@didcid/keymaster 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,158 @@ 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 } });
348
+ return response.data.ok;
349
+ }
350
+ catch (error) {
351
+ throwError(error);
352
+ }
353
+ }
354
+ async exportNsec(id) {
355
+ try {
356
+ const response = await this.axios.post(`${this.API}/nostr/nsec`, { id });
357
+ return response.data.nsec;
358
+ }
359
+ catch (error) {
360
+ throwError(error);
361
+ }
362
+ }
363
+ async signNostrEvent(event) {
364
+ try {
365
+ const response = await this.axios.post(`${this.API}/nostr/sign`, { event });
366
+ return response.data;
367
+ }
368
+ catch (error) {
369
+ throwError(error);
370
+ }
371
+ }
372
+ // Lightning
373
+ async addLightning(id) {
374
+ try {
375
+ const response = await this.axios.post(`${this.API}/lightning`, { id });
376
+ return response.data;
377
+ }
378
+ catch (error) {
379
+ throwError(error);
380
+ }
381
+ }
382
+ async removeLightning(id) {
383
+ try {
384
+ const response = await this.axios.delete(`${this.API}/lightning`, { data: { id } });
317
385
  return response.data.ok;
318
386
  }
319
387
  catch (error) {
320
388
  throwError(error);
321
389
  }
322
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
+ }
463
+ async getLightningPayments(name) {
464
+ try {
465
+ const response = await this.axios.post(`${this.API}/lightning/payments`, { id: name });
466
+ return response.data.payments;
467
+ }
468
+ catch (error) {
469
+ throwError(error);
470
+ }
471
+ }
323
472
  async resolveDID(id, options) {
324
473
  try {
325
474
  if (options) {
326
475
  const queryParams = new URLSearchParams(options);
327
- const response = await axios.get(`${this.API}/did/${id}?${queryParams.toString()}`);
476
+ const response = await this.axios.get(`${this.API}/did/${id}?${queryParams.toString()}`);
328
477
  return response.data.docs;
329
478
  }
330
479
  else {
331
- const response = await axios.get(`${this.API}/did/${id}`);
480
+ const response = await this.axios.get(`${this.API}/did/${id}`);
332
481
  return response.data.docs;
333
482
  }
334
483
  }
@@ -338,7 +487,7 @@ class KeymasterClient {
338
487
  }
339
488
  async updateDID(id, doc) {
340
489
  try {
341
- const response = await axios.put(`${this.API}/did/${id}`, { doc });
490
+ const response = await this.axios.put(`${this.API}/did/${id}`, { doc });
342
491
  return response.data.ok;
343
492
  }
344
493
  catch (error) {
@@ -347,7 +496,7 @@ class KeymasterClient {
347
496
  }
348
497
  async revokeDID(id) {
349
498
  try {
350
- const response = await axios.delete(`${this.API}/did/${id}`);
499
+ const response = await this.axios.delete(`${this.API}/did/${id}`);
351
500
  return response.data.ok;
352
501
  }
353
502
  catch (error) {
@@ -356,7 +505,7 @@ class KeymasterClient {
356
505
  }
357
506
  async createAsset(data, options) {
358
507
  try {
359
- const response = await axios.post(`${this.API}/assets`, { data, options });
508
+ const response = await this.axios.post(`${this.API}/assets`, { data, options });
360
509
  return response.data.did;
361
510
  }
362
511
  catch (error) {
@@ -365,7 +514,7 @@ class KeymasterClient {
365
514
  }
366
515
  async cloneAsset(id, options) {
367
516
  try {
368
- const response = await axios.post(`${this.API}/assets/${id}/clone`, { options });
517
+ const response = await this.axios.post(`${this.API}/assets/${id}/clone`, { options });
369
518
  return response.data.did;
370
519
  }
371
520
  catch (error) {
@@ -374,7 +523,7 @@ class KeymasterClient {
374
523
  }
375
524
  async listAssets() {
376
525
  try {
377
- const response = await axios.get(`${this.API}/assets`);
526
+ const response = await this.axios.get(`${this.API}/assets`);
378
527
  return response.data.assets;
379
528
  }
380
529
  catch (error) {
@@ -385,11 +534,11 @@ class KeymasterClient {
385
534
  try {
386
535
  if (options) {
387
536
  const queryParams = new URLSearchParams(options);
388
- const response = await axios.get(`${this.API}/assets/${id}?${queryParams.toString()}`);
537
+ const response = await this.axios.get(`${this.API}/assets/${id}?${queryParams.toString()}`);
389
538
  return response.data.asset;
390
539
  }
391
540
  else {
392
- const response = await axios.get(`${this.API}/assets/${id}`);
541
+ const response = await this.axios.get(`${this.API}/assets/${id}`);
393
542
  return response.data.asset;
394
543
  }
395
544
  }
@@ -399,7 +548,7 @@ class KeymasterClient {
399
548
  }
400
549
  async mergeData(id, data) {
401
550
  try {
402
- const response = await axios.put(`${this.API}/assets/${id}`, { data });
551
+ const response = await this.axios.put(`${this.API}/assets/${id}`, { data });
403
552
  return response.data.ok;
404
553
  }
405
554
  catch (error) {
@@ -408,7 +557,7 @@ class KeymasterClient {
408
557
  }
409
558
  async transferAsset(id, controller) {
410
559
  try {
411
- const response = await axios.post(`${this.API}/assets/${id}/transfer`, { controller });
560
+ const response = await this.axios.post(`${this.API}/assets/${id}/transfer`, { controller });
412
561
  return response.data.ok;
413
562
  }
414
563
  catch (error) {
@@ -417,7 +566,7 @@ class KeymasterClient {
417
566
  }
418
567
  async createChallenge(challenge = {}, options = {}) {
419
568
  try {
420
- const response = await axios.post(`${this.API}/challenge`, { challenge, options });
569
+ const response = await this.axios.post(`${this.API}/challenge`, { challenge, options });
421
570
  return response.data.did;
422
571
  }
423
572
  catch (error) {
@@ -426,7 +575,7 @@ class KeymasterClient {
426
575
  }
427
576
  async createResponse(challenge, options) {
428
577
  try {
429
- const response = await axios.post(`${this.API}/response`, { challenge, options });
578
+ const response = await this.axios.post(`${this.API}/response`, { challenge, options });
430
579
  return response.data.did;
431
580
  }
432
581
  catch (error) {
@@ -435,7 +584,7 @@ class KeymasterClient {
435
584
  }
436
585
  async verifyResponse(responseDID, options) {
437
586
  try {
438
- const response = await axios.post(`${this.API}/response/verify`, { response: responseDID, options });
587
+ const response = await this.axios.post(`${this.API}/response/verify`, { response: responseDID, options });
439
588
  return response.data.verify;
440
589
  }
441
590
  catch (error) {
@@ -444,7 +593,7 @@ class KeymasterClient {
444
593
  }
445
594
  async createGroup(name, options) {
446
595
  try {
447
- const response = await axios.post(`${this.API}/groups`, { name, options });
596
+ const response = await this.axios.post(`${this.API}/groups`, { name, options });
448
597
  return response.data.did;
449
598
  }
450
599
  catch (error) {
@@ -453,7 +602,7 @@ class KeymasterClient {
453
602
  }
454
603
  async getGroup(group) {
455
604
  try {
456
- const response = await axios.get(`${this.API}/groups/${group}`);
605
+ const response = await this.axios.get(`${this.API}/groups/${group}`);
457
606
  return response.data.group;
458
607
  }
459
608
  catch (error) {
@@ -462,7 +611,7 @@ class KeymasterClient {
462
611
  }
463
612
  async addGroupMember(group, member) {
464
613
  try {
465
- const response = await axios.post(`${this.API}/groups/${group}/add`, { member });
614
+ const response = await this.axios.post(`${this.API}/groups/${group}/add`, { member });
466
615
  return response.data.ok;
467
616
  }
468
617
  catch (error) {
@@ -471,7 +620,7 @@ class KeymasterClient {
471
620
  }
472
621
  async removeGroupMember(group, member) {
473
622
  try {
474
- const response = await axios.post(`${this.API}/groups/${group}/remove`, { member });
623
+ const response = await this.axios.post(`${this.API}/groups/${group}/remove`, { member });
475
624
  return response.data.ok;
476
625
  }
477
626
  catch (error) {
@@ -480,7 +629,7 @@ class KeymasterClient {
480
629
  }
481
630
  async testGroup(group, member) {
482
631
  try {
483
- const response = await axios.post(`${this.API}/groups/${group}/test`, { member });
632
+ const response = await this.axios.post(`${this.API}/groups/${group}/test`, { member });
484
633
  return response.data.test;
485
634
  }
486
635
  catch (error) {
@@ -490,11 +639,11 @@ class KeymasterClient {
490
639
  async listGroups(owner) {
491
640
  try {
492
641
  if (owner) {
493
- const response = await axios.get(`${this.API}/groups?owner=${owner}`);
642
+ const response = await this.axios.get(`${this.API}/groups?owner=${owner}`);
494
643
  return response.data.groups;
495
644
  }
496
645
  else {
497
- const response = await axios.get(`${this.API}/groups`);
646
+ const response = await this.axios.get(`${this.API}/groups`);
498
647
  return response.data.groups;
499
648
  }
500
649
  }
@@ -504,7 +653,7 @@ class KeymasterClient {
504
653
  }
505
654
  async createSchema(schema, options) {
506
655
  try {
507
- const response = await axios.post(`${this.API}/schemas`, { schema, options });
656
+ const response = await this.axios.post(`${this.API}/schemas`, { schema, options });
508
657
  return response.data.did;
509
658
  }
510
659
  catch (error) {
@@ -513,7 +662,7 @@ class KeymasterClient {
513
662
  }
514
663
  async getSchema(id) {
515
664
  try {
516
- const response = await axios.get(`${this.API}/schemas/${id}`);
665
+ const response = await this.axios.get(`${this.API}/schemas/${id}`);
517
666
  return response.data.schema;
518
667
  }
519
668
  catch (error) {
@@ -522,7 +671,7 @@ class KeymasterClient {
522
671
  }
523
672
  async setSchema(id, schema) {
524
673
  try {
525
- const response = await axios.put(`${this.API}/schemas/${id}`, { schema });
674
+ const response = await this.axios.put(`${this.API}/schemas/${id}`, { schema });
526
675
  return response.data.ok;
527
676
  }
528
677
  catch (error) {
@@ -531,7 +680,7 @@ class KeymasterClient {
531
680
  }
532
681
  async testSchema(id) {
533
682
  try {
534
- const response = await axios.post(`${this.API}/schemas/${id}/test`);
683
+ const response = await this.axios.post(`${this.API}/schemas/${id}/test`);
535
684
  return response.data.test;
536
685
  }
537
686
  catch (error) {
@@ -541,11 +690,11 @@ class KeymasterClient {
541
690
  async listSchemas(owner) {
542
691
  try {
543
692
  if (owner) {
544
- const response = await axios.get(`${this.API}/schemas?owner=${owner}`);
693
+ const response = await this.axios.get(`${this.API}/schemas?owner=${owner}`);
545
694
  return response.data.schemas;
546
695
  }
547
696
  else {
548
- const response = await axios.get(`${this.API}/schemas`);
697
+ const response = await this.axios.get(`${this.API}/schemas`);
549
698
  return response.data.schemas;
550
699
  }
551
700
  }
@@ -555,7 +704,7 @@ class KeymasterClient {
555
704
  }
556
705
  async createTemplate(schemaId) {
557
706
  try {
558
- const response = await axios.post(`${this.API}/schemas/${schemaId}/template`);
707
+ const response = await this.axios.post(`${this.API}/schemas/${schemaId}/template`);
559
708
  return response.data.template;
560
709
  }
561
710
  catch (error) {
@@ -564,7 +713,7 @@ class KeymasterClient {
564
713
  }
565
714
  async testAgent(id) {
566
715
  try {
567
- const response = await axios.post(`${this.API}/agents/${id}/test`);
716
+ const response = await this.axios.post(`${this.API}/agents/${id}/test`);
568
717
  return response.data.test;
569
718
  }
570
719
  catch (error) {
@@ -573,7 +722,7 @@ class KeymasterClient {
573
722
  }
574
723
  async bindCredential(subject, options) {
575
724
  try {
576
- const response = await axios.post(`${this.API}/credentials/bind`, { subject, options });
725
+ const response = await this.axios.post(`${this.API}/credentials/bind`, { subject, options });
577
726
  return response.data.credential;
578
727
  }
579
728
  catch (error) {
@@ -582,7 +731,7 @@ class KeymasterClient {
582
731
  }
583
732
  async issueCredential(credential, options) {
584
733
  try {
585
- const response = await axios.post(`${this.API}/credentials/issued`, { credential, options });
734
+ const response = await this.axios.post(`${this.API}/credentials/issued`, { credential, options });
586
735
  return response.data.did;
587
736
  }
588
737
  catch (error) {
@@ -591,7 +740,7 @@ class KeymasterClient {
591
740
  }
592
741
  async sendCredential(did, options) {
593
742
  try {
594
- const response = await axios.post(`${this.API}/credentials/issued/${did}/send`, { options });
743
+ const response = await this.axios.post(`${this.API}/credentials/issued/${did}/send`, { options });
595
744
  return response.data.did;
596
745
  }
597
746
  catch (error) {
@@ -600,7 +749,7 @@ class KeymasterClient {
600
749
  }
601
750
  async updateCredential(did, credential) {
602
751
  try {
603
- const response = await axios.post(`${this.API}/credentials/issued/${did}`, { credential });
752
+ const response = await this.axios.post(`${this.API}/credentials/issued/${did}`, { credential });
604
753
  return response.data.ok;
605
754
  }
606
755
  catch (error) {
@@ -609,7 +758,7 @@ class KeymasterClient {
609
758
  }
610
759
  async listCredentials() {
611
760
  try {
612
- const response = await axios.get(`${this.API}/credentials/held`);
761
+ const response = await this.axios.get(`${this.API}/credentials/held`);
613
762
  return response.data.held;
614
763
  }
615
764
  catch (error) {
@@ -618,7 +767,7 @@ class KeymasterClient {
618
767
  }
619
768
  async acceptCredential(did) {
620
769
  try {
621
- const response = await axios.post(`${this.API}/credentials/held`, { did });
770
+ const response = await this.axios.post(`${this.API}/credentials/held`, { did });
622
771
  return response.data.ok;
623
772
  }
624
773
  catch (error) {
@@ -627,7 +776,7 @@ class KeymasterClient {
627
776
  }
628
777
  async getCredential(did) {
629
778
  try {
630
- const response = await axios.get(`${this.API}/credentials/held/${did}`);
779
+ const response = await this.axios.get(`${this.API}/credentials/held/${did}`);
631
780
  return response.data.credential;
632
781
  }
633
782
  catch (error) {
@@ -636,7 +785,7 @@ class KeymasterClient {
636
785
  }
637
786
  async removeCredential(did) {
638
787
  try {
639
- const response = await axios.delete(`${this.API}/credentials/held/${did}`);
788
+ const response = await this.axios.delete(`${this.API}/credentials/held/${did}`);
640
789
  return response.data.ok;
641
790
  }
642
791
  catch (error) {
@@ -645,7 +794,7 @@ class KeymasterClient {
645
794
  }
646
795
  async publishCredential(did, options) {
647
796
  try {
648
- const response = await axios.post(`${this.API}/credentials/held/${did}/publish`, { options });
797
+ const response = await this.axios.post(`${this.API}/credentials/held/${did}/publish`, { options });
649
798
  return response.data.ok;
650
799
  }
651
800
  catch (error) {
@@ -654,7 +803,7 @@ class KeymasterClient {
654
803
  }
655
804
  async unpublishCredential(did) {
656
805
  try {
657
- const response = await axios.post(`${this.API}/credentials/held/${did}/unpublish`);
806
+ const response = await this.axios.post(`${this.API}/credentials/held/${did}/unpublish`);
658
807
  return response.data.ok;
659
808
  }
660
809
  catch (error) {
@@ -663,7 +812,7 @@ class KeymasterClient {
663
812
  }
664
813
  async listIssued() {
665
814
  try {
666
- const response = await axios.get(`${this.API}/credentials/issued`);
815
+ const response = await this.axios.get(`${this.API}/credentials/issued`);
667
816
  return response.data.issued;
668
817
  }
669
818
  catch (error) {
@@ -672,7 +821,7 @@ class KeymasterClient {
672
821
  }
673
822
  async revokeCredential(did) {
674
823
  try {
675
- const response = await axios.delete(`${this.API}/credentials/issued/${did}`);
824
+ const response = await this.axios.delete(`${this.API}/credentials/issued/${did}`);
676
825
  return response.data.ok;
677
826
  }
678
827
  catch (error) {
@@ -681,7 +830,7 @@ class KeymasterClient {
681
830
  }
682
831
  async pollTemplate() {
683
832
  try {
684
- const response = await axios.get(`${this.API}/templates/poll`);
833
+ const response = await this.axios.get(`${this.API}/templates/poll`);
685
834
  return response.data.template;
686
835
  }
687
836
  catch (error) {
@@ -690,7 +839,7 @@ class KeymasterClient {
690
839
  }
691
840
  async createPoll(config, options) {
692
841
  try {
693
- const response = await axios.post(`${this.API}/polls`, { poll: config, options });
842
+ const response = await this.axios.post(`${this.API}/polls`, { poll: config, options });
694
843
  return response.data.did;
695
844
  }
696
845
  catch (error) {
@@ -699,7 +848,7 @@ class KeymasterClient {
699
848
  }
700
849
  async getPoll(pollId) {
701
850
  try {
702
- const response = await axios.get(`${this.API}/polls/${pollId}`);
851
+ const response = await this.axios.get(`${this.API}/polls/${pollId}`);
703
852
  return response.data.poll;
704
853
  }
705
854
  catch (error) {
@@ -708,7 +857,7 @@ class KeymasterClient {
708
857
  }
709
858
  async testPoll(id) {
710
859
  try {
711
- const response = await axios.get(`${this.API}/polls/${id}/test`);
860
+ const response = await this.axios.get(`${this.API}/polls/${id}/test`);
712
861
  return response.data.test;
713
862
  }
714
863
  catch (error) {
@@ -717,7 +866,7 @@ class KeymasterClient {
717
866
  }
718
867
  async listPolls(owner) {
719
868
  try {
720
- const response = await axios.get(`${this.API}/polls`, { params: { owner } });
869
+ const response = await this.axios.get(`${this.API}/polls`, { params: { owner } });
721
870
  return response.data.polls;
722
871
  }
723
872
  catch (error) {
@@ -726,7 +875,7 @@ class KeymasterClient {
726
875
  }
727
876
  async viewPoll(pollId) {
728
877
  try {
729
- const response = await axios.get(`${this.API}/polls/${pollId}/view`);
878
+ const response = await this.axios.get(`${this.API}/polls/${pollId}/view`);
730
879
  return response.data.poll;
731
880
  }
732
881
  catch (error) {
@@ -735,7 +884,7 @@ class KeymasterClient {
735
884
  }
736
885
  async votePoll(pollId, vote, options) {
737
886
  try {
738
- const response = await axios.post(`${this.API}/polls/${pollId}/vote`, { vote, options });
887
+ const response = await this.axios.post(`${this.API}/polls/${pollId}/vote`, { vote, options });
739
888
  return response.data.did;
740
889
  }
741
890
  catch (error) {
@@ -744,7 +893,7 @@ class KeymasterClient {
744
893
  }
745
894
  async sendPoll(pollId) {
746
895
  try {
747
- const response = await axios.post(`${this.API}/polls/${pollId}/send`);
896
+ const response = await this.axios.post(`${this.API}/polls/${pollId}/send`);
748
897
  return response.data.did;
749
898
  }
750
899
  catch (error) {
@@ -753,7 +902,7 @@ class KeymasterClient {
753
902
  }
754
903
  async sendBallot(ballotDid, pollId) {
755
904
  try {
756
- const response = await axios.post(`${this.API}/polls/ballot/send`, { ballot: ballotDid, poll: pollId });
905
+ const response = await this.axios.post(`${this.API}/polls/ballot/send`, { ballot: ballotDid, poll: pollId });
757
906
  return response.data.did;
758
907
  }
759
908
  catch (error) {
@@ -762,7 +911,7 @@ class KeymasterClient {
762
911
  }
763
912
  async viewBallot(ballotDid) {
764
913
  try {
765
- const response = await axios.get(`${this.API}/polls/ballot/${ballotDid}`);
914
+ const response = await this.axios.get(`${this.API}/polls/ballot/${ballotDid}`);
766
915
  return response.data.ballot;
767
916
  }
768
917
  catch (error) {
@@ -771,7 +920,7 @@ class KeymasterClient {
771
920
  }
772
921
  async updatePoll(ballot) {
773
922
  try {
774
- const response = await axios.put(`${this.API}/polls/update`, { ballot });
923
+ const response = await this.axios.put(`${this.API}/polls/update`, { ballot });
775
924
  return response.data.ok;
776
925
  }
777
926
  catch (error) {
@@ -780,7 +929,7 @@ class KeymasterClient {
780
929
  }
781
930
  async publishPoll(pollId, options) {
782
931
  try {
783
- const response = await axios.post(`${this.API}/polls/${pollId}/publish`, { options });
932
+ const response = await this.axios.post(`${this.API}/polls/${pollId}/publish`, { options });
784
933
  return response.data.ok;
785
934
  }
786
935
  catch (error) {
@@ -789,7 +938,7 @@ class KeymasterClient {
789
938
  }
790
939
  async unpublishPoll(pollId) {
791
940
  try {
792
- const response = await axios.post(`${this.API}/polls/${pollId}/unpublish`);
941
+ const response = await this.axios.post(`${this.API}/polls/${pollId}/unpublish`);
793
942
  return response.data.ok;
794
943
  }
795
944
  catch (error) {
@@ -798,7 +947,7 @@ class KeymasterClient {
798
947
  }
799
948
  async addPollVoter(pollId, memberId) {
800
949
  try {
801
- const response = await axios.post(`${this.API}/polls/${pollId}/voters`, { memberId });
950
+ const response = await this.axios.post(`${this.API}/polls/${pollId}/voters`, { memberId });
802
951
  return response.data.ok;
803
952
  }
804
953
  catch (error) {
@@ -807,7 +956,7 @@ class KeymasterClient {
807
956
  }
808
957
  async removePollVoter(pollId, memberId) {
809
958
  try {
810
- const response = await axios.delete(`${this.API}/polls/${pollId}/voters/${memberId}`);
959
+ const response = await this.axios.delete(`${this.API}/polls/${pollId}/voters/${memberId}`);
811
960
  return response.data.ok;
812
961
  }
813
962
  catch (error) {
@@ -816,7 +965,7 @@ class KeymasterClient {
816
965
  }
817
966
  async listPollVoters(pollId) {
818
967
  try {
819
- const response = await axios.get(`${this.API}/polls/${pollId}/voters`);
968
+ const response = await this.axios.get(`${this.API}/polls/${pollId}/voters`);
820
969
  return response.data.voters;
821
970
  }
822
971
  catch (error) {
@@ -825,7 +974,7 @@ class KeymasterClient {
825
974
  }
826
975
  async createImage(data, options = {}) {
827
976
  try {
828
- const response = await axios.post(`${this.API}/images`, data, {
977
+ const response = await this.axios.post(`${this.API}/images`, data, {
829
978
  headers: {
830
979
  // eslint-disable-next-line
831
980
  'Content-Type': 'application/octet-stream',
@@ -840,7 +989,7 @@ class KeymasterClient {
840
989
  }
841
990
  async updateImage(id, data, options = {}) {
842
991
  try {
843
- const response = await axios.put(`${this.API}/images/${id}`, data, {
992
+ const response = await this.axios.put(`${this.API}/images/${id}`, data, {
844
993
  headers: {
845
994
  'Content-Type': 'application/octet-stream',
846
995
  'X-Options': JSON.stringify(options),
@@ -854,7 +1003,7 @@ class KeymasterClient {
854
1003
  }
855
1004
  async getImage(id) {
856
1005
  try {
857
- const response = await axios.get(`${this.API}/images/${id}`);
1006
+ const response = await this.axios.get(`${this.API}/images/${id}`);
858
1007
  return response.data;
859
1008
  }
860
1009
  catch (error) {
@@ -863,7 +1012,7 @@ class KeymasterClient {
863
1012
  }
864
1013
  async testImage(id) {
865
1014
  try {
866
- const response = await axios.post(`${this.API}/images/${id}/test`);
1015
+ const response = await this.axios.post(`${this.API}/images/${id}/test`);
867
1016
  return response.data.test;
868
1017
  }
869
1018
  catch (error) {
@@ -872,7 +1021,7 @@ class KeymasterClient {
872
1021
  }
873
1022
  async createFile(data, options = {}) {
874
1023
  try {
875
- const response = await axios.post(`${this.API}/files`, data, {
1024
+ const response = await this.axios.post(`${this.API}/files`, 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 @@ class KeymasterClient {
886
1035
  }
887
1036
  async updateFile(id, data, options = {}) {
888
1037
  try {
889
- const response = await axios.put(`${this.API}/files/${id}`, data, {
1038
+ const response = await this.axios.put(`${this.API}/files/${id}`, data, {
890
1039
  headers: {
891
1040
  'Content-Type': 'application/octet-stream',
892
1041
  'X-Options': JSON.stringify(options), // Pass options as a custom header
@@ -900,7 +1049,7 @@ class KeymasterClient {
900
1049
  }
901
1050
  async getFile(id) {
902
1051
  try {
903
- const response = await axios.get(`${this.API}/files/${id}`);
1052
+ const response = await this.axios.get(`${this.API}/files/${id}`);
904
1053
  return response.data.file;
905
1054
  }
906
1055
  catch (error) {
@@ -909,7 +1058,7 @@ class KeymasterClient {
909
1058
  }
910
1059
  async testFile(id) {
911
1060
  try {
912
- const response = await axios.post(`${this.API}/files/${id}/test`);
1061
+ const response = await this.axios.post(`${this.API}/files/${id}/test`);
913
1062
  return response.data.test;
914
1063
  }
915
1064
  catch (error) {
@@ -918,7 +1067,7 @@ class KeymasterClient {
918
1067
  }
919
1068
  async createVault(options = {}) {
920
1069
  try {
921
- const response = await axios.post(`${this.API}/vaults`, { options });
1070
+ const response = await this.axios.post(`${this.API}/vaults`, { options });
922
1071
  return response.data.did;
923
1072
  }
924
1073
  catch (error) {
@@ -929,11 +1078,11 @@ class KeymasterClient {
929
1078
  try {
930
1079
  if (options) {
931
1080
  const queryParams = new URLSearchParams(options);
932
- const response = await axios.get(`${this.API}/vaults/${id}?${queryParams.toString()}`);
1081
+ const response = await this.axios.get(`${this.API}/vaults/${id}?${queryParams.toString()}`);
933
1082
  return response.data.vault;
934
1083
  }
935
1084
  else {
936
- const response = await axios.get(`${this.API}/vaults/${id}`);
1085
+ const response = await this.axios.get(`${this.API}/vaults/${id}`);
937
1086
  return response.data.vault;
938
1087
  }
939
1088
  }
@@ -943,7 +1092,7 @@ class KeymasterClient {
943
1092
  }
944
1093
  async testVault(id, options) {
945
1094
  try {
946
- const response = await axios.post(`${this.API}/vaults/${id}/test`, { options });
1095
+ const response = await this.axios.post(`${this.API}/vaults/${id}/test`, { options });
947
1096
  return response.data.test;
948
1097
  }
949
1098
  catch (error) {
@@ -952,7 +1101,7 @@ class KeymasterClient {
952
1101
  }
953
1102
  async addVaultMember(vaultId, memberId) {
954
1103
  try {
955
- const response = await axios.post(`${this.API}/vaults/${vaultId}/members`, { memberId });
1104
+ const response = await this.axios.post(`${this.API}/vaults/${vaultId}/members`, { memberId });
956
1105
  return response.data.ok;
957
1106
  }
958
1107
  catch (error) {
@@ -961,7 +1110,7 @@ class KeymasterClient {
961
1110
  }
962
1111
  async removeVaultMember(vaultId, memberId) {
963
1112
  try {
964
- const response = await axios.delete(`${this.API}/vaults/${vaultId}/members/${memberId}`);
1113
+ const response = await this.axios.delete(`${this.API}/vaults/${vaultId}/members/${memberId}`);
965
1114
  return response.data.ok;
966
1115
  }
967
1116
  catch (error) {
@@ -970,7 +1119,7 @@ class KeymasterClient {
970
1119
  }
971
1120
  async listVaultMembers(vaultId) {
972
1121
  try {
973
- const response = await axios.get(`${this.API}/vaults/${vaultId}/members`);
1122
+ const response = await this.axios.get(`${this.API}/vaults/${vaultId}/members`);
974
1123
  return response.data.members;
975
1124
  }
976
1125
  catch (error) {
@@ -979,7 +1128,7 @@ class KeymasterClient {
979
1128
  }
980
1129
  async addVaultItem(vaultId, name, buffer) {
981
1130
  try {
982
- const response = await axios.post(`${this.API}/vaults/${vaultId}/items`, buffer, {
1131
+ const response = await this.axios.post(`${this.API}/vaults/${vaultId}/items`, buffer, {
983
1132
  headers: {
984
1133
  // eslint-disable-next-line
985
1134
  'Content-Type': 'application/octet-stream',
@@ -994,7 +1143,7 @@ class KeymasterClient {
994
1143
  }
995
1144
  async removeVaultItem(vaultId, name) {
996
1145
  try {
997
- const response = await axios.delete(`${this.API}/vaults/${vaultId}/items/${name}`);
1146
+ const response = await this.axios.delete(`${this.API}/vaults/${vaultId}/items/${name}`);
998
1147
  return response.data.ok;
999
1148
  }
1000
1149
  catch (error) {
@@ -1005,11 +1154,11 @@ class KeymasterClient {
1005
1154
  try {
1006
1155
  if (options) {
1007
1156
  const queryParams = new URLSearchParams(options);
1008
- const response = await axios.get(`${this.API}/vaults/${vaultId}/items?${queryParams.toString()}`);
1157
+ const response = await this.axios.get(`${this.API}/vaults/${vaultId}/items?${queryParams.toString()}`);
1009
1158
  return response.data.items;
1010
1159
  }
1011
1160
  else {
1012
- const response = await axios.get(`${this.API}/vaults/${vaultId}/items`);
1161
+ const response = await this.axios.get(`${this.API}/vaults/${vaultId}/items`);
1013
1162
  return response.data.items;
1014
1163
  }
1015
1164
  }
@@ -1024,7 +1173,7 @@ class KeymasterClient {
1024
1173
  const queryParams = new URLSearchParams(options);
1025
1174
  url += `?${queryParams.toString()}`;
1026
1175
  }
1027
- const response = await axios.get(url, {
1176
+ const response = await this.axios.get(url, {
1028
1177
  responseType: 'arraybuffer'
1029
1178
  });
1030
1179
  if (!response.data || (buffer.Buffer.isBuffer(response.data) && response.data.length === 0)) {
@@ -1048,7 +1197,7 @@ class KeymasterClient {
1048
1197
  }
1049
1198
  async listDmail() {
1050
1199
  try {
1051
- const response = await axios.get(`${this.API}/dmail`);
1200
+ const response = await this.axios.get(`${this.API}/dmail`);
1052
1201
  return response.data.dmail;
1053
1202
  }
1054
1203
  catch (error) {
@@ -1057,7 +1206,7 @@ class KeymasterClient {
1057
1206
  }
1058
1207
  async createDmail(message, options = {}) {
1059
1208
  try {
1060
- const response = await axios.post(`${this.API}/dmail`, { message, options });
1209
+ const response = await this.axios.post(`${this.API}/dmail`, { message, options });
1061
1210
  return response.data.did;
1062
1211
  }
1063
1212
  catch (error) {
@@ -1066,7 +1215,7 @@ class KeymasterClient {
1066
1215
  }
1067
1216
  async updateDmail(did, message) {
1068
1217
  try {
1069
- const response = await axios.put(`${this.API}/dmail/${did}`, { message });
1218
+ const response = await this.axios.put(`${this.API}/dmail/${did}`, { message });
1070
1219
  return response.data.ok;
1071
1220
  }
1072
1221
  catch (error) {
@@ -1075,7 +1224,7 @@ class KeymasterClient {
1075
1224
  }
1076
1225
  async sendDmail(did) {
1077
1226
  try {
1078
- const response = await axios.post(`${this.API}/dmail/${did}/send`);
1227
+ const response = await this.axios.post(`${this.API}/dmail/${did}/send`);
1079
1228
  return response.data.did;
1080
1229
  }
1081
1230
  catch (error) {
@@ -1084,7 +1233,7 @@ class KeymasterClient {
1084
1233
  }
1085
1234
  async fileDmail(did, tags) {
1086
1235
  try {
1087
- const response = await axios.post(`${this.API}/dmail/${did}/file`, { tags });
1236
+ const response = await this.axios.post(`${this.API}/dmail/${did}/file`, { tags });
1088
1237
  return response.data.ok;
1089
1238
  }
1090
1239
  catch (error) {
@@ -1093,7 +1242,7 @@ class KeymasterClient {
1093
1242
  }
1094
1243
  async removeDmail(did) {
1095
1244
  try {
1096
- const response = await axios.delete(`${this.API}/dmail/${did}`);
1245
+ const response = await this.axios.delete(`${this.API}/dmail/${did}`);
1097
1246
  return response.data.ok;
1098
1247
  }
1099
1248
  catch (error) {
@@ -1104,11 +1253,11 @@ class KeymasterClient {
1104
1253
  try {
1105
1254
  if (options) {
1106
1255
  const queryParams = new URLSearchParams(options);
1107
- const response = await axios.get(`${this.API}/dmail/${did}?${queryParams.toString()}`);
1256
+ const response = await this.axios.get(`${this.API}/dmail/${did}?${queryParams.toString()}`);
1108
1257
  return response.data.message;
1109
1258
  }
1110
1259
  else {
1111
- const response = await axios.get(`${this.API}/dmail/${did}`);
1260
+ const response = await this.axios.get(`${this.API}/dmail/${did}`);
1112
1261
  return response.data.message;
1113
1262
  }
1114
1263
  }
@@ -1120,11 +1269,11 @@ class KeymasterClient {
1120
1269
  try {
1121
1270
  if (options) {
1122
1271
  const queryParams = new URLSearchParams(options);
1123
- const response = await axios.get(`${this.API}/dmail/${did}/attachments?${queryParams.toString()}`);
1272
+ const response = await this.axios.get(`${this.API}/dmail/${did}/attachments?${queryParams.toString()}`);
1124
1273
  return response.data.attachments;
1125
1274
  }
1126
1275
  else {
1127
- const response = await axios.get(`${this.API}/dmail/${did}/attachments`);
1276
+ const response = await this.axios.get(`${this.API}/dmail/${did}/attachments`);
1128
1277
  return response.data.attachments;
1129
1278
  }
1130
1279
  }
@@ -1134,7 +1283,7 @@ class KeymasterClient {
1134
1283
  }
1135
1284
  async addDmailAttachment(did, name, buffer) {
1136
1285
  try {
1137
- const response = await axios.post(`${this.API}/dmail/${did}/attachments`, buffer, {
1286
+ const response = await this.axios.post(`${this.API}/dmail/${did}/attachments`, buffer, {
1138
1287
  headers: {
1139
1288
  // eslint-disable-next-line
1140
1289
  'Content-Type': 'application/octet-stream',
@@ -1149,7 +1298,7 @@ class KeymasterClient {
1149
1298
  }
1150
1299
  async removeDmailAttachment(did, name) {
1151
1300
  try {
1152
- const response = await axios.delete(`${this.API}/dmail/${did}/attachments/${name}`);
1301
+ const response = await this.axios.delete(`${this.API}/dmail/${did}/attachments/${name}`);
1153
1302
  return response.data.ok;
1154
1303
  }
1155
1304
  catch (error) {
@@ -1158,7 +1307,7 @@ class KeymasterClient {
1158
1307
  }
1159
1308
  async getDmailAttachment(did, name) {
1160
1309
  try {
1161
- const response = await axios.get(`${this.API}/dmail/${did}/attachments/${name}`, {
1310
+ const response = await this.axios.get(`${this.API}/dmail/${did}/attachments/${name}`, {
1162
1311
  responseType: 'arraybuffer'
1163
1312
  });
1164
1313
  if (!response.data || (buffer.Buffer.isBuffer(response.data) && response.data.length === 0)) {
@@ -1182,7 +1331,7 @@ class KeymasterClient {
1182
1331
  }
1183
1332
  async importDmail(did) {
1184
1333
  try {
1185
- const response = await axios.post(`${this.API}/dmail/import`, { did });
1334
+ const response = await this.axios.post(`${this.API}/dmail/import`, { did });
1186
1335
  return response.data.ok;
1187
1336
  }
1188
1337
  catch (error) {
@@ -1191,7 +1340,7 @@ class KeymasterClient {
1191
1340
  }
1192
1341
  async createNotice(message, options = {}) {
1193
1342
  try {
1194
- const response = await axios.post(`${this.API}/notices`, { message, options });
1343
+ const response = await this.axios.post(`${this.API}/notices`, { message, options });
1195
1344
  return response.data.did;
1196
1345
  }
1197
1346
  catch (error) {
@@ -1200,7 +1349,7 @@ class KeymasterClient {
1200
1349
  }
1201
1350
  async updateNotice(did, message) {
1202
1351
  try {
1203
- const response = await axios.put(`${this.API}/notices/${did}`, { message });
1352
+ const response = await this.axios.put(`${this.API}/notices/${did}`, { message });
1204
1353
  return response.data.ok;
1205
1354
  }
1206
1355
  catch (error) {
@@ -1209,7 +1358,7 @@ class KeymasterClient {
1209
1358
  }
1210
1359
  async refreshNotices() {
1211
1360
  try {
1212
- const response = await axios.post(`${this.API}/notices/refresh`);
1361
+ const response = await this.axios.post(`${this.API}/notices/refresh`);
1213
1362
  return response.data.ok;
1214
1363
  }
1215
1364
  catch (error) {
@@ -1218,7 +1367,7 @@ class KeymasterClient {
1218
1367
  }
1219
1368
  async exportEncryptedWallet() {
1220
1369
  try {
1221
- const response = await axios.get(`${this.API}/export/wallet/encrypted`);
1370
+ const response = await this.axios.get(`${this.API}/export/wallet/encrypted`);
1222
1371
  return response.data.wallet;
1223
1372
  }
1224
1373
  catch (error) {