import { P as PostMessageType, a as PostMessageMethod } from './post-message-ufv3D_fs.mjs'; /** * Transport — the bidirectional postMessage channel between the parent * (web SDK or RN SDK) and the iframe-app. Web wraps * `createPostMessageClient(iframeRef.current.contentWindow, ...)`; RN * wraps a `WebViewBridge` over react-native-webview. * * `send` resolves with the iframe handler's raw return value and rejects * with the handler's thrown error (canonical envelope, no * {success, data} unwrap at the call site). */ interface Transport { send(type: PostMessageType, method: PostMessageMethod, payload: P): Promise; /** * Register a handler for inbound messages from the iframe-app. Only * needed by the parent-side `*WithUI` flow path, where the modal * postMessages a result back that the SDK's pending Promise needs to * resolve. Returns an unregister fn. */ register?(type: PostMessageType, method: PostMessageMethod, handler: (payload: P) => Promise | R): () => void; /** * Whether the underlying iframe / WebView is loaded and ready to * receive messages. SDK methods short-circuit with "SDK not ready" * before calling `send` if this returns false. */ isReady(): boolean; } /** * PasskeyAssertor — runs the WebAuthn assertion ceremony in the *parent* * (where user activation lives — cross-origin iframes/WebViews can't * reliably get their own click handler). * * Two methods, two distinct flow shapes: * * - `assert` is the DEK-unwrap path: empty allowCredentials, harvests * userHandle (= DEK wrap key in MoonX's overloaded model), consumed * locally by the iframe-app. Never crosses the server boundary. * * - `assertForServer` is the server-roundtrip path (presence step-up, * future passkey sign-in): server issues options, browser asserts, * server verifies the signature. userHandle is stripped on the * platform boundary (DEK hygiene) — the strip happens INSIDE the * assertor impl, not in the orchestrator, so no caller can bypass * it. * * Registration is handled separately via `@simplewebauthn/browser`'s * `startRegistration` on web / `passkeyCreate` from * `react-native-passkeys` on RN; this interface is assertion-only. */ interface PasskeyAssertor { /** * Run a WebAuthn assertion (`navigator.credentials.get` on web, * `passkeyGet` from react-native-passkeys on RN). Returns the * platform-decoded base64url forms of the credential id and userHandle. */ assert(opts: { rpId: string; challenge: string; /** * The wire `allow_credential_ids_b64url` list from GET_DEK_INFO, * passed through for platforms that want to use it. Note both * platforms today pass an empty array to the underlying API; this * field is informational only (e.g. for telemetry or for a future * platform that prefers non-discoverable login). */ allowCredentials: string[]; }): Promise<{ rawIdB64url: string; userHandleB64url: string; }>; /** * Run a WebAuthn assertion for a SERVER-VERIFIED flow (presence * step-up, future passkey sign-in). Takes a full * `PublicKeyCredentialRequestOptionsJSON` (the server-issued * `optionsJSON`) and returns the standard * `AuthenticationResponseJSON` with `response.userHandle` * **stripped** — DEK hygiene is enforced inside the impl so the * orchestrator (and any future caller) cannot forget it. * * The returned object goes straight onto the wire to /presence/verify * (or the future /login/verify). Each platform-specific impl is * responsible for: (a) running the underlying ceremony, (b) * shaping the result into AuthenticationResponseJSON, and (c) the * userHandle strip. */ assertForServer(opts: { optionsJSON: WebAuthnRequestOptions; }): Promise; /** * Internal-use variant of assertForServer. Runs the same WebAuthn * ceremony and returns the same sanitized assertion (userHandle * stripped on the platform boundary), but ALSO surfaces the * captured userHandle + credential id separately for the SDK * orchestrator's downstream postMessage payload — the iframe needs * the userHandle bytes to do AES-GCM unwrap of the DEK after the * presence ceremony mints the scoped tokens. * * DEK hygiene boundary: the sanitized `response` field still has * `response.userHandle === undefined`. The separate * `userHandleB64url` field stays inside the orchestrator and is * postMessaged to the iframe — never sent over the network to the * presence-verify server call. The strip is enforced by the impl; * the separate surfacing is opt-in via this method. */ assertForInternalPresence(opts: { optionsJSON: WebAuthnRequestOptions; }): Promise<{ response: WebAuthnAssertionResponse; userHandleB64url: string; credentialIdB64url: string; }>; } /** * Subset of `PublicKeyCredentialRequestOptionsJSON` we forward to the * platform impl. Kept loose-typed so a server adding fields doesn't * require an interface change here. */ interface WebAuthnRequestOptions { challenge: string; rpId?: string; allowCredentials?: Array<{ id: string; type?: string; transports?: string[]; }>; userVerification?: string; timeout?: number; extensions?: Record; } /** * Standard `AuthenticationResponseJSON` shape, with `userHandle` * deliberately optional because the assertForServer contract is that * impls strip it before returning. The field stays in the type so a * server-side decoder can still parse it (= undefined) without a * union mismatch. */ interface WebAuthnAssertionResponse { id: string; rawId: string; type: string; response: { clientDataJSON: string; authenticatorData: string; signature: string; userHandle?: undefined; }; clientExtensionResults?: Record; authenticatorAttachment?: string; } /** * RelyingPartyOriginInput — the WebAuthn relying-party origin the * presence/register orchestrators thread to `/presence/begin` so the * server can rebuild the per-app RP config. * * Web passes a plain string (`window.location.origin`) — the browser * always has an ambient origin. RN has none, so it passes a thunk that * derives `https://` from the iframe's `GET_DEK_INFO` (and * memoizes the round-trip). Resolved lazily at call time via * `resolveRelyingPartyOrigin` — i.e. always after auth, when * `GET_DEK_INFO` is answerable. */ type RelyingPartyOriginInput = string | (() => string | Promise); /** Resolve a {@link RelyingPartyOriginInput} to its string value. */ declare const resolveRelyingPartyOrigin: (input: RelyingPartyOriginInput) => Promise; /** * KvStorage — async key/value storage for ID tokens + session metadata. * Web wraps `localStorage` (sync, lifted to a resolved Promise); RN * wraps `@react-native-async-storage/async-storage` (natively async). * * Always async at the interface to unify both platforms. */ interface KvStorage { get(key: string): Promise; set(key: string, value: string): Promise; remove(key: string): Promise; } /** * OAuthOpener — start an OAuth authorize request and wait for the * provider redirect to return with `code` + `state`. Web uses a * full-page redirect or popup (completion picked up by * `useOAuthCompletion` listening for postMessages); RN uses * `expo-web-browser.openAuthSessionAsync` (single Promise resolves on * deep-link callback). */ interface OAuthOpener { open(opts: { authorizeUrl: string; redirectUrl: string; }): Promise<{ code: string; state: string; }>; } /** * The bundle of platform impls that the SDK factories accept. Provider * components on each platform construct one of these once and pass it * through to the factories. */ interface PlatformImpls { transport: Transport; passkey: PasskeyAssertor; storage: KvStorage; oauth: OAuthOpener; } export { type KvStorage as K, type OAuthOpener as O, type PasskeyAssertor as P, type RelyingPartyOriginInput as R, type Transport as T, type WebAuthnAssertionResponse as W, type PlatformImpls as a, type WebAuthnRequestOptions as b, resolveRelyingPartyOrigin as r };