@agnostack/next-shopify 1.13.4-beta.6 → 1.13.4-beta.61

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/CHANGELOG.md CHANGED
@@ -1,3 +1,393 @@
1
+ ## [1.13.4-beta.61](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.60...v1.13.4-beta.61) (2023-11-29)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * wip ([76a671d](https://github.com/agnostack/next-shopify/commit/76a671d617d0ce3c5bb7ca6066c4a6d019d029ef))
7
+
8
+ ## [1.13.4-beta.60](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.59...v1.13.4-beta.60) (2023-11-29)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * wip ([b9920c9](https://github.com/agnostack/next-shopify/commit/b9920c9dfa50abb2b7e6648e3bc662da309a9666))
14
+
15
+ ## [1.13.4-beta.59](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.58...v1.13.4-beta.59) (2023-11-29)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * wip ([2381a56](https://github.com/agnostack/next-shopify/commit/2381a5641319e0b7f03e860c27e28a147872a79d))
21
+
22
+ ## [1.13.4-beta.58](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.57...v1.13.4-beta.58) (2023-11-29)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * wip ([e5962d0](https://github.com/agnostack/next-shopify/commit/e5962d07ce2a3a6212826d8c5d32bdb4a538a0ea))
28
+
29
+ ## [1.13.4-beta.57](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.56...v1.13.4-beta.57) (2023-11-29)
30
+
31
+
32
+ ### Bug Fixes
33
+
34
+ * wip ([b2545ea](https://github.com/agnostack/next-shopify/commit/b2545eabbc57a405c73d794e79a2d67d11527cc0))
35
+
36
+ ## [1.13.4-beta.56](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.55...v1.13.4-beta.56) (2023-11-29)
37
+
38
+
39
+ ### Bug Fixes
40
+
41
+ * wip ([850a990](https://github.com/agnostack/next-shopify/commit/850a99069e4dee3e98ee5de449f428d296d29a7a))
42
+
43
+ ## [1.13.4-beta.55](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.54...v1.13.4-beta.55) (2023-11-29)
44
+
45
+
46
+ ### Bug Fixes
47
+
48
+ * wip ([1ea8993](https://github.com/agnostack/next-shopify/commit/1ea8993f414ed6ee9458fb33a5a5a75b49da89d4))
49
+
50
+ ## [1.13.4-beta.54](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.53...v1.13.4-beta.54) (2023-11-29)
51
+
52
+
53
+ ### Bug Fixes
54
+
55
+ * wip ([d83485e](https://github.com/agnostack/next-shopify/commit/d83485eff342c0f21e6a6a1a2bca6391ad1be670))
56
+
57
+ ## [1.13.4-beta.53](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.52...v1.13.4-beta.53) (2023-11-29)
58
+
59
+
60
+ ### Bug Fixes
61
+
62
+ * wip ([567bc8f](https://github.com/agnostack/next-shopify/commit/567bc8f013927755e5fbe3b981cd1b5306254604))
63
+
64
+ ## [1.13.4-beta.52](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.51...v1.13.4-beta.52) (2023-11-29)
65
+
66
+
67
+ ### Bug Fixes
68
+
69
+ * wip ([2c58a8a](https://github.com/agnostack/next-shopify/commit/2c58a8af9b8c36028b5762a6a847448d1594d328))
70
+
71
+ ## [1.13.4-beta.51](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.50...v1.13.4-beta.51) (2023-11-29)
72
+
73
+
74
+ ### Bug Fixes
75
+
76
+ * wip ([8276744](https://github.com/agnostack/next-shopify/commit/8276744bc17785ce1af965d38f317d47ddd532c6))
77
+
78
+ ## [1.13.4-beta.50](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.49...v1.13.4-beta.50) (2023-11-29)
79
+
80
+
81
+ ### Bug Fixes
82
+
83
+ * wip ([a0eb335](https://github.com/agnostack/next-shopify/commit/a0eb33528a9b47d36e8e2f9958e7bafd4bf17823))
84
+
85
+ ## [1.13.4-beta.49](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.48...v1.13.4-beta.49) (2023-11-29)
86
+
87
+
88
+ ### Bug Fixes
89
+
90
+ * wip ([baef655](https://github.com/agnostack/next-shopify/commit/baef655a911b63187eaf1bf0764961ae13b02fe4))
91
+
92
+ ## [1.13.4-beta.48](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.47...v1.13.4-beta.48) (2023-11-29)
93
+
94
+
95
+ ### Bug Fixes
96
+
97
+ * wip ([3315169](https://github.com/agnostack/next-shopify/commit/3315169925362a70daa7d6c4f4897f67b00f1519))
98
+
99
+ ## [1.13.4-beta.47](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.46...v1.13.4-beta.47) (2023-11-28)
100
+
101
+
102
+ ### Bug Fixes
103
+
104
+ * wip ([dcbe873](https://github.com/agnostack/next-shopify/commit/dcbe87388d805f2ceafd16df7f3f527e8d28056c))
105
+
106
+ ## [1.13.4-beta.46](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.45...v1.13.4-beta.46) (2023-11-28)
107
+
108
+
109
+ ### Bug Fixes
110
+
111
+ * wip ([d4433f3](https://github.com/agnostack/next-shopify/commit/d4433f3615b69bfdb208f82bbb96455acd256a21))
112
+
113
+ ## [1.13.4-beta.45](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.44...v1.13.4-beta.45) (2023-11-28)
114
+
115
+
116
+ ### Bug Fixes
117
+
118
+ * wip ([c3b63f1](https://github.com/agnostack/next-shopify/commit/c3b63f10b89a3fac724ee296ce6744220aeaf74e))
119
+
120
+ ## [1.13.4-beta.44](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.43...v1.13.4-beta.44) (2023-11-28)
121
+
122
+
123
+ ### Bug Fixes
124
+
125
+ * wip ([f344e66](https://github.com/agnostack/next-shopify/commit/f344e66e357e19ae0b2bd36539338fb3c7ef716f))
126
+
127
+ ## [1.13.4-beta.43](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.42...v1.13.4-beta.43) (2023-11-28)
128
+
129
+
130
+ ### Bug Fixes
131
+
132
+ * wip ([137d947](https://github.com/agnostack/next-shopify/commit/137d947208da705d8c6159df85621535c553060c))
133
+
134
+ ## [1.13.4-beta.42](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.41...v1.13.4-beta.42) (2023-11-28)
135
+
136
+
137
+ ### Bug Fixes
138
+
139
+ * wip ([b2aa001](https://github.com/agnostack/next-shopify/commit/b2aa0013f4d98bbedbb6e9576d0342049fedee82))
140
+
141
+ ## [1.13.4-beta.41](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.40...v1.13.4-beta.41) (2023-11-28)
142
+
143
+
144
+ ### Bug Fixes
145
+
146
+ * wip ([7a5bc34](https://github.com/agnostack/next-shopify/commit/7a5bc3443e1a4b7e2ecb2961e9882f4dad5ca548))
147
+
148
+ ## [1.13.4-beta.40](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.39...v1.13.4-beta.40) (2023-11-28)
149
+
150
+
151
+ ### Bug Fixes
152
+
153
+ * wip ([b6d011f](https://github.com/agnostack/next-shopify/commit/b6d011f3d36d6d8bf5d9761bf0738054f3c7390d))
154
+
155
+ ## [1.13.4-beta.39](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.38...v1.13.4-beta.39) (2023-11-28)
156
+
157
+
158
+ ### Bug Fixes
159
+
160
+ * wip ([40ebc2d](https://github.com/agnostack/next-shopify/commit/40ebc2d8aa7163943647198d44a81b8d2c316315))
161
+
162
+ ## [1.13.4-beta.38](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.37...v1.13.4-beta.38) (2023-11-28)
163
+
164
+
165
+ ### Bug Fixes
166
+
167
+ * wip ([85e558b](https://github.com/agnostack/next-shopify/commit/85e558bcd5ba9d13e2546f4a66439016ca154e2f))
168
+
169
+ ## [1.13.4-beta.37](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.36...v1.13.4-beta.37) (2023-11-28)
170
+
171
+
172
+ ### Bug Fixes
173
+
174
+ * wip ([c5a2d49](https://github.com/agnostack/next-shopify/commit/c5a2d49fdf9488136a8ce08acbc2fea98998f0d8))
175
+
176
+ ## [1.13.4-beta.36](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.35...v1.13.4-beta.36) (2023-11-28)
177
+
178
+
179
+ ### Bug Fixes
180
+
181
+ * wip ([d263615](https://github.com/agnostack/next-shopify/commit/d26361514e00dcbf401badf43c7690a1bde03332))
182
+
183
+ ## [1.13.4-beta.35](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.34...v1.13.4-beta.35) (2023-11-28)
184
+
185
+
186
+ ### Bug Fixes
187
+
188
+ * wip ([e10b2ab](https://github.com/agnostack/next-shopify/commit/e10b2ab5aeae548ff7e11b707cba8fee1b5dcf15))
189
+
190
+ ## [1.13.4-beta.34](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.33...v1.13.4-beta.34) (2023-11-28)
191
+
192
+
193
+ ### Bug Fixes
194
+
195
+ * wip ([6b7d57e](https://github.com/agnostack/next-shopify/commit/6b7d57ee40cda53abe88c869536f0092f98bd4dd))
196
+
197
+ ## [1.13.4-beta.33](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.32...v1.13.4-beta.33) (2023-11-28)
198
+
199
+
200
+ ### Bug Fixes
201
+
202
+ * wip ([eaea443](https://github.com/agnostack/next-shopify/commit/eaea44343cb78de25156fa6def0893ad96f0699c))
203
+
204
+ ## [1.13.4-beta.32](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.31...v1.13.4-beta.32) (2023-11-28)
205
+
206
+
207
+ ### Bug Fixes
208
+
209
+ * wip ([74082e8](https://github.com/agnostack/next-shopify/commit/74082e8e47120c534b673ed42f3459e0f7baffa0))
210
+
211
+ ## [1.13.4-beta.31](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.30...v1.13.4-beta.31) (2023-11-28)
212
+
213
+
214
+ ### Bug Fixes
215
+
216
+ * updated lock file ([03a7d39](https://github.com/agnostack/next-shopify/commit/03a7d399000d86e6ee933f7709e5410bfb1981b4))
217
+
218
+ ## [1.13.4-beta.30](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.29...v1.13.4-beta.30) (2023-11-28)
219
+
220
+
221
+ ### Bug Fixes
222
+
223
+ * updated lock file ([256e7d7](https://github.com/agnostack/next-shopify/commit/256e7d7c1f5c23e56e5fb8ae481b08b4980ab8e9))
224
+ * wip ([64dceab](https://github.com/agnostack/next-shopify/commit/64dceabfd7272c204713ef424506ec0b7cc720b6))
225
+ * wip ([b577f37](https://github.com/agnostack/next-shopify/commit/b577f377d5f2359365ae21ccb4da45a38c51dbb1))
226
+ * wip ([26109e8](https://github.com/agnostack/next-shopify/commit/26109e867cda0c3917a30093dee14bc0e6061741))
227
+ * wip ([c445db2](https://github.com/agnostack/next-shopify/commit/c445db2cd460af41de389db7137e0115681a8405))
228
+
229
+ ## [1.13.4-beta.29](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.28...v1.13.4-beta.29) (2023-11-28)
230
+
231
+
232
+ ### Bug Fixes
233
+
234
+ * wip ([58b879d](https://github.com/agnostack/next-shopify/commit/58b879d2e18291c25da4e138075bb3a4889e2e75))
235
+
236
+ ## [1.13.4-beta.28](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.27...v1.13.4-beta.28) (2023-11-28)
237
+
238
+
239
+ ### Bug Fixes
240
+
241
+ * wip ([a0a52af](https://github.com/agnostack/next-shopify/commit/a0a52af58ae125dc0ea679cc13c4d623f6367c98))
242
+
243
+ ## [1.13.4-beta.27](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.26...v1.13.4-beta.27) (2023-11-28)
244
+
245
+
246
+ ### Bug Fixes
247
+
248
+ * wip ([1a7f5c9](https://github.com/agnostack/next-shopify/commit/1a7f5c93c5349e6e396784e7d5a21355cc95fc97))
249
+
250
+ ## [1.13.4-beta.26](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.25...v1.13.4-beta.26) (2023-11-28)
251
+
252
+
253
+ ### Bug Fixes
254
+
255
+ * wip ([874da3f](https://github.com/agnostack/next-shopify/commit/874da3f0b247c08521e6e201264379c3fbe0d80a))
256
+
257
+ ## [1.13.4-beta.25](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.24...v1.13.4-beta.25) (2023-11-28)
258
+
259
+
260
+ ### Bug Fixes
261
+
262
+ * wip ([ec34e7b](https://github.com/agnostack/next-shopify/commit/ec34e7b60d9a4fed434af6480f30a72a8bdb589a))
263
+
264
+ ## [1.13.4-beta.24](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.23...v1.13.4-beta.24) (2023-11-28)
265
+
266
+
267
+ ### Bug Fixes
268
+
269
+ * wip ([7131f58](https://github.com/agnostack/next-shopify/commit/7131f5811d91cf438321826cd3f82f80d963dee9))
270
+
271
+ ## [1.13.4-beta.23](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.22...v1.13.4-beta.23) (2023-11-28)
272
+
273
+
274
+ ### Bug Fixes
275
+
276
+ * wip ([fcc0135](https://github.com/agnostack/next-shopify/commit/fcc0135aecfcd2575ca228f9ff905ff9809db166))
277
+
278
+ ## [1.13.4-beta.22](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.21...v1.13.4-beta.22) (2023-11-28)
279
+
280
+
281
+ ### Bug Fixes
282
+
283
+ * wip ([18a8099](https://github.com/agnostack/next-shopify/commit/18a8099ee2dd8e9323a1ea17f5299914e8a95a41))
284
+
285
+ ## [1.13.4-beta.21](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.20...v1.13.4-beta.21) (2023-11-28)
286
+
287
+
288
+ ### Bug Fixes
289
+
290
+ * wip ([5dcd003](https://github.com/agnostack/next-shopify/commit/5dcd003c088ae7fd822803b7ac47f0ba8048b334))
291
+
292
+ ## [1.13.4-beta.20](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.19...v1.13.4-beta.20) (2023-11-28)
293
+
294
+
295
+ ### Bug Fixes
296
+
297
+ * wip ([5bfb2da](https://github.com/agnostack/next-shopify/commit/5bfb2daf4852a6ba3dda7b7958c215bbc6c5c67f))
298
+
299
+ ## [1.13.4-beta.19](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.18...v1.13.4-beta.19) (2023-11-28)
300
+
301
+
302
+ ### Bug Fixes
303
+
304
+ * wip ([fcfcb52](https://github.com/agnostack/next-shopify/commit/fcfcb52b69da5d0ecf281b2f56bbfe85048c6615))
305
+
306
+ ## [1.13.4-beta.18](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.17...v1.13.4-beta.18) (2023-11-28)
307
+
308
+
309
+ ### Bug Fixes
310
+
311
+ * wip ([48835ab](https://github.com/agnostack/next-shopify/commit/48835ab2b7e2a5a9fb921619322bacb044fa37c4))
312
+
313
+ ## [1.13.4-beta.17](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.16...v1.13.4-beta.17) (2023-11-28)
314
+
315
+
316
+ ### Bug Fixes
317
+
318
+ * wip ([f7fb508](https://github.com/agnostack/next-shopify/commit/f7fb50800b0b5e615d50e66d31a4ff7b0496ea35))
319
+
320
+ ## [1.13.4-beta.16](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.15...v1.13.4-beta.16) (2023-11-27)
321
+
322
+
323
+ ### Bug Fixes
324
+
325
+ * wip ([cf0ca62](https://github.com/agnostack/next-shopify/commit/cf0ca626e227a54c45c0c12ed6ae5924c2222868))
326
+
327
+ ## [1.13.4-beta.15](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.14...v1.13.4-beta.15) (2023-11-27)
328
+
329
+
330
+ ### Bug Fixes
331
+
332
+ * wip ([cea69da](https://github.com/agnostack/next-shopify/commit/cea69daea4f939b48ff25d67f694668b2f9307c4))
333
+
334
+ ## [1.13.4-beta.14](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.13...v1.13.4-beta.14) (2023-11-27)
335
+
336
+
337
+ ### Bug Fixes
338
+
339
+ * wip ([7af14c7](https://github.com/agnostack/next-shopify/commit/7af14c71b29f7bf3d7a181cbf9dfb60ded81425b))
340
+
341
+ ## [1.13.4-beta.13](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.12...v1.13.4-beta.13) (2023-11-27)
342
+
343
+
344
+ ### Bug Fixes
345
+
346
+ * wip ([7cc3648](https://github.com/agnostack/next-shopify/commit/7cc3648e80565295ab1e59be21784f5f7197054f))
347
+
348
+ ## [1.13.4-beta.12](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.11...v1.13.4-beta.12) (2023-11-27)
349
+
350
+
351
+ ### Bug Fixes
352
+
353
+ * wip ([142e3d5](https://github.com/agnostack/next-shopify/commit/142e3d540c181035efbc9aee2663b1b263d34664))
354
+ * wip ([03c326f](https://github.com/agnostack/next-shopify/commit/03c326fe0d5305df9df0e03a31417a9a6e737689))
355
+
356
+ ## [1.13.4-beta.11](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.10...v1.13.4-beta.11) (2023-11-27)
357
+
358
+
359
+ ### Bug Fixes
360
+
361
+ * wip ([4403568](https://github.com/agnostack/next-shopify/commit/4403568128d7eb48f6f1c65466f44f9ef225701c))
362
+
363
+ ## [1.13.4-beta.10](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.9...v1.13.4-beta.10) (2023-11-27)
364
+
365
+
366
+ ### Bug Fixes
367
+
368
+ * wip ([7e1b317](https://github.com/agnostack/next-shopify/commit/7e1b31755d1c4b715506e5018c21269be7c93a69))
369
+
370
+ ## [1.13.4-beta.9](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.8...v1.13.4-beta.9) (2023-11-27)
371
+
372
+
373
+ ### Bug Fixes
374
+
375
+ * wip ([72a4ecc](https://github.com/agnostack/next-shopify/commit/72a4ecc06650b0876bae416205d143d81f1e74a2))
376
+
377
+ ## [1.13.4-beta.8](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.7...v1.13.4-beta.8) (2023-11-27)
378
+
379
+
380
+ ### Bug Fixes
381
+
382
+ * wip ([ba69016](https://github.com/agnostack/next-shopify/commit/ba69016ef8ae6fec5146bbdbdb3b7d71bc48e3a5))
383
+
384
+ ## [1.13.4-beta.7](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.6...v1.13.4-beta.7) (2023-11-27)
385
+
386
+
387
+ ### Bug Fixes
388
+
389
+ * wip ([4900495](https://github.com/agnostack/next-shopify/commit/4900495dfc07c53f8e6d17cca5c23da873a25f4e))
390
+
1
391
  ## [1.13.4-beta.6](https://github.com/agnostack/next-shopify/compare/v1.13.4-beta.5...v1.13.4-beta.6) (2023-11-27)
2
392
 
3
393
 
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../../../src/lib/handlers/api/proxy.js"],"names":[],"mappings":"AAiCO,sHA4JN"}
1
+ {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../../../src/lib/handlers/api/proxy.js"],"names":[],"mappings":"AAsCO,sHA8QN"}
@@ -5,6 +5,8 @@ const tslib_1 = require("tslib");
5
5
  /* eslint-disable @typescript-eslint/no-unused-vars */
6
6
  const nextjs_cors_1 = tslib_1.__importDefault(require("nextjs-cors"));
7
7
  const http_proxy_1 = tslib_1.__importDefault(require("http-proxy"));
8
+ const raw_body_1 = tslib_1.__importDefault(require("raw-body"));
9
+ const node_http_proxy_json_1 = tslib_1.__importDefault(require("node-http-proxy-json"));
8
10
  const utils_1 = require("../../utils");
9
11
  const shared_1 = require("../../../shared");
10
12
  const PROXY_TIMEOUT = 6000; // NOTE: 6 seconds
@@ -15,42 +17,53 @@ const verifyAppProxySignature = (signature, verifiable, hmacSecret) => {
15
17
  const handleProxy = (serverRuntimeConfig, config) => (req, res, params) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
16
18
  var _a, _b;
17
19
  const { generateReplacements } = config !== null && config !== void 0 ? config : {};
18
- const { API_PATHS, APP_CONFIG, APP_BASE_URL, TARGET_SAFELIST, ORIGIN_SAFELIST, } = serverRuntimeConfig;
20
+ const { keyPairs, API_PATHS, APP_CONFIG, APP_BASE_URL, TARGET_SAFELIST, ORIGIN_SAFELIST, } = serverRuntimeConfig;
19
21
  const _c = (_a = req.headers) !== null && _a !== void 0 ? _a : {}, { origin, 'x-forwarded-for': _forwardFor, 'x-forwarded-proto': _forwardProto, 'x-forwarded-host': forwardHost, 'x-proxy-origin': proxyOrigin } = _c, _headers = tslib_1.__rest(_c, ["origin", 'x-forwarded-for', 'x-forwarded-proto', 'x-forwarded-host', 'x-proxy-origin']);
20
- const { 'x-extension-session': sessionToken, 'x-extension-point': extensionPoint, 'x-shop-domain': shopDomainHeader, 'x-shopify-shop-domain': shopifyShopDomainHeader, 'x-shopify-shop': shopHeader = shopifyShopDomainHeader !== null && shopifyShopDomainHeader !== void 0 ? shopifyShopDomainHeader : shopDomainHeader,
22
+ const { authorization, // THIS
23
+ 'x-public-key': apiKey, // THIS
24
+ 'x-ephemeral-key': ephemeralPublicKey, // THIS
25
+ 'x-authorization-timestamp': authTimestamp, // THIS
26
+ 'x-extension-session': sessionToken, 'x-extension-point': extensionPoint, 'x-shop-domain': shopDomainHeader, 'x-shopify-shop-domain': shopifyShopDomainHeader, 'x-shopify-shop': shopHeader = shopifyShopDomainHeader !== null && shopifyShopDomainHeader !== void 0 ? shopifyShopDomainHeader : shopDomainHeader, 'x-shopify-app-id': shopifyAppId, 'x-app-id': appId = shopifyAppId,
21
27
  // 'x-shopify-app-installation-id': shopifyAppInstallationId,
22
- 'x-shopify-app-id': shopifyAppId,
23
28
  // 'x-app-installation-id': appInstallationId = shopifyAppInstallationId, // TODO: pass along installationId??
24
- 'x-app-id': appId = shopifyAppId,
25
29
  // TODO: pass along providerSetId??
26
30
  } = _headers;
27
- // NOTE: GET requests are not always sending along origin
28
- if ((0, shared_1.stringEmpty)(origin)) {
29
- req.headers = Object.assign(Object.assign({}, req.headers), { origin: proxyOrigin || forwardHost });
30
- }
31
- const _d = (_b = req.query) !== null && _b !== void 0 ? _b : {}, { signature, proxyEncoded } = _d, verifiable = tslib_1.__rest(_d, ["signature", "proxyEncoded"]);
32
- const { shop: _shop, host, timestamp, path_prefix } = verifiable;
33
- const shop = _shop || shopHeader;
34
- yield (0, nextjs_cors_1.default)(req, res, {
35
- methods: ['PUT', 'PATCH', 'POST', 'DELETE'],
36
- origin: (origin, callback) => {
37
- const isSafelisted = (0, shared_1.matchHostname)(origin, [
38
- ...ORIGIN_SAFELIST,
39
- 'cdn.shopify.com' // NOTE: this is the domain for checkout UI extensions
40
- ]);
41
- if (isSafelisted) {
42
- return callback(null, true);
43
- }
44
- return callback(new Error('Invalid CORS origin'));
45
- },
46
- optionsSuccessStatus: 200, // some legacy browsers (IE11, various SmartTVs) choke on 204
47
- });
48
- const { target: targetParam } = params !== null && params !== void 0 ? params : {};
49
- const _targetUrl = ((0, shared_1.stringEmpty)(targetParam) || targetParam.startsWith('http')) ? targetParam : `${APP_BASE_URL}/${(0, shared_1.removeLeadingSlash)(targetParam)}`;
50
- const { origin: target, hostname, pathname, search } = (0, shared_1.stringNotEmpty)(_targetUrl) ? new URL(_targetUrl) : {};
51
- let targetPath = [pathname, search].filter(shared_1.stringNotEmpty).join('');
52
- let headers;
31
+ let targetPath;
53
32
  try {
33
+ const [authProtocol, authSignature] = (0, shared_1.ensureString)(authorization).split(' ');
34
+ const isVerifiable = (apiKey && ephemeralPublicKey && (keyPairs === null || keyPairs === void 0 ? void 0 : keyPairs.shared) && authTimestamp && authSignature && (authProtocol === 'HMAC-SHA256'));
35
+ let verificationKeys;
36
+ // NOTE raw request body is required for shopify's validation
37
+ const _rawBody = yield (0, raw_body_1.default)(req);
38
+ const rawBody = _rawBody.toString();
39
+ const parsedBody = JSON.parse(rawBody || '{}'); // NOTE: parsedody should be encrypted when isVerifiable
40
+ let decryptedBody = parsedBody;
41
+ // NOTE: GET requests are not always sending along origin
42
+ if ((0, shared_1.stringEmpty)(origin)) {
43
+ req.headers = Object.assign(Object.assign({}, req.headers), { origin: proxyOrigin || forwardHost });
44
+ }
45
+ const _d = (_b = req.query) !== null && _b !== void 0 ? _b : {}, { signature, proxyEncoded } = _d, verifiable = tslib_1.__rest(_d, ["signature", "proxyEncoded"]);
46
+ const { shop: _shop, host, timestamp, path_prefix } = verifiable;
47
+ const shop = _shop || shopHeader;
48
+ yield (0, nextjs_cors_1.default)(req, res, {
49
+ methods: ['PUT', 'PATCH', 'POST', 'DELETE'],
50
+ origin: (origin, callback) => {
51
+ const isSafelisted = (0, shared_1.matchHostname)(origin, [
52
+ ...ORIGIN_SAFELIST,
53
+ 'cdn.shopify.com' // NOTE: this is the domain for checkout UI extensions
54
+ ]);
55
+ if (isSafelisted) {
56
+ return callback(null, true);
57
+ }
58
+ return callback(new Error('Invalid CORS origin'));
59
+ },
60
+ optionsSuccessStatus: 200, // some legacy browsers (IE11, various SmartTVs) choke on 204
61
+ });
62
+ const { target: targetParam } = params !== null && params !== void 0 ? params : {};
63
+ // eslint-disable-next-line max-len
64
+ const _targetUrl = ((0, shared_1.stringEmpty)(targetParam) || targetParam.startsWith('http')) ? targetParam : `${APP_BASE_URL}/${(0, shared_1.removeLeadingSlash)(targetParam)}`;
65
+ const { origin: target, hostname, pathname, search } = (0, shared_1.stringNotEmpty)(_targetUrl) ? new URL(_targetUrl) : {};
66
+ targetPath = [pathname, search].filter(shared_1.stringNotEmpty).join('');
54
67
  const safelistedTarget = (0, shared_1.matchHostname)(hostname, Object.assign({ [new URL(APP_BASE_URL).hostname]: {
55
68
  // HMMM: can we generate our own session token so as to not have to tell handleGraph/Rest to behave as offline?
56
69
  // headers: {
@@ -67,15 +80,22 @@ const handleProxy = (serverRuntimeConfig, config) => (req, res, params) => tslib
67
80
  if (!shop || !host || !extensionPoint || !signature || !proxyEncoded) {
68
81
  return res.status(400).json({ message: 'Invalid or missing headers', extensionPoint });
69
82
  }
83
+ // TODO: handle encrypt/decrypy only if !isShopifyOriginOrRelative??
70
84
  const isShopifyOriginOrRelative = (0, shared_1.stringNotEmpty)((0, shared_1.ensureString)(path_prefix).startsWith('http')
71
85
  ? (0, shared_1.sanitizeShop)(new URL(path_prefix).hostname)
72
86
  : path_prefix);
87
+ console.log(`>>> > handleProxy > isShopifyOriginOrRelative: '${targetPath}'`, {
88
+ path_prefix,
89
+ hostname,
90
+ fooName: new URL(APP_BASE_URL).hostname,
91
+ targetParam,
92
+ isShopifyOriginOrRelative,
93
+ });
73
94
  // TODO: once Shopify fixes CORS issue when origin is cdn.shopify.com, update this!
74
95
  if (!verifyAppProxySignature(signature, verifiable, isShopifyOriginOrRelative ? APP_CONFIG.apiSecretKey : timestamp)) {
75
96
  return res.status(403).json({ message: 'Invalid signature' });
76
97
  }
77
98
  // TODO: clean up targetParam.startsWith??
78
- console.log(`>>> > handleProxy > targetParam:`, { sessionToken, targetParam });
79
99
  if (!targetParam.startsWith(API_PATHS[shared_1.API_ROUTE_NAMES.SESSION_TOKEN])) {
80
100
  const _getVerifiedSessionData = (0, utils_1.getVerifiedSessionData)(serverRuntimeConfig);
81
101
  if (!_getVerifiedSessionData(sessionToken, { shop, host }).catch((_error) => {
@@ -91,34 +111,101 @@ const handleProxy = (serverRuntimeConfig, config) => (req, res, params) => tslib
91
111
  if ((0, shared_1.objectNotEmpty)(targetParams)) {
92
112
  targetPath = (0, shared_1.appendQuery)(targetPath, new URLSearchParams(targetParams).toString());
93
113
  }
114
+ // TEMP!!! remove isVerifiable check once webwidget moved to react
115
+ if (isVerifiable) {
116
+ if (!apiKey || !ephemeralPublicKey || !(keyPairs === null || keyPairs === void 0 ? void 0 : keyPairs.shared) || !authTimestamp || !authSignature || (authProtocol !== 'HMAC-SHA256')) {
117
+ return res.status(401).json({ message: 'Invalid or missing authorization' });
118
+ }
119
+ verificationKeys = yield shared_1.subtle.getVerificationKeys({
120
+ publicKey: ephemeralPublicKey,
121
+ privateKey: keyPairs.shared.privateKey,
122
+ });
123
+ if (!verificationKeys) {
124
+ return res.status(412).json({ message: 'Invalid or missing verification' });
125
+ }
126
+ const verificationPayload = (0, shared_1.objectToSortedString)(Object.assign({ method: (0, shared_1.getRequestMethod)(rawBody, req.method), timestamp: authTimestamp, body: parsedBody }, (0, shared_1.normalizeURIParts)(targetPath)));
127
+ const isValid = yield shared_1.subtle.verifyHMAC(verificationPayload, verificationKeys.derivedHMACKey, authSignature);
128
+ if (!isValid) {
129
+ return res.status(412).json({ message: 'Invalid or missing verification' });
130
+ }
131
+ if (rawBody) {
132
+ console.log(`>>> > handleProxy > rawBody: '${targetPath}'`, rawBody);
133
+ const decryptedMessage = yield shared_1.subtle.decryptMessage(parsedBody, verificationKeys.derivedSecretKey);
134
+ decryptedBody = JSON.parse(decryptedMessage !== null && decryptedMessage !== void 0 ? decryptedMessage : '{}');
135
+ console.log(`>>> > handleProxy > decryptedBody: '${targetPath}'`, decryptedBody);
136
+ }
137
+ }
94
138
  const _prepareHeaders = (0, utils_1.prepareHeaders)(serverRuntimeConfig);
95
- headers = yield _prepareHeaders({
139
+ const headers = yield _prepareHeaders({
96
140
  generateReplacements,
97
141
  shop,
98
142
  appId,
99
143
  headers: Object.assign(Object.assign({}, _headers), targetHeaders),
100
144
  });
145
+ const proxy = http_proxy_1.default.createProxy();
146
+ return new Promise((resolve, reject) => {
147
+ req.url = targetPath;
148
+ if (headers) {
149
+ req.headers = headers;
150
+ }
151
+ proxy.on('proxyReq', (proxyReq, proxyReqRequest, proxyReqResponse, options) => {
152
+ console.log(`>>> > proxy.on > proxyReq:`, { decryptedBody, proxyReqRequestBody: proxyReqRequest.body, proxyReqRequest });
153
+ // Modify the request body before sending it to the target
154
+ if ((0, shared_1.objectNotEmpty)(decryptedBody)) {
155
+ const bodyData = JSON.stringify(decryptedBody);
156
+ console.log(`>>> > proxy.on > proxyReq > bodyData:`, bodyData);
157
+ proxyReq.setHeader('Content-Length', Buffer.byteLength(bodyData));
158
+ proxyReq.write(bodyData);
159
+ console.log(`>>> > proxy.on > proxyReq > AFTER 1`);
160
+ }
161
+ console.log(`>>> > proxy.on > proxyReq > AFTER 2`);
162
+ });
163
+ // proxy.on('proxyRes', function (proxyRes, req, res) {
164
+ // console.log(`>>> > proxy.on > proxyRes`)
165
+ // var body = []
166
+ // proxyRes.on('data', function (chunk) {
167
+ // body.push(chunk)
168
+ // })
169
+ // proxyRes.on('end', function () {
170
+ // body = Buffer.concat(body).toString()
171
+ // console.log("res from proxied server:", body)
172
+ // res.end(JSON.stringify(decryptedBody))
173
+ // return resolve()
174
+ // })
175
+ // })
176
+ proxy.on('proxyRes', function (proxyRes, proxyResRequest, proxyResResponse) {
177
+ console.log(`>>> > proxy.on > proxyRes:`);
178
+ (0, node_http_proxy_json_1.default)(proxyResResponse, proxyRes, function (proxyResBody) {
179
+ console.log(`>>> > proxy.on > proxyRes > modifyJSONProxy > proxyResBody:`, proxyResBody);
180
+ if (!proxyResBody || !isVerifiable || !verificationKeys) {
181
+ return proxyResBody;
182
+ }
183
+ return shared_1.subtle.encryptMessage(JSON.stringify(proxyResBody), verificationKeys.derivedSecretKey)
184
+ .then((encrypedResBody) => {
185
+ console.log(`>>> > proxy.on > proxyRes.then > encrypedResBody:`, encrypedResBody);
186
+ return encrypedResBody;
187
+ });
188
+ });
189
+ });
190
+ proxy.once('error', (error) => {
191
+ console.error('Proxy error', error);
192
+ reject(error);
193
+ });
194
+ proxy.web(req, res, {
195
+ target,
196
+ timeout: PROXY_TIMEOUT,
197
+ proxyTimeout: PROXY_TIMEOUT,
198
+ // selfHandleResponse : true, // HERE
199
+ followRedirects: false,
200
+ changeOrigin: true,
201
+ secure: true,
202
+ });
203
+ });
101
204
  }
102
205
  catch (error) {
103
206
  console.error(`Error handling proxy request for '${targetPath}'`, error);
104
207
  return res.status(200).json({ message: (error === null || error === void 0 ? void 0 : error.message) || 'Error handling proxy request', targetPath });
105
208
  }
106
- const proxy = http_proxy_1.default.createProxy();
107
- return new Promise((_resolve, reject) => {
108
- req.url = targetPath;
109
- if (headers) {
110
- req.headers = headers;
111
- }
112
- proxy.once('error', reject);
113
- proxy.web(req, res, {
114
- target,
115
- timeout: PROXY_TIMEOUT,
116
- proxyTimeout: PROXY_TIMEOUT,
117
- followRedirects: false,
118
- changeOrigin: true,
119
- secure: true,
120
- });
121
- });
122
209
  });
123
210
  exports.handleProxy = handleProxy;
124
211
  //# sourceMappingURL=proxy.js.map