@rhinestone/1auth 0.7.4 → 0.7.6

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 (42) hide show
  1. package/dist/{chunk-IHBVEU33.mjs → chunk-6AHEN3FA.mjs} +1 -1
  2. package/dist/chunk-6AHEN3FA.mjs.map +1 -0
  3. package/dist/{chunk-UXBBB7AV.mjs → chunk-E4YZS7FZ.mjs} +68 -32
  4. package/dist/chunk-E4YZS7FZ.mjs.map +1 -0
  5. package/dist/{client-D4HVy1KF.d.mts → client-C8QSA1th.d.mts} +22 -17
  6. package/dist/{client-CuASptX3.d.ts → client-Dn6mL7BZ.d.ts} +22 -17
  7. package/dist/headless.d.mts +2 -2
  8. package/dist/headless.d.ts +2 -2
  9. package/dist/headless.js +4 -6
  10. package/dist/headless.js.map +1 -1
  11. package/dist/headless.mjs +4 -6
  12. package/dist/headless.mjs.map +1 -1
  13. package/dist/index.d.mts +163 -22
  14. package/dist/index.d.ts +163 -22
  15. package/dist/index.js +210 -116
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +143 -86
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/{provider-6JoziYDq.d.ts → provider-BsVmPgkQ.d.ts} +22 -3
  20. package/dist/{provider-CAQT7Gqx.d.mts → provider-CJv38fIK.d.mts} +22 -3
  21. package/dist/react.d.mts +9 -4
  22. package/dist/react.d.ts +9 -4
  23. package/dist/react.js +4 -7
  24. package/dist/react.js.map +1 -1
  25. package/dist/react.mjs +4 -7
  26. package/dist/react.mjs.map +1 -1
  27. package/dist/server.d.mts +2 -2
  28. package/dist/server.d.ts +2 -2
  29. package/dist/server.js.map +1 -1
  30. package/dist/server.mjs +1 -1
  31. package/dist/{types-C0jKNT_t.d.mts → types-Dzm5lZK-.d.mts} +33 -51
  32. package/dist/{types-C0jKNT_t.d.ts → types-Dzm5lZK-.d.ts} +33 -51
  33. package/dist/{verify-CnOwPq78.d.ts → verify-0VXQpQBJ.d.mts} +4 -6
  34. package/dist/{verify-aWdi5O2z.d.mts → verify-9UgxLSdo.d.ts} +4 -6
  35. package/dist/wagmi.d.mts +3 -3
  36. package/dist/wagmi.d.ts +3 -3
  37. package/dist/wagmi.js +67 -31
  38. package/dist/wagmi.js.map +1 -1
  39. package/dist/wagmi.mjs +1 -1
  40. package/package.json +1 -1
  41. package/dist/chunk-IHBVEU33.mjs.map +0 -1
  42. package/dist/chunk-UXBBB7AV.mjs.map +0 -1
package/dist/index.js CHANGED
@@ -35,6 +35,7 @@ __export(index_exports, {
35
35
  ETHEREUM_MESSAGE_PREFIX: () => ETHEREUM_MESSAGE_PREFIX,
36
36
  OneAuthClient: () => OneAuthClient,
37
37
  createCrossChainPermission: () => createCrossChainPermission,
38
+ createOneAuthConnection: () => createOneAuthConnection,
38
39
  createOneAuthProvider: () => createOneAuthProvider,
39
40
  createPasskeyAccount: () => createPasskeyAccount,
40
41
  createPasskeyWalletClient: () => createPasskeyWalletClient,
@@ -53,7 +54,7 @@ __export(index_exports, {
53
54
  getTokenDecimals: () => getTokenDecimals,
54
55
  getTokenSymbol: () => getTokenSymbol,
55
56
  hashCalls: () => hashCalls,
56
- hashMessage: () => hashMessage2,
57
+ hashMessage: () => hashMessage,
57
58
  isTestnet: () => isTestnet,
58
59
  isTokenAddressSupported: () => isTokenAddressSupported,
59
60
  resolveTokenAddress: () => resolveTokenAddress,
@@ -965,7 +966,6 @@ var OneAuthClient = class {
965
966
  * call — the modal shows the appropriate flow based on whether the user
966
967
  * has a passkey registered.
967
968
  *
968
- * @param options.username - Pre-fill the username field
969
969
  * @param options.theme - Override the theme for this modal invocation
970
970
  * @param options.oauthEnabled - Set to false to hide OAuth sign-in buttons
971
971
  * @param options.flow - Force the login or account-creation route instead
@@ -977,7 +977,7 @@ var OneAuthClient = class {
977
977
  * const result = await client.authWithModal();
978
978
  *
979
979
  * if (result.success) {
980
- * console.log('Signed in as:', result.user?.username);
980
+ * console.log('Signed in as:', result.user?.address);
981
981
  * console.log('Address:', result.user?.address); // typed `0x${string}`
982
982
  * } else if (result.error?.code === 'USER_CANCELLED') {
983
983
  * // User closed the modal
@@ -995,7 +995,6 @@ var OneAuthClient = class {
995
995
  * is creating a login session, for example after an app-level "Log in"
996
996
  * button. The result intentionally matches {@link authWithModal}.
997
997
  *
998
- * @param options.username - Optional account hint for the sign-in ceremony
999
998
  * @param options.theme - Override the theme for this modal invocation
1000
999
  * @returns {@link AuthResult} with user details and typed address
1001
1000
  */
@@ -1025,8 +1024,7 @@ var OneAuthClient = class {
1025
1024
  */
1026
1025
  async openAuthModal(options) {
1027
1026
  const telemetry = this.createTelemetryOperation("auth", {
1028
- flow: options?.flow ?? "auto",
1029
- hasUsernameHint: !!options?.username
1027
+ flow: options?.flow ?? "auto"
1030
1028
  });
1031
1029
  const dialogUrl = this.getDialogUrl();
1032
1030
  const requestId = this.createDialogRequestId();
@@ -1037,12 +1035,12 @@ var OneAuthClient = class {
1037
1035
  if (this.config.clientId) {
1038
1036
  params.set("clientId", this.config.clientId);
1039
1037
  }
1040
- if (options?.username) {
1041
- params.set("username", options.username);
1042
- }
1043
1038
  if (options?.oauthEnabled === false) {
1044
1039
  params.set("oauth", "0");
1045
1040
  }
1041
+ if (options?.eoaConnect) {
1042
+ params.set("eoaConnect", "1");
1043
+ }
1046
1044
  if (options?.flow === "create-account") {
1047
1045
  params.set("switch", "1");
1048
1046
  }
@@ -1111,7 +1109,7 @@ var OneAuthClient = class {
1111
1109
  * const result = await client.connectWithModal();
1112
1110
  *
1113
1111
  * if (result.success) {
1114
- * console.log('Connected as:', result.user?.username);
1112
+ * console.log('Connected as:', result.user?.address);
1115
1113
  * } else if (result.action === 'switch') {
1116
1114
  * // User needs to sign in first
1117
1115
  * const authResult = await client.authWithModal();
@@ -1196,14 +1194,14 @@ var OneAuthClient = class {
1196
1194
  * `{ success: false, action: "cancel", error: { code: "USER_CANCELLED", … } }`.
1197
1195
  *
1198
1196
  * @param options - Forwarded to whichever underlying modal is shown.
1199
- * `username` and `oauthEnabled` only apply to the auth-modal fallback path.
1197
+ * `oauthEnabled` only applies to the auth-modal fallback path.
1200
1198
  * @returns A {@link ConnectResult} discriminated union.
1201
1199
  *
1202
1200
  * @example
1203
1201
  * ```typescript
1204
1202
  * const result = await client.connect();
1205
1203
  * if (result.success) {
1206
- * console.log("Connected as", result.user?.username ?? result.user?.address);
1204
+ * console.log("Connected as", result.user?.address);
1207
1205
  * }
1208
1206
  * ```
1209
1207
  */
@@ -1218,9 +1216,12 @@ var OneAuthClient = class {
1218
1216
  return {
1219
1217
  success: true,
1220
1218
  user: {
1221
- username: authResult.user.username,
1222
1219
  address: authResult.user.address
1223
1220
  },
1221
+ // Preserve the signer type from the auth modal — a wallet-picked
1222
+ // (EOA) signup must not be silently normalized to "passkey", or the
1223
+ // provider would route its transactions through intents.
1224
+ signerType: authResult.signerType ?? "passkey",
1224
1225
  autoConnected: false
1225
1226
  };
1226
1227
  }
@@ -1388,17 +1389,17 @@ var OneAuthClient = class {
1388
1389
  targetChains: normalizeGrantTargetChains(options).join(","),
1389
1390
  sponsor: options.sponsor !== false
1390
1391
  });
1391
- if (!options.username && !options.accountAddress) {
1392
+ if (!options.accountAddress) {
1392
1393
  this.emitTelemetry("grant_permission.failed", telemetry, {
1393
1394
  outcome: "failure",
1394
1395
  errorCode: "INVALID_OPTIONS",
1395
- errorMessage: "Either username or accountAddress is required"
1396
+ errorMessage: "accountAddress is required"
1396
1397
  });
1397
1398
  return {
1398
1399
  success: false,
1399
1400
  error: {
1400
1401
  code: "INVALID_OPTIONS",
1401
- message: "Either username or accountAddress is required"
1402
+ message: "accountAddress is required"
1402
1403
  }
1403
1404
  };
1404
1405
  }
@@ -1462,7 +1463,6 @@ var OneAuthClient = class {
1462
1463
  mode: "iframe",
1463
1464
  clientId: this.config.clientId,
1464
1465
  grant: cloneGrantPayload({
1465
- username: options.username,
1466
1466
  accountAddress: options.accountAddress,
1467
1467
  targetChain: targetChains[0],
1468
1468
  targetChains,
@@ -1517,17 +1517,16 @@ var OneAuthClient = class {
1517
1517
  * not send `clientId` for this lookup because grants are origin-scoped.
1518
1518
  */
1519
1519
  async listSessionGrants(options) {
1520
- if (!options.username && !options.accountAddress) {
1520
+ if (!options.accountAddress) {
1521
1521
  return {
1522
1522
  success: false,
1523
1523
  error: {
1524
1524
  code: "INVALID_OPTIONS",
1525
- message: "Either username or accountAddress is required"
1525
+ message: "accountAddress is required"
1526
1526
  }
1527
1527
  };
1528
1528
  }
1529
1529
  const params = new URLSearchParams();
1530
- if (options.username) params.set("username", options.username);
1531
1530
  if (options.accountAddress) params.set("accountAddress", options.accountAddress);
1532
1531
  if (options.includeRevoked) params.set("includeRevoked", "true");
1533
1532
  try {
@@ -1580,7 +1579,7 @@ var OneAuthClient = class {
1580
1579
  * if (result.success && result.challenge) {
1581
1580
  * // Verify signature server-side
1582
1581
  * const isValid = await verifyOnServer(
1583
- * result.user?.username,
1582
+ * result.user?.address,
1584
1583
  * result.challenge.signature,
1585
1584
  * result.challenge.signedHash
1586
1585
  * );
@@ -1611,15 +1610,14 @@ var OneAuthClient = class {
1611
1610
  return authResult;
1612
1611
  }
1613
1612
  const accountAddress = authResult.user?.address;
1614
- const username = authResult.user?.username;
1615
- if (!accountAddress && !username) {
1613
+ if (!accountAddress) {
1616
1614
  const result2 = {
1617
1615
  success: false,
1618
1616
  user: authResult.user,
1619
1617
  signerType: authResult.signerType,
1620
1618
  error: {
1621
1619
  code: "AUTHENTICATE_USER_MISSING",
1622
- message: "Authentication succeeded but no username or account address was returned for challenge signing"
1620
+ message: "Authentication succeeded but no account address was returned for challenge signing"
1623
1621
  }
1624
1622
  };
1625
1623
  this.emitTelemetry("auth.failed", telemetry, {
@@ -1629,7 +1627,6 @@ var OneAuthClient = class {
1629
1627
  return result2;
1630
1628
  }
1631
1629
  const signResult = await this.signMessage({
1632
- username,
1633
1630
  accountAddress,
1634
1631
  message: options.challenge,
1635
1632
  description: "Verify your identity",
@@ -1697,7 +1694,6 @@ var OneAuthClient = class {
1697
1694
  const ready = await this.waitForDialogReady(dialog, iframe, cleanup, {
1698
1695
  mode: "iframe",
1699
1696
  challenge: options.challenge,
1700
- username: options.username,
1701
1697
  accountAddress: options.accountAddress,
1702
1698
  description: options.description,
1703
1699
  transaction: options.transaction,
@@ -1749,7 +1745,7 @@ var OneAuthClient = class {
1749
1745
  * @example
1750
1746
  * ```typescript
1751
1747
  * const result = await client.sendIntent({
1752
- * username: 'alice',
1748
+ * accountAddress: '0x...',
1753
1749
  * targetChain: 8453, // Base
1754
1750
  * calls: [
1755
1751
  * {
@@ -1767,7 +1763,7 @@ var OneAuthClient = class {
1767
1763
  * ```
1768
1764
  */
1769
1765
  async sendIntent(options) {
1770
- const { username, accountAddress, targetChain } = options;
1766
+ const { accountAddress, targetChain } = options;
1771
1767
  const calls = capCallLabels(options.calls);
1772
1768
  const sponsor = options.sponsor !== false;
1773
1769
  const telemetry = this.createTelemetryOperation("intent", {
@@ -1792,11 +1788,11 @@ var OneAuthClient = class {
1792
1788
  }
1793
1789
  };
1794
1790
  }
1795
- if (!username && !accountAddress) {
1791
+ if (!accountAddress) {
1796
1792
  this.emitTelemetry("intent.completed", telemetry, {
1797
1793
  outcome: "failure",
1798
1794
  errorCode: "INVALID_OPTIONS",
1799
- errorMessage: "Either username or accountAddress is required"
1795
+ errorMessage: "accountAddress is required"
1800
1796
  });
1801
1797
  return {
1802
1798
  success: false,
@@ -1804,7 +1800,7 @@ var OneAuthClient = class {
1804
1800
  status: "failed",
1805
1801
  error: {
1806
1802
  code: "INVALID_OPTIONS",
1807
- message: "Either username or accountAddress is required"
1803
+ message: "accountAddress is required"
1808
1804
  }
1809
1805
  };
1810
1806
  }
@@ -1954,7 +1950,6 @@ var OneAuthClient = class {
1954
1950
  }
1955
1951
  let accessToken = accessTokenResult.ok ? accessTokenResult.accessToken : "";
1956
1952
  const requestBody = {
1957
- username,
1958
1953
  accountAddress,
1959
1954
  targetChain,
1960
1955
  calls,
@@ -2196,7 +2191,6 @@ var OneAuthClient = class {
2196
2191
  chainId: targetChain,
2197
2192
  transaction: prepareResponse.transaction,
2198
2193
  challenge: prepareResponse.challenge,
2199
- username,
2200
2194
  accountAddress: prepareResponse.accountAddress,
2201
2195
  originMessages: prepareResponse.originMessages,
2202
2196
  tokenRequests: serializedTokenRequests,
@@ -2251,7 +2245,6 @@ var OneAuthClient = class {
2251
2245
  signingMode: "transaction",
2252
2246
  calls,
2253
2247
  chainId: targetChain,
2254
- username,
2255
2248
  accountAddress: options.accountAddress,
2256
2249
  tokenRequests: serializedTokenRequests,
2257
2250
  telemetry: this.telemetryPayload(telemetry)
@@ -2327,7 +2320,6 @@ var OneAuthClient = class {
2327
2320
  chainId: targetChain,
2328
2321
  transaction: prepareResponse.transaction,
2329
2322
  challenge: prepareResponse.challenge,
2330
- username,
2331
2323
  accountAddress: prepareResponse.accountAddress,
2332
2324
  originMessages: prepareResponse.originMessages,
2333
2325
  tokenRequests: serializedTokenRequests,
@@ -2722,7 +2714,7 @@ var OneAuthClient = class {
2722
2714
  * @example
2723
2715
  * ```typescript
2724
2716
  * const result = await client.sendBatchIntent({
2725
- * username: 'alice',
2717
+ * accountAddress: '0x...',
2726
2718
  * intents: [
2727
2719
  * {
2728
2720
  * targetChain: 8453, // Base
@@ -2759,11 +2751,11 @@ var OneAuthClient = class {
2759
2751
  error: "Batch intents are not supported for EOA sessions. Use the connected wallet's native RPC instead."
2760
2752
  };
2761
2753
  }
2762
- if (!options.username && !options.accountAddress) {
2754
+ if (!options.accountAddress) {
2763
2755
  this.emitTelemetry("batch.completed", telemetry, {
2764
2756
  outcome: "failure",
2765
2757
  errorCode: "INVALID_OPTIONS",
2766
- errorMessage: "Either username or accountAddress is required"
2758
+ errorMessage: "accountAddress is required"
2767
2759
  });
2768
2760
  return {
2769
2761
  success: false,
@@ -2828,7 +2820,6 @@ var OneAuthClient = class {
2828
2820
  moduleInstall: intent.moduleInstall
2829
2821
  }));
2830
2822
  const requestBody = {
2831
- ...options.username && { username: options.username },
2832
2823
  ...options.accountAddress && { accountAddress: options.accountAddress },
2833
2824
  intents: serializedIntents,
2834
2825
  auth: { accessToken },
@@ -2954,7 +2945,6 @@ var OneAuthClient = class {
2954
2945
  batchFailedIntents: prepareResponse.failedIntents,
2955
2946
  challenge: prepareResponse.challenge,
2956
2947
  binding: prepareResponse.binding,
2957
- username: options.username,
2958
2948
  accountAddress: prepareResponse.accountAddress,
2959
2949
  userId: prepareResponse.userId,
2960
2950
  expiresAt: prepareResponse.expiresAt,
@@ -2973,7 +2963,6 @@ var OneAuthClient = class {
2973
2963
  calls: JSON.stringify(intent.calls)
2974
2964
  // No: transaction, intentOp, expiresAt, originMessages
2975
2965
  })),
2976
- username: options.username,
2977
2966
  accountAddress: options.accountAddress,
2978
2967
  telemetry: this.telemetryPayload(telemetry)
2979
2968
  };
@@ -2998,7 +2987,6 @@ var OneAuthClient = class {
2998
2987
  batchFailedIntents: prepareResponse.failedIntents,
2999
2988
  challenge: prepareResponse.challenge,
3000
2989
  binding: prepareResponse.binding,
3001
- username: options.username,
3002
2990
  accountAddress: prepareResponse.accountAddress,
3003
2991
  userId: prepareResponse.userId,
3004
2992
  expiresAt: prepareResponse.expiresAt,
@@ -4050,7 +4038,7 @@ var OneAuthClient = class {
4050
4038
  * ```typescript
4051
4039
  * // Sign a login challenge
4052
4040
  * const result = await client.signMessage({
4053
- * username: 'alice',
4041
+ * accountAddress: '0x...',
4054
4042
  * message: `Sign in to MyApp\nTimestamp: ${Date.now()}\nNonce: ${crypto.randomUUID()}`,
4055
4043
  * description: 'Verify your identity to continue',
4056
4044
  * });
@@ -4112,7 +4100,6 @@ var OneAuthClient = class {
4112
4100
  mode: "iframe",
4113
4101
  message: options.message,
4114
4102
  challenge: options.challenge || options.message,
4115
- username: options.username,
4116
4103
  accountAddress: options.accountAddress,
4117
4104
  description: options.description,
4118
4105
  metadata: options.metadata,
@@ -4172,7 +4159,7 @@ var OneAuthClient = class {
4172
4159
  * ```typescript
4173
4160
  * // Sign an ERC-2612 Permit
4174
4161
  * const result = await client.signTypedData({
4175
- * username: 'alice',
4162
+ * accountAddress: '0x...',
4176
4163
  * domain: {
4177
4164
  * name: 'Dai Stablecoin',
4178
4165
  * version: '1',
@@ -4261,7 +4248,6 @@ var OneAuthClient = class {
4261
4248
  message: options.message
4262
4249
  },
4263
4250
  challenge: signedHash,
4264
- username: options.username,
4265
4251
  accountAddress: options.accountAddress,
4266
4252
  description: options.description,
4267
4253
  telemetry: this.telemetryPayload(telemetry)
@@ -4526,11 +4512,14 @@ var OneAuthClient = class {
4526
4512
  return this.fetchSigningResult(requestId);
4527
4513
  }
4528
4514
  /**
4529
- * Fetch passkeys for a user from the auth provider
4515
+ * Fetch passkeys for a user from the auth provider.
4516
+ *
4517
+ * The account address is the sole identity; the backend `resolveUserWhere`
4518
+ * accepts an address as a globally-unique path identifier.
4530
4519
  */
4531
- async getPasskeys(username) {
4520
+ async getPasskeys(accountAddress) {
4532
4521
  const response = await fetch(
4533
- `${this.config.providerUrl}/api/users/${encodeURIComponent(username)}/passkeys`,
4522
+ `${this.config.providerUrl}/api/users/${encodeURIComponent(accountAddress)}/passkeys`,
4534
4523
  {
4535
4524
  headers: this.config.clientId ? { "x-client-id": this.config.clientId } : {}
4536
4525
  }
@@ -4551,7 +4540,7 @@ var OneAuthClient = class {
4551
4540
  * them by `requestId` without relying on URL parameters alone. This avoids
4552
4541
  * exposing potentially large challenge payloads in query strings.
4553
4542
  *
4554
- * @param options - The signing options (challenge, username, description, etc.).
4543
+ * @param options - The signing options (challenge, accountAddress, description, etc.).
4555
4544
  * @param mode - How the dialog will be opened (`"popup"`, `"redirect"`, or `"embed"`).
4556
4545
  * @param redirectUrl - Only required for `"redirect"` mode; the URL the dialog
4557
4546
  * will navigate back to after signing.
@@ -4568,7 +4557,6 @@ var OneAuthClient = class {
4568
4557
  },
4569
4558
  body: JSON.stringify({
4570
4559
  ...this.config.clientId && { clientId: this.config.clientId },
4571
- username: options.username,
4572
4560
  accountAddress: options.accountAddress,
4573
4561
  challenge: options.challenge,
4574
4562
  description: options.description,
@@ -4896,6 +4884,7 @@ var OneAuthClient = class {
4896
4884
  iframe.setAttribute(
4897
4885
  "allow",
4898
4886
  [
4887
+ "payment",
4899
4888
  `publickey-credentials-get ${hostUrl.origin}`,
4900
4889
  `publickey-credentials-create ${hostUrl.origin}`,
4901
4890
  "clipboard-write",
@@ -5060,7 +5049,6 @@ var OneAuthClient = class {
5060
5049
  success: true,
5061
5050
  user: {
5062
5051
  id: data.data?.user?.id,
5063
- username: data.data?.username,
5064
5052
  address: data.data?.address
5065
5053
  },
5066
5054
  signerType: data.data?.signerType ?? "passkey"
@@ -5114,7 +5102,6 @@ var OneAuthClient = class {
5114
5102
  success: true,
5115
5103
  user: {
5116
5104
  id: data.data?.user?.id,
5117
- username: data.data?.username,
5118
5105
  address: data.data?.address
5119
5106
  },
5120
5107
  signerType: data.data?.signerType ?? "passkey"
@@ -5146,7 +5133,7 @@ var OneAuthClient = class {
5146
5133
  *
5147
5134
  * The connect flow is a lightweight "are you still you?" confirmation that
5148
5135
  * does not require a new passkey ceremony. On success, the dialog returns the
5149
- * user's username, address, and an `autoConnected` flag indicating whether the
5136
+ * user's address and an `autoConnected` flag indicating whether the
5150
5137
  * user had previously enabled auto-connect (in which case no UI was shown).
5151
5138
  *
5152
5139
  * On failure with `action: "switch"`, the caller should redirect to the full
@@ -5170,9 +5157,12 @@ var OneAuthClient = class {
5170
5157
  resolve({
5171
5158
  success: true,
5172
5159
  user: {
5173
- username: data.data?.username,
5174
5160
  address: data.data?.address
5175
5161
  },
5162
+ // Carry the signer type through so the SDK/provider can route EOA
5163
+ // sessions to the connected wallet (plain tx, no intents) instead
5164
+ // of defaulting to passkey intents. Absent = legacy passkey.
5165
+ signerType: data.data?.signerType ?? "passkey",
5176
5166
  autoConnected: data.data?.autoConnected
5177
5167
  });
5178
5168
  } else {
@@ -5616,12 +5606,14 @@ function createOneAuthProvider(options) {
5616
5606
  let chainId = options.chainId;
5617
5607
  const storageKey = options.storageKey || DEFAULT_STORAGE_KEY;
5618
5608
  const listeners = /* @__PURE__ */ new Map();
5609
+ let sessionOverride;
5619
5610
  const emit = (event, ...args) => {
5620
5611
  const set = listeners.get(event);
5621
5612
  if (!set) return;
5622
5613
  for (const listener of set) listener(...args);
5623
5614
  };
5624
5615
  const getStoredUser = () => {
5616
+ if (sessionOverride !== void 0) return sessionOverride;
5625
5617
  if (typeof window === "undefined") return null;
5626
5618
  try {
5627
5619
  const raw = localStorage.getItem(storageKey);
@@ -5641,21 +5633,6 @@ function createOneAuthProvider(options) {
5641
5633
  if (typeof window === "undefined") return;
5642
5634
  localStorage.removeItem(storageKey);
5643
5635
  };
5644
- const resolveAccountAddress = async (username) => {
5645
- const clientId = client.getClientId();
5646
- const response = await fetch(
5647
- `${client.getProviderUrl()}/api/users/${encodeURIComponent(username)}/account`,
5648
- {
5649
- headers: clientId ? { "x-client-id": clientId } : {}
5650
- }
5651
- );
5652
- if (!response.ok) {
5653
- const data2 = await response.json().catch(() => ({}));
5654
- throw new Error(data2.error || "Failed to resolve account address");
5655
- }
5656
- const data = await response.json();
5657
- return data.address;
5658
- };
5659
5636
  const connect = async () => {
5660
5637
  const stored = getStoredUser();
5661
5638
  if (stored) {
@@ -5665,25 +5642,39 @@ function createOneAuthProvider(options) {
5665
5642
  if (!authResult.success) {
5666
5643
  throw new Error(authResult.error?.message || "Authentication failed");
5667
5644
  }
5668
- const username = authResult.user?.username;
5669
- let address = authResult.user?.address;
5645
+ const address = authResult.user?.address;
5670
5646
  const signerType = authResult.signerType;
5671
- if (!address && username) {
5672
- address = await resolveAccountAddress(username);
5673
- }
5674
5647
  if (!address) {
5675
5648
  throw new Error("No account address available");
5676
5649
  }
5677
- setStoredUser({ username, address, signerType });
5650
+ setStoredUser({ address, signerType });
5678
5651
  emit("accountsChanged", [address]);
5679
5652
  emit("connect", { chainId: (0, import_viem5.numberToHex)(chainId) });
5680
5653
  return [address];
5681
5654
  };
5682
5655
  const disconnect = async () => {
5656
+ sessionOverride = void 0;
5683
5657
  clearStoredUser();
5684
5658
  emit("accountsChanged", []);
5685
5659
  emit("disconnect");
5686
5660
  };
5661
+ const setSession = (session) => {
5662
+ if (!session) {
5663
+ sessionOverride = void 0;
5664
+ clearStoredUser();
5665
+ emit("accountsChanged", []);
5666
+ emit("disconnect");
5667
+ return;
5668
+ }
5669
+ sessionOverride = {
5670
+ address: session.address,
5671
+ signerType: session.signerType,
5672
+ connectorId: session.connectorId
5673
+ };
5674
+ setStoredUser(sessionOverride);
5675
+ emit("accountsChanged", [session.address]);
5676
+ emit("connect", { chainId: (0, import_viem5.numberToHex)(chainId) });
5677
+ };
5687
5678
  const ensureUser = async () => {
5688
5679
  const stored = getStoredUser();
5689
5680
  if (stored) return stored;
@@ -5788,11 +5779,10 @@ function createOneAuthProvider(options) {
5788
5779
  ]);
5789
5780
  const signMessage = async (message) => {
5790
5781
  const user = await ensureUser();
5791
- if (!user.username && !user.address) {
5792
- throw new Error("Username or address required for signing.");
5782
+ if (!user.address) {
5783
+ throw new Error("Account address required for signing.");
5793
5784
  }
5794
5785
  const result = await client.signMessage({
5795
- username: user.username || void 0,
5796
5786
  accountAddress: user.address,
5797
5787
  message
5798
5788
  });
@@ -5803,12 +5793,11 @@ function createOneAuthProvider(options) {
5803
5793
  };
5804
5794
  const signTypedData = async (typedData) => {
5805
5795
  const user = await ensureUser();
5806
- if (!user.username && !user.address) {
5807
- throw new Error("Username or address required for signing.");
5796
+ if (!user.address) {
5797
+ throw new Error("Account address required for signing.");
5808
5798
  }
5809
5799
  const data = typeof typedData === "string" ? JSON.parse(typedData) : typedData;
5810
5800
  const result = await client.signTypedData({
5811
- username: user.username || void 0,
5812
5801
  accountAddress: user.address,
5813
5802
  domain: data.domain,
5814
5803
  types: data.types,
@@ -5821,7 +5810,6 @@ function createOneAuthProvider(options) {
5821
5810
  return encodeWebAuthnSignature(result.signature);
5822
5811
  };
5823
5812
  const resolveIntentPayload = (payload) => ({
5824
- username: payload.username,
5825
5813
  accountAddress: payload.accountAddress,
5826
5814
  targetChain: payload.targetChain,
5827
5815
  calls: payload.calls,
@@ -5896,10 +5884,49 @@ function createOneAuthProvider(options) {
5896
5884
  }
5897
5885
  return list;
5898
5886
  };
5887
+ const eoaBatches = /* @__PURE__ */ new Map();
5888
+ const sendCallsEoa = async (params, address) => {
5889
+ const validated = injectEoaSigner("wallet_sendCalls", params, address);
5890
+ const payload = Array.isArray(validated) ? validated[0] : {};
5891
+ const calls = Array.isArray(payload.calls) ? payload.calls : [];
5892
+ if (!calls.length) throw new Error("No calls provided");
5893
+ const batchChainId = payload.chainId;
5894
+ const hashes = [];
5895
+ for (const raw of calls) {
5896
+ const call = raw || {};
5897
+ const tx = { from: address, to: call.to };
5898
+ if (call.data !== void 0) tx.data = call.data;
5899
+ if (call.value !== void 0) tx.value = call.value;
5900
+ const callChain = call.chainId ?? batchChainId;
5901
+ if (callChain !== void 0) tx.chainId = callChain;
5902
+ const hash = await forwardToWallet("eth_sendTransaction", [tx], address);
5903
+ hashes.push(String(hash));
5904
+ }
5905
+ const id = hashes[hashes.length - 1];
5906
+ eoaBatches.set(id, hashes);
5907
+ return id;
5908
+ };
5909
+ const getCallsStatusEoa = (callsId) => {
5910
+ if (!callsId || typeof callsId !== "string") {
5911
+ throw new Error("callsId is required");
5912
+ }
5913
+ const hashes = eoaBatches.get(callsId) ?? [callsId];
5914
+ return {
5915
+ status: "CONFIRMED",
5916
+ receipts: hashes.map((transactionHash) => ({ transactionHash }))
5917
+ };
5918
+ };
5899
5919
  const request = async ({ method, params }) => {
5900
5920
  if (EOA_FORWARDED_METHODS.has(method)) {
5901
5921
  const user = await ensureUser();
5902
5922
  if (user.signerType === "eoa") {
5923
+ if (method === "wallet_sendCalls") {
5924
+ return sendCallsEoa(params, user.address);
5925
+ }
5926
+ if (method === "wallet_getCallsStatus") {
5927
+ const list = Array.isArray(params) ? params : [];
5928
+ return getCallsStatusEoa(list[0]);
5929
+ }
5903
5930
  return forwardToWallet(
5904
5931
  method,
5905
5932
  injectEoaSigner(method, params, user.address),
@@ -5964,7 +5991,6 @@ function createOneAuthProvider(options) {
5964
5991
  const tokenRequests = normalizeTokenRequests(tx.tokenRequests);
5965
5992
  const txSourceChainId = parseChainId(tx.sourceChainId);
5966
5993
  return sendIntent({
5967
- username: user.username || void 0,
5968
5994
  accountAddress: user.address,
5969
5995
  targetChain,
5970
5996
  calls,
@@ -5982,7 +6008,6 @@ function createOneAuthProvider(options) {
5982
6008
  const sourceChainId = parseChainId(payload.sourceChainId);
5983
6009
  if (!calls.length) throw new Error("No calls provided");
5984
6010
  return sendIntent({
5985
- username: user.username || void 0,
5986
6011
  accountAddress: user.address,
5987
6012
  targetChain,
5988
6013
  calls,
@@ -6118,15 +6143,97 @@ function createOneAuthProvider(options) {
6118
6143
  set.delete(listener);
6119
6144
  if (set.size === 0) listeners.delete(event);
6120
6145
  },
6121
- disconnect
6146
+ disconnect,
6147
+ setSession
6122
6148
  };
6123
6149
  }
6124
6150
 
6151
+ // src/connection.ts
6152
+ var DEFAULT_CHAIN_ID = 8453;
6153
+ function readStoredSession(storageKey, provider, chainId) {
6154
+ if (typeof window === "undefined") return null;
6155
+ try {
6156
+ const raw = localStorage.getItem(storageKey);
6157
+ if (!raw) return null;
6158
+ const parsed = JSON.parse(raw);
6159
+ if (!parsed?.address) return null;
6160
+ return {
6161
+ // Absent signerType = legacy passkey session (backwards compatible).
6162
+ signerType: parsed.signerType === "eoa" ? "eoa" : "passkey",
6163
+ address: parsed.address,
6164
+ provider,
6165
+ chainId,
6166
+ autoConnected: false
6167
+ };
6168
+ } catch {
6169
+ return null;
6170
+ }
6171
+ }
6172
+ function createOneAuthConnection(config) {
6173
+ const {
6174
+ defaultChainId,
6175
+ storageKey: storageKeyOption,
6176
+ closeOn,
6177
+ waitForHash,
6178
+ hashTimeoutMs,
6179
+ hashIntervalMs,
6180
+ eoaConnect: eoaConnectConfig,
6181
+ ...clientConfig
6182
+ } = config;
6183
+ const client = "client" in config && config.client ? config.client : new OneAuthClient(clientConfig);
6184
+ const chainId = defaultChainId ?? DEFAULT_CHAIN_ID;
6185
+ const storageKey = storageKeyOption ?? "1auth-user";
6186
+ const provider = createOneAuthProvider({
6187
+ client,
6188
+ chainId,
6189
+ storageKey,
6190
+ closeOn,
6191
+ waitForHash,
6192
+ hashTimeoutMs,
6193
+ hashIntervalMs
6194
+ });
6195
+ const getSession = () => readStoredSession(storageKey, provider, chainId);
6196
+ const connect = async (options) => {
6197
+ const eoaConnect = options?.eoaConnect ?? eoaConnectConfig ?? false;
6198
+ const result = await client.connect({ ...options, eoaConnect });
6199
+ if (!result.success || !result.user?.address) {
6200
+ const error = result.error ?? {
6201
+ code: "USER_CANCELLED",
6202
+ message: "Connection was cancelled"
6203
+ };
6204
+ throw Object.assign(new Error(error.message), { code: error.code });
6205
+ }
6206
+ const signerType = result.signerType === "eoa" ? "eoa" : "passkey";
6207
+ provider.setSession({ address: result.user.address, signerType });
6208
+ return {
6209
+ signerType,
6210
+ address: result.user.address,
6211
+ provider,
6212
+ chainId,
6213
+ autoConnected: result.autoConnected ?? false
6214
+ };
6215
+ };
6216
+ const disconnect = async () => {
6217
+ await provider.disconnect();
6218
+ };
6219
+ const subscribe = (listener) => {
6220
+ const onAccountsChanged = (...args) => {
6221
+ const accounts = args[0];
6222
+ listener(
6223
+ accounts && accounts.length > 0 ? getSession() : null
6224
+ );
6225
+ };
6226
+ provider.on("accountsChanged", onAccountsChanged);
6227
+ return () => provider.removeListener("accountsChanged", onAccountsChanged);
6228
+ };
6229
+ return { client, provider, connect, getSession, disconnect, subscribe };
6230
+ }
6231
+
6125
6232
  // src/account.ts
6126
6233
  var import_viem6 = require("viem");
6127
6234
  var import_accounts = require("viem/accounts");
6128
6235
  function createPasskeyAccount(client, params) {
6129
- const { address, username } = params;
6236
+ const { address } = params;
6130
6237
  const normalizeMessage = (message) => {
6131
6238
  if (typeof message === "string") return message;
6132
6239
  const raw = message.raw;
@@ -6143,7 +6250,6 @@ function createPasskeyAccount(client, params) {
6143
6250
  address,
6144
6251
  signMessage: async ({ message }) => {
6145
6252
  const result = await client.signMessage({
6146
- username: username || void 0,
6147
6253
  accountAddress: address,
6148
6254
  message: normalizeMessage(message)
6149
6255
  });
@@ -6179,7 +6285,6 @@ function createPasskeyAccount(client, params) {
6179
6285
  ])
6180
6286
  );
6181
6287
  const result = await client.signTypedData({
6182
- username: username || void 0,
6183
6288
  accountAddress: address,
6184
6289
  domain,
6185
6290
  types: normalizedTypes,
@@ -6194,7 +6299,6 @@ function createPasskeyAccount(client, params) {
6194
6299
  });
6195
6300
  return {
6196
6301
  ...account,
6197
- ...username ? { username } : {},
6198
6302
  accountAddress: address
6199
6303
  };
6200
6304
  }
@@ -6202,9 +6306,12 @@ function createPasskeyAccount(client, params) {
6202
6306
  // src/walletClient/index.ts
6203
6307
  var import_viem7 = require("viem");
6204
6308
  var import_accounts2 = require("viem/accounts");
6309
+ function formatSignableMessage(message) {
6310
+ if (typeof message === "string") return message;
6311
+ return typeof message.raw === "string" ? message.raw : (0, import_viem7.toHex)(message.raw);
6312
+ }
6205
6313
  function createPasskeyWalletClient(config) {
6206
6314
  const identity = {
6207
- ...config.username ? { username: config.username } : {},
6208
6315
  accountAddress: config.accountAddress
6209
6316
  };
6210
6317
  const provider = new OneAuthClient({
@@ -6217,20 +6324,10 @@ function createPasskeyWalletClient(config) {
6217
6324
  sponsorship: config.sponsorship
6218
6325
  });
6219
6326
  const signMessageImpl = async (message) => {
6220
- const hash = (0, import_viem7.hashMessage)(message);
6221
- const result = await provider.signWithModal({
6222
- challenge: hash,
6327
+ const result = await provider.signMessage({
6223
6328
  ...identity,
6224
- description: "Sign message",
6225
- transaction: {
6226
- actions: [
6227
- {
6228
- type: "custom",
6229
- label: "Sign Message",
6230
- sublabel: typeof message === "string" ? message.slice(0, 50) + (message.length > 50 ? "..." : "") : "Raw message"
6231
- }
6232
- ]
6233
- }
6329
+ message: formatSignableMessage(message),
6330
+ description: "Sign message"
6234
6331
  });
6235
6332
  if (!result.success) {
6236
6333
  throw new Error(result.error?.message || "Signing failed");
@@ -6299,7 +6396,6 @@ function createPasskeyWalletClient(config) {
6299
6396
  abi: call.abi
6300
6397
  }));
6301
6398
  return {
6302
- ...config.username ? { username: config.username } : {},
6303
6399
  accountAddress: config.accountAddress,
6304
6400
  targetChain,
6305
6401
  calls: intentCalls
@@ -6383,21 +6479,19 @@ function generateId() {
6383
6479
  return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
6384
6480
  }
6385
6481
  function getStorageKey(identity) {
6386
- const key = identity?.accountAddress || identity?.username;
6482
+ const key = identity?.accountAddress;
6387
6483
  return key ? `1auth_batch_queue_${key.toLowerCase()}` : "1auth_batch_queue_anonymous";
6388
6484
  }
6389
6485
  function resolveIdentity(passedIdentity, providerIdentity) {
6390
6486
  if (typeof passedIdentity === "string") {
6391
- return { username: passedIdentity, accountAddress: providerIdentity.accountAddress };
6487
+ return { accountAddress: passedIdentity };
6392
6488
  }
6393
6489
  return {
6394
- username: passedIdentity?.username ?? providerIdentity.username,
6395
6490
  accountAddress: passedIdentity?.accountAddress ?? providerIdentity.accountAddress
6396
6491
  };
6397
6492
  }
6398
6493
  function BatchQueueProvider({
6399
6494
  client,
6400
- username,
6401
6495
  accountAddress,
6402
6496
  children
6403
6497
  }) {
@@ -6406,8 +6500,8 @@ function BatchQueueProvider({
6406
6500
  const [isSigning, setIsSigning] = React.useState(false);
6407
6501
  const [animationTrigger, setAnimationTrigger] = React.useState(0);
6408
6502
  const providerIdentity = React.useMemo(
6409
- () => ({ username, accountAddress }),
6410
- [username, accountAddress]
6503
+ () => ({ accountAddress }),
6504
+ [accountAddress]
6411
6505
  );
6412
6506
  const batchChainId = queue.length > 0 ? queue[0].targetChain : null;
6413
6507
  React.useEffect(() => {
@@ -6473,14 +6567,14 @@ function BatchQueueProvider({
6473
6567
  };
6474
6568
  }
6475
6569
  const signer = resolveIdentity(identity, providerIdentity);
6476
- if (!signer.username && !signer.accountAddress) {
6570
+ if (!signer.accountAddress) {
6477
6571
  return {
6478
6572
  success: false,
6479
6573
  intentId: "",
6480
6574
  status: "failed",
6481
6575
  error: {
6482
6576
  code: "MISSING_IDENTITY",
6483
- message: "Batch signing requires an accountAddress or username"
6577
+ message: "Batch signing requires an accountAddress"
6484
6578
  }
6485
6579
  };
6486
6580
  }
@@ -6489,7 +6583,6 @@ function BatchQueueProvider({
6489
6583
  setIsSigning(true);
6490
6584
  try {
6491
6585
  const result = await client.sendIntent({
6492
- username: signer.username,
6493
6586
  accountAddress: signer.accountAddress,
6494
6587
  targetChain,
6495
6588
  calls
@@ -6823,14 +6916,14 @@ function BatchQueueWidget({ onSignAll }) {
6823
6916
  // src/verify.ts
6824
6917
  var import_viem8 = require("viem");
6825
6918
  var ETHEREUM_MESSAGE_PREFIX = "Ethereum Signed Message:\n";
6826
- function hashMessage2(message) {
6919
+ function hashMessage(message) {
6827
6920
  const messageBytes = (0, import_viem8.toBytes)(message);
6828
6921
  const prefixed = ETHEREUM_MESSAGE_PREFIX + messageBytes.length.toString() + message;
6829
6922
  return (0, import_viem8.keccak256)((0, import_viem8.toBytes)(prefixed));
6830
6923
  }
6831
6924
  function verifyMessageHash(message, signedHash) {
6832
6925
  if (!signedHash) return false;
6833
- const expectedHash = hashMessage2(message);
6926
+ const expectedHash = hashMessage(message);
6834
6927
  return expectedHash.toLowerCase() === signedHash.toLowerCase();
6835
6928
  }
6836
6929
  // Annotate the CommonJS export names for ESM import in node:
@@ -6840,6 +6933,7 @@ function verifyMessageHash(message, signedHash) {
6840
6933
  ETHEREUM_MESSAGE_PREFIX,
6841
6934
  OneAuthClient,
6842
6935
  createCrossChainPermission,
6936
+ createOneAuthConnection,
6843
6937
  createOneAuthProvider,
6844
6938
  createPasskeyAccount,
6845
6939
  createPasskeyWalletClient,