@lwrjs/shared-utils 0.17.2-alpha.10 → 0.17.2-alpha.12
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/build/cjs/env.cjs +14 -6
- package/build/es/env.d.ts +6 -2
- package/build/es/env.js +11 -5
- package/package.json +4 -4
package/build/cjs/env.cjs
CHANGED
|
@@ -8,8 +8,12 @@ var __export = (target, all) => {
|
|
|
8
8
|
// packages/@lwrjs/shared-utils/src/env.ts
|
|
9
9
|
__markAsModule(exports);
|
|
10
10
|
__export(exports, {
|
|
11
|
+
B3_TRACE_ID: () => B3_TRACE_ID,
|
|
12
|
+
CORRELATION_ID: () => CORRELATION_ID,
|
|
13
|
+
MRT_REQUEST_CLASS: () => MRT_REQUEST_CLASS,
|
|
11
14
|
REQUEST_DEPTH_HEADER: () => REQUEST_DEPTH_HEADER,
|
|
12
|
-
|
|
15
|
+
ROUTE_CORE_HEADER: () => ROUTE_CORE_HEADER,
|
|
16
|
+
TRUE_CLIENT_IP: () => TRUE_CLIENT_IP,
|
|
13
17
|
buildEnvironmentContext: () => buildEnvironmentContext,
|
|
14
18
|
getFeatureFlags: () => getFeatureFlags,
|
|
15
19
|
isLambdaEnv: () => isLambdaEnv,
|
|
@@ -64,11 +68,15 @@ function buildEnvironmentContext(runtimeParams) {
|
|
|
64
68
|
uiBasePath
|
|
65
69
|
};
|
|
66
70
|
}
|
|
67
|
-
var
|
|
68
|
-
var
|
|
71
|
+
var TRUE_CLIENT_IP = "true-client-ip";
|
|
72
|
+
var B3_TRACE_ID = "x-b3-traceid";
|
|
73
|
+
var CORRELATION_ID = "x-correlation-id";
|
|
74
|
+
var MRT_REQUEST_CLASS = "x-mobify-request-class";
|
|
75
|
+
var ROUTE_CORE_HEADER = "x-sfdc-route-core";
|
|
76
|
+
var REQUEST_DEPTH_HEADER = "x-sfdc-request-depth";
|
|
69
77
|
function parseRequestDepth(headers = {}, query = {}) {
|
|
70
78
|
let maxDepth = 0;
|
|
71
|
-
const value = headers && headers[
|
|
79
|
+
const value = headers && headers[REQUEST_DEPTH_HEADER];
|
|
72
80
|
if (value) {
|
|
73
81
|
if (Array.isArray(value)) {
|
|
74
82
|
for (const depth of value) {
|
|
@@ -86,8 +94,8 @@ function parseRequestDepth(headers = {}, query = {}) {
|
|
|
86
94
|
}
|
|
87
95
|
}
|
|
88
96
|
}
|
|
89
|
-
if (query[
|
|
90
|
-
const queryValue = parseInt(query[
|
|
97
|
+
if (query[REQUEST_DEPTH_HEADER]) {
|
|
98
|
+
const queryValue = parseInt(query[REQUEST_DEPTH_HEADER], 10);
|
|
91
99
|
if (!isNaN(queryValue) && queryValue > maxDepth) {
|
|
92
100
|
maxDepth = queryValue;
|
|
93
101
|
}
|
package/build/es/env.d.ts
CHANGED
|
@@ -16,7 +16,11 @@ export declare function isLocalDev(): boolean;
|
|
|
16
16
|
* Create a serializable context for user-land exposed environment variables
|
|
17
17
|
*/
|
|
18
18
|
export declare function buildEnvironmentContext(runtimeParams: RuntimeParams): EnvironmentContext;
|
|
19
|
-
export declare const
|
|
20
|
-
export declare const
|
|
19
|
+
export declare const TRUE_CLIENT_IP = "true-client-ip";
|
|
20
|
+
export declare const B3_TRACE_ID = "x-b3-traceid";
|
|
21
|
+
export declare const CORRELATION_ID = "x-correlation-id";
|
|
22
|
+
export declare const MRT_REQUEST_CLASS = "x-mobify-request-class";
|
|
23
|
+
export declare const ROUTE_CORE_HEADER = "x-sfdc-route-core";
|
|
24
|
+
export declare const REQUEST_DEPTH_HEADER = "x-sfdc-request-depth";
|
|
21
25
|
export declare function parseRequestDepth(headers?: Headers, query?: Record<string, string>): number;
|
|
22
26
|
//# sourceMappingURL=env.d.ts.map
|
package/build/es/env.js
CHANGED
|
@@ -89,11 +89,17 @@ export function buildEnvironmentContext(runtimeParams) {
|
|
|
89
89
|
uiBasePath,
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
export const
|
|
92
|
+
// headers used by LWR-Node and LWR@MRT
|
|
93
|
+
export const TRUE_CLIENT_IP = 'true-client-ip'; // public IP of the original request source, eg: 13.123.12.3
|
|
94
|
+
export const B3_TRACE_ID = 'x-b3-traceid'; // trace ID shared across service boundaries for a page request, eg: 463ac35c9f6413ad48485a3953bb6124
|
|
95
|
+
export const CORRELATION_ID = 'x-correlation-id'; // shared correlation ID for the request
|
|
96
|
+
export const MRT_REQUEST_CLASS = 'x-mobify-request-class'; // contains the site base path, eg: basePath=/mysite
|
|
97
|
+
export const ROUTE_CORE_HEADER = 'x-sfdc-route-core'; // helps route requests to Core efficiently, value: true
|
|
98
|
+
export const REQUEST_DEPTH_HEADER = 'x-sfdc-request-depth'; // tracks the request depth to prevent cycles to the LWR server, eg: 2
|
|
99
|
+
// standard headers: Forwarded (eg: host=dev.testing.com;proto=https), Host (eg: darrell.sandbox.my.site.com), Cookie (holds the SID for auth'ed requests)
|
|
94
100
|
export function parseRequestDepth(headers = {}, query = {}) {
|
|
95
101
|
let maxDepth = 0;
|
|
96
|
-
const value = headers && headers[
|
|
102
|
+
const value = headers && headers[REQUEST_DEPTH_HEADER];
|
|
97
103
|
if (value) {
|
|
98
104
|
if (Array.isArray(value)) {
|
|
99
105
|
for (const depth of value) {
|
|
@@ -112,8 +118,8 @@ export function parseRequestDepth(headers = {}, query = {}) {
|
|
|
112
118
|
}
|
|
113
119
|
}
|
|
114
120
|
}
|
|
115
|
-
if (query[
|
|
116
|
-
const queryValue = parseInt(query[
|
|
121
|
+
if (query[REQUEST_DEPTH_HEADER]) {
|
|
122
|
+
const queryValue = parseInt(query[REQUEST_DEPTH_HEADER], 10);
|
|
117
123
|
if (!isNaN(queryValue) && queryValue > maxDepth) {
|
|
118
124
|
maxDepth = queryValue;
|
|
119
125
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.17.2-alpha.
|
|
7
|
+
"version": "0.17.2-alpha.12",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"build/**/*.d.ts"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@lwrjs/diagnostics": "0.17.2-alpha.
|
|
40
|
+
"@lwrjs/diagnostics": "0.17.2-alpha.12",
|
|
41
41
|
"es-module-lexer": "^1.5.4",
|
|
42
42
|
"fast-json-stable-stringify": "^2.1.0",
|
|
43
43
|
"magic-string": "^0.30.9",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"slugify": "^1.4.5"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@lwrjs/types": "0.17.2-alpha.
|
|
53
|
+
"@lwrjs/types": "0.17.2-alpha.12",
|
|
54
54
|
"@types/mime-types": "2.1.4",
|
|
55
55
|
"@types/path-to-regexp": "^1.7.0",
|
|
56
56
|
"memfs": "^4.13.0"
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=18.0.0"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "f5d7c20e7aec008c06db8d5e289c8cb1e3467005"
|
|
62
62
|
}
|