fix compilation errors

This commit is contained in:
Adhiraj Singh
2021-09-25 18:04:26 +05:30
parent 671ea3e097
commit fff2e58997
6 changed files with 46 additions and 42 deletions

View File

@@ -1,5 +1,5 @@
import { hexAt, hexLongIsNegative, hexLongToHex, negateHexLong, NUM_HEX_IN_LONG } from "./HexHelper";
import { inflateSync } from 'zlib'
const { hexAt, hexLongIsNegative, hexLongToHex, negateHexLong, NUM_HEX_IN_LONG } = require("./HexHelper");
const { inflateSync } = require("zlib")
var l = "",
d = 0;
@@ -236,12 +236,12 @@ function H(e, t, r) {
return 128 == (192 & a) ? a : 0;
}
export const numUtf8Bytes = u;
export const longFitsInDouble = c;
export const parseInt64OrThrow = j;
export const parseUint64OrThrow = W;
module.exports.numUtf8Bytes = u;
module.exports.longFitsInDouble = c;
module.exports.parseInt64OrThrow = j;
module.exports.parseUint64OrThrow = W;
export class Binary {
class Binary {
/** @type {Uint8Array} */
buffer;
readEndIndex;
@@ -583,3 +583,5 @@ export class Binary {
return this
}
}
module.exports.Binary = Binary

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
import * as Crypto from "crypto";
const { randomBytes } = require('crypto')
const r = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70],
a = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102];
@@ -36,19 +36,19 @@ const d = (e) => {
return o((e >= 0 ? e : 4294967296 + e).toString(16), 8);
};
export const NUM_HEX_IN_LONG = 16;
export const HEX_LOWER = a;
module.exports.NUM_HEX_IN_LONG = 16;
module.exports.HEX_LOWER = a;
export const randomHex = function (e) {
module.exports.randomHex = function (e) {
var t = new Uint8Array(e);
var bytes = Crypto.randomBytes(t.length);
var bytes = randomBytes(t.length);
t.set(bytes);
return i(t);
};
export const toHex = i;
module.exports.toHex = i;
export const toLowerCaseHex = function (e) {
module.exports.toLowerCaseHex = function (e) {
for (var t = [], r = 0; r < e.length; r++) {
var i = e[r];
t.push(a[i >> 4], a[15 & i]);
@@ -56,7 +56,7 @@ export const toLowerCaseHex = function (e) {
return String.fromCharCode.apply(String, t);
};
export const parseHex = function (e) {
module.exports.parseHex = function (e) {
var t = s(e);
if (t.length % 2 != 0)
throw new Error(
@@ -71,16 +71,16 @@ export const parseHex = function (e) {
return r.buffer;
};
export const hexAt = n;
export const hexOrThrow = s;
export const bytesToBuffer = function (e) {
module.exports.hexAt = n;
module.exports.hexOrThrow = s;
module.exports.bytesToBuffer = function (e) {
var t = e.buffer;
return 0 === e.byteOffset && e.length === t.byteLength
? t
: t.slice(e.byteOffset, e.byteOffset + e.length);
};
export const bytesToDebugString = function (e) {
module.exports.bytesToDebugString = function (e) {
var t = !0,
r = e.length;
for (; t && r; ) {
@@ -90,7 +90,7 @@ export const bytesToDebugString = function (e) {
return t ? JSON.stringify(String.fromCharCode.apply(String, e)) : i(e);
};
export const createHexLong = function (e, t = !1) {
module.exports.createHexLong = function (e, t = !1) {
var r = s(e);
return (
(function (e, t) {
@@ -100,18 +100,18 @@ export const createHexLong = function (e, t = !1) {
);
};
export const createHexLongFrom32Bits = function (e, t, r = !1) {
module.exports.createHexLongFrom32Bits = function (e, t, r = !1) {
var a = d(e),
i = d(t);
return `${r ? "-" : ""}0x${a}${i}`;
};
export const hexLongToHex = function (e) {
module.exports.hexLongToHex = function (e) {
return e.substring(e.indexOf("0x") + 2);
};
export const hexLongIsNegative = l;
module.exports.hexLongIsNegative = l;
export const negateHexLong = function (e) {
module.exports.negateHexLong = function (e) {
return l(e) ? e.slice(1) : "-" + e;
};

View File

@@ -1,7 +1,7 @@
{
"name": "@adiwajshing/baileys",
"version": "4.0.0",
"description": "WhatsApp Web API",
"description": "WhatsApp Multi-Device API",
"homepage": "https://github.com/adiwajshing/Baileys",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@@ -13,7 +13,8 @@
"whatsapp",
"whatsapp-chat",
"whatsapp-group",
"automation"
"automation",
"multi-device"
],
"scripts": {
"test": "mocha --timeout 240000 -r ts-node/register src/Tests/Tests.*.ts",

View File

@@ -1,4 +1,4 @@
import { hkdf } from "../Utils/generics";
const { hkdf } = require("../Utils/generics");
const o = 128;
@@ -45,4 +45,4 @@ class d {
return a
}
}
export const LT_HASH_ANTI_TAMPERING = new d('WhatsApp Patch Integrity')
module.exports.LT_HASH_ANTI_TAMPERING = new d('WhatsApp Patch Integrity')

View File

@@ -3,7 +3,7 @@
"target": "es2018",
"module": "commonjs",
"experimentalDecorators": true,
"allowJs": true,
"allowJs": false,
"checkJs": false,
"outDir": "lib",
"strict": false,
@@ -14,6 +14,6 @@
"declaration": true,
"lib": ["es2020", "esnext.array"]
},
"include": ["src/**/*.ts"],
"include": ["./src/**/*.ts"],
"exclude": ["node_modules", "src/Tests/*", "src/Binary/GenerateStatics.ts"]
}