ddd-ts-kit 0.83.2 → 0.83.4
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 +24 -0
- package/README.fr.md +2 -1
- package/README.md +1 -0
- package/dist/affected/format-selection.d.ts +2 -0
- package/dist/affected/format-selection.d.ts.map +1 -1
- package/dist/affected/format-selection.js +1 -1
- package/dist/affected/format-selection.js.map +1 -1
- package/dist/affected/run-affected.d.ts +18 -0
- package/dist/affected/run-affected.d.ts.map +1 -0
- package/dist/affected/run-affected.js +35 -0
- package/dist/affected/run-affected.js.map +1 -0
- package/dist/check/authz/scoped-permission.d.ts +15 -0
- package/dist/check/authz/scoped-permission.d.ts.map +1 -0
- package/dist/check/authz/scoped-permission.js +39 -0
- package/dist/check/authz/scoped-permission.js.map +1 -0
- package/dist/check/authz/signed-in-grant-sources.d.ts +22 -0
- package/dist/check/authz/signed-in-grant-sources.d.ts.map +1 -0
- package/dist/check/authz/signed-in-grant-sources.js +63 -0
- package/dist/check/authz/signed-in-grant-sources.js.map +1 -0
- package/dist/check/authz/signed-in-grants.d.ts +5 -0
- package/dist/check/authz/signed-in-grants.d.ts.map +1 -0
- package/dist/check/authz/signed-in-grants.js +6 -0
- package/dist/check/authz/signed-in-grants.js.map +1 -0
- package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
- package/dist/check/catalogue/architecture-rules.js +2 -0
- package/dist/check/catalogue/architecture-rules.js.map +1 -1
- package/dist/check/catalogue/default-severities.d.ts.map +1 -1
- package/dist/check/catalogue/default-severities.js +1 -0
- package/dist/check/catalogue/default-severities.js.map +1 -1
- package/dist/check/explain/authz-docs.d.ts.map +1 -1
- package/dist/check/explain/authz-docs.js +13 -0
- package/dist/check/explain/authz-docs.js.map +1 -1
- package/dist/check/fixtures/authz-scope-narrows-fixtures.d.ts +3 -0
- package/dist/check/fixtures/authz-scope-narrows-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/authz-scope-narrows-fixtures.js +111 -0
- package/dist/check/fixtures/authz-scope-narrows-fixtures.js.map +1 -0
- package/dist/check/fixtures/fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/fixtures.js +2 -0
- package/dist/check/fixtures/fixtures.js.map +1 -1
- package/dist/check/rules/authz-granted.d.ts.map +1 -1
- package/dist/check/rules/authz-granted.js +4 -4
- package/dist/check/rules/authz-granted.js.map +1 -1
- package/dist/check/rules/authz-scope-narrows.d.ts +12 -0
- package/dist/check/rules/authz-scope-narrows.d.ts.map +1 -0
- package/dist/check/rules/authz-scope-narrows.js +73 -0
- package/dist/check/rules/authz-scope-narrows.js.map +1 -0
- package/dist/commands/affected.d.ts +3 -1
- package/dist/commands/affected.d.ts.map +1 -1
- package/dist/commands/affected.js +12 -2
- package/dist/commands/affected.js.map +1 -1
- package/dist/generate/errors/refusal-code.d.ts +1 -1
- package/dist/generate/errors/refusal-code.d.ts.map +1 -1
- package/dist/generate/errors/refusal-code.js +8 -1
- package/dist/generate/errors/refusal-code.js.map +1 -1
- package/dist/help/notes.d.ts +1 -1
- package/dist/help/notes.d.ts.map +1 -1
- package/dist/help/notes.js +4 -1
- package/dist/help/notes.js.map +1 -1
- package/dist/help/usage.d.ts +1 -1
- package/dist/help/usage.d.ts.map +1 -1
- package/dist/help/usage.js +1 -0
- package/dist/help/usage.js.map +1 -1
- package/dist/init/manifest/versions.js +24 -24
- package/dist/slice/format-slice-verification.js +6 -2
- package/dist/slice/format-slice-verification.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/templates/init/jest.config.js.tpl +2 -0
- package/templates/pipeline/lefthook.yml +3 -1
- package/templates/pipeline/package-scripts.json +1 -1
- package/templates/pipeline/vitest.config.ts.tpl +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,30 @@ What each version changes for someone who uses the kit. The packages of `package
|
|
|
4
4
|
together, under one version; the notes of each [GitHub release](https://github.com/gbourgeat/ddd-ts-kit/releases)
|
|
5
5
|
list the pull requests behind it.
|
|
6
6
|
|
|
7
|
+
## 0.83.4
|
|
8
|
+
|
|
9
|
+
**`KafkaEventBus` takes the KafkaJS client it builds its clients from: `cluster`.** The bus made a `KafkaJS.Kafka` of `brokers` and `client` and built its producer, consumers and admin from it, so an application could neither instrument that client nor give the bus another one. The new option `cluster?: KafkaJS.Kafka` is that client: when it is given, the bus reads neither `brokers` nor `client`, builds its clients from it, and disconnects the clients it builds, never `cluster` itself. Without it nothing changes. The specs of `@ddd-ts-kit/kafka` use it to run every suite of the bus on a cluster held in memory, and again against a real broker in the integration job.
|
|
10
|
+
|
|
11
|
+
**The skill `access-control` and the README of `@ddd-ts-kit/auth` say how a search across many elements is authorized under relationships, and why the signed-in grants never let it past the bus.** Under ReBAC a requirement always names a resource, so a search names an enclosing one: the context the generator writes (`{ type: 'context', id: '<context>' }`), or the tenant of the actor with a `from(...)` permission when an actor who reaches no element must get 403 instead of an empty page, at the cost of a check that reads the elements of the tenant for an actor who holds none. Its handler asks `Access.scope` on the permission of one element, which the relationships answer with `ids`. A permission in the signed-in grants lists `all` whatever the model: granting it there to let the search through lets every signed-in person read every element, so the search gets a permission of its own and the scope stays on the permission of the element. The skill lists the specs that prove a search lists nothing it should not, run with the real authorizer.
|
|
12
|
+
|
|
13
|
+
To move: a search whose scope is asked on a permission of `signed-in-grants.ts` lists everything to every signed-in person; give the search its own permission there, or move the requirement to an enclosing resource, and ask the scope on the permission of the element.
|
|
14
|
+
|
|
15
|
+
**`ddd-ts-kit check` warns when a search narrows by a permission every signed-in person holds (`authz/scope-narrows`).** `SignedInGrantsAuthorizer` answers the permissions of `platform/auth/signed-in-grants.ts` before the model, and lists them `all`: a handler that asks `Access.scope` about one of them reads every element for every person who signed in, while its tests stay green. The new rule reports the `.scope(` call whose permission a signed-in grant covers (its entry, its id, the wildcard of its context or `*`), with the way out: under relationships, the requirement names an enclosing resource (the context, or the tenant) and the scope answers the ids. It reads the grants of `platform/auth/signed-in-grants.ts` and those given to any `new SignedInGrantsAuthorizer({ grants })` as an array or a constant, and the permission written in the call or held in a constant or a field of the handler; grants or a permission it cannot read are reported, never taken as safe. A permission every person holds through the model itself (a role every account has) stays for the specs of the search to prove. Default severity `warn`.
|
|
16
|
+
|
|
17
|
+
Two messages say more. `generate error <ctx> <Concept> <refusal> --code <CODE>` refused with a code that says something else now names the refusal the code would go with (`Invoice billingFailed` for `BILLING_FAILED`). `verify-slice`, when every change is left out of the slice, no longer says `nothing to commit`: it says that nothing of the slice is to commit and that the files left out are the conductor's or another worker's.
|
|
18
|
+
|
|
19
|
+
To move: run `npx ddd-ts-kit check --rule authz/scope-narrows`. For each report, take the permission out of the signed-in grants and let the model decide it; under relationships, name an enclosing resource in its `@Requires`.
|
|
20
|
+
|
|
21
|
+
**Before a push, a project runs the unit specs of the contexts its branch reaches, and its test runner takes half of the cores of a developer machine.** The pre-push hook ran every unit spec with its coverage at each push: on a project that grows, with several coding agents and their worktrees, that load stalled the machine. `ddd-ts-kit affected` takes `--run <script>`: it runs that script of the project on the selection, as the pipeline does on a pull request (`DDD_TS_KIT_AFFECTED` set to the contexts the change reaches and the ones downstream of them, `--passWithNoTests` on a partial run), runs nothing when only documents changed, everything when a shared path changed or git cannot tell, and answers the exit code of the script. The `lefthook.yml` that `init` writes runs `npx --no -- ddd-ts-kit affected --base origin/HEAD --run ci:test:unit` before a push; the pipeline still runs everything on the trunk and every night. The generated `vitest.config.ts` and `jest.config.js` give the specs `maxWorkers: '50%'` when no `CI` variable is set; `VITEST_MAX_WORKERS` sets another number. A new guide, [Sandboxing coding agents](docs/guides/agent-sandbox.md), says what loads a machine, how to cap a session, and how to run one in NVIDIA OpenShell when its security matters: the guard of the plugin fails open and is no security boundary.
|
|
22
|
+
|
|
23
|
+
To move: in `lefthook.yml`, replace `run: npm run ci:test:unit` of the job `unit tests` with `run: npx --no -- ddd-ts-kit affected --base origin/HEAD --run ci:test:unit` (`pnpm exec ddd-ts-kit ...` under pnpm); a clone without `origin/HEAD` runs everything until `git remote set-head origin --auto`. In `vitest.config.ts`, add `const WORKERS = process.env.CI ? {} : { maxWorkers: '50%' };` and `...WORKERS,` at the top of `test`; in `jest.config.js`, `...(process.env.CI ? {} : { maxWorkers: '50%' }),`.
|
|
24
|
+
|
|
25
|
+
## 0.83.3
|
|
26
|
+
|
|
27
|
+
**A guard that decides on the caller alone refuses it before the request is read: an anonymous caller of an `Authenticated` route gets 401, never the validation issues of its input, and its upload is never received.** The guards of a controller route ran inside `handle`, after the pipeline had received the upload, read the body and validated the request. A caller with no credential (`resolvePrincipal` answering the anonymous actor, as `principalResolver` does without an `Authorization` header) that sent a malformed input to a guarded route got `422 VALIDATION_FAILED` with the issues, which describe the input the route expects, instead of `401`, and its multipart upload was received and parsed before it was refused. `Guard` gains `admit?(admission: GuardAdmission)`, the part of its decision that reads the route, the raw headers, the actor and the session, and `Route` gains `admit?(admission: RouteAdmission)`, which `executeRoute` calls right after `resolvePrincipal`, before the upload, the body, the negotiation and the validation. `controllerRoutes` gives a route the admissions of its guards, in their order; their checks still run in order after validation, so a guard that reads the path reads validated parameters. `Authenticated`, `HasRole` and `HasScope` decide there (401 to the anonymous caller, 403 without the role or the scope), and `TenantMember` refuses the anonymous caller there, the tenant of the request being checked after validation as before. A refusal at the admission is reported to `onGuardRefusal`, and audited by `auditGuardRefusals`, as a refusal of a guard; `guards: 'skip'` leaves it out with the checks. A caller with a valid credential and a malformed input still gets 422. The JSON parser of a framework (`express.json()`, the body parser of Fastify or NestJS) still runs before the pipeline.
|
|
28
|
+
|
|
29
|
+
To move: nothing for the guards of the kit. A guard of the project that decides on the caller alone (a role, a claim, a header) declares `admit` with that decision to refuse before the request is read; one that reads the path keeps deciding in `check`.
|
|
30
|
+
|
|
7
31
|
## 0.83.2
|
|
8
32
|
|
|
9
33
|
**A project written with `init --preset identity` passes its whole `verify` right after the install, with no step of its own.** Two of its steps failed on a project just initialised. `test:coverage`: the branches of `identity/presentation` stood at 66.66% under their floor of 70%, as the controller of `PUT /accounts/me` was never called by a token without an address, nor without a display name in the body; its spec now covers that case. `docs:check`: `openapi/openapi.yaml`, `docs/integration/asyncapi.yaml` and `docs/integration/event-catalog.md` held none of the routes and events of the preset, as the contracts are written from the running application, which `init` cannot build. `init --preset` now marks them with `x-ddd-ts-kit-pending`, and the first check of `scripts/openapi.ts` and `scripts/events.ts` (in `verify` or `docs:check`) writes them, saying `<file> is written for the first time, ...: commit it.`; where `CI` is set, a contract still marked fails instead (`<file> was never generated: run the script docs:generate and commit it.`), so that a pipeline never passes on a contract nobody wrote. The `bootstrap` skill runs `docs:generate` after `generate context --preset` in a project that exists, whose contracts are already written.
|
package/README.fr.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[English](README.md) · **Français**
|
|
2
|
-
<!-- translation-of: README.md sha256:
|
|
2
|
+
<!-- translation-of: README.md sha256:5e8a9b2808c48e80 -->
|
|
3
3
|
|
|
4
4
|
# ddd-ts-kit
|
|
5
5
|
|
|
@@ -1838,6 +1838,7 @@ règle.
|
|
|
1838
1838
|
| `config/suppression-needs-reason` | une désactivation sans identifiant de règle ou sans raison (gardée comme alias à côté de `governance/recorded-deviation`, qui juge la raison) |
|
|
1839
1839
|
| `authz/declared` | dans un fichier de module, `builder.command(X)` ou `builder.query(X)` sans `.requires(` ni `.public(` dans sa chaîne, sauf si la classe du message porte `@Requires` ou `@Public` de `@ddd-ts-kit/kernel/declarations` ; en câblage manuel ou nest, une classe de commande ou de requête absente de tous les `requires(X, ...)` et `publicUseCase(X)` du fichier de module et de `application/authorization/` ; un `defineRoute` sans `security` (le type de la route le refuse déjà, et une liste vide aussi : c'est le filet au niveau du texte pour une définition construite de façon lâche) ; dans le style déclaré, la classe exportée d'un fichier `*.command.ts` ou `*.query.ts` qui ne porte ni `@Requires` ni `@Public` |
|
|
1840
1840
|
| `authz/granted` | avec `stack.authz` `rbac`, une permission du `definePermissions` d'un contexte que ni `platform/auth/roles.ts` ni `platform/auth/signed-in-grants.ts` n'accorde par son nom (par l'entrée de son ensemble, son identifiant ou `<contexte>:*`) ; le `*` du super-administrateur ne compte pas (un avertissement) |
|
|
1841
|
+
| `authz/scope-narrows` | dans un contexte, un appel `.scope(` dont la permission (l'entrée d'un ensemble dans l'appel, ou dans une constante ou un champ du fichier) est détenue par toute personne connectée, dans `platform/auth/signed-in-grants.ts` ou dans les `grants` d'un `new SignedInGrantsAuthorizer` : sa portée est toujours `all` ; des droits ou une permission qu'elle ne sait pas lire sont signalés aussi (un avertissement) |
|
|
1841
1842
|
| `authz/in-application` | `presentation/` : un test sur les rôles, `isAdmin`, l'import d'un autorisateur ou de `Access` ; `infrastructure/` : `authorize(` ou `check(` sur un autorisateur ou un accès, `ForbiddenError` ; `domain/` : tout import de `@ddd-ts-kit/auth`, des types d'acteur du kernel (`Actor`, `ActorContext`, `Session`, `ExecutionContext`, les messages autorisés), une lecture de `.roles` ou `.permissions` sur un acteur. La glu de requête HTTP de `@ddd-ts-kit/auth` (`actorOf`, `sessionOf`, `resolveSession`, `SessionAuthenticator`) est libre dans `presentation/`. `presentation/` et `infrastructure/` : l'import de `Requires`, `Public` ou `Policy` depuis `@ddd-ts-kit/kernel/declarations`, ou des ports `Access` et `PolicyAccess` depuis `@ddd-ts-kit/auth` ; ils sont libres dans `application/` |
|
|
1842
1843
|
| `authz/actor-explicit` | dans `domain/` et `application/` : `ActorContext`, `ExecutionScope` (comme type ou comme valeur : la classe est le jeton d'une liste de dépendances), `AsyncLocalStorageExecutionScope`, `ScopedActorContext`, `AsyncLocalStorage` ; `.current()` ou `.require()` sur un contexte d'acteur ou sur quelque chose nommé `scope`, `scopes` ou `...executionScope` ; un import de `stampCreation`, `stampUpdate` ou `tenantScopeOf` |
|
|
1843
1844
|
| `authz/fields-by-schema` | sous `application/queries/` : `roles.includes(`, `.some(`, `.every(`, `.find(`, `.indexOf(`, une comparaison avec un `role`, `isAdmin` |
|
package/README.md
CHANGED
|
@@ -1736,6 +1736,7 @@ const due = handler.isDueNow(new Reminder(new Date('2026-03-01T09:00:00Z'))); //
|
|
|
1736
1736
|
| `config/suppression-needs-reason` | a suppression without a rule id or a reason (kept as an alias next to `governance/recorded-deviation`, which judges the reason) |
|
|
1737
1737
|
| `authz/declared` | in a module file, `builder.command(X)` or `builder.query(X)` without `.requires(` or `.public(` in its chain, unless the message class carries `@Requires` or `@Public` of `@ddd-ts-kit/kernel/declarations`; with manual or nest wiring, a command or query class absent from every `requires(X, ...)` and `publicUseCase(X)` of the module file and of `application/authorization/`; a `defineRoute` without `security` (the route type refuses it already, and an empty list too: this is the text-level net for a definition built loosely); in the declared style, the exported class of a `*.command.ts` or `*.query.ts` file carrying neither `@Requires` nor `@Public` |
|
|
1738
1738
|
| `authz/granted` | with `stack.authz` `rbac`, a permission of a context's `definePermissions` that neither `platform/auth/roles.ts` nor `platform/auth/signed-in-grants.ts` grants by name (by the entry of its set, its id or `<context>:*`); the super-admin `*` does not count (a warning) |
|
|
1739
|
+
| `authz/scope-narrows` | in a context, a `.scope(` call whose permission (the entry of a set in the call, or in a constant or a field of the file) every signed-in person holds, in `platform/auth/signed-in-grants.ts` or in the `grants` of a `new SignedInGrantsAuthorizer`: its scope is always `all`; grants or a permission it cannot read are reported too (a warning) |
|
|
1739
1740
|
| `authz/in-application` | `presentation/`: a test on roles, `isAdmin`, the import of an authorizer or of `Access`; `infrastructure/`: `authorize(` or `check(` on an authorizer or access, `ForbiddenError`; `domain/`: any import of `@ddd-ts-kit/auth`, of the actor types of the kernel (`Actor`, `ActorContext`, `Session`, `ExecutionContext`, the authorized messages), a read of `.roles` or `.permissions` on an actor. The request glue of `@ddd-ts-kit/auth` (`actorOf`, `sessionOf`, `resolveSession`, `SessionAuthenticator`) is free in `presentation/`. `presentation/` and `infrastructure/`: the import of `Requires`, `Public` or `Policy` from `@ddd-ts-kit/kernel/declarations`, or of the ports `Access` and `PolicyAccess` from `@ddd-ts-kit/auth`; they are free in `application/` |
|
|
1740
1741
|
| `authz/actor-explicit` | in `domain/` and `application/`: `ActorContext`, `ExecutionScope` (as a type or as a value: the class is the token of a dependency list), `AsyncLocalStorageExecutionScope`, `ScopedActorContext`, `AsyncLocalStorage`; `.current()` or `.require()` on an actor context or on something named `scope`, `scopes` or `...executionScope`; an import of `stampCreation`, `stampUpdate` or `tenantScopeOf` |
|
|
1741
1742
|
| `authz/fields-by-schema` | under `application/queries/`: `roles.includes(`, `.some(`, `.every(`, `.find(`, `.indexOf(`, a comparison with a `role`, `isAdmin` |
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Selection } from './selection.js';
|
|
2
|
+
/** Lets a partial run pass when a selected context has no spec of one kind. */
|
|
3
|
+
export declare const PARTIAL_RUN = "--passWithNoTests";
|
|
2
4
|
/**
|
|
3
5
|
* The selection for a reader (`text`), as data (`json`), or as `key=value` lines: `github` for
|
|
4
6
|
* `$GITHUB_OUTPUT`, `env` (keys in upper case behind `AFFECTED_`) for a GitLab `dotenv` report.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-selection.d.ts","sourceRoot":"","sources":["../../src/affected/format-selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"format-selection.d.ts","sourceRoot":"","sources":["../../src/affected/format-selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,+EAA+E;AAC/E,eAAO,MAAM,WAAW,sBAAsB,CAAC;AAG/C;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAc5E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Lets a partial run pass when a selected context has no spec of one kind. */
|
|
2
|
-
const PARTIAL_RUN = '--passWithNoTests';
|
|
2
|
+
export const PARTIAL_RUN = '--passWithNoTests';
|
|
3
3
|
const ENV_PREFIX = 'AFFECTED_';
|
|
4
4
|
/**
|
|
5
5
|
* The selection for a reader (`text`), as data (`json`), or as `key=value` lines: `github` for
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-selection.js","sourceRoot":"","sources":["../../src/affected/format-selection.ts"],"names":[],"mappings":"AAEA,+EAA+E;AAC/E,MAAM,WAAW,GAAG,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"format-selection.js","sourceRoot":"","sources":["../../src/affected/format-selection.ts"],"names":[],"mappings":"AAEA,+EAA+E;AAC/E,MAAM,CAAC,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAC/C,MAAM,UAAU,GAAG,WAAW,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,SAAoB,EAAE,MAAc;IAClE,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC;IACzB,CAAC;IAED,MAAM,GAAG,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAEvG,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;SACrC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;SAC/C,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,SAAS,MAAM,CAAC,SAAoB;IAClC,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,KAAK,UAAU,CAAC;IAE/C,OAAO;QACL,KAAK,EAAE,SAAS,CAAC,KAAK;QACtB,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;QACrD,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE;QAChC,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,oBAAoB,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;KACtF,CAAC;AACJ,CAAC;AAED,SAAS,IAAI,CAAC,SAAoB;IAChC,IAAI,SAAS,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;QAC9B,OAAO,2BAA2B,SAAS,CAAC,MAAM,GAAG,CAAC;IACxD,CAAC;IAED,IAAI,SAAS,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC;QAC/B,OAAO,kCAAkC,SAAS,CAAC,MAAM,GAAG,CAAC;IAC/D,CAAC;IAED,OAAO;QACL,sBAAsB,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC,MAAM,IAAI;QAC5E,UAAU,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QACrC,+BAA+B,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;KAC7D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Stack } from '../config/index.js';
|
|
2
|
+
import type { Io } from '../commands/io.js';
|
|
3
|
+
import type { Selection } from './selection.js';
|
|
4
|
+
/** A script of a project to run on a selection: where, with which package manager, on what. */
|
|
5
|
+
export interface AffectedRun {
|
|
6
|
+
readonly root: string;
|
|
7
|
+
readonly manager: Stack['packageManager'];
|
|
8
|
+
readonly selection: Selection;
|
|
9
|
+
readonly script: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Runs a script of the project on the selection, as the pipeline does on a pull request: the
|
|
13
|
+
* contexts it names in `DDD_TS_KIT_AFFECTED`, `--passWithNoTests` on a partial run. Nothing runs
|
|
14
|
+
* when nothing that runs changed. Its output goes straight to the terminal; its exit code is
|
|
15
|
+
* the answer.
|
|
16
|
+
*/
|
|
17
|
+
export declare function runAffected({ root, manager, selection, script }: AffectedRun, io: Io): number;
|
|
18
|
+
//# sourceMappingURL=run-affected.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-affected.d.ts","sourceRoot":"","sources":["../../src/affected/run-affected.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAG5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAKhD,+FAA+F;AAC/F,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,GAAG,MAAM,CA6B7F"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { CliError } from '../cli-error.js';
|
|
3
|
+
import { inDialect } from '../package-manager/in-dialect.js';
|
|
4
|
+
import { PARTIAL_RUN } from './format-selection.js';
|
|
5
|
+
/** The variable the test runner config reads (`unaffectedContexts()` of @ddd-ts-kit/testing). */
|
|
6
|
+
const AFFECTED = 'DDD_TS_KIT_AFFECTED';
|
|
7
|
+
/**
|
|
8
|
+
* Runs a script of the project on the selection, as the pipeline does on a pull request: the
|
|
9
|
+
* contexts it names in `DDD_TS_KIT_AFFECTED`, `--passWithNoTests` on a partial run. Nothing runs
|
|
10
|
+
* when nothing that runs changed. Its output goes straight to the terminal; its exit code is
|
|
11
|
+
* the answer.
|
|
12
|
+
*/
|
|
13
|
+
export function runAffected({ root, manager, selection, script }, io) {
|
|
14
|
+
if (selection.scope === 'none') {
|
|
15
|
+
io.out(`Nothing that runs is affected (${selection.reason}): ${script} is not run.`);
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
18
|
+
const partial = selection.scope === 'contexts';
|
|
19
|
+
const command = inDialect(`npm run ${script}${partial ? ` -- ${PARTIAL_RUN}` : ''}`, manager);
|
|
20
|
+
const [program = 'npm', ...args] = command.split(' ');
|
|
21
|
+
io.out(partial
|
|
22
|
+
? `${script} on ${selection.contexts.join(', ')} (${selection.reason}).`
|
|
23
|
+
: `${script} on everything (${selection.reason}).`);
|
|
24
|
+
const run = spawnSync(program, args, {
|
|
25
|
+
cwd: root,
|
|
26
|
+
env: { ...process.env, [AFFECTED]: partial ? selection.contexts.join(',') : '' },
|
|
27
|
+
shell: process.platform === 'win32',
|
|
28
|
+
stdio: 'inherit',
|
|
29
|
+
});
|
|
30
|
+
if (run.error !== undefined) {
|
|
31
|
+
throw new CliError(`${program} could not run (${run.error.message}).`, `Is ${program} installed and on the PATH?`);
|
|
32
|
+
}
|
|
33
|
+
return run.status ?? 1;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=run-affected.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-affected.js","sourceRoot":"","sources":["../../src/affected/run-affected.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,QAAQ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C,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;QAChF,KAAK,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO;QACnC,KAAK,EAAE,SAAS;KACjB,CAAC,CAAC;IAEH,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,IAAI,QAAQ,CAAC,GAAG,OAAO,mBAAmB,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,MAAM,OAAO,6BAA6B,CAAC,CAAC;IACrH,CAAC;IAED,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SourceFile } from '../model/source-file.js';
|
|
2
|
+
import type { ListPart } from '../text/list-part.js';
|
|
3
|
+
import type { PermissionSet } from './permission-sets.js';
|
|
4
|
+
/** A permission written as the entry of a set: the set, and the key read in it. */
|
|
5
|
+
export interface ScopedPermission {
|
|
6
|
+
readonly set: PermissionSet;
|
|
7
|
+
readonly key: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The permission an argument names: the entry of a set written in place, or a constant or a field
|
|
11
|
+
* of the same file initialised with one. Undefined when the checker cannot read it: a parameter,
|
|
12
|
+
* a call, a constant of another file, an entry whose key is not a literal.
|
|
13
|
+
*/
|
|
14
|
+
export declare function scopedPermission(file: SourceFile, argument: ListPart, sets: readonly PermissionSet[]): ScopedPermission | undefined;
|
|
15
|
+
//# sourceMappingURL=scoped-permission.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoped-permission.d.ts","sourceRoot":"","sources":["../../../src/check/authz/scoped-permission.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAO1D,mFAAmF;AACnF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,SAAS,aAAa,EAAE,GAC7B,gBAAgB,GAAG,SAAS,CA4B9B"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { escapeRegExp } from '../text/escape-reg-exp.js';
|
|
2
|
+
/** The entry of a set, `billingPermissions[`, up to its key. */
|
|
3
|
+
const SET_ENTRY = /^([A-Za-z_$][\w$]*)\s*\[\s*/;
|
|
4
|
+
/** A name the permission may be held in: `permission`, `this.permission`. */
|
|
5
|
+
const HELD = /^(?:this\.)?([A-Za-z_$][\w$]*)$/;
|
|
6
|
+
/**
|
|
7
|
+
* The permission an argument names: the entry of a set written in place, or a constant or a field
|
|
8
|
+
* of the same file initialised with one. Undefined when the checker cannot read it: a parameter,
|
|
9
|
+
* a call, a constant of another file, an entry whose key is not a literal.
|
|
10
|
+
*/
|
|
11
|
+
export function scopedPermission(file, argument, sets) {
|
|
12
|
+
const inPlace = entryAt(file, argument, sets);
|
|
13
|
+
if (inPlace !== undefined) {
|
|
14
|
+
return inPlace;
|
|
15
|
+
}
|
|
16
|
+
const held = HELD.exec(argument.code)?.[1];
|
|
17
|
+
if (held === undefined) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
const declaration = new RegExp(`\\b(?:const|let|var|readonly|private|protected|public|static)\\s+${escapeRegExp(held)}\\b[^=;(){}]*=\\s*`, 'g');
|
|
21
|
+
for (const found of file.scan.code.matchAll(declaration)) {
|
|
22
|
+
const start = found.index + found[0].length;
|
|
23
|
+
const entry = entryAt(file, { code: file.scan.code.slice(start, start + 200), start }, sets);
|
|
24
|
+
if (entry !== undefined) {
|
|
25
|
+
return entry;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
function entryAt(file, at, sets) {
|
|
31
|
+
const entry = SET_ENTRY.exec(at.code);
|
|
32
|
+
const set = sets.find(({ set: name }) => name === entry?.[1]);
|
|
33
|
+
if (entry === null || set === undefined) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
const key = file.scan.strings.find(({ start }) => start === at.start + entry[0].length)?.value;
|
|
37
|
+
return key === undefined ? undefined : { set, key };
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=scoped-permission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoped-permission.js","sourceRoot":"","sources":["../../../src/check/authz/scoped-permission.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAIzD,gEAAgE;AAChE,MAAM,SAAS,GAAG,6BAA6B,CAAC;AAChD,6EAA6E;AAC7E,MAAM,IAAI,GAAG,iCAAiC,CAAC;AAQ/C;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAgB,EAChB,QAAkB,EAClB,IAA8B;IAE9B,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IAE9C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAE3C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,MAAM,CAC5B,oEAAoE,YAAY,CAAC,IAAI,CAAC,oBAAoB,EAC1G,GAAG,CACJ,CAAC;IAEF,KAAK,MAAM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0,0 +1,22 @@
|
|
|
1
|
+
import type { Project } from '../model/project.js';
|
|
2
|
+
import type { SourceFile } from '../model/source-file.js';
|
|
3
|
+
import { type Scan } from '../scan/scan.js';
|
|
4
|
+
/** A construction of `SignedInGrantsAuthorizer` whose grants the checker cannot read. */
|
|
5
|
+
interface UnreadGrants {
|
|
6
|
+
readonly file: SourceFile;
|
|
7
|
+
readonly line: number;
|
|
8
|
+
}
|
|
9
|
+
/** What every signed-in person holds, wherever the project writes it, and the grants the checker cannot read. */
|
|
10
|
+
export interface SignedInGrantSources {
|
|
11
|
+
/** Each list of grants, scanned alone: the grants file of the platform, an array given to the authorizer. */
|
|
12
|
+
readonly lists: readonly Scan[];
|
|
13
|
+
readonly unread: readonly UnreadGrants[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The grants file of the platform, and the `grants` of every `new SignedInGrantsAuthorizer(...)`
|
|
17
|
+
* outside the tests: an array literal, or a constant declared as one in a source of the project.
|
|
18
|
+
* Any other form (a call, a spread, a parameter) is unread: the rules say they cannot judge it.
|
|
19
|
+
*/
|
|
20
|
+
export declare function signedInGrantSources(project: Project): SignedInGrantSources;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=signed-in-grant-sources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signed-in-grant-sources.d.ts","sourceRoot":"","sources":["../../../src/check/authz/signed-in-grant-sources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,KAAK,IAAI,EAAQ,MAAM,iBAAiB,CAAC;AAWlD,yFAAyF;AACzF,UAAU,YAAY;IACpB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,iHAAiH;AACjH,MAAM,WAAW,oBAAoB;IACnC,6GAA6G;IAC7G,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC;CAC1C;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,oBAAoB,CAmB3E"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { scan } from '../scan/scan.js';
|
|
2
|
+
import { escapeRegExp } from '../text/escape-reg-exp.js';
|
|
3
|
+
import { callArguments } from '../text/call-arguments.js';
|
|
4
|
+
import { matchingBracket } from '../text/matching-bracket.js';
|
|
5
|
+
import { signedInGrants } from './signed-in-grants.js';
|
|
6
|
+
const CONSTRUCTION = /\bnew\s+SignedInGrantsAuthorizer\s*\(/g;
|
|
7
|
+
const GRANTS_PROPERTY = /^grants\b\s*(?::\s*)?/;
|
|
8
|
+
const IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
|
|
9
|
+
/**
|
|
10
|
+
* The grants file of the platform, and the `grants` of every `new SignedInGrantsAuthorizer(...)`
|
|
11
|
+
* outside the tests: an array literal, or a constant declared as one in a source of the project.
|
|
12
|
+
* Any other form (a call, a spread, a parameter) is unread: the rules say they cannot judge it.
|
|
13
|
+
*/
|
|
14
|
+
export function signedInGrantSources(project) {
|
|
15
|
+
const file = signedInGrants(project);
|
|
16
|
+
const lists = file === undefined ? [] : [file.scan];
|
|
17
|
+
const unread = [];
|
|
18
|
+
for (const candidate of project.files.filter(({ isTest }) => !isTest)) {
|
|
19
|
+
for (const call of candidate.scan.code.matchAll(CONSTRUCTION)) {
|
|
20
|
+
const value = grantsValue(candidate.scan.code, call.index + call[0].length - 1);
|
|
21
|
+
const found = value === undefined ? [] : listsOf(project, candidate, value);
|
|
22
|
+
if (found.length === 0) {
|
|
23
|
+
unread.push({ file: candidate, line: candidate.scan.lineAt(call.index) });
|
|
24
|
+
}
|
|
25
|
+
lists.push(...found);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return { lists, unread };
|
|
29
|
+
}
|
|
30
|
+
/** The value of `grants` in the options object given to the constructor. */
|
|
31
|
+
function grantsValue(code, open) {
|
|
32
|
+
const options = callArguments(code, open)[0];
|
|
33
|
+
if (options === undefined || !options.code.startsWith('{')) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
for (const property of callArguments(code, options.start)) {
|
|
37
|
+
const key = GRANTS_PROPERTY.exec(property.code);
|
|
38
|
+
if (key !== null) {
|
|
39
|
+
const shorthand = key[0].trim() === 'grants';
|
|
40
|
+
return shorthand
|
|
41
|
+
? { code: 'grants', start: property.start }
|
|
42
|
+
: { code: property.code.slice(key[0].length), start: property.start + key[0].length };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
function listsOf(project, file, value) {
|
|
48
|
+
if (value.code.startsWith('[')) {
|
|
49
|
+
return [listAt(file, value.start)];
|
|
50
|
+
}
|
|
51
|
+
if (!IDENTIFIER.test(value.code)) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
const declaration = new RegExp(`\\b(?:const|let|var)\\s+${escapeRegExp(value.code)}\\b[^=;]*=\\s*\\[`, 'g');
|
|
55
|
+
return project.files
|
|
56
|
+
.filter(({ isTest }) => !isTest)
|
|
57
|
+
.flatMap((candidate) => [...candidate.scan.code.matchAll(declaration)].map((found) => listAt(candidate, found.index + found[0].length - 1)));
|
|
58
|
+
}
|
|
59
|
+
/** The array literal opening at `open`, scanned alone so that only its grants are read. */
|
|
60
|
+
function listAt(file, open) {
|
|
61
|
+
return scan(file.text.slice(open, matchingBracket(file.scan.code, open) + 1));
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=signed-in-grant-sources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signed-in-grant-sources.js","sourceRoot":"","sources":["../../../src/check/authz/signed-in-grant-s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'../model/source-file.js';
|
|
3
|
+
/** What every signed-in person holds, `<platformDir>/auth/signed-in-grants.ts`, when a context preset or the team wrote it. */
|
|
4
|
+
export declare function signedInGrants(project: Project): SourceFile | undefined;
|
|
5
|
+
//# sourceMappingURL=signed-in-grants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signed-in-grants.d.ts","sourceRoot":"","sources":["../../../src/check/authz/signed-in-grants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,+HAA+H;AAC/H,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAIvE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** What every signed-in person holds, `<platformDir>/auth/signed-in-grants.ts`, when a context preset or the team wrote it. */
|
|
2
|
+
export function signedInGrants(project) {
|
|
3
|
+
const file = `${project.config.platformDir}/auth/signed-in-grants.ts`;
|
|
4
|
+
return project.files.find((candidate) => candidate.path === file);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=signed-in-grants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signed-in-grants.js","sourceRoot":"","sources":["../../../src/check/authz/signed-in-grants.ts"],"names":[],"mappings":"AAGA,+HAA+H;AAC/H,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,MAAM,IAAI,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,2BAA2B,CAAC;IAEtE,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"architecture-rules.d.ts","sourceRoot":"","sources":["../../../src/check/catalogue/architecture-rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"architecture-rules.d.ts","sourceRoot":"","sources":["../../../src/check/catalogue/architecture-rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AA6F7C,gHAAgH;AAChH,eAAO,MAAM,kBAAkB,EAAE,SAAS,IAAI,EA4F7C,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { authzActorExplicit } from '../rules/authz-actor-explicit.js';
|
|
|
3
3
|
import { authzFieldsBySchema } from '../rules/authz-fields-by-schema.js';
|
|
4
4
|
import { authzDeclared } from '../rules/authz-declared.js';
|
|
5
5
|
import { authzGranted } from '../rules/authz-granted.js';
|
|
6
|
+
import { authzScopeNarrows } from '../rules/authz-scope-narrows.js';
|
|
6
7
|
import { authzInApplication } from '../rules/authz-in-application.js';
|
|
7
8
|
import { authzPolicyAsked } from '../rules/authz-policy-asked.js';
|
|
8
9
|
import { cleanBlankLines } from '../rules/clean-blank-lines.js';
|
|
@@ -150,6 +151,7 @@ export const ARCHITECTURE_RULES = [
|
|
|
150
151
|
authzFieldsBySchema,
|
|
151
152
|
authzPolicyAsked,
|
|
152
153
|
authzGranted,
|
|
154
|
+
authzScopeNarrows,
|
|
153
155
|
aspectsOutsideIn,
|
|
154
156
|
tracingPlatformOnly,
|
|
155
157
|
tenancyScopedStatement,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"architecture-rules.js","sourceRoot":"","sources":["../../../src/check/catalogue/architecture-rules.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM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,WAAW;IACX,mBAAmB;IACnB,sBAAsB;IACtB,gBAAgB;IAChB,oBAAoB;IACpB,oBAAoB;IACpB,uBAAuB;IACvB,0BAA0B;IAC1B,mBAAmB;IACnB,yBAAyB;IACzB,mBAAmB;IACnB,aAAa;IACb,iBAAiB;IACjB,uBAAuB;IACvB,mBAAmB;IACnB,kBAAkB;IAClB,mBAAmB;IACnB,kBAAkB;IAClB,eAAe;IACf,WAAW;IACX,qBAAqB;IACrB,aAAa;IACb,sBAAsB;IACtB,oBAAoB;IACpB,wBAAwB;IACxB,4BAA4B;IAC5B,qCAAqC;IACrC,yBAAyB;IACzB,sBAAsB;IACtB,kCAAkC;IAClC,mCAAmC;IACnC,6BAA6B;IAC7B,kBAAkB;IAClB,aAAa;IACb,kBAAkB;IAClB,kBAAkB;IAClB,mBAAmB;IACnB,gBAAgB;IAChB,YAAY;IACZ,gBAAgB;IAChB,mBAAmB;IACnB,sBAAsB;IACtB,2BAA2B;IAC3B,2BAA2B;IAC3B,uBAAuB;IACvB,uBAAuB;IACvB,wBAAwB;IACxB,yBAAyB;IACzB,gCAAgC;IAChC,4BAA4B;IAC5B,kBAAkB;IAClB,2BAA2B;IAC3B,oBAAoB;IACpB,yBAAyB;IACzB,gBAAgB;IAChB,4BAA4B;IAC5B,6BAA6B;IAC7B,wBAAwB;IACxB,iBAAiB;IACjB,gBAAgB;IAChB,gBAAgB;IAChB,oBAAoB;IACpB,gBAAgB;IAChB,gBAAgB;IAChB,eAAe;IACf,2BAA2B;IAC3B,wBAAwB;IACxB,0BAA0B;IAC1B,qBAAqB;CACtB,CAAC"}
|
|
1
|
+
{"version":3,"file":"architecture-rules.js","sourceRoot":"","sources":["../../../src/check/catalogue/architecture-rules.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAo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AkB;IAClB,sBAAsB;IACtB,sBAAsB;IACtB,gBAAgB;IAChB,gBAAgB;IAChB,sBAAsB;IACtB,gCAAgC;IAChC,WAAW;IACX,mBAAmB;IACnB,sBAAsB;IACtB,gBAAgB;IAChB,oBAAoB;IACpB,oBAAoB;IACpB,uBAAuB;IACvB,0BAA0B;IAC1B,mBAAmB;IACnB,yBAAyB;IACzB,mBAAmB;IACnB,aAAa;IACb,iBAAiB;IACjB,uBAAuB;IACvB,mBAAmB;IACnB,kBAAkB;IAClB,mBAAmB;IACnB,kBAAkB;IAClB,eAAe;IACf,WAAW;IACX,qBAAqB;IACrB,aAAa;IACb,sBAAsB;IACtB,oBAAoB;IACpB,wBAAwB;IACxB,4BAA4B;IAC5B,qCAAqC;IACrC,yBAAyB;IACzB,sBAAsB;IACtB,kCAAkC;IAClC,mCAAmC;IACnC,6BAA6B;IAC7B,kBAAkB;IAClB,aAAa;IACb,kBAAkB;IAClB,kBAAkB;IAClB,mBAAmB;IACnB,gBAAgB;IAChB,YAAY;IACZ,iBAAiB;IACjB,gBAAgB;IAChB,mBAAmB;IACnB,sBAAsB;IACtB,2BAA2B;IAC3B,2BAA2B;IAC3B,uBAAuB;IACvB,uBAAuB;IACvB,wBAAwB;IACxB,yBAAyB;IACzB,gCAAgC;IAChC,4BAA4B;IAC5B,kBAAkB;IAClB,2BAA2B;IAC3B,oBAAoB;IACpB,yBAAyB;IACzB,gBAAgB;IAChB,4BAA4B;IAC5B,6BAA6B;IAC7B,wBAAwB;IACxB,iBAAiB;IACjB,gBAAgB;IAChB,gBAAgB;IAChB,oBAAoB;IACpB,gBAAgB;IAChB,gBAAgB;IAChB,eAAe;IACf,2BAA2B;IAC3B,wBAAwB;IACxB,0BAA0B;IAC1B,qBAAqB;CACtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-severities.d.ts","sourceRoot":"","sources":["../../../src/check/catalogue/default-severities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,0GAA0G;AAC1G,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"default-severities.d.ts","sourceRoot":"","sources":["../../../src/check/catalogue/default-severities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,0GAA0G;AAC1G,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAgBjE,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** Rules that advise instead of blocking unless the config says otherwise (ARCHITECTURE.md section 3). */
|
|
2
2
|
export const DEFAULT_SEVERITIES = {
|
|
3
3
|
'authz/granted': 'warn',
|
|
4
|
+
'authz/scope-narrows': 'warn',
|
|
4
5
|
'test/no-mocks': 'warn',
|
|
5
6
|
'test/builder-required': 'warn',
|
|
6
7
|
'clean/function-size': 'warn',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-severities.js","sourceRoot":"","sources":["../../../src/check/catalogue/default-severities.ts"],"names":[],"mappings":"AAEA,0GAA0G;AAC1G,MAAM,CAAC,MAAM,kBAAkB,GAAuC;IACpE,eAAe,EAAE,MAAM;IACvB,eAAe,EAAE,MAAM;IACvB,uBAAuB,EAAE,MAAM;IAC/B,qBAAqB,EAAE,MAAM;IAC7B,wBAAwB,EAAE,MAAM;IAChC,wBAAwB,EAAE,MAAM;IAChC,sCAAsC,EAAE,MAAM;IAC9C,gCAAgC,EAAE,MAAM;IACxC,4BAA4B,EAAE,MAAM;IACpC,uBAAuB,EAAE,MAAM;IAC/B,oBAAoB,EAAE,MAAM;IAC5B,2BAA2B,EAAE,MAAM;IACnC,+BAA+B,EAAE,MAAM;IACvC,iCAAiC,EAAE,MAAM;CAC1C,CAAC"}
|
|
1
|
+
{"version":3,"file":"default-severities.js","sourceRoot":"","sources":["../../../src/check/catalogue/default-severities.ts"],"names":[],"mappings":"AAEA,0GAA0G;AAC1G,MAAM,CAAC,MAAM,kBAAkB,GAAuC;IACpE,eAAe,EAAE,MAAM;IACvB,qBAAqB,EAAE,MAAM;IAC7B,eAAe,EAAE,MAAM;IACvB,uBAAuB,EAAE,MAAM;IAC/B,qBAAqB,EAAE,MAAM;IAC7B,wBAAwB,EAAE,MAAM;IAChC,wBAAwB,EAAE,MAAM;IAChC,sCAAsC,EAAE,MAAM;IAC9C,gCAAgC,EAAE,MAAM;IACxC,4BAA4B,EAAE,MAAM;IACpC,uBAAuB,EAAE,MAAM;IAC/B,oBAAoB,EAAE,MAAM;IAC5B,2BAA2B,EAAE,MAAM;IACnC,+BAA+B,EAAE,MAAM;IACvC,iCAAiC,EAAE,MAAM;CAC1C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authz-docs.d.ts","sourceRoot":"","sources":["../../../src/check/explain/authz-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"authz-docs.d.ts","sourceRoot":"","sources":["../../../src/check/explain/authz-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiGxD,CAAC"}
|
|
@@ -42,6 +42,19 @@ export const roles = {
|
|
|
42
42
|
[Role.Accountant]: [billingPermissions['invoice.void']],
|
|
43
43
|
};
|
|
44
44
|
// or, when generating the use case: --permission invoice.void --grant accountant`,
|
|
45
|
+
},
|
|
46
|
+
'authz/scope-narrows': {
|
|
47
|
+
why: "Every signed-in person holds the grants of SignedInGrantsAuthorizer, whatever the model of the project: it answers them before it asks the model, for a check and for a listing alike, and the listing is `all`. A handler that narrows a search by the scope of such a permission reads every element for every person who signed in, and the tests of the handler stay green. It is the shortcut taken when the model refuses a search with no element to check (relationships answer RESOURCE_REQUIRED): the grant lets the query past the bus, and the scope no longer narrows anything. The model decides instead: under relationships, the requirement names an enclosing resource (`{ type: 'context', id: '<context>' }` as the generator writes it, or the tenant of the actor) and Access.scope answers the ids of the elements. Judged: the second argument of a `.scope(` call in a context, the entry of a permission set written in place or held in a constant or a field of the same file, against the grants of `<platformDir>/auth/signed-in-grants.ts` and those given to every `new SignedInGrantsAuthorizer({ grants })` as an array literal or a constant declared as one (an entry, an id, the wildcard of a context, the bare `*`). What it cannot read is reported, never taken as safe: grants built by a call or a spread, a permission handed in to a `.scope(` call on `access`. What it cannot see at all: a permission every person holds through the model itself (a role every account has, a relation every member of a tenant has), and a search that does not ask Access.scope. Those are decisions of the model: the specs of the search prove them, with the real authorizer, an element of another owner absent. A warning: a search every signed-in person may run on every element is legitimate, its scope then says nothing.",
|
|
48
|
+
bad: `// platform/auth/signed-in-grants.ts
|
|
49
|
+
export const signedInGrants: readonly Grant[] = [docsPermissions['document.search']];
|
|
50
|
+
// contexts/docs/application/queries/search-documents/search-documents.handler.ts
|
|
51
|
+
const scope = await this.access.scope(query.actor, docsPermissions['document.search'], 'document');`,
|
|
52
|
+
good: `// contexts/docs/application/queries/search-documents/search-documents.query.ts
|
|
53
|
+
@Requires(docsPermissions['document.search'], { resource: () => ({ type: 'context', id: 'docs' }) })
|
|
54
|
+
export class SearchDocumentsQuery extends AuthorizedQuery<SearchDocumentsResult> {}
|
|
55
|
+
// contexts/docs/application/queries/search-documents/search-documents.handler.ts
|
|
56
|
+
const scope = await this.access.scope(query.actor, docsPermissions['document.search'], 'document');
|
|
57
|
+
// { kind: 'ids', ids: [...] }: the documents the actor reaches, an empty page for one who reaches none`,
|
|
45
58
|
},
|
|
46
59
|
'authz/policy-asked': {
|
|
47
60
|
why: 'The bus checks the permission of a use case before its handler runs, with the identifier of the element at most: it cannot read the element. A policy is the part of the right that needs the element (only the issuer, not after closing), and it is evaluated only when the handler asks Access once the element is loaded. A handler that forgets to ask leaves the policy declared, tested and never applied, and nothing at run time says so. Judged: for every permission refined by a policy (@Policy or definePolicy in application/authorization/), the handlers in the folder of each command or query that requires it (@Requires, .requires(...) or requires(X, ...)) call authorize, decide or decideOn and name that permission in their code. The TODO(domain) the generator leaves in such a handler, naming the permission, is accepted, and so is a TODO(review) that names it: `ddd-ts-kit todo` lists both, and until it is done the authorization module refuses the result of the handler at run time (PolicyNotAskedError).',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authz-docs.js","sourceRoot":"","sources":["../../../src/check/explain/authz-docs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,GAAsC;IAC3D,gBAAgB,EAAE;QAChB,GAAG,EAAE,mvBAAmvB;QACxvB,GAAG,EAAE;;;mEAG0D;QAC/D,IAAI,EAAE;;;;;mEAKyD;KAChE;IACD,sBAAsB,EAAE;QACtB,GAAG,EAAE,q0BAAq0B;QAC10B,GAAG,EAAE;;;;;4DAKmD;QACxD,IAAI,EAAE;;;;;;sCAM4B;KACnC;IACD,eAAe,EAAE;QACf,GAAG,EAAE,4nCAA4nC;QACjoC,GAAG,EAAE;;;;;8CAKqC;QAC1C,IAAI,EAAE;;;;;kFAKwE;KAC/E;IACD,oBAAoB,EAAE;QACpB,GAAG,EAAE,o/BAAo/B;QACz/B,GAAG,EAAE;;;;;gCAKuB;QAC5B,IAAI,EAAE;;;gCAGsB;KAC7B;IACD,sBAAsB,EAAE;QACtB,GAAG,EAAE,ykBAAykB;QAC9kB,GAAG,EAAE;;;;qDAI4C;QACjD,IAAI,EAAE;;;;;2GAKiG;KACxG;IACD,wBAAwB,EAAE;QACxB,GAAG,EAAE,i1BAAi1B;QACt1B,GAAG,EAAE;;+FAEsF;QAC3F,IAAI,EAAE;;;;;IAKN;KACD;CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"authz-docs.js","sourceRoot":"","sources":["../../../src/check/explain/authz-docs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,GAAsC;IAC3D,gBAAgB,EAAE;QAChB,GAAG,EAAE,mvBAAmvB;QACxvB,GAAG,EAAE;;;mEAG0D;QAC/D,IAAI,EAAE;;;;;mEAKyD;KAChE;IACD,sBAAsB,EAAE;QACtB,GAAG,EAAE,q0BAAq0B;QAC10B,GAAG,EAAE;;;;;4DAKmD;QACxD,IAAI,EAAE;;;;;;sCAM4B;KACnC;IACD,eAAe,EAAE;QACf,GAAG,EAAE,4nCAA4nC;QACjoC,GAAG,EAAE;;;;;8CAKqC;QAC1C,IAAI,EAAE;;;;;kFAKwE;KAC/E;IACD,qBAAqB,EAAE;QACrB,GAAG,EAAE,ywDAAywD;QAC9wD,GAAG,EAAE;;;oGAG2F;QAChG,IAAI,EAAE;;;;;wGAK8F;KACrG;IACD,oBAAoB,EAAE;QACpB,GAAG,EAAE,o/BAAo/B;QACz/B,GAAG,EAAE;;;;;gCAKuB;QAC5B,IAAI,EAAE;;;gCAGsB;KAC7B;IACD,sBAAsB,EAAE;QACtB,GAAG,EAAE,ykBAAykB;QAC9kB,GAAG,EAAE;;;;qDAI4C;QACjD,IAAI,EAAE;;;;;2GAKiG;KACxG;IACD,wBAAwB,EAAE;QACxB,GAAG,EAAE,i1BAAi1B;QACt1B,GAAG,EAAE;;+FAEsF;QAC3F,IAAI,EAAE;;;;;IAKN;KACD;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authz-scope-narrows-fixtures.d.ts","sourceRoot":"","sources":["../../../src/check/fixtures/authz-scope-narrows-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAuB5C,eAAO,MAAM,4BAA4B,EAAE,SAAS,OAAO,EA+E1D,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { PATHS } from './paths.js';
|
|
2
|
+
import { project } from './project.js';
|
|
3
|
+
import { SAMPLES } from './samples.js';
|
|
4
|
+
import { source } from './source.js';
|
|
5
|
+
const { BILLING, QUERY_HANDLER, QUERY_HANDLER_SPEC } = PATHS;
|
|
6
|
+
const PERMISSIONS = `${BILLING}/application/authorization/billing.permissions.ts`;
|
|
7
|
+
const SIGNED_IN = 'src/platform/auth/signed-in-grants.ts';
|
|
8
|
+
const AUTHORIZER = 'src/platform/auth/create-authorizer.ts';
|
|
9
|
+
const DECLARED = source("import { definePermissions } from '@ddd-ts-kit/auth';", '', "export const billingPermissions = definePermissions('billing', {", " 'invoice.search': { description: 'Search invoice' },", " 'invoice.issue': { description: 'Issue invoice' },", '});');
|
|
10
|
+
const rule = 'authz/scope-narrows';
|
|
11
|
+
export const AUTHZ_SCOPE_NARROWS_FIXTURES = [
|
|
12
|
+
{
|
|
13
|
+
ruleId: rule,
|
|
14
|
+
name: 'a search narrowed by a permission the model decides',
|
|
15
|
+
expect: 'pass',
|
|
16
|
+
files: searching("[billingPermissions['invoice.issue']]"),
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
ruleId: rule,
|
|
20
|
+
name: 'a search narrowed by a permission, in a project without signed-in grants',
|
|
21
|
+
expect: 'pass',
|
|
22
|
+
files: project({ [PERMISSIONS]: DECLARED, [QUERY_HANDLER]: handler(), [QUERY_HANDLER_SPEC]: SAMPLES.SPEC }),
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
ruleId: rule,
|
|
26
|
+
name: 'a signed-in grant named in a comment only',
|
|
27
|
+
expect: 'pass',
|
|
28
|
+
files: searching("[\n // billingPermissions['invoice.search'],\n]"),
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
ruleId: rule,
|
|
32
|
+
name: 'a search narrowed by a permission every signed-in person holds by its entry',
|
|
33
|
+
expect: { file: QUERY_HANDLER },
|
|
34
|
+
files: searching("[billingPermissions['invoice.search']]"),
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
ruleId: rule,
|
|
38
|
+
name: 'a search narrowed by a permission every signed-in person holds through the wildcard of its context',
|
|
39
|
+
expect: { file: QUERY_HANDLER },
|
|
40
|
+
files: searching("['billing:*']"),
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
ruleId: rule,
|
|
44
|
+
name: 'a search narrowed by a permission every signed-in person holds through the bare wildcard',
|
|
45
|
+
expect: { file: QUERY_HANDLER },
|
|
46
|
+
files: searching("['*']"),
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
ruleId: rule,
|
|
50
|
+
name: 'a search narrowed by a permission held in a constant of the handler, which every signed-in person holds',
|
|
51
|
+
expect: { file: QUERY_HANDLER },
|
|
52
|
+
files: searching("[billingPermissions['invoice.search']]", {
|
|
53
|
+
before: "const searched = billingPermissions['invoice.search'];",
|
|
54
|
+
permission: 'searched',
|
|
55
|
+
}),
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
ruleId: rule,
|
|
59
|
+
name: 'a search narrowed by a permission held in a field of the handler, which every signed-in person holds',
|
|
60
|
+
expect: { file: QUERY_HANDLER },
|
|
61
|
+
files: searching("[billingPermissions['invoice.search']]", {
|
|
62
|
+
field: "private readonly searched = billingPermissions['invoice.search'];",
|
|
63
|
+
permission: 'this.searched',
|
|
64
|
+
}),
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
ruleId: rule,
|
|
68
|
+
name: 'a search narrowed by a permission handed in, which the checker cannot read',
|
|
69
|
+
expect: { file: QUERY_HANDLER },
|
|
70
|
+
files: searching("[billingPermissions['invoice.issue']]", { permission: 'query.permission' }),
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
ruleId: rule,
|
|
74
|
+
name: 'a search narrowed by a permission the grants given in place to the authorizer hold',
|
|
75
|
+
expect: { file: QUERY_HANDLER },
|
|
76
|
+
files: authorizing("grants: [billingPermissions['invoice.search']]"),
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
ruleId: rule,
|
|
80
|
+
name: 'a search narrowed by a permission the model decides, the grants given in place to the authorizer',
|
|
81
|
+
expect: 'pass',
|
|
82
|
+
files: authorizing("grants: ['billing:invoice.issue']"),
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
ruleId: rule,
|
|
86
|
+
name: 'grants given to the authorizer by a call, which the checker cannot read',
|
|
87
|
+
expect: { file: AUTHORIZER },
|
|
88
|
+
files: authorizing('grants: grantsOf(billingPermissions)'),
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
function searching(grants, narrowing = {}) {
|
|
92
|
+
return project({
|
|
93
|
+
[PERMISSIONS]: DECLARED,
|
|
94
|
+
[QUERY_HANDLER]: handler(narrowing),
|
|
95
|
+
[QUERY_HANDLER_SPEC]: SAMPLES.SPEC,
|
|
96
|
+
[SIGNED_IN]: source("import type { Grant } from '@ddd-ts-kit/auth';", "import { billingPermissions } from '@/contexts/billing/application/authorization/billing.permissions.js';", '', `export const signedInGrants: readonly Grant[] = ${grants};`, '', 'export const searching = billingPermissions;'),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/** A project whose authorizer is given its grants in place: `grants` is the property as written. */
|
|
100
|
+
function authorizing(grants) {
|
|
101
|
+
return project({
|
|
102
|
+
[PERMISSIONS]: DECLARED,
|
|
103
|
+
[QUERY_HANDLER]: handler(),
|
|
104
|
+
[QUERY_HANDLER_SPEC]: SAMPLES.SPEC,
|
|
105
|
+
[AUTHORIZER]: source("import { type Authorizer, SignedInGrantsAuthorizer } from '@ddd-ts-kit/auth';", "import { billingPermissions } from '@/contexts/billing/application/authorization/billing.permissions.js';", '', 'declare const model: Authorizer;', 'declare function grantsOf(set: unknown): readonly string[];', '', 'export function createAuthorizer(): Authorizer {', ` return new SignedInGrantsAuthorizer({ ${grants}, otherwise: model });`, '}', '', 'export const searching = [billingPermissions, grantsOf];'),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function handler({ before, field, permission = "billingPermissions['invoice.search']" } = {}) {
|
|
109
|
+
return source("import type { Access } from '@ddd-ts-kit/auth';", "import { billingPermissions } from '@/contexts/billing/application/authorization/billing.permissions.js';", "import type { InvoicesIssuedQuery } from '@/contexts/billing/application/queries/invoices-issued/invoices-issued.query.js';", '', ...(before === undefined ? [] : [before, '']), 'export class InvoicesIssuedHandler {', ...(field === undefined ? [] : [` ${field}`, '']), ' constructor(private readonly access: Access) {}', '', ' async execute(query: InvoicesIssuedQuery): Promise<unknown> {', ` return this.access.scope(query.actor, ${permission}, 'invoice');`, ' }', '}');
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=authz-scope-narrows-fixtures.js.map
|