@yourself_id/siwys-api-js 0.10.1-SAPP-221-mdipUpdate.5 → 0.10.1-SAPP-221-mdipUpdate.8
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 +225 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +159 -24
- package/dist/index.d.ts +159 -24
- package/dist/index.js +227 -75
- package/dist/index.js.map +1 -1
- package/package.json +2 -7
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/index.ts
|
|
32
32
|
var src_exports = {};
|
|
33
33
|
__export(src_exports, {
|
|
34
|
+
GatekeeperTypes: () => GatekeeperTypes,
|
|
34
35
|
Keymaster: () => Keymaster,
|
|
35
36
|
KeymasterExternalClient: () => KeymasterExternalClient
|
|
36
37
|
});
|
|
@@ -49,6 +50,11 @@ var Keymaster = class _Keymaster {
|
|
|
49
50
|
this.validateConfig(config);
|
|
50
51
|
this.config = config;
|
|
51
52
|
}
|
|
53
|
+
// Initializes the instance if not already initialized
|
|
54
|
+
/**
|
|
55
|
+
* Initializes the Keymaster instance.
|
|
56
|
+
* @param config The configuration object for the Keymaster service.
|
|
57
|
+
*/
|
|
52
58
|
static initialize(config) {
|
|
53
59
|
if (!_Keymaster.instance) {
|
|
54
60
|
_Keymaster.instance = new _Keymaster(config);
|
|
@@ -59,6 +65,7 @@ var Keymaster = class _Keymaster {
|
|
|
59
65
|
);
|
|
60
66
|
}
|
|
61
67
|
}
|
|
68
|
+
// Ensures the instance is initialized
|
|
62
69
|
ensureInitialized() {
|
|
63
70
|
if (!_Keymaster.instance) {
|
|
64
71
|
throw new Error(
|
|
@@ -66,95 +73,242 @@ var Keymaster = class _Keymaster {
|
|
|
66
73
|
);
|
|
67
74
|
}
|
|
68
75
|
}
|
|
69
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Starts the Keymaster service.
|
|
78
|
+
* @returns A boolean indicating whether the service was started successfully.
|
|
79
|
+
*/
|
|
70
80
|
static async start() {
|
|
71
81
|
_Keymaster.getInstance().ensureInitialized();
|
|
72
82
|
return _Keymaster.getInstance().startInternal();
|
|
73
83
|
}
|
|
74
|
-
|
|
84
|
+
// Method to create a challenge
|
|
85
|
+
/**
|
|
86
|
+
* Creates a challenge for the user to solve.
|
|
87
|
+
* @param spec The challenge specifications.
|
|
88
|
+
* @param options Additional options for creating the challenge (optional).
|
|
89
|
+
* @returns A promise with the challenge response, including the challenge and its callback URL.
|
|
90
|
+
*/
|
|
91
|
+
static async createChallenge(spec, options) {
|
|
75
92
|
_Keymaster.getInstance().ensureInitialized();
|
|
76
|
-
return _Keymaster.getInstance().createChallengeInternal(
|
|
77
|
-
}
|
|
78
|
-
|
|
93
|
+
return _Keymaster.getInstance().createChallengeInternal(spec, options);
|
|
94
|
+
}
|
|
95
|
+
// Method to bind a credential to a user
|
|
96
|
+
/**
|
|
97
|
+
* Binds a credential to a subject.
|
|
98
|
+
* @param schemaId The schema ID for the credential.
|
|
99
|
+
* @param subjectId The subject's DID (Decentralized Identifier).
|
|
100
|
+
* @param options Optional options, such as validity period and credential data.
|
|
101
|
+
* @returns A promise with the verifiable credential that was bound.
|
|
102
|
+
*/
|
|
103
|
+
static async bindCredential(schemaId, subjectId, options) {
|
|
79
104
|
_Keymaster.getInstance().ensureInitialized();
|
|
80
|
-
return _Keymaster.getInstance().bindCredentialInternal(
|
|
105
|
+
return _Keymaster.getInstance().bindCredentialInternal(
|
|
106
|
+
schemaId,
|
|
107
|
+
subjectId,
|
|
108
|
+
options
|
|
109
|
+
);
|
|
81
110
|
}
|
|
82
|
-
|
|
111
|
+
// Method to create a response
|
|
112
|
+
/**
|
|
113
|
+
* Creates a response for the challenge.
|
|
114
|
+
* @param challengeDID The DID of the challenge to respond to.
|
|
115
|
+
* @param options Optional options for creating the response (optional).
|
|
116
|
+
* @returns A promise with the response string.
|
|
117
|
+
*/
|
|
118
|
+
static async createResponse(challengeDID, options) {
|
|
83
119
|
_Keymaster.getInstance().ensureInitialized();
|
|
84
|
-
return _Keymaster.getInstance().
|
|
120
|
+
return _Keymaster.getInstance().createResponseInternal(
|
|
121
|
+
challengeDID,
|
|
122
|
+
options
|
|
123
|
+
);
|
|
85
124
|
}
|
|
86
|
-
|
|
125
|
+
// Backup wallet
|
|
126
|
+
/**
|
|
127
|
+
* Backups the wallet data.
|
|
128
|
+
* @param registry Optional registry URL for the wallet backup.
|
|
129
|
+
* @returns A promise with a backup string (e.g., backup URL).
|
|
130
|
+
*/
|
|
131
|
+
static async backupWallet(registry) {
|
|
87
132
|
_Keymaster.getInstance().ensureInitialized();
|
|
88
|
-
return _Keymaster.getInstance().
|
|
89
|
-
}
|
|
90
|
-
|
|
133
|
+
return _Keymaster.getInstance().backupWalletInternal(registry);
|
|
134
|
+
}
|
|
135
|
+
// Issue credential to a user
|
|
136
|
+
/**
|
|
137
|
+
* Issues a credential to the subject.
|
|
138
|
+
* @param credential The credential to be issued.
|
|
139
|
+
* @param options Optional parameters for issuing the credential.
|
|
140
|
+
* @returns A promise with the credential ID or issuance result.
|
|
141
|
+
*/
|
|
142
|
+
static async issueCredential(credential, options) {
|
|
91
143
|
_Keymaster.getInstance().ensureInitialized();
|
|
92
|
-
return _Keymaster.getInstance().issueCredentialInternal(
|
|
93
|
-
}
|
|
94
|
-
|
|
144
|
+
return _Keymaster.getInstance().issueCredentialInternal(credential, options);
|
|
145
|
+
}
|
|
146
|
+
// Publish a credential
|
|
147
|
+
/**
|
|
148
|
+
* Publishes a verifiable credential.
|
|
149
|
+
* @param did The DID of the credential.
|
|
150
|
+
* @param options Optional parameters, such as whether to reveal the credential.
|
|
151
|
+
* @returns A promise with the published credential.
|
|
152
|
+
*/
|
|
153
|
+
static async publishCredential(did, options) {
|
|
95
154
|
_Keymaster.getInstance().ensureInitialized();
|
|
96
|
-
return _Keymaster.getInstance().publishCredentialInternal(
|
|
97
|
-
}
|
|
98
|
-
|
|
155
|
+
return _Keymaster.getInstance().publishCredentialInternal(did, options);
|
|
156
|
+
}
|
|
157
|
+
// Accept a credential
|
|
158
|
+
/**
|
|
159
|
+
* Accepts a credential.
|
|
160
|
+
* @param did The DID of the credential to accept.
|
|
161
|
+
* @returns A promise indicating whether the credential was successfully accepted.
|
|
162
|
+
*/
|
|
163
|
+
static async acceptCredential(did) {
|
|
99
164
|
_Keymaster.getInstance().ensureInitialized();
|
|
100
|
-
return _Keymaster.getInstance().acceptCredentialInternal(
|
|
101
|
-
}
|
|
102
|
-
|
|
165
|
+
return _Keymaster.getInstance().acceptCredentialInternal(did);
|
|
166
|
+
}
|
|
167
|
+
// Show mnemonic
|
|
168
|
+
/**
|
|
169
|
+
* Shows the mnemonic for the wallet.
|
|
170
|
+
* @returns A promise with the mnemonic string.
|
|
171
|
+
*/
|
|
172
|
+
static async showMnemonic() {
|
|
103
173
|
_Keymaster.getInstance().ensureInitialized();
|
|
104
|
-
return _Keymaster.getInstance().showMnemonicInternal(
|
|
105
|
-
}
|
|
106
|
-
|
|
174
|
+
return _Keymaster.getInstance().showMnemonicInternal();
|
|
175
|
+
}
|
|
176
|
+
// Verify a challenge response
|
|
177
|
+
/**
|
|
178
|
+
* Verifies a response to a challenge.
|
|
179
|
+
* @param did The DID to verify the response for.
|
|
180
|
+
* @param options Optional options, such as retry behavior.
|
|
181
|
+
* @returns A promise with the response verification result.
|
|
182
|
+
*/
|
|
183
|
+
static async verifyResponse(did, options) {
|
|
107
184
|
_Keymaster.getInstance().ensureInitialized();
|
|
108
|
-
return _Keymaster.getInstance().verifyResponseInternal(
|
|
109
|
-
}
|
|
110
|
-
|
|
185
|
+
return _Keymaster.getInstance().verifyResponseInternal(did, options);
|
|
186
|
+
}
|
|
187
|
+
// Decrypt a message
|
|
188
|
+
/**
|
|
189
|
+
* Decrypts a message using the current key.
|
|
190
|
+
* @param did The DID of the message to decrypt.
|
|
191
|
+
* @returns A promise with the decrypted message.
|
|
192
|
+
*/
|
|
193
|
+
static async decryptMessage(did) {
|
|
111
194
|
_Keymaster.getInstance().ensureInitialized();
|
|
112
|
-
return _Keymaster.getInstance().decryptMessageInternal(
|
|
113
|
-
}
|
|
114
|
-
|
|
195
|
+
return _Keymaster.getInstance().decryptMessageInternal(did);
|
|
196
|
+
}
|
|
197
|
+
// Decrypt mnemonic
|
|
198
|
+
/**
|
|
199
|
+
* Decrypts the mnemonic for the wallet.
|
|
200
|
+
* @returns A promise with the decrypted mnemonic.
|
|
201
|
+
*/
|
|
202
|
+
static async decryptMnemonic() {
|
|
115
203
|
_Keymaster.getInstance().ensureInitialized();
|
|
116
|
-
return _Keymaster.getInstance().decryptMnemonicInternal(
|
|
117
|
-
}
|
|
118
|
-
|
|
204
|
+
return _Keymaster.getInstance().decryptMnemonicInternal();
|
|
205
|
+
}
|
|
206
|
+
// Get a credential
|
|
207
|
+
/**
|
|
208
|
+
* Retrieves a verifiable credential.
|
|
209
|
+
* @param id The credential ID to retrieve.
|
|
210
|
+
* @returns A promise with the credential data or null if not found.
|
|
211
|
+
*/
|
|
212
|
+
static async getCredential(id) {
|
|
119
213
|
_Keymaster.getInstance().ensureInitialized();
|
|
120
|
-
return _Keymaster.getInstance().getCredentialInternal(
|
|
121
|
-
}
|
|
122
|
-
|
|
214
|
+
return _Keymaster.getInstance().getCredentialInternal(id);
|
|
215
|
+
}
|
|
216
|
+
// Remove a credential
|
|
217
|
+
/**
|
|
218
|
+
* Removes a verifiable credential.
|
|
219
|
+
* @param id The credential ID to remove.
|
|
220
|
+
* @returns A promise indicating success or failure of the operation.
|
|
221
|
+
*/
|
|
222
|
+
static async removeCredential(id) {
|
|
123
223
|
_Keymaster.getInstance().ensureInitialized();
|
|
124
|
-
return _Keymaster.getInstance().removeCredentialInternal(
|
|
125
|
-
}
|
|
126
|
-
|
|
224
|
+
return _Keymaster.getInstance().removeCredentialInternal(id);
|
|
225
|
+
}
|
|
226
|
+
// Update a credential
|
|
227
|
+
/**
|
|
228
|
+
* Updates a verifiable credential.
|
|
229
|
+
* @param did The DID of the credential to update.
|
|
230
|
+
* @param credential The new credential data.
|
|
231
|
+
* @returns A promise indicating success or failure of the update operation.
|
|
232
|
+
*/
|
|
233
|
+
static async updateCredential(did, credential) {
|
|
127
234
|
_Keymaster.getInstance().ensureInitialized();
|
|
128
|
-
return _Keymaster.getInstance().updateCredentialInternal(
|
|
129
|
-
}
|
|
130
|
-
|
|
235
|
+
return _Keymaster.getInstance().updateCredentialInternal(did, credential);
|
|
236
|
+
}
|
|
237
|
+
// Method to create an ID
|
|
238
|
+
/**
|
|
239
|
+
* Creates a new DID (Decentralized Identifier).
|
|
240
|
+
* @param name The name for the DID.
|
|
241
|
+
* @param options Optional options, such as registry URL.
|
|
242
|
+
* @returns A promise with the newly created DID.
|
|
243
|
+
*/
|
|
244
|
+
static async createId(name, options) {
|
|
131
245
|
_Keymaster.getInstance().ensureInitialized();
|
|
132
|
-
return _Keymaster.getInstance().createIdInternal(
|
|
133
|
-
}
|
|
134
|
-
|
|
246
|
+
return _Keymaster.getInstance().createIdInternal(name, options);
|
|
247
|
+
}
|
|
248
|
+
// Remove an ID
|
|
249
|
+
/**
|
|
250
|
+
* Removes an existing DID.
|
|
251
|
+
* @param name The name of the DID to remove.
|
|
252
|
+
* @returns A promise indicating success or failure of the operation.
|
|
253
|
+
*/
|
|
254
|
+
static async removeId(name) {
|
|
135
255
|
_Keymaster.getInstance().ensureInitialized();
|
|
136
|
-
return _Keymaster.getInstance().removeIdInternal(
|
|
137
|
-
}
|
|
138
|
-
|
|
256
|
+
return _Keymaster.getInstance().removeIdInternal(name);
|
|
257
|
+
}
|
|
258
|
+
// Resolve a DID
|
|
259
|
+
/**
|
|
260
|
+
* Resolves a DID to fetch associated data.
|
|
261
|
+
* @param did The DID to resolve.
|
|
262
|
+
* @param options Optional parameters for resolving the DID.
|
|
263
|
+
* @returns A promise with the resolved DID data.
|
|
264
|
+
*/
|
|
265
|
+
static async resolveDID(did, options) {
|
|
139
266
|
_Keymaster.getInstance().ensureInitialized();
|
|
140
|
-
return _Keymaster.getInstance().resolveDIDInternal(
|
|
141
|
-
}
|
|
142
|
-
|
|
267
|
+
return _Keymaster.getInstance().resolveDIDInternal(did, options);
|
|
268
|
+
}
|
|
269
|
+
// Set the current DID
|
|
270
|
+
/**
|
|
271
|
+
* Sets the current DID in use.
|
|
272
|
+
* @param name The DID name to set as the current one.
|
|
273
|
+
* @returns A promise indicating success or failure of the operation.
|
|
274
|
+
*/
|
|
275
|
+
static async setCurrentId(name) {
|
|
143
276
|
_Keymaster.getInstance().ensureInitialized();
|
|
144
|
-
return _Keymaster.getInstance().setCurrentIdInternal(
|
|
145
|
-
}
|
|
146
|
-
|
|
277
|
+
return _Keymaster.getInstance().setCurrentIdInternal(name);
|
|
278
|
+
}
|
|
279
|
+
// Create a schema
|
|
280
|
+
/**
|
|
281
|
+
* Creates a new schema for credentials.
|
|
282
|
+
* @param schema The schema data to create.
|
|
283
|
+
* @param options Optional options for creating the schema.
|
|
284
|
+
* @returns A promise with the created schema data.
|
|
285
|
+
*/
|
|
286
|
+
static async createSchema(schema, options) {
|
|
147
287
|
_Keymaster.getInstance().ensureInitialized();
|
|
148
|
-
return _Keymaster.getInstance().createSchemaInternal(
|
|
149
|
-
}
|
|
150
|
-
|
|
288
|
+
return _Keymaster.getInstance().createSchemaInternal(schema, options);
|
|
289
|
+
}
|
|
290
|
+
// Create a new wallet
|
|
291
|
+
/**
|
|
292
|
+
* Creates a new wallet.
|
|
293
|
+
* @param mnemonic Optional mnemonic to initialize the wallet.
|
|
294
|
+
* @param overwrite Optional flag to overwrite the existing wallet.
|
|
295
|
+
* @returns A promise with the wallet creation result.
|
|
296
|
+
*/
|
|
297
|
+
static async newWallet(mnemonic, overwrite) {
|
|
151
298
|
_Keymaster.getInstance().ensureInitialized();
|
|
152
|
-
return _Keymaster.getInstance().newWalletInternal(
|
|
153
|
-
}
|
|
154
|
-
|
|
299
|
+
return _Keymaster.getInstance().newWalletInternal(mnemonic, overwrite);
|
|
300
|
+
}
|
|
301
|
+
// Recover an existing wallet
|
|
302
|
+
/**
|
|
303
|
+
* Recovers a wallet from a backup.
|
|
304
|
+
* @param did The DID to use for recovery (optional).
|
|
305
|
+
* @returns A promise with the wallet recovery result.
|
|
306
|
+
*/
|
|
307
|
+
static async recoverWallet(did) {
|
|
155
308
|
_Keymaster.getInstance().ensureInitialized();
|
|
156
|
-
return _Keymaster.getInstance().recoverWalletInternal(
|
|
309
|
+
return _Keymaster.getInstance().recoverWalletInternal(did);
|
|
157
310
|
}
|
|
311
|
+
// Helper method to retrieve the instance
|
|
158
312
|
static getInstance() {
|
|
159
313
|
if (!_Keymaster.instance) {
|
|
160
314
|
throw new Error(
|
|
@@ -178,11 +332,14 @@ var Keymaster = class _Keymaster {
|
|
|
178
332
|
return this.serviceStarted;
|
|
179
333
|
}
|
|
180
334
|
async startIntegratedKeymaster() {
|
|
181
|
-
console.log(`Starting integrated Keymaster service`);
|
|
182
335
|
try {
|
|
183
336
|
if (this.config.walletDb) {
|
|
184
|
-
const gatekeeper =
|
|
185
|
-
|
|
337
|
+
const gatekeeper = await import_client.default.create({
|
|
338
|
+
url: this.config.gatekeeperConfig?.url,
|
|
339
|
+
waitUntilReady: this.config.gatekeeperConfig?.waitUntilReady,
|
|
340
|
+
intervalSeconds: this.config.gatekeeperConfig?.intervalSeconds,
|
|
341
|
+
chatty: this.config.gatekeeperConfig?.chatty
|
|
342
|
+
});
|
|
186
343
|
const cipher = new import_node.default();
|
|
187
344
|
this.keymasterService = new import_keymaster.default({
|
|
188
345
|
gatekeeper,
|
|
@@ -197,7 +354,7 @@ var Keymaster = class _Keymaster {
|
|
|
197
354
|
console.error("Error starting Keymaster service:", e);
|
|
198
355
|
return false;
|
|
199
356
|
}
|
|
200
|
-
console.log(
|
|
357
|
+
console.log("\u2705 Keymaster Started");
|
|
201
358
|
return true;
|
|
202
359
|
}
|
|
203
360
|
async createChallengeInternal(spec, options) {
|
|
@@ -292,23 +449,19 @@ var Keymaster = class _Keymaster {
|
|
|
292
449
|
return this.keymasterService.recoverWallet(...args);
|
|
293
450
|
}
|
|
294
451
|
async ensureWalletExists() {
|
|
295
|
-
console.log("Ensuring wallet exists");
|
|
296
452
|
const existing = await this.config?.walletDb?.loadWallet() || null;
|
|
297
453
|
if (existing && "current" in existing) {
|
|
298
454
|
console.log(`Using existing wallet with ID ${existing.current}`);
|
|
299
455
|
return;
|
|
300
456
|
}
|
|
301
457
|
const walletConfig = this.config.walletConfig;
|
|
302
|
-
console.log(`Creating wallet with ID ${walletConfig?.id}`);
|
|
303
458
|
if (walletConfig?.mnemonic) {
|
|
304
459
|
await this.keymasterService.newWallet(walletConfig.mnemonic, true);
|
|
305
460
|
}
|
|
306
461
|
if (walletConfig?.id) {
|
|
307
|
-
|
|
462
|
+
await this.keymasterService.createId(walletConfig.id, {
|
|
308
463
|
registry: walletConfig.registry
|
|
309
464
|
});
|
|
310
|
-
console.log("Did ", did);
|
|
311
|
-
console.log(`Created wallet with ID ${walletConfig.id}`);
|
|
312
465
|
}
|
|
313
466
|
}
|
|
314
467
|
async serviceRunning() {
|
|
@@ -359,7 +512,6 @@ var KeymasterExternalClient = class {
|
|
|
359
512
|
return this.serviceStarted;
|
|
360
513
|
}
|
|
361
514
|
async startExternalKeymaster() {
|
|
362
|
-
console.log(`Starting external Keymaster service`);
|
|
363
515
|
try {
|
|
364
516
|
this.keymasterService = new import_client2.default();
|
|
365
517
|
await this.keymasterService.connect(this.config.keymasterConfig);
|
|
@@ -367,7 +519,6 @@ var KeymasterExternalClient = class {
|
|
|
367
519
|
console.error(`Error starting Keymaster service:`, e);
|
|
368
520
|
return false;
|
|
369
521
|
}
|
|
370
|
-
console.log(`Started external Keymaster service`);
|
|
371
522
|
return true;
|
|
372
523
|
}
|
|
373
524
|
async createChallenge(spec, options) {
|
|
@@ -432,8 +583,10 @@ var KeymasterExternalClient = class {
|
|
|
432
583
|
|
|
433
584
|
// src/index.ts
|
|
434
585
|
__reExport(src_exports, require("@mdip/keymaster/types"), module.exports);
|
|
586
|
+
var GatekeeperTypes = __toESM(require("@mdip/gatekeeper/types"), 1);
|
|
435
587
|
// Annotate the CommonJS export names for ESM import in node:
|
|
436
588
|
0 && (module.exports = {
|
|
589
|
+
GatekeeperTypes,
|
|
437
590
|
Keymaster,
|
|
438
591
|
KeymasterExternalClient,
|
|
439
592
|
...require("@mdip/keymaster/types")
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/keymaster.ts","../src/keymasterClient.ts"],"sourcesContent":["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 CreateResponseOptions,\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 backupWallet(\n ...args: Parameters<Keymaster[\"backupWalletInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().backupWalletInternal(...args);\n }\n\n public static async createResponse(\n ...args: Parameters<Keymaster[\"createResponseInternal\"]>\n ) {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createResponseInternal(...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 createResponseInternal(\n challengeDID: string,\n options?: CreateResponseOptions\n ): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createResponse(challengeDID, options);\n }\n\n private async backupWalletInternal(registry?: string): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.backupWallet(registry);\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;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B;AAAA,EAC/C;AAAA,EAEA,MAAM,eACJ,KACA,SAI4B;AAC5B,QAAI,CAAC,KAAK,eAAe,GAAG;AAC1B,YAAM,IAAI,MAAM,+BAA+B;AAAA,IACjD;AACA,UAAM,WACJ,MAAM,KAAK,iBAAiB,eAAe,KAAK,OAAO;AACzD,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,iBAAmC;AAC/C,WAAO,KAAK,kBAAmB,MAAM,KAAK,MAAM;AAAA,EAClD;AAAA,EAEQ,eAAe,QAA+B;AACpD,QAAI,CAAC,OAAO,iBAAiB;AAC3B,YAAM,IAAI,MAAM,0BAA0B;AAAA,IAC5C;AAAA,EACF;AACF;;;AF9IA,wBAAc,kCAXd;","names":["GatekeeperClient","CipherNode","KeymasterLib","import_client","KeymasterClient"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/keymaster.ts","../src/keymasterClient.ts"],"sourcesContent":["export { Keymaster, KeymasterConfig } from \"./keymaster.js\";\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\";\nimport * as GatekeeperTypes from \"@mdip/gatekeeper/types\";\n\nexport { GatekeeperTypes };\n","// Imports\nimport { default as GatekeeperClient } from \"@mdip/gatekeeper/client\";\nimport { default as CipherNode } from \"@mdip/cipher/node\";\nimport { default as KeymasterLib } from \"@mdip/keymaster\";\nimport {\n CreateChallengeResponse,\n CreateChallengeSpec,\n SdkConfig,\n WalletConfig,\n} from \"./types/index.js\";\nimport {\n ChallengeResponse,\n CreateAssetOptions,\n CreateResponseOptions,\n IssueCredentialsOptions,\n StoredWallet,\n VerifiableCredential,\n WalletBase,\n WalletFile,\n} from \"@mdip/keymaster/types\";\nimport { MdipDocument, ResolveDIDOptions } from \"@mdip/gatekeeper/types\";\n\n// Keymaster configuration interface\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 // Initializes the instance if not already initialized\n /**\n * Initializes the Keymaster instance.\n * @param config The configuration object for the Keymaster service.\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 // Ensures the instance is initialized\n private ensureInitialized() {\n if (!Keymaster.instance) {\n throw new Error(\n \"Keymaster not initialized. Call Keymaster.initialize() first.\"\n );\n }\n }\n\n /**\n * Starts the Keymaster service.\n * @returns A boolean indicating whether the service was started successfully.\n */\n public static async start() {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().startInternal();\n }\n\n // Method to create a challenge\n /**\n * Creates a challenge for the user to solve.\n * @param spec The challenge specifications.\n * @param options Additional options for creating the challenge (optional).\n * @returns A promise with the challenge response, including the challenge and its callback URL.\n */\n public static async createChallenge(\n spec: CreateChallengeSpec,\n options?: CreateAssetOptions\n ): Promise<CreateChallengeResponse> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createChallengeInternal(spec, options);\n }\n\n // Method to bind a credential to a user\n /**\n * Binds a credential to a subject.\n * @param schemaId The schema ID for the credential.\n * @param subjectId The subject's DID (Decentralized Identifier).\n * @param options Optional options, such as validity period and credential data.\n * @returns A promise with the verifiable credential that was bound.\n */\n public static 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 Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().bindCredentialInternal(\n schemaId,\n subjectId,\n options\n );\n }\n\n // Method to create a response\n /**\n * Creates a response for the challenge.\n * @param challengeDID The DID of the challenge to respond to.\n * @param options Optional options for creating the response (optional).\n * @returns A promise with the response string.\n */\n public static async createResponse(\n challengeDID: string,\n options?: CreateResponseOptions\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createResponseInternal(\n challengeDID,\n options\n );\n }\n\n // Backup wallet\n /**\n * Backups the wallet data.\n * @param registry Optional registry URL for the wallet backup.\n * @returns A promise with a backup string (e.g., backup URL).\n */\n public static async backupWallet(registry?: string): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().backupWalletInternal(registry);\n }\n\n // Issue credential to a user\n /**\n * Issues a credential to the subject.\n * @param credential The credential to be issued.\n * @param options Optional parameters for issuing the credential.\n * @returns A promise with the credential ID or issuance result.\n */\n public static async issueCredential(\n credential: Partial<VerifiableCredential>,\n options?: IssueCredentialsOptions\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().issueCredentialInternal(credential, options);\n }\n\n // Publish a credential\n /**\n * Publishes a verifiable credential.\n * @param did The DID of the credential.\n * @param options Optional parameters, such as whether to reveal the credential.\n * @returns A promise with the published credential.\n */\n public static async publishCredential(\n did: string,\n options?: {\n reveal?: boolean;\n }\n ): Promise<VerifiableCredential> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().publishCredentialInternal(did, options);\n }\n\n // Accept a credential\n /**\n * Accepts a credential.\n * @param did The DID of the credential to accept.\n * @returns A promise indicating whether the credential was successfully accepted.\n */\n public static async acceptCredential(did: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().acceptCredentialInternal(did);\n }\n\n // Show mnemonic\n /**\n * Shows the mnemonic for the wallet.\n * @returns A promise with the mnemonic string.\n */\n public static async showMnemonic(): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().showMnemonicInternal();\n }\n\n // Verify a challenge response\n /**\n * Verifies a response to a challenge.\n * @param did The DID to verify the response for.\n * @param options Optional options, such as retry behavior.\n * @returns A promise with the response verification result.\n */\n public static async verifyResponse(\n did: string,\n options?: { retries?: number; delay?: number }\n ): Promise<ChallengeResponse> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().verifyResponseInternal(did, options);\n }\n\n // Decrypt a message\n /**\n * Decrypts a message using the current key.\n * @param did The DID of the message to decrypt.\n * @returns A promise with the decrypted message.\n */\n public static async decryptMessage(did: string): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().decryptMessageInternal(did);\n }\n\n // Decrypt mnemonic\n /**\n * Decrypts the mnemonic for the wallet.\n * @returns A promise with the decrypted mnemonic.\n */\n public static async decryptMnemonic(): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().decryptMnemonicInternal();\n }\n\n // Get a credential\n /**\n * Retrieves a verifiable credential.\n * @param id The credential ID to retrieve.\n * @returns A promise with the credential data or null if not found.\n */\n public static async getCredential(\n id: string\n ): Promise<VerifiableCredential | null> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().getCredentialInternal(id);\n }\n\n // Remove a credential\n /**\n * Removes a verifiable credential.\n * @param id The credential ID to remove.\n * @returns A promise indicating success or failure of the operation.\n */\n public static async removeCredential(id: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().removeCredentialInternal(id);\n }\n\n // Update a credential\n /**\n * Updates a verifiable credential.\n * @param did The DID of the credential to update.\n * @param credential The new credential data.\n * @returns A promise indicating success or failure of the update operation.\n */\n public static async updateCredential(\n did: string,\n credential: VerifiableCredential\n ): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().updateCredentialInternal(did, credential);\n }\n\n // Method to create an ID\n /**\n * Creates a new DID (Decentralized Identifier).\n * @param name The name for the DID.\n * @param options Optional options, such as registry URL.\n * @returns A promise with the newly created DID.\n */\n public static async createId(\n name: string,\n options?: {\n registry?: string;\n }\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createIdInternal(name, options);\n }\n\n // Remove an ID\n /**\n * Removes an existing DID.\n * @param name The name of the DID to remove.\n * @returns A promise indicating success or failure of the operation.\n */\n public static async removeId(name: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().removeIdInternal(name);\n }\n\n // Resolve a DID\n /**\n * Resolves a DID to fetch associated data.\n * @param did The DID to resolve.\n * @param options Optional parameters for resolving the DID.\n * @returns A promise with the resolved DID data.\n */\n public static async resolveDID(\n did: string,\n options?: ResolveDIDOptions\n ): Promise<MdipDocument> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().resolveDIDInternal(did, options);\n }\n\n // Set the current DID\n /**\n * Sets the current DID in use.\n * @param name The DID name to set as the current one.\n * @returns A promise indicating success or failure of the operation.\n */\n public static async setCurrentId(name: string): Promise<boolean> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().setCurrentIdInternal(name);\n }\n\n // Create a schema\n /**\n * Creates a new schema for credentials.\n * @param schema The schema data to create.\n * @param options Optional options for creating the schema.\n * @returns A promise with the created schema data.\n */\n public static async createSchema(\n schema?: unknown,\n options?: CreateAssetOptions\n ): Promise<string> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().createSchemaInternal(schema, options);\n }\n\n // Create a new wallet\n /**\n * Creates a new wallet.\n * @param mnemonic Optional mnemonic to initialize the wallet.\n * @param overwrite Optional flag to overwrite the existing wallet.\n * @returns A promise with the wallet creation result.\n */\n public static async newWallet(\n mnemonic?: string,\n overwrite?: boolean\n ): Promise<WalletFile> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().newWalletInternal(mnemonic, overwrite);\n }\n\n // Recover an existing wallet\n /**\n * Recovers a wallet from a backup.\n * @param did The DID to use for recovery (optional).\n * @returns A promise with the wallet recovery result.\n */\n public static async recoverWallet(did?: string): Promise<WalletFile> {\n Keymaster.getInstance().ensureInitialized();\n return Keymaster.getInstance().recoverWalletInternal(did);\n }\n\n // Helper method to retrieve the instance\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 try {\n if (this.config.walletDb) {\n const gatekeeper = await GatekeeperClient.create({\n url: this.config.gatekeeperConfig?.url,\n waitUntilReady: this.config.gatekeeperConfig?.waitUntilReady,\n intervalSeconds: this.config.gatekeeperConfig?.intervalSeconds,\n chatty: this.config.gatekeeperConfig?.chatty,\n });\n\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\n console.log(\"✅ Keymaster Started\");\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 createResponseInternal(\n challengeDID: string,\n options?: CreateResponseOptions\n ): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.createResponse(challengeDID, options);\n }\n\n private async backupWalletInternal(registry?: string): Promise<string> {\n await this.ensureServiceIsRunning();\n return this.keymasterService.backupWallet(registry);\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 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 if (walletConfig?.mnemonic) {\n await this.keymasterService.newWallet(walletConfig.mnemonic, true);\n }\n\n if (walletConfig?.id) {\n await this.keymasterService.createId(walletConfig.id, {\n registry: walletConfig.registry,\n });\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 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 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,oBAA4C;AAC5C,kBAAsC;AACtC,uBAAwC;AA0BjC,IAAM,YAAN,MAAM,WAAU;AAAA,EACrB,OAAe,WAA6B;AAAA,EAEpC;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EAEjB,YAAY,QAAyB;AAC3C,SAAK,eAAe,MAAM;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