generated from jasonsturges/typescript-npm-package
-
Notifications
You must be signed in to change notification settings - Fork 7
/
access-key.ts
26 lines (20 loc) · 955 Bytes
/
access-key.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { SpvWalletClient } from '../dist/typescript-npm-package.cjs.js';
import { exampleXPriv } from './example-keys.js';
import { errMessage } from './utils.js';
const server = 'http://localhost:3003';
if (!exampleXPriv) {
console.log(errMessage('xPriv'));
process.exit(1);
}
const client = new SpvWalletClient(server, {
xPriv: exampleXPriv,
});
const createdAccessKey = await client.CreateAccessKey({ some_metadata: 'example' });
console.log('Created access key ID:', (createdAccessKey.id));
console.log('Metadata:', (createdAccessKey.metadata));
console.log('Created at:', (createdAccessKey.createdAt));
const fetchedAccessKey = await client.GetAccessKeyByID(createdAccessKey.id);
console.log('Fetched access key ID:', (fetchedAccessKey.id));
const revokedAccessKey = await client.RevokeAccessKey(createdAccessKey.id);
console.log('Revoked access key ID:', (revokedAccessKey.id));
console.log('Revoked at:', (revokedAccessKey.revokedAt));