@open-e2ee/signal-protocol-sdk 0.1.0-alpha.9 → 0.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/ADAPTERS.md +12 -12
- package/ARCHITECTURE.md +3 -3
- package/CHANGELOG.md +374 -0
- package/README.md +25 -15
- package/SECURITY.md +1 -1
- package/client/README.md +2 -2
- package/device/README.md +3 -1
- package/dist/client/client.d.ts +6 -6
- package/dist/client/client.js +6 -6
- package/dist/client/compose.d.ts +2 -2
- package/dist/client/index.d.ts +2 -2
- package/dist/device/expo-metadata.d.ts +26 -0
- package/dist/device/expo-metadata.d.ts.map +1 -0
- package/dist/device/expo-metadata.js +33 -0
- package/dist/device/expo-metadata.js.map +1 -0
- package/dist/device/index.d.ts +1 -1
- package/dist/device/index.d.ts.map +1 -1
- package/dist/device/index.js +5 -1
- package/dist/device/index.js.map +1 -1
- package/dist/device/provisioning.d.ts +4 -12
- package/dist/device/provisioning.d.ts.map +1 -1
- package/dist/device/provisioning.js +4 -21
- package/dist/device/provisioning.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/internal/crypto/symmetric/aes.d.ts.map +1 -1
- package/dist/internal/crypto/symmetric/aes.js +27 -30
- package/dist/internal/crypto/symmetric/aes.js.map +1 -1
- package/dist/internal/encoding/proto/primitives.d.ts +261 -6
- package/dist/internal/encoding/proto/primitives.d.ts.map +1 -1
- package/dist/internal/encoding/proto/primitives.js +468 -6
- package/dist/internal/encoding/proto/primitives.js.map +1 -1
- package/dist/internal/encoding/proto/sender-key-message.d.ts +4 -3
- package/dist/internal/encoding/proto/sender-key-message.d.ts.map +1 -1
- package/dist/internal/encoding/proto/sender-key-message.js +97 -76
- package/dist/internal/encoding/proto/sender-key-message.js.map +1 -1
- package/dist/internal/encoding/proto/signal-message.d.ts +7 -2
- package/dist/internal/encoding/proto/signal-message.d.ts.map +1 -1
- package/dist/internal/encoding/proto/signal-message.js +194 -110
- package/dist/internal/encoding/proto/signal-message.js.map +1 -1
- package/dist/internal/manager/manager.d.ts +2 -2
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts +50 -4
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/proto/index.js +273 -151
- package/dist/internal/protocol/sealed-sender/proto/index.js.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/serialize.d.ts +7 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/serialize.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/serialize.js +334 -151
- package/dist/internal/protocol/spqr/ml-kem-braid/serialize.js.map +1 -1
- package/dist/layers.d.ts +2 -2
- package/dist/layers.d.ts.map +1 -1
- package/dist/layers.js +2 -2
- package/dist/layers.js.map +1 -1
- package/dist/local/store/index.d.ts +3 -3
- package/dist/local/store/index.d.ts.map +1 -1
- package/dist/local/store/index.js +4 -4
- package/dist/local/store/index.js.map +1 -1
- package/dist/local/store/{mock → memory}/adapter.d.ts +10 -10
- package/dist/local/store/memory/adapter.d.ts.map +1 -0
- package/dist/local/store/{mock → memory}/adapter.js +5 -5
- package/dist/local/store/memory/adapter.js.map +1 -0
- package/dist/local/store/{mock → memory}/failures.d.ts +6 -6
- package/dist/local/store/memory/failures.d.ts.map +1 -0
- package/dist/local/store/{mock → memory}/failures.js +6 -6
- package/dist/local/store/memory/failures.js.map +1 -0
- package/dist/local/store/memory/index.d.ts +11 -0
- package/dist/local/store/memory/index.d.ts.map +1 -0
- package/dist/local/store/memory/index.js +7 -0
- package/dist/local/store/memory/index.js.map +1 -0
- package/dist/local/store/react-native/adapter.d.ts.map +1 -1
- package/dist/local/store/react-native/adapter.js +69 -1
- package/dist/local/store/react-native/adapter.js.map +1 -1
- package/dist/local/store/react-native/backend-conformance.d.ts +66 -0
- package/dist/local/store/react-native/backend-conformance.d.ts.map +1 -0
- package/dist/local/store/react-native/backend-conformance.js +326 -0
- package/dist/local/store/react-native/backend-conformance.js.map +1 -0
- package/dist/local/store/react-native/index.d.ts +9 -4
- package/dist/local/store/react-native/index.d.ts.map +1 -1
- package/dist/local/store/react-native/index.js +2 -0
- package/dist/local/store/react-native/index.js.map +1 -1
- package/dist/local/store/react-native/reference-backend.d.ts +42 -0
- package/dist/local/store/react-native/reference-backend.d.ts.map +1 -0
- package/dist/local/store/react-native/reference-backend.js +177 -0
- package/dist/local/store/react-native/reference-backend.js.map +1 -0
- package/dist/local/store/react-native/storage.d.ts +9 -0
- package/dist/local/store/react-native/storage.d.ts.map +1 -1
- package/dist/local/store/web/adapter.d.ts +11 -1
- package/dist/local/store/web/adapter.d.ts.map +1 -1
- package/dist/local/store/web/adapter.js +196 -33
- package/dist/local/store/web/adapter.js.map +1 -1
- package/dist/local/store/web/index.d.ts +3 -2
- package/dist/local/store/web/index.d.ts.map +1 -1
- package/dist/local/store/web/index.js.map +1 -1
- package/dist/local/vault/index.d.ts +5 -1
- package/dist/local/vault/index.d.ts.map +1 -1
- package/dist/local/vault/index.js +1 -1
- package/dist/local/vault/index.js.map +1 -1
- package/dist/remote/relay/convex/component/certificates.d.ts.map +1 -1
- package/dist/remote/relay/convex/component/certificates.js +26 -31
- package/dist/remote/relay/convex/component/certificates.js.map +1 -1
- package/dist/remote/relay/index.d.ts +1 -1
- package/dist/remote/relay/index.d.ts.map +1 -1
- package/dist/remote/relay/index.js +2 -2
- package/dist/remote/relay/index.js.map +1 -1
- package/dist/remote/relay/{mock → memory}/adapter.d.ts +17 -17
- package/dist/remote/relay/memory/adapter.d.ts.map +1 -0
- package/dist/remote/relay/{mock → memory}/adapter.js +17 -17
- package/dist/remote/relay/memory/adapter.js.map +1 -0
- package/dist/remote/relay/{mock → memory}/failures.d.ts +5 -5
- package/dist/remote/relay/memory/failures.d.ts.map +1 -0
- package/dist/remote/relay/{mock → memory}/failures.js +1 -1
- package/dist/remote/relay/memory/failures.js.map +1 -0
- package/dist/remote/relay/{mock → memory}/group-server.d.ts +1 -1
- package/dist/remote/relay/memory/group-server.d.ts.map +1 -0
- package/dist/remote/relay/{mock → memory}/group-server.js +1 -1
- package/dist/remote/relay/memory/group-server.js.map +1 -0
- package/dist/remote/relay/memory/index.d.ts +11 -0
- package/dist/remote/relay/memory/index.d.ts.map +1 -0
- package/dist/remote/relay/memory/index.js +7 -0
- package/dist/remote/relay/memory/index.js.map +1 -0
- package/dist/types/errors.d.ts +33 -0
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +36 -0
- package/dist/types/errors.js.map +1 -1
- package/docs/ASSURANCE.md +49 -14
- package/docs/CLIENT_COMPOSITION.md +3 -3
- package/docs/GETTING_STARTED.md +11 -11
- package/docs/PACKAGE_SURFACE.md +10 -8
- package/docs/RECIPES.md +12 -12
- package/local/store/README.md +95 -8
- package/local/store/{mock → memory}/README.md +8 -8
- package/local/store/react-native/README.md +34 -2
- package/local/store/web/README.md +30 -3
- package/package.json +13 -10
- package/remote/README.md +7 -7
- package/remote/relay/README.md +5 -5
- package/remote/relay/{mock → memory}/README.md +8 -8
- package/dist/local/store/mock/adapter.d.ts.map +0 -1
- package/dist/local/store/mock/adapter.js.map +0 -1
- package/dist/local/store/mock/failures.d.ts.map +0 -1
- package/dist/local/store/mock/failures.js.map +0 -1
- package/dist/local/store/mock/index.d.ts +0 -11
- package/dist/local/store/mock/index.d.ts.map +0 -1
- package/dist/local/store/mock/index.js +0 -7
- package/dist/local/store/mock/index.js.map +0 -1
- package/dist/remote/relay/mock/adapter.d.ts.map +0 -1
- package/dist/remote/relay/mock/adapter.js.map +0 -1
- package/dist/remote/relay/mock/failures.d.ts.map +0 -1
- package/dist/remote/relay/mock/failures.js.map +0 -1
- package/dist/remote/relay/mock/group-server.d.ts.map +0 -1
- package/dist/remote/relay/mock/group-server.js.map +0 -1
- package/dist/remote/relay/mock/index.d.ts +0 -11
- package/dist/remote/relay/mock/index.d.ts.map +0 -1
- package/dist/remote/relay/mock/index.js +0 -7
- package/dist/remote/relay/mock/index.js.map +0 -1
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Wire Codec for Sealed Sender
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Hand-written static encoders and decoders for the sealed sender wire format,
|
|
5
|
+
* built on the shared protobuf primitives. No code is generated at runtime, so
|
|
6
|
+
* this path runs under `script-src 'self'`, in a Chrome MV3 extension, and
|
|
7
|
+
* under `node --disallow-code-generation-from-strings`.
|
|
6
8
|
*
|
|
7
|
-
*
|
|
9
|
+
* Certificates are signed over their *serialized* inner bytes, so byte
|
|
10
|
+
* identity here is what keeps an already-issued certificate verifiable. Two
|
|
11
|
+
* consequences run through the whole module:
|
|
12
|
+
*
|
|
13
|
+
* - Nothing re-encodes a signed region. Wherever the surface carries a signed
|
|
14
|
+
* payload it carries the raw bytes the signer saw — `certificate` in either
|
|
15
|
+
* wrapper, and `signerCertificate` inside the sender certificate — and the
|
|
16
|
+
* decoders hand those bytes straight through.
|
|
17
|
+
* - The encoders reproduce what this module emitted before, field for field
|
|
18
|
+
* and byte for byte, including writing an explicitly-set zero. The
|
|
19
|
+
* `sealed-sender` golden vectors pin every case in both directions. One
|
|
20
|
+
* input diverges: a string holding an unpaired surrogate encodes to the
|
|
21
|
+
* replacement character here, where reflection emitted the surrogate's own
|
|
22
|
+
* three bytes. `senderE164` and `senderUuid` are the only string fields,
|
|
23
|
+
* and no verification path re-encodes either.
|
|
24
|
+
*
|
|
25
|
+
* Field numbers are those this format has always written, and
|
|
26
|
+
* `UnidentifiedDelivery.proto` alongside this file now records them.
|
|
8
27
|
*/
|
|
9
|
-
import protobuf from 'protobufjs';
|
|
10
28
|
import { SealedSenderContentType } from '../types.js';
|
|
11
|
-
|
|
29
|
+
/* The encoding helpers come from their own module rather than the crypto
|
|
30
|
+
* barrel: the relay component bundles this codec, and the barrel also exports
|
|
31
|
+
* `generateRandomBytes`, whose third-choice runtime fallback is a dynamic
|
|
32
|
+
* `import('expo-crypto')`. That fallback never runs on a server, but a bundler
|
|
33
|
+
* still parses what it reaches, and the Expo package pulls in React Native. */
|
|
34
|
+
import { bytesToBase64, base64ToBytes } from '../../../crypto/utils.js';
|
|
35
|
+
import { ProtoReader, concatFields, encodeBytesField, encodeEnumField, encodeFixed64Field, encodeMessageField, encodeStringField, encodeUint32Field, } from '../../../encoding/proto/primitives.js';
|
|
12
36
|
/**
|
|
13
37
|
* Message type enum (matches proto).
|
|
14
38
|
*
|
|
@@ -17,103 +41,115 @@ import { bytesToBase64, base64ToBytes } from '../../../crypto/index.js';
|
|
|
17
41
|
*/
|
|
18
42
|
export { SealedSenderContentType as MessageType };
|
|
19
43
|
// ============================================================================
|
|
20
|
-
//
|
|
44
|
+
// Field Numbers
|
|
21
45
|
// ============================================================================
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
// UnidentifiedSenderMessage
|
|
65
|
-
const UnidentifiedSenderMessageType = new protobuf.Type('UnidentifiedSenderMessage')
|
|
66
|
-
.add(MessageTypeEnum)
|
|
67
|
-
.add(UnidentifiedSenderMessageMessage)
|
|
68
|
-
.add(new protobuf.Field('ephemeralPublic', 1, 'bytes'))
|
|
69
|
-
.add(new protobuf.Field('encryptedStatic', 2, 'bytes'))
|
|
70
|
-
.add(new protobuf.Field('encryptedMessage', 3, 'bytes'));
|
|
71
|
-
// Add all types to root
|
|
72
|
-
root.add(ServerCertificateType);
|
|
73
|
-
root.add(SenderCertificateType);
|
|
74
|
-
root.add(UnidentifiedSenderMessageType);
|
|
46
|
+
/** `ServerCertificate.Certificate` — the signed inner server certificate. */
|
|
47
|
+
const SERVER_CERTIFICATE_DATA = {
|
|
48
|
+
id: 1,
|
|
49
|
+
key: 2,
|
|
50
|
+
};
|
|
51
|
+
/** `ServerCertificate` — the outer wrapper carrying the signature. */
|
|
52
|
+
const SERVER_CERTIFICATE = {
|
|
53
|
+
certificate: 1,
|
|
54
|
+
signature: 2,
|
|
55
|
+
};
|
|
56
|
+
/** `SenderCertificate.Certificate` — the signed inner sender certificate. */
|
|
57
|
+
const SENDER_CERTIFICATE_DATA = {
|
|
58
|
+
senderE164: 1,
|
|
59
|
+
senderDevice: 2,
|
|
60
|
+
expires: 3,
|
|
61
|
+
identityKey: 4,
|
|
62
|
+
signerCertificate: 5,
|
|
63
|
+
senderUuid: 6,
|
|
64
|
+
};
|
|
65
|
+
/** `SenderCertificate` — the outer wrapper carrying the signature. */
|
|
66
|
+
const SENDER_CERTIFICATE = {
|
|
67
|
+
certificate: 1,
|
|
68
|
+
signature: 2,
|
|
69
|
+
};
|
|
70
|
+
/** `UnidentifiedSenderMessage.Message` — the decrypted inner message. */
|
|
71
|
+
const UNIDENTIFIED_SENDER_MESSAGE_DATA = {
|
|
72
|
+
type: 1,
|
|
73
|
+
senderCertificate: 2,
|
|
74
|
+
content: 3,
|
|
75
|
+
contentHint: 4,
|
|
76
|
+
groupId: 5,
|
|
77
|
+
};
|
|
78
|
+
/** `UnidentifiedSenderMessage` — the sealed envelope. */
|
|
79
|
+
const UNIDENTIFIED_SENDER_MESSAGE = {
|
|
80
|
+
ephemeralPublic: 1,
|
|
81
|
+
encryptedStatic: 2,
|
|
82
|
+
encryptedMessage: 3,
|
|
83
|
+
};
|
|
84
|
+
/** The zero value a bytes field decodes to when the message omits it. */
|
|
85
|
+
function emptyBytes() {
|
|
86
|
+
return new Uint8Array(0);
|
|
87
|
+
}
|
|
75
88
|
// ============================================================================
|
|
76
89
|
// Server Certificate Encoding
|
|
77
90
|
// ============================================================================
|
|
78
91
|
/**
|
|
79
92
|
* Encode server certificate inner Certificate data to protobuf bytes.
|
|
93
|
+
*
|
|
94
|
+
* These are the bytes the trust root signs.
|
|
80
95
|
*/
|
|
81
96
|
export function encodeServerCertificateData(data) {
|
|
82
|
-
|
|
83
|
-
id: data.id,
|
|
84
|
-
key: data.key,
|
|
85
|
-
});
|
|
86
|
-
return ServerCertificateCertificate.encode(message).finish();
|
|
97
|
+
return concatFields(encodeUint32Field(SERVER_CERTIFICATE_DATA.id, data.id), encodeBytesField(SERVER_CERTIFICATE_DATA.key, data.key));
|
|
87
98
|
}
|
|
88
99
|
/**
|
|
89
100
|
* Decode server certificate inner Certificate data from protobuf bytes.
|
|
90
101
|
*/
|
|
91
102
|
export function decodeServerCertificateData(bytes) {
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
103
|
+
const reader = new ProtoReader(bytes);
|
|
104
|
+
let id = 0;
|
|
105
|
+
let key = emptyBytes();
|
|
106
|
+
while (reader.hasMore()) {
|
|
107
|
+
const { fieldNumber } = reader.readTag();
|
|
108
|
+
switch (fieldNumber) {
|
|
109
|
+
case SERVER_CERTIFICATE_DATA.id:
|
|
110
|
+
id = reader.readUint32();
|
|
111
|
+
break;
|
|
112
|
+
case SERVER_CERTIFICATE_DATA.key:
|
|
113
|
+
key = reader.readBytes();
|
|
114
|
+
break;
|
|
115
|
+
default:
|
|
116
|
+
reader.skipField();
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return { id, key };
|
|
97
121
|
}
|
|
98
122
|
/**
|
|
99
123
|
* Encode server certificate outer wrapper to protobuf bytes.
|
|
100
124
|
*/
|
|
101
125
|
export function encodeServerCertificate(cert) {
|
|
102
|
-
|
|
103
|
-
certificate: cert.certificate,
|
|
104
|
-
signature: cert.signature,
|
|
105
|
-
});
|
|
106
|
-
return ServerCertificateType.encode(message).finish();
|
|
126
|
+
return concatFields(encodeBytesField(SERVER_CERTIFICATE.certificate, cert.certificate), encodeBytesField(SERVER_CERTIFICATE.signature, cert.signature));
|
|
107
127
|
}
|
|
108
128
|
/**
|
|
109
129
|
* Decode server certificate outer wrapper from protobuf bytes.
|
|
130
|
+
*
|
|
131
|
+
* `certificate` is returned exactly as it arrived — it is the byte string the
|
|
132
|
+
* signature was computed over.
|
|
110
133
|
*/
|
|
111
134
|
export function decodeServerCertificate(bytes) {
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
135
|
+
const reader = new ProtoReader(bytes);
|
|
136
|
+
let certificate = emptyBytes();
|
|
137
|
+
let signature = emptyBytes();
|
|
138
|
+
while (reader.hasMore()) {
|
|
139
|
+
const { fieldNumber } = reader.readTag();
|
|
140
|
+
switch (fieldNumber) {
|
|
141
|
+
case SERVER_CERTIFICATE.certificate:
|
|
142
|
+
certificate = reader.readBytes();
|
|
143
|
+
break;
|
|
144
|
+
case SERVER_CERTIFICATE.signature:
|
|
145
|
+
signature = reader.readBytes();
|
|
146
|
+
break;
|
|
147
|
+
default:
|
|
148
|
+
reader.skipField();
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return { certificate, signature };
|
|
117
153
|
}
|
|
118
154
|
// ============================================================================
|
|
119
155
|
// Sender Certificate Encoding
|
|
@@ -122,130 +158,216 @@ export function decodeServerCertificate(bytes) {
|
|
|
122
158
|
* Encode sender certificate inner Certificate data to protobuf bytes.
|
|
123
159
|
* Field numbers are part of the sealed-sender wire format.
|
|
124
160
|
*
|
|
161
|
+
* These are the bytes the issuing server signs. Fields are written in field
|
|
162
|
+
* number order; `senderE164` is written only when the sender has one, which is
|
|
163
|
+
* the one field a certificate may legitimately omit.
|
|
125
164
|
*/
|
|
126
165
|
export function encodeSenderCertificateData(data) {
|
|
127
|
-
const
|
|
128
|
-
senderUuid: data.senderUuid,
|
|
129
|
-
senderDevice: data.senderDevice,
|
|
130
|
-
expires: data.expires,
|
|
131
|
-
identityKey: data.identityKey,
|
|
132
|
-
signerCertificate: data.signerCertificate,
|
|
133
|
-
};
|
|
166
|
+
const parts = [];
|
|
134
167
|
if (data.senderE164) {
|
|
135
|
-
|
|
168
|
+
parts.push(encodeStringField(SENDER_CERTIFICATE_DATA.senderE164, data.senderE164));
|
|
136
169
|
}
|
|
137
|
-
|
|
138
|
-
|
|
170
|
+
parts.push(encodeUint32Field(SENDER_CERTIFICATE_DATA.senderDevice, data.senderDevice));
|
|
171
|
+
parts.push(encodeFixed64Field(SENDER_CERTIFICATE_DATA.expires, BigInt(data.expires)));
|
|
172
|
+
parts.push(encodeBytesField(SENDER_CERTIFICATE_DATA.identityKey, data.identityKey));
|
|
173
|
+
parts.push(encodeBytesField(SENDER_CERTIFICATE_DATA.signerCertificate, data.signerCertificate));
|
|
174
|
+
parts.push(encodeStringField(SENDER_CERTIFICATE_DATA.senderUuid, data.senderUuid));
|
|
175
|
+
return concatFields(...parts);
|
|
139
176
|
}
|
|
140
177
|
/**
|
|
141
178
|
* Decode sender certificate inner Certificate data from protobuf bytes.
|
|
142
179
|
*
|
|
180
|
+
* `signerCertificate` is the serialized `ServerCertificate` and is returned
|
|
181
|
+
* unmodified: the sender certificate's signature covers these bytes, so
|
|
182
|
+
* re-encoding it here would invalidate certificates that are currently valid.
|
|
143
183
|
*/
|
|
144
184
|
export function decodeSenderCertificateData(bytes) {
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
let
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
185
|
+
const reader = new ProtoReader(bytes);
|
|
186
|
+
let senderE164 = '';
|
|
187
|
+
let senderUuid = '';
|
|
188
|
+
let senderDevice = 0;
|
|
189
|
+
let expires = 0;
|
|
190
|
+
let identityKey = emptyBytes();
|
|
191
|
+
let signerCertificate = emptyBytes();
|
|
192
|
+
while (reader.hasMore()) {
|
|
193
|
+
const { fieldNumber } = reader.readTag();
|
|
194
|
+
switch (fieldNumber) {
|
|
195
|
+
case SENDER_CERTIFICATE_DATA.senderE164:
|
|
196
|
+
senderE164 = reader.readString();
|
|
197
|
+
break;
|
|
198
|
+
case SENDER_CERTIFICATE_DATA.senderDevice:
|
|
199
|
+
senderDevice = reader.readUint32();
|
|
200
|
+
break;
|
|
201
|
+
case SENDER_CERTIFICATE_DATA.expires:
|
|
202
|
+
// Milliseconds since the epoch. A Number holds that exactly well past
|
|
203
|
+
// any expiry a 24-hour credential can carry, and the surface has
|
|
204
|
+
// always been a Number.
|
|
205
|
+
expires = Number(reader.readFixed64());
|
|
206
|
+
break;
|
|
207
|
+
case SENDER_CERTIFICATE_DATA.identityKey:
|
|
208
|
+
identityKey = reader.readBytes();
|
|
209
|
+
break;
|
|
210
|
+
case SENDER_CERTIFICATE_DATA.signerCertificate:
|
|
211
|
+
signerCertificate = reader.readBytes();
|
|
212
|
+
break;
|
|
213
|
+
case SENDER_CERTIFICATE_DATA.senderUuid:
|
|
214
|
+
senderUuid = reader.readString();
|
|
215
|
+
break;
|
|
216
|
+
default:
|
|
217
|
+
reader.skipField();
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
156
220
|
}
|
|
157
221
|
return {
|
|
158
|
-
senderE164:
|
|
159
|
-
senderUuid
|
|
160
|
-
senderDevice
|
|
222
|
+
senderE164: senderE164 || undefined,
|
|
223
|
+
senderUuid,
|
|
224
|
+
senderDevice,
|
|
161
225
|
expires,
|
|
162
|
-
identityKey
|
|
163
|
-
signerCertificate
|
|
164
|
-
? new Uint8Array(message.signerCertificate)
|
|
165
|
-
: new Uint8Array(0),
|
|
226
|
+
identityKey,
|
|
227
|
+
signerCertificate,
|
|
166
228
|
};
|
|
167
229
|
}
|
|
168
230
|
/**
|
|
169
231
|
* Encode sender certificate outer wrapper to protobuf bytes.
|
|
170
232
|
*/
|
|
171
233
|
export function encodeSenderCertificate(cert) {
|
|
172
|
-
|
|
173
|
-
certificate: cert.certificate,
|
|
174
|
-
signature: cert.signature,
|
|
175
|
-
});
|
|
176
|
-
return SenderCertificateType.encode(message).finish();
|
|
234
|
+
return concatFields(encodeBytesField(SENDER_CERTIFICATE.certificate, cert.certificate), encodeBytesField(SENDER_CERTIFICATE.signature, cert.signature));
|
|
177
235
|
}
|
|
178
236
|
/**
|
|
179
237
|
* Decode sender certificate outer wrapper from protobuf bytes.
|
|
238
|
+
*
|
|
239
|
+
* `certificate` is returned exactly as it arrived — it is the byte string the
|
|
240
|
+
* signature was computed over.
|
|
180
241
|
*/
|
|
181
242
|
export function decodeSenderCertificate(bytes) {
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
243
|
+
const reader = new ProtoReader(bytes);
|
|
244
|
+
let certificate = emptyBytes();
|
|
245
|
+
let signature = emptyBytes();
|
|
246
|
+
while (reader.hasMore()) {
|
|
247
|
+
const { fieldNumber } = reader.readTag();
|
|
248
|
+
switch (fieldNumber) {
|
|
249
|
+
case SENDER_CERTIFICATE.certificate:
|
|
250
|
+
certificate = reader.readBytes();
|
|
251
|
+
break;
|
|
252
|
+
case SENDER_CERTIFICATE.signature:
|
|
253
|
+
signature = reader.readBytes();
|
|
254
|
+
break;
|
|
255
|
+
default:
|
|
256
|
+
reader.skipField();
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return { certificate, signature };
|
|
187
261
|
}
|
|
188
262
|
// ============================================================================
|
|
189
263
|
// UnidentifiedSenderMessage Encoding
|
|
190
264
|
// ============================================================================
|
|
191
265
|
/**
|
|
192
266
|
* Encode inner message data to bytes.
|
|
267
|
+
*
|
|
268
|
+
* `contentHint` is written whenever it is set, zero included — an absent hint
|
|
269
|
+
* and a hint of zero are different statements. `groupId` follows the same rule.
|
|
193
270
|
*/
|
|
194
271
|
export function encodeUnidentifiedSenderMessageData(data) {
|
|
195
|
-
const
|
|
196
|
-
type
|
|
197
|
-
senderCertificate
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
},
|
|
201
|
-
content: data.content,
|
|
202
|
-
};
|
|
272
|
+
const parts = [
|
|
273
|
+
encodeEnumField(UNIDENTIFIED_SENDER_MESSAGE_DATA.type, data.type),
|
|
274
|
+
encodeMessageField(UNIDENTIFIED_SENDER_MESSAGE_DATA.senderCertificate, encodeSenderCertificate(data.senderCertificate)),
|
|
275
|
+
encodeBytesField(UNIDENTIFIED_SENDER_MESSAGE_DATA.content, data.content),
|
|
276
|
+
];
|
|
203
277
|
if (data.contentHint !== undefined) {
|
|
204
|
-
|
|
278
|
+
parts.push(encodeUint32Field(UNIDENTIFIED_SENDER_MESSAGE_DATA.contentHint, data.contentHint));
|
|
205
279
|
}
|
|
206
280
|
if (data.groupId) {
|
|
207
|
-
|
|
281
|
+
parts.push(encodeBytesField(UNIDENTIFIED_SENDER_MESSAGE_DATA.groupId, data.groupId));
|
|
208
282
|
}
|
|
209
|
-
|
|
210
|
-
return UnidentifiedSenderMessageMessage.encode(message).finish();
|
|
283
|
+
return concatFields(...parts);
|
|
211
284
|
}
|
|
212
285
|
/**
|
|
213
286
|
* Decode inner message data from bytes.
|
|
287
|
+
*
|
|
288
|
+
* `type` is returned as it arrived — 0 when the field is absent, and any
|
|
289
|
+
* other value the wire carried, declared by the enum or not. Reflection
|
|
290
|
+
* clamped every undeclared value to the enum's first arm, so both an absent
|
|
291
|
+
* type and a type from a newer peer were reported as `PREKEY_MESSAGE`, which
|
|
292
|
+
* the sender never wrote; preserving the value is also what the protobuf spec
|
|
293
|
+
* asks of a decoder. The return type names the enum but nothing here narrows
|
|
294
|
+
* to it, so a caller that routes on `type` must put it through
|
|
295
|
+
* `isSealedSenderContentType` first. Neither decrypt path does today — both
|
|
296
|
+
* read the content type from the envelope framing, not from this decoder.
|
|
214
297
|
*/
|
|
215
298
|
export function decodeUnidentifiedSenderMessageData(bytes) {
|
|
216
|
-
const
|
|
299
|
+
const reader = new ProtoReader(bytes);
|
|
300
|
+
let type = 0;
|
|
301
|
+
let senderCertificate = {
|
|
302
|
+
certificate: emptyBytes(),
|
|
303
|
+
signature: emptyBytes(),
|
|
304
|
+
};
|
|
305
|
+
let content = emptyBytes();
|
|
306
|
+
let contentHint = 0;
|
|
307
|
+
let groupId = emptyBytes();
|
|
308
|
+
while (reader.hasMore()) {
|
|
309
|
+
const { fieldNumber } = reader.readTag();
|
|
310
|
+
switch (fieldNumber) {
|
|
311
|
+
case UNIDENTIFIED_SENDER_MESSAGE_DATA.type:
|
|
312
|
+
type = reader.readEnum();
|
|
313
|
+
break;
|
|
314
|
+
case UNIDENTIFIED_SENDER_MESSAGE_DATA.senderCertificate:
|
|
315
|
+
senderCertificate = decodeSenderCertificate(reader.readMessage());
|
|
316
|
+
break;
|
|
317
|
+
case UNIDENTIFIED_SENDER_MESSAGE_DATA.content:
|
|
318
|
+
content = reader.readBytes();
|
|
319
|
+
break;
|
|
320
|
+
case UNIDENTIFIED_SENDER_MESSAGE_DATA.contentHint:
|
|
321
|
+
contentHint = reader.readUint32();
|
|
322
|
+
break;
|
|
323
|
+
case UNIDENTIFIED_SENDER_MESSAGE_DATA.groupId:
|
|
324
|
+
groupId = reader.readBytes();
|
|
325
|
+
break;
|
|
326
|
+
default:
|
|
327
|
+
reader.skipField();
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
217
331
|
return {
|
|
218
|
-
type:
|
|
219
|
-
senderCertificate
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
content: new Uint8Array(message.content),
|
|
224
|
-
contentHint: message.contentHint,
|
|
225
|
-
groupId: message.groupId ? new Uint8Array(message.groupId) : undefined,
|
|
332
|
+
type: type,
|
|
333
|
+
senderCertificate,
|
|
334
|
+
content,
|
|
335
|
+
contentHint,
|
|
336
|
+
groupId,
|
|
226
337
|
};
|
|
227
338
|
}
|
|
228
339
|
/**
|
|
229
340
|
* Encode outer sealed sender message to bytes.
|
|
230
341
|
*/
|
|
231
342
|
export function encodeUnidentifiedSenderMessage(msg) {
|
|
232
|
-
|
|
233
|
-
ephemeralPublic: msg.ephemeralPublic,
|
|
234
|
-
encryptedStatic: msg.encryptedStatic,
|
|
235
|
-
encryptedMessage: msg.encryptedMessage,
|
|
236
|
-
});
|
|
237
|
-
return UnidentifiedSenderMessageType.encode(message).finish();
|
|
343
|
+
return concatFields(encodeBytesField(UNIDENTIFIED_SENDER_MESSAGE.ephemeralPublic, msg.ephemeralPublic), encodeBytesField(UNIDENTIFIED_SENDER_MESSAGE.encryptedStatic, msg.encryptedStatic), encodeBytesField(UNIDENTIFIED_SENDER_MESSAGE.encryptedMessage, msg.encryptedMessage));
|
|
238
344
|
}
|
|
239
345
|
/**
|
|
240
346
|
* Decode outer sealed sender message from bytes.
|
|
241
347
|
*/
|
|
242
348
|
export function decodeUnidentifiedSenderMessage(bytes) {
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
349
|
+
const reader = new ProtoReader(bytes);
|
|
350
|
+
let ephemeralPublic = emptyBytes();
|
|
351
|
+
let encryptedStatic = emptyBytes();
|
|
352
|
+
let encryptedMessage = emptyBytes();
|
|
353
|
+
while (reader.hasMore()) {
|
|
354
|
+
const { fieldNumber } = reader.readTag();
|
|
355
|
+
switch (fieldNumber) {
|
|
356
|
+
case UNIDENTIFIED_SENDER_MESSAGE.ephemeralPublic:
|
|
357
|
+
ephemeralPublic = reader.readBytes();
|
|
358
|
+
break;
|
|
359
|
+
case UNIDENTIFIED_SENDER_MESSAGE.encryptedStatic:
|
|
360
|
+
encryptedStatic = reader.readBytes();
|
|
361
|
+
break;
|
|
362
|
+
case UNIDENTIFIED_SENDER_MESSAGE.encryptedMessage:
|
|
363
|
+
encryptedMessage = reader.readBytes();
|
|
364
|
+
break;
|
|
365
|
+
default:
|
|
366
|
+
reader.skipField();
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return { ephemeralPublic, encryptedStatic, encryptedMessage };
|
|
249
371
|
}
|
|
250
372
|
// ============================================================================
|
|
251
373
|
// Utility Functions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../internal/protocol/sealed-sender/proto/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../internal/protocol/sealed-sender/proto/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AACnD;;;;+EAI+E;AAC/E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EACL,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,oCAAoC,CAAC;AA2C5C;;;;;GAKG;AACH,OAAO,EAAE,uBAAuB,IAAI,WAAW,EAAE,CAAC;AAsBlD,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E,6EAA6E;AAC7E,MAAM,uBAAuB,GAAG;IAC9B,EAAE,EAAE,CAAC;IACL,GAAG,EAAE,CAAC;CACE,CAAC;AAEX,sEAAsE;AACtE,MAAM,kBAAkB,GAAG;IACzB,WAAW,EAAE,CAAC;IACd,SAAS,EAAE,CAAC;CACJ,CAAC;AAEX,6EAA6E;AAC7E,MAAM,uBAAuB,GAAG;IAC9B,UAAU,EAAE,CAAC;IACb,YAAY,EAAE,CAAC;IACf,OAAO,EAAE,CAAC;IACV,WAAW,EAAE,CA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O,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC;AAChE,CAAC;AAED,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC7C,OAAO,aAAa,CAAC,KAAK,CAAW,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -239,11 +239,17 @@ export declare function deserializeDecoderProto(bytes: Uint8Array): Promise<{
|
|
|
239
239
|
messageSize: number;
|
|
240
240
|
}>;
|
|
241
241
|
/**
|
|
242
|
-
* Initialize serialization module
|
|
242
|
+
* Initialize serialization module.
|
|
243
|
+
*
|
|
244
|
+
* Nothing is loaded any more — the codecs above are static functions, so there
|
|
245
|
+
* is no schema to build at runtime and no first-call latency to pay. Kept, and
|
|
246
|
+
* kept async, because callers await it before serializing.
|
|
243
247
|
*/
|
|
244
248
|
export declare function initSerialization(): Promise<void>;
|
|
245
249
|
/**
|
|
246
250
|
* Check if serialization is ready
|
|
251
|
+
*
|
|
252
|
+
* Always true: with static codecs there is no state that could be missing.
|
|
247
253
|
*/
|
|
248
254
|
export declare function isSerializationReady(): boolean;
|
|
249
255
|
//# sourceMappingURL=serialize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../../../internal/protocol/spqr/ml-kem-braid/serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../../../internal/protocol/spqr/ml-kem-braid/serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAeH,OAAO,EAAE,WAAW,EAAsB,MAAM,SAAS,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM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