@neelegirl/baileys 2.1.8 → 2.2.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.
@@ -1 +1 @@
1
- {"version":[2,3000,1035194821]}
1
+ {"version":[2,3000,1032141294]}
@@ -1,28 +1,19 @@
1
- import { proto } from '../../WAProto'
1
+ import { proto } from '../../WAProto'
2
2
  import type { MediaType, SocketConfig } from '../Types'
3
3
 
4
4
  export declare const UNAUTHORIZED_CODES: number[]
5
5
 
6
6
  export declare const PHONENUMBER_MCC: Record<string, number>
7
7
 
8
- export declare const DEFAULT_ORIGIN: 'https://web.whatsapp.com'
8
+ export declare const DEFAULT_ORIGIN: "https://web.whatsapp.com"
9
9
 
10
- export declare const CALL_VIDEO_PREFIX: 'https://call.whatsapp.com/video/'
11
- export declare const CALL_AUDIO_PREFIX: 'https://call.whatsapp.com/voice/'
12
-
13
- export declare const DEF_CALLBACK_PREFIX: 'CB:'
14
- export declare const DEF_TAG_PREFIX: 'TAG:'
15
- export declare const PHONE_CONNECTION_CB: 'CB:Pong'
16
-
17
- export declare const WA_ADV_ACCOUNT_SIG_PREFIX: Buffer
18
- export declare const WA_ADV_DEVICE_SIG_PREFIX: Buffer
19
- export declare const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX: Buffer
20
- export declare const WA_ADV_HOSTED_DEVICE_SIG_PREFIX: Buffer
10
+ export declare const DEF_CALLBACK_PREFIX: "CB:"
11
+ export declare const DEF_TAG_PREFIX: "TAG:"
12
+ export declare const PHONE_CONNECTION_CB: "CB:Pong"
21
13
 
22
14
  export declare const WA_DEFAULT_EPHEMERAL: number
23
- export declare const STATUS_EXPIRY_SECONDS: number
24
15
 
25
- export declare const NOISE_MODE: 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0'
16
+ export declare const NOISE_MODE: "Noise_XX_25519_AESGCM_SHA256\0\0\0\0"
26
17
 
27
18
  export declare const DICT_VERSION: 3
28
19
 
@@ -33,8 +24,6 @@ export declare const URL_REGEX: RegExp
33
24
 
34
25
  export declare const WA_CERT_DETAILS: {
35
26
  SERIAL: number
36
- ISSUER: string
37
- PUBLIC_KEY: Buffer
38
27
  }
39
28
 
40
29
  export declare const PROCESSABLE_HISTORY_TYPES: proto.Message.HistorySyncNotification.HistorySyncType[]
@@ -46,16 +35,15 @@ export declare const MEDIA_PATH_MAP: {
46
35
  }
47
36
 
48
37
  export declare const MEDIA_HKDF_KEY_MAPPING: {
49
- audio: string
50
- document: string
51
- gif: string
52
- image: string
53
- ppic: string
54
- product: string
55
- ptt: string
56
- video: string
57
- sticker: string
58
- 'sticker-pack': string
38
+ 'audio': string
39
+ 'document': string
40
+ 'gif': string
41
+ 'image': string
42
+ 'ppic': string
43
+ 'product': string
44
+ 'ptt': string
45
+ 'sticker': string
46
+ 'video': string
59
47
  'thumbnail-document': string
60
48
  'thumbnail-image': string
61
49
  'thumbnail-video': string
@@ -64,18 +52,17 @@ export declare const MEDIA_HKDF_KEY_MAPPING: {
64
52
  'md-app-state': string
65
53
  'product-catalog-image': string
66
54
  'payment-bg-image': string
67
- ptv: string
68
- 'biz-cover-photo': string
55
+ 'ptv': string
69
56
  }
70
57
 
71
58
  export declare const MEDIA_KEYS: (keyof typeof MEDIA_HKDF_KEY_MAPPING)[]
72
59
 
73
60
  export declare const MIN_PREKEY_COUNT: 5
74
- export declare const INITIAL_PREKEY_COUNT: 812
61
+ export declare const INITIAL_PREKEY_COUNT: 30
75
62
 
76
63
  export declare const DEFAULT_CACHE_TTLS: {
77
64
  SIGNAL_STORE: number
78
65
  MSG_RETRY: number
79
66
  CALL_OFFER: number
80
67
  USER_DEVICES: number
81
- }
68
+ }
@@ -1,9 +1,4 @@
1
- import { LIDMapping, SignalAuthState } from '../Types'
2
- import { SignalRepositoryWithLIDStore } from '../Types/Signal'
3
- import type { ILogger } from '../Utils/logger'
1
+ import { SignalAuthState } from '../Types'
2
+ import { SignalRepository } from '../Types/Signal'
4
3
 
5
- export declare function makeLibSignalRepository(
6
- auth: SignalAuthState,
7
- logger: ILogger,
8
- pnToLIDFunc?: (jids: string[]) => Promise<LIDMapping[] | undefined>
9
- ): SignalRepositoryWithLIDStore
4
+ export declare function makeLibSignalRepository(auth: SignalAuthState): SignalRepository
@@ -1,332 +1,123 @@
1
1
  "use strict"
2
2
 
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k
5
+ var desc = Object.getOwnPropertyDescriptor(m, k)
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k] } }
8
+ }
9
+ Object.defineProperty(o, k2, desc)
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k
12
+ o[k2] = m[k]
13
+ }))
14
+
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v })
17
+ }) : function(o, v) {
18
+ o["default"] = v
19
+ })
20
+
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod
23
+ var result = {}
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k)
25
+ __setModuleDefault(result, mod)
26
+ return result
27
+ }
3
28
  Object.defineProperty(exports, "__esModule", { value: true })
4
29
 
5
- const libsignal = require("@neelegirl/libsignal")
6
- const { PreKeyWhisperMessage } = require("@neelegirl/libsignal/src/protobufs")
7
- const LRUCacheModule = require("lru-cache")
8
- const LRUCache = LRUCacheModule.LRUCache || LRUCacheModule
30
+ const libsignal = __importStar(require("@neelegirl/libsignal"))
9
31
  const WASignalGroup_1 = require("./WASignalGroup")
10
- const lid_mapping_1 = require("./lid-mapping")
11
32
  const Utils_1 = require("../Utils")
12
33
  const WABinary_1 = require("../WABinary")
13
34
 
14
- function extractIdentityFromPkmsg(ciphertext) {
15
- try {
16
- if (!ciphertext || ciphertext.length < 2) {
17
- return undefined
18
- }
19
- const version = ciphertext[0]
20
- if ((version & 0xf) !== 3) {
21
- return undefined
22
- }
23
- const preKeyProto = PreKeyWhisperMessage.decode(ciphertext.slice(1))
24
- if (preKeyProto.identityKey?.length === 33) {
25
- return new Uint8Array(preKeyProto.identityKey)
26
- }
27
- }
28
- catch (_error) { }
29
- }
30
-
31
- function makeLibSignalRepository(auth, logger, pnToLIDFunc) {
32
- const parsedKeys = auth.keys
33
- const lidMapping = new lid_mapping_1.LIDMappingStore(parsedKeys, logger, pnToLIDFunc)
34
- const storage = signalStorage(auth, lidMapping)
35
- const migratedSessionCache = new LRUCache({
36
- ttl: 3 * 24 * 60 * 60 * 1000,
37
- ttlAutopurge: true,
38
- updateAgeOnGet: true
39
- })
40
- const repository = {
35
+ function makeLibSignalRepository(auth) {
36
+ const storage = signalStorage(auth)
37
+ return {
41
38
  decryptGroupMessage({ group, authorJid, msg }) {
42
39
  const senderName = jidToSignalSenderKeyName(group, authorJid)
43
40
  const cipher = new WASignalGroup_1.GroupCipher(storage, senderName)
44
- return parsedKeys.transaction(async () => {
45
- return cipher.decrypt(msg)
46
- }, group)
41
+ return cipher.decrypt(msg)
47
42
  },
48
43
  async processSenderKeyDistributionMessage({ item, authorJid }) {
49
- if (!item.groupId) {
50
- throw new Error('group ID is required for sender key distribution message')
51
- }
52
44
  const builder = new WASignalGroup_1.GroupSessionBuilder(storage)
53
45
  const senderName = jidToSignalSenderKeyName(item.groupId, authorJid)
54
- const senderNameStr = senderName.toString()
55
- const senderMsg = new WASignalGroup_1.SenderKeyDistributionMessage(
56
- null,
57
- null,
58
- null,
59
- null,
60
- item.axolotlSenderKeyDistributionMessage
61
- )
62
- return parsedKeys.transaction(async () => {
63
- const { [senderNameStr]: senderKey } = await auth.keys.get('sender-key', [senderNameStr])
64
- if (!senderKey) {
65
- await storage.storeSenderKey(senderName, new WASignalGroup_1.SenderKeyRecord())
66
- }
67
- await builder.process(senderName, senderMsg)
68
- }, item.groupId)
46
+ const senderMsg = new WASignalGroup_1.SenderKeyDistributionMessage(null, null, null, null, item.axolotlSenderKeyDistributionMessage)
47
+ const { [senderName]: senderKey } = await auth.keys.get('sender-key', [senderName])
48
+ if (!senderKey) {
49
+ await storage.storeSenderKey(senderName, new WASignalGroup_1.SenderKeyRecord())
50
+ }
51
+ await builder.process(senderName, senderMsg)
69
52
  },
70
53
  async decryptMessage({ jid, type, ciphertext }) {
71
54
  const addr = jidToSignalProtocolAddress(jid)
72
55
  const session = new libsignal.SessionCipher(storage, addr)
73
- if (type === 'pkmsg') {
74
- const identityKey = extractIdentityFromPkmsg(ciphertext)
75
- if (identityKey) {
76
- const addrStr = addr.toString()
77
- const identityChanged = await storage.saveIdentity(addrStr, identityKey)
78
- if (identityChanged) {
79
- logger?.info?.({ jid, addr: addrStr }, 'identity key changed or contact was first seen')
80
- }
81
- }
56
+ let result
57
+ switch (type) {
58
+ case 'pkmsg':
59
+ result = await session.decryptPreKeyWhisperMessage(ciphertext)
60
+ break
61
+ case 'msg':
62
+ result = await session.decryptWhisperMessage(ciphertext)
63
+ break
82
64
  }
83
- return parsedKeys.transaction(async () => {
84
- switch (type) {
85
- case 'pkmsg':
86
- return session.decryptPreKeyWhisperMessage(ciphertext)
87
- case 'msg':
88
- default:
89
- return session.decryptWhisperMessage(ciphertext)
90
- }
91
- }, jid)
65
+ return result
92
66
  },
93
67
  async encryptMessage({ jid, data }) {
94
68
  const addr = jidToSignalProtocolAddress(jid)
95
69
  const cipher = new libsignal.SessionCipher(storage, addr)
96
- return parsedKeys.transaction(async () => {
97
- const { type: sigType, body } = await cipher.encrypt(data)
98
- const type = sigType === 3 ? 'pkmsg' : 'msg'
99
- return {
100
- type,
101
- ciphertext: Buffer.from(body, 'binary')
102
- }
103
- }, jid)
70
+ const { type: sigType, body } = await cipher.encrypt(data)
71
+ const type = sigType === 3 ? 'pkmsg' : 'msg'
72
+ return { type, ciphertext: Buffer.from(body, 'binary') }
104
73
  },
105
74
  async encryptGroupMessage({ group, meId, data }) {
106
75
  const senderName = jidToSignalSenderKeyName(group, meId)
107
76
  const builder = new WASignalGroup_1.GroupSessionBuilder(storage)
108
- return parsedKeys.transaction(async () => {
109
- const senderKeyDistributionMessage = await builder.create(senderName)
110
- const session = new WASignalGroup_1.GroupCipher(storage, senderName)
111
- const ciphertext = await session.encrypt(data)
112
- return {
113
- ciphertext,
114
- senderKeyDistributionMessage: senderKeyDistributionMessage.serialize()
115
- }
116
- }, group)
77
+ const { [senderName]: senderKey } = await auth.keys.get('sender-key', [senderName])
78
+ if (!senderKey) {
79
+ await storage.storeSenderKey(senderName, new WASignalGroup_1.SenderKeyRecord())
80
+ }
81
+ const senderKeyDistributionMessage = await builder.create(senderName)
82
+ const session = new WASignalGroup_1.GroupCipher(storage, senderName)
83
+ const ciphertext = await session.encrypt(data)
84
+ return {
85
+ ciphertext,
86
+ senderKeyDistributionMessage: senderKeyDistributionMessage.serialize(),
87
+ }
117
88
  },
118
89
  async injectE2ESession({ jid, session }) {
119
- logger?.trace?.({ jid }, 'injecting E2EE session')
120
90
  const cipher = new libsignal.SessionBuilder(storage, jidToSignalProtocolAddress(jid))
121
- return parsedKeys.transaction(async () => {
122
- await cipher.initOutgoing(session)
123
- }, jid)
91
+ await cipher.initOutgoing(session)
124
92
  },
125
93
  jidToSignalProtocolAddress(jid) {
126
94
  return jidToSignalProtocolAddress(jid).toString()
127
95
  },
128
- lidMapping,
129
- async validateSession(jid) {
130
- try {
131
- const addr = jidToSignalProtocolAddress(jid)
132
- const session = await storage.loadSession(addr.toString())
133
- if (!session) {
134
- return { exists: false, reason: 'no session' }
135
- }
136
- if (!session.haveOpenSession()) {
137
- return { exists: false, reason: 'no open session' }
138
- }
139
- return { exists: true }
140
- }
141
- catch (_error) {
142
- return { exists: false, reason: 'validation error' }
143
- }
144
- },
145
- async deleteSession(jids) {
146
- if (!jids?.length) {
147
- return
148
- }
149
- const sessionUpdates = {}
150
- for (const jid of jids) {
151
- const addr = jidToSignalProtocolAddress(jid)
152
- sessionUpdates[addr.toString()] = null
153
- }
154
- await parsedKeys.transaction(async () => {
155
- await auth.keys.set({ session: sessionUpdates })
156
- }, `delete-${jids.length}-sessions`)
157
- },
158
- async migrateSession(fromJid, toJid) {
159
- if (!fromJid || (!(0, WABinary_1.isLidUser)(toJid) && !(0, WABinary_1.isHostedLidUser)(toJid))) {
160
- return { migrated: 0, skipped: 0, total: 0 }
161
- }
162
- if (!(0, WABinary_1.isPnUser)(fromJid) && !(0, WABinary_1.isHostedPnUser)(fromJid)) {
163
- return { migrated: 0, skipped: 0, total: 1 }
164
- }
165
- const fromDecoded = (0, WABinary_1.jidDecode)(fromJid)
166
- const user = fromDecoded?.user
167
- if (!user) {
168
- return { migrated: 0, skipped: 0, total: 0 }
169
- }
170
- const { [user]: userDevices } = await parsedKeys.get('device-list', [user])
171
- if (!userDevices?.length) {
172
- return { migrated: 0, skipped: 0, total: 0 }
173
- }
174
- const fromDeviceStr = (fromDecoded?.device || 0).toString()
175
- if (!userDevices.includes(fromDeviceStr)) {
176
- userDevices.push(fromDeviceStr)
177
- }
178
- const uncachedDevices = userDevices.filter(device => !migratedSessionCache.has(`${user}.${device}`))
179
- const deviceSessionKeys = uncachedDevices.map(device => `${user}.${device}`)
180
- const existingSessions = deviceSessionKeys.length
181
- ? await parsedKeys.get('session', deviceSessionKeys)
182
- : {}
183
- const deviceJids = []
184
- for (const [sessionKey, sessionData] of Object.entries(existingSessions)) {
185
- if (!sessionData) {
186
- continue
187
- }
188
- const deviceStr = sessionKey.split('.')[1]
189
- if (!deviceStr) {
190
- continue
191
- }
192
- const deviceNum = parseInt(deviceStr, 10)
193
- let jid = `${user}${deviceNum ? `:${deviceNum}` : ''}@s.whatsapp.net`
194
- if (deviceNum === 99) {
195
- jid = `${user}:99@hosted`
196
- }
197
- deviceJids.push(jid)
198
- }
199
- return parsedKeys.transaction(async () => {
200
- const migrationOps = deviceJids.map(jid => {
201
- const lidWithDevice = (0, WABinary_1.transferDevice)(jid, toJid)
202
- const fromDecoded = (0, WABinary_1.jidDecode)(jid)
203
- return {
204
- fromJid: jid,
205
- toJid: lidWithDevice,
206
- pnUser: fromDecoded?.user,
207
- deviceId: fromDecoded?.device || 0,
208
- fromAddr: jidToSignalProtocolAddress(jid),
209
- toAddr: jidToSignalProtocolAddress(lidWithDevice)
210
- }
211
- })
212
- const totalOps = migrationOps.length
213
- let migratedCount = 0
214
- const pnAddrStrings = [...new Set(migrationOps.map(op => op.fromAddr.toString()))]
215
- const pnSessions = pnAddrStrings.length
216
- ? await parsedKeys.get('session', pnAddrStrings)
217
- : {}
218
- const sessionUpdates = {}
219
- for (const op of migrationOps) {
220
- const pnAddrStr = op.fromAddr.toString()
221
- const lidAddrStr = op.toAddr.toString()
222
- const pnSession = pnSessions[pnAddrStr]
223
- if (!pnSession) {
224
- continue
225
- }
226
- const fromSession = libsignal.SessionRecord.deserialize(pnSession)
227
- if (!fromSession.haveOpenSession()) {
228
- continue
229
- }
230
- sessionUpdates[lidAddrStr] = fromSession.serialize()
231
- sessionUpdates[pnAddrStr] = null
232
- migratedCount += 1
233
- }
234
- if (Object.keys(sessionUpdates).length) {
235
- await parsedKeys.set({ session: sessionUpdates })
236
- for (const op of migrationOps) {
237
- if (sessionUpdates[op.toAddr.toString()] && op.pnUser) {
238
- migratedSessionCache.set(`${op.pnUser}.${op.deviceId}`, true)
239
- }
240
- }
241
- }
242
- return {
243
- migrated: migratedCount,
244
- skipped: totalOps - migratedCount,
245
- total: totalOps
246
- }
247
- }, `migrate-${deviceJids.length}-sessions-${(0, WABinary_1.jidDecode)(toJid)?.user || 'unknown'}`)
248
- }
249
96
  }
250
- return repository
251
97
  }
252
98
 
253
99
  const jidToSignalProtocolAddress = (jid) => {
254
- const decoded = (0, WABinary_1.jidDecode)(jid)
255
- const { user, device, server, domainType } = decoded || {}
256
- if (!user) {
257
- throw new Error(`JID decoded but user is empty: ${jid}`)
258
- }
259
- const signalUser = domainType !== WABinary_1.WAJIDDomains.WHATSAPP ? `${user}_${domainType}` : user
260
- const finalDevice = device || 0
261
- if (device === 99 && server !== 'hosted' && server !== 'hosted.lid') {
262
- throw new Error(`unexpected non-hosted device 99 JID: ${jid}`)
263
- }
264
- return new libsignal.ProtocolAddress(signalUser, finalDevice)
100
+ const { user, device } = WABinary_1.jidDecode(jid)
101
+ return new libsignal.ProtocolAddress(user, device || 0)
265
102
  }
266
103
 
267
104
  const jidToSignalSenderKeyName = (group, user) => {
268
- return new WASignalGroup_1.SenderKeyName(group, jidToSignalProtocolAddress(user))
105
+ return new WASignalGroup_1.SenderKeyName(group, jidToSignalProtocolAddress(user)).toString()
269
106
  }
270
107
 
271
- function signalStorage({ creds, keys }, lidMapping) {
272
- const resolveLIDSignalAddress = async (id) => {
273
- if (id.includes('.')) {
274
- const [deviceId, device] = id.split('.')
275
- const [user, domainType_] = deviceId.split('_')
276
- const domainType = parseInt(domainType_ || '0', 10)
277
- if (domainType === WABinary_1.WAJIDDomains.LID || domainType === WABinary_1.WAJIDDomains.HOSTED_LID) {
278
- return id
279
- }
280
- const pnJid = `${user}${device !== '0' ? `:${device}` : ''}@${domainType === WABinary_1.WAJIDDomains.HOSTED ? 'hosted' : 's.whatsapp.net'}`
281
- const lidForPN = await lidMapping.getLIDForPN(pnJid)
282
- if (lidForPN) {
283
- return jidToSignalProtocolAddress(lidForPN).toString()
284
- }
285
- }
286
- return id
287
- }
108
+ function signalStorage({ creds, keys }) {
288
109
  return {
289
110
  loadSession: async (id) => {
290
- try {
291
- const wireJid = await resolveLIDSignalAddress(id)
292
- const { [wireJid]: sess } = await keys.get('session', [wireJid])
293
- if (sess) {
294
- return libsignal.SessionRecord.deserialize(sess)
295
- }
111
+ const { [id]: sess } = await keys.get('session', [id])
112
+ if (sess) {
113
+ return libsignal.SessionRecord.deserialize(sess)
296
114
  }
297
- catch (_error) {
298
- return null
299
- }
300
- return null
301
115
  },
302
116
  storeSession: async (id, session) => {
303
- const wireJid = await resolveLIDSignalAddress(id)
304
- await keys.set({ session: { [wireJid]: session.serialize() } })
305
- },
306
- isTrustedIdentity: () => true,
307
- loadIdentityKey: async (id) => {
308
- const wireJid = await resolveLIDSignalAddress(id)
309
- const { [wireJid]: key } = await keys.get('identity-key', [wireJid])
310
- return key || undefined
117
+ await keys.set({ 'session': { [id]: session.serialize() } })
311
118
  },
312
- saveIdentity: async (id, identityKey) => {
313
- const wireJid = await resolveLIDSignalAddress(id)
314
- const { [wireJid]: existingKey } = await keys.get('identity-key', [wireJid])
315
- const keysMatch = existingKey
316
- && existingKey.length === identityKey.length
317
- && existingKey.every((byte, i) => byte === identityKey[i])
318
- if (existingKey && !keysMatch) {
319
- await keys.set({
320
- session: { [wireJid]: null },
321
- 'identity-key': { [wireJid]: identityKey }
322
- })
323
- return true
324
- }
325
- if (!existingKey) {
326
- await keys.set({ 'identity-key': { [wireJid]: identityKey } })
327
- return true
328
- }
329
- return false
119
+ isTrustedIdentity: () => {
120
+ return true
330
121
  },
331
122
  loadPreKey: async (id) => {
332
123
  const keyId = id.toString()
@@ -346,26 +137,26 @@ function signalStorage({ creds, keys }, lidMapping) {
346
137
  pubKey: Buffer.from(key.keyPair.public)
347
138
  }
348
139
  },
349
- loadSenderKey: async (senderKeyName) => {
350
- const keyId = senderKeyName.toString()
140
+ loadSenderKey: async (keyId) => {
351
141
  const { [keyId]: key } = await keys.get('sender-key', [keyId])
352
- return key ? new WASignalGroup_1.SenderKeyRecord(key) : new WASignalGroup_1.SenderKeyRecord()
142
+ if (key) {
143
+ return new WASignalGroup_1.SenderKeyRecord(key)
144
+ }
353
145
  },
354
- storeSenderKey: async (senderKeyName, key) => {
355
- const keyId = senderKeyName.toString()
146
+ storeSenderKey: async (keyId, key) => {
356
147
  await keys.set({ 'sender-key': { [keyId]: key.serialize() } })
357
148
  },
358
- getOurRegistrationId: () => creds.registrationId,
149
+ getOurRegistrationId: () => (creds.registrationId),
359
150
  getOurIdentity: () => {
360
151
  const { signedIdentityKey } = creds
361
152
  return {
362
153
  privKey: Buffer.from(signedIdentityKey.private),
363
- pubKey: Buffer.from((0, Utils_1.generateSignalPubKey)(signedIdentityKey.public))
154
+ pubKey: Utils_1.generateSignalPubKey(signedIdentityKey.public),
364
155
  }
365
156
  }
366
157
  }
367
158
  }
368
159
 
369
160
  module.exports = {
370
- makeLibSignalRepository
371
- }
161
+ makeLibSignalRepository
162
+ }
@@ -21,7 +21,7 @@ const MAX_SYNC_ATTEMPTS = 2
21
21
  const makeChatsSocket = (config) => {
22
22
  const { logger, markOnlineOnConnect, fireInitQueries, appStateMacVerification, shouldIgnoreJid, shouldSyncHistoryMessage, } = config
23
23
  const Neele = usync_1.makeUSyncSocket(config)
24
- const { ev, ws, authState, generateMessageTag, sendNode, query, onUnexpectedError, groupFetchAllParticipating, signalRepository } = Neele
24
+ const { ev, ws, authState, generateMessageTag, sendNode, query, onUnexpectedError, groupFetchAllParticipating } = Neele
25
25
 
26
26
  let privacySettings
27
27
  let syncState = Types_1.SyncState.Connecting
@@ -1000,7 +1000,6 @@ const makeChatsSocket = (config) => {
1000
1000
  logger,
1001
1001
  options: config.options,
1002
1002
  getMessage: config.getMessage,
1003
- signalRepository,
1004
1003
  })
1005
1004
  ])
1006
1005
 
@@ -1131,4 +1130,4 @@ const makeChatsSocket = (config) => {
1131
1130
 
1132
1131
  module.exports = {
1133
1132
  makeChatsSocket
1134
- }
1133
+ }
@@ -793,7 +793,7 @@ const makeSocket = (config) => {
793
793
  try {
794
794
  const myPN = authState.creds.me.id
795
795
  // Store our own LID-PN mapping
796
- await signalRepository.lidMapping.storeLIDPNMappings([{ lid: myLID, pn: myPN }])
796
+ await signalRepository?.lidMapping?.storeLIDPNMappings?.([{ lid: myLID, pn: myPN }])
797
797
  // Create device list for our own user (needed for bulk migration)
798
798
  const { user, device } = WABinary_1.jidDecode(myPN)
799
799
  await authState.keys.set({
@@ -802,7 +802,7 @@ const makeSocket = (config) => {
802
802
  }
803
803
  })
804
804
  // migrate our own session
805
- await signalRepository.migrateSession(myPN, myLID)
805
+ await signalRepository?.migrateSession?.(myPN, myLID)
806
806
  logger.info({ myPN, myLID }, 'Own LID session created successfully')
807
807
  }
808
808
  catch (error) {
@@ -944,4 +944,4 @@ function mapWebSocketError(handler) {
944
944
 
945
945
  module.exports = {
946
946
  makeSocket
947
- }
947
+ }
@@ -24,11 +24,6 @@ export type SignalIdentity = {
24
24
  identifierKey: Uint8Array
25
25
  }
26
26
 
27
- export type LIDMapping = {
28
- pn: string
29
- lid: string
30
- }
31
-
32
27
  export type LTHashState = {
33
28
  version: number
34
29
  hash: Buffer
@@ -72,7 +67,6 @@ export type AuthenticationCreds = SignalCreds & {
72
67
  pairingCode: string | undefined
73
68
  lastPropHash: string | undefined
74
69
  routingInfo: Buffer | undefined
75
- additionalData?: any | undefined
76
70
  }
77
71
 
78
72
  export type SignalDataTypeMap = {
@@ -84,13 +78,6 @@ export type SignalDataTypeMap = {
84
78
  }
85
79
  'app-state-sync-key': proto.Message.IAppStateSyncKeyData
86
80
  'app-state-sync-version': LTHashState
87
- 'lid-mapping': string
88
- 'device-list': string[]
89
- 'tctoken': {
90
- token: Buffer
91
- timestamp?: string
92
- }
93
- 'identity-key': Uint8Array
94
81
  }
95
82
 
96
83
  export type SignalDataSet = {
@@ -112,7 +99,7 @@ export type SignalKeyStore = {
112
99
 
113
100
  export type SignalKeyStoreWithTransaction = SignalKeyStore & {
114
101
  isInTransaction: () => boolean
115
- transaction<T>(exec: () => Promise<T>, key?: string): Promise<T>
102
+ transaction<T>(exec: () => Promise<T>): Promise<T>
116
103
  }
117
104
 
118
105
  export type TransactionCapabilityOptions = {
@@ -130,4 +117,4 @@ export type AuthenticationState = {
130
117
  keys: SignalKeyStore
131
118
  }
132
119
 
133
- export {}
120
+ export {}
@@ -2,7 +2,6 @@ export interface Contact {
2
2
  id: string
3
3
  lid?: string
4
4
  jid?: string
5
- phoneNumber?: string
6
5
  /** name of the contact, you have saved on your WA */
7
6
  name?: string
8
7
  /** name of the contact, the contact has set on their own on WA */
@@ -18,4 +17,4 @@ export interface Contact {
18
17
  */
19
18
  imgUrl?: string | null
20
19
  status?: string
21
- }
20
+ }