Files
libsignal/node/Address.ts
Jordan Rose 8c5b6af3fa Sealed sender v2: add an InvalidRegistrationId exception/error
This dedicated error is thrown when a recipient has a registration ID
that's out of the range used by Signal [0, 0x3FFF]. These IDs cannot
be encoded in the sealed sender v2 format and are not supported, even
though they don't cause any problems for 1:1 messages.
2021-08-31 13:11:10 -07:00

35 lines
923 B
TypeScript

//
// Copyright 2021 Signal Messenger, LLC.
// SPDX-License-Identifier: AGPL-3.0-only
//
import * as Native from './Native';
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
const NativeImpl = require('node-gyp-build')(
__dirname + '/../..'
) as typeof Native;
export class ProtocolAddress {
readonly _nativeHandle: Native.ProtocolAddress;
private constructor(handle: Native.ProtocolAddress) {
this._nativeHandle = handle;
}
static _fromNativeHandle(handle: Native.ProtocolAddress): ProtocolAddress {
return new ProtocolAddress(handle);
}
static new(name: string, deviceId: number): ProtocolAddress {
return new ProtocolAddress(NativeImpl.ProtocolAddress_New(name, deviceId));
}
name(): string {
return NativeImpl.ProtocolAddress_Name(this);
}
deviceId(): number {
return NativeImpl.ProtocolAddress_DeviceId(this);
}
}