-
Notifications
You must be signed in to change notification settings - Fork 236
/
types.ts
82 lines (69 loc) · 1.89 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import type { Chain } from "@thirdweb-dev/chains";
import { AuthAndWalletRpcReturnType, InitializedUser } from "./implementations";
export type EmbeddedWalletAdditionalOptions = {
chain: Pick<Chain, "chainId" | "rpc">;
clientId: string;
onAuthSuccess?: (authResult: AuthAndWalletRpcReturnType) => void;
};
export interface EmbeddedWalletConnectorOptions {
clientId: string;
chains: Chain[];
chain: Pick<Chain, "chainId" | "rpc">;
onAuthSuccess?: (authResult: AuthAndWalletRpcReturnType) => void;
}
export type EmbeddedWalletConnectionArgs = {
chainId?: number;
authResult: AuthResult;
};
type EmailVerificationAuthParams = {
strategy: "email_verification";
email: string;
verificationCode: string;
recoveryCode?: string;
};
type SmsVerificationAuthParams = {
strategy: "phone_number_verification";
phoneNumber: string;
verificationCode: string;
recoveryCode?: string;
};
export type EmbeddedWalletOauthStrategy = "google" | "apple" | "facebook";
type OauthAuthParams = {
strategy: EmbeddedWalletOauthStrategy;
openedWindow?: Window;
closeOpenedWindow?: (window: Window) => void;
};
type JwtAuthParams = {
strategy: "jwt";
jwt: string;
encryptionKey: string;
};
type AuthEndpointParams = {
strategy: "auth_endpoint";
payload: string;
encryptionKey: string;
};
// open iFrame to send and input the OTP
type IframeOtpAuthParams = {
strategy: "iframe_email_verification";
email: string;
};
// open iFrame to enter email and OTP
type IframeAuthParams = {
strategy: "iframe";
};
// this is the input to 'authenticate'
export type AuthParams =
| EmailVerificationAuthParams
| SmsVerificationAuthParams
| OauthAuthParams
| JwtAuthParams
| AuthEndpointParams
| IframeOtpAuthParams
| IframeAuthParams;
// TODO typed based off AuthParams["strategy"]
export type AuthResult = {
user?: InitializedUser;
isNewUser?: boolean;
needsRecoveryCode?: boolean;
};