@rhinestone/1auth 0.7.4 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-IHBVEU33.mjs → chunk-6AHEN3FA.mjs} +1 -1
- package/dist/chunk-6AHEN3FA.mjs.map +1 -0
- package/dist/{chunk-UXBBB7AV.mjs → chunk-E4YZS7FZ.mjs} +68 -32
- package/dist/chunk-E4YZS7FZ.mjs.map +1 -0
- package/dist/{client-D4HVy1KF.d.mts → client-C8QSA1th.d.mts} +22 -17
- package/dist/{client-CuASptX3.d.ts → client-Dn6mL7BZ.d.ts} +22 -17
- package/dist/headless.d.mts +2 -2
- package/dist/headless.d.ts +2 -2
- package/dist/headless.js +4 -6
- package/dist/headless.js.map +1 -1
- package/dist/headless.mjs +4 -6
- package/dist/headless.mjs.map +1 -1
- package/dist/index.d.mts +163 -22
- package/dist/index.d.ts +163 -22
- package/dist/index.js +210 -116
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +143 -86
- package/dist/index.mjs.map +1 -1
- package/dist/{provider-6JoziYDq.d.ts → provider-BsVmPgkQ.d.ts} +22 -3
- package/dist/{provider-CAQT7Gqx.d.mts → provider-CJv38fIK.d.mts} +22 -3
- package/dist/react.d.mts +9 -4
- package/dist/react.d.ts +9 -4
- package/dist/react.js +4 -7
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +4 -7
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +1 -1
- package/dist/{types-C0jKNT_t.d.mts → types-Dzm5lZK-.d.mts} +33 -51
- package/dist/{types-C0jKNT_t.d.ts → types-Dzm5lZK-.d.ts} +33 -51
- package/dist/{verify-CnOwPq78.d.ts → verify-0VXQpQBJ.d.mts} +4 -6
- package/dist/{verify-aWdi5O2z.d.mts → verify-9UgxLSdo.d.ts} +4 -6
- package/dist/wagmi.d.mts +3 -3
- package/dist/wagmi.d.ts +3 -3
- package/dist/wagmi.js +67 -31
- package/dist/wagmi.js.map +1 -1
- package/dist/wagmi.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-IHBVEU33.mjs.map +0 -1
- package/dist/chunk-UXBBB7AV.mjs.map +0 -1
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { Address, Chain, Transport, Hex } from 'viem';
|
|
2
|
-
import {
|
|
2
|
+
import { T as ThemeConfig, S as SponsorshipConfig, W as WebAuthnSignature } from './types-Dzm5lZK-.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Configuration for creating a passkey-enabled WalletClient
|
|
6
6
|
*/
|
|
7
7
|
interface PasskeyWalletClientConfig {
|
|
8
|
-
/** User's smart account address */
|
|
8
|
+
/** User's smart account address — the sole signer identity. */
|
|
9
9
|
accountAddress: Address;
|
|
10
|
-
/** Optional username hint for legacy passkey accounts. */
|
|
11
|
-
username?: string;
|
|
12
10
|
/** Base URL of the auth API (defaults to https://passkey.1auth.app) */
|
|
13
11
|
providerUrl?: string;
|
|
14
12
|
/** Client identifier for this application */
|
|
@@ -159,7 +157,7 @@ declare const ETHEREUM_MESSAGE_PREFIX = "\u0019Ethereum Signed Message:\n";
|
|
|
159
157
|
* @example
|
|
160
158
|
* ```typescript
|
|
161
159
|
* const message = "Sign in to MyApp\nTimestamp: 1234567890";
|
|
162
|
-
* const result = await client.signMessage({
|
|
160
|
+
* const result = await client.signMessage({ accountAddress: '0x...', message });
|
|
163
161
|
*
|
|
164
162
|
* // Verify the hash matches
|
|
165
163
|
* const expectedHash = hashMessage(message);
|
|
@@ -178,7 +176,7 @@ declare function hashMessage(message: string): `0x${string}`;
|
|
|
178
176
|
*
|
|
179
177
|
* @example
|
|
180
178
|
* ```typescript
|
|
181
|
-
* const result = await client.signMessage({
|
|
179
|
+
* const result = await client.signMessage({ accountAddress: '0x...', message });
|
|
182
180
|
*
|
|
183
181
|
* if (result.success && verifyMessageHash(message, result.signedHash)) {
|
|
184
182
|
* // The signature is for this exact message
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { Address, Chain, Transport, Hex } from 'viem';
|
|
2
|
-
import {
|
|
2
|
+
import { T as ThemeConfig, S as SponsorshipConfig, W as WebAuthnSignature } from './types-Dzm5lZK-.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Configuration for creating a passkey-enabled WalletClient
|
|
6
6
|
*/
|
|
7
7
|
interface PasskeyWalletClientConfig {
|
|
8
|
-
/** User's smart account address */
|
|
8
|
+
/** User's smart account address — the sole signer identity. */
|
|
9
9
|
accountAddress: Address;
|
|
10
|
-
/** Optional username hint for legacy passkey accounts. */
|
|
11
|
-
username?: string;
|
|
12
10
|
/** Base URL of the auth API (defaults to https://passkey.1auth.app) */
|
|
13
11
|
providerUrl?: string;
|
|
14
12
|
/** Client identifier for this application */
|
|
@@ -159,7 +157,7 @@ declare const ETHEREUM_MESSAGE_PREFIX = "\u0019Ethereum Signed Message:\n";
|
|
|
159
157
|
* @example
|
|
160
158
|
* ```typescript
|
|
161
159
|
* const message = "Sign in to MyApp\nTimestamp: 1234567890";
|
|
162
|
-
* const result = await client.signMessage({
|
|
160
|
+
* const result = await client.signMessage({ accountAddress: '0x...', message });
|
|
163
161
|
*
|
|
164
162
|
* // Verify the hash matches
|
|
165
163
|
* const expectedHash = hashMessage(message);
|
|
@@ -178,7 +176,7 @@ declare function hashMessage(message: string): `0x${string}`;
|
|
|
178
176
|
*
|
|
179
177
|
* @example
|
|
180
178
|
* ```typescript
|
|
181
|
-
* const result = await client.signMessage({
|
|
179
|
+
* const result = await client.signMessage({ accountAddress: '0x...', message });
|
|
182
180
|
*
|
|
183
181
|
* if (result.success && verifyMessageHash(message, result.signedHash)) {
|
|
184
182
|
* // The signature is for this exact message
|
package/dist/wagmi.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _wagmi_core from '@wagmi/core';
|
|
2
|
-
import { O as OneAuthProvider } from './provider-
|
|
3
|
-
import { O as OneAuthClient } from './client-
|
|
4
|
-
import './types-C0jKNT_t.mjs';
|
|
2
|
+
import { O as OneAuthProvider } from './provider-CJv38fIK.mjs';
|
|
3
|
+
import { O as OneAuthClient } from './client-C8QSA1th.mjs';
|
|
5
4
|
import 'viem';
|
|
5
|
+
import './types-Dzm5lZK-.mjs';
|
|
6
6
|
import '@rhinestone/sdk';
|
|
7
7
|
|
|
8
8
|
type OneAuthConnectorOptions = {
|
package/dist/wagmi.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _wagmi_core from '@wagmi/core';
|
|
2
|
-
import { O as OneAuthProvider } from './provider-
|
|
3
|
-
import { O as OneAuthClient } from './client-
|
|
4
|
-
import './types-C0jKNT_t.js';
|
|
2
|
+
import { O as OneAuthProvider } from './provider-BsVmPgkQ.js';
|
|
3
|
+
import { O as OneAuthClient } from './client-Dn6mL7BZ.js';
|
|
5
4
|
import 'viem';
|
|
5
|
+
import './types-Dzm5lZK-.js';
|
|
6
6
|
import '@rhinestone/sdk';
|
|
7
7
|
|
|
8
8
|
type OneAuthConnectorOptions = {
|
package/dist/wagmi.js
CHANGED
|
@@ -143,12 +143,14 @@ function createOneAuthProvider(options) {
|
|
|
143
143
|
let chainId = options.chainId;
|
|
144
144
|
const storageKey = options.storageKey || DEFAULT_STORAGE_KEY;
|
|
145
145
|
const listeners = /* @__PURE__ */ new Map();
|
|
146
|
+
let sessionOverride;
|
|
146
147
|
const emit = (event, ...args) => {
|
|
147
148
|
const set = listeners.get(event);
|
|
148
149
|
if (!set) return;
|
|
149
150
|
for (const listener of set) listener(...args);
|
|
150
151
|
};
|
|
151
152
|
const getStoredUser = () => {
|
|
153
|
+
if (sessionOverride !== void 0) return sessionOverride;
|
|
152
154
|
if (typeof window === "undefined") return null;
|
|
153
155
|
try {
|
|
154
156
|
const raw = localStorage.getItem(storageKey);
|
|
@@ -168,21 +170,6 @@ function createOneAuthProvider(options) {
|
|
|
168
170
|
if (typeof window === "undefined") return;
|
|
169
171
|
localStorage.removeItem(storageKey);
|
|
170
172
|
};
|
|
171
|
-
const resolveAccountAddress = async (username) => {
|
|
172
|
-
const clientId = client.getClientId();
|
|
173
|
-
const response = await fetch(
|
|
174
|
-
`${client.getProviderUrl()}/api/users/${encodeURIComponent(username)}/account`,
|
|
175
|
-
{
|
|
176
|
-
headers: clientId ? { "x-client-id": clientId } : {}
|
|
177
|
-
}
|
|
178
|
-
);
|
|
179
|
-
if (!response.ok) {
|
|
180
|
-
const data2 = await response.json().catch(() => ({}));
|
|
181
|
-
throw new Error(data2.error || "Failed to resolve account address");
|
|
182
|
-
}
|
|
183
|
-
const data = await response.json();
|
|
184
|
-
return data.address;
|
|
185
|
-
};
|
|
186
173
|
const connect = async () => {
|
|
187
174
|
const stored = getStoredUser();
|
|
188
175
|
if (stored) {
|
|
@@ -192,25 +179,39 @@ function createOneAuthProvider(options) {
|
|
|
192
179
|
if (!authResult.success) {
|
|
193
180
|
throw new Error(authResult.error?.message || "Authentication failed");
|
|
194
181
|
}
|
|
195
|
-
const
|
|
196
|
-
let address = authResult.user?.address;
|
|
182
|
+
const address = authResult.user?.address;
|
|
197
183
|
const signerType = authResult.signerType;
|
|
198
|
-
if (!address && username) {
|
|
199
|
-
address = await resolveAccountAddress(username);
|
|
200
|
-
}
|
|
201
184
|
if (!address) {
|
|
202
185
|
throw new Error("No account address available");
|
|
203
186
|
}
|
|
204
|
-
setStoredUser({
|
|
187
|
+
setStoredUser({ address, signerType });
|
|
205
188
|
emit("accountsChanged", [address]);
|
|
206
189
|
emit("connect", { chainId: (0, import_viem3.numberToHex)(chainId) });
|
|
207
190
|
return [address];
|
|
208
191
|
};
|
|
209
192
|
const disconnect = async () => {
|
|
193
|
+
sessionOverride = void 0;
|
|
210
194
|
clearStoredUser();
|
|
211
195
|
emit("accountsChanged", []);
|
|
212
196
|
emit("disconnect");
|
|
213
197
|
};
|
|
198
|
+
const setSession = (session) => {
|
|
199
|
+
if (!session) {
|
|
200
|
+
sessionOverride = void 0;
|
|
201
|
+
clearStoredUser();
|
|
202
|
+
emit("accountsChanged", []);
|
|
203
|
+
emit("disconnect");
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
sessionOverride = {
|
|
207
|
+
address: session.address,
|
|
208
|
+
signerType: session.signerType,
|
|
209
|
+
connectorId: session.connectorId
|
|
210
|
+
};
|
|
211
|
+
setStoredUser(sessionOverride);
|
|
212
|
+
emit("accountsChanged", [session.address]);
|
|
213
|
+
emit("connect", { chainId: (0, import_viem3.numberToHex)(chainId) });
|
|
214
|
+
};
|
|
214
215
|
const ensureUser = async () => {
|
|
215
216
|
const stored = getStoredUser();
|
|
216
217
|
if (stored) return stored;
|
|
@@ -315,11 +316,10 @@ function createOneAuthProvider(options) {
|
|
|
315
316
|
]);
|
|
316
317
|
const signMessage = async (message) => {
|
|
317
318
|
const user = await ensureUser();
|
|
318
|
-
if (!user.
|
|
319
|
-
throw new Error("
|
|
319
|
+
if (!user.address) {
|
|
320
|
+
throw new Error("Account address required for signing.");
|
|
320
321
|
}
|
|
321
322
|
const result = await client.signMessage({
|
|
322
|
-
username: user.username || void 0,
|
|
323
323
|
accountAddress: user.address,
|
|
324
324
|
message
|
|
325
325
|
});
|
|
@@ -330,12 +330,11 @@ function createOneAuthProvider(options) {
|
|
|
330
330
|
};
|
|
331
331
|
const signTypedData = async (typedData) => {
|
|
332
332
|
const user = await ensureUser();
|
|
333
|
-
if (!user.
|
|
334
|
-
throw new Error("
|
|
333
|
+
if (!user.address) {
|
|
334
|
+
throw new Error("Account address required for signing.");
|
|
335
335
|
}
|
|
336
336
|
const data = typeof typedData === "string" ? JSON.parse(typedData) : typedData;
|
|
337
337
|
const result = await client.signTypedData({
|
|
338
|
-
username: user.username || void 0,
|
|
339
338
|
accountAddress: user.address,
|
|
340
339
|
domain: data.domain,
|
|
341
340
|
types: data.types,
|
|
@@ -348,7 +347,6 @@ function createOneAuthProvider(options) {
|
|
|
348
347
|
return encodeWebAuthnSignature(result.signature);
|
|
349
348
|
};
|
|
350
349
|
const resolveIntentPayload = (payload) => ({
|
|
351
|
-
username: payload.username,
|
|
352
350
|
accountAddress: payload.accountAddress,
|
|
353
351
|
targetChain: payload.targetChain,
|
|
354
352
|
calls: payload.calls,
|
|
@@ -423,10 +421,49 @@ function createOneAuthProvider(options) {
|
|
|
423
421
|
}
|
|
424
422
|
return list;
|
|
425
423
|
};
|
|
424
|
+
const eoaBatches = /* @__PURE__ */ new Map();
|
|
425
|
+
const sendCallsEoa = async (params, address) => {
|
|
426
|
+
const validated = injectEoaSigner("wallet_sendCalls", params, address);
|
|
427
|
+
const payload = Array.isArray(validated) ? validated[0] : {};
|
|
428
|
+
const calls = Array.isArray(payload.calls) ? payload.calls : [];
|
|
429
|
+
if (!calls.length) throw new Error("No calls provided");
|
|
430
|
+
const batchChainId = payload.chainId;
|
|
431
|
+
const hashes = [];
|
|
432
|
+
for (const raw of calls) {
|
|
433
|
+
const call = raw || {};
|
|
434
|
+
const tx = { from: address, to: call.to };
|
|
435
|
+
if (call.data !== void 0) tx.data = call.data;
|
|
436
|
+
if (call.value !== void 0) tx.value = call.value;
|
|
437
|
+
const callChain = call.chainId ?? batchChainId;
|
|
438
|
+
if (callChain !== void 0) tx.chainId = callChain;
|
|
439
|
+
const hash = await forwardToWallet("eth_sendTransaction", [tx], address);
|
|
440
|
+
hashes.push(String(hash));
|
|
441
|
+
}
|
|
442
|
+
const id = hashes[hashes.length - 1];
|
|
443
|
+
eoaBatches.set(id, hashes);
|
|
444
|
+
return id;
|
|
445
|
+
};
|
|
446
|
+
const getCallsStatusEoa = (callsId) => {
|
|
447
|
+
if (!callsId || typeof callsId !== "string") {
|
|
448
|
+
throw new Error("callsId is required");
|
|
449
|
+
}
|
|
450
|
+
const hashes = eoaBatches.get(callsId) ?? [callsId];
|
|
451
|
+
return {
|
|
452
|
+
status: "CONFIRMED",
|
|
453
|
+
receipts: hashes.map((transactionHash) => ({ transactionHash }))
|
|
454
|
+
};
|
|
455
|
+
};
|
|
426
456
|
const request = async ({ method, params }) => {
|
|
427
457
|
if (EOA_FORWARDED_METHODS.has(method)) {
|
|
428
458
|
const user = await ensureUser();
|
|
429
459
|
if (user.signerType === "eoa") {
|
|
460
|
+
if (method === "wallet_sendCalls") {
|
|
461
|
+
return sendCallsEoa(params, user.address);
|
|
462
|
+
}
|
|
463
|
+
if (method === "wallet_getCallsStatus") {
|
|
464
|
+
const list = Array.isArray(params) ? params : [];
|
|
465
|
+
return getCallsStatusEoa(list[0]);
|
|
466
|
+
}
|
|
430
467
|
return forwardToWallet(
|
|
431
468
|
method,
|
|
432
469
|
injectEoaSigner(method, params, user.address),
|
|
@@ -491,7 +528,6 @@ function createOneAuthProvider(options) {
|
|
|
491
528
|
const tokenRequests = normalizeTokenRequests(tx.tokenRequests);
|
|
492
529
|
const txSourceChainId = parseChainId(tx.sourceChainId);
|
|
493
530
|
return sendIntent({
|
|
494
|
-
username: user.username || void 0,
|
|
495
531
|
accountAddress: user.address,
|
|
496
532
|
targetChain,
|
|
497
533
|
calls,
|
|
@@ -509,7 +545,6 @@ function createOneAuthProvider(options) {
|
|
|
509
545
|
const sourceChainId = parseChainId(payload.sourceChainId);
|
|
510
546
|
if (!calls.length) throw new Error("No calls provided");
|
|
511
547
|
return sendIntent({
|
|
512
|
-
username: user.username || void 0,
|
|
513
548
|
accountAddress: user.address,
|
|
514
549
|
targetChain,
|
|
515
550
|
calls,
|
|
@@ -645,7 +680,8 @@ function createOneAuthProvider(options) {
|
|
|
645
680
|
set.delete(listener);
|
|
646
681
|
if (set.size === 0) listeners.delete(event);
|
|
647
682
|
},
|
|
648
|
-
disconnect
|
|
683
|
+
disconnect,
|
|
684
|
+
setSession
|
|
649
685
|
};
|
|
650
686
|
}
|
|
651
687
|
|