@magic-ext/wallet-kit 0.1.0 → 0.2.0

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.
Files changed (76) hide show
  1. package/LICENSE +177 -0
  2. package/dist/es/index.mjs +1 -0
  3. package/dist/es/types/MagicWidget.d.ts +3 -0
  4. package/dist/es/types/components/EmailInput.d.ts +2 -0
  5. package/dist/es/types/components/Pending.d.ts +11 -0
  6. package/dist/es/types/components/ProviderButton.d.ts +9 -0
  7. package/dist/es/types/components/SocialProviders.d.ts +10 -0
  8. package/dist/es/types/components/WidgetHeader.d.ts +7 -0
  9. package/dist/es/types/constants.d.ts +3 -0
  10. package/dist/es/types/context/EmailLoginContext.d.ts +24 -0
  11. package/dist/es/types/context/WidgetConfigContext.d.ts +22 -0
  12. package/dist/es/types/context/index.d.ts +2 -0
  13. package/dist/es/types/extension.d.ts +190 -0
  14. package/dist/es/types/hooks/useMediaQuery.d.ts +1 -0
  15. package/dist/es/types/hooks/useOAuthLogin.d.ts +9 -0
  16. package/dist/es/types/hooks/useSiweLogin.d.ts +8 -0
  17. package/dist/es/types/hooks/useWalletConnect.d.ts +11 -0
  18. package/dist/es/types/index.d.ts +3 -0
  19. package/dist/es/types/lib/provider-config.d.ts +2 -0
  20. package/dist/es/types/lib/validators.d.ts +2 -0
  21. package/dist/es/types/reducer.d.ts +69 -0
  22. package/dist/es/types/types/client-config.d.ts +22 -0
  23. package/dist/es/types/types.d.ts +168 -0
  24. package/dist/es/types/utils/device.d.ts +5 -0
  25. package/dist/es/types/views/AdditionalProvidersView.d.ts +7 -0
  26. package/dist/es/types/views/DeviceVerificationView.d.ts +8 -0
  27. package/dist/es/types/views/EmailOTPView.d.ts +8 -0
  28. package/dist/es/types/views/LoginSuccessView.d.ts +7 -0
  29. package/dist/es/types/views/LoginView.d.ts +7 -0
  30. package/dist/es/types/views/LostRecoveryCode.d.ts +5 -0
  31. package/dist/es/types/views/MfaView.d.ts +8 -0
  32. package/dist/es/types/views/OAuthPendingView.d.ts +9 -0
  33. package/dist/es/types/views/RecoveryCode.d.ts +8 -0
  34. package/dist/es/types/views/WalletConnectView.d.ts +7 -0
  35. package/dist/es/types/views/WalletPendingView.d.ts +10 -0
  36. package/dist/es/types/wagmi/config.d.ts +8 -0
  37. package/dist/es/types/wagmi/connectors.d.ts +9 -0
  38. package/dist/es/types/wagmi/walletconnect-provider.d.ts +3 -0
  39. package/dist/styles.css +1 -0
  40. package/dist/types/MagicWidget.d.ts +3 -0
  41. package/dist/types/components/EmailInput.d.ts +2 -0
  42. package/dist/types/components/Pending.d.ts +11 -0
  43. package/dist/types/components/ProviderButton.d.ts +9 -0
  44. package/dist/types/components/SocialProviders.d.ts +10 -0
  45. package/dist/types/components/WidgetHeader.d.ts +7 -0
  46. package/dist/types/constants.d.ts +3 -0
  47. package/dist/types/context/EmailLoginContext.d.ts +24 -0
  48. package/dist/types/context/WidgetConfigContext.d.ts +22 -0
  49. package/dist/types/context/index.d.ts +2 -0
  50. package/dist/types/extension.d.ts +190 -0
  51. package/dist/types/hooks/useMediaQuery.d.ts +1 -0
  52. package/dist/types/hooks/useOAuthLogin.d.ts +9 -0
  53. package/dist/types/hooks/useSiweLogin.d.ts +8 -0
  54. package/dist/types/hooks/useWalletConnect.d.ts +11 -0
  55. package/dist/types/index.d.ts +3 -0
  56. package/dist/types/lib/provider-config.d.ts +2 -0
  57. package/dist/types/lib/validators.d.ts +2 -0
  58. package/dist/types/reducer.d.ts +69 -0
  59. package/dist/types/types/client-config.d.ts +22 -0
  60. package/dist/types/types.d.ts +168 -0
  61. package/dist/types/utils/device.d.ts +5 -0
  62. package/dist/types/views/AdditionalProvidersView.d.ts +7 -0
  63. package/dist/types/views/DeviceVerificationView.d.ts +8 -0
  64. package/dist/types/views/EmailOTPView.d.ts +8 -0
  65. package/dist/types/views/LoginSuccessView.d.ts +7 -0
  66. package/dist/types/views/LoginView.d.ts +7 -0
  67. package/dist/types/views/LostRecoveryCode.d.ts +5 -0
  68. package/dist/types/views/MfaView.d.ts +8 -0
  69. package/dist/types/views/OAuthPendingView.d.ts +9 -0
  70. package/dist/types/views/RecoveryCode.d.ts +8 -0
  71. package/dist/types/views/WalletConnectView.d.ts +7 -0
  72. package/dist/types/views/WalletPendingView.d.ts +10 -0
  73. package/dist/types/wagmi/config.d.ts +8 -0
  74. package/dist/types/wagmi/connectors.d.ts +9 -0
  75. package/dist/types/wagmi/walletconnect-provider.d.ts +3 -0
  76. package/package.json +80 -2
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { MagicWidgetProps } from './types';
3
+ export declare function MagicWidget({ displayMode, isOpen, onClose, closeOnSuccess, closeOnClickOutside, wallets, onSuccess, onError, onReady, }: MagicWidgetProps): React.JSX.Element | null;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const EmailInput: () => React.JSX.Element;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ interface PendingProps {
3
+ onPressBack: () => void;
4
+ title: string;
5
+ description: string;
6
+ Icon: React.ElementType;
7
+ isPending: boolean;
8
+ errorMessage: string | null;
9
+ }
10
+ export declare const Pending: ({ onPressBack, title, description, Icon, isPending, errorMessage }: PendingProps) => React.JSX.Element;
11
+ export {};
@@ -0,0 +1,9 @@
1
+ import React, { ElementType } from 'react';
2
+ interface ProviderButtonProps {
3
+ label?: string;
4
+ Icon: ElementType;
5
+ onPress: () => void;
6
+ hideLabel?: boolean;
7
+ }
8
+ export declare const ProviderButton: ({ label, Icon, onPress, hideLabel }: ProviderButtonProps) => React.JSX.Element;
9
+ export {};
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { OAuthProvider } from '../types';
3
+ import { WidgetAction } from 'src/reducer';
4
+ interface SocialProvidersProps {
5
+ providers: OAuthProvider[];
6
+ onPress: (provider: OAuthProvider) => void;
7
+ dispatch: React.Dispatch<WidgetAction>;
8
+ }
9
+ export declare const SocialProviders: ({ providers, onPress, dispatch }: SocialProvidersProps) => React.JSX.Element;
10
+ export {};
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ type WidgetHeaderProps = {
3
+ showHeaderText?: boolean;
4
+ onPressBack?: () => void;
5
+ };
6
+ export default function WidgetHeader({ showHeaderText, onPressBack }: WidgetHeaderProps): React.JSX.Element;
7
+ export {};
@@ -0,0 +1,3 @@
1
+ import { OAuthProvider, ProviderMetadata, ThirdPartyWallet } from './types';
2
+ export declare const WALLET_METADATA: Record<ThirdPartyWallet, ProviderMetadata>;
3
+ export declare const OAUTH_METADATA: Record<OAuthProvider, ProviderMetadata>;
@@ -0,0 +1,24 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { WidgetAction } from '../reducer';
3
+ interface EmailLoginContextValue {
4
+ startEmailLogin: (email: string) => void;
5
+ submitOTP: (otp: string) => void;
6
+ submitMFA: (totp: string) => void;
7
+ lostDevice: () => void;
8
+ submitRecoveryCode: (recoveryCode: string) => void;
9
+ cancelLogin: () => void;
10
+ retryDeviceVerification: () => void;
11
+ resendEmailOTP: () => void;
12
+ email: string | null;
13
+ }
14
+ interface EmailLoginProviderProps {
15
+ children: ReactNode;
16
+ dispatch: React.Dispatch<WidgetAction>;
17
+ }
18
+ export declare function EmailLoginProvider({ children, dispatch }: EmailLoginProviderProps): React.JSX.Element;
19
+ /**
20
+ * Hook to access the email login context
21
+ * @throws Error if used outside of EmailLoginProvider
22
+ */
23
+ export declare function useEmailLogin(): EmailLoginContextValue;
24
+ export {};
@@ -0,0 +1,22 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { LoginResult, MagicWidgetProps, ThirdPartyWallet } from '../types';
3
+ interface WidgetConfigContextValue {
4
+ /** Third-party wallets to display */
5
+ wallets: ThirdPartyWallet[];
6
+ /** Call when login succeeds */
7
+ handleSuccess: (result: LoginResult) => void;
8
+ /** Call when login fails */
9
+ handleError: (error: Error) => void;
10
+ /** Call to close the widget. Undefined if onClose prop wasn't provided. */
11
+ handleClose?: () => void;
12
+ }
13
+ interface WidgetConfigProviderProps extends MagicWidgetProps {
14
+ children: ReactNode;
15
+ }
16
+ export declare function WidgetConfigProvider({ children, wallets, onSuccess, onError, onClose, closeOnSuccess, }: WidgetConfigProviderProps): React.JSX.Element;
17
+ /**
18
+ * Hook to access the widget configuration
19
+ * @throws Error if used outside of WidgetConfigProvider
20
+ */
21
+ export declare function useWidgetConfig(): WidgetConfigContextValue;
22
+ export {};
@@ -0,0 +1,2 @@
1
+ export { EmailLoginProvider, useEmailLogin } from './EmailLoginContext';
2
+ export { WidgetConfigProvider, useWidgetConfig } from './WidgetConfigContext';
@@ -0,0 +1,190 @@
1
+ import { Extension, SDKBase } from '@magic-sdk/provider';
2
+ import { JsonRpcRequestPayload } from '@magic-sdk/types';
3
+ import type { Config } from '@wagmi/core';
4
+ import type { WagmiAdapter } from '@reown/appkit-adapter-wagmi';
5
+ import { ClientConfig } from './types/client-config';
6
+ export declare const MAGIC_WIDGET_PROVIDER = "magic-widget";
7
+ export type OAuthProvider = 'google' | 'facebook' | 'apple' | 'github' | 'bitbucket' | 'gitlab' | 'linkedin' | 'twitter' | 'discord' | 'twitch' | 'microsoft';
8
+ export interface OpenIDConnectUserInfo {
9
+ name?: string;
10
+ familyName?: string;
11
+ givenName?: string;
12
+ middleName?: string;
13
+ nickname?: string;
14
+ preferredUsername?: string;
15
+ profile?: string;
16
+ picture?: string;
17
+ website?: string;
18
+ email?: string;
19
+ emailVerified?: boolean;
20
+ gender?: string;
21
+ birthdate?: string;
22
+ zoneinfo?: string;
23
+ locale?: string;
24
+ phoneNumber?: string;
25
+ phoneNumberVerified?: boolean;
26
+ sub?: string;
27
+ sources?: Record<string, unknown>;
28
+ [key: string]: unknown;
29
+ }
30
+ export interface MagicUserMetadata {
31
+ issuer: string | null;
32
+ publicAddress: string | null;
33
+ email: string | null;
34
+ phoneNumber?: string | null;
35
+ isMfaEnabled?: boolean;
36
+ recoveryFactors?: Array<{
37
+ type: string;
38
+ value: string;
39
+ }>;
40
+ }
41
+ export interface OAuthRedirectResult {
42
+ oauth: {
43
+ provider: OAuthProvider;
44
+ scope: string[];
45
+ userHandle: string;
46
+ userInfo: OpenIDConnectUserInfo;
47
+ };
48
+ magic: {
49
+ idToken: string;
50
+ userMetadata: MagicUserMetadata;
51
+ };
52
+ }
53
+ export interface OAuthRedirectError {
54
+ provider: OAuthProvider;
55
+ error: string;
56
+ error_description?: string;
57
+ error_uri?: string;
58
+ }
59
+ export interface SiweGenerateNonceParams {
60
+ address?: string;
61
+ }
62
+ export interface SiweGenerateMessageParams {
63
+ address: string;
64
+ chainId?: number;
65
+ statement?: string;
66
+ }
67
+ export interface SiweLoginParams {
68
+ message: string;
69
+ signature: string;
70
+ }
71
+ /**
72
+ * Get the initialized WalletKitExtension instance.
73
+ * Used internally by React components to access SIWE methods.
74
+ * @throws Error if extension hasn't been initialized yet
75
+ */
76
+ export declare function getExtensionInstance(): WalletKitExtension;
77
+ export interface WalletKitExtensionOptions {
78
+ /** Reown (WalletConnect) project ID. Uses a default if not provided. */
79
+ projectId?: string;
80
+ }
81
+ export declare class WalletKitExtension extends Extension.Internal<'walletKit'> {
82
+ name: "walletKit";
83
+ config: {};
84
+ readonly projectId: string;
85
+ readonly wagmiConfig: Config;
86
+ readonly wagmiAdapter: WagmiAdapter;
87
+ private clientConfig;
88
+ private configPromise;
89
+ private eventsListenerAdded;
90
+ private reconnectPromise;
91
+ constructor(options?: WalletKitExtensionOptions);
92
+ /**
93
+ * Called by Magic SDK when the extension is initialized.
94
+ * We override to store a reference for internal React component access.
95
+ */
96
+ init(sdk: SDKBase): void;
97
+ private restoreWalletConnection;
98
+ /**
99
+ * Set up the connected state after successful SIWE login.
100
+ * This enables RPC request routing through the 3rd party wallet.
101
+ */
102
+ setConnectedState(address: string, chainId?: number): void;
103
+ /**
104
+ * Clear the connected state (called on logout/disconnect).
105
+ */
106
+ clearConnectedState(): void;
107
+ /**
108
+ * Get the current wallet provider from wagmi.
109
+ * Returns null if not connected.
110
+ */
111
+ getWalletProvider(): Promise<any | null>;
112
+ /**
113
+ * Execute an RPC request through the connected 3rd party wallet.
114
+ * This is called by ThirdPartyWalletsModule for magic-widget provider.
115
+ */
116
+ walletRequest<T = unknown>(payload: Partial<JsonRpcRequestPayload>): Promise<T>;
117
+ /**
118
+ * Set up event listeners for account and chain changes.
119
+ */
120
+ private setupEip1193EventListeners;
121
+ /**
122
+ * Handle wallet disconnect - clear SDK state AND invalidate Magic iframe session.
123
+ * Called when user disconnects wallet via wallet extension UI.
124
+ */
125
+ private handleWalletDisconnect;
126
+ private dispatchWalletUpdate;
127
+ /**
128
+ * Generate a nonce for SIWE message construction.
129
+ * This calls the Magic backend to get a unique nonce.
130
+ */
131
+ generateNonce(params?: SiweGenerateNonceParams): Promise<string>;
132
+ /**
133
+ * Generate a complete SIWE message.
134
+ * Fetches a nonce from the backend and constructs the message client-side.
135
+ */
136
+ generateMessage(params: SiweGenerateMessageParams): Promise<string>;
137
+ /**
138
+ * Login with SIWE message and signature.
139
+ * Sends the signed message to Magic backend for verification and returns a DID token.
140
+ */
141
+ login(params: SiweLoginParams): Promise<string>;
142
+ /**
143
+ * Login with OAuth popup.
144
+ * Opens a popup for the specified OAuth provider and returns the result.
145
+ */
146
+ loginWithPopup(provider: OAuthProvider): Promise<OAuthRedirectResult>;
147
+ /**
148
+ * Fetch client configuration via RPC (proxied through embedded-wallet iframe).
149
+ * This avoids CORS issues by having the iframe make the request.
150
+ */
151
+ fetchConfig(): Promise<ClientConfig>;
152
+ /**
153
+ * Get the cached client configuration (synchronous).
154
+ * Returns null if config hasn't been fetched yet.
155
+ */
156
+ getConfig(): ClientConfig | null;
157
+ /**
158
+ * Login with Email OTP
159
+ */
160
+ loginWithEmailOTP(email: string): import("@magic-sdk/provider").PromiEvent<string | null, {
161
+ "email-otp-sent": () => void;
162
+ "login-throttled": () => void;
163
+ "invalid-email-otp": () => void;
164
+ "invalid-mfa-otp": () => void;
165
+ "expired-email-otp": () => void;
166
+ "mfa-sent-handle": () => void;
167
+ "recovery-code-sent-handle": () => void;
168
+ "invalid-recovery-code": () => void;
169
+ "recovery-code-success": () => void;
170
+ "max-attempts-reached": () => void;
171
+ "Auth/id-token-created": (idToken: string) => void;
172
+ "Wallet/wallet-info-fetched": () => void;
173
+ "verify-email-otp": (otp: string) => void;
174
+ "verify-mfa-code": (mfa: string) => void;
175
+ "lost-device": () => void;
176
+ "verify-recovery-code": (recoveryCode: string) => void;
177
+ cancel: () => void;
178
+ } & {
179
+ "device-needs-approval": () => void;
180
+ "device-verification-email-sent": () => void;
181
+ "device-verification-link-expired": () => void;
182
+ "device-approved": () => void;
183
+ "device-retry": () => void;
184
+ } & {
185
+ done: (result: string | null) => void;
186
+ error: (reason: any) => void;
187
+ settled: () => void;
188
+ "closed-by-user": () => void;
189
+ }>;
190
+ }
@@ -0,0 +1 @@
1
+ export declare function useMediaQuery(query: string): boolean;
@@ -0,0 +1,9 @@
1
+ import { OAuthProvider, OAuthRedirectResult } from '../extension';
2
+ export interface UseOAuthLoginResult {
3
+ performOAuthLogin: (provider: OAuthProvider) => Promise<OAuthRedirectResult>;
4
+ isLoading: boolean;
5
+ error: Error | null;
6
+ isSuccess: boolean;
7
+ result: OAuthRedirectResult | null;
8
+ }
9
+ export declare function useOAuthLogin(): UseOAuthLoginResult;
@@ -0,0 +1,8 @@
1
+ export interface UseSiweLoginResult {
2
+ performSiweLogin: (address: string, chainId?: number) => Promise<string>;
3
+ isLoading: boolean;
4
+ error: Error | null;
5
+ isSuccess: boolean;
6
+ walletAddress: string | null;
7
+ }
8
+ export declare function useSiweLogin(): UseSiweLoginResult;
@@ -0,0 +1,11 @@
1
+ import { ThirdPartyWallet } from '../types';
2
+ export interface UseWalletConnectResult {
3
+ connectWallet: () => Promise<void>;
4
+ isPending: boolean;
5
+ error: Error | null;
6
+ address: `0x${string}` | undefined;
7
+ isConnected: boolean;
8
+ isConnectedToSelectedProvider: boolean;
9
+ disconnect: () => void;
10
+ }
11
+ export declare function useWalletConnect(provider: ThirdPartyWallet): UseWalletConnectResult;
@@ -0,0 +1,3 @@
1
+ export * from './MagicWidget';
2
+ export * from './extension';
3
+ export { ThirdPartyWallets, OAuthProvider, type ThirdPartyWallet, type DisplayMode, type MagicWidgetProps, type LoginResult, type EmailLoginResult, type OAuthLoginResult, type WalletLoginResult, type OAuthUserInfo, } from './types';
@@ -0,0 +1,2 @@
1
+ import { LoginProvider, ProviderConfig } from '../types';
2
+ export declare function getProviderConfig(provider: LoginProvider): ProviderConfig;
@@ -0,0 +1,2 @@
1
+ export declare function isSanctionedEmail(email: string): boolean;
2
+ export declare function isValidEmail(source?: string | null): boolean;
@@ -0,0 +1,69 @@
1
+ import { LoginProvider, OAuthProvider, ThirdPartyWallet } from './types';
2
+ export type View = 'login' | 'otp' | 'additional_providers' | 'wallet_pending' | 'walletconnect_pending' | 'oauth_pending' | 'email_otp_pending' | 'device_verification' | 'mfa_pending' | 'recovery_code' | 'lost_recovery_code' | 'login_success';
3
+ export type EmailLoginStatus = 'idle' | 'sending' | 'otp_sent' | 'verifying_otp' | 'invalid_otp' | 'expired_otp' | 'max_attempts_reached' | 'device_needs_approval' | 'device_verification_sent' | 'device_verification_expired' | 'device_approved' | 'mfa_required' | 'recovery_code' | 'success' | 'mfa_verifying' | 'mfa_invalid' | 'recovery_code_verifying' | 'lost_recovery_code' | 'error';
4
+ export interface WidgetState {
5
+ view: View;
6
+ email?: string;
7
+ selectedProvider?: LoginProvider;
8
+ walletAddress?: string;
9
+ error?: string;
10
+ emailLoginStatus?: EmailLoginStatus;
11
+ }
12
+ export type WidgetAction = {
13
+ type: 'GO_TO_LOGIN';
14
+ } | {
15
+ type: 'EMAIL_OTP_START';
16
+ email: string;
17
+ } | {
18
+ type: 'EMAIL_OTP_SENT';
19
+ } | {
20
+ type: 'EMAIL_OTP_INVALID';
21
+ } | {
22
+ type: 'EMAIL_OTP_EXPIRED';
23
+ } | {
24
+ type: 'EMAIL_OTP_MAX_ATTEMPTS_REACHED';
25
+ } | {
26
+ type: 'EMAIL_OTP_VERIFYING';
27
+ } | {
28
+ type: 'DEVICE_NEEDS_APPROVAL';
29
+ } | {
30
+ type: 'DEVICE_VERIFICATION_SENT';
31
+ } | {
32
+ type: 'DEVICE_VERIFICATION_EXPIRED';
33
+ } | {
34
+ type: 'DEVICE_APPROVED';
35
+ } | {
36
+ type: 'MFA_REQUIRED';
37
+ } | {
38
+ type: 'MFA_VERIFYING';
39
+ } | {
40
+ type: 'MFA_INVALID';
41
+ } | {
42
+ type: 'LOST_DEVICE';
43
+ } | {
44
+ type: 'RECOVERY_CODE_VERIFYING';
45
+ } | {
46
+ type: 'RECOVERY_CODE_INVALID';
47
+ } | {
48
+ type: 'LOST_RECOVERY_CODE';
49
+ } | {
50
+ type: 'LOGIN_SUCCESS';
51
+ } | {
52
+ type: 'RESET_EMAIL_ERROR';
53
+ } | {
54
+ type: 'LOGIN_ERROR';
55
+ error: string;
56
+ } | {
57
+ type: 'SELECT_PROVIDER';
58
+ provider: OAuthProvider;
59
+ } | {
60
+ type: 'GO_TO_ADDITIONAL_PROVIDERS';
61
+ } | {
62
+ type: 'SELECT_WALLET';
63
+ provider: ThirdPartyWallet;
64
+ } | {
65
+ type: 'WALLETCONNECT_CONNECTED';
66
+ address: string;
67
+ };
68
+ export declare const initialState: WidgetState;
69
+ export declare function widgetReducer(state: WidgetState, action: WidgetAction): WidgetState;
@@ -0,0 +1,22 @@
1
+ export interface ClientTheme {
2
+ appName: string;
3
+ assetUri: string;
4
+ textColor: `#${string}`;
5
+ buttonColor: `#${string}` | undefined;
6
+ buttonRadius: string | undefined;
7
+ containerRadius: string | undefined;
8
+ backgroundColor: `#${string}` | undefined;
9
+ neutralColor: `#${string}` | undefined;
10
+ themeColor: 'auto' | 'dark' | 'light';
11
+ customBrandingType: 1 | 2;
12
+ isDefaultAsset?: boolean;
13
+ }
14
+ export interface ClientConfig {
15
+ clientId: string;
16
+ theme: ClientTheme;
17
+ authProviders: {
18
+ primary: string[];
19
+ secondary: string[];
20
+ social: string[];
21
+ };
22
+ }
@@ -0,0 +1,168 @@
1
+ import { ComponentType } from 'react';
2
+ import { OAuthRedirectResult } from './extension';
3
+ /**
4
+ * Available third-party wallet providers.
5
+ * Use these constants or pass string literals directly: 'metamask', 'coinbase', etc.
6
+ */
7
+ export declare const ThirdPartyWallets: {
8
+ readonly METAMASK: "metamask";
9
+ readonly WALLETCONNECT: "walletconnect";
10
+ readonly COINBASE: "coinbase";
11
+ readonly PHANTOM: "phantom";
12
+ readonly RABBY: "rabby";
13
+ };
14
+ /** Type representing valid third-party wallet values */
15
+ export type ThirdPartyWallet = (typeof ThirdPartyWallets)[keyof typeof ThirdPartyWallets];
16
+ export interface ProviderMetadata {
17
+ displayName: string;
18
+ Icon: ComponentType<{
19
+ width?: number;
20
+ height?: number;
21
+ className?: string;
22
+ }>;
23
+ }
24
+ export declare enum RpcErrorMessage {
25
+ MalformedEmail = "Invalid params: Please provide a valid email address.",
26
+ SanEmail = "We are unable to create an account with that email."
27
+ }
28
+ export declare enum OAuthProvider {
29
+ GOOGLE = "google",
30
+ APPLE = "apple",
31
+ FACEBOOK = "facebook",
32
+ GITHUB = "github",
33
+ TWITTER = "twitter",
34
+ LINKEDIN = "linkedin",
35
+ MICROSOFT = "microsoft",
36
+ TWITCH = "twitch",
37
+ BITBUCKET = "bitbucket",
38
+ DISCORD = "discord",
39
+ GITLAB = "gitlab",
40
+ TELEGRAM = "telegram"
41
+ }
42
+ export type LoginProvider = OAuthProvider | ThirdPartyWallet;
43
+ export interface ProviderConfig {
44
+ title: string;
45
+ description: string;
46
+ Icon: ComponentType<{
47
+ width?: number;
48
+ height?: number;
49
+ className?: string;
50
+ }>;
51
+ }
52
+ /**
53
+ * OAuth user information returned from social login
54
+ */
55
+ export interface OAuthUserInfo {
56
+ /** The OAuth provider used (e.g., 'google', 'apple') */
57
+ provider: string;
58
+ name?: string;
59
+ email?: string;
60
+ picture?: string;
61
+ [key: string]: unknown;
62
+ }
63
+ /**
64
+ * Result returned on successful email login
65
+ */
66
+ export interface EmailLoginResult {
67
+ method: 'email';
68
+ /** The DID token for authentication */
69
+ didToken: string;
70
+ }
71
+ /**
72
+ * Result returned on successful OAuth login
73
+ */
74
+ export interface OAuthLoginResult {
75
+ method: 'oauth';
76
+ /** OAuth provider information */
77
+ oauth: OAuthRedirectResult['oauth'];
78
+ /** Magic user metadata */
79
+ magic: OAuthRedirectResult['magic'];
80
+ }
81
+ /**
82
+ * Result returned on successful wallet login
83
+ */
84
+ export interface WalletLoginResult {
85
+ method: 'wallet';
86
+ /** The connected wallet address */
87
+ walletAddress: string;
88
+ }
89
+ /**
90
+ * Discriminated union of all login result types.
91
+ * Check the `method` property to determine which fields are available.
92
+ *
93
+ * @example
94
+ * onSuccess={(result) => {
95
+ * if (result.method === 'email' || result.method === 'oauth') {
96
+ * sendToBackend(result.didToken);
97
+ * } else {
98
+ * console.log('Wallet:', result.walletAddress);
99
+ * }
100
+ * }}
101
+ */
102
+ export type LoginResult = EmailLoginResult | OAuthLoginResult | WalletLoginResult;
103
+ /**
104
+ * How the widget is displayed on the page.
105
+ * - 'inline': Rendered in the document flow (default)
106
+ * - 'modal': Positioned as a modal dialog, slightly above center
107
+ */
108
+ export type DisplayMode = 'inline' | 'modal';
109
+ export interface MagicWidgetProps {
110
+ /**
111
+ * How the widget is displayed on the page. Defaults to 'inline'.
112
+ * - 'inline': Rendered in the document flow
113
+ * - 'modal': Positioned as a modal dialog with backdrop
114
+ * @example displayMode="modal"
115
+ */
116
+ displayMode?: DisplayMode;
117
+ /**
118
+ * Whether the widget modal is open. Defaults to true.
119
+ * @example isOpen={showLogin}
120
+ */
121
+ isOpen?: boolean;
122
+ /**
123
+ * Callback fired when the widget is closed (e.g., user clicks X button).
124
+ * @example onClose={() => setShowLogin(false)}
125
+ */
126
+ onClose?: () => void;
127
+ /**
128
+ * Automatically call onClose after successful login (with a 2 second delay to show success screen).
129
+ * Defaults to false.
130
+ * @example closeOnSuccess={true}
131
+ */
132
+ closeOnSuccess?: boolean;
133
+ /**
134
+ * Close the modal when clicking the backdrop. Only applies when displayMode="modal".
135
+ * Defaults to false.
136
+ * @example closeOnClickOutside={true}
137
+ */
138
+ closeOnClickOutside?: boolean;
139
+ /**
140
+ * Third-party wallets to display. None enabled by default.
141
+ * Accepts constants or string literals: 'metamask', 'walletconnect', 'coinbase', 'phantom', 'rabby'
142
+ * @example wallets={['metamask', 'coinbase']}
143
+ * @example wallets={[ThirdPartyWallets.METAMASK, ThirdPartyWallets.COINBASE]}
144
+ */
145
+ wallets?: ThirdPartyWallet[];
146
+ /**
147
+ * Callback fired when login succeeds.
148
+ * The result type varies by login method - check `result.method` to determine the shape.
149
+ * @example
150
+ * onSuccess={(result) => {
151
+ * if (result.method === 'email' || result.method === 'oauth') {
152
+ * authenticate(result.didToken);
153
+ * }
154
+ * }}
155
+ */
156
+ onSuccess?: (result: LoginResult) => void;
157
+ /**
158
+ * Callback fired when login fails
159
+ * @example onError={(error) => console.error(error.message)}
160
+ */
161
+ onError?: (error: Error) => void;
162
+ /**
163
+ * Callback fired when the widget has finished initializing and is ready to display.
164
+ * Use this to hide your custom loading UI.
165
+ * @example onReady={() => setIsLoading(false)}
166
+ */
167
+ onReady?: () => void;
168
+ }
@@ -0,0 +1,5 @@
1
+ export declare function isAndroid(): boolean;
2
+ export declare function isSmallIOS(): boolean;
3
+ export declare function isLargeIOS(): boolean;
4
+ export declare function isIOS(): boolean;
5
+ export declare function isMobile(): boolean;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { WidgetAction } from 'src/reducer';
3
+ interface AdditionalProvidersViewProps {
4
+ dispatch: React.Dispatch<WidgetAction>;
5
+ }
6
+ export default function AdditionalProvidersView({ dispatch }: AdditionalProvidersViewProps): React.JSX.Element;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { WidgetAction, WidgetState } from '../reducer';
3
+ interface DeviceVerificationViewProps {
4
+ state: WidgetState;
5
+ dispatch: React.Dispatch<WidgetAction>;
6
+ }
7
+ export declare const DeviceVerificationView: ({ state, dispatch }: DeviceVerificationViewProps) => React.JSX.Element;
8
+ export {};
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { WidgetAction, WidgetState } from '../reducer';
3
+ interface EmailOTPViewProps {
4
+ state: WidgetState;
5
+ dispatch: React.Dispatch<WidgetAction>;
6
+ }
7
+ export declare const EmailOTPView: ({ state, dispatch }: EmailOTPViewProps) => React.JSX.Element;
8
+ export {};
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { WidgetState } from '../reducer';
3
+ interface LoginSuccessViewProps {
4
+ state: WidgetState;
5
+ }
6
+ export declare const LoginSuccessView: ({ state }: LoginSuccessViewProps) => React.JSX.Element;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { WidgetAction } from '../reducer';
3
+ interface LoginViewProps {
4
+ dispatch: React.Dispatch<WidgetAction>;
5
+ }
6
+ export declare const LoginView: ({ dispatch }: LoginViewProps) => React.JSX.Element;
7
+ export {};
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { WidgetAction } from '../reducer';
3
+ export declare const LostRecoveryCode: ({ dispatch }: {
4
+ dispatch: React.Dispatch<WidgetAction>;
5
+ }) => React.JSX.Element;