@naculus/connect-appkit-core 0.9.0 → 0.10.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,6 @@
1
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';
2
+ import { X402TypedDataSigner } from '@naculus/payments-x402';
3
+ export { X402TypedDataSigner } from '@naculus/payments-x402';
2
4
 
3
5
  /**
4
6
  * The types the framework-neutral half of appkit is built on.
@@ -861,6 +863,7 @@ interface AuthorizationAssetMetadata {
861
863
  }
862
864
  interface DescribeAuthorizationOptions {
863
865
  assets?: Record<AssetId, AuthorizationAssetMetadata>;
866
+ trustedAssets?: readonly string[];
864
867
  locale?: string;
865
868
  /** Unix timestamp in seconds. */
866
869
  now?: number;
@@ -874,6 +877,7 @@ interface AuthorizationAmountView {
874
877
  }
875
878
  interface AuthorizationGrantView {
876
879
  asset: AssetId;
880
+ assetTrust: "trusted" | "unverified" | "unchecked";
877
881
  assetLabel: string;
878
882
  recipients: AuthorizationRecipientView[];
879
883
  perPayment: AuthorizationAmountView;
@@ -972,6 +976,53 @@ declare function applySettlementVerification(payment: PaymentRecord, result: Set
972
976
  */
973
977
  declare function describePayment(input: RequestInfo | URL, result: PaymentFetchResult): PaymentRecord | null;
974
978
 
979
+ type X402SignerUnavailableReason = "no-session" | "not-evm" | "unsupported-wallet-type";
980
+ interface X402Eip1193Provider {
981
+ request(args: {
982
+ method: string;
983
+ params?: unknown[];
984
+ }): Promise<unknown>;
985
+ }
986
+ type X402WalletResolution = {
987
+ provider: X402Eip1193Provider;
988
+ address: `0x${string}`;
989
+ reason: null;
990
+ } | {
991
+ provider: null;
992
+ address: null;
993
+ reason: X402SignerUnavailableReason;
994
+ };
995
+ /** Where a session's EIP-1193 provider can come from; each framework supplies its own. */
996
+ interface X402ProviderSources {
997
+ /** EIP-6963 wallets discovered on the page (`eip6963Connector.getDiscoveredWallets()`). */
998
+ injected?: readonly {
999
+ id: string;
1000
+ provider: X402Eip1193Provider;
1001
+ }[];
1002
+ /** The WalletConnect connector, whose `request` routes to its last session. */
1003
+ walletConnect?: X402Eip1193Provider | null;
1004
+ }
1005
+ /**
1006
+ * The provider that belongs to `session`, chosen by the session's wallet
1007
+ * type (never by connector identity): the injected wallet the session was
1008
+ * made with, or the WalletConnect connector. Null for anything else.
1009
+ */
1010
+ declare function findX402Provider(session: UniversalWalletSession | null | undefined, sources: X402ProviderSources): X402Eip1193Provider | null;
1011
+ interface X402SignerResolution {
1012
+ signer: X402TypedDataSigner | null;
1013
+ reason: X402SignerUnavailableReason | null;
1014
+ }
1015
+ /**
1016
+ * Resolve the connected EVM payer without coupling appkit-core to a connector.
1017
+ *
1018
+ * Framework bindings supply the EIP-1193 request facade owned by the active
1019
+ * session. Classification remains session-based: connector identity is never
1020
+ * used as a routing input.
1021
+ */
1022
+ declare function resolveX402Wallet(session: UniversalWalletSession | null | undefined, provider: X402Eip1193Provider | null | undefined): X402WalletResolution;
1023
+ /** Build the signer after applying the shared session-routing policy. */
1024
+ declare function createX402WalletSigner(session: UniversalWalletSession | null | undefined, provider: X402Eip1193Provider | null | undefined, switchChain: (chainId: string) => Promise<void>): X402SignerResolution;
1025
+
975
1026
  /** Request options accepted by a caller-built MPP session fetch. */
976
1027
  interface MppSessionRequestInit extends RequestInit {
977
1028
  units?: bigint;
@@ -1152,4 +1203,4 @@ declare function siwxResultToSession<M extends SiwxMessageLike>(result: SiwxResu
1152
1203
  refreshedAt: null;
1153
1204
  };
1154
1205
 
1155
- 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, __resetResolverForTests, addInAppNotification, applySettlementVerification, assertHexSignature, atomicSupportFor, bareEvmAddress, buildDelegationPolicyMessage, buildSmartAccountConfig, chainNamespace, chainNumber, chainsForNamespace, channelsUpdate, clearOneInAppNotification, compareCostsKey, createDecimalsCache, createDelegationFrameworkAdapter, createDelegationPolicyFlow, createNotification, createNotificationSettingsStorage, createSolanaSessionKeyFlow, decodeRevertReason, defaultSiwxDomain, defaultSiwxUri, describeAuthorization, describeChain, describePayment, eip155ChainIdToNumber, encodeErc20Approve, encodeErc20Transfer, encodeErc20TransferFrom, explainSpend, fetchUserOperationReceipt, 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, sameExecutionIntent, saveNotificationSettings, selectChainCapabilities, sessionKeyConfigFingerprint, simulateTransactionPreview, siwxResultToSession, toChainSwitchError, toEip155Accounts, toExecuteRouteError, toViemChain, tokenChainMismatch, tokenKey, updateNotificationSettings, validateDestination, validateRouteRecipient, web3Reducer, withRetry, withTimeout, writeDecimals };
1206
+ 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, 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 };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
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';
2
+ import { X402TypedDataSigner } from '@naculus/payments-x402';
3
+ export { X402TypedDataSigner } from '@naculus/payments-x402';
2
4
 
3
5
  /**
4
6
  * The types the framework-neutral half of appkit is built on.
@@ -861,6 +863,7 @@ interface AuthorizationAssetMetadata {
861
863
  }
862
864
  interface DescribeAuthorizationOptions {
863
865
  assets?: Record<AssetId, AuthorizationAssetMetadata>;
866
+ trustedAssets?: readonly string[];
864
867
  locale?: string;
865
868
  /** Unix timestamp in seconds. */
866
869
  now?: number;
@@ -874,6 +877,7 @@ interface AuthorizationAmountView {
874
877
  }
875
878
  interface AuthorizationGrantView {
876
879
  asset: AssetId;
880
+ assetTrust: "trusted" | "unverified" | "unchecked";
877
881
  assetLabel: string;
878
882
  recipients: AuthorizationRecipientView[];
879
883
  perPayment: AuthorizationAmountView;
@@ -972,6 +976,53 @@ declare function applySettlementVerification(payment: PaymentRecord, result: Set
972
976
  */
973
977
  declare function describePayment(input: RequestInfo | URL, result: PaymentFetchResult): PaymentRecord | null;
974
978
 
979
+ type X402SignerUnavailableReason = "no-session" | "not-evm" | "unsupported-wallet-type";
980
+ interface X402Eip1193Provider {
981
+ request(args: {
982
+ method: string;
983
+ params?: unknown[];
984
+ }): Promise<unknown>;
985
+ }
986
+ type X402WalletResolution = {
987
+ provider: X402Eip1193Provider;
988
+ address: `0x${string}`;
989
+ reason: null;
990
+ } | {
991
+ provider: null;
992
+ address: null;
993
+ reason: X402SignerUnavailableReason;
994
+ };
995
+ /** Where a session's EIP-1193 provider can come from; each framework supplies its own. */
996
+ interface X402ProviderSources {
997
+ /** EIP-6963 wallets discovered on the page (`eip6963Connector.getDiscoveredWallets()`). */
998
+ injected?: readonly {
999
+ id: string;
1000
+ provider: X402Eip1193Provider;
1001
+ }[];
1002
+ /** The WalletConnect connector, whose `request` routes to its last session. */
1003
+ walletConnect?: X402Eip1193Provider | null;
1004
+ }
1005
+ /**
1006
+ * The provider that belongs to `session`, chosen by the session's wallet
1007
+ * type (never by connector identity): the injected wallet the session was
1008
+ * made with, or the WalletConnect connector. Null for anything else.
1009
+ */
1010
+ declare function findX402Provider(session: UniversalWalletSession | null | undefined, sources: X402ProviderSources): X402Eip1193Provider | null;
1011
+ interface X402SignerResolution {
1012
+ signer: X402TypedDataSigner | null;
1013
+ reason: X402SignerUnavailableReason | null;
1014
+ }
1015
+ /**
1016
+ * Resolve the connected EVM payer without coupling appkit-core to a connector.
1017
+ *
1018
+ * Framework bindings supply the EIP-1193 request facade owned by the active
1019
+ * session. Classification remains session-based: connector identity is never
1020
+ * used as a routing input.
1021
+ */
1022
+ declare function resolveX402Wallet(session: UniversalWalletSession | null | undefined, provider: X402Eip1193Provider | null | undefined): X402WalletResolution;
1023
+ /** Build the signer after applying the shared session-routing policy. */
1024
+ declare function createX402WalletSigner(session: UniversalWalletSession | null | undefined, provider: X402Eip1193Provider | null | undefined, switchChain: (chainId: string) => Promise<void>): X402SignerResolution;
1025
+
975
1026
  /** Request options accepted by a caller-built MPP session fetch. */
976
1027
  interface MppSessionRequestInit extends RequestInit {
977
1028
  units?: bigint;
@@ -1152,4 +1203,4 @@ declare function siwxResultToSession<M extends SiwxMessageLike>(result: SiwxResu
1152
1203
  refreshedAt: null;
1153
1204
  };
1154
1205
 
1155
- 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, __resetResolverForTests, addInAppNotification, applySettlementVerification, assertHexSignature, atomicSupportFor, bareEvmAddress, buildDelegationPolicyMessage, buildSmartAccountConfig, chainNamespace, chainNumber, chainsForNamespace, channelsUpdate, clearOneInAppNotification, compareCostsKey, createDecimalsCache, createDelegationFrameworkAdapter, createDelegationPolicyFlow, createNotification, createNotificationSettingsStorage, createSolanaSessionKeyFlow, decodeRevertReason, defaultSiwxDomain, defaultSiwxUri, describeAuthorization, describeChain, describePayment, eip155ChainIdToNumber, encodeErc20Approve, encodeErc20Transfer, encodeErc20TransferFrom, explainSpend, fetchUserOperationReceipt, 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, sameExecutionIntent, saveNotificationSettings, selectChainCapabilities, sessionKeyConfigFingerprint, simulateTransactionPreview, siwxResultToSession, toChainSwitchError, toEip155Accounts, toExecuteRouteError, toViemChain, tokenChainMismatch, tokenKey, updateNotificationSettings, validateDestination, validateRouteRecipient, web3Reducer, withRetry, withTimeout, writeDecimals };
1206
+ 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, 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 };
package/dist/index.js CHANGED
@@ -1300,39 +1300,44 @@ function createDelegationPolicyFlow(deps) {
1300
1300
  import {
1301
1301
  evaluateSpend
1302
1302
  } from "@naculus/connect-core";
1303
- function assetAddress(asset) {
1304
- return asset.split(/[:/]/).at(-1);
1305
- }
1306
1303
  function groupDigits(value) {
1307
1304
  let out = "";
1308
1305
  for (let i = 0; i < value.length; i++)
1309
1306
  out += (i && (value.length - i) % 3 === 0 ? "," : "") + value[i];
1310
1307
  return out;
1311
1308
  }
1312
- function trimTrailingZeros(value) {
1313
- let end = value.length;
1314
- while (value[end - 1] === "0") end--;
1315
- return value.slice(0, end);
1309
+ function trustedMetadata(asset, options) {
1310
+ const trust = !options.trustedAssets ? "unchecked" : options.trustedAssets.some(
1311
+ (t) => canonicalAssetId(t) === canonicalAssetId(asset)
1312
+ ) ? "trusted" : "unverified";
1313
+ return [trust, trust === "unverified" ? void 0 : options.assets?.[asset]];
1314
+ }
1315
+ function canonicalAssetId(asset) {
1316
+ return asset.replace(
1317
+ /^(eip155:[^/]+\/erc20:)(.+)$/,
1318
+ (_, prefix, reference) => prefix + reference.toLowerCase()
1319
+ );
1316
1320
  }
1317
1321
  function formatAuthorizationAmount(amount, metadata) {
1318
1322
  const baseUnits = amount.toString();
1319
- if (!metadata || !metadata.symbol || !Number.isSafeInteger(metadata.decimals) || metadata.decimals < 0 || metadata.decimals > 255) {
1323
+ if (!metadata?.symbol || !Number.isSafeInteger(metadata.decimals) || metadata.decimals < 0 || metadata.decimals > 255) {
1320
1324
  return {
1321
1325
  formatted: `${groupDigits(baseUnits)} base units`
1322
1326
  };
1323
1327
  }
1324
1328
  const decimals = metadata.decimals;
1325
1329
  const padded = baseUnits.padStart(decimals + 1, "0");
1326
- const integer = decimals === 0 ? padded : padded.slice(0, -decimals);
1327
- const fraction = decimals === 0 ? "" : trimTrailingZeros(padded.slice(-decimals));
1328
- const value = `${groupDigits(integer)}${fraction ? `.${fraction}` : ""}`;
1329
- return { formatted: `${value} ${metadata.symbol}` };
1330
+ const integer = padded.slice(0, decimals ? -decimals : void 0);
1331
+ let fraction = decimals ? padded.slice(-decimals) : "";
1332
+ while (fraction.endsWith("0")) fraction = fraction.slice(0, -1);
1333
+ return {
1334
+ formatted: `${groupDigits(integer)}${fraction ? `.${fraction}` : ""} ${metadata.symbol}`
1335
+ };
1330
1336
  }
1331
1337
  function relativeExpiry(expiresAt, now, locale) {
1332
1338
  const seconds = expiresAt - now;
1333
1339
  const absolute = Math.abs(seconds);
1334
- const divisor = absolute >= 31536e3 ? 31536e3 : absolute >= 2592e3 ? 2592e3 : absolute >= 86400 ? 86400 : absolute >= 3600 ? 3600 : absolute >= 60 ? 60 : 1;
1335
- const unit = divisor === 31536e3 ? "year" : divisor === 2592e3 ? "month" : divisor === 86400 ? "day" : divisor === 3600 ? "hour" : divisor === 60 ? "minute" : "second";
1340
+ const [divisor, unit] = absolute >= 31536e3 ? [31536e3, "year"] : absolute >= 2592e3 ? [2592e3, "month"] : absolute >= 86400 ? [86400, "day"] : absolute >= 3600 ? [3600, "hour"] : absolute >= 60 ? [60, "minute"] : [1, "second"];
1336
1341
  const value = Math.round(seconds / divisor);
1337
1342
  if (typeof Intl.RelativeTimeFormat !== "function") {
1338
1343
  const count = Math.abs(value);
@@ -1350,10 +1355,11 @@ function describeAuthorization(input, options = {}) {
1350
1355
  label,
1351
1356
  principal: input.principal ?? null,
1352
1357
  grants: input.grants.map((grant) => {
1353
- const metadata = options.assets?.[grant.asset];
1358
+ const [assetTrust, metadata] = trustedMetadata(grant.asset, options);
1354
1359
  return {
1355
1360
  asset: grant.asset,
1356
- assetLabel: metadata?.symbol || assetAddress(grant.asset),
1361
+ assetTrust,
1362
+ assetLabel: metadata?.symbol || grant.asset.split(":").at(-1),
1357
1363
  recipients: grant.recipients.map((full) => ({
1358
1364
  shortened: full.length <= 14 ? full : `${full.slice(0, 6)}\u2026${full.slice(-6)}`,
1359
1365
  full
@@ -1406,7 +1412,7 @@ function explainSpend(authorization, request, options = {}) {
1406
1412
  const remainingTotal = authorization.grants[verdict.grant].maxTotal - request.spentSoFar - request.amount;
1407
1413
  const remainingTotalFormatted = formatAuthorizationAmount(
1408
1414
  remainingTotal,
1409
- options.assets?.[authorization.grants[verdict.grant].asset]
1415
+ trustedMetadata(authorization.grants[verdict.grant].asset, options)[1]
1410
1416
  );
1411
1417
  return {
1412
1418
  allowed: true,
@@ -1488,6 +1494,62 @@ function describePayment(input, result) {
1488
1494
  };
1489
1495
  }
1490
1496
 
1497
+ // src/x402-wallet.ts
1498
+ import {
1499
+ isEvmAddress as isEvmAddress2,
1500
+ parseCaip10
1501
+ } from "@naculus/connect-core";
1502
+ import {
1503
+ walletX402Signer
1504
+ } from "@naculus/payments-x402";
1505
+ function findX402Provider(session, sources) {
1506
+ if (!session) return null;
1507
+ if (session.walletType === "eip6963" || session.id.startsWith("eip6963-")) {
1508
+ return sources.injected?.find((wallet) => wallet.id === session.walletId)?.provider ?? null;
1509
+ }
1510
+ if (session.walletType === "walletconnect") {
1511
+ return sources.walletConnect ?? null;
1512
+ }
1513
+ return null;
1514
+ }
1515
+ function unavailable(reason) {
1516
+ return { provider: null, address: null, reason };
1517
+ }
1518
+ function resolveX402Wallet(session, provider) {
1519
+ if (!session) return unavailable("no-session");
1520
+ const namespace = session.namespaces.eip155;
1521
+ if (!namespace) return unavailable("not-evm");
1522
+ const isInjected = session.walletType === "eip6963" || session.id.startsWith("eip6963-");
1523
+ const isWalletConnect = session.walletType === "walletconnect";
1524
+ if (!isInjected && !isWalletConnect || !provider?.request) {
1525
+ return unavailable("unsupported-wallet-type");
1526
+ }
1527
+ for (const account of namespace.accounts) {
1528
+ const parsed = parseCaip10(account);
1529
+ const address = parsed?.namespace === "eip155" ? parsed.address : account;
1530
+ if (isEvmAddress2(address)) {
1531
+ return {
1532
+ provider,
1533
+ address,
1534
+ reason: null
1535
+ };
1536
+ }
1537
+ }
1538
+ return unavailable("not-evm");
1539
+ }
1540
+ function createX402WalletSigner(session, provider, switchChain) {
1541
+ const resolved = resolveX402Wallet(session, provider);
1542
+ if (resolved.reason) return { signer: null, reason: resolved.reason };
1543
+ return {
1544
+ signer: walletX402Signer({
1545
+ provider: resolved.provider,
1546
+ address: resolved.address,
1547
+ switchChain
1548
+ }),
1549
+ reason: null
1550
+ };
1551
+ }
1552
+
1491
1553
  // src/mpp-session.ts
1492
1554
  function record2(value) {
1493
1555
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
@@ -1761,6 +1823,7 @@ export {
1761
1823
  createNotification,
1762
1824
  createNotificationSettingsStorage,
1763
1825
  createSolanaSessionKeyFlow,
1826
+ createX402WalletSigner,
1764
1827
  decodeRevertReason,
1765
1828
  defaultSiwxDomain,
1766
1829
  defaultSiwxUri,
@@ -1773,6 +1836,7 @@ export {
1773
1836
  encodeErc20TransferFrom,
1774
1837
  explainSpend,
1775
1838
  fetchUserOperationReceipt,
1839
+ findX402Provider,
1776
1840
  formatAuthorizationAmount,
1777
1841
  getResolver,
1778
1842
  getSharedSessionKeyManager,
@@ -1803,6 +1867,7 @@ export {
1803
1867
  resolveRevertReason,
1804
1868
  resolveSimulationEndpoint,
1805
1869
  resolveUserOpChain,
1870
+ resolveX402Wallet,
1806
1871
  sameExecutionIntent,
1807
1872
  saveNotificationSettings,
1808
1873
  selectChainCapabilities,