@tezos-x/octez.connect-dapp 4.8.3 → 4.8.5
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 +55 -7
- package/dist/cjs/beacon-message-events.js.map +1 -1
- package/dist/cjs/dapp-client/DAppClient.d.ts +114 -6
- package/dist/cjs/dapp-client/DAppClient.js +986 -392
- package/dist/cjs/dapp-client/DAppClient.js.map +1 -1
- package/dist/cjs/dapp-client/DAppClientOptions.d.ts +17 -0
- package/dist/cjs/dapp-client/DAppClientOptions.js.map +1 -1
- package/dist/cjs/events.d.ts +29 -3
- package/dist/cjs/events.js +41 -37
- package/dist/cjs/events.js.map +1 -1
- package/dist/cjs/index.d.ts +4 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/transports/DappP2PTransport.d.ts +1 -1
- package/dist/cjs/transports/DappP2PTransport.js.map +1 -1
- package/dist/cjs/transports/DappPostMessageTransport.d.ts +1 -1
- package/dist/cjs/transports/DappPostMessageTransport.js.map +1 -1
- package/dist/cjs/transports/DappWalletConnectTransport.d.ts +1 -1
- package/dist/cjs/transports/DappWalletConnectTransport.js.map +1 -1
- package/dist/cjs/utils/available-transports.js.map +1 -1
- package/dist/cjs/utils/block-explorer.d.ts +2 -2
- package/dist/cjs/utils/block-explorer.js +5 -1
- package/dist/cjs/utils/block-explorer.js.map +1 -1
- package/dist/cjs/utils/get-instance.js +7 -1
- package/dist/cjs/utils/get-instance.js.map +1 -1
- package/dist/cjs/utils/shorten-string.js.map +1 -1
- package/dist/cjs/utils/tzkt-blockexplorer.d.ts +2 -2
- package/dist/cjs/utils/tzkt-blockexplorer.js +3 -17
- package/dist/cjs/utils/tzkt-blockexplorer.js.map +1 -1
- package/dist/esm/beacon-message-events.js.map +1 -1
- package/dist/esm/dapp-client/DAppClient.d.ts +114 -6
- package/dist/esm/dapp-client/DAppClient.js +991 -386
- package/dist/esm/dapp-client/DAppClient.js.map +1 -1
- package/dist/esm/dapp-client/DAppClientOptions.d.ts +17 -0
- package/dist/esm/dapp-client/DAppClientOptions.js.map +1 -1
- package/dist/esm/events.d.ts +29 -3
- package/dist/esm/events.js +6 -3
- package/dist/esm/events.js.map +1 -1
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/transports/DappP2PTransport.d.ts +1 -1
- package/dist/esm/transports/DappP2PTransport.js.map +1 -1
- package/dist/esm/transports/DappPostMessageTransport.d.ts +1 -1
- package/dist/esm/transports/DappPostMessageTransport.js.map +1 -1
- package/dist/esm/transports/DappWalletConnectTransport.d.ts +1 -1
- package/dist/esm/transports/DappWalletConnectTransport.js.map +1 -1
- package/dist/esm/utils/available-transports.js.map +1 -1
- package/dist/esm/utils/block-explorer.d.ts +2 -2
- package/dist/esm/utils/block-explorer.js +5 -1
- package/dist/esm/utils/block-explorer.js.map +1 -1
- package/dist/esm/utils/get-instance.js +7 -1
- package/dist/esm/utils/get-instance.js.map +1 -1
- package/dist/esm/utils/shorten-string.js.map +1 -1
- package/dist/esm/utils/tzkt-blockexplorer.d.ts +2 -2
- package/dist/esm/utils/tzkt-blockexplorer.js +3 -17
- package/dist/esm/utils/tzkt-blockexplorer.js.map +1 -1
- package/dist/octez.connect.dapp.min.js +1 -1066
- package/package.json +17 -13
- package/LICENCE +0 -19
- package/dist/walletbeacon.dapp.min.js +0 -1066
package/README.md
CHANGED
|
@@ -1,16 +1,64 @@
|
|
|
1
1
|
# `@tezos-x/octez.connect-dapp`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
octez.connect dApp client for connecting Tezos dApps to wallets.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This is a primary package in the Trilitech-maintained octez.connect SDK line and may be installed directly.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Usage
|
|
7
|
+
## Install
|
|
10
8
|
|
|
9
|
+
```sh
|
|
10
|
+
npm install @tezos-x/octez.connect-dapp
|
|
11
11
|
```
|
|
12
|
-
|
|
12
|
+
## Package provenance
|
|
13
|
+
|
|
14
|
+
This package is published from the Trilitech-maintained octez.connect repository:
|
|
15
|
+
[trilitech/octez.connect](https://github.com/trilitech/octez.connect)
|
|
16
|
+
|
|
17
|
+
- Original Beacon lineage: [airgap-it/beacon-sdk](https://github.com/airgap-it/beacon-sdk)
|
|
18
|
+
- External maintenance line Trilitech may selectively import from: [ecadlabs/beacon-sdk-taquito-patches](https://github.com/ecadlabs/beacon-sdk-taquito-patches)
|
|
19
|
+
|
|
20
|
+
## Notes
|
|
21
|
+
|
|
22
|
+
- Trilitech publishes these packages under the `@tezos-x/octez.connect-*` scope
|
|
23
|
+
- Release notes, package policy, and the current package list live in the repository README
|
|
24
|
+
|
|
25
|
+
## Restoring persisted dApp sessions
|
|
13
26
|
|
|
14
|
-
|
|
27
|
+
Applications should restore Beacon connection state from the SDK, for example by
|
|
28
|
+
calling `client.getActiveAccount()`, instead of relying only on app-local markers
|
|
29
|
+
such as `wallet-provider=beacon`.
|
|
30
|
+
|
|
31
|
+
Treat a missing `beacon:active-account` storage entry as disconnected. Do not use
|
|
32
|
+
checks like `localStorage.getItem('beacon:active-account') !== 'undefined'` as a
|
|
33
|
+
valid restore guard, because `null` and corrupt stored state are not valid active
|
|
34
|
+
accounts.
|
|
35
|
+
|
|
36
|
+
When Beacon deactivates invalid stored active-account state, it emits
|
|
37
|
+
`BeaconEvent.INVALID_ACCOUNT_DEACTIVATED` with this payload:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
{
|
|
41
|
+
reason:
|
|
42
|
+
| 'missing_active_account'
|
|
43
|
+
| 'invalid_active_account_storage'
|
|
44
|
+
| 'storage_validation_failed'
|
|
45
|
+
}
|
|
15
46
|
```
|
|
16
47
|
|
|
48
|
+
For backward compatibility, event handler types still allow this event data to
|
|
49
|
+
be `undefined`. Beacon's invalid active-account deactivation path emits the
|
|
50
|
+
object above; consumers that inspect the reason should handle an absent payload
|
|
51
|
+
defensively if they also support direct event emission or older Beacon versions.
|
|
52
|
+
|
|
53
|
+
Reason meanings:
|
|
54
|
+
|
|
55
|
+
- `missing_active_account`: `beacon:active-account` pointed at an account
|
|
56
|
+
identifier that was not present in Beacon's persisted account list.
|
|
57
|
+
- `invalid_active_account_storage`: Beacon could not read or parse the persisted
|
|
58
|
+
active-account/account storage needed to restore the account.
|
|
59
|
+
- `storage_validation_failed`: Beacon restored an active account, but a later
|
|
60
|
+
storage validation pass still found invalid persisted session state.
|
|
61
|
+
|
|
62
|
+
The default UI intentionally keeps a generic "session expired" message for end
|
|
63
|
+
users, while the event payload and debug logs expose the specific restore failure
|
|
64
|
+
reason for applications and diagnostics.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beacon-message-events.js","sourceRoot":"","sources":["../../src/beacon-message-events.ts"],"names":[],"mappings":";;;AAAA,qCAAsC;AACtC,sEAAgE;AAEnD,QAAA,aAAa,GAEtB;IACF,CAAC,uCAAiB,CAAC,iBAAiB,CAAC,EAAE;QACrC,IAAI,EAAE,oBAAW,CAAC,sBAAsB;QACxC,OAAO,EAAE,oBAAW,CAAC,0BAA0B;QAC/C,KAAK,EAAE,oBAAW,CAAC,uBAAuB;KAC3C;IACD,CAAC,uCAAiB,CAAC,kBAAkB,CAAC,EAAE;QACtC,IAAI,EAAE,oBAAW,CAAC,OAAO;QACzB,OAAO,EAAE,oBAAW,CAAC,OAAO;QAC5B,KAAK,EAAE,oBAAW,CAAC,OAAO;KAC3B;IACD,CAAC,uCAAiB,CAAC,iBAAiB,CAAC,EAAE;QACrC,IAAI,EAAE,oBAAW,CAAC,uBAAuB;QACzC,OAAO,EAAE,oBAAW,CAAC,0BAA0B;QAC/C,KAAK,EAAE,oBAAW,CAAC,wBAAwB;KAC5C;IACD,CAAC,uCAAiB,CAAC,kBAAkB,CAAC,EAAE;QACtC,IAAI,EAAE,oBAAW,CAAC,OAAO;QACzB,OAAO,EAAE,oBAAW,CAAC,OAAO;QAC5B,KAAK,EAAE,oBAAW,CAAC,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AE,oBAAW,CAAC,sBAAsB;QACxC,OAAO,EAAE,oBAAW,CAAC,yBAAyB;QAC9C,KAAK,EAAE,oBAAW,CAAC,uBAAuB;KAC3C;IACD,CAAC,uCAAiB,CAAC,iBAAiB,CAAC,EAAE;QACrC,IAAI,EAAE,oBAAW,CAAC,OAAO;QACzB,OAAO,EAAE,oBAAW,CAAC,OAAO;QAC5B,KAAK,EAAE,oBAAW,CAAC,OAAO;KAC3B;IACD,CAAC,uCAAiB,CAAC,oBAAoB,CAAC,EAAE;QACxC,IAAI,EAAE,oBAAW,CAAC,OAAO;QACzB,OAAO,EAAE,oBAAW,CAAC,OAAO;QAC5B,KAAK,EAAE,oBAAW,CAAC,OAAO;KAC3B;IACD,CAAC,uCAAiB,CAAC,WAAW,CAAC,EAAE;QAC/B,IAAI,EAAE,oBAAW,CAAC,OAAO;QACzB,OAAO,EAAE,oBAAW,CAAC,OAAO;QAC5B,KAAK,EAAE,oBAAW,CAAC,OAAO;KAC3B;IACD,CAAC,uCAAiB,CAAC,UAAU,CAAC,EAAE;QAC9B,IAAI,EAAE,oBAAW,CAAC,OAAO;QACzB,OAAO,EAAE,oBAAW,CAAC,OAAO;QAC5B,KAAK,EAAE,oBAAW,CAAC,OAAO;KAC3B;IACD,CAAC,uCAAiB,CAAC,KAAK,CAAC,EAAE;QACzB,IAAI,EAAE,oBAAW,CAAC,OAAO;QACzB,OAAO,EAAE,oBAAW,CAAC,OAAO;QAC5B,KAAK,EAAE,oBAAW,CAAC,OAAO;KAC3B;CACF,CAAA","sourcesContent":["import { BeaconEvent } from './events'\nimport { BeaconMessageType } from '@tezos-x/octez.connect-types'\n\nexport const messageEvents: {\n [key in BeaconMessageType]: { sent: BeaconEvent; success: BeaconEvent; error: BeaconEvent }\n} = {\n [BeaconMessageType.BlockchainRequest]: {\n sent: BeaconEvent.OPERATION_REQUEST_SENT,\n success: BeaconEvent.BLOCKCHAIN_REQUEST_SUCCESS,\n error: BeaconEvent.OPERATION_REQUEST_ERROR\n },\n [BeaconMessageType.BlockchainResponse]: {\n sent: BeaconEvent.UNKNOWN,\n success: BeaconEvent.UNKNOWN,\n error: BeaconEvent.UNKNOWN\n },\n [BeaconMessageType.PermissionRequest]: {\n sent: BeaconEvent.PERMISSION_REQUEST_SENT,\n success: BeaconEvent.PERMISSION_REQUEST_SUCCESS,\n error: BeaconEvent.PERMISSION_REQUEST_ERROR\n },\n [BeaconMessageType.PermissionResponse]: {\n sent: BeaconEvent.UNKNOWN,\n success: BeaconEvent.UNKNOWN,\n error: BeaconEvent.UNKNOWN\n },\n [BeaconMessageType.ProofOfEventChallengeRequest]: {\n sent: BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT,\n success: BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS,\n error: BeaconEvent.PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR\n },\n [BeaconMessageType.ProofOfEventChallengeResponse]: {\n sent: BeaconEvent.UNKNOWN,\n success: BeaconEvent.UNKNOWN,\n error: BeaconEvent.UNKNOWN\n },\n [BeaconMessageType.SimulatedProofOfEventChallengeRequest]: {\n sent: BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SENT,\n success: BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_SUCCESS,\n error: BeaconEvent.SIMULATED_PROOF_OF_EVENT_CHALLENGE_REQUEST_ERROR\n },\n [BeaconMessageType.SimulatedProofOfEventChallengeResponse]: {\n sent: BeaconEvent.UNKNOWN,\n success: BeaconEvent.UNKNOWN,\n error: BeaconEvent.UNKNOWN\n },\n [BeaconMessageType.OperationRequest]: {\n sent: BeaconEvent.OPERATION_REQUEST_SENT,\n success: BeaconEvent.OPERATION_REQUEST_SUCCESS,\n error: BeaconEvent.OPERATION_REQUEST_ERROR\n },\n [BeaconMessageType.OperationResponse]: {\n sent: BeaconEvent.UNKNOWN,\n success: BeaconEvent.UNKNOWN,\n error: BeaconEvent.UNKNOWN\n },\n [BeaconMessageType.SignPayloadRequest]: {\n sent: BeaconEvent.SIGN_REQUEST_SENT,\n success: BeaconEvent.SIGN_REQUEST_SUCCESS,\n error: BeaconEvent.SIGN_REQUEST_ERROR\n },\n [BeaconMessageType.SignPayloadResponse]: {\n sent: BeaconEvent.UNKNOWN,\n success: BeaconEvent.UNKNOWN,\n error: BeaconEvent.UNKNOWN\n },\n // TODO: ENCRYPTION\n // [BeaconMessageType.EncryptPayloadRequest]: {\n // sent: BeaconEvent.ENCRYPT_REQUEST_SENT,\n // success: BeaconEvent.ENCRYPT_REQUEST_SUCCESS,\n // error: BeaconEvent.ENCRYPT_REQUEST_ERROR\n // },\n // [BeaconMessageType.EncryptPayloadResponse]: {\n // sent: BeaconEvent.UNKNOWN,\n // success: BeaconEvent.UNKNOWN,\n // error: BeaconEvent.UNKNOWN\n // },\n [BeaconMessageType.BroadcastRequest]: {\n sent: BeaconEvent.BROADCAST_REQUEST_SENT,\n success: BeaconEvent.BROADCAST_REQUEST_SUCCESS,\n error: BeaconEvent.BROADCAST_REQUEST_ERROR\n },\n [BeaconMessageType.BroadcastResponse]: {\n sent: BeaconEvent.UNKNOWN,\n success: BeaconEvent.UNKNOWN,\n error: BeaconEvent.UNKNOWN\n },\n [BeaconMessageType.ChangeAccountRequest]: {\n sent: BeaconEvent.UNKNOWN,\n success: BeaconEvent.UNKNOWN,\n error: BeaconEvent.UNKNOWN\n },\n [BeaconMessageType.Acknowledge]: {\n sent: BeaconEvent.UNKNOWN,\n success: BeaconEvent.UNKNOWN,\n error: BeaconEvent.UNKNOWN\n },\n [BeaconMessageType.Disconnect]: {\n sent: BeaconEvent.UNKNOWN,\n success: BeaconEvent.UNKNOWN,\n error: BeaconEvent.UNKNOWN\n },\n [BeaconMessageType.Error]: {\n sent: BeaconEvent.UNKNOWN,\n success: BeaconEvent.UNKNOWN,\n error: BeaconEvent.UNKNOWN\n }\n}\n"]}
|
|
@@ -1,12 +1,25 @@
|
|
|
1
|
-
import { BeaconEvent, BeaconEventHandlerFunction, BeaconEventType } from '../events';
|
|
2
1
|
import { AccountInfo, TransportType, BeaconMessageType, RequestPermissionInput, RequestSignPayloadInput, RequestOperationInput, RequestBroadcastInput, PermissionResponseOutput, SignPayloadResponseOutput, OperationResponseOutput, BroadcastResponseOutput, Network, AppMetadata, ExtendedPeerInfo, ColorMode, Blockchain, BlockchainRequestV3, BlockchainResponseV3, PermissionRequestV3, PermissionResponseV3, ProofOfEventChallengeResponse, RequestProofOfEventChallengeInput, PeerInfoType, SimulatedProofOfEventChallengeResponse, RequestSimulatedProofOfEventChallengeInput } from '@tezos-x/octez.connect-types';
|
|
3
2
|
import { Client, Transport } from '@tezos-x/octez.connect-core';
|
|
3
|
+
import { BeaconEvent, BeaconEventHandlerFunction, BeaconEventType, BeaconEventHandler } from '../events';
|
|
4
4
|
import { BlockExplorer } from '../utils/block-explorer';
|
|
5
5
|
import { DAppClientOptions } from './DAppClientOptions';
|
|
6
|
-
import { BeaconEventHandler } from '@tezos-x/octez.connect-dapp';
|
|
7
6
|
import { DappPostMessageTransport } from '../transports/DappPostMessageTransport';
|
|
8
7
|
import { DappP2PTransport } from '../transports/DappP2PTransport';
|
|
9
8
|
import { DappWalletConnectTransport } from '../transports/DappWalletConnectTransport';
|
|
9
|
+
export interface DAppClientDisconnectOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Send Beacon disconnect messages to stored wallet peers before tearing down the transport.
|
|
12
|
+
*
|
|
13
|
+
* Defaults to true because DAppClient.disconnect is the user-facing wallet logout path.
|
|
14
|
+
*/
|
|
15
|
+
notifyPeers?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface DAppClientRemoveAllPeersOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Continue removing local peer/account state even if notifying one peer fails.
|
|
20
|
+
*/
|
|
21
|
+
ignoreDisconnectErrors?: boolean;
|
|
22
|
+
}
|
|
10
23
|
/**
|
|
11
24
|
* @publicapi
|
|
12
25
|
*
|
|
@@ -40,12 +53,20 @@ export declare class DAppClient extends Client {
|
|
|
40
53
|
protected walletConnectTransport: DappWalletConnectTransport | undefined;
|
|
41
54
|
protected wcProjectId?: string;
|
|
42
55
|
protected wcRelayUrl?: string;
|
|
56
|
+
/**
|
|
57
|
+
* When true, the WalletConnect transport is not built or listened to. See
|
|
58
|
+
* DAppClientOptions.disableWalletConnect.
|
|
59
|
+
*/
|
|
60
|
+
protected disableWalletConnect: boolean;
|
|
43
61
|
private isGetActiveAccountHandled;
|
|
44
62
|
private readonly openRequestsOtherTabs;
|
|
45
63
|
/**
|
|
46
64
|
* A map of requests that are currently "open", meaning we have sent them to a wallet and are still awaiting a response.
|
|
47
65
|
*/
|
|
48
66
|
private readonly openRequests;
|
|
67
|
+
private readonly acknowledgedRequests;
|
|
68
|
+
private readonly openRequestTimeouts;
|
|
69
|
+
private readonly requestTimeoutMs;
|
|
49
70
|
/**
|
|
50
71
|
* The currently active account. For all requests that are associated to a specific request (operation request, signing request),
|
|
51
72
|
* the active account is used to determine the network and destination wallet
|
|
@@ -56,8 +77,22 @@ export declare class DAppClient extends Client {
|
|
|
56
77
|
*/
|
|
57
78
|
private _activePeer;
|
|
58
79
|
private _initPromise;
|
|
59
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Rejector for the in-flight {@link _initPromise}. Populated while init is
|
|
82
|
+
* awaiting a peer pairing; cleared automatically when {@link _initPromise}
|
|
83
|
+
* settles. Abort paths (modal close, WC session-proposal rejection,
|
|
84
|
+
* transport-level connection failure) call this to unwedge any
|
|
85
|
+
* `await this.init()` caller, surfacing the error to handleRequestError
|
|
86
|
+
* instead of hanging.
|
|
87
|
+
*/
|
|
88
|
+
private _initReject;
|
|
89
|
+
private _initSubstratePairing;
|
|
90
|
+
private _requestPermissionsPromise;
|
|
91
|
+
private _requestPermissionsKey;
|
|
92
|
+
private _sdkSecretSeedPromise;
|
|
93
|
+
private destroyed;
|
|
60
94
|
private readonly activeAccountLoaded;
|
|
95
|
+
private readonly storageValidated;
|
|
61
96
|
private readonly appMetadataManager;
|
|
62
97
|
private readonly disclaimerText?;
|
|
63
98
|
private readonly errorMessages;
|
|
@@ -65,15 +100,22 @@ export declare class DAppClient extends Client {
|
|
|
65
100
|
private readonly storageValidator;
|
|
66
101
|
private readonly beaconIDB;
|
|
67
102
|
private debounceSetActiveAccount;
|
|
103
|
+
private hasEmittedInvalidAccountDeactivated;
|
|
104
|
+
private _disconnectPromise?;
|
|
105
|
+
private _disconnectNotifyPeers;
|
|
68
106
|
private multiTabChannel;
|
|
69
107
|
constructor(config: DAppClientOptions);
|
|
70
108
|
private checkIfBCLeaderExists;
|
|
71
109
|
private onElectedLeaderhandler;
|
|
72
110
|
private onBCMessageHandler;
|
|
73
111
|
private prepareRequest;
|
|
112
|
+
private buildDelegatedRequestError;
|
|
74
113
|
private createStateSnapshot;
|
|
75
114
|
private initUserID;
|
|
76
115
|
initInternalTransports(): Promise<void>;
|
|
116
|
+
private getOrCreateSDKSecretSeed;
|
|
117
|
+
private loadOrCreateSDKSecretSeed;
|
|
118
|
+
private isValidSDKSecretSeed;
|
|
77
119
|
private initEvents;
|
|
78
120
|
private onRelayerError;
|
|
79
121
|
private wcToastHandler;
|
|
@@ -86,11 +128,30 @@ export declare class DAppClient extends Client {
|
|
|
86
128
|
* If you wish to disconnect your dApp, use `disconnect` instead.
|
|
87
129
|
*/
|
|
88
130
|
destroy(): Promise<void>;
|
|
131
|
+
private destroyInternalTransports;
|
|
132
|
+
private abortPendingInit;
|
|
133
|
+
private createAbortedError;
|
|
134
|
+
/**
|
|
135
|
+
* @internal
|
|
136
|
+
*/
|
|
137
|
+
isDestroyed(): boolean;
|
|
138
|
+
private assertNotDestroyed;
|
|
89
139
|
init(transport?: Transport<any>, substratePairing?: boolean): Promise<TransportType>;
|
|
140
|
+
/**
|
|
141
|
+
* Attach a settle observer to {@link _initPromise} that drops
|
|
142
|
+
* {@link _initReject} once the promise settles (resolved or rejected).
|
|
143
|
+
* Errors on the observer chain are swallowed; only the original
|
|
144
|
+
* {@link _initPromise} surfaces them to its awaiters.
|
|
145
|
+
*/
|
|
146
|
+
private clearInitRejectOnSettle;
|
|
90
147
|
/**
|
|
91
148
|
* Returns the active account
|
|
92
149
|
*/
|
|
93
150
|
getActiveAccount(): Promise<AccountInfo | undefined>;
|
|
151
|
+
private retainStorageValidationPromise;
|
|
152
|
+
private deactivateInvalidAccountState;
|
|
153
|
+
private repairMissingActiveAccount;
|
|
154
|
+
private hasStoredActiveAccountPointer;
|
|
94
155
|
private isInvalidState;
|
|
95
156
|
private resetInvalidState;
|
|
96
157
|
/**
|
|
@@ -99,6 +160,8 @@ export declare class DAppClient extends Client {
|
|
|
99
160
|
* @param account The account that will be set as the active account
|
|
100
161
|
*/
|
|
101
162
|
setActiveAccount(account?: AccountInfo): Promise<void>;
|
|
163
|
+
private isActiveAccountAlreadyCleared;
|
|
164
|
+
private recoverActiveAccountFromAccountsChange;
|
|
102
165
|
/**
|
|
103
166
|
* Clear the active account
|
|
104
167
|
*/
|
|
@@ -116,7 +179,6 @@ export declare class DAppClient extends Client {
|
|
|
116
179
|
private tryToAppSwitch;
|
|
117
180
|
private addQueryParam;
|
|
118
181
|
private buildPayload;
|
|
119
|
-
private updateMetricsStorage;
|
|
120
182
|
private sendMetrics;
|
|
121
183
|
private checkMakeRequest;
|
|
122
184
|
/**
|
|
@@ -138,7 +200,7 @@ export declare class DAppClient extends Client {
|
|
|
138
200
|
/**
|
|
139
201
|
* Remove all peers and all accounts that have been connected through those peers
|
|
140
202
|
*/
|
|
141
|
-
removeAllPeers(sendDisconnectToPeers?: boolean): Promise<void>;
|
|
203
|
+
removeAllPeers(sendDisconnectToPeers?: boolean, options?: DAppClientRemoveAllPeersOptions): Promise<void>;
|
|
142
204
|
/**
|
|
143
205
|
* Allows the user to subscribe to specific events that are fired in the SDK
|
|
144
206
|
*
|
|
@@ -167,6 +229,9 @@ export declare class DAppClient extends Client {
|
|
|
167
229
|
* @param input The message details we need to prepare the PermissionRequest message.
|
|
168
230
|
*/
|
|
169
231
|
requestPermissions(input?: RequestPermissionInput): Promise<PermissionResponseOutput>;
|
|
232
|
+
private requestPermissionsInternal;
|
|
233
|
+
private getPermissionRequestScopes;
|
|
234
|
+
private getPermissionRequestKey;
|
|
170
235
|
/**
|
|
171
236
|
* Send a proof of event request to the wallet. The wallet will either accept or decline the challenge.
|
|
172
237
|
* If it is accepted, the challenge will be stored, meaning that even if the user refresh the page, the DAppClient will keep checking if the challenge has been fulfilled.
|
|
@@ -231,6 +296,29 @@ export declare class DAppClient extends Client {
|
|
|
231
296
|
*/
|
|
232
297
|
private removeAccountsForPeers;
|
|
233
298
|
private removeAccountsForPeerIds;
|
|
299
|
+
/**
|
|
300
|
+
* Run the standard request-error side effects (abort/error metric,
|
|
301
|
+
* timer stop, {@link handleRequestError}) on a single awaited control
|
|
302
|
+
* flow so callers can re-throw the original {@link ErrorResponse} without
|
|
303
|
+
* leaking an UnhandledPromiseRejection.
|
|
304
|
+
*
|
|
305
|
+
* Why this exists: every request method historically used a fire-and-
|
|
306
|
+
* forget `res.catch(handler)` whose handler did `throw await
|
|
307
|
+
* this.handleRequestError(...)`. The catch returned a detached promise
|
|
308
|
+
* nobody awaited; `handleRequestError`'s thrown wrapped error became an
|
|
309
|
+
* unhandled rejection. The bug rarely surfaced before the dapp-init
|
|
310
|
+
* promise was made rejectable, because pre-pairing rejection paths used
|
|
311
|
+
* to hang instead of routing through these handlers. Once init started
|
|
312
|
+
* rejecting reliably, the unhandled rejection started firing on every
|
|
313
|
+
* WC session-proposal rejection. We swallow the wrapped throw here so
|
|
314
|
+
* callers can re-throw the original `ErrorResponse`, matching the
|
|
315
|
+
* post-pairing rejection contract at the openRequest path.
|
|
316
|
+
*
|
|
317
|
+
* @param request The request we sent
|
|
318
|
+
* @param requestError The error we received
|
|
319
|
+
* @param logId The {@link logger.time} label opened for this request
|
|
320
|
+
*/
|
|
321
|
+
private runRequestErrorSideEffects;
|
|
234
322
|
/**
|
|
235
323
|
* This message handles errors that we receive from the wallet.
|
|
236
324
|
*
|
|
@@ -269,7 +357,22 @@ export declare class DAppClient extends Client {
|
|
|
269
357
|
*/
|
|
270
358
|
private makeRequestV3;
|
|
271
359
|
private makeRequestBC;
|
|
272
|
-
|
|
360
|
+
/**
|
|
361
|
+
* Disconnects all resolved transports (postMessage, P2P, WalletConnect), removes their peers,
|
|
362
|
+
* and clears active account state. After calling, the DAppClient remains usable for a new
|
|
363
|
+
* requestPermissions().
|
|
364
|
+
*/
|
|
365
|
+
disconnect(options?: DAppClientDisconnectOptions): Promise<void>;
|
|
366
|
+
private disconnectInternal;
|
|
367
|
+
private getInitializedTransports;
|
|
368
|
+
private getResolvedTransports;
|
|
369
|
+
private clearInternalTransportReferences;
|
|
370
|
+
private removeAllPeersFromTransports;
|
|
371
|
+
private getUniquePeerNotifications;
|
|
372
|
+
private getPeerNotificationKey;
|
|
373
|
+
private disconnectResolvedTransports;
|
|
374
|
+
private hasClientCleanup;
|
|
375
|
+
private isTransportConnected;
|
|
273
376
|
/**
|
|
274
377
|
* Adds a requests to the "openRequests" set so we know what messages have already been answered/handled.
|
|
275
378
|
*
|
|
@@ -277,6 +380,11 @@ export declare class DAppClient extends Client {
|
|
|
277
380
|
* @param promise A promise that resolves once the response for that specific message is received
|
|
278
381
|
*/
|
|
279
382
|
private addOpenRequest;
|
|
383
|
+
private addOpenRequestTimeout;
|
|
384
|
+
private clearOpenRequest;
|
|
385
|
+
private clearOpenRequestTimeout;
|
|
386
|
+
private clearAllOpenRequestTimeouts;
|
|
387
|
+
private abortOpenRequests;
|
|
280
388
|
private sendNotificationWithAccessToken;
|
|
281
389
|
private onNewAccount;
|
|
282
390
|
}
|