@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
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QR Code Handler Types
|
|
3
|
+
*
|
|
4
|
+
* This module provides interfaces and types for building a generic,
|
|
5
|
+
* extensible QR code handler system that can process various types
|
|
6
|
+
* of QR codes in a decentralized identity wallet.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Context object containing parsed QR code data and metadata
|
|
10
|
+
*
|
|
11
|
+
* @interface QRCodeContext
|
|
12
|
+
*/
|
|
13
|
+
export interface QRCodeContext {
|
|
14
|
+
/**
|
|
15
|
+
* Raw scanned QR code data string
|
|
16
|
+
*/
|
|
17
|
+
data: string;
|
|
18
|
+
/**
|
|
19
|
+
* Parsed JSON data if the QR code contained JSON,
|
|
20
|
+
* or data fetched from a URL if the QR code was a URL
|
|
21
|
+
*/
|
|
22
|
+
jsonData?: any;
|
|
23
|
+
/**
|
|
24
|
+
* Original URL if the scanned data was a valid URL
|
|
25
|
+
*/
|
|
26
|
+
url?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Modified URL after processing (e.g., with authentication parameters added)
|
|
29
|
+
*/
|
|
30
|
+
parsedUrl?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Additional metadata that can be attached by context preparation
|
|
33
|
+
* or handlers for passing data between handlers
|
|
34
|
+
*/
|
|
35
|
+
metadata?: Record<string, any>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Result returned by a QR code handler after processing
|
|
39
|
+
*
|
|
40
|
+
* @interface QRCodeHandlerResult
|
|
41
|
+
*/
|
|
42
|
+
export interface QRCodeHandlerResult {
|
|
43
|
+
/**
|
|
44
|
+
* Whether the handler successfully processed the QR code data
|
|
45
|
+
*/
|
|
46
|
+
success: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Optional data returned by the handler
|
|
49
|
+
* Can be credentials, presentation requests, or any other processed data
|
|
50
|
+
*/
|
|
51
|
+
data?: any;
|
|
52
|
+
/**
|
|
53
|
+
* Error object if processing failed
|
|
54
|
+
*/
|
|
55
|
+
error?: Error;
|
|
56
|
+
/**
|
|
57
|
+
* Additional metadata about the processing result
|
|
58
|
+
*/
|
|
59
|
+
metadata?: Record<string, any>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Handler interface for processing specific types of QR codes
|
|
63
|
+
*
|
|
64
|
+
* Handlers are responsible for:
|
|
65
|
+
* 1. Identifying if they can process the QR code (canHandle)
|
|
66
|
+
* 2. Processing the QR code data (handle)
|
|
67
|
+
*
|
|
68
|
+
* @interface QRCodeHandler
|
|
69
|
+
*/
|
|
70
|
+
export interface QRCodeHandler {
|
|
71
|
+
/**
|
|
72
|
+
* Unique identifier for this handler
|
|
73
|
+
* Used for registration, unregistration, and debugging
|
|
74
|
+
*/
|
|
75
|
+
id: string;
|
|
76
|
+
/**
|
|
77
|
+
* Priority for handler execution (lower number = higher priority)
|
|
78
|
+
* Handlers are executed in priority order until one successfully handles the data
|
|
79
|
+
*
|
|
80
|
+
* @default 100
|
|
81
|
+
*/
|
|
82
|
+
priority?: number;
|
|
83
|
+
/**
|
|
84
|
+
* Check if this handler can process the given QR code data
|
|
85
|
+
*
|
|
86
|
+
* This method should be fast and only do basic checks (string matching, type checking)
|
|
87
|
+
* without performing expensive operations like network requests.
|
|
88
|
+
*
|
|
89
|
+
* @param context - The QR code context containing parsed data
|
|
90
|
+
* @returns True if this handler can process the data, false otherwise
|
|
91
|
+
*/
|
|
92
|
+
canHandle(context: QRCodeContext): boolean | Promise<boolean>;
|
|
93
|
+
/**
|
|
94
|
+
* Process the QR code data
|
|
95
|
+
*
|
|
96
|
+
* This method is only called if canHandle returns true.
|
|
97
|
+
* It should perform the actual processing logic (navigation, API calls, etc.)
|
|
98
|
+
*
|
|
99
|
+
* @param context - The QR code context containing parsed data
|
|
100
|
+
* @returns Result of the processing including success status and any data/errors
|
|
101
|
+
*/
|
|
102
|
+
handle(context: QRCodeContext): Promise<QRCodeHandlerResult>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Options for processing QR codes
|
|
106
|
+
*
|
|
107
|
+
* @interface ProcessOptions
|
|
108
|
+
*/
|
|
109
|
+
export interface ProcessOptions {
|
|
110
|
+
/**
|
|
111
|
+
* Timeout in milliseconds for processing
|
|
112
|
+
* If a handler takes longer than this, it will be skipped
|
|
113
|
+
*
|
|
114
|
+
* @default 30000 (30 seconds)
|
|
115
|
+
*/
|
|
116
|
+
timeout?: number;
|
|
117
|
+
/**
|
|
118
|
+
* Whether to stop processing after the first successful handler
|
|
119
|
+
* If false, all handlers will be tried even after one succeeds
|
|
120
|
+
*
|
|
121
|
+
* @default true
|
|
122
|
+
*/
|
|
123
|
+
stopOnFirstSuccess?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Custom context preparation function
|
|
126
|
+
*
|
|
127
|
+
* This function is called before any handlers to prepare the context
|
|
128
|
+
* from the raw scanned data. It can fetch data from URLs, parse JSON,
|
|
129
|
+
* add metadata, etc.
|
|
130
|
+
*
|
|
131
|
+
* @param data - Raw QR code data string
|
|
132
|
+
* @returns Prepared context object
|
|
133
|
+
*/
|
|
134
|
+
prepareContext?: (data: string) => Promise<QRCodeContext>;
|
|
135
|
+
/**
|
|
136
|
+
* Error handler callback
|
|
137
|
+
*
|
|
138
|
+
* Called when a handler throws an error during processing.
|
|
139
|
+
* Useful for logging, analytics, or custom error handling.
|
|
140
|
+
*
|
|
141
|
+
* @param error - The error that was thrown
|
|
142
|
+
* @param handler - The handler that threw the error
|
|
143
|
+
*/
|
|
144
|
+
onError?: (error: Error, handler: QRCodeHandler) => void;
|
|
145
|
+
/**
|
|
146
|
+
* Success callback
|
|
147
|
+
*
|
|
148
|
+
* Called when a handler successfully processes the QR code.
|
|
149
|
+
* Useful for logging, analytics, or side effects.
|
|
150
|
+
*
|
|
151
|
+
* @param result - The result returned by the handler
|
|
152
|
+
* @param handler - The handler that processed the data
|
|
153
|
+
*/
|
|
154
|
+
onSuccess?: (result: QRCodeHandlerResult, handler: QRCodeHandler) => void;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Main processor interface for managing and executing QR code handlers
|
|
158
|
+
*
|
|
159
|
+
* @interface QRCodeProcessor
|
|
160
|
+
*/
|
|
161
|
+
export interface QRCodeProcessor {
|
|
162
|
+
/**
|
|
163
|
+
* Register a new QR code handler
|
|
164
|
+
*
|
|
165
|
+
* @param handler - The handler to register
|
|
166
|
+
* @throws Error if a handler with the same ID is already registered
|
|
167
|
+
*/
|
|
168
|
+
registerHandler(handler: QRCodeHandler): void;
|
|
169
|
+
/**
|
|
170
|
+
* Unregister a QR code handler by its ID
|
|
171
|
+
*
|
|
172
|
+
* @param id - The ID of the handler to unregister
|
|
173
|
+
* @returns True if the handler was found and removed, false otherwise
|
|
174
|
+
*/
|
|
175
|
+
unregisterHandler(id: string): boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Get all registered handlers sorted by priority
|
|
178
|
+
*
|
|
179
|
+
* @returns Array of registered handlers sorted by priority (lowest first)
|
|
180
|
+
*/
|
|
181
|
+
getHandlers(): QRCodeHandler[];
|
|
182
|
+
/**
|
|
183
|
+
* Get a specific handler by its ID
|
|
184
|
+
*
|
|
185
|
+
* @param id - The ID of the handler to retrieve
|
|
186
|
+
* @returns The handler if found, undefined otherwise
|
|
187
|
+
*/
|
|
188
|
+
getHandler(id: string): QRCodeHandler | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* Process QR code data through registered handlers
|
|
191
|
+
*
|
|
192
|
+
* Handlers are executed in priority order until one successfully
|
|
193
|
+
* processes the data (or all handlers are tried if stopOnFirstSuccess is false)
|
|
194
|
+
*
|
|
195
|
+
* @param data - Raw QR code data string
|
|
196
|
+
* @param options - Processing options
|
|
197
|
+
* @returns Result of the processing
|
|
198
|
+
*/
|
|
199
|
+
process(data: string, options?: ProcessOptions): Promise<QRCodeHandlerResult>;
|
|
200
|
+
/**
|
|
201
|
+
* Clear all registered handlers
|
|
202
|
+
*/
|
|
203
|
+
clearHandlers(): void;
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/qr-handlers/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,QAAQ,CAAC,EAAE,GAAG,CAAC;IAEf;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,IAAI,CAAC,EAAE,GAAG,CAAC;IAEX;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IAEd;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;;OAQG;IACH,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,C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
* extensible QR code handler system that can process various types
|
|
7
|
+
* of QR codes in a decentralized identity wallet.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/qr-handlers/types.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
|