@private.me/xbind 3.0.2 → 3.0.4

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 (222) hide show
  1. package/README.md +2366 -204
  2. package/dist-standalone/_deps/mldsa-wasm/dist/mldsa.js +1 -1920
  3. package/dist-standalone/_deps/shared/cjs/errors.js +1 -729
  4. package/dist-standalone/_deps/shared/cjs/index.js +1 -463
  5. package/dist-standalone/_deps/shared/cjs/types.js +1 -315
  6. package/dist-standalone/_deps/shared/errors.js +1 -244
  7. package/dist-standalone/_deps/shared/index.js +1 -72
  8. package/dist-standalone/_deps/shared/types.js +1 -86
  9. package/dist-standalone/_deps/ux-helpers/cjs/errors.js +1 -1
  10. package/dist-standalone/_deps/ux-helpers/cjs/index.js +1 -1
  11. package/dist-standalone/_deps/ux-helpers/cjs/pagination.js +1 -1
  12. package/dist-standalone/_deps/ux-helpers/cjs/progress.js +1 -1
  13. package/dist-standalone/_deps/ux-helpers/cjs/search.js +1 -1
  14. package/dist-standalone/_deps/ux-helpers/cjs/types.js +1 -1
  15. package/dist-standalone/_deps/ux-helpers/errors.js +1 -1
  16. package/dist-standalone/_deps/ux-helpers/index.js +1 -1
  17. package/dist-standalone/_deps/ux-helpers/pagination.js +1 -1
  18. package/dist-standalone/_deps/ux-helpers/progress.js +1 -1
  19. package/dist-standalone/_deps/ux-helpers/search.js +1 -1
  20. package/dist-standalone/_deps/xchange/auto-accept.js +1 -1
  21. package/dist-standalone/_deps/xchange/cjs/auto-accept.js +1 -1
  22. package/dist-standalone/_deps/xchange/cjs/errors.js +1 -1
  23. package/dist-standalone/_deps/xchange/cjs/index.js +1 -1
  24. package/dist-standalone/_deps/xchange/cjs/invite-client.js +1 -1
  25. package/dist-standalone/_deps/xchange/cjs/lazy-init.js +1 -1
  26. package/dist-standalone/_deps/xchange/cjs/trust-integration.js +1 -1
  27. package/dist-standalone/_deps/xchange/cjs/xchange.js +1 -1
  28. package/dist-standalone/_deps/xchange/errors.js +1 -1
  29. package/dist-standalone/_deps/xchange/index.js +1 -1
  30. package/dist-standalone/_deps/xchange/invite-client.js +1 -1
  31. package/dist-standalone/_deps/xchange/lazy-init.js +1 -1
  32. package/dist-standalone/_deps/xchange/trust-integration.js +1 -1
  33. package/dist-standalone/_deps/xchange/xchange.js +1 -1
  34. package/dist-standalone/_deps/xregistry/cjs/discovery.js +1 -1
  35. package/dist-standalone/_deps/xregistry/cjs/errors.js +1 -1
  36. package/dist-standalone/_deps/xregistry/cjs/index.js +1 -1
  37. package/dist-standalone/_deps/xregistry/cjs/registry.js +1 -1
  38. package/dist-standalone/_deps/xregistry/cjs/schema.js +1 -1
  39. package/dist-standalone/_deps/xregistry/cjs/types.js +1 -1
  40. package/dist-standalone/_deps/xregistry/discovery.js +1 -1
  41. package/dist-standalone/_deps/xregistry/errors.js +1 -1
  42. package/dist-standalone/_deps/xregistry/index.js +1 -1
  43. package/dist-standalone/_deps/xregistry/registry.js +1 -1
  44. package/dist-standalone/_deps/xregistry/schema.js +1 -1
  45. package/dist-standalone/_deps/xregistry/types.js +1 -1
  46. package/dist-standalone/agent-call.d.ts +2 -2
  47. package/dist-standalone/agent-call.js +1 -659
  48. package/dist-standalone/agent-sdk.js +1 -328
  49. package/dist-standalone/agent.d.ts +2 -0
  50. package/dist-standalone/agent.js +1 -1800
  51. package/dist-standalone/approval.js +1 -193
  52. package/dist-standalone/async-iterators.d.ts +3 -3
  53. package/dist-standalone/async-iterators.js +1 -382
  54. package/dist-standalone/auth.js +1 -219
  55. package/dist-standalone/auto-accept.js +1 -229
  56. package/dist-standalone/backup-config.js +1 -201
  57. package/dist-standalone/backup.js +1 -326
  58. package/dist-standalone/batch-operations.js +1 -388
  59. package/dist-standalone/cancellation.js +1 -477
  60. package/dist-standalone/checkpoint.js +1 -186
  61. package/dist-standalone/circuit-breaker.js +1 -468
  62. package/dist-standalone/cjs/agent-call.js +1 -701
  63. package/dist-standalone/cjs/agent-sdk.js +1 -332
  64. package/dist-standalone/cjs/agent.js +1 -1837
  65. package/dist-standalone/cjs/approval.js +1 -199
  66. package/dist-standalone/cjs/async-iterators.js +1 -392
  67. package/dist-standalone/cjs/auth.js +1 -225
  68. package/dist-standalone/cjs/auto-accept.js +1 -233
  69. package/dist-standalone/cjs/backup-config.js +1 -207
  70. package/dist-standalone/cjs/backup.js +1 -330
  71. package/dist-standalone/cjs/batch-operations.js +1 -397
  72. package/dist-standalone/cjs/cancellation.js +1 -490
  73. package/dist-standalone/cjs/checkpoint.js +1 -193
  74. package/dist-standalone/cjs/circuit-breaker.js +1 -476
  75. package/dist-standalone/cjs/cli/init.js +1 -492
  76. package/dist-standalone/cjs/config-validation.js +1 -522
  77. package/dist-standalone/cjs/connect.js +1 -312
  78. package/dist-standalone/cjs/connection-pool.js +1 -506
  79. package/dist-standalone/cjs/correlation-id.js +1 -339
  80. package/dist-standalone/cjs/crypto-utils.js +1 -176
  81. package/dist-standalone/cjs/debug-mode.js +1 -534
  82. package/dist-standalone/cjs/did-document.js +1 -101
  83. package/dist-standalone/cjs/did-privateme.js +1 -130
  84. package/dist-standalone/cjs/did-web.js +1 -201
  85. package/dist-standalone/cjs/discovery.js +1 -462
  86. package/dist-standalone/cjs/dual-mode.js +1 -251
  87. package/dist-standalone/cjs/email-templates.js +1 -313
  88. package/dist-standalone/cjs/email-transport.js +1 -239
  89. package/dist-standalone/cjs/envelope.js +1 -538
  90. package/dist-standalone/cjs/errors.js +1 -913
  91. package/dist-standalone/cjs/event-emitter.js +1 -461
  92. package/dist-standalone/cjs/gateway-state.js +1 -55
  93. package/dist-standalone/cjs/gateway-transport.js +1 -120
  94. package/dist-standalone/cjs/graceful-degradation.js +1 -403
  95. package/dist-standalone/cjs/guardrails.js +1 -223
  96. package/dist-standalone/cjs/health-check.js +1 -336
  97. package/dist-standalone/cjs/http-compat.js +1 -272
  98. package/dist-standalone/cjs/http-status-map.js +1 -571
  99. package/dist-standalone/cjs/identity.js +1 -645
  100. package/dist-standalone/cjs/index.js +1 -406
  101. package/dist-standalone/cjs/invitation.js +1 -421
  102. package/dist-standalone/cjs/invite.js +1 -328
  103. package/dist-standalone/cjs/key-agreement.js +1 -335
  104. package/dist-standalone/cjs/lazy-init.js +1 -300
  105. package/dist-standalone/cjs/logger.js +1 -291
  106. package/dist-standalone/cjs/loopback-transport.js +1 -0
  107. package/dist-standalone/cjs/mdns-discovery.js +1 -202
  108. package/dist-standalone/cjs/nonce-store.js +1 -80
  109. package/dist-standalone/cjs/pairing-manager.js +1 -223
  110. package/dist-standalone/cjs/plugin-system.js +1 -264
  111. package/dist-standalone/cjs/plugins/logging.js +1 -168
  112. package/dist-standalone/cjs/plugins/metrics.js +1 -181
  113. package/dist-standalone/cjs/plugins/validation.js +1 -302
  114. package/dist-standalone/cjs/policy.js +1 -320
  115. package/dist-standalone/cjs/progress-callbacks.js +1 -583
  116. package/dist-standalone/cjs/redis-nonce-store.js +1 -76
  117. package/dist-standalone/cjs/registry-middleware.js +1 -50
  118. package/dist-standalone/cjs/retry-strategies.js +1 -544
  119. package/dist-standalone/cjs/retry-transport.js +1 -102
  120. package/dist-standalone/cjs/runtime/browser.js +1 -533
  121. package/dist-standalone/cjs/runtime/edge.js +1 -526
  122. package/dist-standalone/cjs/runtime/react-native.js +1 -394
  123. package/dist-standalone/cjs/security-policy.js +1 -245
  124. package/dist-standalone/cjs/serialization.js +1 -1040
  125. package/dist-standalone/cjs/split-channel.js +1 -225
  126. package/dist-standalone/cjs/subscription-proof.js +1 -230
  127. package/dist-standalone/cjs/succession.js +1 -148
  128. package/dist-standalone/cjs/timeouts.js +1 -412
  129. package/dist-standalone/cjs/trace-context.js +1 -424
  130. package/dist-standalone/cjs/trace-spans.js +1 -495
  131. package/dist-standalone/cjs/transport.js +1 -63
  132. package/dist-standalone/cjs/trust-registry.js +1 -991
  133. package/dist-standalone/cjs/types/error-response.js +1 -56
  134. package/dist-standalone/cjs/vault-auth.js +1 -178
  135. package/dist-standalone/cjs/vault-store-loader.js +1 -194
  136. package/dist-standalone/cjs/verify.js +1 -25
  137. package/dist-standalone/cjs/version-info.js +1 -543
  138. package/dist-standalone/cjs/xfetch.js +1 -340
  139. package/dist-standalone/cli/init.js +1 -455
  140. package/dist-standalone/cli/setup.js +1 -514
  141. package/dist-standalone/cli/types.js +1 -27
  142. package/dist-standalone/cli/xbind.js +1 -148
  143. package/dist-standalone/config-validation.js +1 -513
  144. package/dist-standalone/connect.js +1 -274
  145. package/dist-standalone/connection-pool.js +1 -500
  146. package/dist-standalone/correlation-id.js +1 -326
  147. package/dist-standalone/crypto-utils.d.ts +2 -7
  148. package/dist-standalone/crypto-utils.js +1 -157
  149. package/dist-standalone/debug-mode.js +1 -510
  150. package/dist-standalone/did-document.js +1 -96
  151. package/dist-standalone/did-privateme.js +1 -121
  152. package/dist-standalone/did-web.js +1 -196
  153. package/dist-standalone/discovery.js +1 -458
  154. package/dist-standalone/dual-mode.js +1 -247
  155. package/dist-standalone/email-templates.js +1 -309
  156. package/dist-standalone/email-transport.d.ts +2 -2
  157. package/dist-standalone/email-transport.js +1 -232
  158. package/dist-standalone/envelope.js +1 -525
  159. package/dist-standalone/errors.d.ts +13 -3
  160. package/dist-standalone/errors.js +1 -896
  161. package/dist-standalone/event-emitter.js +1 -456
  162. package/dist-standalone/gateway-state.d.ts +1 -1
  163. package/dist-standalone/gateway-state.js +1 -51
  164. package/dist-standalone/gateway-transport.js +1 -116
  165. package/dist-standalone/graceful-degradation.js +1 -396
  166. package/dist-standalone/guardrails.js +1 -216
  167. package/dist-standalone/health-check.d.ts +5 -1
  168. package/dist-standalone/health-check.js +1 -332
  169. package/dist-standalone/http-compat.d.ts +1 -1
  170. package/dist-standalone/http-compat.js +1 -267
  171. package/dist-standalone/http-status-map.js +1 -561
  172. package/dist-standalone/identity.js +1 -619
  173. package/dist-standalone/index.d.ts +15 -4
  174. package/dist-standalone/index.js +1 -78
  175. package/dist-standalone/invitation.js +1 -415
  176. package/dist-standalone/invite.js +1 -324
  177. package/dist-standalone/key-agreement.js +1 -325
  178. package/dist-standalone/lazy-init.d.ts +11 -6
  179. package/dist-standalone/lazy-init.js +1 -295
  180. package/dist-standalone/logger.js +1 -285
  181. package/dist-standalone/loopback-transport.d.ts +87 -0
  182. package/dist-standalone/loopback-transport.js +1 -0
  183. package/dist-standalone/mdns-discovery.js +1 -195
  184. package/dist-standalone/nonce-store.js +1 -76
  185. package/dist-standalone/pairing-manager.js +1 -219
  186. package/dist-standalone/plugin-system.js +1 -257
  187. package/dist-standalone/plugins/logging.js +1 -163
  188. package/dist-standalone/plugins/metrics.d.ts +4 -4
  189. package/dist-standalone/plugins/metrics.js +1 -176
  190. package/dist-standalone/plugins/validation.js +1 -297
  191. package/dist-standalone/policy.js +1 -315
  192. package/dist-standalone/progress-callbacks.js +1 -576
  193. package/dist-standalone/redis-nonce-store.js +1 -72
  194. package/dist-standalone/registry-middleware.js +1 -47
  195. package/dist-standalone/retry-strategies.js +1 -534
  196. package/dist-standalone/retry-transport.js +1 -98
  197. package/dist-standalone/runtime/browser.js +1 -516
  198. package/dist-standalone/runtime/edge.js +1 -511
  199. package/dist-standalone/runtime/react-native.d.ts +1 -1
  200. package/dist-standalone/runtime/react-native.js +1 -383
  201. package/dist-standalone/security-policy.js +1 -239
  202. package/dist-standalone/serialization.js +1 -1031
  203. package/dist-standalone/split-channel.d.ts +1 -1
  204. package/dist-standalone/split-channel.js +1 -219
  205. package/dist-standalone/subscription-proof.js +1 -224
  206. package/dist-standalone/succession.js +1 -142
  207. package/dist-standalone/timeouts.js +1 -398
  208. package/dist-standalone/trace-context.js +1 -414
  209. package/dist-standalone/trace-spans.js +1 -488
  210. package/dist-standalone/transport.d.ts +1 -1
  211. package/dist-standalone/transport.js +1 -59
  212. package/dist-standalone/trust-registry.d.ts +3 -3
  213. package/dist-standalone/trust-registry.js +1 -950
  214. package/dist-standalone/types/error-response.js +1 -52
  215. package/dist-standalone/vault-auth.js +1 -174
  216. package/dist-standalone/vault-store-loader.d.ts +9 -0
  217. package/dist-standalone/vault-store-loader.js +1 -187
  218. package/dist-standalone/verify.js +1 -16
  219. package/dist-standalone/version-info.js +1 -530
  220. package/dist-standalone/xfetch.js +1 -335
  221. package/package.json +1 -1
  222. package/share1.dat +0 -0
@@ -1,571 +1 @@
1
- "use strict";
2
- /**
3
- * @module http-status-map
4
- * Maps xBind error codes to HTTP status codes for REST API responses.
5
- *
6
- * This mapping provides:
7
- * - Consistent HTTP status codes for all 52 xBind error codes
8
- * - Retryability information for client retry logic
9
- * - Error categorization (client vs server errors)
10
- * - Human-readable status text
11
- *
12
- * Based on RFC 9110 HTTP Semantics and REST API best practices.
13
- *
14
- * @example
15
- * ```typescript
16
- * import { getHttpStatus, isRetryable } from '@private.me/xbind/http-status-map';
17
- *
18
- * const status = getHttpStatus('VERIFY_FAILED'); // 401
19
- * const canRetry = isRetryable('NETWORK_ERROR'); // true
20
- * ```
21
- */
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.HTTP_STATUS_MAP = void 0;
24
- exports.getHttpStatus = getHttpStatus;
25
- exports.getStatusText = getStatusText;
26
- exports.isRetryable = isRetryable;
27
- exports.getMapping = getMapping;
28
- exports.getErrorCodesByCategory = getErrorCodesByCategory;
29
- exports.getRetryableErrorCodes = getRetryableErrorCodes;
30
- exports.validateCoverage = validateCoverage;
31
- /**
32
- * Complete mapping of xBind error codes to HTTP status codes.
33
- * All 52 error codes are mapped for 100% coverage.
34
- */
35
- exports.HTTP_STATUS_MAP = {
36
- // ============================================================================
37
- // IDENTITY (8 error codes)
38
- // ============================================================================
39
- KEYGEN_FAILED: {
40
- statusCode: 500,
41
- statusText: 'Internal Server Error',
42
- retryable: true,
43
- errorType: 'Server',
44
- category: 'Identity',
45
- rationale: 'Server crypto initialization failure - client should retry',
46
- },
47
- SIGN_FAILED: {
48
- statusCode: 500,
49
- statusText: 'Internal Server Error',
50
- retryable: false,
51
- errorType: 'Server',
52
- category: 'Identity',
53
- rationale: 'Server key corruption - requires admin intervention',
54
- },
55
- VERIFY_FAILED: {
56
- statusCode: 401,
57
- statusText: 'Unauthorized',
58
- retryable: false,
59
- errorType: 'Client',
60
- category: 'Identity',
61
- rationale: 'Invalid signature - authentication failure',
62
- },
63
- INVALID_DID: {
64
- statusCode: 400,
65
- statusText: 'Bad Request',
66
- retryable: false,
67
- errorType: 'Client',
68
- category: 'Identity',
69
- rationale: 'Malformed DID format - client validation error',
70
- },
71
- INVALID_KEY_LENGTH: {
72
- statusCode: 400,
73
- statusText: 'Bad Request',
74
- retryable: false,
75
- errorType: 'Client',
76
- category: 'Identity',
77
- rationale: 'Invalid key material size - client validation error',
78
- },
79
- EXPORT_FAILED: {
80
- statusCode: 500,
81
- statusText: 'Internal Server Error',
82
- retryable: true,
83
- errorType: 'Server',
84
- category: 'Identity',
85
- rationale: 'Crypto API failure - transient server issue',
86
- },
87
- IMPORT_FAILED: {
88
- statusCode: 400,
89
- statusText: 'Bad Request',
90
- retryable: false,
91
- errorType: 'Client',
92
- category: 'Identity',
93
- rationale: 'Invalid PKCS8 format - client validation error',
94
- },
95
- // ============================================================================
96
- // ENVELOPE (7 error codes)
97
- // ============================================================================
98
- INVALID_VERSION: {
99
- statusCode: 400,
100
- statusText: 'Bad Request',
101
- retryable: false,
102
- errorType: 'Client',
103
- category: 'Envelope',
104
- rationale: 'Unsupported protocol version - client must upgrade',
105
- },
106
- INVALID_ALG: {
107
- statusCode: 400,
108
- statusText: 'Bad Request',
109
- retryable: false,
110
- errorType: 'Client',
111
- category: 'Envelope',
112
- rationale: 'Unsupported algorithm - client must use AES-256-GCM',
113
- },
114
- INVALID_NONCE: {
115
- statusCode: 400,
116
- statusText: 'Bad Request',
117
- retryable: false,
118
- errorType: 'Client',
119
- category: 'Envelope',
120
- rationale: 'Missing or invalid nonce - client validation error',
121
- },
122
- INVALID_FIELDS: {
123
- statusCode: 400,
124
- statusText: 'Bad Request',
125
- retryable: false,
126
- errorType: 'Client',
127
- category: 'Envelope',
128
- rationale: 'Missing required envelope fields - client validation error',
129
- },
130
- ENCRYPT_FAILED: {
131
- statusCode: 500,
132
- statusText: 'Internal Server Error',
133
- retryable: true,
134
- errorType: 'Server',
135
- category: 'Envelope',
136
- rationale: 'Server encryption failure - transient issue',
137
- },
138
- DECRYPT_FAILED: {
139
- statusCode: 401,
140
- statusText: 'Unauthorized',
141
- retryable: false,
142
- errorType: 'Client',
143
- category: 'Envelope',
144
- rationale: 'Decryption failed - wrong key or corrupted data',
145
- },
146
- PARSE_FAILED: {
147
- statusCode: 400,
148
- statusText: 'Bad Request',
149
- retryable: false,
150
- errorType: 'Client',
151
- category: 'Envelope',
152
- rationale: 'Malformed JSON envelope - client validation error',
153
- },
154
- // ============================================================================
155
- // TRANSPORT (4 error codes)
156
- // ============================================================================
157
- SEND_FAILED: {
158
- statusCode: 503,
159
- statusText: 'Service Unavailable',
160
- retryable: true,
161
- errorType: 'Server',
162
- category: 'Transport',
163
- rationale: 'Network send failure - retry with backoff',
164
- },
165
- NETWORK_ERROR: {
166
- statusCode: 503,
167
- statusText: 'Service Unavailable',
168
- retryable: true,
169
- errorType: 'Server',
170
- category: 'Transport',
171
- rationale: 'Network connectivity issue - retry with backoff',
172
- },
173
- RECIPIENT_UNREACHABLE: {
174
- statusCode: 503,
175
- statusText: 'Service Unavailable',
176
- retryable: true,
177
- errorType: 'Server',
178
- category: 'Transport',
179
- rationale: 'Recipient offline or unreachable - retry later',
180
- },
181
- TIMEOUT: {
182
- statusCode: 504,
183
- statusText: 'Gateway Timeout',
184
- retryable: true,
185
- errorType: 'Server',
186
- category: 'Transport',
187
- rationale: 'Request timed out - increase timeout and retry',
188
- },
189
- // ============================================================================
190
- // REGISTRY (3 error codes)
191
- // ============================================================================
192
- NOT_FOUND: {
193
- statusCode: 404,
194
- statusText: 'Not Found',
195
- retryable: false,
196
- errorType: 'Client',
197
- category: 'Registry',
198
- rationale: 'Agent not in registry - recipient must register first',
199
- },
200
- ALREADY_REGISTERED: {
201
- statusCode: 409,
202
- statusText: 'Conflict',
203
- retryable: false,
204
- errorType: 'Client',
205
- category: 'Registry',
206
- rationale: 'DID already exists - use updateAgent instead',
207
- },
208
- REVOKED: {
209
- statusCode: 403,
210
- statusText: 'Forbidden',
211
- retryable: false,
212
- errorType: 'Client',
213
- category: 'Registry',
214
- rationale: 'Agent revoked - contact admin for re-registration',
215
- },
216
- // ============================================================================
217
- // KEY AGREEMENT (8 error codes)
218
- // ============================================================================
219
- DERIVE_FAILED: {
220
- statusCode: 500,
221
- statusText: 'Internal Server Error',
222
- retryable: true,
223
- errorType: 'Server',
224
- category: 'Key Agreement',
225
- rationale: 'ECDH derivation failure - transient crypto issue',
226
- },
227
- KEM_ENCAPSULATE_FAILED: {
228
- statusCode: 500,
229
- statusText: 'Internal Server Error',
230
- retryable: true,
231
- errorType: 'Server',
232
- category: 'Key Agreement',
233
- rationale: 'ML-KEM encapsulation failure - transient crypto issue',
234
- },
235
- KEM_DECAPSULATE_FAILED: {
236
- statusCode: 401,
237
- statusText: 'Unauthorized',
238
- retryable: false,
239
- errorType: 'Client',
240
- category: 'Key Agreement',
241
- rationale: 'ML-KEM decapsulation failed - wrong ciphertext',
242
- },
243
- HKDF_FAILED: {
244
- statusCode: 500,
245
- statusText: 'Internal Server Error',
246
- retryable: true,
247
- errorType: 'Server',
248
- category: 'Key Agreement',
249
- rationale: 'HKDF derivation failure - transient crypto issue',
250
- },
251
- MLKEM_NOT_AVAILABLE: {
252
- statusCode: 400,
253
- statusText: 'Bad Request',
254
- retryable: false,
255
- errorType: 'Client',
256
- category: 'Key Agreement',
257
- rationale: 'Post-quantum not enabled - client must configure',
258
- },
259
- PQ_SIGN_FAILED: {
260
- statusCode: 500,
261
- statusText: 'Internal Server Error',
262
- retryable: true,
263
- errorType: 'Server',
264
- category: 'Key Agreement',
265
- rationale: 'ML-DSA signing failure - transient crypto issue',
266
- },
267
- PQ_VERIFY_FAILED: {
268
- statusCode: 401,
269
- statusText: 'Unauthorized',
270
- retryable: false,
271
- errorType: 'Client',
272
- category: 'Key Agreement',
273
- rationale: 'ML-DSA verification failed - invalid signature',
274
- },
275
- // ============================================================================
276
- // SPLIT CHANNEL (6 error codes)
277
- // ============================================================================
278
- SPLIT_FAILED: {
279
- statusCode: 500,
280
- statusText: 'Internal Server Error',
281
- retryable: true,
282
- errorType: 'Server',
283
- category: 'Split Channel',
284
- rationale: 'XorIDA split failure - transient issue',
285
- },
286
- INSUFFICIENT_SHARES: {
287
- statusCode: 400,
288
- statusText: 'Bad Request',
289
- retryable: false,
290
- errorType: 'Client',
291
- category: 'Split Channel',
292
- rationale: 'Not enough shares - client must collect more',
293
- },
294
- INCONSISTENT_SHARES: {
295
- statusCode: 400,
296
- statusText: 'Bad Request',
297
- retryable: false,
298
- errorType: 'Client',
299
- category: 'Split Channel',
300
- rationale: 'Mismatched shares - client validation error',
301
- },
302
- HMAC_VERIFICATION_FAILED: {
303
- statusCode: 401,
304
- statusText: 'Unauthorized',
305
- retryable: false,
306
- errorType: 'Client',
307
- category: 'Split Channel',
308
- rationale: 'Share tampered with - security violation',
309
- },
310
- UNPAD_FAILED: {
311
- statusCode: 500,
312
- statusText: 'Internal Server Error',
313
- retryable: false,
314
- errorType: 'Server',
315
- category: 'Split Channel',
316
- rationale: 'Padding removal error - data corruption',
317
- },
318
- INVALID_SHARE_DATA: {
319
- statusCode: 400,
320
- statusText: 'Bad Request',
321
- retryable: false,
322
- errorType: 'Client',
323
- category: 'Split Channel',
324
- rationale: 'Malformed share format - client validation error',
325
- },
326
- // ============================================================================
327
- // XCHANGE (4 error codes)
328
- // ============================================================================
329
- XCHANGE_KEYGEN_FAILED: {
330
- statusCode: 500,
331
- statusText: 'Internal Server Error',
332
- retryable: true,
333
- errorType: 'Server',
334
- category: 'Xchange',
335
- rationale: 'Key generation failure - transient crypto issue',
336
- },
337
- XCHANGE_ENCRYPT_FAILED: {
338
- statusCode: 500,
339
- statusText: 'Internal Server Error',
340
- retryable: true,
341
- errorType: 'Server',
342
- category: 'Xchange',
343
- rationale: 'Bundle encryption failure - transient crypto issue',
344
- },
345
- XCHANGE_DECRYPT_FAILED: {
346
- statusCode: 401,
347
- statusText: 'Unauthorized',
348
- retryable: false,
349
- errorType: 'Client',
350
- category: 'Xchange',
351
- rationale: 'Bundle decryption failed - wrong key',
352
- },
353
- INVALID_BUNDLE: {
354
- statusCode: 400,
355
- statusText: 'Bad Request',
356
- retryable: false,
357
- errorType: 'Client',
358
- category: 'Xchange',
359
- rationale: 'Malformed bundle format - client validation error',
360
- },
361
- // ============================================================================
362
- // AGENT (12 error codes)
363
- // ============================================================================
364
- IDENTITY_FAILED: {
365
- statusCode: 500,
366
- statusText: 'Internal Server Error',
367
- retryable: true,
368
- errorType: 'Server',
369
- category: 'Agent',
370
- rationale: 'Agent identity creation failed - transient issue',
371
- },
372
- REGISTRATION_FAILED: {
373
- statusCode: 503,
374
- statusText: 'Service Unavailable',
375
- retryable: true,
376
- errorType: 'Server',
377
- category: 'Agent',
378
- rationale: 'Registry unavailable - retry with backoff',
379
- },
380
- RECIPIENT_NOT_FOUND: {
381
- statusCode: 404,
382
- statusText: 'Not Found',
383
- retryable: false,
384
- errorType: 'Client',
385
- category: 'Agent',
386
- rationale: 'Recipient not in registry - recipient must register',
387
- },
388
- RECIPIENT_REVOKED: {
389
- statusCode: 403,
390
- statusText: 'Forbidden',
391
- retryable: false,
392
- errorType: 'Client',
393
- category: 'Agent',
394
- rationale: 'Recipient revoked - contact admin',
395
- },
396
- KEY_AGREEMENT_FAILED: {
397
- statusCode: 500,
398
- statusText: 'Internal Server Error',
399
- retryable: true,
400
- errorType: 'Server',
401
- category: 'Agent',
402
- rationale: 'Key agreement failure - transient crypto issue',
403
- },
404
- ENVELOPE_FAILED: {
405
- statusCode: 500,
406
- statusText: 'Internal Server Error',
407
- retryable: true,
408
- errorType: 'Server',
409
- category: 'Agent',
410
- rationale: 'Envelope creation failed - transient issue',
411
- },
412
- VERIFICATION_FAILED: {
413
- statusCode: 401,
414
- statusText: 'Unauthorized',
415
- retryable: false,
416
- errorType: 'Client',
417
- category: 'Agent',
418
- rationale: 'Envelope verification failed - authentication error',
419
- },
420
- REPLAY_DETECTED: {
421
- statusCode: 403,
422
- statusText: 'Forbidden',
423
- retryable: false,
424
- errorType: 'Client',
425
- category: 'Agent',
426
- rationale: 'Replay attack detected - security violation',
427
- },
428
- SCOPE_DENIED: {
429
- statusCode: 403,
430
- statusText: 'Forbidden',
431
- retryable: false,
432
- errorType: 'Client',
433
- category: 'Agent',
434
- rationale: 'Sender lacks scope permission - authorization failure',
435
- },
436
- RECEIVER_SCOPE_DENIED: {
437
- statusCode: 403,
438
- statusText: 'Forbidden',
439
- retryable: false,
440
- errorType: 'Client',
441
- category: 'Agent',
442
- rationale: 'Recipient rejects scope - authorization failure',
443
- },
444
- TIMESTAMP_EXPIRED: {
445
- statusCode: 400,
446
- statusText: 'Bad Request',
447
- retryable: true,
448
- errorType: 'Client',
449
- category: 'Agent',
450
- rationale: 'Timestamp outside window - clock sync issue (retryable)',
451
- },
452
- };
453
- /**
454
- * Get HTTP status code for a given xBind error code.
455
- * Handles colon-separated sub-codes (e.g., 'DECRYPT_FAILED:KEY_AGREEMENT').
456
- *
457
- * @param errorCode - xBind error code (e.g., 'VERIFY_FAILED')
458
- * @returns HTTP status code (e.g., 401) or 500 if unknown
459
- *
460
- * @example
461
- * ```typescript
462
- * getHttpStatus('VERIFY_FAILED') // 401
463
- * getHttpStatus('DECRYPT_FAILED:NETWORK') // 401 (ignores sub-code)
464
- * getHttpStatus('UNKNOWN_ERROR') // 500 (fallback)
465
- * ```
466
- */
467
- function getHttpStatus(errorCode) {
468
- const baseCode = errorCode.split(':')[0] ?? errorCode;
469
- const mapping = exports.HTTP_STATUS_MAP[baseCode];
470
- return mapping?.statusCode ?? 500; // Default to 500 for unknown errors
471
- }
472
- /**
473
- * Get HTTP status text for a given xBind error code.
474
- *
475
- * @param errorCode - xBind error code (e.g., 'VERIFY_FAILED')
476
- * @returns HTTP status text (e.g., 'Unauthorized') or 'Internal Server Error' if unknown
477
- *
478
- * @example
479
- * ```typescript
480
- * getStatusText('VERIFY_FAILED') // 'Unauthorized'
481
- * getStatusText('NOT_FOUND') // 'Not Found'
482
- * ```
483
- */
484
- function getStatusText(errorCode) {
485
- const baseCode = errorCode.split(':')[0] ?? errorCode;
486
- const mapping = exports.HTTP_STATUS_MAP[baseCode];
487
- return mapping?.statusText ?? 'Internal Server Error';
488
- }
489
- /**
490
- * Check if an error is retryable by the client.
491
- *
492
- * @param errorCode - xBind error code (e.g., 'NETWORK_ERROR')
493
- * @returns True if the client should retry the operation
494
- *
495
- * @example
496
- * ```typescript
497
- * isRetryable('NETWORK_ERROR') // true (503 - retry with backoff)
498
- * isRetryable('VERIFY_FAILED') // false (401 - authentication failure)
499
- * isRetryable('KEYGEN_FAILED') // true (500 - transient server issue)
500
- * ```
501
- */
502
- function isRetryable(errorCode) {
503
- const baseCode = errorCode.split(':')[0] ?? errorCode;
504
- const mapping = exports.HTTP_STATUS_MAP[baseCode];
505
- return mapping?.retryable ?? false; // Default to non-retryable for unknown errors
506
- }
507
- /**
508
- * Get complete mapping information for an error code.
509
- *
510
- * @param errorCode - xBind error code (e.g., 'VERIFY_FAILED')
511
- * @returns Complete mapping information or null if not found
512
- *
513
- * @example
514
- * ```typescript
515
- * const mapping = getMapping('VERIFY_FAILED');
516
- * if (mapping) {
517
- * console.log(`${mapping.statusCode} ${mapping.statusText}`);
518
- * console.log(`Retryable: ${mapping.retryable}`);
519
- * console.log(`Rationale: ${mapping.rationale}`);
520
- * }
521
- * ```
522
- */
523
- function getMapping(errorCode) {
524
- const baseCode = errorCode.split(':')[0] ?? errorCode;
525
- return exports.HTTP_STATUS_MAP[baseCode] ?? null;
526
- }
527
- /**
528
- * Get all error codes in a specific category.
529
- *
530
- * @param category - Error category (e.g., 'Identity', 'Transport')
531
- * @returns Array of error codes in that category
532
- *
533
- * @example
534
- * ```typescript
535
- * const identityErrors = getErrorCodesByCategory('Identity');
536
- * // ['KEYGEN_FAILED', 'SIGN_FAILED', 'VERIFY_FAILED', ...]
537
- * ```
538
- */
539
- function getErrorCodesByCategory(category) {
540
- return Object.entries(exports.HTTP_STATUS_MAP)
541
- .filter(([_, mapping]) => mapping.category === category)
542
- .map(([code]) => code);
543
- }
544
- /**
545
- * Get all retryable error codes.
546
- *
547
- * @returns Array of error codes that are retryable
548
- *
549
- * @example
550
- * ```typescript
551
- * const retryableErrors = getRetryableErrorCodes();
552
- * // ['KEYGEN_FAILED', 'EXPORT_FAILED', 'ENCRYPT_FAILED', ...]
553
- * ```
554
- */
555
- function getRetryableErrorCodes() {
556
- return Object.entries(exports.HTTP_STATUS_MAP)
557
- .filter(([_, mapping]) => mapping.retryable)
558
- .map(([code]) => code);
559
- }
560
- /**
561
- * Validate that all error codes from the CSV are mapped.
562
- * This function is used for testing purposes to ensure 100% coverage.
563
- *
564
- * @param csvErrorCodes - Array of error codes from the CSV file
565
- * @returns Array of missing error codes (empty if all mapped)
566
- *
567
- * @internal
568
- */
569
- function validateCoverage(csvErrorCodes) {
570
- return csvErrorCodes.filter((code) => !exports.HTTP_STATUS_MAP[code]);
571
- }
1
+ "use strict";function getHttpStatus(e){const t=e.split(":")[0]??e,r=exports.HTTP_STATUS_MAP[t];return r?.statusCode??500}function getStatusText(e){const t=e.split(":")[0]??e,r=exports.HTTP_STATUS_MAP[t];return r?.statusText??"Internal Server Error"}function isRetryable(e){const t=e.split(":")[0]??e,r=exports.HTTP_STATUS_MAP[t];return r?.retryable??!1}function getMapping(e){const t=e.split(":")[0]??e;return exports.HTTP_STATUS_MAP[t]??null}function getErrorCodesByCategory(e){return Object.entries(exports.HTTP_STATUS_MAP).filter(([t,r])=>r.category===e).map(([e])=>e)}function getRetryableErrorCodes(){return Object.entries(exports.HTTP_STATUS_MAP).filter(([e,t])=>t.retryable).map(([e])=>e)}function validateCoverage(e){return e.filter(e=>!exports.HTTP_STATUS_MAP[e])}Object.defineProperty(exports,"__esModule",{value:!0}),exports.HTTP_STATUS_MAP=void 0,exports.getHttpStatus=getHttpStatus,exports.getStatusText=getStatusText,exports.isRetryable=isRetryable,exports.getMapping=getMapping,exports.getErrorCodesByCategory=getErrorCodesByCategory,exports.getRetryableErrorCodes=getRetryableErrorCodes,exports.validateCoverage=validateCoverage,exports.HTTP_STATUS_MAP={KEYGEN_FAILED:{statusCode:500,statusText:"Internal Server Error",retryable:!0,errorType:"Server",category:"Identity",rationale:"Server crypto initialization failure - client should retry"},SIGN_FAILED:{statusCode:500,statusText:"Internal Server Error",retryable:!1,errorType:"Server",category:"Identity",rationale:"Server key corruption - requires admin intervention"},VERIFY_FAILED:{statusCode:401,statusText:"Unauthorized",retryable:!1,errorType:"Client",category:"Identity",rationale:"Invalid signature - authentication failure"},INVALID_DID:{statusCode:400,statusText:"Bad Request",retryable:!1,errorType:"Client",category:"Identity",rationale:"Malformed DID format - client validation error"},INVALID_KEY_LENGTH:{statusCode:400,statusText:"Bad Request",retryable:!1,errorType:"Client",category:"Identity",rationale:"Invalid key material size - client validation error"},EXPORT_FAILED:{statusCode:500,statusText:"Internal Server Error",retryable:!0,errorType:"Server",category:"Identity",rationale:"Crypto API failure - transient server issue"},IMPORT_FAILED:{statusCode:400,statusText:"Bad Request",retryable:!1,errorType:"Client",category:"Identity",rationale:"Invalid PKCS8 format - client validation error"},INVALID_VERSION:{statusCode:400,statusText:"Bad Request",retryable:!1,errorType:"Client",category:"Envelope",rationale:"Unsupported protocol version - client must upgrade"},INVALID_ALG:{statusCode:400,statusText:"Bad Request",retryable:!1,errorType:"Client",category:"Envelope",rationale:"Unsupported algorithm - client must use AES-256-GCM"},INVALID_NONCE:{statusCode:400,statusText:"Bad Request",retryable:!1,errorType:"Client",category:"Envelope",rationale:"Missing or invalid nonce - client validation error"},INVALID_FIELDS:{statusCode:400,statusText:"Bad Request",retryable:!1,errorType:"Client",category:"Envelope",rationale:"Missing required envelope fields - client validation error"},ENCRYPT_FAILED:{statusCode:500,statusText:"Internal Server Error",retryable:!0,errorType:"Server",category:"Envelope",rationale:"Server encryption failure - transient issue"},DECRYPT_FAILED:{statusCode:401,statusText:"Unauthorized",retryable:!1,errorType:"Client",category:"Envelope",rationale:"Decryption failed - wrong key or corrupted data"},PARSE_FAILED:{statusCode:400,statusText:"Bad Request",retryable:!1,errorType:"Client",category:"Envelope",rationale:"Malformed JSON envelope - client validation error"},SEND_FAILED:{statusCode:503,statusText:"Service Unavailable",retryable:!0,errorType:"Server",category:"Transport",rationale:"Network send failure - retry with backoff"},NETWORK_ERROR:{statusCode:503,statusText:"Service Unavailable",retryable:!0,errorType:"Server",category:"Transport",rationale:"Network connectivity issue - retry with backoff"},RECIPIENT_UNREACHABLE:{statusCode:503,statusText:"Service Unavailable",retryable:!0,errorType:"Server",category:"Transport",rationale:"Recipient offline or unreachable - retry later"},TIMEOUT:{statusCode:504,statusText:"Gateway Timeout",retryable:!0,errorType:"Server",category:"Transport",rationale:"Request timed out - increase timeout and retry"},NOT_FOUND:{statusCode:404,statusText:"Not Found",retryable:!1,errorType:"Client",category:"Registry",rationale:"Agent not in registry - recipient must register first"},ALREADY_REGISTERED:{statusCode:409,statusText:"Conflict",retryable:!1,errorType:"Client",category:"Registry",rationale:"DID already exists - use updateAgent instead"},REVOKED:{statusCode:403,statusText:"Forbidden",retryable:!1,errorType:"Client",category:"Registry",rationale:"Agent revoked - contact admin for re-registration"},DERIVE_FAILED:{statusCode:500,statusText:"Internal Server Error",retryable:!0,errorType:"Server",category:"Key Agreement",rationale:"ECDH derivation failure - transient crypto issue"},KEM_ENCAPSULATE_FAILED:{statusCode:500,statusText:"Internal Server Error",retryable:!0,errorType:"Server",category:"Key Agreement",rationale:"ML-KEM encapsulation failure - transient crypto issue"},KEM_DECAPSULATE_FAILED:{statusCode:401,statusText:"Unauthorized",retryable:!1,errorType:"Client",category:"Key Agreement",rationale:"ML-KEM decapsulation failed - wrong ciphertext"},HKDF_FAILED:{statusCode:500,statusText:"Internal Server Error",retryable:!0,errorType:"Server",category:"Key Agreement",rationale:"HKDF derivation failure - transient crypto issue"},MLKEM_NOT_AVAILABLE:{statusCode:400,statusText:"Bad Request",retryable:!1,errorType:"Client",category:"Key Agreement",rationale:"Post-quantum not enabled - client must configure"},PQ_SIGN_FAILED:{statusCode:500,statusText:"Internal Server Error",retryable:!0,errorType:"Server",category:"Key Agreement",rationale:"ML-DSA signing failure - transient crypto issue"},PQ_VERIFY_FAILED:{statusCode:401,statusText:"Unauthorized",retryable:!1,errorType:"Client",category:"Key Agreement",rationale:"ML-DSA verification failed - invalid signature"},SPLIT_FAILED:{statusCode:500,statusText:"Internal Server Error",retryable:!0,errorType:"Server",category:"Split Channel",rationale:"XorIDA split failure - transient issue"},INSUFFICIENT_SHARES:{statusCode:400,statusText:"Bad Request",retryable:!1,errorType:"Client",category:"Split Channel",rationale:"Not enough shares - client must collect more"},INCONSISTENT_SHARES:{statusCode:400,statusText:"Bad Request",retryable:!1,errorType:"Client",category:"Split Channel",rationale:"Mismatched shares - client validation error"},HMAC_VERIFICATION_FAILED:{statusCode:401,statusText:"Unauthorized",retryable:!1,errorType:"Client",category:"Split Channel",rationale:"Share tampered with - security violation"},UNPAD_FAILED:{statusCode:500,statusText:"Internal Server Error",retryable:!1,errorType:"Server",category:"Split Channel",rationale:"Padding removal error - data corruption"},INVALID_SHARE_DATA:{statusCode:400,statusText:"Bad Request",retryable:!1,errorType:"Client",category:"Split Channel",rationale:"Malformed share format - client validation error"},XCHANGE_KEYGEN_FAILED:{statusCode:500,statusText:"Internal Server Error",retryable:!0,errorType:"Server",category:"Xchange",rationale:"Key generation failure - transient crypto issue"},XCHANGE_ENCRYPT_FAILED:{statusCode:500,statusText:"Internal Server Error",retryable:!0,errorType:"Server",category:"Xchange",rationale:"Bundle encryption failure - transient crypto issue"},XCHANGE_DECRYPT_FAILED:{statusCode:401,statusText:"Unauthorized",retryable:!1,errorType:"Client",category:"Xchange",rationale:"Bundle decryption failed - wrong key"},INVALID_BUNDLE:{statusCode:400,statusText:"Bad Request",retryable:!1,errorType:"Client",category:"Xchange",rationale:"Malformed bundle format - client validation error"},IDENTITY_FAILED:{statusCode:500,statusText:"Internal Server Error",retryable:!0,errorType:"Server",category:"Agent",rationale:"Agent identity creation failed - transient issue"},REGISTRATION_FAILED:{statusCode:503,statusText:"Service Unavailable",retryable:!0,errorType:"Server",category:"Agent",rationale:"Registry unavailable - retry with backoff"},RECIPIENT_NOT_FOUND:{statusCode:404,statusText:"Not Found",retryable:!1,errorType:"Client",category:"Agent",rationale:"Recipient not in registry - recipient must register"},RECIPIENT_REVOKED:{statusCode:403,statusText:"Forbidden",retryable:!1,errorType:"Client",category:"Agent",rationale:"Recipient revoked - contact admin"},KEY_AGREEMENT_FAILED:{statusCode:500,statusText:"Internal Server Error",retryable:!0,errorType:"Server",category:"Agent",rationale:"Key agreement failure - transient crypto issue"},ENVELOPE_FAILED:{statusCode:500,statusText:"Internal Server Error",retryable:!0,errorType:"Server",category:"Agent",rationale:"Envelope creation failed - transient issue"},VERIFICATION_FAILED:{statusCode:401,statusText:"Unauthorized",retryable:!1,errorType:"Client",category:"Agent",rationale:"Envelope verification failed - authentication error"},REPLAY_DETECTED:{statusCode:403,statusText:"Forbidden",retryable:!1,errorType:"Client",category:"Agent",rationale:"Replay attack detected - security violation"},SCOPE_DENIED:{statusCode:403,statusText:"Forbidden",retryable:!1,errorType:"Client",category:"Agent",rationale:"Sender lacks scope permission - authorization failure"},RECEIVER_SCOPE_DENIED:{statusCode:403,statusText:"Forbidden",retryable:!1,errorType:"Client",category:"Agent",rationale:"Recipient rejects scope - authorization failure"},TIMESTAMP_EXPIRED:{statusCode:400,statusText:"Bad Request",retryable:!0,errorType:"Client",category:"Agent",rationale:"Timestamp outside window - clock sync issue (retryable)"}};