decane-connect-kit 2.3.0 → 2.4.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/dist/index.cjs +88 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -29
- package/dist/index.d.ts +48 -29
- package/dist/index.js +83 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -175,6 +175,7 @@ declare class ApiClient {
|
|
|
175
175
|
getAddresses(jwt: string): Promise<{
|
|
176
176
|
evm: string | null;
|
|
177
177
|
solana: string | null;
|
|
178
|
+
tron: string | null;
|
|
178
179
|
}>;
|
|
179
180
|
putShare(jwt: string, share: {
|
|
180
181
|
ciphertext: Uint8Array;
|
|
@@ -182,6 +183,7 @@ declare class ApiClient {
|
|
|
182
183
|
wrappedShareMeta: WrappedShareMeta;
|
|
183
184
|
evmAddress: string;
|
|
184
185
|
solanaAddress: string;
|
|
186
|
+
tronAddress: string;
|
|
185
187
|
}): Promise<void>;
|
|
186
188
|
getWebAuthnRegisterOptions(jwt: string, rpId: string, rpName: string): Promise<_simplewebauthn_browser.PublicKeyCredentialCreationOptionsJSON>;
|
|
187
189
|
postWebAuthnRegister(jwt: string, response: _simplewebauthn_browser.RegistrationResponseJSON, origin: string): Promise<void>;
|
|
@@ -316,19 +318,18 @@ interface EthereumProviderOptions {
|
|
|
316
318
|
* `signAuthorization` (EIP-7702) is wired only when the client exposes it — that
|
|
317
319
|
* requires the TEE signer to support the authorization signing path.
|
|
318
320
|
*/
|
|
319
|
-
declare function createEthereumProvider(client: DecaneConnect
|
|
320
|
-
signAuthorization?: (req: {
|
|
321
|
-
chainId: number;
|
|
322
|
-
address: string;
|
|
323
|
-
nonce: number;
|
|
324
|
-
}) => Promise<{
|
|
325
|
-
yParity: number;
|
|
326
|
-
r: string;
|
|
327
|
-
s: string;
|
|
328
|
-
}>;
|
|
329
|
-
}, opts?: EthereumProviderOptions): Eip1193Provider;
|
|
321
|
+
declare function createEthereumProvider(client: DecaneConnect, opts?: EthereumProviderOptions): Eip1193Provider;
|
|
330
322
|
|
|
331
|
-
|
|
323
|
+
interface SignedAuthorization {
|
|
324
|
+
chainId: number;
|
|
325
|
+
address: string;
|
|
326
|
+
nonce: number;
|
|
327
|
+
yParity: number;
|
|
328
|
+
r: string;
|
|
329
|
+
s: string;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
type Chain = `evm:${number}` | `solana:${'mainnet' | 'devnet'}` | `tron:${'mainnet' | 'shasta' | 'nile'}`;
|
|
332
333
|
interface DecaneConnectConfig {
|
|
333
334
|
/** Dashboard project ID (public). Sent with every request so the backend can
|
|
334
335
|
* confirm the API key below actually belongs to this project. */
|
|
@@ -406,6 +407,7 @@ interface ConnectResult {
|
|
|
406
407
|
addresses: {
|
|
407
408
|
evm?: string;
|
|
408
409
|
solana?: string;
|
|
410
|
+
tron?: string;
|
|
409
411
|
};
|
|
410
412
|
isNewUser: boolean;
|
|
411
413
|
}
|
|
@@ -490,25 +492,40 @@ interface DecaneConnect {
|
|
|
490
492
|
chainId?: number;
|
|
491
493
|
}): Eip1193Provider;
|
|
492
494
|
/**
|
|
493
|
-
* Sign an EIP-7702 authorization, delegating this EOA to
|
|
494
|
-
* `chainId`. Enables account-abstraction /
|
|
495
|
-
*
|
|
496
|
-
*
|
|
495
|
+
* Sign an EIP-7702 authorization, delegating this EOA to a smart-account
|
|
496
|
+
* implementation contract on `chainId`. Enables account-abstraction /
|
|
497
|
+
* sponsored-gas flows. Returns the full viem `SignedAuthorization` tuple, so
|
|
498
|
+
* it drops straight into a userOperation's `authorization` field or a type-4
|
|
499
|
+
* transaction's authorizationList. `address` and `contractAddress` are
|
|
500
|
+
* interchangeable (the latter matches Privy's/older viem's param name).
|
|
497
501
|
*/
|
|
498
502
|
signAuthorization(req: {
|
|
499
503
|
chainId: number;
|
|
500
|
-
address
|
|
504
|
+
address?: string;
|
|
505
|
+
contractAddress?: string;
|
|
501
506
|
nonce: number;
|
|
502
|
-
}): Promise<
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
+
}): Promise<SignedAuthorization>;
|
|
508
|
+
/**
|
|
509
|
+
* The current session's access token (the Decane JWT). Use it to authenticate
|
|
510
|
+
* the user to your own backend (e.g. a sponsored-bundler proxy); verify it
|
|
511
|
+
* server-side against backend.decane.app/.well-known/jwks.json. Null with no
|
|
512
|
+
* live session.
|
|
513
|
+
*/
|
|
514
|
+
getAccessToken(): string | null;
|
|
507
515
|
signSolanaTransaction(tx: Uint8Array): Promise<Uint8Array>;
|
|
516
|
+
/**
|
|
517
|
+
* Sign a Tron transaction. Pass the transaction's `raw_data_hex` (the value
|
|
518
|
+
* TronWeb puts on a built transaction). The enclave computes the txID
|
|
519
|
+
* (sha256(raw_data)) and signs it with the same secp256k1 key as the EVM
|
|
520
|
+
* wallet; returns the 65-byte recoverable signature as 0x-hex. Attach it to
|
|
521
|
+
* the transaction's `signature` array and broadcast via TronWeb / a full node.
|
|
522
|
+
*/
|
|
523
|
+
signTronTransaction(rawDataHex: string): Promise<string>;
|
|
508
524
|
disconnect(): Promise<void>;
|
|
509
525
|
getAddresses(): {
|
|
510
526
|
evm?: string;
|
|
511
527
|
solana?: string;
|
|
528
|
+
tron?: string;
|
|
512
529
|
} | null;
|
|
513
530
|
/**
|
|
514
531
|
* Native-token balance for a chain (defaults to the first configured EVM
|
|
@@ -775,6 +792,7 @@ interface SocialAuthState {
|
|
|
775
792
|
addresses: {
|
|
776
793
|
evm?: string;
|
|
777
794
|
solana?: string;
|
|
795
|
+
tron?: string;
|
|
778
796
|
} | null;
|
|
779
797
|
isNewUser: boolean;
|
|
780
798
|
isUnlocked: boolean;
|
|
@@ -859,6 +877,7 @@ declare function useSocialAuth(): {
|
|
|
859
877
|
addresses: {
|
|
860
878
|
evm?: string;
|
|
861
879
|
solana?: string;
|
|
880
|
+
tron?: string;
|
|
862
881
|
} | null;
|
|
863
882
|
sessionExpiresAt: number | null;
|
|
864
883
|
canUsePasskey: boolean;
|
|
@@ -892,6 +911,7 @@ declare function useSocialWallet(): {
|
|
|
892
911
|
addresses: {
|
|
893
912
|
evm?: string;
|
|
894
913
|
solana?: string;
|
|
914
|
+
tron?: string;
|
|
895
915
|
} | null;
|
|
896
916
|
sessionExpiresAt: number | null;
|
|
897
917
|
needsReconnect: boolean;
|
|
@@ -912,6 +932,7 @@ declare function useSocialWallet(): {
|
|
|
912
932
|
gasPrice?: bigint;
|
|
913
933
|
}) => Promise<string>;
|
|
914
934
|
signSolanaTransaction: (tx: Uint8Array) => Promise<Uint8Array<ArrayBufferLike>>;
|
|
935
|
+
signTronTransaction: (rawDataHex: string) => Promise<string>;
|
|
915
936
|
signTypedData: (req: {
|
|
916
937
|
chain: string;
|
|
917
938
|
domain: Record<string, unknown>;
|
|
@@ -926,16 +947,14 @@ declare function useSocialWallet(): {
|
|
|
926
947
|
}[]>;
|
|
927
948
|
signAuthorization: (req: {
|
|
928
949
|
chainId: number;
|
|
929
|
-
address
|
|
950
|
+
address?: string;
|
|
951
|
+
contractAddress?: string;
|
|
930
952
|
nonce: number;
|
|
931
|
-
}) => Promise<
|
|
932
|
-
yParity: number;
|
|
933
|
-
r: string;
|
|
934
|
-
s: string;
|
|
935
|
-
}>;
|
|
953
|
+
}) => Promise<SignedAuthorization>;
|
|
936
954
|
getEthereumProvider: (opts?: {
|
|
937
955
|
chainId?: number;
|
|
938
956
|
}) => Eip1193Provider;
|
|
957
|
+
getAccessToken: () => string | null;
|
|
939
958
|
rotateShares: (opts: {
|
|
940
959
|
password: string;
|
|
941
960
|
passwordHint?: string;
|
|
@@ -1032,4 +1051,4 @@ declare function useSignTypedData(): {
|
|
|
1032
1051
|
reset: () => void;
|
|
1033
1052
|
};
|
|
1034
1053
|
|
|
1035
|
-
export { type ActiveSession, AttestationError, type AuthResult, BUILT_IN_CHAINS, type BalanceResult, type CAIP25Method, type CAIP25SessionRequest, type CAIP25SessionResult, CHAINS, CallSequenceError, type Chain, type ChainDescriptor, type ChainId, type ChainScope, type ChainSupport, type ChainType, type ConnectMode, type ConnectResult, type DecaneConfig, type DecaneConnect, type DecaneConnectConfig, DecaneConnectError, DecaneError, DecaneErrorCode, DecaneKit, DecaneLogo, DecaneMark, type DecaneProvider, DecaneWordmark, type Eip1193Provider, type EthereumProviderOptions, ExportNotAuthorizedError, InvalidApiKeyError, InvalidPinError, InvalidRecoveryFileError, NetworkError, NewDeviceError, OriginNotAllowedError, type PortableBackup, PromptPinNotConfiguredError, ReconnectRequiredError, RecoveryFailedError, type RecoveryProgress, type RecoveryShareFile, RecoveryWalletMismatchError, type SdkEvent, type SendTransactionRequest, SessionExpiredError, ShareCorruptedError, type SignMessageRequest, type SignTypedDataRequest, type SocialAuthState, type SocialConfig, SocialWalletModal, type Theme, type TxParams, type UnifiedWalletAccount, UnlockRequiredError, UserCancelledError, WalletSelector, WebAuthnNotSupportedError, type WrappedShareMeta, WrongPasswordError, createDecane, createDecaneConnect, createEthereumProvider, startEmailAuth, useChainSwitch, useDecane, useEthereumProvider, useSendTransaction, useSignMessage, useSignTypedData, useSocialAuth, useSocialBalance, useSocialWallet, useWalletSelector, verifyEmailCode };
|
|
1054
|
+
export { type ActiveSession, AttestationError, type AuthResult, BUILT_IN_CHAINS, type BalanceResult, type CAIP25Method, type CAIP25SessionRequest, type CAIP25SessionResult, CHAINS, CallSequenceError, type Chain, type ChainDescriptor, type ChainId, type ChainScope, type ChainSupport, type ChainType, type ConnectMode, type ConnectResult, type DecaneConfig, type DecaneConnect, type DecaneConnectConfig, DecaneConnectError, DecaneError, DecaneErrorCode, DecaneKit, DecaneLogo, DecaneMark, type DecaneProvider, DecaneWordmark, type Eip1193Provider, type EthereumProviderOptions, ExportNotAuthorizedError, InvalidApiKeyError, InvalidPinError, InvalidRecoveryFileError, NetworkError, NewDeviceError, OriginNotAllowedError, type PortableBackup, PromptPinNotConfiguredError, ReconnectRequiredError, RecoveryFailedError, type RecoveryProgress, type RecoveryShareFile, RecoveryWalletMismatchError, type SdkEvent, type SendTransactionRequest, SessionExpiredError, ShareCorruptedError, type SignMessageRequest, type SignTypedDataRequest, type SignedAuthorization, type SocialAuthState, type SocialConfig, SocialWalletModal, type Theme, type TxParams, type UnifiedWalletAccount, UnlockRequiredError, UserCancelledError, WalletSelector, WebAuthnNotSupportedError, type WrappedShareMeta, WrongPasswordError, createDecane, createDecaneConnect, createEthereumProvider, startEmailAuth, useChainSwitch, useDecane, useEthereumProvider, useSendTransaction, useSignMessage, useSignTypedData, useSocialAuth, useSocialBalance, useSocialWallet, useWalletSelector, verifyEmailCode };
|
package/dist/index.d.ts
CHANGED
|
@@ -175,6 +175,7 @@ declare class ApiClient {
|
|
|
175
175
|
getAddresses(jwt: string): Promise<{
|
|
176
176
|
evm: string | null;
|
|
177
177
|
solana: string | null;
|
|
178
|
+
tron: string | null;
|
|
178
179
|
}>;
|
|
179
180
|
putShare(jwt: string, share: {
|
|
180
181
|
ciphertext: Uint8Array;
|
|
@@ -182,6 +183,7 @@ declare class ApiClient {
|
|
|
182
183
|
wrappedShareMeta: WrappedShareMeta;
|
|
183
184
|
evmAddress: string;
|
|
184
185
|
solanaAddress: string;
|
|
186
|
+
tronAddress: string;
|
|
185
187
|
}): Promise<void>;
|
|
186
188
|
getWebAuthnRegisterOptions(jwt: string, rpId: string, rpName: string): Promise<_simplewebauthn_browser.PublicKeyCredentialCreationOptionsJSON>;
|
|
187
189
|
postWebAuthnRegister(jwt: string, response: _simplewebauthn_browser.RegistrationResponseJSON, origin: string): Promise<void>;
|
|
@@ -316,19 +318,18 @@ interface EthereumProviderOptions {
|
|
|
316
318
|
* `signAuthorization` (EIP-7702) is wired only when the client exposes it — that
|
|
317
319
|
* requires the TEE signer to support the authorization signing path.
|
|
318
320
|
*/
|
|
319
|
-
declare function createEthereumProvider(client: DecaneConnect
|
|
320
|
-
signAuthorization?: (req: {
|
|
321
|
-
chainId: number;
|
|
322
|
-
address: string;
|
|
323
|
-
nonce: number;
|
|
324
|
-
}) => Promise<{
|
|
325
|
-
yParity: number;
|
|
326
|
-
r: string;
|
|
327
|
-
s: string;
|
|
328
|
-
}>;
|
|
329
|
-
}, opts?: EthereumProviderOptions): Eip1193Provider;
|
|
321
|
+
declare function createEthereumProvider(client: DecaneConnect, opts?: EthereumProviderOptions): Eip1193Provider;
|
|
330
322
|
|
|
331
|
-
|
|
323
|
+
interface SignedAuthorization {
|
|
324
|
+
chainId: number;
|
|
325
|
+
address: string;
|
|
326
|
+
nonce: number;
|
|
327
|
+
yParity: number;
|
|
328
|
+
r: string;
|
|
329
|
+
s: string;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
type Chain = `evm:${number}` | `solana:${'mainnet' | 'devnet'}` | `tron:${'mainnet' | 'shasta' | 'nile'}`;
|
|
332
333
|
interface DecaneConnectConfig {
|
|
333
334
|
/** Dashboard project ID (public). Sent with every request so the backend can
|
|
334
335
|
* confirm the API key below actually belongs to this project. */
|
|
@@ -406,6 +407,7 @@ interface ConnectResult {
|
|
|
406
407
|
addresses: {
|
|
407
408
|
evm?: string;
|
|
408
409
|
solana?: string;
|
|
410
|
+
tron?: string;
|
|
409
411
|
};
|
|
410
412
|
isNewUser: boolean;
|
|
411
413
|
}
|
|
@@ -490,25 +492,40 @@ interface DecaneConnect {
|
|
|
490
492
|
chainId?: number;
|
|
491
493
|
}): Eip1193Provider;
|
|
492
494
|
/**
|
|
493
|
-
* Sign an EIP-7702 authorization, delegating this EOA to
|
|
494
|
-
* `chainId`. Enables account-abstraction /
|
|
495
|
-
*
|
|
496
|
-
*
|
|
495
|
+
* Sign an EIP-7702 authorization, delegating this EOA to a smart-account
|
|
496
|
+
* implementation contract on `chainId`. Enables account-abstraction /
|
|
497
|
+
* sponsored-gas flows. Returns the full viem `SignedAuthorization` tuple, so
|
|
498
|
+
* it drops straight into a userOperation's `authorization` field or a type-4
|
|
499
|
+
* transaction's authorizationList. `address` and `contractAddress` are
|
|
500
|
+
* interchangeable (the latter matches Privy's/older viem's param name).
|
|
497
501
|
*/
|
|
498
502
|
signAuthorization(req: {
|
|
499
503
|
chainId: number;
|
|
500
|
-
address
|
|
504
|
+
address?: string;
|
|
505
|
+
contractAddress?: string;
|
|
501
506
|
nonce: number;
|
|
502
|
-
}): Promise<
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
+
}): Promise<SignedAuthorization>;
|
|
508
|
+
/**
|
|
509
|
+
* The current session's access token (the Decane JWT). Use it to authenticate
|
|
510
|
+
* the user to your own backend (e.g. a sponsored-bundler proxy); verify it
|
|
511
|
+
* server-side against backend.decane.app/.well-known/jwks.json. Null with no
|
|
512
|
+
* live session.
|
|
513
|
+
*/
|
|
514
|
+
getAccessToken(): string | null;
|
|
507
515
|
signSolanaTransaction(tx: Uint8Array): Promise<Uint8Array>;
|
|
516
|
+
/**
|
|
517
|
+
* Sign a Tron transaction. Pass the transaction's `raw_data_hex` (the value
|
|
518
|
+
* TronWeb puts on a built transaction). The enclave computes the txID
|
|
519
|
+
* (sha256(raw_data)) and signs it with the same secp256k1 key as the EVM
|
|
520
|
+
* wallet; returns the 65-byte recoverable signature as 0x-hex. Attach it to
|
|
521
|
+
* the transaction's `signature` array and broadcast via TronWeb / a full node.
|
|
522
|
+
*/
|
|
523
|
+
signTronTransaction(rawDataHex: string): Promise<string>;
|
|
508
524
|
disconnect(): Promise<void>;
|
|
509
525
|
getAddresses(): {
|
|
510
526
|
evm?: string;
|
|
511
527
|
solana?: string;
|
|
528
|
+
tron?: string;
|
|
512
529
|
} | null;
|
|
513
530
|
/**
|
|
514
531
|
* Native-token balance for a chain (defaults to the first configured EVM
|
|
@@ -775,6 +792,7 @@ interface SocialAuthState {
|
|
|
775
792
|
addresses: {
|
|
776
793
|
evm?: string;
|
|
777
794
|
solana?: string;
|
|
795
|
+
tron?: string;
|
|
778
796
|
} | null;
|
|
779
797
|
isNewUser: boolean;
|
|
780
798
|
isUnlocked: boolean;
|
|
@@ -859,6 +877,7 @@ declare function useSocialAuth(): {
|
|
|
859
877
|
addresses: {
|
|
860
878
|
evm?: string;
|
|
861
879
|
solana?: string;
|
|
880
|
+
tron?: string;
|
|
862
881
|
} | null;
|
|
863
882
|
sessionExpiresAt: number | null;
|
|
864
883
|
canUsePasskey: boolean;
|
|
@@ -892,6 +911,7 @@ declare function useSocialWallet(): {
|
|
|
892
911
|
addresses: {
|
|
893
912
|
evm?: string;
|
|
894
913
|
solana?: string;
|
|
914
|
+
tron?: string;
|
|
895
915
|
} | null;
|
|
896
916
|
sessionExpiresAt: number | null;
|
|
897
917
|
needsReconnect: boolean;
|
|
@@ -912,6 +932,7 @@ declare function useSocialWallet(): {
|
|
|
912
932
|
gasPrice?: bigint;
|
|
913
933
|
}) => Promise<string>;
|
|
914
934
|
signSolanaTransaction: (tx: Uint8Array) => Promise<Uint8Array<ArrayBufferLike>>;
|
|
935
|
+
signTronTransaction: (rawDataHex: string) => Promise<string>;
|
|
915
936
|
signTypedData: (req: {
|
|
916
937
|
chain: string;
|
|
917
938
|
domain: Record<string, unknown>;
|
|
@@ -926,16 +947,14 @@ declare function useSocialWallet(): {
|
|
|
926
947
|
}[]>;
|
|
927
948
|
signAuthorization: (req: {
|
|
928
949
|
chainId: number;
|
|
929
|
-
address
|
|
950
|
+
address?: string;
|
|
951
|
+
contractAddress?: string;
|
|
930
952
|
nonce: number;
|
|
931
|
-
}) => Promise<
|
|
932
|
-
yParity: number;
|
|
933
|
-
r: string;
|
|
934
|
-
s: string;
|
|
935
|
-
}>;
|
|
953
|
+
}) => Promise<SignedAuthorization>;
|
|
936
954
|
getEthereumProvider: (opts?: {
|
|
937
955
|
chainId?: number;
|
|
938
956
|
}) => Eip1193Provider;
|
|
957
|
+
getAccessToken: () => string | null;
|
|
939
958
|
rotateShares: (opts: {
|
|
940
959
|
password: string;
|
|
941
960
|
passwordHint?: string;
|
|
@@ -1032,4 +1051,4 @@ declare function useSignTypedData(): {
|
|
|
1032
1051
|
reset: () => void;
|
|
1033
1052
|
};
|
|
1034
1053
|
|
|
1035
|
-
export { type ActiveSession, AttestationError, type AuthResult, BUILT_IN_CHAINS, type BalanceResult, type CAIP25Method, type CAIP25SessionRequest, type CAIP25SessionResult, CHAINS, CallSequenceError, type Chain, type ChainDescriptor, type ChainId, type ChainScope, type ChainSupport, type ChainType, type ConnectMode, type ConnectResult, type DecaneConfig, type DecaneConnect, type DecaneConnectConfig, DecaneConnectError, DecaneError, DecaneErrorCode, DecaneKit, DecaneLogo, DecaneMark, type DecaneProvider, DecaneWordmark, type Eip1193Provider, type EthereumProviderOptions, ExportNotAuthorizedError, InvalidApiKeyError, InvalidPinError, InvalidRecoveryFileError, NetworkError, NewDeviceError, OriginNotAllowedError, type PortableBackup, PromptPinNotConfiguredError, ReconnectRequiredError, RecoveryFailedError, type RecoveryProgress, type RecoveryShareFile, RecoveryWalletMismatchError, type SdkEvent, type SendTransactionRequest, SessionExpiredError, ShareCorruptedError, type SignMessageRequest, type SignTypedDataRequest, type SocialAuthState, type SocialConfig, SocialWalletModal, type Theme, type TxParams, type UnifiedWalletAccount, UnlockRequiredError, UserCancelledError, WalletSelector, WebAuthnNotSupportedError, type WrappedShareMeta, WrongPasswordError, createDecane, createDecaneConnect, createEthereumProvider, startEmailAuth, useChainSwitch, useDecane, useEthereumProvider, useSendTransaction, useSignMessage, useSignTypedData, useSocialAuth, useSocialBalance, useSocialWallet, useWalletSelector, verifyEmailCode };
|
|
1054
|
+
export { type ActiveSession, AttestationError, type AuthResult, BUILT_IN_CHAINS, type BalanceResult, type CAIP25Method, type CAIP25SessionRequest, type CAIP25SessionResult, CHAINS, CallSequenceError, type Chain, type ChainDescriptor, type ChainId, type ChainScope, type ChainSupport, type ChainType, type ConnectMode, type ConnectResult, type DecaneConfig, type DecaneConnect, type DecaneConnectConfig, DecaneConnectError, DecaneError, DecaneErrorCode, DecaneKit, DecaneLogo, DecaneMark, type DecaneProvider, DecaneWordmark, type Eip1193Provider, type EthereumProviderOptions, ExportNotAuthorizedError, InvalidApiKeyError, InvalidPinError, InvalidRecoveryFileError, NetworkError, NewDeviceError, OriginNotAllowedError, type PortableBackup, PromptPinNotConfiguredError, ReconnectRequiredError, RecoveryFailedError, type RecoveryProgress, type RecoveryShareFile, RecoveryWalletMismatchError, type SdkEvent, type SendTransactionRequest, SessionExpiredError, ShareCorruptedError, type SignMessageRequest, type SignTypedDataRequest, type SignedAuthorization, type SocialAuthState, type SocialConfig, SocialWalletModal, type Theme, type TxParams, type UnifiedWalletAccount, UnlockRequiredError, UserCancelledError, WalletSelector, WebAuthnNotSupportedError, type WrappedShareMeta, WrongPasswordError, createDecane, createDecaneConnect, createEthereumProvider, startEmailAuth, useChainSwitch, useDecane, useEthereumProvider, useSendTransaction, useSignMessage, useSignTypedData, useSocialAuth, useSocialBalance, useSocialWallet, useWalletSelector, verifyEmailCode };
|
package/dist/index.js
CHANGED
|
@@ -1892,7 +1892,7 @@ function createDecane(config) {
|
|
|
1892
1892
|
|
|
1893
1893
|
// src/social/client.ts
|
|
1894
1894
|
init_errors();
|
|
1895
|
-
import { Wallet } from "ethers";
|
|
1895
|
+
import { Wallet, sha256 as sha2562, encodeBase58 as encodeBase582 } from "ethers";
|
|
1896
1896
|
import { Transaction as Transaction2, VersionedTransaction, Keypair } from "@solana/web3.js";
|
|
1897
1897
|
|
|
1898
1898
|
// src/social/events.ts
|
|
@@ -1986,7 +1986,8 @@ var ApiClient = class {
|
|
|
1986
1986
|
iv: bytesToB64(share.iv),
|
|
1987
1987
|
wrappedShareMeta: btoa(JSON.stringify(share.wrappedShareMeta)),
|
|
1988
1988
|
evmAddress: share.evmAddress,
|
|
1989
|
-
solanaAddress: share.solanaAddress
|
|
1989
|
+
solanaAddress: share.solanaAddress,
|
|
1990
|
+
tronAddress: share.tronAddress
|
|
1990
1991
|
})
|
|
1991
1992
|
});
|
|
1992
1993
|
}
|
|
@@ -2127,6 +2128,9 @@ var Storage = class {
|
|
|
2127
2128
|
}
|
|
2128
2129
|
};
|
|
2129
2130
|
|
|
2131
|
+
// src/social/session.ts
|
|
2132
|
+
import { sha256, encodeBase58 } from "ethers";
|
|
2133
|
+
|
|
2130
2134
|
// src/social/teeClient.ts
|
|
2131
2135
|
import { startAuthentication } from "@simplewebauthn/browser";
|
|
2132
2136
|
|
|
@@ -2407,6 +2411,11 @@ var TeeClient = class {
|
|
|
2407
2411
|
|
|
2408
2412
|
// src/social/session.ts
|
|
2409
2413
|
init_errors();
|
|
2414
|
+
function evmToTronAddress(evmAddress) {
|
|
2415
|
+
const hex41 = "41" + evmAddress.toLowerCase().replace(/^0x/, "");
|
|
2416
|
+
const checksum = sha256(sha256("0x" + hex41)).slice(2, 10);
|
|
2417
|
+
return encodeBase58("0x" + hex41 + checksum);
|
|
2418
|
+
}
|
|
2410
2419
|
var SessionManager = class {
|
|
2411
2420
|
constructor(events, durationMs, teeUrl, requireAssertionPerSignature = false) {
|
|
2412
2421
|
this.events = events;
|
|
@@ -2416,6 +2425,7 @@ var SessionManager = class {
|
|
|
2416
2425
|
this.tee = null;
|
|
2417
2426
|
this.evmAddress = null;
|
|
2418
2427
|
this.solanaAddress = null;
|
|
2428
|
+
this.tronAddress = null;
|
|
2419
2429
|
this.expiresAt = null;
|
|
2420
2430
|
this.timeoutId = null;
|
|
2421
2431
|
}
|
|
@@ -2442,6 +2452,7 @@ var SessionManager = class {
|
|
|
2442
2452
|
this.tee.adoptHandle(handle, this.requireAssertionPerSignature);
|
|
2443
2453
|
this.evmAddress = addresses.evm;
|
|
2444
2454
|
this.solanaAddress = addresses.solana;
|
|
2455
|
+
this.tronAddress = addresses.tron ?? evmToTronAddress(addresses.evm);
|
|
2445
2456
|
this.expiresAt = expiresAtMs;
|
|
2446
2457
|
this.setExpiryTimer(expiresAtMs - Date.now());
|
|
2447
2458
|
this.events.emit("session-started");
|
|
@@ -2468,15 +2479,17 @@ var SessionManager = class {
|
|
|
2468
2479
|
"requireAssertionPerSignature was requested but this signer does not support it \u2014 refusing to open a session with weaker authority than configured."
|
|
2469
2480
|
);
|
|
2470
2481
|
}
|
|
2471
|
-
const
|
|
2472
|
-
if (!
|
|
2482
|
+
const resolved = verified ?? fallback;
|
|
2483
|
+
if (!resolved) {
|
|
2473
2484
|
this.tee = null;
|
|
2474
2485
|
throw new Error(
|
|
2475
2486
|
"No addresses available for this wallet \u2014 the signer could not derive them and none are recorded"
|
|
2476
2487
|
);
|
|
2477
2488
|
}
|
|
2489
|
+
const addresses = { evm: resolved.evm, solana: resolved.solana, tron: resolved.tron ?? evmToTronAddress(resolved.evm) };
|
|
2478
2490
|
this.evmAddress = addresses.evm;
|
|
2479
2491
|
this.solanaAddress = addresses.solana;
|
|
2492
|
+
this.tronAddress = addresses.tron;
|
|
2480
2493
|
const serverTtlMs = this.tee.sessionExpiresIn();
|
|
2481
2494
|
const effectiveMs = serverTtlMs != null ? Math.min(this.durationMs, serverTtlMs * 1e3) : this.durationMs;
|
|
2482
2495
|
this.expiresAt = Date.now() + effectiveMs;
|
|
@@ -2493,6 +2506,7 @@ var SessionManager = class {
|
|
|
2493
2506
|
this.tee = null;
|
|
2494
2507
|
this.evmAddress = null;
|
|
2495
2508
|
this.solanaAddress = null;
|
|
2509
|
+
this.tronAddress = null;
|
|
2496
2510
|
this.expiresAt = null;
|
|
2497
2511
|
if (this.timeoutId) {
|
|
2498
2512
|
clearTimeout(this.timeoutId);
|
|
@@ -2511,7 +2525,11 @@ var SessionManager = class {
|
|
|
2511
2525
|
}
|
|
2512
2526
|
addresses() {
|
|
2513
2527
|
if (!this.evmAddress || !this.solanaAddress) return null;
|
|
2514
|
-
return {
|
|
2528
|
+
return {
|
|
2529
|
+
evm: this.evmAddress,
|
|
2530
|
+
solana: this.solanaAddress,
|
|
2531
|
+
tron: this.tronAddress ?? evmToTronAddress(this.evmAddress)
|
|
2532
|
+
};
|
|
2515
2533
|
}
|
|
2516
2534
|
};
|
|
2517
2535
|
|
|
@@ -2714,7 +2732,7 @@ async function signEvmAuthorization(tee, chainId, address, nonce, jwt) {
|
|
|
2714
2732
|
const r = "0x" + hex.slice(0, 64);
|
|
2715
2733
|
const s = "0x" + hex.slice(64, 128);
|
|
2716
2734
|
const v = parseInt(hex.slice(128, 130), 16);
|
|
2717
|
-
return { yParity: v >= 27 ? v - 27 : v, r, s };
|
|
2735
|
+
return { chainId, address, nonce, yParity: v >= 27 ? v - 27 : v, r, s };
|
|
2718
2736
|
}
|
|
2719
2737
|
async function signEvmTypedData(tee, chain, typedData, jwt) {
|
|
2720
2738
|
const payload = JSON.stringify(
|
|
@@ -2875,9 +2893,6 @@ function createEthereumProvider(client, opts = {}) {
|
|
|
2875
2893
|
}
|
|
2876
2894
|
case "eth_signAuthorization":
|
|
2877
2895
|
case "wallet_sign7702Authorization": {
|
|
2878
|
-
if (!client.signAuthorization) {
|
|
2879
|
-
throw Object.assign(new Error("EIP-7702 is not supported by the connected signer."), { code: 4200 });
|
|
2880
|
-
}
|
|
2881
2896
|
const p = params[0];
|
|
2882
2897
|
const cid = p.chainId != null ? Number(asBigInt(p.chainId)) : chainId;
|
|
2883
2898
|
const address = p.address ?? p.contractAddress;
|
|
@@ -3367,9 +3382,11 @@ async function createDecaneConnect(config) {
|
|
|
3367
3382
|
let shareSet;
|
|
3368
3383
|
let evmAddress;
|
|
3369
3384
|
let solanaAddress;
|
|
3385
|
+
let tronAddress;
|
|
3370
3386
|
try {
|
|
3371
3387
|
evmAddress = new Wallet(toHex2(master)).address;
|
|
3372
3388
|
solanaAddress = Keypair.fromSeed(master).publicKey.toBase58();
|
|
3389
|
+
tronAddress = evmToTronAddress2(evmAddress);
|
|
3373
3390
|
shareSet = await splitMaster(master, 1);
|
|
3374
3391
|
} finally {
|
|
3375
3392
|
zeroize(master);
|
|
@@ -3400,10 +3417,11 @@ async function createDecaneConnect(config) {
|
|
|
3400
3417
|
// credential IDs, prfSalt, pinSalt stay on-device — never sent to server
|
|
3401
3418
|
},
|
|
3402
3419
|
evmAddress,
|
|
3403
|
-
solanaAddress
|
|
3420
|
+
solanaAddress,
|
|
3421
|
+
tronAddress
|
|
3404
3422
|
});
|
|
3405
3423
|
zeroize(shareSet.server);
|
|
3406
|
-
const addresses = { evm: evmAddress, solana: solanaAddress };
|
|
3424
|
+
const addresses = { evm: evmAddress, solana: solanaAddress, tron: tronAddress };
|
|
3407
3425
|
if (unlockMethod === "passkey" && meta.credentialId && meta.prfSalt) {
|
|
3408
3426
|
try {
|
|
3409
3427
|
await api.putRecoveryBackup(jwt, {
|
|
@@ -3426,6 +3444,7 @@ async function createDecaneConnect(config) {
|
|
|
3426
3444
|
}
|
|
3427
3445
|
addresses.evm = evmAddress = confirmed.evm;
|
|
3428
3446
|
addresses.solana = solanaAddress = confirmed.solana;
|
|
3447
|
+
addresses.tron = tronAddress = confirmed.tron ?? evmToTronAddress2(confirmed.evm);
|
|
3429
3448
|
if (config.offerRecoveryAtSignup !== false && config.onRecoveryShareOffer) {
|
|
3430
3449
|
try {
|
|
3431
3450
|
const choice = await config.onRecoveryShareOffer({ evmAddress, solanaAddress });
|
|
@@ -3449,7 +3468,7 @@ async function createDecaneConnect(config) {
|
|
|
3449
3468
|
}
|
|
3450
3469
|
async function returningUserUnlock(userId, jwt) {
|
|
3451
3470
|
const rawAddresses = await api.getAddresses(jwt);
|
|
3452
|
-
const recordedAddresses = rawAddresses.evm && rawAddresses.solana ? { evm: rawAddresses.evm, solana: rawAddresses.solana } : null;
|
|
3471
|
+
const recordedAddresses = rawAddresses.evm && rawAddresses.solana ? { evm: rawAddresses.evm, solana: rawAddresses.solana, tron: rawAddresses.tron ?? evmToTronAddress2(rawAddresses.evm) } : null;
|
|
3453
3472
|
const stored = await storage.getShare(userId);
|
|
3454
3473
|
let deviceShare;
|
|
3455
3474
|
if (!stored) {
|
|
@@ -3531,7 +3550,7 @@ async function createDecaneConnect(config) {
|
|
|
3531
3550
|
throw new ShareCorruptedError();
|
|
3532
3551
|
}
|
|
3533
3552
|
const rawAddresses = await api.getAddresses(result.jwt);
|
|
3534
|
-
const recordedAddresses = rawAddresses.evm && rawAddresses.solana ? { evm: rawAddresses.evm, solana: rawAddresses.solana } : null;
|
|
3553
|
+
const recordedAddresses = rawAddresses.evm && rawAddresses.solana ? { evm: rawAddresses.evm, solana: rawAddresses.solana, tron: rawAddresses.tron ?? evmToTronAddress2(rawAddresses.evm) } : null;
|
|
3535
3554
|
const addresses = await session.start(deviceShare, result.jwt, recordedAddresses);
|
|
3536
3555
|
zeroize(deviceShare);
|
|
3537
3556
|
auth = { jwt: result.jwt, userId, addresses };
|
|
@@ -3663,6 +3682,10 @@ async function createDecaneConnect(config) {
|
|
|
3663
3682
|
const sig = await signSolanaMessage(tee, req.chain, msg, auth?.jwt);
|
|
3664
3683
|
return bufferToB64u(sig);
|
|
3665
3684
|
}
|
|
3685
|
+
if (req.chain.startsWith("tron:")) {
|
|
3686
|
+
const msg = typeof req.message === "string" ? req.message : new TextDecoder().decode(req.message);
|
|
3687
|
+
return tee.sign({ chain: req.chain, kind: "message", payload: msg }, auth?.jwt);
|
|
3688
|
+
}
|
|
3666
3689
|
throw new CallSequenceError(`Unsupported chain: ${req.chain}`);
|
|
3667
3690
|
},
|
|
3668
3691
|
async sendTransaction(req) {
|
|
@@ -3731,7 +3754,16 @@ async function createDecaneConnect(config) {
|
|
|
3731
3754
|
},
|
|
3732
3755
|
async signAuthorization(req) {
|
|
3733
3756
|
const tee = session.requireActive();
|
|
3734
|
-
|
|
3757
|
+
const delegate = req.address ?? req.contractAddress;
|
|
3758
|
+
if (!delegate) throw new CallSequenceError("signAuthorization requires `address` (the delegate contract).");
|
|
3759
|
+
return signEvmAuthorization(tee, req.chainId, delegate, req.nonce, auth?.jwt);
|
|
3760
|
+
},
|
|
3761
|
+
// The current session's access token (the Decane JWT), for authenticating
|
|
3762
|
+
// the user to your own backend — e.g. a sponsored-bundler proxy. Verify it
|
|
3763
|
+
// server-side against https://backend.decane.app/.well-known/jwks.json.
|
|
3764
|
+
// Null when there is no live session.
|
|
3765
|
+
getAccessToken() {
|
|
3766
|
+
return auth?.jwt ?? null;
|
|
3735
3767
|
},
|
|
3736
3768
|
getEthereumProvider(opts) {
|
|
3737
3769
|
if (!ethProvider) {
|
|
@@ -3755,6 +3787,14 @@ async function createDecaneConnect(config) {
|
|
|
3755
3787
|
const solChain = config.chains.find((c) => c.startsWith("solana:")) ?? "solana:mainnet";
|
|
3756
3788
|
return signSolanaTransaction(tee, solChain, tx, auth?.jwt);
|
|
3757
3789
|
},
|
|
3790
|
+
async signTronTransaction(rawDataHex) {
|
|
3791
|
+
const tee = session.requireActive();
|
|
3792
|
+
const tronChain = config.chains.find((c) => c.startsWith("tron:")) ?? "tron:mainnet";
|
|
3793
|
+
return tee.sign(
|
|
3794
|
+
{ chain: tronChain, kind: "transaction", payload: rawDataHex.replace(/^0x/, "") },
|
|
3795
|
+
auth?.jwt
|
|
3796
|
+
);
|
|
3797
|
+
},
|
|
3758
3798
|
async disconnect() {
|
|
3759
3799
|
session.end();
|
|
3760
3800
|
if (auth?.jwt) {
|
|
@@ -3910,12 +3950,19 @@ function b64uToBuffer(b64u) {
|
|
|
3910
3950
|
function toHex2(bytes) {
|
|
3911
3951
|
return "0x" + Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
3912
3952
|
}
|
|
3953
|
+
function evmToTronAddress2(evmAddress) {
|
|
3954
|
+
const hex41 = "41" + evmAddress.toLowerCase().replace(/^0x/, "");
|
|
3955
|
+
const checksum = sha2562(sha2562("0x" + hex41)).slice(2, 10);
|
|
3956
|
+
return encodeBase582("0x" + hex41 + checksum);
|
|
3957
|
+
}
|
|
3913
3958
|
async function deriveAddressesFromShares(a, b) {
|
|
3914
3959
|
const master = await combineShares(a, b);
|
|
3915
3960
|
try {
|
|
3961
|
+
const evm = new Wallet(toHex2(master)).address;
|
|
3916
3962
|
return {
|
|
3917
|
-
evm
|
|
3918
|
-
solana: Keypair.fromSeed(master).publicKey.toBase58()
|
|
3963
|
+
evm,
|
|
3964
|
+
solana: Keypair.fromSeed(master).publicKey.toBase58(),
|
|
3965
|
+
tron: evmToTronAddress2(evm)
|
|
3919
3966
|
};
|
|
3920
3967
|
} finally {
|
|
3921
3968
|
zeroize(master);
|
|
@@ -5937,6 +5984,11 @@ function DecaneKit({ config, children }) {
|
|
|
5937
5984
|
if (!sdk) throw new Error("Social wallet not connected");
|
|
5938
5985
|
return sdk.signSolanaTransaction(tx);
|
|
5939
5986
|
}, []);
|
|
5987
|
+
const socialSignTronTransaction = useCallback3(async (rawDataHex) => {
|
|
5988
|
+
const sdk = socialRef.current;
|
|
5989
|
+
if (!sdk) throw new Error("Social wallet not connected");
|
|
5990
|
+
return sdk.signTronTransaction(rawDataHex);
|
|
5991
|
+
}, []);
|
|
5940
5992
|
const socialSignTypedData = useCallback3(async (req) => {
|
|
5941
5993
|
const sdk = socialRef.current;
|
|
5942
5994
|
if (!sdk) throw new Error("Social wallet not connected");
|
|
@@ -5960,6 +6012,9 @@ function DecaneKit({ config, children }) {
|
|
|
5960
6012
|
},
|
|
5961
6013
|
[]
|
|
5962
6014
|
);
|
|
6015
|
+
const socialGetAccessToken = useCallback3(() => {
|
|
6016
|
+
return socialRef.current?.getAccessToken() ?? null;
|
|
6017
|
+
}, []);
|
|
5963
6018
|
const socialGetBalances = useCallback3(async () => {
|
|
5964
6019
|
const sdk = socialRef.current;
|
|
5965
6020
|
if (!sdk) throw new Error("Social wallet not connected");
|
|
@@ -6024,6 +6079,8 @@ function DecaneKit({ config, children }) {
|
|
|
6024
6079
|
socialGetBalances,
|
|
6025
6080
|
socialGetEthereumProvider,
|
|
6026
6081
|
socialSignAuthorization,
|
|
6082
|
+
socialSignTronTransaction,
|
|
6083
|
+
socialGetAccessToken,
|
|
6027
6084
|
socialSignSolanaTransaction,
|
|
6028
6085
|
socialSignTypedData,
|
|
6029
6086
|
socialRotateShares,
|
|
@@ -6243,11 +6300,13 @@ function useSocialWallet() {
|
|
|
6243
6300
|
socialSignMessage,
|
|
6244
6301
|
socialSendTransaction,
|
|
6245
6302
|
socialSignSolanaTransaction,
|
|
6303
|
+
socialSignTronTransaction,
|
|
6246
6304
|
socialSignTypedData,
|
|
6247
6305
|
socialGetBalance,
|
|
6248
6306
|
socialGetBalances,
|
|
6249
6307
|
socialGetEthereumProvider,
|
|
6250
6308
|
socialSignAuthorization,
|
|
6309
|
+
socialGetAccessToken,
|
|
6251
6310
|
socialRotateShares,
|
|
6252
6311
|
socialExportPortableBackup,
|
|
6253
6312
|
socialHasRecoveryShare,
|
|
@@ -6284,6 +6343,10 @@ function useSocialWallet() {
|
|
|
6284
6343
|
(tx) => run(() => socialSignSolanaTransaction(tx)),
|
|
6285
6344
|
[socialSignSolanaTransaction]
|
|
6286
6345
|
);
|
|
6346
|
+
const signTronTransaction = useCallback4(
|
|
6347
|
+
(rawDataHex) => run(() => socialSignTronTransaction(rawDataHex)),
|
|
6348
|
+
[socialSignTronTransaction]
|
|
6349
|
+
);
|
|
6287
6350
|
const signTypedData = useCallback4(
|
|
6288
6351
|
(req) => run(() => socialSignTypedData(req)),
|
|
6289
6352
|
[socialSignTypedData]
|
|
@@ -6365,6 +6428,7 @@ function useSocialWallet() {
|
|
|
6365
6428
|
signMessage,
|
|
6366
6429
|
sendTransaction,
|
|
6367
6430
|
signSolanaTransaction: signSolanaTransaction2,
|
|
6431
|
+
signTronTransaction,
|
|
6368
6432
|
signTypedData,
|
|
6369
6433
|
// Balances (native token; read-only, works while locked)
|
|
6370
6434
|
getBalance,
|
|
@@ -6373,6 +6437,9 @@ function useSocialWallet() {
|
|
|
6373
6437
|
signAuthorization,
|
|
6374
6438
|
// An EIP-1193 provider for viem/wagmi/ethers (memoized).
|
|
6375
6439
|
getEthereumProvider: socialGetEthereumProvider,
|
|
6440
|
+
// The Decane JWT — authenticate the user to your own backend (bundler proxy,
|
|
6441
|
+
// etc.); verify server-side against backend.decane.app/.well-known/jwks.json.
|
|
6442
|
+
getAccessToken: socialGetAccessToken,
|
|
6376
6443
|
// Recovery (2-of-3 Shamir share set)
|
|
6377
6444
|
rotateShares,
|
|
6378
6445
|
exportPortableBackup,
|