thirdweb 5.39.0 → 5.40.0-nightly-3848327373e49aa83c5902e6a16d5b8e96cf1eeb-20240726000343
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/react/core/hooks/wallets/useAutoConnect.js +16 -3
- package/dist/cjs/react/core/hooks/wallets/useAutoConnect.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +7 -3
- package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js +16 -5
- package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/SocialLogin.js +18 -2
- package/dist/cjs/react/web/wallets/shared/SocialLogin.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/{openOauthSignInWindow.js → oauthSignIn.js} +2 -3
- package/dist/cjs/react/web/wallets/shared/oauthSignIn.js.map +1 -0
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/wallets/in-app/core/wallet/index.js +15 -0
- package/dist/cjs/wallets/in-app/core/wallet/index.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/in-app.js +10 -0
- package/dist/cjs/wallets/in-app/web/in-app.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/lib/auth/index.js +2 -0
- package/dist/cjs/wallets/in-app/web/lib/auth/index.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/lib/auth/oauth.js +9 -1
- package/dist/cjs/wallets/in-app/web/lib/auth/oauth.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/lib/get-url-token.js +26 -0
- package/dist/cjs/wallets/in-app/web/lib/get-url-token.js.map +1 -0
- package/dist/cjs/wallets/in-app/web/lib/web-connector.js +13 -3
- package/dist/cjs/wallets/in-app/web/lib/web-connector.js.map +1 -1
- package/dist/esm/react/core/hooks/wallets/useAutoConnect.js +16 -3
- package/dist/esm/react/core/hooks/wallets/useAutoConnect.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +7 -3
- package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js +15 -4
- package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/SocialLogin.js +17 -1
- package/dist/esm/react/web/wallets/shared/SocialLogin.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/{openOauthSignInWindow.js → oauthSignIn.js} +2 -3
- package/dist/esm/react/web/wallets/shared/oauthSignIn.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/wallets/in-app/core/wallet/index.js +15 -0
- package/dist/esm/wallets/in-app/core/wallet/index.js.map +1 -1
- package/dist/esm/wallets/in-app/web/in-app.js +10 -0
- package/dist/esm/wallets/in-app/web/in-app.js.map +1 -1
- package/dist/esm/wallets/in-app/web/lib/auth/index.js +2 -0
- package/dist/esm/wallets/in-app/web/lib/auth/index.js.map +1 -1
- package/dist/esm/wallets/in-app/web/lib/auth/oauth.js +7 -0
- package/dist/esm/wallets/in-app/web/lib/auth/oauth.js.map +1 -1
- package/dist/esm/wallets/in-app/web/lib/get-url-token.js +23 -0
- package/dist/esm/wallets/in-app/web/lib/get-url-token.js.map +1 -0
- package/dist/esm/wallets/in-app/web/lib/web-connector.js +14 -4
- package/dist/esm/wallets/in-app/web/lib/web-connector.js.map +1 -1
- package/dist/types/exports/utils.d.ts +1 -0
- package/dist/types/exports/utils.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/Modal/ConnectEmbed.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/SocialLogin.d.ts.map +1 -1
- package/dist/types/react/web/wallets/shared/{openOauthSignInWindow.d.ts → oauthSignIn.d.ts} +1 -2
- package/dist/types/react/web/wallets/shared/oauthSignIn.d.ts.map +1 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/dist/types/wallets/ecosystem/types.d.ts +3 -0
- package/dist/types/wallets/ecosystem/types.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/interfaces/connector.d.ts +4 -1
- package/dist/types/wallets/in-app/core/interfaces/connector.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/wallet/index.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/wallet/types.d.ts +4 -1
- package/dist/types/wallets/in-app/core/wallet/types.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/in-app.d.ts +10 -0
- package/dist/types/wallets/in-app/web/in-app.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/lib/auth/index.d.ts +11 -2
- package/dist/types/wallets/in-app/web/lib/auth/index.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/lib/auth/oauth.d.ts +5 -0
- package/dist/types/wallets/in-app/web/lib/auth/oauth.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/lib/get-url-token.d.ts +12 -0
- package/dist/types/wallets/in-app/web/lib/get-url-token.d.ts.map +1 -0
- package/dist/types/wallets/in-app/web/lib/web-connector.d.ts +4 -1
- package/dist/types/wallets/in-app/web/lib/web-connector.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/exports/utils.ts +2 -0
- package/src/react/core/hooks/wallets/useAutoConnect.ts +17 -3
- package/src/react/web/ui/ConnectWallet/Modal/ConnectEmbed.tsx +9 -3
- package/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx +18 -4
- package/src/react/web/wallets/shared/SocialLogin.tsx +20 -1
- package/src/react/web/wallets/shared/{openOauthSignInWindow.ts → oauthSignIn.ts} +1 -2
- package/src/version.ts +1 -1
- package/src/wallets/ecosystem/types.ts +3 -0
- package/src/wallets/in-app/core/interfaces/connector.ts +6 -0
- package/src/wallets/in-app/core/wallet/index.ts +22 -0
- package/src/wallets/in-app/core/wallet/types.ts +4 -0
- package/src/wallets/in-app/web/in-app.ts +10 -0
- package/src/wallets/in-app/web/lib/auth/index.ts +14 -3
- package/src/wallets/in-app/web/lib/auth/oauth.ts +12 -0
- package/src/wallets/in-app/web/lib/get-url-token.ts +36 -0
- package/src/wallets/in-app/web/lib/web-connector.ts +18 -4
- package/dist/cjs/react/web/wallets/shared/openOauthSignInWindow.js.map +0 -1
- package/dist/esm/react/web/wallets/shared/openOauthSignInWindow.js.map +0 -1
- package/dist/types/react/web/wallets/shared/openOauthSignInWindow.d.ts.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/wallets/ecosystem/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,4BAA4B,EAC7B,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/wallets/ecosystem/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,4BAA4B,EAC7B,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE;QACL,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;KAC7B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG,4BAA4B,GAAG;IAC5E,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC;AACF,MAAM,MAAM,iCAAiC,GAC3C,6BAA6B,GAAG;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,CAAC"}
|
@@ -1,9 +1,12 @@
|
|
1
|
+
import type { SocialAuthOption } from "../../../../wallets/types.js";
|
1
2
|
import type { Account } from "../../../interfaces/wallet.js";
|
2
|
-
import type { AuthArgsType, AuthLoginReturnType, GetUser, LogoutReturnType, PreAuthArgsType, SendEmailOtpReturnType } from "../authentication/type.js";
|
3
|
+
import type { AuthArgsType, AuthLoginReturnType, AuthStoredTokenWithCookieReturnType, GetUser, LogoutReturnType, PreAuthArgsType, SendEmailOtpReturnType } from "../authentication/type.js";
|
3
4
|
export interface InAppConnector {
|
4
5
|
getUser(): Promise<GetUser>;
|
5
6
|
getAccount(): Promise<Account>;
|
6
7
|
preAuthenticate(args: PreAuthArgsType): Promise<SendEmailOtpReturnType>;
|
8
|
+
authenticateWithRedirect?(strategy: SocialAuthOption): void;
|
9
|
+
loginWithAuthToken?(authResult: AuthStoredTokenWithCookieReturnType): Promise<AuthLoginReturnType>;
|
7
10
|
authenticate(args: AuthArgsType): Promise<AuthLoginReturnType>;
|
8
11
|
logout(): Promise<LogoutReturnType>;
|
9
12
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/interfaces/connector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,OAAO,EACP,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACvB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,cAAc;IAC7B,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5B,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/B,eAAe,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACxE,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC/D,MAAM,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACrC"}
|
1
|
+
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/interfaces/connector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,mCAAmC,EACnC,OAAO,EACP,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACvB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,cAAc;IAC7B,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5B,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/B,eAAe,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACxE,wBAAwB,CAAC,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC5D,kBAAkB,CAAC,CACjB,UAAU,EAAE,mCAAmC,GAC9C,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAChC,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC/D,MAAM,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACrC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/wallet/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/wallet/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAMzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,KAAK,EACV,gBAAgB,EAChB,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,GACvB,MAAM,IAAI,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC,CAExC;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EACH,sBAAsB,CAAC,OAAO,CAAC,GAC/B,sBAAsB,CAAC,iBAAiB,CAAC,EAC7C,aAAa,EACT,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAC5B,gBAAgB,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAC1C,SAAS,EAAE,cAAc,GACxB,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAgC3B;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EACH,0BAA0B,CAAC,OAAO,CAAC,GACnC,0BAA0B,CAAC,iBAAiB,CAAC,EACjD,aAAa,EACT,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAC5B,gBAAgB,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAC1C,SAAS,EAAE,cAAc,GACxB,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CA0B3B"}
|
@@ -2,13 +2,15 @@ import type { Chain } from "../../../../chains/types.js";
|
|
2
2
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
3
3
|
import type { SmartWalletOptions } from "../../../smart/types.js";
|
4
4
|
import type { AuthOption, SocialAuthOption } from "../../../types.js";
|
5
|
-
import type { MultiStepAuthArgsType, SingleStepAuthArgsType } from "../authentication/type.js";
|
5
|
+
import type { AuthStoredTokenWithCookieReturnType, MultiStepAuthArgsType, SingleStepAuthArgsType } from "../authentication/type.js";
|
6
6
|
export type InAppWalletConnectionOptions = (MultiStepAuthArgsType | SingleStepAuthArgsType) & {
|
7
7
|
client: ThirdwebClient;
|
8
8
|
chain?: Chain;
|
9
|
+
redirect?: boolean;
|
9
10
|
};
|
10
11
|
export type InAppWalletAutoConnectOptions = {
|
11
12
|
client: ThirdwebClient;
|
13
|
+
authResult?: AuthStoredTokenWithCookieReturnType;
|
12
14
|
chain?: Chain;
|
13
15
|
};
|
14
16
|
export type InAppWalletSocialAuth = SocialAuthOption;
|
@@ -16,6 +18,7 @@ export type InAppWalletAuth = AuthOption;
|
|
16
18
|
export type InAppWalletCreationOptions = {
|
17
19
|
auth?: {
|
18
20
|
options: InAppWalletAuth[];
|
21
|
+
mode?: "popup" | "redirect";
|
19
22
|
};
|
20
23
|
metadata?: {
|
21
24
|
image?: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/wallet/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,MAAM,4BAA4B,GAAG,CACvC,qBAAqB,GACrB,sBAAsB,CACzB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G,CAAC,EAAE,MAAM,CAAC;SACd,CAAC;KACH,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,GACD,SAAS,CAAC;AAEd,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC"}
|
@@ -50,6 +50,16 @@ import type { CreateWalletArgs } from "../../wallet-types.js";
|
|
50
50
|
* hidePrivateKeyExport: true
|
51
51
|
* });
|
52
52
|
* ```
|
53
|
+
*
|
54
|
+
* Open the Oauth window in the same tab
|
55
|
+
* ```ts
|
56
|
+
* import { inAppWallet } from "thirdweb/wallets";
|
57
|
+
* const wallet = inAppWallet({
|
58
|
+
* auth: {
|
59
|
+
* mode: "redirect"
|
60
|
+
* }
|
61
|
+
* });
|
62
|
+
* ```
|
53
63
|
* @wallet
|
54
64
|
*/
|
55
65
|
export declare function inAppWallet(createOptions?: CreateWalletArgs<"inApp">[1]): Wallet<"inApp">;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"in-app.d.ts","sourceRoot":"","sources":["../../../../../src/wallets/in-app/web/in-app.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAG9D
|
1
|
+
{"version":3,"file":"in-app.d.ts","sourceRoot":"","sources":["../../../../../src/wallets/in-app/web/in-app.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAG9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,wBAAgB,WAAW,CACzB,aAAa,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAC3C,MAAM,CAAC,OAAO,CAAC,CAUjB"}
|
@@ -1,4 +1,8 @@
|
|
1
|
-
import
|
1
|
+
import type { ThirdwebClient } from "../../../../../client/client.js";
|
2
|
+
import type { OneOf } from "../../../../../utils/type-utils.js";
|
3
|
+
import type { SocialAuthOption } from "../../../../../wallets/types.js";
|
4
|
+
import { type AuthArgsType, type GetAuthenticatedUserParams, type PreAuthArgsType } from "../../../core/authentication/type.js";
|
5
|
+
import type { Ecosystem } from "../../types.js";
|
2
6
|
/**
|
3
7
|
* Retrieves the authenticated user for the active in-app wallet.
|
4
8
|
* @param options - The arguments for retrieving the authenticated user.
|
@@ -78,5 +82,10 @@ export declare function preAuthenticate(args: PreAuthArgsType): Promise<import("
|
|
78
82
|
* ```
|
79
83
|
* @wallet
|
80
84
|
*/
|
81
|
-
export declare function authenticate(args: AuthArgsType
|
85
|
+
export declare function authenticate(args: OneOf<AuthArgsType | {
|
86
|
+
strategy: SocialAuthOption;
|
87
|
+
client: ThirdwebClient;
|
88
|
+
ecosystem?: Ecosystem;
|
89
|
+
redirect: boolean;
|
90
|
+
}>): Promise<void | import("../../../core/authentication/type.js").AuthLoginReturnType>;
|
82
91
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/wallets/in-app/web/lib/auth/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/wallets/in-app/web/lib/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAC/B,KAAK,eAAe,EAErB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAyBhD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,0BAA0B,uFAWpC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,0BAA0B,+BAMrE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,0BAA0B,+BAM3E;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,eAAe,kFAG1D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,KAAK,CACP,YAAY,GACZ;IACE,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;CACnB,CACJ,sFAMF"}
|
@@ -3,6 +3,11 @@ import type { AuthStoredTokenWithCookieReturnType } from "../../../../../wallets
|
|
3
3
|
import type { SocialAuthOption } from "../../../../../wallets/types.js";
|
4
4
|
import type { Ecosystem } from "../../types.js";
|
5
5
|
export declare const getSocialAuthLoginPath: (authOption: SocialAuthOption, client: ThirdwebClient, ecosystem?: Ecosystem) => string;
|
6
|
+
export declare const loginWithOauthRedirect: (options: {
|
7
|
+
authOption: SocialAuthOption;
|
8
|
+
client: ThirdwebClient;
|
9
|
+
ecosystem?: Ecosystem;
|
10
|
+
}) => void;
|
6
11
|
export declare const loginWithOauth: (options: {
|
7
12
|
authOption: SocialAuthOption;
|
8
13
|
client: ThirdwebClient;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../../../../../src/wallets/in-app/web/lib/auth/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,2DAA2D,CAAC;AACrH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAuBhD,eAAO,MAAM,sBAAsB,eACrB,gBAAgB,UACpB,cAAc,cACV,SAAS,WAUtB,CAAC;AAEF,eAAO,MAAM,cAAc,YAAmB;IAC5C,UAAU,EAAE,gBAAgB,CAAC;IAC7B,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACzC,iBAAiB,CAAC,EAAE,CAAC,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAClE,KAAG,OAAO,CAAC,mCAAmC,CA+E9C,CAAC"}
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../../../../../src/wallets/in-app/web/lib/auth/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,2DAA2D,CAAC;AACrH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAuBhD,eAAO,MAAM,sBAAsB,eACrB,gBAAgB,UACpB,cAAc,cACV,SAAS,WAUtB,CAAC;AAEF,eAAO,MAAM,sBAAsB,YAAa;IAC9C,UAAU,EAAE,gBAAgB,CAAC;IAC7B,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,KAAG,IAMH,CAAC;AAEF,eAAO,MAAM,cAAc,YAAmB;IAC5C,UAAU,EAAE,gBAAgB,CAAC;IAC7B,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACzC,iBAAiB,CAAC,EAAE,CAAC,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAClE,KAAG,OAAO,CAAC,mCAAmC,CA+E9C,CAAC"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import type { AuthOption } from "../../../../wallets/types.js";
|
2
|
+
import type { WalletId } from "../../../wallet-types.js";
|
3
|
+
import type { AuthStoredTokenWithCookieReturnType } from "../../core/authentication/type.js";
|
4
|
+
/**
|
5
|
+
* Checks for an auth token and associated metadata in the current URL
|
6
|
+
*/
|
7
|
+
export declare function getUrlToken(): {
|
8
|
+
walletId?: WalletId;
|
9
|
+
authResult?: AuthStoredTokenWithCookieReturnType;
|
10
|
+
authProvider?: AuthOption;
|
11
|
+
};
|
12
|
+
//# sourceMappingURL=get-url-token.d.ts.map
|
@@ -0,0 +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,mCAAmC,CAAC;AAE7F;;GAEG;AACH,wBAAgB,WAAW,IAAI;IAC7B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,mCAAmC,CAAC;IACjD,YAAY,CAAC,EAAE,UAAU,CAAC;CAC3B,CAwBA"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
2
|
+
import type { SocialAuthOption } from "../../../../wallets/types.js";
|
2
3
|
import type { Account } from "../../../interfaces/wallet.js";
|
3
|
-
import { type AuthLoginReturnType, type GetUser, type LogoutReturnType, type MultiStepAuthArgsType, type MultiStepAuthProviderType, type SendEmailOtpReturnType, type SingleStepAuthArgsType } from "../../core/authentication/type.js";
|
4
|
+
import { type AuthLoginReturnType, type AuthStoredTokenWithCookieReturnType, type GetUser, type LogoutReturnType, type MultiStepAuthArgsType, type MultiStepAuthProviderType, type SendEmailOtpReturnType, type SingleStepAuthArgsType } from "../../core/authentication/type.js";
|
4
5
|
import type { InAppConnector } from "../../core/interfaces/connector.js";
|
5
6
|
import type { InAppWalletConstructorType } from "../types.js";
|
6
7
|
import { InAppWalletIframeCommunicator } from "../utils/iFrameCommunication/InAppWalletIframeCommunicator.js";
|
@@ -49,6 +50,8 @@ export declare class InAppWebConnector implements InAppConnector {
|
|
49
50
|
getUser(): Promise<GetUser>;
|
50
51
|
getAccount(): Promise<Account>;
|
51
52
|
preAuthenticate(args: MultiStepAuthProviderType): Promise<SendEmailOtpReturnType>;
|
53
|
+
authenticateWithRedirect(strategy: SocialAuthOption): void;
|
54
|
+
loginWithAuthToken(authResult: AuthStoredTokenWithCookieReturnType): Promise<AuthLoginReturnType>;
|
52
55
|
authenticate(args: MultiStepAuthArgsType | SingleStepAuthArgsType): Promise<AuthLoginReturnType>;
|
53
56
|
logout(): Promise<LogoutReturnType>;
|
54
57
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"web-connector.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/web/lib/web-connector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,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
|
import { useQuery } from "@tanstack/react-query";
|
2
2
|
import type { AsyncStorage } from "../../../../utils/storage/AsyncStorage.js";
|
3
|
+
import { getUrlToken } from "../../../../wallets/in-app/web/lib/get-url-token.js";
|
3
4
|
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
4
5
|
import {
|
5
6
|
type ConnectionManager,
|
@@ -7,6 +8,7 @@ import {
|
|
7
8
|
getStoredActiveWalletId,
|
8
9
|
getStoredConnectedWalletIds,
|
9
10
|
} from "../../../../wallets/manager/index.js";
|
11
|
+
import { setLastAuthProvider } from "../../utils/storage.js";
|
10
12
|
import { timeoutPromise } from "../../utils/timeoutPromise.js";
|
11
13
|
import type { AutoConnectProps } from "../connection/types.js";
|
12
14
|
import { useConnectCore } from "./useConnect.js";
|
@@ -32,12 +34,23 @@ export function useAutoConnectCore(
|
|
32
34
|
const autoConnect = async (): Promise<boolean> => {
|
33
35
|
let autoConnected = false;
|
34
36
|
isAutoConnecting.setValue(true);
|
35
|
-
|
37
|
+
let [lastConnectedWalletIds, lastActiveWalletId] = await Promise.all([
|
36
38
|
getStoredConnectedWalletIds(storage),
|
37
39
|
getStoredActiveWalletId(storage),
|
38
40
|
]);
|
39
41
|
|
40
|
-
|
42
|
+
const { authResult, walletId, authProvider } = getUrlToken();
|
43
|
+
if (authResult && walletId) {
|
44
|
+
lastActiveWalletId = walletId;
|
45
|
+
lastConnectedWalletIds = lastConnectedWalletIds?.includes(walletId)
|
46
|
+
? lastConnectedWalletIds
|
47
|
+
: [walletId, ...(lastConnectedWalletIds || [])];
|
48
|
+
}
|
49
|
+
if (authProvider) {
|
50
|
+
await setLastAuthProvider(authProvider, storage);
|
51
|
+
}
|
52
|
+
|
53
|
+
// if no wallets were last connected or we didn't receive an auth token
|
41
54
|
if (!lastConnectedWalletIds) {
|
42
55
|
return autoConnected;
|
43
56
|
}
|
@@ -48,6 +61,7 @@ export function useAutoConnectCore(
|
|
48
61
|
return wallet.autoConnect({
|
49
62
|
client: props.client,
|
50
63
|
chain: lastConnectedChain ?? undefined,
|
64
|
+
authResult,
|
51
65
|
});
|
52
66
|
}
|
53
67
|
|
@@ -61,7 +75,7 @@ export function useAutoConnectCore(
|
|
61
75
|
setConnectionStatus("connecting"); // only set connecting status if we are connecting the last active EOA
|
62
76
|
await timeoutPromise(handleWalletConnection(activeWallet), {
|
63
77
|
ms: timeout,
|
64
|
-
message: `AutoConnect timeout
|
78
|
+
message: `AutoConnect timeout: ${timeout}ms limit exceeded.`,
|
65
79
|
});
|
66
80
|
|
67
81
|
// connected wallet could be activeWallet or smart wallet
|
@@ -210,7 +210,7 @@ const ConnectEmbedContent = (props: {
|
|
210
210
|
welcomeScreen: undefined,
|
211
211
|
wallets: props.wallets,
|
212
212
|
});
|
213
|
-
const { setScreen, initialScreen } = screenSetup;
|
213
|
+
const { setScreen, initialScreen, screen } = screenSetup;
|
214
214
|
const activeWallet = useActiveWallet();
|
215
215
|
const siweAuth = useSiweAuth(activeWallet, props.auth);
|
216
216
|
const activeAccount = useActiveAccount();
|
@@ -219,11 +219,17 @@ const ConnectEmbedContent = (props: {
|
|
219
219
|
|
220
220
|
let content = null;
|
221
221
|
|
222
|
+
// if sign in is required but connect embed is showing the initial screen - change to sign in screen
|
222
223
|
useEffect(() => {
|
223
|
-
if (
|
224
|
+
if (
|
225
|
+
siweAuth.requiresAuth &&
|
226
|
+
!siweAuth.isLoggedIn &&
|
227
|
+
activeAccount &&
|
228
|
+
screen === initialScreen
|
229
|
+
) {
|
224
230
|
setScreen(reservedScreens.signIn);
|
225
231
|
}
|
226
|
-
}, [siweAuth, setScreen, activeAccount]);
|
232
|
+
}, [siweAuth, setScreen, activeAccount, screen, initialScreen]);
|
227
233
|
|
228
234
|
const modalSize = !canFitWideModal()
|
229
235
|
? "compact"
|
@@ -7,6 +7,7 @@ import type { ThirdwebClient } from "../../../../client/client.js";
|
|
7
7
|
import { webLocalStorage } from "../../../../utils/storage/webStorage.js";
|
8
8
|
import { getEcosystemWalletAuthOptions } from "../../../../wallets/ecosystem/get-ecosystem-wallet-auth-options.js";
|
9
9
|
import { isEcosystemWallet } from "../../../../wallets/ecosystem/is-ecosystem-wallet.js";
|
10
|
+
import { loginWithOauthRedirect } from "../../../../wallets/in-app/web/lib/auth/oauth.js";
|
10
11
|
import type { Account, Wallet } from "../../../../wallets/interfaces/wallet.js";
|
11
12
|
import {
|
12
13
|
type AuthOption,
|
@@ -37,7 +38,7 @@ import { InputSelectionUI } from "../in-app/InputSelectionUI.js";
|
|
37
38
|
import { validateEmail } from "../in-app/validateEmail.js";
|
38
39
|
import { LoadingScreen } from "./LoadingScreen.js";
|
39
40
|
import type { InAppWalletLocale } from "./locale/types.js";
|
40
|
-
import { openOauthSignInWindow } from "./
|
41
|
+
import { openOauthSignInWindow } from "./oauthSignIn.js";
|
41
42
|
|
42
43
|
export type ConnectWalletSelectUIState =
|
43
44
|
| undefined
|
@@ -164,6 +165,19 @@ export const ConnectWalletSocialOptions = (
|
|
164
165
|
|
165
166
|
// Need to trigger login on button click to avoid popup from being blocked
|
166
167
|
const handleSocialLogin = async (strategy: SocialAuthOption) => {
|
168
|
+
const walletConfig = wallet.getConfig();
|
169
|
+
if (
|
170
|
+
walletConfig &&
|
171
|
+
"auth" in walletConfig &&
|
172
|
+
walletConfig?.auth?.mode === "redirect"
|
173
|
+
) {
|
174
|
+
return loginWithOauthRedirect({
|
175
|
+
authOption: strategy,
|
176
|
+
client: props.client,
|
177
|
+
ecosystem: ecosystemInfo,
|
178
|
+
});
|
179
|
+
}
|
180
|
+
|
167
181
|
try {
|
168
182
|
const socialLoginWindow = openOauthSignInWindow({
|
169
183
|
authOption: strategy,
|
@@ -205,10 +219,10 @@ export const ConnectWalletSocialOptions = (
|
|
205
219
|
|
206
220
|
props.select(); // show Connect UI
|
207
221
|
|
208
|
-
// Note: do not call done() here, it will be called
|
209
|
-
// we simply trigger the connect and save promise here - its resolution is handled in
|
222
|
+
// Note: do not call done() here, it will be called SocialLogin component
|
223
|
+
// we simply trigger the connect and save promise here - its resolution is handled in SocialLogin
|
210
224
|
} catch (e) {
|
211
|
-
console.error(`Error
|
225
|
+
console.error(`Error signing in with ${strategy}`, e);
|
212
226
|
}
|
213
227
|
};
|
214
228
|
|
@@ -5,6 +5,7 @@ import type { ThirdwebClient } from "../../../../client/client.js";
|
|
5
5
|
import { webLocalStorage } from "../../../../utils/storage/webStorage.js";
|
6
6
|
import { isEcosystemWallet } from "../../../../wallets/ecosystem/is-ecosystem-wallet.js";
|
7
7
|
import type { InAppWalletSocialAuth } from "../../../../wallets/in-app/core/wallet/types.js";
|
8
|
+
import { loginWithOauthRedirect } from "../../../../wallets/in-app/web/lib/auth/oauth.js";
|
8
9
|
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
9
10
|
import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js";
|
10
11
|
import { setLastAuthProvider } from "../../../core/utils/storage.js";
|
@@ -15,7 +16,7 @@ import { Button } from "../../ui/components/buttons.js";
|
|
15
16
|
import { Text } from "../../ui/components/text.js";
|
16
17
|
import type { ConnectWalletSelectUIState } from "./ConnectWalletSocialOptions.js";
|
17
18
|
import type { InAppWalletLocale } from "./locale/types.js";
|
18
|
-
import { openOauthSignInWindow } from "./
|
19
|
+
import { openOauthSignInWindow } from "./oauthSignIn.js";
|
19
20
|
|
20
21
|
/**
|
21
22
|
* @internal
|
@@ -42,6 +43,24 @@ export function SocialLogin(props: {
|
|
42
43
|
);
|
43
44
|
|
44
45
|
const handleSocialLogin = async () => {
|
46
|
+
const walletConfig = wallet.getConfig();
|
47
|
+
if (
|
48
|
+
walletConfig &&
|
49
|
+
"auth" in walletConfig &&
|
50
|
+
walletConfig?.auth?.mode === "redirect"
|
51
|
+
) {
|
52
|
+
return loginWithOauthRedirect({
|
53
|
+
authOption: props.socialAuth,
|
54
|
+
client: props.client,
|
55
|
+
ecosystem: isEcosystemWallet(wallet)
|
56
|
+
? {
|
57
|
+
id: wallet.id,
|
58
|
+
partnerId: wallet.getConfig()?.partnerId,
|
59
|
+
}
|
60
|
+
: undefined,
|
61
|
+
});
|
62
|
+
}
|
63
|
+
|
45
64
|
try {
|
46
65
|
const socialWindow = openOauthSignInWindow({
|
47
66
|
authOption: props.socialAuth,
|
@@ -41,7 +41,6 @@ function getOauthLoginPath(
|
|
41
41
|
}
|
42
42
|
|
43
43
|
/**
|
44
|
-
*
|
45
44
|
* @internal
|
46
45
|
*/
|
47
46
|
export function openOauthSignInWindow({
|
@@ -137,7 +136,7 @@ const spinnerWindowHtml = `
|
|
137
136
|
@keyframes spin {
|
138
137
|
100% {
|
139
138
|
transform: rotate(360deg);
|
140
|
-
|
139
|
+
}
|
141
140
|
}
|
142
141
|
</style>
|
143
142
|
`;
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.
|
1
|
+
export const version = "5.40.0-nightly-3848327373e49aa83c5902e6a16d5b8e96cf1eeb-20240726000343";
|
@@ -6,6 +6,9 @@ import type { Ecosystem } from "../in-app/web/types.js";
|
|
6
6
|
|
7
7
|
export type EcosystemWalletCreationOptions = {
|
8
8
|
partnerId?: string;
|
9
|
+
auth?: {
|
10
|
+
mode?: "popup" | "redirect";
|
11
|
+
};
|
9
12
|
};
|
10
13
|
|
11
14
|
export type EcosystemWalletConnectionOptions = InAppWalletConnectionOptions & {
|
@@ -1,7 +1,9 @@
|
|
1
|
+
import type { SocialAuthOption } from "../../../../wallets/types.js";
|
1
2
|
import type { Account } from "../../../interfaces/wallet.js";
|
2
3
|
import type {
|
3
4
|
AuthArgsType,
|
4
5
|
AuthLoginReturnType,
|
6
|
+
AuthStoredTokenWithCookieReturnType,
|
5
7
|
GetUser,
|
6
8
|
LogoutReturnType,
|
7
9
|
PreAuthArgsType,
|
@@ -12,6 +14,10 @@ export interface InAppConnector {
|
|
12
14
|
getUser(): Promise<GetUser>;
|
13
15
|
getAccount(): Promise<Account>;
|
14
16
|
preAuthenticate(args: PreAuthArgsType): Promise<SendEmailOtpReturnType>;
|
17
|
+
authenticateWithRedirect?(strategy: SocialAuthOption): void;
|
18
|
+
loginWithAuthToken?(
|
19
|
+
authResult: AuthStoredTokenWithCookieReturnType,
|
20
|
+
): Promise<AuthLoginReturnType>;
|
15
21
|
authenticate(args: AuthArgsType): Promise<AuthLoginReturnType>;
|
16
22
|
logout(): Promise<LogoutReturnType>;
|
17
23
|
}
|
@@ -1,6 +1,10 @@
|
|
1
1
|
import { ethereum } from "../../../../chains/chain-definitions/ethereum.js";
|
2
2
|
import type { Chain } from "../../../../chains/types.js";
|
3
3
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
4
|
+
import {
|
5
|
+
type SocialAuthOption,
|
6
|
+
socialAuthOptions,
|
7
|
+
} from "../../../../wallets/types.js";
|
4
8
|
import type { Account, Wallet } from "../../../interfaces/wallet.js";
|
5
9
|
import type { EcosystemWalletId, WalletId } from "../../../wallet-types.js";
|
6
10
|
import type {
|
@@ -35,6 +39,20 @@ export async function connectInAppWallet(
|
|
35
39
|
| CreateWalletArgs<EcosystemWalletId>[1],
|
36
40
|
connector: InAppConnector,
|
37
41
|
): Promise<[Account, Chain]> {
|
42
|
+
if (
|
43
|
+
createOptions?.auth?.mode === "redirect" &&
|
44
|
+
connector.authenticateWithRedirect
|
45
|
+
) {
|
46
|
+
const strategy = options.strategy;
|
47
|
+
if (!socialAuthOptions.includes(strategy as SocialAuthOption)) {
|
48
|
+
throw new Error("This authentication method does not support redirects");
|
49
|
+
}
|
50
|
+
connector.authenticateWithRedirect(strategy as SocialAuthOption);
|
51
|
+
}
|
52
|
+
// If we don't have authenticateWithRedirect then it's likely react native, so the default is to redirect and we can carry on
|
53
|
+
// IF WE EVER ADD MORE CONNECTOR TYPES, this could cause redirect to be ignored despite being specified
|
54
|
+
// TODO: In V6, make everything redirect auth
|
55
|
+
|
38
56
|
const authResult = await connector.authenticate(options);
|
39
57
|
const authAccount = authResult.user.account;
|
40
58
|
|
@@ -66,6 +84,10 @@ export async function autoConnectInAppWallet(
|
|
66
84
|
| CreateWalletArgs<EcosystemWalletId>[1],
|
67
85
|
connector: InAppConnector,
|
68
86
|
): Promise<[Account, Chain]> {
|
87
|
+
if (options.authResult && connector.loginWithAuthToken) {
|
88
|
+
await connector.loginWithAuthToken(options.authResult);
|
89
|
+
}
|
90
|
+
|
69
91
|
const user = await getAuthenticatedUser(connector);
|
70
92
|
if (!user) {
|
71
93
|
throw new Error("Failed to authenticate user.");
|
@@ -3,6 +3,7 @@ import type { ThirdwebClient } from "../../../../client/client.js";
|
|
3
3
|
import type { SmartWalletOptions } from "../../../smart/types.js";
|
4
4
|
import type { AuthOption, SocialAuthOption } from "../../../types.js";
|
5
5
|
import type {
|
6
|
+
AuthStoredTokenWithCookieReturnType,
|
6
7
|
MultiStepAuthArgsType,
|
7
8
|
SingleStepAuthArgsType,
|
8
9
|
} from "../authentication/type.js";
|
@@ -13,10 +14,12 @@ export type InAppWalletConnectionOptions = (
|
|
13
14
|
) & {
|
14
15
|
client: ThirdwebClient;
|
15
16
|
chain?: Chain;
|
17
|
+
redirect?: boolean;
|
16
18
|
};
|
17
19
|
|
18
20
|
export type InAppWalletAutoConnectOptions = {
|
19
21
|
client: ThirdwebClient;
|
22
|
+
authResult?: AuthStoredTokenWithCookieReturnType;
|
20
23
|
chain?: Chain;
|
21
24
|
};
|
22
25
|
|
@@ -27,6 +30,7 @@ export type InAppWalletCreationOptions =
|
|
27
30
|
| {
|
28
31
|
auth?: {
|
29
32
|
options: InAppWalletAuth[];
|
33
|
+
mode?: "popup" | "redirect";
|
30
34
|
};
|
31
35
|
metadata?: {
|
32
36
|
image?: {
|
@@ -53,6 +53,16 @@ import { createInAppWallet } from "../core/wallet/in-app-core.js";
|
|
53
53
|
* hidePrivateKeyExport: true
|
54
54
|
* });
|
55
55
|
* ```
|
56
|
+
*
|
57
|
+
* Open the Oauth window in the same tab
|
58
|
+
* ```ts
|
59
|
+
* import { inAppWallet } from "thirdweb/wallets";
|
60
|
+
* const wallet = inAppWallet({
|
61
|
+
* auth: {
|
62
|
+
* mode: "redirect"
|
63
|
+
* }
|
64
|
+
* });
|
65
|
+
* ```
|
56
66
|
* @wallet
|
57
67
|
*/
|
58
68
|
export function inAppWallet(
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import type { ThirdwebClient } from "../../../../../client/client.js";
|
2
|
+
import type { OneOf } from "../../../../../utils/type-utils.js";
|
3
|
+
import type { SocialAuthOption } from "../../../../../wallets/types.js";
|
2
4
|
import {
|
3
5
|
type AuthArgsType,
|
4
|
-
type AuthLoginReturnType,
|
5
6
|
type GetAuthenticatedUserParams,
|
6
7
|
type PreAuthArgsType,
|
7
8
|
UserWalletStatus,
|
@@ -143,8 +144,18 @@ export async function preAuthenticate(args: PreAuthArgsType) {
|
|
143
144
|
* @wallet
|
144
145
|
*/
|
145
146
|
export async function authenticate(
|
146
|
-
args:
|
147
|
-
|
147
|
+
args: OneOf<
|
148
|
+
| AuthArgsType
|
149
|
+
| {
|
150
|
+
strategy: SocialAuthOption;
|
151
|
+
client: ThirdwebClient;
|
152
|
+
ecosystem?: Ecosystem;
|
153
|
+
redirect: boolean;
|
154
|
+
}
|
155
|
+
>,
|
156
|
+
) {
|
148
157
|
const connector = await getInAppWalletConnector(args.client, args.ecosystem);
|
158
|
+
if (args.redirect && connector.authenticateWithRedirect)
|
159
|
+
return connector.authenticateWithRedirect(args.strategy);
|
149
160
|
return connector.authenticate(args);
|
150
161
|
}
|
@@ -40,6 +40,18 @@ export const getSocialAuthLoginPath = (
|
|
40
40
|
return baseUrl;
|
41
41
|
};
|
42
42
|
|
43
|
+
export const loginWithOauthRedirect = (options: {
|
44
|
+
authOption: SocialAuthOption;
|
45
|
+
client: ThirdwebClient;
|
46
|
+
ecosystem?: Ecosystem;
|
47
|
+
}): void => {
|
48
|
+
const redirectUrl = new URL(window.location.href);
|
49
|
+
redirectUrl.searchParams.set("walletId", options.ecosystem?.id || "inApp");
|
50
|
+
redirectUrl.searchParams.set("authProvider", options.authOption);
|
51
|
+
const loginUrl = `${getSocialAuthLoginPath(options.authOption, options.client, options.ecosystem)}&redirectUrl=${encodeURIComponent(redirectUrl.toString())}`;
|
52
|
+
window.location.href = loginUrl;
|
53
|
+
};
|
54
|
+
|
43
55
|
export const loginWithOauth = async (options: {
|
44
56
|
authOption: SocialAuthOption;
|
45
57
|
client: ThirdwebClient;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import type { AuthOption } from "../../../../wallets/types.js";
|
2
|
+
import type { WalletId } from "../../../wallet-types.js";
|
3
|
+
import type { AuthStoredTokenWithCookieReturnType } from "../../core/authentication/type.js";
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Checks for an auth token and associated metadata in the current URL
|
7
|
+
*/
|
8
|
+
export function getUrlToken(): {
|
9
|
+
walletId?: WalletId;
|
10
|
+
authResult?: AuthStoredTokenWithCookieReturnType;
|
11
|
+
authProvider?: AuthOption;
|
12
|
+
} {
|
13
|
+
if (!window) {
|
14
|
+
throw new Error("Attempted to fetch a URL token on the server");
|
15
|
+
}
|
16
|
+
|
17
|
+
const queryString = window.location.search;
|
18
|
+
const params = new URLSearchParams(queryString);
|
19
|
+
const authResultString = params.get("authResult");
|
20
|
+
const walletId = params.get("walletId") as WalletId | undefined;
|
21
|
+
const authProvider = params.get("authProvider") as AuthOption | undefined;
|
22
|
+
|
23
|
+
if (authResultString && walletId) {
|
24
|
+
const authResult = JSON.parse(authResultString);
|
25
|
+
params.delete("authResult");
|
26
|
+
params.delete("walletId");
|
27
|
+
params.delete("authProvider");
|
28
|
+
window.history.pushState(
|
29
|
+
{},
|
30
|
+
"",
|
31
|
+
`${window.location.pathname}?${params.toString()}`,
|
32
|
+
);
|
33
|
+
return { walletId, authResult, authProvider };
|
34
|
+
}
|
35
|
+
return {};
|
36
|
+
}
|