evlog 2.13.0 → 2.14.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 (89) hide show
  1. package/README.md +73 -0
  2. package/dist/adapters/axiom.d.mts +1 -1
  3. package/dist/adapters/better-stack.d.mts +1 -1
  4. package/dist/adapters/datadog.d.mts +1 -1
  5. package/dist/adapters/fs.d.mts +1 -1
  6. package/dist/adapters/hyperdx.d.mts +1 -1
  7. package/dist/adapters/otlp.d.mts +1 -1
  8. package/dist/adapters/posthog.d.mts +1 -1
  9. package/dist/adapters/sentry.d.mts +1 -1
  10. package/dist/ai/index.d.mts +106 -5
  11. package/dist/ai/index.d.mts.map +1 -1
  12. package/dist/ai/index.mjs +28 -5
  13. package/dist/ai/index.mjs.map +1 -1
  14. package/dist/{logger-DnobymUQ.mjs → audit-d9esRZOK.mjs} +703 -4
  15. package/dist/audit-d9esRZOK.mjs.map +1 -0
  16. package/dist/{types-DbzDln7O.d.mts → audit-mUutdf6A.d.mts} +499 -3
  17. package/dist/audit-mUutdf6A.d.mts.map +1 -0
  18. package/dist/better-auth/index.d.mts +1 -1
  19. package/dist/browser.d.mts +1 -1
  20. package/dist/elysia/index.d.mts +2 -2
  21. package/dist/elysia/index.mjs +2 -2
  22. package/dist/enrichers.d.mts +1 -1
  23. package/dist/{error-B9CiGK_i.d.mts → error-D1FZI2Kd.d.mts} +2 -2
  24. package/dist/{error-B9CiGK_i.d.mts.map → error-D1FZI2Kd.d.mts.map} +1 -1
  25. package/dist/error.d.mts +1 -1
  26. package/dist/{errors-Dr0r4OpR.d.mts → errors-NIXCyk6I.d.mts} +2 -2
  27. package/dist/{errors-Dr0r4OpR.d.mts.map → errors-NIXCyk6I.d.mts.map} +1 -1
  28. package/dist/express/index.d.mts +2 -2
  29. package/dist/express/index.mjs +2 -2
  30. package/dist/fastify/index.d.mts +2 -2
  31. package/dist/fastify/index.mjs +2 -2
  32. package/dist/{fork-Y4z8iHti.mjs → fork-CTJXnpl8.mjs} +3 -3
  33. package/dist/{fork-Y4z8iHti.mjs.map → fork-CTJXnpl8.mjs.map} +1 -1
  34. package/dist/hono/index.d.mts +2 -2
  35. package/dist/hono/index.mjs +1 -1
  36. package/dist/http.d.mts +1 -1
  37. package/dist/index.d.mts +7 -7
  38. package/dist/index.mjs +2 -2
  39. package/dist/{logger-Dp6nYWjH.d.mts → logger-b3epPH0N.d.mts} +4 -4
  40. package/dist/logger-b3epPH0N.d.mts.map +1 -0
  41. package/dist/logger.d.mts +1 -1
  42. package/dist/logger.mjs +1 -1
  43. package/dist/{middleware-BtBuosFV.mjs → middleware-BWOJ7JI0.mjs} +2 -2
  44. package/dist/{middleware-BtBuosFV.mjs.map → middleware-BWOJ7JI0.mjs.map} +1 -1
  45. package/dist/{middleware-FgC1OdOD.d.mts → middleware-BYf26Lfu.d.mts} +2 -2
  46. package/dist/{middleware-FgC1OdOD.d.mts.map → middleware-BYf26Lfu.d.mts.map} +1 -1
  47. package/dist/nestjs/index.d.mts +2 -2
  48. package/dist/nestjs/index.mjs +2 -2
  49. package/dist/next/client.d.mts +1 -1
  50. package/dist/next/index.d.mts +4 -4
  51. package/dist/next/index.mjs +2 -2
  52. package/dist/next/instrumentation.d.mts +1 -1
  53. package/dist/next/instrumentation.mjs +1 -1
  54. package/dist/nitro/module.d.mts +2 -2
  55. package/dist/nitro/plugin.mjs +1 -1
  56. package/dist/nitro/v3/index.d.mts +2 -2
  57. package/dist/nitro/v3/module.d.mts +1 -1
  58. package/dist/nitro/v3/plugin.mjs +1 -1
  59. package/dist/nitro/v3/useLogger.d.mts +1 -1
  60. package/dist/{nitro-CDHLfRdw.d.mts → nitro-DenB86W6.d.mts} +2 -2
  61. package/dist/{nitro-CDHLfRdw.d.mts.map → nitro-DenB86W6.d.mts.map} +1 -1
  62. package/dist/nuxt/module.d.mts +1 -1
  63. package/dist/nuxt/module.mjs +1 -1
  64. package/dist/{parseError-DM-lyezZ.d.mts → parseError-BR9pocvY.d.mts} +2 -2
  65. package/dist/parseError-BR9pocvY.d.mts.map +1 -0
  66. package/dist/react-router/index.d.mts +2 -2
  67. package/dist/react-router/index.mjs +2 -2
  68. package/dist/runtime/client/log.d.mts +1 -1
  69. package/dist/runtime/server/routes/_evlog/ingest.post.mjs +1 -1
  70. package/dist/runtime/server/useLogger.d.mts +1 -1
  71. package/dist/runtime/utils/parseError.d.mts +2 -2
  72. package/dist/sveltekit/index.d.mts +2 -2
  73. package/dist/sveltekit/index.mjs +2 -2
  74. package/dist/toolkit.d.mts +3 -3
  75. package/dist/toolkit.mjs +2 -2
  76. package/dist/types.d.mts +2 -2
  77. package/dist/{useLogger-N5A-d5l9.d.mts → useLogger-C56tDPwf.d.mts} +2 -2
  78. package/dist/{useLogger-N5A-d5l9.d.mts.map → useLogger-C56tDPwf.d.mts.map} +1 -1
  79. package/dist/{utils-DnX6VMNi.d.mts → utils-DzGCLRFe.d.mts} +2 -2
  80. package/dist/{utils-DnX6VMNi.d.mts.map → utils-DzGCLRFe.d.mts.map} +1 -1
  81. package/dist/utils.d.mts +1 -1
  82. package/dist/vite/index.d.mts +1 -1
  83. package/dist/workers.d.mts +1 -1
  84. package/dist/workers.mjs +1 -1
  85. package/package.json +1 -1
  86. package/dist/logger-DnobymUQ.mjs.map +0 -1
  87. package/dist/logger-Dp6nYWjH.d.mts.map +0 -1
  88. package/dist/parseError-DM-lyezZ.d.mts.map +0 -1
  89. package/dist/types-DbzDln7O.d.mts.map +0 -1
@@ -363,7 +363,97 @@ interface LoggerConfig {
363
363
  _suppressDrainWarning?: boolean;
364
364
  }
365
365
  /**
366
- * Base structure for all wide events
366
+ * Audit actor who initiated the action.
367
+ *
368
+ * `type` covers the most common actor families. `id` is required and should be
369
+ * a stable identifier (user id, service name, API key id, agent id). `model`,
370
+ * `tools`, `reason`, and `promptId` are filled when `type === 'agent'` and
371
+ * mirror the AI SDK fields already used by `evlog/ai`.
372
+ */
373
+ interface AuditActor {
374
+ type: 'user' | 'system' | 'api' | 'agent';
375
+ id: string;
376
+ displayName?: string;
377
+ email?: string;
378
+ model?: string;
379
+ tools?: string[];
380
+ reason?: string;
381
+ promptId?: string;
382
+ }
383
+ /**
384
+ * Audit target — the resource the action was performed on.
385
+ *
386
+ * `type` is a free-form string (e.g. `'invoice'`, `'user'`, `'subscription'`)
387
+ * narrowed by {@link defineAuditAction}. Additional fields are allowed for
388
+ * resource-specific metadata (e.g. `tenantId`, `path`, `previousOwnerId`).
389
+ */
390
+ interface AuditTarget {
391
+ type: string;
392
+ id: string;
393
+ [key: string]: unknown;
394
+ }
395
+ /**
396
+ * Reserved audit fields on the wide event.
397
+ *
398
+ * Set via `log.audit({ ... })`, `log.set({ audit: { ... } })`, or the
399
+ * standalone `audit({ ... })` helper. Downstream filters on `audit IS NOT NULL`.
400
+ *
401
+ * - `outcome` — `'success' | 'failure' | 'denied'`. `'denied'` records an
402
+ * AuthZ-denied action (often forgotten but exactly what auditors want).
403
+ * - `changes.before/after` — the diff for mutating actions. Use
404
+ * {@link auditDiff} to produce a redact-aware compact JSON Patch.
405
+ * - `causationId` / `correlationId` — chain related actions (admin action →
406
+ * system reactions). Set by callers, propagated by `auditEnricher` when
407
+ * available on the request.
408
+ * - `signature` / `prevHash` — populated by the {@link signed} drain wrapper.
409
+ * Never set by application code.
410
+ * - `idempotencyKey` — derived deterministically by `log.audit()` so retries
411
+ * across drains are safe.
412
+ * - `context` — request/runtime context auto-populated by {@link auditEnricher}
413
+ * (`requestId`, `traceId`, `ip`, `userAgent`, `tenantId`).
414
+ */
415
+ interface AuditFields {
416
+ /** Action name. Convention: `'<resource>.<verb>'`, e.g. `'invoice.refund'`. */
417
+ action: string;
418
+ actor: AuditActor;
419
+ target?: AuditTarget;
420
+ outcome: 'success' | 'failure' | 'denied';
421
+ /** Human-readable explanation, especially required for `outcome: 'denied'`. */
422
+ reason?: string;
423
+ /** Before/after snapshots for mutating actions. */
424
+ changes?: {
425
+ before?: unknown;
426
+ after?: unknown;
427
+ };
428
+ /** ID of the action that caused this one. */
429
+ causationId?: string;
430
+ /** ID shared by every action in the same logical operation. */
431
+ correlationId?: string;
432
+ /** Schema version of the audit envelope. Defaults to `1` when omitted by the caller. */
433
+ version?: number;
434
+ /** Set by `log.audit()` as a stable hash for safe retries across drains. */
435
+ idempotencyKey?: string;
436
+ /** Request/runtime context — populated by `auditEnricher`. */
437
+ context?: {
438
+ requestId?: string;
439
+ traceId?: string;
440
+ ip?: string;
441
+ userAgent?: string;
442
+ tenantId?: string;
443
+ [key: string]: unknown;
444
+ };
445
+ /** HMAC signature of the event when wrapped with `signed({ strategy: 'hmac' })`. */
446
+ signature?: string;
447
+ /** Previous event hash when wrapped with `signed({ strategy: 'hash-chain' })`. */
448
+ prevHash?: string;
449
+ /** Hash of the current event when wrapped with `signed({ strategy: 'hash-chain' })`. */
450
+ hash?: string;
451
+ }
452
+ /**
453
+ * Base structure for all wide events.
454
+ *
455
+ * Augment via `declare module 'evlog'` to add app-specific top-level fields.
456
+ * `audit` is reserved for {@link AuditFields}.
367
457
  */
368
458
  interface BaseWideEvent {
369
459
  timestamp: string;
@@ -373,6 +463,7 @@ interface BaseWideEvent {
373
463
  version?: string;
374
464
  commitHash?: string;
375
465
  region?: string;
466
+ audit?: AuditFields;
376
467
  }
377
468
  /**
378
469
  * Wide event with arbitrary additional fields
@@ -508,6 +599,34 @@ interface RequestLogger<T extends object = Record<string, unknown>> {
508
599
  * ```
509
600
  */
510
601
  fork?: (label: string, fn: () => void | Promise<void>) => void;
602
+ /**
603
+ * Record an audit event on this wide event. Strictly equivalent to
604
+ * `log.set({ audit: { ... } })` plus tail-sample force-keep.
605
+ *
606
+ * Use `log.audit.deny(reason, fields)` for AuthZ-denied actions — most teams
607
+ * forget to log denials but they are exactly what auditors and security teams
608
+ * ask for.
609
+ *
610
+ * Available on every logger returned by `createLogger()` / `createRequestLogger()`
611
+ * and on framework loggers exposed via `useLogger()` / `c.get('log')` etc.
612
+ *
613
+ * @example
614
+ * ```ts
615
+ * log.audit({
616
+ * action: 'invoice.refund',
617
+ * actor: { type: 'user', id: user.id, email: user.email },
618
+ * target: { type: 'invoice', id: 'inv_889' },
619
+ * outcome: 'success',
620
+ * reason: 'Customer requested refund',
621
+ * })
622
+ * ```
623
+ */
624
+ audit?: AuditLoggerMethod;
625
+ }
626
+ /** @internal Forward-declaration to avoid a circular import with `audit.ts`. */
627
+ interface AuditLoggerMethod {
628
+ (input: AuditInput): void;
629
+ deny: (reason: string, input: Omit<AuditInput, 'outcome' | 'reason'>) => void;
511
630
  }
512
631
  /**
513
632
  * Log level type
@@ -630,5 +749,382 @@ interface ParsedError {
630
749
  raw: unknown;
631
750
  }
632
751
  //#endregion
633
- export { TailSamplingCondition as C, WideEvent as E, ServerEvent as S, TransportConfig as T, RequestLogger as _, EnvironmentContext as a, SamplingConfig as b, H3EventContext as c, Log as d, LogLevel as f, RequestLogEntry as g, RedactConfig as h, EnrichContext as i, IngestPayload as l, ParsedError as m, DeepPartial as n, ErrorOptions as o, LoggerConfig as p, DrainContext as r, FieldContext as s, BaseWideEvent as t, InternalFields as u, RequestLoggerOptions as v, TailSamplingContext as w, SamplingRates as x, RouteConfig as y };
634
- //# sourceMappingURL=types-DbzDln7O.d.mts.map
752
+ //#region src/audit.d.ts
753
+ /**
754
+ * Current version of the audit envelope. Bumped when `AuditFields` evolves
755
+ * in a backward-incompatible way so downstream pipelines can branch on it.
756
+ */
757
+ declare const AUDIT_SCHEMA_VERSION = 1;
758
+ /**
759
+ * Input accepted by `log.audit()`, `audit()`, and `withAudit()`.
760
+ *
761
+ * `outcome` defaults to `'success'`. Internal fields populated by the audit
762
+ * pipeline (`idempotencyKey`, `context`, `signature`, `prevHash`, `hash`) are
763
+ * stripped — pass them through `log.set({ audit })` if you really need to.
764
+ */
765
+ interface AuditInput {
766
+ action: string;
767
+ actor: AuditActor;
768
+ target?: AuditTarget;
769
+ outcome?: AuditFields['outcome'];
770
+ reason?: string;
771
+ changes?: AuditFields['changes'];
772
+ causationId?: string;
773
+ correlationId?: string;
774
+ version?: number;
775
+ }
776
+ /**
777
+ * Build a normalised {@link AuditFields} from caller input. Defaults:
778
+ * - `outcome` → `'success'`
779
+ * - `version` → {@link AUDIT_SCHEMA_VERSION}
780
+ *
781
+ * `idempotencyKey` is filled at emit time with the event timestamp so retries
782
+ * stay deterministic.
783
+ */
784
+ declare function buildAuditFields(input: AuditInput): AuditFields;
785
+ /**
786
+ * Add audit semantics to an existing {@link RequestLogger}.
787
+ *
788
+ * Mutates the logger in place by adding an `audit` method (with a `.deny()`
789
+ * sub-method). Strictly equivalent to calling `log.set({ audit: ... })` plus
790
+ * `_forceKeep` on emit. Idempotent: calling twice on the same logger only
791
+ * attaches the methods once.
792
+ *
793
+ * @example
794
+ * ```ts
795
+ * const log = withAuditMethods(createLogger())
796
+ * log.audit({
797
+ * action: 'invoice.refund',
798
+ * actor: { type: 'user', id: user.id },
799
+ * target: { type: 'invoice', id: 'inv_889' },
800
+ * })
801
+ * ```
802
+ */
803
+ declare function withAuditMethods<T extends object = Record<string, unknown>>(logger: RequestLogger<T>): AuditableLogger<T>;
804
+ /**
805
+ * Logger augmented with `.audit()` / `.audit.deny()` helpers.
806
+ */
807
+ type AuditableLogger<T extends object = Record<string, unknown>> = RequestLogger<T> & {
808
+ audit: AuditMethod<T>;
809
+ };
810
+ /** Method shape attached to {@link AuditableLogger}. */
811
+ interface AuditMethod<T extends object = Record<string, unknown>> {
812
+ (input: AuditInput): void;
813
+ /**
814
+ * Record an AuthZ-denied action. Forces `outcome: 'denied'` and requires
815
+ * a human-readable `reason`. Most teams forget to log denials — they are
816
+ * exactly what auditors and security teams ask for.
817
+ */
818
+ deny: (reason: string, input: Omit<AuditInput, 'outcome' | 'reason'>) => void;
819
+ }
820
+ /**
821
+ * Standalone audit emitter for non-request contexts (jobs, scripts, CLIs).
822
+ *
823
+ * Creates a one-shot logger, sets the audit fields, and emits immediately.
824
+ * The event is force-kept past tail sampling. Returns the emitted wide event,
825
+ * or `null` if logging is globally disabled.
826
+ *
827
+ * @example
828
+ * ```ts
829
+ * import { audit } from 'evlog'
830
+ *
831
+ * audit({
832
+ * action: 'cron.cleanup',
833
+ * actor: { type: 'system', id: 'cron' },
834
+ * target: { type: 'job', id: 'cleanup-stale-sessions' },
835
+ * outcome: 'success',
836
+ * })
837
+ * ```
838
+ */
839
+ declare function audit(input: AuditInput): WideEvent | null;
840
+ /**
841
+ * Wrap a function so its outcome (success / failure / denied) is automatically
842
+ * audited.
843
+ *
844
+ * Behaviour:
845
+ * - If `fn` resolves, an audit event with `outcome: 'success'` is emitted.
846
+ * - If `fn` throws an `EvlogError` (or any error) with `status === 403`, the
847
+ * audit event is recorded as `'denied'` with the error message as `reason`.
848
+ * - Any other thrown error produces `outcome: 'failure'` and re-throws.
849
+ *
850
+ * Use {@link AuditDeniedError} to signal denial without an HTTP status.
851
+ *
852
+ * @example
853
+ * ```ts
854
+ * const refundInvoice = withAudit(
855
+ * { action: 'invoice.refund', target: (input) => ({ type: 'invoice', id: input.id }) },
856
+ * async (input: { id: string }, ctx: { actor: AuditActor }) => {
857
+ * await db.invoices.refund(input.id)
858
+ * }
859
+ * )
860
+ *
861
+ * await refundInvoice({ id: 'inv_889' }, { actor: { type: 'user', id: user.id } })
862
+ * ```
863
+ */
864
+ declare function withAudit<TInput, TOutput>(options: WithAuditOptions<TInput>, fn: (input: TInput, ctx: WithAuditContext) => Promise<TOutput> | TOutput): (input: TInput, ctx: WithAuditContext) => Promise<TOutput>;
865
+ /**
866
+ * Throw inside a {@link withAudit} body to mark the action as `outcome: 'denied'`
867
+ * regardless of the underlying HTTP status. The constructor message becomes the
868
+ * audit `reason`.
869
+ */
870
+ declare class AuditDeniedError extends Error {
871
+ constructor(reason: string);
872
+ }
873
+ /** Options for {@link withAudit}. `target` may be derived from the input. */
874
+ interface WithAuditOptions<TInput> {
875
+ action: string;
876
+ target?: AuditTarget | ((input: TInput) => AuditTarget | undefined);
877
+ }
878
+ /**
879
+ * Runtime context required by a {@link withAudit}-wrapped function.
880
+ * The actor is always required; correlation IDs are optional.
881
+ */
882
+ interface WithAuditContext {
883
+ actor: AuditActor;
884
+ causationId?: string;
885
+ correlationId?: string;
886
+ }
887
+ /**
888
+ * Compute a compact, redact-aware diff between two objects for the
889
+ * `changes` field. Output is a JSON Patch-style array (RFC 6902 subset:
890
+ * `add`, `remove`, `replace`) — small enough to ship over the wire.
891
+ *
892
+ * Object keys whose name matches one of the `redactPaths` (dot-notation, e.g.
893
+ * `'user.password'`, `'card.cvv'`) are replaced with `'[REDACTED]'` so PII
894
+ * never leaks through the diff.
895
+ *
896
+ * @example
897
+ * ```ts
898
+ * log.audit({
899
+ * action: 'user.update',
900
+ * actor: { type: 'user', id: user.id },
901
+ * target: { type: 'user', id: 'usr_42' },
902
+ * changes: auditDiff(before, after, { redactPaths: ['password'] }),
903
+ * })
904
+ * ```
905
+ */
906
+ declare function auditDiff(before: unknown, after: unknown, options?: AuditDiffOptions): {
907
+ before?: unknown;
908
+ after?: unknown;
909
+ patch: AuditPatchOp[];
910
+ };
911
+ /** Single JSON Patch operation produced by {@link auditDiff}. */
912
+ interface AuditPatchOp {
913
+ op: 'add' | 'remove' | 'replace';
914
+ path: string;
915
+ value?: unknown;
916
+ }
917
+ /** Options for {@link auditDiff}. */
918
+ interface AuditDiffOptions {
919
+ /** Object keys (dot-notation) whose values should be replaced with `[REDACTED]`. */
920
+ redactPaths?: string[];
921
+ /** Custom replacement string. @default '[REDACTED]' */
922
+ replacement?: string;
923
+ /** Include the full redacted `before` snapshot alongside the patch. */
924
+ includeBefore?: boolean;
925
+ /** Include the full redacted `after` snapshot alongside the patch. */
926
+ includeAfter?: boolean;
927
+ }
928
+ /**
929
+ * Define a typed audit action with an optional fixed target type.
930
+ *
931
+ * Returns a curried helper that fills in the action name (and target shape
932
+ * if provided) so call sites stay terse and the action set is discoverable
933
+ * in one place.
934
+ *
935
+ * @example
936
+ * ```ts
937
+ * const refund = defineAuditAction('invoice.refund', { target: 'invoice' })
938
+ *
939
+ * log.audit(refund({
940
+ * actor: { type: 'user', id: user.id },
941
+ * target: { id: 'inv_889' }, // type inferred as 'invoice'
942
+ * outcome: 'success',
943
+ * }))
944
+ * ```
945
+ */
946
+ declare function defineAuditAction<TTargetType extends string | undefined = undefined>(action: string, options?: {
947
+ target?: TTargetType;
948
+ }): DefinedAuditAction<TTargetType>;
949
+ /**
950
+ * Return type of {@link defineAuditAction}. Accepts a partial input (no
951
+ * `action`, target type pre-filled when provided).
952
+ */
953
+ type DefinedAuditAction<TTargetType extends string | undefined> = (input: TTargetType extends string ? Omit<AuditInput, 'action' | 'target'> & {
954
+ target?: Omit<AuditTarget, 'type'> & {
955
+ type?: TTargetType;
956
+ };
957
+ } : Omit<AuditInput, 'action'>) => AuditInput;
958
+ /**
959
+ * Test helper that captures every audit event emitted while it is active.
960
+ *
961
+ * Returns `{ events, restore, expect }`:
962
+ * - `events` — live array of captured `AuditFields`, populated as audits fire.
963
+ * - `restore()` — uninstall the collector. Call from `afterEach()`.
964
+ * - `expect.toIncludeAuditOf(matcher)` — assertion helper used inside `expect`
965
+ * blocks, returns `true` if at least one captured event matches.
966
+ *
967
+ * Only captures audits going through `log.audit()` and the standalone
968
+ * `audit()` function. Events emitted via raw `log.set({ audit })` skip the
969
+ * collector by design — wrap them with `log.audit()` to make them visible to
970
+ * tests.
971
+ *
972
+ * @example
973
+ * ```ts
974
+ * const captured = mockAudit()
975
+ * await refundInvoice('inv_889')
976
+ * expect(captured.events).toHaveLength(1)
977
+ * expect(captured.toIncludeAuditOf({ action: 'invoice.refund' })).toBe(true)
978
+ * captured.restore()
979
+ * ```
980
+ */
981
+ declare function mockAudit(): MockAudit;
982
+ /** Result of {@link mockAudit}. */
983
+ interface MockAudit {
984
+ events: AuditFields[];
985
+ restore: () => void;
986
+ toIncludeAuditOf: (matcher: AuditMatcher) => boolean;
987
+ }
988
+ /** Partial structural matcher for {@link MockAudit.toIncludeAuditOf}. */
989
+ interface AuditMatcher {
990
+ action?: string | RegExp;
991
+ outcome?: AuditFields['outcome'];
992
+ actor?: Partial<AuditActor>;
993
+ target?: Partial<AuditTarget>;
994
+ }
995
+ /** Shape of the optional better-auth bridge for the audit enricher. */
996
+ interface AuditEnricherBetterAuthBridge {
997
+ /** Read the current authenticated session for this request, if any. */
998
+ getSession: (ctx: EnrichContext) => Promise<AuditActor | null | undefined> | AuditActor | null | undefined;
999
+ }
1000
+ /** Options for {@link auditEnricher}. */
1001
+ interface AuditEnricherOptions {
1002
+ /**
1003
+ * Resolve the tenant id for the current request. The result is stored at
1004
+ * `event.audit.context.tenantId`. Multi-tenant SaaS gets isolation by default.
1005
+ */
1006
+ tenantId?: (ctx: EnrichContext) => string | undefined;
1007
+ /**
1008
+ * Bridge to populate `event.audit.actor` from the authenticated session.
1009
+ * Only used when the application has not already filled `actor`.
1010
+ */
1011
+ bridge?: AuditEnricherBetterAuthBridge;
1012
+ /** When true, overwrite existing context fields. @default false */
1013
+ overwrite?: boolean;
1014
+ }
1015
+ /**
1016
+ * Enrich audit-bearing wide events with request, runtime, and tenant context.
1017
+ *
1018
+ * Runs only when `event.audit` is present — every other event passes through
1019
+ * untouched. Populates:
1020
+ * - `event.audit.context.requestId` from `ctx.request.requestId`
1021
+ * - `event.audit.context.traceId` from `event.traceId`
1022
+ * - `event.audit.context.ip` from `x-forwarded-for` / `x-real-ip`
1023
+ * - `event.audit.context.userAgent` from `user-agent`
1024
+ * - `event.audit.context.tenantId` from `options.tenantId(ctx)`
1025
+ *
1026
+ * Optionally fills `event.audit.actor` from the better-auth bridge when the
1027
+ * caller did not provide one. Anything else (custom actor strategies,
1028
+ * extra context) belongs in a custom enricher — replace this one entirely.
1029
+ */
1030
+ declare function auditEnricher(options?: AuditEnricherOptions): (ctx: EnrichContext) => void | Promise<void>;
1031
+ /** Options accepted by {@link auditOnly}. */
1032
+ interface AuditOnlyOptions {
1033
+ /**
1034
+ * When true, the wrapper awaits the wrapped drain so the event is flushed
1035
+ * before the request resolves. Use for crash-safe audit storage.
1036
+ * @default false
1037
+ */
1038
+ await?: boolean;
1039
+ }
1040
+ /** Drain function signature accepted by all wrappers. Matches `LoggerConfig['drain']`. */
1041
+ type DrainFn = (ctx: DrainContext) => void | Promise<void>;
1042
+ /**
1043
+ * Wrap any drain so it only receives events that carry an `audit` field.
1044
+ *
1045
+ * Use to route audit events to dedicated storage (separate Axiom dataset,
1046
+ * append-only Postgres table, FS journal) without affecting your main drain.
1047
+ *
1048
+ * Per-sink failure isolation comes from `initLogger({ drain: [...] })`: each
1049
+ * drain in the array is invoked independently, so a crashed Axiom call never
1050
+ * blocks the FS audit drain.
1051
+ *
1052
+ * @example
1053
+ * ```ts
1054
+ * import { initLogger, auditOnly } from 'evlog'
1055
+ * import { createAxiomDrain } from 'evlog/axiom'
1056
+ * import { createFsDrain } from 'evlog/fs'
1057
+ *
1058
+ * initLogger({
1059
+ * drain: [
1060
+ * createAxiomDrain({ dataset: 'logs' }),
1061
+ * auditOnly(createFsDrain({ dir: '.audit' }), { await: true }),
1062
+ * ],
1063
+ * })
1064
+ * ```
1065
+ */
1066
+ declare function auditOnly(drain: DrainFn, options?: AuditOnlyOptions): DrainFn;
1067
+ /** Pluggable persistence for the hash-chain state. */
1068
+ interface SignedChainState {
1069
+ /** Load the previous hash from durable storage, or `null` on first run. */
1070
+ load: () => Promise<string | null> | string | null;
1071
+ /** Persist the latest hash so the chain survives process restarts. */
1072
+ save: (hash: string) => Promise<void> | void;
1073
+ }
1074
+ /** Options for {@link signed}. Pick a strategy at construction time. */
1075
+ type SignedOptions = {
1076
+ strategy: 'hmac';
1077
+ secret: string;
1078
+ algorithm?: 'sha256' | 'sha512';
1079
+ } | {
1080
+ strategy: 'hash-chain';
1081
+ state?: SignedChainState;
1082
+ algorithm?: 'sha256' | 'sha512';
1083
+ };
1084
+ /**
1085
+ * Wrap a drain so every event passing through gains tamper-evident integrity.
1086
+ *
1087
+ * - `'hmac'` — adds `event.audit.signature` (HMAC of the canonical event).
1088
+ * - `'hash-chain'` — adds `event.audit.prevHash` and `event.audit.hash` so the
1089
+ * sequence of events forms a verifiable chain. State persists in memory
1090
+ * by default; pass a `state: { load, save }` for cross-process / durable
1091
+ * chains (Redis, file, Postgres).
1092
+ *
1093
+ * The signature is computed before the event is forwarded to the wrapped
1094
+ * drain — combine with {@link auditOnly} when you only want integrity for
1095
+ * audit events.
1096
+ *
1097
+ * @example
1098
+ * ```ts
1099
+ * import { initLogger, auditOnly, signed } from 'evlog'
1100
+ * import { createFsDrain } from 'evlog/fs'
1101
+ *
1102
+ * initLogger({
1103
+ * drain: auditOnly(
1104
+ * signed(createFsDrain({ dir: '.audit' }), { strategy: 'hash-chain' }),
1105
+ * { await: true },
1106
+ * ),
1107
+ * })
1108
+ * ```
1109
+ */
1110
+ declare function signed(drain: DrainFn, options: SignedOptions): DrainFn;
1111
+ /**
1112
+ * Strict redact preset for audit events.
1113
+ *
1114
+ * Combine with the user's existing redact configuration via spread:
1115
+ * `initLogger({ redact: { paths: [...auditRedactPreset.paths!, ...mine] } })`.
1116
+ *
1117
+ * Hardens PII handling:
1118
+ * - Drops `Authorization` and `Cookie` headers anywhere they appear.
1119
+ * - Drops common credential field names (`password`, `passwordHash`, `token`,
1120
+ * `apiKey`, `secret`, `accessToken`, `refreshToken`, `cardNumber`, `cvv`,
1121
+ * `ssn`).
1122
+ *
1123
+ * Built-in pattern maskers (email, credit card, …) keep their default
1124
+ * behaviour — partial masking, not full redaction — so audit trails retain
1125
+ * enough signal to be useful.
1126
+ */
1127
+ declare const auditRedactPreset: RedactConfig;
1128
+ //#endregion
1129
+ export { SamplingRates as $, AuditFields as A, H3EventContext as B, buildAuditFields as C, withAudit as D, signed as E, DrainContext as F, LoggerConfig as G, InternalFields as H, EnrichContext as I, RequestLogEntry as J, ParsedError as K, EnvironmentContext as L, AuditTarget as M, BaseWideEvent as N, withAuditMethods as O, DeepPartial as P, SamplingConfig as Q, ErrorOptions as R, auditRedactPreset as S, mockAudit as T, Log as U, IngestPayload as V, LogLevel as W, RequestLoggerOptions as X, RequestLogger as Y, RouteConfig as Z, WithAuditOptions as _, AuditInput as a, auditEnricher as b, AuditOnlyOptions as c, DefinedAuditAction as d, ServerEvent as et, DrainFn as f, WithAuditContext as g, SignedOptions as h, AuditEnricherOptions as i, WideEvent as it, AuditLoggerMethod as j, AuditActor as k, AuditPatchOp as l, SignedChainState as m, AuditDeniedError as n, TailSamplingContext as nt, AuditMatcher as o, MockAudit as p, RedactConfig as q, AuditDiffOptions as r, TransportConfig as rt, AuditMethod as s, AUDIT_SCHEMA_VERSION as t, TailSamplingCondition as tt, AuditableLogger as u, audit as v, defineAuditAction as w, auditOnly as x, auditDiff as y, FieldContext as z };
1130
+ //# sourceMappingURL=audit-mUutdf6A.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-mUutdf6A.d.mts","names":[],"sources":["../src/types.ts","../src/audit.ts"],"mappings":";;YAGY,iBAAA;IAqpBc;;;;;;;;;;;;;IAvoBtB,iBAAA,GAAoB,GAAA,EAAK,mBAAA,YAA+B,OAAA;IAAA;;;;;;;;;;;IAaxD,cAAA,GAAiB,GAAA,EAAK,aAAA,YAAyB,OAAA;IAkBK;;;;;;;;;;;;;;;;IAApD,aAAA,GAAgB,GAAA,EAAK,YAAA,YAAwB,OAAA;EAAA;AAAA;AAAA;EAAA,UAKrC,iBAAA;IACR,iBAAA,GAAoB,GAAA,EAAK,mBAAA,YAA+B,OAAA;IACxD,cAAA,GAAiB,GAAA,EAAK,aAAA,YAAyB,OAAA;IAC/C,aAAA,GAAgB,GAAA,EAAK,YAAA,YAAwB,OAAA;EAAA;AAAA;;AAOjD;;UAAiB,eAAA;EAiBiB;;;;EAZhC,OAAA;EAYgC;;AAMlC;;EAZE,QAAA;EAY4B;;;;EAN5B,WAAA,GAAc,kBAAA;AAAA;AAmBhB;;;AAAA,UAbiB,aAAA;EACf,SAAA;EACA,KAAA;EAAA,CACC,GAAA;AAAA;;;;;;;;UAUc,YAAA;EAqBJ;EAnBX,KAAA;EAmB2B;EA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AAA;AAAA;;KAIU,OAAA,IAAW,GAAA,EAAK,YAAA,YAAwB,OAAA;;;;;;;;;;;;;;;;;;;;ADvIpD;;;;;iBCiKgB,SAAA,CAAU,KAAA,EAAO,OAAA,EAAS,OAAA,GAAS,gBAAA,GAAwB,OAAA;;UAY1D,gBAAA;EDxKf;EC0KA,IAAA,QAAY,OAAA;EDxKI;EC0KhB,IAAA,GAAO,IAAA,aAAiB,OAAA;AAAA;;KAId,aAAA;EACN,QAAA;EAAkB,MAAA;EAAgB,SAAA;AAAA;EAClC,QAAA;EAAwB,KAAA,GAAQ,gBAAA;EAAkB,SAAA;AAAA;;;;;;;;;;;;;;;;;;;ADxHxD;;;;;;;;iBCoJgB,MAAA,CAAO,KAAA,EAAO,OAAA,EAAS,OAAA,EAAS,aAAA,GAAgB,OAAA;;;;;;;;;;;;;;;;;cAwHnD,iBAAA,EAAmB,YAAA"}
@@ -1,4 +1,4 @@
1
- import { _ as RequestLogger } from "../types-DbzDln7O.mjs";
1
+ import { Y as RequestLogger } from "../audit-mUutdf6A.mjs";
2
2
 
3
3
  //#region src/better-auth/index.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { r as DrainContext } from "./types-DbzDln7O.mjs";
1
+ import { F as DrainContext } from "./audit-mUutdf6A.mjs";
2
2
  import { PipelineDrainFn } from "./pipeline.mjs";
3
3
  import { HttpDrainConfig, HttpLogDrainOptions } from "./http.mjs";
4
4
 
@@ -1,5 +1,5 @@
1
- import { _ as RequestLogger } from "../types-DbzDln7O.mjs";
2
- import { t as BaseEvlogOptions } from "../middleware-FgC1OdOD.mjs";
1
+ import { Y as RequestLogger } from "../audit-mUutdf6A.mjs";
2
+ import { t as BaseEvlogOptions } from "../middleware-BYf26Lfu.mjs";
3
3
  import { Elysia } from "elysia";
4
4
 
5
5
  //#region src/elysia/index.d.ts
@@ -1,6 +1,6 @@
1
1
  import { filterSafeHeaders } from "../utils.mjs";
2
- import { t as createMiddlewareLogger } from "../middleware-BtBuosFV.mjs";
3
- import { t as attachForkToLogger } from "../fork-Y4z8iHti.mjs";
2
+ import { t as createMiddlewareLogger } from "../middleware-BWOJ7JI0.mjs";
3
+ import { t as attachForkToLogger } from "../fork-CTJXnpl8.mjs";
4
4
  import { AsyncLocalStorage } from "node:async_hooks";
5
5
  import { Elysia } from "elysia";
6
6
  //#region src/elysia/index.ts
@@ -1,4 +1,4 @@
1
- import { i as EnrichContext } from "./types-DbzDln7O.mjs";
1
+ import { I as EnrichContext } from "./audit-mUutdf6A.mjs";
2
2
 
3
3
  //#region src/enrichers/index.d.ts
4
4
  interface EnricherOptions {
@@ -1,4 +1,4 @@
1
- import { o as ErrorOptions } from "./types-DbzDln7O.mjs";
1
+ import { R as ErrorOptions } from "./audit-mUutdf6A.mjs";
2
2
 
3
3
  //#region src/error.d.ts
4
4
  /**
@@ -67,4 +67,4 @@ declare class EvlogError extends Error {
67
67
  declare function createError(options: ErrorOptions | string): EvlogError;
68
68
  //#endregion
69
69
  export { createError as n, EvlogError as t };
70
- //# sourceMappingURL=error-B9CiGK_i.d.mts.map
70
+ //# sourceMappingURL=error-D1FZI2Kd.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"error-B9CiGK_i.d.mts","names":[],"sources":["../src/error.ts"],"mappings":";;;;;AAqBA;;;;;;;;;;;;;cAAa,UAAA,SAAmB,KAAA;EAY1B;EAAA,SATK,MAAA;EAAA,SACA,GAAA;EAAA,SACA,GAAA;EAAA,SACA,IAAA;EAqCL;;;;EAAA,IA/BA,QAAA,CAAA,GAAY,MAAA;cAIJ,OAAA,EAAS,YAAA;EA0CqB;EAAA,IAftC,UAAA,CAAA;EAuDJ;EAAA,IAlDI,UAAA,CAAA;EAkDY;EAAA,IA7CZ,aAAA,CAAA;EAiFU;EAAA,IA5EV,IAAA,CAAA;IAAU,GAAA;IAAc,GAAA;IAAc,IAAA;EAAA;EAOjC,QAAA,CAAA;EAiCT,MAAA,CAAA,GAAU,MAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;iBAoCI,WAAA,CAAY,OAAA,EAAS,YAAA,YAAwB,UAAA"}
1
+ {"version":3,"file":"error-D1FZI2Kd.d.mts","names":[],"sources":["../src/error.ts"],"mappings":";;;;;AAqBA;;;;;;;;;;;;;cAAa,UAAA,SAAmB,KAAA;EAY1B;EAAA,SATK,MAAA;EAAA,SACA,GAAA;EAAA,SACA,GAAA;EAAA,SACA,IAAA;EAqCL;;;;EAAA,IA/BA,QAAA,CAAA,GAAY,MAAA;cAIJ,OAAA,EAAS,YAAA;EA0CqB;EAAA,IAftC,UAAA,CAAA;EAuDJ;EAAA,IAlDI,UAAA,CAAA;EAkDY;EAAA,IA7CZ,aAAA,CAAA;EAiFU;EAAA,IA5EV,IAAA,CAAA;IAAU,GAAA;IAAc,GAAA;IAAc,IAAA;EAAA;EAOjC,QAAA,CAAA;EAiCT,MAAA,CAAA,GAAU,MAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;iBAoCI,WAAA,CAAY,OAAA,EAAS,YAAA,YAAwB,UAAA"}
package/dist/error.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { n as createError, t as EvlogError } from "./error-B9CiGK_i.mjs";
1
+ import { n as createError, t as EvlogError } from "./error-D1FZI2Kd.mjs";
2
2
  export { EvlogError, createError, createError as createEvlogError };
@@ -1,4 +1,4 @@
1
- import { y as RouteConfig } from "./types-DbzDln7O.mjs";
1
+ import { Z as RouteConfig } from "./audit-mUutdf6A.mjs";
2
2
 
3
3
  //#region src/shared/routes.d.ts
4
4
  declare function shouldLog(path: string, include?: string[], exclude?: string[]): boolean;
@@ -36,4 +36,4 @@ declare function getServiceForPath(path: string, routes?: Record<string, RouteCo
36
36
  declare function extractErrorStatus(error: unknown): number;
37
37
  //#endregion
38
38
  export { getServiceForPath as n, shouldLog as r, extractErrorStatus as t };
39
- //# sourceMappingURL=errors-Dr0r4OpR.d.mts.map
39
+ //# sourceMappingURL=errors-NIXCyk6I.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors-Dr0r4OpR.d.mts","names":[],"sources":["../src/shared/routes.ts","../src/shared/errors.ts"],"mappings":";;;iBAGgB,SAAA,CAAU,IAAA,UAAc,OAAA,aAAoB,OAAA;;AAA5D;;;;;;;;;AAsCA;;;;;;;;;;;iBAAgB,iBAAA,CAAkB,IAAA,UAAc,MAAA,GAAS,MAAA,SAAe,WAAA;;;;;;AAtCxE;;;;iBCIgB,kBAAA,CAAmB,KAAA"}
1
+ {"version":3,"file":"errors-NIXCyk6I.d.mts","names":[],"sources":["../src/shared/routes.ts","../src/shared/errors.ts"],"mappings":";;;iBAGgB,SAAA,CAAU,IAAA,UAAc,OAAA,aAAoB,OAAA;;AAA5D;;;;;;;;;AAsCA;;;;;;;;;;;iBAAgB,iBAAA,CAAkB,IAAA,UAAc,MAAA,GAAS,MAAA,SAAe,WAAA;;;;;;AAtCxE;;;;iBCIgB,kBAAA,CAAmB,KAAA"}
@@ -1,5 +1,5 @@
1
- import { _ as RequestLogger } from "../types-DbzDln7O.mjs";
2
- import { t as BaseEvlogOptions } from "../middleware-FgC1OdOD.mjs";
1
+ import { Y as RequestLogger } from "../audit-mUutdf6A.mjs";
2
+ import { t as BaseEvlogOptions } from "../middleware-BYf26Lfu.mjs";
3
3
  import { RequestHandler } from "express";
4
4
 
5
5
  //#region src/express/index.d.ts
@@ -1,5 +1,5 @@
1
- import { t as createMiddlewareLogger } from "../middleware-BtBuosFV.mjs";
2
- import { t as attachForkToLogger } from "../fork-Y4z8iHti.mjs";
1
+ import { t as createMiddlewareLogger } from "../middleware-BWOJ7JI0.mjs";
2
+ import { t as attachForkToLogger } from "../fork-CTJXnpl8.mjs";
3
3
  import { n as extractSafeNodeHeaders } from "../headers-D74M0wsg.mjs";
4
4
  import { t as createLoggerStorage } from "../storage-CFGTn37X.mjs";
5
5
  //#region src/express/index.ts
@@ -1,5 +1,5 @@
1
- import { _ as RequestLogger } from "../types-DbzDln7O.mjs";
2
- import { t as BaseEvlogOptions } from "../middleware-FgC1OdOD.mjs";
1
+ import { Y as RequestLogger } from "../audit-mUutdf6A.mjs";
2
+ import { t as BaseEvlogOptions } from "../middleware-BYf26Lfu.mjs";
3
3
  import { FastifyPluginCallback } from "fastify";
4
4
 
5
5
  //#region src/fastify/index.d.ts
@@ -1,5 +1,5 @@
1
- import { t as createMiddlewareLogger } from "../middleware-BtBuosFV.mjs";
2
- import { t as attachForkToLogger } from "../fork-Y4z8iHti.mjs";
1
+ import { t as createMiddlewareLogger } from "../middleware-BWOJ7JI0.mjs";
2
+ import { t as attachForkToLogger } from "../fork-CTJXnpl8.mjs";
3
3
  import { n as extractSafeNodeHeaders } from "../headers-D74M0wsg.mjs";
4
4
  import { t as createLoggerStorage } from "../storage-CFGTn37X.mjs";
5
5
  //#region src/fastify/index.ts