dcodeindra-baileyspro 2.3.9
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.
- package/LICENSE +21 -0
- package/README.md +2534 -0
- package/WAProto/Adv/Adv.d.ts +518 -0
- package/WAProto/Adv/Adv.js +1734 -0
- package/WAProto/Adv/Adv.proto +36 -0
- package/WAProto/BotMetadata/BotMetadata.d.ts +5745 -0
- package/WAProto/BotMetadata/BotMetadata.js +16291 -0
- package/WAProto/BotMetadata/BotMetadata.proto +463 -0
- package/WAProto/Cert/Cert.d.ts +497 -0
- package/WAProto/Cert/Cert.js +1503 -0
- package/WAProto/Cert/Cert.proto +28 -0
- package/WAProto/ChatLockSettings/ChatLockSettings.d.ts +391 -0
- package/WAProto/ChatLockSettings/ChatLockSettings.js +1155 -0
- package/WAProto/ChatLockSettings/ChatLockSettings.proto +7 -0
- package/WAProto/CompanionReg/CompanionReg.d.ts +1055 -0
- package/WAProto/CompanionReg/CompanionReg.js +3532 -0
- package/WAProto/CompanionReg/CompanionReg.proto +89 -0
- package/WAProto/DeviceCapabilities/DeviceCapabilities.d.ts +187 -0
- package/WAProto/DeviceCapabilities/DeviceCapabilities.js +520 -0
- package/WAProto/DeviceCapabilities/DeviceCapabilities.proto +14 -0
- package/WAProto/E2E/E2E.d.ts +28417 -0
- package/WAProto/E2E/E2E.js +98438 -0
- package/WAProto/E2E/E2E.proto +2289 -0
- package/WAProto/Ephemeral/Ephemeral.d.ts +95 -0
- package/WAProto/Ephemeral/Ephemeral.js +269 -0
- package/WAProto/Ephemeral/Ephemeral.proto +6 -0
- package/WAProto/HistorySync/HistorySync.d.ts +40728 -0
- package/WAProto/HistorySync/HistorySync.js +142980 -0
- package/WAProto/HistorySync/HistorySync.proto +207 -0
- package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.d.ts +189 -0
- package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.js +585 -0
- package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.proto +11 -0
- package/WAProto/MdStorageChatRowOpaqueData/MdStorageChatRowOpaqueData.d.ts +461 -0
- package/WAProto/MdStorageChatRowOpaqueData/MdStorageChatRowOpaqueData.js +1559 -0
- package/WAProto/MdStorageChatRowOpaqueData/MdStorageChatRowOpaqueData.proto +37 -0
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.d.ts +29294 -0
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.js +101732 -0
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.proto +76 -0
- package/WAProto/MmsRetry/MmsRetry.d.ts +200 -0
- package/WAProto/MmsRetry/MmsRetry.js +586 -0
- package/WAProto/MmsRetry/MmsRetry.proto +17 -0
- package/WAProto/Protocol/Protocol.d.ts +218 -0
- package/WAProto/Protocol/Protocol.js +701 -0
- package/WAProto/Protocol/Protocol.proto +20 -0
- package/WAProto/Reporting/Reporting.d.ts +301 -0
- package/WAProto/Reporting/Reporting.js +989 -0
- package/WAProto/Reporting/Reporting.proto +19 -0
- package/WAProto/ServerSync/ServerSync.d.ts +1050 -0
- package/WAProto/ServerSync/ServerSync.js +3176 -0
- package/WAProto/ServerSync/ServerSync.proto +59 -0
- package/WAProto/SignalLocalStorageProtocol/SignalLocalStorageProtocol.d.ts +1507 -0
- package/WAProto/SignalLocalStorageProtocol/SignalLocalStorageProtocol.js +4756 -0
- package/WAProto/SignalLocalStorageProtocol/SignalLocalStorageProtocol.proto +88 -0
- package/WAProto/SignalWhisperTextProtocol/SignalWhisperTextProtocol.d.ts +617 -0
- package/WAProto/SignalWhisperTextProtocol/SignalWhisperTextProtocol.js +1940 -0
- package/WAProto/SignalWhisperTextProtocol/SignalWhisperTextProtocol.proto +38 -0
- package/WAProto/StatusAttributions/StatusAttributions.d.ts +636 -0
- package/WAProto/StatusAttributions/StatusAttributions.js +2037 -0
- package/WAProto/StatusAttributions/StatusAttributions.proto +61 -0
- package/WAProto/SyncAction/SyncAction.d.ts +7227 -0
- package/WAProto/SyncAction/SyncAction.js +22271 -0
- package/WAProto/SyncAction/SyncAction.proto +423 -0
- package/WAProto/UserPassword/UserPassword.d.ts +298 -0
- package/WAProto/UserPassword/UserPassword.js +898 -0
- package/WAProto/UserPassword/UserPassword.proto +27 -0
- package/WAProto/VnameCert/VnameCert.d.ts +658 -0
- package/WAProto/VnameCert/VnameCert.js +2225 -0
- package/WAProto/VnameCert/VnameCert.proto +60 -0
- package/WAProto/Wa6/Wa6.d.ts +1613 -0
- package/WAProto/Wa6/Wa6.js +6299 -0
- package/WAProto/Wa6/Wa6.proto +229 -0
- package/WAProto/Web/Web.d.ts +31718 -0
- package/WAProto/Web/Web.js +113402 -0
- package/WAProto/Web/Web.proto +545 -0
- package/WAProto/index.d.ts +49 -0
- package/WAProto/index.js +28 -0
- package/WASignalGroup/GroupProtocol.js +1771 -0
- package/WASignalGroup/ciphertext_message.js +10 -0
- package/WASignalGroup/group_cipher.js +103 -0
- package/WASignalGroup/group_session_builder.js +39 -0
- package/WASignalGroup/index.js +5 -0
- package/WASignalGroup/keyhelper.js +17 -0
- package/WASignalGroup/protobufs.js +2 -0
- package/WASignalGroup/queue_job.js +64 -0
- package/WASignalGroup/sender_chain_key.js +38 -0
- package/WASignalGroup/sender_key_distribution_message.js +68 -0
- package/WASignalGroup/sender_key_message.js +79 -0
- package/WASignalGroup/sender_key_name.js +59 -0
- package/WASignalGroup/sender_key_record.js +47 -0
- package/WASignalGroup/sender_key_state.js +110 -0
- package/WASignalGroup/sender_message_key.js +30 -0
- package/check-node-version.js +10 -0
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +51 -0
- package/lib/Defaults/index.js +108 -0
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/ciphertext-message.js +19 -0
- package/lib/Signal/Group/group-session-builder.d.ts +17 -0
- package/lib/Signal/Group/group-session-builder.js +72 -0
- package/lib/Signal/Group/group_cipher.d.ts +19 -0
- package/lib/Signal/Group/group_cipher.js +99 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/index.js +61 -0
- package/lib/Signal/Group/keyhelper.d.ts +16 -0
- package/lib/Signal/Group/keyhelper.js +66 -0
- package/lib/Signal/Group/queue-job.d.ts +1 -0
- package/lib/Signal/Group/queue-job.js +64 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
- package/lib/Signal/Group/sender-chain-key.js +39 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +71 -0
- package/lib/Signal/Group/sender-key-message.d.ts +19 -0
- package/lib/Signal/Group/sender-key-message.js +73 -0
- package/lib/Signal/Group/sender-key-name.d.ts +19 -0
- package/lib/Signal/Group/sender-key-name.js +59 -0
- package/lib/Signal/Group/sender-key-record.d.ts +32 -0
- package/lib/Signal/Group/sender-key-record.js +53 -0
- package/lib/Signal/Group/sender-key-record.ts +77 -0
- package/lib/Signal/Group/sender-key-state.d.ts +44 -0
- package/lib/Signal/Group/sender-key-state.js +104 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/lib/Signal/Group/sender-message-key.js +33 -0
- package/lib/Signal/libsignal.d.ts +3 -0
- package/lib/Signal/libsignal.js +153 -0
- package/lib/Socket/Client/index.d.ts +2 -0
- package/lib/Socket/Client/index.js +18 -0
- package/lib/Socket/Client/types.d.ts +15 -0
- package/lib/Socket/Client/types.js +14 -0
- package/lib/Socket/Client/websocket.d.ts +12 -0
- package/lib/Socket/Client/websocket.js +57 -0
- package/lib/Socket/business.d.ts +181 -0
- package/lib/Socket/business.js +259 -0
- package/lib/Socket/chats.d.ts +95 -0
- package/lib/Socket/chats.js +906 -0
- package/lib/Socket/community.d.ts +131 -0
- package/lib/Socket/community.js +369 -0
- package/lib/Socket/groups.d.ts +122 -0
- package/lib/Socket/groups.js +360 -0
- package/lib/Socket/index.d.ts +183 -0
- package/lib/Socket/index.js +10 -0
- package/lib/Socket/messages-recv.d.ts +170 -0
- package/lib/Socket/messages-recv.js +1074 -0
- package/lib/Socket/messages-send.d.ts +161 -0
- package/lib/Socket/messages-send.js +982 -0
- package/lib/Socket/newsletter.d.ts +140 -0
- package/lib/Socket/newsletter.js +242 -0
- package/lib/Socket/socket.d.ts +43 -0
- package/lib/Socket/socket.js +749 -0
- package/lib/Socket/usync.d.ts +36 -0
- package/lib/Socket/usync.js +71 -0
- package/lib/Store/index.d.ts +4 -0
- package/lib/Store/index.js +20 -0
- package/lib/Store/make-cache-manager-store.d.ts +13 -0
- package/lib/Store/make-cache-manager-store.js +77 -0
- package/lib/Store/make-in-memory-store.d.ts +117 -0
- package/lib/Store/make-in-memory-store.js +420 -0
- package/lib/Store/make-ordered-dictionary.d.ts +12 -0
- package/lib/Store/make-ordered-dictionary.js +83 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Store/object-repository.js +28 -0
- package/lib/Types/Auth.d.ts +103 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Call.d.ts +13 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.d.ts +115 -0
- package/lib/Types/Chat.js +6 -0
- package/lib/Types/Contact.d.ts +35 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Events.d.ts +208 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/GroupMetadata.d.ts +81 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/Label.d.ts +46 -0
- package/lib/Types/Label.js +28 -0
- package/lib/Types/LabelAssociation.d.ts +29 -0
- package/lib/Types/LabelAssociation.js +10 -0
- package/lib/Types/Message.d.ts +480 -0
- package/lib/Types/Message.js +9 -0
- package/lib/Types/MexUpdates.d.ts +9 -0
- package/lib/Types/MexUpdates.js +18 -0
- package/lib/Types/Newsletter.d.ts +92 -0
- package/lib/Types/Newsletter.js +33 -0
- package/lib/Types/Product.d.ts +78 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Signal.d.ts +57 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Socket.d.ts +116 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.d.ts +27 -0
- package/lib/Types/State.js +2 -0
- package/lib/Types/USync.d.ts +25 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.d.ts +70 -0
- package/lib/Types/index.js +42 -0
- package/lib/Utils/auth-utils.d.ts +18 -0
- package/lib/Utils/auth-utils.js +198 -0
- package/lib/Utils/baileys-event-stream.d.ts +16 -0
- package/lib/Utils/baileys-event-stream.js +64 -0
- package/lib/Utils/business.d.ts +22 -0
- package/lib/Utils/business.js +243 -0
- package/lib/Utils/chat-utils.d.ts +72 -0
- package/lib/Utils/chat-utils.js +762 -0
- package/lib/Utils/crypto.d.ts +40 -0
- package/lib/Utils/crypto.js +150 -0
- package/lib/Utils/decode-wa-message.d.ts +252 -0
- package/lib/Utils/decode-wa-message.js +232 -0
- package/lib/Utils/event-buffer.d.ts +35 -0
- package/lib/Utils/event-buffer.js +539 -0
- package/lib/Utils/generics.d.ts +96 -0
- package/lib/Utils/generics.js +553 -0
- package/lib/Utils/history.d.ts +29 -0
- package/lib/Utils/history.js +109 -0
- package/lib/Utils/index.d.ts +19 -0
- package/lib/Utils/index.js +35 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/link-preview.js +112 -0
- package/lib/Utils/logger.d.ts +11 -0
- package/lib/Utils/logger.js +7 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/lt-hash.js +53 -0
- package/lib/Utils/make-mutex.d.ts +7 -0
- package/lib/Utils/make-mutex.js +45 -0
- package/lib/Utils/messages-media.d.ts +104 -0
- package/lib/Utils/messages-media.js +751 -0
- package/lib/Utils/messages.d.ts +80 -0
- package/lib/Utils/messages.js +1741 -0
- package/lib/Utils/noise-handler.d.ts +19 -0
- package/lib/Utils/noise-handler.js +150 -0
- package/lib/Utils/process-message.d.ts +41 -0
- package/lib/Utils/process-message.js +391 -0
- package/lib/Utils/signal.d.ts +33 -0
- package/lib/Utils/signal.js +154 -0
- package/lib/Utils/use-mongo-file-auth-state.d.ts +5 -0
- package/lib/Utils/use-mongo-file-auth-state.js +75 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
- package/lib/Utils/use-multi-file-auth-state.js +123 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +12 -0
- package/lib/Utils/use-single-file-auth-state.js +75 -0
- package/lib/Utils/validate-connection.d.ts +10 -0
- package/lib/Utils/validate-connection.js +174 -0
- package/lib/WABinary/constants.d.ts +27 -0
- package/lib/WABinary/constants.js +45 -0
- package/lib/WABinary/decode.d.ts +6 -0
- package/lib/WABinary/decode.js +255 -0
- package/lib/WABinary/encode.d.ts +2 -0
- package/lib/WABinary/encode.js +243 -0
- package/lib/WABinary/generic-utils.d.ts +16 -0
- package/lib/WABinary/generic-utils.js +125 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/index.js +21 -0
- package/lib/WABinary/jid-utils.d.ts +34 -0
- package/lib/WABinary/jid-utils.js +73 -0
- package/lib/WABinary/types.d.ts +18 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.d.ts +16 -0
- package/lib/WAM/BinaryInfo.js +14 -0
- package/lib/WAM/constants.d.ts +39 -0
- package/lib/WAM/constants.js +15362 -0
- package/lib/WAM/encode.d.ts +2 -0
- package/lib/WAM/encode.js +156 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAM/index.js +19 -0
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +25 -0
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +60 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +58 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +31 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +8 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +26 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/WAUSync/Protocols/index.d.ts +6 -0
- package/lib/WAUSync/Protocols/index.js +22 -0
- package/lib/WAUSync/USyncQuery.d.ts +28 -0
- package/lib/WAUSync/USyncQuery.js +88 -0
- package/lib/WAUSync/USyncUser.d.ts +12 -0
- package/lib/WAUSync/USyncUser.js +27 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +19 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.js +45 -0
- package/package.json +63 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { BufferJSON } from '../../Utils/generics'
|
|
2
|
+
import { SenderKeyState } from './sender-key-state'
|
|
3
|
+
|
|
4
|
+
export interface SenderKeyStateStructure {
|
|
5
|
+
senderKeyId: number
|
|
6
|
+
senderChainKey: {
|
|
7
|
+
iteration: number
|
|
8
|
+
seed: Uint8Array
|
|
9
|
+
}
|
|
10
|
+
senderSigningKey: {
|
|
11
|
+
public: Uint8Array
|
|
12
|
+
private?: Uint8Array
|
|
13
|
+
}
|
|
14
|
+
senderMessageKeys: Array<{
|
|
15
|
+
iteration: number
|
|
16
|
+
seed: Uint8Array
|
|
17
|
+
}>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class SenderKeyRecord {
|
|
21
|
+
private readonly MAX_STATES = 5
|
|
22
|
+
private readonly senderKeyStates: SenderKeyState[] = []
|
|
23
|
+
|
|
24
|
+
constructor(serialized?: SenderKeyStateStructure[]) {
|
|
25
|
+
if (serialized) {
|
|
26
|
+
for (const structure of serialized) {
|
|
27
|
+
this.senderKeyStates.push(new SenderKeyState(null, null, null, null, null, null, structure))
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public isEmpty(): boolean {
|
|
33
|
+
return this.senderKeyStates.length === 0
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public getSenderKeyState(keyId?: number): SenderKeyState | undefined {
|
|
37
|
+
if (keyId === undefined && this.senderKeyStates.length) {
|
|
38
|
+
return this.senderKeyStates[this.senderKeyStates.length - 1]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return this.senderKeyStates.find(state => state.getKeyId() === keyId)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public addSenderKeyState(id: number, iteration: number, chainKey: Uint8Array, signatureKey: Uint8Array): void {
|
|
45
|
+
this.senderKeyStates.push(new SenderKeyState(id, iteration, chainKey, null, signatureKey))
|
|
46
|
+
if (this.senderKeyStates.length > this.MAX_STATES) {
|
|
47
|
+
this.senderKeyStates.shift()
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public setSenderKeyState(
|
|
52
|
+
id: number,
|
|
53
|
+
iteration: number,
|
|
54
|
+
chainKey: Uint8Array,
|
|
55
|
+
keyPair: { public: Uint8Array; private: Uint8Array }
|
|
56
|
+
): void {
|
|
57
|
+
this.senderKeyStates.length = 0
|
|
58
|
+
this.senderKeyStates.push(new SenderKeyState(id, iteration, chainKey, keyPair))
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public serialize(): SenderKeyStateStructure[] {
|
|
62
|
+
return this.senderKeyStates.map(state => state.getStructure())
|
|
63
|
+
}
|
|
64
|
+
static deserialize(data: Uint8Array | string | SenderKeyStateStructure[]): SenderKeyRecord {
|
|
65
|
+
let parsed: SenderKeyStateStructure[]
|
|
66
|
+
if (typeof data === 'string') {
|
|
67
|
+
parsed = JSON.parse(data, BufferJSON.reviver)
|
|
68
|
+
} else if (data instanceof Uint8Array) {
|
|
69
|
+
const str = Buffer.from(data).toString('utf-8')
|
|
70
|
+
parsed = JSON.parse(str, BufferJSON.reviver)
|
|
71
|
+
} else {
|
|
72
|
+
parsed = data
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return new SenderKeyRecord(parsed)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SenderChainKey } from './sender-chain-key'
|
|
2
|
+
import { SenderMessageKey } from './sender-message-key'
|
|
3
|
+
|
|
4
|
+
interface SenderChainKeyStructure {
|
|
5
|
+
iteration: number
|
|
6
|
+
seed: Uint8Array
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface SenderSigningKeyStructure {
|
|
10
|
+
public: Uint8Array
|
|
11
|
+
private?: Uint8Array
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface SenderMessageKeyStructure {
|
|
15
|
+
iteration: number
|
|
16
|
+
seed: Uint8Array
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface SenderKeyStateStructure {
|
|
20
|
+
senderKeyId: number
|
|
21
|
+
senderChainKey: SenderChainKeyStructure
|
|
22
|
+
senderSigningKey: SenderSigningKeyStructure
|
|
23
|
+
senderMessageKeys: SenderMessageKeyStructure[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export declare class SenderKeyState {
|
|
27
|
+
private readonly MAX_MESSAGE_KEYS
|
|
28
|
+
private readonly senderKeyStateStructure
|
|
29
|
+
constructor(id?: number | null, iteration?: number | null, chainKey?: Uint8Array | null, signatureKeyPair?: {
|
|
30
|
+
public: Uint8Array
|
|
31
|
+
private: Uint8Array
|
|
32
|
+
} | null, signatureKeyPublic?: Uint8Array | null, signatureKeyPrivate?: Uint8Array | null, senderKeyStateStructure?: SenderKeyStateStructure | null)
|
|
33
|
+
getKeyId(): number
|
|
34
|
+
getSenderChainKey(): SenderChainKey
|
|
35
|
+
setSenderChainKey(chainKey: SenderChainKey): void
|
|
36
|
+
getSigningKeyPublic(): Buffer
|
|
37
|
+
getSigningKeyPrivate(): Buffer | undefined
|
|
38
|
+
hasSenderMessageKey(iteration: number): boolean
|
|
39
|
+
addSenderMessageKey(senderMessageKey: SenderMessageKey): void
|
|
40
|
+
removeSenderMessageKey(iteration: number): SenderMessageKey | null
|
|
41
|
+
getStructure(): SenderKeyStateStructure
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export {}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
+
|
|
5
|
+
const sender_chain_key_1 = require("./sender-chain-key")
|
|
6
|
+
const sender_message_key_1 = require("./sender-message-key")
|
|
7
|
+
|
|
8
|
+
class SenderKeyState {
|
|
9
|
+
constructor(id, iteration, chainKey, signatureKeyPair, signatureKeyPublic, signatureKeyPrivate, senderKeyStateStructure) {
|
|
10
|
+
this.MAX_MESSAGE_KEYS = 2000
|
|
11
|
+
if (senderKeyStateStructure) {
|
|
12
|
+
this.senderKeyStateStructure = senderKeyStateStructure
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
if (signatureKeyPair) {
|
|
16
|
+
signatureKeyPublic = signatureKeyPair.public
|
|
17
|
+
signatureKeyPrivate = signatureKeyPair.private
|
|
18
|
+
}
|
|
19
|
+
chainKey = typeof chainKey === 'string' ? Buffer.from(chainKey, 'base64') : chainKey
|
|
20
|
+
const senderChainKeyStructure = {
|
|
21
|
+
iteration: iteration || 0,
|
|
22
|
+
seed: chainKey || Buffer.alloc(0)
|
|
23
|
+
}
|
|
24
|
+
const signingKeyStructure = {
|
|
25
|
+
public: typeof signatureKeyPublic === 'string'
|
|
26
|
+
? Buffer.from(signatureKeyPublic, 'base64')
|
|
27
|
+
: signatureKeyPublic || Buffer.alloc(0)
|
|
28
|
+
}
|
|
29
|
+
if (signatureKeyPrivate) {
|
|
30
|
+
signingKeyStructure.private =
|
|
31
|
+
typeof signatureKeyPrivate === 'string' ? Buffer.from(signatureKeyPrivate, 'base64') : signatureKeyPrivate
|
|
32
|
+
}
|
|
33
|
+
this.senderKeyStateStructure = {
|
|
34
|
+
senderKeyId: id || 0,
|
|
35
|
+
senderChainKey: senderChainKeyStructure,
|
|
36
|
+
senderSigningKey: signingKeyStructure,
|
|
37
|
+
senderMessageKeys: []
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
getKeyId() {
|
|
42
|
+
return this.senderKeyStateStructure.senderKeyId
|
|
43
|
+
}
|
|
44
|
+
getSenderChainKey() {
|
|
45
|
+
return new sender_chain_key_1.SenderChainKey(this.senderKeyStateStructure.senderChainKey.iteration, this.senderKeyStateStructure.senderChainKey.seed)
|
|
46
|
+
}
|
|
47
|
+
setSenderChainKey(chainKey) {
|
|
48
|
+
this.senderKeyStateStructure.senderChainKey = {
|
|
49
|
+
iteration: chainKey.getIteration(),
|
|
50
|
+
seed: chainKey.getSeed()
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
getSigningKeyPublic() {
|
|
54
|
+
const publicKey = this.senderKeyStateStructure.senderSigningKey.public
|
|
55
|
+
if (publicKey instanceof Buffer) {
|
|
56
|
+
return publicKey
|
|
57
|
+
}
|
|
58
|
+
else if (typeof publicKey === 'string') {
|
|
59
|
+
return Buffer.from(publicKey, 'base64')
|
|
60
|
+
}
|
|
61
|
+
return Buffer.from(publicKey || [])
|
|
62
|
+
}
|
|
63
|
+
getSigningKeyPrivate() {
|
|
64
|
+
const privateKey = this.senderKeyStateStructure.senderSigningKey.private
|
|
65
|
+
if (!privateKey) {
|
|
66
|
+
return undefined
|
|
67
|
+
}
|
|
68
|
+
if (privateKey instanceof Buffer) {
|
|
69
|
+
return privateKey
|
|
70
|
+
}
|
|
71
|
+
else if (typeof privateKey === 'string') {
|
|
72
|
+
return Buffer.from(privateKey, 'base64')
|
|
73
|
+
}
|
|
74
|
+
return Buffer.from(privateKey || [])
|
|
75
|
+
}
|
|
76
|
+
hasSenderMessageKey(iteration) {
|
|
77
|
+
return this.senderKeyStateStructure.senderMessageKeys.some(key => key.iteration === iteration)
|
|
78
|
+
}
|
|
79
|
+
addSenderMessageKey(senderMessageKey) {
|
|
80
|
+
this.senderKeyStateStructure.senderMessageKeys.push({
|
|
81
|
+
iteration: senderMessageKey.getIteration(),
|
|
82
|
+
seed: senderMessageKey.getSeed()
|
|
83
|
+
})
|
|
84
|
+
if (this.senderKeyStateStructure.senderMessageKeys.length > this.MAX_MESSAGE_KEYS) {
|
|
85
|
+
this.senderKeyStateStructure.senderMessageKeys.shift()
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
removeSenderMessageKey(iteration) {
|
|
89
|
+
const index = this.senderKeyStateStructure.senderMessageKeys.findIndex(key => key.iteration === iteration)
|
|
90
|
+
if (index !== -1) {
|
|
91
|
+
const messageKey = this.senderKeyStateStructure.senderMessageKeys[index]
|
|
92
|
+
this.senderKeyStateStructure.senderMessageKeys.splice(index, 1)
|
|
93
|
+
return new sender_message_key_1.SenderMessageKey(messageKey.iteration, messageKey.seed)
|
|
94
|
+
}
|
|
95
|
+
return null
|
|
96
|
+
}
|
|
97
|
+
getStructure() {
|
|
98
|
+
return this.senderKeyStateStructure
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
module.exports = {
|
|
103
|
+
SenderKeyState
|
|
104
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class SenderMessageKey {
|
|
2
|
+
private readonly iteration
|
|
3
|
+
private readonly iv
|
|
4
|
+
private readonly cipherKey
|
|
5
|
+
private readonly seed
|
|
6
|
+
constructor(iteration: number, seed: Uint8Array)
|
|
7
|
+
getIteration(): number
|
|
8
|
+
getIv(): Uint8Array
|
|
9
|
+
getCipherKey(): Uint8Array
|
|
10
|
+
getSeed(): Uint8Array
|
|
11
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
3
|
+
|
|
4
|
+
const crypto_1 = require("@itsukichan/libsignal-node/src/crypto")
|
|
5
|
+
|
|
6
|
+
class SenderMessageKey {
|
|
7
|
+
constructor(iteration, seed) {
|
|
8
|
+
const derivative = (0, crypto_1.deriveSecrets)(seed, Buffer.alloc(32), Buffer.from('WhisperGroup'))
|
|
9
|
+
const keys = new Uint8Array(32)
|
|
10
|
+
keys.set(new Uint8Array(derivative[0].slice(16)))
|
|
11
|
+
keys.set(new Uint8Array(derivative[1].slice(0, 16)), 16)
|
|
12
|
+
this.iv = Buffer.from(derivative[0].slice(0, 16))
|
|
13
|
+
this.cipherKey = Buffer.from(keys.buffer)
|
|
14
|
+
this.iteration = iteration
|
|
15
|
+
this.seed = seed
|
|
16
|
+
}
|
|
17
|
+
getIteration() {
|
|
18
|
+
return this.iteration
|
|
19
|
+
}
|
|
20
|
+
getIv() {
|
|
21
|
+
return this.iv
|
|
22
|
+
}
|
|
23
|
+
getCipherKey() {
|
|
24
|
+
return this.cipherKey
|
|
25
|
+
}
|
|
26
|
+
getSeed() {
|
|
27
|
+
return this.seed
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = {
|
|
32
|
+
SenderMessageKey
|
|
33
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k)
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k] } }
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc)
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k
|
|
11
|
+
o[k2] = m[k]
|
|
12
|
+
}))
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v })
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v
|
|
17
|
+
})
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod
|
|
20
|
+
var result = {}
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k)
|
|
22
|
+
__setModuleDefault(result, mod)
|
|
23
|
+
return result
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
26
|
+
const libsignal = __importStar(require("libsignal"))
|
|
27
|
+
const WASignalGroup_1 = require("../../WASignalGroup")
|
|
28
|
+
const Utils_1 = require("../Utils")
|
|
29
|
+
const WABinary_1 = require("../WABinary")
|
|
30
|
+
function makeLibSignalRepository(auth) {
|
|
31
|
+
const storage = signalStorage(auth)
|
|
32
|
+
return {
|
|
33
|
+
decryptGroupMessage({ group, authorJid, msg }) {
|
|
34
|
+
const senderName = jidToSignalSenderKeyName(group, authorJid)
|
|
35
|
+
const cipher = new WASignalGroup_1.GroupCipher(storage, senderName)
|
|
36
|
+
return cipher.decrypt(msg)
|
|
37
|
+
},
|
|
38
|
+
async processSenderKeyDistributionMessage({ item, authorJid }) {
|
|
39
|
+
const builder = new WASignalGroup_1.GroupSessionBuilder(storage)
|
|
40
|
+
const senderName = jidToSignalSenderKeyName(item.groupId, authorJid)
|
|
41
|
+
const senderMsg = new WASignalGroup_1.SenderKeyDistributionMessage(null, null, null, null, item.axolotlSenderKeyDistributionMessage)
|
|
42
|
+
const { [senderName]: senderKey } = await auth.keys.get('sender-key', [senderName])
|
|
43
|
+
if (!senderKey) {
|
|
44
|
+
await storage.storeSenderKey(senderName, new WASignalGroup_1.SenderKeyRecord())
|
|
45
|
+
}
|
|
46
|
+
await builder.process(senderName, senderMsg)
|
|
47
|
+
},
|
|
48
|
+
async decryptMessage({ jid, type, ciphertext }) {
|
|
49
|
+
const addr = jidToSignalProtocolAddress(jid)
|
|
50
|
+
const session = new libsignal.SessionCipher(storage, addr)
|
|
51
|
+
let result
|
|
52
|
+
switch (type) {
|
|
53
|
+
case 'pkmsg':
|
|
54
|
+
result = await session.decryptPreKeyWhisperMessage(ciphertext)
|
|
55
|
+
break
|
|
56
|
+
case 'msg':
|
|
57
|
+
result = await session.decryptWhisperMessage(ciphertext)
|
|
58
|
+
break
|
|
59
|
+
}
|
|
60
|
+
return result
|
|
61
|
+
},
|
|
62
|
+
async encryptMessage({ jid, data }) {
|
|
63
|
+
const addr = jidToSignalProtocolAddress(jid)
|
|
64
|
+
const cipher = new libsignal.SessionCipher(storage, addr)
|
|
65
|
+
const { type: sigType, body } = await cipher.encrypt(data)
|
|
66
|
+
const type = sigType === 3 ? 'pkmsg' : 'msg'
|
|
67
|
+
return { type, ciphertext: Buffer.from(body, 'binary') }
|
|
68
|
+
},
|
|
69
|
+
async encryptGroupMessage({ group, meId, data }) {
|
|
70
|
+
const senderName = jidToSignalSenderKeyName(group, meId)
|
|
71
|
+
const builder = new WASignalGroup_1.GroupSessionBuilder(storage)
|
|
72
|
+
const { [senderName]: senderKey } = await auth.keys.get('sender-key', [senderName])
|
|
73
|
+
if (!senderKey) {
|
|
74
|
+
await storage.storeSenderKey(senderName, new WASignalGroup_1.SenderKeyRecord())
|
|
75
|
+
}
|
|
76
|
+
const senderKeyDistributionMessage = await builder.create(senderName)
|
|
77
|
+
const session = new WASignalGroup_1.GroupCipher(storage, senderName)
|
|
78
|
+
const ciphertext = await session.encrypt(data)
|
|
79
|
+
return {
|
|
80
|
+
ciphertext,
|
|
81
|
+
senderKeyDistributionMessage: senderKeyDistributionMessage.serialize(),
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
async injectE2ESession({ jid, session }) {
|
|
85
|
+
const cipher = new libsignal.SessionBuilder(storage, jidToSignalProtocolAddress(jid))
|
|
86
|
+
await cipher.initOutgoing(session)
|
|
87
|
+
},
|
|
88
|
+
jidToSignalProtocolAddress(jid) {
|
|
89
|
+
return jidToSignalProtocolAddress(jid).toString()
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const jidToSignalProtocolAddress = (jid) => {
|
|
94
|
+
const { user, device } = WABinary_1.jidDecode(jid)
|
|
95
|
+
return new libsignal.ProtocolAddress(user, device || 0)
|
|
96
|
+
}
|
|
97
|
+
const jidToSignalSenderKeyName = (group, user) => {
|
|
98
|
+
return new WASignalGroup_1.SenderKeyName(group, jidToSignalProtocolAddress(user)).toString()
|
|
99
|
+
}
|
|
100
|
+
function signalStorage({ creds, keys }) {
|
|
101
|
+
return {
|
|
102
|
+
loadSession: async (id) => {
|
|
103
|
+
const { [id]: sess } = await keys.get('session', [id])
|
|
104
|
+
if (sess) {
|
|
105
|
+
return libsignal.SessionRecord.deserialize(sess)
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
storeSession: async (id, session) => {
|
|
109
|
+
await keys.set({ 'session': { [id]: session.serialize() } })
|
|
110
|
+
},
|
|
111
|
+
isTrustedIdentity: () => {
|
|
112
|
+
return true
|
|
113
|
+
},
|
|
114
|
+
loadPreKey: async (id) => {
|
|
115
|
+
const keyId = id.toString()
|
|
116
|
+
const { [keyId]: key } = await keys.get('pre-key', [keyId])
|
|
117
|
+
if (key) {
|
|
118
|
+
return {
|
|
119
|
+
privKey: Buffer.from(key.private),
|
|
120
|
+
pubKey: Buffer.from(key.public)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
removePreKey: (id) => keys.set({ 'pre-key': { [id]: null } }),
|
|
125
|
+
loadSignedPreKey: () => {
|
|
126
|
+
const key = creds.signedPreKey
|
|
127
|
+
return {
|
|
128
|
+
privKey: Buffer.from(key.keyPair.private),
|
|
129
|
+
pubKey: Buffer.from(key.keyPair.public)
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
loadSenderKey: async (keyId) => {
|
|
133
|
+
const { [keyId]: key } = await keys.get('sender-key', [keyId])
|
|
134
|
+
if (key) {
|
|
135
|
+
return new WASignalGroup_1.SenderKeyRecord(key)
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
storeSenderKey: async (keyId, key) => {
|
|
139
|
+
await keys.set({ 'sender-key': { [keyId]: key.serialize() } })
|
|
140
|
+
},
|
|
141
|
+
getOurRegistrationId: () => (creds.registrationId),
|
|
142
|
+
getOurIdentity: () => {
|
|
143
|
+
const { signedIdentityKey } = creds
|
|
144
|
+
return {
|
|
145
|
+
privKey: Buffer.from(signedIdentityKey.private),
|
|
146
|
+
pubKey: Utils_1.generateSignalPubKey(signedIdentityKey.public),
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
module.exports = {
|
|
152
|
+
makeLibSignalRepository
|
|
153
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k)
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k] } }
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc)
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k
|
|
11
|
+
o[k2] = m[k]
|
|
12
|
+
}))
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p)
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
17
|
+
__exportStar(require("./types"), exports)
|
|
18
|
+
__exportStar(require("./websocket"), exports)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EventEmitter } from 'events'
|
|
2
|
+
import { URL } from 'url'
|
|
3
|
+
import { SocketConfig } from '../../Types'
|
|
4
|
+
export declare abstract class AbstractSocketClient extends EventEmitter {
|
|
5
|
+
url: URL
|
|
6
|
+
config: SocketConfig
|
|
7
|
+
abstract get isOpen(): boolean
|
|
8
|
+
abstract get isClosed(): boolean
|
|
9
|
+
abstract get isClosing(): boolean
|
|
10
|
+
abstract get isConnecting(): boolean
|
|
11
|
+
constructor(url: URL, config: SocketConfig)
|
|
12
|
+
abstract connect(): Promise<void>
|
|
13
|
+
abstract close(): Promise<void>
|
|
14
|
+
abstract send(str: Uint8Array | string, cb?: (err?: Error) => void): boolean
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
3
|
+
const events_1 = require("events")
|
|
4
|
+
class AbstractSocketClient extends events_1.EventEmitter {
|
|
5
|
+
constructor(url, config) {
|
|
6
|
+
super()
|
|
7
|
+
this.url = url
|
|
8
|
+
this.config = config
|
|
9
|
+
this.setMaxListeners(0)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
module.exports = {
|
|
13
|
+
AbstractSocketClient
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import WebSocket from 'ws'
|
|
2
|
+
import { AbstractSocketClient } from './types'
|
|
3
|
+
export declare class WebSocketClient extends AbstractSocketClient {
|
|
4
|
+
protected socket: WebSocket | null
|
|
5
|
+
get isOpen(): boolean
|
|
6
|
+
get isClosed(): boolean
|
|
7
|
+
get isClosing(): boolean
|
|
8
|
+
get isConnecting(): boolean
|
|
9
|
+
connect(): Promise<void>
|
|
10
|
+
close(): Promise<void>
|
|
11
|
+
send(str: string | Uint8Array, cb?: (err?: Error) => void): boolean
|
|
12
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod }
|
|
4
|
+
}
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
6
|
+
const ws_1 = __importDefault(require("ws"))
|
|
7
|
+
const Defaults_1 = require("../../Defaults")
|
|
8
|
+
const types_1 = require("./types")
|
|
9
|
+
class WebSocketClient extends types_1.AbstractSocketClient {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments)
|
|
12
|
+
this.socket = null
|
|
13
|
+
}
|
|
14
|
+
get isOpen() {
|
|
15
|
+
return this.socket?.readyState === ws_1.default.OPEN
|
|
16
|
+
}
|
|
17
|
+
get isClosed() {
|
|
18
|
+
return this.socket?.readyState === ws_1.default.CLOSED
|
|
19
|
+
}
|
|
20
|
+
get isClosing() {
|
|
21
|
+
this.socket?.readyState === ws_1.default.CLOSING
|
|
22
|
+
}
|
|
23
|
+
get isConnecting() {
|
|
24
|
+
this.socket?.readyState === ws_1.default.CONNECTING
|
|
25
|
+
}
|
|
26
|
+
async connect() {
|
|
27
|
+
if (this.socket) {
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
this.socket = new ws_1.default(this.url, {
|
|
31
|
+
origin: Defaults_1.DEFAULT_ORIGIN,
|
|
32
|
+
headers: this.config.options?.headers,
|
|
33
|
+
handshakeTimeout: this.config.connectTimeoutMs,
|
|
34
|
+
timeout: this.config.connectTimeoutMs,
|
|
35
|
+
agent: this.config.agent,
|
|
36
|
+
})
|
|
37
|
+
this.socket.setMaxListeners(0)
|
|
38
|
+
const events = ['close', 'error', 'upgrade', 'message', 'open', 'ping', 'pong', 'unexpected-response']
|
|
39
|
+
for (const event of events) {
|
|
40
|
+
this.socket?.on(event, (...args) => this.emit(event, ...args))
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async close() {
|
|
44
|
+
if (!this.socket) {
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
this.socket.close()
|
|
48
|
+
this.socket = null
|
|
49
|
+
}
|
|
50
|
+
send(str, cb) {
|
|
51
|
+
this.socket?.send(str, cb)
|
|
52
|
+
return Boolean(this.socket)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
module.exports = {
|
|
56
|
+
WebSocketClient
|
|
57
|
+
}
|