@meshconnect/uwc-core 1.10.0-snapshot.913d8f5 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/events.d.ts +1 -5
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/observability/lifecycle-bridge.d.ts +13 -31
- package/dist/observability/lifecycle-bridge.d.ts.map +1 -1
- package/dist/observability/lifecycle-bridge.js +92 -167
- package/dist/observability/lifecycle-bridge.js.map +1 -1
- package/dist/services/connection-service.d.ts +0 -86
- package/dist/services/connection-service.d.ts.map +1 -1
- package/dist/services/connection-service.js +9 -354
- package/dist/services/connection-service.js.map +1 -1
- package/dist/services/network-switch-service.d.ts.map +1 -1
- package/dist/services/network-switch-service.js +1 -4
- package/dist/services/network-switch-service.js.map +1 -1
- package/dist/services/signature-service.d.ts +3 -4
- package/dist/services/signature-service.d.ts.map +1 -1
- package/dist/services/signature-service.js +1 -2
- package/dist/services/signature-service.js.map +1 -1
- package/dist/universal-wallet-connector.d.ts +3 -5
- package/dist/universal-wallet-connector.d.ts.map +1 -1
- package/dist/universal-wallet-connector.js +1 -3
- package/dist/universal-wallet-connector.js.map +1 -1
- package/package.json +5 -5
- package/src/events.ts +2 -5
- package/src/observability/lifecycle-bridge.test.ts +0 -197
- package/src/observability/lifecycle-bridge.ts +99 -211
- package/src/services/connection-service.test.ts +1 -798
- package/src/services/connection-service.ts +10 -410
- package/src/services/network-switch-service.test.ts +0 -33
- package/src/services/network-switch-service.ts +1 -4
- package/src/services/signature-service.test.ts +2 -9
- package/src/services/signature-service.ts +3 -4
- package/src/universal-wallet-connector.ts +3 -5
package/dist/events.d.ts
CHANGED
|
@@ -124,13 +124,9 @@ export interface UWCEventMap {
|
|
|
124
124
|
isLoading: boolean;
|
|
125
125
|
isWaitingForUserApproval: boolean;
|
|
126
126
|
};
|
|
127
|
-
/** Network switch succeeded.
|
|
128
|
-
* resolved to (present whenever the connector returned one) — used by
|
|
129
|
-
* the lifecycle bridge to suppress the wallet's own echo of this same
|
|
130
|
-
* change (see attachLifecycle's echo-suppression window). */
|
|
127
|
+
/** Network switch succeeded. */
|
|
131
128
|
networkSwitched: {
|
|
132
129
|
network: Network;
|
|
133
|
-
address?: string;
|
|
134
130
|
};
|
|
135
131
|
/**
|
|
136
132
|
* Wallet capabilities were refreshed. `source`/`durationMs` make the
|
package/dist/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,cAAc,EACd,cAAc,EACd,WAAW,EACX,eAAe,EACf,QAAQ,EACR,cAAc,EACd,QAAQ,EACR,SAAS,EACT,SAAS,EACT,WAAW,EACX,WAAW,EACX,0BAA0B,EAC3B,MAAM,wBAAwB,CAAA;AAE/B;;;;;GAKG;AACH,eAAO,MAAM,cAAc,wKAUjB,CAAA;AAEV,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAA;AAE1D;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B,kFAAkF;IAClF,KAAK,EAAE,IAAI,CAAA;IACX;;;;;OAKG;IACH,eAAe,EAAE;QACf,OAAO,EAAE,cAAc,EAAE,CAAA;QACzB,SAAS,CAAC,EACN,MAAM,CACJ,MAAM,EACN;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAC;YAAC,cAAc,CAAC,EAAE,MAAM,CAAA;SAAE,CAChE,GACD,SAAS,CAAA;KACd,CAAA;IACD;;;;;OAKG;IACH,qBAAqB,EAAE;QACrB,SAAS,EAAE,SAAS,CAAA;QACpB,cAAc,EAAE,cAAc,CAAA;QAC9B,KAAK,EAAE,WAAW,CAAA;KACnB,CAAA;IACD;;;;;;OAMG;IACH,WAAW,EAAE;QACX,SAAS,CAAC,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EAAE,OAAO,CAAA;QACvB,sGAAsG;QACtG,MAAM,EAAE,OAAO,CAAA;KAChB,CAAA;IAED;;;;;;;OAOG;IACH,yBAAyB,EAAE;QACzB,yEAAyE;QACzE,UAAU,EAAE,SAAS,EAAE,CAAA;KACxB,CAAA;IAED;;;OAGG;IACH,MAAM,EAAE,IAAI,CAAA;CACb;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,WAAW,CAAC,YAAY,CAuB1D,CAAA;AAEF,MAAM,MAAM,YAAY,GAAG,MAAM,WAAW,CAAA;AAC5C,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,YAAY,IAAI,CACrD,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,KACjB,IAAI,CAAA;AA6CT,eAAO,MAAM,eAAe,EAAoC,YAAY,EAAE,CAAA"}
|
package/dist/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAiBA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,SAAS;IACT,YAAY;IACZ,eAAe;IACf,aAAa;IACb,eAAe;IACf,iBAAiB;IACjB,uBAAuB;IACvB,uBAAuB;IACvB,YAAY;CACJ,CAAA;
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAiBA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,SAAS;IACT,YAAY;IACZ,eAAe;IACf,aAAa;IACb,eAAe;IACf,iBAAiB;IACjB,uBAAuB;IACvB,uBAAuB;IACvB,YAAY;CACJ,CAAA;AAwaV;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA8B,IAAI,GAAG,CAAC;IACtE,KAAK;IACL,gBAAgB;IAChB,iBAAiB;IACjB,gBAAgB;IAChB,cAAc;IACd,gBAAgB;IAChB,uBAAuB;IACvB,aAAa;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 +20,9 @@ export interface AttachLifecycleOptions {
|
|
|
20
20
|
* The active connector's `onLifecycleEvent` (already bound). `undefined` when the
|
|
21
21
|
* connector can't observe lifecycle at all; the value it returns is `undefined`
|
|
22
22
|
* when THIS session can't be observed (e.g. no live `.on`). Either way the
|
|
23
|
-
* bridge emits `lifecycleTelemetryUnavailable` and becomes a no-op
|
|
24
|
-
* STREAM — `subscribeAccounts` below is attached independently.
|
|
23
|
+
* bridge emits `lifecycleTelemetryUnavailable` and becomes a no-op.
|
|
25
24
|
*/
|
|
26
25
|
subscribe: ((l: (e: WalletLifecycleEvent) => void) => (() => void) | undefined) | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* The active connector's `onAccountsChanged` (already bound), carrying the
|
|
29
|
-
* REAL account list — a separate concern from `subscribe` above (some
|
|
30
|
-
* connectors, e.g. Tron today, implement one without the other). Absent
|
|
31
|
-
* entirely when the connector doesn't support real account-sync.
|
|
32
|
-
*/
|
|
33
|
-
subscribeAccounts?: ((l: (accounts: string[]) => void) => (() => void) | undefined) | undefined;
|
|
34
|
-
/** Invoked with the resolved (post-echo-filter) real account list whenever `subscribeAccounts` delivers one. Required whenever `subscribeAccounts` is provided. */
|
|
35
|
-
onAccountsChanged?: (accounts: string[]) => void;
|
|
36
26
|
/** Resolved per-event so a mid-session account/chain change is reflected. */
|
|
37
27
|
getRouting: () => LifecycleRouting;
|
|
38
28
|
connectionMode: ConnectionMode;
|
|
@@ -41,9 +31,8 @@ export interface AttachLifecycleOptions {
|
|
|
41
31
|
/** Direct page vs production iframe — stamped on `lifecycleTelemetryUnavailable`. */
|
|
42
32
|
runtime?: 'direct' | 'iframe';
|
|
43
33
|
/**
|
|
44
|
-
* Window (ms) within which a wallet `chainChanged
|
|
45
|
-
*
|
|
46
|
-
* Default 3000.
|
|
34
|
+
* Window (ms) within which a wallet `chainChanged` is treated as the echo of a
|
|
35
|
+
* UWC-initiated `switchNetwork` and suppressed. Default 3000.
|
|
47
36
|
*/
|
|
48
37
|
echoWindowMs?: number;
|
|
49
38
|
/**
|
|
@@ -55,7 +44,6 @@ export interface AttachLifecycleOptions {
|
|
|
55
44
|
*/
|
|
56
45
|
initialSwitch?: {
|
|
57
46
|
chainId: NetworkId;
|
|
58
|
-
address?: string;
|
|
59
47
|
at: number;
|
|
60
48
|
} | undefined;
|
|
61
49
|
now?: () => number;
|
|
@@ -63,25 +51,19 @@ export interface AttachLifecycleOptions {
|
|
|
63
51
|
/**
|
|
64
52
|
* Bridge a connector's PII-safe `WalletLifecycleEvent` stream onto the event bus
|
|
65
53
|
* as `walletAccountChanged` / `walletChainChanged` / `walletDisconnected` /
|
|
66
|
-
* `walletSessionExpired
|
|
67
|
-
* account list to `onAccountsChanged` for session-sync.
|
|
54
|
+
* `walletSessionExpired`.
|
|
68
55
|
*
|
|
69
|
-
*
|
|
56
|
+
* Two correctness concerns are handled here:
|
|
70
57
|
* - **Echo suppression.** When UWC drives a `switchNetwork`, the wallet emits its
|
|
71
|
-
* own `chainChanged
|
|
72
|
-
*
|
|
73
|
-
* would double-count. We watch the bus for
|
|
74
|
-
*
|
|
75
|
-
* - **Availability is signal
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* `onLifecycleEvent` but implementing `onAccountsChanged` (e.g. Tron today)
|
|
79
|
-
* still gets real account-sync; the two streams are independently attached.
|
|
80
|
-
* - **Shared emission budget.** Both streams count against the same
|
|
81
|
-
* `MAX_LIFECYCLE_EVENTS_PER_ATTACHMENT` ceiling — a storming provider
|
|
82
|
-
* doesn't get double budget just because two streams exist.
|
|
58
|
+
* own `chainChanged` for the same chain — that's already captured by UWC's
|
|
59
|
+
* `networkSwitched` / the switch handoff, so re-emitting it as a wallet-
|
|
60
|
+
* initiated `walletChainChanged` would double-count. We watch the bus for
|
|
61
|
+
* `networkSwitched` and drop a matching `chainChanged` inside `echoWindowMs`.
|
|
62
|
+
* - **Availability is signal.** If the connector can't observe lifecycle, we emit
|
|
63
|
+
* `lifecycleTelemetryUnavailable` ONCE so a dashboard can tell "silent" from
|
|
64
|
+
* "unwired".
|
|
83
65
|
*
|
|
84
|
-
* @returns a teardown that removes
|
|
66
|
+
* @returns a teardown that removes the connector subscription AND the bus watcher.
|
|
85
67
|
*/
|
|
86
68
|
export declare function attachLifecycle(opts: AttachLifecycleOptions): () => void;
|
|
87
69
|
//# sourceMappingURL=lifecycle-bridge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle-bridge.d.ts","sourceRoot":"","sources":["../../src/observability/lifecycle-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,cAAc,EACd,SAAS,EACT,SAAS,EAEV,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAE7D,mEAAmE;AACnE,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,cAAc,CAAA;IAC9B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;CAClC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mCAAmC,MAAM,CAAA;AAEtD,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,YAAY,CAAA;IAC1B
|
|
1
|
+
{"version":3,"file":"lifecycle-bridge.d.ts","sourceRoot":"","sources":["../../src/observability/lifecycle-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,cAAc,EACd,SAAS,EACT,SAAS,EAEV,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAE7D,mEAAmE;AACnE,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,cAAc,CAAA;IAC9B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;CAClC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mCAAmC,MAAM,CAAA;AAEtD,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,YAAY,CAAA;IAC1B;;;;;OAKG;IACH,SAAS,EACL,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,oBAAoB,KAAK,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC,GACpE,SAAS,CAAA;IACb,6EAA6E;IAC7E,UAAU,EAAE,MAAM,gBAAgB,CAAA;IAClC,cAAc,EAAE,cAAc,CAAA;IAC9B,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;IACjC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,qFAAqF;IACrF,OAAO,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC7B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE;QAAE,OAAO,EAAE,SAAS,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAA;IAC9D,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CACnB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,sBAAsB,GAAG,MAAM,IAAI,CA2IxE"}
|
|
@@ -9,28 +9,22 @@ export const MAX_LIFECYCLE_EVENTS_PER_ATTACHMENT = 100;
|
|
|
9
9
|
/**
|
|
10
10
|
* Bridge a connector's PII-safe `WalletLifecycleEvent` stream onto the event bus
|
|
11
11
|
* as `walletAccountChanged` / `walletChainChanged` / `walletDisconnected` /
|
|
12
|
-
* `walletSessionExpired
|
|
13
|
-
* account list to `onAccountsChanged` for session-sync.
|
|
12
|
+
* `walletSessionExpired`.
|
|
14
13
|
*
|
|
15
|
-
*
|
|
14
|
+
* Two correctness concerns are handled here:
|
|
16
15
|
* - **Echo suppression.** When UWC drives a `switchNetwork`, the wallet emits its
|
|
17
|
-
* own `chainChanged
|
|
18
|
-
*
|
|
19
|
-
* would double-count. We watch the bus for
|
|
20
|
-
*
|
|
21
|
-
* - **Availability is signal
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* `onLifecycleEvent` but implementing `onAccountsChanged` (e.g. Tron today)
|
|
25
|
-
* still gets real account-sync; the two streams are independently attached.
|
|
26
|
-
* - **Shared emission budget.** Both streams count against the same
|
|
27
|
-
* `MAX_LIFECYCLE_EVENTS_PER_ATTACHMENT` ceiling — a storming provider
|
|
28
|
-
* doesn't get double budget just because two streams exist.
|
|
16
|
+
* own `chainChanged` for the same chain — that's already captured by UWC's
|
|
17
|
+
* `networkSwitched` / the switch handoff, so re-emitting it as a wallet-
|
|
18
|
+
* initiated `walletChainChanged` would double-count. We watch the bus for
|
|
19
|
+
* `networkSwitched` and drop a matching `chainChanged` inside `echoWindowMs`.
|
|
20
|
+
* - **Availability is signal.** If the connector can't observe lifecycle, we emit
|
|
21
|
+
* `lifecycleTelemetryUnavailable` ONCE so a dashboard can tell "silent" from
|
|
22
|
+
* "unwired".
|
|
29
23
|
*
|
|
30
|
-
* @returns a teardown that removes
|
|
24
|
+
* @returns a teardown that removes the connector subscription AND the bus watcher.
|
|
31
25
|
*/
|
|
32
26
|
export function attachLifecycle(opts) {
|
|
33
|
-
const { eventManager, subscribe,
|
|
27
|
+
const { eventManager, subscribe, getRouting } = opts;
|
|
34
28
|
const runtime = opts.runtime ?? 'direct';
|
|
35
29
|
const now = opts.now ?? Date.now;
|
|
36
30
|
const echoWindowMs = opts.echoWindowMs ?? 3000;
|
|
@@ -41,190 +35,121 @@ export function attachLifecycle(opts) {
|
|
|
41
35
|
walletId: opts.walletId,
|
|
42
36
|
runtime
|
|
43
37
|
});
|
|
44
|
-
if (!subscribe
|
|
38
|
+
if (!subscribe) {
|
|
45
39
|
// In the production iframe the injected subscription is deliberately not
|
|
46
40
|
// attempted (the provider is a Comlink proxy) — the BRIDGE, not the connector,
|
|
47
|
-
// is why lifecycle is unobservable. On the direct page, a connector with
|
|
48
|
-
//
|
|
41
|
+
// is why lifecycle is unobservable. On the direct page, a connector with no
|
|
42
|
+
// `onLifecycleEvent` simply has no lifecycle support for this namespace yet.
|
|
49
43
|
emitUnavailable(runtime === 'iframe'
|
|
50
44
|
? 'bridge_subscription_unavailable'
|
|
51
45
|
: 'unsupported_namespace');
|
|
52
46
|
return () => { };
|
|
53
47
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
// duplicate, which would otherwise leave a phantom entry behind after only
|
|
64
|
-
// one of the two is consumed by a single wallet echo.
|
|
65
|
-
const armOrRearm = (partial) => {
|
|
66
|
-
pruneExpired();
|
|
67
|
-
if (partial.chainId !== undefined) {
|
|
68
|
-
const idx = pendingSwitches.findIndex(p => p.chainId === partial.chainId);
|
|
69
|
-
if (idx !== -1) {
|
|
70
|
-
pendingSwitches[idx] = {
|
|
71
|
-
...pendingSwitches[idx],
|
|
72
|
-
...partial,
|
|
73
|
-
at: now()
|
|
74
|
-
};
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
pendingSwitches.push({ ...partial, at: now() });
|
|
79
|
-
};
|
|
48
|
+
// Record UWC-initiated switches so the wallet's chainChanged echo can be
|
|
49
|
+
// dropped. Armed from BOTH signals: `awaitingWallet` (operation switchNetwork)
|
|
50
|
+
// arms at the handoff START, because some providers emit their chainChanged
|
|
51
|
+
// BEFORE the switch request resolves — i.e. before `networkSwitched` exists —
|
|
52
|
+
// and `networkSwitched` re-arms at completion for the late-echo case. The
|
|
53
|
+
// re-arm means one extra suppression window can follow an early echo; the
|
|
54
|
+
// only event it could swallow is a sub-window user re-switch to the chain
|
|
55
|
+
// that just became active — accepted over double-counting every early echo.
|
|
56
|
+
let lastSwitch = opts.initialSwitch;
|
|
80
57
|
const offAwaiting = eventManager.on('awaitingWallet', data => {
|
|
81
58
|
if (data.operation === 'switchNetwork' && data.chainId !== undefined) {
|
|
82
|
-
|
|
59
|
+
lastSwitch = { chainId: data.chainId, at: now() };
|
|
83
60
|
}
|
|
84
61
|
});
|
|
85
62
|
const offSwitched = eventManager.on('networkSwitched', data => {
|
|
86
|
-
|
|
63
|
+
lastSwitch = { chainId: data.network.id, at: now() };
|
|
87
64
|
});
|
|
88
65
|
const detachBusWatchers = () => {
|
|
89
66
|
offAwaiting();
|
|
90
67
|
offSwitched();
|
|
91
68
|
};
|
|
92
|
-
// Emission budget for THIS attachment, shared across both streams —
|
|
93
|
-
// suppressed echoes don't spend it.
|
|
94
|
-
let emitted = 0;
|
|
95
|
-
let capNotified = false;
|
|
96
|
-
const overCap = () => {
|
|
97
|
-
if (emitted >= MAX_LIFECYCLE_EVENTS_PER_ATTACHMENT) {
|
|
98
|
-
// Mark the trip ONCE — a silent cap would be indistinguishable from a
|
|
99
|
-
// provider that simply went quiet.
|
|
100
|
-
if (!capNotified) {
|
|
101
|
-
capNotified = true;
|
|
102
|
-
emitUnavailable('emission_cap');
|
|
103
|
-
}
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
return false;
|
|
107
|
-
};
|
|
108
69
|
// Defense-in-depth: a connector whose subscribe THROWS (e.g. a provider whose
|
|
109
70
|
// `.on` rejects an un-proxied handler across the iframe bridge) must degrade to
|
|
110
71
|
// "unavailable", never break the connect path that called us.
|
|
111
72
|
let unsub;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
pruneExpired();
|
|
130
|
-
const idx = e.chainId !== undefined
|
|
131
|
-
? pendingSwitches.findIndex(p => p.chainId !== undefined && p.chainId === e.chainId)
|
|
132
|
-
: -1;
|
|
133
|
-
if (idx !== -1) {
|
|
134
|
-
// Consume the echo: a UWC switch produces exactly one wallet echo, so
|
|
135
|
-
// a LATER chainChanged to the same chain inside the window is a genuine
|
|
136
|
-
// user-initiated switch-back and must not be suppressed. Only the
|
|
137
|
-
// chain half is consumed — a still-pending address echo (if the
|
|
138
|
-
// switch also changed address format) must still be checked; drop the
|
|
139
|
-
// entry entirely once nothing is left pending on it.
|
|
140
|
-
const entry = pendingSwitches[idx];
|
|
141
|
-
if (entry.address !== undefined) {
|
|
142
|
-
pendingSwitches[idx] = { ...entry, chainId: undefined };
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
pendingSwitches.splice(idx, 1);
|
|
146
|
-
}
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
emitted++;
|
|
150
|
-
eventManager.emit('walletChainChanged', {
|
|
151
|
-
...routing,
|
|
152
|
-
...(e.chainId !== undefined ? { chainId: e.chainId } : {})
|
|
153
|
-
});
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
case 'disconnect':
|
|
157
|
-
emitted++;
|
|
158
|
-
eventManager.emit('walletDisconnected', routing);
|
|
159
|
-
return;
|
|
160
|
-
case 'sessionExpired':
|
|
161
|
-
emitted++;
|
|
162
|
-
eventManager.emit('walletSessionExpired', routing);
|
|
163
|
-
return;
|
|
73
|
+
// Emission budget for THIS attachment — suppressed echoes don't spend it.
|
|
74
|
+
let emitted = 0;
|
|
75
|
+
let capNotified = false;
|
|
76
|
+
try {
|
|
77
|
+
unsub = subscribe(e => {
|
|
78
|
+
// The whole body is guarded: wallet SDKs dispatch their listeners
|
|
79
|
+
// unguarded (e.g. TonConnect's bare `forEach`), so a throw here — from
|
|
80
|
+
// `getRouting()` or any future edit — would abort delivery to the
|
|
81
|
+
// wallet's OWN later subscribers, including one resolving a pending
|
|
82
|
+
// connect. Telemetry must never do that.
|
|
83
|
+
try {
|
|
84
|
+
if (emitted >= MAX_LIFECYCLE_EVENTS_PER_ATTACHMENT) {
|
|
85
|
+
// Mark the trip ONCE — a silent cap would be indistinguishable from a
|
|
86
|
+
// provider that simply went quiet.
|
|
87
|
+
if (!capNotified) {
|
|
88
|
+
capNotified = true;
|
|
89
|
+
emitUnavailable('emission_cap');
|
|
164
90
|
}
|
|
91
|
+
return;
|
|
165
92
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
catch {
|
|
173
|
-
unsub = undefined;
|
|
174
|
-
}
|
|
175
|
-
if (!unsub) {
|
|
176
|
-
// The connector accepted the subscribe call but this session has no
|
|
177
|
-
// observable telemetry surface (returned undefined or threw). Over the
|
|
178
|
-
// bridge, that absence is the bridge's doing, not the provider's.
|
|
179
|
-
emitUnavailable(runtime === 'iframe'
|
|
180
|
-
? 'bridge_subscription_unavailable'
|
|
181
|
-
: 'provider_subscription_unavailable');
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
let unsubAccounts;
|
|
185
|
-
if (subscribeAccounts) {
|
|
186
|
-
try {
|
|
187
|
-
unsubAccounts = subscribeAccounts(accounts => {
|
|
188
|
-
try {
|
|
189
|
-
if (overCap())
|
|
93
|
+
const routing = getRouting();
|
|
94
|
+
switch (e.type) {
|
|
95
|
+
case 'accountChanged':
|
|
96
|
+
emitted++;
|
|
97
|
+
eventManager.emit('walletAccountChanged', routing);
|
|
190
98
|
return;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
pendingSwitches.splice(idx, 1);
|
|
99
|
+
case 'chainChanged': {
|
|
100
|
+
const isEcho = !!lastSwitch &&
|
|
101
|
+
e.chainId !== undefined &&
|
|
102
|
+
lastSwitch.chainId === e.chainId &&
|
|
103
|
+
now() - lastSwitch.at <= echoWindowMs;
|
|
104
|
+
if (isEcho) {
|
|
105
|
+
// Consume the echo: a UWC switch produces exactly one wallet echo, so
|
|
106
|
+
// a LATER chainChanged to the same chain inside the window is a genuine
|
|
107
|
+
// user-initiated switch-back and must not be suppressed.
|
|
108
|
+
lastSwitch = undefined;
|
|
109
|
+
return;
|
|
205
110
|
}
|
|
111
|
+
emitted++;
|
|
112
|
+
eventManager.emit('walletChainChanged', {
|
|
113
|
+
...routing,
|
|
114
|
+
...(e.chainId !== undefined ? { chainId: e.chainId } : {})
|
|
115
|
+
});
|
|
206
116
|
return;
|
|
207
117
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
118
|
+
case 'disconnect':
|
|
119
|
+
emitted++;
|
|
120
|
+
eventManager.emit('walletDisconnected', routing);
|
|
121
|
+
return;
|
|
122
|
+
case 'sessionExpired':
|
|
123
|
+
emitted++;
|
|
124
|
+
eventManager.emit('walletSessionExpired', routing);
|
|
125
|
+
return;
|
|
213
126
|
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// Swallowed: better to drop one lifecycle record than to break the
|
|
130
|
+
// wallet's event dispatch.
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
unsub = undefined;
|
|
219
136
|
}
|
|
220
|
-
|
|
137
|
+
// The connector accepted the subscribe call but this session has no observable
|
|
138
|
+
// surface (returned undefined) or threw — treat as "unavailable" and don't
|
|
139
|
+
// leave the bus watchers attached.
|
|
140
|
+
if (!unsub) {
|
|
221
141
|
detachBusWatchers();
|
|
142
|
+
// `onLifecycleEvent` ran but exposed no live subscription surface for this
|
|
143
|
+
// session (returned undefined or threw). Over the bridge, that absence is the
|
|
144
|
+
// bridge's doing, not the provider's.
|
|
145
|
+
emitUnavailable(runtime === 'iframe'
|
|
146
|
+
? 'bridge_subscription_unavailable'
|
|
147
|
+
: 'provider_subscription_unavailable');
|
|
222
148
|
return () => { };
|
|
223
149
|
}
|
|
224
150
|
return () => {
|
|
225
151
|
detachBusWatchers();
|
|
226
|
-
unsub
|
|
227
|
-
unsubAccounts?.();
|
|
152
|
+
unsub();
|
|
228
153
|
};
|
|
229
154
|
}
|
|
230
155
|
//# sourceMappingURL=lifecycle-bridge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle-bridge.js","sourceRoot":"","sources":["../../src/observability/lifecycle-bridge.ts"],"names":[],"mappings":"AAgBA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,GAAG,CAAA;
|
|
1
|
+
{"version":3,"file":"lifecycle-bridge.js","sourceRoot":"","sources":["../../src/observability/lifecycle-bridge.ts"],"names":[],"mappings":"AAgBA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,GAAG,CAAA;AAoCtD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,eAAe,CAAC,IAA4B;IAC1D,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,IAAI,CAAA;IACpD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,QAAQ,CAAA;IACxC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAA;IAChC,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,IAAI,IAAI,CAAA;IAE9C,MAAM,eAAe,GAAG,CAAC,MAAkC,EAAE,EAAE,CAC7D,YAAY,CAAC,IAAI,CAAC,+BAA+B,EAAE;QACjD,MAAM;QACN,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,OAAO;KACR,CAAC,CAAA;IAEJ,IAAI,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,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAA;wBAChD,OAAM;oBACR,KAAK,gBAAgB;wBACnB,OAAO,EAAE,CAAA;wBACT,YAAY,CAAC,IAAI,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAA;wBAClD,OAAM;gBACV,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,mEAAmE;gBACnE,2BAA2B;YAC7B,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,KAAK,GAAG,SAAS,CAAA;IACnB,CAAC;IAED,+EAA+E;IAC/E,2EAA2E;IAC3E,mCAAmC;IACnC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,iBAAiB,EAAE,CAAA;QACnB,2EAA2E;QAC3E,8EAA8E;QAC9E,sCAAsC;QACtC,eAAe,CACb,OAAO,KAAK,QAAQ;YAClB,CAAC,CAAC,iCAAiC;YACnC,CAAC,CAAC,mCAAmC,CACxC,CAAA;QACD,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;IACjB,CAAC;IAED,OAAO,GAAG,EAAE;QACV,iBAAiB,EAAE,CAAA;QACnB,KAAK,EAAE,CAAA;IACT,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -4,12 +4,6 @@ import type { EventManager } from '../managers/event-manager';
|
|
|
4
4
|
export interface ServiceOptions {
|
|
5
5
|
signal?: AbortSignal;
|
|
6
6
|
}
|
|
7
|
-
/** Sibling-namespace live-account re-read poll: absorbs the lag while a wallet
|
|
8
|
-
* re-derives a sibling namespace's address (e.g. MetaMask's Solana Snap) after
|
|
9
|
-
* an account switch on another namespace. Bounded so a genuinely-unchanged
|
|
10
|
-
* sibling gives up quickly. */
|
|
11
|
-
export declare const SIBLING_REFRESH_MAX_ATTEMPTS = 5;
|
|
12
|
-
export declare const SIBLING_REFRESH_DELAY_MS = 200;
|
|
13
7
|
export declare class ConnectionService {
|
|
14
8
|
private networks;
|
|
15
9
|
private wallets;
|
|
@@ -21,12 +15,6 @@ export declare class ConnectionService {
|
|
|
21
15
|
private activeConnector;
|
|
22
16
|
/** Tears down the post-connect lifecycle subscription; set while connected. */
|
|
23
17
|
private lifecycleTeardown;
|
|
24
|
-
/**
|
|
25
|
-
* Teardowns for the accounts-sync attachments of the session's SECONDARY
|
|
26
|
-
* namespaces (see `attachSecondaryAccountSync`); set while connected,
|
|
27
|
-
* cleared together with `lifecycleTeardown`.
|
|
28
|
-
*/
|
|
29
|
-
private secondaryAccountSyncTeardowns;
|
|
30
18
|
/**
|
|
31
19
|
* Abort handle for the CURRENT in-flight connect attempt. A re-entrant
|
|
32
20
|
* connect() aborts this before starting, so a superseded attempt's URI poll
|
|
@@ -35,25 +23,10 @@ export declare class ConnectionService {
|
|
|
35
23
|
* each reading the shared activeConnector, and flood telemetry).
|
|
36
24
|
*/
|
|
37
25
|
private inFlightAbort;
|
|
38
|
-
/**
|
|
39
|
-
* Monotonic token for the in-flight cross-namespace sibling refresh (see
|
|
40
|
-
* `refreshSiblingNamespaces`). A newer account switch, a teardown, or a
|
|
41
|
-
* disconnect bumps it so a still-polling older refresh aborts before it
|
|
42
|
-
* writes a now-stale sibling address into the session.
|
|
43
|
-
*/
|
|
44
|
-
private siblingRefreshGeneration;
|
|
45
26
|
constructor(networks: Network[], wallets: WalletMetadata[], sessionManager: SessionManager, connectors: Map<ConnectionMode, Connector>, usingIntegratedBrowser: boolean, eventManager: EventManager, walletResponseTimeoutMs: number);
|
|
46
27
|
connect(connectionMode: ConnectionMode, walletId: string, networkId?: NetworkId, options?: ServiceOptions): Promise<void>;
|
|
47
28
|
/** Wire the active connector's lifecycle stream onto the bus (or signal absence). */
|
|
48
29
|
private attachLifecycle;
|
|
49
|
-
/**
|
|
50
|
-
* Apply a REAL account-list change (from `Connector.onAccountsChanged`, via
|
|
51
|
-
* the lifecycle bridge's second stream) to the session. `namespace` is the
|
|
52
|
-
* namespace of the provider that reported the change — `activeAddress`
|
|
53
|
-
* only moves when that matches the session's currently active network; an
|
|
54
|
-
* empty list is a full, wallet-initiated disconnect.
|
|
55
|
-
*/
|
|
56
|
-
private handleAccountsChanged;
|
|
57
30
|
/**
|
|
58
31
|
* Remove the active provider-lifecycle subscription (EIP-1193 `.on` / wallet-
|
|
59
32
|
* adapter / SignClient listeners) WITHOUT disconnecting the wallet. Idempotent.
|
|
@@ -71,71 +44,12 @@ export declare class ConnectionService {
|
|
|
71
44
|
* Safe no-op when nothing is connected.
|
|
72
45
|
*/
|
|
73
46
|
reattachLifecycle(): void;
|
|
74
|
-
/**
|
|
75
|
-
* Attach account-sync for every OTHER namespace the session's
|
|
76
|
-
* `availableAddresses` span. `attachLifecycle` observes only the ACTIVE
|
|
77
|
-
* network's namespace, but the cross-namespace gather seeds addresses from
|
|
78
|
-
* other namespaces' live surfaces at connect time — without their own
|
|
79
|
-
* subscription, a wallet-side account switch on such a namespace is never
|
|
80
|
-
* observed and the session serves the connect-time addresses forever (e.g.
|
|
81
|
-
* a Solana-active MetaMask session whose eip155 addresses never follow the
|
|
82
|
-
* extension's account switch).
|
|
83
|
-
*
|
|
84
|
-
* Accounts-sync ONLY, no lifecycle-telemetry stream: the active namespace
|
|
85
|
-
* stays the single source of wallet* telemetry and of the wallet-initiated
|
|
86
|
-
* disconnect signal.
|
|
87
|
-
*/
|
|
88
|
-
private attachSecondaryAccountSync;
|
|
89
|
-
/**
|
|
90
|
-
* A SECONDARY namespace just reported an empty account list. Determine whether
|
|
91
|
-
* this is a full wallet-initiated disconnect (vs. only that namespace losing
|
|
92
|
-
* authorization) by reading the ACTIVE namespace's LIVE account: if it's also
|
|
93
|
-
* gone, the whole wallet disconnected — clear the session via the active
|
|
94
|
-
* namespace's empty-list path. If the active namespace still has an account
|
|
95
|
-
* (a genuine partial change) or we can't tell, keep the conservative no-op.
|
|
96
|
-
*
|
|
97
|
-
* Motivating case: MetaMask's Solana-Snap active namespace emits no disconnect
|
|
98
|
-
* signal, while its eip155 (secondary) leg does — so the secondary empty is the
|
|
99
|
-
* only signal the wallet is gone.
|
|
100
|
-
*/
|
|
101
|
-
private clearSessionIfWalletFullyDisconnected;
|
|
102
|
-
/**
|
|
103
|
-
* After a real account switch on `changedNamespace`, re-read the LIVE account
|
|
104
|
-
* of every OTHER connected namespace and fold any that changed into the
|
|
105
|
-
* session in ONE update. Sibling namespaces (e.g. a MetaMask Solana Snap
|
|
106
|
-
* address derived from the EVM account) change with the underlying account but
|
|
107
|
-
* emit no `accountsChanged`, and their live read can LAG the firing namespace's
|
|
108
|
-
* event while the wallet re-derives — so poll each sibling up to
|
|
109
|
-
* `SIBLING_REFRESH_MAX_ATTEMPTS` times, `SIBLING_REFRESH_DELAY_MS` apart,
|
|
110
|
-
* stopping a sibling the moment its live address differs from the stored one.
|
|
111
|
-
*
|
|
112
|
-
* Loop-safe: writes addresses DIRECTLY via the session manager (never
|
|
113
|
-
* re-dispatches a per-namespace accountsChanged), and only emits when at least
|
|
114
|
-
* one sibling actually changed — so refreshing B here cannot re-enter this for
|
|
115
|
-
* A and recurse. Generation-guarded so a newer switch / teardown / disconnect
|
|
116
|
-
* supersedes an older still-polling refresh before it writes.
|
|
117
|
-
*/
|
|
118
|
-
private refreshSiblingNamespaces;
|
|
119
47
|
private connectWithURIPoll;
|
|
120
48
|
private getConnector;
|
|
121
49
|
private findWallet;
|
|
122
50
|
private getProviderForMode;
|
|
123
51
|
private validateAndDetermineNetwork;
|
|
124
52
|
disconnect(options?: ServiceOptions): Promise<void>;
|
|
125
|
-
/**
|
|
126
|
-
* Clears core's own local state (session, active connector reference,
|
|
127
|
-
* lifecycle subscription) and emits the disconnect events. Does NOT itself
|
|
128
|
-
* call the connector's `disconnect()` — that happens in each CALLER,
|
|
129
|
-
* because the two callers need different semantics: the public
|
|
130
|
-
* `disconnect()` above awaits it (the caller may care whether the wallet
|
|
131
|
-
* side actually tore down); the wallet-initiated path in
|
|
132
|
-
* `handleAccountsChanged` fires it and swallows the result (the wallet
|
|
133
|
-
* already ended the session on its own side, but the connector's own
|
|
134
|
-
* LOCAL state — e.g. a cached account/uuid — still needs clearing, or a
|
|
135
|
-
* later connect to a different wallet reads it as stale and never
|
|
136
|
-
* rebinds).
|
|
137
|
-
*/
|
|
138
|
-
private finishDisconnect;
|
|
139
53
|
getConnectionURI(): string | undefined;
|
|
140
54
|
getWallets(): WalletMetadata[];
|
|
141
55
|
updateWallets(wallets: WalletMetadata[]): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-service.d.ts","sourceRoot":"","sources":["../../src/services/connection-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,SAAS,EAET,cAAc,EACd,cAAc,EACd,SAAS,EAMV,MAAM,wBAAwB,CAAA;AAE/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAK7D,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED
|
|
1
|
+
{"version":3,"file":"connection-service.d.ts","sourceRoot":"","sources":["../../src/services/connection-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,SAAS,EAET,cAAc,EACd,cAAc,EACd,SAAS,EAMV,MAAM,wBAAwB,CAAA;AAE/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAK7D,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED,qBAAa,iBAAiB;IAc1B,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,sBAAsB;IAC9B,OAAO,CAAC,YAAY;IAEpB,OAAO,CAAC,uBAAuB;IApBjC,OAAO,CAAC,eAAe,CAAyB;IAChD,+EAA+E;IA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