@rhinestone/1auth 0.7.3 → 0.7.5
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-6MUQKHAT.mjs} +7 -31
- package/dist/chunk-6MUQKHAT.mjs.map +1 -0
- package/dist/{client-CuASptX3.d.ts → client-BqKAd2RZ.d.mts} +17 -17
- package/dist/{client-D4HVy1KF.d.mts → client-C9mcj5jN.d.ts} +17 -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 +12 -21
- package/dist/index.d.ts +12 -21
- package/dist/index.js +44 -99
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -71
- package/dist/index.mjs.map +1 -1
- package/dist/{provider-6JoziYDq.d.ts → provider-CCyUBseo.d.ts} +3 -3
- package/dist/{provider-CAQT7Gqx.d.mts → provider-CRhZVLg8.d.mts} +3 -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-CbhPRY5s.d.mts} +23 -50
- package/dist/{types-C0jKNT_t.d.ts → types-CbhPRY5s.d.ts} +23 -50
- package/dist/{verify-CnOwPq78.d.ts → verify-DPJR_foR.d.ts} +4 -6
- package/dist/{verify-aWdi5O2z.d.mts → verify-DVYDJgOS.d.mts} +4 -6
- package/dist/wagmi.d.mts +3 -3
- package/dist/wagmi.d.ts +3 -3
- package/dist/wagmi.js +6 -30
- 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.js
CHANGED
|
@@ -965,7 +965,6 @@ var OneAuthClient = class {
|
|
|
965
965
|
* call — the modal shows the appropriate flow based on whether the user
|
|
966
966
|
* has a passkey registered.
|
|
967
967
|
*
|
|
968
|
-
* @param options.username - Pre-fill the username field
|
|
969
968
|
* @param options.theme - Override the theme for this modal invocation
|
|
970
969
|
* @param options.oauthEnabled - Set to false to hide OAuth sign-in buttons
|
|
971
970
|
* @param options.flow - Force the login or account-creation route instead
|
|
@@ -977,7 +976,7 @@ var OneAuthClient = class {
|
|
|
977
976
|
* const result = await client.authWithModal();
|
|
978
977
|
*
|
|
979
978
|
* if (result.success) {
|
|
980
|
-
* console.log('Signed in as:', result.user?.
|
|
979
|
+
* console.log('Signed in as:', result.user?.address);
|
|
981
980
|
* console.log('Address:', result.user?.address); // typed `0x${string}`
|
|
982
981
|
* } else if (result.error?.code === 'USER_CANCELLED') {
|
|
983
982
|
* // User closed the modal
|
|
@@ -995,7 +994,6 @@ var OneAuthClient = class {
|
|
|
995
994
|
* is creating a login session, for example after an app-level "Log in"
|
|
996
995
|
* button. The result intentionally matches {@link authWithModal}.
|
|
997
996
|
*
|
|
998
|
-
* @param options.username - Optional account hint for the sign-in ceremony
|
|
999
997
|
* @param options.theme - Override the theme for this modal invocation
|
|
1000
998
|
* @returns {@link AuthResult} with user details and typed address
|
|
1001
999
|
*/
|
|
@@ -1025,8 +1023,7 @@ var OneAuthClient = class {
|
|
|
1025
1023
|
*/
|
|
1026
1024
|
async openAuthModal(options) {
|
|
1027
1025
|
const telemetry = this.createTelemetryOperation("auth", {
|
|
1028
|
-
flow: options?.flow ?? "auto"
|
|
1029
|
-
hasUsernameHint: !!options?.username
|
|
1026
|
+
flow: options?.flow ?? "auto"
|
|
1030
1027
|
});
|
|
1031
1028
|
const dialogUrl = this.getDialogUrl();
|
|
1032
1029
|
const requestId = this.createDialogRequestId();
|
|
@@ -1037,9 +1034,6 @@ var OneAuthClient = class {
|
|
|
1037
1034
|
if (this.config.clientId) {
|
|
1038
1035
|
params.set("clientId", this.config.clientId);
|
|
1039
1036
|
}
|
|
1040
|
-
if (options?.username) {
|
|
1041
|
-
params.set("username", options.username);
|
|
1042
|
-
}
|
|
1043
1037
|
if (options?.oauthEnabled === false) {
|
|
1044
1038
|
params.set("oauth", "0");
|
|
1045
1039
|
}
|
|
@@ -1111,7 +1105,7 @@ var OneAuthClient = class {
|
|
|
1111
1105
|
* const result = await client.connectWithModal();
|
|
1112
1106
|
*
|
|
1113
1107
|
* if (result.success) {
|
|
1114
|
-
* console.log('Connected as:', result.user?.
|
|
1108
|
+
* console.log('Connected as:', result.user?.address);
|
|
1115
1109
|
* } else if (result.action === 'switch') {
|
|
1116
1110
|
* // User needs to sign in first
|
|
1117
1111
|
* const authResult = await client.authWithModal();
|
|
@@ -1196,14 +1190,14 @@ var OneAuthClient = class {
|
|
|
1196
1190
|
* `{ success: false, action: "cancel", error: { code: "USER_CANCELLED", … } }`.
|
|
1197
1191
|
*
|
|
1198
1192
|
* @param options - Forwarded to whichever underlying modal is shown.
|
|
1199
|
-
* `
|
|
1193
|
+
* `oauthEnabled` only applies to the auth-modal fallback path.
|
|
1200
1194
|
* @returns A {@link ConnectResult} discriminated union.
|
|
1201
1195
|
*
|
|
1202
1196
|
* @example
|
|
1203
1197
|
* ```typescript
|
|
1204
1198
|
* const result = await client.connect();
|
|
1205
1199
|
* if (result.success) {
|
|
1206
|
-
* console.log("Connected as", result.user?.
|
|
1200
|
+
* console.log("Connected as", result.user?.address);
|
|
1207
1201
|
* }
|
|
1208
1202
|
* ```
|
|
1209
1203
|
*/
|
|
@@ -1218,7 +1212,6 @@ var OneAuthClient = class {
|
|
|
1218
1212
|
return {
|
|
1219
1213
|
success: true,
|
|
1220
1214
|
user: {
|
|
1221
|
-
username: authResult.user.username,
|
|
1222
1215
|
address: authResult.user.address
|
|
1223
1216
|
},
|
|
1224
1217
|
autoConnected: false
|
|
@@ -1388,17 +1381,17 @@ var OneAuthClient = class {
|
|
|
1388
1381
|
targetChains: normalizeGrantTargetChains(options).join(","),
|
|
1389
1382
|
sponsor: options.sponsor !== false
|
|
1390
1383
|
});
|
|
1391
|
-
if (!options.
|
|
1384
|
+
if (!options.accountAddress) {
|
|
1392
1385
|
this.emitTelemetry("grant_permission.failed", telemetry, {
|
|
1393
1386
|
outcome: "failure",
|
|
1394
1387
|
errorCode: "INVALID_OPTIONS",
|
|
1395
|
-
errorMessage: "
|
|
1388
|
+
errorMessage: "accountAddress is required"
|
|
1396
1389
|
});
|
|
1397
1390
|
return {
|
|
1398
1391
|
success: false,
|
|
1399
1392
|
error: {
|
|
1400
1393
|
code: "INVALID_OPTIONS",
|
|
1401
|
-
message: "
|
|
1394
|
+
message: "accountAddress is required"
|
|
1402
1395
|
}
|
|
1403
1396
|
};
|
|
1404
1397
|
}
|
|
@@ -1462,7 +1455,6 @@ var OneAuthClient = class {
|
|
|
1462
1455
|
mode: "iframe",
|
|
1463
1456
|
clientId: this.config.clientId,
|
|
1464
1457
|
grant: cloneGrantPayload({
|
|
1465
|
-
username: options.username,
|
|
1466
1458
|
accountAddress: options.accountAddress,
|
|
1467
1459
|
targetChain: targetChains[0],
|
|
1468
1460
|
targetChains,
|
|
@@ -1517,17 +1509,16 @@ var OneAuthClient = class {
|
|
|
1517
1509
|
* not send `clientId` for this lookup because grants are origin-scoped.
|
|
1518
1510
|
*/
|
|
1519
1511
|
async listSessionGrants(options) {
|
|
1520
|
-
if (!options.
|
|
1512
|
+
if (!options.accountAddress) {
|
|
1521
1513
|
return {
|
|
1522
1514
|
success: false,
|
|
1523
1515
|
error: {
|
|
1524
1516
|
code: "INVALID_OPTIONS",
|
|
1525
|
-
message: "
|
|
1517
|
+
message: "accountAddress is required"
|
|
1526
1518
|
}
|
|
1527
1519
|
};
|
|
1528
1520
|
}
|
|
1529
1521
|
const params = new URLSearchParams();
|
|
1530
|
-
if (options.username) params.set("username", options.username);
|
|
1531
1522
|
if (options.accountAddress) params.set("accountAddress", options.accountAddress);
|
|
1532
1523
|
if (options.includeRevoked) params.set("includeRevoked", "true");
|
|
1533
1524
|
try {
|
|
@@ -1580,7 +1571,7 @@ var OneAuthClient = class {
|
|
|
1580
1571
|
* if (result.success && result.challenge) {
|
|
1581
1572
|
* // Verify signature server-side
|
|
1582
1573
|
* const isValid = await verifyOnServer(
|
|
1583
|
-
* result.user?.
|
|
1574
|
+
* result.user?.address,
|
|
1584
1575
|
* result.challenge.signature,
|
|
1585
1576
|
* result.challenge.signedHash
|
|
1586
1577
|
* );
|
|
@@ -1611,15 +1602,14 @@ var OneAuthClient = class {
|
|
|
1611
1602
|
return authResult;
|
|
1612
1603
|
}
|
|
1613
1604
|
const accountAddress = authResult.user?.address;
|
|
1614
|
-
|
|
1615
|
-
if (!accountAddress && !username) {
|
|
1605
|
+
if (!accountAddress) {
|
|
1616
1606
|
const result2 = {
|
|
1617
1607
|
success: false,
|
|
1618
1608
|
user: authResult.user,
|
|
1619
1609
|
signerType: authResult.signerType,
|
|
1620
1610
|
error: {
|
|
1621
1611
|
code: "AUTHENTICATE_USER_MISSING",
|
|
1622
|
-
message: "Authentication succeeded but no
|
|
1612
|
+
message: "Authentication succeeded but no account address was returned for challenge signing"
|
|
1623
1613
|
}
|
|
1624
1614
|
};
|
|
1625
1615
|
this.emitTelemetry("auth.failed", telemetry, {
|
|
@@ -1629,7 +1619,6 @@ var OneAuthClient = class {
|
|
|
1629
1619
|
return result2;
|
|
1630
1620
|
}
|
|
1631
1621
|
const signResult = await this.signMessage({
|
|
1632
|
-
username,
|
|
1633
1622
|
accountAddress,
|
|
1634
1623
|
message: options.challenge,
|
|
1635
1624
|
description: "Verify your identity",
|
|
@@ -1697,7 +1686,6 @@ var OneAuthClient = class {
|
|
|
1697
1686
|
const ready = await this.waitForDialogReady(dialog, iframe, cleanup, {
|
|
1698
1687
|
mode: "iframe",
|
|
1699
1688
|
challenge: options.challenge,
|
|
1700
|
-
username: options.username,
|
|
1701
1689
|
accountAddress: options.accountAddress,
|
|
1702
1690
|
description: options.description,
|
|
1703
1691
|
transaction: options.transaction,
|
|
@@ -1749,7 +1737,7 @@ var OneAuthClient = class {
|
|
|
1749
1737
|
* @example
|
|
1750
1738
|
* ```typescript
|
|
1751
1739
|
* const result = await client.sendIntent({
|
|
1752
|
-
*
|
|
1740
|
+
* accountAddress: '0x...',
|
|
1753
1741
|
* targetChain: 8453, // Base
|
|
1754
1742
|
* calls: [
|
|
1755
1743
|
* {
|
|
@@ -1767,7 +1755,7 @@ var OneAuthClient = class {
|
|
|
1767
1755
|
* ```
|
|
1768
1756
|
*/
|
|
1769
1757
|
async sendIntent(options) {
|
|
1770
|
-
const {
|
|
1758
|
+
const { accountAddress, targetChain } = options;
|
|
1771
1759
|
const calls = capCallLabels(options.calls);
|
|
1772
1760
|
const sponsor = options.sponsor !== false;
|
|
1773
1761
|
const telemetry = this.createTelemetryOperation("intent", {
|
|
@@ -1792,11 +1780,11 @@ var OneAuthClient = class {
|
|
|
1792
1780
|
}
|
|
1793
1781
|
};
|
|
1794
1782
|
}
|
|
1795
|
-
if (!
|
|
1783
|
+
if (!accountAddress) {
|
|
1796
1784
|
this.emitTelemetry("intent.completed", telemetry, {
|
|
1797
1785
|
outcome: "failure",
|
|
1798
1786
|
errorCode: "INVALID_OPTIONS",
|
|
1799
|
-
errorMessage: "
|
|
1787
|
+
errorMessage: "accountAddress is required"
|
|
1800
1788
|
});
|
|
1801
1789
|
return {
|
|
1802
1790
|
success: false,
|
|
@@ -1804,7 +1792,7 @@ var OneAuthClient = class {
|
|
|
1804
1792
|
status: "failed",
|
|
1805
1793
|
error: {
|
|
1806
1794
|
code: "INVALID_OPTIONS",
|
|
1807
|
-
message: "
|
|
1795
|
+
message: "accountAddress is required"
|
|
1808
1796
|
}
|
|
1809
1797
|
};
|
|
1810
1798
|
}
|
|
@@ -1954,7 +1942,6 @@ var OneAuthClient = class {
|
|
|
1954
1942
|
}
|
|
1955
1943
|
let accessToken = accessTokenResult.ok ? accessTokenResult.accessToken : "";
|
|
1956
1944
|
const requestBody = {
|
|
1957
|
-
username,
|
|
1958
1945
|
accountAddress,
|
|
1959
1946
|
targetChain,
|
|
1960
1947
|
calls,
|
|
@@ -2196,7 +2183,6 @@ var OneAuthClient = class {
|
|
|
2196
2183
|
chainId: targetChain,
|
|
2197
2184
|
transaction: prepareResponse.transaction,
|
|
2198
2185
|
challenge: prepareResponse.challenge,
|
|
2199
|
-
username,
|
|
2200
2186
|
accountAddress: prepareResponse.accountAddress,
|
|
2201
2187
|
originMessages: prepareResponse.originMessages,
|
|
2202
2188
|
tokenRequests: serializedTokenRequests,
|
|
@@ -2251,7 +2237,6 @@ var OneAuthClient = class {
|
|
|
2251
2237
|
signingMode: "transaction",
|
|
2252
2238
|
calls,
|
|
2253
2239
|
chainId: targetChain,
|
|
2254
|
-
username,
|
|
2255
2240
|
accountAddress: options.accountAddress,
|
|
2256
2241
|
tokenRequests: serializedTokenRequests,
|
|
2257
2242
|
telemetry: this.telemetryPayload(telemetry)
|
|
@@ -2327,7 +2312,6 @@ var OneAuthClient = class {
|
|
|
2327
2312
|
chainId: targetChain,
|
|
2328
2313
|
transaction: prepareResponse.transaction,
|
|
2329
2314
|
challenge: prepareResponse.challenge,
|
|
2330
|
-
username,
|
|
2331
2315
|
accountAddress: prepareResponse.accountAddress,
|
|
2332
2316
|
originMessages: prepareResponse.originMessages,
|
|
2333
2317
|
tokenRequests: serializedTokenRequests,
|
|
@@ -2722,7 +2706,7 @@ var OneAuthClient = class {
|
|
|
2722
2706
|
* @example
|
|
2723
2707
|
* ```typescript
|
|
2724
2708
|
* const result = await client.sendBatchIntent({
|
|
2725
|
-
*
|
|
2709
|
+
* accountAddress: '0x...',
|
|
2726
2710
|
* intents: [
|
|
2727
2711
|
* {
|
|
2728
2712
|
* targetChain: 8453, // Base
|
|
@@ -2759,11 +2743,11 @@ var OneAuthClient = class {
|
|
|
2759
2743
|
error: "Batch intents are not supported for EOA sessions. Use the connected wallet's native RPC instead."
|
|
2760
2744
|
};
|
|
2761
2745
|
}
|
|
2762
|
-
if (!options.
|
|
2746
|
+
if (!options.accountAddress) {
|
|
2763
2747
|
this.emitTelemetry("batch.completed", telemetry, {
|
|
2764
2748
|
outcome: "failure",
|
|
2765
2749
|
errorCode: "INVALID_OPTIONS",
|
|
2766
|
-
errorMessage: "
|
|
2750
|
+
errorMessage: "accountAddress is required"
|
|
2767
2751
|
});
|
|
2768
2752
|
return {
|
|
2769
2753
|
success: false,
|
|
@@ -2828,7 +2812,6 @@ var OneAuthClient = class {
|
|
|
2828
2812
|
moduleInstall: intent.moduleInstall
|
|
2829
2813
|
}));
|
|
2830
2814
|
const requestBody = {
|
|
2831
|
-
...options.username && { username: options.username },
|
|
2832
2815
|
...options.accountAddress && { accountAddress: options.accountAddress },
|
|
2833
2816
|
intents: serializedIntents,
|
|
2834
2817
|
auth: { accessToken },
|
|
@@ -2954,7 +2937,6 @@ var OneAuthClient = class {
|
|
|
2954
2937
|
batchFailedIntents: prepareResponse.failedIntents,
|
|
2955
2938
|
challenge: prepareResponse.challenge,
|
|
2956
2939
|
binding: prepareResponse.binding,
|
|
2957
|
-
username: options.username,
|
|
2958
2940
|
accountAddress: prepareResponse.accountAddress,
|
|
2959
2941
|
userId: prepareResponse.userId,
|
|
2960
2942
|
expiresAt: prepareResponse.expiresAt,
|
|
@@ -2973,7 +2955,6 @@ var OneAuthClient = class {
|
|
|
2973
2955
|
calls: JSON.stringify(intent.calls)
|
|
2974
2956
|
// No: transaction, intentOp, expiresAt, originMessages
|
|
2975
2957
|
})),
|
|
2976
|
-
username: options.username,
|
|
2977
2958
|
accountAddress: options.accountAddress,
|
|
2978
2959
|
telemetry: this.telemetryPayload(telemetry)
|
|
2979
2960
|
};
|
|
@@ -2998,7 +2979,6 @@ var OneAuthClient = class {
|
|
|
2998
2979
|
batchFailedIntents: prepareResponse.failedIntents,
|
|
2999
2980
|
challenge: prepareResponse.challenge,
|
|
3000
2981
|
binding: prepareResponse.binding,
|
|
3001
|
-
username: options.username,
|
|
3002
2982
|
accountAddress: prepareResponse.accountAddress,
|
|
3003
2983
|
userId: prepareResponse.userId,
|
|
3004
2984
|
expiresAt: prepareResponse.expiresAt,
|
|
@@ -4050,7 +4030,7 @@ var OneAuthClient = class {
|
|
|
4050
4030
|
* ```typescript
|
|
4051
4031
|
* // Sign a login challenge
|
|
4052
4032
|
* const result = await client.signMessage({
|
|
4053
|
-
*
|
|
4033
|
+
* accountAddress: '0x...',
|
|
4054
4034
|
* message: `Sign in to MyApp\nTimestamp: ${Date.now()}\nNonce: ${crypto.randomUUID()}`,
|
|
4055
4035
|
* description: 'Verify your identity to continue',
|
|
4056
4036
|
* });
|
|
@@ -4112,7 +4092,6 @@ var OneAuthClient = class {
|
|
|
4112
4092
|
mode: "iframe",
|
|
4113
4093
|
message: options.message,
|
|
4114
4094
|
challenge: options.challenge || options.message,
|
|
4115
|
-
username: options.username,
|
|
4116
4095
|
accountAddress: options.accountAddress,
|
|
4117
4096
|
description: options.description,
|
|
4118
4097
|
metadata: options.metadata,
|
|
@@ -4172,7 +4151,7 @@ var OneAuthClient = class {
|
|
|
4172
4151
|
* ```typescript
|
|
4173
4152
|
* // Sign an ERC-2612 Permit
|
|
4174
4153
|
* const result = await client.signTypedData({
|
|
4175
|
-
*
|
|
4154
|
+
* accountAddress: '0x...',
|
|
4176
4155
|
* domain: {
|
|
4177
4156
|
* name: 'Dai Stablecoin',
|
|
4178
4157
|
* version: '1',
|
|
@@ -4261,7 +4240,6 @@ var OneAuthClient = class {
|
|
|
4261
4240
|
message: options.message
|
|
4262
4241
|
},
|
|
4263
4242
|
challenge: signedHash,
|
|
4264
|
-
username: options.username,
|
|
4265
4243
|
accountAddress: options.accountAddress,
|
|
4266
4244
|
description: options.description,
|
|
4267
4245
|
telemetry: this.telemetryPayload(telemetry)
|
|
@@ -4526,11 +4504,14 @@ var OneAuthClient = class {
|
|
|
4526
4504
|
return this.fetchSigningResult(requestId);
|
|
4527
4505
|
}
|
|
4528
4506
|
/**
|
|
4529
|
-
* Fetch passkeys for a user from the auth provider
|
|
4507
|
+
* Fetch passkeys for a user from the auth provider.
|
|
4508
|
+
*
|
|
4509
|
+
* The account address is the sole identity; the backend `resolveUserWhere`
|
|
4510
|
+
* accepts an address as a globally-unique path identifier.
|
|
4530
4511
|
*/
|
|
4531
|
-
async getPasskeys(
|
|
4512
|
+
async getPasskeys(accountAddress) {
|
|
4532
4513
|
const response = await fetch(
|
|
4533
|
-
`${this.config.providerUrl}/api/users/${encodeURIComponent(
|
|
4514
|
+
`${this.config.providerUrl}/api/users/${encodeURIComponent(accountAddress)}/passkeys`,
|
|
4534
4515
|
{
|
|
4535
4516
|
headers: this.config.clientId ? { "x-client-id": this.config.clientId } : {}
|
|
4536
4517
|
}
|
|
@@ -4551,7 +4532,7 @@ var OneAuthClient = class {
|
|
|
4551
4532
|
* them by `requestId` without relying on URL parameters alone. This avoids
|
|
4552
4533
|
* exposing potentially large challenge payloads in query strings.
|
|
4553
4534
|
*
|
|
4554
|
-
* @param options - The signing options (challenge,
|
|
4535
|
+
* @param options - The signing options (challenge, accountAddress, description, etc.).
|
|
4555
4536
|
* @param mode - How the dialog will be opened (`"popup"`, `"redirect"`, or `"embed"`).
|
|
4556
4537
|
* @param redirectUrl - Only required for `"redirect"` mode; the URL the dialog
|
|
4557
4538
|
* will navigate back to after signing.
|
|
@@ -4568,7 +4549,6 @@ var OneAuthClient = class {
|
|
|
4568
4549
|
},
|
|
4569
4550
|
body: JSON.stringify({
|
|
4570
4551
|
...this.config.clientId && { clientId: this.config.clientId },
|
|
4571
|
-
username: options.username,
|
|
4572
4552
|
accountAddress: options.accountAddress,
|
|
4573
4553
|
challenge: options.challenge,
|
|
4574
4554
|
description: options.description,
|
|
@@ -5060,7 +5040,6 @@ var OneAuthClient = class {
|
|
|
5060
5040
|
success: true,
|
|
5061
5041
|
user: {
|
|
5062
5042
|
id: data.data?.user?.id,
|
|
5063
|
-
username: data.data?.username,
|
|
5064
5043
|
address: data.data?.address
|
|
5065
5044
|
},
|
|
5066
5045
|
signerType: data.data?.signerType ?? "passkey"
|
|
@@ -5114,7 +5093,6 @@ var OneAuthClient = class {
|
|
|
5114
5093
|
success: true,
|
|
5115
5094
|
user: {
|
|
5116
5095
|
id: data.data?.user?.id,
|
|
5117
|
-
username: data.data?.username,
|
|
5118
5096
|
address: data.data?.address
|
|
5119
5097
|
},
|
|
5120
5098
|
signerType: data.data?.signerType ?? "passkey"
|
|
@@ -5146,7 +5124,7 @@ var OneAuthClient = class {
|
|
|
5146
5124
|
*
|
|
5147
5125
|
* The connect flow is a lightweight "are you still you?" confirmation that
|
|
5148
5126
|
* does not require a new passkey ceremony. On success, the dialog returns the
|
|
5149
|
-
* user's
|
|
5127
|
+
* user's address and an `autoConnected` flag indicating whether the
|
|
5150
5128
|
* user had previously enabled auto-connect (in which case no UI was shown).
|
|
5151
5129
|
*
|
|
5152
5130
|
* On failure with `action: "switch"`, the caller should redirect to the full
|
|
@@ -5170,7 +5148,6 @@ var OneAuthClient = class {
|
|
|
5170
5148
|
resolve({
|
|
5171
5149
|
success: true,
|
|
5172
5150
|
user: {
|
|
5173
|
-
username: data.data?.username,
|
|
5174
5151
|
address: data.data?.address
|
|
5175
5152
|
},
|
|
5176
5153
|
autoConnected: data.data?.autoConnected
|
|
@@ -5641,21 +5618,6 @@ function createOneAuthProvider(options) {
|
|
|
5641
5618
|
if (typeof window === "undefined") return;
|
|
5642
5619
|
localStorage.removeItem(storageKey);
|
|
5643
5620
|
};
|
|
5644
|
-
const resolveAccountAddress = async (username) => {
|
|
5645
|
-
const clientId = client.getClientId();
|
|
5646
|
-
const response = await fetch(
|
|
5647
|
-
`${client.getProviderUrl()}/api/users/${encodeURIComponent(username)}/account`,
|
|
5648
|
-
{
|
|
5649
|
-
headers: clientId ? { "x-client-id": clientId } : {}
|
|
5650
|
-
}
|
|
5651
|
-
);
|
|
5652
|
-
if (!response.ok) {
|
|
5653
|
-
const data2 = await response.json().catch(() => ({}));
|
|
5654
|
-
throw new Error(data2.error || "Failed to resolve account address");
|
|
5655
|
-
}
|
|
5656
|
-
const data = await response.json();
|
|
5657
|
-
return data.address;
|
|
5658
|
-
};
|
|
5659
5621
|
const connect = async () => {
|
|
5660
5622
|
const stored = getStoredUser();
|
|
5661
5623
|
if (stored) {
|
|
@@ -5665,16 +5627,12 @@ function createOneAuthProvider(options) {
|
|
|
5665
5627
|
if (!authResult.success) {
|
|
5666
5628
|
throw new Error(authResult.error?.message || "Authentication failed");
|
|
5667
5629
|
}
|
|
5668
|
-
const
|
|
5669
|
-
let address = authResult.user?.address;
|
|
5630
|
+
const address = authResult.user?.address;
|
|
5670
5631
|
const signerType = authResult.signerType;
|
|
5671
|
-
if (!address && username) {
|
|
5672
|
-
address = await resolveAccountAddress(username);
|
|
5673
|
-
}
|
|
5674
5632
|
if (!address) {
|
|
5675
5633
|
throw new Error("No account address available");
|
|
5676
5634
|
}
|
|
5677
|
-
setStoredUser({
|
|
5635
|
+
setStoredUser({ address, signerType });
|
|
5678
5636
|
emit("accountsChanged", [address]);
|
|
5679
5637
|
emit("connect", { chainId: (0, import_viem5.numberToHex)(chainId) });
|
|
5680
5638
|
return [address];
|
|
@@ -5788,11 +5746,10 @@ function createOneAuthProvider(options) {
|
|
|
5788
5746
|
]);
|
|
5789
5747
|
const signMessage = async (message) => {
|
|
5790
5748
|
const user = await ensureUser();
|
|
5791
|
-
if (!user.
|
|
5792
|
-
throw new Error("
|
|
5749
|
+
if (!user.address) {
|
|
5750
|
+
throw new Error("Account address required for signing.");
|
|
5793
5751
|
}
|
|
5794
5752
|
const result = await client.signMessage({
|
|
5795
|
-
username: user.username || void 0,
|
|
5796
5753
|
accountAddress: user.address,
|
|
5797
5754
|
message
|
|
5798
5755
|
});
|
|
@@ -5803,12 +5760,11 @@ function createOneAuthProvider(options) {
|
|
|
5803
5760
|
};
|
|
5804
5761
|
const signTypedData = async (typedData) => {
|
|
5805
5762
|
const user = await ensureUser();
|
|
5806
|
-
if (!user.
|
|
5807
|
-
throw new Error("
|
|
5763
|
+
if (!user.address) {
|
|
5764
|
+
throw new Error("Account address required for signing.");
|
|
5808
5765
|
}
|
|
5809
5766
|
const data = typeof typedData === "string" ? JSON.parse(typedData) : typedData;
|
|
5810
5767
|
const result = await client.signTypedData({
|
|
5811
|
-
username: user.username || void 0,
|
|
5812
5768
|
accountAddress: user.address,
|
|
5813
5769
|
domain: data.domain,
|
|
5814
5770
|
types: data.types,
|
|
@@ -5821,7 +5777,6 @@ function createOneAuthProvider(options) {
|
|
|
5821
5777
|
return encodeWebAuthnSignature(result.signature);
|
|
5822
5778
|
};
|
|
5823
5779
|
const resolveIntentPayload = (payload) => ({
|
|
5824
|
-
username: payload.username,
|
|
5825
5780
|
accountAddress: payload.accountAddress,
|
|
5826
5781
|
targetChain: payload.targetChain,
|
|
5827
5782
|
calls: payload.calls,
|
|
@@ -5964,7 +5919,6 @@ function createOneAuthProvider(options) {
|
|
|
5964
5919
|
const tokenRequests = normalizeTokenRequests(tx.tokenRequests);
|
|
5965
5920
|
const txSourceChainId = parseChainId(tx.sourceChainId);
|
|
5966
5921
|
return sendIntent({
|
|
5967
|
-
username: user.username || void 0,
|
|
5968
5922
|
accountAddress: user.address,
|
|
5969
5923
|
targetChain,
|
|
5970
5924
|
calls,
|
|
@@ -5982,7 +5936,6 @@ function createOneAuthProvider(options) {
|
|
|
5982
5936
|
const sourceChainId = parseChainId(payload.sourceChainId);
|
|
5983
5937
|
if (!calls.length) throw new Error("No calls provided");
|
|
5984
5938
|
return sendIntent({
|
|
5985
|
-
username: user.username || void 0,
|
|
5986
5939
|
accountAddress: user.address,
|
|
5987
5940
|
targetChain,
|
|
5988
5941
|
calls,
|
|
@@ -6126,7 +6079,7 @@ function createOneAuthProvider(options) {
|
|
|
6126
6079
|
var import_viem6 = require("viem");
|
|
6127
6080
|
var import_accounts = require("viem/accounts");
|
|
6128
6081
|
function createPasskeyAccount(client, params) {
|
|
6129
|
-
const { address
|
|
6082
|
+
const { address } = params;
|
|
6130
6083
|
const normalizeMessage = (message) => {
|
|
6131
6084
|
if (typeof message === "string") return message;
|
|
6132
6085
|
const raw = message.raw;
|
|
@@ -6143,7 +6096,6 @@ function createPasskeyAccount(client, params) {
|
|
|
6143
6096
|
address,
|
|
6144
6097
|
signMessage: async ({ message }) => {
|
|
6145
6098
|
const result = await client.signMessage({
|
|
6146
|
-
username: username || void 0,
|
|
6147
6099
|
accountAddress: address,
|
|
6148
6100
|
message: normalizeMessage(message)
|
|
6149
6101
|
});
|
|
@@ -6179,7 +6131,6 @@ function createPasskeyAccount(client, params) {
|
|
|
6179
6131
|
])
|
|
6180
6132
|
);
|
|
6181
6133
|
const result = await client.signTypedData({
|
|
6182
|
-
username: username || void 0,
|
|
6183
6134
|
accountAddress: address,
|
|
6184
6135
|
domain,
|
|
6185
6136
|
types: normalizedTypes,
|
|
@@ -6194,7 +6145,6 @@ function createPasskeyAccount(client, params) {
|
|
|
6194
6145
|
});
|
|
6195
6146
|
return {
|
|
6196
6147
|
...account,
|
|
6197
|
-
...username ? { username } : {},
|
|
6198
6148
|
accountAddress: address
|
|
6199
6149
|
};
|
|
6200
6150
|
}
|
|
@@ -6204,7 +6154,6 @@ var import_viem7 = require("viem");
|
|
|
6204
6154
|
var import_accounts2 = require("viem/accounts");
|
|
6205
6155
|
function createPasskeyWalletClient(config) {
|
|
6206
6156
|
const identity = {
|
|
6207
|
-
...config.username ? { username: config.username } : {},
|
|
6208
6157
|
accountAddress: config.accountAddress
|
|
6209
6158
|
};
|
|
6210
6159
|
const provider = new OneAuthClient({
|
|
@@ -6299,7 +6248,6 @@ function createPasskeyWalletClient(config) {
|
|
|
6299
6248
|
abi: call.abi
|
|
6300
6249
|
}));
|
|
6301
6250
|
return {
|
|
6302
|
-
...config.username ? { username: config.username } : {},
|
|
6303
6251
|
accountAddress: config.accountAddress,
|
|
6304
6252
|
targetChain,
|
|
6305
6253
|
calls: intentCalls
|
|
@@ -6383,21 +6331,19 @@ function generateId() {
|
|
|
6383
6331
|
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
6384
6332
|
}
|
|
6385
6333
|
function getStorageKey(identity) {
|
|
6386
|
-
const key = identity?.accountAddress
|
|
6334
|
+
const key = identity?.accountAddress;
|
|
6387
6335
|
return key ? `1auth_batch_queue_${key.toLowerCase()}` : "1auth_batch_queue_anonymous";
|
|
6388
6336
|
}
|
|
6389
6337
|
function resolveIdentity(passedIdentity, providerIdentity) {
|
|
6390
6338
|
if (typeof passedIdentity === "string") {
|
|
6391
|
-
return {
|
|
6339
|
+
return { accountAddress: passedIdentity };
|
|
6392
6340
|
}
|
|
6393
6341
|
return {
|
|
6394
|
-
username: passedIdentity?.username ?? providerIdentity.username,
|
|
6395
6342
|
accountAddress: passedIdentity?.accountAddress ?? providerIdentity.accountAddress
|
|
6396
6343
|
};
|
|
6397
6344
|
}
|
|
6398
6345
|
function BatchQueueProvider({
|
|
6399
6346
|
client,
|
|
6400
|
-
username,
|
|
6401
6347
|
accountAddress,
|
|
6402
6348
|
children
|
|
6403
6349
|
}) {
|
|
@@ -6406,8 +6352,8 @@ function BatchQueueProvider({
|
|
|
6406
6352
|
const [isSigning, setIsSigning] = React.useState(false);
|
|
6407
6353
|
const [animationTrigger, setAnimationTrigger] = React.useState(0);
|
|
6408
6354
|
const providerIdentity = React.useMemo(
|
|
6409
|
-
() => ({
|
|
6410
|
-
[
|
|
6355
|
+
() => ({ accountAddress }),
|
|
6356
|
+
[accountAddress]
|
|
6411
6357
|
);
|
|
6412
6358
|
const batchChainId = queue.length > 0 ? queue[0].targetChain : null;
|
|
6413
6359
|
React.useEffect(() => {
|
|
@@ -6473,14 +6419,14 @@ function BatchQueueProvider({
|
|
|
6473
6419
|
};
|
|
6474
6420
|
}
|
|
6475
6421
|
const signer = resolveIdentity(identity, providerIdentity);
|
|
6476
|
-
if (!signer.
|
|
6422
|
+
if (!signer.accountAddress) {
|
|
6477
6423
|
return {
|
|
6478
6424
|
success: false,
|
|
6479
6425
|
intentId: "",
|
|
6480
6426
|
status: "failed",
|
|
6481
6427
|
error: {
|
|
6482
6428
|
code: "MISSING_IDENTITY",
|
|
6483
|
-
message: "Batch signing requires an accountAddress
|
|
6429
|
+
message: "Batch signing requires an accountAddress"
|
|
6484
6430
|
}
|
|
6485
6431
|
};
|
|
6486
6432
|
}
|
|
@@ -6489,7 +6435,6 @@ function BatchQueueProvider({
|
|
|
6489
6435
|
setIsSigning(true);
|
|
6490
6436
|
try {
|
|
6491
6437
|
const result = await client.sendIntent({
|
|
6492
|
-
username: signer.username,
|
|
6493
6438
|
accountAddress: signer.accountAddress,
|
|
6494
6439
|
targetChain,
|
|
6495
6440
|
calls
|