@flexkit/studio 0.1.0 → 0.1.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.
package/dist/astro.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  handleFlexkitRequest
3
- } from "./chunk-C2BPRGGQ.js";
3
+ } from "./chunk-TXK4OFAG.js";
4
4
 
5
5
  // src/auth/astro-api.ts
6
6
  function resultToResponse(result) {
@@ -1,3 +1,23 @@
1
+ // src/auth/bff-session.ts
2
+ var API_TOKEN_PREFIX = "flk-";
3
+ function getBearerToken(authorizationHeader) {
4
+ if (!authorizationHeader) {
5
+ return "";
6
+ }
7
+ const [scheme, token, ...rest] = authorizationHeader.trim().split(/\s+/);
8
+ if (rest.length > 0 || !scheme || !token || scheme.toLowerCase() !== "bearer") {
9
+ return "";
10
+ }
11
+ return token;
12
+ }
13
+ function resolveBffSession(sessionCookie, authorizationHeader) {
14
+ const bearerToken = getBearerToken(authorizationHeader);
15
+ if (bearerToken.startsWith(API_TOKEN_PREFIX)) {
16
+ return { error: "API tokens are not accepted here. Call the project API directly with the token." };
17
+ }
18
+ return { token: sessionCookie || bearerToken };
19
+ }
20
+
1
21
  // src/core/domains.ts
2
22
  var defaultFlexkitDomain = "flexkit.io";
3
23
  var allowedFlexkitDomains = {
@@ -86,22 +106,6 @@ var hopByHopHeaders = /* @__PURE__ */ new Set([
86
106
  "transfer-encoding",
87
107
  "upgrade"
88
108
  ]);
89
- function getBearerToken(authorizationHeader) {
90
- if (!authorizationHeader) {
91
- return "";
92
- }
93
- const [scheme, token, ...rest] = authorizationHeader.trim().split(/\s+/);
94
- if (rest.length > 0) {
95
- return "";
96
- }
97
- if (!scheme || !token) {
98
- return "";
99
- }
100
- if (scheme.toLowerCase() !== "bearer") {
101
- return "";
102
- }
103
- return token;
104
- }
105
109
  function sanitizeForwardHeaders(headers) {
106
110
  const sanitized = new Headers();
107
111
  headers.forEach((value, key) => {
@@ -200,9 +204,12 @@ async function handleFlexkitRequest(ctx) {
200
204
  body = void 0;
201
205
  }
202
206
  }
207
+ const session = resolveBffSession(sessionToken, request.headers.get("authorization"));
208
+ if (session.error) {
209
+ return { type: "json", status: 401, body: { error: session.error } };
210
+ }
203
211
  const forwardHeaders = sanitizeForwardHeaders(request.headers);
204
- const bearerToken = getBearerToken(request.headers.get("authorization"));
205
- const effectiveSessionToken = sessionToken || bearerToken;
212
+ const effectiveSessionToken = session.token;
206
213
  forwardHeaders.delete("Authorization");
207
214
  forwardHeaders.delete("Cookie");
208
215
  if (effectiveSessionToken) {
package/dist/nextjs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  handleFlexkitRequest
3
- } from "./chunk-C2BPRGGQ.js";
3
+ } from "./chunk-TXK4OFAG.js";
4
4
 
5
5
  // src/auth/nextjs-api.ts
6
6
  function resultToNextResponse(result, NextResponse) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  handleFlexkitRequest
3
- } from "./chunk-C2BPRGGQ.js";
3
+ } from "./chunk-TXK4OFAG.js";
4
4
 
5
5
  // src/auth/tanstack-start-api.ts
6
6
  function getCookieValue(cookieHeader, name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flexkit/studio",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Flexkit Studio - Build custom internal tools like PIMs, CRMs, and ERPs with a flexible React UI and a graph-backed API",
5
5
  "keywords": [
6
6
  "flexkit",
@@ -157,8 +157,8 @@
157
157
  "uuid": "^9.0.1",
158
158
  "vaul": "1.1.2",
159
159
  "zod": "4.4.3",
160
- "@flexkit/agent-protocol": "^0.2.0",
161
- "@flexkit/schema": "0.1.0"
160
+ "@flexkit/schema": "0.1.1",
161
+ "@flexkit/agent-protocol": "^0.2.0"
162
162
  },
163
163
  "peerDependencies": {
164
164
  "react": "^19.0.0",
@@ -185,7 +185,7 @@
185
185
  "test:performance": "tsup --config tests/performance.config.ts && node --test build/tests/list-performance.test.js build/tests/editor-preview.test.js",
186
186
  "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
187
187
  "ui:add": "pnpm dlx shadcn@latest add",
188
- "test:core": "tsup --config tests/core.config.ts && node --test build/tests/json-schema-to-zod.test.js build/tests/icon-name.test.js build/tests/project-schemas.test.js build/tests/rating-preview.test.js build/tests/last-project.test.js build/tests/proxy-target.test.js build/tests/project-label.test.js build/tests/hosted-session.test.js",
188
+ "test:core": "tsup --config tests/core.config.ts && node --test build/tests/json-schema-to-zod.test.js build/tests/icon-name.test.js build/tests/project-schemas.test.js build/tests/rating-preview.test.js build/tests/last-project.test.js build/tests/proxy-target.test.js build/tests/project-label.test.js build/tests/hosted-session.test.js build/tests/bff-session.test.js",
189
189
  "test:ai": "tsup --config tests/ai.config.ts && node --test build/tests/ai/*.test.js",
190
190
  "test": "pnpm run test:core && pnpm run test:ai && pnpm run test:performance"
191
191
  }