@dyrected/core 2.5.60 → 2.5.62

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 (48) hide show
  1. package/dist/app-config-9hs8DRED.d.cts +1718 -0
  2. package/dist/app-config-9hs8DRED.d.ts +1718 -0
  3. package/dist/app-config-BcuZIpvL.d.cts +1951 -0
  4. package/dist/app-config-BcuZIpvL.d.ts +1951 -0
  5. package/dist/app-config-Bm9-2Am6.d.cts +1875 -0
  6. package/dist/app-config-Bm9-2Am6.d.ts +1875 -0
  7. package/dist/app-config-C0uxEU7Q.d.cts +1874 -0
  8. package/dist/app-config-C0uxEU7Q.d.ts +1874 -0
  9. package/dist/app-config-CBOn8IyZ.d.cts +1838 -0
  10. package/dist/app-config-CBOn8IyZ.d.ts +1838 -0
  11. package/dist/app-config-CJAGGPrk.d.cts +1900 -0
  12. package/dist/app-config-CJAGGPrk.d.ts +1900 -0
  13. package/dist/app-config-CiEDJm0e.d.cts +1912 -0
  14. package/dist/app-config-CiEDJm0e.d.ts +1912 -0
  15. package/dist/app-config-CwaU1de2.d.cts +1868 -0
  16. package/dist/app-config-CwaU1de2.d.ts +1868 -0
  17. package/dist/app-config-DCDh8Gbx.d.cts +1926 -0
  18. package/dist/app-config-DCDh8Gbx.d.ts +1926 -0
  19. package/dist/app-config-DVdSospO.d.cts +1842 -0
  20. package/dist/app-config-DVdSospO.d.ts +1842 -0
  21. package/dist/app-config-Dv5XACR4.d.cts +2065 -0
  22. package/dist/app-config-Dv5XACR4.d.ts +2065 -0
  23. package/dist/app-config-_kkj71CB.d.cts +2010 -0
  24. package/dist/app-config-_kkj71CB.d.ts +2010 -0
  25. package/dist/app-config-ouBRb6Bf.d.cts +1716 -0
  26. package/dist/app-config-ouBRb6Bf.d.ts +1716 -0
  27. package/dist/app-config-tITj_0sn.d.cts +1926 -0
  28. package/dist/app-config-tITj_0sn.d.ts +1926 -0
  29. package/dist/chunk-35NM2WPO.js +1658 -0
  30. package/dist/chunk-57FNM42D.js +2392 -0
  31. package/dist/chunk-BAMX7YUC.js +1815 -0
  32. package/dist/chunk-BQV3QW3Y.js +2588 -0
  33. package/dist/chunk-CUOPCOU2.js +1644 -0
  34. package/dist/chunk-EH3MJGB5.js +2571 -0
  35. package/dist/chunk-M3HKRN7E.js +1665 -0
  36. package/dist/chunk-MQZH7RQC.js +1667 -0
  37. package/dist/chunk-VCYYBN5J.js +1873 -0
  38. package/dist/chunk-WVD7PORQ.js +1672 -0
  39. package/dist/chunk-XZLIBQSO.js +2397 -0
  40. package/dist/index.cjs +404 -44
  41. package/dist/index.d.cts +77 -5
  42. package/dist/index.d.ts +77 -5
  43. package/dist/index.js +37 -4
  44. package/dist/server.cjs +2973 -708
  45. package/dist/server.d.cts +124 -12
  46. package/dist/server.d.ts +124 -12
  47. package/dist/server.js +2066 -695
  48. package/package.json +10 -1
package/dist/server.d.cts CHANGED
@@ -1,16 +1,115 @@
1
1
  import * as hono_types from 'hono/types';
2
2
  import * as hono from 'hono';
3
3
  import { Hono, Context } from 'hono';
4
- import { D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig } from './app-config-C0twGIaF.cjs';
5
- import * as hono_utils_http_status from 'hono/utils/http-status';
4
+ import { Logger } from 'pino';
5
+ import { D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig } from './app-config-Dv5XACR4.cjs';
6
+ import { JWTPayload } from 'jose';
7
+ import { Tracer, Counter, Attributes, Histogram, Span } from '@opentelemetry/api';
8
+ import { PrometheusExporter } from '@opentelemetry/exporter-prometheus';
6
9
  import * as hono_utils_types from 'hono/utils/types';
10
+ import * as hono_utils_http_status from 'hono/utils/http-status';
7
11
  import 'lucide-react';
8
12
 
13
+ interface CollectionTokenPayload extends JWTPayload {
14
+ sub: string;
15
+ email: string;
16
+ collection: string;
17
+ sid?: string;
18
+ purpose?: 'invite' | 'reset';
19
+ providerId?: string;
20
+ authSource?: 'local' | 'external';
21
+ }
22
+
23
+ interface ResolvedObservabilityConfig {
24
+ requestLogging: {
25
+ enabled: boolean;
26
+ logBodies: boolean;
27
+ maxBodyBytes: number;
28
+ redactPaths: string[];
29
+ includeHeaders: string[];
30
+ redactHeaders: string[];
31
+ };
32
+ sampling: {
33
+ successRate: number;
34
+ traceSuccessRate: number;
35
+ bodySuccessRate: number;
36
+ alwaysKeep4xx: boolean;
37
+ alwaysKeep5xx: boolean;
38
+ };
39
+ tracing: {
40
+ enabled: boolean;
41
+ serviceName: string;
42
+ exporter: "otlp" | "console" | "none";
43
+ headers: Record<string, string>;
44
+ endpoint?: string;
45
+ };
46
+ metrics: {
47
+ enabled: boolean;
48
+ exporter: "otlp" | "prometheus" | "none";
49
+ endpoint?: string;
50
+ path: string;
51
+ };
52
+ transports: {
53
+ targets: Array<{
54
+ type: "stdout";
55
+ } | {
56
+ type: "stderr";
57
+ } | {
58
+ type: "file";
59
+ path: string;
60
+ } | {
61
+ type: "otlp";
62
+ endpoint: string;
63
+ headers?: Record<string, string>;
64
+ }>;
65
+ };
66
+ }
67
+ interface RequestTraceContext {
68
+ span: Span;
69
+ traceId: string;
70
+ spanId: string;
71
+ sampled: boolean;
72
+ }
73
+ interface RequestBodyCapture {
74
+ attempted: boolean;
75
+ contentType?: string;
76
+ contentLength?: number;
77
+ truncated?: boolean;
78
+ parseFailed?: boolean;
79
+ body?: unknown;
80
+ }
81
+ interface MetricsRuntime {
82
+ requestCount: Counter<Attributes>;
83
+ authFailureCount: Counter<Attributes>;
84
+ uncaughtErrorCount: Counter<Attributes>;
85
+ auditWriteFailureCount: Counter<Attributes>;
86
+ emailSendFailureCount: Counter<Attributes>;
87
+ workflowHookFailureCount: Counter<Attributes>;
88
+ requestDuration: Histogram<Attributes>;
89
+ }
90
+ interface DyrectedObservabilityRuntime {
91
+ logger: Logger;
92
+ config: ResolvedObservabilityConfig;
93
+ tracer?: Tracer;
94
+ metrics?: MetricsRuntime;
95
+ prometheusExporter?: PrometheusExporter;
96
+ shutdown: () => Promise<void>;
97
+ recordAuthFailure: (attributes?: Attributes) => void;
98
+ recordUncaughtError: (attributes?: Attributes) => void;
99
+ recordAuditWriteFailure: (attributes?: Attributes) => void;
100
+ recordEmailSendFailure: (attributes?: Attributes) => void;
101
+ recordWorkflowHookFailure: (attributes?: Attributes) => void;
102
+ }
103
+
9
104
  interface DyrectedContext {
10
105
  Variables: {
11
106
  config: DyrectedConfig;
107
+ logger?: Logger;
108
+ observability?: DyrectedObservabilityRuntime;
12
109
  siteId?: string;
13
110
  workspaceId?: string;
111
+ requestBodyCapture?: RequestBodyCapture;
112
+ requestTrace?: RequestTraceContext;
14
113
  /**
15
114
  * The authenticated user set by requireAuth() or optionalAuth() middleware.
16
115
  * Hydrated from the full user record (minus password) when a db adapter is
@@ -23,6 +122,8 @@ interface DyrectedContext {
23
122
  collection: string;
24
123
  [key: string]: any;
25
124
  };
125
+ clientIp?: string;
126
+ authTokenPayload?: CollectionTokenPayload;
26
127
  };
27
128
  }
28
129
  /**
@@ -40,7 +141,7 @@ declare function registerRoutes(app: Hono<DyrectedContext>, config: DyrectedConf
40
141
  *
41
142
  * Routes registered (relative to `/api/collections/:slug`):
42
143
  * POST /login
43
- * POST /logout (stateless — client drops the token)
144
+ * POST /logout
44
145
  * GET /me
45
146
  * POST /refresh-token
46
147
  * POST /forgot-password
@@ -51,6 +152,9 @@ declare function registerRoutes(app: Hono<DyrectedContext>, config: DyrectedConf
51
152
  declare class AuthController {
52
153
  private collection;
53
154
  constructor(collection: CollectionConfig);
155
+ private sanitizeUser;
156
+ private clearLockoutState;
157
+ private recordFailedLogin;
54
158
  init(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
55
159
  message: string;
56
160
  }, 500, "json">) | (Response & hono.TypedResponse<{
@@ -67,8 +171,7 @@ declare class AuthController {
67
171
  }, 400, "json">) | (Response & hono.TypedResponse<{
68
172
  token: string;
69
173
  user: {
70
- [x: string]: any;
71
- id: string;
174
+ [x: string]: hono_utils_types.JSONValue;
72
175
  };
73
176
  }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
74
177
  login(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
@@ -80,15 +183,22 @@ declare class AuthController {
80
183
  error: true;
81
184
  message: string;
82
185
  }, 401, "json">) | (Response & hono.TypedResponse<{
186
+ error: true;
187
+ message: string;
188
+ retryAfterSeconds: number;
189
+ }, 429, "json">) | (Response & hono.TypedResponse<{
83
190
  token: string;
84
191
  user: {
85
- [x: string]: any;
192
+ [x: string]: hono_utils_types.JSONValue;
86
193
  };
87
194
  }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
88
- logout(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<{
195
+ logout(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
196
+ error: true;
197
+ message: string;
198
+ }, 401, "json">) | (Response & hono.TypedResponse<{
89
199
  success: true;
90
200
  message: string;
91
- }, hono_utils_http_status.ContentfulStatusCode, "json">>;
201
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
92
202
  me(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
93
203
  message: string;
94
204
  }, 500, "json">) | (Response & hono.TypedResponse<{
@@ -98,13 +208,15 @@ declare class AuthController {
98
208
  error: true;
99
209
  message: string;
100
210
  }, 404, "json">) | (Response & hono.TypedResponse<{
101
- [x: string]: any;
102
- id: string;
211
+ [x: string]: hono_utils_types.JSONValue;
103
212
  }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
104
213
  refreshToken(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
105
214
  error: true;
106
215
  message: string;
107
216
  }, 401, "json">) | (Response & hono.TypedResponse<{
217
+ error: true;
218
+ message: string;
219
+ }, 400, "json">) | (Response & hono.TypedResponse<{
108
220
  token: string;
109
221
  }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
110
222
  forgotPassword(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
@@ -151,8 +263,7 @@ declare class AuthController {
151
263
  }, 409, "json">) | (Response & hono.TypedResponse<{
152
264
  token: string;
153
265
  user: {
154
- [x: string]: any;
155
- id: string;
266
+ [x: string]: hono_utils_types.JSONValue;
156
267
  };
157
268
  }, 201, "json">)>;
158
269
  }
@@ -343,6 +454,7 @@ declare class GlobalController {
343
454
 
344
455
  declare class MediaController {
345
456
  private collection;
457
+ private loggerComponent;
346
458
  constructor(collection?: string);
347
459
  upload(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
348
460
  message: string;
package/dist/server.d.ts CHANGED
@@ -1,16 +1,115 @@
1
1
  import * as hono_types from 'hono/types';
2
2
  import * as hono from 'hono';
3
3
  import { Hono, Context } from 'hono';
4
- import { D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig } from './app-config-C0twGIaF.js';
5
- import * as hono_utils_http_status from 'hono/utils/http-status';
4
+ import { Logger } from 'pino';
5
+ import { D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig } from './app-config-Dv5XACR4.js';
6
+ import { JWTPayload } from 'jose';
7
+ import { Tracer, Counter, Attributes, Histogram, Span } from '@opentelemetry/api';
8
+ import { PrometheusExporter } from '@opentelemetry/exporter-prometheus';
6
9
  import * as hono_utils_types from 'hono/utils/types';
10
+ import * as hono_utils_http_status from 'hono/utils/http-status';
7
11
  import 'lucide-react';
8
12
 
13
+ interface CollectionTokenPayload extends JWTPayload {
14
+ sub: string;
15
+ email: string;
16
+ collection: string;
17
+ sid?: string;
18
+ purpose?: 'invite' | 'reset';
19
+ providerId?: string;
20
+ authSource?: 'local' | 'external';
21
+ }
22
+
23
+ interface ResolvedObservabilityConfig {
24
+ requestLogging: {
25
+ enabled: boolean;
26
+ logBodies: boolean;
27
+ maxBodyBytes: number;
28
+ redactPaths: string[];
29
+ includeHeaders: string[];
30
+ redactHeaders: string[];
31
+ };
32
+ sampling: {
33
+ successRate: number;
34
+ traceSuccessRate: number;
35
+ bodySuccessRate: number;
36
+ alwaysKeep4xx: boolean;
37
+ alwaysKeep5xx: boolean;
38
+ };
39
+ tracing: {
40
+ enabled: boolean;
41
+ serviceName: string;
42
+ exporter: "otlp" | "console" | "none";
43
+ headers: Record<string, string>;
44
+ endpoint?: string;
45
+ };
46
+ metrics: {
47
+ enabled: boolean;
48
+ exporter: "otlp" | "prometheus" | "none";
49
+ endpoint?: string;
50
+ path: string;
51
+ };
52
+ transports: {
53
+ targets: Array<{
54
+ type: "stdout";
55
+ } | {
56
+ type: "stderr";
57
+ } | {
58
+ type: "file";
59
+ path: string;
60
+ } | {
61
+ type: "otlp";
62
+ endpoint: string;
63
+ headers?: Record<string, string>;
64
+ }>;
65
+ };
66
+ }
67
+ interface RequestTraceContext {
68
+ span: Span;
69
+ traceId: string;
70
+ spanId: string;
71
+ sampled: boolean;
72
+ }
73
+ interface RequestBodyCapture {
74
+ attempted: boolean;
75
+ contentType?: string;
76
+ contentLength?: number;
77
+ truncated?: boolean;
78
+ parseFailed?: boolean;
79
+ body?: unknown;
80
+ }
81
+ interface MetricsRuntime {
82
+ requestCount: Counter<Attributes>;
83
+ authFailureCount: Counter<Attributes>;
84
+ uncaughtErrorCount: Counter<Attributes>;
85
+ auditWriteFailureCount: Counter<Attributes>;
86
+ emailSendFailureCount: Counter<Attributes>;
87
+ workflowHookFailureCount: Counter<Attributes>;
88
+ requestDuration: Histogram<Attributes>;
89
+ }
90
+ interface DyrectedObservabilityRuntime {
91
+ logger: Logger;
92
+ config: ResolvedObservabilityConfig;
93
+ tracer?: Tracer;
94
+ metrics?: MetricsRuntime;
95
+ prometheusExporter?: PrometheusExporter;
96
+ shutdown: () => Promise<void>;
97
+ recordAuthFailure: (attributes?: Attributes) => void;
98
+ recordUncaughtError: (attributes?: Attributes) => void;
99
+ recordAuditWriteFailure: (attributes?: Attributes) => void;
100
+ recordEmailSendFailure: (attributes?: Attributes) => void;
101
+ recordWorkflowHookFailure: (attributes?: Attributes) => void;
102
+ }
103
+
9
104
  interface DyrectedContext {
10
105
  Variables: {
11
106
  config: DyrectedConfig;
107
+ logger?: Logger;
108
+ observability?: DyrectedObservabilityRuntime;
12
109
  siteId?: string;
13
110
  workspaceId?: string;
111
+ requestBodyCapture?: RequestBodyCapture;
112
+ requestTrace?: RequestTraceContext;
14
113
  /**
15
114
  * The authenticated user set by requireAuth() or optionalAuth() middleware.
16
115
  * Hydrated from the full user record (minus password) when a db adapter is
@@ -23,6 +122,8 @@ interface DyrectedContext {
23
122
  collection: string;
24
123
  [key: string]: any;
25
124
  };
125
+ clientIp?: string;
126
+ authTokenPayload?: CollectionTokenPayload;
26
127
  };
27
128
  }
28
129
  /**
@@ -40,7 +141,7 @@ declare function registerRoutes(app: Hono<DyrectedContext>, config: DyrectedConf
40
141
  *
41
142
  * Routes registered (relative to `/api/collections/:slug`):
42
143
  * POST /login
43
- * POST /logout (stateless — client drops the token)
144
+ * POST /logout
44
145
  * GET /me
45
146
  * POST /refresh-token
46
147
  * POST /forgot-password
@@ -51,6 +152,9 @@ declare function registerRoutes(app: Hono<DyrectedContext>, config: DyrectedConf
51
152
  declare class AuthController {
52
153
  private collection;
53
154
  constructor(collection: CollectionConfig);
155
+ private sanitizeUser;
156
+ private clearLockoutState;
157
+ private recordFailedLogin;
54
158
  init(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
55
159
  message: string;
56
160
  }, 500, "json">) | (Response & hono.TypedResponse<{
@@ -67,8 +171,7 @@ declare class AuthController {
67
171
  }, 400, "json">) | (Response & hono.TypedResponse<{
68
172
  token: string;
69
173
  user: {
70
- [x: string]: any;
71
- id: string;
174
+ [x: string]: hono_utils_types.JSONValue;
72
175
  };
73
176
  }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
74
177
  login(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
@@ -80,15 +183,22 @@ declare class AuthController {
80
183
  error: true;
81
184
  message: string;
82
185
  }, 401, "json">) | (Response & hono.TypedResponse<{
186
+ error: true;
187
+ message: string;
188
+ retryAfterSeconds: number;
189
+ }, 429, "json">) | (Response & hono.TypedResponse<{
83
190
  token: string;
84
191
  user: {
85
- [x: string]: any;
192
+ [x: string]: hono_utils_types.JSONValue;
86
193
  };
87
194
  }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
88
- logout(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<{
195
+ logout(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
196
+ error: true;
197
+ message: string;
198
+ }, 401, "json">) | (Response & hono.TypedResponse<{
89
199
  success: true;
90
200
  message: string;
91
- }, hono_utils_http_status.ContentfulStatusCode, "json">>;
201
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
92
202
  me(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
93
203
  message: string;
94
204
  }, 500, "json">) | (Response & hono.TypedResponse<{
@@ -98,13 +208,15 @@ declare class AuthController {
98
208
  error: true;
99
209
  message: string;
100
210
  }, 404, "json">) | (Response & hono.TypedResponse<{
101
- [x: string]: any;
102
- id: string;
211
+ [x: string]: hono_utils_types.JSONValue;
103
212
  }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
104
213
  refreshToken(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
105
214
  error: true;
106
215
  message: string;
107
216
  }, 401, "json">) | (Response & hono.TypedResponse<{
217
+ error: true;
218
+ message: string;
219
+ }, 400, "json">) | (Response & hono.TypedResponse<{
108
220
  token: string;
109
221
  }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
110
222
  forgotPassword(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
@@ -151,8 +263,7 @@ declare class AuthController {
151
263
  }, 409, "json">) | (Response & hono.TypedResponse<{
152
264
  token: string;
153
265
  user: {
154
- [x: string]: any;
155
- id: string;
266
+ [x: string]: hono_utils_types.JSONValue;
156
267
  };
157
268
  }, 201, "json">)>;
158
269
  }
@@ -343,6 +454,7 @@ declare class GlobalController {
343
454
 
344
455
  declare class MediaController {
345
456
  private collection;
457
+ private loggerComponent;
346
458
  constructor(collection?: string);
347
459
  upload(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
348
460
  message: string;