@open-e2ee/signal-protocol-sdk 14.0.0 → 14.1.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 +46 -0
- package/README.md +9 -8
- package/SECURITY.md +2 -2
- package/client/README.md +5 -3
- package/dist/client/hosted-anonymous-delivery.d.ts +13 -1
- package/dist/client/hosted-anonymous-delivery.d.ts.map +1 -1
- package/dist/client/hosted-anonymous-delivery.js +48 -5
- package/dist/client/hosted-anonymous-delivery.js.map +1 -1
- package/dist/client/hosted-mailbox-subscription.d.ts +6 -5
- package/dist/client/hosted-mailbox-subscription.d.ts.map +1 -1
- package/dist/client/hosted-mailbox-subscription.js +4 -8
- package/dist/client/hosted-mailbox-subscription.js.map +1 -1
- package/dist/client/hosted-sandbox-identity.d.ts +66 -3
- package/dist/client/hosted-sandbox-identity.d.ts.map +1 -1
- package/dist/client/hosted-sandbox-identity.js +136 -45
- package/dist/client/hosted-sandbox-identity.js.map +1 -1
- package/dist/client/hosted-transport.d.ts +12 -0
- package/dist/client/hosted-transport.d.ts.map +1 -1
- package/dist/client/hosted-transport.js +85 -43
- package/dist/client/hosted-transport.js.map +1 -1
- package/dist/client/hosted.d.ts +6 -3
- package/dist/client/hosted.d.ts.map +1 -1
- package/dist/client/hosted.js +6 -3
- package/dist/client/hosted.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- 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/relay-period-close.d.ts +35 -0
- package/dist/client/relay-period-close.d.ts.map +1 -0
- package/dist/client/relay-period-close.js +63 -0
- package/dist/client/relay-period-close.js.map +1 -0
- package/dist/client/send-deadline.d.ts +3 -2
- package/dist/client/send-deadline.d.ts.map +1 -1
- package/dist/client/send-deadline.js +5 -0
- package/dist/client/send-deadline.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/remote/relay/request-admission.d.ts +5 -3
- package/dist/remote/relay/request-admission.d.ts.map +1 -1
- package/dist/remote/relay/request-admission.js +2 -1
- package/dist/remote/relay/request-admission.js.map +1 -1
- package/dist/remote/relay/types.d.ts +1 -1
- package/docs/ASSURANCE.md +8 -8
- package/docs/CLIENT_COMPOSITION.md +4 -2
- package/docs/DEVIATIONS.md +51 -4
- package/docs/GETTING_STARTED.md +5 -2
- package/package.json +7 -2
- package/remote/relay/README.md +4 -2
|
@@ -12,9 +12,17 @@ import type { GetIdentityAssertion } from './hosted.js';
|
|
|
12
12
|
* Sandbox account. Another device of the account joins through device linking.
|
|
13
13
|
*
|
|
14
14
|
* The callback rejects a request for a production environment, for recovery,
|
|
15
|
-
* for provider migration, or for recent or step-up assurance.
|
|
16
|
-
*
|
|
17
|
-
* device-owned
|
|
15
|
+
* for provider migration, or for recent or step-up assurance. This helper is
|
|
16
|
+
* the Sandbox-only guard, and it is not deprecated. For a Production project in
|
|
17
|
+
* device-owned mode, use {@link hostedRelayDeviceOwnedIdentity}. For a
|
|
18
|
+
* Production project in application-bound mode, supply a `getIdentityAssertion`
|
|
19
|
+
* callback that returns an assertion from your backend.
|
|
20
|
+
*
|
|
21
|
+
* The key is stored under the metadata key
|
|
22
|
+
* `'hostedRelay.sandboxIdentity.v1:'` followed by the base64 SHA-256 digest of
|
|
23
|
+
* the publishable key. This is a persisted format that both helpers keep. A
|
|
24
|
+
* new prefix would orphan existing Sandbox accounts. So for the same store and
|
|
25
|
+
* publishable key, both helpers sign with the same key.
|
|
18
26
|
*
|
|
19
27
|
* @example
|
|
20
28
|
* ```ts
|
|
@@ -29,4 +37,59 @@ import type { GetIdentityAssertion } from './hosted.js';
|
|
|
29
37
|
* ```
|
|
30
38
|
*/
|
|
31
39
|
export declare function hostedRelaySandboxIdentity(storage: SignalProtocolLocalStore): GetIdentityAssertion;
|
|
40
|
+
/**
|
|
41
|
+
* Creates the identity assertion callback for a device-owned account in a
|
|
42
|
+
* Sandbox environment, or in a Production environment that is configured in
|
|
43
|
+
* device-owned identity mode.
|
|
44
|
+
*
|
|
45
|
+
* The callback signs a short-lived device-owned assertion with an Ed25519 key
|
|
46
|
+
* that it keeps in `storage`. It creates the key on the first call and uses the
|
|
47
|
+
* same key after that, so the Relay returns the same account each time the
|
|
48
|
+
* device registers. The key is separate for each publishable key. Pass the
|
|
49
|
+
* same store as `adapters.storage`. The key never leaves the store. A device
|
|
50
|
+
* that loses the store loses the account, and its next registration creates a
|
|
51
|
+
* new account: the Relay refuses device-owned recovery. Another device of the
|
|
52
|
+
* account joins through device linking.
|
|
53
|
+
*
|
|
54
|
+
* The assertion is a compact JWS. Its protected header is
|
|
55
|
+
* `{ alg: 'EdDSA', typ: 'JWT', jwk: { kty: 'OKP', crv: 'Ed25519', x } }`,
|
|
56
|
+
* where `x` is the base64url public key. Its claims are:
|
|
57
|
+
*
|
|
58
|
+
* - `iss`: `'https://relay.open-e2ee.dev/device-owned'`.
|
|
59
|
+
* - `aud`: the publishable key of the request.
|
|
60
|
+
* - `sub`: the RFC 7638 SHA-256 thumbprint of the embedded JWK, base64url.
|
|
61
|
+
* - `iat` and `nbf`: the issue time in seconds. `exp`: `iat + 300`.
|
|
62
|
+
* - `jti`: a new UUID for each assertion.
|
|
63
|
+
* - `purpose`: `'register'`. `assurance`: `'normal'`.
|
|
64
|
+
* `token_use`: `'identity'`.
|
|
65
|
+
*
|
|
66
|
+
* The callback rejects a request for an environment other than Sandbox or
|
|
67
|
+
* Production, for recovery, for refresh or provider migration, or for recent or
|
|
68
|
+
* step-up assurance. It creates no key for a request that it rejects.
|
|
69
|
+
*
|
|
70
|
+
* The Production project must be configured in device-owned identity mode. A
|
|
71
|
+
* project in application-bound mode refuses this assertion with
|
|
72
|
+
* `ASSERTION_INVALID`. For that mode, supply a `getIdentityAssertion` callback
|
|
73
|
+
* that returns an assertion from your backend.
|
|
74
|
+
*
|
|
75
|
+
* The key is stored under the metadata key
|
|
76
|
+
* `'hostedRelay.sandboxIdentity.v1:'` followed by the base64 SHA-256 digest of
|
|
77
|
+
* the publishable key. This is a persisted format that both helpers keep. A
|
|
78
|
+
* new prefix would orphan existing Sandbox accounts. So for the same store
|
|
79
|
+
* and publishable key, this helper and {@link hostedRelaySandboxIdentity} sign
|
|
80
|
+
* with the same key, and the Relay returns the same account.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* const storage = inMemoryStore();
|
|
85
|
+
* const client = await createHostedSignalProtocolClient({
|
|
86
|
+
* adapters: { storage },
|
|
87
|
+
* hosted: {
|
|
88
|
+
* relayUrl: process.env.OPEN_E2EE_RELAY_URL!,
|
|
89
|
+
* getIdentityAssertion: hostedRelayDeviceOwnedIdentity(storage),
|
|
90
|
+
* },
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export declare function hostedRelayDeviceOwnedIdentity(storage: SignalProtocolLocalStore): GetIdentityAssertion;
|
|
32
95
|
//# sourceMappingURL=hosted-sandbox-identity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-sandbox-identity.d.ts","sourceRoot":"","sources":["../../client/hosted-sandbox-identity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hosted-sandbox-identity.d.ts","sourceRoot":"","sources":["../../client/hosted-sandbox-identity.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAU,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAA4B,MAAM,UAAU,CAAC;AAuL/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,wBAAwB,GAChC,oBAAoB,CAEtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,wBAAwB,GAChC,oBAAoB,CAEtB"}
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Device-owned identity for
|
|
2
|
+
* Device-owned identity for the Signal Protocol Relay.
|
|
3
3
|
*
|
|
4
|
-
* A Sandbox environment
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
4
|
+
* A Sandbox environment, and a Production environment in device-owned mode,
|
|
5
|
+
* verify a device-owned assertion: a JWT that the device signs with its own
|
|
6
|
+
* Ed25519 key and that carries the public key in its header. The Relay binds
|
|
7
|
+
* the account to the RFC 7638 thumbprint of that key. So the key is the
|
|
8
|
+
* account identity in the environment, and this module keeps it in the
|
|
9
|
+
* device-local store next to the protocol identity. A device that loses its
|
|
10
|
+
* store loses the account. Another device of the account joins through device
|
|
11
|
+
* linking, not with a copy of this key.
|
|
11
12
|
*
|
|
12
|
-
* The
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* The helpers sign only registration assertions. `hostedRelaySandboxIdentity`
|
|
14
|
+
* serves only a Sandbox connection. `hostedRelayDeviceOwnedIdentity` serves a
|
|
15
|
+
* Sandbox connection or a device-owned Production connection. An
|
|
16
|
+
* application-bound Production project needs an application callback. Recovery
|
|
17
|
+
* and provider migration need an identity provider that authenticates the user.
|
|
15
18
|
*/
|
|
16
19
|
import { base64ToBytes, bytesToBase64, bytesToUrlSafeBase64, generateSigningKeyPair, generateUuidV4, sha256, sign, stringToBytes, verify, } from '../internal/crypto/index.js';
|
|
20
|
+
/**
|
|
21
|
+
* The metadata key prefix of the stored device-owned key. It is a persisted
|
|
22
|
+
* format that both helpers keep. A new prefix would orphan the existing keys,
|
|
23
|
+
* and so the existing accounts.
|
|
24
|
+
*/
|
|
17
25
|
const SANDBOX_IDENTITY_METADATA_PREFIX = 'hostedRelay.sandboxIdentity.v1:';
|
|
18
26
|
const DEVICE_OWNED_ISSUER = 'https://relay.open-e2ee.dev/device-owned';
|
|
19
27
|
/** The Relay accepts a lifetime of up to 600 seconds. */
|
|
@@ -84,20 +92,63 @@ function sandboxIdentityKey(storage, publishableKey) {
|
|
|
84
92
|
pending.set(publishableKey, created);
|
|
85
93
|
return created;
|
|
86
94
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
95
|
+
const SANDBOX_SCOPE = {
|
|
96
|
+
name: 'sandbox identity',
|
|
97
|
+
environments: ['sandbox'],
|
|
98
|
+
environmentsLabel: 'a Sandbox environment',
|
|
99
|
+
};
|
|
100
|
+
const DEVICE_OWNED_SCOPE = {
|
|
101
|
+
name: 'device-owned identity',
|
|
102
|
+
environments: ['sandbox', 'production'],
|
|
103
|
+
environmentsLabel: 'a Sandbox or Production environment',
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Accepts only a normal-assurance registration request for an environment of
|
|
107
|
+
* the scope. The Relay refuses device-owned recovery and migration away from
|
|
108
|
+
* device-owned mode, so registration is the whole device-owned path.
|
|
109
|
+
*/
|
|
110
|
+
function assertRegistration(request, scope) {
|
|
111
|
+
if (!scope.environments.includes(request.environment)) {
|
|
112
|
+
throw new Error(`Signal Protocol Relay ${scope.name} works only with ${scope.environmentsLabel}`);
|
|
90
113
|
}
|
|
91
114
|
if (request.purpose !== 'register' || request.migration !== undefined) {
|
|
92
|
-
throw new Error(
|
|
115
|
+
throw new Error(`Signal Protocol Relay ${scope.name} supports only device registration`);
|
|
93
116
|
}
|
|
94
117
|
if (request.assurance !== undefined && request.assurance !== 'normal') {
|
|
95
|
-
throw new Error(
|
|
118
|
+
throw new Error(`Signal Protocol Relay ${scope.name} cannot assert recent or step-up assurance`);
|
|
96
119
|
}
|
|
97
120
|
}
|
|
98
121
|
function encodeSegment(value) {
|
|
99
122
|
return bytesToUrlSafeBase64(stringToBytes(JSON.stringify(value)));
|
|
100
123
|
}
|
|
124
|
+
function deviceOwnedIdentity(storage, scope) {
|
|
125
|
+
return async (request) => {
|
|
126
|
+
assertRegistration(request, scope);
|
|
127
|
+
const key = await sandboxIdentityKey(storage, request.publishableKey);
|
|
128
|
+
const x = bytesToUrlSafeBase64(base64ToBytes(key.publicKey));
|
|
129
|
+
const jwk = { crv: 'Ed25519', kty: 'OKP', x };
|
|
130
|
+
const subject = bytesToUrlSafeBase64(await sha256(stringToBytes(JSON.stringify(jwk))));
|
|
131
|
+
const issuedAt = Math.floor(Date.now() / 1000);
|
|
132
|
+
const signingInput = `${encodeSegment({ alg: 'EdDSA', jwk, typ: 'JWT' })}.${encodeSegment({
|
|
133
|
+
assurance: 'normal',
|
|
134
|
+
aud: request.publishableKey,
|
|
135
|
+
exp: issuedAt + ASSERTION_LIFETIME_SECONDS,
|
|
136
|
+
iat: issuedAt,
|
|
137
|
+
iss: DEVICE_OWNED_ISSUER,
|
|
138
|
+
jti: await generateUuidV4(),
|
|
139
|
+
nbf: issuedAt,
|
|
140
|
+
purpose: request.purpose,
|
|
141
|
+
sub: subject,
|
|
142
|
+
token_use: 'identity',
|
|
143
|
+
})}`;
|
|
144
|
+
const signingBytes = stringToBytes(signingInput);
|
|
145
|
+
const signature = await sign(key.privateKey, signingBytes);
|
|
146
|
+
if (!(await verify(key.publicKey, signingBytes, signature))) {
|
|
147
|
+
throw new Error('Stored Signal Protocol Relay sandbox identity key is invalid');
|
|
148
|
+
}
|
|
149
|
+
return `${signingInput}.${bytesToUrlSafeBase64(base64ToBytes(signature))}`;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
101
152
|
/**
|
|
102
153
|
* Creates the identity assertion callback for a Sandbox environment of the
|
|
103
154
|
* Signal Protocol Relay.
|
|
@@ -110,9 +161,17 @@ function encodeSegment(value) {
|
|
|
110
161
|
* Sandbox account. Another device of the account joins through device linking.
|
|
111
162
|
*
|
|
112
163
|
* The callback rejects a request for a production environment, for recovery,
|
|
113
|
-
* for provider migration, or for recent or step-up assurance.
|
|
114
|
-
*
|
|
115
|
-
* device-owned
|
|
164
|
+
* for provider migration, or for recent or step-up assurance. This helper is
|
|
165
|
+
* the Sandbox-only guard, and it is not deprecated. For a Production project in
|
|
166
|
+
* device-owned mode, use {@link hostedRelayDeviceOwnedIdentity}. For a
|
|
167
|
+
* Production project in application-bound mode, supply a `getIdentityAssertion`
|
|
168
|
+
* callback that returns an assertion from your backend.
|
|
169
|
+
*
|
|
170
|
+
* The key is stored under the metadata key
|
|
171
|
+
* `'hostedRelay.sandboxIdentity.v1:'` followed by the base64 SHA-256 digest of
|
|
172
|
+
* the publishable key. This is a persisted format that both helpers keep. A
|
|
173
|
+
* new prefix would orphan existing Sandbox accounts. So for the same store and
|
|
174
|
+
* publishable key, both helpers sign with the same key.
|
|
116
175
|
*
|
|
117
176
|
* @example
|
|
118
177
|
* ```ts
|
|
@@ -127,31 +186,63 @@ function encodeSegment(value) {
|
|
|
127
186
|
* ```
|
|
128
187
|
*/
|
|
129
188
|
export function hostedRelaySandboxIdentity(storage) {
|
|
130
|
-
return
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
189
|
+
return deviceOwnedIdentity(storage, SANDBOX_SCOPE);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Creates the identity assertion callback for a device-owned account in a
|
|
193
|
+
* Sandbox environment, or in a Production environment that is configured in
|
|
194
|
+
* device-owned identity mode.
|
|
195
|
+
*
|
|
196
|
+
* The callback signs a short-lived device-owned assertion with an Ed25519 key
|
|
197
|
+
* that it keeps in `storage`. It creates the key on the first call and uses the
|
|
198
|
+
* same key after that, so the Relay returns the same account each time the
|
|
199
|
+
* device registers. The key is separate for each publishable key. Pass the
|
|
200
|
+
* same store as `adapters.storage`. The key never leaves the store. A device
|
|
201
|
+
* that loses the store loses the account, and its next registration creates a
|
|
202
|
+
* new account: the Relay refuses device-owned recovery. Another device of the
|
|
203
|
+
* account joins through device linking.
|
|
204
|
+
*
|
|
205
|
+
* The assertion is a compact JWS. Its protected header is
|
|
206
|
+
* `{ alg: 'EdDSA', typ: 'JWT', jwk: { kty: 'OKP', crv: 'Ed25519', x } }`,
|
|
207
|
+
* where `x` is the base64url public key. Its claims are:
|
|
208
|
+
*
|
|
209
|
+
* - `iss`: `'https://relay.open-e2ee.dev/device-owned'`.
|
|
210
|
+
* - `aud`: the publishable key of the request.
|
|
211
|
+
* - `sub`: the RFC 7638 SHA-256 thumbprint of the embedded JWK, base64url.
|
|
212
|
+
* - `iat` and `nbf`: the issue time in seconds. `exp`: `iat + 300`.
|
|
213
|
+
* - `jti`: a new UUID for each assertion.
|
|
214
|
+
* - `purpose`: `'register'`. `assurance`: `'normal'`.
|
|
215
|
+
* `token_use`: `'identity'`.
|
|
216
|
+
*
|
|
217
|
+
* The callback rejects a request for an environment other than Sandbox or
|
|
218
|
+
* Production, for recovery, for refresh or provider migration, or for recent or
|
|
219
|
+
* step-up assurance. It creates no key for a request that it rejects.
|
|
220
|
+
*
|
|
221
|
+
* The Production project must be configured in device-owned identity mode. A
|
|
222
|
+
* project in application-bound mode refuses this assertion with
|
|
223
|
+
* `ASSERTION_INVALID`. For that mode, supply a `getIdentityAssertion` callback
|
|
224
|
+
* that returns an assertion from your backend.
|
|
225
|
+
*
|
|
226
|
+
* The key is stored under the metadata key
|
|
227
|
+
* `'hostedRelay.sandboxIdentity.v1:'` followed by the base64 SHA-256 digest of
|
|
228
|
+
* the publishable key. This is a persisted format that both helpers keep. A
|
|
229
|
+
* new prefix would orphan existing Sandbox accounts. So for the same store
|
|
230
|
+
* and publishable key, this helper and {@link hostedRelaySandboxIdentity} sign
|
|
231
|
+
* with the same key, and the Relay returns the same account.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```ts
|
|
235
|
+
* const storage = inMemoryStore();
|
|
236
|
+
* const client = await createHostedSignalProtocolClient({
|
|
237
|
+
* adapters: { storage },
|
|
238
|
+
* hosted: {
|
|
239
|
+
* relayUrl: process.env.OPEN_E2EE_RELAY_URL!,
|
|
240
|
+
* getIdentityAssertion: hostedRelayDeviceOwnedIdentity(storage),
|
|
241
|
+
* },
|
|
242
|
+
* });
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
export function hostedRelayDeviceOwnedIdentity(storage) {
|
|
246
|
+
return deviceOwnedIdentity(storage, DEVICE_OWNED_SCOPE);
|
|
156
247
|
}
|
|
157
248
|
//# sourceMappingURL=hosted-sandbox-identity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-sandbox-identity.js","sourceRoot":"","sources":["../../client/hosted-sandbox-identity.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"hosted-sandbox-identity.js","sourceRoot":"","sources":["../../client/hosted-sandbox-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EACL,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EACtB,cAAc,EACd,MAAM,EACN,IAAI,EACJ,aAAa,EACb,MAAM,GACP,MAAM,oBAAoB,CAAC;AAK5B;;;;GAIG;AACH,MAAM,gCAAgC,GAAG,iCAAiC,CAAC;AAC3E,MAAM,mBAAmB,GAAG,0CAA0C,CAAC;AACvE,yDAAyD;AACzD,MAAM,0BAA0B,GAAG,GAAG,CAAC;AACvC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAO7B,+DAA+D;AAC/D,MAAM,WAAW,GAAG,IAAI,OAAO,EAG5B,CAAC;AAEJ,SAAS,eAAe,CAAC,KAAa;IACpC,MAAM,OAAO,GAAG,GAAG,EAAE,CACnB,IAAI,KAAK,CA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qDG;AACH,MAAM,UAAU,8BAA8B,CAC5C,OAAiC;IAEjC,OAAO,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -90,6 +90,18 @@ export declare class HostedRelayHttpTransport implements SignalProtocolRelayServ
|
|
|
90
90
|
* account a lookup already reads waits for that lookup.
|
|
91
91
|
*/
|
|
92
92
|
private lookUpDestinations;
|
|
93
|
+
/**
|
|
94
|
+
* The Relay refused a post to this mailbox generation as NOT_FOUND. True
|
|
95
|
+
* when a new read of the device directory lists the device at another
|
|
96
|
+
* mailbox generation: a recovery replaced the device, so the refusal is
|
|
97
|
+
* the stale-device refusal of the posted generation. False when the read
|
|
98
|
+
* fails, or the directory does not list the device, or lists it at the
|
|
99
|
+
* posted generation. The read refills the destination cache, so a repost
|
|
100
|
+
* goes to the listed generation. An identified post runs in a slot of the
|
|
101
|
+
* relay request bound, so it reads without a slot. A sealed post holds no
|
|
102
|
+
* slot, so it reads under the bound.
|
|
103
|
+
*/
|
|
104
|
+
private destinationRecovered;
|
|
93
105
|
private directory;
|
|
94
106
|
/**
|
|
95
107
|
* A prekey read addressed by the destination mailbox generation, because
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-transport.d.ts","sourceRoot":"","sources":["../../client/hosted-transport.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,2BAA2B,EAC3B,uBAAuB,EACvB,WAAW,EACX,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,yBAAyB,EACzB,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY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,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAIxH;YACa,eAAe;CAiB9B;AAED,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,oCAAoC,GAC5C,OAAO,CAAC,0BAA0B,CAAC,CAqFrC;AAED,wBAAsB,0BAA0B,CAAC,OAAO,EAAE;IACxD,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAC;IAC3C,QAAQ,CAAC,oBAAoB,EAAE,+BAA+B,CAAC;IAC/D,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;CAK5C,GAAG,OAAO,CAAC,0BAA0B,GAAG,SAAS,CAAC,CA6ClD;AAED,iFAAiF;AACjF,wBAAsB,wBAAwB,CAAC,OAAO,EAAE;IACtD,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAC;IAC3C,QAAQ,CAAC,aAAa,EAAE,wBAAwB,CAAC;IACjD,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;IAC3C,QAAQ,CAAC,OAAO,EAAE,mCAAmC,CAAC;CACvD,GAAG,OAAO,CAAC,0BAA0B,GAAG,kCAAkC,CAAC,CAQ3E"}
|
|
@@ -14,10 +14,11 @@ import { HostedGroupServer } from "./hosted-groups.js";
|
|
|
14
14
|
import { RELAY_PROTOCOL_VERSION, markRelayAnswerVersion, relayProtocolHeadersFor, throwIfUpgradeRequired, } from "./relay-protocol.js";
|
|
15
15
|
import { HostedRelayDeviceUnknownError, throwIfDeviceRevoked, } from "./hosted-device-standing.js";
|
|
16
16
|
import { HostedAnonymousDelivery, HostedAnonymousDeliveryError, decodeHostedAnonymousEnvelope, } from "./hosted-anonymous-delivery.js";
|
|
17
|
-
import { createAdapterRelayFanOut } from "./relay-work.js";
|
|
17
|
+
import { createAdapterRelayFanOut, rethrowRelayWorkStopped } from "./relay-work.js";
|
|
18
18
|
import { withRelayRequestDeadline } from "./relay-request-deadline.js";
|
|
19
19
|
import { applyPreKeyUploads, parseHostedPreKeyStatus, parseStoredPendingPublication, parseStoredPublication, publicationMatchesStatus, registrationPreKey, statusPreKeys, storedPreKey, storedPublication, } from "./hosted-prekey-publication.js";
|
|
20
20
|
import { declareRefusesRemovedDevices, markRelayDeviceRefusal, } from "./relay-device-refusal.js";
|
|
21
|
+
import { onePeriodClosedRetry } from "./relay-period-close.js";
|
|
21
22
|
import { declareComparesDeviceSets, deviceSetRefusal, markDeviceSetRefusal, parseDeviceSetRefusal, } from "../remote/relay/device-set.js";
|
|
22
23
|
import { admitRepeatRequest, markAfterRepeatedRequest, } from "../remote/relay/request-admission.js";
|
|
23
24
|
import { RelayReceiptInbox, declareRelayReceiptIntake, decodeRelayDeliveryReceipts, } from "./relay-receipt-intake.js";
|
|
@@ -482,7 +483,7 @@ export class HostedRelayHttpTransport {
|
|
|
482
483
|
if (generation === undefined)
|
|
483
484
|
throw missingDestination(accountAddress, deviceId);
|
|
484
485
|
return { accountAddress, deviceId, generation };
|
|
485
|
-
}, (clientMessageId, request) => admitRepeatRequest(this, clientMessageId, request), relayProtocolVersion);
|
|
486
|
+
}, (clientMessageId, request) => admitRepeatRequest(this, clientMessageId, request), relayProtocolVersion, ({ accountAddress, deviceId, generation }) => this.destinationRecovered(accountAddress, deviceId, generation, true));
|
|
486
487
|
}
|
|
487
488
|
get accountId() {
|
|
488
489
|
return this.session.canonicalAccountId;
|
|
@@ -764,6 +765,30 @@ export class HostedRelayHttpTransport {
|
|
|
764
765
|
}
|
|
765
766
|
return lookup;
|
|
766
767
|
}
|
|
768
|
+
/**
|
|
769
|
+
* The Relay refused a post to this mailbox generation as NOT_FOUND. True
|
|
770
|
+
* when a new read of the device directory lists the device at another
|
|
771
|
+
* mailbox generation: a recovery replaced the device, so the refusal is
|
|
772
|
+
* the stale-device refusal of the posted generation. False when the read
|
|
773
|
+
* fails, or the directory does not list the device, or lists it at the
|
|
774
|
+
* posted generation. The read refills the destination cache, so a repost
|
|
775
|
+
* goes to the listed generation. An identified post runs in a slot of the
|
|
776
|
+
* relay request bound, so it reads without a slot. A sealed post holds no
|
|
777
|
+
* slot, so it reads under the bound.
|
|
778
|
+
*/
|
|
779
|
+
async destinationRecovered(userId, deviceId, postedGeneration, underBound) {
|
|
780
|
+
try {
|
|
781
|
+
await (underBound
|
|
782
|
+
? this.fanOut.request(() => this.directory(userId))
|
|
783
|
+
: this.directory(userId));
|
|
784
|
+
}
|
|
785
|
+
catch (error) {
|
|
786
|
+
rethrowRelayWorkStopped(error);
|
|
787
|
+
return false;
|
|
788
|
+
}
|
|
789
|
+
const listed = this.destinationGenerations.get(`${userId}\0${String(deviceId)}`);
|
|
790
|
+
return listed !== undefined && listed !== postedGeneration;
|
|
791
|
+
}
|
|
767
792
|
async directory(userId) {
|
|
768
793
|
const value = await this.authenticatedPost("/identity/devices", {
|
|
769
794
|
accountAddress: userId,
|
|
@@ -1307,7 +1332,7 @@ export class HostedRelayHttpTransport {
|
|
|
1307
1332
|
},
|
|
1308
1333
|
];
|
|
1309
1334
|
let value;
|
|
1310
|
-
let
|
|
1335
|
+
let uncertainRepeat = false;
|
|
1311
1336
|
// Each repeat request meets the checks that the owner of the post
|
|
1312
1337
|
// registered under its message ID, and names its device and the answer
|
|
1313
1338
|
// that it follows.
|
|
@@ -1316,32 +1341,36 @@ export class HostedRelayHttpTransport {
|
|
|
1316
1341
|
deviceId: envelope.targetDeviceId,
|
|
1317
1342
|
after,
|
|
1318
1343
|
});
|
|
1344
|
+
const repeatAfterUncertain = async () => {
|
|
1345
|
+
await beforeRepeat("uncertain")();
|
|
1346
|
+
uncertainRepeat = true;
|
|
1347
|
+
};
|
|
1348
|
+
// A PERIOD_CLOSED answer proves that the Relay stored nothing, so the
|
|
1349
|
+
// same request goes once more, in the next period.
|
|
1350
|
+
const periodClosedRetry = onePeriodClosedRetry();
|
|
1319
1351
|
try {
|
|
1320
|
-
value = await withOneUncertainRetry(envelope.deliveryClass, () => {
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
...(deviceSets === undefined ? {} : { deviceSets }),
|
|
1338
|
-
}, beforeRepeat("token"));
|
|
1339
|
-
}, beforeRepeat("uncertain"));
|
|
1352
|
+
value = await withOneUncertainRetry(envelope.deliveryClass, () => periodClosedRetry(() => this.authenticatedPost("/delivery/send", {
|
|
1353
|
+
contentKind: envelope.contentKind ?? "message",
|
|
1354
|
+
deliveryClass: envelope.deliveryClass,
|
|
1355
|
+
destination: {
|
|
1356
|
+
accountAddress: envelope.targetUserId,
|
|
1357
|
+
deviceId: envelope.targetDeviceId,
|
|
1358
|
+
generation,
|
|
1359
|
+
},
|
|
1360
|
+
envelope: bytesToBase64(encodeDeliveryWire(envelope)),
|
|
1361
|
+
messageId,
|
|
1362
|
+
operationEpochMilliseconds: envelope.operationEpochMilliseconds ?? envelope.timestamp,
|
|
1363
|
+
publishableKey: this.connection.publishableKey,
|
|
1364
|
+
...(envelope.recipientRegistrationId === undefined
|
|
1365
|
+
? {}
|
|
1366
|
+
: { recipientRegistrationId: envelope.recipientRegistrationId }),
|
|
1367
|
+
...(deviceSets === undefined ? {} : { deviceSets }),
|
|
1368
|
+
}, beforeRepeat("token")), beforeRepeat("period-closed")), repeatAfterUncertain);
|
|
1340
1369
|
}
|
|
1341
1370
|
catch (error) {
|
|
1342
1371
|
// After an uncertain answer, the first request can have stored the
|
|
1343
1372
|
// copy, so the answer to the repeat tells nothing about the post.
|
|
1344
|
-
const answer = (failure) =>
|
|
1373
|
+
const answer = (failure) => uncertainRepeat ? markAfterRepeatedRequest(failure) : failure;
|
|
1345
1374
|
const device = {
|
|
1346
1375
|
userId: envelope.targetUserId,
|
|
1347
1376
|
deviceId: envelope.targetDeviceId,
|
|
@@ -1353,22 +1382,42 @@ export class HostedRelayHttpTransport {
|
|
|
1353
1382
|
throw answer(markDeviceSetRefusal(error, refusal));
|
|
1354
1383
|
}
|
|
1355
1384
|
}
|
|
1385
|
+
const staleDevice = (stale) => answer(markRelayDeviceRefusal(new HostedRelayHttpError(stale.status, "STALE_DEVICE", stale.message, {
|
|
1386
|
+
data: {
|
|
1387
|
+
code: "STALE_DEVICE",
|
|
1388
|
+
message: stale.message,
|
|
1389
|
+
reason: "device_reinstalled",
|
|
1390
|
+
staleDevices: [envelope.targetDeviceId],
|
|
1391
|
+
},
|
|
1392
|
+
retryable: stale.retryable,
|
|
1393
|
+
}), { code: "STALE_DEVICE", ...device }));
|
|
1356
1394
|
if (error instanceof HostedRelayHttpError &&
|
|
1357
1395
|
error.code === "STALE_DEVICE") {
|
|
1358
|
-
throw
|
|
1359
|
-
data: {
|
|
1360
|
-
code: "STALE_DEVICE",
|
|
1361
|
-
message: error.message,
|
|
1362
|
-
reason: "device_reinstalled",
|
|
1363
|
-
staleDevices: [envelope.targetDeviceId],
|
|
1364
|
-
},
|
|
1365
|
-
retryable: error.retryable,
|
|
1366
|
-
}), { code: "STALE_DEVICE", ...device }));
|
|
1396
|
+
throw staleDevice(error);
|
|
1367
1397
|
}
|
|
1368
1398
|
// Only the Relay's own error body names NOT_FOUND. A 404 without it
|
|
1369
1399
|
// fails to parse or carries no code, so it is not a device refusal.
|
|
1370
|
-
if (error instanceof HostedRelayHttpError && error.code === "NOT_FOUND")
|
|
1400
|
+
if (error instanceof HostedRelayHttpError && error.code === "NOT_FOUND") {
|
|
1401
|
+
// A recovery retired the posted generation. As for a stale device,
|
|
1402
|
+
// the send archives the session and posts to the recovered device.
|
|
1403
|
+
// A declared post gets the declared STALE_DEVICE that the Relay
|
|
1404
|
+
// gives for a changed registration.
|
|
1405
|
+
if (await this.destinationRecovered(envelope.targetUserId, envelope.targetDeviceId, generation, false)) {
|
|
1406
|
+
const stale = staleDevice(error);
|
|
1407
|
+
throw deviceSets === undefined
|
|
1408
|
+
? stale
|
|
1409
|
+
: markDeviceSetRefusal(stale, {
|
|
1410
|
+
kind: "stale",
|
|
1411
|
+
accounts: [
|
|
1412
|
+
{
|
|
1413
|
+
userId: envelope.targetUserId,
|
|
1414
|
+
staleDeviceIds: [envelope.targetDeviceId],
|
|
1415
|
+
},
|
|
1416
|
+
],
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1371
1419
|
throw answer(markRelayDeviceRefusal(error, { code: "NOT_FOUND", ...device }));
|
|
1420
|
+
}
|
|
1372
1421
|
throw answer(error);
|
|
1373
1422
|
}
|
|
1374
1423
|
if (!record(value) ||
|
|
@@ -1390,7 +1439,7 @@ export class HostedRelayHttpTransport {
|
|
|
1390
1439
|
serverTimestamp: typeof value.enqueuedAt === "number"
|
|
1391
1440
|
? value.enqueuedAt
|
|
1392
1441
|
: envelope.timestamp,
|
|
1393
|
-
...(typeof value.duplicate === "boolean" &&
|
|
1442
|
+
...(typeof value.duplicate === "boolean" && !uncertainRepeat
|
|
1394
1443
|
? { duplicate: value.duplicate }
|
|
1395
1444
|
: {}),
|
|
1396
1445
|
...(typeof value.expiresAt === "number"
|
|
@@ -1432,14 +1481,7 @@ export class HostedRelayHttpTransport {
|
|
|
1432
1481
|
const previous = this.session.deviceToken;
|
|
1433
1482
|
const token = await this.token();
|
|
1434
1483
|
const url = websocketUrl(`${identifiedEndpoint(this.connection)}/mailbox/connect`, [["publishableKey", this.connection.publishableKey]]);
|
|
1435
|
-
return {
|
|
1436
|
-
url,
|
|
1437
|
-
token,
|
|
1438
|
-
renewAt: (tokenExpiration(token, this.session) -
|
|
1439
|
-
DEVICE_TOKEN_REFRESH_SECONDS) *
|
|
1440
|
-
1_000,
|
|
1441
|
-
refreshed: token !== previous,
|
|
1442
|
-
};
|
|
1484
|
+
return { url, token, refreshed: token !== previous };
|
|
1443
1485
|
},
|
|
1444
1486
|
isConclusiveRefusal,
|
|
1445
1487
|
decodeDurable: (message) => this.incomingEnvelope(message),
|