@moon-x/core 0.12.0 → 0.14.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 (40) hide show
  1. package/dist/{chunk-L7GL3PFM.mjs → chunk-7UGU27T3.mjs} +249 -7
  2. package/dist/{chunk-264CEGDS.mjs → chunk-HAEJD7NC.mjs} +4 -3
  3. package/dist/chunk-LP55IGPN.mjs +21 -0
  4. package/dist/{chunk-BJKWC4MG.mjs → chunk-PEIBEYMA.mjs} +3 -3
  5. package/dist/index.d.mts +2 -2
  6. package/dist/index.d.ts +2 -2
  7. package/dist/index.js +12 -10
  8. package/dist/index.mjs +5 -5
  9. package/dist/lib/index.d.mts +40 -4
  10. package/dist/lib/index.d.ts +40 -4
  11. package/dist/lib/index.js +258 -10
  12. package/dist/lib/index.mjs +12 -2
  13. package/dist/react/ethereum.js +9 -9
  14. package/dist/react/ethereum.mjs +9 -9
  15. package/dist/react/index.d.mts +14 -10
  16. package/dist/react/index.d.ts +14 -10
  17. package/dist/react/index.js +23 -15
  18. package/dist/react/index.mjs +16 -16
  19. package/dist/react/solana.js +6 -6
  20. package/dist/react/solana.mjs +6 -6
  21. package/dist/react/tron.d.mts +16 -0
  22. package/dist/react/tron.d.ts +16 -0
  23. package/dist/react/tron.js +95 -0
  24. package/dist/react/tron.mjs +55 -0
  25. package/dist/sdk/index.d.mts +17 -5
  26. package/dist/sdk/index.d.ts +17 -5
  27. package/dist/sdk/index.js +141 -0
  28. package/dist/sdk/index.mjs +107 -2
  29. package/dist/types/index.d.mts +98 -8
  30. package/dist/types/index.d.ts +98 -8
  31. package/dist/types/index.mjs +1 -1
  32. package/dist/utils/index.d.mts +3 -3
  33. package/dist/utils/index.d.ts +3 -3
  34. package/dist/utils/index.js +12 -10
  35. package/dist/utils/index.mjs +4 -4
  36. package/dist/web/index.js +5 -4
  37. package/dist/web/index.mjs +2 -2
  38. package/package.json +6 -1
  39. package/dist/chunk-GQKIA37O.mjs +0 -20
  40. /package/dist/{chunk-IMLBIIJ4.mjs → chunk-CEL3U6EI.mjs} +0 -0
@@ -1,7 +1,7 @@
1
1
  import { T as Transport, P as PasskeyAssertor, R as RelyingPartyOriginInput, K as KvStorage } from '../interfaces-Bt5CAMSt.mjs';
2
2
  export { O as OAuthOpener, a as PlatformImpls, W as WebAuthnAssertionResponse, b as WebAuthnRequestOptions, r as resolveRelyingPartyOrigin } from '../interfaces-Bt5CAMSt.mjs';
3
3
  import { C as CachedAssertion } from '../passkey-cache-WnDFQ-v4.mjs';
4
- import { EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumGetTokenAccountsByOwnerParams, EthereumGetTokenAccountsByOwnerResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaGetTokenAccountsByOwnerParams, SolanaGetTokenAccountsByOwnerResult, SendEmailOtpResponse, PublicWallet, ProvisionEphemeralSignerParams, ProvisionEphemeralSignerResult, ListEphemeralSignersResult, RevokeEphemeralSignerParams } from '../types/index.mjs';
4
+ import { EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumGetTokenAccountsByOwnerParams, EthereumGetTokenAccountsByOwnerResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaGetTokenAccountsByOwnerParams, SolanaGetTokenAccountsByOwnerResult, TronSignMessageParams, TronSignMessageResult, TronSignTransactionParams, TronSignTransactionResult, TronSendTransactionParams, TronSendTransactionResult, TronGetBalanceParams, TronGetBalanceResult, SendEmailOtpResponse, PublicWallet, ProvisionEphemeralSignerParams, ProvisionEphemeralSignerResult, ListEphemeralSignersResult, RevokeEphemeralSignerParams } from '../types/index.mjs';
5
5
  import '../post-message-BR2NClJ5.mjs';
6
6
 
7
7
  type AssertPasskeyInParentResult = CachedAssertion;
@@ -89,6 +89,18 @@ declare const getHeadlessSolanaMethods: ({ transport, passkey, publishableKey, r
89
89
  getSolanaTokenAccountsByOwner: (params: SolanaGetTokenAccountsByOwnerParams) => Promise<SolanaGetTokenAccountsByOwnerResult>;
90
90
  };
91
91
 
92
+ declare const getHeadlessTronMethods: ({ transport, passkey, publishableKey, relyingPartyOrigin, }: {
93
+ transport: Transport;
94
+ passkey: PasskeyAssertor;
95
+ publishableKey: string;
96
+ relyingPartyOrigin: RelyingPartyOriginInput;
97
+ }) => {
98
+ signTronMessageHeadless: (params: TronSignMessageParams) => Promise<TronSignMessageResult>;
99
+ signTronTransactionHeadless: (params: TronSignTransactionParams) => Promise<TronSignTransactionResult>;
100
+ sendTronTransactionHeadless: (params: TronSendTransactionParams) => Promise<TronSendTransactionResult>;
101
+ getTronBalance: (params: TronGetBalanceParams) => Promise<TronGetBalanceResult>;
102
+ };
103
+
92
104
  interface SendCodeParams {
93
105
  email: string;
94
106
  disableSignup?: boolean;
@@ -140,19 +152,19 @@ declare const getHeadlessGeneralMethods: ({ transport, passkey, storage, publish
140
152
  }) => {
141
153
  getPasskeyStatus: () => Promise<unknown>;
142
154
  removePasskey: (credentialIdB64url: string) => Promise<void>;
143
- createWallet: (walletType: "solana" | "ethereum", options?: {
155
+ createWallet: (walletType: "solana" | "ethereum" | "tron", options?: {
144
156
  createAdditional?: boolean;
145
157
  walletIndex?: number;
146
158
  }) => Promise<{
147
159
  wallet: PublicWallet;
148
160
  }>;
149
- importKey: (walletType: "solana" | "ethereum", key: string) => Promise<{
161
+ importKey: (walletType: "solana" | "ethereum" | "tron", key: string) => Promise<{
150
162
  wallet: PublicWallet;
151
163
  }>;
152
164
  provisionEphemeralSigner: (params: ProvisionEphemeralSignerParams) => Promise<ProvisionEphemeralSignerResult>;
153
165
  listEphemeralSigners: () => Promise<ListEphemeralSignersResult>;
154
166
  revokeEphemeralSigner: (params: RevokeEphemeralSignerParams) => Promise<void>;
155
- getWallets: (walletType: "solana" | "ethereum") => Promise<{
167
+ getWallets: (walletType: "solana" | "ethereum" | "tron") => Promise<{
156
168
  wallets: unknown[];
157
169
  walletType: string;
158
170
  }>;
@@ -230,4 +242,4 @@ declare class EphemeralSignerSignError extends Error {
230
242
  }
231
243
  declare function signWithEphemeralSigner(input: EphemeralSignerSignInput): Promise<EphemeralSignerSignResult>;
232
244
 
233
- export { type AssertPasskeyInParentResult, DEFAULT_API_BASE_URL, EphemeralSignerSignError, type EphemeralSignerSignInput, type EphemeralSignerSignResult, type GetInternalPresenceTokensResult, type GetPresenceTokenResult, KvStorage, type LoginWithCodeParams, PasskeyAssertor, type PresenceScope, RelyingPartyOriginInput, SCOPES_ADD_PASSKEY, SCOPES_CREATE_WALLET, SCOPES_EXPORT_KEY, SCOPES_IMPORT_KEY, SCOPES_PROVISION_EPHEMERAL_SIGNER, SCOPES_REMOVE_PASSKEY, SCOPES_REVOKE_EPHEMERAL_SIGNER, SCOPES_SIGN, type ScopedPresenceToken, type SendCodeParams, Transport, type VerifyOAuthParams, assertPasskeyInParent, flattenPresenceTokens, getHeadlessAuthenticationMethods, getHeadlessEthereumMethods, getHeadlessGeneralMethods, getHeadlessSolanaMethods, getInternalPresenceTokens, getPresenceToken, signWithEphemeralSigner };
245
+ export { type AssertPasskeyInParentResult, DEFAULT_API_BASE_URL, EphemeralSignerSignError, type EphemeralSignerSignInput, type EphemeralSignerSignResult, type GetInternalPresenceTokensResult, type GetPresenceTokenResult, KvStorage, type LoginWithCodeParams, PasskeyAssertor, type PresenceScope, RelyingPartyOriginInput, SCOPES_ADD_PASSKEY, SCOPES_CREATE_WALLET, SCOPES_EXPORT_KEY, SCOPES_IMPORT_KEY, SCOPES_PROVISION_EPHEMERAL_SIGNER, SCOPES_REMOVE_PASSKEY, SCOPES_REVOKE_EPHEMERAL_SIGNER, SCOPES_SIGN, type ScopedPresenceToken, type SendCodeParams, Transport, type VerifyOAuthParams, assertPasskeyInParent, flattenPresenceTokens, getHeadlessAuthenticationMethods, getHeadlessEthereumMethods, getHeadlessGeneralMethods, getHeadlessSolanaMethods, getHeadlessTronMethods, getInternalPresenceTokens, getPresenceToken, signWithEphemeralSigner };
@@ -1,7 +1,7 @@
1
1
  import { T as Transport, P as PasskeyAssertor, R as RelyingPartyOriginInput, K as KvStorage } from '../interfaces-pGbKBjWD.js';
2
2
  export { O as OAuthOpener, a as PlatformImpls, W as WebAuthnAssertionResponse, b as WebAuthnRequestOptions, r as resolveRelyingPartyOrigin } from '../interfaces-pGbKBjWD.js';
3
3
  import { C as CachedAssertion } from '../passkey-cache-WnDFQ-v4.js';
4
- import { EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumGetTokenAccountsByOwnerParams, EthereumGetTokenAccountsByOwnerResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaGetTokenAccountsByOwnerParams, SolanaGetTokenAccountsByOwnerResult, SendEmailOtpResponse, PublicWallet, ProvisionEphemeralSignerParams, ProvisionEphemeralSignerResult, ListEphemeralSignersResult, RevokeEphemeralSignerParams } from '../types/index.js';
4
+ import { EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumGetTokenAccountsByOwnerParams, EthereumGetTokenAccountsByOwnerResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaGetTokenAccountsByOwnerParams, SolanaGetTokenAccountsByOwnerResult, TronSignMessageParams, TronSignMessageResult, TronSignTransactionParams, TronSignTransactionResult, TronSendTransactionParams, TronSendTransactionResult, TronGetBalanceParams, TronGetBalanceResult, SendEmailOtpResponse, PublicWallet, ProvisionEphemeralSignerParams, ProvisionEphemeralSignerResult, ListEphemeralSignersResult, RevokeEphemeralSignerParams } from '../types/index.js';
5
5
  import '../post-message-BR2NClJ5.js';
6
6
 
7
7
  type AssertPasskeyInParentResult = CachedAssertion;
@@ -89,6 +89,18 @@ declare const getHeadlessSolanaMethods: ({ transport, passkey, publishableKey, r
89
89
  getSolanaTokenAccountsByOwner: (params: SolanaGetTokenAccountsByOwnerParams) => Promise<SolanaGetTokenAccountsByOwnerResult>;
90
90
  };
91
91
 
92
+ declare const getHeadlessTronMethods: ({ transport, passkey, publishableKey, relyingPartyOrigin, }: {
93
+ transport: Transport;
94
+ passkey: PasskeyAssertor;
95
+ publishableKey: string;
96
+ relyingPartyOrigin: RelyingPartyOriginInput;
97
+ }) => {
98
+ signTronMessageHeadless: (params: TronSignMessageParams) => Promise<TronSignMessageResult>;
99
+ signTronTransactionHeadless: (params: TronSignTransactionParams) => Promise<TronSignTransactionResult>;
100
+ sendTronTransactionHeadless: (params: TronSendTransactionParams) => Promise<TronSendTransactionResult>;
101
+ getTronBalance: (params: TronGetBalanceParams) => Promise<TronGetBalanceResult>;
102
+ };
103
+
92
104
  interface SendCodeParams {
93
105
  email: string;
94
106
  disableSignup?: boolean;
@@ -140,19 +152,19 @@ declare const getHeadlessGeneralMethods: ({ transport, passkey, storage, publish
140
152
  }) => {
141
153
  getPasskeyStatus: () => Promise<unknown>;
142
154
  removePasskey: (credentialIdB64url: string) => Promise<void>;
143
- createWallet: (walletType: "solana" | "ethereum", options?: {
155
+ createWallet: (walletType: "solana" | "ethereum" | "tron", options?: {
144
156
  createAdditional?: boolean;
145
157
  walletIndex?: number;
146
158
  }) => Promise<{
147
159
  wallet: PublicWallet;
148
160
  }>;
149
- importKey: (walletType: "solana" | "ethereum", key: string) => Promise<{
161
+ importKey: (walletType: "solana" | "ethereum" | "tron", key: string) => Promise<{
150
162
  wallet: PublicWallet;
151
163
  }>;
152
164
  provisionEphemeralSigner: (params: ProvisionEphemeralSignerParams) => Promise<ProvisionEphemeralSignerResult>;
153
165
  listEphemeralSigners: () => Promise<ListEphemeralSignersResult>;
154
166
  revokeEphemeralSigner: (params: RevokeEphemeralSignerParams) => Promise<void>;
155
- getWallets: (walletType: "solana" | "ethereum") => Promise<{
167
+ getWallets: (walletType: "solana" | "ethereum" | "tron") => Promise<{
156
168
  wallets: unknown[];
157
169
  walletType: string;
158
170
  }>;
@@ -230,4 +242,4 @@ declare class EphemeralSignerSignError extends Error {
230
242
  }
231
243
  declare function signWithEphemeralSigner(input: EphemeralSignerSignInput): Promise<EphemeralSignerSignResult>;
232
244
 
233
- export { type AssertPasskeyInParentResult, DEFAULT_API_BASE_URL, EphemeralSignerSignError, type EphemeralSignerSignInput, type EphemeralSignerSignResult, type GetInternalPresenceTokensResult, type GetPresenceTokenResult, KvStorage, type LoginWithCodeParams, PasskeyAssertor, type PresenceScope, RelyingPartyOriginInput, SCOPES_ADD_PASSKEY, SCOPES_CREATE_WALLET, SCOPES_EXPORT_KEY, SCOPES_IMPORT_KEY, SCOPES_PROVISION_EPHEMERAL_SIGNER, SCOPES_REMOVE_PASSKEY, SCOPES_REVOKE_EPHEMERAL_SIGNER, SCOPES_SIGN, type ScopedPresenceToken, type SendCodeParams, Transport, type VerifyOAuthParams, assertPasskeyInParent, flattenPresenceTokens, getHeadlessAuthenticationMethods, getHeadlessEthereumMethods, getHeadlessGeneralMethods, getHeadlessSolanaMethods, getInternalPresenceTokens, getPresenceToken, signWithEphemeralSigner };
245
+ export { type AssertPasskeyInParentResult, DEFAULT_API_BASE_URL, EphemeralSignerSignError, type EphemeralSignerSignInput, type EphemeralSignerSignResult, type GetInternalPresenceTokensResult, type GetPresenceTokenResult, KvStorage, type LoginWithCodeParams, PasskeyAssertor, type PresenceScope, RelyingPartyOriginInput, SCOPES_ADD_PASSKEY, SCOPES_CREATE_WALLET, SCOPES_EXPORT_KEY, SCOPES_IMPORT_KEY, SCOPES_PROVISION_EPHEMERAL_SIGNER, SCOPES_REMOVE_PASSKEY, SCOPES_REVOKE_EPHEMERAL_SIGNER, SCOPES_SIGN, type ScopedPresenceToken, type SendCodeParams, Transport, type VerifyOAuthParams, assertPasskeyInParent, flattenPresenceTokens, getHeadlessAuthenticationMethods, getHeadlessEthereumMethods, getHeadlessGeneralMethods, getHeadlessSolanaMethods, getHeadlessTronMethods, getInternalPresenceTokens, getPresenceToken, signWithEphemeralSigner };
package/dist/sdk/index.js CHANGED
@@ -46,6 +46,7 @@ __export(sdk_exports, {
46
46
  getHeadlessEthereumMethods: () => getHeadlessEthereumMethods,
47
47
  getHeadlessGeneralMethods: () => getHeadlessGeneralMethods,
48
48
  getHeadlessSolanaMethods: () => getHeadlessSolanaMethods,
49
+ getHeadlessTronMethods: () => getHeadlessTronMethods,
49
50
  getInternalPresenceTokens: () => getInternalPresenceTokens,
50
51
  getPresenceToken: () => getPresenceToken,
51
52
  resolveRelyingPartyOrigin: () => resolveRelyingPartyOrigin,
@@ -100,6 +101,14 @@ var nacl = __toESM(require("tweetnacl"));
100
101
  var import_web3 = require("@solana/web3.js");
101
102
  var import_bn = __toESM(require("bn.js"));
102
103
 
104
+ // src/lib/tron/tron-address.ts
105
+ var import_secp256k1 = require("@noble/curves/secp256k1");
106
+ var import_sha3 = require("@noble/hashes/sha3");
107
+ var import_sha256 = require("@noble/hashes/sha256");
108
+
109
+ // src/lib/tron/decode-raw-data.ts
110
+ var import_sha2562 = require("@noble/hashes/sha256");
111
+
103
112
  // src/lib/rpc-broadcast.ts
104
113
  var serializeEthereumTransaction = async (transaction) => {
105
114
  if (typeof transaction === "string") {
@@ -192,6 +201,34 @@ var broadcastSolanaSigned = async (rpcUrl, signedBase58) => {
192
201
  }
193
202
  return result.result;
194
203
  };
204
+ var broadcastTronSigned = async (rpcUrl, signedTransaction) => {
205
+ const response = await fetch(
206
+ `${rpcUrl.replace(/\/$/, "")}/wallet/broadcasttransaction`,
207
+ {
208
+ method: "POST",
209
+ headers: { "Content-Type": "application/json" },
210
+ body: JSON.stringify(signedTransaction)
211
+ }
212
+ );
213
+ const result = await response.json();
214
+ if (!result.result) {
215
+ let message = result.message ?? "";
216
+ if (/^[0-9a-fA-F]+$/.test(message) && message.length % 2 === 0) {
217
+ try {
218
+ message = new TextDecoder().decode(
219
+ Uint8Array.from(
220
+ message.match(/.{2}/g).map((h) => parseInt(h, 16))
221
+ )
222
+ );
223
+ } catch {
224
+ }
225
+ }
226
+ throw new Error(
227
+ `Tron broadcast failed: ${result.code ?? "UNKNOWN"} ${message}`.trim()
228
+ );
229
+ }
230
+ return result.txid ?? signedTransaction.txID;
231
+ };
195
232
 
196
233
  // src/lib/wire-codec.ts
197
234
  var arrayLikeToBytes = (value) => {
@@ -804,6 +841,109 @@ var getHeadlessSolanaMethods = ({
804
841
  }
805
842
  });
806
843
 
844
+ // src/sdk/headless-tron.ts
845
+ var getHeadlessTronMethods = ({
846
+ transport,
847
+ passkey,
848
+ publishableKey,
849
+ relyingPartyOrigin
850
+ }) => ({
851
+ signTronMessageHeadless: async (params) => {
852
+ if (!transport.isReady()) throw new Error("SDK not ready");
853
+ const { userHandleB64url, credentialIdB64url, tokens } = await getInternalPresenceTokens({
854
+ transport,
855
+ passkey,
856
+ publishableKey,
857
+ relyingPartyOrigin,
858
+ scopes: SCOPES_SIGN
859
+ });
860
+ const { signature } = await transport.send(
861
+ PostMessageType.WALLET,
862
+ PostMessageMethod.SIGN_MESSAGE,
863
+ {
864
+ message: params.message,
865
+ publishableKey,
866
+ wallet: params.wallet,
867
+ uiOptions: params.options?.uiOptions,
868
+ userHandleB64url,
869
+ credentialIdB64url,
870
+ presenceTokens: flattenPresenceTokens({
871
+ tokens,
872
+ userHandleB64url,
873
+ credentialIdB64url
874
+ })
875
+ }
876
+ );
877
+ return { signature };
878
+ },
879
+ signTronTransactionHeadless: async (params) => {
880
+ if (!transport.isReady()) throw new Error("SDK not ready");
881
+ const { userHandleB64url, credentialIdB64url, tokens } = await getInternalPresenceTokens({
882
+ transport,
883
+ passkey,
884
+ publishableKey,
885
+ relyingPartyOrigin,
886
+ scopes: SCOPES_SIGN
887
+ });
888
+ const { signedTransaction } = await transport.send(
889
+ PostMessageType.WALLET,
890
+ PostMessageMethod.SIGN_TRANSACTION,
891
+ {
892
+ serializedTransaction: JSON.stringify(params.transaction),
893
+ publishableKey,
894
+ wallet: params.wallet,
895
+ options: params.options,
896
+ userHandleB64url,
897
+ credentialIdB64url,
898
+ presenceTokens: flattenPresenceTokens({
899
+ tokens,
900
+ userHandleB64url,
901
+ credentialIdB64url
902
+ })
903
+ }
904
+ );
905
+ return { signedTransaction: JSON.parse(signedTransaction) };
906
+ },
907
+ sendTronTransactionHeadless: async (params) => {
908
+ if (!transport.isReady()) throw new Error("SDK not ready");
909
+ const { userHandleB64url, credentialIdB64url, tokens } = await getInternalPresenceTokens({
910
+ transport,
911
+ passkey,
912
+ publishableKey,
913
+ relyingPartyOrigin,
914
+ scopes: SCOPES_SIGN
915
+ });
916
+ const { signedTransaction } = await transport.send(
917
+ PostMessageType.WALLET,
918
+ PostMessageMethod.SIGN_TRANSACTION,
919
+ {
920
+ serializedTransaction: JSON.stringify(params.transaction),
921
+ publishableKey,
922
+ wallet: params.wallet,
923
+ options: params.options,
924
+ userHandleB64url,
925
+ credentialIdB64url,
926
+ presenceTokens: flattenPresenceTokens({
927
+ tokens,
928
+ userHandleB64url,
929
+ credentialIdB64url
930
+ })
931
+ }
932
+ );
933
+ const signed = JSON.parse(signedTransaction);
934
+ const txid = await broadcastTronSigned(params.rpcUrl, signed);
935
+ return { txid, signedTransaction: signed };
936
+ },
937
+ getTronBalance: async (params) => {
938
+ if (!transport.isReady()) throw new Error("SDK not ready");
939
+ return transport.send(
940
+ PostMessageType.WALLET,
941
+ PostMessageMethod.GET_BALANCE,
942
+ { publishableKey, ...params }
943
+ );
944
+ }
945
+ });
946
+
807
947
  // src/sdk/headless-authentication.ts
808
948
  var getHeadlessAuthenticationMethods = ({
809
949
  transport,
@@ -1314,6 +1454,7 @@ async function signWithEphemeralSigner(input) {
1314
1454
  getHeadlessEthereumMethods,
1315
1455
  getHeadlessGeneralMethods,
1316
1456
  getHeadlessSolanaMethods,
1457
+ getHeadlessTronMethods,
1317
1458
  getInternalPresenceTokens,
1318
1459
  getPresenceToken,
1319
1460
  resolveRelyingPartyOrigin,
@@ -7,11 +7,12 @@ import {
7
7
  authState,
8
8
  broadcastEthereumRaw,
9
9
  broadcastSolanaSigned,
10
+ broadcastTronSigned,
10
11
  bs58ToBytes,
11
12
  serializeEthereumTransaction,
12
13
  toB64url
13
- } from "../chunk-L7GL3PFM.mjs";
14
- import "../chunk-GQKIA37O.mjs";
14
+ } from "../chunk-7UGU27T3.mjs";
15
+ import "../chunk-LP55IGPN.mjs";
15
16
 
16
17
  // src/sdk/interfaces.ts
17
18
  var resolveRelyingPartyOrigin = async (input) => typeof input === "function" ? input() : input;
@@ -505,6 +506,109 @@ var getHeadlessSolanaMethods = ({
505
506
  }
506
507
  });
507
508
 
509
+ // src/sdk/headless-tron.ts
510
+ var getHeadlessTronMethods = ({
511
+ transport,
512
+ passkey,
513
+ publishableKey,
514
+ relyingPartyOrigin
515
+ }) => ({
516
+ signTronMessageHeadless: async (params) => {
517
+ if (!transport.isReady()) throw new Error("SDK not ready");
518
+ const { userHandleB64url, credentialIdB64url, tokens } = await getInternalPresenceTokens({
519
+ transport,
520
+ passkey,
521
+ publishableKey,
522
+ relyingPartyOrigin,
523
+ scopes: SCOPES_SIGN
524
+ });
525
+ const { signature } = await transport.send(
526
+ PostMessageType.WALLET,
527
+ PostMessageMethod.SIGN_MESSAGE,
528
+ {
529
+ message: params.message,
530
+ publishableKey,
531
+ wallet: params.wallet,
532
+ uiOptions: params.options?.uiOptions,
533
+ userHandleB64url,
534
+ credentialIdB64url,
535
+ presenceTokens: flattenPresenceTokens({
536
+ tokens,
537
+ userHandleB64url,
538
+ credentialIdB64url
539
+ })
540
+ }
541
+ );
542
+ return { signature };
543
+ },
544
+ signTronTransactionHeadless: async (params) => {
545
+ if (!transport.isReady()) throw new Error("SDK not ready");
546
+ const { userHandleB64url, credentialIdB64url, tokens } = await getInternalPresenceTokens({
547
+ transport,
548
+ passkey,
549
+ publishableKey,
550
+ relyingPartyOrigin,
551
+ scopes: SCOPES_SIGN
552
+ });
553
+ const { signedTransaction } = await transport.send(
554
+ PostMessageType.WALLET,
555
+ PostMessageMethod.SIGN_TRANSACTION,
556
+ {
557
+ serializedTransaction: JSON.stringify(params.transaction),
558
+ publishableKey,
559
+ wallet: params.wallet,
560
+ options: params.options,
561
+ userHandleB64url,
562
+ credentialIdB64url,
563
+ presenceTokens: flattenPresenceTokens({
564
+ tokens,
565
+ userHandleB64url,
566
+ credentialIdB64url
567
+ })
568
+ }
569
+ );
570
+ return { signedTransaction: JSON.parse(signedTransaction) };
571
+ },
572
+ sendTronTransactionHeadless: async (params) => {
573
+ if (!transport.isReady()) throw new Error("SDK not ready");
574
+ const { userHandleB64url, credentialIdB64url, tokens } = await getInternalPresenceTokens({
575
+ transport,
576
+ passkey,
577
+ publishableKey,
578
+ relyingPartyOrigin,
579
+ scopes: SCOPES_SIGN
580
+ });
581
+ const { signedTransaction } = await transport.send(
582
+ PostMessageType.WALLET,
583
+ PostMessageMethod.SIGN_TRANSACTION,
584
+ {
585
+ serializedTransaction: JSON.stringify(params.transaction),
586
+ publishableKey,
587
+ wallet: params.wallet,
588
+ options: params.options,
589
+ userHandleB64url,
590
+ credentialIdB64url,
591
+ presenceTokens: flattenPresenceTokens({
592
+ tokens,
593
+ userHandleB64url,
594
+ credentialIdB64url
595
+ })
596
+ }
597
+ );
598
+ const signed = JSON.parse(signedTransaction);
599
+ const txid = await broadcastTronSigned(params.rpcUrl, signed);
600
+ return { txid, signedTransaction: signed };
601
+ },
602
+ getTronBalance: async (params) => {
603
+ if (!transport.isReady()) throw new Error("SDK not ready");
604
+ return transport.send(
605
+ PostMessageType.WALLET,
606
+ PostMessageMethod.GET_BALANCE,
607
+ { publishableKey, ...params }
608
+ );
609
+ }
610
+ });
611
+
508
612
  // src/sdk/headless-authentication.ts
509
613
  var getHeadlessAuthenticationMethods = ({
510
614
  transport,
@@ -1014,6 +1118,7 @@ export {
1014
1118
  getHeadlessEthereumMethods,
1015
1119
  getHeadlessGeneralMethods,
1016
1120
  getHeadlessSolanaMethods,
1121
+ getHeadlessTronMethods,
1017
1122
  getInternalPresenceTokens,
1018
1123
  getPresenceToken,
1019
1124
  resolveRelyingPartyOrigin,
@@ -62,10 +62,18 @@ type SolanaChainEntry = {
62
62
  /** Optional WebSocket (rpcSubscriptions) endpoint. */
63
63
  wsUrl?: string;
64
64
  };
65
+ type TronChainEntry = {
66
+ /** CAIP-2-style network id, e.g. "tron:mainnet" | "tron:nile". */
67
+ id: string;
68
+ /** Fullnode HTTP endpoint, e.g. "https://api.trongrid.io". */
69
+ rpcUrl: string;
70
+ /** Unused for tron (fullnode HTTP only); present for ChainEntry shape parity. */
71
+ wsUrl?: string;
72
+ };
65
73
  /** Normalized internal entry form (bare `Chain`s are coerced to `EvmChainEntry`). */
66
- type ChainEntry = EvmChainEntry | SolanaChainEntry;
74
+ type ChainEntry = EvmChainEntry | SolanaChainEntry | TronChainEntry;
67
75
  /** A single element of the public `chains` config array. */
68
- type ChainConfigItem = Chain | EvmChainEntry | SolanaChainEntry;
76
+ type ChainConfigItem = Chain | EvmChainEntry | SolanaChainEntry | TronChainEntry;
69
77
 
70
78
  interface PublicWallet {
71
79
  id: string;
@@ -191,7 +199,7 @@ type ContractUIOptions = {
191
199
  imgAltText?: string;
192
200
  imgSize?: "sm" | "lg";
193
201
  };
194
- type WalletType = "solana" | "ethereum";
202
+ type WalletType = "solana" | "ethereum" | "tron";
195
203
  type TransactionCommitment = "processed" | "confirmed" | "finalized";
196
204
  type TransactionEncoding = "base64" | "base58" | "json" | "jsonParsed";
197
205
  interface WalletError extends Error {
@@ -227,7 +235,7 @@ interface MoonPaySignRequest {
227
235
  accessToken: string;
228
236
  publicAddress: string;
229
237
  currencyCode: string;
230
- quoteCurrencyAmount: number;
238
+ quoteCurrencyAmount?: number;
231
239
  useSandbox?: boolean;
232
240
  }
233
241
  interface MoonPaySignResponse {
@@ -687,8 +695,90 @@ interface SolanaGetTokenAccountsByOwnerResult {
687
695
  tokenAccounts: any[];
688
696
  }
689
697
 
698
+ /**
699
+ * A TronWeb-built transaction (TransactionBuilder output). Structurally
700
+ * identical to @moon-x/signing-codec/tron's TronTransaction - kept as a
701
+ * standalone type because core doesn't depend on the internal codec.
702
+ * `raw_data_hex` is the protobuf-serialized bytes a signature covers;
703
+ * `txID` is their sha256.
704
+ */
705
+ interface TronTransactionJson {
706
+ visible?: boolean;
707
+ txID: string;
708
+ raw_data: unknown;
709
+ raw_data_hex: string;
710
+ signature?: string[];
711
+ }
712
+ interface TronSignMessageParams {
713
+ message: string;
714
+ wallet: PublicWallet;
715
+ options?: {
716
+ uiOptions?: {
717
+ title?: string;
718
+ description?: string;
719
+ showWalletUI?: boolean;
720
+ logoUrl?: string;
721
+ confirmButtonText?: string;
722
+ cancelButtonText?: string;
723
+ waitBeforeCloseTime?: number;
724
+ };
725
+ };
726
+ }
727
+ interface TronSignMessageResult {
728
+ /** 65-byte 0x-prefixed hex - verifies via TronWeb `Trx.verifyMessageV2`. */
729
+ signature: string;
730
+ }
731
+ interface TronSignTransactionParams {
732
+ transaction: TronTransactionJson;
733
+ wallet: PublicWallet;
734
+ options?: {
735
+ uiOptions?: {
736
+ title?: string;
737
+ description?: string;
738
+ showWalletUI?: boolean;
739
+ logoUrl?: string;
740
+ cancelButtonText?: string;
741
+ confirmButtonText?: string;
742
+ footerText?: string;
743
+ waitBeforeCloseTime?: number;
744
+ };
745
+ };
746
+ }
747
+ interface TronSignTransactionResult {
748
+ /** Broadcast-ready for `tronWeb.trx.sendRawTransaction`. */
749
+ signedTransaction: TronTransactionJson & {
750
+ signature: string[];
751
+ };
752
+ }
753
+ interface TronSendTransactionParams {
754
+ transaction: TronTransactionJson;
755
+ wallet: PublicWallet;
756
+ /** Fullnode HTTP endpoint, e.g. "https://api.trongrid.io". */
757
+ rpcUrl: string;
758
+ options?: TronSignTransactionParams["options"];
759
+ }
760
+ interface TronSendTransactionResult {
761
+ /** Transaction id accepted by the fullnode (== sha256 of raw_data). */
762
+ txid: string;
763
+ signedTransaction: TronTransactionJson & {
764
+ signature: string[];
765
+ };
766
+ }
767
+ interface TronGetBalanceParams {
768
+ wallet: PublicWallet;
769
+ /** Fullnode HTTP endpoint. */
770
+ rpcUrl: string;
771
+ }
772
+ interface TronGetBalanceResult {
773
+ /** SUN (1 TRX = 1e6 SUN). */
774
+ balanceBaseUnit: string;
775
+ balanceNativeUnit: string;
776
+ walletAddress: string;
777
+ network: string;
778
+ }
779
+
690
780
  type EphemeralSignerScheme = "ecdsa_secp256k1" | "eddsa_ed25519";
691
- type EphemeralSignerChain = "ethereum" | "solana";
781
+ type EphemeralSignerChain = "ethereum" | "solana" | "tron";
692
782
  interface ProvisionEphemeralSignerParams {
693
783
  /**
694
784
  * Wallet IDs (from `user.wallets[i].id`) the agent will be authorized
@@ -955,7 +1045,7 @@ interface AuthAppearance {
955
1045
  dark?: AppearanceModeTokens;
956
1046
  }
957
1047
  /**
958
- * Flexible theme type that accepts both strict MoonKeyTheme and loose config theme objects.
1048
+ * Flexible theme type that accepts both strict MoonXTheme and loose config theme objects.
959
1049
  * Used for functions that need to work with various theme configuration formats.
960
1050
  */
961
1051
  type FlexibleTheme = {
@@ -1055,7 +1145,7 @@ interface ExportKeyConfig {
1055
1145
  logoUrl?: string;
1056
1146
  };
1057
1147
  }
1058
- type WalletChain = "solana" | "ethereum";
1148
+ type WalletChain = "solana" | "ethereum" | "tron";
1059
1149
  interface MethodDetails {
1060
1150
  id: string;
1061
1151
  method_id: string;
@@ -1456,4 +1546,4 @@ interface WalletVerifyRequest {
1456
1546
  sessionExpiresIn: number;
1457
1547
  }
1458
1548
 
1459
- export { type AccessTokenClaims, type AppConfigRequest, type AppConfigResponse, type AppearanceBackdrop, type AppearanceBorderRadius, type AppearanceCard, type AppearanceColors, type AppearanceComponents, type AppearanceLogo, type AppearanceModeTokens, type AppearanceTypography, type AttachOAuthTokenRequest, type AttachOAuthTokenResponse, type AuthAppearance, type AuthFlow, type AuthFlowComponent, type AuthLoginMethod, type AuthProviderConfig, type BaseGetBalanceParams, type BaseGetBalanceResult, type BaseGetTokenAccountsParams, type BaseSendTransactionParams, type BaseSendTransactionResult, type BaseSignMessageParams, type BaseSignMessageResult, type BaseSignTransactionParams, type BaseSignTransactionResult, type BaseTokenClaims, type BaseUIOptions, type BaseWalletHooks, type BlockExplorer, type Chain, type ChainConfigItem, type ChainEntry, type ChainLikeWithId, type ComponentStyle, type ContractUIOptions, type CreateWalletResponse, type DefaultFundingMethod, type DeleteSessionRequest, type DeleteSessionResponse, type DetachOAuthTokenRequest, type DeviceFingerprint, type DisplayMode, type EmailOtpConfig, type EmailOtpFlowState, type EphemeralSigner, type EphemeralSignerChain, type EphemeralSignerScheme, type EphemeralSignerWallet, type EthereumFundingConfig, type EthereumGetBalanceParams, type EthereumGetBalanceResult, type EthereumGetTokenAccountsByOwnerParams, type EthereumGetTokenAccountsByOwnerResult, type EthereumSendTransactionParams, type EthereumSendTransactionRequest, type EthereumSendTransactionResult, type EthereumSign7702AuthorizationParams, type EthereumSign7702AuthorizationResult, type EthereumSignHashParams, type EthereumSignHashResult, type EthereumSignMessageParams, type EthereumSignMessageResult, type EthereumSignTransactionParams, type EthereumSignTransactionResult, type EthereumSignTypedDataParams, type EthereumSignTypedDataResult, type EthereumSwitchChainParams, type EvmChainEntry, type ExportKeyConfig, type Factor, type FlexibleTheme, type FundWalletConfig, type FundingEvents, type FundingMethod, type FundingUIConfig, type GetCurrentSessionRequest, type GetCurrentSessionResponse, type Hex, type IdentityTokenClaims, type IdpProvider, type IsAuthenticatedRequest, type IsAuthenticatedResponse, type ListEphemeralSignersResult, type LoginTokenBundle, type LogoutRequest, type LogoutResponse, type MessageTypeProperty, type MessageTypes, type MoonPaySignRequest, type MoonPaySignResponse, type MpcKeyShares, type NativeCurrency, Network, type OAuthRequest, type OAuthResponse, type OnrampFundingSettings, type PasskeyEnrollConfig, type PasskeySettings, type PreferredCardProvider, type PrefillConfig, type PresenceTokenClaims, type ProvisionEphemeralSignerParams, type ProvisionEphemeralSignerResult, type PublicEthereumWallet, type PublicSessionData, type PublicWallet, type RefreshSessionRequest, type RefreshSessionResponse, type RetrieveWalletKeyRequest, type RetrieveWalletKeyResponse, type RevokeEphemeralSignerParams, type RpcConfig, type RpcUrls, type SdkSettings, type SendEmailOtpRequest, type SendEmailOtpResponse, type SendTransactionConfig, type SendTransactionRequest, type SessionData, type SessionWallet, type SharesDeviceRequest, type SharesDeviceResponse, type Sign7702AuthorizationError, type Sign7702AuthorizationParams, type Sign7702AuthorizationResponse, type Sign7702AuthorizationResult, type SignMessageConfig, type SignTransactionConfig, type SignTypedDataError, type SignTypedDataParams, type SignTypedDataResponse, type SignTypedDataResult, type SmsSettings, type SolanaChain, type SolanaChainEntry, type SolanaFundingConfig, type SolanaGetBalanceParams, type SolanaGetBalanceResult, type SolanaGetTokenAccountsByOwnerParams, type SolanaGetTokenAccountsByOwnerResult, type SolanaSendTransactionParams, type SolanaSendTransactionResult, type SolanaSignMessageParams, type SolanaSignMessageResult, type SolanaSignTransactionParams, type SolanaSignTransactionResult, type TransactionCommitment, type TransactionEncoding, type TransactionUIOptions, type TypedMessage, type UseFundWalletInterface, type UsersMePublicResponse, type UsersMeRequest, type UsersMeResponse, type VerifiedSession, type VerifyEmailOtpRequest, type VerifyEmailOtpResponse, type VerifyEmailOtpUser, type VerifyOAuthTokenRequest, type VerifyOAuthTokenResponse, type VerifySiweWalletRegistrationRequest, WALLET_ERROR_CODES, type Wallet, type WalletChain, type WalletChainType, type WalletConnectConfig, WalletCreationError, type WalletError, type WalletErrorCode, type WalletKeyRequest, type WalletListEntry, type WalletRegistrationNonceRequest, type WalletRegistrationNonceResponse, type WalletType, type WalletVerifyRequest };
1549
+ export { type AccessTokenClaims, type AppConfigRequest, type AppConfigResponse, type AppearanceBackdrop, type AppearanceBorderRadius, type AppearanceCard, type AppearanceColors, type AppearanceComponents, type AppearanceLogo, type AppearanceModeTokens, type AppearanceTypography, type AttachOAuthTokenRequest, type AttachOAuthTokenResponse, type AuthAppearance, type AuthFlow, type AuthFlowComponent, type AuthLoginMethod, type AuthProviderConfig, type BaseGetBalanceParams, type BaseGetBalanceResult, type BaseGetTokenAccountsParams, type BaseSendTransactionParams, type BaseSendTransactionResult, type BaseSignMessageParams, type BaseSignMessageResult, type BaseSignTransactionParams, type BaseSignTransactionResult, type BaseTokenClaims, type BaseUIOptions, type BaseWalletHooks, type BlockExplorer, type Chain, type ChainConfigItem, type ChainEntry, type ChainLikeWithId, type ComponentStyle, type ContractUIOptions, type CreateWalletResponse, type DefaultFundingMethod, type DeleteSessionRequest, type DeleteSessionResponse, type DetachOAuthTokenRequest, type DeviceFingerprint, type DisplayMode, type EmailOtpConfig, type EmailOtpFlowState, type EphemeralSigner, type EphemeralSignerChain, type EphemeralSignerScheme, type EphemeralSignerWallet, type EthereumFundingConfig, type EthereumGetBalanceParams, type EthereumGetBalanceResult, type EthereumGetTokenAccountsByOwnerParams, type EthereumGetTokenAccountsByOwnerResult, type EthereumSendTransactionParams, type EthereumSendTransactionRequest, type EthereumSendTransactionResult, type EthereumSign7702AuthorizationParams, type EthereumSign7702AuthorizationResult, type EthereumSignHashParams, type EthereumSignHashResult, type EthereumSignMessageParams, type EthereumSignMessageResult, type EthereumSignTransactionParams, type EthereumSignTransactionResult, type EthereumSignTypedDataParams, type EthereumSignTypedDataResult, type EthereumSwitchChainParams, type EvmChainEntry, type ExportKeyConfig, type Factor, type FlexibleTheme, type FundWalletConfig, type FundingEvents, type FundingMethod, type FundingUIConfig, type GetCurrentSessionRequest, type GetCurrentSessionResponse, type Hex, type IdentityTokenClaims, type IdpProvider, type IsAuthenticatedRequest, type IsAuthenticatedResponse, type ListEphemeralSignersResult, type LoginTokenBundle, type LogoutRequest, type LogoutResponse, type MessageTypeProperty, type MessageTypes, type MoonPaySignRequest, type MoonPaySignResponse, type MpcKeyShares, type NativeCurrency, Network, type OAuthRequest, type OAuthResponse, type OnrampFundingSettings, type PasskeyEnrollConfig, type PasskeySettings, type PreferredCardProvider, type PrefillConfig, type PresenceTokenClaims, type ProvisionEphemeralSignerParams, type ProvisionEphemeralSignerResult, type PublicEthereumWallet, type PublicSessionData, type PublicWallet, type RefreshSessionRequest, type RefreshSessionResponse, type RetrieveWalletKeyRequest, type RetrieveWalletKeyResponse, type RevokeEphemeralSignerParams, type RpcConfig, type RpcUrls, type SdkSettings, type SendEmailOtpRequest, type SendEmailOtpResponse, type SendTransactionConfig, type SendTransactionRequest, type SessionData, type SessionWallet, type SharesDeviceRequest, type SharesDeviceResponse, type Sign7702AuthorizationError, type Sign7702AuthorizationParams, type Sign7702AuthorizationResponse, type Sign7702AuthorizationResult, type SignMessageConfig, type SignTransactionConfig, type SignTypedDataError, type SignTypedDataParams, type SignTypedDataResponse, type SignTypedDataResult, type SmsSettings, type SolanaChain, type SolanaChainEntry, type SolanaFundingConfig, type SolanaGetBalanceParams, type SolanaGetBalanceResult, type SolanaGetTokenAccountsByOwnerParams, type SolanaGetTokenAccountsByOwnerResult, type SolanaSendTransactionParams, type SolanaSendTransactionResult, type SolanaSignMessageParams, type SolanaSignMessageResult, type SolanaSignTransactionParams, type SolanaSignTransactionResult, type TransactionCommitment, type TransactionEncoding, type TransactionUIOptions, type TronChainEntry, type TronGetBalanceParams, type TronGetBalanceResult, type TronSendTransactionParams, type TronSendTransactionResult, type TronSignMessageParams, type TronSignMessageResult, type TronSignTransactionParams, type TronSignTransactionResult, type TronTransactionJson, type TypedMessage, type UseFundWalletInterface, type UsersMePublicResponse, type UsersMeRequest, type UsersMeResponse, type VerifiedSession, type VerifyEmailOtpRequest, type VerifyEmailOtpResponse, type VerifyEmailOtpUser, type VerifyOAuthTokenRequest, type VerifyOAuthTokenResponse, type VerifySiweWalletRegistrationRequest, WALLET_ERROR_CODES, type Wallet, type WalletChain, type WalletChainType, type WalletConnectConfig, WalletCreationError, type WalletError, type WalletErrorCode, type WalletKeyRequest, type WalletListEntry, type WalletRegistrationNonceRequest, type WalletRegistrationNonceResponse, type WalletType, type WalletVerifyRequest };