@docknetwork/wallet-sdk-core 1.5.14 → 1.7.6
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/.claude/settings.local.json +12 -0
- package/generate-docs.js +33 -0
- package/jsdoc.conf.json +28 -0
- package/lib/biometric-provider.d.ts +124 -32
- package/lib/biometric-provider.d.ts.map +1 -1
- package/lib/biometric-provider.js +146 -7
- package/lib/biometric-provider.js.map +1 -1
- package/lib/cloud-wallet.d.ts +8 -6
- package/lib/cloud-wallet.d.ts.map +1 -1
- package/lib/cloud-wallet.js +41 -57
- package/lib/cloud-wallet.js.map +1 -1
- package/lib/credential-provider.d.ts +58 -33
- package/lib/credential-provider.d.ts.map +1 -1
- package/lib/credential-provider.js +212 -11
- package/lib/credential-provider.js.map +1 -1
- package/lib/credentials/oidvc.js +4 -5
- package/lib/credentials/oidvc.js.map +1 -1
- package/lib/did-provider.d.ts +102 -36
- package/lib/did-provider.d.ts.map +1 -1
- package/lib/did-provider.js +185 -27
- package/lib/did-provider.js.map +1 -1
- package/lib/ecosystem-tools.js +4 -5
- package/lib/ecosystem-tools.js.map +1 -1
- package/lib/helpers.js +6 -6
- package/lib/helpers.js.map +1 -1
- package/lib/message-provider.d.ts +39 -13
- package/lib/message-provider.d.ts.map +1 -1
- package/lib/message-provider.js +173 -22
- package/lib/message-provider.js.map +1 -1
- package/lib/messages/message-helpers.js +6 -6
- package/lib/messages/message-helpers.js.map +1 -1
- package/lib/network-resolver.js +5 -5
- package/lib/network-resolver.js.map +1 -1
- package/lib/qr-handlers/builtin/index.d.ts +30 -0
- package/lib/qr-handlers/builtin/index.d.ts.map +1 -0
- package/lib/qr-handlers/builtin/index.js +46 -0
- package/lib/qr-handlers/builtin/index.js.map +1 -0
- package/lib/qr-handlers/builtin/oid4vc-handler.d.ts +137 -0
- package/lib/qr-handlers/builtin/oid4vc-handler.d.ts.map +1 -0
- package/lib/qr-handlers/builtin/oid4vc-handler.js +134 -0
- package/lib/qr-handlers/builtin/oid4vc-handler.js.map +1 -0
- package/lib/qr-handlers/index.d.ts +76 -0
- package/lib/qr-handlers/index.d.ts.map +1 -0
- package/lib/qr-handlers/index.js +92 -0
- package/lib/qr-handlers/index.js.map +1 -0
- package/lib/qr-handlers/processor.d.ts +110 -0
- package/lib/qr-handlers/processor.d.ts.map +1 -0
- package/lib/qr-handlers/processor.js +251 -0
- package/lib/qr-handlers/processor.js.map +1 -0
- package/lib/qr-handlers/types.d.ts +205 -0
- package/lib/qr-handlers/types.d.ts.map +1 -0
- package/lib/qr-handlers/types.js +10 -0
- package/lib/qr-handlers/types.js.map +1 -0
- package/lib/types.d.ts +613 -13
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +16 -0
- package/lib/types.js.map +1 -1
- package/lib/verification-controller.d.ts +3 -4
- package/lib/verification-controller.d.ts.map +1 -1
- package/lib/verification-controller.js +10 -3
- package/lib/verification-controller.js.map +1 -1
- package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.d.ts +0 -1
- package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.d.ts.map +1 -1
- package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.js +2 -2
- package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.js.map +1 -1
- package/lib/wallet-wasm.d.ts +2 -2
- package/lib/wallet-wasm.d.ts.map +1 -1
- package/lib/wallet-wasm.js +15 -17
- package/lib/wallet-wasm.js.map +1 -1
- package/lib/wallet.d.ts +36 -20
- package/lib/wallet.d.ts.map +1 -1
- package/lib/wallet.js +172 -26
- package/lib/wallet.js.map +1 -1
- package/package.json +19 -11
- package/src/biometric-provider.ts +157 -42
- package/src/cloud-wallet.ts +21 -60
- package/src/credential-provider.test.ts +191 -1
- package/src/credential-provider.ts +208 -27
- package/src/did-provider.ts +183 -34
- package/src/message-provider.ts +177 -38
- package/src/qr-handlers/builtin/index.ts +30 -0
- package/src/qr-handlers/builtin/oid4vc-handler.ts +198 -0
- package/src/qr-handlers/index.ts +76 -0
- package/src/qr-handlers/processor.test.ts +514 -0
- package/src/qr-handlers/processor.ts +311 -0
- package/src/qr-handlers/types.ts +228 -0
- package/src/types.ts +671 -11
- package/src/verification-controller.test.ts +1 -2
- package/src/verification-controller.ts +14 -2
- package/src/wallet-wasm.ts +5 -8
- package/src/wallet.ts +173 -24
- package/tsconfig.build.tsbuildinfo +1 -1
package/lib/message-provider.js
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module message-provider
|
|
4
|
+
* @description DIDComm message management functionality for the Truvera Wallet SDK.
|
|
5
|
+
* This module provides functions for sending, receiving, and processing DIDComm messages.
|
|
6
|
+
*/
|
|
2
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createMessageProvider =
|
|
8
|
+
exports.createMessageProvider = createMessageProvider;
|
|
4
9
|
const logger_1 = require("@docknetwork/wallet-sdk-data-store/lib/logger");
|
|
5
10
|
const helpers_1 = require("./helpers");
|
|
6
11
|
const relay_service_1 = require("@docknetwork/wallet-sdk-wasm/lib/services/relay-service");
|
|
7
12
|
const FETCH_MESSAGE_LIMIT = 10;
|
|
13
|
+
/**
|
|
14
|
+
* Internal function to retrieve key pair documents for a DID
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
8
17
|
async function getKeyPairDocs(didProvider, did) {
|
|
9
18
|
try {
|
|
10
19
|
const keyPairDocs = await didProvider.getDIDKeyPairs();
|
|
@@ -17,6 +26,37 @@ async function getKeyPairDocs(didProvider, did) {
|
|
|
17
26
|
throw new Error(`Failed to get key pair docs: ${error.message}`);
|
|
18
27
|
}
|
|
19
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Creates a message provider instance bound to a wallet and DID provider
|
|
31
|
+
* @param {Object} params - Provider configuration
|
|
32
|
+
* @param {IWallet} params.wallet - The wallet instance to use for message storage
|
|
33
|
+
* @param {IDIDProvider} params.didProvider - The DID provider instance to use for key management
|
|
34
|
+
* @param {any} [params.relayService] - Optional relay service implementation (defaults to built-in service)
|
|
35
|
+
* @returns {IMessageProvider} A message provider instance with all DIDComm message management methods
|
|
36
|
+
* @see {@link IMessageProvider} - The interface defining all available message provider methods
|
|
37
|
+
* @example
|
|
38
|
+
* import { createMessageProvider } from '@docknetwork/wallet-sdk-core';
|
|
39
|
+
*
|
|
40
|
+
* const messageProvider = createMessageProvider({
|
|
41
|
+
* wallet,
|
|
42
|
+
* didProvider
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* // Send a message
|
|
46
|
+
* await messageProvider.sendMessage({
|
|
47
|
+
* did: 'did:key:sender123',
|
|
48
|
+
* recipientDid: 'did:key:recipient456',
|
|
49
|
+
* message: { hello: 'world' }
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* // Start auto-fetching messages
|
|
53
|
+
* const stopAutoFetch = messageProvider.startAutoFetch(5000);
|
|
54
|
+
*
|
|
55
|
+
* // Add message listener
|
|
56
|
+
* const removeListener = messageProvider.addMessageListener((message) => {
|
|
57
|
+
* console.log('Received message:', message);
|
|
58
|
+
* });
|
|
59
|
+
*/
|
|
20
60
|
function createMessageProvider({ wallet, didProvider, relayService = relay_service_1.relayService, }) {
|
|
21
61
|
async function markMessageAsRead(messageId) {
|
|
22
62
|
try {
|
|
@@ -156,38 +196,67 @@ function createMessageProvider({ wallet, didProvider, relayService = relay_servi
|
|
|
156
196
|
return () => wallet.eventManager.removeListener('didcomm-message-decrypted', listener);
|
|
157
197
|
}
|
|
158
198
|
let listenerIntervalId = null;
|
|
199
|
+
let processMessageTimeoutId = null;
|
|
200
|
+
let stopped = false;
|
|
159
201
|
const processMessageInterval = 3000;
|
|
160
202
|
async function processMessageRecurrentJob() {
|
|
161
203
|
try {
|
|
162
204
|
await processDIDCommMessages();
|
|
163
205
|
}
|
|
164
206
|
finally {
|
|
165
|
-
|
|
207
|
+
if (!stopped) {
|
|
208
|
+
processMessageTimeoutId = setTimeout(processMessageRecurrentJob, processMessageInterval);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function stop() {
|
|
213
|
+
stopped = true;
|
|
214
|
+
if (listenerIntervalId) {
|
|
215
|
+
clearInterval(listenerIntervalId);
|
|
216
|
+
listenerIntervalId = null;
|
|
217
|
+
}
|
|
218
|
+
if (processMessageTimeoutId) {
|
|
219
|
+
clearTimeout(processMessageTimeoutId);
|
|
220
|
+
processMessageTimeoutId = null;
|
|
166
221
|
}
|
|
167
222
|
}
|
|
168
223
|
return {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
224
|
+
/**
|
|
225
|
+
* Sends a DIDComm message to a recipient
|
|
226
|
+
* @memberof IMessageProvider
|
|
227
|
+
* @param {Object} params - Message parameters
|
|
228
|
+
* @param {string} [params.from] - Sender DID identifier
|
|
229
|
+
* @param {string} [params.to] - Recipient DID identifier
|
|
230
|
+
* @param {any} [params.message] - Message payload to send
|
|
231
|
+
* @param {string} [params.type] - DIDComm message type
|
|
232
|
+
* @param {string} [params.did] - @deprecated Use 'from' instead - Sender DID identifier
|
|
233
|
+
* @param {string} [params.recipientDid] - @deprecated Use 'to' instead - Recipient DID identifier
|
|
234
|
+
* @param {any} [params.body] - @deprecated Use 'message' instead - Message payload to send
|
|
235
|
+
* @returns {Promise<any>} Result of sending the message
|
|
236
|
+
* @throws {Error} If sender DID not found or message sending fails
|
|
237
|
+
* @example
|
|
238
|
+
* await messageProvider.sendMessage({
|
|
239
|
+
* from: 'did:key:sender123',
|
|
240
|
+
* to: 'did:key:recipient456',
|
|
241
|
+
* message: { hello: 'world' },
|
|
242
|
+
* type: 'basic-message'
|
|
243
|
+
* });
|
|
244
|
+
*
|
|
245
|
+
*/
|
|
246
|
+
async sendMessage({
|
|
247
|
+
// Recommended parameters
|
|
248
|
+
from, to, message, type,
|
|
249
|
+
// Deprecated parameters
|
|
250
|
+
did, recipientDid, body, }) {
|
|
182
251
|
try {
|
|
183
|
-
const keyPairDoc = await getKeyPairDocs(didProvider, did);
|
|
252
|
+
const keyPairDoc = await getKeyPairDocs(didProvider, from || did);
|
|
184
253
|
if (!keyPairDoc) {
|
|
185
254
|
throw new Error(`${did} not found in didDocs`);
|
|
186
255
|
}
|
|
187
256
|
return await relayService.sendMessage({
|
|
188
257
|
keyPairDoc,
|
|
189
|
-
message,
|
|
190
|
-
recipientDid,
|
|
258
|
+
message: message || body,
|
|
259
|
+
recipientDid: to || recipientDid,
|
|
191
260
|
type,
|
|
192
261
|
});
|
|
193
262
|
}
|
|
@@ -196,6 +265,14 @@ function createMessageProvider({ wallet, didProvider, relayService = relay_servi
|
|
|
196
265
|
throw new Error(`Failed to send message: ${error.message}`);
|
|
197
266
|
}
|
|
198
267
|
},
|
|
268
|
+
/**
|
|
269
|
+
* Waits for the next incoming message
|
|
270
|
+
* @memberof IMessageProvider
|
|
271
|
+
* @returns {Promise<any>} Promise that resolves with the next received message
|
|
272
|
+
* @example
|
|
273
|
+
* const nextMessage = await messageProvider.waitForMessage();
|
|
274
|
+
* console.log('Received message:', nextMessage);
|
|
275
|
+
*/
|
|
199
276
|
waitForMessage() {
|
|
200
277
|
return new Promise((resolve) => {
|
|
201
278
|
let removeListener = addMessageListener(async (message) => {
|
|
@@ -204,26 +281,100 @@ function createMessageProvider({ wallet, didProvider, relayService = relay_servi
|
|
|
204
281
|
});
|
|
205
282
|
});
|
|
206
283
|
},
|
|
284
|
+
/**
|
|
285
|
+
* Starts automatic message fetching at regular intervals
|
|
286
|
+
* @memberof IMessageProvider
|
|
287
|
+
* @param {number} [timeout=2000] - Interval in milliseconds between fetch operations
|
|
288
|
+
* @returns {Function} Function to stop the auto-fetch process
|
|
289
|
+
* @example
|
|
290
|
+
* const stopAutoFetch = messageProvider.startAutoFetch(5000);
|
|
291
|
+
* // Later, stop auto-fetching
|
|
292
|
+
* stopAutoFetch();
|
|
293
|
+
*/
|
|
207
294
|
startAutoFetch(timeout = 2000) {
|
|
208
295
|
clearInterval(listenerIntervalId);
|
|
296
|
+
stopped = false;
|
|
209
297
|
listenerIntervalId = setInterval(async () => {
|
|
210
|
-
|
|
211
|
-
|
|
298
|
+
try {
|
|
299
|
+
await fetchMessages();
|
|
300
|
+
await processDIDCommMessages();
|
|
301
|
+
}
|
|
302
|
+
catch (err) {
|
|
303
|
+
logger_1.logger.debug(`Auto-fetch error: ${err.message}`);
|
|
304
|
+
}
|
|
212
305
|
}, timeout);
|
|
213
|
-
return () =>
|
|
306
|
+
return () => {
|
|
307
|
+
clearInterval(listenerIntervalId);
|
|
308
|
+
listenerIntervalId = null;
|
|
309
|
+
};
|
|
214
310
|
},
|
|
311
|
+
/**
|
|
312
|
+
* Clears all cached messages from the wallet
|
|
313
|
+
* @memberof IMessageProvider
|
|
314
|
+
* @returns {Promise<void>}
|
|
315
|
+
* @example
|
|
316
|
+
* await messageProvider.clearCache();
|
|
317
|
+
* console.log('All messages cleared');
|
|
318
|
+
*/
|
|
215
319
|
clearCache: async () => {
|
|
216
320
|
return Promise.all((await wallet.getDocumentsByType(helpers_1.WalletDocumentTypes.DIDCommMessage)).map(document => {
|
|
217
321
|
markMessageAsRead(document.id);
|
|
218
322
|
return wallet.removeDocument(document.id);
|
|
219
323
|
}));
|
|
220
324
|
},
|
|
325
|
+
/**
|
|
326
|
+
* Fetches new messages from the relay service
|
|
327
|
+
* @memberof IMessageProvider
|
|
328
|
+
* @returns {Promise<void>}
|
|
329
|
+
* @throws {Error} If message fetching fails
|
|
330
|
+
* @example
|
|
331
|
+
* await messageProvider.fetchMessages();
|
|
332
|
+
* console.log('Messages fetched successfully');
|
|
333
|
+
*/
|
|
221
334
|
fetchMessages,
|
|
335
|
+
/**
|
|
336
|
+
* Adds a listener for when messages are decrypted
|
|
337
|
+
* @memberof IMessageProvider
|
|
338
|
+
* @param {Function} handler - Callback function to handle decrypted messages
|
|
339
|
+
* @returns {Function} Function to remove the listener
|
|
340
|
+
* @example
|
|
341
|
+
* const removeListener = messageProvider.addMessageListener((message) => {
|
|
342
|
+
* console.log('New message received:', message);
|
|
343
|
+
* });
|
|
344
|
+
* // Later, remove the listener
|
|
345
|
+
* removeListener();
|
|
346
|
+
*/
|
|
222
347
|
addMessageListener,
|
|
348
|
+
/**
|
|
349
|
+
* Processes stored DIDComm messages and decrypts them
|
|
350
|
+
* @memberof IMessageProvider
|
|
351
|
+
* @returns {Promise<void>}
|
|
352
|
+
* @throws {Error} If message processing fails
|
|
353
|
+
* @example
|
|
354
|
+
* await messageProvider.processDIDCommMessages();
|
|
355
|
+
* console.log('Messages processed successfully');
|
|
356
|
+
*/
|
|
223
357
|
processDIDCommMessages,
|
|
358
|
+
/**
|
|
359
|
+
* Starts the recurrent message processing job
|
|
360
|
+
* @memberof IMessageProvider
|
|
361
|
+
* @returns {Promise<void>}
|
|
362
|
+
* @example
|
|
363
|
+
* await messageProvider.processMessageRecurrentJob();
|
|
364
|
+
*/
|
|
224
365
|
processMessageRecurrentJob,
|
|
366
|
+
/**
|
|
367
|
+
* Marks a message as read and removes it from storage
|
|
368
|
+
* @memberof IMessageProvider
|
|
369
|
+
* @param {string} messageId - The ID of the message to mark as read
|
|
370
|
+
* @returns {Promise<void>}
|
|
371
|
+
* @throws {Error} If message is not found or not a DIDComm message
|
|
372
|
+
* @example
|
|
373
|
+
* await messageProvider.markMessageAsRead('message-id-123');
|
|
374
|
+
* console.log('Message marked as read');
|
|
375
|
+
*/
|
|
225
376
|
markMessageAsRead,
|
|
377
|
+
stop,
|
|
226
378
|
};
|
|
227
379
|
}
|
|
228
|
-
exports.createMessageProvider = createMessageProvider;
|
|
229
380
|
//# sourceMappingURL=message-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-provider.js","sourceRoot":"","sources":["../src/message-provider.ts"],"names":[],"mappings":"
|
|
1
|
+
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c,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YAC5C,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;QACD;;;;;;;;WAQG;QACH,aAAa;QACb;;;;;;;;;;;WAWG;QACH,kBAAkB;QAClB;;;;;;;;WAQG;QACH,sBAAsB;QACtB;;;;;;WAMG;QACH,0BAA0B;QAC1B;;;;;;;;;WASG;QACH,iBAAiB;QACjB,IAAI;KACE,CAAC;AACX,CAAC"}
|
|
@@ -4,7 +4,12 @@
|
|
|
4
4
|
* Check https://identity.foundation/didcomm-messaging/spec/#out-of-band-messages for more details
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.Goals = exports.MessageTypes = void 0;
|
|
8
|
+
exports.buildVerificationFlowInviteMessage = buildVerificationFlowInviteMessage;
|
|
9
|
+
exports.buildRequestVerifiablePresentationMessage = buildRequestVerifiablePresentationMessage;
|
|
10
|
+
exports.buildAckWalletToWalletVerificationMessage = buildAckWalletToWalletVerificationMessage;
|
|
11
|
+
exports.buildVerifiablePresentationMessage = buildVerifiablePresentationMessage;
|
|
12
|
+
exports.buildVerifiablePresentationAckMessage = buildVerifiablePresentationAckMessage;
|
|
8
13
|
exports.MessageTypes = {
|
|
9
14
|
Invitation: 'https://didcomm.org/out-of-band/2.0/invitation',
|
|
10
15
|
RequestPresentation: 'https://didcomm.org/present-proof/1.0/request-presentation',
|
|
@@ -35,7 +40,6 @@ function buildVerificationFlowInviteMessage({ verifierDID, proofRequestId }) {
|
|
|
35
40
|
},
|
|
36
41
|
};
|
|
37
42
|
}
|
|
38
|
-
exports.buildVerificationFlowInviteMessage = buildVerificationFlowInviteMessage;
|
|
39
43
|
/**
|
|
40
44
|
* Sender: Verifier
|
|
41
45
|
* OOB message to request a verifiable presentation from the holder
|
|
@@ -51,7 +55,6 @@ function buildRequestVerifiablePresentationMessage({ verifierDID, holderDID, pro
|
|
|
51
55
|
},
|
|
52
56
|
};
|
|
53
57
|
}
|
|
54
|
-
exports.buildRequestVerifiablePresentationMessage = buildRequestVerifiablePresentationMessage;
|
|
55
58
|
/**
|
|
56
59
|
* Sender: Holder
|
|
57
60
|
* Start a wallet to wallet verification flow
|
|
@@ -68,7 +71,6 @@ function buildAckWalletToWalletVerificationMessage({ holderDID, verifierDID, pro
|
|
|
68
71
|
},
|
|
69
72
|
};
|
|
70
73
|
}
|
|
71
|
-
exports.buildAckWalletToWalletVerificationMessage = buildAckWalletToWalletVerificationMessage;
|
|
72
74
|
/**
|
|
73
75
|
* Sender: Holder
|
|
74
76
|
* Send a verifiable presentation to the verifier
|
|
@@ -84,7 +86,6 @@ function buildVerifiablePresentationMessage({ verifierDID, holderDID, proofReque
|
|
|
84
86
|
},
|
|
85
87
|
};
|
|
86
88
|
}
|
|
87
|
-
exports.buildVerifiablePresentationMessage = buildVerifiablePresentationMessage;
|
|
88
89
|
/**
|
|
89
90
|
* Sender: Verifier
|
|
90
91
|
* Sends an the presentation result to the holder
|
|
@@ -102,5 +103,4 @@ function buildVerifiablePresentationAckMessage({ verifierDID, holderDID, proofRe
|
|
|
102
103
|
},
|
|
103
104
|
};
|
|
104
105
|
}
|
|
105
|
-
exports.buildVerifiablePresentationAckMessage = buildVerifiablePresentationAckMessage;
|
|
106
106
|
//# sourceMappingURL=message-helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-helpers.js","sourceRoot":"","sources":["../../src/messages/message-helpers.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"message-helpers.js","sourceRoot":"","sources":["../../src/messages/message-helpers.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAwBH,gFAUC;AAMD,8FAeC;AAMD,8FAeC;AAOD,gFAeC;AAMD,sFAiBC;AAvHY,QAAA,YAAY,GAAG;IAC1B,UAAU,EAAE,gDAAgD;IAC5D,mBAAmB,EACjB,4DAA4D;IAC9D,YAAY,EAAE,oDAAo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;QACf,EAAE,EAAE,WAAW;QACf,IAAI,EAAE;YACJ,cAAc;YACd,YAAY;SACb;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,qCAAqC,CAAC,EACpD,WAAW,EACX,SAAS,EACT,cAAc,EACd,kBAAkB,GACnB;IACC,OAAO;QACL,IAAI,EAAE,oBAAY,CAAC,GAAG;QACtB,IAAI,EAAE,WAAW;QACjB,EAAE,EAAE,SAAS;QACb,IAAI,EAAE;YACJ,SAAS,EAAE,aAAK,CAAC,2BAA2B;YAC5C,IAAI,EAAE,kEAAkE;YACxE,cAAc;YACd,kBAAkB;SACnB;KACF,CAAC;AACJ,CAAC"}
|
package/lib/network-resolver.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.dockDocumentNetworkResolver = void 0;
|
|
4
|
+
exports.resolveApiNetwork = resolveApiNetwork;
|
|
5
|
+
exports.credentialResolver = credentialResolver;
|
|
6
|
+
exports.proofRequestResolver = proofRequestResolver;
|
|
7
|
+
exports.didResolver = didResolver;
|
|
4
8
|
const dockDocumentNetworkResolver = async ({ document, dataStore, }) => {
|
|
5
9
|
let networkId;
|
|
6
10
|
let isFallback = false;
|
|
@@ -47,7 +51,6 @@ function resolveApiNetwork({ url, dataStore, }) {
|
|
|
47
51
|
}
|
|
48
52
|
return null;
|
|
49
53
|
}
|
|
50
|
-
exports.resolveApiNetwork = resolveApiNetwork;
|
|
51
54
|
async function credentialResolver({ document, dataStore, }) {
|
|
52
55
|
if (!document) {
|
|
53
56
|
return null;
|
|
@@ -61,7 +64,6 @@ async function credentialResolver({ document, dataStore, }) {
|
|
|
61
64
|
dataStore,
|
|
62
65
|
});
|
|
63
66
|
}
|
|
64
|
-
exports.credentialResolver = credentialResolver;
|
|
65
67
|
async function proofRequestResolver({ document, dataStore, }) {
|
|
66
68
|
if (!document) {
|
|
67
69
|
return null;
|
|
@@ -75,12 +77,10 @@ async function proofRequestResolver({ document, dataStore, }) {
|
|
|
75
77
|
dataStore,
|
|
76
78
|
});
|
|
77
79
|
}
|
|
78
|
-
exports.proofRequestResolver = proofRequestResolver;
|
|
79
80
|
async function didResolver({ document, dataStore, }) {
|
|
80
81
|
// TODO: Define DID resolver
|
|
81
82
|
return null;
|
|
82
83
|
}
|
|
83
|
-
exports.didResolver = didResolver;
|
|
84
84
|
const resolvers = [
|
|
85
85
|
credentialResolver,
|
|
86
86
|
didResolver,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-resolver.js","sourceRoot":"","sources":["../src/network-resolver.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"network-resolver.js","sourceRoot":"","sources":["../src/network-resolver.ts"],"names":[],"mappings":";;;AA2CA,8CAsBC;AAED,gDAkBC;AAED,oDAmBC;AAED,kCAMC;AAzGM,MAAM,2BAA2B,GAA4B,KAAK,EAAE,EACzE,QAAQ,EACR,SAAS,GACa,EAAmC,EAAE;IAC3D,IAAI,SAAS,CAAC;IACd,IAAI,UAAU,GAAG,KAAK,CAAC;IACvB,IAAI,eAAe,CAAC;IACpB,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,SAAS,GAAG,MAAM,QAAQ,CAAC,EAAC,QAAQ,EAAE,SAAS,EAAC,CAAC,CAAC;QAClD,eAAe,GAAG,QAAQ,CAAC;QAC3B,IAAI,SAAS,EAAE,CAAC;YACd,MAAM;QACR,CAAC;IACH,CAAC;IAED,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,UAAU,GAAG,IAAI,CAAC;QAClB,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC;IAClC,CAAC;IAED,OAAO;QACL,SAAS,EAAE,SAAS;QACpB,UAAU;QACV,QAAQ,EAAE,eAAe;KAC1B,CAAC;AACJ,CAAC,CAAC;AAzBW,QAAA,2BAA2B,+BAyBtC;AAEF;;;;;;GA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AAiB,CAAC;QACvB,GAAG,EAAE,QAAQ,CAAC,EAAE;QAChB,SAAS;KACV,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,WAAW,CAAC,EAChC,QAAQ,EACR,SAAS,GACa;IACtB,4BAA4B;IAC5B,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,SAAS,GAAG;IAChB,kBAAkB;IAClB,WAAW;IACX,oBAAoB;CACrB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in QR Code Handlers
|
|
3
|
+
*
|
|
4
|
+
* This module provides pre-built handlers for common protocols used in
|
|
5
|
+
* decentralized identity wallets. These handlers can be used directly or
|
|
6
|
+
* extended for custom behavior.
|
|
7
|
+
*
|
|
8
|
+
* ## Available Handlers
|
|
9
|
+
*
|
|
10
|
+
* - **OID4VCHandler**: OpenID for Verifiable Credentials (OID4VC)
|
|
11
|
+
*
|
|
12
|
+
* ## Usage
|
|
13
|
+
*
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { OID4VCHandler } from '@docknetwork/wallet-sdk-core/lib/qr-handlers/builtin';
|
|
16
|
+
*
|
|
17
|
+
* const handler = new OID4VCHandler({
|
|
18
|
+
* onImportCredential: async (uri) => {
|
|
19
|
+
* // Your credential import logic
|
|
20
|
+
* return { success: true };
|
|
21
|
+
* },
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* processor.registerHandler(handler);
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @module qr-handlers/builtin
|
|
28
|
+
*/
|
|
29
|
+
export * from './oid4vc-handler';
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/qr-handlers/builtin/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Built-in QR Code Handlers
|
|
4
|
+
*
|
|
5
|
+
* This module provides pre-built handlers for common protocols used in
|
|
6
|
+
* decentralized identity wallets. These handlers can be used directly or
|
|
7
|
+
* extended for custom behavior.
|
|
8
|
+
*
|
|
9
|
+
* ## Available Handlers
|
|
10
|
+
*
|
|
11
|
+
* - **OID4VCHandler**: OpenID for Verifiable Credentials (OID4VC)
|
|
12
|
+
*
|
|
13
|
+
* ## Usage
|
|
14
|
+
*
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { OID4VCHandler } from '@docknetwork/wallet-sdk-core/lib/qr-handlers/builtin';
|
|
17
|
+
*
|
|
18
|
+
* const handler = new OID4VCHandler({
|
|
19
|
+
* onImportCredential: async (uri) => {
|
|
20
|
+
* // Your credential import logic
|
|
21
|
+
* return { success: true };
|
|
22
|
+
* },
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* processor.registerHandler(handler);
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @module qr-handlers/builtin
|
|
29
|
+
*/
|
|
30
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
33
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
34
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
35
|
+
}
|
|
36
|
+
Object.defineProperty(o, k2, desc);
|
|
37
|
+
}) : (function(o, m, k, k2) {
|
|
38
|
+
if (k2 === undefined) k2 = k;
|
|
39
|
+
o[k2] = m[k];
|
|
40
|
+
}));
|
|
41
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
42
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
__exportStar(require("./oid4vc-handler"), exports);
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/qr-handlers/builtin/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;;;;;;;;;;;;;;AAEH,mDAAiC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { QRCodeContext, QRCodeHandler, QRCodeHandlerResult } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for OID4VC handler
|
|
4
|
+
*/
|
|
5
|
+
export interface OID4VCHandlerConfig {
|
|
6
|
+
/**
|
|
7
|
+
* URI prefixes to match (default: ['openid-credential-offer://'])
|
|
8
|
+
*/
|
|
9
|
+
uriPrefixes?: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Priority for this handler (default: 5)
|
|
12
|
+
*/
|
|
13
|
+
priority?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Callback to handle credential import
|
|
16
|
+
* This is where app-specific logic (navigation, UI, etc.) should be implemented
|
|
17
|
+
*
|
|
18
|
+
* @param uri - The OID4VC URI to process
|
|
19
|
+
* @param context - The full QR code context
|
|
20
|
+
* @returns Result of the import operation
|
|
21
|
+
*/
|
|
22
|
+
onImportCredential: (uri: string, context: QRCodeContext) => Promise<OID4VCImportResult>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Result from importing an OID4VC credential
|
|
26
|
+
*/
|
|
27
|
+
export interface OID4VCImportResult {
|
|
28
|
+
/**
|
|
29
|
+
* Whether the import was successful
|
|
30
|
+
*/
|
|
31
|
+
success: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Credential data if import succeeded
|
|
34
|
+
*/
|
|
35
|
+
credential?: any;
|
|
36
|
+
/**
|
|
37
|
+
* Error if import failed
|
|
38
|
+
*/
|
|
39
|
+
error?: Error;
|
|
40
|
+
/**
|
|
41
|
+
* Additional metadata
|
|
42
|
+
*/
|
|
43
|
+
metadata?: Record<string, any>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Built-in handler for OID4VC (OpenID for Verifiable Credentials) URIs
|
|
47
|
+
*
|
|
48
|
+
* This is a generic handler that can be configured with app-specific callbacks
|
|
49
|
+
* for importing credentials. The handler itself only handles protocol detection
|
|
50
|
+
* and delegates the actual import logic to the configured callback.
|
|
51
|
+
*
|
|
52
|
+
* ## Example Usage
|
|
53
|
+
*
|
|
54
|
+
* ```typescript
|
|
55
|
+
* import { OID4VCHandler } from '@docknetwork/wallet-sdk-core/lib/qr-handlers/builtin';
|
|
56
|
+
* import { getCredentialProvider } from '@docknetwork/wallet-sdk-react-native';
|
|
57
|
+
*
|
|
58
|
+
* const handler = new OID4VCHandler({
|
|
59
|
+
* onImportCredential: async (uri, context) => {
|
|
60
|
+
* try {
|
|
61
|
+
* // Use SDK to import credential
|
|
62
|
+
* await getCredentialProvider().importCredentialFromURI({
|
|
63
|
+
* uri,
|
|
64
|
+
* didProvider: getDIDProvider(),
|
|
65
|
+
* getAuthCode: async (authUrl) => {
|
|
66
|
+
* // App-specific auth handling
|
|
67
|
+
* return await showAuthWebView(authUrl);
|
|
68
|
+
* },
|
|
69
|
+
* });
|
|
70
|
+
*
|
|
71
|
+
* return { success: true };
|
|
72
|
+
* } catch (error) {
|
|
73
|
+
* return {
|
|
74
|
+
* success: false,
|
|
75
|
+
* error: error instanceof Error ? error : new Error(String(error)),
|
|
76
|
+
* };
|
|
77
|
+
* }
|
|
78
|
+
* },
|
|
79
|
+
* });
|
|
80
|
+
*
|
|
81
|
+
* processor.registerHandler(handler);
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* ## Handler Priority
|
|
85
|
+
*
|
|
86
|
+
* Default priority: 5 (very high)
|
|
87
|
+
* This ensures OID4VC URIs are checked before other credential handlers.
|
|
88
|
+
*
|
|
89
|
+
* @category Built-in Handlers
|
|
90
|
+
*/
|
|
91
|
+
export declare class OID4VCHandler implements QRCodeHandler {
|
|
92
|
+
id: string;
|
|
93
|
+
priority: number;
|
|
94
|
+
private uriPrefixes;
|
|
95
|
+
private onImportCredential;
|
|
96
|
+
constructor(config: OID4VCHandlerConfig);
|
|
97
|
+
/**
|
|
98
|
+
* Check if this is an OID4VC URI
|
|
99
|
+
*
|
|
100
|
+
* Matches URIs that start with any of the configured prefixes.
|
|
101
|
+
* By default, matches: openid-credential-offer://
|
|
102
|
+
*
|
|
103
|
+
* @param context - The QR code context
|
|
104
|
+
* @returns True if this handler can process the URI
|
|
105
|
+
*/
|
|
106
|
+
canHandle(context: QRCodeContext): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Process the OID4VC credential offer URI
|
|
109
|
+
*
|
|
110
|
+
* Delegates to the configured onImportCredential callback for actual processing.
|
|
111
|
+
* This allows apps to implement their own navigation, UI, and error handling.
|
|
112
|
+
*
|
|
113
|
+
* @param context - The QR code context
|
|
114
|
+
* @returns Result of the processing
|
|
115
|
+
*/
|
|
116
|
+
handle(context: QRCodeContext): Promise<QRCodeHandlerResult>;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Create an OID4VC handler with custom configuration
|
|
120
|
+
*
|
|
121
|
+
* This is a convenience factory function for creating an OID4VC handler.
|
|
122
|
+
*
|
|
123
|
+
* @param config - Handler configuration
|
|
124
|
+
* @returns Configured OID4VC handler
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* const handler = createOID4VCHandler({
|
|
129
|
+
* onImportCredential: async (uri) => {
|
|
130
|
+
* // Your import logic
|
|
131
|
+
* return { success: true };
|
|
132
|
+
* },
|
|
133
|
+
* });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
export declare function createOID4VCHandler(config: OID4VCHandlerConfig): OID4VCHandler;
|
|
137
|
+
//# sourceMappingURL=oid4vc-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oid4vc-handler.d.ts","sourceRoot":"","sources":["../../../src/qr-handlers/builtin/oid4vc-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,aAAa,EACb,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;OAOG;IACH,kBAAkB,EAAE,CAClB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,aAAa,KACnB,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,UAAU,CAAC,EAAE,GAAG,CAAC;IAEjB;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IAEd;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,qBAAa,aAAc,YAAW,aAAa;IACjD,EAAE,SAAY;IACd,QAAQ,EAAE,MAAM,CAAC;IAEjB,OAAO,CAAC,WAAW,CAAW;IAC9B,OAAO,CAAC,kBAAkB,CAGO;gBAErB,MAAM,EAAE,mBAAmB;IAUvC;;;;;;;;OAQG;IACH,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO;IAI1C;;;;;;;;OAQG;IACG,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,mBAAmB,CAAC;CA0BnE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CACjC,MAA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