@wix/astro 0.3.3 → 1.0.1

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 (71) hide show
  1. package/build/index.d.ts +5 -0
  2. package/build/index.js +124854 -0
  3. package/build/index.js.map +1 -0
  4. package/build/xdg-open +1267 -0
  5. package/build/yoga.wasm +0 -0
  6. package/build-runtime/auth.d.ts +5 -0
  7. package/build-runtime/auth.js +3557 -0
  8. package/package.json +37 -47
  9. package/runtime/entry.astro +26 -0
  10. package/src/directories.ts +10 -0
  11. package/src/env.d.ts +3 -0
  12. package/src/index.ts +217 -0
  13. package/src/middleware/auth.ts +115 -0
  14. package/src/plugins/patchGlobal.ts +20 -0
  15. package/src/utils/authStrategyAsyncLocalStorage.ts +6 -0
  16. package/src/utils/createProjectModel.ts +77 -0
  17. package/src/utils/generateAppManifest.ts +32 -0
  18. package/src/utils/isValidBackofficeComponent.ts +15 -0
  19. package/src/utils/loadExtension.ts +59 -0
  20. package/src/utils/sessionCookieJson.ts +9 -0
  21. package/src/utils/writeVirtualExtensionFiles.ts +54 -0
  22. package/tsconfig.json +8 -0
  23. package/tsup.config.mjs +28 -0
  24. package/README.md +0 -121
  25. package/dist/auth-context.d.ts +0 -5
  26. package/dist/auth-context.js +0 -2
  27. package/dist/client.d.ts +0 -15
  28. package/dist/client.js +0 -16
  29. package/dist/components/login-helpers/bi-header-generator.d.ts +0 -11
  30. package/dist/components/login-helpers/bi-header-generator.js +0 -17
  31. package/dist/components/login-helpers/iframeUtils.d.ts +0 -4
  32. package/dist/components/login-helpers/iframeUtils.js +0 -43
  33. package/dist/components/login-helpers/login-helpers.d.ts +0 -42
  34. package/dist/components/login-helpers/login-helpers.js +0 -119
  35. package/dist/components/login.astro +0 -873
  36. package/dist/entrypoints/server.d.ts +0 -13
  37. package/dist/entrypoints/server.js +0 -36
  38. package/dist/helpers/index.d.ts +0 -1
  39. package/dist/helpers/index.js +0 -1
  40. package/dist/index.d.ts +0 -5
  41. package/dist/index.js +0 -4
  42. package/dist/integration.d.ts +0 -22
  43. package/dist/integration.js +0 -233
  44. package/dist/loaders/blog.d.ts +0 -2
  45. package/dist/loaders/blog.js +0 -48
  46. package/dist/loaders/index.d.ts +0 -2
  47. package/dist/loaders/index.js +0 -2
  48. package/dist/middleware.d.ts +0 -2
  49. package/dist/middleware.js +0 -89
  50. package/dist/routes/auth/callback.d.ts +0 -3
  51. package/dist/routes/auth/callback.js +0 -52
  52. package/dist/routes/auth/constants.d.ts +0 -5
  53. package/dist/routes/auth/constants.js +0 -5
  54. package/dist/routes/auth/login.d.ts +0 -3
  55. package/dist/routes/auth/login.js +0 -26
  56. package/dist/routes/auth/logout-callback.d.ts +0 -3
  57. package/dist/routes/auth/logout-callback.js +0 -9
  58. package/dist/routes/auth/logout.d.ts +0 -3
  59. package/dist/routes/auth/logout.js +0 -10
  60. package/dist/routes/auth/runtime.d.ts +0 -5
  61. package/dist/routes/auth/runtime.js +0 -7
  62. package/dist/runtime-client.d.ts +0 -3
  63. package/dist/runtime-client.js +0 -4
  64. package/dist/runtime.client.d.ts +0 -2
  65. package/dist/runtime.client.js +0 -4
  66. package/dist/runtime.d.ts +0 -5
  67. package/dist/runtime.js +0 -12
  68. package/dist/runtime.server.d.ts +0 -2
  69. package/dist/runtime.server.js +0 -8
  70. package/dist/vite-plugins/sdk-context.d.ts +0 -4
  71. package/dist/vite-plugins/sdk-context.js +0 -67
package/dist/runtime.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { OAuthStrategy } from "@wix/sdk/auth/oauth2";
2
- import type { WixClient } from "@wix/sdk";
3
- import type { SiteSessionAuth } from "@wix/sdk/auth/site-session";
4
- export declare function getAuth(): ReturnType<typeof OAuthStrategy>;
5
- export declare function getWixClient(): WixClient<undefined, ReturnType<typeof SiteSessionAuth>>;
package/dist/runtime.js DELETED
@@ -1,12 +0,0 @@
1
- import { authStrategyAsyncLocalStorage } from "./auth-context.js";
2
- import { wixContext } from '@wix/sdk-context';
3
- export function getAuth() {
4
- const auth = authStrategyAsyncLocalStorage.getStore()?.auth;
5
- if (!auth) {
6
- throw new Error("No authentication strategy found in the current context");
7
- }
8
- return auth;
9
- }
10
- export function getWixClient() {
11
- return wixContext['client'];
12
- }
@@ -1,2 +0,0 @@
1
- import { OAuthStrategy } from "@wix/sdk/auth/oauth2";
2
- export declare function getAuth(): ReturnType<typeof OAuthStrategy>;
@@ -1,8 +0,0 @@
1
- import { authStrategyAsyncLocalStorage } from "./auth-context.js";
2
- export function getAuth() {
3
- const auth = authStrategyAsyncLocalStorage.getStore()?.auth;
4
- if (!auth) {
5
- throw new Error("No authentication strategy found in the current context");
6
- }
7
- return auth;
8
- }
@@ -1,4 +0,0 @@
1
- import { Plugin } from "vite";
2
- export declare function wixSDKContext(opts: {
3
- sessionCookieName: string;
4
- }): Plugin;
@@ -1,67 +0,0 @@
1
- import buildResolver from "esm-resolve";
2
- import { fileURLToPath } from "node:url";
3
- import { loadEnv } from "vite";
4
- export function wixSDKContext(opts) {
5
- const virtualModuleId = '@wix/sdk-context';
6
- const resolvedVirtualModuleId = '\0' + virtualModuleId;
7
- return {
8
- name: 'vite-plugin-sdk-context',
9
- enforce: 'pre', // Ensure the plugin runs before Vite processes dependencies
10
- config(_, { isSsrBuild }) {
11
- if (isSsrBuild)
12
- return; // Skip for server-side rendering
13
- return {
14
- optimizeDeps: {
15
- exclude: [virtualModuleId], // Ensure the virtual module is not pre-bundled
16
- },
17
- };
18
- },
19
- resolveId(id, _, { ssr }) {
20
- if (ssr)
21
- return null; // Skip for server-side rendering
22
- if (id === virtualModuleId) {
23
- return resolvedVirtualModuleId;
24
- }
25
- return null;
26
- },
27
- load(id) {
28
- if (id === resolvedVirtualModuleId) {
29
- const aRequire = buildResolver(fileURLToPath(import.meta.url), {
30
- resolveToAbsolute: true,
31
- });
32
- const userLoadedEnv = loadEnv(process.env["NODE_ENV"] ?? "development", process.cwd(), "");
33
- const wixSDKResolved = aRequire("@wix/sdk/client");
34
- const wixSDKAuthResolved = aRequire("@wix/sdk/auth/site-session");
35
- return `import { createClient } from "${wixSDKResolved}";
36
- import { SiteSessionAuth } from "${wixSDKAuthResolved}";
37
-
38
- function getCookieAsJson(name) {
39
- const cookies = document.cookie.split('; ');
40
- const cookie = cookies.find(row => row.startsWith(\`\${name}=\`));
41
-
42
- if (!cookie) return null;
43
-
44
- try {
45
- const jsonString = decodeURIComponent(cookie.split('=')[1]);
46
- return JSON.parse(jsonString);
47
- } catch (error) {
48
- console.error('Error parsing cookie JSON:', error);
49
- return null;
50
- }
51
- }
52
-
53
- export const wixContext = {
54
- client: createClient({
55
- auth: SiteSessionAuth({
56
- clientId: ${JSON.stringify(userLoadedEnv["WIX_CLIENT_ID"])},
57
- tokens: getCookieAsJson(${JSON.stringify(opts.sessionCookieName)})?.tokens,
58
- }),
59
- }),
60
- clientId: ${JSON.stringify(userLoadedEnv["WIX_CLIENT_ID"])},
61
- };
62
- `;
63
- }
64
- return null;
65
- },
66
- };
67
- }