@fluent.xyz/connect 0.5.1 → 0.5.2
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/INTEGRATION.md +30 -2
- package/README.md +2 -1
- package/dist/index.js +40 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/INTEGRATION.md
CHANGED
|
@@ -33,7 +33,10 @@ Before writing code you need:
|
|
|
33
33
|
Required; the widget throws without it, and throws on any other shape.
|
|
34
34
|
2. **A Privy app client (`privyClientId`)** — the `client-…` value Fluent
|
|
35
35
|
issued alongside. Login configuration: your allowed origins live on it.
|
|
36
|
-
Required; the widget throws without it.
|
|
36
|
+
Required; the widget throws without it. The client is issued from the Privy
|
|
37
|
+
app of your network: the dev Privy app for `testnet`, the production Privy
|
|
38
|
+
app for `mainnet`, which Fluent hands out together with your production
|
|
39
|
+
`appId`. A client of one Privy app does not sign in on the other.
|
|
37
40
|
3. **A target network** — `testnet` (default) or `mainnet`.
|
|
38
41
|
4. **Your app's origin registered on that Privy app client** — Fluent's sign-in
|
|
39
42
|
dialog runs in your page, and Privy refuses an origin it does not know.
|
|
@@ -164,7 +167,7 @@ routing rather than mutating `config.network` under a live session.
|
|
|
164
167
|
| Field | Required | Default | Notes |
|
|
165
168
|
|---------------|----------|--------------------|-------|
|
|
166
169
|
| `appId` | ✅ | — | The App's `app_<32 hex>` id — identity for sponsorship, auth and analytics; the token `aud`. Asserted at startup. |
|
|
167
|
-
| `privyClientId` | ✅ | — | Privy app client issued by Fluent — login configuration; allowed origins live on it. |
|
|
170
|
+
| `privyClientId` | ✅ | — | Privy app client issued by Fluent — login configuration; allowed origins live on it. Issued from the Privy app of the App's network: the dev Privy app for `testnet`, the production Privy app for `mainnet`; a client of one does not sign in on the other. |
|
|
168
171
|
| `clientId` | ⛔ | — | Removed in 0.2.0, and still typed (as `never`) only so the error can name the fix: pass the App's id as `appId` and the Privy app client as `privyClientId`. Passing it throws at resolve time. |
|
|
169
172
|
| `partnerId` | ⛔ | — | Renamed to `appId` in 0.3.0, and still typed (as `never`) only so the error can name the fix. Passing it throws at resolve time. |
|
|
170
173
|
| `network` | ➖ | env → `"testnet"` | `"testnet"` or `"mainnet"` — see [Networks and chain ids](#networks-and-chain-ids). |
|
|
@@ -1344,6 +1347,31 @@ one source of wallet/account state, and you read it through `useFluentWidget()`.
|
|
|
1344
1347
|
> widget's), that's a separate architecture — shared providers / a single
|
|
1345
1348
|
> `WagmiProvider`. Not supported in phase 1; talk to the Fluent team.
|
|
1346
1349
|
|
|
1350
|
+
### Your own TanStack Query client
|
|
1351
|
+
|
|
1352
|
+
Mount a `QueryClientProvider` **around** `<FluentWidget>` and everything you
|
|
1353
|
+
render through `renderPage` / `renderHome` keeps resolving against *your* client:
|
|
1354
|
+
|
|
1355
|
+
```tsx
|
|
1356
|
+
<QueryClientProvider client={queryClient}> {/* yours */}
|
|
1357
|
+
<FluentWidget
|
|
1358
|
+
config={{ /* … */ }}
|
|
1359
|
+
mode="page"
|
|
1360
|
+
renderPage={() => <YourApp />} {/* useQueryClient() === queryClient */}
|
|
1361
|
+
/>
|
|
1362
|
+
</QueryClientProvider>
|
|
1363
|
+
```
|
|
1364
|
+
|
|
1365
|
+
So a query you prefetched, or hydrated from your own server render, is served
|
|
1366
|
+
from your cache instead of running a second time. There is no prop for it: the
|
|
1367
|
+
widget reads the client from the context above it.
|
|
1368
|
+
|
|
1369
|
+
The two caches stay separate. The widget's own queries stay on the widget's
|
|
1370
|
+
client, so a `defaultOptions` you set, an `invalidateQueries` or a `clear()` of
|
|
1371
|
+
yours does not reach them — and the widget's bridge queries do not appear in
|
|
1372
|
+
your devtools. Mount no client of your own and nothing changes: your pages
|
|
1373
|
+
resolve against the widget's, as before.
|
|
1374
|
+
|
|
1347
1375
|
---
|
|
1348
1376
|
|
|
1349
1377
|
## 9b. Debugging an integration
|
package/README.md
CHANGED
|
@@ -66,7 +66,8 @@ export function App() {
|
|
|
66
66
|
`appId` and `privyClientId` are both required and come from Fluent. `appId` is the
|
|
67
67
|
App's identity — sponsorship, auth and analytics speak it — and must be the `app_<32 hex>`
|
|
68
68
|
value the Fluent Dashboard shows; the widget throws on any other shape. `privyClientId` is
|
|
69
|
-
login configuration: the Privy app client carrying your allowed origins
|
|
69
|
+
login configuration: the Privy app client carrying your allowed origins, issued from the
|
|
70
|
+
dev Privy app for `testnet` and from the production Privy app for `mainnet`.
|
|
70
71
|
|
|
71
72
|
For Capacitor social login, pass
|
|
72
73
|
`customOAuthRedirectUrl: "https://app.example.com/auth/ios/callback"` in `config`.
|
package/dist/index.js
CHANGED
|
@@ -21,9 +21,9 @@ import { twMerge } from 'tailwind-merge';
|
|
|
21
21
|
import { Button as Button$1 } from '@base-ui/react/button';
|
|
22
22
|
import { cva } from 'class-variance-authority';
|
|
23
23
|
import { XIcon, Trash2, RefreshCw, X, ChevronLeft, ExternalLink, Copy, Settings, LogOut, Loader2, ChevronDownIcon, CheckIcon, AlertTriangle, Layers, Plus, Loader2Icon, ChevronUpIcon, CircleHelp, LogIn, Send, RotateCw, KeyRound, Mail, Wallet, Check, CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon } from 'lucide-react';
|
|
24
|
+
import { QueryClient, QueryClientContext, QueryClientProvider, useInfiniteQuery, useQuery } from '@tanstack/react-query';
|
|
24
25
|
import { WagmiAdapter } from '@reown/appkit-adapter-wagmi';
|
|
25
26
|
import { createAppKit, useAppKit } from '@reown/appkit/react';
|
|
26
|
-
import { QueryClient, QueryClientContext, QueryClientProvider, useInfiniteQuery, useQuery } from '@tanstack/react-query';
|
|
27
27
|
import { WagmiContext, WagmiProvider, useAccount, useDisconnect, useWalletClient, useSwitchChain, useConnect, usePublicClient, useBalance, useReadContract, useWriteContract, useWaitForTransactionReceipt } from 'wagmi';
|
|
28
28
|
import { hydrate } from '@wagmi/core';
|
|
29
29
|
import { reconnect } from 'wagmi/actions';
|
|
@@ -5295,7 +5295,8 @@ var FLUENT_WIDGET_USER_TOKENS_IMPORT_MARKER_KEY = "fluent:widget:tokens-import:v
|
|
|
5295
5295
|
var FLUENT_WIDGET_REFRESH_CREDENTIAL_STORAGE_PREFIX = "fluent:widget:refresh:v1";
|
|
5296
5296
|
|
|
5297
5297
|
// src/core/config.ts
|
|
5298
|
-
var
|
|
5298
|
+
var FLUENT_CONNECT_TESTNET_PRIVY_APP_ID = "cmi7li7v901yojv0dmtfuf0v4";
|
|
5299
|
+
var FLUENT_CONNECT_MAINNET_PRIVY_APP_ID = "cmig3bvhd005hkz0c2q8vdg3s";
|
|
5299
5300
|
var FLUENT_CONNECT_REOWN_PROJECT_ID = "fbf7578f67b4a34e5101051131829ac0";
|
|
5300
5301
|
var FLUENT_CONNECT_TESTNET_ZERODEV_PROJECT_ID = "893acc63-da39-4b57-8789-5784ed7f1969";
|
|
5301
5302
|
var FLUENT_CONNECT_MAINNET_ZERODEV_PROJECT_ID = "216ca7d9-2b97-4894-ac23-7aa6a287dd97";
|
|
@@ -5351,6 +5352,13 @@ var FLUENT_CONNECT_ZERODEV_PROJECT_IDS = {
|
|
|
5351
5352
|
function getFluentZeroDevProjectId(network) {
|
|
5352
5353
|
return FLUENT_CONNECT_ZERODEV_PROJECT_IDS[network];
|
|
5353
5354
|
}
|
|
5355
|
+
var FLUENT_CONNECT_PRIVY_APP_IDS = {
|
|
5356
|
+
testnet: FLUENT_CONNECT_TESTNET_PRIVY_APP_ID,
|
|
5357
|
+
mainnet: FLUENT_CONNECT_MAINNET_PRIVY_APP_ID
|
|
5358
|
+
};
|
|
5359
|
+
function getFluentPrivyAppId(network) {
|
|
5360
|
+
return FLUENT_CONNECT_PRIVY_APP_IDS[network];
|
|
5361
|
+
}
|
|
5354
5362
|
var FLUENT_CONNECT_DEFAULT_ASSETS = {
|
|
5355
5363
|
fluentLogo: FLUENT_CONNECT_BUNDLED_ASSETS.fluentLogo,
|
|
5356
5364
|
walletConnectIcon: FLUENT_CONNECT_BUNDLED_ASSETS.walletConnectIcon,
|
|
@@ -9678,7 +9686,7 @@ function useFluentIframeBridge(iframeRef, { allowedOrigin }) {
|
|
|
9678
9686
|
}
|
|
9679
9687
|
|
|
9680
9688
|
// package.json
|
|
9681
|
-
var version = "0.5.
|
|
9689
|
+
var version = "0.5.2";
|
|
9682
9690
|
|
|
9683
9691
|
// src/core/analytics.ts
|
|
9684
9692
|
var INSTANCE_NAME = "fluent";
|
|
@@ -18315,7 +18323,8 @@ function FluentWidgetContent({
|
|
|
18315
18323
|
handledInlineLoginRequest,
|
|
18316
18324
|
authTokenState,
|
|
18317
18325
|
userSettingsRef,
|
|
18318
|
-
connectedPresentation
|
|
18326
|
+
connectedPresentation,
|
|
18327
|
+
appQueryClient
|
|
18319
18328
|
}) {
|
|
18320
18329
|
const internalWallet = useReownWallet();
|
|
18321
18330
|
const isMobile = useIsMobile();
|
|
@@ -18508,13 +18517,23 @@ function FluentWidgetContent({
|
|
|
18508
18517
|
commitSilentSigningEnabled(FLUENT_CONNECT_DEFAULT_SILENT_SIGNING);
|
|
18509
18518
|
connectedPresentation.current.connected = null;
|
|
18510
18519
|
connectedPresentation.current.rebuilding = null;
|
|
18511
|
-
clearPrivyRecentLoginMethod(
|
|
18520
|
+
clearPrivyRecentLoginMethod(getFluentPrivyAppId(resolvedConfig.network));
|
|
18512
18521
|
if (activeWallet?.connected) activeWallet.disconnect();
|
|
18513
18522
|
} finally {
|
|
18514
18523
|
disconnectingRef.current = false;
|
|
18515
18524
|
}
|
|
18516
18525
|
if (awaitAuthSession) await authSessionEnded;
|
|
18517
|
-
}, [
|
|
18526
|
+
}, [
|
|
18527
|
+
activeWallet,
|
|
18528
|
+
authenticated,
|
|
18529
|
+
commitSilentSigningEnabled,
|
|
18530
|
+
connectedPresentation,
|
|
18531
|
+
fluentConnect,
|
|
18532
|
+
logout,
|
|
18533
|
+
resolvedConfig.network,
|
|
18534
|
+
setDirectAuthRequested,
|
|
18535
|
+
setSession
|
|
18536
|
+
]);
|
|
18518
18537
|
const requestDisconnect = useCallback(() => {
|
|
18519
18538
|
track("wallet_disconnected");
|
|
18520
18539
|
return handleDisconnect({ awaitAuthSession: true });
|
|
@@ -19281,6 +19300,11 @@ function FluentWidgetContent({
|
|
|
19281
19300
|
linkX
|
|
19282
19301
|
]
|
|
19283
19302
|
);
|
|
19303
|
+
const appPage = (() => {
|
|
19304
|
+
const page = mode === "page" ? renderPage?.(context) : renderHome?.(context);
|
|
19305
|
+
if (!appQueryClient) return page;
|
|
19306
|
+
return /* @__PURE__ */ jsx(QueryClientProvider, { client: appQueryClient, children: page });
|
|
19307
|
+
})();
|
|
19284
19308
|
const widget = /* @__PURE__ */ jsxs(FluentPortalContainerProvider, { children: [
|
|
19285
19309
|
/* @__PURE__ */ jsx(FluentTopLayerBridge, {}),
|
|
19286
19310
|
!session && connectedWalletAddress !== void 0 ? /* @__PURE__ */ jsx(LinkXSiweSource, { source: linkXSiwe }) : null,
|
|
@@ -19375,7 +19399,7 @@ function FluentWidgetContent({
|
|
|
19375
19399
|
)
|
|
19376
19400
|
}
|
|
19377
19401
|
) }),
|
|
19378
|
-
/* @__PURE__ */ jsx(FluentWidgetProvider, { value: context, children:
|
|
19402
|
+
/* @__PURE__ */ jsx(FluentWidgetProvider, { value: context, children: appPage }),
|
|
19379
19403
|
/* @__PURE__ */ jsxs("div", { className: WIDGET_STYLE_SCOPE, children: [
|
|
19380
19404
|
showDebugPayload && mode === "home" ? /* @__PURE__ */ jsx(
|
|
19381
19405
|
DebugPanel,
|
|
@@ -19442,6 +19466,7 @@ function LinkXSiweSource({
|
|
|
19442
19466
|
var SILENT_SIGNING_REMOUNT_MS = 220;
|
|
19443
19467
|
function FluentWidget(props) {
|
|
19444
19468
|
setDebugLogging(props.debugLogging ?? false);
|
|
19469
|
+
const appQueryClient = useContext(QueryClientContext);
|
|
19445
19470
|
const resolvedConfig = useMemo(
|
|
19446
19471
|
() => resolveFluentWidgetConfig(props.config),
|
|
19447
19472
|
[props.config]
|
|
@@ -19467,6 +19492,7 @@ function FluentWidget(props) {
|
|
|
19467
19492
|
);
|
|
19468
19493
|
const resolvedNetwork = resolvedConfig.network;
|
|
19469
19494
|
const privyClientId = resolvedConfig.privyClientId;
|
|
19495
|
+
const privyAppId = getFluentPrivyAppId(resolvedNetwork);
|
|
19470
19496
|
const analyticsContext = useRef({});
|
|
19471
19497
|
const externalWallet = useRef({ intent: false, connected: false });
|
|
19472
19498
|
const track = useMemo(
|
|
@@ -19573,8 +19599,8 @@ function FluentWidget(props) {
|
|
|
19573
19599
|
]
|
|
19574
19600
|
);
|
|
19575
19601
|
useLayoutEffect(() => {
|
|
19576
|
-
clearPrivyRecentLoginMethod(
|
|
19577
|
-
}, []);
|
|
19602
|
+
clearPrivyRecentLoginMethod(privyAppId);
|
|
19603
|
+
}, [privyAppId]);
|
|
19578
19604
|
const applySilentSigningEnabled = useCallback((enabled) => {
|
|
19579
19605
|
setSilentSigningEnabled(enabled);
|
|
19580
19606
|
}, []);
|
|
@@ -19603,9 +19629,9 @@ function FluentWidget(props) {
|
|
|
19603
19629
|
[applySilentSigningEnabled]
|
|
19604
19630
|
);
|
|
19605
19631
|
const requestPrivyLogin = useCallback(() => {
|
|
19606
|
-
clearPrivyRecentLoginMethod(
|
|
19632
|
+
clearPrivyRecentLoginMethod(privyAppId);
|
|
19607
19633
|
setInlineLoginRequest((value) => value + 1);
|
|
19608
|
-
}, []);
|
|
19634
|
+
}, [privyAppId]);
|
|
19609
19635
|
useEffect(() => {
|
|
19610
19636
|
return () => {
|
|
19611
19637
|
if (silentSigningRemountTimer.current) {
|
|
@@ -19624,7 +19650,7 @@ function FluentWidget(props) {
|
|
|
19624
19650
|
FluentPrivyProvider,
|
|
19625
19651
|
{
|
|
19626
19652
|
adapter: props.privyAdapter,
|
|
19627
|
-
appId:
|
|
19653
|
+
appId: privyAppId,
|
|
19628
19654
|
clientId: privyClientId,
|
|
19629
19655
|
config: privyConfig,
|
|
19630
19656
|
children: /* @__PURE__ */ jsx(
|
|
@@ -19649,7 +19675,8 @@ function FluentWidget(props) {
|
|
|
19649
19675
|
handledInlineLoginRequest,
|
|
19650
19676
|
authTokenState,
|
|
19651
19677
|
userSettingsRef: userSettings,
|
|
19652
|
-
connectedPresentation
|
|
19678
|
+
connectedPresentation,
|
|
19679
|
+
appQueryClient
|
|
19653
19680
|
}
|
|
19654
19681
|
)
|
|
19655
19682
|
},
|