@agent-native/dispatch 0.15.21 → 0.15.23

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 (31) hide show
  1. package/dist/actions/provider-api-register.d.ts +11 -11
  2. package/dist/actions/sync-vault-to-app.d.ts +4 -4
  3. package/dist/components/layout/Layout.d.ts.map +1 -1
  4. package/dist/components/layout/Layout.js +1 -5
  5. package/dist/components/layout/Layout.js.map +1 -1
  6. package/dist/routes/pages/_index.js +1 -1
  7. package/dist/routes/pages/_index.js.map +1 -1
  8. package/dist/routes/pages/overview.js +1 -1
  9. package/dist/routes/pages/overview.js.map +1 -1
  10. package/dist/server/lib/app-creation-store.js +1 -1
  11. package/dist/server/lib/app-creation-store.js.map +1 -1
  12. package/dist/server/lib/vault-store.d.ts +4 -4
  13. package/dist/server/lib/vault-store.d.ts.map +1 -1
  14. package/dist/server/lib/vault-store.js +53 -28
  15. package/dist/server/lib/vault-store.js.map +1 -1
  16. package/dist/server/plugins/auth.js +1 -1
  17. package/dist/server/plugins/auth.js.map +1 -1
  18. package/package.json +3 -5
  19. package/src/components/layout/Layout.spec.tsx +33 -0
  20. package/src/components/layout/Layout.tsx +2 -19
  21. package/src/routes/pages/_index.tsx +1 -1
  22. package/src/routes/pages/overview.tsx +1 -1
  23. package/src/server/lib/app-creation-store.ts +1 -1
  24. package/src/server/lib/vault-store.spec.ts +159 -0
  25. package/src/server/lib/vault-store.ts +61 -28
  26. package/src/server/plugins/auth.ts +1 -1
  27. package/dist/server/lib/pre-auth-routing.d.ts +0 -2
  28. package/dist/server/lib/pre-auth-routing.d.ts.map +0 -1
  29. package/dist/server/lib/pre-auth-routing.js +0 -136
  30. package/dist/server/lib/pre-auth-routing.js.map +0 -1
  31. package/src/server/lib/pre-auth-routing.ts +0 -159
@@ -1,159 +0,0 @@
1
- function normalizeBasePath(value?: string): string {
2
- if (!value || value === "/") return "";
3
- const trimmed = value.trim();
4
- if (!trimmed || trimmed === "/") return "";
5
- return `/${trimmed.replace(/^\/+/, "").replace(/\/+$/, "")}`;
6
- }
7
-
8
- function normalizePathname(value: string): string {
9
- if (value === "/") return "/";
10
- return value.replace(/\/+$/, "") || "/";
11
- }
12
-
13
- const DISPATCH_PAGE_PATHS = new Set([
14
- "/overview",
15
- "/metrics",
16
- "/login",
17
- "/signup",
18
- "/apps",
19
- "/new-app",
20
- "/vault",
21
- "/integrations",
22
- "/agents",
23
- "/workspace",
24
- "/tools",
25
- "/messaging",
26
- "/destinations",
27
- "/identities",
28
- "/approvals",
29
- "/automations",
30
- "/audit",
31
- "/team",
32
- ]);
33
-
34
- const DISPATCH_ROOT_ALIASES = new Map<string, string>([
35
- ...Array.from(DISPATCH_PAGE_PATHS, (path) => [path, path] as const),
36
- ["/approval", "/approval"],
37
- ["/extensions", "/extensions"],
38
- ["/tools", "/tools"],
39
- ["/apps/new-app", "/new-app"],
40
- ]);
41
-
42
- const MOUNTED_DISPATCH_ALIASES = new Map<string, string>([
43
- ["/apps/new-app", "/new-app"],
44
- ]);
45
-
46
- function isDispatchPagePath(pathname: string): boolean {
47
- if (DISPATCH_PAGE_PATHS.has(pathname)) return true;
48
- if (pathname === "/approval" || pathname === "/extensions") return true;
49
- if (pathname === "/tools") return true;
50
- return (
51
- /^\/extensions\/[^/]+$/.test(pathname) ||
52
- /^\/tools\/[^/]+$/.test(pathname) ||
53
- /^\/apps\/[^/]+$/.test(pathname)
54
- );
55
- }
56
-
57
- function isDispatchAssetOrFrameworkPath(pathname: string): boolean {
58
- return (
59
- pathname === "/__manifest" ||
60
- pathname.startsWith("/__manifest/") ||
61
- pathname === "/_agent-native" ||
62
- pathname.startsWith("/_agent-native/") ||
63
- pathname === "/.well-known" ||
64
- pathname.startsWith("/.well-known/") ||
65
- pathname.startsWith("/assets/") ||
66
- pathname.startsWith("/_build/") ||
67
- pathname.endsWith(".js") ||
68
- pathname.endsWith(".css") ||
69
- pathname.endsWith(".map") ||
70
- pathname.endsWith(".ico") ||
71
- pathname.endsWith(".png") ||
72
- pathname.endsWith(".svg") ||
73
- pathname.endsWith(".woff2") ||
74
- pathname.endsWith(".woff")
75
- );
76
- }
77
-
78
- function dispatchNotFoundResponse(): Response {
79
- return new Response("Dispatch route not found", {
80
- status: 404,
81
- headers: { "content-type": "text/plain; charset=utf-8" },
82
- });
83
- }
84
-
85
- export function rootDispatchRedirect(
86
- pathname: string,
87
- search: string,
88
- ): Response | null {
89
- const normalizedPathname = normalizePathname(pathname);
90
- const basePath = normalizeBasePath(
91
- process.env.VITE_APP_BASE_PATH || process.env.APP_BASE_PATH,
92
- );
93
- if (!basePath) return null;
94
-
95
- if (
96
- normalizedPathname === "/__manifest" ||
97
- normalizedPathname.startsWith("/__manifest/") ||
98
- normalizedPathname === "/_agent-native" ||
99
- normalizedPathname.startsWith("/_agent-native/")
100
- ) {
101
- return null;
102
- }
103
-
104
- if (
105
- normalizedPathname === "/.well-known" ||
106
- normalizedPathname.startsWith("/.well-known/")
107
- ) {
108
- return null;
109
- }
110
-
111
- if (normalizedPathname === "/") {
112
- return new Response(null, {
113
- status: 302,
114
- headers: { Location: `${basePath}/overview${search}` },
115
- });
116
- }
117
-
118
- if (normalizedPathname === basePath) {
119
- return new Response(null, {
120
- status: 302,
121
- headers: { Location: `${basePath}/overview${search}` },
122
- });
123
- }
124
-
125
- if (normalizedPathname.startsWith(`${basePath}/`)) {
126
- const dispatchPath = normalizedPathname.slice(basePath.length);
127
- const mountedAlias = MOUNTED_DISPATCH_ALIASES.get(dispatchPath);
128
- if (mountedAlias) {
129
- return new Response(null, {
130
- status: 302,
131
- headers: { Location: `${basePath}${mountedAlias}${search}` },
132
- });
133
- }
134
- if (
135
- isDispatchPagePath(dispatchPath) ||
136
- isDispatchAssetOrFrameworkPath(dispatchPath)
137
- ) {
138
- return null;
139
- }
140
- return dispatchNotFoundResponse();
141
- }
142
-
143
- const rootAlias = DISPATCH_ROOT_ALIASES.get(normalizedPathname);
144
- if (rootAlias) {
145
- return new Response(null, {
146
- status: 302,
147
- headers: { Location: `${basePath}${rootAlias}${search}` },
148
- });
149
- }
150
-
151
- if (/^\/apps\/[^/]+$/.test(normalizedPathname)) {
152
- return new Response(null, {
153
- status: 302,
154
- headers: { Location: `${basePath}${normalizedPathname}${search}` },
155
- });
156
- }
157
-
158
- return dispatchNotFoundResponse();
159
- }