summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--dist/Config.d.ts13
-rw-r--r--dist/Config.js28
-rw-r--r--dist/Config.js.map1
-rw-r--r--dist/Constants.d.ts2
-rw-r--r--dist/Constants.js5
-rw-r--r--dist/Constants.js.map1
-rw-r--r--dist/Database.d.ts3
-rw-r--r--dist/Database.js7
-rw-r--r--dist/Database.js.map1
-rw-r--r--dist/checkToken.d.ts1
-rw-r--r--dist/checkToken.js20
-rw-r--r--dist/checkToken.js.map1
-rw-r--r--dist/index.d.ts5
-rw-r--r--dist/index.js35
-rw-r--r--dist/index.js.map1
-rw-r--r--src/index.ts4
17 files changed, 126 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore

index 67045665..adb2c197 100644 --- a/.gitignore +++ b/.gitignore
@@ -80,7 +80,6 @@ typings/ # Nuxt.js build / generate output .nuxt -dist # Gatsby files .cache/ diff --git a/dist/Config.d.ts b/dist/Config.d.ts new file mode 100644
index 00000000..f796ab08 --- /dev/null +++ b/dist/Config.d.ts
@@ -0,0 +1,13 @@ +import "missing-native-js-functions"; +declare const _default: { + init: (opts?: DefaultOptions) => Promise<void>; + getAll: () => DefaultOptions; + setAll: (val: any) => any; +}; +export default _default; +export interface DefaultOptions { + api: any; + gateway: any; + voice: any; +} +export declare const DefaultOptions: DefaultOptions; diff --git a/dist/Config.js b/dist/Config.js new file mode 100644
index 00000000..948f09d6 --- /dev/null +++ b/dist/Config.js
@@ -0,0 +1,28 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DefaultOptions = void 0; +require("missing-native-js-functions"); +const Database_1 = __importDefault(require("./Database")); +var Config; +exports.default = { + init: async function init(opts = exports.DefaultOptions) { + Config = Database_1.default.data.config({}).cache(); + await Config.init(); + await Config.set(opts.merge(Config.cache || {})); + }, + getAll: function get() { + return Config.get(); + }, + setAll: function set(val) { + return Config.set(val); + }, +}; +exports.DefaultOptions = { + api: {}, + gateway: {}, + voice: {}, +}; +//# sourceMappingURL=Config.js.map \ No newline at end of file diff --git a/dist/Config.js.map b/dist/Config.js.map new file mode 100644
index 00000000..35439efd --- /dev/null +++ b/dist/Config.js.map
@@ -0,0 +1 @@ +{"version":3,"file":"Config.js","sourceRoot":"","sources":["../src/Config.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAqC;AACrC,0DAA4B;AAE5B,IAAI,MAAqB,CAAC;AAE1B,kBAAe;IACd,IAAI,EAAE,KAAK,UAAU,IAAI,CAAC,OAAuB,sBAAc;QAC9D,MAAM,GAAG,kBAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QACpC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC;IACD,MAAM,EAAE,SAAS,GAAG;QACnB,OAAuB,MAAM,CAAC,GAAG,EAAE,CAAC;IACrC,CAAC;IACD,MAAM,EAAE,SAAS,GAAG,CAAC,GAAQ;QAC5B,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;CACD,CAAC;AAQW,QAAA,cAAc,GAAmB;IAC7C,GAAG,EAAE,EAAE;IACP,OAAO,EAAE,EAAE;IACX,KAAK,EAAE,EAAE;CACT,CAAC"} \ No newline at end of file diff --git a/dist/Constants.d.ts b/dist/Constants.d.ts new file mode 100644
index 00000000..ecceb4e6 --- /dev/null +++ b/dist/Constants.d.ts
@@ -0,0 +1,2 @@ +import { VerifyOptions } from "jsonwebtoken"; +export declare const JWTOptions: VerifyOptions; diff --git a/dist/Constants.js b/dist/Constants.js new file mode 100644
index 00000000..d65f8185 --- /dev/null +++ b/dist/Constants.js
@@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.JWTOptions = void 0; +exports.JWTOptions = { algorithms: ["HS256"] }; +//# sourceMappingURL=Constants.js.map \ No newline at end of file diff --git a/dist/Constants.js.map b/dist/Constants.js.map new file mode 100644
index 00000000..00d4855d --- /dev/null +++ b/dist/Constants.js.map
@@ -0,0 +1 @@ +{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../src/Constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAkB,EAAE,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/dist/Database.d.ts b/dist/Database.d.ts new file mode 100644
index 00000000..1a45ea78 --- /dev/null +++ b/dist/Database.d.ts
@@ -0,0 +1,3 @@ +import { MongoDatabase } from "lambert-db"; +declare const db: MongoDatabase; +export default db; diff --git a/dist/Database.js b/dist/Database.js new file mode 100644
index 00000000..9fe58f0a --- /dev/null +++ b/dist/Database.js
@@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const lambert_db_1 = require("lambert-db"); +// TODO: load url from config +const db = new lambert_db_1.MongoDatabase("mongodb://127.0.0.1:27017/lambert?readPreference=secondaryPreferred"); +exports.default = db; +//# sourceMappingURL=Database.js.map \ No newline at end of file diff --git a/dist/Database.js.map b/dist/Database.js.map new file mode 100644
index 00000000..f40d2496 --- /dev/null +++ b/dist/Database.js.map
@@ -0,0 +1 @@ +{"version":3,"file":"Database.js","sourceRoot":"","sources":["../src/Database.ts"],"names":[],"mappings":";;AAAA,2CAA2C;AAE3C,6BAA6B;AAC7B,MAAM,EAAE,GAAG,IAAI,0BAAa,CAAC,qEAAqE,CAAC,CAAC;AAEpG,kBAAe,EAAE,CAAC"} \ No newline at end of file diff --git a/dist/checkToken.d.ts b/dist/checkToken.d.ts new file mode 100644
index 00000000..478d382a --- /dev/null +++ b/dist/checkToken.d.ts
@@ -0,0 +1 @@ +export declare function checkToken(token: string): Promise<unknown>; diff --git a/dist/checkToken.js b/dist/checkToken.js new file mode 100644
index 00000000..17d88178 --- /dev/null +++ b/dist/checkToken.js
@@ -0,0 +1,20 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.checkToken = void 0; +const Constants_1 = require("./Constants"); +const jsonwebtoken_1 = __importDefault(require("jsonwebtoken")); +const Config_1 = __importDefault(require("./Config")); +function checkToken(token) { + return new Promise((res, rej) => { + jsonwebtoken_1.default.verify(token, Config_1.default.getAll().api.security.jwtSecret, Constants_1.JWTOptions, (err, decoded) => { + if (err || !decoded) + return rej("Invalid Token"); + return res(decoded); + }); + }); +} +exports.checkToken = checkToken; +//# sourceMappingURL=checkToken.js.map \ No newline at end of file diff --git a/dist/checkToken.js.map b/dist/checkToken.js.map new file mode 100644
index 00000000..2011f85b --- /dev/null +++ b/dist/checkToken.js.map
@@ -0,0 +1 @@ +{"version":3,"file":"checkToken.js","sourceRoot":"","sources":["../src/checkToken.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAyC;AACzC,gEAA+B;AAC/B,sDAA8B;AAE9B,SAAgB,UAAU,CAAC,KAAa;IACvC,OAAO,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC/B,sBAAG,CAAC,MAAM,CAAC,KAAK,EAAE,gBAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,EAAE,sBAAU,EAAE,CAAC,GAAG,EAAE,OAAY,EAAE,EAAE;YAC3F,IAAI,GAAG,IAAI,CAAC,OAAO;gBAAE,OAAO,GAAG,CAAC,eAAe,CAAC,CAAC;YAEjD,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC;AARD,gCAQC"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644
index 00000000..46dcff5a --- /dev/null +++ b/dist/index.d.ts
@@ -0,0 +1,5 @@ +import { checkToken } from "./checkToken"; +import Config, { DefaultOptions } from "./Config"; +import db from "./Database"; +import * as Constants from "./Constants"; +export { checkToken, Config, Constants, db, DefaultOptions }; diff --git a/dist/index.js b/dist/index.js new file mode 100644
index 00000000..ecd64489 --- /dev/null +++ b/dist/index.js
@@ -0,0 +1,35 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DefaultOptions = exports.db = exports.Constants = exports.Config = exports.checkToken = void 0; +const checkToken_1 = require("./checkToken"); +Object.defineProperty(exports, "checkToken", { enumerable: true, get: function () { return checkToken_1.checkToken; } }); +const Config_1 = __importStar(require("./Config")); +exports.Config = Config_1.default; +Object.defineProperty(exports, "DefaultOptions", { enumerable: true, get: function () { return Config_1.DefaultOptions; } }); +const Database_1 = __importDefault(require("./Database")); +exports.db = Database_1.default; +const Constants = __importStar(require("./Constants")); +exports.Constants = Constants; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map new file mode 100644
index 00000000..f5d21a46 --- /dev/null +++ b/dist/index.js.map
@@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA0C;AAKjC,2FALA,uBAAU,OAKA;AAJnB,mDAAkD;AAI7B,iBAJd,gBAAM,CAIc;AAAiB,+FAJ3B,uBAAc,OAI2B;AAH1D,0DAA4B;AAGY,aAHjC,kBAAE,CAGiC;AAF1C,uDAAyC;AAEZ,8BAAS"} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts
index fb7ac8d0..69c592f9 100644 --- a/src/index.ts +++ b/src/index.ts
@@ -1,6 +1,6 @@ import { checkToken } from "./checkToken"; import Config, { DefaultOptions } from "./Config"; -import Database from "./Database"; +import db from "./Database"; import * as Constants from "./Constants"; -export { checkToken, Config, Constants, Database, DefaultOptions }; +export { checkToken, Config, Constants, db, DefaultOptions };