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