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