@astram/core 1.9.0 → 1.11.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.
Files changed (50) hide show
  1. package/dist/audit/audit-recorder.d.ts +38 -2
  2. package/dist/audit/audit-recorder.d.ts.map +1 -1
  3. package/dist/audit/audit-recorder.js +39 -12
  4. package/dist/audit/audit-recorder.js.map +1 -1
  5. package/dist/audit/audit-row.d.ts +63 -0
  6. package/dist/audit/audit-row.d.ts.map +1 -0
  7. package/dist/audit/audit-row.js +99 -0
  8. package/dist/audit/audit-row.js.map +1 -0
  9. package/dist/audit/errors.d.ts +22 -0
  10. package/dist/audit/errors.d.ts.map +1 -1
  11. package/dist/audit/errors.js +18 -0
  12. package/dist/audit/errors.js.map +1 -1
  13. package/dist/audit/index.d.ts +1 -0
  14. package/dist/audit/index.d.ts.map +1 -1
  15. package/dist/audit/index.js +3 -0
  16. package/dist/audit/index.js.map +1 -1
  17. package/dist/audit/ports.d.ts +13 -8
  18. package/dist/audit/ports.d.ts.map +1 -1
  19. package/dist/audit/ports.js +7 -5
  20. package/dist/audit/ports.js.map +1 -1
  21. package/dist/authentication/captcha.d.ts +58 -0
  22. package/dist/authentication/captcha.d.ts.map +1 -0
  23. package/dist/authentication/captcha.js +37 -0
  24. package/dist/authentication/captcha.js.map +1 -0
  25. package/dist/authentication/index.d.ts +3 -0
  26. package/dist/authentication/index.d.ts.map +1 -1
  27. package/dist/authentication/index.js +6 -0
  28. package/dist/authentication/index.js.map +1 -1
  29. package/dist/authentication/login-name.d.ts +22 -0
  30. package/dist/authentication/login-name.d.ts.map +1 -0
  31. package/dist/authentication/login-name.js +35 -0
  32. package/dist/authentication/login-name.js.map +1 -0
  33. package/dist/authentication/mfa-requirement.d.ts +156 -0
  34. package/dist/authentication/mfa-requirement.d.ts.map +1 -0
  35. package/dist/authentication/mfa-requirement.js +122 -0
  36. package/dist/authentication/mfa-requirement.js.map +1 -0
  37. package/dist/database/framework-tables.d.ts.map +1 -1
  38. package/dist/database/framework-tables.js +3 -1
  39. package/dist/database/framework-tables.js.map +1 -1
  40. package/dist-cjs/audit/audit-recorder.js +40 -12
  41. package/dist-cjs/audit/audit-row.js +102 -0
  42. package/dist-cjs/audit/errors.js +20 -1
  43. package/dist-cjs/audit/index.js +3 -0
  44. package/dist-cjs/audit/ports.js +7 -5
  45. package/dist-cjs/authentication/captcha.js +40 -0
  46. package/dist-cjs/authentication/index.js +6 -0
  47. package/dist-cjs/authentication/login-name.js +39 -0
  48. package/dist-cjs/authentication/mfa-requirement.js +127 -0
  49. package/dist-cjs/database/framework-tables.js +3 -1
  50. package/package.json +6 -1
@@ -40,7 +40,7 @@
40
40
  *
41
41
  * ADR-0003: framework-agnostic — no framework / HTTP / DB / node imports.
42
42
  */
43
- import type { AuditSink } from './index.js';
43
+ import type { AuditEvent, AuditSink } from './index.js';
44
44
  import type { AuditEventStore, Clock, HashFunction, StoredAuditRecord } from './ports.js';
45
45
  /**
46
46
  * The fixed genesis `prevHash` for the FIRST record of every tenant's chain
@@ -50,6 +50,35 @@ import type { AuditEventStore, Clock, HashFunction, StoredAuditRecord } from './
50
50
  * `entryHash` and lets the scheme version later without ambiguity.
51
51
  */
52
52
  export declare const GENESIS = "shield:audit:genesis:v1";
53
+ /**
54
+ * The position a tenant's chain continues from: the last linked (or last pruned)
55
+ * record's tenant, sequence and entry hash. Passed to {@link linkEntry} as `prev` and
56
+ * to {@link verifyChain} as `anchor` (a pruned chain's checkpoint, or the tail of the
57
+ * previous page when a verifier pages a long chain).
58
+ */
59
+ export interface ChainAnchor {
60
+ readonly tenantId: string;
61
+ readonly sequenceNumber: number;
62
+ readonly entryHash: string;
63
+ }
64
+ /** The chain fields {@link linkEntry} computes for one event. */
65
+ export interface ChainLink {
66
+ readonly sequenceNumber: number;
67
+ readonly contentHash: string;
68
+ readonly prevHash: string;
69
+ readonly entryHash: string;
70
+ }
71
+ /**
72
+ * The pure chain math for ONE event (§3): `contentHash = H(canonicalize(content))`,
73
+ * `sequenceNumber = prev.sequenceNumber + 1` (or `0`), `prevHash = prev.entryHash`
74
+ * (or {@link GENESIS}), `entryHash = H(contentHash ‖ prevHash ‖ sequenceNumber)`.
75
+ *
76
+ * `content` is hashed exactly as given: the caller passes the already-cleaned event
77
+ * (the recorder strips secrets first; the sealer builds it from the stored row with
78
+ * `auditEventFromRow`). Equal inputs give equal outputs. `prev.tenantId` is not read
79
+ * here; the caller keeps chains per tenant.
80
+ */
81
+ export declare function linkEntry(content: AuditEvent, prev: ChainAnchor | undefined, hash: HashFunction): ChainLink;
53
82
  /** Injected capabilities for {@link createAuditRecorder}. */
54
83
  export interface AuditRecorderDeps {
55
84
  /** Append-only record store PORT (MariaDB adapter in `@astram/guard`). */
@@ -122,8 +151,15 @@ export type ChainVerification = {
122
151
  * - `content_mismatch` — the recomputed `contentHash`/`entryHash` ≠ the stored
123
152
  * ones: a field of the record was mutated.
124
153
  *
154
+ * With an `anchor` (a pruned chain's checkpoint, or the last record of the previous
155
+ * page), the chain is expected to continue from it: the expected tenant is
156
+ * `anchor.tenantId` (a foreign first record is reported at index 0), the first
157
+ * sequence `anchor.sequenceNumber + 1` and the first `prevHash` `anchor.entryHash`.
158
+ * Without one, the chain must start at sequence 0 from {@link GENESIS}.
159
+ *
125
160
  * @param records An ordered, single-tenant chain (sequence ascending).
126
161
  * @param hash The SAME deterministic hash used to write the chain.
162
+ * @param anchor Optional position the records continue from.
127
163
  */
128
- export declare function verifyChain(records: readonly StoredAuditRecord[], hash: HashFunction): ChainVerification;
164
+ export declare function verifyChain(records: readonly StoredAuditRecord[], hash: HashFunction, anchor?: ChainAnchor): ChainVerification;
129
165
  //# sourceMappingURL=audit-recorder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"audit-recorder.d.ts","sourceRoot":"","sources":["../../src/audit/audit-recorder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,KA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ACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,SAAS,CAsGtE;AAED,sDAAsD;AACtD,MAAM,MAAM,gBAAgB,GAC1B,kBAAkB,GAAG,eAAe,GAAG,cAAc,GAAG,iBAAiB,CAAC;AAE5E,sFAAsF;AACtF,MAAM,MAAM,iBAAiB,GACzB;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAEhG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,SAAS,iBAAiB,EAAE,EACrC,IAAI,EAAE,YAAY,EAClB,MAAM,CAAC,EAAE,WAAW,GACnB,iBAAiB,CAoEnB"}
@@ -61,6 +61,23 @@ const CHAIN_SEP = '|';
61
61
  function entryPreimage(contentHash, prevHash, sequenceNumber) {
62
62
  return `${contentHash}${CHAIN_SEP}${prevHash}${CHAIN_SEP}${sequenceNumber}`;
63
63
  }
64
+ /**
65
+ * The pure chain math for ONE event (§3): `contentHash = H(canonicalize(content))`,
66
+ * `sequenceNumber = prev.sequenceNumber + 1` (or `0`), `prevHash = prev.entryHash`
67
+ * (or {@link GENESIS}), `entryHash = H(contentHash ‖ prevHash ‖ sequenceNumber)`.
68
+ *
69
+ * `content` is hashed exactly as given: the caller passes the already-cleaned event
70
+ * (the recorder strips secrets first; the sealer builds it from the stored row with
71
+ * `auditEventFromRow`). Equal inputs give equal outputs. `prev.tenantId` is not read
72
+ * here; the caller keeps chains per tenant.
73
+ */
74
+ export function linkEntry(content, prev, hash) {
75
+ const sequenceNumber = prev !== undefined ? prev.sequenceNumber + 1 : 0;
76
+ const prevHash = prev !== undefined ? prev.entryHash : GENESIS;
77
+ const contentHash = hash.hash(canonicalizeEvent(content));
78
+ const entryHash = hash.hash(entryPreimage(contentHash, prevHash, sequenceNumber));
79
+ return { sequenceNumber, contentHash, prevHash, entryHash };
80
+ }
64
81
  /**
65
82
  * A non-blank string guard — an actor/tenant id must be a present, non-whitespace
66
83
  * string. (`.trim()` catches `' '`, which a bare `length === 0` would miss.)
@@ -129,10 +146,13 @@ export function createAuditRecorder(deps) {
129
146
  // prevHash from it. Per-tenant: `readChain` only returns THIS tenant's records.
130
147
  const chain = await store.readChain(event.tenantId);
131
148
  const tail = chain.length > 0 ? chain[chain.length - 1] : undefined;
132
- const sequenceNumber = tail !== undefined ? tail.sequenceNumber + 1 : 0;
133
- const prevHash = tail !== undefined ? tail.entryHash : GENESIS;
134
- const contentHash = hash.hash(canonicalizeEvent(cleanEvent));
135
- const entryHash = hash.hash(entryPreimage(contentHash, prevHash, sequenceNumber));
149
+ const { sequenceNumber, contentHash, prevHash, entryHash } = linkEntry(cleanEvent, tail !== undefined
150
+ ? {
151
+ tenantId: tail.tenantId,
152
+ sequenceNumber: tail.sequenceNumber,
153
+ entryHash: tail.entryHash,
154
+ }
155
+ : undefined, hash);
136
156
  // ── (4) STAMP (AC-9). The engine's own clock — distinct from occurredAtMs.
137
157
  const recordedAtMs = clock.nowMs();
138
158
  const stored = {
@@ -200,17 +220,24 @@ export function createAuditRecorder(deps) {
200
220
  * - `content_mismatch` — the recomputed `contentHash`/`entryHash` ≠ the stored
201
221
  * ones: a field of the record was mutated.
202
222
  *
223
+ * With an `anchor` (a pruned chain's checkpoint, or the last record of the previous
224
+ * page), the chain is expected to continue from it: the expected tenant is
225
+ * `anchor.tenantId` (a foreign first record is reported at index 0), the first
226
+ * sequence `anchor.sequenceNumber + 1` and the first `prevHash` `anchor.entryHash`.
227
+ * Without one, the chain must start at sequence 0 from {@link GENESIS}.
228
+ *
203
229
  * @param records An ordered, single-tenant chain (sequence ascending).
204
230
  * @param hash The SAME deterministic hash used to write the chain.
231
+ * @param anchor Optional position the records continue from.
205
232
  */
206
- export function verifyChain(records, hash) {
207
- let expectedPrevHash = GENESIS;
208
- let expectedSequence = 0;
209
- // The chain is contractually SINGLE-tenant. Pin the expected tenant to the first
210
- // record's; any later record with a different `tenantId` is a cross-tenant splice
211
- // (a foreign record chained on at the right sequence can self-verify) and MUST be
212
- // rejected. An empty array has no tenant → vacuously intact (loop does not run).
213
- const expectedTenantId = records.length > 0 ? records[0]?.tenantId : undefined;
233
+ export function verifyChain(records, hash, anchor) {
234
+ let expectedPrevHash = anchor !== undefined ? anchor.entryHash : GENESIS;
235
+ let expectedSequence = anchor !== undefined ? anchor.sequenceNumber + 1 : 0;
236
+ // The chain is contractually SINGLE-tenant. Pin the expected tenant to the anchor's
237
+ // (else the first record's); any record with a different `tenantId` is a cross-tenant
238
+ // splice (a foreign record chained on at the right sequence can self-verify) and MUST
239
+ // be rejected. An empty array is vacuously intact (loop does not run).
240
+ const expectedTenantId = anchor !== undefined ? anchor.tenantId : records.length > 0 ? records[0]?.tenantId : undefined;
214
241
  for (let i = 0; i < records.length; i++) {
215
242
  const record = records[i];
216
243
  if (record === undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"audit-recorder.js","sourceRoot":"","sources":["../../src/audit/audit-recorder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,0BAA0B,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,yBAAyB,CAAC;AAEjD,wEAAwE;AACxE,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB;;;;GAIG;AACH,SAAS,aAAa,CAAC,WAAmB,EAAE,QAAgB,EAAE,cAAsB;IAClF,OAAO,GAAG,WAAW,GAAG,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AAE,CAAC;YACvE,GAAG,CAAC,MAAM,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9E,CAAC;QACF,MAAM,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAC;QACvE,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CACnC,aAAa,CAAC,qBAAqB,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,cAAc,CAAC,CAC7E,CAAC;QACF,IAAI,qBAAqB,KAAK,MAAM,CAAC,WAAW,IAAI,mBAAmB,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC;YAC7F,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC;QACvE,CAAC;QAED,4EAA4E;QAC5E,gBAAgB,GAAG,mBAAmB,CAAC;QACvC,gBAAgB,GAAG,MAAM,CAAC,cAAc,GAAG,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Stored-row mapping for the durable audit chain (audit-chain-store SPEC §5.D).
3
+ *
4
+ * `auditEventFromRow` is THE one mapping from an `audit_log` row back to the
5
+ * {@link AuditEvent} whose canonical form is hashed into the chain. The sealer (guard)
6
+ * and the verifier (`astram-migrate audit:verify`) both use it, so the content they
7
+ * hash is built the same way from the same stored columns. It is the inverse of the
8
+ * one INSERT shape (`@astram/engine` `MariaDbAuditSink.record`):
9
+ * - `al_type`, `al_actor_id`, `al_tenant_id` ⇒ `type`, `actorId`, `tenantId`;
10
+ * - `al_occurred_at_ms` (BIGINT) ⇒ `occurredAtMs` via {@link toSafeInteger};
11
+ * - `al_action_key` ⇒ `action: { key }`;
12
+ * - `al_resource_json`, `al_decision_json`, `al_attributes_json` ⇒ the parsed value
13
+ * (the driver may return JSON text or an already-parsed value);
14
+ * - SQL NULL ⇒ the field is absent (never `undefined`-valued, never `null`);
15
+ * - `al_uuid` is the row key, not content: it is never part of the event.
16
+ *
17
+ * BIGINT values never reach the hashed content as `bigint` (`canonicalizeEvent`
18
+ * rejects them): they are converted to a safe `number` or the row is rejected with a
19
+ * typed {@link AuditRowError}. A JSON column whose text does not parse is also rejected
20
+ * typed (`invalid_json`), so the sealer can tell a repeating row problem from a
21
+ * transient database error.
22
+ *
23
+ * Kept in its own file (not `audit-recorder.ts`): it is row/driver shape knowledge,
24
+ * not chain math, and the recorder stays independent of any storage layout.
25
+ *
26
+ * ADR-0003: framework-agnostic — no framework / HTTP / DB / node imports.
27
+ */
28
+ import type { AuditEvent } from './index.js';
29
+ /** A BIGINT column value as a MariaDB driver may return it. */
30
+ export type BigIntColumnValue = number | bigint | string;
31
+ /**
32
+ * One `audit_log` row as read back from the database (column names of identity
33
+ * migration `1710000000010-CreateAuditLog`). JSON columns may be text or parsed;
34
+ * nullable columns may be `null`. `al_uuid` is accepted but never mapped.
35
+ */
36
+ export interface AuditLogRow {
37
+ readonly al_uuid?: string;
38
+ readonly al_type: string;
39
+ readonly al_occurred_at_ms: BigIntColumnValue;
40
+ readonly al_actor_id: string;
41
+ readonly al_tenant_id: string;
42
+ readonly al_action_key?: string | null;
43
+ readonly al_resource_json?: unknown;
44
+ readonly al_decision_json?: unknown;
45
+ readonly al_attributes_json?: unknown;
46
+ }
47
+ /**
48
+ * Convert a BIGINT column value (`number`, `bigint`, or decimal-integer string) to a
49
+ * JS `number`, refusing anything that is not exactly representable: a non-integer, a
50
+ * value outside `Number.MIN_SAFE_INTEGER..MAX_SAFE_INTEGER`, `NaN`/`±Infinity`, an
51
+ * empty or non-decimal string, `null`, `undefined` or any other type ⇒
52
+ * `AuditRowError('unsafe_integer')` (the value is never put in the message).
53
+ *
54
+ * Used for `al_occurred_at_ms`, `ac_sequence` and `acc_sequence`.
55
+ */
56
+ export declare function toSafeInteger(value: BigIntColumnValue): number;
57
+ /**
58
+ * Map one stored `audit_log` row to the {@link AuditEvent} that is hashed into the
59
+ * chain (see the file header for the column mapping). Throws {@link AuditRowError}
60
+ * for an unsafe BIGINT or unparseable JSON text.
61
+ */
62
+ export declare function auditEventFromRow(row: AuditLogRow): AuditEvent;
63
+ //# sourceMappingURL=audit-row.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-row.d.ts","sourceRoot":"","sources":["../../src/audit/audit-row.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,YAAY,CAAC;AAE7D,+DAA+D;AAC/D,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzD;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAC9C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CACvC;AAQD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAc9D;AAeD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,WAAW,GAAG,UAAU,CAsB9D"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Stored-row mapping for the durable audit chain (audit-chain-store SPEC §5.D).
3
+ *
4
+ * `auditEventFromRow` is THE one mapping from an `audit_log` row back to the
5
+ * {@link AuditEvent} whose canonical form is hashed into the chain. The sealer (guard)
6
+ * and the verifier (`astram-migrate audit:verify`) both use it, so the content they
7
+ * hash is built the same way from the same stored columns. It is the inverse of the
8
+ * one INSERT shape (`@astram/engine` `MariaDbAuditSink.record`):
9
+ * - `al_type`, `al_actor_id`, `al_tenant_id` ⇒ `type`, `actorId`, `tenantId`;
10
+ * - `al_occurred_at_ms` (BIGINT) ⇒ `occurredAtMs` via {@link toSafeInteger};
11
+ * - `al_action_key` ⇒ `action: { key }`;
12
+ * - `al_resource_json`, `al_decision_json`, `al_attributes_json` ⇒ the parsed value
13
+ * (the driver may return JSON text or an already-parsed value);
14
+ * - SQL NULL ⇒ the field is absent (never `undefined`-valued, never `null`);
15
+ * - `al_uuid` is the row key, not content: it is never part of the event.
16
+ *
17
+ * BIGINT values never reach the hashed content as `bigint` (`canonicalizeEvent`
18
+ * rejects them): they are converted to a safe `number` or the row is rejected with a
19
+ * typed {@link AuditRowError}. A JSON column whose text does not parse is also rejected
20
+ * typed (`invalid_json`), so the sealer can tell a repeating row problem from a
21
+ * transient database error.
22
+ *
23
+ * Kept in its own file (not `audit-recorder.ts`): it is row/driver shape knowledge,
24
+ * not chain math, and the recorder stays independent of any storage layout.
25
+ *
26
+ * ADR-0003: framework-agnostic — no framework / HTTP / DB / node imports.
27
+ */
28
+ import { AuditRowError } from './errors.js';
29
+ const MAX_SAFE = BigInt(Number.MAX_SAFE_INTEGER);
30
+ const MIN_SAFE = BigInt(Number.MIN_SAFE_INTEGER);
31
+ /** Optional sign, then decimal digits only; 17 digits already exceed the safe range. */
32
+ const DECIMAL_INTEGER = /^-?[0-9]{1,20}$/;
33
+ /**
34
+ * Convert a BIGINT column value (`number`, `bigint`, or decimal-integer string) to a
35
+ * JS `number`, refusing anything that is not exactly representable: a non-integer, a
36
+ * value outside `Number.MIN_SAFE_INTEGER..MAX_SAFE_INTEGER`, `NaN`/`±Infinity`, an
37
+ * empty or non-decimal string, `null`, `undefined` or any other type ⇒
38
+ * `AuditRowError('unsafe_integer')` (the value is never put in the message).
39
+ *
40
+ * Used for `al_occurred_at_ms`, `ac_sequence` and `acc_sequence`.
41
+ */
42
+ export function toSafeInteger(value) {
43
+ const v = value;
44
+ if (typeof v === 'number') {
45
+ if (!Number.isSafeInteger(v))
46
+ throw new AuditRowError('unsafe_integer');
47
+ return v === 0 ? 0 : v; // normalize -0
48
+ }
49
+ if (typeof v === 'bigint') {
50
+ if (v > MAX_SAFE || v < MIN_SAFE)
51
+ throw new AuditRowError('unsafe_integer');
52
+ return Number(v);
53
+ }
54
+ if (typeof v === 'string' && DECIMAL_INTEGER.test(v)) {
55
+ return toSafeInteger(BigInt(v));
56
+ }
57
+ throw new AuditRowError('unsafe_integer');
58
+ }
59
+ /** A JSON column: SQL NULL (or a parsed JSON null) ⇒ absent; text ⇒ parsed; else as given. */
60
+ function jsonColumn(value) {
61
+ if (value === null || value === undefined)
62
+ return undefined;
63
+ if (typeof value !== 'string')
64
+ return value;
65
+ let parsed;
66
+ try {
67
+ parsed = JSON.parse(value);
68
+ }
69
+ catch {
70
+ throw new AuditRowError('invalid_json');
71
+ }
72
+ return parsed === null ? undefined : parsed;
73
+ }
74
+ /**
75
+ * Map one stored `audit_log` row to the {@link AuditEvent} that is hashed into the
76
+ * chain (see the file header for the column mapping). Throws {@link AuditRowError}
77
+ * for an unsafe BIGINT or unparseable JSON text.
78
+ */
79
+ export function auditEventFromRow(row) {
80
+ const occurredAtMs = toSafeInteger(row.al_occurred_at_ms);
81
+ const actionKey = row.al_action_key;
82
+ const resource = jsonColumn(row.al_resource_json);
83
+ const decision = jsonColumn(row.al_decision_json);
84
+ const attributes = jsonColumn(row.al_attributes_json);
85
+ const action = actionKey !== null && actionKey !== undefined ? { key: actionKey } : undefined;
86
+ return {
87
+ type: row.al_type,
88
+ occurredAtMs,
89
+ actorId: row.al_actor_id,
90
+ tenantId: row.al_tenant_id,
91
+ ...(action !== undefined ? { action } : {}),
92
+ ...(resource !== undefined ? { resource: resource } : {}),
93
+ ...(decision !== undefined ? { decision: decision } : {}),
94
+ ...(attributes !== undefined
95
+ ? { attributes: attributes }
96
+ : {}),
97
+ };
98
+ }
99
+ //# sourceMappingURL=audit-row.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-row.js","sourceRoot":"","sources":["../../src/audit/audit-row.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAuB5C,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACjD,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEjD,wFAAwF;AACxF,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAE1C;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,KAAwB;IACpD,MAAM,CAAC,GAAY,KAAK,CAAC;IACzB,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;YAAE,MAAM,IAAI,aAAa,CAAC,gBAAgB,CAAC,CAAC;QACxE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe;IACzC,CAAC;IACD,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,IAAI,CAAC,GAAG,QAAQ,IAAI,CAAC,GAAG,QAAQ;YAAE,MAAM,IAAI,aAAa,CAAC,gBAAgB,CAAC,CAAC;QAC5E,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;IACD,IAAI,OAAO,CAAC,KAAK,QAAQ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AyB;QACnC,YAAY;QACZ,OAAO,EAAE,GAAG,CAAC,WAAW;QACxB,QAAQ,EAAE,GAAG,CAAC,YAAY;QAC1B,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3C,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAoB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrE,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAoB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrE,GAAG,CAAC,UAAU,KAAK,SAAS;YAC1B,CAAC,CAAC,EAAE,UAAU,EAAE,UAA+C,EAAE;YACjE,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC"}
@@ -53,4 +53,26 @@ export declare class AuditValidationError extends Error {
53
53
  readonly reason: AuditValidationReason;
54
54
  constructor(reason: AuditValidationReason);
55
55
  }
56
+ /** Why a stored `audit_log` / chain row could not be mapped back to its hashed content. */
57
+ export type AuditRowRejectionReason =
58
+ /**
59
+ * A BIGINT column (`al_occurred_at_ms`, `ac_sequence`, `acc_sequence`) is not a
60
+ * safe integer (or not an integer, or not a number/bigint/decimal string), so it
61
+ * cannot become a JS `number` without losing precision.
62
+ */
63
+ 'unsafe_integer'
64
+ /** A JSON column holds text that does not parse as JSON. */
65
+ | 'invalid_json';
66
+ /**
67
+ * Thrown by `auditEventFromRow` / `toSafeInteger` (`./audit-row.ts`) when a STORED
68
+ * row cannot be turned back into the exact `AuditEvent` that is hashed. A repeating
69
+ * error: the same row fails the same way on every retry, so the sealer parks that
70
+ * tenant until the next sweep (SPEC §5.G). Names the reason only; NEVER carries the
71
+ * offending value (it comes from the database and could be anything).
72
+ */
73
+ export declare class AuditRowError extends Error {
74
+ /** The specific row problem. */
75
+ readonly reason: AuditRowRejectionReason;
76
+ constructor(reason: AuditRowRejectionReason);
77
+ }
56
78
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/audit/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,wFAAwF;AACxF,MAAM,MAAM,qBAAqB,GAC7B,eAAe,GACf,gBAAgB,GAChB,qBAAqB;AACvB;;;;;;;GAOG;GACD,0BAA0B;AAC5B;;;;;;;;GAQG;GACD,kBAAkB,CAAC;AAEvB;;;;;;;;;;GAUG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;gBAE3B,MAAM,EAAE,qBAAqB;CAO1C"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/audit/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,wFAAwF;AACxF,MAAM,MAAM,qBAAqB,GAC7B,eAAe,GACf,gBAAgB,GAChB,qBAAqB;AACvB;;;;;;;GAOG;GACD,0BAA0B;AAC5B;;;;;;;;GAQG;GACD,kBAAkB,CAAC;AAEvB;;;;;;;;;;GAUG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;gBAE3B,MAAM,EAAE,qBAAqB;CAO1C;AAED,2FAA2F;AAC3F,MAAM,MAAM,uBAAuB;AACjC;;;;GAIG;AACD,gBAAgB;AAClB,4DAA4D;GAC1D,cAAc,CAAC;AAEnB;;;;;;GAMG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,gCAAgC;IAChC,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC;gBAE7B,MAAM,EAAE,uBAAuB;CAO5C"}
@@ -38,4 +38,22 @@ export class AuditValidationError extends Error {
38
38
  Object.setPrototypeOf(this, AuditValidationError.prototype);
39
39
  }
40
40
  }
41
+ /**
42
+ * Thrown by `auditEventFromRow` / `toSafeInteger` (`./audit-row.ts`) when a STORED
43
+ * row cannot be turned back into the exact `AuditEvent` that is hashed. A repeating
44
+ * error: the same row fails the same way on every retry, so the sealer parks that
45
+ * tenant until the next sweep (SPEC §5.G). Names the reason only; NEVER carries the
46
+ * offending value (it comes from the database and could be anything).
47
+ */
48
+ export class AuditRowError extends Error {
49
+ /** The specific row problem. */
50
+ reason;
51
+ constructor(reason) {
52
+ super(`audit_row_rejected:${reason}`);
53
+ this.name = 'AuditRowError';
54
+ this.reason = reason;
55
+ // Preserve the prototype chain when compiled down-level so `instanceof` works.
56
+ Object.setPrototypeOf(this, AuditRowError.prototype);
57
+ }
58
+ }
41
59
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/audit/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA2BH;;;;;;;;;;GAUG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,4EAA4E;IACnE,MAAM,CAAwB;IAEvC,YAAY,MAA6B;QACvC,KAAK,CAAC,wBAAwB,MAAM,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,+EAA+E;QAC/E,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC9D,CAAC;CACF"}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/audit/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA2BH;;;;;;;;;;GAUG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,4EAA4E;IACnE,MAAM,CAAwB;IAEvC,YAAY,MAA6B;QACvC,KAAK,CAAC,wBAAwB,MAAM,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,+EAA+E;QAC/E,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC9D,CAAC;CACF;AAaD;;;;;;GAMG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,gCAAgC;IACvB,MAAM,CAA0B;IAEzC,YAAY,MAA+B;QACzC,KAAK,CAAC,sBAAsB,MAAM,EAAE,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,+EAA+E;QAC/E,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;CACF"}
@@ -42,4 +42,5 @@ export * from './canonicalize.js';
42
42
  export * from './sensitive.js';
43
43
  export * from './errors.js';
44
44
  export * from './audit-recorder.js';
45
+ export * from './audit-row.js';
45
46
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/audit/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE5E,qCAAqC;AACrC,MAAM,MAAM,cAAc,GACtB,gBAAgB,GAChB,mBAAmB,GACnB,wBAAwB,GACxB,mBAAmB,GACnB,cAAc,GACd,aAAa,CAAC;AAElB;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,gEAAgE;IAChE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;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AQ,CAAC,EAAE,QAAQ,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAC7B,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACzD;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,0EAA0E;IAC1E,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAMD,cAAc,YAAY,CAAC;AAE3B,cAAc,mBAAmB,CAAC;AAElC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,aAAa,CAAC;AAG5B,cAAc,qBAAqB,CAAC;AAGpC,cAAc,gBAAgB,CAAC"}
@@ -21,4 +21,7 @@ export * from './errors.js';
21
21
  // - the tamper-evident recorder `createAuditRecorder` (IS an AuditSink) + the pure
22
22
  // `verifyChain` primitive + the GENESIS chain constant:
23
23
  export * from './audit-recorder.js';
24
+ // - the stored-row mapping for the durable chain (`auditEventFromRow`, `toSafeInteger`,
25
+ // `AuditLogRow`); `linkEntry` / `ChainAnchor` come from `./audit-recorder.js` above:
26
+ export * from './audit-row.js';
24
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/audit/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA0CH,iFAAiF;AACjF,2EAA2E;AAC3E,yEAAyE;AACzE,0FAA0F;AAC1F,cAAc,YAAY,CAAC;AAC3B,qFAAqF;AACrF,cAAc,mBAAmB,CAAC;AAClC,wEAAwE;AACxE,cAAc,gBAAgB,CAAC;AAC/B,+EAA+E;AAC/E,cAAc,aAAa,CAAC;AAC5B,qFAAqF;AACrF,4DAA4D;AAC5D,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/audit/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA0CH,iFAAiF;AACjF,2EAA2E;AAC3E,yEAAyE;AACzE,0FAA0F;AAC1F,cAAc,YAAY,CAAC;AAC3B,qFAAqF;AACrF,cAAc,mBAAmB,CAAC;AAClC,wEAAwE;AACxE,cAAc,gBAAgB,CAAC;AAC/B,+EAA+E;AAC/E,cAAc,aAAa,CAAC;AAC5B,qFAAqF;AACrF,4DAA4D;AAC5D,cAAc,qBAAqB,CAAC;AACpC,0FAA0F;AAC1F,yFAAyF;AACzF,cAAc,gBAAgB,CAAC"}
@@ -5,11 +5,13 @@
5
5
  * knowing which crypto / DB backs them.
6
6
  *
7
7
  * ADR-0003 (zero-dep Core): every concrete adapter (`node:crypto` SHA-256, the
8
- * append-only MariaDB `shield_audit` table) is a real runtime dependency and
9
- * CANNOT live here. The Core defines only these interfaces; `@astram/guard`
10
- * ships the concretes and INJECTS them into `createAuditRecorder(...)`. This keeps
11
- * `@astram/core` at ZERO runtime dependencies (the load-bearing invariant) while
12
- * the substrate stays swappable.
8
+ * append-only MariaDB `<ns>_audit` tables) is a real runtime dependency and
9
+ * CANNOT live here. The Core defines only these interfaces. `@astram/guard` ships
10
+ * the SHA-256 `HashFunction` and the deferred sealer (`AuditChainSealer`,
11
+ * audit-chain-store SPEC §5.G), which chains committed `audit_log` rows with
12
+ * `linkEntry` instead of injecting a store into `createAuditRecorder(...)`. This
13
+ * keeps `@astram/core` at ZERO runtime dependencies (the load-bearing invariant)
14
+ * while the substrate stays swappable.
13
15
  *
14
16
  * ⛔ SECURITY — the audit engine records for INTEGRITY, not confidentiality. It
15
17
  * NEVER persists a secret value (a denylist strips secret-bearing keys before a
@@ -93,9 +95,12 @@ export interface StoredAuditRecord {
93
95
  readonly entryHash: string;
94
96
  }
95
97
  /**
96
- * The **append-only audit record store** PORT (MariaDB `shield_audit` adapter).
97
- * Written ONCE per event and read back ordered for verification. Concrete:
98
- * `MariaDbAuditEventStore` in `@astram/guard`.
98
+ * The **append-only audit record store** PORT used by `createAuditRecorder`
99
+ * (inline chaining). Written ONCE per event and read back ordered for verification.
100
+ * No framework concrete ships for it: framework writers append plain `audit_log`
101
+ * rows and the guard's deferred sealer (`AuditChainSealer`, audit-chain-store SPEC
102
+ * §5.G) chains them into `<ns>_audit.audit_chain` with `linkEntry` /
103
+ * `auditEventFromRow`.
99
104
  *
100
105
  * ⛔ APPEND-ONLY IS STRUCTURAL: this port intentionally exposes NO update / delete
101
106
  * method — the adapter's table forbids UPDATE/DELETE (Infra, ADR-0014). Even the
@@ -1 +1 @@
1
- {"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/audit/ports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAO7C,YAAY,EAAE,KAAK,EAAE,CAAC;AAMtB;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,YAAY;IAC3B,2FAA2F;IAC3F,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7B;AAMD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,iBAAiB;IAEhC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAClC,0FAA0F;IAC1F,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IACvC,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IAC3C,iFAAiF;IACjF,QAAQ,CAAC,UAAU,CAAC,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,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IACvC,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IAC3C,iFAAiF;IACjF,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACxD,oFAAoF;IACpF,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAG1C;;;;OAIG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,kFAAkF;IAClF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjD;;;;;;;;OAQG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAAC;CACpE"}
@@ -5,11 +5,13 @@
5
5
  * knowing which crypto / DB backs them.
6
6
  *
7
7
  * ADR-0003 (zero-dep Core): every concrete adapter (`node:crypto` SHA-256, the
8
- * append-only MariaDB `shield_audit` table) is a real runtime dependency and
9
- * CANNOT live here. The Core defines only these interfaces; `@astram/guard`
10
- * ships the concretes and INJECTS them into `createAuditRecorder(...)`. This keeps
11
- * `@astram/core` at ZERO runtime dependencies (the load-bearing invariant) while
12
- * the substrate stays swappable.
8
+ * append-only MariaDB `<ns>_audit` tables) is a real runtime dependency and
9
+ * CANNOT live here. The Core defines only these interfaces. `@astram/guard` ships
10
+ * the SHA-256 `HashFunction` and the deferred sealer (`AuditChainSealer`,
11
+ * audit-chain-store SPEC §5.G), which chains committed `audit_log` rows with
12
+ * `linkEntry` instead of injecting a store into `createAuditRecorder(...)`. This
13
+ * keeps `@astram/core` at ZERO runtime dependencies (the load-bearing invariant)
14
+ * while the substrate stays swappable.
13
15
  *
14
16
  * ⛔ SECURITY — the audit engine records for INTEGRITY, not confidentiality. It
15
17
  * NEVER persists a secret value (a denylist strips secret-bearing keys before a
@@ -1 +1 @@
1
- {"version":3,"file":"ports.js","sourceRoot":"","sources":["../../src/audit/ports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAqIH,yEAAyE;AACzE,+EAA+E;AAC/E,4EAA4E;AAC5E,2DAA2D"}
1
+ {"version":3,"file":"ports.js","sourceRoot":"","sources":["../../src/audit/ports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;AAwIH,yEAAyE;AACzE,+EAA+E;AAC/E,4EAA4E;AAC5E,2DAA2D"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * CAPTCHA verification port (auth capabilities R7.1, R7.4, R7.5; G-017).
3
+ *
4
+ * Core names the contract only; the Turnstile and reCAPTCHA adapters live in `@astram/guard`
5
+ * (D-4: `fetch`, no new dependency). A verifier checks one client token with the provider and
6
+ * answers one of three outcomes:
7
+ * - passed: the provider accepted the token AND its hostname is expected, its action matches the
8
+ * endpoint and (reCAPTCHA v3) its score reaches the minimum;
9
+ * - rejected (`reason`): the token is missing, invalid, from another hostname, for another action,
10
+ * below the score, or already used (`timeout-or-duplicate`);
11
+ * - unavailable: the provider could not answer (network error, timeout, 5xx, unreadable body).
12
+ * This is NOT a rejection: the caller applies its fail mode (closed by default, R7.5).
13
+ *
14
+ * A verifier never logs or returns the secret or the token.
15
+ *
16
+ * ADR-0003: framework-agnostic, no I/O here.
17
+ */
18
+ import type { CancellationSignal } from '../messaging/ports.js';
19
+ /** The CAPTCHA providers the framework ships adapters for (`CAPTCHA_PROVIDER`). */
20
+ export declare const CAPTCHA_PROVIDERS: readonly ["turnstile", "recaptcha-v3", "recaptcha-v2"];
21
+ export type CaptchaProvider = (typeof CAPTCHA_PROVIDERS)[number];
22
+ /** Why a token was rejected. Never carries provider text. */
23
+ export declare const CAPTCHA_FAILURE_REASONS: readonly ["invalid", "hostname", "action", "score", "reused", "missing"];
24
+ export type CaptchaFailureReason = (typeof CAPTCHA_FAILURE_REASONS)[number];
25
+ /** One verification request. `expectedAction` is the endpoint's action (`login`, …). */
26
+ export interface CaptchaVerifyRequest {
27
+ readonly token: string;
28
+ readonly expectedAction: string;
29
+ /** The client IP as the app trusts it; forwarded to the provider when present. */
30
+ readonly remoteIp?: string;
31
+ }
32
+ /** The provider accepted the token and every local check passed. */
33
+ export interface CaptchaPassed {
34
+ readonly ok: true;
35
+ readonly hostname: string;
36
+ /** The action the provider reported (reCAPTCHA v2 reports none). */
37
+ readonly action?: string;
38
+ /** reCAPTCHA v3 only. */
39
+ readonly score?: number;
40
+ }
41
+ /** The token was refused. */
42
+ export interface CaptchaRejected {
43
+ readonly ok: false;
44
+ readonly reason: CaptchaFailureReason;
45
+ }
46
+ /** The provider could not answer; distinct from a rejection (fail mode decides). */
47
+ export interface CaptchaUnavailable {
48
+ readonly ok: false;
49
+ readonly reason: 'unavailable';
50
+ }
51
+ export type CaptchaVerifyResult = CaptchaPassed | CaptchaRejected | CaptchaUnavailable;
52
+ /** The verifier port. Must settle (never hang) and must not throw: errors are `unavailable`. */
53
+ export interface CaptchaVerifier {
54
+ verify(request: CaptchaVerifyRequest, signal?: CancellationSignal): Promise<CaptchaVerifyResult>;
55
+ }
56
+ /** True for the provider-outage outcome. */
57
+ export declare function isCaptchaUnavailable(result: CaptchaVerifyResult): result is CaptchaUnavailable;
58
+ //# sourceMappingURL=captcha.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"captcha.d.ts","sourceRoot":"","sources":["../../src/authentication/captcha.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,mFAAmF;AACnF,eAAO,MAAM,iBAAiB,wDAInB,CAAC;AACZ,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjE,6DAA6D;AAC7D,eAAO,MAAM,uBAAuB,0EAOzB,CAAC;AACZ,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5E,wFAAwF;AACxF,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,kFAAkF;IAClF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,oEAAoE;AACpE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,oEAAoE;IACpE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,yBAAyB;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,6BAA6B;AAC7B,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;CACvC;AAED,oFAAoF;AACpF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;CAChC;AAED,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG,eAAe,GAAG,kBAAkB,CAAC;AAEvF,gGAAgG;AAChG,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,OAAO,EAAE,oBAAoB,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAClG;AAED,4CAA4C;AAC5C,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,IAAI,kBAAkB,CAE9F"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * CAPTCHA verification port (auth capabilities R7.1, R7.4, R7.5; G-017).
3
+ *
4
+ * Core names the contract only; the Turnstile and reCAPTCHA adapters live in `@astram/guard`
5
+ * (D-4: `fetch`, no new dependency). A verifier checks one client token with the provider and
6
+ * answers one of three outcomes:
7
+ * - passed: the provider accepted the token AND its hostname is expected, its action matches the
8
+ * endpoint and (reCAPTCHA v3) its score reaches the minimum;
9
+ * - rejected (`reason`): the token is missing, invalid, from another hostname, for another action,
10
+ * below the score, or already used (`timeout-or-duplicate`);
11
+ * - unavailable: the provider could not answer (network error, timeout, 5xx, unreadable body).
12
+ * This is NOT a rejection: the caller applies its fail mode (closed by default, R7.5).
13
+ *
14
+ * A verifier never logs or returns the secret or the token.
15
+ *
16
+ * ADR-0003: framework-agnostic, no I/O here.
17
+ */
18
+ /** The CAPTCHA providers the framework ships adapters for (`CAPTCHA_PROVIDER`). */
19
+ export const CAPTCHA_PROVIDERS = Object.freeze([
20
+ 'turnstile',
21
+ 'recaptcha-v3',
22
+ 'recaptcha-v2',
23
+ ]);
24
+ /** Why a token was rejected. Never carries provider text. */
25
+ export const CAPTCHA_FAILURE_REASONS = Object.freeze([
26
+ 'invalid',
27
+ 'hostname',
28
+ 'action',
29
+ 'score',
30
+ 'reused',
31
+ 'missing',
32
+ ]);
33
+ /** True for the provider-outage outcome. */
34
+ export function isCaptchaUnavailable(result) {
35
+ return result.ok === false && result.reason === 'unavailable';
36
+ }
37
+ //# sourceMappingURL=captcha.js.map