@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
package/dist/index.mjs
CHANGED
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
ETHEREUM_MESSAGE_PREFIX,
|
|
6
6
|
hashMessage,
|
|
7
7
|
verifyMessageHash
|
|
8
|
-
} from "./chunk-
|
|
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,
|
|
@@ -750,7 +750,6 @@ var OneAuthClient = class {
|
|
|
750
750
|
* call — the modal shows the appropriate flow based on whether the user
|
|
751
751
|
* has a passkey registered.
|
|
752
752
|
*
|
|
753
|
-
* @param options.username - Pre-fill the username field
|
|
754
753
|
* @param options.theme - Override the theme for this modal invocation
|
|
755
754
|
* @param options.oauthEnabled - Set to false to hide OAuth sign-in buttons
|
|
756
755
|
* @param options.flow - Force the login or account-creation route instead
|
|
@@ -762,7 +761,7 @@ var OneAuthClient = class {
|
|
|
762
761
|
* const result = await client.authWithModal();
|
|
763
762
|
*
|
|
764
763
|
* if (result.success) {
|
|
765
|
-
* console.log('Signed in as:', result.user?.
|
|
764
|
+
* console.log('Signed in as:', result.user?.address);
|
|
766
765
|
* console.log('Address:', result.user?.address); // typed `0x${string}`
|
|
767
766
|
* } else if (result.error?.code === 'USER_CANCELLED') {
|
|
768
767
|
* // User closed the modal
|
|
@@ -780,7 +779,6 @@ var OneAuthClient = class {
|
|
|
780
779
|
* is creating a login session, for example after an app-level "Log in"
|
|
781
780
|
* button. The result intentionally matches {@link authWithModal}.
|
|
782
781
|
*
|
|
783
|
-
* @param options.username - Optional account hint for the sign-in ceremony
|
|
784
782
|
* @param options.theme - Override the theme for this modal invocation
|
|
785
783
|
* @returns {@link AuthResult} with user details and typed address
|
|
786
784
|
*/
|
|
@@ -810,8 +808,7 @@ var OneAuthClient = class {
|
|
|
810
808
|
*/
|
|
811
809
|
async openAuthModal(options) {
|
|
812
810
|
const telemetry = this.createTelemetryOperation("auth", {
|
|
813
|
-
flow: options?.flow ?? "auto"
|
|
814
|
-
hasUsernameHint: !!options?.username
|
|
811
|
+
flow: options?.flow ?? "auto"
|
|
815
812
|
});
|
|
816
813
|
const dialogUrl = this.getDialogUrl();
|
|
817
814
|
const requestId = this.createDialogRequestId();
|
|
@@ -822,12 +819,12 @@ var OneAuthClient = class {
|
|
|
822
819
|
if (this.config.clientId) {
|
|
823
820
|
params.set("clientId", this.config.clientId);
|
|
824
821
|
}
|
|
825
|
-
if (options?.username) {
|
|
826
|
-
params.set("username", options.username);
|
|
827
|
-
}
|
|
828
822
|
if (options?.oauthEnabled === false) {
|
|
829
823
|
params.set("oauth", "0");
|
|
830
824
|
}
|
|
825
|
+
if (options?.eoaConnect) {
|
|
826
|
+
params.set("eoaConnect", "1");
|
|
827
|
+
}
|
|
831
828
|
if (options?.flow === "create-account") {
|
|
832
829
|
params.set("switch", "1");
|
|
833
830
|
}
|
|
@@ -896,7 +893,7 @@ var OneAuthClient = class {
|
|
|
896
893
|
* const result = await client.connectWithModal();
|
|
897
894
|
*
|
|
898
895
|
* if (result.success) {
|
|
899
|
-
* console.log('Connected as:', result.user?.
|
|
896
|
+
* console.log('Connected as:', result.user?.address);
|
|
900
897
|
* } else if (result.action === 'switch') {
|
|
901
898
|
* // User needs to sign in first
|
|
902
899
|
* const authResult = await client.authWithModal();
|
|
@@ -981,14 +978,14 @@ var OneAuthClient = class {
|
|
|
981
978
|
* `{ success: false, action: "cancel", error: { code: "USER_CANCELLED", … } }`.
|
|
982
979
|
*
|
|
983
980
|
* @param options - Forwarded to whichever underlying modal is shown.
|
|
984
|
-
* `
|
|
981
|
+
* `oauthEnabled` only applies to the auth-modal fallback path.
|
|
985
982
|
* @returns A {@link ConnectResult} discriminated union.
|
|
986
983
|
*
|
|
987
984
|
* @example
|
|
988
985
|
* ```typescript
|
|
989
986
|
* const result = await client.connect();
|
|
990
987
|
* if (result.success) {
|
|
991
|
-
* console.log("Connected as", result.user?.
|
|
988
|
+
* console.log("Connected as", result.user?.address);
|
|
992
989
|
* }
|
|
993
990
|
* ```
|
|
994
991
|
*/
|
|
@@ -1003,9 +1000,12 @@ var OneAuthClient = class {
|
|
|
1003
1000
|
return {
|
|
1004
1001
|
success: true,
|
|
1005
1002
|
user: {
|
|
1006
|
-
username: authResult.user.username,
|
|
1007
1003
|
address: authResult.user.address
|
|
1008
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",
|
|
1009
1009
|
autoConnected: false
|
|
1010
1010
|
};
|
|
1011
1011
|
}
|
|
@@ -1173,17 +1173,17 @@ var OneAuthClient = class {
|
|
|
1173
1173
|
targetChains: normalizeGrantTargetChains(options).join(","),
|
|
1174
1174
|
sponsor: options.sponsor !== false
|
|
1175
1175
|
});
|
|
1176
|
-
if (!options.
|
|
1176
|
+
if (!options.accountAddress) {
|
|
1177
1177
|
this.emitTelemetry("grant_permission.failed", telemetry, {
|
|
1178
1178
|
outcome: "failure",
|
|
1179
1179
|
errorCode: "INVALID_OPTIONS",
|
|
1180
|
-
errorMessage: "
|
|
1180
|
+
errorMessage: "accountAddress is required"
|
|
1181
1181
|
});
|
|
1182
1182
|
return {
|
|
1183
1183
|
success: false,
|
|
1184
1184
|
error: {
|
|
1185
1185
|
code: "INVALID_OPTIONS",
|
|
1186
|
-
message: "
|
|
1186
|
+
message: "accountAddress is required"
|
|
1187
1187
|
}
|
|
1188
1188
|
};
|
|
1189
1189
|
}
|
|
@@ -1247,7 +1247,6 @@ var OneAuthClient = class {
|
|
|
1247
1247
|
mode: "iframe",
|
|
1248
1248
|
clientId: this.config.clientId,
|
|
1249
1249
|
grant: cloneGrantPayload({
|
|
1250
|
-
username: options.username,
|
|
1251
1250
|
accountAddress: options.accountAddress,
|
|
1252
1251
|
targetChain: targetChains[0],
|
|
1253
1252
|
targetChains,
|
|
@@ -1302,17 +1301,16 @@ var OneAuthClient = class {
|
|
|
1302
1301
|
* not send `clientId` for this lookup because grants are origin-scoped.
|
|
1303
1302
|
*/
|
|
1304
1303
|
async listSessionGrants(options) {
|
|
1305
|
-
if (!options.
|
|
1304
|
+
if (!options.accountAddress) {
|
|
1306
1305
|
return {
|
|
1307
1306
|
success: false,
|
|
1308
1307
|
error: {
|
|
1309
1308
|
code: "INVALID_OPTIONS",
|
|
1310
|
-
message: "
|
|
1309
|
+
message: "accountAddress is required"
|
|
1311
1310
|
}
|
|
1312
1311
|
};
|
|
1313
1312
|
}
|
|
1314
1313
|
const params = new URLSearchParams();
|
|
1315
|
-
if (options.username) params.set("username", options.username);
|
|
1316
1314
|
if (options.accountAddress) params.set("accountAddress", options.accountAddress);
|
|
1317
1315
|
if (options.includeRevoked) params.set("includeRevoked", "true");
|
|
1318
1316
|
try {
|
|
@@ -1365,7 +1363,7 @@ var OneAuthClient = class {
|
|
|
1365
1363
|
* if (result.success && result.challenge) {
|
|
1366
1364
|
* // Verify signature server-side
|
|
1367
1365
|
* const isValid = await verifyOnServer(
|
|
1368
|
-
* result.user?.
|
|
1366
|
+
* result.user?.address,
|
|
1369
1367
|
* result.challenge.signature,
|
|
1370
1368
|
* result.challenge.signedHash
|
|
1371
1369
|
* );
|
|
@@ -1396,15 +1394,14 @@ var OneAuthClient = class {
|
|
|
1396
1394
|
return authResult;
|
|
1397
1395
|
}
|
|
1398
1396
|
const accountAddress = authResult.user?.address;
|
|
1399
|
-
|
|
1400
|
-
if (!accountAddress && !username) {
|
|
1397
|
+
if (!accountAddress) {
|
|
1401
1398
|
const result2 = {
|
|
1402
1399
|
success: false,
|
|
1403
1400
|
user: authResult.user,
|
|
1404
1401
|
signerType: authResult.signerType,
|
|
1405
1402
|
error: {
|
|
1406
1403
|
code: "AUTHENTICATE_USER_MISSING",
|
|
1407
|
-
message: "Authentication succeeded but no
|
|
1404
|
+
message: "Authentication succeeded but no account address was returned for challenge signing"
|
|
1408
1405
|
}
|
|
1409
1406
|
};
|
|
1410
1407
|
this.emitTelemetry("auth.failed", telemetry, {
|
|
@@ -1414,7 +1411,6 @@ var OneAuthClient = class {
|
|
|
1414
1411
|
return result2;
|
|
1415
1412
|
}
|
|
1416
1413
|
const signResult = await this.signMessage({
|
|
1417
|
-
username,
|
|
1418
1414
|
accountAddress,
|
|
1419
1415
|
message: options.challenge,
|
|
1420
1416
|
description: "Verify your identity",
|
|
@@ -1482,7 +1478,6 @@ var OneAuthClient = class {
|
|
|
1482
1478
|
const ready = await this.waitForDialogReady(dialog, iframe, cleanup, {
|
|
1483
1479
|
mode: "iframe",
|
|
1484
1480
|
challenge: options.challenge,
|
|
1485
|
-
username: options.username,
|
|
1486
1481
|
accountAddress: options.accountAddress,
|
|
1487
1482
|
description: options.description,
|
|
1488
1483
|
transaction: options.transaction,
|
|
@@ -1534,7 +1529,7 @@ var OneAuthClient = class {
|
|
|
1534
1529
|
* @example
|
|
1535
1530
|
* ```typescript
|
|
1536
1531
|
* const result = await client.sendIntent({
|
|
1537
|
-
*
|
|
1532
|
+
* accountAddress: '0x...',
|
|
1538
1533
|
* targetChain: 8453, // Base
|
|
1539
1534
|
* calls: [
|
|
1540
1535
|
* {
|
|
@@ -1552,7 +1547,7 @@ var OneAuthClient = class {
|
|
|
1552
1547
|
* ```
|
|
1553
1548
|
*/
|
|
1554
1549
|
async sendIntent(options) {
|
|
1555
|
-
const {
|
|
1550
|
+
const { accountAddress, targetChain } = options;
|
|
1556
1551
|
const calls = capCallLabels(options.calls);
|
|
1557
1552
|
const sponsor = options.sponsor !== false;
|
|
1558
1553
|
const telemetry = this.createTelemetryOperation("intent", {
|
|
@@ -1577,11 +1572,11 @@ var OneAuthClient = class {
|
|
|
1577
1572
|
}
|
|
1578
1573
|
};
|
|
1579
1574
|
}
|
|
1580
|
-
if (!
|
|
1575
|
+
if (!accountAddress) {
|
|
1581
1576
|
this.emitTelemetry("intent.completed", telemetry, {
|
|
1582
1577
|
outcome: "failure",
|
|
1583
1578
|
errorCode: "INVALID_OPTIONS",
|
|
1584
|
-
errorMessage: "
|
|
1579
|
+
errorMessage: "accountAddress is required"
|
|
1585
1580
|
});
|
|
1586
1581
|
return {
|
|
1587
1582
|
success: false,
|
|
@@ -1589,7 +1584,7 @@ var OneAuthClient = class {
|
|
|
1589
1584
|
status: "failed",
|
|
1590
1585
|
error: {
|
|
1591
1586
|
code: "INVALID_OPTIONS",
|
|
1592
|
-
message: "
|
|
1587
|
+
message: "accountAddress is required"
|
|
1593
1588
|
}
|
|
1594
1589
|
};
|
|
1595
1590
|
}
|
|
@@ -1739,7 +1734,6 @@ var OneAuthClient = class {
|
|
|
1739
1734
|
}
|
|
1740
1735
|
let accessToken = accessTokenResult.ok ? accessTokenResult.accessToken : "";
|
|
1741
1736
|
const requestBody = {
|
|
1742
|
-
username,
|
|
1743
1737
|
accountAddress,
|
|
1744
1738
|
targetChain,
|
|
1745
1739
|
calls,
|
|
@@ -1981,7 +1975,6 @@ var OneAuthClient = class {
|
|
|
1981
1975
|
chainId: targetChain,
|
|
1982
1976
|
transaction: prepareResponse.transaction,
|
|
1983
1977
|
challenge: prepareResponse.challenge,
|
|
1984
|
-
username,
|
|
1985
1978
|
accountAddress: prepareResponse.accountAddress,
|
|
1986
1979
|
originMessages: prepareResponse.originMessages,
|
|
1987
1980
|
tokenRequests: serializedTokenRequests,
|
|
@@ -2036,7 +2029,6 @@ var OneAuthClient = class {
|
|
|
2036
2029
|
signingMode: "transaction",
|
|
2037
2030
|
calls,
|
|
2038
2031
|
chainId: targetChain,
|
|
2039
|
-
username,
|
|
2040
2032
|
accountAddress: options.accountAddress,
|
|
2041
2033
|
tokenRequests: serializedTokenRequests,
|
|
2042
2034
|
telemetry: this.telemetryPayload(telemetry)
|
|
@@ -2112,7 +2104,6 @@ var OneAuthClient = class {
|
|
|
2112
2104
|
chainId: targetChain,
|
|
2113
2105
|
transaction: prepareResponse.transaction,
|
|
2114
2106
|
challenge: prepareResponse.challenge,
|
|
2115
|
-
username,
|
|
2116
2107
|
accountAddress: prepareResponse.accountAddress,
|
|
2117
2108
|
originMessages: prepareResponse.originMessages,
|
|
2118
2109
|
tokenRequests: serializedTokenRequests,
|
|
@@ -2507,7 +2498,7 @@ var OneAuthClient = class {
|
|
|
2507
2498
|
* @example
|
|
2508
2499
|
* ```typescript
|
|
2509
2500
|
* const result = await client.sendBatchIntent({
|
|
2510
|
-
*
|
|
2501
|
+
* accountAddress: '0x...',
|
|
2511
2502
|
* intents: [
|
|
2512
2503
|
* {
|
|
2513
2504
|
* targetChain: 8453, // Base
|
|
@@ -2544,11 +2535,11 @@ var OneAuthClient = class {
|
|
|
2544
2535
|
error: "Batch intents are not supported for EOA sessions. Use the connected wallet's native RPC instead."
|
|
2545
2536
|
};
|
|
2546
2537
|
}
|
|
2547
|
-
if (!options.
|
|
2538
|
+
if (!options.accountAddress) {
|
|
2548
2539
|
this.emitTelemetry("batch.completed", telemetry, {
|
|
2549
2540
|
outcome: "failure",
|
|
2550
2541
|
errorCode: "INVALID_OPTIONS",
|
|
2551
|
-
errorMessage: "
|
|
2542
|
+
errorMessage: "accountAddress is required"
|
|
2552
2543
|
});
|
|
2553
2544
|
return {
|
|
2554
2545
|
success: false,
|
|
@@ -2613,7 +2604,6 @@ var OneAuthClient = class {
|
|
|
2613
2604
|
moduleInstall: intent.moduleInstall
|
|
2614
2605
|
}));
|
|
2615
2606
|
const requestBody = {
|
|
2616
|
-
...options.username && { username: options.username },
|
|
2617
2607
|
...options.accountAddress && { accountAddress: options.accountAddress },
|
|
2618
2608
|
intents: serializedIntents,
|
|
2619
2609
|
auth: { accessToken },
|
|
@@ -2739,7 +2729,6 @@ var OneAuthClient = class {
|
|
|
2739
2729
|
batchFailedIntents: prepareResponse.failedIntents,
|
|
2740
2730
|
challenge: prepareResponse.challenge,
|
|
2741
2731
|
binding: prepareResponse.binding,
|
|
2742
|
-
username: options.username,
|
|
2743
2732
|
accountAddress: prepareResponse.accountAddress,
|
|
2744
2733
|
userId: prepareResponse.userId,
|
|
2745
2734
|
expiresAt: prepareResponse.expiresAt,
|
|
@@ -2758,7 +2747,6 @@ var OneAuthClient = class {
|
|
|
2758
2747
|
calls: JSON.stringify(intent.calls)
|
|
2759
2748
|
// No: transaction, intentOp, expiresAt, originMessages
|
|
2760
2749
|
})),
|
|
2761
|
-
username: options.username,
|
|
2762
2750
|
accountAddress: options.accountAddress,
|
|
2763
2751
|
telemetry: this.telemetryPayload(telemetry)
|
|
2764
2752
|
};
|
|
@@ -2783,7 +2771,6 @@ var OneAuthClient = class {
|
|
|
2783
2771
|
batchFailedIntents: prepareResponse.failedIntents,
|
|
2784
2772
|
challenge: prepareResponse.challenge,
|
|
2785
2773
|
binding: prepareResponse.binding,
|
|
2786
|
-
username: options.username,
|
|
2787
2774
|
accountAddress: prepareResponse.accountAddress,
|
|
2788
2775
|
userId: prepareResponse.userId,
|
|
2789
2776
|
expiresAt: prepareResponse.expiresAt,
|
|
@@ -3835,7 +3822,7 @@ var OneAuthClient = class {
|
|
|
3835
3822
|
* ```typescript
|
|
3836
3823
|
* // Sign a login challenge
|
|
3837
3824
|
* const result = await client.signMessage({
|
|
3838
|
-
*
|
|
3825
|
+
* accountAddress: '0x...',
|
|
3839
3826
|
* message: `Sign in to MyApp\nTimestamp: ${Date.now()}\nNonce: ${crypto.randomUUID()}`,
|
|
3840
3827
|
* description: 'Verify your identity to continue',
|
|
3841
3828
|
* });
|
|
@@ -3897,7 +3884,6 @@ var OneAuthClient = class {
|
|
|
3897
3884
|
mode: "iframe",
|
|
3898
3885
|
message: options.message,
|
|
3899
3886
|
challenge: options.challenge || options.message,
|
|
3900
|
-
username: options.username,
|
|
3901
3887
|
accountAddress: options.accountAddress,
|
|
3902
3888
|
description: options.description,
|
|
3903
3889
|
metadata: options.metadata,
|
|
@@ -3957,7 +3943,7 @@ var OneAuthClient = class {
|
|
|
3957
3943
|
* ```typescript
|
|
3958
3944
|
* // Sign an ERC-2612 Permit
|
|
3959
3945
|
* const result = await client.signTypedData({
|
|
3960
|
-
*
|
|
3946
|
+
* accountAddress: '0x...',
|
|
3961
3947
|
* domain: {
|
|
3962
3948
|
* name: 'Dai Stablecoin',
|
|
3963
3949
|
* version: '1',
|
|
@@ -4046,7 +4032,6 @@ var OneAuthClient = class {
|
|
|
4046
4032
|
message: options.message
|
|
4047
4033
|
},
|
|
4048
4034
|
challenge: signedHash,
|
|
4049
|
-
username: options.username,
|
|
4050
4035
|
accountAddress: options.accountAddress,
|
|
4051
4036
|
description: options.description,
|
|
4052
4037
|
telemetry: this.telemetryPayload(telemetry)
|
|
@@ -4311,11 +4296,14 @@ var OneAuthClient = class {
|
|
|
4311
4296
|
return this.fetchSigningResult(requestId);
|
|
4312
4297
|
}
|
|
4313
4298
|
/**
|
|
4314
|
-
* Fetch passkeys for a user from the auth provider
|
|
4299
|
+
* Fetch passkeys for a user from the auth provider.
|
|
4300
|
+
*
|
|
4301
|
+
* The account address is the sole identity; the backend `resolveUserWhere`
|
|
4302
|
+
* accepts an address as a globally-unique path identifier.
|
|
4315
4303
|
*/
|
|
4316
|
-
async getPasskeys(
|
|
4304
|
+
async getPasskeys(accountAddress) {
|
|
4317
4305
|
const response = await fetch(
|
|
4318
|
-
`${this.config.providerUrl}/api/users/${encodeURIComponent(
|
|
4306
|
+
`${this.config.providerUrl}/api/users/${encodeURIComponent(accountAddress)}/passkeys`,
|
|
4319
4307
|
{
|
|
4320
4308
|
headers: this.config.clientId ? { "x-client-id": this.config.clientId } : {}
|
|
4321
4309
|
}
|
|
@@ -4336,7 +4324,7 @@ var OneAuthClient = class {
|
|
|
4336
4324
|
* them by `requestId` without relying on URL parameters alone. This avoids
|
|
4337
4325
|
* exposing potentially large challenge payloads in query strings.
|
|
4338
4326
|
*
|
|
4339
|
-
* @param options - The signing options (challenge,
|
|
4327
|
+
* @param options - The signing options (challenge, accountAddress, description, etc.).
|
|
4340
4328
|
* @param mode - How the dialog will be opened (`"popup"`, `"redirect"`, or `"embed"`).
|
|
4341
4329
|
* @param redirectUrl - Only required for `"redirect"` mode; the URL the dialog
|
|
4342
4330
|
* will navigate back to after signing.
|
|
@@ -4353,7 +4341,6 @@ var OneAuthClient = class {
|
|
|
4353
4341
|
},
|
|
4354
4342
|
body: JSON.stringify({
|
|
4355
4343
|
...this.config.clientId && { clientId: this.config.clientId },
|
|
4356
|
-
username: options.username,
|
|
4357
4344
|
accountAddress: options.accountAddress,
|
|
4358
4345
|
challenge: options.challenge,
|
|
4359
4346
|
description: options.description,
|
|
@@ -4681,6 +4668,7 @@ var OneAuthClient = class {
|
|
|
4681
4668
|
iframe.setAttribute(
|
|
4682
4669
|
"allow",
|
|
4683
4670
|
[
|
|
4671
|
+
"payment",
|
|
4684
4672
|
`publickey-credentials-get ${hostUrl.origin}`,
|
|
4685
4673
|
`publickey-credentials-create ${hostUrl.origin}`,
|
|
4686
4674
|
"clipboard-write",
|
|
@@ -4845,7 +4833,6 @@ var OneAuthClient = class {
|
|
|
4845
4833
|
success: true,
|
|
4846
4834
|
user: {
|
|
4847
4835
|
id: data.data?.user?.id,
|
|
4848
|
-
username: data.data?.username,
|
|
4849
4836
|
address: data.data?.address
|
|
4850
4837
|
},
|
|
4851
4838
|
signerType: data.data?.signerType ?? "passkey"
|
|
@@ -4899,7 +4886,6 @@ var OneAuthClient = class {
|
|
|
4899
4886
|
success: true,
|
|
4900
4887
|
user: {
|
|
4901
4888
|
id: data.data?.user?.id,
|
|
4902
|
-
username: data.data?.username,
|
|
4903
4889
|
address: data.data?.address
|
|
4904
4890
|
},
|
|
4905
4891
|
signerType: data.data?.signerType ?? "passkey"
|
|
@@ -4931,7 +4917,7 @@ var OneAuthClient = class {
|
|
|
4931
4917
|
*
|
|
4932
4918
|
* The connect flow is a lightweight "are you still you?" confirmation that
|
|
4933
4919
|
* does not require a new passkey ceremony. On success, the dialog returns the
|
|
4934
|
-
* user's
|
|
4920
|
+
* user's address and an `autoConnected` flag indicating whether the
|
|
4935
4921
|
* user had previously enabled auto-connect (in which case no UI was shown).
|
|
4936
4922
|
*
|
|
4937
4923
|
* On failure with `action: "switch"`, the caller should redirect to the full
|
|
@@ -4955,9 +4941,12 @@ var OneAuthClient = class {
|
|
|
4955
4941
|
resolve({
|
|
4956
4942
|
success: true,
|
|
4957
4943
|
user: {
|
|
4958
|
-
username: data.data?.username,
|
|
4959
4944
|
address: data.data?.address
|
|
4960
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",
|
|
4961
4950
|
autoConnected: data.data?.autoConnected
|
|
4962
4951
|
});
|
|
4963
4952
|
} else {
|
|
@@ -5325,6 +5314,87 @@ function createCrossChainPermission(input) {
|
|
|
5325
5314
|
};
|
|
5326
5315
|
}
|
|
5327
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
|
+
|
|
5328
5398
|
// src/account.ts
|
|
5329
5399
|
import {
|
|
5330
5400
|
bytesToString,
|
|
@@ -5333,7 +5403,7 @@ import {
|
|
|
5333
5403
|
} from "viem";
|
|
5334
5404
|
import { toAccount } from "viem/accounts";
|
|
5335
5405
|
function createPasskeyAccount(client, params) {
|
|
5336
|
-
const { address
|
|
5406
|
+
const { address } = params;
|
|
5337
5407
|
const normalizeMessage = (message) => {
|
|
5338
5408
|
if (typeof message === "string") return message;
|
|
5339
5409
|
const raw = message.raw;
|
|
@@ -5350,7 +5420,6 @@ function createPasskeyAccount(client, params) {
|
|
|
5350
5420
|
address,
|
|
5351
5421
|
signMessage: async ({ message }) => {
|
|
5352
5422
|
const result = await client.signMessage({
|
|
5353
|
-
username: username || void 0,
|
|
5354
5423
|
accountAddress: address,
|
|
5355
5424
|
message: normalizeMessage(message)
|
|
5356
5425
|
});
|
|
@@ -5386,7 +5455,6 @@ function createPasskeyAccount(client, params) {
|
|
|
5386
5455
|
])
|
|
5387
5456
|
);
|
|
5388
5457
|
const result = await client.signTypedData({
|
|
5389
|
-
username: username || void 0,
|
|
5390
5458
|
accountAddress: address,
|
|
5391
5459
|
domain,
|
|
5392
5460
|
types: normalizedTypes,
|
|
@@ -5401,7 +5469,6 @@ function createPasskeyAccount(client, params) {
|
|
|
5401
5469
|
});
|
|
5402
5470
|
return {
|
|
5403
5471
|
...account,
|
|
5404
|
-
...username ? { username } : {},
|
|
5405
5472
|
accountAddress: address
|
|
5406
5473
|
};
|
|
5407
5474
|
}
|
|
@@ -5409,13 +5476,16 @@ function createPasskeyAccount(client, params) {
|
|
|
5409
5476
|
// src/walletClient/index.ts
|
|
5410
5477
|
import {
|
|
5411
5478
|
createWalletClient,
|
|
5412
|
-
|
|
5413
|
-
|
|
5479
|
+
hashTypedData as hashTypedData2,
|
|
5480
|
+
toHex
|
|
5414
5481
|
} from "viem";
|
|
5415
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
|
+
}
|
|
5416
5487
|
function createPasskeyWalletClient(config) {
|
|
5417
5488
|
const identity = {
|
|
5418
|
-
...config.username ? { username: config.username } : {},
|
|
5419
5489
|
accountAddress: config.accountAddress
|
|
5420
5490
|
};
|
|
5421
5491
|
const provider = new OneAuthClient({
|
|
@@ -5428,20 +5498,10 @@ function createPasskeyWalletClient(config) {
|
|
|
5428
5498
|
sponsorship: config.sponsorship
|
|
5429
5499
|
});
|
|
5430
5500
|
const signMessageImpl = async (message) => {
|
|
5431
|
-
const
|
|
5432
|
-
const result = await provider.signWithModal({
|
|
5433
|
-
challenge: hash,
|
|
5501
|
+
const result = await provider.signMessage({
|
|
5434
5502
|
...identity,
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
actions: [
|
|
5438
|
-
{
|
|
5439
|
-
type: "custom",
|
|
5440
|
-
label: "Sign Message",
|
|
5441
|
-
sublabel: typeof message === "string" ? message.slice(0, 50) + (message.length > 50 ? "..." : "") : "Raw message"
|
|
5442
|
-
}
|
|
5443
|
-
]
|
|
5444
|
-
}
|
|
5503
|
+
message: formatSignableMessage(message),
|
|
5504
|
+
description: "Sign message"
|
|
5445
5505
|
});
|
|
5446
5506
|
if (!result.success) {
|
|
5447
5507
|
throw new Error(result.error?.message || "Signing failed");
|
|
@@ -5510,7 +5570,6 @@ function createPasskeyWalletClient(config) {
|
|
|
5510
5570
|
abi: call.abi
|
|
5511
5571
|
}));
|
|
5512
5572
|
return {
|
|
5513
|
-
...config.username ? { username: config.username } : {},
|
|
5514
5573
|
accountAddress: config.accountAddress,
|
|
5515
5574
|
targetChain,
|
|
5516
5575
|
calls: intentCalls
|
|
@@ -5594,21 +5653,19 @@ function generateId() {
|
|
|
5594
5653
|
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
5595
5654
|
}
|
|
5596
5655
|
function getStorageKey(identity) {
|
|
5597
|
-
const key = identity?.accountAddress
|
|
5656
|
+
const key = identity?.accountAddress;
|
|
5598
5657
|
return key ? `1auth_batch_queue_${key.toLowerCase()}` : "1auth_batch_queue_anonymous";
|
|
5599
5658
|
}
|
|
5600
5659
|
function resolveIdentity(passedIdentity, providerIdentity) {
|
|
5601
5660
|
if (typeof passedIdentity === "string") {
|
|
5602
|
-
return {
|
|
5661
|
+
return { accountAddress: passedIdentity };
|
|
5603
5662
|
}
|
|
5604
5663
|
return {
|
|
5605
|
-
username: passedIdentity?.username ?? providerIdentity.username,
|
|
5606
5664
|
accountAddress: passedIdentity?.accountAddress ?? providerIdentity.accountAddress
|
|
5607
5665
|
};
|
|
5608
5666
|
}
|
|
5609
5667
|
function BatchQueueProvider({
|
|
5610
5668
|
client,
|
|
5611
|
-
username,
|
|
5612
5669
|
accountAddress,
|
|
5613
5670
|
children
|
|
5614
5671
|
}) {
|
|
@@ -5617,8 +5674,8 @@ function BatchQueueProvider({
|
|
|
5617
5674
|
const [isSigning, setIsSigning] = React.useState(false);
|
|
5618
5675
|
const [animationTrigger, setAnimationTrigger] = React.useState(0);
|
|
5619
5676
|
const providerIdentity = React.useMemo(
|
|
5620
|
-
() => ({
|
|
5621
|
-
[
|
|
5677
|
+
() => ({ accountAddress }),
|
|
5678
|
+
[accountAddress]
|
|
5622
5679
|
);
|
|
5623
5680
|
const batchChainId = queue.length > 0 ? queue[0].targetChain : null;
|
|
5624
5681
|
React.useEffect(() => {
|
|
@@ -5684,14 +5741,14 @@ function BatchQueueProvider({
|
|
|
5684
5741
|
};
|
|
5685
5742
|
}
|
|
5686
5743
|
const signer = resolveIdentity(identity, providerIdentity);
|
|
5687
|
-
if (!signer.
|
|
5744
|
+
if (!signer.accountAddress) {
|
|
5688
5745
|
return {
|
|
5689
5746
|
success: false,
|
|
5690
5747
|
intentId: "",
|
|
5691
5748
|
status: "failed",
|
|
5692
5749
|
error: {
|
|
5693
5750
|
code: "MISSING_IDENTITY",
|
|
5694
|
-
message: "Batch signing requires an accountAddress
|
|
5751
|
+
message: "Batch signing requires an accountAddress"
|
|
5695
5752
|
}
|
|
5696
5753
|
};
|
|
5697
5754
|
}
|
|
@@ -5700,7 +5757,6 @@ function BatchQueueProvider({
|
|
|
5700
5757
|
setIsSigning(true);
|
|
5701
5758
|
try {
|
|
5702
5759
|
const result = await client.sendIntent({
|
|
5703
|
-
username: signer.username,
|
|
5704
5760
|
accountAddress: signer.accountAddress,
|
|
5705
5761
|
targetChain,
|
|
5706
5762
|
calls
|
|
@@ -6036,6 +6092,7 @@ export {
|
|
|
6036
6092
|
ETHEREUM_MESSAGE_PREFIX,
|
|
6037
6093
|
OneAuthClient,
|
|
6038
6094
|
createCrossChainPermission,
|
|
6095
|
+
createOneAuthConnection,
|
|
6039
6096
|
createOneAuthProvider,
|
|
6040
6097
|
createPasskeyAccount,
|
|
6041
6098
|
createPasskeyWalletClient,
|