@signalapp/libsignal-client 0.76.6 → 0.77.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 +11 -3
- package/dist/AccountKeys.d.ts +11 -0
- package/dist/AccountKeys.js +14 -1
- package/dist/Errors.d.ts +18 -10
- package/dist/Errors.js +11 -9
- package/dist/MessageBackup.d.ts +4 -3
- package/dist/MessageBackup.js +5 -6
- package/dist/acknowledgments.md +2 -81
- package/dist/net/SvrB.d.ts +155 -0
- package/dist/net/SvrB.js +146 -0
- package/dist/net.d.ts +17 -0
- package/dist/net.js +22 -1
- package/package.json +1 -1
- 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/Native.d.ts
CHANGED
|
@@ -228,6 +228,9 @@ export function BackupKey_DeriveLocalBackupMetadataKey(backupKey: Uint8Array): U
|
|
|
228
228
|
export function BackupKey_DeriveMediaEncryptionKey(backupKey: Uint8Array, mediaId: Uint8Array): Uint8Array;
|
|
229
229
|
export function BackupKey_DeriveMediaId(backupKey: Uint8Array, mediaName: string): Uint8Array;
|
|
230
230
|
export function BackupKey_DeriveThumbnailTransitEncryptionKey(backupKey: Uint8Array, mediaId: Uint8Array): Uint8Array;
|
|
231
|
+
export function BackupResponse_GetForwardSecrecyToken(response: Wrapper<BackupResponse>): Uint8Array;
|
|
232
|
+
export function BackupResponse_GetNextBackupSecretData(response: Wrapper<BackupResponse>): Uint8Array;
|
|
233
|
+
export function BackupResponse_GetOpaqueMetadata(response: Wrapper<BackupResponse>): Uint8Array;
|
|
231
234
|
export function BridgedStringMap_insert(map: Wrapper<BridgedStringMap>, key: string, value: string): void;
|
|
232
235
|
export function BridgedStringMap_new(initialCapacity: number): BridgedStringMap;
|
|
233
236
|
export function CallLinkAuthCredentialPresentation_CheckValidContents(presentationBytes: Uint8Array): void;
|
|
@@ -373,8 +376,8 @@ export function LookupRequest_addE164(request: Wrapper<LookupRequest>, e164: str
|
|
|
373
376
|
export function LookupRequest_addPreviousE164(request: Wrapper<LookupRequest>, e164: string): void;
|
|
374
377
|
export function LookupRequest_new(): LookupRequest;
|
|
375
378
|
export function LookupRequest_setToken(request: Wrapper<LookupRequest>, token: Uint8Array): void;
|
|
376
|
-
export function MessageBackupKey_FromAccountEntropyPool(accountEntropy: AccountEntropyPool, aci: Uint8Array): MessageBackupKey;
|
|
377
|
-
export function MessageBackupKey_FromBackupKeyAndBackupId(backupKey: Uint8Array, backupId: Uint8Array): MessageBackupKey;
|
|
379
|
+
export function MessageBackupKey_FromAccountEntropyPool(accountEntropy: AccountEntropyPool, aci: Uint8Array, forwardSecrecyToken: Uint8Array | null): MessageBackupKey;
|
|
380
|
+
export function MessageBackupKey_FromBackupKeyAndBackupId(backupKey: Uint8Array, backupId: Uint8Array, forwardSecrecyToken: Uint8Array | null): MessageBackupKey;
|
|
378
381
|
export function MessageBackupKey_GetAesKey(key: Wrapper<MessageBackupKey>): Uint8Array;
|
|
379
382
|
export function MessageBackupKey_GetHmacKey(key: Wrapper<MessageBackupKey>): Uint8Array;
|
|
380
383
|
export function MessageBackupValidator_Validate(key: Wrapper<MessageBackupKey>, firstStream: InputStream, secondStream: InputStream, len: bigint, purpose: number): Promise<MessageBackupValidationOutcome>;
|
|
@@ -498,6 +501,9 @@ export function SealedSender_DecryptToUsmc(ctext: Uint8Array, identityStore: Ide
|
|
|
498
501
|
export function SealedSender_Encrypt(destination: Wrapper<ProtocolAddress>, content: Wrapper<UnidentifiedSenderMessageContent>, identityKeyStore: IdentityKeyStore): Promise<Uint8Array>;
|
|
499
502
|
export function SealedSender_MultiRecipientEncrypt(recipients: Wrapper<ProtocolAddress>[], recipientSessions: Wrapper<SessionRecord>[], excludedRecipients: Uint8Array, content: Wrapper<UnidentifiedSenderMessageContent>, identityKeyStore: IdentityKeyStore): Promise<Uint8Array>;
|
|
500
503
|
export function SealedSender_MultiRecipientMessageForSingleRecipient(encodedMultiRecipientMessage: Uint8Array): Uint8Array;
|
|
504
|
+
export function SecureValueRecoveryForBackups_CreateStoreArgs(backupKey: Uint8Array, previousSecretData: Uint8Array, environment: number): StoreArgs;
|
|
505
|
+
export function SecureValueRecoveryForBackups_RestoreBackupFromServer(asyncRuntime: Wrapper<TokioAsyncContext>, backupKey: Uint8Array, metadata: Uint8Array, connectionManager: Wrapper<ConnectionManager>, username: string, password: string): CancellablePromise<Uint8Array>;
|
|
506
|
+
export function SecureValueRecoveryForBackups_StoreBackup(asyncRuntime: Wrapper<TokioAsyncContext>, store: Wrapper<StoreArgs>, connectionManager: Wrapper<ConnectionManager>, username: string, password: string): CancellablePromise<BackupResponse>;
|
|
501
507
|
export function SenderCertificate_Deserialize(data: Uint8Array): SenderCertificate;
|
|
502
508
|
export function SenderCertificate_GetCertificate(obj: Wrapper<SenderCertificate>): Uint8Array;
|
|
503
509
|
export function SenderCertificate_GetDeviceId(obj: Wrapper<SenderCertificate>): number;
|
|
@@ -609,7 +615,7 @@ export function TESTING_ChatRequestGetPath(request: Wrapper<HttpRequest>): strin
|
|
|
609
615
|
export function TESTING_ChatResponseConvert(bodyPresent: boolean): ChatResponse;
|
|
610
616
|
export function TESTING_ChatSendErrorConvert(errorDescription: string): void;
|
|
611
617
|
export function TESTING_ConnectionManager_isUsingProxy(manager: Wrapper<ConnectionManager>): number;
|
|
612
|
-
export function TESTING_ConnectionManager_newLocalOverride(userAgent: string, chatPort: number, cdsiPort: number, svr2Port: number, rootCertificateDer: Uint8Array): ConnectionManager;
|
|
618
|
+
export function TESTING_ConnectionManager_newLocalOverride(userAgent: string, chatPort: number, cdsiPort: number, svr2Port: number, svrBPort: number, rootCertificateDer: Uint8Array): ConnectionManager;
|
|
613
619
|
export function TESTING_ConvertOptionalUuid(present: boolean): Uuid | null;
|
|
614
620
|
export function TESTING_ErrorOnBorrowAsync(_input: null): Promise<void>;
|
|
615
621
|
export function TESTING_ErrorOnBorrowIo(asyncRuntime: Wrapper<NonSuspendingBackgroundThreadRuntime>, _input: null): CancellablePromise<void>;
|
|
@@ -714,6 +720,7 @@ export function initLogger(maxLevel: LogLevel, callback: (level: LogLevel, targe
|
|
|
714
720
|
export function test_only_fn_returns_123(): number;
|
|
715
721
|
interface Aes256GcmSiv { readonly __type: unique symbol; }
|
|
716
722
|
interface AuthenticatedChatConnection { readonly __type: unique symbol; }
|
|
723
|
+
interface BackupResponse { readonly __type: unique symbol; }
|
|
717
724
|
interface BridgedStringMap { readonly __type: unique symbol; }
|
|
718
725
|
interface CdsiLookup { readonly __type: unique symbol; }
|
|
719
726
|
interface ChatConnectionInfo { readonly __type: unique symbol; }
|
|
@@ -782,6 +789,7 @@ interface SessionRecord { readonly __type: unique symbol; }
|
|
|
782
789
|
interface SgxClientState { readonly __type: unique symbol; }
|
|
783
790
|
interface SignalMessage { readonly __type: unique symbol; }
|
|
784
791
|
interface SignedPreKeyRecord { readonly __type: unique symbol; }
|
|
792
|
+
interface StoreArgs { readonly __type: unique symbol; }
|
|
785
793
|
interface TestingFutureCancellationCounter { readonly __type: unique symbol; }
|
|
786
794
|
interface TestingHandleType { readonly __type: unique symbol; }
|
|
787
795
|
interface TestingSemaphore { readonly __type: unique symbol; }
|
package/dist/AccountKeys.d.ts
CHANGED
|
@@ -99,3 +99,14 @@ export declare class BackupKey extends ByteArray {
|
|
|
99
99
|
*/
|
|
100
100
|
deriveThumbnailTransitEncryptionKey(mediaId: Uint8Array): Uint8Array;
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* A forward secrecy token used for deriving message backup keys.
|
|
104
|
+
*
|
|
105
|
+
* This token is retrieved from the server when restoring a backup and is used together
|
|
106
|
+
* with the backup key to derive the actual encryption keys for message backups.
|
|
107
|
+
*/
|
|
108
|
+
export declare class BackupForwardSecrecyToken extends ByteArray {
|
|
109
|
+
private readonly __type?;
|
|
110
|
+
static SIZE: number;
|
|
111
|
+
constructor(contents: Uint8Array);
|
|
112
|
+
}
|
package/dist/AccountKeys.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
5
|
//
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.BackupKey = exports.AccountEntropyPool = void 0;
|
|
7
|
+
exports.BackupForwardSecrecyToken = exports.BackupKey = exports.AccountEntropyPool = void 0;
|
|
8
8
|
/**
|
|
9
9
|
* Cryptographic hashing, randomness generation, etc. related to SVR/Backup Keys.
|
|
10
10
|
*
|
|
@@ -140,4 +140,17 @@ class BackupKey extends ByteArray_1.default {
|
|
|
140
140
|
}
|
|
141
141
|
exports.BackupKey = BackupKey;
|
|
142
142
|
BackupKey.SIZE = 32;
|
|
143
|
+
/**
|
|
144
|
+
* A forward secrecy token used for deriving message backup keys.
|
|
145
|
+
*
|
|
146
|
+
* This token is retrieved from the server when restoring a backup and is used together
|
|
147
|
+
* with the backup key to derive the actual encryption keys for message backups.
|
|
148
|
+
*/
|
|
149
|
+
class BackupForwardSecrecyToken extends ByteArray_1.default {
|
|
150
|
+
constructor(contents) {
|
|
151
|
+
super(contents, BackupForwardSecrecyToken.checkLength(BackupForwardSecrecyToken.SIZE));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.BackupForwardSecrecyToken = BackupForwardSecrecyToken;
|
|
155
|
+
BackupForwardSecrecyToken.SIZE = 32;
|
|
143
156
|
//# sourceMappingURL=AccountKeys.js.map
|
package/dist/Errors.d.ts
CHANGED
|
@@ -35,15 +35,17 @@ export declare enum ErrorCode {
|
|
|
35
35
|
SvrDataMissing = 31,
|
|
36
36
|
SvrRequestFailed = 32,
|
|
37
37
|
SvrRestoreFailed = 33,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
SvrMultipleErrors = 34,
|
|
39
|
+
SvrAttestationError = 35,
|
|
40
|
+
ChatServiceInactive = 36,
|
|
41
|
+
AppExpired = 37,
|
|
42
|
+
DeviceDelinked = 38,
|
|
43
|
+
ConnectionInvalidated = 39,
|
|
44
|
+
ConnectedElsewhere = 40,
|
|
45
|
+
BackupValidation = 41,
|
|
46
|
+
Cancelled = 42,
|
|
47
|
+
KeyTransparencyError = 43,
|
|
48
|
+
KeyTransparencyVerificationFailed = 44
|
|
47
49
|
}
|
|
48
50
|
export declare class LibSignalErrorBase extends Error {
|
|
49
51
|
readonly code: ErrorCode;
|
|
@@ -186,6 +188,12 @@ export type SvrRestoreFailedError = LibSignalErrorCommon & {
|
|
|
186
188
|
code: ErrorCode.SvrRestoreFailed;
|
|
187
189
|
readonly triesRemaining: number;
|
|
188
190
|
};
|
|
191
|
+
export type SvrMultipleErrorsError = LibSignalErrorCommon & {
|
|
192
|
+
code: ErrorCode.SvrMultipleErrors;
|
|
193
|
+
};
|
|
194
|
+
export type SvrAttestationError = LibSignalErrorCommon & {
|
|
195
|
+
code: ErrorCode.SvrAttestationError;
|
|
196
|
+
};
|
|
189
197
|
export type BackupValidationError = LibSignalErrorCommon & {
|
|
190
198
|
code: ErrorCode.BackupValidation;
|
|
191
199
|
readonly unknownFields: ReadonlyArray<string>;
|
|
@@ -199,4 +207,4 @@ export type KeyTransparencyError = LibSignalErrorCommon & {
|
|
|
199
207
|
export type KeyTransparencyVerificationFailed = LibSignalErrorCommon & {
|
|
200
208
|
code: ErrorCode.KeyTransparencyVerificationFailed;
|
|
201
209
|
};
|
|
202
|
-
export type LibSignalError = GenericError | DuplicatedMessageError | SealedSenderSelfSendError | UntrustedIdentityError | InvalidRegistrationIdError | InvalidProtocolAddress | VerificationFailedError | InvalidSessionError | InvalidSenderKeySessionError | NicknameCannotBeEmptyError | CannotStartWithDigitError | MissingSeparatorError | BadNicknameCharacterError | NicknameTooShortError | NicknameTooLongError | DiscriminatorCannotBeEmptyError | DiscriminatorCannotBeZeroError | DiscriminatorCannotBeSingleDigitError | DiscriminatorCannotHaveLeadingZerosError | BadDiscriminatorCharacterError | DiscriminatorTooLargeError | InputDataTooLong | InvalidEntropyDataLength | InvalidUsernameLinkEncryptedData | IoError | CdsiInvalidTokenError | InvalidUriError | InvalidMediaInputError | SvrDataMissingError | SvrRestoreFailedError | SvrRequestFailedError | UnsupportedMediaInputError | ChatServiceInactive | AppExpiredError | DeviceDelinkedError | ConnectionInvalidatedError | ConnectedElsewhereError | RateLimitedError | RateLimitChallengeError | BackupValidationError | CancellationError | KeyTransparencyError | KeyTransparencyVerificationFailed;
|
|
210
|
+
export type LibSignalError = GenericError | DuplicatedMessageError | SealedSenderSelfSendError | UntrustedIdentityError | InvalidRegistrationIdError | InvalidProtocolAddress | VerificationFailedError | InvalidSessionError | InvalidSenderKeySessionError | NicknameCannotBeEmptyError | CannotStartWithDigitError | MissingSeparatorError | BadNicknameCharacterError | NicknameTooShortError | NicknameTooLongError | DiscriminatorCannotBeEmptyError | DiscriminatorCannotBeZeroError | DiscriminatorCannotBeSingleDigitError | DiscriminatorCannotHaveLeadingZerosError | BadDiscriminatorCharacterError | DiscriminatorTooLargeError | InputDataTooLong | InvalidEntropyDataLength | InvalidUsernameLinkEncryptedData | IoError | CdsiInvalidTokenError | InvalidUriError | InvalidMediaInputError | SvrDataMissingError | SvrRestoreFailedError | SvrRequestFailedError | SvrMultipleErrorsError | SvrAttestationError | UnsupportedMediaInputError | ChatServiceInactive | AppExpiredError | DeviceDelinkedError | ConnectionInvalidatedError | ConnectedElsewhereError | RateLimitedError | RateLimitChallengeError | BackupValidationError | CancellationError | KeyTransparencyError | KeyTransparencyVerificationFailed;
|
package/dist/Errors.js
CHANGED
|
@@ -42,15 +42,17 @@ var ErrorCode;
|
|
|
42
42
|
ErrorCode[ErrorCode["SvrDataMissing"] = 31] = "SvrDataMissing";
|
|
43
43
|
ErrorCode[ErrorCode["SvrRequestFailed"] = 32] = "SvrRequestFailed";
|
|
44
44
|
ErrorCode[ErrorCode["SvrRestoreFailed"] = 33] = "SvrRestoreFailed";
|
|
45
|
-
ErrorCode[ErrorCode["
|
|
46
|
-
ErrorCode[ErrorCode["
|
|
47
|
-
ErrorCode[ErrorCode["
|
|
48
|
-
ErrorCode[ErrorCode["
|
|
49
|
-
ErrorCode[ErrorCode["
|
|
50
|
-
ErrorCode[ErrorCode["
|
|
51
|
-
ErrorCode[ErrorCode["
|
|
52
|
-
ErrorCode[ErrorCode["
|
|
53
|
-
ErrorCode[ErrorCode["
|
|
45
|
+
ErrorCode[ErrorCode["SvrMultipleErrors"] = 34] = "SvrMultipleErrors";
|
|
46
|
+
ErrorCode[ErrorCode["SvrAttestationError"] = 35] = "SvrAttestationError";
|
|
47
|
+
ErrorCode[ErrorCode["ChatServiceInactive"] = 36] = "ChatServiceInactive";
|
|
48
|
+
ErrorCode[ErrorCode["AppExpired"] = 37] = "AppExpired";
|
|
49
|
+
ErrorCode[ErrorCode["DeviceDelinked"] = 38] = "DeviceDelinked";
|
|
50
|
+
ErrorCode[ErrorCode["ConnectionInvalidated"] = 39] = "ConnectionInvalidated";
|
|
51
|
+
ErrorCode[ErrorCode["ConnectedElsewhere"] = 40] = "ConnectedElsewhere";
|
|
52
|
+
ErrorCode[ErrorCode["BackupValidation"] = 41] = "BackupValidation";
|
|
53
|
+
ErrorCode[ErrorCode["Cancelled"] = 42] = "Cancelled";
|
|
54
|
+
ErrorCode[ErrorCode["KeyTransparencyError"] = 43] = "KeyTransparencyError";
|
|
55
|
+
ErrorCode[ErrorCode["KeyTransparencyVerificationFailed"] = 44] = "KeyTransparencyVerificationFailed";
|
|
54
56
|
})(ErrorCode || (exports.ErrorCode = ErrorCode = {}));
|
|
55
57
|
class LibSignalErrorBase extends Error {
|
|
56
58
|
constructor(message, name, operation, extraProps) {
|
package/dist/MessageBackup.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @module MessageBackup
|
|
5
5
|
*/
|
|
6
6
|
import * as Native from '../Native';
|
|
7
|
-
import { BackupKey } from './AccountKeys';
|
|
7
|
+
import { BackupForwardSecrecyToken, BackupKey } from './AccountKeys';
|
|
8
8
|
import { Aci } from './Address';
|
|
9
9
|
import { InputStream } from './io';
|
|
10
10
|
export type InputStreamFactory = () => InputStream;
|
|
@@ -32,9 +32,11 @@ export declare class ValidationOutcome {
|
|
|
32
32
|
export type MessageBackupKeyInput = Readonly<{
|
|
33
33
|
accountEntropy: string;
|
|
34
34
|
aci: Aci;
|
|
35
|
+
forwardSecrecyToken?: BackupForwardSecrecyToken;
|
|
35
36
|
} | {
|
|
36
37
|
backupKey: BackupKey | Uint8Array;
|
|
37
38
|
backupId: Uint8Array;
|
|
39
|
+
forwardSecrecyToken?: BackupForwardSecrecyToken;
|
|
38
40
|
}>;
|
|
39
41
|
/**
|
|
40
42
|
* Key used to encrypt and decrypt a message backup bundle.
|
|
@@ -47,8 +49,7 @@ export declare class MessageBackupKey {
|
|
|
47
49
|
* Create a backup bundle key from an account entropy pool and ACI.
|
|
48
50
|
*
|
|
49
51
|
* ...or from a backup key and ID, used when reading from a local backup, which may have been
|
|
50
|
-
* created with a different ACI.
|
|
51
|
-
* cannot be used to read a backup created from a master key.
|
|
52
|
+
* created with a different ACI.
|
|
52
53
|
*
|
|
53
54
|
* The account entropy pool must be **validated**; passing an arbitrary string here is considered
|
|
54
55
|
* a programmer error. Similarly, passing a backup key or ID of the wrong length is also an error.
|
package/dist/MessageBackup.js
CHANGED
|
@@ -41,24 +41,23 @@ class MessageBackupKey {
|
|
|
41
41
|
* Create a backup bundle key from an account entropy pool and ACI.
|
|
42
42
|
*
|
|
43
43
|
* ...or from a backup key and ID, used when reading from a local backup, which may have been
|
|
44
|
-
* created with a different ACI.
|
|
45
|
-
* cannot be used to read a backup created from a master key.
|
|
44
|
+
* created with a different ACI.
|
|
46
45
|
*
|
|
47
46
|
* The account entropy pool must be **validated**; passing an arbitrary string here is considered
|
|
48
47
|
* a programmer error. Similarly, passing a backup key or ID of the wrong length is also an error.
|
|
49
48
|
*/
|
|
50
49
|
constructor(input) {
|
|
51
50
|
if ('accountEntropy' in input) {
|
|
52
|
-
const { accountEntropy, aci } = input;
|
|
53
|
-
this._nativeHandle = Native.MessageBackupKey_FromAccountEntropyPool(accountEntropy, aci.getServiceIdFixedWidthBinary());
|
|
51
|
+
const { accountEntropy, aci, forwardSecrecyToken } = input;
|
|
52
|
+
this._nativeHandle = Native.MessageBackupKey_FromAccountEntropyPool(accountEntropy, aci.getServiceIdFixedWidthBinary(), forwardSecrecyToken?.contents ?? null);
|
|
54
53
|
}
|
|
55
54
|
else {
|
|
56
|
-
const { backupId } = input;
|
|
55
|
+
const { backupId, forwardSecrecyToken } = input;
|
|
57
56
|
let { backupKey } = input;
|
|
58
57
|
if (backupKey instanceof AccountKeys_1.BackupKey) {
|
|
59
58
|
backupKey = backupKey.contents;
|
|
60
59
|
}
|
|
61
|
-
this._nativeHandle = Native.MessageBackupKey_FromBackupKeyAndBackupId(backupKey, backupId);
|
|
60
|
+
this._nativeHandle = Native.MessageBackupKey_FromBackupKeyAndBackupId(backupKey, backupId, forwardSecrecyToken?.contents ?? null);
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
63
|
/** An HMAC key used to sign a backup file. */
|
package/dist/acknowledgments.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
libsignal makes use of the following open source projects.
|
|
4
4
|
|
|
5
|
-
## spqr
|
|
5
|
+
## spqr 1.2.0, partial-default-derive 0.1.0, partial-default 0.1.0
|
|
6
6
|
|
|
7
7
|
```
|
|
8
8
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
|
@@ -2007,7 +2007,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
2007
2007
|
|
|
2008
2008
|
```
|
|
2009
2009
|
|
|
2010
|
-
## libcrux-intrinsics 0.0.2, libcrux-intrinsics 0.0.3, libcrux-ml-kem 0.0.2, libcrux-platform 0.0.2, libcrux-sha3 0.0.2, libcrux-sha3 0.0.3
|
|
2010
|
+
## libcrux-hacl-rs 0.0.2, libcrux-hkdf 0.0.2, libcrux-hmac 0.0.2, libcrux-intrinsics 0.0.2, libcrux-intrinsics 0.0.3, libcrux-macros 0.0.2, libcrux-ml-kem 0.0.2, libcrux-platform 0.0.2, libcrux-sha2 0.0.2, libcrux-sha3 0.0.2, libcrux-sha3 0.0.3, libcrux-traits 0.0.2
|
|
2011
2011
|
|
|
2012
2012
|
```
|
|
2013
2013
|
Apache License
|
|
@@ -2591,85 +2591,6 @@ limitations under the License.
|
|
|
2591
2591
|
|
|
2592
2592
|
```
|
|
2593
2593
|
|
|
2594
|
-
## libcrux-hacl-rs 0.0.2, libcrux-hkdf 0.0.2, libcrux-hmac 0.0.2, libcrux-macros 0.0.2, libcrux-sha2 0.0.2, libcrux-traits 0.0.2
|
|
2595
|
-
|
|
2596
|
-
```
|
|
2597
|
-
Apache License
|
|
2598
|
-
Version 2.0, January 2004
|
|
2599
|
-
http://www.apache.org/licenses/
|
|
2600
|
-
|
|
2601
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
2602
|
-
|
|
2603
|
-
1. Definitions.
|
|
2604
|
-
|
|
2605
|
-
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
2606
|
-
|
|
2607
|
-
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
2608
|
-
|
|
2609
|
-
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
2610
|
-
|
|
2611
|
-
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
2612
|
-
|
|
2613
|
-
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
2614
|
-
|
|
2615
|
-
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
2616
|
-
|
|
2617
|
-
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
2618
|
-
|
|
2619
|
-
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
2620
|
-
|
|
2621
|
-
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
2622
|
-
|
|
2623
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
2624
|
-
|
|
2625
|
-
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
2626
|
-
|
|
2627
|
-
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
2628
|
-
|
|
2629
|
-
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
2630
|
-
|
|
2631
|
-
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
2632
|
-
|
|
2633
|
-
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
2634
|
-
|
|
2635
|
-
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
2636
|
-
|
|
2637
|
-
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
2638
|
-
|
|
2639
|
-
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
2640
|
-
|
|
2641
|
-
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
2642
|
-
|
|
2643
|
-
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
2644
|
-
|
|
2645
|
-
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
2646
|
-
|
|
2647
|
-
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
2648
|
-
|
|
2649
|
-
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
2650
|
-
|
|
2651
|
-
END OF TERMS AND CONDITIONS
|
|
2652
|
-
|
|
2653
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
2654
|
-
|
|
2655
|
-
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
|
2656
|
-
|
|
2657
|
-
Copyright [yyyy] [name of copyright owner]
|
|
2658
|
-
|
|
2659
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
2660
|
-
you may not use this file except in compliance with the License.
|
|
2661
|
-
You may obtain a copy of the License at
|
|
2662
|
-
|
|
2663
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
2664
|
-
|
|
2665
|
-
Unless required by applicable law or agreed to in writing, software
|
|
2666
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
2667
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2668
|
-
See the License for the specific language governing permissions and
|
|
2669
|
-
limitations under the License.
|
|
2670
|
-
|
|
2671
|
-
```
|
|
2672
|
-
|
|
2673
2594
|
## boring 4.15.0
|
|
2674
2595
|
|
|
2675
2596
|
```
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import * as Native from '../../Native';
|
|
2
|
+
import { TokioAsyncContext, Environment } from '../net';
|
|
3
|
+
import { BackupKey, BackupForwardSecrecyToken } from '../AccountKeys';
|
|
4
|
+
type ConnectionManager = Native.Wrapper<Native.ConnectionManager>;
|
|
5
|
+
/**
|
|
6
|
+
* The result of preparing a backup to be stored with forward secrecy guarantees.
|
|
7
|
+
*
|
|
8
|
+
* This context contains all the necessary components to encrypt and store a backup using a
|
|
9
|
+
* key derived from both the user's Account Entropy Pool and the SVR-B-protected
|
|
10
|
+
* Forward Secrecy Token.
|
|
11
|
+
*
|
|
12
|
+
* @see {@link BackupForwardSecrecyToken}
|
|
13
|
+
*/
|
|
14
|
+
export type StoreBackupResponse = {
|
|
15
|
+
/**
|
|
16
|
+
* The forward secrecy token used to derive MessageBackupKey instances.
|
|
17
|
+
*
|
|
18
|
+
* This token provides forward secrecy guarantees by ensuring that compromise of the backup key
|
|
19
|
+
* alone is insufficient to decrypt backups. Each backup is protected by a value stored on
|
|
20
|
+
* the SVR-B server that must be retrieved during restoration.
|
|
21
|
+
*/
|
|
22
|
+
forwardSecrecyToken: BackupForwardSecrecyToken;
|
|
23
|
+
/**
|
|
24
|
+
* Opaque metadata that must be stored in the backup file.
|
|
25
|
+
*
|
|
26
|
+
* This metadata contains the encrypted forward secrecy token and other information required
|
|
27
|
+
* to restore the backup. It must be retrievable when restoring the backup, as it's required
|
|
28
|
+
* to fetch the forward secrecy token from SVR-B. This is currently stored in the header of
|
|
29
|
+
* the backup file.
|
|
30
|
+
*/
|
|
31
|
+
metadata: Uint8Array;
|
|
32
|
+
/**
|
|
33
|
+
* Opaque value that must be persisted and provided to the next call to {@link SvrB#storeBackup}.
|
|
34
|
+
*
|
|
35
|
+
* See the {@link SvrB} documentation for lifecycle and persistence handling
|
|
36
|
+
* for this value.
|
|
37
|
+
*/
|
|
38
|
+
nextBackupSecretData: Uint8Array;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Service for Secure Value Recovery for Backups (SVR-B) operations.
|
|
42
|
+
*
|
|
43
|
+
* This service provides forward secrecy for Signal backups using SVR-B. Forward secrecy ensures
|
|
44
|
+
* that even if the user's Account Entropy Pool or Backup Key is compromised, the attacker can
|
|
45
|
+
* decrypt a very small number of past backups. This is achieved by storing a token
|
|
46
|
+
* in a secure enclave inside the SVR-B server, which provably attests that it
|
|
47
|
+
* only stores a single token at a time for each user.
|
|
48
|
+
*
|
|
49
|
+
* ## Overview
|
|
50
|
+
*
|
|
51
|
+
* To achieve these properties, a secret token is required to derive the actual encryption
|
|
52
|
+
* keys for the backup. At backup time, this token must be stored in the SVR-B server, overwriting the
|
|
53
|
+
* previous token. At restore time, the token must be retrieved from the SVR-B server, and used to
|
|
54
|
+
* derive the encryption keys for the backup.
|
|
55
|
+
*
|
|
56
|
+
* ## Storage Flow
|
|
57
|
+
*
|
|
58
|
+
* 1. Create a {@link Net} instance and get the {@link SvrB} service via {@link Net#svrB}
|
|
59
|
+
* 2. Call {@link SvrB#storeBackup}
|
|
60
|
+
* - Pass the secret data from the last **successful** {@link SvrB#storeBackup} call
|
|
61
|
+
* - If no previous backup exists or the secret data is unavailable, pass `undefined`
|
|
62
|
+
* 3. Use the returned forward secrecy token to derive encryption keys
|
|
63
|
+
* 4. Encrypt and upload the backup data to the user's remote, off-device storage location, including the
|
|
64
|
+
* returned {@link StoreBackupResponse#metadata}. The upload **must succeed**
|
|
65
|
+
* before proceeding or the previous backup might become unretrievable.
|
|
66
|
+
* 5. Store the {@link StoreBackupResponse#nextBackupSecretData} locally, overwriting any previously-saved value.
|
|
67
|
+
*
|
|
68
|
+
* ## Secret handling
|
|
69
|
+
*
|
|
70
|
+
* When calling {@link SvrB#storeBackup}, the `previousSecretData` parameter
|
|
71
|
+
* must be from the last call to {@link SvrB#storeBackup} that
|
|
72
|
+
* succeeded. The returned secret from a successful `storeBackup()` call should
|
|
73
|
+
* be persisted until it is overwritten by the value from a subsequent
|
|
74
|
+
* successful call. The caller should pass `undefined` as `previousSecretData`
|
|
75
|
+
* only for the very first backup from a device.
|
|
76
|
+
*
|
|
77
|
+
* ## Restore Flow
|
|
78
|
+
*
|
|
79
|
+
* 1. Create a {@link Net} instance and get the {@link SvrB} service via {@link Net#svrB}
|
|
80
|
+
* 2. Fetch the backup metadata from storage
|
|
81
|
+
* 3. Call {@link SvrB#fetchForwardSecrecyTokenFromServer} to get the forward secrecy token
|
|
82
|
+
* 4. Use the token to derive decryption keys
|
|
83
|
+
* 5. Decrypt and restore the backup data
|
|
84
|
+
*
|
|
85
|
+
* ## Usage
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const net = new Net({ env: Environment.Production, userAgent: 'MyApp' });
|
|
88
|
+
* const auth = { username: 'myUsername', password: 'myPassword' };
|
|
89
|
+
* const svrB = net.svrB(auth);
|
|
90
|
+
*
|
|
91
|
+
* // Prepare a backup
|
|
92
|
+
* const stored = await svrB.storeBackup(myKey, previousSecretData);
|
|
93
|
+
* // ... store backup with stored.forwardSecrecyToken remotely ...
|
|
94
|
+
* // Securely persist stored.nextBackupSecretData for the next backup
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @see {@link BackupKey}, {@link MessageBackupKey}, {@link BackupForwardSecrecyToken}
|
|
98
|
+
*/
|
|
99
|
+
export declare class SvrB {
|
|
100
|
+
private readonly asyncContext;
|
|
101
|
+
private readonly connectionManager;
|
|
102
|
+
private readonly auth;
|
|
103
|
+
private readonly environment;
|
|
104
|
+
constructor(asyncContext: TokioAsyncContext, connectionManager: ConnectionManager, auth: Readonly<{
|
|
105
|
+
username: string;
|
|
106
|
+
password: string;
|
|
107
|
+
}>, environment: Environment);
|
|
108
|
+
/**
|
|
109
|
+
* Prepares a backup for storage with forward secrecy guarantees.
|
|
110
|
+
*
|
|
111
|
+
* This makes a network call to the SVR-B server to store the forward secrecy token
|
|
112
|
+
* and returns a {@link StoreBackupResponse}. See its fields' documentation and {@link SvrB}
|
|
113
|
+
* for how to continue persisting the backup on success.
|
|
114
|
+
*
|
|
115
|
+
* @param backupKey The backup key derived from the Account Entropy Pool (AEP).
|
|
116
|
+
* @param previousSecretData Optional secret data from the most recent previous backup.
|
|
117
|
+
* **Critical**: This MUST be the {@link StoreBackupResponse#nextBackupSecretData} data
|
|
118
|
+
* from the last {@link #storeBackup} whose returned {@link StoreBackupResponse#metadata} was
|
|
119
|
+
* successfully uploaded, and whose `nextBackupSecretData` was persisted.
|
|
120
|
+
* If `undefined`, starts a new chain and renders any prior backups unretrievable; this should
|
|
121
|
+
* only be used for the very first backup from a device.
|
|
122
|
+
* @param options Optional configuration.
|
|
123
|
+
* @param options.abortSignal An AbortSignal that will cancel the request.
|
|
124
|
+
* @returns a {@link StoreBackupResponse} containing the forward secrecy token, metadata, and secret data.
|
|
125
|
+
* @throws Error if the previous secret data is malformed, or if processing or upload fail.
|
|
126
|
+
*/
|
|
127
|
+
storeBackup(backupKey: BackupKey, previousSecretData?: Uint8Array, options?: {
|
|
128
|
+
abortSignal?: AbortSignal;
|
|
129
|
+
}): Promise<StoreBackupResponse>;
|
|
130
|
+
/**
|
|
131
|
+
* Fetches the forward secrecy token needed to decrypt a backup.
|
|
132
|
+
*
|
|
133
|
+
* This function makes a network call to the SVR-B server to retrieve the forward secrecy token
|
|
134
|
+
* associated with a specific backup. The token is required to derive the message backup keys
|
|
135
|
+
* for decryption.
|
|
136
|
+
*
|
|
137
|
+
* The typical restore flow:
|
|
138
|
+
* 1. Fetch the backup metadata (stored in a header in the backup file)
|
|
139
|
+
* 2. Call this function to retrieve the forward secrecy token from SVR-B
|
|
140
|
+
* 3. Use the token to derive message backup keys
|
|
141
|
+
* 4. Decrypt and restore the backup data
|
|
142
|
+
*
|
|
143
|
+
* @param backupKey The backup key derived from the Account Entropy Pool (AEP).
|
|
144
|
+
* @param metadata The metadata that was stored in a header in the backup file during backup creation.
|
|
145
|
+
* @param options Optional configuration.
|
|
146
|
+
* @param options.abortSignal An AbortSignal that will cancel the request.
|
|
147
|
+
* @returns The forward secrecy token needed to derive keys for decrypting the backup.
|
|
148
|
+
* @throws Error if the metadata is invalid, the network operation fails, or the
|
|
149
|
+
* backup cannot be found.
|
|
150
|
+
*/
|
|
151
|
+
fetchForwardSecrecyTokenFromServer(backupKey: BackupKey, metadata: Uint8Array, options?: {
|
|
152
|
+
abortSignal?: AbortSignal;
|
|
153
|
+
}): Promise<BackupForwardSecrecyToken>;
|
|
154
|
+
}
|
|
155
|
+
export {};
|
package/dist/net/SvrB.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//
|
|
3
|
+
// Copyright 2025 Signal Messenger, LLC.
|
|
4
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
|
+
//
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.SvrB = void 0;
|
|
8
|
+
const Native = require("../../Native");
|
|
9
|
+
const AccountKeys_1 = require("../AccountKeys");
|
|
10
|
+
const internal_1 = require("../internal");
|
|
11
|
+
class StoreBackupResponseImpl {
|
|
12
|
+
constructor(handle) {
|
|
13
|
+
this._nativeHandle = handle;
|
|
14
|
+
}
|
|
15
|
+
get forwardSecrecyToken() {
|
|
16
|
+
const tokenBytes = Native.BackupResponse_GetForwardSecrecyToken(this);
|
|
17
|
+
return new AccountKeys_1.BackupForwardSecrecyToken(tokenBytes);
|
|
18
|
+
}
|
|
19
|
+
get metadata() {
|
|
20
|
+
return Native.BackupResponse_GetOpaqueMetadata(this);
|
|
21
|
+
}
|
|
22
|
+
get nextBackupSecretData() {
|
|
23
|
+
return Native.BackupResponse_GetNextBackupSecretData(this);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Service for Secure Value Recovery for Backups (SVR-B) operations.
|
|
28
|
+
*
|
|
29
|
+
* This service provides forward secrecy for Signal backups using SVR-B. Forward secrecy ensures
|
|
30
|
+
* that even if the user's Account Entropy Pool or Backup Key is compromised, the attacker can
|
|
31
|
+
* decrypt a very small number of past backups. This is achieved by storing a token
|
|
32
|
+
* in a secure enclave inside the SVR-B server, which provably attests that it
|
|
33
|
+
* only stores a single token at a time for each user.
|
|
34
|
+
*
|
|
35
|
+
* ## Overview
|
|
36
|
+
*
|
|
37
|
+
* To achieve these properties, a secret token is required to derive the actual encryption
|
|
38
|
+
* keys for the backup. At backup time, this token must be stored in the SVR-B server, overwriting the
|
|
39
|
+
* previous token. At restore time, the token must be retrieved from the SVR-B server, and used to
|
|
40
|
+
* derive the encryption keys for the backup.
|
|
41
|
+
*
|
|
42
|
+
* ## Storage Flow
|
|
43
|
+
*
|
|
44
|
+
* 1. Create a {@link Net} instance and get the {@link SvrB} service via {@link Net#svrB}
|
|
45
|
+
* 2. Call {@link SvrB#storeBackup}
|
|
46
|
+
* - Pass the secret data from the last **successful** {@link SvrB#storeBackup} call
|
|
47
|
+
* - If no previous backup exists or the secret data is unavailable, pass `undefined`
|
|
48
|
+
* 3. Use the returned forward secrecy token to derive encryption keys
|
|
49
|
+
* 4. Encrypt and upload the backup data to the user's remote, off-device storage location, including the
|
|
50
|
+
* returned {@link StoreBackupResponse#metadata}. The upload **must succeed**
|
|
51
|
+
* before proceeding or the previous backup might become unretrievable.
|
|
52
|
+
* 5. Store the {@link StoreBackupResponse#nextBackupSecretData} locally, overwriting any previously-saved value.
|
|
53
|
+
*
|
|
54
|
+
* ## Secret handling
|
|
55
|
+
*
|
|
56
|
+
* When calling {@link SvrB#storeBackup}, the `previousSecretData` parameter
|
|
57
|
+
* must be from the last call to {@link SvrB#storeBackup} that
|
|
58
|
+
* succeeded. The returned secret from a successful `storeBackup()` call should
|
|
59
|
+
* be persisted until it is overwritten by the value from a subsequent
|
|
60
|
+
* successful call. The caller should pass `undefined` as `previousSecretData`
|
|
61
|
+
* only for the very first backup from a device.
|
|
62
|
+
*
|
|
63
|
+
* ## Restore Flow
|
|
64
|
+
*
|
|
65
|
+
* 1. Create a {@link Net} instance and get the {@link SvrB} service via {@link Net#svrB}
|
|
66
|
+
* 2. Fetch the backup metadata from storage
|
|
67
|
+
* 3. Call {@link SvrB#fetchForwardSecrecyTokenFromServer} to get the forward secrecy token
|
|
68
|
+
* 4. Use the token to derive decryption keys
|
|
69
|
+
* 5. Decrypt and restore the backup data
|
|
70
|
+
*
|
|
71
|
+
* ## Usage
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const net = new Net({ env: Environment.Production, userAgent: 'MyApp' });
|
|
74
|
+
* const auth = { username: 'myUsername', password: 'myPassword' };
|
|
75
|
+
* const svrB = net.svrB(auth);
|
|
76
|
+
*
|
|
77
|
+
* // Prepare a backup
|
|
78
|
+
* const stored = await svrB.storeBackup(myKey, previousSecretData);
|
|
79
|
+
* // ... store backup with stored.forwardSecrecyToken remotely ...
|
|
80
|
+
* // Securely persist stored.nextBackupSecretData for the next backup
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @see {@link BackupKey}, {@link MessageBackupKey}, {@link BackupForwardSecrecyToken}
|
|
84
|
+
*/
|
|
85
|
+
class SvrB {
|
|
86
|
+
constructor(asyncContext, connectionManager, auth, environment) {
|
|
87
|
+
this.asyncContext = asyncContext;
|
|
88
|
+
this.connectionManager = connectionManager;
|
|
89
|
+
this.auth = auth;
|
|
90
|
+
this.environment = environment;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Prepares a backup for storage with forward secrecy guarantees.
|
|
94
|
+
*
|
|
95
|
+
* This makes a network call to the SVR-B server to store the forward secrecy token
|
|
96
|
+
* and returns a {@link StoreBackupResponse}. See its fields' documentation and {@link SvrB}
|
|
97
|
+
* for how to continue persisting the backup on success.
|
|
98
|
+
*
|
|
99
|
+
* @param backupKey The backup key derived from the Account Entropy Pool (AEP).
|
|
100
|
+
* @param previousSecretData Optional secret data from the most recent previous backup.
|
|
101
|
+
* **Critical**: This MUST be the {@link StoreBackupResponse#nextBackupSecretData} data
|
|
102
|
+
* from the last {@link #storeBackup} whose returned {@link StoreBackupResponse#metadata} was
|
|
103
|
+
* successfully uploaded, and whose `nextBackupSecretData` was persisted.
|
|
104
|
+
* If `undefined`, starts a new chain and renders any prior backups unretrievable; this should
|
|
105
|
+
* only be used for the very first backup from a device.
|
|
106
|
+
* @param options Optional configuration.
|
|
107
|
+
* @param options.abortSignal An AbortSignal that will cancel the request.
|
|
108
|
+
* @returns a {@link StoreBackupResponse} containing the forward secrecy token, metadata, and secret data.
|
|
109
|
+
* @throws Error if the previous secret data is malformed, or if processing or upload fail.
|
|
110
|
+
*/
|
|
111
|
+
async storeBackup(backupKey, previousSecretData, options) {
|
|
112
|
+
const secretData = previousSecretData ?? new Uint8Array(0);
|
|
113
|
+
const handle = (0, internal_1.newNativeHandle)(Native.SecureValueRecoveryForBackups_CreateStoreArgs(backupKey.serialize(), secretData, this.environment));
|
|
114
|
+
const promise = Native.SecureValueRecoveryForBackups_StoreBackup(this.asyncContext, handle, this.connectionManager, this.auth.username, this.auth.password);
|
|
115
|
+
const response = await this.asyncContext.makeCancellable(options?.abortSignal, promise);
|
|
116
|
+
return new StoreBackupResponseImpl(response);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Fetches the forward secrecy token needed to decrypt a backup.
|
|
120
|
+
*
|
|
121
|
+
* This function makes a network call to the SVR-B server to retrieve the forward secrecy token
|
|
122
|
+
* associated with a specific backup. The token is required to derive the message backup keys
|
|
123
|
+
* for decryption.
|
|
124
|
+
*
|
|
125
|
+
* The typical restore flow:
|
|
126
|
+
* 1. Fetch the backup metadata (stored in a header in the backup file)
|
|
127
|
+
* 2. Call this function to retrieve the forward secrecy token from SVR-B
|
|
128
|
+
* 3. Use the token to derive message backup keys
|
|
129
|
+
* 4. Decrypt and restore the backup data
|
|
130
|
+
*
|
|
131
|
+
* @param backupKey The backup key derived from the Account Entropy Pool (AEP).
|
|
132
|
+
* @param metadata The metadata that was stored in a header in the backup file during backup creation.
|
|
133
|
+
* @param options Optional configuration.
|
|
134
|
+
* @param options.abortSignal An AbortSignal that will cancel the request.
|
|
135
|
+
* @returns The forward secrecy token needed to derive keys for decrypting the backup.
|
|
136
|
+
* @throws Error if the metadata is invalid, the network operation fails, or the
|
|
137
|
+
* backup cannot be found.
|
|
138
|
+
*/
|
|
139
|
+
async fetchForwardSecrecyTokenFromServer(backupKey, metadata, options) {
|
|
140
|
+
const promise = Native.SecureValueRecoveryForBackups_RestoreBackupFromServer(this.asyncContext, backupKey.serialize(), metadata, this.connectionManager, this.auth.username, this.auth.password);
|
|
141
|
+
const tokenBytes = await this.asyncContext.makeCancellable(options?.abortSignal, promise);
|
|
142
|
+
return new AccountKeys_1.BackupForwardSecrecyToken(tokenBytes);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.SvrB = SvrB;
|
|
146
|
+
//# sourceMappingURL=SvrB.js.map
|
package/dist/net.d.ts
CHANGED
|
@@ -3,9 +3,11 @@ import * as Native from '../Native';
|
|
|
3
3
|
import { CDSRequestOptionsType, CDSResponseType } from './net/CDSI';
|
|
4
4
|
import { ConnectionEventsListener, UnauthenticatedChatConnection, AuthenticatedChatConnection, ChatServiceListener } from './net/Chat';
|
|
5
5
|
import { RegistrationService } from './net/Registration';
|
|
6
|
+
import { SvrB } from './net/SvrB';
|
|
6
7
|
export * from './net/CDSI';
|
|
7
8
|
export * from './net/Chat';
|
|
8
9
|
export * from './net/Registration';
|
|
10
|
+
export * from './net/SvrB';
|
|
9
11
|
export declare enum Environment {
|
|
10
12
|
Staging = 0,
|
|
11
13
|
Production = 1
|
|
@@ -39,6 +41,7 @@ export type NetConstructorOptions = Readonly<{
|
|
|
39
41
|
TESTING_localServer_chatPort: number;
|
|
40
42
|
TESTING_localServer_cdsiPort: number;
|
|
41
43
|
TESTING_localServer_svr2Port: number;
|
|
44
|
+
TESTING_localServer_svrBPort: number;
|
|
42
45
|
TESTING_localServer_rootCertificateDer: Uint8Array;
|
|
43
46
|
}>;
|
|
44
47
|
/** See {@link Net.setProxy()}. */
|
|
@@ -214,4 +217,18 @@ export declare class Net {
|
|
|
214
217
|
*/
|
|
215
218
|
onNetworkChange(): void;
|
|
216
219
|
cdsiLookup(auth: Readonly<ServiceAuth>, options: ReadonlyDeep<CDSRequestOptionsType>): Promise<CDSResponseType<string, string>>;
|
|
220
|
+
/**
|
|
221
|
+
* Get the SVR-B (Secure Value Recovery for Backups) service for this network instance.
|
|
222
|
+
*
|
|
223
|
+
* SVR-B provides forward secrecy for Signal backups, ensuring that even if the user's
|
|
224
|
+
* Account Entropy Pool or Backup Key is compromised, the attacker cannot
|
|
225
|
+
* compromise all past backups. This is achieved by storing the forward
|
|
226
|
+
* secrecy token in a secure enclave inside the SVR-B server, which provably
|
|
227
|
+
* attests that it only stores a single token at a time for each user.
|
|
228
|
+
*
|
|
229
|
+
* @param auth The authentication credentials to use when connecting to the SVR-B server.
|
|
230
|
+
* @returns An SvrB service instance configured for this network environment
|
|
231
|
+
* @see {@link SvrB}
|
|
232
|
+
*/
|
|
233
|
+
svrB(auth: Readonly<ServiceAuth>): SvrB;
|
|
217
234
|
}
|
package/dist/net.js
CHANGED
|
@@ -23,10 +23,12 @@ const Native = require("../Native");
|
|
|
23
23
|
const CDSI_1 = require("./net/CDSI");
|
|
24
24
|
const Chat_1 = require("./net/Chat");
|
|
25
25
|
const Registration_1 = require("./net/Registration");
|
|
26
|
+
const SvrB_1 = require("./net/SvrB");
|
|
26
27
|
const internal_1 = require("./internal");
|
|
27
28
|
__exportStar(require("./net/CDSI"), exports);
|
|
28
29
|
__exportStar(require("./net/Chat"), exports);
|
|
29
30
|
__exportStar(require("./net/Registration"), exports);
|
|
31
|
+
__exportStar(require("./net/SvrB"), exports);
|
|
30
32
|
// This must match the libsignal-bridge Rust enum of the same name.
|
|
31
33
|
var Environment;
|
|
32
34
|
(function (Environment) {
|
|
@@ -62,7 +64,7 @@ class Net {
|
|
|
62
64
|
this.options = options;
|
|
63
65
|
this.asyncContext = new TokioAsyncContext(Native.TokioAsyncContext_new());
|
|
64
66
|
if (options.localTestServer) {
|
|
65
|
-
this._connectionManager = (0, internal_1.newNativeHandle)(Native.TESTING_ConnectionManager_newLocalOverride(options.userAgent, options.TESTING_localServer_chatPort, options.TESTING_localServer_cdsiPort, options.TESTING_localServer_svr2Port, options.TESTING_localServer_rootCertificateDer));
|
|
67
|
+
this._connectionManager = (0, internal_1.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));
|
|
66
68
|
}
|
|
67
69
|
else {
|
|
68
70
|
this._connectionManager = (0, internal_1.newNativeHandle)(Native.ConnectionManager_new(options.env, options.userAgent, new internal_1.BridgedStringMap(options.remoteConfig || new Map())));
|
|
@@ -282,6 +284,25 @@ class Net {
|
|
|
282
284
|
connectionManager: this._connectionManager,
|
|
283
285
|
}, auth, options);
|
|
284
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* Get the SVR-B (Secure Value Recovery for Backups) service for this network instance.
|
|
289
|
+
*
|
|
290
|
+
* SVR-B provides forward secrecy for Signal backups, ensuring that even if the user's
|
|
291
|
+
* Account Entropy Pool or Backup Key is compromised, the attacker cannot
|
|
292
|
+
* compromise all past backups. This is achieved by storing the forward
|
|
293
|
+
* secrecy token in a secure enclave inside the SVR-B server, which provably
|
|
294
|
+
* attests that it only stores a single token at a time for each user.
|
|
295
|
+
*
|
|
296
|
+
* @param auth The authentication credentials to use when connecting to the SVR-B server.
|
|
297
|
+
* @returns An SvrB service instance configured for this network environment
|
|
298
|
+
* @see {@link SvrB}
|
|
299
|
+
*/
|
|
300
|
+
svrB(auth) {
|
|
301
|
+
const env = this.options.localTestServer
|
|
302
|
+
? Environment.Staging
|
|
303
|
+
: this.options.env;
|
|
304
|
+
return new SvrB_1.SvrB(this.asyncContext, this._connectionManager, auth, env);
|
|
305
|
+
}
|
|
285
306
|
}
|
|
286
307
|
exports.Net = Net;
|
|
287
308
|
//# sourceMappingURL=net.js.map
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|