@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,89 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_AUTH_URL,
|
|
3
|
+
EthereumSiweMessage,
|
|
4
|
+
SiwsMessage,
|
|
5
|
+
SolanaTransactionParser,
|
|
6
|
+
arrayLikeToBytes,
|
|
7
|
+
authState,
|
|
8
|
+
broadcastEthereumRaw,
|
|
9
|
+
broadcastSolanaSigned,
|
|
10
|
+
bs58ToBytes,
|
|
11
|
+
buildUrl,
|
|
12
|
+
clearParentAssertCache,
|
|
13
|
+
createManualSiweMessage,
|
|
14
|
+
estimateEvmGas,
|
|
15
|
+
estimateEvmGasReserve,
|
|
16
|
+
formatPasskeyLabel,
|
|
17
|
+
fromB64url,
|
|
18
|
+
generatePasskeyUserId,
|
|
19
|
+
getAssertCacheTtlMs,
|
|
20
|
+
getChainById,
|
|
21
|
+
getDefaultChain,
|
|
22
|
+
getEvmGasPrice,
|
|
23
|
+
getEvmMaxPriorityFeePerGas,
|
|
24
|
+
getEvmNonce,
|
|
25
|
+
getInstructionsForHTML,
|
|
26
|
+
getRpcUrl,
|
|
27
|
+
getSOLTransfersFromInstructions,
|
|
28
|
+
getTransferInfoFromInstructions,
|
|
29
|
+
isChainSupported,
|
|
30
|
+
prepareEvmSendTransaction,
|
|
31
|
+
prepareEvmSignTransaction,
|
|
32
|
+
readParentAssertCache,
|
|
33
|
+
resolveEvmChain,
|
|
34
|
+
resolvePasskeyMetadata,
|
|
35
|
+
sanitizeUserData,
|
|
36
|
+
serializeEthereumTransaction,
|
|
37
|
+
setAssertCacheTtlMs,
|
|
38
|
+
setChainRpcUrl,
|
|
39
|
+
toB64url,
|
|
40
|
+
validateChainConfig,
|
|
41
|
+
verifyIdToken,
|
|
42
|
+
withClearOnFailure,
|
|
43
|
+
writeParentAssertCache
|
|
44
|
+
} from "../chunk-CDT4MC7S.mjs";
|
|
45
|
+
import "../chunk-GQKIA37O.mjs";
|
|
46
|
+
export {
|
|
47
|
+
DEFAULT_AUTH_URL,
|
|
48
|
+
EthereumSiweMessage,
|
|
49
|
+
SiwsMessage,
|
|
50
|
+
SolanaTransactionParser,
|
|
51
|
+
arrayLikeToBytes,
|
|
52
|
+
authState,
|
|
53
|
+
broadcastEthereumRaw,
|
|
54
|
+
broadcastSolanaSigned,
|
|
55
|
+
bs58ToBytes,
|
|
56
|
+
buildUrl,
|
|
57
|
+
clearParentAssertCache,
|
|
58
|
+
createManualSiweMessage,
|
|
59
|
+
estimateEvmGas,
|
|
60
|
+
estimateEvmGasReserve,
|
|
61
|
+
formatPasskeyLabel,
|
|
62
|
+
fromB64url,
|
|
63
|
+
generatePasskeyUserId,
|
|
64
|
+
getAssertCacheTtlMs,
|
|
65
|
+
getChainById,
|
|
66
|
+
getDefaultChain,
|
|
67
|
+
getEvmGasPrice,
|
|
68
|
+
getEvmMaxPriorityFeePerGas,
|
|
69
|
+
getEvmNonce,
|
|
70
|
+
getInstructionsForHTML,
|
|
71
|
+
getRpcUrl,
|
|
72
|
+
getSOLTransfersFromInstructions,
|
|
73
|
+
getTransferInfoFromInstructions,
|
|
74
|
+
isChainSupported,
|
|
75
|
+
prepareEvmSendTransaction,
|
|
76
|
+
prepareEvmSignTransaction,
|
|
77
|
+
readParentAssertCache,
|
|
78
|
+
resolveEvmChain,
|
|
79
|
+
resolvePasskeyMetadata,
|
|
80
|
+
sanitizeUserData,
|
|
81
|
+
serializeEthereumTransaction,
|
|
82
|
+
setAssertCacheTtlMs,
|
|
83
|
+
setChainRpcUrl,
|
|
84
|
+
toB64url,
|
|
85
|
+
validateChainConfig,
|
|
86
|
+
verifyIdToken,
|
|
87
|
+
withClearOnFailure,
|
|
88
|
+
writeParentAssertCache
|
|
89
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
interface CachedAssertion {
|
|
2
|
+
userHandleB64url: string;
|
|
3
|
+
credentialIdB64url: string;
|
|
4
|
+
}
|
|
5
|
+
declare const setAssertCacheTtlMs: (ms: number) => void;
|
|
6
|
+
declare const getAssertCacheTtlMs: () => number;
|
|
7
|
+
declare const clearParentAssertCache: () => void;
|
|
8
|
+
declare const readParentAssertCache: () => CachedAssertion | null;
|
|
9
|
+
declare const writeParentAssertCache: (entry: CachedAssertion) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Run `fn` inside a try/catch that clears the parent-side assertion
|
|
12
|
+
* cache on failure. Used by every wallet-interaction SDK method
|
|
13
|
+
* (sign / send / etc.) so that if the operation fails for any reason
|
|
14
|
+
* — backend rejection, network error, MPC ceremony failure — the
|
|
15
|
+
* next user attempt re-prompts biometric instead of silently reusing
|
|
16
|
+
* a possibly-bad cached assertion.
|
|
17
|
+
*
|
|
18
|
+
* The cache is set inside the platform-specific `assertPasskeyInParent`
|
|
19
|
+
* only on a successful ceremony, so cancellations / activation
|
|
20
|
+
* failures don't pollute it. This wrapper specifically handles the
|
|
21
|
+
* "assertion succeeded but downstream work failed" case where the
|
|
22
|
+
* cache is set but the user is stuck — without the clear, the user
|
|
23
|
+
* would have to refresh to escape.
|
|
24
|
+
*/
|
|
25
|
+
declare const withClearOnFailure: <T>(fn: () => Promise<T>) => Promise<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Generate fresh user.id bytes for a new WebAuthn credential. The
|
|
28
|
+
* caller overrides `options.user.id` with these bytes before
|
|
29
|
+
* navigator.credentials.create so the authenticator persists them as
|
|
30
|
+
* the credential's user.id; on every subsequent assertion they come
|
|
31
|
+
* back as response.userHandle and serve as the AES-GCM key for that
|
|
32
|
+
* credential's DEK wrap.
|
|
33
|
+
*
|
|
34
|
+
* Returns the bytes both as base64url (what the WebAuthn options
|
|
35
|
+
* accept and what we ship over postMessage) and as raw bytes (for
|
|
36
|
+
* any caller that prefers direct binary).
|
|
37
|
+
*
|
|
38
|
+
* Requires a working `crypto.getRandomValues`. On RN this is provided
|
|
39
|
+
* by the `react-native-get-random-values` polyfill that the SDK's
|
|
40
|
+
* docs ask consumers to import at app entry.
|
|
41
|
+
*/
|
|
42
|
+
declare const generatePasskeyUserId: () => {
|
|
43
|
+
userIdB64url: string;
|
|
44
|
+
userIdBytes: Uint8Array;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { type CachedAssertion as C, getAssertCacheTtlMs as a, writeParentAssertCache as b, clearParentAssertCache as c, generatePasskeyUserId as g, readParentAssertCache as r, setAssertCacheTtlMs as s, withClearOnFailure as w };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
interface CachedAssertion {
|
|
2
|
+
userHandleB64url: string;
|
|
3
|
+
credentialIdB64url: string;
|
|
4
|
+
}
|
|
5
|
+
declare const setAssertCacheTtlMs: (ms: number) => void;
|
|
6
|
+
declare const getAssertCacheTtlMs: () => number;
|
|
7
|
+
declare const clearParentAssertCache: () => void;
|
|
8
|
+
declare const readParentAssertCache: () => CachedAssertion | null;
|
|
9
|
+
declare const writeParentAssertCache: (entry: CachedAssertion) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Run `fn` inside a try/catch that clears the parent-side assertion
|
|
12
|
+
* cache on failure. Used by every wallet-interaction SDK method
|
|
13
|
+
* (sign / send / etc.) so that if the operation fails for any reason
|
|
14
|
+
* — backend rejection, network error, MPC ceremony failure — the
|
|
15
|
+
* next user attempt re-prompts biometric instead of silently reusing
|
|
16
|
+
* a possibly-bad cached assertion.
|
|
17
|
+
*
|
|
18
|
+
* The cache is set inside the platform-specific `assertPasskeyInParent`
|
|
19
|
+
* only on a successful ceremony, so cancellations / activation
|
|
20
|
+
* failures don't pollute it. This wrapper specifically handles the
|
|
21
|
+
* "assertion succeeded but downstream work failed" case where the
|
|
22
|
+
* cache is set but the user is stuck — without the clear, the user
|
|
23
|
+
* would have to refresh to escape.
|
|
24
|
+
*/
|
|
25
|
+
declare const withClearOnFailure: <T>(fn: () => Promise<T>) => Promise<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Generate fresh user.id bytes for a new WebAuthn credential. The
|
|
28
|
+
* caller overrides `options.user.id` with these bytes before
|
|
29
|
+
* navigator.credentials.create so the authenticator persists them as
|
|
30
|
+
* the credential's user.id; on every subsequent assertion they come
|
|
31
|
+
* back as response.userHandle and serve as the AES-GCM key for that
|
|
32
|
+
* credential's DEK wrap.
|
|
33
|
+
*
|
|
34
|
+
* Returns the bytes both as base64url (what the WebAuthn options
|
|
35
|
+
* accept and what we ship over postMessage) and as raw bytes (for
|
|
36
|
+
* any caller that prefers direct binary).
|
|
37
|
+
*
|
|
38
|
+
* Requires a working `crypto.getRandomValues`. On RN this is provided
|
|
39
|
+
* by the `react-native-get-random-values` polyfill that the SDK's
|
|
40
|
+
* docs ask consumers to import at app entry.
|
|
41
|
+
*/
|
|
42
|
+
declare const generatePasskeyUserId: () => {
|
|
43
|
+
userIdB64url: string;
|
|
44
|
+
userIdBytes: Uint8Array;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { type CachedAssertion as C, getAssertCacheTtlMs as a, writeParentAssertCache as b, clearParentAssertCache as c, generatePasskeyUserId as g, readParentAssertCache as r, setAssertCacheTtlMs as s, withClearOnFailure as w };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface PasskeyMetadataInput {
|
|
2
|
+
/** AAGUID as 8-4-4-4-12 lowercase hex from /auth/passkey/status */
|
|
3
|
+
aaguid?: string;
|
|
4
|
+
/** WebAuthn AuthenticatorTransport list, e.g. ["internal"], ["hybrid","internal"] */
|
|
5
|
+
transports?: string[];
|
|
6
|
+
/** True iff the credential is currently cloud-synced */
|
|
7
|
+
backupState?: boolean;
|
|
8
|
+
/** Browser parsed from the verify request's User-Agent (e.g. "Chrome") */
|
|
9
|
+
registeredBrowser?: string;
|
|
10
|
+
/** OS parsed from the verify request's User-Agent (e.g. "macOS") */
|
|
11
|
+
registeredOS?: string;
|
|
12
|
+
/** Optional user-supplied nickname (override beats everything) */
|
|
13
|
+
nickname?: string;
|
|
14
|
+
}
|
|
15
|
+
type PasskeyFormFactor = "platform" | "hybrid" | "roaming" | "unknown";
|
|
16
|
+
interface PasskeyMetadata {
|
|
17
|
+
providerName: string;
|
|
18
|
+
formFactor: PasskeyFormFactor;
|
|
19
|
+
isCloudSynced: boolean;
|
|
20
|
+
label: string;
|
|
21
|
+
}
|
|
22
|
+
declare function formatPasskeyLabel(input: PasskeyMetadataInput): string;
|
|
23
|
+
declare function resolvePasskeyMetadata(input: PasskeyMetadataInput): PasskeyMetadata;
|
|
24
|
+
|
|
25
|
+
export { type PasskeyMetadata as P, type PasskeyFormFactor as a, type PasskeyMetadataInput as b, formatPasskeyLabel as f, resolvePasskeyMetadata as r };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface PasskeyMetadataInput {
|
|
2
|
+
/** AAGUID as 8-4-4-4-12 lowercase hex from /auth/passkey/status */
|
|
3
|
+
aaguid?: string;
|
|
4
|
+
/** WebAuthn AuthenticatorTransport list, e.g. ["internal"], ["hybrid","internal"] */
|
|
5
|
+
transports?: string[];
|
|
6
|
+
/** True iff the credential is currently cloud-synced */
|
|
7
|
+
backupState?: boolean;
|
|
8
|
+
/** Browser parsed from the verify request's User-Agent (e.g. "Chrome") */
|
|
9
|
+
registeredBrowser?: string;
|
|
10
|
+
/** OS parsed from the verify request's User-Agent (e.g. "macOS") */
|
|
11
|
+
registeredOS?: string;
|
|
12
|
+
/** Optional user-supplied nickname (override beats everything) */
|
|
13
|
+
nickname?: string;
|
|
14
|
+
}
|
|
15
|
+
type PasskeyFormFactor = "platform" | "hybrid" | "roaming" | "unknown";
|
|
16
|
+
interface PasskeyMetadata {
|
|
17
|
+
providerName: string;
|
|
18
|
+
formFactor: PasskeyFormFactor;
|
|
19
|
+
isCloudSynced: boolean;
|
|
20
|
+
label: string;
|
|
21
|
+
}
|
|
22
|
+
declare function formatPasskeyLabel(input: PasskeyMetadataInput): string;
|
|
23
|
+
declare function resolvePasskeyMetadata(input: PasskeyMetadataInput): PasskeyMetadata;
|
|
24
|
+
|
|
25
|
+
export { type PasskeyMetadata as P, type PasskeyFormFactor as a, type PasskeyMetadataInput as b, formatPasskeyLabel as f, resolvePasskeyMetadata as r };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
declare const FORWARDED_ERROR_FIELDS: readonly ["error_type", "error_code", "status_code"];
|
|
2
|
+
declare const PostMessageType: {
|
|
3
|
+
readonly AUTH: "auth";
|
|
4
|
+
readonly INIT: "init";
|
|
5
|
+
readonly WALLET: "wallet";
|
|
6
|
+
readonly EXTERNAL_WALLET: "external_wallet";
|
|
7
|
+
};
|
|
8
|
+
type PostMessageType = (typeof PostMessageType)[keyof typeof PostMessageType];
|
|
9
|
+
declare const PostMessageMethod: {
|
|
10
|
+
readonly CLOSE: "CLOSE";
|
|
11
|
+
readonly CREATE_WALLET: "CREATE_WALLET";
|
|
12
|
+
readonly IMPORT_KEY: "IMPORT_KEY";
|
|
13
|
+
readonly FUND_WALLET: "FUND_WALLET";
|
|
14
|
+
readonly GET_APP_CONFIG: "GET_APP_CONFIG";
|
|
15
|
+
readonly GET_BALANCE: "GET_BALANCE";
|
|
16
|
+
readonly GET_CONFIRM_TRANSACTION: "GET_CONFIRM_TRANSACTION";
|
|
17
|
+
readonly GET_CONFIRM_ETHEREUM_TRANSACTION: "GET_CONFIRM_ETHEREUM_TRANSACTION";
|
|
18
|
+
readonly GET_CURRENT_SESSION: "GET_CURRENT_SESSION";
|
|
19
|
+
readonly GET_TOKEN_ACCOUNTS_BY_OWNER: "GET_TOKEN_ACCOUNTS_BY_OWNER";
|
|
20
|
+
readonly GET_USER: "GET_USER";
|
|
21
|
+
readonly GET_WALLET: "GET_WALLET";
|
|
22
|
+
readonly GET_WALLETS: "GET_WALLETS";
|
|
23
|
+
readonly IS_AUTHENTICATED: "IS_AUTHENTICATED";
|
|
24
|
+
readonly LOGIN_CREATE: "LOGIN_CREATE";
|
|
25
|
+
readonly LOGOUT: "LOGOUT";
|
|
26
|
+
readonly PREFETCH_CAPTCHA: "PREFETCH_CAPTCHA";
|
|
27
|
+
readonly READY: "READY";
|
|
28
|
+
readonly SEND_TRANSACTION: "SEND_TRANSACTION";
|
|
29
|
+
readonly SIGN_MESSAGE: "SIGN_MESSAGE";
|
|
30
|
+
readonly SIGN_TRANSACTION: "SIGN_TRANSACTION";
|
|
31
|
+
readonly SIGN_TYPED_DATA: "SIGN_TYPED_DATA";
|
|
32
|
+
readonly SIGN_HASH: "SIGN_HASH";
|
|
33
|
+
readonly SIGN_7702_AUTHORIZATION: "SIGN_7702_AUTHORIZATION";
|
|
34
|
+
readonly VERIFY_EMAIL_OTP: "VERIFY_EMAIL_OTP";
|
|
35
|
+
readonly VERIFY_OAUTH: "VERIFY_OAUTH";
|
|
36
|
+
readonly START_OAUTH: "START_OAUTH";
|
|
37
|
+
readonly WALLET_REGISTRATION_NONCE: "WALLET_REGISTRATION_NONCE";
|
|
38
|
+
readonly VERIFY_SIWE_WALLET_REGISTRATION: "VERIFY_SIWE_WALLET_REGISTRATION";
|
|
39
|
+
readonly ATTACH_OAUTH: "ATTACH_OAUTH";
|
|
40
|
+
readonly DETACH_OAUTH: "DETACH_OAUTH";
|
|
41
|
+
readonly PASSKEY_REGISTER_BEGIN: "PASSKEY_REGISTER_BEGIN";
|
|
42
|
+
readonly PASSKEY_REGISTER_VERIFY: "PASSKEY_REGISTER_VERIFY";
|
|
43
|
+
readonly GET_PASSKEY_STATUS: "GET_PASSKEY_STATUS";
|
|
44
|
+
readonly GET_DEK_INFO: "GET_DEK_INFO";
|
|
45
|
+
readonly ADD_PASSKEY_WRAP: "ADD_PASSKEY_WRAP";
|
|
46
|
+
readonly REMOVE_PASSKEY: "REMOVE_PASSKEY";
|
|
47
|
+
};
|
|
48
|
+
type PostMessageMethod = (typeof PostMessageMethod)[keyof typeof PostMessageMethod];
|
|
49
|
+
declare class PostMessageClient {
|
|
50
|
+
private target;
|
|
51
|
+
private origin;
|
|
52
|
+
constructor(target: Window, origin?: string);
|
|
53
|
+
send<Payload = Record<string, unknown>, Response = any>(type: PostMessageType, method: string, payload?: Payload): Promise<Response>;
|
|
54
|
+
sendOneWay<Payload>(type: PostMessageType, method: string, payload?: Payload): Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
declare class PostMessageServer {
|
|
57
|
+
private handlers;
|
|
58
|
+
private originValidator?;
|
|
59
|
+
private trustedSources;
|
|
60
|
+
constructor(originValidator?: (origin: string, publishableKey?: string) => Promise<boolean>);
|
|
61
|
+
addTrustedSource(source: Window): void;
|
|
62
|
+
removeTrustedSource(source: Window): void;
|
|
63
|
+
register<Payload, Response>(type: PostMessageType, method: string, handler: (payload: Payload) => Promise<Response | void>): void;
|
|
64
|
+
cleanup(): void;
|
|
65
|
+
private static isLocalhostOrigin;
|
|
66
|
+
private isValidPostMessageRequest;
|
|
67
|
+
private handleMessage;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { FORWARDED_ERROR_FIELDS as F, PostMessageClient as P, PostMessageMethod as a, PostMessageServer as b, PostMessageType as c };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
declare const FORWARDED_ERROR_FIELDS: readonly ["error_type", "error_code", "status_code"];
|
|
2
|
+
declare const PostMessageType: {
|
|
3
|
+
readonly AUTH: "auth";
|
|
4
|
+
readonly INIT: "init";
|
|
5
|
+
readonly WALLET: "wallet";
|
|
6
|
+
readonly EXTERNAL_WALLET: "external_wallet";
|
|
7
|
+
};
|
|
8
|
+
type PostMessageType = (typeof PostMessageType)[keyof typeof PostMessageType];
|
|
9
|
+
declare const PostMessageMethod: {
|
|
10
|
+
readonly CLOSE: "CLOSE";
|
|
11
|
+
readonly CREATE_WALLET: "CREATE_WALLET";
|
|
12
|
+
readonly IMPORT_KEY: "IMPORT_KEY";
|
|
13
|
+
readonly FUND_WALLET: "FUND_WALLET";
|
|
14
|
+
readonly GET_APP_CONFIG: "GET_APP_CONFIG";
|
|
15
|
+
readonly GET_BALANCE: "GET_BALANCE";
|
|
16
|
+
readonly GET_CONFIRM_TRANSACTION: "GET_CONFIRM_TRANSACTION";
|
|
17
|
+
readonly GET_CONFIRM_ETHEREUM_TRANSACTION: "GET_CONFIRM_ETHEREUM_TRANSACTION";
|
|
18
|
+
readonly GET_CURRENT_SESSION: "GET_CURRENT_SESSION";
|
|
19
|
+
readonly GET_TOKEN_ACCOUNTS_BY_OWNER: "GET_TOKEN_ACCOUNTS_BY_OWNER";
|
|
20
|
+
readonly GET_USER: "GET_USER";
|
|
21
|
+
readonly GET_WALLET: "GET_WALLET";
|
|
22
|
+
readonly GET_WALLETS: "GET_WALLETS";
|
|
23
|
+
readonly IS_AUTHENTICATED: "IS_AUTHENTICATED";
|
|
24
|
+
readonly LOGIN_CREATE: "LOGIN_CREATE";
|
|
25
|
+
readonly LOGOUT: "LOGOUT";
|
|
26
|
+
readonly PREFETCH_CAPTCHA: "PREFETCH_CAPTCHA";
|
|
27
|
+
readonly READY: "READY";
|
|
28
|
+
readonly SEND_TRANSACTION: "SEND_TRANSACTION";
|
|
29
|
+
readonly SIGN_MESSAGE: "SIGN_MESSAGE";
|
|
30
|
+
readonly SIGN_TRANSACTION: "SIGN_TRANSACTION";
|
|
31
|
+
readonly SIGN_TYPED_DATA: "SIGN_TYPED_DATA";
|
|
32
|
+
readonly SIGN_HASH: "SIGN_HASH";
|
|
33
|
+
readonly SIGN_7702_AUTHORIZATION: "SIGN_7702_AUTHORIZATION";
|
|
34
|
+
readonly VERIFY_EMAIL_OTP: "VERIFY_EMAIL_OTP";
|
|
35
|
+
readonly VERIFY_OAUTH: "VERIFY_OAUTH";
|
|
36
|
+
readonly START_OAUTH: "START_OAUTH";
|
|
37
|
+
readonly WALLET_REGISTRATION_NONCE: "WALLET_REGISTRATION_NONCE";
|
|
38
|
+
readonly VERIFY_SIWE_WALLET_REGISTRATION: "VERIFY_SIWE_WALLET_REGISTRATION";
|
|
39
|
+
readonly ATTACH_OAUTH: "ATTACH_OAUTH";
|
|
40
|
+
readonly DETACH_OAUTH: "DETACH_OAUTH";
|
|
41
|
+
readonly PASSKEY_REGISTER_BEGIN: "PASSKEY_REGISTER_BEGIN";
|
|
42
|
+
readonly PASSKEY_REGISTER_VERIFY: "PASSKEY_REGISTER_VERIFY";
|
|
43
|
+
readonly GET_PASSKEY_STATUS: "GET_PASSKEY_STATUS";
|
|
44
|
+
readonly GET_DEK_INFO: "GET_DEK_INFO";
|
|
45
|
+
readonly ADD_PASSKEY_WRAP: "ADD_PASSKEY_WRAP";
|
|
46
|
+
readonly REMOVE_PASSKEY: "REMOVE_PASSKEY";
|
|
47
|
+
};
|
|
48
|
+
type PostMessageMethod = (typeof PostMessageMethod)[keyof typeof PostMessageMethod];
|
|
49
|
+
declare class PostMessageClient {
|
|
50
|
+
private target;
|
|
51
|
+
private origin;
|
|
52
|
+
constructor(target: Window, origin?: string);
|
|
53
|
+
send<Payload = Record<string, unknown>, Response = any>(type: PostMessageType, method: string, payload?: Payload): Promise<Response>;
|
|
54
|
+
sendOneWay<Payload>(type: PostMessageType, method: string, payload?: Payload): Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
declare class PostMessageServer {
|
|
57
|
+
private handlers;
|
|
58
|
+
private originValidator?;
|
|
59
|
+
private trustedSources;
|
|
60
|
+
constructor(originValidator?: (origin: string, publishableKey?: string) => Promise<boolean>);
|
|
61
|
+
addTrustedSource(source: Window): void;
|
|
62
|
+
removeTrustedSource(source: Window): void;
|
|
63
|
+
register<Payload, Response>(type: PostMessageType, method: string, handler: (payload: Payload) => Promise<Response | void>): void;
|
|
64
|
+
cleanup(): void;
|
|
65
|
+
private static isLocalhostOrigin;
|
|
66
|
+
private isValidPostMessageRequest;
|
|
67
|
+
private handleMessage;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { FORWARDED_ERROR_FIELDS as F, PostMessageClient as P, PostMessageMethod as a, PostMessageServer as b, PostMessageType as c };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult } from '../types/index.mjs';
|
|
2
|
+
import '../chain-C9dvKXUY.mjs';
|
|
3
|
+
|
|
4
|
+
declare const useSignMessage: () => {
|
|
5
|
+
signMessage: (params: EthereumSignMessageParams) => Promise<EthereumSignMessageResult>;
|
|
6
|
+
};
|
|
7
|
+
declare const useSignTransaction: () => {
|
|
8
|
+
signTransaction: (params: EthereumSignTransactionParams) => Promise<EthereumSignTransactionResult>;
|
|
9
|
+
};
|
|
10
|
+
declare const useSignTypedData: () => {
|
|
11
|
+
signTypedData: (params: EthereumSignTypedDataParams) => Promise<EthereumSignTypedDataResult>;
|
|
12
|
+
};
|
|
13
|
+
declare const useSignHash: () => {
|
|
14
|
+
signHash: (params: EthereumSignHashParams) => Promise<EthereumSignHashResult>;
|
|
15
|
+
};
|
|
16
|
+
declare const useSign7702Authorization: () => {
|
|
17
|
+
signAuthorization: (params: EthereumSign7702AuthorizationParams) => Promise<EthereumSign7702AuthorizationResult>;
|
|
18
|
+
};
|
|
19
|
+
declare const useSendTransaction: () => {
|
|
20
|
+
sendTransaction: (params: EthereumSendTransactionParams) => Promise<EthereumSendTransactionResult>;
|
|
21
|
+
};
|
|
22
|
+
declare const useGetBalance: () => {
|
|
23
|
+
getBalance: (params: EthereumGetBalanceParams) => Promise<EthereumGetBalanceResult>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { useGetBalance, useSendTransaction, useSign7702Authorization, useSignHash, useSignMessage, useSignTransaction, useSignTypedData };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult } from '../types/index.js';
|
|
2
|
+
import '../chain-C9dvKXUY.js';
|
|
3
|
+
|
|
4
|
+
declare const useSignMessage: () => {
|
|
5
|
+
signMessage: (params: EthereumSignMessageParams) => Promise<EthereumSignMessageResult>;
|
|
6
|
+
};
|
|
7
|
+
declare const useSignTransaction: () => {
|
|
8
|
+
signTransaction: (params: EthereumSignTransactionParams) => Promise<EthereumSignTransactionResult>;
|
|
9
|
+
};
|
|
10
|
+
declare const useSignTypedData: () => {
|
|
11
|
+
signTypedData: (params: EthereumSignTypedDataParams) => Promise<EthereumSignTypedDataResult>;
|
|
12
|
+
};
|
|
13
|
+
declare const useSignHash: () => {
|
|
14
|
+
signHash: (params: EthereumSignHashParams) => Promise<EthereumSignHashResult>;
|
|
15
|
+
};
|
|
16
|
+
declare const useSign7702Authorization: () => {
|
|
17
|
+
signAuthorization: (params: EthereumSign7702AuthorizationParams) => Promise<EthereumSign7702AuthorizationResult>;
|
|
18
|
+
};
|
|
19
|
+
declare const useSendTransaction: () => {
|
|
20
|
+
sendTransaction: (params: EthereumSendTransactionParams) => Promise<EthereumSendTransactionResult>;
|
|
21
|
+
};
|
|
22
|
+
declare const useGetBalance: () => {
|
|
23
|
+
getBalance: (params: EthereumGetBalanceParams) => Promise<EthereumGetBalanceResult>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { useGetBalance, useSendTransaction, useSign7702Authorization, useSignHash, useSignMessage, useSignTransaction, useSignTypedData };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/react/ethereum.ts
|
|
21
|
+
var ethereum_exports = {};
|
|
22
|
+
__export(ethereum_exports, {
|
|
23
|
+
useGetBalance: () => useGetBalance,
|
|
24
|
+
useSendTransaction: () => useSendTransaction,
|
|
25
|
+
useSign7702Authorization: () => useSign7702Authorization,
|
|
26
|
+
useSignHash: () => useSignHash,
|
|
27
|
+
useSignMessage: () => useSignMessage,
|
|
28
|
+
useSignTransaction: () => useSignTransaction,
|
|
29
|
+
useSignTypedData: () => useSignTypedData
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(ethereum_exports);
|
|
32
|
+
|
|
33
|
+
// src/react/sdk-context.ts
|
|
34
|
+
var import_react = require("react");
|
|
35
|
+
var SDKContext = (0, import_react.createContext)(null);
|
|
36
|
+
var SDKProvider = SDKContext.Provider;
|
|
37
|
+
var useMoonKeySDK = () => {
|
|
38
|
+
const sdk = (0, import_react.useContext)(SDKContext);
|
|
39
|
+
if (!sdk) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
"MoonKey hook called outside a <MoonKeyProvider> \u2014 wrap your app in the provider from @moon-x/react-sdk (web) or @moon-x/react-native-sdk (RN)."
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
return sdk;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// src/react/ethereum.ts
|
|
48
|
+
var useSignMessage = () => {
|
|
49
|
+
const sdk = useMoonKeySDK();
|
|
50
|
+
return {
|
|
51
|
+
signMessage: (params) => sdk.signEthereumMessageHeadless(params)
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
var useSignTransaction = () => {
|
|
55
|
+
const sdk = useMoonKeySDK();
|
|
56
|
+
return {
|
|
57
|
+
signTransaction: (params) => sdk.signEthereumTransactionHeadless(params)
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
var useSignTypedData = () => {
|
|
61
|
+
const sdk = useMoonKeySDK();
|
|
62
|
+
return {
|
|
63
|
+
signTypedData: (params) => sdk.signEthereumTypedDataHeadless(params)
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
var useSignHash = () => {
|
|
67
|
+
const sdk = useMoonKeySDK();
|
|
68
|
+
return {
|
|
69
|
+
signHash: (params) => sdk.signEthereumHashHeadless(params)
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
var useSign7702Authorization = () => {
|
|
73
|
+
const sdk = useMoonKeySDK();
|
|
74
|
+
return {
|
|
75
|
+
signAuthorization: (params) => sdk.signEthereum7702AuthorizationHeadless(params)
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
var useSendTransaction = () => {
|
|
79
|
+
const sdk = useMoonKeySDK();
|
|
80
|
+
return {
|
|
81
|
+
sendTransaction: (params) => sdk.sendEthereumTransactionHeadless(params)
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
var useGetBalance = () => {
|
|
85
|
+
const sdk = useMoonKeySDK();
|
|
86
|
+
return {
|
|
87
|
+
getBalance: (params) => sdk.getEthereumBalance(params)
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
+
0 && (module.exports = {
|
|
92
|
+
useGetBalance,
|
|
93
|
+
useSendTransaction,
|
|
94
|
+
useSign7702Authorization,
|
|
95
|
+
useSignHash,
|
|
96
|
+
useSignMessage,
|
|
97
|
+
useSignTransaction,
|
|
98
|
+
useSignTypedData
|
|
99
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useMoonKeySDK
|
|
3
|
+
} from "../chunk-MOREUKOG.mjs";
|
|
4
|
+
|
|
5
|
+
// src/react/ethereum.ts
|
|
6
|
+
var useSignMessage = () => {
|
|
7
|
+
const sdk = useMoonKeySDK();
|
|
8
|
+
return {
|
|
9
|
+
signMessage: (params) => sdk.signEthereumMessageHeadless(params)
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
var useSignTransaction = () => {
|
|
13
|
+
const sdk = useMoonKeySDK();
|
|
14
|
+
return {
|
|
15
|
+
signTransaction: (params) => sdk.signEthereumTransactionHeadless(params)
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
var useSignTypedData = () => {
|
|
19
|
+
const sdk = useMoonKeySDK();
|
|
20
|
+
return {
|
|
21
|
+
signTypedData: (params) => sdk.signEthereumTypedDataHeadless(params)
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
var useSignHash = () => {
|
|
25
|
+
const sdk = useMoonKeySDK();
|
|
26
|
+
return {
|
|
27
|
+
signHash: (params) => sdk.signEthereumHashHeadless(params)
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
var useSign7702Authorization = () => {
|
|
31
|
+
const sdk = useMoonKeySDK();
|
|
32
|
+
return {
|
|
33
|
+
signAuthorization: (params) => sdk.signEthereum7702AuthorizationHeadless(params)
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
var useSendTransaction = () => {
|
|
37
|
+
const sdk = useMoonKeySDK();
|
|
38
|
+
return {
|
|
39
|
+
sendTransaction: (params) => sdk.sendEthereumTransactionHeadless(params)
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
var useGetBalance = () => {
|
|
43
|
+
const sdk = useMoonKeySDK();
|
|
44
|
+
return {
|
|
45
|
+
getBalance: (params) => sdk.getEthereumBalance(params)
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
useGetBalance,
|
|
50
|
+
useSendTransaction,
|
|
51
|
+
useSign7702Authorization,
|
|
52
|
+
useSignHash,
|
|
53
|
+
useSignMessage,
|
|
54
|
+
useSignTransaction,
|
|
55
|
+
useSignTypedData
|
|
56
|
+
};
|