Skip to content

Instantly share code, notes, and snippets.

@pmrt

pmrt/appInfo.js

Created Nov 3, 2019
Embed
What would you like to do?
WhatsApp constants
// appInfo (for HKDF)
feacbgeaf: function(e, t, n) {
"use strict";
Object.defineProperty(t, "__esModule", {
value: !0
}), t.default = function(e, t) {
var n = function(e) {
return (0, i.default)(e, {
[u.default.AUDIO]: function() {
return "WhatsApp Audio Keys"
},
[u.default.DOCUMENT]: function() {
return "WhatsApp Document Keys"
},
[u.default.GIF]: function() {
return "WhatsApp Video Keys"
},
[u.default.IMAGE]: function() {
return "WhatsApp Image Keys"
},
[u.default.PPIC]: function() {
throw new Error("Cannot create media keys for profile pics")
},
[u.default.PRODUCT]: function() {
return "WhatsApp Image Keys"
},
[u.default.PTT]: function() {
return "WhatsApp Audio Keys"
},
[u.default.STICKER]: function() {
return "WhatsApp Image Keys"
},
[u.default.VIDEO]: function() {
return "WhatsApp Video Keys"
},
[u.default.TEMPLATE]: function() {
return "WhatsApp Template Keys"
}
})
}(e);
if (!t || !n) throw new r.MediaEncryptionError(`createKeys fail: !!mediakey: ${!!t} info: ${n} type: ${e}`);
return o.default.extractAndExpand(a.default.decode(t), n, 112).then(function(e) {
if (!e || e.byteLength < 112) throw new r.MediaEncryptionError("computeMediaKeys: hkdf error");
return {
iv: e.slice(0, 16),
encKey: e.slice(16, 48),
macKey: e.slice(48, 80),
refKey: e.slice(80, 112)
}
})
};
MSG_TYPE: {
NOTIFICATION: "notification",
NOTIFICATION_TEMPLATE: "notification_template",
GROUP_NOTIFICATION: "group_notification",
GP2: "gp2",
BROADCAST_NOTIFICATION: "broadcast_notification",
E2E_NOTIFICATION: "e2e_notification",
CALL_LOG: "call_log",
PROTOCOL: "protocol",
CHAT: "chat",
LOCATION: "location",
PAYMENT: "payment",
VCARD: "vcard",
CIPHERTEXT: "ciphertext",
MULTI_VCARD: "multi_vcard",
REVOKED: "revoked",
OVERSIZED: "oversized",
GROUPS_V4_INVITE: "groups_v4_invite",
TEMPLATE: "template",
HSM: "hsm",
TEMPLATE_BUTTON_REPLY: "template_button_reply",
IMAGE: "image",
VIDEO: "video",
AUDIO: "audio",
PTT: "ptt",
STICKER: "sticker",
DOCUMENT: "document",
PRODUCT: "product",
UNKNOWN: "unknown"
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment