@rhinestone/1auth 0.7.0 → 0.7.2

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 +1 @@
1
- {"version":3,"sources":["../src/headless-client.ts","../src/smart-session-signatures.ts"],"sourcesContent":["/**\n * Headless 1auth client.\n *\n * Used by integrators that hold their own ECDSA signer in localStorage\n * and produce signatures for an ERC-7579 validator other than the\n * passkey one (typically `@rhinestone/sdk` experimental SmartSession).\n *\n * Responsibilities:\n * - Fetch sponsorship JWTs from the app's own backend.\n * - Call `/api/intent/prepare?signingMode=headless` to get an\n * orchestrator-quoted `intentOp` + `digestResult`.\n * - Forward pre-encoded validator-prefixed signatures to the new\n * `/api/intent/headless-execute` route.\n * - Drive the existing passkey dialog (via {@link OneAuthClient}) for\n * the one-time SmartSession install ceremony.\n *\n * 1auth itself stays ignorant of session keys — the on-chain\n * SmartSession validator is the only authority over what a session key\n * may sign for. The host app persists `{ sessionKeyAddress, permissionId,\n * accountAddress, permissions }` in its own storage.\n */\n\nimport type {\n HeadlessIntentOptions,\n HeadlessIntentStatusResult,\n HeadlessPrepareResult,\n HeadlessSubmitOptions,\n HeadlessSubmitResult,\n InstallSmartSessionOptions,\n InstallSmartSessionResult,\n IntentTokenRequest,\n PasskeyProviderConfig,\n SponsorshipCallbackConfig,\n SponsorshipConfig,\n} from \"./types\";\nimport { tokenFetchError } from \"./sponsorship-fetch\";\n\nconst DEFAULT_PROVIDER_URL = \"https://passkey.1auth.box\";\n\nconst MISSING_APP_CREDENTIALS_MESSAGE =\n \"No sponsorship configured on OneAuthHeadlessClient. Every user intent must carry the app's JWT — pass `sponsorship: { accessToken, getExtensionToken }` (or URL form) to the constructor.\";\n\ntype AccessTokenFetchResult =\n | { ok: true; accessToken: string }\n | { ok: false; code?: \"MISSING_APP_CREDENTIALS\"; message: string };\n\ntype ExtensionTokenFetchResult =\n | { ok: true; extensionToken: string | undefined }\n | { ok: false; message: string };\n\n/**\n * Mirrors `normalizeSponsorship` in `client.ts`. Kept local so the\n * headless entry point doesn't pull in the whole OneAuthClient module\n * graph for callers that only need the headless surface.\n */\nfunction normalizeSponsorship(\n config: SponsorshipConfig | undefined,\n): SponsorshipCallbackConfig | null {\n if (!config) return null;\n if (\"accessToken\" in config && \"getExtensionToken\" in config) {\n return config;\n }\n const { accessTokenUrl, extensionTokenUrl } = config;\n return {\n accessToken: async () => {\n const response = await fetch(accessTokenUrl, { credentials: \"include\" });\n if (!response.ok) {\n throw await tokenFetchError(\"access token\", response);\n }\n const data = (await response.json()) as { token?: string };\n if (!data.token) {\n throw new Error(\"Access token response missing `token` field\");\n }\n return data.token;\n },\n getExtensionToken: async (intentOp: string) => {\n const response = await fetch(extensionTokenUrl, {\n method: \"POST\",\n credentials: \"include\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ intentOp }),\n });\n if (!response.ok) {\n throw await tokenFetchError(\"extension token\", response);\n }\n const data = (await response.json()) as { token?: string };\n if (!data.token) {\n throw new Error(\"Extension token response missing `token` field\");\n }\n return data.token;\n },\n };\n}\n\nexport class OneAuthHeadlessClient {\n private providerUrl: string;\n private clientId?: string;\n private sponsorship: SponsorshipCallbackConfig | null;\n\n constructor(config: PasskeyProviderConfig) {\n this.providerUrl = config.providerUrl || DEFAULT_PROVIDER_URL;\n this.clientId = config.clientId;\n this.sponsorship = normalizeSponsorship(config.sponsorship);\n }\n\n setSponsorship(sponsorship: SponsorshipConfig | undefined): void {\n this.sponsorship = normalizeSponsorship(sponsorship);\n }\n\n // ---------------------------------------------------------------------------\n // Sponsorship JWT fetchers\n // ---------------------------------------------------------------------------\n\n private async fetchAccessToken(): Promise<AccessTokenFetchResult> {\n if (!this.sponsorship) {\n return {\n ok: false,\n code: \"MISSING_APP_CREDENTIALS\",\n message: MISSING_APP_CREDENTIALS_MESSAGE,\n };\n }\n try {\n const accessToken = await this.sponsorship.accessToken();\n return { ok: true, accessToken };\n } catch (err) {\n return {\n ok: false,\n message: err instanceof Error ? err.message : String(err),\n };\n }\n }\n\n private async fetchExtensionToken(\n intentOp: string,\n sponsor: boolean,\n ): Promise<ExtensionTokenFetchResult> {\n if (!sponsor) return { ok: true, extensionToken: undefined };\n if (!this.sponsorship) {\n return { ok: false, message: MISSING_APP_CREDENTIALS_MESSAGE };\n }\n try {\n const token = await this.sponsorship.getExtensionToken(intentOp);\n return { ok: true, extensionToken: token };\n } catch (err) {\n return {\n ok: false,\n message: err instanceof Error ? err.message : String(err),\n };\n }\n }\n\n // ---------------------------------------------------------------------------\n // Intent prepare / submit\n // ---------------------------------------------------------------------------\n\n /**\n * Quote an intent without opening any dialog. Returns the orchestrator's\n * `intentOp` plus the digest the caller must sign with their own\n * validator (e.g. SmartSession). The caller is responsible for\n * encoding signatures and submitting via {@link submitIntent}.\n */\n async prepareIntent(options: HeadlessIntentOptions): Promise<HeadlessPrepareResult> {\n if (!options.username && !options.accountAddress) {\n throw new Error(\"prepareIntent requires either `username` or `accountAddress`\");\n }\n\n const accessTokenResult = await this.fetchAccessToken();\n if (!accessTokenResult.ok) {\n throw new Error(`Sponsorship access token fetch failed: ${accessTokenResult.message}`);\n }\n\n // bigint → string conversion for token requests; matches what the\n // dialog flow does before serializing requestBody.\n const tokenRequests = options.tokenRequests?.map((tr: IntentTokenRequest) => ({\n token: tr.token,\n amount: tr.amount.toString(),\n }));\n\n const body = {\n username: options.username,\n accountAddress: options.accountAddress,\n targetChain: options.targetChain,\n calls: options.calls,\n tokenRequests,\n sourceAssets: options.sourceAssets,\n sourceChainId: options.sourceChainId,\n sessionKeyHandle: options.sessionKeyHandle,\n clientId: this.clientId,\n signingMode: \"headless\" as const,\n auth: { accessToken: accessTokenResult.accessToken },\n };\n\n const response = await fetch(`${this.providerUrl}/api/intent/prepare`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({}))) as { error?: string };\n throw new Error(errorData.error || `Prepare failed (${response.status})`);\n }\n\n return (await response.json()) as HeadlessPrepareResult;\n }\n\n /**\n * Forward a pre-signed intent to the orchestrator. The caller has\n * already encoded validator-prefixed origin + destination signatures\n * (one origin signature per intent element); 1auth treats them as\n * opaque bytes.\n *\n * If `sponsor` is omitted or `true`, an extension token is fetched\n * just-in-time and bound to the intent. Pass `sponsor: false` for\n * self-paying intents.\n */\n async submitIntent(options: HeadlessSubmitOptions): Promise<HeadlessSubmitResult> {\n const sponsor = options.sponsor ?? true;\n const accessTokenResult = await this.fetchAccessToken();\n if (!accessTokenResult.ok) {\n throw new Error(`Sponsorship access token fetch failed: ${accessTokenResult.message}`);\n }\n\n const extensionResult = await this.fetchExtensionToken(options.intentOp, sponsor);\n if (!extensionResult.ok) {\n throw new Error(`Sponsorship extension token fetch failed: ${extensionResult.message}`);\n }\n\n const body = {\n intentOp: options.intentOp,\n accountAddress: options.accountAddress,\n targetChain: options.targetChain,\n calls: options.calls,\n expiresAt: options.expiresAt,\n originSignatures: options.originSignatures,\n destinationSignature: options.destinationSignature,\n targetExecutionSignature: options.targetExecutionSignature,\n auth: {\n accessToken: accessTokenResult.accessToken,\n ...(extensionResult.extensionToken && { extensionToken: extensionResult.extensionToken }),\n },\n };\n\n const response = await fetch(`${this.providerUrl}/api/intent/headless-execute`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({}))) as { error?: string };\n throw new Error(errorData.error || `Headless execute failed (${response.status})`);\n }\n\n return (await response.json()) as HeadlessSubmitResult;\n }\n\n // ---------------------------------------------------------------------------\n // Status / wait — proxies to the existing routes (no headless variant needed).\n // ---------------------------------------------------------------------------\n\n /**\n * Fetch the latest known status for a submitted headless intent.\n * This is a non-blocking read and may return `pending` before a\n * solver has produced a fill transaction hash.\n */\n async getIntentStatus(intentId: string): Promise<HeadlessIntentStatusResult> {\n const response = await fetch(`${this.providerUrl}/api/intent/status/${intentId}`);\n if (!response.ok) {\n throw new Error(`Status fetch failed (${response.status})`);\n }\n return (await response.json()) as HeadlessIntentStatusResult;\n }\n\n /**\n * Wait for a submitted headless intent to produce a status update and,\n * when available, the final fill transaction hash. The wait endpoint\n * needs the opaque `transactionResult` returned by submit because 1auth\n * does not persist that SDK object in its database.\n */\n async waitForIntent(\n intentId: string,\n transactionResult: unknown,\n ): Promise<HeadlessIntentStatusResult> {\n if (!transactionResult) {\n throw new Error(\"waitForIntent requires submitResult.transactionResult\");\n }\n\n const response = await fetch(`${this.providerUrl}/api/intent/wait/${intentId}`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ transactionResult }),\n });\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({}))) as {\n error?: string;\n details?: string;\n };\n throw new Error(\n errorData.details || errorData.error || `Wait fetch failed (${response.status})`,\n );\n }\n return (await response.json()) as HeadlessIntentStatusResult;\n }\n\n // ---------------------------------------------------------------------------\n // SmartSession install (one-time, passkey-signed)\n // ---------------------------------------------------------------------------\n\n /**\n * Resolve the SmartSession install call(s) for `sessionKeyAddress`\n * with the supplied `permissions`.\n *\n * Returns `{ install, sessionKeyHandle }`:\n *\n * - `install` is a `{ targetChain, calls }` pair the caller feeds\n * straight into `OneAuthClient.sendIntent({ targetChain, calls })`\n * so the user passkey-signs the install via the existing dialog.\n * - `sessionKeyHandle` contains the deterministic `permissionId`\n * plus metadata to persist in localStorage. Persist this BEFORE\n * submitting the install so a refresh during signing doesn't\n * lose the handle.\n *\n * If the validator is already installed on the user's account,\n * `install.calls` is empty and `install.alreadyInstalled` is true.\n * The caller should still persist `sessionKeyHandle` — the on-chain\n * session enabling happens at first headless use via SmartSession's\n * ENABLE-mode signature wrapping (see follow-up).\n */\n async installSmartSession(\n options: InstallSmartSessionOptions,\n ): Promise<InstallSmartSessionResult> {\n if (!options.username && !options.accountAddress) {\n throw new Error(\n \"installSmartSession requires either `username` or `accountAddress`\",\n );\n }\n\n const accessTokenResult = await this.fetchAccessToken();\n if (!accessTokenResult.ok) {\n throw new Error(\n `Sponsorship access token fetch failed: ${accessTokenResult.message}`,\n );\n }\n\n const body = {\n username: options.username,\n accountAddress: options.accountAddress,\n targetChain: options.targetChain,\n sessionKeyAddress: options.sessionKeyAddress,\n permissions: options.permissions,\n validUntil: options.validUntil,\n validAfter: options.validAfter,\n maxUses: options.maxUses,\n enableSessionSignature: options.enableSessionSignature,\n label: options.label,\n auth: { accessToken: accessTokenResult.accessToken },\n };\n\n const response = await fetch(`${this.providerUrl}/api/sessions/install`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({}))) as {\n error?: string;\n };\n throw new Error(errorData.error || `Install failed (${response.status})`);\n }\n\n return (await response.json()) as InstallSmartSessionResult;\n }\n}\n","import { type Address, type Hex } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport {\n createRhinestoneAccount,\n type Session,\n type SignData,\n type SignerSet,\n} from \"@rhinestone/sdk\";\nimport { toSession } from \"@rhinestone/sdk/smart-sessions\";\nimport { getChainById } from \"./registry\";\nimport type { HeadlessPrepareResult, SessionKeyHandle } from \"./types\";\n\n/** Restores bigint sentinel strings emitted by 1auth's JSON transport. */\nfunction reviveBigIntStrings<T>(value: T): T {\n if (Array.isArray(value)) return value.map((entry) => reviveBigIntStrings(entry)) as T;\n if (value && typeof value === \"object\") {\n return Object.fromEntries(\n Object.entries(value).map(([key, entry]) => [key, reviveBigIntStrings(entry)]),\n ) as T;\n }\n if (typeof value === \"string\" && value.startsWith(\"__bigint:\")) {\n return BigInt(value.slice(\"__bigint:\".length)) as T;\n }\n if (typeof value === \"string\" && /^\\d+$/.test(value)) return BigInt(value) as T;\n return value;\n}\n\n/** Parses the prepared transaction enough to recover the SDK-native SignData. */\nfunction parsePreparedSignData(value: string): SignData {\n const prepared = JSON.parse(value, (_key, nested) => reviveBigIntStrings(nested)) as {\n quotes?: { best?: { signData?: SignData } };\n };\n const signData = prepared.quotes?.best?.signData;\n if (!signData) {\n throw new Error(\"Prepared headless intent is missing quotes.best.signData\");\n }\n return signData;\n}\n\n/** Reads the numeric EIP-712 chain id from a typed-data domain. */\nfunction chainIdFromSignDataDomain(domainChainId: unknown): number | undefined {\n if (typeof domainChainId === \"number\" && Number.isSafeInteger(domainChainId)) {\n return domainChainId;\n }\n if (typeof domainChainId === \"bigint\") return Number(domainChainId);\n if (typeof domainChainId === \"string\" && /^\\d+$/.test(domainChainId)) {\n return Number(domainChainId);\n }\n return undefined;\n}\n\n/** Rebuilds the SDK SmartSession object from the persisted grant handle. */\nfunction buildSessionForChain(args: {\n privateKey: Hex;\n handle: SessionKeyHandle;\n chainId: number;\n}): Session {\n return toSession(\n {\n chain: getChainById(args.chainId),\n owners: { type: \"ecdsa\", accounts: [privateKeyToAccount(args.privateKey)] },\n permissions: reviveBigIntStrings(args.handle.permissions ?? []),\n crossChainPermits: reviveBigIntStrings(args.handle.crossChainPermits ?? []),\n },\n // The production SmartSession module is deployed on testnets too. Never opt\n // into SDK dev contracts for 1auth headless permissions.\n { useDevContracts: false },\n );\n}\n\n/** Builds a per-chain SmartSession signer set for every chain in SignData. */\nfunction buildSessionSigners(args: {\n privateKey: Hex;\n handle: SessionKeyHandle;\n prepared: HeadlessPrepareResult;\n signData: SignData;\n}): SignerSet {\n const chainIds = new Set<number>([args.prepared.targetChain]);\n for (const typedData of args.signData.origin) {\n const chainId = chainIdFromSignDataDomain(typedData.domain?.chainId);\n if (chainId) chainIds.add(chainId);\n }\n const targetExecutionChainId = chainIdFromSignDataDomain(\n args.signData.targetExecution?.domain?.chainId,\n );\n if (targetExecutionChainId) chainIds.add(targetExecutionChainId);\n\n return {\n type: \"experimental_session\",\n sessions: Object.fromEntries(\n [...chainIds].map((chainId) => [\n chainId,\n {\n session: buildSessionForChain({\n privateKey: args.privateKey,\n handle: args.handle,\n chainId,\n }),\n },\n ]),\n ),\n };\n}\n\nexport interface BuildSmartSessionHeadlessSignaturesOptions {\n /** ECDSA private key for the locally-held SmartSession signer. */\n privateKey: Hex;\n /** Smart account address the SmartSession is scoped to. */\n accountAddress: Address;\n /** Persisted handle returned by `grantPermissions` / SmartSession install. */\n sessionKeyHandle: SessionKeyHandle;\n /** Prepared headless intent returned by `OneAuthHeadlessClient.prepareIntent`. */\n prepared: HeadlessPrepareResult;\n}\n\n/**\n * Builds SmartSession signatures for `OneAuthHeadlessClient.submitIntent`.\n *\n * This intentionally delegates signing and SmartSession signature packing to\n * `@rhinestone/sdk`. 1auth only rebuilds the persisted session descriptor and\n * supplies the SDK-native `SignData` returned by the orchestrator quote.\n */\nexport async function buildSmartSessionHeadlessSignatures(\n options: BuildSmartSessionHeadlessSignaturesOptions,\n) {\n const signData = parsePreparedSignData(options.prepared.intentOp);\n const account = await createRhinestoneAccount({\n initData: { address: options.accountAddress },\n owners: {\n type: \"ecdsa\",\n accounts: [privateKeyToAccount(options.privateKey)],\n },\n experimental_sessions: { enabled: true },\n });\n\n return account.signIntent(\n signData,\n getChainById(options.prepared.targetChain),\n buildSessionSigners({\n privateKey: options.privateKey,\n handle: options.sessionKeyHandle,\n prepared: options.prepared,\n signData,\n }),\n );\n}\n"],"mappings":";;;;;;;;AAqCA,IAAM,uBAAuB;AAE7B,IAAM,kCACJ;AAeF,SAAS,qBACP,QACkC;AAClC,MAAI,CAAC,OAAQ,QAAO;AACpB,MAAI,iBAAiB,UAAU,uBAAuB,QAAQ;AAC5D,WAAO;AAAA,EACT;AACA,QAAM,EAAE,gBAAgB,kBAAkB,IAAI;AAC9C,SAAO;AAAA,IACL,aAAa,YAAY;AACvB,YAAM,WAAW,MAAM,MAAM,gBAAgB,EAAE,aAAa,UAAU,CAAC;AACvE,UAAI,CAAC,SAAS,IAAI;AAChB,cAAM,MAAM,gBAAgB,gBAAgB,QAAQ;AAAA,MACtD;AACA,YAAM,OAAQ,MAAM,SAAS,KAAK;AAClC,UAAI,CAAC,KAAK,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f;AACZ,QAAM,WAAW,oBAAI,IAAY,CAAC,KAAK,SAAS,WAAW,CAAC;AAC5D,aAAW,aAAa,KAAK,SAAS,QAAQ;AAC5C,UAAM,UAAU,0BAA0B,UAAU,QAAQ,OAAO;AACnE,QAAI,QAAS,UAAS,IAAI,OAAO;AAAA,EACnC;AACA,QAAM,yBAAyB;AAAA,IAC7B,KAAK,SAAS,iBAAiB,QAAQ;AAAA,EACzC;AACA,MAAI,uBAAwB,UAAS,IAAI,sBAAsB;AAE/D,SAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU,OAAO;AAAA,MACf,CAAC,GAAG,QAAQ,EAAE,IAAI,CAAC,YAAY;AAAA,QAC7B;AAAA,QACA;AAAA,UACE,SAAS,qBAAqB;AAAA,YAC5B,YAAY,KAAK;AAAA,YACjB,QAAQ,KAAK;AAAA,YACb;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAoBA,eAAsB,oCACpB,SACA;AACA,QAAM,WAAW,sBAAsB,QAAQ,SAAS,QAAQ;AAChE,QAAM,UAAU,MAAM,wBAAwB;AAAA,IAC5C,UAAU,EAAE,SAAS,QAAQ,eAAe;AAAA,IAC5C,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU,CAAC,oBAAoB,QAAQ,UAAU,CAAC;AAAA,IACpD;AAAA,IACA,uBAAuB,EAAE,SAAS,KAAK;AAAA,EACzC,CAAC;AAED,SAAO,QAAQ;AAAA,IACb;AAAA,IACA,aAAa,QAAQ,SAAS,WAAW;AAAA,IACzC,oBAAoB;AAAA,MAClB,YAAY,QAAQ;AAAA,MACpB,QAAQ,QAAQ;AAAA,MAChB,UAAU,QAAQ;AAAA,MAClB;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/headless-client.ts","../src/smart-session-signatures.ts"],"sourcesContent":["/**\n * Headless 1auth client.\n *\n * Used by integrators that hold their own ECDSA signer in localStorage\n * and produce signatures for an ERC-7579 validator other than the\n * passkey one (typically `@rhinestone/sdk` experimental SmartSession).\n *\n * Responsibilities:\n * - Fetch sponsorship JWTs from the app's own backend.\n * - Call `/api/intent/prepare?signingMode=headless` to get an\n * orchestrator-quoted `intentOp` + `digestResult`.\n * - Forward pre-encoded validator-prefixed signatures to the new\n * `/api/intent/headless-execute` route.\n * - Drive the existing passkey dialog (via {@link OneAuthClient}) for\n * the one-time SmartSession install ceremony.\n *\n * 1auth itself stays ignorant of session keys — the on-chain\n * SmartSession validator is the only authority over what a session key\n * may sign for. The host app persists `{ sessionKeyAddress, permissionId,\n * accountAddress, permissions }` in its own storage.\n */\n\nimport type {\n HeadlessIntentOptions,\n HeadlessIntentStatusResult,\n HeadlessPrepareResult,\n HeadlessSubmitOptions,\n HeadlessSubmitResult,\n InstallSmartSessionOptions,\n InstallSmartSessionResult,\n IntentTokenRequest,\n PasskeyProviderConfig,\n SponsorshipCallbackConfig,\n SponsorshipConfig,\n} from \"./types\";\nimport { tokenFetchError } from \"./sponsorship-fetch\";\n\nconst DEFAULT_PROVIDER_URL = \"https://passkey.1auth.app\";\n\nconst MISSING_APP_CREDENTIALS_MESSAGE =\n \"No sponsorship configured on OneAuthHeadlessClient. Every user intent must carry the app's JWT — pass `sponsorship: { accessToken, getExtensionToken }` (or URL form) to the constructor.\";\n\ntype AccessTokenFetchResult =\n | { ok: true; accessToken: string }\n | { ok: false; code?: \"MISSING_APP_CREDENTIALS\"; message: string };\n\ntype ExtensionTokenFetchResult =\n | { ok: true; extensionToken: string | undefined }\n | { ok: false; message: string };\n\n/**\n * Mirrors `normalizeSponsorship` in `client.ts`. Kept local so the\n * headless entry point doesn't pull in the whole OneAuthClient module\n * graph for callers that only need the headless surface.\n */\nfunction normalizeSponsorship(\n config: SponsorshipConfig | undefined,\n): SponsorshipCallbackConfig | null {\n if (!config) return null;\n if (\"accessToken\" in config && \"getExtensionToken\" in config) {\n return config;\n }\n const { accessTokenUrl, extensionTokenUrl } = config;\n return {\n accessToken: async () => {\n const response = await fetch(accessTokenUrl, { credentials: \"include\" });\n if (!response.ok) {\n throw await tokenFetchError(\"access token\", response);\n }\n const data = (await response.json()) as { token?: string };\n if (!data.token) {\n throw new Error(\"Access token response missing `token` field\");\n }\n return data.token;\n },\n getExtensionToken: async (intentOp: string) => {\n const response = await fetch(extensionTokenUrl, {\n method: \"POST\",\n credentials: \"include\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ intentOp }),\n });\n if (!response.ok) {\n throw await tokenFetchError(\"extension token\", response);\n }\n const data = (await response.json()) as { token?: string };\n if (!data.token) {\n throw new Error(\"Extension token response missing `token` field\");\n }\n return data.token;\n },\n };\n}\n\nexport class OneAuthHeadlessClient {\n private providerUrl: string;\n private clientId?: string;\n private sponsorship: SponsorshipCallbackConfig | null;\n\n constructor(config: PasskeyProviderConfig) {\n this.providerUrl = config.providerUrl || DEFAULT_PROVIDER_URL;\n this.clientId = config.clientId;\n this.sponsorship = normalizeSponsorship(config.sponsorship);\n }\n\n setSponsorship(sponsorship: SponsorshipConfig | undefined): void {\n this.sponsorship = normalizeSponsorship(sponsorship);\n }\n\n // ---------------------------------------------------------------------------\n // Sponsorship JWT fetchers\n // ---------------------------------------------------------------------------\n\n private async fetchAccessToken(): Promise<AccessTokenFetchResult> {\n if (!this.sponsorship) {\n return {\n ok: false,\n code: \"MISSING_APP_CREDENTIALS\",\n message: MISSING_APP_CREDENTIALS_MESSAGE,\n };\n }\n try {\n const accessToken = await this.sponsorship.accessToken();\n return { ok: true, accessToken };\n } catch (err) {\n return {\n ok: false,\n message: err instanceof Error ? err.message : String(err),\n };\n }\n }\n\n private async fetchExtensionToken(\n intentOp: string,\n sponsor: boolean,\n ): Promise<ExtensionTokenFetchResult> {\n if (!sponsor) return { ok: true, extensionToken: undefined };\n if (!this.sponsorship) {\n return { ok: false, message: MISSING_APP_CREDENTIALS_MESSAGE };\n }\n try {\n const token = await this.sponsorship.getExtensionToken(intentOp);\n return { ok: true, extensionToken: token };\n } catch (err) {\n return {\n ok: false,\n message: err instanceof Error ? err.message : String(err),\n };\n }\n }\n\n // ---------------------------------------------------------------------------\n // Intent prepare / submit\n // ---------------------------------------------------------------------------\n\n /**\n * Quote an intent without opening any dialog. Returns the orchestrator's\n * `intentOp` plus the digest the caller must sign with their own\n * validator (e.g. SmartSession). The caller is responsible for\n * encoding signatures and submitting via {@link submitIntent}.\n */\n async prepareIntent(options: HeadlessIntentOptions): Promise<HeadlessPrepareResult> {\n if (!options.username && !options.accountAddress) {\n throw new Error(\"prepareIntent requires either `username` or `accountAddress`\");\n }\n\n const accessTokenResult = await this.fetchAccessToken();\n if (!accessTokenResult.ok) {\n throw new Error(`Sponsorship access token fetch failed: ${accessTokenResult.message}`);\n }\n\n // bigint → string conversion for token requests; matches what the\n // dialog flow does before serializing requestBody.\n const tokenRequests = options.tokenRequests?.map((tr: IntentTokenRequest) => ({\n token: tr.token,\n amount: tr.amount.toString(),\n }));\n\n const body = {\n username: options.username,\n accountAddress: options.accountAddress,\n targetChain: options.targetChain,\n calls: options.calls,\n tokenRequests,\n sourceAssets: options.sourceAssets,\n sourceChainId: options.sourceChainId,\n sessionKeyHandle: options.sessionKeyHandle,\n clientId: this.clientId,\n signingMode: \"headless\" as const,\n auth: { accessToken: accessTokenResult.accessToken },\n };\n\n const response = await fetch(`${this.providerUrl}/api/intent/prepare`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({}))) as { error?: string };\n throw new Error(errorData.error || `Prepare failed (${response.status})`);\n }\n\n return (await response.json()) as HeadlessPrepareResult;\n }\n\n /**\n * Forward a pre-signed intent to the orchestrator. The caller has\n * already encoded validator-prefixed origin + destination signatures\n * (one origin signature per intent element); 1auth treats them as\n * opaque bytes.\n *\n * If `sponsor` is omitted or `true`, an extension token is fetched\n * just-in-time and bound to the intent. Pass `sponsor: false` for\n * self-paying intents.\n */\n async submitIntent(options: HeadlessSubmitOptions): Promise<HeadlessSubmitResult> {\n const sponsor = options.sponsor ?? true;\n const accessTokenResult = await this.fetchAccessToken();\n if (!accessTokenResult.ok) {\n throw new Error(`Sponsorship access token fetch failed: ${accessTokenResult.message}`);\n }\n\n const extensionResult = await this.fetchExtensionToken(options.intentOp, sponsor);\n if (!extensionResult.ok) {\n throw new Error(`Sponsorship extension token fetch failed: ${extensionResult.message}`);\n }\n\n const body = {\n intentOp: options.intentOp,\n accountAddress: options.accountAddress,\n targetChain: options.targetChain,\n calls: options.calls,\n expiresAt: options.expiresAt,\n originSignatures: options.originSignatures,\n destinationSignature: options.destinationSignature,\n targetExecutionSignature: options.targetExecutionSignature,\n auth: {\n accessToken: accessTokenResult.accessToken,\n ...(extensionResult.extensionToken && { extensionToken: extensionResult.extensionToken }),\n },\n };\n\n const response = await fetch(`${this.providerUrl}/api/intent/headless-execute`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({}))) as { error?: string };\n throw new Error(errorData.error || `Headless execute failed (${response.status})`);\n }\n\n return (await response.json()) as HeadlessSubmitResult;\n }\n\n // ---------------------------------------------------------------------------\n // Status / wait — proxies to the existing routes (no headless variant needed).\n // ---------------------------------------------------------------------------\n\n /**\n * Fetch the latest known status for a submitted headless intent.\n * This is a non-blocking read and may return `pending` before a\n * solver has produced a fill transaction hash.\n */\n async getIntentStatus(intentId: string): Promise<HeadlessIntentStatusResult> {\n const response = await fetch(`${this.providerUrl}/api/intent/status/${intentId}`);\n if (!response.ok) {\n throw new Error(`Status fetch failed (${response.status})`);\n }\n return (await response.json()) as HeadlessIntentStatusResult;\n }\n\n /**\n * Wait for a submitted headless intent to produce a status update and,\n * when available, the final fill transaction hash. The wait endpoint\n * needs the opaque `transactionResult` returned by submit because 1auth\n * does not persist that SDK object in its database.\n */\n async waitForIntent(\n intentId: string,\n transactionResult: unknown,\n ): Promise<HeadlessIntentStatusResult> {\n if (!transactionResult) {\n throw new Error(\"waitForIntent requires submitResult.transactionResult\");\n }\n\n const response = await fetch(`${this.providerUrl}/api/intent/wait/${intentId}`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ transactionResult }),\n });\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({}))) as {\n error?: string;\n details?: string;\n };\n throw new Error(\n errorData.details || errorData.error || `Wait fetch failed (${response.status})`,\n );\n }\n return (await response.json()) as HeadlessIntentStatusResult;\n }\n\n // ---------------------------------------------------------------------------\n // SmartSession install (one-time, passkey-signed)\n // ---------------------------------------------------------------------------\n\n /**\n * Resolve the SmartSession install call(s) for `sessionKeyAddress`\n * with the supplied `permissions`.\n *\n * Returns `{ install, sessionKeyHandle }`:\n *\n * - `install` is a `{ targetChain, calls }` pair the caller feeds\n * straight into `OneAuthClient.sendIntent({ targetChain, calls })`\n * so the user passkey-signs the install via the existing dialog.\n * - `sessionKeyHandle` contains the deterministic `permissionId`\n * plus metadata to persist in localStorage. Persist this BEFORE\n * submitting the install so a refresh during signing doesn't\n * lose the handle.\n *\n * If the validator is already installed on the user's account,\n * `install.calls` is empty and `install.alreadyInstalled` is true.\n * The caller should still persist `sessionKeyHandle` — the on-chain\n * session enabling happens at first headless use via SmartSession's\n * ENABLE-mode signature wrapping (see follow-up).\n */\n async installSmartSession(\n options: InstallSmartSessionOptions,\n ): Promise<InstallSmartSessionResult> {\n if (!options.username && !options.accountAddress) {\n throw new Error(\n \"installSmartSession requires either `username` or `accountAddress`\",\n );\n }\n\n const accessTokenResult = await this.fetchAccessToken();\n if (!accessTokenResult.ok) {\n throw new Error(\n `Sponsorship access token fetch failed: ${accessTokenResult.message}`,\n );\n }\n\n const body = {\n username: options.username,\n accountAddress: options.accountAddress,\n targetChain: options.targetChain,\n sessionKeyAddress: options.sessionKeyAddress,\n permissions: options.permissions,\n validUntil: options.validUntil,\n validAfter: options.validAfter,\n maxUses: options.maxUses,\n enableSessionSignature: options.enableSessionSignature,\n label: options.label,\n auth: { accessToken: accessTokenResult.accessToken },\n };\n\n const response = await fetch(`${this.providerUrl}/api/sessions/install`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n const errorData = (await response.json().catch(() => ({}))) as {\n error?: string;\n };\n throw new Error(errorData.error || `Install failed (${response.status})`);\n }\n\n return (await response.json()) as InstallSmartSessionResult;\n }\n}\n","import { type Address, type Hex } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport {\n createRhinestoneAccount,\n type Session,\n type SignData,\n type SignerSet,\n} from \"@rhinestone/sdk\";\nimport { toSession } from \"@rhinestone/sdk/smart-sessions\";\nimport { getChainById } from \"./registry\";\nimport type { HeadlessPrepareResult, SessionKeyHandle } from \"./types\";\n\n/** Restores bigint sentinel strings emitted by 1auth's JSON transport. */\nfunction reviveBigIntStrings<T>(value: T): T {\n if (Array.isArray(value)) return value.map((entry) => reviveBigIntStrings(entry)) as T;\n if (value && typeof value === \"object\") {\n return Object.fromEntries(\n Object.entries(value).map(([key, entry]) => [key, reviveBigIntStrings(entry)]),\n ) as T;\n }\n if (typeof value === \"string\" && value.startsWith(\"__bigint:\")) {\n return BigInt(value.slice(\"__bigint:\".length)) as T;\n }\n if (typeof value === \"string\" && /^\\d+$/.test(value)) return BigInt(value) as T;\n return value;\n}\n\n/** Parses the prepared transaction enough to recover the SDK-native SignData. */\nfunction parsePreparedSignData(value: string): SignData {\n const prepared = JSON.parse(value, (_key, nested) => reviveBigIntStrings(nested)) as {\n quotes?: { best?: { signData?: SignData } };\n };\n const signData = prepared.quotes?.best?.signData;\n if (!signData) {\n throw new Error(\"Prepared headless intent is missing quotes.best.signData\");\n }\n return signData;\n}\n\n/** Reads the numeric EIP-712 chain id from a typed-data domain. */\nfunction chainIdFromSignDataDomain(domainChainId: unknown): number | undefined {\n if (typeof domainChainId === \"number\" && Number.isSafeInteger(domainChainId)) {\n return domainChainId;\n }\n if (typeof domainChainId === \"bigint\") return Number(domainChainId);\n if (typeof domainChainId === \"string\" && /^\\d+$/.test(domainChainId)) {\n return Number(domainChainId);\n }\n return undefined;\n}\n\n/** Rebuilds the SDK SmartSession object from the persisted grant handle. */\nfunction buildSessionForChain(args: {\n privateKey: Hex;\n handle: SessionKeyHandle;\n chainId: number;\n}): Session {\n return toSession(\n {\n chain: getChainById(args.chainId),\n owners: { type: \"ecdsa\", accounts: [privateKeyToAccount(args.privateKey)] },\n permissions: reviveBigIntStrings(args.handle.permissions ?? []),\n crossChainPermits: reviveBigIntStrings(args.handle.crossChainPermits ?? []),\n },\n // The production SmartSession module is deployed on testnets too. Never opt\n // into SDK dev contracts for 1auth headless permissions.\n { useDevContracts: false },\n );\n}\n\n/** Builds a per-chain SmartSession signer set for every chain in SignData. */\nfunction buildSessionSigners(args: {\n privateKey: Hex;\n handle: SessionKeyHandle;\n prepared: HeadlessPrepareResult;\n signData: SignData;\n}): SignerSet {\n const chainIds = new Set<number>([args.prepared.targetChain]);\n for (const typedData of args.signData.origin) {\n const chainId = chainIdFromSignDataDomain(typedData.domain?.chainId);\n if (chainId) chainIds.add(chainId);\n }\n const targetExecutionChainId = chainIdFromSignDataDomain(\n args.signData.targetExecution?.domain?.chainId,\n );\n if (targetExecutionChainId) chainIds.add(targetExecutionChainId);\n\n return {\n type: \"experimental_session\",\n sessions: Object.fromEntries(\n [...chainIds].map((chainId) => [\n chainId,\n {\n session: buildSessionForChain({\n privateKey: args.privateKey,\n handle: args.handle,\n chainId,\n }),\n },\n ]),\n ),\n };\n}\n\nexport interface BuildSmartSessionHeadlessSignaturesOptions {\n /** ECDSA private key for the locally-held SmartSession signer. */\n privateKey: Hex;\n /** Smart account address the SmartSession is scoped to. */\n accountAddress: Address;\n /** Persisted handle returned by `grantPermissions` / SmartSession install. */\n sessionKeyHandle: SessionKeyHandle;\n /** Prepared headless intent returned by `OneAuthHeadlessClient.prepareIntent`. */\n prepared: HeadlessPrepareResult;\n}\n\n/**\n * Builds SmartSession signatures for `OneAuthHeadlessClient.submitIntent`.\n *\n * This intentionally delegates signing and SmartSession signature packing to\n * `@rhinestone/sdk`. 1auth only rebuilds the persisted session descriptor and\n * supplies the SDK-native `SignData` returned by the orchestrator quote.\n */\nexport async function buildSmartSessionHeadlessSignatures(\n options: BuildSmartSessionHeadlessSignaturesOptions,\n) {\n const signData = parsePreparedSignData(options.prepared.intentOp);\n const account = await createRhinestoneAccount({\n initData: { address: options.accountAddress },\n owners: {\n type: \"ecdsa\",\n accounts: [privateKeyToAccount(options.privateKey)],\n },\n experimental_sessions: { enabled: true },\n });\n\n return account.signIntent(\n signData,\n getChainById(options.prepared.targetChain),\n buildSessionSigners({\n privateKey: options.privateKey,\n handle: options.sessionKeyHandle,\n prepared: options.prepared,\n signData,\n }),\n );\n}\n"],"mappings":";;;;;;;;AAqCA,IAAM,uBAAuB;AAE7B,IAAM,kCACJ;AAeF,SAAS,qBACP,QACkC;AAClC,MAAI,CAAC,OAAQ,QAAO;AACpB,MAAI,iBAAiB,UAAU,uBAAuB,QAAQ;AAC5D,WAAO;AAAA,EACT;AACA,QAAM,EAAE,gBAAgB,kBAAkB,IAAI;AAC9C,SAAO;AAAA,IACL,aAAa,YAAY;AACvB,YAAM,WAAW,MAAM,MAAM,gBAAgB,EAAE,aAAa,UAAU,CAAC;AACvE,UAAI,CAAC,SAAS,IAAI;AAChB,cAAM,MAAM,gBAAgB,gBAAgB,QAAQ;AAAA,MACtD;AACA,YAAM,OAAQ,MAAM,SAAS,KAAK;AAClC,UAAI,CAAC,KAAK,OAAO;AACf,cAAM,IAAI,MAAM,6CAA6C;AAAA,MAC/D;AACA,aAAO,KAAK;AAAA,IACd;AAAA,IACA,mBAAmB,OAAO,aAAqB;AAC7C,YAAM,WAAW,MAAM,MAAM,mBAAmB;AAAA,QAC9C,QAAQ;AAAA,QACR,aAAa;AAAA,QACb,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,QAC9C,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,iBAAiB,QAAQ;AAAA,EACzC;AACA,MAAI,uBAAwB,UAAS,IAAI,sBAAsB;AAE/D,SAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU,OAAO;AAAA,MACf,CAAC,GAAG,QAAQ,EAAE,IAAI,CAAC,YAAY;AAAA,QAC7B;AAAA,QACA;AAAA,UACE,SAAS,qBAAqB;AAAA,YAC5B,YAAY,KAAK;AAAA,YACjB,QAAQ,KAAK;AAAA,YACb;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAoBA,eAAsB,oCACpB,SACA;AACA,QAAM,WAAW,sBAAsB,QAAQ,SAAS,QAAQ;AAChE,QAAM,UAAU,MAAM,wBAAwB;AAAA,IAC5C,UAAU,EAAE,SAAS,QAAQ,eAAe;AAAA,IAC5C,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU,CAAC,oBAAoB,QAAQ,UAAU,CAAC;AAAA,IACpD;AAAA,IACA,uBAAuB,EAAE,SAAS,KAAK;AAAA,EACzC,CAAC;AAED,SAAO,QAAQ;AAAA,IACb;AAAA,IACA,aAAa,QAAQ,SAAS,WAAW;AAAA,IACzC,oBAAoB;AAAA,MAClB,YAAY,QAAQ;AAAA,MACpB,QAAQ,QAAQ;AAAA,MAChB,UAAU,QAAQ;AAAA,MAClB;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
package/dist/index.d.mts CHANGED
@@ -1,12 +1,12 @@
1
- import { O as OneAuthClient } from './client-F4DnFM8d.mjs';
2
- import { Abi, Address, LocalAccount, WalletClient, Hash, Chain } from 'viem';
1
+ import { O as OneAuthClient } from './client-DvtGr2xn.mjs';
2
+ import { Abi, Address, LocalAccount, WalletClient, Hash } from 'viem';
3
3
  import { Permission } from '@rhinestone/sdk';
4
4
  export { Permission } from '@rhinestone/sdk';
5
- import { h as IntentCall, i as SendIntentResult } from './types-U_dwxbtS.mjs';
6
- export { a7 as AssetBalance, a8 as AssetBalanceBucket, a9 as AssetsResponse, u as AuthFlow, A as AuthResult, v as AuthWithModalOptions, z as AuthenticateOptions, B as AuthenticateResult, R as BalanceRequirement, ap as BatchIntentItem, as as BatchIntentItemResult, ad as CheckConsentOptions, ae as CheckConsentResult, a0 as CloseOnStatus, y as ConnectResult, ac as ConsentData, ab as ConsentField, w as CreateAccountWithModalOptions, C as CreateCrossChainPermissionInput, r as CreateSigningRequestResponse, k as CrossChainPermit, l as CrossChainSettlementLayer, M as EIP712Domain, O as EIP712TypeField, N as EIP712Types, E as EmbedOptions, a2 as ExecuteIntentResponse, a6 as GetAssetsOptions, an as GrantPermissionContractMetadata, ah as GrantPermissionsOptions, ai as GrantPermissionsResult, a4 as IntentHistoryItem, a3 as IntentHistoryOptions, a5 as IntentHistoryResult, Z as IntentQuote, _ as IntentStatus, X as IntentTokenRequest, aj as ListSessionGrantsOptions, ak as ListSessionGrantsResult, L as LoginWithModalOptions, ax as OneAuthTelemetryAttributeValue, ay as OneAuthTelemetryAttributes, az as OneAuthTelemetryConfig, aA as OneAuthTelemetryEvent, aB as OneAuthTelemetryEventName, aC as OneAuthTelemetryFlow, aD as OneAuthTelemetryTraceContext, $ as OrchestratorStatus, t as PasskeyCredential, P as PasskeyProviderConfig, au as PrepareBatchIntentResponse, a1 as PrepareIntentResponse, at as PreparedBatchIntent, af as RequestConsentOptions, ag as RequestConsentResult, aq as SendBatchIntentOptions, ar as SendBatchIntentResult, Y as SendIntentOptions, am as SessionGrantChain, al as SessionGrantRecord, F as SignMessageOptions, G as SignMessageResult, J as SignTypedDataOptions, K as SignTypedDataResult, x as SignerType, p as SigningError, q as SigningErrorCode, m as SigningRequestOptions, s as SigningRequestStatus, n as SigningResult, D as SigningResultBase, o as SigningSuccess, ao as SmartSessionPolicy, av as SponsorshipCallbackConfig, S as SponsorshipConfig, aw as SponsorshipUrlConfig, aa as ThemeConfig, T as TransactionAction, V as TransactionDetails, Q as TransactionFees, U as UserPasskeysResponse, W as WebAuthnSignature, j as createCrossChainPermission } from './types-U_dwxbtS.mjs';
7
- export { O as OneAuthProvider, a as OneAuthProviderOptions, c as createOneAuthProvider } from './provider-IvYXPMpk.mjs';
8
- import { P as PasskeyWalletClientConfig, S as SendCallsParams } from './verify-C8-a5c3K.mjs';
9
- export { E as ETHEREUM_MESSAGE_PREFIX, T as TransactionCall, e as encodeWebAuthnSignature, h as hashCalls, a as hashMessage, v as verifyMessageHash } from './verify-C8-a5c3K.mjs';
5
+ import { h as IntentCall, i as SendIntentResult } from './types-C0jKNT_t.mjs';
6
+ export { a7 as AssetBalance, a8 as AssetBalanceBucket, a9 as AssetsResponse, u as AuthFlow, A as AuthResult, v as AuthWithModalOptions, z as AuthenticateOptions, B as AuthenticateResult, R as BalanceRequirement, ap as BatchIntentItem, as as BatchIntentItemResult, ad as CheckConsentOptions, ae as CheckConsentResult, a0 as CloseOnStatus, y as ConnectResult, ac as ConsentData, ab as ConsentField, w as CreateAccountWithModalOptions, C as CreateCrossChainPermissionInput, r as CreateSigningRequestResponse, k as CrossChainPermit, l as CrossChainSettlementLayer, M as EIP712Domain, O as EIP712TypeField, N as EIP712Types, E as EmbedOptions, a2 as ExecuteIntentResponse, a6 as GetAssetsOptions, an as GrantPermissionContractMetadata, ah as GrantPermissionsOptions, ai as GrantPermissionsResult, a4 as IntentHistoryItem, a3 as IntentHistoryOptions, a5 as IntentHistoryResult, Z as IntentQuote, _ as IntentStatus, X as IntentTokenRequest, aj as ListSessionGrantsOptions, ak as ListSessionGrantsResult, L as LoginWithModalOptions, ax as OneAuthTelemetryAttributeValue, ay as OneAuthTelemetryAttributes, az as OneAuthTelemetryConfig, aA as OneAuthTelemetryEvent, aB as OneAuthTelemetryEventName, aC as OneAuthTelemetryFlow, aD as OneAuthTelemetryTraceContext, $ as OrchestratorStatus, t as PasskeyCredential, P as PasskeyProviderConfig, au as PrepareBatchIntentResponse, a1 as PrepareIntentResponse, at as PreparedBatchIntent, af as RequestConsentOptions, ag as RequestConsentResult, aq as SendBatchIntentOptions, ar as SendBatchIntentResult, Y as SendIntentOptions, am as SessionGrantChain, al as SessionGrantRecord, F as SignMessageOptions, G as SignMessageResult, J as SignTypedDataOptions, K as SignTypedDataResult, x as SignerType, p as SigningError, q as SigningErrorCode, m as SigningRequestOptions, s as SigningRequestStatus, n as SigningResult, D as SigningResultBase, o as SigningSuccess, ao as SmartSessionPolicy, av as SponsorshipCallbackConfig, S as SponsorshipConfig, aw as SponsorshipUrlConfig, aa as ThemeConfig, T as TransactionAction, V as TransactionDetails, Q as TransactionFees, U as UserPasskeysResponse, W as WebAuthnSignature, j as createCrossChainPermission } from './types-C0jKNT_t.mjs';
7
+ export { O as OneAuthProvider, a as OneAuthProviderOptions, c as createOneAuthProvider } from './provider-NYl0jlHw.mjs';
8
+ import { P as PasskeyWalletClientConfig, S as SendCallsParams } from './verify-aWdi5O2z.mjs';
9
+ export { C as ChainFilterOptions, E as ETHEREUM_MESSAGE_PREFIX, p as TokenConfig, T as TransactionCall, e as encodeWebAuthnSignature, b as getAllSupportedChainsAndTokens, f as getChainById, i as getChainExplorerUrl, j as getChainRpcUrl, g as getSupportedChainIds, a as getSupportedChains, d as getSupportedTokenSymbols, c as getSupportedTokens, l as getTokenAddress, n as getTokenDecimals, m as getTokenSymbol, h as hashCalls, q as hashMessage, k as isTestnet, o as isTokenAddressSupported, r as resolveTokenAddress, v as verifyMessageHash } from './verify-aWdi5O2z.mjs';
10
10
  import * as react_jsx_runtime from 'react/jsx-runtime';
11
11
  import * as React from 'react';
12
12
 
@@ -160,7 +160,7 @@ type PasskeyWalletClient = WalletClient & {
160
160
  * const walletClient = createPasskeyWalletClient({
161
161
  * accountAddress: '0x...',
162
162
  * username: 'alice',
163
- * providerUrl: 'https://passkey.1auth.box',
163
+ * providerUrl: 'https://passkey.1auth.app',
164
164
  * clientId: 'my-dapp',
165
165
  * chain: baseSepolia,
166
166
  * transport: http(),
@@ -289,45 +289,4 @@ interface BatchQueueWidgetProps {
289
289
  */
290
290
  declare function BatchQueueWidget({ onSignAll }: BatchQueueWidgetProps): react_jsx_runtime.JSX.Element | null;
291
291
 
292
- /**
293
- * @file Chain and token registry for the 1auth SDK.
294
- *
295
- * Wraps `@rhinestone/shared-configs` chain/token data and combines it with
296
- * viem's chain definitions to expose a filtered, testnet-aware registry.
297
- * Consumers can look up supported chains and tokens, resolve token addresses
298
- * by symbol, and retrieve chain metadata such as explorer URLs and default RPC
299
- * endpoints.
300
- *
301
- * Testnet inclusion is controlled by the `includeTestnets` option on each
302
- * function or, as a project-wide default, by the environment variables
303
- * `NEXT_PUBLIC_ORCHESTRATOR_USE_TESTNETS` or `ORCHESTRATOR_USE_TESTNETS`.
304
- */
305
-
306
- type TokenConfig = {
307
- symbol: string;
308
- address: Address;
309
- decimals: number;
310
- };
311
- type ChainFilterOptions = {
312
- includeTestnets?: boolean;
313
- chainIds?: number[];
314
- };
315
- declare function getSupportedChainIds(options?: ChainFilterOptions): number[];
316
- declare function getSupportedChains(options?: ChainFilterOptions): Chain[];
317
- declare function getAllSupportedChainsAndTokens(options?: ChainFilterOptions): Array<{
318
- chainId: number;
319
- tokens: TokenConfig[];
320
- }>;
321
- declare function getChainById(chainId: number): Chain;
322
- declare function getChainExplorerUrl(chainId: number): string | undefined;
323
- declare function getChainRpcUrl(chainId: number): string | undefined;
324
- declare function getSupportedTokens(chainId: number): TokenConfig[];
325
- declare function getSupportedTokenSymbols(chainId: number): string[];
326
- declare function getTokenAddress(symbolOrAddress: string, chainId: number): Address;
327
- declare function getTokenDecimals(symbolOrAddress: string, chainId: number): number;
328
- declare function resolveTokenAddress(token: string, chainId: number): Address;
329
- declare function isTestnet(chainId: number): boolean;
330
- declare function getTokenSymbol(tokenAddress: Address, chainId: number): string;
331
- declare function isTokenAddressSupported(tokenAddress: Address, chainId: number): boolean;
332
-
333
- export { type BatchQueueContextValue, type BatchQueueIdentity, BatchQueueProvider, type BatchQueueProviderProps, BatchQueueWidget, type BatchQueueWidgetProps, type BatchedCall, type ChainFilterOptions, type DefinePermissionsConfig, type DefinedPermissions, IntentCall, OneAuthClient, type PasskeyAccount, type PasskeyWalletClient, PasskeyWalletClientConfig, SendCallsParams, SendIntentResult, type TokenConfig, createPasskeyAccount, createPasskeyWalletClient, definePermissions, getAllSupportedChainsAndTokens, getChainById, getChainExplorerUrl, getChainName, getChainRpcUrl, getSupportedChainIds, getSupportedChains, getSupportedTokenSymbols, getSupportedTokens, getTokenAddress, getTokenDecimals, getTokenSymbol, isTestnet, isTokenAddressSupported, resolveTokenAddress, useBatchQueue };
292
+ export { type BatchQueueContextValue, type BatchQueueIdentity, BatchQueueProvider, type BatchQueueProviderProps, BatchQueueWidget, type BatchQueueWidgetProps, type BatchedCall, type DefinePermissionsConfig, type DefinedPermissions, IntentCall, OneAuthClient, type PasskeyAccount, type PasskeyWalletClient, PasskeyWalletClientConfig, SendCallsParams, SendIntentResult, createPasskeyAccount, createPasskeyWalletClient, definePermissions, getChainName, useBatchQueue };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { O as OneAuthClient } from './client-B_CzDa_I.js';
2
- import { Abi, Address, LocalAccount, WalletClient, Hash, Chain } from 'viem';
1
+ import { O as OneAuthClient } from './client-Ewr_7x-d.js';
2
+ import { Abi, Address, LocalAccount, WalletClient, Hash } from 'viem';
3
3
  import { Permission } from '@rhinestone/sdk';
4
4
  export { Permission } from '@rhinestone/sdk';
5
- import { h as IntentCall, i as SendIntentResult } from './types-U_dwxbtS.js';
6
- export { a7 as AssetBalance, a8 as AssetBalanceBucket, a9 as AssetsResponse, u as AuthFlow, A as AuthResult, v as AuthWithModalOptions, z as AuthenticateOptions, B as AuthenticateResult, R as BalanceRequirement, ap as BatchIntentItem, as as BatchIntentItemResult, ad as CheckConsentOptions, ae as CheckConsentResult, a0 as CloseOnStatus, y as ConnectResult, ac as ConsentData, ab as ConsentField, w as CreateAccountWithModalOptions, C as CreateCrossChainPermissionInput, r as CreateSigningRequestResponse, k as CrossChainPermit, l as CrossChainSettlementLayer, M as EIP712Domain, O as EIP712TypeField, N as EIP712Types, E as EmbedOptions, a2 as ExecuteIntentResponse, a6 as GetAssetsOptions, an as GrantPermissionContractMetadata, ah as GrantPermissionsOptions, ai as GrantPermissionsResult, a4 as IntentHistoryItem, a3 as IntentHistoryOptions, a5 as IntentHistoryResult, Z as IntentQuote, _ as IntentStatus, X as IntentTokenRequest, aj as ListSessionGrantsOptions, ak as ListSessionGrantsResult, L as LoginWithModalOptions, ax as OneAuthTelemetryAttributeValue, ay as OneAuthTelemetryAttributes, az as OneAuthTelemetryConfig, aA as OneAuthTelemetryEvent, aB as OneAuthTelemetryEventName, aC as OneAuthTelemetryFlow, aD as OneAuthTelemetryTraceContext, $ as OrchestratorStatus, t as PasskeyCredential, P as PasskeyProviderConfig, au as PrepareBatchIntentResponse, a1 as PrepareIntentResponse, at as PreparedBatchIntent, af as RequestConsentOptions, ag as RequestConsentResult, aq as SendBatchIntentOptions, ar as SendBatchIntentResult, Y as SendIntentOptions, am as SessionGrantChain, al as SessionGrantRecord, F as SignMessageOptions, G as SignMessageResult, J as SignTypedDataOptions, K as SignTypedDataResult, x as SignerType, p as SigningError, q as SigningErrorCode, m as SigningRequestOptions, s as SigningRequestStatus, n as SigningResult, D as SigningResultBase, o as SigningSuccess, ao as SmartSessionPolicy, av as SponsorshipCallbackConfig, S as SponsorshipConfig, aw as SponsorshipUrlConfig, aa as ThemeConfig, T as TransactionAction, V as TransactionDetails, Q as TransactionFees, U as UserPasskeysResponse, W as WebAuthnSignature, j as createCrossChainPermission } from './types-U_dwxbtS.js';
7
- export { O as OneAuthProvider, a as OneAuthProviderOptions, c as createOneAuthProvider } from './provider-Cd7Ip5L-.js';
8
- import { P as PasskeyWalletClientConfig, S as SendCallsParams } from './verify-BLgZzwmJ.js';
9
- export { E as ETHEREUM_MESSAGE_PREFIX, T as TransactionCall, e as encodeWebAuthnSignature, h as hashCalls, a as hashMessage, v as verifyMessageHash } from './verify-BLgZzwmJ.js';
5
+ import { h as IntentCall, i as SendIntentResult } from './types-C0jKNT_t.js';
6
+ export { a7 as AssetBalance, a8 as AssetBalanceBucket, a9 as AssetsResponse, u as AuthFlow, A as AuthResult, v as AuthWithModalOptions, z as AuthenticateOptions, B as AuthenticateResult, R as BalanceRequirement, ap as BatchIntentItem, as as BatchIntentItemResult, ad as CheckConsentOptions, ae as CheckConsentResult, a0 as CloseOnStatus, y as ConnectResult, ac as ConsentData, ab as ConsentField, w as CreateAccountWithModalOptions, C as CreateCrossChainPermissionInput, r as CreateSigningRequestResponse, k as CrossChainPermit, l as CrossChainSettlementLayer, M as EIP712Domain, O as EIP712TypeField, N as EIP712Types, E as EmbedOptions, a2 as ExecuteIntentResponse, a6 as GetAssetsOptions, an as GrantPermissionContractMetadata, ah as GrantPermissionsOptions, ai as GrantPermissionsResult, a4 as IntentHistoryItem, a3 as IntentHistoryOptions, a5 as IntentHistoryResult, Z as IntentQuote, _ as IntentStatus, X as IntentTokenRequest, aj as ListSessionGrantsOptions, ak as ListSessionGrantsResult, L as LoginWithModalOptions, ax as OneAuthTelemetryAttributeValue, ay as OneAuthTelemetryAttributes, az as OneAuthTelemetryConfig, aA as OneAuthTelemetryEvent, aB as OneAuthTelemetryEventName, aC as OneAuthTelemetryFlow, aD as OneAuthTelemetryTraceContext, $ as OrchestratorStatus, t as PasskeyCredential, P as PasskeyProviderConfig, au as PrepareBatchIntentResponse, a1 as PrepareIntentResponse, at as PreparedBatchIntent, af as RequestConsentOptions, ag as RequestConsentResult, aq as SendBatchIntentOptions, ar as SendBatchIntentResult, Y as SendIntentOptions, am as SessionGrantChain, al as SessionGrantRecord, F as SignMessageOptions, G as SignMessageResult, J as SignTypedDataOptions, K as SignTypedDataResult, x as SignerType, p as SigningError, q as SigningErrorCode, m as SigningRequestOptions, s as SigningRequestStatus, n as SigningResult, D as SigningResultBase, o as SigningSuccess, ao as SmartSessionPolicy, av as SponsorshipCallbackConfig, S as SponsorshipConfig, aw as SponsorshipUrlConfig, aa as ThemeConfig, T as TransactionAction, V as TransactionDetails, Q as TransactionFees, U as UserPasskeysResponse, W as WebAuthnSignature, j as createCrossChainPermission } from './types-C0jKNT_t.js';
7
+ export { O as OneAuthProvider, a as OneAuthProviderOptions, c as createOneAuthProvider } from './provider-BRHZoB8U.js';
8
+ import { P as PasskeyWalletClientConfig, S as SendCallsParams } from './verify-CnOwPq78.js';
9
+ export { C as ChainFilterOptions, E as ETHEREUM_MESSAGE_PREFIX, p as TokenConfig, T as TransactionCall, e as encodeWebAuthnSignature, b as getAllSupportedChainsAndTokens, f as getChainById, i as getChainExplorerUrl, j as getChainRpcUrl, g as getSupportedChainIds, a as getSupportedChains, d as getSupportedTokenSymbols, c as getSupportedTokens, l as getTokenAddress, n as getTokenDecimals, m as getTokenSymbol, h as hashCalls, q as hashMessage, k as isTestnet, o as isTokenAddressSupported, r as resolveTokenAddress, v as verifyMessageHash } from './verify-CnOwPq78.js';
10
10
  import * as react_jsx_runtime from 'react/jsx-runtime';
11
11
  import * as React from 'react';
12
12
 
@@ -160,7 +160,7 @@ type PasskeyWalletClient = WalletClient & {
160
160
  * const walletClient = createPasskeyWalletClient({
161
161
  * accountAddress: '0x...',
162
162
  * username: 'alice',
163
- * providerUrl: 'https://passkey.1auth.box',
163
+ * providerUrl: 'https://passkey.1auth.app',
164
164
  * clientId: 'my-dapp',
165
165
  * chain: baseSepolia,
166
166
  * transport: http(),
@@ -289,45 +289,4 @@ interface BatchQueueWidgetProps {
289
289
  */
290
290
  declare function BatchQueueWidget({ onSignAll }: BatchQueueWidgetProps): react_jsx_runtime.JSX.Element | null;
291
291
 
292
- /**
293
- * @file Chain and token registry for the 1auth SDK.
294
- *
295
- * Wraps `@rhinestone/shared-configs` chain/token data and combines it with
296
- * viem's chain definitions to expose a filtered, testnet-aware registry.
297
- * Consumers can look up supported chains and tokens, resolve token addresses
298
- * by symbol, and retrieve chain metadata such as explorer URLs and default RPC
299
- * endpoints.
300
- *
301
- * Testnet inclusion is controlled by the `includeTestnets` option on each
302
- * function or, as a project-wide default, by the environment variables
303
- * `NEXT_PUBLIC_ORCHESTRATOR_USE_TESTNETS` or `ORCHESTRATOR_USE_TESTNETS`.
304
- */
305
-
306
- type TokenConfig = {
307
- symbol: string;
308
- address: Address;
309
- decimals: number;
310
- };
311
- type ChainFilterOptions = {
312
- includeTestnets?: boolean;
313
- chainIds?: number[];
314
- };
315
- declare function getSupportedChainIds(options?: ChainFilterOptions): number[];
316
- declare function getSupportedChains(options?: ChainFilterOptions): Chain[];
317
- declare function getAllSupportedChainsAndTokens(options?: ChainFilterOptions): Array<{
318
- chainId: number;
319
- tokens: TokenConfig[];
320
- }>;
321
- declare function getChainById(chainId: number): Chain;
322
- declare function getChainExplorerUrl(chainId: number): string | undefined;
323
- declare function getChainRpcUrl(chainId: number): string | undefined;
324
- declare function getSupportedTokens(chainId: number): TokenConfig[];
325
- declare function getSupportedTokenSymbols(chainId: number): string[];
326
- declare function getTokenAddress(symbolOrAddress: string, chainId: number): Address;
327
- declare function getTokenDecimals(symbolOrAddress: string, chainId: number): number;
328
- declare function resolveTokenAddress(token: string, chainId: number): Address;
329
- declare function isTestnet(chainId: number): boolean;
330
- declare function getTokenSymbol(tokenAddress: Address, chainId: number): string;
331
- declare function isTokenAddressSupported(tokenAddress: Address, chainId: number): boolean;
332
-
333
- export { type BatchQueueContextValue, type BatchQueueIdentity, BatchQueueProvider, type BatchQueueProviderProps, BatchQueueWidget, type BatchQueueWidgetProps, type BatchedCall, type ChainFilterOptions, type DefinePermissionsConfig, type DefinedPermissions, IntentCall, OneAuthClient, type PasskeyAccount, type PasskeyWalletClient, PasskeyWalletClientConfig, SendCallsParams, SendIntentResult, type TokenConfig, createPasskeyAccount, createPasskeyWalletClient, definePermissions, getAllSupportedChainsAndTokens, getChainById, getChainExplorerUrl, getChainName, getChainRpcUrl, getSupportedChainIds, getSupportedChains, getSupportedTokenSymbols, getSupportedTokens, getTokenAddress, getTokenDecimals, getTokenSymbol, isTestnet, isTokenAddressSupported, resolveTokenAddress, useBatchQueue };
292
+ export { type BatchQueueContextValue, type BatchQueueIdentity, BatchQueueProvider, type BatchQueueProviderProps, BatchQueueWidget, type BatchQueueWidgetProps, type BatchedCall, type DefinePermissionsConfig, type DefinedPermissions, IntentCall, OneAuthClient, type PasskeyAccount, type PasskeyWalletClient, PasskeyWalletClientConfig, SendCallsParams, SendIntentResult, createPasskeyAccount, createPasskeyWalletClient, definePermissions, getChainName, useBatchQueue };
package/dist/index.js CHANGED
@@ -378,7 +378,7 @@ var POPUP_WIDTH = LOADING_MODAL_WIDTH;
378
378
  var POPUP_HEIGHT = 600;
379
379
  var DEFAULT_EMBED_WIDTH = `${LOADING_MODAL_WIDTH}px`;
380
380
  var DEFAULT_EMBED_HEIGHT = "500px";
381
- var DEFAULT_PROVIDER_URL = "https://passkey.1auth.box";
381
+ var DEFAULT_PROVIDER_URL = "https://passkey.1auth.app";
382
382
  function currentWindowOrigin() {
383
383
  if (typeof window === "undefined") return null;
384
384
  const origin = window.location?.origin;
@@ -834,7 +834,7 @@ var OneAuthClient = class {
834
834
  * Falls back to the raw dialog URL string if URL parsing fails (e.g. during
835
835
  * unit tests with non-standard URL formats).
836
836
  *
837
- * @returns The scheme + host + optional port of the dialog app (e.g. `"https://passkey.1auth.box"`).
837
+ * @returns The scheme + host + optional port of the dialog app (e.g. `"https://passkey.1auth.app"`).
838
838
  */
839
839
  getDialogOrigin() {
840
840
  const dialogUrl = this.getDialogUrl();
@@ -1885,7 +1885,7 @@ var OneAuthClient = class {
1885
1885
  };
1886
1886
  const handleMessage = (event) => {
1887
1887
  if (event.origin !== dialogOrigin) return;
1888
- if (event.data?.type === "PASSKEY_CLOSE") {
1888
+ if (event.data?.type === "PASSKEY_CLOSE" && event.source === iframe.contentWindow) {
1889
1889
  resolveClosed(iframeReadyObserved);
1890
1890
  }
1891
1891
  };
@@ -2584,7 +2584,7 @@ var OneAuthClient = class {
2584
2584
  const dialogOrigin2 = this.getDialogOrigin();
2585
2585
  const earlyCloseHandler = (event) => {
2586
2586
  if (event.origin !== dialogOrigin2) return;
2587
- if (event.data?.type === "PASSKEY_CLOSE") {
2587
+ if (event.data?.type === "PASSKEY_CLOSE" && event.source === iframe.contentWindow) {
2588
2588
  userClosedEarly = true;
2589
2589
  cleanup();
2590
2590
  }