thirdweb 5.65.2 → 5.66.0-nightly-880c3453ee8fc0fabbde0afb752a17894cd579a0-20241106000325
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/cjs/exports/react.js +4 -1
- package/dist/cjs/exports/react.js.map +1 -1
- package/dist/cjs/react/core/hooks/contract/useContractEvents.js +1 -1
- package/dist/cjs/react/core/hooks/contract/useContractEvents.js.map +1 -1
- package/dist/cjs/react/core/hooks/wallets/useAutoConnect.js +19 -2
- package/dist/cjs/react/core/hooks/wallets/useAutoConnect.js.map +1 -1
- package/dist/cjs/react/native/ui/connect/ConnectModal.js.map +1 -1
- package/dist/cjs/react/native/ui/connect/ConnectedModal.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/Details.js.map +1 -1
- package/dist/cjs/react/web/ui/MediaRenderer/ModelViewer.js +3 -1
- package/dist/cjs/react/web/ui/MediaRenderer/ModelViewer.js.map +1 -1
- package/dist/cjs/react/web/ui/SiteEmbed.js +63 -0
- package/dist/cjs/react/web/ui/SiteEmbed.js.map +1 -0
- package/dist/cjs/react/web/wallets/in-app/WalletAuth.js +1 -1
- package/dist/cjs/react/web/wallets/in-app/WalletAuth.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/lib/get-url-token.js +10 -4
- package/dist/cjs/wallets/in-app/web/lib/get-url-token.js.map +1 -1
- package/dist/esm/exports/react.js +2 -0
- package/dist/esm/exports/react.js.map +1 -1
- package/dist/esm/react/core/hooks/contract/useContractEvents.js +1 -1
- package/dist/esm/react/core/hooks/contract/useContractEvents.js.map +1 -1
- package/dist/esm/react/core/hooks/wallets/useAutoConnect.js +19 -2
- package/dist/esm/react/core/hooks/wallets/useAutoConnect.js.map +1 -1
- package/dist/esm/react/native/ui/connect/ConnectModal.js.map +1 -1
- package/dist/esm/react/native/ui/connect/ConnectedModal.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/Details.js.map +1 -1
- package/dist/esm/react/web/ui/MediaRenderer/ModelViewer.js +3 -1
- package/dist/esm/react/web/ui/MediaRenderer/ModelViewer.js.map +1 -1
- package/dist/esm/react/web/ui/SiteEmbed.js +60 -0
- package/dist/esm/react/web/ui/SiteEmbed.js.map +1 -0
- package/dist/esm/react/web/wallets/in-app/WalletAuth.js +1 -1
- package/dist/esm/react/web/wallets/in-app/WalletAuth.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/wallets/in-app/web/lib/get-url-token.js +10 -4
- package/dist/esm/wallets/in-app/web/lib/get-url-token.js.map +1 -1
- package/dist/types/exports/react.d.ts +1 -0
- package/dist/types/exports/react.d.ts.map +1 -1
- package/dist/types/react/core/hooks/connection/ConnectButtonProps.d.ts +1 -0
- package/dist/types/react/core/hooks/connection/ConnectButtonProps.d.ts.map +1 -1
- package/dist/types/react/core/hooks/wallets/useAutoConnect.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/Details.d.ts +1 -0
- package/dist/types/react/web/ui/ConnectWallet/Details.d.ts.map +1 -1
- package/dist/types/react/web/ui/MediaRenderer/ModelViewer.d.ts +0 -8
- package/dist/types/react/web/ui/MediaRenderer/ModelViewer.d.ts.map +1 -1
- package/dist/types/react/web/ui/SiteEmbed.d.ts +27 -0
- package/dist/types/react/web/ui/SiteEmbed.d.ts.map +1 -0
- package/dist/types/react/web/ui/components/Drawer.d.ts +2 -2
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/lib/get-url-token.d.ts +1 -0
- package/dist/types/wallets/in-app/web/lib/get-url-token.d.ts.map +1 -1
- package/package.json +29 -29
- package/src/exports/react.ts +3 -0
- package/src/react/core/hooks/connection/ConnectButtonProps.ts +1 -0
- package/src/react/core/hooks/contract/useContractEvents.ts +1 -1
- package/src/react/core/hooks/wallets/useAutoConnect.ts +21 -2
- package/src/react/native/ui/connect/ConnectModal.tsx +1 -1
- package/src/react/native/ui/connect/ConnectedModal.tsx +1 -1
- package/src/react/web/ui/ConnectWallet/Details.tsx +1 -1
- package/src/react/web/ui/MediaRenderer/ModelViewer.tsx +1 -9
- package/src/react/web/ui/SiteEmbed.test.tsx +39 -0
- package/src/react/web/ui/SiteEmbed.tsx +90 -0
- package/src/react/web/wallets/in-app/WalletAuth.tsx +1 -1
- package/src/version.ts +1 -1
- package/src/wallets/in-app/web/lib/get-url-token.ts +11 -4
@@ -1,14 +1,6 @@
|
|
1
1
|
import "@google/model-viewer";
|
2
|
-
import type { ModelViewerElement } from "@google/model-viewer";
|
3
2
|
import React from "react";
|
4
3
|
import type { MediaRendererProps } from "./types.js";
|
5
|
-
declare global {
|
6
|
-
namespace JSX {
|
7
|
-
interface IntrinsicElements {
|
8
|
-
"model-viewer": Partial<ModelViewerElement>;
|
9
|
-
}
|
10
|
-
}
|
11
|
-
}
|
12
4
|
declare const ModelViewer: React.ForwardRefExoticComponent<Pick<MediaRendererProps, "src" | "style" | "alt" | "className" | "poster"> & React.RefAttributes<HTMLDivElement>>;
|
13
5
|
export default ModelViewer;
|
14
6
|
//# sourceMappingURL=ModelViewer.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ModelViewer.d.ts","sourceRoot":"","sources":["../../../../../../src/react/web/ui/MediaRenderer/ModelViewer.tsx"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,
|
1
|
+
{"version":3,"file":"ModelViewer.d.ts","sourceRoot":"","sources":["../../../../../../src/react/web/ui/MediaRenderer/ModelViewer.tsx"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,QAAA,MAAM,WAAW,mJAmBV,CAAC;AAER,eAAe,WAAW,CAAC"}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import type { ThirdwebClient } from "../../../client/client.js";
|
2
|
+
import type { Ecosystem } from "../../../wallets/in-app/core/wallet/types.js";
|
3
|
+
/**
|
4
|
+
* Embeds another thirdweb-supported site for seamless in-app and ecosystem wallet connection.
|
5
|
+
*
|
6
|
+
* @note Make sure the embedded site includes <AutoConnect /> and supports frame ancestors, see [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors) for more information.
|
7
|
+
*
|
8
|
+
* @note The embedded site must support the connected wallet (ecosystem or in-app).
|
9
|
+
*
|
10
|
+
* @param {Object} props - The props to pass to the iframe
|
11
|
+
* @param {String} props.src - The URL of the site to embed
|
12
|
+
* @param {ThirdwebClient} props.client - The client to use for the embedded site
|
13
|
+
* @param {Ecosystem} [props.ecosystem] - The ecosystem to use for the embedded site
|
14
|
+
*
|
15
|
+
* @example
|
16
|
+
* ```tsx
|
17
|
+
* import { SiteEmbed } from "thirdweb/react";
|
18
|
+
*
|
19
|
+
* <SiteEmbed src="https://thirdweb.com" clientId="thirdweb-client-id" />
|
20
|
+
* ```
|
21
|
+
*/
|
22
|
+
export declare function SiteEmbed({ src, client, ecosystem, ...props }: {
|
23
|
+
src: string;
|
24
|
+
client: ThirdwebClient;
|
25
|
+
ecosystem?: Ecosystem;
|
26
|
+
} & React.DetailedHTMLProps<React.IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>): import("react/jsx-runtime.js").JSX.Element;
|
27
|
+
//# sourceMappingURL=SiteEmbed.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"SiteEmbed.d.ts","sourceRoot":"","sources":["../../../../../src/react/web/ui/SiteEmbed.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAKhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8CAA8C,CAAC;AAG9E;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CAAC,EACxB,GAAG,EACH,MAAM,EACN,SAAS,EACT,GAAG,KAAK,EACT,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,GAAG,KAAK,CAAC,iBAAiB,CACzB,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAC7C,iBAAiB,CAClB,8CAgDA"}
|
@@ -16,8 +16,8 @@ export declare const DrawerOverlay: import("@emotion/styled").StyledComponent<{
|
|
16
16
|
* @internal
|
17
17
|
*/
|
18
18
|
export declare function useDrawer(): {
|
19
|
-
drawerRef: import("react").RefObject<HTMLDivElement>;
|
20
|
-
drawerOverlayRef: import("react").RefObject<HTMLDivElement>;
|
19
|
+
drawerRef: import("react").RefObject<HTMLDivElement | null>;
|
20
|
+
drawerOverlayRef: import("react").RefObject<HTMLDivElement | null>;
|
21
21
|
setIsOpen: (value: boolean) => Promise<void>;
|
22
22
|
isOpen: boolean;
|
23
23
|
};
|
package/dist/types/version.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const version = "5.
|
1
|
+
export declare const version = "5.66.0-nightly-880c3453ee8fc0fabbde0afb752a17894cd579a0-20241106000325";
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,2EAA2E,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"get-url-token.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/web/lib/get-url-token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oCAAoC,CAAC;AAE9F;;GAEG;AACH,wBAAgB,WAAW,IAAI;IAC7B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,mCAAmC,CAAC;IACjD,YAAY,CAAC,EAAE,UAAU,CAAC;
|
1
|
+
{"version":3,"file":"get-url-token.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/web/lib/get-url-token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oCAAoC,CAAC;AAE9F;;GAEG;AACH,wBAAgB,WAAW,IAAI;IAC7B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,mCAAmC,CAAC;IACjD,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CA+BA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "thirdweb",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.66.0-nightly-880c3453ee8fc0fabbde0afb752a17894cd579a0-20241106000325",
|
4
4
|
"repository": {
|
5
5
|
"type": "git",
|
6
6
|
"url": "git+https://github.com/thirdweb-dev/js.git#main"
|
@@ -199,7 +199,7 @@
|
|
199
199
|
"!tsconfig.build.json"
|
200
200
|
],
|
201
201
|
"dependencies": {
|
202
|
-
"@coinbase/wallet-sdk": "4.
|
202
|
+
"@coinbase/wallet-sdk": "4.2.0",
|
203
203
|
"@emotion/react": "11.13.3",
|
204
204
|
"@emotion/styled": "11.13.0",
|
205
205
|
"@google/model-viewer": "2.1.1",
|
@@ -208,17 +208,17 @@
|
|
208
208
|
"@passwordless-id/webauthn": "^1.6.1",
|
209
209
|
"@radix-ui/react-dialog": "1.1.2",
|
210
210
|
"@radix-ui/react-focus-scope": "1.1.0",
|
211
|
-
"@radix-ui/react-icons": "1.3.
|
211
|
+
"@radix-ui/react-icons": "1.3.1",
|
212
212
|
"@radix-ui/react-tooltip": "1.1.3",
|
213
|
-
"@tanstack/react-query": "5.59.
|
213
|
+
"@tanstack/react-query": "5.59.19",
|
214
214
|
"@walletconnect/ethereum-provider": "2.17.1",
|
215
215
|
"@walletconnect/sign-client": "2.17.1",
|
216
216
|
"abitype": "1.0.6",
|
217
217
|
"fuse.js": "7.0.0",
|
218
|
-
"input-otp": "^1.
|
218
|
+
"input-otp": "^1.4.1",
|
219
219
|
"mipd": "0.0.7",
|
220
220
|
"uqr": "0.1.2",
|
221
|
-
"viem": "2.21.
|
221
|
+
"viem": "2.21.40"
|
222
222
|
},
|
223
223
|
"peerDependencies": {
|
224
224
|
"@aws-sdk/client-lambda": "^3",
|
@@ -290,28 +290,28 @@
|
|
290
290
|
"node": ">=18"
|
291
291
|
},
|
292
292
|
"devDependencies": {
|
293
|
-
"@aws-sdk/client-kms": "3.
|
294
|
-
"@aws-sdk/client-lambda": "3.
|
295
|
-
"@aws-sdk/credential-providers": "3.
|
293
|
+
"@aws-sdk/client-kms": "3.682.0",
|
294
|
+
"@aws-sdk/client-lambda": "3.682.0",
|
295
|
+
"@aws-sdk/credential-providers": "3.685.0",
|
296
296
|
"@biomejs/biome": "1.9.4",
|
297
|
-
"@chromatic-com/storybook": "2.
|
297
|
+
"@chromatic-com/storybook": "3.2.2",
|
298
298
|
"@codspeed/vitest-plugin": "3.1.1",
|
299
299
|
"@coinbase/wallet-mobile-sdk": "1.1.2",
|
300
|
-
"@mobile-wallet-protocol/client": "0.1.
|
300
|
+
"@mobile-wallet-protocol/client": "0.1.2",
|
301
301
|
"@react-native-async-storage/async-storage": "2.0.0",
|
302
302
|
"@size-limit/preset-big-lib": "11.1.6",
|
303
|
-
"@storybook/addon-essentials": "8.
|
304
|
-
"@storybook/addon-interactions": "8.
|
305
|
-
"@storybook/addon-links": "8.
|
306
|
-
"@storybook/addon-onboarding": "8.
|
307
|
-
"@storybook/react": "8.
|
308
|
-
"@storybook/react-vite": "8.
|
309
|
-
"@storybook/test": "8.
|
310
|
-
"@testing-library/jest-dom": "^6.
|
303
|
+
"@storybook/addon-essentials": "8.4.2",
|
304
|
+
"@storybook/addon-interactions": "8.4.2",
|
305
|
+
"@storybook/addon-links": "8.4.2",
|
306
|
+
"@storybook/addon-onboarding": "8.4.2",
|
307
|
+
"@storybook/react": "8.4.2",
|
308
|
+
"@storybook/react-vite": "8.4.2",
|
309
|
+
"@storybook/test": "8.4.2",
|
310
|
+
"@testing-library/jest-dom": "^6.6.3",
|
311
311
|
"@testing-library/react": "^16.0.0",
|
312
312
|
"@testing-library/user-event": "^14.5.2",
|
313
313
|
"@types/cross-spawn": "^6.0.6",
|
314
|
-
"@types/react": "
|
314
|
+
"@types/react": "npm:types-react@19.0.0-rc.1",
|
315
315
|
"@viem/anvil": "0.0.10",
|
316
316
|
"@vitejs/plugin-react": "^4.3.3",
|
317
317
|
"@vitest/coverage-v8": "2.1.4",
|
@@ -322,21 +322,21 @@
|
|
322
322
|
"ethers6": "npm:ethers@6",
|
323
323
|
"expo-linking": "6.3.1",
|
324
324
|
"expo-web-browser": "13.0.3",
|
325
|
-
"happy-dom": "^15.
|
326
|
-
"knip": "5.
|
327
|
-
"msw": "^2.
|
325
|
+
"happy-dom": "^15.9.0",
|
326
|
+
"knip": "5.36.2",
|
327
|
+
"msw": "^2.6.0",
|
328
328
|
"prettier": "^3.3.2",
|
329
|
-
"react": "
|
330
|
-
"react-native": "0.76.
|
329
|
+
"react": "19.0.0-rc-69d4b800-20241021",
|
330
|
+
"react-native": "0.76.1",
|
331
331
|
"react-native-aes-gcm-crypto": "0.2.2",
|
332
|
-
"react-native-passkey": "3.0.0
|
333
|
-
"react-native-quick-crypto": "0.7.
|
332
|
+
"react-native-passkey": "3.0.0",
|
333
|
+
"react-native-quick-crypto": "0.7.6",
|
334
334
|
"react-native-svg": "15.8.0",
|
335
335
|
"rimraf": "6.0.1",
|
336
336
|
"sharp": "^0.33.5",
|
337
337
|
"size-limit": "11.1.6",
|
338
|
-
"storybook": "8.
|
339
|
-
"typedoc": "0.26.
|
338
|
+
"storybook": "8.4.2",
|
339
|
+
"typedoc": "0.26.11",
|
340
340
|
"typescript": "5.6.3",
|
341
341
|
"vite": "5.4.10",
|
342
342
|
"vitest": "2.1.4"
|
package/src/exports/react.ts
CHANGED
@@ -84,7 +84,7 @@ export function useContractEvents<
|
|
84
84
|
enabled = true,
|
85
85
|
watch = true,
|
86
86
|
} = options;
|
87
|
-
const latestBlockNumber = useRef<bigint>(); // We use this to keep track of the latest block number when new pollers are spawned
|
87
|
+
const latestBlockNumber = useRef<bigint>(undefined); // We use this to keep track of the latest block number when new pollers are spawned
|
88
88
|
|
89
89
|
const queryClient = useQueryClient();
|
90
90
|
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
import { useQuery } from "@tanstack/react-query";
|
4
4
|
import type { AsyncStorage } from "../../../../utils/storage/AsyncStorage.js";
|
5
|
+
import { isEcosystemWallet } from "../../../../wallets/ecosystem/is-ecosystem-wallet.js";
|
6
|
+
import { ClientScopedStorage } from "../../../../wallets/in-app/core/authentication/client-scoped-storage.js";
|
5
7
|
import { getUrlToken } from "../../../../wallets/in-app/web/lib/get-url-token.js";
|
6
8
|
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
7
9
|
import {
|
@@ -43,8 +45,25 @@ export function useAutoConnectCore(
|
|
43
45
|
getStoredActiveWalletId(storage),
|
44
46
|
]);
|
45
47
|
|
46
|
-
const { authResult, walletId, authProvider } = getUrlToken();
|
47
|
-
|
48
|
+
const { authResult, walletId, authProvider, authCookie } = getUrlToken();
|
49
|
+
const wallet = wallets.find((w) => w.id === walletId);
|
50
|
+
|
51
|
+
// If an auth cookie is found and this site supports the wallet, we'll set the auth cookie in the client storage
|
52
|
+
if (authCookie && wallet) {
|
53
|
+
const clientStorage = new ClientScopedStorage({
|
54
|
+
storage,
|
55
|
+
clientId: props.client.clientId,
|
56
|
+
ecosystem: isEcosystemWallet(wallet)
|
57
|
+
? {
|
58
|
+
id: wallet.id,
|
59
|
+
partnerId: wallet.getConfig()?.partnerId,
|
60
|
+
}
|
61
|
+
: undefined,
|
62
|
+
});
|
63
|
+
await clientStorage.saveAuthCookie(authCookie);
|
64
|
+
}
|
65
|
+
|
66
|
+
if (walletId) {
|
48
67
|
lastActiveWalletId = walletId;
|
49
68
|
lastConnectedWalletIds = lastConnectedWalletIds?.includes(walletId)
|
50
69
|
? lastConnectedWalletIds
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { useEffect, useState } from "react";
|
1
|
+
import { type JSX, useEffect, useState } from "react";
|
2
2
|
import { Linking, StyleSheet, TouchableOpacity, View } from "react-native";
|
3
3
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
4
4
|
import { getContract } from "../../../../contract/contract.js";
|
@@ -9,7 +9,7 @@ import {
|
|
9
9
|
TextAlignJustifyIcon,
|
10
10
|
} from "@radix-ui/react-icons";
|
11
11
|
import { useQuery } from "@tanstack/react-query";
|
12
|
-
import { useContext, useEffect, useState } from "react";
|
12
|
+
import { type JSX, useContext, useEffect, useState } from "react";
|
13
13
|
import { trackPayEvent } from "../../../../analytics/track/pay.js";
|
14
14
|
import type { Chain } from "../../../../chains/types.js";
|
15
15
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
@@ -1,16 +1,7 @@
|
|
1
1
|
import "@google/model-viewer";
|
2
|
-
import type { ModelViewerElement } from "@google/model-viewer";
|
3
2
|
import React from "react";
|
4
3
|
import type { MediaRendererProps } from "./types.js";
|
5
4
|
|
6
|
-
declare global {
|
7
|
-
namespace JSX {
|
8
|
-
interface IntrinsicElements {
|
9
|
-
"model-viewer": Partial<ModelViewerElement>;
|
10
|
-
}
|
11
|
-
}
|
12
|
-
}
|
13
|
-
|
14
5
|
const ModelViewer = /* @__PURE__ */ (() =>
|
15
6
|
React.forwardRef<
|
16
7
|
HTMLDivElement,
|
@@ -19,6 +10,7 @@ const ModelViewer = /* @__PURE__ */ (() =>
|
|
19
10
|
return (
|
20
11
|
<div style={{ ...style }} className={className} ref={ref}>
|
21
12
|
{src ? (
|
13
|
+
// @ts-expect-error - model-viewer is not a standard HTML element
|
22
14
|
<model-viewer
|
23
15
|
src={src}
|
24
16
|
alt={alt || "3D Model"}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
2
|
+
import { render, waitFor } from "../../../../test/src/react-render.js";
|
3
|
+
import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
|
4
|
+
import { SiteEmbed } from "./SiteEmbed.js";
|
5
|
+
|
6
|
+
describe("SiteEmbed", () => {
|
7
|
+
it("renders iframe with correct src", () => {
|
8
|
+
const testUrl = "https://example.com/";
|
9
|
+
const { container } = render(
|
10
|
+
<SiteEmbed src={testUrl} client={TEST_CLIENT} />,
|
11
|
+
);
|
12
|
+
|
13
|
+
const iframe = container.querySelector("iframe");
|
14
|
+
expect(iframe).toBeTruthy();
|
15
|
+
expect(iframe?.src).toBe(testUrl);
|
16
|
+
});
|
17
|
+
|
18
|
+
it("throws error if clientId is not provided", () => {
|
19
|
+
const testUrl = "https://example.com/";
|
20
|
+
expect(() =>
|
21
|
+
// biome-ignore lint/suspicious/noExplicitAny: testing invalid input
|
22
|
+
render(<SiteEmbed src={testUrl} client={{} as any} />),
|
23
|
+
).toThrow("The SiteEmbed client must have a clientId");
|
24
|
+
});
|
25
|
+
|
26
|
+
it("adds wallet params to url when wallet is connected", async () => {
|
27
|
+
const testUrl = "https://example.com/";
|
28
|
+
const { container } = render(
|
29
|
+
<SiteEmbed src={testUrl} client={TEST_CLIENT} />,
|
30
|
+
{
|
31
|
+
setConnectedWallet: true,
|
32
|
+
},
|
33
|
+
);
|
34
|
+
|
35
|
+
const iframe = container.querySelector("iframe");
|
36
|
+
expect(iframe).toBeTruthy();
|
37
|
+
await waitFor(() => expect(iframe?.src).toContain("walletId="));
|
38
|
+
});
|
39
|
+
});
|
@@ -0,0 +1,90 @@
|
|
1
|
+
"use client";
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
3
|
+
import type { ThirdwebClient } from "../../../client/client.js";
|
4
|
+
import { getLastAuthProvider } from "../../../react/core/utils/storage.js";
|
5
|
+
import { webLocalStorage } from "../../../utils/storage/webStorage.js";
|
6
|
+
import { isEcosystemWallet } from "../../../wallets/ecosystem/is-ecosystem-wallet.js";
|
7
|
+
import { ClientScopedStorage } from "../../../wallets/in-app/core/authentication/client-scoped-storage.js";
|
8
|
+
import type { Ecosystem } from "../../../wallets/in-app/core/wallet/types.js";
|
9
|
+
import { useActiveWallet } from "../../core/hooks/wallets/useActiveWallet.js";
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Embeds another thirdweb-supported site for seamless in-app and ecosystem wallet connection.
|
13
|
+
*
|
14
|
+
* @note Make sure the embedded site includes <AutoConnect /> and supports frame ancestors, see [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors) for more information.
|
15
|
+
*
|
16
|
+
* @note The embedded site must support the connected wallet (ecosystem or in-app).
|
17
|
+
*
|
18
|
+
* @param {Object} props - The props to pass to the iframe
|
19
|
+
* @param {String} props.src - The URL of the site to embed
|
20
|
+
* @param {ThirdwebClient} props.client - The client to use for the embedded site
|
21
|
+
* @param {Ecosystem} [props.ecosystem] - The ecosystem to use for the embedded site
|
22
|
+
*
|
23
|
+
* @example
|
24
|
+
* ```tsx
|
25
|
+
* import { SiteEmbed } from "thirdweb/react";
|
26
|
+
*
|
27
|
+
* <SiteEmbed src="https://thirdweb.com" clientId="thirdweb-client-id" />
|
28
|
+
* ```
|
29
|
+
*/
|
30
|
+
export function SiteEmbed({
|
31
|
+
src,
|
32
|
+
client,
|
33
|
+
ecosystem,
|
34
|
+
...props
|
35
|
+
}: {
|
36
|
+
src: string;
|
37
|
+
client: ThirdwebClient;
|
38
|
+
ecosystem?: Ecosystem;
|
39
|
+
} & React.DetailedHTMLProps<
|
40
|
+
React.IframeHTMLAttributes<HTMLIFrameElement>,
|
41
|
+
HTMLIFrameElement
|
42
|
+
>) {
|
43
|
+
if (!client.clientId) {
|
44
|
+
throw new Error("The SiteEmbed client must have a clientId");
|
45
|
+
}
|
46
|
+
|
47
|
+
const activeWallet = useActiveWallet();
|
48
|
+
const walletId = activeWallet?.id;
|
49
|
+
|
50
|
+
const {
|
51
|
+
data: { authProvider, authCookie } = {},
|
52
|
+
} = useQuery({
|
53
|
+
queryKey: ["site-embed", walletId, src, client.clientId, ecosystem],
|
54
|
+
enabled:
|
55
|
+
activeWallet && (isEcosystemWallet(activeWallet) || walletId === "inApp"),
|
56
|
+
queryFn: async () => {
|
57
|
+
const storage = new ClientScopedStorage({
|
58
|
+
storage: webLocalStorage,
|
59
|
+
clientId: client.clientId,
|
60
|
+
ecosystem,
|
61
|
+
});
|
62
|
+
|
63
|
+
const authProvider = await getLastAuthProvider(webLocalStorage);
|
64
|
+
const authCookie = await storage.getAuthCookie();
|
65
|
+
|
66
|
+
return { authProvider, authCookie };
|
67
|
+
},
|
68
|
+
});
|
69
|
+
|
70
|
+
const url = new URL(src);
|
71
|
+
if (walletId) {
|
72
|
+
url.searchParams.set("walletId", walletId);
|
73
|
+
}
|
74
|
+
if (authProvider) {
|
75
|
+
url.searchParams.set("authProvider", authProvider);
|
76
|
+
}
|
77
|
+
if (authCookie) {
|
78
|
+
url.searchParams.set("authCookie", authCookie);
|
79
|
+
}
|
80
|
+
|
81
|
+
return (
|
82
|
+
<iframe
|
83
|
+
src={encodeURI(url.toString())}
|
84
|
+
width="100%"
|
85
|
+
height="100%"
|
86
|
+
allowFullScreen
|
87
|
+
{...props}
|
88
|
+
/>
|
89
|
+
);
|
90
|
+
}
|
@@ -39,7 +39,7 @@ export function WalletAuth(props: {
|
|
39
39
|
}) {
|
40
40
|
const { wallet, done } = props;
|
41
41
|
const addConnectedWallet = useAddConnectedWallet();
|
42
|
-
const walletToConnect = useRef<Wallet>();
|
42
|
+
const walletToConnect = useRef<Wallet>(undefined);
|
43
43
|
const [status, setStatus] = useState<"loading" | "error" | "selecting">(
|
44
44
|
"selecting",
|
45
45
|
);
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.
|
1
|
+
export const version = "5.66.0-nightly-880c3453ee8fc0fabbde0afb752a17894cd579a0-20241106000325";
|
@@ -9,6 +9,7 @@ export function getUrlToken(): {
|
|
9
9
|
walletId?: WalletId;
|
10
10
|
authResult?: AuthStoredTokenWithCookieReturnType;
|
11
11
|
authProvider?: AuthOption;
|
12
|
+
authCookie?: string;
|
12
13
|
} {
|
13
14
|
if (!window?.location) {
|
14
15
|
// Not in web
|
@@ -20,18 +21,24 @@ export function getUrlToken(): {
|
|
20
21
|
const authResultString = params.get("authResult");
|
21
22
|
const walletId = params.get("walletId") as WalletId | undefined;
|
22
23
|
const authProvider = params.get("authProvider") as AuthOption | undefined;
|
24
|
+
const authCookie = params.get("authCookie") as string | undefined;
|
23
25
|
|
24
|
-
if (authResultString && walletId) {
|
25
|
-
const authResult =
|
26
|
-
|
26
|
+
if ((authCookie || authResultString) && walletId) {
|
27
|
+
const authResult = (() => {
|
28
|
+
if (authResultString) {
|
29
|
+
params.delete("authResult");
|
30
|
+
return JSON.parse(decodeURIComponent(authResultString));
|
31
|
+
}
|
32
|
+
})();
|
27
33
|
params.delete("walletId");
|
28
34
|
params.delete("authProvider");
|
35
|
+
params.delete("authCookie");
|
29
36
|
window.history.pushState(
|
30
37
|
{},
|
31
38
|
"",
|
32
39
|
`${window.location.pathname}?${params.toString()}`,
|
33
40
|
);
|
34
|
-
return { walletId, authResult, authProvider };
|
41
|
+
return { walletId, authResult, authProvider, authCookie };
|
35
42
|
}
|
36
43
|
return {};
|
37
44
|
}
|