@wix/astro 2.27.0 → 2.28.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/build/dependencies/astro-auth/backend-runtime/constants-Dbkf3D5f.mjs +6 -0
- package/build/dependencies/astro-auth/backend-runtime/elevatedContextualClient-tJx9dIn_.mjs +41 -0
- package/build/dependencies/astro-auth/backend-runtime/host-utils-B2Fs_Z4S.mjs +17 -0
- package/build/dependencies/astro-auth/backend-runtime/middleware/auth.d.mts +6 -0
- package/build/dependencies/astro-auth/backend-runtime/middleware/auth.mjs +3643 -0
- package/build/dependencies/astro-auth/backend-runtime/middleware/localization.d.mts +6 -0
- package/build/dependencies/astro-auth/backend-runtime/middleware/localization.mjs +193 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/callback.d.mts +6 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/callback.mjs +34 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/login.d.mts +6 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/login.mjs +32 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/logout-callback.d.mts +6 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/logout-callback.mjs +14 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/logout.d.mts +6 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/logout.mjs +19 -0
- package/build/dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.d.mts +1 -0
- package/build/dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.mjs +8 -0
- package/build/dependencies/astro-auth/backend-runtime/saveSessionTokensToCookie-DK3xvtzk.mjs +24 -0
- package/build/dependencies/astro-auth/backend-runtime/schemas-XrMhpOYn.mjs +2771 -0
- package/build/dependencies/astro-auth/browser-runtime/setup.d.ts +4 -3
- package/build/dependencies/astro-auth/browser-runtime/setup.js +55 -81
- package/build/dependencies/astro-backend-extensions/backend-runtime/routes/extensions.d.mts +6 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/routes/extensions.mjs +37 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.d.mts +10 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.mjs +22 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.d.mts +9 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.mjs +22 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/utils-DDHGZHjR.mjs +56 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/utils-mYlwmIjd.d.mts +6 -0
- package/build/dependencies/astro-backoffice-extensions/browser-runtime/wrapComponent.d.ts +4 -3
- package/build/dependencies/astro-backoffice-extensions/browser-runtime/wrapComponent.js +6 -5
- package/build/dependencies/astro-context-providers-extensions/browser-runtime/hmr.d.ts +10 -0
- package/build/dependencies/astro-context-providers-extensions/browser-runtime/hmr.js +20 -23
- package/build/dependencies/astro-context-providers-extensions/browser-runtime/sdk.d.ts +9 -0
- package/build/dependencies/astro-context-providers-extensions/browser-runtime/sdk.js +16 -15
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/customElementHmr.d.ts +9 -5
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/customElementHmr.js +23 -40
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/reactHmr.d.ts +10 -1
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/reactHmr.js +20 -23
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/renderSettingsPanel.d.ts +4 -3
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/renderSettingsPanel.js +14 -18
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/wrapCustomElement.d.ts +9 -5
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/wrapCustomElement.js +23 -25
- package/build/dependencies/astro-embedded-scripts-extensions/browser-runtime/setupContext.d.ts +8 -4
- package/build/dependencies/astro-embedded-scripts-extensions/browser-runtime/setupContext.js +18 -17
- package/build/dependencies/astro-function-libraries-extensions/browser-runtime/sdk.d.ts +9 -0
- package/build/dependencies/astro-function-libraries-extensions/browser-runtime/sdk.js +16 -15
- package/build/dependencies/astro-html-embeds/backend-runtime/html-embeds.d.mts +6 -0
- package/build/dependencies/astro-html-embeds/backend-runtime/html-embeds.mjs +53 -0
- package/build/dependencies/astro-monitor/backend-runtime/monitor.d.mts +6 -0
- package/build/dependencies/astro-monitor/backend-runtime/monitor.mjs +43 -0
- package/build/dependencies/astro-payment-links/backend-runtime/elevate-CDDLuCIf.mjs +9 -0
- package/build/dependencies/astro-payment-links/backend-runtime/payment-checkout.d.mts +6 -0
- package/build/dependencies/astro-payment-links/backend-runtime/payment-checkout.mjs +20 -0
- package/build/dependencies/astro-payment-links/backend-runtime/payment-link.d.mts +6 -0
- package/build/dependencies/astro-payment-links/backend-runtime/payment-link.mjs +15 -0
- package/build/dependencies/astro-payment-links/backend-runtime/proposal.d.mts +6 -0
- package/build/dependencies/astro-payment-links/backend-runtime/proposal.mjs +20 -0
- package/build/dependencies/astro-robots/backend-runtime/robots.d.mts +6 -0
- package/build/dependencies/astro-robots/backend-runtime/robots.mjs +26 -0
- package/build/dependencies/astro-site-component-panels-extensions/browser-runtime/hmr.d.ts +10 -0
- package/build/dependencies/astro-site-component-panels-extensions/browser-runtime/hmr.js +20 -23
- package/build/dependencies/astro-site-component-panels-extensions/browser-runtime/sdk.d.ts +12 -0
- package/build/dependencies/astro-site-component-panels-extensions/browser-runtime/sdk.js +10 -10
- package/build/dependencies/astro-site-components-extensions/browser-runtime/hmr.d.ts +10 -0
- package/build/dependencies/astro-site-components-extensions/browser-runtime/hmr.js +20 -23
- package/build/dependencies/astro-site-components-extensions/browser-runtime/sdk.d.ts +9 -0
- package/build/dependencies/astro-site-components-extensions/browser-runtime/sdk.js +16 -15
- package/build/dependencies/astro-translations/backend-runtime/middleware/static-translations.d.mts +6 -0
- package/build/dependencies/astro-translations/backend-runtime/middleware/static-translations.mjs +177 -0
- package/build/dependencies/astro-translations/backend-runtime/runtime/{i18n.d.ts → i18n.d.mts} +3 -2
- package/build/dependencies/astro-translations/backend-runtime/runtime/i18n.mjs +38 -0
- package/build/dependencies/astro-translations/integration/index.d.mts +105 -0
- package/build/dependencies/astro-translations/integration/index.mjs +264 -0
- package/build/dependencies/astro-trusted-backoffice-extensions/browser-runtime/hmr.d.ts +10 -1
- package/build/dependencies/astro-trusted-backoffice-extensions/browser-runtime/hmr.js +20 -23
- package/build/dependencies/astro-trusted-backoffice-extensions/browser-runtime/wrapComponent.d.ts +12 -8
- package/build/dependencies/astro-trusted-backoffice-extensions/browser-runtime/wrapComponent.js +25 -35
- package/build/dependencies/astro-viewer-api/backend-runtime/api.d.mts +6 -0
- package/build/dependencies/astro-viewer-api/backend-runtime/api.mjs +27 -0
- package/build/dependencies/astro-viewer-services-extensions/browser-runtime/sdk.d.ts +9 -0
- package/build/dependencies/astro-viewer-services-extensions/browser-runtime/sdk.js +16 -15
- package/build/integration/builders-B9yQdgSz.mjs +76 -0
- package/build/integration/builders-DP0350YQ.d.mts +121 -0
- package/build/integration/builders-DVfxT6EC.mjs +225 -0
- package/build/integration/builders-experimental.d.mts +56 -0
- package/build/integration/builders-experimental.mjs +26 -0
- package/build/integration/builders-trusted.d.mts +75 -0
- package/build/integration/builders-trusted.mjs +46 -0
- package/build/integration/builders.d.mts +4 -0
- package/build/integration/builders.mjs +4 -0
- package/build/integration/index-B3B_5bgh.d.mts +248 -0
- package/build/integration/index-D5k6Bmue.d.mts +32 -0
- package/build/integration/index.d.mts +35 -0
- package/build/integration/index.mjs +29236 -0
- package/package.json +12 -12
- package/build/dependencies/astro-auth/backend-runtime/chunk-24J7STEA.js +0 -8
- package/build/dependencies/astro-auth/backend-runtime/chunk-352W54SQ.js +0 -70
- package/build/dependencies/astro-auth/backend-runtime/chunk-BIARYLOZ.js +0 -3267
- package/build/dependencies/astro-auth/backend-runtime/chunk-DZHZMKUF.js +0 -26
- package/build/dependencies/astro-auth/backend-runtime/chunk-MLKGABMK.js +0 -9
- package/build/dependencies/astro-auth/backend-runtime/chunk-USQSPPTM.js +0 -14
- package/build/dependencies/astro-auth/backend-runtime/middleware/auth.d.ts +0 -5
- package/build/dependencies/astro-auth/backend-runtime/middleware/auth.js +0 -136
- package/build/dependencies/astro-auth/backend-runtime/middleware/localization.d.ts +0 -5
- package/build/dependencies/astro-auth/backend-runtime/middleware/localization.js +0 -219
- package/build/dependencies/astro-auth/backend-runtime/routes/callback.d.ts +0 -5
- package/build/dependencies/astro-auth/backend-runtime/routes/callback.js +0 -53
- package/build/dependencies/astro-auth/backend-runtime/routes/login.d.ts +0 -5
- package/build/dependencies/astro-auth/backend-runtime/routes/login.js +0 -46
- package/build/dependencies/astro-auth/backend-runtime/routes/logout-callback.d.ts +0 -5
- package/build/dependencies/astro-auth/backend-runtime/routes/logout-callback.js +0 -24
- package/build/dependencies/astro-auth/backend-runtime/routes/logout.d.ts +0 -5
- package/build/dependencies/astro-auth/backend-runtime/routes/logout.js +0 -33
- package/build/dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.d.ts +0 -2
- package/build/dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.js +0 -10
- package/build/dependencies/astro-backend-extensions/backend-runtime/chunk-CPGTXQVH.js +0 -75
- package/build/dependencies/astro-backend-extensions/backend-runtime/routes/extensions.d.ts +0 -5
- package/build/dependencies/astro-backend-extensions/backend-runtime/routes/extensions.js +0 -41
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.d.ts +0 -10
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.js +0 -35
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.d.ts +0 -9
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.js +0 -34
- package/build/dependencies/astro-backend-extensions/backend-runtime/utils-B7jr2PES.d.ts +0 -5
- package/build/dependencies/astro-backend-extensions/types/index.d.ts +0 -102
- package/build/dependencies/astro-backoffice-extensions/types/index.d.ts +0 -68
- package/build/dependencies/astro-context-providers-extensions/types/index.d.ts +0 -32
- package/build/dependencies/astro-core/types/index.d.ts +0 -109
- package/build/dependencies/astro-custom-elements-extensions/types/index.d.ts +0 -45
- package/build/dependencies/astro-embedded-scripts-extensions/types/index.d.ts +0 -18
- package/build/dependencies/astro-function-libraries-extensions/types/index.d.ts +0 -23
- package/build/dependencies/astro-html-embeds/backend-runtime/html-embeds.d.ts +0 -5
- package/build/dependencies/astro-html-embeds/backend-runtime/html-embeds.js +0 -66
- package/build/dependencies/astro-payment-links/backend-runtime/chunk-656BVIJ3.js +0 -9
- package/build/dependencies/astro-payment-links/backend-runtime/payment-checkout.d.ts +0 -5
- package/build/dependencies/astro-payment-links/backend-runtime/payment-checkout.js +0 -24
- package/build/dependencies/astro-payment-links/backend-runtime/payment-link.d.ts +0 -5
- package/build/dependencies/astro-payment-links/backend-runtime/payment-link.js +0 -20
- package/build/dependencies/astro-payment-links/backend-runtime/proposal.d.ts +0 -5
- package/build/dependencies/astro-payment-links/backend-runtime/proposal.js +0 -24
- package/build/dependencies/astro-robots/backend-runtime/robots.d.ts +0 -5
- package/build/dependencies/astro-robots/backend-runtime/robots.js +0 -38
- package/build/dependencies/astro-site-component-panels-extensions/types/index.d.ts +0 -21
- package/build/dependencies/astro-site-components-extensions/types/index.d.ts +0 -48
- package/build/dependencies/astro-translations/backend-runtime/middleware/static-translations.d.ts +0 -5
- package/build/dependencies/astro-translations/backend-runtime/middleware/static-translations.js +0 -189
- package/build/dependencies/astro-translations/backend-runtime/runtime/i18n.js +0 -42
- package/build/dependencies/astro-translations/integration/index.d.ts +0 -5
- package/build/dependencies/astro-translations/integration/index.js +0 -296
- package/build/dependencies/astro-trusted-backoffice-extensions/types/index.d.ts +0 -50
- package/build/dependencies/astro-viewer-api/backend-runtime/api.d.ts +0 -5
- package/build/dependencies/astro-viewer-api/backend-runtime/api.js +0 -34
- package/build/dependencies/astro-viewer-services-extensions/types/index.d.ts +0 -27
- package/build/integration/builders-experimental.d.ts +0 -53
- package/build/integration/builders-experimental.js +0 -20
- package/build/integration/builders-experimental.js.map +0 -1
- package/build/integration/builders-trusted.d.ts +0 -69
- package/build/integration/builders-trusted.js +0 -52
- package/build/integration/builders-trusted.js.map +0 -1
- package/build/integration/builders.d.ts +0 -112
- package/build/integration/builders.js +0 -14
- package/build/integration/builders.js.map +0 -1
- package/build/integration/chunk-23MOLCVI.js +0 -1087
- package/build/integration/chunk-23MOLCVI.js.map +0 -1
- package/build/integration/chunk-6UOFHB2M.js +0 -386
- package/build/integration/chunk-6UOFHB2M.js.map +0 -1
- package/build/integration/chunk-L6JEDTVM.js +0 -7458
- package/build/integration/chunk-L6JEDTVM.js.map +0 -1
- package/build/integration/chunk-MNQWQ2MC.js +0 -809
- package/build/integration/chunk-MNQWQ2MC.js.map +0 -1
- package/build/integration/chunk-XN6SBNMI.js +0 -23758
- package/build/integration/chunk-XN6SBNMI.js.map +0 -1
- package/build/integration/index.d-BUVlSCHa.d.ts +0 -211
- package/build/integration/index.d-D4c48TR0.d.ts +0 -58
- package/build/integration/index.d.ts +0 -34
- package/build/integration/index.js +0 -498
- package/build/integration/index.js.map +0 -1
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// src/utils/saveSessionTokensToCookie.ts
|
|
2
|
-
import { WIX_CLIENT_ID } from "astro:env/client";
|
|
3
|
-
|
|
4
|
-
// src/utils/sessionCookie.ts
|
|
5
|
-
var SESSION_COOKIE_NAME = "wixSession";
|
|
6
|
-
var SESSION_COOKIE_OPTIONS = {
|
|
7
|
-
path: "/",
|
|
8
|
-
secure: true,
|
|
9
|
-
...import.meta.env.DEV && {
|
|
10
|
-
maxAge: 10800,
|
|
11
|
-
sameSite: "none"
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// src/utils/saveSessionTokensToCookie.ts
|
|
16
|
-
function saveSessionTokensToCookie(context, tokens) {
|
|
17
|
-
context.cookies.set(
|
|
18
|
-
SESSION_COOKIE_NAME,
|
|
19
|
-
{ clientId: WIX_CLIENT_ID, tokens },
|
|
20
|
-
SESSION_COOKIE_OPTIONS
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export {
|
|
25
|
-
saveSessionTokensToCookie
|
|
26
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// src/utils/authAsyncLocalStorage.ts
|
|
2
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
3
|
-
var authAsyncLocalStorage = new AsyncLocalStorage();
|
|
4
|
-
|
|
5
|
-
// src/utils/host-utils.ts
|
|
6
|
-
import { headlessNode } from "@wix/headless-node";
|
|
7
|
-
function createHost(request, essentials) {
|
|
8
|
-
return headlessNode.host({ essentials, req: request });
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
authAsyncLocalStorage,
|
|
13
|
-
createHost
|
|
14
|
-
};
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
saveSessionTokensToCookie
|
|
3
|
-
} from "../chunk-DZHZMKUF.js";
|
|
4
|
-
import {
|
|
5
|
-
contextualClient,
|
|
6
|
-
elevatedContextualClient
|
|
7
|
-
} from "../chunk-352W54SQ.js";
|
|
8
|
-
import {
|
|
9
|
-
authAsyncLocalStorage,
|
|
10
|
-
createHost
|
|
11
|
-
} from "../chunk-USQSPPTM.js";
|
|
12
|
-
import "../chunk-MLKGABMK.js";
|
|
13
|
-
|
|
14
|
-
// src/middleware/auth.ts
|
|
15
|
-
import { AppStrategy, OAuthStrategy as OAuthStrategy2 } from "@wix/sdk";
|
|
16
|
-
import { WIX_CLIENT_ID as WIX_CLIENT_ID3 } from "astro:env/client";
|
|
17
|
-
import {
|
|
18
|
-
WIX_CLIENT_INSTANCE_ID,
|
|
19
|
-
WIX_CLIENT_PUBLIC_KEY,
|
|
20
|
-
WIX_CLIENT_SECRET
|
|
21
|
-
} from "astro:env/server";
|
|
22
|
-
|
|
23
|
-
// src/utils/generateVisitorTokens.ts
|
|
24
|
-
import { OAuthStrategy } from "@wix/sdk";
|
|
25
|
-
import { WIX_CLIENT_ID } from "astro:env/client";
|
|
26
|
-
var auth = OAuthStrategy({
|
|
27
|
-
clientId: WIX_CLIENT_ID
|
|
28
|
-
});
|
|
29
|
-
async function generateVisitorTokens() {
|
|
30
|
-
return auth.generateVisitorTokens();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// src/utils/getSessionTokensFromCookie.ts
|
|
34
|
-
import { TokenRole } from "@wix/sdk";
|
|
35
|
-
import { z } from "astro/zod";
|
|
36
|
-
import { WIX_CLIENT_ID as WIX_CLIENT_ID2 } from "astro:env/client";
|
|
37
|
-
var tokensSchema = z.object({
|
|
38
|
-
clientId: z.string(),
|
|
39
|
-
tokens: z.object({
|
|
40
|
-
accessToken: z.object({
|
|
41
|
-
expiresAt: z.number(),
|
|
42
|
-
value: z.string()
|
|
43
|
-
}),
|
|
44
|
-
refreshToken: z.object({
|
|
45
|
-
role: z.nativeEnum(TokenRole),
|
|
46
|
-
value: z.string()
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
});
|
|
50
|
-
function getSessionTokensFromCookie(context) {
|
|
51
|
-
if (!context.isPrerendered) {
|
|
52
|
-
const rawCookie = context.cookies.get("wixSession")?.json();
|
|
53
|
-
if (rawCookie != null) {
|
|
54
|
-
const tokensParseResult = tokensSchema.safeParse(rawCookie);
|
|
55
|
-
if (tokensParseResult.success && tokensParseResult.data.clientId === WIX_CLIENT_ID2) {
|
|
56
|
-
return tokensParseResult.data.tokens;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// src/middleware/auth.ts
|
|
64
|
-
contextualClient.enableContext("module");
|
|
65
|
-
elevatedContextualClient.enableContext("module", { elevated: true });
|
|
66
|
-
var onRequest = async (context, next) => {
|
|
67
|
-
if (context.url.pathname.startsWith("/_wix/extensions/")) {
|
|
68
|
-
return next();
|
|
69
|
-
}
|
|
70
|
-
const accessToken = context.request.headers.get("Authorization");
|
|
71
|
-
if (accessToken != null) {
|
|
72
|
-
const auth2 = AppStrategy({
|
|
73
|
-
accessToken,
|
|
74
|
-
appId: WIX_CLIENT_ID3
|
|
75
|
-
});
|
|
76
|
-
const elevatedAuth = await auth2.elevated();
|
|
77
|
-
return authAsyncLocalStorage.run(
|
|
78
|
-
{
|
|
79
|
-
auth: auth2,
|
|
80
|
-
elevatedAuth,
|
|
81
|
-
sdkHost: createHost(context.request)
|
|
82
|
-
},
|
|
83
|
-
async () => next()
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
const existingToken = getExistingTokens(context);
|
|
87
|
-
if (existingToken) {
|
|
88
|
-
return authAsyncLocalStorage.run(
|
|
89
|
-
{
|
|
90
|
-
auth: OAuthStrategy2({
|
|
91
|
-
clientId: WIX_CLIENT_ID3,
|
|
92
|
-
tokens: existingToken
|
|
93
|
-
}),
|
|
94
|
-
elevatedAuth: AppStrategy({
|
|
95
|
-
appId: WIX_CLIENT_ID3,
|
|
96
|
-
appSecret: WIX_CLIENT_SECRET,
|
|
97
|
-
instanceId: WIX_CLIENT_INSTANCE_ID,
|
|
98
|
-
publicKey: WIX_CLIENT_PUBLIC_KEY
|
|
99
|
-
}),
|
|
100
|
-
sdkHost: createHost(context.request)
|
|
101
|
-
},
|
|
102
|
-
async () => next()
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
const visitorToken = await generateVisitorTokens();
|
|
106
|
-
if (context.request.headers.get("Accept")?.includes("text/html") && !context.isPrerendered) {
|
|
107
|
-
saveSessionTokensToCookie(context, visitorToken);
|
|
108
|
-
}
|
|
109
|
-
const response = await authAsyncLocalStorage.run(
|
|
110
|
-
{
|
|
111
|
-
auth: OAuthStrategy2({
|
|
112
|
-
clientId: WIX_CLIENT_ID3,
|
|
113
|
-
tokens: visitorToken
|
|
114
|
-
}),
|
|
115
|
-
elevatedAuth: AppStrategy({
|
|
116
|
-
appId: WIX_CLIENT_ID3,
|
|
117
|
-
appSecret: WIX_CLIENT_SECRET,
|
|
118
|
-
instanceId: WIX_CLIENT_INSTANCE_ID,
|
|
119
|
-
publicKey: WIX_CLIENT_PUBLIC_KEY
|
|
120
|
-
}),
|
|
121
|
-
sdkHost: createHost(context.request)
|
|
122
|
-
},
|
|
123
|
-
async () => next()
|
|
124
|
-
);
|
|
125
|
-
return response;
|
|
126
|
-
};
|
|
127
|
-
function getExistingTokens(context) {
|
|
128
|
-
const existingTokens = getSessionTokensFromCookie(context);
|
|
129
|
-
if (existingTokens && existingTokens.accessToken.expiresAt + 600 > Date.now() / 1e3) {
|
|
130
|
-
return existingTokens;
|
|
131
|
-
}
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
export {
|
|
135
|
-
onRequest
|
|
136
|
-
};
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
authAsyncLocalStorage,
|
|
3
|
-
createHost
|
|
4
|
-
} from "../chunk-USQSPPTM.js";
|
|
5
|
-
import "../chunk-MLKGABMK.js";
|
|
6
|
-
|
|
7
|
-
// ../request-transform-utils/src/transformStreamUtils.ts
|
|
8
|
-
function injectBeforeTransformStream(predicate, htmlToInject) {
|
|
9
|
-
let hasInjected = false;
|
|
10
|
-
return new TransformStream({
|
|
11
|
-
transform: (chunk, controller) => {
|
|
12
|
-
if (!hasInjected) {
|
|
13
|
-
const index = chunk.indexOf(predicate);
|
|
14
|
-
if (index > -1) {
|
|
15
|
-
chunk = chunk.slice(0, index) + htmlToInject + chunk.slice(index);
|
|
16
|
-
hasInjected = true;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
controller.enqueue(chunk);
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// ../request-transform-utils/src/index.ts
|
|
25
|
-
var headTransformStream = (htmlToInject) => injectBeforeTransformStream("</head>", htmlToInject);
|
|
26
|
-
|
|
27
|
-
// ../../node_modules/outdent/lib-module/index.js
|
|
28
|
-
function noop() {
|
|
29
|
-
var args = [];
|
|
30
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
31
|
-
args[_i] = arguments[_i];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function createWeakMap() {
|
|
35
|
-
if (typeof WeakMap !== "undefined") {
|
|
36
|
-
return /* @__PURE__ */ new WeakMap();
|
|
37
|
-
} else {
|
|
38
|
-
return fakeSetOrMap();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function fakeSetOrMap() {
|
|
42
|
-
return {
|
|
43
|
-
add: noop,
|
|
44
|
-
delete: noop,
|
|
45
|
-
get: noop,
|
|
46
|
-
set: noop,
|
|
47
|
-
has: function(k) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
var hop = Object.prototype.hasOwnProperty;
|
|
53
|
-
var has = function(obj, prop) {
|
|
54
|
-
return hop.call(obj, prop);
|
|
55
|
-
};
|
|
56
|
-
function extend(target, source) {
|
|
57
|
-
for (var prop in source) {
|
|
58
|
-
if (has(source, prop)) {
|
|
59
|
-
target[prop] = source[prop];
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return target;
|
|
63
|
-
}
|
|
64
|
-
var reLeadingNewline = /^[ \t]*(?:\r\n|\r|\n)/;
|
|
65
|
-
var reTrailingNewline = /(?:\r\n|\r|\n)[ \t]*$/;
|
|
66
|
-
var reStartsWithNewlineOrIsEmpty = /^(?:[\r\n]|$)/;
|
|
67
|
-
var reDetectIndentation = /(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/;
|
|
68
|
-
var reOnlyWhitespaceWithAtLeastOneNewline = /^[ \t]*[\r\n][ \t\r\n]*$/;
|
|
69
|
-
function _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options) {
|
|
70
|
-
var indentationLevel = 0;
|
|
71
|
-
var match = strings[0].match(reDetectIndentation);
|
|
72
|
-
if (match) {
|
|
73
|
-
indentationLevel = match[1].length;
|
|
74
|
-
}
|
|
75
|
-
var reSource = "(\\r\\n|\\r|\\n).{0," + indentationLevel + "}";
|
|
76
|
-
var reMatchIndent = new RegExp(reSource, "g");
|
|
77
|
-
if (firstInterpolatedValueSetsIndentationLevel) {
|
|
78
|
-
strings = strings.slice(1);
|
|
79
|
-
}
|
|
80
|
-
var newline = options.newline, trimLeadingNewline = options.trimLeadingNewline, trimTrailingNewline = options.trimTrailingNewline;
|
|
81
|
-
var normalizeNewlines = typeof newline === "string";
|
|
82
|
-
var l = strings.length;
|
|
83
|
-
var outdentedStrings = strings.map(function(v, i) {
|
|
84
|
-
v = v.replace(reMatchIndent, "$1");
|
|
85
|
-
if (i === 0 && trimLeadingNewline) {
|
|
86
|
-
v = v.replace(reLeadingNewline, "");
|
|
87
|
-
}
|
|
88
|
-
if (i === l - 1 && trimTrailingNewline) {
|
|
89
|
-
v = v.replace(reTrailingNewline, "");
|
|
90
|
-
}
|
|
91
|
-
if (normalizeNewlines) {
|
|
92
|
-
v = v.replace(/\r\n|\n|\r/g, function(_) {
|
|
93
|
-
return newline;
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return v;
|
|
97
|
-
});
|
|
98
|
-
return outdentedStrings;
|
|
99
|
-
}
|
|
100
|
-
function concatStringsAndValues(strings, values) {
|
|
101
|
-
var ret = "";
|
|
102
|
-
for (var i = 0, l = strings.length; i < l; i++) {
|
|
103
|
-
ret += strings[i];
|
|
104
|
-
if (i < l - 1) {
|
|
105
|
-
ret += values[i];
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return ret;
|
|
109
|
-
}
|
|
110
|
-
function isTemplateStringsArray(v) {
|
|
111
|
-
return has(v, "raw") && has(v, "length");
|
|
112
|
-
}
|
|
113
|
-
function createInstance(options) {
|
|
114
|
-
var arrayAutoIndentCache = createWeakMap();
|
|
115
|
-
var arrayFirstInterpSetsIndentCache = createWeakMap();
|
|
116
|
-
function outdent(stringsOrOptions) {
|
|
117
|
-
var values = [];
|
|
118
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
119
|
-
values[_i - 1] = arguments[_i];
|
|
120
|
-
}
|
|
121
|
-
if (isTemplateStringsArray(stringsOrOptions)) {
|
|
122
|
-
var strings = stringsOrOptions;
|
|
123
|
-
var firstInterpolatedValueSetsIndentationLevel = (values[0] === outdent || values[0] === defaultOutdent) && reOnlyWhitespaceWithAtLeastOneNewline.test(strings[0]) && reStartsWithNewlineOrIsEmpty.test(strings[1]);
|
|
124
|
-
var cache = firstInterpolatedValueSetsIndentationLevel ? arrayFirstInterpSetsIndentCache : arrayAutoIndentCache;
|
|
125
|
-
var renderedArray = cache.get(strings);
|
|
126
|
-
if (!renderedArray) {
|
|
127
|
-
renderedArray = _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options);
|
|
128
|
-
cache.set(strings, renderedArray);
|
|
129
|
-
}
|
|
130
|
-
if (values.length === 0) {
|
|
131
|
-
return renderedArray[0];
|
|
132
|
-
}
|
|
133
|
-
var rendered = concatStringsAndValues(renderedArray, firstInterpolatedValueSetsIndentationLevel ? values.slice(1) : values);
|
|
134
|
-
return rendered;
|
|
135
|
-
} else {
|
|
136
|
-
return createInstance(extend(extend({}, options), stringsOrOptions || {}));
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
var fullOutdent = extend(outdent, {
|
|
140
|
-
string: function(str) {
|
|
141
|
-
return _outdentArray([str], false, options)[0];
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
return fullOutdent;
|
|
145
|
-
}
|
|
146
|
-
var defaultOutdent = createInstance({
|
|
147
|
-
trimLeadingNewline: true,
|
|
148
|
-
trimTrailingNewline: true
|
|
149
|
-
});
|
|
150
|
-
if (typeof module !== "undefined") {
|
|
151
|
-
try {
|
|
152
|
-
module.exports = defaultOutdent;
|
|
153
|
-
Object.defineProperty(defaultOutdent, "__esModule", { value: true });
|
|
154
|
-
defaultOutdent.default = defaultOutdent;
|
|
155
|
-
defaultOutdent.outdent = defaultOutdent;
|
|
156
|
-
} catch (e) {
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// src/utils/localizationUtils.ts
|
|
161
|
-
import {
|
|
162
|
-
getLocalizationData as getLocalizationDataFromUtils,
|
|
163
|
-
MULTILINGUAL_COOKIE_HEADER_KEY
|
|
164
|
-
} from "@wix/headless-localization-utils";
|
|
165
|
-
import { scripts } from "@wix/headless-site-assets";
|
|
166
|
-
async function getLocalizationData(context) {
|
|
167
|
-
return getLocalizationDataFromUtils(
|
|
168
|
-
context.url,
|
|
169
|
-
context.request.headers,
|
|
170
|
-
(await scripts.getSiteMetadata()).properties ?? {}
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
function setMultilingualCookie(context, language) {
|
|
174
|
-
if (context.cookies.get(MULTILINGUAL_COOKIE_HEADER_KEY)?.value !== language) {
|
|
175
|
-
context.cookies.set(MULTILINGUAL_COOKIE_HEADER_KEY, language, {
|
|
176
|
-
httpOnly: false,
|
|
177
|
-
path: "/",
|
|
178
|
-
sameSite: "lax"
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// src/middleware/localization.ts
|
|
184
|
-
var onRequest = async (context, next) => {
|
|
185
|
-
const store = authAsyncLocalStorage.getStore();
|
|
186
|
-
if (!store) {
|
|
187
|
-
return next();
|
|
188
|
-
}
|
|
189
|
-
let localizationData;
|
|
190
|
-
try {
|
|
191
|
-
localizationData = await getLocalizationData(context);
|
|
192
|
-
} catch {
|
|
193
|
-
return next();
|
|
194
|
-
}
|
|
195
|
-
const { cleanUrl, essentials } = localizationData;
|
|
196
|
-
if (essentials.language == null || essentials.multilingual === void 0) {
|
|
197
|
-
return next();
|
|
198
|
-
}
|
|
199
|
-
store.sdkHost = createHost(context.request, essentials);
|
|
200
|
-
setMultilingualCookie(context, essentials.language);
|
|
201
|
-
const nextResponse = cleanUrl !== context.url.href ? await next(cleanUrl) : await next();
|
|
202
|
-
return modifyHtmlEmbed(nextResponse, context, essentials);
|
|
203
|
-
};
|
|
204
|
-
function modifyHtmlEmbed(response, context, essentials) {
|
|
205
|
-
const contentType = response.headers.get("Content-Type");
|
|
206
|
-
if (contentType !== "text/html" || context.url.pathname.startsWith("/_wix") || !response.body) {
|
|
207
|
-
return response;
|
|
208
|
-
}
|
|
209
|
-
const essentialsScript = defaultOutdent`
|
|
210
|
-
<script>window.essentials = ${JSON.stringify(essentials)};</script>
|
|
211
|
-
`;
|
|
212
|
-
return new Response(
|
|
213
|
-
response.body.pipeThrough(new TextDecoderStream()).pipeThrough(headTransformStream(essentialsScript)).pipeThrough(new TextEncoderStream()),
|
|
214
|
-
response
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
export {
|
|
218
|
-
onRequest
|
|
219
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
saveSessionTokensToCookie
|
|
3
|
-
} from "../chunk-DZHZMKUF.js";
|
|
4
|
-
import {
|
|
5
|
-
object,
|
|
6
|
-
string
|
|
7
|
-
} from "../chunk-BIARYLOZ.js";
|
|
8
|
-
import {
|
|
9
|
-
oAuthStateCookieName
|
|
10
|
-
} from "../chunk-24J7STEA.js";
|
|
11
|
-
import "../chunk-MLKGABMK.js";
|
|
12
|
-
|
|
13
|
-
// src/routes/callback.ts
|
|
14
|
-
import { getContextualAuth } from "@wix/sdk-runtime/context";
|
|
15
|
-
var oauthCookieSchema = object({
|
|
16
|
-
codeChallenge: string(),
|
|
17
|
-
codeVerifier: string(),
|
|
18
|
-
originalUri: string(),
|
|
19
|
-
redirectUri: string(),
|
|
20
|
-
state: string()
|
|
21
|
-
});
|
|
22
|
-
var GET = async (context) => {
|
|
23
|
-
const oauthStateCookie = context.cookies.get(oAuthStateCookieName);
|
|
24
|
-
if (oauthStateCookie == null) {
|
|
25
|
-
throw new Error(`Missing \`${oAuthStateCookieName}\` cookie`);
|
|
26
|
-
}
|
|
27
|
-
const oauthData = oauthCookieSchema.parse(JSON.parse(oauthStateCookie.value));
|
|
28
|
-
if (!oauthData.originalUri.startsWith("/")) {
|
|
29
|
-
throw new Error(
|
|
30
|
-
"Invalid `originalUri` cookie param, only relative URLs are allowed"
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
const auth = getContextualAuth();
|
|
34
|
-
const { code, error, errorDescription, state } = auth.parseFromUrl(
|
|
35
|
-
context.url.toString(),
|
|
36
|
-
"query"
|
|
37
|
-
);
|
|
38
|
-
if (error != null) {
|
|
39
|
-
throw new Error(`Error while authenticating: \`${errorDescription}\``);
|
|
40
|
-
}
|
|
41
|
-
const memberTokens = await auth.getMemberTokens(code, state, oauthData);
|
|
42
|
-
context.cookies.delete(oAuthStateCookieName, {
|
|
43
|
-
httpOnly: true,
|
|
44
|
-
path: "/",
|
|
45
|
-
sameSite: "lax",
|
|
46
|
-
secure: true
|
|
47
|
-
});
|
|
48
|
-
saveSessionTokensToCookie(context, memberTokens);
|
|
49
|
-
return context.redirect(oauthData.originalUri);
|
|
50
|
-
};
|
|
51
|
-
export {
|
|
52
|
-
GET
|
|
53
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
_enum,
|
|
3
|
-
object,
|
|
4
|
-
string
|
|
5
|
-
} from "../chunk-BIARYLOZ.js";
|
|
6
|
-
import {
|
|
7
|
-
oAuthStateCookieName
|
|
8
|
-
} from "../chunk-24J7STEA.js";
|
|
9
|
-
import "../chunk-MLKGABMK.js";
|
|
10
|
-
|
|
11
|
-
// src/routes/login.ts
|
|
12
|
-
import { getContextualAuth } from "@wix/sdk-runtime/context";
|
|
13
|
-
var loginSearchParams = object({
|
|
14
|
-
prompt: _enum(["login", "none"]).optional(),
|
|
15
|
-
returnToUrl: string().optional()
|
|
16
|
-
});
|
|
17
|
-
var GET = async ({ request, url }) => {
|
|
18
|
-
const { prompt, returnToUrl = "/" } = loginSearchParams.parse(
|
|
19
|
-
Object.fromEntries(url.searchParams.entries())
|
|
20
|
-
);
|
|
21
|
-
const callbackUrl = new URL("/api/auth/callback", url);
|
|
22
|
-
const referer = request.headers.get("referer");
|
|
23
|
-
if (referer != null) {
|
|
24
|
-
const originalUrl = new URL(referer);
|
|
25
|
-
callbackUrl.protocol = originalUrl.protocol;
|
|
26
|
-
}
|
|
27
|
-
const auth = getContextualAuth();
|
|
28
|
-
const oauthData = auth.generateOAuthData(callbackUrl.toString(), returnToUrl);
|
|
29
|
-
const { authUrl } = await auth.getAuthUrl(oauthData, {
|
|
30
|
-
prompt,
|
|
31
|
-
responseMode: "query"
|
|
32
|
-
});
|
|
33
|
-
const sameSite = import.meta.env.DEV ? "None" : "Lax";
|
|
34
|
-
return new Response(null, {
|
|
35
|
-
headers: {
|
|
36
|
-
Location: authUrl,
|
|
37
|
-
"Set-Cookie": `${oAuthStateCookieName}=${JSON.stringify(
|
|
38
|
-
oauthData
|
|
39
|
-
)}; Max-Age=1800; Path=/; HttpOnly; Secure; SameSite=${sameSite}`
|
|
40
|
-
},
|
|
41
|
-
status: 302
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
export {
|
|
45
|
-
GET
|
|
46
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
saveSessionTokensToCookie
|
|
3
|
-
} from "../chunk-DZHZMKUF.js";
|
|
4
|
-
import {
|
|
5
|
-
returnToQueryParamName
|
|
6
|
-
} from "../chunk-24J7STEA.js";
|
|
7
|
-
import "../chunk-MLKGABMK.js";
|
|
8
|
-
|
|
9
|
-
// src/routes/logout-callback.ts
|
|
10
|
-
import { getContextualAuth } from "@wix/sdk-runtime/context";
|
|
11
|
-
var GET = async (context) => {
|
|
12
|
-
const returnTo = context.url.searchParams.get(returnToQueryParamName) ?? "/";
|
|
13
|
-
if (!returnTo.startsWith("/")) {
|
|
14
|
-
throw new Error(
|
|
15
|
-
`Invalid \`${returnToQueryParamName}\` query param, only relative URLs are allowed`
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
const auth = getContextualAuth();
|
|
19
|
-
saveSessionTokensToCookie(context, await auth.generateVisitorTokens());
|
|
20
|
-
return context.redirect(returnTo);
|
|
21
|
-
};
|
|
22
|
-
export {
|
|
23
|
-
GET
|
|
24
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
object,
|
|
3
|
-
string
|
|
4
|
-
} from "../chunk-BIARYLOZ.js";
|
|
5
|
-
import {
|
|
6
|
-
returnToQueryParamName
|
|
7
|
-
} from "../chunk-24J7STEA.js";
|
|
8
|
-
import "../chunk-MLKGABMK.js";
|
|
9
|
-
|
|
10
|
-
// src/routes/logout.ts
|
|
11
|
-
import { getContextualAuth } from "@wix/sdk-runtime/context";
|
|
12
|
-
var logoutSearchParams = object({
|
|
13
|
-
returnToUrl: string().optional()
|
|
14
|
-
});
|
|
15
|
-
var POST = async ({ redirect, request, url }) => {
|
|
16
|
-
const { returnToUrl = "/" } = logoutSearchParams.parse(
|
|
17
|
-
Object.fromEntries(url.searchParams.entries())
|
|
18
|
-
);
|
|
19
|
-
const baseUrl = `${new URL(request.url).origin}/${import.meta.env.BASE_URL}`;
|
|
20
|
-
const postFlowUrl = new URL("/api/auth/logout-callback", baseUrl);
|
|
21
|
-
const referer = request.headers.get("referer");
|
|
22
|
-
if (referer != null) {
|
|
23
|
-
const originalUrl = new URL(referer);
|
|
24
|
-
postFlowUrl.protocol = originalUrl.protocol;
|
|
25
|
-
}
|
|
26
|
-
postFlowUrl.searchParams.set(returnToQueryParamName, returnToUrl);
|
|
27
|
-
const auth = getContextualAuth();
|
|
28
|
-
const { logoutUrl } = await auth.logout(postFlowUrl.toString());
|
|
29
|
-
return redirect(logoutUrl);
|
|
30
|
-
};
|
|
31
|
-
export {
|
|
32
|
-
POST
|
|
33
|
-
};
|
package/build/dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
contextualClient,
|
|
3
|
-
elevatedContextualClient
|
|
4
|
-
} from "../../chunk-352W54SQ.js";
|
|
5
|
-
import "../../chunk-USQSPPTM.js";
|
|
6
|
-
import "../../chunk-MLKGABMK.js";
|
|
7
|
-
|
|
8
|
-
// src/runtime/backend/setupContextualClient.ts
|
|
9
|
-
contextualClient.enableContext("module");
|
|
10
|
-
elevatedContextualClient.enableContext("module", { elevated: true });
|