1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-22 10:22:39 +01:00

convertBigIntToString

This commit is contained in:
Flam3rboy 2021-02-06 09:20:07 +01:00
parent 047066aca9
commit 6ab626fc0d
8 changed files with 1045 additions and 7 deletions

View File

@ -1 +1 @@
export declare function checkToken(token: string): Promise<unknown>;
export declare function checkToken(token: string): Promise<any>;

2
dist/util/convertBigIntToString.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
import "missing-native-js-functions";
export declare function convertBigIntToString(obj: any): any;

16
dist/util/convertBigIntToString.js vendored Normal file
View File

@ -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

View File

@ -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"}

1013
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -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",

View File

@ -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<any> {
return new Promise((res, rej) => {
jwt.verify(token, Config.getAll().api.security.jwtSecret, JWTOptions, (err, decoded: any) => {
if (err || !decoded) return rej("Invalid Token");

View File

@ -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;
}