@wix/astro 1.0.27 → 2.0.0
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/.turbo/turbo-build.log +13 -0
- package/CHANGELOG.md +15 -0
- package/build/index.d.ts +2 -3
- package/build/index.js +38 -17073
- package/build/index.js.map +1 -1
- package/package.json +13 -29
- package/src/index.ts +26 -214
- package/tsup.config.mjs +0 -42
- package/build-browser-runtime/setup.d.ts +0 -5
- package/build-browser-runtime/setup.js +0 -129
- package/build-runtime/chunk-B6RICTPP.js +0 -94
- package/build-runtime/chunk-HPW4ZAEJ.js +0 -23
- package/build-runtime/chunk-MLKGABMK.js +0 -9
- package/build-runtime/chunk-NVTQFGTR.js +0 -7
- package/build-runtime/chunk-RKE6XT5Z.js +0 -3104
- package/build-runtime/chunk-UZPSWWI5.js +0 -13
- package/build-runtime/chunk-W73LN534.js +0 -24
- package/build-runtime/context/elevated.d.ts +0 -2
- package/build-runtime/context/elevated.js +0 -24
- package/build-runtime/context/nonElevated.d.ts +0 -2
- package/build-runtime/context/nonElevated.js +0 -37
- package/build-runtime/context/setupServicePlugin.d.ts +0 -5
- package/build-runtime/context/setupServicePlugin.js +0 -16
- package/build-runtime/context/setupWebhook.d.ts +0 -5
- package/build-runtime/context/setupWebhook.js +0 -16
- package/build-runtime/middleware/auth.d.ts +0 -5
- package/build-runtime/middleware/auth.js +0 -74
- package/build-runtime/middleware/html-embeds.d.ts +0 -5
- package/build-runtime/middleware/html-embeds.js +0 -588
- package/build-runtime/routes/auth/callback.d.ts +0 -5
- package/build-runtime/routes/auth/callback.js +0 -52
- package/build-runtime/routes/auth/login.d.ts +0 -5
- package/build-runtime/routes/auth/login.js +0 -45
- package/build-runtime/routes/auth/logout-callback.d.ts +0 -5
- package/build-runtime/routes/auth/logout-callback.js +0 -23
- package/build-runtime/routes/auth/logout.d.ts +0 -5
- package/build-runtime/routes/auth/logout.js +0 -32
- package/build-runtime/routes/servicePluginsDevRoute.d.ts +0 -5
- package/build-runtime/routes/servicePluginsDevRoute.js +0 -13
- package/build-runtime/routes/webhooksDevRoute.d.ts +0 -5
- package/build-runtime/routes/webhooksDevRoute.js +0 -13
- package/runtime/entry.astro +0 -26
- package/src/client-context/setup.ts +0 -14
- package/src/client-context/utils.ts +0 -59
- package/src/components.ts +0 -98
- package/src/constants.ts +0 -2
- package/src/context/elevated.ts +0 -20
- package/src/context/hostProxy.ts +0 -38
- package/src/context/nonElevated.ts +0 -42
- package/src/context/setupServicePlugin.ts +0 -13
- package/src/context/setupWebhook.ts +0 -13
- package/src/context/utils.ts +0 -32
- package/src/directories.ts +0 -5
- package/src/env.d.ts +0 -11
- package/src/middleware/auth.ts +0 -38
- package/src/middleware/html-embeds.ts +0 -59
- package/src/plugins/patchAstroInlineScripts.ts +0 -27
- package/src/plugins/setupSsrContext.ts +0 -65
- package/src/routes/auth/callback.ts +0 -51
- package/src/routes/auth/login.ts +0 -42
- package/src/routes/auth/logout-callback.ts +0 -18
- package/src/routes/auth/logout.ts +0 -28
- package/src/routes/servicePluginsDevRoute.ts +0 -10
- package/src/routes/webhooksDevRoute.ts +0 -10
- package/src/schemas.ts +0 -227
- package/src/types.ts +0 -9
- package/src/utils/authAsyncLocalStorage.ts +0 -7
- package/src/utils/buildBackofficeComponent.ts +0 -64
- package/src/utils/buildComponents.ts +0 -182
- package/src/utils/buildServicePluginComponent.ts +0 -52
- package/src/utils/buildWebhookComponent.ts +0 -39
- package/src/utils/contextualAuth.ts +0 -4
- package/src/utils/createProjectModel.ts +0 -190
- package/src/utils/fs-utils.ts +0 -48
- package/src/utils/generateAppManifest.ts +0 -177
- package/src/utils/generateVisitorTokens.ts +0 -11
- package/src/utils/getSessionTokensFromCookie.ts +0 -38
- package/src/utils/loadEnvVars.ts +0 -47
- package/src/utils/removeUnusedCodegenFiles.ts +0 -34
- package/src/utils/resolveBuildMetadata.ts +0 -37
- package/src/utils/saveSessionTokensToCookie.ts +0 -27
- package/src/utils/transformStreamUtils.ts +0 -39
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// src/constants.ts
|
|
2
|
-
var oAuthStateCookieName = "oAuthState";
|
|
3
|
-
var returnToQueryParamName = "returnTo";
|
|
4
|
-
|
|
5
|
-
// src/utils/contextualAuth.ts
|
|
6
|
-
import { auth as originalAuth } from "@wix/essentials";
|
|
7
|
-
var auth = originalAuth.getContextualAuth();
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
oAuthStateCookieName,
|
|
11
|
-
returnToQueryParamName,
|
|
12
|
-
auth
|
|
13
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// src/context/utils.ts
|
|
2
|
-
import { AppStrategy, createClient } from "@wix/sdk";
|
|
3
|
-
import { WIX_CLIENT_ID } from "astro:env/client";
|
|
4
|
-
import { WIX_CLIENT_PUBLIC_KEY, WIX_CLIENT_SECRET } from "astro:env/server";
|
|
5
|
-
async function setupClient(fn) {
|
|
6
|
-
const client = createClient({
|
|
7
|
-
auth: AppStrategy({
|
|
8
|
-
appId: WIX_CLIENT_ID,
|
|
9
|
-
appSecret: WIX_CLIENT_SECRET,
|
|
10
|
-
publicKey: WIX_CLIENT_PUBLIC_KEY
|
|
11
|
-
})
|
|
12
|
-
});
|
|
13
|
-
const olderClient = globalThis.__wix_context__.client;
|
|
14
|
-
client.enableContext("global");
|
|
15
|
-
await fn();
|
|
16
|
-
if (olderClient) {
|
|
17
|
-
olderClient.enableContext("global");
|
|
18
|
-
}
|
|
19
|
-
return client;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
setupClient
|
|
24
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createHostProxy
|
|
3
|
-
} from "../chunk-B6RICTPP.js";
|
|
4
|
-
import "../chunk-NVTQFGTR.js";
|
|
5
|
-
import "../chunk-MLKGABMK.js";
|
|
6
|
-
|
|
7
|
-
// src/context/elevated.ts
|
|
8
|
-
import { AppStrategy, createClient } from "@wix/sdk";
|
|
9
|
-
import { WIX_CLIENT_ID } from "astro:env/client";
|
|
10
|
-
import {
|
|
11
|
-
WIX_CLIENT_INSTANCE_ID,
|
|
12
|
-
WIX_CLIENT_PUBLIC_KEY,
|
|
13
|
-
WIX_CLIENT_SECRET
|
|
14
|
-
} from "astro:env/server";
|
|
15
|
-
var elevatedContextClient = createClient({
|
|
16
|
-
auth: AppStrategy({
|
|
17
|
-
appId: WIX_CLIENT_ID,
|
|
18
|
-
appSecret: WIX_CLIENT_SECRET,
|
|
19
|
-
instanceId: WIX_CLIENT_INSTANCE_ID,
|
|
20
|
-
publicKey: WIX_CLIENT_PUBLIC_KEY
|
|
21
|
-
}),
|
|
22
|
-
host: createHostProxy()
|
|
23
|
-
});
|
|
24
|
-
elevatedContextClient.enableContext("global", { elevated: true });
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createHostProxy
|
|
3
|
-
} from "../chunk-B6RICTPP.js";
|
|
4
|
-
import {
|
|
5
|
-
authAsyncLocalStorage
|
|
6
|
-
} from "../chunk-NVTQFGTR.js";
|
|
7
|
-
import "../chunk-MLKGABMK.js";
|
|
8
|
-
|
|
9
|
-
// src/context/nonElevated.ts
|
|
10
|
-
import { createClient, OAuthStrategy } from "@wix/sdk";
|
|
11
|
-
import { WIX_CLIENT_ID } from "astro:env/client";
|
|
12
|
-
var authProxy = new Proxy(
|
|
13
|
-
{},
|
|
14
|
-
{
|
|
15
|
-
get(target, prop) {
|
|
16
|
-
const auth = OAuthStrategy({
|
|
17
|
-
clientId: WIX_CLIENT_ID
|
|
18
|
-
});
|
|
19
|
-
const value = auth[prop];
|
|
20
|
-
if (typeof value !== "function") {
|
|
21
|
-
return value;
|
|
22
|
-
}
|
|
23
|
-
return function(...args) {
|
|
24
|
-
const store = authAsyncLocalStorage.getStore();
|
|
25
|
-
if (store?.sessionTokens) {
|
|
26
|
-
auth.setTokens(store.sessionTokens);
|
|
27
|
-
}
|
|
28
|
-
return value.apply(auth, args);
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
var contextClient = createClient({
|
|
34
|
-
auth: authProxy,
|
|
35
|
-
host: createHostProxy()
|
|
36
|
-
});
|
|
37
|
-
contextClient.enableContext("global");
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
setupClient
|
|
3
|
-
} from "../chunk-W73LN534.js";
|
|
4
|
-
import "../chunk-MLKGABMK.js";
|
|
5
|
-
|
|
6
|
-
// src/context/setupServicePlugin.ts
|
|
7
|
-
async function setupServicePlugin(fn) {
|
|
8
|
-
const client = await setupClient(fn);
|
|
9
|
-
return async function(context) {
|
|
10
|
-
await client.servicePlugins.processRequest(context.request);
|
|
11
|
-
return new Response("OK");
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
setupServicePlugin
|
|
16
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
setupClient
|
|
3
|
-
} from "../chunk-W73LN534.js";
|
|
4
|
-
import "../chunk-MLKGABMK.js";
|
|
5
|
-
|
|
6
|
-
// src/context/setupWebhook.ts
|
|
7
|
-
async function setupWebhook(fn) {
|
|
8
|
-
const client = await setupClient(fn);
|
|
9
|
-
return async function(context) {
|
|
10
|
-
await client.webhooks.processRequest(context.request);
|
|
11
|
-
return new Response("OK");
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
setupWebhook
|
|
16
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
saveSessionTokensToCookie
|
|
3
|
-
} from "../chunk-HPW4ZAEJ.js";
|
|
4
|
-
import {
|
|
5
|
-
authAsyncLocalStorage
|
|
6
|
-
} from "../chunk-NVTQFGTR.js";
|
|
7
|
-
import "../chunk-MLKGABMK.js";
|
|
8
|
-
|
|
9
|
-
// src/utils/generateVisitorTokens.ts
|
|
10
|
-
import { OAuthStrategy } from "@wix/sdk";
|
|
11
|
-
import { WIX_CLIENT_ID } from "astro:env/client";
|
|
12
|
-
var auth = OAuthStrategy({
|
|
13
|
-
clientId: WIX_CLIENT_ID
|
|
14
|
-
});
|
|
15
|
-
async function generateVisitorTokens() {
|
|
16
|
-
return auth.generateVisitorTokens();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// src/utils/getSessionTokensFromCookie.ts
|
|
20
|
-
import { TokenRole } from "@wix/sdk";
|
|
21
|
-
import { z } from "astro/zod";
|
|
22
|
-
import { WIX_CLIENT_ID as WIX_CLIENT_ID2 } from "astro:env/client";
|
|
23
|
-
var tokensSchema = z.object({
|
|
24
|
-
clientId: z.string(),
|
|
25
|
-
tokens: z.object({
|
|
26
|
-
accessToken: z.object({
|
|
27
|
-
expiresAt: z.number(),
|
|
28
|
-
value: z.string()
|
|
29
|
-
}),
|
|
30
|
-
refreshToken: z.object({
|
|
31
|
-
role: z.nativeEnum(TokenRole),
|
|
32
|
-
value: z.string()
|
|
33
|
-
})
|
|
34
|
-
})
|
|
35
|
-
});
|
|
36
|
-
function getSessionTokensFromCookie(context) {
|
|
37
|
-
if (!context.isPrerendered) {
|
|
38
|
-
const rawCookie = context.cookies.get("wixSession")?.json();
|
|
39
|
-
if (rawCookie != null) {
|
|
40
|
-
const tokensParseResult = tokensSchema.safeParse(rawCookie);
|
|
41
|
-
if (tokensParseResult.success && tokensParseResult.data.clientId === WIX_CLIENT_ID2) {
|
|
42
|
-
return tokensParseResult.data.tokens;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// src/middleware/auth.ts
|
|
50
|
-
var onRequest = async (context, next) => {
|
|
51
|
-
const existingTokens = getExistingTokens(context);
|
|
52
|
-
const usedTokens = existingTokens ?? await generateVisitorTokens();
|
|
53
|
-
const store = {
|
|
54
|
-
request: context.request,
|
|
55
|
-
sessionTokens: usedTokens
|
|
56
|
-
};
|
|
57
|
-
const response = await authAsyncLocalStorage.run(store, async () => {
|
|
58
|
-
return next();
|
|
59
|
-
});
|
|
60
|
-
if (!context.isPrerendered && existingTokens !== usedTokens) {
|
|
61
|
-
saveSessionTokensToCookie(context, usedTokens);
|
|
62
|
-
}
|
|
63
|
-
return response;
|
|
64
|
-
};
|
|
65
|
-
function getExistingTokens(context) {
|
|
66
|
-
const existingTokens = getSessionTokensFromCookie(context);
|
|
67
|
-
if (existingTokens && existingTokens.accessToken.expiresAt + 600 > Date.now() / 1e3) {
|
|
68
|
-
return existingTokens;
|
|
69
|
-
}
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
export {
|
|
73
|
-
onRequest
|
|
74
|
-
};
|