@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.esm.js
CHANGED
|
@@ -51,20 +51,26 @@ const DEEP_LINK_HOSTS = {
|
|
|
51
51
|
* ```typescript
|
|
52
52
|
* const metadata = CIRCUIT_METADATA['coinbase_attestation'];
|
|
53
53
|
* console.log(metadata.name); // "Coinbase KYC"
|
|
54
|
-
* console.log(metadata.publicInputsCount); //
|
|
54
|
+
* console.log(metadata.publicInputsCount); // 128
|
|
55
55
|
* ```
|
|
56
56
|
*/
|
|
57
57
|
const CIRCUIT_METADATA = {
|
|
58
58
|
coinbase_attestation: {
|
|
59
59
|
name: 'Coinbase KYC',
|
|
60
60
|
description: 'Prove Coinbase identity verification',
|
|
61
|
-
|
|
61
|
+
// 4 x `pub [u8; 32]` in coinbase-attestation/src/main.nr, flattened to
|
|
62
|
+
// bytes: signal_hash, signer_list_merkle_root, scope, nullifier.
|
|
63
|
+
// Read 2 here until 2026-09-04, which was wrong under any reading —
|
|
64
|
+
// the circuit has never had two public inputs, logical or flattened.
|
|
65
|
+
publicInputsCount: 128,
|
|
62
66
|
publicInputNames: ['signal_hash', 'signer_list_merkle_root'],
|
|
63
67
|
},
|
|
64
68
|
coinbase_country_attestation: {
|
|
65
69
|
name: 'Coinbase Country',
|
|
66
70
|
description: 'Prove Coinbase country verification',
|
|
67
|
-
|
|
71
|
+
// 32 + 32 + (10 x 2) + 1 + 1 + 32 + 32 = 150, counted off
|
|
72
|
+
// coinbase-country-attestation/src/main.nr. Read 14 until 2026-09-04.
|
|
73
|
+
publicInputsCount: 150,
|
|
68
74
|
publicInputNames: ['signal_hash', 'signer_list_merkle_root', 'country_list', 'country_list_length', 'is_included'],
|
|
69
75
|
},
|
|
70
76
|
oidc_domain_attestation: {
|
|
@@ -73,8 +79,22 @@ const CIRCUIT_METADATA = {
|
|
|
73
79
|
publicInputsCount: 148,
|
|
74
80
|
publicInputNames: ['pubkey_modulus_limbs', 'domain', 'scope', 'nullifier', 'provider'],
|
|
75
81
|
},
|
|
76
|
-
//
|
|
77
|
-
//
|
|
82
|
+
// Planned circuit — the identifier is reserved and the circuit exists, but it
|
|
83
|
+
// is not officially supported yet. See CIRCUIT_SUPPORT_STATUS in ./circuits.
|
|
84
|
+
// Forked from coinbase_attestation and shares its four public inputs, so the
|
|
85
|
+
// count is the byte-flattened total (4 x [u8; 32] = 128), matching the
|
|
86
|
+
// COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT indices below. The
|
|
87
|
+
// coinbase_attestation entry above reports a legacy logical count of 2 and is
|
|
88
|
+
// left as-is for backwards compatibility.
|
|
89
|
+
giwa_attestation: {
|
|
90
|
+
name: 'GIWA Attestation',
|
|
91
|
+
description: 'Prove GIWA identity verification (planned — not officially supported yet)',
|
|
92
|
+
publicInputsCount: 128,
|
|
93
|
+
publicInputNames: ['signal_hash', 'signer_list_merkle_root', 'scope', 'nullifier'],
|
|
94
|
+
},
|
|
95
|
+
// Korea Mobile ID (mDL) circuits. Planned — not officially supported yet.
|
|
96
|
+
// Counts are byte-flattened field totals from the compiled circuit ABIs:
|
|
97
|
+
// [u8; 32] arrays contribute 32 inputs each.
|
|
78
98
|
mdl_kr_ownership: {
|
|
79
99
|
name: 'Korea Mobile ID — Ownership',
|
|
80
100
|
description: "Prove valid Korean mobile driver's license ownership with selective disclosure",
|
|
@@ -613,8 +633,16 @@ function validateMdlInputs(circuit, inputs) {
|
|
|
613
633
|
const MAX_RETURN_SCHEME_LENGTH = 128;
|
|
614
634
|
/** RFC 3986 scheme (`ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )`) followed by exactly `://`. */
|
|
615
635
|
const BARE_SCHEME_RE = /^[a-z][a-z0-9+.-]*:\/\/$/;
|
|
616
|
-
/**
|
|
617
|
-
|
|
636
|
+
/**
|
|
637
|
+
* Schemes we refuse even in the bare `scheme://` shape.
|
|
638
|
+
*
|
|
639
|
+
* `http` and `https` are the back door the shape rule alone leaves open: with
|
|
640
|
+
* no host, `https://` is shaped exactly like a bare custom scheme and would
|
|
641
|
+
* otherwise pass. A browser pointed at nowhere is not a return target, and
|
|
642
|
+
* accepting it would re-open the URL-shaped door this field just closed.
|
|
643
|
+
* `googlechrome://` and `firefox://` are deliberately NOT denied — bare, they
|
|
644
|
+
* foreground that browser without navigating, which is the whole point.
|
|
645
|
+
*/
|
|
618
646
|
const DENIED_RETURN_SCHEMES = new Set([
|
|
619
647
|
'about',
|
|
620
648
|
'blob',
|
|
@@ -625,6 +653,7 @@ const DENIED_RETURN_SCHEMES = new Set([
|
|
|
625
653
|
'file',
|
|
626
654
|
'ftp',
|
|
627
655
|
'http',
|
|
656
|
+
'https',
|
|
628
657
|
'intent',
|
|
629
658
|
'javascript',
|
|
630
659
|
'jar',
|
|
@@ -638,6 +667,11 @@ const DENIED_RETURN_SCHEMES = new Set([
|
|
|
638
667
|
* value fails fast in the integrator's own code instead of coming back as a
|
|
639
668
|
* relay 400. The relay re-validates and is the authority.
|
|
640
669
|
*
|
|
670
|
+
* One shape is accepted: a bare custom scheme such as `mydapp://`. It names an
|
|
671
|
+
* app to switch back to, never a page to visit — so hosts, paths and query
|
|
672
|
+
* strings are rejected, and an https URL is not a valid value. A web page has
|
|
673
|
+
* no app to return to and simply omits the field.
|
|
674
|
+
*
|
|
641
675
|
* @param value - Candidate return target
|
|
642
676
|
* @returns `null` when acceptable, otherwise a human-readable error message
|
|
643
677
|
*
|
|
@@ -658,11 +692,8 @@ function validateReturnScheme(value) {
|
|
|
658
692
|
return 'returnScheme must not contain whitespace';
|
|
659
693
|
}
|
|
660
694
|
const normalized = value.toLowerCase();
|
|
661
|
-
if (HTTPS_ORIGIN_RE.test(normalized)) {
|
|
662
|
-
return null;
|
|
663
|
-
}
|
|
664
695
|
if (!BARE_SCHEME_RE.test(normalized)) {
|
|
665
|
-
return 'returnScheme must be a bare custom scheme such as "mydapp://"
|
|
696
|
+
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';
|
|
666
697
|
}
|
|
667
698
|
const schemeName = normalized.slice(0, normalized.indexOf(':'));
|
|
668
699
|
if (DENIED_RETURN_SCHEMES.has(schemeName)) {
|
|
@@ -670,6 +701,90 @@ function validateReturnScheme(value) {
|
|
|
670
701
|
}
|
|
671
702
|
return null;
|
|
672
703
|
}
|
|
704
|
+
/**
|
|
705
|
+
* The return target to use when the integrator named none.
|
|
706
|
+
*
|
|
707
|
+
* Only the requesting PAGE can answer "which browser is this?" — iOS gives the
|
|
708
|
+
* ZKProofport app nothing to work with (`sourceApplication` is nil across team
|
|
709
|
+
* identifiers, and there is no public API to foreground an app by bundle id).
|
|
710
|
+
* So the detection has to happen here, in the SDK, and travel with the request.
|
|
711
|
+
*
|
|
712
|
+
* Two cases are detected, each from a POSITIVE token, and each verified in the
|
|
713
|
+
* browser's own source to foreground WITHOUT navigating anywhere:
|
|
714
|
+
*
|
|
715
|
+
* Chrome for iOS (`CriOS/`) -> `googlechrome://`
|
|
716
|
+
* Firefox for iOS (`FxiOS/`) -> `firefox://`
|
|
717
|
+
*
|
|
718
|
+
* The BARE scheme is the point in both cases: it carries no URL, so the browser
|
|
719
|
+
* comes forward with nothing to open and the user lands on the tab they were
|
|
720
|
+
* already reading — no new tab, no navigation, no reload, JS state intact.
|
|
721
|
+
*
|
|
722
|
+
* Chrome: `ios/chrome/app/startup/chrome_app_startup_parameters.mm` replaces
|
|
723
|
+
* the scheme with `http`, producing `http://`, which fails GURL validation
|
|
724
|
+
* (`if (!externalURL.is_valid()) return nil;`), so the startup parameters are
|
|
725
|
+
* nil and there is nothing to open.
|
|
726
|
+
*
|
|
727
|
+
* Firefox: `firefox://` has an empty host, and
|
|
728
|
+
* `Coordinators/Router/RouteBuilder.swift` resolves the host through
|
|
729
|
+
* `DeeplinkInput.Host(rawValue: "")`, which is nil because no case has an empty
|
|
730
|
+
* raw value (`Coordinators/Router/DeeplinkInput.swift`). The scheme is not http
|
|
731
|
+
* either, so `makeRoute(url:)` falls to its final `else { return nil }`, and
|
|
732
|
+
* `SceneDelegate.handleOpenURL` then hits `guard let route = ... else
|
|
733
|
+
* { return }` and does nothing at all. Verified on the warm path — the browser
|
|
734
|
+
* is already running, which is always true here, because the user came from a
|
|
735
|
+
* page in it.
|
|
736
|
+
*
|
|
737
|
+
* Everything else deliberately returns undefined, and that is not a gap:
|
|
738
|
+
*
|
|
739
|
+
* - Safari has no equivalent. No scheme means "just come forward";
|
|
740
|
+
* `https://<url>` navigates and opens a new tab, `x-web-search://` opens a
|
|
741
|
+
* search page. Both lose the user's page.
|
|
742
|
+
* - Brave and Arc for iOS are UNDETECTABLE. Brave ships no UA token and
|
|
743
|
+
* identifies itself only via Client Hints, which WebKit does not implement,
|
|
744
|
+
* so it looks exactly like Safari. Inferring "Safari" by elimination and
|
|
745
|
+
* firing a Safari-ish scheme would throw Brave and Arc users into a browser
|
|
746
|
+
* they were not using — strictly worse than doing nothing.
|
|
747
|
+
* - In-app webviews (KakaoTalk, Naver, Line, Instagram) are not tabs at all.
|
|
748
|
+
* Any scheme destroys the page; the system "< Back to X" breadcrumb is the
|
|
749
|
+
* only thing that preserves it.
|
|
750
|
+
* - Edge (`EdgiOS`) and Opera (`OPiOS` / `OPT`) for iOS are NOT included.
|
|
751
|
+
* Both are closed source, so `microsoft-edge://` and `opera-http://` cannot
|
|
752
|
+
* be checked the way Chrome's and Firefox's were. Their bare schemes are
|
|
753
|
+
* plausible analogues, and that is exactly why they stay out: an unverified
|
|
754
|
+
* guess that opens a new tab is the bug this field exists to avoid. Add one
|
|
755
|
+
* only with evidence that it foregrounds WITHOUT navigating.
|
|
756
|
+
* - Android needs nothing: the ZKProofport app brings itself to the back
|
|
757
|
+
* (`moveTaskToBack`), which resumes the browser exactly as it was.
|
|
758
|
+
*
|
|
759
|
+
* When this returns undefined the field is omitted and the ZKProofport app
|
|
760
|
+
* tells the user the proof was delivered and to switch back themselves.
|
|
761
|
+
*
|
|
762
|
+
* @param userAgent - override, for tests. Defaults to `navigator.userAgent`.
|
|
763
|
+
* Returns undefined when there is no navigator at all (Node, SSR).
|
|
764
|
+
* @returns a scheme that is safe to open, or undefined to send nothing
|
|
765
|
+
*
|
|
766
|
+
* @internal
|
|
767
|
+
*/
|
|
768
|
+
function detectReturnScheme(userAgent) {
|
|
769
|
+
const ua = (typeof navigator === 'undefined' ? undefined : navigator.userAgent);
|
|
770
|
+
if (typeof ua !== 'string' || ua.length === 0) {
|
|
771
|
+
return undefined;
|
|
772
|
+
}
|
|
773
|
+
// A device token is required alongside the browser token. `CriOS` and `FxiOS`
|
|
774
|
+
// are already iOS-only and unambiguous on their own, but pairing them with the
|
|
775
|
+
// device token costs nothing and stops a synthetic or spoofed desktop user
|
|
776
|
+
// agent from producing a mobile-only scheme.
|
|
777
|
+
if (!/(iPhone|iPad|iPod)/.test(ua)) {
|
|
778
|
+
return undefined;
|
|
779
|
+
}
|
|
780
|
+
if (/CriOS\//.test(ua)) {
|
|
781
|
+
return 'googlechrome://';
|
|
782
|
+
}
|
|
783
|
+
if (/FxiOS\//.test(ua)) {
|
|
784
|
+
return 'firefox://';
|
|
785
|
+
}
|
|
786
|
+
return undefined;
|
|
787
|
+
}
|
|
673
788
|
function validateProofRequest(request) {
|
|
674
789
|
if (!request.requestId) {
|
|
675
790
|
return { valid: false, error: 'Missing requestId' };
|
|
@@ -5091,8 +5206,13 @@ class ProofportSDK {
|
|
|
5091
5206
|
body.dappIcon = options.dappIcon;
|
|
5092
5207
|
if (options.nonce)
|
|
5093
5208
|
body.nonce = options.nonce;
|
|
5094
|
-
|
|
5095
|
-
|
|
5209
|
+
// An explicit value always wins. Otherwise ask the SDK to work one out from
|
|
5210
|
+
// the page's own user agent — the requesting page is the only side that can
|
|
5211
|
+
// (iOS tells the app nothing about who launched it). Both paths can end in
|
|
5212
|
+
// "send nothing", which is a legitimate outcome, not a failure.
|
|
5213
|
+
const returnScheme = options.returnScheme ?? detectReturnScheme();
|
|
5214
|
+
if (returnScheme)
|
|
5215
|
+
body.returnScheme = returnScheme;
|
|
5096
5216
|
const response = await fetch(`${this.relayUrl}/api/v1/proof/request`, {
|
|
5097
5217
|
method: 'POST',
|
|
5098
5218
|
headers: {
|
|
@@ -5396,8 +5516,10 @@ class ProofportSDK {
|
|
|
5396
5516
|
* @param options - Request options (message, dappName, dappIcon, nonce, returnScheme)
|
|
5397
5517
|
* @param options.returnScheme - Which app the ZKProofport app should switch back
|
|
5398
5518
|
* to once it has finished. Put **your own** deep link scheme here — the bare
|
|
5399
|
-
* scheme your app registers, e.g. `'mydapp://'`.
|
|
5400
|
-
*
|
|
5519
|
+
* scheme your app registers, e.g. `'mydapp://'`. Only a native app has an
|
|
5520
|
+
* answer to this question; a web app omits the option entirely, because
|
|
5521
|
+
* opening its https origin would launch a new browser tab on a fresh page
|
|
5522
|
+
* rather than return the user to the tab they started from.
|
|
5401
5523
|
*
|
|
5402
5524
|
* This is intentionally **not** a URL and not a return address: no path, query
|
|
5403
5525
|
* string or fragment is accepted, and the ZKProofport app never sends the proof
|
|
@@ -5406,14 +5528,26 @@ class ProofportSDK {
|
|
|
5406
5528
|
* "which app should come back to the foreground", exactly like the
|
|
5407
5529
|
* `redirect.native` value a wallet uses to hand control back after signing.
|
|
5408
5530
|
*
|
|
5409
|
-
* **Omit it and
|
|
5410
|
-
*
|
|
5411
|
-
*
|
|
5531
|
+
* **Omit it and the SDK decides for you.** When the request is created from a
|
|
5532
|
+
* page running in Chrome for iOS (`CriOS`) or Firefox for iOS (`FxiOS`), the
|
|
5533
|
+
* SDK fills in `'googlechrome://'` or `'firefox://'` by itself: opening either
|
|
5534
|
+
* scheme bare brings that browser forward without navigating, so the user lands
|
|
5535
|
+
* back on the tab they were already reading. Every other browser sends nothing,
|
|
5536
|
+
* because nothing safe exists to send — Safari has no such scheme, and Brave
|
|
5537
|
+
* and Arc are indistinguishable from Safari on iOS, so guessing would eject the
|
|
5538
|
+
* user into the wrong browser.
|
|
5539
|
+
* On Android nothing is needed at all: the ZKProofport app brings itself to the
|
|
5540
|
+
* back and the browser resumes exactly as it was. When no target is sent and
|
|
5541
|
+
* none can be inferred, the ZKProofport app tells the user the proof was
|
|
5542
|
+
* delivered and lets them switch back themselves.
|
|
5543
|
+
*
|
|
5544
|
+
* There is no auto-switch on proof failure; only on success and on the user
|
|
5545
|
+
* declining the request.
|
|
5412
5546
|
*
|
|
5413
5547
|
* Rejected with an error before the request is sent: empty or whitespace values,
|
|
5414
|
-
* anything longer than 128 characters, values
|
|
5415
|
-
*
|
|
5416
|
-
* `mailto:` families.
|
|
5548
|
+
* anything longer than 128 characters, values carrying a host/path/query/fragment
|
|
5549
|
+
* (including https origins such as `'https://myapp.com'`), and the `http:`,
|
|
5550
|
+
* `file:`, `data:`, `javascript:`, `intent:`, `tel:`, `sms:`, `mailto:` families.
|
|
5417
5551
|
* @returns Promise resolving to RelayProofRequest with requestId, deepLink, pollUrl
|
|
5418
5552
|
* @throws Error if signer not set, returnScheme is malformed, or the relay request fails
|
|
5419
5553
|
*
|
|
@@ -5439,5 +5573,151 @@ ProofportSDK.WALLET_SIGNATURE_CIRCUITS = [
|
|
|
5439
5573
|
'coinbase_country_attestation',
|
|
5440
5574
|
];
|
|
5441
5575
|
|
|
5442
|
-
|
|
5576
|
+
/**
|
|
5577
|
+
* Canonical ZKProofport circuit identifiers.
|
|
5578
|
+
*
|
|
5579
|
+
* This module is the single source of truth for circuit IDs. Every other layer
|
|
5580
|
+
* — the mobile app, the demo, the relay, server-side provers — reads its list
|
|
5581
|
+
* from here instead of keeping a private copy that silently drifts.
|
|
5582
|
+
*
|
|
5583
|
+
* It has **no imports and no dependencies**, so it can be pulled in on its own:
|
|
5584
|
+
*
|
|
5585
|
+
* ```typescript
|
|
5586
|
+
* import { CIRCUIT_IDS, isCircuitId } from '@zkproofport-app/sdk/circuits';
|
|
5587
|
+
* ```
|
|
5588
|
+
*
|
|
5589
|
+
* The same names are also re-exported from the package root
|
|
5590
|
+
* (`@zkproofport-app/sdk`) for callers that already import the SDK.
|
|
5591
|
+
*
|
|
5592
|
+
* ## Identifiers are canonical and case-sensitive
|
|
5593
|
+
*
|
|
5594
|
+
* Each ID is the circuit's `name` in its `Nargo.toml`, verbatim. The format is
|
|
5595
|
+
* lowercase with underscores. Hyphenated spellings (`coinbase-kyc`,
|
|
5596
|
+
* `mdl-kr-age`) are directory or UI route names in other repositories — they
|
|
5597
|
+
* are **not** circuit IDs, and passing one produces a nullifier mismatch or a
|
|
5598
|
+
* failed on-chain lookup rather than a clear error.
|
|
5599
|
+
*/
|
|
5600
|
+
/**
|
|
5601
|
+
* Canonical circuit identifiers, keyed by a stable constant name.
|
|
5602
|
+
*
|
|
5603
|
+
* Prefer these constants over string literals so a rename is a compile error
|
|
5604
|
+
* rather than a runtime surprise.
|
|
5605
|
+
*
|
|
5606
|
+
* @example
|
|
5607
|
+
* ```typescript
|
|
5608
|
+
* import { CIRCUIT_IDS } from '@zkproofport-app/sdk/circuits';
|
|
5609
|
+
*
|
|
5610
|
+
* const relay = await sdk.createRelayRequest(CIRCUIT_IDS.COINBASE_ATTESTATION, {
|
|
5611
|
+
* scope: 'myapp.com',
|
|
5612
|
+
* });
|
|
5613
|
+
* ```
|
|
5614
|
+
*/
|
|
5615
|
+
const CIRCUIT_IDS = Object.freeze({
|
|
5616
|
+
/** Coinbase KYC attestation. Officially supported. */
|
|
5617
|
+
COINBASE_ATTESTATION: 'coinbase_attestation',
|
|
5618
|
+
/** Coinbase country attestation (inclusion / exclusion). Officially supported. */
|
|
5619
|
+
COINBASE_COUNTRY_ATTESTATION: 'coinbase_country_attestation',
|
|
5620
|
+
/** OIDC email-domain attestation. Officially supported. */
|
|
5621
|
+
OIDC_DOMAIN_ATTESTATION: 'oidc_domain_attestation',
|
|
5622
|
+
/** GIWA attestation. Planned — not officially supported yet. */
|
|
5623
|
+
GIWA_ATTESTATION: 'giwa_attestation',
|
|
5624
|
+
/** Korea Mobile ID ownership. Planned — not officially supported yet. */
|
|
5625
|
+
MDL_KR_OWNERSHIP: 'mdl_kr_ownership',
|
|
5626
|
+
/** Korea Mobile ID age threshold. Planned — not officially supported yet. */
|
|
5627
|
+
MDL_KR_AGE: 'mdl_kr_age',
|
|
5628
|
+
/** Korea Mobile ID si/do region. Planned — not officially supported yet. */
|
|
5629
|
+
MDL_KR_REGION: 'mdl_kr_region',
|
|
5630
|
+
});
|
|
5631
|
+
/**
|
|
5632
|
+
* Support status for every circuit.
|
|
5633
|
+
*
|
|
5634
|
+
* The record is exhaustive over {@link CircuitId}: adding an identifier without
|
|
5635
|
+
* giving it a status is a compile error, so this list cannot drift from
|
|
5636
|
+
* {@link CIRCUIT_IDS}.
|
|
5637
|
+
*
|
|
5638
|
+
* @example
|
|
5639
|
+
* ```typescript
|
|
5640
|
+
* import { CIRCUIT_SUPPORT_STATUS } from '@zkproofport-app/sdk/circuits';
|
|
5641
|
+
*
|
|
5642
|
+
* CIRCUIT_SUPPORT_STATUS.coinbase_attestation; // 'supported'
|
|
5643
|
+
* CIRCUIT_SUPPORT_STATUS.mdl_kr_age; // 'planned'
|
|
5644
|
+
* ```
|
|
5645
|
+
*/
|
|
5646
|
+
const CIRCUIT_SUPPORT_STATUS = Object.freeze({
|
|
5647
|
+
coinbase_attestation: 'supported',
|
|
5648
|
+
coinbase_country_attestation: 'supported',
|
|
5649
|
+
oidc_domain_attestation: 'supported',
|
|
5650
|
+
giwa_attestation: 'planned',
|
|
5651
|
+
mdl_kr_ownership: 'planned',
|
|
5652
|
+
mdl_kr_age: 'planned',
|
|
5653
|
+
mdl_kr_region: 'planned',
|
|
5654
|
+
});
|
|
5655
|
+
/**
|
|
5656
|
+
* Every canonical circuit identifier, in declaration order.
|
|
5657
|
+
*
|
|
5658
|
+
* Includes circuits that are still `planned`. Use {@link SUPPORTED_CIRCUIT_IDS}
|
|
5659
|
+
* when you only want the ones that are officially supported today.
|
|
5660
|
+
*/
|
|
5661
|
+
const ALL_CIRCUIT_IDS = Object.freeze(Object.values(CIRCUIT_IDS));
|
|
5662
|
+
/**
|
|
5663
|
+
* Circuits that are officially supported today: the two Coinbase circuits and
|
|
5664
|
+
* OIDC domain attestation.
|
|
5665
|
+
*
|
|
5666
|
+
* Derived from {@link CIRCUIT_SUPPORT_STATUS}, so it cannot fall out of sync.
|
|
5667
|
+
*/
|
|
5668
|
+
const SUPPORTED_CIRCUIT_IDS = Object.freeze(ALL_CIRCUIT_IDS.filter((id) => CIRCUIT_SUPPORT_STATUS[id] === 'supported'));
|
|
5669
|
+
/**
|
|
5670
|
+
* Circuits whose identifiers are reserved but which are not officially
|
|
5671
|
+
* supported yet: GIWA attestation and the three Korea Mobile ID circuits.
|
|
5672
|
+
*
|
|
5673
|
+
* Derived from {@link CIRCUIT_SUPPORT_STATUS}, so it cannot fall out of sync.
|
|
5674
|
+
*/
|
|
5675
|
+
const PLANNED_CIRCUIT_IDS = Object.freeze(ALL_CIRCUIT_IDS.filter((id) => CIRCUIT_SUPPORT_STATUS[id] === 'planned'));
|
|
5676
|
+
/**
|
|
5677
|
+
* Narrows an unknown value to a canonical circuit identifier.
|
|
5678
|
+
*
|
|
5679
|
+
* Returns `false` for hyphenated route names such as `'coinbase-kyc'`, which
|
|
5680
|
+
* are not circuit IDs.
|
|
5681
|
+
*
|
|
5682
|
+
* @example
|
|
5683
|
+
* ```typescript
|
|
5684
|
+
* isCircuitId('coinbase_attestation'); // true
|
|
5685
|
+
* isCircuitId('coinbase-kyc'); // false
|
|
5686
|
+
* ```
|
|
5687
|
+
*/
|
|
5688
|
+
function isCircuitId(value) {
|
|
5689
|
+
return typeof value === 'string' && ALL_CIRCUIT_IDS.includes(value);
|
|
5690
|
+
}
|
|
5691
|
+
/**
|
|
5692
|
+
* Narrows an unknown value to a circuit identifier that is officially supported
|
|
5693
|
+
* today. Planned circuits return `false`.
|
|
5694
|
+
*
|
|
5695
|
+
* @example
|
|
5696
|
+
* ```typescript
|
|
5697
|
+
* isSupportedCircuitId('oidc_domain_attestation'); // true
|
|
5698
|
+
* isSupportedCircuitId('mdl_kr_age'); // false — planned
|
|
5699
|
+
* ```
|
|
5700
|
+
*/
|
|
5701
|
+
function isSupportedCircuitId(value) {
|
|
5702
|
+
return isCircuitId(value) && CIRCUIT_SUPPORT_STATUS[value] === 'supported';
|
|
5703
|
+
}
|
|
5704
|
+
/**
|
|
5705
|
+
* Returns the support status of a circuit.
|
|
5706
|
+
*
|
|
5707
|
+
* @param circuit - A canonical circuit identifier.
|
|
5708
|
+
* @throws Error when the value is not a canonical circuit identifier.
|
|
5709
|
+
*
|
|
5710
|
+
* @example
|
|
5711
|
+
* ```typescript
|
|
5712
|
+
* getCircuitSupportStatus('giwa_attestation'); // 'planned'
|
|
5713
|
+
* ```
|
|
5714
|
+
*/
|
|
5715
|
+
function getCircuitSupportStatus(circuit) {
|
|
5716
|
+
if (!isCircuitId(circuit)) {
|
|
5717
|
+
throw new Error(`Unknown circuit '${String(circuit)}'. Expected one of: ${ALL_CIRCUIT_IDS.join(', ')}`);
|
|
5718
|
+
}
|
|
5719
|
+
return CIRCUIT_SUPPORT_STATUS[circuit];
|
|
5720
|
+
}
|
|
5721
|
+
|
|
5722
|
+
export { ALL_CIRCUIT_IDS, CIRCUIT_IDS, CIRCUIT_SUPPORT_STATUS, COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT, COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT, MDL_KR_PUBLIC_INPUT_LAYOUT, OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT, PLANNED_CIRCUIT_IDS, ProofportSDK, SUPPORTED_CIRCUIT_IDS, ProofportSDK as default, extractDomainFromPublicInputs, extractNullifierFromPublicInputs, extractScopeFromPublicInputs, getCircuitSupportStatus, isCircuitId, isSupportedCircuitId };
|
|
5443
5723
|
//# sourceMappingURL=index.esm.js.map
|