@rhinestone/1auth 0.1.2 → 0.5.0
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-TACK3LJN.mjs → chunk-N4BLW5UR.mjs} +49 -25
- package/dist/chunk-N4BLW5UR.mjs.map +1 -0
- package/dist/{client-DyYGKWj3.d.mts → client-Di8SBnPO.d.mts} +242 -85
- package/dist/{client-DyYGKWj3.d.ts → client-Di8SBnPO.d.ts} +242 -85
- package/dist/index.d.mts +5 -9
- package/dist/index.d.ts +5 -9
- package/dist/index.js +559 -178
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +513 -155
- package/dist/index.mjs.map +1 -1
- package/dist/{provider-CNTZPPFz.d.ts → provider-8anOtc87.d.mts} +2 -8
- package/dist/{provider-Ctr7HQHR.d.mts → provider-CFnLQt5m.d.ts} +2 -8
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +16 -9
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +16 -9
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +2 -5
- package/dist/server.d.ts +2 -5
- package/dist/server.js +2 -2
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +2 -2
- package/dist/server.mjs.map +1 -1
- package/dist/wagmi.d.mts +2 -2
- package/dist/wagmi.d.ts +2 -2
- package/dist/wagmi.js +48 -23
- package/dist/wagmi.js.map +1 -1
- package/dist/wagmi.mjs +3 -3
- package/dist/wagmi.mjs.map +1 -1
- package/package.json +7 -6
- package/dist/chunk-TACK3LJN.mjs.map +0 -1
package/dist/wagmi.js
CHANGED
|
@@ -44,12 +44,15 @@ var import_viem = require("viem");
|
|
|
44
44
|
var viemChains = __toESM(require("viem/chains"));
|
|
45
45
|
var import_sdk = require("@rhinestone/sdk");
|
|
46
46
|
var env = typeof process !== "undefined" ? process.env : {};
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
)
|
|
47
|
+
var VIEM_CHAIN_BY_ID = /* @__PURE__ */ new Map();
|
|
48
|
+
for (const value of Object.values(viemChains)) {
|
|
49
|
+
if (typeof value !== "object" || value === null || !("id" in value) || !("name" in value)) continue;
|
|
50
|
+
const chain = value;
|
|
51
|
+
const existing = VIEM_CHAIN_BY_ID.get(chain.id);
|
|
52
|
+
if (!existing || existing.testnet && !chain.testnet) {
|
|
53
|
+
VIEM_CHAIN_BY_ID.set(chain.id, chain);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
53
56
|
var SUPPORTED_CHAIN_IDS = new Set(
|
|
54
57
|
(0, import_sdk.getAllSupportedChainsAndTokens)().map((entry) => entry.chainId)
|
|
55
58
|
);
|
|
@@ -149,7 +152,7 @@ function createOneAuthProvider(options) {
|
|
|
149
152
|
const raw = localStorage.getItem(storageKey);
|
|
150
153
|
if (!raw) return null;
|
|
151
154
|
const parsed = JSON.parse(raw);
|
|
152
|
-
if (!parsed?.
|
|
155
|
+
if (!parsed?.address) return null;
|
|
153
156
|
return parsed;
|
|
154
157
|
} catch {
|
|
155
158
|
return null;
|
|
@@ -185,18 +188,26 @@ function createOneAuthProvider(options) {
|
|
|
185
188
|
}
|
|
186
189
|
const connectResult = await client.connectWithModal();
|
|
187
190
|
let username;
|
|
188
|
-
|
|
189
|
-
|
|
191
|
+
let address;
|
|
192
|
+
if (connectResult.success) {
|
|
193
|
+
username = connectResult.user?.username;
|
|
194
|
+
address = connectResult.user?.address;
|
|
190
195
|
} else if (connectResult.action === "switch") {
|
|
191
196
|
const authResult = await client.authWithModal();
|
|
192
|
-
if (!authResult.success
|
|
197
|
+
if (!authResult.success) {
|
|
193
198
|
throw new Error(authResult.error?.message || "Authentication failed");
|
|
194
199
|
}
|
|
195
|
-
username = authResult.username;
|
|
200
|
+
username = authResult.user?.username;
|
|
201
|
+
address = authResult.user?.address;
|
|
196
202
|
} else {
|
|
197
203
|
throw new Error(connectResult.error?.message || "Connection cancelled");
|
|
198
204
|
}
|
|
199
|
-
|
|
205
|
+
if (!address && username) {
|
|
206
|
+
address = await resolveAccountAddress(username);
|
|
207
|
+
}
|
|
208
|
+
if (!address) {
|
|
209
|
+
throw new Error("No account address available");
|
|
210
|
+
}
|
|
200
211
|
setStoredUser({ username, address });
|
|
201
212
|
emit("accountsChanged", [address]);
|
|
202
213
|
emit("connect", { chainId: (0, import_viem3.numberToHex)(chainId) });
|
|
@@ -211,11 +222,11 @@ function createOneAuthProvider(options) {
|
|
|
211
222
|
const stored = getStoredUser();
|
|
212
223
|
if (stored) return stored;
|
|
213
224
|
const [address] = await connect();
|
|
214
|
-
|
|
215
|
-
if (!username || !address) {
|
|
225
|
+
if (!address) {
|
|
216
226
|
throw new Error("Failed to resolve user session");
|
|
217
227
|
}
|
|
218
|
-
|
|
228
|
+
const user = getStoredUser();
|
|
229
|
+
return user || { address };
|
|
219
230
|
};
|
|
220
231
|
const parseChainId = (value) => {
|
|
221
232
|
if (typeof value === "number") return value;
|
|
@@ -273,9 +284,13 @@ function createOneAuthProvider(options) {
|
|
|
273
284
|
}
|
|
274
285
|
};
|
|
275
286
|
const signMessage = async (message) => {
|
|
276
|
-
const
|
|
287
|
+
const user = await ensureUser();
|
|
288
|
+
if (!user.username && !user.address) {
|
|
289
|
+
throw new Error("Username or address required for signing.");
|
|
290
|
+
}
|
|
277
291
|
const result = await client.signMessage({
|
|
278
|
-
username,
|
|
292
|
+
username: user.username,
|
|
293
|
+
accountAddress: user.address,
|
|
279
294
|
message
|
|
280
295
|
});
|
|
281
296
|
if (!result.success || !result.signature) {
|
|
@@ -284,10 +299,14 @@ function createOneAuthProvider(options) {
|
|
|
284
299
|
return encodeWebAuthnSignature(result.signature);
|
|
285
300
|
};
|
|
286
301
|
const signTypedData = async (typedData) => {
|
|
287
|
-
const
|
|
302
|
+
const user = await ensureUser();
|
|
303
|
+
if (!user.username && !user.address) {
|
|
304
|
+
throw new Error("Username or address required for signing.");
|
|
305
|
+
}
|
|
288
306
|
const data = typeof typedData === "string" ? JSON.parse(typedData) : typedData;
|
|
289
307
|
const result = await client.signTypedData({
|
|
290
|
-
username,
|
|
308
|
+
username: user.username,
|
|
309
|
+
accountAddress: user.address,
|
|
291
310
|
domain: data.domain,
|
|
292
311
|
types: data.types,
|
|
293
312
|
primaryType: data.primaryType,
|
|
@@ -302,11 +321,15 @@ function createOneAuthProvider(options) {
|
|
|
302
321
|
if (!options.signIntent) {
|
|
303
322
|
return {
|
|
304
323
|
username: payload.username,
|
|
324
|
+
accountAddress: payload.accountAddress,
|
|
305
325
|
targetChain: payload.targetChain,
|
|
306
326
|
calls: payload.calls,
|
|
307
327
|
tokenRequests: payload.tokenRequests
|
|
308
328
|
};
|
|
309
329
|
}
|
|
330
|
+
if (!payload.username) {
|
|
331
|
+
throw new Error("Username required for signed intents. Set a username first.");
|
|
332
|
+
}
|
|
310
333
|
const signedIntent = await options.signIntent({
|
|
311
334
|
username: payload.username,
|
|
312
335
|
accountAddress: payload.accountAddress,
|
|
@@ -432,10 +455,13 @@ function createOneAuthProvider(options) {
|
|
|
432
455
|
return capabilities;
|
|
433
456
|
}
|
|
434
457
|
case "wallet_getAssets": {
|
|
435
|
-
const
|
|
458
|
+
const user = await ensureUser();
|
|
459
|
+
if (!user.username) {
|
|
460
|
+
throw new Error("Username required to fetch assets. Set a username first.");
|
|
461
|
+
}
|
|
436
462
|
const clientId = client.getClientId();
|
|
437
463
|
const response = await fetch(
|
|
438
|
-
`${client.getProviderUrl()}/api/users/${encodeURIComponent(username)}/portfolio`,
|
|
464
|
+
`${client.getProviderUrl()}/api/users/${encodeURIComponent(user.username)}/portfolio`,
|
|
439
465
|
{
|
|
440
466
|
headers: clientId ? { "x-client-id": clientId } : {}
|
|
441
467
|
}
|
|
@@ -545,7 +571,6 @@ function createOneAuthProvider(options) {
|
|
|
545
571
|
disconnect
|
|
546
572
|
};
|
|
547
573
|
}
|
|
548
|
-
var createPasskeyProvider = createOneAuthProvider;
|
|
549
574
|
|
|
550
575
|
// src/wagmi.ts
|
|
551
576
|
function oneAuth(options) {
|
|
@@ -642,7 +667,7 @@ function oneAuth(options) {
|
|
|
642
667
|
if (!initialChainId) {
|
|
643
668
|
throw new Error("No chain configured for 1auth connector");
|
|
644
669
|
}
|
|
645
|
-
provider =
|
|
670
|
+
provider = createOneAuthProvider({
|
|
646
671
|
client: options.client,
|
|
647
672
|
chainId: initialChainId,
|
|
648
673
|
storageKey: options.storageKey,
|
package/dist/wagmi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/wagmi.ts","../src/provider.ts","../src/registry.ts","../src/walletClient/utils.ts"],"sourcesContent":["import { createConnector, type Connector } from \"@wagmi/core\";\nimport {\n numberToHex,\n type Address,\n type Chain,\n type ProviderConnectInfo,\n} from \"viem\";\nimport { createPasskeyProvider, type PasskeyProvider } from \"./provider\";\nimport type { OneAuthClient } from \"./client\";\nimport type { IntentSigner } from \"./types\";\n\nexport type OneAuthConnectorOptions = {\n client: OneAuthClient;\n chainId?: number;\n storageKey?: string;\n waitForHash?: boolean;\n hashTimeoutMs?: number;\n hashIntervalMs?: number;\n signIntent?: IntentSigner;\n};\n\nexport function oneAuth(options: OneAuthConnectorOptions) {\n type Provider = PasskeyProvider;\n\n return createConnector<Provider>((wagmiConfig) => {\n const chains = (wagmiConfig.chains ?? []) as readonly [Chain, ...Chain[]];\n const initialChainId = options.chainId ?? chains[0]?.id;\n\n let provider: Provider | null = null;\n let accountsChanged: Connector[\"onAccountsChanged\"] | undefined;\n let chainChanged: Connector[\"onChainChanged\"] | undefined;\n let connect: Connector[\"onConnect\"] | undefined;\n let disconnect: Connector[\"onDisconnect\"] | undefined;\n\n return {\n id: \"1auth\",\n name: \"1auth Passkey\",\n type: \"wallet\",\n async connect<withCapabilities extends boolean = false>(\n { chainId, isReconnecting, withCapabilities }:\n | {\n chainId?: number;\n isReconnecting?: boolean;\n withCapabilities?: withCapabilities | boolean;\n }\n | undefined = {}\n ): Promise<{\n accounts: withCapabilities extends true\n ? readonly { address: Address; capabilities: Record<string, unknown> }[]\n : readonly Address[];\n chainId: number;\n }> {\n if (!initialChainId) {\n throw new Error(\"No chain configured for 1auth connector\");\n }\n\n const provider = await this.getProvider({ chainId });\n let accounts: readonly Address[] = [];\n let currentChainId = await this.getChainId();\n\n if (isReconnecting) {\n accounts = await this.getAccounts().catch(() => []);\n }\n\n if (!accounts.length) {\n accounts = (await provider.request({\n method: \"wallet_connect\",\n })) as Address[];\n currentChainId = await this.getChainId();\n }\n\n if (chainId && currentChainId !== chainId) {\n await provider.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: numberToHex(chainId) }],\n });\n currentChainId = await this.getChainId();\n }\n\n if (connect) {\n provider.removeListener(\"connect\", connect as never);\n connect = undefined;\n }\n if (!accountsChanged) {\n accountsChanged = this.onAccountsChanged.bind(this);\n provider.on(\"accountsChanged\", accountsChanged as never);\n }\n if (!chainChanged) {\n chainChanged = this.onChainChanged.bind(this);\n provider.on(\"chainChanged\", chainChanged as never);\n }\n if (!disconnect) {\n disconnect = this.onDisconnect.bind(this);\n provider.on(\"disconnect\", disconnect as never);\n }\n\n const response = withCapabilities\n ? {\n accounts: accounts.map((account) => ({\n address: account,\n capabilities: {},\n })),\n chainId: currentChainId,\n }\n : {\n accounts,\n chainId: currentChainId,\n };\n\n return response as unknown as {\n accounts: withCapabilities extends true\n ? readonly { address: Address; capabilities: Record<string, unknown> }[]\n : readonly Address[];\n chainId: number;\n };\n },\n async disconnect() {\n const provider = await this.getProvider();\n await provider.disconnect();\n if (chainChanged) {\n provider.removeListener(\"chainChanged\", chainChanged as never);\n chainChanged = undefined;\n }\n if (disconnect) {\n provider.removeListener(\"disconnect\", disconnect as never);\n disconnect = undefined;\n }\n },\n async getAccounts() {\n const provider = await this.getProvider();\n return (await provider.request({\n method: \"eth_accounts\",\n })) as Address[];\n },\n async getChainId() {\n const provider = await this.getProvider();\n const hexChainId = (await provider.request({\n method: \"eth_chainId\",\n })) as string;\n return Number.parseInt(hexChainId, 16);\n },\n async getProvider({ chainId } = {}) {\n if (!provider) {\n if (!initialChainId) {\n throw new Error(\"No chain configured for 1auth connector\");\n }\n provider = createPasskeyProvider({\n client: options.client,\n chainId: initialChainId,\n storageKey: options.storageKey,\n waitForHash: options.waitForHash,\n hashTimeoutMs: options.hashTimeoutMs,\n hashIntervalMs: options.hashIntervalMs,\n signIntent: options.signIntent,\n });\n }\n if (chainId) {\n await provider.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: numberToHex(chainId) }],\n });\n }\n return provider;\n },\n async setup() {\n const provider = await this.getProvider();\n if (!connect) {\n const onConnect = this.onConnect?.bind(this);\n if (onConnect) {\n connect = onConnect;\n provider.on(\"connect\", connect as never);\n }\n }\n },\n async isAuthorized() {\n try {\n const accounts = await this.getAccounts();\n return accounts.length > 0;\n } catch {\n return false;\n }\n },\n async switchChain({ chainId }) {\n const chain = chains.find((chain) => chain.id === chainId);\n if (!chain) {\n throw new Error(\"Chain not configured\");\n }\n const provider = await this.getProvider();\n await provider.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: numberToHex(chainId) }],\n });\n return chain;\n },\n async onConnect(connectInfo: ProviderConnectInfo) {\n const accounts = await this.getAccounts();\n if (!accounts.length) return;\n const chainId = Number(connectInfo.chainId);\n wagmiConfig.emitter.emit(\"connect\", { accounts, chainId });\n },\n onAccountsChanged(accounts: string[]) {\n wagmiConfig.emitter.emit(\"change\", {\n accounts: accounts as Address[],\n });\n },\n onChainChanged(chainId: string) {\n wagmiConfig.emitter.emit(\"change\", {\n chainId: Number(chainId),\n });\n },\n onDisconnect(_error?: Error) {\n wagmiConfig.emitter.emit(\"disconnect\");\n },\n };\n });\n}\n","import {\n hexToString,\n isHex,\n numberToHex,\n type Address,\n type Hex,\n} from \"viem\";\nimport { OneAuthClient } from \"./client\";\nimport { getSupportedChainIds } from \"./registry\";\nimport type { CloseOnStatus, IntentCall, IntentSigner, IntentTokenRequest } from \"./types\";\nimport { encodeWebAuthnSignature } from \"./walletClient/utils\";\n\ntype ProviderRequest = {\n method: string;\n params?: unknown[] | Record<string, unknown>;\n};\n\ntype Listener = (...args: unknown[]) => void;\n\ntype StoredUser = {\n username: string;\n address: Address;\n};\n\nexport type OneAuthProvider = {\n request: (args: ProviderRequest) => Promise<unknown>;\n on: (event: string, listener: Listener) => void;\n removeListener: (event: string, listener: Listener) => void;\n disconnect: () => Promise<void>;\n};\n\n/** @deprecated Use OneAuthProvider instead */\nexport type PasskeyProvider = OneAuthProvider;\n\nexport type OneAuthProviderOptions = {\n client: OneAuthClient;\n chainId: number;\n storageKey?: string;\n /** When to close the dialog and return success. Defaults to \"preconfirmed\" */\n closeOn?: CloseOnStatus;\n waitForHash?: boolean;\n hashTimeoutMs?: number;\n hashIntervalMs?: number;\n signIntent?: IntentSigner;\n};\n\n/** @deprecated Use OneAuthProviderOptions instead */\nexport type PasskeyProviderOptions = OneAuthProviderOptions;\n\nconst DEFAULT_STORAGE_KEY = \"1auth-user\";\n\nexport function createOneAuthProvider(\n options: OneAuthProviderOptions\n): OneAuthProvider {\n const { client } = options;\n let chainId = options.chainId;\n const storageKey = options.storageKey || DEFAULT_STORAGE_KEY;\n\n const listeners = new Map<string, Set<Listener>>();\n\n const emit = (event: string, ...args: unknown[]) => {\n const set = listeners.get(event);\n if (!set) return;\n for (const listener of set) listener(...args);\n };\n\n const getStoredUser = (): StoredUser | null => {\n if (typeof window === \"undefined\") return null;\n try {\n const raw = localStorage.getItem(storageKey);\n if (!raw) return null;\n const parsed = JSON.parse(raw) as StoredUser;\n if (!parsed?.username || !parsed?.address) return null;\n return parsed;\n } catch {\n return null;\n }\n };\n\n const setStoredUser = (user: StoredUser) => {\n if (typeof window === \"undefined\") return;\n localStorage.setItem(storageKey, JSON.stringify(user));\n };\n\n const clearStoredUser = () => {\n if (typeof window === \"undefined\") return;\n localStorage.removeItem(storageKey);\n };\n\n const resolveAccountAddress = async (username: string): Promise<Address> => {\n const clientId = client.getClientId();\n const response = await fetch(\n `${client.getProviderUrl()}/api/users/${encodeURIComponent(username)}/account`,\n {\n headers: clientId ? { \"x-client-id\": clientId } : {},\n }\n );\n\n if (!response.ok) {\n const data = await response.json().catch(() => ({}));\n throw new Error(data.error || \"Failed to resolve account address\");\n }\n\n const data = await response.json();\n return data.address as Address;\n };\n\n const connect = async (): Promise<Address[]> => {\n const stored = getStoredUser();\n if (stored) {\n return [stored.address];\n }\n\n // First try the lightweight connect modal\n const connectResult = await client.connectWithModal();\n\n let username: string | undefined;\n\n if (connectResult.success && connectResult.username) {\n // Connection successful (user confirmed or auto-connected)\n username = connectResult.username;\n } else if (connectResult.action === \"switch\") {\n // User wants to switch account or no previous user - show auth modal\n const authResult = await client.authWithModal();\n if (!authResult.success || !authResult.username) {\n throw new Error(authResult.error?.message || \"Authentication failed\");\n }\n username = authResult.username;\n } else {\n // Connection was cancelled\n throw new Error(connectResult.error?.message || \"Connection cancelled\");\n }\n\n const address = await resolveAccountAddress(username);\n setStoredUser({ username, address });\n emit(\"accountsChanged\", [address]);\n emit(\"connect\", { chainId: numberToHex(chainId) });\n return [address];\n };\n\n const disconnect = async () => {\n clearStoredUser();\n emit(\"accountsChanged\", []);\n emit(\"disconnect\");\n };\n\n const ensureUser = async (): Promise<StoredUser> => {\n const stored = getStoredUser();\n if (stored) return stored;\n const [address] = await connect();\n const username = getStoredUser()?.username;\n if (!username || !address) {\n throw new Error(\"Failed to resolve user session\");\n }\n return { username, address };\n };\n\n const parseChainId = (value: unknown): number | undefined => {\n if (typeof value === \"number\") return value;\n if (typeof value === \"string\") {\n if (value.startsWith(\"0x\")) return Number.parseInt(value, 16);\n const parsed = Number(value);\n return Number.isFinite(parsed) ? parsed : undefined;\n }\n return undefined;\n };\n\n const normalizeValue = (value: unknown): string | undefined => {\n if (value === undefined || value === null) return undefined;\n if (typeof value === \"bigint\") return value.toString();\n if (typeof value === \"number\") return Math.trunc(value).toString();\n if (typeof value === \"string\") {\n if (value.startsWith(\"0x\")) {\n try {\n return BigInt(value).toString();\n } catch {\n return \"0\";\n }\n }\n return value;\n }\n return undefined;\n };\n\n const normalizeCalls = (calls: unknown[]): IntentCall[] => {\n return calls.map((call) => {\n const c = call as Record<string, unknown>;\n return {\n to: c.to as Address,\n data: (c.data as Hex | undefined) || \"0x\",\n value: normalizeValue(c.value) || \"0\",\n label: c.label as string | undefined,\n sublabel: c.sublabel as string | undefined,\n };\n });\n };\n\n const normalizeTokenRequests = (\n requests: unknown\n ): IntentTokenRequest[] | undefined => {\n if (!Array.isArray(requests)) return undefined;\n return requests.map((r) => {\n const req = r as Record<string, unknown>;\n return {\n token: req.token as string,\n amount:\n typeof req.amount === \"bigint\"\n ? req.amount\n : BigInt(String(req.amount || \"0\")),\n };\n });\n };\n\n const decodeMessage = (value: string) => {\n if (!isHex(value)) return value;\n try {\n return hexToString(value as Hex);\n } catch {\n return value;\n }\n };\n\n const signMessage = async (message: string) => {\n const { username } = await ensureUser();\n const result = await client.signMessage({\n username,\n message,\n });\n if (!result.success || !result.signature) {\n throw new Error(result.error?.message || \"Signing failed\");\n }\n return encodeWebAuthnSignature(result.signature);\n };\n\n const signTypedData = async (typedData: unknown) => {\n const { username } = await ensureUser();\n const data =\n typeof typedData === \"string\" ? JSON.parse(typedData) : typedData;\n const result = await client.signTypedData({\n username,\n domain: (data as any).domain,\n types: (data as any).types,\n primaryType: (data as any).primaryType,\n message: (data as any).message,\n });\n if (!result.success || !result.signature) {\n throw new Error(result.error?.message || \"Signing failed\");\n }\n return encodeWebAuthnSignature(result.signature);\n };\n\n const resolveIntentPayload = async (payload: {\n username: string;\n accountAddress: Address;\n targetChain: number;\n calls: IntentCall[];\n tokenRequests?: IntentTokenRequest[];\n }) => {\n if (!options.signIntent) {\n return {\n username: payload.username,\n targetChain: payload.targetChain,\n calls: payload.calls,\n tokenRequests: payload.tokenRequests,\n };\n }\n const signedIntent = await options.signIntent({\n username: payload.username,\n accountAddress: payload.accountAddress,\n targetChain: payload.targetChain,\n calls: payload.calls,\n tokenRequests: payload.tokenRequests,\n });\n return { signedIntent };\n };\n\n const sendIntent = async (payload: {\n username: string;\n accountAddress: Address;\n targetChain: number;\n calls: IntentCall[];\n tokenRequests?: IntentTokenRequest[];\n sourceChainId?: number;\n }) => {\n // Use explicit closeOn if provided, otherwise default based on waitForHash\n const closeOn = options.closeOn ?? ((options.waitForHash ?? true) ? \"completed\" : \"preconfirmed\");\n const intentPayload = await resolveIntentPayload(payload);\n const result = await client.sendIntent({\n ...intentPayload,\n tokenRequests: payload.tokenRequests,\n sourceChainId: payload.sourceChainId,\n closeOn,\n waitForHash: options.waitForHash ?? true,\n hashTimeoutMs: options.hashTimeoutMs,\n hashIntervalMs: options.hashIntervalMs,\n });\n\n if (!result.success) {\n throw new Error(result.error?.message || \"Transaction failed\");\n }\n\n // Return intentId as callsId for EIP-5792 compatibility\n return result.intentId;\n };\n\n const request = async ({ method, params }: ProviderRequest) => {\n switch (method) {\n case \"eth_chainId\":\n return numberToHex(chainId);\n case \"eth_accounts\": {\n const stored = getStoredUser();\n return stored ? [stored.address] : [];\n }\n case \"eth_requestAccounts\":\n return connect();\n case \"wallet_connect\":\n return connect();\n case \"wallet_disconnect\":\n await disconnect();\n return true;\n case \"wallet_switchEthereumChain\": {\n const [param] = (params as any[]) || [];\n const next = parseChainId(param?.chainId ?? param);\n if (!next) {\n throw new Error(\"Invalid chainId\");\n }\n chainId = next;\n emit(\"chainChanged\", numberToHex(chainId));\n return null;\n }\n case \"personal_sign\": {\n const paramList = Array.isArray(params) ? params : [];\n const first = paramList[0];\n const second = paramList[1];\n const message =\n typeof first === \"string\" && first.startsWith(\"0x\") && second\n ? typeof second === \"string\" && !second.startsWith(\"0x\")\n ? second\n : decodeMessage(first)\n : typeof first === \"string\"\n ? decodeMessage(first)\n : typeof second === \"string\"\n ? decodeMessage(second)\n : \"\";\n if (!message) throw new Error(\"Invalid personal_sign payload\");\n return signMessage(message);\n }\n case \"eth_sign\": {\n const paramList = Array.isArray(params) ? params : [];\n const message = typeof paramList[1] === \"string\" ? paramList[1] : \"\";\n if (!message) throw new Error(\"Invalid eth_sign payload\");\n return signMessage(decodeMessage(message));\n }\n case \"eth_signTypedData\":\n case \"eth_signTypedData_v4\": {\n const paramList = Array.isArray(params) ? params : [];\n const typedData = paramList[1] ?? paramList[0];\n return signTypedData(typedData);\n }\n case \"eth_sendTransaction\": {\n const paramList = Array.isArray(params) ? params : [];\n const tx = (paramList[0] || {}) as Record<string, unknown>;\n const user = await ensureUser();\n const targetChain = parseChainId(tx.chainId) ?? chainId;\n const calls = normalizeCalls([tx]);\n const tokenRequests = normalizeTokenRequests(tx.tokenRequests);\n const txSourceChainId = parseChainId(tx.sourceChainId);\n return sendIntent({\n username: user.username,\n accountAddress: user.address,\n targetChain,\n calls,\n tokenRequests,\n sourceChainId: txSourceChainId,\n });\n }\n case \"wallet_sendCalls\": {\n const paramList = Array.isArray(params) ? params : [];\n const payload = (paramList[0] || {}) as Record<string, unknown>;\n const user = await ensureUser();\n const targetChain = parseChainId(payload.chainId) ?? chainId;\n const calls = normalizeCalls((payload.calls as unknown[]) || []);\n const tokenRequests = normalizeTokenRequests(payload.tokenRequests);\n const sourceChainId = parseChainId(payload.sourceChainId);\n if (!calls.length) throw new Error(\"No calls provided\");\n return sendIntent({\n username: user.username,\n accountAddress: user.address,\n targetChain,\n calls,\n tokenRequests,\n sourceChainId,\n });\n }\n case \"wallet_getCapabilities\": {\n const paramList = Array.isArray(params) ? params : [];\n // walletAddress is params[0] - we ignore since all accounts have same capabilities\n const requestedChains = paramList[1] as `0x${string}`[] | undefined;\n\n const chainIds = getSupportedChainIds();\n const capabilities: Record<`0x${string}`, Record<string, unknown>> = {};\n\n for (const chainId of chainIds) {\n const hexChainId = `0x${chainId.toString(16)}` as `0x${string}`;\n\n // Filter if specific chains requested\n if (requestedChains && !requestedChains.includes(hexChainId)) {\n continue;\n }\n\n capabilities[hexChainId] = {\n atomic: { status: \"supported\" },\n paymasterService: { supported: true },\n auxiliaryFunds: { supported: true },\n };\n }\n\n return capabilities;\n }\n case \"wallet_getAssets\": {\n const { username } = await ensureUser();\n const clientId = client.getClientId();\n const response = await fetch(\n `${client.getProviderUrl()}/api/users/${encodeURIComponent(username)}/portfolio`,\n {\n headers: clientId ? { \"x-client-id\": clientId } : {},\n }\n );\n if (!response.ok) {\n const data = await response.json().catch(() => ({}));\n throw new Error(data.error || \"Failed to get assets\");\n }\n return response.json();\n }\n case \"wallet_getCallsStatus\": {\n const paramList = Array.isArray(params) ? params : [];\n const callsId = paramList[0] as string;\n if (!callsId) {\n throw new Error(\"callsId is required\");\n }\n const statusClientId = client.getClientId();\n const response = await fetch(\n `${client.getProviderUrl()}/api/intent/status/${encodeURIComponent(callsId)}`,\n {\n headers: statusClientId ? { \"x-client-id\": statusClientId } : {},\n }\n );\n if (!response.ok) {\n const data = await response.json().catch(() => ({}));\n throw new Error(data.error || \"Failed to get calls status\");\n }\n const data = await response.json();\n // Map intent status to EIP-5792 format\n const statusMap: Record<string, string> = {\n pending: \"PENDING\",\n preconfirmed: \"PENDING\",\n completed: \"CONFIRMED\",\n failed: \"CONFIRMED\",\n expired: \"CONFIRMED\",\n };\n return {\n status: statusMap[data.status] || \"PENDING\",\n receipts: data.transactionHash\n ? [\n {\n logs: [],\n status: data.status === \"completed\" ? \"0x1\" : \"0x0\",\n blockHash: data.blockHash,\n blockNumber: data.blockNumber,\n transactionHash: data.transactionHash,\n },\n ]\n : [],\n };\n }\n case \"wallet_getCallsHistory\": {\n const paramList = Array.isArray(params) ? params : [];\n const options = (paramList[0] || {}) as {\n limit?: number;\n offset?: number;\n status?: string;\n from?: string;\n to?: string;\n };\n\n const queryParams = new URLSearchParams();\n if (options.limit) queryParams.set(\"limit\", String(options.limit));\n if (options.offset) queryParams.set(\"offset\", String(options.offset));\n if (options.status) queryParams.set(\"status\", options.status);\n if (options.from) queryParams.set(\"from\", options.from);\n if (options.to) queryParams.set(\"to\", options.to);\n\n const url = `${client.getProviderUrl()}/api/intent/history${\n queryParams.toString() ? `?${queryParams}` : \"\"\n }`;\n\n const historyClientId = client.getClientId();\n const response = await fetch(url, {\n headers: historyClientId ? { \"x-client-id\": historyClientId } : {},\n credentials: \"include\",\n });\n\n if (!response.ok) {\n const data = await response.json().catch(() => ({}));\n throw new Error(data.error || \"Failed to get calls history\");\n }\n\n const data = await response.json();\n\n // Map intent status to EIP-5792 format\n const statusMap: Record<string, string> = {\n pending: \"PENDING\",\n preconfirmed: \"PENDING\",\n completed: \"CONFIRMED\",\n failed: \"CONFIRMED\",\n expired: \"CONFIRMED\",\n };\n\n // intentId IS the orchestrator's ID (used as callsId in EIP-5792)\n return {\n calls: data.intents.map(\n (intent: {\n intentId: string;\n status: string;\n transactionHash?: string;\n targetChain: number;\n }) => ({\n callsId: intent.intentId, // intentId is the orchestrator's ID\n status: statusMap[intent.status] || \"PENDING\",\n receipts: intent.transactionHash\n ? [{ transactionHash: intent.transactionHash }]\n : [],\n chainId: `0x${intent.targetChain.toString(16)}`,\n })\n ),\n total: data.total,\n hasMore: data.hasMore,\n };\n }\n default:\n throw new Error(`Unsupported method: ${method}`);\n }\n };\n\n return {\n request,\n on(event, listener) {\n const set = listeners.get(event) ?? new Set();\n set.add(listener);\n listeners.set(event, set);\n },\n removeListener(event, listener) {\n const set = listeners.get(event);\n if (!set) return;\n set.delete(listener);\n if (set.size === 0) listeners.delete(event);\n },\n disconnect,\n };\n}\n\n/** @deprecated Use createOneAuthProvider instead */\nexport const createPasskeyProvider = createOneAuthProvider;\n","import type { Address, Chain } from \"viem\";\nimport { isAddress } from \"viem\";\nimport * as viemChains from \"viem/chains\";\nimport {\n getAllSupportedChainsAndTokens as getAllSupportedChainsAndTokensRaw,\n getSupportedTokens as getSupportedTokensRaw,\n getTokenAddress,\n getTokenDecimals,\n} from \"@rhinestone/sdk\";\n\nexport type TokenConfig = {\n symbol: string;\n address: Address;\n decimals: number;\n supportsMultichain?: boolean;\n [key: string]: unknown;\n};\n\nexport type ChainFilterOptions = {\n includeTestnets?: boolean;\n chainIds?: number[];\n};\n\nconst env: Record<string, string | undefined> =\n typeof process !== \"undefined\" ? process.env : {};\n\nconst ALL_VIEM_CHAINS = (Object.values(viemChains) as unknown[]).filter(\n (value): value is Chain =>\n typeof value === \"object\" && value !== null && \"id\" in value && \"name\" in value\n);\nconst VIEM_CHAIN_BY_ID = new Map<number, Chain>(\n ALL_VIEM_CHAINS.map((chain) => [chain.id, chain])\n);\nconst SUPPORTED_CHAIN_IDS = new Set(\n getAllSupportedChainsAndTokensRaw().map((entry) => entry.chainId)\n);\n\nfunction parseBool(value?: string): boolean | undefined {\n if (value === \"true\" || value === \"1\") return true;\n if (value === \"false\" || value === \"0\") return false;\n return undefined;\n}\n\nfunction resolveIncludeTestnets(explicit?: boolean): boolean {\n if (explicit !== undefined) return explicit;\n const envValue =\n parseBool(env.NEXT_PUBLIC_ORCHESTRATOR_USE_TESTNETS) ??\n parseBool(env.ORCHESTRATOR_USE_TESTNETS);\n return envValue ?? false;\n}\n\nfunction applyChainFilters(chainIds: number[], options?: ChainFilterOptions): number[] {\n const includeTestnets = resolveIncludeTestnets(options?.includeTestnets);\n const allowlist = options?.chainIds;\n let filtered = chainIds;\n\n if (!includeTestnets) {\n filtered = filtered.filter((chainId) => !isTestnet(chainId));\n }\n\n if (allowlist && allowlist.length > 0) {\n const allowed = new Set(allowlist);\n filtered = filtered.filter((chainId) => allowed.has(chainId));\n }\n\n return filtered;\n}\n\nexport function getSupportedChainIds(options?: ChainFilterOptions): number[] {\n return applyChainFilters(Array.from(SUPPORTED_CHAIN_IDS), options);\n}\n\nexport function getSupportedChains(options?: ChainFilterOptions): Chain[] {\n return getSupportedChainIds(options)\n .map((chainId) => VIEM_CHAIN_BY_ID.get(chainId))\n .filter((chain): chain is Chain => Boolean(chain));\n}\n\nexport function getAllSupportedChainsAndTokens(options?: ChainFilterOptions): Array<{\n chainId: number;\n tokens: TokenConfig[];\n}> {\n const allowed = new Set(getSupportedChainIds(options));\n return getAllSupportedChainsAndTokensRaw()\n .filter((entry) => allowed.has(entry.chainId))\n .map((entry) => ({\n chainId: entry.chainId,\n tokens: entry.tokens as TokenConfig[],\n }));\n}\n\nexport function getChainById(chainId: number): Chain {\n if (!SUPPORTED_CHAIN_IDS.has(chainId)) {\n throw new Error(`Unsupported chain ID: ${chainId}`);\n }\n const chain = VIEM_CHAIN_BY_ID.get(chainId);\n if (!chain) {\n throw new Error(`Unsupported chain ID: ${chainId}`);\n }\n return chain;\n}\n\nexport function getChainName(chainId: number): string {\n try {\n return getChainById(chainId).name;\n } catch {\n return `Chain ${chainId}`;\n }\n}\n\nexport function getChainExplorerUrl(chainId: number): string | undefined {\n try {\n return getChainById(chainId).blockExplorers?.default?.url;\n } catch {\n return undefined;\n }\n}\n\nexport function getChainRpcUrl(chainId: number): string | undefined {\n try {\n const chain = getChainById(chainId);\n return chain.rpcUrls?.default?.http?.[0] || chain.rpcUrls?.public?.http?.[0];\n } catch {\n return undefined;\n }\n}\n\nexport function getSupportedTokens(chainId: number): TokenConfig[] {\n return getSupportedTokensRaw(chainId) as TokenConfig[];\n}\n\nexport function getSupportedTokenSymbols(chainId: number): string[] {\n return getSupportedTokens(chainId).map((token) => token.symbol);\n}\n\nexport function resolveTokenAddress(token: string, chainId: number): Address {\n if (isAddress(token)) {\n return token;\n }\n // Case-insensitive lookup: find canonical symbol from registry, then resolve\n const match = getSupportedTokens(chainId).find(\n (t) => t.symbol.toUpperCase() === token.toUpperCase()\n );\n if (!match) {\n return getTokenAddress(token as never, chainId);\n }\n return match.address;\n}\n\nexport function isTestnet(chainId: number): boolean {\n try {\n return getChainById(chainId).testnet ?? false;\n } catch {\n return false;\n }\n}\n\nexport function getTokenSymbol(tokenAddress: Address, chainId: number): string {\n const token = getSupportedTokens(chainId).find(\n (entry) => entry.address.toLowerCase() === tokenAddress.toLowerCase()\n );\n if (!token) {\n throw new Error(`Unsupported token: ${tokenAddress} on chain ${chainId}`);\n }\n return token.symbol;\n}\n\nexport function isTokenAddressSupported(tokenAddress: Address, chainId: number): boolean {\n try {\n return getSupportedTokens(chainId).some(\n (entry) => entry.address.toLowerCase() === tokenAddress.toLowerCase()\n );\n } catch {\n return false;\n }\n}\n\nexport { getTokenAddress, getTokenDecimals };\n","import { encodeAbiParameters, keccak256 } from 'viem';\nimport type { Hex } from 'viem';\nimport type { WebAuthnSignature } from '../types';\nimport type { TransactionCall } from './types';\n\n/**\n * P-256 curve order (n)\n * Used for signature malleability normalization\n */\nconst P256_N = BigInt(\n '0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551'\n);\nconst P256_N_DIV_2 = P256_N / 2n;\n\n/**\n * WebAuthnAuth struct type for ABI encoding\n */\nconst WEBAUTHN_AUTH_TYPE = {\n type: 'tuple',\n components: [\n { type: 'bytes', name: 'authenticatorData' },\n { type: 'string', name: 'clientDataJSON' },\n { type: 'uint256', name: 'challengeIndex' },\n { type: 'uint256', name: 'typeIndex' },\n { type: 'uint256', name: 'r' },\n { type: 'uint256', name: 's' },\n ],\n} as const;\n\n/**\n * Encode a WebAuthn signature for ERC-1271 verification on-chain\n *\n * @param sig - The WebAuthn signature from the passkey\n * @returns ABI-encoded signature bytes\n */\nexport function encodeWebAuthnSignature(sig: WebAuthnSignature): Hex {\n // Normalize s to prevent signature malleability\n let s = BigInt(sig.s);\n if (s > P256_N_DIV_2) {\n s = P256_N - s;\n }\n\n return encodeAbiParameters([WEBAUTHN_AUTH_TYPE], [\n {\n authenticatorData: sig.authenticatorData as Hex,\n clientDataJSON: sig.clientDataJSON,\n challengeIndex: BigInt(sig.challengeIndex),\n typeIndex: BigInt(sig.typeIndex),\n r: BigInt(sig.r),\n s,\n },\n ]);\n}\n\n/**\n * Hash an array of transaction calls for signing\n *\n * @param calls - Array of transaction calls\n * @returns keccak256 hash of the encoded calls\n */\nexport function hashCalls(calls: TransactionCall[]): Hex {\n const encoded = encodeAbiParameters(\n [\n {\n type: 'tuple[]',\n components: [\n { type: 'address', name: 'to' },\n { type: 'bytes', name: 'data' },\n { type: 'uint256', name: 'value' },\n ],\n },\n ],\n [\n calls.map((c) => ({\n to: c.to,\n data: c.data || '0x',\n value: c.value || 0n,\n })),\n ]\n );\n return keccak256(encoded);\n}\n\n/**\n * Build transaction review display data from calls\n *\n * @param calls - Array of transaction calls\n * @returns TransactionDetails for the signing modal\n */\nexport function buildTransactionReview(calls: TransactionCall[]) {\n return {\n actions: calls.map((call, i) => ({\n type: 'custom' as const,\n label: call.label || `Contract Call ${i + 1}`,\n sublabel: call.sublabel || `To: ${call.to.slice(0, 10)}...${call.to.slice(-8)}`,\n amount: call.value ? `${call.value} wei` : undefined,\n })),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAgD;AAChD,IAAAA,eAKO;;;ACNP,IAAAC,eAMO;;;ACLP,kBAA0B;AAC1B,iBAA4B;AAC5B,iBAKO;AAeP,IAAM,MACJ,OAAO,YAAY,cAAc,QAAQ,MAAM,CAAC;AAElD,IAAM,kBAAmB,OAAO,OAAO,UAAU,EAAgB;AAAA,EAC/D,CAAC,UACC,OAAO,UAAU,YAAY,UAAU,QAAQ,QAAQ,SAAS,UAAU;AAC9E;AACA,IAAM,mBAAmB,IAAI;AAAA,EAC3B,gBAAgB,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI,KAAK,CAAC;AAClD;AACA,IAAM,sBAAsB,IAAI;AAAA,MAC9B,WAAAC,gCAAkC,EAAE,IAAI,CAAC,UAAU,MAAM,OAAO;AAClE;AAEA,SAAS,UAAU,OAAqC;AACtD,MAAI,UAAU,UAAU,UAAU,IAAK,QAAO;AAC9C,MAAI,UAAU,WAAW,UAAU,IAAK,QAAO;AAC/C,SAAO;AACT;AAEA,SAAS,uBAAuB,UAA6B;AAC3D,MAAI,aAAa,OAAW,QAAO;AACnC,QAAM,WACJ,UAAU,IAAI,qCAAqC,KACnD,UAAU,IAAI,yBAAyB;AACzC,SA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U;AAAA,UACjC;AAAA,QACF,CAAC;AAAA,MACH;AAAA,MACA,eAAe,SAAiB;AAC9B,oBAAY,QAAQ,KAAK,UAAU;AAAA,UACjC,SAAS,OAAO,OAAO;AAAA,QACzB,CAAC;AAAA,MACH;AAAA,MACA,aAAa,QAAgB;AAC3B,oBAAY,QAAQ,KAAK,YAAY;AAAA,MACvC;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":["import_viem","import_viem","getAllSupportedChainsAndTokensRaw","import_viem","data","chainId","options","provider","chain"]}
|
|
1
|
+
{"version":3,"sources":["../src/wagmi.ts","../src/provider.ts","../src/registry.ts","../src/walletClient/utils.ts"],"sourcesContent":["import { createConnector, type Connector } from \"@wagmi/core\";\nimport {\n numberToHex,\n type Address,\n type Chain,\n type ProviderConnectInfo,\n} from \"viem\";\nimport { createOneAuthProvider, type OneAuthProvider } from \"./provider\";\nimport type { OneAuthClient } from \"./client\";\nimport type { IntentSigner } from \"./types\";\n\nexport type OneAuthConnectorOptions = {\n client: OneAuthClient;\n chainId?: number;\n storageKey?: string;\n waitForHash?: boolean;\n hashTimeoutMs?: number;\n hashIntervalMs?: number;\n signIntent?: IntentSigner;\n};\n\nexport function oneAuth(options: OneAuthConnectorOptions) {\n type Provider = OneAuthProvider;\n\n return createConnector<Provider>((wagmiConfig) => {\n const chains = (wagmiConfig.chains ?? []) as readonly [Chain, ...Chain[]];\n const initialChainId = options.chainId ?? chains[0]?.id;\n\n let provider: Provider | null = null;\n let accountsChanged: Connector[\"onAccountsChanged\"] | undefined;\n let chainChanged: Connector[\"onChainChanged\"] | undefined;\n let connect: Connector[\"onConnect\"] | undefined;\n let disconnect: Connector[\"onDisconnect\"] | undefined;\n\n return {\n id: \"1auth\",\n name: \"1auth Passkey\",\n type: \"wallet\",\n async connect<withCapabilities extends boolean = false>(\n { chainId, isReconnecting, withCapabilities }:\n | {\n chainId?: number;\n isReconnecting?: boolean;\n withCapabilities?: withCapabilities | boolean;\n }\n | undefined = {}\n ): Promise<{\n accounts: withCapabilities extends true\n ? readonly { address: Address; capabilities: Record<string, unknown> }[]\n : readonly Address[];\n chainId: number;\n }> {\n if (!initialChainId) {\n throw new Error(\"No chain configured for 1auth connector\");\n }\n\n const provider = await this.getProvider({ chainId });\n let accounts: readonly Address[] = [];\n let currentChainId = await this.getChainId();\n\n if (isReconnecting) {\n accounts = await this.getAccounts().catch(() => []);\n }\n\n if (!accounts.length) {\n accounts = (await provider.request({\n method: \"wallet_connect\",\n })) as Address[];\n currentChainId = await this.getChainId();\n }\n\n if (chainId && currentChainId !== chainId) {\n await provider.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: numberToHex(chainId) }],\n });\n currentChainId = await this.getChainId();\n }\n\n if (connect) {\n provider.removeListener(\"connect\", connect as never);\n connect = undefined;\n }\n if (!accountsChanged) {\n accountsChanged = this.onAccountsChanged.bind(this);\n provider.on(\"accountsChanged\", accountsChanged as never);\n }\n if (!chainChanged) {\n chainChanged = this.onChainChanged.bind(this);\n provider.on(\"chainChanged\", chainChanged as never);\n }\n if (!disconnect) {\n disconnect = this.onDisconnect.bind(this);\n provider.on(\"disconnect\", disconnect as never);\n }\n\n const response = withCapabilities\n ? {\n accounts: accounts.map((account) => ({\n address: account,\n capabilities: {},\n })),\n chainId: currentChainId,\n }\n : {\n accounts,\n chainId: currentChainId,\n };\n\n return response as unknown as {\n accounts: withCapabilities extends true\n ? readonly { address: Address; capabilities: Record<string, unknown> }[]\n : readonly Address[];\n chainId: number;\n };\n },\n async disconnect() {\n const provider = await this.getProvider();\n await provider.disconnect();\n if (chainChanged) {\n provider.removeListener(\"chainChanged\", chainChanged as never);\n chainChanged = undefined;\n }\n if (disconnect) {\n provider.removeListener(\"disconnect\", disconnect as never);\n disconnect = undefined;\n }\n },\n async getAccounts() {\n const provider = await this.getProvider();\n return (await provider.request({\n method: \"eth_accounts\",\n })) as Address[];\n },\n async getChainId() {\n const provider = await this.getProvider();\n const hexChainId = (await provider.request({\n method: \"eth_chainId\",\n })) as string;\n return Number.parseInt(hexChainId, 16);\n },\n async getProvider({ chainId } = {}) {\n if (!provider) {\n if (!initialChainId) {\n throw new Error(\"No chain configured for 1auth connector\");\n }\n provider = createOneAuthProvider({\n client: options.client,\n chainId: initialChainId,\n storageKey: options.storageKey,\n waitForHash: options.waitForHash,\n hashTimeoutMs: options.hashTimeoutMs,\n hashIntervalMs: options.hashIntervalMs,\n signIntent: options.signIntent,\n });\n }\n if (chainId) {\n await provider.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: numberToHex(chainId) }],\n });\n }\n return provider;\n },\n async setup() {\n const provider = await this.getProvider();\n if (!connect) {\n const onConnect = this.onConnect?.bind(this);\n if (onConnect) {\n connect = onConnect;\n provider.on(\"connect\", connect as never);\n }\n }\n },\n async isAuthorized() {\n try {\n const accounts = await this.getAccounts();\n return accounts.length > 0;\n } catch {\n return false;\n }\n },\n async switchChain({ chainId }) {\n const chain = chains.find((chain) => chain.id === chainId);\n if (!chain) {\n throw new Error(\"Chain not configured\");\n }\n const provider = await this.getProvider();\n await provider.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: numberToHex(chainId) }],\n });\n return chain;\n },\n async onConnect(connectInfo: ProviderConnectInfo) {\n const accounts = await this.getAccounts();\n if (!accounts.length) return;\n const chainId = Number(connectInfo.chainId);\n wagmiConfig.emitter.emit(\"connect\", { accounts, chainId });\n },\n onAccountsChanged(accounts: string[]) {\n wagmiConfig.emitter.emit(\"change\", {\n accounts: accounts as Address[],\n });\n },\n onChainChanged(chainId: string) {\n wagmiConfig.emitter.emit(\"change\", {\n chainId: Number(chainId),\n });\n },\n onDisconnect(_error?: Error) {\n wagmiConfig.emitter.emit(\"disconnect\");\n },\n };\n });\n}\n","import {\n hexToString,\n isHex,\n numberToHex,\n type Address,\n type Hex,\n} from \"viem\";\nimport { OneAuthClient } from \"./client\";\nimport { getSupportedChainIds } from \"./registry\";\nimport type { CloseOnStatus, IntentCall, IntentSigner, IntentTokenRequest } from \"./types\";\nimport { encodeWebAuthnSignature } from \"./walletClient/utils\";\n\ntype ProviderRequest = {\n method: string;\n params?: unknown[] | Record<string, unknown>;\n};\n\ntype Listener = (...args: unknown[]) => void;\n\ntype StoredUser = {\n username?: string;\n address: Address;\n};\n\nexport type OneAuthProvider = {\n request: (args: ProviderRequest) => Promise<unknown>;\n on: (event: string, listener: Listener) => void;\n removeListener: (event: string, listener: Listener) => void;\n disconnect: () => Promise<void>;\n};\n\nexport type OneAuthProviderOptions = {\n client: OneAuthClient;\n chainId: number;\n storageKey?: string;\n /** When to close the dialog and return success. Defaults to \"preconfirmed\" */\n closeOn?: CloseOnStatus;\n waitForHash?: boolean;\n hashTimeoutMs?: number;\n hashIntervalMs?: number;\n signIntent?: IntentSigner;\n};\n\nconst DEFAULT_STORAGE_KEY = \"1auth-user\";\n\nexport function createOneAuthProvider(\n options: OneAuthProviderOptions\n): OneAuthProvider {\n const { client } = options;\n let chainId = options.chainId;\n const storageKey = options.storageKey || DEFAULT_STORAGE_KEY;\n\n const listeners = new Map<string, Set<Listener>>();\n\n const emit = (event: string, ...args: unknown[]) => {\n const set = listeners.get(event);\n if (!set) return;\n for (const listener of set) listener(...args);\n };\n\n const getStoredUser = (): StoredUser | null => {\n if (typeof window === \"undefined\") return null;\n try {\n const raw = localStorage.getItem(storageKey);\n if (!raw) return null;\n const parsed = JSON.parse(raw) as StoredUser;\n if (!parsed?.address) return null;\n return parsed;\n } catch {\n return null;\n }\n };\n\n const setStoredUser = (user: StoredUser) => {\n if (typeof window === \"undefined\") return;\n localStorage.setItem(storageKey, JSON.stringify(user));\n };\n\n const clearStoredUser = () => {\n if (typeof window === \"undefined\") return;\n localStorage.removeItem(storageKey);\n };\n\n const resolveAccountAddress = async (username: string): Promise<Address> => {\n const clientId = client.getClientId();\n const response = await fetch(\n `${client.getProviderUrl()}/api/users/${encodeURIComponent(username)}/account`,\n {\n headers: clientId ? { \"x-client-id\": clientId } : {},\n }\n );\n\n if (!response.ok) {\n const data = await response.json().catch(() => ({}));\n throw new Error(data.error || \"Failed to resolve account address\");\n }\n\n const data = await response.json();\n return data.address as Address;\n };\n\n const connect = async (): Promise<Address[]> => {\n const stored = getStoredUser();\n if (stored) {\n return [stored.address];\n }\n\n // First try the lightweight connect modal\n const connectResult = await client.connectWithModal();\n\n let username: string | undefined;\n let address: Address | undefined;\n\n if (connectResult.success) {\n // Connection successful (user confirmed or auto-connected)\n username = connectResult.user?.username;\n address = connectResult.user?.address;\n } else if (connectResult.action === \"switch\") {\n // User wants to switch account or no previous user - show auth modal\n const authResult = await client.authWithModal();\n if (!authResult.success) {\n throw new Error(authResult.error?.message || \"Authentication failed\");\n }\n username = authResult.user?.username;\n address = authResult.user?.address;\n } else {\n // Connection was cancelled\n throw new Error(connectResult.error?.message || \"Connection cancelled\");\n }\n\n // Use address from result directly, or resolve from username\n if (!address && username) {\n address = await resolveAccountAddress(username);\n }\n if (!address) {\n throw new Error(\"No account address available\");\n }\n\n setStoredUser({ username, address });\n emit(\"accountsChanged\", [address]);\n emit(\"connect\", { chainId: numberToHex(chainId) });\n return [address];\n };\n\n const disconnect = async () => {\n clearStoredUser();\n emit(\"accountsChanged\", []);\n emit(\"disconnect\");\n };\n\n const ensureUser = async (): Promise<StoredUser> => {\n const stored = getStoredUser();\n if (stored) return stored;\n const [address] = await connect();\n if (!address) {\n throw new Error(\"Failed to resolve user session\");\n }\n const user = getStoredUser();\n return user || { address };\n };\n\n const parseChainId = (value: unknown): number | undefined => {\n if (typeof value === \"number\") return value;\n if (typeof value === \"string\") {\n if (value.startsWith(\"0x\")) return Number.parseInt(value, 16);\n const parsed = Number(value);\n return Number.isFinite(parsed) ? parsed : undefined;\n }\n return undefined;\n };\n\n const normalizeValue = (value: unknown): string | undefined => {\n if (value === undefined || value === null) return undefined;\n if (typeof value === \"bigint\") return value.toString();\n if (typeof value === \"number\") return Math.trunc(value).toString();\n if (typeof value === \"string\") {\n if (value.startsWith(\"0x\")) {\n try {\n return BigInt(value).toString();\n } catch {\n return \"0\";\n }\n }\n return value;\n }\n return undefined;\n };\n\n const normalizeCalls = (calls: unknown[]): IntentCall[] => {\n return calls.map((call) => {\n const c = call as Record<string, unknown>;\n return {\n to: c.to as Address,\n data: (c.data as Hex | undefined) || \"0x\",\n value: normalizeValue(c.value) || \"0\",\n label: c.label as string | undefined,\n sublabel: c.sublabel as string | undefined,\n };\n });\n };\n\n const normalizeTokenRequests = (\n requests: unknown\n ): IntentTokenRequest[] | undefined => {\n if (!Array.isArray(requests)) return undefined;\n return requests.map((r) => {\n const req = r as Record<string, unknown>;\n return {\n token: req.token as string,\n amount:\n typeof req.amount === \"bigint\"\n ? req.amount\n : BigInt(String(req.amount || \"0\")),\n };\n });\n };\n\n const decodeMessage = (value: string) => {\n if (!isHex(value)) return value;\n try {\n return hexToString(value as Hex);\n } catch {\n return value;\n }\n };\n\n const signMessage = async (message: string) => {\n const user = await ensureUser();\n if (!user.username && !user.address) {\n throw new Error(\"Username or address required for signing.\");\n }\n const result = await client.signMessage({\n username: user.username,\n accountAddress: user.address,\n message,\n });\n if (!result.success || !result.signature) {\n throw new Error(result.error?.message || \"Signing failed\");\n }\n return encodeWebAuthnSignature(result.signature);\n };\n\n const signTypedData = async (typedData: unknown) => {\n const user = await ensureUser();\n if (!user.username && !user.address) {\n throw new Error(\"Username or address required for signing.\");\n }\n const data =\n typeof typedData === \"string\" ? JSON.parse(typedData) : typedData;\n const result = await client.signTypedData({\n username: user.username,\n accountAddress: user.address,\n domain: (data as any).domain,\n types: (data as any).types,\n primaryType: (data as any).primaryType,\n message: (data as any).message,\n });\n if (!result.success || !result.signature) {\n throw new Error(result.error?.message || \"Signing failed\");\n }\n return encodeWebAuthnSignature(result.signature);\n };\n\n const resolveIntentPayload = async (payload: {\n username?: string;\n accountAddress: Address;\n targetChain: number;\n calls: IntentCall[];\n tokenRequests?: IntentTokenRequest[];\n }) => {\n if (!options.signIntent) {\n return {\n username: payload.username,\n accountAddress: payload.accountAddress,\n targetChain: payload.targetChain,\n calls: payload.calls,\n tokenRequests: payload.tokenRequests,\n };\n }\n if (!payload.username) {\n throw new Error(\"Username required for signed intents. Set a username first.\");\n }\n const signedIntent = await options.signIntent({\n username: payload.username,\n accountAddress: payload.accountAddress,\n targetChain: payload.targetChain,\n calls: payload.calls,\n tokenRequests: payload.tokenRequests,\n });\n return { signedIntent };\n };\n\n const sendIntent = async (payload: {\n username?: string;\n accountAddress: Address;\n targetChain: number;\n calls: IntentCall[];\n tokenRequests?: IntentTokenRequest[];\n sourceChainId?: number;\n }) => {\n // Use explicit closeOn if provided, otherwise default based on waitForHash\n const closeOn = options.closeOn ?? ((options.waitForHash ?? true) ? \"completed\" : \"preconfirmed\");\n const intentPayload = await resolveIntentPayload(payload);\n const result = await client.sendIntent({\n ...intentPayload,\n tokenRequests: payload.tokenRequests,\n sourceChainId: payload.sourceChainId,\n closeOn,\n waitForHash: options.waitForHash ?? true,\n hashTimeoutMs: options.hashTimeoutMs,\n hashIntervalMs: options.hashIntervalMs,\n });\n\n if (!result.success) {\n throw new Error(result.error?.message || \"Transaction failed\");\n }\n\n // Return intentId as callsId for EIP-5792 compatibility\n return result.intentId;\n };\n\n const request = async ({ method, params }: ProviderRequest) => {\n switch (method) {\n case \"eth_chainId\":\n return numberToHex(chainId);\n case \"eth_accounts\": {\n const stored = getStoredUser();\n return stored ? [stored.address] : [];\n }\n case \"eth_requestAccounts\":\n return connect();\n case \"wallet_connect\":\n return connect();\n case \"wallet_disconnect\":\n await disconnect();\n return true;\n case \"wallet_switchEthereumChain\": {\n const [param] = (params as any[]) || [];\n const next = parseChainId(param?.chainId ?? param);\n if (!next) {\n throw new Error(\"Invalid chainId\");\n }\n chainId = next;\n emit(\"chainChanged\", numberToHex(chainId));\n return null;\n }\n case \"personal_sign\": {\n const paramList = Array.isArray(params) ? params : [];\n const first = paramList[0];\n const second = paramList[1];\n const message =\n typeof first === \"string\" && first.startsWith(\"0x\") && second\n ? typeof second === \"string\" && !second.startsWith(\"0x\")\n ? second\n : decodeMessage(first)\n : typeof first === \"string\"\n ? decodeMessage(first)\n : typeof second === \"string\"\n ? decodeMessage(second)\n : \"\";\n if (!message) throw new Error(\"Invalid personal_sign payload\");\n return signMessage(message);\n }\n case \"eth_sign\": {\n const paramList = Array.isArray(params) ? params : [];\n const message = typeof paramList[1] === \"string\" ? paramList[1] : \"\";\n if (!message) throw new Error(\"Invalid eth_sign payload\");\n return signMessage(decodeMessage(message));\n }\n case \"eth_signTypedData\":\n case \"eth_signTypedData_v4\": {\n const paramList = Array.isArray(params) ? params : [];\n const typedData = paramList[1] ?? paramList[0];\n return signTypedData(typedData);\n }\n case \"eth_sendTransaction\": {\n const paramList = Array.isArray(params) ? params : [];\n const tx = (paramList[0] || {}) as Record<string, unknown>;\n const user = await ensureUser();\n const targetChain = parseChainId(tx.chainId) ?? chainId;\n const calls = normalizeCalls([tx]);\n const tokenRequests = normalizeTokenRequests(tx.tokenRequests);\n const txSourceChainId = parseChainId(tx.sourceChainId);\n return sendIntent({\n username: user.username,\n accountAddress: user.address,\n targetChain,\n calls,\n tokenRequests,\n sourceChainId: txSourceChainId,\n });\n }\n case \"wallet_sendCalls\": {\n const paramList = Array.isArray(params) ? params : [];\n const payload = (paramList[0] || {}) as Record<string, unknown>;\n const user = await ensureUser();\n const targetChain = parseChainId(payload.chainId) ?? chainId;\n const calls = normalizeCalls((payload.calls as unknown[]) || []);\n const tokenRequests = normalizeTokenRequests(payload.tokenRequests);\n const sourceChainId = parseChainId(payload.sourceChainId);\n if (!calls.length) throw new Error(\"No calls provided\");\n return sendIntent({\n username: user.username,\n accountAddress: user.address,\n targetChain,\n calls,\n tokenRequests,\n sourceChainId,\n });\n }\n case \"wallet_getCapabilities\": {\n const paramList = Array.isArray(params) ? params : [];\n // walletAddress is params[0] - we ignore since all accounts have same capabilities\n const requestedChains = paramList[1] as `0x${string}`[] | undefined;\n\n const chainIds = getSupportedChainIds();\n const capabilities: Record<`0x${string}`, Record<string, unknown>> = {};\n\n for (const chainId of chainIds) {\n const hexChainId = `0x${chainId.toString(16)}` as `0x${string}`;\n\n // Filter if specific chains requested\n if (requestedChains && !requestedChains.includes(hexChainId)) {\n continue;\n }\n\n capabilities[hexChainId] = {\n atomic: { status: \"supported\" },\n paymasterService: { supported: true },\n auxiliaryFunds: { supported: true },\n };\n }\n\n return capabilities;\n }\n case \"wallet_getAssets\": {\n const user = await ensureUser();\n if (!user.username) {\n throw new Error(\"Username required to fetch assets. Set a username first.\");\n }\n const clientId = client.getClientId();\n const response = await fetch(\n `${client.getProviderUrl()}/api/users/${encodeURIComponent(user.username)}/portfolio`,\n {\n headers: clientId ? { \"x-client-id\": clientId } : {},\n }\n );\n if (!response.ok) {\n const data = await response.json().catch(() => ({}));\n throw new Error(data.error || \"Failed to get assets\");\n }\n return response.json();\n }\n case \"wallet_getCallsStatus\": {\n const paramList = Array.isArray(params) ? params : [];\n const callsId = paramList[0] as string;\n if (!callsId) {\n throw new Error(\"callsId is required\");\n }\n const statusClientId = client.getClientId();\n const response = await fetch(\n `${client.getProviderUrl()}/api/intent/status/${encodeURIComponent(callsId)}`,\n {\n headers: statusClientId ? { \"x-client-id\": statusClientId } : {},\n }\n );\n if (!response.ok) {\n const data = await response.json().catch(() => ({}));\n throw new Error(data.error || \"Failed to get calls status\");\n }\n const data = await response.json();\n // Map intent status to EIP-5792 format\n const statusMap: Record<string, string> = {\n pending: \"PENDING\",\n preconfirmed: \"PENDING\",\n completed: \"CONFIRMED\",\n failed: \"CONFIRMED\",\n expired: \"CONFIRMED\",\n };\n return {\n status: statusMap[data.status] || \"PENDING\",\n receipts: data.transactionHash\n ? [\n {\n logs: [],\n status: data.status === \"completed\" ? \"0x1\" : \"0x0\",\n blockHash: data.blockHash,\n blockNumber: data.blockNumber,\n transactionHash: data.transactionHash,\n },\n ]\n : [],\n };\n }\n case \"wallet_getCallsHistory\": {\n const paramList = Array.isArray(params) ? params : [];\n const options = (paramList[0] || {}) as {\n limit?: number;\n offset?: number;\n status?: string;\n from?: string;\n to?: string;\n };\n\n const queryParams = new URLSearchParams();\n if (options.limit) queryParams.set(\"limit\", String(options.limit));\n if (options.offset) queryParams.set(\"offset\", String(options.offset));\n if (options.status) queryParams.set(\"status\", options.status);\n if (options.from) queryParams.set(\"from\", options.from);\n if (options.to) queryParams.set(\"to\", options.to);\n\n const url = `${client.getProviderUrl()}/api/intent/history${\n queryParams.toString() ? `?${queryParams}` : \"\"\n }`;\n\n const historyClientId = client.getClientId();\n const response = await fetch(url, {\n headers: historyClientId ? { \"x-client-id\": historyClientId } : {},\n credentials: \"include\",\n });\n\n if (!response.ok) {\n const data = await response.json().catch(() => ({}));\n throw new Error(data.error || \"Failed to get calls history\");\n }\n\n const data = await response.json();\n\n // Map intent status to EIP-5792 format\n const statusMap: Record<string, string> = {\n pending: \"PENDING\",\n preconfirmed: \"PENDING\",\n completed: \"CONFIRMED\",\n failed: \"CONFIRMED\",\n expired: \"CONFIRMED\",\n };\n\n // intentId IS the orchestrator's ID (used as callsId in EIP-5792)\n return {\n calls: data.intents.map(\n (intent: {\n intentId: string;\n status: string;\n transactionHash?: string;\n targetChain: number;\n }) => ({\n callsId: intent.intentId, // intentId is the orchestrator's ID\n status: statusMap[intent.status] || \"PENDING\",\n receipts: intent.transactionHash\n ? [{ transactionHash: intent.transactionHash }]\n : [],\n chainId: `0x${intent.targetChain.toString(16)}`,\n })\n ),\n total: data.total,\n hasMore: data.hasMore,\n };\n }\n default:\n throw new Error(`Unsupported method: ${method}`);\n }\n };\n\n return {\n request,\n on(event, listener) {\n const set = listeners.get(event) ?? new Set();\n set.add(listener);\n listeners.set(event, set);\n },\n removeListener(event, listener) {\n const set = listeners.get(event);\n if (!set) return;\n set.delete(listener);\n if (set.size === 0) listeners.delete(event);\n },\n disconnect,\n };\n}\n","import type { Address, Chain } from \"viem\";\nimport { isAddress } from \"viem\";\nimport * as viemChains from \"viem/chains\";\nimport {\n getAllSupportedChainsAndTokens as getAllSupportedChainsAndTokensRaw,\n getSupportedTokens as getSupportedTokensRaw,\n getTokenAddress,\n getTokenDecimals,\n} from \"@rhinestone/sdk\";\n\nexport type TokenConfig = {\n symbol: string;\n address: Address;\n decimals: number;\n supportsMultichain?: boolean;\n [key: string]: unknown;\n};\n\nexport type ChainFilterOptions = {\n includeTestnets?: boolean;\n chainIds?: number[];\n};\n\nconst env: Record<string, string | undefined> =\n typeof process !== \"undefined\" ? process.env : {};\n\n// Build a chain-ID-to-Chain map from viem, resolving collisions by\n// preferring non-testnet (mainnet) definitions. Viem has duplicate IDs\n// (e.g. zoraTestnet and hyperEvm both use 999) and Map last-write-wins\n// can pick the wrong one.\nconst VIEM_CHAIN_BY_ID = new Map<number, Chain>();\nfor (const value of Object.values(viemChains)) {\n if (typeof value !== \"object\" || value === null || !(\"id\" in value) || !(\"name\" in value)) continue;\n const chain = value as Chain;\n const existing = VIEM_CHAIN_BY_ID.get(chain.id);\n if (!existing || (existing.testnet && !chain.testnet)) {\n VIEM_CHAIN_BY_ID.set(chain.id, chain);\n }\n}\nconst SUPPORTED_CHAIN_IDS = new Set(\n getAllSupportedChainsAndTokensRaw().map((entry) => entry.chainId)\n);\n\nfunction parseBool(value?: string): boolean | undefined {\n if (value === \"true\" || value === \"1\") return true;\n if (value === \"false\" || value === \"0\") return false;\n return undefined;\n}\n\nfunction resolveIncludeTestnets(explicit?: boolean): boolean {\n if (explicit !== undefined) return explicit;\n const envValue =\n parseBool(env.NEXT_PUBLIC_ORCHESTRATOR_USE_TESTNETS) ??\n parseBool(env.ORCHESTRATOR_USE_TESTNETS);\n return envValue ?? false;\n}\n\nfunction applyChainFilters(chainIds: number[], options?: ChainFilterOptions): number[] {\n const includeTestnets = resolveIncludeTestnets(options?.includeTestnets);\n const allowlist = options?.chainIds;\n let filtered = chainIds;\n\n if (!includeTestnets) {\n filtered = filtered.filter((chainId) => !isTestnet(chainId));\n }\n\n if (allowlist && allowlist.length > 0) {\n const allowed = new Set(allowlist);\n filtered = filtered.filter((chainId) => allowed.has(chainId));\n }\n\n return filtered;\n}\n\nexport function getSupportedChainIds(options?: ChainFilterOptions): number[] {\n return applyChainFilters(Array.from(SUPPORTED_CHAIN_IDS), options);\n}\n\nexport function getSupportedChains(options?: ChainFilterOptions): Chain[] {\n return getSupportedChainIds(options)\n .map((chainId) => VIEM_CHAIN_BY_ID.get(chainId))\n .filter((chain): chain is Chain => Boolean(chain));\n}\n\nexport function getAllSupportedChainsAndTokens(options?: ChainFilterOptions): Array<{\n chainId: number;\n tokens: TokenConfig[];\n}> {\n const allowed = new Set(getSupportedChainIds(options));\n return getAllSupportedChainsAndTokensRaw()\n .filter((entry) => allowed.has(entry.chainId))\n .map((entry) => ({\n chainId: entry.chainId,\n tokens: entry.tokens as TokenConfig[],\n }));\n}\n\nexport function getChainById(chainId: number): Chain {\n if (!SUPPORTED_CHAIN_IDS.has(chainId)) {\n throw new Error(`Unsupported chain ID: ${chainId}`);\n }\n const chain = VIEM_CHAIN_BY_ID.get(chainId);\n if (!chain) {\n throw new Error(`Unsupported chain ID: ${chainId}`);\n }\n return chain;\n}\n\nexport function getChainName(chainId: number): string {\n try {\n return getChainById(chainId).name;\n } catch {\n return `Chain ${chainId}`;\n }\n}\n\nexport function getChainExplorerUrl(chainId: number): string | undefined {\n try {\n return getChainById(chainId).blockExplorers?.default?.url;\n } catch {\n return undefined;\n }\n}\n\nexport function getChainRpcUrl(chainId: number): string | undefined {\n try {\n const chain = getChainById(chainId);\n return chain.rpcUrls?.default?.http?.[0] || chain.rpcUrls?.public?.http?.[0];\n } catch {\n return undefined;\n }\n}\n\nexport function getSupportedTokens(chainId: number): TokenConfig[] {\n return getSupportedTokensRaw(chainId) as TokenConfig[];\n}\n\nexport function getSupportedTokenSymbols(chainId: number): string[] {\n return getSupportedTokens(chainId).map((token) => token.symbol);\n}\n\nexport function resolveTokenAddress(token: string, chainId: number): Address {\n if (isAddress(token)) {\n return token;\n }\n // Case-insensitive lookup: find canonical symbol from registry, then resolve\n const match = getSupportedTokens(chainId).find(\n (t) => t.symbol.toUpperCase() === token.toUpperCase()\n );\n if (!match) {\n return getTokenAddress(token as never, chainId);\n }\n return match.address;\n}\n\nexport function isTestnet(chainId: number): boolean {\n try {\n return getChainById(chainId).testnet ?? false;\n } catch {\n return false;\n }\n}\n\nexport function getTokenSymbol(tokenAddress: Address, chainId: number): string {\n const token = getSupportedTokens(chainId).find(\n (entry) => entry.address.toLowerCase() === tokenAddress.toLowerCase()\n );\n if (!token) {\n throw new Error(`Unsupported token: ${tokenAddress} on chain ${chainId}`);\n }\n return token.symbol;\n}\n\nexport function isTokenAddressSupported(tokenAddress: Address, chainId: number): boolean {\n try {\n return getSupportedTokens(chainId).some(\n (entry) => entry.address.toLowerCase() === tokenAddress.toLowerCase()\n );\n } catch {\n return false;\n }\n}\n\nexport { getTokenAddress, getTokenDecimals };\n","import { encodeAbiParameters, keccak256 } from 'viem';\nimport type { Hex } from 'viem';\nimport type { WebAuthnSignature } from '../types';\nimport type { TransactionCall } from './types';\n\n/**\n * P-256 curve order (n)\n * Used for signature malleability normalization\n */\nconst P256_N = BigInt(\n '0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551'\n);\nconst P256_N_DIV_2 = P256_N / 2n;\n\n/**\n * WebAuthnAuth struct type for ABI encoding\n */\nconst WEBAUTHN_AUTH_TYPE = {\n type: 'tuple',\n components: [\n { type: 'bytes', name: 'authenticatorData' },\n { type: 'string', name: 'clientDataJSON' },\n { type: 'uint256', name: 'challengeIndex' },\n { type: 'uint256', name: 'typeIndex' },\n { type: 'uint256', name: 'r' },\n { type: 'uint256', name: 's' },\n ],\n} as const;\n\n/**\n * Encode a WebAuthn signature for ERC-1271 verification on-chain\n *\n * @param sig - The WebAuthn signature from the passkey\n * @returns ABI-encoded signature bytes\n */\nexport function encodeWebAuthnSignature(sig: WebAuthnSignature): Hex {\n // Normalize s to prevent signature malleability\n let s = BigInt(sig.s);\n if (s > P256_N_DIV_2) {\n s = P256_N - s;\n }\n\n return encodeAbiParameters([WEBAUTHN_AUTH_TYPE], [\n {\n authenticatorData: sig.authenticatorData as Hex,\n clientDataJSON: sig.clientDataJSON,\n challengeIndex: BigInt(sig.challengeIndex),\n typeIndex: BigInt(sig.typeIndex),\n r: BigInt(sig.r),\n s,\n },\n ]);\n}\n\n/**\n * Hash an array of transaction calls for signing\n *\n * @param calls - Array of transaction calls\n * @returns keccak256 hash of the encoded calls\n */\nexport function hashCalls(calls: TransactionCall[]): Hex {\n const encoded = encodeAbiParameters(\n [\n {\n type: 'tuple[]',\n components: [\n { type: 'address', name: 'to' },\n { type: 'bytes', name: 'data' },\n { type: 'uint256', name: 'value' },\n ],\n },\n ],\n [\n calls.map((c) => ({\n to: c.to,\n data: c.data || '0x',\n value: c.value || 0n,\n })),\n ]\n );\n return keccak256(encoded);\n}\n\n/**\n * Build transaction review display data from calls\n *\n * @param calls - Array of transaction calls\n * @returns TransactionDetails for the signing modal\n */\nexport function buildTransactionReview(calls: TransactionCall[]) {\n return {\n actions: calls.map((call, i) => ({\n type: 'custom' as const,\n label: call.label || `Contract Call ${i + 1}`,\n sublabel: call.sublabel || `To: ${call.to.slice(0, 10)}...${call.to.slice(-8)}`,\n amount: call.value ? `${call.value} wei` : undefined,\n })),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAgD;AAChD,IAAAA,eAKO;;;ACNP,IAAAC,eAMO;;;ACLP,kBAA0B;AAC1B,iBAA4B;AAC5B,iBAKO;AAeP,IAAM,MACJ,OAAO,YAAY,cAAc,QAAQ,MAAM,CAAC;AAMlD,IAAM,mBAAmB,oBAAI,IAAmB;AAChD,WAAW,SAAS,OAAO,OAAO,UAAU,GAAG;AAC7C,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,EAAE,QAAQ,UAAU,EAAE,UAAU,OAAQ;AAC3F,QAAM,QAAQ;AACd,QAAM,WAAW,iBAAiB,IAAI,MAAM,EAAE;AAC9C,MAAI,C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viem","import_viem","getAllSupportedChainsAndTokensRaw","import_viem","data","chainId","options","provider","chain"]}
|
package/dist/wagmi.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
createOneAuthProvider
|
|
3
|
+
} from "./chunk-N4BLW5UR.mjs";
|
|
4
4
|
|
|
5
5
|
// src/wagmi.ts
|
|
6
6
|
import { createConnector } from "@wagmi/core";
|
|
@@ -101,7 +101,7 @@ function oneAuth(options) {
|
|
|
101
101
|
if (!initialChainId) {
|
|
102
102
|
throw new Error("No chain configured for 1auth connector");
|
|
103
103
|
}
|
|
104
|
-
provider =
|
|
104
|
+
provider = createOneAuthProvider({
|
|
105
105
|
client: options.client,
|
|
106
106
|
chainId: initialChainId,
|
|
107
107
|
storageKey: options.storageKey,
|
package/dist/wagmi.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/wagmi.ts"],"sourcesContent":["import { createConnector, type Connector } from \"@wagmi/core\";\nimport {\n numberToHex,\n type Address,\n type Chain,\n type ProviderConnectInfo,\n} from \"viem\";\nimport { createPasskeyProvider, type PasskeyProvider } from \"./provider\";\nimport type { OneAuthClient } from \"./client\";\nimport type { IntentSigner } from \"./types\";\n\nexport type OneAuthConnectorOptions = {\n client: OneAuthClient;\n chainId?: number;\n storageKey?: string;\n waitForHash?: boolean;\n hashTimeoutMs?: number;\n hashIntervalMs?: number;\n signIntent?: IntentSigner;\n};\n\nexport function oneAuth(options: OneAuthConnectorOptions) {\n type Provider = PasskeyProvider;\n\n return createConnector<Provider>((wagmiConfig) => {\n const chains = (wagmiConfig.chains ?? []) as readonly [Chain, ...Chain[]];\n const initialChainId = options.chainId ?? chains[0]?.id;\n\n let provider: Provider | null = null;\n let accountsChanged: Connector[\"onAccountsChanged\"] | undefined;\n let chainChanged: Connector[\"onChainChanged\"] | undefined;\n let connect: Connector[\"onConnect\"] | undefined;\n let disconnect: Connector[\"onDisconnect\"] | undefined;\n\n return {\n id: \"1auth\",\n name: \"1auth Passkey\",\n type: \"wallet\",\n async connect<withCapabilities extends boolean = false>(\n { chainId, isReconnecting, withCapabilities }:\n | {\n chainId?: number;\n isReconnecting?: boolean;\n withCapabilities?: withCapabilities | boolean;\n }\n | undefined = {}\n ): Promise<{\n accounts: withCapabilities extends true\n ? readonly { address: Address; capabilities: Record<string, unknown> }[]\n : readonly Address[];\n chainId: number;\n }> {\n if (!initialChainId) {\n throw new Error(\"No chain configured for 1auth connector\");\n }\n\n const provider = await this.getProvider({ chainId });\n let accounts: readonly Address[] = [];\n let currentChainId = await this.getChainId();\n\n if (isReconnecting) {\n accounts = await this.getAccounts().catch(() => []);\n }\n\n if (!accounts.length) {\n accounts = (await provider.request({\n method: \"wallet_connect\",\n })) as Address[];\n currentChainId = await this.getChainId();\n }\n\n if (chainId && currentChainId !== chainId) {\n await provider.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: numberToHex(chainId) }],\n });\n currentChainId = await this.getChainId();\n }\n\n if (connect) {\n provider.removeListener(\"connect\", connect as never);\n connect = undefined;\n }\n if (!accountsChanged) {\n accountsChanged = this.onAccountsChanged.bind(this);\n provider.on(\"accountsChanged\", accountsChanged as never);\n }\n if (!chainChanged) {\n chainChanged = this.onChainChanged.bind(this);\n provider.on(\"chainChanged\", chainChanged as never);\n }\n if (!disconnect) {\n disconnect = this.onDisconnect.bind(this);\n provider.on(\"disconnect\", disconnect as never);\n }\n\n const response = withCapabilities\n ? {\n accounts: accounts.map((account) => ({\n address: account,\n capabilities: {},\n })),\n chainId: currentChainId,\n }\n : {\n accounts,\n chainId: currentChainId,\n };\n\n return response as unknown as {\n accounts: withCapabilities extends true\n ? readonly { address: Address; capabilities: Record<string, unknown> }[]\n : readonly Address[];\n chainId: number;\n };\n },\n async disconnect() {\n const provider = await this.getProvider();\n await provider.disconnect();\n if (chainChanged) {\n provider.removeListener(\"chainChanged\", chainChanged as never);\n chainChanged = undefined;\n }\n if (disconnect) {\n provider.removeListener(\"disconnect\", disconnect as never);\n disconnect = undefined;\n }\n },\n async getAccounts() {\n const provider = await this.getProvider();\n return (await provider.request({\n method: \"eth_accounts\",\n })) as Address[];\n },\n async getChainId() {\n const provider = await this.getProvider();\n const hexChainId = (await provider.request({\n method: \"eth_chainId\",\n })) as string;\n return Number.parseInt(hexChainId, 16);\n },\n async getProvider({ chainId } = {}) {\n if (!provider) {\n if (!initialChainId) {\n throw new Error(\"No chain configured for 1auth connector\");\n }\n provider = createPasskeyProvider({\n client: options.client,\n chainId: initialChainId,\n storageKey: options.storageKey,\n waitForHash: options.waitForHash,\n hashTimeoutMs: options.hashTimeoutMs,\n hashIntervalMs: options.hashIntervalMs,\n signIntent: options.signIntent,\n });\n }\n if (chainId) {\n await provider.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: numberToHex(chainId) }],\n });\n }\n return provider;\n },\n async setup() {\n const provider = await this.getProvider();\n if (!connect) {\n const onConnect = this.onConnect?.bind(this);\n if (onConnect) {\n connect = onConnect;\n provider.on(\"connect\", connect as never);\n }\n }\n },\n async isAuthorized() {\n try {\n const accounts = await this.getAccounts();\n return accounts.length > 0;\n } catch {\n return false;\n }\n },\n async switchChain({ chainId }) {\n const chain = chains.find((chain) => chain.id === chainId);\n if (!chain) {\n throw new Error(\"Chain not configured\");\n }\n const provider = await this.getProvider();\n await provider.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: numberToHex(chainId) }],\n });\n return chain;\n },\n async onConnect(connectInfo: ProviderConnectInfo) {\n const accounts = await this.getAccounts();\n if (!accounts.length) return;\n const chainId = Number(connectInfo.chainId);\n wagmiConfig.emitter.emit(\"connect\", { accounts, chainId });\n },\n onAccountsChanged(accounts: string[]) {\n wagmiConfig.emitter.emit(\"change\", {\n accounts: accounts as Address[],\n });\n },\n onChainChanged(chainId: string) {\n wagmiConfig.emitter.emit(\"change\", {\n chainId: Number(chainId),\n });\n },\n onDisconnect(_error?: Error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AAC,SAAS,OAAQ;AACtB,cAAM,UAAU,OAAO,YAAY,OAAO;AAC1C,oBAAY,QAAQ,KAAK,WAAW,EAAE,UAAU,QAAQ,CAAC;AAAA,MAC3D;AAAA,MACA,kBAAkB,UAAoB;AACpC,oBAAY,QAAQ,KAAK,UAAU;AAAA,UACjC;AAAA,QACF,CAAC;AAAA,MACH;AAAA,MACA,eAAe,SAAiB;AAC9B,oBAAY,QAAQ,KAAK,UAAU;AAAA,UACjC,SAAS,OAAO,OAAO;AAAA,QACzB,CAAC;AAAA,MACH;AAAA,MACA,aAAa,QAAgB;AAC3B,oBAAY,QAAQ,KAAK,YAAY;AAAA,MACvC;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":["provider","chain"]}
|
|
1
|
+
{"version":3,"sources":["../src/wagmi.ts"],"sourcesContent":["import { createConnector, type Connector } from \"@wagmi/core\";\nimport {\n numberToHex,\n type Address,\n type Chain,\n type ProviderConnectInfo,\n} from \"viem\";\nimport { createOneAuthProvider, type OneAuthProvider } from \"./provider\";\nimport type { OneAuthClient } from \"./client\";\nimport type { IntentSigner } from \"./types\";\n\nexport type OneAuthConnectorOptions = {\n client: OneAuthClient;\n chainId?: number;\n storageKey?: string;\n waitForHash?: boolean;\n hashTimeoutMs?: number;\n hashIntervalMs?: number;\n signIntent?: IntentSigner;\n};\n\nexport function oneAuth(options: OneAuthConnectorOptions) {\n type Provider = OneAuthProvider;\n\n return createConnector<Provider>((wagmiConfig) => {\n const chains = (wagmiConfig.chains ?? []) as readonly [Chain, ...Chain[]];\n const initialChainId = options.chainId ?? chains[0]?.id;\n\n let provider: Provider | null = null;\n let accountsChanged: Connector[\"onAccountsChanged\"] | undefined;\n let chainChanged: Connector[\"onChainChanged\"] | undefined;\n let connect: Connector[\"onConnect\"] | undefined;\n let disconnect: Connector[\"onDisconnect\"] | undefined;\n\n return {\n id: \"1auth\",\n name: \"1auth Passkey\",\n type: \"wallet\",\n async connect<withCapabilities extends boolean = false>(\n { chainId, isReconnecting, withCapabilities }:\n | {\n chainId?: number;\n isReconnecting?: boolean;\n withCapabilities?: withCapabilities | boolean;\n }\n | undefined = {}\n ): Promise<{\n accounts: withCapabilities extends true\n ? readonly { address: Address; capabilities: Record<string, unknown> }[]\n : readonly Address[];\n chainId: number;\n }> {\n if (!initialChainId) {\n throw new Error(\"No chain configured for 1auth connector\");\n }\n\n const provider = await this.getProvider({ chainId });\n let accounts: readonly Address[] = [];\n let currentChainId = await this.getChainId();\n\n if (isReconnecting) {\n accounts = await this.getAccounts().catch(() => []);\n }\n\n if (!accounts.length) {\n accounts = (await provider.request({\n method: \"wallet_connect\",\n })) as Address[];\n currentChainId = await this.getChainId();\n }\n\n if (chainId && currentChainId !== chainId) {\n await provider.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: numberToHex(chainId) }],\n });\n currentChainId = await this.getChainId();\n }\n\n if (connect) {\n provider.removeListener(\"connect\", connect as never);\n connect = undefined;\n }\n if (!accountsChanged) {\n accountsChanged = this.onAccountsChanged.bind(this);\n provider.on(\"accountsChanged\", accountsChanged as never);\n }\n if (!chainChanged) {\n chainChanged = this.onChainChanged.bind(this);\n provider.on(\"chainChanged\", chainChanged as never);\n }\n if (!disconnect) {\n disconnect = this.onDisconnect.bind(this);\n provider.on(\"disconnect\", disconnect as never);\n }\n\n const response = withCapabilities\n ? {\n accounts: accounts.map((account) => ({\n address: account,\n capabilities: {},\n })),\n chainId: currentChainId,\n }\n : {\n accounts,\n chainId: currentChainId,\n };\n\n return response as unknown as {\n accounts: withCapabilities extends true\n ? readonly { address: Address; capabilities: Record<string, unknown> }[]\n : readonly Address[];\n chainId: number;\n };\n },\n async disconnect() {\n const provider = await this.getProvider();\n await provider.disconnect();\n if (chainChanged) {\n provider.removeListener(\"chainChanged\", chainChanged as never);\n chainChanged = undefined;\n }\n if (disconnect) {\n provider.removeListener(\"disconnect\", disconnect as never);\n disconnect = undefined;\n }\n },\n async getAccounts() {\n const provider = await this.getProvider();\n return (await provider.request({\n method: \"eth_accounts\",\n })) as Address[];\n },\n async getChainId() {\n const provider = await this.getProvider();\n const hexChainId = (await provider.request({\n method: \"eth_chainId\",\n })) as string;\n return Number.parseInt(hexChainId, 16);\n },\n async getProvider({ chainId } = {}) {\n if (!provider) {\n if (!initialChainId) {\n throw new Error(\"No chain configured for 1auth connector\");\n }\n provider = createOneAuthProvider({\n client: options.client,\n chainId: initialChainId,\n storageKey: options.storageKey,\n waitForHash: options.waitForHash,\n hashTimeoutMs: options.hashTimeoutMs,\n hashIntervalMs: options.hashIntervalMs,\n signIntent: options.signIntent,\n });\n }\n if (chainId) {\n await provider.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: numberToHex(chainId) }],\n });\n }\n return provider;\n },\n async setup() {\n const provider = await this.getProvider();\n if (!connect) {\n const onConnect = this.onConnect?.bind(this);\n if (onConnect) {\n connect = onConnect;\n provider.on(\"connect\", connect as never);\n }\n }\n },\n async isAuthorized() {\n try {\n const accounts = await this.getAccounts();\n return accounts.length > 0;\n } catch {\n return false;\n }\n },\n async switchChain({ chainId }) {\n const chain = chains.find((chain) => chain.id === chainId);\n if (!chain) {\n throw new Error(\"Chain not configured\");\n }\n const provider = await this.getProvider();\n await provider.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: numberToHex(chainId) }],\n });\n return chain;\n },\n async onConnect(connectInfo: ProviderConnectInfo) {\n const accounts = await this.getAccounts();\n if (!accounts.length) return;\n const chainId = Number(connectInfo.chainId);\n wagmiConfig.emitter.emit(\"connect\", { accounts, chainId });\n },\n onAccountsChanged(accounts: string[]) {\n wagmiConfig.emitter.emit(\"change\", {\n accounts: accounts as Address[],\n });\n },\n onChainChanged(chainId: string) {\n wagmiConfig.emitter.emit(\"change\", {\n chainId: Number(chainId),\n });\n },\n onDisconnect(_error?: Error) {\n wagmiConfig.emitter.emit(\"disconnect\");\n },\n };\n });\n}\n"],"mappings":";;;;;AAAA,SAAS,uBAAuC;AAChD;AAAA,EACE;AAAA,OAIK;AAe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A,MAC3D;AAAA,MACA,kBAAkB,UAAoB;AACpC,oBAAY,QAAQ,KAAK,UAAU;AAAA,UACjC;AAAA,QACF,CAAC;AAAA,MACH;AAAA,MACA,eAAe,SAAiB;AAC9B,oBAAY,QAAQ,KAAK,UAAU;AAAA,UACjC,SAAS,OAAO,OAAO;AAAA,QACzB,CAAC;AAAA,MACH;AAAA,MACA,aAAa,QAAgB;AAC3B,oBAAY,QAAQ,KAAK,YAAY;AAAA,MACvC;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":["provider","chain"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhinestone/1auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Passkey-based authentication SDK for Web3 applications",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -33,11 +33,12 @@
|
|
|
33
33
|
],
|
|
34
34
|
"repository": {
|
|
35
35
|
"type": "git",
|
|
36
|
-
"url": "git+https://github.com/rhinestonewtf/1auth
|
|
36
|
+
"url": "git+https://github.com/rhinestonewtf/1auth.git",
|
|
37
|
+
"directory": "packages/sdk"
|
|
37
38
|
},
|
|
38
|
-
"homepage": "https://github.com/rhinestonewtf/1auth
|
|
39
|
+
"homepage": "https://github.com/rhinestonewtf/1auth/tree/main/packages/sdk#readme",
|
|
39
40
|
"bugs": {
|
|
40
|
-
"url": "https://github.com/rhinestonewtf/1auth
|
|
41
|
+
"url": "https://github.com/rhinestonewtf/1auth/issues"
|
|
41
42
|
},
|
|
42
43
|
"publishConfig": {
|
|
43
44
|
"access": "public"
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
"type-check": "tsc --noEmit"
|
|
50
51
|
},
|
|
51
52
|
"dependencies": {
|
|
52
|
-
"@rhinestone/sdk": "^1.2.
|
|
53
|
+
"@rhinestone/sdk": "^1.2.13"
|
|
53
54
|
},
|
|
54
55
|
"peerDependencies": {
|
|
55
56
|
"@wagmi/core": "^2.0.0",
|
|
@@ -71,4 +72,4 @@
|
|
|
71
72
|
"viem": "^2.21.0",
|
|
72
73
|
"vitest": "^2.1.0"
|
|
73
74
|
}
|
|
74
|
-
}
|
|
75
|
+
}
|