@zkproofport-app/sdk 0.5.0-beta.3 → 0.5.0-beta.5
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 +45 -133
- package/dist/ProofportSDK.d.ts +3 -18
- package/dist/constants.d.ts +3 -12
- package/dist/deeplink.d.ts +17 -18
- package/dist/index.d.ts +6 -6
- package/dist/index.esm.js +66 -202
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +99 -202
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -202
- package/dist/index.mjs.map +1 -1
- package/dist/offChainVerifier.d.ts +8 -1
- package/dist/relayStatus.d.ts +11 -0
- package/dist/types.d.ts +11 -63
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ const RELAY_URLS = {
|
|
|
32
32
|
* Mirrors the mobile app's `CIRCUIT_NETWORKS` (proofport-app
|
|
33
33
|
* src/config/contracts.ts), because a proof is checked where the app said its
|
|
34
34
|
* verifier is: Base for the Coinbase and OIDC circuits, GIWA Sepolia for GIWA
|
|
35
|
-
* and Dojang (testnet-only)
|
|
35
|
+
* and Dojang (testnet-only).
|
|
36
36
|
* The ADDRESS on that chain always comes from core's pinned table, never from
|
|
37
37
|
* a proof response.
|
|
38
38
|
*/
|
|
@@ -43,9 +43,6 @@ const VERIFICATION_CHAINS = {
|
|
|
43
43
|
oidc_domain_attestation: 8453,
|
|
44
44
|
giwa_attestation: 91342,
|
|
45
45
|
dojang_playground: 91342,
|
|
46
|
-
mdl_kr_ownership: 84532,
|
|
47
|
-
mdl_kr_age: 84532,
|
|
48
|
-
mdl_kr_region: 84532,
|
|
49
46
|
},
|
|
50
47
|
staging: {
|
|
51
48
|
coinbase_attestation: 84532,
|
|
@@ -53,9 +50,6 @@ const VERIFICATION_CHAINS = {
|
|
|
53
50
|
oidc_domain_attestation: 84532,
|
|
54
51
|
giwa_attestation: 91342,
|
|
55
52
|
dojang_playground: 91342,
|
|
56
|
-
mdl_kr_ownership: 84532,
|
|
57
|
-
mdl_kr_age: 84532,
|
|
58
|
-
mdl_kr_region: 84532,
|
|
59
53
|
},
|
|
60
54
|
local: {
|
|
61
55
|
coinbase_attestation: 84532,
|
|
@@ -63,9 +57,6 @@ const VERIFICATION_CHAINS = {
|
|
|
63
57
|
oidc_domain_attestation: 84532,
|
|
64
58
|
giwa_attestation: 91342,
|
|
65
59
|
dojang_playground: 91342,
|
|
66
|
-
mdl_kr_ownership: 84532,
|
|
67
|
-
mdl_kr_age: 84532,
|
|
68
|
-
mdl_kr_region: 84532,
|
|
69
60
|
},
|
|
70
61
|
};
|
|
71
62
|
/**
|
|
@@ -101,19 +92,20 @@ const DEEP_LINK_HOSTS = {
|
|
|
101
92
|
* ```typescript
|
|
102
93
|
* const metadata = CIRCUIT_METADATA['coinbase_attestation'];
|
|
103
94
|
* console.log(metadata.name); // "Coinbase KYC"
|
|
104
|
-
* console.log(metadata.publicInputsCount); //
|
|
95
|
+
* console.log(metadata.publicInputsCount); // 193
|
|
105
96
|
* ```
|
|
106
97
|
*/
|
|
107
98
|
const CIRCUIT_METADATA = {
|
|
108
99
|
coinbase_attestation: {
|
|
109
100
|
name: 'Coinbase KYC',
|
|
110
|
-
description: 'Prove Coinbase identity verification',
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
101
|
+
description: 'Prove Coinbase identity verification, optionally authorizing one EIP-712 action',
|
|
102
|
+
// Coinbase KYC v2 (coinbase-attestation-v2/src/main.nr): GIWA's six
|
|
103
|
+
// `pub [u8; 32]` in its order, then `attested_at: pub u64` = 193 fields.
|
|
104
|
+
// signal_hash 0-31, domain_separator 32-63, action_hash 64-95,
|
|
105
|
+
// signer_list_merkle_root 96-127, scope 128-159, nullifier 160-191,
|
|
106
|
+
// attested_at 192. v1's 128 fields are refused on every verify path.
|
|
107
|
+
publicInputsCount: 193,
|
|
108
|
+
publicInputNames: ['signal_hash', 'domain_separator', 'action_hash', 'signer_list_merkle_root', 'scope', 'nullifier', 'attested_at'],
|
|
117
109
|
},
|
|
118
110
|
coinbase_country_attestation: {
|
|
119
111
|
name: 'Coinbase Country',
|
|
@@ -162,27 +154,6 @@ const CIRCUIT_METADATA = {
|
|
|
162
154
|
publicInputsCount: 160,
|
|
163
155
|
publicInputNames: ['signal_hash', 'domain_separator', 'action_hash', 'scope', 'nullifier'],
|
|
164
156
|
},
|
|
165
|
-
// Korea Mobile ID (mDL) circuits. Planned — not officially supported yet.
|
|
166
|
-
// Counts are byte-flattened field totals from the compiled circuit ABIs:
|
|
167
|
-
// [u8; 32] arrays contribute 32 inputs each.
|
|
168
|
-
mdl_kr_ownership: {
|
|
169
|
-
name: 'Korea Mobile ID — Ownership',
|
|
170
|
-
description: "Prove valid Korean mobile driver's license ownership with selective disclosure",
|
|
171
|
-
publicInputsCount: 97,
|
|
172
|
-
publicInputNames: ['scope', 'nullifier_value', 'disclose_flags', 'owner_commit'],
|
|
173
|
-
},
|
|
174
|
-
mdl_kr_age: {
|
|
175
|
-
name: 'Korea Mobile ID — Age',
|
|
176
|
-
description: "Prove minimum age from Korean mobile driver's license without revealing birth date",
|
|
177
|
-
publicInputsCount: 66,
|
|
178
|
-
publicInputNames: ['scope', 'nullifier_value', 'age_threshold', 'current_year'],
|
|
179
|
-
},
|
|
180
|
-
mdl_kr_region: {
|
|
181
|
-
name: 'Korea Mobile ID — Region',
|
|
182
|
-
description: "Prove si/do residency from Korean mobile driver's license without revealing address",
|
|
183
|
-
publicInputsCount: 96,
|
|
184
|
-
publicInputNames: ['scope', 'nullifier_value', 'region_code'],
|
|
185
|
-
},
|
|
186
157
|
};
|
|
187
158
|
/**
|
|
188
159
|
* Default proof request expiration time in milliseconds.
|
|
@@ -426,6 +397,12 @@ function parseProofResponseUrl(url) {
|
|
|
426
397
|
if (timestamp) {
|
|
427
398
|
response.timestamp = parseInt(timestamp, 10);
|
|
428
399
|
}
|
|
400
|
+
// Kept as sent, even when unknown: verification refuses it by name,
|
|
401
|
+
// which says more than a callback that fails to parse.
|
|
402
|
+
const signerVariant = urlObj.searchParams.get('signerVariant');
|
|
403
|
+
if (signerVariant !== null) {
|
|
404
|
+
response.signerVariant = signerVariant;
|
|
405
|
+
}
|
|
429
406
|
}
|
|
430
407
|
else if (status === 'error') {
|
|
431
408
|
response.error = urlObj.searchParams.get('error') || undefined;
|
|
@@ -457,94 +434,6 @@ function parseProofResponseUrl(url) {
|
|
|
457
434
|
function isProofportDeepLink(url, scheme = DEFAULT_SCHEME) {
|
|
458
435
|
return url.toLowerCase().startsWith(`${scheme.toLowerCase()}://`);
|
|
459
436
|
}
|
|
460
|
-
/**
|
|
461
|
-
* @internal
|
|
462
|
-
* Validates a proof request for completeness and correctness.
|
|
463
|
-
*
|
|
464
|
-
* Performs comprehensive validation including:
|
|
465
|
-
* - Required fields (requestId, circuit, callbackUrl)
|
|
466
|
-
* - Circuit type validity (must be a supported circuit)
|
|
467
|
-
* - Circuit-specific input validation (e.g., userAddress format, countryList structure)
|
|
468
|
-
* - Expiration check (if expiresAt is provided)
|
|
469
|
-
*
|
|
470
|
-
* Note: userAddress is optional for both circuits - the mobile app will prompt
|
|
471
|
-
* for wallet connection if not provided.
|
|
472
|
-
*
|
|
473
|
-
* @param request - Proof request to validate
|
|
474
|
-
* @returns Validation result with `valid` flag and optional `error` message
|
|
475
|
-
*/
|
|
476
|
-
/**
|
|
477
|
-
* Validates a free-text mDL input (scope / targetRegion).
|
|
478
|
-
* Rejects empty or whitespace-only values, control characters (which break
|
|
479
|
-
* deep-link query encoding and downstream logging), and values over 256 chars
|
|
480
|
-
* (server-side length cap mirror). UTF-8 text such as Korean region names is
|
|
481
|
-
* allowed.
|
|
482
|
-
*
|
|
483
|
-
* @returns Error message string, or null when valid.
|
|
484
|
-
*/
|
|
485
|
-
function validateMdlTextInput(value, fieldName) {
|
|
486
|
-
if (typeof value !== 'string' || value.trim() === '') {
|
|
487
|
-
return `${fieldName} is required and must be a non-empty string`;
|
|
488
|
-
}
|
|
489
|
-
if (value.length > 256) {
|
|
490
|
-
return `${fieldName} must be 256 characters or fewer`;
|
|
491
|
-
}
|
|
492
|
-
// eslint-disable-next-line no-control-regex
|
|
493
|
-
if (/[\u0000-\u001F\u007F]/.test(value)) {
|
|
494
|
-
return `${fieldName} must not contain control characters`;
|
|
495
|
-
}
|
|
496
|
-
return null;
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* Validates dapp-supplied inputs for the Korea Mobile ID (mDL) circuits.
|
|
500
|
-
* Shared by deep-link request validation and relay request creation so the
|
|
501
|
-
* same guards apply on every request path.
|
|
502
|
-
*
|
|
503
|
-
* Rules:
|
|
504
|
-
* - `scope` — required non-empty string, ≤256 chars, no control characters
|
|
505
|
-
* - `mdl_kr_ownership.discloseFlags` — optional integer 0–15 (0x0F bitmask)
|
|
506
|
-
* - `mdl_kr_age.ageThreshold` — required integer 1–150
|
|
507
|
-
* - `mdl_kr_region.targetRegion` — required non-empty string (Korean si/do),
|
|
508
|
-
* ≤256 chars, no control characters
|
|
509
|
-
*
|
|
510
|
-
* @param circuit - One of the three mDL circuit identifiers
|
|
511
|
-
* @param inputs - Dapp-supplied circuit inputs
|
|
512
|
-
* @returns Error message string, or null when the inputs are valid
|
|
513
|
-
*/
|
|
514
|
-
function validateMdlInputs(circuit, inputs) {
|
|
515
|
-
const scopeError = validateMdlTextInput(inputs.scope, 'scope');
|
|
516
|
-
if (scopeError) {
|
|
517
|
-
return scopeError;
|
|
518
|
-
}
|
|
519
|
-
if (circuit === 'mdl_kr_ownership') {
|
|
520
|
-
const { discloseFlags } = inputs;
|
|
521
|
-
if (discloseFlags !== undefined) {
|
|
522
|
-
if (typeof discloseFlags !== 'number' ||
|
|
523
|
-
!Number.isInteger(discloseFlags) ||
|
|
524
|
-
discloseFlags < 0 ||
|
|
525
|
-
discloseFlags > 0x0f) {
|
|
526
|
-
return 'discloseFlags must be an integer between 0 and 15';
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
else if (circuit === 'mdl_kr_age') {
|
|
531
|
-
const { ageThreshold } = inputs;
|
|
532
|
-
if (typeof ageThreshold !== 'number' ||
|
|
533
|
-
!Number.isInteger(ageThreshold) ||
|
|
534
|
-
ageThreshold < 1 ||
|
|
535
|
-
ageThreshold > 150) {
|
|
536
|
-
return 'ageThreshold is required and must be an integer between 1 and 150';
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
else {
|
|
540
|
-
const { targetRegion } = inputs;
|
|
541
|
-
const regionError = validateMdlTextInput(targetRegion, 'targetRegion');
|
|
542
|
-
if (regionError) {
|
|
543
|
-
return regionError;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
return null;
|
|
547
|
-
}
|
|
548
437
|
/**
|
|
549
438
|
* Longest accepted `returnScheme` value.
|
|
550
439
|
* Kept in sync with proofport-relay `src/returnScheme.ts`.
|
|
@@ -704,6 +593,22 @@ function detectReturnScheme(userAgent) {
|
|
|
704
593
|
}
|
|
705
594
|
return undefined;
|
|
706
595
|
}
|
|
596
|
+
/**
|
|
597
|
+
* @internal
|
|
598
|
+
* Validates a proof request for completeness and correctness.
|
|
599
|
+
*
|
|
600
|
+
* Performs comprehensive validation including:
|
|
601
|
+
* - Required fields (requestId, circuit, callbackUrl)
|
|
602
|
+
* - Circuit type validity (must be a supported circuit)
|
|
603
|
+
* - Circuit-specific input validation (e.g., userAddress format, countryList structure)
|
|
604
|
+
* - Expiration check (if expiresAt is provided)
|
|
605
|
+
*
|
|
606
|
+
* Note: userAddress is optional for both circuits - the mobile app will prompt
|
|
607
|
+
* for wallet connection if not provided.
|
|
608
|
+
*
|
|
609
|
+
* @param request - Proof request to validate
|
|
610
|
+
* @returns Validation result with `valid` flag and optional `error` message
|
|
611
|
+
*/
|
|
707
612
|
function validateProofRequest(request) {
|
|
708
613
|
if (!request.requestId) {
|
|
709
614
|
return { valid: false, error: 'Missing requestId' };
|
|
@@ -759,14 +664,6 @@ function validateProofRequest(request) {
|
|
|
759
664
|
return { valid: false, error: 'provider must be a non-empty string when specified' };
|
|
760
665
|
}
|
|
761
666
|
}
|
|
762
|
-
else if (request.circuit === 'mdl_kr_ownership' ||
|
|
763
|
-
request.circuit === 'mdl_kr_age' ||
|
|
764
|
-
request.circuit === 'mdl_kr_region') {
|
|
765
|
-
const mdlError = validateMdlInputs(request.circuit, request.inputs);
|
|
766
|
-
if (mdlError) {
|
|
767
|
-
return { valid: false, error: mdlError };
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
667
|
// The action, decided by the circuit's own entry rather than by naming a
|
|
771
668
|
// circuit here, so every action-capable circuit is checked the same way.
|
|
772
669
|
{
|
|
@@ -1003,7 +900,7 @@ function estimateQRDataSize(requestOrUrl, scheme = DEFAULT_SCHEME) {
|
|
|
1003
900
|
* The version. `@aztec/bb.js` must be the WASM build of the same bb the
|
|
1004
901
|
* circuits are compiled with -- `BB_VERSION` in circuits/toolchain.env,
|
|
1005
902
|
* 4.2.0-aztecnr-rc.2 since the beta.19 toolchain. Versions are not
|
|
1006
|
-
* interchangeable: on
|
|
903
|
+
* interchangeable: on one of our circuits the 2025 nightly wrote
|
|
1007
904
|
* a 16256-byte proof where bb 1.2.0 wrote 16224 for the identical circuit and
|
|
1008
905
|
* witness, with the SAME verification key, so the key cannot warn you. A
|
|
1009
906
|
* mismatch shows up only as verification failing.
|
|
@@ -1105,15 +1002,12 @@ function normalisePublicInputs(publicInputs) {
|
|
|
1105
1002
|
*
|
|
1106
1003
|
* @internal
|
|
1107
1004
|
*/
|
|
1108
|
-
async function fetchVerificationKey(circuit, timeoutMs) {
|
|
1109
|
-
const
|
|
1005
|
+
async function fetchVerificationKey(circuit, variant, timeoutMs) {
|
|
1006
|
+
const cacheKey = `${circuit}/${variant}`;
|
|
1007
|
+
const cached = vkCache.get(cacheKey);
|
|
1110
1008
|
if (cached && Date.now() - cached.at < VK_CACHE_TTL_MS)
|
|
1111
1009
|
return cached.vk;
|
|
1112
|
-
const vkPath = circuits.
|
|
1113
|
-
if (!vkPath) {
|
|
1114
|
-
throw new Error(`No verification key path for circuit '${circuit}'. ` +
|
|
1115
|
-
`Add it to CIRCUIT_VK_PATHS, or pass verificationKey directly.`);
|
|
1116
|
-
}
|
|
1010
|
+
const vkPath = circuits.getCircuitPackage(circuit, variant).vkPath;
|
|
1117
1011
|
const url = `${CIRCUITS_VK_BASE}/${vkPath}`;
|
|
1118
1012
|
const controller = new AbortController();
|
|
1119
1013
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -1130,7 +1024,7 @@ async function fetchVerificationKey(circuit, timeoutMs) {
|
|
|
1130
1024
|
throw new Error(`The verification key at ${url} is ${vk.length} bytes, far too small to be one. ` +
|
|
1131
1025
|
`The path is probably wrong and something else was served.`);
|
|
1132
1026
|
}
|
|
1133
|
-
vkCache.set(
|
|
1027
|
+
vkCache.set(cacheKey, { vk, at: Date.now() });
|
|
1134
1028
|
return vk;
|
|
1135
1029
|
}
|
|
1136
1030
|
finally {
|
|
@@ -1170,6 +1064,10 @@ async function verifyProofOffChain(circuit, proof, publicInputs, options = {}) {
|
|
|
1170
1064
|
if (!circuits.isCircuitId(circuit)) {
|
|
1171
1065
|
return { valid: false, error: `Unknown circuit '${circuit}'. Known: ${circuits.ALL_CIRCUIT_IDS.join(', ')}.` };
|
|
1172
1066
|
}
|
|
1067
|
+
const signer = circuits.resolveSignerVariant(circuit, options.signerVariant, proof);
|
|
1068
|
+
if ('error' in signer) {
|
|
1069
|
+
return { valid: false, error: signer.error };
|
|
1070
|
+
}
|
|
1173
1071
|
// Before Barretenberg, and for the same reason as on-chain: a proof can be
|
|
1174
1072
|
// mathematically valid and still mean nothing, because some circuits take
|
|
1175
1073
|
// their trust anchor as a public input the prover chooses. For OIDC that is
|
|
@@ -1216,7 +1114,7 @@ async function verifyProofOffChain(circuit, proof, publicInputs, options = {}) {
|
|
|
1216
1114
|
// relay can deliver a short value (`0x01`), and the check below must see
|
|
1217
1115
|
// exactly what the circuit committed to.
|
|
1218
1116
|
const fields = normalisePublicInputs(publicInputs);
|
|
1219
|
-
const vk = options.verificationKey ?? (await fetchVerificationKey(circuit, timeoutMs));
|
|
1117
|
+
const vk = options.verificationKey ?? (await fetchVerificationKey(circuit, signer.variant, timeoutMs));
|
|
1220
1118
|
const barretenberg = await bb.Barretenberg.new({ threads: 1 });
|
|
1221
1119
|
api = barretenberg;
|
|
1222
1120
|
const verifier = new bb.UltraHonkVerifierBackend(barretenberg);
|
|
@@ -1250,6 +1148,17 @@ const RELAY_TERMINAL_STATUSES = ['completed', 'error', 'failed', 'cancelled', 'e
|
|
|
1250
1148
|
function isTerminalRelayStatus(status) {
|
|
1251
1149
|
return RELAY_TERMINAL_STATUSES.includes(status);
|
|
1252
1150
|
}
|
|
1151
|
+
/**
|
|
1152
|
+
* How long `waitForProof()` / `waitForResult()` wait when the caller passes no
|
|
1153
|
+
* `timeoutMs`: 600 000 ms (10 min).
|
|
1154
|
+
*
|
|
1155
|
+
* The relay answers `expired` itself at 540 s, so with this default a dApp
|
|
1156
|
+
* always gets a terminal status to branch on rather than its own timeout. A
|
|
1157
|
+
* heavy proof on an older phone takes a few minutes after the user confirms;
|
|
1158
|
+
* the earlier 300 000 ms default could fire while such a proof was still being
|
|
1159
|
+
* made.
|
|
1160
|
+
*/
|
|
1161
|
+
const DEFAULT_RELAY_WAIT_MS = 600000;
|
|
1253
1162
|
|
|
1254
1163
|
/**
|
|
1255
1164
|
* Proofport SDK - Main class
|
|
@@ -1400,7 +1309,7 @@ class ProofportSDK {
|
|
|
1400
1309
|
const request = {
|
|
1401
1310
|
requestId: generateRequestId(),
|
|
1402
1311
|
// The circuit asked for, always. This used to be the literal
|
|
1403
|
-
// 'coinbase_attestation', and every circuit that was not country
|
|
1312
|
+
// 'coinbase_attestation', and every circuit that was not country
|
|
1404
1313
|
// was routed here -- a GIWA, Dojang or OIDC request silently became a
|
|
1405
1314
|
// Coinbase KYC request.
|
|
1406
1315
|
circuit,
|
|
@@ -1507,45 +1416,10 @@ class ProofportSDK {
|
|
|
1507
1416
|
switch (builder) {
|
|
1508
1417
|
case 'country':
|
|
1509
1418
|
return this.createCoinbaseCountryRequest(inputs, options);
|
|
1510
|
-
case 'mdl':
|
|
1511
|
-
return this.createMdlKrRequest(circuit, inputs, options);
|
|
1512
1419
|
case 'scoped':
|
|
1513
1420
|
return this.createScopedRequest(circuit, inputs, options);
|
|
1514
1421
|
}
|
|
1515
1422
|
}
|
|
1516
|
-
/**
|
|
1517
|
-
* @internal
|
|
1518
|
-
* Creates a Korea Mobile ID (mDL) proof request for any of the three
|
|
1519
|
-
* mDL predicate circuits (ownership / age / region).
|
|
1520
|
-
*
|
|
1521
|
-
* The mobile app collects the license data on-device; the dapp only
|
|
1522
|
-
* supplies the predicate parameters validated here. No wallet signature
|
|
1523
|
-
* is required for mDL circuits.
|
|
1524
|
-
*
|
|
1525
|
-
* @param circuit - 'mdl_kr_ownership' | 'mdl_kr_age' | 'mdl_kr_region'
|
|
1526
|
-
* @param inputs - Predicate inputs (see MdlKr*Inputs types)
|
|
1527
|
-
* @param options - Request configuration options
|
|
1528
|
-
*
|
|
1529
|
-
* @throws Error if the predicate inputs fail validation
|
|
1530
|
-
*/
|
|
1531
|
-
createMdlKrRequest(circuit, inputs, options = {}) {
|
|
1532
|
-
const mdlError = validateMdlInputs(circuit, inputs);
|
|
1533
|
-
if (mdlError) {
|
|
1534
|
-
throw new Error(`${mdlError} (circuit: ${circuit})`);
|
|
1535
|
-
}
|
|
1536
|
-
const request = {
|
|
1537
|
-
requestId: generateRequestId(),
|
|
1538
|
-
circuit,
|
|
1539
|
-
inputs,
|
|
1540
|
-
message: options.message,
|
|
1541
|
-
dappName: options.dappName,
|
|
1542
|
-
dappIcon: options.dappIcon,
|
|
1543
|
-
createdAt: Date.now(),
|
|
1544
|
-
expiresAt: Date.now() + (options.expiresInMs || DEFAULT_REQUEST_EXPIRY_MS),
|
|
1545
|
-
};
|
|
1546
|
-
this.pendingRequests.set(request.requestId, request);
|
|
1547
|
-
return request;
|
|
1548
|
-
}
|
|
1549
1423
|
// ============ Deep Link Generation ============
|
|
1550
1424
|
/**
|
|
1551
1425
|
* @internal
|
|
@@ -1889,6 +1763,7 @@ class ProofportSDK {
|
|
|
1889
1763
|
const parsedProof = core.parseProofForOnChain(proof, publicInputs, publicInputs.length);
|
|
1890
1764
|
return core.verifyProofOnChain(circuit, parsedProof, providerOrSigner, this.verifierTarget(circuit), undefined, {
|
|
1891
1765
|
request: options.request,
|
|
1766
|
+
signerVariant: options.signerVariant,
|
|
1892
1767
|
});
|
|
1893
1768
|
}
|
|
1894
1769
|
/**
|
|
@@ -2002,7 +1877,7 @@ class ProofportSDK {
|
|
|
2002
1877
|
return core.verifyProofOnChain(response.circuit, parsedProof, providerOrSigner, this.verifierTarget(response.circuit), {
|
|
2003
1878
|
verifierAddress: response.verifierAddress,
|
|
2004
1879
|
chainId: response.chainId,
|
|
2005
|
-
}, { request });
|
|
1880
|
+
}, { request, signerVariant: response.signerVariant });
|
|
2006
1881
|
}
|
|
2007
1882
|
/**
|
|
2008
1883
|
* Verifies a proof response off-chain, against the circuit's verification key.
|
|
@@ -2039,7 +1914,7 @@ class ProofportSDK {
|
|
|
2039
1914
|
return { valid: false, error: found.error };
|
|
2040
1915
|
request = found.request;
|
|
2041
1916
|
}
|
|
2042
|
-
return verifyProofOffChain(response.circuit, response.proof, response.publicInputs, { ...options, request });
|
|
1917
|
+
return verifyProofOffChain(response.circuit, response.proof, response.publicInputs, { ...options, request, signerVariant: response.signerVariant });
|
|
2043
1918
|
}
|
|
2044
1919
|
// ============ Utility Methods ============
|
|
2045
1920
|
/**
|
|
@@ -2397,14 +2272,6 @@ class ProofportSDK {
|
|
|
2397
2272
|
if (needsSignature && !this.signer) {
|
|
2398
2273
|
throw new Error('Signer not set. Call setSigner() first. Wallet signature is required for this circuit.');
|
|
2399
2274
|
}
|
|
2400
|
-
// mDL circuits: validate predicate inputs client-side before hitting the
|
|
2401
|
-
// relay, so a bad ageThreshold / targetRegion fails fast with a clear error.
|
|
2402
|
-
if (circuit === 'mdl_kr_ownership' || circuit === 'mdl_kr_age' || circuit === 'mdl_kr_region') {
|
|
2403
|
-
const mdlError = validateMdlInputs(circuit, inputs);
|
|
2404
|
-
if (mdlError) {
|
|
2405
|
-
throw new Error(`${mdlError} (circuit: ${circuit})`);
|
|
2406
|
-
}
|
|
2407
|
-
}
|
|
2408
2275
|
// The action, per the circuit's entry in CIRCUIT_ACTION_BINDING. Checked
|
|
2409
2276
|
// here, before a challenge is burned, because the alternative is a refusal
|
|
2410
2277
|
// from inside the mobile app -- a screen the dapp developer never sees,
|
|
@@ -2520,14 +2387,14 @@ class ProofportSDK {
|
|
|
2520
2387
|
* @param requestId - The relay-issued request ID
|
|
2521
2388
|
* @param options - Polling options
|
|
2522
2389
|
* @param options.intervalMs - Polling interval in milliseconds (default: 2000)
|
|
2523
|
-
* @param options.timeoutMs - Maximum polling time in milliseconds (default:
|
|
2390
|
+
* @param options.timeoutMs - Maximum polling time in milliseconds (default: 600000 = 10 min, `DEFAULT_RELAY_WAIT_MS`)
|
|
2524
2391
|
* @param options.onStatusChange - Callback when status changes
|
|
2525
2392
|
* @returns Promise resolving to final RelayProofResult
|
|
2526
2393
|
* @throws Error if timeout or relay error
|
|
2527
2394
|
*/
|
|
2528
2395
|
async waitForResult(requestId, options = {}) {
|
|
2529
2396
|
const interval = options.intervalMs || 2000;
|
|
2530
|
-
const timeout = options.timeoutMs ||
|
|
2397
|
+
const timeout = options.timeoutMs || DEFAULT_RELAY_WAIT_MS;
|
|
2531
2398
|
const startTime = Date.now();
|
|
2532
2399
|
let lastStatus = '';
|
|
2533
2400
|
while (Date.now() - startTime < timeout) {
|
|
@@ -2639,12 +2506,12 @@ class ProofportSDK {
|
|
|
2639
2506
|
*
|
|
2640
2507
|
* @param requestId - The relay-issued request ID
|
|
2641
2508
|
* @param options - Configuration options
|
|
2642
|
-
* @param options.timeoutMs - Maximum wait time in ms (default:
|
|
2509
|
+
* @param options.timeoutMs - Maximum wait time in ms (default: 600000 = 10 min, `DEFAULT_RELAY_WAIT_MS`)
|
|
2643
2510
|
* @param options.onStatusChange - Callback for status updates
|
|
2644
2511
|
* @returns Promise resolving to final RelayProofResult
|
|
2645
2512
|
*/
|
|
2646
2513
|
async waitForProof(requestId, options = {}) {
|
|
2647
|
-
const timeout = options.timeoutMs ||
|
|
2514
|
+
const timeout = options.timeoutMs || DEFAULT_RELAY_WAIT_MS;
|
|
2648
2515
|
// Try Socket.IO first
|
|
2649
2516
|
if (this.relayUrl) {
|
|
2650
2517
|
try {
|
|
@@ -2776,9 +2643,6 @@ ProofportSDK.REQUEST_BUILDERS = {
|
|
|
2776
2643
|
oidc_domain_attestation: 'scoped',
|
|
2777
2644
|
giwa_attestation: 'scoped',
|
|
2778
2645
|
dojang_playground: 'scoped',
|
|
2779
|
-
mdl_kr_ownership: 'mdl',
|
|
2780
|
-
mdl_kr_age: 'mdl',
|
|
2781
|
-
mdl_kr_region: 'mdl',
|
|
2782
2646
|
};
|
|
2783
2647
|
|
|
2784
2648
|
Object.defineProperty(exports, "COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT", {
|
|
@@ -2789,10 +2653,6 @@ Object.defineProperty(exports, "COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT", {
|
|
|
2789
2653
|
enumerable: true,
|
|
2790
2654
|
get: function () { return core.COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT; }
|
|
2791
2655
|
});
|
|
2792
|
-
Object.defineProperty(exports, "MDL_KR_PUBLIC_INPUT_LAYOUT", {
|
|
2793
|
-
enumerable: true,
|
|
2794
|
-
get: function () { return core.MDL_KR_PUBLIC_INPUT_LAYOUT; }
|
|
2795
|
-
});
|
|
2796
2656
|
Object.defineProperty(exports, "OIDC_ALLOWED_AUDIENCES", {
|
|
2797
2657
|
enumerable: true,
|
|
2798
2658
|
get: function () { return core.OIDC_ALLOWED_AUDIENCES; }
|
|
@@ -2821,6 +2681,10 @@ Object.defineProperty(exports, "OIDC_V2_PUBLIC_INPUT_COUNT", {
|
|
|
2821
2681
|
enumerable: true,
|
|
2822
2682
|
get: function () { return core.OIDC_V2_PUBLIC_INPUT_COUNT; }
|
|
2823
2683
|
});
|
|
2684
|
+
Object.defineProperty(exports, "PINNED_VARIANT_VERIFIERS", {
|
|
2685
|
+
enumerable: true,
|
|
2686
|
+
get: function () { return core.PINNED_VARIANT_VERIFIERS; }
|
|
2687
|
+
});
|
|
2824
2688
|
Object.defineProperty(exports, "PINNED_VERIFIERS", {
|
|
2825
2689
|
enumerable: true,
|
|
2826
2690
|
get: function () { return core.PINNED_VERIFIERS; }
|
|
@@ -2845,6 +2709,10 @@ Object.defineProperty(exports, "extractScopeFromPublicInputs", {
|
|
|
2845
2709
|
enumerable: true,
|
|
2846
2710
|
get: function () { return core.extractScopeFromPublicInputs; }
|
|
2847
2711
|
});
|
|
2712
|
+
Object.defineProperty(exports, "getPinnedVariantVerifier", {
|
|
2713
|
+
enumerable: true,
|
|
2714
|
+
get: function () { return core.getPinnedVariantVerifier; }
|
|
2715
|
+
});
|
|
2848
2716
|
Object.defineProperty(exports, "getPinnedVerifier", {
|
|
2849
2717
|
enumerable: true,
|
|
2850
2718
|
get: function () { return core.getPinnedVerifier; }
|
|
@@ -2865,6 +2733,10 @@ Object.defineProperty(exports, "CIRCUIT_IDS", {
|
|
|
2865
2733
|
enumerable: true,
|
|
2866
2734
|
get: function () { return circuits.CIRCUIT_IDS; }
|
|
2867
2735
|
});
|
|
2736
|
+
Object.defineProperty(exports, "CIRCUIT_PACKAGES", {
|
|
2737
|
+
enumerable: true,
|
|
2738
|
+
get: function () { return circuits.CIRCUIT_PACKAGES; }
|
|
2739
|
+
});
|
|
2868
2740
|
Object.defineProperty(exports, "CIRCUIT_SUPPORT_STATUS", {
|
|
2869
2741
|
enumerable: true,
|
|
2870
2742
|
get: function () { return circuits.CIRCUIT_SUPPORT_STATUS; }
|
|
@@ -2881,6 +2753,10 @@ Object.defineProperty(exports, "PLANNED_CIRCUIT_IDS", {
|
|
|
2881
2753
|
enumerable: true,
|
|
2882
2754
|
get: function () { return circuits.PLANNED_CIRCUIT_IDS; }
|
|
2883
2755
|
});
|
|
2756
|
+
Object.defineProperty(exports, "SIGNER_VARIANTS", {
|
|
2757
|
+
enumerable: true,
|
|
2758
|
+
get: function () { return circuits.SIGNER_VARIANTS; }
|
|
2759
|
+
});
|
|
2884
2760
|
Object.defineProperty(exports, "SUPPORTED_CIRCUIT_IDS", {
|
|
2885
2761
|
enumerable: true,
|
|
2886
2762
|
get: function () { return circuits.SUPPORTED_CIRCUIT_IDS; }
|
|
@@ -2889,6 +2765,14 @@ Object.defineProperty(exports, "circuitActionBinding", {
|
|
|
2889
2765
|
enumerable: true,
|
|
2890
2766
|
get: function () { return circuits.circuitActionBinding; }
|
|
2891
2767
|
});
|
|
2768
|
+
Object.defineProperty(exports, "evmProofByteLength", {
|
|
2769
|
+
enumerable: true,
|
|
2770
|
+
get: function () { return circuits.evmProofByteLength; }
|
|
2771
|
+
});
|
|
2772
|
+
Object.defineProperty(exports, "getCircuitPackage", {
|
|
2773
|
+
enumerable: true,
|
|
2774
|
+
get: function () { return circuits.getCircuitPackage; }
|
|
2775
|
+
});
|
|
2892
2776
|
Object.defineProperty(exports, "getCircuitSupportStatus", {
|
|
2893
2777
|
enumerable: true,
|
|
2894
2778
|
get: function () { return circuits.getCircuitSupportStatus; }
|
|
@@ -2897,10 +2781,22 @@ Object.defineProperty(exports, "isCircuitId", {
|
|
|
2897
2781
|
enumerable: true,
|
|
2898
2782
|
get: function () { return circuits.isCircuitId; }
|
|
2899
2783
|
});
|
|
2784
|
+
Object.defineProperty(exports, "isSignerVariant", {
|
|
2785
|
+
enumerable: true,
|
|
2786
|
+
get: function () { return circuits.isSignerVariant; }
|
|
2787
|
+
});
|
|
2900
2788
|
Object.defineProperty(exports, "isSupportedCircuitId", {
|
|
2901
2789
|
enumerable: true,
|
|
2902
2790
|
get: function () { return circuits.isSupportedCircuitId; }
|
|
2903
2791
|
});
|
|
2792
|
+
Object.defineProperty(exports, "resolveSignerVariant", {
|
|
2793
|
+
enumerable: true,
|
|
2794
|
+
get: function () { return circuits.resolveSignerVariant; }
|
|
2795
|
+
});
|
|
2796
|
+
Object.defineProperty(exports, "signerVariantsOf", {
|
|
2797
|
+
enumerable: true,
|
|
2798
|
+
get: function () { return circuits.signerVariantsOf; }
|
|
2799
|
+
});
|
|
2904
2800
|
Object.defineProperty(exports, "parseTypedAction", {
|
|
2905
2801
|
enumerable: true,
|
|
2906
2802
|
get: function () { return typedAction.parseTypedAction; }
|
|
@@ -2909,6 +2805,7 @@ Object.defineProperty(exports, "validateTypedAction", {
|
|
|
2909
2805
|
enumerable: true,
|
|
2910
2806
|
get: function () { return typedAction.validateTypedAction; }
|
|
2911
2807
|
});
|
|
2808
|
+
exports.DEFAULT_RELAY_WAIT_MS = DEFAULT_RELAY_WAIT_MS;
|
|
2912
2809
|
exports.ProofportSDK = ProofportSDK;
|
|
2913
2810
|
exports.RELAY_TERMINAL_STATUSES = RELAY_TERMINAL_STATUSES;
|
|
2914
2811
|
exports.default = ProofportSDK;
|