@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/dist/index.mjs CHANGED
@@ -98,6 +98,18 @@ const CIRCUIT_METADATA = {
98
98
  publicInputsCount: 192,
99
99
  publicInputNames: ['signal_hash', 'domain_separator', 'action_hash', 'signer_list_merkle_root', 'scope', 'nullifier'],
100
100
  },
101
+ // Experimental, GIWA Sepolia only. The wallet signs the request (an EIP-712
102
+ // action, or signal_hash when none is given -- the same branch as GIWA), and
103
+ // the same key must have signed a payAndIssueEAS() call to the Playground
104
+ // faucet. No issuer list, so no merkle root: 5 x [u8; 32] = 160, read off the
105
+ // compiled ABI -- signal_hash 0-31, domain_separator 32-63, action_hash
106
+ // 64-95, scope 96-127, nullifier 128-159.
107
+ dojang_playground: {
108
+ name: 'Dojang Playground',
109
+ description: 'Prove this wallet issued itself a Dojang through the GIWA Playground, optionally authorizing one EIP-712 action',
110
+ publicInputsCount: 160,
111
+ publicInputNames: ['signal_hash', 'domain_separator', 'action_hash', 'scope', 'nullifier'],
112
+ },
101
113
  // Korea Mobile ID (mDL) circuits. Planned — not officially supported yet.
102
114
  // Counts are byte-flattened field totals from the compiled circuit ABIs:
103
115
  // [u8; 32] arrays contribute 32 inputs each.
@@ -372,6 +384,8 @@ const CIRCUIT_IDS = Object.freeze({
372
384
  OIDC_DOMAIN_ATTESTATION: 'oidc_domain_attestation',
373
385
  /** GIWA attestation. Planned — not officially supported yet. */
374
386
  GIWA_ATTESTATION: 'giwa_attestation',
387
+ /** Dojang Playground on GIWA Sepolia. Experimental — testnet only. */
388
+ DOJANG_PLAYGROUND: 'dojang_playground',
375
389
  /** Korea Mobile ID ownership. Planned — not officially supported yet. */
376
390
  MDL_KR_OWNERSHIP: 'mdl_kr_ownership',
377
391
  /** Korea Mobile ID age threshold. Planned — not officially supported yet. */
@@ -403,6 +417,9 @@ const CIRCUIT_SUPPORT_STATUS = Object.freeze({
403
417
  // 'supported' is that it is testnet-only, so the app offers it behind
404
418
  // Developer Mode and reads its files from main rather than a release tag.
405
419
  giwa_attestation: 'experimental',
420
+ // Same footing as GIWA: built, verifier deployed on GIWA Sepolia, a real
421
+ // proof verifies there. Testnet only.
422
+ dojang_playground: 'experimental',
406
423
  mdl_kr_ownership: 'planned',
407
424
  mdl_kr_age: 'planned',
408
425
  mdl_kr_region: 'planned',
@@ -432,6 +449,7 @@ const CIRCUIT_VK_PATHS = Object.freeze({
432
449
  coinbase_country_attestation: 'coinbase-country-attestation/target/vk/vk',
433
450
  oidc_domain_attestation: 'oidc-domain-attestation/target/vk/vk',
434
451
  giwa_attestation: 'giwa-attestation/target/vk/vk',
452
+ dojang_playground: 'dojang-playground/target/vk/vk',
435
453
  mdl_kr_ownership: 'mdl/kr-ownership/target/vk/vk',
436
454
  mdl_kr_age: 'mdl/kr-age/target/vk/vk',
437
455
  mdl_kr_region: 'mdl/kr-region/target/vk/vk',
@@ -520,6 +538,8 @@ const CIRCUIT_ACTION_BINDING = {
520
538
  // Branches in-circuit: with an action the wallet signs the typed data,
521
539
  // without one it personal_signs the request's signal hash.
522
540
  giwa_attestation: 'optional',
541
+ // Same branch as GIWA; see dojang-playground/src/main.nr.
542
+ dojang_playground: 'optional',
523
543
  mdl_kr_ownership: 'none',
524
544
  mdl_kr_age: 'none',
525
545
  mdl_kr_region: 'none',
@@ -560,6 +580,9 @@ const CIRCUIT_NEEDS_WALLET_SIGNATURE = {
560
580
  // -- it sat under the Web2 comment above and was never revisited. A request
561
581
  // for it would have reached the relay with no signer.
562
582
  giwa_attestation: true,
583
+ // The wallet signs the request, and the same key must have signed its
584
+ // Playground faucet transaction.
585
+ dojang_playground: true,
563
586
  };
564
587
 
565
588
  const ADDRESS = /^0x[0-9a-fA-F]{40}$/;
@@ -4510,6 +4533,9 @@ const PUBLIC_INPUT_OFFSETS = Object.freeze({
4510
4533
  // it reads: signal_hash, domain_separator, action_hash, merkle root, then
4511
4534
  // scope and nullifier 64 bytes further along than Coinbase.
4512
4535
  giwa_attestation: { scope: [128, 159], nullifier: [160, 191] },
4536
+ // signal_hash, domain_separator, action_hash, scope, nullifier: GIWA's
4537
+ // order without the merkle root, since there is no issuer list.
4538
+ dojang_playground: { scope: [96, 127], nullifier: [128, 159] },
4513
4539
  // country_list, country_list_length and is_included sit before scope.
4514
4540
  coinbase_country_attestation: { scope: [86, 117], nullifier: [118, 149] },
4515
4541
  // pubkey_modulus_limbs and the bounded domain sit before scope.
@@ -4890,6 +4916,17 @@ async function verifyProofOffChain(circuit, proof, publicInputs, options = {}) {
4890
4916
  }
4891
4917
  }
4892
4918
 
4919
+ /**
4920
+ * The statuses a relay request ends in, as a runtime list. `satisfies` keeps it
4921
+ * in step with the `RelayTerminalStatus` type in both directions: a status
4922
+ * added to the type and not here, or here and not in the type, fails to compile.
4923
+ */
4924
+ const RELAY_TERMINAL_STATUSES = ['completed', 'error', 'failed', 'cancelled', 'expired'];
4925
+ /** True when `status` is one a relay request ends in. */
4926
+ function isTerminalRelayStatus(status) {
4927
+ return RELAY_TERMINAL_STATUSES.includes(status);
4928
+ }
4929
+
4893
4930
  /**
4894
4931
  * Proofport SDK - Main class
4895
4932
  */
@@ -6015,7 +6052,9 @@ class ProofportSDK {
6015
6052
  return await response.json();
6016
6053
  }
6017
6054
  /**
6018
- * Polls the relay until proof is completed or failed, with configurable interval and timeout.
6055
+ * Polls the relay until the request reaches a terminal status
6056
+ * (`completed`, `error`, `failed`, `cancelled` or `expired`), with
6057
+ * configurable interval and timeout. Branch on `result.status`.
6019
6058
  *
6020
6059
  * @param requestId - The relay-issued request ID
6021
6060
  * @param options - Polling options
@@ -6036,7 +6075,10 @@ class ProofportSDK {
6036
6075
  lastStatus = result.status;
6037
6076
  options.onStatusChange?.(result);
6038
6077
  }
6039
- if (result.status === 'completed' || result.status === 'failed') {
6078
+ // Every terminal status ends the wait, not only success: an app error,
6079
+ // a cancellation and a relay-side timeout are answers too, and polling
6080
+ // past them would only end in this method's own timeout.
6081
+ if (isTerminalRelayStatus(result.status)) {
6040
6082
  return result;
6041
6083
  }
6042
6084
  await new Promise(resolve => setTimeout(resolve, interval));
@@ -6054,7 +6096,7 @@ class ProofportSDK {
6054
6096
  * @param requestId - The relay-issued request ID to subscribe to
6055
6097
  * @param callbacks - Event callbacks for status changes and results
6056
6098
  * @param callbacks.onStatus - Called on status updates (pending, generating)
6057
- * @param callbacks.onResult - Called when proof is completed or failed
6099
+ * @param callbacks.onResult - Called once with the terminal result: completed, error, failed, cancelled or expired
6058
6100
  * @param callbacks.onError - Called on errors
6059
6101
  * @returns Unsubscribe function to clean up the connection
6060
6102
  * @throws Error if relayUrl not set or socket.io-client not installed
@@ -6261,5 +6303,5 @@ class ProofportSDK {
6261
6303
  }
6262
6304
  }
6263
6305
 
6264
- export { ALL_CIRCUIT_IDS, CIRCUIT_ACTION_BINDING, CIRCUIT_IDS, CIRCUIT_SUPPORT_STATUS, CIRCUIT_VK_PATHS, COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT, COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT, EXPERIMENTAL_CIRCUIT_IDS, MDL_KR_PUBLIC_INPUT_LAYOUT, OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT, PLANNED_CIRCUIT_IDS, ProofportSDK, SUPPORTED_CIRCUIT_IDS, circuitActionBinding, ProofportSDK as default, extractDomainFromPublicInputs, extractNullifierFromPublicInputs, extractScopeFromPublicInputs, getCircuitSupportStatus, isCircuitId, isSupportedCircuitId, parseTypedAction, validateTypedAction, verifyProofOffChain };
6306
+ export { ALL_CIRCUIT_IDS, CIRCUIT_ACTION_BINDING, CIRCUIT_IDS, CIRCUIT_SUPPORT_STATUS, CIRCUIT_VK_PATHS, COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT, COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT, EXPERIMENTAL_CIRCUIT_IDS, MDL_KR_PUBLIC_INPUT_LAYOUT, OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT, PLANNED_CIRCUIT_IDS, ProofportSDK, RELAY_TERMINAL_STATUSES, SUPPORTED_CIRCUIT_IDS, circuitActionBinding, ProofportSDK as default, extractDomainFromPublicInputs, extractNullifierFromPublicInputs, extractScopeFromPublicInputs, getCircuitSupportStatus, isCircuitId, isSupportedCircuitId, isTerminalRelayStatus, parseTypedAction, validateTypedAction, verifyProofOffChain };
6265
6307
  //# sourceMappingURL=index.mjs.map