thirdweb 5.30.0-nightly-d974db533a5a2e241df7743b201d730c90cda0d7-20240627000603 → 5.30.0-nightly-f9f5250b58a756e1abe6e89de7a7965caaeaa8db-20240627172339
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/extensions/ens/resolve-name.js +9 -1
- package/dist/cjs/extensions/ens/resolve-name.js.map +1 -1
- package/dist/cjs/react/web/wallets/ecosystem/EcosystemWalletHeader.js +1 -1
- package/dist/cjs/react/web/wallets/ecosystem/EcosystemWalletHeader.js.map +1 -1
- package/dist/cjs/react/web/wallets/in-app/InAppWalletFormUI.js +3 -2
- package/dist/cjs/react/web/wallets/in-app/InAppWalletFormUI.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js +29 -6
- package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/WalletConnectConnection.js +19 -14
- package/dist/cjs/react/web/wallets/shared/WalletConnectConnection.js.map +1 -1
- package/dist/cjs/utils/web/openWindow.js +22 -16
- package/dist/cjs/utils/web/openWindow.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wallets/ecosystem/get-ecosystem-partner-permissions.js +4 -4
- package/dist/cjs/wallets/ecosystem/get-ecosystem-partner-permissions.js.map +1 -1
- package/dist/cjs/wallets/ecosystem/get-ecosystem-wallet-auth-options.js +24 -0
- package/dist/cjs/wallets/ecosystem/get-ecosystem-wallet-auth-options.js.map +1 -0
- package/dist/cjs/wallets/ecosystem/get-ecosystem-wallet-info.js +3 -3
- package/dist/cjs/wallets/ecosystem/get-ecosystem-wallet-info.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/lib/in-app-account.js +3 -3
- package/dist/cjs/wallets/in-app/web/lib/in-app-account.js.map +1 -1
- package/dist/esm/extensions/ens/resolve-name.js +9 -1
- package/dist/esm/extensions/ens/resolve-name.js.map +1 -1
- package/dist/esm/react/web/wallets/ecosystem/EcosystemWalletHeader.js +1 -1
- package/dist/esm/react/web/wallets/ecosystem/EcosystemWalletHeader.js.map +1 -1
- package/dist/esm/react/web/wallets/in-app/InAppWalletFormUI.js +3 -2
- package/dist/esm/react/web/wallets/in-app/InAppWalletFormUI.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js +30 -7
- package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/WalletConnectConnection.js +19 -14
- package/dist/esm/react/web/wallets/shared/WalletConnectConnection.js.map +1 -1
- package/dist/esm/utils/web/openWindow.js +22 -16
- package/dist/esm/utils/web/openWindow.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/wallets/ecosystem/get-ecosystem-partner-permissions.js +4 -4
- package/dist/esm/wallets/ecosystem/get-ecosystem-partner-permissions.js.map +1 -1
- package/dist/esm/wallets/ecosystem/get-ecosystem-wallet-auth-options.js +21 -0
- package/dist/esm/wallets/ecosystem/get-ecosystem-wallet-auth-options.js.map +1 -0
- package/dist/esm/wallets/ecosystem/get-ecosystem-wallet-info.js +3 -3
- package/dist/esm/wallets/ecosystem/get-ecosystem-wallet-info.js.map +1 -1
- package/dist/esm/wallets/in-app/web/lib/in-app-account.js +3 -3
- package/dist/esm/wallets/in-app/web/lib/in-app-account.js.map +1 -1
- package/dist/types/extensions/ens/resolve-name.d.ts.map +1 -1
- package/dist/types/react/web/wallets/ecosystem/EcosystemWalletHeader.d.ts.map +1 -1
- package/dist/types/react/web/wallets/in-app/InAppWalletFormUI.d.ts.map +1 -1
- package/dist/types/react/web/wallets/shared/ConnectWalletSocialOptions.d.ts.map +1 -1
- package/dist/types/react/web/wallets/shared/WalletConnectConnection.d.ts.map +1 -1
- package/dist/types/utils/web/openWindow.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/wallets/ecosystem/get-ecosystem-wallet-auth-options.d.ts +10 -0
- package/dist/types/wallets/ecosystem/get-ecosystem-wallet-auth-options.d.ts.map +1 -0
- package/dist/types/wallets/in-app/web/lib/in-app-account.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/extensions/ens/resolve-name.test.ts +10 -2
- package/src/extensions/ens/resolve-name.ts +9 -1
- package/src/react/web/wallets/ecosystem/EcosystemWalletHeader.tsx +1 -0
- package/src/react/web/wallets/in-app/InAppWalletFormUI.tsx +28 -27
- package/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx +35 -7
- package/src/react/web/wallets/shared/WalletConnectConnection.tsx +25 -22
- package/src/utils/web/openWindow.ts +22 -17
- package/src/version.ts +1 -1
- package/src/wallets/ecosystem/get-ecosystem-partner-permissions.ts +4 -4
- package/src/wallets/ecosystem/get-ecosystem-wallet-auth-options.ts +33 -0
- package/src/wallets/ecosystem/get-ecosystem-wallet-info.ts +3 -3
- package/src/wallets/in-app/web/lib/in-app-account.ts +3 -3
@@ -1,9 +1,11 @@
|
|
1
1
|
"use client";
|
2
2
|
import styled from "@emotion/styled";
|
3
|
-
import {
|
3
|
+
import { useQuery } from "@tanstack/react-query";
|
4
|
+
import { useMemo, useState } from "react";
|
4
5
|
import type { Chain } from "../../../../chains/types.js";
|
5
6
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
6
7
|
import { webLocalStorage } from "../../../../utils/storage/webStorage.js";
|
8
|
+
import { getEcosystemWalletAuthOptions } from "../../../../wallets/ecosystem/get-ecosystem-wallet-auth-options.js";
|
7
9
|
import { isEcosystemWallet } from "../../../../wallets/ecosystem/is-ecosystem-wallet.js";
|
8
10
|
import type { Account, Wallet } from "../../../../wallets/interfaces/wallet.js";
|
9
11
|
import type {
|
@@ -31,6 +33,7 @@ import { Button } from "../../ui/components/buttons.js";
|
|
31
33
|
import { InputSelectionUI } from "../in-app/InputSelectionUI.js";
|
32
34
|
import { socialIcons } from "../in-app/socialIcons.js";
|
33
35
|
import { validateEmail } from "../in-app/validateEmail.js";
|
36
|
+
import { LoadingScreen } from "./LoadingScreen.js";
|
34
37
|
import type { InAppWalletLocale } from "./locale/types.js";
|
35
38
|
import { openOauthSignInWindow } from "./openOauthSignInWindow.js";
|
36
39
|
import { setLastAuthProvider } from "./storage.js";
|
@@ -87,15 +90,34 @@ export const ConnectWalletSocialOptions = (
|
|
87
90
|
apple: locale.signInWithApple,
|
88
91
|
};
|
89
92
|
|
90
|
-
const
|
91
|
-
|
93
|
+
const { data: ecosystemAuthOptions, isLoading } = useQuery({
|
94
|
+
queryKey: ["auth-options", wallet.id],
|
95
|
+
queryFn: async () => {
|
96
|
+
if (isEcosystemWallet(wallet)) {
|
97
|
+
return getEcosystemWalletAuthOptions(wallet.id);
|
98
|
+
}
|
99
|
+
return null;
|
100
|
+
},
|
101
|
+
enabled: isEcosystemWallet(wallet),
|
102
|
+
retry: false,
|
103
|
+
});
|
104
|
+
const authOptions = isEcosystemWallet(wallet)
|
105
|
+
? ecosystemAuthOptions ?? defaultAuthOptions
|
106
|
+
: wallet.getConfig()?.auth?.options ?? defaultAuthOptions;
|
92
107
|
|
93
108
|
const emailIndex = authOptions.indexOf("email");
|
94
109
|
const isEmailEnabled = emailIndex !== -1;
|
95
110
|
const phoneIndex = authOptions.indexOf("phone");
|
96
111
|
const isPhoneEnabled = phoneIndex !== -1;
|
97
112
|
|
98
|
-
const [
|
113
|
+
const [manualInputMode, setManualInputMode] = useState<
|
114
|
+
"email" | "phone" | "none" | null
|
115
|
+
>(null);
|
116
|
+
|
117
|
+
const inputMode = useMemo(() => {
|
118
|
+
if (manualInputMode) {
|
119
|
+
return manualInputMode;
|
120
|
+
}
|
99
121
|
if (isEmailEnabled && isPhoneEnabled) {
|
100
122
|
return emailIndex < phoneIndex ? "email" : "phone";
|
101
123
|
}
|
@@ -106,7 +128,13 @@ export const ConnectWalletSocialOptions = (
|
|
106
128
|
return "phone";
|
107
129
|
}
|
108
130
|
return "none";
|
109
|
-
});
|
131
|
+
}, [isEmailEnabled, isPhoneEnabled, emailIndex, phoneIndex, manualInputMode]);
|
132
|
+
|
133
|
+
if (isEcosystemWallet(wallet) && isLoading) {
|
134
|
+
return <LoadingScreen />;
|
135
|
+
}
|
136
|
+
|
137
|
+
const passKeyEnabled = authOptions.includes("passkey");
|
110
138
|
|
111
139
|
const placeholder =
|
112
140
|
inputMode === "email" ? locale.emailPlaceholder : locale.phonePlaceholder;
|
@@ -255,7 +283,7 @@ export const ConnectWalletSocialOptions = (
|
|
255
283
|
client={props.client}
|
256
284
|
icon={emailIcon}
|
257
285
|
onClick={() => {
|
258
|
-
|
286
|
+
setManualInputMode("email");
|
259
287
|
}}
|
260
288
|
// TODO locale
|
261
289
|
title={"Email address"}
|
@@ -295,7 +323,7 @@ export const ConnectWalletSocialOptions = (
|
|
295
323
|
client={props.client}
|
296
324
|
icon={phoneIcon}
|
297
325
|
onClick={() => {
|
298
|
-
|
326
|
+
setManualInputMode("phone");
|
299
327
|
}}
|
300
328
|
// TODO locale
|
301
329
|
title={"Phone number"}
|
@@ -51,31 +51,34 @@ export const WalletConnectConnection: React.FC<{
|
|
51
51
|
onDisplayUri(uri) {
|
52
52
|
const preferNative =
|
53
53
|
walletInfo.mobile.native || walletInfo.mobile.universal;
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
54
|
+
try {
|
55
|
+
if (isMobile()) {
|
56
|
+
if (isAndroid()) {
|
57
|
+
if (preferNative) {
|
58
|
+
openWindow(
|
59
|
+
formatWalletConnectUrl(preferNative, uri).redirect,
|
60
|
+
);
|
61
|
+
}
|
62
|
+
} else if (isIOS()) {
|
63
|
+
if (preferNative) {
|
64
|
+
openWindow(
|
65
|
+
formatWalletConnectUrl(preferNative, uri).redirect,
|
66
|
+
);
|
67
|
+
}
|
68
|
+
} else {
|
69
|
+
const preferUniversal =
|
70
|
+
walletInfo.mobile.universal || walletInfo.mobile.native;
|
71
|
+
if (preferUniversal) {
|
72
|
+
openWindow(
|
73
|
+
formatWalletConnectUrl(preferUniversal, uri).redirect,
|
74
|
+
);
|
75
|
+
}
|
67
76
|
}
|
68
77
|
} else {
|
69
|
-
|
70
|
-
walletInfo.mobile.universal || walletInfo.mobile.native;
|
71
|
-
if (preferUniversal) {
|
72
|
-
openWindow(
|
73
|
-
formatWalletConnectUrl(preferUniversal, uri).redirect,
|
74
|
-
);
|
75
|
-
}
|
78
|
+
setQrCodeUri(uri);
|
76
79
|
}
|
77
|
-
}
|
78
|
-
|
80
|
+
} catch {
|
81
|
+
setErrorConnecting(true);
|
79
82
|
}
|
80
83
|
},
|
81
84
|
optionalChains: props.chains,
|
@@ -2,24 +2,29 @@
|
|
2
2
|
* @internal
|
3
3
|
*/
|
4
4
|
export function openWindow(uri: string) {
|
5
|
-
|
6
|
-
|
5
|
+
const isInsideIframe = window !== window.top;
|
6
|
+
if (isInsideIframe) {
|
7
|
+
window.open(uri);
|
8
|
+
} else {
|
9
|
+
if (uri.startsWith("http")) {
|
10
|
+
// taken from for https://github.com/rainbow-me/rainbowkit/
|
7
11
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
// Using 'window.open' causes issues on iOS in non-Safari browsers and
|
13
|
+
// WebViews where a blank tab is left behind after connecting.
|
14
|
+
// This is especially bad in some WebView scenarios (e.g. following a
|
15
|
+
// link from Twitter) where the user doesn't have any mechanism for
|
16
|
+
// closing the blank tab.
|
17
|
+
// For whatever reason, links with a target of "_blank" don't suffer
|
18
|
+
// from this problem, and programmatically clicking a detached link
|
19
|
+
// element with the same attributes also avoids the issue.
|
16
20
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
const link = document.createElement("a");
|
22
|
+
link.href = uri;
|
23
|
+
link.target = "_blank";
|
24
|
+
link.rel = "noreferrer noopener";
|
25
|
+
link.click();
|
26
|
+
} else {
|
27
|
+
window.location.href = uri;
|
28
|
+
}
|
24
29
|
}
|
25
30
|
}
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.30.0-nightly-
|
1
|
+
export const version = "5.30.0-nightly-f9f5250b58a756e1abe6e89de7a7965caaeaa8db-20240627172339";
|
@@ -6,15 +6,15 @@ export const getEcosystemPartnerPermissions = async (
|
|
6
6
|
ecosystemId: EcosystemWalletId,
|
7
7
|
partnerId?: string,
|
8
8
|
): Promise<EcosystemPermssions> => {
|
9
|
-
const headers = new Headers();
|
10
|
-
headers.set("x-ecosystem-id", ecosystemId);
|
11
|
-
headers.set("x-ecosystem-partner-id", partnerId || "");
|
12
9
|
const res = await fetch(
|
13
10
|
`${getThirdwebBaseUrl(
|
14
11
|
"inAppWallet",
|
15
12
|
)}/api/2024-05-05/ecosystem-wallet/${ecosystemId}/partner/${partnerId}`,
|
16
13
|
{
|
17
|
-
headers
|
14
|
+
headers: {
|
15
|
+
"x-ecosystem-id": ecosystemId,
|
16
|
+
"x-ecosystem-partner-id": partnerId || "",
|
17
|
+
},
|
18
18
|
},
|
19
19
|
);
|
20
20
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { getThirdwebBaseUrl } from "../../utils/domains.js";
|
2
|
+
import type { AuthOption } from "../types.js";
|
3
|
+
import type { EcosystemWalletId } from "../wallet-types.js";
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Retrieves the specified auth options for a given ecosystem wallet, if any.
|
7
|
+
* @param walletId The ecosystem wallet ID.
|
8
|
+
* @returns {AuthOption[] | undefined} The auth options for the ecosystem wallet.
|
9
|
+
* @internal
|
10
|
+
*/
|
11
|
+
export async function getEcosystemWalletAuthOptions(
|
12
|
+
walletId: EcosystemWalletId,
|
13
|
+
): Promise<AuthOption[] | undefined> {
|
14
|
+
const res = await fetch(
|
15
|
+
`${getThirdwebBaseUrl("inAppWallet")}/api/2024-05-05/ecosystem-wallet`,
|
16
|
+
{
|
17
|
+
headers: {
|
18
|
+
"x-ecosystem-id": walletId,
|
19
|
+
},
|
20
|
+
},
|
21
|
+
);
|
22
|
+
|
23
|
+
const data = await res.json();
|
24
|
+
|
25
|
+
if (!data || data.code === "UNAUTHORIZED") {
|
26
|
+
throw new Error(
|
27
|
+
data.message ||
|
28
|
+
`Could not find ecosystem wallet with id ${walletId}, please check your ecosystem wallet configuration.`,
|
29
|
+
);
|
30
|
+
}
|
31
|
+
|
32
|
+
return data.authOptions ?? undefined;
|
33
|
+
}
|
@@ -14,12 +14,12 @@ import type { EcosystemWalletId } from "../wallet-types.js";
|
|
14
14
|
export async function getEcosystemWalletInfo(
|
15
15
|
walletId: EcosystemWalletId,
|
16
16
|
): Promise<Prettify<WalletInfo>> {
|
17
|
-
const headers = new Headers();
|
18
|
-
headers.set("x-ecosystem-id", walletId);
|
19
17
|
const res = await fetch(
|
20
18
|
`${getThirdwebBaseUrl("inAppWallet")}/api/2024-05-05/ecosystem-wallet`,
|
21
19
|
{
|
22
|
-
headers
|
20
|
+
headers: {
|
21
|
+
"x-ecosystem-id": walletId,
|
22
|
+
},
|
23
23
|
},
|
24
24
|
);
|
25
25
|
|
@@ -7,7 +7,6 @@ import { getRpcClient } from "../../../../rpc/rpc.js";
|
|
7
7
|
import { type Hex, hexToString } from "../../../../utils/encoding/hex.js";
|
8
8
|
import { parseTypedData } from "../../../../utils/signatures/helpers/parseTypedData.js";
|
9
9
|
import type { Prettify } from "../../../../utils/type-utils.js";
|
10
|
-
import { uint8ArrayToString } from "../../../../utils/uint8-array.js";
|
11
10
|
import { getEcosystemPartnerPermissions } from "../../../ecosystem/get-ecosystem-partner-permissions.js";
|
12
11
|
import type {
|
13
12
|
Account,
|
@@ -279,7 +278,7 @@ export class IFrameWallet {
|
|
279
278
|
return message;
|
280
279
|
}
|
281
280
|
if (message.raw instanceof Uint8Array) {
|
282
|
-
return
|
281
|
+
return message.raw;
|
283
282
|
}
|
284
283
|
return hexToString(message.raw);
|
285
284
|
})();
|
@@ -287,7 +286,8 @@ export class IFrameWallet {
|
|
287
286
|
const { signedMessage } = await querier.call<SignMessageReturnType>({
|
288
287
|
procedureName: "signMessage",
|
289
288
|
params: {
|
290
|
-
|
289
|
+
// biome-ignore lint/suspicious/noExplicitAny: ethers tx transformation
|
290
|
+
message: messageDecoded as any, // needs bytes or string
|
291
291
|
partnerId,
|
292
292
|
chainId: 1, // TODO check if we need this
|
293
293
|
},
|