@zkproofport-app/sdk 0.4.0 → 0.4.2
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 +65 -30
- package/dist/ProofportSDK.d.ts +4 -2
- package/dist/circuits.d.ts +4 -0
- package/dist/circuits.esm.js +11 -0
- package/dist/circuits.esm.js.map +1 -1
- package/dist/circuits.js +11 -0
- package/dist/circuits.js.map +1 -1
- package/dist/circuits.mjs +11 -0
- package/dist/circuits.mjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.esm.js +46 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +47 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -4
- package/dist/index.mjs.map +1 -1
- package/dist/relayStatus.d.ts +9 -0
- package/dist/types.d.ts +22 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -103,6 +103,18 @@ const CIRCUIT_METADATA = {
|
|
|
103
103
|
publicInputsCount: 192,
|
|
104
104
|
publicInputNames: ['signal_hash', 'domain_separator', 'action_hash', 'signer_list_merkle_root', 'scope', 'nullifier'],
|
|
105
105
|
},
|
|
106
|
+
// Experimental, GIWA Sepolia only. The wallet signs the request (an EIP-712
|
|
107
|
+
// action, or signal_hash when none is given -- the same branch as GIWA), and
|
|
108
|
+
// the same key must have signed a payAndIssueEAS() call to the Playground
|
|
109
|
+
// faucet. No issuer list, so no merkle root: 5 x [u8; 32] = 160, read off the
|
|
110
|
+
// compiled ABI -- signal_hash 0-31, domain_separator 32-63, action_hash
|
|
111
|
+
// 64-95, scope 96-127, nullifier 128-159.
|
|
112
|
+
dojang_playground: {
|
|
113
|
+
name: 'Dojang Playground',
|
|
114
|
+
description: 'Prove this wallet issued itself a Dojang through the GIWA Playground, optionally authorizing one EIP-712 action',
|
|
115
|
+
publicInputsCount: 160,
|
|
116
|
+
publicInputNames: ['signal_hash', 'domain_separator', 'action_hash', 'scope', 'nullifier'],
|
|
117
|
+
},
|
|
106
118
|
// Korea Mobile ID (mDL) circuits. Planned — not officially supported yet.
|
|
107
119
|
// Counts are byte-flattened field totals from the compiled circuit ABIs:
|
|
108
120
|
// [u8; 32] arrays contribute 32 inputs each.
|
|
@@ -377,6 +389,8 @@ const CIRCUIT_IDS = Object.freeze({
|
|
|
377
389
|
OIDC_DOMAIN_ATTESTATION: 'oidc_domain_attestation',
|
|
378
390
|
/** GIWA attestation. Planned — not officially supported yet. */
|
|
379
391
|
GIWA_ATTESTATION: 'giwa_attestation',
|
|
392
|
+
/** Dojang Playground on GIWA Sepolia. Experimental — testnet only. */
|
|
393
|
+
DOJANG_PLAYGROUND: 'dojang_playground',
|
|
380
394
|
/** Korea Mobile ID ownership. Planned — not officially supported yet. */
|
|
381
395
|
MDL_KR_OWNERSHIP: 'mdl_kr_ownership',
|
|
382
396
|
/** Korea Mobile ID age threshold. Planned — not officially supported yet. */
|
|
@@ -408,6 +422,9 @@ const CIRCUIT_SUPPORT_STATUS = Object.freeze({
|
|
|
408
422
|
// 'supported' is that it is testnet-only, so the app offers it behind
|
|
409
423
|
// Developer Mode and reads its files from main rather than a release tag.
|
|
410
424
|
giwa_attestation: 'experimental',
|
|
425
|
+
// Same footing as GIWA: built, verifier deployed on GIWA Sepolia, a real
|
|
426
|
+
// proof verifies there. Testnet only.
|
|
427
|
+
dojang_playground: 'experimental',
|
|
411
428
|
mdl_kr_ownership: 'planned',
|
|
412
429
|
mdl_kr_age: 'planned',
|
|
413
430
|
mdl_kr_region: 'planned',
|
|
@@ -437,6 +454,7 @@ const CIRCUIT_VK_PATHS = Object.freeze({
|
|
|
437
454
|
coinbase_country_attestation: 'coinbase-country-attestation/target/vk/vk',
|
|
438
455
|
oidc_domain_attestation: 'oidc-domain-attestation/target/vk/vk',
|
|
439
456
|
giwa_attestation: 'giwa-attestation/target/vk/vk',
|
|
457
|
+
dojang_playground: 'dojang-playground/target/vk/vk',
|
|
440
458
|
mdl_kr_ownership: 'mdl/kr-ownership/target/vk/vk',
|
|
441
459
|
mdl_kr_age: 'mdl/kr-age/target/vk/vk',
|
|
442
460
|
mdl_kr_region: 'mdl/kr-region/target/vk/vk',
|
|
@@ -525,6 +543,8 @@ const CIRCUIT_ACTION_BINDING = {
|
|
|
525
543
|
// Branches in-circuit: with an action the wallet signs the typed data,
|
|
526
544
|
// without one it personal_signs the request's signal hash.
|
|
527
545
|
giwa_attestation: 'optional',
|
|
546
|
+
// Same branch as GIWA; see dojang-playground/src/main.nr.
|
|
547
|
+
dojang_playground: 'optional',
|
|
528
548
|
mdl_kr_ownership: 'none',
|
|
529
549
|
mdl_kr_age: 'none',
|
|
530
550
|
mdl_kr_region: 'none',
|
|
@@ -565,6 +585,9 @@ const CIRCUIT_NEEDS_WALLET_SIGNATURE = {
|
|
|
565
585
|
// -- it sat under the Web2 comment above and was never revisited. A request
|
|
566
586
|
// for it would have reached the relay with no signer.
|
|
567
587
|
giwa_attestation: true,
|
|
588
|
+
// The wallet signs the request, and the same key must have signed its
|
|
589
|
+
// Playground faucet transaction.
|
|
590
|
+
dojang_playground: true,
|
|
568
591
|
};
|
|
569
592
|
|
|
570
593
|
const ADDRESS = /^0x[0-9a-fA-F]{40}$/;
|
|
@@ -1648,6 +1671,9 @@ const PUBLIC_INPUT_OFFSETS = Object.freeze({
|
|
|
1648
1671
|
// it reads: signal_hash, domain_separator, action_hash, merkle root, then
|
|
1649
1672
|
// scope and nullifier 64 bytes further along than Coinbase.
|
|
1650
1673
|
giwa_attestation: { scope: [128, 159], nullifier: [160, 191] },
|
|
1674
|
+
// signal_hash, domain_separator, action_hash, scope, nullifier: GIWA's
|
|
1675
|
+
// order without the merkle root, since there is no issuer list.
|
|
1676
|
+
dojang_playground: { scope: [96, 127], nullifier: [128, 159] },
|
|
1651
1677
|
// country_list, country_list_length and is_included sit before scope.
|
|
1652
1678
|
coinbase_country_attestation: { scope: [86, 117], nullifier: [118, 149] },
|
|
1653
1679
|
// pubkey_modulus_limbs and the bounded domain sit before scope.
|
|
@@ -2028,6 +2054,17 @@ async function verifyProofOffChain(circuit, proof, publicInputs, options = {}) {
|
|
|
2028
2054
|
}
|
|
2029
2055
|
}
|
|
2030
2056
|
|
|
2057
|
+
/**
|
|
2058
|
+
* The statuses a relay request ends in, as a runtime list. `satisfies` keeps it
|
|
2059
|
+
* in step with the `RelayTerminalStatus` type in both directions: a status
|
|
2060
|
+
* added to the type and not here, or here and not in the type, fails to compile.
|
|
2061
|
+
*/
|
|
2062
|
+
const RELAY_TERMINAL_STATUSES = ['completed', 'error', 'failed', 'cancelled', 'expired'];
|
|
2063
|
+
/** True when `status` is one a relay request ends in. */
|
|
2064
|
+
function isTerminalRelayStatus(status) {
|
|
2065
|
+
return RELAY_TERMINAL_STATUSES.includes(status);
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2031
2068
|
/**
|
|
2032
2069
|
* Proofport SDK - Main class
|
|
2033
2070
|
*/
|
|
@@ -3153,7 +3190,9 @@ class ProofportSDK {
|
|
|
3153
3190
|
return await response.json();
|
|
3154
3191
|
}
|
|
3155
3192
|
/**
|
|
3156
|
-
* Polls the relay until
|
|
3193
|
+
* Polls the relay until the request reaches a terminal status
|
|
3194
|
+
* (`completed`, `error`, `failed`, `cancelled` or `expired`), with
|
|
3195
|
+
* configurable interval and timeout. Branch on `result.status`.
|
|
3157
3196
|
*
|
|
3158
3197
|
* @param requestId - The relay-issued request ID
|
|
3159
3198
|
* @param options - Polling options
|
|
@@ -3174,7 +3213,10 @@ class ProofportSDK {
|
|
|
3174
3213
|
lastStatus = result.status;
|
|
3175
3214
|
options.onStatusChange?.(result);
|
|
3176
3215
|
}
|
|
3177
|
-
|
|
3216
|
+
// Every terminal status ends the wait, not only success: an app error,
|
|
3217
|
+
// a cancellation and a relay-side timeout are answers too, and polling
|
|
3218
|
+
// past them would only end in this method's own timeout.
|
|
3219
|
+
if (isTerminalRelayStatus(result.status)) {
|
|
3178
3220
|
return result;
|
|
3179
3221
|
}
|
|
3180
3222
|
await new Promise(resolve => setTimeout(resolve, interval));
|
|
@@ -3192,7 +3234,7 @@ class ProofportSDK {
|
|
|
3192
3234
|
* @param requestId - The relay-issued request ID to subscribe to
|
|
3193
3235
|
* @param callbacks - Event callbacks for status changes and results
|
|
3194
3236
|
* @param callbacks.onStatus - Called on status updates (pending, generating)
|
|
3195
|
-
* @param callbacks.onResult - Called
|
|
3237
|
+
* @param callbacks.onResult - Called once with the terminal result: completed, error, failed, cancelled or expired
|
|
3196
3238
|
* @param callbacks.onError - Called on errors
|
|
3197
3239
|
* @returns Unsubscribe function to clean up the connection
|
|
3198
3240
|
* @throws Error if relayUrl not set or socket.io-client not installed
|
|
@@ -3411,6 +3453,7 @@ exports.MDL_KR_PUBLIC_INPUT_LAYOUT = MDL_KR_PUBLIC_INPUT_LAYOUT;
|
|
|
3411
3453
|
exports.OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT = OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT;
|
|
3412
3454
|
exports.PLANNED_CIRCUIT_IDS = PLANNED_CIRCUIT_IDS;
|
|
3413
3455
|
exports.ProofportSDK = ProofportSDK;
|
|
3456
|
+
exports.RELAY_TERMINAL_STATUSES = RELAY_TERMINAL_STATUSES;
|
|
3414
3457
|
exports.SUPPORTED_CIRCUIT_IDS = SUPPORTED_CIRCUIT_IDS;
|
|
3415
3458
|
exports.circuitActionBinding = circuitActionBinding;
|
|
3416
3459
|
exports.default = ProofportSDK;
|
|
@@ -3420,6 +3463,7 @@ exports.extractScopeFromPublicInputs = extractScopeFromPublicInputs;
|
|
|
3420
3463
|
exports.getCircuitSupportStatus = getCircuitSupportStatus;
|
|
3421
3464
|
exports.isCircuitId = isCircuitId;
|
|
3422
3465
|
exports.isSupportedCircuitId = isSupportedCircuitId;
|
|
3466
|
+
exports.isTerminalRelayStatus = isTerminalRelayStatus;
|
|
3423
3467
|
exports.parseTypedAction = parseTypedAction;
|
|
3424
3468
|
exports.validateTypedAction = validateTypedAction;
|
|
3425
3469
|
exports.verifyProofOffChain = verifyProofOffChain;
|