@moon-x/core 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.
- package/README.md +39 -0
- package/dist/chain-C9dvKXUY.d.mts +48 -0
- package/dist/chain-C9dvKXUY.d.ts +48 -0
- package/dist/chunk-264CEGDS.mjs +46 -0
- package/dist/chunk-CDT4MC7S.mjs +1532 -0
- package/dist/chunk-CMYR6AOY.mjs +0 -0
- package/dist/chunk-GQKIA37O.mjs +20 -0
- package/dist/chunk-IMLBIIJ4.mjs +36 -0
- package/dist/chunk-MOREUKOG.mjs +18 -0
- package/dist/chunk-SOKLPX7V.mjs +270 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +402 -0
- package/dist/index.mjs +33 -0
- package/dist/interfaces-9k0eKCc4.d.ts +120 -0
- package/dist/interfaces-fNhwnCeY.d.mts +120 -0
- package/dist/lib/index.d.mts +410 -0
- package/dist/lib/index.d.ts +410 -0
- package/dist/lib/index.js +1622 -0
- package/dist/lib/index.mjs +89 -0
- package/dist/passkey-cache-B9PT3AWX.d.mts +47 -0
- package/dist/passkey-cache-B9PT3AWX.d.ts +47 -0
- package/dist/passkey-metadata-QqFF2SWQ.d.mts +25 -0
- package/dist/passkey-metadata-QqFF2SWQ.d.ts +25 -0
- package/dist/post-message-C_99BCBh.d.mts +70 -0
- package/dist/post-message-C_99BCBh.d.ts +70 -0
- package/dist/react/ethereum.d.mts +26 -0
- package/dist/react/ethereum.d.ts +26 -0
- package/dist/react/ethereum.js +99 -0
- package/dist/react/ethereum.mjs +56 -0
- package/dist/react/index.d.mts +182 -0
- package/dist/react/index.d.ts +182 -0
- package/dist/react/index.js +586 -0
- package/dist/react/index.mjs +328 -0
- package/dist/react/solana.d.mts +17 -0
- package/dist/react/solana.d.ts +17 -0
- package/dist/react/solana.js +75 -0
- package/dist/react/solana.mjs +35 -0
- package/dist/sdk/index.d.mts +126 -0
- package/dist/sdk/index.d.ts +126 -0
- package/dist/sdk/index.js +864 -0
- package/dist/sdk/index.mjs +579 -0
- package/dist/types/index.d.mts +1190 -0
- package/dist/types/index.d.ts +1190 -0
- package/dist/types/index.js +64 -0
- package/dist/types/index.mjs +10 -0
- package/dist/utils/index.d.mts +11 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.js +365 -0
- package/dist/utils/index.mjs +25 -0
- package/dist/web/index.d.mts +20 -0
- package/dist/web/index.d.ts +20 -0
- package/dist/web/index.js +470 -0
- package/dist/web/index.mjs +155 -0
- package/package.json +111 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { PublicWallet } from '../types/index.mjs';
|
|
3
|
+
import { P as PasskeyMetadata } from '../passkey-metadata-QqFF2SWQ.mjs';
|
|
4
|
+
import '../chain-C9dvKXUY.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The minimal SDK surface the shared hooks rely on. Both platform
|
|
8
|
+
* SDKs (web's AuthSDK and RN's SDK instance) implement this — and more.
|
|
9
|
+
*
|
|
10
|
+
* Methods are loosely typed (the parameter/result shapes live in
|
|
11
|
+
* `@moon-x/core/types`) so this interface stays single-source-of-truth
|
|
12
|
+
* for "what shared hooks need" without dragging in every overload.
|
|
13
|
+
*/
|
|
14
|
+
interface MoonKeyHookSDK {
|
|
15
|
+
user?: unknown | null;
|
|
16
|
+
isAuthenticated?: boolean;
|
|
17
|
+
ready?: boolean;
|
|
18
|
+
refreshUser?: () => Promise<unknown>;
|
|
19
|
+
signEthereumMessageHeadless: (params: unknown) => Promise<unknown>;
|
|
20
|
+
signEthereumTransactionHeadless: (params: unknown) => Promise<unknown>;
|
|
21
|
+
signEthereumTypedDataHeadless: (params: unknown) => Promise<unknown>;
|
|
22
|
+
signEthereumHashHeadless: (params: unknown) => Promise<unknown>;
|
|
23
|
+
signEthereum7702AuthorizationHeadless: (params: unknown) => Promise<unknown>;
|
|
24
|
+
sendEthereumTransactionHeadless: (params: unknown) => Promise<unknown>;
|
|
25
|
+
getEthereumBalance: (params: unknown) => Promise<unknown>;
|
|
26
|
+
getEthereumTokenAccountsByOwner?: (params: unknown) => Promise<unknown>;
|
|
27
|
+
signSolanaMessageHeadless: (params: unknown) => Promise<unknown>;
|
|
28
|
+
signSolanaTransactionHeadless: (params: unknown) => Promise<unknown>;
|
|
29
|
+
sendSolanaTransactionHeadless: (params: unknown) => Promise<unknown>;
|
|
30
|
+
getSolanaBalance: (params: unknown) => Promise<unknown>;
|
|
31
|
+
getSolanaTokenAccountsByOwner?: (params: unknown) => Promise<unknown>;
|
|
32
|
+
getWallets: (walletType: "ethereum" | "solana") => Promise<unknown>;
|
|
33
|
+
createWallet: (walletType: "ethereum" | "solana", options?: unknown) => Promise<unknown>;
|
|
34
|
+
importKey: (walletType: "ethereum" | "solana", key: string) => Promise<unknown>;
|
|
35
|
+
getUser: () => Promise<unknown>;
|
|
36
|
+
logout: () => Promise<unknown>;
|
|
37
|
+
getPasskeyStatus: () => Promise<unknown>;
|
|
38
|
+
removePasskey: (credentialIdB64url: string) => Promise<unknown>;
|
|
39
|
+
sendCode: (params: {
|
|
40
|
+
email: string;
|
|
41
|
+
disableSignup?: boolean;
|
|
42
|
+
}) => Promise<unknown>;
|
|
43
|
+
loginWithCode: (params: {
|
|
44
|
+
code: string;
|
|
45
|
+
}) => Promise<unknown>;
|
|
46
|
+
getCurrentSession?: () => Promise<unknown>;
|
|
47
|
+
registerPasskey?: (params?: {
|
|
48
|
+
displayName?: string;
|
|
49
|
+
}) => Promise<unknown>;
|
|
50
|
+
addPasskey?: (params?: {
|
|
51
|
+
displayName?: string;
|
|
52
|
+
}) => Promise<unknown>;
|
|
53
|
+
}
|
|
54
|
+
declare const SDKProvider: react.Provider<MoonKeyHookSDK | null>;
|
|
55
|
+
/**
|
|
56
|
+
* Read the active SDK instance. Throws if no Provider is in the tree —
|
|
57
|
+
* shared hooks can rely on a non-null return.
|
|
58
|
+
*/
|
|
59
|
+
declare const useMoonKeySDK: () => MoonKeyHookSDK;
|
|
60
|
+
|
|
61
|
+
type LoginWithEmailState = {
|
|
62
|
+
status: "idle";
|
|
63
|
+
} | {
|
|
64
|
+
status: "sending";
|
|
65
|
+
} | {
|
|
66
|
+
status: "awaiting-code";
|
|
67
|
+
email: string;
|
|
68
|
+
} | {
|
|
69
|
+
status: "verifying";
|
|
70
|
+
} | {
|
|
71
|
+
status: "complete";
|
|
72
|
+
} | {
|
|
73
|
+
status: "error";
|
|
74
|
+
error: Error;
|
|
75
|
+
};
|
|
76
|
+
interface UseLoginWithEmailCallbacks {
|
|
77
|
+
onComplete?: (user: unknown) => void;
|
|
78
|
+
onError?: (error: Error) => void;
|
|
79
|
+
}
|
|
80
|
+
declare const useLoginWithEmail: (callbacks?: UseLoginWithEmailCallbacks) => {
|
|
81
|
+
state: LoginWithEmailState;
|
|
82
|
+
sendCode: (params: {
|
|
83
|
+
email: string;
|
|
84
|
+
disableSignup?: boolean;
|
|
85
|
+
}) => Promise<void>;
|
|
86
|
+
loginWithCode: (params: {
|
|
87
|
+
code: string;
|
|
88
|
+
}) => Promise<void>;
|
|
89
|
+
reset: () => void;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
interface RegisterPasskeyResult {
|
|
93
|
+
/** RN headless path */
|
|
94
|
+
credential_id?: string;
|
|
95
|
+
/** Web modal path: true on enroll, false on skip */
|
|
96
|
+
passkey_registered?: boolean;
|
|
97
|
+
}
|
|
98
|
+
interface UseRegisterPasskeyResult {
|
|
99
|
+
registerPasskey: (params?: {
|
|
100
|
+
displayName?: string;
|
|
101
|
+
}) => Promise<RegisterPasskeyResult>;
|
|
102
|
+
isRegistering: boolean;
|
|
103
|
+
error: string | null;
|
|
104
|
+
}
|
|
105
|
+
declare const useRegisterPasskey: () => UseRegisterPasskeyResult;
|
|
106
|
+
|
|
107
|
+
declare const useUser: () => {
|
|
108
|
+
user: any;
|
|
109
|
+
loading: boolean;
|
|
110
|
+
refresh: () => Promise<void>;
|
|
111
|
+
refreshUser: () => Promise<void>;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
declare const useWallets: (walletType: "ethereum" | "solana") => {
|
|
115
|
+
wallets: unknown[];
|
|
116
|
+
loading: boolean;
|
|
117
|
+
error: Error | null;
|
|
118
|
+
refresh: () => Promise<void>;
|
|
119
|
+
refetch: () => Promise<void>;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
declare const useLogout: () => {
|
|
123
|
+
logout: () => Promise<unknown>;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
declare const useCreateWallet: () => {
|
|
127
|
+
createWallet: (walletType: "ethereum" | "solana", options?: {
|
|
128
|
+
createAdditional?: boolean;
|
|
129
|
+
walletIndex?: number;
|
|
130
|
+
}) => Promise<{
|
|
131
|
+
wallet: PublicWallet;
|
|
132
|
+
}>;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
declare const useImportKey: () => {
|
|
136
|
+
importKey: (walletType: "ethereum" | "solana", key: string) => Promise<{
|
|
137
|
+
wallet: PublicWallet;
|
|
138
|
+
}>;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
interface PasskeyStatusEntry {
|
|
142
|
+
id: string;
|
|
143
|
+
credential_id: string;
|
|
144
|
+
created_at: string;
|
|
145
|
+
last_used_at: string | null;
|
|
146
|
+
aaguid?: string;
|
|
147
|
+
transports?: string[];
|
|
148
|
+
backup_state?: boolean;
|
|
149
|
+
registered_browser?: string;
|
|
150
|
+
registered_os?: string;
|
|
151
|
+
/** Display-ready label, e.g. "1Password on Chrome" */
|
|
152
|
+
label: string;
|
|
153
|
+
/** Parsed metadata used to render the label */
|
|
154
|
+
metadata: PasskeyMetadata;
|
|
155
|
+
}
|
|
156
|
+
interface UsePasskeyStatusResult {
|
|
157
|
+
hasPasskey: boolean | null;
|
|
158
|
+
passkeys: PasskeyStatusEntry[];
|
|
159
|
+
loading: boolean;
|
|
160
|
+
error: string | null;
|
|
161
|
+
refresh: () => Promise<void>;
|
|
162
|
+
}
|
|
163
|
+
declare const usePasskeyStatus: () => UsePasskeyStatusResult;
|
|
164
|
+
|
|
165
|
+
interface UseAddPasskeyResult {
|
|
166
|
+
addPasskey: (params?: {
|
|
167
|
+
displayName?: string;
|
|
168
|
+
}) => Promise<{
|
|
169
|
+
credential_id: string;
|
|
170
|
+
}>;
|
|
171
|
+
isAdding: boolean;
|
|
172
|
+
error: string | null;
|
|
173
|
+
}
|
|
174
|
+
declare const useAddPasskey: () => UseAddPasskeyResult;
|
|
175
|
+
interface UseRemovePasskeyResult {
|
|
176
|
+
removePasskey: (credentialIdB64url: string) => Promise<void>;
|
|
177
|
+
isRemoving: boolean;
|
|
178
|
+
error: string | null;
|
|
179
|
+
}
|
|
180
|
+
declare const useRemovePasskey: () => UseRemovePasskeyResult;
|
|
181
|
+
|
|
182
|
+
export { type LoginWithEmailState, type MoonKeyHookSDK, type PasskeyStatusEntry, type RegisterPasskeyResult, SDKProvider, type UseAddPasskeyResult, type UseLoginWithEmailCallbacks, type UsePasskeyStatusResult, type UseRemovePasskeyResult, useAddPasskey, useCreateWallet, useImportKey, useLoginWithEmail, useLogout, useMoonKeySDK, usePasskeyStatus, useRegisterPasskey, useRemovePasskey, useUser, useWallets };
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { PublicWallet } from '../types/index.js';
|
|
3
|
+
import { P as PasskeyMetadata } from '../passkey-metadata-QqFF2SWQ.js';
|
|
4
|
+
import '../chain-C9dvKXUY.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The minimal SDK surface the shared hooks rely on. Both platform
|
|
8
|
+
* SDKs (web's AuthSDK and RN's SDK instance) implement this — and more.
|
|
9
|
+
*
|
|
10
|
+
* Methods are loosely typed (the parameter/result shapes live in
|
|
11
|
+
* `@moon-x/core/types`) so this interface stays single-source-of-truth
|
|
12
|
+
* for "what shared hooks need" without dragging in every overload.
|
|
13
|
+
*/
|
|
14
|
+
interface MoonKeyHookSDK {
|
|
15
|
+
user?: unknown | null;
|
|
16
|
+
isAuthenticated?: boolean;
|
|
17
|
+
ready?: boolean;
|
|
18
|
+
refreshUser?: () => Promise<unknown>;
|
|
19
|
+
signEthereumMessageHeadless: (params: unknown) => Promise<unknown>;
|
|
20
|
+
signEthereumTransactionHeadless: (params: unknown) => Promise<unknown>;
|
|
21
|
+
signEthereumTypedDataHeadless: (params: unknown) => Promise<unknown>;
|
|
22
|
+
signEthereumHashHeadless: (params: unknown) => Promise<unknown>;
|
|
23
|
+
signEthereum7702AuthorizationHeadless: (params: unknown) => Promise<unknown>;
|
|
24
|
+
sendEthereumTransactionHeadless: (params: unknown) => Promise<unknown>;
|
|
25
|
+
getEthereumBalance: (params: unknown) => Promise<unknown>;
|
|
26
|
+
getEthereumTokenAccountsByOwner?: (params: unknown) => Promise<unknown>;
|
|
27
|
+
signSolanaMessageHeadless: (params: unknown) => Promise<unknown>;
|
|
28
|
+
signSolanaTransactionHeadless: (params: unknown) => Promise<unknown>;
|
|
29
|
+
sendSolanaTransactionHeadless: (params: unknown) => Promise<unknown>;
|
|
30
|
+
getSolanaBalance: (params: unknown) => Promise<unknown>;
|
|
31
|
+
getSolanaTokenAccountsByOwner?: (params: unknown) => Promise<unknown>;
|
|
32
|
+
getWallets: (walletType: "ethereum" | "solana") => Promise<unknown>;
|
|
33
|
+
createWallet: (walletType: "ethereum" | "solana", options?: unknown) => Promise<unknown>;
|
|
34
|
+
importKey: (walletType: "ethereum" | "solana", key: string) => Promise<unknown>;
|
|
35
|
+
getUser: () => Promise<unknown>;
|
|
36
|
+
logout: () => Promise<unknown>;
|
|
37
|
+
getPasskeyStatus: () => Promise<unknown>;
|
|
38
|
+
removePasskey: (credentialIdB64url: string) => Promise<unknown>;
|
|
39
|
+
sendCode: (params: {
|
|
40
|
+
email: string;
|
|
41
|
+
disableSignup?: boolean;
|
|
42
|
+
}) => Promise<unknown>;
|
|
43
|
+
loginWithCode: (params: {
|
|
44
|
+
code: string;
|
|
45
|
+
}) => Promise<unknown>;
|
|
46
|
+
getCurrentSession?: () => Promise<unknown>;
|
|
47
|
+
registerPasskey?: (params?: {
|
|
48
|
+
displayName?: string;
|
|
49
|
+
}) => Promise<unknown>;
|
|
50
|
+
addPasskey?: (params?: {
|
|
51
|
+
displayName?: string;
|
|
52
|
+
}) => Promise<unknown>;
|
|
53
|
+
}
|
|
54
|
+
declare const SDKProvider: react.Provider<MoonKeyHookSDK | null>;
|
|
55
|
+
/**
|
|
56
|
+
* Read the active SDK instance. Throws if no Provider is in the tree —
|
|
57
|
+
* shared hooks can rely on a non-null return.
|
|
58
|
+
*/
|
|
59
|
+
declare const useMoonKeySDK: () => MoonKeyHookSDK;
|
|
60
|
+
|
|
61
|
+
type LoginWithEmailState = {
|
|
62
|
+
status: "idle";
|
|
63
|
+
} | {
|
|
64
|
+
status: "sending";
|
|
65
|
+
} | {
|
|
66
|
+
status: "awaiting-code";
|
|
67
|
+
email: string;
|
|
68
|
+
} | {
|
|
69
|
+
status: "verifying";
|
|
70
|
+
} | {
|
|
71
|
+
status: "complete";
|
|
72
|
+
} | {
|
|
73
|
+
status: "error";
|
|
74
|
+
error: Error;
|
|
75
|
+
};
|
|
76
|
+
interface UseLoginWithEmailCallbacks {
|
|
77
|
+
onComplete?: (user: unknown) => void;
|
|
78
|
+
onError?: (error: Error) => void;
|
|
79
|
+
}
|
|
80
|
+
declare const useLoginWithEmail: (callbacks?: UseLoginWithEmailCallbacks) => {
|
|
81
|
+
state: LoginWithEmailState;
|
|
82
|
+
sendCode: (params: {
|
|
83
|
+
email: string;
|
|
84
|
+
disableSignup?: boolean;
|
|
85
|
+
}) => Promise<void>;
|
|
86
|
+
loginWithCode: (params: {
|
|
87
|
+
code: string;
|
|
88
|
+
}) => Promise<void>;
|
|
89
|
+
reset: () => void;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
interface RegisterPasskeyResult {
|
|
93
|
+
/** RN headless path */
|
|
94
|
+
credential_id?: string;
|
|
95
|
+
/** Web modal path: true on enroll, false on skip */
|
|
96
|
+
passkey_registered?: boolean;
|
|
97
|
+
}
|
|
98
|
+
interface UseRegisterPasskeyResult {
|
|
99
|
+
registerPasskey: (params?: {
|
|
100
|
+
displayName?: string;
|
|
101
|
+
}) => Promise<RegisterPasskeyResult>;
|
|
102
|
+
isRegistering: boolean;
|
|
103
|
+
error: string | null;
|
|
104
|
+
}
|
|
105
|
+
declare const useRegisterPasskey: () => UseRegisterPasskeyResult;
|
|
106
|
+
|
|
107
|
+
declare const useUser: () => {
|
|
108
|
+
user: any;
|
|
109
|
+
loading: boolean;
|
|
110
|
+
refresh: () => Promise<void>;
|
|
111
|
+
refreshUser: () => Promise<void>;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
declare const useWallets: (walletType: "ethereum" | "solana") => {
|
|
115
|
+
wallets: unknown[];
|
|
116
|
+
loading: boolean;
|
|
117
|
+
error: Error | null;
|
|
118
|
+
refresh: () => Promise<void>;
|
|
119
|
+
refetch: () => Promise<void>;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
declare const useLogout: () => {
|
|
123
|
+
logout: () => Promise<unknown>;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
declare const useCreateWallet: () => {
|
|
127
|
+
createWallet: (walletType: "ethereum" | "solana", options?: {
|
|
128
|
+
createAdditional?: boolean;
|
|
129
|
+
walletIndex?: number;
|
|
130
|
+
}) => Promise<{
|
|
131
|
+
wallet: PublicWallet;
|
|
132
|
+
}>;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
declare const useImportKey: () => {
|
|
136
|
+
importKey: (walletType: "ethereum" | "solana", key: string) => Promise<{
|
|
137
|
+
wallet: PublicWallet;
|
|
138
|
+
}>;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
interface PasskeyStatusEntry {
|
|
142
|
+
id: string;
|
|
143
|
+
credential_id: string;
|
|
144
|
+
created_at: string;
|
|
145
|
+
last_used_at: string | null;
|
|
146
|
+
aaguid?: string;
|
|
147
|
+
transports?: string[];
|
|
148
|
+
backup_state?: boolean;
|
|
149
|
+
registered_browser?: string;
|
|
150
|
+
registered_os?: string;
|
|
151
|
+
/** Display-ready label, e.g. "1Password on Chrome" */
|
|
152
|
+
label: string;
|
|
153
|
+
/** Parsed metadata used to render the label */
|
|
154
|
+
metadata: PasskeyMetadata;
|
|
155
|
+
}
|
|
156
|
+
interface UsePasskeyStatusResult {
|
|
157
|
+
hasPasskey: boolean | null;
|
|
158
|
+
passkeys: PasskeyStatusEntry[];
|
|
159
|
+
loading: boolean;
|
|
160
|
+
error: string | null;
|
|
161
|
+
refresh: () => Promise<void>;
|
|
162
|
+
}
|
|
163
|
+
declare const usePasskeyStatus: () => UsePasskeyStatusResult;
|
|
164
|
+
|
|
165
|
+
interface UseAddPasskeyResult {
|
|
166
|
+
addPasskey: (params?: {
|
|
167
|
+
displayName?: string;
|
|
168
|
+
}) => Promise<{
|
|
169
|
+
credential_id: string;
|
|
170
|
+
}>;
|
|
171
|
+
isAdding: boolean;
|
|
172
|
+
error: string | null;
|
|
173
|
+
}
|
|
174
|
+
declare const useAddPasskey: () => UseAddPasskeyResult;
|
|
175
|
+
interface UseRemovePasskeyResult {
|
|
176
|
+
removePasskey: (credentialIdB64url: string) => Promise<void>;
|
|
177
|
+
isRemoving: boolean;
|
|
178
|
+
error: string | null;
|
|
179
|
+
}
|
|
180
|
+
declare const useRemovePasskey: () => UseRemovePasskeyResult;
|
|
181
|
+
|
|
182
|
+
export { type LoginWithEmailState, type MoonKeyHookSDK, type PasskeyStatusEntry, type RegisterPasskeyResult, SDKProvider, type UseAddPasskeyResult, type UseLoginWithEmailCallbacks, type UsePasskeyStatusResult, type UseRemovePasskeyResult, useAddPasskey, useCreateWallet, useImportKey, useLoginWithEmail, useLogout, useMoonKeySDK, usePasskeyStatus, useRegisterPasskey, useRemovePasskey, useUser, useWallets };
|