@hmcts/opal-frontend-common-node 0.0.7 → 0.0.9
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/README.md +42 -18
- package/csrf-token/index.d.ts.map +1 -1
- package/csrf-token/index.js +3 -4
- package/csrf-token/index.js.map +1 -1
- package/package.json +10 -8
- package/routes/index.d.ts +1 -1
- package/routes/index.d.ts.map +1 -1
- package/routes/index.js +8 -8
- package/routes/index.js.map +1 -1
- package/session/session-storage/index.d.ts +1 -1
- package/session/session-storage/index.d.ts.map +1 -1
- package/session/session-storage/index.js +19 -19
- package/session/session-storage/index.js.map +1 -1
- package/type.d.ts +0 -7
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# OPAL Frontend Common Node Library
|
|
2
|
+
|
|
2
3
|
[](https://www.npmjs.com/package/@hmcts/opal-frontend-common-node)
|
|
3
4
|
[](https://github.com/hmcts/opal-frontend-common-node-lib/blob/main/LICENSE)
|
|
4
5
|
[](https://sonarcloud.io/summary/new_code?id=hmcts_opal-frontend-common-node-lib)
|
|
@@ -47,36 +48,39 @@ See [opal-frontend](https://github.com/hmcts/opal-frontend) for how this library
|
|
|
47
48
|
Use the `yarn import:local:common-node-lib` and `yarn import:published:common-node-lib` scripts in your consuming project (`opal-frontend`) to switch between local development and the published npm version of the library.
|
|
48
49
|
|
|
49
50
|
To use a published version of this library during development in another project:
|
|
51
|
+
|
|
50
52
|
1. In the consuming project, run:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
```bash
|
|
54
|
+
yarn import:published:common-node-lib
|
|
55
|
+
```
|
|
54
56
|
|
|
55
57
|
To use a local version of this library during development in another project:
|
|
56
58
|
|
|
57
59
|
1. Build this library:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
yarn build
|
|
63
|
+
```
|
|
61
64
|
|
|
62
65
|
2. In your consuming project (e.g. `opal-frontend`), ensure you have set an environment variable pointing to the local build:
|
|
63
66
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
```bash
|
|
68
|
+
# In your shell config file (.zshrc, .bash_profile, or .bashrc)
|
|
69
|
+
export COMMON_NODE_LIB_PATH="[INSERT PATH TO COMMON NODE LIB DIST FOLDER]"
|
|
70
|
+
```
|
|
68
71
|
|
|
69
72
|
3. In the consuming project (e.g. `opal-frontend`), run:
|
|
70
|
-
```bash
|
|
71
|
-
yarn import:local:common-node-lib
|
|
72
|
-
```
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
```bash
|
|
75
|
+
yarn import:local:common-node-lib
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
This will remove the published version and install the local build using the path provided.
|
|
75
79
|
|
|
76
80
|
4. To switch back to the published version:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
```bash
|
|
82
|
+
yarn import:published:common-node-lib
|
|
83
|
+
```
|
|
80
84
|
|
|
81
85
|
This setup makes it easy to switch between development and production versions of the shared library.
|
|
82
86
|
|
|
@@ -103,6 +107,26 @@ To lint and check formatting:
|
|
|
103
107
|
yarn lint
|
|
104
108
|
```
|
|
105
109
|
|
|
110
|
+
There is a custom lint rule for member ordering to ensure members in the code are ordered in the following format:
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
[
|
|
114
|
+
"private-static-field",
|
|
115
|
+
"protected-static-field",
|
|
116
|
+
"public-static-field",
|
|
117
|
+
"private-instance-field",
|
|
118
|
+
"protected-instance-field",
|
|
119
|
+
"public-instance-field",
|
|
120
|
+
"constructor",
|
|
121
|
+
"private-static-method",
|
|
122
|
+
"protected-static-method",
|
|
123
|
+
"public-static-method",
|
|
124
|
+
"private-instance-method",
|
|
125
|
+
"protected-instance-method",
|
|
126
|
+
"public-instance-method"
|
|
127
|
+
]
|
|
128
|
+
```
|
|
129
|
+
|
|
106
130
|
To fix formatting issues automatically:
|
|
107
131
|
|
|
108
132
|
```bash
|
|
@@ -145,4 +169,4 @@ The following commands are available in the `package.json`:
|
|
|
145
169
|
Checks if files are formatted correctly.
|
|
146
170
|
|
|
147
171
|
- `yarn prettier:fix`
|
|
148
|
-
Automatically formats the codebase.
|
|
172
|
+
Automatically formats the codebase.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/csrf-token/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/csrf-token/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,qBAAa,SAAS;IACb,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;CA8BjH"}
|
package/csrf-token/index.js
CHANGED
|
@@ -10,9 +10,8 @@ export class CSRFToken {
|
|
|
10
10
|
secure: secure,
|
|
11
11
|
path: '/',
|
|
12
12
|
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
13
|
+
getSessionIdentifier: (req) => req.session.id,
|
|
14
|
+
getCsrfTokenFromRequest: (req) => req.cookies[cookieName].split('|')[0] ?? null,
|
|
16
15
|
});
|
|
17
16
|
app.use((req, res, next) => {
|
|
18
17
|
if (ignore.includes(req.url)) {
|
|
@@ -24,7 +23,7 @@ export class CSRFToken {
|
|
|
24
23
|
});
|
|
25
24
|
app.use((req, res, next) => {
|
|
26
25
|
if (req.csrfToken) {
|
|
27
|
-
req.csrfToken(true);
|
|
26
|
+
req.csrfToken({ overwrite: true, validateOnReuse: true });
|
|
28
27
|
}
|
|
29
28
|
next();
|
|
30
29
|
});
|
package/csrf-token/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/csrf-token/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,MAAM,OAAO,SAAS;IACb,SAAS,CAAC,GAAgB,EAAE,MAAc,EAAE,UAAkB,EAAE,QAAiB,EAAE,MAAe;QACvG,MAAM,MAAM,GAAG,CAAC,qBAAqB,CAAC,CAAC;QAEvC,MAAM,EAAE,oBAAoB,EAAE,GAAG,UAAU,CAAC;YAC1C,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM;YACvB,UAAU,EAAE,UAAU;YACtB,aAAa,EAAE;gBACb,QAAQ,EAAE,QAAQ;gBAClB,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,GAAG;aACV;YACD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/csrf-token/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,MAAM,OAAO,SAAS;IACb,SAAS,CAAC,GAAgB,EAAE,MAAc,EAAE,UAAkB,EAAE,QAAiB,EAAE,MAAe;QACvG,MAAM,MAAM,GAAG,CAAC,qBAAqB,CAAC,CAAC;QAEvC,MAAM,EAAE,oBAAoB,EAAE,GAAG,UAAU,CAAC;YAC1C,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM;YACvB,UAAU,EAAE,UAAU;YACtB,aAAa,EAAE;gBACb,QAAQ,EAAE,QAAQ;gBAClB,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,GAAG;aACV;YACD,oBAAoB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YAC7C,uBAAuB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI;SAChF,CAAC,CAAC;QAEH,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;YACzB,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC7B,IAAI,EAAE,CAAC;YACT,CAAC;iBAAM,CAAC;gBACN,oBAAoB,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;YACvC,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;YACzB,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;gBAClB,GAAG,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;YAC5D,CAAC;YACD,IAAI,EAAE,CAAC;QACT,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmcts/opal-frontend-common-node",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.9",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Common nodejs library components for opal",
|
|
7
7
|
"main": "dist/index",
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"clean": "rm -rf dist",
|
|
12
12
|
"lint": "eslint ./src --ext .ts && yarn prettier",
|
|
13
13
|
"prettier": "prettier --check \"./src/**/*.{ts,js,json}\"",
|
|
14
|
-
"prettier:fix": "prettier --write \"./src/**/*.{ts,js,json}\""
|
|
14
|
+
"prettier:fix": "prettier --write \"./src/**/*.{ts,js,json}\"",
|
|
15
|
+
"audit:save": "yarn audit --recursive --environment production --json > yarn-known-issues || true",
|
|
16
|
+
"audit:check": "yarn audit --recursive --environment production --json > yarn-known-issues-current || true && jq -s '[.[] | select(.type==\"auditAdvisory\") | .data.advisory.id] | sort' yarn-known-issues-current > current-ids.json && jq -s '[.[] | select(.type==\"auditAdvisory\") | .data.advisory.id] | sort' yarn-known-issues > known-ids.json && diff -q known-ids.json current-ids.json || (echo '❌ New vulnerabilities detected. Please review.' && exit 1)"
|
|
15
17
|
},
|
|
16
18
|
"dependencies": {
|
|
17
19
|
"@hmcts/info-provider": "^1.1.0",
|
|
@@ -21,17 +23,17 @@
|
|
|
21
23
|
"applicationinsights": "~2.9.6",
|
|
22
24
|
"axios": "^1.6.2",
|
|
23
25
|
"body-parser": "^2.0.0",
|
|
24
|
-
"config": "^
|
|
25
|
-
"connect-redis": "^
|
|
26
|
+
"config": "^4.0.0",
|
|
27
|
+
"connect-redis": "^9.0.0",
|
|
26
28
|
"cookie-parser": "^1.4.6",
|
|
27
|
-
"csrf-csrf": "^
|
|
29
|
+
"csrf-csrf": "^4.0.0",
|
|
28
30
|
"express": "^5.0.0",
|
|
29
31
|
"express-session": "^1.17.3",
|
|
30
32
|
"helmet": "^8.0.0",
|
|
31
33
|
"http-proxy-middleware": "^3.0.0",
|
|
32
34
|
"luxon": "^3.4.3",
|
|
33
35
|
"prettier": "^3.0.3",
|
|
34
|
-
"redis": "^
|
|
36
|
+
"redis": "^5.0.0",
|
|
35
37
|
"session-file-store": "^1.5.0",
|
|
36
38
|
"xml2js": "^0.6.2"
|
|
37
39
|
},
|
|
@@ -42,8 +44,8 @@
|
|
|
42
44
|
"@types/luxon": "^3.4.2",
|
|
43
45
|
"@types/node": "^22.0.0",
|
|
44
46
|
"@types/session-file-store": "^1.2.5",
|
|
45
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
46
|
-
"@typescript-eslint/parser": "8.
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "8.35.1",
|
|
48
|
+
"@typescript-eslint/parser": "8.35.1",
|
|
47
49
|
"eslint": "^9.0.0",
|
|
48
50
|
"eslint-plugin-prettier": "^5.2.6",
|
|
49
51
|
"typescript": "~5.8.0",
|
package/routes/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import RoutesConfiguration from '@hmcts/opal-frontend-common-node/interfaces/rou
|
|
|
4
4
|
import SsoConfiguration from '@hmcts/opal-frontend-common-node/interfaces/sso-config';
|
|
5
5
|
import SessionConfiguration from '@hmcts/opal-frontend-common-node/interfaces/session-config';
|
|
6
6
|
export declare class Routes {
|
|
7
|
-
enableFor(app: Application, ssoEnabled: boolean, expiryConfiguration: ExpiryConfiguration, routesConfiguration: RoutesConfiguration, sessionConfiguration: SessionConfiguration, ssoConfiguration: SsoConfiguration): void;
|
|
8
7
|
private setupSSORoutes;
|
|
8
|
+
enableFor(app: Application, ssoEnabled: boolean, expiryConfiguration: ExpiryConfiguration, routesConfiguration: RoutesConfiguration, sessionConfiguration: SessionConfiguration, ssoConfiguration: SsoConfiguration): void;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/routes/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAatC,OAAO,mBAAmB,MAAM,mEAAmE,CAAC;AACpG,OAAO,mBAAmB,MAAM,2DAA2D,CAAC;AAC5F,OAAO,gBAAgB,MAAM,wDAAwD,CAAC;AACtF,OAAO,oBAAoB,MAAM,4DAA4D,CAAC;AAE9F,qBAAa,MAAM;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAatC,OAAO,mBAAmB,MAAM,mEAAmE,CAAC;AACpG,OAAO,mBAAmB,MAAM,2DAA2D,CAAC;AAC5F,OAAO,gBAAgB,MAAM,wDAAwD,CAAC;AACtF,OAAO,oBAAoB,MAAM,4DAA4D,CAAC;AAE9F,qBAAa,MAAM;IACjB,OAAO,CAAC,cAAc;IAuCf,SAAS,CACd,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE,OAAO,EACnB,mBAAmB,EAAE,mBAAmB,EACxC,mBAAmB,EAAE,mBAAmB,EACxC,oBAAoB,EAAE,oBAAoB,EAC1C,gBAAgB,EAAE,gBAAgB,GACjC,IAAI;CAyBR"}
|
package/routes/index.js
CHANGED
|
@@ -4,14 +4,6 @@ import { ssoLoginStub, ssoLoginCallbackStub, ssoAuthenticatedStub, ssoLogoutStub
|
|
|
4
4
|
import sessionExpiry from '@hmcts/opal-frontend-common-node/session/session-expiry';
|
|
5
5
|
import sessionUserState from '@hmcts/opal-frontend-common-node/session/session-user-state';
|
|
6
6
|
export class Routes {
|
|
7
|
-
enableFor(app, ssoEnabled, expiryConfiguration, routesConfiguration, sessionConfiguration, ssoConfiguration) {
|
|
8
|
-
// Declare use of body-parser AFTER the use of proxy https://github.com/villadora/express-http-proxy
|
|
9
|
-
app.use(bodyParser.json());
|
|
10
|
-
app.use(bodyParser.urlencoded({ extended: false }));
|
|
11
|
-
this.setupSSORoutes(app, ssoEnabled, routesConfiguration.opalApiTarget, routesConfiguration.frontendHostname, routesConfiguration.prefix, ssoConfiguration);
|
|
12
|
-
app.get(sessionConfiguration.userStateUrl, (req, res) => sessionUserState(req, res));
|
|
13
|
-
app.get(sessionConfiguration.sessionExpiryUrl, (req, res) => sessionExpiry(req, res, expiryConfiguration.testMode, expiryConfiguration.expiryTimeInMilliseconds, expiryConfiguration.warningThresholdInMilliseconds));
|
|
14
|
-
}
|
|
15
7
|
setupSSORoutes(app, ssoEnabled, opalApiUrl, frontendHostname, prefix, ssoConfiguration) {
|
|
16
8
|
const login = ssoEnabled ? ssoLogin : ssoLoginStub;
|
|
17
9
|
const loginCallback = ssoEnabled ? ssoLoginCallback : ssoLoginCallbackStub;
|
|
@@ -32,5 +24,13 @@ export class Routes {
|
|
|
32
24
|
app.get(ssoConfiguration.logoutCallback, (req, res, next) => logoutCallback(req, res, next, prefix));
|
|
33
25
|
app.get(ssoConfiguration.authenticated, (req, res) => authenticated(req, res));
|
|
34
26
|
}
|
|
27
|
+
enableFor(app, ssoEnabled, expiryConfiguration, routesConfiguration, sessionConfiguration, ssoConfiguration) {
|
|
28
|
+
// Declare use of body-parser AFTER the use of proxy https://github.com/villadora/express-http-proxy
|
|
29
|
+
app.use(bodyParser.json());
|
|
30
|
+
app.use(bodyParser.urlencoded({ extended: false }));
|
|
31
|
+
this.setupSSORoutes(app, ssoEnabled, routesConfiguration.opalApiTarget, routesConfiguration.frontendHostname, routesConfiguration.prefix, ssoConfiguration);
|
|
32
|
+
app.get(sessionConfiguration.userStateUrl, (req, res) => sessionUserState(req, res));
|
|
33
|
+
app.get(sessionConfiguration.sessionExpiryUrl, (req, res) => sessionExpiry(req, res, expiryConfiguration.testMode, expiryConfiguration.expiryTimeInMilliseconds, expiryConfiguration.warningThresholdInMilliseconds));
|
|
34
|
+
}
|
|
35
35
|
}
|
|
36
36
|
//# sourceMappingURL=index.js.map
|
package/routes/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AACpG,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,aAAa,MAAM,yDAAyD,CAAC;AACpF,OAAO,gBAAgB,MAAM,6DAA6D,CAAC;AAM3F,MAAM,OAAO,MAAM;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,E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EF,GAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,YAAY,EAAE,CAAC,GAAY,EAAE,GAAa,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;QACxG,GAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,CAAC,GAAY,EAAE,GAAa,EAAE,EAAE,CAC7E,aAAa,CACX,GAAG,EACH,GAAG,EACH,mBAAmB,CAAC,QAAQ,EAC5B,mBAAmB,CAAC,wBAAwB,EAC5C,mBAAmB,CAAC,8BAA8B,CACnD,CACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import SessionStorageConfiguration from '@hmcts/opal-frontend-common-node/interfaces/session-storage-config';
|
|
2
2
|
import { Application } from 'express';
|
|
3
3
|
export default class SessionStorage {
|
|
4
|
-
enableFor(app: Application, sessionStorage: SessionStorageConfiguration): void;
|
|
5
4
|
private getStore;
|
|
5
|
+
enableFor(app: Application, sessionStorage: SessionStorageConfiguration): void;
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/session/session-storage/index.ts"],"names":[],"mappings":"AACA,OAAO,2BAA2B,MAAM,oEAAoE,CAAC;AAG7G,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAQtC,MAAM,CAAC,OAAO,OAAO,cAAc;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/session/session-storage/index.ts"],"names":[],"mappings":"AACA,OAAO,2BAA2B,MAAM,oEAAoE,CAAC;AAG7G,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAQtC,MAAM,CAAC,OAAO,OAAO,cAAc;IACjC,OAAO,CAAC,QAAQ;IA+BT,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,cAAc,EAAE,2BAA2B,GAAG,IAAI;CAsBtF"}
|
|
@@ -7,25 +7,6 @@ import FileStoreFactory from 'session-file-store';
|
|
|
7
7
|
const FileStore = FileStoreFactory(session);
|
|
8
8
|
const logger = Logger.getLogger('session-storage');
|
|
9
9
|
export default class SessionStorage {
|
|
10
|
-
enableFor(app, sessionStorage) {
|
|
11
|
-
app.use(cookieParser(sessionStorage.secret));
|
|
12
|
-
app.set('trust proxy', 1);
|
|
13
|
-
app.use(session({
|
|
14
|
-
name: sessionStorage.prefix,
|
|
15
|
-
resave: false,
|
|
16
|
-
saveUninitialized: false,
|
|
17
|
-
secret: sessionStorage.secret,
|
|
18
|
-
cookie: {
|
|
19
|
-
httpOnly: true,
|
|
20
|
-
maxAge: sessionStorage.maxAge,
|
|
21
|
-
sameSite: sessionStorage.sameSite,
|
|
22
|
-
secure: sessionStorage.secure,
|
|
23
|
-
domain: sessionStorage.domain,
|
|
24
|
-
},
|
|
25
|
-
rolling: true,
|
|
26
|
-
store: this.getStore(app, sessionStorage.redisEnabled, sessionStorage.redisConnectionString),
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
10
|
getStore(app, enabled, connectionString) {
|
|
30
11
|
if (enabled) {
|
|
31
12
|
logger.info('Using Redis session store', connectionString);
|
|
@@ -54,5 +35,24 @@ export default class SessionStorage {
|
|
|
54
35
|
}
|
|
55
36
|
return new FileStore({ path: '/tmp' });
|
|
56
37
|
}
|
|
38
|
+
enableFor(app, sessionStorage) {
|
|
39
|
+
app.use(cookieParser(sessionStorage.secret));
|
|
40
|
+
app.set('trust proxy', 1);
|
|
41
|
+
app.use(session({
|
|
42
|
+
name: sessionStorage.prefix,
|
|
43
|
+
resave: false,
|
|
44
|
+
saveUninitialized: false,
|
|
45
|
+
secret: sessionStorage.secret,
|
|
46
|
+
cookie: {
|
|
47
|
+
httpOnly: true,
|
|
48
|
+
maxAge: sessionStorage.maxAge,
|
|
49
|
+
sameSite: sessionStorage.sameSite,
|
|
50
|
+
secure: sessionStorage.secure,
|
|
51
|
+
domain: sessionStorage.domain,
|
|
52
|
+
},
|
|
53
|
+
rolling: true,
|
|
54
|
+
store: this.getStore(app, sessionStorage.redisEnabled, sessionStorage.redisConnectionString),
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
57
|
}
|
|
58
58
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/session/session-storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,YAAY,MAAM,eAAe,CAAC;AAEzC,OAAO,OAAO,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,MAAM,SAAS,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;AAEnD,MAAM,CAAC,OAAO,OAAO,cAAc;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/session/session-storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,YAAY,MAAM,eAAe,CAAC;AAEzC,OAAO,OAAO,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,MAAM,SAAS,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;AAEnD,MAAM,CAAC,O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