@wix/astro 1.0.30 → 1.0.32

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.
Files changed (36) hide show
  1. package/build/index.js +31 -0
  2. package/build/index.js.map +1 -1
  3. package/build-browser-runtime/setup.js +723 -3
  4. package/build-runtime/chunk-7EHL72JI.js +1079 -0
  5. package/build-runtime/{chunk-FR26HCAT.js → chunk-EK7YZVWJ.js} +17 -135
  6. package/build-runtime/chunk-NKY4T53W.js +709 -0
  7. package/build-runtime/chunk-PSHIUVP2.js +131 -0
  8. package/build-runtime/chunk-U67V476Y.js +35 -0
  9. package/build-runtime/{chunk-RKE6XT5Z.js → chunk-WE3ELMU5.js} +1 -1
  10. package/build-runtime/chunk-YX6EVX5Q.js +11 -0
  11. package/build-runtime/context/elevated.js +3 -2
  12. package/build-runtime/context/nonElevated.js +3 -2
  13. package/build-runtime/context/setupServicePlugin.js +1 -1
  14. package/build-runtime/context/setupWebhook.js +1 -1
  15. package/build-runtime/middleware/auth.js +1 -1
  16. package/build-runtime/middleware/html-embeds.js +3 -2
  17. package/build-runtime/routes/auth/callback.js +2 -2
  18. package/build-runtime/routes/auth/login.js +2 -2
  19. package/build-runtime/routes/auth/logout-callback.js +1 -1
  20. package/build-runtime/routes/auth/logout.js +2 -2
  21. package/build-runtime/routes/paylink/checkout.d.ts +5 -0
  22. package/build-runtime/routes/paylink/checkout.js +35 -0
  23. package/build-runtime/routes/paylink/paylink.js +5 -1072
  24. package/build-runtime/routes/robots/robots.d.ts +5 -0
  25. package/build-runtime/routes/robots/robots.js +44 -0
  26. package/build-runtime/routes/servicePluginsDevRoute.js +1 -1
  27. package/build-runtime/routes/webhooksDevRoute.js +1 -1
  28. package/package.json +4 -4
  29. package/src/index.ts +28 -0
  30. package/src/plugins/setupSsrContext.ts +6 -0
  31. package/src/routes/paylink/checkout.ts +28 -0
  32. package/src/routes/robots/robots.ts +40 -0
  33. package/src/utils/normalizeWixRedirectUrl.ts +11 -0
  34. package/tsup.config.mjs +6 -0
  35. package/build-runtime/chunk-B6RICTPP.js +0 -94
  36. package/build-runtime/chunk-MLKGABMK.js +0 -9
@@ -0,0 +1,5 @@
1
+ import { APIRoute } from 'astro';
2
+
3
+ declare const GET: APIRoute;
4
+
5
+ export { GET };
@@ -0,0 +1,44 @@
1
+ import {
2
+ normalizeWixRedirectUrl
3
+ } from "../../chunk-YX6EVX5Q.js";
4
+ import {
5
+ es_exports
6
+ } from "../../chunk-7EHL72JI.js";
7
+ import "../../chunk-EK7YZVWJ.js";
8
+ import "../../chunk-PSHIUVP2.js";
9
+ import "../../chunk-U67V476Y.js";
10
+
11
+ // src/routes/robots/robots.ts
12
+ import { auth } from "@wix/essentials";
13
+ import { WIX_CLIENT_ID } from "astro:env/client";
14
+ var GET = async ({ request }) => {
15
+ const { redirectUrlWixPages } = await auth.elevate(es_exports.getOAuthApp)(
16
+ WIX_CLIENT_ID
17
+ );
18
+ if (redirectUrlWixPages == null) {
19
+ throw new Error(`Invalid Redirect URL: '${redirectUrlWixPages}'`);
20
+ }
21
+ const baseUrl = normalizeWixRedirectUrl({
22
+ wixRedirectUrl: redirectUrlWixPages
23
+ });
24
+ const robotsUrl = new URL("robots.txt", baseUrl);
25
+ const userAgent = request.headers.get("user-agent");
26
+ const originalRobotsFileResponse = await fetch(robotsUrl, {
27
+ headers: { ...userAgent != null ? { "User-Agent": userAgent } : {} }
28
+ });
29
+ if (!originalRobotsFileResponse.ok) {
30
+ throw new Error(
31
+ `Failed to retrieve original robots.txt from: ${robotsUrl.toString()}. Error: ${originalRobotsFileResponse.statusText}`
32
+ );
33
+ }
34
+ const contentType = originalRobotsFileResponse.headers.get("content-type");
35
+ return new Response(originalRobotsFileResponse.body, {
36
+ headers: {
37
+ ...contentType != null ? { "Content-Type": contentType } : {}
38
+ },
39
+ status: 200
40
+ });
41
+ };
42
+ export {
43
+ GET
44
+ };
@@ -1,4 +1,4 @@
1
- import "../chunk-MLKGABMK.js";
1
+ import "../chunk-U67V476Y.js";
2
2
 
3
3
  // src/routes/servicePluginsDevRoute.ts
4
4
  var ALL = async (context) => {
@@ -1,4 +1,4 @@
1
- import "../chunk-MLKGABMK.js";
1
+ import "../chunk-U67V476Y.js";
2
2
 
3
3
  // src/routes/webhooksDevRoute.ts
4
4
  var ALL = async (context) => {
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@wix/astro",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "devDependencies": {
5
5
  "@wix/auth-management": "^1.0.70",
6
6
  "@wix/dashboard": "^1.3.35",
7
7
  "@wix/essentials": "^0.1.23",
8
- "@wix/headless-node": "^1.4.0",
9
- "@wix/headless-site": "^1.0.0",
8
+ "@wix/headless-node": "^1.7.0",
9
+ "@wix/headless-site": "^1.3.0",
10
10
  "@wix/headless-site-assets": "^1.0.2",
11
11
  "@wix/sdk": "^1.15.23",
12
12
  "@wix/sdk-context": "^0.0.1",
@@ -51,5 +51,5 @@
51
51
  "artifactId": "wix-astro"
52
52
  }
53
53
  },
54
- "falconPackageHash": "5dcf23446b8dffbca01615c5bdb7455061cb4a01c86e30fce676dfd9"
54
+ "falconPackageHash": "6f606824546987477247020af5483a643d4c7e87e963a9fd1bca977b"
55
55
  }
package/src/index.ts CHANGED
@@ -159,6 +159,34 @@ const createIntegration = (
159
159
  prerender: false,
160
160
  });
161
161
 
162
+ injectRoute({
163
+ entrypoint: new URL(
164
+ '../build-runtime/routes/paylink/checkout.js',
165
+ import.meta.url
166
+ ),
167
+ pattern: '/checkout',
168
+ prerender: false,
169
+ });
170
+
171
+ injectRoute({
172
+ entrypoint: new URL(
173
+ '../build-runtime/routes/paylink/checkout.js',
174
+ import.meta.url
175
+ ),
176
+ // https://github.com/wix-private/wix-cli-one/pull/205/files#r2312298435
177
+ pattern: '/__ecom/checkout',
178
+ prerender: false,
179
+ });
180
+
181
+ injectRoute({
182
+ entrypoint: new URL(
183
+ '../build-runtime/routes/robots/robots.js',
184
+ import.meta.url
185
+ ),
186
+ pattern: '/robots.txt',
187
+ prerender: false,
188
+ });
189
+
162
190
  updateConfig({
163
191
  env: {
164
192
  schema: {
@@ -31,6 +31,12 @@ const whitelistedFilePaths = [
31
31
  fileURLToPath(
32
32
  new URL('../build-runtime/routes/paylink/paylink.js', import.meta.url)
33
33
  ),
34
+ fileURLToPath(
35
+ new URL('../build-runtime/routes/paylink/checkout.js', import.meta.url)
36
+ ),
37
+ fileURLToPath(
38
+ new URL('../build-runtime/routes/robots/robots.js', import.meta.url)
39
+ ),
34
40
  ];
35
41
 
36
42
  export function setupSsrContext(rootDir: string): PluginOption {
@@ -0,0 +1,28 @@
1
+ import type { APIRoute } from 'astro';
2
+ import { oAuthApps } from '@wix/auth-management';
3
+ import { auth } from '@wix/essentials';
4
+ import { WIX_CLIENT_ID } from 'astro:env/client';
5
+ import { normalizeWixRedirectUrl } from '../../utils/normalizeWixRedirectUrl.js';
6
+
7
+ export const GET: APIRoute = async ({ url }) => {
8
+ const { redirectUrlWixPages } = await auth.elevate(oAuthApps.getOAuthApp)(
9
+ WIX_CLIENT_ID
10
+ );
11
+
12
+ if (redirectUrlWixPages == null) {
13
+ throw new Error(`Invalid Redirect URL: '${redirectUrlWixPages}'`);
14
+ }
15
+
16
+ const baseUrl = normalizeWixRedirectUrl({
17
+ wixRedirectUrl: redirectUrlWixPages,
18
+ });
19
+ const newCheckoutUrl = new URL(
20
+ url.pathname.replace('/', '') + url.search,
21
+ baseUrl
22
+ );
23
+
24
+ return new Response(null, {
25
+ headers: { Location: newCheckoutUrl.toString() },
26
+ status: 302,
27
+ });
28
+ };
@@ -0,0 +1,40 @@
1
+ import type { APIRoute } from 'astro';
2
+ import { oAuthApps } from '@wix/auth-management';
3
+ import { auth } from '@wix/essentials';
4
+ import { WIX_CLIENT_ID } from 'astro:env/client';
5
+ import { normalizeWixRedirectUrl } from '../../utils/normalizeWixRedirectUrl.js';
6
+
7
+ export const GET: APIRoute = async ({ request }) => {
8
+ const { redirectUrlWixPages } = await auth.elevate(oAuthApps.getOAuthApp)(
9
+ WIX_CLIENT_ID
10
+ );
11
+
12
+ if (redirectUrlWixPages == null) {
13
+ throw new Error(`Invalid Redirect URL: '${redirectUrlWixPages}'`);
14
+ }
15
+
16
+ const baseUrl = normalizeWixRedirectUrl({
17
+ wixRedirectUrl: redirectUrlWixPages,
18
+ });
19
+
20
+ const robotsUrl = new URL('robots.txt', baseUrl);
21
+ const userAgent = request.headers.get('user-agent');
22
+ const originalRobotsFileResponse = await fetch(robotsUrl, {
23
+ headers: { ...(userAgent != null ? { 'User-Agent': userAgent } : {}) },
24
+ });
25
+
26
+ if (!originalRobotsFileResponse.ok) {
27
+ throw new Error(
28
+ `Failed to retrieve original robots.txt from: ${robotsUrl.toString()}. Error: ${originalRobotsFileResponse.statusText}`
29
+ );
30
+ }
31
+
32
+ const contentType = originalRobotsFileResponse.headers.get('content-type');
33
+
34
+ return new Response(originalRobotsFileResponse.body, {
35
+ headers: {
36
+ ...(contentType != null ? { 'Content-Type': contentType } : {}),
37
+ },
38
+ status: 200,
39
+ });
40
+ };
@@ -0,0 +1,11 @@
1
+ export function normalizeWixRedirectUrl({
2
+ wixRedirectUrl,
3
+ }: {
4
+ wixRedirectUrl: string;
5
+ }): string {
6
+ const normalizedWixRedirectUrl = wixRedirectUrl.endsWith('/')
7
+ ? wixRedirectUrl
8
+ : `${wixRedirectUrl}/`;
9
+
10
+ return normalizedWixRedirectUrl;
11
+ }
package/tsup.config.mjs CHANGED
@@ -58,6 +58,12 @@ export default defineConfig([
58
58
  // paylink route
59
59
  'src/routes/paylink/paylink.ts',
60
60
 
61
+ // checkout route
62
+ 'src/routes/paylink/checkout.ts',
63
+
64
+ // robots route
65
+ 'src/routes/robots/robots.ts',
66
+
61
67
  // html embeds
62
68
  'src/middleware/html-embeds.ts',
63
69
  ],
@@ -1,94 +0,0 @@
1
- import {
2
- authAsyncLocalStorage
3
- } from "./chunk-NVTQFGTR.js";
4
-
5
- // ../../node_modules/@wix/headless-node/dist/esm/headers/common-config-header.js
6
- var COMMON_CONFIG_HEADER_NAME = "commonConfig";
7
- var BSI_COOKIE_NAME = "bSession";
8
- var getCommonConfigHeader = (req) => {
9
- let value = req.headers.get(COMMON_CONFIG_HEADER_NAME);
10
- if (!value) {
11
- const cookies = req.headers.get("cookie");
12
- const bsiCookie = cookies == null ? void 0 : cookies.split(";").find((keyValue) => keyValue.trim().startsWith(`${BSI_COOKIE_NAME}=`));
13
- value = bsiCookie ? encodeURIComponent(JSON.stringify({
14
- BSI: bsiCookie.split("=")[1]
15
- })) : "";
16
- }
17
- return {
18
- [COMMON_CONFIG_HEADER_NAME]: value
19
- };
20
- };
21
-
22
- // ../../node_modules/@wix/headless-node/dist/esm/headers/index.js
23
- var getPassThroughHeaders = (req) => {
24
- if (!req) {
25
- return {};
26
- }
27
- const headers = [getCommonConfigHeader(req)];
28
- return headers.reduce((res, header) => {
29
- const entries = Object.entries(header).filter((_ref) => {
30
- let [_, value] = _ref;
31
- return !!value;
32
- });
33
- res = {
34
- ...res,
35
- ...Object.fromEntries(entries)
36
- };
37
- return res;
38
- }, {});
39
- };
40
-
41
- // ../../node_modules/@wix/headless-node/dist/esm/host-module.js
42
- var createHostModule = () => {
43
- return {
44
- __type: "host",
45
- create: () => {
46
- return {};
47
- },
48
- host: function(_temp) {
49
- let {
50
- req
51
- } = _temp === void 0 ? {} : _temp;
52
- const passThroughHeaders = getPassThroughHeaders(req);
53
- return {
54
- essentials: {
55
- passThroughHeaders
56
- }
57
- };
58
- }
59
- };
60
- };
61
-
62
- // ../../node_modules/@wix/headless-node/dist/esm/index.js
63
- var headlessNode = createHostModule();
64
-
65
- // src/context/hostProxy.ts
66
- var createHostWithCurrentRequest = () => {
67
- const store = authAsyncLocalStorage.getStore();
68
- return headlessNode.host({ req: store?.request });
69
- };
70
- var createHostProxy = () => {
71
- return new Proxy(
72
- {},
73
- {
74
- get(target, prop) {
75
- const host = createHostWithCurrentRequest();
76
- const value = host[prop];
77
- if (typeof value !== "function") {
78
- return value;
79
- }
80
- return function(...args) {
81
- const anotherHost = createHostWithCurrentRequest();
82
- return anotherHost[prop].apply(
83
- anotherHost,
84
- args
85
- );
86
- };
87
- }
88
- }
89
- );
90
- };
91
-
92
- export {
93
- createHostProxy
94
- };
@@ -1,9 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, { get: all[name], enumerable: true });
5
- };
6
-
7
- export {
8
- __export
9
- };