@naculus/connect-appkit-core 0.2.5 → 0.2.7

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, NameResolverConfig, NameResolver, NotificationSettings, InAppChannel, NotificationItem } from '@naculus/connect-core';
1
+ import { Namespace, UniversalWalletSession, WalletCapabilities, TokenConfig, WalletError, WalletErrorCode, SimulationResult, NameResolverConfig, NameResolver, NotificationSettings, InAppChannel, NotificationItem, SessionKeyManagerConfig, SessionKeyManager, Hex, UserOperationReceipt, Address, SmartAccountConfig, AtomicityRequirement, ExecutionPlan, SessionKeyInfo, SessionKeyTransaction, SessionKeyScope, ScopeCheckResult } from '@naculus/connect-core';
2
2
 
3
3
  /**
4
4
  * The types the framework-neutral half of appkit is built on.
@@ -362,6 +362,13 @@ declare function createDecimalsCache(token: TokenIdentity, known?: number): Deci
362
362
  declare function readDecimals(cache: DecimalsCache, token: TokenIdentity, known?: number): number | undefined;
363
363
  declare function writeDecimals(cache: DecimalsCache, token: TokenIdentity, value: number): void;
364
364
 
365
+ /** Encode ERC-20 transfer(address,uint256), without signing or broadcasting. */
366
+ declare function encodeErc20Transfer(to: string, amount: bigint): `0x${string}`;
367
+ /** Encode ERC-20 approve(address,uint256), without signing or broadcasting. */
368
+ declare function encodeErc20Approve(spender: string, amount: bigint): `0x${string}`;
369
+ /** Encode ERC-20 transferFrom(address,address,uint256), without signing or broadcasting. */
370
+ declare function encodeErc20TransferFrom(from: string, to: string, amount: bigint): `0x${string}`;
371
+
365
372
  /**
366
373
  * Normalize an EIP-1193 provider error into a WalletError.
367
374
  *
@@ -407,6 +414,44 @@ declare function decodeRevertReason(data: unknown): string | undefined;
407
414
  /** Decoded reason if available, otherwise the node's own message. */
408
415
  declare function resolveRevertReason(data: unknown, fallbackMessage: string): string;
409
416
 
417
+ /** Resolve a simulation target without ever guessing a default chain. */
418
+ declare function resolveSimulationEndpoint(requestedChainId: number | undefined, fallbackChainId: number | undefined, requestedRpcUrl?: string, fallbackRpcUrl?: string): {
419
+ chainId: number;
420
+ rpcUrl: string | undefined;
421
+ };
422
+ /** Resolve the chain from an explicit override or CAIP-2 chain context. */
423
+ declare function resolveContextSimulationEndpoint(requestedChainId: number | undefined, currentChain: WalletChain | null | undefined): {
424
+ chainId: number;
425
+ rpcUrl: string | undefined;
426
+ };
427
+
428
+ interface SimulationTransaction {
429
+ to: string;
430
+ value?: string;
431
+ data?: string;
432
+ gas?: string;
433
+ }
434
+ interface SimulationCallClient {
435
+ chain?: {
436
+ id: number;
437
+ };
438
+ call(args: {
439
+ to: `0x${string}`;
440
+ data: `0x${string}`;
441
+ value: bigint;
442
+ from?: `0x${string}`;
443
+ }): Promise<unknown>;
444
+ }
445
+ interface TransactionSimulationContext {
446
+ chainId?: number;
447
+ currentChain?: WalletChain | null;
448
+ publicClient?: SimulationCallClient | null;
449
+ evmAccount?: string | null;
450
+ fetcher?: typeof fetch;
451
+ }
452
+ /** Basic revert check only: never claims asset changes or risk coverage. */
453
+ declare function simulateTransactionPreview(tx: SimulationTransaction | undefined, context: TransactionSimulationContext): Promise<SimulationResult>;
454
+
410
455
  /**
411
456
  * Shared NameResolver instance for the name-resolution hooks.
412
457
  *
@@ -464,9 +509,9 @@ interface DestinationValidation {
464
509
  issue: DestinationIssue | null;
465
510
  }
466
511
  /**
467
- * Burn heuristic kept from the React hook: known sinks plus any well-formed
468
- * address containing "dead". Stricter than connect-core's prefix-only
469
- * `isBurnAddress`; unifying the two is a connect-lib change.
512
+ * connect-core's `isBurnAddress` is the single definition (sinks, vanity
513
+ * prefixes, "dead" anywhere) since connect-lib 0.2.6; this name stays for
514
+ * callers that imported it.
470
515
  */
471
516
  declare function isBurnDestination(address: string): boolean;
472
517
  declare function validateDestination(address: string): DestinationValidation;
@@ -567,6 +612,173 @@ declare function validateRouteRecipient(quote: ExecutableQuote | null | undefine
567
612
  /** Normalise whatever an executor threw into the hook's error shape. */
568
613
  declare function toExecuteRouteError(cause: unknown): ExecuteRouteError;
569
614
 
615
+ /** The subset of the config that changes what a key may spend or how it is sealed. */
616
+ declare function sessionKeyConfigFingerprint(config?: SessionKeyManagerConfig): string;
617
+ declare function getSharedSessionKeyManager(config?: SessionKeyManagerConfig): SessionKeyManager;
618
+ /** Drop the shared instance. For tests and for a full sign-out that must forget keys. */
619
+ declare function resetSharedSessionKeyManager(): void;
620
+
621
+ /**
622
+ * Validation of an ERC-4337 `eth_getUserOperationReceipt` result, shared by
623
+ * the React hook and the Vue composable. A bundler is an untrusted party:
624
+ * every field is checked, the hash must match the one asked for, and a
625
+ * malformed receipt is refused instead of banked as a confirmation.
626
+ */
627
+ declare class InvalidUserOperationReceiptError extends Error {
628
+ constructor(message: string);
629
+ }
630
+ declare function parseUserOperationReceipt(value: unknown, expectedHash: Hex): UserOperationReceipt;
631
+ /**
632
+ * One `eth_getUserOperationReceipt` call. Resolves to the validated receipt,
633
+ * or null while the operation is not yet included. HTTP and JSON-RPC
634
+ * failures throw a plain Error (retryable); a malformed receipt throws
635
+ * InvalidUserOperationReceiptError (not retryable — the bundler is lying).
636
+ */
637
+ declare function fetchUserOperationReceipt(bundlerUrl: string, hash: Hex, signal?: AbortSignal): Promise<UserOperationReceipt | null>;
638
+
639
+ /**
640
+ * The decisions the smart-account hooks share, kept out of both framework
641
+ * shells: which chain a UserOperation targets, how the account config is
642
+ * assembled from options, and what a wallet's signature must look like.
643
+ */
644
+ type SmartAccountType = "simple" | "light" | "kernel" | "safe";
645
+ interface SmartAccountOptionsLike {
646
+ chainId?: string;
647
+ entryPoint?: Address;
648
+ accountType?: SmartAccountType;
649
+ salt?: bigint;
650
+ }
651
+ /**
652
+ * Target chain for a UserOperation. Fails closed: no chain → error rather
653
+ * than mainnet; a connected wallet on a different chain → chain_mismatch,
654
+ * because the signature it would produce is for the wrong domain.
655
+ */
656
+ declare function resolveUserOpChain(optionsChainId: string | undefined, connectedChainId: string | null | undefined): string;
657
+ /** Account config from owner, CAIP-2 chain and options; entry point falls back per chain. */
658
+ declare function buildSmartAccountConfig(owner: Address, chainId: string, options?: SmartAccountOptionsLike): SmartAccountConfig;
659
+ /** A wallet's answer to a signing request must be non-empty even-length hex. */
660
+ declare function assertHexSignature(value: unknown): Hex;
661
+
662
+ /**
663
+ * Signed off-chain delegation policies: the complete product flow, shared by
664
+ * React and Vue. Everything that decides whether a policy may be created,
665
+ * is still valid, or may sign or broadcast lives here; the framework shells
666
+ * only add state and wiring.
667
+ *
668
+ * Only `offchain` mode is created. An EIP-7702 or AA-module policy needs a
669
+ * real on-chain executor; accepting those here would turn a local record into
670
+ * a false delegation claim.
671
+ */
672
+ /** What the execution planner says about a batch, plus the route it chose. */
673
+ interface PolicyExecutionPreview extends ExecutionPlan {
674
+ route: string | null;
675
+ }
676
+ interface DelegationPolicyPreview {
677
+ policy: SessionKeyInfo | null;
678
+ scope: ScopeCheckResult;
679
+ execution: PolicyExecutionPreview;
680
+ signerMatches: boolean;
681
+ authorizationVerified: boolean;
682
+ ready: boolean;
683
+ broadcastReady: boolean;
684
+ broadcastRoute: PolicyExecutionRoute | null;
685
+ onchainAuthorizationVerified: boolean;
686
+ broadcastSponsored: boolean | null;
687
+ broadcastPromptless: boolean;
688
+ reason: string;
689
+ }
690
+ type PolicyExecutionRoute = "erc4337" | "eip7702";
691
+ interface PolicyExecutionCheck {
692
+ ready: boolean;
693
+ authorizationInstalled: boolean;
694
+ sponsored: boolean;
695
+ promptless: boolean;
696
+ executorAddress?: `0x${string}`;
697
+ reason: string;
698
+ }
699
+ interface PreparedPolicyExecution {
700
+ digest: Hex;
701
+ transaction: SessionKeyTransaction;
702
+ payload: unknown;
703
+ }
704
+ interface PolicyExecutionSubmission {
705
+ route: PolicyExecutionRoute;
706
+ hash: Hex;
707
+ status: "submitted";
708
+ }
709
+ interface PolicyExecutionAdapter {
710
+ route: PolicyExecutionRoute;
711
+ check: (request: {
712
+ policy: SessionKeyInfo;
713
+ transaction: SessionKeyTransaction;
714
+ }) => Promise<PolicyExecutionCheck>;
715
+ prepare: (request: {
716
+ policy: SessionKeyInfo;
717
+ transaction: SessionKeyTransaction;
718
+ }) => Promise<PreparedPolicyExecution>;
719
+ broadcast: (request: {
720
+ policy: SessionKeyInfo;
721
+ prepared: PreparedPolicyExecution;
722
+ signature: Hex;
723
+ }) => Promise<PolicyExecutionSubmission>;
724
+ }
725
+ /** Recovers the signer of an EIP-191 message and compares; the flow never trusts a signature unrecovered. */
726
+ type PolicySignatureVerifier = (input: {
727
+ message: string;
728
+ signature: `0x${string}`;
729
+ signerAddress: `0x${string}`;
730
+ }) => Promise<boolean> | boolean;
731
+ interface DelegationPolicyDeps {
732
+ manager: SessionKeyManager;
733
+ /** Origin bound into the signed message. */
734
+ origin: string;
735
+ /** Connected EOA, bare 0x form, or null. Read at call time. */
736
+ signer: () => `0x${string}` | null;
737
+ signMessage: (message: string) => Promise<string>;
738
+ verifySignature: PolicySignatureVerifier;
739
+ previewExecution: (callCount: number, atomicity: AtomicityRequirement) => PolicyExecutionPreview;
740
+ /** Whether gas must be sponsored for a broadcast to count as ready. */
741
+ sponsorship?: AtomicityRequirement;
742
+ adapter?: PolicyExecutionAdapter;
743
+ /** Current on-chain EIP-7702 delegation of the account. Read at call time. */
744
+ delegation: () => {
745
+ delegated: boolean | null;
746
+ delegate: `0x${string}` | null;
747
+ };
748
+ /** A host-provided encryption key is required for persistent policies. */
749
+ encryptionKeyConfigured: boolean;
750
+ storageAvailable: () => boolean;
751
+ /** Re-read the policy list after a mutation. */
752
+ refresh: () => Promise<void>;
753
+ }
754
+ /**
755
+ * True when the adapter's prepared transaction still means what was
756
+ * requested. Fail-closed: a field the caller left undefined is not a
757
+ * wildcard. An adapter may not add a target to a creation, add calldata to
758
+ * a plain transfer, or pick a chain the caller did not name — each of those
759
+ * changes what the session key ends up signing. Only "no value" and "0"
760
+ * (and "no data" and "0x") are treated as the same thing.
761
+ */
762
+ declare function sameExecutionIntent(requested: SessionKeyTransaction, prepared: SessionKeyTransaction): boolean;
763
+ /**
764
+ * The exact, deterministic message the main wallet signs. Every scope field
765
+ * is included in canonical order so a stored policy whose scope, signer or
766
+ * origin was altered no longer verifies. There must be exactly one copy of
767
+ * this function.
768
+ */
769
+ declare function buildDelegationPolicyMessage(policy: SessionKeyInfo, origin: string): string;
770
+ /** A stored policy is a verification candidate only in this state. */
771
+ declare function isVerifiablePolicy(policy: SessionKeyInfo): boolean;
772
+ interface DelegationPolicyFlow {
773
+ verifyStoredPolicy: (policy: SessionKeyInfo) => Promise<boolean>;
774
+ createPolicy: (scope: Partial<SessionKeyScope>) => Promise<SessionKeyInfo>;
775
+ revokePolicy: (policyId: string) => Promise<void>;
776
+ previewPolicyExecution: (policyId: string, tx: SessionKeyTransaction, callCount?: number, atomicity?: AtomicityRequirement) => Promise<DelegationPolicyPreview>;
777
+ signPolicyDigest: (policyId: string, digest: `0x${string}`, tx: SessionKeyTransaction) => Promise<`0x${string}`>;
778
+ executePolicy: (policyId: string, tx: SessionKeyTransaction) => Promise<PolicyExecutionSubmission>;
779
+ }
780
+ declare function createDelegationPolicyFlow(deps: DelegationPolicyDeps): DelegationPolicyFlow;
781
+
570
782
  declare function withTimeout<T>(promise: Promise<T>, ms: number, label?: string): Promise<T>;
571
783
  interface RetryOptions {
572
784
  maxRetries: number;
@@ -607,4 +819,36 @@ type Web3Action = {
607
819
  declare const initialWeb3State: Web3State;
608
820
  declare function web3Reducer(state: Web3State, action: Web3Action): Web3State;
609
821
 
610
- export { type AddressValidationLevel, type AtomicSupport, type ChainCapabilities, type ChainInfo, type CompareCosts, type CompareCostsInput, type ConnectionStatus, type CostComparison, type CostComparisonOperation, type CostComparisonOptions, DEFAULT_NOTIFICATION_SETTINGS, type DecimalsCache, type DestinationIssue, type DestinationValidation, type ExecutableQuote, type ExecuteRoute, type ExecuteRouteError, type ExecuteRouteOptions, type ExecuteRouteResult, type GetRouteQuotes, NOTIFICATION_SETTINGS_KEY, type NotificationSettingsStorage, type RetryOptions, type RouteQuote, type RouteQuoteInput, type RouteQuoteOptions, type SolanaIdentity, type SolanaPayer, type SolanaRoles, type SolanaRolesAbsence, type SolanaRolesSource, type SolanaRolesState, type SolanaSigner, type SolanaWalletFeatures, type TokenIdentity, type ViemChainShape, type WalletChain, type Web3Action, type Web3State, __resetResolverForTests, addInAppNotification, atomicSupportFor, bareEvmAddress, chainNamespace, chainNumber, chainsForNamespace, channelsUpdate, clearOneInAppNotification, compareCostsKey, createDecimalsCache, createNotification, createNotificationSettingsStorage, decodeRevertReason, describeChain, eip155ChainIdToNumber, getResolver, initialWeb3State, isBurnDestination, isEvmChainId, isPositiveIntegerAmount, isQuotableInput, loadNotificationSettings, mutedChainSettings, normalizeCapabilities, normalizeEip155ChainId, readDecimals, readSolanaRoles, resolveChain, resolveEvmChainId, resolveRevertReason, saveNotificationSettings, selectChainCapabilities, toChainSwitchError, toEip155Accounts, toExecuteRouteError, toViemChain, tokenChainMismatch, tokenKey, updateNotificationSettings, validateDestination, validateRouteRecipient, web3Reducer, withRetry, withTimeout, writeDecimals };
822
+ interface SiwxLocation {
823
+ host: string;
824
+ origin: string;
825
+ }
826
+ interface SiwxMessageLike {
827
+ chainId: string;
828
+ address: string;
829
+ domain: string;
830
+ issuedAt?: string | null;
831
+ expirationTime?: string | null;
832
+ notBefore?: string | null;
833
+ }
834
+ interface SiwxResultLike<M extends SiwxMessageLike = SiwxMessageLike> {
835
+ message: M;
836
+ signature: string;
837
+ }
838
+ declare function defaultSiwxDomain(location?: SiwxLocation): string;
839
+ declare function defaultSiwxUri(location?: SiwxLocation): string;
840
+ declare function isSiwxExpired(result: SiwxResultLike, now: Date): boolean;
841
+ declare function isSiwxNotBeforeValid(result: SiwxResultLike, now: Date): boolean;
842
+ declare function siwxResultToSession<M extends SiwxMessageLike>(result: SiwxResultLike<M>, now?: Date): {
843
+ id: string;
844
+ chainId: string;
845
+ address: string;
846
+ domain: string;
847
+ message: M;
848
+ signature: string;
849
+ issuedAt: string;
850
+ expiresAt: string | null;
851
+ refreshedAt: null;
852
+ };
853
+
854
+ export { type AddressValidationLevel, type AtomicSupport, type ChainCapabilities, type ChainInfo, type CompareCosts, type CompareCostsInput, type ConnectionStatus, type CostComparison, type CostComparisonOperation, type CostComparisonOptions, DEFAULT_NOTIFICATION_SETTINGS, type DecimalsCache, type DelegationPolicyDeps, type DelegationPolicyFlow, type DelegationPolicyPreview, type DestinationIssue, type DestinationValidation, type ExecutableQuote, type ExecuteRoute, type ExecuteRouteError, type ExecuteRouteOptions, type ExecuteRouteResult, type GetRouteQuotes, InvalidUserOperationReceiptError, NOTIFICATION_SETTINGS_KEY, type NotificationSettingsStorage, type PolicyExecutionAdapter, type PolicyExecutionCheck, type PolicyExecutionPreview, type PolicyExecutionRoute, type PolicyExecutionSubmission, type PolicySignatureVerifier, type PreparedPolicyExecution, 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 SolanaPayer, type SolanaRoles, type SolanaRolesAbsence, type SolanaRolesSource, type SolanaRolesState, type SolanaSigner, type SolanaWalletFeatures, type TokenIdentity, type TransactionSimulationContext, type ViemChainShape, type WalletChain, type Web3Action, type Web3State, __resetResolverForTests, addInAppNotification, assertHexSignature, atomicSupportFor, bareEvmAddress, buildDelegationPolicyMessage, buildSmartAccountConfig, chainNamespace, chainNumber, chainsForNamespace, channelsUpdate, clearOneInAppNotification, compareCostsKey, createDecimalsCache, createDelegationPolicyFlow, createNotification, createNotificationSettingsStorage, decodeRevertReason, defaultSiwxDomain, defaultSiwxUri, describeChain, eip155ChainIdToNumber, encodeErc20Approve, encodeErc20Transfer, encodeErc20TransferFrom, fetchUserOperationReceipt, getResolver, getSharedSessionKeyManager, initialWeb3State, isBurnDestination, isEvmChainId, isPositiveIntegerAmount, isQuotableInput, isSiwxExpired, isSiwxNotBeforeValid, isVerifiablePolicy, loadNotificationSettings, mutedChainSettings, normalizeCapabilities, normalizeEip155ChainId, parseUserOperationReceipt, readDecimals, readSolanaRoles, 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 };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Namespace, UniversalWalletSession, WalletCapabilities, TokenConfig, WalletError, WalletErrorCode, NameResolverConfig, NameResolver, NotificationSettings, InAppChannel, NotificationItem } from '@naculus/connect-core';
1
+ import { Namespace, UniversalWalletSession, WalletCapabilities, TokenConfig, WalletError, WalletErrorCode, SimulationResult, NameResolverConfig, NameResolver, NotificationSettings, InAppChannel, NotificationItem, SessionKeyManagerConfig, SessionKeyManager, Hex, UserOperationReceipt, Address, SmartAccountConfig, AtomicityRequirement, ExecutionPlan, SessionKeyInfo, SessionKeyTransaction, SessionKeyScope, ScopeCheckResult } from '@naculus/connect-core';
2
2
 
3
3
  /**
4
4
  * The types the framework-neutral half of appkit is built on.
@@ -362,6 +362,13 @@ declare function createDecimalsCache(token: TokenIdentity, known?: number): Deci
362
362
  declare function readDecimals(cache: DecimalsCache, token: TokenIdentity, known?: number): number | undefined;
363
363
  declare function writeDecimals(cache: DecimalsCache, token: TokenIdentity, value: number): void;
364
364
 
365
+ /** Encode ERC-20 transfer(address,uint256), without signing or broadcasting. */
366
+ declare function encodeErc20Transfer(to: string, amount: bigint): `0x${string}`;
367
+ /** Encode ERC-20 approve(address,uint256), without signing or broadcasting. */
368
+ declare function encodeErc20Approve(spender: string, amount: bigint): `0x${string}`;
369
+ /** Encode ERC-20 transferFrom(address,address,uint256), without signing or broadcasting. */
370
+ declare function encodeErc20TransferFrom(from: string, to: string, amount: bigint): `0x${string}`;
371
+
365
372
  /**
366
373
  * Normalize an EIP-1193 provider error into a WalletError.
367
374
  *
@@ -407,6 +414,44 @@ declare function decodeRevertReason(data: unknown): string | undefined;
407
414
  /** Decoded reason if available, otherwise the node's own message. */
408
415
  declare function resolveRevertReason(data: unknown, fallbackMessage: string): string;
409
416
 
417
+ /** Resolve a simulation target without ever guessing a default chain. */
418
+ declare function resolveSimulationEndpoint(requestedChainId: number | undefined, fallbackChainId: number | undefined, requestedRpcUrl?: string, fallbackRpcUrl?: string): {
419
+ chainId: number;
420
+ rpcUrl: string | undefined;
421
+ };
422
+ /** Resolve the chain from an explicit override or CAIP-2 chain context. */
423
+ declare function resolveContextSimulationEndpoint(requestedChainId: number | undefined, currentChain: WalletChain | null | undefined): {
424
+ chainId: number;
425
+ rpcUrl: string | undefined;
426
+ };
427
+
428
+ interface SimulationTransaction {
429
+ to: string;
430
+ value?: string;
431
+ data?: string;
432
+ gas?: string;
433
+ }
434
+ interface SimulationCallClient {
435
+ chain?: {
436
+ id: number;
437
+ };
438
+ call(args: {
439
+ to: `0x${string}`;
440
+ data: `0x${string}`;
441
+ value: bigint;
442
+ from?: `0x${string}`;
443
+ }): Promise<unknown>;
444
+ }
445
+ interface TransactionSimulationContext {
446
+ chainId?: number;
447
+ currentChain?: WalletChain | null;
448
+ publicClient?: SimulationCallClient | null;
449
+ evmAccount?: string | null;
450
+ fetcher?: typeof fetch;
451
+ }
452
+ /** Basic revert check only: never claims asset changes or risk coverage. */
453
+ declare function simulateTransactionPreview(tx: SimulationTransaction | undefined, context: TransactionSimulationContext): Promise<SimulationResult>;
454
+
410
455
  /**
411
456
  * Shared NameResolver instance for the name-resolution hooks.
412
457
  *
@@ -464,9 +509,9 @@ interface DestinationValidation {
464
509
  issue: DestinationIssue | null;
465
510
  }
466
511
  /**
467
- * Burn heuristic kept from the React hook: known sinks plus any well-formed
468
- * address containing "dead". Stricter than connect-core's prefix-only
469
- * `isBurnAddress`; unifying the two is a connect-lib change.
512
+ * connect-core's `isBurnAddress` is the single definition (sinks, vanity
513
+ * prefixes, "dead" anywhere) since connect-lib 0.2.6; this name stays for
514
+ * callers that imported it.
470
515
  */
471
516
  declare function isBurnDestination(address: string): boolean;
472
517
  declare function validateDestination(address: string): DestinationValidation;
@@ -567,6 +612,173 @@ declare function validateRouteRecipient(quote: ExecutableQuote | null | undefine
567
612
  /** Normalise whatever an executor threw into the hook's error shape. */
568
613
  declare function toExecuteRouteError(cause: unknown): ExecuteRouteError;
569
614
 
615
+ /** The subset of the config that changes what a key may spend or how it is sealed. */
616
+ declare function sessionKeyConfigFingerprint(config?: SessionKeyManagerConfig): string;
617
+ declare function getSharedSessionKeyManager(config?: SessionKeyManagerConfig): SessionKeyManager;
618
+ /** Drop the shared instance. For tests and for a full sign-out that must forget keys. */
619
+ declare function resetSharedSessionKeyManager(): void;
620
+
621
+ /**
622
+ * Validation of an ERC-4337 `eth_getUserOperationReceipt` result, shared by
623
+ * the React hook and the Vue composable. A bundler is an untrusted party:
624
+ * every field is checked, the hash must match the one asked for, and a
625
+ * malformed receipt is refused instead of banked as a confirmation.
626
+ */
627
+ declare class InvalidUserOperationReceiptError extends Error {
628
+ constructor(message: string);
629
+ }
630
+ declare function parseUserOperationReceipt(value: unknown, expectedHash: Hex): UserOperationReceipt;
631
+ /**
632
+ * One `eth_getUserOperationReceipt` call. Resolves to the validated receipt,
633
+ * or null while the operation is not yet included. HTTP and JSON-RPC
634
+ * failures throw a plain Error (retryable); a malformed receipt throws
635
+ * InvalidUserOperationReceiptError (not retryable — the bundler is lying).
636
+ */
637
+ declare function fetchUserOperationReceipt(bundlerUrl: string, hash: Hex, signal?: AbortSignal): Promise<UserOperationReceipt | null>;
638
+
639
+ /**
640
+ * The decisions the smart-account hooks share, kept out of both framework
641
+ * shells: which chain a UserOperation targets, how the account config is
642
+ * assembled from options, and what a wallet's signature must look like.
643
+ */
644
+ type SmartAccountType = "simple" | "light" | "kernel" | "safe";
645
+ interface SmartAccountOptionsLike {
646
+ chainId?: string;
647
+ entryPoint?: Address;
648
+ accountType?: SmartAccountType;
649
+ salt?: bigint;
650
+ }
651
+ /**
652
+ * Target chain for a UserOperation. Fails closed: no chain → error rather
653
+ * than mainnet; a connected wallet on a different chain → chain_mismatch,
654
+ * because the signature it would produce is for the wrong domain.
655
+ */
656
+ declare function resolveUserOpChain(optionsChainId: string | undefined, connectedChainId: string | null | undefined): string;
657
+ /** Account config from owner, CAIP-2 chain and options; entry point falls back per chain. */
658
+ declare function buildSmartAccountConfig(owner: Address, chainId: string, options?: SmartAccountOptionsLike): SmartAccountConfig;
659
+ /** A wallet's answer to a signing request must be non-empty even-length hex. */
660
+ declare function assertHexSignature(value: unknown): Hex;
661
+
662
+ /**
663
+ * Signed off-chain delegation policies: the complete product flow, shared by
664
+ * React and Vue. Everything that decides whether a policy may be created,
665
+ * is still valid, or may sign or broadcast lives here; the framework shells
666
+ * only add state and wiring.
667
+ *
668
+ * Only `offchain` mode is created. An EIP-7702 or AA-module policy needs a
669
+ * real on-chain executor; accepting those here would turn a local record into
670
+ * a false delegation claim.
671
+ */
672
+ /** What the execution planner says about a batch, plus the route it chose. */
673
+ interface PolicyExecutionPreview extends ExecutionPlan {
674
+ route: string | null;
675
+ }
676
+ interface DelegationPolicyPreview {
677
+ policy: SessionKeyInfo | null;
678
+ scope: ScopeCheckResult;
679
+ execution: PolicyExecutionPreview;
680
+ signerMatches: boolean;
681
+ authorizationVerified: boolean;
682
+ ready: boolean;
683
+ broadcastReady: boolean;
684
+ broadcastRoute: PolicyExecutionRoute | null;
685
+ onchainAuthorizationVerified: boolean;
686
+ broadcastSponsored: boolean | null;
687
+ broadcastPromptless: boolean;
688
+ reason: string;
689
+ }
690
+ type PolicyExecutionRoute = "erc4337" | "eip7702";
691
+ interface PolicyExecutionCheck {
692
+ ready: boolean;
693
+ authorizationInstalled: boolean;
694
+ sponsored: boolean;
695
+ promptless: boolean;
696
+ executorAddress?: `0x${string}`;
697
+ reason: string;
698
+ }
699
+ interface PreparedPolicyExecution {
700
+ digest: Hex;
701
+ transaction: SessionKeyTransaction;
702
+ payload: unknown;
703
+ }
704
+ interface PolicyExecutionSubmission {
705
+ route: PolicyExecutionRoute;
706
+ hash: Hex;
707
+ status: "submitted";
708
+ }
709
+ interface PolicyExecutionAdapter {
710
+ route: PolicyExecutionRoute;
711
+ check: (request: {
712
+ policy: SessionKeyInfo;
713
+ transaction: SessionKeyTransaction;
714
+ }) => Promise<PolicyExecutionCheck>;
715
+ prepare: (request: {
716
+ policy: SessionKeyInfo;
717
+ transaction: SessionKeyTransaction;
718
+ }) => Promise<PreparedPolicyExecution>;
719
+ broadcast: (request: {
720
+ policy: SessionKeyInfo;
721
+ prepared: PreparedPolicyExecution;
722
+ signature: Hex;
723
+ }) => Promise<PolicyExecutionSubmission>;
724
+ }
725
+ /** Recovers the signer of an EIP-191 message and compares; the flow never trusts a signature unrecovered. */
726
+ type PolicySignatureVerifier = (input: {
727
+ message: string;
728
+ signature: `0x${string}`;
729
+ signerAddress: `0x${string}`;
730
+ }) => Promise<boolean> | boolean;
731
+ interface DelegationPolicyDeps {
732
+ manager: SessionKeyManager;
733
+ /** Origin bound into the signed message. */
734
+ origin: string;
735
+ /** Connected EOA, bare 0x form, or null. Read at call time. */
736
+ signer: () => `0x${string}` | null;
737
+ signMessage: (message: string) => Promise<string>;
738
+ verifySignature: PolicySignatureVerifier;
739
+ previewExecution: (callCount: number, atomicity: AtomicityRequirement) => PolicyExecutionPreview;
740
+ /** Whether gas must be sponsored for a broadcast to count as ready. */
741
+ sponsorship?: AtomicityRequirement;
742
+ adapter?: PolicyExecutionAdapter;
743
+ /** Current on-chain EIP-7702 delegation of the account. Read at call time. */
744
+ delegation: () => {
745
+ delegated: boolean | null;
746
+ delegate: `0x${string}` | null;
747
+ };
748
+ /** A host-provided encryption key is required for persistent policies. */
749
+ encryptionKeyConfigured: boolean;
750
+ storageAvailable: () => boolean;
751
+ /** Re-read the policy list after a mutation. */
752
+ refresh: () => Promise<void>;
753
+ }
754
+ /**
755
+ * True when the adapter's prepared transaction still means what was
756
+ * requested. Fail-closed: a field the caller left undefined is not a
757
+ * wildcard. An adapter may not add a target to a creation, add calldata to
758
+ * a plain transfer, or pick a chain the caller did not name — each of those
759
+ * changes what the session key ends up signing. Only "no value" and "0"
760
+ * (and "no data" and "0x") are treated as the same thing.
761
+ */
762
+ declare function sameExecutionIntent(requested: SessionKeyTransaction, prepared: SessionKeyTransaction): boolean;
763
+ /**
764
+ * The exact, deterministic message the main wallet signs. Every scope field
765
+ * is included in canonical order so a stored policy whose scope, signer or
766
+ * origin was altered no longer verifies. There must be exactly one copy of
767
+ * this function.
768
+ */
769
+ declare function buildDelegationPolicyMessage(policy: SessionKeyInfo, origin: string): string;
770
+ /** A stored policy is a verification candidate only in this state. */
771
+ declare function isVerifiablePolicy(policy: SessionKeyInfo): boolean;
772
+ interface DelegationPolicyFlow {
773
+ verifyStoredPolicy: (policy: SessionKeyInfo) => Promise<boolean>;
774
+ createPolicy: (scope: Partial<SessionKeyScope>) => Promise<SessionKeyInfo>;
775
+ revokePolicy: (policyId: string) => Promise<void>;
776
+ previewPolicyExecution: (policyId: string, tx: SessionKeyTransaction, callCount?: number, atomicity?: AtomicityRequirement) => Promise<DelegationPolicyPreview>;
777
+ signPolicyDigest: (policyId: string, digest: `0x${string}`, tx: SessionKeyTransaction) => Promise<`0x${string}`>;
778
+ executePolicy: (policyId: string, tx: SessionKeyTransaction) => Promise<PolicyExecutionSubmission>;
779
+ }
780
+ declare function createDelegationPolicyFlow(deps: DelegationPolicyDeps): DelegationPolicyFlow;
781
+
570
782
  declare function withTimeout<T>(promise: Promise<T>, ms: number, label?: string): Promise<T>;
571
783
  interface RetryOptions {
572
784
  maxRetries: number;
@@ -607,4 +819,36 @@ type Web3Action = {
607
819
  declare const initialWeb3State: Web3State;
608
820
  declare function web3Reducer(state: Web3State, action: Web3Action): Web3State;
609
821
 
610
- export { type AddressValidationLevel, type AtomicSupport, type ChainCapabilities, type ChainInfo, type CompareCosts, type CompareCostsInput, type ConnectionStatus, type CostComparison, type CostComparisonOperation, type CostComparisonOptions, DEFAULT_NOTIFICATION_SETTINGS, type DecimalsCache, type DestinationIssue, type DestinationValidation, type ExecutableQuote, type ExecuteRoute, type ExecuteRouteError, type ExecuteRouteOptions, type ExecuteRouteResult, type GetRouteQuotes, NOTIFICATION_SETTINGS_KEY, type NotificationSettingsStorage, type RetryOptions, type RouteQuote, type RouteQuoteInput, type RouteQuoteOptions, type SolanaIdentity, type SolanaPayer, type SolanaRoles, type SolanaRolesAbsence, type SolanaRolesSource, type SolanaRolesState, type SolanaSigner, type SolanaWalletFeatures, type TokenIdentity, type ViemChainShape, type WalletChain, type Web3Action, type Web3State, __resetResolverForTests, addInAppNotification, atomicSupportFor, bareEvmAddress, chainNamespace, chainNumber, chainsForNamespace, channelsUpdate, clearOneInAppNotification, compareCostsKey, createDecimalsCache, createNotification, createNotificationSettingsStorage, decodeRevertReason, describeChain, eip155ChainIdToNumber, getResolver, initialWeb3State, isBurnDestination, isEvmChainId, isPositiveIntegerAmount, isQuotableInput, loadNotificationSettings, mutedChainSettings, normalizeCapabilities, normalizeEip155ChainId, readDecimals, readSolanaRoles, resolveChain, resolveEvmChainId, resolveRevertReason, saveNotificationSettings, selectChainCapabilities, toChainSwitchError, toEip155Accounts, toExecuteRouteError, toViemChain, tokenChainMismatch, tokenKey, updateNotificationSettings, validateDestination, validateRouteRecipient, web3Reducer, withRetry, withTimeout, writeDecimals };
822
+ interface SiwxLocation {
823
+ host: string;
824
+ origin: string;
825
+ }
826
+ interface SiwxMessageLike {
827
+ chainId: string;
828
+ address: string;
829
+ domain: string;
830
+ issuedAt?: string | null;
831
+ expirationTime?: string | null;
832
+ notBefore?: string | null;
833
+ }
834
+ interface SiwxResultLike<M extends SiwxMessageLike = SiwxMessageLike> {
835
+ message: M;
836
+ signature: string;
837
+ }
838
+ declare function defaultSiwxDomain(location?: SiwxLocation): string;
839
+ declare function defaultSiwxUri(location?: SiwxLocation): string;
840
+ declare function isSiwxExpired(result: SiwxResultLike, now: Date): boolean;
841
+ declare function isSiwxNotBeforeValid(result: SiwxResultLike, now: Date): boolean;
842
+ declare function siwxResultToSession<M extends SiwxMessageLike>(result: SiwxResultLike<M>, now?: Date): {
843
+ id: string;
844
+ chainId: string;
845
+ address: string;
846
+ domain: string;
847
+ message: M;
848
+ signature: string;
849
+ issuedAt: string;
850
+ expiresAt: string | null;
851
+ refreshedAt: null;
852
+ };
853
+
854
+ export { type AddressValidationLevel, type AtomicSupport, type ChainCapabilities, type ChainInfo, type CompareCosts, type CompareCostsInput, type ConnectionStatus, type CostComparison, type CostComparisonOperation, type CostComparisonOptions, DEFAULT_NOTIFICATION_SETTINGS, type DecimalsCache, type DelegationPolicyDeps, type DelegationPolicyFlow, type DelegationPolicyPreview, type DestinationIssue, type DestinationValidation, type ExecutableQuote, type ExecuteRoute, type ExecuteRouteError, type ExecuteRouteOptions, type ExecuteRouteResult, type GetRouteQuotes, InvalidUserOperationReceiptError, NOTIFICATION_SETTINGS_KEY, type NotificationSettingsStorage, type PolicyExecutionAdapter, type PolicyExecutionCheck, type PolicyExecutionPreview, type PolicyExecutionRoute, type PolicyExecutionSubmission, type PolicySignatureVerifier, type PreparedPolicyExecution, 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 SolanaPayer, type SolanaRoles, type SolanaRolesAbsence, type SolanaRolesSource, type SolanaRolesState, type SolanaSigner, type SolanaWalletFeatures, type TokenIdentity, type TransactionSimulationContext, type ViemChainShape, type WalletChain, type Web3Action, type Web3State, __resetResolverForTests, addInAppNotification, assertHexSignature, atomicSupportFor, bareEvmAddress, buildDelegationPolicyMessage, buildSmartAccountConfig, chainNamespace, chainNumber, chainsForNamespace, channelsUpdate, clearOneInAppNotification, compareCostsKey, createDecimalsCache, createDelegationPolicyFlow, createNotification, createNotificationSettingsStorage, decodeRevertReason, defaultSiwxDomain, defaultSiwxUri, describeChain, eip155ChainIdToNumber, encodeErc20Approve, encodeErc20Transfer, encodeErc20TransferFrom, fetchUserOperationReceipt, getResolver, getSharedSessionKeyManager, initialWeb3State, isBurnDestination, isEvmChainId, isPositiveIntegerAmount, isQuotableInput, isSiwxExpired, isSiwxNotBeforeValid, isVerifiablePolicy, loadNotificationSettings, mutedChainSettings, normalizeCapabilities, normalizeEip155ChainId, parseUserOperationReceipt, readDecimals, readSolanaRoles, 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 };