@open-e2ee/signal-protocol-sdk 13.3.0 → 13.5.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 +436 -0
- package/README.md +1 -1
- package/SECURITY.md +2 -2
- package/dist/client/binary-send.d.ts +28 -0
- package/dist/client/binary-send.d.ts.map +1 -0
- package/dist/client/binary-send.js +26 -0
- package/dist/client/binary-send.js.map +1 -0
- package/dist/client/client.d.ts +47 -6
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +288 -136
- package/dist/client/client.js.map +1 -1
- package/dist/client/content-adapter.d.ts +18 -0
- package/dist/client/content-adapter.d.ts.map +1 -1
- package/dist/client/content-adapter.js.map +1 -1
- package/dist/client/device-set-reconciliation.d.ts +23 -8
- package/dist/client/device-set-reconciliation.d.ts.map +1 -1
- package/dist/client/device-set-reconciliation.js +25 -11
- package/dist/client/device-set-reconciliation.js.map +1 -1
- package/dist/client/event-hooks.d.ts +88 -8
- 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/group-outbox.d.ts +45 -10
- package/dist/client/group-outbox.d.ts.map +1 -1
- package/dist/client/group-outbox.js +246 -154
- package/dist/client/group-outbox.js.map +1 -1
- package/dist/client/group-receive-authorization.d.ts +10 -1
- package/dist/client/group-receive-authorization.d.ts.map +1 -1
- package/dist/client/group-receive-authorization.js.map +1 -1
- package/dist/client/hosted-anonymous-delivery.d.ts +18 -1
- package/dist/client/hosted-anonymous-delivery.d.ts.map +1 -1
- package/dist/client/hosted-anonymous-delivery.js +84 -12
- package/dist/client/hosted-anonymous-delivery.js.map +1 -1
- package/dist/client/hosted-connection.js +1 -1
- package/dist/client/hosted-connection.js.map +1 -1
- package/dist/client/hosted-group-authority.d.ts +6 -2
- package/dist/client/hosted-group-authority.d.ts.map +1 -1
- package/dist/client/hosted-group-authority.js +11 -7
- package/dist/client/hosted-group-authority.js.map +1 -1
- package/dist/client/hosted-groups.d.ts +5 -1
- package/dist/client/hosted-groups.d.ts.map +1 -1
- package/dist/client/hosted-groups.js +8 -4
- package/dist/client/hosted-groups.js.map +1 -1
- package/dist/client/hosted-http-error.d.ts +5 -1
- package/dist/client/hosted-http-error.d.ts.map +1 -1
- package/dist/client/hosted-http-error.js +5 -1
- package/dist/client/hosted-http-error.js.map +1 -1
- package/dist/client/hosted-mailbox-subscription.d.ts +2 -0
- package/dist/client/hosted-mailbox-subscription.d.ts.map +1 -1
- package/dist/client/hosted-mailbox-subscription.js +5 -5
- package/dist/client/hosted-mailbox-subscription.js.map +1 -1
- package/dist/client/hosted-resume-error.d.ts +19 -0
- package/dist/client/hosted-resume-error.d.ts.map +1 -0
- package/dist/client/hosted-resume-error.js +44 -0
- package/dist/client/hosted-resume-error.js.map +1 -0
- package/dist/client/hosted-resume.d.ts +24 -0
- package/dist/client/hosted-resume.d.ts.map +1 -0
- package/dist/client/hosted-resume.js +82 -0
- package/dist/client/hosted-resume.js.map +1 -0
- package/dist/client/hosted-transport.d.ts +11 -1
- package/dist/client/hosted-transport.d.ts.map +1 -1
- package/dist/client/hosted-transport.js +102 -33
- package/dist/client/hosted-transport.js.map +1 -1
- package/dist/client/hosted.d.ts.map +1 -1
- package/dist/client/hosted.js +29 -6
- package/dist/client/hosted.js.map +1 -1
- package/dist/client/index.d.ts +3 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/receive-queue.d.ts +5 -2
- package/dist/client/receive-queue.d.ts.map +1 -1
- package/dist/client/receive-queue.js +55 -18
- package/dist/client/receive-queue.js.map +1 -1
- package/dist/client/relay-acceptance.d.ts +49 -6
- package/dist/client/relay-acceptance.d.ts.map +1 -1
- package/dist/client/relay-acceptance.js +49 -3
- package/dist/client/relay-acceptance.js.map +1 -1
- package/dist/client/relay-protocol.d.ts +37 -7
- package/dist/client/relay-protocol.d.ts.map +1 -1
- package/dist/client/relay-protocol.js +53 -10
- package/dist/client/relay-protocol.js.map +1 -1
- package/dist/client/retry-family.d.ts +3 -3
- package/dist/client/retry-family.js +1 -1
- package/dist/client/retry-family.js.map +1 -1
- package/dist/client/retry-request-envelope.d.ts +18 -8
- package/dist/client/retry-request-envelope.d.ts.map +1 -1
- package/dist/client/retry-request-envelope.js +57 -29
- package/dist/client/retry-request-envelope.js.map +1 -1
- package/dist/client/retry-request-lifecycle.d.ts +24 -11
- package/dist/client/retry-request-lifecycle.d.ts.map +1 -1
- package/dist/client/retry-request-lifecycle.js +46 -20
- package/dist/client/retry-request-lifecycle.js.map +1 -1
- package/dist/client/retry-terminal-recovery.d.ts +11 -8
- package/dist/client/retry-terminal-recovery.d.ts.map +1 -1
- package/dist/client/retry-terminal-recovery.js +18 -12
- package/dist/client/retry-terminal-recovery.js.map +1 -1
- package/dist/client/retry.d.ts +8 -7
- package/dist/client/retry.d.ts.map +1 -1
- package/dist/client/retry.js +30 -22
- package/dist/client/retry.js.map +1 -1
- package/dist/client/send-deadline.d.ts +308 -0
- package/dist/client/send-deadline.d.ts.map +1 -0
- package/dist/client/send-deadline.js +914 -0
- package/dist/client/send-deadline.js.map +1 -0
- package/dist/client/send-intent-driver.d.ts +116 -0
- package/dist/client/send-intent-driver.d.ts.map +1 -0
- package/dist/client/send-intent-driver.js +373 -0
- package/dist/client/send-intent-driver.js.map +1 -0
- package/dist/client/signal-service-cipher.d.ts +257 -27
- package/dist/client/signal-service-cipher.d.ts.map +1 -1
- package/dist/client/signal-service-cipher.js +1274 -283
- package/dist/client/signal-service-cipher.js.map +1 -1
- package/dist/client/startup-cleanup.d.ts +2 -0
- package/dist/client/startup-cleanup.d.ts.map +1 -0
- package/dist/client/startup-cleanup.js +14 -0
- package/dist/client/startup-cleanup.js.map +1 -0
- package/dist/client/types.d.ts +48 -5
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/types.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/manager/manager.d.ts +1 -0
- package/dist/internal/manager/manager.d.ts.map +1 -1
- package/dist/internal/manager/manager.js +17 -2
- package/dist/internal/manager/manager.js.map +1 -1
- package/dist/internal/manager/retained-identity.d.ts +2 -0
- package/dist/internal/manager/retained-identity.d.ts.map +1 -0
- package/dist/internal/manager/retained-identity.js +57 -0
- package/dist/internal/manager/retained-identity.js.map +1 -0
- package/dist/local/store/conformance/cases/metadata.d.ts +3 -2
- package/dist/local/store/conformance/cases/metadata.d.ts.map +1 -1
- package/dist/local/store/conformance/cases/metadata.js +153 -2
- package/dist/local/store/conformance/cases/metadata.js.map +1 -1
- package/dist/local/store/key-value/adapter.d.ts +2 -1
- package/dist/local/store/key-value/adapter.d.ts.map +1 -1
- package/dist/local/store/key-value/adapter.js +9 -0
- package/dist/local/store/key-value/adapter.js.map +1 -1
- package/dist/local/store/memory/adapter.d.ts +2 -1
- package/dist/local/store/memory/adapter.d.ts.map +1 -1
- package/dist/local/store/memory/adapter.js +4 -0
- package/dist/local/store/memory/adapter.js.map +1 -1
- package/dist/local/store/metadata-keys.d.ts +13 -0
- package/dist/local/store/metadata-keys.d.ts.map +1 -0
- package/dist/local/store/metadata-keys.js +20 -0
- package/dist/local/store/metadata-keys.js.map +1 -0
- package/dist/local/store/receive-work.d.ts.map +1 -1
- package/dist/local/store/receive-work.js +12 -1
- package/dist/local/store/receive-work.js.map +1 -1
- package/dist/local/store/reliability.d.ts +482 -33
- package/dist/local/store/reliability.d.ts.map +1 -1
- package/dist/local/store/reliability.js +690 -48
- package/dist/local/store/reliability.js.map +1 -1
- package/dist/local/store/sqlite/key-storage/index.d.ts +2 -1
- package/dist/local/store/sqlite/key-storage/index.d.ts.map +1 -1
- package/dist/local/store/sqlite/key-storage/index.js +3 -0
- package/dist/local/store/sqlite/key-storage/index.js.map +1 -1
- package/dist/local/store/sqlite/key-storage/metadata.d.ts +9 -0
- package/dist/local/store/sqlite/key-storage/metadata.d.ts.map +1 -1
- package/dist/local/store/sqlite/key-storage/metadata.js +12 -0
- package/dist/local/store/sqlite/key-storage/metadata.js.map +1 -1
- package/dist/local/store/sqlite/store.d.ts +2 -1
- package/dist/local/store/sqlite/store.d.ts.map +1 -1
- package/dist/local/store/sqlite/store.js +3 -0
- package/dist/local/store/sqlite/store.js.map +1 -1
- package/dist/local/store/web/adapter.d.ts +8 -1
- package/dist/local/store/web/adapter.d.ts.map +1 -1
- package/dist/local/store/web/adapter.js +18 -0
- package/dist/local/store/web/adapter.js.map +1 -1
- package/dist/remote/relay/request-admission.d.ts +49 -0
- package/dist/remote/relay/request-admission.d.ts.map +1 -0
- package/dist/remote/relay/request-admission.js +74 -0
- package/dist/remote/relay/request-admission.js.map +1 -0
- package/dist/types/api.d.ts +77 -0
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/errors.d.ts +144 -1
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +146 -1
- package/dist/types/errors.js.map +1 -1
- package/docs/ASSURANCE.md +5 -5
- package/docs/DEVIATIONS.md +34 -4
- package/docs/ERROR_HANDLING.md +134 -7
- package/docs/PACKAGE_SURFACE.md +21 -0
- package/docs/RECIPES.md +3 -2
- package/package.json +1 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/** Resume existing hosted authority without an assertion or registration fallback. */
|
|
2
|
+
import { readRetainedIdentities, RetainedIdentityError, } from '../internal/manager/retained-identity.js';
|
|
3
|
+
import { createClientWithRetainedIdentities, } from './client.js';
|
|
4
|
+
import { ClientStartupCleanupError } from './startup-cleanup.js';
|
|
5
|
+
import { createClientFromHostedResult, getExistingDeviceAuthentication, } from './hosted.js';
|
|
6
|
+
import { resolveHostedRelayConnection } from './hosted-connection.js';
|
|
7
|
+
import { resumeHostedRelayTransport } from './hosted-transport.js';
|
|
8
|
+
import { assertHostedRelayProfileKeys } from './hosted-profile-keys.js';
|
|
9
|
+
import { HostedRelayResumeError, retainHostedResumeCleanup, } from './hosted-resume-error.js';
|
|
10
|
+
/**
|
|
11
|
+
* Require the existing permanent identities, device key and scoped hosted session.
|
|
12
|
+
* Renews the token and starts the ordinary client, including prekey maintenance and
|
|
13
|
+
* automatic subscription. Never requests assertions or registers a replacement.
|
|
14
|
+
* The caller owns the already-open store and must not use it concurrently.
|
|
15
|
+
* On an unresolved stop, the thrown HostedRelayResumeError owns retryCleanup().
|
|
16
|
+
*/
|
|
17
|
+
export async function resumeHostedSignalProtocolClient(options) {
|
|
18
|
+
const { adapters, hosted, ...clientOptions } = options;
|
|
19
|
+
if (adapters.protocolManager !== undefined ||
|
|
20
|
+
['getIdentityAssertion', 'assertionPurpose', 'assurance'].some((key) => Object.hasOwn(hosted, key))) {
|
|
21
|
+
throw new TypeError('Strict hosted resume does not accept registration options or a custom protocol manager.');
|
|
22
|
+
}
|
|
23
|
+
if (hosted.profileKeys !== undefined)
|
|
24
|
+
assertHostedRelayProfileKeys(hosted.profileKeys);
|
|
25
|
+
let phase = 'reading-local-state';
|
|
26
|
+
let captured;
|
|
27
|
+
const progress = (next) => {
|
|
28
|
+
phase = next;
|
|
29
|
+
hosted.onProgress?.({ phase });
|
|
30
|
+
};
|
|
31
|
+
try {
|
|
32
|
+
progress('reading-local-state');
|
|
33
|
+
// Hosted composition activates ACI. The manager checks all actual active types.
|
|
34
|
+
const identities = await readRetainedIdentities(adapters.storage, ['aci']);
|
|
35
|
+
const connection = await resolveHostedRelayConnection(hosted.relayUrl);
|
|
36
|
+
const deviceAuthentication = await getExistingDeviceAuthentication(adapters.storage, connection.publishableKey, true);
|
|
37
|
+
const resumed = await resumeHostedRelayTransport({
|
|
38
|
+
connection,
|
|
39
|
+
deviceAuthentication,
|
|
40
|
+
storage: adapters.storage,
|
|
41
|
+
requireExisting: true,
|
|
42
|
+
onAuthenticating: () => progress('authenticating'),
|
|
43
|
+
});
|
|
44
|
+
if (!resumed)
|
|
45
|
+
throw new HostedRelayResumeError('RETAINED_SESSION_UNAVAILABLE', 'reading-local-state');
|
|
46
|
+
progress('initializing');
|
|
47
|
+
const client = await createClientFromHostedResult(resumed, connection, adapters, clientOptions, hosted.sealedSenderAccessMode, resumed.remoteObjectStore, resumed.transport, hosted.profileKeys, async (userId, config) => {
|
|
48
|
+
captured = await createClientWithRetainedIdentities(userId, config, identities);
|
|
49
|
+
return captured;
|
|
50
|
+
});
|
|
51
|
+
if (client.syncStatus === 'failed')
|
|
52
|
+
throw new Error('OpenE2EE Signal Protocol Relay initial synchronization failed');
|
|
53
|
+
progress('complete');
|
|
54
|
+
return client;
|
|
55
|
+
}
|
|
56
|
+
catch (caught) {
|
|
57
|
+
let failure = caught;
|
|
58
|
+
if (captured) {
|
|
59
|
+
try {
|
|
60
|
+
await captured.stop();
|
|
61
|
+
}
|
|
62
|
+
catch (cleanupFailure) {
|
|
63
|
+
failure = new ClientStartupCleanupError(caught, cleanupFailure, () => captured.stop());
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (failure instanceof ClientStartupCleanupError) {
|
|
67
|
+
const error = new HostedRelayResumeError('RESUME_CLEANUP_UNRESOLVED', phase, { cause: failure.failure });
|
|
68
|
+
retainHostedResumeCleanup(error, failure.retryCleanup);
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
if (failure instanceof RetainedIdentityError) {
|
|
72
|
+
const code = failure.reason === 'changed'
|
|
73
|
+
? 'RETAINED_IDENTITY_CHANGED'
|
|
74
|
+
: failure.reason === 'unreadable'
|
|
75
|
+
? 'RETAINED_STATE_UNREADABLE'
|
|
76
|
+
: 'RETAINED_IDENTITY_UNAVAILABLE';
|
|
77
|
+
throw new HostedRelayResumeError(code, phase, { cause: failure });
|
|
78
|
+
}
|
|
79
|
+
throw failure;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=hosted-resume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-resume.js","sourceRoot":"","sources":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M,CAAC;IAChB,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,IAAI,OAAO,GAAG,MAAM,CAAC;QACrB,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC;gBACH,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACxB,CAAC;YAAC,OAAO,cAAc,EAAE,CAAC;gBACxB,OAAO,GAAG,IAAI,yBAAyB,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,CACnE,QAAS,CAAC,IAAI,EAAE,CACjB,CAAC;YACJ,CAAC;QACH,CAAC;QACD,IAAI,OAAO,YAAY,yBAAyB,EAAE,CAAC;YACjD,MAAM,KAAK,GAAG,IAAI,sBAAsB,CACtC,2BAA2B,EAC3B,KAAK,EACL,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE,CAC3B,CAAC;YACF,yBAAyB,CAAC,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;YACvD,MAAM,KAAK,CAAC;QACd,CAAC;QACD,IAAI,OAAO,YAAY,qBAAqB,EAAE,CAAC;YAC7C,MAAM,IAAI,GACR,OAAO,CAAC,MAAM,KAAK,SAAS;gBAC1B,CAAC,CAAC,2BAA2B;gBAC7B,CAAC,CAAC,OAAO,CAAC,MAAM,KAAK,YAAY;oBAC/B,CAAC,CAAC,2BAA2B;oBAC7B,CAAC,CAAC,+BAA+B,CAAC;YACxC,MAAM,IAAI,sBAAsB,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QACpE,CAAC;QACD,MAAM,OAAO,CAAC;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -60,7 +60,12 @@ export declare class HostedRelayHttpTransport implements SignalProtocolRelayServ
|
|
|
60
60
|
private readonly presenceListeners;
|
|
61
61
|
private readonly receiptInbox;
|
|
62
62
|
private readonly receiptJoin;
|
|
63
|
-
constructor(connection: HostedRelayConnection, storage: SignalProtocolLocalStore, deviceAuthentication: HostedRelayDeviceAuthentication, session: StoredHostedRelaySession, persistRefreshedToken?: boolean
|
|
63
|
+
constructor(connection: HostedRelayConnection, storage: SignalProtocolLocalStore, deviceAuthentication: HostedRelayDeviceAuthentication, session: StoredHostedRelaySession, persistRefreshedToken?: boolean,
|
|
64
|
+
/**
|
|
65
|
+
* @internal The Relay protocol version of the client that owns this
|
|
66
|
+
* transport. Every carrier of the client sends it.
|
|
67
|
+
*/
|
|
68
|
+
relayProtocolVersion?: number);
|
|
64
69
|
get accountId(): string;
|
|
65
70
|
get deviceId(): number;
|
|
66
71
|
readonly objectStore: SignalProtocolRemoteObjectStore;
|
|
@@ -73,6 +78,11 @@ export declare class HostedRelayHttpTransport implements SignalProtocolRelayServ
|
|
|
73
78
|
ensureAuthenticated(force?: boolean): Promise<void>;
|
|
74
79
|
/** Private-package link capability. Detached active authority never persists. */
|
|
75
80
|
linkDevice(request: HostedRelayManagedDeviceLinkRequest, storage: SignalProtocolLocalStore): Promise<HostedRelayTransportResult & HostedRelayManagedDeviceLinkResult>;
|
|
81
|
+
/**
|
|
82
|
+
* Post with the device token. On TOKEN_INVALID, get a new token and post
|
|
83
|
+
* once more. When `beforeRepeat` rejects, no repeat starts and the
|
|
84
|
+
* TOKEN_INVALID error is thrown.
|
|
85
|
+
*/
|
|
76
86
|
private authenticatedPost;
|
|
77
87
|
private assertCurrentIdentity;
|
|
78
88
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-transport.d.ts","sourceRoot":"","sources":["../../client/hosted-transport.ts"],"names":[],"mappings":"
|
|
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,gBAAg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AAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAG7F;IACY,4BAA4B,CAAC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,kBAAkB,GAAG,OAAO,CAAC;QAAE,YAAY,EAAE,UAAU,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAE3J;IACY,yBAAyB,CAAC,MAAM,EAAE,MAAM,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"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HostedRelayResumeError } from './hosted-resume-error.js';
|
|
1
2
|
import { hostedAssertionIdentifier } from "./hosted-assertion-id.js";
|
|
2
3
|
import { HostedRelayHttpError } from "./hosted-http-error.js";
|
|
3
4
|
import { submitHostedRelayDeviceLink } from "./hosted-device-link-transport.js";
|
|
@@ -10,7 +11,7 @@ import { RelayConnectionStateOwner } from "../remote/relay/connection-state.js";
|
|
|
10
11
|
import { presenceHttpBody, } from "./hosted-presence-frames.js";
|
|
11
12
|
import { subscribeHostedMailbox, } from "./hosted-mailbox-subscription.js";
|
|
12
13
|
import { HostedGroupServer } from "./hosted-groups.js";
|
|
13
|
-
import {
|
|
14
|
+
import { RELAY_PROTOCOL_VERSION, markRelayAnswerVersion, relayProtocolHeadersFor, throwIfUpgradeRequired, } from "./relay-protocol.js";
|
|
14
15
|
import { HostedRelayDeviceUnknownError, throwIfDeviceRevoked, } from "./hosted-device-standing.js";
|
|
15
16
|
import { HostedAnonymousDelivery, HostedAnonymousDeliveryError, decodeHostedAnonymousEnvelope, } from "./hosted-anonymous-delivery.js";
|
|
16
17
|
import { createAdapterRelayFanOut } from "./relay-work.js";
|
|
@@ -18,6 +19,7 @@ import { withRelayRequestDeadline } from "./relay-request-deadline.js";
|
|
|
18
19
|
import { applyPreKeyUploads, parseHostedPreKeyStatus, parseStoredPendingPublication, parseStoredPublication, publicationMatchesStatus, registrationPreKey, statusPreKeys, storedPreKey, storedPublication, } from "./hosted-prekey-publication.js";
|
|
19
20
|
import { declareRefusesRemovedDevices, markRelayDeviceRefusal, } from "./relay-device-refusal.js";
|
|
20
21
|
import { declareComparesDeviceSets, deviceSetRefusal, markDeviceSetRefusal, parseDeviceSetRefusal, } from "../remote/relay/device-set.js";
|
|
22
|
+
import { admitRepeatRequest, markAfterRepeatedRequest, } from "../remote/relay/request-admission.js";
|
|
21
23
|
import { RelayReceiptInbox, declareRelayReceiptIntake, decodeRelayDeliveryReceipts, } from "./relay-receipt-intake.js";
|
|
22
24
|
import { RelayReceiptJoin, declareRelayReceiptJoin, } from "./relay-receipt-join.js";
|
|
23
25
|
const SESSION_METADATA_PREFIX = "hostedRelay.session.v1:";
|
|
@@ -76,9 +78,10 @@ function isConclusiveRefusal(error) {
|
|
|
76
78
|
* answers 503 `DELIVERY_UNCERTAIN`. The operation identifier makes a repeat
|
|
77
79
|
* exact, so the transport sends the same request once more before it
|
|
78
80
|
* surfaces the error. An ephemeral delivery is best-effort, so an uncertain
|
|
79
|
-
* answer on that class is not repeated.
|
|
81
|
+
* answer on that class is not repeated. When `beforeRepeat` rejects, no repeat
|
|
82
|
+
* starts and the first `DELIVERY_UNCERTAIN` error is thrown.
|
|
80
83
|
*/
|
|
81
|
-
async function withOneUncertainRetry(deliveryClass, post) {
|
|
84
|
+
async function withOneUncertainRetry(deliveryClass, post, beforeRepeat) {
|
|
82
85
|
try {
|
|
83
86
|
return await post();
|
|
84
87
|
}
|
|
@@ -88,6 +91,12 @@ async function withOneUncertainRetry(deliveryClass, post) {
|
|
|
88
91
|
error.code !== "DELIVERY_UNCERTAIN") {
|
|
89
92
|
throw error;
|
|
90
93
|
}
|
|
94
|
+
try {
|
|
95
|
+
await beforeRepeat?.();
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
91
100
|
return post();
|
|
92
101
|
}
|
|
93
102
|
}
|
|
@@ -148,7 +157,12 @@ function relayScopeId(connection) {
|
|
|
148
157
|
function identifiedEndpoint(connection) {
|
|
149
158
|
return connection.protocolEndpoint.replace(/\/$/u, "");
|
|
150
159
|
}
|
|
151
|
-
|
|
160
|
+
/**
|
|
161
|
+
* Read the body of a Relay answer. An error answer throws, and the error
|
|
162
|
+
* records `relayProtocolVersion`, the protocol version of the request that
|
|
163
|
+
* it answers.
|
|
164
|
+
*/
|
|
165
|
+
async function parseResponse(response, relayProtocolVersion) {
|
|
152
166
|
const body = await response.text();
|
|
153
167
|
if (body.length > MAXIMUM_RESPONSE_BYTES) {
|
|
154
168
|
throw new Error("Signal Protocol Relay response is too large");
|
|
@@ -173,7 +187,7 @@ async function parseResponse(response) {
|
|
|
173
187
|
// stays a `HostedRelayHttpError` whose `retryable` is true: the Relay
|
|
174
188
|
// sends it for a version above the newest one that it serves, which
|
|
175
189
|
// happens only after a Relay rollback.
|
|
176
|
-
throwIfUpgradeRequired(response.status, parsed);
|
|
190
|
+
throwIfUpgradeRequired(response.status, parsed, relayProtocolVersion);
|
|
177
191
|
throwIfDeviceRevoked(response.status, parsed);
|
|
178
192
|
const error = record(parsed) && record(parsed.error) ? parsed.error : {};
|
|
179
193
|
const code = typeof error.code === "string" ? error.code : "UNKNOWN";
|
|
@@ -182,10 +196,10 @@ async function parseResponse(response) {
|
|
|
182
196
|
: "Signal Protocol Relay request failed";
|
|
183
197
|
// A refused declared post names the devices of each account in
|
|
184
198
|
// `details`. The error keeps them for the device-set reconciliation.
|
|
185
|
-
throw new HostedRelayHttpError(response.status, code, message, {
|
|
199
|
+
throw markRelayAnswerVersion(new HostedRelayHttpError(response.status, code, message, {
|
|
186
200
|
...(record(error.details) ? { data: { details: error.details } } : {}),
|
|
187
201
|
retryable: error.retryable === true,
|
|
188
|
-
});
|
|
202
|
+
}), relayProtocolVersion);
|
|
189
203
|
}
|
|
190
204
|
return parsed;
|
|
191
205
|
}
|
|
@@ -196,11 +210,11 @@ async function parseResponse(response) {
|
|
|
196
210
|
function missingDestination(userId, deviceId) {
|
|
197
211
|
return markRelayDeviceRefusal(new Error("Signal Protocol Relay destination device does not exist"), { code: "NOT_FOUND", userId, deviceId });
|
|
198
212
|
}
|
|
199
|
-
async function postJson(connection, path, body, token) {
|
|
213
|
+
async function postJson(connection, relayProtocolVersion, path, body, token) {
|
|
200
214
|
const headers = new Headers({
|
|
201
215
|
accept: "application/json",
|
|
202
216
|
"content-type": "application/json",
|
|
203
|
-
...
|
|
217
|
+
...relayProtocolHeadersFor(relayProtocolVersion),
|
|
204
218
|
});
|
|
205
219
|
if (token !== undefined)
|
|
206
220
|
headers.set("authorization", `Bearer ${token}`);
|
|
@@ -219,7 +233,7 @@ async function postJson(connection, path, body, token) {
|
|
|
219
233
|
catch (cause) {
|
|
220
234
|
throw new Error("Signal Protocol Relay request could not be completed", { cause });
|
|
221
235
|
}
|
|
222
|
-
return parseResponse(response);
|
|
236
|
+
return parseResponse(response, relayProtocolVersion);
|
|
223
237
|
});
|
|
224
238
|
}
|
|
225
239
|
function serializedPreKey(prekey) {
|
|
@@ -409,6 +423,7 @@ export class HostedRelayHttpTransport {
|
|
|
409
423
|
deviceAuthentication;
|
|
410
424
|
session;
|
|
411
425
|
persistRefreshedToken;
|
|
426
|
+
relayProtocolVersion;
|
|
412
427
|
groups;
|
|
413
428
|
groupServer;
|
|
414
429
|
anonymousDelivery;
|
|
@@ -424,12 +439,18 @@ export class HostedRelayHttpTransport {
|
|
|
424
439
|
presenceListeners = new Set();
|
|
425
440
|
receiptInbox = new RelayReceiptInbox();
|
|
426
441
|
receiptJoin = new RelayReceiptJoin();
|
|
427
|
-
constructor(connection, storage, deviceAuthentication, session, persistRefreshedToken = true
|
|
442
|
+
constructor(connection, storage, deviceAuthentication, session, persistRefreshedToken = true,
|
|
443
|
+
/**
|
|
444
|
+
* @internal The Relay protocol version of the client that owns this
|
|
445
|
+
* transport. Every carrier of the client sends it.
|
|
446
|
+
*/
|
|
447
|
+
relayProtocolVersion = RELAY_PROTOCOL_VERSION) {
|
|
428
448
|
this.connection = connection;
|
|
429
449
|
this.storage = storage;
|
|
430
450
|
this.deviceAuthentication = deviceAuthentication;
|
|
431
451
|
this.session = session;
|
|
432
452
|
this.persistRefreshedToken = persistRefreshedToken;
|
|
453
|
+
this.relayProtocolVersion = relayProtocolVersion;
|
|
433
454
|
// The Relay refuses a removed device's mailbox on every send path before
|
|
434
455
|
// its device list shows the removal, so a direct send may post first.
|
|
435
456
|
declareRefusesRemovedDevices(this);
|
|
@@ -441,7 +462,7 @@ export class HostedRelayHttpTransport {
|
|
|
441
462
|
// each acknowledgment with the messages whose receipt it owns.
|
|
442
463
|
declareRelayReceiptIntake(this, this.receiptInbox);
|
|
443
464
|
declareRelayReceiptJoin(this, this.receiptJoin);
|
|
444
|
-
this.groups = new HostedGroupServer(connection);
|
|
465
|
+
this.groups = new HostedGroupServer(connection, relayProtocolVersion);
|
|
445
466
|
this.groupServer = {
|
|
446
467
|
server: this.groups,
|
|
447
468
|
issueAuthCredential: (userId, authorityKeyId) => this.issueAuthCredential(userId, authorityKeyId),
|
|
@@ -461,7 +482,7 @@ export class HostedRelayHttpTransport {
|
|
|
461
482
|
if (generation === undefined)
|
|
462
483
|
throw missingDestination(accountAddress, deviceId);
|
|
463
484
|
return { accountAddress, deviceId, generation };
|
|
464
|
-
});
|
|
485
|
+
}, (clientMessageId, request) => admitRepeatRequest(this, clientMessageId, request), relayProtocolVersion);
|
|
465
486
|
}
|
|
466
487
|
get accountId() {
|
|
467
488
|
return this.session.canonicalAccountId;
|
|
@@ -570,7 +591,7 @@ export class HostedRelayHttpTransport {
|
|
|
570
591
|
const proof = await this.deviceAuthentication.signChallenge(challenge);
|
|
571
592
|
let value;
|
|
572
593
|
try {
|
|
573
|
-
value = await postJson(this.connection, "/identity/token", {
|
|
594
|
+
value = await postJson(this.connection, this.relayProtocolVersion, "/identity/token", {
|
|
574
595
|
accountAddress: this.session.canonicalAccountId,
|
|
575
596
|
// The Relay checks this key against the keys that a recovery revoked.
|
|
576
597
|
deviceAuthenticationPublicKey: bytesToBase64(this.deviceAuthentication.publicKey),
|
|
@@ -633,13 +654,13 @@ export class HostedRelayHttpTransport {
|
|
|
633
654
|
post: async (body) => {
|
|
634
655
|
let token = await this.token();
|
|
635
656
|
try {
|
|
636
|
-
return await postJson(this.connection, '/identity/devices/link', await bodyFor(body, token), token);
|
|
657
|
+
return await postJson(this.connection, this.relayProtocolVersion, '/identity/devices/link', await bodyFor(body, token), token);
|
|
637
658
|
}
|
|
638
659
|
catch (error) {
|
|
639
660
|
if (!(error instanceof HostedRelayHttpError) || error.code !== 'TOKEN_INVALID')
|
|
640
661
|
throw error;
|
|
641
662
|
token = await this.token(true);
|
|
642
|
-
return postJson(this.connection, '/identity/devices/link', await bodyFor(body, token), token);
|
|
663
|
+
return postJson(this.connection, this.relayProtocolVersion, '/identity/devices/link', await bodyFor(body, token), token);
|
|
643
664
|
}
|
|
644
665
|
},
|
|
645
666
|
});
|
|
@@ -677,7 +698,7 @@ export class HostedRelayHttpTransport {
|
|
|
677
698
|
throw new Error('Stored Signal Protocol Relay link session conflicts with the retained attempt');
|
|
678
699
|
session = existing;
|
|
679
700
|
}
|
|
680
|
-
const transport = new HostedRelayHttpTransport(this.connection, storage, request.newDeviceAuthentication, session);
|
|
701
|
+
const transport = new HostedRelayHttpTransport(this.connection, storage, request.newDeviceAuthentication, session, true, this.relayProtocolVersion);
|
|
681
702
|
// Persist the complete shape before synchronization or token renewal can fail.
|
|
682
703
|
try {
|
|
683
704
|
await storage.setMetadata(key, JSON.stringify(session));
|
|
@@ -697,10 +718,15 @@ export class HostedRelayHttpTransport {
|
|
|
697
718
|
accountPreserved: true, protocolStateCopied: false,
|
|
698
719
|
};
|
|
699
720
|
}
|
|
700
|
-
|
|
721
|
+
/**
|
|
722
|
+
* Post with the device token. On TOKEN_INVALID, get a new token and post
|
|
723
|
+
* once more. When `beforeRepeat` rejects, no repeat starts and the
|
|
724
|
+
* TOKEN_INVALID error is thrown.
|
|
725
|
+
*/
|
|
726
|
+
async authenticatedPost(path, body, beforeRepeat) {
|
|
701
727
|
let token = await this.token();
|
|
702
728
|
try {
|
|
703
|
-
return await postJson(this.connection, path, body, token);
|
|
729
|
+
return await postJson(this.connection, this.relayProtocolVersion, path, body, token);
|
|
704
730
|
}
|
|
705
731
|
catch (error) {
|
|
706
732
|
if (!(error instanceof HostedRelayHttpError) ||
|
|
@@ -708,7 +734,13 @@ export class HostedRelayHttpTransport {
|
|
|
708
734
|
throw error;
|
|
709
735
|
}
|
|
710
736
|
token = await this.token(true);
|
|
711
|
-
|
|
737
|
+
try {
|
|
738
|
+
await beforeRepeat?.();
|
|
739
|
+
}
|
|
740
|
+
catch {
|
|
741
|
+
throw error;
|
|
742
|
+
}
|
|
743
|
+
return postJson(this.connection, this.relayProtocolVersion, path, body, token);
|
|
712
744
|
}
|
|
713
745
|
}
|
|
714
746
|
assertCurrentIdentity(userId, deviceId, identityType = "aci") {
|
|
@@ -1024,7 +1056,7 @@ export class HostedRelayHttpTransport {
|
|
|
1024
1056
|
if (proof.byteLength !== 64)
|
|
1025
1057
|
throw new Error("Signal Protocol Relay certificate proof is invalid");
|
|
1026
1058
|
try {
|
|
1027
|
-
const result = await postJson(this.connection, "/certificates/issue", {
|
|
1059
|
+
const result = await postJson(this.connection, this.relayProtocolVersion, "/certificates/issue", {
|
|
1028
1060
|
publishableKey: this.connection.publishableKey,
|
|
1029
1061
|
nonce,
|
|
1030
1062
|
deviceProof: bytesToBase64(proof),
|
|
@@ -1241,7 +1273,7 @@ export class HostedRelayHttpTransport {
|
|
|
1241
1273
|
expiresAt: tokenExpiration(token, this.session) * 1_000,
|
|
1242
1274
|
headers: {
|
|
1243
1275
|
authorization: `Bearer ${token}`,
|
|
1244
|
-
...
|
|
1276
|
+
...relayProtocolHeadersFor(this.relayProtocolVersion),
|
|
1245
1277
|
"x-open-e2ee-publishable-key": this.connection.publishableKey,
|
|
1246
1278
|
"x-open-e2ee-object-id": input.objectId,
|
|
1247
1279
|
"x-open-e2ee-attachment-capability": input.readCapability,
|
|
@@ -1276,6 +1308,14 @@ export class HostedRelayHttpTransport {
|
|
|
1276
1308
|
];
|
|
1277
1309
|
let value;
|
|
1278
1310
|
let attempts = 0;
|
|
1311
|
+
// Each repeat request meets the checks that the owner of the post
|
|
1312
|
+
// registered under its message ID, and names its device and the answer
|
|
1313
|
+
// that it follows.
|
|
1314
|
+
const beforeRepeat = (after) => () => admitRepeatRequest(this, messageId, {
|
|
1315
|
+
userId: envelope.targetUserId,
|
|
1316
|
+
deviceId: envelope.targetDeviceId,
|
|
1317
|
+
after,
|
|
1318
|
+
});
|
|
1279
1319
|
try {
|
|
1280
1320
|
value = await withOneUncertainRetry(envelope.deliveryClass, () => {
|
|
1281
1321
|
attempts++;
|
|
@@ -1295,10 +1335,13 @@ export class HostedRelayHttpTransport {
|
|
|
1295
1335
|
? {}
|
|
1296
1336
|
: { recipientRegistrationId: envelope.recipientRegistrationId }),
|
|
1297
1337
|
...(deviceSets === undefined ? {} : { deviceSets }),
|
|
1298
|
-
});
|
|
1299
|
-
});
|
|
1338
|
+
}, beforeRepeat("token"));
|
|
1339
|
+
}, beforeRepeat("uncertain"));
|
|
1300
1340
|
}
|
|
1301
1341
|
catch (error) {
|
|
1342
|
+
// After an uncertain answer, the first request can have stored the
|
|
1343
|
+
// copy, so the answer to the repeat tells nothing about the post.
|
|
1344
|
+
const answer = (failure) => attempts > 1 ? markAfterRepeatedRequest(failure) : failure;
|
|
1302
1345
|
const device = {
|
|
1303
1346
|
userId: envelope.targetUserId,
|
|
1304
1347
|
deviceId: envelope.targetDeviceId,
|
|
@@ -1307,12 +1350,12 @@ export class HostedRelayHttpTransport {
|
|
|
1307
1350
|
const refusal = parseDeviceSetRefusal(error.code, error.data?.details);
|
|
1308
1351
|
if (refusal !== undefined) {
|
|
1309
1352
|
this.forgetDestinationGenerations(refusal.accounts);
|
|
1310
|
-
throw markDeviceSetRefusal(error, refusal);
|
|
1353
|
+
throw answer(markDeviceSetRefusal(error, refusal));
|
|
1311
1354
|
}
|
|
1312
1355
|
}
|
|
1313
1356
|
if (error instanceof HostedRelayHttpError &&
|
|
1314
1357
|
error.code === "STALE_DEVICE") {
|
|
1315
|
-
throw markRelayDeviceRefusal(new HostedRelayHttpError(error.status, error.code, error.message, {
|
|
1358
|
+
throw answer(markRelayDeviceRefusal(new HostedRelayHttpError(error.status, error.code, error.message, {
|
|
1316
1359
|
data: {
|
|
1317
1360
|
code: "STALE_DEVICE",
|
|
1318
1361
|
message: error.message,
|
|
@@ -1320,13 +1363,13 @@ export class HostedRelayHttpTransport {
|
|
|
1320
1363
|
staleDevices: [envelope.targetDeviceId],
|
|
1321
1364
|
},
|
|
1322
1365
|
retryable: error.retryable,
|
|
1323
|
-
}), { code: "STALE_DEVICE", ...device });
|
|
1366
|
+
}), { code: "STALE_DEVICE", ...device }));
|
|
1324
1367
|
}
|
|
1325
1368
|
// Only the Relay's own error body names NOT_FOUND. A 404 without it
|
|
1326
1369
|
// fails to parse or carries no code, so it is not a device refusal.
|
|
1327
1370
|
if (error instanceof HostedRelayHttpError && error.code === "NOT_FOUND")
|
|
1328
|
-
throw markRelayDeviceRefusal(error, { code: "NOT_FOUND", ...device });
|
|
1329
|
-
throw error;
|
|
1371
|
+
throw answer(markRelayDeviceRefusal(error, { code: "NOT_FOUND", ...device }));
|
|
1372
|
+
throw answer(error);
|
|
1330
1373
|
}
|
|
1331
1374
|
if (!record(value) ||
|
|
1332
1375
|
requiredString(value, "messageId") !== messageId ||
|
|
@@ -1365,6 +1408,7 @@ export class HostedRelayHttpTransport {
|
|
|
1365
1408
|
const generation = ++this.subscriptionGeneration;
|
|
1366
1409
|
const subscription = subscribeHostedMailbox({
|
|
1367
1410
|
...options,
|
|
1411
|
+
relayProtocolVersion: this.relayProtocolVersion,
|
|
1368
1412
|
onConnectionState: (state, reason) => {
|
|
1369
1413
|
if (generation === this.subscriptionGeneration)
|
|
1370
1414
|
this.connectionState.move(state, reason);
|
|
@@ -1666,7 +1710,9 @@ export class HostedRelayHttpTransport {
|
|
|
1666
1710
|
}
|
|
1667
1711
|
export async function bootstrapHostedRelayTransport(request) {
|
|
1668
1712
|
const proof = await request.deviceAuthentication.signChallenge(await registrationChallenge(request));
|
|
1669
|
-
|
|
1713
|
+
// A new client starts at the default version, which the transport built
|
|
1714
|
+
// below also takes.
|
|
1715
|
+
const value = await postJson(request.connection, RELAY_PROTOCOL_VERSION, request.assertionPurpose === "recover"
|
|
1670
1716
|
? "/identity/recover"
|
|
1671
1717
|
: "/identity/register", {
|
|
1672
1718
|
assertion: request.assertion,
|
|
@@ -1713,11 +1759,34 @@ export async function bootstrapHostedRelayTransport(request) {
|
|
|
1713
1759
|
};
|
|
1714
1760
|
}
|
|
1715
1761
|
export async function resumeHostedRelayTransport(options) {
|
|
1716
|
-
|
|
1717
|
-
|
|
1762
|
+
let stored;
|
|
1763
|
+
try {
|
|
1764
|
+
stored = await options.storage.getMetadata(await sessionMetadataKey(options.connection));
|
|
1765
|
+
}
|
|
1766
|
+
catch (cause) {
|
|
1767
|
+
if (options.requireExisting) {
|
|
1768
|
+
throw new HostedRelayResumeError('RETAINED_STATE_UNREADABLE', 'reading-local-state', { cause });
|
|
1769
|
+
}
|
|
1770
|
+
throw cause;
|
|
1771
|
+
}
|
|
1772
|
+
if (!stored) {
|
|
1773
|
+
if (options.requireExisting) {
|
|
1774
|
+
throw new HostedRelayResumeError('RETAINED_SESSION_UNAVAILABLE', 'reading-local-state');
|
|
1775
|
+
}
|
|
1718
1776
|
return undefined;
|
|
1719
|
-
|
|
1777
|
+
}
|
|
1778
|
+
let session;
|
|
1779
|
+
try {
|
|
1780
|
+
session = parseSession(stored, options.connection);
|
|
1781
|
+
}
|
|
1782
|
+
catch (cause) {
|
|
1783
|
+
if (options.requireExisting) {
|
|
1784
|
+
throw new HostedRelayResumeError('RETAINED_SESSION_UNAVAILABLE', 'reading-local-state', { cause });
|
|
1785
|
+
}
|
|
1786
|
+
throw cause;
|
|
1787
|
+
}
|
|
1720
1788
|
const transport = new HostedRelayHttpTransport(options.connection, options.storage, options.deviceAuthentication, session);
|
|
1789
|
+
options.onAuthenticating?.();
|
|
1721
1790
|
await transport.ensureAuthenticated(true);
|
|
1722
1791
|
return {
|
|
1723
1792
|
canonicalAccountId: session.canonicalAccountId,
|