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