miakapi 3.0.31 → 4.0.0-alpha.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.
Files changed (124) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +358 -0
  3. package/contracts/miakapp-v3.json +6 -0
  4. package/dist/access-token-provider.d.ts +8 -0
  5. package/dist/access-token-provider.d.ts.map +1 -0
  6. package/dist/access-token-provider.js +167 -0
  7. package/dist/access-token-provider.js.map +1 -0
  8. package/dist/api.d.ts +224 -0
  9. package/dist/api.d.ts.map +1 -0
  10. package/dist/api.js +47 -0
  11. package/dist/api.js.map +1 -0
  12. package/dist/browser-api.d.ts +113 -0
  13. package/dist/browser-api.d.ts.map +1 -0
  14. package/dist/browser-api.js +2 -0
  15. package/dist/browser-api.js.map +1 -0
  16. package/dist/browser-client.d.ts +3 -0
  17. package/dist/browser-client.d.ts.map +1 -0
  18. package/dist/browser-client.js +678 -0
  19. package/dist/browser-client.js.map +1 -0
  20. package/dist/browser-relay-credential-provider.d.ts +3 -0
  21. package/dist/browser-relay-credential-provider.d.ts.map +1 -0
  22. package/dist/browser-relay-credential-provider.js +243 -0
  23. package/dist/browser-relay-credential-provider.js.map +1 -0
  24. package/dist/browser.d.ts +4 -0
  25. package/dist/browser.d.ts.map +1 -0
  26. package/dist/browser.js +4 -0
  27. package/dist/browser.js.map +1 -0
  28. package/dist/coordinator.d.ts +3 -0
  29. package/dist/coordinator.d.ts.map +1 -0
  30. package/dist/coordinator.js +544 -0
  31. package/dist/coordinator.js.map +1 -0
  32. package/dist/index.d.ts +4 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +4 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/internal/browser-errors.d.ts +31 -0
  37. package/dist/internal/browser-errors.d.ts.map +1 -0
  38. package/dist/internal/browser-errors.js +69 -0
  39. package/dist/internal/browser-errors.js.map +1 -0
  40. package/dist/internal/browser-socket.d.ts +8 -0
  41. package/dist/internal/browser-socket.d.ts.map +1 -0
  42. package/dist/internal/browser-socket.js +204 -0
  43. package/dist/internal/browser-socket.js.map +1 -0
  44. package/dist/internal/calls.d.ts +33 -0
  45. package/dist/internal/calls.d.ts.map +1 -0
  46. package/dist/internal/calls.js +525 -0
  47. package/dist/internal/calls.js.map +1 -0
  48. package/dist/internal/control-plane-response.d.ts +10 -0
  49. package/dist/internal/control-plane-response.d.ts.map +1 -0
  50. package/dist/internal/control-plane-response.js +283 -0
  51. package/dist/internal/control-plane-response.js.map +1 -0
  52. package/dist/internal/declarations.d.ts +62 -0
  53. package/dist/internal/declarations.d.ts.map +1 -0
  54. package/dist/internal/declarations.js +427 -0
  55. package/dist/internal/declarations.js.map +1 -0
  56. package/dist/internal/errors.d.ts +31 -0
  57. package/dist/internal/errors.d.ts.map +1 -0
  58. package/dist/internal/errors.js +72 -0
  59. package/dist/internal/errors.js.map +1 -0
  60. package/dist/internal/events.d.ts +27 -0
  61. package/dist/internal/events.d.ts.map +1 -0
  62. package/dist/internal/events.js +207 -0
  63. package/dist/internal/events.js.map +1 -0
  64. package/dist/internal/presence.d.ts +15 -0
  65. package/dist/internal/presence.d.ts.map +1 -0
  66. package/dist/internal/presence.js +99 -0
  67. package/dist/internal/presence.js.map +1 -0
  68. package/dist/internal/resources.d.ts +33 -0
  69. package/dist/internal/resources.d.ts.map +1 -0
  70. package/dist/internal/resources.js +136 -0
  71. package/dist/internal/resources.js.map +1 -0
  72. package/dist/internal/runtime.d.ts +34 -0
  73. package/dist/internal/runtime.d.ts.map +1 -0
  74. package/dist/internal/runtime.js +17 -0
  75. package/dist/internal/runtime.js.map +1 -0
  76. package/dist/internal/session.d.ts +33 -0
  77. package/dist/internal/session.d.ts.map +1 -0
  78. package/dist/internal/session.js +199 -0
  79. package/dist/internal/session.js.map +1 -0
  80. package/dist/internal/socket.d.ts +6 -0
  81. package/dist/internal/socket.d.ts.map +1 -0
  82. package/dist/internal/socket.js +176 -0
  83. package/dist/internal/socket.js.map +1 -0
  84. package/dist/internal/state.d.ts +21 -0
  85. package/dist/internal/state.d.ts.map +1 -0
  86. package/dist/internal/state.js +133 -0
  87. package/dist/internal/state.js.map +1 -0
  88. package/dist/internal/user-calls.d.ts +27 -0
  89. package/dist/internal/user-calls.d.ts.map +1 -0
  90. package/dist/internal/user-calls.js +325 -0
  91. package/dist/internal/user-calls.js.map +1 -0
  92. package/dist/internal/user-session.d.ts +36 -0
  93. package/dist/internal/user-session.d.ts.map +1 -0
  94. package/dist/internal/user-session.js +250 -0
  95. package/dist/internal/user-session.js.map +1 -0
  96. package/dist/internal/user-state.d.ts +21 -0
  97. package/dist/internal/user-state.d.ts.map +1 -0
  98. package/dist/internal/user-state.js +240 -0
  99. package/dist/internal/user-state.js.map +1 -0
  100. package/dist/internal/validation.d.ts +32 -0
  101. package/dist/internal/validation.d.ts.map +1 -0
  102. package/dist/internal/validation.js +553 -0
  103. package/dist/internal/validation.js.map +1 -0
  104. package/dist/protocol/codec.d.ts +75 -0
  105. package/dist/protocol/codec.d.ts.map +1 -0
  106. package/dist/protocol/codec.js +1091 -0
  107. package/dist/protocol/codec.js.map +1 -0
  108. package/dist/protocol/session.d.ts +14 -0
  109. package/dist/protocol/session.d.ts.map +1 -0
  110. package/dist/protocol/session.js +125 -0
  111. package/dist/protocol/session.js.map +1 -0
  112. package/dist/protocol/user-session.d.ts +14 -0
  113. package/dist/protocol/user-session.d.ts.map +1 -0
  114. package/dist/protocol/user-session.js +116 -0
  115. package/dist/protocol/user-session.js.map +1 -0
  116. package/package.json +57 -9
  117. package/.eslintrc.js +0 -16
  118. package/.gitattributes +0 -2
  119. package/main.js +0 -305
  120. package/miakode.js +0 -56
  121. package/screenshots/bigGrid.jpg +0 -0
  122. package/screenshots/formExample.jpg +0 -0
  123. package/screenshots/properties&table.jpg +0 -0
  124. package/test.js +0 -45
@@ -0,0 +1,544 @@
1
+ import { Opcode } from './protocol/codec.js';
2
+ import { AccessManager, DeclarationManager, } from './internal/declarations.js';
3
+ import { cancelled, CoordinatorError, internalFailure, invalidLifecycle, protocolFailure, relayFailure, safeLog, unavailable, } from './internal/errors.js';
4
+ import { EventManager } from './internal/events.js';
5
+ import { CallManager, FunctionManager } from './internal/calls.js';
6
+ import { PresenceManager } from './internal/presence.js';
7
+ import { childAbortController, createDeferred, IdSequence, ListenerSet, } from './internal/resources.js';
8
+ import { delay } from './internal/runtime.js';
9
+ import { RelaySession } from './internal/session.js';
10
+ import { createProductionRuntime } from './internal/socket.js';
11
+ import { StateManager } from './internal/state.js';
12
+ import { validateAccessToken, validateConfiguration, validateCoordinatorOptions, validateStartOptions, validateStopOptions, } from './internal/validation.js';
13
+ const FIRST_RECONNECT_CEILING_MS = 1_000;
14
+ const MAX_RECONNECT_CEILING_MS = 30_000;
15
+ /**
16
+ * A session must hold for this long before it counts as healthy. Sessions that
17
+ * end sooner keep the backoff growing, so a coordinator that is repeatedly
18
+ * displaced — two deployments briefly sharing one home, for instance — backs
19
+ * off instead of racing the relay at full speed.
20
+ */
21
+ const STABLE_SESSION_MS = 30_000;
22
+ function relayInteger(frame, index, label) {
23
+ const value = frame.payload[index];
24
+ if (typeof value !== 'number' || !Number.isSafeInteger(value)) {
25
+ throw protocolFailure(`${label} is not an integer`);
26
+ }
27
+ return value;
28
+ }
29
+ function relayBoolean(frame, index, label) {
30
+ const value = frame.payload[index];
31
+ if (typeof value !== 'boolean')
32
+ throw protocolFailure(`${label} is not a boolean`);
33
+ return value;
34
+ }
35
+ class CoordinatorImpl {
36
+ #options;
37
+ #runtime;
38
+ #lifecycleListeners = new ListenerSet();
39
+ #errorListeners = new ListenerSet();
40
+ #declarations;
41
+ #loopController = new AbortController();
42
+ state;
43
+ access;
44
+ events;
45
+ functions;
46
+ calls;
47
+ presence;
48
+ errors;
49
+ #status = 'idle';
50
+ #started = false;
51
+ #configured = false;
52
+ #session;
53
+ #sessionEnd;
54
+ #startDeferred;
55
+ #stopDeferred;
56
+ #stopTimer;
57
+ #loopTask;
58
+ #startSignal;
59
+ #startAbort;
60
+ #tokenRequest;
61
+ #reauthentication;
62
+ #reauthTimer;
63
+ #requestIds = new IdSequence();
64
+ #eventIds = new IdSequence();
65
+ #callIds = new IdSequence();
66
+ #localEventIds = new IdSequence();
67
+ #localCallIds = new IdSequence();
68
+ #reconnectAttempt = 0;
69
+ #sessionEstablishedAtMs;
70
+ #relayHost;
71
+ #goawayRetryAfterMs;
72
+ constructor(options, runtime) {
73
+ this.#options = options;
74
+ this.#runtime = runtime;
75
+ this.#declarations = new DeclarationManager(this);
76
+ this.state = new StateManager(this, this.#declarations);
77
+ this.access = new AccessManager(this.#declarations);
78
+ this.events = new EventManager(this, this.#declarations);
79
+ this.functions = new FunctionManager(this.#declarations);
80
+ this.calls = new CallManager(this);
81
+ this.presence = new PresenceManager(this);
82
+ this.errors = Object.freeze({
83
+ subscribe: (listener) => {
84
+ if (typeof listener !== 'function')
85
+ throw new TypeError('error listener must be a function');
86
+ return this.#errorListeners.subscribe(listener);
87
+ },
88
+ });
89
+ }
90
+ get status() {
91
+ return this.#status;
92
+ }
93
+ configure(configuration) {
94
+ if (this.#started || this.#status !== 'idle' || this.#configured) {
95
+ throw invalidLifecycle('configure may be called once before start');
96
+ }
97
+ this.#declarations.configure(validateConfiguration(configuration));
98
+ this.#configured = true;
99
+ }
100
+ start(options = {}) {
101
+ if (this.#started || this.#status !== 'idle') {
102
+ return Promise.reject(invalidLifecycle('Coordinator has already started or stopped'));
103
+ }
104
+ const signal = validateStartOptions(options);
105
+ if (signal?.aborted === true)
106
+ return Promise.reject(cancelled('not_dispatched'));
107
+ this.#started = true;
108
+ this.#startDeferred = createDeferred();
109
+ if (signal !== undefined) {
110
+ const abort = () => void this.stop();
111
+ this.#startSignal = signal;
112
+ this.#startAbort = abort;
113
+ signal.addEventListener('abort', abort, { once: true });
114
+ }
115
+ this.#loopTask = this.#runConnectionLoop();
116
+ void this.#loopTask.catch((error) => {
117
+ const failure = error instanceof CoordinatorError ? error : internalFailure();
118
+ this.#startDeferred?.reject(failure);
119
+ this.#emitFailure(failure);
120
+ void this.stop();
121
+ });
122
+ return this.#startDeferred.promise;
123
+ }
124
+ stop(options = {}) {
125
+ if (this.#stopDeferred !== undefined)
126
+ return this.#stopDeferred.promise;
127
+ let deadlineMs;
128
+ try {
129
+ deadlineMs = validateStopOptions(options);
130
+ }
131
+ catch (error) {
132
+ return Promise.reject(error);
133
+ }
134
+ this.#stopDeferred = createDeferred();
135
+ const stoppingFailure = cancelled('not_dispatched', 'Coordinator is stopping');
136
+ this.#transition('stopping');
137
+ this.calls.stop();
138
+ this.#declarations.stop();
139
+ this.state.stop(stoppingFailure);
140
+ this.events.stop();
141
+ this.presence.stop();
142
+ this.#clearReauthentication();
143
+ this.#abortTokenRequest();
144
+ this.#loopController.abort(stoppingFailure);
145
+ this.#sessionEnd?.resolve({ failure: stoppingFailure });
146
+ this.#session?.terminate();
147
+ this.#startDeferred?.reject(stoppingFailure);
148
+ const finish = () => this.#finishStop();
149
+ if (this.#loopTask === undefined)
150
+ finish();
151
+ else {
152
+ this.#stopTimer = this.#runtime.setTimer(finish, deadlineMs);
153
+ void this.#loopTask.then(finish, finish);
154
+ }
155
+ return this.#stopDeferred.promise;
156
+ }
157
+ subscribe(listener) {
158
+ if (typeof listener !== 'function')
159
+ throw new TypeError('lifecycle listener must be a function');
160
+ return this.#lifecycleListeners.subscribe(listener);
161
+ }
162
+ nextRequestId() {
163
+ return this.#requestIds.take();
164
+ }
165
+ nextEventId() {
166
+ return this.#eventIds.take();
167
+ }
168
+ nextCallId() {
169
+ return this.#callIds.take();
170
+ }
171
+ nextLocalEventId() {
172
+ return this.#localEventIds.take();
173
+ }
174
+ nextLocalCallId() {
175
+ return this.#localCallIds.take();
176
+ }
177
+ currentSession() {
178
+ return this.#status === 'ready' || this.#status === 'synchronizing'
179
+ ? this.#session
180
+ : undefined;
181
+ }
182
+ readySession() {
183
+ return this.#status === 'ready' ? this.#session : undefined;
184
+ }
185
+ activeDeclarations() {
186
+ return this.#declarations.active;
187
+ }
188
+ runtime() {
189
+ return this.#runtime;
190
+ }
191
+ logger() {
192
+ return this.#options.logger;
193
+ }
194
+ emitFailure(failure) {
195
+ this.#emitFailure(failure);
196
+ }
197
+ synchronizing() {
198
+ this.#transition('synchronizing');
199
+ }
200
+ activeDeclarationsChanged(active) {
201
+ this.calls.setActiveDeclarations(active);
202
+ }
203
+ declarationsReady(_receipt) {
204
+ const session = this.#session;
205
+ if (session === undefined)
206
+ return;
207
+ const ready = session.welcome.readySession;
208
+ this.#transition('ready', ready);
209
+ this.#startDeferred?.resolve(ready);
210
+ }
211
+ declarationFailure(failure, hasActiveConfiguration, hasQueuedSnapshot) {
212
+ this.#emitFailure(failure);
213
+ if (hasActiveConfiguration && !hasQueuedSnapshot && this.#session !== undefined) {
214
+ const ready = this.#session.welcome.readySession;
215
+ this.#transition('ready', ready, failure);
216
+ }
217
+ }
218
+ transportFailure(error) {
219
+ const failure = error instanceof CoordinatorError
220
+ ? error
221
+ : unavailable('Coordinator transport failed');
222
+ this.#sessionEnd?.resolve({ failure });
223
+ this.#session?.terminate();
224
+ }
225
+ async #runConnectionLoop() {
226
+ let reason = 'initial';
227
+ while (!this.#loopController.signal.aborted) {
228
+ let end = {};
229
+ let sessionEnd;
230
+ try {
231
+ this.#transition('connecting');
232
+ if (this.#loopController.signal.aborted)
233
+ break;
234
+ const token = await this.#getAccessToken(reason);
235
+ this.#relayHost = new URL(token.relayUrl).host;
236
+ if (this.#loopController.signal.aborted)
237
+ break;
238
+ this.#transition('authenticating');
239
+ if (this.#loopController.signal.aborted)
240
+ break;
241
+ this.#requestIds = new IdSequence();
242
+ this.#eventIds = new IdSequence();
243
+ this.#callIds = new IdSequence();
244
+ const connectionEnd = createDeferred();
245
+ sessionEnd = connectionEnd;
246
+ this.#sessionEnd = connectionEnd;
247
+ this.#goawayRetryAfterMs = undefined;
248
+ const session = await RelaySession.connect(this.#runtime, this.#options.name, token.relayUrl, token.token, this.#loopController.signal, {
249
+ frame: (frame) => this.#handleFrame(frame),
250
+ closed: () => {
251
+ const retryAfterMs = this.#goawayRetryAfterMs;
252
+ connectionEnd.resolve(retryAfterMs === undefined ? {} : { retryAfterMs });
253
+ },
254
+ failed: (error) => connectionEnd.resolve({
255
+ failure: error instanceof CoordinatorError
256
+ ? error
257
+ : unavailable('Relay connection failed'),
258
+ }),
259
+ });
260
+ if (this.#loopController.signal.aborted) {
261
+ session.terminate();
262
+ session.detach();
263
+ break;
264
+ }
265
+ this.#session = session;
266
+ this.#sessionEstablishedAtMs = this.#runtime.now();
267
+ this.#scheduleReauthentication(Math.min(token.expiresAtMs, session.welcome.expiresAtMs));
268
+ this.#declarations.synchronize(session);
269
+ if (this.#loopController.signal.aborted) {
270
+ session.terminate();
271
+ break;
272
+ }
273
+ session.startDelivery();
274
+ end = await connectionEnd.promise;
275
+ }
276
+ catch (error) {
277
+ if (this.#loopController.signal.aborted)
278
+ break;
279
+ end = sessionEnd?.settled === true
280
+ ? await sessionEnd.promise
281
+ : { failure: error instanceof CoordinatorError ? error : unavailable('Connection attempt failed') };
282
+ }
283
+ this.#disconnectSession();
284
+ if (this.#loopController.signal.aborted)
285
+ break;
286
+ if (end.failure !== undefined)
287
+ this.#emitFailure(end.failure);
288
+ this.#transition('reconnecting', undefined, end.failure);
289
+ const establishedAtMs = this.#sessionEstablishedAtMs;
290
+ this.#sessionEstablishedAtMs = undefined;
291
+ if (establishedAtMs !== undefined && this.#runtime.now() - establishedAtMs >= STABLE_SESSION_MS) {
292
+ this.#reconnectAttempt = 0;
293
+ }
294
+ const ceiling = Math.min(FIRST_RECONNECT_CEILING_MS * (2 ** this.#reconnectAttempt), MAX_RECONNECT_CEILING_MS);
295
+ this.#reconnectAttempt += 1;
296
+ const randomDelay = Math.floor(this.#runtime.random() * (ceiling + 1));
297
+ const reconnectDelay = Math.max(randomDelay, end.retryAfterMs ?? 0);
298
+ try {
299
+ await delay(this.#runtime, reconnectDelay, this.#loopController.signal);
300
+ }
301
+ catch {
302
+ break;
303
+ }
304
+ reason = 'reconnect';
305
+ }
306
+ }
307
+ async #getAccessToken(reason) {
308
+ if (this.#tokenRequest !== undefined)
309
+ return this.#tokenRequest.promise;
310
+ const child = childAbortController(this.#loopController.signal);
311
+ const request = this.#relayHost === undefined
312
+ ? Object.freeze({
313
+ coordinatorName: this.#options.name,
314
+ reason,
315
+ signal: child.controller.signal,
316
+ })
317
+ : Object.freeze({
318
+ coordinatorName: this.#options.name,
319
+ reason,
320
+ relayHost: this.#relayHost,
321
+ signal: child.controller.signal,
322
+ });
323
+ const promise = Promise.resolve()
324
+ .then(() => this.#options.accessTokenProvider.getAccessToken(request))
325
+ .then((value) => validateAccessToken(value, this.#runtime.now()));
326
+ const tokenRequest = {
327
+ controller: child.controller,
328
+ dispose: child.dispose,
329
+ promise,
330
+ };
331
+ this.#tokenRequest = tokenRequest;
332
+ void promise.finally(() => {
333
+ if (this.#tokenRequest !== tokenRequest)
334
+ return;
335
+ child.dispose();
336
+ this.#tokenRequest = undefined;
337
+ }).catch(() => undefined);
338
+ return promise;
339
+ }
340
+ #abortTokenRequest() {
341
+ const request = this.#tokenRequest;
342
+ if (request === undefined)
343
+ return;
344
+ request.controller.abort(cancelled('not_dispatched'));
345
+ request.dispose();
346
+ this.#tokenRequest = undefined;
347
+ }
348
+ #scheduleReauthentication(expiresAtMs) {
349
+ this.#clearReauthentication();
350
+ if (this.#status === 'draining'
351
+ || this.#status === 'stopping'
352
+ || this.#status === 'stopped')
353
+ return;
354
+ const remaining = Math.max(0, expiresAtMs - this.#runtime.now());
355
+ const lead = Math.min(30_000, Math.floor(remaining / 2));
356
+ this.#reauthTimer = this.#runtime.setTimer(() => {
357
+ void this.#reauthenticate();
358
+ }, Math.max(0, remaining - lead));
359
+ }
360
+ async #reauthenticate() {
361
+ const session = this.#session;
362
+ if (session === undefined || this.#loopController.signal.aborted)
363
+ return;
364
+ try {
365
+ const token = await this.#getAccessToken('reauth');
366
+ if (!this.#mayReauthenticate(session))
367
+ return;
368
+ if (new URL(token.relayUrl).host !== this.#relayHost) {
369
+ throw new TypeError('Reauthentication cannot change relay host');
370
+ }
371
+ const requestId = this.nextRequestId();
372
+ const deferred = createDeferred();
373
+ this.#reauthentication = { requestId, deferred };
374
+ await session.send({ opcode: Opcode.Reauth, payload: [requestId, token.token] });
375
+ const relayExpiry = await deferred.promise;
376
+ if (!this.#mayReauthenticate(session))
377
+ return;
378
+ this.#scheduleReauthentication(Math.min(token.expiresAtMs, relayExpiry));
379
+ }
380
+ catch (error) {
381
+ if (this.#mayReauthenticate(session))
382
+ this.transportFailure(error);
383
+ }
384
+ }
385
+ #mayReauthenticate(session) {
386
+ return this.#session === session
387
+ && !this.#loopController.signal.aborted
388
+ && this.#status !== 'draining';
389
+ }
390
+ #clearReauthentication() {
391
+ this.#reauthTimer?.cancel();
392
+ this.#reauthTimer = undefined;
393
+ this.#reauthentication?.deferred.reject(cancelled('not_dispatched'));
394
+ this.#reauthentication = undefined;
395
+ }
396
+ #handleFrame(frame) {
397
+ try {
398
+ if (frame.opcode === Opcode.Error) {
399
+ this.#handleRelayError(frame);
400
+ return;
401
+ }
402
+ if (frame.opcode === Opcode.Fatal) {
403
+ const code = relayInteger(frame, 1, 'FATAL.code');
404
+ const retryable = relayBoolean(frame, 2, 'FATAL.retryable');
405
+ const failure = relayFailure(code, retryable, 'not_dispatched');
406
+ if (retryable)
407
+ this.transportFailure(failure);
408
+ else {
409
+ this.#emitFailure(failure);
410
+ this.#startDeferred?.reject(failure);
411
+ void this.stop();
412
+ }
413
+ return;
414
+ }
415
+ if (frame.opcode === Opcode.ReauthOk) {
416
+ const requestId = relayInteger(frame, 0, 'REAUTH_OK.requestId');
417
+ if (this.#reauthentication?.requestId !== requestId) {
418
+ throw protocolFailure('REAUTH_OK is not correlated');
419
+ }
420
+ const expiresAtMs = relayInteger(frame, 1, 'REAUTH_OK.expiresAtMs');
421
+ if (expiresAtMs <= this.#runtime.now()) {
422
+ throw protocolFailure('REAUTH_OK expiry is not in the future');
423
+ }
424
+ this.#reauthentication.deferred.resolve(expiresAtMs);
425
+ this.#reauthentication = undefined;
426
+ return;
427
+ }
428
+ if (frame.opcode === Opcode.Goaway) {
429
+ this.#transition('draining');
430
+ this.#reauthTimer?.cancel();
431
+ this.#reauthTimer = undefined;
432
+ this.#abortTokenRequest();
433
+ this.#goawayRetryAfterMs = relayInteger(frame, 0, 'GOAWAY.retryAfterMs');
434
+ return;
435
+ }
436
+ if (frame.opcode === Opcode.StateDict || frame.opcode === Opcode.TopicDict)
437
+ return;
438
+ if (this.#declarations.handleFrame(frame)
439
+ || this.state.handleFrame(frame)
440
+ || this.events.handleFrame(frame)
441
+ || this.calls.handleFrame(frame)
442
+ || this.presence.handleFrame(frame))
443
+ return;
444
+ throw protocolFailure('Relay sent an unsupported coordinator frame');
445
+ }
446
+ catch (error) {
447
+ const failure = error instanceof CoordinatorError ? error : protocolFailure();
448
+ this.transportFailure(failure);
449
+ }
450
+ }
451
+ #handleRelayError(frame) {
452
+ const correlationId = relayInteger(frame, 0, 'ERROR.correlationId');
453
+ const sourceOpcode = relayInteger(frame, 1, 'ERROR.sourceOpcode');
454
+ const code = relayInteger(frame, 2, 'ERROR.code');
455
+ const retryable = relayBoolean(frame, 3, 'ERROR.retryable');
456
+ if (sourceOpcode === Opcode.Event && this.events.handleError(correlationId, code, retryable))
457
+ return;
458
+ if (sourceOpcode === Opcode.StateSet && this.state.handleError(correlationId, code, retryable))
459
+ return;
460
+ if ((sourceOpcode === Opcode.StateSync
461
+ || sourceOpcode === Opcode.StateAclSync
462
+ || sourceOpcode === Opcode.EventSync
463
+ || sourceOpcode === Opcode.EventAclSync
464
+ || sourceOpcode === Opcode.FunctionSync)
465
+ && this.#declarations.handleError(correlationId, code, retryable))
466
+ return;
467
+ if ((sourceOpcode === Opcode.Call
468
+ || sourceOpcode === Opcode.CallCancel
469
+ || sourceOpcode === Opcode.CallCredit)
470
+ && this.calls.handleError(correlationId, code, retryable))
471
+ return;
472
+ if ((sourceOpcode === Opcode.CallResult || sourceOpcode === Opcode.CallError)
473
+ && this.calls.handleResponseError(correlationId, code, retryable))
474
+ return;
475
+ if (sourceOpcode === Opcode.Reauth
476
+ && this.#reauthentication?.requestId === correlationId) {
477
+ const failure = relayFailure(code, retryable, 'not_dispatched');
478
+ this.#reauthentication.deferred.reject(failure);
479
+ this.#reauthentication = undefined;
480
+ return;
481
+ }
482
+ if (correlationId !== 0 || sourceOpcode !== 0) {
483
+ throw protocolFailure('ERROR is not correlated to an active operation');
484
+ }
485
+ this.#emitFailure(relayFailure(code, retryable, 'not_dispatched'));
486
+ }
487
+ #disconnectSession() {
488
+ this.#clearReauthentication();
489
+ this.#abortTokenRequest();
490
+ this.#declarations.disconnected();
491
+ this.state.disconnected();
492
+ this.events.disconnected();
493
+ this.calls.disconnected();
494
+ this.presence.disconnected();
495
+ this.#session?.detach();
496
+ this.#session = undefined;
497
+ this.#sessionEnd = undefined;
498
+ this.#goawayRetryAfterMs = undefined;
499
+ }
500
+ #emitFailure(failure) {
501
+ this.#errorListeners.emit(failure, () => {
502
+ safeLog(this.#options.logger, { level: 'error', event: 'error_listener_failed' });
503
+ });
504
+ }
505
+ #transition(current, session, reason) {
506
+ if (this.#status === current)
507
+ return;
508
+ const previous = this.#status;
509
+ this.#status = current;
510
+ const event = session === undefined && reason === undefined
511
+ ? Object.freeze({ previous, current })
512
+ : session === undefined
513
+ ? Object.freeze({ previous, current, reason })
514
+ : reason === undefined
515
+ ? Object.freeze({ previous, current, session })
516
+ : Object.freeze({ previous, current, session, reason });
517
+ safeLog(this.#options.logger, { level: 'info', event: 'status_changed', status: current });
518
+ this.#lifecycleListeners.emit(event, () => {
519
+ safeLog(this.#options.logger, { level: 'error', event: 'lifecycle_listener_failed' });
520
+ });
521
+ }
522
+ #finishStop() {
523
+ if (this.#status === 'stopped')
524
+ return;
525
+ this.#stopTimer?.cancel();
526
+ this.#stopTimer = undefined;
527
+ this.#disconnectSession();
528
+ if (this.#startSignal !== undefined && this.#startAbort !== undefined) {
529
+ this.#startSignal.removeEventListener('abort', this.#startAbort);
530
+ }
531
+ this.#transition('stopped');
532
+ this.#stopDeferred?.resolve();
533
+ this.#lifecycleListeners.clear();
534
+ this.#errorListeners.clear();
535
+ }
536
+ }
537
+ export function createCoordinator(options) {
538
+ return new CoordinatorImpl(validateCoordinatorOptions(options), createProductionRuntime());
539
+ }
540
+ /** @internal */
541
+ export function createCoordinatorWithRuntime(options, runtime) {
542
+ return new CoordinatorImpl(validateCoordinatorOptions(options), runtime);
543
+ }
544
+ //# sourceMappingURL=coordinator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinator.js","sourceRoot":"","sources":["../src/coordinator.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,MAAM,EAAc,MAAM,qBAAqB,CAAC;AACzD,OAAO,EACL,aAAa,EACb,kBAAkB,GAGnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,OAAO,EACP,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAkB,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAiB,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAqB,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,UAAU,EACV,WAAW,GAEZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,EAA8C,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAkB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,EAC1B,oBAAoB,EACpB,mBAAmB,GACpB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AAE,2BAA2B,EAAE,CAAC,CAAC;QACxF,CAAC,CAAC,CAAC;IACL,CAAC;IAED,WAAW;QACT,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;YAAE,OAAO;QACvC,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC1B,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACtE,IAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACnE,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QAC5B,IAAI,CAAC,aAAa,EAAE,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;CACF;AAED,MAAM,UAAU,iBAAiB,CAAC,OAA2B;IAC3D,OAAO,IAAI,eAAe,CAAC,0BAA0B,CAAC,OAAO,CAAC,EAAE,uBAAuB,EAAE,CAAC,CAAC;AAC7F,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,4BAA4B,CAC1C,OAA2B,EAC3B,OAA2B;IAE3B,OAAO,IAAI,eAAe,CAAC,0BAA0B,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './api.js';
2
+ export * from './access-token-provider.js';
3
+ export { createCoordinator } from './coordinator.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from './api.js';
2
+ export * from './access-token-provider.js';
3
+ export { createCoordinator } from './coordinator.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { BrowserClientFailure, BrowserClientLogRecord, BrowserClientLogger } from '../browser-api.js';
2
+ import type { DispatchOutcome } from '../api.js';
3
+ interface FailureOptions {
4
+ readonly code?: number;
5
+ readonly retryable?: boolean;
6
+ readonly correlation?: {
7
+ readonly kind: 'call';
8
+ readonly localId: string;
9
+ };
10
+ }
11
+ export declare class BrowserClientError extends Error implements BrowserClientFailure {
12
+ readonly kind: BrowserClientFailure['kind'];
13
+ readonly retryable: boolean;
14
+ readonly outcome: DispatchOutcome;
15
+ readonly code?: number;
16
+ readonly correlation?: {
17
+ readonly kind: 'call';
18
+ readonly localId: string;
19
+ };
20
+ constructor(kind: BrowserClientFailure['kind'], outcome: DispatchOutcome, message: string, options?: FailureOptions);
21
+ }
22
+ export declare function browserInvalidLifecycle(message: string): BrowserClientError;
23
+ export declare function browserUnavailable(message?: string): BrowserClientError;
24
+ export declare function browserCancelled(outcome: 'not_dispatched' | 'outcome_unknown', message?: string): BrowserClientError;
25
+ export declare function browserOutcomeUnknown(message?: string): BrowserClientError;
26
+ export declare function browserInternalFailure(): BrowserClientError;
27
+ export declare function browserProtocolFailure(message?: string): BrowserClientError;
28
+ export declare function browserRelayFailure(code: number, retryable: boolean, outcome: DispatchOutcome, correlation?: FailureOptions['correlation']): BrowserClientError;
29
+ export declare function safeBrowserLog(logger: BrowserClientLogger | undefined, record: BrowserClientLogRecord): void;
30
+ export {};
31
+ //# sourceMappingURL=browser-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-errors.d.ts","sourceRoot":"","sources":["../../src/internal/browser-errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,UAAU,cAAc;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE;QACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH;AAED,qBAAa,kBAAmB,SAAQ,KAAM,YAAW,oBAAoB;IAC3E,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC5C,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE;QACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;KAC1B,CAAC;IAEF,YACE,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,EAClC,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,cAAmB,EAW7B;CACF;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAE3E;AAED,wBAAgB,kBAAkB,CAAC,OAAO,SAAgC,GAAG,kBAAkB,CAE9F;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EA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