@signalapp/libsignal-client 0.42.0 → 0.44.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 +23 -15
- package/dist/Errors.d.ts +22 -10
- package/dist/Errors.js +12 -9
- package/dist/acknowledgments.md +1 -1
- package/dist/net.d.ts +100 -33
- package/dist/net.js +105 -28
- package/dist/zkgroup/internal/ByteArray.d.ts +1 -1
- package/dist/zkgroup/internal/ByteArray.js +2 -1
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
- package/prebuilds/darwin-x64/node.napi.node +0 -0
- package/prebuilds/linux-arm64/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.node +0 -0
- package/prebuilds/win32-arm64/node.napi.node +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
package/Native.d.ts
CHANGED
|
@@ -21,22 +21,24 @@ interface LookupResponseEntry {
|
|
|
21
21
|
readonly pni: string | undefined;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
interface
|
|
24
|
+
interface ChatResponse {
|
|
25
25
|
status: number;
|
|
26
26
|
message: string | undefined;
|
|
27
27
|
headers: ReadonlyArray<[string, string]>;
|
|
28
28
|
body: Buffer | undefined;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
interface
|
|
31
|
+
interface ChatServiceDebugInfo {
|
|
32
32
|
connectionReused: boolean;
|
|
33
33
|
reconnectCount: number;
|
|
34
34
|
ipType: number;
|
|
35
|
+
durationMillis: number;
|
|
36
|
+
connectionInfo: string;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
interface ResponseAndDebugInfo {
|
|
38
|
-
response:
|
|
39
|
-
debugInfo:
|
|
40
|
+
response: ChatResponse;
|
|
41
|
+
debugInfo: ChatServiceDebugInfo;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
interface SealedSenderMultiRecipientMessageRecipient {
|
|
@@ -113,9 +115,9 @@ export abstract class InputStream {
|
|
|
113
115
|
|
|
114
116
|
export abstract class SyncInputStream extends Buffer {}
|
|
115
117
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
118
|
+
type Wrapper<T> = Readonly<{
|
|
119
|
+
_nativeHandle: T;
|
|
120
|
+
}>;
|
|
119
121
|
|
|
120
122
|
interface MessageBackupValidationOutcome {
|
|
121
123
|
errorMessage: string | null;
|
|
@@ -164,16 +166,20 @@ export function CallLinkSecretParams_DeriveFromRootKey(rootKey: Buffer): Buffer;
|
|
|
164
166
|
export function CallLinkSecretParams_GetPublicParams(paramsBytes: Buffer): Buffer;
|
|
165
167
|
export function Cds2ClientState_New(mrenclave: Buffer, attestationMsg: Buffer, currentTimestamp: Timestamp): SgxClientState;
|
|
166
168
|
export function CdsiLookup_complete(asyncRuntime: Wrapper<TokioAsyncContext>, lookup: Wrapper<CdsiLookup>): Promise<LookupResponse>;
|
|
167
|
-
export function CdsiLookup_new(asyncRuntime: Wrapper<TokioAsyncContext>, connectionManager: Wrapper<ConnectionManager>, username: string, password: string, request: Wrapper<LookupRequest
|
|
169
|
+
export function CdsiLookup_new(asyncRuntime: Wrapper<TokioAsyncContext>, connectionManager: Wrapper<ConnectionManager>, username: string, password: string, request: Wrapper<LookupRequest>): Promise<CdsiLookup>;
|
|
168
170
|
export function CdsiLookup_token(lookup: Wrapper<CdsiLookup>): Buffer;
|
|
171
|
+
export function ChatService_connect_auth(asyncRuntime: Wrapper<TokioAsyncContext>, chat: Wrapper<Chat>): Promise<ChatServiceDebugInfo>;
|
|
172
|
+
export function ChatService_connect_unauth(asyncRuntime: Wrapper<TokioAsyncContext>, chat: Wrapper<Chat>): Promise<ChatServiceDebugInfo>;
|
|
169
173
|
export function ChatService_disconnect(asyncRuntime: Wrapper<TokioAsyncContext>, chat: Wrapper<Chat>): Promise<void>;
|
|
170
174
|
export function ChatService_new(connectionManager: Wrapper<ConnectionManager>, username: string, password: string): Chat;
|
|
171
|
-
export function ChatService_unauth_send(asyncRuntime: Wrapper<TokioAsyncContext>, chat: Wrapper<Chat>, httpRequest: Wrapper<HttpRequest>, timeoutMillis: number): Promise<
|
|
175
|
+
export function ChatService_unauth_send(asyncRuntime: Wrapper<TokioAsyncContext>, chat: Wrapper<Chat>, httpRequest: Wrapper<HttpRequest>, timeoutMillis: number): Promise<ChatResponse>;
|
|
172
176
|
export function ChatService_unauth_send_and_debug(asyncRuntime: Wrapper<TokioAsyncContext>, chat: Wrapper<Chat>, httpRequest: Wrapper<HttpRequest>, timeoutMillis: number): Promise<ResponseAndDebugInfo>;
|
|
173
177
|
export function CiphertextMessage_FromPlaintextContent(m: Wrapper<PlaintextContent>): CiphertextMessage;
|
|
174
178
|
export function CiphertextMessage_Serialize(obj: Wrapper<CiphertextMessage>): Buffer;
|
|
175
179
|
export function CiphertextMessage_Type(msg: Wrapper<CiphertextMessage>): number;
|
|
180
|
+
export function ConnectionManager_clear_proxy(connectionManager: Wrapper<ConnectionManager>): void;
|
|
176
181
|
export function ConnectionManager_new(environment: number): ConnectionManager;
|
|
182
|
+
export function ConnectionManager_set_proxy(connectionManager: Wrapper<ConnectionManager>, host: string, port: number): void;
|
|
177
183
|
export function CreateCallLinkCredentialPresentation_CheckValidContents(presentationBytes: Buffer): void;
|
|
178
184
|
export function CreateCallLinkCredentialPresentation_Verify(presentationBytes: Buffer, roomId: Buffer, now: Timestamp, serverParamsBytes: Buffer, callLinkParamsBytes: Buffer): void;
|
|
179
185
|
export function CreateCallLinkCredentialRequestContext_CheckValidContents(contextBytes: Buffer): void;
|
|
@@ -457,17 +463,19 @@ export function SignedPreKeyRecord_GetSignature(obj: Wrapper<SignedPreKeyRecord>
|
|
|
457
463
|
export function SignedPreKeyRecord_GetTimestamp(obj: Wrapper<SignedPreKeyRecord>): Timestamp;
|
|
458
464
|
export function SignedPreKeyRecord_New(id: number, timestamp: Timestamp, pubKey: Wrapper<PublicKey>, privKey: Wrapper<PrivateKey>, signature: Buffer): SignedPreKeyRecord;
|
|
459
465
|
export function SignedPreKeyRecord_Serialize(obj: Wrapper<SignedPreKeyRecord>): Buffer;
|
|
460
|
-
export function Svr3Backup(asyncRuntime: Wrapper<TokioAsyncContext>, connectionManager: Wrapper<ConnectionManager>, secret: Buffer, password: string, maxTries: number, username: string, enclavePassword: string
|
|
461
|
-
export function Svr3Restore(asyncRuntime: Wrapper<TokioAsyncContext>, connectionManager: Wrapper<ConnectionManager>, password: string, shareSet: Buffer, username: string, enclavePassword: string
|
|
462
|
-
export function TESTING_CdsiLookupErrorConvert(): void;
|
|
466
|
+
export function Svr3Backup(asyncRuntime: Wrapper<TokioAsyncContext>, connectionManager: Wrapper<ConnectionManager>, secret: Buffer, password: string, maxTries: number, username: string, enclavePassword: string): Promise<Buffer>;
|
|
467
|
+
export function Svr3Restore(asyncRuntime: Wrapper<TokioAsyncContext>, connectionManager: Wrapper<ConnectionManager>, password: string, shareSet: Buffer, username: string, enclavePassword: string): Promise<Buffer>;
|
|
468
|
+
export function TESTING_CdsiLookupErrorConvert(errorDescription: string): void;
|
|
463
469
|
export function TESTING_CdsiLookupResponseConvert(asyncRuntime: Wrapper<TokioAsyncContext>): Promise<LookupResponse>;
|
|
464
|
-
export function TESTING_ChatRequestGetBody(request: Wrapper<HttpRequest>): Buffer
|
|
470
|
+
export function TESTING_ChatRequestGetBody(request: Wrapper<HttpRequest>): Buffer;
|
|
465
471
|
export function TESTING_ChatRequestGetHeaderValue(request: Wrapper<HttpRequest>, headerName: string): string;
|
|
466
472
|
export function TESTING_ChatRequestGetMethod(request: Wrapper<HttpRequest>): string;
|
|
467
473
|
export function TESTING_ChatRequestGetPath(request: Wrapper<HttpRequest>): string;
|
|
468
|
-
export function TESTING_ChatServiceDebugInfoConvert():
|
|
474
|
+
export function TESTING_ChatServiceDebugInfoConvert(): ChatServiceDebugInfo;
|
|
469
475
|
export function TESTING_ChatServiceErrorConvert(): void;
|
|
470
|
-
export function
|
|
476
|
+
export function TESTING_ChatServiceInactiveErrorConvert(): void;
|
|
477
|
+
export function TESTING_ChatServiceResponseAndDebugInfoConvert(): ResponseAndDebugInfo;
|
|
478
|
+
export function TESTING_ChatServiceResponseConvert(bodyPresent: boolean): ChatResponse;
|
|
471
479
|
export function TESTING_ErrorOnBorrowAsync(_input: null): Promise<void>;
|
|
472
480
|
export function TESTING_ErrorOnBorrowIo(asyncRuntime: Wrapper<NonSuspendingBackgroundThreadRuntime>, _input: null): Promise<void>;
|
|
473
481
|
export function TESTING_ErrorOnBorrowSync(_input: null): void;
|
package/dist/Errors.d.ts
CHANGED
|
@@ -22,15 +22,18 @@ export declare enum ErrorCode {
|
|
|
22
22
|
BadDiscriminatorCharacter = 18,
|
|
23
23
|
DiscriminatorTooLarge = 19,
|
|
24
24
|
IoError = 20,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
CdsiInvalidToken = 21,
|
|
26
|
+
InvalidUri = 22,
|
|
27
|
+
InvalidMediaInput = 23,
|
|
28
|
+
UnsupportedMediaInput = 24,
|
|
29
|
+
InputDataTooLong = 25,
|
|
30
|
+
InvalidEntropyDataLength = 26,
|
|
31
|
+
InvalidUsernameLinkEncryptedData = 27,
|
|
32
|
+
RateLimitedError = 28,
|
|
33
|
+
SvrDataMissing = 29,
|
|
34
|
+
SvrRequestFailed = 30,
|
|
35
|
+
SvrRestoreFailed = 31,
|
|
36
|
+
ChatServiceInactive = 32
|
|
34
37
|
}
|
|
35
38
|
export declare class LibSignalErrorBase extends Error {
|
|
36
39
|
readonly code: ErrorCode;
|
|
@@ -115,6 +118,12 @@ export type InvalidUsernameLinkEncryptedData = LibSignalErrorCommon & {
|
|
|
115
118
|
export type IoError = LibSignalErrorCommon & {
|
|
116
119
|
code: ErrorCode.IoError;
|
|
117
120
|
};
|
|
121
|
+
export type CdsiInvalidTokenError = LibSignalErrorCommon & {
|
|
122
|
+
code: ErrorCode.CdsiInvalidToken;
|
|
123
|
+
};
|
|
124
|
+
export type InvalidUriError = LibSignalErrorCommon & {
|
|
125
|
+
code: ErrorCode.InvalidUri;
|
|
126
|
+
};
|
|
118
127
|
export type InvalidMediaInputError = LibSignalErrorCommon & {
|
|
119
128
|
code: ErrorCode.InvalidMediaInput;
|
|
120
129
|
};
|
|
@@ -125,6 +134,9 @@ export type RateLimitedError = LibSignalErrorBase & {
|
|
|
125
134
|
code: ErrorCode.RateLimitedError;
|
|
126
135
|
readonly retryAfterSecs: number;
|
|
127
136
|
};
|
|
137
|
+
export type ChatServiceInactive = LibSignalErrorBase & {
|
|
138
|
+
code: ErrorCode.ChatServiceInactive;
|
|
139
|
+
};
|
|
128
140
|
export type SvrDataMissingError = LibSignalErrorBase & {
|
|
129
141
|
code: ErrorCode.SvrDataMissing;
|
|
130
142
|
};
|
|
@@ -134,4 +146,4 @@ export type SvrRequestFailedError = LibSignalErrorCommon & {
|
|
|
134
146
|
export type SvrRestoreFailedError = LibSignalErrorCommon & {
|
|
135
147
|
code: ErrorCode.SvrRestoreFailed;
|
|
136
148
|
};
|
|
137
|
-
export type LibSignalError = GenericError | DuplicatedMessageError | SealedSenderSelfSendError | UntrustedIdentityError | InvalidRegistrationIdError | VerificationFailedError | InvalidSessionError | InvalidSenderKeySessionError | NicknameCannotBeEmptyError | CannotStartWithDigitError | MissingSeparatorError | BadNicknameCharacterError | NicknameTooShortError | NicknameTooLongError | DiscriminatorCannotBeEmptyError | DiscriminatorCannotBeZeroError | DiscriminatorCannotBeSingleDigitError | DiscriminatorCannotHaveLeadingZerosError | BadDiscriminatorCharacterError | DiscriminatorTooLargeError | InputDataTooLong | InvalidEntropyDataLength | InvalidUsernameLinkEncryptedData | IoError | InvalidMediaInputError | SvrDataMissingError | SvrRestoreFailedError | SvrRequestFailedError | UnsupportedMediaInputError;
|
|
149
|
+
export type LibSignalError = GenericError | DuplicatedMessageError | SealedSenderSelfSendError | UntrustedIdentityError | InvalidRegistrationIdError | 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;
|
package/dist/Errors.js
CHANGED
|
@@ -29,15 +29,18 @@ var ErrorCode;
|
|
|
29
29
|
ErrorCode[ErrorCode["BadDiscriminatorCharacter"] = 18] = "BadDiscriminatorCharacter";
|
|
30
30
|
ErrorCode[ErrorCode["DiscriminatorTooLarge"] = 19] = "DiscriminatorTooLarge";
|
|
31
31
|
ErrorCode[ErrorCode["IoError"] = 20] = "IoError";
|
|
32
|
-
ErrorCode[ErrorCode["
|
|
33
|
-
ErrorCode[ErrorCode["
|
|
34
|
-
ErrorCode[ErrorCode["
|
|
35
|
-
ErrorCode[ErrorCode["
|
|
36
|
-
ErrorCode[ErrorCode["
|
|
37
|
-
ErrorCode[ErrorCode["
|
|
38
|
-
ErrorCode[ErrorCode["
|
|
39
|
-
ErrorCode[ErrorCode["
|
|
40
|
-
ErrorCode[ErrorCode["
|
|
32
|
+
ErrorCode[ErrorCode["CdsiInvalidToken"] = 21] = "CdsiInvalidToken";
|
|
33
|
+
ErrorCode[ErrorCode["InvalidUri"] = 22] = "InvalidUri";
|
|
34
|
+
ErrorCode[ErrorCode["InvalidMediaInput"] = 23] = "InvalidMediaInput";
|
|
35
|
+
ErrorCode[ErrorCode["UnsupportedMediaInput"] = 24] = "UnsupportedMediaInput";
|
|
36
|
+
ErrorCode[ErrorCode["InputDataTooLong"] = 25] = "InputDataTooLong";
|
|
37
|
+
ErrorCode[ErrorCode["InvalidEntropyDataLength"] = 26] = "InvalidEntropyDataLength";
|
|
38
|
+
ErrorCode[ErrorCode["InvalidUsernameLinkEncryptedData"] = 27] = "InvalidUsernameLinkEncryptedData";
|
|
39
|
+
ErrorCode[ErrorCode["RateLimitedError"] = 28] = "RateLimitedError";
|
|
40
|
+
ErrorCode[ErrorCode["SvrDataMissing"] = 29] = "SvrDataMissing";
|
|
41
|
+
ErrorCode[ErrorCode["SvrRequestFailed"] = 30] = "SvrRequestFailed";
|
|
42
|
+
ErrorCode[ErrorCode["SvrRestoreFailed"] = 31] = "SvrRestoreFailed";
|
|
43
|
+
ErrorCode[ErrorCode["ChatServiceInactive"] = 32] = "ChatServiceInactive";
|
|
41
44
|
})(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {}));
|
|
42
45
|
class LibSignalErrorBase extends Error {
|
|
43
46
|
constructor(message, name, operation, extraProps) {
|
package/dist/acknowledgments.md
CHANGED
|
@@ -669,7 +669,7 @@ For more information on this, and how to apply and follow the GNU AGPL, see
|
|
|
669
669
|
|
|
670
670
|
```
|
|
671
671
|
|
|
672
|
-
## attest 0.1.0, device-transfer 0.1.0, libsignal-bridge 0.1.0, libsignal-bridge-macros 0.1.0, libsignal-core 0.1.0, libsignal-ffi 0.
|
|
672
|
+
## attest 0.1.0, device-transfer 0.1.0, libsignal-bridge 0.1.0, libsignal-bridge-macros 0.1.0, libsignal-core 0.1.0, libsignal-ffi 0.44.0, libsignal-jni 0.44.0, libsignal-message-backup 0.1.0, libsignal-message-backup-macros 0.1.0, libsignal-net 0.1.0, libsignal-node 0.44.0, libsignal-protocol 0.1.0, libsignal-svr3 0.1.0, poksho 0.7.0, signal-crypto 0.1.0, signal-media 0.1.0, signal-neon-futures 0.1.0, signal-neon-futures-tests 0.1.0, signal-pin 0.1.0, usernames 0.1.0, zkcredential 0.1.0, zkgroup 0.9.0
|
|
673
673
|
|
|
674
674
|
```
|
|
675
675
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
package/dist/net.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { ReadonlyDeep } from 'type-fest';
|
|
3
3
|
import * as Native from '../Native';
|
|
4
|
+
import { Wrapper } from '../Native';
|
|
4
5
|
export declare enum Environment {
|
|
5
6
|
Staging = 0,
|
|
6
7
|
Production = 1
|
|
@@ -15,7 +16,6 @@ export type CDSRequestOptionsType = {
|
|
|
15
16
|
aci: string;
|
|
16
17
|
accessKey: string;
|
|
17
18
|
}>;
|
|
18
|
-
timeout: number;
|
|
19
19
|
returnAcisWithoutUaks: boolean;
|
|
20
20
|
};
|
|
21
21
|
export type CDSResponseEntryType<Aci, Pni> = {
|
|
@@ -34,22 +34,90 @@ export type ChatRequest = Readonly<{
|
|
|
34
34
|
body?: Uint8Array;
|
|
35
35
|
timeoutMillis?: number;
|
|
36
36
|
}>;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
type TokioAsyncContext = Wrapper<Native.TokioAsyncContext>;
|
|
38
|
+
type ConnectionManager = Wrapper<Native.ConnectionManager>;
|
|
39
|
+
/**
|
|
40
|
+
* Provides API methods to connect and communicate with the Chat Service.
|
|
41
|
+
* Before using either authenticated or unauthenticated channels,
|
|
42
|
+
* a corresponding `connect*` method must be called.
|
|
43
|
+
* It's also important to call {@link #disconnect()} method when the instance is no longer needed.
|
|
44
|
+
*/
|
|
45
|
+
export declare class ChatService {
|
|
46
|
+
private readonly asyncContext;
|
|
47
|
+
private readonly chatService;
|
|
48
|
+
constructor(asyncContext: TokioAsyncContext, connectionManager: ConnectionManager);
|
|
41
49
|
/**
|
|
42
|
-
*
|
|
50
|
+
* Initiates termination of the underlying connection to the Chat Service. After the service is
|
|
51
|
+
* disconnected, it will not attempt to automatically reconnect until you call
|
|
52
|
+
* {@link #connectAuthenticated()} and/or {@link #connectUnauthenticated()}.
|
|
53
|
+
*
|
|
54
|
+
* Note: the same instance of `ChatService` can be reused after `disconnect()` was
|
|
55
|
+
* called.
|
|
56
|
+
*/
|
|
57
|
+
disconnect(): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Initiates establishing of the underlying unauthenticated connection to the Chat Service. Once
|
|
60
|
+
* the service is connected, all the requests will be using the established connection. Also, if
|
|
61
|
+
* the connection is lost for any reason other than the call to {@link #disconnect()}, an
|
|
62
|
+
* automatic reconnect attempt will be made.
|
|
63
|
+
*/
|
|
64
|
+
connectUnauthenticated(): Promise<Native.ChatServiceDebugInfo>;
|
|
65
|
+
/**
|
|
66
|
+
* Initiates establishing of the underlying authenticated connection to the Chat Service. Once the
|
|
67
|
+
* service is connected, all the requests will be using the established connection. Also, if the
|
|
68
|
+
* connection is lost for any reason other than the call to {@link #disconnect()}, an automatic
|
|
69
|
+
* reconnect attempt will be made.
|
|
70
|
+
*
|
|
71
|
+
* Calling this method will result in starting to accept incoming requests from the Chat Service.
|
|
72
|
+
*/
|
|
73
|
+
connectAuthenticated(): Promise<Native.ChatServiceDebugInfo>;
|
|
74
|
+
/**
|
|
75
|
+
* Sends request to the Chat Service over an unauthenticated channel.
|
|
76
|
+
*
|
|
77
|
+
* In addition to the response, an object containing debug information about the request flow is
|
|
78
|
+
* returned.
|
|
79
|
+
*
|
|
80
|
+
* @throws {ChatServiceInactive} if you haven't called {@link #connectUnauthenticated()}.
|
|
43
81
|
*/
|
|
44
|
-
svr3: Svr3Client;
|
|
45
|
-
constructor(env: Environment);
|
|
46
|
-
disconnectChatService(): Promise<void>;
|
|
47
82
|
unauthenticatedFetchAndDebug(chatRequest: ChatRequest): Promise<Native.ResponseAndDebugInfo>;
|
|
48
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Sends request to the Chat Service over an unauthenticated channel.
|
|
85
|
+
*
|
|
86
|
+
* @throws {ChatServiceInactive} if you haven't called {@link #connectUnauthenticated()}.
|
|
87
|
+
*/
|
|
88
|
+
unauthenticatedFetch(chatRequest: ChatRequest): Promise<Native.ChatResponse>;
|
|
49
89
|
static buildHttpRequest(chatRequest: ChatRequest): {
|
|
50
90
|
_nativeHandle: Native.HttpRequest;
|
|
51
91
|
};
|
|
52
|
-
|
|
92
|
+
}
|
|
93
|
+
export declare class Net {
|
|
94
|
+
private readonly asyncContext;
|
|
95
|
+
private readonly connectionManager;
|
|
96
|
+
/**
|
|
97
|
+
* Instance of the {@link Svr3Client} to access SVR3.
|
|
98
|
+
*/
|
|
99
|
+
svr3: Svr3Client;
|
|
100
|
+
constructor(env: Environment);
|
|
101
|
+
/**
|
|
102
|
+
* Creates a new instance of {@link ChatService}.
|
|
103
|
+
*/
|
|
104
|
+
newChatService(): ChatService;
|
|
105
|
+
/**
|
|
106
|
+
* Sets the proxy host to be used for all new connections (until overridden).
|
|
107
|
+
*
|
|
108
|
+
* Sets a domain name and port to be used to proxy all new outgoing
|
|
109
|
+
* connections. The proxy can be overridden by calling this method again or
|
|
110
|
+
* unset by calling {@link #clearProxy}.
|
|
111
|
+
*/
|
|
112
|
+
setProxy(host: string, port: number): void;
|
|
113
|
+
/**
|
|
114
|
+
* Ensures that future connections will be made directly, not through a proxy.
|
|
115
|
+
*
|
|
116
|
+
* Clears any proxy configuration set via {@link #setProxy}. If none was set, calling this
|
|
117
|
+
* method is a no-op.
|
|
118
|
+
*/
|
|
119
|
+
clearProxy(): void;
|
|
120
|
+
cdsiLookup({ username, password }: Readonly<ServiceAuth>, { e164s, acisAndAccessKeys, returnAcisWithoutUaks, }: ReadonlyDeep<CDSRequestOptionsType>): Promise<CDSResponseType<string, string>>;
|
|
53
121
|
}
|
|
54
122
|
/**
|
|
55
123
|
* This interface provides functionality for communicating with SVR3
|
|
@@ -67,8 +135,8 @@ export declare class Net {
|
|
|
67
135
|
* // Instantiate ServiceAuth with the username and password obtained from the Chat Server.
|
|
68
136
|
* const auth = { username: USERNAME, password: ENCLAVE_PASSWORD };
|
|
69
137
|
* // Store a value in SVR3. Here 10 is the number of permitted restore attempts.
|
|
70
|
-
* const shareSet = await SVR3.backup(SECRET_TO_BE_STORED, PASSWORD, 10, auth
|
|
71
|
-
* const restoredSecret = await SVR3.restore( PASSWORD, shareSet, auth
|
|
138
|
+
* const shareSet = await SVR3.backup(SECRET_TO_BE_STORED, PASSWORD, 10, auth);
|
|
139
|
+
* const restoredSecret = await SVR3.restore( PASSWORD, shareSet, auth);
|
|
72
140
|
* ```
|
|
73
141
|
*/
|
|
74
142
|
export interface Svr3Client {
|
|
@@ -89,8 +157,6 @@ export interface Svr3Client {
|
|
|
89
157
|
* generally good for about 15 minutes, therefore it can be reused for the
|
|
90
158
|
* subsequent calls to either backup or restore that are not too far apart in
|
|
91
159
|
* time.
|
|
92
|
-
* @param opTimeoutMs - The maximum wall time libsignal is allowed to spend
|
|
93
|
-
* communicating with SVR3 service.
|
|
94
160
|
* @returns A `Promise` which--when awaited--will return a byte array with a
|
|
95
161
|
* serialized masked share set. It is supposed to be an opaque blob for the
|
|
96
162
|
* clients and therefore no assumptions should be made about its contents.
|
|
@@ -98,15 +164,16 @@ export interface Svr3Client {
|
|
|
98
164
|
* secret along with the password. Please note that masked share set does not
|
|
99
165
|
* have to be treated as secret.
|
|
100
166
|
*
|
|
101
|
-
* The returned `Promise` can also fail due to the network issues (including
|
|
102
|
-
* timeout), problems establishing the Noise connection to the
|
|
103
|
-
* invalid arguments' values. {@link IoError} errors can, in
|
|
104
|
-
* retried, although there is already a retry-with-backoff
|
|
105
|
-
* libsignal used to connect to the SVR3 servers. Other
|
|
106
|
-
* by the bad input or data missing on the server. They
|
|
107
|
-
* non-actionable and are guaranteed to be thrown again when
|
|
167
|
+
* The returned `Promise` can also fail due to the network issues (including a
|
|
168
|
+
* connection timeout), problems establishing the Noise connection to the
|
|
169
|
+
* enclaves, or invalid arguments' values. {@link IoError} errors can, in
|
|
170
|
+
* general, be retried, although there is already a retry-with-backoff
|
|
171
|
+
* mechanism inside libsignal used to connect to the SVR3 servers. Other
|
|
172
|
+
* exceptions are caused by the bad input or data missing on the server. They
|
|
173
|
+
* are therefore non-actionable and are guaranteed to be thrown again when
|
|
174
|
+
* retried.
|
|
108
175
|
*/
|
|
109
|
-
backup(what: Buffer, password: string, maxTries: number, auth: Readonly<ServiceAuth
|
|
176
|
+
backup(what: Buffer, password: string, maxTries: number, auth: Readonly<ServiceAuth>): Promise<Buffer>;
|
|
110
177
|
/**
|
|
111
178
|
* Restore a secret from SVR3.
|
|
112
179
|
*
|
|
@@ -122,18 +189,17 @@ export interface Svr3Client {
|
|
|
122
189
|
* generally good for about 15 minutes, therefore it can be reused for the
|
|
123
190
|
* subsequent calls to either backup or restore that are not too far apart in
|
|
124
191
|
* time.
|
|
125
|
-
* @param opTimeoutMs - The maximum wall time libsignal is allowed to spend
|
|
126
|
-
* communicating with SVR3 service.
|
|
127
192
|
* @returns A `Promise` which--when awaited--will return a byte array with the
|
|
128
193
|
* restored secret.
|
|
129
194
|
*
|
|
130
|
-
* The returned `Promise` can also fail due to the network issues (including
|
|
131
|
-
* timeout), problems establishing the Noise connection to the
|
|
132
|
-
* invalid arguments' values. {@link IoError} errors can, in
|
|
133
|
-
* retried, although there is already a retry-with-backoff
|
|
134
|
-
* libsignal used to connect to the SVR3 servers. Other
|
|
135
|
-
* by the bad input or data missing on the server. They
|
|
136
|
-
* non-actionable and are guaranteed to be thrown again when
|
|
195
|
+
* The returned `Promise` can also fail due to the network issues (including
|
|
196
|
+
* the connection timeout), problems establishing the Noise connection to the
|
|
197
|
+
* enclaves, or invalid arguments' values. {@link IoError} errors can, in
|
|
198
|
+
* general, be retried, although there is already a retry-with-backoff
|
|
199
|
+
* mechanism inside libsignal used to connect to the SVR3 servers. Other
|
|
200
|
+
* exceptions are caused by the bad input or data missing on the server. They
|
|
201
|
+
* are therefore non-actionable and are guaranteed to be thrown again when
|
|
202
|
+
* retried.
|
|
137
203
|
*
|
|
138
204
|
* - {@link SvrDataMissingError} is returned when the maximum restore attempts
|
|
139
205
|
* number has been exceeded or if the value has never been backed up.
|
|
@@ -144,5 +210,6 @@ export interface Svr3Client {
|
|
|
144
210
|
* masked share set fails, or when the server requests fail for reasons
|
|
145
211
|
* other than "maximum attempts exceeded".
|
|
146
212
|
*/
|
|
147
|
-
restore(password: string, shareSet: Buffer, auth: Readonly<ServiceAuth
|
|
213
|
+
restore(password: string, shareSet: Buffer, auth: Readonly<ServiceAuth>): Promise<Buffer>;
|
|
148
214
|
}
|
|
215
|
+
export {};
|
package/dist/net.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.Net = exports.Environment = void 0;
|
|
7
|
+
exports.Net = exports.ChatService = exports.Environment = void 0;
|
|
8
8
|
const Native = require("../Native");
|
|
9
9
|
const Address_1 = require("./Address");
|
|
10
10
|
const DEFAULT_CHAT_REQUEST_TIMEOUT_MILLIS = 5000;
|
|
@@ -14,25 +14,71 @@ var Environment;
|
|
|
14
14
|
Environment[Environment["Staging"] = 0] = "Staging";
|
|
15
15
|
Environment[Environment["Production"] = 1] = "Production";
|
|
16
16
|
})(Environment = exports.Environment || (exports.Environment = {}));
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
function newNativeHandle(handle) {
|
|
18
|
+
return {
|
|
19
|
+
_nativeHandle: handle,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Provides API methods to connect and communicate with the Chat Service.
|
|
24
|
+
* Before using either authenticated or unauthenticated channels,
|
|
25
|
+
* a corresponding `connect*` method must be called.
|
|
26
|
+
* It's also important to call {@link #disconnect()} method when the instance is no longer needed.
|
|
27
|
+
*/
|
|
28
|
+
class ChatService {
|
|
29
|
+
constructor(asyncContext, connectionManager) {
|
|
30
|
+
this.asyncContext = asyncContext;
|
|
31
|
+
this.chatService = newNativeHandle(Native.ChatService_new(connectionManager, '', ''));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Initiates termination of the underlying connection to the Chat Service. After the service is
|
|
35
|
+
* disconnected, it will not attempt to automatically reconnect until you call
|
|
36
|
+
* {@link #connectAuthenticated()} and/or {@link #connectUnauthenticated()}.
|
|
37
|
+
*
|
|
38
|
+
* Note: the same instance of `ChatService` can be reused after `disconnect()` was
|
|
39
|
+
* called.
|
|
40
|
+
*/
|
|
41
|
+
async disconnect() {
|
|
42
|
+
await Native.ChatService_disconnect(this.asyncContext, this.chatService);
|
|
27
43
|
}
|
|
28
|
-
|
|
29
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Initiates establishing of the underlying unauthenticated connection to the Chat Service. Once
|
|
46
|
+
* the service is connected, all the requests will be using the established connection. Also, if
|
|
47
|
+
* the connection is lost for any reason other than the call to {@link #disconnect()}, an
|
|
48
|
+
* automatic reconnect attempt will be made.
|
|
49
|
+
*/
|
|
50
|
+
async connectUnauthenticated() {
|
|
51
|
+
return await Native.ChatService_connect_unauth(this.asyncContext, this.chatService);
|
|
30
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Initiates establishing of the underlying authenticated connection to the Chat Service. Once the
|
|
55
|
+
* service is connected, all the requests will be using the established connection. Also, if the
|
|
56
|
+
* connection is lost for any reason other than the call to {@link #disconnect()}, an automatic
|
|
57
|
+
* reconnect attempt will be made.
|
|
58
|
+
*
|
|
59
|
+
* Calling this method will result in starting to accept incoming requests from the Chat Service.
|
|
60
|
+
*/
|
|
61
|
+
async connectAuthenticated() {
|
|
62
|
+
return await Native.ChatService_connect_auth(this.asyncContext, this.chatService);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Sends request to the Chat Service over an unauthenticated channel.
|
|
66
|
+
*
|
|
67
|
+
* In addition to the response, an object containing debug information about the request flow is
|
|
68
|
+
* returned.
|
|
69
|
+
*
|
|
70
|
+
* @throws {ChatServiceInactive} if you haven't called {@link #connectUnauthenticated()}.
|
|
71
|
+
*/
|
|
31
72
|
async unauthenticatedFetchAndDebug(chatRequest) {
|
|
32
|
-
return await Native.ChatService_unauth_send_and_debug(this.
|
|
73
|
+
return await Native.ChatService_unauth_send_and_debug(this.asyncContext, this.chatService, ChatService.buildHttpRequest(chatRequest), chatRequest.timeoutMillis ?? DEFAULT_CHAT_REQUEST_TIMEOUT_MILLIS);
|
|
33
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Sends request to the Chat Service over an unauthenticated channel.
|
|
77
|
+
*
|
|
78
|
+
* @throws {ChatServiceInactive} if you haven't called {@link #connectUnauthenticated()}.
|
|
79
|
+
*/
|
|
34
80
|
async unauthenticatedFetch(chatRequest) {
|
|
35
|
-
return await Native.ChatService_unauth_send(this.
|
|
81
|
+
return await Native.ChatService_unauth_send(this.asyncContext, this.chatService, ChatService.buildHttpRequest(chatRequest), chatRequest.timeoutMillis ?? DEFAULT_CHAT_REQUEST_TIMEOUT_MILLIS);
|
|
36
82
|
}
|
|
37
83
|
static buildHttpRequest(chatRequest) {
|
|
38
84
|
const { verb, path, body, headers } = chatRequest;
|
|
@@ -46,8 +92,41 @@ class Net {
|
|
|
46
92
|
});
|
|
47
93
|
return httpRequest;
|
|
48
94
|
}
|
|
49
|
-
|
|
50
|
-
|
|
95
|
+
}
|
|
96
|
+
exports.ChatService = ChatService;
|
|
97
|
+
class Net {
|
|
98
|
+
constructor(env) {
|
|
99
|
+
this.asyncContext = newNativeHandle(Native.TokioAsyncContext_new());
|
|
100
|
+
this.connectionManager = newNativeHandle(Native.ConnectionManager_new(env));
|
|
101
|
+
this.svr3 = new Svr3ClientImpl(this.asyncContext, this.connectionManager);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Creates a new instance of {@link ChatService}.
|
|
105
|
+
*/
|
|
106
|
+
newChatService() {
|
|
107
|
+
return new ChatService(this.asyncContext, this.connectionManager);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Sets the proxy host to be used for all new connections (until overridden).
|
|
111
|
+
*
|
|
112
|
+
* Sets a domain name and port to be used to proxy all new outgoing
|
|
113
|
+
* connections. The proxy can be overridden by calling this method again or
|
|
114
|
+
* unset by calling {@link #clearProxy}.
|
|
115
|
+
*/
|
|
116
|
+
setProxy(host, port) {
|
|
117
|
+
Native.ConnectionManager_set_proxy(this.connectionManager, host, port);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Ensures that future connections will be made directly, not through a proxy.
|
|
121
|
+
*
|
|
122
|
+
* Clears any proxy configuration set via {@link #setProxy}. If none was set, calling this
|
|
123
|
+
* method is a no-op.
|
|
124
|
+
*/
|
|
125
|
+
clearProxy() {
|
|
126
|
+
Native.ConnectionManager_clear_proxy(this.connectionManager);
|
|
127
|
+
}
|
|
128
|
+
async cdsiLookup({ username, password }, { e164s, acisAndAccessKeys, returnAcisWithoutUaks, }) {
|
|
129
|
+
const request = newNativeHandle(Native.LookupRequest_new());
|
|
51
130
|
e164s.forEach((e164) => {
|
|
52
131
|
Native.LookupRequest_addE164(request, e164);
|
|
53
132
|
});
|
|
@@ -55,23 +134,21 @@ class Net {
|
|
|
55
134
|
Native.LookupRequest_addAciAndAccessKey(request, Address_1.Aci.parseFromServiceIdString(aciStr).getServiceIdFixedWidthBinary(), Buffer.from(accessKeyStr, 'base64'));
|
|
56
135
|
});
|
|
57
136
|
Native.LookupRequest_setReturnAcisWithoutUaks(request, returnAcisWithoutUaks);
|
|
58
|
-
const lookup = await Native.CdsiLookup_new(this.
|
|
59
|
-
return await Native.CdsiLookup_complete(this.
|
|
60
|
-
_nativeHandle: lookup,
|
|
61
|
-
});
|
|
137
|
+
const lookup = await Native.CdsiLookup_new(this.asyncContext, this.connectionManager, username, password, request);
|
|
138
|
+
return await Native.CdsiLookup_complete(this.asyncContext, newNativeHandle(lookup));
|
|
62
139
|
}
|
|
63
140
|
}
|
|
64
141
|
exports.Net = Net;
|
|
65
142
|
class Svr3ClientImpl {
|
|
66
|
-
constructor(
|
|
67
|
-
this.
|
|
68
|
-
this.
|
|
143
|
+
constructor(asyncContext, connectionManager) {
|
|
144
|
+
this.asyncContext = asyncContext;
|
|
145
|
+
this.connectionManager = connectionManager;
|
|
69
146
|
}
|
|
70
|
-
async backup(what, password, maxTries, auth
|
|
71
|
-
return Native.Svr3Backup(this.
|
|
147
|
+
async backup(what, password, maxTries, auth) {
|
|
148
|
+
return Native.Svr3Backup(this.asyncContext, this.connectionManager, what, password, maxTries, auth.username, auth.password);
|
|
72
149
|
}
|
|
73
|
-
async restore(password, shareSet, auth
|
|
74
|
-
return Native.Svr3Restore(this.
|
|
150
|
+
async restore(password, shareSet, auth) {
|
|
151
|
+
return Native.Svr3Restore(this.asyncContext, this.connectionManager, password, shareSet, auth.username, auth.password);
|
|
75
152
|
}
|
|
76
153
|
}
|
|
77
154
|
//# sourceMappingURL=net.js.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const UNCHECKED_AND_UNCLONED: unique symbol;
|
|
3
3
|
export default class ByteArray {
|
|
4
4
|
contents: Buffer;
|
|
5
|
-
constructor(contents: Buffer, checkValid: ((contents: Buffer) => void) | typeof UNCHECKED_AND_UNCLONED);
|
|
5
|
+
protected constructor(contents: Buffer, checkValid: ((contents: Buffer) => void) | typeof UNCHECKED_AND_UNCLONED);
|
|
6
6
|
protected static checkLength(expectedLength: number): (contents: Buffer) => void;
|
|
7
7
|
getContents(): Buffer;
|
|
8
8
|
serialize(): Buffer;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.UNCHECKED_AND_UNCLONED = void 0;
|
|
8
8
|
const Errors_1 = require("../../Errors");
|
|
9
|
+
const Native = require("../../../Native");
|
|
9
10
|
exports.UNCHECKED_AND_UNCLONED = Symbol();
|
|
10
11
|
class ByteArray {
|
|
11
12
|
constructor(contents, checkValid) {
|
|
@@ -13,7 +14,7 @@ class ByteArray {
|
|
|
13
14
|
this.contents = contents;
|
|
14
15
|
}
|
|
15
16
|
else {
|
|
16
|
-
checkValid(contents);
|
|
17
|
+
checkValid.call(Native, contents);
|
|
17
18
|
this.contents = Buffer.from(contents);
|
|
18
19
|
}
|
|
19
20
|
}
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|