supunmd-bail 2.0.1
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/WAProto/GenerateStatics.sh +3 -0
- package/WAProto/WAProto.proto +5519 -0
- package/WAProto/fix-imports.js +29 -0
- package/WAProto/index.d.ts +11969 -0
- package/WAProto/index.js +84368 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +62 -0
- package/lib/Defaults/index.js +115 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
- package/lib/Signal/Group/ciphertext-message.js +12 -0
- package/lib/Signal/Group/group-session-builder.d.ts +15 -0
- package/lib/Signal/Group/group-session-builder.js +30 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.js +82 -0
- package/lib/Signal/Group/index.d.ts +12 -0
- package/lib/Signal/Group/index.js +12 -0
- package/lib/Signal/Group/keyhelper.d.ts +11 -0
- package/lib/Signal/Group/keyhelper.js +18 -0
- package/lib/Signal/Group/queue-job.d.ts +2 -0
- package/lib/Signal/Group/queue-job.js +54 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
- package/lib/Signal/Group/sender-chain-key.js +26 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
- package/lib/Signal/Group/sender-key-message.d.ts +19 -0
- package/lib/Signal/Group/sender-key-message.js +66 -0
- package/lib/Signal/Group/sender-key-name.d.ts +18 -0
- package/lib/Signal/Group/sender-key-name.js +48 -0
- package/lib/Signal/Group/sender-key-record.d.ts +31 -0
- package/lib/Signal/Group/sender-key-record.js +41 -0
- package/lib/Signal/Group/sender-key-state.d.ts +39 -0
- package/lib/Signal/Group/sender-key-state.js +84 -0
- package/lib/Signal/Group/sender-message-key.d.ts +12 -0
- package/lib/Signal/Group/sender-message-key.js +26 -0
- package/lib/Signal/libsignal.d.ts +5 -0
- package/lib/Signal/libsignal.js +342 -0
- package/lib/Signal/lid-mapping.d.ts +23 -0
- package/lib/Signal/lid-mapping.js +171 -0
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/index.js +3 -0
- package/lib/Socket/Client/types.d.ts +16 -0
- package/lib/Socket/Client/types.js +11 -0
- package/lib/Socket/Client/websocket.d.ts +13 -0
- package/lib/Socket/Client/websocket.js +50 -0
- package/lib/Socket/business.d.ts +188 -0
- package/lib/Socket/business.js +376 -0
- package/lib/Socket/chats.d.ts +98 -0
- package/lib/Socket/chats.js +962 -0
- package/lib/Socket/communities.d.ts +244 -0
- package/lib/Socket/communities.js +431 -0
- package/lib/Socket/groups.d.ts +137 -0
- package/lib/Socket/groups.js +327 -0
- package/lib/Socket/index.d.ts +231 -0
- package/lib/Socket/index.js +18 -0
- package/lib/Socket/messages-recv.d.ts +173 -0
- package/lib/Socket/messages-recv.js +1228 -0
- package/lib/Socket/messages-send.d.ts +169 -0
- package/lib/Socket/messages-send.js +1070 -0
- package/lib/Socket/mex.d.ts +3 -0
- package/lib/Socket/mex.js +42 -0
- package/lib/Socket/newsletter.d.ts +147 -0
- package/lib/Socket/newsletter.js +181 -0
- package/lib/Socket/socket.d.ts +51 -0
- package/lib/Socket/socket.js +883 -0
- package/lib/Socket/usync.d.ts +37 -0
- package/lib/Socket/usync.js +63 -0
- package/lib/Types/Auth.d.ts +111 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Bussines.d.ts +25 -0
- package/lib/Types/Bussines.js +2 -0
- package/lib/Types/Call.d.ts +14 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.d.ts +123 -0
- package/lib/Types/Chat.js +8 -0
- package/lib/Types/Contact.d.ts +24 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Events.d.ts +202 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/GroupMetadata.d.ts +67 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/Label.d.ts +47 -0
- package/lib/Types/Label.js +25 -0
- package/lib/Types/LabelAssociation.d.ts +30 -0
- package/lib/Types/LabelAssociation.js +7 -0
- package/lib/Types/Message.d.ts +303 -0
- package/lib/Types/Message.js +11 -0
- package/lib/Types/Newsletter.d.ts +135 -0
- package/lib/Types/Newsletter.js +31 -0
- package/lib/Types/Product.d.ts +79 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Signal.d.ts +76 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Socket.d.ts +133 -0
- package/lib/Types/Socket.js +3 -0
- package/lib/Types/State.d.ts +39 -0
- package/lib/Types/State.js +13 -0
- package/lib/Types/USync.d.ts +26 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.d.ts +65 -0
- package/lib/Types/index.js +26 -0
- package/lib/Utils/auth-utils.d.ts +19 -0
- package/lib/Utils/auth-utils.js +257 -0
- package/lib/Utils/baileys-event-stream.d.ts +17 -0
- package/lib/Utils/baileys-event-stream.js +56 -0
- package/lib/Utils/browser-utils.d.ts +4 -0
- package/lib/Utils/browser-utils.js +28 -0
- package/lib/Utils/business.d.ts +23 -0
- package/lib/Utils/business.js +231 -0
- package/lib/Utils/chat-utils.d.ts +70 -0
- package/lib/Utils/chat-utils.js +763 -0
- package/lib/Utils/crypto.d.ts +41 -0
- package/lib/Utils/crypto.js +142 -0
- package/lib/Utils/decode-wa-message.d.ts +48 -0
- package/lib/Utils/decode-wa-message.js +279 -0
- package/lib/Utils/event-buffer.d.ts +34 -0
- package/lib/Utils/event-buffer.js +548 -0
- package/lib/Utils/generics.d.ts +90 -0
- package/lib/Utils/generics.js +381 -0
- package/lib/Utils/history.d.ts +19 -0
- package/lib/Utils/history.js +84 -0
- package/lib/Utils/index.d.ts +20 -0
- package/lib/Utils/index.js +20 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/link-preview.js +85 -0
- package/lib/Utils/logger.d.ts +12 -0
- package/lib/Utils/logger.js +3 -0
- package/lib/Utils/lt-hash.d.ts +13 -0
- package/lib/Utils/lt-hash.js +48 -0
- package/lib/Utils/make-mutex.d.ts +8 -0
- package/lib/Utils/make-mutex.js +40 -0
- package/lib/Utils/message-retry-manager.d.ts +82 -0
- package/lib/Utils/message-retry-manager.js +149 -0
- package/lib/Utils/messages-media.d.ts +114 -0
- package/lib/Utils/messages-media.js +663 -0
- package/lib/Utils/messages.d.ts +76 -0
- package/lib/Utils/messages.js +908 -0
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/noise-handler.js +147 -0
- package/lib/Utils/pre-key-manager.d.ts +28 -0
- package/lib/Utils/pre-key-manager.js +106 -0
- package/lib/Utils/process-message.d.ts +42 -0
- package/lib/Utils/process-message.js +413 -0
- package/lib/Utils/signal.d.ts +34 -0
- package/lib/Utils/signal.js +159 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-multi-file-auth-state.js +121 -0
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/Utils/validate-connection.js +195 -0
- package/lib/WABinary/constants.d.ts +28 -0
- package/lib/WABinary/constants.js +1301 -0
- package/lib/WABinary/decode.d.ts +7 -0
- package/lib/WABinary/decode.js +238 -0
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/encode.js +216 -0
- package/lib/WABinary/generic-utils.d.ts +15 -0
- package/lib/WABinary/generic-utils.js +191 -0
- package/lib/WABinary/index.d.ts +6 -0
- package/lib/WABinary/index.js +6 -0
- package/lib/WABinary/jid-utils.d.ts +48 -0
- package/lib/WABinary/jid-utils.js +96 -0
- package/lib/WABinary/types.d.ts +19 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.d.ts +9 -0
- package/lib/WAM/BinaryInfo.js +10 -0
- package/lib/WAM/constants.d.ts +40 -0
- package/lib/WAM/constants.js +22853 -0
- package/lib/WAM/encode.d.ts +3 -0
- package/lib/WAM/encode.js +150 -0
- package/lib/WAM/index.d.ts +4 -0
- package/lib/WAM/index.js +4 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +29 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +54 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +38 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
- package/lib/WAUSync/Protocols/index.d.ts +5 -0
- package/lib/WAUSync/Protocols/index.js +5 -0
- package/lib/WAUSync/USyncQuery.d.ts +29 -0
- package/lib/WAUSync/USyncQuery.js +94 -0
- package/lib/WAUSync/USyncUser.d.ts +13 -0
- package/lib/WAUSync/USyncUser.js +23 -0
- package/lib/WAUSync/index.d.ts +4 -0
- package/lib/WAUSync/index.js +4 -0
- package/lib/index.d.ts +22 -0
- package/lib/index.js +36 -0
- package/lib/supun +1 -0
- package/package.json +104 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const major = parseInt(process.versions.node.split('.')[0], 10);
|
|
2
|
+
|
|
3
|
+
if (major < 20) {
|
|
4
|
+
console.error(
|
|
5
|
+
`\n❌ This package requires Node.js 20+ to run reliably.\n` +
|
|
6
|
+
` You are using Node.js ${process.versions.node}.\n` +
|
|
7
|
+
` Please upgrade to Node.js 20+ to proceed.\n`
|
|
8
|
+
);
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { proto } from '../../WAProto/index.js';
|
|
2
|
+
import type { SocketConfig } from '../Types/index.js';
|
|
3
|
+
export declare const UNAUTHORIZED_CODES: number[];
|
|
4
|
+
export declare const DEFAULT_ORIGIN = "https://web.whatsapp.com";
|
|
5
|
+
export declare const CALL_VIDEO_PREFIX = "https://call.whatsapp.com/video/";
|
|
6
|
+
export declare const CALL_AUDIO_PREFIX = "https://call.whatsapp.com/voice/";
|
|
7
|
+
export declare const DEF_CALLBACK_PREFIX = "CB:";
|
|
8
|
+
export declare const DEF_TAG_PREFIX = "TAG:";
|
|
9
|
+
export declare const PHONE_CONNECTION_CB = "CB:Pong";
|
|
10
|
+
export declare const WA_ADV_ACCOUNT_SIG_PREFIX: Buffer<ArrayBuffer>;
|
|
11
|
+
export declare const WA_ADV_DEVICE_SIG_PREFIX: Buffer<ArrayBuffer>;
|
|
12
|
+
export declare const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX: Buffer<ArrayBuffer>;
|
|
13
|
+
export declare const WA_ADV_HOSTED_DEVICE_SIG_PREFIX: Buffer<ArrayBuffer>;
|
|
14
|
+
export declare const WA_DEFAULT_EPHEMERAL: number;
|
|
15
|
+
export declare const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
|
|
16
|
+
export declare const DICT_VERSION = 3;
|
|
17
|
+
export declare const KEY_BUNDLE_TYPE: Buffer<ArrayBuffer>;
|
|
18
|
+
export declare const NOISE_WA_HEADER: Buffer<ArrayBuffer>;
|
|
19
|
+
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
20
|
+
export declare const URL_REGEX: RegExp;
|
|
21
|
+
export declare const WA_CERT_DETAILS: {
|
|
22
|
+
SERIAL: number;
|
|
23
|
+
};
|
|
24
|
+
export declare const PROCESSABLE_HISTORY_TYPES: proto.Message.HistorySyncNotification.HistorySyncType[];
|
|
25
|
+
export declare const DEFAULT_CONNECTION_CONFIG: SocketConfig;
|
|
26
|
+
export declare const MEDIA_PATH_MAP: {
|
|
27
|
+
[T in MediaType]?: string;
|
|
28
|
+
};
|
|
29
|
+
export declare const MEDIA_HKDF_KEY_MAPPING: {
|
|
30
|
+
audio: string;
|
|
31
|
+
document: string;
|
|
32
|
+
gif: string;
|
|
33
|
+
image: string;
|
|
34
|
+
ppic: string;
|
|
35
|
+
product: string;
|
|
36
|
+
ptt: string;
|
|
37
|
+
sticker: string;
|
|
38
|
+
video: string;
|
|
39
|
+
'thumbnail-document': string;
|
|
40
|
+
'thumbnail-image': string;
|
|
41
|
+
'thumbnail-video': string;
|
|
42
|
+
'thumbnail-link': string;
|
|
43
|
+
'md-msg-hist': string;
|
|
44
|
+
'md-app-state': string;
|
|
45
|
+
'product-catalog-image': string;
|
|
46
|
+
'payment-bg-image': string;
|
|
47
|
+
ptv: string;
|
|
48
|
+
'biz-cover-photo': string;
|
|
49
|
+
};
|
|
50
|
+
export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
|
|
51
|
+
export declare const MEDIA_KEYS: MediaType[];
|
|
52
|
+
export declare const MIN_PREKEY_COUNT = 5;
|
|
53
|
+
export declare const INITIAL_PREKEY_COUNT = 812;
|
|
54
|
+
export declare const UPLOAD_TIMEOUT = 30000;
|
|
55
|
+
export declare const MIN_UPLOAD_INTERVAL = 5000;
|
|
56
|
+
export declare const DEFAULT_CACHE_TTLS: {
|
|
57
|
+
SIGNAL_STORE: number;
|
|
58
|
+
MSG_RETRY: number;
|
|
59
|
+
CALL_OFFER: number;
|
|
60
|
+
USER_DEVICES: number;
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { proto } from '../../WAProto/index.js';
|
|
2
|
+
import { makeLibSignalRepository } from '../Signal/libsignal.js';
|
|
3
|
+
import { Browsers } from '../Utils/browser-utils.js';
|
|
4
|
+
import logger from '../Utils/logger.js';
|
|
5
|
+
const version = [2, 3000, 102986882];
|
|
6
|
+
export const UNAUTHORIZED_CODES = [401, 403, 419];
|
|
7
|
+
export const DEFAULT_ORIGIN = 'https://web.whatsapp.com';
|
|
8
|
+
export const CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
|
|
9
|
+
export const CALL_AUDIO_PREFIX = 'https://call.whatsapp.com/voice/';
|
|
10
|
+
export const DEF_CALLBACK_PREFIX = 'CB:';
|
|
11
|
+
export const DEF_TAG_PREFIX = 'TAG:';
|
|
12
|
+
export const PHONE_CONNECTION_CB = 'CB:Pong';
|
|
13
|
+
export const WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0]);
|
|
14
|
+
export const WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1]);
|
|
15
|
+
export const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5]);
|
|
16
|
+
export const WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6]);
|
|
17
|
+
export const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
|
|
18
|
+
export const NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0';
|
|
19
|
+
export const DICT_VERSION = 3;
|
|
20
|
+
export const KEY_BUNDLE_TYPE = Buffer.from([5]);
|
|
21
|
+
export const NOISE_WA_HEADER = Buffer.from([87, 65, 6, DICT_VERSION]); // last is "DICT_VERSION"
|
|
22
|
+
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
23
|
+
export const URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
|
|
24
|
+
// TODO: Add WA root CA
|
|
25
|
+
export const WA_CERT_DETAILS = {
|
|
26
|
+
SERIAL: 0
|
|
27
|
+
};
|
|
28
|
+
export const PROCESSABLE_HISTORY_TYPES = [
|
|
29
|
+
proto.Message.HistorySyncNotification.HistorySyncType.INITIAL_BOOTSTRAP,
|
|
30
|
+
proto.Message.HistorySyncNotification.HistorySyncType.PUSH_NAME,
|
|
31
|
+
proto.Message.HistorySyncNotification.HistorySyncType.RECENT,
|
|
32
|
+
proto.Message.HistorySyncNotification.HistorySyncType.FULL,
|
|
33
|
+
proto.Message.HistorySyncNotification.HistorySyncType.ON_DEMAND,
|
|
34
|
+
proto.Message.HistorySyncNotification.HistorySyncType.NON_BLOCKING_DATA,
|
|
35
|
+
proto.Message.HistorySyncNotification.HistorySyncType.INITIAL_STATUS_V3
|
|
36
|
+
];
|
|
37
|
+
export const DEFAULT_CONNECTION_CONFIG = {
|
|
38
|
+
version: version,
|
|
39
|
+
browser: Browsers.macOS('Chrome'),
|
|
40
|
+
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
41
|
+
connectTimeoutMs: 20000,
|
|
42
|
+
keepAliveIntervalMs: 30000,
|
|
43
|
+
logger: logger.child({ class: 'baileys' }),
|
|
44
|
+
emitOwnEvents: true,
|
|
45
|
+
defaultQueryTimeoutMs: 60000,
|
|
46
|
+
customUploadHosts: [],
|
|
47
|
+
retryRequestDelayMs: 250,
|
|
48
|
+
maxMsgRetryCount: 5,
|
|
49
|
+
fireInitQueries: true,
|
|
50
|
+
auth: undefined,
|
|
51
|
+
markOnlineOnConnect: true,
|
|
52
|
+
syncFullHistory: true,
|
|
53
|
+
patchMessageBeforeSending: msg => msg,
|
|
54
|
+
shouldSyncHistoryMessage: () => true,
|
|
55
|
+
shouldIgnoreJid: () => false,
|
|
56
|
+
linkPreviewImageThumbnailWidth: 192,
|
|
57
|
+
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
|
|
58
|
+
generateHighQualityLinkPreview: false,
|
|
59
|
+
enableAutoSessionRecreation: true,
|
|
60
|
+
enableRecentMessageCache: true,
|
|
61
|
+
options: {},
|
|
62
|
+
appStateMacVerification: {
|
|
63
|
+
patch: false,
|
|
64
|
+
snapshot: false
|
|
65
|
+
},
|
|
66
|
+
countryCode: 'US',
|
|
67
|
+
getMessage: async () => undefined,
|
|
68
|
+
cachedGroupMetadata: async () => undefined,
|
|
69
|
+
makeSignalRepository: makeLibSignalRepository
|
|
70
|
+
};
|
|
71
|
+
export const MEDIA_PATH_MAP = {
|
|
72
|
+
image: '/mms/image',
|
|
73
|
+
video: '/mms/video',
|
|
74
|
+
document: '/mms/document',
|
|
75
|
+
audio: '/mms/audio',
|
|
76
|
+
sticker: '/mms/image',
|
|
77
|
+
'thumbnail-link': '/mms/image',
|
|
78
|
+
'product-catalog-image': '/product/image',
|
|
79
|
+
'md-app-state': '',
|
|
80
|
+
'md-msg-hist': '/mms/md-app-state',
|
|
81
|
+
'biz-cover-photo': '/pps/biz-cover-photo'
|
|
82
|
+
};
|
|
83
|
+
export const MEDIA_HKDF_KEY_MAPPING = {
|
|
84
|
+
audio: 'Audio',
|
|
85
|
+
document: 'Document',
|
|
86
|
+
gif: 'Video',
|
|
87
|
+
image: 'Image',
|
|
88
|
+
ppic: '',
|
|
89
|
+
product: 'Image',
|
|
90
|
+
ptt: 'Audio',
|
|
91
|
+
sticker: 'Image',
|
|
92
|
+
video: 'Video',
|
|
93
|
+
'thumbnail-document': 'Document Thumbnail',
|
|
94
|
+
'thumbnail-image': 'Image Thumbnail',
|
|
95
|
+
'thumbnail-video': 'Video Thumbnail',
|
|
96
|
+
'thumbnail-link': 'Link Thumbnail',
|
|
97
|
+
'md-msg-hist': 'History',
|
|
98
|
+
'md-app-state': 'App State',
|
|
99
|
+
'product-catalog-image': '',
|
|
100
|
+
'payment-bg-image': 'Payment Background',
|
|
101
|
+
ptv: 'Video',
|
|
102
|
+
'biz-cover-photo': 'Image'
|
|
103
|
+
};
|
|
104
|
+
export const MEDIA_KEYS = Object.keys(MEDIA_PATH_MAP);
|
|
105
|
+
export const MIN_PREKEY_COUNT = 5;
|
|
106
|
+
export const INITIAL_PREKEY_COUNT = 812;
|
|
107
|
+
export const UPLOAD_TIMEOUT = 30000; // 30 seconds
|
|
108
|
+
export const MIN_UPLOAD_INTERVAL = 5000; // 5 seconds minimum between uploads
|
|
109
|
+
export const DEFAULT_CACHE_TTLS = {
|
|
110
|
+
SIGNAL_STORE: 5 * 60, // 5 minutes
|
|
111
|
+
MSG_RETRY: 60 * 60, // 1 hour
|
|
112
|
+
CALL_OFFER: 5 * 60, // 5 minutes
|
|
113
|
+
USER_DEVICES: 5 * 60 // 5 minutes
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class CiphertextMessage {
|
|
2
|
+
readonly UNSUPPORTED_VERSION: number;
|
|
3
|
+
readonly CURRENT_VERSION: number;
|
|
4
|
+
readonly WHISPER_TYPE: number;
|
|
5
|
+
readonly PREKEY_TYPE: number;
|
|
6
|
+
readonly SENDERKEY_TYPE: number;
|
|
7
|
+
readonly SENDERKEY_DISTRIBUTION_TYPE: number;
|
|
8
|
+
readonly ENCRYPTED_MESSAGE_OVERHEAD: number;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=ciphertext-message.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export class CiphertextMessage {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.UNSUPPORTED_VERSION = 1;
|
|
4
|
+
this.CURRENT_VERSION = 3;
|
|
5
|
+
this.WHISPER_TYPE = 2;
|
|
6
|
+
this.PREKEY_TYPE = 3;
|
|
7
|
+
this.SENDERKEY_TYPE = 4;
|
|
8
|
+
this.SENDERKEY_DISTRIBUTION_TYPE = 5;
|
|
9
|
+
this.ENCRYPTED_MESSAGE_OVERHEAD = 53;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=ciphertext-message.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SenderKeyDistributionMessage } from './sender-key-distribution-message.js';
|
|
2
|
+
import { SenderKeyName } from './sender-key-name.js';
|
|
3
|
+
import { SenderKeyRecord } from './sender-key-record.js';
|
|
4
|
+
interface SenderKeyStore {
|
|
5
|
+
loadSenderKey(senderKeyName: SenderKeyName): Promise<SenderKeyRecord>;
|
|
6
|
+
storeSenderKey(senderKeyName: SenderKeyName, record: SenderKeyRecord): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare class GroupSessionBuilder {
|
|
9
|
+
private readonly senderKeyStore;
|
|
10
|
+
constructor(senderKeyStore: SenderKeyStore);
|
|
11
|
+
process(senderKeyName: SenderKeyName, senderKeyDistributionMessage: SenderKeyDistributionMessage): Promise<void>;
|
|
12
|
+
create(senderKeyName: SenderKeyName): Promise<SenderKeyDistributionMessage>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=group-session-builder.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as keyhelper from './keyhelper.js';
|
|
2
|
+
import { SenderKeyDistributionMessage } from './sender-key-distribution-message.js';
|
|
3
|
+
import { SenderKeyName } from './sender-key-name.js';
|
|
4
|
+
import { SenderKeyRecord } from './sender-key-record.js';
|
|
5
|
+
export class GroupSessionBuilder {
|
|
6
|
+
constructor(senderKeyStore) {
|
|
7
|
+
this.senderKeyStore = senderKeyStore;
|
|
8
|
+
}
|
|
9
|
+
async process(senderKeyName, senderKeyDistributionMessage) {
|
|
10
|
+
const senderKeyRecord = await this.senderKeyStore.loadSenderKey(senderKeyName);
|
|
11
|
+
senderKeyRecord.addSenderKeyState(senderKeyDistributionMessage.getId(), senderKeyDistributionMessage.getIteration(), senderKeyDistributionMessage.getChainKey(), senderKeyDistributionMessage.getSignatureKey());
|
|
12
|
+
await this.senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord);
|
|
13
|
+
}
|
|
14
|
+
async create(senderKeyName) {
|
|
15
|
+
const senderKeyRecord = await this.senderKeyStore.loadSenderKey(senderKeyName);
|
|
16
|
+
if (senderKeyRecord.isEmpty()) {
|
|
17
|
+
const keyId = keyhelper.generateSenderKeyId();
|
|
18
|
+
const senderKey = keyhelper.generateSenderKey();
|
|
19
|
+
const signingKey = keyhelper.generateSenderSigningKey();
|
|
20
|
+
senderKeyRecord.setSenderKeyState(keyId, 0, senderKey, signingKey);
|
|
21
|
+
await this.senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord);
|
|
22
|
+
}
|
|
23
|
+
const state = senderKeyRecord.getSenderKeyState();
|
|
24
|
+
if (!state) {
|
|
25
|
+
throw new Error('No session state available');
|
|
26
|
+
}
|
|
27
|
+
return new SenderKeyDistributionMessage(state.getKeyId(), state.getSenderChainKey().getIteration(), state.getSenderChainKey().getSeed(), state.getSigningKeyPublic());
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=group-session-builder.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SenderKeyName } from './sender-key-name.js';
|
|
2
|
+
import { SenderKeyRecord } from './sender-key-record.js';
|
|
3
|
+
export interface SenderKeyStore {
|
|
4
|
+
loadSenderKey(senderKeyName: SenderKeyName): Promise<SenderKeyRecord>;
|
|
5
|
+
storeSenderKey(senderKeyName: SenderKeyName, record: SenderKeyRecord): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export declare class GroupCipher {
|
|
8
|
+
private readonly senderKeyStore;
|
|
9
|
+
private readonly senderKeyName;
|
|
10
|
+
constructor(senderKeyStore: SenderKeyStore, senderKeyName: SenderKeyName);
|
|
11
|
+
encrypt(paddedPlaintext: Uint8Array): Promise<Uint8Array>;
|
|
12
|
+
decrypt(senderKeyMessageBytes: Uint8Array): Promise<Uint8Array>;
|
|
13
|
+
private getSenderKey;
|
|
14
|
+
private getPlainText;
|
|
15
|
+
private getCipherText;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=group_cipher.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { decrypt, encrypt } from 'libsignal/src/crypto.js';
|
|
2
|
+
import { SenderKeyMessage } from './sender-key-message.js';
|
|
3
|
+
import { SenderKeyName } from './sender-key-name.js';
|
|
4
|
+
import { SenderKeyRecord } from './sender-key-record.js';
|
|
5
|
+
import { SenderKeyState } from './sender-key-state.js';
|
|
6
|
+
export class GroupCipher {
|
|
7
|
+
constructor(senderKeyStore, senderKeyName) {
|
|
8
|
+
this.senderKeyStore = senderKeyStore;
|
|
9
|
+
this.senderKeyName = senderKeyName;
|
|
10
|
+
}
|
|
11
|
+
async encrypt(paddedPlaintext) {
|
|
12
|
+
const record = await this.senderKeyStore.loadSenderKey(this.senderKeyName);
|
|
13
|
+
if (!record) {
|
|
14
|
+
throw new Error('No SenderKeyRecord found for encryption');
|
|
15
|
+
}
|
|
16
|
+
const senderKeyState = record.getSenderKeyState();
|
|
17
|
+
if (!senderKeyState) {
|
|
18
|
+
throw new Error('No session to encrypt message');
|
|
19
|
+
}
|
|
20
|
+
const iteration = senderKeyState.getSenderChainKey().getIteration();
|
|
21
|
+
const senderKey = this.getSenderKey(senderKeyState, iteration === 0 ? 0 : iteration + 1);
|
|
22
|
+
const ciphertext = await this.getCipherText(senderKey.getIv(), senderKey.getCipherKey(), paddedPlaintext);
|
|
23
|
+
const senderKeyMessage = new SenderKeyMessage(senderKeyState.getKeyId(), senderKey.getIteration(), ciphertext, senderKeyState.getSigningKeyPrivate());
|
|
24
|
+
await this.senderKeyStore.storeSenderKey(this.senderKeyName, record);
|
|
25
|
+
return senderKeyMessage.serialize();
|
|
26
|
+
}
|
|
27
|
+
async decrypt(senderKeyMessageBytes) {
|
|
28
|
+
const record = await this.senderKeyStore.loadSenderKey(this.senderKeyName);
|
|
29
|
+
if (!record) {
|
|
30
|
+
throw new Error('No SenderKeyRecord found for decryption');
|
|
31
|
+
}
|
|
32
|
+
const senderKeyMessage = new SenderKeyMessage(null, null, null, null, senderKeyMessageBytes);
|
|
33
|
+
const senderKeyState = record.getSenderKeyState(senderKeyMessage.getKeyId());
|
|
34
|
+
if (!senderKeyState) {
|
|
35
|
+
throw new Error('No session found to decrypt message');
|
|
36
|
+
}
|
|
37
|
+
senderKeyMessage.verifySignature(senderKeyState.getSigningKeyPublic());
|
|
38
|
+
const senderKey = this.getSenderKey(senderKeyState, senderKeyMessage.getIteration());
|
|
39
|
+
const plaintext = await this.getPlainText(senderKey.getIv(), senderKey.getCipherKey(), senderKeyMessage.getCipherText());
|
|
40
|
+
await this.senderKeyStore.storeSenderKey(this.senderKeyName, record);
|
|
41
|
+
return plaintext;
|
|
42
|
+
}
|
|
43
|
+
getSenderKey(senderKeyState, iteration) {
|
|
44
|
+
let senderChainKey = senderKeyState.getSenderChainKey();
|
|
45
|
+
if (senderChainKey.getIteration() > iteration) {
|
|
46
|
+
if (senderKeyState.hasSenderMessageKey(iteration)) {
|
|
47
|
+
const messageKey = senderKeyState.removeSenderMessageKey(iteration);
|
|
48
|
+
if (!messageKey) {
|
|
49
|
+
throw new Error('No sender message key found for iteration');
|
|
50
|
+
}
|
|
51
|
+
return messageKey;
|
|
52
|
+
}
|
|
53
|
+
throw new Error(`Received message with old counter: ${senderChainKey.getIteration()}, ${iteration}`);
|
|
54
|
+
}
|
|
55
|
+
if (iteration - senderChainKey.getIteration() > 2000) {
|
|
56
|
+
throw new Error('Over 2000 messages into the future!');
|
|
57
|
+
}
|
|
58
|
+
while (senderChainKey.getIteration() < iteration) {
|
|
59
|
+
senderKeyState.addSenderMessageKey(senderChainKey.getSenderMessageKey());
|
|
60
|
+
senderChainKey = senderChainKey.getNext();
|
|
61
|
+
}
|
|
62
|
+
senderKeyState.setSenderChainKey(senderChainKey.getNext());
|
|
63
|
+
return senderChainKey.getSenderMessageKey();
|
|
64
|
+
}
|
|
65
|
+
async getPlainText(iv, key, ciphertext) {
|
|
66
|
+
try {
|
|
67
|
+
return decrypt(key, ciphertext, iv);
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
throw new Error('InvalidMessageException');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async getCipherText(iv, key, plaintext) {
|
|
74
|
+
try {
|
|
75
|
+
return encrypt(key, plaintext, iv);
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
throw new Error('InvalidMessageException');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=group_cipher.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { GroupSessionBuilder } from './group-session-builder.js';
|
|
2
|
+
export { SenderKeyDistributionMessage } from './sender-key-distribution-message.js';
|
|
3
|
+
export { SenderKeyRecord } from './sender-key-record.js';
|
|
4
|
+
export { SenderKeyName } from './sender-key-name.js';
|
|
5
|
+
export { GroupCipher } from './group_cipher.js';
|
|
6
|
+
export { SenderKeyState } from './sender-key-state.js';
|
|
7
|
+
export { SenderKeyMessage } from './sender-key-message.js';
|
|
8
|
+
export { SenderMessageKey } from './sender-message-key.js';
|
|
9
|
+
export { SenderChainKey } from './sender-chain-key.js';
|
|
10
|
+
export { CiphertextMessage } from './ciphertext-message.js';
|
|
11
|
+
export * as keyhelper from './keyhelper.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { GroupSessionBuilder } from './group-session-builder.js';
|
|
2
|
+
export { SenderKeyDistributionMessage } from './sender-key-distribution-message.js';
|
|
3
|
+
export { SenderKeyRecord } from './sender-key-record.js';
|
|
4
|
+
export { SenderKeyName } from './sender-key-name.js';
|
|
5
|
+
export { GroupCipher } from './group_cipher.js';
|
|
6
|
+
export { SenderKeyState } from './sender-key-state.js';
|
|
7
|
+
export { SenderKeyMessage } from './sender-key-message.js';
|
|
8
|
+
export { SenderMessageKey } from './sender-message-key.js';
|
|
9
|
+
export { SenderChainKey } from './sender-chain-key.js';
|
|
10
|
+
export { CiphertextMessage } from './ciphertext-message.js';
|
|
11
|
+
export * as keyhelper from './keyhelper.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { generateKeyPair } from 'libsignal/src/curve.js';
|
|
2
|
+
type KeyPairType = ReturnType<typeof generateKeyPair>;
|
|
3
|
+
export declare function generateSenderKey(): Buffer;
|
|
4
|
+
export declare function generateSenderKeyId(): number;
|
|
5
|
+
export interface SigningKeyPair {
|
|
6
|
+
public: Buffer;
|
|
7
|
+
private: Buffer;
|
|
8
|
+
}
|
|
9
|
+
export declare function generateSenderSigningKey(key?: KeyPairType): SigningKeyPair;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=keyhelper.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as nodeCrypto from 'crypto';
|
|
2
|
+
import { generateKeyPair } from 'libsignal/src/curve.js';
|
|
3
|
+
export function generateSenderKey() {
|
|
4
|
+
return nodeCrypto.randomBytes(32);
|
|
5
|
+
}
|
|
6
|
+
export function generateSenderKeyId() {
|
|
7
|
+
return nodeCrypto.randomInt(2147483647);
|
|
8
|
+
}
|
|
9
|
+
export function generateSenderSigningKey(key) {
|
|
10
|
+
if (!key) {
|
|
11
|
+
key = generateKeyPair();
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
public: Buffer.from(key.pubKey),
|
|
15
|
+
private: Buffer.from(key.privKey)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=keyhelper.js.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const _queueAsyncBuckets = new Map();
|
|
2
|
+
const _gcLimit = 10000;
|
|
3
|
+
async function _asyncQueueExecutor(queue, cleanup) {
|
|
4
|
+
let offt = 0;
|
|
5
|
+
while (true) {
|
|
6
|
+
const limit = Math.min(queue.length, _gcLimit);
|
|
7
|
+
for (let i = offt; i < limit; i++) {
|
|
8
|
+
const job = queue[i];
|
|
9
|
+
try {
|
|
10
|
+
job.resolve(await job.awaitable());
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
job.reject(e);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (limit < queue.length) {
|
|
17
|
+
if (limit >= _gcLimit) {
|
|
18
|
+
queue.splice(0, limit);
|
|
19
|
+
offt = 0;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
offt = limit;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
cleanup();
|
|
30
|
+
}
|
|
31
|
+
export default function queueJob(bucket, awaitable) {
|
|
32
|
+
// Skip name assignment since it's readonly in strict mode
|
|
33
|
+
if (typeof bucket !== 'string') {
|
|
34
|
+
console.warn('Unhandled bucket type (for naming):', typeof bucket, bucket);
|
|
35
|
+
}
|
|
36
|
+
let inactive = false;
|
|
37
|
+
if (!_queueAsyncBuckets.has(bucket)) {
|
|
38
|
+
_queueAsyncBuckets.set(bucket, []);
|
|
39
|
+
inactive = true;
|
|
40
|
+
}
|
|
41
|
+
const queue = _queueAsyncBuckets.get(bucket);
|
|
42
|
+
const job = new Promise((resolve, reject) => {
|
|
43
|
+
queue.push({
|
|
44
|
+
awaitable,
|
|
45
|
+
resolve: resolve,
|
|
46
|
+
reject
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
if (inactive) {
|
|
50
|
+
_asyncQueueExecutor(queue, () => _queueAsyncBuckets.delete(bucket));
|
|
51
|
+
}
|
|
52
|
+
return job;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=queue-job.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SenderMessageKey } from './sender-message-key.js';
|
|
2
|
+
export declare class SenderChainKey {
|
|
3
|
+
private readonly MESSAGE_KEY_SEED;
|
|
4
|
+
private readonly CHAIN_KEY_SEED;
|
|
5
|
+
private readonly iteration;
|
|
6
|
+
private readonly chainKey;
|
|
7
|
+
constructor(iteration: number, chainKey: Uint8Array | Buffer);
|
|
8
|
+
getIteration(): number;
|
|
9
|
+
getSenderMessageKey(): SenderMessageKey;
|
|
10
|
+
getNext(): SenderChainKey;
|
|
11
|
+
getSeed(): Uint8Array;
|
|
12
|
+
private getDerivative;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=sender-chain-key.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { calculateMAC } from 'libsignal/src/crypto.js';
|
|
2
|
+
import { SenderMessageKey } from './sender-message-key.js';
|
|
3
|
+
export class SenderChainKey {
|
|
4
|
+
constructor(iteration, chainKey) {
|
|
5
|
+
this.MESSAGE_KEY_SEED = Buffer.from([0x01]);
|
|
6
|
+
this.CHAIN_KEY_SEED = Buffer.from([0x02]);
|
|
7
|
+
this.iteration = iteration;
|
|
8
|
+
this.chainKey = Buffer.from(chainKey);
|
|
9
|
+
}
|
|
10
|
+
getIteration() {
|
|
11
|
+
return this.iteration;
|
|
12
|
+
}
|
|
13
|
+
getSenderMessageKey() {
|
|
14
|
+
return new SenderMessageKey(this.iteration, this.getDerivative(this.MESSAGE_KEY_SEED, this.chainKey));
|
|
15
|
+
}
|
|
16
|
+
getNext() {
|
|
17
|
+
return new SenderChainKey(this.iteration + 1, this.getDerivative(this.CHAIN_KEY_SEED, this.chainKey));
|
|
18
|
+
}
|
|
19
|
+
getSeed() {
|
|
20
|
+
return this.chainKey;
|
|
21
|
+
}
|
|
22
|
+
getDerivative(seed, key) {
|
|
23
|
+
return calculateMAC(key, seed);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=sender-chain-key.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CiphertextMessage } from './ciphertext-message.js';
|
|
2
|
+
export declare class SenderKeyDistributionMessage extends CiphertextMessage {
|
|
3
|
+
private readonly id;
|
|
4
|
+
private readonly iteration;
|
|
5
|
+
private readonly chainKey;
|
|
6
|
+
private readonly signatureKey;
|
|
7
|
+
private readonly serialized;
|
|
8
|
+
constructor(id?: number | null, iteration?: number | null, chainKey?: Uint8Array | null, signatureKey?: Uint8Array | null, serialized?: Uint8Array | null);
|
|
9
|
+
private intsToByteHighAndLow;
|
|
10
|
+
serialize(): Uint8Array;
|
|
11
|
+
getType(): number;
|
|
12
|
+
getIteration(): number;
|
|
13
|
+
getChainKey(): Uint8Array;
|
|
14
|
+
getSignatureKey(): Uint8Array;
|
|
15
|
+
getId(): number;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=sender-key-distribution-message.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { proto } from '../../../WAProto/index.js';
|
|
2
|
+
import { CiphertextMessage } from './ciphertext-message.js';
|
|
3
|
+
export class SenderKeyDistributionMessage extends CiphertextMessage {
|
|
4
|
+
constructor(id, iteration, chainKey, signatureKey, serialized) {
|
|
5
|
+
super();
|
|
6
|
+
if (serialized) {
|
|
7
|
+
try {
|
|
8
|
+
const message = serialized.slice(1);
|
|
9
|
+
const distributionMessage = proto.SenderKeyDistributionMessage.decode(message).toJSON();
|
|
10
|
+
this.serialized = serialized;
|
|
11
|
+
this.id = distributionMessage.id;
|
|
12
|
+
this.iteration = distributionMessage.iteration;
|
|
13
|
+
this.chainKey =
|
|
14
|
+
typeof distributionMessage.chainKey === 'string'
|
|
15
|
+
? Buffer.from(distributionMessage.chainKey, 'base64')
|
|
16
|
+
: distributionMessage.chainKey;
|
|
17
|
+
this.signatureKey =
|
|
18
|
+
typeof distributionMessage.signingKey === 'string'
|
|
19
|
+
? Buffer.from(distributionMessage.signingKey, 'base64')
|
|
20
|
+
: distributionMessage.signingKey;
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
throw new Error(String(e));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const version = this.intsToByteHighAndLow(this.CURRENT_VERSION, this.CURRENT_VERSION);
|
|
28
|
+
this.id = id;
|
|
29
|
+
this.iteration = iteration;
|
|
30
|
+
this.chainKey = chainKey;
|
|
31
|
+
this.signatureKey = signatureKey;
|
|
32
|
+
const message = proto.SenderKeyDistributionMessage.encode(proto.SenderKeyDistributionMessage.create({
|
|
33
|
+
id,
|
|
34
|
+
iteration,
|
|
35
|
+
chainKey,
|
|
36
|
+
signingKey: this.signatureKey
|
|
37
|
+
})).finish();
|
|
38
|
+
this.serialized = Buffer.concat([Buffer.from([version]), message]);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
intsToByteHighAndLow(highValue, lowValue) {
|
|
42
|
+
return (((highValue << 4) | lowValue) & 0xff) % 256;
|
|
43
|
+
}
|
|
44
|
+
serialize() {
|
|
45
|
+
return this.serialized;
|
|
46
|
+
}
|
|
47
|
+
getType() {
|
|
48
|
+
return this.SENDERKEY_DISTRIBUTION_TYPE;
|
|
49
|
+
}
|
|
50
|
+
getIteration() {
|
|
51
|
+
return this.iteration;
|
|
52
|
+
}
|
|
53
|
+
getChainKey() {
|
|
54
|
+
return this.chainKey;
|
|
55
|
+
}
|
|
56
|
+
getSignatureKey() {
|
|
57
|
+
return this.signatureKey;
|
|
58
|
+
}
|
|
59
|
+
getId() {
|
|
60
|
+
return this.id;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=sender-key-distribution-message.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CiphertextMessage } from './ciphertext-message.js';
|
|
2
|
+
export declare class SenderKeyMessage extends CiphertextMessage {
|
|
3
|
+
private readonly SIGNATURE_LENGTH;
|
|
4
|
+
private readonly messageVersion;
|
|
5
|
+
private readonly keyId;
|
|
6
|
+
private readonly iteration;
|
|
7
|
+
private readonly ciphertext;
|
|
8
|
+
private readonly signature;
|
|
9
|
+
private readonly serialized;
|
|
10
|
+
constructor(keyId?: number | null, iteration?: number | null, ciphertext?: Uint8Array | null, signatureKey?: Uint8Array | null, serialized?: Uint8Array | null);
|
|
11
|
+
getKeyId(): number;
|
|
12
|
+
getIteration(): number;
|
|
13
|
+
getCipherText(): Uint8Array;
|
|
14
|
+
verifySignature(signatureKey: Uint8Array): void;
|
|
15
|
+
private getSignature;
|
|
16
|
+
serialize(): Uint8Array;
|
|
17
|
+
getType(): number;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=sender-key-message.d.ts.map
|