@sitecore-content-sdk/nextjs 2.0.2-canary.9 → 2.0.2

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/LICENSE.txt CHANGED
@@ -1,202 +1,202 @@
1
-
2
- Apache License
3
- Version 2.0, January 2004
4
- http://www.apache.org/licenses/
5
-
6
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
-
8
- 1. Definitions.
9
-
10
- "License" shall mean the terms and conditions for use, reproduction,
11
- and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by
14
- the copyright owner that is granting the License.
15
-
16
- "Legal Entity" shall mean the union of the acting entity and all
17
- other entities that control, are controlled by, or are under common
18
- control with that entity. For the purposes of this definition,
19
- "control" means (i) the power, direct or indirect, to cause the
20
- direction or management of such entity, whether by contract or
21
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
- outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
- "You" (or "Your") shall mean an individual or Legal Entity
25
- exercising permissions granted by this License.
26
-
27
- "Source" form shall mean the preferred form for making modifications,
28
- including but not limited to software source code, documentation
29
- source, and configuration files.
30
-
31
- "Object" form shall mean any form resulting from mechanical
32
- transformation or translation of a Source form, including but
33
- not limited to compiled object code, generated documentation,
34
- and conversions to other media types.
35
-
36
- "Work" shall mean the work of authorship, whether in Source or
37
- Object form, made available under the License, as indicated by a
38
- copyright notice that is included in or attached to the work
39
- (an example is provided in the Appendix below).
40
-
41
- "Derivative Works" shall mean any work, whether in Source or Object
42
- form, that is based on (or derived from) the Work and for which the
43
- editorial revisions, annotations, elaborations, or other modifications
44
- represent, as a whole, an original work of authorship. For the purposes
45
- of this License, Derivative Works shall not include works that remain
46
- separable from, or merely link (or bind by name) to the interfaces of,
47
- the Work and Derivative Works thereof.
48
-
49
- "Contribution" shall mean any work of authorship, including
50
- the original version of the Work and any modifications or additions
51
- to that Work or Derivative Works thereof, that is intentionally
52
- submitted to Licensor for inclusion in the Work by the copyright owner
53
- or by an individual or Legal Entity authorized to submit on behalf of
54
- the copyright owner. For the purposes of this definition, "submitted"
55
- means any form of electronic, verbal, or written communication sent
56
- to the Licensor or its representatives, including but not limited to
57
- communication on electronic mailing lists, source code control systems,
58
- and issue tracking systems that are managed by, or on behalf of, the
59
- Licensor for the purpose of discussing and improving the Work, but
60
- excluding communication that is conspicuously marked or otherwise
61
- designated in writing by the copyright owner as "Not a Contribution."
62
-
63
- "Contributor" shall mean Licensor and any individual or Legal Entity
64
- on behalf of whom a Contribution has been received by Licensor and
65
- subsequently incorporated within the Work.
66
-
67
- 2. Grant of Copyright License. Subject to the terms and conditions of
68
- this License, each Contributor hereby grants to You a perpetual,
69
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
- copyright license to reproduce, prepare Derivative Works of,
71
- publicly display, publicly perform, sublicense, and distribute the
72
- Work and such Derivative Works in Source or Object form.
73
-
74
- 3. Grant of Patent License. Subject to the terms and conditions of
75
- this License, each Contributor hereby grants to You a perpetual,
76
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
- (except as stated in this section) patent license to make, have made,
78
- use, offer to sell, sell, import, and otherwise transfer the Work,
79
- where such license applies only to those patent claims licensable
80
- by such Contributor that are necessarily infringed by their
81
- Contribution(s) alone or by combination of their Contribution(s)
82
- with the Work to which such Contribution(s) was submitted. If You
83
- institute patent litigation against any entity (including a
84
- cross-claim or counterclaim in a lawsuit) alleging that the Work
85
- or a Contribution incorporated within the Work constitutes direct
86
- or contributory patent infringement, then any patent licenses
87
- granted to You under this License for that Work shall terminate
88
- as of the date such litigation is filed.
89
-
90
- 4. Redistribution. You may reproduce and distribute copies of the
91
- Work or Derivative Works thereof in any medium, with or without
92
- modifications, and in Source or Object form, provided that You
93
- meet the following conditions:
94
-
95
- (a) You must give any other recipients of the Work or
96
- Derivative Works a copy of this License; and
97
-
98
- (b) You must cause any modified files to carry prominent notices
99
- stating that You changed the files; and
100
-
101
- (c) You must retain, in the Source form of any Derivative Works
102
- that You distribute, all copyright, patent, trademark, and
103
- attribution notices from the Source form of the Work,
104
- excluding those notices that do not pertain to any part of
105
- the Derivative Works; and
106
-
107
- (d) If the Work includes a "NOTICE" text file as part of its
108
- distribution, then any Derivative Works that You distribute must
109
- include a readable copy of the attribution notices contained
110
- within such NOTICE file, excluding those notices that do not
111
- pertain to any part of the Derivative Works, in at least one
112
- of the following places: within a NOTICE text file distributed
113
- as part of the Derivative Works; within the Source form or
114
- documentation, if provided along with the Derivative Works; or,
115
- within a display generated by the Derivative Works, if and
116
- wherever such third-party notices normally appear. The contents
117
- of the NOTICE file are for informational purposes only and
118
- do not modify the License. You may add Your own attribution
119
- notices within Derivative Works that You distribute, alongside
120
- or as an addendum to the NOTICE text from the Work, provided
121
- that such additional attribution notices cannot be construed
122
- as modifying the License.
123
-
124
- You may add Your own copyright statement to Your modifications and
125
- may provide additional or different license terms and conditions
126
- for use, reproduction, or distribution of Your modifications, or
127
- for any such Derivative Works as a whole, provided Your use,
128
- reproduction, and distribution of the Work otherwise complies with
129
- the conditions stated in this License.
130
-
131
- 5. Submission of Contributions. Unless You explicitly state otherwise,
132
- any Contribution intentionally submitted for inclusion in the Work
133
- by You to the Licensor shall be under the terms and conditions of
134
- this License, without any additional terms or conditions.
135
- Notwithstanding the above, nothing herein shall supersede or modify
136
- the terms of any separate license agreement you may have executed
137
- with Licensor regarding such Contributions.
138
-
139
- 6. Trademarks. This License does not grant permission to use the trade
140
- names, trademarks, service marks, or product names of the Licensor,
141
- except as required for reasonable and customary use in describing the
142
- origin of the Work and reproducing the content of the NOTICE file.
143
-
144
- 7. Disclaimer of Warranty. Unless required by applicable law or
145
- agreed to in writing, Licensor provides the Work (and each
146
- Contributor provides its Contributions) on an "AS IS" BASIS,
147
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
- implied, including, without limitation, any warranties or conditions
149
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
- PARTICULAR PURPOSE. You are solely responsible for determining the
151
- appropriateness of using or redistributing the Work and assume any
152
- risks associated with Your exercise of permissions under this License.
153
-
154
- 8. Limitation of Liability. In no event and under no legal theory,
155
- whether in tort (including negligence), contract, or otherwise,
156
- unless required by applicable law (such as deliberate and grossly
157
- negligent acts) or agreed to in writing, shall any Contributor be
158
- liable to You for damages, including any direct, indirect, special,
159
- incidental, or consequential damages of any character arising as a
160
- result of this License or out of the use or inability to use the
161
- Work (including but not limited to damages for loss of goodwill,
162
- work stoppage, computer failure or malfunction, or any and all
163
- other commercial damages or losses), even if such Contributor
164
- has been advised of the possibility of such damages.
165
-
166
- 9. Accepting Warranty or Additional Liability. While redistributing
167
- the Work or Derivative Works thereof, You may choose to offer,
168
- and charge a fee for, acceptance of support, warranty, indemnity,
169
- or other liability obligations and/or rights consistent with this
170
- License. However, in accepting such obligations, You may act only
171
- on Your own behalf and on Your sole responsibility, not on behalf
172
- of any other Contributor, and only if You agree to indemnify,
173
- defend, and hold each Contributor harmless for any liability
174
- incurred by, or claims asserted against, such Contributor by reason
175
- of your accepting any such warranty or additional liability.
176
-
177
- END OF TERMS AND CONDITIONS
178
-
179
- APPENDIX: How to apply the Apache License to your work.
180
-
181
- To apply the Apache License to your work, attach the following
182
- boilerplate notice, with the fields enclosed by brackets "[]"
183
- replaced with your own identifying information. (Don't include
184
- the brackets!) The text should be enclosed in the appropriate
185
- comment syntax for the file format. We also recommend that a
186
- file or class name and description of purpose be included on the
187
- same "printed page" as the copyright notice for easier
188
- identification within third-party archives.
189
-
190
- Copyright [yyyy] [name of copyright owner]
191
-
192
- Licensed under the Apache License, Version 2.0 (the "License");
193
- you may not use this file except in compliance with the License.
194
- You may obtain a copy of the License at
195
-
196
- http://www.apache.org/licenses/LICENSE-2.0
197
-
198
- Unless required by applicable law or agreed to in writing, software
199
- distributed under the License is distributed on an "AS IS" BASIS,
200
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
- See the License for the specific language governing permissions and
202
- limitations under the License.
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -52,7 +52,6 @@ exports.Link = void 0;
52
52
  const react_1 = __importStar(require("react"));
53
53
  const link_1 = __importDefault(require("next/link"));
54
54
  const react_2 = require("@sitecore-content-sdk/react");
55
- const router_1 = require("next/compat/router");
56
55
  /**
57
56
  * The list of NextLink props to be supported by the Link component.
58
57
  */
@@ -74,7 +73,6 @@ const FILE_EXTENSION_MATCHER = /^\/.*\.\w+$/;
74
73
  * @public
75
74
  */
76
75
  exports.Link = (0, react_1.forwardRef)((props, ref) => {
77
- const pageRouter = (0, router_1.useRouter)();
78
76
  const { field, editable = true, children, internalLinkMatcher = /^\//g, showLinkTextWithChildrenPresent } = props, rest = __rest(props, ["field", "editable", "children", "internalLinkMatcher", "showLinkTextWithChildrenPresent"]);
79
77
  if (!field || (!field.value && !field.href && !field.metadata)) {
80
78
  return null;
@@ -89,13 +87,10 @@ exports.Link = (0, react_1.forwardRef)((props, ref) => {
89
87
  const isFileUrl = FILE_EXTENSION_MATCHER.test(href);
90
88
  // determine if a link is a route or not. File extensions are not routes and should not be pre-fetched.
91
89
  if (isMatching && !isFileUrl) {
92
- return (react_1.default.createElement(link_1.default, Object.assign({ href: { pathname: href, query: querystring, hash: anchor }, key: "link", title: value.title, target: value.target, className: value.class }, rest, {
93
- // locale prop is supported only in Pages Router
94
- locale: pageRouter ? false : undefined, ref: ref }, (process.env.TEST
90
+ return (react_1.default.createElement(link_1.default, Object.assign({ href: { pathname: href, query: querystring, hash: anchor }, key: "link", title: value.title, target: value.target, className: value.class }, rest, { locale: false, ref: ref }, (process.env.TEST
95
91
  ? {
96
92
  'data-nextjs-link': true,
97
93
  'data-nextjs-prefetch': props.prefetch,
98
- 'data-nextjs-locale': pageRouter ? false : undefined,
99
94
  }
100
95
  : {})),
101
96
  text,
@@ -3,7 +3,7 @@ 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
- exports.debug = exports.REDIRECT_TYPE_SERVER_TRANSFER = exports.REDIRECT_TYPE_302 = exports.REDIRECT_TYPE_301 = exports.RedirectsService = exports.BotTrackingProxy = exports.PersonalizeService = exports.LocaleProxy = exports.AppRouterMultisiteProxy = exports.MultisiteProxy = exports.PersonalizeProxy = exports.RedirectsProxy = exports.defineProxy = exports.ProxyHandler = exports.ProxyBase = void 0;
6
+ exports.debug = exports.REDIRECT_TYPE_SERVER_TRANSFER = exports.REDIRECT_TYPE_302 = exports.REDIRECT_TYPE_301 = exports.RedirectsService = exports.PersonalizeService = exports.LocaleProxy = exports.AppRouterMultisiteProxy = exports.MultisiteProxy = exports.PersonalizeProxy = exports.RedirectsProxy = exports.defineProxy = exports.ProxyHandler = exports.ProxyBase = void 0;
7
7
  var proxy_1 = require("./proxy");
8
8
  Object.defineProperty(exports, "ProxyBase", { enumerable: true, get: function () { return proxy_1.ProxyBase; } });
9
9
  Object.defineProperty(exports, "ProxyHandler", { enumerable: true, get: function () { return proxy_1.ProxyHandler; } });
@@ -20,8 +20,6 @@ var locale_proxy_1 = require("./locale-proxy");
20
20
  Object.defineProperty(exports, "LocaleProxy", { enumerable: true, get: function () { return locale_proxy_1.LocaleProxy; } });
21
21
  var personalize_1 = require("@sitecore-content-sdk/content/personalize");
22
22
  Object.defineProperty(exports, "PersonalizeService", { enumerable: true, get: function () { return personalize_1.PersonalizeService; } });
23
- var bot_tracking_proxy_1 = require("./bot-tracking-proxy");
24
- Object.defineProperty(exports, "BotTrackingProxy", { enumerable: true, get: function () { return bot_tracking_proxy_1.BotTrackingProxy; } });
25
23
  var site_1 = require("@sitecore-content-sdk/content/site");
26
24
  Object.defineProperty(exports, "RedirectsService", { enumerable: true, get: function () { return site_1.RedirectsService; } });
27
25
  Object.defineProperty(exports, "REDIRECT_TYPE_301", { enumerable: true, get: function () { return site_1.REDIRECT_TYPE_301; } });
@@ -5,14 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.PersonalizeProxy = void 0;
7
7
  const personalize_1 = require("@sitecore-content-sdk/content/personalize");
8
+ const proxy_1 = require("./proxy");
8
9
  const core_1 = require("@sitecore-content-sdk/core");
9
10
  const personalize_2 = require("@sitecore-content-sdk/personalize");
10
- const internal_1 = require("@sitecore-content-sdk/events/internal");
11
+ const debug_1 = __importDefault(require("../debug"));
11
12
  const analytics_core_1 = require("@sitecore-content-sdk/analytics-core");
12
- const personalize_3 = require("@sitecore-content-sdk/personalize");
13
13
  const analytics_adapter_1 = require("../initialization/proxy/analytics-adapter");
14
- const proxy_1 = require("./proxy");
15
- const debug_1 = __importDefault(require("../debug"));
14
+ const personalize_3 = require("@sitecore-content-sdk/personalize");
16
15
  const personalize_adapter_1 = require("../initialization/proxy/personalize-adapter");
17
16
  /**
18
17
  * Proxy / handler to support Sitecore Personalize
@@ -27,13 +26,11 @@ class PersonalizeProxy extends proxy_1.ProxyBase {
27
26
  super(config);
28
27
  this.config = config;
29
28
  this.handle = async (req, res) => {
30
- var _a, _b;
31
29
  if (!this.config.enabled) {
32
30
  debug_1.default.personalize('skipped (personalize proxy is disabled globally)');
33
31
  return res;
34
32
  }
35
33
  try {
36
- const skipForBot = (_a = this.config.skipForBot) !== null && _a !== void 0 ? _a : true;
37
34
  const pathname = req.nextUrl.pathname;
38
35
  const language = this.getLanguage(req, res);
39
36
  const hostname = this.getHostHeader(req) || this.defaultHostname;
@@ -55,10 +52,6 @@ class PersonalizeProxy extends proxy_1.ProxyBase {
55
52
  debug_1.default.personalize('skipped (%s)', res.redirected ? 'redirected' : 'preview');
56
53
  return res;
57
54
  }
58
- if (skipForBot && ((_b = req.cookies.get(internal_1.BOT_DETECTION_COOKIE)) === null || _b === void 0 ? void 0 : _b.value)) {
59
- debug_1.default.personalize('skipped (bot request)');
60
- return res;
61
- }
62
55
  const site = this.getSite(req, res);
63
56
  // Get personalization info from Experience Edge
64
57
  // personalizeService is guaranteed to be non-null here because disabled() check passed
@@ -17,37 +17,6 @@ exports.LOCALE_HEADER_NAME = 'x-sc-locale';
17
17
  class ProxyHandler {
18
18
  }
19
19
  exports.ProxyHandler = ProxyHandler;
20
- /**
21
- * Hostname from a `Host` or `x-forwarded-host` value, without port.
22
- * - `[::1]:3000` → `::1`
23
- * - `127.0.0.1:3000` → `127.0.0.1`
24
- * - `example.com:443` → `example.com`
25
- * - `::1` → `::1` (does not treat `:1` as a port)
26
- * @param {string} host - Raw header value
27
- */
28
- function getHostnameFromHostHeader(host) {
29
- const trimmed = host.trim();
30
- // Bracketed IPv6: "[...]:port" or "[...]"
31
- if (trimmed.startsWith('[')) {
32
- const end = trimmed.indexOf(']');
33
- if (end !== -1) {
34
- return trimmed.slice(1, end).toLowerCase();
35
- }
36
- }
37
- // Unbracketed IPv6 (e.g. ::1, 2001:db8::1) — never strip on last ":digits"
38
- if (trimmed.includes('::')) {
39
- return trimmed.toLowerCase();
40
- }
41
- // IPv4 or DNS name with ":port" (port = decimal digits only)
42
- const lastColon = trimmed.lastIndexOf(':');
43
- if (lastColon > 0) {
44
- const after = trimmed.slice(lastColon + 1);
45
- if (/^\d+$/.test(after)) {
46
- return trimmed.slice(0, lastColon).toLowerCase();
47
- }
48
- }
49
- return trimmed.toLowerCase();
50
- }
51
20
  /**
52
21
  * Base proxy class with common methods
53
22
  * @public
@@ -144,7 +113,8 @@ class ProxyBase extends ProxyHandler {
144
113
  * @param {NextRequest} req request
145
114
  */
146
115
  getHostHeader(req) {
147
- return getHostnameFromHostHeader(req.headers.get('x-forwarded-host') || req.headers.get('host') || '');
116
+ var _a;
117
+ return req.headers.get('x-forwarded-host') || ((_a = req.headers.get('host')) === null || _a === void 0 ? void 0 : _a.split(':')[0]);
148
118
  }
149
119
  /**
150
120
  * Get site information. If site name is stored in cookie, use it, otherwise resolve by hostname
@@ -13,7 +13,6 @@ var __rest = (this && this.__rest) || function (s, e) {
13
13
  import React, { forwardRef } from 'react';
14
14
  import NextLink from 'next/link';
15
15
  import { Link as ReactLink, } from '@sitecore-content-sdk/react';
16
- import { useRouter as usePageRouter } from 'next/compat/router';
17
16
  /**
18
17
  * The list of NextLink props to be supported by the Link component.
19
18
  */
@@ -35,7 +34,6 @@ const FILE_EXTENSION_MATCHER = /^\/.*\.\w+$/;
35
34
  * @public
36
35
  */
37
36
  export const Link = forwardRef((props, ref) => {
38
- const pageRouter = usePageRouter();
39
37
  const { field, editable = true, children, internalLinkMatcher = /^\//g, showLinkTextWithChildrenPresent } = props, rest = __rest(props, ["field", "editable", "children", "internalLinkMatcher", "showLinkTextWithChildrenPresent"]);
40
38
  if (!field || (!field.value && !field.href && !field.metadata)) {
41
39
  return null;
@@ -50,13 +48,10 @@ export const Link = forwardRef((props, ref) => {
50
48
  const isFileUrl = FILE_EXTENSION_MATCHER.test(href);
51
49
  // determine if a link is a route or not. File extensions are not routes and should not be pre-fetched.
52
50
  if (isMatching && !isFileUrl) {
53
- return (React.createElement(NextLink, Object.assign({ href: { pathname: href, query: querystring, hash: anchor }, key: "link", title: value.title, target: value.target, className: value.class }, rest, {
54
- // locale prop is supported only in Pages Router
55
- locale: pageRouter ? false : undefined, ref: ref }, (process.env.TEST
51
+ return (React.createElement(NextLink, Object.assign({ href: { pathname: href, query: querystring, hash: anchor }, key: "link", title: value.title, target: value.target, className: value.class }, rest, { locale: false, ref: ref }, (process.env.TEST
56
52
  ? {
57
53
  'data-nextjs-link': true,
58
54
  'data-nextjs-prefetch': props.prefetch,
59
- 'data-nextjs-locale': pageRouter ? false : undefined,
60
55
  }
61
56
  : {})),
62
57
  text,
@@ -5,6 +5,5 @@ export { MultisiteProxy } from './multisite-proxy';
5
5
  export { AppRouterMultisiteProxy } from './app-router-multisite-proxy';
6
6
  export { LocaleProxy } from './locale-proxy';
7
7
  export { PersonalizeService, } from '@sitecore-content-sdk/content/personalize';
8
- export { BotTrackingProxy } from './bot-tracking-proxy';
9
8
  export { RedirectsService, REDIRECT_TYPE_301, REDIRECT_TYPE_302, REDIRECT_TYPE_SERVER_TRANSFER, } from '@sitecore-content-sdk/content/site';
10
9
  export { default as debug } from '../debug';
@@ -1,12 +1,11 @@
1
1
  import { PersonalizeService, getPersonalizedRewrite, CdpHelper, DEFAULT_VARIANT, } from '@sitecore-content-sdk/content/personalize';
2
+ import { ProxyBase, REWRITE_HEADER_NAME } from './proxy';
2
3
  import { initContentSdk } from '@sitecore-content-sdk/core';
3
4
  import { personalize } from '@sitecore-content-sdk/personalize';
4
- import { BOT_DETECTION_COOKIE } from '@sitecore-content-sdk/events/internal';
5
+ import debug from '../debug';
5
6
  import { analyticsPlugin } from '@sitecore-content-sdk/analytics-core';
6
- import { personalizeServerPlugin } from '@sitecore-content-sdk/personalize';
7
7
  import { analyticsProxyAdapter } from '../initialization/proxy/analytics-adapter';
8
- import { ProxyBase, REWRITE_HEADER_NAME } from './proxy';
9
- import debug from '../debug';
8
+ import { personalizeServerPlugin } from '@sitecore-content-sdk/personalize';
10
9
  import { personalizeProxyAdapter } from '../initialization/proxy/personalize-adapter';
11
10
  /**
12
11
  * Proxy / handler to support Sitecore Personalize
@@ -21,13 +20,11 @@ export class PersonalizeProxy extends ProxyBase {
21
20
  super(config);
22
21
  this.config = config;
23
22
  this.handle = async (req, res) => {
24
- var _a, _b;
25
23
  if (!this.config.enabled) {
26
24
  debug.personalize('skipped (personalize proxy is disabled globally)');
27
25
  return res;
28
26
  }
29
27
  try {
30
- const skipForBot = (_a = this.config.skipForBot) !== null && _a !== void 0 ? _a : true;
31
28
  const pathname = req.nextUrl.pathname;
32
29
  const language = this.getLanguage(req, res);
33
30
  const hostname = this.getHostHeader(req) || this.defaultHostname;
@@ -49,10 +46,6 @@ export class PersonalizeProxy extends ProxyBase {
49
46
  debug.personalize('skipped (%s)', res.redirected ? 'redirected' : 'preview');
50
47
  return res;
51
48
  }
52
- if (skipForBot && ((_b = req.cookies.get(BOT_DETECTION_COOKIE)) === null || _b === void 0 ? void 0 : _b.value)) {
53
- debug.personalize('skipped (bot request)');
54
- return res;
55
- }
56
49
  const site = this.getSite(req, res);
57
50
  // Get personalization info from Experience Edge
58
51
  // personalizeService is guaranteed to be non-null here because disabled() check passed
@@ -10,37 +10,6 @@ export const LOCALE_HEADER_NAME = 'x-sc-locale';
10
10
  */
11
11
  export class ProxyHandler {
12
12
  }
13
- /**
14
- * Hostname from a `Host` or `x-forwarded-host` value, without port.
15
- * - `[::1]:3000` → `::1`
16
- * - `127.0.0.1:3000` → `127.0.0.1`
17
- * - `example.com:443` → `example.com`
18
- * - `::1` → `::1` (does not treat `:1` as a port)
19
- * @param {string} host - Raw header value
20
- */
21
- function getHostnameFromHostHeader(host) {
22
- const trimmed = host.trim();
23
- // Bracketed IPv6: "[...]:port" or "[...]"
24
- if (trimmed.startsWith('[')) {
25
- const end = trimmed.indexOf(']');
26
- if (end !== -1) {
27
- return trimmed.slice(1, end).toLowerCase();
28
- }
29
- }
30
- // Unbracketed IPv6 (e.g. ::1, 2001:db8::1) — never strip on last ":digits"
31
- if (trimmed.includes('::')) {
32
- return trimmed.toLowerCase();
33
- }
34
- // IPv4 or DNS name with ":port" (port = decimal digits only)
35
- const lastColon = trimmed.lastIndexOf(':');
36
- if (lastColon > 0) {
37
- const after = trimmed.slice(lastColon + 1);
38
- if (/^\d+$/.test(after)) {
39
- return trimmed.slice(0, lastColon).toLowerCase();
40
- }
41
- }
42
- return trimmed.toLowerCase();
43
- }
44
13
  /**
45
14
  * Base proxy class with common methods
46
15
  * @public
@@ -137,7 +106,8 @@ export class ProxyBase extends ProxyHandler {
137
106
  * @param {NextRequest} req request
138
107
  */
139
108
  getHostHeader(req) {
140
- return getHostnameFromHostHeader(req.headers.get('x-forwarded-host') || req.headers.get('host') || '');
109
+ var _a;
110
+ return req.headers.get('x-forwarded-host') || ((_a = req.headers.get('host')) === null || _a === void 0 ? void 0 : _a.split(':')[0]);
141
111
  }
142
112
  /**
143
113
  * Get site information. If site name is stored in cookie, use it, otherwise resolve by hostname
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-content-sdk/nextjs",
3
- "version": "2.0.2-canary.9",
3
+ "version": "2.0.2",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -32,8 +32,8 @@
32
32
  "url": "https://github.com/sitecore/content-sdk/issues"
33
33
  },
34
34
  "devDependencies": {
35
- "@sitecore-content-sdk/analytics-core": "2.0.2-canary.9",
36
- "@sitecore-content-sdk/personalize": "2.0.2-canary.9",
35
+ "@sitecore-content-sdk/analytics-core": "^2.0.2",
36
+ "@sitecore-content-sdk/personalize": "^2.0.2",
37
37
  "@stylistic/eslint-plugin": "^5.2.2",
38
38
  "@testing-library/dom": "^10.4.0",
39
39
  "@testing-library/react": "^16.3.0",
@@ -63,7 +63,7 @@
63
63
  "glob": "^11.0.2",
64
64
  "jsdom": "^26.1.0",
65
65
  "mocha": "^11.2.2",
66
- "next": "^16.2.0",
66
+ "next": "^16.1.1",
67
67
  "nock": "14.0.0-beta.7",
68
68
  "nyc": "^17.1.0",
69
69
  "prettier": "^2.8.0",
@@ -76,10 +76,10 @@
76
76
  "typescript": "~5.8.3"
77
77
  },
78
78
  "peerDependencies": {
79
- "@sitecore-content-sdk/analytics-core": "^2.0.2-canary.2",
80
- "@sitecore-content-sdk/events": "^2.0.2-canary.2",
81
- "@sitecore-content-sdk/personalize": "^2.0.2-canary.2",
82
- "next": "^16.2.0",
79
+ "@sitecore-content-sdk/analytics-core": "^2.0.2",
80
+ "@sitecore-content-sdk/events": "^2.0.2",
81
+ "@sitecore-content-sdk/personalize": "^2.0.2",
82
+ "next": "^16.1.1",
83
83
  "react": "^19.2.1",
84
84
  "react-dom": "^19.2.1",
85
85
  "typescript": "^5.4.0"
@@ -91,10 +91,9 @@
91
91
  },
92
92
  "dependencies": {
93
93
  "@babel/parser": "^7.27.2",
94
- "@sitecore-content-sdk/content": "2.0.2-canary.9",
95
- "@sitecore-content-sdk/core": "2.0.2-canary.9",
96
- "@sitecore-content-sdk/events": "2.0.2-canary.9",
97
- "@sitecore-content-sdk/react": "2.0.2-canary.9",
94
+ "@sitecore-content-sdk/content": "^2.0.2",
95
+ "@sitecore-content-sdk/core": "^2.0.2",
96
+ "@sitecore-content-sdk/react": "^2.0.2",
98
97
  "recast": "^0.23.11",
99
98
  "regex-parser": "^2.3.1",
100
99
  "sync-disk-cache": "^2.1.0"
@@ -178,7 +177,7 @@
178
177
  },
179
178
  "description": "",
180
179
  "types": "types/index.d.ts",
181
- "gitHead": "e5dbadae727a0077c3fa467769bd9015c3e4ba94",
180
+ "gitHead": "b76e6169344e65141a96238321b74ef92202b436",
182
181
  "files": [
183
182
  "dist",
184
183
  "types",
@@ -1 +1 @@
1
- {"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/components/Link.tsx"],"names":[],"mappings":"AACA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAC/C,OAAiB,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAIL,SAAS,IAAI,cAAc,EAC5B,MAAM,6BAA6B,CAAC;AAGrC;;GAEG;AACH,QAAA,MAAM,sBAAsB,uFAQlB,CAAC;AAEX;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG;IACvC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAOjE;;;GAGG;AACH,eAAO,MAAM,IAAI,kGAqEhB,CAAC"}
1
+ {"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/components/Link.tsx"],"names":[],"mappings":"AACA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAC/C,OAAiB,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAIL,SAAS,IAAI,cAAc,EAC5B,MAAM,6BAA6B,CAAC;AAErC;;GAEG;AACH,QAAA,MAAM,sBAAsB,uFAQlB,CAAC;AAEX;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG;IACvC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAOjE;;;GAGG;AACH,eAAO,MAAM,IAAI,kGAiEhB,CAAC"}
@@ -5,7 +5,6 @@ export { MultisiteProxy, MultisiteProxyConfig } from './multisite-proxy';
5
5
  export { AppRouterMultisiteProxy } from './app-router-multisite-proxy';
6
6
  export { LocaleProxy, LocaleProxyConfig } from './locale-proxy';
7
7
  export { PersonalizeService, PersonalizeServiceConfig, } from '@sitecore-content-sdk/content/personalize';
8
- export { BotTrackingProxy, BotTrackingProxyConfig } from './bot-tracking-proxy';
9
8
  export { RedirectsService, RedirectsServiceConfig, REDIRECT_TYPE_301, REDIRECT_TYPE_302, REDIRECT_TYPE_SERVER_TRANSFER, RedirectInfo, } from '@sitecore-content-sdk/content/site';
10
9
  export { default as debug } from '../debug';
11
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/proxy/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,6BAA6B,EAC7B,YAAY,GACb,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/proxy/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,6BAA6B,EAC7B,YAAY,GACb,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,UAAU,CAAC"}
@@ -19,11 +19,6 @@ export type PersonalizeProxyConfig = ProxyBaseConfig & SitecoreConfig['api']['ed
19
19
  personalizeService?: PersonalizeService;
20
20
  getExtraUtmParams?: (req: NextRequest) => Partial<ExperienceParams['utm']>;
21
21
  extractGeoDataCb?: (req?: NextRequest) => Promise<PersonalizeGeoData> | PersonalizeGeoData;
22
- /**
23
- * Skip personalize proxy for bot requests marked by the bot tracking proxy.
24
- * Default is `true`.
25
- */
26
- skipForBot?: boolean;
27
22
  };
28
23
  /**
29
24
  * Object model of Experience Context data
@@ -1 +1 @@
1
- {"version":3,"file":"personalize-proxy.d.ts","sourceRoot":"","sources":["../../src/proxy/personalize-proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EACL,kBAAkB,EAElB,eAAe,EAGhB,MAAM,2CAA2C,CAAC;AAOnD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAuB,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAI3C;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,eAAe,GAClD,cAAc,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAC7B,cAAc,CAAC,aAAa,CAAC,GAAG;IAC9B,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,gBAAgB,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;IAC3F;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,Q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AE;QACD,MAAM,EAAE,gBAAgB,CAAC;QACzB,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,GAAG,CAAC,EAAE,kBAAkB,CAAC;KAC1B;mBAec,MAAM;;IAIrB;;;;;OAKG;IACH,SAAS,CAAC,wBAAwB,CAChC,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,MAAM,GACf,oBAAoB,EAAE;CA8C1B"}
@@ -97,7 +97,7 @@ export declare abstract class ProxyBase extends ProxyHandler {
97
97
  * Extract 'host' header
98
98
  * @param {NextRequest} req request
99
99
  */
100
- protected getHostHeader(req: NextRequest): string;
100
+ protected getHostHeader(req: NextRequest): string | undefined;
101
101
  /**
102
102
  * Get site information. If site name is stored in cookie, use it, otherwise resolve by hostname
103
103
  * - If site can't be resolved by site name cookie use default site info based on provided parameters
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/proxy/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACtF,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAEL,oBAAoB,EACrB,MAAM,sCAAsC,CAAC;AAI9C,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAClD,eAAO,MAAM,kBAAkB,gBAAgB,CAAC;AAEhD;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;OAIG;IACH,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,KAAK,OAAO,CAAC;IACxD;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,eAA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 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.BotTrackingProxy = void 0;
7
- const core_1 = require("@sitecore-content-sdk/core");
8
- const analytics_core_1 = require("@sitecore-content-sdk/analytics-core");
9
- const events_1 = require("@sitecore-content-sdk/events");
10
- const internal_1 = require("@sitecore-content-sdk/events/internal");
11
- const proxy_1 = require("./proxy");
12
- const debug_1 = __importDefault(require("../debug"));
13
- const analytics_adapter_1 = require("../initialization/proxy/analytics-adapter");
14
- /**
15
- * Next.js proxy that runs bot detection once per request and sets the bot cookie.
16
- * Run first in the proxy chain to ensure that the bot cookie is set before other proxies run.
17
- * @public
18
- */
19
- class BotTrackingProxy extends proxy_1.ProxyBase {
20
- constructor(config) {
21
- super(config);
22
- this.config = config;
23
- this.handle = async (req, res) => {
24
- try {
25
- const isDisabled = (this.config.skip && this.config.skip(req, res)) || false;
26
- debug_1.default.common('bot tracking proxy start: %o', {
27
- pathname: req.nextUrl.pathname,
28
- headers: this.extractDebugHeaders(req.headers),
29
- });
30
- if (isDisabled) {
31
- debug_1.default.common('bot tracking proxy skipped (disabled)');
32
- return res;
33
- }
34
- if (this.isPreview(req)) {
35
- debug_1.default.common('bot tracking proxy skipped (preview)');
36
- return res;
37
- }
38
- if (this.shouldSkipForLocalEnvironment(req)) {
39
- debug_1.default.common('bot tracking proxy skipped (local environment)');
40
- return res;
41
- }
42
- if (!(0, internal_1.isBot)(req.headers.get('user-agent'))) {
43
- debug_1.default.common('bot tracking proxy skipped (not a bot)');
44
- return res;
45
- }
46
- if (this.isPrefetch(req)) {
47
- debug_1.default.common('bot tracking proxy skipped (prefetch)');
48
- return res;
49
- }
50
- const site = this.getSite(req, res);
51
- const botTracking = async () => {
52
- await (0, core_1.initContentSdk)({
53
- config: {
54
- contextId: this.config.contextId,
55
- edgeUrl: this.config.edgeUrl,
56
- siteName: site.name,
57
- },
58
- plugins: [
59
- (0, analytics_core_1.analyticsPlugin)({
60
- options: {
61
- enableCookie: false,
62
- },
63
- adapter: (0, analytics_adapter_1.analyticsProxyAdapter)(req, res),
64
- }),
65
- (0, events_1.eventsPlugin)(),
66
- ],
67
- });
68
- await (0, events_1.botPageView)();
69
- };
70
- res.cookies.set(internal_1.BOT_DETECTION_COOKIE, '1', {
71
- secure: true,
72
- sameSite: 'lax',
73
- path: '/',
74
- });
75
- if (this.config.fetchEvent) {
76
- this.config.fetchEvent.waitUntil(botTracking());
77
- }
78
- else {
79
- await botTracking();
80
- }
81
- debug_1.default.common('bot tracking proxy end: %o', {
82
- pathname: req.nextUrl.pathname,
83
- cookies: res.cookies,
84
- });
85
- return res;
86
- }
87
- catch (error) {
88
- debug_1.default.common('bot tracking proxy error: %o', error);
89
- return res;
90
- }
91
- };
92
- }
93
- /**
94
- * @param {NextRequest} req - Incoming request
95
- * @returns True when bot tracking should be skipped for a local / dev environment.
96
- * @internal
97
- */
98
- shouldSkipForLocalEnvironment(req) {
99
- // Allow bot tracking in local environment for development purposes
100
- if (process.env.SITECORE_ENABLE_BOT_TRACKING === 'true') {
101
- return false;
102
- }
103
- if (process.env.NODE_ENV === 'development') {
104
- return true;
105
- }
106
- const hostName = (this.getHostHeader(req) ||
107
- req.nextUrl.hostname ||
108
- this.defaultHostname ||
109
- '').toLowerCase();
110
- return (hostName === 'localhost' ||
111
- hostName === '127.0.0.1' ||
112
- hostName === '::1' ||
113
- hostName === '[::1]');
114
- }
115
- }
116
- exports.BotTrackingProxy = BotTrackingProxy;
@@ -1,109 +0,0 @@
1
- import { initContentSdk } from '@sitecore-content-sdk/core';
2
- import { analyticsPlugin } from '@sitecore-content-sdk/analytics-core';
3
- import { eventsPlugin, botPageView, } from '@sitecore-content-sdk/events';
4
- import { isBot, BOT_DETECTION_COOKIE } from '@sitecore-content-sdk/events/internal';
5
- import { ProxyBase } from './proxy';
6
- import debug from '../debug';
7
- import { analyticsProxyAdapter } from '../initialization/proxy/analytics-adapter';
8
- /**
9
- * Next.js proxy that runs bot detection once per request and sets the bot cookie.
10
- * Run first in the proxy chain to ensure that the bot cookie is set before other proxies run.
11
- * @public
12
- */
13
- export class BotTrackingProxy extends ProxyBase {
14
- constructor(config) {
15
- super(config);
16
- this.config = config;
17
- this.handle = async (req, res) => {
18
- try {
19
- const isDisabled = (this.config.skip && this.config.skip(req, res)) || false;
20
- debug.common('bot tracking proxy start: %o', {
21
- pathname: req.nextUrl.pathname,
22
- headers: this.extractDebugHeaders(req.headers),
23
- });
24
- if (isDisabled) {
25
- debug.common('bot tracking proxy skipped (disabled)');
26
- return res;
27
- }
28
- if (this.isPreview(req)) {
29
- debug.common('bot tracking proxy skipped (preview)');
30
- return res;
31
- }
32
- if (this.shouldSkipForLocalEnvironment(req)) {
33
- debug.common('bot tracking proxy skipped (local environment)');
34
- return res;
35
- }
36
- if (!isBot(req.headers.get('user-agent'))) {
37
- debug.common('bot tracking proxy skipped (not a bot)');
38
- return res;
39
- }
40
- if (this.isPrefetch(req)) {
41
- debug.common('bot tracking proxy skipped (prefetch)');
42
- return res;
43
- }
44
- const site = this.getSite(req, res);
45
- const botTracking = async () => {
46
- await initContentSdk({
47
- config: {
48
- contextId: this.config.contextId,
49
- edgeUrl: this.config.edgeUrl,
50
- siteName: site.name,
51
- },
52
- plugins: [
53
- analyticsPlugin({
54
- options: {
55
- enableCookie: false,
56
- },
57
- adapter: analyticsProxyAdapter(req, res),
58
- }),
59
- eventsPlugin(),
60
- ],
61
- });
62
- await botPageView();
63
- };
64
- res.cookies.set(BOT_DETECTION_COOKIE, '1', {
65
- secure: true,
66
- sameSite: 'lax',
67
- path: '/',
68
- });
69
- if (this.config.fetchEvent) {
70
- this.config.fetchEvent.waitUntil(botTracking());
71
- }
72
- else {
73
- await botTracking();
74
- }
75
- debug.common('bot tracking proxy end: %o', {
76
- pathname: req.nextUrl.pathname,
77
- cookies: res.cookies,
78
- });
79
- return res;
80
- }
81
- catch (error) {
82
- debug.common('bot tracking proxy error: %o', error);
83
- return res;
84
- }
85
- };
86
- }
87
- /**
88
- * @param {NextRequest} req - Incoming request
89
- * @returns True when bot tracking should be skipped for a local / dev environment.
90
- * @internal
91
- */
92
- shouldSkipForLocalEnvironment(req) {
93
- // Allow bot tracking in local environment for development purposes
94
- if (process.env.SITECORE_ENABLE_BOT_TRACKING === 'true') {
95
- return false;
96
- }
97
- if (process.env.NODE_ENV === 'development') {
98
- return true;
99
- }
100
- const hostName = (this.getHostHeader(req) ||
101
- req.nextUrl.hostname ||
102
- this.defaultHostname ||
103
- '').toLowerCase();
104
- return (hostName === 'localhost' ||
105
- hostName === '127.0.0.1' ||
106
- hostName === '::1' ||
107
- hostName === '[::1]');
108
- }
109
- }
@@ -1,33 +0,0 @@
1
- import { NextFetchEvent, NextRequest, NextResponse } from 'next/server';
2
- import { SitecoreConfig } from '@sitecore-content-sdk/content/config';
3
- import { ProxyBase, ProxyBaseConfig } from './proxy';
4
- /**
5
- * Configuration for BotTrackingProxy.
6
- * @public
7
- */
8
- export type BotTrackingProxyConfig = SitecoreConfig['api']['edge'] & Omit<ProxyBaseConfig, 'defaultLanguage'> & {
9
- /**
10
- * Fetch event to run the bot tracking in the background to not block the request.
11
- * If not provided, the bot tracking will run synchronously.
12
- * Read more about `fetchEvent` in the [Next.js documentation](https://nextjs.org/docs/app/api-reference/file-conventions/proxy#waituntil-and-nextfetchevent)
13
- * @param {NextFetchEvent} fetchEvent - Fetch event to run the bot tracking in the background.
14
- */
15
- fetchEvent?: NextFetchEvent;
16
- };
17
- /**
18
- * Next.js proxy that runs bot detection once per request and sets the bot cookie.
19
- * Run first in the proxy chain to ensure that the bot cookie is set before other proxies run.
20
- * @public
21
- */
22
- export declare class BotTrackingProxy extends ProxyBase {
23
- protected config: BotTrackingProxyConfig;
24
- constructor(config: BotTrackingProxyConfig);
25
- handle: (req: NextRequest, res: NextResponse) => Promise<NextResponse>;
26
- /**
27
- * @param {NextRequest} req - Incoming request
28
- * @returns True when bot tracking should be skipped for a local / dev environment.
29
- * @internal
30
- */
31
- protected shouldSkipForLocalEnvironment(req: NextRequest): boolean;
32
- }
33
- //# sourceMappingURL=bot-tracking-proxy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bot-tracking-proxy.d.ts","sourceRoot":"","sources":["../../src/proxy/bot-tracking-proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAOtE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAIrD;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAChE,IAAI,CAAC,eAAe,EAAE,iBAAiB,CAAC,GAAG;IACzC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B,CAAC;AAEJ;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,SAAS;IACjC,SAAS,CAAC,MAAM,EAAE,sBAAsB;gBAA9B,MAAM,EAAE,sBAAsB;IAIpD,MAAM,GAAU,KAAK,WAAW,EAAE,KAAK,YAAY,KAAG,OAAO,CAAC,YAAY,CAAC,CA+EzE;IAEF;;;;OAIG;IACH,SAAS,CAAC,6BAA6B,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO;CAwBnE"}