@eventcatalog/core 4.12.0-beta.9 → 4.12.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 (44) hide show
  1. package/dist/analytics/analytics.cjs +1 -1
  2. package/dist/analytics/analytics.js +2 -2
  3. package/dist/analytics/log-build.cjs +1 -1
  4. package/dist/analytics/log-build.js +3 -3
  5. package/dist/{chunk-GNFKUOXD.js → chunk-DZZDBFUM.js} +1 -1
  6. package/dist/{chunk-K3DWGBGQ.js → chunk-EVXNBTRA.js} +1 -1
  7. package/dist/{chunk-YOIPWS7L.js → chunk-HH6GPY4H.js} +1 -1
  8. package/dist/{chunk-UIHG2TPV.js → chunk-HHZFKWX7.js} +1 -1
  9. package/dist/{chunk-4S47JELQ.js → chunk-UWSBZYF5.js} +3 -3
  10. package/dist/constants.cjs +1 -1
  11. package/dist/constants.js +1 -1
  12. package/dist/docs/development/01-getting-started/develop-and-build.md +18 -0
  13. package/dist/docs/development/ask-your-architecture/02-eventcatalog-assistant/02-configuration.md +4 -0
  14. package/dist/docs/development/components/components/27-code-group.md +95 -0
  15. package/dist/docs/development/components/components/28-columns.md +115 -0
  16. package/dist/docs/development/customization/05-custom-pages-and-api-routes/02-create-a-custom-page.md +21 -0
  17. package/dist/docs/development/customization/05-custom-pages-and-api-routes/04-reference.md +24 -0
  18. package/dist/docs/development/deployment/hosting-options.md +8 -0
  19. package/dist/docs/development/guides/resources/messages/09-add-usage-examples.md +103 -9
  20. package/dist/docs/development/guides/resources/schemas/04-explore-schemas/01-schema-explorer.md +79 -13
  21. package/dist/docs/development/upgrading/upgrading.md +8 -3
  22. package/dist/docs/development/upgrading/v4.md +1 -1
  23. package/dist/eventcatalog.cjs +1 -1
  24. package/dist/eventcatalog.js +12 -12
  25. package/dist/federation/federate.js +3 -3
  26. package/dist/generate.cjs +1 -1
  27. package/dist/generate.js +3 -3
  28. package/dist/runtime-dependencies/manifest.json +1 -3
  29. package/dist/runtime-dependencies/set-cookie-parser.mjs +3 -0
  30. package/dist/utils/cli-logger.cjs +1 -1
  31. package/dist/utils/cli-logger.js +2 -2
  32. package/eventcatalog/auth.config.ts +3 -4
  33. package/eventcatalog/src/components/Header.astro +101 -33
  34. package/eventcatalog/src/enterprise/auth/[...auth].ts +1 -1
  35. package/eventcatalog/src/enterprise/auth/login.astro +2 -2
  36. package/eventcatalog/src/enterprise/auth/middleware/middleware-auth.ts +1 -1
  37. package/eventcatalog/src/utils/auth-astro/client.ts +89 -0
  38. package/eventcatalog/src/utils/auth-astro/config.ts +24 -0
  39. package/eventcatalog/src/utils/auth-astro/server.ts +74 -0
  40. package/package.json +3 -2
  41. package/dist/runtime-dependencies/auth-astro.mjs +0 -3
  42. package/dist/runtime-dependencies/auth-astro__client.mjs +0 -3
  43. package/dist/runtime-dependencies/auth-astro__server.mjs +0 -3
  44. package/dist/{chunk-U4YJSTGV.js → chunk-WRLNLWPW.js} +7 -7
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Adapted from auth-astro 4.2.0 (MIT, https://github.com/nowaythatworked/auth-astro).
3
+ *
4
+ * Kept in Core so every Auth.js import resolves to Core's own `@auth/core`. The
5
+ * auth-astro package pins an older `@auth/core` peer range, which makes npm install
6
+ * a second, vulnerable copy in user projects.
7
+ */
8
+ import type { AuthConfig } from '@auth/core/types';
9
+
10
+ export interface AstroAuthConfig {
11
+ /**
12
+ * Base path for the auth routes.
13
+ * @default '/api/auth'
14
+ */
15
+ prefix?: string;
16
+ }
17
+
18
+ export interface FullAuthConfig extends AstroAuthConfig, Omit<AuthConfig, 'raw'> {}
19
+
20
+ export const defineConfig = (config: FullAuthConfig) => {
21
+ config.prefix ??= '/api/auth';
22
+ config.basePath = config.prefix;
23
+ return config;
24
+ };
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Adapted from auth-astro 4.2.0 (MIT, https://github.com/nowaythatworked/auth-astro).
3
+ * See ./config.ts for why this lives in Core.
4
+ */
5
+ import { Auth } from '@auth/core';
6
+ import type { AuthAction, Session } from '@auth/core/types';
7
+ import type { APIContext } from 'astro';
8
+ import { parseString } from 'set-cookie-parser';
9
+ import authConfig from 'auth:config';
10
+
11
+ const actions: AuthAction[] = ['providers', 'session', 'csrf', 'signin', 'signout', 'callback', 'verify-request', 'error'];
12
+
13
+ function AstroAuthHandler(prefix: string, options = authConfig) {
14
+ return async ({ cookies, request }: APIContext) => {
15
+ const url = new URL(request.url);
16
+ const action = url.pathname.slice(prefix.length + 1).split('/')[0] as AuthAction;
17
+
18
+ if (!actions.includes(action) || !url.pathname.startsWith(prefix + '/')) return;
19
+
20
+ const res = await Auth(request, options);
21
+ if (['callback', 'signin', 'signout'].includes(action)) {
22
+ // Multiple Set-Cookie headers can't be concatenated, so hand each one to Astro
23
+ const setCookies = res.headers.getSetCookie();
24
+ if (setCookies.length > 0) {
25
+ setCookies.forEach((cookie) => {
26
+ const { name, value, ...cookieOptions } = parseString(cookie);
27
+ cookies.set(name, value, cookieOptions as Parameters<(typeof cookies)['set']>[2]);
28
+ });
29
+ res.headers.delete('Set-Cookie');
30
+ }
31
+ }
32
+ return res;
33
+ };
34
+ }
35
+
36
+ /**
37
+ * Creates the Astro GET and POST endpoints for authentication.
38
+ */
39
+ export function AstroAuth(options = authConfig) {
40
+ const { AUTH_SECRET, AUTH_TRUST_HOST, VERCEL, NODE_ENV } = import.meta.env;
41
+
42
+ options.secret ??= AUTH_SECRET;
43
+ options.trustHost ??= !!(AUTH_TRUST_HOST ?? VERCEL ?? NODE_ENV !== 'production');
44
+
45
+ const { prefix = '/api/auth', ...authOptions } = options;
46
+
47
+ const handler = AstroAuthHandler(prefix, authOptions);
48
+ return {
49
+ async GET(context: APIContext) {
50
+ return await handler(context);
51
+ },
52
+ async POST(context: APIContext) {
53
+ return await handler(context);
54
+ },
55
+ };
56
+ }
57
+
58
+ /**
59
+ * Fetches the current session, or `null` if there is none.
60
+ */
61
+ export async function getSession(req: Request, options = authConfig): Promise<Session | null> {
62
+ options.secret ??= import.meta.env.AUTH_SECRET;
63
+ options.trustHost ??= true;
64
+
65
+ const url = new URL(`${options.prefix}/session`, req.url);
66
+ const response = await Auth(new Request(url, { headers: req.headers }), options);
67
+ const { status = 200 } = response;
68
+
69
+ const data = await response.json();
70
+
71
+ if (!data || !Object.keys(data).length) return null;
72
+ if (status === 200) return data;
73
+ throw new Error(data.message);
74
+ }
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "license": "SEE LICENSE IN LICENSE",
9
9
  "type": "module",
10
- "version": "4.12.0-beta.9",
10
+ "version": "4.12.1",
11
11
  "publishConfig": {
12
12
  "access": "public"
13
13
  },
@@ -78,7 +78,6 @@
78
78
  "astro": "7.3.3",
79
79
  "astro-expressive-code": "^0.44.0",
80
80
  "astro-seo": "^0.8.4",
81
- "auth-astro": "^4.2.0",
82
81
  "boxen": "^8.0.1",
83
82
  "commander": "^12.1.0",
84
83
  "cross-env": "^7.0.3",
@@ -124,6 +123,7 @@
124
123
  "remark-gfm": "^4.0.1",
125
124
  "rimraf": "^6.1.3",
126
125
  "semver": "7.6.3",
126
+ "set-cookie-parser": "^2.7.1",
127
127
  "shelljs": "^0.9.0",
128
128
  "sonner": "^2.0.7",
129
129
  "sql.js": "^1.12.0",
@@ -155,6 +155,7 @@
155
155
  "@types/react-dom": "^19.2.3",
156
156
  "@types/react-syntax-highlighter": "^15.5.13",
157
157
  "@types/semver": "^7.5.8",
158
+ "@types/set-cookie-parser": "^2.4.10",
158
159
  "@types/shelljs": "^0.8.15",
159
160
  "@types/update-notifier": "^6.0.8",
160
161
  "@types/uuid": "^10.0.0",
@@ -1,3 +0,0 @@
1
- export * from "auth-astro";
2
- import * as dependency from "auth-astro";
3
- export default dependency.default;
@@ -1,3 +0,0 @@
1
- export * from "auth-astro/client";
2
- import * as dependency from "auth-astro/client";
3
- export default dependency.default;
@@ -1,3 +0,0 @@
1
- export * from "auth-astro/server";
2
- import * as dependency from "auth-astro/server";
3
- export default dependency.default;
@@ -1,3 +1,10 @@
1
+ import {
2
+ getFederationDiagnostics,
3
+ resolveFederationRules
4
+ } from "./chunk-JJPB6EOZ.js";
5
+ import {
6
+ isFederationEnabled
7
+ } from "./chunk-FV56YFM4.js";
1
8
  import {
2
9
  withFederationOutputTransaction
3
10
  } from "./chunk-WRNH5C3U.js";
@@ -10,13 +17,6 @@ import {
10
17
  import {
11
18
  createFederationContentCache
12
19
  } from "./chunk-R7Z5ALYI.js";
13
- import {
14
- getFederationDiagnostics,
15
- resolveFederationRules
16
- } from "./chunk-JJPB6EOZ.js";
17
- import {
18
- isFederationEnabled
19
- } from "./chunk-FV56YFM4.js";
20
20
  import {
21
21
  getEventCatalogConfigFile
22
22
  } from "./chunk-RFIXKATC.js";