@zkproofport-app/sdk 0.5.0-beta.3 → 0.5.0-beta.4
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 +23 -119
- package/dist/ProofportSDK.d.ts +3 -18
- package/dist/constants.d.ts +2 -11
- package/dist/deeplink.d.ts +17 -18
- package/dist/index.d.ts +6 -6
- package/dist/index.esm.js +57 -194
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +90 -194
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -194
- 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
|
/**
|
|
@@ -162,27 +153,6 @@ const CIRCUIT_METADATA = {
|
|
|
162
153
|
publicInputsCount: 160,
|
|
163
154
|
publicInputNames: ['signal_hash', 'domain_separator', 'action_hash', 'scope', 'nullifier'],
|
|
164
155
|
},
|
|
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
156
|
};
|
|
187
157
|
/**
|
|
188
158
|
* Default proof request expiration time in milliseconds.
|
|
@@ -426,6 +396,12 @@ function parseProofResponseUrl(url) {
|
|
|
426
396
|
if (timestamp) {
|
|
427
397
|
response.timestamp = parseInt(timestamp, 10);
|
|
428
398
|
}
|
|
399
|
+
// Kept as sent, even when unknown: verification refuses it by name,
|
|
400
|
+
// which says more than a callback that fails to parse.
|
|
401
|
+
const signerVariant = urlObj.searchParams.get('signerVariant');
|
|
402
|
+
if (signerVariant !== null) {
|
|
403
|
+
response.signerVariant = signerVariant;
|
|
404
|
+
}
|
|
429
405
|
}
|
|
430
406
|
else if (status === 'error') {
|
|
431
407
|
response.error = urlObj.searchParams.get('error') || undefined;
|
|
@@ -457,94 +433,6 @@ function parseProofResponseUrl(url) {
|
|
|
457
433
|
function isProofportDeepLink(url, scheme = DEFAULT_SCHEME) {
|
|
458
434
|
return url.toLowerCase().startsWith(`${scheme.toLowerCase()}://`);
|
|
459
435
|
}
|
|
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
436
|
/**
|
|
549
437
|
* Longest accepted `returnScheme` value.
|
|
550
438
|
* Kept in sync with proofport-relay `src/returnScheme.ts`.
|
|
@@ -704,6 +592,22 @@ function detectReturnScheme(userAgent) {
|
|
|
704
592
|
}
|
|
705
593
|
return undefined;
|
|
706
594
|
}
|
|
595
|
+
/**
|
|
596
|
+
* @internal
|
|
597
|
+
* Validates a proof request for completeness and correctness.
|
|
598
|
+
*
|
|
599
|
+
* Performs comprehensive validation including:
|
|
600
|
+
* - Required fields (requestId, circuit, callbackUrl)
|
|
601
|
+
* - Circuit type validity (must be a supported circuit)
|
|
602
|
+
* - Circuit-specific input validation (e.g., userAddress format, countryList structure)
|
|
603
|
+
* - Expiration check (if expiresAt is provided)
|
|
604
|
+
*
|
|
605
|
+
* Note: userAddress is optional for both circuits - the mobile app will prompt
|
|
606
|
+
* for wallet connection if not provided.
|
|
607
|
+
*
|
|
608
|
+
* @param request - Proof request to validate
|
|
609
|
+
* @returns Validation result with `valid` flag and optional `error` message
|
|
610
|
+
*/
|
|
707
611
|
function validateProofRequest(request) {
|
|
708
612
|
if (!request.requestId) {
|
|
709
613
|
return { valid: false, error: 'Missing requestId' };
|
|
@@ -759,14 +663,6 @@ function validateProofRequest(request) {
|
|
|
759
663
|
return { valid: false, error: 'provider must be a non-empty string when specified' };
|
|
760
664
|
}
|
|
761
665
|
}
|
|
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
666
|
// The action, decided by the circuit's own entry rather than by naming a
|
|
771
667
|
// circuit here, so every action-capable circuit is checked the same way.
|
|
772
668
|
{
|
|
@@ -1003,7 +899,7 @@ function estimateQRDataSize(requestOrUrl, scheme = DEFAULT_SCHEME) {
|
|
|
1003
899
|
* The version. `@aztec/bb.js` must be the WASM build of the same bb the
|
|
1004
900
|
* circuits are compiled with -- `BB_VERSION` in circuits/toolchain.env,
|
|
1005
901
|
* 4.2.0-aztecnr-rc.2 since the beta.19 toolchain. Versions are not
|
|
1006
|
-
* interchangeable: on
|
|
902
|
+
* interchangeable: on one of our circuits the 2025 nightly wrote
|
|
1007
903
|
* a 16256-byte proof where bb 1.2.0 wrote 16224 for the identical circuit and
|
|
1008
904
|
* witness, with the SAME verification key, so the key cannot warn you. A
|
|
1009
905
|
* mismatch shows up only as verification failing.
|
|
@@ -1105,15 +1001,12 @@ function normalisePublicInputs(publicInputs) {
|
|
|
1105
1001
|
*
|
|
1106
1002
|
* @internal
|
|
1107
1003
|
*/
|
|
1108
|
-
async function fetchVerificationKey(circuit, timeoutMs) {
|
|
1109
|
-
const
|
|
1004
|
+
async function fetchVerificationKey(circuit, variant, timeoutMs) {
|
|
1005
|
+
const cacheKey = `${circuit}/${variant}`;
|
|
1006
|
+
const cached = vkCache.get(cacheKey);
|
|
1110
1007
|
if (cached && Date.now() - cached.at < VK_CACHE_TTL_MS)
|
|
1111
1008
|
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
|
-
}
|
|
1009
|
+
const vkPath = circuits.getCircuitPackage(circuit, variant).vkPath;
|
|
1117
1010
|
const url = `${CIRCUITS_VK_BASE}/${vkPath}`;
|
|
1118
1011
|
const controller = new AbortController();
|
|
1119
1012
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -1130,7 +1023,7 @@ async function fetchVerificationKey(circuit, timeoutMs) {
|
|
|
1130
1023
|
throw new Error(`The verification key at ${url} is ${vk.length} bytes, far too small to be one. ` +
|
|
1131
1024
|
`The path is probably wrong and something else was served.`);
|
|
1132
1025
|
}
|
|
1133
|
-
vkCache.set(
|
|
1026
|
+
vkCache.set(cacheKey, { vk, at: Date.now() });
|
|
1134
1027
|
return vk;
|
|
1135
1028
|
}
|
|
1136
1029
|
finally {
|
|
@@ -1170,6 +1063,10 @@ async function verifyProofOffChain(circuit, proof, publicInputs, options = {}) {
|
|
|
1170
1063
|
if (!circuits.isCircuitId(circuit)) {
|
|
1171
1064
|
return { valid: false, error: `Unknown circuit '${circuit}'. Known: ${circuits.ALL_CIRCUIT_IDS.join(', ')}.` };
|
|
1172
1065
|
}
|
|
1066
|
+
const signer = circuits.resolveSignerVariant(circuit, options.signerVariant, proof);
|
|
1067
|
+
if ('error' in signer) {
|
|
1068
|
+
return { valid: false, error: signer.error };
|
|
1069
|
+
}
|
|
1173
1070
|
// Before Barretenberg, and for the same reason as on-chain: a proof can be
|
|
1174
1071
|
// mathematically valid and still mean nothing, because some circuits take
|
|
1175
1072
|
// their trust anchor as a public input the prover chooses. For OIDC that is
|
|
@@ -1216,7 +1113,7 @@ async function verifyProofOffChain(circuit, proof, publicInputs, options = {}) {
|
|
|
1216
1113
|
// relay can deliver a short value (`0x01`), and the check below must see
|
|
1217
1114
|
// exactly what the circuit committed to.
|
|
1218
1115
|
const fields = normalisePublicInputs(publicInputs);
|
|
1219
|
-
const vk = options.verificationKey ?? (await fetchVerificationKey(circuit, timeoutMs));
|
|
1116
|
+
const vk = options.verificationKey ?? (await fetchVerificationKey(circuit, signer.variant, timeoutMs));
|
|
1220
1117
|
const barretenberg = await bb.Barretenberg.new({ threads: 1 });
|
|
1221
1118
|
api = barretenberg;
|
|
1222
1119
|
const verifier = new bb.UltraHonkVerifierBackend(barretenberg);
|
|
@@ -1250,6 +1147,17 @@ const RELAY_TERMINAL_STATUSES = ['completed', 'error', 'failed', 'cancelled', 'e
|
|
|
1250
1147
|
function isTerminalRelayStatus(status) {
|
|
1251
1148
|
return RELAY_TERMINAL_STATUSES.includes(status);
|
|
1252
1149
|
}
|
|
1150
|
+
/**
|
|
1151
|
+
* How long `waitForProof()` / `waitForResult()` wait when the caller passes no
|
|
1152
|
+
* `timeoutMs`: 600 000 ms (10 min).
|
|
1153
|
+
*
|
|
1154
|
+
* The relay answers `expired` itself at 540 s, so with this default a dApp
|
|
1155
|
+
* always gets a terminal status to branch on rather than its own timeout. A
|
|
1156
|
+
* heavy proof on an older phone takes a few minutes after the user confirms;
|
|
1157
|
+
* the earlier 300 000 ms default could fire while such a proof was still being
|
|
1158
|
+
* made.
|
|
1159
|
+
*/
|
|
1160
|
+
const DEFAULT_RELAY_WAIT_MS = 600000;
|
|
1253
1161
|
|
|
1254
1162
|
/**
|
|
1255
1163
|
* Proofport SDK - Main class
|
|
@@ -1400,7 +1308,7 @@ class ProofportSDK {
|
|
|
1400
1308
|
const request = {
|
|
1401
1309
|
requestId: generateRequestId(),
|
|
1402
1310
|
// The circuit asked for, always. This used to be the literal
|
|
1403
|
-
// 'coinbase_attestation', and every circuit that was not country
|
|
1311
|
+
// 'coinbase_attestation', and every circuit that was not country
|
|
1404
1312
|
// was routed here -- a GIWA, Dojang or OIDC request silently became a
|
|
1405
1313
|
// Coinbase KYC request.
|
|
1406
1314
|
circuit,
|
|
@@ -1507,45 +1415,10 @@ class ProofportSDK {
|
|
|
1507
1415
|
switch (builder) {
|
|
1508
1416
|
case 'country':
|
|
1509
1417
|
return this.createCoinbaseCountryRequest(inputs, options);
|
|
1510
|
-
case 'mdl':
|
|
1511
|
-
return this.createMdlKrRequest(circuit, inputs, options);
|
|
1512
1418
|
case 'scoped':
|
|
1513
1419
|
return this.createScopedRequest(circuit, inputs, options);
|
|
1514
1420
|
}
|
|
1515
1421
|
}
|
|
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
1422
|
// ============ Deep Link Generation ============
|
|
1550
1423
|
/**
|
|
1551
1424
|
* @internal
|
|
@@ -1889,6 +1762,7 @@ class ProofportSDK {
|
|
|
1889
1762
|
const parsedProof = core.parseProofForOnChain(proof, publicInputs, publicInputs.length);
|
|
1890
1763
|
return core.verifyProofOnChain(circuit, parsedProof, providerOrSigner, this.verifierTarget(circuit), undefined, {
|
|
1891
1764
|
request: options.request,
|
|
1765
|
+
signerVariant: options.signerVariant,
|
|
1892
1766
|
});
|
|
1893
1767
|
}
|
|
1894
1768
|
/**
|
|
@@ -2002,7 +1876,7 @@ class ProofportSDK {
|
|
|
2002
1876
|
return core.verifyProofOnChain(response.circuit, parsedProof, providerOrSigner, this.verifierTarget(response.circuit), {
|
|
2003
1877
|
verifierAddress: response.verifierAddress,
|
|
2004
1878
|
chainId: response.chainId,
|
|
2005
|
-
}, { request });
|
|
1879
|
+
}, { request, signerVariant: response.signerVariant });
|
|
2006
1880
|
}
|
|
2007
1881
|
/**
|
|
2008
1882
|
* Verifies a proof response off-chain, against the circuit's verification key.
|
|
@@ -2039,7 +1913,7 @@ class ProofportSDK {
|
|
|
2039
1913
|
return { valid: false, error: found.error };
|
|
2040
1914
|
request = found.request;
|
|
2041
1915
|
}
|
|
2042
|
-
return verifyProofOffChain(response.circuit, response.proof, response.publicInputs, { ...options, request });
|
|
1916
|
+
return verifyProofOffChain(response.circuit, response.proof, response.publicInputs, { ...options, request, signerVariant: response.signerVariant });
|
|
2043
1917
|
}
|
|
2044
1918
|
// ============ Utility Methods ============
|
|
2045
1919
|
/**
|
|
@@ -2397,14 +2271,6 @@ class ProofportSDK {
|
|
|
2397
2271
|
if (needsSignature && !this.signer) {
|
|
2398
2272
|
throw new Error('Signer not set. Call setSigner() first. Wallet signature is required for this circuit.');
|
|
2399
2273
|
}
|
|
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
2274
|
// The action, per the circuit's entry in CIRCUIT_ACTION_BINDING. Checked
|
|
2409
2275
|
// here, before a challenge is burned, because the alternative is a refusal
|
|
2410
2276
|
// from inside the mobile app -- a screen the dapp developer never sees,
|
|
@@ -2520,14 +2386,14 @@ class ProofportSDK {
|
|
|
2520
2386
|
* @param requestId - The relay-issued request ID
|
|
2521
2387
|
* @param options - Polling options
|
|
2522
2388
|
* @param options.intervalMs - Polling interval in milliseconds (default: 2000)
|
|
2523
|
-
* @param options.timeoutMs - Maximum polling time in milliseconds (default:
|
|
2389
|
+
* @param options.timeoutMs - Maximum polling time in milliseconds (default: 600000 = 10 min, `DEFAULT_RELAY_WAIT_MS`)
|
|
2524
2390
|
* @param options.onStatusChange - Callback when status changes
|
|
2525
2391
|
* @returns Promise resolving to final RelayProofResult
|
|
2526
2392
|
* @throws Error if timeout or relay error
|
|
2527
2393
|
*/
|
|
2528
2394
|
async waitForResult(requestId, options = {}) {
|
|
2529
2395
|
const interval = options.intervalMs || 2000;
|
|
2530
|
-
const timeout = options.timeoutMs ||
|
|
2396
|
+
const timeout = options.timeoutMs || DEFAULT_RELAY_WAIT_MS;
|
|
2531
2397
|
const startTime = Date.now();
|
|
2532
2398
|
let lastStatus = '';
|
|
2533
2399
|
while (Date.now() - startTime < timeout) {
|
|
@@ -2639,12 +2505,12 @@ class ProofportSDK {
|
|
|
2639
2505
|
*
|
|
2640
2506
|
* @param requestId - The relay-issued request ID
|
|
2641
2507
|
* @param options - Configuration options
|
|
2642
|
-
* @param options.timeoutMs - Maximum wait time in ms (default:
|
|
2508
|
+
* @param options.timeoutMs - Maximum wait time in ms (default: 600000 = 10 min, `DEFAULT_RELAY_WAIT_MS`)
|
|
2643
2509
|
* @param options.onStatusChange - Callback for status updates
|
|
2644
2510
|
* @returns Promise resolving to final RelayProofResult
|
|
2645
2511
|
*/
|
|
2646
2512
|
async waitForProof(requestId, options = {}) {
|
|
2647
|
-
const timeout = options.timeoutMs ||
|
|
2513
|
+
const timeout = options.timeoutMs || DEFAULT_RELAY_WAIT_MS;
|
|
2648
2514
|
// Try Socket.IO first
|
|
2649
2515
|
if (this.relayUrl) {
|
|
2650
2516
|
try {
|
|
@@ -2776,9 +2642,6 @@ ProofportSDK.REQUEST_BUILDERS = {
|
|
|
2776
2642
|
oidc_domain_attestation: 'scoped',
|
|
2777
2643
|
giwa_attestation: 'scoped',
|
|
2778
2644
|
dojang_playground: 'scoped',
|
|
2779
|
-
mdl_kr_ownership: 'mdl',
|
|
2780
|
-
mdl_kr_age: 'mdl',
|
|
2781
|
-
mdl_kr_region: 'mdl',
|
|
2782
2645
|
};
|
|
2783
2646
|
|
|
2784
2647
|
Object.defineProperty(exports, "COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT", {
|
|
@@ -2789,10 +2652,6 @@ Object.defineProperty(exports, "COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT", {
|
|
|
2789
2652
|
enumerable: true,
|
|
2790
2653
|
get: function () { return core.COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT; }
|
|
2791
2654
|
});
|
|
2792
|
-
Object.defineProperty(exports, "MDL_KR_PUBLIC_INPUT_LAYOUT", {
|
|
2793
|
-
enumerable: true,
|
|
2794
|
-
get: function () { return core.MDL_KR_PUBLIC_INPUT_LAYOUT; }
|
|
2795
|
-
});
|
|
2796
2655
|
Object.defineProperty(exports, "OIDC_ALLOWED_AUDIENCES", {
|
|
2797
2656
|
enumerable: true,
|
|
2798
2657
|
get: function () { return core.OIDC_ALLOWED_AUDIENCES; }
|
|
@@ -2821,6 +2680,10 @@ Object.defineProperty(exports, "OIDC_V2_PUBLIC_INPUT_COUNT", {
|
|
|
2821
2680
|
enumerable: true,
|
|
2822
2681
|
get: function () { return core.OIDC_V2_PUBLIC_INPUT_COUNT; }
|
|
2823
2682
|
});
|
|
2683
|
+
Object.defineProperty(exports, "PINNED_VARIANT_VERIFIERS", {
|
|
2684
|
+
enumerable: true,
|
|
2685
|
+
get: function () { return core.PINNED_VARIANT_VERIFIERS; }
|
|
2686
|
+
});
|
|
2824
2687
|
Object.defineProperty(exports, "PINNED_VERIFIERS", {
|
|
2825
2688
|
enumerable: true,
|
|
2826
2689
|
get: function () { return core.PINNED_VERIFIERS; }
|
|
@@ -2845,6 +2708,10 @@ Object.defineProperty(exports, "extractScopeFromPublicInputs", {
|
|
|
2845
2708
|
enumerable: true,
|
|
2846
2709
|
get: function () { return core.extractScopeFromPublicInputs; }
|
|
2847
2710
|
});
|
|
2711
|
+
Object.defineProperty(exports, "getPinnedVariantVerifier", {
|
|
2712
|
+
enumerable: true,
|
|
2713
|
+
get: function () { return core.getPinnedVariantVerifier; }
|
|
2714
|
+
});
|
|
2848
2715
|
Object.defineProperty(exports, "getPinnedVerifier", {
|
|
2849
2716
|
enumerable: true,
|
|
2850
2717
|
get: function () { return core.getPinnedVerifier; }
|
|
@@ -2865,6 +2732,10 @@ Object.defineProperty(exports, "CIRCUIT_IDS", {
|
|
|
2865
2732
|
enumerable: true,
|
|
2866
2733
|
get: function () { return circuits.CIRCUIT_IDS; }
|
|
2867
2734
|
});
|
|
2735
|
+
Object.defineProperty(exports, "CIRCUIT_PACKAGES", {
|
|
2736
|
+
enumerable: true,
|
|
2737
|
+
get: function () { return circuits.CIRCUIT_PACKAGES; }
|
|
2738
|
+
});
|
|
2868
2739
|
Object.defineProperty(exports, "CIRCUIT_SUPPORT_STATUS", {
|
|
2869
2740
|
enumerable: true,
|
|
2870
2741
|
get: function () { return circuits.CIRCUIT_SUPPORT_STATUS; }
|
|
@@ -2881,6 +2752,10 @@ Object.defineProperty(exports, "PLANNED_CIRCUIT_IDS", {
|
|
|
2881
2752
|
enumerable: true,
|
|
2882
2753
|
get: function () { return circuits.PLANNED_CIRCUIT_IDS; }
|
|
2883
2754
|
});
|
|
2755
|
+
Object.defineProperty(exports, "SIGNER_VARIANTS", {
|
|
2756
|
+
enumerable: true,
|
|
2757
|
+
get: function () { return circuits.SIGNER_VARIANTS; }
|
|
2758
|
+
});
|
|
2884
2759
|
Object.defineProperty(exports, "SUPPORTED_CIRCUIT_IDS", {
|
|
2885
2760
|
enumerable: true,
|
|
2886
2761
|
get: function () { return circuits.SUPPORTED_CIRCUIT_IDS; }
|
|
@@ -2889,6 +2764,14 @@ Object.defineProperty(exports, "circuitActionBinding", {
|
|
|
2889
2764
|
enumerable: true,
|
|
2890
2765
|
get: function () { return circuits.circuitActionBinding; }
|
|
2891
2766
|
});
|
|
2767
|
+
Object.defineProperty(exports, "evmProofByteLength", {
|
|
2768
|
+
enumerable: true,
|
|
2769
|
+
get: function () { return circuits.evmProofByteLength; }
|
|
2770
|
+
});
|
|
2771
|
+
Object.defineProperty(exports, "getCircuitPackage", {
|
|
2772
|
+
enumerable: true,
|
|
2773
|
+
get: function () { return circuits.getCircuitPackage; }
|
|
2774
|
+
});
|
|
2892
2775
|
Object.defineProperty(exports, "getCircuitSupportStatus", {
|
|
2893
2776
|
enumerable: true,
|
|
2894
2777
|
get: function () { return circuits.getCircuitSupportStatus; }
|
|
@@ -2897,10 +2780,22 @@ Object.defineProperty(exports, "isCircuitId", {
|
|
|
2897
2780
|
enumerable: true,
|
|
2898
2781
|
get: function () { return circuits.isCircuitId; }
|
|
2899
2782
|
});
|
|
2783
|
+
Object.defineProperty(exports, "isSignerVariant", {
|
|
2784
|
+
enumerable: true,
|
|
2785
|
+
get: function () { return circuits.isSignerVariant; }
|
|
2786
|
+
});
|
|
2900
2787
|
Object.defineProperty(exports, "isSupportedCircuitId", {
|
|
2901
2788
|
enumerable: true,
|
|
2902
2789
|
get: function () { return circuits.isSupportedCircuitId; }
|
|
2903
2790
|
});
|
|
2791
|
+
Object.defineProperty(exports, "resolveSignerVariant", {
|
|
2792
|
+
enumerable: true,
|
|
2793
|
+
get: function () { return circuits.resolveSignerVariant; }
|
|
2794
|
+
});
|
|
2795
|
+
Object.defineProperty(exports, "signerVariantsOf", {
|
|
2796
|
+
enumerable: true,
|
|
2797
|
+
get: function () { return circuits.signerVariantsOf; }
|
|
2798
|
+
});
|
|
2904
2799
|
Object.defineProperty(exports, "parseTypedAction", {
|
|
2905
2800
|
enumerable: true,
|
|
2906
2801
|
get: function () { return typedAction.parseTypedAction; }
|
|
@@ -2909,6 +2804,7 @@ Object.defineProperty(exports, "validateTypedAction", {
|
|
|
2909
2804
|
enumerable: true,
|
|
2910
2805
|
get: function () { return typedAction.validateTypedAction; }
|
|
2911
2806
|
});
|
|
2807
|
+
exports.DEFAULT_RELAY_WAIT_MS = DEFAULT_RELAY_WAIT_MS;
|
|
2912
2808
|
exports.ProofportSDK = ProofportSDK;
|
|
2913
2809
|
exports.RELAY_TERMINAL_STATUSES = RELAY_TERMINAL_STATUSES;
|
|
2914
2810
|
exports.default = ProofportSDK;
|