@zkpassport/sdk 0.17.0-beta.2 → 0.17.1

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.
@@ -1,3 +1,3 @@
1
- export { D as DashboardConfig, d as OfflineQueryBuilderResult, O as OnSuccessVerdict, P as Policy, Q as QueryBuilder, a as QueryBuilderResult, e as QueryResultError, f as QueryResultErrors, R as RequestSuccess, h as RequestedNullifierType, S as SolidityProofVerificationData, i as SolidityServiceConfig, j as SolidityVerifierParameters, V as VerificationResult, k as VerifierMode, Z as ZKPassport, c as createOfflineQuery } from './index-PPMt5JWF.cjs';
1
+ export { D as DashboardConfig, d as OfflineQueryBuilderResult, O as OnSuccessVerdict, P as Policy, Q as QueryBuilder, a as QueryBuilderResult, e as QueryResultError, f as QueryResultErrors, R as RequestSuccess, h as RequestedNullifierType, S as SolidityProofVerificationData, i as SolidityServiceConfig, j as SolidityVerifierParameters, V as VERSION, k as VerificationResult, l as VerifierMode, Z as ZKPassport, c as createOfflineQuery } from './index-BBgXLFAR.cjs';
2
2
  export { ASEAN_COUNTRIES, BoundData, CountryName, DisclosableIDCredential, EEA_COUNTRIES, EU_COUNTRIES, FacematchMode, IDCredential, IDCredentialValue, JsonRpcRequest, MERCOSUR_COUNTRIES, NullifierType, NumericalIDCredential, ProofMode, ProofResult, ProofType, ProofTypeLength, Query, QueryResult, SANCTIONED_COUNTRIES, SCHENGEN_COUNTRIES, SanctionsCountries, SanctionsLists, Service, SupportedChain } from '@zkpassport/utils';
3
3
  import 'i18n-iso-countries';
@@ -1,3 +1,3 @@
1
- 'use strict';var y="https://verify.zkpassport.id";function d(e){return !!e&&e.zkpassport===true&&typeof e.type=="string"}var f=460,g=780,v=500;function h(e){if(typeof window>"u")return null;let p=e.popupUrl??y,i=new URL(p).origin,P=Math.max(0,(window.screenX??0)+(window.outerWidth-f)/2),m=Math.max(0,(window.screenY??0)+(window.outerHeight-g)/2),t=window.open(p,"zkpassport-verify",`popup,width=${f},height=${g},left=${Math.round(P)},top=${Math.round(m)}`)??window.open(p,"zkpassport-verify");if(!t)return null;let r=e.callbacks??{},n=false,s=null,a=()=>{window.removeEventListener("message",c),s&&(clearInterval(s),s=null);},c=u=>{if(u.origin!==i||u.source!==t)return;let o=u.data;if(d(o))switch(o.type){case "ready":try{t.postMessage({zkpassport:!0,type:"configure",request:e.request,query:e.query},i);}catch(l){console.error("[zkpassport] failed to send the request to the popup:",l),r.onError?.("Failed to send the request to the verification popup");try{t.close();}catch{}}break;case "request-received":r.onRequestReceived?.();break;case "generating":r.onGeneratingProof?.();break;case "proof-generated":r.onProofGenerated?.({index:o.index,total:o.total,name:o.name});break;case "success":{n=true;let{zkpassport:l,type:x,...k}=o;r.onSuccess?.(k);break}case "rejected":n=true,r.onReject?.();break;case "error":r.onError?.(o.message);break}};return window.addEventListener("message",c),s=setInterval(()=>{t.closed&&(a(),n||r.onClose?.());},v),{popup:t,close:()=>{a();try{t.close();}catch{}}}}function w(e,p){return e.raw(p).done()}
2
- exports.DEFAULT_POPUP_URL=y;exports.hydrateQueryBuilder=w;exports.isPopupMessage=d;exports.openVerificationPopup=h;//# sourceMappingURL=popup.cjs.map
1
+ 'use strict';var d="https://verify.zkpassport.id";function y(e){return !!e&&e.zkpassport===true&&typeof e.type=="string"}var f=460,g=780,m=500;function x(e){let r=Math.max(0,(window.screenX??0)+(window.outerWidth-f)/2),s=Math.max(0,(window.screenY??0)+(window.outerHeight-g)/2);return window.open(e,"zkpassport-verify",`popup,width=${f},height=${g},left=${Math.round(r)},top=${Math.round(s)}`)??window.open(e,"zkpassport-verify")}function h(e){if(typeof window>"u")return null;let r=e.popupUrl??d,s=new URL(r).origin,o=e.windowMode==="tab"?window.open(r,"zkpassport-verify"):x(r);if(!o)return null;let t=e.callbacks??{},i=false,n=null,u=()=>{window.removeEventListener("message",l),n&&(clearInterval(n),n=null);},l=a=>{if(a.origin!==s||a.source!==o)return;let p=a.data;if(y(p))switch(p.type){case "ready":try{o.postMessage({zkpassport:!0,type:"configure",request:e.request,query:e.query,...e.credential?{credential:e.credential}:{}},s);}catch(c){console.error("[zkpassport] failed to send the request to the popup:",c),t.onError?.("Failed to send the request to the verification popup");try{o.close();}catch{}}break;case "request-received":t.onRequestReceived?.();break;case "generating":t.onGeneratingProof?.();break;case "proof-generated":t.onProofGenerated?.({index:p.index,total:p.total,name:p.name});break;case "success":{i=true;let{zkpassport:c,type:w,...P}=p;t.onSuccess?.(P);break}case "rejected":i=true,t.onReject?.();break;case "error":t.onError?.(p.message);break}};return window.addEventListener("message",l),n=setInterval(()=>{o.closed&&(u(),i||t.onClose?.());},m),{popup:o,release:u,close:()=>{u();try{o.close();}catch{}}}}function k(e,r){return e.raw(r).done()}
2
+ exports.DEFAULT_POPUP_URL=d;exports.hydrateQueryBuilder=k;exports.isPopupMessage=y;exports.openVerificationPopup=h;//# sourceMappingURL=popup.cjs.map
3
3
  //# sourceMappingURL=popup.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/popup/protocol.ts","../../src/popup/client.ts","../../src/popup/hydrate.ts"],"names":["DEFAULT_POPUP_URL","isPopupMessage","data","POPUP_WIDTH","POPUP_HEIGHT","CLOSE_POLL_INTERVAL","openVerificationPopup","options","popupUrl","popupOrigin","left","top","popup","callbacks","finished","closePoll","cleanup","onMessage","event","error","_z","_t","response","hydrateQueryBuilder","builder","query"],"mappings":"aAEO,IAAMA,CAAAA,CAAoB,+BA6C1B,SAASC,CAAAA,CAAeC,EAAiC,CAC9D,OAAO,CAAC,CAACA,GAAQA,CAAAA,CAAK,UAAA,GAAe,IAAA,EAAQ,OAAOA,EAAK,IAAA,EAAS,QACpE,CCfA,IAAMC,EAAc,GAAA,CACdC,CAAAA,CAAe,GAAA,CACfC,CAAAA,CAAsB,IAQrB,SAASC,CAAAA,CACdC,CAAAA,CACgC,CAChC,GAAI,OAAO,MAAA,CAAW,GAAA,CAAa,OAAO,KAC1C,IAAMC,CAAAA,CAAWD,CAAAA,CAAQ,QAA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AAA,CACA,KAAA,CAAO,IAAM,CACXI,CAAAA,EAAQ,CACR,GAAI,CACFJ,CAAAA,CAAM,KAAA,GACR,CAAA,KAAQ,CAER,CACF,CACF,CACF,CChJO,SAASW,CAAAA,CAAoBC,CAAAA,CAAuBC,CAAAA,CAAkC,CAC3F,OAAOD,CAAAA,CAAQ,GAAA,CAAIC,CAAK,CAAA,CAAE,MAC5B","file":"popup.cjs","sourcesContent":["import type { NullifierType, ProofMode, ProofResult, Query, QueryResult } from \"@zkpassport/utils\"\n\nexport const DEFAULT_POPUP_URL = \"https://verify.zkpassport.id\"\n\nexport type PopupRequestConfig = {\n name?: string\n logo?: string\n purpose?: string\n scope?: string\n mode?: ProofMode\n devMode?: boolean\n validity?: number\n uniqueIdentifierType?: NullifierType.NON_SALTED | NullifierType.SALTED\n oprfKeyId?: string\n}\n\nexport type PopupConfigureMessage = {\n zkpassport: true\n type: \"configure\"\n request: PopupRequestConfig\n query: Query\n}\n\nexport type PopupReadyMessage = { zkpassport: true; type: \"ready\" }\n\nexport type PopupEventMessage =\n | { zkpassport: true; type: \"request-received\" }\n | { zkpassport: true; type: \"generating\" }\n | {\n zkpassport: true\n type: \"proof-generated\"\n index?: number\n total?: number\n name?: string\n }\n | {\n zkpassport: true\n type: \"success\"\n proofs: ProofResult[]\n result: QueryResult\n }\n | { zkpassport: true; type: \"rejected\" }\n | { zkpassport: true; type: \"error\"; message: string }\n\nexport type PopupMessage = PopupConfigureMessage | PopupReadyMessage | PopupEventMessage\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isPopupMessage(data: any): data is PopupMessage {\n return !!data && data.zkpassport === true && typeof data.type === \"string\"\n}\n","import type { Query } from \"@zkpassport/utils\"\nimport type { OnSuccessVerdict } from \"../types\"\nimport {\n DEFAULT_POPUP_URL,\n isPopupMessage,\n type PopupEventMessage,\n type PopupRequestConfig,\n} from \"./protocol\"\n\nexport type PopupSuccess = Extract<PopupEventMessage, { type: \"success\" }>\n\nexport type PopupCallbacks = {\n onRequestReceived?: () => void\n onGeneratingProof?: () => void\n onProofGenerated?: (progress: { index?: number; total?: number; name?: string }) => void\n onSuccess?: (response: Omit<PopupSuccess, \"zkpassport\" | \"type\">) => OnSuccessVerdict\n onReject?: () => void\n onError?: (message: string) => void\n // Fired when the user closes the popup before a result was produced\n onClose?: () => void\n}\n\nexport type OpenVerificationPopupOptions = {\n popupUrl?: string\n request: PopupRequestConfig\n query: Query\n callbacks?: PopupCallbacks\n}\n\nexport type VerificationPopupHandle = {\n close: () => void\n popup: Window\n}\n\nconst POPUP_WIDTH = 460\nconst POPUP_HEIGHT = 780\nconst CLOSE_POLL_INTERVAL = 500\n\n/**\n * Open the hosted verification popup. MUST be called from a user gesture\n * (e.g. a click handler) or the browser will block the popup.\n *\n * If popup is blocked, will attempt to open in a new window.\n */\nexport function openVerificationPopup(\n options: OpenVerificationPopupOptions,\n): VerificationPopupHandle | null {\n if (typeof window === \"undefined\") return null\n const popupUrl = options.popupUrl ?? DEFAULT_POPUP_URL\n const popupOrigin = new URL(popupUrl).origin\n\n // Centered on the current window\n const left = Math.max(0, (window.screenX ?? 0) + (window.outerWidth - POPUP_WIDTH) / 2)\n const top = Math.max(0, (window.screenY ?? 0) + (window.outerHeight - POPUP_HEIGHT) / 2)\n const popup =\n window.open(\n popupUrl,\n \"zkpassport-verify\",\n `popup,width=${POPUP_WIDTH},height=${POPUP_HEIGHT},left=${Math.round(left)},top=${Math.round(top)}`,\n ) ??\n // Popup blocked: retry as a regular new tab\n window.open(popupUrl, \"zkpassport-verify\")\n if (!popup) return null\n\n const callbacks = options.callbacks ?? {}\n let finished = false\n let closePoll: ReturnType<typeof setInterval> | null = null\n\n const cleanup = () => {\n window.removeEventListener(\"message\", onMessage)\n if (closePoll) {\n clearInterval(closePoll)\n closePoll = null\n }\n }\n\n const onMessage = (event: MessageEvent) => {\n if (event.origin !== popupOrigin) return\n if (event.source !== popup) return\n const data = event.data\n if (!isPopupMessage(data)) return\n switch (data.type) {\n case \"ready\":\n try {\n popup.postMessage(\n {\n zkpassport: true,\n type: \"configure\",\n request: options.request,\n query: options.query,\n },\n popupOrigin,\n )\n } catch (error) {\n // Most likely DataCloneError: a non-serializable value in the request options\n console.error(\"[zkpassport] failed to send the request to the popup:\", error)\n callbacks.onError?.(\"Failed to send the request to the verification popup\")\n try {\n popup.close()\n } catch {\n // Already closed\n }\n }\n break\n case \"request-received\":\n callbacks.onRequestReceived?.()\n break\n case \"generating\":\n callbacks.onGeneratingProof?.()\n break\n case \"proof-generated\":\n callbacks.onProofGenerated?.({ index: data.index, total: data.total, name: data.name })\n break\n case \"success\": {\n finished = true\n const { zkpassport: _z, type: _t, ...response } = data\n callbacks.onSuccess?.(response)\n break\n }\n case \"rejected\":\n finished = true\n callbacks.onReject?.()\n break\n case \"error\":\n callbacks.onError?.(data.message)\n break\n }\n }\n\n window.addEventListener(\"message\", onMessage)\n closePoll = setInterval(() => {\n if (popup.closed) {\n cleanup()\n if (!finished) callbacks.onClose?.()\n }\n }, CLOSE_POLL_INTERVAL)\n\n return {\n popup,\n close: () => {\n cleanup()\n try {\n popup.close()\n } catch {\n // Already closed\n }\n },\n }\n}\n","import type { Query } from \"@zkpassport/utils\"\nimport type { QueryBuilder, QueryBuilderResult } from \"../types\"\n\n// Seed a fresh builder from the serialized Query the RP page sent over postMessage.\nexport function hydrateQueryBuilder(builder: QueryBuilder, query: Query): QueryBuilderResult {\n return builder.raw(query).done()\n}\n"]}
1
+ {"version":3,"sources":["../../src/popup/protocol.ts","../../src/popup/client.ts","../../src/popup/hydrate.ts"],"names":["DEFAULT_POPUP_URL","isPopupMessage","data","POPUP_WIDTH","POPUP_HEIGHT","CLOSE_POLL_INTERVAL","openPopupWindow","popupUrl","left","top","openVerificationPopup","options","popupOrigin","popup","callbacks","finished","closePoll","cleanup","onMessage","event","error","_z","_t","response","hydrateQueryBuilder","builder","query"],"mappings":"aASO,IAAMA,EAAoB,+BAmG1B,SAASC,CAAAA,CAAeC,CAAAA,CAAi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AAMC,CAAAA,CAAI,GAAGC,CAAS,CAAA,CAAIrB,EAClDY,CAAAA,CAAU,SAAA,GAAYS,CAAQ,CAAA,CAC9B,KACF,CACA,KAAK,WACHR,CAAAA,CAAW,IAAA,CACXD,EAAU,QAAA,IAAW,CACrB,MACF,KAAK,QACHA,CAAAA,CAAU,OAAA,GAAUZ,EAAK,OAAO,CAAA,CAChC,KACJ,CACF,CAAA,CAEA,OAAA,MAAA,CAAO,gBAAA,CAAiB,UAAWgB,CAAS,CAAA,CAC5CF,EAAY,WAAA,CAAY,IAAM,CACxBH,CAAAA,CAAM,MAAA,GACRI,CAAAA,EAAQ,CACHF,GAAUD,CAAAA,CAAU,OAAA,IAAU,EAEvC,CAAA,CAAGT,CAAmB,CAAA,CAEf,CACL,KAAA,CAAAQ,CAAAA,CACA,QAASI,CAAAA,CACT,KAAA,CAAO,IAAM,CACXA,CAAAA,GACA,GAAI,CACFJ,CAAAA,CAAM,KAAA,GACR,CAAA,KAAQ,CAER,CACF,CACF,CACF,CCpKO,SAASW,CAAAA,CAAoBC,CAAAA,CAAuBC,CAAAA,CAAkC,CAC3F,OAAOD,CAAAA,CAAQ,IAAIC,CAAK,CAAA,CAAE,MAC5B","file":"popup.cjs","sourcesContent":["import type {\n NullifierType,\n ProofMode,\n ProofResult,\n Query,\n QueryResult,\n SupportedChain,\n} from \"@zkpassport/utils\"\n\nexport const DEFAULT_POPUP_URL = \"https://verify.zkpassport.id\"\n\n/**\n * Credential minting request. When present, the popup ignores the free-form\n * query and instead resolves the on-chain policy from the registry, binds the\n * recipient and the chain into the proof, and once the proof is verified has\n * the user connect a wallet to submit ZKPassportCredentials.issue(). Any\n * account may pay for the mint; the credential always lands on `recipient`.\n */\nexport type PopupCredentialConfig = {\n /** Chain the registry lives on; also bound into the proof. */\n chain: SupportedChain\n /** On-chain policy id, as a 0x-prefixed 32-byte hex string. */\n policyId: `0x${string}`\n /** Wallet the credential is issued to, chosen by the relying party and bound into the proof. */\n recipient: `0x${string}`\n}\n\nexport type PopupRequestConfig = {\n name?: string\n logo?: string\n purpose?: string\n scope?: string\n mode?: ProofMode\n devMode?: boolean\n validity?: number\n uniqueIdentifierType?: NullifierType.NON_SALTED | NullifierType.SALTED\n oprfKeyId?: string\n}\n\n/**\n * Ready-to-send ZKPassportCredentials.issue() call, minus the ABI: pair it with\n * `ZKPassportCredentialsAbi` from `@zkpassport/onchain-credentials`.\n * The first argument is the `policyId`.\n * The second argument is the proof data.\n */\nexport type PopupCredentialIssueCall = {\n address: `0x${string}`\n functionName: \"issue\"\n args: readonly [bigint, `0x${string}`]\n}\n\n/**\n * issue() checks the wallet bound into the proof, not the transaction sender,\n * so an \"unminted\" issueCall may be submitted by any account the relying party\n * controls. The hosted popup emits \"minted\" or \"already-verified\" only;\n * \"unminted\" is reserved for a flow that hands the issue() call over instead\n * of submitting it.\n * `recipient` is the one the relying party passed in.\n */\nexport type PopupCredentialOutcome =\n | {\n status: \"minted\"\n recipient: `0x${string}`\n txHash: `0x${string}`\n issueCall: PopupCredentialIssueCall\n }\n | {\n status: \"unminted\"\n recipient: `0x${string}`\n reason?: string\n issueCall: PopupCredentialIssueCall\n }\n | { status: \"already-verified\"; recipient: `0x${string}` }\n\nexport type PopupConfigureMessage = {\n zkpassport: true\n type: \"configure\"\n request: PopupRequestConfig\n query: Query\n /** Mint mode; a sibling of `query` because each defines what to prove for its mode. */\n credential?: PopupCredentialConfig\n}\n\nexport type PopupReadyMessage = { zkpassport: true; type: \"ready\" }\n\nexport type PopupEventMessage =\n | { zkpassport: true; type: \"request-received\" }\n | { zkpassport: true; type: \"generating\" }\n | {\n zkpassport: true\n type: \"proof-generated\"\n index?: number\n total?: number\n name?: string\n }\n | {\n zkpassport: true\n type: \"success\"\n proofs: ProofResult[]\n result: QueryResult\n credential?: PopupCredentialOutcome\n }\n | { zkpassport: true; type: \"rejected\" }\n | { zkpassport: true; type: \"error\"; message: string }\n\nexport type PopupMessage = PopupConfigureMessage | PopupReadyMessage | PopupEventMessage\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isPopupMessage(data: any): data is PopupMessage {\n return !!data && data.zkpassport === true && typeof data.type === \"string\"\n}\n","import type { Query } from \"@zkpassport/utils\"\nimport type { OnSuccessVerdict } from \"../types\"\nimport {\n DEFAULT_POPUP_URL,\n isPopupMessage,\n type PopupCredentialConfig,\n type PopupEventMessage,\n type PopupRequestConfig,\n} from \"./protocol\"\n\nexport type PopupSuccess = Extract<PopupEventMessage, { type: \"success\" }>\n\nexport type PopupCallbacks = {\n onRequestReceived?: () => void\n onGeneratingProof?: () => void\n onProofGenerated?: (progress: { index?: number; total?: number; name?: string }) => void\n onSuccess?: (response: Omit<PopupSuccess, \"zkpassport\" | \"type\">) => OnSuccessVerdict\n onReject?: () => void\n onError?: (message: string) => void\n // Fired when the user closes the popup before a result was produced\n onClose?: () => void\n}\n\nexport type OpenVerificationPopupOptions = {\n popupUrl?: string\n /**\n * \"popup\" (default) opens a small chromeless window; \"tab\" opens a regular\n * browser tab (or window, per the user's browser settings) with full chrome.\n */\n windowMode?: \"popup\" | \"tab\"\n request: PopupRequestConfig\n query: Query\n credential?: PopupCredentialConfig\n callbacks?: PopupCallbacks\n}\n\nexport type VerificationPopupHandle = {\n /** Close the popup window and stop listening to it. */\n close: () => void\n /** Stop listening to the popup but leave the window open for the user. */\n release: () => void\n popup: Window\n}\n\nconst POPUP_WIDTH = 460\nconst POPUP_HEIGHT = 780\nconst CLOSE_POLL_INTERVAL = 500\n\nfunction openPopupWindow(popupUrl: string): Window | null {\n // Centered on the current window\n const left = Math.max(0, (window.screenX ?? 0) + (window.outerWidth - POPUP_WIDTH) / 2)\n const top = Math.max(0, (window.screenY ?? 0) + (window.outerHeight - POPUP_HEIGHT) / 2)\n return (\n window.open(\n popupUrl,\n \"zkpassport-verify\",\n `popup,width=${POPUP_WIDTH},height=${POPUP_HEIGHT},left=${Math.round(left)},top=${Math.round(top)}`,\n ) ??\n // Popup blocked: retry as a regular new tab\n window.open(popupUrl, \"zkpassport-verify\")\n )\n}\n\n/**\n * Open the hosted verification popup. MUST be called from a user gesture\n * (e.g. a click handler) or the browser will block the popup.\n *\n * If popup is blocked, will attempt to open in a new window.\n */\nexport function openVerificationPopup(\n options: OpenVerificationPopupOptions,\n): VerificationPopupHandle | null {\n if (typeof window === \"undefined\") return null\n const popupUrl = options.popupUrl ?? DEFAULT_POPUP_URL\n const popupOrigin = new URL(popupUrl).origin\n\n const popup =\n options.windowMode === \"tab\"\n ? window.open(popupUrl, \"zkpassport-verify\")\n : openPopupWindow(popupUrl)\n if (!popup) return null\n\n const callbacks = options.callbacks ?? {}\n let finished = false\n let closePoll: ReturnType<typeof setInterval> | null = null\n\n const cleanup = () => {\n window.removeEventListener(\"message\", onMessage)\n if (closePoll) {\n clearInterval(closePoll)\n closePoll = null\n }\n }\n\n const onMessage = (event: MessageEvent) => {\n if (event.origin !== popupOrigin) return\n if (event.source !== popup) return\n const data = event.data\n if (!isPopupMessage(data)) return\n switch (data.type) {\n case \"ready\":\n try {\n popup.postMessage(\n {\n zkpassport: true,\n type: \"configure\",\n request: options.request,\n query: options.query,\n ...(options.credential ? { credential: options.credential } : {}),\n },\n popupOrigin,\n )\n } catch (error) {\n // Most likely DataCloneError: a non-serializable value in the request options\n console.error(\"[zkpassport] failed to send the request to the popup:\", error)\n callbacks.onError?.(\"Failed to send the request to the verification popup\")\n try {\n popup.close()\n } catch {\n // Already closed\n }\n }\n break\n case \"request-received\":\n callbacks.onRequestReceived?.()\n break\n case \"generating\":\n callbacks.onGeneratingProof?.()\n break\n case \"proof-generated\":\n callbacks.onProofGenerated?.({ index: data.index, total: data.total, name: data.name })\n break\n case \"success\": {\n finished = true\n const { zkpassport: _z, type: _t, ...response } = data\n callbacks.onSuccess?.(response)\n break\n }\n case \"rejected\":\n finished = true\n callbacks.onReject?.()\n break\n case \"error\":\n callbacks.onError?.(data.message)\n break\n }\n }\n\n window.addEventListener(\"message\", onMessage)\n closePoll = setInterval(() => {\n if (popup.closed) {\n cleanup()\n if (!finished) callbacks.onClose?.()\n }\n }, CLOSE_POLL_INTERVAL)\n\n return {\n popup,\n release: cleanup,\n close: () => {\n cleanup()\n try {\n popup.close()\n } catch {\n // Already closed\n }\n },\n }\n}\n","import type { Query } from \"@zkpassport/utils\"\nimport type { QueryBuilder, QueryBuilderResult } from \"../types\"\n\n// Seed a fresh builder from the serialized Query the RP page sent over postMessage.\nexport function hydrateQueryBuilder(builder: QueryBuilder, query: Query): QueryBuilderResult {\n return builder.raw(query).done()\n}\n"]}
@@ -1,8 +1,23 @@
1
- import { ProofMode, NullifierType, ProofResult, QueryResult, Query } from '@zkpassport/utils';
2
- import { O as OnSuccessVerdict, Q as QueryBuilder, a as QueryBuilderResult } from './index-PPMt5JWF.cjs';
1
+ import { ProofMode, NullifierType, SupportedChain, ProofResult, QueryResult, Query } from '@zkpassport/utils';
2
+ import { O as OnSuccessVerdict, Q as QueryBuilder, a as QueryBuilderResult } from './index-BBgXLFAR.cjs';
3
3
  import 'i18n-iso-countries';
4
4
 
5
5
  declare const DEFAULT_POPUP_URL = "https://verify.zkpassport.id";
6
+ /**
7
+ * Credential minting request. When present, the popup ignores the free-form
8
+ * query and instead resolves the on-chain policy from the registry, binds the
9
+ * recipient and the chain into the proof, and once the proof is verified has
10
+ * the user connect a wallet to submit ZKPassportCredentials.issue(). Any
11
+ * account may pay for the mint; the credential always lands on `recipient`.
12
+ */
13
+ type PopupCredentialConfig = {
14
+ /** Chain the registry lives on; also bound into the proof. */
15
+ chain: SupportedChain;
16
+ /** On-chain policy id, as a 0x-prefixed 32-byte hex string. */
17
+ policyId: `0x${string}`;
18
+ /** Wallet the credential is issued to, chosen by the relying party and bound into the proof. */
19
+ recipient: `0x${string}`;
20
+ };
6
21
  type PopupRequestConfig = {
7
22
  name?: string;
8
23
  logo?: string;
@@ -14,11 +29,46 @@ type PopupRequestConfig = {
14
29
  uniqueIdentifierType?: NullifierType.NON_SALTED | NullifierType.SALTED;
15
30
  oprfKeyId?: string;
16
31
  };
32
+ /**
33
+ * Ready-to-send ZKPassportCredentials.issue() call, minus the ABI: pair it with
34
+ * `ZKPassportCredentialsAbi` from `@zkpassport/onchain-credentials`.
35
+ * The first argument is the `policyId`.
36
+ * The second argument is the proof data.
37
+ */
38
+ type PopupCredentialIssueCall = {
39
+ address: `0x${string}`;
40
+ functionName: "issue";
41
+ args: readonly [bigint, `0x${string}`];
42
+ };
43
+ /**
44
+ * issue() checks the wallet bound into the proof, not the transaction sender,
45
+ * so an "unminted" issueCall may be submitted by any account the relying party
46
+ * controls. The hosted popup emits "minted" or "already-verified" only;
47
+ * "unminted" is reserved for a flow that hands the issue() call over instead
48
+ * of submitting it.
49
+ * `recipient` is the one the relying party passed in.
50
+ */
51
+ type PopupCredentialOutcome = {
52
+ status: "minted";
53
+ recipient: `0x${string}`;
54
+ txHash: `0x${string}`;
55
+ issueCall: PopupCredentialIssueCall;
56
+ } | {
57
+ status: "unminted";
58
+ recipient: `0x${string}`;
59
+ reason?: string;
60
+ issueCall: PopupCredentialIssueCall;
61
+ } | {
62
+ status: "already-verified";
63
+ recipient: `0x${string}`;
64
+ };
17
65
  type PopupConfigureMessage = {
18
66
  zkpassport: true;
19
67
  type: "configure";
20
68
  request: PopupRequestConfig;
21
69
  query: Query;
70
+ /** Mint mode; a sibling of `query` because each defines what to prove for its mode. */
71
+ credential?: PopupCredentialConfig;
22
72
  };
23
73
  type PopupReadyMessage = {
24
74
  zkpassport: true;
@@ -41,6 +91,7 @@ type PopupEventMessage = {
41
91
  type: "success";
42
92
  proofs: ProofResult[];
43
93
  result: QueryResult;
94
+ credential?: PopupCredentialOutcome;
44
95
  } | {
45
96
  zkpassport: true;
46
97
  type: "rejected";
@@ -70,12 +121,21 @@ type PopupCallbacks = {
70
121
  };
71
122
  type OpenVerificationPopupOptions = {
72
123
  popupUrl?: string;
124
+ /**
125
+ * "popup" (default) opens a small chromeless window; "tab" opens a regular
126
+ * browser tab (or window, per the user's browser settings) with full chrome.
127
+ */
128
+ windowMode?: "popup" | "tab";
73
129
  request: PopupRequestConfig;
74
130
  query: Query;
131
+ credential?: PopupCredentialConfig;
75
132
  callbacks?: PopupCallbacks;
76
133
  };
77
134
  type VerificationPopupHandle = {
135
+ /** Close the popup window and stop listening to it. */
78
136
  close: () => void;
137
+ /** Stop listening to the popup but leave the window open for the user. */
138
+ release: () => void;
79
139
  popup: Window;
80
140
  };
81
141
  /**
@@ -88,4 +148,4 @@ declare function openVerificationPopup(options: OpenVerificationPopupOptions): V
88
148
 
89
149
  declare function hydrateQueryBuilder(builder: QueryBuilder, query: Query): QueryBuilderResult;
90
150
 
91
- export { DEFAULT_POPUP_URL, type OpenVerificationPopupOptions, type PopupCallbacks, type PopupConfigureMessage, type PopupEventMessage, type PopupMessage, type PopupReadyMessage, type PopupRequestConfig, type PopupSuccess, type VerificationPopupHandle, hydrateQueryBuilder, isPopupMessage, openVerificationPopup };
151
+ export { DEFAULT_POPUP_URL, type OpenVerificationPopupOptions, type PopupCallbacks, type PopupConfigureMessage, type PopupCredentialConfig, type PopupCredentialIssueCall, type PopupCredentialOutcome, type PopupEventMessage, type PopupMessage, type PopupReadyMessage, type PopupRequestConfig, type PopupSuccess, type VerificationPopupHandle, hydrateQueryBuilder, isPopupMessage, openVerificationPopup };
@@ -1,3 +1,3 @@
1
1
  import 'i18n-iso-countries';
2
2
  import '@zkpassport/utils';
3
- export { c as createOfflineQuery, g as generalCompare, n as normalizeCountry, b as numericalCompare, r as rangeCompare } from './index-PPMt5JWF.cjs';
3
+ export { c as createOfflineQuery, g as generalCompare, n as normalizeCountry, b as numericalCompare, r as rangeCompare } from './index-BBgXLFAR.cjs';
@@ -106,6 +106,11 @@ type QueryBuilderResult = {
106
106
  * Called when the SDK successfully connects to the bridge with the mobile app.
107
107
  */
108
108
  onBridgeConnect: (callback: () => void) => void;
109
+ /**
110
+ * Called when the connection to the bridge is lost and the SDK has stopped
111
+ * trying to reconnect on its own. A later `onBridgeConnect` means it came back.
112
+ */
113
+ onBridgeConnectionLost: (callback: () => void) => void;
109
114
  /**
110
115
  * Called when the user has generated a proof.
111
116
  *
@@ -252,9 +257,9 @@ type QueryBuilder<T extends "online" | "offline" = "online"> = {
252
257
  facematch: (mode?: FacematchMode) => QueryBuilder;
253
258
  raw: (query: Query) => QueryBuilder<T>;
254
259
  /**
255
- * Applies an immutable policy fetched from the dashboard. The policy's query,
256
- * purpose and scope are locked; combining with builder methods (except
257
- * `.bind()`, which may follow it) or calling twice throws.
260
+ * Applies a policy fetched from the dashboard. The policy's query is locked, and its
261
+ * purpose and scope are used unless the request sets its own. Combining with builder
262
+ * methods (except `.bind()`, which may follow it) or calling twice throws.
258
263
  * @param id The policy id (e.g. `'pol_xyz'`).
259
264
  */
260
265
  policy: (id: string) => QueryBuilder<T>;
@@ -275,6 +280,8 @@ declare function generalCompare(fnName: "in" | "out" | "eq", key: IDCredential,
275
280
  requestId: string, requestIdToConfig: Record<string, Query>): void;
276
281
  declare function createOfflineQuery(): QueryBuilder<"offline">;
277
282
 
283
+ declare const VERSION: string;
284
+
278
285
  declare class ZKPassport {
279
286
  private domain;
280
287
  private domainProvided;
@@ -295,6 +302,7 @@ declare class ZKPassport {
295
302
  private onRequestReceivedCallbacks;
296
303
  private onGeneratingProofCallbacks;
297
304
  private onBridgeConnectCallbacks;
305
+ private onBridgeConnectionLostCallbacks;
298
306
  private onProofGeneratedCallbacks;
299
307
  private onSuccessCallbacks;
300
308
  private onResultCallbacks;
@@ -318,11 +326,11 @@ declare class ZKPassport {
318
326
  private assertCanApplyPolicy;
319
327
  /**
320
328
  * @notice Create a new request. To apply a policy, chain `.policy('<id>')` on
321
- * the returned builder; a policy locks the query and scope.
329
+ * the returned builder; a policy locks the query.
322
330
  * @param name Your service name. Defaults to the dashboard branding, then the domain.
323
331
  * @param logo Your service logo. Defaults to the dashboard branding.
324
332
  * @param purpose Explanation shown to the user. Defaults to the policy's purpose (if any), then a generic message.
325
- * @param scope Use-case scope (drives the nullifier). Defaults to the domain. Locked by `.policy()` (to the policy id).
333
+ * @param scope Use-case scope (drives the nullifier). Defaults to the policy id (if any), then the domain.
326
334
  * @param projectID The project ID of your service
327
335
  * @param validity How many seconds ago the proof checking the expiry date of the ID should have been generated
328
336
  * @param mode The proof mode (e.g. "fast" / "compressed").
@@ -441,4 +449,4 @@ declare class ZKPassport {
441
449
  clearAllRequests(): void;
442
450
  }
443
451
 
444
- export { type DashboardConfig as D, type OnSuccessVerdict as O, type Policy as P, type QueryBuilder as Q, type RequestSuccess as R, type SolidityProofVerificationData as S, type VerificationResult as V, ZKPassport as Z, type QueryBuilderResult as a, numericalCompare as b, createOfflineQuery as c, type OfflineQueryBuilderResult as d, type QueryResultError as e, type QueryResultErrors as f, generalCompare as g, type RequestedNullifierType as h, type SolidityServiceConfig as i, type SolidityVerifierParameters as j, type VerifierMode as k, normalizeCountry as n, rangeCompare as r };
452
+ export { type DashboardConfig as D, type OnSuccessVerdict as O, type Policy as P, type QueryBuilder as Q, type RequestSuccess as R, type SolidityProofVerificationData as S, VERSION as V, ZKPassport as Z, type QueryBuilderResult as a, numericalCompare as b, createOfflineQuery as c, type OfflineQueryBuilderResult as d, type QueryResultError as e, type QueryResultErrors as f, generalCompare as g, type RequestedNullifierType as h, type SolidityServiceConfig as i, type SolidityVerifierParameters as j, type VerificationResult as k, type VerifierMode as l, normalizeCountry as n, rangeCompare as r };
@@ -1,3 +1,3 @@
1
- export { D as DashboardConfig, d as OfflineQueryBuilderResult, O as OnSuccessVerdict, P as Policy, Q as QueryBuilder, a as QueryBuilderResult, e as QueryResultError, f as QueryResultErrors, R as RequestSuccess, h as RequestedNullifierType, S as SolidityProofVerificationData, i as SolidityServiceConfig, j as SolidityVerifierParameters, V as VerificationResult, k as VerifierMode, Z as ZKPassport, c as createOfflineQuery } from './index-PPMt5JWF.js';
1
+ export { D as DashboardConfig, d as OfflineQueryBuilderResult, O as OnSuccessVerdict, P as Policy, Q as QueryBuilder, a as QueryBuilderResult, e as QueryResultError, f as QueryResultErrors, R as RequestSuccess, h as RequestedNullifierType, S as SolidityProofVerificationData, i as SolidityServiceConfig, j as SolidityVerifierParameters, V as VERSION, k as VerificationResult, l as VerifierMode, Z as ZKPassport, c as createOfflineQuery } from './index-BBgXLFAR.js';
2
2
  export { ASEAN_COUNTRIES, BoundData, CountryName, DisclosableIDCredential, EEA_COUNTRIES, EU_COUNTRIES, FacematchMode, IDCredential, IDCredentialValue, JsonRpcRequest, MERCOSUR_COUNTRIES, NullifierType, NumericalIDCredential, ProofMode, ProofResult, ProofType, ProofTypeLength, Query, QueryResult, SANCTIONED_COUNTRIES, SCHENGEN_COUNTRIES, SanctionsCountries, SanctionsLists, Service, SupportedChain } from '@zkpassport/utils';
3
3
  import 'i18n-iso-countries';