@naculus/connect-appkit-core 0.6.0 → 0.8.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/README.md +13 -0
- package/dist/index.cjs +188 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +142 -6
- package/dist/index.d.ts +142 -6
- package/dist/index.js +173 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
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, SolanaSessionKeyInfo, SolanaSessionKeyScope, SolanaSessionKeyManager, SolanaPaymentRpc } 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, delegationTypedData, SessionKeyScope, ScopeCheckResult, SpendRefusal, Authorization, ListedAuthorization, SpendRequest, SettlementVerification, SolanaSessionKeyInfo, SolanaSessionKeyScope, SolanaSessionKeyManager, SolanaPaymentRpc } from '@naculus/connect-core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The types the framework-neutral half of appkit is built on.
|
|
@@ -43,7 +43,7 @@ interface Web3State {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
* EIP-5792 capability answers,
|
|
46
|
+
* EIP-5792 capability answers, normalized once.
|
|
47
47
|
*
|
|
48
48
|
* Deciding how to execute before sending is the whole point of
|
|
49
49
|
* `wallet_getCapabilities`, and the reasoning that turns a raw answer into
|
|
@@ -82,7 +82,7 @@ declare function normalizeCapabilities(raw: Record<string, unknown> | null | und
|
|
|
82
82
|
/**
|
|
83
83
|
* Find the entry for a chain, by CAIP-2 or by the hex form.
|
|
84
84
|
*
|
|
85
|
-
* Connectors
|
|
85
|
+
* Connectors normalize keys to CAIP-2, but a wallet answering in raw hex
|
|
86
86
|
* through a custom connector should still be found rather than reported as
|
|
87
87
|
* "unknown" next to an entry that is sitting right there.
|
|
88
88
|
*/
|
|
@@ -484,6 +484,15 @@ declare function createNotificationSettingsStorage(): NotificationSettingsStorag
|
|
|
484
484
|
declare function loadNotificationSettings(storage: NotificationSettingsStorage): Promise<NotificationSettings | null>;
|
|
485
485
|
declare function saveNotificationSettings(storage: NotificationSettingsStorage, settings: NotificationSettings): void;
|
|
486
486
|
declare function updateNotificationSettings(current: NotificationSettings, update: Partial<NotificationSettings>): NotificationSettings;
|
|
487
|
+
/** One settings change, computed from the settings it applies to. */
|
|
488
|
+
type NotificationSettingsUpdate = (current: NotificationSettings) => Partial<NotificationSettings>;
|
|
489
|
+
/**
|
|
490
|
+
* The settings once the persisted ones finish loading: every change made
|
|
491
|
+
* before the load resolved, replayed in order on top of what was persisted
|
|
492
|
+
* (or the defaults when nothing was). Without this the late load overwrote
|
|
493
|
+
* those changes, e.g. a chain muted during the first render came back.
|
|
494
|
+
*/
|
|
495
|
+
declare function replayNotificationSettings(persisted: NotificationSettings | null, updates: readonly NotificationSettingsUpdate[]): NotificationSettings;
|
|
487
496
|
declare function channelsUpdate(channels: string[]): Partial<NotificationSettings>;
|
|
488
497
|
declare function mutedChainSettings(settings: NotificationSettings, chainId: string, muted: boolean): Partial<NotificationSettings>;
|
|
489
498
|
declare function createNotification(item: Omit<NotificationItem, "id" | "timestamp">): NotificationItem;
|
|
@@ -609,7 +618,7 @@ type ExecuteRoute = (quote: ExecutableQuote, recipient: string, options?: Execut
|
|
|
609
618
|
* a valid non-EVM address on a guess.
|
|
610
619
|
*/
|
|
611
620
|
declare function validateRouteRecipient(quote: ExecutableQuote | null | undefined, recipient: string): ExecuteRouteError | null;
|
|
612
|
-
/**
|
|
621
|
+
/** Normalize whatever an executor threw into the hook's error shape. */
|
|
613
622
|
declare function toExecuteRouteError(cause: unknown): ExecuteRouteError;
|
|
614
623
|
|
|
615
624
|
/** The subset of the config that changes what a key may spend or how it is sealed. */
|
|
@@ -845,6 +854,62 @@ interface DelegationFrameworkAdapterOptions {
|
|
|
845
854
|
}
|
|
846
855
|
declare function createDelegationFrameworkAdapter(options: DelegationFrameworkAdapterOptions): PolicyExecutionAdapter;
|
|
847
856
|
|
|
857
|
+
type AssetId = string;
|
|
858
|
+
interface AuthorizationAssetMetadata {
|
|
859
|
+
symbol: string;
|
|
860
|
+
decimals: number;
|
|
861
|
+
}
|
|
862
|
+
interface DescribeAuthorizationOptions {
|
|
863
|
+
assets?: Record<AssetId, AuthorizationAssetMetadata>;
|
|
864
|
+
locale?: string;
|
|
865
|
+
/** Unix timestamp in seconds. */
|
|
866
|
+
now?: number;
|
|
867
|
+
}
|
|
868
|
+
interface AuthorizationRecipientView {
|
|
869
|
+
shortened: string;
|
|
870
|
+
full: string;
|
|
871
|
+
}
|
|
872
|
+
interface AuthorizationAmountView {
|
|
873
|
+
formatted: string;
|
|
874
|
+
}
|
|
875
|
+
interface AuthorizationGrantView {
|
|
876
|
+
asset: AssetId;
|
|
877
|
+
assetLabel: string;
|
|
878
|
+
recipients: AuthorizationRecipientView[];
|
|
879
|
+
perPayment: AuthorizationAmountView;
|
|
880
|
+
total: AuthorizationAmountView;
|
|
881
|
+
count: number | null;
|
|
882
|
+
rails: string[];
|
|
883
|
+
}
|
|
884
|
+
interface AuthorizationExpiryView {
|
|
885
|
+
timestamp: number;
|
|
886
|
+
absolute: string;
|
|
887
|
+
relative: string;
|
|
888
|
+
}
|
|
889
|
+
interface AuthorizationDescription {
|
|
890
|
+
label: string | null;
|
|
891
|
+
principal: string | null;
|
|
892
|
+
grants: AuthorizationGrantView[];
|
|
893
|
+
expiry: AuthorizationExpiryView;
|
|
894
|
+
warnings: string[];
|
|
895
|
+
}
|
|
896
|
+
declare function formatAuthorizationAmount(amount: bigint, metadata: AuthorizationAssetMetadata | undefined): AuthorizationAmountView;
|
|
897
|
+
/** Build a network-free consent/listing view of an authorization. */
|
|
898
|
+
declare function describeAuthorization(input: Authorization | ListedAuthorization, options?: DescribeAuthorizationOptions): AuthorizationDescription;
|
|
899
|
+
type SpendExplanation = {
|
|
900
|
+
allowed: true;
|
|
901
|
+
grant: number;
|
|
902
|
+
remainingTotal: bigint;
|
|
903
|
+
remainingTotalFormatted: AuthorizationAmountView;
|
|
904
|
+
sentence: string;
|
|
905
|
+
} | {
|
|
906
|
+
allowed: false;
|
|
907
|
+
reason: SpendRefusal;
|
|
908
|
+
sentence: string;
|
|
909
|
+
};
|
|
910
|
+
/** Explain the shared evaluator's exact allow/refuse result for a UI. */
|
|
911
|
+
declare function explainSpend(authorization: Authorization, request: SpendRequest, options?: DescribeAuthorizationOptions): SpendExplanation;
|
|
912
|
+
|
|
848
913
|
/**
|
|
849
914
|
* Agentic payments (x402 / MPP) for the appkit shells.
|
|
850
915
|
*
|
|
@@ -852,7 +917,7 @@ declare function createDelegationFrameworkAdapter(options: DelegationFrameworkAd
|
|
|
852
917
|
* `@naculus/payments-x402` or `createMppFetch` from `@naculus/payments-mpp`,
|
|
853
918
|
* with the session key and limits it chooses — and the hooks only track its
|
|
854
919
|
* state. So appkit takes no dependency on either package: their results are
|
|
855
|
-
* read here by shape, and a shape this does not
|
|
920
|
+
* read here by shape, and a shape this does not recognize is reported as
|
|
856
921
|
* `protocol: "unknown"` rather than guessed at.
|
|
857
922
|
*/
|
|
858
923
|
/** What `createX402Fetch` and `createMppFetch` return, structurally. */
|
|
@@ -866,6 +931,11 @@ interface PaymentFetchResult {
|
|
|
866
931
|
receipt?: unknown;
|
|
867
932
|
}
|
|
868
933
|
type PaymentFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<PaymentFetchResult>;
|
|
934
|
+
type PaymentVerificationStatus = "unverified" | "pending" | "verified" | "mismatch" | "failed" | "unavailable";
|
|
935
|
+
interface PaymentVerification {
|
|
936
|
+
status: PaymentVerificationStatus;
|
|
937
|
+
reason?: string;
|
|
938
|
+
}
|
|
869
939
|
/** One payment, in the terms a UI shows. Amounts are token base units. */
|
|
870
940
|
interface PaymentRecord {
|
|
871
941
|
protocol: "x402" | "mpp" | "unknown";
|
|
@@ -882,7 +952,19 @@ interface PaymentRecord {
|
|
|
882
952
|
* other fields are what the client signed.
|
|
883
953
|
*/
|
|
884
954
|
reference: string | null;
|
|
955
|
+
/** A server-reported reference remains unverified until this is verified. */
|
|
956
|
+
verification: PaymentVerification;
|
|
957
|
+
}
|
|
958
|
+
declare const DEFAULT_VERIFY_RETRY: {
|
|
959
|
+
readonly attempts: 5;
|
|
960
|
+
readonly delayMs: 4000;
|
|
961
|
+
};
|
|
962
|
+
interface VerifyRetryOptions {
|
|
963
|
+
attempts: number;
|
|
964
|
+
delayMs: number;
|
|
885
965
|
}
|
|
966
|
+
/** Apply a verifier result without mutating the payment record. */
|
|
967
|
+
declare function applySettlementVerification(payment: PaymentRecord, result: SettlementVerification): PaymentRecord;
|
|
886
968
|
/**
|
|
887
969
|
* The payment a paying fetch made, or null when it paid nothing. Reads the
|
|
888
970
|
* x402 requirement / settlement (EVM or Solana) or the MPP `evm` / `solana`
|
|
@@ -890,6 +972,60 @@ interface PaymentRecord {
|
|
|
890
972
|
*/
|
|
891
973
|
declare function describePayment(input: RequestInfo | URL, result: PaymentFetchResult): PaymentRecord | null;
|
|
892
974
|
|
|
975
|
+
/** Request options accepted by a caller-built MPP session fetch. */
|
|
976
|
+
interface MppSessionRequestInit extends RequestInit {
|
|
977
|
+
units?: bigint;
|
|
978
|
+
}
|
|
979
|
+
/** An open MPP payment channel, represented without depending on payments-mpp. */
|
|
980
|
+
interface MppSessionChannel {
|
|
981
|
+
channelId: string;
|
|
982
|
+
payer: string;
|
|
983
|
+
payee: string;
|
|
984
|
+
mint: string;
|
|
985
|
+
channelProgram: string;
|
|
986
|
+
deposit: bigint;
|
|
987
|
+
gracePeriodSeconds: number;
|
|
988
|
+
openSlot: bigint;
|
|
989
|
+
salt: bigint;
|
|
990
|
+
}
|
|
991
|
+
/** A successful MPP receipt, represented structurally. */
|
|
992
|
+
interface MppSessionReceipt {
|
|
993
|
+
status: "success";
|
|
994
|
+
method: string;
|
|
995
|
+
timestamp: string;
|
|
996
|
+
reference: string;
|
|
997
|
+
[field: string]: unknown;
|
|
998
|
+
}
|
|
999
|
+
interface MppSessionFetchResult {
|
|
1000
|
+
response: Response;
|
|
1001
|
+
receipt: unknown;
|
|
1002
|
+
channel: unknown;
|
|
1003
|
+
}
|
|
1004
|
+
type MppSessionRequest = (input: RequestInfo | URL, init?: MppSessionRequestInit) => Promise<MppSessionFetchResult>;
|
|
1005
|
+
interface MppSessionForceCloseResult {
|
|
1006
|
+
requestCloseTxHash: string;
|
|
1007
|
+
withdrawPayer(): Promise<string>;
|
|
1008
|
+
}
|
|
1009
|
+
interface MppSessionMeter {
|
|
1010
|
+
add(units: bigint): void;
|
|
1011
|
+
readonly pending: bigint;
|
|
1012
|
+
}
|
|
1013
|
+
/** The caller-owned session surface consumed by the React and Vue shells. */
|
|
1014
|
+
interface MppSessionFetch extends MppSessionRequest {
|
|
1015
|
+
readonly meter: MppSessionMeter;
|
|
1016
|
+
readonly channels: readonly unknown[];
|
|
1017
|
+
close(): Promise<MppSessionFetchResult>;
|
|
1018
|
+
forceClose(): Promise<MppSessionForceCloseResult>;
|
|
1019
|
+
}
|
|
1020
|
+
/** Return a channel only when all public fields have the expected shape. */
|
|
1021
|
+
declare function readMppSessionChannel(value: unknown): MppSessionChannel | null;
|
|
1022
|
+
/** Return the newest structurally valid channel currently held by a session. */
|
|
1023
|
+
declare function readCurrentMppSessionChannel(session: Pick<MppSessionFetch, "channels">): MppSessionChannel | null;
|
|
1024
|
+
/** Return a receipt only when it has the public success-receipt shape. */
|
|
1025
|
+
declare function readMppSessionReceipt(value: unknown): MppSessionReceipt | null;
|
|
1026
|
+
/** A post-send channel-open failure carries the channel that can be recovered. */
|
|
1027
|
+
declare function readMppRecoveryChannelId(error: unknown): string | null;
|
|
1028
|
+
|
|
893
1029
|
/**
|
|
894
1030
|
* Solana session keys for the appkit shells (connect-lib STATE thread 18).
|
|
895
1031
|
*
|
|
@@ -1016,4 +1152,4 @@ declare function siwxResultToSession<M extends SiwxMessageLike>(result: SiwxResu
|
|
|
1016
1152
|
refreshedAt: null;
|
|
1017
1153
|
};
|
|
1018
1154
|
|
|
1019
|
-
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 DelegationFrameworkAdapterOptions, type DelegationPolicyDeps, type DelegationPolicyFlow, type DelegationPolicyPreview, type DelegationTypedData, type DestinationIssue, type DestinationValidation, type ExecutableQuote, type ExecuteRoute, type ExecuteRouteError, type ExecuteRouteOptions, type ExecuteRouteResult, type GetRouteQuotes, InvalidUserOperationReceiptError, NOTIFICATION_SETTINGS_KEY, type NotificationSettingsStorage, type PaymentFetch, type PaymentFetchResult, type PaymentRecord, 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 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, createDelegationFrameworkAdapter, createDelegationPolicyFlow, createNotification, createNotificationSettingsStorage, createSolanaSessionKeyFlow, decodeRevertReason, defaultSiwxDomain, defaultSiwxUri, describeChain, describePayment, 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 };
|
|
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 };
|
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, SolanaSessionKeyInfo, SolanaSessionKeyScope, SolanaSessionKeyManager, SolanaPaymentRpc } 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, delegationTypedData, SessionKeyScope, ScopeCheckResult, SpendRefusal, Authorization, ListedAuthorization, SpendRequest, SettlementVerification, SolanaSessionKeyInfo, SolanaSessionKeyScope, SolanaSessionKeyManager, SolanaPaymentRpc } from '@naculus/connect-core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The types the framework-neutral half of appkit is built on.
|
|
@@ -43,7 +43,7 @@ interface Web3State {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
* EIP-5792 capability answers,
|
|
46
|
+
* EIP-5792 capability answers, normalized once.
|
|
47
47
|
*
|
|
48
48
|
* Deciding how to execute before sending is the whole point of
|
|
49
49
|
* `wallet_getCapabilities`, and the reasoning that turns a raw answer into
|
|
@@ -82,7 +82,7 @@ declare function normalizeCapabilities(raw: Record<string, unknown> | null | und
|
|
|
82
82
|
/**
|
|
83
83
|
* Find the entry for a chain, by CAIP-2 or by the hex form.
|
|
84
84
|
*
|
|
85
|
-
* Connectors
|
|
85
|
+
* Connectors normalize keys to CAIP-2, but a wallet answering in raw hex
|
|
86
86
|
* through a custom connector should still be found rather than reported as
|
|
87
87
|
* "unknown" next to an entry that is sitting right there.
|
|
88
88
|
*/
|
|
@@ -484,6 +484,15 @@ declare function createNotificationSettingsStorage(): NotificationSettingsStorag
|
|
|
484
484
|
declare function loadNotificationSettings(storage: NotificationSettingsStorage): Promise<NotificationSettings | null>;
|
|
485
485
|
declare function saveNotificationSettings(storage: NotificationSettingsStorage, settings: NotificationSettings): void;
|
|
486
486
|
declare function updateNotificationSettings(current: NotificationSettings, update: Partial<NotificationSettings>): NotificationSettings;
|
|
487
|
+
/** One settings change, computed from the settings it applies to. */
|
|
488
|
+
type NotificationSettingsUpdate = (current: NotificationSettings) => Partial<NotificationSettings>;
|
|
489
|
+
/**
|
|
490
|
+
* The settings once the persisted ones finish loading: every change made
|
|
491
|
+
* before the load resolved, replayed in order on top of what was persisted
|
|
492
|
+
* (or the defaults when nothing was). Without this the late load overwrote
|
|
493
|
+
* those changes, e.g. a chain muted during the first render came back.
|
|
494
|
+
*/
|
|
495
|
+
declare function replayNotificationSettings(persisted: NotificationSettings | null, updates: readonly NotificationSettingsUpdate[]): NotificationSettings;
|
|
487
496
|
declare function channelsUpdate(channels: string[]): Partial<NotificationSettings>;
|
|
488
497
|
declare function mutedChainSettings(settings: NotificationSettings, chainId: string, muted: boolean): Partial<NotificationSettings>;
|
|
489
498
|
declare function createNotification(item: Omit<NotificationItem, "id" | "timestamp">): NotificationItem;
|
|
@@ -609,7 +618,7 @@ type ExecuteRoute = (quote: ExecutableQuote, recipient: string, options?: Execut
|
|
|
609
618
|
* a valid non-EVM address on a guess.
|
|
610
619
|
*/
|
|
611
620
|
declare function validateRouteRecipient(quote: ExecutableQuote | null | undefined, recipient: string): ExecuteRouteError | null;
|
|
612
|
-
/**
|
|
621
|
+
/** Normalize whatever an executor threw into the hook's error shape. */
|
|
613
622
|
declare function toExecuteRouteError(cause: unknown): ExecuteRouteError;
|
|
614
623
|
|
|
615
624
|
/** The subset of the config that changes what a key may spend or how it is sealed. */
|
|
@@ -845,6 +854,62 @@ interface DelegationFrameworkAdapterOptions {
|
|
|
845
854
|
}
|
|
846
855
|
declare function createDelegationFrameworkAdapter(options: DelegationFrameworkAdapterOptions): PolicyExecutionAdapter;
|
|
847
856
|
|
|
857
|
+
type AssetId = string;
|
|
858
|
+
interface AuthorizationAssetMetadata {
|
|
859
|
+
symbol: string;
|
|
860
|
+
decimals: number;
|
|
861
|
+
}
|
|
862
|
+
interface DescribeAuthorizationOptions {
|
|
863
|
+
assets?: Record<AssetId, AuthorizationAssetMetadata>;
|
|
864
|
+
locale?: string;
|
|
865
|
+
/** Unix timestamp in seconds. */
|
|
866
|
+
now?: number;
|
|
867
|
+
}
|
|
868
|
+
interface AuthorizationRecipientView {
|
|
869
|
+
shortened: string;
|
|
870
|
+
full: string;
|
|
871
|
+
}
|
|
872
|
+
interface AuthorizationAmountView {
|
|
873
|
+
formatted: string;
|
|
874
|
+
}
|
|
875
|
+
interface AuthorizationGrantView {
|
|
876
|
+
asset: AssetId;
|
|
877
|
+
assetLabel: string;
|
|
878
|
+
recipients: AuthorizationRecipientView[];
|
|
879
|
+
perPayment: AuthorizationAmountView;
|
|
880
|
+
total: AuthorizationAmountView;
|
|
881
|
+
count: number | null;
|
|
882
|
+
rails: string[];
|
|
883
|
+
}
|
|
884
|
+
interface AuthorizationExpiryView {
|
|
885
|
+
timestamp: number;
|
|
886
|
+
absolute: string;
|
|
887
|
+
relative: string;
|
|
888
|
+
}
|
|
889
|
+
interface AuthorizationDescription {
|
|
890
|
+
label: string | null;
|
|
891
|
+
principal: string | null;
|
|
892
|
+
grants: AuthorizationGrantView[];
|
|
893
|
+
expiry: AuthorizationExpiryView;
|
|
894
|
+
warnings: string[];
|
|
895
|
+
}
|
|
896
|
+
declare function formatAuthorizationAmount(amount: bigint, metadata: AuthorizationAssetMetadata | undefined): AuthorizationAmountView;
|
|
897
|
+
/** Build a network-free consent/listing view of an authorization. */
|
|
898
|
+
declare function describeAuthorization(input: Authorization | ListedAuthorization, options?: DescribeAuthorizationOptions): AuthorizationDescription;
|
|
899
|
+
type SpendExplanation = {
|
|
900
|
+
allowed: true;
|
|
901
|
+
grant: number;
|
|
902
|
+
remainingTotal: bigint;
|
|
903
|
+
remainingTotalFormatted: AuthorizationAmountView;
|
|
904
|
+
sentence: string;
|
|
905
|
+
} | {
|
|
906
|
+
allowed: false;
|
|
907
|
+
reason: SpendRefusal;
|
|
908
|
+
sentence: string;
|
|
909
|
+
};
|
|
910
|
+
/** Explain the shared evaluator's exact allow/refuse result for a UI. */
|
|
911
|
+
declare function explainSpend(authorization: Authorization, request: SpendRequest, options?: DescribeAuthorizationOptions): SpendExplanation;
|
|
912
|
+
|
|
848
913
|
/**
|
|
849
914
|
* Agentic payments (x402 / MPP) for the appkit shells.
|
|
850
915
|
*
|
|
@@ -852,7 +917,7 @@ declare function createDelegationFrameworkAdapter(options: DelegationFrameworkAd
|
|
|
852
917
|
* `@naculus/payments-x402` or `createMppFetch` from `@naculus/payments-mpp`,
|
|
853
918
|
* with the session key and limits it chooses — and the hooks only track its
|
|
854
919
|
* state. So appkit takes no dependency on either package: their results are
|
|
855
|
-
* read here by shape, and a shape this does not
|
|
920
|
+
* read here by shape, and a shape this does not recognize is reported as
|
|
856
921
|
* `protocol: "unknown"` rather than guessed at.
|
|
857
922
|
*/
|
|
858
923
|
/** What `createX402Fetch` and `createMppFetch` return, structurally. */
|
|
@@ -866,6 +931,11 @@ interface PaymentFetchResult {
|
|
|
866
931
|
receipt?: unknown;
|
|
867
932
|
}
|
|
868
933
|
type PaymentFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<PaymentFetchResult>;
|
|
934
|
+
type PaymentVerificationStatus = "unverified" | "pending" | "verified" | "mismatch" | "failed" | "unavailable";
|
|
935
|
+
interface PaymentVerification {
|
|
936
|
+
status: PaymentVerificationStatus;
|
|
937
|
+
reason?: string;
|
|
938
|
+
}
|
|
869
939
|
/** One payment, in the terms a UI shows. Amounts are token base units. */
|
|
870
940
|
interface PaymentRecord {
|
|
871
941
|
protocol: "x402" | "mpp" | "unknown";
|
|
@@ -882,7 +952,19 @@ interface PaymentRecord {
|
|
|
882
952
|
* other fields are what the client signed.
|
|
883
953
|
*/
|
|
884
954
|
reference: string | null;
|
|
955
|
+
/** A server-reported reference remains unverified until this is verified. */
|
|
956
|
+
verification: PaymentVerification;
|
|
957
|
+
}
|
|
958
|
+
declare const DEFAULT_VERIFY_RETRY: {
|
|
959
|
+
readonly attempts: 5;
|
|
960
|
+
readonly delayMs: 4000;
|
|
961
|
+
};
|
|
962
|
+
interface VerifyRetryOptions {
|
|
963
|
+
attempts: number;
|
|
964
|
+
delayMs: number;
|
|
885
965
|
}
|
|
966
|
+
/** Apply a verifier result without mutating the payment record. */
|
|
967
|
+
declare function applySettlementVerification(payment: PaymentRecord, result: SettlementVerification): PaymentRecord;
|
|
886
968
|
/**
|
|
887
969
|
* The payment a paying fetch made, or null when it paid nothing. Reads the
|
|
888
970
|
* x402 requirement / settlement (EVM or Solana) or the MPP `evm` / `solana`
|
|
@@ -890,6 +972,60 @@ interface PaymentRecord {
|
|
|
890
972
|
*/
|
|
891
973
|
declare function describePayment(input: RequestInfo | URL, result: PaymentFetchResult): PaymentRecord | null;
|
|
892
974
|
|
|
975
|
+
/** Request options accepted by a caller-built MPP session fetch. */
|
|
976
|
+
interface MppSessionRequestInit extends RequestInit {
|
|
977
|
+
units?: bigint;
|
|
978
|
+
}
|
|
979
|
+
/** An open MPP payment channel, represented without depending on payments-mpp. */
|
|
980
|
+
interface MppSessionChannel {
|
|
981
|
+
channelId: string;
|
|
982
|
+
payer: string;
|
|
983
|
+
payee: string;
|
|
984
|
+
mint: string;
|
|
985
|
+
channelProgram: string;
|
|
986
|
+
deposit: bigint;
|
|
987
|
+
gracePeriodSeconds: number;
|
|
988
|
+
openSlot: bigint;
|
|
989
|
+
salt: bigint;
|
|
990
|
+
}
|
|
991
|
+
/** A successful MPP receipt, represented structurally. */
|
|
992
|
+
interface MppSessionReceipt {
|
|
993
|
+
status: "success";
|
|
994
|
+
method: string;
|
|
995
|
+
timestamp: string;
|
|
996
|
+
reference: string;
|
|
997
|
+
[field: string]: unknown;
|
|
998
|
+
}
|
|
999
|
+
interface MppSessionFetchResult {
|
|
1000
|
+
response: Response;
|
|
1001
|
+
receipt: unknown;
|
|
1002
|
+
channel: unknown;
|
|
1003
|
+
}
|
|
1004
|
+
type MppSessionRequest = (input: RequestInfo | URL, init?: MppSessionRequestInit) => Promise<MppSessionFetchResult>;
|
|
1005
|
+
interface MppSessionForceCloseResult {
|
|
1006
|
+
requestCloseTxHash: string;
|
|
1007
|
+
withdrawPayer(): Promise<string>;
|
|
1008
|
+
}
|
|
1009
|
+
interface MppSessionMeter {
|
|
1010
|
+
add(units: bigint): void;
|
|
1011
|
+
readonly pending: bigint;
|
|
1012
|
+
}
|
|
1013
|
+
/** The caller-owned session surface consumed by the React and Vue shells. */
|
|
1014
|
+
interface MppSessionFetch extends MppSessionRequest {
|
|
1015
|
+
readonly meter: MppSessionMeter;
|
|
1016
|
+
readonly channels: readonly unknown[];
|
|
1017
|
+
close(): Promise<MppSessionFetchResult>;
|
|
1018
|
+
forceClose(): Promise<MppSessionForceCloseResult>;
|
|
1019
|
+
}
|
|
1020
|
+
/** Return a channel only when all public fields have the expected shape. */
|
|
1021
|
+
declare function readMppSessionChannel(value: unknown): MppSessionChannel | null;
|
|
1022
|
+
/** Return the newest structurally valid channel currently held by a session. */
|
|
1023
|
+
declare function readCurrentMppSessionChannel(session: Pick<MppSessionFetch, "channels">): MppSessionChannel | null;
|
|
1024
|
+
/** Return a receipt only when it has the public success-receipt shape. */
|
|
1025
|
+
declare function readMppSessionReceipt(value: unknown): MppSessionReceipt | null;
|
|
1026
|
+
/** A post-send channel-open failure carries the channel that can be recovered. */
|
|
1027
|
+
declare function readMppRecoveryChannelId(error: unknown): string | null;
|
|
1028
|
+
|
|
893
1029
|
/**
|
|
894
1030
|
* Solana session keys for the appkit shells (connect-lib STATE thread 18).
|
|
895
1031
|
*
|
|
@@ -1016,4 +1152,4 @@ declare function siwxResultToSession<M extends SiwxMessageLike>(result: SiwxResu
|
|
|
1016
1152
|
refreshedAt: null;
|
|
1017
1153
|
};
|
|
1018
1154
|
|
|
1019
|
-
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 DelegationFrameworkAdapterOptions, type DelegationPolicyDeps, type DelegationPolicyFlow, type DelegationPolicyPreview, type DelegationTypedData, type DestinationIssue, type DestinationValidation, type ExecutableQuote, type ExecuteRoute, type ExecuteRouteError, type ExecuteRouteOptions, type ExecuteRouteResult, type GetRouteQuotes, InvalidUserOperationReceiptError, NOTIFICATION_SETTINGS_KEY, type NotificationSettingsStorage, type PaymentFetch, type PaymentFetchResult, type PaymentRecord, 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 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, createDelegationFrameworkAdapter, createDelegationPolicyFlow, createNotification, createNotificationSettingsStorage, createSolanaSessionKeyFlow, decodeRevertReason, defaultSiwxDomain, defaultSiwxUri, describeChain, describePayment, 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 };
|
|
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 };
|