@rhinestone/1auth 0.1.0 → 0.1.1
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 → chunk-U7KZ4XMQ.mjs} +21 -2
- package/dist/chunk-U7KZ4XMQ.mjs.map +1 -0
- package/dist/{client-C1inywuT.d.mts → client-B-HGKKaJ.d.mts} +21 -13
- package/dist/{client-C1inywuT.d.ts → client-B-HGKKaJ.d.ts} +21 -13
- package/dist/index.d.mts +14 -10
- package/dist/index.d.ts +14 -10
- package/dist/index.js +78 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -31
- package/dist/index.mjs.map +1 -1
- package/dist/{provider-q7M728Mn.d.ts → provider-CDIRlA4y.d.mts} +3 -2
- package/dist/{provider-Dgh51NRc.d.mts → provider-Cy1StrOe.d.ts} +3 -2
- package/dist/react.d.mts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js.map +1 -1
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +10 -44
- package/dist/server.d.ts +10 -44
- package/dist/server.js +11 -8
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +11 -8
- package/dist/server.mjs.map +1 -1
- package/dist/wagmi.d.mts +4 -3
- package/dist/wagmi.d.ts +4 -3
- package/dist/wagmi.js +22 -2
- package/dist/wagmi.js.map +1 -1
- package/dist/wagmi.mjs +3 -2
- package/dist/wagmi.mjs.map +1 -1
- package/package.json +8 -8
- package/dist/chunk-UXYKIMGZ.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
isTestnet,
|
|
19
19
|
isTokenAddressSupported,
|
|
20
20
|
resolveTokenAddress
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-U7KZ4XMQ.mjs";
|
|
22
22
|
|
|
23
23
|
// src/client.ts
|
|
24
24
|
import { parseUnits, hashTypedData } from "viem";
|
|
@@ -27,10 +27,13 @@ var POPUP_HEIGHT = 600;
|
|
|
27
27
|
var DEFAULT_EMBED_WIDTH = "400px";
|
|
28
28
|
var DEFAULT_EMBED_HEIGHT = "500px";
|
|
29
29
|
var MODAL_WIDTH = 360;
|
|
30
|
-
var
|
|
30
|
+
var DEFAULT_PROVIDER_URL = "https://passkey.1auth.box";
|
|
31
|
+
var OneAuthClient = class {
|
|
31
32
|
constructor(config) {
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
const providerUrl = config.providerUrl || DEFAULT_PROVIDER_URL;
|
|
34
|
+
const dialogUrl = config.dialogUrl || providerUrl;
|
|
35
|
+
this.config = { ...config, providerUrl, dialogUrl };
|
|
36
|
+
this.theme = this.config.theme || {};
|
|
34
37
|
}
|
|
35
38
|
/**
|
|
36
39
|
* Update the theme configuration at runtime
|
|
@@ -113,9 +116,7 @@ var PasskeyProviderClient = class {
|
|
|
113
116
|
return void 0;
|
|
114
117
|
}
|
|
115
118
|
/**
|
|
116
|
-
*
|
|
117
|
-
* This is the recommended method for authentication - shows a modal overlay
|
|
118
|
-
* with both sign in and create account options.
|
|
119
|
+
* Open the auth dialog (sign in + sign up).
|
|
119
120
|
*/
|
|
120
121
|
async authWithModal(options) {
|
|
121
122
|
const dialogUrl = this.getDialogUrl();
|
|
@@ -243,10 +244,24 @@ var PasskeyProviderClient = class {
|
|
|
243
244
|
* ```
|
|
244
245
|
*/
|
|
245
246
|
async sendIntent(options) {
|
|
246
|
-
const signedIntent = options.signedIntent
|
|
247
|
+
const signedIntent = options.signedIntent ? {
|
|
248
|
+
...options.signedIntent,
|
|
249
|
+
merchantId: options.signedIntent.merchantId || options.signedIntent.developerId
|
|
250
|
+
} : void 0;
|
|
247
251
|
const username = signedIntent?.username || options.username;
|
|
248
252
|
const targetChain = signedIntent?.targetChain || options.targetChain;
|
|
249
253
|
const calls = signedIntent?.calls || options.calls;
|
|
254
|
+
if (signedIntent && !signedIntent.merchantId) {
|
|
255
|
+
return {
|
|
256
|
+
success: false,
|
|
257
|
+
intentId: "",
|
|
258
|
+
status: "failed",
|
|
259
|
+
error: {
|
|
260
|
+
code: "INVALID_OPTIONS",
|
|
261
|
+
message: "Signed intent requires developerId (clientId)"
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
}
|
|
250
265
|
if (!username && !signedIntent?.accountAddress) {
|
|
251
266
|
return {
|
|
252
267
|
success: false,
|
|
@@ -1161,7 +1176,7 @@ var PasskeyProviderClient = class {
|
|
|
1161
1176
|
);
|
|
1162
1177
|
}
|
|
1163
1178
|
/**
|
|
1164
|
-
* Create a modal dialog with an iframe inside
|
|
1179
|
+
* Create a modal dialog with an iframe inside.
|
|
1165
1180
|
*/
|
|
1166
1181
|
createModalDialog(url) {
|
|
1167
1182
|
const dialogUrl = this.getDialogUrl();
|
|
@@ -1601,7 +1616,7 @@ import {
|
|
|
1601
1616
|
} from "viem";
|
|
1602
1617
|
import { toAccount as toAccount2 } from "viem/accounts";
|
|
1603
1618
|
function createPasskeyWalletClient(config) {
|
|
1604
|
-
const provider = new
|
|
1619
|
+
const provider = new OneAuthClient({
|
|
1605
1620
|
providerUrl: config.providerUrl,
|
|
1606
1621
|
clientId: config.clientId,
|
|
1607
1622
|
dialogUrl: config.dialogUrl
|
|
@@ -1668,6 +1683,30 @@ function createPasskeyWalletClient(config) {
|
|
|
1668
1683
|
}
|
|
1669
1684
|
return encodeWebAuthnSignature(result.signature);
|
|
1670
1685
|
};
|
|
1686
|
+
const buildIntentPayload = async (calls, targetChainOverride) => {
|
|
1687
|
+
const targetChain = targetChainOverride ?? config.chain.id;
|
|
1688
|
+
const intentCalls = calls.map((call) => ({
|
|
1689
|
+
to: call.to,
|
|
1690
|
+
data: call.data || "0x",
|
|
1691
|
+
value: call.value !== void 0 ? call.value.toString() : "0",
|
|
1692
|
+
label: call.label,
|
|
1693
|
+
sublabel: call.sublabel
|
|
1694
|
+
}));
|
|
1695
|
+
if (config.signIntent) {
|
|
1696
|
+
const signedIntent = await config.signIntent({
|
|
1697
|
+
username: config.username,
|
|
1698
|
+
accountAddress: config.accountAddress,
|
|
1699
|
+
targetChain,
|
|
1700
|
+
calls: intentCalls
|
|
1701
|
+
});
|
|
1702
|
+
return { signedIntent };
|
|
1703
|
+
}
|
|
1704
|
+
return {
|
|
1705
|
+
username: config.username,
|
|
1706
|
+
targetChain,
|
|
1707
|
+
calls: intentCalls
|
|
1708
|
+
};
|
|
1709
|
+
};
|
|
1671
1710
|
const account = toAccount2({
|
|
1672
1711
|
address: config.accountAddress,
|
|
1673
1712
|
signMessage: ({ message }) => signMessageImpl(message),
|
|
@@ -1684,24 +1723,18 @@ function createPasskeyWalletClient(config) {
|
|
|
1684
1723
|
* Send a single transaction via intent flow
|
|
1685
1724
|
*/
|
|
1686
1725
|
async sendTransaction(transaction) {
|
|
1726
|
+
const targetChain = typeof transaction.chainId === "number" ? transaction.chainId : transaction.chain?.id;
|
|
1687
1727
|
const calls = [
|
|
1688
1728
|
{
|
|
1689
1729
|
to: transaction.to,
|
|
1690
|
-
data: transaction.data,
|
|
1730
|
+
data: transaction.data || "0x",
|
|
1691
1731
|
value: transaction.value
|
|
1692
1732
|
}
|
|
1693
1733
|
];
|
|
1694
1734
|
const closeOn = config.waitForHash ?? true ? "completed" : "preconfirmed";
|
|
1735
|
+
const intentPayload = await buildIntentPayload(calls, targetChain);
|
|
1695
1736
|
const result = await provider.sendIntent({
|
|
1696
|
-
|
|
1697
|
-
targetChain: config.chain.id,
|
|
1698
|
-
calls: calls.map((call) => ({
|
|
1699
|
-
to: call.to,
|
|
1700
|
-
data: call.data,
|
|
1701
|
-
value: call.value ? call.value.toString() : "0",
|
|
1702
|
-
label: call.label,
|
|
1703
|
-
sublabel: call.sublabel
|
|
1704
|
-
})),
|
|
1737
|
+
...intentPayload,
|
|
1705
1738
|
closeOn,
|
|
1706
1739
|
waitForHash: config.waitForHash ?? true,
|
|
1707
1740
|
hashTimeoutMs: config.hashTimeoutMs,
|
|
@@ -1716,18 +1749,11 @@ function createPasskeyWalletClient(config) {
|
|
|
1716
1749
|
* Send multiple calls as a single batched transaction
|
|
1717
1750
|
*/
|
|
1718
1751
|
async sendCalls(params) {
|
|
1719
|
-
const { calls } = params;
|
|
1752
|
+
const { calls, chainId: targetChain } = params;
|
|
1720
1753
|
const closeOn = config.waitForHash ?? true ? "completed" : "preconfirmed";
|
|
1754
|
+
const intentPayload = await buildIntentPayload(calls, targetChain);
|
|
1721
1755
|
const result = await provider.sendIntent({
|
|
1722
|
-
|
|
1723
|
-
targetChain: config.chain.id,
|
|
1724
|
-
calls: calls.map((call) => ({
|
|
1725
|
-
to: call.to,
|
|
1726
|
-
data: call.data,
|
|
1727
|
-
value: call.value ? call.value.toString() : "0",
|
|
1728
|
-
label: call.label,
|
|
1729
|
-
sublabel: call.sublabel
|
|
1730
|
-
})),
|
|
1756
|
+
...intentPayload,
|
|
1731
1757
|
closeOn,
|
|
1732
1758
|
waitForHash: config.waitForHash ?? true,
|
|
1733
1759
|
hashTimeoutMs: config.hashTimeoutMs,
|
|
@@ -2184,8 +2210,9 @@ function verifyMessageHash(message, signedHash) {
|
|
|
2184
2210
|
export {
|
|
2185
2211
|
BatchQueueProvider,
|
|
2186
2212
|
BatchQueueWidget,
|
|
2213
|
+
OneAuthClient,
|
|
2187
2214
|
PASSKEY_MESSAGE_PREFIX,
|
|
2188
|
-
PasskeyProviderClient,
|
|
2215
|
+
OneAuthClient as PasskeyProviderClient,
|
|
2189
2216
|
createPasskeyAccount,
|
|
2190
2217
|
createPasskeyProvider,
|
|
2191
2218
|
createPasskeyWalletClient,
|