@zkproofport-app/sdk 0.2.11 → 0.2.12

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.js CHANGED
@@ -56,20 +56,26 @@ const DEEP_LINK_HOSTS = {
56
56
  * ```typescript
57
57
  * const metadata = CIRCUIT_METADATA['coinbase_attestation'];
58
58
  * console.log(metadata.name); // "Coinbase KYC"
59
- * console.log(metadata.publicInputsCount); // 2
59
+ * console.log(metadata.publicInputsCount); // 128
60
60
  * ```
61
61
  */
62
62
  const CIRCUIT_METADATA = {
63
63
  coinbase_attestation: {
64
64
  name: 'Coinbase KYC',
65
65
  description: 'Prove Coinbase identity verification',
66
- publicInputsCount: 2,
66
+ // 4 x `pub [u8; 32]` in coinbase-attestation/src/main.nr, flattened to
67
+ // bytes: signal_hash, signer_list_merkle_root, scope, nullifier.
68
+ // Read 2 here until 2026-09-04, which was wrong under any reading —
69
+ // the circuit has never had two public inputs, logical or flattened.
70
+ publicInputsCount: 128,
67
71
  publicInputNames: ['signal_hash', 'signer_list_merkle_root'],
68
72
  },
69
73
  coinbase_country_attestation: {
70
74
  name: 'Coinbase Country',
71
75
  description: 'Prove Coinbase country verification',
72
- publicInputsCount: 14,
76
+ // 32 + 32 + (10 x 2) + 1 + 1 + 32 + 32 = 150, counted off
77
+ // coinbase-country-attestation/src/main.nr. Read 14 until 2026-09-04.
78
+ publicInputsCount: 150,
73
79
  publicInputNames: ['signal_hash', 'signer_list_merkle_root', 'country_list', 'country_list_length', 'is_included'],
74
80
  },
75
81
  oidc_domain_attestation: {
@@ -78,8 +84,22 @@ const CIRCUIT_METADATA = {
78
84
  publicInputsCount: 148,
79
85
  publicInputNames: ['pubkey_modulus_limbs', 'domain', 'scope', 'nullifier', 'provider'],
80
86
  },
81
- // Korea Mobile ID (mDL) circuits. Counts are byte-flattened field totals
82
- // from the compiled circuit ABIs: [u8; 32] arrays contribute 32 inputs each.
87
+ // Planned circuit — the identifier is reserved and the circuit exists, but it
88
+ // is not officially supported yet. See CIRCUIT_SUPPORT_STATUS in ./circuits.
89
+ // Forked from coinbase_attestation and shares its four public inputs, so the
90
+ // count is the byte-flattened total (4 x [u8; 32] = 128), matching the
91
+ // COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT indices below. The
92
+ // coinbase_attestation entry above reports a legacy logical count of 2 and is
93
+ // left as-is for backwards compatibility.
94
+ giwa_attestation: {
95
+ name: 'GIWA Attestation',
96
+ description: 'Prove GIWA identity verification (planned — not officially supported yet)',
97
+ publicInputsCount: 128,
98
+ publicInputNames: ['signal_hash', 'signer_list_merkle_root', 'scope', 'nullifier'],
99
+ },
100
+ // Korea Mobile ID (mDL) circuits. Planned — not officially supported yet.
101
+ // Counts are byte-flattened field totals from the compiled circuit ABIs:
102
+ // [u8; 32] arrays contribute 32 inputs each.
83
103
  mdl_kr_ownership: {
84
104
  name: 'Korea Mobile ID — Ownership',
85
105
  description: "Prove valid Korean mobile driver's license ownership with selective disclosure",
@@ -2691,13 +2711,167 @@ ProofportSDK.WALLET_SIGNATURE_CIRCUITS = [
2691
2711
  'coinbase_country_attestation',
2692
2712
  ];
2693
2713
 
2714
+ /**
2715
+ * Canonical ZKProofport circuit identifiers.
2716
+ *
2717
+ * This module is the single source of truth for circuit IDs. Every other layer
2718
+ * — the mobile app, the demo, the relay, server-side provers — reads its list
2719
+ * from here instead of keeping a private copy that silently drifts.
2720
+ *
2721
+ * It has **no imports and no dependencies**, so it can be pulled in on its own:
2722
+ *
2723
+ * ```typescript
2724
+ * import { CIRCUIT_IDS, isCircuitId } from '@zkproofport-app/sdk/circuits';
2725
+ * ```
2726
+ *
2727
+ * The same names are also re-exported from the package root
2728
+ * (`@zkproofport-app/sdk`) for callers that already import the SDK.
2729
+ *
2730
+ * ## Identifiers are canonical and case-sensitive
2731
+ *
2732
+ * Each ID is the circuit's `name` in its `Nargo.toml`, verbatim. The format is
2733
+ * lowercase with underscores. Hyphenated spellings (`coinbase-kyc`,
2734
+ * `mdl-kr-age`) are directory or UI route names in other repositories — they
2735
+ * are **not** circuit IDs, and passing one produces a nullifier mismatch or a
2736
+ * failed on-chain lookup rather than a clear error.
2737
+ */
2738
+ /**
2739
+ * Canonical circuit identifiers, keyed by a stable constant name.
2740
+ *
2741
+ * Prefer these constants over string literals so a rename is a compile error
2742
+ * rather than a runtime surprise.
2743
+ *
2744
+ * @example
2745
+ * ```typescript
2746
+ * import { CIRCUIT_IDS } from '@zkproofport-app/sdk/circuits';
2747
+ *
2748
+ * const relay = await sdk.createRelayRequest(CIRCUIT_IDS.COINBASE_ATTESTATION, {
2749
+ * scope: 'myapp.com',
2750
+ * });
2751
+ * ```
2752
+ */
2753
+ const CIRCUIT_IDS = Object.freeze({
2754
+ /** Coinbase KYC attestation. Officially supported. */
2755
+ COINBASE_ATTESTATION: 'coinbase_attestation',
2756
+ /** Coinbase country attestation (inclusion / exclusion). Officially supported. */
2757
+ COINBASE_COUNTRY_ATTESTATION: 'coinbase_country_attestation',
2758
+ /** OIDC email-domain attestation. Officially supported. */
2759
+ OIDC_DOMAIN_ATTESTATION: 'oidc_domain_attestation',
2760
+ /** GIWA attestation. Planned — not officially supported yet. */
2761
+ GIWA_ATTESTATION: 'giwa_attestation',
2762
+ /** Korea Mobile ID ownership. Planned — not officially supported yet. */
2763
+ MDL_KR_OWNERSHIP: 'mdl_kr_ownership',
2764
+ /** Korea Mobile ID age threshold. Planned — not officially supported yet. */
2765
+ MDL_KR_AGE: 'mdl_kr_age',
2766
+ /** Korea Mobile ID si/do region. Planned — not officially supported yet. */
2767
+ MDL_KR_REGION: 'mdl_kr_region',
2768
+ });
2769
+ /**
2770
+ * Support status for every circuit.
2771
+ *
2772
+ * The record is exhaustive over {@link CircuitId}: adding an identifier without
2773
+ * giving it a status is a compile error, so this list cannot drift from
2774
+ * {@link CIRCUIT_IDS}.
2775
+ *
2776
+ * @example
2777
+ * ```typescript
2778
+ * import { CIRCUIT_SUPPORT_STATUS } from '@zkproofport-app/sdk/circuits';
2779
+ *
2780
+ * CIRCUIT_SUPPORT_STATUS.coinbase_attestation; // 'supported'
2781
+ * CIRCUIT_SUPPORT_STATUS.mdl_kr_age; // 'planned'
2782
+ * ```
2783
+ */
2784
+ const CIRCUIT_SUPPORT_STATUS = Object.freeze({
2785
+ coinbase_attestation: 'supported',
2786
+ coinbase_country_attestation: 'supported',
2787
+ oidc_domain_attestation: 'supported',
2788
+ giwa_attestation: 'planned',
2789
+ mdl_kr_ownership: 'planned',
2790
+ mdl_kr_age: 'planned',
2791
+ mdl_kr_region: 'planned',
2792
+ });
2793
+ /**
2794
+ * Every canonical circuit identifier, in declaration order.
2795
+ *
2796
+ * Includes circuits that are still `planned`. Use {@link SUPPORTED_CIRCUIT_IDS}
2797
+ * when you only want the ones that are officially supported today.
2798
+ */
2799
+ const ALL_CIRCUIT_IDS = Object.freeze(Object.values(CIRCUIT_IDS));
2800
+ /**
2801
+ * Circuits that are officially supported today: the two Coinbase circuits and
2802
+ * OIDC domain attestation.
2803
+ *
2804
+ * Derived from {@link CIRCUIT_SUPPORT_STATUS}, so it cannot fall out of sync.
2805
+ */
2806
+ const SUPPORTED_CIRCUIT_IDS = Object.freeze(ALL_CIRCUIT_IDS.filter((id) => CIRCUIT_SUPPORT_STATUS[id] === 'supported'));
2807
+ /**
2808
+ * Circuits whose identifiers are reserved but which are not officially
2809
+ * supported yet: GIWA attestation and the three Korea Mobile ID circuits.
2810
+ *
2811
+ * Derived from {@link CIRCUIT_SUPPORT_STATUS}, so it cannot fall out of sync.
2812
+ */
2813
+ const PLANNED_CIRCUIT_IDS = Object.freeze(ALL_CIRCUIT_IDS.filter((id) => CIRCUIT_SUPPORT_STATUS[id] === 'planned'));
2814
+ /**
2815
+ * Narrows an unknown value to a canonical circuit identifier.
2816
+ *
2817
+ * Returns `false` for hyphenated route names such as `'coinbase-kyc'`, which
2818
+ * are not circuit IDs.
2819
+ *
2820
+ * @example
2821
+ * ```typescript
2822
+ * isCircuitId('coinbase_attestation'); // true
2823
+ * isCircuitId('coinbase-kyc'); // false
2824
+ * ```
2825
+ */
2826
+ function isCircuitId(value) {
2827
+ return typeof value === 'string' && ALL_CIRCUIT_IDS.includes(value);
2828
+ }
2829
+ /**
2830
+ * Narrows an unknown value to a circuit identifier that is officially supported
2831
+ * today. Planned circuits return `false`.
2832
+ *
2833
+ * @example
2834
+ * ```typescript
2835
+ * isSupportedCircuitId('oidc_domain_attestation'); // true
2836
+ * isSupportedCircuitId('mdl_kr_age'); // false — planned
2837
+ * ```
2838
+ */
2839
+ function isSupportedCircuitId(value) {
2840
+ return isCircuitId(value) && CIRCUIT_SUPPORT_STATUS[value] === 'supported';
2841
+ }
2842
+ /**
2843
+ * Returns the support status of a circuit.
2844
+ *
2845
+ * @param circuit - A canonical circuit identifier.
2846
+ * @throws Error when the value is not a canonical circuit identifier.
2847
+ *
2848
+ * @example
2849
+ * ```typescript
2850
+ * getCircuitSupportStatus('giwa_attestation'); // 'planned'
2851
+ * ```
2852
+ */
2853
+ function getCircuitSupportStatus(circuit) {
2854
+ if (!isCircuitId(circuit)) {
2855
+ throw new Error(`Unknown circuit '${String(circuit)}'. Expected one of: ${ALL_CIRCUIT_IDS.join(', ')}`);
2856
+ }
2857
+ return CIRCUIT_SUPPORT_STATUS[circuit];
2858
+ }
2859
+
2860
+ exports.ALL_CIRCUIT_IDS = ALL_CIRCUIT_IDS;
2861
+ exports.CIRCUIT_IDS = CIRCUIT_IDS;
2862
+ exports.CIRCUIT_SUPPORT_STATUS = CIRCUIT_SUPPORT_STATUS;
2694
2863
  exports.COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT = COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT;
2695
2864
  exports.COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT = COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT;
2696
2865
  exports.MDL_KR_PUBLIC_INPUT_LAYOUT = MDL_KR_PUBLIC_INPUT_LAYOUT;
2697
2866
  exports.OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT = OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT;
2867
+ exports.PLANNED_CIRCUIT_IDS = PLANNED_CIRCUIT_IDS;
2698
2868
  exports.ProofportSDK = ProofportSDK;
2869
+ exports.SUPPORTED_CIRCUIT_IDS = SUPPORTED_CIRCUIT_IDS;
2699
2870
  exports.default = ProofportSDK;
2700
2871
  exports.extractDomainFromPublicInputs = extractDomainFromPublicInputs;
2701
2872
  exports.extractNullifierFromPublicInputs = extractNullifierFromPublicInputs;
2702
2873
  exports.extractScopeFromPublicInputs = extractScopeFromPublicInputs;
2874
+ exports.getCircuitSupportStatus = getCircuitSupportStatus;
2875
+ exports.isCircuitId = isCircuitId;
2876
+ exports.isSupportedCircuitId = isSupportedCircuitId;
2703
2877
  //# sourceMappingURL=index.js.map