@rhinestone/1auth 0.6.8 → 0.6.9

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.
Files changed (49) hide show
  1. package/README.md +171 -12
  2. package/dist/chunk-IHBVEU33.mjs +20 -0
  3. package/dist/chunk-IHBVEU33.mjs.map +1 -0
  4. package/dist/chunk-IIACVHR3.mjs +28 -0
  5. package/dist/chunk-IIACVHR3.mjs.map +1 -0
  6. package/dist/chunk-N6KE5CII.mjs +72 -0
  7. package/dist/chunk-N6KE5CII.mjs.map +1 -0
  8. package/dist/{chunk-SXISYG2P.mjs → chunk-VZYHCFEH.mjs} +195 -140
  9. package/dist/chunk-VZYHCFEH.mjs.map +1 -0
  10. package/dist/{client-BrMrhetG.d.mts → client-BNluVe4_.d.ts} +305 -849
  11. package/dist/{client-BrMrhetG.d.ts → client-CLCdahyj.d.mts} +305 -849
  12. package/dist/headless.d.mts +90 -0
  13. package/dist/headless.d.ts +90 -0
  14. package/dist/headless.js +327 -0
  15. package/dist/headless.js.map +1 -0
  16. package/dist/headless.mjs +280 -0
  17. package/dist/headless.mjs.map +1 -0
  18. package/dist/index.d.mts +96 -144
  19. package/dist/index.d.ts +96 -144
  20. package/dist/index.js +2984 -718
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +2740 -627
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/{provider-CDl9wYEc.d.mts → provider-BgD9PeDX.d.ts} +6 -5
  25. package/dist/{provider-Dgv533YQ.d.ts → provider-hxHGb6SX.d.mts} +6 -5
  26. package/dist/react.d.mts +42 -2
  27. package/dist/react.d.ts +42 -2
  28. package/dist/react.js +92 -2
  29. package/dist/react.js.map +1 -1
  30. package/dist/react.mjs +66 -1
  31. package/dist/react.mjs.map +1 -1
  32. package/dist/server.d.mts +118 -0
  33. package/dist/server.d.ts +118 -0
  34. package/dist/server.js +356 -0
  35. package/dist/server.js.map +1 -0
  36. package/dist/server.mjs +282 -0
  37. package/dist/server.mjs.map +1 -0
  38. package/dist/types-1BMD1PSH.d.mts +1425 -0
  39. package/dist/types-1BMD1PSH.d.ts +1425 -0
  40. package/dist/verify-CZe-m_Vf.d.ts +150 -0
  41. package/dist/verify-D3FaLeAi.d.mts +150 -0
  42. package/dist/wagmi.d.mts +5 -2
  43. package/dist/wagmi.d.ts +5 -2
  44. package/dist/wagmi.js +138 -43
  45. package/dist/wagmi.js.map +1 -1
  46. package/dist/wagmi.mjs +2 -1
  47. package/dist/wagmi.mjs.map +1 -1
  48. package/package.json +15 -2
  49. package/dist/chunk-SXISYG2P.mjs.map +0 -1
@@ -0,0 +1,1425 @@
1
+ import { Chain, Address, Abi } from 'viem';
2
+ import { Permission, OriginSignature } from '@rhinestone/sdk';
3
+
4
+ type CrossChainSettlementLayer = "SAME_CHAIN" | "ECO" | "ACROSS";
5
+ interface CrossChainPermit {
6
+ /** Allowed source legs: chain + token, with an optional amount cap. */
7
+ from: Array<{
8
+ chain: Chain;
9
+ token: Address;
10
+ maxAmount?: bigint;
11
+ }>;
12
+ /** Allowed destination legs: chain + token, with an optional recipient pin. */
13
+ to: Array<{
14
+ chain: Chain;
15
+ token: Address;
16
+ recipient?: Address | "any";
17
+ }>;
18
+ /** Upper bound on the Permit2 deadline, expressed as Unix seconds. */
19
+ validUntil?: bigint;
20
+ /** Lower bound on the Permit2 deadline, expressed as Unix seconds. */
21
+ validAfter?: bigint;
22
+ /** Per-destination fill-deadline windows, expressed as Unix seconds. */
23
+ fillDeadline?: Array<{
24
+ chain: Chain;
25
+ min?: bigint;
26
+ max?: bigint;
27
+ }>;
28
+ /** When true, the destination recipient must be the smart account. */
29
+ recipientIsAccount?: boolean;
30
+ /** Allowed settlement layers. Omit or pass an empty array to allow any supported layer. */
31
+ settlementLayers?: CrossChainSettlementLayer[];
32
+ }
33
+ interface FromLeg {
34
+ chain: Chain;
35
+ token: Address | string;
36
+ maxAmount?: bigint;
37
+ }
38
+ interface ToLeg {
39
+ chain: Chain;
40
+ token: Address | string;
41
+ recipient?: Address | "any";
42
+ }
43
+ interface CreateCrossChainPermissionInput {
44
+ /** Source chain + token, with an optional amount cap. Pass an array for multi-leg permits. */
45
+ from: FromLeg | FromLeg[];
46
+ /** Destination chain + token, with an optional recipient pin. Pass an array for fan-out destinations. */
47
+ to: ToLeg | ToLeg[];
48
+ /** Upper bound on the Permit2 deadline. Accepts Unix-seconds bigint or Date. */
49
+ validUntil?: bigint | Date;
50
+ /** Lower bound on the Permit2 deadline. Accepts Unix-seconds bigint or Date. */
51
+ validAfter?: bigint | Date;
52
+ /** Per-destination fill-deadline windows, expressed as Unix seconds. */
53
+ fillDeadline?: Array<{
54
+ chain: Chain;
55
+ min?: bigint;
56
+ max?: bigint;
57
+ }>;
58
+ /**
59
+ * Allow the destination recipient to differ from the smart account.
60
+ * Defaults to false so bridge permissions are bridge-to-self unless the
61
+ * caller explicitly broadens the grant.
62
+ */
63
+ allowRecipientNotAccount?: boolean;
64
+ /** Settlement layers this session is permitted to use. */
65
+ settlementLayers?: CrossChainSettlementLayer[];
66
+ }
67
+ /**
68
+ * Build a CrossChainPermit for Permit2-backed bridge settlement.
69
+ *
70
+ * The returned object is JSON-safe after callers stringify bigint fields at
71
+ * the iframe/API boundary and can be passed as
72
+ * `grantPermissions({ crossChainPermits: [...] })`.
73
+ */
74
+ declare function createCrossChainPermission(input: CreateCrossChainPermissionInput): CrossChainPermit;
75
+
76
+ /**
77
+ * Theme configuration for the dialog UI
78
+ */
79
+ interface ThemeConfig {
80
+ /** Color mode: 'light', 'dark', or 'system' (follows user's OS preference) */
81
+ mode?: 'light' | 'dark' | 'system';
82
+ /**
83
+ * Primary brand color (hex, e.g. `"#5436f5"`). Drives interactive accents:
84
+ * primary CTAs, the spinner, link/account-bar text, and the focus glow
85
+ * around input fields (RHI-4026). The dialog derives lighter tints
86
+ * automatically by alpha-blending this color for the soft inner stroke
87
+ * and diffused outer halo, so apps only need to pass one hex value.
88
+ *
89
+ * Falls back to {@link ThemeConfig.accent} when unset.
90
+ */
91
+ primaryColor?: string;
92
+ /** @deprecated Use {@link ThemeConfig.primaryColor}. Kept as alias for back-compat. */
93
+ accent?: string;
94
+ }
95
+ type OneAuthTelemetryAttributeValue = string | number | boolean | null | undefined;
96
+ type OneAuthTelemetryAttributes = Record<string, OneAuthTelemetryAttributeValue>;
97
+ type OneAuthTelemetryFlow = "client" | "auth" | "connect" | "authenticate" | "sign" | "intent" | "batch_intent" | "grant_permission" | "assets" | "status" | "history";
98
+ type OneAuthTelemetryEventName = "client.init" | "dialog.opened" | "dialog.ready" | "dialog.cancelled" | "auth.succeeded" | "auth.failed" | "connect.succeeded" | "connect.failed" | "sign.succeeded" | "sign.failed" | "intent.prepare.started" | "intent.prepare.succeeded" | "intent.prepare.failed" | "intent.sign.succeeded" | "intent.sign.failed" | "intent.execute.started" | "intent.execute.succeeded" | "intent.execute.failed" | "intent.status.started" | "intent.status.succeeded" | "intent.status.failed" | "intent.completed" | "batch.prepare.started" | "batch.prepare.succeeded" | "batch.prepare.failed" | "batch.sign.succeeded" | "batch.sign.failed" | "batch.completed" | "grant_permission.succeeded" | "grant_permission.failed" | "assets.succeeded" | "assets.failed" | "status.succeeded" | "status.failed" | "history.succeeded" | "history.failed";
99
+ interface OneAuthTelemetryTraceContext {
100
+ /** W3C traceparent header value supplied by the host app's tracer. */
101
+ traceparent?: string;
102
+ /** W3C tracestate header value supplied by the host app's tracer. */
103
+ tracestate?: string;
104
+ /** Optional trace id for SDK event callbacks that do not use traceparent. */
105
+ traceId?: string;
106
+ /** Optional span id for SDK event callbacks that do not use traceparent. */
107
+ spanId?: string;
108
+ }
109
+ interface OneAuthTelemetryEvent {
110
+ /** Low-cardinality event name emitted by the SDK. */
111
+ name: OneAuthTelemetryEventName;
112
+ /** Per-operation correlation id generated by the SDK. */
113
+ operationId: string;
114
+ /** High-level SDK flow that owns the event. */
115
+ flow: OneAuthTelemetryFlow;
116
+ /** ISO timestamp when the event was emitted. */
117
+ timestamp: string;
118
+ /** Milliseconds since the SDK operation started, when applicable. */
119
+ durationMs?: number;
120
+ /** Human outcome for dashboards and SDK-side spans. */
121
+ outcome?: "success" | "failure" | "cancelled" | "started";
122
+ clientId?: string;
123
+ providerUrl?: string;
124
+ dialogUrl?: string;
125
+ targetChain?: number;
126
+ targetChains?: number[];
127
+ intentCount?: number;
128
+ status?: string;
129
+ errorCode?: string;
130
+ errorMessage?: string;
131
+ trace?: OneAuthTelemetryTraceContext;
132
+ attributes?: OneAuthTelemetryAttributes;
133
+ }
134
+ interface OneAuthTelemetryConfig {
135
+ /**
136
+ * Enable SDK telemetry callbacks and trace propagation. Defaults to true
137
+ * when a telemetry object is provided.
138
+ */
139
+ enabled?: boolean;
140
+ /**
141
+ * Optional callback for host apps to bridge SDK events into their own
142
+ * OpenTelemetry tracer/logger. The SDK catches callback errors so telemetry
143
+ * can never break an auth or signing flow.
144
+ */
145
+ onEvent?: (event: OneAuthTelemetryEvent) => void;
146
+ /**
147
+ * Current host-app trace context. When supplied, the SDK forwards it to
148
+ * 1auth dialogs and passkey API calls through W3C-compatible fields.
149
+ */
150
+ traceContext?: OneAuthTelemetryTraceContext | (() => OneAuthTelemetryTraceContext | undefined);
151
+ /** Static or lazily computed attributes attached to every SDK event. */
152
+ attributes?: OneAuthTelemetryAttributes | (() => OneAuthTelemetryAttributes | undefined);
153
+ }
154
+ interface PasskeyProviderConfig {
155
+ /** Base URL of the auth API. Defaults to https://passkey.1auth.box */
156
+ providerUrl?: string;
157
+ /** Client identifier for this application (optional for development) */
158
+ clientId?: string;
159
+ /** Optional redirect URL for redirect flow */
160
+ redirectUrl?: string;
161
+ /** Optional URL of the dialog UI. Defaults to providerUrl */
162
+ dialogUrl?: string;
163
+ /** Optional theme configuration for the dialog */
164
+ theme?: ThemeConfig;
165
+ /**
166
+ * Control whether the 1auth signing review iframe is hidden.
167
+ *
168
+ * When blind signing is on, the 1auth transaction, message, and EIP-712
169
+ * review UI is skipped and the WebAuthn signature auto-starts; the browser's
170
+ * own WebAuthn prompt is still shown.
171
+ *
172
+ * Defaults to blind signing (see the `DEFAULT_BLIND_SIGNING` switch in the
173
+ * SDK). Set `blind_signing: false` to *opt in* to 1auth's visible review UI
174
+ * (clear signing) for this app. Per-call overrides still take precedence.
175
+ */
176
+ blind_signing?: boolean;
177
+ /** When true, operate chain queries on testnets. `wallet_getAssets` returns grouped mainnet and testnet balances. */
178
+ testnets?: boolean;
179
+ /**
180
+ * Sponsorship configuration for app-sponsored intents. Set once on the
181
+ * client; applied automatically to every sendIntent / sendCalls / batch.
182
+ * Accepts either a callback pair (full control) or a pair of URLs (SDK
183
+ * handles fetching).
184
+ */
185
+ sponsorship?: SponsorshipConfig;
186
+ /**
187
+ * Optional SDK telemetry bridge. Core SDK stays dependency-free: integrators
188
+ * can use this callback to create spans/logs in their own OTEL setup.
189
+ */
190
+ telemetry?: OneAuthTelemetryConfig;
191
+ }
192
+ /**
193
+ * Authentication dialog entry point.
194
+ *
195
+ * `auto` preserves the legacy SDK behavior: the passkey app decides whether
196
+ * to show sign-in or account creation from local iframe-origin state.
197
+ */
198
+ type AuthFlow = "auto" | "login" | "create-account";
199
+ /**
200
+ * Options for {@link OneAuthClient.authWithModal}.
201
+ */
202
+ interface AuthWithModalOptions {
203
+ /** Optional account hint; the passkey app uses it to prefer sign-in. */
204
+ username?: string;
205
+ /** Override the theme for this modal invocation. */
206
+ theme?: ThemeConfig;
207
+ /** Set to false to hide OAuth sign-in buttons in account creation. */
208
+ oauthEnabled?: boolean;
209
+ /** Force a specific auth entry route instead of the default auto-router. */
210
+ flow?: AuthFlow;
211
+ }
212
+ /**
213
+ * Options for {@link OneAuthClient.loginWithModal}.
214
+ */
215
+ interface LoginWithModalOptions {
216
+ /** Optional account hint for the sign-in ceremony. */
217
+ username?: string;
218
+ /** Override the theme for this modal invocation. */
219
+ theme?: ThemeConfig;
220
+ }
221
+ /**
222
+ * Options for {@link OneAuthClient.createAccountWithModal}.
223
+ */
224
+ interface CreateAccountWithModalOptions {
225
+ /** Override the theme for this modal invocation. */
226
+ theme?: ThemeConfig;
227
+ /** Set to false to hide OAuth sign-in buttons. */
228
+ oauthEnabled?: boolean;
229
+ }
230
+ /**
231
+ * Signer backing the authenticated session. Defaults to `"passkey"` when absent
232
+ * for back-compat with clients that predate the wallet-connect flow.
233
+ */
234
+ type SignerType = "passkey" | "eoa";
235
+ /**
236
+ * Result of {@link OneAuthClient.authWithModal} — covers both sign-in and sign-up.
237
+ *
238
+ * @example
239
+ * ```typescript
240
+ * const result = await client.authWithModal();
241
+ * if (result.success) {
242
+ * console.log(result.user?.username); // "alice"
243
+ * console.log(result.user?.address); // "0x1234..."
244
+ * }
245
+ * ```
246
+ */
247
+ interface AuthResult {
248
+ success: boolean;
249
+ /** Authenticated user details (present when `success` is true) */
250
+ user?: {
251
+ id: string;
252
+ username?: string;
253
+ address: `0x${string}`;
254
+ };
255
+ /**
256
+ * Which signer produced this session. Absent = treat as `"passkey"` so older
257
+ * clients keep working; new wallet flows populate explicitly.
258
+ */
259
+ signerType?: SignerType;
260
+ error?: {
261
+ code: string;
262
+ message: string;
263
+ };
264
+ }
265
+ /**
266
+ * Result of the connect modal (lightweight connection without passkey auth)
267
+ */
268
+ interface ConnectResult {
269
+ success: boolean;
270
+ /** Connected user details (present when `success` is true) */
271
+ user?: {
272
+ username?: string;
273
+ address: `0x${string}`;
274
+ };
275
+ /**
276
+ * Which signer produced this connection. Absent = treat as `"passkey"` for
277
+ * back-compat; wallet-connect flows set this to `"eoa"`.
278
+ */
279
+ signerType?: SignerType;
280
+ /** Whether this was auto-connected (user had auto-connect enabled) */
281
+ autoConnected?: boolean;
282
+ /** Action to take when connection was not successful */
283
+ action?: "switch" | "cancel";
284
+ error?: {
285
+ code: string;
286
+ message: string;
287
+ };
288
+ }
289
+ /**
290
+ * Options for the authenticate() method
291
+ */
292
+ interface AuthenticateOptions {
293
+ /**
294
+ * Human-readable challenge message for the user to sign.
295
+ * The provider will hash this with a domain separator to prevent
296
+ * the signature from being reused for transaction signing.
297
+ */
298
+ challenge?: string;
299
+ }
300
+ /**
301
+ * Result of {@link OneAuthClient.authenticate} — extends {@link AuthResult}
302
+ * with challenge-signing fields.
303
+ *
304
+ * @example
305
+ * ```typescript
306
+ * const result = await client.authenticate({
307
+ * challenge: `Login to MyApp\nNonce: ${crypto.randomUUID()}`
308
+ * });
309
+ * if (result.success && result.challenge) {
310
+ * await verifyOnServer(result.user?.username, result.challenge.signature, result.challenge.signedHash);
311
+ * }
312
+ * ```
313
+ */
314
+ interface AuthenticateResult extends AuthResult {
315
+ /** Challenge signing result (present when a challenge was provided) */
316
+ challenge?: {
317
+ /** WebAuthn signature of the hashed challenge */
318
+ signature: WebAuthnSignature;
319
+ /**
320
+ * The hash that was actually signed (so apps can verify server-side).
321
+ * Computed as: keccak256("\x19Ethereum Signed Message:\n" + len + challenge) (EIP-191)
322
+ */
323
+ signedHash: `0x${string}`;
324
+ };
325
+ }
326
+ /**
327
+ * Options for signMessage
328
+ */
329
+ interface SignMessageOptions {
330
+ /** Username of the signer (required if accountAddress is not provided) */
331
+ username?: string;
332
+ /** Account address of the signer (alternative to username) */
333
+ accountAddress?: string;
334
+ /** Human-readable message to sign */
335
+ message: string;
336
+ /** Optional custom challenge (defaults to message hash) */
337
+ challenge?: string;
338
+ /** Description shown to user in the dialog */
339
+ description?: string;
340
+ /** Optional metadata to display to the user */
341
+ metadata?: Record<string, unknown>;
342
+ /** Theme configuration */
343
+ theme?: ThemeConfig;
344
+ /** Override the client's blind signing setting for this request. */
345
+ blind_signing?: boolean;
346
+ }
347
+ /**
348
+ * Base result for all signing operations (message signing, typed data signing).
349
+ */
350
+ interface SigningResultBase {
351
+ success: boolean;
352
+ /** WebAuthn signature if successful */
353
+ signature?: WebAuthnSignature;
354
+ /** The hash that was signed */
355
+ signedHash?: `0x${string}`;
356
+ /** Passkey credentials used for signing */
357
+ passkey?: PasskeyCredentials;
358
+ /** Error details if failed */
359
+ error?: {
360
+ code: SigningErrorCode;
361
+ message: string;
362
+ };
363
+ }
364
+ /**
365
+ * Result of signMessage
366
+ */
367
+ interface SignMessageResult extends SigningResultBase {
368
+ /** The original message that was signed */
369
+ signedMessage?: string;
370
+ }
371
+ interface ClearSignData {
372
+ decoded: boolean;
373
+ verified: boolean;
374
+ functionName?: string;
375
+ intent?: string;
376
+ args?: Array<{
377
+ name: string;
378
+ type: string;
379
+ value: string;
380
+ label?: string;
381
+ }>;
382
+ selector?: string;
383
+ }
384
+ interface TransactionAction {
385
+ type: 'send' | 'receive' | 'approve' | 'swap' | 'mint' | 'custom' | 'module_install';
386
+ label: string;
387
+ sublabel?: string;
388
+ amount?: string;
389
+ icon?: string;
390
+ clearSign?: ClearSignData;
391
+ recipient?: TransactionRecipient;
392
+ }
393
+ interface TransactionRecipient {
394
+ address: string;
395
+ label?: string;
396
+ display: string;
397
+ source: "decoded_transfer" | "token_request";
398
+ }
399
+ interface TransactionFees {
400
+ estimated: string;
401
+ network: {
402
+ name: string;
403
+ icon?: string;
404
+ };
405
+ }
406
+ interface BalanceRequirement {
407
+ token: string;
408
+ amount: string;
409
+ faucetUrl?: string;
410
+ }
411
+ interface TransactionDetails {
412
+ actions: TransactionAction[];
413
+ fees?: TransactionFees;
414
+ requiredBalance?: BalanceRequirement;
415
+ account?: {
416
+ address: string;
417
+ label?: string;
418
+ };
419
+ }
420
+ interface SigningRequestOptions {
421
+ challenge: string;
422
+ /** Username hint for legacy passkey accounts. Prefer accountAddress when available. */
423
+ username?: string;
424
+ /** Smart account address of the signer. Required when username is omitted. */
425
+ accountAddress?: string;
426
+ description?: string;
427
+ metadata?: Record<string, unknown>;
428
+ transaction?: TransactionDetails;
429
+ /** Override the client's blind signing setting for this request. */
430
+ blind_signing?: boolean;
431
+ }
432
+ interface PasskeyCredential {
433
+ id: string;
434
+ deviceName: string | null;
435
+ publicKeyX: string;
436
+ publicKeyY: string;
437
+ }
438
+ interface UserPasskeysResponse {
439
+ passkeys: PasskeyCredential[];
440
+ }
441
+ interface WebAuthnSignature {
442
+ authenticatorData: string;
443
+ clientDataJSON: string;
444
+ challengeIndex: number;
445
+ typeIndex: number;
446
+ r: string;
447
+ s: string;
448
+ topOrigin: string | null;
449
+ }
450
+ interface PasskeyCredentials {
451
+ credentialId: string;
452
+ publicKeyX: string;
453
+ publicKeyY: string;
454
+ }
455
+ interface SigningSuccess {
456
+ success: true;
457
+ requestId?: string;
458
+ /** WebAuthn signature - present for message/typedData signing */
459
+ signature?: WebAuthnSignature;
460
+ /** Array of signatures for multi-origin cross-chain intents (one per source chain) */
461
+ originSignatures?: WebAuthnSignature[];
462
+ /** Credentials of the passkey used for signing - present for message/typedData signing */
463
+ passkey?: PasskeyCredentials;
464
+ /** Intent ID - present for intent signing (after execute in dialog) */
465
+ intentId?: string;
466
+ }
467
+ type SigningErrorCode = "USER_REJECTED" | "EXPIRED" | "INVALID_REQUEST" | "NETWORK_ERROR" | "POPUP_BLOCKED" | "SIGNING_FAILED" | "UNKNOWN";
468
+ interface EmbedOptions {
469
+ container: HTMLElement;
470
+ width?: string;
471
+ height?: string;
472
+ onReady?: () => void;
473
+ onClose?: () => void;
474
+ }
475
+ interface SigningError {
476
+ success: false;
477
+ requestId?: string;
478
+ error: {
479
+ code: SigningErrorCode;
480
+ message: string;
481
+ };
482
+ }
483
+ type SigningResult = SigningSuccess | SigningError;
484
+ interface CreateSigningRequestResponse {
485
+ requestId: string;
486
+ nonce: string;
487
+ signingUrl: string;
488
+ expiresAt: string;
489
+ }
490
+ interface SigningRequestStatus {
491
+ id: string;
492
+ status: "PENDING" | "COMPLETED" | "REJECTED" | "EXPIRED" | "FAILED";
493
+ signature?: WebAuthnSignature;
494
+ error?: {
495
+ code: SigningErrorCode;
496
+ message: string;
497
+ };
498
+ }
499
+ /**
500
+ * Low-level sponsorship config: caller supplies callbacks that produce tokens.
501
+ * The SDK invokes `accessToken()` before each sponsored intent and
502
+ * `getExtensionToken(intentOp)` in parallel with the signing ceremony.
503
+ */
504
+ interface SponsorshipCallbackConfig {
505
+ accessToken: () => Promise<string>;
506
+ getExtensionToken: (intentOp: string) => Promise<string>;
507
+ }
508
+ /**
509
+ * High-level sponsorship config: the SDK fetches tokens from the app's own
510
+ * endpoints (same-origin recommended so session cookies authenticate the user).
511
+ * `accessTokenUrl` is GET → `{ token }`, `extensionTokenUrl` is POST
512
+ * `{ intentOp }` → `{ token }`.
513
+ */
514
+ interface SponsorshipUrlConfig {
515
+ accessTokenUrl: string;
516
+ extensionTokenUrl: string;
517
+ }
518
+ type SponsorshipConfig = SponsorshipCallbackConfig | SponsorshipUrlConfig;
519
+ /**
520
+ * Options for querying a unified 1auth wallet asset portfolio.
521
+ */
522
+ interface GetAssetsOptions {
523
+ /** Account address whose unified portfolio should be queried. */
524
+ accountAddress: Address;
525
+ }
526
+ /**
527
+ * Single token balance on one chain in the normalized assets response.
528
+ */
529
+ interface AssetBalance {
530
+ /** Chain ID where this balance lives. */
531
+ chainId: number;
532
+ /** Token contract address on the chain. */
533
+ token: string;
534
+ /** Human token symbol, e.g. USDC. */
535
+ symbol: string;
536
+ /** Token decimals used to format balance. */
537
+ decimals: number;
538
+ /** Raw base-unit token balance as a decimal string. */
539
+ balance: string;
540
+ /** Optional fiat value when supplied by the passkey portfolio API. */
541
+ usdValue?: number;
542
+ /** True when the chain is a known testnet. */
543
+ isTestnet?: boolean;
544
+ }
545
+ /**
546
+ * Network bucket in the grouped assets response.
547
+ */
548
+ interface AssetBalanceBucket {
549
+ /** Balances in this network bucket. */
550
+ balances: AssetBalance[];
551
+ }
552
+ /**
553
+ * Normalized response returned by client.getAssets and wallet_getAssets.
554
+ */
555
+ interface AssetsResponse {
556
+ /** Flat portfolio rows across all supported chains. */
557
+ balances: AssetBalance[];
558
+ /** Mainnet portfolio rows. */
559
+ mainnets: AssetBalanceBucket;
560
+ /** Testnet portfolio rows. */
561
+ testnets: AssetBalanceBucket;
562
+ /** Raw passkey portfolio asset groups, when the provider includes them. */
563
+ assets?: unknown;
564
+ }
565
+ /**
566
+ * A call to execute on the target chain
567
+ */
568
+ interface IntentCall {
569
+ /** Target contract address */
570
+ to: string;
571
+ /** Calldata to send */
572
+ data?: string;
573
+ /** Value in wei (as string for serialization) */
574
+ value?: string;
575
+ /**
576
+ * Optional label for the transaction review UI (bold title row in the
577
+ * sign dialog's action card, e.g. "Send", "Approve").
578
+ *
579
+ * Hard-capped by the SDK at 20 characters before being sent to the
580
+ * passkey service; longer strings are truncated with a trailing ellipsis.
581
+ * The dialog additionally applies CSS `truncate` as a defense-in-depth
582
+ * single-line guarantee — design column is only ~200–260px wide at
583
+ * `text-[16px] bold`, so anything past ~17 typical glyphs would wrap.
584
+ */
585
+ label?: string;
586
+ /**
587
+ * Optional sublabel for additional context (the secondary row underneath
588
+ * `label`, e.g. token amount or destination).
589
+ *
590
+ * Same 20-character SDK cap as {@link IntentCall.label}.
591
+ */
592
+ sublabel?: string;
593
+ /**
594
+ * Optional icon shown in the sign dialog's action card. Used as a
595
+ * fallback only — when 1auth can resolve a built-in token icon for this
596
+ * call (USDC, ETH, …) that one wins, so apps cannot impersonate
597
+ * well-known tokens with a custom glyph.
598
+ *
599
+ * Must be an `https://` URL or a `data:image/<format>;...` URL
600
+ * (svg+xml, png, webp, jpeg, gif). Max 8 KB. Other schemes
601
+ * (`http:`, `javascript:`, `file:`, …) are rejected by the server.
602
+ *
603
+ * Note: HTTPS URLs are fetched directly by the user's browser, which
604
+ * leaks IP/UA/Referer to the host you point at. Use a `data:` URL if
605
+ * you don't want the user's browser making a third-party request.
606
+ */
607
+ icon?: string;
608
+ /**
609
+ * Optional ABI used by the sign dialog to render a human-readable
610
+ * preview of `data` (decoded function name + args) under the action
611
+ * card's label/sublabel.
612
+ *
613
+ * App-supplied and unverified — same trust model as {@link IntentCall.label},
614
+ * {@link IntentCall.sublabel}, and {@link IntentCall.icon}, and the same
615
+ * as the ABI in {@link GrantPermissionContractMetadata}. The dialog renders
616
+ * it with an "Unverified" badge and never uses it for authorization; the
617
+ * raw `to` + selector is always shown alongside as ground truth.
618
+ *
619
+ * The dialog decodes via viem's `decodeFunctionData(abi, data)`. If the
620
+ * ABI doesn't cover the selector in `data` (or decoding throws for any
621
+ * reason) the preview is silently dropped — no hard failure.
622
+ */
623
+ abi?: readonly unknown[];
624
+ }
625
+ /**
626
+ * Token request for the intent
627
+ */
628
+ interface IntentTokenRequest {
629
+ /** Token contract address */
630
+ token: string;
631
+ /** Amount in base units (use parseUnits for decimals) */
632
+ amount: bigint;
633
+ }
634
+ /**
635
+ * Options for sendIntent
636
+ */
637
+ interface SendIntentOptions {
638
+ /** Username of the signer */
639
+ username?: string;
640
+ /** Account address of the signer (alternative to username) */
641
+ accountAddress?: string;
642
+ /** Target chain ID */
643
+ targetChain?: number;
644
+ /** Calls to execute on the target chain */
645
+ calls?: IntentCall[];
646
+ /** Optional token requests */
647
+ tokenRequests?: IntentTokenRequest[];
648
+ /**
649
+ * Constrain which tokens can be used as input/payment.
650
+ * If not specified, orchestrator picks from all available balances.
651
+ * Example: ['USDC'] or ['0x...'] to only use USDC as input.
652
+ */
653
+ sourceAssets?: string[];
654
+ /**
655
+ * Source chain ID for the assets.
656
+ * When specified with sourceAssets containing addresses, tells orchestrator
657
+ * which chain to look for those tokens on.
658
+ */
659
+ sourceChainId?: number;
660
+ /** When to close the dialog and return success. Defaults to "preconfirmed" */
661
+ closeOn?: CloseOnStatus;
662
+ /**
663
+ * Wait for a transaction hash before resolving.
664
+ * Defaults to false to preserve existing behavior.
665
+ */
666
+ waitForHash?: boolean;
667
+ /** Maximum time to wait for a transaction hash in ms. */
668
+ hashTimeoutMs?: number;
669
+ /** Poll interval for transaction hash in ms. */
670
+ hashIntervalMs?: number;
671
+ /**
672
+ * Whether to request sponsorship (app pays gas) for this intent.
673
+ * Defaults to `true`. When `false`, the intent authenticates with the
674
+ * app's JWT but pays its own gas from source assets — no extension
675
+ * token is fetched. Requires `sponsorship` to be configured on the
676
+ * client either way; there is no anonymous fallback.
677
+ */
678
+ sponsor?: boolean;
679
+ /** Override the client's blind signing setting for this request. */
680
+ blind_signing?: boolean;
681
+ }
682
+ /**
683
+ * Quote from the Rhinestone orchestrator
684
+ */
685
+ interface IntentQuote {
686
+ /** Total cost in input tokens */
687
+ cost: {
688
+ total: string;
689
+ breakdown?: {
690
+ gas?: string;
691
+ bridge?: string;
692
+ swap?: string;
693
+ };
694
+ };
695
+ /** Token requirements to fulfill the intent */
696
+ tokenRequirements: Array<{
697
+ token: string;
698
+ amount: string;
699
+ chainId: number;
700
+ }>;
701
+ }
702
+ /**
703
+ * Status of an intent (local states)
704
+ */
705
+ type IntentStatus = "pending" | "quoted" | "signed" | "submitted" | "claimed" | "preconfirmed" | "filled" | "completed" | "failed" | "expired" | "unknown";
706
+ /**
707
+ * Orchestrator status (from Rhinestone)
708
+ * These are the statuses we can receive when polling
709
+ */
710
+ type OrchestratorStatus = "PENDING" | "CLAIMED" | "PRECONFIRMED" | "FILLED" | "COMPLETED" | "FAILED" | "EXPIRED";
711
+ /**
712
+ * When to consider the transaction complete and close the dialog
713
+ * - "claimed" - Close when a solver has claimed the intent (fastest)
714
+ * - "preconfirmed" - Close on pre-confirmation (recommended)
715
+ * - "filled" - Close when the transaction is filled
716
+ * - "completed" - Wait for full completion (slowest, most certain)
717
+ */
718
+ type CloseOnStatus = "claimed" | "preconfirmed" | "filled" | "completed";
719
+ /**
720
+ * Result of sendIntent
721
+ */
722
+ interface SendIntentResult {
723
+ /** Whether the intent was successfully submitted */
724
+ success: boolean;
725
+ /** Intent ID for tracking */
726
+ intentId: string;
727
+ /** Current status */
728
+ status: IntentStatus;
729
+ /** Transaction hash if completed */
730
+ transactionHash?: string;
731
+ /** Operation ID from orchestrator */
732
+ operationId?: string;
733
+ /** Error details if failed */
734
+ error?: {
735
+ code: string;
736
+ message: string;
737
+ /** Structured provider details, when the auth service returns them. */
738
+ details?: unknown;
739
+ };
740
+ }
741
+ /**
742
+ * Prepare intent response from auth service
743
+ */
744
+ interface PrepareIntentResponse {
745
+ quote: IntentQuote;
746
+ transaction: TransactionDetails;
747
+ challenge: string;
748
+ expiresAt: string;
749
+ /** Account address for the sign dialog to detect self-transfer vs external send */
750
+ accountAddress?: string;
751
+ /** Serialized PreparedTransactionData from orchestrator - needed for execute */
752
+ intentOp: string;
753
+ /** User ID for creating intent record on execute */
754
+ userId: string;
755
+ /** Target chain ID */
756
+ targetChain: number;
757
+ /** JSON stringified calls */
758
+ calls: string;
759
+ /** Origin message hashes for multi-source cross-chain intents */
760
+ originMessages?: Array<{
761
+ chainId: number;
762
+ messageHash: string;
763
+ }>;
764
+ /** Serialized DigestResult from module SDK (EIP-712 wrapped challenge + merkle proofs) */
765
+ digestResult?: string;
766
+ }
767
+ /**
768
+ * Execute intent response from auth service
769
+ */
770
+ interface ExecuteIntentResponse {
771
+ success: boolean;
772
+ intentId: string;
773
+ operationId?: string;
774
+ status: IntentStatus;
775
+ transactionHash?: string;
776
+ /** Transaction result data needed for waiting via POST /api/intent/wait */
777
+ transactionResult?: unknown;
778
+ error?: {
779
+ code: string;
780
+ message: string;
781
+ /** Structured provider details, when the auth service returns them. */
782
+ details?: unknown;
783
+ };
784
+ }
785
+ /**
786
+ * EIP-712 Domain parameters
787
+ */
788
+ interface EIP712Domain {
789
+ /** Name of the signing domain (e.g., "Dai Stablecoin") */
790
+ name: string;
791
+ /** Version of the signing domain (e.g., "1") */
792
+ version: string;
793
+ /** Chain ID (optional) */
794
+ chainId?: number;
795
+ /** Verifying contract address (optional) */
796
+ verifyingContract?: `0x${string}`;
797
+ /** Salt for disambiguation (optional) */
798
+ salt?: `0x${string}`;
799
+ }
800
+ /**
801
+ * EIP-712 Type field definition
802
+ */
803
+ interface EIP712TypeField {
804
+ /** Field name */
805
+ name: string;
806
+ /** Solidity type (e.g., "address", "uint256", "bytes32") */
807
+ type: string;
808
+ }
809
+ /**
810
+ * EIP-712 Types map - maps type names to their field definitions
811
+ */
812
+ type EIP712Types = {
813
+ [typeName: string]: EIP712TypeField[];
814
+ };
815
+ /**
816
+ * Options for signTypedData
817
+ */
818
+ interface SignTypedDataOptions {
819
+ /** Username of the signer (required if accountAddress is not provided) */
820
+ username?: string;
821
+ /** Account address of the signer (alternative to username) */
822
+ accountAddress?: string;
823
+ /** EIP-712 domain parameters */
824
+ domain: EIP712Domain;
825
+ /** Type definitions for all types used in the message */
826
+ types: EIP712Types;
827
+ /** Primary type being signed (must be a key in types) */
828
+ primaryType: string;
829
+ /** Message values matching the primaryType structure */
830
+ message: Record<string, unknown>;
831
+ /** Optional description shown in the dialog */
832
+ description?: string;
833
+ /** Theme configuration */
834
+ theme?: ThemeConfig;
835
+ /** Override the client's blind signing setting for this request. */
836
+ blind_signing?: boolean;
837
+ }
838
+ /**
839
+ * Result of signTypedData
840
+ */
841
+ interface SignTypedDataResult extends SigningResultBase {
842
+ }
843
+ /**
844
+ * Options for querying intent history
845
+ */
846
+ interface IntentHistoryOptions {
847
+ /** Maximum number of intents to return (default: 50, max: 100) */
848
+ limit?: number;
849
+ /** Number of intents to skip for pagination */
850
+ offset?: number;
851
+ /** Filter by intent status */
852
+ status?: IntentStatus;
853
+ /** Filter by creation date (ISO string) - intents created on or after this date */
854
+ from?: string;
855
+ /** Filter by creation date (ISO string) - intents created on or before this date */
856
+ to?: string;
857
+ }
858
+ /**
859
+ * Single intent item in history response
860
+ */
861
+ interface IntentHistoryItem {
862
+ /** Intent identifier (orchestrator's ID, used as primary key) */
863
+ intentId: string;
864
+ /** Current status of the intent */
865
+ status: IntentStatus;
866
+ /** Transaction hash (if completed) */
867
+ transactionHash?: string;
868
+ /** Target chain ID */
869
+ targetChain: number;
870
+ /** Calls that were executed */
871
+ calls: IntentCall[];
872
+ /** When the intent was created (ISO string) */
873
+ createdAt: string;
874
+ /** When the intent was last updated (ISO string) */
875
+ updatedAt: string;
876
+ }
877
+ /**
878
+ * Result of getIntentHistory
879
+ */
880
+ interface IntentHistoryResult {
881
+ /** List of intents */
882
+ intents: IntentHistoryItem[];
883
+ /** Total count of matching intents */
884
+ total: number;
885
+ /** Whether there are more intents beyond this page */
886
+ hasMore: boolean;
887
+ }
888
+ /**
889
+ * A single intent within a batch
890
+ */
891
+ interface BatchIntentItem {
892
+ /** Target chain ID */
893
+ targetChain: number;
894
+ /** Calls to execute on the target chain */
895
+ calls?: IntentCall[];
896
+ /** Optional token requests */
897
+ tokenRequests?: IntentTokenRequest[];
898
+ /** Constrain which tokens can be used as input */
899
+ sourceAssets?: string[];
900
+ /** Source chain ID for the assets */
901
+ sourceChainId?: number;
902
+ /** Install an ERC-7579 module instead of executing calls */
903
+ moduleInstall?: {
904
+ moduleType: "validator" | "executor" | "fallback" | "hook";
905
+ moduleAddress: string;
906
+ initData?: string;
907
+ };
908
+ /**
909
+ * Whether to request sponsorship for this item. Defaults to `true`.
910
+ * When `false`, the item authenticates with the app's JWT but no
911
+ * extension token is fetched for it.
912
+ */
913
+ sponsor?: boolean;
914
+ }
915
+ /**
916
+ * Options for sendBatchIntent
917
+ */
918
+ interface SendBatchIntentOptions {
919
+ /** Username of the signer */
920
+ username?: string;
921
+ /** Account address of the signer (alternative to username) */
922
+ accountAddress?: string;
923
+ /** Array of intents to execute as a batch */
924
+ intents: BatchIntentItem[];
925
+ /** When to close the dialog for each intent. Defaults to "preconfirmed" */
926
+ closeOn?: CloseOnStatus;
927
+ /** Override the client's blind signing setting for this request. */
928
+ blind_signing?: boolean;
929
+ }
930
+ /**
931
+ * Result for a single intent within a batch
932
+ */
933
+ interface BatchIntentItemResult {
934
+ /** Index in the original batch */
935
+ index: number;
936
+ /** Whether this intent succeeded */
937
+ success: boolean;
938
+ /** Intent ID from orchestrator */
939
+ intentId: string;
940
+ /** Current status */
941
+ status: IntentStatus;
942
+ /** Error details if failed */
943
+ error?: {
944
+ code: string;
945
+ message: string;
946
+ };
947
+ }
948
+ /**
949
+ * Result of sendBatchIntent
950
+ */
951
+ interface SendBatchIntentResult {
952
+ /** Whether ALL intents succeeded */
953
+ success: boolean;
954
+ /** Per-intent results */
955
+ results: BatchIntentItemResult[];
956
+ /** Count of successful intents */
957
+ successCount: number;
958
+ /** Count of failed intents */
959
+ failureCount: number;
960
+ /** Top-level error message when batch-prepare itself fails */
961
+ error?: string;
962
+ }
963
+ /**
964
+ * Prepared intent data within a batch response
965
+ */
966
+ interface PreparedBatchIntent {
967
+ /** Index in the original batch */
968
+ index: number;
969
+ /** Quote from orchestrator */
970
+ quote: IntentQuote;
971
+ /** Decoded transaction details for UI */
972
+ transaction: TransactionDetails;
973
+ /** Serialized PreparedTransactionData from orchestrator */
974
+ intentOp: string;
975
+ /** Expiry for this specific intent */
976
+ expiresAt: string;
977
+ /** Target chain ID */
978
+ targetChain: number;
979
+ /** JSON stringified calls */
980
+ calls: string;
981
+ /** Origin message hashes for this intent */
982
+ originMessages: Array<{
983
+ chainId: number;
984
+ messageHash: string;
985
+ }>;
986
+ }
987
+ /**
988
+ * Prepare batch intent response from auth service
989
+ */
990
+ interface PrepareBatchIntentResponse {
991
+ /** Per-intent prepared data (successful quotes only) */
992
+ intents: PreparedBatchIntent[];
993
+ /** Intents that failed to get quotes (unsupported chains, etc.) */
994
+ failedIntents?: Array<{
995
+ index: number;
996
+ targetChain: number;
997
+ error: string;
998
+ }>;
999
+ /** Shared challenge (merkle root of ALL origin hashes across ALL intents) */
1000
+ challenge: string;
1001
+ /** User ID */
1002
+ userId: string;
1003
+ /** Account address */
1004
+ accountAddress?: string;
1005
+ /** Global expiry (earliest of all intent expiries) */
1006
+ expiresAt: string;
1007
+ }
1008
+ /** @deprecated Data-sharing consent is disabled. */
1009
+ type ConsentField = "email" | "deviceNames";
1010
+ /** @deprecated Data-sharing consent is disabled. */
1011
+ interface ConsentData {
1012
+ email?: string;
1013
+ deviceNames?: string[];
1014
+ }
1015
+ /** @deprecated Data-sharing consent is disabled. */
1016
+ interface CheckConsentOptions {
1017
+ /** Username of the account (required if accountAddress not provided) */
1018
+ username?: string;
1019
+ /** Account address (alternative to username) */
1020
+ accountAddress?: string;
1021
+ /** Fields to check */
1022
+ fields: ConsentField[];
1023
+ /** Override clientId from SDK config */
1024
+ clientId?: string;
1025
+ }
1026
+ /** @deprecated Data-sharing consent is disabled. */
1027
+ interface CheckConsentResult {
1028
+ /** Whether consent has been granted for ALL requested fields */
1029
+ hasConsent: boolean;
1030
+ /** Shared data (present when hasConsent is true) */
1031
+ data?: ConsentData;
1032
+ /** When consent was granted (ISO timestamp) */
1033
+ grantedAt?: string;
1034
+ }
1035
+ /** @deprecated Data-sharing consent is disabled. */
1036
+ interface RequestConsentOptions {
1037
+ /** Username of the account (required if accountAddress not provided) */
1038
+ username?: string;
1039
+ /** Account address (alternative to username) */
1040
+ accountAddress?: string;
1041
+ /** Fields to request access to */
1042
+ fields: ConsentField[];
1043
+ /** Override clientId from SDK config */
1044
+ clientId?: string;
1045
+ /** Theme configuration */
1046
+ theme?: ThemeConfig;
1047
+ }
1048
+ /** @deprecated Data-sharing consent is disabled. */
1049
+ interface RequestConsentResult {
1050
+ success: boolean;
1051
+ /** Shared data (present when success is true) */
1052
+ data?: ConsentData;
1053
+ /** When consent was granted (ISO timestamp) */
1054
+ grantedAt?: string;
1055
+ /** Whether data came from an existing grant (no dialog shown) */
1056
+ cached?: boolean;
1057
+ /** Error details */
1058
+ error?: {
1059
+ code: "USER_REJECTED" | "USER_CANCELLED" | "INVALID_REQUEST" | "NETWORK_ERROR" | "UNKNOWN";
1060
+ message: string;
1061
+ };
1062
+ }
1063
+ /**
1064
+ * Options for one-time SmartSession install. The host app generates an
1065
+ * ECDSA key locally (or imports one), passes its public address as the
1066
+ * session-key signer, and a permission spec defining what the session
1067
+ * key may do. This triggers a passkey-signed management transaction
1068
+ * that installs the SmartSession validator and registers the session.
1069
+ */
1070
+ interface InstallSmartSessionOptions {
1071
+ /** Username of the account owner (or use accountAddress). */
1072
+ username?: string;
1073
+ /** Account address of the owner (alternative to username). */
1074
+ accountAddress?: string;
1075
+ /** Target chain to install the validator on. */
1076
+ targetChain: number;
1077
+ /** Public address of the ECDSA session-key the app holds in localStorage. */
1078
+ sessionKeyAddress: `0x${string}`;
1079
+ /**
1080
+ * Per-contract permission specs from `definePermissions()`. 1auth
1081
+ * re-validates server-side against an allowlist before asking the
1082
+ * user to passkey-sign.
1083
+ */
1084
+ permissions: Permission<Abi>[];
1085
+ /**
1086
+ * Cross-chain asset movement permits. The upstream SmartSession SDK expands
1087
+ * these into Permit2 claim policy plus fallback guardrails for bridge fills.
1088
+ */
1089
+ crossChainPermits?: CrossChainPermit[];
1090
+ /** Unix seconds. Session is invalid after this time. */
1091
+ validUntil?: number;
1092
+ /** Unix seconds. Session is invalid before this time. */
1093
+ validAfter?: number;
1094
+ /** Optional max number of uses across the session lifetime. */
1095
+ maxUses?: number;
1096
+ /**
1097
+ * Passkey EIP-712 signature over `sessionEnable.typedData`.
1098
+ * Omit on the first request to discover whether this exact
1099
+ * permission needs owner authorization; include on the second
1100
+ * request to receive the on-chain enable call.
1101
+ */
1102
+ enableSessionSignature?: `0x${string}` | WebAuthnSignature;
1103
+ /** Optional human label shown in the install dialog. */
1104
+ label?: string;
1105
+ }
1106
+ interface SmartSessionEnableRequest {
1107
+ alreadyEnabled: boolean;
1108
+ /**
1109
+ * EIP-712 payload to pass to `OneAuthClient.signTypedData` when
1110
+ * `alreadyEnabled` is false. Big integer fields are JSON-encoded as
1111
+ * decimal strings by the provider and should be revived before signing.
1112
+ */
1113
+ typedData?: {
1114
+ domain: EIP712Domain;
1115
+ types: EIP712Types;
1116
+ primaryType: string;
1117
+ message: Record<string, unknown>;
1118
+ };
1119
+ }
1120
+ interface InstallSmartSessionResult {
1121
+ install: {
1122
+ targetChain: number;
1123
+ calls: Array<{
1124
+ to: string;
1125
+ data: string;
1126
+ value: string;
1127
+ label?: string;
1128
+ sublabel?: string;
1129
+ }>;
1130
+ alreadyInstalled: boolean;
1131
+ };
1132
+ sessionKeyHandle: SessionKeyHandle;
1133
+ sessionEnable: SmartSessionEnableRequest;
1134
+ }
1135
+ /**
1136
+ * Legacy low-level SmartSession policy descriptors used by passkey review
1137
+ * APIs. New app integrations should prefer `definePermissions()` parameter
1138
+ * constraints plus `grantPermissions()` session limits (`maxUses`,
1139
+ * `validAfter`, `validUntil`) instead of hand-authoring raw policy arrays.
1140
+ */
1141
+ type SmartSessionPolicy = {
1142
+ type: "usage-limit";
1143
+ limit: bigint;
1144
+ } | {
1145
+ type: "time-frame";
1146
+ validAfter: number;
1147
+ validUntil: number;
1148
+ } | {
1149
+ type: "value-limit";
1150
+ limit: bigint;
1151
+ } | {
1152
+ type: "universal-action";
1153
+ valueLimitPerUse?: bigint;
1154
+ rules: [
1155
+ UniversalActionPolicyRule,
1156
+ ...UniversalActionPolicyRule[]
1157
+ ];
1158
+ };
1159
+ interface UniversalActionPolicyRule {
1160
+ condition: "equal" | "greaterThan" | "lessThan" | "greaterThanOrEqual" | "lessThanOrEqual" | "notEqual" | "inRange";
1161
+ calldataOffset: bigint;
1162
+ referenceValue: `0x${string}` | bigint;
1163
+ usageLimit?: bigint;
1164
+ }
1165
+ interface GrantPermissionContractMetadata {
1166
+ address: `0x${string}`;
1167
+ name?: string;
1168
+ /** App-supplied ABI is used for readable labels only and is not verified. */
1169
+ abi?: readonly unknown[];
1170
+ }
1171
+ interface GrantPermissionsOptions {
1172
+ /** Username of the account owner (or use accountAddress). */
1173
+ username?: string;
1174
+ /** Account address of the owner (alternative to username). */
1175
+ accountAddress?: `0x${string}`;
1176
+ /**
1177
+ * Chains where this permission should be installed/enabled.
1178
+ *
1179
+ * SmartSession owner authorization is multi-chain: 1auth asks for one
1180
+ * passkey signature that commits to every requested chain session, then
1181
+ * submits the per-chain install/enable intents internally.
1182
+ */
1183
+ targetChains?: number[];
1184
+ /** @deprecated Use targetChains. Kept as a single-chain compatibility alias. */
1185
+ targetChain?: number;
1186
+ /**
1187
+ * Source/funding chains that need SmartSession coverage for cross-chain
1188
+ * claim signatures, but where selector permissions should not be installed.
1189
+ */
1190
+ sourceChains?: number[];
1191
+ /** Public address of the ECDSA session signer owned by the app. */
1192
+ sessionKeyAddress: `0x${string}`;
1193
+ /** Per-contract permission specs from `definePermissions()`. */
1194
+ permissions: Permission<Abi>[];
1195
+ /**
1196
+ * Cross-chain asset movement permits, usually created with
1197
+ * `createCrossChainPermission()`. These are reviewed and installed together
1198
+ * with selector permissions so headless bridge/swap intents have claim
1199
+ * authority.
1200
+ */
1201
+ crossChainPermits?: CrossChainPermit[];
1202
+ /** Optional session-wide policy hints applied to every function. */
1203
+ validUntil?: number;
1204
+ validAfter?: number;
1205
+ maxUses?: number;
1206
+ /** Optional ABI/name metadata for non-verified human-readable review. */
1207
+ contracts?: GrantPermissionContractMetadata[];
1208
+ /** Whether the app sponsors the install/enable transaction. Defaults to true. */
1209
+ sponsor?: boolean;
1210
+ theme?: ThemeConfig;
1211
+ }
1212
+ interface GrantPermissionsResult {
1213
+ success: boolean;
1214
+ grantId?: string;
1215
+ sessionKeyHandle?: SessionKeyHandle;
1216
+ permissionId?: `0x${string}`;
1217
+ permissionIdsByChain?: Record<number, `0x${string}`>;
1218
+ intentId?: string;
1219
+ intentIds?: string[];
1220
+ status?: IntentStatus | string;
1221
+ statusesByChain?: Record<number, IntentStatus | string>;
1222
+ transactionHash?: string;
1223
+ transactionHashesByChain?: Record<number, string>;
1224
+ statusUrl?: string;
1225
+ statusUrlsByChain?: Record<number, string>;
1226
+ waitUrl?: string;
1227
+ waitUrlsByChain?: Record<number, string>;
1228
+ chainResults?: Array<{
1229
+ chainId: number;
1230
+ intentId?: string;
1231
+ status?: IntentStatus | string;
1232
+ transactionHash?: string;
1233
+ statusUrl?: string;
1234
+ waitUrl?: string;
1235
+ alreadyInstalled?: boolean;
1236
+ }>;
1237
+ error?: {
1238
+ code: string;
1239
+ message: string;
1240
+ };
1241
+ }
1242
+ interface ListSessionGrantsOptions {
1243
+ /** Username of the account owner (or use accountAddress). */
1244
+ username?: string;
1245
+ /** Account address of the owner (alternative to username). */
1246
+ accountAddress?: `0x${string}`;
1247
+ /** Include grants that 1auth has marked revoked. Defaults to false. */
1248
+ includeRevoked?: boolean;
1249
+ }
1250
+ interface SessionGrantChain {
1251
+ chainId: number;
1252
+ permissionId: `0x${string}`;
1253
+ status: string;
1254
+ intentId?: string;
1255
+ transactionHash?: string;
1256
+ statusUrl?: string;
1257
+ waitUrl?: string;
1258
+ revokeStatus?: string;
1259
+ revokeIntentId?: string;
1260
+ revokeTransactionHash?: string;
1261
+ revokedAt?: string;
1262
+ }
1263
+ interface SessionGrantRecord {
1264
+ grantId: string;
1265
+ origin: string;
1266
+ app?: {
1267
+ id: string;
1268
+ name: string;
1269
+ clientId: string;
1270
+ };
1271
+ accountAddress: `0x${string}`;
1272
+ sessionKeyAddress: `0x${string}`;
1273
+ permissionId: `0x${string}`;
1274
+ permissionIdsByChain?: Record<number, `0x${string}`>;
1275
+ chainIds: number[];
1276
+ chains: SessionGrantChain[];
1277
+ sessionKeyHandle?: SessionKeyHandle;
1278
+ /** Per-contract permission specs echoed for app bookkeeping. */
1279
+ permissions?: Permission<Abi>[];
1280
+ /** Cross-chain permits echoed for app bookkeeping. */
1281
+ crossChainPermits?: CrossChainPermit[];
1282
+ expiresAt?: string;
1283
+ createdAt: string;
1284
+ updatedAt: string;
1285
+ revokedAt?: string;
1286
+ }
1287
+ interface ListSessionGrantsResult {
1288
+ success: boolean;
1289
+ grants?: SessionGrantRecord[];
1290
+ error?: {
1291
+ code: string;
1292
+ message: string;
1293
+ };
1294
+ }
1295
+ /**
1296
+ * Returned to the caller of {@link InstallSmartSessionOptions}. 1auth stores
1297
+ * this public handle for origin-scoped recovery, but the host app still owns
1298
+ * and stores the private signer material or KMS reference.
1299
+ */
1300
+ interface SessionKeyHandle {
1301
+ sessionKeyAddress: `0x${string}`;
1302
+ /** Deterministic on-chain permission ID for this session key. */
1303
+ permissionId: `0x${string}`;
1304
+ /** Account this permission is scoped to. */
1305
+ accountAddress: `0x${string}`;
1306
+ /** Echoed per-contract permission specs (for app's own bookkeeping). */
1307
+ permissions: Permission<Abi>[];
1308
+ /** Echoed cross-chain permit specs required to rebuild the session hash. */
1309
+ crossChainPermits?: CrossChainPermit[];
1310
+ /** Unix seconds. Session is invalid after this time. */
1311
+ validUntil?: number;
1312
+ /** Unix seconds. Session is invalid before this time. */
1313
+ validAfter?: number;
1314
+ /** Optional max number of uses across the session lifetime. */
1315
+ maxUses?: number;
1316
+ /** Chains where the permission was requested. */
1317
+ chainIds?: number[];
1318
+ /** Chains where selector permissions are installed. */
1319
+ targetChains?: number[];
1320
+ /** Source/funding chains covered only for cross-chain claim signatures. */
1321
+ sourceChains?: number[];
1322
+ /** Per-chain permission IDs. In most SmartSession flows these are stable per session, but callers should key by chain. */
1323
+ permissionIdsByChain?: Record<number, `0x${string}`>;
1324
+ /** First chain in `chainIds`; kept for single-chain compatibility. */
1325
+ chainId: number;
1326
+ /** Mirror of `validUntil` if provided. */
1327
+ expiresAt?: number;
1328
+ }
1329
+ /**
1330
+ * Options for {@link OneAuthHeadlessClient.prepareIntent}. Mirrors the
1331
+ * subset of {@link SendIntentOptions} that's relevant when there is no
1332
+ * dialog UI involved (no `closeOn`, no `waitForHash`, etc.).
1333
+ */
1334
+ interface HeadlessIntentOptions {
1335
+ username?: string;
1336
+ accountAddress?: string;
1337
+ targetChain: number;
1338
+ calls: IntentCall[];
1339
+ tokenRequests?: IntentTokenRequest[];
1340
+ sourceAssets?: string[];
1341
+ sourceChainId?: number;
1342
+ /** Persisted handle from `installSmartSession`; required for SmartSession headless quotes. */
1343
+ sessionKeyHandle?: SessionKeyHandle;
1344
+ /** Whether to request sponsorship for this intent. Defaults to `true`. */
1345
+ sponsor?: boolean;
1346
+ }
1347
+ /**
1348
+ * Result of {@link OneAuthHeadlessClient.prepareIntent}. The host app
1349
+ * feeds `intentOp` and `digestResult` to its own SmartSession encoder
1350
+ * to produce signatures.
1351
+ */
1352
+ interface HeadlessPrepareResult {
1353
+ /**
1354
+ * Serialized PreparedTransactionData from the orchestrator. Treat as
1355
+ * opaque on the wire; pass through to your validator's signer.
1356
+ */
1357
+ intentOp: string;
1358
+ /** Serialized DigestResult (EIP-712 wrapped challenge + merkle proofs). */
1359
+ digestResult: string;
1360
+ /** Per-origin EIP-712 message hashes. */
1361
+ originMessages?: Array<{
1362
+ chainId: number;
1363
+ messageHash: `0x${string}`;
1364
+ hash?: `0x${string}`;
1365
+ }>;
1366
+ /** Destination EIP-712 message hash for SmartSession destination signing. */
1367
+ destinationMessageHash?: `0x${string}`;
1368
+ /** Target execution hash for same-chain / IntentExecutor settlements. */
1369
+ targetExecutionMessageHash?: `0x${string}`;
1370
+ /** Top-level challenge (destination message hash for single-chain, merkle root otherwise). */
1371
+ challenge: `0x${string}`;
1372
+ targetChain: number;
1373
+ /** JSON-stringified calls array (echoed for the submit step). */
1374
+ calls: string;
1375
+ expiresAt: string;
1376
+ accountAddress: `0x${string}`;
1377
+ /** Cost / token-requirement breakdown from the orchestrator quote. */
1378
+ quote?: IntentQuote;
1379
+ }
1380
+ /**
1381
+ * Options for {@link OneAuthHeadlessClient.submitIntent}. The caller
1382
+ * supplies pre-encoded validator-prefixed signatures; 1auth forwards
1383
+ * them unchanged to the orchestrator.
1384
+ */
1385
+ interface HeadlessSubmitOptions {
1386
+ /** Echoed verbatim from the prepare result. */
1387
+ intentOp: string;
1388
+ digestResult: string;
1389
+ /** Public smart account address; 1auth resolves the internal user server-side. */
1390
+ accountAddress: `0x${string}`;
1391
+ targetChain: number;
1392
+ /** JSON-stringified calls array from the prepare result. */
1393
+ calls: string;
1394
+ expiresAt: string;
1395
+ /** One per intent element. Each must already be validator-prefixed. */
1396
+ originSignatures: OriginSignature[];
1397
+ /** Validator-prefixed destination signature. */
1398
+ destinationSignature: `0x${string}`;
1399
+ /** Extra SmartSession signature required by SAME_CHAIN / INTENT_EXECUTOR execution. */
1400
+ targetExecutionSignature?: `0x${string}`;
1401
+ /** Whether to request sponsorship at submit time. Defaults to `true`. */
1402
+ sponsor?: boolean;
1403
+ }
1404
+ /** Result of {@link OneAuthHeadlessClient.submitIntent}. */
1405
+ interface HeadlessSubmitResult {
1406
+ success: boolean;
1407
+ /** Orchestrator's intent ID (use with status / wait endpoints). */
1408
+ intentId: string;
1409
+ status: string;
1410
+ /** Transaction hash when the submit endpoint can resolve it immediately. */
1411
+ transactionHash?: string;
1412
+ /** Opaque transaction result required by POST /api/intent/wait. */
1413
+ transactionResult?: unknown;
1414
+ statusUrl: string;
1415
+ waitUrl: string;
1416
+ }
1417
+ /** Result of the headless status and wait endpoints. */
1418
+ interface HeadlessIntentStatusResult {
1419
+ intentId?: string;
1420
+ operationId?: string;
1421
+ status: string;
1422
+ transactionHash?: string;
1423
+ }
1424
+
1425
+ export { type OrchestratorStatus as $, type AuthResult as A, type AuthenticateResult as B, type CreateCrossChainPermissionInput as C, type SigningResultBase as D, type EmbedOptions as E, type SignMessageOptions as F, type SignMessageResult as G, type HeadlessIntentOptions as H, type InstallSmartSessionOptions as I, type SignTypedDataOptions as J, type SignTypedDataResult as K, type LoginWithModalOptions as L, type EIP712Domain as M, type EIP712Types as N, type EIP712TypeField as O, type PasskeyProviderConfig as P, type TransactionFees as Q, type BalanceRequirement as R, type SponsorshipConfig as S, type TransactionAction as T, type UserPasskeysResponse as U, type TransactionDetails as V, type WebAuthnSignature as W, type IntentTokenRequest as X, type SendIntentOptions as Y, type IntentQuote as Z, type IntentStatus as _, type HeadlessPrepareResult as a, type CloseOnStatus as a0, type PrepareIntentResponse as a1, type ExecuteIntentResponse as a2, type IntentHistoryOptions as a3, type IntentHistoryItem as a4, type IntentHistoryResult as a5, type GetAssetsOptions as a6, type AssetBalance as a7, type AssetBalanceBucket as a8, type AssetsResponse as a9, type OneAuthTelemetryEvent as aA, type OneAuthTelemetryEventName as aB, type OneAuthTelemetryFlow as aC, type OneAuthTelemetryTraceContext as aD, type ThemeConfig as aa, type ConsentField as ab, type ConsentData as ac, type CheckConsentOptions as ad, type CheckConsentResult as ae, type RequestConsentOptions as af, type RequestConsentResult as ag, type GrantPermissionsOptions as ah, type GrantPermissionsResult as ai, type ListSessionGrantsOptions as aj, type ListSessionGrantsResult as ak, type SessionGrantRecord as al, type SessionGrantChain as am, type GrantPermissionContractMetadata as an, type SmartSessionPolicy as ao, type BatchIntentItem as ap, type SendBatchIntentOptions as aq, type SendBatchIntentResult as ar, type BatchIntentItemResult as as, type PreparedBatchIntent as at, type PrepareBatchIntentResponse as au, type SponsorshipCallbackConfig as av, type SponsorshipUrlConfig as aw, type OneAuthTelemetryAttributeValue as ax, type OneAuthTelemetryAttributes as ay, type OneAuthTelemetryConfig as az, type HeadlessSubmitOptions as b, type HeadlessSubmitResult as c, type HeadlessIntentStatusResult as d, type InstallSmartSessionResult as e, type SessionKeyHandle as f, type SmartSessionEnableRequest as g, type IntentCall as h, type SendIntentResult as i, createCrossChainPermission as j, type CrossChainPermit as k, type CrossChainSettlementLayer as l, type SigningRequestOptions as m, type SigningResult as n, type SigningSuccess as o, type SigningError as p, type SigningErrorCode as q, type CreateSigningRequestResponse as r, type SigningRequestStatus as s, type PasskeyCredential as t, type AuthFlow as u, type AuthWithModalOptions as v, type CreateAccountWithModalOptions as w, type SignerType as x, type ConnectResult as y, type AuthenticateOptions as z };