@venizia/ignis-docs 0.2.0 → 0.2.1-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 (142) hide show
  1. package/README.md +14 -14
  2. package/content/best-practices/api-usage-examples.md +39 -19
  3. package/content/best-practices/architectural-patterns.md +22 -11
  4. package/content/best-practices/architecture-decisions.md +29 -16
  5. package/content/best-practices/code-style-standards/advanced-patterns.md +43 -31
  6. package/content/best-practices/code-style-standards/constants-configuration.md +19 -4
  7. package/content/best-practices/code-style-standards/control-flow.md +33 -1
  8. package/content/best-practices/code-style-standards/documentation.md +28 -8
  9. package/content/best-practices/code-style-standards/function-patterns.md +15 -4
  10. package/content/best-practices/code-style-standards/index.md +7 -2
  11. package/content/best-practices/code-style-standards/naming-conventions.md +26 -2
  12. package/content/best-practices/code-style-standards/route-definitions.md +9 -5
  13. package/content/best-practices/code-style-standards/tooling.md +14 -1
  14. package/content/best-practices/code-style-standards/type-safety.md +39 -6
  15. package/content/best-practices/common-pitfalls.md +59 -35
  16. package/content/best-practices/contribution-workflow.md +6 -2
  17. package/content/best-practices/data-modeling.md +78 -62
  18. package/content/best-practices/deployment-strategies.md +56 -19
  19. package/content/best-practices/error-handling.md +182 -93
  20. package/content/best-practices/index.md +6 -0
  21. package/content/best-practices/performance-optimization.md +26 -13
  22. package/content/best-practices/security-guidelines.md +35 -9
  23. package/content/best-practices/testing-strategies.md +7 -2
  24. package/content/best-practices/troubleshooting-tips.md +27 -17
  25. package/content/extensions/components/api-reference.md +107 -322
  26. package/content/extensions/components/authentication/api.md +454 -603
  27. package/content/extensions/components/authentication/errors.md +121 -498
  28. package/content/extensions/components/authentication/index.md +88 -801
  29. package/content/extensions/components/authentication/usage.md +207 -956
  30. package/content/extensions/components/authorization/api.md +736 -656
  31. package/content/extensions/components/authorization/errors.md +168 -206
  32. package/content/extensions/components/authorization/index.md +82 -797
  33. package/content/extensions/components/authorization/usage.md +194 -527
  34. package/content/extensions/components/health-check.md +71 -243
  35. package/content/extensions/components/mail/api.md +504 -287
  36. package/content/extensions/components/mail/errors.md +73 -61
  37. package/content/extensions/components/mail/index.md +96 -467
  38. package/content/extensions/components/mail/usage.md +130 -172
  39. package/content/extensions/components/request-tracker.md +66 -173
  40. package/content/extensions/components/socket-io/api.md +195 -13
  41. package/content/extensions/components/socket-io/errors.md +3 -3
  42. package/content/extensions/components/socket-io/index.md +50 -337
  43. package/content/extensions/components/socket-io/usage.md +143 -26
  44. package/content/extensions/components/static-asset/api.md +410 -142
  45. package/content/extensions/components/static-asset/errors.md +110 -53
  46. package/content/extensions/components/static-asset/index.md +79 -608
  47. package/content/extensions/components/static-asset/usage.md +180 -300
  48. package/content/extensions/components/websocket/api.md +275 -399
  49. package/content/extensions/components/websocket/errors.md +47 -56
  50. package/content/extensions/components/websocket/index.md +74 -407
  51. package/content/extensions/components/websocket/usage.md +110 -341
  52. package/content/extensions/helpers/cron/index.md +51 -160
  53. package/content/extensions/helpers/crypto/index.md +62 -483
  54. package/content/extensions/helpers/crypto/reference.md +456 -0
  55. package/content/extensions/helpers/env/index.md +60 -178
  56. package/content/extensions/helpers/error/index.md +221 -207
  57. package/content/extensions/helpers/inversion/index.md +65 -556
  58. package/content/extensions/helpers/inversion/reference.md +522 -0
  59. package/content/extensions/helpers/kafka/admin.md +20 -1
  60. package/content/extensions/helpers/kafka/compile-binary.md +41 -35
  61. package/content/extensions/helpers/kafka/consumer.md +54 -20
  62. package/content/extensions/helpers/kafka/examples.md +21 -16
  63. package/content/extensions/helpers/kafka/index.md +80 -610
  64. package/content/extensions/helpers/kafka/producer.md +134 -5
  65. package/content/extensions/helpers/kafka/schema-registry.md +45 -70
  66. package/content/extensions/helpers/logger/hf-logger.md +193 -0
  67. package/content/extensions/helpers/logger/index.md +64 -563
  68. package/content/extensions/helpers/logger/pino.md +85 -0
  69. package/content/extensions/helpers/logger/reference.md +746 -0
  70. package/content/extensions/helpers/network/api.md +241 -195
  71. package/content/extensions/helpers/network/index.md +72 -530
  72. package/content/extensions/helpers/queue/index.md +72 -900
  73. package/content/extensions/helpers/queue/reference.md +467 -0
  74. package/content/extensions/helpers/redis/index.md +73 -645
  75. package/content/extensions/helpers/redis/reference.md +727 -0
  76. package/content/extensions/helpers/secrets/index.md +66 -0
  77. package/content/extensions/helpers/socket-io/api.md +305 -203
  78. package/content/extensions/helpers/socket-io/index.md +66 -432
  79. package/content/extensions/helpers/storage/api.md +564 -462
  80. package/content/extensions/helpers/storage/index.md +77 -573
  81. package/content/extensions/helpers/types/index.md +66 -499
  82. package/content/extensions/helpers/types/reference.md +650 -0
  83. package/content/extensions/helpers/uid/index.md +58 -227
  84. package/content/extensions/helpers/websocket/api.md +329 -216
  85. package/content/extensions/helpers/websocket/index.md +65 -503
  86. package/content/extensions/helpers/worker-thread/index.md +58 -396
  87. package/content/extensions/helpers/worker-thread/reference.md +428 -0
  88. package/content/guides/core-concepts/persistent/models.md +1 -1
  89. package/content/guides/core-concepts/persistent/search-typesense.md +3 -3
  90. package/content/guides/core-concepts/persistent/transactions.md +1 -1
  91. package/content/guides/core-concepts/secrets-vault.md +177 -0
  92. package/content/guides/core-concepts/services.md +1 -1
  93. package/content/guides/migrations/redis-helpers-migration.md +1 -1
  94. package/content/guides/migrations/unified-connectors-migration.md +2 -2
  95. package/content/guides/tutorials/ecommerce-api.md +3 -8
  96. package/content/references/base/application.md +1 -1
  97. package/content/references/base/connectors.md +79 -136
  98. package/content/references/base/datasources-reference.md +599 -0
  99. package/content/references/base/datasources.md +84 -444
  100. package/content/references/base/dependency-injection.md +17 -39
  101. package/content/references/base/filter-system/application-usage.md +69 -121
  102. package/content/references/base/filter-system/array-operators.md +12 -0
  103. package/content/references/base/filter-system/comparison-operators.md +12 -0
  104. package/content/references/base/filter-system/default-filter.md +136 -348
  105. package/content/references/base/filter-system/fields-order-pagination.md +38 -16
  106. package/content/references/base/filter-system/index.md +106 -257
  107. package/content/references/base/filter-system/json-filtering.md +12 -2
  108. package/content/references/base/filter-system/list-operators.md +16 -2
  109. package/content/references/base/filter-system/logical-operators.md +13 -0
  110. package/content/references/base/filter-system/null-operators.md +13 -0
  111. package/content/references/base/filter-system/pattern-matching.md +12 -0
  112. package/content/references/base/filter-system/quick-reference.md +11 -2
  113. package/content/references/base/filter-system/range-operators.md +12 -0
  114. package/content/references/base/filter-system/tips.md +70 -133
  115. package/content/references/base/filter-system/use-cases.md +156 -233
  116. package/content/references/base/middlewares.md +35 -21
  117. package/content/references/base/models-reference.md +886 -0
  118. package/content/references/base/models.md +80 -1452
  119. package/content/references/base/repositories/advanced.md +156 -192
  120. package/content/references/base/repositories/index.md +77 -650
  121. package/content/references/base/repositories/mixins.md +22 -18
  122. package/content/references/base/repositories/relations.md +123 -171
  123. package/content/references/base/repositories/soft-deletable.md +58 -56
  124. package/content/references/base/secrets.md +263 -0
  125. package/content/references/base/services.md +2 -2
  126. package/content/references/configuration/environment-variables.md +48 -4
  127. package/content/references/configuration/index.md +49 -31
  128. package/content/references/quick-reference.md +3 -16
  129. package/content/references/utilities/crypto.md +35 -76
  130. package/content/references/utilities/date.md +33 -73
  131. package/content/references/utilities/index.md +1 -1
  132. package/content/references/utilities/jsx-reference.md +298 -0
  133. package/content/references/utilities/jsx.md +82 -525
  134. package/content/references/utilities/module.md +29 -62
  135. package/content/references/utilities/parse.md +34 -64
  136. package/content/references/utilities/performance.md +33 -58
  137. package/content/references/utilities/promise.md +28 -62
  138. package/content/references/utilities/request.md +57 -218
  139. package/content/references/utilities/schema.md +43 -137
  140. package/content/references/utilities/statuses-reference.md +361 -0
  141. package/content/references/utilities/statuses.md +63 -667
  142. package/package.json +8 -8
@@ -1,8 +1,17 @@
1
- # Authentication -- Error Reference
1
+ ---
2
+ title: Authentication Errors
3
+ description: Every error the Authentication component throws, organized by source, with cause and fix
4
+ difficulty: intermediate
5
+ ---
6
+
7
+ # Authentication Errors
2
8
 
3
- > Complete error messages and troubleshooting for the authentication module. See [Setup & Configuration](./) for initial setup.
9
+ Every error message the Authentication component and its services throw, with cause and fix. See the [Overview](./) for initial setup.
4
10
 
5
- ## Error Flow Overview
11
+ - **Startup errors (400 unless noted)** come from `AuthenticateComponent.binding()` and stop the application before it serves traffic.
12
+ - **Runtime errors (401)** come from request-time credential extraction, verification, or strategy exhaustion.
13
+ - **Structural errors (500)** come from calling an unsupported operation (e.g. signing on a verify-only service) or accessing uninitialized state.
14
+ - All of them go through `getError()`, which defaults `statusCode` to `400` when not given explicitly - so every "startup" error below is a 400 unless the table says otherwise.
6
15
 
7
16
  ```mermaid
8
17
  flowchart LR
@@ -10,512 +19,170 @@ flowchart LR
10
19
  MW --> SKIP{"Skip auth?"}
11
20
  SKIP -->|"Yes"| PASS["Pass through"]
12
21
  SKIP -->|"No"| EXTRACT["Extract credentials"]
13
- EXTRACT -->|"Missing header"| E401A["401 Missing header"]
14
- EXTRACT -->|"Wrong scheme"| E401B["401 Invalid scheme"]
15
- EXTRACT -->|"Bad format"| E401C["401 Invalid format"]
16
- EXTRACT -->|"OK"| VERIFY["Verify token"]
17
- VERIFY -->|"Expired/invalid"| E401D["401 Invalid token"]
22
+ EXTRACT -->|"Missing/wrong/malformed"| E401["401"]
23
+ EXTRACT -->|"OK"| VERIFY["Verify token / credentials"]
24
+ VERIFY -->|"Invalid/expired"| E401
18
25
  VERIFY -->|"Valid"| USER["Set CURRENT_USER"]
19
26
  USER --> NEXT["Next middleware"]
20
27
 
21
- style E401A fill:#f8d7da,stroke:#dc3545
22
- style E401B fill:#f8d7da,stroke:#dc3545
23
- style E401C fill:#f8d7da,stroke:#dc3545
24
- style E401D fill:#f8d7da,stroke:#dc3545
28
+ style E401 fill:#f8d7da,stroke:#dc3545
25
29
  style PASS fill:#d4edda,stroke:#28a745
26
30
  style NEXT fill:#d4edda,stroke:#28a745
27
31
  ```
28
32
 
29
- ## Complete Error Reference
30
-
31
- All error messages from the authentication module, organized by source.
32
-
33
- ---
34
-
35
- ### Component Errors (`AuthenticateComponent`)
36
-
37
- Thrown during `binding()` when validating options and configuring services.
38
-
39
- | Error Message | Status | Method | When |
40
- |---------------|--------|--------|------|
41
- | `[AuthenticateComponent] At least one of jwtOptions or basicOptions must be provided` | 400 | `binding` | Neither `JWT_OPTIONS` nor `BASIC_OPTIONS` bound in DI container |
42
- | <code v-pre>[AuthenticateComponent] Unknown JOSE standard: {{standard}}</code> | 400 | `binding` | `jwtOptions.standard` is not `'JWS'` or `'JWKS'` |
43
-
44
- #### `defineJWSAuth` Errors
45
-
46
- | Error Message | Status | Method | When |
47
- |---------------|--------|--------|------|
48
- | <code v-pre>[defineJWSAuth] Invalid jwtSecret &#124; Provided: {{jwtSecret}}</code> | 400 | `defineJWSAuth` | `jwtSecret` is falsy or equals `'unknown_secret'` |
49
- | `[defineJWSAuth] getTokenExpiresFn is required` | 400 | `defineJWSAuth` | `getTokenExpiresFn` not provided in JWS options |
50
-
51
- ::: info applicationSecret is no longer validated
52
- `applicationSecret` was previously required and validated by the component. It is now **optional** - omitting it simply disables AES payload encryption.
53
- :::
54
-
55
- #### `defineJWKSAuth` Errors (Issuer Mode)
56
-
57
- | Error Message | Status | Method | When |
58
- |---------------|--------|--------|------|
59
- | `[defineJWKSAuth] keys.private and keys.public are required for issuer mode` | 400 | `defineJWKSAuth` | `keys.private` or `keys.public` missing |
60
- | <code v-pre>[defineJWKSAuth] keys.format is required and must be one of: pem, jwk</code> | 400 | `defineJWKSAuth` | `keys.format` missing or not in `JWKSKeyFormats.SCHEME_SET` |
61
- | `[defineJWKSAuth] kid is required for issuer mode` | 400 | `defineJWKSAuth` | `kid` (Key ID) not provided |
62
- | `[defineJWKSAuth] getTokenExpiresFn is required for issuer mode` | 400 | `defineJWKSAuth` | `getTokenExpiresFn` not provided |
63
-
64
- #### `defineJWKSAuth` Errors (Verifier Mode)
65
-
66
- | Error Message | Status | Method | When |
67
- |---------------|--------|--------|------|
68
- | `[defineJWKSAuth] jwksUrl is required for verifier mode` | 400 | `defineJWKSAuth` | `jwksUrl` not provided for verifier mode |
69
-
70
- #### `defineJWKSAuth` Errors (General)
71
-
72
- | Error Message | Status | Method | When |
73
- |---------------|--------|--------|------|
74
- | <code v-pre>[defineJWKSAuth] Invalid JWKS mode: {{mode}}</code> | 400 | `defineJWKSAuth` | `mode` is not `'issuer'` or `'verifier'` |
75
-
76
- #### `defineBasicAuth` Errors
77
-
78
- | Error Message | Status | Method | When |
79
- |---------------|--------|--------|------|
80
- | `[defineBasicAuth] verifyCredentials function is required` | 400 | `defineBasicAuth` | `BASIC_OPTIONS` bound without a `verifyCredentials` callback |
33
+ ## AuthenticateComponent (startup)
81
34
 
82
- #### `defineControllers` Errors
35
+ Thrown during `binding()` while validating options and wiring services.
83
36
 
84
- | Error Message | Status | Method | When |
85
- |---------------|--------|--------|------|
86
- | `[defineControllers] Auth controller requires jwtOptions to be configured` | 400 | `defineControllers` | `useAuthController: true` but no `jwtOptions` provided |
37
+ | Message | Status | Cause | Fix |
38
+ |---------|--------|-------|-----|
39
+ | `[AuthenticateComponent] At least one of jwtOptions or basicOptions must be provided` | 400 | Neither `JWT_OPTIONS` nor `BASIC_OPTIONS` bound before `this.component(AuthenticateComponent)` | Bind at least one before registering the component - see [Setup](./#common-tasks) |
40
+ | `[AuthenticateComponent] Unknown JOSE standard: {standard}` | 400 | `jwtOptions.standard` is not `'JWS'` or `'JWKS'` | Use `JOSEStandards.JWS` or `JOSEStandards.JWKS` |
41
+ | `[defineJWSAuth] Invalid jwtSecret \| Provided: {jwtSecret}` | 400 | `jwtSecret` falsy or equals placeholder `'unknown_secret'` | Set a real secret, e.g. `APP_ENV_JWT_SECRET` |
42
+ | `[defineJWSAuth] getTokenExpiresFn is required` | 400 | `getTokenExpiresFn` missing from JWS options | Provide `() => Number(process.env.APP_ENV_JWT_EXPIRES_IN \|\| 86400)` |
43
+ | `[defineJWKSAuth] keys.private and keys.public are required for issuer mode` | 400 | Issuer mode missing one or both keys | Provide `keys.private` and `keys.public` |
44
+ | `[defineJWKSAuth] keys.format is required and must be one of: pem, jwk` | 400 | `keys.format` missing or invalid | Use `JWKSKeyFormats.PEM` or `JWKSKeyFormats.JWK` |
45
+ | `[defineJWKSAuth] kid is required for issuer mode` | 400 | `kid` (Key ID) not provided | Provide a unique `kid` string |
46
+ | `[defineJWKSAuth] getTokenExpiresFn is required for issuer mode` | 400 | `getTokenExpiresFn` missing | Provide a token-expiry function |
47
+ | `[defineJWKSAuth] jwksUrl is required for verifier mode` | 400 | Verifier mode missing `jwksUrl` | Provide the issuer's `/certs` URL |
48
+ | `[defineJWKSAuth] Invalid JWKS mode: {mode}` | 400 | `mode` is not `'issuer'` or `'verifier'` | Use `JWKSModes.ISSUER` or `JWKSModes.VERIFIER` |
49
+ | `[defineBasicAuth] verifyCredentials function is required` | 400 | `BASIC_OPTIONS` bound without a `verifyCredentials` callback | Provide the callback - see [Setup](./#common-tasks) |
50
+ | `[defineControllers] Auth controller requires jwtOptions to be configured` | 400 | `useAuthController: true` but no `jwtOptions` bound | Bind `JWT_OPTIONS` before enabling the auth controller |
87
51
 
88
- ---
89
-
90
- ### Bearer Token Service Errors (`AbstractBearerTokenService`)
91
-
92
- Base class errors shared by `JWSTokenService`, `JWKSIssuerTokenService`, and `JWKSVerifierTokenService`.
93
-
94
- #### `extractCredentials` Errors
95
-
96
- | Error Message | Status | Method | When |
97
- |---------------|--------|--------|------|
98
- | `Unauthorized user! Missing authorization header` | 401 | `extractCredentials` | Request has no `Authorization` header |
99
- | `Unauthorized user! Invalid schema of request token!` | 401 | `extractCredentials` | `Authorization` header doesn't start with `Bearer` |
100
- | <code v-pre>Authorization header value is invalid format. It must follow the pattern: 'Bearer xx.yy.zz' where xx.yy.zz is a valid JWT token.</code> | 401 | `extractCredentials` | `Authorization` header doesn't have exactly 2 parts (type + token) |
101
-
102
- #### `verify` Errors
103
-
104
- | Error Message | Status | Method | When |
105
- |---------------|--------|--------|------|
106
- | `[verify] Invalid request token!` | 401 | `verify` | Token value is empty/falsy |
107
- | `[verify] Invalid or expired token` | 401 | `verify` | `doVerify()` threw - token is expired, malformed, or signature invalid |
108
-
109
- ::: tip Sanitized error messages
110
- The `verify()` and `generate()` methods use **sanitized error messages** - they do NOT include the original `error.message` in the thrown error. The full error is logged at `error` level for debugging but not exposed to clients.
111
- :::
112
-
113
- #### `generate` Errors
114
-
115
- | Error Message | Status | Method | When |
116
- |---------------|--------|--------|------|
117
- | `[generate] Invalid token payload!` | 401 | `generate` | Payload is null/undefined |
118
- | `[generate] Failed to generate token` | 500 | `generate` | Signing failed (key issue, algorithm mismatch, etc.) |
52
+ > [!NOTE]
53
+ > `applicationSecret` is optional and not validated. The component and every token service treat it as optional - omitting it simply disables AES payload encryption. It is never checked for presence.
119
54
 
120
- ---
121
-
122
- ### JWS Token Service Errors (`JWSTokenService`)
123
-
124
- Constructor validation errors thrown during DI resolution.
125
-
126
- | Error Message | Status | Method | When |
127
- |---------------|--------|--------|------|
128
- | `[JWSTokenService] Invalid jwtSecret` | 500 | `constructor` | `jwtSecret` is falsy in injected `IJWSTokenServiceOptions` |
129
- | `[JWSTokenService] Invalid getTokenExpiresFn` | 500 | `constructor` | `getTokenExpiresFn` is falsy in injected options |
130
- | `[getSigningKey] Invalid jwtSecret!` | 400 | `getSigningKey` | `jwtSecret` Uint8Array is null (should not happen after constructor validation) |
131
-
132
- ::: info applicationSecret no longer validated
133
- `JWSTokenService` no longer validates `applicationSecret` in its constructor. If not provided, AES payload encryption is simply disabled.
134
- :::
55
+ ## Bearer token services (runtime)
135
56
 
136
- ---
137
-
138
- ### JWKS Issuer Token Service Errors (`JWKSIssuerTokenService`)
139
-
140
- Errors thrown during lazy initialization (`ensureInitialized()`) and key operations.
57
+ Shared by `JWSTokenService`, `JWKSIssuerTokenService`, and `JWKSVerifierTokenService` via `AbstractBearerTokenService`.
141
58
 
142
- #### Initialization Errors
59
+ | Message | Status | Method | Cause | Fix |
60
+ |---------|--------|--------|-------|-----|
61
+ | `Unauthorized user! Missing authorization header` | 401 | `extractCredentials` | No `Authorization` header | Send `Authorization: Bearer <token>` |
62
+ | `Unauthorized user! Invalid schema of request token!` | 401 | `extractCredentials` | Header doesn't start with `Bearer` | Use the `Bearer` scheme |
63
+ | `Authorization header value is invalid format. It must follow the pattern: 'Bearer xx.yy.zz' ...` | 401 | `extractCredentials` | Header doesn't split into exactly 2 parts | Check for extra whitespace or a malformed token |
64
+ | `[verify] Invalid request token!` | 401 | `verify` | Token value is empty | Ensure the token half of the header isn't blank |
65
+ | `[verify] Invalid or expired token` | 401 | `verify` | `doVerify()` threw - expired, malformed, or bad signature | Check application logs for the real cause (see below) |
66
+ | `[generate] Invalid token payload!` | 401 | `generate` | Payload is null/undefined | Pass a non-null `IJWTTokenPayload` |
67
+ | `[generate] Failed to generate token` | 500 | `generate` | Signing failed (key/algorithm issue) | Check application logs for the real cause |
143
68
 
144
- | Error Message | Status | Method | When |
145
- |---------------|--------|--------|------|
146
- | <code v-pre>[JWKSIssuerTokenService] Unknown key driver: {{driver}}</code> | 500 | `resolveKeyContent` | `keys.driver` is not `'text'` or `'file'` |
147
- | `[JWKSIssuerTokenService] Invalid raw.priv key!` | 500 | `parseKeyMaterial` | Resolved private key content is empty |
148
- | `[JWKSIssuerTokenService] Invalid raw.pub key!` | 500 | `parseKeyMaterial` | Resolved public key content is empty |
149
- | `[JWKSIssuerTokenService] Invalid JWK key material` | 500 | `parseKeyMaterial` | JWK JSON parsing or `importJWK()` failed (PEM format works, JWK content is invalid) |
150
- | <code v-pre>[JWKSIssuerTokenService] Unknown key format: {{format}}</code> | 500 | `parseKeyMaterial` | `keys.format` is not `'pem'` or `'jwk'` |
69
+ > [!TIP]
70
+ > Errors are sanitized on the wire. `verify()` and `generate()` never leak the original `error.message` to the client. The full error is logged at `error` level - run `grep "Failed to verify token" logs/application.log` to find it.
151
71
 
152
- ::: warning File read errors
153
- When using `JWKSKeyDrivers.FILE`, file read errors from `readFile()` propagate as Node.js filesystem errors (e.g., `ENOENT`, `EACCES`). These are **not** wrapped - the raw error surfaces during initialization.
154
- :::
72
+ ## JWSTokenService (constructor)
155
73
 
156
- #### Runtime Errors
74
+ | Message | Status | Cause | Fix |
75
+ |---------|--------|-------|-----|
76
+ | `[JWSTokenService] Invalid jwtSecret` | 500 | `jwtSecret` falsy in injected options | Fix the `JWT_OPTIONS` binding |
77
+ | `[JWSTokenService] Invalid getTokenExpiresFn` | 500 | `getTokenExpiresFn` falsy in injected options | Fix the `JWT_OPTIONS` binding |
78
+ | `[getSigningKey] Invalid jwtSecret!` | 400 | `jwtSecret` Uint8Array is null | Should not happen after constructor validation - report if seen |
157
79
 
158
- | Error Message | Status | Method | When |
159
- |---------------|--------|--------|------|
160
- | `[getSigningKey] Invalid privateKey!` | 400 | `getSigningKey` | Private key is null (initialization incomplete or failed) |
161
- | `[JWKSIssuerTokenService] JWKS not initialized yet. Call getJWKSAsync() instead.` | 500 | `getJWKS` | Sync `getJWKS()` called before lazy init completed |
162
-
163
- ---
80
+ ## JWKSIssuerTokenService (init + runtime)
164
81
 
165
- ### JWKS Verifier Token Service Errors (`JWKSVerifierTokenService`)
82
+ | Message | Status | Method | Cause | Fix |
83
+ |---------|--------|--------|-------|-----|
84
+ | `[JWKSIssuerTokenService] Unknown key driver: {driver}` | 500 | `resolveKeyContent` | `keys.driver` not `'text'` or `'file'` | Use `JWKSKeyDrivers.TEXT` or `.FILE` |
85
+ | `[JWKSIssuerTokenService] Invalid raw.priv key!` | 500 | `parseKeyMaterial` | Resolved private key content is empty | Check the file path or inline string |
86
+ | `[JWKSIssuerTokenService] Invalid raw.pub key!` | 500 | `parseKeyMaterial` | Resolved public key content is empty | Check the file path or inline string |
87
+ | `[JWKSIssuerTokenService] Invalid JWK key material` | 500 | `parseKeyMaterial` | JWK JSON parse or `importJWK()` failed | Validate the JWK is well-formed JSON (see below) |
88
+ | `[JWKSIssuerTokenService] Unknown key format: {format}` | 500 | `parseKeyMaterial` | `keys.format` not `'pem'` or `'jwk'` | Use `JWKSKeyFormats.PEM` or `.JWK` |
89
+ | `[getSigningKey] Invalid privateKey!` | 400 | `getSigningKey` | Private key null - init incomplete or failed | Ensure `initialize()` succeeded; check logs |
90
+ | `[JWKSIssuerTokenService] JWKS not initialized yet. Call getJWKSAsync() instead.` | 500 | `getJWKS` | Sync `getJWKS()` called before lazy init completed | Use `await getJWKSAsync()` instead |
166
91
 
167
- | Error Message | Status | Method | When |
168
- |---------------|--------|--------|------|
169
- | `[JWKSVerifierTokenService] Verifier mode cannot sign tokens` | 500 | `getSigner` | Attempt to call `generate()` on a verify-only service |
170
- | `[JWKSVerifierTokenService] Verifier mode cannot sign tokens` | 500 | `getSigningKey` | Attempt to access signing key on a verify-only service |
171
- | `[JWKSVerifierTokenService] Verifier mode has no token expiry` | 500 | `getDefaultTokenExpiresFn` | Attempt to access token expiry on a verify-only service |
92
+ > [!WARNING]
93
+ > File read errors are not wrapped. With `JWKSKeyDrivers.FILE`, `readFile()` errors (`ENOENT`, `EACCES`, ...) surface as raw Node.js filesystem errors during initialization - they are not caught and re-thrown as `getError()`.
172
94
 
173
- ::: tip Verifier mode is read-only
174
- `JWKSVerifierTokenService` **cannot** generate tokens. Calling `generate()` throws because both `getSigner()` and `getSigningKey()` throw. Only `verify()` and `extractCredentials()` are functional.
175
- :::
95
+ ## JWKSVerifierTokenService (runtime)
176
96
 
177
- ---
97
+ | Message | Status | Method | Cause |
98
+ |---------|--------|--------|-------|
99
+ | `[JWKSVerifierTokenService] Verifier mode cannot sign tokens` | 500 | `getSigner` | `generate()` called on a verify-only service |
100
+ | `[JWKSVerifierTokenService] Verifier mode cannot sign tokens` | 500 | `getSigningKey` | Signing key accessed on a verify-only service |
101
+ | `[JWKSVerifierTokenService] Verifier mode has no token expiry` | 500 | `getDefaultTokenExpiresFn` | Token expiry accessed on a verify-only service |
178
102
 
179
- ### Basic Token Service Errors (`BasicTokenService`)
103
+ **Fix:** token generation must happen on the **issuer** service. If one application needs both signing and verification, use `JWKSModes.ISSUER` everywhere - an issuer can both sign and verify.
180
104
 
181
- | Error Message | Status | Method | When |
182
- |---------------|--------|--------|------|
183
- | `[BasicTokenService] Invalid verifyCredentials function` | 500 | `constructor` | `verifyCredentials` not provided in injected `TBasicTokenServiceOptions` |
184
- | `Unauthorized! Missing authorization header` | 401 | `extractCredentials` | Request has no `Authorization` header |
185
- | `Unauthorized! Invalid authorization schema, expected Basic` | 401 | `extractCredentials` | `Authorization` header doesn't start with `Basic` |
186
- | `Unauthorized! Invalid authorization header format` | 401 | `extractCredentials` | Header doesn't have exactly 2 parts (`Basic` + base64 value) |
187
- | `Unauthorized! Invalid base64 credentials format` | 401 | `extractCredentials` | Base64 decoding failed, no colon separator, or empty username |
188
- | `Unauthorized! Invalid username or password` | 401 | `verify` | `verifyCredentials` callback returned null/falsy |
105
+ ## BasicTokenService (runtime)
189
106
 
190
- ---
107
+ | Message | Status | Method | Cause | Fix |
108
+ |---------|--------|--------|-------|-----|
109
+ | `[BasicTokenService] Invalid verifyCredentials function` | 500 | `constructor` | `verifyCredentials` missing from injected options | Provide the callback in `BASIC_OPTIONS` |
110
+ | `Unauthorized! Missing authorization header` | 401 | `extractCredentials` | No `Authorization` header | Send `Authorization: Basic <base64>` |
111
+ | `Unauthorized! Invalid authorization schema, expected Basic` | 401 | `extractCredentials` | Header doesn't start with `Basic` | Use the `Basic` scheme |
112
+ | `Unauthorized! Invalid authorization header format` | 401 | `extractCredentials` | Header doesn't split into exactly 2 parts | Check the header value |
113
+ | `Unauthorized! Invalid base64 credentials format` | 401 | `extractCredentials` | Base64 decode failed, or no `:` separator, or empty username | Verify the client encodes `username:password` correctly |
114
+ | `Unauthorized! Invalid username or password` | 401 | `verify` | `verifyCredentials` callback returned `null` | Expected on wrong credentials - check your callback's lookup logic if unexpected |
191
115
 
192
- ### Strategy Registry Errors (`AuthenticationStrategyRegistry`)
116
+ ## AuthenticationStrategyRegistry (startup + runtime)
193
117
 
194
118
  Inherited from `AbstractAuthRegistry`.
195
119
 
196
- | Error Message | Status | Method | When |
197
- |---------------|--------|--------|------|
198
- | <code v-pre>[getKey] Invalid name &#124; name: {{name}}</code> | 400 | `getKey` | Strategy name is empty or falsy |
199
- | <code v-pre>[AuthenticationStrategyRegistry] No items registered</code> | 400 | `getDefaultName` | No strategies have been registered |
200
- | <code v-pre>[AuthenticationStrategyRegistry] Descriptor not found: {{name}}</code> | 400 | `resolveDescriptor` | Strategy with given name is not registered |
201
- | <code v-pre>[AuthenticationStrategyRegistry] Failed to resolve: {{name}}</code> | 400 | `resolveDescriptor` | Strategy registered but DI container returned null |
202
-
203
- ---
204
-
205
- ### Authentication Provider Errors (`AuthenticationProvider`)
206
-
207
- The middleware that executes strategies in the configured mode.
208
-
209
- | Error Message | Status | Method | When |
210
- |---------------|--------|--------|------|
211
- | <code v-pre>Authentication failed. Tried strategies: {{strategies}}</code> | 401 | `executeAnyMode` | All strategies failed in `'any'` mode - each strategy threw during `authenticate()` |
212
- | `Failed to identify authenticated user!` | 401 | `executeAllMode` | All strategies succeeded in `'all'` mode but the first strategy's `authUser.userId` is falsy |
213
- | <code v-pre>Invalid authentication mode &#124; mode: {{mode}}</code> | 500 | `createAuthenticateMiddleware` | `mode` is not `'any'` or `'all'` |
214
-
215
- ---
216
-
217
- ### Auth Controller Factory Errors
218
-
219
- | Error Message | Status | Method | When |
220
- |---------------|--------|--------|------|
221
- | `[AuthController] Failed to init auth controller \| Invalid injectable authentication service!` | 400 | `constructor` | DI could not resolve the authentication service (service key not bound) |
222
-
223
- ---
224
-
225
- ## Troubleshooting
120
+ | Message | Status | Method | Cause | Fix |
121
+ |---------|--------|--------|-------|-----|
122
+ | `[getKey] Invalid name \| name: {name}` | 400 | `getKey` | Strategy name empty or falsy | Pass a non-empty strategy name |
123
+ | `[AuthenticationStrategyRegistry] No items registered` | 400 | `getDefaultName` | No strategies registered yet | Register at least one strategy |
124
+ | `[AuthenticationStrategyRegistry] Descriptor not found: {name}` | 400 | `resolveDescriptor` | Route references a strategy name that was never registered | Register it after the component - see below |
125
+ | `[AuthenticationStrategyRegistry] Failed to resolve: {name}` | 400 | `resolveDescriptor` | Strategy registered but the container returned null | Check the strategy's own constructor dependencies |
226
126
 
227
- ### "[AuthenticateComponent] At least one of jwtOptions or basicOptions must be provided"
228
-
229
- **Cause:** The component requires at least one authentication method. Neither `JWT_OPTIONS` nor `BASIC_OPTIONS` was bound before calling `this.component(AuthenticateComponent)`.
230
-
231
- **Fix:** Bind at least one set of options before registering the component:
127
+ **Fix for "Descriptor not found":** strategies are **not** auto-registered by `AuthenticateComponent`.
232
128
 
233
129
  ```typescript
234
- // Option A: JWS (symmetric JWT)
235
- this.bind<TJWTTokenServiceOptions>({ key: AuthenticateBindingKeys.JWT_OPTIONS }).toValue({
236
- standard: JOSEStandards.JWS,
237
- options: {
238
- jwtSecret: env.get('JWT_SECRET'),
239
- getTokenExpiresFn: () => 86_400,
240
- },
241
- });
242
-
243
- // Option B: JWKS Issuer (asymmetric JWT)
244
- this.bind<TJWTTokenServiceOptions>({ key: AuthenticateBindingKeys.JWT_OPTIONS }).toValue({
245
- standard: JOSEStandards.JWKS,
246
- options: {
247
- mode: JWKSModes.ISSUER,
248
- algorithm: 'RS256',
249
- kid: 'my-key-1',
250
- keys: { driver: JWKSKeyDrivers.FILE, format: JWKSKeyFormats.PEM, private: './keys/private.pem', public: './keys/public.pem' },
251
- getTokenExpiresFn: () => 86_400,
252
- },
253
- });
254
-
255
- // Then register the component
256
130
  this.component(AuthenticateComponent);
257
- ```
258
-
259
- ### "[defineJWSAuth] Invalid jwtSecret"
260
-
261
- **Cause:** `jwtSecret` is missing, empty, or set to the default placeholder `'unknown_secret'`. The component validates this during `defineJWSAuth()`.
262
-
263
- **Fix:** Set a strong, unique JWT secret:
264
-
265
- ```bash
266
- # .env
267
- JWT_SECRET=your-strong-jwt-secret-at-least-32-chars
268
- ```
269
-
270
- ```typescript
271
- this.bind<TJWTTokenServiceOptions>({ key: AuthenticateBindingKeys.JWT_OPTIONS }).toValue({
272
- standard: JOSEStandards.JWS,
273
- options: {
274
- jwtSecret: env.get('JWT_SECRET'),
275
- getTokenExpiresFn: () => 86_400,
276
- },
277
- });
278
- ```
279
-
280
- ### "[defineJWSAuth] getTokenExpiresFn is required"
281
-
282
- **Cause:** `getTokenExpiresFn` was not provided in the JWS options.
283
-
284
- **Fix:** Include a function that returns the token expiry time in seconds:
285
-
286
- ```typescript
287
- options: {
288
- jwtSecret: env.get('JWT_SECRET'),
289
- getTokenExpiresFn: () => Number(env.get('JWT_EXPIRES_IN') || 86_400),
290
- }
291
- ```
292
-
293
- ### "[defineJWKSAuth] keys.private and keys.public are required for issuer mode"
294
-
295
- **Cause:** JWKS issuer mode requires both a private key (for signing) and a public key (for the `/certs` JWKS endpoint). One or both were not provided.
296
-
297
- **Fix:** Provide both keys in the options:
298
131
 
299
- ```typescript
300
- options: {
301
- mode: JWKSModes.ISSUER,
302
- algorithm: 'RS256',
303
- kid: 'my-key-1',
304
- keys: {
305
- driver: JWKSKeyDrivers.FILE,
306
- format: JWKSKeyFormats.PEM,
307
- private: './keys/private.pem',
308
- public: './keys/public.pem',
309
- },
310
- getTokenExpiresFn: () => 86_400,
311
- }
312
- ```
313
-
314
- ### "[defineJWKSAuth] keys.format is required and must be one of: pem, jwk"
315
-
316
- **Cause:** `keys.format` is missing or invalid. The component validates against `JWKSKeyFormats.SCHEME_SET` (values are lowercase: `'pem'`, `'jwk'`).
317
-
318
- **Fix:** Use one of the supported formats:
319
-
320
- ```typescript
321
- keys: {
322
- driver: JWKSKeyDrivers.FILE,
323
- format: JWKSKeyFormats.PEM, // or JWKSKeyFormats.JWK
324
- private: './keys/private.pem',
325
- public: './keys/public.pem',
326
- }
327
- ```
328
-
329
- ### "[defineJWKSAuth] kid is required for issuer mode"
330
-
331
- **Cause:** The Key ID (`kid`) is required for the issuer to include in the JWKS and JWT headers. It allows verifiers to identify which key was used to sign a token.
332
-
333
- **Fix:** Provide a unique key identifier:
334
-
335
- ```typescript
336
- options: {
337
- mode: JWKSModes.ISSUER,
338
- kid: 'my-service-key-2024',
339
- // ...
340
- }
341
- ```
342
-
343
- ### "[defineJWKSAuth] jwksUrl is required for verifier mode"
344
-
345
- **Cause:** JWKS verifier mode needs the URL of the issuer's `/certs` endpoint to fetch the public key set.
346
-
347
- **Fix:** Provide the JWKS endpoint URL:
348
-
349
- ```typescript
350
- this.bind<TJWTTokenServiceOptions>({ key: AuthenticateBindingKeys.JWT_OPTIONS }).toValue({
351
- standard: JOSEStandards.JWKS,
352
- options: {
353
- mode: JWKSModes.VERIFIER,
354
- jwksUrl: 'https://auth-service.example.com/certs',
355
- },
356
- });
357
- ```
358
-
359
- ### "[JWKSIssuerTokenService] Invalid JWK key material"
360
-
361
- **Cause:** When using `JWKSKeyFormats.JWK`, the private or public key content failed to parse as valid JSON, or `importJWK()` rejected it. The full error is logged at `error` level.
362
-
363
- **Fix:** Ensure your JWK keys are valid JSON objects:
364
-
365
- ```json
366
- {
367
- "kty": "RSA",
368
- "n": "...",
369
- "e": "AQAB",
370
- "d": "...",
371
- "alg": "RS256",
372
- "use": "sig"
373
- }
374
- ```
375
-
376
- If stored as files, ensure the file contains valid JSON (not PEM). If stored as text (`JWKSKeyDrivers.TEXT`), ensure the string is parseable JSON.
377
-
378
- ### "[JWKSIssuerTokenService] JWKS not initialized yet. Call getJWKSAsync() instead."
379
-
380
- **Cause:** `getJWKS()` (synchronous) was called before the lazy initialization completed. The issuer loads keys asynchronously on first use.
381
-
382
- **Fix:** Use the async variant:
383
-
384
- ```typescript
385
- const jwks = await issuerService.getJWKSAsync();
386
- ```
387
-
388
- The built-in `JWKSController` already uses `getJWKSAsync()`, so this error only occurs if you call `getJWKS()` directly in custom code.
389
-
390
- ### "[JWKSVerifierTokenService] Verifier mode cannot sign tokens"
391
-
392
- **Cause:** `generate()` was called on a `JWKSVerifierTokenService`. The verifier mode only has access to public keys (via the remote JWKS URL) and cannot sign tokens.
393
-
394
- **Fix:** Token generation should only happen on the **issuer** service. If you need both signing and verification in the same application, use `JWKSModes.ISSUER` - the issuer can both sign and verify.
395
-
396
- ### "Authentication failed. Tried strategies: jwt, jwks"
397
-
398
- **Cause:** All configured strategies failed in `'any'` mode. Each strategy attempted to authenticate the request and threw.
399
-
400
- **Fix:** Verify the client is sending the correct `Authorization` header:
401
- - For Bearer (JWS/JWKS): `Authorization: Bearer <token>`
402
- - For Basic: `Authorization: Basic <base64(username:password)>`
403
-
404
- Common causes:
405
- - Token expired
406
- - Token signed with a different key
407
- - Wrong strategy name in route config (e.g., `'jwt'` when using JWKS)
408
- - Strategy not registered (see below)
409
-
410
- ### "[AuthenticationStrategyRegistry] Descriptor not found: jwt"
411
-
412
- **Cause:** A route references strategy name `'jwt'` but no strategy with that name has been registered in the `AuthenticationStrategyRegistry`.
413
-
414
- **Fix:** Strategies are **not auto-registered** by `AuthenticateComponent`. You must manually register them after the component:
415
-
416
- ```typescript
417
- // In preConfigure() or after component registration
418
- this.component(AuthenticateComponent);
419
-
420
- // Manual strategy registration
421
132
  AuthenticationStrategyRegistry.getInstance().register({
422
133
  container: this,
423
- strategies: [
424
- { strategy: JWSAuthenticationStrategy, name: 'jwt' },
425
- ],
134
+ strategies: [{ name: Authentication.STRATEGY_JWT, strategy: JWSAuthenticationStrategy }],
426
135
  });
427
136
  ```
428
137
 
429
- See [Usage & Examples](./usage#strategy-registration) for the full registration flow.
138
+ ## AuthenticationProvider (runtime)
139
+
140
+ The middleware that executes strategies in the configured mode.
141
+
142
+ | Message | Status | Method | Cause |
143
+ |---------|--------|--------|-------|
144
+ | `Authentication failed. Tried strategies: {strategies}` | 401 | `executeAnyMode` | Every strategy failed in `'any'` mode |
145
+ | `Failed to identify authenticated user!` | 401 | `executeAllMode` | All strategies passed in `'all'` mode, but the first strategy's `userId` is falsy |
146
+ | `Invalid authentication mode \| mode: {mode}` | 500 | `createAuthenticateMiddleware` | `mode` is not `'any'` or `'all'` |
430
147
 
431
- ### "[AuthController] Failed to init auth controller | Invalid injectable authentication service!"
148
+ **Fix for "Authentication failed":** verify the client sends the right header (`Bearer <token>` or `Basic <base64>`); common causes are an expired token, a token signed with a different key, or the wrong strategy name in the route config.
432
149
 
433
- **Cause:** The auth controller factory could not resolve the authentication service from DI. The service key (configured via `controllerOpts.serviceKey`) is not bound.
150
+ ## Auth controller factory
434
151
 
435
- **Fix:** Register your `AuthenticationService` before registering the component:
152
+ | Message | Status | Method | Cause | Fix |
153
+ |---------|--------|--------|-------|-----|
154
+ | `[AuthController] Failed to init auth controller \| Invalid injectable authentication service!` | 400 | `constructor` | DI could not resolve the service at `controllerOpts.serviceKey` | Register your service before the component |
436
155
 
437
156
  ```typescript
438
- // 1. Register your auth service
439
157
  this.service(AuthenticationService);
440
158
 
441
- // 2. Configure REST options with matching service key
442
159
  this.bind<TAuthenticationRestOptions>({ key: AuthenticateBindingKeys.REST_OPTIONS }).toValue({
443
160
  useAuthController: true,
444
- controllerOpts: {
445
- restPath: '/auth',
446
- serviceKey: 'services.AuthenticationService',
447
- },
161
+ controllerOpts: { restPath: '/auth', serviceKey: 'services.AuthenticationService' },
448
162
  });
449
163
 
450
- // 3. Register component
451
164
  this.component(AuthenticateComponent);
452
165
  ```
453
166
 
454
- ### "[defineBasicAuth] verifyCredentials function is required"
455
-
456
- **Cause:** `BASIC_OPTIONS` was bound but without a `verifyCredentials` callback.
457
-
458
- **Fix:** Provide a `verifyCredentials` function:
459
-
460
- ```typescript
461
- this.bind<TBasicTokenServiceOptions>({ key: AuthenticateBindingKeys.BASIC_OPTIONS }).toValue({
462
- verifyCredentials: async ({ credentials, context }) => {
463
- const user = await userRepo.findByUsername(credentials.username);
464
- if (user && await bcrypt.compare(credentials.password, user.passwordHash)) {
465
- return { userId: user.id };
466
- }
467
- return null;
468
- },
469
- });
470
- ```
471
-
472
- ### "[verify] Invalid or expired token"
473
-
474
- **Cause:** Token verification failed. This is a sanitized error - the original error (expired, wrong signature, malformed) is logged internally but not exposed to clients.
475
-
476
- **Fix:** Check the application logs for the full error. Common causes:
477
- - Token has expired (check `exp` claim)
478
- - Token signed with a different secret/key
479
- - Token was tampered with
480
- - Algorithm mismatch between signing and verification
481
-
482
- ```bash
483
- # Look for the full error in logs
484
- grep "Failed to verify token" logs/application.log
485
- ```
486
-
487
- ---
488
-
489
- ## Error Categories
167
+ ## Error categories
490
168
 
491
169
  ```mermaid
492
170
  flowchart TB
493
- subgraph S400["Startup Errors (400)"]
494
- direction TB
495
- A1["Missing options"]
496
- A2["Invalid secrets"]
497
- A3["Missing functions"]
498
- A4["JWKS key validation"]
499
- A5["Mode validation"]
500
- A6["DI resolution"]
171
+ subgraph S400["Startup (400)"]
172
+ A1["Missing options / secrets / functions"]
173
+ A2["JWKS key + format validation"]
174
+ A3["Mode validation"]
175
+ A4["DI resolution"]
501
176
  end
502
-
503
- subgraph S401["Runtime Errors (401)"]
504
- direction TB
505
- B1["Missing header"]
506
- B2["Wrong scheme"]
507
- B3["Invalid format"]
508
- B4["Token verification"]
509
- B5["Credential verification"]
510
- B6["Strategy exhaustion"]
177
+ subgraph S401["Runtime (401)"]
178
+ B1["Missing/wrong/malformed header"]
179
+ B2["Token or credential verification"]
180
+ B3["Strategy exhaustion"]
511
181
  end
512
-
513
- subgraph S500["Structural Errors (500)"]
514
- direction TB
182
+ subgraph S500["Structural (500)"]
515
183
  C1["Unsupported operation"]
516
184
  C2["Uninitialized state"]
517
- C3["Key/file I/O errors"]
518
- C4["Invalid auth mode"]
185
+ C3["Key/file I/O"]
519
186
  end
520
187
 
521
188
  style S400 fill:#fff3cd,stroke:#ffc107
@@ -523,52 +190,8 @@ flowchart TB
523
190
  style S500 fill:#d1ecf1,stroke:#0dcaf0
524
191
  ```
525
192
 
526
- ### Startup Errors (400)
527
-
528
- These errors prevent the application from starting. They occur during component binding or DI resolution. The component uses `getError()` without an explicit status code, which defaults to **400**.
529
-
530
- | Category | Errors | When |
531
- |----------|--------|------|
532
- | Missing options | `At least one of jwtOptions or basicOptions` | No auth options bound |
533
- | Invalid secrets | `Invalid jwtSecret` | JWS secret missing or placeholder |
534
- | Missing functions | `getTokenExpiresFn is required` | No expiry function |
535
- | JWKS key validation | `keys.private and keys.public are required` | Missing key material |
536
- | JWKS format validation | `keys.format is required` | Invalid key format |
537
- | Mode validation | `Unknown JOSE standard`, `Invalid JWKS mode` | Invalid discriminated union value |
538
- | DI resolution | `Invalid injectable authentication service` | Service not registered |
539
-
540
- ::: info Why 400 and not 500?
541
- The `AuthenticateComponent` and `AbstractAuthRegistry` use `getError({ message })` without specifying `statusCode`. The `getError()` helper defaults to `statusCode: 400`. Service-level initialization errors (file I/O, key parsing) explicitly set `statusCode: 500`.
542
- :::
543
-
544
- ### Runtime Errors (401)
545
-
546
- These errors occur during request processing and return `401 Unauthorized` to clients.
547
-
548
- | Category | Errors | When |
549
- |----------|--------|------|
550
- | Missing header | `Missing authorization header` | No `Authorization` header |
551
- | Wrong scheme | `Invalid schema of request token` | Header uses wrong auth type |
552
- | Invalid format | `Invalid authorization header format` | Malformed header value |
553
- | Token verification | `Invalid or expired token` | JWT verification failed |
554
- | Credential verification | `Invalid username or password` | Basic auth credentials rejected |
555
- | Strategy exhaustion | `Authentication failed. Tried strategies:` | All strategies failed |
556
-
557
- ### Structural Errors (500)
558
-
559
- These errors indicate programming mistakes, I/O failures, or misconfiguration that should be fixed in code.
560
-
561
- | Category | Errors | When |
562
- |----------|--------|------|
563
- | Unsupported operation | `Verifier mode cannot sign tokens` | Wrong service used for signing |
564
- | Uninitialized state | `JWKS not initialized yet` | Sync access before async init |
565
- | Key/file I/O errors | `Unknown key driver`, `Invalid raw.priv key`, `Invalid JWK key material` | JWKS key loading/parsing failed |
566
- | Invalid mode | `Invalid authentication mode` | Unknown mode passed to provider |
567
-
568
- ---
569
-
570
- ## See Also
193
+ ## See also
571
194
 
572
- - [Setup & Configuration](./) -- Binding keys, options interfaces, and initial setup
573
- - [Usage & Examples](./usage) -- Securing routes, auth flows, and API endpoints
574
- - [API Reference](./api) -- Architecture, service internals, and strategy registry
195
+ - [Overview](./) - initial setup and binding keys
196
+ - [Usage & Examples](./usage) - securing routes, auth flows, and API endpoints
197
+ - [API Reference](./api) - architecture, service internals, and strategy registry