@rhinestone/1auth 0.7.5 → 0.7.8-dev.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-6MUQKHAT.mjs → chunk-E4YZS7FZ.mjs} +62 -2
- package/dist/chunk-E4YZS7FZ.mjs.map +1 -0
- package/dist/{client-C9mcj5jN.d.ts → client-C8QSA1th.d.mts} +6 -1
- package/dist/{client-BqKAd2RZ.d.mts → client-Dn6mL7BZ.d.ts} +6 -1
- package/dist/headless.d.mts +2 -2
- package/dist/headless.d.ts +2 -2
- package/dist/index.d.mts +157 -7
- package/dist/index.d.ts +157 -7
- package/dist/index.js +166 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +104 -16
- package/dist/index.mjs.map +1 -1
- package/dist/{provider-CCyUBseo.d.ts → provider-BsVmPgkQ.d.ts} +21 -2
- package/dist/{provider-CRhZVLg8.d.mts → provider-CJv38fIK.d.mts} +21 -2
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/{types-CbhPRY5s.d.mts → types-Dzm5lZK-.d.mts} +10 -1
- package/dist/{types-CbhPRY5s.d.ts → types-Dzm5lZK-.d.ts} +10 -1
- package/dist/{verify-DPJR_foR.d.ts → verify-0VXQpQBJ.d.mts} +1 -1
- package/dist/{verify-DVYDJgOS.d.mts → verify-9UgxLSdo.d.ts} +1 -1
- package/dist/wagmi.d.mts +3 -3
- package/dist/wagmi.d.ts +3 -3
- package/dist/wagmi.js +61 -1
- package/dist/wagmi.js.map +1 -1
- package/dist/wagmi.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-6MUQKHAT.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "./chunk-6AHEN3FA.mjs";
|
|
9
9
|
import {
|
|
10
10
|
createOneAuthProvider
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-E4YZS7FZ.mjs";
|
|
12
12
|
import {
|
|
13
13
|
buildTransactionReview,
|
|
14
14
|
encodeWebAuthnSignature,
|
|
@@ -822,6 +822,9 @@ var OneAuthClient = class {
|
|
|
822
822
|
if (options?.oauthEnabled === false) {
|
|
823
823
|
params.set("oauth", "0");
|
|
824
824
|
}
|
|
825
|
+
if (options?.eoaConnect) {
|
|
826
|
+
params.set("eoaConnect", "1");
|
|
827
|
+
}
|
|
825
828
|
if (options?.flow === "create-account") {
|
|
826
829
|
params.set("switch", "1");
|
|
827
830
|
}
|
|
@@ -999,6 +1002,10 @@ var OneAuthClient = class {
|
|
|
999
1002
|
user: {
|
|
1000
1003
|
address: authResult.user.address
|
|
1001
1004
|
},
|
|
1005
|
+
// Preserve the signer type from the auth modal — a wallet-picked
|
|
1006
|
+
// (EOA) signup must not be silently normalized to "passkey", or the
|
|
1007
|
+
// provider would route its transactions through intents.
|
|
1008
|
+
signerType: authResult.signerType ?? "passkey",
|
|
1002
1009
|
autoConnected: false
|
|
1003
1010
|
};
|
|
1004
1011
|
}
|
|
@@ -4661,6 +4668,7 @@ var OneAuthClient = class {
|
|
|
4661
4668
|
iframe.setAttribute(
|
|
4662
4669
|
"allow",
|
|
4663
4670
|
[
|
|
4671
|
+
"payment",
|
|
4664
4672
|
`publickey-credentials-get ${hostUrl.origin}`,
|
|
4665
4673
|
`publickey-credentials-create ${hostUrl.origin}`,
|
|
4666
4674
|
"clipboard-write",
|
|
@@ -4935,6 +4943,10 @@ var OneAuthClient = class {
|
|
|
4935
4943
|
user: {
|
|
4936
4944
|
address: data.data?.address
|
|
4937
4945
|
},
|
|
4946
|
+
// Carry the signer type through so the SDK/provider can route EOA
|
|
4947
|
+
// sessions to the connected wallet (plain tx, no intents) instead
|
|
4948
|
+
// of defaulting to passkey intents. Absent = legacy passkey.
|
|
4949
|
+
signerType: data.data?.signerType ?? "passkey",
|
|
4938
4950
|
autoConnected: data.data?.autoConnected
|
|
4939
4951
|
});
|
|
4940
4952
|
} else {
|
|
@@ -5302,6 +5314,87 @@ function createCrossChainPermission(input) {
|
|
|
5302
5314
|
};
|
|
5303
5315
|
}
|
|
5304
5316
|
|
|
5317
|
+
// src/connection.ts
|
|
5318
|
+
var DEFAULT_CHAIN_ID = 8453;
|
|
5319
|
+
function readStoredSession(storageKey, provider, chainId) {
|
|
5320
|
+
if (typeof window === "undefined") return null;
|
|
5321
|
+
try {
|
|
5322
|
+
const raw = localStorage.getItem(storageKey);
|
|
5323
|
+
if (!raw) return null;
|
|
5324
|
+
const parsed = JSON.parse(raw);
|
|
5325
|
+
if (!parsed?.address) return null;
|
|
5326
|
+
return {
|
|
5327
|
+
// Absent signerType = legacy passkey session (backwards compatible).
|
|
5328
|
+
signerType: parsed.signerType === "eoa" ? "eoa" : "passkey",
|
|
5329
|
+
address: parsed.address,
|
|
5330
|
+
provider,
|
|
5331
|
+
chainId,
|
|
5332
|
+
autoConnected: false
|
|
5333
|
+
};
|
|
5334
|
+
} catch {
|
|
5335
|
+
return null;
|
|
5336
|
+
}
|
|
5337
|
+
}
|
|
5338
|
+
function createOneAuthConnection(config) {
|
|
5339
|
+
const {
|
|
5340
|
+
defaultChainId,
|
|
5341
|
+
storageKey: storageKeyOption,
|
|
5342
|
+
closeOn,
|
|
5343
|
+
waitForHash,
|
|
5344
|
+
hashTimeoutMs,
|
|
5345
|
+
hashIntervalMs,
|
|
5346
|
+
eoaConnect: eoaConnectConfig,
|
|
5347
|
+
...clientConfig
|
|
5348
|
+
} = config;
|
|
5349
|
+
const client = "client" in config && config.client ? config.client : new OneAuthClient(clientConfig);
|
|
5350
|
+
const chainId = defaultChainId ?? DEFAULT_CHAIN_ID;
|
|
5351
|
+
const storageKey = storageKeyOption ?? "1auth-user";
|
|
5352
|
+
const provider = createOneAuthProvider({
|
|
5353
|
+
client,
|
|
5354
|
+
chainId,
|
|
5355
|
+
storageKey,
|
|
5356
|
+
closeOn,
|
|
5357
|
+
waitForHash,
|
|
5358
|
+
hashTimeoutMs,
|
|
5359
|
+
hashIntervalMs
|
|
5360
|
+
});
|
|
5361
|
+
const getSession = () => readStoredSession(storageKey, provider, chainId);
|
|
5362
|
+
const connect = async (options) => {
|
|
5363
|
+
const eoaConnect = options?.eoaConnect ?? eoaConnectConfig ?? false;
|
|
5364
|
+
const result = await client.connect({ ...options, eoaConnect });
|
|
5365
|
+
if (!result.success || !result.user?.address) {
|
|
5366
|
+
const error = result.error ?? {
|
|
5367
|
+
code: "USER_CANCELLED",
|
|
5368
|
+
message: "Connection was cancelled"
|
|
5369
|
+
};
|
|
5370
|
+
throw Object.assign(new Error(error.message), { code: error.code });
|
|
5371
|
+
}
|
|
5372
|
+
const signerType = result.signerType === "eoa" ? "eoa" : "passkey";
|
|
5373
|
+
provider.setSession({ address: result.user.address, signerType });
|
|
5374
|
+
return {
|
|
5375
|
+
signerType,
|
|
5376
|
+
address: result.user.address,
|
|
5377
|
+
provider,
|
|
5378
|
+
chainId,
|
|
5379
|
+
autoConnected: result.autoConnected ?? false
|
|
5380
|
+
};
|
|
5381
|
+
};
|
|
5382
|
+
const disconnect = async () => {
|
|
5383
|
+
await provider.disconnect();
|
|
5384
|
+
};
|
|
5385
|
+
const subscribe = (listener) => {
|
|
5386
|
+
const onAccountsChanged = (...args) => {
|
|
5387
|
+
const accounts = args[0];
|
|
5388
|
+
listener(
|
|
5389
|
+
accounts && accounts.length > 0 ? getSession() : null
|
|
5390
|
+
);
|
|
5391
|
+
};
|
|
5392
|
+
provider.on("accountsChanged", onAccountsChanged);
|
|
5393
|
+
return () => provider.removeListener("accountsChanged", onAccountsChanged);
|
|
5394
|
+
};
|
|
5395
|
+
return { client, provider, connect, getSession, disconnect, subscribe };
|
|
5396
|
+
}
|
|
5397
|
+
|
|
5305
5398
|
// src/account.ts
|
|
5306
5399
|
import {
|
|
5307
5400
|
bytesToString,
|
|
@@ -5383,10 +5476,14 @@ function createPasskeyAccount(client, params) {
|
|
|
5383
5476
|
// src/walletClient/index.ts
|
|
5384
5477
|
import {
|
|
5385
5478
|
createWalletClient,
|
|
5386
|
-
|
|
5387
|
-
|
|
5479
|
+
hashTypedData as hashTypedData2,
|
|
5480
|
+
toHex
|
|
5388
5481
|
} from "viem";
|
|
5389
5482
|
import { toAccount as toAccount2 } from "viem/accounts";
|
|
5483
|
+
function formatSignableMessage(message) {
|
|
5484
|
+
if (typeof message === "string") return message;
|
|
5485
|
+
return typeof message.raw === "string" ? message.raw : toHex(message.raw);
|
|
5486
|
+
}
|
|
5390
5487
|
function createPasskeyWalletClient(config) {
|
|
5391
5488
|
const identity = {
|
|
5392
5489
|
accountAddress: config.accountAddress
|
|
@@ -5401,20 +5498,10 @@ function createPasskeyWalletClient(config) {
|
|
|
5401
5498
|
sponsorship: config.sponsorship
|
|
5402
5499
|
});
|
|
5403
5500
|
const signMessageImpl = async (message) => {
|
|
5404
|
-
const
|
|
5405
|
-
const result = await provider.signWithModal({
|
|
5406
|
-
challenge: hash,
|
|
5501
|
+
const result = await provider.signMessage({
|
|
5407
5502
|
...identity,
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
actions: [
|
|
5411
|
-
{
|
|
5412
|
-
type: "custom",
|
|
5413
|
-
label: "Sign Message",
|
|
5414
|
-
sublabel: typeof message === "string" ? message.slice(0, 50) + (message.length > 50 ? "..." : "") : "Raw message"
|
|
5415
|
-
}
|
|
5416
|
-
]
|
|
5417
|
-
}
|
|
5503
|
+
message: formatSignableMessage(message),
|
|
5504
|
+
description: "Sign message"
|
|
5418
5505
|
});
|
|
5419
5506
|
if (!result.success) {
|
|
5420
5507
|
throw new Error(result.error?.message || "Signing failed");
|
|
@@ -6005,6 +6092,7 @@ export {
|
|
|
6005
6092
|
ETHEREUM_MESSAGE_PREFIX,
|
|
6006
6093
|
OneAuthClient,
|
|
6007
6094
|
createCrossChainPermission,
|
|
6095
|
+
createOneAuthConnection,
|
|
6008
6096
|
createOneAuthProvider,
|
|
6009
6097
|
createPasskeyAccount,
|
|
6010
6098
|
createPasskeyWalletClient,
|