@signalapp/signal-client
Advanced tools
Comparing version 0.8.4 to 0.9.0
@@ -0,1 +1,3 @@ | ||
import { ProtocolAddress } from './Address'; | ||
import * as Native from './Native'; | ||
export declare enum ErrorCode { | ||
@@ -5,3 +7,4 @@ Generic = 0, | ||
SealedSenderSelfSend = 2, | ||
UntrustedIdentity = 3 | ||
UntrustedIdentity = 3, | ||
InvalidRegistrationId = 4 | ||
} | ||
@@ -11,17 +14,24 @@ export declare class SignalClientErrorBase extends Error { | ||
readonly operation: string; | ||
readonly _addr?: string | Native.ProtocolAddress; | ||
constructor(message: string, name: keyof typeof ErrorCode | undefined, operation: string, extraProps?: Record<string, unknown>); | ||
get addr(): ProtocolAddress | string; | ||
} | ||
export declare type GenericError = SignalClientErrorBase & { | ||
export declare type SignalClientErrorCommon = Omit<SignalClientErrorBase, 'addr'>; | ||
export declare type GenericError = SignalClientErrorCommon & { | ||
code: ErrorCode.Generic; | ||
}; | ||
export declare type DuplicatedMessageError = SignalClientErrorBase & { | ||
export declare type DuplicatedMessageError = SignalClientErrorCommon & { | ||
code: ErrorCode.DuplicatedMessage; | ||
}; | ||
export declare type SealedSenderSelfSendError = SignalClientErrorBase & { | ||
export declare type SealedSenderSelfSendError = SignalClientErrorCommon & { | ||
code: ErrorCode.SealedSenderSelfSend; | ||
}; | ||
export declare type UntrustedIdentityError = SignalClientErrorBase & { | ||
export declare type UntrustedIdentityError = SignalClientErrorCommon & { | ||
code: ErrorCode.UntrustedIdentity; | ||
addr: string; | ||
}; | ||
export declare type SignalClientError = GenericError | DuplicatedMessageError | SealedSenderSelfSendError | UntrustedIdentityError; | ||
export declare type InvalidRegistrationIdError = SignalClientErrorCommon & { | ||
code: ErrorCode.InvalidRegistrationId; | ||
addr: ProtocolAddress; | ||
}; | ||
export declare type SignalClientError = GenericError | DuplicatedMessageError | SealedSenderSelfSendError | UntrustedIdentityError | InvalidRegistrationIdError; |
@@ -7,2 +7,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const Address_1 = require("./Address"); | ||
var ErrorCode; | ||
@@ -14,2 +15,3 @@ (function (ErrorCode) { | ||
ErrorCode[ErrorCode["UntrustedIdentity"] = 3] = "UntrustedIdentity"; | ||
ErrorCode[ErrorCode["InvalidRegistrationId"] = 4] = "InvalidRegistrationId"; | ||
})(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {})); | ||
@@ -38,4 +40,14 @@ class SignalClientErrorBase extends Error { | ||
} | ||
get addr() { | ||
switch (this.code) { | ||
case ErrorCode.UntrustedIdentity: | ||
return this._addr; | ||
case ErrorCode.InvalidRegistrationId: | ||
return Address_1.ProtocolAddress._fromNativeHandle(this._addr); | ||
default: | ||
throw new TypeError(`cannot get address from this error (${this})`); | ||
} | ||
} | ||
} | ||
exports.SignalClientErrorBase = SignalClientErrorBase; | ||
//# sourceMappingURL=Errors.js.map |
/// <reference types="node" /> | ||
export * from './Errors'; | ||
import { ProtocolAddress } from './Address'; | ||
export * from './Address'; | ||
import * as Native from './Native'; | ||
@@ -54,10 +56,2 @@ export declare const initLogger: typeof Native.initLogger, LogLevel: typeof Native.LogLevel; | ||
} | ||
export declare class ProtocolAddress { | ||
readonly _nativeHandle: Native.ProtocolAddress; | ||
private constructor(); | ||
static _fromNativeHandle(handle: Native.ProtocolAddress): ProtocolAddress; | ||
static new(name: string, deviceId: number): ProtocolAddress; | ||
name(): string; | ||
deviceId(): number; | ||
} | ||
export declare class PublicKey { | ||
@@ -64,0 +58,0 @@ readonly _nativeHandle: Native.PublicKey; |
@@ -22,2 +22,4 @@ "use strict"; | ||
__export(require("./Errors")); | ||
const Address_1 = require("./Address"); | ||
__export(require("./Address")); | ||
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires | ||
@@ -96,20 +98,2 @@ const NativeImpl = require('node-gyp-build')(__dirname + '/../..'); | ||
exports.Aes256GcmSiv = Aes256GcmSiv; | ||
class ProtocolAddress { | ||
constructor(handle) { | ||
this._nativeHandle = handle; | ||
} | ||
static _fromNativeHandle(handle) { | ||
return new ProtocolAddress(handle); | ||
} | ||
static new(name, deviceId) { | ||
return new ProtocolAddress(NativeImpl.ProtocolAddress_New(name, deviceId)); | ||
} | ||
name() { | ||
return NativeImpl.ProtocolAddress_Name(this); | ||
} | ||
deviceId() { | ||
return NativeImpl.ProtocolAddress_DeviceId(this); | ||
} | ||
} | ||
exports.ProtocolAddress = ProtocolAddress; | ||
class PublicKey { | ||
@@ -563,3 +547,3 @@ constructor(handle) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.saveSession(ProtocolAddress._fromNativeHandle(name), SessionRecord._fromNativeHandle(record)); | ||
return this.saveSession(Address_1.ProtocolAddress._fromNativeHandle(name), SessionRecord._fromNativeHandle(record)); | ||
}); | ||
@@ -569,3 +553,3 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const sess = yield this.getSession(ProtocolAddress._fromNativeHandle(name)); | ||
const sess = yield this.getSession(Address_1.ProtocolAddress._fromNativeHandle(name)); | ||
if (sess == null) { | ||
@@ -595,3 +579,3 @@ return null; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.saveIdentity(ProtocolAddress._fromNativeHandle(name), PublicKey._fromNativeHandle(key)); | ||
return this.saveIdentity(Address_1.ProtocolAddress._fromNativeHandle(name), PublicKey._fromNativeHandle(key)); | ||
}); | ||
@@ -602,3 +586,3 @@ } | ||
const direction = sending ? 0 /* Sending */ : 1 /* Receiving */; | ||
return this.isTrustedIdentity(ProtocolAddress._fromNativeHandle(name), PublicKey._fromNativeHandle(key), direction); | ||
return this.isTrustedIdentity(Address_1.ProtocolAddress._fromNativeHandle(name), PublicKey._fromNativeHandle(key), direction); | ||
}); | ||
@@ -608,3 +592,3 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const key = yield this.getIdentity(ProtocolAddress._fromNativeHandle(name)); | ||
const key = yield this.getIdentity(Address_1.ProtocolAddress._fromNativeHandle(name)); | ||
if (key == null) { | ||
@@ -656,3 +640,3 @@ return Promise.resolve(null); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.saveSenderKey(ProtocolAddress._fromNativeHandle(sender), uuid.stringify(distributionId), SenderKeyRecord._fromNativeHandle(record)); | ||
return this.saveSenderKey(Address_1.ProtocolAddress._fromNativeHandle(sender), uuid.stringify(distributionId), SenderKeyRecord._fromNativeHandle(record)); | ||
}); | ||
@@ -662,3 +646,3 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const skr = yield this.getSenderKey(ProtocolAddress._fromNativeHandle(sender), uuid.stringify(distributionId)); | ||
const skr = yield this.getSenderKey(Address_1.ProtocolAddress._fromNativeHandle(sender), uuid.stringify(distributionId)); | ||
if (skr == null) { | ||
@@ -665,0 +649,0 @@ return null; |
{ | ||
"name": "@signalapp/signal-client", | ||
"version": "0.8.4", | ||
"version": "0.9.0", | ||
"license": "AGPL-3.0-only", | ||
@@ -5,0 +5,0 @@ "main": "node/dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
8106265
13
1455