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