@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,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;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { WidgetAction, WidgetState } from '../reducer';
3
+ interface MFAViewProps {
4
+ state: WidgetState;
5
+ dispatch: React.Dispatch<WidgetAction>;
6
+ }
7
+ export declare const MFAView: ({ state, dispatch }: MFAViewProps) => React.JSX.Element;
8
+ export {};
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { WidgetAction } from '../reducer';
3
+ import { OAuthProvider } from '../types';
4
+ interface OAuthPendingViewProps {
5
+ provider: OAuthProvider;
6
+ dispatch: React.Dispatch<WidgetAction>;
7
+ }
8
+ export declare const OAuthPendingView: ({ provider, dispatch }: OAuthPendingViewProps) => React.JSX.Element;
9
+ export {};
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { WidgetAction, WidgetState } from '../reducer';
3
+ interface RecoveryCodeViewProps {
4
+ state: WidgetState;
5
+ dispatch: React.Dispatch<WidgetAction>;
6
+ }
7
+ export declare const RecoveryCodeView: ({ state, dispatch }: RecoveryCodeViewProps) => React.JSX.Element;
8
+ export {};
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { WidgetAction } from '../reducer';
3
+ interface WalletConnectViewProps {
4
+ dispatch: React.Dispatch<WidgetAction>;
5
+ }
6
+ export declare const WalletConnectView: ({ dispatch }: WalletConnectViewProps) => React.JSX.Element;
7
+ export {};
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { WidgetAction, WidgetState } from '../reducer';
3
+ import { ThirdPartyWallet } from '../types';
4
+ interface WalletPendingViewProps {
5
+ provider: ThirdPartyWallet;
6
+ state: WidgetState;
7
+ dispatch: React.Dispatch<WidgetAction>;
8
+ }
9
+ export declare const WalletPendingView: ({ provider, state, dispatch }: WalletPendingViewProps) => React.JSX.Element | null;
10
+ export {};
@@ -0,0 +1,8 @@
1
+ import { WagmiAdapter } from '@reown/appkit-adapter-wagmi';
2
+ import type { AppKitNetwork } from '@reown/appkit/networks';
3
+ export declare const networks: [AppKitNetwork, ...AppKitNetwork[]];
4
+ export declare function createWagmiConfig(projectId?: string): {
5
+ projectId: string;
6
+ wagmiAdapter: WagmiAdapter;
7
+ wagmiConfig: import("wagmi").Config;
8
+ };
@@ -0,0 +1,9 @@
1
+ import { ThirdPartyWallet } from '../types';
2
+ /**
3
+ * Map wallet types to wagmi connector IDs
4
+ */
5
+ export declare const CONNECTOR_IDS: Record<ThirdPartyWallet, string>;
6
+ /**
7
+ * Alternative names to match connectors by name if ID doesn't match
8
+ */
9
+ export declare const CONNECTOR_NAME_PATTERNS: Record<ThirdPartyWallet, string>;
@@ -0,0 +1,3 @@
1
+ import type { EthereumProvider } from '@walletconnect/ethereum-provider';
2
+ export declare function setWalletConnectProvider(provider: Awaited<ReturnType<typeof EthereumProvider.init>> | null): void;
3
+ export declare function getWalletConnectProvider(): Awaited<ReturnType<typeof EthereumProvider.init>> | null;
package/package.json CHANGED
@@ -1,5 +1,83 @@
1
1
  {
2
2
  "name": "@magic-ext/wallet-kit",
3
- "version": "0.1.0",
4
- "description": "Magic SDK Wallet Kit Extension"
3
+ "useCustomBuild": true,
4
+ "version": "0.2.0",
5
+ "description": "Magic SDK Wallet Kit Extension",
6
+ "author": "Magic <team@magic.link> (https://magic.link/)",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/magiclabs/magic-js"
11
+ },
12
+ "scripts": {
13
+ "prepare": "panda codegen",
14
+ "build:css": "panda cssgen --outfile dist/styles.css",
15
+ "build": "rollup -c rollup.config.mjs && tsc"
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "target": "browser",
21
+ "type": "module",
22
+ "module": "./dist/es/index.mjs",
23
+ "types": "./dist/types/index.d.ts",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/types/index.d.ts",
27
+ "import": "./dist/es/index.mjs"
28
+ }
29
+ },
30
+ "externals": {
31
+ "include": [
32
+ "@magic-sdk/provider",
33
+ "@reown/appkit",
34
+ "@reown/appkit-adapter-wagmi",
35
+ "@tanstack/react-query",
36
+ "@wagmi/core",
37
+ "@walletconnect/ethereum-provider",
38
+ "react",
39
+ "react-dom",
40
+ "viem",
41
+ "wagmi"
42
+ ]
43
+ },
44
+ "esbuildAliases": {
45
+ "@styled/css": "./styled-system/css",
46
+ "@styled/jsx": "./styled-system/jsx",
47
+ "@styled/tokens": "./styled-system/tokens",
48
+ "@styled/patterns": "./styled-system/patterns"
49
+ },
50
+ "dependencies": {
51
+ "@magiclabs/ui-components": "^1.49.2",
52
+ "@reown/appkit": "^1.8.0",
53
+ "@reown/appkit-adapter-wagmi": "^1.8.0",
54
+ "@wagmi/core": "^2.0.0",
55
+ "@walletconnect/ethereum-provider": "^2.23.0",
56
+ "wagmi": "^2.0.0"
57
+ },
58
+ "peerDependencies": {
59
+ "@tanstack/react-query": "^5.0.0",
60
+ "react": ">=18.0.0",
61
+ "react-dom": ">=18.0.0",
62
+ "viem": "^2.0.0"
63
+ },
64
+ "devDependencies": {
65
+ "@magic-sdk/provider": "^33.3.0",
66
+ "@magic-sdk/types": "^27.3.0",
67
+ "@pandacss/dev": "^0.35.0",
68
+ "@rollup/plugin-commonjs": "^26.0.1",
69
+ "@rollup/plugin-node-resolve": "^15.2.3",
70
+ "@rollup/plugin-replace": "^5.0.5",
71
+ "@rollup/plugin-terser": "^0.4.4",
72
+ "@rollup/plugin-typescript": "^11.1.6",
73
+ "@tanstack/react-query": "^5.0.0",
74
+ "@types/react": "^18.0.0",
75
+ "@types/react-dom": "^18.0.0",
76
+ "react": "^18.0.0",
77
+ "react-dom": "^18.0.0",
78
+ "rollup": "^4.18.0",
79
+ "tslib": "^2.6.3",
80
+ "viem": "^2.37.9"
81
+ },
82
+ "gitHead": "36ebb29c1090e98d4d66c56a395b528e6369f7c9"
5
83
  }