@open-e2ee/signal-protocol-sdk 10.0.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +117 -0
- package/README.md +1 -1
- package/SECURITY.md +2 -2
- package/client/README.md +14 -0
- package/dist/client/client.d.ts +9 -0
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +32 -0
- package/dist/client/client.js.map +1 -1
- package/dist/client/event-hooks.d.ts +36 -0
- package/dist/client/event-hooks.d.ts.map +1 -1
- package/dist/client/event-hooks.js +1 -0
- package/dist/client/event-hooks.js.map +1 -1
- package/dist/client/hosted-anonymous-delivery.d.ts.map +1 -1
- package/dist/client/hosted-anonymous-delivery.js +3 -0
- package/dist/client/hosted-anonymous-delivery.js.map +1 -1
- package/dist/client/hosted-device-standing.d.ts +52 -0
- package/dist/client/hosted-device-standing.d.ts.map +1 -0
- package/dist/client/hosted-device-standing.js +74 -0
- package/dist/client/hosted-device-standing.js.map +1 -0
- package/dist/client/hosted-group-authority.d.ts.map +1 -1
- package/dist/client/hosted-group-authority.js +18 -4
- package/dist/client/hosted-group-authority.js.map +1 -1
- package/dist/client/hosted-groups.d.ts.map +1 -1
- package/dist/client/hosted-groups.js +5 -1
- package/dist/client/hosted-groups.js.map +1 -1
- package/dist/client/hosted-mailbox-subscription.d.ts +16 -2
- package/dist/client/hosted-mailbox-subscription.d.ts.map +1 -1
- package/dist/client/hosted-mailbox-subscription.js +243 -42
- package/dist/client/hosted-mailbox-subscription.js.map +1 -1
- package/dist/client/hosted-transport.d.ts.map +1 -1
- package/dist/client/hosted-transport.js +56 -8
- package/dist/client/hosted-transport.js.map +1 -1
- package/dist/client/hosted.d.ts +13 -1
- package/dist/client/hosted.d.ts.map +1 -1
- package/dist/client/hosted.js +113 -41
- package/dist/client/hosted.js.map +1 -1
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/messages.d.ts.map +1 -1
- package/dist/client/messages.js +10 -0
- package/dist/client/messages.js.map +1 -1
- package/dist/client/one-time-prekey-refill.d.ts +7 -0
- package/dist/client/one-time-prekey-refill.d.ts.map +1 -1
- package/dist/client/one-time-prekey-refill.js +5 -1
- package/dist/client/one-time-prekey-refill.js.map +1 -1
- package/dist/client/relay-acceptance.d.ts +17 -0
- package/dist/client/relay-acceptance.d.ts.map +1 -1
- package/dist/client/relay-acceptance.js +37 -0
- package/dist/client/relay-acceptance.js.map +1 -1
- package/dist/client/relay-protocol.d.ts +41 -0
- package/dist/client/relay-protocol.d.ts.map +1 -0
- package/dist/client/relay-protocol.js +60 -0
- package/dist/client/relay-protocol.js.map +1 -0
- package/dist/client/relay-subscription.d.ts.map +1 -1
- package/dist/client/relay-subscription.js +30 -30
- package/dist/client/relay-subscription.js.map +1 -1
- package/dist/client/retry-family.d.ts +11 -9
- package/dist/client/retry-family.d.ts.map +1 -1
- package/dist/client/retry-family.js +5 -5
- package/dist/client/retry-family.js.map +1 -1
- package/dist/client/retry-request-envelope.d.ts +40 -12
- package/dist/client/retry-request-envelope.d.ts.map +1 -1
- package/dist/client/retry-request-envelope.js +142 -54
- package/dist/client/retry-request-envelope.js.map +1 -1
- package/dist/client/retry-request-lifecycle.d.ts +101 -0
- package/dist/client/retry-request-lifecycle.d.ts.map +1 -0
- package/dist/client/retry-request-lifecycle.js +307 -0
- package/dist/client/retry-request-lifecycle.js.map +1 -0
- package/dist/client/retry.d.ts +6 -6
- package/dist/client/retry.d.ts.map +1 -1
- package/dist/client/retry.js +83 -38
- package/dist/client/retry.js.map +1 -1
- package/dist/client/signal-service-cipher.d.ts.map +1 -1
- package/dist/client/signal-service-cipher.js +5 -1
- package/dist/client/signal-service-cipher.js.map +1 -1
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/types.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/local/store/reliability.d.ts +106 -8
- package/dist/local/store/reliability.d.ts.map +1 -1
- package/dist/local/store/reliability.js +165 -16
- package/dist/local/store/reliability.js.map +1 -1
- package/dist/remote/relay/types.d.ts +19 -5
- package/dist/remote/relay/types.d.ts.map +1 -1
- package/dist/utils/retry.d.ts +3 -0
- package/dist/utils/retry.d.ts.map +1 -1
- package/dist/utils/retry.js +13 -0
- package/dist/utils/retry.js.map +1 -1
- package/docs/ASSURANCE.md +5 -5
- package/docs/ERROR_HANDLING.md +119 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { utf8Decode } from '../internal/platform/index.js';
|
|
2
2
|
import { withRelayRequestDeadline } from './relay-request-deadline.js';
|
|
3
|
+
import { relayProtocolHeaders, throwIfUpgradeRequired } from './relay-protocol.js';
|
|
3
4
|
import { EndorsementManager, } from './endorsement-manager.js';
|
|
4
5
|
import { verifyGroupAuthority } from '../internal/groups/authority-certificate.js';
|
|
5
6
|
import { decodeGroupTrustRoot } from '../internal/groups/trust-root.js';
|
|
@@ -12,14 +13,13 @@ async function fetchAuthority(connection) {
|
|
|
12
13
|
headers: {
|
|
13
14
|
'content-type': 'application/json',
|
|
14
15
|
accept: 'application/json',
|
|
16
|
+
...relayProtocolHeaders(),
|
|
15
17
|
},
|
|
16
18
|
body: JSON.stringify({ publishableKey: connection.publishableKey }),
|
|
17
19
|
signal,
|
|
18
20
|
});
|
|
19
|
-
if (!response.
|
|
20
|
-
await response.body?.cancel();
|
|
21
|
+
if (!response.body)
|
|
21
22
|
throw new Error('Managed group authority is unavailable');
|
|
22
|
-
}
|
|
23
23
|
const reader = response.body.getReader();
|
|
24
24
|
const chunks = [];
|
|
25
25
|
let length = 0;
|
|
@@ -31,7 +31,9 @@ async function fetchAuthority(connection) {
|
|
|
31
31
|
length += part.value.length;
|
|
32
32
|
if (length > 8192) {
|
|
33
33
|
await reader.cancel();
|
|
34
|
-
throw new Error(
|
|
34
|
+
throw new Error(response.ok
|
|
35
|
+
? 'Managed group authority exceeds its size limit'
|
|
36
|
+
: 'Managed group authority is unavailable');
|
|
35
37
|
}
|
|
36
38
|
chunks.push(part.value);
|
|
37
39
|
}
|
|
@@ -45,6 +47,18 @@ async function fetchAuthority(connection) {
|
|
|
45
47
|
body.set(part, offset);
|
|
46
48
|
offset += part.length;
|
|
47
49
|
}
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
// Only the error body tells a terminal `UPGRADE_REQUIRED` from an outage.
|
|
52
|
+
let error;
|
|
53
|
+
try {
|
|
54
|
+
error = JSON.parse(utf8Decode(body, { fatal: true }));
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
error = undefined;
|
|
58
|
+
}
|
|
59
|
+
throwIfUpgradeRequired(response.status, error);
|
|
60
|
+
throw new Error('Managed group authority is unavailable');
|
|
61
|
+
}
|
|
48
62
|
return body;
|
|
49
63
|
});
|
|
50
64
|
return verifyGroupAuthority(JSON.parse(utf8Decode(buffer, { fatal: true })), {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-group-authority.js","sourceRoot":"","sources":["../../client/hosted-group-authority.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EACL,kBAAkB,GAEnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAUrE,KAAK,UAAU,cAAc,CAAC,UAAiC;IAC7D,MAAM,MAAM,GAAG,MAAM,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC7D,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,GAAG,UAAU,CAAC,gBAAgB,mBAAmB,EACjD;YACE,MA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gBAC9B,cAAc,EAAE,SAAS,CAAC,KAAK;gBAC/B,GAAG,CAAC,OAAO,CAAC,gBAAgB,KAAK,SAAS;oBACxC,CAAC,CAAC,EAAE;oBACJ,CAAC,CAAC;wBACE,kBAAkB,EAAE,IAAI,kBAAkB,CACxC,OAAO,CAAC,gBAAgB,EACxB,IAAI,CAAC,wBAAwB,CAC9B;qBACF,CAAC;aACP,CAAC;YACF,OAAO,GAAG;gBACR,KAAK;gBACL,SAAS,EAAE,SAAS,CAAC,qBAAqB;gBAC1C,QAAQ,EAAE,SAAS,CAAC,oBAAoB;aACzC,CAAC;YACF,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,EAAE,CAAC;QACL,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC;QACvB,CAAC;gBAAS,CAAC;YACT,OAAO,GAAG,SAAS,CAAC;QACtB,CAAC;IACH,CAAC,CAAC;IACF,MAAM,SAAS,GAAG,MAAM,gBAAgB,EAAE,CAAC;IAC3C,OAAO;QACL,GAAG,SAAS;QACZ,gBAAgB;QAChB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;KACjE,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-groups.d.ts","sourceRoot":"","sources":["../../client/hosted-groups.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAGpC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"hosted-groups.d.ts","sourceRoot":"","sources":["../../client/hosted-groups.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,E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A;KAAE,GAAG,IAAI,CAAC,CAUpE;IAEK,eAAe,CACnB,OAAO,EAAE,UAAU,EACnB,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,kBAAkB,GAChC,OAAO,CAAC,kBAAkB,CAAC,CAkB7B;IAEK,iBAAiB,CACrB,OAAO,EAAE,UAAU,EACnB,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,UAAU,EACnB,kBAAkB,EAAE,UAAU,EAC9B,aAAa,EAAE,kBAAkB,GAChC,OAAO,CAAC,mBAAmB,CAAC,CAc9B;CACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { utf8Decode } from '../internal/platform/index.js';
|
|
2
2
|
import { base64ToBytes, bytesToBase64 } from '../internal/crypto/index.js';
|
|
3
3
|
import { withRelayRequestDeadline } from './relay-request-deadline.js';
|
|
4
|
+
import { relayProtocolHeaders, throwIfUpgradeRequired } from './relay-protocol.js';
|
|
4
5
|
import { isGroupErrorDetail, } from '../internal/groups/error-details.js';
|
|
5
6
|
const MAXIMUM_RESPONSE_BYTES = 8 * 1024 * 1024;
|
|
6
7
|
const MAXIMUM_CHANGE_ENTRIES = 64;
|
|
@@ -128,6 +129,7 @@ export class HostedGroupServer {
|
|
|
128
129
|
headers: {
|
|
129
130
|
accept: 'application/json',
|
|
130
131
|
'content-type': 'application/json',
|
|
132
|
+
...relayProtocolHeaders(),
|
|
131
133
|
},
|
|
132
134
|
body: JSON.stringify({
|
|
133
135
|
publishableKey: this.connection.publishableKey,
|
|
@@ -140,8 +142,10 @@ export class HostedGroupServer {
|
|
|
140
142
|
signal,
|
|
141
143
|
});
|
|
142
144
|
const value = await readResponse(response);
|
|
143
|
-
if (!response.ok)
|
|
145
|
+
if (!response.ok) {
|
|
146
|
+
throwIfUpgradeRequired(response.status, value);
|
|
144
147
|
throw new HostedGroupError(response.status, value);
|
|
148
|
+
}
|
|
145
149
|
return value;
|
|
146
150
|
});
|
|
147
151
|
}
|
|
@@ -1 +1 @@
|
|
|
1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AA8B,EAC9B,aAAiC;QAEjC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;YACxB,MAAM,IAAI,KAAK,CACb,kEAAkE,CACnE,CAAC;QACJ,MAAM,MAAM,GAAG,MAAM,CACnB,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE;YACnD,eAAe;YACf,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC;YAC/B,kBAAkB,EAAE,aAAa,CAAC,kBAAkB,CAAC;SACtD,CAAC,CACH,CAAC;QACF,IAAI,MAAM,CAAC,OAAO,KAAK,eAAe,GAAG,CAAC;YAAE,eAAe,EAAE,CAAC;QAC9D,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -26,11 +26,22 @@ export interface MailboxAcknowledgment {
|
|
|
26
26
|
readonly receipted: readonly string[];
|
|
27
27
|
}
|
|
28
28
|
interface MailboxSubscription {
|
|
29
|
+
/**
|
|
30
|
+
* Gets the socket address and a device token. `refreshed` is true when the
|
|
31
|
+
* call got a new device token from the Relay.
|
|
32
|
+
*/
|
|
29
33
|
authenticate(): Promise<{
|
|
30
34
|
url: string;
|
|
31
35
|
token: string;
|
|
32
36
|
renewAt: number;
|
|
37
|
+
refreshed: boolean;
|
|
33
38
|
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Returns true for a Relay refusal of a socket authentication or a pull
|
|
41
|
+
* that the same request gets again. The subscription then stops with the
|
|
42
|
+
* reason `authority-refused`. Each other failure goes to the retry schedule.
|
|
43
|
+
*/
|
|
44
|
+
isConclusiveRefusal(error: unknown): boolean;
|
|
34
45
|
/** Decodes the `message` of a `durable-message` frame. */
|
|
35
46
|
decodeDurable(message: unknown): Envelope;
|
|
36
47
|
/** Recovers retained work over HTTP while no socket delivers it. */
|
|
@@ -59,8 +70,11 @@ interface MailboxSubscription {
|
|
|
59
70
|
onBatchEnd?(): void;
|
|
60
71
|
/**
|
|
61
72
|
* Receives each connection transition. The subscription starts at
|
|
62
|
-
* `connecting` and ends at `stopped`.
|
|
63
|
-
*
|
|
73
|
+
* `connecting` and ends at `stopped`. It ends at `stopped` with the reason
|
|
74
|
+
* `upgrade-required` when the Relay no longer serves the protocol version of
|
|
75
|
+
* this SDK, with `device-revoked` or `device-unknown` when the Relay refuses
|
|
76
|
+
* this device, and with `authority-refused` after a conclusive refusal. A
|
|
77
|
+
* token renewal on a live socket is not a transition.
|
|
64
78
|
*/
|
|
65
79
|
onConnectionState(state: RelayConnectionState["state"], reason?: RelayConnectionReason): void;
|
|
66
80
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-mailbox-subscription.d.ts","sourceRoot":"","sources":["../../client/hosted-mailbox-subscription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAOL,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC/B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"hosted-mailbox-subscription.d.ts","sourceRoot":"","sources":["../../client/hosted-mailbox-subscription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAOL,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC/B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,wBAAwB,CAAC;AAyGhC;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,y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5E,YAAY,CAAC,IAAI,IAAI,CAAC;IACtB,UAAU,CAAC,IAAI,IAAI,CAAC;IACpB;;;;;;;OAOG;IACH,iBAAiB,CACf,KAAK,EAAE,oBAAoB,CAAC,OAAO,CAAC,EACpC,MAAM,CAAC,EAAE,qBAAqB,GAC7B,IAAI,CAAC;IACR;;;OAGG;IACH,UAAU,CAAC,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAAC;CAC/C;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC;;;OAGG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IACxC;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACjE;AAqBD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,mBAAmB,GAC3B,yBAAyB,CAowB3B"}
|
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
import { HostedRelayPresenceError, decodePresenceAnswer, decodePresenceUpdate, encodePresenceFrame, isPresenceAnswerType, isPresenceUpdateType, } from "./hosted-presence-frames.js";
|
|
2
2
|
import { MAXIMUM_RECEIPTS_PER_FRAME, decodeRelayDeliveryReceipts, } from "./relay-receipt-intake.js";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { HostedRelayUpgradeRequiredError, RELAY_AUTH_PROTOCOL_PREFIX, RELAY_PROTOCOL_VERSION, relayProtocolToken, } from "./relay-protocol.js";
|
|
4
|
+
import { HostedRelayDeviceRevokedError, HostedRelayDeviceUnknownError, } from "./hosted-device-standing.js";
|
|
5
|
+
/**
|
|
6
|
+
* The stop reason that a typed Relay refusal names, or undefined for any other
|
|
7
|
+
* error. A conclusive `HostedRelayHttpError` refusal is not typed. The
|
|
8
|
+
* subscription asks `isConclusiveRefusal` for it.
|
|
9
|
+
*/
|
|
10
|
+
function relayRefusalReason(error) {
|
|
11
|
+
if (error instanceof HostedRelayUpgradeRequiredError)
|
|
12
|
+
return "upgrade-required";
|
|
13
|
+
if (error instanceof HostedRelayDeviceRevokedError)
|
|
14
|
+
return "device-revoked";
|
|
15
|
+
if (error instanceof HostedRelayDeviceUnknownError)
|
|
16
|
+
return "device-unknown";
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
/** The subprotocol token that the socket offers and the Relay must echo. */
|
|
20
|
+
const RELAY_PROTOCOL_TOKEN = relayProtocolToken(RELAY_PROTOCOL_VERSION);
|
|
5
21
|
/**
|
|
6
22
|
* The recovery pull waits a random time from half to one and a half of this
|
|
7
23
|
* value after the call that asks for it, so clients that lose their sockets
|
|
@@ -28,11 +44,15 @@ const MAXIMUM_RECOVERY_MILLISECONDS = 64_000;
|
|
|
28
44
|
*/
|
|
29
45
|
const FAILED_MESSAGE_GONE_MILLISECONDS = 5_000;
|
|
30
46
|
/**
|
|
31
|
-
* The
|
|
32
|
-
* random time from zero up to the ceiling (full jitter), the first one
|
|
33
|
-
* clients that lose their sockets together, for example in a Relay
|
|
34
|
-
* not reconnect together.
|
|
35
|
-
*
|
|
47
|
+
* The retry schedule. Its ceiling starts at 1 s and doubles to 30 s. Each wait
|
|
48
|
+
* is a random time from zero up to the ceiling (full jitter), the first one
|
|
49
|
+
* too, so clients that lose their sockets together, for example in a Relay
|
|
50
|
+
* deploy, do not reconnect together. A failed socket, a failed socket
|
|
51
|
+
* authentication, and a failed pull share this one schedule. While a wait is
|
|
52
|
+
* pending, a further failure draws no new wait, so failures of different
|
|
53
|
+
* kinds do not multiply the requests of an outage. The ceiling starts again at
|
|
54
|
+
* 1 s when the Relay answers a ping, 30 s after the socket opens, and when the
|
|
55
|
+
* socket authentication gets a new device token. A socket that closes sooner,
|
|
36
56
|
* for example on a frame that the client refuses on each connect, keeps the
|
|
37
57
|
* ceiling growing, so a loop of short connections backs off to 30 s.
|
|
38
58
|
*/
|
|
@@ -59,6 +79,12 @@ const MAXIMUM_PENDING_PRESENCE_REQUESTS = 16;
|
|
|
59
79
|
const PRESENCE_ANSWER_MILLISECONDS = 10_000;
|
|
60
80
|
/** The Relay closes the socket with this code on a frame that it refuses. */
|
|
61
81
|
const POLICY_VIOLATION_CLOSE_CODE = 1008;
|
|
82
|
+
/**
|
|
83
|
+
* The Relay closes the socket with this code and the reason
|
|
84
|
+
* `UPGRADE_REQUIRED` when it no longer serves the offered protocol version.
|
|
85
|
+
*/
|
|
86
|
+
const UPGRADE_REQUIRED_CLOSE_CODE = 4426;
|
|
87
|
+
const UPGRADE_REQUIRED_CLOSE_REASON = "UPGRADE_REQUIRED";
|
|
62
88
|
function notConnected() {
|
|
63
89
|
return new HostedRelayPresenceError("NOT_CONNECTED", "The mailbox socket is not connected", true);
|
|
64
90
|
}
|
|
@@ -71,15 +97,44 @@ function notConnected() {
|
|
|
71
97
|
*/
|
|
72
98
|
export function subscribeHostedMailbox(options) {
|
|
73
99
|
let active = true;
|
|
100
|
+
/**
|
|
101
|
+
* True after the Relay refused the protocol version of this SDK, refused
|
|
102
|
+
* this device, or refused the subscription conclusively.
|
|
103
|
+
*/
|
|
104
|
+
let refused = false;
|
|
74
105
|
let socket;
|
|
106
|
+
/** True after the current socket opened with the mailbox subprotocol. */
|
|
107
|
+
let socketOpened = false;
|
|
108
|
+
/** True while a connect waits for its socket authentication. */
|
|
109
|
+
let authenticating = false;
|
|
75
110
|
let connectionGeneration = 0;
|
|
111
|
+
/** The ceiling of the retry schedule. */
|
|
76
112
|
let reconnectDelay = FIRST_RECONNECT_MILLISECONDS;
|
|
77
|
-
let reconnectTimer;
|
|
78
113
|
let handshakeTimer;
|
|
79
114
|
let renewalTimer;
|
|
80
|
-
|
|
115
|
+
/**
|
|
116
|
+
* The one timer of the retries. It fires at the sooner of `retryDue` and
|
|
117
|
+
* `recoveryDue`.
|
|
118
|
+
*/
|
|
119
|
+
let retryTimer;
|
|
120
|
+
/**
|
|
121
|
+
* The `Date.now()` time of the next retry of the schedule. The retry
|
|
122
|
+
* reconnects a missing socket, or runs an owed pull while a socket is up or
|
|
123
|
+
* connecting. Undefined while no retry waits.
|
|
124
|
+
*/
|
|
125
|
+
let retryDue;
|
|
81
126
|
/** The `Date.now()` time at which the pending recovery pull starts. */
|
|
82
|
-
let recoveryDue
|
|
127
|
+
let recoveryDue;
|
|
128
|
+
/**
|
|
129
|
+
* True from a failed socket authentication or a failed pull until a pull
|
|
130
|
+
* succeeds, the socket authentication gets a new device token, or the
|
|
131
|
+
* Relay answers a ping. In an outage a failed socket draws no recovery pull
|
|
132
|
+
* of its own. A socket attempt that fails before it opens pulls at once
|
|
133
|
+
* instead, on the retry schedule.
|
|
134
|
+
*/
|
|
135
|
+
let outage = false;
|
|
136
|
+
/** True while a failed pull waits for the next retry. */
|
|
137
|
+
let pullOwed = false;
|
|
83
138
|
let failedWorkRecoveryDelay = RECOVERY_MILLISECONDS;
|
|
84
139
|
/**
|
|
85
140
|
* The id of each message whose work failed, with the `Date.now()` time of
|
|
@@ -188,6 +243,67 @@ export function subscribeHostedMailbox(options) {
|
|
|
188
243
|
if (awaitingReply.delete(messageId))
|
|
189
244
|
options.onAcknowledgmentReply(messageId, receipted.includes(messageId));
|
|
190
245
|
};
|
|
246
|
+
/** Sets the one retry timer for the sooner of the two pending times. */
|
|
247
|
+
const armRetryTimer = () => {
|
|
248
|
+
clearTimeout(retryTimer);
|
|
249
|
+
retryTimer = undefined;
|
|
250
|
+
if (!active)
|
|
251
|
+
return;
|
|
252
|
+
const due = Math.min(retryDue ?? Infinity, recoveryDue ?? Infinity);
|
|
253
|
+
if (due === Infinity)
|
|
254
|
+
return;
|
|
255
|
+
retryTimer = setTimeout(() => runRetries(due), Math.max(0, due - Date.now()));
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* Runs each retry that is due at `due`, the time of the timer that fired,
|
|
259
|
+
* then sets the timer for the rest.
|
|
260
|
+
*/
|
|
261
|
+
const runRetries = (due) => {
|
|
262
|
+
retryTimer = undefined;
|
|
263
|
+
if (retryDue !== undefined && retryDue <= due) {
|
|
264
|
+
retryDue = undefined;
|
|
265
|
+
// A new socket attempt carries the owed pull, which runs when the
|
|
266
|
+
// attempt fails before it opens.
|
|
267
|
+
if (socket === undefined && !authenticating)
|
|
268
|
+
void connect();
|
|
269
|
+
else if (pullOwed) {
|
|
270
|
+
pullOwed = false;
|
|
271
|
+
requestPull();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if (recoveryDue !== undefined && recoveryDue <= due) {
|
|
275
|
+
recoveryDue = undefined;
|
|
276
|
+
requestPull();
|
|
277
|
+
}
|
|
278
|
+
armRetryTimer();
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* Draws the next retry wait from the schedule and doubles the ceiling,
|
|
282
|
+
* unless a retry already waits. A failure during the wait draws nothing.
|
|
283
|
+
*/
|
|
284
|
+
const scheduleRetry = () => {
|
|
285
|
+
if (!active || retryDue !== undefined)
|
|
286
|
+
return;
|
|
287
|
+
retryDue = Date.now() + Math.floor(Math.random() * reconnectDelay);
|
|
288
|
+
reconnectDelay = Math.min(MAXIMUM_RECONNECT_MILLISECONDS, reconnectDelay * 2);
|
|
289
|
+
armRetryTimer();
|
|
290
|
+
};
|
|
291
|
+
/** A request succeeded, so the outage ends and the ceiling starts again. */
|
|
292
|
+
const endOutage = () => {
|
|
293
|
+
outage = false;
|
|
294
|
+
reconnectDelay = FIRST_RECONNECT_MILLISECONDS;
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* Owes a failed pull to the retry schedule. The pending recovery pull
|
|
298
|
+
* ends, so the failed pull does not run twice.
|
|
299
|
+
*/
|
|
300
|
+
const retryPull = () => {
|
|
301
|
+
outage = true;
|
|
302
|
+
pullOwed = true;
|
|
303
|
+
recoveryDue = undefined;
|
|
304
|
+
armRetryTimer();
|
|
305
|
+
scheduleRetry();
|
|
306
|
+
};
|
|
191
307
|
/**
|
|
192
308
|
* Schedules one recovery pull. A pending pull that starts sooner stays, and
|
|
193
309
|
* a pending pull that starts later is replaced, so a longer wait for failed
|
|
@@ -199,16 +315,10 @@ export function subscribeHostedMailbox(options) {
|
|
|
199
315
|
return false;
|
|
200
316
|
const wait = delay * (0.5 + Math.random());
|
|
201
317
|
const due = Date.now() + wait;
|
|
202
|
-
if (
|
|
203
|
-
|
|
204
|
-
return false;
|
|
205
|
-
clearTimeout(recoveryTimer);
|
|
206
|
-
}
|
|
318
|
+
if (recoveryDue !== undefined && due >= recoveryDue)
|
|
319
|
+
return false;
|
|
207
320
|
recoveryDue = due;
|
|
208
|
-
|
|
209
|
-
recoveryTimer = undefined;
|
|
210
|
-
requestPull();
|
|
211
|
-
}, wait);
|
|
321
|
+
armRetryTimer();
|
|
212
322
|
return true;
|
|
213
323
|
};
|
|
214
324
|
/** Schedules the recovery pull for failed work, and doubles its next wait. */
|
|
@@ -240,7 +350,11 @@ export function subscribeHostedMailbox(options) {
|
|
|
240
350
|
if ("receipt" in work) {
|
|
241
351
|
try {
|
|
242
352
|
await options.receiveReceipt(work.receipt);
|
|
243
|
-
|
|
353
|
+
// A hand-off that settles after a refusal stop is not
|
|
354
|
+
// acknowledged, because the Relay refuses the acknowledgment. The
|
|
355
|
+
// Relay keeps the receipt.
|
|
356
|
+
if (!refused)
|
|
357
|
+
receiptAcknowledgments.push(work.receipt.receiptId);
|
|
244
358
|
}
|
|
245
359
|
catch {
|
|
246
360
|
failed = true;
|
|
@@ -291,6 +405,8 @@ export function subscribeHostedMailbox(options) {
|
|
|
291
405
|
if (draining || !active)
|
|
292
406
|
return;
|
|
293
407
|
draining = true;
|
|
408
|
+
/** True while `options.pull` runs, so the catch knows what failed. */
|
|
409
|
+
let pulling = false;
|
|
294
410
|
try {
|
|
295
411
|
while (active &&
|
|
296
412
|
(pullRequested || ephemeral.length > 0 || durable.length > 0)) {
|
|
@@ -316,7 +432,13 @@ export function subscribeHostedMailbox(options) {
|
|
|
316
432
|
pullRequested = false;
|
|
317
433
|
flushAcknowledgments();
|
|
318
434
|
const pulledAt = Date.now();
|
|
435
|
+
pulling = true;
|
|
319
436
|
const { messages, receipts } = await options.pull();
|
|
437
|
+
pulling = false;
|
|
438
|
+
// The Relay answered, so the HTTP outage ends. The reconnect ceiling
|
|
439
|
+
// stays, because the socket can still fail.
|
|
440
|
+
outage = false;
|
|
441
|
+
pullOwed = false;
|
|
320
442
|
const { failed, acknowledged } = await receiveBatch([
|
|
321
443
|
...messages.map((message) => ({ message })),
|
|
322
444
|
...receipts.map((receipt) => ({ receipt })),
|
|
@@ -338,10 +460,22 @@ export function subscribeHostedMailbox(options) {
|
|
|
338
460
|
recoverLater();
|
|
339
461
|
}
|
|
340
462
|
}
|
|
341
|
-
catch {
|
|
463
|
+
catch (error) {
|
|
342
464
|
// A pull, an ephemeral message, or a batch callback failed. Retained
|
|
343
|
-
// durable work stays in the mailbox. Ephemeral work can be lost.
|
|
344
|
-
|
|
465
|
+
// durable work stays in the mailbox. Ephemeral work can be lost. A pull
|
|
466
|
+
// that the Relay refuses for this SDK or this device, or refuses
|
|
467
|
+
// conclusively, fails the same way each time, so it ends the
|
|
468
|
+
// subscription. Each other failed pull goes to the retry schedule. A
|
|
469
|
+
// callback error is the application's, so it only schedules a pull.
|
|
470
|
+
const refusal = relayRefusalReason(error);
|
|
471
|
+
if (refusal !== undefined)
|
|
472
|
+
stop(refusal);
|
|
473
|
+
else if (!pulling)
|
|
474
|
+
recoverLater();
|
|
475
|
+
else if (options.isConclusiveRefusal(error))
|
|
476
|
+
stop("authority-refused");
|
|
477
|
+
else
|
|
478
|
+
retryPull();
|
|
345
479
|
}
|
|
346
480
|
finally {
|
|
347
481
|
draining = false;
|
|
@@ -361,6 +495,9 @@ export function subscribeHostedMailbox(options) {
|
|
|
361
495
|
const disconnect = () => {
|
|
362
496
|
const previous = socket;
|
|
363
497
|
socket = undefined;
|
|
498
|
+
socketOpened = false;
|
|
499
|
+
// A connect that still authenticates is dropped by its generation.
|
|
500
|
+
authenticating = false;
|
|
364
501
|
connectionGeneration++;
|
|
365
502
|
ephemeral.length = 0;
|
|
366
503
|
durable.length = 0;
|
|
@@ -383,19 +520,55 @@ export function subscribeHostedMailbox(options) {
|
|
|
383
520
|
/* Already closed. */
|
|
384
521
|
}
|
|
385
522
|
};
|
|
523
|
+
/**
|
|
524
|
+
* Ends the subscription because the Relay refused it in a way that each
|
|
525
|
+
* reconnect and each pull gets again: `upgrade-required` when the Relay no
|
|
526
|
+
* longer serves the protocol version of this SDK, `device-revoked` or
|
|
527
|
+
* `device-unknown` when the Relay refuses this device, and
|
|
528
|
+
* `authority-refused` after a conclusive refusal of a socket authentication
|
|
529
|
+
* or a pull. No retry
|
|
530
|
+
* follows. Queued acknowledgments are not sent, because the Relay refuses
|
|
531
|
+
* them too. A receipt hand-off that settles after the stop is not
|
|
532
|
+
* acknowledged either. The Relay keeps their messages and receipts, and each
|
|
533
|
+
* queued message gets the reply `receipted` false.
|
|
534
|
+
*/
|
|
535
|
+
const stop = (reason) => {
|
|
536
|
+
if (!active)
|
|
537
|
+
return;
|
|
538
|
+
active = false;
|
|
539
|
+
refused = true;
|
|
540
|
+
const unsent = acknowledgments.splice(0);
|
|
541
|
+
receiptAcknowledgments.length = 0;
|
|
542
|
+
for (const messageId of unsent)
|
|
543
|
+
options.onAcknowledgmentReply(messageId, false);
|
|
544
|
+
clearTimeout(retryTimer);
|
|
545
|
+
retryTimer = undefined;
|
|
546
|
+
retryDue = undefined;
|
|
547
|
+
recoveryDue = undefined;
|
|
548
|
+
clearTimeout(acknowledgmentTimer);
|
|
549
|
+
acknowledgmentTimer = undefined;
|
|
550
|
+
disconnect();
|
|
551
|
+
options.onConnectionState("stopped", reason);
|
|
552
|
+
};
|
|
386
553
|
const retryConnection = (reason) => {
|
|
387
|
-
if (!active
|
|
554
|
+
if (!active)
|
|
388
555
|
return;
|
|
556
|
+
const replayed = socketOpened;
|
|
389
557
|
disconnect();
|
|
390
558
|
options.onConnectionState("reconnecting", reason);
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
559
|
+
if (!outage) {
|
|
560
|
+
// One recovery pull per reconnect attempt, drawn before the wait.
|
|
561
|
+
recoverLater();
|
|
562
|
+
}
|
|
563
|
+
else if (reason !== "authentication" && !replayed) {
|
|
564
|
+
// In an outage, a socket attempt that fails before it opens pulls at
|
|
565
|
+
// once, on the retry schedule. A socket that opened replayed the
|
|
566
|
+
// retained work. A pull after a failed authentication would fail on
|
|
567
|
+
// the same device token.
|
|
568
|
+
pullOwed = false;
|
|
569
|
+
requestPull();
|
|
570
|
+
}
|
|
571
|
+
scheduleRetry();
|
|
399
572
|
};
|
|
400
573
|
const queueDurable = (candidate, message) => {
|
|
401
574
|
const envelope = options.decodeDurable(message);
|
|
@@ -425,14 +598,19 @@ export function subscribeHostedMailbox(options) {
|
|
|
425
598
|
const connect = async () => {
|
|
426
599
|
const generation = ++connectionGeneration;
|
|
427
600
|
let authenticated = false;
|
|
601
|
+
authenticating = true;
|
|
428
602
|
try {
|
|
429
603
|
const authority = await options.authenticate();
|
|
430
604
|
authenticated = true;
|
|
431
605
|
if (!active || generation !== connectionGeneration)
|
|
432
606
|
return;
|
|
607
|
+
authenticating = false;
|
|
608
|
+
// A new device token shows that the Relay serves this device again.
|
|
609
|
+
if (authority.refreshed)
|
|
610
|
+
endOutage();
|
|
433
611
|
const candidate = new WebSocket(authority.url, [
|
|
434
|
-
|
|
435
|
-
`${
|
|
612
|
+
RELAY_PROTOCOL_TOKEN,
|
|
613
|
+
`${RELAY_AUTH_PROTOCOL_PREFIX}${authority.token}`,
|
|
436
614
|
]);
|
|
437
615
|
socket = candidate;
|
|
438
616
|
const current = () => active && socket === candidate;
|
|
@@ -443,7 +621,7 @@ export function subscribeHostedMailbox(options) {
|
|
|
443
621
|
candidate.addEventListener("open", () => {
|
|
444
622
|
if (!current())
|
|
445
623
|
return;
|
|
446
|
-
if (candidate.protocol !==
|
|
624
|
+
if (candidate.protocol !== RELAY_PROTOCOL_TOKEN) {
|
|
447
625
|
retryConnection("protocol");
|
|
448
626
|
return;
|
|
449
627
|
}
|
|
@@ -456,8 +634,10 @@ export function subscribeHostedMailbox(options) {
|
|
|
456
634
|
// a failed message remains. This pull is scheduled before the replay
|
|
457
635
|
// arrives, so it can find an empty page when the replay handles the
|
|
458
636
|
// last failed message.
|
|
459
|
-
|
|
460
|
-
|
|
637
|
+
socketOpened = true;
|
|
638
|
+
recoveryDue = undefined;
|
|
639
|
+
pullOwed = false;
|
|
640
|
+
armRetryTimer();
|
|
461
641
|
failedWorkRecoveryDelay = RECOVERY_MILLISECONDS;
|
|
462
642
|
if (failedMessages.size > 0)
|
|
463
643
|
recoverFailedWork();
|
|
@@ -501,7 +681,7 @@ export function subscribeHostedMailbox(options) {
|
|
|
501
681
|
if (event.data === "pong") {
|
|
502
682
|
unansweredPings = 0;
|
|
503
683
|
// The socket stayed open and the Relay answers it.
|
|
504
|
-
|
|
684
|
+
endOutage();
|
|
505
685
|
return;
|
|
506
686
|
}
|
|
507
687
|
const frame = JSON.parse(event.data);
|
|
@@ -554,6 +734,15 @@ export function subscribeHostedMailbox(options) {
|
|
|
554
734
|
candidate.addEventListener("close", (event) => {
|
|
555
735
|
if (!current())
|
|
556
736
|
return;
|
|
737
|
+
if (event.code === UPGRADE_REQUIRED_CLOSE_CODE &&
|
|
738
|
+
event.reason === UPGRADE_REQUIRED_CLOSE_REASON) {
|
|
739
|
+
stop("upgrade-required");
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
// A close 4400 with the reason `PROTOCOL_UNSUPPORTED` takes the
|
|
743
|
+
// retry below. The Relay sends it for a version above the newest one
|
|
744
|
+
// that it serves, which happens only after a Relay rollback. The
|
|
745
|
+
// version comes back when the newer Relay does, so the socket retries.
|
|
557
746
|
if (event.code === POLICY_VIOLATION_CLOSE_CODE)
|
|
558
747
|
rejectPresence(new HostedRelayPresenceError("FRAME_REJECTED", "The Relay closed the mailbox socket on a refused frame", false));
|
|
559
748
|
retryConnection("closed");
|
|
@@ -563,9 +752,21 @@ export function subscribeHostedMailbox(options) {
|
|
|
563
752
|
retryConnection("error");
|
|
564
753
|
});
|
|
565
754
|
}
|
|
566
|
-
catch {
|
|
567
|
-
if (active
|
|
755
|
+
catch (error) {
|
|
756
|
+
if (!active || generation !== connectionGeneration)
|
|
757
|
+
return;
|
|
758
|
+
authenticating = false;
|
|
759
|
+
const refusal = relayRefusalReason(error);
|
|
760
|
+
if (refusal !== undefined)
|
|
761
|
+
stop(refusal);
|
|
762
|
+
else if (options.isConclusiveRefusal(error))
|
|
763
|
+
stop("authority-refused");
|
|
764
|
+
else {
|
|
765
|
+
// A failed socket authentication is a failed Relay request.
|
|
766
|
+
if (!authenticated)
|
|
767
|
+
outage = true;
|
|
568
768
|
retryConnection(authenticated ? "error" : "authentication");
|
|
769
|
+
}
|
|
569
770
|
}
|
|
570
771
|
};
|
|
571
772
|
options.onConnectionState("connecting");
|
|
@@ -623,8 +824,8 @@ export function subscribeHostedMailbox(options) {
|
|
|
623
824
|
return;
|
|
624
825
|
flushAcknowledgments();
|
|
625
826
|
active = false;
|
|
626
|
-
clearTimeout(
|
|
627
|
-
|
|
827
|
+
clearTimeout(retryTimer);
|
|
828
|
+
retryTimer = undefined;
|
|
628
829
|
disconnect();
|
|
629
830
|
options.onConnectionState("stopped");
|
|
630
831
|
},
|