@flytedesk/app-kit 11.4.0 → 12.0.0
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/README.md +138 -2
- package/dist/auth/errors.d.ts +10 -0
- package/dist/auth/errors.js +14 -0
- package/dist/auth/errors.js.map +1 -1
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.js +1 -0
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/people/lookup.d.ts +32 -0
- package/dist/auth/people/lookup.js +81 -0
- package/dist/auth/people/lookup.js.map +1 -0
- package/dist/auth/prisma/prismaAuthStore.js +1 -6
- package/dist/auth/prisma/prismaAuthStore.js.map +1 -1
- package/dist/auth/revocationReasons.d.ts +4 -0
- package/dist/auth/revocationReasons.js +10 -0
- package/dist/auth/revocationReasons.js.map +1 -0
- package/dist/chat/tools/index.d.ts +38 -0
- package/dist/chat/tools/index.js +60 -0
- package/dist/chat/tools/index.js.map +1 -0
- package/dist/cli/auth-adopt.d.ts +13 -0
- package/dist/cli/auth-adopt.js +201 -0
- package/dist/cli/auth-adopt.js.map +1 -0
- package/dist/cli/auth-sync.js +2 -1
- package/dist/cli/auth-sync.js.map +1 -1
- package/dist/cli/sync-engine.d.ts +8 -0
- package/dist/cli/sync-engine.js +155 -21
- package/dist/cli/sync-engine.js.map +1 -1
- package/dist/flytebot/client.d.ts +66 -0
- package/dist/flytebot/client.js +377 -0
- package/dist/flytebot/client.js.map +1 -0
- package/dist/flytebot/env.d.ts +11 -0
- package/dist/flytebot/env.js +25 -0
- package/dist/flytebot/env.js.map +1 -0
- package/dist/flytebot/error.d.ts +36 -0
- package/dist/flytebot/error.js +60 -0
- package/dist/flytebot/error.js.map +1 -0
- package/dist/flytebot/index.d.ts +32 -0
- package/dist/flytebot/index.js +28 -0
- package/dist/flytebot/index.js.map +1 -0
- package/dist/flytebot/sse.d.ts +11 -0
- package/dist/flytebot/sse.js +55 -0
- package/dist/flytebot/sse.js.map +1 -0
- package/dist/flytebot/testing/fake.d.ts +77 -0
- package/dist/flytebot/testing/fake.js +399 -0
- package/dist/flytebot/testing/fake.js.map +1 -0
- package/dist/flytebot/testing/index.d.ts +18 -0
- package/dist/flytebot/testing/index.js +18 -0
- package/dist/flytebot/testing/index.js.map +1 -0
- package/dist/flytebot/webhook.d.ts +24 -0
- package/dist/flytebot/webhook.js +63 -0
- package/dist/flytebot/webhook.js.map +1 -0
- package/dist/spa-server/index.d.ts +8 -16
- package/dist/spa-server/index.js +36 -4
- package/dist/spa-server/index.js.map +1 -1
- package/package.json +17 -2
- package/prisma/fragments/auth.prisma +9 -3
- package/prisma/migrations/0004_app_kit_auth_init/migration.sql +74 -41
- package/prisma/migrations/manifest.json +1 -1
package/dist/spa-server/index.js
CHANGED
|
@@ -13,11 +13,15 @@
|
|
|
13
13
|
* does: `sirv-cli`'s flags can't express a DIFFERENT Cache-Control per path, only one
|
|
14
14
|
* value for the whole tree.
|
|
15
15
|
*/
|
|
16
|
+
import { stat } from "node:fs/promises";
|
|
16
17
|
import { createServer } from "node:http";
|
|
18
|
+
import { resolve, sep } from "node:path";
|
|
17
19
|
import fp from "fastify-plugin";
|
|
18
20
|
import sirv from "sirv";
|
|
19
21
|
/** Vite's own default output directory for content-hashed files. */
|
|
20
22
|
export const DEFAULT_ASSET_PREFIX = "/assets/";
|
|
23
|
+
const IMMUTABLE_CACHE_CONTROL = "public, max-age=31536000, immutable";
|
|
24
|
+
const NO_CACHE_CONTROL = "no-cache";
|
|
21
25
|
/**
|
|
22
26
|
* THE Cache-Control policy of a served SPA (AK-18, AK-59) — the one place it is written.
|
|
23
27
|
* `createSpaServer`, the `spa-server` bin and `spaCachePolicy` (the Fastify plugin) all
|
|
@@ -27,14 +31,39 @@ export const DEFAULT_ASSET_PREFIX = "/assets/";
|
|
|
27
31
|
*/
|
|
28
32
|
export function spaCacheControl(pathname, assetPrefix = DEFAULT_ASSET_PREFIX) {
|
|
29
33
|
return pathname.startsWith(assetPrefix)
|
|
30
|
-
?
|
|
31
|
-
:
|
|
34
|
+
? IMMUTABLE_CACHE_CONTROL
|
|
35
|
+
: NO_CACHE_CONTROL;
|
|
36
|
+
}
|
|
37
|
+
/** True when `pathname` names an existing regular file inside the asset directory
|
|
38
|
+
* (`dir` + `assetPrefix`). A traversal out of it or a malformed percent-escape is not
|
|
39
|
+
* an asset. */
|
|
40
|
+
async function isServedAsset(dir, assetPrefix, pathname) {
|
|
41
|
+
let decoded;
|
|
42
|
+
try {
|
|
43
|
+
decoded = decodeURIComponent(pathname);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
const root = resolve(dir, `.${assetPrefix}`);
|
|
49
|
+
const file = resolve(resolve(dir), `.${decoded}`);
|
|
50
|
+
if (!file.startsWith(root + sep))
|
|
51
|
+
return false;
|
|
52
|
+
try {
|
|
53
|
+
return (await stat(file)).isFile();
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
32
58
|
}
|
|
33
59
|
/**
|
|
34
60
|
* The same policy for a Fastify app that serves its SPA itself (e.g. with
|
|
35
61
|
* `@fastify/static`): `app.register(spaCachePolicy, { assetPrefix })` stamps
|
|
36
62
|
* `spaCacheControl` on every successful (status < 400) response of the routes in the
|
|
37
|
-
* scope it is registered in, unless the route set its own Cache-Control.
|
|
63
|
+
* scope it is registered in, unless the route set its own Cache-Control. A path under
|
|
64
|
+
* `assetPrefix` is immutable only when it is a real file in `dir`: an app's not-found
|
|
65
|
+
* handler serving `index.html` for a missing `/assets/old.js` is a fallback page and
|
|
66
|
+
* gets `no-cache`, as `createSpaServer` (which decides by the file it served) does. The hook covers the
|
|
38
67
|
* scope the plugin is registered in and its children, never the parent: register it
|
|
39
68
|
* inside a scope that holds only the SPA routes (`app.register(async (spa) => {
|
|
40
69
|
* await spa.register(spaCachePolicy); ...static routes... })`) so the app's API routes
|
|
@@ -44,7 +73,10 @@ export const spaCachePolicy = fp(async (app, options) => {
|
|
|
44
73
|
app.addHook("onSend", async (request, reply, payload) => {
|
|
45
74
|
if (reply.statusCode < 400 && !reply.hasHeader("cache-control")) {
|
|
46
75
|
const pathname = request.url.split("?")[0] ?? request.url;
|
|
47
|
-
|
|
76
|
+
const assetPrefix = options.assetPrefix ?? DEFAULT_ASSET_PREFIX;
|
|
77
|
+
const immutable = pathname.startsWith(assetPrefix) && (await isServedAsset(options.dir, assetPrefix, pathname));
|
|
78
|
+
// AK-63: the URL alone does not make a response an asset; the file served does.
|
|
79
|
+
reply.header("cache-control", immutable ? spaCacheControl(pathname, assetPrefix) : NO_CACHE_CONTROL);
|
|
48
80
|
}
|
|
49
81
|
return payload;
|
|
50
82
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/spa-server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,YAAY,EAA0D,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/spa-server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,YAAY,EAA0D,MAAM,WAAW,CAAC;AACjG,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,oEAAoE;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;AAE/C,MAAM,uBAAuB,GAAG,qCAAqC,CAAC;AACtE,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAgB,EAChB,cAAsB,oBAAoB;IAE1C,OAAO,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC;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C;IAClC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,SAAS,CAAC;IACvC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC,CAAC;IAClG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flytedesk/app-kit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
4
|
"description": "Shared platform kit for flytedesk apps: flytedesk-id auth (BFF/OIDC client) and a Postgres-native trace/audit layer.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -93,6 +93,18 @@
|
|
|
93
93
|
"types": "./dist/chat/index.d.ts",
|
|
94
94
|
"import": "./dist/chat/index.js"
|
|
95
95
|
},
|
|
96
|
+
"./chat/tools": {
|
|
97
|
+
"types": "./dist/chat/tools/index.d.ts",
|
|
98
|
+
"import": "./dist/chat/tools/index.js"
|
|
99
|
+
},
|
|
100
|
+
"./flytebot": {
|
|
101
|
+
"types": "./dist/flytebot/index.d.ts",
|
|
102
|
+
"import": "./dist/flytebot/index.js"
|
|
103
|
+
},
|
|
104
|
+
"./flytebot/testing": {
|
|
105
|
+
"types": "./dist/flytebot/testing/index.d.ts",
|
|
106
|
+
"import": "./dist/flytebot/testing/index.js"
|
|
107
|
+
},
|
|
96
108
|
"./spa-server": {
|
|
97
109
|
"types": "./dist/spa-server/index.d.ts",
|
|
98
110
|
"import": "./dist/spa-server/index.js"
|
|
@@ -180,11 +192,14 @@
|
|
|
180
192
|
},
|
|
181
193
|
"dependencies": {
|
|
182
194
|
"@fastify/cookie": "^11.0.1",
|
|
195
|
+
"@flytedesk/flytebot-contracts": "^0.2.0",
|
|
183
196
|
"cross-spawn": "^7.0.6",
|
|
184
197
|
"fastify-plugin": "^6.0.0",
|
|
198
|
+
"google-auth-library": "^11.3.1",
|
|
185
199
|
"jose": "^6.2.10",
|
|
186
200
|
"node-sql-parser": "^5.4.0",
|
|
187
201
|
"pgsql-ast-parser": "^12.0.2",
|
|
188
|
-
"sirv": "^3.0.2"
|
|
202
|
+
"sirv": "^3.0.2",
|
|
203
|
+
"zod": "^4.6.7"
|
|
189
204
|
}
|
|
190
205
|
}
|
|
@@ -12,11 +12,16 @@
|
|
|
12
12
|
// - Models are named IdpSession / RefreshToken / AuthAuditLog so a client exposes
|
|
13
13
|
// `idpSession`, `refreshToken` and `authAuditLog`, exactly what `PrismaAuthStore`'s
|
|
14
14
|
// structural client asks for. Tables are prefixed `app_kit_` via `@@map`; columns are snake_case via `@map`,
|
|
15
|
-
// matching prisma/migrations/0004_app_kit_auth_init/migration.sql exactly
|
|
15
|
+
// matching prisma/migrations/0004_app_kit_auth_init/migration.sql exactly (that SQL is
|
|
16
|
+
// what Prisma derives from this file, plus the CHECKs below).
|
|
16
17
|
// - The only relation is IdpSession -> RefreshToken (both models are in this
|
|
17
18
|
// fragment): signing out deletes the session and the cascade removes its tokens.
|
|
18
|
-
// - `
|
|
19
|
+
// - `app_kit_refresh_token_revocation_complete` (a CHECK in the migration) makes
|
|
19
20
|
// `revokedAt` and `revokedReason` NULL together: a revoked row always says why.
|
|
21
|
+
// - `app_kit_refresh_token_revoked_reason_valid` (a CHECK in the migration) limits
|
|
22
|
+
// `revokedReason` to its four values. Prisma's schema language has no CHECK, so an
|
|
23
|
+
// app on Prisma migrate adds both to its generated migration (`auth-sync init`
|
|
24
|
+
// prints the statements; `auth-sync adopt` emits them).
|
|
20
25
|
|
|
21
26
|
model IdpSession {
|
|
22
27
|
id String @id @default(uuid())
|
|
@@ -43,7 +48,8 @@ model RefreshToken {
|
|
|
43
48
|
idpSessionId String @map("idp_session_id")
|
|
44
49
|
idpSession IdpSession @relation(fields: [idpSessionId], references: [id], onDelete: Cascade)
|
|
45
50
|
revokedAt DateTime? @map("revoked_at")
|
|
46
|
-
/// NULL exactly when `revokedAt` is NULL
|
|
51
|
+
/// NULL exactly when `revokedAt` is NULL, and one of rotated / reuse_detected / signed_out /
|
|
52
|
+
/// authorization_rejected (CHECK constraints in the migration).
|
|
47
53
|
revokedReason String? @map("revoked_reason")
|
|
48
54
|
expiresAt DateTime @map("expires_at")
|
|
49
55
|
userAgent String? @map("user_agent")
|
|
@@ -1,47 +1,80 @@
|
|
|
1
1
|
-- @flytedesk/app-kit/auth/prisma :: 0004_app_kit_auth_init
|
|
2
2
|
--
|
|
3
|
-
--
|
|
4
|
-
--
|
|
5
|
-
--
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
-- The SQL `prisma migrate diff --from-empty --to-schema prisma/fragments/auth.prisma --script`
|
|
4
|
+
-- derives from the fragment (src/cli/auth-sql.test.ts asserts they are identical), then the
|
|
5
|
+
-- CHECK constraints Prisma's schema language cannot express. For an app that does not use
|
|
6
|
+
-- Prisma migrate; an app that does never receives this file (see sync-engine.ts).
|
|
7
|
+
|
|
8
|
+
-- CreateSchema
|
|
9
|
+
CREATE SCHEMA IF NOT EXISTS "public";
|
|
10
|
+
|
|
11
|
+
-- CreateTable
|
|
12
|
+
CREATE TABLE "app_kit_idp_session" (
|
|
13
|
+
"id" TEXT NOT NULL,
|
|
14
|
+
"subject" TEXT NOT NULL,
|
|
15
|
+
"name" TEXT NOT NULL,
|
|
16
|
+
"email" TEXT NOT NULL,
|
|
17
|
+
"idp_access_token" TEXT NOT NULL,
|
|
18
|
+
"idp_access_token_expires_at" TIMESTAMP(3) NOT NULL,
|
|
19
|
+
"idp_refresh_token" TEXT,
|
|
20
|
+
"id_token" TEXT NOT NULL,
|
|
21
|
+
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
22
|
+
|
|
23
|
+
CONSTRAINT "app_kit_idp_session_pkey" PRIMARY KEY ("id")
|
|
16
24
|
);
|
|
17
25
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
-- CreateTable
|
|
27
|
+
CREATE TABLE "app_kit_refresh_token" (
|
|
28
|
+
"id" TEXT NOT NULL,
|
|
29
|
+
"family_id" TEXT NOT NULL,
|
|
30
|
+
"user_id" TEXT NOT NULL,
|
|
31
|
+
"token_hash" TEXT NOT NULL,
|
|
32
|
+
"idp_session_id" TEXT NOT NULL,
|
|
33
|
+
"revoked_at" TIMESTAMP(3),
|
|
34
|
+
"revoked_reason" TEXT,
|
|
35
|
+
"expires_at" TIMESTAMP(3) NOT NULL,
|
|
36
|
+
"user_agent" TEXT,
|
|
37
|
+
"ip" TEXT NOT NULL,
|
|
38
|
+
"replaces_id" TEXT,
|
|
39
|
+
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
40
|
+
|
|
41
|
+
CONSTRAINT "app_kit_refresh_token_pkey" PRIMARY KEY ("id")
|
|
33
42
|
);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
CREATE
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
|
|
44
|
+
-- CreateTable
|
|
45
|
+
CREATE TABLE "app_kit_auth_audit_log" (
|
|
46
|
+
"id" TEXT NOT NULL,
|
|
47
|
+
"family_id" TEXT NOT NULL,
|
|
48
|
+
"reason" TEXT NOT NULL,
|
|
49
|
+
"rotated_at" TIMESTAMP(3) NOT NULL,
|
|
50
|
+
"ip" TEXT,
|
|
51
|
+
"user_agent" TEXT,
|
|
52
|
+
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
53
|
+
|
|
54
|
+
CONSTRAINT "app_kit_auth_audit_log_pkey" PRIMARY KEY ("id")
|
|
46
55
|
);
|
|
47
|
-
|
|
56
|
+
|
|
57
|
+
-- CreateIndex
|
|
58
|
+
CREATE UNIQUE INDEX "app_kit_refresh_token_token_hash_key" ON "app_kit_refresh_token"("token_hash");
|
|
59
|
+
|
|
60
|
+
-- CreateIndex
|
|
61
|
+
CREATE INDEX "app_kit_refresh_token_family_id_idx" ON "app_kit_refresh_token"("family_id");
|
|
62
|
+
|
|
63
|
+
-- CreateIndex
|
|
64
|
+
CREATE INDEX "app_kit_refresh_token_replaces_id_idx" ON "app_kit_refresh_token"("replaces_id");
|
|
65
|
+
|
|
66
|
+
-- CreateIndex
|
|
67
|
+
CREATE INDEX "app_kit_refresh_token_idp_session_id_idx" ON "app_kit_refresh_token"("idp_session_id");
|
|
68
|
+
|
|
69
|
+
-- CreateIndex
|
|
70
|
+
CREATE INDEX "app_kit_auth_audit_log_family_id_idx" ON "app_kit_auth_audit_log"("family_id");
|
|
71
|
+
|
|
72
|
+
-- AddForeignKey
|
|
73
|
+
ALTER TABLE "app_kit_refresh_token" ADD CONSTRAINT "app_kit_refresh_token_idp_session_id_fkey" FOREIGN KEY ("idp_session_id") REFERENCES "app_kit_idp_session"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
-- AddCheck: a revoked row always says why, and a live one never does (Prisma has no CHECK syntax).
|
|
77
|
+
ALTER TABLE "app_kit_refresh_token" ADD CONSTRAINT "app_kit_refresh_token_revocation_complete" CHECK (("revoked_at" IS NULL) = ("revoked_reason" IS NULL));
|
|
78
|
+
|
|
79
|
+
-- AddCheck: revoked_reason holds exactly app-kit's RefreshTokenRevocationReason values.
|
|
80
|
+
ALTER TABLE "app_kit_refresh_token" ADD CONSTRAINT "app_kit_refresh_token_revoked_reason_valid" CHECK ("revoked_reason" IN ('rotated', 'reuse_detected', 'signed_out', 'authorization_rejected'));
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"id": "0004_app_kit_auth_init",
|
|
25
25
|
"fragment": "auth",
|
|
26
26
|
"file": "0004_app_kit_auth_init/migration.sql",
|
|
27
|
-
"checksum": "sha256:
|
|
27
|
+
"checksum": "sha256:f1d725a4862362ab31c188de27c6c552aa755e63e3f907e6244a407e918a0bc9",
|
|
28
28
|
"introducedInFragmentVersion": "1.0.0"
|
|
29
29
|
}
|
|
30
30
|
]
|