@wix/astro 1.0.19 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +52 -48
- package/build/index.js.map +1 -1
- package/build-browser-runtime/setup.js +4082 -11
- package/build-runtime/middleware/auth.js +3 -3
- package/build-runtime/routes/auth/callback.d.ts +2 -2
- package/build-runtime/routes/auth/callback.js +6 -4
- package/build-runtime/routes/auth/login.d.ts +2 -2
- package/build-runtime/routes/auth/login.js +3 -3
- package/build-runtime/routes/auth/logout-callback.js +4 -2
- package/build-runtime/routes/auth/logout.d.ts +3 -3
- package/build-runtime/routes/auth/logout.js +13 -5
- package/package.json +2 -2
- package/src/context/non-elevated.ts +1 -1
- package/src/context/setup.ts +1 -1
- package/src/context/utils.ts +24 -13
- package/src/index.ts +2 -2
- package/src/routes/auth/callback.ts +6 -4
- package/src/routes/auth/login.ts +4 -4
- package/src/routes/auth/logout-callback.ts +3 -1
- package/src/routes/auth/logout.ts +12 -5
- package/src/routes/service-plugins.ts +2 -2
- package/src/routes/webhooks.ts +2 -2
- package/src/schemas.ts +2 -2
- package/src/utils/createProjectModel.ts +23 -21
- package/src/utils/fs-utils.ts +20 -20
- package/src/utils/generateAppManifest.ts +12 -12
- package/src/utils/generateVisitorTokens.ts +2 -1
- package/src/utils/getSessionTokensFromCookie.ts +3 -3
- package/src/utils/isValidBackofficeComponent.ts +4 -3
- package/src/utils/isValidServicePluginComponent.ts +6 -6
- package/src/utils/isValidWebhookComponent.ts +1 -1
- package/src/utils/loadEnvVars.ts +5 -2
- package/src/utils/saveSessionTokensToCookie.ts +10 -7
- package/src/utils/writeVirtualBackofficeExtensionFiles.ts +1 -1
- package/src/utils/writeVirtualServicePluginExtensionFiles.ts +1 -1
- package/src/utils/writeVirtualWebhookExtensionFiles.ts +1 -1
- package/tsup.config.mjs +17 -17
- package/build-runtime/{chunk-HVACFX6T.js → chunk-VMS3NKCF.js} +6 -6
package/build/index.js
CHANGED
|
@@ -10972,7 +10972,7 @@ var require_ignore = __commonJS({
|
|
|
10972
10972
|
var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
10973
10973
|
var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
|
10974
10974
|
var REGEX_SPLITALL_CRLF = /\r?\n/g;
|
|
10975
|
-
var REGEX_TEST_INVALID_PATH =
|
|
10975
|
+
var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
|
|
10976
10976
|
var REGEX_TEST_TRAILING_SLASH = /\/$/;
|
|
10977
10977
|
var SLASH = "/";
|
|
10978
10978
|
var TMP_KEY_IGNORE = "node-ignore";
|
|
@@ -11395,18 +11395,22 @@ var require_ignore = __commonJS({
|
|
|
11395
11395
|
};
|
|
11396
11396
|
var factory = (options) => new Ignore(options);
|
|
11397
11397
|
var isPathValid = (path2) => checkPath(path2 && checkPath.convert(path2), path2, RETURN_FALSE);
|
|
11398
|
-
|
|
11399
|
-
// Detect `process` so that it can run in browsers.
|
|
11400
|
-
typeof process !== "undefined" && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === "win32")
|
|
11401
|
-
) {
|
|
11398
|
+
var setupWindows = () => {
|
|
11402
11399
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
11403
11400
|
checkPath.convert = makePosix;
|
|
11404
11401
|
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
11405
11402
|
checkPath.isNotRelative = (path2) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path2) || isNotRelative(path2);
|
|
11403
|
+
};
|
|
11404
|
+
if (
|
|
11405
|
+
// Detect `process` so that it can run in browsers.
|
|
11406
|
+
typeof process !== "undefined" && process.platform === "win32"
|
|
11407
|
+
) {
|
|
11408
|
+
setupWindows();
|
|
11406
11409
|
}
|
|
11407
11410
|
module2.exports = factory;
|
|
11408
11411
|
factory.default = factory;
|
|
11409
11412
|
module2.exports.isPathValid = isPathValid;
|
|
11413
|
+
define2(module2.exports, Symbol.for("setupWindows"), setupWindows);
|
|
11410
11414
|
}
|
|
11411
11415
|
});
|
|
11412
11416
|
|
|
@@ -17271,27 +17275,27 @@ import {
|
|
|
17271
17275
|
} from "node:fs/promises";
|
|
17272
17276
|
import { EOL } from "node:os";
|
|
17273
17277
|
import { dirname, relative } from "node:path";
|
|
17274
|
-
function
|
|
17275
|
-
|
|
17276
|
-
}
|
|
17277
|
-
async function writeJson(filePath, object, opts) {
|
|
17278
|
-
const str = toJsonString(object, opts);
|
|
17279
|
-
await outputDir(dirname(filePath));
|
|
17280
|
-
await writeFile(filePath, str, "utf-8");
|
|
17281
|
-
}
|
|
17282
|
-
async function readJson(file) {
|
|
17283
|
-
return JSON.parse(await fsReadFile(file, "utf-8"));
|
|
17278
|
+
async function outputDir(dir) {
|
|
17279
|
+
await mkdir(dir, { recursive: true });
|
|
17284
17280
|
}
|
|
17285
17281
|
function pathExists(path2) {
|
|
17286
17282
|
return access(path2).then(() => true).catch(() => false);
|
|
17287
17283
|
}
|
|
17288
|
-
async function
|
|
17289
|
-
await
|
|
17284
|
+
async function readJson(file) {
|
|
17285
|
+
return JSON.parse(await fsReadFile(file, "utf-8"));
|
|
17290
17286
|
}
|
|
17291
17287
|
function toRelativePath2(from, to) {
|
|
17292
17288
|
const rel = relative(dirname(from), to).replaceAll("\\", "/");
|
|
17293
17289
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
17294
17290
|
}
|
|
17291
|
+
async function writeJson(filePath, object, opts) {
|
|
17292
|
+
const str = toJsonString(object, opts);
|
|
17293
|
+
await outputDir(dirname(filePath));
|
|
17294
|
+
await writeFile(filePath, str, "utf-8");
|
|
17295
|
+
}
|
|
17296
|
+
function toJsonString(object, opts) {
|
|
17297
|
+
return `${JSON.stringify(object, null, opts?.spaces)}${EOL}`;
|
|
17298
|
+
}
|
|
17295
17299
|
|
|
17296
17300
|
// src/utils/loadEnvVars.ts
|
|
17297
17301
|
init_esm_shims();
|
|
@@ -17794,10 +17798,10 @@ var source_default = chalk;
|
|
|
17794
17798
|
// src/utils/loadEnvVars.ts
|
|
17795
17799
|
import { loadEnv } from "vite";
|
|
17796
17800
|
var wixClientIdEnvVar = "WIX_CLIENT_ID";
|
|
17797
|
-
function loadEnvVars(
|
|
17801
|
+
function loadEnvVars(logger) {
|
|
17798
17802
|
const env2 = loadEnv("production", process.cwd(), "");
|
|
17799
17803
|
const appId = env2[wixClientIdEnvVar];
|
|
17800
|
-
if (
|
|
17804
|
+
if (appId == null) {
|
|
17801
17805
|
logger.error(
|
|
17802
17806
|
defaultOutdent`
|
|
17803
17807
|
Missing environment variable ${source_default.blueBright(wixClientIdEnvVar)}
|
|
@@ -17826,7 +17830,7 @@ function loadEnvVars(rootDir, logger) {
|
|
|
17826
17830
|
// src/utils/createProjectModel.ts
|
|
17827
17831
|
async function createProjectModel(logger) {
|
|
17828
17832
|
const rootDir = cwd();
|
|
17829
|
-
const { appId, env: env2 } = loadEnvVars(
|
|
17833
|
+
const { appId, env: env2 } = loadEnvVars(logger);
|
|
17830
17834
|
const componentsPaths = await globby(
|
|
17831
17835
|
pathToGlobby(join3(EXTENSIONS_DIR, "*")),
|
|
17832
17836
|
{
|
|
@@ -17838,12 +17842,12 @@ async function createProjectModel(logger) {
|
|
|
17838
17842
|
const unknownComponents = [];
|
|
17839
17843
|
for (const componentPath of componentsPaths) {
|
|
17840
17844
|
const extensionManifest = await readExtensionManifest(componentPath);
|
|
17841
|
-
const knownManifest =
|
|
17845
|
+
const knownManifest = parseKnownExtensionManifest(extensionManifest);
|
|
17842
17846
|
if (knownManifest != null) {
|
|
17843
17847
|
components.push(createComponent(knownManifest, componentPath));
|
|
17844
17848
|
continue;
|
|
17845
17849
|
}
|
|
17846
|
-
const unknownManifest =
|
|
17850
|
+
const unknownManifest = parseBaseExtensionManifest(extensionManifest);
|
|
17847
17851
|
unknownComponents.push(
|
|
17848
17852
|
UnknownComponent.Unknown({
|
|
17849
17853
|
directory: componentPath,
|
|
@@ -17859,9 +17863,6 @@ async function createProjectModel(logger) {
|
|
|
17859
17863
|
unknownComponents
|
|
17860
17864
|
};
|
|
17861
17865
|
}
|
|
17862
|
-
function pathToGlobby(path2) {
|
|
17863
|
-
return path2.replaceAll("\\", "/");
|
|
17864
|
-
}
|
|
17865
17866
|
function createComponent(manifest, directory) {
|
|
17866
17867
|
switch (manifest.compType) {
|
|
17867
17868
|
case "BACK_OFFICE_EXTENSION_MENU_ITEM":
|
|
@@ -17931,14 +17932,7 @@ function createComponent(manifest, directory) {
|
|
|
17931
17932
|
}
|
|
17932
17933
|
}
|
|
17933
17934
|
}
|
|
17934
|
-
|
|
17935
|
-
const appManifestResult = devCenterComponentSchema.safeParse(extensionManifest);
|
|
17936
|
-
if (appManifestResult.error) {
|
|
17937
|
-
return null;
|
|
17938
|
-
}
|
|
17939
|
-
return appManifestResult.data;
|
|
17940
|
-
}
|
|
17941
|
-
async function parseBaseExtensionManifest(extensionManifest) {
|
|
17935
|
+
function parseBaseExtensionManifest(extensionManifest) {
|
|
17942
17936
|
const appManifestResult = baseDevCenterComponentSchema.safeParse(extensionManifest);
|
|
17943
17937
|
if (!appManifestResult.success) {
|
|
17944
17938
|
throw new Error(defaultOutdent`
|
|
@@ -17949,6 +17943,16 @@ async function parseBaseExtensionManifest(extensionManifest) {
|
|
|
17949
17943
|
}
|
|
17950
17944
|
return appManifestResult.data;
|
|
17951
17945
|
}
|
|
17946
|
+
function parseKnownExtensionManifest(extensionManifest) {
|
|
17947
|
+
const appManifestResult = devCenterComponentSchema.safeParse(extensionManifest);
|
|
17948
|
+
if (appManifestResult.error) {
|
|
17949
|
+
return null;
|
|
17950
|
+
}
|
|
17951
|
+
return appManifestResult.data;
|
|
17952
|
+
}
|
|
17953
|
+
function pathToGlobby(path2) {
|
|
17954
|
+
return path2.replaceAll("\\", "/");
|
|
17955
|
+
}
|
|
17952
17956
|
async function readExtensionManifest(directoryPath) {
|
|
17953
17957
|
const manifestFilePath = join3(directoryPath, "extension.json");
|
|
17954
17958
|
if (!await pathExists(manifestFilePath)) {
|
|
@@ -17965,7 +17969,7 @@ function generateAppManifest(model) {
|
|
|
17965
17969
|
case "BACK_OFFICE_EXTENSION_MENU_ITEM":
|
|
17966
17970
|
return manifest;
|
|
17967
17971
|
case "BACK_OFFICE_EXTENSION_WIDGET":
|
|
17968
|
-
if (manifest.compData.backOfficeExtensionWidget.iframeUrl) {
|
|
17972
|
+
if (manifest.compData.backOfficeExtensionWidget.iframeUrl != null) {
|
|
17969
17973
|
return manifest;
|
|
17970
17974
|
}
|
|
17971
17975
|
return {
|
|
@@ -17978,7 +17982,7 @@ function generateAppManifest(model) {
|
|
|
17978
17982
|
}
|
|
17979
17983
|
};
|
|
17980
17984
|
case "BACK_OFFICE_MODAL":
|
|
17981
|
-
if (manifest.compData.backOfficeModal.iframeUrl) {
|
|
17985
|
+
if (manifest.compData.backOfficeModal.iframeUrl != null) {
|
|
17982
17986
|
return manifest;
|
|
17983
17987
|
}
|
|
17984
17988
|
return {
|
|
@@ -17991,7 +17995,7 @@ function generateAppManifest(model) {
|
|
|
17991
17995
|
}
|
|
17992
17996
|
};
|
|
17993
17997
|
case "BACK_OFFICE_PAGE":
|
|
17994
|
-
if (manifest.compData.backOfficePage.iframeUrl) {
|
|
17998
|
+
if (manifest.compData.backOfficePage.iframeUrl != null) {
|
|
17995
17999
|
return manifest;
|
|
17996
18000
|
}
|
|
17997
18001
|
return {
|
|
@@ -18004,7 +18008,7 @@ function generateAppManifest(model) {
|
|
|
18004
18008
|
}
|
|
18005
18009
|
};
|
|
18006
18010
|
case "ECOM_ADDITIONAL_FEES":
|
|
18007
|
-
if (manifest.compData.ecomAdditionalFees.deploymentUri) {
|
|
18011
|
+
if (manifest.compData.ecomAdditionalFees.deploymentUri != null) {
|
|
18008
18012
|
return manifest;
|
|
18009
18013
|
}
|
|
18010
18014
|
return {
|
|
@@ -18017,7 +18021,7 @@ function generateAppManifest(model) {
|
|
|
18017
18021
|
}
|
|
18018
18022
|
};
|
|
18019
18023
|
case "ECOM_DISCOUNTS_TRIGGER":
|
|
18020
|
-
if (manifest.compData.ecomDiscountsTrigger.deploymentUri) {
|
|
18024
|
+
if (manifest.compData.ecomDiscountsTrigger.deploymentUri != null) {
|
|
18021
18025
|
return manifest;
|
|
18022
18026
|
}
|
|
18023
18027
|
return {
|
|
@@ -18030,7 +18034,7 @@ function generateAppManifest(model) {
|
|
|
18030
18034
|
}
|
|
18031
18035
|
};
|
|
18032
18036
|
case "ECOM_PAYMENT_SETTINGS":
|
|
18033
|
-
if (manifest.compData.ecomPaymentSettings.deploymentUri) {
|
|
18037
|
+
if (manifest.compData.ecomPaymentSettings.deploymentUri != null) {
|
|
18034
18038
|
return manifest;
|
|
18035
18039
|
}
|
|
18036
18040
|
return {
|
|
@@ -18043,7 +18047,7 @@ function generateAppManifest(model) {
|
|
|
18043
18047
|
}
|
|
18044
18048
|
};
|
|
18045
18049
|
case "ECOM_SHIPPING_RATES":
|
|
18046
|
-
if (manifest.compData.ecomShippingRates.deploymentUri) {
|
|
18050
|
+
if (manifest.compData.ecomShippingRates.deploymentUri != null) {
|
|
18047
18051
|
return manifest;
|
|
18048
18052
|
}
|
|
18049
18053
|
return {
|
|
@@ -18056,7 +18060,7 @@ function generateAppManifest(model) {
|
|
|
18056
18060
|
}
|
|
18057
18061
|
};
|
|
18058
18062
|
case "ECOM_VALIDATIONS":
|
|
18059
|
-
if (manifest.compData.ecomValidations.deploymentUri) {
|
|
18063
|
+
if (manifest.compData.ecomValidations.deploymentUri != null) {
|
|
18060
18064
|
return manifest;
|
|
18061
18065
|
}
|
|
18062
18066
|
return {
|
|
@@ -18069,7 +18073,7 @@ function generateAppManifest(model) {
|
|
|
18069
18073
|
}
|
|
18070
18074
|
};
|
|
18071
18075
|
case "GIFT_CARDS_PROVIDER":
|
|
18072
|
-
if (manifest.compData.giftCardsProvider.deploymentUri) {
|
|
18076
|
+
if (manifest.compData.giftCardsProvider.deploymentUri != null) {
|
|
18073
18077
|
return manifest;
|
|
18074
18078
|
}
|
|
18075
18079
|
return {
|
|
@@ -18082,7 +18086,7 @@ function generateAppManifest(model) {
|
|
|
18082
18086
|
}
|
|
18083
18087
|
};
|
|
18084
18088
|
case "WEBHOOK":
|
|
18085
|
-
if (manifest.compData.webhook.callbackUrl) {
|
|
18089
|
+
if (manifest.compData.webhook.callbackUrl != null) {
|
|
18086
18090
|
return manifest;
|
|
18087
18091
|
}
|
|
18088
18092
|
return {
|
|
@@ -18110,19 +18114,19 @@ function generateAppManifest(model) {
|
|
|
18110
18114
|
// src/utils/isValidBackofficeComponent.ts
|
|
18111
18115
|
init_esm_shims();
|
|
18112
18116
|
function isValidBackofficeComponent(component) {
|
|
18113
|
-
return component.type === "BackofficePage" &&
|
|
18117
|
+
return component.type === "BackofficePage" && component.manifest.compData.backOfficePage.iframeUrl == null || component.type === "BackofficeExtensionWidget" && component.manifest.compData.backOfficeExtensionWidget.iframeUrl == null || component.type === "BackofficeModal" && component.manifest.compData.backOfficeModal.iframeUrl == null;
|
|
18114
18118
|
}
|
|
18115
18119
|
|
|
18116
18120
|
// src/utils/isValidServicePluginComponent.ts
|
|
18117
18121
|
init_esm_shims();
|
|
18118
18122
|
function isValidServicePluginComponent(component) {
|
|
18119
|
-
return component.type === "EcomShippingRates" &&
|
|
18123
|
+
return component.type === "EcomShippingRates" && component.manifest.compData.ecomShippingRates.deploymentUri == null || component.type === "EcomAdditionalFees" && component.manifest.compData.ecomAdditionalFees.deploymentUri == null || component.type === "EcomDiscountsTrigger" && component.manifest.compData.ecomDiscountsTrigger.deploymentUri == null || component.type === "EcomValidations" && component.manifest.compData.ecomValidations.deploymentUri == null || component.type === "EcomPaymentSettings" && component.manifest.compData.ecomPaymentSettings.deploymentUri == null || component.type === "EcomGiftCardsProvider" && component.manifest.compData.giftCardsProvider.deploymentUri == null;
|
|
18120
18124
|
}
|
|
18121
18125
|
|
|
18122
18126
|
// src/utils/isValidWebhookComponent.ts
|
|
18123
18127
|
init_esm_shims();
|
|
18124
18128
|
function isValidWebhookComponent(component) {
|
|
18125
|
-
return component.type === "Webhook" &&
|
|
18129
|
+
return component.type === "Webhook" && component.manifest.compData.webhook.callbackUrl == null;
|
|
18126
18130
|
}
|
|
18127
18131
|
|
|
18128
18132
|
// src/utils/resolveBuildMetadata.ts
|
|
@@ -18349,7 +18353,7 @@ var createIntegration = (options = {
|
|
|
18349
18353
|
{ spaces: 2 }
|
|
18350
18354
|
);
|
|
18351
18355
|
},
|
|
18352
|
-
"astro:config:done":
|
|
18356
|
+
"astro:config:done": ({ config }) => {
|
|
18353
18357
|
_config = config;
|
|
18354
18358
|
},
|
|
18355
18359
|
async "astro:config:setup"({
|
|
@@ -18573,7 +18577,7 @@ var createIntegration = (options = {
|
|
|
18573
18577
|
}
|
|
18574
18578
|
await writeVirtualBackofficeExtensionFiles(model, backofficeCodegenDir);
|
|
18575
18579
|
},
|
|
18576
|
-
"astro:server:setup":
|
|
18580
|
+
"astro:server:setup": ({ logger, server }) => {
|
|
18577
18581
|
server.middlewares.use(async (req, res, next) => {
|
|
18578
18582
|
if (req.url === "/_wix/app-manifest.json") {
|
|
18579
18583
|
const model2 = await createProjectModel(logger);
|