@meshconnect/uwc-core 1.2.2 → 1.2.3-snapshot.2b4c3e4
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 +5 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/observability/lifecycle-bridge.d.ts +31 -13
- package/dist/observability/lifecycle-bridge.d.ts.map +1 -1
- package/dist/observability/lifecycle-bridge.js +167 -92
- package/dist/observability/lifecycle-bridge.js.map +1 -1
- package/dist/services/connection-service.d.ts +43 -0
- package/dist/services/connection-service.d.ts.map +1 -1
- package/dist/services/connection-service.js +163 -9
- 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 +4 -1
- package/dist/services/network-switch-service.js.map +1 -1
- package/dist/services/signature-service.d.ts +4 -3
- package/dist/services/signature-service.d.ts.map +1 -1
- package/dist/services/signature-service.js +2 -1
- package/dist/services/signature-service.js.map +1 -1
- package/dist/universal-wallet-connector.d.ts +5 -3
- package/dist/universal-wallet-connector.d.ts.map +1 -1
- package/dist/universal-wallet-connector.js +3 -1
- package/dist/universal-wallet-connector.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
- package/src/events.ts +5 -2
- package/src/observability/lifecycle-bridge.test.ts +197 -0
- package/src/observability/lifecycle-bridge.ts +211 -99
- package/src/services/connection-service.test.ts +272 -0
- package/src/services/connection-service.ts +190 -10
- package/src/services/network-switch-service.test.ts +33 -0
- package/src/services/network-switch-service.ts +4 -1
- package/src/services/signature-service.test.ts +9 -2
- package/src/services/signature-service.ts +4 -3
- package/src/universal-wallet-connector.ts +5 -3
- package/src/version.ts +1 -1
package/dist/events.d.ts
CHANGED
|
@@ -106,9 +106,13 @@ export interface UWCEventMap {
|
|
|
106
106
|
isLoading: boolean;
|
|
107
107
|
isWaitingForUserApproval: boolean;
|
|
108
108
|
};
|
|
109
|
-
/** Network switch succeeded.
|
|
109
|
+
/** Network switch succeeded. `address` is the new address the switch
|
|
110
|
+
* resolved to (present whenever the connector returned one) — used by
|
|
111
|
+
* the lifecycle bridge to suppress the wallet's own echo of this same
|
|
112
|
+
* change (see attachLifecycle's echo-suppression window). */
|
|
110
113
|
networkSwitched: {
|
|
111
114
|
network: Network;
|
|
115
|
+
address?: string;
|
|
112
116
|
};
|
|
113
117
|
/** Wallet capabilities were refreshed. */
|
|
114
118
|
capabilitiesUpdated: {
|
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,CAAC,MAAM,EAAE;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC,GACtD,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;;;;;;OA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I,CAAA;AAwCT,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;AA8SV;;;;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;IACb,YAAY;IACZ,wBAAwB;IACxB,sBAAsB;IACtB,oBAAoB;IACpB,oBAAoB;IACpB,sBAAsB;IACtB,+BAA+B;IAC/B,yBAAyB;IACzB,0BAA0B;CAC3B,CAAC,CAAA;AAOF;;;;;GAKG;AACH,MAAM,gBAAgB,GAA+B;IACnD,KAAK,EAAE,IAAI;IACX,eAAe,EAAE,IAAI;IACrB,qBAAqB,EAAE,IAAI;IAC3B,WAAW,EAAE,IAAI;IACjB,UAAU,EAAE,IAAI;IAChB,sBAAsB,EAAE,IAAI;IAC5B,UAAU,EAAE,IAAI;IAChB,SAAS,EAAE,IAAI;IACf,YAAY,EAAE,IAAI;IAClB,aAAa,EAAE,IAAI;IACnB,cAAc,EAAE,IAAI;IACpB,gBAAgB,EAAE,IAAI;IACtB,eAAe,EAAE,IAAI;IACrB,mBAAmB,EAAE,IAAI;IACzB,KAAK,EAAE,IAAI;IACX,GAAG,EAAE,IAAI;IACT,cAAc,EAAE,IAAI;IACpB,eAAe,EAAE,IAAI;IACrB,cAAc,EAAE,IAAI;IACpB,YAAY,EAAE,IAAI;IAClB,cAAc,EAAE,IAAI;IACpB,oBAAoB,EAAE,IAAI;IAC1B,kBAAkB,EAAE,IAAI;IACxB,kBAAkB,EAAE,IAAI;IACxB,oBAAoB,EAAE,IAAI;IAC1B,6BAA6B,EAAE,IAAI;IACnC,uBAAuB,EAAE,IAAI;IAC7B,wBAAwB,EAAE,IAAI;IAC9B,MAAM,EAAE,IAAI;CACb,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAmB,CAAA"}
|
|
@@ -20,9 +20,19 @@ 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
|
|
23
|
+
* bridge emits `lifecycleTelemetryUnavailable` and becomes a no-op FOR THIS
|
|
24
|
+
* STREAM — `subscribeAccounts` below is attached independently.
|
|
24
25
|
*/
|
|
25
26
|
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;
|
|
26
36
|
/** Resolved per-event so a mid-session account/chain change is reflected. */
|
|
27
37
|
getRouting: () => LifecycleRouting;
|
|
28
38
|
connectionMode: ConnectionMode;
|
|
@@ -31,8 +41,9 @@ export interface AttachLifecycleOptions {
|
|
|
31
41
|
/** Direct page vs production iframe — stamped on `lifecycleTelemetryUnavailable`. */
|
|
32
42
|
runtime?: 'direct' | 'iframe';
|
|
33
43
|
/**
|
|
34
|
-
* Window (ms) within which a wallet `chainChanged` is
|
|
35
|
-
* UWC-initiated `switchNetwork` and suppressed.
|
|
44
|
+
* Window (ms) within which a wallet `chainChanged`/`accountsChanged` is
|
|
45
|
+
* treated as the echo of a UWC-initiated `switchNetwork` and suppressed.
|
|
46
|
+
* Default 3000.
|
|
36
47
|
*/
|
|
37
48
|
echoWindowMs?: number;
|
|
38
49
|
/**
|
|
@@ -44,6 +55,7 @@ export interface AttachLifecycleOptions {
|
|
|
44
55
|
*/
|
|
45
56
|
initialSwitch?: {
|
|
46
57
|
chainId: NetworkId;
|
|
58
|
+
address?: string;
|
|
47
59
|
at: number;
|
|
48
60
|
} | undefined;
|
|
49
61
|
now?: () => number;
|
|
@@ -51,19 +63,25 @@ export interface AttachLifecycleOptions {
|
|
|
51
63
|
/**
|
|
52
64
|
* Bridge a connector's PII-safe `WalletLifecycleEvent` stream onto the event bus
|
|
53
65
|
* as `walletAccountChanged` / `walletChainChanged` / `walletDisconnected` /
|
|
54
|
-
* `walletSessionExpired
|
|
66
|
+
* `walletSessionExpired`, AND (separately) forward the connector's real
|
|
67
|
+
* account list to `onAccountsChanged` for session-sync.
|
|
55
68
|
*
|
|
56
|
-
*
|
|
69
|
+
* Three correctness concerns are handled here:
|
|
57
70
|
* - **Echo suppression.** When UWC drives a `switchNetwork`, the wallet emits its
|
|
58
|
-
* own `chainChanged` for the same
|
|
59
|
-
* `networkSwitched` / the switch handoff, so re-emitting it
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* - **Availability is signal.** If the connector can't observe
|
|
63
|
-
* `lifecycleTelemetryUnavailable` ONCE
|
|
64
|
-
*
|
|
71
|
+
* own `chainChanged`/`accountsChanged` for the same change — that's already
|
|
72
|
+
* captured by UWC's `networkSwitched` / the switch handoff, so re-emitting it
|
|
73
|
+
* would double-count. We watch the bus for `networkSwitched` and drop a
|
|
74
|
+
* matching echo of either kind inside `echoWindowMs`.
|
|
75
|
+
* - **Availability is signal, per stream.** If the connector can't observe
|
|
76
|
+
* telemetry lifecycle, we emit `lifecycleTelemetryUnavailable` ONCE — but
|
|
77
|
+
* that signal is specific to the TELEMETRY stream. A connector missing
|
|
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.
|
|
65
83
|
*
|
|
66
|
-
* @returns a teardown that removes
|
|
84
|
+
* @returns a teardown that removes both connector subscriptions AND the bus watcher.
|
|
67
85
|
*/
|
|
68
86
|
export declare function attachLifecycle(opts: AttachLifecycleOptions): () => void;
|
|
69
87
|
//# 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,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E,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;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;;;OAMG;IACH,aAAa,CAAC,EACV;QAAE,OAAO,EAAE,SAAS,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GACpD,SAAS,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,sBAAsB,GAAG,MAAM,IAAI,CAsOxE"}
|
|
@@ -9,22 +9,28 @@ 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
|
|
12
|
+
* `walletSessionExpired`, AND (separately) forward the connector's real
|
|
13
|
+
* account list to `onAccountsChanged` for session-sync.
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
+
* Three correctness concerns are handled here:
|
|
15
16
|
* - **Echo suppression.** When UWC drives a `switchNetwork`, the wallet emits its
|
|
16
|
-
* own `chainChanged` for the same
|
|
17
|
-
* `networkSwitched` / the switch handoff, so re-emitting it
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* - **Availability is signal.** If the connector can't observe
|
|
21
|
-
* `lifecycleTelemetryUnavailable` ONCE
|
|
22
|
-
*
|
|
17
|
+
* own `chainChanged`/`accountsChanged` for the same change — that's already
|
|
18
|
+
* captured by UWC's `networkSwitched` / the switch handoff, so re-emitting it
|
|
19
|
+
* would double-count. We watch the bus for `networkSwitched` and drop a
|
|
20
|
+
* matching echo of either kind inside `echoWindowMs`.
|
|
21
|
+
* - **Availability is signal, per stream.** If the connector can't observe
|
|
22
|
+
* telemetry lifecycle, we emit `lifecycleTelemetryUnavailable` ONCE — but
|
|
23
|
+
* that signal is specific to the TELEMETRY stream. A connector missing
|
|
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.
|
|
23
29
|
*
|
|
24
|
-
* @returns a teardown that removes
|
|
30
|
+
* @returns a teardown that removes both connector subscriptions AND the bus watcher.
|
|
25
31
|
*/
|
|
26
32
|
export function attachLifecycle(opts) {
|
|
27
|
-
const { eventManager, subscribe, getRouting } = opts;
|
|
33
|
+
const { eventManager, subscribe, subscribeAccounts, getRouting } = opts;
|
|
28
34
|
const runtime = opts.runtime ?? 'direct';
|
|
29
35
|
const now = opts.now ?? Date.now;
|
|
30
36
|
const echoWindowMs = opts.echoWindowMs ?? 3000;
|
|
@@ -35,121 +41,190 @@ export function attachLifecycle(opts) {
|
|
|
35
41
|
walletId: opts.walletId,
|
|
36
42
|
runtime
|
|
37
43
|
});
|
|
38
|
-
if (!subscribe) {
|
|
44
|
+
if (!subscribe && !subscribeAccounts) {
|
|
39
45
|
// In the production iframe the injected subscription is deliberately not
|
|
40
46
|
// attempted (the provider is a Comlink proxy) — the BRIDGE, not the connector,
|
|
41
|
-
// is why lifecycle is unobservable. On the direct page, a connector with
|
|
42
|
-
//
|
|
47
|
+
// is why lifecycle is unobservable. On the direct page, a connector with
|
|
48
|
+
// neither stream simply has no lifecycle support for this namespace yet.
|
|
43
49
|
emitUnavailable(runtime === 'iframe'
|
|
44
50
|
? 'bridge_subscription_unavailable'
|
|
45
51
|
: 'unsupported_namespace');
|
|
46
52
|
return () => { };
|
|
47
53
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
|
|
54
|
+
let pendingSwitches = opts.initialSwitch
|
|
55
|
+
? [opts.initialSwitch]
|
|
56
|
+
: [];
|
|
57
|
+
const pruneExpired = () => {
|
|
58
|
+
pendingSwitches = pendingSwitches.filter(p => now() - p.at <= echoWindowMs);
|
|
59
|
+
};
|
|
60
|
+
// `awaitingWallet` then `networkSwitched` are usually the START and
|
|
61
|
+
// COMPLETION of the SAME switch — re-arming updates that existing entry
|
|
62
|
+
// (refreshing `at`, adding the resolved address) rather than pushing a
|
|
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
|
+
};
|
|
57
80
|
const offAwaiting = eventManager.on('awaitingWallet', data => {
|
|
58
81
|
if (data.operation === 'switchNetwork' && data.chainId !== undefined) {
|
|
59
|
-
|
|
82
|
+
armOrRearm({ chainId: data.chainId });
|
|
60
83
|
}
|
|
61
84
|
});
|
|
62
85
|
const offSwitched = eventManager.on('networkSwitched', data => {
|
|
63
|
-
|
|
86
|
+
armOrRearm({ chainId: data.network.id, address: data.address });
|
|
64
87
|
});
|
|
65
88
|
const detachBusWatchers = () => {
|
|
66
89
|
offAwaiting();
|
|
67
90
|
offSwitched();
|
|
68
91
|
};
|
|
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
|
+
};
|
|
69
108
|
// Defense-in-depth: a connector whose subscribe THROWS (e.g. a provider whose
|
|
70
109
|
// `.on` rejects an un-proxied handler across the iframe bridge) must degrade to
|
|
71
110
|
// "unavailable", never break the connect path that called us.
|
|
72
111
|
let unsub;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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');
|
|
90
|
-
}
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const routing = getRouting();
|
|
94
|
-
switch (e.type) {
|
|
95
|
-
case 'accountChanged':
|
|
96
|
-
emitted++;
|
|
97
|
-
eventManager.emit('walletAccountChanged', routing);
|
|
112
|
+
if (subscribe) {
|
|
113
|
+
try {
|
|
114
|
+
unsub = subscribe(e => {
|
|
115
|
+
// The whole body is guarded: wallet SDKs dispatch their listeners
|
|
116
|
+
// unguarded (e.g. TonConnect's bare `forEach`), so a throw here would
|
|
117
|
+
// abort delivery to the wallet's OWN later subscribers, including one
|
|
118
|
+
// resolving a pending connect. Telemetry must never do that.
|
|
119
|
+
try {
|
|
120
|
+
if (overCap())
|
|
98
121
|
return;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
122
|
+
const routing = getRouting();
|
|
123
|
+
switch (e.type) {
|
|
124
|
+
case 'accountChanged':
|
|
125
|
+
emitted++;
|
|
126
|
+
eventManager.emit('walletAccountChanged', routing);
|
|
127
|
+
return;
|
|
128
|
+
case 'chainChanged': {
|
|
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
|
+
});
|
|
109
154
|
return;
|
|
110
155
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
156
|
+
case 'disconnect':
|
|
157
|
+
emitted++;
|
|
158
|
+
eventManager.emit('walletDisconnected', routing);
|
|
159
|
+
return;
|
|
160
|
+
case 'sessionExpired':
|
|
161
|
+
emitted++;
|
|
162
|
+
eventManager.emit('walletSessionExpired', routing);
|
|
163
|
+
return;
|
|
117
164
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
// Swallowed: better to drop one lifecycle record than to break the
|
|
168
|
+
// wallet's event dispatch.
|
|
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())
|
|
121
190
|
return;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
191
|
+
const primary = accounts[0];
|
|
192
|
+
pruneExpired();
|
|
193
|
+
const idx = accounts.length > 0
|
|
194
|
+
? pendingSwitches.findIndex(p => p.address !== undefined && p.address === primary)
|
|
195
|
+
: -1;
|
|
196
|
+
if (idx !== -1) {
|
|
197
|
+
// Same one-shot consume as the chainChanged echo above, mirrored
|
|
198
|
+
// for the address half.
|
|
199
|
+
const entry = pendingSwitches[idx];
|
|
200
|
+
if (entry.chainId !== undefined) {
|
|
201
|
+
pendingSwitches[idx] = { ...entry, address: undefined };
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
pendingSwitches.splice(idx, 1);
|
|
205
|
+
}
|
|
125
206
|
return;
|
|
207
|
+
}
|
|
208
|
+
emitted++;
|
|
209
|
+
opts.onAccountsChanged?.(accounts);
|
|
126
210
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
unsub = undefined;
|
|
211
|
+
catch {
|
|
212
|
+
// Swallowed: never break the wallet SDK's own listener dispatch.
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
unsubAccounts = undefined;
|
|
218
|
+
}
|
|
136
219
|
}
|
|
137
|
-
|
|
138
|
-
// surface (returned undefined) or threw — treat as "unavailable" and don't
|
|
139
|
-
// leave the bus watchers attached.
|
|
140
|
-
if (!unsub) {
|
|
220
|
+
if (!unsub && !unsubAccounts) {
|
|
141
221
|
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');
|
|
148
222
|
return () => { };
|
|
149
223
|
}
|
|
150
224
|
return () => {
|
|
151
225
|
detachBusWatchers();
|
|
152
|
-
unsub();
|
|
226
|
+
unsub?.();
|
|
227
|
+
unsubAccounts?.();
|
|
153
228
|
};
|
|
154
229
|
}
|
|
155
230
|
//# 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;AAmDtD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,eAAe,CAAC,IAA4B;IAC1D,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,GAAG,IAAI,CAAA;IACvE,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,CAAC,SAAS,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACrC,yEAAyE;QACzE,+EAA+E;QAC/E,yEAAyE;QACzE,yEAAyE;QACzE,eAAe,CACb,OAAO,KAAK,QAAQ;YAClB,CAAC,CAAC,iCAAiC;YACnC,CAAC,CAAC,uBAAuB,CAC5B,CAAA;QACD,OAAO,GAAG,EAAE,GAAE,CA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C;6BAAM,CAAC;4BACN,eAAe,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;wBAChC,CAAC;wBACD,OAAM;oBACR,CAAC;oBACD,OAAO,EAAE,CAAA;oBACT,IAAI,CAAC,iBAAiB,EAAE,CAAC,QAAQ,CAAC,CAAA;gBACpC,CAAC;gBAAC,MAAM,CAAC;oBACP,iEAAiE;gBACnE,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,aAAa,GAAG,SAAS,CAAA;QAC3B,CAAC;IACH,CAAC;IAED,IAAI,CAAC,KAAK,IAAI,CAAC,aAAa,EAAE,CAAC;QAC7B,iBAAiB,EAAE,CAAA;QACnB,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;IACjB,CAAC;IAED,OAAO,GAAG,EAAE;QACV,iBAAiB,EAAE,CAAA;QACnB,KAAK,EAAE,EAAE,CAAA;QACT,aAAa,EAAE,EAAE,CAAA;IACnB,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -15,6 +15,12 @@ export declare class ConnectionService {
|
|
|
15
15
|
private activeConnector;
|
|
16
16
|
/** Tears down the post-connect lifecycle subscription; set while connected. */
|
|
17
17
|
private lifecycleTeardown;
|
|
18
|
+
/**
|
|
19
|
+
* Teardowns for the accounts-sync attachments of the session's SECONDARY
|
|
20
|
+
* namespaces (see `attachSecondaryAccountSync`); set while connected,
|
|
21
|
+
* cleared together with `lifecycleTeardown`.
|
|
22
|
+
*/
|
|
23
|
+
private secondaryAccountSyncTeardowns;
|
|
18
24
|
/**
|
|
19
25
|
* Abort handle for the CURRENT in-flight connect attempt. A re-entrant
|
|
20
26
|
* connect() aborts this before starting, so a superseded attempt's URI poll
|
|
@@ -27,6 +33,14 @@ export declare class ConnectionService {
|
|
|
27
33
|
connect(connectionMode: ConnectionMode, walletId: string, networkId?: NetworkId, options?: ServiceOptions): Promise<void>;
|
|
28
34
|
/** Wire the active connector's lifecycle stream onto the bus (or signal absence). */
|
|
29
35
|
private attachLifecycle;
|
|
36
|
+
/**
|
|
37
|
+
* Apply a REAL account-list change (from `Connector.onAccountsChanged`, via
|
|
38
|
+
* the lifecycle bridge's second stream) to the session. `namespace` is the
|
|
39
|
+
* namespace of the provider that reported the change — `activeAddress`
|
|
40
|
+
* only moves when that matches the session's currently active network; an
|
|
41
|
+
* empty list is a full, wallet-initiated disconnect.
|
|
42
|
+
*/
|
|
43
|
+
private handleAccountsChanged;
|
|
30
44
|
/**
|
|
31
45
|
* Remove the active provider-lifecycle subscription (EIP-1193 `.on` / wallet-
|
|
32
46
|
* adapter / SignClient listeners) WITHOUT disconnecting the wallet. Idempotent.
|
|
@@ -44,12 +58,41 @@ export declare class ConnectionService {
|
|
|
44
58
|
* Safe no-op when nothing is connected.
|
|
45
59
|
*/
|
|
46
60
|
reattachLifecycle(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Attach account-sync for every OTHER namespace the session's
|
|
63
|
+
* `availableAddresses` span. `attachLifecycle` observes only the ACTIVE
|
|
64
|
+
* network's namespace, but the cross-namespace gather seeds addresses from
|
|
65
|
+
* other namespaces' live surfaces at connect time — without their own
|
|
66
|
+
* subscription, a wallet-side account switch on such a namespace is never
|
|
67
|
+
* observed and the session serves the connect-time addresses forever (e.g.
|
|
68
|
+
* a Solana-active MetaMask session whose eip155 addresses never follow the
|
|
69
|
+
* extension's account switch).
|
|
70
|
+
*
|
|
71
|
+
* Accounts-sync ONLY, no lifecycle-telemetry stream: the active namespace
|
|
72
|
+
* stays the single source of wallet* telemetry and of the wallet-initiated
|
|
73
|
+
* disconnect signal.
|
|
74
|
+
*/
|
|
75
|
+
private attachSecondaryAccountSync;
|
|
47
76
|
private connectWithURIPoll;
|
|
48
77
|
private getConnector;
|
|
49
78
|
private findWallet;
|
|
50
79
|
private getProviderForMode;
|
|
51
80
|
private validateAndDetermineNetwork;
|
|
52
81
|
disconnect(options?: ServiceOptions): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Clears core's own local state (session, active connector reference,
|
|
84
|
+
* lifecycle subscription) and emits the disconnect events. Does NOT itself
|
|
85
|
+
* call the connector's `disconnect()` — that happens in each CALLER,
|
|
86
|
+
* because the two callers need different semantics: the public
|
|
87
|
+
* `disconnect()` above awaits it (the caller may care whether the wallet
|
|
88
|
+
* side actually tore down); the wallet-initiated path in
|
|
89
|
+
* `handleAccountsChanged` fires it and swallows the result (the wallet
|
|
90
|
+
* already ended the session on its own side, but the connector's own
|
|
91
|
+
* LOCAL state — e.g. a cached account/uuid — still needs clearing, or a
|
|
92
|
+
* later connect to a different wallet reads it as stale and never
|
|
93
|
+
* rebinds).
|
|
94
|
+
*/
|
|
95
|
+
private finishDisconnect;
|
|
53
96
|
getConnectionURI(): string | undefined;
|
|
54
97
|
getWallets(): WalletMetadata[];
|
|
55
98
|
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,qBAAa,iBAAiB;
|
|
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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