@rhinestone/1auth 0.6.8 → 0.6.10

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 (51) hide show
  1. package/README.md +171 -12
  2. package/dist/chunk-GUAI55LL.mjs +179 -0
  3. package/dist/chunk-GUAI55LL.mjs.map +1 -0
  4. package/dist/chunk-IHBVEU33.mjs +20 -0
  5. package/dist/chunk-IHBVEU33.mjs.map +1 -0
  6. package/dist/chunk-IIACVHR3.mjs +28 -0
  7. package/dist/chunk-IIACVHR3.mjs.map +1 -0
  8. package/dist/chunk-N6KE5CII.mjs +72 -0
  9. package/dist/chunk-N6KE5CII.mjs.map +1 -0
  10. package/dist/{chunk-SXISYG2P.mjs → chunk-THKG3FAG.mjs} +137 -255
  11. package/dist/chunk-THKG3FAG.mjs.map +1 -0
  12. package/dist/{client-BrMrhetG.d.mts → client-B_CzDa_I.d.ts} +360 -857
  13. package/dist/{client-BrMrhetG.d.ts → client-F4DnFM8d.d.mts} +360 -857
  14. package/dist/headless.d.mts +109 -0
  15. package/dist/headless.d.ts +109 -0
  16. package/dist/headless.js +467 -0
  17. package/dist/headless.js.map +1 -0
  18. package/dist/headless.mjs +382 -0
  19. package/dist/headless.mjs.map +1 -0
  20. package/dist/index.d.mts +96 -144
  21. package/dist/index.d.ts +96 -144
  22. package/dist/index.js +3212 -756
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +3010 -705
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/{provider-CDl9wYEc.d.mts → provider-Cd7Ip5L-.d.ts} +6 -5
  27. package/dist/{provider-Dgv533YQ.d.ts → provider-IvYXPMpk.d.mts} +6 -5
  28. package/dist/react.d.mts +42 -2
  29. package/dist/react.d.ts +42 -2
  30. package/dist/react.js +92 -2
  31. package/dist/react.js.map +1 -1
  32. package/dist/react.mjs +66 -1
  33. package/dist/react.mjs.map +1 -1
  34. package/dist/server.d.mts +118 -0
  35. package/dist/server.d.ts +118 -0
  36. package/dist/server.js +356 -0
  37. package/dist/server.js.map +1 -0
  38. package/dist/server.mjs +282 -0
  39. package/dist/server.mjs.map +1 -0
  40. package/dist/types-U_dwxbtS.d.mts +1488 -0
  41. package/dist/types-U_dwxbtS.d.ts +1488 -0
  42. package/dist/verify-BLgZzwmJ.d.ts +150 -0
  43. package/dist/verify-C8-a5c3K.d.mts +150 -0
  44. package/dist/wagmi.d.mts +5 -2
  45. package/dist/wagmi.d.ts +5 -2
  46. package/dist/wagmi.js +138 -43
  47. package/dist/wagmi.js.map +1 -1
  48. package/dist/wagmi.mjs +3 -1
  49. package/dist/wagmi.mjs.map +1 -1
  50. package/package.json +15 -2
  51. package/dist/chunk-SXISYG2P.mjs.map +0 -1
@@ -0,0 +1,150 @@
1
+ import { Address, Chain, Transport, Hex } from 'viem';
2
+ import { aa as ThemeConfig, S as SponsorshipConfig, W as WebAuthnSignature } from './types-U_dwxbtS.js';
3
+
4
+ /**
5
+ * Configuration for creating a passkey-enabled WalletClient
6
+ */
7
+ interface PasskeyWalletClientConfig {
8
+ /** User's smart account address */
9
+ accountAddress: Address;
10
+ /** Optional username hint for legacy passkey accounts. */
11
+ username?: string;
12
+ /** Base URL of the auth API (defaults to https://passkey.1auth.box) */
13
+ providerUrl?: string;
14
+ /** Client identifier for this application */
15
+ clientId: string;
16
+ /** Optional URL of the dialog UI */
17
+ dialogUrl?: string;
18
+ /** Theme configuration for the signing dialog */
19
+ theme?: ThemeConfig;
20
+ /**
21
+ * Control whether the 1auth signing review iframe is hidden.
22
+ *
23
+ * Blind signing is the SDK default. Set `blind_signing: false` to opt this
24
+ * wallet-client factory into 1auth's visible review UI globally; individual
25
+ * methods still use the internal OneAuthClient defaults.
26
+ */
27
+ blind_signing?: boolean;
28
+ /** When true, operate on testnet chains only. Default: false */
29
+ testnets?: boolean;
30
+ /** Chain configuration */
31
+ chain: Chain;
32
+ /** Transport (e.g., http(), webSocket()) */
33
+ transport: Transport;
34
+ /** Wait for a transaction hash before resolving send calls. */
35
+ waitForHash?: boolean;
36
+ /** Maximum time to wait for a transaction hash in ms. */
37
+ hashTimeoutMs?: number;
38
+ /** Poll interval for transaction hash in ms. */
39
+ hashIntervalMs?: number;
40
+ /** Sponsorship configuration for app-sponsored intents */
41
+ sponsorship?: SponsorshipConfig;
42
+ }
43
+ /**
44
+ * A single call in a batch transaction
45
+ */
46
+ interface TransactionCall {
47
+ /** Target contract address */
48
+ to: Address;
49
+ /** Calldata to send */
50
+ data?: Hex;
51
+ /** Value in wei to send */
52
+ value?: bigint;
53
+ /** Optional label for the transaction review UI (e.g., "Swap ETH for USDC") */
54
+ label?: string;
55
+ /** Optional sublabel for additional context (e.g., "1 ETH → 2,500 USDC") */
56
+ sublabel?: string;
57
+ /**
58
+ * Optional icon shown in the sign dialog's action card. Falls back to the
59
+ * built-in token icon if 1auth can resolve one for this call. SVG / square
60
+ * PNG URL, or a `data:image/svg+xml,...` URL.
61
+ */
62
+ icon?: string;
63
+ /**
64
+ * Optional ABI for unverified human-readable decoding of `data` in the
65
+ * sign dialog. App-supplied — rendered with an "Unverified" badge.
66
+ * Decoding is best-effort; failures are silently dropped.
67
+ */
68
+ abi?: readonly unknown[];
69
+ }
70
+ /**
71
+ * Parameters for sendCalls (batched transactions)
72
+ */
73
+ interface SendCallsParams {
74
+ /** Array of calls to execute */
75
+ calls: TransactionCall[];
76
+ /** Optional chain id override */
77
+ chainId?: number;
78
+ /** Optional token requests for orchestrator output (what tokens/amounts to deliver) */
79
+ tokenRequests?: {
80
+ token: string;
81
+ amount: bigint;
82
+ }[];
83
+ /** Constrain which tokens the orchestrator can use as input/payment */
84
+ sourceAssets?: string[];
85
+ /** Which chain to look for source assets on */
86
+ sourceChainId?: number;
87
+ }
88
+
89
+ /**
90
+ * Encode a WebAuthn signature for ERC-1271 verification on-chain
91
+ *
92
+ * @param sig - The WebAuthn signature from the passkey
93
+ * @returns ABI-encoded signature bytes
94
+ */
95
+ declare function encodeWebAuthnSignature(sig: WebAuthnSignature): Hex;
96
+ /**
97
+ * Hash an array of transaction calls for signing
98
+ *
99
+ * @param calls - Array of transaction calls
100
+ * @returns keccak256 hash of the encoded calls
101
+ */
102
+ declare function hashCalls(calls: TransactionCall[]): Hex;
103
+
104
+ /**
105
+ * The EIP-191 prefix used for personal message signing.
106
+ * This is the standard Ethereum message prefix for `personal_sign`.
107
+ */
108
+ declare const ETHEREUM_MESSAGE_PREFIX = "\u0019Ethereum Signed Message:\n";
109
+ /**
110
+ * Hash a message with the EIP-191 Ethereum prefix.
111
+ *
112
+ * This is the same hashing function used by the passkey sign dialog.
113
+ * Use this to verify that the `signedHash` returned from `signMessage()`
114
+ * matches your original message.
115
+ *
116
+ * Format: keccak256("\x19Ethereum Signed Message:\n" + len + message)
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * const message = "Sign in to MyApp\nTimestamp: 1234567890";
121
+ * const result = await client.signMessage({ username: 'alice', message });
122
+ *
123
+ * // Verify the hash matches
124
+ * const expectedHash = hashMessage(message);
125
+ * if (result.signedHash === expectedHash) {
126
+ * console.log('Hash matches - signature is for this message');
127
+ * }
128
+ * ```
129
+ */
130
+ declare function hashMessage(message: string): `0x${string}`;
131
+ /**
132
+ * Verify that a signedHash matches the expected message.
133
+ *
134
+ * This is a convenience wrapper around `hashMessage()` that returns
135
+ * a boolean. For full cryptographic verification of the P256 signature,
136
+ * use on-chain verification via the WebAuthn.sol contract.
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * const result = await client.signMessage({ username: 'alice', message });
141
+ *
142
+ * if (result.success && verifyMessageHash(message, result.signedHash)) {
143
+ * // The signature is for this exact message
144
+ * // For full verification, verify the P256 signature on-chain or server-side
145
+ * }
146
+ * ```
147
+ */
148
+ declare function verifyMessageHash(message: string, signedHash: string | undefined): boolean;
149
+
150
+ export { ETHEREUM_MESSAGE_PREFIX as E, type PasskeyWalletClientConfig as P, type SendCallsParams as S, type TransactionCall as T, hashMessage as a, encodeWebAuthnSignature as e, hashCalls as h, verifyMessageHash as v };
@@ -0,0 +1,150 @@
1
+ import { Address, Chain, Transport, Hex } from 'viem';
2
+ import { aa as ThemeConfig, S as SponsorshipConfig, W as WebAuthnSignature } from './types-U_dwxbtS.mjs';
3
+
4
+ /**
5
+ * Configuration for creating a passkey-enabled WalletClient
6
+ */
7
+ interface PasskeyWalletClientConfig {
8
+ /** User's smart account address */
9
+ accountAddress: Address;
10
+ /** Optional username hint for legacy passkey accounts. */
11
+ username?: string;
12
+ /** Base URL of the auth API (defaults to https://passkey.1auth.box) */
13
+ providerUrl?: string;
14
+ /** Client identifier for this application */
15
+ clientId: string;
16
+ /** Optional URL of the dialog UI */
17
+ dialogUrl?: string;
18
+ /** Theme configuration for the signing dialog */
19
+ theme?: ThemeConfig;
20
+ /**
21
+ * Control whether the 1auth signing review iframe is hidden.
22
+ *
23
+ * Blind signing is the SDK default. Set `blind_signing: false` to opt this
24
+ * wallet-client factory into 1auth's visible review UI globally; individual
25
+ * methods still use the internal OneAuthClient defaults.
26
+ */
27
+ blind_signing?: boolean;
28
+ /** When true, operate on testnet chains only. Default: false */
29
+ testnets?: boolean;
30
+ /** Chain configuration */
31
+ chain: Chain;
32
+ /** Transport (e.g., http(), webSocket()) */
33
+ transport: Transport;
34
+ /** Wait for a transaction hash before resolving send calls. */
35
+ waitForHash?: boolean;
36
+ /** Maximum time to wait for a transaction hash in ms. */
37
+ hashTimeoutMs?: number;
38
+ /** Poll interval for transaction hash in ms. */
39
+ hashIntervalMs?: number;
40
+ /** Sponsorship configuration for app-sponsored intents */
41
+ sponsorship?: SponsorshipConfig;
42
+ }
43
+ /**
44
+ * A single call in a batch transaction
45
+ */
46
+ interface TransactionCall {
47
+ /** Target contract address */
48
+ to: Address;
49
+ /** Calldata to send */
50
+ data?: Hex;
51
+ /** Value in wei to send */
52
+ value?: bigint;
53
+ /** Optional label for the transaction review UI (e.g., "Swap ETH for USDC") */
54
+ label?: string;
55
+ /** Optional sublabel for additional context (e.g., "1 ETH → 2,500 USDC") */
56
+ sublabel?: string;
57
+ /**
58
+ * Optional icon shown in the sign dialog's action card. Falls back to the
59
+ * built-in token icon if 1auth can resolve one for this call. SVG / square
60
+ * PNG URL, or a `data:image/svg+xml,...` URL.
61
+ */
62
+ icon?: string;
63
+ /**
64
+ * Optional ABI for unverified human-readable decoding of `data` in the
65
+ * sign dialog. App-supplied — rendered with an "Unverified" badge.
66
+ * Decoding is best-effort; failures are silently dropped.
67
+ */
68
+ abi?: readonly unknown[];
69
+ }
70
+ /**
71
+ * Parameters for sendCalls (batched transactions)
72
+ */
73
+ interface SendCallsParams {
74
+ /** Array of calls to execute */
75
+ calls: TransactionCall[];
76
+ /** Optional chain id override */
77
+ chainId?: number;
78
+ /** Optional token requests for orchestrator output (what tokens/amounts to deliver) */
79
+ tokenRequests?: {
80
+ token: string;
81
+ amount: bigint;
82
+ }[];
83
+ /** Constrain which tokens the orchestrator can use as input/payment */
84
+ sourceAssets?: string[];
85
+ /** Which chain to look for source assets on */
86
+ sourceChainId?: number;
87
+ }
88
+
89
+ /**
90
+ * Encode a WebAuthn signature for ERC-1271 verification on-chain
91
+ *
92
+ * @param sig - The WebAuthn signature from the passkey
93
+ * @returns ABI-encoded signature bytes
94
+ */
95
+ declare function encodeWebAuthnSignature(sig: WebAuthnSignature): Hex;
96
+ /**
97
+ * Hash an array of transaction calls for signing
98
+ *
99
+ * @param calls - Array of transaction calls
100
+ * @returns keccak256 hash of the encoded calls
101
+ */
102
+ declare function hashCalls(calls: TransactionCall[]): Hex;
103
+
104
+ /**
105
+ * The EIP-191 prefix used for personal message signing.
106
+ * This is the standard Ethereum message prefix for `personal_sign`.
107
+ */
108
+ declare const ETHEREUM_MESSAGE_PREFIX = "\u0019Ethereum Signed Message:\n";
109
+ /**
110
+ * Hash a message with the EIP-191 Ethereum prefix.
111
+ *
112
+ * This is the same hashing function used by the passkey sign dialog.
113
+ * Use this to verify that the `signedHash` returned from `signMessage()`
114
+ * matches your original message.
115
+ *
116
+ * Format: keccak256("\x19Ethereum Signed Message:\n" + len + message)
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * const message = "Sign in to MyApp\nTimestamp: 1234567890";
121
+ * const result = await client.signMessage({ username: 'alice', message });
122
+ *
123
+ * // Verify the hash matches
124
+ * const expectedHash = hashMessage(message);
125
+ * if (result.signedHash === expectedHash) {
126
+ * console.log('Hash matches - signature is for this message');
127
+ * }
128
+ * ```
129
+ */
130
+ declare function hashMessage(message: string): `0x${string}`;
131
+ /**
132
+ * Verify that a signedHash matches the expected message.
133
+ *
134
+ * This is a convenience wrapper around `hashMessage()` that returns
135
+ * a boolean. For full cryptographic verification of the P256 signature,
136
+ * use on-chain verification via the WebAuthn.sol contract.
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * const result = await client.signMessage({ username: 'alice', message });
141
+ *
142
+ * if (result.success && verifyMessageHash(message, result.signedHash)) {
143
+ * // The signature is for this exact message
144
+ * // For full verification, verify the P256 signature on-chain or server-side
145
+ * }
146
+ * ```
147
+ */
148
+ declare function verifyMessageHash(message: string, signedHash: string | undefined): boolean;
149
+
150
+ export { ETHEREUM_MESSAGE_PREFIX as E, type PasskeyWalletClientConfig as P, type SendCallsParams as S, type TransactionCall as T, hashMessage as a, encodeWebAuthnSignature as e, hashCalls as h, verifyMessageHash as v };
package/dist/wagmi.d.mts CHANGED
@@ -1,6 +1,9 @@
1
1
  import * as _wagmi_core from '@wagmi/core';
2
- import { O as OneAuthProvider } from './provider-CDl9wYEc.mjs';
3
- import { O as OneAuthClient } from './client-BrMrhetG.mjs';
2
+ import { O as OneAuthProvider } from './provider-IvYXPMpk.mjs';
3
+ import { O as OneAuthClient } from './client-F4DnFM8d.mjs';
4
+ import './types-U_dwxbtS.mjs';
5
+ import 'viem';
6
+ import '@rhinestone/sdk';
4
7
 
5
8
  type OneAuthConnectorOptions = {
6
9
  client: OneAuthClient;
package/dist/wagmi.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import * as _wagmi_core from '@wagmi/core';
2
- import { O as OneAuthProvider } from './provider-Dgv533YQ.js';
3
- import { O as OneAuthClient } from './client-BrMrhetG.js';
2
+ import { O as OneAuthProvider } from './provider-Cd7Ip5L-.js';
3
+ import { O as OneAuthClient } from './client-B_CzDa_I.js';
4
+ import './types-U_dwxbtS.js';
5
+ import 'viem';
6
+ import '@rhinestone/sdk';
4
7
 
5
8
  type OneAuthConnectorOptions = {
6
9
  client: OneAuthClient;
package/dist/wagmi.js CHANGED
@@ -42,7 +42,7 @@ var import_viem3 = require("viem");
42
42
  // src/registry.ts
43
43
  var import_viem = require("viem");
44
44
  var viemChains = __toESM(require("viem/chains"));
45
- var import_sdk = require("@rhinestone/sdk");
45
+ var import_shared_configs = require("@rhinestone/shared-configs");
46
46
  var env = typeof process !== "undefined" ? process.env : {};
47
47
  var VIEM_CHAIN_BY_ID = /* @__PURE__ */ new Map();
48
48
  for (const value of Object.values(viemChains)) {
@@ -53,9 +53,11 @@ for (const value of Object.values(viemChains)) {
53
53
  VIEM_CHAIN_BY_ID.set(chain.id, chain);
54
54
  }
55
55
  }
56
- var SUPPORTED_CHAIN_IDS = new Set(
57
- (0, import_sdk.getAllSupportedChainsAndTokens)().map((entry) => entry.chainId)
58
- );
56
+ function isEvmRegistryEntry(entry) {
57
+ return entry?.vmType === "evm";
58
+ }
59
+ var REGISTRY_CHAIN_IDS = Object.entries(import_shared_configs.chainRegistry).filter(([, entry]) => isEvmRegistryEntry(entry)).map(([id]) => Number(id));
60
+ var SUPPORTED_CHAIN_IDS = new Set(REGISTRY_CHAIN_IDS);
59
61
  function parseBool(value) {
60
62
  if (value === "true" || value === "1") return true;
61
63
  if (value === "false" || value === "0") return false;
@@ -80,7 +82,7 @@ function applyChainFilters(chainIds, options) {
80
82
  return filtered;
81
83
  }
82
84
  function getSupportedChainIds(options) {
83
- return applyChainFilters(Array.from(SUPPORTED_CHAIN_IDS), options);
85
+ return applyChainFilters(REGISTRY_CHAIN_IDS, options);
84
86
  }
85
87
  function getChainById(chainId) {
86
88
  if (!SUPPORTED_CHAIN_IDS.has(chainId)) {
@@ -186,29 +188,20 @@ function createOneAuthProvider(options) {
186
188
  if (stored) {
187
189
  return [stored.address];
188
190
  }
189
- const connectResult = await client.connectWithModal();
190
- let username;
191
- let address;
192
- if (connectResult.success) {
193
- username = connectResult.user?.username;
194
- address = connectResult.user?.address;
195
- } else if (connectResult.action === "switch") {
196
- const authResult = await client.authWithModal();
197
- if (!authResult.success) {
198
- throw new Error(authResult.error?.message || "Authentication failed");
199
- }
200
- username = authResult.user?.username;
201
- address = authResult.user?.address;
202
- } else {
203
- throw new Error(connectResult.error?.message || "Connection cancelled");
191
+ const authResult = await client.authWithModal();
192
+ if (!authResult.success) {
193
+ throw new Error(authResult.error?.message || "Authentication failed");
204
194
  }
195
+ const username = authResult.user?.username;
196
+ let address = authResult.user?.address;
197
+ const signerType = authResult.signerType;
205
198
  if (!address && username) {
206
199
  address = await resolveAccountAddress(username);
207
200
  }
208
201
  if (!address) {
209
202
  throw new Error("No account address available");
210
203
  }
211
- setStoredUser({ username, address });
204
+ setStoredUser({ username, address, signerType });
212
205
  emit("accountsChanged", [address]);
213
206
  emit("connect", { chainId: (0, import_viem3.numberToHex)(chainId) });
214
207
  return [address];
@@ -228,6 +221,22 @@ function createOneAuthProvider(options) {
228
221
  const user = getStoredUser();
229
222
  return user || { address };
230
223
  };
224
+ const getAssetsAccountAddress = (assetsParams) => {
225
+ const raw = Array.isArray(assetsParams) ? assetsParams[0] : assetsParams;
226
+ if (typeof raw === "string" && raw.trim()) return raw.trim();
227
+ if (!raw || typeof raw !== "object") return void 0;
228
+ const request2 = raw;
229
+ const candidates = [
230
+ request2.accountAddress,
231
+ request2.address
232
+ ];
233
+ for (const candidate of candidates) {
234
+ if (typeof candidate === "string" && candidate.trim()) {
235
+ return candidate.trim();
236
+ }
237
+ }
238
+ return void 0;
239
+ };
231
240
  const parseChainId = (value) => {
232
241
  if (typeof value === "number") return value;
233
242
  if (typeof value === "string") {
@@ -257,7 +266,9 @@ function createOneAuthProvider(options) {
257
266
  data: c.data || "0x",
258
267
  value: normalizeValue(c.value) || "0",
259
268
  label: c.label,
260
- sublabel: c.sublabel
269
+ sublabel: c.sublabel,
270
+ icon: c.icon,
271
+ abi: c.abi
261
272
  };
262
273
  });
263
274
  };
@@ -279,13 +290,36 @@ function createOneAuthProvider(options) {
279
290
  return value;
280
291
  }
281
292
  };
293
+ const forwardToWallet = async (method, params, expectedAddress) => {
294
+ const result = await client.requestWithWallet({
295
+ method,
296
+ params,
297
+ expectedAddress
298
+ });
299
+ if (!result.success) {
300
+ const err = new Error(result.error.message);
301
+ err.code = result.error.code;
302
+ throw err;
303
+ }
304
+ return result.result;
305
+ };
306
+ const EOA_FORWARDED_METHODS = /* @__PURE__ */ new Set([
307
+ "personal_sign",
308
+ "eth_sign",
309
+ "eth_signTypedData",
310
+ "eth_signTypedData_v3",
311
+ "eth_signTypedData_v4",
312
+ "eth_sendTransaction",
313
+ "wallet_sendCalls",
314
+ "wallet_getCallsStatus"
315
+ ]);
282
316
  const signMessage = async (message) => {
283
317
  const user = await ensureUser();
284
318
  if (!user.username && !user.address) {
285
319
  throw new Error("Username or address required for signing.");
286
320
  }
287
321
  const result = await client.signMessage({
288
- username: user.username,
322
+ username: user.username || void 0,
289
323
  accountAddress: user.address,
290
324
  message
291
325
  });
@@ -301,7 +335,7 @@ function createOneAuthProvider(options) {
301
335
  }
302
336
  const data = typeof typedData === "string" ? JSON.parse(typedData) : typedData;
303
337
  const result = await client.signTypedData({
304
- username: user.username,
338
+ username: user.username || void 0,
305
339
  accountAddress: user.address,
306
340
  domain: data.domain,
307
341
  types: data.types,
@@ -321,13 +355,12 @@ function createOneAuthProvider(options) {
321
355
  tokenRequests: payload.tokenRequests
322
356
  });
323
357
  const sendIntent = async (payload) => {
324
- const closeOn = options.closeOn ?? (options.waitForHash ?? true ? "completed" : "preconfirmed");
325
358
  const intentPayload = resolveIntentPayload(payload);
326
359
  const result = await client.sendIntent({
327
360
  ...intentPayload,
328
361
  tokenRequests: payload.tokenRequests,
329
362
  sourceChainId: payload.sourceChainId,
330
- closeOn,
363
+ closeOn: options.closeOn,
331
364
  waitForHash: options.waitForHash ?? true,
332
365
  hashTimeoutMs: options.hashTimeoutMs,
333
366
  hashIntervalMs: options.hashIntervalMs
@@ -337,7 +370,70 @@ function createOneAuthProvider(options) {
337
370
  }
338
371
  return result.intentId;
339
372
  };
373
+ const accountMismatchError = () => {
374
+ const err = new Error(
375
+ "Requested signer does not match the active wallet connection."
376
+ );
377
+ err.code = "ACCOUNT_MISMATCH";
378
+ return err;
379
+ };
380
+ const sameAddress = (a, b) => typeof a === "string" && a.toLowerCase() === b.toLowerCase();
381
+ const injectEoaSigner = (method, params, address) => {
382
+ const list = Array.isArray(params) ? params.slice() : params;
383
+ if (!Array.isArray(list)) return params;
384
+ if (method === "eth_sendTransaction") {
385
+ const first = list[0] || {};
386
+ if (first.from !== void 0 && !sameAddress(first.from, address)) {
387
+ throw accountMismatchError();
388
+ }
389
+ list[0] = { ...first, from: address };
390
+ return list;
391
+ }
392
+ if (method === "wallet_sendCalls") {
393
+ const first = list[0] || {};
394
+ if (first.from !== void 0 && !sameAddress(first.from, address)) {
395
+ throw accountMismatchError();
396
+ }
397
+ const calls = first.calls;
398
+ if (Array.isArray(calls)) {
399
+ for (const call of calls) {
400
+ if (!call || typeof call !== "object") continue;
401
+ const callFrom = call.from;
402
+ if (callFrom !== void 0 && !sameAddress(callFrom, address)) {
403
+ throw accountMismatchError();
404
+ }
405
+ }
406
+ }
407
+ list[0] = { ...first, from: address };
408
+ return list;
409
+ }
410
+ if (method === "personal_sign") {
411
+ if (list[1] !== void 0 && !sameAddress(list[1], address)) {
412
+ throw accountMismatchError();
413
+ }
414
+ if (list[0] && list[1] === void 0) list[1] = address;
415
+ return list;
416
+ }
417
+ if (method === "eth_sign" || method === "eth_signTypedData" || method === "eth_signTypedData_v3" || method === "eth_signTypedData_v4") {
418
+ if (list[0] !== void 0 && !sameAddress(list[0], address)) {
419
+ throw accountMismatchError();
420
+ }
421
+ if (list[0] === void 0 && list[1] !== void 0) list[0] = address;
422
+ return list;
423
+ }
424
+ return list;
425
+ };
340
426
  const request = async ({ method, params }) => {
427
+ if (EOA_FORWARDED_METHODS.has(method)) {
428
+ const user = await ensureUser();
429
+ if (user.signerType === "eoa") {
430
+ return forwardToWallet(
431
+ method,
432
+ injectEoaSigner(method, params, user.address),
433
+ user.address
434
+ );
435
+ }
436
+ }
341
437
  switch (method) {
342
438
  case "eth_chainId":
343
439
  return (0, import_viem3.numberToHex)(chainId);
@@ -358,6 +454,10 @@ function createOneAuthProvider(options) {
358
454
  if (!next) {
359
455
  throw new Error("Invalid chainId");
360
456
  }
457
+ const stored = getStoredUser();
458
+ if (stored?.signerType === "eoa") {
459
+ await forwardToWallet(method, params, stored.address);
460
+ }
361
461
  chainId = next;
362
462
  emit("chainChanged", (0, import_viem3.numberToHex)(chainId));
363
463
  return null;
@@ -391,7 +491,7 @@ function createOneAuthProvider(options) {
391
491
  const tokenRequests = normalizeTokenRequests(tx.tokenRequests);
392
492
  const txSourceChainId = parseChainId(tx.sourceChainId);
393
493
  return sendIntent({
394
- username: user.username,
494
+ username: user.username || void 0,
395
495
  accountAddress: user.address,
396
496
  targetChain,
397
497
  calls,
@@ -409,7 +509,7 @@ function createOneAuthProvider(options) {
409
509
  const sourceChainId = parseChainId(payload.sourceChainId);
410
510
  if (!calls.length) throw new Error("No calls provided");
411
511
  return sendIntent({
412
- username: user.username,
512
+ username: user.username || void 0,
413
513
  accountAddress: user.address,
414
514
  targetChain,
415
515
  calls,
@@ -418,6 +518,10 @@ function createOneAuthProvider(options) {
418
518
  });
419
519
  }
420
520
  case "wallet_getCapabilities": {
521
+ const stored = getStoredUser();
522
+ if (stored?.signerType === "eoa") {
523
+ return {};
524
+ }
421
525
  const paramList = Array.isArray(params) ? params : [];
422
526
  const requestedChains = paramList[1];
423
527
  const chainIds = getSupportedChainIds();
@@ -436,22 +540,13 @@ function createOneAuthProvider(options) {
436
540
  return capabilities;
437
541
  }
438
542
  case "wallet_getAssets": {
439
- const user = await ensureUser();
440
- if (!user.username) {
441
- throw new Error("Username required to fetch assets. Set a username first.");
442
- }
443
- const clientId = client.getClientId();
444
- const response = await fetch(
445
- `${client.getProviderUrl()}/api/users/${encodeURIComponent(user.username)}/portfolio`,
446
- {
447
- headers: clientId ? { "x-client-id": clientId } : {}
448
- }
449
- );
450
- if (!response.ok) {
451
- const data = await response.json().catch(() => ({}));
452
- throw new Error(data.error || "Failed to get assets");
543
+ const explicitAccountAddress = getAssetsAccountAddress(params);
544
+ const user = explicitAccountAddress ? null : await ensureUser();
545
+ const accountAddress = explicitAccountAddress || user?.address;
546
+ if (!accountAddress) {
547
+ throw new Error("wallet_getAssets requires accountAddress or a connected account");
453
548
  }
454
- return response.json();
549
+ return client.getAssets({ accountAddress });
455
550
  }
456
551
  case "wallet_getCallsStatus": {
457
552
  const paramList = Array.isArray(params) ? params : [];