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