@zkproofport-app/sdk 0.2.7 → 0.2.8
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/LICENSE +1 -1
- package/README.md +51 -1
- package/dist/ProofportSDK.d.ts +16 -0
- package/dist/constants.d.ts +30 -0
- package/dist/deeplink.d.ts +16 -15
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +195 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +195 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +195 -2
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +64 -2
- package/package.json +2 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -163,6 +163,56 @@ const relay = await sdk.createRelayRequest('oidc_domain_attestation', {
|
|
|
163
163
|
|
|
164
164
|
> When `provider` is set, the mobile app verifies the user's account is managed by the specified workspace provider (e.g., Google Workspace `hd` claim, Microsoft 365 `tid` claim). Without `provider`, only the email domain is verified.
|
|
165
165
|
|
|
166
|
+
### `mdl_kr_ownership`
|
|
167
|
+
|
|
168
|
+
Proves the user holds a valid Korean mobile driver's license (모바일 신분증). The license data stays on-device; only the attributes selected by `discloseFlags` are revealed. No wallet signature is required.
|
|
169
|
+
|
|
170
|
+
| Field | Type | Required | Description |
|
|
171
|
+
|-------|------|----------|-------------|
|
|
172
|
+
| `scope` | `string` | Yes | Application-specific identifier for proof uniqueness |
|
|
173
|
+
| `discloseFlags` | `number` | No | Attribute disclosure bitmask `0x00`–`0x0F` (`0x01` name, `0x02` birth, `0x04` sex, `0x08` phone). Omit or `0` for a fully anonymous ownership proof. |
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
// Anonymous "holds a valid Korean mobile ID" proof
|
|
177
|
+
const relay = await sdk.createRelayRequest('mdl_kr_ownership', {
|
|
178
|
+
scope: 'myapp.com',
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### `mdl_kr_age`
|
|
183
|
+
|
|
184
|
+
Proves the user is at least `ageThreshold` years old according to their Korean mobile driver's license, without revealing the birth date.
|
|
185
|
+
|
|
186
|
+
| Field | Type | Required | Description |
|
|
187
|
+
|-------|------|----------|-------------|
|
|
188
|
+
| `scope` | `string` | Yes | Application-specific identifier |
|
|
189
|
+
| `ageThreshold` | `number` | Yes | Minimum age to prove (integer 1–150, e.g. `19` for Korean adult verification) |
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
const relay = await sdk.createRelayRequest('mdl_kr_age', {
|
|
193
|
+
scope: 'myapp.com',
|
|
194
|
+
ageThreshold: 19,
|
|
195
|
+
});
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### `mdl_kr_region`
|
|
199
|
+
|
|
200
|
+
Proves the user's registered address is in the specified si/do region without revealing the full address.
|
|
201
|
+
|
|
202
|
+
| Field | Type | Required | Description |
|
|
203
|
+
|-------|------|----------|-------------|
|
|
204
|
+
| `scope` | `string` | Yes | Application-specific identifier |
|
|
205
|
+
| `targetRegion` | `string` | Yes | Region (si/do) to prove residency in, in Korean (e.g. `'경기도'`, `'서울특별시'`) |
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
const relay = await sdk.createRelayRequest('mdl_kr_region', {
|
|
209
|
+
scope: 'myapp.com',
|
|
210
|
+
targetRegion: '경기도',
|
|
211
|
+
});
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
> The mDL circuits do not require `setSigner()` — the proof is bound to the license via an on-device nullifier (`nullifier_value` public input), not a wallet address. Use `sdk.extractNullifier(result.publicInputs, result.circuit)` for sybil-resistant user identification.
|
|
215
|
+
|
|
166
216
|
## Integration Guide
|
|
167
217
|
|
|
168
218
|
### Step 1: Initialize
|
|
@@ -418,7 +468,7 @@ import {
|
|
|
418
468
|
extractDomainFromPublicInputs,
|
|
419
469
|
} from '@zkproofport-app/sdk';
|
|
420
470
|
|
|
421
|
-
// Works with all circuits: coinbase_attestation, coinbase_country_attestation, oidc_domain_attestation
|
|
471
|
+
// Works with all circuits: coinbase_attestation, coinbase_country_attestation, oidc_domain_attestation, mdl_kr_ownership, mdl_kr_age, mdl_kr_region
|
|
422
472
|
const scope = extractScopeFromPublicInputs(publicInputs, 'coinbase_attestation');
|
|
423
473
|
const nullifier = extractNullifierFromPublicInputs(publicInputs, 'coinbase_attestation');
|
|
424
474
|
|
package/dist/ProofportSDK.d.ts
CHANGED
|
@@ -168,6 +168,22 @@ export declare class ProofportSDK {
|
|
|
168
168
|
* ```
|
|
169
169
|
*/
|
|
170
170
|
private createProofRequest;
|
|
171
|
+
/**
|
|
172
|
+
* @internal
|
|
173
|
+
* Creates a Korea Mobile ID (mDL) proof request for any of the three
|
|
174
|
+
* mDL predicate circuits (ownership / age / region).
|
|
175
|
+
*
|
|
176
|
+
* The mobile app collects the license data on-device; the dapp only
|
|
177
|
+
* supplies the predicate parameters validated here. No wallet signature
|
|
178
|
+
* is required for mDL circuits.
|
|
179
|
+
*
|
|
180
|
+
* @param circuit - 'mdl_kr_ownership' | 'mdl_kr_age' | 'mdl_kr_region'
|
|
181
|
+
* @param inputs - Predicate inputs (see MdlKr*Inputs types)
|
|
182
|
+
* @param options - Request configuration options
|
|
183
|
+
*
|
|
184
|
+
* @throws Error if the predicate inputs fail validation
|
|
185
|
+
*/
|
|
186
|
+
private createMdlKrRequest;
|
|
171
187
|
/**
|
|
172
188
|
* @internal
|
|
173
189
|
* Generates a deep link URL for a proof request.
|
package/dist/constants.d.ts
CHANGED
|
@@ -183,6 +183,36 @@ export declare const COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT: {
|
|
|
183
183
|
readonly NULLIFIER_START: 118;
|
|
184
184
|
readonly NULLIFIER_END: 149;
|
|
185
185
|
};
|
|
186
|
+
/**
|
|
187
|
+
* Korea Mobile ID (mDL) circuit public input layout (field offsets).
|
|
188
|
+
* All three mDL circuits share the same prefix: scope [0..31] and
|
|
189
|
+
* nullifier_value [32..63], each stored one byte per field element.
|
|
190
|
+
* The suffix differs per predicate circuit:
|
|
191
|
+
* - mdl_kr_ownership (97 inputs): disclose_flags [64], owner_commit [65..96]
|
|
192
|
+
* - mdl_kr_age (66 inputs): age_threshold [64], current_year [65]
|
|
193
|
+
* - mdl_kr_region (96 inputs): region_code [64..95]
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* const nullifier = publicInputs.slice(
|
|
198
|
+
* MDL_KR_PUBLIC_INPUT_LAYOUT.NULLIFIER_START,
|
|
199
|
+
* MDL_KR_PUBLIC_INPUT_LAYOUT.NULLIFIER_END + 1
|
|
200
|
+
* );
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
export declare const MDL_KR_PUBLIC_INPUT_LAYOUT: {
|
|
204
|
+
readonly SCOPE_START: 0;
|
|
205
|
+
readonly SCOPE_END: 31;
|
|
206
|
+
readonly NULLIFIER_START: 32;
|
|
207
|
+
readonly NULLIFIER_END: 63;
|
|
208
|
+
readonly OWNERSHIP_DISCLOSE_FLAGS: 64;
|
|
209
|
+
readonly OWNERSHIP_OWNER_COMMIT_START: 65;
|
|
210
|
+
readonly OWNERSHIP_OWNER_COMMIT_END: 96;
|
|
211
|
+
readonly AGE_THRESHOLD: 64;
|
|
212
|
+
readonly AGE_CURRENT_YEAR: 65;
|
|
213
|
+
readonly REGION_CODE_START: 64;
|
|
214
|
+
readonly REGION_CODE_END: 95;
|
|
215
|
+
};
|
|
186
216
|
/**
|
|
187
217
|
* OIDC Domain Attestation circuit public input layout (field offsets).
|
|
188
218
|
* Defines the field positions in the flattened public inputs array (148 fields total).
|
package/dist/deeplink.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Deep Link utilities for ZKProofport SDK
|
|
3
3
|
*/
|
|
4
|
-
import type { ProofRequest, ProofResponse, DeepLinkComponents } from './types';
|
|
4
|
+
import type { ProofRequest, ProofResponse, CircuitInputs, DeepLinkComponents } from './types';
|
|
5
5
|
/**
|
|
6
6
|
* Generates a unique request ID for proof requests.
|
|
7
7
|
*
|
|
@@ -171,21 +171,22 @@ export declare function parseDeepLink(url: string): DeepLinkComponents | null;
|
|
|
171
171
|
*/
|
|
172
172
|
export declare function isProofportDeepLink(url: string, scheme?: string): boolean;
|
|
173
173
|
/**
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* -
|
|
180
|
-
* -
|
|
181
|
-
* -
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* @param
|
|
187
|
-
* @returns
|
|
174
|
+
* Validates dapp-supplied inputs for the Korea Mobile ID (mDL) circuits.
|
|
175
|
+
* Shared by deep-link request validation and relay request creation so the
|
|
176
|
+
* same guards apply on every request path.
|
|
177
|
+
*
|
|
178
|
+
* Rules:
|
|
179
|
+
* - `scope` — required non-empty string, ≤256 chars, no control characters
|
|
180
|
+
* - `mdl_kr_ownership.discloseFlags` — optional integer 0–15 (0x0F bitmask)
|
|
181
|
+
* - `mdl_kr_age.ageThreshold` — required integer 1–150
|
|
182
|
+
* - `mdl_kr_region.targetRegion` — required non-empty string (Korean si/do),
|
|
183
|
+
* ≤256 chars, no control characters
|
|
184
|
+
*
|
|
185
|
+
* @param circuit - One of the three mDL circuit identifiers
|
|
186
|
+
* @param inputs - Dapp-supplied circuit inputs
|
|
187
|
+
* @returns Error message string, or null when the inputs are valid
|
|
188
188
|
*/
|
|
189
|
+
export declare function validateMdlInputs(circuit: 'mdl_kr_ownership' | 'mdl_kr_age' | 'mdl_kr_region', inputs: CircuitInputs): string | null;
|
|
189
190
|
export declare function validateProofRequest(request: ProofRequest): {
|
|
190
191
|
valid: boolean;
|
|
191
192
|
error?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
*/
|
|
28
28
|
export { ProofportSDK, default } from './ProofportSDK';
|
|
29
29
|
export { extractScopeFromPublicInputs, extractNullifierFromPublicInputs, extractDomainFromPublicInputs, } from './verifier';
|
|
30
|
-
export { COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT, COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT, OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT, } from './constants';
|
|
31
|
-
export type { CircuitType, ProofRequestStatus, CoinbaseKycInputs, CoinbaseCountryInputs, OidcDomainInputs, CircuitInputs, ProofRequest, ProofResponse, QRCodeOptions, VerifierContract, ProofportConfig, ChallengeResponse, WalletSigner, RelayProofRequest, RelayProofResult, SDKEnvironment, } from './types';
|
|
30
|
+
export { COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT, COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT, OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT, MDL_KR_PUBLIC_INPUT_LAYOUT, } from './constants';
|
|
31
|
+
export type { CircuitType, ProofRequestStatus, CoinbaseKycInputs, CoinbaseCountryInputs, OidcDomainInputs, MdlKrOwnershipInputs, MdlKrAgeInputs, MdlKrRegionInputs, CircuitInputs, ProofRequest, ProofResponse, QRCodeOptions, VerifierContract, ProofportConfig, ChallengeResponse, WalletSigner, RelayProofRequest, RelayProofResult, SDKEnvironment, } from './types';
|
package/dist/index.esm.js
CHANGED
|
@@ -73,6 +73,26 @@ const CIRCUIT_METADATA = {
|
|
|
73
73
|
publicInputsCount: 148,
|
|
74
74
|
publicInputNames: ['pubkey_modulus_limbs', 'domain', 'scope', 'nullifier', 'provider'],
|
|
75
75
|
},
|
|
76
|
+
// Korea Mobile ID (mDL) circuits. Counts are byte-flattened field totals
|
|
77
|
+
// from the compiled circuit ABIs: [u8; 32] arrays contribute 32 inputs each.
|
|
78
|
+
mdl_kr_ownership: {
|
|
79
|
+
name: 'Korea Mobile ID — Ownership',
|
|
80
|
+
description: "Prove valid Korean mobile driver's license ownership with selective disclosure",
|
|
81
|
+
publicInputsCount: 97,
|
|
82
|
+
publicInputNames: ['scope', 'nullifier_value', 'disclose_flags', 'owner_commit'],
|
|
83
|
+
},
|
|
84
|
+
mdl_kr_age: {
|
|
85
|
+
name: 'Korea Mobile ID — Age',
|
|
86
|
+
description: "Prove minimum age from Korean mobile driver's license without revealing birth date",
|
|
87
|
+
publicInputsCount: 66,
|
|
88
|
+
publicInputNames: ['scope', 'nullifier_value', 'age_threshold', 'current_year'],
|
|
89
|
+
},
|
|
90
|
+
mdl_kr_region: {
|
|
91
|
+
name: 'Korea Mobile ID — Region',
|
|
92
|
+
description: "Prove si/do residency from Korean mobile driver's license without revealing address",
|
|
93
|
+
publicInputsCount: 96,
|
|
94
|
+
publicInputNames: ['scope', 'nullifier_value', 'region_code'],
|
|
95
|
+
},
|
|
76
96
|
};
|
|
77
97
|
/**
|
|
78
98
|
* Standard verifier contract ABI shared across all Barretenberg-generated verifiers.
|
|
@@ -204,6 +224,36 @@ const COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT = {
|
|
|
204
224
|
NULLIFIER_START: 118,
|
|
205
225
|
NULLIFIER_END: 149,
|
|
206
226
|
};
|
|
227
|
+
/**
|
|
228
|
+
* Korea Mobile ID (mDL) circuit public input layout (field offsets).
|
|
229
|
+
* All three mDL circuits share the same prefix: scope [0..31] and
|
|
230
|
+
* nullifier_value [32..63], each stored one byte per field element.
|
|
231
|
+
* The suffix differs per predicate circuit:
|
|
232
|
+
* - mdl_kr_ownership (97 inputs): disclose_flags [64], owner_commit [65..96]
|
|
233
|
+
* - mdl_kr_age (66 inputs): age_threshold [64], current_year [65]
|
|
234
|
+
* - mdl_kr_region (96 inputs): region_code [64..95]
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```typescript
|
|
238
|
+
* const nullifier = publicInputs.slice(
|
|
239
|
+
* MDL_KR_PUBLIC_INPUT_LAYOUT.NULLIFIER_START,
|
|
240
|
+
* MDL_KR_PUBLIC_INPUT_LAYOUT.NULLIFIER_END + 1
|
|
241
|
+
* );
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
const MDL_KR_PUBLIC_INPUT_LAYOUT = {
|
|
245
|
+
SCOPE_START: 0,
|
|
246
|
+
SCOPE_END: 31,
|
|
247
|
+
NULLIFIER_START: 32,
|
|
248
|
+
NULLIFIER_END: 63,
|
|
249
|
+
OWNERSHIP_DISCLOSE_FLAGS: 64,
|
|
250
|
+
OWNERSHIP_OWNER_COMMIT_START: 65,
|
|
251
|
+
OWNERSHIP_OWNER_COMMIT_END: 96,
|
|
252
|
+
AGE_THRESHOLD: 64,
|
|
253
|
+
AGE_CURRENT_YEAR: 65,
|
|
254
|
+
REGION_CODE_START: 64,
|
|
255
|
+
REGION_CODE_END: 95,
|
|
256
|
+
};
|
|
207
257
|
/**
|
|
208
258
|
* OIDC Domain Attestation circuit public input layout (field offsets).
|
|
209
259
|
* Defines the field positions in the flattened public inputs array (148 fields total).
|
|
@@ -484,6 +534,78 @@ function isProofportDeepLink(url, scheme = DEFAULT_SCHEME) {
|
|
|
484
534
|
* @param request - Proof request to validate
|
|
485
535
|
* @returns Validation result with `valid` flag and optional `error` message
|
|
486
536
|
*/
|
|
537
|
+
/**
|
|
538
|
+
* Validates a free-text mDL input (scope / targetRegion).
|
|
539
|
+
* Rejects empty or whitespace-only values, control characters (which break
|
|
540
|
+
* deep-link query encoding and downstream logging), and values over 256 chars
|
|
541
|
+
* (server-side length cap mirror). UTF-8 text such as Korean region names is
|
|
542
|
+
* allowed.
|
|
543
|
+
*
|
|
544
|
+
* @returns Error message string, or null when valid.
|
|
545
|
+
*/
|
|
546
|
+
function validateMdlTextInput(value, fieldName) {
|
|
547
|
+
if (typeof value !== 'string' || value.trim() === '') {
|
|
548
|
+
return `${fieldName} is required and must be a non-empty string`;
|
|
549
|
+
}
|
|
550
|
+
if (value.length > 256) {
|
|
551
|
+
return `${fieldName} must be 256 characters or fewer`;
|
|
552
|
+
}
|
|
553
|
+
// eslint-disable-next-line no-control-regex
|
|
554
|
+
if (/[\u0000-\u001F\u007F]/.test(value)) {
|
|
555
|
+
return `${fieldName} must not contain control characters`;
|
|
556
|
+
}
|
|
557
|
+
return null;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Validates dapp-supplied inputs for the Korea Mobile ID (mDL) circuits.
|
|
561
|
+
* Shared by deep-link request validation and relay request creation so the
|
|
562
|
+
* same guards apply on every request path.
|
|
563
|
+
*
|
|
564
|
+
* Rules:
|
|
565
|
+
* - `scope` — required non-empty string, ≤256 chars, no control characters
|
|
566
|
+
* - `mdl_kr_ownership.discloseFlags` — optional integer 0–15 (0x0F bitmask)
|
|
567
|
+
* - `mdl_kr_age.ageThreshold` — required integer 1–150
|
|
568
|
+
* - `mdl_kr_region.targetRegion` — required non-empty string (Korean si/do),
|
|
569
|
+
* ≤256 chars, no control characters
|
|
570
|
+
*
|
|
571
|
+
* @param circuit - One of the three mDL circuit identifiers
|
|
572
|
+
* @param inputs - Dapp-supplied circuit inputs
|
|
573
|
+
* @returns Error message string, or null when the inputs are valid
|
|
574
|
+
*/
|
|
575
|
+
function validateMdlInputs(circuit, inputs) {
|
|
576
|
+
const scopeError = validateMdlTextInput(inputs.scope, 'scope');
|
|
577
|
+
if (scopeError) {
|
|
578
|
+
return scopeError;
|
|
579
|
+
}
|
|
580
|
+
if (circuit === 'mdl_kr_ownership') {
|
|
581
|
+
const { discloseFlags } = inputs;
|
|
582
|
+
if (discloseFlags !== undefined) {
|
|
583
|
+
if (typeof discloseFlags !== 'number' ||
|
|
584
|
+
!Number.isInteger(discloseFlags) ||
|
|
585
|
+
discloseFlags < 0 ||
|
|
586
|
+
discloseFlags > 0x0f) {
|
|
587
|
+
return 'discloseFlags must be an integer between 0 and 15';
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
else if (circuit === 'mdl_kr_age') {
|
|
592
|
+
const { ageThreshold } = inputs;
|
|
593
|
+
if (typeof ageThreshold !== 'number' ||
|
|
594
|
+
!Number.isInteger(ageThreshold) ||
|
|
595
|
+
ageThreshold < 1 ||
|
|
596
|
+
ageThreshold > 150) {
|
|
597
|
+
return 'ageThreshold is required and must be an integer between 1 and 150';
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
else {
|
|
601
|
+
const { targetRegion } = inputs;
|
|
602
|
+
const regionError = validateMdlTextInput(targetRegion, 'targetRegion');
|
|
603
|
+
if (regionError) {
|
|
604
|
+
return regionError;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
return null;
|
|
608
|
+
}
|
|
487
609
|
function validateProofRequest(request) {
|
|
488
610
|
if (!request.requestId) {
|
|
489
611
|
return { valid: false, error: 'Missing requestId' };
|
|
@@ -491,7 +613,14 @@ function validateProofRequest(request) {
|
|
|
491
613
|
if (!request.circuit) {
|
|
492
614
|
return { valid: false, error: 'Missing circuit type' };
|
|
493
615
|
}
|
|
494
|
-
if (![
|
|
616
|
+
if (![
|
|
617
|
+
'coinbase_attestation',
|
|
618
|
+
'coinbase_country_attestation',
|
|
619
|
+
'oidc_domain_attestation',
|
|
620
|
+
'mdl_kr_ownership',
|
|
621
|
+
'mdl_kr_age',
|
|
622
|
+
'mdl_kr_region',
|
|
623
|
+
].includes(request.circuit)) {
|
|
495
624
|
return { valid: false, error: `Invalid circuit type: ${request.circuit}` };
|
|
496
625
|
}
|
|
497
626
|
if (!request.callbackUrl) {
|
|
@@ -533,6 +662,14 @@ function validateProofRequest(request) {
|
|
|
533
662
|
return { valid: false, error: 'provider must be a non-empty string when specified' };
|
|
534
663
|
}
|
|
535
664
|
}
|
|
665
|
+
else if (request.circuit === 'mdl_kr_ownership' ||
|
|
666
|
+
request.circuit === 'mdl_kr_age' ||
|
|
667
|
+
request.circuit === 'mdl_kr_region') {
|
|
668
|
+
const mdlError = validateMdlInputs(request.circuit, request.inputs);
|
|
669
|
+
if (mdlError) {
|
|
670
|
+
return { valid: false, error: mdlError };
|
|
671
|
+
}
|
|
672
|
+
}
|
|
536
673
|
// Check expiry
|
|
537
674
|
if (request.expiresAt && Date.now() > request.expiresAt) {
|
|
538
675
|
return { valid: false, error: 'Request has expired' };
|
|
@@ -3838,6 +3975,11 @@ function extractScopeFromPublicInputs(publicInputsHex, circuit) {
|
|
|
3838
3975
|
start = 83;
|
|
3839
3976
|
end = 114;
|
|
3840
3977
|
}
|
|
3978
|
+
else if (circuit !== undefined && circuit.startsWith('mdl_kr_')) {
|
|
3979
|
+
// All Korea mDL circuits: scope [0..31], nullifier_value [32..63]
|
|
3980
|
+
start = 0;
|
|
3981
|
+
end = 31;
|
|
3982
|
+
}
|
|
3841
3983
|
else {
|
|
3842
3984
|
start = 64;
|
|
3843
3985
|
end = 95;
|
|
@@ -3875,6 +4017,11 @@ function extractNullifierFromPublicInputs(publicInputsHex, circuit) {
|
|
|
3875
4017
|
start = 115;
|
|
3876
4018
|
end = 146;
|
|
3877
4019
|
}
|
|
4020
|
+
else if (circuit !== undefined && circuit.startsWith('mdl_kr_')) {
|
|
4021
|
+
// All Korea mDL circuits: scope [0..31], nullifier_value [32..63]
|
|
4022
|
+
start = 32;
|
|
4023
|
+
end = 63;
|
|
4024
|
+
}
|
|
3878
4025
|
else {
|
|
3879
4026
|
start = 96;
|
|
3880
4027
|
end = 127;
|
|
@@ -4142,10 +4289,48 @@ class ProofportSDK {
|
|
|
4142
4289
|
if (circuit === 'coinbase_country_attestation') {
|
|
4143
4290
|
return this.createCoinbaseCountryRequest(inputs, options);
|
|
4144
4291
|
}
|
|
4292
|
+
else if (circuit === 'mdl_kr_ownership' ||
|
|
4293
|
+
circuit === 'mdl_kr_age' ||
|
|
4294
|
+
circuit === 'mdl_kr_region') {
|
|
4295
|
+
return this.createMdlKrRequest(circuit, inputs, options);
|
|
4296
|
+
}
|
|
4145
4297
|
else {
|
|
4146
4298
|
return this.createCoinbaseKycRequest(inputs, options);
|
|
4147
4299
|
}
|
|
4148
4300
|
}
|
|
4301
|
+
/**
|
|
4302
|
+
* @internal
|
|
4303
|
+
* Creates a Korea Mobile ID (mDL) proof request for any of the three
|
|
4304
|
+
* mDL predicate circuits (ownership / age / region).
|
|
4305
|
+
*
|
|
4306
|
+
* The mobile app collects the license data on-device; the dapp only
|
|
4307
|
+
* supplies the predicate parameters validated here. No wallet signature
|
|
4308
|
+
* is required for mDL circuits.
|
|
4309
|
+
*
|
|
4310
|
+
* @param circuit - 'mdl_kr_ownership' | 'mdl_kr_age' | 'mdl_kr_region'
|
|
4311
|
+
* @param inputs - Predicate inputs (see MdlKr*Inputs types)
|
|
4312
|
+
* @param options - Request configuration options
|
|
4313
|
+
*
|
|
4314
|
+
* @throws Error if the predicate inputs fail validation
|
|
4315
|
+
*/
|
|
4316
|
+
createMdlKrRequest(circuit, inputs, options = {}) {
|
|
4317
|
+
const mdlError = validateMdlInputs(circuit, inputs);
|
|
4318
|
+
if (mdlError) {
|
|
4319
|
+
throw new Error(`${mdlError} (circuit: ${circuit})`);
|
|
4320
|
+
}
|
|
4321
|
+
const request = {
|
|
4322
|
+
requestId: generateRequestId(),
|
|
4323
|
+
circuit,
|
|
4324
|
+
inputs,
|
|
4325
|
+
message: options.message,
|
|
4326
|
+
dappName: options.dappName,
|
|
4327
|
+
dappIcon: options.dappIcon,
|
|
4328
|
+
createdAt: Date.now(),
|
|
4329
|
+
expiresAt: Date.now() + (options.expiresInMs || DEFAULT_REQUEST_EXPIRY_MS),
|
|
4330
|
+
};
|
|
4331
|
+
this.pendingRequests.set(request.requestId, request);
|
|
4332
|
+
return request;
|
|
4333
|
+
}
|
|
4149
4334
|
// ============ Deep Link Generation ============
|
|
4150
4335
|
/**
|
|
4151
4336
|
* @internal
|
|
@@ -4806,6 +4991,14 @@ class ProofportSDK {
|
|
|
4806
4991
|
if (needsSignature && !this.signer) {
|
|
4807
4992
|
throw new Error('Signer not set. Call setSigner() first. Wallet signature is required for this circuit.');
|
|
4808
4993
|
}
|
|
4994
|
+
// mDL circuits: validate predicate inputs client-side before hitting the
|
|
4995
|
+
// relay, so a bad ageThreshold / targetRegion fails fast with a clear error.
|
|
4996
|
+
if (circuit === 'mdl_kr_ownership' || circuit === 'mdl_kr_age' || circuit === 'mdl_kr_region') {
|
|
4997
|
+
const mdlError = validateMdlInputs(circuit, inputs);
|
|
4998
|
+
if (mdlError) {
|
|
4999
|
+
throw new Error(`${mdlError} (circuit: ${circuit})`);
|
|
5000
|
+
}
|
|
5001
|
+
}
|
|
4809
5002
|
// Get challenge + requestId from relay
|
|
4810
5003
|
const { requestId, challenge } = await this.getChallenge();
|
|
4811
5004
|
const body = {
|
|
@@ -5152,5 +5345,5 @@ ProofportSDK.WALLET_SIGNATURE_CIRCUITS = [
|
|
|
5152
5345
|
'coinbase_country_attestation',
|
|
5153
5346
|
];
|
|
5154
5347
|
|
|
5155
|
-
export { COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT, COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT, OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT, ProofportSDK, ProofportSDK as default, extractDomainFromPublicInputs, extractNullifierFromPublicInputs, extractScopeFromPublicInputs };
|
|
5348
|
+
export { COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT, COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT, MDL_KR_PUBLIC_INPUT_LAYOUT, OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT, ProofportSDK, ProofportSDK as default, extractDomainFromPublicInputs, extractNullifierFromPublicInputs, extractScopeFromPublicInputs };
|
|
5156
5349
|
//# sourceMappingURL=index.esm.js.map
|