@rhinestone/1auth 0.1.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-UXYKIMGZ.mjs +482 -0
- package/dist/chunk-UXYKIMGZ.mjs.map +1 -0
- package/dist/client-C1inywuT.d.mts +777 -0
- package/dist/client-C1inywuT.d.ts +777 -0
- package/dist/index.d.mts +267 -0
- package/dist/index.d.ts +267 -0
- package/dist/index.js +2701 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2213 -0
- package/dist/index.mjs.map +1 -0
- package/dist/provider-Dgh51NRc.d.mts +24 -0
- package/dist/provider-q7M728Mn.d.ts +24 -0
- package/dist/react.d.mts +41 -0
- package/dist/react.d.ts +41 -0
- package/dist/react.js +228 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +193 -0
- package/dist/react.mjs.map +1 -0
- package/dist/server.d.mts +81 -0
- package/dist/server.d.ts +81 -0
- package/dist/server.js +142 -0
- package/dist/server.js.map +1 -0
- package/dist/server.mjs +116 -0
- package/dist/server.mjs.map +1 -0
- package/dist/wagmi.d.mts +15 -0
- package/dist/wagmi.d.ts +15 -0
- package/dist/wagmi.js +569 -0
- package/dist/wagmi.js.map +1 -0
- package/dist/wagmi.mjs +176 -0
- package/dist/wagmi.mjs.map +1 -0
- package/package.json +61 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { P as PasskeyProviderClient, W as WebAuthnSignature, I as IntentCall, S as SendIntentResult } from './client-C1inywuT.mjs';
|
|
2
|
+
export { A as AuthenticateOptions, k as AuthenticateResult, B as BalanceRequirement, y as CloseOnStatus, C as CreateSigningRequestResponse, p as EIP712Domain, r as EIP712TypeField, q as EIP712Types, E as EmbedOptions, D as ExecuteIntentResponse, w as IntentQuote, x as IntentStatus, u as IntentTokenRequest, L as LoginOptions, j as LoginResult, M as MerchantSignedIntent, O as OrchestratorStatus, h as PasskeyCredential, a as PasskeyProviderConfig, z as PrepareIntentResponse, R as RegisterOptions, i as RegisterResult, v as SendIntentOptions, F as SendSwapOptions, G as SendSwapResult, l as SignMessageOptions, m as SignMessageResult, n as SignTypedDataOptions, o as SignTypedDataResult, e as SigningError, f as SigningErrorCode, b as SigningRequestOptions, g as SigningRequestStatus, c as SigningResult, d as SigningSuccess, H as SwapQuote, J as ThemeConfig, T as TransactionAction, t as TransactionDetails, s as TransactionFees, U as UserPasskeysResponse } from './client-C1inywuT.mjs';
|
|
3
|
+
export { P as PasskeyProvider, a as PasskeyProviderOptions, c as createPasskeyProvider } from './provider-Dgh51NRc.mjs';
|
|
4
|
+
import { Address, LocalAccount, Chain, Transport, Hex, WalletClient, Hash } from 'viem';
|
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
export { getTokenAddress, getTokenDecimals } from '@rhinestone/sdk';
|
|
8
|
+
|
|
9
|
+
type PasskeyAccount = LocalAccount<"1auth"> & {
|
|
10
|
+
username: string;
|
|
11
|
+
};
|
|
12
|
+
declare function createPasskeyAccount(client: PasskeyProviderClient, params: {
|
|
13
|
+
address: Address;
|
|
14
|
+
username: string;
|
|
15
|
+
}): PasskeyAccount;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Configuration for creating a passkey-enabled WalletClient
|
|
19
|
+
*/
|
|
20
|
+
interface PasskeyWalletClientConfig {
|
|
21
|
+
/** User's smart account address */
|
|
22
|
+
accountAddress: Address;
|
|
23
|
+
/** Username for the passkey provider */
|
|
24
|
+
username: string;
|
|
25
|
+
/** Base URL of the auth API */
|
|
26
|
+
providerUrl: string;
|
|
27
|
+
/** Client identifier for this application */
|
|
28
|
+
clientId: string;
|
|
29
|
+
/** Optional URL of the dialog UI */
|
|
30
|
+
dialogUrl?: string;
|
|
31
|
+
/** Chain configuration */
|
|
32
|
+
chain: Chain;
|
|
33
|
+
/** Transport (e.g., http(), webSocket()) */
|
|
34
|
+
transport: Transport;
|
|
35
|
+
/** Wait for a transaction hash before resolving send calls. */
|
|
36
|
+
waitForHash?: boolean;
|
|
37
|
+
/** Maximum time to wait for a transaction hash in ms. */
|
|
38
|
+
hashTimeoutMs?: number;
|
|
39
|
+
/** Poll interval for transaction hash in ms. */
|
|
40
|
+
hashIntervalMs?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A single call in a batch transaction
|
|
44
|
+
*/
|
|
45
|
+
interface TransactionCall {
|
|
46
|
+
/** Target contract address */
|
|
47
|
+
to: Address;
|
|
48
|
+
/** Calldata to send */
|
|
49
|
+
data?: Hex;
|
|
50
|
+
/** Value in wei to send */
|
|
51
|
+
value?: bigint;
|
|
52
|
+
/** Optional label for the transaction review UI (e.g., "Swap ETH for USDC") */
|
|
53
|
+
label?: string;
|
|
54
|
+
/** Optional sublabel for additional context (e.g., "1 ETH → 2,500 USDC") */
|
|
55
|
+
sublabel?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Parameters for sendCalls (batched transactions)
|
|
59
|
+
*/
|
|
60
|
+
interface SendCallsParams {
|
|
61
|
+
/** Array of calls to execute */
|
|
62
|
+
calls: TransactionCall[];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Encode a WebAuthn signature for ERC-1271 verification on-chain
|
|
67
|
+
*
|
|
68
|
+
* @param sig - The WebAuthn signature from the passkey
|
|
69
|
+
* @returns ABI-encoded signature bytes
|
|
70
|
+
*/
|
|
71
|
+
declare function encodeWebAuthnSignature(sig: WebAuthnSignature): Hex;
|
|
72
|
+
/**
|
|
73
|
+
* Hash an array of transaction calls for signing
|
|
74
|
+
*
|
|
75
|
+
* @param calls - Array of transaction calls
|
|
76
|
+
* @returns keccak256 hash of the encoded calls
|
|
77
|
+
*/
|
|
78
|
+
declare function hashCalls(calls: TransactionCall[]): Hex;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Extended WalletClient with passkey signing and batch transaction support
|
|
82
|
+
*/
|
|
83
|
+
type PasskeyWalletClient = WalletClient & {
|
|
84
|
+
/**
|
|
85
|
+
* Send multiple calls as a single batched transaction
|
|
86
|
+
* Opens the passkey modal for user approval
|
|
87
|
+
*/
|
|
88
|
+
sendCalls: (params: SendCallsParams) => Promise<Hash>;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Create a viem-compatible WalletClient that uses passkeys for signing
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* import { createPasskeyWalletClient } from '@rhinestone/1auth';
|
|
96
|
+
* import { baseSepolia } from 'viem/chains';
|
|
97
|
+
* import { http } from 'viem';
|
|
98
|
+
*
|
|
99
|
+
* const walletClient = createPasskeyWalletClient({
|
|
100
|
+
* accountAddress: '0x...',
|
|
101
|
+
* username: 'alice',
|
|
102
|
+
* providerUrl: 'https://auth.example.com',
|
|
103
|
+
* clientId: 'my-dapp',
|
|
104
|
+
* chain: baseSepolia,
|
|
105
|
+
* transport: http(),
|
|
106
|
+
* });
|
|
107
|
+
*
|
|
108
|
+
* // Standard viem API
|
|
109
|
+
* const hash = await walletClient.sendTransaction({
|
|
110
|
+
* to: '0x...',
|
|
111
|
+
* data: '0x...',
|
|
112
|
+
* value: 0n,
|
|
113
|
+
* });
|
|
114
|
+
*
|
|
115
|
+
* // Batched transactions
|
|
116
|
+
* const batchHash = await walletClient.sendCalls({
|
|
117
|
+
* calls: [
|
|
118
|
+
* { to: '0x...', data: '0x...' },
|
|
119
|
+
* { to: '0x...', data: '0x...' },
|
|
120
|
+
* ],
|
|
121
|
+
* });
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
declare function createPasskeyWalletClient(config: PasskeyWalletClientConfig): PasskeyWalletClient;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* A batched call in the queue
|
|
128
|
+
*/
|
|
129
|
+
interface BatchedCall {
|
|
130
|
+
/** Unique ID for removal */
|
|
131
|
+
id: string;
|
|
132
|
+
/** The actual call data */
|
|
133
|
+
call: IntentCall;
|
|
134
|
+
/** Chain ID for execution */
|
|
135
|
+
targetChain: number;
|
|
136
|
+
/** Timestamp when added */
|
|
137
|
+
addedAt: number;
|
|
138
|
+
}
|
|
139
|
+
declare function getChainName(chainId: number): string;
|
|
140
|
+
/**
|
|
141
|
+
* Batch queue context value
|
|
142
|
+
*/
|
|
143
|
+
interface BatchQueueContextValue {
|
|
144
|
+
/** Current queue of batched calls */
|
|
145
|
+
queue: BatchedCall[];
|
|
146
|
+
/** Chain ID of the current batch (from first call) */
|
|
147
|
+
batchChainId: number | null;
|
|
148
|
+
/** Add a call to the batch */
|
|
149
|
+
addToBatch: (call: IntentCall, targetChain: number) => {
|
|
150
|
+
success: boolean;
|
|
151
|
+
error?: string;
|
|
152
|
+
};
|
|
153
|
+
/** Remove a call from the batch */
|
|
154
|
+
removeFromBatch: (id: string) => void;
|
|
155
|
+
/** Clear all calls from the batch */
|
|
156
|
+
clearBatch: () => void;
|
|
157
|
+
/** Sign and execute all batched calls */
|
|
158
|
+
signAll: (username: string) => Promise<SendIntentResult>;
|
|
159
|
+
/** Whether the widget is expanded */
|
|
160
|
+
isExpanded: boolean;
|
|
161
|
+
/** Set widget expanded state */
|
|
162
|
+
setExpanded: (expanded: boolean) => void;
|
|
163
|
+
/** Whether signing is in progress */
|
|
164
|
+
isSigning: boolean;
|
|
165
|
+
/** Animation trigger for bounce effect */
|
|
166
|
+
animationTrigger: number;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Hook to access the batch queue context
|
|
170
|
+
*/
|
|
171
|
+
declare function useBatchQueue(): BatchQueueContextValue;
|
|
172
|
+
interface BatchQueueProviderProps {
|
|
173
|
+
/** The PasskeyProviderClient instance */
|
|
174
|
+
client: PasskeyProviderClient;
|
|
175
|
+
/** Optional username for localStorage persistence key */
|
|
176
|
+
username?: string;
|
|
177
|
+
/** Children to render */
|
|
178
|
+
children: React.ReactNode;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Provider component for the batch queue
|
|
182
|
+
*/
|
|
183
|
+
declare function BatchQueueProvider({ client, username, children, }: BatchQueueProviderProps): react_jsx_runtime.JSX.Element;
|
|
184
|
+
|
|
185
|
+
interface BatchQueueWidgetProps {
|
|
186
|
+
/** Callback when "Sign All" is clicked - should provide username */
|
|
187
|
+
onSignAll: () => void;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Floating widget showing the batch queue
|
|
191
|
+
*/
|
|
192
|
+
declare function BatchQueueWidget({ onSignAll }: BatchQueueWidgetProps): react_jsx_runtime.JSX.Element | null;
|
|
193
|
+
|
|
194
|
+
type TokenConfig = {
|
|
195
|
+
symbol: string;
|
|
196
|
+
address: Address;
|
|
197
|
+
decimals: number;
|
|
198
|
+
supportsMultichain?: boolean;
|
|
199
|
+
[key: string]: unknown;
|
|
200
|
+
};
|
|
201
|
+
type ChainFilterOptions = {
|
|
202
|
+
includeTestnets?: boolean;
|
|
203
|
+
chainIds?: number[];
|
|
204
|
+
};
|
|
205
|
+
declare function getSupportedChainIds(options?: ChainFilterOptions): number[];
|
|
206
|
+
declare function getSupportedChains(options?: ChainFilterOptions): Chain[];
|
|
207
|
+
declare function getAllSupportedChainsAndTokens(options?: ChainFilterOptions): Array<{
|
|
208
|
+
chainId: number;
|
|
209
|
+
tokens: TokenConfig[];
|
|
210
|
+
}>;
|
|
211
|
+
declare function getChainById(chainId: number): Chain;
|
|
212
|
+
declare function getChainExplorerUrl(chainId: number): string | undefined;
|
|
213
|
+
declare function getChainRpcUrl(chainId: number): string | undefined;
|
|
214
|
+
declare function getSupportedTokens(chainId: number): TokenConfig[];
|
|
215
|
+
declare function getSupportedTokenSymbols(chainId: number): string[];
|
|
216
|
+
declare function resolveTokenAddress(token: string, chainId: number): Address;
|
|
217
|
+
declare function isTestnet(chainId: number): boolean;
|
|
218
|
+
declare function getTokenSymbol(tokenAddress: Address, chainId: number): string;
|
|
219
|
+
declare function isTokenAddressSupported(tokenAddress: Address, chainId: number): boolean;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* The domain separator prefix used for passkey message signing.
|
|
223
|
+
* This ensures message signatures cannot be replayed for transaction signing.
|
|
224
|
+
*/
|
|
225
|
+
declare const PASSKEY_MESSAGE_PREFIX = "\u0019Passkey Signed Message:\n";
|
|
226
|
+
/**
|
|
227
|
+
* Hash a message with the passkey domain separator.
|
|
228
|
+
*
|
|
229
|
+
* This is the same hashing function used by the passkey sign dialog.
|
|
230
|
+
* Use this to verify that the `signedHash` returned from `signMessage()`
|
|
231
|
+
* matches your original message.
|
|
232
|
+
*
|
|
233
|
+
* Format: keccak256("\x19Passkey Signed Message:\n" + len + message)
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```typescript
|
|
237
|
+
* const message = "Sign in to MyApp\nTimestamp: 1234567890";
|
|
238
|
+
* const result = await client.signMessage({ username: 'alice', message });
|
|
239
|
+
*
|
|
240
|
+
* // Verify the hash matches
|
|
241
|
+
* const expectedHash = hashMessage(message);
|
|
242
|
+
* if (result.signedHash === expectedHash) {
|
|
243
|
+
* console.log('Hash matches - signature is for this message');
|
|
244
|
+
* }
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
declare function hashMessage(message: string): `0x${string}`;
|
|
248
|
+
/**
|
|
249
|
+
* Verify that a signedHash matches the expected message.
|
|
250
|
+
*
|
|
251
|
+
* This is a convenience wrapper around `hashMessage()` that returns
|
|
252
|
+
* a boolean. For full cryptographic verification of the P256 signature,
|
|
253
|
+
* use on-chain verification via the WebAuthn.sol contract.
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* const result = await client.signMessage({ username: 'alice', message });
|
|
258
|
+
*
|
|
259
|
+
* if (result.success && verifyMessageHash(message, result.signedHash)) {
|
|
260
|
+
* // The signature is for this exact message
|
|
261
|
+
* // For full verification, verify the P256 signature on-chain or server-side
|
|
262
|
+
* }
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
declare function verifyMessageHash(message: string, signedHash: string | undefined): boolean;
|
|
266
|
+
|
|
267
|
+
export { type BatchQueueContextValue, BatchQueueProvider, type BatchQueueProviderProps, BatchQueueWidget, type BatchQueueWidgetProps, type BatchedCall, type ChainFilterOptions, IntentCall, PASSKEY_MESSAGE_PREFIX, type PasskeyAccount, PasskeyProviderClient, type PasskeyWalletClient, type PasskeyWalletClientConfig, type SendCallsParams, SendIntentResult, type TokenConfig, type TransactionCall, WebAuthnSignature, createPasskeyAccount, createPasskeyWalletClient, encodeWebAuthnSignature, getAllSupportedChainsAndTokens, getChainById, getChainExplorerUrl, getChainName, getChainRpcUrl, getSupportedChainIds, getSupportedChains, getSupportedTokenSymbols, getSupportedTokens, getTokenSymbol, hashCalls, hashMessage, isTestnet, isTokenAddressSupported, resolveTokenAddress, useBatchQueue, verifyMessageHash };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { P as PasskeyProviderClient, W as WebAuthnSignature, I as IntentCall, S as SendIntentResult } from './client-C1inywuT.js';
|
|
2
|
+
export { A as AuthenticateOptions, k as AuthenticateResult, B as BalanceRequirement, y as CloseOnStatus, C as CreateSigningRequestResponse, p as EIP712Domain, r as EIP712TypeField, q as EIP712Types, E as EmbedOptions, D as ExecuteIntentResponse, w as IntentQuote, x as IntentStatus, u as IntentTokenRequest, L as LoginOptions, j as LoginResult, M as MerchantSignedIntent, O as OrchestratorStatus, h as PasskeyCredential, a as PasskeyProviderConfig, z as PrepareIntentResponse, R as RegisterOptions, i as RegisterResult, v as SendIntentOptions, F as SendSwapOptions, G as SendSwapResult, l as SignMessageOptions, m as SignMessageResult, n as SignTypedDataOptions, o as SignTypedDataResult, e as SigningError, f as SigningErrorCode, b as SigningRequestOptions, g as SigningRequestStatus, c as SigningResult, d as SigningSuccess, H as SwapQuote, J as ThemeConfig, T as TransactionAction, t as TransactionDetails, s as TransactionFees, U as UserPasskeysResponse } from './client-C1inywuT.js';
|
|
3
|
+
export { P as PasskeyProvider, a as PasskeyProviderOptions, c as createPasskeyProvider } from './provider-q7M728Mn.js';
|
|
4
|
+
import { Address, LocalAccount, Chain, Transport, Hex, WalletClient, Hash } from 'viem';
|
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
export { getTokenAddress, getTokenDecimals } from '@rhinestone/sdk';
|
|
8
|
+
|
|
9
|
+
type PasskeyAccount = LocalAccount<"1auth"> & {
|
|
10
|
+
username: string;
|
|
11
|
+
};
|
|
12
|
+
declare function createPasskeyAccount(client: PasskeyProviderClient, params: {
|
|
13
|
+
address: Address;
|
|
14
|
+
username: string;
|
|
15
|
+
}): PasskeyAccount;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Configuration for creating a passkey-enabled WalletClient
|
|
19
|
+
*/
|
|
20
|
+
interface PasskeyWalletClientConfig {
|
|
21
|
+
/** User's smart account address */
|
|
22
|
+
accountAddress: Address;
|
|
23
|
+
/** Username for the passkey provider */
|
|
24
|
+
username: string;
|
|
25
|
+
/** Base URL of the auth API */
|
|
26
|
+
providerUrl: string;
|
|
27
|
+
/** Client identifier for this application */
|
|
28
|
+
clientId: string;
|
|
29
|
+
/** Optional URL of the dialog UI */
|
|
30
|
+
dialogUrl?: string;
|
|
31
|
+
/** Chain configuration */
|
|
32
|
+
chain: Chain;
|
|
33
|
+
/** Transport (e.g., http(), webSocket()) */
|
|
34
|
+
transport: Transport;
|
|
35
|
+
/** Wait for a transaction hash before resolving send calls. */
|
|
36
|
+
waitForHash?: boolean;
|
|
37
|
+
/** Maximum time to wait for a transaction hash in ms. */
|
|
38
|
+
hashTimeoutMs?: number;
|
|
39
|
+
/** Poll interval for transaction hash in ms. */
|
|
40
|
+
hashIntervalMs?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A single call in a batch transaction
|
|
44
|
+
*/
|
|
45
|
+
interface TransactionCall {
|
|
46
|
+
/** Target contract address */
|
|
47
|
+
to: Address;
|
|
48
|
+
/** Calldata to send */
|
|
49
|
+
data?: Hex;
|
|
50
|
+
/** Value in wei to send */
|
|
51
|
+
value?: bigint;
|
|
52
|
+
/** Optional label for the transaction review UI (e.g., "Swap ETH for USDC") */
|
|
53
|
+
label?: string;
|
|
54
|
+
/** Optional sublabel for additional context (e.g., "1 ETH → 2,500 USDC") */
|
|
55
|
+
sublabel?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Parameters for sendCalls (batched transactions)
|
|
59
|
+
*/
|
|
60
|
+
interface SendCallsParams {
|
|
61
|
+
/** Array of calls to execute */
|
|
62
|
+
calls: TransactionCall[];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Encode a WebAuthn signature for ERC-1271 verification on-chain
|
|
67
|
+
*
|
|
68
|
+
* @param sig - The WebAuthn signature from the passkey
|
|
69
|
+
* @returns ABI-encoded signature bytes
|
|
70
|
+
*/
|
|
71
|
+
declare function encodeWebAuthnSignature(sig: WebAuthnSignature): Hex;
|
|
72
|
+
/**
|
|
73
|
+
* Hash an array of transaction calls for signing
|
|
74
|
+
*
|
|
75
|
+
* @param calls - Array of transaction calls
|
|
76
|
+
* @returns keccak256 hash of the encoded calls
|
|
77
|
+
*/
|
|
78
|
+
declare function hashCalls(calls: TransactionCall[]): Hex;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Extended WalletClient with passkey signing and batch transaction support
|
|
82
|
+
*/
|
|
83
|
+
type PasskeyWalletClient = WalletClient & {
|
|
84
|
+
/**
|
|
85
|
+
* Send multiple calls as a single batched transaction
|
|
86
|
+
* Opens the passkey modal for user approval
|
|
87
|
+
*/
|
|
88
|
+
sendCalls: (params: SendCallsParams) => Promise<Hash>;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Create a viem-compatible WalletClient that uses passkeys for signing
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* import { createPasskeyWalletClient } from '@rhinestone/1auth';
|
|
96
|
+
* import { baseSepolia } from 'viem/chains';
|
|
97
|
+
* import { http } from 'viem';
|
|
98
|
+
*
|
|
99
|
+
* const walletClient = createPasskeyWalletClient({
|
|
100
|
+
* accountAddress: '0x...',
|
|
101
|
+
* username: 'alice',
|
|
102
|
+
* providerUrl: 'https://auth.example.com',
|
|
103
|
+
* clientId: 'my-dapp',
|
|
104
|
+
* chain: baseSepolia,
|
|
105
|
+
* transport: http(),
|
|
106
|
+
* });
|
|
107
|
+
*
|
|
108
|
+
* // Standard viem API
|
|
109
|
+
* const hash = await walletClient.sendTransaction({
|
|
110
|
+
* to: '0x...',
|
|
111
|
+
* data: '0x...',
|
|
112
|
+
* value: 0n,
|
|
113
|
+
* });
|
|
114
|
+
*
|
|
115
|
+
* // Batched transactions
|
|
116
|
+
* const batchHash = await walletClient.sendCalls({
|
|
117
|
+
* calls: [
|
|
118
|
+
* { to: '0x...', data: '0x...' },
|
|
119
|
+
* { to: '0x...', data: '0x...' },
|
|
120
|
+
* ],
|
|
121
|
+
* });
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
declare function createPasskeyWalletClient(config: PasskeyWalletClientConfig): PasskeyWalletClient;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* A batched call in the queue
|
|
128
|
+
*/
|
|
129
|
+
interface BatchedCall {
|
|
130
|
+
/** Unique ID for removal */
|
|
131
|
+
id: string;
|
|
132
|
+
/** The actual call data */
|
|
133
|
+
call: IntentCall;
|
|
134
|
+
/** Chain ID for execution */
|
|
135
|
+
targetChain: number;
|
|
136
|
+
/** Timestamp when added */
|
|
137
|
+
addedAt: number;
|
|
138
|
+
}
|
|
139
|
+
declare function getChainName(chainId: number): string;
|
|
140
|
+
/**
|
|
141
|
+
* Batch queue context value
|
|
142
|
+
*/
|
|
143
|
+
interface BatchQueueContextValue {
|
|
144
|
+
/** Current queue of batched calls */
|
|
145
|
+
queue: BatchedCall[];
|
|
146
|
+
/** Chain ID of the current batch (from first call) */
|
|
147
|
+
batchChainId: number | null;
|
|
148
|
+
/** Add a call to the batch */
|
|
149
|
+
addToBatch: (call: IntentCall, targetChain: number) => {
|
|
150
|
+
success: boolean;
|
|
151
|
+
error?: string;
|
|
152
|
+
};
|
|
153
|
+
/** Remove a call from the batch */
|
|
154
|
+
removeFromBatch: (id: string) => void;
|
|
155
|
+
/** Clear all calls from the batch */
|
|
156
|
+
clearBatch: () => void;
|
|
157
|
+
/** Sign and execute all batched calls */
|
|
158
|
+
signAll: (username: string) => Promise<SendIntentResult>;
|
|
159
|
+
/** Whether the widget is expanded */
|
|
160
|
+
isExpanded: boolean;
|
|
161
|
+
/** Set widget expanded state */
|
|
162
|
+
setExpanded: (expanded: boolean) => void;
|
|
163
|
+
/** Whether signing is in progress */
|
|
164
|
+
isSigning: boolean;
|
|
165
|
+
/** Animation trigger for bounce effect */
|
|
166
|
+
animationTrigger: number;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Hook to access the batch queue context
|
|
170
|
+
*/
|
|
171
|
+
declare function useBatchQueue(): BatchQueueContextValue;
|
|
172
|
+
interface BatchQueueProviderProps {
|
|
173
|
+
/** The PasskeyProviderClient instance */
|
|
174
|
+
client: PasskeyProviderClient;
|
|
175
|
+
/** Optional username for localStorage persistence key */
|
|
176
|
+
username?: string;
|
|
177
|
+
/** Children to render */
|
|
178
|
+
children: React.ReactNode;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Provider component for the batch queue
|
|
182
|
+
*/
|
|
183
|
+
declare function BatchQueueProvider({ client, username, children, }: BatchQueueProviderProps): react_jsx_runtime.JSX.Element;
|
|
184
|
+
|
|
185
|
+
interface BatchQueueWidgetProps {
|
|
186
|
+
/** Callback when "Sign All" is clicked - should provide username */
|
|
187
|
+
onSignAll: () => void;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Floating widget showing the batch queue
|
|
191
|
+
*/
|
|
192
|
+
declare function BatchQueueWidget({ onSignAll }: BatchQueueWidgetProps): react_jsx_runtime.JSX.Element | null;
|
|
193
|
+
|
|
194
|
+
type TokenConfig = {
|
|
195
|
+
symbol: string;
|
|
196
|
+
address: Address;
|
|
197
|
+
decimals: number;
|
|
198
|
+
supportsMultichain?: boolean;
|
|
199
|
+
[key: string]: unknown;
|
|
200
|
+
};
|
|
201
|
+
type ChainFilterOptions = {
|
|
202
|
+
includeTestnets?: boolean;
|
|
203
|
+
chainIds?: number[];
|
|
204
|
+
};
|
|
205
|
+
declare function getSupportedChainIds(options?: ChainFilterOptions): number[];
|
|
206
|
+
declare function getSupportedChains(options?: ChainFilterOptions): Chain[];
|
|
207
|
+
declare function getAllSupportedChainsAndTokens(options?: ChainFilterOptions): Array<{
|
|
208
|
+
chainId: number;
|
|
209
|
+
tokens: TokenConfig[];
|
|
210
|
+
}>;
|
|
211
|
+
declare function getChainById(chainId: number): Chain;
|
|
212
|
+
declare function getChainExplorerUrl(chainId: number): string | undefined;
|
|
213
|
+
declare function getChainRpcUrl(chainId: number): string | undefined;
|
|
214
|
+
declare function getSupportedTokens(chainId: number): TokenConfig[];
|
|
215
|
+
declare function getSupportedTokenSymbols(chainId: number): string[];
|
|
216
|
+
declare function resolveTokenAddress(token: string, chainId: number): Address;
|
|
217
|
+
declare function isTestnet(chainId: number): boolean;
|
|
218
|
+
declare function getTokenSymbol(tokenAddress: Address, chainId: number): string;
|
|
219
|
+
declare function isTokenAddressSupported(tokenAddress: Address, chainId: number): boolean;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* The domain separator prefix used for passkey message signing.
|
|
223
|
+
* This ensures message signatures cannot be replayed for transaction signing.
|
|
224
|
+
*/
|
|
225
|
+
declare const PASSKEY_MESSAGE_PREFIX = "\u0019Passkey Signed Message:\n";
|
|
226
|
+
/**
|
|
227
|
+
* Hash a message with the passkey domain separator.
|
|
228
|
+
*
|
|
229
|
+
* This is the same hashing function used by the passkey sign dialog.
|
|
230
|
+
* Use this to verify that the `signedHash` returned from `signMessage()`
|
|
231
|
+
* matches your original message.
|
|
232
|
+
*
|
|
233
|
+
* Format: keccak256("\x19Passkey Signed Message:\n" + len + message)
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```typescript
|
|
237
|
+
* const message = "Sign in to MyApp\nTimestamp: 1234567890";
|
|
238
|
+
* const result = await client.signMessage({ username: 'alice', message });
|
|
239
|
+
*
|
|
240
|
+
* // Verify the hash matches
|
|
241
|
+
* const expectedHash = hashMessage(message);
|
|
242
|
+
* if (result.signedHash === expectedHash) {
|
|
243
|
+
* console.log('Hash matches - signature is for this message');
|
|
244
|
+
* }
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
declare function hashMessage(message: string): `0x${string}`;
|
|
248
|
+
/**
|
|
249
|
+
* Verify that a signedHash matches the expected message.
|
|
250
|
+
*
|
|
251
|
+
* This is a convenience wrapper around `hashMessage()` that returns
|
|
252
|
+
* a boolean. For full cryptographic verification of the P256 signature,
|
|
253
|
+
* use on-chain verification via the WebAuthn.sol contract.
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* const result = await client.signMessage({ username: 'alice', message });
|
|
258
|
+
*
|
|
259
|
+
* if (result.success && verifyMessageHash(message, result.signedHash)) {
|
|
260
|
+
* // The signature is for this exact message
|
|
261
|
+
* // For full verification, verify the P256 signature on-chain or server-side
|
|
262
|
+
* }
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
declare function verifyMessageHash(message: string, signedHash: string | undefined): boolean;
|
|
266
|
+
|
|
267
|
+
export { type BatchQueueContextValue, BatchQueueProvider, type BatchQueueProviderProps, BatchQueueWidget, type BatchQueueWidgetProps, type BatchedCall, type ChainFilterOptions, IntentCall, PASSKEY_MESSAGE_PREFIX, type PasskeyAccount, PasskeyProviderClient, type PasskeyWalletClient, type PasskeyWalletClientConfig, type SendCallsParams, SendIntentResult, type TokenConfig, type TransactionCall, WebAuthnSignature, createPasskeyAccount, createPasskeyWalletClient, encodeWebAuthnSignature, getAllSupportedChainsAndTokens, getChainById, getChainExplorerUrl, getChainName, getChainRpcUrl, getSupportedChainIds, getSupportedChains, getSupportedTokenSymbols, getSupportedTokens, getTokenSymbol, hashCalls, hashMessage, isTestnet, isTokenAddressSupported, resolveTokenAddress, useBatchQueue, verifyMessageHash };
|