@attraccess/plugins-backend-sdk 1.11.0-beta.0 → 1.11.0-beta.2

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.
Files changed (45) hide show
  1. package/package.json +8 -8
  2. package/src/index.d.ts +4 -0
  3. package/src/index.js +4 -0
  4. package/src/index.js.map +1 -1
  5. package/src/internal.d.ts +6 -0
  6. package/src/internal.js +11 -0
  7. package/src/internal.js.map +1 -0
  8. package/src/lib/auth-decorator.d.ts +4 -3
  9. package/src/lib/auth-decorator.js.map +1 -1
  10. package/src/lib/auth.types.d.ts +5 -1
  11. package/src/lib/dual-auth.guard.js +4 -0
  12. package/src/lib/dual-auth.guard.js.map +1 -1
  13. package/src/lib/plugin-audit.d.ts +16 -2
  14. package/src/lib/plugin-audit.js +8 -3
  15. package/src/lib/plugin-audit.js.map +1 -1
  16. package/src/lib/plugin-backend-module.d.ts +15 -1
  17. package/src/lib/plugin-ble-fake-clock.d.ts +15 -0
  18. package/src/lib/plugin-ble-fake-clock.js +52 -0
  19. package/src/lib/plugin-ble-fake-clock.js.map +1 -0
  20. package/src/lib/plugin-ble-fake.d.ts +102 -0
  21. package/src/lib/plugin-ble-fake.js +424 -0
  22. package/src/lib/plugin-ble-fake.js.map +1 -0
  23. package/src/lib/plugin-ble-notification-stream.d.ts +30 -0
  24. package/src/lib/plugin-ble-notification-stream.js +123 -0
  25. package/src/lib/plugin-ble-notification-stream.js.map +1 -0
  26. package/src/lib/plugin-ble-session-engine.d.ts +151 -0
  27. package/src/lib/plugin-ble-session-engine.js +465 -0
  28. package/src/lib/plugin-ble-session-engine.js.map +1 -0
  29. package/src/lib/plugin-ble-validation.d.ts +71 -0
  30. package/src/lib/plugin-ble-validation.js +453 -0
  31. package/src/lib/plugin-ble-validation.js.map +1 -0
  32. package/src/lib/plugin-ble.d.ts +258 -0
  33. package/src/lib/plugin-ble.js +88 -0
  34. package/src/lib/plugin-ble.js.map +1 -0
  35. package/src/lib/plugin-context.d.ts +6 -0
  36. package/src/lib/plugin-context.js.map +1 -1
  37. package/src/lib/plugin-permissions.d.ts +65 -0
  38. package/src/lib/plugin-permissions.js +107 -0
  39. package/src/lib/plugin-permissions.js.map +1 -0
  40. package/src/lib/plugin-resource-access.d.ts +2 -1
  41. package/src/lib/plugin.interface.d.ts +20 -2
  42. package/src/lib/plugin.interface.js +8 -0
  43. package/src/lib/plugin.interface.js.map +1 -1
  44. package/src/lib/reader-ui.d.ts +42 -0
  45. package/src/lib/reader-ui.js.map +1 -1
@@ -0,0 +1,151 @@
1
+ import { PluginBleCallOptions, PluginBleCloseReason, PluginBleError, PluginBleErrorCode, PluginBleNotificationStream, PluginBleProfile, PluginBleSession, PluginBleWriteOptions } from './plugin-ble';
2
+ /**
3
+ * The session state machine shared by the host and the fake transport, so their semantics cannot drift.
4
+ *
5
+ * @internal Building block for the host implementation and `createFakeBleHost`. Plugins never construct it:
6
+ * they receive a `PluginBleSession` from `context.ble`.
7
+ */
8
+ /**
9
+ * A connected peripheral, as the session engine sees it. Receives only validated, normalized primitives.
10
+ * `timeoutMs` is the engine's own deadline for the call, so a transport can enforce it on its side as well.
11
+ */
12
+ export interface BleSessionLink {
13
+ /** Negotiated ATT MTU. A link without one counts as the BLE minimum (23). */
14
+ readonly mtu?: number;
15
+ read(request: {
16
+ serviceUuid: string;
17
+ characteristicUuid: string;
18
+ signal: AbortSignal;
19
+ timeoutMs?: number;
20
+ }): Promise<Uint8Array>;
21
+ write(request: {
22
+ serviceUuid: string;
23
+ characteristicUuid: string;
24
+ value: Uint8Array;
25
+ withoutResponse: boolean;
26
+ signal: AbortSignal;
27
+ timeoutMs?: number;
28
+ }): Promise<void>;
29
+ subscribe(request: {
30
+ serviceUuid: string;
31
+ characteristicUuid: string;
32
+ indicate: boolean;
33
+ signal: AbortSignal;
34
+ timeoutMs?: number;
35
+ onNotification(value: Uint8Array): void;
36
+ /** The transport failed the stream (overflow, malformed or oversized notification); it is torn down. */
37
+ onError?(error: PluginBleError): void;
38
+ }): Promise<void>;
39
+ unsubscribe(request: {
40
+ serviceUuid: string;
41
+ characteristicUuid: string;
42
+ timeoutMs?: number;
43
+ }): Promise<void>;
44
+ disconnect(): Promise<void>;
45
+ /**
46
+ * Registers the callback for a lost link. A link already lost must call it right away. `detail` is a safe
47
+ * diagnostic (e.g. `reader-link-lost`) that pending calls fail with.
48
+ */
49
+ onDisconnected?(listener: (detail?: string) => void): void;
50
+ }
51
+ export interface BleSessionClock {
52
+ now(): number;
53
+ setTimeout(fn: () => void, ms: number): () => void;
54
+ }
55
+ export interface BleSessionEngineDeps {
56
+ id: string;
57
+ endpointId: string;
58
+ profile: PluginBleProfile;
59
+ clock: BleSessionClock;
60
+ connect(signal: AbortSignal, timeoutMs: number): Promise<BleSessionLink>;
61
+ /** Called once the session has fully closed (after the link disconnected or its deadline passed). */
62
+ onClosed(engine: BleSessionEngine): void;
63
+ /**
64
+ * Logging of operation, outcome, duration and, for a failure, its safe `detail` (e.g. `att:0x0a`). Never receives
65
+ * payload bytes.
66
+ */
67
+ log?(operation: string, outcome: string, durationMs: number, detail?: string): void;
68
+ /** A call the engine refused before it reached the link (validation, bounds, closed session). */
69
+ onRejected?(operation: string, error: PluginBleError): void;
70
+ /**
71
+ * The engine failed a notification stream itself: its queue overflowed (`NOTIFICATION_OVERFLOW`) or a notification
72
+ * broke the profile bound. Failures the link reported through `onError` are the link's to count.
73
+ */
74
+ onStreamFailed?(errorCode: PluginBleErrorCode, detail?: string): void;
75
+ }
76
+ /**
77
+ * Session semantics of the contract: one operation at a time in call order, per-call deadlines, a lease,
78
+ * cancellation, bounded notification queues and exactly-once settlement of every pending promise.
79
+ */
80
+ export declare class BleSessionEngine {
81
+ private readonly deps;
82
+ readonly id: string;
83
+ readonly endpointId: string;
84
+ /** Resolves once the session has fully closed: pending calls are settled and the link is released. */
85
+ readonly closed: Promise<{
86
+ reason: PluginBleCloseReason;
87
+ }>;
88
+ /** What plugins get: a frozen object without the link, the dependencies or any other internals. */
89
+ readonly handle: PluginBleSession;
90
+ private state;
91
+ private link;
92
+ private tail;
93
+ private readonly active;
94
+ private readonly subscriptions;
95
+ /** Keys with a queued or running subscribe, so two concurrent subscribes cannot both succeed. */
96
+ private readonly subscribing;
97
+ /** Streams whose subscribe is still running on the link; they already receive notifications. */
98
+ private readonly starting;
99
+ private resolveClosed;
100
+ private readonly connectController;
101
+ private rejectConnect;
102
+ private cancelLease;
103
+ private detachOpenSignal;
104
+ private closing;
105
+ private closeReason;
106
+ /** Why the link was lost, for the DISCONNECTED errors of pending calls. */
107
+ private lostDetail;
108
+ /** Settles once `open()` adopted or released its link. */
109
+ private openSettled;
110
+ /** Settles once the transport's connect call returned and a link that arrived too late was released. */
111
+ private connectWork;
112
+ private connectPending;
113
+ private linkMtu;
114
+ constructor(deps: BleSessionEngineDeps);
115
+ get isClosed(): boolean;
116
+ /** The link's negotiated ATT MTU, kept after the session closed. */
117
+ get mtu(): number;
118
+ /** Connects the link. Rejects, with the session closed, when the connect fails, times out or is cancelled. */
119
+ open(options: {
120
+ signal?: AbortSignal;
121
+ leaseMs: number;
122
+ connectTimeoutMs: number;
123
+ }): Promise<void>;
124
+ private connect;
125
+ /** Disconnects a link; never rejects and never waits longer than the disconnect deadline. */
126
+ private release;
127
+ /** Waits for `work`, but never longer than the disconnect deadline. */
128
+ private bounded;
129
+ /** Called by the transport when the link was lost. */
130
+ linkLost(detail?: string): void;
131
+ close(reason?: PluginBleCloseReason): Promise<void>;
132
+ read(key: string, options?: PluginBleCallOptions): Promise<Uint8Array>;
133
+ write(key: string, value: Uint8Array, options?: PluginBleWriteOptions): Promise<void>;
134
+ subscribe(key: string, options?: {
135
+ signal?: AbortSignal;
136
+ }): Promise<PluginBleNotificationStream>;
137
+ private startSubscription;
138
+ unsubscribe(key: string): Promise<void>;
139
+ private unsubscribeStream;
140
+ /** Removes the subscription of `key` (only if it is `only`, when given) and tells the link. */
141
+ private teardown;
142
+ private deliver;
143
+ private owns;
144
+ private failStream;
145
+ private dropIfEnded;
146
+ /**
147
+ * Queues one operation. `prepare` validates synchronously (before anything is queued or reaches the link) and
148
+ * returns the function that talks to the link.
149
+ */
150
+ private run;
151
+ }
@@ -0,0 +1,465 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BleSessionEngine = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const plugin_ble_1 = require("./plugin-ble");
6
+ const plugin_ble_validation_1 = require("./plugin-ble-validation");
7
+ const plugin_ble_notification_stream_1 = require("./plugin-ble-notification-stream");
8
+ /** How long a close waits for the link to disconnect before the session counts as closed anyway. */
9
+ const DISCONNECT_DEADLINE_MS = plugin_ble_1.PLUGIN_BLE_LIMITS.opTimeoutDefaultMs;
10
+ function closeError(reason, operation, detail) {
11
+ if (reason === 'disconnected') {
12
+ return new plugin_ble_1.PluginBleError('DISCONNECTED', 'The device disconnected', { operation, detail });
13
+ }
14
+ if (reason === 'cancelled')
15
+ return new plugin_ble_1.PluginBleError('CANCELLED', 'The session was cancelled', { operation });
16
+ return new plugin_ble_1.PluginBleError('SESSION_CLOSED', 'The session is closed', { operation, detail: reason });
17
+ }
18
+ const cancelled = plugin_ble_notification_stream_1.cancelledBleCall;
19
+ function normalizeMtu(value) {
20
+ if (typeof value !== 'number' || !Number.isInteger(value))
21
+ return plugin_ble_1.PLUGIN_BLE_LIMITS.mtuMin;
22
+ return Math.min(Math.max(value, plugin_ble_1.PLUGIN_BLE_LIMITS.mtuMin), plugin_ble_1.PLUGIN_BLE_LIMITS.mtuMax);
23
+ }
24
+ /** Calls `fn` so that a synchronous throw becomes a rejection. */
25
+ function attempt(fn) {
26
+ return Promise.resolve().then(fn);
27
+ }
28
+ /**
29
+ * Session semantics of the contract: one operation at a time in call order, per-call deadlines, a lease,
30
+ * cancellation, bounded notification queues and exactly-once settlement of every pending promise.
31
+ */
32
+ class BleSessionEngine {
33
+ constructor(deps) {
34
+ this.deps = deps;
35
+ this.state = 'connecting';
36
+ this.link = null;
37
+ this.tail = Promise.resolve();
38
+ this.active = new Set();
39
+ this.subscriptions = new Map();
40
+ /** Keys with a queued or running subscribe, so two concurrent subscribes cannot both succeed. */
41
+ this.subscribing = new Set();
42
+ /** Streams whose subscribe is still running on the link; they already receive notifications. */
43
+ this.starting = new Map();
44
+ this.connectController = new AbortController();
45
+ this.rejectConnect = null;
46
+ this.cancelLease = null;
47
+ this.detachOpenSignal = null;
48
+ this.closing = null;
49
+ this.closeReason = 'closed';
50
+ /** Settles once `open()` adopted or released its link. */
51
+ this.openSettled = Promise.resolve();
52
+ /** Settles once the transport's connect call returned and a link that arrived too late was released. */
53
+ this.connectWork = Promise.resolve();
54
+ this.connectPending = false;
55
+ this.linkMtu = plugin_ble_1.PLUGIN_BLE_LIMITS.mtuMin;
56
+ this.id = deps.id;
57
+ this.endpointId = deps.endpointId;
58
+ this.closed = new Promise((resolve) => (this.resolveClosed = resolve));
59
+ // eslint-disable-next-line @typescript-eslint/no-this-alias -- the frozen handle reads the live MTU
60
+ const engine = this;
61
+ this.handle = Object.freeze({
62
+ id: this.id,
63
+ endpointId: this.endpointId,
64
+ closed: this.closed,
65
+ get mtu() {
66
+ return engine.mtu;
67
+ },
68
+ read: (key, options) => this.read(key, options),
69
+ write: (key, value, options) => this.write(key, value, options),
70
+ subscribe: (key, options) => this.subscribe(key, options),
71
+ unsubscribe: (key) => this.unsubscribe(key),
72
+ close: () => this.close(),
73
+ });
74
+ }
75
+ get isClosed() {
76
+ return this.state === 'closed';
77
+ }
78
+ /** The link's negotiated ATT MTU, kept after the session closed. */
79
+ get mtu() {
80
+ return this.linkMtu;
81
+ }
82
+ /** Connects the link. Rejects, with the session closed, when the connect fails, times out or is cancelled. */
83
+ open(options) {
84
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
85
+ var _a;
86
+ const { signal } = options;
87
+ if (signal) {
88
+ const onAbort = () => void this.close('cancelled');
89
+ signal.addEventListener('abort', onAbort, { once: true });
90
+ this.detachOpenSignal = () => signal.removeEventListener('abort', onAbort);
91
+ if (signal.aborted)
92
+ onAbort();
93
+ }
94
+ let markOpenSettled;
95
+ this.openSettled = new Promise((resolve) => (markOpenSettled = resolve));
96
+ let link;
97
+ try {
98
+ link = yield this.connect(options.connectTimeoutMs);
99
+ }
100
+ catch (error) {
101
+ const failure = (0, plugin_ble_validation_1.toBleError)(error, 'connect');
102
+ markOpenSettled();
103
+ const closing = this.close(this.state === 'closed' ? this.closeReason : 'error');
104
+ // Report the failure at once. The endpoint stays busy (retryable) until a still-running transport connect
105
+ // returned and its late link was released; otherwise the session is fully closed before we reject.
106
+ if (!this.connectPending)
107
+ yield closing;
108
+ throw failure;
109
+ }
110
+ finally {
111
+ this.rejectConnect = null;
112
+ }
113
+ if (this.state === 'closed') {
114
+ yield this.release(link);
115
+ markOpenSettled();
116
+ yield this.closing;
117
+ throw closeError(this.closeReason, 'connect');
118
+ }
119
+ this.link = link;
120
+ this.linkMtu = normalizeMtu(link.mtu);
121
+ this.state = 'open';
122
+ this.cancelLease = this.deps.clock.setTimeout(() => void this.close('lease-expired'), options.leaseMs);
123
+ try {
124
+ (_a = link.onDisconnected) === null || _a === void 0 ? void 0 : _a.call(link, (detail) => this.linkLost(detail));
125
+ }
126
+ catch (error) {
127
+ markOpenSettled();
128
+ yield this.close('error');
129
+ throw (0, plugin_ble_validation_1.toBleError)(error, 'connect');
130
+ }
131
+ markOpenSettled();
132
+ });
133
+ }
134
+ connect(timeoutMs) {
135
+ return new Promise((resolve, reject) => {
136
+ if (this.state === 'closed')
137
+ return reject(closeError(this.closeReason, 'connect'));
138
+ let settled = false;
139
+ const fail = (error) => {
140
+ settled = true;
141
+ reject(error);
142
+ };
143
+ this.rejectConnect = fail;
144
+ const cancelTimer = this.deps.clock.setTimeout(() => {
145
+ this.connectController.abort();
146
+ fail(new plugin_ble_1.PluginBleError('TIMEOUT', 'Connecting timed out', { operation: 'connect' }));
147
+ }, timeoutMs);
148
+ this.connectPending = true;
149
+ this.connectWork = attempt(() => this.deps.connect(this.connectController.signal, timeoutMs))
150
+ .then((value) => {
151
+ cancelTimer();
152
+ // A link that arrives after the connect already failed must not be leaked.
153
+ if (settled)
154
+ return this.release(value).then(() => void (this.connectPending = false));
155
+ this.connectPending = false;
156
+ settled = true;
157
+ resolve(value);
158
+ }, (error) => {
159
+ cancelTimer();
160
+ this.connectPending = false;
161
+ if (!settled)
162
+ fail((0, plugin_ble_validation_1.toBleError)(error, 'connect'));
163
+ })
164
+ .catch(() => undefined);
165
+ });
166
+ }
167
+ /** Disconnects a link; never rejects and never waits longer than the disconnect deadline. */
168
+ release(link) {
169
+ return new Promise((resolve) => {
170
+ const cancelTimer = this.deps.clock.setTimeout(resolve, DISCONNECT_DEADLINE_MS);
171
+ attempt(() => link.disconnect())
172
+ .catch(() => undefined)
173
+ .then(() => (cancelTimer(), resolve()));
174
+ });
175
+ }
176
+ /** Waits for `work`, but never longer than the disconnect deadline. */
177
+ bounded(work) {
178
+ return new Promise((resolve) => {
179
+ const cancelTimer = this.deps.clock.setTimeout(resolve, DISCONNECT_DEADLINE_MS);
180
+ void work.then(() => (cancelTimer(), resolve()));
181
+ });
182
+ }
183
+ /** Called by the transport when the link was lost. */
184
+ linkLost(detail) {
185
+ if (!this.closing)
186
+ this.lostDetail = typeof detail === 'string' ? detail : undefined;
187
+ void this.close('disconnected');
188
+ }
189
+ close(reason = 'closed') {
190
+ var _a, _b, _c;
191
+ if (this.closing)
192
+ return this.closing;
193
+ let finish;
194
+ // Set first, so a close triggered from inside this one (e.g. a driver reporting the link lost) is a no-op.
195
+ this.closing = new Promise((resolve) => (finish = resolve));
196
+ this.state = 'closed';
197
+ this.closeReason = reason;
198
+ (_a = this.cancelLease) === null || _a === void 0 ? void 0 : _a.call(this);
199
+ (_b = this.detachOpenSignal) === null || _b === void 0 ? void 0 : _b.call(this);
200
+ this.connectController.abort();
201
+ (_c = this.rejectConnect) === null || _c === void 0 ? void 0 : _c.call(this, closeError(reason, 'connect'));
202
+ for (const operation of [...this.active]) {
203
+ operation.controller.abort();
204
+ operation.fail(closeError(reason, 'operation', this.lostDetail));
205
+ }
206
+ for (const { stream } of this.subscriptions.values())
207
+ stream.end(closeError(reason, 'subscribe'));
208
+ for (const stream of this.starting.values())
209
+ stream.end(closeError(reason, 'subscribe'));
210
+ this.subscriptions.clear();
211
+ this.starting.clear();
212
+ this.subscribing.clear();
213
+ const link = this.link;
214
+ this.link = null;
215
+ void (() => tslib_1.__awaiter(this, void 0, void 0, function* () {
216
+ if (link && reason !== 'disconnected')
217
+ yield this.release(link);
218
+ yield this.openSettled;
219
+ yield this.bounded(this.connectWork);
220
+ }))().then(() => {
221
+ // Only now is the endpoint free again, so a reopen never overlaps the old link's disconnect.
222
+ try {
223
+ this.deps.onClosed(this);
224
+ }
225
+ catch (_a) {
226
+ // A failing callback must not keep the session from closing.
227
+ }
228
+ finally {
229
+ this.resolveClosed({ reason });
230
+ finish();
231
+ }
232
+ });
233
+ return this.closing;
234
+ }
235
+ read(key, options = {}) {
236
+ return this.run('read', options, () => {
237
+ const target = (0, plugin_ble_validation_1.prepareBleRead)(this.deps.profile, key);
238
+ return (signal, link, timeoutMs) => tslib_1.__awaiter(this, void 0, void 0, function* () {
239
+ const value = yield link.read({
240
+ serviceUuid: target.serviceUuid,
241
+ characteristicUuid: target.characteristic.uuid,
242
+ signal,
243
+ timeoutMs,
244
+ });
245
+ return (0, plugin_ble_validation_1.checkBleInboundPayload)(target.characteristic, 'read', value);
246
+ });
247
+ });
248
+ }
249
+ write(key, value, options = {}) {
250
+ return this.run('write', options, () => {
251
+ const prepared = (0, plugin_ble_validation_1.prepareBleWrite)(this.deps.profile, key, value, options.withoutResponse === true);
252
+ // A write without response travels in one ATT packet: three bytes of it are the ATT header.
253
+ if (prepared.withoutResponse && prepared.value.byteLength > this.linkMtu - 3) {
254
+ throw new plugin_ble_1.PluginBleError('PAYLOAD_TOO_LARGE', `A write without response to "${prepared.characteristic.key}" exceeds the MTU payload of ${this.linkMtu - 3} bytes`, { operation: 'write', detail: 'exceeds-mtu' });
255
+ }
256
+ return (signal, link, timeoutMs) => link.write({
257
+ serviceUuid: prepared.serviceUuid,
258
+ characteristicUuid: prepared.characteristic.uuid,
259
+ value: prepared.value,
260
+ withoutResponse: prepared.withoutResponse,
261
+ signal,
262
+ timeoutMs,
263
+ });
264
+ });
265
+ }
266
+ subscribe(key, options = {}) {
267
+ let reserved = false;
268
+ const result = this.run('subscribe', options, () => {
269
+ const target = (0, plugin_ble_validation_1.prepareBleSubscribe)(this.deps.profile, key);
270
+ if (this.subscriptions.has(key) || this.subscribing.has(key)) {
271
+ throw new plugin_ble_1.PluginBleError('INVALID_ARGUMENT', `"${key}" is already subscribed`, { operation: 'subscribe' });
272
+ }
273
+ this.subscribing.add(key);
274
+ reserved = true;
275
+ return (signal, link, timeoutMs) => this.startSubscription(key, target, signal, link, timeoutMs);
276
+ });
277
+ if (reserved) {
278
+ const release = () => void this.subscribing.delete(key);
279
+ result.then(release, release);
280
+ }
281
+ return result;
282
+ }
283
+ startSubscription(key, target, signal, link, timeoutMs) {
284
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
285
+ const stream = new plugin_ble_notification_stream_1.BleNotificationStream(key, this.deps.profile.limits.maxNotificationQueue, this.deps.clock, () => this.unsubscribeStream(key, stream));
286
+ const ref = { serviceUuid: target.serviceUuid, characteristicUuid: target.characteristic.uuid };
287
+ // Registered only once the link confirmed it, so a timed-out subscribe never blocks a retry.
288
+ this.starting.set(key, stream);
289
+ try {
290
+ yield link.subscribe(Object.assign(Object.assign({}, ref), { indicate: target.indicate, signal,
291
+ timeoutMs, onNotification: (bytes) => this.deliver(key, stream, target, bytes), onError: (error) => this.failStream(key, stream, target, (0, plugin_ble_validation_1.toBleError)(error, 'subscribe')) }));
292
+ }
293
+ finally {
294
+ if (this.starting.get(key) === stream)
295
+ this.starting.delete(key);
296
+ }
297
+ if (signal.aborted || this.state !== 'open') {
298
+ // Timed out or cancelled while the link call ran: nobody holds this stream. Undo it on the link unless a
299
+ // newer subscribe for the key already took over.
300
+ stream.end(cancelled('next'));
301
+ if (this.link === link && !this.subscriptions.has(key) && !this.starting.has(key))
302
+ yield link.unsubscribe(ref);
303
+ throw cancelled('subscribe');
304
+ }
305
+ // A stream that already failed (overflow during the start) was torn down on the link by `deliver`.
306
+ if (!stream.ended)
307
+ this.subscriptions.set(key, { stream, target });
308
+ return stream.handle;
309
+ });
310
+ }
311
+ unsubscribe(key) {
312
+ return this.run('unsubscribe', {}, () => {
313
+ // Unknown or non-notifying keys are rejected; a valid key without a subscription is a no-op.
314
+ (0, plugin_ble_validation_1.prepareBleSubscribe)(this.deps.profile, key);
315
+ // Looked up when the operation runs, so it applies to a subscribe queued before it.
316
+ return (_signal, link) => this.teardown(key, null, link);
317
+ });
318
+ }
319
+ unsubscribeStream(key, stream) {
320
+ if (this.state !== 'open')
321
+ return Promise.resolve();
322
+ return this.run('unsubscribe', {}, () => (_signal, link) => this.teardown(key, stream, link));
323
+ }
324
+ /** Removes the subscription of `key` (only if it is `only`, when given) and tells the link. */
325
+ teardown(key, only, link) {
326
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
327
+ const subscription = this.subscriptions.get(key);
328
+ if (!subscription || (only && subscription.stream !== only))
329
+ return;
330
+ this.subscriptions.delete(key);
331
+ subscription.stream.end(cancelled('next'));
332
+ yield (link === null || link === void 0 ? void 0 : link.unsubscribe({
333
+ serviceUuid: subscription.target.serviceUuid,
334
+ characteristicUuid: subscription.target.characteristic.uuid,
335
+ }));
336
+ });
337
+ }
338
+ deliver(key, stream, target, bytes) {
339
+ var _a, _b;
340
+ if (!this.owns(key, stream))
341
+ return;
342
+ const wasEnded = stream.ended;
343
+ try {
344
+ stream.push((0, plugin_ble_validation_1.checkBleInboundPayload)(target.characteristic, 'notification', bytes));
345
+ }
346
+ catch (error) {
347
+ stream.end((0, plugin_ble_validation_1.toBleError)(error, 'subscribe'));
348
+ }
349
+ const failure = stream.failure;
350
+ if (!wasEnded && failure) {
351
+ try {
352
+ (_b = (_a = this.deps).onStreamFailed) === null || _b === void 0 ? void 0 : _b.call(_a, failure.code, failure.detail);
353
+ }
354
+ catch (_c) {
355
+ // Reporting never changes the outcome of a stream.
356
+ }
357
+ }
358
+ this.dropIfEnded(key, stream, target);
359
+ }
360
+ owns(key, stream) {
361
+ var _a;
362
+ return ((_a = this.subscriptions.get(key)) === null || _a === void 0 ? void 0 : _a.stream) === stream || this.starting.get(key) === stream;
363
+ }
364
+ failStream(key, stream, target, error) {
365
+ if (!this.owns(key, stream))
366
+ return;
367
+ stream.end(error);
368
+ this.dropIfEnded(key, stream, target);
369
+ }
370
+ dropIfEnded(key, stream, target) {
371
+ if (stream.ended) {
372
+ this.subscriptions.delete(key);
373
+ // Overflow tears the subscription down on the link as well.
374
+ const link = this.link;
375
+ if (link) {
376
+ const ref = { serviceUuid: target.serviceUuid, characteristicUuid: target.characteristic.uuid };
377
+ void attempt(() => link.unsubscribe(ref)).catch(() => undefined);
378
+ }
379
+ }
380
+ }
381
+ /**
382
+ * Queues one operation. `prepare` validates synchronously (before anything is queued or reaches the link) and
383
+ * returns the function that talks to the link.
384
+ */
385
+ run(operation, options, prepare) {
386
+ var _a, _b, _c;
387
+ let execute;
388
+ let timeoutMs;
389
+ try {
390
+ if (this.state !== 'open') {
391
+ throw new plugin_ble_1.PluginBleError('SESSION_CLOSED', 'The session is closed', { operation, detail: this.closeReason });
392
+ }
393
+ timeoutMs = (0, plugin_ble_validation_1.resolveBleTimeout)(options.timeoutMs, plugin_ble_1.PLUGIN_BLE_LIMITS.opTimeoutDefaultMs, plugin_ble_1.PLUGIN_BLE_LIMITS.opTimeoutMaxMs);
394
+ execute = prepare();
395
+ if ((_a = options.signal) === null || _a === void 0 ? void 0 : _a.aborted)
396
+ throw cancelled(operation);
397
+ }
398
+ catch (error) {
399
+ try {
400
+ (_c = (_b = this.deps).onRejected) === null || _c === void 0 ? void 0 : _c.call(_b, operation, (0, plugin_ble_validation_1.toBleError)(error, operation));
401
+ }
402
+ catch (_d) {
403
+ // Reporting never changes the outcome of a call.
404
+ }
405
+ return Promise.reject(error);
406
+ }
407
+ return new Promise((resolve, reject) => {
408
+ var _a;
409
+ let cancelTimer;
410
+ let finished;
411
+ const done = new Promise((resolveDone) => (finished = resolveDone));
412
+ const startedAt = this.deps.clock.now();
413
+ const op = {
414
+ settled: false,
415
+ controller: new AbortController(),
416
+ fail: (error) => settle(() => reject(error), error.code, error.detail),
417
+ };
418
+ const settle = (complete, outcome, detail) => {
419
+ var _a, _b, _c;
420
+ if (op.settled)
421
+ return;
422
+ op.settled = true;
423
+ cancelTimer === null || cancelTimer === void 0 ? void 0 : cancelTimer();
424
+ (_a = options.signal) === null || _a === void 0 ? void 0 : _a.removeEventListener('abort', onAbort);
425
+ this.active.delete(op);
426
+ finished();
427
+ complete();
428
+ try {
429
+ (_c = (_b = this.deps).log) === null || _c === void 0 ? void 0 : _c.call(_b, operation, outcome, this.deps.clock.now() - startedAt, detail);
430
+ }
431
+ catch (_d) {
432
+ // Logging never changes the outcome of an operation.
433
+ }
434
+ };
435
+ const onAbort = () => {
436
+ op.controller.abort();
437
+ op.fail(cancelled(operation));
438
+ };
439
+ (_a = options.signal) === null || _a === void 0 ? void 0 : _a.addEventListener('abort', onAbort, { once: true });
440
+ this.active.add(op);
441
+ const step = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
442
+ const link = this.link;
443
+ if (op.settled || !link)
444
+ return;
445
+ cancelTimer = this.deps.clock.setTimeout(() => {
446
+ op.controller.abort();
447
+ op.fail(new plugin_ble_1.PluginBleError('TIMEOUT', `${operation} timed out`, { operation }));
448
+ }, timeoutMs);
449
+ const call = attempt(() => execute(op.controller.signal, link, timeoutMs)).then((value) => settle(() => resolve(value), 'ok'), (error) => {
450
+ const failure = (0, plugin_ble_validation_1.toBleError)(error, operation);
451
+ // The driver reporting a lost link ends the session; timeouts and cancellations do not.
452
+ if (failure.code === 'DISCONNECTED')
453
+ void this.close('disconnected');
454
+ op.fail(failure);
455
+ });
456
+ // A timed-out or cancelled operation must not block the queue behind a hung link call.
457
+ yield Promise.race([call, done]);
458
+ });
459
+ // The catch keeps the chain usable whatever happens in a step.
460
+ this.tail = this.tail.then(step).catch(() => undefined);
461
+ });
462
+ }
463
+ }
464
+ exports.BleSessionEngine = BleSessionEngine;
465
+ //# sourceMappingURL=plugin-ble-session-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-ble-session-engine.js","sourceRoot":"","sources":["../../../../../libs/plugins-backend-sdk/src/lib/plugin-ble-session-engine.ts"],"names":[],"mappings":";;;;AAAA,6CAUsB;AACtB,mEAOiC;AACjC,qFAA2F;AA4E3F,oGAAoG;AACpG,MAAM,sBAAsB,GAAG,8BAAiB,CAAC,kBAAkB,CAAC;AAWpE,SAAS,UAAU,CAAC,MAA4B,EAAE,SAAiB,EAAE,MAAe;IAClF,IAAI,MAAM,KAAK,cAAc,EAAE,CAAC;QAC9B,OAAO,IAAI,2BAAc,CAAC,cAAc,EAAE,yBAAyB,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9F,CAAC;IACD,IAAI,MAAM,KAAK,WAAW;QAAE,OAAO,IAAI,2BAAc,CAAC,WAAW,EAAE,2BAA2B,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IAC/G,OAAO,IAAI,2BAAc,CAAC,gBAAgB,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AACtG,CAAC;AAED,MAAM,SAAS,GAAG,iDAAgB,CAAC;AAEnC,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC;QAAE,OAAO,8BAAiB,CAAC,MAAM,CAAC;IAC3F,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,8BAAiB,CAAC,MAAM,CAAC,EAAE,8BAAiB,C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