@signalapp/libsignal-client
Advanced tools
Comparing version 0.31.0 to 0.32.0
@@ -24,3 +24,5 @@ /// <reference types="node" /> | ||
_nativeHandle: Native.ValidatingMac; | ||
_validatedBytes: number; | ||
constructor(key: Buffer, sizeChoice: ChunkSizeChoice, digest: Buffer); | ||
validatedSize(): number; | ||
_write(chunk: any, _encoding: BufferEncoding, callback: (error?: Error | null) => void): void; | ||
@@ -27,0 +29,0 @@ _final(callback: (error?: Error | null) => void): void; |
@@ -48,4 +48,8 @@ "use strict"; | ||
super(); | ||
this._validatedBytes = 0; | ||
this._nativeHandle = Native.ValidatingMac_Initialize(key, chunkSizeInBytes(sizeChoice), digest); | ||
} | ||
validatedSize() { | ||
return this._validatedBytes; | ||
} | ||
_write( | ||
@@ -56,3 +60,5 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types | ||
const buffer = Buffer.from(chunk, 'binary'); | ||
if (Native.ValidatingMac_Update(this, buffer, 0, buffer.length)) { | ||
const validBytes = Native.ValidatingMac_Update(this, buffer, 0, buffer.length); | ||
if (validBytes >= 0) { | ||
this._validatedBytes += validBytes; | ||
callback(); | ||
@@ -65,3 +71,5 @@ } | ||
_final(callback) { | ||
if (Native.ValidatingMac_Finalize(this)) { | ||
const validBytes = Native.ValidatingMac_Finalize(this); | ||
if (validBytes >= 0) { | ||
this._validatedBytes += validBytes; | ||
callback(); | ||
@@ -68,0 +76,0 @@ } |
@@ -198,3 +198,8 @@ /// <reference types="node" /> | ||
remoteRegistrationId(): number; | ||
hasCurrentState(): boolean; | ||
/** | ||
* Returns whether the current session can be used to send messages. | ||
* | ||
* If there is no current session, returns false. | ||
*/ | ||
hasCurrentState(now?: Date): boolean; | ||
currentRatchetKeyMatches(key: PublicKey): boolean; | ||
@@ -378,4 +383,4 @@ } | ||
} | ||
export declare function processPreKeyBundle(bundle: PreKeyBundle, address: ProtocolAddress, sessionStore: SessionStore, identityStore: IdentityKeyStore): Promise<void>; | ||
export declare function signalEncrypt(message: Buffer, address: ProtocolAddress, sessionStore: SessionStore, identityStore: IdentityKeyStore): Promise<CiphertextMessage>; | ||
export declare function processPreKeyBundle(bundle: PreKeyBundle, address: ProtocolAddress, sessionStore: SessionStore, identityStore: IdentityKeyStore, now?: Date): Promise<void>; | ||
export declare function signalEncrypt(message: Buffer, address: ProtocolAddress, sessionStore: SessionStore, identityStore: IdentityKeyStore, now?: Date): Promise<CiphertextMessage>; | ||
export declare function signalDecrypt(message: SignalMessage, address: ProtocolAddress, sessionStore: SessionStore, identityStore: IdentityKeyStore): Promise<Buffer>; | ||
@@ -382,0 +387,0 @@ export declare function signalDecryptPreKey(message: PreKeySignalMessage, address: ProtocolAddress, sessionStore: SessionStore, identityStore: IdentityKeyStore, prekeyStore: PreKeyStore, signedPrekeyStore: SignedPreKeyStore, kyberPrekeyStore: KyberPreKeyStore): Promise<Buffer>; |
@@ -486,4 +486,9 @@ "use strict"; | ||
} | ||
hasCurrentState() { | ||
return Native.SessionRecord_HasCurrentState(this); | ||
/** | ||
* Returns whether the current session can be used to send messages. | ||
* | ||
* If there is no current session, returns false. | ||
*/ | ||
hasCurrentState(now = new Date()) { | ||
return Native.SessionRecord_HasUsableSenderChain(this, now.getTime()); | ||
} | ||
@@ -950,9 +955,9 @@ currentRatchetKeyMatches(key) { | ||
exports.DecryptionErrorMessage = DecryptionErrorMessage; | ||
function processPreKeyBundle(bundle, address, sessionStore, identityStore) { | ||
return Native.SessionBuilder_ProcessPreKeyBundle(bundle, address, sessionStore, identityStore); | ||
function processPreKeyBundle(bundle, address, sessionStore, identityStore, now = new Date()) { | ||
return Native.SessionBuilder_ProcessPreKeyBundle(bundle, address, sessionStore, identityStore, now.getTime()); | ||
} | ||
exports.processPreKeyBundle = processPreKeyBundle; | ||
function signalEncrypt(message, address, sessionStore, identityStore) { | ||
function signalEncrypt(message, address, sessionStore, identityStore, now = new Date()) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return CiphertextMessage._fromNativeHandle(yield Native.SessionCipher_EncryptMessage(message, address, sessionStore, identityStore)); | ||
return CiphertextMessage._fromNativeHandle(yield Native.SessionCipher_EncryptMessage(message, address, sessionStore, identityStore, now.getTime())); | ||
}); | ||
@@ -959,0 +964,0 @@ } |
@@ -316,6 +316,6 @@ // | ||
export function ServiceId_ServiceIdString(value: Buffer): string; | ||
export function SessionBuilder_ProcessPreKeyBundle(bundle: Wrapper<PreKeyBundle>, protocolAddress: Wrapper<ProtocolAddress>, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore): Promise<void>; | ||
export function SessionBuilder_ProcessPreKeyBundle(bundle: Wrapper<PreKeyBundle>, protocolAddress: Wrapper<ProtocolAddress>, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore, now: Timestamp): Promise<void>; | ||
export function SessionCipher_DecryptPreKeySignalMessage(message: Wrapper<PreKeySignalMessage>, protocolAddress: Wrapper<ProtocolAddress>, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore, prekeyStore: PreKeyStore, signedPrekeyStore: SignedPreKeyStore, kyberPrekeyStore: KyberPreKeyStore): Promise<Buffer>; | ||
export function SessionCipher_DecryptSignalMessage(message: Wrapper<SignalMessage>, protocolAddress: Wrapper<ProtocolAddress>, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore): Promise<Buffer>; | ||
export function SessionCipher_EncryptMessage(ptext: Buffer, protocolAddress: Wrapper<ProtocolAddress>, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore): Promise<CiphertextMessage>; | ||
export function SessionCipher_EncryptMessage(ptext: Buffer, protocolAddress: Wrapper<ProtocolAddress>, sessionStore: SessionStore, identityKeyStore: IdentityKeyStore, now: Timestamp): Promise<CiphertextMessage>; | ||
export function SessionRecord_ArchiveCurrentState(sessionRecord: Wrapper<SessionRecord>): void; | ||
@@ -326,3 +326,3 @@ export function SessionRecord_CurrentRatchetKeyMatches(s: Wrapper<SessionRecord>, key: Wrapper<PublicKey>): boolean; | ||
export function SessionRecord_GetRemoteRegistrationId(obj: Wrapper<SessionRecord>): number; | ||
export function SessionRecord_HasCurrentState(obj: Wrapper<SessionRecord>): boolean; | ||
export function SessionRecord_HasUsableSenderChain(s: Wrapper<SessionRecord>, now: Timestamp): boolean; | ||
export function SessionRecord_Serialize(obj: Wrapper<SessionRecord>): Buffer; | ||
@@ -364,5 +364,5 @@ export function SgxClientState_CompleteHandshake(cli: Wrapper<SgxClientState>, handshakeReceived: Buffer): void; | ||
export function UuidCiphertext_CheckValidContents(buffer: Buffer): void; | ||
export function ValidatingMac_Finalize(mac: Wrapper<ValidatingMac>): boolean; | ||
export function ValidatingMac_Finalize(mac: Wrapper<ValidatingMac>): number; | ||
export function ValidatingMac_Initialize(key: Buffer, chunkSize: number, digests: Buffer): ValidatingMac; | ||
export function ValidatingMac_Update(mac: Wrapper<ValidatingMac>, bytes: Buffer, offset: number, length: number): boolean; | ||
export function ValidatingMac_Update(mac: Wrapper<ValidatingMac>, bytes: Buffer, offset: number, length: number): number; | ||
export function initLogger(maxLevel: LogLevel, callback: (level: LogLevel, target: string, file: string | null, line: number | null, message: string) => void): void | ||
@@ -369,0 +369,0 @@ interface Aes256GcmSiv { readonly __type: unique symbol; } |
{ | ||
"name": "@signalapp/libsignal-client", | ||
"version": "0.31.0", | ||
"version": "0.32.0", | ||
"license": "AGPL-3.0-only", | ||
@@ -5,0 +5,0 @@ "main": "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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37106437
4433