@signalapp/libsignal-client 0.77.1 → 0.78.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 +10 -6
- package/dist/net/SvrB.d.ts +64 -26
- package/dist/net/SvrB.js +56 -31
- 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,9 +228,11 @@ 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
|
|
232
|
-
export function
|
|
233
|
-
export function
|
|
231
|
+
export function BackupRestoreResponse_GetForwardSecrecyToken(response: Wrapper<BackupRestoreResponse>): Uint8Array;
|
|
232
|
+
export function BackupRestoreResponse_GetNextBackupSecretData(response: Wrapper<BackupRestoreResponse>): Uint8Array;
|
|
233
|
+
export function BackupStoreResponse_GetForwardSecrecyToken(response: Wrapper<BackupStoreResponse>): Uint8Array;
|
|
234
|
+
export function BackupStoreResponse_GetNextBackupSecretData(response: Wrapper<BackupStoreResponse>): Uint8Array;
|
|
235
|
+
export function BackupStoreResponse_GetOpaqueMetadata(response: Wrapper<BackupStoreResponse>): Uint8Array;
|
|
234
236
|
export function BridgedStringMap_insert(map: Wrapper<BridgedStringMap>, key: string, value: string): void;
|
|
235
237
|
export function BridgedStringMap_new(initialCapacity: number): BridgedStringMap;
|
|
236
238
|
export function CallLinkAuthCredentialPresentation_CheckValidContents(presentationBytes: Uint8Array): void;
|
|
@@ -501,8 +503,9 @@ export function SealedSender_DecryptToUsmc(ctext: Uint8Array, identityStore: Ide
|
|
|
501
503
|
export function SealedSender_Encrypt(destination: Wrapper<ProtocolAddress>, content: Wrapper<UnidentifiedSenderMessageContent>, identityKeyStore: IdentityKeyStore): Promise<Uint8Array>;
|
|
502
504
|
export function SealedSender_MultiRecipientEncrypt(recipients: Wrapper<ProtocolAddress>[], recipientSessions: Wrapper<SessionRecord>[], excludedRecipients: Uint8Array, content: Wrapper<UnidentifiedSenderMessageContent>, identityKeyStore: IdentityKeyStore): Promise<Uint8Array>;
|
|
503
505
|
export function SealedSender_MultiRecipientMessageForSingleRecipient(encodedMultiRecipientMessage: Uint8Array): Uint8Array;
|
|
504
|
-
export function
|
|
505
|
-
export function
|
|
506
|
+
export function SecureValueRecoveryForBackups_CreateNewBackupChain(environment: number, backupKey: Uint8Array): Uint8Array;
|
|
507
|
+
export function SecureValueRecoveryForBackups_RestoreBackupFromServer(asyncRuntime: Wrapper<TokioAsyncContext>, backupKey: Uint8Array, metadata: Uint8Array, connectionManager: Wrapper<ConnectionManager>, username: string, password: string): CancellablePromise<BackupRestoreResponse>;
|
|
508
|
+
export function SecureValueRecoveryForBackups_StoreBackup(asyncRuntime: Wrapper<TokioAsyncContext>, backupKey: Uint8Array, previousSecretData: Uint8Array, connectionManager: Wrapper<ConnectionManager>, username: string, password: string): CancellablePromise<BackupStoreResponse>;
|
|
506
509
|
export function SenderCertificate_Deserialize(data: Uint8Array): SenderCertificate;
|
|
507
510
|
export function SenderCertificate_GetCertificate(obj: Wrapper<SenderCertificate>): Uint8Array;
|
|
508
511
|
export function SenderCertificate_GetDeviceId(obj: Wrapper<SenderCertificate>): number;
|
|
@@ -719,7 +722,8 @@ export function initLogger(maxLevel: LogLevel, callback: (level: LogLevel, targe
|
|
|
719
722
|
export function test_only_fn_returns_123(): number;
|
|
720
723
|
interface Aes256GcmSiv { readonly __type: unique symbol; }
|
|
721
724
|
interface AuthenticatedChatConnection { readonly __type: unique symbol; }
|
|
722
|
-
interface
|
|
725
|
+
interface BackupRestoreResponse { readonly __type: unique symbol; }
|
|
726
|
+
interface BackupStoreResponse { readonly __type: unique symbol; }
|
|
723
727
|
interface BridgedStringMap { readonly __type: unique symbol; }
|
|
724
728
|
interface CdsiLookup { readonly __type: unique symbol; }
|
|
725
729
|
interface ChatConnectionInfo { readonly __type: unique symbol; }
|
package/dist/net/SvrB.d.ts
CHANGED
|
@@ -30,7 +30,33 @@ export type StoreBackupResponse = {
|
|
|
30
30
|
*/
|
|
31
31
|
metadata: Uint8Array;
|
|
32
32
|
/**
|
|
33
|
-
* Opaque value that must be persisted and provided to the next call to {@link SvrB#
|
|
33
|
+
* Opaque value that must be persisted and provided to the next call to {@link SvrB#store}.
|
|
34
|
+
*
|
|
35
|
+
* See the {@link SvrB} documentation for lifecycle and persistence handling
|
|
36
|
+
* for this value.
|
|
37
|
+
*/
|
|
38
|
+
nextBackupSecretData: Uint8Array;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The result of preparing a backup to be stored with forward secrecy guarantees.
|
|
42
|
+
*
|
|
43
|
+
* This context contains all the necessary components to encrypt and store a backup using a
|
|
44
|
+
* key derived from both the user's Account Entropy Pool and the SVR-B-protected
|
|
45
|
+
* Forward Secrecy Token.
|
|
46
|
+
*
|
|
47
|
+
* @see {@link BackupForwardSecrecyToken}
|
|
48
|
+
*/
|
|
49
|
+
export type RestoreBackupResponse = {
|
|
50
|
+
/**
|
|
51
|
+
* The forward secrecy token used to derive MessageBackupKey instances.
|
|
52
|
+
*
|
|
53
|
+
* This token provides forward secrecy guarantees by ensuring that compromise of the backup key
|
|
54
|
+
* alone is insufficient to decrypt backups. Each backup is protected by a value stored on
|
|
55
|
+
* the SVR-B server that must be retrieved during restoration.
|
|
56
|
+
*/
|
|
57
|
+
forwardSecrecyToken: BackupForwardSecrecyToken;
|
|
58
|
+
/**
|
|
59
|
+
* Opaque value that must be persisted and provided to the next call to {@link SvrB#store}.
|
|
34
60
|
*
|
|
35
61
|
* See the {@link SvrB} documentation for lifecycle and persistence handling
|
|
36
62
|
* for this value.
|
|
@@ -56,23 +82,24 @@ export type StoreBackupResponse = {
|
|
|
56
82
|
* ## Storage Flow
|
|
57
83
|
*
|
|
58
84
|
* 1. Create a {@link Net} instance and get the {@link SvrB} service via {@link Net#svrB}
|
|
59
|
-
* 2.
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* 3.
|
|
63
|
-
* 4.
|
|
64
|
-
*
|
|
85
|
+
* 2. If this is a fresh install, call {@link SvrB#createNewBackupChain} and store the result
|
|
86
|
+
* locally. Otherwise, retrieve the secret data from the last **successful** backup operation
|
|
87
|
+
* (store or restore).
|
|
88
|
+
* 3. Call {@link SvrB#store}
|
|
89
|
+
* 4. Use the returned forward secrecy token to derive encryption keys
|
|
90
|
+
* 5. Encrypt and upload the backup data to the user's remote, off-device storage location,
|
|
91
|
+
* including the returned {@link StoreBackupResponse#metadata}. The upload **must succeed**
|
|
65
92
|
* before proceeding or the previous backup might become unretrievable.
|
|
66
|
-
*
|
|
93
|
+
* 6. Store the {@link StoreBackupResponse#nextBackupSecretData} locally, overwriting any
|
|
94
|
+
* previously-saved value.
|
|
67
95
|
*
|
|
68
96
|
* ## Secret handling
|
|
69
97
|
*
|
|
70
|
-
* When calling {@link SvrB#
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* only for the very first backup from a device.
|
|
98
|
+
* When calling {@link SvrB#store}, the `previousSecretData` parameter must be from the last call to
|
|
99
|
+
* {@link SvrB#store} or {@link SvrB#restore} that succeeded. The returned secret from a successful
|
|
100
|
+
* store or restore should be persisted until it is overwritten by the value from a subsequent
|
|
101
|
+
* successful call. The caller should use {@link SvrB#createNewBackupChain} only for the very first
|
|
102
|
+
* backup with a particular backup key.
|
|
76
103
|
*
|
|
77
104
|
* ## Restore Flow
|
|
78
105
|
*
|
|
@@ -81,6 +108,7 @@ export type StoreBackupResponse = {
|
|
|
81
108
|
* 3. Call {@link SvrB#fetchForwardSecrecyTokenFromServer} to get the forward secrecy token
|
|
82
109
|
* 4. Use the token to derive decryption keys
|
|
83
110
|
* 5. Decrypt and restore the backup data
|
|
111
|
+
* 6. Store the returned {@link RestoreBackupResponse#nextBackupSecretData} locally.
|
|
84
112
|
*
|
|
85
113
|
* ## Usage
|
|
86
114
|
* ```typescript
|
|
@@ -105,26 +133,35 @@ export declare class SvrB {
|
|
|
105
133
|
username: string;
|
|
106
134
|
password: string;
|
|
107
135
|
}>, environment: Environment);
|
|
136
|
+
/**
|
|
137
|
+
* Generates backup "secret data" for a fresh install.
|
|
138
|
+
*
|
|
139
|
+
* Should not be used if any previous backups exist for this `backupKey`, whether uploaded or
|
|
140
|
+
* restored by the local device. See {@link SvrB} for more information.
|
|
141
|
+
*/
|
|
142
|
+
createNewBackupChain(backupKey: BackupKey): Uint8Array;
|
|
108
143
|
/**
|
|
109
144
|
* Prepares a backup for storage with forward secrecy guarantees.
|
|
110
145
|
*
|
|
111
|
-
* This makes a network call to the SVR-B server to store the forward secrecy token
|
|
112
|
-
*
|
|
113
|
-
*
|
|
146
|
+
* This makes a network call to the SVR-B server to store the forward secrecy token and returns a
|
|
147
|
+
* {@link StoreBackupResponse}. See its fields' documentation and {@link SvrB} for how to continue
|
|
148
|
+
* persisting the backup on success.
|
|
114
149
|
*
|
|
115
150
|
* @param backupKey The backup key derived from the Account Entropy Pool (AEP).
|
|
116
151
|
* @param previousSecretData Optional secret data from the most recent previous backup.
|
|
117
|
-
* **Critical**: This MUST be the
|
|
118
|
-
*
|
|
152
|
+
* **Critical**: This MUST be the secret data from the most recent of the following:
|
|
153
|
+
* - the last {@link #store} call whose returned {@link StoreBackupResponse#metadata} was
|
|
119
154
|
* successfully uploaded, and whose `nextBackupSecretData` was persisted.
|
|
120
|
-
*
|
|
121
|
-
*
|
|
155
|
+
* - the last {@link #restore} call
|
|
156
|
+
* - the already-persisted result from {@link #createNewBackupChain}, only if neither of the other
|
|
157
|
+
* two are available.
|
|
122
158
|
* @param options Optional configuration.
|
|
123
159
|
* @param options.abortSignal An AbortSignal that will cancel the request.
|
|
124
|
-
* @returns a {@link StoreBackupResponse} containing the forward secrecy token, metadata, and
|
|
125
|
-
*
|
|
160
|
+
* @returns a {@link StoreBackupResponse} containing the forward secrecy token, metadata, and
|
|
161
|
+
* secret data.
|
|
162
|
+
* @throws Error if the previous secret data is malformed, or if processing or upload fail.
|
|
126
163
|
*/
|
|
127
|
-
|
|
164
|
+
store(backupKey: BackupKey, previousSecretData: Uint8Array, options?: {
|
|
128
165
|
abortSignal?: AbortSignal;
|
|
129
166
|
}): Promise<StoreBackupResponse>;
|
|
130
167
|
/**
|
|
@@ -139,6 +176,7 @@ export declare class SvrB {
|
|
|
139
176
|
* 2. Call this function to retrieve the forward secrecy token from SVR-B
|
|
140
177
|
* 3. Use the token to derive message backup keys
|
|
141
178
|
* 4. Decrypt and restore the backup data
|
|
179
|
+
* 5. Store the returned {@link RestoreBackupResponse#nextBackupSecretData} locally.
|
|
142
180
|
*
|
|
143
181
|
* @param backupKey The backup key derived from the Account Entropy Pool (AEP).
|
|
144
182
|
* @param metadata The metadata that was stored in a header in the backup file during backup creation.
|
|
@@ -148,8 +186,8 @@ export declare class SvrB {
|
|
|
148
186
|
* @throws Error if the metadata is invalid, the network operation fails, or the
|
|
149
187
|
* backup cannot be found.
|
|
150
188
|
*/
|
|
151
|
-
|
|
189
|
+
restore(backupKey: BackupKey, metadata: Uint8Array, options?: {
|
|
152
190
|
abortSignal?: AbortSignal;
|
|
153
|
-
}): Promise<
|
|
191
|
+
}): Promise<RestoreBackupResponse>;
|
|
154
192
|
}
|
|
155
193
|
export {};
|
package/dist/net/SvrB.js
CHANGED
|
@@ -12,14 +12,26 @@ class StoreBackupResponseImpl {
|
|
|
12
12
|
this._nativeHandle = handle;
|
|
13
13
|
}
|
|
14
14
|
get forwardSecrecyToken() {
|
|
15
|
-
const tokenBytes = Native.
|
|
15
|
+
const tokenBytes = Native.BackupStoreResponse_GetForwardSecrecyToken(this);
|
|
16
16
|
return new AccountKeys_1.BackupForwardSecrecyToken(tokenBytes);
|
|
17
17
|
}
|
|
18
18
|
get metadata() {
|
|
19
|
-
return Native.
|
|
19
|
+
return Native.BackupStoreResponse_GetOpaqueMetadata(this);
|
|
20
20
|
}
|
|
21
21
|
get nextBackupSecretData() {
|
|
22
|
-
return Native.
|
|
22
|
+
return Native.BackupStoreResponse_GetNextBackupSecretData(this);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
class RestoreBackupResponseImpl {
|
|
26
|
+
constructor(handle) {
|
|
27
|
+
this._nativeHandle = handle;
|
|
28
|
+
}
|
|
29
|
+
get forwardSecrecyToken() {
|
|
30
|
+
const tokenBytes = Native.BackupRestoreResponse_GetForwardSecrecyToken(this);
|
|
31
|
+
return new AccountKeys_1.BackupForwardSecrecyToken(tokenBytes);
|
|
32
|
+
}
|
|
33
|
+
get nextBackupSecretData() {
|
|
34
|
+
return Native.BackupRestoreResponse_GetNextBackupSecretData(this);
|
|
23
35
|
}
|
|
24
36
|
}
|
|
25
37
|
/**
|
|
@@ -41,23 +53,24 @@ class StoreBackupResponseImpl {
|
|
|
41
53
|
* ## Storage Flow
|
|
42
54
|
*
|
|
43
55
|
* 1. Create a {@link Net} instance and get the {@link SvrB} service via {@link Net#svrB}
|
|
44
|
-
* 2.
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* 3.
|
|
48
|
-
* 4.
|
|
49
|
-
*
|
|
56
|
+
* 2. If this is a fresh install, call {@link SvrB#createNewBackupChain} and store the result
|
|
57
|
+
* locally. Otherwise, retrieve the secret data from the last **successful** backup operation
|
|
58
|
+
* (store or restore).
|
|
59
|
+
* 3. Call {@link SvrB#store}
|
|
60
|
+
* 4. Use the returned forward secrecy token to derive encryption keys
|
|
61
|
+
* 5. Encrypt and upload the backup data to the user's remote, off-device storage location,
|
|
62
|
+
* including the returned {@link StoreBackupResponse#metadata}. The upload **must succeed**
|
|
50
63
|
* before proceeding or the previous backup might become unretrievable.
|
|
51
|
-
*
|
|
64
|
+
* 6. Store the {@link StoreBackupResponse#nextBackupSecretData} locally, overwriting any
|
|
65
|
+
* previously-saved value.
|
|
52
66
|
*
|
|
53
67
|
* ## Secret handling
|
|
54
68
|
*
|
|
55
|
-
* When calling {@link SvrB#
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* only for the very first backup from a device.
|
|
69
|
+
* When calling {@link SvrB#store}, the `previousSecretData` parameter must be from the last call to
|
|
70
|
+
* {@link SvrB#store} or {@link SvrB#restore} that succeeded. The returned secret from a successful
|
|
71
|
+
* store or restore should be persisted until it is overwritten by the value from a subsequent
|
|
72
|
+
* successful call. The caller should use {@link SvrB#createNewBackupChain} only for the very first
|
|
73
|
+
* backup with a particular backup key.
|
|
61
74
|
*
|
|
62
75
|
* ## Restore Flow
|
|
63
76
|
*
|
|
@@ -66,6 +79,7 @@ class StoreBackupResponseImpl {
|
|
|
66
79
|
* 3. Call {@link SvrB#fetchForwardSecrecyTokenFromServer} to get the forward secrecy token
|
|
67
80
|
* 4. Use the token to derive decryption keys
|
|
68
81
|
* 5. Decrypt and restore the backup data
|
|
82
|
+
* 6. Store the returned {@link RestoreBackupResponse#nextBackupSecretData} locally.
|
|
69
83
|
*
|
|
70
84
|
* ## Usage
|
|
71
85
|
* ```typescript
|
|
@@ -88,28 +102,38 @@ class SvrB {
|
|
|
88
102
|
this.auth = auth;
|
|
89
103
|
this.environment = environment;
|
|
90
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Generates backup "secret data" for a fresh install.
|
|
107
|
+
*
|
|
108
|
+
* Should not be used if any previous backups exist for this `backupKey`, whether uploaded or
|
|
109
|
+
* restored by the local device. See {@link SvrB} for more information.
|
|
110
|
+
*/
|
|
111
|
+
createNewBackupChain(backupKey) {
|
|
112
|
+
return Native.SecureValueRecoveryForBackups_CreateNewBackupChain(this.environment, backupKey.serialize());
|
|
113
|
+
}
|
|
91
114
|
/**
|
|
92
115
|
* Prepares a backup for storage with forward secrecy guarantees.
|
|
93
116
|
*
|
|
94
|
-
* This makes a network call to the SVR-B server to store the forward secrecy token
|
|
95
|
-
*
|
|
96
|
-
*
|
|
117
|
+
* This makes a network call to the SVR-B server to store the forward secrecy token and returns a
|
|
118
|
+
* {@link StoreBackupResponse}. See its fields' documentation and {@link SvrB} for how to continue
|
|
119
|
+
* persisting the backup on success.
|
|
97
120
|
*
|
|
98
121
|
* @param backupKey The backup key derived from the Account Entropy Pool (AEP).
|
|
99
122
|
* @param previousSecretData Optional secret data from the most recent previous backup.
|
|
100
|
-
* **Critical**: This MUST be the
|
|
101
|
-
*
|
|
123
|
+
* **Critical**: This MUST be the secret data from the most recent of the following:
|
|
124
|
+
* - the last {@link #store} call whose returned {@link StoreBackupResponse#metadata} was
|
|
102
125
|
* successfully uploaded, and whose `nextBackupSecretData` was persisted.
|
|
103
|
-
*
|
|
104
|
-
*
|
|
126
|
+
* - the last {@link #restore} call
|
|
127
|
+
* - the already-persisted result from {@link #createNewBackupChain}, only if neither of the other
|
|
128
|
+
* two are available.
|
|
105
129
|
* @param options Optional configuration.
|
|
106
130
|
* @param options.abortSignal An AbortSignal that will cancel the request.
|
|
107
|
-
* @returns a {@link StoreBackupResponse} containing the forward secrecy token, metadata, and
|
|
108
|
-
*
|
|
131
|
+
* @returns a {@link StoreBackupResponse} containing the forward secrecy token, metadata, and
|
|
132
|
+
* secret data.
|
|
133
|
+
* @throws Error if the previous secret data is malformed, or if processing or upload fail.
|
|
109
134
|
*/
|
|
110
|
-
async
|
|
111
|
-
const
|
|
112
|
-
const promise = Native.SecureValueRecoveryForBackups_StoreBackup(this.asyncContext, backupKey.serialize(), secretData, this.connectionManager, this.auth.username, this.auth.password);
|
|
135
|
+
async store(backupKey, previousSecretData, options) {
|
|
136
|
+
const promise = Native.SecureValueRecoveryForBackups_StoreBackup(this.asyncContext, backupKey.serialize(), previousSecretData, this.connectionManager, this.auth.username, this.auth.password);
|
|
113
137
|
const response = await this.asyncContext.makeCancellable(options?.abortSignal, promise);
|
|
114
138
|
return new StoreBackupResponseImpl(response);
|
|
115
139
|
}
|
|
@@ -125,6 +149,7 @@ class SvrB {
|
|
|
125
149
|
* 2. Call this function to retrieve the forward secrecy token from SVR-B
|
|
126
150
|
* 3. Use the token to derive message backup keys
|
|
127
151
|
* 4. Decrypt and restore the backup data
|
|
152
|
+
* 5. Store the returned {@link RestoreBackupResponse#nextBackupSecretData} locally.
|
|
128
153
|
*
|
|
129
154
|
* @param backupKey The backup key derived from the Account Entropy Pool (AEP).
|
|
130
155
|
* @param metadata The metadata that was stored in a header in the backup file during backup creation.
|
|
@@ -134,10 +159,10 @@ class SvrB {
|
|
|
134
159
|
* @throws Error if the metadata is invalid, the network operation fails, or the
|
|
135
160
|
* backup cannot be found.
|
|
136
161
|
*/
|
|
137
|
-
async
|
|
162
|
+
async restore(backupKey, metadata, options) {
|
|
138
163
|
const promise = Native.SecureValueRecoveryForBackups_RestoreBackupFromServer(this.asyncContext, backupKey.serialize(), metadata, this.connectionManager, this.auth.username, this.auth.password);
|
|
139
|
-
const
|
|
140
|
-
return new
|
|
164
|
+
const response = await this.asyncContext.makeCancellable(options?.abortSignal, promise);
|
|
165
|
+
return new RestoreBackupResponseImpl(response);
|
|
141
166
|
}
|
|
142
167
|
}
|
|
143
168
|
exports.SvrB = SvrB;
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|