decane-connect-kit 2.3.0 → 2.3.1

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.d.cts CHANGED
@@ -316,17 +316,16 @@ interface EthereumProviderOptions {
316
316
  * `signAuthorization` (EIP-7702) is wired only when the client exposes it — that
317
317
  * requires the TEE signer to support the authorization signing path.
318
318
  */
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;
319
+ declare function createEthereumProvider(client: DecaneConnect, opts?: EthereumProviderOptions): Eip1193Provider;
320
+
321
+ interface SignedAuthorization {
322
+ chainId: number;
323
+ address: string;
324
+ nonce: number;
325
+ yParity: number;
326
+ r: string;
327
+ s: string;
328
+ }
330
329
 
331
330
  type Chain = `evm:${number}` | `solana:${'mainnet' | 'devnet'}`;
332
331
  interface DecaneConnectConfig {
@@ -490,20 +489,26 @@ interface DecaneConnect {
490
489
  chainId?: number;
491
490
  }): Eip1193Provider;
492
491
  /**
493
- * Sign an EIP-7702 authorization, delegating this EOA to `address` on
494
- * `chainId`. Enables account-abstraction / sponsored-gas flows: pair the
495
- * returned {yParity, r, s} into a type-4 transaction's authorizationList.
496
- * Requires a TEE signer that supports the 7702 path.
492
+ * Sign an EIP-7702 authorization, delegating this EOA to a smart-account
493
+ * implementation contract on `chainId`. Enables account-abstraction /
494
+ * sponsored-gas flows. Returns the full viem `SignedAuthorization` tuple, so
495
+ * it drops straight into a userOperation's `authorization` field or a type-4
496
+ * transaction's authorizationList. `address` and `contractAddress` are
497
+ * interchangeable (the latter matches Privy's/older viem's param name).
497
498
  */
498
499
  signAuthorization(req: {
499
500
  chainId: number;
500
- address: string;
501
+ address?: string;
502
+ contractAddress?: string;
501
503
  nonce: number;
502
- }): Promise<{
503
- yParity: number;
504
- r: string;
505
- s: string;
506
- }>;
504
+ }): Promise<SignedAuthorization>;
505
+ /**
506
+ * The current session's access token (the Decane JWT). Use it to authenticate
507
+ * the user to your own backend (e.g. a sponsored-bundler proxy); verify it
508
+ * server-side against backend.decane.app/.well-known/jwks.json. Null with no
509
+ * live session.
510
+ */
511
+ getAccessToken(): string | null;
507
512
  signSolanaTransaction(tx: Uint8Array): Promise<Uint8Array>;
508
513
  disconnect(): Promise<void>;
509
514
  getAddresses(): {
@@ -926,16 +931,14 @@ declare function useSocialWallet(): {
926
931
  }[]>;
927
932
  signAuthorization: (req: {
928
933
  chainId: number;
929
- address: string;
934
+ address?: string;
935
+ contractAddress?: string;
930
936
  nonce: number;
931
- }) => Promise<{
932
- yParity: number;
933
- r: string;
934
- s: string;
935
- }>;
937
+ }) => Promise<SignedAuthorization>;
936
938
  getEthereumProvider: (opts?: {
937
939
  chainId?: number;
938
940
  }) => Eip1193Provider;
941
+ getAccessToken: () => string | null;
939
942
  rotateShares: (opts: {
940
943
  password: string;
941
944
  passwordHint?: string;
@@ -1032,4 +1035,4 @@ declare function useSignTypedData(): {
1032
1035
  reset: () => void;
1033
1036
  };
1034
1037
 
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 };
1038
+ 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
@@ -316,17 +316,16 @@ interface EthereumProviderOptions {
316
316
  * `signAuthorization` (EIP-7702) is wired only when the client exposes it — that
317
317
  * requires the TEE signer to support the authorization signing path.
318
318
  */
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;
319
+ declare function createEthereumProvider(client: DecaneConnect, opts?: EthereumProviderOptions): Eip1193Provider;
320
+
321
+ interface SignedAuthorization {
322
+ chainId: number;
323
+ address: string;
324
+ nonce: number;
325
+ yParity: number;
326
+ r: string;
327
+ s: string;
328
+ }
330
329
 
331
330
  type Chain = `evm:${number}` | `solana:${'mainnet' | 'devnet'}`;
332
331
  interface DecaneConnectConfig {
@@ -490,20 +489,26 @@ interface DecaneConnect {
490
489
  chainId?: number;
491
490
  }): Eip1193Provider;
492
491
  /**
493
- * Sign an EIP-7702 authorization, delegating this EOA to `address` on
494
- * `chainId`. Enables account-abstraction / sponsored-gas flows: pair the
495
- * returned {yParity, r, s} into a type-4 transaction's authorizationList.
496
- * Requires a TEE signer that supports the 7702 path.
492
+ * Sign an EIP-7702 authorization, delegating this EOA to a smart-account
493
+ * implementation contract on `chainId`. Enables account-abstraction /
494
+ * sponsored-gas flows. Returns the full viem `SignedAuthorization` tuple, so
495
+ * it drops straight into a userOperation's `authorization` field or a type-4
496
+ * transaction's authorizationList. `address` and `contractAddress` are
497
+ * interchangeable (the latter matches Privy's/older viem's param name).
497
498
  */
498
499
  signAuthorization(req: {
499
500
  chainId: number;
500
- address: string;
501
+ address?: string;
502
+ contractAddress?: string;
501
503
  nonce: number;
502
- }): Promise<{
503
- yParity: number;
504
- r: string;
505
- s: string;
506
- }>;
504
+ }): Promise<SignedAuthorization>;
505
+ /**
506
+ * The current session's access token (the Decane JWT). Use it to authenticate
507
+ * the user to your own backend (e.g. a sponsored-bundler proxy); verify it
508
+ * server-side against backend.decane.app/.well-known/jwks.json. Null with no
509
+ * live session.
510
+ */
511
+ getAccessToken(): string | null;
507
512
  signSolanaTransaction(tx: Uint8Array): Promise<Uint8Array>;
508
513
  disconnect(): Promise<void>;
509
514
  getAddresses(): {
@@ -926,16 +931,14 @@ declare function useSocialWallet(): {
926
931
  }[]>;
927
932
  signAuthorization: (req: {
928
933
  chainId: number;
929
- address: string;
934
+ address?: string;
935
+ contractAddress?: string;
930
936
  nonce: number;
931
- }) => Promise<{
932
- yParity: number;
933
- r: string;
934
- s: string;
935
- }>;
937
+ }) => Promise<SignedAuthorization>;
936
938
  getEthereumProvider: (opts?: {
937
939
  chainId?: number;
938
940
  }) => Eip1193Provider;
941
+ getAccessToken: () => string | null;
939
942
  rotateShares: (opts: {
940
943
  password: string;
941
944
  passwordHint?: string;
@@ -1032,4 +1035,4 @@ declare function useSignTypedData(): {
1032
1035
  reset: () => void;
1033
1036
  };
1034
1037
 
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 };
1038
+ 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
@@ -2714,7 +2714,7 @@ async function signEvmAuthorization(tee, chainId, address, nonce, jwt) {
2714
2714
  const r = "0x" + hex.slice(0, 64);
2715
2715
  const s = "0x" + hex.slice(64, 128);
2716
2716
  const v = parseInt(hex.slice(128, 130), 16);
2717
- return { yParity: v >= 27 ? v - 27 : v, r, s };
2717
+ return { chainId, address, nonce, yParity: v >= 27 ? v - 27 : v, r, s };
2718
2718
  }
2719
2719
  async function signEvmTypedData(tee, chain, typedData, jwt) {
2720
2720
  const payload = JSON.stringify(
@@ -2875,9 +2875,6 @@ function createEthereumProvider(client, opts = {}) {
2875
2875
  }
2876
2876
  case "eth_signAuthorization":
2877
2877
  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
2878
  const p = params[0];
2882
2879
  const cid = p.chainId != null ? Number(asBigInt(p.chainId)) : chainId;
2883
2880
  const address = p.address ?? p.contractAddress;
@@ -3731,7 +3728,16 @@ async function createDecaneConnect(config) {
3731
3728
  },
3732
3729
  async signAuthorization(req) {
3733
3730
  const tee = session.requireActive();
3734
- return signEvmAuthorization(tee, req.chainId, req.address, req.nonce, auth?.jwt);
3731
+ const delegate = req.address ?? req.contractAddress;
3732
+ if (!delegate) throw new CallSequenceError("signAuthorization requires `address` (the delegate contract).");
3733
+ return signEvmAuthorization(tee, req.chainId, delegate, req.nonce, auth?.jwt);
3734
+ },
3735
+ // The current session's access token (the Decane JWT), for authenticating
3736
+ // the user to your own backend — e.g. a sponsored-bundler proxy. Verify it
3737
+ // server-side against https://backend.decane.app/.well-known/jwks.json.
3738
+ // Null when there is no live session.
3739
+ getAccessToken() {
3740
+ return auth?.jwt ?? null;
3735
3741
  },
3736
3742
  getEthereumProvider(opts) {
3737
3743
  if (!ethProvider) {
@@ -5960,6 +5966,9 @@ function DecaneKit({ config, children }) {
5960
5966
  },
5961
5967
  []
5962
5968
  );
5969
+ const socialGetAccessToken = useCallback3(() => {
5970
+ return socialRef.current?.getAccessToken() ?? null;
5971
+ }, []);
5963
5972
  const socialGetBalances = useCallback3(async () => {
5964
5973
  const sdk = socialRef.current;
5965
5974
  if (!sdk) throw new Error("Social wallet not connected");
@@ -6024,6 +6033,7 @@ function DecaneKit({ config, children }) {
6024
6033
  socialGetBalances,
6025
6034
  socialGetEthereumProvider,
6026
6035
  socialSignAuthorization,
6036
+ socialGetAccessToken,
6027
6037
  socialSignSolanaTransaction,
6028
6038
  socialSignTypedData,
6029
6039
  socialRotateShares,
@@ -6248,6 +6258,7 @@ function useSocialWallet() {
6248
6258
  socialGetBalances,
6249
6259
  socialGetEthereumProvider,
6250
6260
  socialSignAuthorization,
6261
+ socialGetAccessToken,
6251
6262
  socialRotateShares,
6252
6263
  socialExportPortableBackup,
6253
6264
  socialHasRecoveryShare,
@@ -6373,6 +6384,9 @@ function useSocialWallet() {
6373
6384
  signAuthorization,
6374
6385
  // An EIP-1193 provider for viem/wagmi/ethers (memoized).
6375
6386
  getEthereumProvider: socialGetEthereumProvider,
6387
+ // The Decane JWT — authenticate the user to your own backend (bundler proxy,
6388
+ // etc.); verify server-side against backend.decane.app/.well-known/jwks.json.
6389
+ getAccessToken: socialGetAccessToken,
6376
6390
  // Recovery (2-of-3 Shamir share set)
6377
6391
  rotateShares,
6378
6392
  exportPortableBackup,