@signalapp/libsignal-client 0.81.0 → 0.82.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/Native.d.ts +34 -31
- package/Native.js +4 -1
- package/dist/AccountKeys.d.ts +3 -3
- package/dist/AccountKeys.js +8 -14
- package/dist/Address.d.ts +1 -1
- package/dist/Address.js +8 -15
- package/dist/EcKeys.d.ts +1 -1
- package/dist/EcKeys.js +4 -10
- package/dist/Errors.d.ts +2 -2
- package/dist/Errors.js +5 -9
- package/dist/MessageBackup.d.ts +4 -4
- package/dist/MessageBackup.js +10 -18
- package/dist/Minidump.js +2 -6
- package/dist/Mp4Sanitizer.d.ts +2 -2
- package/dist/Mp4Sanitizer.js +3 -8
- package/dist/SealedSenderMultiRecipientMessage.d.ts +1 -1
- package/dist/SealedSenderMultiRecipientMessage.js +2 -5
- package/dist/WebpSanitizer.js +2 -6
- package/dist/acknowledgments.md +254 -89
- package/dist/incremental_mac.d.ts +1 -1
- package/dist/incremental_mac.js +11 -19
- package/dist/index.d.ts +18 -18
- package/dist/index.js +93 -158
- package/dist/internal.d.ts +2 -2
- package/dist/internal.js +3 -8
- package/dist/io.d.ts +1 -1
- package/dist/io.js +1 -5
- package/dist/net/CDSI.d.ts +2 -2
- package/dist/net/CDSI.js +8 -12
- package/dist/net/Chat.d.ts +11 -12
- package/dist/net/Chat.js +15 -22
- package/dist/net/KeyTransparency.d.ts +10 -10
- package/dist/net/KeyTransparency.js +4 -8
- package/dist/net/Registration.d.ts +5 -5
- package/dist/net/Registration.js +16 -22
- package/dist/net/SvrB.d.ts +3 -3
- package/dist/net/SvrB.js +5 -9
- package/dist/net/chat/UnauthUsernamesService.d.ts +4 -4
- package/dist/net/chat/UnauthUsernamesService.js +5 -7
- package/dist/net.d.ts +11 -11
- package/dist/net.js +27 -46
- package/dist/usernames.js +12 -23
- package/dist/zkgroup/GenericServerPublicParams.d.ts +1 -1
- package/dist/zkgroup/GenericServerPublicParams.js +3 -6
- package/dist/zkgroup/GenericServerSecretParams.d.ts +2 -2
- package/dist/zkgroup/GenericServerSecretParams.js +8 -11
- package/dist/zkgroup/NotarySignature.d.ts +1 -1
- package/dist/zkgroup/NotarySignature.js +3 -5
- package/dist/zkgroup/ServerPublicParams.d.ts +2 -2
- package/dist/zkgroup/ServerPublicParams.js +2 -5
- package/dist/zkgroup/ServerSecretParams.d.ts +3 -3
- package/dist/zkgroup/ServerSecretParams.js +10 -13
- package/dist/zkgroup/auth/AuthCredentialPresentation.d.ts +2 -2
- package/dist/zkgroup/auth/AuthCredentialPresentation.js +6 -9
- package/dist/zkgroup/auth/AuthCredentialWithPni.d.ts +1 -1
- package/dist/zkgroup/auth/AuthCredentialWithPni.js +3 -6
- package/dist/zkgroup/auth/AuthCredentialWithPniResponse.d.ts +1 -1
- package/dist/zkgroup/auth/AuthCredentialWithPniResponse.js +3 -6
- package/dist/zkgroup/auth/ClientZkAuthOperations.d.ts +6 -6
- package/dist/zkgroup/auth/ClientZkAuthOperations.js +9 -12
- package/dist/zkgroup/auth/ServerZkAuthOperations.d.ts +5 -5
- package/dist/zkgroup/auth/ServerZkAuthOperations.js +7 -10
- package/dist/zkgroup/backups/BackupAuthCredential.d.ts +5 -5
- package/dist/zkgroup/backups/BackupAuthCredential.js +12 -15
- package/dist/zkgroup/backups/BackupAuthCredentialPresentation.d.ts +4 -4
- package/dist/zkgroup/backups/BackupAuthCredentialPresentation.js +7 -10
- package/dist/zkgroup/backups/BackupAuthCredentialRequest.d.ts +5 -5
- package/dist/zkgroup/backups/BackupAuthCredentialRequest.js +8 -11
- package/dist/zkgroup/backups/BackupAuthCredentialRequestContext.d.ts +6 -6
- package/dist/zkgroup/backups/BackupAuthCredentialRequestContext.js +8 -11
- package/dist/zkgroup/backups/BackupAuthCredentialResponse.d.ts +1 -1
- package/dist/zkgroup/backups/BackupAuthCredentialResponse.js +3 -6
- package/dist/zkgroup/backups/BackupCredentialType.js +1 -3
- package/dist/zkgroup/backups/BackupLevel.js +1 -3
- package/dist/zkgroup/calllinks/CallLinkAuthCredential.d.ts +5 -5
- package/dist/zkgroup/calllinks/CallLinkAuthCredential.js +8 -11
- package/dist/zkgroup/calllinks/CallLinkAuthCredentialPresentation.d.ts +4 -4
- package/dist/zkgroup/calllinks/CallLinkAuthCredentialPresentation.js +5 -8
- package/dist/zkgroup/calllinks/CallLinkAuthCredentialResponse.d.ts +5 -5
- package/dist/zkgroup/calllinks/CallLinkAuthCredentialResponse.js +8 -11
- package/dist/zkgroup/calllinks/CallLinkPublicParams.d.ts +1 -1
- package/dist/zkgroup/calllinks/CallLinkPublicParams.js +3 -6
- package/dist/zkgroup/calllinks/CallLinkSecretParams.d.ts +4 -4
- package/dist/zkgroup/calllinks/CallLinkSecretParams.js +9 -12
- package/dist/zkgroup/calllinks/CreateCallLinkCredential.d.ts +5 -5
- package/dist/zkgroup/calllinks/CreateCallLinkCredential.js +8 -11
- package/dist/zkgroup/calllinks/CreateCallLinkCredentialPresentation.d.ts +3 -3
- package/dist/zkgroup/calllinks/CreateCallLinkCredentialPresentation.js +3 -6
- package/dist/zkgroup/calllinks/CreateCallLinkCredentialRequest.d.ts +4 -4
- package/dist/zkgroup/calllinks/CreateCallLinkCredentialRequest.js +8 -11
- package/dist/zkgroup/calllinks/CreateCallLinkCredentialRequestContext.d.ts +6 -6
- package/dist/zkgroup/calllinks/CreateCallLinkCredentialRequestContext.js +10 -13
- package/dist/zkgroup/calllinks/CreateCallLinkCredentialResponse.d.ts +1 -1
- package/dist/zkgroup/calllinks/CreateCallLinkCredentialResponse.js +3 -6
- package/dist/zkgroup/groups/ClientZkGroupCipher.d.ts +5 -5
- package/dist/zkgroup/groups/ClientZkGroupCipher.js +13 -16
- package/dist/zkgroup/groups/GroupIdentifier.d.ts +1 -1
- package/dist/zkgroup/groups/GroupIdentifier.js +3 -5
- package/dist/zkgroup/groups/GroupMasterKey.d.ts +1 -1
- package/dist/zkgroup/groups/GroupMasterKey.js +3 -5
- package/dist/zkgroup/groups/GroupPublicParams.d.ts +2 -2
- package/dist/zkgroup/groups/GroupPublicParams.js +5 -8
- package/dist/zkgroup/groups/GroupSecretParams.d.ts +3 -3
- package/dist/zkgroup/groups/GroupSecretParams.js +10 -13
- package/dist/zkgroup/groups/ProfileKeyCiphertext.d.ts +1 -1
- package/dist/zkgroup/groups/ProfileKeyCiphertext.js +3 -6
- package/dist/zkgroup/groups/UuidCiphertext.d.ts +1 -1
- package/dist/zkgroup/groups/UuidCiphertext.js +3 -6
- package/dist/zkgroup/groupsend/GroupSendDerivedKeyPair.d.ts +2 -2
- package/dist/zkgroup/groupsend/GroupSendDerivedKeyPair.js +3 -6
- package/dist/zkgroup/groupsend/GroupSendEndorsement.d.ts +5 -5
- package/dist/zkgroup/groupsend/GroupSendEndorsement.js +10 -13
- package/dist/zkgroup/groupsend/GroupSendEndorsementsResponse.d.ts +7 -7
- package/dist/zkgroup/groupsend/GroupSendEndorsementsResponse.js +14 -17
- package/dist/zkgroup/groupsend/GroupSendFullToken.d.ts +3 -3
- package/dist/zkgroup/groupsend/GroupSendFullToken.js +5 -8
- package/dist/zkgroup/groupsend/GroupSendToken.d.ts +2 -2
- package/dist/zkgroup/groupsend/GroupSendToken.js +5 -8
- package/dist/zkgroup/index.d.ts +57 -57
- package/dist/zkgroup/index.js +57 -118
- package/dist/zkgroup/internal/ByteArray.js +6 -10
- package/dist/zkgroup/internal/Constants.js +4 -7
- package/dist/zkgroup/profiles/ClientZkProfileOperations.d.ts +8 -8
- package/dist/zkgroup/profiles/ClientZkProfileOperations.js +12 -15
- package/dist/zkgroup/profiles/ExpiringProfileKeyCredential.d.ts +1 -1
- package/dist/zkgroup/profiles/ExpiringProfileKeyCredential.js +3 -6
- package/dist/zkgroup/profiles/ExpiringProfileKeyCredentialResponse.d.ts +1 -1
- package/dist/zkgroup/profiles/ExpiringProfileKeyCredentialResponse.js +3 -6
- package/dist/zkgroup/profiles/ProfileKey.d.ts +4 -4
- package/dist/zkgroup/profiles/ProfileKey.js +8 -10
- package/dist/zkgroup/profiles/ProfileKeyCommitment.d.ts +1 -1
- package/dist/zkgroup/profiles/ProfileKeyCommitment.js +3 -6
- package/dist/zkgroup/profiles/ProfileKeyCredentialPresentation.d.ts +3 -3
- package/dist/zkgroup/profiles/ProfileKeyCredentialPresentation.js +7 -10
- package/dist/zkgroup/profiles/ProfileKeyCredentialRequest.d.ts +1 -1
- package/dist/zkgroup/profiles/ProfileKeyCredentialRequest.js +3 -6
- package/dist/zkgroup/profiles/ProfileKeyCredentialRequestContext.d.ts +2 -2
- package/dist/zkgroup/profiles/ProfileKeyCredentialRequestContext.js +5 -8
- package/dist/zkgroup/profiles/ProfileKeyVersion.d.ts +1 -1
- package/dist/zkgroup/profiles/ProfileKeyVersion.js +3 -5
- package/dist/zkgroup/profiles/ServerZkProfileOperations.d.ts +7 -7
- package/dist/zkgroup/profiles/ServerZkProfileOperations.js +7 -10
- package/dist/zkgroup/receipts/ClientZkReceiptOperations.d.ts +6 -6
- package/dist/zkgroup/receipts/ClientZkReceiptOperations.js +12 -15
- package/dist/zkgroup/receipts/ReceiptCredential.d.ts +1 -1
- package/dist/zkgroup/receipts/ReceiptCredential.js +3 -6
- package/dist/zkgroup/receipts/ReceiptCredentialPresentation.d.ts +2 -2
- package/dist/zkgroup/receipts/ReceiptCredentialPresentation.js +6 -8
- package/dist/zkgroup/receipts/ReceiptCredentialRequest.d.ts +1 -1
- package/dist/zkgroup/receipts/ReceiptCredentialRequest.js +3 -6
- package/dist/zkgroup/receipts/ReceiptCredentialRequestContext.d.ts +2 -2
- package/dist/zkgroup/receipts/ReceiptCredentialRequestContext.js +6 -8
- package/dist/zkgroup/receipts/ReceiptCredentialResponse.d.ts +1 -1
- package/dist/zkgroup/receipts/ReceiptCredentialResponse.js +3 -6
- package/dist/zkgroup/receipts/ReceiptSerial.d.ts +1 -1
- package/dist/zkgroup/receipts/ReceiptSerial.js +3 -5
- package/dist/zkgroup/receipts/ServerZkReceiptOperations.d.ts +4 -4
- package/dist/zkgroup/receipts/ServerZkReceiptOperations.js +7 -10
- package/package.json +24 -20
- package/prebuilds/darwin-arm64/@signalapp+libsignal-client.node +0 -0
- package/prebuilds/darwin-x64/@signalapp+libsignal-client.node +0 -0
- package/prebuilds/linux-arm64/@signalapp+libsignal-client.node +0 -0
- package/prebuilds/linux-x64/@signalapp+libsignal-client.node +0 -0
- package/prebuilds/win32-arm64/@signalapp+libsignal-client.node +0 -0
- package/prebuilds/win32-x64/@signalapp+libsignal-client.node +0 -0
- package/zkgroup.js +1 -1
package/dist/net.js
CHANGED
|
@@ -1,43 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
//
|
|
3
2
|
// Copyright 2023 Signal Messenger, LLC.
|
|
4
3
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
4
|
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.Net = exports.SIGNAL_TLS_PROXY_SCHEME = exports.TokioAsyncContext = exports.Environment = void 0;
|
|
22
|
-
const Native = require("../Native");
|
|
23
|
-
const CDSI_1 = require("./net/CDSI");
|
|
24
|
-
const Chat_1 = require("./net/Chat");
|
|
25
|
-
const Registration_1 = require("./net/Registration");
|
|
26
|
-
const SvrB_1 = require("./net/SvrB");
|
|
27
|
-
const internal_1 = require("./internal");
|
|
28
|
-
__exportStar(require("./net/CDSI"), exports);
|
|
29
|
-
__exportStar(require("./net/Chat"), exports);
|
|
30
|
-
__exportStar(require("./net/chat/UnauthUsernamesService"), exports);
|
|
31
|
-
__exportStar(require("./net/Registration"), exports);
|
|
32
|
-
__exportStar(require("./net/SvrB"), exports);
|
|
5
|
+
import Native from '../Native.js';
|
|
6
|
+
import { cdsiLookup, } from './net/CDSI.js';
|
|
7
|
+
import { UnauthenticatedChatConnection, AuthenticatedChatConnection, } from './net/Chat.js';
|
|
8
|
+
import { RegistrationService } from './net/Registration.js';
|
|
9
|
+
import { SvrB } from './net/SvrB.js';
|
|
10
|
+
import { BridgedStringMap, newNativeHandle } from './internal.js';
|
|
11
|
+
export * from './net/CDSI.js';
|
|
12
|
+
export * from './net/Chat.js';
|
|
13
|
+
export * from './net/chat/UnauthUsernamesService.js';
|
|
14
|
+
export * from './net/Registration.js';
|
|
15
|
+
export * from './net/SvrB.js';
|
|
33
16
|
// This must match the libsignal-bridge Rust enum of the same name.
|
|
34
|
-
var Environment;
|
|
17
|
+
export var Environment;
|
|
35
18
|
(function (Environment) {
|
|
36
19
|
Environment[Environment["Staging"] = 0] = "Staging";
|
|
37
20
|
Environment[Environment["Production"] = 1] = "Production";
|
|
38
|
-
})(Environment || (
|
|
21
|
+
})(Environment || (Environment = {}));
|
|
39
22
|
/** Low-level async runtime control, mostly just exported for testing. */
|
|
40
|
-
class TokioAsyncContext {
|
|
23
|
+
export class TokioAsyncContext {
|
|
41
24
|
constructor(handle) {
|
|
42
25
|
this._nativeHandle = handle;
|
|
43
26
|
}
|
|
@@ -57,18 +40,17 @@ class TokioAsyncContext {
|
|
|
57
40
|
return promise;
|
|
58
41
|
}
|
|
59
42
|
}
|
|
60
|
-
exports.TokioAsyncContext = TokioAsyncContext;
|
|
61
43
|
/** The "scheme" for Signal TLS proxies. See {@link Net.setProxy()}. */
|
|
62
|
-
|
|
63
|
-
class Net {
|
|
44
|
+
export const SIGNAL_TLS_PROXY_SCHEME = 'org.signal.tls';
|
|
45
|
+
export class Net {
|
|
64
46
|
constructor(options) {
|
|
65
47
|
this.options = options;
|
|
66
48
|
this.asyncContext = new TokioAsyncContext(Native.TokioAsyncContext_new());
|
|
67
49
|
if (options.localTestServer) {
|
|
68
|
-
this._connectionManager =
|
|
50
|
+
this._connectionManager = newNativeHandle(Native.TESTING_ConnectionManager_newLocalOverride(options.userAgent, options.TESTING_localServer_chatPort, options.TESTING_localServer_cdsiPort, options.TESTING_localServer_svr2Port, options.TESTING_localServer_svrBPort, options.TESTING_localServer_rootCertificateDer));
|
|
69
51
|
}
|
|
70
52
|
else {
|
|
71
|
-
this._connectionManager =
|
|
53
|
+
this._connectionManager = newNativeHandle(Native.ConnectionManager_new(options.env, options.userAgent, new BridgedStringMap(options.remoteConfig || new Map())));
|
|
72
54
|
}
|
|
73
55
|
}
|
|
74
56
|
/**
|
|
@@ -97,7 +79,7 @@ class Net {
|
|
|
97
79
|
*/
|
|
98
80
|
async connectUnauthenticatedChat(listener, options) {
|
|
99
81
|
const env = this.options.localTestServer ? undefined : this.options.env;
|
|
100
|
-
return
|
|
82
|
+
return UnauthenticatedChatConnection.connect(this.asyncContext, this._connectionManager, listener, env, options);
|
|
101
83
|
}
|
|
102
84
|
/**
|
|
103
85
|
* Creates a new instance of {@link AuthenticatedChatConnection}.
|
|
@@ -114,16 +96,16 @@ class Net {
|
|
|
114
96
|
* @param options.abortSignal an {@link AbortSignal} that will cancel the connection attempt.
|
|
115
97
|
*/
|
|
116
98
|
connectAuthenticatedChat(username, password, receiveStories, listener, options) {
|
|
117
|
-
return
|
|
99
|
+
return AuthenticatedChatConnection.connect(this.asyncContext, this._connectionManager, username, password, receiveStories, listener, options);
|
|
118
100
|
}
|
|
119
101
|
async resumeRegistrationSession({ sessionId, e164, }) {
|
|
120
|
-
return
|
|
102
|
+
return RegistrationService.resumeSession({
|
|
121
103
|
connectionManager: this._connectionManager,
|
|
122
104
|
tokioAsyncContext: this.asyncContext,
|
|
123
105
|
}, { sessionId, e164 });
|
|
124
106
|
}
|
|
125
107
|
async createRegistrationSession({ e164, }) {
|
|
126
|
-
return
|
|
108
|
+
return RegistrationService.createSession({
|
|
127
109
|
connectionManager: this._connectionManager,
|
|
128
110
|
tokioAsyncContext: this.asyncContext,
|
|
129
111
|
}, { e164 });
|
|
@@ -157,7 +139,7 @@ class Net {
|
|
|
157
139
|
const [before, after] = hostOrOptions.split('@', 2);
|
|
158
140
|
const [username, domain] = after ? [before, after] : [undefined, before];
|
|
159
141
|
hostOrOptions = {
|
|
160
|
-
scheme:
|
|
142
|
+
scheme: SIGNAL_TLS_PROXY_SCHEME,
|
|
161
143
|
host: domain,
|
|
162
144
|
port: portOrNothing,
|
|
163
145
|
username,
|
|
@@ -165,7 +147,7 @@ class Net {
|
|
|
165
147
|
}
|
|
166
148
|
const { scheme, host, port, username, password } = hostOrOptions;
|
|
167
149
|
try {
|
|
168
|
-
const proxyConfig =
|
|
150
|
+
const proxyConfig = newNativeHandle(Native.ConnectionProxyConfig_new(scheme, host,
|
|
169
151
|
// i32::MIN represents "no port provided"; we don't expect anyone to pass that manually.
|
|
170
152
|
port ?? -2147483648, username ?? null, password ?? null));
|
|
171
153
|
Native.ConnectionManager_set_proxy(this._connectionManager, proxyConfig);
|
|
@@ -269,7 +251,7 @@ class Net {
|
|
|
269
251
|
* @param remoteConfig A map containing preprocessed libsignal configuration keys and their associated values.
|
|
270
252
|
*/
|
|
271
253
|
setRemoteConfig(remoteConfig) {
|
|
272
|
-
Native.ConnectionManager_set_remote_config(this._connectionManager, new
|
|
254
|
+
Native.ConnectionManager_set_remote_config(this._connectionManager, new BridgedStringMap(remoteConfig));
|
|
273
255
|
}
|
|
274
256
|
/**
|
|
275
257
|
* Notifies libsignal that the network has changed.
|
|
@@ -280,7 +262,7 @@ class Net {
|
|
|
280
262
|
Native.ConnectionManager_on_network_change(this._connectionManager);
|
|
281
263
|
}
|
|
282
264
|
async cdsiLookup(auth, options) {
|
|
283
|
-
return
|
|
265
|
+
return cdsiLookup({
|
|
284
266
|
asyncContext: this.asyncContext,
|
|
285
267
|
connectionManager: this._connectionManager,
|
|
286
268
|
}, auth, options);
|
|
@@ -302,8 +284,7 @@ class Net {
|
|
|
302
284
|
const env = this.options.localTestServer
|
|
303
285
|
? Environment.Staging
|
|
304
286
|
: this.options.env;
|
|
305
|
-
return new
|
|
287
|
+
return new SvrB(this.asyncContext, this._connectionManager, auth, env);
|
|
306
288
|
}
|
|
307
289
|
}
|
|
308
|
-
exports.Net = Net;
|
|
309
290
|
//# sourceMappingURL=net.js.map
|
package/dist/usernames.js
CHANGED
|
@@ -1,52 +1,41 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
//
|
|
3
2
|
// Copyright 2023 Signal Messenger, LLC.
|
|
4
3
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
4
|
//
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.verifyProof = exports.createUsernameLink = exports.decryptUsernameLink = exports.generateProofWithRandom = exports.generateProof = exports.hash = exports.fromParts = exports.generateCandidates = void 0;
|
|
8
5
|
/* eslint @typescript-eslint/no-shadow: ["error", { "allow": ["hash"] }] */
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function generateCandidates(nickname, minNicknameLength, maxNicknameLength) {
|
|
6
|
+
import { randomBytes } from 'node:crypto';
|
|
7
|
+
import { RANDOM_LENGTH } from './zkgroup/internal/Constants.js';
|
|
8
|
+
import Native from '../Native.js';
|
|
9
|
+
export function generateCandidates(nickname, minNicknameLength, maxNicknameLength) {
|
|
13
10
|
return Native.Username_CandidatesFrom(nickname, minNicknameLength, maxNicknameLength);
|
|
14
11
|
}
|
|
15
|
-
|
|
16
|
-
function fromParts(nickname, discriminator, minNicknameLength, maxNicknameLength) {
|
|
12
|
+
export function fromParts(nickname, discriminator, minNicknameLength, maxNicknameLength) {
|
|
17
13
|
const hash = Native.Username_HashFromParts(nickname, discriminator, minNicknameLength, maxNicknameLength);
|
|
18
14
|
// If we generated the hash correctly, we can format the nickname and discriminator manually.
|
|
19
15
|
const username = `${nickname}.${discriminator}`;
|
|
20
16
|
return { username, hash };
|
|
21
17
|
}
|
|
22
|
-
|
|
23
|
-
function hash(username) {
|
|
18
|
+
export function hash(username) {
|
|
24
19
|
return Native.Username_Hash(username);
|
|
25
20
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const random = (0, crypto_1.randomBytes)(Constants_1.RANDOM_LENGTH);
|
|
21
|
+
export function generateProof(username) {
|
|
22
|
+
const random = randomBytes(RANDOM_LENGTH);
|
|
29
23
|
return generateProofWithRandom(username, random);
|
|
30
24
|
}
|
|
31
|
-
|
|
32
|
-
function generateProofWithRandom(username, random) {
|
|
25
|
+
export function generateProofWithRandom(username, random) {
|
|
33
26
|
return Native.Username_Proof(username, random);
|
|
34
27
|
}
|
|
35
|
-
|
|
36
|
-
function decryptUsernameLink(usernameLink) {
|
|
28
|
+
export function decryptUsernameLink(usernameLink) {
|
|
37
29
|
return Native.UsernameLink_DecryptUsername(usernameLink.entropy, usernameLink.encryptedUsername);
|
|
38
30
|
}
|
|
39
|
-
|
|
40
|
-
function createUsernameLink(username, previousEntropy) {
|
|
31
|
+
export function createUsernameLink(username, previousEntropy) {
|
|
41
32
|
const usernameLinkData = Native.UsernameLink_Create(username, previousEntropy ?? null);
|
|
42
33
|
const entropy = usernameLinkData.subarray(0, 32);
|
|
43
34
|
const encryptedUsername = usernameLinkData.subarray(32);
|
|
44
35
|
return { entropy, encryptedUsername };
|
|
45
36
|
}
|
|
46
|
-
exports.createUsernameLink = createUsernameLink;
|
|
47
37
|
// Only for testing. Will throw on failure.
|
|
48
|
-
function verifyProof(proof, hash) {
|
|
38
|
+
export function verifyProof(proof, hash) {
|
|
49
39
|
Native.Username_Verify(proof, hash);
|
|
50
40
|
}
|
|
51
|
-
exports.verifyProof = verifyProof;
|
|
52
41
|
//# sourceMappingURL=usernames.js.map
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
//
|
|
3
2
|
// Copyright 2020-2021 Signal Messenger, LLC.
|
|
4
3
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
4
|
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class GenericServerPublicParams extends ByteArray_1.default {
|
|
5
|
+
import ByteArray from './internal/ByteArray.js';
|
|
6
|
+
import Native from '../../Native.js';
|
|
7
|
+
export default class GenericServerPublicParams extends ByteArray {
|
|
10
8
|
constructor(contents) {
|
|
11
9
|
super(contents, Native.GenericServerPublicParams_CheckValidContents);
|
|
12
10
|
}
|
|
13
11
|
}
|
|
14
|
-
exports.default = GenericServerPublicParams;
|
|
15
12
|
//# sourceMappingURL=GenericServerPublicParams.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ByteArray from './internal/ByteArray';
|
|
2
|
-
import GenericServerPublicParams from './GenericServerPublicParams';
|
|
1
|
+
import ByteArray from './internal/ByteArray.js';
|
|
2
|
+
import GenericServerPublicParams from './GenericServerPublicParams.js';
|
|
3
3
|
export default class GenericServerSecretParams extends ByteArray {
|
|
4
4
|
private readonly __type?;
|
|
5
5
|
static generate(): GenericServerSecretParams;
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
//
|
|
3
2
|
// Copyright 2023 Signal Messenger, LLC.
|
|
4
3
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
4
|
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class GenericServerSecretParams extends ByteArray_1.default {
|
|
5
|
+
import { randomBytes } from 'node:crypto';
|
|
6
|
+
import Native from '../../Native.js';
|
|
7
|
+
import ByteArray from './internal/ByteArray.js';
|
|
8
|
+
import { RANDOM_LENGTH } from './internal/Constants.js';
|
|
9
|
+
import GenericServerPublicParams from './GenericServerPublicParams.js';
|
|
10
|
+
export default class GenericServerSecretParams extends ByteArray {
|
|
13
11
|
static generate() {
|
|
14
|
-
const random =
|
|
12
|
+
const random = randomBytes(RANDOM_LENGTH);
|
|
15
13
|
return GenericServerSecretParams.generateWithRandom(random);
|
|
16
14
|
}
|
|
17
15
|
static generateWithRandom(random) {
|
|
@@ -21,8 +19,7 @@ class GenericServerSecretParams extends ByteArray_1.default {
|
|
|
21
19
|
super(contents, Native.GenericServerSecretParams_CheckValidContents);
|
|
22
20
|
}
|
|
23
21
|
getPublicParams() {
|
|
24
|
-
return new
|
|
22
|
+
return new GenericServerPublicParams(Native.GenericServerSecretParams_GetPublicParams(this.contents));
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
|
-
exports.default = GenericServerSecretParams;
|
|
28
25
|
//# sourceMappingURL=GenericServerSecretParams.js.map
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
//
|
|
3
2
|
// Copyright 2020-2021 Signal Messenger, LLC.
|
|
4
3
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
4
|
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class NotarySignature extends ByteArray_1.default {
|
|
5
|
+
import ByteArray from './internal/ByteArray.js';
|
|
6
|
+
class NotarySignature extends ByteArray {
|
|
9
7
|
constructor(contents) {
|
|
10
8
|
super(contents, NotarySignature.checkLength(NotarySignature.SIZE));
|
|
11
9
|
}
|
|
12
10
|
}
|
|
13
11
|
NotarySignature.SIZE = 64;
|
|
14
|
-
|
|
12
|
+
export default NotarySignature;
|
|
15
13
|
//# sourceMappingURL=NotarySignature.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import NotarySignature from './NotarySignature';
|
|
1
|
+
import Native from '../../Native.js';
|
|
2
|
+
import NotarySignature from './NotarySignature.js';
|
|
3
3
|
export default class ServerPublicParams {
|
|
4
4
|
readonly _nativeHandle: Native.ServerPublicParams;
|
|
5
5
|
constructor(contents: Uint8Array | Native.ServerPublicParams);
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
//
|
|
3
2
|
// Copyright 2020-2021 Signal Messenger, LLC.
|
|
4
3
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
4
|
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class ServerPublicParams {
|
|
5
|
+
import Native from '../../Native.js';
|
|
6
|
+
export default class ServerPublicParams {
|
|
9
7
|
constructor(contents) {
|
|
10
8
|
if (contents instanceof Uint8Array) {
|
|
11
9
|
this._nativeHandle = Native.ServerPublicParams_Deserialize(contents);
|
|
@@ -29,5 +27,4 @@ class ServerPublicParams {
|
|
|
29
27
|
return Native.ServerPublicParams_Serialize(this);
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
|
-
exports.default = ServerPublicParams;
|
|
33
30
|
//# sourceMappingURL=ServerPublicParams.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import ServerPublicParams from './ServerPublicParams';
|
|
3
|
-
import NotarySignature from './NotarySignature';
|
|
1
|
+
import Native from '../../Native.js';
|
|
2
|
+
import ServerPublicParams from './ServerPublicParams.js';
|
|
3
|
+
import NotarySignature from './NotarySignature.js';
|
|
4
4
|
export default class ServerSecretParams {
|
|
5
5
|
static generate(): ServerSecretParams;
|
|
6
6
|
static generateWithRandom(random: Uint8Array): ServerSecretParams;
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
//
|
|
3
2
|
// Copyright 2021 Signal Messenger, LLC.
|
|
4
3
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
4
|
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class ServerSecretParams {
|
|
5
|
+
import { randomBytes } from 'node:crypto';
|
|
6
|
+
import Native from '../../Native.js';
|
|
7
|
+
import { RANDOM_LENGTH } from './internal/Constants.js';
|
|
8
|
+
import ServerPublicParams from './ServerPublicParams.js';
|
|
9
|
+
import NotarySignature from './NotarySignature.js';
|
|
10
|
+
export default class ServerSecretParams {
|
|
13
11
|
static generate() {
|
|
14
|
-
const random =
|
|
12
|
+
const random = randomBytes(RANDOM_LENGTH);
|
|
15
13
|
return ServerSecretParams.generateWithRandom(random);
|
|
16
14
|
}
|
|
17
15
|
static generateWithRandom(random) {
|
|
@@ -26,18 +24,17 @@ class ServerSecretParams {
|
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
26
|
getPublicParams() {
|
|
29
|
-
return new
|
|
27
|
+
return new ServerPublicParams(Native.ServerSecretParams_GetPublicParams(this));
|
|
30
28
|
}
|
|
31
29
|
sign(message) {
|
|
32
|
-
const random =
|
|
30
|
+
const random = randomBytes(RANDOM_LENGTH);
|
|
33
31
|
return this.signWithRandom(random, message);
|
|
34
32
|
}
|
|
35
33
|
signWithRandom(random, message) {
|
|
36
|
-
return new
|
|
34
|
+
return new NotarySignature(Native.ServerSecretParams_SignDeterministic(this, random, message));
|
|
37
35
|
}
|
|
38
36
|
serialize() {
|
|
39
37
|
return Native.ServerSecretParams_Serialize(this);
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
|
-
exports.default = ServerSecretParams;
|
|
43
40
|
//# sourceMappingURL=ServerSecretParams.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ByteArray from '../internal/ByteArray';
|
|
2
|
-
import UuidCiphertext from '../groups/UuidCiphertext';
|
|
1
|
+
import ByteArray from '../internal/ByteArray.js';
|
|
2
|
+
import UuidCiphertext from '../groups/UuidCiphertext.js';
|
|
3
3
|
export default class AuthCredentialPresentation extends ByteArray {
|
|
4
4
|
private readonly __type?;
|
|
5
5
|
constructor(contents: Uint8Array);
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
//
|
|
3
2
|
// Copyright 2020-2022 Signal Messenger, LLC.
|
|
4
3
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
4
|
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class AuthCredentialPresentation extends ByteArray_1.default {
|
|
5
|
+
import ByteArray from '../internal/ByteArray.js';
|
|
6
|
+
import Native from '../../../Native.js';
|
|
7
|
+
import UuidCiphertext from '../groups/UuidCiphertext.js';
|
|
8
|
+
export default class AuthCredentialPresentation extends ByteArray {
|
|
11
9
|
constructor(contents) {
|
|
12
10
|
super(contents, Native.AuthCredentialPresentation_CheckValidContents);
|
|
13
11
|
}
|
|
14
12
|
getUuidCiphertext() {
|
|
15
|
-
return new
|
|
13
|
+
return new UuidCiphertext(Native.AuthCredentialPresentation_GetUuidCiphertext(this.contents));
|
|
16
14
|
}
|
|
17
15
|
getPniCiphertext() {
|
|
18
|
-
return new
|
|
16
|
+
return new UuidCiphertext(Native.AuthCredentialPresentation_GetPniCiphertext(this.contents));
|
|
19
17
|
}
|
|
20
18
|
getRedemptionTime() {
|
|
21
19
|
return new Date(1000 * Native.AuthCredentialPresentation_GetRedemptionTime(this.contents));
|
|
22
20
|
}
|
|
23
21
|
}
|
|
24
|
-
exports.default = AuthCredentialPresentation;
|
|
25
22
|
//# sourceMappingURL=AuthCredentialPresentation.js.map
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
//
|
|
3
2
|
// Copyright 2022 Signal Messenger, LLC.
|
|
4
3
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
4
|
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class AuthCredentialWithPni extends ByteArray_1.default {
|
|
5
|
+
import ByteArray from '../internal/ByteArray.js';
|
|
6
|
+
import Native from '../../../Native.js';
|
|
7
|
+
export default class AuthCredentialWithPni extends ByteArray {
|
|
10
8
|
constructor(contents) {
|
|
11
9
|
super(contents, Native.AuthCredentialWithPni_CheckValidContents);
|
|
12
10
|
}
|
|
13
11
|
}
|
|
14
|
-
exports.default = AuthCredentialWithPni;
|
|
15
12
|
//# sourceMappingURL=AuthCredentialWithPni.js.map
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
//
|
|
3
2
|
// Copyright 2022 Signal Messenger, LLC.
|
|
4
3
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
4
|
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class AuthCredentialWithPniResponse extends ByteArray_1.default {
|
|
5
|
+
import ByteArray from '../internal/ByteArray.js';
|
|
6
|
+
import Native from '../../../Native.js';
|
|
7
|
+
export default class AuthCredentialWithPniResponse extends ByteArray {
|
|
10
8
|
constructor(contents) {
|
|
11
9
|
super(contents, Native.AuthCredentialWithPniResponse_CheckValidContents);
|
|
12
10
|
}
|
|
13
11
|
}
|
|
14
|
-
exports.default = AuthCredentialWithPniResponse;
|
|
15
12
|
//# sourceMappingURL=AuthCredentialWithPniResponse.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import ServerPublicParams from '../ServerPublicParams';
|
|
2
|
-
import AuthCredentialPresentation from './AuthCredentialPresentation';
|
|
3
|
-
import AuthCredentialWithPni from './AuthCredentialWithPni';
|
|
4
|
-
import AuthCredentialWithPniResponse from './AuthCredentialWithPniResponse';
|
|
5
|
-
import GroupSecretParams from '../groups/GroupSecretParams';
|
|
6
|
-
import { Aci, Pni } from '../../Address';
|
|
1
|
+
import ServerPublicParams from '../ServerPublicParams.js';
|
|
2
|
+
import AuthCredentialPresentation from './AuthCredentialPresentation.js';
|
|
3
|
+
import AuthCredentialWithPni from './AuthCredentialWithPni.js';
|
|
4
|
+
import AuthCredentialWithPniResponse from './AuthCredentialWithPniResponse.js';
|
|
5
|
+
import GroupSecretParams from '../groups/GroupSecretParams.js';
|
|
6
|
+
import { Aci, Pni } from '../../Address.js';
|
|
7
7
|
export default class ClientZkAuthOperations {
|
|
8
8
|
serverPublicParams: ServerPublicParams;
|
|
9
9
|
constructor(serverPublicParams: ServerPublicParams);
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
//
|
|
3
2
|
// Copyright 2020-2022 Signal Messenger, LLC.
|
|
4
3
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
4
|
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class ClientZkAuthOperations {
|
|
5
|
+
import { randomBytes } from 'node:crypto';
|
|
6
|
+
import Native from '../../../Native.js';
|
|
7
|
+
import { RANDOM_LENGTH } from '../internal/Constants.js';
|
|
8
|
+
import AuthCredentialPresentation from './AuthCredentialPresentation.js';
|
|
9
|
+
import AuthCredentialWithPni from './AuthCredentialWithPni.js';
|
|
10
|
+
export default class ClientZkAuthOperations {
|
|
13
11
|
constructor(serverPublicParams) {
|
|
14
12
|
this.serverPublicParams = serverPublicParams;
|
|
15
13
|
}
|
|
@@ -19,15 +17,14 @@ class ClientZkAuthOperations {
|
|
|
19
17
|
* @param redemptionTime - This is provided by the server as an integer, and should be passed through directly.
|
|
20
18
|
*/
|
|
21
19
|
receiveAuthCredentialWithPniAsServiceId(aci, pni, redemptionTime, authCredentialResponse) {
|
|
22
|
-
return new
|
|
20
|
+
return new AuthCredentialWithPni(Native.ServerPublicParams_ReceiveAuthCredentialWithPniAsServiceId(this.serverPublicParams, aci.getServiceIdFixedWidthBinary(), pni.getServiceIdFixedWidthBinary(), redemptionTime, authCredentialResponse.getContents()));
|
|
23
21
|
}
|
|
24
22
|
createAuthCredentialWithPniPresentation(groupSecretParams, authCredential) {
|
|
25
|
-
const random =
|
|
23
|
+
const random = randomBytes(RANDOM_LENGTH);
|
|
26
24
|
return this.createAuthCredentialWithPniPresentationWithRandom(random, groupSecretParams, authCredential);
|
|
27
25
|
}
|
|
28
26
|
createAuthCredentialWithPniPresentationWithRandom(random, groupSecretParams, authCredential) {
|
|
29
|
-
return new
|
|
27
|
+
return new AuthCredentialPresentation(Native.ServerPublicParams_CreateAuthCredentialWithPniPresentationDeterministic(this.serverPublicParams, random, groupSecretParams.getContents(), authCredential.getContents()));
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
|
-
exports.default = ClientZkAuthOperations;
|
|
33
30
|
//# sourceMappingURL=ClientZkAuthOperations.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import ServerSecretParams from '../ServerSecretParams';
|
|
2
|
-
import AuthCredentialPresentation from './AuthCredentialPresentation';
|
|
3
|
-
import AuthCredentialWithPniResponse from './AuthCredentialWithPniResponse';
|
|
4
|
-
import GroupPublicParams from '../groups/GroupPublicParams';
|
|
5
|
-
import { Aci, Pni } from '../../Address';
|
|
1
|
+
import ServerSecretParams from '../ServerSecretParams.js';
|
|
2
|
+
import AuthCredentialPresentation from './AuthCredentialPresentation.js';
|
|
3
|
+
import AuthCredentialWithPniResponse from './AuthCredentialWithPniResponse.js';
|
|
4
|
+
import GroupPublicParams from '../groups/GroupPublicParams.js';
|
|
5
|
+
import { Aci, Pni } from '../../Address.js';
|
|
6
6
|
export default class ServerZkAuthOperations {
|
|
7
7
|
serverSecretParams: ServerSecretParams;
|
|
8
8
|
constructor(serverSecretParams: ServerSecretParams);
|
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
//
|
|
3
2
|
// Copyright 2020-2022 Signal Messenger, LLC.
|
|
4
3
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
4
|
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class ServerZkAuthOperations {
|
|
5
|
+
import { randomBytes } from 'node:crypto';
|
|
6
|
+
import { RANDOM_LENGTH } from '../internal/Constants.js';
|
|
7
|
+
import Native from '../../../Native.js';
|
|
8
|
+
import AuthCredentialWithPniResponse from './AuthCredentialWithPniResponse.js';
|
|
9
|
+
export default class ServerZkAuthOperations {
|
|
12
10
|
constructor(serverSecretParams) {
|
|
13
11
|
this.serverSecretParams = serverSecretParams;
|
|
14
12
|
}
|
|
15
13
|
issueAuthCredentialWithPniZkc(aci, pni, redemptionTime) {
|
|
16
|
-
const random =
|
|
14
|
+
const random = randomBytes(RANDOM_LENGTH);
|
|
17
15
|
return this.issueAuthCredentialWithPniZkcWithRandom(random, aci, pni, redemptionTime);
|
|
18
16
|
}
|
|
19
17
|
issueAuthCredentialWithPniZkcWithRandom(random, aci, pni, redemptionTime) {
|
|
20
|
-
return new
|
|
18
|
+
return new AuthCredentialWithPniResponse(Native.ServerSecretParams_IssueAuthCredentialWithPniZkcDeterministic(this.serverSecretParams, random, aci.getServiceIdFixedWidthBinary(), pni.getServiceIdFixedWidthBinary(), redemptionTime));
|
|
21
19
|
}
|
|
22
20
|
verifyAuthCredentialPresentation(groupPublicParams, authCredentialPresentation, now = new Date()) {
|
|
23
21
|
Native.ServerSecretParams_VerifyAuthCredentialPresentation(this.serverSecretParams, groupPublicParams.getContents(), authCredentialPresentation.getContents(), Math.floor(now.getTime() / 1000));
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
|
-
exports.default = ServerZkAuthOperations;
|
|
27
24
|
//# sourceMappingURL=ServerZkAuthOperations.js.map
|