@fluent.xyz/connect 0.2.3 → 0.3.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/README.md +10 -8
- package/dist/index.d.ts +18 -16
- package/dist/index.js +44 -36
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ export function App() {
|
|
|
39
39
|
return (
|
|
40
40
|
<FluentWidget
|
|
41
41
|
config={{
|
|
42
|
-
|
|
42
|
+
appId: "app_<32 hex, from the Fluent Dashboard>",
|
|
43
43
|
privyClientId: "client-<issued by Fluent>",
|
|
44
44
|
network: resolveFluentWidgetNetworkFromEnv() ?? "testnet",
|
|
45
45
|
appName: "My App",
|
|
@@ -56,12 +56,14 @@ export function App() {
|
|
|
56
56
|
}
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
`
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
`appId` and `privyClientId` are both required and come from Fluent. `appId` is the
|
|
60
|
+
App's identity — sponsorship, auth and analytics speak it — and must be the `app_<32 hex>`
|
|
61
|
+
value the Fluent Dashboard shows; the widget throws on any other shape. `privyClientId` is
|
|
62
|
+
login configuration: the Privy app client carrying your allowed origins.
|
|
62
63
|
|
|
63
|
-
>
|
|
64
|
-
>
|
|
64
|
+
> Upgrading from 0.2.x? `partnerId` was renamed to `appId` in 0.3.0 and the id value changed
|
|
65
|
+
> from `partner_…` to `app_…`; passing `partnerId` throws with the same hint. Migrating from
|
|
66
|
+
> `clientId`? That option is gone: the value it held is now `privyClientId`.
|
|
65
67
|
|
|
66
68
|
`authMode: "direct"` requires your origin registered on the Privy app client behind your `privyClientId`. Default `authMode: "hosted"` uses the Fluent authorize popup and works on any origin.
|
|
67
69
|
|
|
@@ -70,7 +72,7 @@ configuration: the Privy app client carrying your allowed origins.
|
|
|
70
72
|
`getAuthToken()` (render context / `useFluentWidget()`) returns a 5-minute ES256 JWT signed by
|
|
71
73
|
Fluent Connect. Send it to your backend once and issue your own session; verify it with the keys
|
|
72
74
|
at `<iss>/.well-known/jwks.json` — `iss` is the API host root, not `/api/v1` — and check `iss`,
|
|
73
|
-
`aud` (your `
|
|
75
|
+
`aud` (your `appId`) and `exp`. `sub` is stable per user per app. `addresses` is present only
|
|
74
76
|
when your app has the `addresses` scope. Direct auth only. External wallets: an EOA or a deployed
|
|
75
77
|
contract wallet signs in; a counterfactual smart account cannot (no ERC-6492).
|
|
76
78
|
See `apps/auth-demo` for a browser-side verifier.
|
|
@@ -85,7 +87,7 @@ By default the connect control floats top-right (`connectButton="fixed"`). To pl
|
|
|
85
87
|
// Hide the default control and use your own CTA
|
|
86
88
|
<FluentWidget
|
|
87
89
|
connectButton={false}
|
|
88
|
-
config={{
|
|
90
|
+
config={{ appId: "app_…", privyClientId: "client-…", network: "testnet", appName: "My App" }}
|
|
89
91
|
mode="page"
|
|
90
92
|
renderPage={({ openConnect, openAccount, hasConnectedAccount }) => (
|
|
91
93
|
<button type="button" onClick={hasConnectedAccount ? openAccount : openConnect}>
|
package/dist/index.d.ts
CHANGED
|
@@ -1198,7 +1198,7 @@ declare const FLUENT_CONNECT_DEFAULT_ASSETS: {
|
|
|
1198
1198
|
};
|
|
1199
1199
|
|
|
1200
1200
|
type FluentWidgetSession = FluentSession & {
|
|
1201
|
-
|
|
1201
|
+
appId?: string;
|
|
1202
1202
|
idToken: string;
|
|
1203
1203
|
wallet: Omit<FluentSession["wallet"], "smartAccountAddress"> & {
|
|
1204
1204
|
smartAccountAddress: `0x${string}`;
|
|
@@ -1215,16 +1215,18 @@ type FluentWidgetSession = FluentSession & {
|
|
|
1215
1215
|
};
|
|
1216
1216
|
type FluentWidgetAuthMode = "hosted" | "direct";
|
|
1217
1217
|
type FluentWidgetConfig = {
|
|
1218
|
-
/** The
|
|
1219
|
-
|
|
1218
|
+
/** The App's id (`app_<32 hex>`) — the same string the Fluent Dashboard shows and the token's `aud` carries. */
|
|
1219
|
+
appId: string;
|
|
1220
1220
|
/**
|
|
1221
|
-
* The Privy app client issued by Fluent for this
|
|
1222
|
-
* identity: it carries the allowed origins for Privy login, while `
|
|
1221
|
+
* The Privy app client issued by Fluent for this App. Login configuration, not
|
|
1222
|
+
* identity: it carries the allowed origins for Privy login, while `appId` is what
|
|
1223
1223
|
* sponsorship, auth and analytics speak.
|
|
1224
1224
|
*/
|
|
1225
1225
|
privyClientId: string;
|
|
1226
|
-
/** Removed in
|
|
1226
|
+
/** Removed in 0.2.0 — the type exists only so the error names the fix. */
|
|
1227
1227
|
clientId?: never;
|
|
1228
|
+
/** Renamed to `appId` in 0.3.0 — the type exists only so the error names the fix. */
|
|
1229
|
+
partnerId?: never;
|
|
1228
1230
|
network?: FluentWidgetNetwork;
|
|
1229
1231
|
appName?: string;
|
|
1230
1232
|
/**
|
|
@@ -1281,7 +1283,7 @@ type FluentWidgetConfig = {
|
|
|
1281
1283
|
};
|
|
1282
1284
|
};
|
|
1283
1285
|
type ResolvedFluentWidgetConfig = {
|
|
1284
|
-
|
|
1286
|
+
appId: string;
|
|
1285
1287
|
privyClientId: string;
|
|
1286
1288
|
network: FluentWidgetNetwork;
|
|
1287
1289
|
appName: string;
|
|
@@ -1372,8 +1374,8 @@ type FluentZeroDevPermissionCall = {
|
|
|
1372
1374
|
declare function useFluentZeroDevAccount(hookOptions?: {
|
|
1373
1375
|
authorizeUrl?: string;
|
|
1374
1376
|
allowHostedSigner?: boolean;
|
|
1375
|
-
/**
|
|
1376
|
-
|
|
1377
|
+
/** App id in the sponsorship path. Sponsorship is off unless both this and the URL are set. */
|
|
1378
|
+
appId?: string;
|
|
1377
1379
|
sponsorshipUrl?: string;
|
|
1378
1380
|
authorizationSession?: {
|
|
1379
1381
|
expiresAt: number;
|
|
@@ -1533,7 +1535,7 @@ type FluentExecuteResult = {
|
|
|
1533
1535
|
/** True when all calls landed atomically (smart account), false for sequential EOA txs. */
|
|
1534
1536
|
atomic: boolean;
|
|
1535
1537
|
/**
|
|
1536
|
-
* True when
|
|
1538
|
+
* True when an App's sponsorship paid the gas for this operation. Read back off the
|
|
1537
1539
|
* settled UserOperation (which contract the EntryPoint charged), not from which client
|
|
1538
1540
|
* we chose to send with: a refusal in the sponsorship proxy is a flat 403 and the
|
|
1539
1541
|
* account silently pays its own gas, so an optimistic flag would report the failure
|
|
@@ -1582,7 +1584,7 @@ type FluentGasPayment = {
|
|
|
1582
1584
|
*/
|
|
1583
1585
|
symbol: FluentGasTokenSymbol;
|
|
1584
1586
|
/**
|
|
1585
|
-
* Whether to ask the
|
|
1587
|
+
* Whether to ask the App's sponsorship paymaster to pay for this operation.
|
|
1586
1588
|
*
|
|
1587
1589
|
* Defaults to `"auto"`, which is what every caller got before this option existed: try
|
|
1588
1590
|
* sponsorship, and if the paymaster refuses, resend with the account paying its own gas.
|
|
@@ -1591,7 +1593,7 @@ type FluentGasPayment = {
|
|
|
1591
1593
|
*
|
|
1592
1594
|
* The distinction is not cosmetic: under `"auto"` the two outcomes are indistinguishable
|
|
1593
1595
|
* before the send and only the settled receipt separates them, so a caller that wants to
|
|
1594
|
-
* *demonstrate* unsponsored execution — or to keep
|
|
1596
|
+
* *demonstrate* unsponsored execution — or to keep an App's budget untouched — has no
|
|
1595
1597
|
* way to say so. Ignored when `symbol` names an ERC-20: that token's own paymaster pays,
|
|
1596
1598
|
* and sponsorship is not in the picture.
|
|
1597
1599
|
*/
|
|
@@ -1701,7 +1703,7 @@ type FluentWidgetRenderContext = {
|
|
|
1701
1703
|
refreshBalances: () => void;
|
|
1702
1704
|
/**
|
|
1703
1705
|
* A short-lived (5 min) Fluent-signed JWT for the connected user. Verify it on your backend
|
|
1704
|
-
* against `<iss>/.well-known/jwks.json` (ES256), checking `iss`, `aud` (= your
|
|
1706
|
+
* against `<iss>/.well-known/jwks.json` (ES256), checking `iss`, `aud` (= your appId) and
|
|
1705
1707
|
* `exp`; `sub` is stable per user per app. Reused until `authTokenRenewalOffsetSeconds`
|
|
1706
1708
|
* before `exp`. Direct auth only; throws `FluentAuthError`
|
|
1707
1709
|
* (`code: "hosted_not_supported"`) in hosted mode. External wallets: EOAs and deployed
|
|
@@ -1794,7 +1796,7 @@ declare function useFluentUserTokens(options?: {
|
|
|
1794
1796
|
remove: (token: Pick<FluentTokenDefinition, "chainId" | "address">) => void;
|
|
1795
1797
|
};
|
|
1796
1798
|
|
|
1797
|
-
type FluentAuthErrorCode = "
|
|
1799
|
+
type FluentAuthErrorCode = "unknown_app" | "app_not_auth_enabled" | "origin_not_allowed" | "origin_missing" | "bad_request" | "nonce_unknown" | "nonce_used" | "nonce_expired" | "app_mismatch" | "invalid_signature" | "signature_prefix_rejected" | "address_already_linked" | "invalid_privy_token" | "no_embedded_wallet" | "rate_limited" | "internal" | "hosted_not_supported" | "not_connected" | "privy_token_missing" | "origin_mismatch" | "request_failed";
|
|
1798
1800
|
declare class FluentAuthError extends Error {
|
|
1799
1801
|
readonly code: FluentAuthErrorCode;
|
|
1800
1802
|
readonly status?: number | undefined;
|
|
@@ -1855,10 +1857,10 @@ declare function createFluentZeroDevErc20PaymasterRpcUrl(params?: {
|
|
|
1855
1857
|
chainId?: number;
|
|
1856
1858
|
projectId?: string;
|
|
1857
1859
|
}): string;
|
|
1858
|
-
/** The
|
|
1860
|
+
/** The App travels in the path, the user in the `Authorization` header. */
|
|
1859
1861
|
declare function createFluentSponsorshipRpcUrl(params: {
|
|
1860
1862
|
sponsorshipUrl: string;
|
|
1861
|
-
|
|
1863
|
+
appId: string;
|
|
1862
1864
|
}): string;
|
|
1863
1865
|
declare function createFluentZeroDevSponsoredPaymaster(params: {
|
|
1864
1866
|
chain: Chain;
|
package/dist/index.js
CHANGED
|
@@ -5262,32 +5262,40 @@ var FLUENT_FAMILY_TIER_PROGRESS = {
|
|
|
5262
5262
|
C: 33,
|
|
5263
5263
|
D: 0
|
|
5264
5264
|
};
|
|
5265
|
+
var APP_ID_PATTERN = /^app_[0-9a-f]{32}$/;
|
|
5266
|
+
var APP_ID_HINT = "Pass the app_<32 hex> id from the Fluent Dashboard as appId.";
|
|
5265
5267
|
function resolveFluentWidgetConfig(config) {
|
|
5266
5268
|
if (config.clientId !== void 0) {
|
|
5267
5269
|
throw new Error(
|
|
5268
|
-
|
|
5270
|
+
`FluentWidgetConfig.clientId was removed in 0.2.0. ${APP_ID_HINT} Pass the Privy app client as privyClientId \u2014 both are required.`
|
|
5269
5271
|
);
|
|
5270
5272
|
}
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
+
if (config.partnerId !== void 0) {
|
|
5274
|
+
throw new Error(`FluentWidgetConfig.partnerId was renamed to appId in 0.3.0. ${APP_ID_HINT}`);
|
|
5275
|
+
}
|
|
5276
|
+
const appId = (config.appId ?? "").trim();
|
|
5277
|
+
if (!appId) {
|
|
5278
|
+
throw new Error(`FluentWidgetConfig.appId is required. ${APP_ID_HINT}`);
|
|
5279
|
+
}
|
|
5280
|
+
if (appId.startsWith("client-")) {
|
|
5273
5281
|
throw new Error(
|
|
5274
|
-
|
|
5282
|
+
`FluentWidgetConfig.appId "${appId}" is a Privy app client, not an app id. Pass the app_<32 hex> id as appId and the Privy client as privyClientId.`
|
|
5275
5283
|
);
|
|
5276
5284
|
}
|
|
5277
|
-
if (
|
|
5285
|
+
if (!APP_ID_PATTERN.test(appId)) {
|
|
5278
5286
|
throw new Error(
|
|
5279
|
-
`FluentWidgetConfig.
|
|
5287
|
+
`FluentWidgetConfig.appId "${appId}" is not an app id. Expected app_<32 hex> (lowercase), the id the Fluent Dashboard shows for the App.`
|
|
5280
5288
|
);
|
|
5281
5289
|
}
|
|
5282
5290
|
const privyClientId = (config.privyClientId ?? "").trim();
|
|
5283
5291
|
if (!privyClientId) {
|
|
5284
5292
|
throw new Error(
|
|
5285
|
-
"FluentWidgetConfig.privyClientId is required. Pass the Privy app client issued by Fluent for this
|
|
5293
|
+
"FluentWidgetConfig.privyClientId is required. Pass the Privy app client issued by Fluent for this App."
|
|
5286
5294
|
);
|
|
5287
5295
|
}
|
|
5288
|
-
if (privyClientId.startsWith("
|
|
5296
|
+
if (privyClientId.startsWith("app_")) {
|
|
5289
5297
|
throw new Error(
|
|
5290
|
-
`FluentWidgetConfig.privyClientId "${privyClientId}" is
|
|
5298
|
+
`FluentWidgetConfig.privyClientId "${privyClientId}" is an app id, not a Privy app client. Swap the two: appId takes the app_<32 hex> id, privyClientId the client-\u2026 value.`
|
|
5291
5299
|
);
|
|
5292
5300
|
}
|
|
5293
5301
|
if (!privyClientId.startsWith("client-")) {
|
|
@@ -5300,7 +5308,7 @@ function resolveFluentWidgetConfig(config) {
|
|
|
5300
5308
|
return {
|
|
5301
5309
|
network,
|
|
5302
5310
|
appName: config.appName ?? "Fluent Connect Demo",
|
|
5303
|
-
|
|
5311
|
+
appId,
|
|
5304
5312
|
privyClientId,
|
|
5305
5313
|
authMode: config.authMode ?? "hosted",
|
|
5306
5314
|
authorizeUrl: endpoints.authorizeUrl,
|
|
@@ -5572,7 +5580,7 @@ function toAuthError(err) {
|
|
|
5572
5580
|
async function exchangePrivyAuthToken(params) {
|
|
5573
5581
|
try {
|
|
5574
5582
|
const { token } = await postJson(`${params.publicApiUrl}/auth/exchange/privy`, {
|
|
5575
|
-
|
|
5583
|
+
appId: params.appId,
|
|
5576
5584
|
accessToken: params.accessToken,
|
|
5577
5585
|
identityToken: params.identityToken
|
|
5578
5586
|
});
|
|
@@ -5584,7 +5592,7 @@ async function exchangePrivyAuthToken(params) {
|
|
|
5584
5592
|
async function exchangeWalletAuthToken(params) {
|
|
5585
5593
|
const attempt = async () => {
|
|
5586
5594
|
const challenge = await postJson(`${params.publicApiUrl}/auth/challenge`, {
|
|
5587
|
-
|
|
5595
|
+
appId: params.appId,
|
|
5588
5596
|
address: params.address
|
|
5589
5597
|
});
|
|
5590
5598
|
if (challenge.typedData.message.origin !== params.origin) {
|
|
@@ -5598,7 +5606,7 @@ async function exchangeWalletAuthToken(params) {
|
|
|
5598
5606
|
...challenge.typedData
|
|
5599
5607
|
});
|
|
5600
5608
|
const { token } = await postJson(`${params.publicApiUrl}/auth/exchange/wallet`, {
|
|
5601
|
-
|
|
5609
|
+
appId: params.appId,
|
|
5602
5610
|
nonce: challenge.nonce,
|
|
5603
5611
|
signature
|
|
5604
5612
|
});
|
|
@@ -5950,7 +5958,7 @@ function createFluentZeroDevErc20PaymasterRpcUrl(params = {}) {
|
|
|
5950
5958
|
}
|
|
5951
5959
|
function createFluentSponsorshipRpcUrl(params) {
|
|
5952
5960
|
const base = params.sponsorshipUrl.replace(/\/+$/, "");
|
|
5953
|
-
return `${base}/paymaster/${encodeURIComponent(params.
|
|
5961
|
+
return `${base}/paymaster/${encodeURIComponent(params.appId)}`;
|
|
5954
5962
|
}
|
|
5955
5963
|
function createFluentZeroDevSponsoredPaymaster(params) {
|
|
5956
5964
|
const paymasterClient = createZeroDevPaymasterClient({
|
|
@@ -6313,7 +6321,7 @@ function useFluentZeroDevAccount(hookOptions = {}) {
|
|
|
6313
6321
|
[authenticated, embeddedWallet, error, hostedSigner, initialize2, kernels.prompt, ready]
|
|
6314
6322
|
);
|
|
6315
6323
|
const createSponsoredClient = useCallback(async (kernel) => {
|
|
6316
|
-
if (!hookOptions.sponsorshipUrl || !hookOptions.
|
|
6324
|
+
if (!hookOptions.sponsorshipUrl || !hookOptions.appId) return null;
|
|
6317
6325
|
if (sponsorshipUnavailable.current) return null;
|
|
6318
6326
|
const accessToken = await getAccessToken();
|
|
6319
6327
|
if (!accessToken) return null;
|
|
@@ -6327,11 +6335,11 @@ function useFluentZeroDevAccount(hookOptions = {}) {
|
|
|
6327
6335
|
accessToken,
|
|
6328
6336
|
rpcUrl: createFluentSponsorshipRpcUrl({
|
|
6329
6337
|
sponsorshipUrl: hookOptions.sponsorshipUrl,
|
|
6330
|
-
|
|
6338
|
+
appId: hookOptions.appId
|
|
6331
6339
|
})
|
|
6332
6340
|
})
|
|
6333
6341
|
});
|
|
6334
|
-
}, [getAccessToken, hookOptions.
|
|
6342
|
+
}, [getAccessToken, hookOptions.appId, hookOptions.sponsorshipUrl]);
|
|
6335
6343
|
const sendCalls = useCallback(
|
|
6336
6344
|
async (calls, options) => {
|
|
6337
6345
|
const signerMode = confirmationToSignerMode(options?.confirmation ?? "always");
|
|
@@ -6382,7 +6390,7 @@ function useFluentZeroDevAccount(hookOptions = {}) {
|
|
|
6382
6390
|
let sponsorshipReason;
|
|
6383
6391
|
if (sponsorshipRefused) {
|
|
6384
6392
|
sponsorshipReason = "not_requested";
|
|
6385
|
-
} else if (!gasToken && !sponsoredClient && hookOptions.sponsorshipUrl && hookOptions.
|
|
6393
|
+
} else if (!gasToken && !sponsoredClient && hookOptions.sponsorshipUrl && hookOptions.appId) {
|
|
6386
6394
|
sponsorshipReason = sponsorshipUnavailable.current ? "unauthorized" : "no_token";
|
|
6387
6395
|
}
|
|
6388
6396
|
let settlementClient = executionClient;
|
|
@@ -6439,7 +6447,7 @@ function useFluentZeroDevAccount(hookOptions = {}) {
|
|
|
6439
6447
|
error,
|
|
6440
6448
|
hostedSigner,
|
|
6441
6449
|
hookOptions.authorizationSession,
|
|
6442
|
-
hookOptions.
|
|
6450
|
+
hookOptions.appId,
|
|
6443
6451
|
hookOptions.sponsorshipUrl,
|
|
6444
6452
|
initialize2,
|
|
6445
6453
|
kernels,
|
|
@@ -6950,7 +6958,7 @@ function toUnixSeconds(value) {
|
|
|
6950
6958
|
}
|
|
6951
6959
|
|
|
6952
6960
|
// package.json
|
|
6953
|
-
var version = "0.
|
|
6961
|
+
var version = "0.3.0";
|
|
6954
6962
|
|
|
6955
6963
|
// src/core/analytics.ts
|
|
6956
6964
|
var INSTANCE_NAME = "fluent";
|
|
@@ -7032,7 +7040,7 @@ function createTracker(config, getContext) {
|
|
|
7032
7040
|
const enabled = analyticsEnabled(config);
|
|
7033
7041
|
if (enabled) initFluentAnalytics(config);
|
|
7034
7042
|
const base = {
|
|
7035
|
-
|
|
7043
|
+
app_id: config.appId,
|
|
7036
7044
|
network: config.network,
|
|
7037
7045
|
auth_mode: config.authMode,
|
|
7038
7046
|
source: config.source,
|
|
@@ -7355,7 +7363,7 @@ function createLocalFluentSession(params) {
|
|
|
7355
7363
|
const issuedAt = Math.floor(Date.now() / 1e3);
|
|
7356
7364
|
const payload = {
|
|
7357
7365
|
iss: typeof location !== "undefined" ? location.origin : "fluent-local",
|
|
7358
|
-
aud: params.
|
|
7366
|
+
aud: params.appId,
|
|
7359
7367
|
sub: params.userId,
|
|
7360
7368
|
app: params.app,
|
|
7361
7369
|
scopes: params.scopes,
|
|
@@ -7363,7 +7371,7 @@ function createLocalFluentSession(params) {
|
|
|
7363
7371
|
};
|
|
7364
7372
|
return {
|
|
7365
7373
|
app: params.app,
|
|
7366
|
-
|
|
7374
|
+
appId: params.appId,
|
|
7367
7375
|
idToken: `mock.${btoa(JSON.stringify(payload))}.signature`,
|
|
7368
7376
|
user: {
|
|
7369
7377
|
id: params.userId,
|
|
@@ -10147,7 +10155,7 @@ function useHostedConnect(params) {
|
|
|
10147
10155
|
const {
|
|
10148
10156
|
fluentConnect,
|
|
10149
10157
|
authorizeUrl,
|
|
10150
|
-
|
|
10158
|
+
appId,
|
|
10151
10159
|
appName,
|
|
10152
10160
|
authMode,
|
|
10153
10161
|
setSession,
|
|
@@ -10169,10 +10177,10 @@ function useHostedConnect(params) {
|
|
|
10169
10177
|
} catch {
|
|
10170
10178
|
}
|
|
10171
10179
|
const url = fluentConnect.buildAuthorizeUrl(state).toString();
|
|
10172
|
-
debugLog("[fluent widget] open connect", { state, authorizeUrl: url,
|
|
10180
|
+
debugLog("[fluent widget] open connect", { state, authorizeUrl: url, appId, appName, authMode });
|
|
10173
10181
|
setHostedAuthorizeUrl(url);
|
|
10174
10182
|
setConnectOpen(true);
|
|
10175
|
-
}, [appName, authMode,
|
|
10183
|
+
}, [appName, authMode, appId, fluentConnect, setConnectOpen]);
|
|
10176
10184
|
const acceptHostedResult = useCallback(
|
|
10177
10185
|
(data) => {
|
|
10178
10186
|
if (!data || typeof data !== "object") return;
|
|
@@ -10323,12 +10331,12 @@ function useAccountMenu(params) {
|
|
|
10323
10331
|
return { openAccountMenu, handleAccountMenuAction };
|
|
10324
10332
|
}
|
|
10325
10333
|
function authTokenCacheKey(params) {
|
|
10326
|
-
return `${params.publicApiUrl}|${params.
|
|
10334
|
+
return `${params.publicApiUrl}|${params.appId}|${params.subject}`;
|
|
10327
10335
|
}
|
|
10328
10336
|
function useAuthToken(params) {
|
|
10329
10337
|
const {
|
|
10330
10338
|
publicApiUrl,
|
|
10331
|
-
|
|
10339
|
+
appId,
|
|
10332
10340
|
authMode,
|
|
10333
10341
|
renewalOffsetSeconds,
|
|
10334
10342
|
accountType,
|
|
@@ -10351,7 +10359,7 @@ function useAuthToken(params) {
|
|
|
10351
10359
|
if (!subject) {
|
|
10352
10360
|
throw new FluentAuthError("not_connected", "Connect a Fluent ID or an external wallet first.");
|
|
10353
10361
|
}
|
|
10354
|
-
const key = authTokenCacheKey({ publicApiUrl,
|
|
10362
|
+
const key = authTokenCacheKey({ publicApiUrl, appId, subject });
|
|
10355
10363
|
const cached = cache.current;
|
|
10356
10364
|
if (cached?.key === key && cached.expiresAt - renewalOffsetSeconds * 1e3 > Date.now()) {
|
|
10357
10365
|
return cached.token;
|
|
@@ -10367,14 +10375,14 @@ function useAuthToken(params) {
|
|
|
10367
10375
|
"Privy session is not ready; sign in again."
|
|
10368
10376
|
);
|
|
10369
10377
|
}
|
|
10370
|
-
token = await exchangePrivyAuthToken({ publicApiUrl,
|
|
10378
|
+
token = await exchangePrivyAuthToken({ publicApiUrl, appId, accessToken, identityToken });
|
|
10371
10379
|
} else {
|
|
10372
10380
|
if (!walletClient) {
|
|
10373
10381
|
throw new FluentAuthError("not_connected", "External wallet has no signer.");
|
|
10374
10382
|
}
|
|
10375
10383
|
token = await exchangeWalletAuthToken({
|
|
10376
10384
|
publicApiUrl,
|
|
10377
|
-
|
|
10385
|
+
appId,
|
|
10378
10386
|
walletClient,
|
|
10379
10387
|
address: walletAddress,
|
|
10380
10388
|
origin: window.location.origin
|
|
@@ -10394,7 +10402,7 @@ function useAuthToken(params) {
|
|
|
10394
10402
|
accountType,
|
|
10395
10403
|
authMode,
|
|
10396
10404
|
renewalOffsetSeconds,
|
|
10397
|
-
|
|
10405
|
+
appId,
|
|
10398
10406
|
getAccessToken,
|
|
10399
10407
|
identityToken,
|
|
10400
10408
|
privyUserId,
|
|
@@ -10793,7 +10801,7 @@ function FluentWidgetContent({
|
|
|
10793
10801
|
const resolvedConfig = useMemo(() => resolveFluentWidgetConfig(config), [config]);
|
|
10794
10802
|
const smartAccount = useFluentZeroDevAccount({
|
|
10795
10803
|
login: requestPrivyLogin,
|
|
10796
|
-
|
|
10804
|
+
appId: resolvedConfig.appId,
|
|
10797
10805
|
sponsorshipUrl: resolvedConfig.sponsorshipUrl
|
|
10798
10806
|
});
|
|
10799
10807
|
const { authenticated, getAccessToken, login, logout, ready: privyReady, user } = usePrivy();
|
|
@@ -10876,7 +10884,7 @@ function FluentWidgetContent({
|
|
|
10876
10884
|
const { hostedAuthorizeUrl, beginHostedConnect } = useHostedConnect({
|
|
10877
10885
|
fluentConnect,
|
|
10878
10886
|
authorizeUrl: resolvedConfig.authorizeUrl,
|
|
10879
|
-
|
|
10887
|
+
appId: resolvedConfig.appId,
|
|
10880
10888
|
appName: resolvedConfig.appName,
|
|
10881
10889
|
authMode: resolvedConfig.authMode,
|
|
10882
10890
|
setSession,
|
|
@@ -10996,7 +11004,7 @@ function FluentWidgetContent({
|
|
|
10996
11004
|
const app = fluentConnect.status().app;
|
|
10997
11005
|
const nextSession = createLocalFluentSession({
|
|
10998
11006
|
app,
|
|
10999
|
-
|
|
11007
|
+
appId: resolvedConfig.appId,
|
|
11000
11008
|
scopes: resolvedConfig.scopes,
|
|
11001
11009
|
userId: user.id,
|
|
11002
11010
|
email: typeof user.email?.address === "string" ? user.email.address : void 0,
|
|
@@ -11097,7 +11105,7 @@ function FluentWidgetContent({
|
|
|
11097
11105
|
});
|
|
11098
11106
|
const getAuthToken = useAuthToken({
|
|
11099
11107
|
publicApiUrl: resolvedConfig.publicApiUrl,
|
|
11100
|
-
|
|
11108
|
+
appId: resolvedConfig.appId,
|
|
11101
11109
|
authMode: resolvedConfig.authMode,
|
|
11102
11110
|
renewalOffsetSeconds: resolvedConfig.authTokenRenewalOffsetSeconds,
|
|
11103
11111
|
accountType: widgetAccount.type,
|