@yourself_id/siwys-api-js 0.10.1-SAPP-221-mdipUpdate.0 → 0.10.1-SAPP-221-mdipUpdate.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +35 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -35
- package/dist/index.d.ts +2 -35
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +11 -5
package/dist/index.cjs
CHANGED
|
@@ -55,12 +55,40 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
55
55
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
56
56
|
return Constructor;
|
|
57
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
|
+
}
|
|
58
71
|
function _iterable_to_array(iter) {
|
|
59
72
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
60
73
|
}
|
|
61
74
|
function _non_iterable_spread() {
|
|
62
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.");
|
|
63
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
|
+
}
|
|
64
92
|
function _to_consumable_array(arr) {
|
|
65
93
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
66
94
|
}
|
|
@@ -214,6 +242,9 @@ var __copyProps = function(to, from, except, desc) {
|
|
|
214
242
|
}
|
|
215
243
|
return to;
|
|
216
244
|
};
|
|
245
|
+
var __reExport = function(target, mod, secondTarget) {
|
|
246
|
+
return __copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default");
|
|
247
|
+
};
|
|
217
248
|
var __toESM = function(mod, isNodeMode, target) {
|
|
218
249
|
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
219
250
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -1696,9 +1727,11 @@ var KeymasterExternalClient = /*#__PURE__*/ function() {
|
|
|
1696
1727
|
]);
|
|
1697
1728
|
return KeymasterExternalClient;
|
|
1698
1729
|
}();
|
|
1730
|
+
// src/index.ts
|
|
1731
|
+
__reExport(src_exports, require("@mdip/keymaster/types"), module.exports);
|
|
1699
1732
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1700
|
-
0 && (module.exports = {
|
|
1733
|
+
0 && (module.exports = _object_spread({
|
|
1701
1734
|
Keymaster: Keymaster,
|
|
1702
1735
|
KeymasterExternalClient: KeymasterExternalClient
|
|
1703
|
-
});
|
|
1736
|
+
}, require("@mdip/keymaster/types")));
|
|
1704
1737
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/siwys-js/siwys-js/packages/api-js/dist/index.cjs","../src/index.ts","../src/keymaster.ts","../src/keymasterClient.ts"],"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","src_exports","Keymaster","KeymasterExternalClient","module","exports","import_client","require","import_node","import_keymaster","_Keymaster","config","serviceStarted","validateConfig","ensureInitialized","instance","Error","ensureServiceIsRunning","serviceRunning","startInternal","gatekeeperConfig","startIntegratedKeymaster","gatekeeper","cipher","e","console","log","walletDb","GatekeeperClient","connect","CipherNode","keymasterService","KeymasterLib","wallet","ensureWalletExists","error","createChallengeInternal","spec","options","challenge","createChallenge","challengeUrl","callback","bindCredentialInternal","schemaId","subjectId","bindCredential","issueCredentialInternal","credential","issueCredential","publishCredentialInternal","did","publishCredential","acceptCredentialInternal","acceptCredential","showMnemonicInternal","decryptMnemonic","verifyResponseInternal","verifyResponse","decryptMessageInternal","args","decryptMessage","decryptMnemonicInternal","getCredentialInternal","getCredential","removeCredentialInternal","removeCredential","updateCredentialInternal","updateCredential","createIdInternal","createId","removeIdInternal","removeId","resolveDIDInternal","resolveDID","setCurrentIdInternal","setCurrentId","createSchemaInternal","createSchema","newWalletInternal","newWallet","recoverWalletInternal","recoverWallet","existing","walletConfig","loadWallet","current","id","mnemonic","registry","saveWallet","initialize","warn","start","getInstance","showMnemonic","keymasterConfig","startExternalKeymaster","startExternal","import_client2","KeymasterClient","response"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAIA,WAAWC,OAAOC,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BAChD;;;;YAEM4C,KAAAA;mBAAN,SAAMA;;uBAAN,oBAAA;;wBACE,IAAI,CAAC,MAAK7E,cAAA,IAAkB;4BAC1B,MAAM,IAAIF,MAAM;wBAClB;wBACA;;4BAAO,MAAKe,gBAAA,CAAiByB,eAAA;;;gBAC/B;;;;YAEME,KAAAA;mBAAN,SAAMA,eACJP,GAAA,EACAb,OAAA;;uBAFF,oBAAA;wBAUQ+D;;;;gCAHN,IAAI,CAAC,MAAKnF,cAAA,IAAkB;oCAC1B,MAAM,IAAIF,MAAM;gCAClB;gCAEE;;oCAAM,MAAKe,gBAAA,CAAiB2B,cAAA,CAAeP,KAAKb;;;gCAD5C+D,WACJ;gCACF;;oCAAOA;;;;gBACT;;;;YAEcnF,KAAAA;mBAAd,SAAcA;;uBAAd,oBAAA;;;;;uCACS,MAAKN,cAAA;0CAAL;;;;gCAAwB;;oCAAM,MAAKiF,KAAA;;;uCAAX;;;gCAA/B;;;;;;gBACF;;;;YAEQhF,KAAAA;mBAAAA,SAAAA,eAAeF,MAAA;gBACrB,IAAI,CAACA,OAAOqF,eAAA,EAAiB;oBAC3B,MAAM,IAAIhF,MAAM;gBAClB;YACF;;;;;AHmQF,6DAA6D;AAC7D,KAAMZ,CAAAA,OAAOC,OAAO,GAAG;IACrBH,WAAAA;IACAC,yBAAAA;AACF,CAAA","sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/index.ts\nvar src_exports = {};\n__export(src_exports, {\n Keymaster: () => Keymaster,\n KeymasterExternalClient: () => KeymasterExternalClient\n});\nmodule.exports = __toCommonJS(src_exports);\n\n// src/keymaster.ts\nvar import_client = __toESM(require(\"@mdip/gatekeeper/client\"), 1);\nvar import_node = __toESM(require(\"@mdip/cipher/node\"), 1);\nvar import_keymaster = __toESM(require(\"@mdip/keymaster\"), 1);\nvar _Keymaster = class _Keymaster {\n constructor(config) {\n this.serviceStarted = false;\n this.validateConfig(config);\n this.config = config;\n }\n static initialize(config) {\n if (!_Keymaster.instance) {\n _Keymaster.instance = new _Keymaster(config);\n console.log(\"\\u2705 Keymaster initialized\");\n } else {\n console.warn(\n \"Keymaster already initialized, ignoring re-initialization.\"\n );\n }\n }\n ensureInitialized() {\n if (!_Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n }\n // Delegated STATIC methods\n static async start() {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().startInternal();\n }\n static async createChallenge(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().createChallengeInternal(...args);\n }\n static async bindCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().bindCredentialInternal(...args);\n }\n static async issueCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().issueCredentialInternal(...args);\n }\n static async publishCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().publishCredentialInternal(...args);\n }\n static async acceptCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().acceptCredentialInternal(...args);\n }\n static async showMnemonic(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().showMnemonicInternal(...args);\n }\n static async verifyResponse(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().verifyResponseInternal(...args);\n }\n static async decryptMessage(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().decryptMessageInternal(...args);\n }\n static async decryptMnemonic(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().decryptMnemonicInternal(...args);\n }\n static async getCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().getCredentialInternal(...args);\n }\n static async removeCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().removeCredentialInternal(...args);\n }\n static async updateCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().updateCredentialInternal(...args);\n }\n static async createId(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().createIdInternal(...args);\n }\n static async removeId(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().removeIdInternal(...args);\n }\n static async resolveDID(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().resolveDIDInternal(...args);\n }\n static async setCurrentId(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().setCurrentIdInternal(...args);\n }\n static async createSchema(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().createSchemaInternal(...args);\n }\n static async newWallet(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().newWalletInternal(...args);\n }\n static async recoverWallet(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().recoverWalletInternal(...args);\n }\n static getInstance() {\n if (!_Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n return _Keymaster.instance;\n }\n // -------- Internal instance methods (originals renamed with Internal) -------\n async ensureServiceIsRunning() {\n if (!await this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n }\n async startInternal() {\n if (this.config.gatekeeperConfig) {\n this.serviceStarted = await this.startIntegratedKeymaster();\n } else {\n throw \"Missing Gatekeeper config\";\n }\n return this.serviceStarted;\n }\n async startIntegratedKeymaster() {\n console.log(`Starting integrated Keymaster service`);\n try {\n if (this.config.walletDb) {\n const gatekeeper = new import_client.default();\n await gatekeeper.connect(this.config.gatekeeperConfig);\n const cipher = new import_node.default();\n this.keymasterService = new import_keymaster.default({\n gatekeeper,\n wallet: this.config.walletDb,\n cipher\n });\n await this.ensureWalletExists();\n } else {\n return false;\n }\n } catch (e) {\n console.error(\"Error starting Keymaster service:\", e);\n return false;\n }\n console.log(`Started integrated Keymaster service`);\n return true;\n }\n async createChallengeInternal(spec, options) {\n await this.ensureServiceIsRunning();\n const challenge = await this.keymasterService.createChallenge(\n spec,\n options\n );\n return {\n challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`\n };\n }\n async bindCredentialInternal(schemaId, subjectId, options = {}) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n async issueCredentialInternal(credential, options = {}) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.issueCredential(credential, options);\n }\n async publishCredentialInternal(did, options = {}) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.publishCredential(did, options);\n }\n async acceptCredentialInternal(did) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.acceptCredential(did);\n }\n async showMnemonicInternal() {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic();\n }\n async verifyResponseInternal(did, options) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.verifyResponse(did, options);\n }\n async decryptMessageInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMessage(...args);\n }\n async decryptMnemonicInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic(...args);\n }\n async getCredentialInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.getCredential(...args);\n }\n async removeCredentialInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeCredential(...args);\n }\n async updateCredentialInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.updateCredential(...args);\n }\n async createIdInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createId(...args);\n }\n async removeIdInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeId(...args);\n }\n async resolveDIDInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.resolveDID(...args);\n }\n async setCurrentIdInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.setCurrentId(...args);\n }\n async createSchemaInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createSchema(...args);\n }\n async newWalletInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.newWallet(...args);\n }\n async recoverWalletInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.recoverWallet(...args);\n }\n async ensureWalletExists() {\n console.log(\"Ensuring wallet exists\");\n const existing = await this.config?.walletDb?.loadWallet() || null;\n if (existing && \"current\" in existing) {\n console.log(`Using existing wallet with ID ${existing.current}`);\n return;\n }\n const walletConfig = this.config.walletConfig;\n console.log(`Creating wallet with ID ${walletConfig?.id}`);\n if (walletConfig?.mnemonic) {\n await this.keymasterService.newWallet(walletConfig.mnemonic, true);\n }\n if (walletConfig?.id) {\n const did = await this.keymasterService.createId(walletConfig.id, {\n registry: walletConfig.registry\n });\n console.log(\"Did \", did);\n console.log(`Created wallet with ID ${walletConfig.id}`);\n }\n }\n async serviceRunning() {\n return this.serviceStarted || await this.startInternal();\n }\n validateConfig(config) {\n if (!config.gatekeeperConfig) {\n throw new Error(\"Missing Gatekeeper config\");\n }\n if (config.gatekeeperConfig) {\n if (!config.walletConfig) {\n throw new Error(\"Missing wallet config\");\n }\n if (!config.walletDb?.loadWallet) {\n throw new Error(\"Missing load wallet callback\");\n }\n if (!config.walletDb?.saveWallet) {\n throw new Error(\"Missing save wallet callback\");\n }\n }\n }\n};\n_Keymaster.instance = null;\nvar Keymaster = _Keymaster;\n\n// src/keymasterClient.ts\nvar import_client2 = __toESM(require(\"@mdip/keymaster/client\"), 1);\nvar KeymasterExternalClient = class {\n constructor(config) {\n this.serviceStarted = false;\n this.validateConfig(config);\n this.config = config;\n }\n async start() {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Keymaster config\";\n }\n return this.serviceStarted;\n }\n async startExternal() {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Gatekeeper or Keymaster config\";\n }\n return this.serviceStarted;\n }\n async startExternalKeymaster() {\n console.log(`Starting external Keymaster service`);\n try {\n this.keymasterService = new import_client2.default();\n await this.keymasterService.connect(this.config.keymasterConfig);\n } catch (e) {\n console.error(`Error starting Keymaster service:`, e);\n return false;\n }\n console.log(`Started external Keymaster service`);\n return true;\n }\n async createChallenge(spec, options) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const challenge = await this.keymasterService?.createChallenge(\n spec,\n options\n );\n return {\n challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`\n };\n }\n async bindCredential(schemaId, subjectId, options = {}) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n async issueCredential(credential, options = {}) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.issueCredential(credential, options);\n }\n async publishCredential(did, options = {}) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.publishCredential(did, options);\n }\n async acceptCredential(did) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.acceptCredential(did);\n }\n async showMnemonic() {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.decryptMnemonic();\n }\n async verifyResponse(did, options) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const response = await this.keymasterService.verifyResponse(did, options);\n return response;\n }\n async serviceRunning() {\n return this.serviceStarted || await this.start();\n }\n validateConfig(config) {\n if (!config.keymasterConfig) {\n throw new Error(\"Missing Keymaster config\");\n }\n }\n};\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n Keymaster,\n KeymasterExternalClient\n});\n","export { Keymaster, KeymasterConfig } from \"./keymaster.js\";\n\nexport { KeymasterExternalClient } from \"./keymasterClient.js\";\n\nexport {\n SdkConfig,\n VerifyResponseOptions,\n VerifyResponseResponse,\n Wallet,\n WalletConfig,\n WalletDb,\n WalletSeed,\n CreateChallengeOptions,\n CreateChallengeResponse,\n CreateChallengeSpec,\n} from \"./types/index.js\";\n","import GatekeeperClient from \"@mdip/gatekeeper/client\";\nimport CipherNode from \"@mdip/cipher/node\";\nimport KeymasterLib from \"@mdip/keymaster\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n WalletConfig,\n} from \"./types/index.js\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n IssueCredentialsOptions,\n StoredWallet,\n VerifiableCredential,\n WalletBase,\n} from \"@mdip/keymaster/types\";\n\nexport interface KeymasterConfig {\n gatekeeperConfig?: SdkConfig;\n walletDb?: WalletBase;\n walletConfig?: WalletConfig;\n}\n\nexport class Keymaster {\n private static instance: Keymaster | null = null;\n\n private config: KeymasterConfig;\n private keymasterService!: KeymasterLib;\n private serviceStarted = false;\n\n private constructor(config: KeymasterConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n public static initialize(config: KeymasterConfig) {\n if (!Keymaster.instance) {\n Keymaster.instance = new Keymaster(config);\n console.log(\"✅ Keymaster initialized\");\n } else {\n console.warn(\n \"Keymaster already initialized, ignoring re-initialization.\"\n );\n }\n }\n\n private ensureInitialized() {\n if (!Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n }\n\n // Delegated STATIC methods\n\n public static async start() {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().startInternal();\n }\n\n public static async createChallenge(\n ...args: Parameters<Keymaster[\"createChallengeInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createChallengeInternal(...args);\n }\n\n public static async bindCredential(\n ...args: Parameters<Keymaster[\"bindCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().bindCredentialInternal(...args);\n }\n\n public static async issueCredential(\n ...args: Parameters<Keymaster[\"issueCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().issueCredentialInternal(...args);\n }\n\n public static async publishCredential(\n ...args: Parameters<Keymaster[\"publishCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().publishCredentialInternal(...args);\n }\n\n public static async acceptCredential(\n ...args: Parameters<Keymaster[\"acceptCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().acceptCredentialInternal(...args);\n }\n\n public static async showMnemonic(\n ...args: Parameters<Keymaster[\"showMnemonicInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().showMnemonicInternal(...args);\n }\n\n public static async verifyResponse(\n ...args: Parameters<Keymaster[\"verifyResponseInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().verifyResponseInternal(...args);\n }\n\n public static async decryptMessage(\n ...args: Parameters<Keymaster[\"decryptMessageInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().decryptMessageInternal(...args);\n }\n\n public static async decryptMnemonic(\n ...args: Parameters<Keymaster[\"decryptMnemonicInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().decryptMnemonicInternal(...args);\n }\n\n public static async getCredential(\n ...args: Parameters<Keymaster[\"getCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().getCredentialInternal(...args);\n }\n\n public static async removeCredential(\n ...args: Parameters<Keymaster[\"removeCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().removeCredentialInternal(...args);\n }\n\n public static async updateCredential(\n ...args: Parameters<Keymaster[\"updateCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().updateCredentialInternal(...args);\n }\n\n public static async createId(\n ...args: Parameters<Keymaster[\"createIdInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createIdInternal(...args);\n }\n\n public static async removeId(\n ...args: Parameters<Keymaster[\"removeIdInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().removeIdInternal(...args);\n }\n\n public static async resolveDID(\n ...args: Parameters<Keymaster[\"resolveDIDInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().resolveDIDInternal(...args);\n }\n\n public static async setCurrentId(\n ...args: Parameters<Keymaster[\"setCurrentIdInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().setCurrentIdInternal(...args);\n }\n\n public static async createSchema(\n ...args: Parameters<Keymaster[\"createSchemaInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createSchemaInternal(...args);\n }\n\n public static async newWallet(\n ...args: Parameters<Keymaster[\"newWalletInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().newWalletInternal(...args);\n }\n\n public static async recoverWallet(\n ...args: Parameters<Keymaster[\"recoverWalletInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().recoverWalletInternal(...args);\n }\n\n private static getInstance(): Keymaster {\n if (!Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n return Keymaster.instance;\n }\n\n // -------- Internal instance methods (originals renamed with Internal) -------\n\n private async ensureServiceIsRunning() {\n if (!(await this.serviceRunning())) {\n throw new Error(\"Keymaster service not running\");\n }\n }\n\n private async startInternal(): Promise<boolean> {\n if (this.config.gatekeeperConfig) {\n this.serviceStarted = await this.startIntegratedKeymaster();\n } else {\n throw \"Missing Gatekeeper config\";\n }\n return this.serviceStarted;\n }\n\n private async startIntegratedKeymaster(): Promise<boolean> {\n console.log(`Starting integrated Keymaster service`);\n\n try {\n if (this.config.walletDb) {\n const gatekeeper = new GatekeeperClient();\n await gatekeeper.connect(this.config.gatekeeperConfig);\n\n const cipher = new CipherNode();\n\n this.keymasterService = new KeymasterLib({\n gatekeeper,\n wallet: this.config.walletDb,\n cipher,\n });\n\n await this.ensureWalletExists();\n } else {\n return false;\n }\n } catch (e) {\n console.error(\"Error starting Keymaster service:\", e);\n return false;\n }\n\n console.log(`Started integrated Keymaster service`);\n return true;\n }\n\n private async createChallengeInternal(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n await this.ensureServiceIsRunning();\n const challenge: string = await this.keymasterService.createChallenge(\n spec,\n options\n );\n return {\n challenge: challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`,\n };\n }\n\n private async bindCredentialInternal(\n schemaId: string,\n subjectId: string,\n options: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n } = {}\n ): Promise<VerifiableCredential> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n\n private async issueCredentialInternal(\n credential: Partial<VerifiableCredential>,\n options: IssueCredentialsOptions = {}\n ): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.issueCredential(credential, options);\n }\n\n private async publishCredentialInternal(\n did: string,\n options: { reveal?: boolean } = {}\n ): Promise<VerifiableCredential> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.publishCredential(did, options);\n }\n\n private async acceptCredentialInternal(did: string): Promise<boolean> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.acceptCredential(did);\n }\n\n private async showMnemonicInternal(): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic();\n }\n\n private async verifyResponseInternal(\n did: string,\n options?: { retries?: number; delay?: number }\n ): Promise<ChallengeResponse> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.verifyResponse(did, options);\n }\n\n private async decryptMessageInternal(\n ...args: Parameters<KeymasterLib[\"decryptMessage\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMessage(...args);\n }\n\n private async decryptMnemonicInternal(\n ...args: Parameters<KeymasterLib[\"decryptMnemonic\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic(...args);\n }\n\n private async getCredentialInternal(\n ...args: Parameters<KeymasterLib[\"getCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.getCredential(...args);\n }\n\n private async removeCredentialInternal(\n ...args: Parameters<KeymasterLib[\"removeCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeCredential(...args);\n }\n\n private async updateCredentialInternal(\n ...args: Parameters<KeymasterLib[\"updateCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.updateCredential(...args);\n }\n\n private async createIdInternal(\n ...args: Parameters<KeymasterLib[\"createId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createId(...args);\n }\n\n private async removeIdInternal(\n ...args: Parameters<KeymasterLib[\"removeId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeId(...args);\n }\n\n private async resolveDIDInternal(\n ...args: Parameters<KeymasterLib[\"resolveDID\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.resolveDID(...args);\n }\n\n private async setCurrentIdInternal(\n ...args: Parameters<KeymasterLib[\"setCurrentId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.setCurrentId(...args);\n }\n\n private async createSchemaInternal(\n ...args: Parameters<KeymasterLib[\"createSchema\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createSchema(...args);\n }\n\n private async newWalletInternal(\n ...args: Parameters<KeymasterLib[\"newWallet\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.newWallet(...args);\n }\n\n private async recoverWalletInternal(\n ...args: Parameters<KeymasterLib[\"recoverWallet\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.recoverWallet(...args);\n }\n\n private async ensureWalletExists(): Promise<void> {\n console.log(\"Ensuring wallet exists\");\n const existing: StoredWallet | null =\n (await this.config?.walletDb?.loadWallet()) || null;\n if (existing && \"current\" in existing) {\n console.log(`Using existing wallet with ID ${existing.current}`);\n return;\n }\n\n const walletConfig = this.config.walletConfig;\n console.log(`Creating wallet with ID ${walletConfig?.id}`);\n if (walletConfig?.mnemonic) {\n await this.keymasterService.newWallet(walletConfig.mnemonic, true);\n }\n\n if (walletConfig?.id) {\n const did = await this.keymasterService.createId(walletConfig.id, {\n registry: walletConfig.registry,\n });\n console.log(\"Did \", did);\n console.log(`Created wallet with ID ${walletConfig.id}`);\n }\n }\n\n private async serviceRunning(): Promise<boolean> {\n return this.serviceStarted || (await this.startInternal());\n }\n\n private validateConfig(config: KeymasterConfig): void {\n if (!config.gatekeeperConfig) {\n throw new Error(\"Missing Gatekeeper config\");\n }\n\n if (config.gatekeeperConfig) {\n if (!config.walletConfig) {\n throw new Error(\"Missing wallet config\");\n }\n if (!config.walletDb?.loadWallet) {\n throw new Error(\"Missing load wallet callback\");\n }\n if (!config.walletDb?.saveWallet) {\n throw new Error(\"Missing save wallet callback\");\n }\n }\n }\n}\n","import KeymasterClient from \"@mdip/keymaster/client\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n IssueCredentialsOptions,\n VerifiableCredential,\n} from \"@mdip/keymaster/types\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n} from \"./types/index.js\";\n\nexport interface KeymasterConfig {\n keymasterConfig?: SdkConfig;\n}\n\nexport class KeymasterExternalClient {\n private config: KeymasterConfig;\n private keymasterService!: KeymasterClient;\n private serviceStarted = false;\n\n constructor(config: KeymasterConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n public async start(): Promise<boolean> {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Keymaster config\";\n }\n return this.serviceStarted;\n }\n\n public async startExternal(): Promise<boolean> {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Gatekeeper or Keymaster config\";\n }\n return this.serviceStarted;\n }\n\n private async startExternalKeymaster(): Promise<boolean> {\n console.log(`Starting external Keymaster service`);\n try {\n this.keymasterService = new KeymasterClient();\n await this.keymasterService.connect(this.config.keymasterConfig);\n } catch (e) {\n console.error(`Error starting Keymaster service:`, e);\n return false;\n }\n\n console.log(`Started external Keymaster service`);\n return true;\n }\n\n async createChallenge(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const challenge: string = await this.keymasterService?.createChallenge(\n spec,\n options\n );\n return {\n challenge: challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`,\n };\n }\n\n async bindCredential(\n schemaId: string,\n subjectId: string,\n options: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n } = {}\n ): Promise<VerifiableCredential> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n\n async issueCredential(\n credential: Partial<VerifiableCredential>,\n options: IssueCredentialsOptions = {}\n ): Promise<string> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.issueCredential(credential, options);\n }\n\n async publishCredential(\n did: string,\n options: { reveal?: boolean } = {}\n ): Promise<boolean> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.publishCredential(did, options);\n }\n\n async acceptCredential(did: string): Promise<boolean> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.acceptCredential(did);\n }\n\n async showMnemonic(): Promise<string> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.decryptMnemonic();\n }\n\n async verifyResponse(\n did: string,\n options?: {\n retries?: number;\n delay?: number;\n }\n ): Promise<ChallengeResponse> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const response: ChallengeResponse =\n await this.keymasterService.verifyResponse(did, options);\n return response;\n }\n\n private async serviceRunning(): Promise<boolean> {\n return this.serviceStarted || (await this.start());\n }\n\n private validateConfig(config: KeymasterConfig): void {\n if (!config.keymasterConfig) {\n throw new Error(\"Missing Keymaster config\");\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/siwys-js/siwys-js/packages/api-js/dist/index.cjs","../src/index.ts","../src/keymaster.ts","../src/keymasterClient.ts"],"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__reExport","mod","secondTarget","__toESM","isNodeMode","__esModule","value","__toCommonJS","src_exports","Keymaster","KeymasterExternalClient","module","exports","import_client","require","import_node","import_keymaster","_Keymaster","config","serviceStarted","validateConfig","ensureInitialized","instance","Error","ensureServiceIsRunning","serviceRunning","startInternal","gatekeeperConfig","startIntegratedKeymaster","gatekeeper","cipher","e","console","log","walletDb","GatekeeperClient","connect","CipherNode","keymasterService","KeymasterLib","wallet","ensureWalletExists","error","createChallengeInternal","spec","options","challenge","createChallenge","challengeUrl","callback","bindCredentialInternal","schemaId","subjectId","bindCredential","issueCredentialInternal","credential","issueCredential","publishCredentialInternal","did","publishCredential","acceptCredentialInternal","acceptCredential","showMnemonicInternal","decryptMnemonic","verifyResponseInternal","verifyResponse","decryptMessageInternal","args","decryptMessage","decryptMnemonicInternal","getCredentialInternal","getCredential","removeCredentialInternal","removeCredential","updateCredentialInternal","updateCredential","createIdInternal","createId","removeIdInternal","removeId","resolveDIDInternal","resolveDID","setCurrentIdInternal","setCurrentId","createSchemaInternal","createSchema","newWalletInternal","newWallet","recoverWalletInternal","recoverWallet","existing","walletConfig","loadWallet","current","id","mnemonic","registry","saveWallet","initialize","warn","start","getInstance","showMnemonic","keymasterConfig","startExternalKeymaster","startExternal","import_client2","KeymasterClient","response"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAIA,WAAWC,OAAOC,MAAM;AAC5B,IAAIC,YAAYF,OAAOG,cAAc;AACrC,IAAIC,mBAAmBJ,OAAOK,wBAAwB;AACtD,IAAIC,oBAAoBN,OAAOO,mBAAmB;AAClD,IAAIC,eAAeR,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AN,SAAMA;;uBAAN,oBAAA;;wBACE,IAAI,CAAC,MAAK7E,cAAA,IAAkB;4BAC1B,MAAM,IAAIF,MAAM;wBAClB;wBACA;;4BAAO,MAAKe,gBAAA,CAAiByB,eAAA;;;gBAC/B;;;;YAEME,KAAAA;mBAAN,SAAMA,eACJP,GAAA,EACAb,OAAA;;uBAFF,oBAAA;wBAUQ+D;;;;gCAHN,IAAI,CAAC,MAAKnF,cAAA,IAAkB;oCAC1B,MAAM,IAAIF,MAAM;gCAClB;gCAEE;;oCAAM,MAAKe,gBAAA,CAAiB2B,cAAA,CAAeP,KAAKb;;;gCAD5C+D,WACJ;gCACF;;oCAAOA;;;;gBACT;;;;YAEcnF,KAAAA;mBAAd,SAAcA;;uBAAd,oBAAA;;;;;uCACS,MAAKN,cAAA;0CAAL;;;;gCAAwB;;oCAAM,MAAKiF,KAAA;;;uCAAX;;;gCAA/B;;;;;;gBACF;;;;YAEQhF,KAAAA;mBAAAA,SAAAA,eAAeF,MAAA;gBACrB,IAAI,CAACA,OAAOqF,eAAA,EAAiB;oBAC3B,MAAM,IAAIhF,MAAM;gBAClB;YACF;;;;;AHqQF,eAAe;AClZfvB,WAAAQ,aAAcM,QAAA,0BAXdH,OAAAC,OAAA;AD+ZA,6DAA6D;AAC7D,KAAMD,CAAAA,OAAOC,OAAO,GAAG;IACrBH,WAAAA;IACAC,yBAAAA;GACGI,QAAQ,yBACb","sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, \"default\"), secondTarget && __copyProps(secondTarget, mod, \"default\"));\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/index.ts\nvar src_exports = {};\n__export(src_exports, {\n Keymaster: () => Keymaster,\n KeymasterExternalClient: () => KeymasterExternalClient\n});\nmodule.exports = __toCommonJS(src_exports);\n\n// src/keymaster.ts\nvar import_client = __toESM(require(\"@mdip/gatekeeper/client\"), 1);\nvar import_node = __toESM(require(\"@mdip/cipher/node\"), 1);\nvar import_keymaster = __toESM(require(\"@mdip/keymaster\"), 1);\nvar _Keymaster = class _Keymaster {\n constructor(config) {\n this.serviceStarted = false;\n this.validateConfig(config);\n this.config = config;\n }\n static initialize(config) {\n if (!_Keymaster.instance) {\n _Keymaster.instance = new _Keymaster(config);\n console.log(\"\\u2705 Keymaster initialized\");\n } else {\n console.warn(\n \"Keymaster already initialized, ignoring re-initialization.\"\n );\n }\n }\n ensureInitialized() {\n if (!_Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n }\n // Delegated STATIC methods\n static async start() {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().startInternal();\n }\n static async createChallenge(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().createChallengeInternal(...args);\n }\n static async bindCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().bindCredentialInternal(...args);\n }\n static async issueCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().issueCredentialInternal(...args);\n }\n static async publishCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().publishCredentialInternal(...args);\n }\n static async acceptCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().acceptCredentialInternal(...args);\n }\n static async showMnemonic(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().showMnemonicInternal(...args);\n }\n static async verifyResponse(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().verifyResponseInternal(...args);\n }\n static async decryptMessage(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().decryptMessageInternal(...args);\n }\n static async decryptMnemonic(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().decryptMnemonicInternal(...args);\n }\n static async getCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().getCredentialInternal(...args);\n }\n static async removeCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().removeCredentialInternal(...args);\n }\n static async updateCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().updateCredentialInternal(...args);\n }\n static async createId(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().createIdInternal(...args);\n }\n static async removeId(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().removeIdInternal(...args);\n }\n static async resolveDID(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().resolveDIDInternal(...args);\n }\n static async setCurrentId(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().setCurrentIdInternal(...args);\n }\n static async createSchema(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().createSchemaInternal(...args);\n }\n static async newWallet(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().newWalletInternal(...args);\n }\n static async recoverWallet(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().recoverWalletInternal(...args);\n }\n static getInstance() {\n if (!_Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n return _Keymaster.instance;\n }\n // -------- Internal instance methods (originals renamed with Internal) -------\n async ensureServiceIsRunning() {\n if (!await this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n }\n async startInternal() {\n if (this.config.gatekeeperConfig) {\n this.serviceStarted = await this.startIntegratedKeymaster();\n } else {\n throw \"Missing Gatekeeper config\";\n }\n return this.serviceStarted;\n }\n async startIntegratedKeymaster() {\n console.log(`Starting integrated Keymaster service`);\n try {\n if (this.config.walletDb) {\n const gatekeeper = new import_client.default();\n await gatekeeper.connect(this.config.gatekeeperConfig);\n const cipher = new import_node.default();\n this.keymasterService = new import_keymaster.default({\n gatekeeper,\n wallet: this.config.walletDb,\n cipher\n });\n await this.ensureWalletExists();\n } else {\n return false;\n }\n } catch (e) {\n console.error(\"Error starting Keymaster service:\", e);\n return false;\n }\n console.log(`Started integrated Keymaster service`);\n return true;\n }\n async createChallengeInternal(spec, options) {\n await this.ensureServiceIsRunning();\n const challenge = await this.keymasterService.createChallenge(\n spec,\n options\n );\n return {\n challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`\n };\n }\n async bindCredentialInternal(schemaId, subjectId, options = {}) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n async issueCredentialInternal(credential, options = {}) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.issueCredential(credential, options);\n }\n async publishCredentialInternal(did, options = {}) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.publishCredential(did, options);\n }\n async acceptCredentialInternal(did) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.acceptCredential(did);\n }\n async showMnemonicInternal() {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic();\n }\n async verifyResponseInternal(did, options) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.verifyResponse(did, options);\n }\n async decryptMessageInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMessage(...args);\n }\n async decryptMnemonicInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic(...args);\n }\n async getCredentialInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.getCredential(...args);\n }\n async removeCredentialInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeCredential(...args);\n }\n async updateCredentialInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.updateCredential(...args);\n }\n async createIdInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createId(...args);\n }\n async removeIdInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeId(...args);\n }\n async resolveDIDInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.resolveDID(...args);\n }\n async setCurrentIdInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.setCurrentId(...args);\n }\n async createSchemaInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createSchema(...args);\n }\n async newWalletInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.newWallet(...args);\n }\n async recoverWalletInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.recoverWallet(...args);\n }\n async ensureWalletExists() {\n console.log(\"Ensuring wallet exists\");\n const existing = await this.config?.walletDb?.loadWallet() || null;\n if (existing && \"current\" in existing) {\n console.log(`Using existing wallet with ID ${existing.current}`);\n return;\n }\n const walletConfig = this.config.walletConfig;\n console.log(`Creating wallet with ID ${walletConfig?.id}`);\n if (walletConfig?.mnemonic) {\n await this.keymasterService.newWallet(walletConfig.mnemonic, true);\n }\n if (walletConfig?.id) {\n const did = await this.keymasterService.createId(walletConfig.id, {\n registry: walletConfig.registry\n });\n console.log(\"Did \", did);\n console.log(`Created wallet with ID ${walletConfig.id}`);\n }\n }\n async serviceRunning() {\n return this.serviceStarted || await this.startInternal();\n }\n validateConfig(config) {\n if (!config.gatekeeperConfig) {\n throw new Error(\"Missing Gatekeeper config\");\n }\n if (config.gatekeeperConfig) {\n if (!config.walletConfig) {\n throw new Error(\"Missing wallet config\");\n }\n if (!config.walletDb?.loadWallet) {\n throw new Error(\"Missing load wallet callback\");\n }\n if (!config.walletDb?.saveWallet) {\n throw new Error(\"Missing save wallet callback\");\n }\n }\n }\n};\n_Keymaster.instance = null;\nvar Keymaster = _Keymaster;\n\n// src/keymasterClient.ts\nvar import_client2 = __toESM(require(\"@mdip/keymaster/client\"), 1);\nvar KeymasterExternalClient = class {\n constructor(config) {\n this.serviceStarted = false;\n this.validateConfig(config);\n this.config = config;\n }\n async start() {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Keymaster config\";\n }\n return this.serviceStarted;\n }\n async startExternal() {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Gatekeeper or Keymaster config\";\n }\n return this.serviceStarted;\n }\n async startExternalKeymaster() {\n console.log(`Starting external Keymaster service`);\n try {\n this.keymasterService = new import_client2.default();\n await this.keymasterService.connect(this.config.keymasterConfig);\n } catch (e) {\n console.error(`Error starting Keymaster service:`, e);\n return false;\n }\n console.log(`Started external Keymaster service`);\n return true;\n }\n async createChallenge(spec, options) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const challenge = await this.keymasterService?.createChallenge(\n spec,\n options\n );\n return {\n challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`\n };\n }\n async bindCredential(schemaId, subjectId, options = {}) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n async issueCredential(credential, options = {}) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.issueCredential(credential, options);\n }\n async publishCredential(did, options = {}) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.publishCredential(did, options);\n }\n async acceptCredential(did) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.acceptCredential(did);\n }\n async showMnemonic() {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.decryptMnemonic();\n }\n async verifyResponse(did, options) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const response = await this.keymasterService.verifyResponse(did, options);\n return response;\n }\n async serviceRunning() {\n return this.serviceStarted || await this.start();\n }\n validateConfig(config) {\n if (!config.keymasterConfig) {\n throw new Error(\"Missing Keymaster config\");\n }\n }\n};\n\n// src/index.ts\n__reExport(src_exports, require(\"@mdip/keymaster/types\"), module.exports);\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n Keymaster,\n KeymasterExternalClient,\n ...require(\"@mdip/keymaster/types\")\n});\n","export { Keymaster, KeymasterConfig } from \"./keymaster.js\";\n\nexport { KeymasterExternalClient } from \"./keymasterClient.js\";\n\nexport {\n SdkConfig,\n WalletConfig,\n CreateChallengeResponse,\n CreateChallengeSpec,\n} from \"./types/index.js\";\n\nexport * from \"@mdip/keymaster/types\";\n","import GatekeeperClient from \"@mdip/gatekeeper/client\";\nimport CipherNode from \"@mdip/cipher/node\";\nimport KeymasterLib from \"@mdip/keymaster\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n WalletConfig,\n} from \"./types/index.js\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n IssueCredentialsOptions,\n StoredWallet,\n VerifiableCredential,\n WalletBase,\n} from \"@mdip/keymaster/types\";\n\nexport interface KeymasterConfig {\n gatekeeperConfig?: SdkConfig;\n walletDb?: WalletBase;\n walletConfig?: WalletConfig;\n}\n\nexport class Keymaster {\n private static instance: Keymaster | null = null;\n\n private config: KeymasterConfig;\n private keymasterService!: KeymasterLib;\n private serviceStarted = false;\n\n private constructor(config: KeymasterConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n public static initialize(config: KeymasterConfig) {\n if (!Keymaster.instance) {\n Keymaster.instance = new Keymaster(config);\n console.log(\"✅ Keymaster initialized\");\n } else {\n console.warn(\n \"Keymaster already initialized, ignoring re-initialization.\"\n );\n }\n }\n\n private ensureInitialized() {\n if (!Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n }\n\n // Delegated STATIC methods\n\n public static async start() {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().startInternal();\n }\n\n public static async createChallenge(\n ...args: Parameters<Keymaster[\"createChallengeInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createChallengeInternal(...args);\n }\n\n public static async bindCredential(\n ...args: Parameters<Keymaster[\"bindCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().bindCredentialInternal(...args);\n }\n\n public static async issueCredential(\n ...args: Parameters<Keymaster[\"issueCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().issueCredentialInternal(...args);\n }\n\n public static async publishCredential(\n ...args: Parameters<Keymaster[\"publishCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().publishCredentialInternal(...args);\n }\n\n public static async acceptCredential(\n ...args: Parameters<Keymaster[\"acceptCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().acceptCredentialInternal(...args);\n }\n\n public static async showMnemonic(\n ...args: Parameters<Keymaster[\"showMnemonicInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().showMnemonicInternal(...args);\n }\n\n public static async verifyResponse(\n ...args: Parameters<Keymaster[\"verifyResponseInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().verifyResponseInternal(...args);\n }\n\n public static async decryptMessage(\n ...args: Parameters<Keymaster[\"decryptMessageInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().decryptMessageInternal(...args);\n }\n\n public static async decryptMnemonic(\n ...args: Parameters<Keymaster[\"decryptMnemonicInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().decryptMnemonicInternal(...args);\n }\n\n public static async getCredential(\n ...args: Parameters<Keymaster[\"getCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().getCredentialInternal(...args);\n }\n\n public static async removeCredential(\n ...args: Parameters<Keymaster[\"removeCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().removeCredentialInternal(...args);\n }\n\n public static async updateCredential(\n ...args: Parameters<Keymaster[\"updateCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().updateCredentialInternal(...args);\n }\n\n public static async createId(\n ...args: Parameters<Keymaster[\"createIdInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createIdInternal(...args);\n }\n\n public static async removeId(\n ...args: Parameters<Keymaster[\"removeIdInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().removeIdInternal(...args);\n }\n\n public static async resolveDID(\n ...args: Parameters<Keymaster[\"resolveDIDInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().resolveDIDInternal(...args);\n }\n\n public static async setCurrentId(\n ...args: Parameters<Keymaster[\"setCurrentIdInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().setCurrentIdInternal(...args);\n }\n\n public static async createSchema(\n ...args: Parameters<Keymaster[\"createSchemaInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createSchemaInternal(...args);\n }\n\n public static async newWallet(\n ...args: Parameters<Keymaster[\"newWalletInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().newWalletInternal(...args);\n }\n\n public static async recoverWallet(\n ...args: Parameters<Keymaster[\"recoverWalletInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().recoverWalletInternal(...args);\n }\n\n private static getInstance(): Keymaster {\n if (!Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n return Keymaster.instance;\n }\n\n // -------- Internal instance methods (originals renamed with Internal) -------\n\n private async ensureServiceIsRunning() {\n if (!(await this.serviceRunning())) {\n throw new Error(\"Keymaster service not running\");\n }\n }\n\n private async startInternal(): Promise<boolean> {\n if (this.config.gatekeeperConfig) {\n this.serviceStarted = await this.startIntegratedKeymaster();\n } else {\n throw \"Missing Gatekeeper config\";\n }\n return this.serviceStarted;\n }\n\n private async startIntegratedKeymaster(): Promise<boolean> {\n console.log(`Starting integrated Keymaster service`);\n\n try {\n if (this.config.walletDb) {\n const gatekeeper = new GatekeeperClient();\n await gatekeeper.connect(this.config.gatekeeperConfig);\n\n const cipher = new CipherNode();\n\n this.keymasterService = new KeymasterLib({\n gatekeeper,\n wallet: this.config.walletDb,\n cipher,\n });\n\n await this.ensureWalletExists();\n } else {\n return false;\n }\n } catch (e) {\n console.error(\"Error starting Keymaster service:\", e);\n return false;\n }\n\n console.log(`Started integrated Keymaster service`);\n return true;\n }\n\n private async createChallengeInternal(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n await this.ensureServiceIsRunning();\n const challenge: string = await this.keymasterService.createChallenge(\n spec,\n options\n );\n return {\n challenge: challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`,\n };\n }\n\n private async bindCredentialInternal(\n schemaId: string,\n subjectId: string,\n options: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n } = {}\n ): Promise<VerifiableCredential> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n\n private async issueCredentialInternal(\n credential: Partial<VerifiableCredential>,\n options: IssueCredentialsOptions = {}\n ): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.issueCredential(credential, options);\n }\n\n private async publishCredentialInternal(\n did: string,\n options: { reveal?: boolean } = {}\n ): Promise<VerifiableCredential> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.publishCredential(did, options);\n }\n\n private async acceptCredentialInternal(did: string): Promise<boolean> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.acceptCredential(did);\n }\n\n private async showMnemonicInternal(): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic();\n }\n\n private async verifyResponseInternal(\n did: string,\n options?: { retries?: number; delay?: number }\n ): Promise<ChallengeResponse> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.verifyResponse(did, options);\n }\n\n private async decryptMessageInternal(\n ...args: Parameters<KeymasterLib[\"decryptMessage\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMessage(...args);\n }\n\n private async decryptMnemonicInternal(\n ...args: Parameters<KeymasterLib[\"decryptMnemonic\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic(...args);\n }\n\n private async getCredentialInternal(\n ...args: Parameters<KeymasterLib[\"getCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.getCredential(...args);\n }\n\n private async removeCredentialInternal(\n ...args: Parameters<KeymasterLib[\"removeCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeCredential(...args);\n }\n\n private async updateCredentialInternal(\n ...args: Parameters<KeymasterLib[\"updateCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.updateCredential(...args);\n }\n\n private async createIdInternal(\n ...args: Parameters<KeymasterLib[\"createId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createId(...args);\n }\n\n private async removeIdInternal(\n ...args: Parameters<KeymasterLib[\"removeId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeId(...args);\n }\n\n private async resolveDIDInternal(\n ...args: Parameters<KeymasterLib[\"resolveDID\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.resolveDID(...args);\n }\n\n private async setCurrentIdInternal(\n ...args: Parameters<KeymasterLib[\"setCurrentId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.setCurrentId(...args);\n }\n\n private async createSchemaInternal(\n ...args: Parameters<KeymasterLib[\"createSchema\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createSchema(...args);\n }\n\n private async newWalletInternal(\n ...args: Parameters<KeymasterLib[\"newWallet\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.newWallet(...args);\n }\n\n private async recoverWalletInternal(\n ...args: Parameters<KeymasterLib[\"recoverWallet\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.recoverWallet(...args);\n }\n\n private async ensureWalletExists(): Promise<void> {\n console.log(\"Ensuring wallet exists\");\n const existing: StoredWallet | null =\n (await this.config?.walletDb?.loadWallet()) || null;\n if (existing && \"current\" in existing) {\n console.log(`Using existing wallet with ID ${existing.current}`);\n return;\n }\n\n const walletConfig = this.config.walletConfig;\n console.log(`Creating wallet with ID ${walletConfig?.id}`);\n if (walletConfig?.mnemonic) {\n await this.keymasterService.newWallet(walletConfig.mnemonic, true);\n }\n\n if (walletConfig?.id) {\n const did = await this.keymasterService.createId(walletConfig.id, {\n registry: walletConfig.registry,\n });\n console.log(\"Did \", did);\n console.log(`Created wallet with ID ${walletConfig.id}`);\n }\n }\n\n private async serviceRunning(): Promise<boolean> {\n return this.serviceStarted || (await this.startInternal());\n }\n\n private validateConfig(config: KeymasterConfig): void {\n if (!config.gatekeeperConfig) {\n throw new Error(\"Missing Gatekeeper config\");\n }\n\n if (config.gatekeeperConfig) {\n if (!config.walletConfig) {\n throw new Error(\"Missing wallet config\");\n }\n if (!config.walletDb?.loadWallet) {\n throw new Error(\"Missing load wallet callback\");\n }\n if (!config.walletDb?.saveWallet) {\n throw new Error(\"Missing save wallet callback\");\n }\n }\n }\n}\n","import KeymasterClient from \"@mdip/keymaster/client\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n IssueCredentialsOptions,\n VerifiableCredential,\n} from \"@mdip/keymaster/types\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n} from \"./types/index.js\";\n\nexport interface KeymasterConfig {\n keymasterConfig?: SdkConfig;\n}\n\nexport class KeymasterExternalClient {\n private config: KeymasterConfig;\n private keymasterService!: KeymasterClient;\n private serviceStarted = false;\n\n constructor(config: KeymasterConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n public async start(): Promise<boolean> {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Keymaster config\";\n }\n return this.serviceStarted;\n }\n\n public async startExternal(): Promise<boolean> {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Gatekeeper or Keymaster config\";\n }\n return this.serviceStarted;\n }\n\n private async startExternalKeymaster(): Promise<boolean> {\n console.log(`Starting external Keymaster service`);\n try {\n this.keymasterService = new KeymasterClient();\n await this.keymasterService.connect(this.config.keymasterConfig);\n } catch (e) {\n console.error(`Error starting Keymaster service:`, e);\n return false;\n }\n\n console.log(`Started external Keymaster service`);\n return true;\n }\n\n async createChallenge(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const challenge: string = await this.keymasterService?.createChallenge(\n spec,\n options\n );\n return {\n challenge: challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`,\n };\n }\n\n async bindCredential(\n schemaId: string,\n subjectId: string,\n options: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n } = {}\n ): Promise<VerifiableCredential> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n\n async issueCredential(\n credential: Partial<VerifiableCredential>,\n options: IssueCredentialsOptions = {}\n ): Promise<string> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.issueCredential(credential, options);\n }\n\n async publishCredential(\n did: string,\n options: { reveal?: boolean } = {}\n ): Promise<boolean> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.publishCredential(did, options);\n }\n\n async acceptCredential(did: string): Promise<boolean> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.acceptCredential(did);\n }\n\n async showMnemonic(): Promise<string> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.decryptMnemonic();\n }\n\n async verifyResponse(\n did: string,\n options?: {\n retries?: number;\n delay?: number;\n }\n ): Promise<ChallengeResponse> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const response: ChallengeResponse =\n await this.keymasterService.verifyResponse(did, options);\n return response;\n }\n\n private async serviceRunning(): Promise<boolean> {\n return this.serviceStarted || (await this.start());\n }\n\n private validateConfig(config: KeymasterConfig): void {\n if (!config.keymasterConfig) {\n throw new Error(\"Missing Keymaster config\");\n }\n }\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as _mdip_keymaster_types from '@mdip/keymaster/types';
|
|
2
2
|
import { WalletBase, VerifiableCredential, ChallengeResponse, CreateAssetOptions, IssueCredentialsOptions } from '@mdip/keymaster/types';
|
|
3
|
+
export * from '@mdip/keymaster/types';
|
|
3
4
|
import * as _mdip_gatekeeper_types from '@mdip/gatekeeper/types';
|
|
4
5
|
|
|
5
6
|
interface CreateChallengeSpec {
|
|
@@ -9,40 +10,10 @@ interface CreateChallengeSpec {
|
|
|
9
10
|
issuers: string[];
|
|
10
11
|
}[];
|
|
11
12
|
}
|
|
12
|
-
interface CreateChallengeOptions {
|
|
13
|
-
registry?: string;
|
|
14
|
-
validUntil?: string;
|
|
15
|
-
}
|
|
16
13
|
interface CreateChallengeResponse {
|
|
17
14
|
challenge: string;
|
|
18
15
|
challengeUrl: string;
|
|
19
16
|
}
|
|
20
|
-
interface VerifyResponseOptions {
|
|
21
|
-
retries?: number;
|
|
22
|
-
delay?: number;
|
|
23
|
-
}
|
|
24
|
-
interface Credential {
|
|
25
|
-
vp: string;
|
|
26
|
-
}
|
|
27
|
-
interface VerifyResponseResponse {
|
|
28
|
-
match: boolean;
|
|
29
|
-
challenge: string;
|
|
30
|
-
responder: string;
|
|
31
|
-
credentials?: Credential[];
|
|
32
|
-
}
|
|
33
|
-
interface WalletSeed {
|
|
34
|
-
mnemonic: string;
|
|
35
|
-
hdkey: {
|
|
36
|
-
xpriv: string;
|
|
37
|
-
xpub: string;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
interface Wallet {
|
|
41
|
-
seed: WalletSeed;
|
|
42
|
-
counter: number;
|
|
43
|
-
ids: any;
|
|
44
|
-
current?: string;
|
|
45
|
-
}
|
|
46
17
|
interface SdkConfig {
|
|
47
18
|
url: string;
|
|
48
19
|
waitUntilReady?: boolean;
|
|
@@ -54,10 +25,6 @@ interface WalletConfig {
|
|
|
54
25
|
mnemonic?: string;
|
|
55
26
|
registry?: string;
|
|
56
27
|
}
|
|
57
|
-
interface WalletDb {
|
|
58
|
-
loadWallet: () => Promise<Wallet | null>;
|
|
59
|
-
saveWallet: (w: Wallet, overwrite?: boolean) => Promise<boolean>;
|
|
60
|
-
}
|
|
61
28
|
|
|
62
29
|
interface KeymasterConfig$1 {
|
|
63
30
|
gatekeeperConfig?: SdkConfig;
|
|
@@ -151,4 +118,4 @@ declare class KeymasterExternalClient {
|
|
|
151
118
|
private validateConfig;
|
|
152
119
|
}
|
|
153
120
|
|
|
154
|
-
export { type
|
|
121
|
+
export { type CreateChallengeResponse, type CreateChallengeSpec, Keymaster, type KeymasterConfig$1 as KeymasterConfig, KeymasterExternalClient, type SdkConfig, type WalletConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as _mdip_keymaster_types from '@mdip/keymaster/types';
|
|
2
2
|
import { WalletBase, VerifiableCredential, ChallengeResponse, CreateAssetOptions, IssueCredentialsOptions } from '@mdip/keymaster/types';
|
|
3
|
+
export * from '@mdip/keymaster/types';
|
|
3
4
|
import * as _mdip_gatekeeper_types from '@mdip/gatekeeper/types';
|
|
4
5
|
|
|
5
6
|
interface CreateChallengeSpec {
|
|
@@ -9,40 +10,10 @@ interface CreateChallengeSpec {
|
|
|
9
10
|
issuers: string[];
|
|
10
11
|
}[];
|
|
11
12
|
}
|
|
12
|
-
interface CreateChallengeOptions {
|
|
13
|
-
registry?: string;
|
|
14
|
-
validUntil?: string;
|
|
15
|
-
}
|
|
16
13
|
interface CreateChallengeResponse {
|
|
17
14
|
challenge: string;
|
|
18
15
|
challengeUrl: string;
|
|
19
16
|
}
|
|
20
|
-
interface VerifyResponseOptions {
|
|
21
|
-
retries?: number;
|
|
22
|
-
delay?: number;
|
|
23
|
-
}
|
|
24
|
-
interface Credential {
|
|
25
|
-
vp: string;
|
|
26
|
-
}
|
|
27
|
-
interface VerifyResponseResponse {
|
|
28
|
-
match: boolean;
|
|
29
|
-
challenge: string;
|
|
30
|
-
responder: string;
|
|
31
|
-
credentials?: Credential[];
|
|
32
|
-
}
|
|
33
|
-
interface WalletSeed {
|
|
34
|
-
mnemonic: string;
|
|
35
|
-
hdkey: {
|
|
36
|
-
xpriv: string;
|
|
37
|
-
xpub: string;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
interface Wallet {
|
|
41
|
-
seed: WalletSeed;
|
|
42
|
-
counter: number;
|
|
43
|
-
ids: any;
|
|
44
|
-
current?: string;
|
|
45
|
-
}
|
|
46
17
|
interface SdkConfig {
|
|
47
18
|
url: string;
|
|
48
19
|
waitUntilReady?: boolean;
|
|
@@ -54,10 +25,6 @@ interface WalletConfig {
|
|
|
54
25
|
mnemonic?: string;
|
|
55
26
|
registry?: string;
|
|
56
27
|
}
|
|
57
|
-
interface WalletDb {
|
|
58
|
-
loadWallet: () => Promise<Wallet | null>;
|
|
59
|
-
saveWallet: (w: Wallet, overwrite?: boolean) => Promise<boolean>;
|
|
60
|
-
}
|
|
61
28
|
|
|
62
29
|
interface KeymasterConfig$1 {
|
|
63
30
|
gatekeeperConfig?: SdkConfig;
|
|
@@ -151,4 +118,4 @@ declare class KeymasterExternalClient {
|
|
|
151
118
|
private validateConfig;
|
|
152
119
|
}
|
|
153
120
|
|
|
154
|
-
export { type
|
|
121
|
+
export { type CreateChallengeResponse, type CreateChallengeSpec, Keymaster, type KeymasterConfig$1 as KeymasterConfig, KeymasterExternalClient, type SdkConfig, type WalletConfig };
|
package/dist/index.js
CHANGED
|
@@ -1624,5 +1624,7 @@ var KeymasterExternalClient = /*#__PURE__*/ function() {
|
|
|
1624
1624
|
]);
|
|
1625
1625
|
return KeymasterExternalClient;
|
|
1626
1626
|
}();
|
|
1627
|
+
// src/index.ts
|
|
1628
|
+
export * from "@mdip/keymaster/types";
|
|
1627
1629
|
export { Keymaster, KeymasterExternalClient };
|
|
1628
1630
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/siwys-js/siwys-js/packages/api-js/dist/index.js","../src/keymaster.ts","../src/keymasterClient.ts"],"names":["GatekeeperClient","CipherNode","KeymasterLib","_Keymaster","config","serviceStarted","validateConfig","ensureInitialized","instance","Error","ensureServiceIsRunning","serviceRunning","startInternal","gatekeeperConfig","startIntegratedKeymaster","gatekeeper","cipher","e","console","log","walletDb","connect","keymasterService","wallet","ensureWalletExists","error","createChallengeInternal","spec","options","challenge","createChallenge","challengeUrl","callback","bindCredentialInternal","schemaId","subjectId","bindCredential","issueCredentialInternal","credential","issueCredential","publishCredentialInternal","did","publishCredential","acceptCredentialInternal","acceptCredential","showMnemonicInternal","decryptMnemonic","verifyResponseInternal","verifyResponse","decryptMessageInternal","args","decryptMessage","decryptMnemonicInternal","getCredentialInternal","getCredential","removeCredentialInternal","removeCredential","updateCredentialInternal","updateCredential","createIdInternal","createId","removeIdInternal","removeId","resolveDIDInternal","resolveDID","setCurrentIdInternal","setCurrentId","createSchemaInternal","createSchema","newWalletInternal","newWallet","recoverWalletInternal","recoverWallet","existing","walletConfig","loadWallet","current","id","mnemonic","registry","saveWallet","initialize","warn","start","getInstance","showMnemonic","Keymaster","KeymasterClient","KeymasterExternalClient","keymasterConfig","startExternalKeymaster","startExternal","response"],"mappings":"AAAA,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAnB,OAAOA,sBAAsB,0BAAA;AAC7B,OAAOC,gBAAgB,oBAAA;AACvB,OAAOC,kBAAkB,kBAAA;AAsBlB,IAAMC,2BAAN;;aAAMA,WAOSC,MAAA;gCAPTD;QAKX,IAAA,CAAQE,cAAA,GAAiB;QAGvB,IAAA,CAAKC,cAAA,CAAeF;QACpB,IAAA,CAAKA,MAAA,GAASA;;;;YAcRG,KAAAA;mBAAAA,SAAAA;gBACN,IAAI,CA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AwB;;oCAAM,MAAK8E,KAAA;;;uCAAX;;;gCAA/B;;;;;;gBACF;;;;YAEQ7E,KAAAA;mBAAAA,SAAAA,eAAeF,MAAA;gBACrB,IAAI,CAACA,OAAOqF,eAAA,EAAiB;oBAC3B,MAAM,IAAIhF,MAAM;gBAClB;YACF;;;;;AF8NF,SACE6E,SAAS,EACTE,uBAAuB,GACvB","sourcesContent":["// src/keymaster.ts\nimport GatekeeperClient from \"@mdip/gatekeeper/client\";\nimport CipherNode from \"@mdip/cipher/node\";\nimport KeymasterLib from \"@mdip/keymaster\";\nvar _Keymaster = class _Keymaster {\n constructor(config) {\n this.serviceStarted = false;\n this.validateConfig(config);\n this.config = config;\n }\n static initialize(config) {\n if (!_Keymaster.instance) {\n _Keymaster.instance = new _Keymaster(config);\n console.log(\"\\u2705 Keymaster initialized\");\n } else {\n console.warn(\n \"Keymaster already initialized, ignoring re-initialization.\"\n );\n }\n }\n ensureInitialized() {\n if (!_Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n }\n // Delegated STATIC methods\n static async start() {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().startInternal();\n }\n static async createChallenge(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().createChallengeInternal(...args);\n }\n static async bindCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().bindCredentialInternal(...args);\n }\n static async issueCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().issueCredentialInternal(...args);\n }\n static async publishCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().publishCredentialInternal(...args);\n }\n static async acceptCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().acceptCredentialInternal(...args);\n }\n static async showMnemonic(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().showMnemonicInternal(...args);\n }\n static async verifyResponse(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().verifyResponseInternal(...args);\n }\n static async decryptMessage(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().decryptMessageInternal(...args);\n }\n static async decryptMnemonic(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().decryptMnemonicInternal(...args);\n }\n static async getCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().getCredentialInternal(...args);\n }\n static async removeCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().removeCredentialInternal(...args);\n }\n static async updateCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().updateCredentialInternal(...args);\n }\n static async createId(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().createIdInternal(...args);\n }\n static async removeId(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().removeIdInternal(...args);\n }\n static async resolveDID(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().resolveDIDInternal(...args);\n }\n static async setCurrentId(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().setCurrentIdInternal(...args);\n }\n static async createSchema(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().createSchemaInternal(...args);\n }\n static async newWallet(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().newWalletInternal(...args);\n }\n static async recoverWallet(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().recoverWalletInternal(...args);\n }\n static getInstance() {\n if (!_Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n return _Keymaster.instance;\n }\n // -------- Internal instance methods (originals renamed with Internal) -------\n async ensureServiceIsRunning() {\n if (!await this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n }\n async startInternal() {\n if (this.config.gatekeeperConfig) {\n this.serviceStarted = await this.startIntegratedKeymaster();\n } else {\n throw \"Missing Gatekeeper config\";\n }\n return this.serviceStarted;\n }\n async startIntegratedKeymaster() {\n console.log(`Starting integrated Keymaster service`);\n try {\n if (this.config.walletDb) {\n const gatekeeper = new GatekeeperClient();\n await gatekeeper.connect(this.config.gatekeeperConfig);\n const cipher = new CipherNode();\n this.keymasterService = new KeymasterLib({\n gatekeeper,\n wallet: this.config.walletDb,\n cipher\n });\n await this.ensureWalletExists();\n } else {\n return false;\n }\n } catch (e) {\n console.error(\"Error starting Keymaster service:\", e);\n return false;\n }\n console.log(`Started integrated Keymaster service`);\n return true;\n }\n async createChallengeInternal(spec, options) {\n await this.ensureServiceIsRunning();\n const challenge = await this.keymasterService.createChallenge(\n spec,\n options\n );\n return {\n challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`\n };\n }\n async bindCredentialInternal(schemaId, subjectId, options = {}) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n async issueCredentialInternal(credential, options = {}) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.issueCredential(credential, options);\n }\n async publishCredentialInternal(did, options = {}) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.publishCredential(did, options);\n }\n async acceptCredentialInternal(did) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.acceptCredential(did);\n }\n async showMnemonicInternal() {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic();\n }\n async verifyResponseInternal(did, options) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.verifyResponse(did, options);\n }\n async decryptMessageInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMessage(...args);\n }\n async decryptMnemonicInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic(...args);\n }\n async getCredentialInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.getCredential(...args);\n }\n async removeCredentialInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeCredential(...args);\n }\n async updateCredentialInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.updateCredential(...args);\n }\n async createIdInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createId(...args);\n }\n async removeIdInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeId(...args);\n }\n async resolveDIDInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.resolveDID(...args);\n }\n async setCurrentIdInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.setCurrentId(...args);\n }\n async createSchemaInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createSchema(...args);\n }\n async newWalletInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.newWallet(...args);\n }\n async recoverWalletInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.recoverWallet(...args);\n }\n async ensureWalletExists() {\n console.log(\"Ensuring wallet exists\");\n const existing = await this.config?.walletDb?.loadWallet() || null;\n if (existing && \"current\" in existing) {\n console.log(`Using existing wallet with ID ${existing.current}`);\n return;\n }\n const walletConfig = this.config.walletConfig;\n console.log(`Creating wallet with ID ${walletConfig?.id}`);\n if (walletConfig?.mnemonic) {\n await this.keymasterService.newWallet(walletConfig.mnemonic, true);\n }\n if (walletConfig?.id) {\n const did = await this.keymasterService.createId(walletConfig.id, {\n registry: walletConfig.registry\n });\n console.log(\"Did \", did);\n console.log(`Created wallet with ID ${walletConfig.id}`);\n }\n }\n async serviceRunning() {\n return this.serviceStarted || await this.startInternal();\n }\n validateConfig(config) {\n if (!config.gatekeeperConfig) {\n throw new Error(\"Missing Gatekeeper config\");\n }\n if (config.gatekeeperConfig) {\n if (!config.walletConfig) {\n throw new Error(\"Missing wallet config\");\n }\n if (!config.walletDb?.loadWallet) {\n throw new Error(\"Missing load wallet callback\");\n }\n if (!config.walletDb?.saveWallet) {\n throw new Error(\"Missing save wallet callback\");\n }\n }\n }\n};\n_Keymaster.instance = null;\nvar Keymaster = _Keymaster;\n\n// src/keymasterClient.ts\nimport KeymasterClient from \"@mdip/keymaster/client\";\nvar KeymasterExternalClient = class {\n constructor(config) {\n this.serviceStarted = false;\n this.validateConfig(config);\n this.config = config;\n }\n async start() {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Keymaster config\";\n }\n return this.serviceStarted;\n }\n async startExternal() {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Gatekeeper or Keymaster config\";\n }\n return this.serviceStarted;\n }\n async startExternalKeymaster() {\n console.log(`Starting external Keymaster service`);\n try {\n this.keymasterService = new KeymasterClient();\n await this.keymasterService.connect(this.config.keymasterConfig);\n } catch (e) {\n console.error(`Error starting Keymaster service:`, e);\n return false;\n }\n console.log(`Started external Keymaster service`);\n return true;\n }\n async createChallenge(spec, options) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const challenge = await this.keymasterService?.createChallenge(\n spec,\n options\n );\n return {\n challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`\n };\n }\n async bindCredential(schemaId, subjectId, options = {}) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n async issueCredential(credential, options = {}) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.issueCredential(credential, options);\n }\n async publishCredential(did, options = {}) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.publishCredential(did, options);\n }\n async acceptCredential(did) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.acceptCredential(did);\n }\n async showMnemonic() {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.decryptMnemonic();\n }\n async verifyResponse(did, options) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const response = await this.keymasterService.verifyResponse(did, options);\n return response;\n }\n async serviceRunning() {\n return this.serviceStarted || await this.start();\n }\n validateConfig(config) {\n if (!config.keymasterConfig) {\n throw new Error(\"Missing Keymaster config\");\n }\n }\n};\nexport {\n Keymaster,\n KeymasterExternalClient\n};\n","import GatekeeperClient from \"@mdip/gatekeeper/client\";\nimport CipherNode from \"@mdip/cipher/node\";\nimport KeymasterLib from \"@mdip/keymaster\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n WalletConfig,\n} from \"./types/index.js\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n IssueCredentialsOptions,\n StoredWallet,\n VerifiableCredential,\n WalletBase,\n} from \"@mdip/keymaster/types\";\n\nexport interface KeymasterConfig {\n gatekeeperConfig?: SdkConfig;\n walletDb?: WalletBase;\n walletConfig?: WalletConfig;\n}\n\nexport class Keymaster {\n private static instance: Keymaster | null = null;\n\n private config: KeymasterConfig;\n private keymasterService!: KeymasterLib;\n private serviceStarted = false;\n\n private constructor(config: KeymasterConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n public static initialize(config: KeymasterConfig) {\n if (!Keymaster.instance) {\n Keymaster.instance = new Keymaster(config);\n console.log(\"✅ Keymaster initialized\");\n } else {\n console.warn(\n \"Keymaster already initialized, ignoring re-initialization.\"\n );\n }\n }\n\n private ensureInitialized() {\n if (!Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n }\n\n // Delegated STATIC methods\n\n public static async start() {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().startInternal();\n }\n\n public static async createChallenge(\n ...args: Parameters<Keymaster[\"createChallengeInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createChallengeInternal(...args);\n }\n\n public static async bindCredential(\n ...args: Parameters<Keymaster[\"bindCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().bindCredentialInternal(...args);\n }\n\n public static async issueCredential(\n ...args: Parameters<Keymaster[\"issueCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().issueCredentialInternal(...args);\n }\n\n public static async publishCredential(\n ...args: Parameters<Keymaster[\"publishCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().publishCredentialInternal(...args);\n }\n\n public static async acceptCredential(\n ...args: Parameters<Keymaster[\"acceptCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().acceptCredentialInternal(...args);\n }\n\n public static async showMnemonic(\n ...args: Parameters<Keymaster[\"showMnemonicInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().showMnemonicInternal(...args);\n }\n\n public static async verifyResponse(\n ...args: Parameters<Keymaster[\"verifyResponseInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().verifyResponseInternal(...args);\n }\n\n public static async decryptMessage(\n ...args: Parameters<Keymaster[\"decryptMessageInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().decryptMessageInternal(...args);\n }\n\n public static async decryptMnemonic(\n ...args: Parameters<Keymaster[\"decryptMnemonicInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().decryptMnemonicInternal(...args);\n }\n\n public static async getCredential(\n ...args: Parameters<Keymaster[\"getCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().getCredentialInternal(...args);\n }\n\n public static async removeCredential(\n ...args: Parameters<Keymaster[\"removeCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().removeCredentialInternal(...args);\n }\n\n public static async updateCredential(\n ...args: Parameters<Keymaster[\"updateCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().updateCredentialInternal(...args);\n }\n\n public static async createId(\n ...args: Parameters<Keymaster[\"createIdInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createIdInternal(...args);\n }\n\n public static async removeId(\n ...args: Parameters<Keymaster[\"removeIdInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().removeIdInternal(...args);\n }\n\n public static async resolveDID(\n ...args: Parameters<Keymaster[\"resolveDIDInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().resolveDIDInternal(...args);\n }\n\n public static async setCurrentId(\n ...args: Parameters<Keymaster[\"setCurrentIdInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().setCurrentIdInternal(...args);\n }\n\n public static async createSchema(\n ...args: Parameters<Keymaster[\"createSchemaInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createSchemaInternal(...args);\n }\n\n public static async newWallet(\n ...args: Parameters<Keymaster[\"newWalletInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().newWalletInternal(...args);\n }\n\n public static async recoverWallet(\n ...args: Parameters<Keymaster[\"recoverWalletInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().recoverWalletInternal(...args);\n }\n\n private static getInstance(): Keymaster {\n if (!Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n return Keymaster.instance;\n }\n\n // -------- Internal instance methods (originals renamed with Internal) -------\n\n private async ensureServiceIsRunning() {\n if (!(await this.serviceRunning())) {\n throw new Error(\"Keymaster service not running\");\n }\n }\n\n private async startInternal(): Promise<boolean> {\n if (this.config.gatekeeperConfig) {\n this.serviceStarted = await this.startIntegratedKeymaster();\n } else {\n throw \"Missing Gatekeeper config\";\n }\n return this.serviceStarted;\n }\n\n private async startIntegratedKeymaster(): Promise<boolean> {\n console.log(`Starting integrated Keymaster service`);\n\n try {\n if (this.config.walletDb) {\n const gatekeeper = new GatekeeperClient();\n await gatekeeper.connect(this.config.gatekeeperConfig);\n\n const cipher = new CipherNode();\n\n this.keymasterService = new KeymasterLib({\n gatekeeper,\n wallet: this.config.walletDb,\n cipher,\n });\n\n await this.ensureWalletExists();\n } else {\n return false;\n }\n } catch (e) {\n console.error(\"Error starting Keymaster service:\", e);\n return false;\n }\n\n console.log(`Started integrated Keymaster service`);\n return true;\n }\n\n private async createChallengeInternal(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n await this.ensureServiceIsRunning();\n const challenge: string = await this.keymasterService.createChallenge(\n spec,\n options\n );\n return {\n challenge: challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`,\n };\n }\n\n private async bindCredentialInternal(\n schemaId: string,\n subjectId: string,\n options: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n } = {}\n ): Promise<VerifiableCredential> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n\n private async issueCredentialInternal(\n credential: Partial<VerifiableCredential>,\n options: IssueCredentialsOptions = {}\n ): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.issueCredential(credential, options);\n }\n\n private async publishCredentialInternal(\n did: string,\n options: { reveal?: boolean } = {}\n ): Promise<VerifiableCredential> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.publishCredential(did, options);\n }\n\n private async acceptCredentialInternal(did: string): Promise<boolean> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.acceptCredential(did);\n }\n\n private async showMnemonicInternal(): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic();\n }\n\n private async verifyResponseInternal(\n did: string,\n options?: { retries?: number; delay?: number }\n ): Promise<ChallengeResponse> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.verifyResponse(did, options);\n }\n\n private async decryptMessageInternal(\n ...args: Parameters<KeymasterLib[\"decryptMessage\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMessage(...args);\n }\n\n private async decryptMnemonicInternal(\n ...args: Parameters<KeymasterLib[\"decryptMnemonic\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic(...args);\n }\n\n private async getCredentialInternal(\n ...args: Parameters<KeymasterLib[\"getCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.getCredential(...args);\n }\n\n private async removeCredentialInternal(\n ...args: Parameters<KeymasterLib[\"removeCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeCredential(...args);\n }\n\n private async updateCredentialInternal(\n ...args: Parameters<KeymasterLib[\"updateCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.updateCredential(...args);\n }\n\n private async createIdInternal(\n ...args: Parameters<KeymasterLib[\"createId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createId(...args);\n }\n\n private async removeIdInternal(\n ...args: Parameters<KeymasterLib[\"removeId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeId(...args);\n }\n\n private async resolveDIDInternal(\n ...args: Parameters<KeymasterLib[\"resolveDID\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.resolveDID(...args);\n }\n\n private async setCurrentIdInternal(\n ...args: Parameters<KeymasterLib[\"setCurrentId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.setCurrentId(...args);\n }\n\n private async createSchemaInternal(\n ...args: Parameters<KeymasterLib[\"createSchema\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createSchema(...args);\n }\n\n private async newWalletInternal(\n ...args: Parameters<KeymasterLib[\"newWallet\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.newWallet(...args);\n }\n\n private async recoverWalletInternal(\n ...args: Parameters<KeymasterLib[\"recoverWallet\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.recoverWallet(...args);\n }\n\n private async ensureWalletExists(): Promise<void> {\n console.log(\"Ensuring wallet exists\");\n const existing: StoredWallet | null =\n (await this.config?.walletDb?.loadWallet()) || null;\n if (existing && \"current\" in existing) {\n console.log(`Using existing wallet with ID ${existing.current}`);\n return;\n }\n\n const walletConfig = this.config.walletConfig;\n console.log(`Creating wallet with ID ${walletConfig?.id}`);\n if (walletConfig?.mnemonic) {\n await this.keymasterService.newWallet(walletConfig.mnemonic, true);\n }\n\n if (walletConfig?.id) {\n const did = await this.keymasterService.createId(walletConfig.id, {\n registry: walletConfig.registry,\n });\n console.log(\"Did \", did);\n console.log(`Created wallet with ID ${walletConfig.id}`);\n }\n }\n\n private async serviceRunning(): Promise<boolean> {\n return this.serviceStarted || (await this.startInternal());\n }\n\n private validateConfig(config: KeymasterConfig): void {\n if (!config.gatekeeperConfig) {\n throw new Error(\"Missing Gatekeeper config\");\n }\n\n if (config.gatekeeperConfig) {\n if (!config.walletConfig) {\n throw new Error(\"Missing wallet config\");\n }\n if (!config.walletDb?.loadWallet) {\n throw new Error(\"Missing load wallet callback\");\n }\n if (!config.walletDb?.saveWallet) {\n throw new Error(\"Missing save wallet callback\");\n }\n }\n }\n}\n","import KeymasterClient from \"@mdip/keymaster/client\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n IssueCredentialsOptions,\n VerifiableCredential,\n} from \"@mdip/keymaster/types\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n} from \"./types/index.js\";\n\nexport interface KeymasterConfig {\n keymasterConfig?: SdkConfig;\n}\n\nexport class KeymasterExternalClient {\n private config: KeymasterConfig;\n private keymasterService!: KeymasterClient;\n private serviceStarted = false;\n\n constructor(config: KeymasterConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n public async start(): Promise<boolean> {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Keymaster config\";\n }\n return this.serviceStarted;\n }\n\n public async startExternal(): Promise<boolean> {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Gatekeeper or Keymaster config\";\n }\n return this.serviceStarted;\n }\n\n private async startExternalKeymaster(): Promise<boolean> {\n console.log(`Starting external Keymaster service`);\n try {\n this.keymasterService = new KeymasterClient();\n await this.keymasterService.connect(this.config.keymasterConfig);\n } catch (e) {\n console.error(`Error starting Keymaster service:`, e);\n return false;\n }\n\n console.log(`Started external Keymaster service`);\n return true;\n }\n\n async createChallenge(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const challenge: string = await this.keymasterService?.createChallenge(\n spec,\n options\n );\n return {\n challenge: challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`,\n };\n }\n\n async bindCredential(\n schemaId: string,\n subjectId: string,\n options: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n } = {}\n ): Promise<VerifiableCredential> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n\n async issueCredential(\n credential: Partial<VerifiableCredential>,\n options: IssueCredentialsOptions = {}\n ): Promise<string> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.issueCredential(credential, options);\n }\n\n async publishCredential(\n did: string,\n options: { reveal?: boolean } = {}\n ): Promise<boolean> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.publishCredential(did, options);\n }\n\n async acceptCredential(did: string): Promise<boolean> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.acceptCredential(did);\n }\n\n async showMnemonic(): Promise<string> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.decryptMnemonic();\n }\n\n async verifyResponse(\n did: string,\n options?: {\n retries?: number;\n delay?: number;\n }\n ): Promise<ChallengeResponse> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const response: ChallengeResponse =\n await this.keymasterService.verifyResponse(did, options);\n return response;\n }\n\n private async serviceRunning(): Promise<boolean> {\n return this.serviceStarted || (await this.start());\n }\n\n private validateConfig(config: KeymasterConfig): void {\n if (!config.keymasterConfig) {\n throw new Error(\"Missing Keymaster config\");\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/siwys-js/siwys-js/packages/api-js/dist/index.js","../src/keymaster.ts","../src/keymasterClient.ts","../src/index.ts"],"names":["GatekeeperClient","CipherNode","KeymasterLib","_Keymaster","config","serviceStarted","validateConfig","ensureInitialized","instance","Error","ensureServiceIsRunning","serviceRunning","startInternal","gatekeeperConfig","startIntegratedKeymaster","gatekeeper","cipher","e","console","log","walletDb","connect","keymasterService","wallet","ensureWalletExists","error","createChallengeInternal","spec","options","challenge","createChallenge","challengeUrl","callback","bindCredentialInternal","schemaId","subjectId","bindCredential","issueCredentialInternal","credential","issueCredential","publishCredentialInternal","did","publishCredential","acceptCredentialInternal","acceptCredential","showMnemonicInternal","decryptMnemonic","verifyResponseInternal","verifyResponse","decryptMessageInternal","args","decryptMessage","decryptMnemonicInternal","getCredentialInternal","getCredential","removeCredentialInternal","removeCredential","updateCredentialInternal","updateCredential","createIdInternal","createId","removeIdInternal","removeId","resolveDIDInternal","resolveDID","setCurrentIdInternal","setCurrentId","createSchemaInternal","createSchema","newWalletInternal","newWallet","recoverWalletInternal","recoverWallet","existing","walletConfig","loadWallet","current","id","mnemonic","registry","saveWallet","initialize","warn","start","getInstance","showMnemonic","Keymaster","KeymasterClient","KeymasterExternalClient","keymasterConfig","startExternalKeymaster","startExtern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AA;mBAAN,SAAMA;;uBAAN,oBAAA;;wBACE,IAAI,CAAC,MAAK1E,cAAA,IAAkB;4BAC1B,MAAM,IAAIF,MAAM;wBAClB;wBACA;;4BAAO,MAAKa,gBAAA,CAAiBwB,eAAA;;;gBAC/B;;;;YAEME,KAAAA;mBAAN,SAAMA,eACJP,GAAA,EACAb,OAAA;;uBAFF,oBAAA;wBAUQgE;;;;gCAHN,IAAI,CAAC,MAAKjF,cAAA,IAAkB;oCAC1B,MAAM,IAAIF,MAAM;gCAClB;gCAEE;;oCAAM,MAAKa,gBAAA,CAAiB0B,cAAA,CAAeP,KAAKb;;;gCAD5CgE,WACJ;gCACF;;oCAAOA;;;;gBACT;;;;YAEcjF,KAAAA;mBAAd,SAAcA;;uBAAd,oBAAA;;;;;uCACS,MAAKN,cAAA;0CAAL;;;;gCAAwB;;oCAAM,MAAK8E,KAAA;;;uCAAX;;;gCAA/B;;;;;;gBACF;;;;YAEQ7E,KAAAA;mBAAAA,SAAAA,eAAeF,MAAA;gBACrB,IAAI,CAACA,OAAOqF,eAAA,EAAiB;oBAC3B,MAAM,IAAIhF,MAAM;gBAClB;YACF;;;;;AF+NF,eAAe;AG5Wf,cAAc,wBAAA;AH8Wd,SACE6E,SAAS,EACTE,uBAAuB,GACvB","sourcesContent":["// src/keymaster.ts\nimport GatekeeperClient from \"@mdip/gatekeeper/client\";\nimport CipherNode from \"@mdip/cipher/node\";\nimport KeymasterLib from \"@mdip/keymaster\";\nvar _Keymaster = class _Keymaster {\n constructor(config) {\n this.serviceStarted = false;\n this.validateConfig(config);\n this.config = config;\n }\n static initialize(config) {\n if (!_Keymaster.instance) {\n _Keymaster.instance = new _Keymaster(config);\n console.log(\"\\u2705 Keymaster initialized\");\n } else {\n console.warn(\n \"Keymaster already initialized, ignoring re-initialization.\"\n );\n }\n }\n ensureInitialized() {\n if (!_Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n }\n // Delegated STATIC methods\n static async start() {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().startInternal();\n }\n static async createChallenge(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().createChallengeInternal(...args);\n }\n static async bindCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().bindCredentialInternal(...args);\n }\n static async issueCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().issueCredentialInternal(...args);\n }\n static async publishCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().publishCredentialInternal(...args);\n }\n static async acceptCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().acceptCredentialInternal(...args);\n }\n static async showMnemonic(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().showMnemonicInternal(...args);\n }\n static async verifyResponse(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().verifyResponseInternal(...args);\n }\n static async decryptMessage(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().decryptMessageInternal(...args);\n }\n static async decryptMnemonic(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().decryptMnemonicInternal(...args);\n }\n static async getCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().getCredentialInternal(...args);\n }\n static async removeCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().removeCredentialInternal(...args);\n }\n static async updateCredential(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().updateCredentialInternal(...args);\n }\n static async createId(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().createIdInternal(...args);\n }\n static async removeId(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().removeIdInternal(...args);\n }\n static async resolveDID(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().resolveDIDInternal(...args);\n }\n static async setCurrentId(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().setCurrentIdInternal(...args);\n }\n static async createSchema(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().createSchemaInternal(...args);\n }\n static async newWallet(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().newWalletInternal(...args);\n }\n static async recoverWallet(...args) {\n _Keymaster.getInstance().ensureInitialized();\n return _Keymaster.getInstance().recoverWalletInternal(...args);\n }\n static getInstance() {\n if (!_Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n return _Keymaster.instance;\n }\n // -------- Internal instance methods (originals renamed with Internal) -------\n async ensureServiceIsRunning() {\n if (!await this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n }\n async startInternal() {\n if (this.config.gatekeeperConfig) {\n this.serviceStarted = await this.startIntegratedKeymaster();\n } else {\n throw \"Missing Gatekeeper config\";\n }\n return this.serviceStarted;\n }\n async startIntegratedKeymaster() {\n console.log(`Starting integrated Keymaster service`);\n try {\n if (this.config.walletDb) {\n const gatekeeper = new GatekeeperClient();\n await gatekeeper.connect(this.config.gatekeeperConfig);\n const cipher = new CipherNode();\n this.keymasterService = new KeymasterLib({\n gatekeeper,\n wallet: this.config.walletDb,\n cipher\n });\n await this.ensureWalletExists();\n } else {\n return false;\n }\n } catch (e) {\n console.error(\"Error starting Keymaster service:\", e);\n return false;\n }\n console.log(`Started integrated Keymaster service`);\n return true;\n }\n async createChallengeInternal(spec, options) {\n await this.ensureServiceIsRunning();\n const challenge = await this.keymasterService.createChallenge(\n spec,\n options\n );\n return {\n challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`\n };\n }\n async bindCredentialInternal(schemaId, subjectId, options = {}) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n async issueCredentialInternal(credential, options = {}) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.issueCredential(credential, options);\n }\n async publishCredentialInternal(did, options = {}) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.publishCredential(did, options);\n }\n async acceptCredentialInternal(did) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.acceptCredential(did);\n }\n async showMnemonicInternal() {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic();\n }\n async verifyResponseInternal(did, options) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.verifyResponse(did, options);\n }\n async decryptMessageInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMessage(...args);\n }\n async decryptMnemonicInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic(...args);\n }\n async getCredentialInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.getCredential(...args);\n }\n async removeCredentialInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeCredential(...args);\n }\n async updateCredentialInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.updateCredential(...args);\n }\n async createIdInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createId(...args);\n }\n async removeIdInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeId(...args);\n }\n async resolveDIDInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.resolveDID(...args);\n }\n async setCurrentIdInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.setCurrentId(...args);\n }\n async createSchemaInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createSchema(...args);\n }\n async newWalletInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.newWallet(...args);\n }\n async recoverWalletInternal(...args) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.recoverWallet(...args);\n }\n async ensureWalletExists() {\n console.log(\"Ensuring wallet exists\");\n const existing = await this.config?.walletDb?.loadWallet() || null;\n if (existing && \"current\" in existing) {\n console.log(`Using existing wallet with ID ${existing.current}`);\n return;\n }\n const walletConfig = this.config.walletConfig;\n console.log(`Creating wallet with ID ${walletConfig?.id}`);\n if (walletConfig?.mnemonic) {\n await this.keymasterService.newWallet(walletConfig.mnemonic, true);\n }\n if (walletConfig?.id) {\n const did = await this.keymasterService.createId(walletConfig.id, {\n registry: walletConfig.registry\n });\n console.log(\"Did \", did);\n console.log(`Created wallet with ID ${walletConfig.id}`);\n }\n }\n async serviceRunning() {\n return this.serviceStarted || await this.startInternal();\n }\n validateConfig(config) {\n if (!config.gatekeeperConfig) {\n throw new Error(\"Missing Gatekeeper config\");\n }\n if (config.gatekeeperConfig) {\n if (!config.walletConfig) {\n throw new Error(\"Missing wallet config\");\n }\n if (!config.walletDb?.loadWallet) {\n throw new Error(\"Missing load wallet callback\");\n }\n if (!config.walletDb?.saveWallet) {\n throw new Error(\"Missing save wallet callback\");\n }\n }\n }\n};\n_Keymaster.instance = null;\nvar Keymaster = _Keymaster;\n\n// src/keymasterClient.ts\nimport KeymasterClient from \"@mdip/keymaster/client\";\nvar KeymasterExternalClient = class {\n constructor(config) {\n this.serviceStarted = false;\n this.validateConfig(config);\n this.config = config;\n }\n async start() {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Keymaster config\";\n }\n return this.serviceStarted;\n }\n async startExternal() {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Gatekeeper or Keymaster config\";\n }\n return this.serviceStarted;\n }\n async startExternalKeymaster() {\n console.log(`Starting external Keymaster service`);\n try {\n this.keymasterService = new KeymasterClient();\n await this.keymasterService.connect(this.config.keymasterConfig);\n } catch (e) {\n console.error(`Error starting Keymaster service:`, e);\n return false;\n }\n console.log(`Started external Keymaster service`);\n return true;\n }\n async createChallenge(spec, options) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const challenge = await this.keymasterService?.createChallenge(\n spec,\n options\n );\n return {\n challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`\n };\n }\n async bindCredential(schemaId, subjectId, options = {}) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n async issueCredential(credential, options = {}) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.issueCredential(credential, options);\n }\n async publishCredential(did, options = {}) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.publishCredential(did, options);\n }\n async acceptCredential(did) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.acceptCredential(did);\n }\n async showMnemonic() {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.decryptMnemonic();\n }\n async verifyResponse(did, options) {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const response = await this.keymasterService.verifyResponse(did, options);\n return response;\n }\n async serviceRunning() {\n return this.serviceStarted || await this.start();\n }\n validateConfig(config) {\n if (!config.keymasterConfig) {\n throw new Error(\"Missing Keymaster config\");\n }\n }\n};\n\n// src/index.ts\nexport * from \"@mdip/keymaster/types\";\nexport {\n Keymaster,\n KeymasterExternalClient\n};\n","import GatekeeperClient from \"@mdip/gatekeeper/client\";\nimport CipherNode from \"@mdip/cipher/node\";\nimport KeymasterLib from \"@mdip/keymaster\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n WalletConfig,\n} from \"./types/index.js\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n IssueCredentialsOptions,\n StoredWallet,\n VerifiableCredential,\n WalletBase,\n} from \"@mdip/keymaster/types\";\n\nexport interface KeymasterConfig {\n gatekeeperConfig?: SdkConfig;\n walletDb?: WalletBase;\n walletConfig?: WalletConfig;\n}\n\nexport class Keymaster {\n private static instance: Keymaster | null = null;\n\n private config: KeymasterConfig;\n private keymasterService!: KeymasterLib;\n private serviceStarted = false;\n\n private constructor(config: KeymasterConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n public static initialize(config: KeymasterConfig) {\n if (!Keymaster.instance) {\n Keymaster.instance = new Keymaster(config);\n console.log(\"✅ Keymaster initialized\");\n } else {\n console.warn(\n \"Keymaster already initialized, ignoring re-initialization.\"\n );\n }\n }\n\n private ensureInitialized() {\n if (!Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n }\n\n // Delegated STATIC methods\n\n public static async start() {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().startInternal();\n }\n\n public static async createChallenge(\n ...args: Parameters<Keymaster[\"createChallengeInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createChallengeInternal(...args);\n }\n\n public static async bindCredential(\n ...args: Parameters<Keymaster[\"bindCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().bindCredentialInternal(...args);\n }\n\n public static async issueCredential(\n ...args: Parameters<Keymaster[\"issueCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().issueCredentialInternal(...args);\n }\n\n public static async publishCredential(\n ...args: Parameters<Keymaster[\"publishCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().publishCredentialInternal(...args);\n }\n\n public static async acceptCredential(\n ...args: Parameters<Keymaster[\"acceptCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().acceptCredentialInternal(...args);\n }\n\n public static async showMnemonic(\n ...args: Parameters<Keymaster[\"showMnemonicInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().showMnemonicInternal(...args);\n }\n\n public static async verifyResponse(\n ...args: Parameters<Keymaster[\"verifyResponseInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().verifyResponseInternal(...args);\n }\n\n public static async decryptMessage(\n ...args: Parameters<Keymaster[\"decryptMessageInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().decryptMessageInternal(...args);\n }\n\n public static async decryptMnemonic(\n ...args: Parameters<Keymaster[\"decryptMnemonicInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().decryptMnemonicInternal(...args);\n }\n\n public static async getCredential(\n ...args: Parameters<Keymaster[\"getCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().getCredentialInternal(...args);\n }\n\n public static async removeCredential(\n ...args: Parameters<Keymaster[\"removeCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().removeCredentialInternal(...args);\n }\n\n public static async updateCredential(\n ...args: Parameters<Keymaster[\"updateCredentialInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().updateCredentialInternal(...args);\n }\n\n public static async createId(\n ...args: Parameters<Keymaster[\"createIdInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createIdInternal(...args);\n }\n\n public static async removeId(\n ...args: Parameters<Keymaster[\"removeIdInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().removeIdInternal(...args);\n }\n\n public static async resolveDID(\n ...args: Parameters<Keymaster[\"resolveDIDInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().resolveDIDInternal(...args);\n }\n\n public static async setCurrentId(\n ...args: Parameters<Keymaster[\"setCurrentIdInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().setCurrentIdInternal(...args);\n }\n\n public static async createSchema(\n ...args: Parameters<Keymaster[\"createSchemaInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createSchemaInternal(...args);\n }\n\n public static async newWallet(\n ...args: Parameters<Keymaster[\"newWalletInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().newWalletInternal(...args);\n }\n\n public static async recoverWallet(\n ...args: Parameters<Keymaster[\"recoverWalletInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().recoverWalletInternal(...args);\n }\n\n private static getInstance(): Keymaster {\n if (!Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n return Keymaster.instance;\n }\n\n // -------- Internal instance methods (originals renamed with Internal) -------\n\n private async ensureServiceIsRunning() {\n if (!(await this.serviceRunning())) {\n throw new Error(\"Keymaster service not running\");\n }\n }\n\n private async startInternal(): Promise<boolean> {\n if (this.config.gatekeeperConfig) {\n this.serviceStarted = await this.startIntegratedKeymaster();\n } else {\n throw \"Missing Gatekeeper config\";\n }\n return this.serviceStarted;\n }\n\n private async startIntegratedKeymaster(): Promise<boolean> {\n console.log(`Starting integrated Keymaster service`);\n\n try {\n if (this.config.walletDb) {\n const gatekeeper = new GatekeeperClient();\n await gatekeeper.connect(this.config.gatekeeperConfig);\n\n const cipher = new CipherNode();\n\n this.keymasterService = new KeymasterLib({\n gatekeeper,\n wallet: this.config.walletDb,\n cipher,\n });\n\n await this.ensureWalletExists();\n } else {\n return false;\n }\n } catch (e) {\n console.error(\"Error starting Keymaster service:\", e);\n return false;\n }\n\n console.log(`Started integrated Keymaster service`);\n return true;\n }\n\n private async createChallengeInternal(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n await this.ensureServiceIsRunning();\n const challenge: string = await this.keymasterService.createChallenge(\n spec,\n options\n );\n return {\n challenge: challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`,\n };\n }\n\n private async bindCredentialInternal(\n schemaId: string,\n subjectId: string,\n options: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n } = {}\n ): Promise<VerifiableCredential> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n\n private async issueCredentialInternal(\n credential: Partial<VerifiableCredential>,\n options: IssueCredentialsOptions = {}\n ): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.issueCredential(credential, options);\n }\n\n private async publishCredentialInternal(\n did: string,\n options: { reveal?: boolean } = {}\n ): Promise<VerifiableCredential> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.publishCredential(did, options);\n }\n\n private async acceptCredentialInternal(did: string): Promise<boolean> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.acceptCredential(did);\n }\n\n private async showMnemonicInternal(): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic();\n }\n\n private async verifyResponseInternal(\n did: string,\n options?: { retries?: number; delay?: number }\n ): Promise<ChallengeResponse> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.verifyResponse(did, options);\n }\n\n private async decryptMessageInternal(\n ...args: Parameters<KeymasterLib[\"decryptMessage\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMessage(...args);\n }\n\n private async decryptMnemonicInternal(\n ...args: Parameters<KeymasterLib[\"decryptMnemonic\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.decryptMnemonic(...args);\n }\n\n private async getCredentialInternal(\n ...args: Parameters<KeymasterLib[\"getCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.getCredential(...args);\n }\n\n private async removeCredentialInternal(\n ...args: Parameters<KeymasterLib[\"removeCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeCredential(...args);\n }\n\n private async updateCredentialInternal(\n ...args: Parameters<KeymasterLib[\"updateCredential\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.updateCredential(...args);\n }\n\n private async createIdInternal(\n ...args: Parameters<KeymasterLib[\"createId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createId(...args);\n }\n\n private async removeIdInternal(\n ...args: Parameters<KeymasterLib[\"removeId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.removeId(...args);\n }\n\n private async resolveDIDInternal(\n ...args: Parameters<KeymasterLib[\"resolveDID\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.resolveDID(...args);\n }\n\n private async setCurrentIdInternal(\n ...args: Parameters<KeymasterLib[\"setCurrentId\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.setCurrentId(...args);\n }\n\n private async createSchemaInternal(\n ...args: Parameters<KeymasterLib[\"createSchema\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createSchema(...args);\n }\n\n private async newWalletInternal(\n ...args: Parameters<KeymasterLib[\"newWallet\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.newWallet(...args);\n }\n\n private async recoverWalletInternal(\n ...args: Parameters<KeymasterLib[\"recoverWallet\"]>\n ) {\n await this.ensureServiceIsRunning();\n return this.keymasterService.recoverWallet(...args);\n }\n\n private async ensureWalletExists(): Promise<void> {\n console.log(\"Ensuring wallet exists\");\n const existing: StoredWallet | null =\n (await this.config?.walletDb?.loadWallet()) || null;\n if (existing && \"current\" in existing) {\n console.log(`Using existing wallet with ID ${existing.current}`);\n return;\n }\n\n const walletConfig = this.config.walletConfig;\n console.log(`Creating wallet with ID ${walletConfig?.id}`);\n if (walletConfig?.mnemonic) {\n await this.keymasterService.newWallet(walletConfig.mnemonic, true);\n }\n\n if (walletConfig?.id) {\n const did = await this.keymasterService.createId(walletConfig.id, {\n registry: walletConfig.registry,\n });\n console.log(\"Did \", did);\n console.log(`Created wallet with ID ${walletConfig.id}`);\n }\n }\n\n private async serviceRunning(): Promise<boolean> {\n return this.serviceStarted || (await this.startInternal());\n }\n\n private validateConfig(config: KeymasterConfig): void {\n if (!config.gatekeeperConfig) {\n throw new Error(\"Missing Gatekeeper config\");\n }\n\n if (config.gatekeeperConfig) {\n if (!config.walletConfig) {\n throw new Error(\"Missing wallet config\");\n }\n if (!config.walletDb?.loadWallet) {\n throw new Error(\"Missing load wallet callback\");\n }\n if (!config.walletDb?.saveWallet) {\n throw new Error(\"Missing save wallet callback\");\n }\n }\n }\n}\n","import KeymasterClient from \"@mdip/keymaster/client\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n IssueCredentialsOptions,\n VerifiableCredential,\n} from \"@mdip/keymaster/types\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n} from \"./types/index.js\";\n\nexport interface KeymasterConfig {\n keymasterConfig?: SdkConfig;\n}\n\nexport class KeymasterExternalClient {\n private config: KeymasterConfig;\n private keymasterService!: KeymasterClient;\n private serviceStarted = false;\n\n constructor(config: KeymasterConfig) {\n this.validateConfig(config);\n this.config = config;\n }\n\n public async start(): Promise<boolean> {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Keymaster config\";\n }\n return this.serviceStarted;\n }\n\n public async startExternal(): Promise<boolean> {\n if (this.config.keymasterConfig) {\n this.serviceStarted = await this.startExternalKeymaster();\n } else {\n throw \"Missing Gatekeeper or Keymaster config\";\n }\n return this.serviceStarted;\n }\n\n private async startExternalKeymaster(): Promise<boolean> {\n console.log(`Starting external Keymaster service`);\n try {\n this.keymasterService = new KeymasterClient();\n await this.keymasterService.connect(this.config.keymasterConfig);\n } catch (e) {\n console.error(`Error starting Keymaster service:`, e);\n return false;\n }\n\n console.log(`Started external Keymaster service`);\n return true;\n }\n\n async createChallenge(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const challenge: string = await this.keymasterService?.createChallenge(\n spec,\n options\n );\n return {\n challenge: challenge,\n challengeUrl: `${spec.callback}?challenge=${challenge}`,\n };\n }\n\n async bindCredential(\n schemaId: string,\n subjectId: string,\n options: {\n validFrom?: string;\n validUntil?: string;\n credential?: Record<string, unknown>;\n } = {}\n ): Promise<VerifiableCredential> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.bindCredential(schemaId, subjectId, options);\n }\n\n async issueCredential(\n credential: Partial<VerifiableCredential>,\n options: IssueCredentialsOptions = {}\n ): Promise<string> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.issueCredential(credential, options);\n }\n\n async publishCredential(\n did: string,\n options: { reveal?: boolean } = {}\n ): Promise<boolean> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.publishCredential(did, options);\n }\n\n async acceptCredential(did: string): Promise<boolean> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n\n return this.keymasterService.acceptCredential(did);\n }\n\n async showMnemonic(): Promise<string> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n return this.keymasterService.decryptMnemonic();\n }\n\n async verifyResponse(\n did: string,\n options?: {\n retries?: number;\n delay?: number;\n }\n ): Promise<ChallengeResponse> {\n if (!this.serviceRunning()) {\n throw new Error(\"Keymaster service not running\");\n }\n const response: ChallengeResponse =\n await this.keymasterService.verifyResponse(did, options);\n return response;\n }\n\n private async serviceRunning(): Promise<boolean> {\n return this.serviceStarted || (await this.start());\n }\n\n private validateConfig(config: KeymasterConfig): void {\n if (!config.keymasterConfig) {\n throw new Error(\"Missing Keymaster config\");\n }\n }\n}\n","export { Keymaster, KeymasterConfig } from \"./keymaster.js\";\n\nexport { KeymasterExternalClient } from \"./keymasterClient.js\";\n\nexport {\n SdkConfig,\n WalletConfig,\n CreateChallengeResponse,\n CreateChallengeSpec,\n} from \"./types/index.js\";\n\nexport * from \"@mdip/keymaster/types\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yourself_id/siwys-api-js",
|
|
3
|
-
"version": "0.10.1-SAPP-221-mdipUpdate.
|
|
3
|
+
"version": "0.10.1-SAPP-221-mdipUpdate.2+51382eb",
|
|
4
4
|
"description": "A React component library",
|
|
5
5
|
"repository": "https://github.com/selfidhq/siwys-js",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"module": "dist/index.js",
|
|
8
|
-
"types": "dist/index.d.ts",
|
|
9
6
|
"type": "module",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
10
16
|
"files": [
|
|
11
17
|
"dist"
|
|
12
18
|
],
|
|
@@ -35,5 +41,5 @@
|
|
|
35
41
|
"tsup": "^8.3.0",
|
|
36
42
|
"typescript": "4.9.4"
|
|
37
43
|
},
|
|
38
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "51382eb5a1a611f5b9dddbebe38acec94c36c0d3"
|
|
39
45
|
}
|