1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const StrategyCollection_1 = require("./StrategyCollection");
|
4 | function assertConfig(config) {
|
5 | if (typeof config.realm !== "string") {
|
6 | throw new Error("The config option `realm` must be a string.");
|
7 | }
|
8 | if (typeof config.base !== "string")
|
9 | throw new Error("The config option `base` must be a string.");
|
10 | if (typeof config.codeValidityDuration !== "number") {
|
11 | throw new Error("The config option `codeValidityDuration` must be a number.");
|
12 | }
|
13 | if (typeof config.jwtValidityDuration !== "number") {
|
14 | throw new Error("The config option `jwtValidityDuration` must be a number.");
|
15 | }
|
16 | if (typeof config.privateKey !== "string") {
|
17 | throw new Error("The config option `privateKey` must be a string.");
|
18 | }
|
19 | if (!Array.isArray(config.publicKeys)) {
|
20 | throw new Error("The config option `publicKeys` must be an array.");
|
21 | }
|
22 | if (config.publicKeys.some((key) => typeof key !== "string")) {
|
23 | throw new Error("The config option `publicKeys` must only include strings.");
|
24 | }
|
25 | if (!config.publicKeys.length) {
|
26 | throw new Error("The config option `publicKeys` must include at least one key.");
|
27 | }
|
28 | if (typeof config.sendMail !== "function") {
|
29 | throw new Error("The config option `sendMail` must be a function.");
|
30 | }
|
31 | if (!(config.strategies instanceof StrategyCollection_1.StrategyCollection) &&
|
32 | !Array.isArray(config.strategies)) {
|
33 | throw new Error("The config option `strategies` must either be an instance of `StrategyCollection` or an array of `Strategy` instances.");
|
34 | }
|
35 | if (typeof config.pg !== "object") {
|
36 | throw new Error("The config option `pg` must be an object.");
|
37 | }
|
38 | if (typeof config.processSchema !== "undefined" &&
|
39 | typeof config.processSchema !== "function") {
|
40 | throw new Error("The config option `processSchema` must be a function if defined.");
|
41 | }
|
42 | }
|
43 | exports.assertConfig = assertConfig;
|
44 |
|
\ | No newline at end of file |