claim169 0.1.0-alpha
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/README.md +392 -0
- package/dist/index.d.ts +319 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +582 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +476 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +29 -0
- package/dist/types.js.map +1 -0
- package/package.json +53 -0
- package/wasm/README.md +264 -0
- package/wasm/claim169_wasm.d.ts +99 -0
- package/wasm/claim169_wasm.js +9 -0
- package/wasm/claim169_wasm_bg.js +822 -0
- package/wasm/claim169_wasm_bg.wasm +0 -0
- package/wasm/claim169_wasm_bg.wasm.d.ts +36 -0
- package/wasm/package.json +19 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for MOSIP Claim 169 QR Code decoder.
|
|
3
|
+
*
|
|
4
|
+
* This module contains TypeScript interfaces and types for the decoded
|
|
5
|
+
* Claim 169 identity data.
|
|
6
|
+
*
|
|
7
|
+
* @module claim169/types
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* A single biometric data entry from a Claim 169 credential.
|
|
11
|
+
*
|
|
12
|
+
* Biometric data can be fingerprints, iris scans, face images, or voice samples.
|
|
13
|
+
* Each entry contains the raw data and metadata about its format.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Access face biometric data
|
|
18
|
+
* if (claim.face && claim.face.length > 0) {
|
|
19
|
+
* const faceData = claim.face[0];
|
|
20
|
+
* console.log(`Format: ${faceData.format}`);
|
|
21
|
+
* console.log(`Data size: ${faceData.data.byteLength} bytes`);
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export interface Biometric {
|
|
26
|
+
/** Raw biometric data bytes (image, template, or audio) */
|
|
27
|
+
data: Uint8Array;
|
|
28
|
+
/**
|
|
29
|
+
* Biometric format code:
|
|
30
|
+
* - 0: Image
|
|
31
|
+
* - 1: Template
|
|
32
|
+
* - 2: Sound
|
|
33
|
+
* - 3: BioHash
|
|
34
|
+
*/
|
|
35
|
+
format: number;
|
|
36
|
+
/**
|
|
37
|
+
* Sub-format code (depends on format type):
|
|
38
|
+
* - For Image: 0=PNG, 1=JPEG, 2=JPEG2000, 3=AVIF, 4=WebP, 5=TIFF, 6=WSQ
|
|
39
|
+
* - For Template: 0=ANSI378, 1=ISO19794-2, 2=NIST
|
|
40
|
+
* - For Sound: 0=WAV, 1=MP3
|
|
41
|
+
*/
|
|
42
|
+
subFormat?: number;
|
|
43
|
+
/** Biometric data issuer/provider identifier */
|
|
44
|
+
issuer?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* CWT (CBOR Web Token) metadata from the credential.
|
|
48
|
+
*
|
|
49
|
+
* Contains standard JWT/CWT claims that provide information about the
|
|
50
|
+
* credential's validity, issuer, and subject.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* // Check if credential is expired
|
|
55
|
+
* const now = Math.floor(Date.now() / 1000);
|
|
56
|
+
* if (result.cwtMeta.expiresAt && result.cwtMeta.expiresAt < now) {
|
|
57
|
+
* console.log('Credential has expired!');
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
60
|
+
* // Check issuer
|
|
61
|
+
* if (result.cwtMeta.issuer === 'https://mosip.io') {
|
|
62
|
+
* console.log('Issued by MOSIP');
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export interface CwtMeta {
|
|
67
|
+
/** Token issuer (typically a URL or identifier) */
|
|
68
|
+
issuer?: string;
|
|
69
|
+
/** Token subject (typically the credential holder's ID) */
|
|
70
|
+
subject?: string;
|
|
71
|
+
/** Expiration timestamp (Unix seconds) - credential invalid after this time */
|
|
72
|
+
expiresAt?: number;
|
|
73
|
+
/** Not-before timestamp (Unix seconds) - credential invalid before this time */
|
|
74
|
+
notBefore?: number;
|
|
75
|
+
/** Issued-at timestamp (Unix seconds) - when the credential was created */
|
|
76
|
+
issuedAt?: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Decoded Claim 169 identity data.
|
|
80
|
+
*
|
|
81
|
+
* This interface contains all identity fields defined in the MOSIP Claim 169
|
|
82
|
+
* specification. All fields are optional since credentials may contain only
|
|
83
|
+
* a subset of the available fields.
|
|
84
|
+
*
|
|
85
|
+
* Fields are organized into:
|
|
86
|
+
* - **Demographics** (id, name, DOB, address, etc.)
|
|
87
|
+
* - **Biometrics** (fingerprints, iris, face, voice)
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* // Access demographic data
|
|
92
|
+
* console.log(`Name: ${claim.fullName}`);
|
|
93
|
+
* console.log(`DOB: ${claim.dateOfBirth}`);
|
|
94
|
+
*
|
|
95
|
+
* // Check for biometrics
|
|
96
|
+
* const hasFace = claim.face && claim.face.length > 0;
|
|
97
|
+
* const hasFingerprints = claim.rightThumb || claim.leftThumb;
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export interface Claim169 {
|
|
101
|
+
/** Unique identifier (CBOR key 1) */
|
|
102
|
+
id?: string;
|
|
103
|
+
/** Claim version */
|
|
104
|
+
version?: string;
|
|
105
|
+
/** Primary language code */
|
|
106
|
+
language?: string;
|
|
107
|
+
/** Full name */
|
|
108
|
+
fullName?: string;
|
|
109
|
+
/** First name */
|
|
110
|
+
firstName?: string;
|
|
111
|
+
/** Middle name */
|
|
112
|
+
middleName?: string;
|
|
113
|
+
/** Last name */
|
|
114
|
+
lastName?: string;
|
|
115
|
+
/** Date of birth (ISO 8601 format) */
|
|
116
|
+
dateOfBirth?: string;
|
|
117
|
+
/** Gender code (1=Male, 2=Female, 3=Other) */
|
|
118
|
+
gender?: number;
|
|
119
|
+
/** Address */
|
|
120
|
+
address?: string;
|
|
121
|
+
/** Email address */
|
|
122
|
+
email?: string;
|
|
123
|
+
/** Phone number */
|
|
124
|
+
phone?: string;
|
|
125
|
+
/** Nationality */
|
|
126
|
+
nationality?: string;
|
|
127
|
+
/** Marital status code */
|
|
128
|
+
maritalStatus?: number;
|
|
129
|
+
/** Guardian name */
|
|
130
|
+
guardian?: string;
|
|
131
|
+
/** Photo data */
|
|
132
|
+
photo?: Uint8Array;
|
|
133
|
+
/** Photo format code */
|
|
134
|
+
photoFormat?: number;
|
|
135
|
+
/** Best quality fingers indicator */
|
|
136
|
+
bestQualityFingers?: Uint8Array;
|
|
137
|
+
/** Secondary full name */
|
|
138
|
+
secondaryFullName?: string;
|
|
139
|
+
/** Secondary language code */
|
|
140
|
+
secondaryLanguage?: string;
|
|
141
|
+
/** Location code */
|
|
142
|
+
locationCode?: string;
|
|
143
|
+
/** Legal status */
|
|
144
|
+
legalStatus?: string;
|
|
145
|
+
/** Country of issuance */
|
|
146
|
+
countryOfIssuance?: string;
|
|
147
|
+
/** Right thumb biometrics */
|
|
148
|
+
rightThumb?: Biometric[];
|
|
149
|
+
/** Right pointer finger biometrics */
|
|
150
|
+
rightPointerFinger?: Biometric[];
|
|
151
|
+
/** Right middle finger biometrics */
|
|
152
|
+
rightMiddleFinger?: Biometric[];
|
|
153
|
+
/** Right ring finger biometrics */
|
|
154
|
+
rightRingFinger?: Biometric[];
|
|
155
|
+
/** Right little finger biometrics */
|
|
156
|
+
rightLittleFinger?: Biometric[];
|
|
157
|
+
/** Left thumb biometrics */
|
|
158
|
+
leftThumb?: Biometric[];
|
|
159
|
+
/** Left pointer finger biometrics */
|
|
160
|
+
leftPointerFinger?: Biometric[];
|
|
161
|
+
/** Left middle finger biometrics */
|
|
162
|
+
leftMiddleFinger?: Biometric[];
|
|
163
|
+
/** Left ring finger biometrics */
|
|
164
|
+
leftRingFinger?: Biometric[];
|
|
165
|
+
/** Left little finger biometrics */
|
|
166
|
+
leftLittleFinger?: Biometric[];
|
|
167
|
+
/** Right iris biometrics */
|
|
168
|
+
rightIris?: Biometric[];
|
|
169
|
+
/** Left iris biometrics */
|
|
170
|
+
leftIris?: Biometric[];
|
|
171
|
+
/** Face biometrics */
|
|
172
|
+
face?: Biometric[];
|
|
173
|
+
/** Right palm biometrics */
|
|
174
|
+
rightPalm?: Biometric[];
|
|
175
|
+
/** Left palm biometrics */
|
|
176
|
+
leftPalm?: Biometric[];
|
|
177
|
+
/** Voice biometrics */
|
|
178
|
+
voice?: Biometric[];
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Signature verification status of the decoded credential.
|
|
182
|
+
*
|
|
183
|
+
* - `"verified"`: Signature was verified successfully with the provided public key
|
|
184
|
+
* - `"skipped"`: Verification was explicitly skipped using `allowUnverified()`
|
|
185
|
+
* - `"failed"`: Signature verification failed (invalid signature or wrong key)
|
|
186
|
+
*/
|
|
187
|
+
export type VerificationStatus = "verified" | "skipped" | "failed";
|
|
188
|
+
/**
|
|
189
|
+
* Result of decoding a Claim 169 QR code.
|
|
190
|
+
*
|
|
191
|
+
* Contains the decoded identity data, CWT metadata, and verification status.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* // Decode with verification
|
|
196
|
+
* const result = new Decoder(qrText)
|
|
197
|
+
* .verifyWithEd25519(publicKey)
|
|
198
|
+
* .decode();
|
|
199
|
+
*
|
|
200
|
+
* // Access identity data
|
|
201
|
+
* console.log(result.claim169.fullName);
|
|
202
|
+
*
|
|
203
|
+
* // Access metadata
|
|
204
|
+
* console.log(result.cwtMeta.issuer);
|
|
205
|
+
*
|
|
206
|
+
* // Check verification status
|
|
207
|
+
* console.log(result.verificationStatus); // "verified", "skipped", or "failed"
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
export interface DecodeResult {
|
|
211
|
+
/** Decoded Claim 169 identity data */
|
|
212
|
+
claim169: Claim169;
|
|
213
|
+
/** CWT metadata (issuer, expiration, etc.) */
|
|
214
|
+
cwtMeta: CwtMeta;
|
|
215
|
+
/**
|
|
216
|
+
* Signature verification status.
|
|
217
|
+
* - "verified": Signature verified successfully with provided public key
|
|
218
|
+
* - "skipped": Verification skipped (allowUnverified() or decode(..., { allowUnverified: true }))
|
|
219
|
+
* - "failed": Signature verification failed
|
|
220
|
+
*/
|
|
221
|
+
verificationStatus: VerificationStatus;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Error thrown when decoding fails.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* try {
|
|
229
|
+
* decode(qrText, { allowUnverified: true }); // testing only
|
|
230
|
+
* } catch (error) {
|
|
231
|
+
* if (error instanceof Claim169Error) {
|
|
232
|
+
* console.error('Decoding failed:', error.message);
|
|
233
|
+
* }
|
|
234
|
+
* }
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
export declare class Claim169Error extends Error {
|
|
238
|
+
constructor(message: string);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Input data for creating a Claim 169 credential.
|
|
242
|
+
*
|
|
243
|
+
* This interface contains all identity fields that can be encoded into
|
|
244
|
+
* a Claim 169 QR code.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```typescript
|
|
248
|
+
* const claim169: Claim169Input = {
|
|
249
|
+
* id: "123456789",
|
|
250
|
+
* fullName: "John Doe",
|
|
251
|
+
* dateOfBirth: "1990-01-15",
|
|
252
|
+
* gender: 1, // Male
|
|
253
|
+
* };
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
export interface Claim169Input {
|
|
257
|
+
/** Unique identifier */
|
|
258
|
+
id?: string;
|
|
259
|
+
/** Claim version */
|
|
260
|
+
version?: string;
|
|
261
|
+
/** Primary language code */
|
|
262
|
+
language?: string;
|
|
263
|
+
/** Full name */
|
|
264
|
+
fullName?: string;
|
|
265
|
+
/** First name */
|
|
266
|
+
firstName?: string;
|
|
267
|
+
/** Middle name */
|
|
268
|
+
middleName?: string;
|
|
269
|
+
/** Last name */
|
|
270
|
+
lastName?: string;
|
|
271
|
+
/** Date of birth (ISO 8601 format) */
|
|
272
|
+
dateOfBirth?: string;
|
|
273
|
+
/** Gender code (1=Male, 2=Female, 3=Other) */
|
|
274
|
+
gender?: number;
|
|
275
|
+
/** Address */
|
|
276
|
+
address?: string;
|
|
277
|
+
/** Email address */
|
|
278
|
+
email?: string;
|
|
279
|
+
/** Phone number */
|
|
280
|
+
phone?: string;
|
|
281
|
+
/** Nationality */
|
|
282
|
+
nationality?: string;
|
|
283
|
+
/** Marital status code (1=Unmarried, 2=Married, 3=Divorced) */
|
|
284
|
+
maritalStatus?: number;
|
|
285
|
+
/** Guardian name */
|
|
286
|
+
guardian?: string;
|
|
287
|
+
/** Photo data */
|
|
288
|
+
photo?: Uint8Array;
|
|
289
|
+
/** Photo format code (1=JPEG, 2=JPEG2000, 3=AVIF, 4=WebP) */
|
|
290
|
+
photoFormat?: number;
|
|
291
|
+
/** Secondary full name */
|
|
292
|
+
secondaryFullName?: string;
|
|
293
|
+
/** Secondary language code */
|
|
294
|
+
secondaryLanguage?: string;
|
|
295
|
+
/** Location code */
|
|
296
|
+
locationCode?: string;
|
|
297
|
+
/** Legal status */
|
|
298
|
+
legalStatus?: string;
|
|
299
|
+
/** Country of issuance */
|
|
300
|
+
countryOfIssuance?: string;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* CWT metadata input for creating a Claim 169 credential.
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* ```typescript
|
|
307
|
+
* const cwtMeta: CwtMetaInput = {
|
|
308
|
+
* issuer: "https://issuer.example.com",
|
|
309
|
+
* expiresAt: 1800000000, // Unix timestamp
|
|
310
|
+
* };
|
|
311
|
+
* ```
|
|
312
|
+
*/
|
|
313
|
+
export interface CwtMetaInput {
|
|
314
|
+
/** Token issuer (typically a URL or identifier) */
|
|
315
|
+
issuer?: string;
|
|
316
|
+
/** Token subject (typically the credential holder's ID) */
|
|
317
|
+
subject?: string;
|
|
318
|
+
/** Expiration timestamp (Unix seconds) */
|
|
319
|
+
expiresAt?: number;
|
|
320
|
+
/** Not-before timestamp (Unix seconds) */
|
|
321
|
+
notBefore?: number;
|
|
322
|
+
/** Issued-at timestamp (Unix seconds) */
|
|
323
|
+
issuedAt?: number;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Interface for the Encoder builder class.
|
|
327
|
+
*
|
|
328
|
+
* Provides a fluent API for configuring and encoding Claim 169 credentials.
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```typescript
|
|
332
|
+
* const qrData = new Encoder(claim169, cwtMeta)
|
|
333
|
+
* .signWithEd25519(privateKey)
|
|
334
|
+
* .encode();
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
export interface IEncoder {
|
|
338
|
+
/**
|
|
339
|
+
* Sign with Ed25519 private key.
|
|
340
|
+
* @param privateKey - 32-byte Ed25519 private key
|
|
341
|
+
* @returns The encoder instance for chaining
|
|
342
|
+
*/
|
|
343
|
+
signWithEd25519(privateKey: Uint8Array): IEncoder;
|
|
344
|
+
/**
|
|
345
|
+
* Sign with ECDSA P-256 private key.
|
|
346
|
+
* @param privateKey - 32-byte ECDSA P-256 private key (scalar)
|
|
347
|
+
* @returns The encoder instance for chaining
|
|
348
|
+
*/
|
|
349
|
+
signWithEcdsaP256(privateKey: Uint8Array): IEncoder;
|
|
350
|
+
/**
|
|
351
|
+
* Encrypt with AES-256-GCM.
|
|
352
|
+
* @param key - 32-byte AES-256 key
|
|
353
|
+
* @returns The encoder instance for chaining
|
|
354
|
+
*/
|
|
355
|
+
encryptWithAes256(key: Uint8Array): IEncoder;
|
|
356
|
+
/**
|
|
357
|
+
* Encrypt with AES-128-GCM.
|
|
358
|
+
* @param key - 16-byte AES-128 key
|
|
359
|
+
* @returns The encoder instance for chaining
|
|
360
|
+
*/
|
|
361
|
+
encryptWithAes128(key: Uint8Array): IEncoder;
|
|
362
|
+
/**
|
|
363
|
+
* Allow encoding without a signature.
|
|
364
|
+
* WARNING: Unsigned credentials cannot be verified. Use for testing only.
|
|
365
|
+
* @returns The encoder instance for chaining
|
|
366
|
+
*/
|
|
367
|
+
allowUnsigned(): IEncoder;
|
|
368
|
+
/**
|
|
369
|
+
* Skip biometric fields during encoding.
|
|
370
|
+
* @returns The encoder instance for chaining
|
|
371
|
+
*/
|
|
372
|
+
skipBiometrics(): IEncoder;
|
|
373
|
+
/**
|
|
374
|
+
* Encode the credential to a Base45 QR string.
|
|
375
|
+
* @returns Base45-encoded string suitable for QR code generation
|
|
376
|
+
* @throws {Claim169Error} If encoding fails
|
|
377
|
+
*/
|
|
378
|
+
encode(): string;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Interface for the Decoder builder class.
|
|
382
|
+
*
|
|
383
|
+
* Provides a fluent API for configuring and decoding Claim 169 QR codes.
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* ```typescript
|
|
387
|
+
* // With verification (recommended)
|
|
388
|
+
* const result = new Decoder(qrText)
|
|
389
|
+
* .verifyWithEd25519(publicKey)
|
|
390
|
+
* .decode();
|
|
391
|
+
*
|
|
392
|
+
* // Without verification (testing only)
|
|
393
|
+
* const result = new Decoder(qrText)
|
|
394
|
+
* .allowUnverified()
|
|
395
|
+
* .skipBiometrics()
|
|
396
|
+
* .decode();
|
|
397
|
+
*
|
|
398
|
+
* // With decryption and verification
|
|
399
|
+
* const result = new Decoder(qrText)
|
|
400
|
+
* .decryptWithAes256(aesKey)
|
|
401
|
+
* .verifyWithEd25519(publicKey)
|
|
402
|
+
* .decode();
|
|
403
|
+
* ```
|
|
404
|
+
*/
|
|
405
|
+
export interface IDecoder {
|
|
406
|
+
/**
|
|
407
|
+
* Verify signature with Ed25519 public key.
|
|
408
|
+
* @param publicKey - 32-byte Ed25519 public key
|
|
409
|
+
* @returns The decoder instance for chaining
|
|
410
|
+
* @throws {Claim169Error} If the public key is invalid
|
|
411
|
+
*/
|
|
412
|
+
verifyWithEd25519(publicKey: Uint8Array): IDecoder;
|
|
413
|
+
/**
|
|
414
|
+
* Verify signature with ECDSA P-256 public key.
|
|
415
|
+
* @param publicKey - SEC1-encoded P-256 public key (33 or 65 bytes)
|
|
416
|
+
* @returns The decoder instance for chaining
|
|
417
|
+
* @throws {Claim169Error} If the public key is invalid
|
|
418
|
+
*/
|
|
419
|
+
verifyWithEcdsaP256(publicKey: Uint8Array): IDecoder;
|
|
420
|
+
/**
|
|
421
|
+
* Allow decoding without signature verification.
|
|
422
|
+
* WARNING: Unverified credentials cannot be trusted. Use for testing only.
|
|
423
|
+
* @returns The decoder instance for chaining
|
|
424
|
+
*/
|
|
425
|
+
allowUnverified(): IDecoder;
|
|
426
|
+
/**
|
|
427
|
+
* Decrypt with AES-256-GCM.
|
|
428
|
+
* @param key - 32-byte AES-256 key
|
|
429
|
+
* @returns The decoder instance for chaining
|
|
430
|
+
* @throws {Claim169Error} If the key is invalid
|
|
431
|
+
*/
|
|
432
|
+
decryptWithAes256(key: Uint8Array): IDecoder;
|
|
433
|
+
/**
|
|
434
|
+
* Decrypt with AES-128-GCM.
|
|
435
|
+
* @param key - 16-byte AES-128 key
|
|
436
|
+
* @returns The decoder instance for chaining
|
|
437
|
+
* @throws {Claim169Error} If the key is invalid
|
|
438
|
+
*/
|
|
439
|
+
decryptWithAes128(key: Uint8Array): IDecoder;
|
|
440
|
+
/**
|
|
441
|
+
* Skip biometric data during decoding.
|
|
442
|
+
* Useful when only demographic data is needed.
|
|
443
|
+
* @returns The decoder instance for chaining
|
|
444
|
+
*/
|
|
445
|
+
skipBiometrics(): IDecoder;
|
|
446
|
+
/**
|
|
447
|
+
* Enable timestamp validation.
|
|
448
|
+
* When enabled, expired or not-yet-valid credentials will throw an error.
|
|
449
|
+
* @returns The decoder instance for chaining
|
|
450
|
+
*/
|
|
451
|
+
withTimestampValidation(): IDecoder;
|
|
452
|
+
/**
|
|
453
|
+
* Set clock skew tolerance in seconds.
|
|
454
|
+
* Allows credentials to be accepted when clocks are slightly out of sync.
|
|
455
|
+
* Only applies when timestamp validation is enabled.
|
|
456
|
+
* @param seconds - The tolerance in seconds
|
|
457
|
+
* @returns The decoder instance for chaining
|
|
458
|
+
*/
|
|
459
|
+
clockSkewTolerance(seconds: number): IDecoder;
|
|
460
|
+
/**
|
|
461
|
+
* Set maximum decompressed size in bytes.
|
|
462
|
+
* Protects against decompression bomb attacks.
|
|
463
|
+
* @param bytes - The maximum size in bytes (default: 65536)
|
|
464
|
+
* @returns The decoder instance for chaining
|
|
465
|
+
*/
|
|
466
|
+
maxDecompressedBytes(bytes: number): IDecoder;
|
|
467
|
+
/**
|
|
468
|
+
* Decode the QR code with the configured options.
|
|
469
|
+
* Requires either a verifier (verifyWithEd25519/verifyWithEcdsaP256) or
|
|
470
|
+
* explicit allowUnverified() to be called first.
|
|
471
|
+
* @returns The decoded result
|
|
472
|
+
* @throws {Claim169Error} If decoding fails or no verification method specified
|
|
473
|
+
*/
|
|
474
|
+
decode(): DecodeResult;
|
|
475
|
+
}
|
|
476
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,SAAS;IACxB,2DAA2D;IAC3D,IAAI,EAAE,UAAU,CAAC;IACjB;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,OAAO;IACtB,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,OAAO,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AG,QAAQ,CAAC;IAErD;;;;OAIG;IACH,eAAe,IAAI,QAAQ,CAAC;IAE5B;;;;;OAKG;IACH,iBAAiB,CAAC,GAAG,EAAE,UAAU,GAAG,QAAQ,CAAC;IAE7C;;;;;OAKG;IACH,iBAAiB,CAAC,GAAG,EAAE,UAAU,GAAG,QAAQ,CAAC;IAE7C;;;;OAIG;IACH,cAAc,IAAI,QAAQ,CAAC;IAE3B;;;;OAIG;IACH,uBAAuB,IAAI,QAAQ,CAAC;IAEpC;;;;;;OAMG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAC;IAE9C;;;;;OAKG;IACH,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC;IAE9C;;;;;;OAMG;IACH,MAAM,IAAI,YAAY,CAAC;CACxB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for MOSIP Claim 169 QR Code decoder.
|
|
3
|
+
*
|
|
4
|
+
* This module contains TypeScript interfaces and types for the decoded
|
|
5
|
+
* Claim 169 identity data.
|
|
6
|
+
*
|
|
7
|
+
* @module claim169/types
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Error thrown when decoding fails.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* try {
|
|
15
|
+
* decode(qrText, { allowUnverified: true }); // testing only
|
|
16
|
+
* } catch (error) {
|
|
17
|
+
* if (error instanceof Claim169Error) {
|
|
18
|
+
* console.error('Decoding failed:', error.message);
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export class Claim169Error extends Error {
|
|
24
|
+
constructor(message) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = "Claim169Error";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA8NH;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "claim169",
|
|
3
|
+
"version": "0.1.0-alpha",
|
|
4
|
+
"description": "MOSIP Claim 169 QR Code decoder library",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public",
|
|
11
|
+
"provenance": true
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"wasm"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build:wasm": "wasm-pack build ../../core/claim169-wasm --target bundler --release --out-dir ../../sdks/typescript/wasm",
|
|
25
|
+
"build:ts": "tsc",
|
|
26
|
+
"build": "npm run build:wasm && npm run build:ts",
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"test:watch": "vitest",
|
|
29
|
+
"test:coverage": "vitest run --coverage",
|
|
30
|
+
"clean": "rm -rf dist wasm coverage"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"mosip",
|
|
34
|
+
"claim169",
|
|
35
|
+
"qr-code",
|
|
36
|
+
"identity",
|
|
37
|
+
"cbor",
|
|
38
|
+
"cose",
|
|
39
|
+
"wasm"
|
|
40
|
+
],
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/jeremi/claim-169"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@vitest/coverage-v8": "^4.0.0",
|
|
48
|
+
"typescript": "^5.7.0",
|
|
49
|
+
"vite-plugin-top-level-await": "^1.6.0",
|
|
50
|
+
"vite-plugin-wasm": "^3.5.0",
|
|
51
|
+
"vitest": "^4.0.0"
|
|
52
|
+
}
|
|
53
|
+
}
|