@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.
Files changed (92) hide show
  1. package/.claude/settings.local.json +12 -0
  2. package/generate-docs.js +33 -0
  3. package/jsdoc.conf.json +28 -0
  4. package/lib/biometric-provider.d.ts +124 -32
  5. package/lib/biometric-provider.d.ts.map +1 -1
  6. package/lib/biometric-provider.js +146 -7
  7. package/lib/biometric-provider.js.map +1 -1
  8. package/lib/cloud-wallet.d.ts +8 -6
  9. package/lib/cloud-wallet.d.ts.map +1 -1
  10. package/lib/cloud-wallet.js +41 -57
  11. package/lib/cloud-wallet.js.map +1 -1
  12. package/lib/credential-provider.d.ts +58 -33
  13. package/lib/credential-provider.d.ts.map +1 -1
  14. package/lib/credential-provider.js +212 -11
  15. package/lib/credential-provider.js.map +1 -1
  16. package/lib/credentials/oidvc.js +4 -5
  17. package/lib/credentials/oidvc.js.map +1 -1
  18. package/lib/did-provider.d.ts +102 -36
  19. package/lib/did-provider.d.ts.map +1 -1
  20. package/lib/did-provider.js +185 -27
  21. package/lib/did-provider.js.map +1 -1
  22. package/lib/ecosystem-tools.js +4 -5
  23. package/lib/ecosystem-tools.js.map +1 -1
  24. package/lib/helpers.js +6 -6
  25. package/lib/helpers.js.map +1 -1
  26. package/lib/message-provider.d.ts +39 -13
  27. package/lib/message-provider.d.ts.map +1 -1
  28. package/lib/message-provider.js +173 -22
  29. package/lib/message-provider.js.map +1 -1
  30. package/lib/messages/message-helpers.js +6 -6
  31. package/lib/messages/message-helpers.js.map +1 -1
  32. package/lib/network-resolver.js +5 -5
  33. package/lib/network-resolver.js.map +1 -1
  34. package/lib/qr-handlers/builtin/index.d.ts +30 -0
  35. package/lib/qr-handlers/builtin/index.d.ts.map +1 -0
  36. package/lib/qr-handlers/builtin/index.js +46 -0
  37. package/lib/qr-handlers/builtin/index.js.map +1 -0
  38. package/lib/qr-handlers/builtin/oid4vc-handler.d.ts +137 -0
  39. package/lib/qr-handlers/builtin/oid4vc-handler.d.ts.map +1 -0
  40. package/lib/qr-handlers/builtin/oid4vc-handler.js +134 -0
  41. package/lib/qr-handlers/builtin/oid4vc-handler.js.map +1 -0
  42. package/lib/qr-handlers/index.d.ts +76 -0
  43. package/lib/qr-handlers/index.d.ts.map +1 -0
  44. package/lib/qr-handlers/index.js +92 -0
  45. package/lib/qr-handlers/index.js.map +1 -0
  46. package/lib/qr-handlers/processor.d.ts +110 -0
  47. package/lib/qr-handlers/processor.d.ts.map +1 -0
  48. package/lib/qr-handlers/processor.js +251 -0
  49. package/lib/qr-handlers/processor.js.map +1 -0
  50. package/lib/qr-handlers/types.d.ts +205 -0
  51. package/lib/qr-handlers/types.d.ts.map +1 -0
  52. package/lib/qr-handlers/types.js +10 -0
  53. package/lib/qr-handlers/types.js.map +1 -0
  54. package/lib/types.d.ts +613 -13
  55. package/lib/types.d.ts.map +1 -1
  56. package/lib/types.js +16 -0
  57. package/lib/types.js.map +1 -1
  58. package/lib/verification-controller.d.ts +3 -4
  59. package/lib/verification-controller.d.ts.map +1 -1
  60. package/lib/verification-controller.js +10 -3
  61. package/lib/verification-controller.js.map +1 -1
  62. package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.d.ts +0 -1
  63. package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.d.ts.map +1 -1
  64. package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.js +2 -2
  65. package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.js.map +1 -1
  66. package/lib/wallet-wasm.d.ts +2 -2
  67. package/lib/wallet-wasm.d.ts.map +1 -1
  68. package/lib/wallet-wasm.js +15 -17
  69. package/lib/wallet-wasm.js.map +1 -1
  70. package/lib/wallet.d.ts +36 -20
  71. package/lib/wallet.d.ts.map +1 -1
  72. package/lib/wallet.js +172 -26
  73. package/lib/wallet.js.map +1 -1
  74. package/package.json +19 -11
  75. package/src/biometric-provider.ts +157 -42
  76. package/src/cloud-wallet.ts +21 -60
  77. package/src/credential-provider.test.ts +191 -1
  78. package/src/credential-provider.ts +208 -27
  79. package/src/did-provider.ts +183 -34
  80. package/src/message-provider.ts +177 -38
  81. package/src/qr-handlers/builtin/index.ts +30 -0
  82. package/src/qr-handlers/builtin/oid4vc-handler.ts +198 -0
  83. package/src/qr-handlers/index.ts +76 -0
  84. package/src/qr-handlers/processor.test.ts +514 -0
  85. package/src/qr-handlers/processor.ts +311 -0
  86. package/src/qr-handlers/types.ts +228 -0
  87. package/src/types.ts +671 -11
  88. package/src/verification-controller.test.ts +1 -2
  89. package/src/verification-controller.ts +14 -2
  90. package/src/wallet-wasm.ts +5 -8
  91. package/src/wallet.ts +173 -24
  92. package/tsconfig.build.tsbuildinfo +1 -1
package/src/types.ts CHANGED
@@ -5,12 +5,51 @@ import {
5
5
  } from '@docknetwork/wallet-sdk-data-store/src/types';
6
6
  import {EventEmitter} from 'events';
7
7
 
8
+ /**
9
+ * Legacy V1 wallet interface for backward compatibility
10
+ * @interface IV1Wallet
11
+ * @deprecated This interface is obsolete and should not be used for new implementations. Use IWallet instead.
12
+ */
8
13
  export interface IV1Wallet {
14
+ /**
15
+ * Gets the current wallet status
16
+ * @returns {string} The current status (e.g., 'ready', 'loading', 'error')
17
+ */
9
18
  getStatus: () => string;
19
+
20
+ /**
21
+ * Sets the wallet status
22
+ * @param {string} status - The new status to set
23
+ */
10
24
  setStatus: (status: string) => void;
25
+
26
+ /**
27
+ * Event emitter for wallet events
28
+ * @type {EventEmitter}
29
+ */
11
30
  eventManager: EventEmitter;
31
+
32
+ /**
33
+ * Waits for a specific event to be emitted
34
+ * @param {string} eventName - The event name to wait for
35
+ * @returns {Promise<any>} Promise that resolves when the event is emitted
36
+ */
12
37
  waitForEvent: (eventName: string) => Promise<any>;
38
+
39
+ /**
40
+ * Resolves correlations for a document ID
41
+ * @param {string} id - The document ID to resolve correlations for
42
+ * @returns {Promise<WalletDocument[]>} Array of correlated documents
43
+ */
13
44
  resolveCorrelations: (id: string) => Promise<WalletDocument[]>;
45
+
46
+ /**
47
+ * Queries documents by ID or type
48
+ * @param {Object} [params] - Query parameters
49
+ * @param {string} [params.id] - Document ID to search for
50
+ * @param {string} [params.type] - Document type to filter by
51
+ * @returns {Promise<WalletDocument[]>} Array of matching documents
52
+ */
14
53
  query: ({
15
54
  id,
16
55
  type,
@@ -19,55 +58,214 @@ export interface IV1Wallet {
19
58
  type?: string;
20
59
  }) => Promise<WalletDocument[]>;
21
60
 
61
+ /**
62
+ * Ensures network connection is established
63
+ * @returns {Promise<void>}
64
+ */
22
65
  ensureNetwork: () => Promise<void>;
66
+
67
+ /**
68
+ * Synchronizes wallet data
69
+ * @returns {Promise<void>}
70
+ */
23
71
  sync: () => Promise<void>;
72
+
73
+ /**
74
+ * Removes a document (legacy method)
75
+ * @param {string} id - Document ID to remove
76
+ * @returns {Promise<void>}
77
+ * @deprecated Use removeDocument instead
78
+ */
24
79
  remove: (id: string) => Promise<void>;
80
+
81
+ /**
82
+ * Creates a new document (legacy method)
83
+ * @param {any} json - Document data
84
+ * @returns {Promise<WalletDocument>} The created document
85
+ * @deprecated Use addDocument instead
86
+ */
25
87
  create: (json: any) => Promise<WalletDocument>;
88
+
89
+ /**
90
+ * Updates a document (legacy method)
91
+ * @param {any} json - Updated document data
92
+ * @returns {Promise<WalletDocument>} The updated document
93
+ * @deprecated Use updateDocument instead
94
+ */
26
95
  update: (json: any) => Promise<WalletDocument>;
96
+
97
+ /**
98
+ * Creates or updates a document (legacy method)
99
+ * @param {any} json - Document data
100
+ * @returns {Promise<WalletDocument>} The created or updated document
101
+ * @deprecated Use upsertDocument instead
102
+ */
27
103
  upsert: (json: any) => Promise<WalletDocument>;
104
+
105
+ /**
106
+ * Deletes the entire wallet
107
+ * @returns {Promise<void>}
108
+ * @fires WalletEvents.walletDeleted
109
+ */
28
110
  deleteWallet: () => Promise<void>;
29
111
  }
30
112
 
31
- export type IWallet = {
113
+ /**
114
+ * Main wallet interface providing methods for document management, import/export, and network operations.
115
+ * @interface IWallet
116
+ * @extends {IV1Wallet}
117
+ */
118
+ export interface IWallet extends IV1Wallet{
119
+ /**
120
+ * Retrieves a document by its ID
121
+ * @param {string} id - The unique identifier of the document
122
+ * @returns {Promise<WalletDocument>} The document with the specified ID
123
+ * @throws {Error} If document is not found
124
+ */
32
125
  getDocumentById: (id: string) => Promise<WalletDocument>;
126
+
127
+ /**
128
+ * Retrieves multiple documents by their IDs
129
+ * @param {string[]} idList - Array of document IDs to retrieve
130
+ * @returns {Promise<WalletDocument[]>} Array of documents matching the provided IDs
131
+ */
33
132
  getDocumentsById: (idList: string[]) => Promise<WalletDocument[]>;
133
+
134
+ /**
135
+ * Retrieves all documents of a specific type
136
+ * @param {string} type - The document type to filter by (e.g., 'VerifiableCredential', 'DIDDocument')
137
+ * @returns {Promise<WalletDocument[]>} Array of documents matching the specified type
138
+ */
34
139
  getDocumentsByType: (type: string) => Promise<WalletDocument[]>;
140
+
141
+ /**
142
+ * Retrieves all documents stored in the wallet
143
+ * @returns {Promise<WalletDocument[]>} Array of all documents in the wallet
144
+ */
35
145
  getAllDocuments: () => Promise<WalletDocument[]>;
146
+
147
+ /**
148
+ * Adds a new document to the wallet
149
+ * @param {any} json - The document to add (must have valid JSON-LD structure)
150
+ * @param {any} [options] - Optional parameters for document creation
151
+ * @returns {Promise<WalletDocument>} The created document with generated metadata
152
+ * @fires WalletEvents.documentAdded
153
+ */
36
154
  addDocument: (json: any, options?: any) => Promise<WalletDocument>;
155
+
156
+ /**
157
+ * Creates or updates a document based on its ID
158
+ * @param {any} json - The document to create or update
159
+ * @param {any} [options] - Optional parameters for the operation
160
+ * @returns {Promise<WalletDocument>} The created or updated document
161
+ */
37
162
  upsertDocument: (json: any, options?: any) => Promise<WalletDocument>;
163
+
164
+ /**
165
+ * Updates an existing document
166
+ * @param {any} json - The document with updated data (must include ID)
167
+ * @param {any} [options] - Optional parameters for document update
168
+ * @returns {Promise<WalletDocument>} The updated document
169
+ * @fires WalletEvents.documentUpdated
170
+ * @throws {Error} If document doesn't exist
171
+ */
38
172
  updateDocument: (json: any, options?: any) => Promise<WalletDocument>;
173
+
174
+ /**
175
+ * Gets all documents correlated to a specific document
176
+ * @param {string} documentId - The ID of the document to find correlations for
177
+ * @returns {Promise<WalletDocument[]>} Array of correlated documents
178
+ */
39
179
  getDocumentCorrelations: (documentId: string) => Promise<WalletDocument[]>;
180
+
181
+ /**
182
+ * Retrieves the keypair associated with an account
183
+ * @param {string} accountId - The account ID to get the keypair for
184
+ * @returns {Promise<any>} The keypair associated with the account
185
+ */
40
186
  getAccountKeyPair: (accountId: string) => Promise<any>;
187
+
41
188
  /**
42
- * Remove document by id
43
- * @param id
189
+ * Removes a document from the wallet
190
+ * @param {string} id - The ID of the document to remove
191
+ * @param {any} [options] - Optional parameters for document removal
192
+ * @returns {Promise<void>}
193
+ * @fires WalletEvents.documentRemoved
194
+ * @throws {Error} If document is not found
44
195
  */
45
196
  removeDocument: (id: string, options?: any) => Promise<void>;
197
+
46
198
  /**
47
- * Import data from a Universal Wallet 2020 JSON
48
- * https://w3c-ccg.github.io/universal-wallet-interop-spec/
49
- *
50
- * @param json
199
+ * Imports documents from an encrypted Universal Wallet 2020 JSON
200
+ * @param {any} json - The encrypted wallet JSON
201
+ * @param {string} password - Password to decrypt the wallet
202
+ * @returns {Promise<void>}
203
+ * @see {@link https://w3c-ccg.github.io/universal-wallet-interop-spec/}
51
204
  */
52
205
  importUniversalWalletJSON: (json: any, password: string) => Promise<void>;
206
+
207
+ /**
208
+ * Decrypts and retrieves documents from an encrypted wallet without importing
209
+ * @param {any} json - The encrypted wallet JSON
210
+ * @param {string} password - Password to decrypt the wallet
211
+ * @returns {Promise<any>} Array of decrypted documents
212
+ * @see {@link https://w3c-ccg.github.io/universal-wallet-interop-spec/}
213
+ */
53
214
  getDocumentsFromEncryptedWallet: (
54
215
  json: any,
55
216
  password: string,
56
217
  ) => Promise<any>;
218
+
219
+ /**
220
+ * Exports specified documents as an encrypted JSON
221
+ * @param {Object} params - Export parameters
222
+ * @param {any[]} params.documents - Documents to export
223
+ * @param {string} params.password - Password for encryption
224
+ * @returns {Promise<any>} Encrypted wallet JSON
225
+ */
57
226
  exportDocuments: (params: {documents: any; password: string}) => Promise<any>;
227
+
58
228
  /**
59
- * Create a Universal Wallet 2020 JSON representation of the wallet
60
- * https://w3c-ccg.github.io/universal-wallet-interop-spec/
61
- * @returns JSON representation of the wallet
229
+ * Exports the entire wallet as an encrypted Universal Wallet 2020 JSON
230
+ * @param {string} password - Password for encryption
231
+ * @returns {any} Encrypted Universal Wallet JSON representation
232
+ * @see {@link https://w3c-ccg.github.io/universal-wallet-interop-spec/}
62
233
  */
63
234
  exportUniversalWalletJSON: (password: string) => any;
64
235
 
236
+ /**
237
+ * Sets the active network for the wallet
238
+ * @param {string} networkId - The network identifier to switch to
239
+ * @returns {Promise<void>}
240
+ * @fires WalletEvents.networkUpdated
241
+ */
65
242
  setNetwork: (networkId: string) => Promise<void>;
243
+
244
+ /**
245
+ * Gets the current network ID
246
+ * @returns {string} The current network identifier
247
+ */
66
248
  getNetworkId: () => string;
249
+
250
+ /**
251
+ * Resolves network-specific information for a document
252
+ * @param {any} document - The document to resolve network info for
253
+ * @returns {Promise<DocumentResolverResult>} Network resolution result
254
+ */
67
255
  resolveDocumentNetwork: (document: any) => Promise<DocumentResolverResult>;
256
+
257
+ /**
258
+ * The underlying data store instance
259
+ * @type {DataStore}
260
+ */
68
261
  dataStore: DataStore;
262
+
263
+ /**
264
+ * Network check interval handle (if periodic checks are enabled)
265
+ * @type {NodeJS.Timeout | number | undefined}
266
+ */
69
267
  networkCheckInterval?: NodeJS.Timeout | number;
70
- } & IV1Wallet;
268
+ };
71
269
 
72
270
  export type CrateWalletWithDataStore = {
73
271
 
@@ -76,3 +274,465 @@ export type CrateWalletWithDataStore = {
76
274
  export type CreateWalletProps = {
77
275
  dataStore: DataStore;
78
276
  }
277
+
278
+
279
+ /**
280
+ * Possible wallet status values
281
+ * @typedef {'closed' | 'loading' | 'ready' | 'error'} WalletStatus
282
+ */
283
+ export type WalletStatus = 'closed' | 'loading' | 'ready' | 'error';
284
+
285
+ /**
286
+ * Supported keypair types
287
+ * @typedef {'sr25519' | 'ed25519' | 'ecdsa'} KeypairType
288
+ */
289
+ export type KeypairType = 'sr25519' | 'ed25519' | 'ecdsa';
290
+
291
+ export const WalletEvents = {
292
+ ready: 'ready',
293
+ error: 'error',
294
+ migrated: 'migrated',
295
+ statusUpdated: 'status-updated',
296
+ documentAdded: 'document-added',
297
+ documentUpdated: 'document-updated',
298
+ documentRemoved: 'document-removed',
299
+ walletDeleted: 'wallet-deleted',
300
+ walletImported: 'wallet-imported',
301
+ networkUpdated: 'network-updated',
302
+ networkConnected: 'network-connected',
303
+ networkError: 'network-error',
304
+ };
305
+
306
+ /**
307
+ * Interface for DID provider operations
308
+ * @interface IDIDProvider
309
+ * @description Provides a high-level API for DID management operations
310
+ */
311
+ export interface IDIDProvider {
312
+ /**
313
+ * Imports a DID from an encrypted wallet JSON
314
+ * @param {Object} params - Import parameters
315
+ * @param {any} params.encryptedJSONWallet - The encrypted wallet JSON containing the DID
316
+ * @param {string} params.password - Password to decrypt the wallet
317
+ * @returns {Promise<any[]>} Array of imported documents
318
+ * @throws {Error} If password is incorrect or DID already exists in wallet
319
+ */
320
+ importDID: (params: {encryptedJSONWallet: any; password: string}) => Promise<any>;
321
+
322
+ /**
323
+ * Creates a new DID:key with an associated keypair
324
+ * @param {Object} params - Creation parameters
325
+ * @param {string} params.name - The name for the new DID
326
+ * @param {string} [params.derivePath] - Optional derivation path for the keypair
327
+ * @param {string} [params.type] - Optional key type specification
328
+ * @returns {Promise<{keyDoc: any, didDocumentResolution: any}>} The created keypair and DID document
329
+ * @throws {Error} If name is not provided
330
+ */
331
+ createDIDKey: (params: {name: string; derivePath?: string; type?: string}) => Promise<any>;
332
+
333
+ /**
334
+ * Edits a DID document's name
335
+ * @param {Object} params - Edit parameters
336
+ * @param {string} params.id - The ID of the DID document to edit
337
+ * @param {string} params.name - The new name for the DID
338
+ * @returns {Promise<void>}
339
+ * @throws {Error} If document ID is not set or document not found
340
+ */
341
+ editDID: (params: {id: string; name: string}) => Promise<void>;
342
+
343
+ /**
344
+ * Deletes a DID from the wallet
345
+ * @param {Object} params - Delete parameters
346
+ * @param {string} params.id - The ID of the DID document to delete
347
+ * @returns {Promise<void>}
348
+ * @throws {Error} If document ID is not set
349
+ */
350
+ deleteDID: (params: {id: string}) => Promise<void>;
351
+
352
+ /**
353
+ * Exports a DID and its correlated documents as an encrypted JSON
354
+ * @param {Object} params - Export parameters
355
+ * @param {string} params.id - The ID of the DID document to export
356
+ * @param {string} params.password - Password for encryption
357
+ * @returns {Promise<any>} Encrypted wallet JSON containing the DID and correlations
358
+ * @throws {Error} If DID document or keypair not found
359
+ */
360
+ exportDID: (params: {id: string; password: string}) => Promise<any>;
361
+
362
+ /**
363
+ * Retrieves all DIDs stored in the wallet
364
+ * @returns {Promise<any[]>} Array of DID resolution response documents
365
+ */
366
+ getAll: () => Promise<any>;
367
+
368
+ /**
369
+ * Retrieves all keypairs associated with DIDs in the wallet
370
+ * @returns {Promise<any[]>} Array of keypair documents
371
+ */
372
+ getDIDKeyPairs: () => Promise<any>;
373
+
374
+ /**
375
+ * Ensures at least one DID exists in the wallet, creating a default if none exist
376
+ * @returns {Promise<{keyDoc: any, didDocumentResolution: any}|void>} The created DID if one was created, undefined otherwise
377
+ */
378
+ ensureDID: () => Promise<any>;
379
+
380
+ /**
381
+ * Gets the default DID from the wallet (first DID if exists)
382
+ * @returns {Promise<string|undefined>} The default DID identifier or undefined if no DIDs exist
383
+ */
384
+ getDefaultDID: () => Promise<string>;
385
+ }
386
+
387
+ /**
388
+ * Interface for DIDComm message provider operations
389
+ * @interface IMessageProvider
390
+ * @description Provides a high-level API for DIDComm message management operations
391
+ */
392
+ export interface IMessageProvider {
393
+ /**
394
+ * Sends a DIDComm message to a recipient
395
+ * @memberof IMessageProvider
396
+ * @param {Object} params - Message parameters
397
+ * @param {string} [params.from] - Sender DID identifier
398
+ * @param {string} [params.to] - Recipient DID identifier
399
+ * @param {any} [params.message] - Message payload to send
400
+ * @param {string} [params.type] - DIDComm message type
401
+ * @param {string} [params.did] - @deprecated Use 'from' instead - Sender DID identifier
402
+ * @param {string} [params.recipientDid] - @deprecated Use 'to' instead - Recipient DID identifier
403
+ * @param {any} [params.body] - @deprecated Use 'message' instead - Message payload to send
404
+ * @returns {Promise<any>} Result of sending the message
405
+ * @throws {Error} If sender DID not found or message sending fails
406
+ * @example
407
+ * await messageProvider.sendMessage({
408
+ * from: 'did:key:sender123',
409
+ * to: 'did:key:recipient456',
410
+ * message: { hello: 'world' },
411
+ * type: 'basic-message'
412
+ * });
413
+ *
414
+ */
415
+ sendMessage: (params: {
416
+ from?: string;
417
+ to?: string;
418
+ message?: any;
419
+ type?: string;
420
+ /** @deprecated Use 'from' instead */
421
+ did?: string;
422
+ /** @deprecated Use 'to' instead */
423
+ recipientDid?: string;
424
+ /** @deprecated Use 'message' instead */
425
+ body?: any;
426
+ }) => Promise<any>;
427
+
428
+ /**
429
+ * Fetches new messages from the relay service
430
+ * @returns {Promise<void>}
431
+ * @throws {Error} If message fetching fails
432
+ */
433
+ fetchMessages: () => Promise<void>;
434
+
435
+ /**
436
+ * Processes stored DIDComm messages and decrypts them
437
+ * @returns {Promise<void>}
438
+ * @throws {Error} If message processing fails
439
+ */
440
+ processDIDCommMessages: () => Promise<void>;
441
+
442
+ /**
443
+ * Starts automatic message fetching at regular intervals
444
+ * @param {number} [timeout=2000] - Interval in milliseconds between fetch operations
445
+ * @returns {Function} Function to stop the auto-fetch process
446
+ */
447
+ startAutoFetch: (timeout?: number) => () => void;
448
+
449
+ /**
450
+ * Adds a listener for when messages are decrypted
451
+ * @param {Function} handler - Callback function to handle decrypted messages
452
+ * @returns {Function} Function to remove the listener
453
+ */
454
+ addMessageListener: (handler: (message: any) => void) => () => void;
455
+
456
+ /**
457
+ * Waits for the next incoming message
458
+ * @returns {Promise<any>} Promise that resolves with the next received message
459
+ */
460
+ waitForMessage: () => Promise<any>;
461
+
462
+ /**
463
+ * Marks a message as read and removes it from storage
464
+ * @param {string} messageId - The ID of the message to mark as read
465
+ * @returns {Promise<void>}
466
+ * @throws {Error} If message is not found or not a DIDComm message
467
+ */
468
+ markMessageAsRead: (messageId: string) => Promise<void>;
469
+
470
+ /**
471
+ * Clears all cached messages from the wallet
472
+ * @returns {Promise<void>}
473
+ */
474
+ clearCache: () => Promise<void>;
475
+
476
+ /**
477
+ * Starts the recurrent message processing job
478
+ * @returns {Promise<void>}
479
+ */
480
+ processMessageRecurrentJob: () => Promise<void>;
481
+
482
+ /**
483
+ * Stops all message fetching and processing timers
484
+ */
485
+ stop: () => void;
486
+ }
487
+
488
+ /**
489
+ * Interface for verifiable credential provider operations
490
+ * @interface ICredentialProvider
491
+ * @description Provides a high-level API for verifiable credential management operations
492
+ */
493
+ export interface ICredentialProvider {
494
+ /**
495
+ * Retrieves credentials from the wallet, optionally filtered by type
496
+ * @param {string} [type='VerifiableCredential'] - The credential type to filter by
497
+ * @returns {any[]} Array of credentials matching the specified type
498
+ * @example
499
+ * const allCredentials = credentialProvider.getCredentials();
500
+ * const certificates = credentialProvider.getCredentials('Certificate');
501
+ */
502
+ getCredentials: (type?: string) => any[];
503
+
504
+ /**
505
+ * Retrieves a credential by its ID
506
+ * @param {string} id - The unique identifier of the credential
507
+ * @returns {any} The credential document
508
+ * @throws {Error} If credential is not found
509
+ */
510
+ getById: (id: string) => any;
511
+
512
+ /**
513
+ * Gets the membership witness for a credential (used for BBS+ credentials)
514
+ * @param {any} credential - The credential to get the witness for
515
+ * @returns {Promise<any>} The membership witness data
516
+ */
517
+ getMembershipWitness: (credential: any) => Promise<any>;
518
+
519
+ /**
520
+ * Checks if a credential uses BBS+ signature
521
+ * @param {any} credential - The credential to check
522
+ * @returns {boolean} True if the credential uses BBS+ signature
523
+ */
524
+ isBBSPlusCredential: (credential: any) => boolean;
525
+
526
+ /**
527
+ * Validates a credential by verifying its cryptographic proof and status
528
+ * @param {any} credential - The credential to validate
529
+ * @param {boolean} [forceFetch=false] - Whether to force refresh the credential status
530
+ * @returns {Promise<{status: string, error?: string, warning?: string}>} Validation result
531
+ * @throws {Error} If validation fails
532
+ * @example
533
+ * const result = await credentialProvider.isValid(credential);
534
+ * if (result.status === 'verified') {
535
+ * console.log('Credential is valid');
536
+ * }
537
+ */
538
+ isValid: (credential: any, forceFetch?: boolean) => Promise<{
539
+ status: string;
540
+ error?: string;
541
+ warning?: string;
542
+ }>;
543
+
544
+ /**
545
+ * Adds a credential to the wallet
546
+ * @param {any} credential - The credential to add
547
+ * @returns {Promise<any>} The added credential document
548
+ * @example
549
+ * const addedCredential = await credentialProvider.addCredential(myCredential);
550
+ */
551
+ addCredential: (credential: any) => Promise<any>;
552
+
553
+ /**
554
+ * Imports a credential from a URI (supports OpenID credential offers)
555
+ * @param {Object} params - Import parameters
556
+ * @param {string} params.uri - The URI containing the credential offer
557
+ * @param {any} params.didProvider - DID provider instance for key management
558
+ * @param {Function} [params.getAuthCode] - Optional callback to handle authorization
559
+ * @returns {Promise<any>} The imported credential
560
+ * @throws {Error} If import fails
561
+ */
562
+ importCredentialFromURI: (params: {
563
+ uri: string;
564
+ didProvider: any;
565
+ getAuthCode?: (authorizationURL: string) => Promise<string>;
566
+ }) => Promise<any>;
567
+
568
+ /**
569
+ * Synchronizes credential status from the blockchain
570
+ * @param {Object} params - Sync parameters
571
+ * @param {string[]} [params.credentialIds] - Optional list of credential IDs to sync
572
+ * @param {boolean} [params.forceFetch=false] - Whether to force refresh from blockchain
573
+ * @returns {Promise<any[]>} Array of credential status documents
574
+ */
575
+ syncCredentialStatus: (params: {
576
+ credentialIds?: string[];
577
+ forceFetch?: boolean;
578
+ }) => Promise<any[]>;
579
+
580
+ /**
581
+ * Gets the current status of a credential (cached, fast operation)
582
+ * @param {any} credential - The credential to check
583
+ * @returns {Promise<{status: string, error?: string}>} Current credential status
584
+ */
585
+ getCredentialStatus: (credential: any) => Promise<{status: string; error?: string}>;
586
+
587
+ /**
588
+ * Removes a credential and all its related documents from the wallet
589
+ * @param {any} credential - The credential to remove
590
+ * @returns {Promise<void>}
591
+ * @throws {Error} If credential is not found
592
+ */
593
+ removeCredential: (credential: any) => Promise<void>;
594
+ }
595
+
596
+ /**
597
+ * Configuration options for biometric provider operations
598
+ * @typedef {Object} BiometricsProviderConfigs
599
+ * @template E - Type for IDV-specific configurations
600
+ * @property {string} enrollmentCredentialType - The credential type used for biometric enrollment
601
+ * @property {string} biometricMatchCredentialType - The credential type used for biometric matching
602
+ * @property {E} idvConfigs - IDV provider-specific configuration options
603
+ */
604
+ export type BiometricsProviderConfigs<E> = {
605
+ enrollmentCredentialType: string;
606
+ biometricMatchCredentialType: string;
607
+ idvConfigs: E;
608
+ };
609
+
610
+ /**
611
+ * Options for IDV (Identity Verification) process callbacks
612
+ * @interface IDVProcessOptions
613
+ * @description Callback functions for handling different stages of the identity verification process
614
+ */
615
+ export interface IDVProcessOptions {
616
+ /**
617
+ * Called when a deep link is triggered during IDV process
618
+ */
619
+ onDeepLink?: () => void;
620
+
621
+ /**
622
+ * Called when a message is received during IDV process
623
+ */
624
+ onMessage?: () => void;
625
+
626
+ /**
627
+ * Called when an error occurs during IDV process
628
+ * @param {Error} error - The error that occurred
629
+ */
630
+ onError?: (error: Error) => void;
631
+
632
+ /**
633
+ * Called when the IDV process is cancelled
634
+ */
635
+ onCancel?: () => void;
636
+
637
+ /**
638
+ * Called when the IDV process completes successfully
639
+ * @param {any} credential - The credential issued upon completion
640
+ */
641
+ onComplete?: (credential: any) => void;
642
+ }
643
+
644
+ /**
645
+ * Interface for biometric plugin implementations
646
+ * @interface BiometricPlugin
647
+ * @description Defines the contract for biometric enrollment and matching operations
648
+ */
649
+ export interface BiometricPlugin {
650
+ /**
651
+ * Performs biometric enrollment for a wallet DID
652
+ * @param {string} walletDID - The DID of the wallet to enroll
653
+ * @returns {Promise<any>} The enrollment result document
654
+ * @throws {Error} If enrollment fails
655
+ */
656
+ onEnroll: (walletDID: string) => Promise<any>;
657
+
658
+ /**
659
+ * Performs biometric matching against an enrollment credential
660
+ * @param {string} walletDID - The DID of the wallet performing the match
661
+ * @param {any} enrollmentCredential - The enrollment credential to match against
662
+ * @returns {Promise<any>} The matching result document
663
+ * @throws {Error} If matching fails
664
+ */
665
+ onMatch: (walletDID: string, enrollmentCredential: any) => Promise<any>;
666
+ }
667
+
668
+ /**
669
+ * Interface for IDV (Identity Verification) provider implementations
670
+ * @interface IDVProvider
671
+ * @description Defines the contract for identity verification operations
672
+ */
673
+ export interface IDVProvider {
674
+ /**
675
+ * Enrolls a user with biometric data and issues credentials
676
+ * @param {string} walletDID - The DID of the wallet to enroll
677
+ * @param {any} proofRequest - The proof request for enrollment
678
+ * @returns {Promise<{enrollmentCredential: any, matchCredential: any}>} Both enrollment and match credentials
679
+ * @throws {Error} If enrollment fails
680
+ */
681
+ enroll: (
682
+ walletDID: string,
683
+ proofRequest: any,
684
+ ) => Promise<{enrollmentCredential: any; matchCredential: any}>;
685
+
686
+ /**
687
+ * Matches biometric data against an enrollment credential
688
+ * @param {string} walletDID - The DID of the wallet performing the match
689
+ * @param {any} enrollmentCredential - The enrollment credential to match against
690
+ * @param {any} proofRequest - The proof request for matching
691
+ * @returns {Promise<{matchCredential: any}>} The match credential
692
+ * @throws {Error} If matching fails
693
+ */
694
+ match: (
695
+ walletDID: string,
696
+ enrollmentCredential: any,
697
+ proofRequest: any,
698
+ ) => Promise<{matchCredential: any}>;
699
+ }
700
+
701
+ /**
702
+ * Factory interface for creating IDV provider instances
703
+ * @interface IDVProviderFactory
704
+ * @description Creates IDV provider instances with proper event handling and wallet integration
705
+ */
706
+ export interface IDVProviderFactory {
707
+ /**
708
+ * Creates an IDV provider instance
709
+ * @param {EventEmitter} eventEmitter - Event emitter for IDV process events
710
+ * @param {IWallet} wallet - The wallet instance for credential storage
711
+ * @returns {IDVProvider} A configured IDV provider instance
712
+ */
713
+ create: (eventEmitter: EventEmitter, wallet: IWallet) => IDVProvider;
714
+ }
715
+
716
+ /**
717
+ * Interface for biometric provider operations
718
+ * @interface IBiometricProvider
719
+ * @description Provides a high-level API for biometric identity verification operations
720
+ */
721
+ export interface IBiometricProvider {
722
+ /**
723
+ * Starts the identity verification process
724
+ * @param {any} proofRequest - The proof request to fulfill through IDV
725
+ * @returns {Promise<{enrollmentCredential: any, matchCredential: any}>} The enrollment and match credentials
726
+ * @throws {Error} If IDV process fails
727
+ */
728
+ startIDV: (proofRequest: any) => Promise<{
729
+ enrollmentCredential: any;
730
+ matchCredential: any;
731
+ }>;
732
+
733
+ /**
734
+ * Event emitter for IDV process events
735
+ * @type {EventEmitter}
736
+ */
737
+ eventEmitter: EventEmitter;
738
+ }