@nordcraft/ssr 1.0.19 → 1.0.20
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/rendering/template.js +2 -2
- package/dist/rendering/template.js.map +1 -1
- package/dist/utils/headers.d.ts +4 -4
- package/dist/utils/headers.js +6 -5
- package/dist/utils/headers.js.map +1 -1
- package/package.json +3 -3
- package/src/rendering/template.ts +2 -2
- package/src/utils/headers.ts +9 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { STRING_TEMPLATE } from '@nordcraft/core/dist/api/template';
|
|
2
2
|
import { isDefined } from '@nordcraft/core/dist/utils/util';
|
|
3
|
-
import { skipCookieHeader,
|
|
3
|
+
import { skipCookieHeader, skipNordcraftHeaders } from '../utils/headers';
|
|
4
4
|
export const applyTemplateValues = (input, cookies) => {
|
|
5
5
|
if (!isDefined(input)) {
|
|
6
6
|
return '';
|
|
@@ -27,7 +27,7 @@ export const applyTemplateValues = (input, cookies) => {
|
|
|
27
27
|
};
|
|
28
28
|
export const sanitizeProxyHeaders = ({ cookies, headers, }) => new Headers(mapTemplateHeaders({
|
|
29
29
|
cookies,
|
|
30
|
-
headers: skipCookieHeader(
|
|
30
|
+
headers: skipCookieHeader(skipNordcraftHeaders(headers)),
|
|
31
31
|
}));
|
|
32
32
|
export const mapTemplateHeaders = ({ cookies, headers, }) => new Headers([...headers.entries()].map(([name, value]) => [
|
|
33
33
|
name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/rendering/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/rendering/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,e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AAoB,CAAC,OAAO,CAAC,CAAC;CACzD,CAAC,CACH,CAAA;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EACjC,OAAO,EACP,OAAO,GAIR,EAAE,EAAE,CACH,IAAI,OAAO,CACT,CAAC,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAoB,EAAE,CAAC;IAC9D,IAAI;IACJ,8CAA8C;IAC9C,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC;CACpC,CAAC,CACH,CAAA"}
|
package/dist/utils/headers.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const skipCookieHeader: (headers: Headers) => Headers;
|
|
7
7
|
/**
|
|
8
|
-
* Omit the x-
|
|
9
|
-
* Since
|
|
10
|
-
* for other services to receive
|
|
8
|
+
* Omit the "x-nordcraft-url" and "x-nordcraft-templates-in-body" headers
|
|
9
|
+
* from a set of headers. Since these headers are only relevant for the
|
|
10
|
+
* Nordcraft API proxy, it's not useful for other services to receive them
|
|
11
11
|
*/
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const skipNordcraftHeaders: (headers: Headers) => Headers;
|
package/dist/utils/headers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PROXY_URL_HEADER } from '@nordcraft/core/dist/utils/url';
|
|
1
|
+
import { PROXY_TEMPLATES_IN_BODY, PROXY_URL_HEADER, } from '@nordcraft/core/dist/utils/url';
|
|
2
2
|
/**
|
|
3
3
|
* Omit the `cookie` header from a set of headers.
|
|
4
4
|
* This is useful when proxying requests for routes/proxied API requests
|
|
@@ -10,13 +10,14 @@ export const skipCookieHeader = (headers) => {
|
|
|
10
10
|
return newHeaders;
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
|
-
* Omit the x-
|
|
14
|
-
* Since
|
|
15
|
-
* for other services to receive
|
|
13
|
+
* Omit the "x-nordcraft-url" and "x-nordcraft-templates-in-body" headers
|
|
14
|
+
* from a set of headers. Since these headers are only relevant for the
|
|
15
|
+
* Nordcraft API proxy, it's not useful for other services to receive them
|
|
16
16
|
*/
|
|
17
|
-
export const
|
|
17
|
+
export const skipNordcraftHeaders = (headers) => {
|
|
18
18
|
const newHeaders = new Headers(headers);
|
|
19
19
|
newHeaders.delete(PROXY_URL_HEADER);
|
|
20
|
+
newHeaders.delete(PROXY_TEMPLATES_IN_BODY);
|
|
20
21
|
return newHeaders;
|
|
21
22
|
};
|
|
22
23
|
//# sourceMappingURL=headers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headers.js","sourceRoot":"","sources":["../../src/utils/headers.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"headers.js","sourceRoot":"","sources":["../../src/utils/headers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,gCAAgC,CAAA;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAgB,EAAE,EAAE;IACnD,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;IACvC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC3B,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAAgB,EAAE,EAAE;IACvD,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;IACvC,UAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAA;IACnC,UAAU,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAA;IAC1C,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"main": "dist/index.js",
|
|
14
14
|
"types": "dist/index.d.ts",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@nordcraft/core": "1.0.
|
|
17
|
-
"@nordcraft/std-lib": "1.0.
|
|
16
|
+
"@nordcraft/core": "1.0.20",
|
|
17
|
+
"@nordcraft/std-lib": "1.0.20",
|
|
18
18
|
"cookie": "1.0.2",
|
|
19
19
|
"xss": "1.0.15"
|
|
20
20
|
},
|
|
21
|
-
"version": "1.0.
|
|
21
|
+
"version": "1.0.20"
|
|
22
22
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { STRING_TEMPLATE } from '@nordcraft/core/dist/api/template'
|
|
2
2
|
import type { ToddleServerEnv } from '@nordcraft/core/dist/formula/formula'
|
|
3
3
|
import { isDefined } from '@nordcraft/core/dist/utils/util'
|
|
4
|
-
import { skipCookieHeader,
|
|
4
|
+
import { skipCookieHeader, skipNordcraftHeaders } from '../utils/headers'
|
|
5
5
|
|
|
6
6
|
export const applyTemplateValues = (
|
|
7
7
|
input: string | null | undefined,
|
|
@@ -43,7 +43,7 @@ export const sanitizeProxyHeaders = ({
|
|
|
43
43
|
new Headers(
|
|
44
44
|
mapTemplateHeaders({
|
|
45
45
|
cookies,
|
|
46
|
-
headers: skipCookieHeader(
|
|
46
|
+
headers: skipCookieHeader(skipNordcraftHeaders(headers)),
|
|
47
47
|
}),
|
|
48
48
|
)
|
|
49
49
|
|
package/src/utils/headers.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
PROXY_TEMPLATES_IN_BODY,
|
|
3
|
+
PROXY_URL_HEADER,
|
|
4
|
+
} from '@nordcraft/core/dist/utils/url'
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* Omit the `cookie` header from a set of headers.
|
|
@@ -12,12 +15,13 @@ export const skipCookieHeader = (headers: Headers) => {
|
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
|
-
* Omit the x-
|
|
16
|
-
* Since
|
|
17
|
-
* for other services to receive
|
|
18
|
+
* Omit the "x-nordcraft-url" and "x-nordcraft-templates-in-body" headers
|
|
19
|
+
* from a set of headers. Since these headers are only relevant for the
|
|
20
|
+
* Nordcraft API proxy, it's not useful for other services to receive them
|
|
18
21
|
*/
|
|
19
|
-
export const
|
|
22
|
+
export const skipNordcraftHeaders = (headers: Headers) => {
|
|
20
23
|
const newHeaders = new Headers(headers)
|
|
21
24
|
newHeaders.delete(PROXY_URL_HEADER)
|
|
25
|
+
newHeaders.delete(PROXY_TEMPLATES_IN_BODY)
|
|
22
26
|
return newHeaders
|
|
23
27
|
}
|