@starci/eslint-canon-be 3.12.0 → 3.13.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/CHANGELOG.md +5 -0
- package/dist/auth-passport.d.ts +2 -4
- package/dist/auth-passport.js +21 -33
- package/dist/lib/unit-spec.js +2 -2
- package/package.json +1 -1
- package/runtime/knowledge/hfs/canon-pins.yaml +30 -9
- package/runtime/knowledge/hfs/fe-stack.yaml +7 -7
- package/runtime/knowledge/hfs/rules.yaml +55 -7
- package/runtime/knowledge/hfs/slots.yaml +71 -22
- package/runtime/scripts/hfs/architecture/identity.mjs +18 -83
- package/runtime/scripts/hfs/architecture/transport-owner.mjs +3 -6
- package/runtime/scripts/hfs/manifest-shape.mjs +1 -1
- package/runtime/scripts/hfs/slots.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.13.0 - 2026-11-03
|
|
4
|
+
|
|
5
|
+
- Changed: the runtime copies of the slot manifest carry the managed sign-in slots and the slot field `managedOnly`.
|
|
6
|
+
- Changed: `own-jwks-only` refuses `jwtVerify`, `decodeJwt`, `decodeProtectedHeader` and `createRemoteJWKSet` of jose in every app file; `refresh-token-cookie-only` no longer exempts `integrations/passport` (the package sets the cookie); the infrastructure table owns the identity libraries by nobody and `@starci/auth` by `integrations/passport` (R328, R329, R330).
|
|
7
|
+
|
|
3
8
|
## 3.12.0
|
|
4
9
|
|
|
5
10
|
- Added: `starci-be/explicit-export-surface` (R368, `HFS_EXPLICIT_EXPORT_SURFACE`) at error: an exported function's return type, an exported variable's type and a parameter's type are written, not inferred from a body or from other files. It reports each export the isolated declaration emit cannot write, at the offending span, and says what to annotate. It reads the classifier the lint result cache reads.
|
package/dist/auth-passport.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { Recommended, RuleModule } from "./lib/rule.js";
|
|
2
|
-
/**
|
|
3
|
-
export declare const PASSPORT_OWNER = "integrations/passport";
|
|
4
|
-
/** A lite principal comes only from the app's own verified token. */
|
|
2
|
+
/** A lite principal comes only from the app's own token, verified by the package. */
|
|
5
3
|
export declare const ownJwksOnly: RuleModule;
|
|
6
|
-
/** A refresh token lives only in the
|
|
4
|
+
/** A refresh token lives only in the package's httpOnly cookie. */
|
|
7
5
|
export declare const refreshTokenCookieOnly: RuleModule;
|
|
8
6
|
/** The rules of the lite identity law, by name. */
|
|
9
7
|
export declare const rules: {
|
package/dist/auth-passport.js
CHANGED
|
@@ -1,44 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The rules of the lite identity (catalog R329 `BE_AUTH_JWT_OWN_JWKS`, R330 `BE_AUTH_REFRESH_COOKIE`; contexts/code/be/api-auth.md
|
|
3
3
|
* BE-AUTH-2 and BE-AUTH-3). Which owner may import the identity and S3 libraries at all is the infrastructure table of the slot
|
|
4
|
-
* manifest (`ruleParams.be.infraOwners`, judged by `infra-import-owner`: R328 `BE_AUTH_PASSPORT_OWNER`, R331 `BE_STORAGE_OWNER`)
|
|
4
|
+
* manifest (`ruleParams.be.infraOwners`, judged by `infra-import-owner`: R328 `BE_AUTH_PASSPORT_OWNER`, R331 `BE_STORAGE_OWNER`): the
|
|
5
|
+
* identity libraries belong to `@starci/auth` and to no app file, and `@starci/auth` itself only to `integrations/passport`.
|
|
5
6
|
*
|
|
6
|
-
* - `own-jwks-only`: the app verifies
|
|
7
|
-
* `
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* refresh cookie: the cookie is set, rotated and cleared only by the integration's `setRefreshCookie`/`clearRefreshCookie`.
|
|
13
|
-
* Its attributes (httpOnly, Secure, SameSite=Strict, the refresh path) are `response-cookie-attributes` (R141) and the
|
|
14
|
-
* integration's own spec; rotation with reuse detection is held by the identity domain's spec and review.
|
|
7
|
+
* - `own-jwks-only`: the app verifies no token itself. `createRemoteJWKSet` (a remote identity provider's key set), `decodeJwt`,
|
|
8
|
+
* `decodeProtectedHeader` (a token read without its signature) and `jwtVerify` are refused wherever jose is imported; the package
|
|
9
|
+
* verifies against its own key set. The architecture machine (`own-jwks-principal`) proves the same on the call sites.
|
|
10
|
+
* - `refresh-token-cookie-only`: a refresh token never travels in a body. No object literal, class property or type member is
|
|
11
|
+
* named `refreshToken` or `refresh_token`, and no `.cookie()`/`.clearCookie()` call names a refresh cookie: `@starci/auth` sets,
|
|
12
|
+
* rotates and clears it. Its attributes and rotation with reuse detection are the package's own specs.
|
|
15
13
|
*/
|
|
16
14
|
import { keyName, staticText } from "./lib/ast.js";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export const PASSPORT_OWNER = "integrations/passport";
|
|
20
|
-
/** The jose exports no file uses: a remote key set and the unverified decoders. */
|
|
21
|
-
const FORBIDDEN_JOSE = new Set(["createRemoteJWKSet", "decodeJwt", "decodeProtectedHeader"]);
|
|
15
|
+
/** The jose exports no app file uses: a remote key set, the unverified decoders and the verifier itself. */
|
|
16
|
+
const FORBIDDEN_JOSE = new Set(["createRemoteJWKSet", "decodeJwt", "decodeProtectedHeader", "jwtVerify"]);
|
|
22
17
|
const REFRESH_NAME = /^refresh_?token$/i;
|
|
23
18
|
const REFRESH_COOKIE = /refresh/i;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return root === null ? null : root.split("/").slice(-2).join("/");
|
|
19
|
+
const WHY = {
|
|
20
|
+
createRemoteJWKSet: "trusts another issuer's key set",
|
|
21
|
+
jwtVerify: "verifies a token in the app",
|
|
28
22
|
};
|
|
29
|
-
/** A lite principal comes only from the app's own verified
|
|
23
|
+
/** A lite principal comes only from the app's own token, verified by the package. */
|
|
30
24
|
export const ownJwksOnly = {
|
|
31
25
|
meta: {
|
|
32
26
|
type: "problem",
|
|
33
|
-
docs: { description: "
|
|
27
|
+
docs: { description: "No app file verifies or decodes a token with jose: `@starci/auth` verifies the app's own access tokens against its own key set." },
|
|
34
28
|
schema: [],
|
|
35
29
|
messages: {
|
|
36
|
-
forbidden: "`{{name}}` of jose {{why}}. The app verifies only its own access tokens
|
|
37
|
-
verifier: "`jwtVerify` is imported outside `integrations/passport`. Verify a token through the integration's verifier (`OWN_TOKEN_VERIFIER`), which domain/identity turns into the principal.",
|
|
30
|
+
forbidden: "`{{name}}` of jose {{why}}. The app verifies only its own access tokens, and `@starci/auth` does it (the verifier of `integrations/passport`, `OWN_TOKEN_VERIFIER`, which `domain/identity` turns into the principal).",
|
|
38
31
|
},
|
|
39
32
|
},
|
|
40
33
|
create(context) {
|
|
41
|
-
const owner = ownerIdOf(context, context.filename) === PASSPORT_OWNER;
|
|
42
34
|
return {
|
|
43
35
|
ImportDeclaration(node) {
|
|
44
36
|
if (node.source.value !== "jose")
|
|
@@ -48,29 +40,25 @@ export const ownJwksOnly = {
|
|
|
48
40
|
continue;
|
|
49
41
|
const name = keyName(specifier.imported);
|
|
50
42
|
if (name !== null && FORBIDDEN_JOSE.has(name)) {
|
|
51
|
-
context.report({ node: specifier, messageId: "forbidden", data: { name, why: name
|
|
43
|
+
context.report({ node: specifier, messageId: "forbidden", data: { name, why: WHY[name] ?? "reads a token without proving its signature" } });
|
|
52
44
|
}
|
|
53
|
-
else if (name === "jwtVerify" && !owner)
|
|
54
|
-
context.report({ node: specifier, messageId: "verifier" });
|
|
55
45
|
}
|
|
56
46
|
},
|
|
57
47
|
};
|
|
58
48
|
},
|
|
59
49
|
};
|
|
60
|
-
/** A refresh token lives only in the
|
|
50
|
+
/** A refresh token lives only in the package's httpOnly cookie. */
|
|
61
51
|
export const refreshTokenCookieOnly = {
|
|
62
52
|
meta: {
|
|
63
53
|
type: "problem",
|
|
64
|
-
docs: { description: "A refresh token never appears as a body field, and
|
|
54
|
+
docs: { description: "A refresh token never appears as a body field, and no app file sets or clears the refresh cookie: `@starci/auth` does." },
|
|
65
55
|
schema: [],
|
|
66
56
|
messages: {
|
|
67
|
-
field: "`{{name}}` carries a refresh token in a body. The refresh token lives only in the httpOnly, Secure
|
|
68
|
-
cookie: "`{{call}}` names the refresh cookie
|
|
57
|
+
field: "`{{name}}` carries a refresh token in a body. The refresh token lives only in the httpOnly, Secure cookie that `@starci/auth` sets, rotates and clears.",
|
|
58
|
+
cookie: "`{{call}}` names the refresh cookie in the app. `@starci/auth` sets and clears it through `AuthDoors`; the app never writes it.",
|
|
69
59
|
},
|
|
70
60
|
},
|
|
71
61
|
create(context) {
|
|
72
|
-
if (ownerIdOf(context, context.filename) === PASSPORT_OWNER)
|
|
73
|
-
return {};
|
|
74
62
|
const field = (node, key, computed) => {
|
|
75
63
|
const name = computed ? null : keyName(key);
|
|
76
64
|
if (name !== null && REFRESH_NAME.test(name))
|
package/dist/lib/unit-spec.js
CHANGED
|
@@ -49,8 +49,8 @@ const inRoleSlot = (hfs, role, filename) => (role.optional === true ? inCoverage
|
|
|
49
49
|
/** The path of a classified file below the instance root of its slot. */
|
|
50
50
|
const slotRelative = (found) => (found.root !== undefined && found.path.startsWith(`${found.root}/`) ? found.path.slice(found.root.length + 1) : baseOf(found.path));
|
|
51
51
|
/**
|
|
52
|
-
* The optional spec role of a spec beside a logic file its slot declares (`logic`): `passport.
|
|
53
|
-
* `passport.
|
|
52
|
+
* The optional spec role of a spec beside a logic file its slot declares (`logic`): `passport.kit.spec.ts` beside the declared
|
|
53
|
+
* `passport.kit.ts` gives `{ role: "kit", spec: "kit.spec" }`, so the subject resolves as a logic role's does. It holds for that
|
|
54
54
|
* one declared file only, never for another `*.tokens.ts`, and adds no role name to the manifest.
|
|
55
55
|
*/
|
|
56
56
|
const declaredLogicRole = (hfs, filename) => {
|
package/package.json
CHANGED
|
@@ -30,36 +30,43 @@ pins:
|
|
|
30
30
|
side: fe
|
|
31
31
|
source: packages/event-stream/package.json
|
|
32
32
|
why: 'the one server-sent-events client of every front end (fe-stack event-stream, owner:event-stream-package): the transport client layer (modules/api/sse/clients) creates one instance for the app with the bearer token source and the stream operations follow on it; it carries Last-Event-ID resume, the capped doubling backoff, the heartbeat timeout, the single 401 renewal and the useSWRSubscription adapter, so no app keeps a hand-written reader.'
|
|
33
|
+
'@starci/next-data':
|
|
34
|
+
version: 0.1.0
|
|
35
|
+
group: starci
|
|
36
|
+
install: registry
|
|
37
|
+
side: fe
|
|
38
|
+
source: packages/next-data/package.json
|
|
39
|
+
why: 'the SWR data helpers of every front end (fe-stack data, owner:next-data-package): pollingRestart, the viewer and tenant key helpers, viewerSwrConfig and the viewer cache; each operation hook stays in the app and the package holds no component.'
|
|
33
40
|
'@starci/grammar':
|
|
34
|
-
version: 0.21.
|
|
41
|
+
version: 0.21.14
|
|
35
42
|
group: starci
|
|
36
43
|
install: registry
|
|
37
44
|
side: fe
|
|
38
45
|
source: packages/grammar/package.json
|
|
39
46
|
why: 'the grammar front ends read: the brand layer sets `--font-sans` and `--font-mono` and the grammar reads them; it carries the Input tel kind, the copyable and read-only Input, the IconButton disclosure props and count badge, ChatBubble, FillViewport, Textarea mentions and Enter-to-send, the leading PrimaryRailLayout rail, the plate-less Image, ListRow, the soft Alert, Progress steps, the floating primary IconButton, FlowGraph, the STATE-8 loading views and the bordered selectable TagGroup chips. The runtime source version wins for a @starci package.'
|
|
40
47
|
'@starci/eslint-canon-be':
|
|
41
|
-
version: 3.
|
|
48
|
+
version: 3.13.0
|
|
42
49
|
group: starci
|
|
43
50
|
install: registry
|
|
44
51
|
side: be
|
|
45
52
|
source: packages/eslint-canon-be/package.json
|
|
46
53
|
why: 'the back-end ESLint canon: `loadHfs(import.meta.url)` of be/eslint.config.mjs finds the app-root hfs.json (kind app) and gives every linted file the view of the be side, and the project graph is built per side; its bundled runtime copies (slots, canon-pins, failure codes, the architecture machine) put .starcistacks and .sops.yaml at the app root; `starciBeConfig({ hfs: loadHfs(import.meta.url) })` is the typed factory and the BE-CONVENTION laws are its rules.'
|
|
47
54
|
'@starci/eslint-canon-fe':
|
|
48
|
-
version: 9.
|
|
55
|
+
version: 9.11.0
|
|
49
56
|
group: starci
|
|
50
57
|
install: registry
|
|
51
58
|
side: fe
|
|
52
59
|
source: packages/eslint-canon-fe/package.json
|
|
53
60
|
why: 'the front-end ESLint canon: `loadHfs(import.meta.url)` of fe/eslint.config.mjs finds the app-root hfs.json (kind app) and gives every linted file the view of the fe side, and the project graph is built per side; its bundled runtime copies (slots, canon-pins, failure codes, the architecture machine) put .starcistacks and .sops.yaml at the app root; the front end has no tests (FE_NO_TESTS R97 in hfs) and no-vietnamese-in-source (R91) applies.'
|
|
54
61
|
'@starci/eslint-grammar-core':
|
|
55
|
-
version: 0.21.
|
|
62
|
+
version: 0.21.14
|
|
56
63
|
group: starci
|
|
57
64
|
install: registry
|
|
58
65
|
side: fe
|
|
59
66
|
source: packages/eslint-grammar-core/package.json
|
|
60
67
|
why: 'the StarCi Grammar component API lint, versioned with @starci/grammar; front ends compose this family package with the universal FE canon.'
|
|
61
68
|
'@starci/eslint-grammar-offset-pop':
|
|
62
|
-
version: 0.21.
|
|
69
|
+
version: 0.21.14
|
|
63
70
|
group: starci
|
|
64
71
|
install: registry
|
|
65
72
|
side: fe
|
|
@@ -85,7 +92,7 @@ pins:
|
|
|
85
92
|
side: both
|
|
86
93
|
source: packages/prettier-config/package.json
|
|
87
94
|
'@starci/jest-preset':
|
|
88
|
-
version: 2.6.
|
|
95
|
+
version: 2.6.1
|
|
89
96
|
group: starci
|
|
90
97
|
install: registry
|
|
91
98
|
side: be
|
|
@@ -105,8 +112,22 @@ pins:
|
|
|
105
112
|
side: be
|
|
106
113
|
source: packages/ai-router/package.json
|
|
107
114
|
why: 'the AI pool router of a back end: a NestJS module that routes OpenAI-compatible chat, stream and embeddings calls across keys, models and providers, with @starci/ai-router/testing for its specs; @starci/jest-preset compiles it as an ESM-only dependency.'
|
|
115
|
+
'@starci/auth':
|
|
116
|
+
version: 0.1.0
|
|
117
|
+
group: starci
|
|
118
|
+
install: registry
|
|
119
|
+
side: both
|
|
120
|
+
source: packages/auth/package.json
|
|
121
|
+
why: 'the lite sign-in: the NestJS module (EdDSA access tokens with a multi-key JWKS, passwords, Google OAuth with state and PKCE, rotating refresh sessions, the sign-in budget, the refresh cookie), the front-end client and its React bindings, the door contracts and test doubles; the one importer of the identity libraries, reached by a back end only through integrations/passport; @starci/jest-preset compiles it as an ESM-only dependency.'
|
|
122
|
+
'@starci/object-storage':
|
|
123
|
+
version: 0.1.0
|
|
124
|
+
group: starci
|
|
125
|
+
install: registry
|
|
126
|
+
side: be
|
|
127
|
+
source: packages/object-storage/package.json
|
|
128
|
+
why: 'object storage of a back end: a NestJS module and the ObjectStorage port over S3-compatible storage (presigned PUT and GET that sign the content type and size, head, get, put, list, delete, bucket setup, size and content-type limits, coded errors), with @starci/object-storage/testing for its specs; the only importer of @aws-sdk/client-s3 and @aws-sdk/s3-request-presigner (R331).'
|
|
108
129
|
'@starci/hfs':
|
|
109
|
-
version: 5.
|
|
130
|
+
version: 5.2.0
|
|
110
131
|
group: starci
|
|
111
132
|
install: registry
|
|
112
133
|
side: both
|
|
@@ -543,12 +564,12 @@ pins:
|
|
|
543
564
|
version: 3.1150.0
|
|
544
565
|
group: framework
|
|
545
566
|
side: be
|
|
546
|
-
why: 'the S3 transport
|
|
567
|
+
why: 'the S3 transport inside @starci/object-storage, the one ObjectStorage adapter of both editions (MinIO, S3, Spaces), which depends on it at exactly this version and which no app file imports; 3.1150.0 is the release of 2026-10-12, chosen over newer ones that had not aged two weeks.'
|
|
547
568
|
'@aws-sdk/s3-request-presigner':
|
|
548
569
|
version: 3.1150.0
|
|
549
570
|
group: framework
|
|
550
571
|
side: be
|
|
551
|
-
why: 'signs the presigned PUT and GET
|
|
572
|
+
why: 'signs the presigned PUT and GET inside @starci/object-storage locally, the same release as client-s3; no app file imports it.'
|
|
552
573
|
'@apollo/server':
|
|
553
574
|
version: 5.5.1
|
|
554
575
|
group: framework
|
|
@@ -37,17 +37,17 @@ concerns:
|
|
|
37
37
|
- id: rest
|
|
38
38
|
tier: core
|
|
39
39
|
packages: [axios]
|
|
40
|
-
home: [fe.modules.api
|
|
40
|
+
home: [fe.modules.api]
|
|
41
41
|
pattern: FE-API-REST
|
|
42
42
|
forbids: [ky, superagent, node-fetch, cross-fetch, isomorphic-fetch]
|
|
43
|
-
why: modules/api/rest/<area>/*.ts for uploads and presigned URLs,
|
|
43
|
+
why: modules/api/rest/<area>/*.ts for uploads and presigned URLs, only; GraphQL carries every other call.
|
|
44
44
|
- id: data
|
|
45
45
|
tier: core
|
|
46
|
-
packages: [swr]
|
|
46
|
+
packages: [swr, '@starci/next-data']
|
|
47
47
|
home: [fe.hooks.swr]
|
|
48
48
|
pattern: FE-DATA-SWR
|
|
49
49
|
forbids: ['@tanstack/react-query', react-query]
|
|
50
|
-
why: hooks/swr/api/{graphql,rest}/{queries,mutations}/use*Swr.ts wrap one operation each; components call hooks only.
|
|
50
|
+
why: hooks/swr/api/{graphql,rest}/{queries,mutations}/use*Swr.ts wrap one operation each; components call hooks only. The polling-restart middleware (pollingRestart), the key helpers, the viewer-keyed config and the viewer cache are @starci/next-data's (owner next-data-package); an app imports no Middleware or ScopedMutator type of swr and writes none of them.
|
|
51
51
|
- id: toast
|
|
52
52
|
tier: core
|
|
53
53
|
packages: ['@heroui/react']
|
|
@@ -96,11 +96,11 @@ concerns:
|
|
|
96
96
|
hand-written reader (read-event-stream.ts) and no second SSE library is installed.
|
|
97
97
|
- id: auth
|
|
98
98
|
tier: core
|
|
99
|
-
packages: []
|
|
99
|
+
packages: ['@starci/auth']
|
|
100
100
|
home: [fe.modules.auth]
|
|
101
101
|
pattern: FE-AUTH
|
|
102
|
-
forbids: ['@supabase/supabase-js', '@supabase/ssr', '@supabase/auth-js']
|
|
103
|
-
why: modules/auth is the session issuer's client (
|
|
102
|
+
forbids: ['@supabase/supabase-js', '@supabase/ssr', '@supabase/auth-js', jose, jwt-decode, next-auth, '@auth/core', keycloak-js, oidc-client-ts]
|
|
103
|
+
why: modules/auth is the session issuer's client (one @starci/auth client instance over the app's own back-end auth doors, the access token in its memory; full - the app's IdP client); it yields the session and the access token for the Apollo link and never reads data.
|
|
104
104
|
- id: i18n
|
|
105
105
|
tier: core
|
|
106
106
|
packages: [next-intl]
|
|
@@ -4084,6 +4084,7 @@ rules:
|
|
|
4084
4084
|
enforcers:
|
|
4085
4085
|
- {kind: hfs, id: fe-stack, at: scripts/hfs/rules/fe-stack.mjs}
|
|
4086
4086
|
- {kind: eslint-fe, id: fe-stack-import}
|
|
4087
|
+
- {kind: eslint-fe, id: swr-extension-from-package}
|
|
4087
4088
|
proves:
|
|
4088
4089
|
- {path: packages/eslint/fe/frontend-boundary-coverage.spec.mjs, editions: [lite, full], codes: [FE_STACK_FORBIDDEN]}
|
|
4089
4090
|
- {path: packages/hfs/src/frontend-boundary-coverage.spec.mjs, editions: [lite, full], codes: [FE_STACK_FORBIDDEN]}
|
|
@@ -5696,7 +5697,7 @@ rules:
|
|
|
5696
5697
|
ruling: "A model call made straight from code uses LangChain with retrieved context, through the ai-router gateway (owner ruling be-ai-langchain-gateway): the LangChain clients point at the gateway's base URL with its virtual key."
|
|
5697
5698
|
- id: R328
|
|
5698
5699
|
code: "BE_AUTH_PASSPORT_OWNER"
|
|
5699
|
-
law: "The identity libraries (@nestjs/passport, passport, passport-google-oauth20, passport-local, @nestjs/jwt, jose and bcryptjs) are
|
|
5700
|
+
law: "The identity libraries (@nestjs/passport, passport, passport-google-oauth20, passport-local, @nestjs/jwt, jose and bcryptjs) are the dependencies of @starci/auth and are imported by no app file; @starci/auth/server is imported only by integrations/passport, its one glue. bcrypt and every Supabase client are owned nowhere."
|
|
5700
5701
|
kinds: [lint]
|
|
5701
5702
|
gates: [pre-commit, settle, land, ci]
|
|
5702
5703
|
failureCodes: ["BE_AUTH_PASSPORT_OWNER"]
|
|
@@ -5718,7 +5719,7 @@ rules:
|
|
|
5718
5719
|
ruling: "Lite leaves Supabase: its identity is the app own Passport integration (Google OAuth and email/password) on its self-hosted PostgreSQL; full keeps Keycloak."
|
|
5719
5720
|
- id: R329
|
|
5720
5721
|
code: "BE_AUTH_JWT_OWN_JWKS"
|
|
5721
|
-
law: "A lite back-end principal comes only from the app's own access token verified by
|
|
5722
|
+
law: "A lite back-end principal comes only from the app's own access token, verified by @starci/auth (EdDSA pinned, issuer and audience checked, a local key set that may hold several keys), never from a remote JWKS, a token decoded without its signature check, a jwtVerify call in the app or a body claim."
|
|
5722
5723
|
kinds: [check, lint]
|
|
5723
5724
|
gates: [pre-commit, settle, land, ci]
|
|
5724
5725
|
failureCodes: ["BE_AUTH_JWT_OWN_JWKS"]
|
|
@@ -5742,7 +5743,7 @@ rules:
|
|
|
5742
5743
|
ruling: "The lite back end verifies its own asymmetric access tokens against its own JWKS; it trusts no remote identity provider."
|
|
5743
5744
|
- id: R330
|
|
5744
5745
|
code: "BE_AUTH_REFRESH_COOKIE"
|
|
5745
|
-
law: "A refresh token travels only in
|
|
5746
|
+
law: "A refresh token travels only in the httpOnly, Secure cookie that @starci/auth sets, rotates (with a reuse grace window and reuse detection) and clears; no app file writes that cookie, and the token never appears as a field of a request or response body."
|
|
5746
5747
|
kinds: [lint]
|
|
5747
5748
|
gates: [pre-commit, settle, land, ci]
|
|
5748
5749
|
failureCodes: ["BE_AUTH_REFRESH_COOKIE"]
|
|
@@ -5764,7 +5765,7 @@ rules:
|
|
|
5764
5765
|
ruling: "The refresh token of the lite identity rotates and lives only in an httpOnly cookie; the browser holds no credential."
|
|
5765
5766
|
- id: R331
|
|
5766
5767
|
code: "BE_STORAGE_OWNER"
|
|
5767
|
-
law: "The S3 client (@aws-sdk/client-s3 and @aws-sdk/s3-request-presigner)
|
|
5768
|
+
law: "The S3 client libraries (@aws-sdk/client-s3 and @aws-sdk/s3-request-presigner) are the dependencies of @starci/object-storage, the ObjectStorage port over S3-compatible storage (MinIO in lite) with presigned PUT and GET, and are imported by no app file; @starci/object-storage is imported only by integrations/object-storage, its one glue; no module imports minio."
|
|
5768
5769
|
kinds: [lint]
|
|
5769
5770
|
gates: [pre-commit, settle, land, ci]
|
|
5770
5771
|
failureCodes: ["BE_STORAGE_OWNER"]
|
|
@@ -5773,11 +5774,11 @@ rules:
|
|
|
5773
5774
|
editions: [lite, full]
|
|
5774
5775
|
docs: [contexts/code/be/infra.md]
|
|
5775
5776
|
proves:
|
|
5776
|
-
- packages/eslint-canon-be/src/
|
|
5777
|
+
- packages/eslint-canon-be/src/object-storage-package.spec.ts
|
|
5777
5778
|
exemplifiedBy:
|
|
5778
|
-
- {path: packages/hfs/templates/be/skeleton-lite/src/modules/integrations/object-storage/object-storage.
|
|
5779
|
+
- {path: packages/hfs/templates/be/skeleton-lite/src/modules/integrations/object-storage/object-storage.module.ts, edition: lite}
|
|
5779
5780
|
witness:
|
|
5780
|
-
- {path: packages/eslint-canon-be/src/
|
|
5781
|
+
- {path: packages/eslint-canon-be/src/object-storage-package.spec.ts, editions: [lite, full], codes: [BE_STORAGE_OWNER]}
|
|
5781
5782
|
cases:
|
|
5782
5783
|
- id: case-1
|
|
5783
5784
|
date: "2026-10-29"
|
|
@@ -6576,3 +6577,50 @@ rules:
|
|
|
6576
6577
|
source: owner
|
|
6577
6578
|
quote: "no lint caught it"
|
|
6578
6579
|
ruling: "A directive below an import broke Nivo's CI build on 2026-11-02; the directive is the first statement of its module and a lint reports it elsewhere."
|
|
6580
|
+
- id: R372
|
|
6581
|
+
code: "STACKS_LOCAL_CONFIG_INVALID"
|
|
6582
|
+
law: "In lite and full apps, every docker-compose environment of .starcistacks/application-stacks.yaml declares a coherent `local` block, judged by the same normalizeLocal the dev verbs of `starci app stack` (doctor, prepare, up, status, logs, verify, down) use: closed fields, one loopback port each, compose services that exist in the compose files, an environment-owned database role (never postgres, never the app role), dev-only custody generators and loopback probes; and a lite app declares at least one such dev environment, so `starci app stack up --env dev` has something to run."
|
|
6583
|
+
kinds: [check]
|
|
6584
|
+
gates: [settle, land, ci]
|
|
6585
|
+
failureCodes: ["STACKS_LOCAL_CONFIG_INVALID", "STACKS_DEV_UNDECLARED"]
|
|
6586
|
+
enforcers:
|
|
6587
|
+
- {kind: hfs, id: stacks-local, at: scripts/hfs/rules/stacks-local.mjs}
|
|
6588
|
+
editions: [lite, full]
|
|
6589
|
+
docs:
|
|
6590
|
+
- {path: contexts/project/stacks.md#project-stacks-6-every-runbook-declares-the-same-operations, editions: [lite, full]}
|
|
6591
|
+
proves:
|
|
6592
|
+
- {path: packages/hfs/src/stack-local.spec.mjs, editions: [lite, full]}
|
|
6593
|
+
exemplifiedBy:
|
|
6594
|
+
- {path: packages/hfs/templates/app/skeleton-lite/.starcistacks, edition: lite}
|
|
6595
|
+
witness:
|
|
6596
|
+
- {path: packages/hfs/src/stack-local.spec.mjs, editions: [lite, full]}
|
|
6597
|
+
- id: R373
|
|
6598
|
+
code: "STACKS_RUNBOOK_DOCKER_COMMAND"
|
|
6599
|
+
law: "The runbook of a docker-compose environment names `starci app stack up --env <env>` and carries no `docker build|run|compose|create|start|stop|pull|push` or `docker stack deploy` command: Docker is run by the harness verb, never by hand (hard rule 8)."
|
|
6600
|
+
kinds: [check]
|
|
6601
|
+
gates: [settle, land, ci]
|
|
6602
|
+
failureCodes: ["STACKS_RUNBOOK_DOCKER_COMMAND"]
|
|
6603
|
+
enforcers:
|
|
6604
|
+
- {kind: hfs, id: stacks-local, at: scripts/hfs/rules/stacks-local.mjs}
|
|
6605
|
+
editions: [lite, full]
|
|
6606
|
+
docs:
|
|
6607
|
+
- {path: contexts/project/stacks.md#project-stacks-10-local-runs, editions: [lite, full]}
|
|
6608
|
+
proves:
|
|
6609
|
+
- {path: packages/hfs/src/stack-local.spec.mjs, editions: [lite, full]}
|
|
6610
|
+
exemplifiedBy:
|
|
6611
|
+
- {path: packages/hfs/templates/app/skeleton-lite/.starcistacks, edition: lite}
|
|
6612
|
+
witness:
|
|
6613
|
+
- {path: packages/hfs/src/stack-local.spec.mjs, editions: [lite, full]}
|
|
6614
|
+
- id: R374
|
|
6615
|
+
code: "STACKS_CODE_BIND_MOUNT"
|
|
6616
|
+
law: "A service the app customises runs from an image built out of `.starcistacks/images/<name>/` (a Dockerfile whose every FROM is digest-pinned and whose final stage is the harness's image for that service, the fork or its runtime layer, when the harness owns one), the same image in every environment; no stack or compose file bind-mounts code, plugins or scripts into a service container (data volumes, secrets, least grants and read-only plain config data files stay allowed)."
|
|
6617
|
+
kinds: [check]
|
|
6618
|
+
gates: [settle, land, ci]
|
|
6619
|
+
failureCodes: ["STACKS_CODE_BIND_MOUNT", "STACKS_IMAGE_BASE_UNPINNED", "STACKS_IMAGE_BASE_NOT_FORK", "STACKS_IMAGE_ENV_DIVERGES"]
|
|
6620
|
+
enforcers:
|
|
6621
|
+
- {kind: hfs, id: stacks-service-images, at: scripts/hfs/rules/stacks-service-images.mjs}
|
|
6622
|
+
editions: [lite, full]
|
|
6623
|
+
docs:
|
|
6624
|
+
- {path: contexts/project/stacks.md#project-stacks-11-a-customised-service-is-an-image-the-app-builds-the-same-in-every-environment, editions: [lite, full]}
|
|
6625
|
+
proves:
|
|
6626
|
+
- {path: packages/hfs/src/stacks-service-images.spec.mjs, editions: [lite, full]}
|
|
@@ -236,17 +236,20 @@ ruleParams:
|
|
|
236
236
|
"node:https": [platform/http]
|
|
237
237
|
http: [platform/http]
|
|
238
238
|
https: [platform/http]
|
|
239
|
-
"@aws-sdk/client-s3": [
|
|
240
|
-
"@aws-sdk/s3-request-presigner": [
|
|
241
|
-
|
|
239
|
+
"@aws-sdk/client-s3": [] # the S3 client is a dependency of @starci/object-storage, imported by no app file (R331)
|
|
240
|
+
"@aws-sdk/s3-request-presigner": []
|
|
241
|
+
"@starci/object-storage": [integrations/object-storage] # the ObjectStorage port: one S3 adapter for MinIO, S3 and Spaces (R331)
|
|
242
|
+
minio: [] # storage goes through @starci/object-storage
|
|
242
243
|
"@supabase": [] # no Supabase client in a back end
|
|
243
|
-
"@nestjs/passport": [
|
|
244
|
-
passport: [
|
|
245
|
-
passport-google-oauth20: [
|
|
246
|
-
passport-local: [
|
|
247
|
-
"@nestjs/jwt": [
|
|
248
|
-
jose: [
|
|
249
|
-
bcryptjs: [
|
|
244
|
+
"@nestjs/passport": [] # the identity libraries are @starci/auth's dependencies, never an app's (R328)
|
|
245
|
+
passport: []
|
|
246
|
+
passport-google-oauth20: []
|
|
247
|
+
passport-local: []
|
|
248
|
+
"@nestjs/jwt": []
|
|
249
|
+
jose: []
|
|
250
|
+
bcryptjs: []
|
|
251
|
+
"@starci/auth": [integrations/passport] # the lite sign-in package: its server entry is reached only through integrations/passport (R328)
|
|
252
|
+
"@starci/auth/testing": [integrations/passport] # its test doubles, for the glue's specs
|
|
250
253
|
bcrypt: []
|
|
251
254
|
cache-manager: [integrations/cache, integrations/redis]
|
|
252
255
|
"@nestjs/cache-manager": [integrations/cache, integrations/redis] # the CACHE_MANAGER token: caching goes through the cache capability
|
|
@@ -1978,36 +1981,68 @@ slots:
|
|
|
1978
1981
|
editions: [lite]
|
|
1979
1982
|
exemplifiedBy:
|
|
1980
1983
|
- packages/hfs/templates/be/skeleton-lite/src/modules/integrations/passport/
|
|
1981
|
-
# The
|
|
1982
|
-
#
|
|
1983
|
-
#
|
|
1984
|
-
#
|
|
1984
|
+
# The glue of @starci/auth, the lite sign-in package (Google OAuth with state and PKCE, email and password, EdDSA access tokens with
|
|
1985
|
+
# their JWKS, rotating refresh sessions): the one importer of the package (ruleParams.be.infraOwners), which owns the identity
|
|
1986
|
+
# libraries (@nestjs/passport, passport, passport-google-oauth20, passport-local, @nestjs/jwt, jose, bcryptjs) that no app imports.
|
|
1987
|
+
# It parses the typed options, builds the verifier and names the injectors; domain/identity verifies a token through the kit and
|
|
1988
|
+
# builds the principal (contexts/code/be/api-auth.md).
|
|
1985
1989
|
path: "src/modules/integrations/passport/"
|
|
1986
1990
|
presence: required
|
|
1987
1991
|
tracked: tracked
|
|
1988
1992
|
tier: integrations
|
|
1989
1993
|
owner: true
|
|
1990
|
-
requires: [index.ts, passport.config.ts, passport.options.ts, passport.decorators.ts, passport.
|
|
1991
|
-
allows: [index.ts, passport.config.ts, passport.options.ts, passport.decorators.ts, passport.
|
|
1992
|
-
logic: [passport.
|
|
1994
|
+
requires: [index.ts, passport.config.ts, passport.options.ts, passport.decorators.ts, passport.kit.ts, passport.registration.ts] # Secrets, no defaults (R44); options and named injectors (R83); the kit and the module over @starci/auth
|
|
1995
|
+
allows: [index.ts, passport.config.ts, passport.options.ts, passport.decorators.ts, passport.kit.ts, passport.registration.ts, errors/]
|
|
1996
|
+
logic: [passport.kit.ts] # the verifier mapping over the package: measured at 100 per file
|
|
1993
1997
|
tests: unit-beside
|
|
1994
1998
|
rules: [BE_TIER_DIRECTION, BE_ERROR_HOME, BE_SECRET_DEFAULT, BE_INFRA_OWNER, BE_AUTH_PASSPORT_OWNER, BE_AUTH_JWT_OWN_JWKS, BE_AUTH_REFRESH_COOKIE]
|
|
1995
1999
|
coverage: required
|
|
1996
2000
|
since: 3.9.0
|
|
2001
|
+
- id: be.identity.sign-in
|
|
2002
|
+
since: 3.16.0
|
|
2003
|
+
profiles: [be]
|
|
2004
|
+
editions: [lite]
|
|
2005
|
+
editionWhy: "lite signs people in with the package @starci/auth, so its sign-in glue is rendered, not written (owner ruling auth-package); full uses its identity provider."
|
|
2006
|
+
# The identity capability's sign-in glue over @starci/auth: the entities of the session, attempt and user tables, the stores the package asks for (sessions, accounts, rate counter), the authenticator and the service the doors call, with their specs. `starci app sync` renders them; a hand edit is drift.
|
|
2007
|
+
path: "{src/modules/domain/identity/account-directory.service.spec.ts,src/modules/domain/identity/account-directory.service.ts,src/modules/domain/identity/authenticator.service.spec.ts,src/modules/domain/identity/authenticator.service.ts,src/modules/domain/identity/persistence/entities/auth-identity.entity.ts,src/modules/domain/identity/persistence/entities/auth-user.entity.ts,src/modules/domain/identity/persistence/entities/identity-attempt.entity.ts,src/modules/domain/identity/persistence/entities/identity-refresh-token.entity.ts,src/modules/domain/identity/persistence/entities/identity-session.entity.ts,src/modules/domain/identity/persistence/entities/index.ts,src/modules/domain/identity/rate-counter.service.spec.ts,src/modules/domain/identity/rate-counter.service.ts,src/modules/domain/identity/session-store.service.spec.ts,src/modules/domain/identity/session-store.service.ts,src/modules/domain/identity/sign-in.service.spec.ts,src/modules/domain/identity/sign-in.service.ts,src/tests/fixtures/builders/identity.builder.ts}"
|
|
2008
|
+
presence: optional
|
|
2009
|
+
tracked: tracked
|
|
2010
|
+
tier: inherit
|
|
2011
|
+
tests: unit-beside
|
|
2012
|
+
coverage: none
|
|
2013
|
+
managedBy: auth-lite
|
|
2014
|
+
managedOnly: true # lists files sync renders; the slot owning the path judges them
|
|
2015
|
+
rules: [HFS_MANAGED_FILE_DRIFT]
|
|
2016
|
+
- id: be.feature.auth
|
|
2017
|
+
since: 3.16.0
|
|
2018
|
+
profiles: [be]
|
|
2019
|
+
editions: [lite]
|
|
2020
|
+
editionWhy: "lite signs people in with the package @starci/auth, so its sign-in glue is rendered, not written (owner ruling auth-package); full uses its identity provider."
|
|
2021
|
+
# The auth feature: the REST doors under /auth (login, refresh, session, logout, Google start and callback, jwks) over IdentitySignInService, one command or query and handler per door.
|
|
2022
|
+
path: "{src/features/api/auth/application/auth.contracts.ts,src/features/api/auth/application/get-jwks.handler.ts,src/features/api/auth/application/get-jwks.query.ts,src/features/api/auth/application/google-begin.command.ts,src/features/api/auth/application/google-begin.handler.ts,src/features/api/auth/application/google-complete.command.ts,src/features/api/auth/application/google-complete.handler.ts,src/features/api/auth/application/login.command.ts,src/features/api/auth/application/login.handler.ts,src/features/api/auth/application/logout.command.ts,src/features/api/auth/application/logout.handler.ts,src/features/api/auth/application/refresh.command.ts,src/features/api/auth/application/refresh.handler.ts,src/features/api/auth/application/session.command.ts,src/features/api/auth/application/session.handler.ts,src/features/api/auth/auth.module-definition.ts,src/features/api/auth/auth.module.ts,src/features/api/auth/auth.options.ts,src/features/api/auth/index.ts,src/features/api/auth/transport/http/auth-http.module-definition.ts,src/features/api/auth/transport/http/auth-http.module.ts,src/features/api/auth/transport/http/auth-http.options.ts,src/features/api/auth/transport/http/auth.controller.ts,src/features/api/auth/transport/http/dto/google-start.request.ts,src/features/api/auth/transport/http/dto/login.request.ts}"
|
|
2023
|
+
presence: optional
|
|
2024
|
+
tracked: tracked
|
|
2025
|
+
tier: inherit
|
|
2026
|
+
tests: none
|
|
2027
|
+
coverage: none
|
|
2028
|
+
managedBy: auth-lite
|
|
2029
|
+
managedOnly: true # lists files sync renders; the slot owning the path judges them
|
|
2030
|
+
rules: [HFS_MANAGED_FILE_DRIFT]
|
|
1997
2031
|
- id: be.integrations.object-storage
|
|
1998
2032
|
profiles: [be]
|
|
1999
2033
|
exemplifiedBy:
|
|
2000
2034
|
- packages/hfs/templates/be/skeleton-lite/src/modules/integrations/object-storage/
|
|
2001
|
-
# The
|
|
2002
|
-
# lite): the
|
|
2035
|
+
# The glue of @starci/object-storage, the owner of the S3 client (@aws-sdk/client-s3 and @aws-sdk/s3-request-presigner) over
|
|
2036
|
+
# S3-compatible storage (MinIO in lite): this folder keeps the bucket, parses the settings and registers the module; no app
|
|
2037
|
+
# file imports an S3 SDK or minio, and no other module imports the package.
|
|
2003
2038
|
path: "src/modules/integrations/object-storage/"
|
|
2004
2039
|
presence: optional
|
|
2005
2040
|
litePresence: required
|
|
2006
2041
|
tracked: tracked
|
|
2007
2042
|
tier: integrations
|
|
2008
2043
|
owner: true
|
|
2009
|
-
requires: [index.ts, object-storage.config.ts, object-storage.options.ts, object-storage.decorators.ts, object-storage.
|
|
2010
|
-
allows: [index.ts, object-storage.
|
|
2044
|
+
requires: [index.ts, object-storage.config.ts, object-storage.options.ts, object-storage.decorators.ts, object-storage.module-definition.ts, object-storage.module.ts]
|
|
2045
|
+
allows: [index.ts, object-storage.config.ts, object-storage.options.ts, object-storage.decorators.ts, object-storage.module-definition.ts, object-storage.module.ts, errors/]
|
|
2011
2046
|
tests: unit-beside
|
|
2012
2047
|
rules: [BE_TIER_DIRECTION, BE_ERROR_HOME, BE_SECRET_DEFAULT, BE_INFRA_OWNER, BE_STORAGE_OWNER]
|
|
2013
2048
|
coverage: required
|
|
@@ -2541,7 +2576,7 @@ slots:
|
|
|
2541
2576
|
profiles: [fe]
|
|
2542
2577
|
# The identity-provider client (fe-stack auth, FE-AUTH): the session, the access token the Apollo link attaches and the
|
|
2543
2578
|
# sign-in/sign-out calls. It talks only to the app's own back-end auth doors and holds no credential: the refresh token lives in
|
|
2544
|
-
# the back end's httpOnly cookie and the access token in memory (ruling:lite-self-hosted-postgres-passport-minio).
|
|
2579
|
+
# the back end's httpOnly cookie and the access token in the memory of the one @starci/auth client (ruling:lite-self-hosted-postgres-passport-minio).
|
|
2545
2580
|
path: "apps/<app>/src/modules/auth/"
|
|
2546
2581
|
presence: optional
|
|
2547
2582
|
tracked: tracked
|
|
@@ -2551,6 +2586,20 @@ slots:
|
|
|
2551
2586
|
tests: none
|
|
2552
2587
|
since: 3.0.0
|
|
2553
2588
|
rules: [FE_STACK_FORBIDDEN]
|
|
2589
|
+
- id: fe.modules.auth.client
|
|
2590
|
+
since: 3.16.0
|
|
2591
|
+
profiles: [fe]
|
|
2592
|
+
editions: [lite]
|
|
2593
|
+
editionWhy: "lite signs people in with the package @starci/auth, so its auth client is rendered, not written (owner ruling auth-package); full wires its identity provider."
|
|
2594
|
+
# The AuthClient every edition shares, implemented by one @starci/auth/client instance over the app's own back-end auth doors.
|
|
2595
|
+
path: "apps/web/src/modules/auth/client.ts"
|
|
2596
|
+
presence: optional
|
|
2597
|
+
tracked: tracked
|
|
2598
|
+
tier: inherit
|
|
2599
|
+
tests: none
|
|
2600
|
+
managedBy: auth-lite
|
|
2601
|
+
managedOnly: true # lists files sync renders; the slot owning the path judges them
|
|
2602
|
+
rules: [HFS_MANAGED_FILE_DRIFT]
|
|
2554
2603
|
- id: fe.modules.toast
|
|
2555
2604
|
profiles: [fe]
|
|
2556
2605
|
# Mutation feedback (fe-stack toast, FE-TOAST): the HeroUI toast wrapper, showGraphQLToast over a GraphQLResponse and the
|
|
@@ -1,57 +1,17 @@
|
|
|
1
|
-
// identity.mjs - the back-end identity machine. Under lite the one token verifier is be.integrations.passport:
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// In both editions every jwtVerify call holds the JWT policy (R260, jwtPolicyProblems).
|
|
1
|
+
// identity.mjs - the back-end identity machine. Under lite the one token verifier is @starci/auth, composed by be.integrations.passport:
|
|
2
|
+
// no app file calls jose's jwtVerify, decodes a token unverified or reads authorization claims from a request body (R329), and the
|
|
3
|
+
// passport integration imports @starci/auth/server. In both editions every jwtVerify call holds the JWT policy (R260, jwtPolicyProblems).
|
|
5
4
|
import path from 'node:path';
|
|
6
5
|
import { machineKit } from './machine-ast.mjs';
|
|
7
|
-
import {
|
|
6
|
+
import { jwtPolicyProblems, reportAt, unwrap } from './jwt-ast.mjs';
|
|
8
7
|
import { accessName } from '../../lib/ts-ast.mjs';
|
|
9
8
|
const PASSPORT_SLOT = 'be.integrations.passport';
|
|
9
|
+
const PACKAGE_ENTRY = '@starci/auth/server';
|
|
10
10
|
const BE_JWT_VERIFIED = 'BE_AUTH_JWT_OWN_JWKS';
|
|
11
11
|
/** The rule ids the back-end identity machine reports. */
|
|
12
12
|
export const IDENTITY_RULE_IDS = Object.freeze(['BE_AUTH_JWT_OWN_JWKS', 'BE_JWT_ALG_PINNED']);
|
|
13
13
|
const JWT_MODULES = new Set(['jose', 'jsonwebtoken', 'jwt-decode']);
|
|
14
14
|
const CLAIM_NAMES = new Set(['role', 'roles', 'membership', 'memberships']);
|
|
15
|
-
const objectLiteral = (kit, checker, node) => {
|
|
16
|
-
const current = unwrap(kit.ts, node);
|
|
17
|
-
if (!current)
|
|
18
|
-
return null;
|
|
19
|
-
if (kit.ts.isObjectLiteralExpression(current))
|
|
20
|
-
return current;
|
|
21
|
-
if (!kit.ts.isIdentifier(current))
|
|
22
|
-
return null;
|
|
23
|
-
for (const declaration of kit.declarationsOf(checker, current)) {
|
|
24
|
-
if (kit.ts.isVariableDeclaration(declaration) && declaration.initializer) {
|
|
25
|
-
const value = unwrap(kit.ts, declaration.initializer);
|
|
26
|
-
if (kit.ts.isObjectLiteralExpression(value))
|
|
27
|
-
return value;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return null;
|
|
31
|
-
};
|
|
32
|
-
const staticStrings = (kit, checker, node) => {
|
|
33
|
-
const current = unwrap(kit.ts, node);
|
|
34
|
-
if (kit.ts.isStringLiteralLike(current))
|
|
35
|
-
return [current.text];
|
|
36
|
-
if (kit.ts.isArrayLiteralExpression(current)) {
|
|
37
|
-
const literals = current.elements.filter((element) => kit.ts.isStringLiteralLike(element));
|
|
38
|
-
if (literals.length === current.elements.length)
|
|
39
|
-
return literals.map((element) => element.text);
|
|
40
|
-
}
|
|
41
|
-
const value = kit.stringValue(checker, current);
|
|
42
|
-
return value === null ? null : [value];
|
|
43
|
-
};
|
|
44
|
-
const jwksArgument = (kit, checker, node) => {
|
|
45
|
-
const current = unwrap(kit.ts, node);
|
|
46
|
-
if (!current)
|
|
47
|
-
return false;
|
|
48
|
-
if (kit.ts.isCallExpression(current))
|
|
49
|
-
return importedFrom(kit, checker, current.expression, new Set(['jose']), new Set(['createLocalJWKSet']));
|
|
50
|
-
if (!kit.ts.isIdentifier(current))
|
|
51
|
-
return false;
|
|
52
|
-
return kit.declarationsOf(checker, current).some((declaration) => kit.ts.isVariableDeclaration(declaration) && declaration.initializer
|
|
53
|
-
&& jwksArgument(kit, checker, declaration.initializer));
|
|
54
|
-
};
|
|
55
15
|
const importedCall = (kit, checker, call) => {
|
|
56
16
|
const direct = kit.importBinding(checker, call.expression);
|
|
57
17
|
if (direct?.module === 'jwt-decode' && direct.name === 'default')
|
|
@@ -84,41 +44,16 @@ const fromRequestBody = (kit, checker, node, seen = new Set()) => {
|
|
|
84
44
|
return kit.declarationsOf(checker, current).some(declaration => kit.ts.isVariableDeclaration(declaration) && declaration.initializer
|
|
85
45
|
&& fromRequestBody(kit, checker, declaration.initializer, seen));
|
|
86
46
|
};
|
|
87
|
-
function verifyJwtCall(kit, checker, file, node, counters, violations) {
|
|
88
|
-
counters.verifyCalls += 1;
|
|
89
|
-
if (file.slot !== PASSPORT_SLOT) {
|
|
90
|
-
reportAt(violations, kit, BE_JWT_VERIFIED, file, node, `jwtVerify is called outside ${PASSPORT_SLOT}; the integration is the one token verifier.`);
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
const options = objectLiteral(kit, checker, node.arguments[2]);
|
|
94
|
-
const property = (name) => options ? kit.propertyOf(options, name) : null;
|
|
95
|
-
const values = (name) => {
|
|
96
|
-
const entry = property(name);
|
|
97
|
-
return entry ? staticStrings(kit, checker, kit.valueOfProperty(entry)) : null;
|
|
98
|
-
};
|
|
99
|
-
const issuer = property('issuer');
|
|
100
|
-
const audience = values('audience');
|
|
101
|
-
const algorithms = values('algorithms');
|
|
102
|
-
// The audience is pinned by a literal or, as R260 accepts, by typed configuration (the skeleton's TokenOptions.audience).
|
|
103
|
-
const audienceEntry = property('audience');
|
|
104
|
-
const pinnedAudience = (audience !== null && audience.length > 0)
|
|
105
|
-
|| (audienceEntry != null && fromConfig(kit.ts, checker, kit.valueOfProperty(audienceEntry)));
|
|
106
|
-
const good = jwksArgument(kit, checker, node.arguments[1]) && issuer != null && pinnedAudience
|
|
107
|
-
&& algorithms !== null && algorithms.length > 0;
|
|
108
|
-
if (!good) {
|
|
109
|
-
reportAt(violations, kit, BE_JWT_VERIFIED, file, node, 'jwtVerify must check the app\'s own key set (createLocalJWKSet(...) over the keys integrations/passport signs with) and pin issuer, audience and a non-empty algorithms list; jwtVerify then enforces signature and exp.');
|
|
110
|
-
}
|
|
111
|
-
else
|
|
112
|
-
counters.verifiedCalls += 1;
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
47
|
function inspectJwtCall(kit, checker, file, node, counters, violations) {
|
|
116
48
|
const binding = importedCall(kit, checker, node);
|
|
117
49
|
if (binding && JWT_MODULES.has(binding.module) && ['decode', 'decodeJwt', 'jwtDecode'].includes(binding.name)) {
|
|
118
50
|
reportAt(violations, kit, BE_JWT_VERIFIED, file, node, `${binding.module}.${binding.name} decodes a token without proving its signature; verify it through integrations/passport.`, { module: binding.module, method: binding.name });
|
|
119
51
|
}
|
|
120
|
-
if (binding?.module === 'jose' && binding.name === 'jwtVerify')
|
|
121
|
-
|
|
52
|
+
if (binding?.module === 'jose' && binding.name === 'jwtVerify') {
|
|
53
|
+
counters.verifyCalls += 1;
|
|
54
|
+
reportAt(violations, kit, BE_JWT_VERIFIED, file, node, 'jwtVerify is called in the app; @starci/auth verifies the own access tokens, reached through ' + PASSPORT_SLOT + '.');
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
122
57
|
return false;
|
|
123
58
|
}
|
|
124
59
|
function inspectRequestClaims(kit, file, node, checker, violations) {
|
|
@@ -146,18 +81,18 @@ function checkOwnJwks(input) {
|
|
|
146
81
|
const violations = [];
|
|
147
82
|
const integrations = [...input.graph.files.values()].filter((file) => file.slot === PASSPORT_SLOT);
|
|
148
83
|
if (!integrations.length)
|
|
149
|
-
return { violations, coverage: { status: 'not-applicable', integrationFiles: 0,
|
|
150
|
-
const counters = { verifyCalls: 0
|
|
84
|
+
return { violations, coverage: { status: 'not-applicable', integrationFiles: 0, verifyCalls: 0 } };
|
|
85
|
+
const counters = { verifyCalls: 0 };
|
|
151
86
|
for (const file of input.graph.files.values()) {
|
|
152
87
|
const checker = kit.checkerOf(file.sourceFile);
|
|
153
88
|
kit.walk(file.sourceFile, (node) => inspectBackendNode(kit, checker, file, node, counters, violations));
|
|
154
89
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return { violations, coverage: { status: 'checked', integrationFiles: integrations.length, verifyCalls: counters.verifyCalls,
|
|
90
|
+
const composes = integrations.some((file) => file.sourceFile.statements.some((statement) => kit.ts.isImportDeclaration(statement)
|
|
91
|
+
&& kit.ts.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === PACKAGE_ENTRY));
|
|
92
|
+
const anchor = integrations.find((file) => path.posix.basename(file.rel) === 'index.ts') ?? integrations[0];
|
|
93
|
+
if (!composes && anchor)
|
|
94
|
+
reportAt(violations, kit, BE_JWT_VERIFIED, anchor, anchor.sourceFile, PASSPORT_SLOT + ' does not import ' + PACKAGE_ENTRY + ', the one verifier of the own access tokens.');
|
|
95
|
+
return { violations, coverage: { status: 'checked', integrationFiles: integrations.length, verifyCalls: counters.verifyCalls, composesPackage: composes } };
|
|
161
96
|
}
|
|
162
97
|
/** R260 BE_JWT_ALG_PINNED: every jose jwtVerify call pins a literal secure algorithm list and a configured issuer, and binds the principal by a configured audience or the authenticated role. */
|
|
163
98
|
export function checkJwtPolicy(input) {
|
|
@@ -17,8 +17,7 @@ import { propertyValue } from './function-spec-providers.mjs';
|
|
|
17
17
|
* - no file outside the client folder and the stream reader folder (`fe.transport.stream`, `modules/api/sse/clients/`) references the global `fetch`: a call, `globalThis.fetch`, `window.fetch`, or a
|
|
18
18
|
* reference passed as a value (`useSWR(key, fetch)`, `const send = fetch`), all of which a spelling-based rule misses; with no
|
|
19
19
|
* client at all every such reference is a finding that says the repository has no client;
|
|
20
|
-
* - axios is imported only by the api owner (modules/api, the api package) for its rest calls
|
|
21
|
-
* (modules/auth/auth-door.ts) for the app's own auth doors; every other HTTP library is a
|
|
20
|
+
* - axios is imported only by the api owner (modules/api, the api package) for its rest calls; every other HTTP library is a
|
|
22
21
|
* second transport wherever it is imported, by static import, `import()` or `require()`;
|
|
23
22
|
* - an `ApolloClient` is constructed only inside the client folder;
|
|
24
23
|
* - every GraphQL operation (`graphql/queries/query-*.ts`, `graphql/mutations/mutation-*.ts`, `graphql/subscriptions/subscription-*.ts`) imports the client (or the api
|
|
@@ -105,17 +104,15 @@ function isApolloClientConstruction(ts, kit, checker, node) {
|
|
|
105
104
|
const binding = kit.importBinding(checker, node.expression);
|
|
106
105
|
return Boolean(binding?.name === 'ApolloClient' && binding.module.startsWith('@apollo/client'));
|
|
107
106
|
}
|
|
108
|
-
/** The one auth door of the session issuer's client (`modules/auth/auth-door.ts`, slot fe.modules.auth): it calls the app's own auth doors with axios. */
|
|
109
|
-
const isAuthDoor = (file) => file.slot === 'fe.modules.auth' && path.posix.basename(file.rel) === 'auth-door.ts';
|
|
110
107
|
function inspectLibraryImport({ ts, file, node, transport, report }) {
|
|
111
108
|
const specifier = moduleSpecifierOf(ts, node);
|
|
112
109
|
if (!specifier || !ts.isStringLiteralLike(specifier))
|
|
113
110
|
return;
|
|
114
111
|
const library = specifier.text.split('/')[0];
|
|
115
|
-
if (!HTTP_LIBRARIES.has(library) || (library === REST_LIBRARY && (API_OWNER_SLOTS.has(file.slot)
|
|
112
|
+
if (!HTTP_LIBRARIES.has(library) || (library === REST_LIBRARY && (API_OWNER_SLOTS.has(file.slot))))
|
|
116
113
|
return;
|
|
117
114
|
const where = library === REST_LIBRARY
|
|
118
|
-
? 'axios belongs to the api owner (modules/api/rest, the api package)
|
|
115
|
+
? 'axios belongs to the api owner (modules/api/rest, the api package) only: call their functions'
|
|
119
116
|
: `the transport is Apollo GraphQL (${transport}) with axios for the rest calls of modules/api/rest`;
|
|
120
117
|
report(file, node, `${specifier.text} is a second HTTP transport in ${file.rel}; ${where}.`, { library: specifier.text });
|
|
121
118
|
}
|
|
@@ -121,7 +121,7 @@ export const MANIFEST_KINDS = [APP_KIND, RUNTIME_KIND];
|
|
|
121
121
|
export const manifestKind = (m) => (isPlainObject(m) && m.kind !== undefined ? m.kind : APP_KIND);
|
|
122
122
|
const strList = (v) => stringList(v);
|
|
123
123
|
|
|
124
|
-
const APP_SLOT_KEYS = ['id', 'profiles', 'path', 'presence', 'tracked', 'tier', 'tests', 'owner', 'appKind', 'minInstances', 'requiredWhen', 'requiredInstances', 'requires', 'pattern', 'trigger', 'allows', 'forbids', 'layers', 'kinds', 'roles', 'composedBy', 'budget', 'managedBy', 'liteManagedBy', 'rules', 'goesTo', 'why', 'since', 'perConnection', 'parent', 'editions', 'editionWhy', 'litePresence', 'lite', 'provider', 'coverage', 'entries', 'outcomeHome', 'templateNa', 'exemplifiedBy', 'role', 'importedBy', 'logic'];
|
|
124
|
+
const APP_SLOT_KEYS = ['id', 'profiles', 'path', 'presence', 'tracked', 'tier', 'tests', 'owner', 'appKind', 'minInstances', 'requiredWhen', 'requiredInstances', 'requires', 'pattern', 'trigger', 'allows', 'forbids', 'layers', 'kinds', 'roles', 'composedBy', 'budget', 'managedBy', 'liteManagedBy', 'rules', 'goesTo', 'why', 'since', 'perConnection', 'parent', 'editions', 'editionWhy', 'litePresence', 'lite', 'provider', 'coverage', 'entries', 'outcomeHome', 'templateNa', 'exemplifiedBy', 'role', 'importedBy', 'logic', 'managedOnly'];
|
|
125
125
|
/** The roles a file slot may play that a rule reads (`role`): the entity registry of persistence.md BE-PERSISTENCE-3 (architecture/entity-registry.mjs). */
|
|
126
126
|
const SLOT_ROLES = ['entity-registry'];
|
|
127
127
|
/** The fields a slot's `lite` overlay may hold: the same keys it would carry in the slot body, resolved under edition lite. */
|
|
@@ -232,7 +232,7 @@ export function readRepoDeclaration(manifest, repoRoot) {
|
|
|
232
232
|
function createScopeResolver(manifest, repo) {
|
|
233
233
|
const profile = repo.profile;
|
|
234
234
|
const edition = repo.edition ?? 'full';
|
|
235
|
-
const slots = manifest.slots.filter((s) => s.profiles.includes(profile) && slotInEdition(manifest, s, edition)).map((s) => effectiveSlot(s, profile, edition));
|
|
235
|
+
const slots = manifest.slots.filter((s) => s.managedOnly !== true && s.profiles.includes(profile) && slotInEdition(manifest, s, edition)).map((s) => effectiveSlot(s, profile, edition));
|
|
236
236
|
const scope = { manifest, repo, profile, slots, byId: new Map(slots.map((s) => [s.id, s])), variants: slots.flatMap(variantsOf), appKind: new Map(repo.apps.map((a) => [a.name, a.kind])) };
|
|
237
237
|
const classifyPath = (input) => classifyIn(scope, input);
|
|
238
238
|
/** tracked | ignored | external for the slot owning `p`, or null when no slot owns it. */
|