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