@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.js
CHANGED
|
@@ -32,8 +32,9 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
BatchQueueProvider: () => BatchQueueProvider,
|
|
34
34
|
BatchQueueWidget: () => BatchQueueWidget,
|
|
35
|
+
OneAuthClient: () => OneAuthClient,
|
|
35
36
|
PASSKEY_MESSAGE_PREFIX: () => PASSKEY_MESSAGE_PREFIX,
|
|
36
|
-
PasskeyProviderClient: () =>
|
|
37
|
+
PasskeyProviderClient: () => OneAuthClient,
|
|
37
38
|
createPasskeyAccount: () => createPasskeyAccount,
|
|
38
39
|
createPasskeyProvider: () => createPasskeyProvider,
|
|
39
40
|
createPasskeyWalletClient: () => createPasskeyWalletClient,
|
|
@@ -189,10 +190,13 @@ var POPUP_HEIGHT = 600;
|
|
|
189
190
|
var DEFAULT_EMBED_WIDTH = "400px";
|
|
190
191
|
var DEFAULT_EMBED_HEIGHT = "500px";
|
|
191
192
|
var MODAL_WIDTH = 360;
|
|
192
|
-
var
|
|
193
|
+
var DEFAULT_PROVIDER_URL = "https://passkey.1auth.box";
|
|
194
|
+
var OneAuthClient = class {
|
|
193
195
|
constructor(config) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
+
const providerUrl = config.providerUrl || DEFAULT_PROVIDER_URL;
|
|
197
|
+
const dialogUrl = config.dialogUrl || providerUrl;
|
|
198
|
+
this.config = { ...config, providerUrl, dialogUrl };
|
|
199
|
+
this.theme = this.config.theme || {};
|
|
196
200
|
}
|
|
197
201
|
/**
|
|
198
202
|
* Update the theme configuration at runtime
|
|
@@ -275,9 +279,7 @@ var PasskeyProviderClient = class {
|
|
|
275
279
|
return void 0;
|
|
276
280
|
}
|
|
277
281
|
/**
|
|
278
|
-
*
|
|
279
|
-
* This is the recommended method for authentication - shows a modal overlay
|
|
280
|
-
* with both sign in and create account options.
|
|
282
|
+
* Open the auth dialog (sign in + sign up).
|
|
281
283
|
*/
|
|
282
284
|
async authWithModal(options) {
|
|
283
285
|
const dialogUrl = this.getDialogUrl();
|
|
@@ -405,10 +407,24 @@ var PasskeyProviderClient = class {
|
|
|
405
407
|
* ```
|
|
406
408
|
*/
|
|
407
409
|
async sendIntent(options) {
|
|
408
|
-
const signedIntent = options.signedIntent
|
|
410
|
+
const signedIntent = options.signedIntent ? {
|
|
411
|
+
...options.signedIntent,
|
|
412
|
+
merchantId: options.signedIntent.merchantId || options.signedIntent.developerId
|
|
413
|
+
} : void 0;
|
|
409
414
|
const username = signedIntent?.username || options.username;
|
|
410
415
|
const targetChain = signedIntent?.targetChain || options.targetChain;
|
|
411
416
|
const calls = signedIntent?.calls || options.calls;
|
|
417
|
+
if (signedIntent && !signedIntent.merchantId) {
|
|
418
|
+
return {
|
|
419
|
+
success: false,
|
|
420
|
+
intentId: "",
|
|
421
|
+
status: "failed",
|
|
422
|
+
error: {
|
|
423
|
+
code: "INVALID_OPTIONS",
|
|
424
|
+
message: "Signed intent requires developerId (clientId)"
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
}
|
|
412
428
|
if (!username && !signedIntent?.accountAddress) {
|
|
413
429
|
return {
|
|
414
430
|
success: false,
|
|
@@ -1323,7 +1339,7 @@ var PasskeyProviderClient = class {
|
|
|
1323
1339
|
);
|
|
1324
1340
|
}
|
|
1325
1341
|
/**
|
|
1326
|
-
* Create a modal dialog with an iframe inside
|
|
1342
|
+
* Create a modal dialog with an iframe inside.
|
|
1327
1343
|
*/
|
|
1328
1344
|
createModalDialog(url) {
|
|
1329
1345
|
const dialogUrl = this.getDialogUrl();
|
|
@@ -1896,10 +1912,27 @@ function createPasskeyProvider(options) {
|
|
|
1896
1912
|
}
|
|
1897
1913
|
return encodeWebAuthnSignature(result.signature);
|
|
1898
1914
|
};
|
|
1915
|
+
const resolveIntentPayload = async (payload) => {
|
|
1916
|
+
if (!options.signIntent) {
|
|
1917
|
+
return {
|
|
1918
|
+
username: payload.username,
|
|
1919
|
+
targetChain: payload.targetChain,
|
|
1920
|
+
calls: payload.calls
|
|
1921
|
+
};
|
|
1922
|
+
}
|
|
1923
|
+
const signedIntent = await options.signIntent({
|
|
1924
|
+
username: payload.username,
|
|
1925
|
+
accountAddress: payload.accountAddress,
|
|
1926
|
+
targetChain: payload.targetChain,
|
|
1927
|
+
calls: payload.calls
|
|
1928
|
+
});
|
|
1929
|
+
return { signedIntent };
|
|
1930
|
+
};
|
|
1899
1931
|
const sendIntent = async (payload) => {
|
|
1900
1932
|
const closeOn = options.waitForHash ?? true ? "completed" : "preconfirmed";
|
|
1933
|
+
const intentPayload = await resolveIntentPayload(payload);
|
|
1901
1934
|
const result = await client.sendIntent({
|
|
1902
|
-
...
|
|
1935
|
+
...intentPayload,
|
|
1903
1936
|
closeOn,
|
|
1904
1937
|
waitForHash: options.waitForHash ?? true,
|
|
1905
1938
|
hashTimeoutMs: options.hashTimeoutMs,
|
|
@@ -1963,6 +1996,7 @@ function createPasskeyProvider(options) {
|
|
|
1963
1996
|
const calls = normalizeCalls([tx]);
|
|
1964
1997
|
return sendIntent({
|
|
1965
1998
|
username: user.username,
|
|
1999
|
+
accountAddress: user.address,
|
|
1966
2000
|
targetChain,
|
|
1967
2001
|
calls
|
|
1968
2002
|
});
|
|
@@ -1976,6 +2010,7 @@ function createPasskeyProvider(options) {
|
|
|
1976
2010
|
if (!calls.length) throw new Error("No calls provided");
|
|
1977
2011
|
return sendIntent({
|
|
1978
2012
|
username: user.username,
|
|
2013
|
+
accountAddress: user.address,
|
|
1979
2014
|
targetChain,
|
|
1980
2015
|
calls
|
|
1981
2016
|
});
|
|
@@ -2088,7 +2123,7 @@ function createPasskeyAccount(client, params) {
|
|
|
2088
2123
|
var import_viem6 = require("viem");
|
|
2089
2124
|
var import_accounts2 = require("viem/accounts");
|
|
2090
2125
|
function createPasskeyWalletClient(config) {
|
|
2091
|
-
const provider = new
|
|
2126
|
+
const provider = new OneAuthClient({
|
|
2092
2127
|
providerUrl: config.providerUrl,
|
|
2093
2128
|
clientId: config.clientId,
|
|
2094
2129
|
dialogUrl: config.dialogUrl
|
|
@@ -2155,6 +2190,30 @@ function createPasskeyWalletClient(config) {
|
|
|
2155
2190
|
}
|
|
2156
2191
|
return encodeWebAuthnSignature(result.signature);
|
|
2157
2192
|
};
|
|
2193
|
+
const buildIntentPayload = async (calls, targetChainOverride) => {
|
|
2194
|
+
const targetChain = targetChainOverride ?? config.chain.id;
|
|
2195
|
+
const intentCalls = calls.map((call) => ({
|
|
2196
|
+
to: call.to,
|
|
2197
|
+
data: call.data || "0x",
|
|
2198
|
+
value: call.value !== void 0 ? call.value.toString() : "0",
|
|
2199
|
+
label: call.label,
|
|
2200
|
+
sublabel: call.sublabel
|
|
2201
|
+
}));
|
|
2202
|
+
if (config.signIntent) {
|
|
2203
|
+
const signedIntent = await config.signIntent({
|
|
2204
|
+
username: config.username,
|
|
2205
|
+
accountAddress: config.accountAddress,
|
|
2206
|
+
targetChain,
|
|
2207
|
+
calls: intentCalls
|
|
2208
|
+
});
|
|
2209
|
+
return { signedIntent };
|
|
2210
|
+
}
|
|
2211
|
+
return {
|
|
2212
|
+
username: config.username,
|
|
2213
|
+
targetChain,
|
|
2214
|
+
calls: intentCalls
|
|
2215
|
+
};
|
|
2216
|
+
};
|
|
2158
2217
|
const account = (0, import_accounts2.toAccount)({
|
|
2159
2218
|
address: config.accountAddress,
|
|
2160
2219
|
signMessage: ({ message }) => signMessageImpl(message),
|
|
@@ -2171,24 +2230,18 @@ function createPasskeyWalletClient(config) {
|
|
|
2171
2230
|
* Send a single transaction via intent flow
|
|
2172
2231
|
*/
|
|
2173
2232
|
async sendTransaction(transaction) {
|
|
2233
|
+
const targetChain = typeof transaction.chainId === "number" ? transaction.chainId : transaction.chain?.id;
|
|
2174
2234
|
const calls = [
|
|
2175
2235
|
{
|
|
2176
2236
|
to: transaction.to,
|
|
2177
|
-
data: transaction.data,
|
|
2237
|
+
data: transaction.data || "0x",
|
|
2178
2238
|
value: transaction.value
|
|
2179
2239
|
}
|
|
2180
2240
|
];
|
|
2181
2241
|
const closeOn = config.waitForHash ?? true ? "completed" : "preconfirmed";
|
|
2242
|
+
const intentPayload = await buildIntentPayload(calls, targetChain);
|
|
2182
2243
|
const result = await provider.sendIntent({
|
|
2183
|
-
|
|
2184
|
-
targetChain: config.chain.id,
|
|
2185
|
-
calls: calls.map((call) => ({
|
|
2186
|
-
to: call.to,
|
|
2187
|
-
data: call.data,
|
|
2188
|
-
value: call.value ? call.value.toString() : "0",
|
|
2189
|
-
label: call.label,
|
|
2190
|
-
sublabel: call.sublabel
|
|
2191
|
-
})),
|
|
2244
|
+
...intentPayload,
|
|
2192
2245
|
closeOn,
|
|
2193
2246
|
waitForHash: config.waitForHash ?? true,
|
|
2194
2247
|
hashTimeoutMs: config.hashTimeoutMs,
|
|
@@ -2203,18 +2256,11 @@ function createPasskeyWalletClient(config) {
|
|
|
2203
2256
|
* Send multiple calls as a single batched transaction
|
|
2204
2257
|
*/
|
|
2205
2258
|
async sendCalls(params) {
|
|
2206
|
-
const { calls } = params;
|
|
2259
|
+
const { calls, chainId: targetChain } = params;
|
|
2207
2260
|
const closeOn = config.waitForHash ?? true ? "completed" : "preconfirmed";
|
|
2261
|
+
const intentPayload = await buildIntentPayload(calls, targetChain);
|
|
2208
2262
|
const result = await provider.sendIntent({
|
|
2209
|
-
|
|
2210
|
-
targetChain: config.chain.id,
|
|
2211
|
-
calls: calls.map((call) => ({
|
|
2212
|
-
to: call.to,
|
|
2213
|
-
data: call.data,
|
|
2214
|
-
value: call.value ? call.value.toString() : "0",
|
|
2215
|
-
label: call.label,
|
|
2216
|
-
sublabel: call.sublabel
|
|
2217
|
-
})),
|
|
2263
|
+
...intentPayload,
|
|
2218
2264
|
closeOn,
|
|
2219
2265
|
waitForHash: config.waitForHash ?? true,
|
|
2220
2266
|
hashTimeoutMs: config.hashTimeoutMs,
|
|
@@ -2672,6 +2718,7 @@ function verifyMessageHash(message, signedHash) {
|
|
|
2672
2718
|
0 && (module.exports = {
|
|
2673
2719
|
BatchQueueProvider,
|
|
2674
2720
|
BatchQueueWidget,
|
|
2721
|
+
OneAuthClient,
|
|
2675
2722
|
PASSKEY_MESSAGE_PREFIX,
|
|
2676
2723
|
PasskeyProviderClient,
|
|
2677
2724
|
createPasskeyAccount,
|