@didcid/keymaster 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/keymaster-client.cjs +272 -123
- package/dist/cjs/keymaster.cjs +298 -15
- package/dist/cjs/node.cjs +1 -0
- package/dist/esm/cli.js +171 -2
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/keymaster-client.js +272 -123
- package/dist/esm/keymaster-client.js.map +1 -1
- package/dist/esm/keymaster.js +287 -16
- package/dist/esm/keymaster.js.map +1 -1
- package/dist/types/keymaster-client.d.ts +20 -1
- package/dist/types/keymaster.d.ts +18 -1
- package/dist/types/types.d.ts +33 -2
- package/package.json +6 -5
|
@@ -11,16 +11,29 @@ function throwError(error) {
|
|
|
11
11
|
}
|
|
12
12
|
export default class KeymasterClient {
|
|
13
13
|
API = "/api/v1";
|
|
14
|
+
axios;
|
|
15
|
+
constructor() {
|
|
16
|
+
this.axios = axios.create();
|
|
17
|
+
}
|
|
14
18
|
// Factory method
|
|
15
19
|
static async create(options) {
|
|
16
20
|
const keymaster = new KeymasterClient();
|
|
17
21
|
await keymaster.connect(options);
|
|
18
22
|
return keymaster;
|
|
19
23
|
}
|
|
24
|
+
addCustomHeader(header, value) {
|
|
25
|
+
this.axios.defaults.headers.common[header] = value;
|
|
26
|
+
}
|
|
27
|
+
removeCustomHeader(header) {
|
|
28
|
+
delete this.axios.defaults.headers.common[header];
|
|
29
|
+
}
|
|
20
30
|
async connect(options = {}) {
|
|
21
31
|
if (options.url) {
|
|
22
32
|
this.API = `${options.url}${VERSION}`;
|
|
23
33
|
}
|
|
34
|
+
if (options.apiKey) {
|
|
35
|
+
this.addCustomHeader('Authorization', `Bearer ${options.apiKey}`);
|
|
36
|
+
}
|
|
24
37
|
// Only used for unit testing
|
|
25
38
|
// TBD replace console with a real logging package
|
|
26
39
|
if (options.console) {
|
|
@@ -62,7 +75,7 @@ export default class KeymasterClient {
|
|
|
62
75
|
}
|
|
63
76
|
async isReady() {
|
|
64
77
|
try {
|
|
65
|
-
const response = await axios.get(`${this.API}/ready`);
|
|
78
|
+
const response = await this.axios.get(`${this.API}/ready`);
|
|
66
79
|
return response.data.ready;
|
|
67
80
|
}
|
|
68
81
|
catch (error) {
|
|
@@ -71,7 +84,7 @@ export default class KeymasterClient {
|
|
|
71
84
|
}
|
|
72
85
|
async loadWallet() {
|
|
73
86
|
try {
|
|
74
|
-
const response = await axios.get(`${this.API}/wallet`);
|
|
87
|
+
const response = await this.axios.get(`${this.API}/wallet`);
|
|
75
88
|
return response.data.wallet;
|
|
76
89
|
}
|
|
77
90
|
catch (error) {
|
|
@@ -80,7 +93,7 @@ export default class KeymasterClient {
|
|
|
80
93
|
}
|
|
81
94
|
async saveWallet(wallet) {
|
|
82
95
|
try {
|
|
83
|
-
const response = await axios.put(`${this.API}/wallet`, { wallet });
|
|
96
|
+
const response = await this.axios.put(`${this.API}/wallet`, { wallet });
|
|
84
97
|
return response.data.ok;
|
|
85
98
|
}
|
|
86
99
|
catch (error) {
|
|
@@ -89,7 +102,7 @@ export default class KeymasterClient {
|
|
|
89
102
|
}
|
|
90
103
|
async newWallet(mnemonic, overwrite = false) {
|
|
91
104
|
try {
|
|
92
|
-
const response = await axios.post(`${this.API}/wallet/new`, { mnemonic, overwrite });
|
|
105
|
+
const response = await this.axios.post(`${this.API}/wallet/new`, { mnemonic, overwrite });
|
|
93
106
|
return response.data.wallet;
|
|
94
107
|
}
|
|
95
108
|
catch (error) {
|
|
@@ -98,7 +111,7 @@ export default class KeymasterClient {
|
|
|
98
111
|
}
|
|
99
112
|
async backupWallet() {
|
|
100
113
|
try {
|
|
101
|
-
const response = await axios.post(`${this.API}/wallet/backup`);
|
|
114
|
+
const response = await this.axios.post(`${this.API}/wallet/backup`);
|
|
102
115
|
return response.data.ok;
|
|
103
116
|
}
|
|
104
117
|
catch (error) {
|
|
@@ -107,7 +120,7 @@ export default class KeymasterClient {
|
|
|
107
120
|
}
|
|
108
121
|
async recoverWallet() {
|
|
109
122
|
try {
|
|
110
|
-
const response = await axios.post(`${this.API}/wallet/recover`);
|
|
123
|
+
const response = await this.axios.post(`${this.API}/wallet/recover`);
|
|
111
124
|
return response.data.wallet;
|
|
112
125
|
}
|
|
113
126
|
catch (error) {
|
|
@@ -116,7 +129,7 @@ export default class KeymasterClient {
|
|
|
116
129
|
}
|
|
117
130
|
async checkWallet() {
|
|
118
131
|
try {
|
|
119
|
-
const response = await axios.post(`${this.API}/wallet/check`);
|
|
132
|
+
const response = await this.axios.post(`${this.API}/wallet/check`);
|
|
120
133
|
return response.data.check;
|
|
121
134
|
}
|
|
122
135
|
catch (error) {
|
|
@@ -125,7 +138,7 @@ export default class KeymasterClient {
|
|
|
125
138
|
}
|
|
126
139
|
async fixWallet() {
|
|
127
140
|
try {
|
|
128
|
-
const response = await axios.post(`${this.API}/wallet/fix`);
|
|
141
|
+
const response = await this.axios.post(`${this.API}/wallet/fix`);
|
|
129
142
|
return response.data.fix;
|
|
130
143
|
}
|
|
131
144
|
catch (error) {
|
|
@@ -134,7 +147,7 @@ export default class KeymasterClient {
|
|
|
134
147
|
}
|
|
135
148
|
async decryptMnemonic() {
|
|
136
149
|
try {
|
|
137
|
-
const response = await axios.get(`${this.API}/wallet/mnemonic`);
|
|
150
|
+
const response = await this.axios.get(`${this.API}/wallet/mnemonic`);
|
|
138
151
|
return response.data.mnemonic;
|
|
139
152
|
}
|
|
140
153
|
catch (error) {
|
|
@@ -143,7 +156,7 @@ export default class KeymasterClient {
|
|
|
143
156
|
}
|
|
144
157
|
async changePassphrase(newPassphrase) {
|
|
145
158
|
try {
|
|
146
|
-
const response = await axios.post(`${this.API}/wallet/passphrase`, { passphrase: newPassphrase });
|
|
159
|
+
const response = await this.axios.post(`${this.API}/wallet/passphrase`, { passphrase: newPassphrase });
|
|
147
160
|
return response.data.ok;
|
|
148
161
|
}
|
|
149
162
|
catch (error) {
|
|
@@ -152,7 +165,7 @@ export default class KeymasterClient {
|
|
|
152
165
|
}
|
|
153
166
|
async listRegistries() {
|
|
154
167
|
try {
|
|
155
|
-
const response = await axios.get(`${this.API}/registries`);
|
|
168
|
+
const response = await this.axios.get(`${this.API}/registries`);
|
|
156
169
|
return response.data.registries;
|
|
157
170
|
}
|
|
158
171
|
catch (error) {
|
|
@@ -161,7 +174,7 @@ export default class KeymasterClient {
|
|
|
161
174
|
}
|
|
162
175
|
async getCurrentId() {
|
|
163
176
|
try {
|
|
164
|
-
const response = await axios.get(`${this.API}/ids/current`);
|
|
177
|
+
const response = await this.axios.get(`${this.API}/ids/current`);
|
|
165
178
|
return response.data.current;
|
|
166
179
|
}
|
|
167
180
|
catch (error) {
|
|
@@ -170,7 +183,7 @@ export default class KeymasterClient {
|
|
|
170
183
|
}
|
|
171
184
|
async setCurrentId(name) {
|
|
172
185
|
try {
|
|
173
|
-
const response = await axios.put(`${this.API}/ids/current`, { name });
|
|
186
|
+
const response = await this.axios.put(`${this.API}/ids/current`, { name });
|
|
174
187
|
return response.data.ok;
|
|
175
188
|
}
|
|
176
189
|
catch (error) {
|
|
@@ -179,7 +192,7 @@ export default class KeymasterClient {
|
|
|
179
192
|
}
|
|
180
193
|
async listIds() {
|
|
181
194
|
try {
|
|
182
|
-
const response = await axios.get(`${this.API}/ids`);
|
|
195
|
+
const response = await this.axios.get(`${this.API}/ids`);
|
|
183
196
|
return response.data.ids;
|
|
184
197
|
}
|
|
185
198
|
catch (error) {
|
|
@@ -188,7 +201,7 @@ export default class KeymasterClient {
|
|
|
188
201
|
}
|
|
189
202
|
async rotateKeys() {
|
|
190
203
|
try {
|
|
191
|
-
const response = await axios.post(`${this.API}/keys/rotate`);
|
|
204
|
+
const response = await this.axios.post(`${this.API}/keys/rotate`);
|
|
192
205
|
return response.data.ok;
|
|
193
206
|
}
|
|
194
207
|
catch (error) {
|
|
@@ -197,7 +210,7 @@ export default class KeymasterClient {
|
|
|
197
210
|
}
|
|
198
211
|
async encryptMessage(msg, receiver, options = {}) {
|
|
199
212
|
try {
|
|
200
|
-
const response = await axios.post(`${this.API}/keys/encrypt/message`, { msg, receiver, options });
|
|
213
|
+
const response = await this.axios.post(`${this.API}/keys/encrypt/message`, { msg, receiver, options });
|
|
201
214
|
return response.data.did;
|
|
202
215
|
}
|
|
203
216
|
catch (error) {
|
|
@@ -206,7 +219,7 @@ export default class KeymasterClient {
|
|
|
206
219
|
}
|
|
207
220
|
async decryptMessage(did) {
|
|
208
221
|
try {
|
|
209
|
-
const response = await axios.post(`${this.API}/keys/decrypt/message`, { did });
|
|
222
|
+
const response = await this.axios.post(`${this.API}/keys/decrypt/message`, { did });
|
|
210
223
|
return response.data.message;
|
|
211
224
|
}
|
|
212
225
|
catch (error) {
|
|
@@ -215,7 +228,7 @@ export default class KeymasterClient {
|
|
|
215
228
|
}
|
|
216
229
|
async encryptJSON(json, receiver, options) {
|
|
217
230
|
try {
|
|
218
|
-
const response = await axios.post(`${this.API}/keys/encrypt/json`, { json, receiver, options });
|
|
231
|
+
const response = await this.axios.post(`${this.API}/keys/encrypt/json`, { json, receiver, options });
|
|
219
232
|
return response.data.did;
|
|
220
233
|
}
|
|
221
234
|
catch (error) {
|
|
@@ -224,7 +237,7 @@ export default class KeymasterClient {
|
|
|
224
237
|
}
|
|
225
238
|
async decryptJSON(did) {
|
|
226
239
|
try {
|
|
227
|
-
const response = await axios.post(`${this.API}/keys/decrypt/json`, { did });
|
|
240
|
+
const response = await this.axios.post(`${this.API}/keys/decrypt/json`, { did });
|
|
228
241
|
return response.data.json;
|
|
229
242
|
}
|
|
230
243
|
catch (error) {
|
|
@@ -233,7 +246,7 @@ export default class KeymasterClient {
|
|
|
233
246
|
}
|
|
234
247
|
async createId(name, options) {
|
|
235
248
|
try {
|
|
236
|
-
const response = await axios.post(`${this.API}/ids`, { name, options });
|
|
249
|
+
const response = await this.axios.post(`${this.API}/ids`, { name, options });
|
|
237
250
|
return response.data.did;
|
|
238
251
|
}
|
|
239
252
|
catch (error) {
|
|
@@ -242,7 +255,7 @@ export default class KeymasterClient {
|
|
|
242
255
|
}
|
|
243
256
|
async removeId(id) {
|
|
244
257
|
try {
|
|
245
|
-
const response = await axios.delete(`${this.API}/ids/${id}`);
|
|
258
|
+
const response = await this.axios.delete(`${this.API}/ids/${id}`);
|
|
246
259
|
return response.data.ok;
|
|
247
260
|
}
|
|
248
261
|
catch (error) {
|
|
@@ -251,7 +264,7 @@ export default class KeymasterClient {
|
|
|
251
264
|
}
|
|
252
265
|
async renameId(id, name) {
|
|
253
266
|
try {
|
|
254
|
-
const response = await axios.post(`${this.API}/ids/${id}/rename`, { name });
|
|
267
|
+
const response = await this.axios.post(`${this.API}/ids/${id}/rename`, { name });
|
|
255
268
|
return response.data.ok;
|
|
256
269
|
}
|
|
257
270
|
catch (error) {
|
|
@@ -263,7 +276,7 @@ export default class KeymasterClient {
|
|
|
263
276
|
if (!id) {
|
|
264
277
|
id = await this.getCurrentId();
|
|
265
278
|
}
|
|
266
|
-
const response = await axios.post(`${this.API}/ids/${id}/backup`);
|
|
279
|
+
const response = await this.axios.post(`${this.API}/ids/${id}/backup`);
|
|
267
280
|
return response.data.ok;
|
|
268
281
|
}
|
|
269
282
|
catch (error) {
|
|
@@ -272,7 +285,7 @@ export default class KeymasterClient {
|
|
|
272
285
|
}
|
|
273
286
|
async recoverId(did) {
|
|
274
287
|
try {
|
|
275
|
-
const response = await axios.post(`${this.API}/ids/${did}/recover`);
|
|
288
|
+
const response = await this.axios.post(`${this.API}/ids/${did}/recover`);
|
|
276
289
|
return response.data.recovered;
|
|
277
290
|
}
|
|
278
291
|
catch (error) {
|
|
@@ -281,7 +294,7 @@ export default class KeymasterClient {
|
|
|
281
294
|
}
|
|
282
295
|
async listAliases() {
|
|
283
296
|
try {
|
|
284
|
-
const response = await axios.get(`${this.API}/aliases`);
|
|
297
|
+
const response = await this.axios.get(`${this.API}/aliases`);
|
|
285
298
|
return response.data.aliases;
|
|
286
299
|
}
|
|
287
300
|
catch (error) {
|
|
@@ -290,7 +303,7 @@ export default class KeymasterClient {
|
|
|
290
303
|
}
|
|
291
304
|
async addAlias(alias, did) {
|
|
292
305
|
try {
|
|
293
|
-
const response = await axios.post(`${this.API}/aliases`, { alias, did });
|
|
306
|
+
const response = await this.axios.post(`${this.API}/aliases`, { alias, did });
|
|
294
307
|
return response.data.ok;
|
|
295
308
|
}
|
|
296
309
|
catch (error) {
|
|
@@ -299,7 +312,7 @@ export default class KeymasterClient {
|
|
|
299
312
|
}
|
|
300
313
|
async getAlias(alias) {
|
|
301
314
|
try {
|
|
302
|
-
const response = await axios.get(`${this.API}/aliases/${alias}`);
|
|
315
|
+
const response = await this.axios.get(`${this.API}/aliases/${alias}`);
|
|
303
316
|
return response.data.did;
|
|
304
317
|
}
|
|
305
318
|
catch (error) {
|
|
@@ -308,22 +321,158 @@ export default class KeymasterClient {
|
|
|
308
321
|
}
|
|
309
322
|
async removeAlias(alias) {
|
|
310
323
|
try {
|
|
311
|
-
const response = await axios.delete(`${this.API}/aliases/${alias}`);
|
|
324
|
+
const response = await this.axios.delete(`${this.API}/aliases/${alias}`);
|
|
325
|
+
return response.data.ok;
|
|
326
|
+
}
|
|
327
|
+
catch (error) {
|
|
328
|
+
throwError(error);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
async addNostr(id) {
|
|
332
|
+
try {
|
|
333
|
+
const response = await this.axios.post(`${this.API}/nostr`, { id });
|
|
334
|
+
return response.data;
|
|
335
|
+
}
|
|
336
|
+
catch (error) {
|
|
337
|
+
throwError(error);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
async removeNostr(id) {
|
|
341
|
+
try {
|
|
342
|
+
const response = await this.axios.delete(`${this.API}/nostr`, { data: { id } });
|
|
343
|
+
return response.data.ok;
|
|
344
|
+
}
|
|
345
|
+
catch (error) {
|
|
346
|
+
throwError(error);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
async exportNsec(id) {
|
|
350
|
+
try {
|
|
351
|
+
const response = await this.axios.post(`${this.API}/nostr/nsec`, { id });
|
|
352
|
+
return response.data.nsec;
|
|
353
|
+
}
|
|
354
|
+
catch (error) {
|
|
355
|
+
throwError(error);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
async signNostrEvent(event) {
|
|
359
|
+
try {
|
|
360
|
+
const response = await this.axios.post(`${this.API}/nostr/sign`, { event });
|
|
361
|
+
return response.data;
|
|
362
|
+
}
|
|
363
|
+
catch (error) {
|
|
364
|
+
throwError(error);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
// Lightning
|
|
368
|
+
async addLightning(id) {
|
|
369
|
+
try {
|
|
370
|
+
const response = await this.axios.post(`${this.API}/lightning`, { id });
|
|
371
|
+
return response.data;
|
|
372
|
+
}
|
|
373
|
+
catch (error) {
|
|
374
|
+
throwError(error);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
async removeLightning(id) {
|
|
378
|
+
try {
|
|
379
|
+
const response = await this.axios.delete(`${this.API}/lightning`, { data: { id } });
|
|
312
380
|
return response.data.ok;
|
|
313
381
|
}
|
|
314
382
|
catch (error) {
|
|
315
383
|
throwError(error);
|
|
316
384
|
}
|
|
317
385
|
}
|
|
386
|
+
async getLightningBalance(id) {
|
|
387
|
+
try {
|
|
388
|
+
const response = await this.axios.post(`${this.API}/lightning/balance`, { id });
|
|
389
|
+
return response.data;
|
|
390
|
+
}
|
|
391
|
+
catch (error) {
|
|
392
|
+
throwError(error);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
async createLightningInvoice(amount, memo, id) {
|
|
396
|
+
try {
|
|
397
|
+
const response = await this.axios.post(`${this.API}/lightning/invoice`, { amount, memo, id });
|
|
398
|
+
return response.data;
|
|
399
|
+
}
|
|
400
|
+
catch (error) {
|
|
401
|
+
throwError(error);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
async payLightningInvoice(bolt11, id) {
|
|
405
|
+
try {
|
|
406
|
+
const response = await this.axios.post(`${this.API}/lightning/pay`, { bolt11, id });
|
|
407
|
+
return response.data;
|
|
408
|
+
}
|
|
409
|
+
catch (error) {
|
|
410
|
+
throwError(error);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
async checkLightningPayment(paymentHash, id) {
|
|
414
|
+
try {
|
|
415
|
+
const response = await this.axios.post(`${this.API}/lightning/payment`, { paymentHash, id });
|
|
416
|
+
return response.data;
|
|
417
|
+
}
|
|
418
|
+
catch (error) {
|
|
419
|
+
throwError(error);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
async decodeLightningInvoice(bolt11) {
|
|
423
|
+
try {
|
|
424
|
+
const response = await this.axios.post(`${this.API}/lightning/decode`, { bolt11 });
|
|
425
|
+
return response.data;
|
|
426
|
+
}
|
|
427
|
+
catch (error) {
|
|
428
|
+
throwError(error);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
async publishLightning(name) {
|
|
432
|
+
try {
|
|
433
|
+
const response = await this.axios.post(`${this.API}/lightning/publish`, { id: name });
|
|
434
|
+
return response.data.ok;
|
|
435
|
+
}
|
|
436
|
+
catch (error) {
|
|
437
|
+
throwError(error);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
async unpublishLightning(name) {
|
|
441
|
+
try {
|
|
442
|
+
const response = await this.axios.post(`${this.API}/lightning/unpublish`, { id: name });
|
|
443
|
+
return response.data.ok;
|
|
444
|
+
}
|
|
445
|
+
catch (error) {
|
|
446
|
+
throwError(error);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
async zapLightning(did, amount, memo, name) {
|
|
450
|
+
try {
|
|
451
|
+
const response = await this.axios.post(`${this.API}/lightning/zap`, { did, amount, memo, id: name });
|
|
452
|
+
return response.data;
|
|
453
|
+
}
|
|
454
|
+
catch (error) {
|
|
455
|
+
throwError(error);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
async getLightningPayments(name) {
|
|
459
|
+
try {
|
|
460
|
+
const response = await this.axios.post(`${this.API}/lightning/payments`, { id: name });
|
|
461
|
+
return response.data.payments;
|
|
462
|
+
}
|
|
463
|
+
catch (error) {
|
|
464
|
+
throwError(error);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
318
467
|
async resolveDID(id, options) {
|
|
319
468
|
try {
|
|
320
469
|
if (options) {
|
|
321
470
|
const queryParams = new URLSearchParams(options);
|
|
322
|
-
const response = await axios.get(`${this.API}/did/${id}?${queryParams.toString()}`);
|
|
471
|
+
const response = await this.axios.get(`${this.API}/did/${id}?${queryParams.toString()}`);
|
|
323
472
|
return response.data.docs;
|
|
324
473
|
}
|
|
325
474
|
else {
|
|
326
|
-
const response = await axios.get(`${this.API}/did/${id}`);
|
|
475
|
+
const response = await this.axios.get(`${this.API}/did/${id}`);
|
|
327
476
|
return response.data.docs;
|
|
328
477
|
}
|
|
329
478
|
}
|
|
@@ -333,7 +482,7 @@ export default class KeymasterClient {
|
|
|
333
482
|
}
|
|
334
483
|
async updateDID(id, doc) {
|
|
335
484
|
try {
|
|
336
|
-
const response = await axios.put(`${this.API}/did/${id}`, { doc });
|
|
485
|
+
const response = await this.axios.put(`${this.API}/did/${id}`, { doc });
|
|
337
486
|
return response.data.ok;
|
|
338
487
|
}
|
|
339
488
|
catch (error) {
|
|
@@ -342,7 +491,7 @@ export default class KeymasterClient {
|
|
|
342
491
|
}
|
|
343
492
|
async revokeDID(id) {
|
|
344
493
|
try {
|
|
345
|
-
const response = await axios.delete(`${this.API}/did/${id}`);
|
|
494
|
+
const response = await this.axios.delete(`${this.API}/did/${id}`);
|
|
346
495
|
return response.data.ok;
|
|
347
496
|
}
|
|
348
497
|
catch (error) {
|
|
@@ -351,7 +500,7 @@ export default class KeymasterClient {
|
|
|
351
500
|
}
|
|
352
501
|
async createAsset(data, options) {
|
|
353
502
|
try {
|
|
354
|
-
const response = await axios.post(`${this.API}/assets`, { data, options });
|
|
503
|
+
const response = await this.axios.post(`${this.API}/assets`, { data, options });
|
|
355
504
|
return response.data.did;
|
|
356
505
|
}
|
|
357
506
|
catch (error) {
|
|
@@ -360,7 +509,7 @@ export default class KeymasterClient {
|
|
|
360
509
|
}
|
|
361
510
|
async cloneAsset(id, options) {
|
|
362
511
|
try {
|
|
363
|
-
const response = await axios.post(`${this.API}/assets/${id}/clone`, { options });
|
|
512
|
+
const response = await this.axios.post(`${this.API}/assets/${id}/clone`, { options });
|
|
364
513
|
return response.data.did;
|
|
365
514
|
}
|
|
366
515
|
catch (error) {
|
|
@@ -369,7 +518,7 @@ export default class KeymasterClient {
|
|
|
369
518
|
}
|
|
370
519
|
async listAssets() {
|
|
371
520
|
try {
|
|
372
|
-
const response = await axios.get(`${this.API}/assets`);
|
|
521
|
+
const response = await this.axios.get(`${this.API}/assets`);
|
|
373
522
|
return response.data.assets;
|
|
374
523
|
}
|
|
375
524
|
catch (error) {
|
|
@@ -380,11 +529,11 @@ export default class KeymasterClient {
|
|
|
380
529
|
try {
|
|
381
530
|
if (options) {
|
|
382
531
|
const queryParams = new URLSearchParams(options);
|
|
383
|
-
const response = await axios.get(`${this.API}/assets/${id}?${queryParams.toString()}`);
|
|
532
|
+
const response = await this.axios.get(`${this.API}/assets/${id}?${queryParams.toString()}`);
|
|
384
533
|
return response.data.asset;
|
|
385
534
|
}
|
|
386
535
|
else {
|
|
387
|
-
const response = await axios.get(`${this.API}/assets/${id}`);
|
|
536
|
+
const response = await this.axios.get(`${this.API}/assets/${id}`);
|
|
388
537
|
return response.data.asset;
|
|
389
538
|
}
|
|
390
539
|
}
|
|
@@ -394,7 +543,7 @@ export default class KeymasterClient {
|
|
|
394
543
|
}
|
|
395
544
|
async mergeData(id, data) {
|
|
396
545
|
try {
|
|
397
|
-
const response = await axios.put(`${this.API}/assets/${id}`, { data });
|
|
546
|
+
const response = await this.axios.put(`${this.API}/assets/${id}`, { data });
|
|
398
547
|
return response.data.ok;
|
|
399
548
|
}
|
|
400
549
|
catch (error) {
|
|
@@ -403,7 +552,7 @@ export default class KeymasterClient {
|
|
|
403
552
|
}
|
|
404
553
|
async transferAsset(id, controller) {
|
|
405
554
|
try {
|
|
406
|
-
const response = await axios.post(`${this.API}/assets/${id}/transfer`, { controller });
|
|
555
|
+
const response = await this.axios.post(`${this.API}/assets/${id}/transfer`, { controller });
|
|
407
556
|
return response.data.ok;
|
|
408
557
|
}
|
|
409
558
|
catch (error) {
|
|
@@ -412,7 +561,7 @@ export default class KeymasterClient {
|
|
|
412
561
|
}
|
|
413
562
|
async createChallenge(challenge = {}, options = {}) {
|
|
414
563
|
try {
|
|
415
|
-
const response = await axios.post(`${this.API}/challenge`, { challenge, options });
|
|
564
|
+
const response = await this.axios.post(`${this.API}/challenge`, { challenge, options });
|
|
416
565
|
return response.data.did;
|
|
417
566
|
}
|
|
418
567
|
catch (error) {
|
|
@@ -421,7 +570,7 @@ export default class KeymasterClient {
|
|
|
421
570
|
}
|
|
422
571
|
async createResponse(challenge, options) {
|
|
423
572
|
try {
|
|
424
|
-
const response = await axios.post(`${this.API}/response`, { challenge, options });
|
|
573
|
+
const response = await this.axios.post(`${this.API}/response`, { challenge, options });
|
|
425
574
|
return response.data.did;
|
|
426
575
|
}
|
|
427
576
|
catch (error) {
|
|
@@ -430,7 +579,7 @@ export default class KeymasterClient {
|
|
|
430
579
|
}
|
|
431
580
|
async verifyResponse(responseDID, options) {
|
|
432
581
|
try {
|
|
433
|
-
const response = await axios.post(`${this.API}/response/verify`, { response: responseDID, options });
|
|
582
|
+
const response = await this.axios.post(`${this.API}/response/verify`, { response: responseDID, options });
|
|
434
583
|
return response.data.verify;
|
|
435
584
|
}
|
|
436
585
|
catch (error) {
|
|
@@ -439,7 +588,7 @@ export default class KeymasterClient {
|
|
|
439
588
|
}
|
|
440
589
|
async createGroup(name, options) {
|
|
441
590
|
try {
|
|
442
|
-
const response = await axios.post(`${this.API}/groups`, { name, options });
|
|
591
|
+
const response = await this.axios.post(`${this.API}/groups`, { name, options });
|
|
443
592
|
return response.data.did;
|
|
444
593
|
}
|
|
445
594
|
catch (error) {
|
|
@@ -448,7 +597,7 @@ export default class KeymasterClient {
|
|
|
448
597
|
}
|
|
449
598
|
async getGroup(group) {
|
|
450
599
|
try {
|
|
451
|
-
const response = await axios.get(`${this.API}/groups/${group}`);
|
|
600
|
+
const response = await this.axios.get(`${this.API}/groups/${group}`);
|
|
452
601
|
return response.data.group;
|
|
453
602
|
}
|
|
454
603
|
catch (error) {
|
|
@@ -457,7 +606,7 @@ export default class KeymasterClient {
|
|
|
457
606
|
}
|
|
458
607
|
async addGroupMember(group, member) {
|
|
459
608
|
try {
|
|
460
|
-
const response = await axios.post(`${this.API}/groups/${group}/add`, { member });
|
|
609
|
+
const response = await this.axios.post(`${this.API}/groups/${group}/add`, { member });
|
|
461
610
|
return response.data.ok;
|
|
462
611
|
}
|
|
463
612
|
catch (error) {
|
|
@@ -466,7 +615,7 @@ export default class KeymasterClient {
|
|
|
466
615
|
}
|
|
467
616
|
async removeGroupMember(group, member) {
|
|
468
617
|
try {
|
|
469
|
-
const response = await axios.post(`${this.API}/groups/${group}/remove`, { member });
|
|
618
|
+
const response = await this.axios.post(`${this.API}/groups/${group}/remove`, { member });
|
|
470
619
|
return response.data.ok;
|
|
471
620
|
}
|
|
472
621
|
catch (error) {
|
|
@@ -475,7 +624,7 @@ export default class KeymasterClient {
|
|
|
475
624
|
}
|
|
476
625
|
async testGroup(group, member) {
|
|
477
626
|
try {
|
|
478
|
-
const response = await axios.post(`${this.API}/groups/${group}/test`, { member });
|
|
627
|
+
const response = await this.axios.post(`${this.API}/groups/${group}/test`, { member });
|
|
479
628
|
return response.data.test;
|
|
480
629
|
}
|
|
481
630
|
catch (error) {
|
|
@@ -485,11 +634,11 @@ export default class KeymasterClient {
|
|
|
485
634
|
async listGroups(owner) {
|
|
486
635
|
try {
|
|
487
636
|
if (owner) {
|
|
488
|
-
const response = await axios.get(`${this.API}/groups?owner=${owner}`);
|
|
637
|
+
const response = await this.axios.get(`${this.API}/groups?owner=${owner}`);
|
|
489
638
|
return response.data.groups;
|
|
490
639
|
}
|
|
491
640
|
else {
|
|
492
|
-
const response = await axios.get(`${this.API}/groups`);
|
|
641
|
+
const response = await this.axios.get(`${this.API}/groups`);
|
|
493
642
|
return response.data.groups;
|
|
494
643
|
}
|
|
495
644
|
}
|
|
@@ -499,7 +648,7 @@ export default class KeymasterClient {
|
|
|
499
648
|
}
|
|
500
649
|
async createSchema(schema, options) {
|
|
501
650
|
try {
|
|
502
|
-
const response = await axios.post(`${this.API}/schemas`, { schema, options });
|
|
651
|
+
const response = await this.axios.post(`${this.API}/schemas`, { schema, options });
|
|
503
652
|
return response.data.did;
|
|
504
653
|
}
|
|
505
654
|
catch (error) {
|
|
@@ -508,7 +657,7 @@ export default class KeymasterClient {
|
|
|
508
657
|
}
|
|
509
658
|
async getSchema(id) {
|
|
510
659
|
try {
|
|
511
|
-
const response = await axios.get(`${this.API}/schemas/${id}`);
|
|
660
|
+
const response = await this.axios.get(`${this.API}/schemas/${id}`);
|
|
512
661
|
return response.data.schema;
|
|
513
662
|
}
|
|
514
663
|
catch (error) {
|
|
@@ -517,7 +666,7 @@ export default class KeymasterClient {
|
|
|
517
666
|
}
|
|
518
667
|
async setSchema(id, schema) {
|
|
519
668
|
try {
|
|
520
|
-
const response = await axios.put(`${this.API}/schemas/${id}`, { schema });
|
|
669
|
+
const response = await this.axios.put(`${this.API}/schemas/${id}`, { schema });
|
|
521
670
|
return response.data.ok;
|
|
522
671
|
}
|
|
523
672
|
catch (error) {
|
|
@@ -526,7 +675,7 @@ export default class KeymasterClient {
|
|
|
526
675
|
}
|
|
527
676
|
async testSchema(id) {
|
|
528
677
|
try {
|
|
529
|
-
const response = await axios.post(`${this.API}/schemas/${id}/test`);
|
|
678
|
+
const response = await this.axios.post(`${this.API}/schemas/${id}/test`);
|
|
530
679
|
return response.data.test;
|
|
531
680
|
}
|
|
532
681
|
catch (error) {
|
|
@@ -536,11 +685,11 @@ export default class KeymasterClient {
|
|
|
536
685
|
async listSchemas(owner) {
|
|
537
686
|
try {
|
|
538
687
|
if (owner) {
|
|
539
|
-
const response = await axios.get(`${this.API}/schemas?owner=${owner}`);
|
|
688
|
+
const response = await this.axios.get(`${this.API}/schemas?owner=${owner}`);
|
|
540
689
|
return response.data.schemas;
|
|
541
690
|
}
|
|
542
691
|
else {
|
|
543
|
-
const response = await axios.get(`${this.API}/schemas`);
|
|
692
|
+
const response = await this.axios.get(`${this.API}/schemas`);
|
|
544
693
|
return response.data.schemas;
|
|
545
694
|
}
|
|
546
695
|
}
|
|
@@ -550,7 +699,7 @@ export default class KeymasterClient {
|
|
|
550
699
|
}
|
|
551
700
|
async createTemplate(schemaId) {
|
|
552
701
|
try {
|
|
553
|
-
const response = await axios.post(`${this.API}/schemas/${schemaId}/template`);
|
|
702
|
+
const response = await this.axios.post(`${this.API}/schemas/${schemaId}/template`);
|
|
554
703
|
return response.data.template;
|
|
555
704
|
}
|
|
556
705
|
catch (error) {
|
|
@@ -559,7 +708,7 @@ export default class KeymasterClient {
|
|
|
559
708
|
}
|
|
560
709
|
async testAgent(id) {
|
|
561
710
|
try {
|
|
562
|
-
const response = await axios.post(`${this.API}/agents/${id}/test`);
|
|
711
|
+
const response = await this.axios.post(`${this.API}/agents/${id}/test`);
|
|
563
712
|
return response.data.test;
|
|
564
713
|
}
|
|
565
714
|
catch (error) {
|
|
@@ -568,7 +717,7 @@ export default class KeymasterClient {
|
|
|
568
717
|
}
|
|
569
718
|
async bindCredential(subject, options) {
|
|
570
719
|
try {
|
|
571
|
-
const response = await axios.post(`${this.API}/credentials/bind`, { subject, options });
|
|
720
|
+
const response = await this.axios.post(`${this.API}/credentials/bind`, { subject, options });
|
|
572
721
|
return response.data.credential;
|
|
573
722
|
}
|
|
574
723
|
catch (error) {
|
|
@@ -577,7 +726,7 @@ export default class KeymasterClient {
|
|
|
577
726
|
}
|
|
578
727
|
async issueCredential(credential, options) {
|
|
579
728
|
try {
|
|
580
|
-
const response = await axios.post(`${this.API}/credentials/issued`, { credential, options });
|
|
729
|
+
const response = await this.axios.post(`${this.API}/credentials/issued`, { credential, options });
|
|
581
730
|
return response.data.did;
|
|
582
731
|
}
|
|
583
732
|
catch (error) {
|
|
@@ -586,7 +735,7 @@ export default class KeymasterClient {
|
|
|
586
735
|
}
|
|
587
736
|
async sendCredential(did, options) {
|
|
588
737
|
try {
|
|
589
|
-
const response = await axios.post(`${this.API}/credentials/issued/${did}/send`, { options });
|
|
738
|
+
const response = await this.axios.post(`${this.API}/credentials/issued/${did}/send`, { options });
|
|
590
739
|
return response.data.did;
|
|
591
740
|
}
|
|
592
741
|
catch (error) {
|
|
@@ -595,7 +744,7 @@ export default class KeymasterClient {
|
|
|
595
744
|
}
|
|
596
745
|
async updateCredential(did, credential) {
|
|
597
746
|
try {
|
|
598
|
-
const response = await axios.post(`${this.API}/credentials/issued/${did}`, { credential });
|
|
747
|
+
const response = await this.axios.post(`${this.API}/credentials/issued/${did}`, { credential });
|
|
599
748
|
return response.data.ok;
|
|
600
749
|
}
|
|
601
750
|
catch (error) {
|
|
@@ -604,7 +753,7 @@ export default class KeymasterClient {
|
|
|
604
753
|
}
|
|
605
754
|
async listCredentials() {
|
|
606
755
|
try {
|
|
607
|
-
const response = await axios.get(`${this.API}/credentials/held`);
|
|
756
|
+
const response = await this.axios.get(`${this.API}/credentials/held`);
|
|
608
757
|
return response.data.held;
|
|
609
758
|
}
|
|
610
759
|
catch (error) {
|
|
@@ -613,7 +762,7 @@ export default class KeymasterClient {
|
|
|
613
762
|
}
|
|
614
763
|
async acceptCredential(did) {
|
|
615
764
|
try {
|
|
616
|
-
const response = await axios.post(`${this.API}/credentials/held`, { did });
|
|
765
|
+
const response = await this.axios.post(`${this.API}/credentials/held`, { did });
|
|
617
766
|
return response.data.ok;
|
|
618
767
|
}
|
|
619
768
|
catch (error) {
|
|
@@ -622,7 +771,7 @@ export default class KeymasterClient {
|
|
|
622
771
|
}
|
|
623
772
|
async getCredential(did) {
|
|
624
773
|
try {
|
|
625
|
-
const response = await axios.get(`${this.API}/credentials/held/${did}`);
|
|
774
|
+
const response = await this.axios.get(`${this.API}/credentials/held/${did}`);
|
|
626
775
|
return response.data.credential;
|
|
627
776
|
}
|
|
628
777
|
catch (error) {
|
|
@@ -631,7 +780,7 @@ export default class KeymasterClient {
|
|
|
631
780
|
}
|
|
632
781
|
async removeCredential(did) {
|
|
633
782
|
try {
|
|
634
|
-
const response = await axios.delete(`${this.API}/credentials/held/${did}`);
|
|
783
|
+
const response = await this.axios.delete(`${this.API}/credentials/held/${did}`);
|
|
635
784
|
return response.data.ok;
|
|
636
785
|
}
|
|
637
786
|
catch (error) {
|
|
@@ -640,7 +789,7 @@ export default class KeymasterClient {
|
|
|
640
789
|
}
|
|
641
790
|
async publishCredential(did, options) {
|
|
642
791
|
try {
|
|
643
|
-
const response = await axios.post(`${this.API}/credentials/held/${did}/publish`, { options });
|
|
792
|
+
const response = await this.axios.post(`${this.API}/credentials/held/${did}/publish`, { options });
|
|
644
793
|
return response.data.ok;
|
|
645
794
|
}
|
|
646
795
|
catch (error) {
|
|
@@ -649,7 +798,7 @@ export default class KeymasterClient {
|
|
|
649
798
|
}
|
|
650
799
|
async unpublishCredential(did) {
|
|
651
800
|
try {
|
|
652
|
-
const response = await axios.post(`${this.API}/credentials/held/${did}/unpublish`);
|
|
801
|
+
const response = await this.axios.post(`${this.API}/credentials/held/${did}/unpublish`);
|
|
653
802
|
return response.data.ok;
|
|
654
803
|
}
|
|
655
804
|
catch (error) {
|
|
@@ -658,7 +807,7 @@ export default class KeymasterClient {
|
|
|
658
807
|
}
|
|
659
808
|
async listIssued() {
|
|
660
809
|
try {
|
|
661
|
-
const response = await axios.get(`${this.API}/credentials/issued`);
|
|
810
|
+
const response = await this.axios.get(`${this.API}/credentials/issued`);
|
|
662
811
|
return response.data.issued;
|
|
663
812
|
}
|
|
664
813
|
catch (error) {
|
|
@@ -667,7 +816,7 @@ export default class KeymasterClient {
|
|
|
667
816
|
}
|
|
668
817
|
async revokeCredential(did) {
|
|
669
818
|
try {
|
|
670
|
-
const response = await axios.delete(`${this.API}/credentials/issued/${did}`);
|
|
819
|
+
const response = await this.axios.delete(`${this.API}/credentials/issued/${did}`);
|
|
671
820
|
return response.data.ok;
|
|
672
821
|
}
|
|
673
822
|
catch (error) {
|
|
@@ -676,7 +825,7 @@ export default class KeymasterClient {
|
|
|
676
825
|
}
|
|
677
826
|
async pollTemplate() {
|
|
678
827
|
try {
|
|
679
|
-
const response = await axios.get(`${this.API}/templates/poll`);
|
|
828
|
+
const response = await this.axios.get(`${this.API}/templates/poll`);
|
|
680
829
|
return response.data.template;
|
|
681
830
|
}
|
|
682
831
|
catch (error) {
|
|
@@ -685,7 +834,7 @@ export default class KeymasterClient {
|
|
|
685
834
|
}
|
|
686
835
|
async createPoll(config, options) {
|
|
687
836
|
try {
|
|
688
|
-
const response = await axios.post(`${this.API}/polls`, { poll: config, options });
|
|
837
|
+
const response = await this.axios.post(`${this.API}/polls`, { poll: config, options });
|
|
689
838
|
return response.data.did;
|
|
690
839
|
}
|
|
691
840
|
catch (error) {
|
|
@@ -694,7 +843,7 @@ export default class KeymasterClient {
|
|
|
694
843
|
}
|
|
695
844
|
async getPoll(pollId) {
|
|
696
845
|
try {
|
|
697
|
-
const response = await axios.get(`${this.API}/polls/${pollId}`);
|
|
846
|
+
const response = await this.axios.get(`${this.API}/polls/${pollId}`);
|
|
698
847
|
return response.data.poll;
|
|
699
848
|
}
|
|
700
849
|
catch (error) {
|
|
@@ -703,7 +852,7 @@ export default class KeymasterClient {
|
|
|
703
852
|
}
|
|
704
853
|
async testPoll(id) {
|
|
705
854
|
try {
|
|
706
|
-
const response = await axios.get(`${this.API}/polls/${id}/test`);
|
|
855
|
+
const response = await this.axios.get(`${this.API}/polls/${id}/test`);
|
|
707
856
|
return response.data.test;
|
|
708
857
|
}
|
|
709
858
|
catch (error) {
|
|
@@ -712,7 +861,7 @@ export default class KeymasterClient {
|
|
|
712
861
|
}
|
|
713
862
|
async listPolls(owner) {
|
|
714
863
|
try {
|
|
715
|
-
const response = await axios.get(`${this.API}/polls`, { params: { owner } });
|
|
864
|
+
const response = await this.axios.get(`${this.API}/polls`, { params: { owner } });
|
|
716
865
|
return response.data.polls;
|
|
717
866
|
}
|
|
718
867
|
catch (error) {
|
|
@@ -721,7 +870,7 @@ export default class KeymasterClient {
|
|
|
721
870
|
}
|
|
722
871
|
async viewPoll(pollId) {
|
|
723
872
|
try {
|
|
724
|
-
const response = await axios.get(`${this.API}/polls/${pollId}/view`);
|
|
873
|
+
const response = await this.axios.get(`${this.API}/polls/${pollId}/view`);
|
|
725
874
|
return response.data.poll;
|
|
726
875
|
}
|
|
727
876
|
catch (error) {
|
|
@@ -730,7 +879,7 @@ export default class KeymasterClient {
|
|
|
730
879
|
}
|
|
731
880
|
async votePoll(pollId, vote, options) {
|
|
732
881
|
try {
|
|
733
|
-
const response = await axios.post(`${this.API}/polls/${pollId}/vote`, { vote, options });
|
|
882
|
+
const response = await this.axios.post(`${this.API}/polls/${pollId}/vote`, { vote, options });
|
|
734
883
|
return response.data.did;
|
|
735
884
|
}
|
|
736
885
|
catch (error) {
|
|
@@ -739,7 +888,7 @@ export default class KeymasterClient {
|
|
|
739
888
|
}
|
|
740
889
|
async sendPoll(pollId) {
|
|
741
890
|
try {
|
|
742
|
-
const response = await axios.post(`${this.API}/polls/${pollId}/send`);
|
|
891
|
+
const response = await this.axios.post(`${this.API}/polls/${pollId}/send`);
|
|
743
892
|
return response.data.did;
|
|
744
893
|
}
|
|
745
894
|
catch (error) {
|
|
@@ -748,7 +897,7 @@ export default class KeymasterClient {
|
|
|
748
897
|
}
|
|
749
898
|
async sendBallot(ballotDid, pollId) {
|
|
750
899
|
try {
|
|
751
|
-
const response = await axios.post(`${this.API}/polls/ballot/send`, { ballot: ballotDid, poll: pollId });
|
|
900
|
+
const response = await this.axios.post(`${this.API}/polls/ballot/send`, { ballot: ballotDid, poll: pollId });
|
|
752
901
|
return response.data.did;
|
|
753
902
|
}
|
|
754
903
|
catch (error) {
|
|
@@ -757,7 +906,7 @@ export default class KeymasterClient {
|
|
|
757
906
|
}
|
|
758
907
|
async viewBallot(ballotDid) {
|
|
759
908
|
try {
|
|
760
|
-
const response = await axios.get(`${this.API}/polls/ballot/${ballotDid}`);
|
|
909
|
+
const response = await this.axios.get(`${this.API}/polls/ballot/${ballotDid}`);
|
|
761
910
|
return response.data.ballot;
|
|
762
911
|
}
|
|
763
912
|
catch (error) {
|
|
@@ -766,7 +915,7 @@ export default class KeymasterClient {
|
|
|
766
915
|
}
|
|
767
916
|
async updatePoll(ballot) {
|
|
768
917
|
try {
|
|
769
|
-
const response = await axios.put(`${this.API}/polls/update`, { ballot });
|
|
918
|
+
const response = await this.axios.put(`${this.API}/polls/update`, { ballot });
|
|
770
919
|
return response.data.ok;
|
|
771
920
|
}
|
|
772
921
|
catch (error) {
|
|
@@ -775,7 +924,7 @@ export default class KeymasterClient {
|
|
|
775
924
|
}
|
|
776
925
|
async publishPoll(pollId, options) {
|
|
777
926
|
try {
|
|
778
|
-
const response = await axios.post(`${this.API}/polls/${pollId}/publish`, { options });
|
|
927
|
+
const response = await this.axios.post(`${this.API}/polls/${pollId}/publish`, { options });
|
|
779
928
|
return response.data.ok;
|
|
780
929
|
}
|
|
781
930
|
catch (error) {
|
|
@@ -784,7 +933,7 @@ export default class KeymasterClient {
|
|
|
784
933
|
}
|
|
785
934
|
async unpublishPoll(pollId) {
|
|
786
935
|
try {
|
|
787
|
-
const response = await axios.post(`${this.API}/polls/${pollId}/unpublish`);
|
|
936
|
+
const response = await this.axios.post(`${this.API}/polls/${pollId}/unpublish`);
|
|
788
937
|
return response.data.ok;
|
|
789
938
|
}
|
|
790
939
|
catch (error) {
|
|
@@ -793,7 +942,7 @@ export default class KeymasterClient {
|
|
|
793
942
|
}
|
|
794
943
|
async addPollVoter(pollId, memberId) {
|
|
795
944
|
try {
|
|
796
|
-
const response = await axios.post(`${this.API}/polls/${pollId}/voters`, { memberId });
|
|
945
|
+
const response = await this.axios.post(`${this.API}/polls/${pollId}/voters`, { memberId });
|
|
797
946
|
return response.data.ok;
|
|
798
947
|
}
|
|
799
948
|
catch (error) {
|
|
@@ -802,7 +951,7 @@ export default class KeymasterClient {
|
|
|
802
951
|
}
|
|
803
952
|
async removePollVoter(pollId, memberId) {
|
|
804
953
|
try {
|
|
805
|
-
const response = await axios.delete(`${this.API}/polls/${pollId}/voters/${memberId}`);
|
|
954
|
+
const response = await this.axios.delete(`${this.API}/polls/${pollId}/voters/${memberId}`);
|
|
806
955
|
return response.data.ok;
|
|
807
956
|
}
|
|
808
957
|
catch (error) {
|
|
@@ -811,7 +960,7 @@ export default class KeymasterClient {
|
|
|
811
960
|
}
|
|
812
961
|
async listPollVoters(pollId) {
|
|
813
962
|
try {
|
|
814
|
-
const response = await axios.get(`${this.API}/polls/${pollId}/voters`);
|
|
963
|
+
const response = await this.axios.get(`${this.API}/polls/${pollId}/voters`);
|
|
815
964
|
return response.data.voters;
|
|
816
965
|
}
|
|
817
966
|
catch (error) {
|
|
@@ -820,7 +969,7 @@ export default class KeymasterClient {
|
|
|
820
969
|
}
|
|
821
970
|
async createImage(data, options = {}) {
|
|
822
971
|
try {
|
|
823
|
-
const response = await axios.post(`${this.API}/images`, data, {
|
|
972
|
+
const response = await this.axios.post(`${this.API}/images`, data, {
|
|
824
973
|
headers: {
|
|
825
974
|
// eslint-disable-next-line
|
|
826
975
|
'Content-Type': 'application/octet-stream',
|
|
@@ -835,7 +984,7 @@ export default class KeymasterClient {
|
|
|
835
984
|
}
|
|
836
985
|
async updateImage(id, data, options = {}) {
|
|
837
986
|
try {
|
|
838
|
-
const response = await axios.put(`${this.API}/images/${id}`, data, {
|
|
987
|
+
const response = await this.axios.put(`${this.API}/images/${id}`, data, {
|
|
839
988
|
headers: {
|
|
840
989
|
'Content-Type': 'application/octet-stream',
|
|
841
990
|
'X-Options': JSON.stringify(options),
|
|
@@ -849,7 +998,7 @@ export default class KeymasterClient {
|
|
|
849
998
|
}
|
|
850
999
|
async getImage(id) {
|
|
851
1000
|
try {
|
|
852
|
-
const response = await axios.get(`${this.API}/images/${id}`);
|
|
1001
|
+
const response = await this.axios.get(`${this.API}/images/${id}`);
|
|
853
1002
|
return response.data;
|
|
854
1003
|
}
|
|
855
1004
|
catch (error) {
|
|
@@ -858,7 +1007,7 @@ export default class KeymasterClient {
|
|
|
858
1007
|
}
|
|
859
1008
|
async testImage(id) {
|
|
860
1009
|
try {
|
|
861
|
-
const response = await axios.post(`${this.API}/images/${id}/test`);
|
|
1010
|
+
const response = await this.axios.post(`${this.API}/images/${id}/test`);
|
|
862
1011
|
return response.data.test;
|
|
863
1012
|
}
|
|
864
1013
|
catch (error) {
|
|
@@ -867,7 +1016,7 @@ export default class KeymasterClient {
|
|
|
867
1016
|
}
|
|
868
1017
|
async createFile(data, options = {}) {
|
|
869
1018
|
try {
|
|
870
|
-
const response = await axios.post(`${this.API}/files`, data, {
|
|
1019
|
+
const response = await this.axios.post(`${this.API}/files`, data, {
|
|
871
1020
|
headers: {
|
|
872
1021
|
'Content-Type': 'application/octet-stream',
|
|
873
1022
|
'X-Options': JSON.stringify(options), // Pass options as a custom header
|
|
@@ -881,7 +1030,7 @@ export default class KeymasterClient {
|
|
|
881
1030
|
}
|
|
882
1031
|
async updateFile(id, data, options = {}) {
|
|
883
1032
|
try {
|
|
884
|
-
const response = await axios.put(`${this.API}/files/${id}`, data, {
|
|
1033
|
+
const response = await this.axios.put(`${this.API}/files/${id}`, data, {
|
|
885
1034
|
headers: {
|
|
886
1035
|
'Content-Type': 'application/octet-stream',
|
|
887
1036
|
'X-Options': JSON.stringify(options), // Pass options as a custom header
|
|
@@ -895,7 +1044,7 @@ export default class KeymasterClient {
|
|
|
895
1044
|
}
|
|
896
1045
|
async getFile(id) {
|
|
897
1046
|
try {
|
|
898
|
-
const response = await axios.get(`${this.API}/files/${id}`);
|
|
1047
|
+
const response = await this.axios.get(`${this.API}/files/${id}`);
|
|
899
1048
|
return response.data.file;
|
|
900
1049
|
}
|
|
901
1050
|
catch (error) {
|
|
@@ -904,7 +1053,7 @@ export default class KeymasterClient {
|
|
|
904
1053
|
}
|
|
905
1054
|
async testFile(id) {
|
|
906
1055
|
try {
|
|
907
|
-
const response = await axios.post(`${this.API}/files/${id}/test`);
|
|
1056
|
+
const response = await this.axios.post(`${this.API}/files/${id}/test`);
|
|
908
1057
|
return response.data.test;
|
|
909
1058
|
}
|
|
910
1059
|
catch (error) {
|
|
@@ -913,7 +1062,7 @@ export default class KeymasterClient {
|
|
|
913
1062
|
}
|
|
914
1063
|
async createVault(options = {}) {
|
|
915
1064
|
try {
|
|
916
|
-
const response = await axios.post(`${this.API}/vaults`, { options });
|
|
1065
|
+
const response = await this.axios.post(`${this.API}/vaults`, { options });
|
|
917
1066
|
return response.data.did;
|
|
918
1067
|
}
|
|
919
1068
|
catch (error) {
|
|
@@ -924,11 +1073,11 @@ export default class KeymasterClient {
|
|
|
924
1073
|
try {
|
|
925
1074
|
if (options) {
|
|
926
1075
|
const queryParams = new URLSearchParams(options);
|
|
927
|
-
const response = await axios.get(`${this.API}/vaults/${id}?${queryParams.toString()}`);
|
|
1076
|
+
const response = await this.axios.get(`${this.API}/vaults/${id}?${queryParams.toString()}`);
|
|
928
1077
|
return response.data.vault;
|
|
929
1078
|
}
|
|
930
1079
|
else {
|
|
931
|
-
const response = await axios.get(`${this.API}/vaults/${id}`);
|
|
1080
|
+
const response = await this.axios.get(`${this.API}/vaults/${id}`);
|
|
932
1081
|
return response.data.vault;
|
|
933
1082
|
}
|
|
934
1083
|
}
|
|
@@ -938,7 +1087,7 @@ export default class KeymasterClient {
|
|
|
938
1087
|
}
|
|
939
1088
|
async testVault(id, options) {
|
|
940
1089
|
try {
|
|
941
|
-
const response = await axios.post(`${this.API}/vaults/${id}/test`, { options });
|
|
1090
|
+
const response = await this.axios.post(`${this.API}/vaults/${id}/test`, { options });
|
|
942
1091
|
return response.data.test;
|
|
943
1092
|
}
|
|
944
1093
|
catch (error) {
|
|
@@ -947,7 +1096,7 @@ export default class KeymasterClient {
|
|
|
947
1096
|
}
|
|
948
1097
|
async addVaultMember(vaultId, memberId) {
|
|
949
1098
|
try {
|
|
950
|
-
const response = await axios.post(`${this.API}/vaults/${vaultId}/members`, { memberId });
|
|
1099
|
+
const response = await this.axios.post(`${this.API}/vaults/${vaultId}/members`, { memberId });
|
|
951
1100
|
return response.data.ok;
|
|
952
1101
|
}
|
|
953
1102
|
catch (error) {
|
|
@@ -956,7 +1105,7 @@ export default class KeymasterClient {
|
|
|
956
1105
|
}
|
|
957
1106
|
async removeVaultMember(vaultId, memberId) {
|
|
958
1107
|
try {
|
|
959
|
-
const response = await axios.delete(`${this.API}/vaults/${vaultId}/members/${memberId}`);
|
|
1108
|
+
const response = await this.axios.delete(`${this.API}/vaults/${vaultId}/members/${memberId}`);
|
|
960
1109
|
return response.data.ok;
|
|
961
1110
|
}
|
|
962
1111
|
catch (error) {
|
|
@@ -965,7 +1114,7 @@ export default class KeymasterClient {
|
|
|
965
1114
|
}
|
|
966
1115
|
async listVaultMembers(vaultId) {
|
|
967
1116
|
try {
|
|
968
|
-
const response = await axios.get(`${this.API}/vaults/${vaultId}/members`);
|
|
1117
|
+
const response = await this.axios.get(`${this.API}/vaults/${vaultId}/members`);
|
|
969
1118
|
return response.data.members;
|
|
970
1119
|
}
|
|
971
1120
|
catch (error) {
|
|
@@ -974,7 +1123,7 @@ export default class KeymasterClient {
|
|
|
974
1123
|
}
|
|
975
1124
|
async addVaultItem(vaultId, name, buffer) {
|
|
976
1125
|
try {
|
|
977
|
-
const response = await axios.post(`${this.API}/vaults/${vaultId}/items`, buffer, {
|
|
1126
|
+
const response = await this.axios.post(`${this.API}/vaults/${vaultId}/items`, buffer, {
|
|
978
1127
|
headers: {
|
|
979
1128
|
// eslint-disable-next-line
|
|
980
1129
|
'Content-Type': 'application/octet-stream',
|
|
@@ -989,7 +1138,7 @@ export default class KeymasterClient {
|
|
|
989
1138
|
}
|
|
990
1139
|
async removeVaultItem(vaultId, name) {
|
|
991
1140
|
try {
|
|
992
|
-
const response = await axios.delete(`${this.API}/vaults/${vaultId}/items/${name}`);
|
|
1141
|
+
const response = await this.axios.delete(`${this.API}/vaults/${vaultId}/items/${name}`);
|
|
993
1142
|
return response.data.ok;
|
|
994
1143
|
}
|
|
995
1144
|
catch (error) {
|
|
@@ -1000,11 +1149,11 @@ export default class KeymasterClient {
|
|
|
1000
1149
|
try {
|
|
1001
1150
|
if (options) {
|
|
1002
1151
|
const queryParams = new URLSearchParams(options);
|
|
1003
|
-
const response = await axios.get(`${this.API}/vaults/${vaultId}/items?${queryParams.toString()}`);
|
|
1152
|
+
const response = await this.axios.get(`${this.API}/vaults/${vaultId}/items?${queryParams.toString()}`);
|
|
1004
1153
|
return response.data.items;
|
|
1005
1154
|
}
|
|
1006
1155
|
else {
|
|
1007
|
-
const response = await axios.get(`${this.API}/vaults/${vaultId}/items`);
|
|
1156
|
+
const response = await this.axios.get(`${this.API}/vaults/${vaultId}/items`);
|
|
1008
1157
|
return response.data.items;
|
|
1009
1158
|
}
|
|
1010
1159
|
}
|
|
@@ -1019,7 +1168,7 @@ export default class KeymasterClient {
|
|
|
1019
1168
|
const queryParams = new URLSearchParams(options);
|
|
1020
1169
|
url += `?${queryParams.toString()}`;
|
|
1021
1170
|
}
|
|
1022
|
-
const response = await axios.get(url, {
|
|
1171
|
+
const response = await this.axios.get(url, {
|
|
1023
1172
|
responseType: 'arraybuffer'
|
|
1024
1173
|
});
|
|
1025
1174
|
if (!response.data || (Buffer.isBuffer(response.data) && response.data.length === 0)) {
|
|
@@ -1043,7 +1192,7 @@ export default class KeymasterClient {
|
|
|
1043
1192
|
}
|
|
1044
1193
|
async listDmail() {
|
|
1045
1194
|
try {
|
|
1046
|
-
const response = await axios.get(`${this.API}/dmail`);
|
|
1195
|
+
const response = await this.axios.get(`${this.API}/dmail`);
|
|
1047
1196
|
return response.data.dmail;
|
|
1048
1197
|
}
|
|
1049
1198
|
catch (error) {
|
|
@@ -1052,7 +1201,7 @@ export default class KeymasterClient {
|
|
|
1052
1201
|
}
|
|
1053
1202
|
async createDmail(message, options = {}) {
|
|
1054
1203
|
try {
|
|
1055
|
-
const response = await axios.post(`${this.API}/dmail`, { message, options });
|
|
1204
|
+
const response = await this.axios.post(`${this.API}/dmail`, { message, options });
|
|
1056
1205
|
return response.data.did;
|
|
1057
1206
|
}
|
|
1058
1207
|
catch (error) {
|
|
@@ -1061,7 +1210,7 @@ export default class KeymasterClient {
|
|
|
1061
1210
|
}
|
|
1062
1211
|
async updateDmail(did, message) {
|
|
1063
1212
|
try {
|
|
1064
|
-
const response = await axios.put(`${this.API}/dmail/${did}`, { message });
|
|
1213
|
+
const response = await this.axios.put(`${this.API}/dmail/${did}`, { message });
|
|
1065
1214
|
return response.data.ok;
|
|
1066
1215
|
}
|
|
1067
1216
|
catch (error) {
|
|
@@ -1070,7 +1219,7 @@ export default class KeymasterClient {
|
|
|
1070
1219
|
}
|
|
1071
1220
|
async sendDmail(did) {
|
|
1072
1221
|
try {
|
|
1073
|
-
const response = await axios.post(`${this.API}/dmail/${did}/send`);
|
|
1222
|
+
const response = await this.axios.post(`${this.API}/dmail/${did}/send`);
|
|
1074
1223
|
return response.data.did;
|
|
1075
1224
|
}
|
|
1076
1225
|
catch (error) {
|
|
@@ -1079,7 +1228,7 @@ export default class KeymasterClient {
|
|
|
1079
1228
|
}
|
|
1080
1229
|
async fileDmail(did, tags) {
|
|
1081
1230
|
try {
|
|
1082
|
-
const response = await axios.post(`${this.API}/dmail/${did}/file`, { tags });
|
|
1231
|
+
const response = await this.axios.post(`${this.API}/dmail/${did}/file`, { tags });
|
|
1083
1232
|
return response.data.ok;
|
|
1084
1233
|
}
|
|
1085
1234
|
catch (error) {
|
|
@@ -1088,7 +1237,7 @@ export default class KeymasterClient {
|
|
|
1088
1237
|
}
|
|
1089
1238
|
async removeDmail(did) {
|
|
1090
1239
|
try {
|
|
1091
|
-
const response = await axios.delete(`${this.API}/dmail/${did}`);
|
|
1240
|
+
const response = await this.axios.delete(`${this.API}/dmail/${did}`);
|
|
1092
1241
|
return response.data.ok;
|
|
1093
1242
|
}
|
|
1094
1243
|
catch (error) {
|
|
@@ -1099,11 +1248,11 @@ export default class KeymasterClient {
|
|
|
1099
1248
|
try {
|
|
1100
1249
|
if (options) {
|
|
1101
1250
|
const queryParams = new URLSearchParams(options);
|
|
1102
|
-
const response = await axios.get(`${this.API}/dmail/${did}?${queryParams.toString()}`);
|
|
1251
|
+
const response = await this.axios.get(`${this.API}/dmail/${did}?${queryParams.toString()}`);
|
|
1103
1252
|
return response.data.message;
|
|
1104
1253
|
}
|
|
1105
1254
|
else {
|
|
1106
|
-
const response = await axios.get(`${this.API}/dmail/${did}`);
|
|
1255
|
+
const response = await this.axios.get(`${this.API}/dmail/${did}`);
|
|
1107
1256
|
return response.data.message;
|
|
1108
1257
|
}
|
|
1109
1258
|
}
|
|
@@ -1115,11 +1264,11 @@ export default class KeymasterClient {
|
|
|
1115
1264
|
try {
|
|
1116
1265
|
if (options) {
|
|
1117
1266
|
const queryParams = new URLSearchParams(options);
|
|
1118
|
-
const response = await axios.get(`${this.API}/dmail/${did}/attachments?${queryParams.toString()}`);
|
|
1267
|
+
const response = await this.axios.get(`${this.API}/dmail/${did}/attachments?${queryParams.toString()}`);
|
|
1119
1268
|
return response.data.attachments;
|
|
1120
1269
|
}
|
|
1121
1270
|
else {
|
|
1122
|
-
const response = await axios.get(`${this.API}/dmail/${did}/attachments`);
|
|
1271
|
+
const response = await this.axios.get(`${this.API}/dmail/${did}/attachments`);
|
|
1123
1272
|
return response.data.attachments;
|
|
1124
1273
|
}
|
|
1125
1274
|
}
|
|
@@ -1129,7 +1278,7 @@ export default class KeymasterClient {
|
|
|
1129
1278
|
}
|
|
1130
1279
|
async addDmailAttachment(did, name, buffer) {
|
|
1131
1280
|
try {
|
|
1132
|
-
const response = await axios.post(`${this.API}/dmail/${did}/attachments`, buffer, {
|
|
1281
|
+
const response = await this.axios.post(`${this.API}/dmail/${did}/attachments`, buffer, {
|
|
1133
1282
|
headers: {
|
|
1134
1283
|
// eslint-disable-next-line
|
|
1135
1284
|
'Content-Type': 'application/octet-stream',
|
|
@@ -1144,7 +1293,7 @@ export default class KeymasterClient {
|
|
|
1144
1293
|
}
|
|
1145
1294
|
async removeDmailAttachment(did, name) {
|
|
1146
1295
|
try {
|
|
1147
|
-
const response = await axios.delete(`${this.API}/dmail/${did}/attachments/${name}`);
|
|
1296
|
+
const response = await this.axios.delete(`${this.API}/dmail/${did}/attachments/${name}`);
|
|
1148
1297
|
return response.data.ok;
|
|
1149
1298
|
}
|
|
1150
1299
|
catch (error) {
|
|
@@ -1153,7 +1302,7 @@ export default class KeymasterClient {
|
|
|
1153
1302
|
}
|
|
1154
1303
|
async getDmailAttachment(did, name) {
|
|
1155
1304
|
try {
|
|
1156
|
-
const response = await axios.get(`${this.API}/dmail/${did}/attachments/${name}`, {
|
|
1305
|
+
const response = await this.axios.get(`${this.API}/dmail/${did}/attachments/${name}`, {
|
|
1157
1306
|
responseType: 'arraybuffer'
|
|
1158
1307
|
});
|
|
1159
1308
|
if (!response.data || (Buffer.isBuffer(response.data) && response.data.length === 0)) {
|
|
@@ -1177,7 +1326,7 @@ export default class KeymasterClient {
|
|
|
1177
1326
|
}
|
|
1178
1327
|
async importDmail(did) {
|
|
1179
1328
|
try {
|
|
1180
|
-
const response = await axios.post(`${this.API}/dmail/import`, { did });
|
|
1329
|
+
const response = await this.axios.post(`${this.API}/dmail/import`, { did });
|
|
1181
1330
|
return response.data.ok;
|
|
1182
1331
|
}
|
|
1183
1332
|
catch (error) {
|
|
@@ -1186,7 +1335,7 @@ export default class KeymasterClient {
|
|
|
1186
1335
|
}
|
|
1187
1336
|
async createNotice(message, options = {}) {
|
|
1188
1337
|
try {
|
|
1189
|
-
const response = await axios.post(`${this.API}/notices`, { message, options });
|
|
1338
|
+
const response = await this.axios.post(`${this.API}/notices`, { message, options });
|
|
1190
1339
|
return response.data.did;
|
|
1191
1340
|
}
|
|
1192
1341
|
catch (error) {
|
|
@@ -1195,7 +1344,7 @@ export default class KeymasterClient {
|
|
|
1195
1344
|
}
|
|
1196
1345
|
async updateNotice(did, message) {
|
|
1197
1346
|
try {
|
|
1198
|
-
const response = await axios.put(`${this.API}/notices/${did}`, { message });
|
|
1347
|
+
const response = await this.axios.put(`${this.API}/notices/${did}`, { message });
|
|
1199
1348
|
return response.data.ok;
|
|
1200
1349
|
}
|
|
1201
1350
|
catch (error) {
|
|
@@ -1204,7 +1353,7 @@ export default class KeymasterClient {
|
|
|
1204
1353
|
}
|
|
1205
1354
|
async refreshNotices() {
|
|
1206
1355
|
try {
|
|
1207
|
-
const response = await axios.post(`${this.API}/notices/refresh`);
|
|
1356
|
+
const response = await this.axios.post(`${this.API}/notices/refresh`);
|
|
1208
1357
|
return response.data.ok;
|
|
1209
1358
|
}
|
|
1210
1359
|
catch (error) {
|
|
@@ -1213,7 +1362,7 @@ export default class KeymasterClient {
|
|
|
1213
1362
|
}
|
|
1214
1363
|
async exportEncryptedWallet() {
|
|
1215
1364
|
try {
|
|
1216
|
-
const response = await axios.get(`${this.API}/export/wallet/encrypted`);
|
|
1365
|
+
const response = await this.axios.get(`${this.API}/export/wallet/encrypted`);
|
|
1217
1366
|
return response.data.wallet;
|
|
1218
1367
|
}
|
|
1219
1368
|
catch (error) {
|