@yourself_id/siwys-api-js 0.10.0 → 0.10.1-SAPP-221-mdipUpdate.0
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/index.cjs +1226 -165
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -59
- package/dist/index.d.ts +74 -59
- package/dist/index.js +1224 -166
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_without_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
9
|
+
}
|
|
2
10
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
3
11
|
try {
|
|
4
12
|
var info = gen[key](arg);
|
|
@@ -47,10 +55,27 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
47
55
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
48
56
|
return Constructor;
|
|
49
57
|
}
|
|
58
|
+
function _iterable_to_array(iter) {
|
|
59
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
60
|
+
}
|
|
61
|
+
function _non_iterable_spread() {
|
|
62
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
63
|
+
}
|
|
64
|
+
function _to_consumable_array(arr) {
|
|
65
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
66
|
+
}
|
|
50
67
|
function _type_of(obj) {
|
|
51
68
|
"@swc/helpers - typeof";
|
|
52
69
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
53
70
|
}
|
|
71
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
72
|
+
if (!o) return;
|
|
73
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
74
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
75
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
76
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
77
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
78
|
+
}
|
|
54
79
|
function _ts_generator(thisArg, body) {
|
|
55
80
|
var f, y, t, g, _ = {
|
|
56
81
|
label: 0,
|
|
@@ -209,62 +234,82 @@ var src_exports = {};
|
|
|
209
234
|
__export(src_exports, {
|
|
210
235
|
Keymaster: function() {
|
|
211
236
|
return Keymaster;
|
|
237
|
+
},
|
|
238
|
+
KeymasterExternalClient: function() {
|
|
239
|
+
return KeymasterExternalClient;
|
|
212
240
|
}
|
|
213
241
|
});
|
|
214
242
|
module.exports = __toCommonJS(src_exports);
|
|
215
243
|
// src/keymaster.ts
|
|
216
244
|
var import_client = __toESM(require("@mdip/gatekeeper/client"), 1);
|
|
217
245
|
var import_node = __toESM(require("@mdip/cipher/node"), 1);
|
|
218
|
-
var import_client2 = __toESM(require("@mdip/keymaster/client"), 1);
|
|
219
246
|
var import_keymaster = __toESM(require("@mdip/keymaster"), 1);
|
|
220
|
-
var
|
|
221
|
-
function
|
|
222
|
-
_class_call_check(this,
|
|
247
|
+
var _Keymaster = /*#__PURE__*/ function() {
|
|
248
|
+
function _Keymaster(config) {
|
|
249
|
+
_class_call_check(this, _Keymaster);
|
|
223
250
|
this.serviceStarted = false;
|
|
224
251
|
this.validateConfig(config);
|
|
225
252
|
this.config = config;
|
|
226
253
|
}
|
|
227
|
-
_create_class(
|
|
254
|
+
_create_class(_Keymaster, [
|
|
228
255
|
{
|
|
229
|
-
key: "
|
|
230
|
-
value: function
|
|
256
|
+
key: "ensureInitialized",
|
|
257
|
+
value: function ensureInitialized() {
|
|
258
|
+
if (!_Keymaster.instance) {
|
|
259
|
+
throw new Error("Keymaster not initialized. Call Keymaster.initialize() first.");
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
key: "ensureServiceIsRunning",
|
|
265
|
+
value: // -------- Internal instance methods (originals renamed with Internal) -------
|
|
266
|
+
function ensureServiceIsRunning() {
|
|
231
267
|
var _this = this;
|
|
232
268
|
return _async_to_generator(function() {
|
|
233
269
|
return _ts_generator(this, function(_state) {
|
|
234
270
|
switch(_state.label){
|
|
235
271
|
case 0:
|
|
236
|
-
if (!_this.config.gatekeeperConfig) return [
|
|
237
|
-
3,
|
|
238
|
-
2
|
|
239
|
-
];
|
|
240
272
|
return [
|
|
241
273
|
4,
|
|
242
|
-
_this.
|
|
274
|
+
_this.serviceRunning()
|
|
243
275
|
];
|
|
244
276
|
case 1:
|
|
245
|
-
|
|
277
|
+
if (!_state.sent()) {
|
|
278
|
+
throw new Error("Keymaster service not running");
|
|
279
|
+
}
|
|
246
280
|
return [
|
|
247
|
-
|
|
248
|
-
5
|
|
281
|
+
2
|
|
249
282
|
];
|
|
250
|
-
|
|
251
|
-
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
})();
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
key: "startInternal",
|
|
290
|
+
value: function startInternal() {
|
|
291
|
+
var _this = this;
|
|
292
|
+
return _async_to_generator(function() {
|
|
293
|
+
return _ts_generator(this, function(_state) {
|
|
294
|
+
switch(_state.label){
|
|
295
|
+
case 0:
|
|
296
|
+
if (!_this.config.gatekeeperConfig) return [
|
|
252
297
|
3,
|
|
253
|
-
|
|
298
|
+
2
|
|
254
299
|
];
|
|
255
300
|
return [
|
|
256
301
|
4,
|
|
257
|
-
_this.
|
|
302
|
+
_this.startIntegratedKeymaster()
|
|
258
303
|
];
|
|
259
|
-
case
|
|
304
|
+
case 1:
|
|
260
305
|
_this.serviceStarted = _state.sent();
|
|
261
306
|
return [
|
|
262
307
|
3,
|
|
263
|
-
|
|
308
|
+
3
|
|
264
309
|
];
|
|
265
|
-
case
|
|
266
|
-
throw "Missing Gatekeeper
|
|
267
|
-
case
|
|
310
|
+
case 2:
|
|
311
|
+
throw "Missing Gatekeeper config";
|
|
312
|
+
case 3:
|
|
268
313
|
return [
|
|
269
314
|
2,
|
|
270
315
|
_this.serviceStarted
|
|
@@ -288,10 +333,14 @@ var Keymaster = /*#__PURE__*/ function() {
|
|
|
288
333
|
case 1:
|
|
289
334
|
_state.trys.push([
|
|
290
335
|
1,
|
|
291
|
-
|
|
336
|
+
6,
|
|
292
337
|
,
|
|
293
|
-
|
|
338
|
+
7
|
|
294
339
|
]);
|
|
340
|
+
if (!_this.config.walletDb) return [
|
|
341
|
+
3,
|
|
342
|
+
4
|
|
343
|
+
];
|
|
295
344
|
gatekeeper = new import_client.default();
|
|
296
345
|
return [
|
|
297
346
|
4,
|
|
@@ -300,34 +349,39 @@ var Keymaster = /*#__PURE__*/ function() {
|
|
|
300
349
|
case 2:
|
|
301
350
|
_state.sent();
|
|
302
351
|
cipher = new import_node.default();
|
|
352
|
+
_this.keymasterService = new import_keymaster.default({
|
|
353
|
+
gatekeeper: gatekeeper,
|
|
354
|
+
wallet: _this.config.walletDb,
|
|
355
|
+
cipher: cipher
|
|
356
|
+
});
|
|
303
357
|
return [
|
|
304
358
|
4,
|
|
305
|
-
|
|
306
|
-
gatekeeper: gatekeeper,
|
|
307
|
-
wallet: _this.config.walletDb,
|
|
308
|
-
cipher: cipher
|
|
309
|
-
})
|
|
359
|
+
_this.ensureWalletExists()
|
|
310
360
|
];
|
|
311
361
|
case 3:
|
|
312
|
-
|
|
362
|
+
_state.sent();
|
|
313
363
|
return [
|
|
314
|
-
|
|
315
|
-
|
|
364
|
+
3,
|
|
365
|
+
5
|
|
316
366
|
];
|
|
317
367
|
case 4:
|
|
318
|
-
_state.sent();
|
|
319
368
|
return [
|
|
320
|
-
|
|
321
|
-
|
|
369
|
+
2,
|
|
370
|
+
false
|
|
322
371
|
];
|
|
323
372
|
case 5:
|
|
373
|
+
return [
|
|
374
|
+
3,
|
|
375
|
+
7
|
|
376
|
+
];
|
|
377
|
+
case 6:
|
|
324
378
|
e = _state.sent();
|
|
325
379
|
console.error("Error starting Keymaster service:", e);
|
|
326
380
|
return [
|
|
327
381
|
2,
|
|
328
382
|
false
|
|
329
383
|
];
|
|
330
|
-
case
|
|
384
|
+
case 7:
|
|
331
385
|
console.log("Started integrated Keymaster service");
|
|
332
386
|
return [
|
|
333
387
|
2,
|
|
@@ -339,46 +393,32 @@ var Keymaster = /*#__PURE__*/ function() {
|
|
|
339
393
|
}
|
|
340
394
|
},
|
|
341
395
|
{
|
|
342
|
-
key: "
|
|
343
|
-
value: function
|
|
396
|
+
key: "createChallengeInternal",
|
|
397
|
+
value: function createChallengeInternal(spec, options) {
|
|
344
398
|
var _this = this;
|
|
345
399
|
return _async_to_generator(function() {
|
|
346
|
-
var
|
|
400
|
+
var challenge;
|
|
347
401
|
return _ts_generator(this, function(_state) {
|
|
348
402
|
switch(_state.label){
|
|
349
403
|
case 0:
|
|
350
|
-
console.log("Starting external Keymaster service");
|
|
351
|
-
_state.label = 1;
|
|
352
|
-
case 1:
|
|
353
|
-
_state.trys.push([
|
|
354
|
-
1,
|
|
355
|
-
3,
|
|
356
|
-
,
|
|
357
|
-
4
|
|
358
|
-
]);
|
|
359
|
-
_this.keymasterService = new import_client2.default();
|
|
360
404
|
return [
|
|
361
405
|
4,
|
|
362
|
-
_this.
|
|
406
|
+
_this.ensureServiceIsRunning()
|
|
363
407
|
];
|
|
364
|
-
case
|
|
408
|
+
case 1:
|
|
365
409
|
_state.sent();
|
|
366
410
|
return [
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
];
|
|
370
|
-
case 3:
|
|
371
|
-
e = _state.sent();
|
|
372
|
-
console.error("Error starting Keymaster service:", e);
|
|
373
|
-
return [
|
|
374
|
-
2,
|
|
375
|
-
false
|
|
411
|
+
4,
|
|
412
|
+
_this.keymasterService.createChallenge(spec, options)
|
|
376
413
|
];
|
|
377
|
-
case
|
|
378
|
-
|
|
414
|
+
case 2:
|
|
415
|
+
challenge = _state.sent();
|
|
379
416
|
return [
|
|
380
417
|
2,
|
|
381
|
-
|
|
418
|
+
{
|
|
419
|
+
challenge: challenge,
|
|
420
|
+
challengeUrl: "".concat(spec.callback, "?challenge=").concat(challenge)
|
|
421
|
+
}
|
|
382
422
|
];
|
|
383
423
|
}
|
|
384
424
|
});
|
|
@@ -386,29 +426,23 @@ var Keymaster = /*#__PURE__*/ function() {
|
|
|
386
426
|
}
|
|
387
427
|
},
|
|
388
428
|
{
|
|
389
|
-
key: "
|
|
390
|
-
value: function
|
|
429
|
+
key: "bindCredentialInternal",
|
|
430
|
+
value: function bindCredentialInternal(schemaId, subjectId) {
|
|
431
|
+
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
391
432
|
var _this = this;
|
|
392
433
|
return _async_to_generator(function() {
|
|
393
|
-
var challenge;
|
|
394
434
|
return _ts_generator(this, function(_state) {
|
|
395
435
|
switch(_state.label){
|
|
396
436
|
case 0:
|
|
397
|
-
if (!_this.serviceRunning()) {
|
|
398
|
-
throw new Error("Keymaster service not running");
|
|
399
|
-
}
|
|
400
437
|
return [
|
|
401
438
|
4,
|
|
402
|
-
_this.
|
|
439
|
+
_this.ensureServiceIsRunning()
|
|
403
440
|
];
|
|
404
441
|
case 1:
|
|
405
|
-
|
|
442
|
+
_state.sent();
|
|
406
443
|
return [
|
|
407
444
|
2,
|
|
408
|
-
|
|
409
|
-
challenge: challenge,
|
|
410
|
-
challengeUrl: "".concat(spec.callback, "?challenge=").concat(challenge)
|
|
411
|
-
}
|
|
445
|
+
_this.keymasterService.bindCredential(schemaId, subjectId, options)
|
|
412
446
|
];
|
|
413
447
|
}
|
|
414
448
|
});
|
|
@@ -416,114 +450,143 @@ var Keymaster = /*#__PURE__*/ function() {
|
|
|
416
450
|
}
|
|
417
451
|
},
|
|
418
452
|
{
|
|
419
|
-
key: "
|
|
420
|
-
value: function
|
|
421
|
-
var options = arguments.length >
|
|
453
|
+
key: "issueCredentialInternal",
|
|
454
|
+
value: function issueCredentialInternal(credential) {
|
|
455
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
422
456
|
var _this = this;
|
|
423
457
|
return _async_to_generator(function() {
|
|
424
458
|
return _ts_generator(this, function(_state) {
|
|
425
|
-
|
|
426
|
-
|
|
459
|
+
switch(_state.label){
|
|
460
|
+
case 0:
|
|
461
|
+
return [
|
|
462
|
+
4,
|
|
463
|
+
_this.ensureServiceIsRunning()
|
|
464
|
+
];
|
|
465
|
+
case 1:
|
|
466
|
+
_state.sent();
|
|
467
|
+
return [
|
|
468
|
+
2,
|
|
469
|
+
_this.keymasterService.issueCredential(credential, options)
|
|
470
|
+
];
|
|
427
471
|
}
|
|
428
|
-
return [
|
|
429
|
-
2,
|
|
430
|
-
_this.keymasterService.bindCredential(schemaId, subjectId, options)
|
|
431
|
-
];
|
|
432
472
|
});
|
|
433
473
|
})();
|
|
434
474
|
}
|
|
435
475
|
},
|
|
436
476
|
{
|
|
437
|
-
key: "
|
|
438
|
-
value: function
|
|
477
|
+
key: "publishCredentialInternal",
|
|
478
|
+
value: function publishCredentialInternal(did) {
|
|
439
479
|
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
440
480
|
var _this = this;
|
|
441
481
|
return _async_to_generator(function() {
|
|
442
482
|
return _ts_generator(this, function(_state) {
|
|
443
|
-
|
|
444
|
-
|
|
483
|
+
switch(_state.label){
|
|
484
|
+
case 0:
|
|
485
|
+
return [
|
|
486
|
+
4,
|
|
487
|
+
_this.ensureServiceIsRunning()
|
|
488
|
+
];
|
|
489
|
+
case 1:
|
|
490
|
+
_state.sent();
|
|
491
|
+
return [
|
|
492
|
+
2,
|
|
493
|
+
_this.keymasterService.publishCredential(did, options)
|
|
494
|
+
];
|
|
445
495
|
}
|
|
446
|
-
return [
|
|
447
|
-
2,
|
|
448
|
-
_this.keymasterService.issueCredential(credential, options)
|
|
449
|
-
];
|
|
450
496
|
});
|
|
451
497
|
})();
|
|
452
498
|
}
|
|
453
499
|
},
|
|
454
500
|
{
|
|
455
|
-
key: "
|
|
456
|
-
value: function
|
|
457
|
-
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
501
|
+
key: "acceptCredentialInternal",
|
|
502
|
+
value: function acceptCredentialInternal(did) {
|
|
458
503
|
var _this = this;
|
|
459
504
|
return _async_to_generator(function() {
|
|
460
505
|
return _ts_generator(this, function(_state) {
|
|
461
|
-
|
|
462
|
-
|
|
506
|
+
switch(_state.label){
|
|
507
|
+
case 0:
|
|
508
|
+
return [
|
|
509
|
+
4,
|
|
510
|
+
_this.ensureServiceIsRunning()
|
|
511
|
+
];
|
|
512
|
+
case 1:
|
|
513
|
+
_state.sent();
|
|
514
|
+
return [
|
|
515
|
+
2,
|
|
516
|
+
_this.keymasterService.acceptCredential(did)
|
|
517
|
+
];
|
|
463
518
|
}
|
|
464
|
-
return [
|
|
465
|
-
2,
|
|
466
|
-
_this.keymasterService.publishCredential(did, options)
|
|
467
|
-
];
|
|
468
519
|
});
|
|
469
520
|
})();
|
|
470
521
|
}
|
|
471
522
|
},
|
|
472
523
|
{
|
|
473
|
-
key: "
|
|
474
|
-
value: function
|
|
524
|
+
key: "showMnemonicInternal",
|
|
525
|
+
value: function showMnemonicInternal() {
|
|
475
526
|
var _this = this;
|
|
476
527
|
return _async_to_generator(function() {
|
|
477
528
|
return _ts_generator(this, function(_state) {
|
|
478
|
-
|
|
479
|
-
|
|
529
|
+
switch(_state.label){
|
|
530
|
+
case 0:
|
|
531
|
+
return [
|
|
532
|
+
4,
|
|
533
|
+
_this.ensureServiceIsRunning()
|
|
534
|
+
];
|
|
535
|
+
case 1:
|
|
536
|
+
_state.sent();
|
|
537
|
+
return [
|
|
538
|
+
2,
|
|
539
|
+
_this.keymasterService.decryptMnemonic()
|
|
540
|
+
];
|
|
480
541
|
}
|
|
481
|
-
return [
|
|
482
|
-
2,
|
|
483
|
-
_this.keymasterService.acceptCredential(did)
|
|
484
|
-
];
|
|
485
542
|
});
|
|
486
543
|
})();
|
|
487
544
|
}
|
|
488
545
|
},
|
|
489
546
|
{
|
|
490
|
-
key: "
|
|
491
|
-
value: function
|
|
547
|
+
key: "verifyResponseInternal",
|
|
548
|
+
value: function verifyResponseInternal(did, options) {
|
|
492
549
|
var _this = this;
|
|
493
550
|
return _async_to_generator(function() {
|
|
494
551
|
return _ts_generator(this, function(_state) {
|
|
495
|
-
|
|
496
|
-
|
|
552
|
+
switch(_state.label){
|
|
553
|
+
case 0:
|
|
554
|
+
return [
|
|
555
|
+
4,
|
|
556
|
+
_this.ensureServiceIsRunning()
|
|
557
|
+
];
|
|
558
|
+
case 1:
|
|
559
|
+
_state.sent();
|
|
560
|
+
return [
|
|
561
|
+
2,
|
|
562
|
+
_this.keymasterService.verifyResponse(did, options)
|
|
563
|
+
];
|
|
497
564
|
}
|
|
498
|
-
return [
|
|
499
|
-
2,
|
|
500
|
-
_this.keymasterService.decryptMnemonic()
|
|
501
|
-
];
|
|
502
565
|
});
|
|
503
566
|
})();
|
|
504
567
|
}
|
|
505
568
|
},
|
|
506
569
|
{
|
|
507
|
-
key: "
|
|
508
|
-
value: function
|
|
570
|
+
key: "decryptMessageInternal",
|
|
571
|
+
value: function decryptMessageInternal() {
|
|
572
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
573
|
+
args[_key] = arguments[_key];
|
|
574
|
+
}
|
|
509
575
|
var _this = this;
|
|
510
576
|
return _async_to_generator(function() {
|
|
511
|
-
var
|
|
577
|
+
var _this_keymasterService;
|
|
512
578
|
return _ts_generator(this, function(_state) {
|
|
513
579
|
switch(_state.label){
|
|
514
580
|
case 0:
|
|
515
|
-
if (!_this.serviceRunning()) {
|
|
516
|
-
throw new Error("Keymaster service not running");
|
|
517
|
-
}
|
|
518
581
|
return [
|
|
519
582
|
4,
|
|
520
|
-
_this.
|
|
583
|
+
_this.ensureServiceIsRunning()
|
|
521
584
|
];
|
|
522
585
|
case 1:
|
|
523
|
-
|
|
586
|
+
_state.sent();
|
|
524
587
|
return [
|
|
525
588
|
2,
|
|
526
|
-
|
|
589
|
+
(_this_keymasterService = _this.keymasterService).decryptMessage.apply(_this_keymasterService, _to_consumable_array(args))
|
|
527
590
|
];
|
|
528
591
|
}
|
|
529
592
|
});
|
|
@@ -531,50 +594,355 @@ var Keymaster = /*#__PURE__*/ function() {
|
|
|
531
594
|
}
|
|
532
595
|
},
|
|
533
596
|
{
|
|
534
|
-
key: "
|
|
535
|
-
value: function
|
|
597
|
+
key: "decryptMnemonicInternal",
|
|
598
|
+
value: function decryptMnemonicInternal() {
|
|
599
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
600
|
+
args[_key] = arguments[_key];
|
|
601
|
+
}
|
|
536
602
|
var _this = this;
|
|
537
603
|
return _async_to_generator(function() {
|
|
538
|
-
var
|
|
604
|
+
var _this_keymasterService;
|
|
539
605
|
return _ts_generator(this, function(_state) {
|
|
540
606
|
switch(_state.label){
|
|
541
607
|
case 0:
|
|
542
|
-
console.log("Ensuring wallet exists");
|
|
543
608
|
return [
|
|
544
609
|
4,
|
|
545
|
-
|
|
610
|
+
_this.ensureServiceIsRunning()
|
|
546
611
|
];
|
|
547
612
|
case 1:
|
|
548
|
-
existing = _state.sent() || null;
|
|
549
|
-
if (existing === null || existing === void 0 ? void 0 : existing.current) {
|
|
550
|
-
console.log("Using existing wallet with ID ".concat(existing.current));
|
|
551
|
-
return [
|
|
552
|
-
2
|
|
553
|
-
];
|
|
554
|
-
}
|
|
555
|
-
walletConfig = _this.config.walletConfig;
|
|
556
|
-
console.log("Creating Creating Creating wallet with ID ".concat(walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.id));
|
|
557
|
-
if (!(walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.mnemonic)) return [
|
|
558
|
-
3,
|
|
559
|
-
3
|
|
560
|
-
];
|
|
561
|
-
return [
|
|
562
|
-
4,
|
|
563
|
-
_this.keymasterService.newWallet(walletConfig.mnemonic, true)
|
|
564
|
-
];
|
|
565
|
-
case 2:
|
|
566
613
|
_state.sent();
|
|
567
|
-
_state.label = 3;
|
|
568
|
-
case 3:
|
|
569
614
|
return [
|
|
570
|
-
|
|
571
|
-
_this.keymasterService.
|
|
615
|
+
2,
|
|
616
|
+
(_this_keymasterService = _this.keymasterService).decryptMnemonic.apply(_this_keymasterService, _to_consumable_array(args))
|
|
572
617
|
];
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
})();
|
|
621
|
+
}
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
key: "getCredentialInternal",
|
|
625
|
+
value: function getCredentialInternal() {
|
|
626
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
627
|
+
args[_key] = arguments[_key];
|
|
628
|
+
}
|
|
629
|
+
var _this = this;
|
|
630
|
+
return _async_to_generator(function() {
|
|
631
|
+
var _this_keymasterService;
|
|
632
|
+
return _ts_generator(this, function(_state) {
|
|
633
|
+
switch(_state.label){
|
|
634
|
+
case 0:
|
|
635
|
+
return [
|
|
636
|
+
4,
|
|
637
|
+
_this.ensureServiceIsRunning()
|
|
638
|
+
];
|
|
639
|
+
case 1:
|
|
640
|
+
_state.sent();
|
|
641
|
+
return [
|
|
642
|
+
2,
|
|
643
|
+
(_this_keymasterService = _this.keymasterService).getCredential.apply(_this_keymasterService, _to_consumable_array(args))
|
|
644
|
+
];
|
|
645
|
+
}
|
|
646
|
+
});
|
|
647
|
+
})();
|
|
648
|
+
}
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
key: "removeCredentialInternal",
|
|
652
|
+
value: function removeCredentialInternal() {
|
|
653
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
654
|
+
args[_key] = arguments[_key];
|
|
655
|
+
}
|
|
656
|
+
var _this = this;
|
|
657
|
+
return _async_to_generator(function() {
|
|
658
|
+
var _this_keymasterService;
|
|
659
|
+
return _ts_generator(this, function(_state) {
|
|
660
|
+
switch(_state.label){
|
|
661
|
+
case 0:
|
|
662
|
+
return [
|
|
663
|
+
4,
|
|
664
|
+
_this.ensureServiceIsRunning()
|
|
665
|
+
];
|
|
666
|
+
case 1:
|
|
667
|
+
_state.sent();
|
|
668
|
+
return [
|
|
669
|
+
2,
|
|
670
|
+
(_this_keymasterService = _this.keymasterService).removeCredential.apply(_this_keymasterService, _to_consumable_array(args))
|
|
671
|
+
];
|
|
672
|
+
}
|
|
673
|
+
});
|
|
674
|
+
})();
|
|
675
|
+
}
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
key: "updateCredentialInternal",
|
|
679
|
+
value: function updateCredentialInternal() {
|
|
680
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
681
|
+
args[_key] = arguments[_key];
|
|
682
|
+
}
|
|
683
|
+
var _this = this;
|
|
684
|
+
return _async_to_generator(function() {
|
|
685
|
+
var _this_keymasterService;
|
|
686
|
+
return _ts_generator(this, function(_state) {
|
|
687
|
+
switch(_state.label){
|
|
688
|
+
case 0:
|
|
689
|
+
return [
|
|
690
|
+
4,
|
|
691
|
+
_this.ensureServiceIsRunning()
|
|
692
|
+
];
|
|
693
|
+
case 1:
|
|
694
|
+
_state.sent();
|
|
695
|
+
return [
|
|
696
|
+
2,
|
|
697
|
+
(_this_keymasterService = _this.keymasterService).updateCredential.apply(_this_keymasterService, _to_consumable_array(args))
|
|
698
|
+
];
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
})();
|
|
702
|
+
}
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
key: "createIdInternal",
|
|
706
|
+
value: function createIdInternal() {
|
|
707
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
708
|
+
args[_key] = arguments[_key];
|
|
709
|
+
}
|
|
710
|
+
var _this = this;
|
|
711
|
+
return _async_to_generator(function() {
|
|
712
|
+
var _this_keymasterService;
|
|
713
|
+
return _ts_generator(this, function(_state) {
|
|
714
|
+
switch(_state.label){
|
|
715
|
+
case 0:
|
|
716
|
+
return [
|
|
717
|
+
4,
|
|
718
|
+
_this.ensureServiceIsRunning()
|
|
719
|
+
];
|
|
720
|
+
case 1:
|
|
721
|
+
_state.sent();
|
|
722
|
+
return [
|
|
723
|
+
2,
|
|
724
|
+
(_this_keymasterService = _this.keymasterService).createId.apply(_this_keymasterService, _to_consumable_array(args))
|
|
725
|
+
];
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
})();
|
|
729
|
+
}
|
|
730
|
+
},
|
|
731
|
+
{
|
|
732
|
+
key: "removeIdInternal",
|
|
733
|
+
value: function removeIdInternal() {
|
|
734
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
735
|
+
args[_key] = arguments[_key];
|
|
736
|
+
}
|
|
737
|
+
var _this = this;
|
|
738
|
+
return _async_to_generator(function() {
|
|
739
|
+
var _this_keymasterService;
|
|
740
|
+
return _ts_generator(this, function(_state) {
|
|
741
|
+
switch(_state.label){
|
|
742
|
+
case 0:
|
|
743
|
+
return [
|
|
744
|
+
4,
|
|
745
|
+
_this.ensureServiceIsRunning()
|
|
746
|
+
];
|
|
747
|
+
case 1:
|
|
748
|
+
_state.sent();
|
|
749
|
+
return [
|
|
750
|
+
2,
|
|
751
|
+
(_this_keymasterService = _this.keymasterService).removeId.apply(_this_keymasterService, _to_consumable_array(args))
|
|
752
|
+
];
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
})();
|
|
756
|
+
}
|
|
757
|
+
},
|
|
758
|
+
{
|
|
759
|
+
key: "resolveDIDInternal",
|
|
760
|
+
value: function resolveDIDInternal() {
|
|
761
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
762
|
+
args[_key] = arguments[_key];
|
|
763
|
+
}
|
|
764
|
+
var _this = this;
|
|
765
|
+
return _async_to_generator(function() {
|
|
766
|
+
var _this_keymasterService;
|
|
767
|
+
return _ts_generator(this, function(_state) {
|
|
768
|
+
switch(_state.label){
|
|
769
|
+
case 0:
|
|
770
|
+
return [
|
|
771
|
+
4,
|
|
772
|
+
_this.ensureServiceIsRunning()
|
|
773
|
+
];
|
|
774
|
+
case 1:
|
|
775
|
+
_state.sent();
|
|
776
|
+
return [
|
|
777
|
+
2,
|
|
778
|
+
(_this_keymasterService = _this.keymasterService).resolveDID.apply(_this_keymasterService, _to_consumable_array(args))
|
|
779
|
+
];
|
|
780
|
+
}
|
|
781
|
+
});
|
|
782
|
+
})();
|
|
783
|
+
}
|
|
784
|
+
},
|
|
785
|
+
{
|
|
786
|
+
key: "setCurrentIdInternal",
|
|
787
|
+
value: function setCurrentIdInternal() {
|
|
788
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
789
|
+
args[_key] = arguments[_key];
|
|
790
|
+
}
|
|
791
|
+
var _this = this;
|
|
792
|
+
return _async_to_generator(function() {
|
|
793
|
+
var _this_keymasterService;
|
|
794
|
+
return _ts_generator(this, function(_state) {
|
|
795
|
+
switch(_state.label){
|
|
796
|
+
case 0:
|
|
797
|
+
return [
|
|
798
|
+
4,
|
|
799
|
+
_this.ensureServiceIsRunning()
|
|
800
|
+
];
|
|
801
|
+
case 1:
|
|
802
|
+
_state.sent();
|
|
803
|
+
return [
|
|
804
|
+
2,
|
|
805
|
+
(_this_keymasterService = _this.keymasterService).setCurrentId.apply(_this_keymasterService, _to_consumable_array(args))
|
|
806
|
+
];
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
})();
|
|
810
|
+
}
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
key: "createSchemaInternal",
|
|
814
|
+
value: function createSchemaInternal() {
|
|
815
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
816
|
+
args[_key] = arguments[_key];
|
|
817
|
+
}
|
|
818
|
+
var _this = this;
|
|
819
|
+
return _async_to_generator(function() {
|
|
820
|
+
var _this_keymasterService;
|
|
821
|
+
return _ts_generator(this, function(_state) {
|
|
822
|
+
switch(_state.label){
|
|
823
|
+
case 0:
|
|
824
|
+
return [
|
|
825
|
+
4,
|
|
826
|
+
_this.ensureServiceIsRunning()
|
|
827
|
+
];
|
|
828
|
+
case 1:
|
|
829
|
+
_state.sent();
|
|
830
|
+
return [
|
|
831
|
+
2,
|
|
832
|
+
(_this_keymasterService = _this.keymasterService).createSchema.apply(_this_keymasterService, _to_consumable_array(args))
|
|
833
|
+
];
|
|
834
|
+
}
|
|
835
|
+
});
|
|
836
|
+
})();
|
|
837
|
+
}
|
|
838
|
+
},
|
|
839
|
+
{
|
|
840
|
+
key: "newWalletInternal",
|
|
841
|
+
value: function newWalletInternal() {
|
|
842
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
843
|
+
args[_key] = arguments[_key];
|
|
844
|
+
}
|
|
845
|
+
var _this = this;
|
|
846
|
+
return _async_to_generator(function() {
|
|
847
|
+
var _this_keymasterService;
|
|
848
|
+
return _ts_generator(this, function(_state) {
|
|
849
|
+
switch(_state.label){
|
|
850
|
+
case 0:
|
|
851
|
+
return [
|
|
852
|
+
4,
|
|
853
|
+
_this.ensureServiceIsRunning()
|
|
854
|
+
];
|
|
855
|
+
case 1:
|
|
856
|
+
_state.sent();
|
|
857
|
+
return [
|
|
858
|
+
2,
|
|
859
|
+
(_this_keymasterService = _this.keymasterService).newWallet.apply(_this_keymasterService, _to_consumable_array(args))
|
|
860
|
+
];
|
|
861
|
+
}
|
|
862
|
+
});
|
|
863
|
+
})();
|
|
864
|
+
}
|
|
865
|
+
},
|
|
866
|
+
{
|
|
867
|
+
key: "recoverWalletInternal",
|
|
868
|
+
value: function recoverWalletInternal() {
|
|
869
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
870
|
+
args[_key] = arguments[_key];
|
|
871
|
+
}
|
|
872
|
+
var _this = this;
|
|
873
|
+
return _async_to_generator(function() {
|
|
874
|
+
var _this_keymasterService;
|
|
875
|
+
return _ts_generator(this, function(_state) {
|
|
876
|
+
switch(_state.label){
|
|
877
|
+
case 0:
|
|
878
|
+
return [
|
|
879
|
+
4,
|
|
880
|
+
_this.ensureServiceIsRunning()
|
|
881
|
+
];
|
|
882
|
+
case 1:
|
|
883
|
+
_state.sent();
|
|
884
|
+
return [
|
|
885
|
+
2,
|
|
886
|
+
(_this_keymasterService = _this.keymasterService).recoverWallet.apply(_this_keymasterService, _to_consumable_array(args))
|
|
887
|
+
];
|
|
888
|
+
}
|
|
889
|
+
});
|
|
890
|
+
})();
|
|
891
|
+
}
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
key: "ensureWalletExists",
|
|
895
|
+
value: function ensureWalletExists() {
|
|
896
|
+
var _this = this;
|
|
897
|
+
return _async_to_generator(function() {
|
|
898
|
+
var _this_config_walletDb, _this_config, existing, walletConfig, did;
|
|
899
|
+
return _ts_generator(this, function(_state) {
|
|
900
|
+
switch(_state.label){
|
|
901
|
+
case 0:
|
|
902
|
+
console.log("Ensuring wallet exists");
|
|
903
|
+
return [
|
|
904
|
+
4,
|
|
905
|
+
(_this_config = _this.config) === null || _this_config === void 0 ? void 0 : (_this_config_walletDb = _this_config.walletDb) === null || _this_config_walletDb === void 0 ? void 0 : _this_config_walletDb.loadWallet()
|
|
906
|
+
];
|
|
907
|
+
case 1:
|
|
908
|
+
existing = _state.sent() || null;
|
|
909
|
+
if (existing && "current" in existing) {
|
|
910
|
+
console.log("Using existing wallet with ID ".concat(existing.current));
|
|
911
|
+
return [
|
|
912
|
+
2
|
|
913
|
+
];
|
|
914
|
+
}
|
|
915
|
+
walletConfig = _this.config.walletConfig;
|
|
916
|
+
console.log("Creating wallet with ID ".concat(walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.id));
|
|
917
|
+
if (!(walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.mnemonic)) return [
|
|
918
|
+
3,
|
|
919
|
+
3
|
|
920
|
+
];
|
|
921
|
+
return [
|
|
922
|
+
4,
|
|
923
|
+
_this.keymasterService.newWallet(walletConfig.mnemonic, true)
|
|
924
|
+
];
|
|
925
|
+
case 2:
|
|
926
|
+
_state.sent();
|
|
927
|
+
_state.label = 3;
|
|
928
|
+
case 3:
|
|
929
|
+
if (!(walletConfig === null || walletConfig === void 0 ? void 0 : walletConfig.id)) return [
|
|
930
|
+
3,
|
|
931
|
+
5
|
|
932
|
+
];
|
|
933
|
+
return [
|
|
934
|
+
4,
|
|
935
|
+
_this.keymasterService.createId(walletConfig.id, {
|
|
936
|
+
registry: walletConfig.registry
|
|
937
|
+
})
|
|
938
|
+
];
|
|
939
|
+
case 4:
|
|
940
|
+
did = _state.sent();
|
|
941
|
+
console.log("Did ", did);
|
|
942
|
+
console.log("Created wallet with ID ".concat(walletConfig.id));
|
|
943
|
+
_state.label = 5;
|
|
944
|
+
case 5:
|
|
945
|
+
return [
|
|
578
946
|
2
|
|
579
947
|
];
|
|
580
948
|
}
|
|
@@ -598,7 +966,7 @@ var Keymaster = /*#__PURE__*/ function() {
|
|
|
598
966
|
];
|
|
599
967
|
return [
|
|
600
968
|
4,
|
|
601
|
-
_this.
|
|
969
|
+
_this.startInternal()
|
|
602
970
|
];
|
|
603
971
|
case 1:
|
|
604
972
|
_tmp = _state.sent();
|
|
@@ -616,8 +984,8 @@ var Keymaster = /*#__PURE__*/ function() {
|
|
|
616
984
|
{
|
|
617
985
|
key: "validateConfig",
|
|
618
986
|
value: function validateConfig(config) {
|
|
619
|
-
if (config.gatekeeperConfig
|
|
620
|
-
throw new Error("
|
|
987
|
+
if (!config.gatekeeperConfig) {
|
|
988
|
+
throw new Error("Missing Gatekeeper config");
|
|
621
989
|
}
|
|
622
990
|
if (config.gatekeeperConfig) {
|
|
623
991
|
var _config_walletDb, _config_walletDb1;
|
|
@@ -633,11 +1001,704 @@ var Keymaster = /*#__PURE__*/ function() {
|
|
|
633
1001
|
}
|
|
634
1002
|
}
|
|
635
1003
|
}
|
|
1004
|
+
], [
|
|
1005
|
+
{
|
|
1006
|
+
key: "initialize",
|
|
1007
|
+
value: function initialize(config) {
|
|
1008
|
+
if (!_Keymaster.instance) {
|
|
1009
|
+
_Keymaster.instance = new _Keymaster(config);
|
|
1010
|
+
console.log("\u2705 Keymaster initialized");
|
|
1011
|
+
} else {
|
|
1012
|
+
console.warn("Keymaster already initialized, ignoring re-initialization.");
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
},
|
|
1016
|
+
{
|
|
1017
|
+
key: "start",
|
|
1018
|
+
value: // Delegated STATIC methods
|
|
1019
|
+
function start() {
|
|
1020
|
+
return _async_to_generator(function() {
|
|
1021
|
+
return _ts_generator(this, function(_state) {
|
|
1022
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1023
|
+
return [
|
|
1024
|
+
2,
|
|
1025
|
+
_Keymaster.getInstance().startInternal()
|
|
1026
|
+
];
|
|
1027
|
+
});
|
|
1028
|
+
})();
|
|
1029
|
+
}
|
|
1030
|
+
},
|
|
1031
|
+
{
|
|
1032
|
+
key: "createChallenge",
|
|
1033
|
+
value: function createChallenge() {
|
|
1034
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1035
|
+
args[_key] = arguments[_key];
|
|
1036
|
+
}
|
|
1037
|
+
return _async_to_generator(function() {
|
|
1038
|
+
var _Keymaster_getInstance;
|
|
1039
|
+
return _ts_generator(this, function(_state) {
|
|
1040
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1041
|
+
return [
|
|
1042
|
+
2,
|
|
1043
|
+
(_Keymaster_getInstance = _Keymaster.getInstance()).createChallengeInternal.apply(_Keymaster_getInstance, _to_consumable_array(args))
|
|
1044
|
+
];
|
|
1045
|
+
});
|
|
1046
|
+
})();
|
|
1047
|
+
}
|
|
1048
|
+
},
|
|
1049
|
+
{
|
|
1050
|
+
key: "bindCredential",
|
|
1051
|
+
value: function bindCredential() {
|
|
1052
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1053
|
+
args[_key] = arguments[_key];
|
|
1054
|
+
}
|
|
1055
|
+
return _async_to_generator(function() {
|
|
1056
|
+
var _Keymaster_getInstance;
|
|
1057
|
+
return _ts_generator(this, function(_state) {
|
|
1058
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1059
|
+
return [
|
|
1060
|
+
2,
|
|
1061
|
+
(_Keymaster_getInstance = _Keymaster.getInstance()).bindCredentialInternal.apply(_Keymaster_getInstance, _to_consumable_array(args))
|
|
1062
|
+
];
|
|
1063
|
+
});
|
|
1064
|
+
})();
|
|
1065
|
+
}
|
|
1066
|
+
},
|
|
1067
|
+
{
|
|
1068
|
+
key: "issueCredential",
|
|
1069
|
+
value: function issueCredential() {
|
|
1070
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1071
|
+
args[_key] = arguments[_key];
|
|
1072
|
+
}
|
|
1073
|
+
return _async_to_generator(function() {
|
|
1074
|
+
var _Keymaster_getInstance;
|
|
1075
|
+
return _ts_generator(this, function(_state) {
|
|
1076
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1077
|
+
return [
|
|
1078
|
+
2,
|
|
1079
|
+
(_Keymaster_getInstance = _Keymaster.getInstance()).issueCredentialInternal.apply(_Keymaster_getInstance, _to_consumable_array(args))
|
|
1080
|
+
];
|
|
1081
|
+
});
|
|
1082
|
+
})();
|
|
1083
|
+
}
|
|
1084
|
+
},
|
|
1085
|
+
{
|
|
1086
|
+
key: "publishCredential",
|
|
1087
|
+
value: function publishCredential() {
|
|
1088
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1089
|
+
args[_key] = arguments[_key];
|
|
1090
|
+
}
|
|
1091
|
+
return _async_to_generator(function() {
|
|
1092
|
+
var _Keymaster_getInstance;
|
|
1093
|
+
return _ts_generator(this, function(_state) {
|
|
1094
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1095
|
+
return [
|
|
1096
|
+
2,
|
|
1097
|
+
(_Keymaster_getInstance = _Keymaster.getInstance()).publishCredentialInternal.apply(_Keymaster_getInstance, _to_consumable_array(args))
|
|
1098
|
+
];
|
|
1099
|
+
});
|
|
1100
|
+
})();
|
|
1101
|
+
}
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
key: "acceptCredential",
|
|
1105
|
+
value: function acceptCredential() {
|
|
1106
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1107
|
+
args[_key] = arguments[_key];
|
|
1108
|
+
}
|
|
1109
|
+
return _async_to_generator(function() {
|
|
1110
|
+
var _Keymaster_getInstance;
|
|
1111
|
+
return _ts_generator(this, function(_state) {
|
|
1112
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1113
|
+
return [
|
|
1114
|
+
2,
|
|
1115
|
+
(_Keymaster_getInstance = _Keymaster.getInstance()).acceptCredentialInternal.apply(_Keymaster_getInstance, _to_consumable_array(args))
|
|
1116
|
+
];
|
|
1117
|
+
});
|
|
1118
|
+
})();
|
|
1119
|
+
}
|
|
1120
|
+
},
|
|
1121
|
+
{
|
|
1122
|
+
key: "showMnemonic",
|
|
1123
|
+
value: function showMnemonic() {
|
|
1124
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1125
|
+
args[_key] = arguments[_key];
|
|
1126
|
+
}
|
|
1127
|
+
return _async_to_generator(function() {
|
|
1128
|
+
var _Keymaster_getInstance;
|
|
1129
|
+
return _ts_generator(this, function(_state) {
|
|
1130
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1131
|
+
return [
|
|
1132
|
+
2,
|
|
1133
|
+
(_Keymaster_getInstance = _Keymaster.getInstance()).showMnemonicInternal.apply(_Keymaster_getInstance, _to_consumable_array(args))
|
|
1134
|
+
];
|
|
1135
|
+
});
|
|
1136
|
+
})();
|
|
1137
|
+
}
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
key: "verifyResponse",
|
|
1141
|
+
value: function verifyResponse() {
|
|
1142
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1143
|
+
args[_key] = arguments[_key];
|
|
1144
|
+
}
|
|
1145
|
+
return _async_to_generator(function() {
|
|
1146
|
+
var _Keymaster_getInstance;
|
|
1147
|
+
return _ts_generator(this, function(_state) {
|
|
1148
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1149
|
+
return [
|
|
1150
|
+
2,
|
|
1151
|
+
(_Keymaster_getInstance = _Keymaster.getInstance()).verifyResponseInternal.apply(_Keymaster_getInstance, _to_consumable_array(args))
|
|
1152
|
+
];
|
|
1153
|
+
});
|
|
1154
|
+
})();
|
|
1155
|
+
}
|
|
1156
|
+
},
|
|
1157
|
+
{
|
|
1158
|
+
key: "decryptMessage",
|
|
1159
|
+
value: function decryptMessage() {
|
|
1160
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1161
|
+
args[_key] = arguments[_key];
|
|
1162
|
+
}
|
|
1163
|
+
return _async_to_generator(function() {
|
|
1164
|
+
var _Keymaster_getInstance;
|
|
1165
|
+
return _ts_generator(this, function(_state) {
|
|
1166
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1167
|
+
return [
|
|
1168
|
+
2,
|
|
1169
|
+
(_Keymaster_getInstance = _Keymaster.getInstance()).decryptMessageInternal.apply(_Keymaster_getInstance, _to_consumable_array(args))
|
|
1170
|
+
];
|
|
1171
|
+
});
|
|
1172
|
+
})();
|
|
1173
|
+
}
|
|
1174
|
+
},
|
|
1175
|
+
{
|
|
1176
|
+
key: "decryptMnemonic",
|
|
1177
|
+
value: function decryptMnemonic() {
|
|
1178
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1179
|
+
args[_key] = arguments[_key];
|
|
1180
|
+
}
|
|
1181
|
+
return _async_to_generator(function() {
|
|
1182
|
+
var _Keymaster_getInstance;
|
|
1183
|
+
return _ts_generator(this, function(_state) {
|
|
1184
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1185
|
+
return [
|
|
1186
|
+
2,
|
|
1187
|
+
(_Keymaster_getInstance = _Keymaster.getInstance()).decryptMnemonicInternal.apply(_Keymaster_getInstance, _to_consumable_array(args))
|
|
1188
|
+
];
|
|
1189
|
+
});
|
|
1190
|
+
})();
|
|
1191
|
+
}
|
|
1192
|
+
},
|
|
1193
|
+
{
|
|
1194
|
+
key: "getCredential",
|
|
1195
|
+
value: function getCredential() {
|
|
1196
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1197
|
+
args[_key] = arguments[_key];
|
|
1198
|
+
}
|
|
1199
|
+
return _async_to_generator(function() {
|
|
1200
|
+
var _Keymaster_getInstance;
|
|
1201
|
+
return _ts_generator(this, function(_state) {
|
|
1202
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1203
|
+
return [
|
|
1204
|
+
2,
|
|
1205
|
+
(_Keymaster_getInstance = _Keymaster.getInstance()).getCredentialInternal.apply(_Keymaster_getInstance, _to_consumable_array(args))
|
|
1206
|
+
];
|
|
1207
|
+
});
|
|
1208
|
+
})();
|
|
1209
|
+
}
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
key: "removeCredential",
|
|
1213
|
+
value: function removeCredential() {
|
|
1214
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1215
|
+
args[_key] = arguments[_key];
|
|
1216
|
+
}
|
|
1217
|
+
return _async_to_generator(function() {
|
|
1218
|
+
var _Keymaster_getInstance;
|
|
1219
|
+
return _ts_generator(this, function(_state) {
|
|
1220
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1221
|
+
return [
|
|
1222
|
+
2,
|
|
1223
|
+
(_Keymaster_getInstance = _Keymaster.getInstance()).removeCredentialInternal.apply(_Keymaster_getInstance, _to_consumable_array(args))
|
|
1224
|
+
];
|
|
1225
|
+
});
|
|
1226
|
+
})();
|
|
1227
|
+
}
|
|
1228
|
+
},
|
|
1229
|
+
{
|
|
1230
|
+
key: "updateCredential",
|
|
1231
|
+
value: function updateCredential() {
|
|
1232
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1233
|
+
args[_key] = arguments[_key];
|
|
1234
|
+
}
|
|
1235
|
+
return _async_to_generator(function() {
|
|
1236
|
+
var _Keymaster_getInstance;
|
|
1237
|
+
return _ts_generator(this, function(_state) {
|
|
1238
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1239
|
+
return [
|
|
1240
|
+
2,
|
|
1241
|
+
(_Keymaster_getInstance = _Keymaster.getInstance()).updateCredentialInternal.apply(_Keymaster_getInstance, _to_consumable_array(args))
|
|
1242
|
+
];
|
|
1243
|
+
});
|
|
1244
|
+
})();
|
|
1245
|
+
}
|
|
1246
|
+
},
|
|
1247
|
+
{
|
|
1248
|
+
key: "createId",
|
|
1249
|
+
value: function createId() {
|
|
1250
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1251
|
+
args[_key] = arguments[_key];
|
|
1252
|
+
}
|
|
1253
|
+
return _async_to_generator(function() {
|
|
1254
|
+
var _Keymaster_getInstance;
|
|
1255
|
+
return _ts_generator(this, function(_state) {
|
|
1256
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1257
|
+
return [
|
|
1258
|
+
2,
|
|
1259
|
+
(_Keymaster_getInstance = _Keymaster.getInstance()).createIdInternal.apply(_Keymaster_getInstance, _to_consumable_array(args))
|
|
1260
|
+
];
|
|
1261
|
+
});
|
|
1262
|
+
})();
|
|
1263
|
+
}
|
|
1264
|
+
},
|
|
1265
|
+
{
|
|
1266
|
+
key: "removeId",
|
|
1267
|
+
value: function removeId() {
|
|
1268
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1269
|
+
args[_key] = arguments[_key];
|
|
1270
|
+
}
|
|
1271
|
+
return _async_to_generator(function() {
|
|
1272
|
+
var _Keymaster_getInstance;
|
|
1273
|
+
return _ts_generator(this, function(_state) {
|
|
1274
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1275
|
+
return [
|
|
1276
|
+
2,
|
|
1277
|
+
(_Keymaster_getInstance = _Keymaster.getInstance()).removeIdInternal.apply(_Keymaster_getInstance, _to_consumable_array(args))
|
|
1278
|
+
];
|
|
1279
|
+
});
|
|
1280
|
+
})();
|
|
1281
|
+
}
|
|
1282
|
+
},
|
|
1283
|
+
{
|
|
1284
|
+
key: "resolveDID",
|
|
1285
|
+
value: function resolveDID() {
|
|
1286
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1287
|
+
args[_key] = arguments[_key];
|
|
1288
|
+
}
|
|
1289
|
+
return _async_to_generator(function() {
|
|
1290
|
+
var _Keymaster_getInstance;
|
|
1291
|
+
return _ts_generator(this, function(_state) {
|
|
1292
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1293
|
+
return [
|
|
1294
|
+
2,
|
|
1295
|
+
(_Keymaster_getInstance = _Keymaster.getInstance()).resolveDIDInternal.apply(_Keymaster_getInstance, _to_consumable_array(args))
|
|
1296
|
+
];
|
|
1297
|
+
});
|
|
1298
|
+
})();
|
|
1299
|
+
}
|
|
1300
|
+
},
|
|
1301
|
+
{
|
|
1302
|
+
key: "setCurrentId",
|
|
1303
|
+
value: function setCurrentId() {
|
|
1304
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1305
|
+
args[_key] = arguments[_key];
|
|
1306
|
+
}
|
|
1307
|
+
return _async_to_generator(function() {
|
|
1308
|
+
var _Keymaster_getInstance;
|
|
1309
|
+
return _ts_generator(this, function(_state) {
|
|
1310
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1311
|
+
return [
|
|
1312
|
+
2,
|
|
1313
|
+
(_Keymaster_getInstance = _Keymaster.getInstance()).setCurrentIdInternal.apply(_Keymaster_getInstance, _to_consumable_array(args))
|
|
1314
|
+
];
|
|
1315
|
+
});
|
|
1316
|
+
})();
|
|
1317
|
+
}
|
|
1318
|
+
},
|
|
1319
|
+
{
|
|
1320
|
+
key: "createSchema",
|
|
1321
|
+
value: function createSchema() {
|
|
1322
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1323
|
+
args[_key] = arguments[_key];
|
|
1324
|
+
}
|
|
1325
|
+
return _async_to_generator(function() {
|
|
1326
|
+
var _Keymaster_getInstance;
|
|
1327
|
+
return _ts_generator(this, function(_state) {
|
|
1328
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1329
|
+
return [
|
|
1330
|
+
2,
|
|
1331
|
+
(_Keymaster_getInstance = _Keymaster.getInstance()).createSchemaInternal.apply(_Keymaster_getInstance, _to_consumable_array(args))
|
|
1332
|
+
];
|
|
1333
|
+
});
|
|
1334
|
+
})();
|
|
1335
|
+
}
|
|
1336
|
+
},
|
|
1337
|
+
{
|
|
1338
|
+
key: "newWallet",
|
|
1339
|
+
value: function newWallet() {
|
|
1340
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1341
|
+
args[_key] = arguments[_key];
|
|
1342
|
+
}
|
|
1343
|
+
return _async_to_generator(function() {
|
|
1344
|
+
var _Keymaster_getInstance;
|
|
1345
|
+
return _ts_generator(this, function(_state) {
|
|
1346
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1347
|
+
return [
|
|
1348
|
+
2,
|
|
1349
|
+
(_Keymaster_getInstance = _Keymaster.getInstance()).newWalletInternal.apply(_Keymaster_getInstance, _to_consumable_array(args))
|
|
1350
|
+
];
|
|
1351
|
+
});
|
|
1352
|
+
})();
|
|
1353
|
+
}
|
|
1354
|
+
},
|
|
1355
|
+
{
|
|
1356
|
+
key: "recoverWallet",
|
|
1357
|
+
value: function recoverWallet() {
|
|
1358
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1359
|
+
args[_key] = arguments[_key];
|
|
1360
|
+
}
|
|
1361
|
+
return _async_to_generator(function() {
|
|
1362
|
+
var _Keymaster_getInstance;
|
|
1363
|
+
return _ts_generator(this, function(_state) {
|
|
1364
|
+
_Keymaster.getInstance().ensureInitialized();
|
|
1365
|
+
return [
|
|
1366
|
+
2,
|
|
1367
|
+
(_Keymaster_getInstance = _Keymaster.getInstance()).recoverWalletInternal.apply(_Keymaster_getInstance, _to_consumable_array(args))
|
|
1368
|
+
];
|
|
1369
|
+
});
|
|
1370
|
+
})();
|
|
1371
|
+
}
|
|
1372
|
+
},
|
|
1373
|
+
{
|
|
1374
|
+
key: "getInstance",
|
|
1375
|
+
value: function getInstance() {
|
|
1376
|
+
if (!_Keymaster.instance) {
|
|
1377
|
+
throw new Error("Keymaster not initialized. Call Keymaster.initialize() first.");
|
|
1378
|
+
}
|
|
1379
|
+
return _Keymaster.instance;
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
]);
|
|
1383
|
+
return _Keymaster;
|
|
1384
|
+
}();
|
|
1385
|
+
_Keymaster.instance = null;
|
|
1386
|
+
var Keymaster = _Keymaster;
|
|
1387
|
+
// src/keymasterClient.ts
|
|
1388
|
+
var import_client2 = __toESM(require("@mdip/keymaster/client"), 1);
|
|
1389
|
+
var KeymasterExternalClient = /*#__PURE__*/ function() {
|
|
1390
|
+
function KeymasterExternalClient(config) {
|
|
1391
|
+
_class_call_check(this, KeymasterExternalClient);
|
|
1392
|
+
this.serviceStarted = false;
|
|
1393
|
+
this.validateConfig(config);
|
|
1394
|
+
this.config = config;
|
|
1395
|
+
}
|
|
1396
|
+
_create_class(KeymasterExternalClient, [
|
|
1397
|
+
{
|
|
1398
|
+
key: "start",
|
|
1399
|
+
value: function start() {
|
|
1400
|
+
var _this = this;
|
|
1401
|
+
return _async_to_generator(function() {
|
|
1402
|
+
return _ts_generator(this, function(_state) {
|
|
1403
|
+
switch(_state.label){
|
|
1404
|
+
case 0:
|
|
1405
|
+
if (!_this.config.keymasterConfig) return [
|
|
1406
|
+
3,
|
|
1407
|
+
2
|
|
1408
|
+
];
|
|
1409
|
+
return [
|
|
1410
|
+
4,
|
|
1411
|
+
_this.startExternalKeymaster()
|
|
1412
|
+
];
|
|
1413
|
+
case 1:
|
|
1414
|
+
_this.serviceStarted = _state.sent();
|
|
1415
|
+
return [
|
|
1416
|
+
3,
|
|
1417
|
+
3
|
|
1418
|
+
];
|
|
1419
|
+
case 2:
|
|
1420
|
+
throw "Missing Keymaster config";
|
|
1421
|
+
case 3:
|
|
1422
|
+
return [
|
|
1423
|
+
2,
|
|
1424
|
+
_this.serviceStarted
|
|
1425
|
+
];
|
|
1426
|
+
}
|
|
1427
|
+
});
|
|
1428
|
+
})();
|
|
1429
|
+
}
|
|
1430
|
+
},
|
|
1431
|
+
{
|
|
1432
|
+
key: "startExternal",
|
|
1433
|
+
value: function startExternal() {
|
|
1434
|
+
var _this = this;
|
|
1435
|
+
return _async_to_generator(function() {
|
|
1436
|
+
return _ts_generator(this, function(_state) {
|
|
1437
|
+
switch(_state.label){
|
|
1438
|
+
case 0:
|
|
1439
|
+
if (!_this.config.keymasterConfig) return [
|
|
1440
|
+
3,
|
|
1441
|
+
2
|
|
1442
|
+
];
|
|
1443
|
+
return [
|
|
1444
|
+
4,
|
|
1445
|
+
_this.startExternalKeymaster()
|
|
1446
|
+
];
|
|
1447
|
+
case 1:
|
|
1448
|
+
_this.serviceStarted = _state.sent();
|
|
1449
|
+
return [
|
|
1450
|
+
3,
|
|
1451
|
+
3
|
|
1452
|
+
];
|
|
1453
|
+
case 2:
|
|
1454
|
+
throw "Missing Gatekeeper or Keymaster config";
|
|
1455
|
+
case 3:
|
|
1456
|
+
return [
|
|
1457
|
+
2,
|
|
1458
|
+
_this.serviceStarted
|
|
1459
|
+
];
|
|
1460
|
+
}
|
|
1461
|
+
});
|
|
1462
|
+
})();
|
|
1463
|
+
}
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
key: "startExternalKeymaster",
|
|
1467
|
+
value: function startExternalKeymaster() {
|
|
1468
|
+
var _this = this;
|
|
1469
|
+
return _async_to_generator(function() {
|
|
1470
|
+
var e;
|
|
1471
|
+
return _ts_generator(this, function(_state) {
|
|
1472
|
+
switch(_state.label){
|
|
1473
|
+
case 0:
|
|
1474
|
+
console.log("Starting external Keymaster service");
|
|
1475
|
+
_state.label = 1;
|
|
1476
|
+
case 1:
|
|
1477
|
+
_state.trys.push([
|
|
1478
|
+
1,
|
|
1479
|
+
3,
|
|
1480
|
+
,
|
|
1481
|
+
4
|
|
1482
|
+
]);
|
|
1483
|
+
_this.keymasterService = new import_client2.default();
|
|
1484
|
+
return [
|
|
1485
|
+
4,
|
|
1486
|
+
_this.keymasterService.connect(_this.config.keymasterConfig)
|
|
1487
|
+
];
|
|
1488
|
+
case 2:
|
|
1489
|
+
_state.sent();
|
|
1490
|
+
return [
|
|
1491
|
+
3,
|
|
1492
|
+
4
|
|
1493
|
+
];
|
|
1494
|
+
case 3:
|
|
1495
|
+
e = _state.sent();
|
|
1496
|
+
console.error("Error starting Keymaster service:", e);
|
|
1497
|
+
return [
|
|
1498
|
+
2,
|
|
1499
|
+
false
|
|
1500
|
+
];
|
|
1501
|
+
case 4:
|
|
1502
|
+
console.log("Started external Keymaster service");
|
|
1503
|
+
return [
|
|
1504
|
+
2,
|
|
1505
|
+
true
|
|
1506
|
+
];
|
|
1507
|
+
}
|
|
1508
|
+
});
|
|
1509
|
+
})();
|
|
1510
|
+
}
|
|
1511
|
+
},
|
|
1512
|
+
{
|
|
1513
|
+
key: "createChallenge",
|
|
1514
|
+
value: function createChallenge(spec, options) {
|
|
1515
|
+
var _this = this;
|
|
1516
|
+
return _async_to_generator(function() {
|
|
1517
|
+
var _this_keymasterService, challenge;
|
|
1518
|
+
return _ts_generator(this, function(_state) {
|
|
1519
|
+
switch(_state.label){
|
|
1520
|
+
case 0:
|
|
1521
|
+
if (!_this.serviceRunning()) {
|
|
1522
|
+
throw new Error("Keymaster service not running");
|
|
1523
|
+
}
|
|
1524
|
+
return [
|
|
1525
|
+
4,
|
|
1526
|
+
(_this_keymasterService = _this.keymasterService) === null || _this_keymasterService === void 0 ? void 0 : _this_keymasterService.createChallenge(spec, options)
|
|
1527
|
+
];
|
|
1528
|
+
case 1:
|
|
1529
|
+
challenge = _state.sent();
|
|
1530
|
+
return [
|
|
1531
|
+
2,
|
|
1532
|
+
{
|
|
1533
|
+
challenge: challenge,
|
|
1534
|
+
challengeUrl: "".concat(spec.callback, "?challenge=").concat(challenge)
|
|
1535
|
+
}
|
|
1536
|
+
];
|
|
1537
|
+
}
|
|
1538
|
+
});
|
|
1539
|
+
})();
|
|
1540
|
+
}
|
|
1541
|
+
},
|
|
1542
|
+
{
|
|
1543
|
+
key: "bindCredential",
|
|
1544
|
+
value: function bindCredential(schemaId, subjectId) {
|
|
1545
|
+
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
1546
|
+
var _this = this;
|
|
1547
|
+
return _async_to_generator(function() {
|
|
1548
|
+
return _ts_generator(this, function(_state) {
|
|
1549
|
+
if (!_this.serviceRunning()) {
|
|
1550
|
+
throw new Error("Keymaster service not running");
|
|
1551
|
+
}
|
|
1552
|
+
return [
|
|
1553
|
+
2,
|
|
1554
|
+
_this.keymasterService.bindCredential(schemaId, subjectId, options)
|
|
1555
|
+
];
|
|
1556
|
+
});
|
|
1557
|
+
})();
|
|
1558
|
+
}
|
|
1559
|
+
},
|
|
1560
|
+
{
|
|
1561
|
+
key: "issueCredential",
|
|
1562
|
+
value: function issueCredential(credential) {
|
|
1563
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1564
|
+
var _this = this;
|
|
1565
|
+
return _async_to_generator(function() {
|
|
1566
|
+
return _ts_generator(this, function(_state) {
|
|
1567
|
+
if (!_this.serviceRunning()) {
|
|
1568
|
+
throw new Error("Keymaster service not running");
|
|
1569
|
+
}
|
|
1570
|
+
return [
|
|
1571
|
+
2,
|
|
1572
|
+
_this.keymasterService.issueCredential(credential, options)
|
|
1573
|
+
];
|
|
1574
|
+
});
|
|
1575
|
+
})();
|
|
1576
|
+
}
|
|
1577
|
+
},
|
|
1578
|
+
{
|
|
1579
|
+
key: "publishCredential",
|
|
1580
|
+
value: function publishCredential(did) {
|
|
1581
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1582
|
+
var _this = this;
|
|
1583
|
+
return _async_to_generator(function() {
|
|
1584
|
+
return _ts_generator(this, function(_state) {
|
|
1585
|
+
if (!_this.serviceRunning()) {
|
|
1586
|
+
throw new Error("Keymaster service not running");
|
|
1587
|
+
}
|
|
1588
|
+
return [
|
|
1589
|
+
2,
|
|
1590
|
+
_this.keymasterService.publishCredential(did, options)
|
|
1591
|
+
];
|
|
1592
|
+
});
|
|
1593
|
+
})();
|
|
1594
|
+
}
|
|
1595
|
+
},
|
|
1596
|
+
{
|
|
1597
|
+
key: "acceptCredential",
|
|
1598
|
+
value: function acceptCredential(did) {
|
|
1599
|
+
var _this = this;
|
|
1600
|
+
return _async_to_generator(function() {
|
|
1601
|
+
return _ts_generator(this, function(_state) {
|
|
1602
|
+
if (!_this.serviceRunning()) {
|
|
1603
|
+
throw new Error("Keymaster service not running");
|
|
1604
|
+
}
|
|
1605
|
+
return [
|
|
1606
|
+
2,
|
|
1607
|
+
_this.keymasterService.acceptCredential(did)
|
|
1608
|
+
];
|
|
1609
|
+
});
|
|
1610
|
+
})();
|
|
1611
|
+
}
|
|
1612
|
+
},
|
|
1613
|
+
{
|
|
1614
|
+
key: "showMnemonic",
|
|
1615
|
+
value: function showMnemonic() {
|
|
1616
|
+
var _this = this;
|
|
1617
|
+
return _async_to_generator(function() {
|
|
1618
|
+
return _ts_generator(this, function(_state) {
|
|
1619
|
+
if (!_this.serviceRunning()) {
|
|
1620
|
+
throw new Error("Keymaster service not running");
|
|
1621
|
+
}
|
|
1622
|
+
return [
|
|
1623
|
+
2,
|
|
1624
|
+
_this.keymasterService.decryptMnemonic()
|
|
1625
|
+
];
|
|
1626
|
+
});
|
|
1627
|
+
})();
|
|
1628
|
+
}
|
|
1629
|
+
},
|
|
1630
|
+
{
|
|
1631
|
+
key: "verifyResponse",
|
|
1632
|
+
value: function verifyResponse(did, options) {
|
|
1633
|
+
var _this = this;
|
|
1634
|
+
return _async_to_generator(function() {
|
|
1635
|
+
var response;
|
|
1636
|
+
return _ts_generator(this, function(_state) {
|
|
1637
|
+
switch(_state.label){
|
|
1638
|
+
case 0:
|
|
1639
|
+
if (!_this.serviceRunning()) {
|
|
1640
|
+
throw new Error("Keymaster service not running");
|
|
1641
|
+
}
|
|
1642
|
+
return [
|
|
1643
|
+
4,
|
|
1644
|
+
_this.keymasterService.verifyResponse(did, options)
|
|
1645
|
+
];
|
|
1646
|
+
case 1:
|
|
1647
|
+
response = _state.sent();
|
|
1648
|
+
return [
|
|
1649
|
+
2,
|
|
1650
|
+
response
|
|
1651
|
+
];
|
|
1652
|
+
}
|
|
1653
|
+
});
|
|
1654
|
+
})();
|
|
1655
|
+
}
|
|
1656
|
+
},
|
|
1657
|
+
{
|
|
1658
|
+
key: "serviceRunning",
|
|
1659
|
+
value: function serviceRunning() {
|
|
1660
|
+
var _this = this;
|
|
1661
|
+
return _async_to_generator(function() {
|
|
1662
|
+
var _tmp;
|
|
1663
|
+
return _ts_generator(this, function(_state) {
|
|
1664
|
+
switch(_state.label){
|
|
1665
|
+
case 0:
|
|
1666
|
+
_tmp = _this.serviceStarted;
|
|
1667
|
+
if (_tmp) return [
|
|
1668
|
+
3,
|
|
1669
|
+
2
|
|
1670
|
+
];
|
|
1671
|
+
return [
|
|
1672
|
+
4,
|
|
1673
|
+
_this.start()
|
|
1674
|
+
];
|
|
1675
|
+
case 1:
|
|
1676
|
+
_tmp = _state.sent();
|
|
1677
|
+
_state.label = 2;
|
|
1678
|
+
case 2:
|
|
1679
|
+
return [
|
|
1680
|
+
2,
|
|
1681
|
+
_tmp
|
|
1682
|
+
];
|
|
1683
|
+
}
|
|
1684
|
+
});
|
|
1685
|
+
})();
|
|
1686
|
+
}
|
|
1687
|
+
},
|
|
1688
|
+
{
|
|
1689
|
+
key: "validateConfig",
|
|
1690
|
+
value: function validateConfig(config) {
|
|
1691
|
+
if (!config.keymasterConfig) {
|
|
1692
|
+
throw new Error("Missing Keymaster config");
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
636
1696
|
]);
|
|
637
|
-
return
|
|
1697
|
+
return KeymasterExternalClient;
|
|
638
1698
|
}();
|
|
639
1699
|
// Annotate the CommonJS export names for ESM import in node:
|
|
640
1700
|
0 && (module.exports = {
|
|
641
|
-
Keymaster: Keymaster
|
|
1701
|
+
Keymaster: Keymaster,
|
|
1702
|
+
KeymasterExternalClient: KeymasterExternalClient
|
|
642
1703
|
});
|
|
643
1704
|
//# sourceMappingURL=index.cjs.map
|