@wix/astro 1.0.32 → 1.0.34
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/package.json +8 -7
- package/src/index.ts +9 -0
- package/src/plugins/setupSsrContext.ts +3 -0
- package/src/routes/wix-apis/api.ts +31 -0
- package/tsup.config.mjs +3 -0
- package/build/index.d.ts +0 -9
- package/build/index.js +0 -17165
- package/build/index.js.map +0 -1
- package/build-browser-runtime/setup.d.ts +0 -5
- package/build-browser-runtime/setup.js +0 -849
- package/build-runtime/chunk-7EHL72JI.js +0 -1079
- package/build-runtime/chunk-EK7YZVWJ.js +0 -353
- package/build-runtime/chunk-HPW4ZAEJ.js +0 -23
- package/build-runtime/chunk-NKY4T53W.js +0 -709
- package/build-runtime/chunk-NVTQFGTR.js +0 -7
- package/build-runtime/chunk-PSHIUVP2.js +0 -131
- package/build-runtime/chunk-U67V476Y.js +0 -35
- package/build-runtime/chunk-UZPSWWI5.js +0 -13
- package/build-runtime/chunk-W73LN534.js +0 -24
- package/build-runtime/chunk-WE3ELMU5.js +0 -3104
- package/build-runtime/chunk-YX6EVX5Q.js +0 -11
- package/build-runtime/context/elevated.d.ts +0 -2
- package/build-runtime/context/elevated.js +0 -25
- package/build-runtime/context/nonElevated.d.ts +0 -2
- package/build-runtime/context/nonElevated.js +0 -38
- 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 -166
- 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/paylink/checkout.d.ts +0 -5
- package/build-runtime/routes/paylink/checkout.js +0 -35
- package/build-runtime/routes/paylink/paylink.d.ts +0 -5
- package/build-runtime/routes/paylink/paylink.js +0 -34
- package/build-runtime/routes/robots/robots.d.ts +0 -5
- package/build-runtime/routes/robots/robots.js +0 -44
- 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
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// src/utils/normalizeWixRedirectUrl.ts
|
|
2
|
-
function normalizeWixRedirectUrl({
|
|
3
|
-
wixRedirectUrl
|
|
4
|
-
}) {
|
|
5
|
-
const normalizedWixRedirectUrl = wixRedirectUrl.endsWith("/") ? wixRedirectUrl : `${wixRedirectUrl}/`;
|
|
6
|
-
return normalizedWixRedirectUrl;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
normalizeWixRedirectUrl
|
|
11
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createHostProxy
|
|
3
|
-
} from "../chunk-NKY4T53W.js";
|
|
4
|
-
import "../chunk-NVTQFGTR.js";
|
|
5
|
-
import "../chunk-PSHIUVP2.js";
|
|
6
|
-
import "../chunk-U67V476Y.js";
|
|
7
|
-
|
|
8
|
-
// src/context/elevated.ts
|
|
9
|
-
import { AppStrategy, createClient } from "@wix/sdk";
|
|
10
|
-
import { WIX_CLIENT_ID } from "astro:env/client";
|
|
11
|
-
import {
|
|
12
|
-
WIX_CLIENT_INSTANCE_ID,
|
|
13
|
-
WIX_CLIENT_PUBLIC_KEY,
|
|
14
|
-
WIX_CLIENT_SECRET
|
|
15
|
-
} from "astro:env/server";
|
|
16
|
-
var elevatedContextClient = createClient({
|
|
17
|
-
auth: AppStrategy({
|
|
18
|
-
appId: WIX_CLIENT_ID,
|
|
19
|
-
appSecret: WIX_CLIENT_SECRET,
|
|
20
|
-
instanceId: WIX_CLIENT_INSTANCE_ID,
|
|
21
|
-
publicKey: WIX_CLIENT_PUBLIC_KEY
|
|
22
|
-
}),
|
|
23
|
-
host: createHostProxy()
|
|
24
|
-
});
|
|
25
|
-
elevatedContextClient.enableContext("global", { elevated: true });
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createHostProxy
|
|
3
|
-
} from "../chunk-NKY4T53W.js";
|
|
4
|
-
import {
|
|
5
|
-
authAsyncLocalStorage
|
|
6
|
-
} from "../chunk-NVTQFGTR.js";
|
|
7
|
-
import "../chunk-PSHIUVP2.js";
|
|
8
|
-
import "../chunk-U67V476Y.js";
|
|
9
|
-
|
|
10
|
-
// src/context/nonElevated.ts
|
|
11
|
-
import { createClient, OAuthStrategy } from "@wix/sdk";
|
|
12
|
-
import { WIX_CLIENT_ID } from "astro:env/client";
|
|
13
|
-
var authProxy = new Proxy(
|
|
14
|
-
{},
|
|
15
|
-
{
|
|
16
|
-
get(target, prop) {
|
|
17
|
-
const auth = OAuthStrategy({
|
|
18
|
-
clientId: WIX_CLIENT_ID
|
|
19
|
-
});
|
|
20
|
-
const value = auth[prop];
|
|
21
|
-
if (typeof value !== "function") {
|
|
22
|
-
return value;
|
|
23
|
-
}
|
|
24
|
-
return function(...args) {
|
|
25
|
-
const store = authAsyncLocalStorage.getStore();
|
|
26
|
-
if (store?.sessionTokens) {
|
|
27
|
-
auth.setTokens(store.sessionTokens);
|
|
28
|
-
}
|
|
29
|
-
return value.apply(auth, args);
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
var contextClient = createClient({
|
|
35
|
-
auth: authProxy,
|
|
36
|
-
host: createHostProxy()
|
|
37
|
-
});
|
|
38
|
-
contextClient.enableContext("global");
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
setupClient
|
|
3
|
-
} from "../chunk-W73LN534.js";
|
|
4
|
-
import "../chunk-U67V476Y.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-U67V476Y.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-U67V476Y.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
|
-
};
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createRESTModule,
|
|
3
|
-
renameKeysFromRESTResponseToSDKResponse,
|
|
4
|
-
renameKeysFromSDKRequestToRESTRequest,
|
|
5
|
-
resolveUrl,
|
|
6
|
-
toURLSearchParams,
|
|
7
|
-
transformError
|
|
8
|
-
} from "../chunk-EK7YZVWJ.js";
|
|
9
|
-
import "../chunk-PSHIUVP2.js";
|
|
10
|
-
import {
|
|
11
|
-
__export
|
|
12
|
-
} from "../chunk-U67V476Y.js";
|
|
13
|
-
|
|
14
|
-
// ../../node_modules/@wix/auto_sdk_headless-site-assets_scripts/build/es/index.mjs
|
|
15
|
-
var es_exports = {};
|
|
16
|
-
__export(es_exports, {
|
|
17
|
-
PositionOnPage: () => PositionOnPage,
|
|
18
|
-
listSiteScripts: () => listSiteScripts4
|
|
19
|
-
});
|
|
20
|
-
function resolveWixAssetsScriptsV1SiteScriptsServiceUrl(opts) {
|
|
21
|
-
const domainToMappings = {
|
|
22
|
-
"bo._base_domain_": [
|
|
23
|
-
{
|
|
24
|
-
srcPath: "/_api/site-scripts",
|
|
25
|
-
destPath: ""
|
|
26
|
-
}
|
|
27
|
-
],
|
|
28
|
-
"wixbo.ai": [
|
|
29
|
-
{
|
|
30
|
-
srcPath: "/_api/site-scripts",
|
|
31
|
-
destPath: ""
|
|
32
|
-
}
|
|
33
|
-
],
|
|
34
|
-
"wix-bo.com": [
|
|
35
|
-
{
|
|
36
|
-
srcPath: "/_api/site-scripts",
|
|
37
|
-
destPath: ""
|
|
38
|
-
}
|
|
39
|
-
],
|
|
40
|
-
"www.wixapis.com": [
|
|
41
|
-
{
|
|
42
|
-
srcPath: "/assets/scripts/v1/site-scripts",
|
|
43
|
-
destPath: "/v1/site-scripts"
|
|
44
|
-
}
|
|
45
|
-
]
|
|
46
|
-
};
|
|
47
|
-
return resolveUrl(Object.assign(opts, { domainToMappings }));
|
|
48
|
-
}
|
|
49
|
-
var PACKAGE_NAME = "@wix/auto_sdk_headless-site-assets_scripts";
|
|
50
|
-
function listSiteScripts(payload) {
|
|
51
|
-
function __listSiteScripts({ host }) {
|
|
52
|
-
const metadata = {
|
|
53
|
-
entityFqdn: "wix.assets.v1.site_script",
|
|
54
|
-
method: "GET",
|
|
55
|
-
methodFqn: "wix.assets.scripts.v1.SiteScriptsService.ListSiteScripts",
|
|
56
|
-
packageName: PACKAGE_NAME,
|
|
57
|
-
url: resolveWixAssetsScriptsV1SiteScriptsServiceUrl({
|
|
58
|
-
protoPath: "/v1/site-scripts",
|
|
59
|
-
data: payload,
|
|
60
|
-
host
|
|
61
|
-
}),
|
|
62
|
-
params: toURLSearchParams(payload)
|
|
63
|
-
};
|
|
64
|
-
return metadata;
|
|
65
|
-
}
|
|
66
|
-
return __listSiteScripts;
|
|
67
|
-
}
|
|
68
|
-
var PositionOnPage = /* @__PURE__ */ ((PositionOnPage2) => {
|
|
69
|
-
PositionOnPage2["UNKNOWN_POSITION"] = "UNKNOWN_POSITION";
|
|
70
|
-
PositionOnPage2["HEAD"] = "HEAD";
|
|
71
|
-
PositionOnPage2["BODY_START"] = "BODY_START";
|
|
72
|
-
PositionOnPage2["BODY_END"] = "BODY_END";
|
|
73
|
-
return PositionOnPage2;
|
|
74
|
-
})(PositionOnPage || {});
|
|
75
|
-
async function listSiteScripts2() {
|
|
76
|
-
const { httpClient, sideEffects } = arguments[0];
|
|
77
|
-
const payload = renameKeysFromSDKRequestToRESTRequest({});
|
|
78
|
-
const reqOpts = listSiteScripts(payload);
|
|
79
|
-
sideEffects?.onSiteCall?.();
|
|
80
|
-
try {
|
|
81
|
-
const result = await httpClient.request(reqOpts);
|
|
82
|
-
sideEffects?.onSuccess?.(result);
|
|
83
|
-
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
84
|
-
} catch (err) {
|
|
85
|
-
const transformedError = transformError(
|
|
86
|
-
err,
|
|
87
|
-
{
|
|
88
|
-
spreadPathsToArguments: {},
|
|
89
|
-
explicitPathsToArguments: {},
|
|
90
|
-
singleArgumentUnchanged: false
|
|
91
|
-
},
|
|
92
|
-
[]
|
|
93
|
-
);
|
|
94
|
-
sideEffects?.onError?.(err);
|
|
95
|
-
throw transformedError;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
function listSiteScripts3(httpClient) {
|
|
99
|
-
return () => listSiteScripts2(
|
|
100
|
-
// @ts-ignore
|
|
101
|
-
{ httpClient }
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
var listSiteScripts4 = /* @__PURE__ */ createRESTModule(listSiteScripts3);
|
|
105
|
-
|
|
106
|
-
// src/utils/transformStreamUtils.ts
|
|
107
|
-
function injectAfterTransformStream(predicate, htmlToInject) {
|
|
108
|
-
let hasInjected = false;
|
|
109
|
-
return new TransformStream({
|
|
110
|
-
transform: (chunk, controller) => {
|
|
111
|
-
if (!hasInjected) {
|
|
112
|
-
const index = predicate.exec(chunk);
|
|
113
|
-
if (index) {
|
|
114
|
-
const position = index.index + index[0].length;
|
|
115
|
-
chunk = chunk.slice(0, position) + htmlToInject + chunk.slice(position);
|
|
116
|
-
hasInjected = true;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
controller.enqueue(chunk);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
function injectBeforeTransformStream(predicate, htmlToInject) {
|
|
124
|
-
let hasInjected = false;
|
|
125
|
-
return new TransformStream({
|
|
126
|
-
transform: (chunk, controller) => {
|
|
127
|
-
if (!hasInjected) {
|
|
128
|
-
const index = chunk.indexOf(predicate);
|
|
129
|
-
if (index > -1) {
|
|
130
|
-
chunk = chunk.slice(0, index) + htmlToInject + chunk.slice(index);
|
|
131
|
-
hasInjected = true;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
controller.enqueue(chunk);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// src/middleware/html-embeds.ts
|
|
140
|
-
var bodyEndTransformStream = (htmlToInject) => injectBeforeTransformStream("</body>", htmlToInject);
|
|
141
|
-
var headTransformStream = (htmlToInject) => injectBeforeTransformStream("</head>", htmlToInject);
|
|
142
|
-
var bodyStartTransformStream = (htmlToInject) => injectAfterTransformStream(/<body(?![^>]*\/>)[^>]*>/, htmlToInject);
|
|
143
|
-
var onRequest = async (context, next) => {
|
|
144
|
-
const response = await next();
|
|
145
|
-
const contentType = response.headers.get("Content-Type");
|
|
146
|
-
if (contentType !== "text/html") {
|
|
147
|
-
return response;
|
|
148
|
-
}
|
|
149
|
-
if (context.url.pathname.startsWith("/_wix")) {
|
|
150
|
-
return response;
|
|
151
|
-
}
|
|
152
|
-
const { siteScripts } = await es_exports.listSiteScripts();
|
|
153
|
-
if (siteScripts == null) {
|
|
154
|
-
throw new Error("Could not fetch site scripts");
|
|
155
|
-
}
|
|
156
|
-
const headInjection = siteScripts.filter((x) => x.position === "HEAD").map((x) => x.html).join("\n");
|
|
157
|
-
const bodyStartInjection = siteScripts.filter((x) => x.position === "BODY_START").map((x) => x.html).join("\n");
|
|
158
|
-
const bodyEndInjection = siteScripts.filter((x) => x.position === "BODY_END").map((x) => x.html).join("\n");
|
|
159
|
-
return new Response(
|
|
160
|
-
response.body?.pipeThrough(new TextDecoderStream()).pipeThrough(headTransformStream(headInjection)).pipeThrough(bodyStartTransformStream(bodyStartInjection)).pipeThrough(bodyEndTransformStream(bodyEndInjection)).pipeThrough(new TextEncoderStream()),
|
|
161
|
-
response
|
|
162
|
-
);
|
|
163
|
-
};
|
|
164
|
-
export {
|
|
165
|
-
onRequest
|
|
166
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
object,
|
|
3
|
-
string
|
|
4
|
-
} from "../../chunk-WE3ELMU5.js";
|
|
5
|
-
import {
|
|
6
|
-
auth,
|
|
7
|
-
oAuthStateCookieName
|
|
8
|
-
} from "../../chunk-UZPSWWI5.js";
|
|
9
|
-
import {
|
|
10
|
-
saveSessionTokensToCookie
|
|
11
|
-
} from "../../chunk-HPW4ZAEJ.js";
|
|
12
|
-
import "../../chunk-U67V476Y.js";
|
|
13
|
-
|
|
14
|
-
// src/routes/auth/callback.ts
|
|
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 { code, error, errorDescription, state } = auth.parseFromUrl(
|
|
34
|
-
context.url.toString(),
|
|
35
|
-
"query"
|
|
36
|
-
);
|
|
37
|
-
if (error != null) {
|
|
38
|
-
throw new Error(`Error while authenticating: \`${errorDescription}\``);
|
|
39
|
-
}
|
|
40
|
-
const memberTokens = await auth.getMemberTokens(code, state, oauthData);
|
|
41
|
-
context.cookies.delete(oAuthStateCookieName, {
|
|
42
|
-
httpOnly: true,
|
|
43
|
-
path: "/",
|
|
44
|
-
sameSite: "lax",
|
|
45
|
-
secure: true
|
|
46
|
-
});
|
|
47
|
-
saveSessionTokensToCookie(context, memberTokens);
|
|
48
|
-
return context.redirect(oauthData.originalUri);
|
|
49
|
-
};
|
|
50
|
-
export {
|
|
51
|
-
GET
|
|
52
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
_enum,
|
|
3
|
-
object,
|
|
4
|
-
string
|
|
5
|
-
} from "../../chunk-WE3ELMU5.js";
|
|
6
|
-
import {
|
|
7
|
-
auth,
|
|
8
|
-
oAuthStateCookieName
|
|
9
|
-
} from "../../chunk-UZPSWWI5.js";
|
|
10
|
-
import "../../chunk-U67V476Y.js";
|
|
11
|
-
|
|
12
|
-
// src/routes/auth/login.ts
|
|
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 oauthData = auth.generateOAuthData(callbackUrl.toString(), returnToUrl);
|
|
28
|
-
const { authUrl } = await auth.getAuthUrl(oauthData, {
|
|
29
|
-
prompt,
|
|
30
|
-
responseMode: "query"
|
|
31
|
-
});
|
|
32
|
-
const sameSite = import.meta.env.DEV ? "None" : "Lax";
|
|
33
|
-
return new Response(null, {
|
|
34
|
-
headers: {
|
|
35
|
-
Location: authUrl,
|
|
36
|
-
"Set-Cookie": `${oAuthStateCookieName}=${JSON.stringify(
|
|
37
|
-
oauthData
|
|
38
|
-
)}; Max-Age=1800; Path=/; HttpOnly; Secure; SameSite=${sameSite}`
|
|
39
|
-
},
|
|
40
|
-
status: 302
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
export {
|
|
44
|
-
GET
|
|
45
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
auth,
|
|
3
|
-
returnToQueryParamName
|
|
4
|
-
} from "../../chunk-UZPSWWI5.js";
|
|
5
|
-
import {
|
|
6
|
-
saveSessionTokensToCookie
|
|
7
|
-
} from "../../chunk-HPW4ZAEJ.js";
|
|
8
|
-
import "../../chunk-U67V476Y.js";
|
|
9
|
-
|
|
10
|
-
// src/routes/auth/logout-callback.ts
|
|
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
|
-
saveSessionTokensToCookie(context, await auth.generateVisitorTokens());
|
|
19
|
-
return context.redirect(returnTo);
|
|
20
|
-
};
|
|
21
|
-
export {
|
|
22
|
-
GET
|
|
23
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
object,
|
|
3
|
-
string
|
|
4
|
-
} from "../../chunk-WE3ELMU5.js";
|
|
5
|
-
import {
|
|
6
|
-
auth,
|
|
7
|
-
returnToQueryParamName
|
|
8
|
-
} from "../../chunk-UZPSWWI5.js";
|
|
9
|
-
import "../../chunk-U67V476Y.js";
|
|
10
|
-
|
|
11
|
-
// src/routes/auth/logout.ts
|
|
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 { logoutUrl } = await auth.logout(postFlowUrl.toString());
|
|
28
|
-
return redirect(logoutUrl);
|
|
29
|
-
};
|
|
30
|
-
export {
|
|
31
|
-
POST
|
|
32
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
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/paylink/checkout.ts
|
|
12
|
-
import { auth } from "@wix/essentials";
|
|
13
|
-
import { WIX_CLIENT_ID } from "astro:env/client";
|
|
14
|
-
var GET = async ({ url }) => {
|
|
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 newCheckoutUrl = new URL(
|
|
25
|
-
url.pathname.replace("/", "") + url.search,
|
|
26
|
-
baseUrl
|
|
27
|
-
);
|
|
28
|
-
return new Response(null, {
|
|
29
|
-
headers: { Location: newCheckoutUrl.toString() },
|
|
30
|
-
status: 302
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
export {
|
|
34
|
-
GET
|
|
35
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
es_exports
|
|
3
|
-
} from "../../chunk-7EHL72JI.js";
|
|
4
|
-
import "../../chunk-EK7YZVWJ.js";
|
|
5
|
-
import "../../chunk-PSHIUVP2.js";
|
|
6
|
-
import "../../chunk-U67V476Y.js";
|
|
7
|
-
|
|
8
|
-
// src/routes/paylink/paylink.ts
|
|
9
|
-
import { auth } from "@wix/essentials";
|
|
10
|
-
import { WIX_CLIENT_ID } from "astro:env/client";
|
|
11
|
-
var GET = async ({ params }) => {
|
|
12
|
-
try {
|
|
13
|
-
const { redirectUrlWixPages } = await auth.elevate(es_exports.getOAuthApp)(
|
|
14
|
-
WIX_CLIENT_ID
|
|
15
|
-
);
|
|
16
|
-
if (redirectUrlWixPages == null) {
|
|
17
|
-
throw new Error(`Invalid Redirect URL: ${redirectUrlWixPages}`);
|
|
18
|
-
}
|
|
19
|
-
const paylinkId = params.id;
|
|
20
|
-
const baseUrl = redirectUrlWixPages.endsWith("/") ? redirectUrlWixPages : `${redirectUrlWixPages}/`;
|
|
21
|
-
const paylinkUrl = new URL(`_paylink/${paylinkId}`, baseUrl);
|
|
22
|
-
return new Response(null, {
|
|
23
|
-
headers: { Location: paylinkUrl.toString() },
|
|
24
|
-
status: 302
|
|
25
|
-
});
|
|
26
|
-
} catch (error) {
|
|
27
|
-
throw new Error(
|
|
28
|
-
`Error while constructing Paylink URL: ${JSON.stringify(error)}`
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
export {
|
|
33
|
-
GET
|
|
34
|
-
};
|