@pithy-sh/audit 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions.d.ts +4 -4
- package/dist/actions.js +5 -5
- package/dist/http/schemas.js +1 -1
- package/dist/query.d.ts +1 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/seeds/example.js +2 -2
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/package.json +3 -3
- package/src/actions.ts +5 -5
- package/src/http/schemas.ts +1 -1
- package/src/query.ts +1 -1
- package/src/seeds/example.ts +2 -2
- package/src/version.generated.ts +1 -1
package/dist/actions.d.ts
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
// SPDX-License-Identifier: FSL-1.1-MIT
|
|
3
3
|
/**
|
|
4
4
|
* Author a capability's action constants. The taxonomy is **federated**: each capability owns and
|
|
5
|
-
* exports its own `domain/reason` action codes (`auth/
|
|
5
|
+
* exports its own `domain/reason` action codes (`auth/signin`, `entitlement/granted`) and adds them
|
|
6
6
|
* without touching core — the way migrations and table prefixes already federate per-capability.
|
|
7
7
|
*
|
|
8
8
|
* This validates every code against the shared {@link AuditAction} shape at author time, so a typo
|
|
9
9
|
* (a missing slash, an uppercase letter) fails loudly where the constant is declared rather than
|
|
10
10
|
* silently when an event is emitted. Returns the same object, typed, so call sites read
|
|
11
|
-
* `AuthAuditActions.
|
|
11
|
+
* `AuthAuditActions.signin`:
|
|
12
12
|
*
|
|
13
13
|
* ```ts
|
|
14
14
|
* export const AuthAuditActions = defineAuditActions({
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* signin: "auth/signin",
|
|
16
|
+
* tokenRefresh: "auth/token_refresh",
|
|
17
17
|
* });
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
package/dist/actions.js
CHANGED
|
@@ -5,18 +5,18 @@ import { AuditAction } from "@pithy-sh/core/src/audit/auditEvent";
|
|
|
5
5
|
//#region src/actions.ts
|
|
6
6
|
/**
|
|
7
7
|
* Author a capability's action constants. The taxonomy is **federated**: each capability owns and
|
|
8
|
-
* exports its own `domain/reason` action codes (`auth/
|
|
8
|
+
* exports its own `domain/reason` action codes (`auth/signin`, `entitlement/granted`) and adds them
|
|
9
9
|
* without touching core — the way migrations and table prefixes already federate per-capability.
|
|
10
10
|
*
|
|
11
11
|
* This validates every code against the shared {@link AuditAction} shape at author time, so a typo
|
|
12
12
|
* (a missing slash, an uppercase letter) fails loudly where the constant is declared rather than
|
|
13
13
|
* silently when an event is emitted. Returns the same object, typed, so call sites read
|
|
14
|
-
* `AuthAuditActions.
|
|
14
|
+
* `AuthAuditActions.signin`:
|
|
15
15
|
*
|
|
16
16
|
* ```ts
|
|
17
17
|
* export const AuthAuditActions = defineAuditActions({
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* signin: "auth/signin",
|
|
19
|
+
* tokenRefresh: "auth/token_refresh",
|
|
20
20
|
* });
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
@@ -25,7 +25,7 @@ function defineAuditActions(actions) {
|
|
|
25
25
|
const parsed = AuditAction.safeParse(code);
|
|
26
26
|
if (!parsed.success) throw new AuditInvalidEventError({
|
|
27
27
|
message: `Invalid audit action code for "${name}": ${code}`,
|
|
28
|
-
action: "Use a lowercase namespaced `domain/reason` code, e.g. `auth/
|
|
28
|
+
action: "Use a lowercase namespaced `domain/reason` code, e.g. `auth/signin`.",
|
|
29
29
|
detail: parsed.error.message
|
|
30
30
|
});
|
|
31
31
|
}
|
package/dist/http/schemas.js
CHANGED
|
@@ -55,7 +55,7 @@ const ListAuditEventsQuery = z.object({
|
|
|
55
55
|
actorId: FilterValue.optional().describe("Filter to one principal — a user id, a service name, a token subject."),
|
|
56
56
|
actorKind: ControlPlaneActorKind.optional().describe("Filter to one kind of client: `agent`, `dashboard` or `script`. `agent` finds a management agent's rows and every row a user's MCP client wrote, on both paths."),
|
|
57
57
|
action: AuditAction.max(MAX_FILTER_LENGTH).optional().describe("Filter to one exact `domain/reason` action code. Exact; `actionPrefix` is the domain-wide filter."),
|
|
58
|
-
actionPrefix: z.string().regex(/^[a-z][a-z0-9]*\/?$/, "An action prefix is one domain, lowercase, with or without its trailing `/` (e.g. `auth` or `auth/`).").max(MAX_FILTER_LENGTH).transform((value) => value.replace(/\/$/, "")).optional().describe("Filter to every action under one domain — `auth` or `auth/` matches `auth/
|
|
58
|
+
actionPrefix: z.string().regex(/^[a-z][a-z0-9]*\/?$/, "An action prefix is one domain, lowercase, with or without its trailing `/` (e.g. `auth` or `auth/`).").max(MAX_FILTER_LENGTH).transform((value) => value.replace(/\/$/, "")).optional().describe("Filter to every action under one domain — `auth` or `auth/` matches `auth/signin` and `auth/signout`, never `authority/granted`. The domain is the only prefix: a reason is never matched by its start."),
|
|
59
59
|
outcome: AuditOutcome.optional().describe("Filter to one outcome. `denied` is the one worth watching: a run of denials is what a credential being probed looks like."),
|
|
60
60
|
severity: AuditSeverity.optional().describe("Filter to one severity."),
|
|
61
61
|
resourceType: FilterValue.optional().describe("Filter to the kind of thing acted on (`user`, `secret`)."),
|
package/dist/query.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface AuditQuery {
|
|
|
26
26
|
actorKind?: ControlPlaneActorKind;
|
|
27
27
|
/** Match an exact `domain/reason` action code. */
|
|
28
28
|
action?: string;
|
|
29
|
-
/** Match every action under one domain — `auth` matches `auth/
|
|
29
|
+
/** Match every action under one domain — `auth` matches `auth/signin`, never `authority/granted`. */
|
|
30
30
|
actionPrefix?: string;
|
|
31
31
|
/** Match the outcome (`success` | `failure` | `denied`). */
|
|
32
32
|
outcome?: AuditOutcome;
|
package/dist/query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;A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CAAC,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,6CAA6C;IAC7C,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,6CAA6C;IAC7C,EAAE,CAAC,EAAE,IAAI,CAAC;IACV;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,8BAA8B;IAC9B,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,mEAAmE;IACnE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AA8DD;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,aAAa,EAAE,MAAM,GAAE,UAAe,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAK3G;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,EAAE,EAAE,aAAa,EAAE,MAAM,GAAE,UAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAuBzG;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAGtG"}
|
package/dist/seeds/example.js
CHANGED
|
@@ -78,7 +78,7 @@ const auditExampleSeed = defineSeed({
|
|
|
78
78
|
id: 1,
|
|
79
79
|
eventId: "example-audit-0001",
|
|
80
80
|
occurredAt: minutesAgo(90),
|
|
81
|
-
action: "auth/
|
|
81
|
+
action: "auth/signin",
|
|
82
82
|
outcome: "success",
|
|
83
83
|
severity: "info",
|
|
84
84
|
actorType: "user",
|
|
@@ -99,7 +99,7 @@ const auditExampleSeed = defineSeed({
|
|
|
99
99
|
id: 2,
|
|
100
100
|
eventId: "example-audit-0002",
|
|
101
101
|
occurredAt: minutesAgo(75),
|
|
102
|
-
action: "auth/
|
|
102
|
+
action: "auth/signin",
|
|
103
103
|
outcome: "denied",
|
|
104
104
|
severity: "warning",
|
|
105
105
|
actorType: "user",
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
/** This package's npm name — the join key against a release feed. */
|
|
4
4
|
export declare const PACKAGE_NAME = "@pithy-sh/audit";
|
|
5
5
|
/** This package's version, stamped from its own package.json at generation time. */
|
|
6
|
-
export declare const PACKAGE_VERSION = "0.9.
|
|
6
|
+
export declare const PACKAGE_VERSION = "0.9.2";
|
|
7
7
|
//# sourceMappingURL=version.generated.d.ts.map
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
/** This package's npm name — the join key against a release feed. */
|
|
5
5
|
const PACKAGE_NAME = "@pithy-sh/audit";
|
|
6
6
|
/** This package's version, stamped from its own package.json at generation time. */
|
|
7
|
-
const PACKAGE_VERSION = "0.9.
|
|
7
|
+
const PACKAGE_VERSION = "0.9.2";
|
|
8
8
|
//#endregion
|
|
9
9
|
export { PACKAGE_NAME, PACKAGE_VERSION };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pithy-sh/audit",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"license": "FSL-1.1-MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@hono/zod-validator": "^0.9.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@pithy-sh/core": "^0.
|
|
42
|
-
"@pithy-sh/secrets": "^0.6.
|
|
41
|
+
"@pithy-sh/core": "^0.19.0",
|
|
42
|
+
"@pithy-sh/secrets": "^0.6.7",
|
|
43
43
|
"hono": "^4.13.2",
|
|
44
44
|
"kysely": "^0.29.0",
|
|
45
45
|
"zod": "^4.4.0"
|
package/src/actions.ts
CHANGED
|
@@ -6,18 +6,18 @@ import { AuditInvalidEventError } from "./error/errors";
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Author a capability's action constants. The taxonomy is **federated**: each capability owns and
|
|
9
|
-
* exports its own `domain/reason` action codes (`auth/
|
|
9
|
+
* exports its own `domain/reason` action codes (`auth/signin`, `entitlement/granted`) and adds them
|
|
10
10
|
* without touching core — the way migrations and table prefixes already federate per-capability.
|
|
11
11
|
*
|
|
12
12
|
* This validates every code against the shared {@link AuditAction} shape at author time, so a typo
|
|
13
13
|
* (a missing slash, an uppercase letter) fails loudly where the constant is declared rather than
|
|
14
14
|
* silently when an event is emitted. Returns the same object, typed, so call sites read
|
|
15
|
-
* `AuthAuditActions.
|
|
15
|
+
* `AuthAuditActions.signin`:
|
|
16
16
|
*
|
|
17
17
|
* ```ts
|
|
18
18
|
* export const AuthAuditActions = defineAuditActions({
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* signin: "auth/signin",
|
|
20
|
+
* tokenRefresh: "auth/token_refresh",
|
|
21
21
|
* });
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
@@ -27,7 +27,7 @@ export function defineAuditActions<const T extends Record<string, string>>(actio
|
|
|
27
27
|
if (!parsed.success) {
|
|
28
28
|
throw new AuditInvalidEventError({
|
|
29
29
|
message: `Invalid audit action code for "${name}": ${code}`,
|
|
30
|
-
action: "Use a lowercase namespaced `domain/reason` code, e.g. `auth/
|
|
30
|
+
action: "Use a lowercase namespaced `domain/reason` code, e.g. `auth/signin`.",
|
|
31
31
|
detail: parsed.error.message,
|
|
32
32
|
});
|
|
33
33
|
}
|
package/src/http/schemas.ts
CHANGED
|
@@ -92,7 +92,7 @@ export const ListAuditEventsQuery = z
|
|
|
92
92
|
.transform((value) => value.replace(/\/$/, ""))
|
|
93
93
|
.optional()
|
|
94
94
|
.describe(
|
|
95
|
-
"Filter to every action under one domain — `auth` or `auth/` matches `auth/
|
|
95
|
+
"Filter to every action under one domain — `auth` or `auth/` matches `auth/signin` and `auth/signout`, never `authority/granted`. The domain is the only prefix: a reason is never matched by its start.",
|
|
96
96
|
),
|
|
97
97
|
outcome: AuditOutcome.optional().describe(
|
|
98
98
|
"Filter to one outcome. `denied` is the one worth watching: a run of denials is what a credential being probed looks like.",
|
package/src/query.ts
CHANGED
|
@@ -30,7 +30,7 @@ export interface AuditQuery {
|
|
|
30
30
|
actorKind?: ControlPlaneActorKind;
|
|
31
31
|
/** Match an exact `domain/reason` action code. */
|
|
32
32
|
action?: string;
|
|
33
|
-
/** Match every action under one domain — `auth` matches `auth/
|
|
33
|
+
/** Match every action under one domain — `auth` matches `auth/signin`, never `authority/granted`. */
|
|
34
34
|
actionPrefix?: string;
|
|
35
35
|
/** Match the outcome (`success` | `failure` | `denied`). */
|
|
36
36
|
outcome?: AuditOutcome;
|
package/src/seeds/example.ts
CHANGED
|
@@ -75,7 +75,7 @@ export const auditExampleSeed: SeedSet = defineSeed({
|
|
|
75
75
|
id: 1,
|
|
76
76
|
eventId: "example-audit-0001",
|
|
77
77
|
occurredAt: minutesAgo(90),
|
|
78
|
-
action: "auth/
|
|
78
|
+
action: "auth/signin",
|
|
79
79
|
outcome: "success",
|
|
80
80
|
severity: "info",
|
|
81
81
|
actorType: "user",
|
|
@@ -96,7 +96,7 @@ export const auditExampleSeed: SeedSet = defineSeed({
|
|
|
96
96
|
id: 2,
|
|
97
97
|
eventId: "example-audit-0002",
|
|
98
98
|
occurredAt: minutesAgo(75),
|
|
99
|
-
action: "auth/
|
|
99
|
+
action: "auth/signin",
|
|
100
100
|
outcome: "denied",
|
|
101
101
|
severity: "warning",
|
|
102
102
|
actorType: "user",
|
package/src/version.generated.ts
CHANGED