@dwp/govuk-casa 8.16.2 → 8.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/css/casa-ie8.css +1 -1
- package/dist/assets/css/casa.css +1 -1
- package/dist/casa.d.ts +13 -13
- package/dist/casa.js +17 -7
- package/dist/casa.js.map +1 -1
- package/dist/lib/CasaTemplateLoader.d.ts +1 -1
- package/dist/lib/CasaTemplateLoader.js +13 -14
- package/dist/lib/CasaTemplateLoader.js.map +1 -1
- package/dist/lib/JourneyContext.d.ts +10 -4
- package/dist/lib/JourneyContext.js +57 -47
- package/dist/lib/JourneyContext.js.map +1 -1
- package/dist/lib/MutableRouter.d.ts +1 -1
- package/dist/lib/MutableRouter.js +22 -23
- package/dist/lib/MutableRouter.js.map +1 -1
- package/dist/lib/Plan.d.ts +5 -5
- package/dist/lib/Plan.js +49 -36
- package/dist/lib/Plan.js.map +1 -1
- package/dist/lib/ValidationError.d.ts +1 -1
- package/dist/lib/ValidationError.js +9 -9
- package/dist/lib/ValidationError.js.map +1 -1
- package/dist/lib/ValidatorFactory.js +4 -7
- package/dist/lib/ValidatorFactory.js.map +1 -1
- package/dist/lib/configuration-ingestor.d.ts +75 -14
- package/dist/lib/configuration-ingestor.js +156 -64
- package/dist/lib/configuration-ingestor.js.map +1 -1
- package/dist/lib/configure.js +11 -10
- package/dist/lib/configure.js.map +1 -1
- package/dist/lib/constants.js +8 -8
- package/dist/lib/context-id-generators.d.ts +1 -1
- package/dist/lib/context-id-generators.js +7 -4
- package/dist/lib/context-id-generators.js.map +1 -1
- package/dist/lib/end-session.js +2 -2
- package/dist/lib/field.d.ts +6 -6
- package/dist/lib/field.js +15 -21
- package/dist/lib/field.js.map +1 -1
- package/dist/lib/index.d.ts +13 -13
- package/dist/lib/index.js +17 -7
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/logger.js +7 -7
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/mount.js +3 -3
- package/dist/lib/mount.js.map +1 -1
- package/dist/lib/nunjucks-filters.d.ts +5 -1
- package/dist/lib/nunjucks-filters.js +37 -23
- package/dist/lib/nunjucks-filters.js.map +1 -1
- package/dist/lib/nunjucks.d.ts +2 -2
- package/dist/lib/nunjucks.js +6 -7
- package/dist/lib/nunjucks.js.map +1 -1
- package/dist/lib/utils.js +52 -42
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/validators/dateObject.d.ts +3 -3
- package/dist/lib/validators/dateObject.js +44 -37
- package/dist/lib/validators/dateObject.js.map +1 -1
- package/dist/lib/validators/email.d.ts +2 -2
- package/dist/lib/validators/email.js +4 -5
- package/dist/lib/validators/email.js.map +1 -1
- package/dist/lib/validators/inArray.d.ts +2 -2
- package/dist/lib/validators/inArray.js +5 -6
- package/dist/lib/validators/inArray.js.map +1 -1
- package/dist/lib/validators/index.d.ts +10 -10
- package/dist/lib/validators/index.js.map +1 -1
- package/dist/lib/validators/nino.d.ts +2 -2
- package/dist/lib/validators/nino.js +10 -7
- package/dist/lib/validators/nino.js.map +1 -1
- package/dist/lib/validators/postalAddressObject.d.ts +2 -2
- package/dist/lib/validators/postalAddressObject.js +52 -39
- package/dist/lib/validators/postalAddressObject.js.map +1 -1
- package/dist/lib/validators/range.d.ts +2 -2
- package/dist/lib/validators/range.js +6 -7
- package/dist/lib/validators/range.js.map +1 -1
- package/dist/lib/validators/regex.d.ts +2 -2
- package/dist/lib/validators/regex.js +4 -5
- package/dist/lib/validators/regex.js.map +1 -1
- package/dist/lib/validators/required.d.ts +2 -2
- package/dist/lib/validators/required.js +6 -9
- package/dist/lib/validators/required.js.map +1 -1
- package/dist/lib/validators/strlen.d.ts +2 -2
- package/dist/lib/validators/strlen.js +8 -9
- package/dist/lib/validators/strlen.js.map +1 -1
- package/dist/lib/validators/wordCount.d.ts +2 -2
- package/dist/lib/validators/wordCount.js +10 -9
- package/dist/lib/validators/wordCount.js.map +1 -1
- package/dist/lib/waypoint-url.d.ts +4 -4
- package/dist/lib/waypoint-url.js +23 -23
- package/dist/lib/waypoint-url.js.map +1 -1
- package/dist/middleware/body-parser.d.ts +27 -5
- package/dist/middleware/body-parser.js +37 -6
- package/dist/middleware/body-parser.js.map +1 -1
- package/dist/middleware/csrf.d.ts +3 -0
- package/dist/middleware/csrf.js +3 -0
- package/dist/middleware/csrf.js.map +1 -1
- package/dist/middleware/data.d.ts +22 -5
- package/dist/middleware/data.js +37 -7
- package/dist/middleware/data.js.map +1 -1
- package/dist/middleware/gather-fields.d.ts +1 -1
- package/dist/middleware/gather-fields.js +4 -3
- package/dist/middleware/gather-fields.js.map +1 -1
- package/dist/middleware/i18n.d.ts +11 -2
- package/dist/middleware/i18n.js +26 -17
- package/dist/middleware/i18n.js.map +1 -1
- package/dist/middleware/post.d.ts +3 -1
- package/dist/middleware/post.js +35 -18
- package/dist/middleware/post.js.map +1 -1
- package/dist/middleware/pre.d.ts +1 -1
- package/dist/middleware/pre.js +44 -21
- package/dist/middleware/pre.js.map +1 -1
- package/dist/middleware/progress-journey.d.ts +1 -1
- package/dist/middleware/progress-journey.js +5 -5
- package/dist/middleware/progress-journey.js.map +1 -1
- package/dist/middleware/sanitise-fields.d.ts +2 -2
- package/dist/middleware/sanitise-fields.js +13 -11
- package/dist/middleware/sanitise-fields.js.map +1 -1
- package/dist/middleware/serve-first-waypoint.d.ts +1 -1
- package/dist/middleware/serve-first-waypoint.js +6 -4
- package/dist/middleware/serve-first-waypoint.js.map +1 -1
- package/dist/middleware/session.d.ts +27 -8
- package/dist/middleware/session.js +53 -25
- package/dist/middleware/session.js.map +1 -1
- package/dist/middleware/skip-waypoint.d.ts +1 -1
- package/dist/middleware/skip-waypoint.js +3 -3
- package/dist/middleware/skip-waypoint.js.map +1 -1
- package/dist/middleware/steer-journey.d.ts +1 -1
- package/dist/middleware/steer-journey.js +15 -13
- package/dist/middleware/steer-journey.js.map +1 -1
- package/dist/middleware/strip-proxy-path.d.ts +1 -1
- package/dist/middleware/strip-proxy-path.js +3 -3
- package/dist/middleware/strip-proxy-path.js.map +1 -1
- package/dist/middleware/validate-fields.d.ts +2 -2
- package/dist/middleware/validate-fields.js +2 -5
- package/dist/middleware/validate-fields.js.map +1 -1
- package/dist/routes/ancillary.d.ts +2 -2
- package/dist/routes/ancillary.js +3 -3
- package/dist/routes/ancillary.js.map +1 -1
- package/dist/routes/journey.d.ts +1 -1
- package/dist/routes/journey.js +85 -31
- package/dist/routes/journey.js.map +1 -1
- package/dist/routes/static.d.ts +2 -2
- package/dist/routes/static.js +18 -18
- package/dist/routes/static.js.map +1 -1
- package/package.json +33 -36
- package/src/casa.js +13 -13
- package/src/lib/CasaTemplateLoader.js +21 -17
- package/src/lib/JourneyContext.js +118 -79
- package/src/lib/MutableRouter.js +30 -26
- package/src/lib/Plan.js +109 -62
- package/src/lib/ValidationError.js +13 -10
- package/src/lib/ValidatorFactory.js +7 -8
- package/src/lib/configuration-ingestor.js +200 -74
- package/src/lib/configure.js +31 -30
- package/src/lib/constants.js +8 -8
- package/src/lib/context-id-generators.js +39 -38
- package/src/lib/end-session.js +3 -3
- package/src/lib/field.js +48 -32
- package/src/lib/index.js +12 -12
- package/src/lib/logger.js +9 -9
- package/src/lib/mount.js +68 -73
- package/src/lib/nunjucks-filters.js +57 -44
- package/src/lib/nunjucks.js +20 -16
- package/src/lib/utils.js +69 -44
- package/src/lib/validators/dateObject.js +57 -48
- package/src/lib/validators/email.js +8 -9
- package/src/lib/validators/inArray.js +8 -9
- package/src/lib/validators/index.js +11 -11
- package/src/lib/validators/nino.js +25 -12
- package/src/lib/validators/postalAddressObject.js +73 -55
- package/src/lib/validators/range.js +9 -11
- package/src/lib/validators/regex.js +7 -8
- package/src/lib/validators/required.js +13 -14
- package/src/lib/validators/strlen.js +11 -12
- package/src/lib/validators/wordCount.js +17 -12
- package/src/lib/waypoint-url.js +48 -33
- package/src/middleware/body-parser.js +44 -10
- package/src/middleware/csrf.js +4 -1
- package/src/middleware/data.js +62 -25
- package/src/middleware/gather-fields.js +8 -8
- package/src/middleware/i18n.js +49 -39
- package/src/middleware/post.js +47 -21
- package/src/middleware/pre.js +60 -35
- package/src/middleware/progress-journey.js +32 -18
- package/src/middleware/sanitise-fields.js +43 -20
- package/src/middleware/serve-first-waypoint.js +12 -10
- package/src/middleware/session.js +97 -65
- package/src/middleware/skip-waypoint.js +7 -9
- package/src/middleware/steer-journey.js +39 -27
- package/src/middleware/strip-proxy-path.js +8 -7
- package/src/middleware/validate-fields.js +5 -12
- package/src/routes/ancillary.js +4 -6
- package/src/routes/journey.js +158 -78
- package/src/routes/static.js +61 -28
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
/* eslint-disable class-methods-use-this */
|
|
7
6
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
7
|
const { isPlainObject } = lodash_1.default; // CommonJS
|
|
9
8
|
/**
|
|
@@ -45,12 +44,11 @@ class ValidatorFactory {
|
|
|
45
44
|
*/
|
|
46
45
|
static make(config = {}) {
|
|
47
46
|
if (!isPlainObject(config)) {
|
|
48
|
-
throw new TypeError(
|
|
47
|
+
throw new TypeError("Configuration must be an object");
|
|
49
48
|
}
|
|
50
49
|
const validator = Reflect.construct(this, [config]);
|
|
51
|
-
/* eslint-disable-next-line sonarjs/prefer-object-literal */
|
|
52
50
|
const instance = {};
|
|
53
|
-
instance.name = validator.name ||
|
|
51
|
+
instance.name = validator.name || "unknown";
|
|
54
52
|
instance.config = config;
|
|
55
53
|
instance.validate = validator.validate.bind(instance);
|
|
56
54
|
instance.sanitise = validator.sanitise.bind(instance);
|
|
@@ -64,7 +62,7 @@ class ValidatorFactory {
|
|
|
64
62
|
*/
|
|
65
63
|
constructor(config = {}) {
|
|
66
64
|
if (new.target === ValidatorFactory) {
|
|
67
|
-
throw new TypeError(
|
|
65
|
+
throw new TypeError("Cannot instantiate the abstract class, ValidatorFactory");
|
|
68
66
|
}
|
|
69
67
|
this.config = config;
|
|
70
68
|
}
|
|
@@ -79,9 +77,8 @@ class ValidatorFactory {
|
|
|
79
77
|
* @throws {Error}
|
|
80
78
|
*/
|
|
81
79
|
validate(fieldValue, context) {
|
|
82
|
-
throw new Error(
|
|
80
|
+
throw new Error("validate() method has not been implemented");
|
|
83
81
|
}
|
|
84
|
-
/* eslint-disable-next-line jsdoc/require-returns-check */
|
|
85
82
|
/**
|
|
86
83
|
* Sanitise the given value.
|
|
87
84
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidatorFactory.js","sourceRoot":"","sources":["../../src/lib/ValidatorFactory.js"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"ValidatorFactory.js","sourceRoot":"","sources":["../../src/lib/ValidatorFactory.js"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAE5B,MAAM,EAAE,aAAa,EAAE,GAAG,gBAAM,CAAC,CAAC,WAAW;AAE7C;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AACH,MAAqB,gBAAgB;IACnC;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,EAAE;QACrB,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC,CAAC;QACzD,CAAC;QAED,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAEpD,MAAM,QAAQ,GAAG,EAAE,CAAC;QACpB,QAAQ,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC;QAC5C,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;QACzB,QAAQ,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtD,QAAQ,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEtD,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAExB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACH,YAAY,MAAM,GAAG,EAAE;QACrB,IAAI,GAAG,CAAC,MAAM,KAAK,gBAAgB,EAAE,CAAC;YACpC,MAAM,IAAI,SAAS,CACjB,yDAAyD,CAC1D,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,mCAAmC;IAEnC,0DAA0D;IAC1D;;;;;;;OAOG;IACH,QAAQ,CAAC,UAAU,EAAE,OAAO;QAC1B,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACH,QAAQ,CAAC,UAAU;QACjB,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAjED,mCAiEC"}
|
|
@@ -81,12 +81,12 @@ export function validateSessionTtl(ttl?: number): number;
|
|
|
81
81
|
* Validates and sanitises sessions name.
|
|
82
82
|
*
|
|
83
83
|
* @access private
|
|
84
|
-
* @param {string} [name
|
|
84
|
+
* @param {string} [name] Session name.
|
|
85
85
|
* @throws {ReferenceError} For missing value type.
|
|
86
86
|
* @throws {TypeError} For invalid value.
|
|
87
87
|
* @returns {string} Name.
|
|
88
88
|
*/
|
|
89
|
-
export function validateSessionName(name?: string
|
|
89
|
+
export function validateSessionName(name?: string): string;
|
|
90
90
|
/**
|
|
91
91
|
* Validates and sanitises sessions secure flag.
|
|
92
92
|
*
|
|
@@ -96,7 +96,7 @@ export function validateSessionName(name?: string | undefined): string;
|
|
|
96
96
|
* @throws {TypeError} For invalid or missing value.
|
|
97
97
|
* @returns {string} Name.
|
|
98
98
|
*/
|
|
99
|
-
export function validateSessionSecure(secure?: boolean
|
|
99
|
+
export function validateSessionSecure(secure?: boolean): string;
|
|
100
100
|
/**
|
|
101
101
|
* Validates and sanitises sessions store.
|
|
102
102
|
*
|
|
@@ -137,14 +137,47 @@ export function validateSessionCookiePath(cookiePath: string, defaultPath?: stri
|
|
|
137
137
|
* @returns {symbol | Function} flag for error visibility.
|
|
138
138
|
*/
|
|
139
139
|
export function validateErrorVisibility(errorVisibility?: string): symbol | Function;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
export function
|
|
146
|
-
|
|
147
|
-
|
|
140
|
+
/**
|
|
141
|
+
* @param {boolean | string} cookieSameSite Cookie SameSite value
|
|
142
|
+
* @param {boolean | string} defaultFlag Default value
|
|
143
|
+
* @returns {boolean | string} Validated value
|
|
144
|
+
*/
|
|
145
|
+
export function validateSessionCookieSameSite(cookieSameSite: boolean | string, defaultFlag: boolean | string): boolean | string;
|
|
146
|
+
/**
|
|
147
|
+
* @param {PageHook[]} hooks Page hook functions
|
|
148
|
+
* @returns {PageHook[]} Validated page hooks
|
|
149
|
+
*/
|
|
150
|
+
export function validatePageHooks(hooks: PageHook[]): PageHook[];
|
|
151
|
+
/**
|
|
152
|
+
* @param {PageField[]} fields Page fields
|
|
153
|
+
* @returns {PageField[]} Validated fields
|
|
154
|
+
*/
|
|
155
|
+
export function validateFields(fields: PageField[]): PageField[];
|
|
156
|
+
/**
|
|
157
|
+
* @param {Page[]} [pages] Pages
|
|
158
|
+
* @returns {Page[]} Validated pages
|
|
159
|
+
*/
|
|
160
|
+
export function validatePages(pages?: Page[]): Page[];
|
|
161
|
+
/**
|
|
162
|
+
* @param {Plan} plan Plan
|
|
163
|
+
* @returns {Plan} Validated plan
|
|
164
|
+
*/
|
|
165
|
+
export function validatePlan(plan: Plan): Plan;
|
|
166
|
+
/**
|
|
167
|
+
* @param {GlobalHook[]} hooks Global hook functions
|
|
168
|
+
* @returns {GlobalHook[]} Validated global hooks
|
|
169
|
+
*/
|
|
170
|
+
export function validateGlobalHooks(hooks: GlobalHook[]): GlobalHook[];
|
|
171
|
+
/**
|
|
172
|
+
* @param {IPlugin[]} plugins Plugins
|
|
173
|
+
* @returns {IPlugin[]} Validated plugins
|
|
174
|
+
*/
|
|
175
|
+
export function validatePlugins(plugins: IPlugin[]): IPlugin[];
|
|
176
|
+
/**
|
|
177
|
+
* @param {ContextEventHandler[]} events Event handlers
|
|
178
|
+
* @returns {ContextEventHandler[]} Validated event handlers
|
|
179
|
+
*/
|
|
180
|
+
export function validateEvents(events: ContextEventHandler[]): ContextEventHandler[];
|
|
148
181
|
/**
|
|
149
182
|
* Validates helmet configuration function.
|
|
150
183
|
*
|
|
@@ -154,9 +187,28 @@ export function validateEvents(events: any): any;
|
|
|
154
187
|
* @throws {TypeError} when passed a non-function
|
|
155
188
|
*/
|
|
156
189
|
export function validateHelmetConfigurator(helmetConfigurator: HelmetConfigurator): HelmetConfigurator;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
190
|
+
/**
|
|
191
|
+
* @param {number} value Max params value
|
|
192
|
+
* @param {number} [defaultValue] Default value
|
|
193
|
+
* @returns {number} Valid value
|
|
194
|
+
* @throws {TypeError} If not an integer
|
|
195
|
+
* @throws {RangeError} If out of bounds
|
|
196
|
+
*/
|
|
197
|
+
export function validateFormMaxParams(value: number, defaultValue?: number): number;
|
|
198
|
+
/**
|
|
199
|
+
* @param {number} value Max bytes value
|
|
200
|
+
* @param {number} [defaultValue] Default value
|
|
201
|
+
* @returns {number} Valid value
|
|
202
|
+
* @throws {TypeError} If not an integer
|
|
203
|
+
* @throws {RangeError} If out of bounds
|
|
204
|
+
*/
|
|
205
|
+
export function validateFormMaxBytes(value: number, defaultValue?: number): number;
|
|
206
|
+
/**
|
|
207
|
+
* @param {ContextIdGenerator} generator ID generator function
|
|
208
|
+
* @returns {ContextIdGenerator} Validated generator
|
|
209
|
+
* @throws {TypeError} If not a function
|
|
210
|
+
*/
|
|
211
|
+
export function validateContextIdGenerator(generator: ContextIdGenerator): ContextIdGenerator;
|
|
160
212
|
/**
|
|
161
213
|
* Ingest, validate, sanitise and manipulate configuration parameters.
|
|
162
214
|
*
|
|
@@ -168,3 +220,12 @@ export function validateContextIdGenerator(generator: any): any;
|
|
|
168
220
|
export default function ingest(config?: ConfigurationOptions): object;
|
|
169
221
|
export type ConfigurationOptions = import("../casa").ConfigurationOptions;
|
|
170
222
|
export type HelmetConfigurator = import("../casa").HelmetConfigurator;
|
|
223
|
+
export type Page = import("../casa").Page;
|
|
224
|
+
export type PageField = import("../casa").PageField;
|
|
225
|
+
export type PageHook = import("../casa").PageHook;
|
|
226
|
+
export type GlobalHook = import("../casa").GlobalHook;
|
|
227
|
+
export type IPlugin = import("../casa").IPlugin;
|
|
228
|
+
export type ContextEventHandler = import("../casa").ContextEventHandler;
|
|
229
|
+
export type ContextIdGenerator = import("../casa").ContextIdGenerator;
|
|
230
|
+
import { PageField } from "./field.js";
|
|
231
|
+
import Plan from "./Plan.js";
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -52,7 +62,6 @@ exports.validateFormMaxParams = validateFormMaxParams;
|
|
|
52
62
|
exports.validateFormMaxBytes = validateFormMaxBytes;
|
|
53
63
|
exports.validateContextIdGenerator = validateContextIdGenerator;
|
|
54
64
|
exports.default = ingest;
|
|
55
|
-
/* eslint-disable sonarjs/no-duplicate-string */
|
|
56
65
|
const bytes_1 = __importDefault(require("bytes"));
|
|
57
66
|
const field_js_1 = require("./field.js");
|
|
58
67
|
const Plan_js_1 = __importDefault(require("./Plan.js"));
|
|
@@ -61,15 +70,43 @@ const utils_js_1 = require("./utils.js");
|
|
|
61
70
|
const contextIdGenerators = __importStar(require("./context-id-generators.js"));
|
|
62
71
|
const constants_js_1 = require("./constants.js");
|
|
63
72
|
/**
|
|
73
|
+
* @typedef {import("../casa").ConfigurationOptions} ConfigurationOptions
|
|
74
|
+
* @access private
|
|
75
|
+
*/
|
|
76
|
+
/**
|
|
77
|
+
* @typedef {import("../casa").HelmetConfigurator} HelmetConfigurator
|
|
78
|
+
* @access private
|
|
79
|
+
*/
|
|
80
|
+
/**
|
|
81
|
+
* @typedef {import("../casa").Page} Page
|
|
82
|
+
* @access private
|
|
83
|
+
*/
|
|
84
|
+
/**
|
|
85
|
+
* @typedef {import("../casa").PageField} PageField
|
|
86
|
+
* @access private
|
|
87
|
+
*/
|
|
88
|
+
/**
|
|
89
|
+
* @typedef {import("../casa").PageHook} PageHook
|
|
90
|
+
* @access private
|
|
91
|
+
*/
|
|
92
|
+
/**
|
|
93
|
+
* @typedef {import("../casa").GlobalHook} GlobalHook
|
|
94
|
+
* @access private
|
|
95
|
+
*/
|
|
96
|
+
/**
|
|
97
|
+
* @typedef {import("../casa").IPlugin} IPlugin
|
|
98
|
+
* @access private
|
|
99
|
+
*/
|
|
100
|
+
/**
|
|
101
|
+
* @typedef {import("../casa").ContextEventHandler} ContextEventHandler
|
|
64
102
|
* @access private
|
|
65
|
-
* @typedef {import('../casa').ConfigurationOptions} ConfigurationOptions
|
|
66
103
|
*/
|
|
67
104
|
/**
|
|
105
|
+
* @typedef {import("../casa").ContextIdGenerator} ContextIdGenerator
|
|
68
106
|
* @access private
|
|
69
|
-
* @typedef {import('../casa').HelmetConfigurator} HelmetConfigurator
|
|
70
107
|
*/
|
|
71
|
-
const log = (0, logger_js_1.default)(
|
|
72
|
-
const echo = (a) =>
|
|
108
|
+
const log = (0, logger_js_1.default)("lib:configuration-ingestor");
|
|
109
|
+
const echo = (a) => a;
|
|
73
110
|
/**
|
|
74
111
|
* Validates and sanitises i18n object.
|
|
75
112
|
*
|
|
@@ -80,8 +117,8 @@ const echo = (a) => (a);
|
|
|
80
117
|
* @returns {object} Sanitised i18n object.
|
|
81
118
|
*/
|
|
82
119
|
function validateI18nObject(i18n = Object.create(null), cb = echo) {
|
|
83
|
-
if (Object.prototype.toString.call(i18n) !==
|
|
84
|
-
throw new TypeError(
|
|
120
|
+
if (Object.prototype.toString.call(i18n) !== "[object Object]") {
|
|
121
|
+
throw new TypeError("I18n must be an object");
|
|
85
122
|
}
|
|
86
123
|
return cb(i18n);
|
|
87
124
|
}
|
|
@@ -96,10 +133,10 @@ function validateI18nObject(i18n = Object.create(null), cb = echo) {
|
|
|
96
133
|
*/
|
|
97
134
|
function validateI18nDirs(dirs = []) {
|
|
98
135
|
if (!Array.isArray(dirs)) {
|
|
99
|
-
throw new TypeError(
|
|
136
|
+
throw new TypeError("I18n directories must be an array (i18n.dirs)");
|
|
100
137
|
}
|
|
101
138
|
dirs.forEach((dir, i) => {
|
|
102
|
-
if (typeof dir !==
|
|
139
|
+
if (typeof dir !== "string") {
|
|
103
140
|
throw new TypeError(`I18n directory must be a string, got ${typeof dir} (i18n.dirs[${i}])`);
|
|
104
141
|
}
|
|
105
142
|
});
|
|
@@ -114,12 +151,12 @@ function validateI18nDirs(dirs = []) {
|
|
|
114
151
|
* @throws {TypeError} For invalid type.
|
|
115
152
|
* @returns {Array} Array of locales.
|
|
116
153
|
*/
|
|
117
|
-
function validateI18nLocales(locales = [
|
|
154
|
+
function validateI18nLocales(locales = ["en", "cy"]) {
|
|
118
155
|
if (!Array.isArray(locales)) {
|
|
119
|
-
throw new TypeError(
|
|
156
|
+
throw new TypeError("I18n locales must be an array (i18n.locales)");
|
|
120
157
|
}
|
|
121
158
|
locales.forEach((locale, i) => {
|
|
122
|
-
if (typeof locale !==
|
|
159
|
+
if (typeof locale !== "string") {
|
|
123
160
|
throw new TypeError(`I18n locale must be a string, got ${typeof locale} (i18n.locales[${i}])`);
|
|
124
161
|
}
|
|
125
162
|
});
|
|
@@ -134,11 +171,11 @@ function validateI18nLocales(locales = ['en', 'cy']) {
|
|
|
134
171
|
* @returns {string|undefined} Sanitised URL.
|
|
135
172
|
*/
|
|
136
173
|
function validateMountUrl(mountUrl) {
|
|
137
|
-
if (typeof mountUrl ===
|
|
174
|
+
if (typeof mountUrl === "undefined") {
|
|
138
175
|
return undefined;
|
|
139
176
|
}
|
|
140
177
|
if (!mountUrl.match(/\/$/)) {
|
|
141
|
-
throw new SyntaxError(
|
|
178
|
+
throw new SyntaxError("mountUrl must include a trailing slash (/)");
|
|
142
179
|
}
|
|
143
180
|
return mountUrl;
|
|
144
181
|
}
|
|
@@ -155,8 +192,8 @@ function validateSessionObject(session = Object.create(null), cb = echo) {
|
|
|
155
192
|
if (session === undefined) {
|
|
156
193
|
return cb(session);
|
|
157
194
|
}
|
|
158
|
-
if (typeof session !==
|
|
159
|
-
throw new TypeError(
|
|
195
|
+
if (typeof session !== "object") {
|
|
196
|
+
throw new TypeError("Session config has not been specified");
|
|
160
197
|
}
|
|
161
198
|
return cb(session);
|
|
162
199
|
}
|
|
@@ -171,10 +208,10 @@ function validateSessionObject(session = Object.create(null), cb = echo) {
|
|
|
171
208
|
*/
|
|
172
209
|
function validateViews(dirs = []) {
|
|
173
210
|
if (!Array.isArray(dirs)) {
|
|
174
|
-
throw new TypeError(
|
|
211
|
+
throw new TypeError("View directories must be an array (views)");
|
|
175
212
|
}
|
|
176
213
|
dirs.forEach((dir, i) => {
|
|
177
|
-
if (typeof dir !==
|
|
214
|
+
if (typeof dir !== "string") {
|
|
178
215
|
throw new TypeError(`View directory must be a string, got ${typeof dir} (views[${i}])`);
|
|
179
216
|
}
|
|
180
217
|
});
|
|
@@ -190,11 +227,11 @@ function validateViews(dirs = []) {
|
|
|
190
227
|
* @returns {string} Secret.
|
|
191
228
|
*/
|
|
192
229
|
function validateSessionSecret(secret) {
|
|
193
|
-
if (typeof secret ===
|
|
194
|
-
throw ReferenceError(
|
|
230
|
+
if (typeof secret === "undefined") {
|
|
231
|
+
throw ReferenceError("Session secret is missing (session.secret)");
|
|
195
232
|
}
|
|
196
|
-
else if (typeof secret !==
|
|
197
|
-
throw new TypeError(
|
|
233
|
+
else if (typeof secret !== "string") {
|
|
234
|
+
throw new TypeError("Session secret must be a string (session.secret)");
|
|
198
235
|
}
|
|
199
236
|
return secret;
|
|
200
237
|
}
|
|
@@ -208,8 +245,8 @@ function validateSessionSecret(secret) {
|
|
|
208
245
|
* @returns {number} Ttl.
|
|
209
246
|
*/
|
|
210
247
|
function validateSessionTtl(ttl = 3600) {
|
|
211
|
-
if (typeof ttl !==
|
|
212
|
-
throw new TypeError(
|
|
248
|
+
if (typeof ttl !== "number") {
|
|
249
|
+
throw new TypeError("Session ttl must be an integer (session.ttl)");
|
|
213
250
|
}
|
|
214
251
|
return ttl;
|
|
215
252
|
}
|
|
@@ -217,14 +254,14 @@ function validateSessionTtl(ttl = 3600) {
|
|
|
217
254
|
* Validates and sanitises sessions name.
|
|
218
255
|
*
|
|
219
256
|
* @access private
|
|
220
|
-
* @param {string} [name
|
|
257
|
+
* @param {string} [name] Session name.
|
|
221
258
|
* @throws {ReferenceError} For missing value type.
|
|
222
259
|
* @throws {TypeError} For invalid value.
|
|
223
260
|
* @returns {string} Name.
|
|
224
261
|
*/
|
|
225
|
-
function validateSessionName(name =
|
|
226
|
-
if (typeof name !==
|
|
227
|
-
throw new TypeError(
|
|
262
|
+
function validateSessionName(name = "casa-session") {
|
|
263
|
+
if (typeof name !== "string") {
|
|
264
|
+
throw new TypeError("Session name must be a string (session.name)");
|
|
228
265
|
}
|
|
229
266
|
return name;
|
|
230
267
|
}
|
|
@@ -239,10 +276,10 @@ function validateSessionName(name = 'casa-session') {
|
|
|
239
276
|
*/
|
|
240
277
|
function validateSessionSecure(secure) {
|
|
241
278
|
if (secure === undefined) {
|
|
242
|
-
throw new Error(
|
|
279
|
+
throw new Error("Session secure flag must be explicitly defined (session.secure)");
|
|
243
280
|
}
|
|
244
|
-
if (typeof secure !==
|
|
245
|
-
throw new TypeError(
|
|
281
|
+
if (typeof secure !== "boolean") {
|
|
282
|
+
throw new TypeError("Session secure flag must be boolean (session.secure)");
|
|
246
283
|
}
|
|
247
284
|
return secure;
|
|
248
285
|
}
|
|
@@ -254,8 +291,8 @@ function validateSessionSecure(secure) {
|
|
|
254
291
|
* @returns {Function} Store.
|
|
255
292
|
*/
|
|
256
293
|
function validateSessionStore(store) {
|
|
257
|
-
if (typeof store ===
|
|
258
|
-
log.warn(
|
|
294
|
+
if (typeof store === "undefined") {
|
|
295
|
+
log.warn("Using MemoryStore session storage, which is not suitable for production");
|
|
259
296
|
return null;
|
|
260
297
|
}
|
|
261
298
|
return store;
|
|
@@ -268,8 +305,8 @@ function validateSessionStore(store) {
|
|
|
268
305
|
* @param {string} defaultPath Default path if none specified.
|
|
269
306
|
* @returns {string} Cookie path.
|
|
270
307
|
*/
|
|
271
|
-
function validateSessionCookiePath(cookiePath, defaultPath =
|
|
272
|
-
if (typeof cookiePath ===
|
|
308
|
+
function validateSessionCookiePath(cookiePath, defaultPath = "/") {
|
|
309
|
+
if (typeof cookiePath === "undefined") {
|
|
273
310
|
return defaultPath;
|
|
274
311
|
}
|
|
275
312
|
return cookiePath;
|
|
@@ -300,30 +337,37 @@ function validateErrorVisibility(errorVisibility = constants_js_1.CONFIG_ERROR_V
|
|
|
300
337
|
if (errorVisibility === undefined) {
|
|
301
338
|
return undefined;
|
|
302
339
|
}
|
|
303
|
-
if (errorVisibility === constants_js_1.CONFIG_ERROR_VISIBILITY_ALWAYS ||
|
|
340
|
+
if (errorVisibility === constants_js_1.CONFIG_ERROR_VISIBILITY_ALWAYS ||
|
|
341
|
+
errorVisibility === constants_js_1.CONFIG_ERROR_VISIBILITY_ONSUBMIT ||
|
|
342
|
+
typeof errorVisibility === "function") {
|
|
304
343
|
return errorVisibility;
|
|
305
344
|
}
|
|
306
|
-
throw new TypeError(
|
|
345
|
+
throw new TypeError("errorVisibility must be casa constant CONFIG_ERROR_VISIBILITY_ALWAYS | CONFIG_ERROR_VISIBILITY_ONSUBMIT or function");
|
|
307
346
|
}
|
|
347
|
+
/**
|
|
348
|
+
* @param {boolean | string} cookieSameSite Cookie SameSite value
|
|
349
|
+
* @param {boolean | string} defaultFlag Default value
|
|
350
|
+
* @returns {boolean | string} Validated value
|
|
351
|
+
*/
|
|
308
352
|
function validateSessionCookieSameSite(cookieSameSite, defaultFlag) {
|
|
309
|
-
const validValues = [true, false,
|
|
353
|
+
const validValues = [true, false, "Strict", "Lax", "None"];
|
|
310
354
|
if (defaultFlag === undefined) {
|
|
311
|
-
throw new TypeError(
|
|
355
|
+
throw new TypeError("validateSessionCookieSameSite() requires an explicit default flag");
|
|
312
356
|
}
|
|
313
357
|
else if (!validValues.includes(defaultFlag)) {
|
|
314
|
-
throw new TypeError(
|
|
358
|
+
throw new TypeError("validateSessionCookieSameSite() default flag must be set to one of true, false, Strict, Lax or None (session.cookieSameSite)");
|
|
315
359
|
}
|
|
316
360
|
const value = cookieSameSite !== undefined ? cookieSameSite : defaultFlag;
|
|
317
361
|
if (!validValues.includes(value)) {
|
|
318
|
-
throw new TypeError(
|
|
362
|
+
throw new TypeError("SameSite flag must be set to one of true, false, Strict, Lax or None (session.cookieSameSite)");
|
|
319
363
|
}
|
|
320
364
|
return value;
|
|
321
365
|
}
|
|
322
366
|
const validatePageHook = (hook, index) => {
|
|
323
367
|
try {
|
|
324
368
|
(0, utils_js_1.validateHookName)(hook.hook);
|
|
325
|
-
if (typeof hook.middleware !==
|
|
326
|
-
throw new TypeError(
|
|
369
|
+
if (typeof hook.middleware !== "function") {
|
|
370
|
+
throw new TypeError("Hook middleware must be a function");
|
|
327
371
|
}
|
|
328
372
|
}
|
|
329
373
|
catch (err) {
|
|
@@ -331,9 +375,13 @@ const validatePageHook = (hook, index) => {
|
|
|
331
375
|
throw err;
|
|
332
376
|
}
|
|
333
377
|
};
|
|
378
|
+
/**
|
|
379
|
+
* @param {PageHook[]} hooks Page hook functions
|
|
380
|
+
* @returns {PageHook[]} Validated page hooks
|
|
381
|
+
*/
|
|
334
382
|
function validatePageHooks(hooks) {
|
|
335
383
|
if (!Array.isArray(hooks)) {
|
|
336
|
-
throw new TypeError(
|
|
384
|
+
throw new TypeError("Hooks must be an array");
|
|
337
385
|
}
|
|
338
386
|
hooks.forEach((hook, index) => validatePageHook(hook, index));
|
|
339
387
|
return hooks;
|
|
@@ -349,9 +397,13 @@ const validateField = (field, index) => {
|
|
|
349
397
|
throw err;
|
|
350
398
|
}
|
|
351
399
|
};
|
|
400
|
+
/**
|
|
401
|
+
* @param {PageField[]} fields Page fields
|
|
402
|
+
* @returns {PageField[]} Validated fields
|
|
403
|
+
*/
|
|
352
404
|
function validateFields(fields) {
|
|
353
405
|
if (!Array.isArray(fields)) {
|
|
354
|
-
throw new TypeError(
|
|
406
|
+
throw new TypeError("Page fields must be an array (page[].fields)");
|
|
355
407
|
}
|
|
356
408
|
fields.forEach((hook, index) => validateField(hook, index));
|
|
357
409
|
return fields;
|
|
@@ -375,27 +427,35 @@ const validatePage = (page, index) => {
|
|
|
375
427
|
throw err;
|
|
376
428
|
}
|
|
377
429
|
};
|
|
430
|
+
/**
|
|
431
|
+
* @param {Page[]} [pages] Pages
|
|
432
|
+
* @returns {Page[]} Validated pages
|
|
433
|
+
*/
|
|
378
434
|
function validatePages(pages = []) {
|
|
379
435
|
if (!Array.isArray(pages)) {
|
|
380
|
-
throw new TypeError(
|
|
436
|
+
throw new TypeError("Pages must be an array (pages)");
|
|
381
437
|
}
|
|
382
438
|
pages.forEach((page, index) => validatePage(page, index));
|
|
383
439
|
return pages;
|
|
384
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* @param {Plan} plan Plan
|
|
443
|
+
* @returns {Plan} Validated plan
|
|
444
|
+
*/
|
|
385
445
|
function validatePlan(plan) {
|
|
386
446
|
if (plan === undefined) {
|
|
387
447
|
return plan;
|
|
388
448
|
}
|
|
389
449
|
if (!(plan instanceof Plan_js_1.default)) {
|
|
390
|
-
throw new TypeError(
|
|
450
|
+
throw new TypeError("Plan must be an instance the Plan class (plan)");
|
|
391
451
|
}
|
|
392
452
|
return plan;
|
|
393
453
|
}
|
|
394
454
|
const validateGlobalHook = (hook, index) => {
|
|
395
455
|
try {
|
|
396
456
|
(0, utils_js_1.validateHookName)(hook.hook);
|
|
397
|
-
if (typeof hook.middleware !==
|
|
398
|
-
throw new TypeError(
|
|
457
|
+
if (typeof hook.middleware !== "function") {
|
|
458
|
+
throw new TypeError("Hook middleware must be a function");
|
|
399
459
|
}
|
|
400
460
|
if (hook.path !== undefined) {
|
|
401
461
|
(0, utils_js_1.validateHookPath)(hook.path);
|
|
@@ -406,19 +466,31 @@ const validateGlobalHook = (hook, index) => {
|
|
|
406
466
|
throw err;
|
|
407
467
|
}
|
|
408
468
|
};
|
|
469
|
+
/**
|
|
470
|
+
* @param {GlobalHook[]} hooks Global hook functions
|
|
471
|
+
* @returns {GlobalHook[]} Validated global hooks
|
|
472
|
+
*/
|
|
409
473
|
function validateGlobalHooks(hooks) {
|
|
410
474
|
if (hooks === undefined) {
|
|
411
475
|
return [];
|
|
412
476
|
}
|
|
413
477
|
if (!Array.isArray(hooks)) {
|
|
414
|
-
throw new TypeError(
|
|
478
|
+
throw new TypeError("Hooks must be an array");
|
|
415
479
|
}
|
|
416
480
|
hooks.forEach((hook, index) => validateGlobalHook(hook, index));
|
|
417
481
|
return hooks;
|
|
418
482
|
}
|
|
483
|
+
/**
|
|
484
|
+
* @param {IPlugin[]} plugins Plugins
|
|
485
|
+
* @returns {IPlugin[]} Validated plugins
|
|
486
|
+
*/
|
|
419
487
|
function validatePlugins(plugins) {
|
|
420
488
|
return plugins;
|
|
421
489
|
}
|
|
490
|
+
/**
|
|
491
|
+
* @param {ContextEventHandler[]} events Event handlers
|
|
492
|
+
* @returns {ContextEventHandler[]} Validated event handlers
|
|
493
|
+
*/
|
|
422
494
|
function validateEvents(events) {
|
|
423
495
|
return events;
|
|
424
496
|
}
|
|
@@ -431,11 +503,19 @@ function validateEvents(events) {
|
|
|
431
503
|
* @throws {TypeError} when passed a non-function
|
|
432
504
|
*/
|
|
433
505
|
function validateHelmetConfigurator(helmetConfigurator) {
|
|
434
|
-
if (helmetConfigurator !== undefined &&
|
|
435
|
-
|
|
506
|
+
if (helmetConfigurator !== undefined &&
|
|
507
|
+
!(helmetConfigurator instanceof Function)) {
|
|
508
|
+
throw new TypeError("Helmet configurator must be a function");
|
|
436
509
|
}
|
|
437
510
|
return helmetConfigurator;
|
|
438
511
|
}
|
|
512
|
+
/**
|
|
513
|
+
* @param {number} value Max params value
|
|
514
|
+
* @param {number} [defaultValue] Default value
|
|
515
|
+
* @returns {number} Valid value
|
|
516
|
+
* @throws {TypeError} If not an integer
|
|
517
|
+
* @throws {RangeError} If out of bounds
|
|
518
|
+
*/
|
|
439
519
|
function validateFormMaxParams(value, defaultValue = 25) {
|
|
440
520
|
// CASA needs to send certain hidden form fields (see `sanitise-fields`
|
|
441
521
|
// middleware), plus some padding here.
|
|
@@ -444,13 +524,20 @@ function validateFormMaxParams(value, defaultValue = 25) {
|
|
|
444
524
|
return defaultValue;
|
|
445
525
|
}
|
|
446
526
|
if (!Number.isInteger(value)) {
|
|
447
|
-
throw new TypeError(
|
|
527
|
+
throw new TypeError("formMaxParams must be an integer");
|
|
448
528
|
}
|
|
449
529
|
if (value < MIN_PARAMS) {
|
|
450
530
|
throw new RangeError(`formMaxParams must be at least ${MIN_PARAMS}`);
|
|
451
531
|
}
|
|
452
532
|
return value;
|
|
453
533
|
}
|
|
534
|
+
/**
|
|
535
|
+
* @param {number} value Max bytes value
|
|
536
|
+
* @param {number} [defaultValue] Default value
|
|
537
|
+
* @returns {number} Valid value
|
|
538
|
+
* @throws {TypeError} If not an integer
|
|
539
|
+
* @throws {RangeError} If out of bounds
|
|
540
|
+
*/
|
|
454
541
|
function validateFormMaxBytes(value, defaultValue = 1024 * 50) {
|
|
455
542
|
const MIN_BYTES = 1024;
|
|
456
543
|
if (value === undefined) {
|
|
@@ -458,19 +545,24 @@ function validateFormMaxBytes(value, defaultValue = 1024 * 50) {
|
|
|
458
545
|
}
|
|
459
546
|
const parsedValue = bytes_1.default.parse(value);
|
|
460
547
|
if (!Number.isInteger(parsedValue)) {
|
|
461
|
-
throw new TypeError(
|
|
548
|
+
throw new TypeError("formMaxParams must be a string or an integer");
|
|
462
549
|
}
|
|
463
550
|
if (parsedValue < MIN_BYTES) {
|
|
464
551
|
throw new RangeError(`formMaxBytes must be at least ${MIN_BYTES} bytes (${bytes_1.default.format(MIN_BYTES)})`);
|
|
465
552
|
}
|
|
466
553
|
return parsedValue;
|
|
467
554
|
}
|
|
555
|
+
/**
|
|
556
|
+
* @param {ContextIdGenerator} generator ID generator function
|
|
557
|
+
* @returns {ContextIdGenerator} Validated generator
|
|
558
|
+
* @throws {TypeError} If not a function
|
|
559
|
+
*/
|
|
468
560
|
function validateContextIdGenerator(generator) {
|
|
469
561
|
if (generator === undefined) {
|
|
470
562
|
return contextIdGenerators.uuid();
|
|
471
563
|
}
|
|
472
564
|
if (!(generator instanceof Function)) {
|
|
473
|
-
throw new TypeError(
|
|
565
|
+
throw new TypeError("contextIdGenerator must be a function");
|
|
474
566
|
}
|
|
475
567
|
return generator;
|
|
476
568
|
}
|
|
@@ -500,8 +592,8 @@ function ingest(config = {}) {
|
|
|
500
592
|
secure: validateSessionSecure(session.secure),
|
|
501
593
|
ttl: validateSessionTtl(session.ttl),
|
|
502
594
|
store: validateSessionStore(session.store),
|
|
503
|
-
cookiePath: validateSessionCookiePath(session.cookiePath,
|
|
504
|
-
cookieSameSite: validateSessionCookieSameSite(session.cookieSameSite,
|
|
595
|
+
cookiePath: validateSessionCookiePath(session.cookiePath, "/"),
|
|
596
|
+
cookieSameSite: validateSessionCookieSameSite(session.cookieSameSite, "Strict"),
|
|
505
597
|
})),
|
|
506
598
|
// Views configuration
|
|
507
599
|
views: validateViews(config.views),
|