@open-e2ee/signal-protocol-sdk 0.3.0 → 1.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/ADAPTERS.md +7 -0
- package/ARCHITECTURE.md +2 -0
- package/CHANGELOG.md +96 -5
- package/README.md +67 -102
- package/SECURITY.md +2 -2
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/TROUBLESHOOTING.md +7 -0
- package/blocking/README.md +1 -0
- package/client/README.md +10 -0
- package/device/README.md +12 -5
- package/dist/client/client.d.ts +3 -2
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +58 -25
- package/dist/client/client.js.map +1 -1
- package/dist/client/config.d.ts +46 -7
- package/dist/client/config.d.ts.map +1 -1
- package/dist/client/config.js +2 -2
- package/dist/client/config.js.map +1 -1
- package/dist/client/group-outbox.d.ts +38 -0
- package/dist/client/group-outbox.d.ts.map +1 -0
- package/dist/client/group-outbox.js +221 -0
- package/dist/client/group-outbox.js.map +1 -0
- package/dist/client/group-sealed-sender.d.ts +28 -0
- package/dist/client/group-sealed-sender.d.ts.map +1 -0
- package/dist/client/group-sealed-sender.js +74 -0
- package/dist/client/group-sealed-sender.js.map +1 -0
- package/dist/client/groups.d.ts.map +1 -1
- package/dist/client/groups.js +14 -4
- package/dist/client/groups.js.map +1 -1
- package/dist/client/hosted-push.d.ts +77 -0
- package/dist/client/hosted-push.d.ts.map +1 -0
- package/dist/client/hosted-push.js +90 -0
- package/dist/client/hosted-push.js.map +1 -0
- package/dist/client/hosted.d.ts +207 -0
- package/dist/client/hosted.d.ts.map +1 -0
- package/dist/client/hosted.js +505 -0
- package/dist/client/hosted.js.map +1 -0
- package/dist/client/index.d.ts +4 -2
- 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/relay-subscription.d.ts.map +1 -1
- package/dist/client/relay-subscription.js +34 -7
- package/dist/client/relay-subscription.js.map +1 -1
- package/dist/client/{sealed-sender-ops.d.ts → sealed-sender.d.ts} +39 -22
- package/dist/client/sealed-sender.d.ts.map +1 -0
- package/dist/client/sealed-sender.js +296 -0
- package/dist/client/sealed-sender.js.map +1 -0
- package/dist/client/signal-service-cipher.d.ts +23 -26
- package/dist/client/signal-service-cipher.d.ts.map +1 -1
- package/dist/client/signal-service-cipher.js +465 -706
- package/dist/client/signal-service-cipher.js.map +1 -1
- package/dist/client/types.d.ts +18 -3
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/types.js +6 -0
- package/dist/client/types.js.map +1 -1
- package/dist/device/index.d.ts +2 -2
- package/dist/device/index.d.ts.map +1 -1
- package/dist/device/index.js +1 -1
- package/dist/device/index.js.map +1 -1
- package/dist/device/transfer.d.ts +7 -43
- package/dist/device/transfer.d.ts.map +1 -1
- package/dist/device/transfer.js +31 -150
- package/dist/device/transfer.js.map +1 -1
- package/dist/device/types.d.ts +6 -47
- package/dist/device/types.d.ts.map +1 -1
- package/dist/device/types.js +1 -1
- package/dist/device/types.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/internal/encoding/proto/pq-ratchet-serialize.js +1 -1
- package/dist/internal/encoding/proto/pq-ratchet-serialize.js.map +1 -1
- package/dist/internal/encoding/proto/primitives.js +1 -1
- package/dist/internal/encoding/proto/primitives.js.map +1 -1
- package/dist/internal/groups/manager.d.ts +3 -3
- package/dist/internal/groups/manager.d.ts.map +1 -1
- package/dist/internal/groups/manager.js +5 -4
- package/dist/internal/groups/manager.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/certificate.d.ts +10 -4
- package/dist/internal/protocol/sealed-sender/certificate.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/certificate.js +64 -7
- package/dist/internal/protocol/sealed-sender/certificate.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/decryption.d.ts +34 -47
- package/dist/internal/protocol/sealed-sender/decryption.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/decryption.js +95 -182
- package/dist/internal/protocol/sealed-sender/decryption.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/encryption.d.ts +49 -64
- package/dist/internal/protocol/sealed-sender/encryption.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/encryption.js +120 -123
- package/dist/internal/protocol/sealed-sender/encryption.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/index.d.ts +5 -7
- package/dist/internal/protocol/sealed-sender/index.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/index.js +4 -12
- package/dist/internal/protocol/sealed-sender/index.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/{v2-helpers.d.ts → multi-recipient-crypto.d.ts} +1 -1
- package/dist/internal/protocol/sealed-sender/multi-recipient-crypto.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/{v2-helpers.js → multi-recipient-crypto.js} +1 -1
- package/dist/internal/protocol/sealed-sender/multi-recipient-crypto.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/{v2-binary.d.ts → multi-recipient-message.d.ts} +3 -2
- package/dist/internal/protocol/sealed-sender/multi-recipient-message.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/{v2-binary.js → multi-recipient-message.js} +16 -8
- package/dist/internal/protocol/sealed-sender/multi-recipient-message.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts +3 -0
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/proto/index.js +25 -2
- package/dist/internal/protocol/sealed-sender/proto/index.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/trust-root.d.ts +11 -1
- package/dist/internal/protocol/sealed-sender/trust-root.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/trust-root.js +13 -1
- package/dist/internal/protocol/sealed-sender/trust-root.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/types.d.ts +20 -135
- package/dist/internal/protocol/sealed-sender/types.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/types.js +15 -6
- package/dist/internal/protocol/sealed-sender/types.js.map +1 -1
- package/dist/internal/protocol/sender-keys/manager.d.ts +22 -1
- package/dist/internal/protocol/sender-keys/manager.d.ts.map +1 -1
- package/dist/internal/protocol/sender-keys/manager.js +39 -4
- package/dist/internal/protocol/sender-keys/manager.js.map +1 -1
- package/dist/internal/protocol/spqr/braid-serialize.js +1 -1
- package/dist/internal/protocol/spqr/braid-serialize.js.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/state-machine.js +4 -4
- package/dist/internal/protocol/spqr/ml-kem-braid/state-machine.js.map +1 -1
- package/dist/internal/protocol/zk/groups/index.d.ts +1 -1
- package/dist/internal/protocol/zk/groups/index.d.ts.map +1 -1
- package/dist/internal/protocol/zk/groups/index.js +1 -1
- package/dist/internal/protocol/zk/groups/index.js.map +1 -1
- package/dist/internal/protocol/zk/groups/profile-key-credential.d.ts +37 -12
- package/dist/internal/protocol/zk/groups/profile-key-credential.d.ts.map +1 -1
- package/dist/internal/protocol/zk/groups/profile-key-credential.js +104 -31
- package/dist/internal/protocol/zk/groups/profile-key-credential.js.map +1 -1
- package/dist/internal/sesame/types.d.ts +0 -2
- package/dist/internal/sesame/types.d.ts.map +1 -1
- package/dist/internal/sesame/types.js +0 -2
- package/dist/internal/sesame/types.js.map +1 -1
- package/dist/local/store/expo/adapter.d.ts +1 -0
- package/dist/local/store/expo/adapter.d.ts.map +1 -1
- package/dist/local/store/expo/adapter.js +3 -0
- package/dist/local/store/expo/adapter.js.map +1 -1
- package/dist/local/store/expo/key-storage.d.ts +1 -0
- package/dist/local/store/expo/key-storage.d.ts.map +1 -1
- package/dist/local/store/expo/key-storage.js +4 -0
- package/dist/local/store/expo/key-storage.js.map +1 -1
- package/dist/local/store/memory/adapter.d.ts +1 -0
- 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/node/adapter.d.ts +1 -0
- package/dist/local/store/node/adapter.d.ts.map +1 -1
- package/dist/local/store/node/adapter.js +3 -0
- package/dist/local/store/node/adapter.js.map +1 -1
- package/dist/local/store/node/database.d.ts +1 -0
- package/dist/local/store/node/database.d.ts.map +1 -1
- package/dist/local/store/node/database.js +5 -0
- package/dist/local/store/node/database.js.map +1 -1
- package/dist/local/store/react-native/adapter.d.ts +1 -0
- package/dist/local/store/react-native/adapter.d.ts.map +1 -1
- package/dist/local/store/react-native/adapter.js +4 -0
- package/dist/local/store/react-native/adapter.js.map +1 -1
- package/dist/local/store/react-native/reference-backend.js +1 -1
- package/dist/local/store/react-native/reference-backend.js.map +1 -1
- package/dist/local/store/reliability.d.ts +63 -0
- package/dist/local/store/reliability.d.ts.map +1 -0
- package/dist/local/store/reliability.js +219 -0
- package/dist/local/store/reliability.js.map +1 -0
- package/dist/local/store/web/adapter.d.ts +1 -0
- package/dist/local/store/web/adapter.d.ts.map +1 -1
- package/dist/local/store/web/adapter.js +5 -0
- package/dist/local/store/web/adapter.js.map +1 -1
- package/dist/media/index.d.ts +0 -1
- package/dist/media/index.d.ts.map +1 -1
- package/dist/media/index.js +0 -1
- package/dist/media/index.js.map +1 -1
- package/dist/remote/relay/convex/backend.d.ts +6 -16
- package/dist/remote/relay/convex/backend.d.ts.map +1 -1
- package/dist/remote/relay/convex/backend.js +12 -21
- package/dist/remote/relay/convex/backend.js.map +1 -1
- package/dist/remote/relay/convex/component/_generated/component.d.ts +9 -16
- package/dist/remote/relay/convex/component/_generated/component.d.ts.map +1 -1
- package/dist/remote/relay/convex/component/certificates.d.ts.map +1 -1
- package/dist/remote/relay/convex/component/certificates.js +14 -5
- package/dist/remote/relay/convex/component/certificates.js.map +1 -1
- package/dist/remote/relay/convex/component/messages.d.ts +2 -15
- package/dist/remote/relay/convex/component/messages.d.ts.map +1 -1
- package/dist/remote/relay/convex/component/messages.js +14 -48
- package/dist/remote/relay/convex/component/messages.js.map +1 -1
- package/dist/remote/relay/convex/component/schema.d.ts +5 -3
- package/dist/remote/relay/convex/component/schema.js +2 -1
- package/dist/remote/relay/convex/component/schema.js.map +1 -1
- package/dist/remote/relay/convex/component/zkAuth.d.ts +7 -1
- package/dist/remote/relay/convex/component/zkAuth.d.ts.map +1 -1
- package/dist/remote/relay/convex/component/zkAuth.js +29 -14
- package/dist/remote/relay/convex/component/zkAuth.js.map +1 -1
- package/dist/remote/relay/convex/relay.d.ts +2 -5
- package/dist/remote/relay/convex/relay.d.ts.map +1 -1
- package/dist/remote/relay/convex/relay.js +17 -47
- package/dist/remote/relay/convex/relay.js.map +1 -1
- package/dist/remote/relay/memory/adapter.d.ts +4 -10
- package/dist/remote/relay/memory/adapter.d.ts.map +1 -1
- package/dist/remote/relay/memory/adapter.js +31 -34
- package/dist/remote/relay/memory/adapter.js.map +1 -1
- package/dist/remote/relay/types.d.ts +6 -19
- package/dist/remote/relay/types.d.ts.map +1 -1
- package/dist/types/api.d.ts +2 -0
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/errors.d.ts +3 -1
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +4 -2
- package/dist/types/errors.js.map +1 -1
- package/dist/types/protocol-config.d.ts +1 -1
- package/dist/username/link.d.ts.map +1 -1
- package/dist/username/link.js +1 -1
- package/dist/username/link.js.map +1 -1
- package/dist/utils/retry.d.ts +2 -1
- package/dist/utils/retry.d.ts.map +1 -1
- package/dist/utils/retry.js +2 -1
- package/dist/utils/retry.js.map +1 -1
- package/docs/ASSURANCE.md +16 -10
- package/docs/CLIENT_COMPOSITION.md +3 -0
- package/docs/DEVIATIONS.md +32 -61
- package/docs/DOCUMENTATION_STANDARDS.md +28 -0
- package/docs/ERROR_HANDLING.md +91 -60
- package/docs/GETTING_STARTED.md +27 -1
- package/docs/INTERFACES.md +5 -0
- package/docs/PACKAGE_SURFACE.md +1 -0
- package/docs/PROTOCOL_POLICY.md +6 -0
- package/docs/RECIPES.md +9 -0
- package/docs/SECURITY.md +6 -0
- package/encoding/README.md +1 -0
- package/files/README.md +1 -0
- package/groups/README.md +1 -0
- package/keys/README.md +2 -0
- package/local/store/README.md +2 -0
- package/local/store/expo/README.md +2 -0
- package/local/store/memory/README.md +2 -0
- package/local/store/node/README.md +1 -0
- package/local/store/react-native/README.md +2 -0
- package/local/store/web/README.md +1 -0
- package/local/vault/README.md +1 -0
- package/media/README.md +2 -0
- package/package.json +4 -2
- package/profile/README.md +1 -0
- package/remote/README.md +6 -0
- package/remote/object-store/README.md +1 -0
- package/remote/object-store/convex-r2/README.md +2 -0
- package/remote/object-store/s3/README.md +1 -0
- package/remote/relay/README.md +2 -0
- package/remote/relay/convex/README.md +1 -0
- package/remote/relay/convex/component/README.md +29 -14
- package/remote/relay/memory/README.md +2 -0
- package/safety/README.md +1 -0
- package/scripts/oe-groups.mjs +5 -1
- package/sealed-sender/README.md +1 -0
- package/types/README.md +1 -0
- package/username/README.md +1 -0
- package/utils/README.md +1 -0
- package/zk/README.md +1 -0
- package/dist/client/sealed-sender-ops.d.ts.map +0 -1
- package/dist/client/sealed-sender-ops.js +0 -203
- package/dist/client/sealed-sender-ops.js.map +0 -1
- package/dist/internal/protocol/sealed-sender/decryption-v2.d.ts +0 -46
- package/dist/internal/protocol/sealed-sender/decryption-v2.d.ts.map +0 -1
- package/dist/internal/protocol/sealed-sender/decryption-v2.js +0 -198
- package/dist/internal/protocol/sealed-sender/decryption-v2.js.map +0 -1
- package/dist/internal/protocol/sealed-sender/encryption-v2.d.ts +0 -56
- package/dist/internal/protocol/sealed-sender/encryption-v2.d.ts.map +0 -1
- package/dist/internal/protocol/sealed-sender/encryption-v2.js +0 -163
- package/dist/internal/protocol/sealed-sender/encryption-v2.js.map +0 -1
- package/dist/internal/protocol/sealed-sender/v2-binary.d.ts.map +0 -1
- package/dist/internal/protocol/sealed-sender/v2-binary.js.map +0 -1
- package/dist/internal/protocol/sealed-sender/v2-helpers.d.ts.map +0 -1
- package/dist/internal/protocol/sealed-sender/v2-helpers.js.map +0 -1
package/dist/client/config.d.ts
CHANGED
|
@@ -26,12 +26,19 @@ export { applyProtocolStrategyDefaults, ARCHIVED_STATES_MAX_LENGTH, BraidPolicy,
|
|
|
26
26
|
* - `disabled`: Sealed sender is fully disabled
|
|
27
27
|
*/
|
|
28
28
|
export type SealedSenderAccessMode = 'unrestricted' | 'contacts-only' | 'disabled';
|
|
29
|
+
/** Outbound sealed-sender policy for direct and group delivery. */
|
|
30
|
+
export type SealedSenderDeliveryMode = 'preferred' | 'required' | 'disabled';
|
|
31
|
+
/** A deliberate privacy-route change after anonymous authorization is rejected. */
|
|
32
|
+
export interface SealedSenderIdentifiedFallbackEvent {
|
|
33
|
+
recipientUserId: string;
|
|
34
|
+
reason: 'authorization-rejected';
|
|
35
|
+
}
|
|
29
36
|
/**
|
|
30
37
|
* Sealed Sender configuration.
|
|
31
38
|
*
|
|
32
39
|
* @see https://signal.org/blog/sealed-sender/
|
|
33
40
|
*/
|
|
34
|
-
|
|
41
|
+
interface SealedSenderConfigBase {
|
|
35
42
|
/**
|
|
36
43
|
* Ed25519 trust root public keys for certificate validation.
|
|
37
44
|
*
|
|
@@ -41,6 +48,10 @@ export interface SealedSenderConfig {
|
|
|
41
48
|
* Multiple roots work for key rotation scenarios.
|
|
42
49
|
*/
|
|
43
50
|
trustRoots: Uint8Array[];
|
|
51
|
+
/** Opaque 16-byte Relay project-environment scope pinned by the application. */
|
|
52
|
+
relayScopeId: Uint8Array;
|
|
53
|
+
/** Issuer key IDs revoked by this deployment's operator. */
|
|
54
|
+
revokedIssuerKeyIds: readonly number[];
|
|
44
55
|
/**
|
|
45
56
|
* Provider function that returns a serialized SenderCertificate (base64).
|
|
46
57
|
*
|
|
@@ -57,6 +68,19 @@ export interface SealedSenderConfig {
|
|
|
57
68
|
* @default 'unrestricted'
|
|
58
69
|
*/
|
|
59
70
|
accessMode?: SealedSenderAccessMode;
|
|
71
|
+
/**
|
|
72
|
+
* Outbound delivery policy.
|
|
73
|
+
*
|
|
74
|
+
* - `preferred`: use identified delivery only when anonymous capability is
|
|
75
|
+
* absent before send or the relay rejects anonymous authorization.
|
|
76
|
+
* - `required`: fail closed when anonymous delivery is unavailable or rejected.
|
|
77
|
+
* - `disabled`: always use identified delivery and do not fetch a certificate.
|
|
78
|
+
*
|
|
79
|
+
* @default 'preferred'
|
|
80
|
+
*/
|
|
81
|
+
deliveryMode?: SealedSenderDeliveryMode;
|
|
82
|
+
/** Reports the only post-send-attempt privacy downgrade allowed by `preferred`. */
|
|
83
|
+
onIdentifiedFallback?: (event: SealedSenderIdentifiedFallbackEvent) => void | Promise<void>;
|
|
60
84
|
/**
|
|
61
85
|
* Optional host-provided contact profile state store.
|
|
62
86
|
*
|
|
@@ -66,7 +90,19 @@ export interface SealedSenderConfig {
|
|
|
66
90
|
*/
|
|
67
91
|
contactStateStore?: import('../profile/contact-state.js').ContactProfileStateStore;
|
|
68
92
|
}
|
|
69
|
-
/**
|
|
93
|
+
/** Self-hosted sealed-sender trust is pinned by the application deployment. */
|
|
94
|
+
export interface SelfHostedSealedSenderConfig extends SealedSenderConfigBase {
|
|
95
|
+
/** Selects the application-owned self-hosted trust system. */
|
|
96
|
+
trustModel?: 'self-hosted';
|
|
97
|
+
}
|
|
98
|
+
/** Hosted Relay sealed-sender trust is bound to one project environment. */
|
|
99
|
+
export interface HostedSealedSenderConfig extends SealedSenderConfigBase {
|
|
100
|
+
/** Selects the OpenE2EE hosted trust system. */
|
|
101
|
+
trustModel: 'hosted';
|
|
102
|
+
}
|
|
103
|
+
/** Sealed-sender trust configuration. Hosted and self-hosted roots cannot mix. */
|
|
104
|
+
export type SealedSenderConfig = SelfHostedSealedSenderConfig | HostedSealedSenderConfig;
|
|
105
|
+
/** Refresh sender certificates one hour before their signed expiration. */
|
|
70
106
|
export declare const SEALED_SENDER_CERTIFICATE_MARGIN_MS: number;
|
|
71
107
|
/**
|
|
72
108
|
* Signal Protocol configuration options
|
|
@@ -657,9 +693,10 @@ export interface SignalProtocolClientConfig {
|
|
|
657
693
|
* variable.
|
|
658
694
|
* - The deployment's Ed25519 sender-certificate root public key pinned in
|
|
659
695
|
* `trustRoots` at build time. Print it with `npx oe-groups trust-root`,
|
|
660
|
-
* which reports it as `sealed sender trust root` alongside the
|
|
661
|
-
*
|
|
662
|
-
*
|
|
696
|
+
* which reports it as `sealed sender trust root` alongside the matching
|
|
697
|
+
* `sealed sender relay scope`. Pin both values. Never fetch either from a
|
|
698
|
+
* relay at runtime. A relay that can choose its own validation policy can
|
|
699
|
+
* mint certificates for any sender.
|
|
663
700
|
*
|
|
664
701
|
* With `trustRoots` empty, inbound sealed-sender validation stays disabled
|
|
665
702
|
* and sends fall back to identified delivery, which deanonymizes the sender
|
|
@@ -673,6 +710,8 @@ export interface SignalProtocolClientConfig {
|
|
|
673
710
|
* storage: customStorage,
|
|
674
711
|
* sealedSender: {
|
|
675
712
|
* trustRoots: [trustRootPublicKeyBytes],
|
|
713
|
+
* relayScopeId: relayScopeIdBytes,
|
|
714
|
+
* revokedIssuerKeyIds: [],
|
|
676
715
|
* certificateProvider: async () => {
|
|
677
716
|
* return await convex.mutation(api.signal.certificates.issueSenderCertificate, { deviceId: 1 });
|
|
678
717
|
* },
|
|
@@ -715,8 +754,8 @@ export interface SignalProtocolClientConfig {
|
|
|
715
754
|
server?: import('../internal/groups/manager.js').IGroupServer;
|
|
716
755
|
/** Override the relay's auth-credential issuance transport. */
|
|
717
756
|
issueCredential?: () => Promise<Uint8Array>;
|
|
718
|
-
/** Override the relay's profile-key credential issuance transport. */
|
|
719
|
-
issueProfileKeyCredential?: () => Promise<Uint8Array>;
|
|
757
|
+
/** Override the relay's blinded profile-key credential issuance transport. */
|
|
758
|
+
issueProfileKeyCredential?: (request: Uint8Array) => Promise<Uint8Array>;
|
|
720
759
|
/**
|
|
721
760
|
* Explicitly accept group history without server signatures.
|
|
722
761
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.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E,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,MAAM,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C,KAAK,IAAI,CAAC"}
|
package/dist/client/config.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* applications can compose the client for their own runtime.
|
|
6
6
|
*/
|
|
7
7
|
export { applyProtocolStrategyDefaults, ARCHIVED_STATES_MAX_LENGTH, BraidPolicy, KEY_REFRESH_INTERVAL_MS_DEFAULT, MAX_PREKEY_AGE_MS_DEFAULT, MAX_SENDER_KEY_STATES, MAX_UNACKNOWLEDGED_SESSION_AGE_MS, PostQuantumPolicy, PQXDH_INFO_DEFAULT, PREKEY_CHECK_THROTTLE_MS_DEFAULT, protocolConfigToStrategy, resolveKeyExchangeInfoStrings, resolveSCKAMode, resolveSignalProtocolStrategy, resolveSPQRLimits, SENDER_KEYS_DEFAULTS, SPQR_LIMITS_DEFAULTS, validateProtocolStrategy, X3DH_INFO_DEFAULT, } from '../types/protocol-config.js';
|
|
8
|
-
/**
|
|
9
|
-
export const SEALED_SENDER_CERTIFICATE_MARGIN_MS =
|
|
8
|
+
/** Refresh sender certificates one hour before their signed expiration. */
|
|
9
|
+
export const SEALED_SENDER_CERTIFICATE_MARGIN_MS = 60 * 60 * 1000;
|
|
10
10
|
/**
|
|
11
11
|
* Get the identity types to operate on based on config.
|
|
12
12
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../client/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoCH,OAAO,EACL,6BAA6B,EAC7B,0BAA0B,EAC1B,WAAW,EACX,+BAA+B,EAC/B,yBAAyB,EACzB,qBAAqB,EACrB,iCAAiC,EACjC,iBAAiB,EACjB,kBAAkB,EAClB,gCAAgC,EAChC,wBAAwB,EACxB,6BAA6B,EAC7B,eAAe,EACf,6BAA6B,EAC7B,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../client/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoCH,OAAO,EACL,6BAA6B,EAC7B,0BAA0B,EAC1B,WAAW,EACX,+BAA+B,EAC/B,yBAAyB,EACzB,qBAAqB,EACrB,iCAAiC,EACjC,iBAAiB,EACjB,kBAAkB,EAClB,gCAAgC,EAChC,wBAAwB,EACxB,6BAA6B,EAC7B,eAAe,EACf,6BAA6B,EAC7B,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAqGlC,2EAA2E;AAC3E,MAAM,CAAC,MAAM,mCAAmC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AA8rBlE;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAEtC;IACC,OAAO,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC,CAAC,CAAE,CAAC,KAAK,EAAE,KAAK,CAAW,CAAC,CAAC,CAAE,CAAC,KAAK,CAAW,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ISignalProtocolLocalStore } from '../types/index.js';
|
|
2
|
+
import type { GroupMemberDevice, ISignalProtocolRelayServer, SealedSenderAuth } from '../remote/relay/types.js';
|
|
3
|
+
import { type StoredOutgoingDeviceMessage, type StoredOutgoingMessageIntent } from '../local/store/reliability.js';
|
|
4
|
+
import type { SendOptions, SendResult } from './types.js';
|
|
5
|
+
export interface GroupOutboxContext {
|
|
6
|
+
storage: ISignalProtocolLocalStore;
|
|
7
|
+
relay?: ISignalProtocolRelayServer;
|
|
8
|
+
senderUserId: string;
|
|
9
|
+
senderDeviceId: number;
|
|
10
|
+
deliveryMode: 'preferred' | 'required' | 'disabled';
|
|
11
|
+
preparePayload(groupId: string, plaintextBytes: Uint8Array, options: SendOptions & {
|
|
12
|
+
clientMessageId: string;
|
|
13
|
+
timestamp: number;
|
|
14
|
+
}): Promise<{
|
|
15
|
+
ciphertext: string;
|
|
16
|
+
preMessages: StoredOutgoingDeviceMessage[];
|
|
17
|
+
senderKeyDistributionId?: string;
|
|
18
|
+
}>;
|
|
19
|
+
confirmSenderKeyDistributionSent(groupId: string, senderKeyId: string): Promise<void>;
|
|
20
|
+
resolveMemberDevices(groupId: string, options: SendOptions & {
|
|
21
|
+
clientMessageId: string;
|
|
22
|
+
}): Promise<GroupMemberDevice[]>;
|
|
23
|
+
prepareSharedMessage(groupId: string, members: GroupMemberDevice[], ciphertext: string): Promise<StoredOutgoingMessageIntent['groupSharedMessage']>;
|
|
24
|
+
prepareDeviceMessage(member: GroupMemberDevice, groupId: string, ciphertext: string, timestamp: number): Promise<StoredOutgoingDeviceMessage>;
|
|
25
|
+
prepareSyncMessages(groupId: string, plaintextBytes: Uint8Array, timestamp: number, clientMessageId: string): Promise<StoredOutgoingDeviceMessage[]>;
|
|
26
|
+
resolveGroupAuthorization(groupId: string, recipientUserIds: string[]): Promise<Extract<SealedSenderAuth, {
|
|
27
|
+
type: 'groupSendToken';
|
|
28
|
+
}> | null>;
|
|
29
|
+
reportIdentifiedFallback(recipientUserId: string): Promise<void>;
|
|
30
|
+
sendPreparedSealedDevice(intent: StoredOutgoingMessageIntent, message: StoredOutgoingDeviceMessage, auth: SealedSenderAuth): Promise<{
|
|
31
|
+
messageId: string;
|
|
32
|
+
serverTimestamp: number;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
export declare function sendGroupWithExactOutbox(context: GroupOutboxContext, groupId: string, plaintextBytes: Uint8Array, options: SendOptions & {
|
|
36
|
+
clientMessageId: string;
|
|
37
|
+
}): Promise<SendResult>;
|
|
38
|
+
//# sourceMappingURL=group-outbox.d.ts.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5B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,2BAA2B,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAC9D,oBAAoB,CAClB,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,2BAA2B,CAAC,CAAC;IACxC,mBAAmB,CACjB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,UAAU,EAC1B,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,2BAA2B,EAAE,CAAC,CAAC;IAC1C,yBAAyB,CACvB,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,MAAM,EAAE,GACzB,OAAO,CAAC,OAAO,CAAC,gBAAgB,EAAE;QAAE,IAAI,EAAE,gBAAgB,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IACzE,wBAAwB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,wBAAwB,CACtB,MAAM,EAAE,2BAA2B,EACnC,OAAO,EAAE,2BAA2B,EACpC,IAAI,EAAE,gBAAgB,GACrB,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5D;AAqND,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,UAAU,EAC1B,OAAO,EAAE,WAAW,GAAG;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,GACjD,OAAO,CAAC,UAAU,CAAC,CA2ErB"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { EncryptionError, EncryptionErrorCode } from '../types/index.js';
|
|
2
|
+
import { SealedSenderAuthError } from '../types/errors.js';
|
|
3
|
+
import * as CryptoUtils from '../internal/crypto/index.js';
|
|
4
|
+
import { appendOutgoingGroupDeviceMessages, completeOutgoingMessageIntent, getOutgoingMessageIntent, storeOutgoingMessageIntent, withOutgoingMessageIntentLock, } from '../local/store/reliability.js';
|
|
5
|
+
async function sendStoredDeviceMessage(context, intent, message, forceIdentified = false) {
|
|
6
|
+
const relay = context.relay;
|
|
7
|
+
if (!relay)
|
|
8
|
+
throw new Error('Relay is required for a stored group transmission');
|
|
9
|
+
if (message.sealedSenderMessage && !relay.sendMultiRecipientUnidentified) {
|
|
10
|
+
if (message.sealedSenderDeliveryMode === 'required') {
|
|
11
|
+
throw new EncryptionError('Required group sealed-sender transport is unavailable', EncryptionErrorCode.SEALED_SENDER_REQUIRED, { recipientUserId: message.recipientUserId });
|
|
12
|
+
}
|
|
13
|
+
return sendStoredDeviceMessage(context, intent, message, true);
|
|
14
|
+
}
|
|
15
|
+
if (forceIdentified || !message.sealedSenderMessage) {
|
|
16
|
+
return relay.send({
|
|
17
|
+
targetUserId: message.recipientUserId,
|
|
18
|
+
targetDeviceId: message.recipientDeviceId,
|
|
19
|
+
senderUserId: context.senderUserId,
|
|
20
|
+
senderDeviceId: context.senderDeviceId,
|
|
21
|
+
ciphertext: message.ciphertext,
|
|
22
|
+
messageType: message.messageType,
|
|
23
|
+
timestamp: message.timestamp,
|
|
24
|
+
clientMessageId: intent.clientMessageId,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const auth = message.sealedSenderAuthorization === 'access_key' && message.sealedSenderAccessKey
|
|
28
|
+
? {
|
|
29
|
+
type: 'accessKey',
|
|
30
|
+
unidentifiedAccessKey: message.sealedSenderAccessKey,
|
|
31
|
+
}
|
|
32
|
+
: message.sealedSenderAuthorization === 'group_send_token'
|
|
33
|
+
? await context.resolveGroupAuthorization(intent.recipientId, [message.recipientUserId])
|
|
34
|
+
: null;
|
|
35
|
+
if (!auth) {
|
|
36
|
+
if (message.sealedSenderDeliveryMode === 'required') {
|
|
37
|
+
throw new Error('Required group sealed-sender authorization is unavailable');
|
|
38
|
+
}
|
|
39
|
+
return sendStoredDeviceMessage(context, intent, message, true);
|
|
40
|
+
}
|
|
41
|
+
return context.sendPreparedSealedDevice(intent, message, auth);
|
|
42
|
+
}
|
|
43
|
+
async function sendStoredGroupIntent(context, initialIntent) {
|
|
44
|
+
let intent = initialIntent;
|
|
45
|
+
if (intent.kind !== 'group')
|
|
46
|
+
throw new Error('Expected a group outbox intent');
|
|
47
|
+
if (!intent.groupCiphertext)
|
|
48
|
+
throw new Error('Corrupt group outbox intent');
|
|
49
|
+
const relay = context.relay;
|
|
50
|
+
if (!relay) {
|
|
51
|
+
const localResult = {
|
|
52
|
+
clientMessageId: intent.clientMessageId,
|
|
53
|
+
messageId: `local-${intent.clientTimestamp}`,
|
|
54
|
+
timestamp: intent.clientTimestamp,
|
|
55
|
+
recipientDeviceCount: intent.groupRecipientDeviceCount ?? 0,
|
|
56
|
+
groupId: intent.recipientId,
|
|
57
|
+
};
|
|
58
|
+
await completeOutgoingMessageIntent(context.storage, intent.clientMessageId, localResult);
|
|
59
|
+
return localResult;
|
|
60
|
+
}
|
|
61
|
+
let messageId = `group-${intent.recipientId}-${String(intent.clientTimestamp)}`;
|
|
62
|
+
let timestamp = intent.clientTimestamp;
|
|
63
|
+
let sharedSucceeded = false;
|
|
64
|
+
let skippedUsers = [];
|
|
65
|
+
for (const message of intent.preMessages ?? []) {
|
|
66
|
+
await relay.send({
|
|
67
|
+
targetUserId: message.recipientUserId,
|
|
68
|
+
targetDeviceId: message.recipientDeviceId,
|
|
69
|
+
senderUserId: context.senderUserId,
|
|
70
|
+
senderDeviceId: context.senderDeviceId,
|
|
71
|
+
ciphertext: message.ciphertext,
|
|
72
|
+
messageType: message.messageType,
|
|
73
|
+
timestamp: message.timestamp,
|
|
74
|
+
clientMessageId: message.clientMessageId,
|
|
75
|
+
recipientRegistrationId: message.recipientRegistrationId,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (intent.groupSenderKeyDistributionId) {
|
|
79
|
+
await context.confirmSenderKeyDistributionSent(intent.recipientId, intent.groupSenderKeyDistributionId);
|
|
80
|
+
}
|
|
81
|
+
if (intent.groupSharedMessage?.deliveryMode === 'required' &&
|
|
82
|
+
!relay.sendMultiRecipientUnidentified) {
|
|
83
|
+
throw new EncryptionError('Required group sealed-sender transport is unavailable', EncryptionErrorCode.SEALED_SENDER_REQUIRED, { groupId: intent.recipientId });
|
|
84
|
+
}
|
|
85
|
+
if (intent.groupSharedMessage && relay.sendMultiRecipientUnidentified) {
|
|
86
|
+
const auth = await context.resolveGroupAuthorization(intent.groupSharedMessage.groupId, intent.groupSharedMessage.recipientUserIds);
|
|
87
|
+
if (!auth) {
|
|
88
|
+
if (intent.groupSharedMessage.deliveryMode === 'required') {
|
|
89
|
+
throw new Error('Required group sealed-sender authorization is unavailable');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
try {
|
|
94
|
+
const result = await relay.sendMultiRecipientUnidentified(intent.groupSharedMessage.sentMessageBase64, auth, intent.clientTimestamp, intent.groupSharedMessage.recipientUserIds, intent.clientMessageId);
|
|
95
|
+
messageId = result.messageId;
|
|
96
|
+
timestamp = result.serverTimestamp;
|
|
97
|
+
skippedUsers = result.uuids404;
|
|
98
|
+
sharedSucceeded = true;
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
if (!(error instanceof SealedSenderAuthError))
|
|
102
|
+
throw error;
|
|
103
|
+
if (intent.groupSharedMessage.deliveryMode === 'required')
|
|
104
|
+
throw error;
|
|
105
|
+
await Promise.all(intent.groupSharedMessage.recipientUserIds.map((recipientUserId) => context.reportIdentifiedFallback(recipientUserId)));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const sharedUsers = new Set(intent.groupSharedMessage?.recipientUserIds ?? []);
|
|
110
|
+
const usersToRepair = new Set(skippedUsers);
|
|
111
|
+
const forceIdentified = Boolean(intent.groupSharedMessage && !sharedSucceeded);
|
|
112
|
+
for (const message of intent.deviceMessages) {
|
|
113
|
+
if (sharedSucceeded && sharedUsers.has(message.recipientUserId)) {
|
|
114
|
+
if (!usersToRepair.has(message.recipientUserId))
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const result = await sendStoredDeviceMessage(context, intent, message, forceIdentified);
|
|
118
|
+
if (messageId.startsWith('group-')) {
|
|
119
|
+
messageId = result.messageId;
|
|
120
|
+
timestamp = result.serverTimestamp;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (skippedUsers.length > 0) {
|
|
124
|
+
const refreshed = (await Promise.all(skippedUsers.map((userId) => relay.getActiveDevices(userId)))).flat();
|
|
125
|
+
const knownTargets = new Set(intent.deviceMessages.map((message) => `${message.recipientUserId}\u0000${String(message.recipientDeviceId)}`));
|
|
126
|
+
const additions = [];
|
|
127
|
+
for (const member of refreshed) {
|
|
128
|
+
const target = `${member.userId}\u0000${String(member.deviceId)}`;
|
|
129
|
+
if (knownTargets.has(target))
|
|
130
|
+
continue;
|
|
131
|
+
additions.push(await context.prepareDeviceMessage(member, intent.recipientId, intent.groupCiphertext, intent.clientTimestamp));
|
|
132
|
+
}
|
|
133
|
+
if (additions.length > 0) {
|
|
134
|
+
intent = await appendOutgoingGroupDeviceMessages(context.storage, intent.clientMessageId, additions);
|
|
135
|
+
for (const message of additions) {
|
|
136
|
+
await sendStoredDeviceMessage(context, intent, message);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
for (const message of intent.syncMessages) {
|
|
141
|
+
await relay.send({
|
|
142
|
+
targetUserId: message.recipientUserId,
|
|
143
|
+
targetDeviceId: message.recipientDeviceId,
|
|
144
|
+
senderUserId: context.senderUserId,
|
|
145
|
+
senderDeviceId: context.senderDeviceId,
|
|
146
|
+
ciphertext: message.ciphertext,
|
|
147
|
+
messageType: message.messageType,
|
|
148
|
+
timestamp: message.timestamp,
|
|
149
|
+
clientMessageId: message.clientMessageId,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
const result = {
|
|
153
|
+
clientMessageId: intent.clientMessageId,
|
|
154
|
+
messageId,
|
|
155
|
+
timestamp,
|
|
156
|
+
recipientDeviceCount: intent.groupRecipientDeviceCount ?? intent.deviceMessages.length,
|
|
157
|
+
groupId: intent.recipientId,
|
|
158
|
+
};
|
|
159
|
+
await completeOutgoingMessageIntent(context.storage, intent.clientMessageId, result);
|
|
160
|
+
return result;
|
|
161
|
+
}
|
|
162
|
+
export async function sendGroupWithExactOutbox(context, groupId, plaintextBytes, options) {
|
|
163
|
+
return withOutgoingMessageIntentLock(context.storage, options.clientMessageId, async () => {
|
|
164
|
+
const plaintextDigest = CryptoUtils.bytesToBase64(await CryptoUtils.sha256(plaintextBytes));
|
|
165
|
+
const groupMemberUserIds = [...new Set(options.groupMemberUserIds ?? [])].sort();
|
|
166
|
+
const existing = await getOutgoingMessageIntent(context.storage, options.clientMessageId);
|
|
167
|
+
if (existing) {
|
|
168
|
+
if (existing.kind !== 'group' ||
|
|
169
|
+
existing.recipientId !== groupId ||
|
|
170
|
+
existing.plaintextDigest !== plaintextDigest ||
|
|
171
|
+
(options.timestamp !== undefined && existing.clientTimestamp !== options.timestamp) ||
|
|
172
|
+
JSON.stringify(existing.groupMemberUserIds) !== JSON.stringify(groupMemberUserIds)) {
|
|
173
|
+
throw new Error('A clientMessageId cannot identify two different logical sends');
|
|
174
|
+
}
|
|
175
|
+
if (existing.result)
|
|
176
|
+
return existing.result;
|
|
177
|
+
return sendStoredGroupIntent(context, existing);
|
|
178
|
+
}
|
|
179
|
+
const clientTimestamp = options.timestamp ?? Date.now();
|
|
180
|
+
const preparedPayload = await context.preparePayload(groupId, plaintextBytes, {
|
|
181
|
+
...options,
|
|
182
|
+
timestamp: clientTimestamp,
|
|
183
|
+
});
|
|
184
|
+
const encryptedMessageBase64 = preparedPayload.ciphertext;
|
|
185
|
+
const members = context.relay ? await context.resolveMemberDevices(groupId, options) : [];
|
|
186
|
+
const otherMembers = members.filter((member) => member.userId !== context.senderUserId);
|
|
187
|
+
const groupSharedMessage = await context.prepareSharedMessage(groupId, otherMembers, encryptedMessageBase64);
|
|
188
|
+
const deviceMessages = await Promise.all(otherMembers.map((member) => context.prepareDeviceMessage(member, groupId, encryptedMessageBase64, clientTimestamp)));
|
|
189
|
+
const syncMessages = context.relay
|
|
190
|
+
? await context.prepareSyncMessages(groupId, plaintextBytes, clientTimestamp, options.clientMessageId)
|
|
191
|
+
: [];
|
|
192
|
+
const intent = {
|
|
193
|
+
kind: 'group',
|
|
194
|
+
clientMessageId: options.clientMessageId,
|
|
195
|
+
recipientId: groupId,
|
|
196
|
+
plaintextDigest,
|
|
197
|
+
clientTimestamp,
|
|
198
|
+
createdAt: Date.now(),
|
|
199
|
+
transportMode: groupSharedMessage
|
|
200
|
+
? context.deliveryMode === 'required'
|
|
201
|
+
? 'sealed_sender_required'
|
|
202
|
+
: 'sealed_sender_preferred'
|
|
203
|
+
: 'identified',
|
|
204
|
+
...(preparedPayload.preMessages.length > 0 && {
|
|
205
|
+
preMessages: preparedPayload.preMessages,
|
|
206
|
+
}),
|
|
207
|
+
deviceMessages,
|
|
208
|
+
syncMessages,
|
|
209
|
+
groupMemberUserIds,
|
|
210
|
+
groupRecipientDeviceCount: otherMembers.length,
|
|
211
|
+
groupCiphertext: encryptedMessageBase64,
|
|
212
|
+
...(preparedPayload.senderKeyDistributionId && {
|
|
213
|
+
groupSenderKeyDistributionId: preparedPayload.senderKeyDistributionId,
|
|
214
|
+
}),
|
|
215
|
+
...(groupSharedMessage && { groupSharedMessage }),
|
|
216
|
+
};
|
|
217
|
+
await storeOutgoingMessageIntent(context.storage, intent);
|
|
218
|
+
return sendStoredGroupIntent(context, intent);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=group-outbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-outbox.js","sourceRoot":"","sources":["../../client/group-outbox.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe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YACxC,WAAW,EAAE,OAAO;YACpB,eAAe;YACf,eAAe;YACf,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,aAAa,EAAE,kBAAkB;gBAC/B,CAAC,CAAC,OAAO,CAAC,YAAY,KAAK,UAAU;oBACnC,CAAC,CAAC,wBAAwB;oBAC1B,CAAC,CAAC,yBAAyB;gBAC7B,CAAC,CAAC,YAAY;YAChB,GAAG,CAAC,eAAe,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,IAAI;gBAC5C,WAAW,EAAE,eAAe,CAAC,WAAW;aACzC,CAAC;YACF,cAAc;YACd,YAAY;YACZ,kBAAkB;YAClB,yBAAyB,EAAE,YAAY,CAAC,MAAM;YAC9C,eAAe,EAAE,sBAAsB;YACvC,GAAG,CAAC,eAAe,CAAC,uBAAuB,IAAI;gBAC7C,4BAA4B,EAAE,eAAe,CAAC,uBAAuB;aACtE,CAAC;YACF,GAAG,CAAC,kBAAkB,IAAI,EAAE,kBAAkB,EAAE,CAAC;SAClD,CAAC;QACF,MAAM,0BAA0B,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC1D,OAAO,qBAAqB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { GroupMemberDevice } from '../remote/relay/types.js';
|
|
2
|
+
import type { ISignalProtocolLocalStore } from '../types/index.js';
|
|
3
|
+
export interface GroupSealedSenderKeys {
|
|
4
|
+
senderCertificateBase64: string;
|
|
5
|
+
senderIdentityPrivate: Uint8Array;
|
|
6
|
+
senderIdentityPublic: Uint8Array;
|
|
7
|
+
}
|
|
8
|
+
export interface PreparedGroupSharedMessage {
|
|
9
|
+
sentMessageBase64: string;
|
|
10
|
+
recipientUserIds: string[];
|
|
11
|
+
sharedMembers: GroupMemberDevice[];
|
|
12
|
+
fallbackMembers: GroupMemberDevice[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Prepare one immutable multi-recipient sealed-sender body for a group send.
|
|
16
|
+
*
|
|
17
|
+
* Recipient identity and registration data are captured in the body. Callers
|
|
18
|
+
* can persist the returned bytes before transport and replay them verbatim.
|
|
19
|
+
* Members without a known identity remain outside the shared body and must be
|
|
20
|
+
* handled by a separately persisted per-device plan.
|
|
21
|
+
*/
|
|
22
|
+
export declare function prepareGroupSharedMessage(input: {
|
|
23
|
+
storage: ISignalProtocolLocalStore;
|
|
24
|
+
senderKeys: GroupSealedSenderKeys;
|
|
25
|
+
members: GroupMemberDevice[];
|
|
26
|
+
encryptedMessageBase64: string;
|
|
27
|
+
}): Promise<PreparedGroupSharedMessage | null>;
|
|
28
|
+
//# sourceMappingURL=group-sealed-sender.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-sealed-sender.d.ts","sourceRoot":"","sources":["../../client/group-sealed-sender.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,yBAAyB,EAAU,MAAM,UAAU,CAAC;AAUlE,MAAM,WAAW,qBAAqB;IACpC,uBAAuB,EAAE,MAAM,CAAC;IAChC,qBAAqB,EAAE,UAAU,CAAC;IAClC,oBAAoB,EAAE,UAAU,CAAC;CAClC;AAED,MAAM,WAAW,0BAA0B;IACzC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,iBAAiB,EAAE,CAAC;IACnC,eAAe,EAAE,iBAAiB,EAAE,CAAC;CACtC;AAED;;;;;;;GAOG;AACH,wBAAsB,yBAAyB,CAAC,KAAK,EAAE;IACrD,OAAO,EAAE,yBAAyB,CAAC;IACnC,UAAU,EAAE,qBAAqB,CAAC;IAClC,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,sBAAsB,EAAE,MAAM,CAAC;CAChC,GAAG,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC,CAuF7C"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ProtocolAddress } from '../types/address.js';
|
|
2
|
+
import { base64ToBytes, bytesToBase64 } from '../internal/crypto/index.js';
|
|
3
|
+
import { deserializeSenderCertificate, sealMultiRecipient, } from '../internal/protocol/sealed-sender/index.js';
|
|
4
|
+
import { serializeSentMessage } from '../internal/protocol/sealed-sender/multi-recipient-message.js';
|
|
5
|
+
import { SealedSenderContentType } from '../internal/protocol/sealed-sender/types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Prepare one immutable multi-recipient sealed-sender body for a group send.
|
|
8
|
+
*
|
|
9
|
+
* Recipient identity and registration data are captured in the body. Callers
|
|
10
|
+
* can persist the returned bytes before transport and replay them verbatim.
|
|
11
|
+
* Members without a known identity remain outside the shared body and must be
|
|
12
|
+
* handled by a separately persisted per-device plan.
|
|
13
|
+
*/
|
|
14
|
+
export async function prepareGroupSharedMessage(input) {
|
|
15
|
+
const identityByUser = new Map();
|
|
16
|
+
const uniqueUserIds = [...new Set(input.members.map((member) => member.userId))];
|
|
17
|
+
for (const userId of uniqueUserIds) {
|
|
18
|
+
const identityRecord = await input.storage.getContactIdentity(ProtocolAddress.create(userId, 1));
|
|
19
|
+
if (identityRecord) {
|
|
20
|
+
identityByUser.set(userId, base64ToBytes(identityRecord.identity.x25519PublicKey));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const sharedMembers = input.members.filter((member) => identityByUser.has(member.userId));
|
|
24
|
+
const fallbackMembers = input.members.filter((member) => !identityByUser.has(member.userId));
|
|
25
|
+
if (sharedMembers.length === 0)
|
|
26
|
+
return null;
|
|
27
|
+
const recipients = await Promise.all(sharedMembers.map(async (member) => {
|
|
28
|
+
const session = await input.storage.getSessionRecord(ProtocolAddress.create(member.userId, member.deviceId));
|
|
29
|
+
return {
|
|
30
|
+
serviceId: member.userId,
|
|
31
|
+
deviceId: member.deviceId,
|
|
32
|
+
registrationId: session?.currentSession?.remoteRegistrationId ?? 0,
|
|
33
|
+
identityPublic: identityByUser.get(member.userId),
|
|
34
|
+
};
|
|
35
|
+
}));
|
|
36
|
+
const sealed = await sealMultiRecipient({
|
|
37
|
+
senderCertificate: deserializeSenderCertificate(base64ToBytes(input.senderKeys.senderCertificateBase64)),
|
|
38
|
+
senderIdentityPrivate: input.senderKeys.senderIdentityPrivate,
|
|
39
|
+
senderIdentityPublic: input.senderKeys.senderIdentityPublic,
|
|
40
|
+
recipients,
|
|
41
|
+
signalProtocolMessage: base64ToBytes(input.encryptedMessageBase64),
|
|
42
|
+
contentType: SealedSenderContentType.SENDERKEY_MESSAGE,
|
|
43
|
+
});
|
|
44
|
+
const recipientsByUser = new Map();
|
|
45
|
+
for (const recipient of sealed.recipients) {
|
|
46
|
+
const existing = recipientsByUser.get(recipient.serviceId);
|
|
47
|
+
if (existing) {
|
|
48
|
+
existing.devices.push({
|
|
49
|
+
deviceId: recipient.deviceId,
|
|
50
|
+
registrationId: recipient.registrationId,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
recipientsByUser.set(recipient.serviceId, {
|
|
55
|
+
serviceId: recipient.serviceId,
|
|
56
|
+
devices: [
|
|
57
|
+
{
|
|
58
|
+
deviceId: recipient.deviceId,
|
|
59
|
+
registrationId: recipient.registrationId,
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
encryptedMessageKey: base64ToBytes(recipient.encryptedMessageKey),
|
|
63
|
+
authenticationTag: base64ToBytes(recipient.authenticationTag),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
sentMessageBase64: bytesToBase64(serializeSentMessage([...recipientsByUser.values()], [], base64ToBytes(sealed.ephemeralPublic), base64ToBytes(sealed.messageCiphertext))),
|
|
69
|
+
recipientUserIds: [...recipientsByUser.keys()],
|
|
70
|
+
sharedMembers,
|
|
71
|
+
fallbackMembers,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=group-sealed-sender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-sealed-sender.js","sourceRoot":"","sources":["../../client/group-sealed-sender.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,GACnB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4DAA4D,CAAC;AAClG,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAenF;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,KAK/C;IACC,MAAM,cAAc,GAAG,IAAI,GAAG,EAAsB,CAAC;IACrD,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAEjF,KAAK,MAAM,MAAM,IAAI,aAAa,EAAE,CAAC;QACnC,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAC3D,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAClC,CAAC;QACF,IAAI,cAAc,EAAE,CAAC;YACnB,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC;QACrF,CAAC;IACH,CAAC;IAED,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC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getGroupSenderKeyStats(ctx, groupId, senderId, senderDevic
|
|
|
244
244
|
* All group functions follow the same pattern: call manager, log success, throw
|
|
245
245
|
* EncryptionError on failure. This helper eliminates that boilerplate.
|
|
246
246
|
*/
|
|
247
|
-
async function
|
|
247
|
+
async function runGroupOp(label, logger, op, logData, wrapError) {
|
|
248
248
|
try {
|
|
249
249
|
const result = await op();
|
|
250
250
|
logger.debug(label, { category: 'E2EE', data: logData });
|
|
@@ -255,9 +255,19 @@ async function wrapGroupOp(label, logger, op, logData, errorCode = EncryptionErr
|
|
|
255
255
|
error.name === 'GroupSecurityReactionPendingError') {
|
|
256
256
|
throw error;
|
|
257
257
|
}
|
|
258
|
-
throw
|
|
258
|
+
throw wrapError(error);
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
|
+
async function wrapGroupOp(label, logger, op, logData) {
|
|
262
|
+
return runGroupOp(label, logger, op, logData, (error) => new EncryptionError(label, EncryptionErrorCode.INVALID_STATE, {
|
|
263
|
+
originalError: error,
|
|
264
|
+
}));
|
|
265
|
+
}
|
|
266
|
+
async function wrapGroupInitializationOp(label, logger, op, logData) {
|
|
267
|
+
return runGroupOp(label, logger, op, logData, (error) => new EncryptionError(label, EncryptionErrorCode.INITIALIZATION_FAILED, {
|
|
268
|
+
originalError: error,
|
|
269
|
+
}));
|
|
270
|
+
}
|
|
261
271
|
/**
|
|
262
272
|
* Create a new group
|
|
263
273
|
*
|
|
@@ -265,7 +275,7 @@ async function wrapGroupOp(label, logger, op, logData, errorCode = EncryptionErr
|
|
|
265
275
|
* to the server. The creator is added as an administrator.
|
|
266
276
|
*/
|
|
267
277
|
export async function createGroup(ctx, manager, creatorAci, creatorProfileKey, members, title, options) {
|
|
268
|
-
return
|
|
278
|
+
return wrapGroupInitializationOp(`Created group "${title}"`, ctx.logger, () => manager.createGroup(creatorAci, creatorProfileKey, members, title, options), { memberCount: members.length + 1, title });
|
|
269
279
|
}
|
|
270
280
|
/**
|
|
271
281
|
* Get the decrypted state for a group
|
|
@@ -352,6 +362,6 @@ export async function createGroupInviteLink(ctx, manager, groupId, editorAci) {
|
|
|
352
362
|
* (if admin approval is required).
|
|
353
363
|
*/
|
|
354
364
|
export async function joinGroupViaInviteLink(ctx, manager, url, userAci, userProfileKey) {
|
|
355
|
-
return
|
|
365
|
+
return wrapGroupInitializationOp(`Joined group via invite link`, ctx.logger, () => manager.joinViaInviteLink(url, userAci, userProfileKey), {});
|
|
356
366
|
}
|
|
357
367
|
//# sourceMappingURL=groups.js.map
|