@dwp/govuk-casa 8.16.1 → 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 +39 -42
- 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 ValidatorFactory_js_1 = __importDefault(require("../ValidatorFactory.js"));
|
|
8
7
|
const ValidationError_js_1 = __importDefault(require("../ValidationError.js"));
|
|
9
8
|
const utils_js_1 = require("../utils.js");
|
|
@@ -29,26 +28,28 @@ const utils_js_1 = require("../utils.js");
|
|
|
29
28
|
class WordCount extends ValidatorFactory_js_1.default {
|
|
30
29
|
constructor() {
|
|
31
30
|
super(...arguments);
|
|
32
|
-
this.name =
|
|
31
|
+
this.name = "wordCount";
|
|
33
32
|
}
|
|
34
33
|
count(input) {
|
|
35
34
|
return (input.match(/\S+/g) || []).length;
|
|
36
35
|
}
|
|
37
|
-
validate(inputValue =
|
|
36
|
+
validate(inputValue = "", dataContext = {}) {
|
|
38
37
|
const { errorMsgMax = {
|
|
39
|
-
inline:
|
|
40
|
-
summary:
|
|
38
|
+
inline: "validation:rule.wordCount.max.inline",
|
|
39
|
+
summary: "validation:rule.wordCount.max.summary",
|
|
41
40
|
}, errorMsgMin = {
|
|
42
|
-
inline:
|
|
43
|
-
summary:
|
|
41
|
+
inline: "validation:rule.wordCount.min.inline",
|
|
42
|
+
summary: "validation:rule.wordCount.min.summary",
|
|
44
43
|
}, min, max, } = this.config;
|
|
45
44
|
let errorMsg;
|
|
46
45
|
let valid = true;
|
|
47
|
-
if (typeof max !==
|
|
46
|
+
if (typeof max !== "undefined" &&
|
|
47
|
+
(inputValue.match(/\S+/g) || []).length > max) {
|
|
48
48
|
valid = false;
|
|
49
49
|
errorMsg = errorMsgMax;
|
|
50
50
|
}
|
|
51
|
-
if (typeof min !==
|
|
51
|
+
if (typeof min !== "undefined" &&
|
|
52
|
+
(inputValue.match(/\S+/g) || []).length < min) {
|
|
52
53
|
valid = false;
|
|
53
54
|
errorMsg = errorMsgMin;
|
|
54
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wordCount.js","sourceRoot":"","sources":["../../../src/lib/validators/wordCount.js"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"wordCount.js","sourceRoot":"","sources":["../../../src/lib/validators/wordCount.js"],"names":[],"mappings":";;;;;AAAA,iFAAsD;AACtD,+EAAoD;AACpD,0CAA6C;AAE7C;;;GAGG;AAEH;;;;;;GAMG;AAEH;;;;;;;GAOG;AACH,MAAqB,SAAU,SAAQ,6BAAgB;IAAvD;;QACE,SAAI,GAAG,WAAW,CAAC;IAgDrB,CAAC;IA9CC,KAAK,CAAC,KAAK;QACT,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IAC5C,CAAC;IAED,QAAQ,CAAC,UAAU,GAAG,EAAE,EAAE,WAAW,GAAG,EAAE;QACxC,MAAM,EACJ,WAAW,GAAG;YACZ,MAAM,EAAE,sCAAsC;YAC9C,OAAO,EAAE,uCAAuC;SACjD,EACD,WAAW,GAAG;YACZ,MAAM,EAAE,sCAAsC;YAC9C,OAAO,EAAE,uCAAuC;SACjD,EACD,GAAG,EACH,GAAG,GACJ,GAAG,IAAI,CAAC,MAAM,CAAC;QAEhB,IAAI,QAAQ,CAAC;QACb,IAAI,KAAK,GAAG,IAAI,CAAC;QAEjB,IACE,OAAO,GAAG,KAAK,WAAW;YAC1B,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,GAAG,EAC7C,CAAC;YACD,KAAK,GAAG,KAAK,CAAC;YACd,QAAQ,GAAG,WAAW,CAAC;QACzB,CAAC;QAED,IACE,OAAO,GAAG,KAAK,WAAW;YAC1B,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,GAAG,EAC7C,CAAC;YACD,KAAK,GAAG,KAAK,CAAC;YACd,QAAQ,GAAG,WAAW,CAAC;QACzB,CAAC;QAED,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,4BAAe,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;IACxE,CAAC;IAED,QAAQ,CAAC,KAAK;QACZ,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,IAAA,yBAAc,EAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAjDD,4BAiDC"}
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
* })
|
|
12
12
|
* @memberof module:@dwp/govuk-casa
|
|
13
13
|
* @param {object} obj Options
|
|
14
|
-
* @param {string} [obj.waypoint
|
|
15
|
-
* @param {string} [obj.mountUrl
|
|
14
|
+
* @param {string} [obj.waypoint] Waypoint
|
|
15
|
+
* @param {string} [obj.mountUrl] Mount URL
|
|
16
16
|
* @param {JourneyContext} [obj.journeyContext] JourneyContext
|
|
17
|
-
* @param {boolean} [obj.edit
|
|
17
|
+
* @param {boolean} [obj.edit] Turn edit mode on or off
|
|
18
18
|
* @param {string} [obj.editOrigin] Edit mode original URL
|
|
19
19
|
* @param {boolean} [obj.skipTo] Skip to this waypoint from the current one
|
|
20
|
-
* @param {string} [obj.routeName
|
|
20
|
+
* @param {string} [obj.routeName] Plan route name; next | prev
|
|
21
21
|
* @returns {string} URL
|
|
22
22
|
*/
|
|
23
23
|
export default function waypointUrl({ waypoint, mountUrl, journeyContext, edit, editOrigin, skipTo, routeName, }?: {
|
package/dist/lib/waypoint-url.js
CHANGED
|
@@ -14,7 +14,7 @@ const reUrlProtocolExtract = /^url:\/\/(.+)$/i;
|
|
|
14
14
|
* @param {string} w Waypoint
|
|
15
15
|
* @returns {string} Sanitised waypoint
|
|
16
16
|
*/
|
|
17
|
-
const sanitiseWaypoint = (w) => w.replace(/[^/a-z0-9_-]/
|
|
17
|
+
const sanitiseWaypoint = (w) => w.replace(/[^/a-z0-9_-]/gi, "").replace(/\/+/g, "/");
|
|
18
18
|
/**
|
|
19
19
|
* Sanitise a waypoint string, with allowed URL parameters:
|
|
20
20
|
* contextid = JourneyContext ID
|
|
@@ -25,7 +25,7 @@ const sanitiseWaypoint = (w) => w.replace(/[^/a-z0-9_-]/ig, '').replace(/\/+/g,
|
|
|
25
25
|
*/
|
|
26
26
|
const sanitiseWaypointWithAllowedParams = (w) => {
|
|
27
27
|
// Extract URL params
|
|
28
|
-
const parts = w.split(
|
|
28
|
+
const parts = w.split("?");
|
|
29
29
|
if (parts.length !== 2) {
|
|
30
30
|
return sanitiseWaypoint(w);
|
|
31
31
|
}
|
|
@@ -33,12 +33,12 @@ const sanitiseWaypointWithAllowedParams = (w) => {
|
|
|
33
33
|
const urlSearchParams = new URLSearchParams(rawParams);
|
|
34
34
|
// Strip all but those parameters allowed
|
|
35
35
|
const validatedUrlSearchParams = new URLSearchParams();
|
|
36
|
-
for (const pk of [
|
|
36
|
+
for (const pk of ["contextid"]) {
|
|
37
37
|
if (urlSearchParams.has(pk)) {
|
|
38
38
|
validatedUrlSearchParams.set(pk, urlSearchParams.get(pk));
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
return `${sanitiseWaypoint(waypoint)}?${validatedUrlSearchParams.toString()}`.replace(/\?$/,
|
|
41
|
+
return `${sanitiseWaypoint(waypoint)}?${validatedUrlSearchParams.toString()}`.replace(/\?$/, "");
|
|
42
42
|
};
|
|
43
43
|
/**
|
|
44
44
|
* Generate a URL pointing at a particular waypoint.
|
|
@@ -53,31 +53,31 @@ const sanitiseWaypointWithAllowedParams = (w) => {
|
|
|
53
53
|
* })
|
|
54
54
|
* @memberof module:@dwp/govuk-casa
|
|
55
55
|
* @param {object} obj Options
|
|
56
|
-
* @param {string} [obj.waypoint
|
|
57
|
-
* @param {string} [obj.mountUrl
|
|
56
|
+
* @param {string} [obj.waypoint] Waypoint
|
|
57
|
+
* @param {string} [obj.mountUrl] Mount URL
|
|
58
58
|
* @param {JourneyContext} [obj.journeyContext] JourneyContext
|
|
59
|
-
* @param {boolean} [obj.edit
|
|
59
|
+
* @param {boolean} [obj.edit] Turn edit mode on or off
|
|
60
60
|
* @param {string} [obj.editOrigin] Edit mode original URL
|
|
61
61
|
* @param {boolean} [obj.skipTo] Skip to this waypoint from the current one
|
|
62
|
-
* @param {string} [obj.routeName
|
|
62
|
+
* @param {string} [obj.routeName] Plan route name; next | prev
|
|
63
63
|
* @returns {string} URL
|
|
64
64
|
*/
|
|
65
|
-
function waypointUrl({ waypoint =
|
|
66
|
-
const url = new URL(
|
|
65
|
+
function waypointUrl({ waypoint = "", mountUrl = "/", journeyContext, edit = false, editOrigin, skipTo, routeName = "next", } = Object.create(null)) {
|
|
66
|
+
const url = new URL("https://placeholder.test");
|
|
67
67
|
// Handle url:// protocol
|
|
68
68
|
// - This will generate a link to the root handler "_" for the given mount path
|
|
69
|
-
if (String(waypoint).substr(0, 7) ===
|
|
69
|
+
if (String(waypoint).substr(0, 7) === "url:///") {
|
|
70
70
|
const m = waypoint.match(reUrlProtocolExtract);
|
|
71
|
-
const u = new URL(sanitiseWaypointWithAllowedParams(m[1]),
|
|
71
|
+
const u = new URL(sanitiseWaypointWithAllowedParams(m[1]), "https://placeholder.test/");
|
|
72
72
|
url.pathname = `${sanitiseWaypoint(u.pathname)}/_/`;
|
|
73
|
-
url.searchParams.set(
|
|
74
|
-
url.searchParams.set(
|
|
73
|
+
url.searchParams.set("refmount", `url://${mountUrl}`);
|
|
74
|
+
url.searchParams.set("route", routeName);
|
|
75
75
|
for (const [uk, uv] of u.searchParams.entries()) {
|
|
76
76
|
url.searchParams.append(uk, uv);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
else {
|
|
80
|
-
const u = new URL(sanitiseWaypointWithAllowedParams(`${mountUrl}${waypoint}`),
|
|
80
|
+
const u = new URL(sanitiseWaypointWithAllowedParams(`${mountUrl}${waypoint}`), "https://placeholder.test/");
|
|
81
81
|
url.pathname = u.pathname;
|
|
82
82
|
url.search = u.search;
|
|
83
83
|
}
|
|
@@ -85,22 +85,22 @@ function waypointUrl({ waypoint = '', mountUrl = '/', journeyContext, edit = fal
|
|
|
85
85
|
// To avoid messy URLs with duplicated content, this parameter will _not_ be
|
|
86
86
|
// added if the context ID already appears in the url path, i.e. to avoid
|
|
87
87
|
// `/path/1234-abcd/waypoint?contextid=1234-abcd` scenarios
|
|
88
|
-
if (journeyContext
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
url.searchParams.set(
|
|
88
|
+
if (journeyContext &&
|
|
89
|
+
!journeyContext.isDefault() &&
|
|
90
|
+
journeyContext.identity.id &&
|
|
91
|
+
!mountUrl.includes(`/${journeyContext.identity.id}/`)) {
|
|
92
|
+
url.searchParams.set("contextid", journeyContext.identity.id);
|
|
93
93
|
}
|
|
94
94
|
// Attach edit mode flag
|
|
95
95
|
if (edit === true) {
|
|
96
|
-
url.searchParams.set(
|
|
96
|
+
url.searchParams.set("edit", "true");
|
|
97
97
|
}
|
|
98
98
|
if (edit && editOrigin) {
|
|
99
|
-
url.searchParams.set(
|
|
99
|
+
url.searchParams.set("editorigin", sanitiseWaypointWithAllowedParams(editOrigin));
|
|
100
100
|
}
|
|
101
101
|
// Skipto
|
|
102
102
|
if (skipTo) {
|
|
103
|
-
url.searchParams.set(
|
|
103
|
+
url.searchParams.set("skipto", sanitiseWaypointWithAllowedParams(skipTo));
|
|
104
104
|
}
|
|
105
105
|
return `${sanitiseWaypoint(url.pathname)}${url.search}`;
|
|
106
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waypoint-url.js","sourceRoot":"","sources":["../../src/lib/waypoint-url.js"],"names":[],"mappings":";AAAA;;;GAGG;;
|
|
1
|
+
{"version":3,"file":"waypoint-url.js","sourceRoot":"","sources":["../../src/lib/waypoint-url.js"],"names":[],"mappings":";AAAA;;;GAGG;;AAoEH,8BAqEC;AAvID,sBAAsB;AACtB,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,EAAE,CAC7B,CAAC,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAEvD;;;;;;;GAOG;AACH,MAAM,iCAAiC,GAAG,CAAC,CAAC,EAAE,EAAE;IAC9C,qBAAqB;IACrB,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;IACD,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC;IACpC,MAAM,eAAe,GAAG,IAAI,eAAe,CAAC,SAAS,CAAC,CAAC;IAEvD,yCAAyC;IACzC,MAAM,wBAAwB,GAAG,IAAI,eAAe,EAAE,CAAC;IACvD,KAAK,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/B,IAAI,eAAe,CAAC,GAAG,CAAC,EAA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,CAAC,MAAM,EAAE,CAAC;AAC1D,CAAC"}
|
|
@@ -1,5 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Verify request body.
|
|
3
|
+
*
|
|
4
|
+
* @param {Request} req HTTP request
|
|
5
|
+
* @param {Response} res HTTP response
|
|
6
|
+
* @param {Buffer} buf Buffer
|
|
7
|
+
* @param {string} encoding Character encoding
|
|
8
|
+
* @returns {void}
|
|
9
|
+
* @throws {Error} For invalid bodies
|
|
10
|
+
*/
|
|
11
|
+
export function verifyBody(req: Request, res: Response, buf: Buffer, encoding: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* Body parsing middleware.
|
|
14
|
+
*
|
|
15
|
+
* @param {object} opts Options
|
|
16
|
+
* @param {number} opts.formMaxParams Max number of parameters that should be
|
|
17
|
+
* parsed
|
|
18
|
+
* @param {number} opts.formMaxBytes Max bytes that should be read
|
|
19
|
+
* @returns {RequestHandler[]} Middleware functions
|
|
20
|
+
*/
|
|
21
|
+
export default function bodyParserMiddleware({ formMaxParams, formMaxBytes }: {
|
|
22
|
+
formMaxParams: number;
|
|
23
|
+
formMaxBytes: number;
|
|
24
|
+
}): RequestHandler[];
|
|
25
|
+
export type RequestHandler = import("express").RequestHandler;
|
|
26
|
+
export type Request = import("express").Request;
|
|
27
|
+
export type Response = import("express").Response;
|
|
@@ -3,26 +3,57 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.verifyBody = verifyBody;
|
|
4
4
|
exports.default = bodyParserMiddleware;
|
|
5
5
|
const express_1 = require("express");
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {import("express").RequestHandler} RequestHandler
|
|
8
|
+
* @access private
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {import("express").Request} Request
|
|
12
|
+
* @access private
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {import("express").Response} Response
|
|
16
|
+
* @access private
|
|
17
|
+
*/
|
|
6
18
|
const rProto = /__proto__/i;
|
|
7
19
|
const rPrototype = /prototype[='"[\]]/i;
|
|
8
20
|
const rConstructor = /constructor[='"[\]]/i;
|
|
21
|
+
/**
|
|
22
|
+
* Verify request body.
|
|
23
|
+
*
|
|
24
|
+
* @param {Request} req HTTP request
|
|
25
|
+
* @param {Response} res HTTP response
|
|
26
|
+
* @param {Buffer} buf Buffer
|
|
27
|
+
* @param {string} encoding Character encoding
|
|
28
|
+
* @returns {void}
|
|
29
|
+
* @throws {Error} For invalid bodies
|
|
30
|
+
*/
|
|
9
31
|
function verifyBody(req, res, buf, encoding) {
|
|
10
|
-
const body = decodeURI(buf.toString(encoding)).replace(/[\s\u200B-\u200D\uFEFF]/g,
|
|
32
|
+
const body = decodeURI(buf.toString(encoding)).replace(/[\s\u200B-\u200D\uFEFF]/g, "");
|
|
11
33
|
if (rProto.test(body)) {
|
|
12
|
-
throw new Error(
|
|
34
|
+
throw new Error("Request body verification failed (__proto__)");
|
|
13
35
|
}
|
|
14
36
|
if (rPrototype.test(body)) {
|
|
15
|
-
throw new Error(
|
|
37
|
+
throw new Error("Request body verification failed (prototype)");
|
|
16
38
|
}
|
|
17
39
|
if (rConstructor.test(body)) {
|
|
18
|
-
throw new Error(
|
|
40
|
+
throw new Error("Request body verification failed (constructor)");
|
|
19
41
|
}
|
|
20
42
|
}
|
|
21
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Body parsing middleware.
|
|
45
|
+
*
|
|
46
|
+
* @param {object} opts Options
|
|
47
|
+
* @param {number} opts.formMaxParams Max number of parameters that should be
|
|
48
|
+
* parsed
|
|
49
|
+
* @param {number} opts.formMaxBytes Max bytes that should be read
|
|
50
|
+
* @returns {RequestHandler[]} Middleware functions
|
|
51
|
+
*/
|
|
52
|
+
function bodyParserMiddleware({ formMaxParams, formMaxBytes }) {
|
|
22
53
|
return [
|
|
23
54
|
(0, express_1.urlencoded)({
|
|
24
55
|
extended: true,
|
|
25
|
-
type:
|
|
56
|
+
type: "application/x-www-form-urlencoded",
|
|
26
57
|
inflate: true,
|
|
27
58
|
parameterLimit: formMaxParams,
|
|
28
59
|
limit: formMaxBytes,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body-parser.js","sourceRoot":"","sources":["../../src/middleware/body-parser.js"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"body-parser.js","sourceRoot":"","sources":["../../src/middleware/body-parser.js"],"names":[],"mappings":";;AA+BA,gCAcC;AAWD,uCAWC;AAnED,qCAA0D;AAE1D;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH,MAAM,MAAM,GAAG,YAAY,CAAC;AAC5B,MAAM,UAAU,GAAG,oBAAoB,CAAC;AACxC,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAE5C;;;;;;;;;GASG;AACH,SAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ;IAChD,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CACpD,0BAA0B,EAC1B,EAAE,CACH,CAAC;IACF,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IACD,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IACD,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,SAAwB,oBAAoB,CAAC,EAAE,aAAa,EAAE,YAAY,EAAE;IAC1E,OAAO;QACL,IAAA,oBAAiB,EAAC;YAChB,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,mCAAmC;YACzC,OAAO,EAAE,IAAI;YACb,cAAc,EAAE,aAAa;YAC7B,KAAK,EAAE,YAAY;YACnB,MAAM,EAAE,UAAU;SACnB,CAAC;KACH,CAAC;AACJ,CAAC"}
|
package/dist/middleware/csrf.js
CHANGED
|
@@ -5,6 +5,9 @@ const csrf_sync_1 = require("csrf-sync");
|
|
|
5
5
|
// 2 middleware: one to generate the csrf token and check its validity (POST
|
|
6
6
|
// only), and one to provide that token to templates via the `casa.csrfToken`
|
|
7
7
|
// variable.
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
8
11
|
function csrfMiddleware() {
|
|
9
12
|
const { csrfSynchronisedProtection } = (0, csrf_sync_1.csrfSync)({
|
|
10
13
|
getTokenFromRequest: (req) => req.body._csrf,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csrf.js","sourceRoot":"","sources":["../../src/middleware/csrf.js"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"csrf.js","sourceRoot":"","sources":["../../src/middleware/csrf.js"],"names":[],"mappings":";;AASA,iCAcC;AAvBD,yCAAqC;AAErC,4EAA4E;AAC5E,6EAA6E;AAC7E,YAAY;AAEZ;;GAEG;AACH,SAAwB,cAAc;IACpC,MAAM,EAAE,0BAA0B,EAAE,GAAG,IAAA,oBAAQ,EAAC;QAC9C,mBAAmB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK;KAC7C,CAAC,CAAC;IACH,OAAO;QACL,0BAA0B;QAC1B,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;;YACjB,GAAG,CAAC,MAAM,CAAC,IAAI,mCACV,MAAA,GAAG,CAAC,MAAM,0CAAE,IAAI,KACnB,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,GAC3B,CAAC;YACF,IAAI,EAAE,CAAC;QACT,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Data middleware.
|
|
3
|
+
*
|
|
4
|
+
* Decorates the request with some contextual data about the user's journey
|
|
5
|
+
* through the application. This is used by downstream middleware and
|
|
6
|
+
* templates.
|
|
7
|
+
*
|
|
8
|
+
* @param {object} opts Options
|
|
9
|
+
* @param {Plan} opts.plan CASA Plan
|
|
10
|
+
* @param {ContextEventHandler[]} opts.events Event handlers
|
|
11
|
+
* @param {ContextIdGenerator} opts.contextIdGenerator Content ID generator
|
|
12
|
+
* @returns {RequestHandler[]} Middleware functions
|
|
13
|
+
*/
|
|
14
|
+
export default function dataMiddleware({ plan, events, contextIdGenerator }: {
|
|
15
|
+
plan: Plan;
|
|
16
|
+
events: ContextEventHandler[];
|
|
17
|
+
contextIdGenerator: ContextIdGenerator;
|
|
18
|
+
}): RequestHandler[];
|
|
19
|
+
export type RequestHandler = import("express").RequestHandler;
|
|
20
|
+
export type Plan = import("../casa.js").Plan;
|
|
21
|
+
export type ContextEventHandler = import("../casa.js").ContextEventHandler;
|
|
22
|
+
export type ContextIdGenerator = import("../casa.js").ContextIdGenerator;
|
package/dist/middleware/data.js
CHANGED
|
@@ -10,17 +10,46 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
10
10
|
const JourneyContext_js_1 = __importDefault(require("../lib/JourneyContext.js"));
|
|
11
11
|
const utils_js_1 = require("../lib/utils.js");
|
|
12
12
|
const waypoint_url_js_1 = __importDefault(require("../lib/waypoint-url.js"));
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {import("express").RequestHandler} RequestHandler
|
|
15
|
+
* @access private
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {import("../casa.js").Plan} Plan
|
|
19
|
+
* @access private
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {import("../casa.js").ContextEventHandler} ContextEventHandler
|
|
23
|
+
* @access private
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {import("../casa.js").ContextIdGenerator} ContextIdGenerator
|
|
27
|
+
* @access private
|
|
28
|
+
*/
|
|
13
29
|
const { has } = lodash_1.default;
|
|
14
30
|
const editOrigin = (req) => {
|
|
15
|
-
if (has(req.query,
|
|
31
|
+
if (has(req.query, "editorigin")) {
|
|
16
32
|
return (0, waypoint_url_js_1.default)({ waypoint: req.query.editorigin });
|
|
17
33
|
}
|
|
18
|
-
if (has(req === null || req === void 0 ? void 0 : req.body,
|
|
34
|
+
if (has(req === null || req === void 0 ? void 0 : req.body, "editorigin")) {
|
|
19
35
|
return (0, waypoint_url_js_1.default)({ waypoint: req.body.editorigin });
|
|
20
36
|
}
|
|
21
|
-
return
|
|
37
|
+
return "";
|
|
22
38
|
};
|
|
23
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Data middleware.
|
|
41
|
+
*
|
|
42
|
+
* Decorates the request with some contextual data about the user's journey
|
|
43
|
+
* through the application. This is used by downstream middleware and
|
|
44
|
+
* templates.
|
|
45
|
+
*
|
|
46
|
+
* @param {object} opts Options
|
|
47
|
+
* @param {Plan} opts.plan CASA Plan
|
|
48
|
+
* @param {ContextEventHandler[]} opts.events Event handlers
|
|
49
|
+
* @param {ContextIdGenerator} opts.contextIdGenerator Content ID generator
|
|
50
|
+
* @returns {RequestHandler[]} Middleware functions
|
|
51
|
+
*/
|
|
52
|
+
function dataMiddleware({ plan, events, contextIdGenerator }) {
|
|
24
53
|
return [
|
|
25
54
|
(req, res, next) => {
|
|
26
55
|
/* ------------------------------------------------ Request decorations */
|
|
@@ -32,7 +61,8 @@ function dataMiddleware({ plan, events, contextIdGenerator, }) {
|
|
|
32
61
|
// `contextid` request parameter
|
|
33
62
|
journeyContext: JourneyContext_js_1.default.extractContextFromRequest(req).addEventListeners(events),
|
|
34
63
|
// Edit mode
|
|
35
|
-
editMode: (has(req === null || req === void 0 ? void 0 : req.query,
|
|
64
|
+
editMode: (has(req === null || req === void 0 ? void 0 : req.query, "edit") && has(req === null || req === void 0 ? void 0 : req.query, "editorigin")) ||
|
|
65
|
+
(has(req === null || req === void 0 ? void 0 : req.body, "edit") && has(req === null || req === void 0 ? void 0 : req.body, "editorigin")), editOrigin: editOrigin(req) });
|
|
36
66
|
// Grab chosen language from session
|
|
37
67
|
req.casa.journeyContext.nav.language = req.session.language;
|
|
38
68
|
// Context ID generator
|
|
@@ -43,7 +73,7 @@ function dataMiddleware({ plan, events, contextIdGenerator, }) {
|
|
|
43
73
|
});
|
|
44
74
|
/* ------------------------------------------------- Template variables */
|
|
45
75
|
// Capture mount URL that will be used in generating all browser URLs
|
|
46
|
-
const mountUrl = (0, utils_js_1.validateUrlPath)(`${req.baseUrl}/`.replace(/\/+/g,
|
|
76
|
+
const mountUrl = (0, utils_js_1.validateUrlPath)(`${req.baseUrl}/`.replace(/\/+/g, "/"));
|
|
47
77
|
// If this CASA app is mounted on a parameterised route, then all of its
|
|
48
78
|
// static assets (served by `staticRouter`) will, by default, be served
|
|
49
79
|
// from that dynamic path, for example:
|
|
@@ -63,7 +93,7 @@ function dataMiddleware({ plan, events, contextIdGenerator, }) {
|
|
|
63
93
|
// Router, the `baseUrl` is different in each case, so we cannot rely
|
|
64
94
|
// on it to be consistent. Hence the need for this property, which will
|
|
65
95
|
// always be the non-parameterised version of the baseUrl.
|
|
66
|
-
const staticMountUrl = (0, utils_js_1.validateUrlPath)(`${req.unparameterisedBaseUrl}/`.replace(/\/+/g,
|
|
96
|
+
const staticMountUrl = (0, utils_js_1.validateUrlPath)(`${req.unparameterisedBaseUrl}/`.replace(/\/+/g, "/"));
|
|
67
97
|
// CASA and userland templates
|
|
68
98
|
res.locals.casa = {
|
|
69
99
|
mountUrl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/middleware/data.js"],"names":[],"mappings":";A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AAO,CAAC,MAAM,EAAE,GAAG,CAAC,CACtD,CAAC;YAEF,8BAA8B;YAC9B,GAAG,CAAC,MAAM,CAAC,IAAI,GAAG;gBAChB,QAAQ;gBACR,cAAc;gBACd,QAAQ,EAAE,GAAG,CAAC,IAAI,CAAC,QAAQ;gBAC3B,UAAU,EAAE,GAAG,CAAC,IAAI,CAAC,UAAU;aAChC,CAAC;YACF,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC;YAEjC,kCAAkC;YAClC,gEAAgE;YAChE,+EAA+E;YAC/E,GAAG,CAAC,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;YACnC,GAAG,CAAC,MAAM,CAAC,SAAS,GAAG,GAAG,cAAc,cAAc,CAAC;YAEvD,wEAAwE;YACxE,wEAAwE;YACxE,sEAAsE;YACtE,sEAAsE;YACtE,sCAAsC;YACtC,GAAG,CAAC,MAAM,CAAC,WAAW,GAAG,CAAC,IAAI,EAAE,EAAE,CAChC,IAAA,yBAAW,kBACT,QAAQ,EACR,cAAc,EAAE,GAAG,CAAC,IAAI,CAAC,cAAc,EACvC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,QAAQ,EACvB,UAAU,EAAE,GAAG,CAAC,IAAI,CAAC,UAAU,IAC5B,IAAI,EACP,CAAC;YAEL,IAAI,EAAE,CAAC;QACT,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -21,10 +21,10 @@ const constants_js_1 = require("../lib/constants.js");
|
|
|
21
21
|
*
|
|
22
22
|
* @param {object} obj Options
|
|
23
23
|
* @param {string} obj.waypoint Waypoint
|
|
24
|
-
* @param {PageField[]} [obj.fields
|
|
24
|
+
* @param {PageField[]} [obj.fields] Fields
|
|
25
25
|
* @returns {Array} Array of middleware
|
|
26
26
|
*/
|
|
27
|
-
exports.default = ({ waypoint, fields = []
|
|
27
|
+
exports.default = ({ waypoint, fields = [] }) => [
|
|
28
28
|
(req, res, next) => {
|
|
29
29
|
// Store a copy of the journey context before modifying it. This is useful
|
|
30
30
|
// for any comparison work that may be done in subsequent middleware.
|
|
@@ -34,7 +34,8 @@ exports.default = ({ waypoint, fields = [], }) => [
|
|
|
34
34
|
/* eslint-disable security/detect-object-injection */
|
|
35
35
|
const persistentBody = Object.create(null);
|
|
36
36
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
37
|
-
if (fields[i].meta.persist &&
|
|
37
|
+
if (fields[i].meta.persist &&
|
|
38
|
+
fields[i].getValue(req.body) !== undefined) {
|
|
38
39
|
persistentBody[fields[i].name] = fields[i].getValue(req.body);
|
|
39
40
|
}
|
|
40
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gather-fields.js","sourceRoot":"","sources":["../../src/middleware/gather-fields.js"],"names":[],"mappings":";AAAA,wEAAwE;AACxE,iCAAiC;AACjC,wDAAwD;AACxD,mEAAmE;;;;;AAEnE,iFAAsD;AACtD,sDAA2D;AAE3D;;;GAGG;AAEH;;;;;;;;;;GAUG;AACH,kBAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"gather-fields.js","sourceRoot":"","sources":["../../src/middleware/gather-fields.js"],"names":[],"mappings":";AAAA,wEAAwE;AACxE,iCAAiC;AACjC,wDAAwD;AACxD,mEAAmE;;;;;AAEnE,iFAAsD;AACtD,sDAA2D;AAE3D;;;GAGG;AAEH;;;;;;;;;;GAUG;AACH,kBAAe,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC;IAC5C,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACjB,0EAA0E;QAC1E,qEAAqE;QACrE,GAAG,CAAC,IAAI,CAAC,sBAAsB,GAAG,2BAAc,CAAC,WAAW,CAC1D,GAAG,CAAC,IAAI,CAAC,cAAc,EACvB,GAAG,CACJ,CAAC;QAEF,4CAA4C;QAC5C,iEAAiE;QACjE,qDAAqD;QACrD,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC9C,IACE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO;gBACtB,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS,EAC1C,CAAC;gBACD,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;QACD,oDAAoD;QAEpD,wEAAwE;QACxE,2EAA2E;QAC3E,0EAA0E;QAC1E,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;QACjE,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,4BAA4B,CAAC,QAAQ,CAAC,CAAC;QAC/D,2BAAc,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE;YAC9D,QAAQ,EAAE;gBACR,gBAAgB,EAAE,mCAAoB;aACvC;SACF,CAAC,CAAC;QAEH,IAAI,EAAE,CAAC;IACT,CAAC;CACF,CAAC"}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internationalisation middleware.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} opts Options
|
|
5
|
+
* @param {string[]} [opts.languages] Language codes
|
|
6
|
+
* @param {string[]} [opts.directories] Source translations directories
|
|
7
|
+
* @returns {RequestHandler[]} Middleware functions
|
|
8
|
+
*/
|
|
1
9
|
export default function i18nMiddleware({ languages, directories, }: {
|
|
2
10
|
languages?: string[] | undefined;
|
|
3
|
-
directories?:
|
|
4
|
-
}):
|
|
11
|
+
directories?: string[] | undefined;
|
|
12
|
+
}): RequestHandler[];
|
|
13
|
+
export type RequestHandler = import("express").RequestHandler;
|
package/dist/middleware/i18n.js
CHANGED
|
@@ -9,21 +9,25 @@ const i18next_http_middleware_1 = require("i18next-http-middleware");
|
|
|
9
9
|
const path_1 = require("path");
|
|
10
10
|
const fs_1 = require("fs");
|
|
11
11
|
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
12
|
-
const js_yaml_1 =
|
|
12
|
+
const js_yaml_1 = require("js-yaml");
|
|
13
13
|
const logger_js_1 = __importDefault(require("../lib/logger.js"));
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {import("express").RequestHandler} RequestHandler
|
|
16
|
+
* @access private
|
|
17
|
+
*/
|
|
18
|
+
const log = (0, logger_js_1.default)("middleware:i18n");
|
|
15
19
|
const loadJson = (file) => {
|
|
16
20
|
// Strip out newlines (this is a legacy feature which we're keeping for
|
|
17
21
|
// backwards compatibility).
|
|
18
22
|
/* eslint-disable-next-line security/detect-non-literal-fs-filename */
|
|
19
|
-
const json = (0, fs_1.readFileSync)(file,
|
|
20
|
-
return JSON.parse(json.replace(/[\r\n]/g,
|
|
23
|
+
const json = (0, fs_1.readFileSync)(file, "utf8");
|
|
24
|
+
return JSON.parse(json.replace(/[\r\n]/g, ""));
|
|
21
25
|
};
|
|
22
26
|
/* eslint-disable-next-line security/detect-non-literal-fs-filename */
|
|
23
|
-
const loadYaml = (file) => js_yaml_1.
|
|
27
|
+
const loadYaml = (file) => (0, js_yaml_1.load)((0, fs_1.readFileSync)(file, "utf8"));
|
|
24
28
|
const extract = (file) => {
|
|
25
|
-
const ext = /.yaml$/i.test(file) ?
|
|
26
|
-
const data = ext ===
|
|
29
|
+
const ext = /.yaml$/i.test(file) ? ".yaml" : ".json";
|
|
30
|
+
const data = ext === ".yaml" ? loadYaml(file) : loadJson(file);
|
|
27
31
|
return {
|
|
28
32
|
ns: (0, path_1.basename)(file, ext),
|
|
29
33
|
data,
|
|
@@ -42,7 +46,7 @@ const loadResources = (languages, directories) => {
|
|
|
42
46
|
if (!(0, fs_1.existsSync)(dir)) {
|
|
43
47
|
return;
|
|
44
48
|
}
|
|
45
|
-
log.info(
|
|
49
|
+
log.info("Loading %s language from %s ...", language, dir);
|
|
46
50
|
/* eslint-disable-next-line security/detect-non-literal-fs-filename */
|
|
47
51
|
(0, fs_1.readdirSync)(dir).forEach((file) => {
|
|
48
52
|
const { ns, data } = extract((0, path_1.resolve)(dir, file));
|
|
@@ -56,26 +60,32 @@ const loadResources = (languages, directories) => {
|
|
|
56
60
|
});
|
|
57
61
|
return store;
|
|
58
62
|
};
|
|
59
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Internationalisation middleware.
|
|
65
|
+
*
|
|
66
|
+
* @param {object} opts Options
|
|
67
|
+
* @param {string[]} [opts.languages] Language codes
|
|
68
|
+
* @param {string[]} [opts.directories] Source translations directories
|
|
69
|
+
* @returns {RequestHandler[]} Middleware functions
|
|
70
|
+
*/
|
|
71
|
+
function i18nMiddleware({ languages = ["en", "cy"], directories = [], }) {
|
|
60
72
|
// Load _all_ translations, from all directories into memory.
|
|
61
73
|
const resources = loadResources(languages, directories);
|
|
62
74
|
// Configure i18next
|
|
63
75
|
const i18nInstance = (0, i18next_1.createInstance)();
|
|
64
|
-
i18nInstance
|
|
65
|
-
.use(i18next_http_middleware_1.LanguageDetector)
|
|
66
|
-
.init({
|
|
76
|
+
i18nInstance.use(i18next_http_middleware_1.LanguageDetector).init({
|
|
67
77
|
initImmediate: false, // because we need synchronous loading
|
|
68
78
|
supportedLngs: languages,
|
|
69
79
|
fallbackLng: false,
|
|
70
|
-
defaultNS:
|
|
80
|
+
defaultNS: "common",
|
|
71
81
|
// debug: true,
|
|
72
82
|
// All translation resources
|
|
73
83
|
resources,
|
|
74
84
|
// LanguageDetector options
|
|
75
85
|
detection: {
|
|
76
|
-
lookupQuerystring:
|
|
77
|
-
lookupSession:
|
|
78
|
-
order: [
|
|
86
|
+
lookupQuerystring: "lang",
|
|
87
|
+
lookupSession: "language",
|
|
88
|
+
order: ["querystring", "session"],
|
|
79
89
|
},
|
|
80
90
|
});
|
|
81
91
|
// 2 middleware: one to read/set the session language, and one to enhance the
|
|
@@ -83,7 +93,6 @@ function i18nMiddleware({ languages = ['en', 'cy'], directories = [], }) {
|
|
|
83
93
|
return [
|
|
84
94
|
(req, res, next) => {
|
|
85
95
|
if (!req.session.language) {
|
|
86
|
-
/* eslint-disable-next-line prefer-destructuring */
|
|
87
96
|
req.session.language = languages[0];
|
|
88
97
|
}
|
|
89
98
|
if ((req === null || req === void 0 ? void 0 : req.query.lang) && languages.includes(req.query.lang)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/middleware/i18n.js"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/middleware/i18n.js"],"names":[],"mappings":";;;;;AA8EA,iCAyCC;AAvHD,qCAAyC;AACzC,qEAAmE;AACnE,+BAAyC;AACzC,2BAA2D;AAC3D,0DAAkC;AAClC,qCAA6C;AAC7C,iEAAsC;AAEtC;;;GAGG;AAEH,MAAM,GAAG,GAAG,IAAA,mBAAM,EAAC,iBAAiB,CAAC,CAAC;AAEtC,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,EAAE;IACxB,uEAAuE;IACvE,4BAA4B;IAC5B,sEAAsE;IACtE,MAAM,IAAI,GAAG,IAAA,iBAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACxC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC;AAEF,sEAAsE;AACtE,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,cAAU,EAAC,IAAA,iBAAY,E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E;YACjB,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;gBAC1B,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;YACtC,CAAC;YACD,IAAI,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,KAAK,CAAC,IAAI,KAAI,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC1D,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAChD,CAAC;YACD,IAAI,EAAE,CAAC;QACT,CAAC;QACD,IAAA,gCAAM,EAAC,YAAY,CAAC;KACrB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
/** @returns {RequestHandler[]} Middleware functions */
|
|
2
|
+
export default function postMiddleware(): RequestHandler[];
|
|
3
|
+
export type RequestHandler = import("express").RequestHandler;
|