@rhinestone/1auth 0.7.5 → 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.
- package/dist/{chunk-6MUQKHAT.mjs → chunk-E4YZS7FZ.mjs} +62 -2
- package/dist/chunk-E4YZS7FZ.mjs.map +1 -0
- package/dist/{client-C9mcj5jN.d.ts → client-C8QSA1th.d.mts} +6 -1
- package/dist/{client-BqKAd2RZ.d.mts → client-Dn6mL7BZ.d.ts} +6 -1
- package/dist/headless.d.mts +2 -2
- package/dist/headless.d.ts +2 -2
- package/dist/index.d.mts +157 -7
- package/dist/index.d.ts +157 -7
- package/dist/index.js +166 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +104 -16
- package/dist/index.mjs.map +1 -1
- package/dist/{provider-CCyUBseo.d.ts → provider-BsVmPgkQ.d.ts} +21 -2
- package/dist/{provider-CRhZVLg8.d.mts → provider-CJv38fIK.d.mts} +21 -2
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/{types-CbhPRY5s.d.mts → types-Dzm5lZK-.d.mts} +10 -1
- package/dist/{types-CbhPRY5s.d.ts → types-Dzm5lZK-.d.ts} +10 -1
- package/dist/{verify-DPJR_foR.d.ts → verify-0VXQpQBJ.d.mts} +1 -1
- package/dist/{verify-DVYDJgOS.d.mts → verify-9UgxLSdo.d.ts} +1 -1
- package/dist/wagmi.d.mts +3 -3
- package/dist/wagmi.d.ts +3 -3
- package/dist/wagmi.js +61 -1
- package/dist/wagmi.js.map +1 -1
- package/dist/wagmi.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-6MUQKHAT.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { O as OneAuthClient } from './client-
|
|
1
|
+
import { O as OneAuthClient } from './client-Dn6mL7BZ.js';
|
|
2
2
|
import { Abi, Address, LocalAccount, WalletClient, Hash } from 'viem';
|
|
3
3
|
import { Permission } from '@rhinestone/sdk';
|
|
4
4
|
export { Permission } from '@rhinestone/sdk';
|
|
5
|
-
import { h as
|
|
6
|
-
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
import { P as PasskeyProviderConfig, C as CloseOnStatus, T as ThemeConfig, h as SignerType, i as IntentCall, j as SendIntentResult } from './types-Dzm5lZK-.js';
|
|
6
|
+
export { a8 as AssetBalance, a9 as AssetBalanceBucket, aa as AssetsResponse, w as AuthFlow, A as AuthResult, x as AuthWithModalOptions, B as AuthenticateOptions, D as AuthenticateResult, X as BalanceRequirement, ap as BatchIntentItem, as as BatchIntentItemResult, ad as CheckConsentOptions, ae as CheckConsentResult, z as ConnectResult, ac as ConsentData, ab as ConsentField, y as CreateAccountWithModalOptions, l as CreateCrossChainPermissionInput, t as CreateSigningRequestResponse, m as CrossChainPermit, n as CrossChainSettlementLayer, N as EIP712Domain, Q as EIP712TypeField, O as EIP712Types, E as EmbedOptions, a3 as ExecuteIntentResponse, a7 as GetAssetsOptions, an as GrantPermissionContractMetadata, ah as GrantPermissionsOptions, ai as GrantPermissionsResult, a5 as IntentHistoryItem, a4 as IntentHistoryOptions, a6 as IntentHistoryResult, $ as IntentQuote, a0 as IntentStatus, Z as IntentTokenRequest, aj as ListSessionGrantsOptions, ak as ListSessionGrantsResult, L as LoginWithModalOptions, ax as OneAuthTelemetryAttributeValue, ay as OneAuthTelemetryAttributes, az as OneAuthTelemetryConfig, aA as OneAuthTelemetryEvent, aB as OneAuthTelemetryEventName, aC as OneAuthTelemetryFlow, aD as OneAuthTelemetryTraceContext, a1 as OrchestratorStatus, v as PasskeyCredential, au as PrepareBatchIntentResponse, a2 as PrepareIntentResponse, at as PreparedBatchIntent, af as RequestConsentOptions, ag as RequestConsentResult, aq as SendBatchIntentOptions, ar as SendBatchIntentResult, _ as SendIntentOptions, am as SessionGrantChain, al as SessionGrantRecord, G as SignMessageOptions, J as SignMessageResult, K as SignTypedDataOptions, M as SignTypedDataResult, r as SigningError, s as SigningErrorCode, o as SigningRequestOptions, u as SigningRequestStatus, p as SigningResult, F as SigningResultBase, q as SigningSuccess, ao as SmartSessionPolicy, av as SponsorshipCallbackConfig, S as SponsorshipConfig, aw as SponsorshipUrlConfig, R as TransactionAction, Y as TransactionDetails, V as TransactionFees, U as UserPasskeysResponse, W as WebAuthnSignature, k as createCrossChainPermission } from './types-Dzm5lZK-.js';
|
|
7
|
+
import { O as OneAuthProvider } from './provider-BsVmPgkQ.js';
|
|
8
|
+
export { a as OneAuthProviderOptions, c as createOneAuthProvider } from './provider-BsVmPgkQ.js';
|
|
9
|
+
import { P as PasskeyWalletClientConfig, S as SendCallsParams } from './verify-9UgxLSdo.js';
|
|
10
|
+
export { C as ChainFilterOptions, E as ETHEREUM_MESSAGE_PREFIX, p as TokenConfig, T as TransactionCall, e as encodeWebAuthnSignature, b as getAllSupportedChainsAndTokens, f as getChainById, i as getChainExplorerUrl, j as getChainRpcUrl, g as getSupportedChainIds, a as getSupportedChains, d as getSupportedTokenSymbols, c as getSupportedTokens, l as getTokenAddress, n as getTokenDecimals, m as getTokenSymbol, h as hashCalls, q as hashMessage, k as isTestnet, o as isTokenAddressSupported, r as resolveTokenAddress, v as verifyMessageHash } from './verify-9UgxLSdo.js';
|
|
10
11
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
11
12
|
import * as React from 'react';
|
|
12
13
|
|
|
@@ -67,6 +68,155 @@ interface DefinedPermissions<TAbi extends Abi = Abi> {
|
|
|
67
68
|
*/
|
|
68
69
|
declare function definePermissions<const TAbi extends Abi>(config: DefinePermissionsConfig<TAbi>): DefinedPermissions<TAbi>;
|
|
69
70
|
|
|
71
|
+
/**
|
|
72
|
+
* One-call connect entry point for 1auth.
|
|
73
|
+
*
|
|
74
|
+
* `createOneAuthConnection` is the ergonomic front door for integrators who
|
|
75
|
+
* want a single function that:
|
|
76
|
+
* 1. opens the 1auth dialog so the user picks **1auth passkey** *or* a
|
|
77
|
+
* **traditional wallet** (WalletConnect / injected), and
|
|
78
|
+
* 2. hands back a ready-to-use EIP-1193 provider plus the connected
|
|
79
|
+
* `{ address, signerType }`.
|
|
80
|
+
*
|
|
81
|
+
* When the user picks a traditional wallet (an EOA), the returned provider
|
|
82
|
+
* forwards `eth_sendTransaction` / `personal_sign` / `signTypedData` /
|
|
83
|
+
* `wallet_sendCalls` straight to that wallet's native RPC — **no Rhinestone
|
|
84
|
+
* intents**. When they pick a passkey, transactions route through 1auth intents
|
|
85
|
+
* exactly as before. The app writes one downstream code path either way.
|
|
86
|
+
*
|
|
87
|
+
* This is purely additive: `OneAuthClient.connect()` and
|
|
88
|
+
* `createOneAuthProvider()` are unchanged and remain the lower-level building
|
|
89
|
+
* blocks this factory composes.
|
|
90
|
+
*
|
|
91
|
+
* @module
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Provider-shaping options that apply on top of the passkey client config.
|
|
96
|
+
* Mirrors the relevant {@link createOneAuthProvider} options.
|
|
97
|
+
*/
|
|
98
|
+
interface OneAuthConnectionOptions {
|
|
99
|
+
/**
|
|
100
|
+
* Chain the returned provider reports via `eth_chainId` and uses as the
|
|
101
|
+
* default intent target. Defaults to `8453` (Base). Ignored for EOA sessions
|
|
102
|
+
* beyond the reported chain id — an EOA transacts on whatever chain its
|
|
103
|
+
* wallet is on.
|
|
104
|
+
*/
|
|
105
|
+
defaultChainId?: number;
|
|
106
|
+
/**
|
|
107
|
+
* localStorage key the session is persisted under. Defaults to `"1auth-user"`.
|
|
108
|
+
* Override only to run multiple independent connections on one origin.
|
|
109
|
+
*/
|
|
110
|
+
storageKey?: string;
|
|
111
|
+
/** Forwarded to the provider for passkey intent sends. */
|
|
112
|
+
closeOn?: CloseOnStatus;
|
|
113
|
+
waitForHash?: boolean;
|
|
114
|
+
hashTimeoutMs?: number;
|
|
115
|
+
hashIntervalMs?: number;
|
|
116
|
+
/**
|
|
117
|
+
* Opt in to offering a **traditional wallet as the account signer**. When
|
|
118
|
+
* `true`, the dialog's wallet path connects the chosen EOA as the signer (a
|
|
119
|
+
* `signerType: "eoa"` session whose transactions bypass Rhinestone intents).
|
|
120
|
+
*
|
|
121
|
+
* **Defaults to `false`** — by default the app gets 1auth smart accounts +
|
|
122
|
+
* intents, and the wallet path (if the user picks it) still bootstraps a
|
|
123
|
+
* passkey account. Passkey selection is unaffected either way. Can be
|
|
124
|
+
* overridden per call via {@link OneAuthConnectOptions.eoaConnect}.
|
|
125
|
+
*/
|
|
126
|
+
eoaConnect?: boolean;
|
|
127
|
+
}
|
|
128
|
+
/** Full config form: constructs the client for you. Only `clientId` is practically required. */
|
|
129
|
+
type OneAuthConnectionConfig = PasskeyProviderConfig & OneAuthConnectionOptions;
|
|
130
|
+
/** Reuse form: bring your own configured {@link OneAuthClient}. */
|
|
131
|
+
type OneAuthConnectionConfigWithClient = {
|
|
132
|
+
client: OneAuthClient;
|
|
133
|
+
} & OneAuthConnectionOptions;
|
|
134
|
+
/** Options accepted by {@link OneAuthConnection.connect}. */
|
|
135
|
+
interface OneAuthConnectOptions {
|
|
136
|
+
theme?: ThemeConfig;
|
|
137
|
+
/** Applies only to the auth-modal fallback path (email/OAuth entry). */
|
|
138
|
+
oauthEnabled?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Per-call override of {@link OneAuthConnectionOptions.eoaConnect}. Defaults
|
|
141
|
+
* to the connection's config value (which itself defaults to `false`).
|
|
142
|
+
*/
|
|
143
|
+
eoaConnect?: boolean;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The resolved session. Discriminated on `signerType` so callers can branch on
|
|
147
|
+
* EOA vs passkey with full type safety.
|
|
148
|
+
*/
|
|
149
|
+
interface OneAuthSession {
|
|
150
|
+
/** `"eoa"` = traditional wallet (plain tx, no intents). `"passkey"` = 1auth smart account (intents). */
|
|
151
|
+
signerType: SignerType;
|
|
152
|
+
address: `0x${string}`;
|
|
153
|
+
/** The same {@link OneAuthProvider} instance exposed on the connection. */
|
|
154
|
+
provider: OneAuthProvider;
|
|
155
|
+
/** Chain id the provider reports (see {@link OneAuthConnectionOptions.defaultChainId}). */
|
|
156
|
+
chainId: number;
|
|
157
|
+
/** True when a returning user was reconnected with no visible UI. */
|
|
158
|
+
autoConnected: boolean;
|
|
159
|
+
}
|
|
160
|
+
/** Error thrown by {@link OneAuthConnection.connect} when the user cancels or auth fails. */
|
|
161
|
+
interface OneAuthConnectError {
|
|
162
|
+
code: string;
|
|
163
|
+
message: string;
|
|
164
|
+
}
|
|
165
|
+
/** The handle returned by {@link createOneAuthConnection}. */
|
|
166
|
+
interface OneAuthConnection {
|
|
167
|
+
/** The underlying client — escape hatch for `signMessage`, history, the account dialog, etc. */
|
|
168
|
+
client: OneAuthClient;
|
|
169
|
+
/** Ready-to-use EIP-1193 provider. Stable across reconnects. */
|
|
170
|
+
provider: OneAuthProvider;
|
|
171
|
+
/**
|
|
172
|
+
* Open the 1auth dialog so the user picks passkey OR a traditional wallet.
|
|
173
|
+
* Binds the resulting session to {@link OneAuthConnection.provider} before it
|
|
174
|
+
* resolves, so a send issued immediately after routes correctly.
|
|
175
|
+
*
|
|
176
|
+
* @throws {@link OneAuthConnectError} shape (`{ code, message }`) on cancel/failure.
|
|
177
|
+
*/
|
|
178
|
+
connect: (options?: OneAuthConnectOptions) => Promise<OneAuthSession>;
|
|
179
|
+
/** Current session read from persisted state, or `null`. Never opens a dialog. */
|
|
180
|
+
getSession: () => OneAuthSession | null;
|
|
181
|
+
/** Clear the session and emit `accountsChanged([])` / `disconnect`. */
|
|
182
|
+
disconnect: () => Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* Subscribe to session changes (connect/disconnect). Returns an unsubscribe
|
|
185
|
+
* function. Sugar over `provider.on("accountsChanged", …)`.
|
|
186
|
+
*/
|
|
187
|
+
subscribe: (listener: (session: OneAuthSession | null) => void) => () => void;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Create a one-call 1auth connection.
|
|
191
|
+
*
|
|
192
|
+
* @example Zero-boilerplate
|
|
193
|
+
* ```typescript
|
|
194
|
+
* import { createOneAuthConnection } from "@rhinestone/1auth";
|
|
195
|
+
* import { createWalletClient, custom } from "viem";
|
|
196
|
+
* import { base } from "viem/chains";
|
|
197
|
+
*
|
|
198
|
+
* const conn = createOneAuthConnection({ clientId: "my-app" });
|
|
199
|
+
* const session = await conn.connect(); // user picks passkey OR wallet
|
|
200
|
+
*
|
|
201
|
+
* const walletClient = createWalletClient({
|
|
202
|
+
* account: session.address,
|
|
203
|
+
* chain: base,
|
|
204
|
+
* transport: custom(session.provider),
|
|
205
|
+
* });
|
|
206
|
+
* // Same call for both signer types; EOA bypasses intents, passkey uses them.
|
|
207
|
+
* await walletClient.sendTransaction({ to: "0x…", value: 1n });
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
210
|
+
* @example Reuse an existing client
|
|
211
|
+
* ```typescript
|
|
212
|
+
* const client = new OneAuthClient({ clientId: "my-app", sponsorship });
|
|
213
|
+
* const conn = createOneAuthConnection({ client, defaultChainId: 8453 });
|
|
214
|
+
* const { address, signerType, provider } = await conn.connect();
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
declare function createOneAuthConnection(config: OneAuthConnectionConfig): OneAuthConnection;
|
|
218
|
+
declare function createOneAuthConnection(config: OneAuthConnectionConfigWithClient): OneAuthConnection;
|
|
219
|
+
|
|
70
220
|
/**
|
|
71
221
|
* viem LocalAccount adapter for 1auth passkey-controlled smart accounts.
|
|
72
222
|
*
|
|
@@ -280,4 +430,4 @@ interface BatchQueueWidgetProps {
|
|
|
280
430
|
*/
|
|
281
431
|
declare function BatchQueueWidget({ onSignAll }: BatchQueueWidgetProps): react_jsx_runtime.JSX.Element | null;
|
|
282
432
|
|
|
283
|
-
export { type BatchQueueContextValue, type BatchQueueIdentity, BatchQueueProvider, type BatchQueueProviderProps, BatchQueueWidget, type BatchQueueWidgetProps, type BatchedCall, type DefinePermissionsConfig, type DefinedPermissions, IntentCall, OneAuthClient, type PasskeyAccount, type PasskeyWalletClient, PasskeyWalletClientConfig, SendCallsParams, SendIntentResult, createPasskeyAccount, createPasskeyWalletClient, definePermissions, getChainName, useBatchQueue };
|
|
433
|
+
export { type BatchQueueContextValue, type BatchQueueIdentity, BatchQueueProvider, type BatchQueueProviderProps, BatchQueueWidget, type BatchQueueWidgetProps, type BatchedCall, CloseOnStatus, type DefinePermissionsConfig, type DefinedPermissions, IntentCall, OneAuthClient, type OneAuthConnectError, type OneAuthConnectOptions, type OneAuthConnection, type OneAuthConnectionConfig, type OneAuthConnectionConfigWithClient, type OneAuthConnectionOptions, OneAuthProvider, type OneAuthSession, type PasskeyAccount, PasskeyProviderConfig, type PasskeyWalletClient, PasskeyWalletClientConfig, SendCallsParams, SendIntentResult, SignerType, ThemeConfig, createOneAuthConnection, createPasskeyAccount, createPasskeyWalletClient, definePermissions, getChainName, useBatchQueue };
|
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: () =>
|
|
57
|
+
hashMessage: () => hashMessage,
|
|
57
58
|
isTestnet: () => isTestnet,
|
|
58
59
|
isTokenAddressSupported: () => isTokenAddressSupported,
|
|
59
60
|
resolveTokenAddress: () => resolveTokenAddress,
|
|
@@ -1037,6 +1038,9 @@ var OneAuthClient = class {
|
|
|
1037
1038
|
if (options?.oauthEnabled === false) {
|
|
1038
1039
|
params.set("oauth", "0");
|
|
1039
1040
|
}
|
|
1041
|
+
if (options?.eoaConnect) {
|
|
1042
|
+
params.set("eoaConnect", "1");
|
|
1043
|
+
}
|
|
1040
1044
|
if (options?.flow === "create-account") {
|
|
1041
1045
|
params.set("switch", "1");
|
|
1042
1046
|
}
|
|
@@ -1214,6 +1218,10 @@ var OneAuthClient = class {
|
|
|
1214
1218
|
user: {
|
|
1215
1219
|
address: authResult.user.address
|
|
1216
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",
|
|
1217
1225
|
autoConnected: false
|
|
1218
1226
|
};
|
|
1219
1227
|
}
|
|
@@ -4876,6 +4884,7 @@ var OneAuthClient = class {
|
|
|
4876
4884
|
iframe.setAttribute(
|
|
4877
4885
|
"allow",
|
|
4878
4886
|
[
|
|
4887
|
+
"payment",
|
|
4879
4888
|
`publickey-credentials-get ${hostUrl.origin}`,
|
|
4880
4889
|
`publickey-credentials-create ${hostUrl.origin}`,
|
|
4881
4890
|
"clipboard-write",
|
|
@@ -5150,6 +5159,10 @@ var OneAuthClient = class {
|
|
|
5150
5159
|
user: {
|
|
5151
5160
|
address: data.data?.address
|
|
5152
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",
|
|
5153
5166
|
autoConnected: data.data?.autoConnected
|
|
5154
5167
|
});
|
|
5155
5168
|
} else {
|
|
@@ -5593,12 +5606,14 @@ function createOneAuthProvider(options) {
|
|
|
5593
5606
|
let chainId = options.chainId;
|
|
5594
5607
|
const storageKey = options.storageKey || DEFAULT_STORAGE_KEY;
|
|
5595
5608
|
const listeners = /* @__PURE__ */ new Map();
|
|
5609
|
+
let sessionOverride;
|
|
5596
5610
|
const emit = (event, ...args) => {
|
|
5597
5611
|
const set = listeners.get(event);
|
|
5598
5612
|
if (!set) return;
|
|
5599
5613
|
for (const listener of set) listener(...args);
|
|
5600
5614
|
};
|
|
5601
5615
|
const getStoredUser = () => {
|
|
5616
|
+
if (sessionOverride !== void 0) return sessionOverride;
|
|
5602
5617
|
if (typeof window === "undefined") return null;
|
|
5603
5618
|
try {
|
|
5604
5619
|
const raw = localStorage.getItem(storageKey);
|
|
@@ -5638,10 +5653,28 @@ function createOneAuthProvider(options) {
|
|
|
5638
5653
|
return [address];
|
|
5639
5654
|
};
|
|
5640
5655
|
const disconnect = async () => {
|
|
5656
|
+
sessionOverride = void 0;
|
|
5641
5657
|
clearStoredUser();
|
|
5642
5658
|
emit("accountsChanged", []);
|
|
5643
5659
|
emit("disconnect");
|
|
5644
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
|
+
};
|
|
5645
5678
|
const ensureUser = async () => {
|
|
5646
5679
|
const stored = getStoredUser();
|
|
5647
5680
|
if (stored) return stored;
|
|
@@ -5851,10 +5884,49 @@ function createOneAuthProvider(options) {
|
|
|
5851
5884
|
}
|
|
5852
5885
|
return list;
|
|
5853
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
|
+
};
|
|
5854
5919
|
const request = async ({ method, params }) => {
|
|
5855
5920
|
if (EOA_FORWARDED_METHODS.has(method)) {
|
|
5856
5921
|
const user = await ensureUser();
|
|
5857
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
|
+
}
|
|
5858
5930
|
return forwardToWallet(
|
|
5859
5931
|
method,
|
|
5860
5932
|
injectEoaSigner(method, params, user.address),
|
|
@@ -6071,10 +6143,92 @@ function createOneAuthProvider(options) {
|
|
|
6071
6143
|
set.delete(listener);
|
|
6072
6144
|
if (set.size === 0) listeners.delete(event);
|
|
6073
6145
|
},
|
|
6074
|
-
disconnect
|
|
6146
|
+
disconnect,
|
|
6147
|
+
setSession
|
|
6075
6148
|
};
|
|
6076
6149
|
}
|
|
6077
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
|
+
|
|
6078
6232
|
// src/account.ts
|
|
6079
6233
|
var import_viem6 = require("viem");
|
|
6080
6234
|
var import_accounts = require("viem/accounts");
|
|
@@ -6152,6 +6306,10 @@ function createPasskeyAccount(client, params) {
|
|
|
6152
6306
|
// src/walletClient/index.ts
|
|
6153
6307
|
var import_viem7 = require("viem");
|
|
6154
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
|
+
}
|
|
6155
6313
|
function createPasskeyWalletClient(config) {
|
|
6156
6314
|
const identity = {
|
|
6157
6315
|
accountAddress: config.accountAddress
|
|
@@ -6166,20 +6324,10 @@ function createPasskeyWalletClient(config) {
|
|
|
6166
6324
|
sponsorship: config.sponsorship
|
|
6167
6325
|
});
|
|
6168
6326
|
const signMessageImpl = async (message) => {
|
|
6169
|
-
const
|
|
6170
|
-
const result = await provider.signWithModal({
|
|
6171
|
-
challenge: hash,
|
|
6327
|
+
const result = await provider.signMessage({
|
|
6172
6328
|
...identity,
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
actions: [
|
|
6176
|
-
{
|
|
6177
|
-
type: "custom",
|
|
6178
|
-
label: "Sign Message",
|
|
6179
|
-
sublabel: typeof message === "string" ? message.slice(0, 50) + (message.length > 50 ? "..." : "") : "Raw message"
|
|
6180
|
-
}
|
|
6181
|
-
]
|
|
6182
|
-
}
|
|
6329
|
+
message: formatSignableMessage(message),
|
|
6330
|
+
description: "Sign message"
|
|
6183
6331
|
});
|
|
6184
6332
|
if (!result.success) {
|
|
6185
6333
|
throw new Error(result.error?.message || "Signing failed");
|
|
@@ -6768,14 +6916,14 @@ function BatchQueueWidget({ onSignAll }) {
|
|
|
6768
6916
|
// src/verify.ts
|
|
6769
6917
|
var import_viem8 = require("viem");
|
|
6770
6918
|
var ETHEREUM_MESSAGE_PREFIX = "Ethereum Signed Message:\n";
|
|
6771
|
-
function
|
|
6919
|
+
function hashMessage(message) {
|
|
6772
6920
|
const messageBytes = (0, import_viem8.toBytes)(message);
|
|
6773
6921
|
const prefixed = ETHEREUM_MESSAGE_PREFIX + messageBytes.length.toString() + message;
|
|
6774
6922
|
return (0, import_viem8.keccak256)((0, import_viem8.toBytes)(prefixed));
|
|
6775
6923
|
}
|
|
6776
6924
|
function verifyMessageHash(message, signedHash) {
|
|
6777
6925
|
if (!signedHash) return false;
|
|
6778
|
-
const expectedHash =
|
|
6926
|
+
const expectedHash = hashMessage(message);
|
|
6779
6927
|
return expectedHash.toLowerCase() === signedHash.toLowerCase();
|
|
6780
6928
|
}
|
|
6781
6929
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -6785,6 +6933,7 @@ function verifyMessageHash(message, signedHash) {
|
|
|
6785
6933
|
ETHEREUM_MESSAGE_PREFIX,
|
|
6786
6934
|
OneAuthClient,
|
|
6787
6935
|
createCrossChainPermission,
|
|
6936
|
+
createOneAuthConnection,
|
|
6788
6937
|
createOneAuthProvider,
|
|
6789
6938
|
createPasskeyAccount,
|
|
6790
6939
|
createPasskeyWalletClient,
|