diff --git a/dist/util/checkToken.d.ts b/dist/util/checkToken.d.ts index 478d382a0..f8dcbe129 100644 --- a/dist/util/checkToken.d.ts +++ b/dist/util/checkToken.d.ts @@ -1 +1 @@ -export declare function checkToken(token: string): Promise; +export declare function checkToken(token: string): Promise; diff --git a/dist/util/convertBigIntToString.d.ts b/dist/util/convertBigIntToString.d.ts new file mode 100644 index 000000000..b0efd9c4c --- /dev/null +++ b/dist/util/convertBigIntToString.d.ts @@ -0,0 +1,2 @@ +import "missing-native-js-functions"; +export declare function convertBigIntToString(obj: any): any; diff --git a/dist/util/convertBigIntToString.js b/dist/util/convertBigIntToString.js new file mode 100644 index 000000000..a72b5a571 --- /dev/null +++ b/dist/util/convertBigIntToString.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.convertBigIntToString = void 0; +require("missing-native-js-functions"); +function convertBigIntToString(obj) { + if (typeof obj === "bigint") + obj = obj.toString(); + if (typeof obj === "object") { + obj.keys().forEach((key) => { + obj[key] = convertBigIntToString(obj[key]); + }); + } + return obj; +} +exports.convertBigIntToString = convertBigIntToString; +//# sourceMappingURL=convertBigIntToString.js.map \ No newline at end of file diff --git a/dist/util/convertBigIntToString.js.map b/dist/util/convertBigIntToString.js.map new file mode 100644 index 000000000..010706aa0 --- /dev/null +++ b/dist/util/convertBigIntToString.js.map @@ -0,0 +1 @@ +{"version":3,"file":"convertBigIntToString.js","sourceRoot":"","sources":["../../src/util/convertBigIntToString.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AAErC,SAAgB,qBAAqB,CAAC,GAAQ;IAC7C,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,GAAG,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;IAElD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC5B,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;YAClC,GAAG,CAAC,GAAG,CAAC,GAAG,qBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;KACH;IAED,OAAO,GAAG,CAAC;AACZ,CAAC;AAVD,sDAUC"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 6a78da57d..267e87120 100644 Binary files a/package-lock.json and b/package-lock.json differ diff --git a/package.json b/package.json index 91e82f3af..049fdd2ab 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,8 @@ "homepage": "https://github.com/discord-open-source/discord-server-util#readme", "dependencies": { "jsonwebtoken": "^8.5.1", - "lambert-db": "^1.1.4" + "lambert-db": "^1.1.4", + "missing-native-js-functions": "^1.2.1" }, "devDependencies": { "@types/jsonwebtoken": "^8.5.0", diff --git a/src/util/checkToken.ts b/src/util/checkToken.ts index 96c7806ad..b46351264 100644 --- a/src/util/checkToken.ts +++ b/src/util/checkToken.ts @@ -2,7 +2,7 @@ import { JWTOptions } from "./Constants"; import jwt from "jsonwebtoken"; import Config from "./Config"; -export function checkToken(token: string) { +export function checkToken(token: string): Promise { return new Promise((res, rej) => { jwt.verify(token, Config.getAll().api.security.jwtSecret, JWTOptions, (err, decoded: any) => { if (err || !decoded) return rej("Invalid Token"); diff --git a/src/util/convertBigIntToString.ts b/src/util/convertBigIntToString.ts new file mode 100644 index 000000000..2c8d9a383 --- /dev/null +++ b/src/util/convertBigIntToString.ts @@ -0,0 +1,13 @@ +import "missing-native-js-functions"; + +export function convertBigIntToString(obj: any) { + if (typeof obj === "bigint") obj = obj.toString(); + + if (typeof obj === "object") { + obj.keys().forEach((key: string) => { + obj[key] = convertBigIntToString(obj[key]); + }); + } + + return obj; +}