@naculus/connect-appkit-core 0.13.0 → 0.15.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.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { Namespace, UniversalWalletSession, WalletCapabilities, TokenConfig, WalletError, WalletErrorCode, SimulationResult, NameResolverConfig, NameResolver, NotificationSettings, InAppChannel, NotificationItem, SessionKeyManagerConfig, SessionKeyManager, Hex, UserOperationReceipt, Address, SmartAccountConfig, AtomicityRequirement, ExecutionPlan, SessionKeyInfo, SessionKeyTransaction, delegationTypedData, SessionKeyScope, ScopeCheckResult, SpendRefusal, Authorization, ListedAuthorization, SpendRequest, SettlementVerification, SolanaSessionKeyInfo, SolanaSessionKeyScope, SolanaSessionKeyManager, SolanaPaymentRpc } from '@naculus/connect-core';
1
+ import { Namespace, UniversalWalletSession, WalletCapabilities, TokenConfig, WalletError, WalletErrorCode, SimulationResult, NameResolverConfig, NameResolver, NotificationSettings, InAppChannel, NotificationItem, SessionKeyManagerConfig, SessionKeyManager, SessionKeyRail, SessionKeyScope, Hex, UserOperationReceipt, Address, SmartAccountConfig, AtomicityRequirement, ExecutionPlan, SessionKeyInfo, SessionKeyTransaction, TransactionRequest, delegationTypedData, ScopeCheckResult, SpendRefusal, Authorization, ListedAuthorization, SpendRequest, SettlementVerification, SolanaSessionKeyInfo, SolanaSessionKeyScope, SolanaSessionKeyManager, SolanaPaymentRpc } from '@naculus/connect-core';
2
2
  import { X402TypedDataSigner } from '@naculus/payments-x402';
3
3
  export { X402TypedDataSigner } from '@naculus/payments-x402';
4
4
 
@@ -632,6 +632,21 @@ declare function getSharedSessionKeyManager(config?: SessionKeyManagerConfig): S
632
632
  /** Drop the shared instance. For tests and for a full sign-out that must forget keys. */
633
633
  declare function resetSharedSessionKeyManager(): void;
634
634
 
635
+ type Eip3009SessionKeyRail = Extract<SessionKeyRail, "x402-exact" | "mpp-charge">;
636
+ type SessionKeyRailGrantCheck = {
637
+ status: "ok";
638
+ rail: Eip3009SessionKeyRail;
639
+ } | {
640
+ status: "needs-regrant";
641
+ missingRail: Eip3009SessionKeyRail;
642
+ };
643
+ /**
644
+ * Checks whether a stored session-key scope can sign EIP-3009 for `rail`.
645
+ * Legacy, empty, unknown, and malformed rail lists fail closed and require a
646
+ * new wallet-approved grant.
647
+ */
648
+ declare function checkSessionKeyRailGrant(scope: SessionKeyScope | null | undefined, rail: Eip3009SessionKeyRail): SessionKeyRailGrantCheck;
649
+
635
650
  /**
636
651
  * Validation of an ERC-4337 `eth_getUserOperationReceipt` result, shared by
637
652
  * the React hook and the Vue composable. A bundler is an untrusted party:
@@ -710,8 +725,17 @@ interface PolicyExecutionCheck {
710
725
  executorAddress?: `0x${string}`;
711
726
  reason: string;
712
727
  }
728
+ /**
729
+ * What an execution adapter prepared for one policy execution.
730
+ *
731
+ * Breaking change: `request` is new and required. Adapters must return the
732
+ * exact transaction they will broadcast as a `TransactionRequest`; `digest`
733
+ * must equal `transactionSigningHash(request)`. Signing refuses any mismatch.
734
+ */
713
735
  interface PreparedPolicyExecution {
714
736
  digest: Hex;
737
+ /** The exact transaction to sign, as connect-core's transaction request. */
738
+ request: TransactionRequest;
715
739
  transaction: SessionKeyTransaction;
716
740
  payload: unknown;
717
741
  }
@@ -798,7 +822,7 @@ interface DelegationPolicyFlow {
798
822
  createPolicy: (scope: Partial<SessionKeyScope>) => Promise<SessionKeyInfo>;
799
823
  revokePolicy: (policyId: string) => Promise<void>;
800
824
  previewPolicyExecution: (policyId: string, tx: SessionKeyTransaction, callCount?: number, atomicity?: AtomicityRequirement) => Promise<DelegationPolicyPreview>;
801
- signPolicyDigest: (policyId: string, digest: `0x${string}`, tx: SessionKeyTransaction) => Promise<`0x${string}`>;
825
+ signPolicyDigest: (policyId: string, prepared: PreparedPolicyExecution) => Promise<`0x${string}`>;
802
826
  executePolicy: (policyId: string, tx: SessionKeyTransaction) => Promise<PolicyExecutionSubmission>;
803
827
  }
804
828
  declare function createDelegationPolicyFlow(deps: DelegationPolicyDeps): DelegationPolicyFlow;
@@ -810,7 +834,7 @@ declare function createDelegationPolicyFlow(deps: DelegationPolicyDeps): Delegat
810
834
  * The session key sends `DelegationManager.redeemDelegations` from its own
811
835
  * address and pays the gas; the chain enforces the delegation's caveats. The
812
836
  * adapter builds that transaction and broadcasts it; the delegation-policy
813
- * flow signs it with connect-core's `signDelegationRedemption`, which
837
+ * flow signs it with connect-core's `signTransactionDelegationRedemption`, which
814
838
  * re-encodes the redemption from the stored delegation and refuses anything
815
839
  * else.
816
840
  *
@@ -1215,4 +1239,5 @@ declare function siwxResultToSession<M extends SiwxMessageLike>(result: SiwxResu
1215
1239
  refreshedAt: null;
1216
1240
  };
1217
1241
 
1218
- export { type AddressValidationLevel, type AssetId, type AtomicSupport, type AuthorizationAmountView, type AuthorizationAssetMetadata, type AuthorizationDescription, type AuthorizationExpiryView, type AuthorizationGrantView, type AuthorizationRecipientView, type ChainCapabilities, type ChainInfo, type CompareCosts, type CompareCostsInput, type ConnectionStatus, type CostComparison, type CostComparisonOperation, type CostComparisonOptions, DEFAULT_NOTIFICATION_SETTINGS, DEFAULT_VERIFY_RETRY, type DecimalsCache, type DelegationFrameworkAdapterOptions, type DelegationPolicyDeps, type DelegationPolicyFlow, type DelegationPolicyPreview, type DelegationTypedData, type DescribeAuthorizationOptions, type DestinationIssue, type DestinationValidation, type ExecutableQuote, type ExecuteRoute, type ExecuteRouteError, type ExecuteRouteOptions, type ExecuteRouteResult, type GetRouteQuotes, InvalidUserOperationReceiptError, type MppSessionChannel, type MppSessionFetch, type MppSessionFetchResult, type MppSessionForceCloseResult, type MppSessionMeter, type MppSessionReceipt, type MppSessionRequest, type MppSessionRequestInit, NOTIFICATION_SETTINGS_KEY, type NotificationSettingsStorage, type NotificationSettingsUpdate, type PaymentFetch, type PaymentFetchResult, type PaymentRecord, type PaymentVerification, type PaymentVerificationStatus, type PolicyExecutionAdapter, type PolicyExecutionCheck, type PolicyExecutionPreview, type PolicyExecutionRoute, type PolicyExecutionSubmission, type PolicySignatureVerifier, type PreparedPolicyExecution, type RedemptionCodec, type RedemptionRpc, type RedemptionTransaction, type RetryOptions, type RouteQuote, type RouteQuoteInput, type RouteQuoteOptions, type SimulationCallClient, type SimulationTransaction, type SiwxLocation, type SiwxMessageLike, type SiwxResultLike, type SmartAccountOptionsLike, type SmartAccountType, type SolanaIdentity, type SolanaOwnerSigner, type SolanaPayer, type SolanaRoles, type SolanaRolesAbsence, type SolanaRolesSource, type SolanaRolesState, type SolanaSessionKeyFlow, type SolanaSessionKeyFlowDeps, type SolanaSigner, type SolanaWalletFeatures, type SpendExplanation, type TokenIdentity, type TransactionSimulationContext, type VerifyRetryOptions, type ViemChainShape, type WalletChain, type Web3Action, type Web3State, type X402Eip1193Provider, type X402ProviderSources, type X402SignerResolution, type X402SignerUnavailableReason, type X402WalletResolution, __resetResolverForTests, addInAppNotification, applySettlementVerification, assertHexSignature, atomicSupportFor, bareEvmAddress, buildDelegationPolicyMessage, buildSmartAccountConfig, chainNamespace, chainNumber, chainsForNamespace, channelsUpdate, clearOneInAppNotification, compareCostsKey, createDecimalsCache, createDelegationFrameworkAdapter, createDelegationPolicyFlow, createNotification, createNotificationSettingsStorage, createSolanaSessionKeyFlow, createX402WalletSigner, decodeRevertReason, defaultSiwxDomain, defaultSiwxUri, describeAuthorization, describeChain, describePayment, eip155ChainIdToNumber, encodeErc20Approve, encodeErc20Transfer, encodeErc20TransferFrom, errorMessage, explainSpend, fetchUserOperationReceipt, findX402Provider, formatAuthorizationAmount, getResolver, getSharedSessionKeyManager, initialWeb3State, isBurnDestination, isEvmChainId, isPositiveIntegerAmount, isQuotableInput, isSiwxExpired, isSiwxNotBeforeValid, isVerifiablePolicy, loadNotificationSettings, mutedChainSettings, normalizeCapabilities, normalizeEip155ChainId, parseUserOperationReceipt, readCurrentMppSessionChannel, readDecimals, readMppRecoveryChannelId, readMppSessionChannel, readMppSessionReceipt, readSolanaRoles, replayNotificationSettings, resetSharedSessionKeyManager, resolveChain, resolveContextSimulationEndpoint, resolveEvmChainId, resolveRevertReason, resolveSimulationEndpoint, resolveUserOpChain, resolveX402Wallet, sameExecutionIntent, saveNotificationSettings, selectChainCapabilities, sessionKeyConfigFingerprint, simulateTransactionPreview, siwxResultToSession, toChainSwitchError, toEip155Accounts, toExecuteRouteError, toViemChain, tokenChainMismatch, tokenKey, updateNotificationSettings, validateDestination, validateRouteRecipient, web3Reducer, withRetry, withTimeout, writeDecimals };
1242
+ export { DEFAULT_NOTIFICATION_SETTINGS, DEFAULT_VERIFY_RETRY, InvalidUserOperationReceiptError, NOTIFICATION_SETTINGS_KEY, __resetResolverForTests, addInAppNotification, applySettlementVerification, assertHexSignature, atomicSupportFor, bareEvmAddress, buildDelegationPolicyMessage, buildSmartAccountConfig, chainNamespace, chainNumber, chainsForNamespace, channelsUpdate, checkSessionKeyRailGrant, clearOneInAppNotification, compareCostsKey, createDecimalsCache, createDelegationFrameworkAdapter, createDelegationPolicyFlow, createNotification, createNotificationSettingsStorage, createSolanaSessionKeyFlow, createX402WalletSigner, decodeRevertReason, defaultSiwxDomain, defaultSiwxUri, describeAuthorization, describeChain, describePayment, eip155ChainIdToNumber, encodeErc20Approve, encodeErc20Transfer, encodeErc20TransferFrom, errorMessage, explainSpend, fetchUserOperationReceipt, findX402Provider, formatAuthorizationAmount, getResolver, getSharedSessionKeyManager, initialWeb3State, isBurnDestination, isEvmChainId, isPositiveIntegerAmount, isQuotableInput, isSiwxExpired, isSiwxNotBeforeValid, isVerifiablePolicy, loadNotificationSettings, mutedChainSettings, normalizeCapabilities, normalizeEip155ChainId, parseUserOperationReceipt, readCurrentMppSessionChannel, readDecimals, readMppRecoveryChannelId, readMppSessionChannel, readMppSessionReceipt, readSolanaRoles, replayNotificationSettings, resetSharedSessionKeyManager, resolveChain, resolveContextSimulationEndpoint, resolveEvmChainId, resolveRevertReason, resolveSimulationEndpoint, resolveUserOpChain, resolveX402Wallet, sameExecutionIntent, saveNotificationSettings, selectChainCapabilities, sessionKeyConfigFingerprint, simulateTransactionPreview, siwxResultToSession, toChainSwitchError, toEip155Accounts, toExecuteRouteError, toViemChain, tokenChainMismatch, tokenKey, updateNotificationSettings, validateDestination, validateRouteRecipient, web3Reducer, withRetry, withTimeout, writeDecimals };
1243
+ export type { AddressValidationLevel, AssetId, AtomicSupport, AuthorizationAmountView, AuthorizationAssetMetadata, AuthorizationDescription, AuthorizationExpiryView, AuthorizationGrantView, AuthorizationRecipientView, ChainCapabilities, ChainInfo, CompareCosts, CompareCostsInput, ConnectionStatus, CostComparison, CostComparisonOperation, CostComparisonOptions, DecimalsCache, DelegationFrameworkAdapterOptions, DelegationPolicyDeps, DelegationPolicyFlow, DelegationPolicyPreview, DelegationTypedData, DescribeAuthorizationOptions, DestinationIssue, DestinationValidation, Eip3009SessionKeyRail, ExecutableQuote, ExecuteRoute, ExecuteRouteError, ExecuteRouteOptions, ExecuteRouteResult, GetRouteQuotes, MppSessionChannel, MppSessionFetch, MppSessionFetchResult, MppSessionForceCloseResult, MppSessionMeter, MppSessionReceipt, MppSessionRequest, MppSessionRequestInit, NotificationSettingsStorage, NotificationSettingsUpdate, PaymentFetch, PaymentFetchResult, PaymentRecord, PaymentVerification, PaymentVerificationStatus, PolicyExecutionAdapter, PolicyExecutionCheck, PolicyExecutionPreview, PolicyExecutionRoute, PolicyExecutionSubmission, PolicySignatureVerifier, PreparedPolicyExecution, RedemptionCodec, RedemptionRpc, RedemptionTransaction, RetryOptions, RouteQuote, RouteQuoteInput, RouteQuoteOptions, SessionKeyRailGrantCheck, SimulationCallClient, SimulationTransaction, SiwxLocation, SiwxMessageLike, SiwxResultLike, SmartAccountOptionsLike, SmartAccountType, SolanaIdentity, SolanaOwnerSigner, SolanaPayer, SolanaRoles, SolanaRolesAbsence, SolanaRolesSource, SolanaRolesState, SolanaSessionKeyFlow, SolanaSessionKeyFlowDeps, SolanaSigner, SolanaWalletFeatures, SpendExplanation, TokenIdentity, TransactionSimulationContext, VerifyRetryOptions, ViemChainShape, WalletChain, Web3Action, Web3State, X402Eip1193Provider, X402ProviderSources, X402SignerResolution, X402SignerUnavailableReason, X402WalletResolution };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Namespace, UniversalWalletSession, WalletCapabilities, TokenConfig, WalletError, WalletErrorCode, SimulationResult, NameResolverConfig, NameResolver, NotificationSettings, InAppChannel, NotificationItem, SessionKeyManagerConfig, SessionKeyManager, Hex, UserOperationReceipt, Address, SmartAccountConfig, AtomicityRequirement, ExecutionPlan, SessionKeyInfo, SessionKeyTransaction, delegationTypedData, SessionKeyScope, ScopeCheckResult, SpendRefusal, Authorization, ListedAuthorization, SpendRequest, SettlementVerification, SolanaSessionKeyInfo, SolanaSessionKeyScope, SolanaSessionKeyManager, SolanaPaymentRpc } from '@naculus/connect-core';
1
+ import { Namespace, UniversalWalletSession, WalletCapabilities, TokenConfig, WalletError, WalletErrorCode, SimulationResult, NameResolverConfig, NameResolver, NotificationSettings, InAppChannel, NotificationItem, SessionKeyManagerConfig, SessionKeyManager, SessionKeyRail, SessionKeyScope, Hex, UserOperationReceipt, Address, SmartAccountConfig, AtomicityRequirement, ExecutionPlan, SessionKeyInfo, SessionKeyTransaction, TransactionRequest, delegationTypedData, ScopeCheckResult, SpendRefusal, Authorization, ListedAuthorization, SpendRequest, SettlementVerification, SolanaSessionKeyInfo, SolanaSessionKeyScope, SolanaSessionKeyManager, SolanaPaymentRpc } from '@naculus/connect-core';
2
2
  import { X402TypedDataSigner } from '@naculus/payments-x402';
3
3
  export { X402TypedDataSigner } from '@naculus/payments-x402';
4
4
 
@@ -632,6 +632,21 @@ declare function getSharedSessionKeyManager(config?: SessionKeyManagerConfig): S
632
632
  /** Drop the shared instance. For tests and for a full sign-out that must forget keys. */
633
633
  declare function resetSharedSessionKeyManager(): void;
634
634
 
635
+ type Eip3009SessionKeyRail = Extract<SessionKeyRail, "x402-exact" | "mpp-charge">;
636
+ type SessionKeyRailGrantCheck = {
637
+ status: "ok";
638
+ rail: Eip3009SessionKeyRail;
639
+ } | {
640
+ status: "needs-regrant";
641
+ missingRail: Eip3009SessionKeyRail;
642
+ };
643
+ /**
644
+ * Checks whether a stored session-key scope can sign EIP-3009 for `rail`.
645
+ * Legacy, empty, unknown, and malformed rail lists fail closed and require a
646
+ * new wallet-approved grant.
647
+ */
648
+ declare function checkSessionKeyRailGrant(scope: SessionKeyScope | null | undefined, rail: Eip3009SessionKeyRail): SessionKeyRailGrantCheck;
649
+
635
650
  /**
636
651
  * Validation of an ERC-4337 `eth_getUserOperationReceipt` result, shared by
637
652
  * the React hook and the Vue composable. A bundler is an untrusted party:
@@ -710,8 +725,17 @@ interface PolicyExecutionCheck {
710
725
  executorAddress?: `0x${string}`;
711
726
  reason: string;
712
727
  }
728
+ /**
729
+ * What an execution adapter prepared for one policy execution.
730
+ *
731
+ * Breaking change: `request` is new and required. Adapters must return the
732
+ * exact transaction they will broadcast as a `TransactionRequest`; `digest`
733
+ * must equal `transactionSigningHash(request)`. Signing refuses any mismatch.
734
+ */
713
735
  interface PreparedPolicyExecution {
714
736
  digest: Hex;
737
+ /** The exact transaction to sign, as connect-core's transaction request. */
738
+ request: TransactionRequest;
715
739
  transaction: SessionKeyTransaction;
716
740
  payload: unknown;
717
741
  }
@@ -798,7 +822,7 @@ interface DelegationPolicyFlow {
798
822
  createPolicy: (scope: Partial<SessionKeyScope>) => Promise<SessionKeyInfo>;
799
823
  revokePolicy: (policyId: string) => Promise<void>;
800
824
  previewPolicyExecution: (policyId: string, tx: SessionKeyTransaction, callCount?: number, atomicity?: AtomicityRequirement) => Promise<DelegationPolicyPreview>;
801
- signPolicyDigest: (policyId: string, digest: `0x${string}`, tx: SessionKeyTransaction) => Promise<`0x${string}`>;
825
+ signPolicyDigest: (policyId: string, prepared: PreparedPolicyExecution) => Promise<`0x${string}`>;
802
826
  executePolicy: (policyId: string, tx: SessionKeyTransaction) => Promise<PolicyExecutionSubmission>;
803
827
  }
804
828
  declare function createDelegationPolicyFlow(deps: DelegationPolicyDeps): DelegationPolicyFlow;
@@ -810,7 +834,7 @@ declare function createDelegationPolicyFlow(deps: DelegationPolicyDeps): Delegat
810
834
  * The session key sends `DelegationManager.redeemDelegations` from its own
811
835
  * address and pays the gas; the chain enforces the delegation's caveats. The
812
836
  * adapter builds that transaction and broadcasts it; the delegation-policy
813
- * flow signs it with connect-core's `signDelegationRedemption`, which
837
+ * flow signs it with connect-core's `signTransactionDelegationRedemption`, which
814
838
  * re-encodes the redemption from the stored delegation and refuses anything
815
839
  * else.
816
840
  *
@@ -1215,4 +1239,5 @@ declare function siwxResultToSession<M extends SiwxMessageLike>(result: SiwxResu
1215
1239
  refreshedAt: null;
1216
1240
  };
1217
1241
 
1218
- export { type AddressValidationLevel, type AssetId, type AtomicSupport, type AuthorizationAmountView, type AuthorizationAssetMetadata, type AuthorizationDescription, type AuthorizationExpiryView, type AuthorizationGrantView, type AuthorizationRecipientView, type ChainCapabilities, type ChainInfo, type CompareCosts, type CompareCostsInput, type ConnectionStatus, type CostComparison, type CostComparisonOperation, type CostComparisonOptions, DEFAULT_NOTIFICATION_SETTINGS, DEFAULT_VERIFY_RETRY, type DecimalsCache, type DelegationFrameworkAdapterOptions, type DelegationPolicyDeps, type DelegationPolicyFlow, type DelegationPolicyPreview, type DelegationTypedData, type DescribeAuthorizationOptions, type DestinationIssue, type DestinationValidation, type ExecutableQuote, type ExecuteRoute, type ExecuteRouteError, type ExecuteRouteOptions, type ExecuteRouteResult, type GetRouteQuotes, InvalidUserOperationReceiptError, type MppSessionChannel, type MppSessionFetch, type MppSessionFetchResult, type MppSessionForceCloseResult, type MppSessionMeter, type MppSessionReceipt, type MppSessionRequest, type MppSessionRequestInit, NOTIFICATION_SETTINGS_KEY, type NotificationSettingsStorage, type NotificationSettingsUpdate, type PaymentFetch, type PaymentFetchResult, type PaymentRecord, type PaymentVerification, type PaymentVerificationStatus, type PolicyExecutionAdapter, type PolicyExecutionCheck, type PolicyExecutionPreview, type PolicyExecutionRoute, type PolicyExecutionSubmission, type PolicySignatureVerifier, type PreparedPolicyExecution, type RedemptionCodec, type RedemptionRpc, type RedemptionTransaction, type RetryOptions, type RouteQuote, type RouteQuoteInput, type RouteQuoteOptions, type SimulationCallClient, type SimulationTransaction, type SiwxLocation, type SiwxMessageLike, type SiwxResultLike, type SmartAccountOptionsLike, type SmartAccountType, type SolanaIdentity, type SolanaOwnerSigner, type SolanaPayer, type SolanaRoles, type SolanaRolesAbsence, type SolanaRolesSource, type SolanaRolesState, type SolanaSessionKeyFlow, type SolanaSessionKeyFlowDeps, type SolanaSigner, type SolanaWalletFeatures, type SpendExplanation, type TokenIdentity, type TransactionSimulationContext, type VerifyRetryOptions, type ViemChainShape, type WalletChain, type Web3Action, type Web3State, type X402Eip1193Provider, type X402ProviderSources, type X402SignerResolution, type X402SignerUnavailableReason, type X402WalletResolution, __resetResolverForTests, addInAppNotification, applySettlementVerification, assertHexSignature, atomicSupportFor, bareEvmAddress, buildDelegationPolicyMessage, buildSmartAccountConfig, chainNamespace, chainNumber, chainsForNamespace, channelsUpdate, clearOneInAppNotification, compareCostsKey, createDecimalsCache, createDelegationFrameworkAdapter, createDelegationPolicyFlow, createNotification, createNotificationSettingsStorage, createSolanaSessionKeyFlow, createX402WalletSigner, decodeRevertReason, defaultSiwxDomain, defaultSiwxUri, describeAuthorization, describeChain, describePayment, eip155ChainIdToNumber, encodeErc20Approve, encodeErc20Transfer, encodeErc20TransferFrom, errorMessage, explainSpend, fetchUserOperationReceipt, findX402Provider, formatAuthorizationAmount, getResolver, getSharedSessionKeyManager, initialWeb3State, isBurnDestination, isEvmChainId, isPositiveIntegerAmount, isQuotableInput, isSiwxExpired, isSiwxNotBeforeValid, isVerifiablePolicy, loadNotificationSettings, mutedChainSettings, normalizeCapabilities, normalizeEip155ChainId, parseUserOperationReceipt, readCurrentMppSessionChannel, readDecimals, readMppRecoveryChannelId, readMppSessionChannel, readMppSessionReceipt, readSolanaRoles, replayNotificationSettings, resetSharedSessionKeyManager, resolveChain, resolveContextSimulationEndpoint, resolveEvmChainId, resolveRevertReason, resolveSimulationEndpoint, resolveUserOpChain, resolveX402Wallet, sameExecutionIntent, saveNotificationSettings, selectChainCapabilities, sessionKeyConfigFingerprint, simulateTransactionPreview, siwxResultToSession, toChainSwitchError, toEip155Accounts, toExecuteRouteError, toViemChain, tokenChainMismatch, tokenKey, updateNotificationSettings, validateDestination, validateRouteRecipient, web3Reducer, withRetry, withTimeout, writeDecimals };
1242
+ export { DEFAULT_NOTIFICATION_SETTINGS, DEFAULT_VERIFY_RETRY, InvalidUserOperationReceiptError, NOTIFICATION_SETTINGS_KEY, __resetResolverForTests, addInAppNotification, applySettlementVerification, assertHexSignature, atomicSupportFor, bareEvmAddress, buildDelegationPolicyMessage, buildSmartAccountConfig, chainNamespace, chainNumber, chainsForNamespace, channelsUpdate, checkSessionKeyRailGrant, clearOneInAppNotification, compareCostsKey, createDecimalsCache, createDelegationFrameworkAdapter, createDelegationPolicyFlow, createNotification, createNotificationSettingsStorage, createSolanaSessionKeyFlow, createX402WalletSigner, decodeRevertReason, defaultSiwxDomain, defaultSiwxUri, describeAuthorization, describeChain, describePayment, eip155ChainIdToNumber, encodeErc20Approve, encodeErc20Transfer, encodeErc20TransferFrom, errorMessage, explainSpend, fetchUserOperationReceipt, findX402Provider, formatAuthorizationAmount, getResolver, getSharedSessionKeyManager, initialWeb3State, isBurnDestination, isEvmChainId, isPositiveIntegerAmount, isQuotableInput, isSiwxExpired, isSiwxNotBeforeValid, isVerifiablePolicy, loadNotificationSettings, mutedChainSettings, normalizeCapabilities, normalizeEip155ChainId, parseUserOperationReceipt, readCurrentMppSessionChannel, readDecimals, readMppRecoveryChannelId, readMppSessionChannel, readMppSessionReceipt, readSolanaRoles, replayNotificationSettings, resetSharedSessionKeyManager, resolveChain, resolveContextSimulationEndpoint, resolveEvmChainId, resolveRevertReason, resolveSimulationEndpoint, resolveUserOpChain, resolveX402Wallet, sameExecutionIntent, saveNotificationSettings, selectChainCapabilities, sessionKeyConfigFingerprint, simulateTransactionPreview, siwxResultToSession, toChainSwitchError, toEip155Accounts, toExecuteRouteError, toViemChain, tokenChainMismatch, tokenKey, updateNotificationSettings, validateDestination, validateRouteRecipient, web3Reducer, withRetry, withTimeout, writeDecimals };
1243
+ export type { AddressValidationLevel, AssetId, AtomicSupport, AuthorizationAmountView, AuthorizationAssetMetadata, AuthorizationDescription, AuthorizationExpiryView, AuthorizationGrantView, AuthorizationRecipientView, ChainCapabilities, ChainInfo, CompareCosts, CompareCostsInput, ConnectionStatus, CostComparison, CostComparisonOperation, CostComparisonOptions, DecimalsCache, DelegationFrameworkAdapterOptions, DelegationPolicyDeps, DelegationPolicyFlow, DelegationPolicyPreview, DelegationTypedData, DescribeAuthorizationOptions, DestinationIssue, DestinationValidation, Eip3009SessionKeyRail, ExecutableQuote, ExecuteRoute, ExecuteRouteError, ExecuteRouteOptions, ExecuteRouteResult, GetRouteQuotes, MppSessionChannel, MppSessionFetch, MppSessionFetchResult, MppSessionForceCloseResult, MppSessionMeter, MppSessionReceipt, MppSessionRequest, MppSessionRequestInit, NotificationSettingsStorage, NotificationSettingsUpdate, PaymentFetch, PaymentFetchResult, PaymentRecord, PaymentVerification, PaymentVerificationStatus, PolicyExecutionAdapter, PolicyExecutionCheck, PolicyExecutionPreview, PolicyExecutionRoute, PolicyExecutionSubmission, PolicySignatureVerifier, PreparedPolicyExecution, RedemptionCodec, RedemptionRpc, RedemptionTransaction, RetryOptions, RouteQuote, RouteQuoteInput, RouteQuoteOptions, SessionKeyRailGrantCheck, SimulationCallClient, SimulationTransaction, SiwxLocation, SiwxMessageLike, SiwxResultLike, SmartAccountOptionsLike, SmartAccountType, SolanaIdentity, SolanaOwnerSigner, SolanaPayer, SolanaRoles, SolanaRolesAbsence, SolanaRolesSource, SolanaRolesState, SolanaSessionKeyFlow, SolanaSessionKeyFlowDeps, SolanaSigner, SolanaWalletFeatures, SpendExplanation, TokenIdentity, TransactionSimulationContext, VerifyRetryOptions, ViemChainShape, WalletChain, Web3Action, Web3State, X402Eip1193Provider, X402ProviderSources, X402SignerResolution, X402SignerUnavailableReason, X402WalletResolution };
package/dist/index.js CHANGED
@@ -670,6 +670,22 @@ function resetSharedSessionKeyManager() {
670
670
  sharedFingerprint = null;
671
671
  }
672
672
 
673
+ // src/session-key-rail.ts
674
+ var knownRails = /* @__PURE__ */ new Set([
675
+ "transfer",
676
+ "x402-exact",
677
+ "mpp-charge"
678
+ ]);
679
+ function checkSessionKeyRailGrant(scope, rail) {
680
+ const rails = scope?.rails;
681
+ if (!Array.isArray(rails) || rails.length === 0 || new Set(rails).size !== rails.length || !Array.from(rails).every(
682
+ (candidate) => typeof candidate === "string" && knownRails.has(candidate)
683
+ ) || !rails.includes(rail)) {
684
+ return { status: "needs-regrant", missingRail: rail };
685
+ }
686
+ return { status: "ok", rail };
687
+ }
688
+
673
689
  // src/user-op-receipt.ts
674
690
  var InvalidUserOperationReceiptError = class extends Error {
675
691
  constructor(message) {
@@ -902,8 +918,21 @@ function createDelegationFrameworkAdapter(options) {
902
918
  execution,
903
919
  unsigned
904
920
  };
921
+ const hex = (value2) => `0x${value2.toString(16)}`;
905
922
  return {
906
923
  digest: codec.signingHash(unsigned),
924
+ // The same redemption as `unsigned`, as a request for the digest check.
925
+ request: {
926
+ type: "eip1559",
927
+ chainId: unsigned.chainId,
928
+ nonce: hex(unsigned.nonce),
929
+ to: unsigned.to,
930
+ value: hex(unsigned.value),
931
+ data: unsigned.data,
932
+ gas: hex(unsigned.gas),
933
+ maxFeePerGas: hex(unsigned.maxFeePerGas),
934
+ maxPriorityFeePerGas: hex(unsigned.maxPriorityFeePerGas)
935
+ },
907
936
  transaction,
908
937
  payload
909
938
  };
@@ -924,6 +953,7 @@ import {
924
953
  delegationTypedData,
925
954
  WalletError as WalletError8
926
955
  } from "@naculus/connect-core";
956
+ import { transactionSigningHash } from "@naculus/connect-core/signing";
927
957
  function delegatesToStatelessDeleGator(delegation) {
928
958
  return delegation.delegated === true && delegation.delegate?.toLowerCase() === DELEGATION_FRAMEWORK2.eip7702StatelessDeleGator.toLowerCase();
929
959
  }
@@ -1199,16 +1229,39 @@ function createDelegationPolicyFlow(deps) {
1199
1229
  reason
1200
1230
  };
1201
1231
  };
1202
- const signVerified = (policyId, digest, tx) => manager.signWithVerifiedOffchainAuthorization(
1203
- policyId,
1204
- (authoritativePolicy) => buildDelegationPolicyMessage(authoritativePolicy, origin),
1205
- deps.verifySignature,
1206
- digest,
1207
- tx
1208
- );
1232
+ const signVerified = (policyId, prepared) => {
1233
+ const { request } = prepared;
1234
+ const computed = `0x${Array.from(
1235
+ transactionSigningHash(request),
1236
+ (byte) => byte.toString(16).padStart(2, "0")
1237
+ ).join("")}`;
1238
+ if (computed !== prepared.digest.toLowerCase()) {
1239
+ throw new WalletError8(
1240
+ "invalid_input",
1241
+ `The prepared digest ${prepared.digest} does not match the signing hash ${computed} of the prepared transaction request.`
1242
+ );
1243
+ }
1244
+ if (!sameExecutionIntent(prepared.transaction, {
1245
+ to: request.to,
1246
+ value: request.value,
1247
+ data: request.data,
1248
+ chainId: request.chainId
1249
+ })) {
1250
+ throw new WalletError8(
1251
+ "invalid_input",
1252
+ "The prepared transaction request differs from the prepared transaction checked by the policy."
1253
+ );
1254
+ }
1255
+ return manager.signTransactionWithVerifiedOffchainAuthorization(
1256
+ policyId,
1257
+ (authoritativePolicy) => buildDelegationPolicyMessage(authoritativePolicy, origin),
1258
+ deps.verifySignature,
1259
+ request
1260
+ );
1261
+ };
1209
1262
  const signRedemption = (policyId, prepared) => {
1210
1263
  const payload = prepared.payload;
1211
- if (!payload?.outerTx || !payload.execution) {
1264
+ if (!payload?.outerTx || !payload.execution || !payload.unsigned) {
1212
1265
  throw new WalletError8(
1213
1266
  "invalid_input",
1214
1267
  "The EIP-7702 adapter did not return a redemption to sign."
@@ -1232,15 +1285,33 @@ function createDelegationPolicyFlow(deps) {
1232
1285
  "The EIP-7702 adapter's execution differs from the requested transaction."
1233
1286
  );
1234
1287
  }
1235
- return manager.signDelegationRedemption(
1288
+ const { unsigned } = payload;
1289
+ const hex = (value) => `0x${value.toString(16)}`;
1290
+ const tx = {
1291
+ type: "eip1559",
1292
+ chainId: unsigned.chainId,
1293
+ nonce: hex(unsigned.nonce),
1294
+ to: unsigned.to,
1295
+ value: hex(unsigned.value),
1296
+ data: unsigned.data,
1297
+ gas: hex(unsigned.gas),
1298
+ maxFeePerGas: hex(unsigned.maxFeePerGas),
1299
+ maxPriorityFeePerGas: hex(unsigned.maxPriorityFeePerGas)
1300
+ };
1301
+ return manager.signTransactionDelegationRedemption(
1236
1302
  policyId,
1237
- prepared.digest,
1238
- payload.outerTx,
1303
+ tx,
1304
+ { gas: payload.outerTx.gas },
1239
1305
  payload.execution
1240
1306
  );
1241
1307
  };
1242
- const signPolicyDigest = async (policyId, digest, tx) => {
1243
- const preview = await previewPolicyExecution(policyId, tx, 1, "any");
1308
+ const signPolicyDigest = async (policyId, prepared) => {
1309
+ const preview = await previewPolicyExecution(
1310
+ policyId,
1311
+ prepared.transaction,
1312
+ 1,
1313
+ "any"
1314
+ );
1244
1315
  if (preview.policy?.scope.mode === "eip7702") {
1245
1316
  throw new WalletError8(
1246
1317
  "method_not_allowed",
@@ -1250,7 +1321,7 @@ function createDelegationPolicyFlow(deps) {
1250
1321
  if (!preview.ready) {
1251
1322
  throw new WalletError8("method_not_allowed", preview.reason);
1252
1323
  }
1253
- return signVerified(policyId, digest, tx);
1324
+ return signVerified(policyId, prepared);
1254
1325
  };
1255
1326
  const executePolicy = async (policyId, tx) => {
1256
1327
  const adapter = deps.adapter;
@@ -1292,7 +1363,7 @@ function createDelegationPolicyFlow(deps) {
1292
1363
  currentCheck.reason || "The on-chain policy authorization is not ready."
1293
1364
  );
1294
1365
  }
1295
- const signature = preview.policy.scope.mode === "eip7702" ? await signRedemption(policyId, prepared) : await signVerified(policyId, prepared.digest, prepared.transaction);
1366
+ const signature = preview.policy.scope.mode === "eip7702" ? await signRedemption(policyId, prepared) : await signVerified(policyId, prepared);
1296
1367
  const submission = await adapter.broadcast({
1297
1368
  policy: preview.policy,
1298
1369
  prepared,
@@ -1856,6 +1927,7 @@ export {
1856
1927
  chainNumber,
1857
1928
  chainsForNamespace,
1858
1929
  channelsUpdate,
1930
+ checkSessionKeyRailGrant,
1859
1931
  clearOneInAppNotification,
1860
1932
  compareCostsKey,
1861
1933
  createDecimalsCache,