@zkproofport-app/sdk 0.2.10 → 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/README.md +131 -31
- package/dist/ProofportSDK.d.ts +22 -8
- package/dist/circuits.d.ts +144 -0
- package/dist/circuits.esm.js +148 -0
- package/dist/circuits.esm.js.map +1 -0
- package/dist/circuits.js +157 -0
- package/dist/circuits.js.map +1 -0
- package/dist/circuits.mjs +148 -0
- package/dist/circuits.mjs.map +1 -0
- package/dist/constants.d.ts +1 -1
- package/dist/deeplink.d.ts +70 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +302 -22
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +309 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +302 -22
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +16 -3
- package/package.json +8 -2
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); //
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
82
|
-
//
|
|
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",
|
|
@@ -618,8 +638,16 @@ function validateMdlInputs(circuit, inputs) {
|
|
|
618
638
|
const MAX_RETURN_SCHEME_LENGTH = 128;
|
|
619
639
|
/** RFC 3986 scheme (`ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )`) followed by exactly `://`. */
|
|
620
640
|
const BARE_SCHEME_RE = /^[a-z][a-z0-9+.-]*:\/\/$/;
|
|
621
|
-
/**
|
|
622
|
-
|
|
641
|
+
/**
|
|
642
|
+
* Schemes we refuse even in the bare `scheme://` shape.
|
|
643
|
+
*
|
|
644
|
+
* `http` and `https` are the back door the shape rule alone leaves open: with
|
|
645
|
+
* no host, `https://` is shaped exactly like a bare custom scheme and would
|
|
646
|
+
* otherwise pass. A browser pointed at nowhere is not a return target, and
|
|
647
|
+
* accepting it would re-open the URL-shaped door this field just closed.
|
|
648
|
+
* `googlechrome://` and `firefox://` are deliberately NOT denied — bare, they
|
|
649
|
+
* foreground that browser without navigating, which is the whole point.
|
|
650
|
+
*/
|
|
623
651
|
const DENIED_RETURN_SCHEMES = new Set([
|
|
624
652
|
'about',
|
|
625
653
|
'blob',
|
|
@@ -630,6 +658,7 @@ const DENIED_RETURN_SCHEMES = new Set([
|
|
|
630
658
|
'file',
|
|
631
659
|
'ftp',
|
|
632
660
|
'http',
|
|
661
|
+
'https',
|
|
633
662
|
'intent',
|
|
634
663
|
'javascript',
|
|
635
664
|
'jar',
|
|
@@ -643,6 +672,11 @@ const DENIED_RETURN_SCHEMES = new Set([
|
|
|
643
672
|
* value fails fast in the integrator's own code instead of coming back as a
|
|
644
673
|
* relay 400. The relay re-validates and is the authority.
|
|
645
674
|
*
|
|
675
|
+
* One shape is accepted: a bare custom scheme such as `mydapp://`. It names an
|
|
676
|
+
* app to switch back to, never a page to visit — so hosts, paths and query
|
|
677
|
+
* strings are rejected, and an https URL is not a valid value. A web page has
|
|
678
|
+
* no app to return to and simply omits the field.
|
|
679
|
+
*
|
|
646
680
|
* @param value - Candidate return target
|
|
647
681
|
* @returns `null` when acceptable, otherwise a human-readable error message
|
|
648
682
|
*
|
|
@@ -663,11 +697,8 @@ function validateReturnScheme(value) {
|
|
|
663
697
|
return 'returnScheme must not contain whitespace';
|
|
664
698
|
}
|
|
665
699
|
const normalized = value.toLowerCase();
|
|
666
|
-
if (HTTPS_ORIGIN_RE.test(normalized)) {
|
|
667
|
-
return null;
|
|
668
|
-
}
|
|
669
700
|
if (!BARE_SCHEME_RE.test(normalized)) {
|
|
670
|
-
return 'returnScheme must be a bare custom scheme such as "mydapp://"
|
|
701
|
+
return 'returnScheme must be a bare custom scheme such as "mydapp://" — hosts, paths, query strings and fragments are not accepted, and an https URL is not a return target';
|
|
671
702
|
}
|
|
672
703
|
const schemeName = normalized.slice(0, normalized.indexOf(':'));
|
|
673
704
|
if (DENIED_RETURN_SCHEMES.has(schemeName)) {
|
|
@@ -675,6 +706,90 @@ function validateReturnScheme(value) {
|
|
|
675
706
|
}
|
|
676
707
|
return null;
|
|
677
708
|
}
|
|
709
|
+
/**
|
|
710
|
+
* The return target to use when the integrator named none.
|
|
711
|
+
*
|
|
712
|
+
* Only the requesting PAGE can answer "which browser is this?" — iOS gives the
|
|
713
|
+
* ZKProofport app nothing to work with (`sourceApplication` is nil across team
|
|
714
|
+
* identifiers, and there is no public API to foreground an app by bundle id).
|
|
715
|
+
* So the detection has to happen here, in the SDK, and travel with the request.
|
|
716
|
+
*
|
|
717
|
+
* Two cases are detected, each from a POSITIVE token, and each verified in the
|
|
718
|
+
* browser's own source to foreground WITHOUT navigating anywhere:
|
|
719
|
+
*
|
|
720
|
+
* Chrome for iOS (`CriOS/`) -> `googlechrome://`
|
|
721
|
+
* Firefox for iOS (`FxiOS/`) -> `firefox://`
|
|
722
|
+
*
|
|
723
|
+
* The BARE scheme is the point in both cases: it carries no URL, so the browser
|
|
724
|
+
* comes forward with nothing to open and the user lands on the tab they were
|
|
725
|
+
* already reading — no new tab, no navigation, no reload, JS state intact.
|
|
726
|
+
*
|
|
727
|
+
* Chrome: `ios/chrome/app/startup/chrome_app_startup_parameters.mm` replaces
|
|
728
|
+
* the scheme with `http`, producing `http://`, which fails GURL validation
|
|
729
|
+
* (`if (!externalURL.is_valid()) return nil;`), so the startup parameters are
|
|
730
|
+
* nil and there is nothing to open.
|
|
731
|
+
*
|
|
732
|
+
* Firefox: `firefox://` has an empty host, and
|
|
733
|
+
* `Coordinators/Router/RouteBuilder.swift` resolves the host through
|
|
734
|
+
* `DeeplinkInput.Host(rawValue: "")`, which is nil because no case has an empty
|
|
735
|
+
* raw value (`Coordinators/Router/DeeplinkInput.swift`). The scheme is not http
|
|
736
|
+
* either, so `makeRoute(url:)` falls to its final `else { return nil }`, and
|
|
737
|
+
* `SceneDelegate.handleOpenURL` then hits `guard let route = ... else
|
|
738
|
+
* { return }` and does nothing at all. Verified on the warm path — the browser
|
|
739
|
+
* is already running, which is always true here, because the user came from a
|
|
740
|
+
* page in it.
|
|
741
|
+
*
|
|
742
|
+
* Everything else deliberately returns undefined, and that is not a gap:
|
|
743
|
+
*
|
|
744
|
+
* - Safari has no equivalent. No scheme means "just come forward";
|
|
745
|
+
* `https://<url>` navigates and opens a new tab, `x-web-search://` opens a
|
|
746
|
+
* search page. Both lose the user's page.
|
|
747
|
+
* - Brave and Arc for iOS are UNDETECTABLE. Brave ships no UA token and
|
|
748
|
+
* identifies itself only via Client Hints, which WebKit does not implement,
|
|
749
|
+
* so it looks exactly like Safari. Inferring "Safari" by elimination and
|
|
750
|
+
* firing a Safari-ish scheme would throw Brave and Arc users into a browser
|
|
751
|
+
* they were not using — strictly worse than doing nothing.
|
|
752
|
+
* - In-app webviews (KakaoTalk, Naver, Line, Instagram) are not tabs at all.
|
|
753
|
+
* Any scheme destroys the page; the system "< Back to X" breadcrumb is the
|
|
754
|
+
* only thing that preserves it.
|
|
755
|
+
* - Edge (`EdgiOS`) and Opera (`OPiOS` / `OPT`) for iOS are NOT included.
|
|
756
|
+
* Both are closed source, so `microsoft-edge://` and `opera-http://` cannot
|
|
757
|
+
* be checked the way Chrome's and Firefox's were. Their bare schemes are
|
|
758
|
+
* plausible analogues, and that is exactly why they stay out: an unverified
|
|
759
|
+
* guess that opens a new tab is the bug this field exists to avoid. Add one
|
|
760
|
+
* only with evidence that it foregrounds WITHOUT navigating.
|
|
761
|
+
* - Android needs nothing: the ZKProofport app brings itself to the back
|
|
762
|
+
* (`moveTaskToBack`), which resumes the browser exactly as it was.
|
|
763
|
+
*
|
|
764
|
+
* When this returns undefined the field is omitted and the ZKProofport app
|
|
765
|
+
* tells the user the proof was delivered and to switch back themselves.
|
|
766
|
+
*
|
|
767
|
+
* @param userAgent - override, for tests. Defaults to `navigator.userAgent`.
|
|
768
|
+
* Returns undefined when there is no navigator at all (Node, SSR).
|
|
769
|
+
* @returns a scheme that is safe to open, or undefined to send nothing
|
|
770
|
+
*
|
|
771
|
+
* @internal
|
|
772
|
+
*/
|
|
773
|
+
function detectReturnScheme(userAgent) {
|
|
774
|
+
const ua = (typeof navigator === 'undefined' ? undefined : navigator.userAgent);
|
|
775
|
+
if (typeof ua !== 'string' || ua.length === 0) {
|
|
776
|
+
return undefined;
|
|
777
|
+
}
|
|
778
|
+
// A device token is required alongside the browser token. `CriOS` and `FxiOS`
|
|
779
|
+
// are already iOS-only and unambiguous on their own, but pairing them with the
|
|
780
|
+
// device token costs nothing and stops a synthetic or spoofed desktop user
|
|
781
|
+
// agent from producing a mobile-only scheme.
|
|
782
|
+
if (!/(iPhone|iPad|iPod)/.test(ua)) {
|
|
783
|
+
return undefined;
|
|
784
|
+
}
|
|
785
|
+
if (/CriOS\//.test(ua)) {
|
|
786
|
+
return 'googlechrome://';
|
|
787
|
+
}
|
|
788
|
+
if (/FxiOS\//.test(ua)) {
|
|
789
|
+
return 'firefox://';
|
|
790
|
+
}
|
|
791
|
+
return undefined;
|
|
792
|
+
}
|
|
678
793
|
function validateProofRequest(request) {
|
|
679
794
|
if (!request.requestId) {
|
|
680
795
|
return { valid: false, error: 'Missing requestId' };
|
|
@@ -2229,8 +2344,13 @@ class ProofportSDK {
|
|
|
2229
2344
|
body.dappIcon = options.dappIcon;
|
|
2230
2345
|
if (options.nonce)
|
|
2231
2346
|
body.nonce = options.nonce;
|
|
2232
|
-
|
|
2233
|
-
|
|
2347
|
+
// An explicit value always wins. Otherwise ask the SDK to work one out from
|
|
2348
|
+
// the page's own user agent — the requesting page is the only side that can
|
|
2349
|
+
// (iOS tells the app nothing about who launched it). Both paths can end in
|
|
2350
|
+
// "send nothing", which is a legitimate outcome, not a failure.
|
|
2351
|
+
const returnScheme = options.returnScheme ?? detectReturnScheme();
|
|
2352
|
+
if (returnScheme)
|
|
2353
|
+
body.returnScheme = returnScheme;
|
|
2234
2354
|
const response = await fetch(`${this.relayUrl}/api/v1/proof/request`, {
|
|
2235
2355
|
method: 'POST',
|
|
2236
2356
|
headers: {
|
|
@@ -2534,8 +2654,10 @@ class ProofportSDK {
|
|
|
2534
2654
|
* @param options - Request options (message, dappName, dappIcon, nonce, returnScheme)
|
|
2535
2655
|
* @param options.returnScheme - Which app the ZKProofport app should switch back
|
|
2536
2656
|
* to once it has finished. Put **your own** deep link scheme here — the bare
|
|
2537
|
-
* scheme your app registers, e.g. `'mydapp://'`.
|
|
2538
|
-
*
|
|
2657
|
+
* scheme your app registers, e.g. `'mydapp://'`. Only a native app has an
|
|
2658
|
+
* answer to this question; a web app omits the option entirely, because
|
|
2659
|
+
* opening its https origin would launch a new browser tab on a fresh page
|
|
2660
|
+
* rather than return the user to the tab they started from.
|
|
2539
2661
|
*
|
|
2540
2662
|
* This is intentionally **not** a URL and not a return address: no path, query
|
|
2541
2663
|
* string or fragment is accepted, and the ZKProofport app never sends the proof
|
|
@@ -2544,14 +2666,26 @@ class ProofportSDK {
|
|
|
2544
2666
|
* "which app should come back to the foreground", exactly like the
|
|
2545
2667
|
* `redirect.native` value a wallet uses to hand control back after signing.
|
|
2546
2668
|
*
|
|
2547
|
-
* **Omit it and
|
|
2548
|
-
*
|
|
2549
|
-
*
|
|
2669
|
+
* **Omit it and the SDK decides for you.** When the request is created from a
|
|
2670
|
+
* page running in Chrome for iOS (`CriOS`) or Firefox for iOS (`FxiOS`), the
|
|
2671
|
+
* SDK fills in `'googlechrome://'` or `'firefox://'` by itself: opening either
|
|
2672
|
+
* scheme bare brings that browser forward without navigating, so the user lands
|
|
2673
|
+
* back on the tab they were already reading. Every other browser sends nothing,
|
|
2674
|
+
* because nothing safe exists to send — Safari has no such scheme, and Brave
|
|
2675
|
+
* and Arc are indistinguishable from Safari on iOS, so guessing would eject the
|
|
2676
|
+
* user into the wrong browser.
|
|
2677
|
+
* On Android nothing is needed at all: the ZKProofport app brings itself to the
|
|
2678
|
+
* back and the browser resumes exactly as it was. When no target is sent and
|
|
2679
|
+
* none can be inferred, the ZKProofport app tells the user the proof was
|
|
2680
|
+
* delivered and lets them switch back themselves.
|
|
2681
|
+
*
|
|
2682
|
+
* There is no auto-switch on proof failure; only on success and on the user
|
|
2683
|
+
* declining the request.
|
|
2550
2684
|
*
|
|
2551
2685
|
* Rejected with an error before the request is sent: empty or whitespace values,
|
|
2552
|
-
* anything longer than 128 characters, values
|
|
2553
|
-
*
|
|
2554
|
-
* `mailto:` families.
|
|
2686
|
+
* anything longer than 128 characters, values carrying a host/path/query/fragment
|
|
2687
|
+
* (including https origins such as `'https://myapp.com'`), and the `http:`,
|
|
2688
|
+
* `file:`, `data:`, `javascript:`, `intent:`, `tel:`, `sms:`, `mailto:` families.
|
|
2555
2689
|
* @returns Promise resolving to RelayProofRequest with requestId, deepLink, pollUrl
|
|
2556
2690
|
* @throws Error if signer not set, returnScheme is malformed, or the relay request fails
|
|
2557
2691
|
*
|
|
@@ -2577,13 +2711,167 @@ ProofportSDK.WALLET_SIGNATURE_CIRCUITS = [
|
|
|
2577
2711
|
'coinbase_country_attestation',
|
|
2578
2712
|
];
|
|
2579
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;
|
|
2580
2863
|
exports.COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT = COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT;
|
|
2581
2864
|
exports.COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT = COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT;
|
|
2582
2865
|
exports.MDL_KR_PUBLIC_INPUT_LAYOUT = MDL_KR_PUBLIC_INPUT_LAYOUT;
|
|
2583
2866
|
exports.OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT = OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT;
|
|
2867
|
+
exports.PLANNED_CIRCUIT_IDS = PLANNED_CIRCUIT_IDS;
|
|
2584
2868
|
exports.ProofportSDK = ProofportSDK;
|
|
2869
|
+
exports.SUPPORTED_CIRCUIT_IDS = SUPPORTED_CIRCUIT_IDS;
|
|
2585
2870
|
exports.default = ProofportSDK;
|
|
2586
2871
|
exports.extractDomainFromPublicInputs = extractDomainFromPublicInputs;
|
|
2587
2872
|
exports.extractNullifierFromPublicInputs = extractNullifierFromPublicInputs;
|
|
2588
2873
|
exports.extractScopeFromPublicInputs = extractScopeFromPublicInputs;
|
|
2874
|
+
exports.getCircuitSupportStatus = getCircuitSupportStatus;
|
|
2875
|
+
exports.isCircuitId = isCircuitId;
|
|
2876
|
+
exports.isSupportedCircuitId = isSupportedCircuitId;
|
|
2589
2877
|
//# sourceMappingURL=index.js.map
|