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