project: Move to ESM Modules
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
/* @ts-ignore */
|
||||
import { decrypt, encrypt } from 'libsignal/src/crypto'
|
||||
import queueJob from './queue-job'
|
||||
import { SenderKeyMessage } from './sender-key-message'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as nodeCrypto from 'crypto'
|
||||
/* @ts-ignore */
|
||||
import { generateKeyPair } from 'libsignal/src/curve'
|
||||
|
||||
type KeyPairType = ReturnType<typeof generateKeyPair>
|
||||
|
||||
@@ -13,7 +13,7 @@ async function _asyncQueueExecutor(queue: Array<QueueJob<any>>, cleanup: () => v
|
||||
while (true) {
|
||||
const limit = Math.min(queue.length, _gcLimit)
|
||||
for (let i = offt; i < limit; i++) {
|
||||
const job = queue[i]
|
||||
const job = queue[i]!
|
||||
try {
|
||||
job.resolve(await job.awaitable())
|
||||
} catch (e) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* @ts-ignore */
|
||||
import { calculateMAC } from 'libsignal/src/crypto'
|
||||
import { SenderMessageKey } from './sender-message-key'
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* @ts-ignore */
|
||||
import { calculateSignature, verifySignature } from 'libsignal/src/curve'
|
||||
import { proto } from '../../../WAProto'
|
||||
import { CiphertextMessage } from './ciphertext-message'
|
||||
@@ -27,7 +28,7 @@ export class SenderKeyMessage extends CiphertextMessage {
|
||||
super()
|
||||
|
||||
if (serialized) {
|
||||
const version = serialized[0]
|
||||
const version = serialized[0]!
|
||||
const message = serialized.slice(1, serialized.length - this.SIGNATURE_LENGTH)
|
||||
const signature = serialized.slice(-1 * this.SIGNATURE_LENGTH)
|
||||
const senderKeyMessage = proto.SenderKeyMessage.decode(message).toJSON() as SenderKeyMessageStructure
|
||||
|
||||
@@ -135,7 +135,7 @@ export class SenderKeyState {
|
||||
const index = this.senderKeyStateStructure.senderMessageKeys.findIndex(key => key.iteration === iteration)
|
||||
|
||||
if (index !== -1) {
|
||||
const messageKey = this.senderKeyStateStructure.senderMessageKeys[index]
|
||||
const messageKey = this.senderKeyStateStructure.senderMessageKeys[index]!
|
||||
this.senderKeyStateStructure.senderMessageKeys.splice(index, 1)
|
||||
return new SenderMessageKey(messageKey.iteration, messageKey.seed)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* @ts-ignore */
|
||||
import { deriveSecrets } from 'libsignal/src/crypto'
|
||||
|
||||
export class SenderMessageKey {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/* @ts-ignore */
|
||||
import * as libsignal from 'libsignal'
|
||||
import { SignalAuthState } from '../Types'
|
||||
import { SignalRepository } from '../Types/Signal'
|
||||
import type { SignalAuthState } from '../Types'
|
||||
import type { SignalRepository } from '../Types/Signal'
|
||||
import { generateSignalPubKey } from '../Utils'
|
||||
import { jidDecode } from '../WABinary'
|
||||
import type { SenderKeyStore } from './Group/group_cipher'
|
||||
@@ -111,7 +112,8 @@ function signalStorage({ creds, keys }: SignalAuthState): SenderKeyStore & Recor
|
||||
return libsignal.SessionRecord.deserialize(sess)
|
||||
}
|
||||
},
|
||||
storeSession: async (id: string, session: libsignal.SessionRecord) => {
|
||||
// TODO: Replace with libsignal.SessionRecord when type exports are added to libsignal
|
||||
storeSession: async (id: string, session: any) => {
|
||||
await keys.set({ session: { [id]: session.serialize() } })
|
||||
},
|
||||
isTrustedIdentity: () => {
|
||||
|
||||
Reference in New Issue
Block a user