@reown/appkit-controllers 1.8.21 → 1.8.22-coinbase-4100-provider-reauth.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/esm/exports/index.js +2 -0
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/exports/react.js +1 -0
- package/dist/esm/exports/react.js.map +1 -1
- package/dist/esm/src/utils/HeadlessWalletUtil.js +164 -0
- package/dist/esm/src/utils/HeadlessWalletUtil.js.map +1 -0
- package/dist/esm/src/utils/ProviderReauthUtil.js +149 -0
- package/dist/esm/src/utils/ProviderReauthUtil.js.map +1 -0
- package/dist/esm/tests/utils/HeadlessWalletUtil.test.js +226 -0
- package/dist/esm/tests/utils/HeadlessWalletUtil.test.js.map +1 -0
- package/dist/esm/tests/utils/ProviderReauthUtil.test.js +213 -0
- package/dist/esm/tests/utils/ProviderReauthUtil.test.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/types/exports/index.d.ts +3 -0
- package/dist/types/exports/react.d.ts +3 -27
- package/dist/types/src/utils/HeadlessWalletUtil.d.ts +112 -0
- package/dist/types/src/utils/ProviderReauthUtil.d.ts +45 -0
- package/dist/types/tests/utils/HeadlessWalletUtil.test.d.ts +1 -0
- package/dist/types/tests/utils/ProviderReauthUtil.test.d.ts +1 -0
- package/package.json +3 -3
|
@@ -6,6 +6,7 @@ export { ChainController } from '../src/controllers/ChainController.js';
|
|
|
6
6
|
export type { ChainControllerState, AccountState } from '../src/controllers/ChainController.js';
|
|
7
7
|
export { ProviderController } from '../src/controllers/ProviderController.js';
|
|
8
8
|
export type { ProviderControllerState } from '../src/controllers/ProviderController.js';
|
|
9
|
+
export { isCoinbaseConnectorId, isUnauthorizedProviderError, maybeWrapCoinbaseProvider, withCoinbaseReauth } from '../src/utils/ProviderReauthUtil.js';
|
|
9
10
|
export { OnRampController } from '../src/controllers/OnRampController.js';
|
|
10
11
|
export type { OnRampControllerState, OnRampProvider } from '../src/controllers/OnRampController.js';
|
|
11
12
|
export { AdapterController } from '../src/controllers/AdapterController/index.js';
|
|
@@ -73,5 +74,7 @@ export { MobileWalletUtil } from '../src/utils/MobileWallet.js';
|
|
|
73
74
|
export type * from '../src/utils/TypeUtil.js';
|
|
74
75
|
export type * from '../src/utils/SIWXUtil.js';
|
|
75
76
|
export type { WalletItem } from '../src/utils/ConnectUtil.js';
|
|
77
|
+
export { HeadlessWalletUtil } from '../src/utils/HeadlessWalletUtil.js';
|
|
78
|
+
export type { ConnectOptions, FetchWalletsOptions, WalletConnectUriSnapshot, WalletListSnapshot } from '../src/utils/HeadlessWalletUtil.js';
|
|
76
79
|
export * from '../src/utils/ChainControllerUtil.js';
|
|
77
80
|
export * from '../src/utils/WalletConnectUtil.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type CaipNetwork, type ChainNamespace, type Connection } from '@reown/appkit-common';
|
|
2
2
|
import { type WalletItem } from '../src/utils/ConnectUtil.js';
|
|
3
|
-
import
|
|
3
|
+
import { type ConnectOptions, type FetchWalletsOptions } from '../src/utils/HeadlessWalletUtil.js';
|
|
4
|
+
import type { UseAppKitAccountReturn, UseAppKitNetworkReturn } from '../src/utils/TypeUtil.js';
|
|
4
5
|
export type { Connection } from '@reown/appkit-common';
|
|
5
6
|
interface DisconnectParams {
|
|
6
7
|
id?: string;
|
|
@@ -25,9 +26,7 @@ interface DeleteRecentConnectionProps {
|
|
|
25
26
|
address: string;
|
|
26
27
|
connectorId: string;
|
|
27
28
|
}
|
|
28
|
-
export
|
|
29
|
-
wcPayUrl?: string;
|
|
30
|
-
}
|
|
29
|
+
export type { ConnectOptions, FetchWalletsOptions } from '../src/utils/HeadlessWalletUtil.js';
|
|
31
30
|
export declare function useAppKitProvider<T>(chainNamespace: ChainNamespace): {
|
|
32
31
|
walletProvider: T;
|
|
33
32
|
walletProviderType: import("./index.js").ConnectorType | undefined;
|
|
@@ -81,29 +80,6 @@ export declare function useAppKitConnection({ namespace, onSuccess, onError }: U
|
|
|
81
80
|
switchConnection: ({ connection: _connection, address }: SwitchConnectionParams) => Promise<void>;
|
|
82
81
|
deleteConnection: ({ address, connectorId }: DeleteRecentConnectionProps) => void;
|
|
83
82
|
};
|
|
84
|
-
export interface FetchWalletsOptions {
|
|
85
|
-
/** Page number to fetch (default: 1) */
|
|
86
|
-
page?: number;
|
|
87
|
-
/** @deprecated Use `search` instead */
|
|
88
|
-
query?: string;
|
|
89
|
-
/** Search query to filter wallets. When provided, switches to search mode. */
|
|
90
|
-
search?: string;
|
|
91
|
-
/** Number of entries per page. Defaults to 40 for list mode, 100 for search mode. */
|
|
92
|
-
entries?: number;
|
|
93
|
-
/** Filter wallets by badge type ('none' | 'certified') */
|
|
94
|
-
badge?: BadgeType;
|
|
95
|
-
/** Wallet IDs to include. Overrides the global includeWalletIds config when provided. */
|
|
96
|
-
include?: string[];
|
|
97
|
-
/** Wallet IDs to exclude. Overrides the default exclude list when provided. */
|
|
98
|
-
exclude?: string[];
|
|
99
|
-
/**
|
|
100
|
-
* Include wallets that support WalletConnect Pay but are not v2-compatible.
|
|
101
|
-
* By default these are filtered out. Enable for WalletConnect Pay surfaces.
|
|
102
|
-
*/
|
|
103
|
-
includePayOnly?: boolean;
|
|
104
|
-
/** Sort mode. 'wcpay' bubbles WalletConnect Pay-supporting wallets to the top. */
|
|
105
|
-
sort?: 'default' | 'wcpay';
|
|
106
|
-
}
|
|
107
83
|
export interface UseAppKitWalletsReturn {
|
|
108
84
|
/**
|
|
109
85
|
* List of wallets for the initial connect view including WalletConnect wallet and injected wallets together. If user doesn't have any injected wallets, it'll fill the list with most ranked WalletConnect wallets.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { ChainNamespace } from '@reown/appkit-common';
|
|
2
|
+
import { type WalletItem } from './ConnectUtil.js';
|
|
3
|
+
/** Options for {@link HeadlessWalletUtil.fetchWallets}. */
|
|
4
|
+
export interface FetchWalletsOptions {
|
|
5
|
+
/** Page number to fetch (default: 1) */
|
|
6
|
+
page?: number;
|
|
7
|
+
/** @deprecated Use `search` instead */
|
|
8
|
+
query?: string;
|
|
9
|
+
/** Search query to filter wallets. When provided, switches to search mode. */
|
|
10
|
+
search?: string;
|
|
11
|
+
/** Number of entries per page. Defaults to 40 for list mode, 100 for search mode. */
|
|
12
|
+
entries?: number;
|
|
13
|
+
/** Filter wallets by badge type ('none' | 'certified') */
|
|
14
|
+
badge?: 'none' | 'certified';
|
|
15
|
+
/** Wallet IDs to include. Overrides the global includeWalletIds config when provided. */
|
|
16
|
+
include?: string[];
|
|
17
|
+
/** Wallet IDs to exclude. Overrides the default exclude list when provided. */
|
|
18
|
+
exclude?: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Include wallets that support WalletConnect Pay but are not v2-compatible.
|
|
21
|
+
* By default these are filtered out. Enable for WalletConnect Pay surfaces.
|
|
22
|
+
*/
|
|
23
|
+
includePayOnly?: boolean;
|
|
24
|
+
/** Sort mode. 'wcpay' bubbles WalletConnect Pay-supporting wallets to the top. */
|
|
25
|
+
sort?: 'default' | 'wcpay';
|
|
26
|
+
}
|
|
27
|
+
/** Options for {@link HeadlessWalletUtil.connect} / {@link HeadlessWalletUtil.prefetchWalletConnectUri}. */
|
|
28
|
+
export interface ConnectOptions {
|
|
29
|
+
/**
|
|
30
|
+
* A WalletConnect Pay deeplink appended to the WC URI, so a WCPay-capable wallet
|
|
31
|
+
* returns to — and processes — this payment after pairing.
|
|
32
|
+
*/
|
|
33
|
+
wcPayUrl?: string;
|
|
34
|
+
}
|
|
35
|
+
/** The headless wallet list, read imperatively. */
|
|
36
|
+
export interface WalletListSnapshot {
|
|
37
|
+
/** Initial connect-view wallets: installed extensions + top-ranked WalletConnect wallets. */
|
|
38
|
+
wallets: WalletItem[];
|
|
39
|
+
/** The full WalletGuide WalletConnect list (with the current search results applied). */
|
|
40
|
+
wcWallets: WalletItem[];
|
|
41
|
+
/** Current page of the WalletConnect list. */
|
|
42
|
+
page: number;
|
|
43
|
+
/** Total number of available WalletConnect wallets for the current parameters. */
|
|
44
|
+
count: number;
|
|
45
|
+
}
|
|
46
|
+
/** The WalletConnect URI + connection-attempt signals, read imperatively. */
|
|
47
|
+
export interface WalletConnectUriSnapshot {
|
|
48
|
+
/** Active WalletConnect pairing URI (for rendering a QR / deeplink), or undefined when none. */
|
|
49
|
+
wcUri: string | undefined;
|
|
50
|
+
/** Whether the last WalletConnect URI fetch / connection attempt errored. */
|
|
51
|
+
wcError: boolean;
|
|
52
|
+
/** Whether a WalletConnect URI is currently being fetched. */
|
|
53
|
+
wcFetchingUri: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Framework-agnostic headless wallet-list logic — the imperative core behind the
|
|
57
|
+
* `useAppKitWallets` React hook and the `AppKit` client's wallet methods.
|
|
58
|
+
*
|
|
59
|
+
* AppKit runs headless (no modal): the host renders its own picker and connects a
|
|
60
|
+
* chosen wallet programmatically. That orchestration (list / search / paginate the
|
|
61
|
+
* WalletGuide wallets, fetch the WalletConnect URI, and connect injected / API / mobile
|
|
62
|
+
* wallets) lived only inside the React hook; lifting it here lets a non-React host
|
|
63
|
+
* (e.g. `@walletconnect/pay-appkit`) drive the same flow through `appKit.*` methods,
|
|
64
|
+
* with the hook and the client sharing one tested code path.
|
|
65
|
+
*
|
|
66
|
+
* Reads/writes the global controllers directly (valtio singletons), so it takes no
|
|
67
|
+
* AppKit instance — exactly like {@link ConnectionControllerUtil}.
|
|
68
|
+
*/
|
|
69
|
+
export declare const HeadlessWalletUtil: {
|
|
70
|
+
/**
|
|
71
|
+
* Fetch / search / paginate the WalletConnect wallet list from the explorer API.
|
|
72
|
+
* With a `search` (or the deprecated `query`), switches to search mode; otherwise
|
|
73
|
+
* lists/paginates. Reads results from `ApiController.state` (see {@link getWalletList}).
|
|
74
|
+
*/
|
|
75
|
+
fetchWallets(fetchOptions?: FetchWalletsOptions): Promise<void>;
|
|
76
|
+
/** Read the current wallet list (initial view + WalletConnect list + pagination). */
|
|
77
|
+
getWalletList(): WalletListSnapshot;
|
|
78
|
+
/** Subscribe to wallet-list changes (the WalletGuide list + search results). */
|
|
79
|
+
subscribeWalletList(callback: () => void): () => void;
|
|
80
|
+
/**
|
|
81
|
+
* Pre-fetch the WalletConnect URI. Read the result with {@link getWalletConnectUri};
|
|
82
|
+
* subscribe with {@link subscribeWalletConnectUri}. Call when a wallet is selected so a
|
|
83
|
+
* later connect can deeplink synchronously (required for iOS Safari) or render a QR. Uses
|
|
84
|
+
* 'auto' cache to reuse a valid URI or fetch a new one.
|
|
85
|
+
*/
|
|
86
|
+
prefetchWalletConnectUri(_options?: ConnectOptions): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Read the current WalletConnect URI state (the QR / deeplink URI plus the fetch/error
|
|
89
|
+
* signals) — the symmetric read for {@link prefetchWalletConnectUri}. Reads
|
|
90
|
+
* `ConnectionController` directly, so a headless host gets it ungated through the AppKit
|
|
91
|
+
* instance without importing the controllers package.
|
|
92
|
+
*/
|
|
93
|
+
getWalletConnectUri(): WalletConnectUriSnapshot;
|
|
94
|
+
/**
|
|
95
|
+
* Subscribe to WalletConnect URI state changes (wcUri / wcError / wcFetchingUri). The
|
|
96
|
+
* callback receives no arguments — read the current values with {@link getWalletConnectUri}.
|
|
97
|
+
* Returns an unsubscribe.
|
|
98
|
+
*/
|
|
99
|
+
subscribeWalletConnectUri(callback: () => void): () => void;
|
|
100
|
+
/**
|
|
101
|
+
* Connect a chosen wallet programmatically (headless — no modal).
|
|
102
|
+
*
|
|
103
|
+
* Handles injected wallets, API wallets (from the "all wallets" list), and mobile
|
|
104
|
+
* deeplinks. For API wallets without pre-populated connectors, falls back to a lookup
|
|
105
|
+
* by the wallet's ID via `explorerId` matching (e.g. Coinbase/Base from "all wallets").
|
|
106
|
+
*/
|
|
107
|
+
connect(wallet: WalletItem, namespace?: ChainNamespace, options?: ConnectOptions): Promise<void>;
|
|
108
|
+
/** Reset the WalletConnect URI + linking state (e.g. when a QR is closed). */
|
|
109
|
+
resetWcUri(): void;
|
|
110
|
+
/** Clear the `connectingWallet` state. */
|
|
111
|
+
resetConnectingWallet(): void;
|
|
112
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ChainNamespace } from '@reown/appkit-common';
|
|
2
|
+
/**
|
|
3
|
+
* True when `connectorId` is a Coinbase connector.
|
|
4
|
+
*
|
|
5
|
+
* The connector id (not the provider "type") is the reliable signal: it is a
|
|
6
|
+
* stable `'coinbaseWallet'` / `'coinbaseWalletSDK'` across every adapter and
|
|
7
|
+
* registration path, whereas the provider type is remapped to `'EXTERNAL'` by
|
|
8
|
+
* `PresetsUtil.ConnectorTypesMap` on most paths. Matched case-insensitively by
|
|
9
|
+
* substring to also tolerate the wagmi restore path's uppercased
|
|
10
|
+
* `connector.type` (`'COINBASEWALLET'`).
|
|
11
|
+
*/
|
|
12
|
+
export declare function isCoinbaseConnectorId(connectorId: string | undefined): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* EIP-1193 `4100` unauthorized error, matched by code or by the SDK's
|
|
15
|
+
* `eth_requestAccounts` wording, walking the `cause` chain (viem/provider
|
|
16
|
+
* wrappers nest the original error) with bounded depth.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isUnauthorizedProviderError(err: unknown, depth?: number): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Wrap a Coinbase provider so any signing RPC that fails with `4100` triggers a
|
|
21
|
+
* one-shot recovery: a single `eth_requestAccounts` re-authorization, an active-
|
|
22
|
+
* chain re-assert for state-changing calls, then exactly one retry.
|
|
23
|
+
*
|
|
24
|
+
* - Non-`4100` failures pass through untouched (no re-auth attempt).
|
|
25
|
+
* - A rejected re-auth prompt propagates and classifies as a user rejection.
|
|
26
|
+
* - A still-unauthorized retry fails once (no loop) — the recovery calls the raw
|
|
27
|
+
* provider, never the wrapper, so it cannot recurse.
|
|
28
|
+
*
|
|
29
|
+
* Non-`request` members are delegated to the raw provider bound to the raw
|
|
30
|
+
* instance, so private class fields and EIP-1193 event emitters keep working.
|
|
31
|
+
* The wrapper is cached per raw instance so repeated `setProvider` calls with
|
|
32
|
+
* the same provider return a stable reference (no consumer identity churn).
|
|
33
|
+
*/
|
|
34
|
+
export declare function withCoinbaseReauth<T extends object>(provider: T): T;
|
|
35
|
+
/**
|
|
36
|
+
* Apply {@link withCoinbaseReauth} to an eip155 Coinbase provider, returning
|
|
37
|
+
* every other provider untouched. This is the single decision the provider
|
|
38
|
+
* registration seam (`syncProvider`) needs — keeping the guard here (keyed on
|
|
39
|
+
* the reliable connector id) rather than in the state setter.
|
|
40
|
+
*/
|
|
41
|
+
export declare function maybeWrapCoinbaseProvider<T>(params: {
|
|
42
|
+
connectorId: string | undefined;
|
|
43
|
+
chainNamespace: ChainNamespace | undefined;
|
|
44
|
+
provider: T;
|
|
45
|
+
}): T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reown/appkit-controllers",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.22-coinbase-4100-provider-reauth.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/esm/exports/index.js",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"@walletconnect/universal-provider": "2.23.7",
|
|
57
57
|
"valtio": "2.1.7",
|
|
58
58
|
"viem": ">=2.45.0",
|
|
59
|
-
"@reown/appkit-common": "1.8.
|
|
60
|
-
"@reown/appkit-wallet": "1.8.
|
|
59
|
+
"@reown/appkit-common": "1.8.22-coinbase-4100-provider-reauth.0",
|
|
60
|
+
"@reown/appkit-wallet": "1.8.22-coinbase-4100-provider-reauth.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@vitest/coverage-v8": "2.1.9",
|