@parmana/shared 0.0.0-stage → 0.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 (417) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +8 -0
  3. package/README.md +16 -2
  4. package/dist/.tsbuildinfo +1 -0
  5. package/dist/config/ApiKeyEntry.d.ts +97 -0
  6. package/dist/config/ApiKeyEntry.d.ts.map +1 -0
  7. package/dist/config/ApiKeyEntry.js +2 -0
  8. package/dist/config/ApiKeyEntry.js.map +1 -0
  9. package/dist/config/Config.d.ts +202 -0
  10. package/dist/config/Config.d.ts.map +1 -0
  11. package/dist/config/Config.js +172 -0
  12. package/dist/config/Config.js.map +1 -0
  13. package/dist/config/ConfigLoader.d.ts +5 -0
  14. package/dist/config/ConfigLoader.d.ts.map +1 -0
  15. package/dist/config/ConfigLoader.js +8 -0
  16. package/dist/config/ConfigLoader.js.map +1 -0
  17. package/dist/config/ConfigUtils.d.ts +6 -0
  18. package/dist/config/ConfigUtils.d.ts.map +1 -0
  19. package/dist/config/ConfigUtils.js +8 -0
  20. package/dist/config/ConfigUtils.js.map +1 -0
  21. package/dist/config/ConfigValidation.d.ts +30 -0
  22. package/dist/config/ConfigValidation.d.ts.map +1 -0
  23. package/dist/config/ConfigValidation.js +170 -0
  24. package/dist/config/ConfigValidation.js.map +1 -0
  25. package/dist/config/CryptoAlgorithms.d.ts +42 -0
  26. package/dist/config/CryptoAlgorithms.d.ts.map +1 -0
  27. package/dist/config/CryptoAlgorithms.js +42 -0
  28. package/dist/config/CryptoAlgorithms.js.map +1 -0
  29. package/dist/config/KeyProviders.d.ts +9 -0
  30. package/dist/config/KeyProviders.d.ts.map +1 -0
  31. package/dist/config/KeyProviders.js +8 -0
  32. package/dist/config/KeyProviders.js.map +1 -0
  33. package/dist/config/SecretsProviders.d.ts +6 -0
  34. package/dist/config/SecretsProviders.d.ts.map +1 -0
  35. package/dist/config/SecretsProviders.js +5 -0
  36. package/dist/config/SecretsProviders.js.map +1 -0
  37. package/dist/config/StorageProviders.d.ts +18 -0
  38. package/dist/config/StorageProviders.d.ts.map +1 -0
  39. package/dist/config/StorageProviders.js +20 -0
  40. package/dist/config/StorageProviders.js.map +1 -0
  41. package/dist/config/TrustProfiles.d.ts +5 -0
  42. package/dist/config/TrustProfiles.d.ts.map +1 -0
  43. package/dist/config/TrustProfiles.js +4 -0
  44. package/dist/config/TrustProfiles.js.map +1 -0
  45. package/dist/config/index.d.ts +11 -0
  46. package/dist/config/index.d.ts.map +1 -0
  47. package/dist/config/index.js +11 -0
  48. package/dist/config/index.js.map +1 -0
  49. package/dist/domain/approval-artifact.d.ts +136 -0
  50. package/dist/domain/approval-artifact.d.ts.map +1 -0
  51. package/dist/domain/approval-artifact.js +2 -0
  52. package/dist/domain/approval-artifact.js.map +1 -0
  53. package/dist/domain/approval-issuer.d.ts +52 -0
  54. package/dist/domain/approval-issuer.d.ts.map +1 -0
  55. package/dist/domain/approval-issuer.js +2 -0
  56. package/dist/domain/approval-issuer.js.map +1 -0
  57. package/dist/domain/authority-grant.d.ts +54 -0
  58. package/dist/domain/authority-grant.d.ts.map +1 -0
  59. package/dist/domain/authority-grant.js +2 -0
  60. package/dist/domain/authority-grant.js.map +1 -0
  61. package/dist/domain/authority.d.ts +42 -0
  62. package/dist/domain/authority.d.ts.map +1 -0
  63. package/dist/domain/authority.js +11 -0
  64. package/dist/domain/authority.js.map +1 -0
  65. package/dist/domain/authorization.d.ts +54 -0
  66. package/dist/domain/authorization.d.ts.map +1 -0
  67. package/dist/domain/authorization.js +2 -0
  68. package/dist/domain/authorization.js.map +1 -0
  69. package/dist/domain/business-signal-source.d.ts +52 -0
  70. package/dist/domain/business-signal-source.d.ts.map +1 -0
  71. package/dist/domain/business-signal-source.js +2 -0
  72. package/dist/domain/business-signal-source.js.map +1 -0
  73. package/dist/domain/business-transaction.d.ts +99 -0
  74. package/dist/domain/business-transaction.d.ts.map +1 -0
  75. package/dist/domain/business-transaction.js +16 -0
  76. package/dist/domain/business-transaction.js.map +1 -0
  77. package/dist/domain/business-validation.d.ts +177 -0
  78. package/dist/domain/business-validation.d.ts.map +1 -0
  79. package/dist/domain/business-validation.js +60 -0
  80. package/dist/domain/business-validation.js.map +1 -0
  81. package/dist/domain/challenge-record.d.ts +181 -0
  82. package/dist/domain/challenge-record.d.ts.map +1 -0
  83. package/dist/domain/challenge-record.js +2 -0
  84. package/dist/domain/challenge-record.js.map +1 -0
  85. package/dist/domain/decision.d.ts +89 -0
  86. package/dist/domain/decision.d.ts.map +1 -0
  87. package/dist/domain/decision.js +9 -0
  88. package/dist/domain/decision.js.map +1 -0
  89. package/dist/domain/evidence-anchor.d.ts +54 -0
  90. package/dist/domain/evidence-anchor.d.ts.map +1 -0
  91. package/dist/domain/evidence-anchor.js +2 -0
  92. package/dist/domain/evidence-anchor.js.map +1 -0
  93. package/dist/domain/executable-content.d.ts +45 -0
  94. package/dist/domain/executable-content.d.ts.map +1 -0
  95. package/dist/domain/executable-content.js +39 -0
  96. package/dist/domain/executable-content.js.map +1 -0
  97. package/dist/domain/execution-audit-event.d.ts +65 -0
  98. package/dist/domain/execution-audit-event.d.ts.map +1 -0
  99. package/dist/domain/execution-audit-event.js +2 -0
  100. package/dist/domain/execution-audit-event.js.map +1 -0
  101. package/dist/domain/execution-authorization.d.ts +224 -0
  102. package/dist/domain/execution-authorization.d.ts.map +1 -0
  103. package/dist/domain/execution-authorization.js +2 -0
  104. package/dist/domain/execution-authorization.js.map +1 -0
  105. package/dist/domain/execution-evidence.d.ts +38 -0
  106. package/dist/domain/execution-evidence.d.ts.map +1 -0
  107. package/dist/domain/execution-evidence.js +2 -0
  108. package/dist/domain/execution-evidence.js.map +1 -0
  109. package/dist/domain/execution-intent.d.ts +92 -0
  110. package/dist/domain/execution-intent.d.ts.map +1 -0
  111. package/dist/domain/execution-intent.js +2 -0
  112. package/dist/domain/execution-intent.js.map +1 -0
  113. package/dist/domain/execution-metadata.d.ts +8 -0
  114. package/dist/domain/execution-metadata.d.ts.map +1 -0
  115. package/dist/domain/execution-metadata.js +2 -0
  116. package/dist/domain/execution-metadata.js.map +1 -0
  117. package/dist/domain/execution-outcome-store.d.ts +49 -0
  118. package/dist/domain/execution-outcome-store.d.ts.map +1 -0
  119. package/dist/domain/execution-outcome-store.js +10 -0
  120. package/dist/domain/execution-outcome-store.js.map +1 -0
  121. package/dist/domain/execution-result.d.ts +49 -0
  122. package/dist/domain/execution-result.d.ts.map +1 -0
  123. package/dist/domain/execution-result.js +2 -0
  124. package/dist/domain/execution-result.js.map +1 -0
  125. package/dist/domain/execution-trust-record.d.ts +142 -0
  126. package/dist/domain/execution-trust-record.d.ts.map +1 -0
  127. package/dist/domain/execution-trust-record.js +2 -0
  128. package/dist/domain/execution-trust-record.js.map +1 -0
  129. package/dist/domain/execution.d.ts +108 -0
  130. package/dist/domain/execution.d.ts.map +1 -0
  131. package/dist/domain/execution.js +18 -0
  132. package/dist/domain/execution.js.map +1 -0
  133. package/dist/domain/external-connector.d.ts +68 -0
  134. package/dist/domain/external-connector.d.ts.map +1 -0
  135. package/dist/domain/external-connector.js +2 -0
  136. package/dist/domain/external-connector.js.map +1 -0
  137. package/dist/domain/index.d.ts +37 -0
  138. package/dist/domain/index.d.ts.map +1 -0
  139. package/dist/domain/index.js +37 -0
  140. package/dist/domain/index.js.map +1 -0
  141. package/dist/domain/intent.d.ts +66 -0
  142. package/dist/domain/intent.d.ts.map +1 -0
  143. package/dist/domain/intent.js +2 -0
  144. package/dist/domain/intent.js.map +1 -0
  145. package/dist/domain/metadata.d.ts +53 -0
  146. package/dist/domain/metadata.d.ts.map +1 -0
  147. package/dist/domain/metadata.js +11 -0
  148. package/dist/domain/metadata.js.map +1 -0
  149. package/dist/domain/override.d.ts +39 -0
  150. package/dist/domain/override.d.ts.map +1 -0
  151. package/dist/domain/override.js +2 -0
  152. package/dist/domain/override.js.map +1 -0
  153. package/dist/domain/pending-policy-change.d.ts +109 -0
  154. package/dist/domain/pending-policy-change.d.ts.map +1 -0
  155. package/dist/domain/pending-policy-change.js +12 -0
  156. package/dist/domain/pending-policy-change.js.map +1 -0
  157. package/dist/domain/policy-change-approval-record.d.ts +81 -0
  158. package/dist/domain/policy-change-approval-record.d.ts.map +1 -0
  159. package/dist/domain/policy-change-approval-record.js +2 -0
  160. package/dist/domain/policy-change-approval-record.js.map +1 -0
  161. package/dist/domain/policy-change-step-up-authorization.d.ts +97 -0
  162. package/dist/domain/policy-change-step-up-authorization.d.ts.map +1 -0
  163. package/dist/domain/policy-change-step-up-authorization.js +2 -0
  164. package/dist/domain/policy-change-step-up-authorization.js.map +1 -0
  165. package/dist/domain/policy-reference.d.ts +58 -0
  166. package/dist/domain/policy-reference.d.ts.map +1 -0
  167. package/dist/domain/policy-reference.js +2 -0
  168. package/dist/domain/policy-reference.js.map +1 -0
  169. package/dist/domain/receipt.d.ts +72 -0
  170. package/dist/domain/receipt.d.ts.map +1 -0
  171. package/dist/domain/receipt.js +2 -0
  172. package/dist/domain/receipt.js.map +1 -0
  173. package/dist/domain/refusal-record.d.ts +110 -0
  174. package/dist/domain/refusal-record.d.ts.map +1 -0
  175. package/dist/domain/refusal-record.js +2 -0
  176. package/dist/domain/refusal-record.js.map +1 -0
  177. package/dist/domain/release-approval.d.ts +14 -0
  178. package/dist/domain/release-approval.d.ts.map +1 -0
  179. package/dist/domain/release-approval.js +2 -0
  180. package/dist/domain/release-approval.js.map +1 -0
  181. package/dist/domain/signals.d.ts +10 -0
  182. package/dist/domain/signals.d.ts.map +1 -0
  183. package/dist/domain/signals.js +2 -0
  184. package/dist/domain/signals.js.map +1 -0
  185. package/dist/domain/signature-entry.d.ts +23 -0
  186. package/dist/domain/signature-entry.d.ts.map +1 -0
  187. package/dist/domain/signature-entry.js +2 -0
  188. package/dist/domain/signature-entry.js.map +1 -0
  189. package/dist/domain/signature.d.ts +26 -0
  190. package/dist/domain/signature.d.ts.map +1 -0
  191. package/dist/domain/signature.js +2 -0
  192. package/dist/domain/signature.js.map +1 -0
  193. package/dist/domain/unsigned-execution-trust-record.d.ts +7 -0
  194. package/dist/domain/unsigned-execution-trust-record.d.ts.map +1 -0
  195. package/dist/domain/unsigned-execution-trust-record.js +2 -0
  196. package/dist/domain/unsigned-execution-trust-record.js.map +1 -0
  197. package/dist/domain/verification.d.ts +48 -0
  198. package/dist/domain/verification.d.ts.map +1 -0
  199. package/dist/domain/verification.js +9 -0
  200. package/dist/domain/verification.js.map +1 -0
  201. package/dist/errors/approval-issuer-change-not-found-error.d.ts +9 -0
  202. package/dist/errors/approval-issuer-change-not-found-error.d.ts.map +1 -0
  203. package/dist/errors/approval-issuer-change-not-found-error.js +11 -0
  204. package/dist/errors/approval-issuer-change-not-found-error.js.map +1 -0
  205. package/dist/errors/authority-grant-change-not-found-error.d.ts +9 -0
  206. package/dist/errors/authority-grant-change-not-found-error.d.ts.map +1 -0
  207. package/dist/errors/authority-grant-change-not-found-error.js +11 -0
  208. package/dist/errors/authority-grant-change-not-found-error.js.map +1 -0
  209. package/dist/errors/authority-required-error.d.ts +5 -0
  210. package/dist/errors/authority-required-error.d.ts.map +1 -0
  211. package/dist/errors/authority-required-error.js +7 -0
  212. package/dist/errors/authority-required-error.js.map +1 -0
  213. package/dist/errors/authorization-no-longer-valid-error.d.ts +19 -0
  214. package/dist/errors/authorization-no-longer-valid-error.d.ts.map +1 -0
  215. package/dist/errors/authorization-no-longer-valid-error.js +23 -0
  216. package/dist/errors/authorization-no-longer-valid-error.js.map +1 -0
  217. package/dist/errors/authorization-required-error.d.ts +5 -0
  218. package/dist/errors/authorization-required-error.d.ts.map +1 -0
  219. package/dist/errors/authorization-required-error.js +7 -0
  220. package/dist/errors/authorization-required-error.js.map +1 -0
  221. package/dist/errors/business-signal-source-change-not-found-error.d.ts +9 -0
  222. package/dist/errors/business-signal-source-change-not-found-error.d.ts.map +1 -0
  223. package/dist/errors/business-signal-source-change-not-found-error.js +11 -0
  224. package/dist/errors/business-signal-source-change-not-found-error.js.map +1 -0
  225. package/dist/errors/business-transaction-not-found-error.d.ts +5 -0
  226. package/dist/errors/business-transaction-not-found-error.d.ts.map +1 -0
  227. package/dist/errors/business-transaction-not-found-error.js +7 -0
  228. package/dist/errors/business-transaction-not-found-error.js.map +1 -0
  229. package/dist/errors/challenge-record-not-found-error.d.ts +9 -0
  230. package/dist/errors/challenge-record-not-found-error.d.ts.map +1 -0
  231. package/dist/errors/challenge-record-not-found-error.js +11 -0
  232. package/dist/errors/challenge-record-not-found-error.js.map +1 -0
  233. package/dist/errors/conflict-error.d.ts +5 -0
  234. package/dist/errors/conflict-error.d.ts.map +1 -0
  235. package/dist/errors/conflict-error.js +7 -0
  236. package/dist/errors/conflict-error.js.map +1 -0
  237. package/dist/errors/connector-not-registered-error.d.ts +21 -0
  238. package/dist/errors/connector-not-registered-error.d.ts.map +1 -0
  239. package/dist/errors/connector-not-registered-error.js +24 -0
  240. package/dist/errors/connector-not-registered-error.js.map +1 -0
  241. package/dist/errors/decision-not-approved-error.d.ts +5 -0
  242. package/dist/errors/decision-not-approved-error.d.ts.map +1 -0
  243. package/dist/errors/decision-not-approved-error.js +7 -0
  244. package/dist/errors/decision-not-approved-error.js.map +1 -0
  245. package/dist/errors/duplicate-business-transaction-error.d.ts +26 -0
  246. package/dist/errors/duplicate-business-transaction-error.d.ts.map +1 -0
  247. package/dist/errors/duplicate-business-transaction-error.js +28 -0
  248. package/dist/errors/duplicate-business-transaction-error.js.map +1 -0
  249. package/dist/errors/external-connector-change-not-found-error.d.ts +9 -0
  250. package/dist/errors/external-connector-change-not-found-error.d.ts.map +1 -0
  251. package/dist/errors/external-connector-change-not-found-error.js +11 -0
  252. package/dist/errors/external-connector-change-not-found-error.js.map +1 -0
  253. package/dist/errors/forbidden-error.d.ts +5 -0
  254. package/dist/errors/forbidden-error.d.ts.map +1 -0
  255. package/dist/errors/forbidden-error.js +7 -0
  256. package/dist/errors/forbidden-error.js.map +1 -0
  257. package/dist/errors/index.d.ts +30 -0
  258. package/dist/errors/index.d.ts.map +1 -0
  259. package/dist/errors/index.js +30 -0
  260. package/dist/errors/index.js.map +1 -0
  261. package/dist/errors/intent-required-error.d.ts +5 -0
  262. package/dist/errors/intent-required-error.d.ts.map +1 -0
  263. package/dist/errors/intent-required-error.js +7 -0
  264. package/dist/errors/intent-required-error.js.map +1 -0
  265. package/dist/errors/non-human-caller-denied-error.d.ts +10 -0
  266. package/dist/errors/non-human-caller-denied-error.d.ts.map +1 -0
  267. package/dist/errors/non-human-caller-denied-error.js +12 -0
  268. package/dist/errors/non-human-caller-denied-error.js.map +1 -0
  269. package/dist/errors/nonce-already-consumed-error.d.ts +26 -0
  270. package/dist/errors/nonce-already-consumed-error.d.ts.map +1 -0
  271. package/dist/errors/nonce-already-consumed-error.js +29 -0
  272. package/dist/errors/nonce-already-consumed-error.js.map +1 -0
  273. package/dist/errors/outcome-unknown-error.d.ts +15 -0
  274. package/dist/errors/outcome-unknown-error.d.ts.map +1 -0
  275. package/dist/errors/outcome-unknown-error.js +19 -0
  276. package/dist/errors/outcome-unknown-error.js.map +1 -0
  277. package/dist/errors/override-not-allowed-error.d.ts +5 -0
  278. package/dist/errors/override-not-allowed-error.d.ts.map +1 -0
  279. package/dist/errors/override-not-allowed-error.js +7 -0
  280. package/dist/errors/override-not-allowed-error.js.map +1 -0
  281. package/dist/errors/parmana-error.d.ts +15 -0
  282. package/dist/errors/parmana-error.d.ts.map +1 -0
  283. package/dist/errors/parmana-error.js +21 -0
  284. package/dist/errors/parmana-error.js.map +1 -0
  285. package/dist/errors/pending-policy-change-not-found-error.d.ts +9 -0
  286. package/dist/errors/pending-policy-change-not-found-error.d.ts.map +1 -0
  287. package/dist/errors/pending-policy-change-not-found-error.js +11 -0
  288. package/dist/errors/pending-policy-change-not-found-error.js.map +1 -0
  289. package/dist/errors/policy-not-found-error.d.ts +5 -0
  290. package/dist/errors/policy-not-found-error.d.ts.map +1 -0
  291. package/dist/errors/policy-not-found-error.js +7 -0
  292. package/dist/errors/policy-not-found-error.js.map +1 -0
  293. package/dist/errors/receipt-generation-error.d.ts +5 -0
  294. package/dist/errors/receipt-generation-error.d.ts.map +1 -0
  295. package/dist/errors/receipt-generation-error.js +7 -0
  296. package/dist/errors/receipt-generation-error.js.map +1 -0
  297. package/dist/errors/same-actor-cannot-approve-own-change-error.d.ts +12 -0
  298. package/dist/errors/same-actor-cannot-approve-own-change-error.d.ts.map +1 -0
  299. package/dist/errors/same-actor-cannot-approve-own-change-error.js +15 -0
  300. package/dist/errors/same-actor-cannot-approve-own-change-error.js.map +1 -0
  301. package/dist/errors/step-up-authorization-invalid-error.d.ts +25 -0
  302. package/dist/errors/step-up-authorization-invalid-error.d.ts.map +1 -0
  303. package/dist/errors/step-up-authorization-invalid-error.js +28 -0
  304. package/dist/errors/step-up-authorization-invalid-error.js.map +1 -0
  305. package/dist/errors/trust-chain-validation-error.d.ts +5 -0
  306. package/dist/errors/trust-chain-validation-error.d.ts.map +1 -0
  307. package/dist/errors/trust-chain-validation-error.js +7 -0
  308. package/dist/errors/trust-chain-validation-error.js.map +1 -0
  309. package/dist/errors/unauthorized-error.d.ts +5 -0
  310. package/dist/errors/unauthorized-error.d.ts.map +1 -0
  311. package/dist/errors/unauthorized-error.js +7 -0
  312. package/dist/errors/unauthorized-error.js.map +1 -0
  313. package/dist/errors/validation-error.d.ts +5 -0
  314. package/dist/errors/validation-error.d.ts.map +1 -0
  315. package/dist/errors/validation-error.js +7 -0
  316. package/dist/errors/validation-error.js.map +1 -0
  317. package/dist/errors/verification-failed-error.d.ts +5 -0
  318. package/dist/errors/verification-failed-error.d.ts.map +1 -0
  319. package/dist/errors/verification-failed-error.js +7 -0
  320. package/dist/errors/verification-failed-error.js.map +1 -0
  321. package/dist/gateway/GatewayAuthentication.d.ts +8 -0
  322. package/dist/gateway/GatewayAuthentication.d.ts.map +1 -0
  323. package/dist/gateway/GatewayAuthentication.js +2 -0
  324. package/dist/gateway/GatewayAuthentication.js.map +1 -0
  325. package/dist/gateway/GatewayAuthenticationClaims.d.ts +10 -0
  326. package/dist/gateway/GatewayAuthenticationClaims.d.ts.map +1 -0
  327. package/dist/gateway/GatewayAuthenticationClaims.js +2 -0
  328. package/dist/gateway/GatewayAuthenticationClaims.js.map +1 -0
  329. package/dist/gateway/GatewayAuthenticationPayload.d.ts +15 -0
  330. package/dist/gateway/GatewayAuthenticationPayload.d.ts.map +1 -0
  331. package/dist/gateway/GatewayAuthenticationPayload.js +2 -0
  332. package/dist/gateway/GatewayAuthenticationPayload.js.map +1 -0
  333. package/dist/gateway/SignedGatewayAuthentication.d.ts +9 -0
  334. package/dist/gateway/SignedGatewayAuthentication.d.ts.map +1 -0
  335. package/dist/gateway/SignedGatewayAuthentication.js +2 -0
  336. package/dist/gateway/SignedGatewayAuthentication.js.map +1 -0
  337. package/dist/gateway/index.d.ts +4 -0
  338. package/dist/gateway/index.d.ts.map +1 -0
  339. package/dist/gateway/index.js +4 -0
  340. package/dist/gateway/index.js.map +1 -0
  341. package/dist/index.d.ts +19 -0
  342. package/dist/index.d.ts.map +1 -0
  343. package/dist/index.js +19 -0
  344. package/dist/index.js.map +1 -0
  345. package/dist/logging/Logger.d.ts +65 -0
  346. package/dist/logging/Logger.d.ts.map +1 -0
  347. package/dist/logging/Logger.js +97 -0
  348. package/dist/logging/Logger.js.map +1 -0
  349. package/dist/network/externalEndpointAddress.d.ts +48 -0
  350. package/dist/network/externalEndpointAddress.d.ts.map +1 -0
  351. package/dist/network/externalEndpointAddress.js +147 -0
  352. package/dist/network/externalEndpointAddress.js.map +1 -0
  353. package/dist/repositories/approval-issuer-repository.d.ts +31 -0
  354. package/dist/repositories/approval-issuer-repository.d.ts.map +1 -0
  355. package/dist/repositories/approval-issuer-repository.js +2 -0
  356. package/dist/repositories/approval-issuer-repository.js.map +1 -0
  357. package/dist/repositories/authority-grant-repository.d.ts +22 -0
  358. package/dist/repositories/authority-grant-repository.d.ts.map +1 -0
  359. package/dist/repositories/authority-grant-repository.js +2 -0
  360. package/dist/repositories/authority-grant-repository.js.map +1 -0
  361. package/dist/repositories/business-signal-source-repository.d.ts +17 -0
  362. package/dist/repositories/business-signal-source-repository.d.ts.map +1 -0
  363. package/dist/repositories/business-signal-source-repository.js +2 -0
  364. package/dist/repositories/business-signal-source-repository.js.map +1 -0
  365. package/dist/repositories/business-transaction-repository.d.ts +34 -0
  366. package/dist/repositories/business-transaction-repository.d.ts.map +1 -0
  367. package/dist/repositories/business-transaction-repository.js +2 -0
  368. package/dist/repositories/business-transaction-repository.js.map +1 -0
  369. package/dist/repositories/challenge-record-repository.d.ts +67 -0
  370. package/dist/repositories/challenge-record-repository.d.ts.map +1 -0
  371. package/dist/repositories/challenge-record-repository.js +76 -0
  372. package/dist/repositories/challenge-record-repository.js.map +1 -0
  373. package/dist/repositories/execution-intent-repository.d.ts +38 -0
  374. package/dist/repositories/execution-intent-repository.d.ts.map +1 -0
  375. package/dist/repositories/execution-intent-repository.js +2 -0
  376. package/dist/repositories/execution-intent-repository.js.map +1 -0
  377. package/dist/repositories/execution-trust-record-repository.d.ts +62 -0
  378. package/dist/repositories/execution-trust-record-repository.d.ts.map +1 -0
  379. package/dist/repositories/execution-trust-record-repository.js +2 -0
  380. package/dist/repositories/execution-trust-record-repository.js.map +1 -0
  381. package/dist/repositories/external-connector-repository.d.ts +37 -0
  382. package/dist/repositories/external-connector-repository.d.ts.map +1 -0
  383. package/dist/repositories/external-connector-repository.js +2 -0
  384. package/dist/repositories/external-connector-repository.js.map +1 -0
  385. package/dist/repositories/handbook-download-lead-repository.d.ts +18 -0
  386. package/dist/repositories/handbook-download-lead-repository.d.ts.map +1 -0
  387. package/dist/repositories/handbook-download-lead-repository.js +2 -0
  388. package/dist/repositories/handbook-download-lead-repository.js.map +1 -0
  389. package/dist/repositories/index.d.ts +14 -0
  390. package/dist/repositories/index.d.ts.map +1 -0
  391. package/dist/repositories/index.js +14 -0
  392. package/dist/repositories/index.js.map +1 -0
  393. package/dist/repositories/pending-policy-change-repository.d.ts +72 -0
  394. package/dist/repositories/pending-policy-change-repository.d.ts.map +1 -0
  395. package/dist/repositories/pending-policy-change-repository.js +46 -0
  396. package/dist/repositories/pending-policy-change-repository.js.map +1 -0
  397. package/dist/repositories/policy-change-approval-record-repository.d.ts +39 -0
  398. package/dist/repositories/policy-change-approval-record-repository.d.ts.map +1 -0
  399. package/dist/repositories/policy-change-approval-record-repository.js +2 -0
  400. package/dist/repositories/policy-change-approval-record-repository.js.map +1 -0
  401. package/dist/repositories/policy-repository.d.ts +15 -0
  402. package/dist/repositories/policy-repository.d.ts.map +1 -0
  403. package/dist/repositories/policy-repository.js +2 -0
  404. package/dist/repositories/policy-repository.js.map +1 -0
  405. package/dist/repositories/refusal-record-repository.d.ts +13 -0
  406. package/dist/repositories/refusal-record-repository.d.ts.map +1 -0
  407. package/dist/repositories/refusal-record-repository.js +2 -0
  408. package/dist/repositories/refusal-record-repository.js.map +1 -0
  409. package/dist/types/Json.d.ts +7 -0
  410. package/dist/types/Json.d.ts.map +1 -0
  411. package/dist/types/Json.js +2 -0
  412. package/dist/types/Json.js.map +1 -0
  413. package/dist/utils/normalize-policy.d.ts +16 -0
  414. package/dist/utils/normalize-policy.d.ts.map +1 -0
  415. package/dist/utils/normalize-policy.js +10 -0
  416. package/dist/utils/normalize-policy.js.map +1 -0
  417. package/package.json +39 -4
@@ -0,0 +1,202 @@
1
+ import type { CryptoMode, HashAlgorithm, SignatureAlgorithm } from "./CryptoAlgorithms.js";
2
+ import type { StorageProvider } from "./StorageProviders.js";
3
+ import type { KeyProvider } from "./KeyProviders.js";
4
+ import type { SecretsProvider } from "./SecretsProviders.js";
5
+ import type { TrustProfile } from "./TrustProfiles.js";
6
+ import type { ApiKeyEntry } from "./ApiKeyEntry.js";
7
+ /**
8
+ * Parmana Configuration.
9
+ *
10
+ * Centralized immutable configuration.
11
+ *
12
+ * This is the only configuration model used by
13
+ * Parmana. Environment variables are converted
14
+ * into strongly typed values through the
15
+ * ConfigValidation module.
16
+ */
17
+ /**
18
+ * Root configuration.
19
+ */
20
+ export interface Config {
21
+ readonly environment: EnvironmentConfig;
22
+ readonly storage: StorageConfig;
23
+ readonly crypto: CryptoConfig;
24
+ readonly keys: KeyConfig;
25
+ readonly secrets: SecretsConfig;
26
+ readonly authorization: AuthorizationConfig;
27
+ readonly policy: PolicyConfig;
28
+ readonly trust: TrustConfig;
29
+ readonly api: ApiConfig;
30
+ readonly auth: ApiAuthConfig;
31
+ readonly rateLimit: RateLimitConfig;
32
+ readonly logging: LoggingConfig;
33
+ }
34
+ /**
35
+ * Runtime environment.
36
+ */
37
+ export interface EnvironmentConfig {
38
+ readonly nodeEnv: string;
39
+ }
40
+ /**
41
+ * Storage configuration.
42
+ */
43
+ export interface StorageConfig {
44
+ readonly provider: StorageProvider;
45
+ readonly databaseUrl?: string;
46
+ }
47
+ /**
48
+ * Cryptographic configuration.
49
+ */
50
+ export interface CryptoConfig {
51
+ /**
52
+ * Crypto operating mode.
53
+ */
54
+ readonly mode: CryptoMode;
55
+ /**
56
+ * Hash algorithm.
57
+ */
58
+ readonly hashProvider: HashAlgorithm;
59
+ /**
60
+ * Primary signature algorithm.
61
+ */
62
+ readonly primarySignatureProvider: SignatureAlgorithm;
63
+ /**
64
+ * Secondary signature algorithm.
65
+ *
66
+ * Required only in hybrid mode.
67
+ */
68
+ readonly secondarySignatureProvider?: SignatureAlgorithm;
69
+ /**
70
+ * When true, verification of a hybrid-schema-capable artifact
71
+ * (an ExecutionTrustRecord) MUST find a valid `signatures` array
72
+ * covering every configured algorithm -- a record with `signatures`
73
+ * absent, empty, or partial is rejected outright, never silently
74
+ * verified via the legacy single signature alone.
75
+ *
76
+ * Off by default so no already-issued record (hybrid or not) is
77
+ * affected by turning CRYPTO_MODE=hybrid on: a deployment opts into
78
+ * this once it is confident every record going forward is genuinely
79
+ * hybrid-signed. See VerificationCrypto.verifySignature()'s own
80
+ * comment for the exact downgrade this closes.
81
+ */
82
+ readonly requireHybridSignature: boolean;
83
+ /**
84
+ * Cutover (ADR-0016, option 2): a record created at or after this ISO-8601
85
+ * UTC instant must carry a valid hybrid envelope. Unset means no cutover.
86
+ * The same instant belongs in the offline verifier's trust file.
87
+ */
88
+ readonly hybridRequiredFrom?: string;
89
+ /**
90
+ * Schema version that hybrid signatures are made under (ADR-0016).
91
+ *
92
+ * 2 (default) signs the canonical fields plus schemaVersion. 3 signs
93
+ * every top-level field except the signature envelope and the
94
+ * post-signing fields (verifications, receipts). Records made under 3
95
+ * are not readable by verifiers that implement only version 2, so
96
+ * switch to 3 only once those consumers are updated.
97
+ */
98
+ readonly hybridSchemaVersion: 2 | 3;
99
+ }
100
+ /**
101
+ * Key management.
102
+ */
103
+ export interface KeyConfig {
104
+ readonly provider: KeyProvider;
105
+ /**
106
+ * Root directory containing all Parmana keys.
107
+ */
108
+ readonly keyDirectory: string;
109
+ }
110
+ /**
111
+ * Secrets backend configuration (ADR-0009). Selects where connector
112
+ * credentials that are opaque bearer values -- not signing keys, see
113
+ * KeyConfig/Signer for those -- are resolved from at request time.
114
+ * "env" (default) is an identity pass-through: the value each
115
+ * connector's own env var already holds IS the secret. In
116
+ * "aws-secrets-manager" mode, that same env var's value is instead
117
+ * treated as the Secrets Manager secret's name/ARN to fetch.
118
+ */
119
+ export interface SecretsConfig {
120
+ readonly provider: SecretsProvider;
121
+ }
122
+ /**
123
+ * Execution authorization configuration.
124
+ */
125
+ export interface AuthorizationConfig {
126
+ /**
127
+ * Default TTL, in seconds, applied to a signed
128
+ * Execution Authorization when the caller does
129
+ * not specify one.
130
+ */
131
+ readonly ttlSeconds: number;
132
+ }
133
+ /**
134
+ * Policy configuration.
135
+ */
136
+ export interface PolicyConfig {
137
+ /**
138
+ * Root directory containing policy files.
139
+ */
140
+ readonly directory: string;
141
+ }
142
+ /**
143
+ * Trust profile configuration.
144
+ */
145
+ export interface TrustConfig {
146
+ readonly profile: TrustProfile;
147
+ readonly receiptVersion: string;
148
+ }
149
+ /**
150
+ * API configuration.
151
+ */
152
+ export interface ApiConfig {
153
+ readonly port: number;
154
+ }
155
+ /**
156
+ * API caller authentication.
157
+ *
158
+ * Fail-closed by design: an empty `keys` array means the
159
+ * caller-authenticator bootstrap refuses to start the
160
+ * server unless `disabled` is explicitly true (local
161
+ * development and tutorials only).
162
+ */
163
+ export interface ApiAuthConfig {
164
+ readonly keys: readonly ApiKeyEntry[];
165
+ readonly disabled: boolean;
166
+ }
167
+ /**
168
+ * Rate limiting configuration.
169
+ *
170
+ * Both are per-caller/per-IP-per-minute ceilings applied by
171
+ * packages/api/src/middleware/rate-limit.ts; see that file for exactly
172
+ * where and how each is keyed.
173
+ */
174
+ export interface RateLimitConfig {
175
+ /**
176
+ * POST /execute, keyed by authenticated caller identity.
177
+ */
178
+ readonly executePerMinute: number;
179
+ /**
180
+ * GET /health and GET /ready, keyed by IP.
181
+ */
182
+ readonly healthPerMinute: number;
183
+ /**
184
+ * The unauthenticated verify routes, /handbook and key discovery,
185
+ * keyed by IP (G-78).
186
+ */
187
+ readonly publicPerMinute: number;
188
+ /**
189
+ * Failed caller authentications (401) on every authenticated route,
190
+ * keyed by IP. Each one writes a signed audit event, so an unlimited
191
+ * stream of bad keys would spend signing capacity real requests need.
192
+ */
193
+ readonly authFailurePerMinute: number;
194
+ }
195
+ /**
196
+ * Logging configuration.
197
+ */
198
+ export interface LoggingConfig {
199
+ readonly level: string;
200
+ }
201
+ export declare function loadConfig(): Readonly<Config>;
202
+ //# sourceMappingURL=Config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../src/config/Config.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EACb,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KA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AQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;CACvC;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAgED,wBAAgB,UAAU,IAAI,QAAQ,CAAC,MAAM,CAAC,CA8F7C"}
@@ -0,0 +1,172 @@
1
+ import dotenv from "dotenv";
2
+ import { existsSync } from "node:fs";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { optionalProperty } from "./ConfigUtils.js";
6
+ import { parseStorageProvider, parseCryptoMode, parseHashAlgorithm, parseSignatureAlgorithm, parseKeyProvider, parseSecretsProvider, parseTrustProfile, parseApiKeys, } from "./ConfigValidation.js";
7
+ /**
8
+ * Resolve the repository .env file.
9
+ *
10
+ * This implementation is independent of the
11
+ * current working directory, allowing every
12
+ * Parmana package to share the same
13
+ * configuration.
14
+ */
15
+ const __filename = fileURLToPath(import.meta.url);
16
+ const __dirname = dirname(__filename);
17
+ function findEnvFile() {
18
+ let current = __dirname;
19
+ while (true) {
20
+ const candidate = join(current, ".env");
21
+ if (existsSync(candidate)) {
22
+ return candidate;
23
+ }
24
+ const parent = dirname(current);
25
+ if (parent === current) {
26
+ return undefined;
27
+ }
28
+ current = parent;
29
+ }
30
+ }
31
+ //
32
+ // The .env file is read on first use of loadConfig(), not when this module
33
+ // is imported. Importing a package (for example the offline verifier) then
34
+ // reads no file from the working tree.
35
+ //
36
+ let dotEnvLoaded = false;
37
+ function loadDotEnvOnce() {
38
+ // Test runs set PARMANA_SKIP_DOTENV so a local .env cannot leak into them.
39
+ if (dotEnvLoaded || process.env.PARMANA_SKIP_DOTENV === "1") {
40
+ return;
41
+ }
42
+ dotEnvLoaded = true;
43
+ const envFile = findEnvFile();
44
+ if (envFile) {
45
+ dotenv.config({
46
+ path: envFile,
47
+ quiet: true,
48
+ });
49
+ }
50
+ else {
51
+ dotenv.config({ quiet: true });
52
+ }
53
+ }
54
+ /**
55
+ * Fail-closed by design, same discipline as caller authentication
56
+ * (see createCallerAuthenticator.ts): refuses to start rather than let
57
+ * an unset policy directory surface later as a raw filesystem error
58
+ * (ERR_INVALID_ARG_TYPE from path.join(undefined, ...)) inside
59
+ * FilePolicyRepository.load at request time.
60
+ */
61
+ function requirePolicyDirectory() {
62
+ const directory = process.env.PARMANA_POLICY_DIR;
63
+ if (directory === undefined || directory.trim() === "") {
64
+ throw new Error("PARMANA_POLICY_DIR is not set. Refusing to start without a " +
65
+ "configured policy directory; the server cannot load or evaluate " +
66
+ "policies without it. Set PARMANA_POLICY_DIR to the directory " +
67
+ "containing policy files (e.g. ./policies).");
68
+ }
69
+ return directory;
70
+ }
71
+ /**
72
+ * Loads the immutable Parmana configuration.
73
+ *
74
+ * This is the only location where process.env
75
+ * should be accessed.
76
+ */
77
+ /**
78
+ * HYBRID_SCHEMA_VERSION: unset means 2. Any other value must be exactly
79
+ * 2 or 3, and anything else throws, so a typo cannot pick a schema
80
+ * version silently.
81
+ */
82
+ function parseHybridSchemaVersion(value, acknowledged) {
83
+ if (value === undefined || value.trim() === "") {
84
+ return 2;
85
+ }
86
+ if (value === "2") {
87
+ return 2;
88
+ }
89
+ if (value === "3") {
90
+ //
91
+ // Schema version 3 records are not readable by the SDKs and by
92
+ // the published third-party verifier until those are updated (ADR-0016 issuance gate).
93
+ // Refuse to start unless the operator also sets the acknowledgement,
94
+ // so a stray value cannot switch v3 on.
95
+ //
96
+ if (acknowledged !== "true") {
97
+ throw new Error("HYBRID_SCHEMA_VERSION=3 is refused unless HYBRID_SCHEMA_V3_ACKNOWLEDGED=true is also set (ADR-0016 issuance gate).");
98
+ }
99
+ return 3;
100
+ }
101
+ throw new Error(`HYBRID_SCHEMA_VERSION must be 2 or 3, got "${value}".`);
102
+ }
103
+ /**
104
+ * HYBRID_REQUIRED_FROM: unset or blank means no cutover. Otherwise it must be
105
+ * an ISO-8601 UTC timestamp ending in "Z", so it means the same time everywhere.
106
+ */
107
+ function parseHybridRequiredFrom(value) {
108
+ if (value === undefined || value.trim() === "") {
109
+ return undefined;
110
+ }
111
+ if (!value.endsWith("Z") || Number.isNaN(Date.parse(value))) {
112
+ throw new Error(`HYBRID_REQUIRED_FROM must be an ISO-8601 UTC timestamp ending in "Z", got "${value}".`);
113
+ }
114
+ return value;
115
+ }
116
+ export function loadConfig() {
117
+ loadDotEnvOnce();
118
+ return Object.freeze({
119
+ environment: Object.freeze({
120
+ nodeEnv: process.env.NODE_ENV ?? "development",
121
+ }),
122
+ storage: Object.freeze({
123
+ provider: parseStorageProvider(process.env.PARMANA_STORAGE),
124
+ ...optionalProperty("databaseUrl", process.env.DATABASE_URL),
125
+ }),
126
+ crypto: Object.freeze({
127
+ mode: parseCryptoMode(process.env.CRYPTO_MODE),
128
+ hashProvider: parseHashAlgorithm(process.env.HASH_PROVIDER),
129
+ primarySignatureProvider: parseSignatureAlgorithm(process.env.PRIMARY_SIGNATURE_PROVIDER),
130
+ ...optionalProperty("secondarySignatureProvider", process.env.SECONDARY_SIGNATURE_PROVIDER
131
+ ? parseSignatureAlgorithm(process.env.SECONDARY_SIGNATURE_PROVIDER)
132
+ : undefined),
133
+ requireHybridSignature: process.env.HYBRID_SIGNATURE_REQUIRED === "true",
134
+ ...optionalProperty("hybridRequiredFrom", parseHybridRequiredFrom(process.env.HYBRID_REQUIRED_FROM)),
135
+ hybridSchemaVersion: parseHybridSchemaVersion(process.env.HYBRID_SCHEMA_VERSION, process.env.HYBRID_SCHEMA_V3_ACKNOWLEDGED),
136
+ }),
137
+ keys: Object.freeze({
138
+ provider: parseKeyProvider(process.env.KEY_PROVIDER),
139
+ keyDirectory: process.env.PARMANA_KEY_DIR,
140
+ }),
141
+ secrets: Object.freeze({
142
+ provider: parseSecretsProvider(process.env.PARMANA_SECRETS_PROVIDER),
143
+ }),
144
+ authorization: Object.freeze({
145
+ ttlSeconds: Number(process.env.EXECUTION_AUTHORIZATION_TTL_SECONDS ?? 120),
146
+ }),
147
+ policy: Object.freeze({
148
+ directory: requirePolicyDirectory(),
149
+ }),
150
+ trust: Object.freeze({
151
+ profile: parseTrustProfile(process.env.TRUST_PROFILE),
152
+ receiptVersion: process.env.RECEIPT_VERSION ?? "1",
153
+ }),
154
+ api: Object.freeze({
155
+ port: Number(process.env.PORT ?? 3000),
156
+ }),
157
+ auth: Object.freeze({
158
+ keys: parseApiKeys(process.env.PARMANA_API_KEYS),
159
+ disabled: process.env.PARMANA_AUTH_DISABLED === "true",
160
+ }),
161
+ rateLimit: Object.freeze({
162
+ executePerMinute: Number(process.env.RATE_LIMIT_EXECUTE_PER_MINUTE ?? 30),
163
+ healthPerMinute: Number(process.env.RATE_LIMIT_HEALTH_PER_MINUTE ?? 300),
164
+ publicPerMinute: Number(process.env.RATE_LIMIT_PUBLIC_PER_MINUTE ?? 60),
165
+ authFailurePerMinute: Number(process.env.RATE_LIMIT_AUTH_FAILURE_PER_MINUTE ?? 30),
166
+ }),
167
+ logging: Object.freeze({
168
+ level: process.env.LOG_LEVEL ?? "info",
169
+ }),
170
+ });
171
+ }
172
+ //# sourceMappingURL=Config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Config.js","sourceRoot":"","sources":["../../src/config/Config.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAUzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAUpD,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,GACb,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;GAOG;AACH,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC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F,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC;YACrB,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,MAAM;SACvC,CAAC;KACH,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Returns the immutable Parmana configuration.
3
+ */
4
+ export declare function getConfig(): Readonly<import("./Config.js").Config>;
5
+ //# sourceMappingURL=ConfigLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigLoader.d.ts","sourceRoot":"","sources":["../../src/config/ConfigLoader.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,SAAS,2CAExB"}
@@ -0,0 +1,8 @@
1
+ import { loadConfig } from "./Config.js";
2
+ /**
3
+ * Returns the immutable Parmana configuration.
4
+ */
5
+ export function getConfig() {
6
+ return loadConfig();
7
+ }
8
+ //# sourceMappingURL=ConfigLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigLoader.js","sourceRoot":"","sources":["../../src/config/ConfigLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;GAEG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,UAAU,EAAE,CAAC;AACtB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns an object containing the property only when
3
+ * the value is defined.
4
+ */
5
+ export declare function optionalProperty<T>(key: string, value: T | undefined): Record<string, T>;
6
+ //# sourceMappingURL=ConfigUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigUtils.d.ts","sourceRoot":"","sources":["../../src/config/ConfigUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,CAAC,GAAG,SAAS,GACnB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAEnB"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Returns an object containing the property only when
3
+ * the value is defined.
4
+ */
5
+ export function optionalProperty(key, value) {
6
+ return value === undefined ? {} : { [key]: value };
7
+ }
8
+ //# sourceMappingURL=ConfigUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigUtils.js","sourceRoot":"","sources":["../../src/config/ConfigUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAW,EACX,KAAoB;IAEpB,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC;AACrD,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { type CryptoMode, type HashAlgorithm, type SignatureAlgorithm } from "./CryptoAlgorithms.js";
2
+ import { type StorageProvider } from "./StorageProviders.js";
3
+ import { type KeyProvider } from "./KeyProviders.js";
4
+ import { type SecretsProvider } from "./SecretsProviders.js";
5
+ import { type TrustProfile } from "./TrustProfiles.js";
6
+ import type { ApiKeyEntry } from "./ApiKeyEntry.js";
7
+ export declare const parseStorageProvider: (value?: string) => StorageProvider;
8
+ export declare const parseCryptoMode: (value?: string) => CryptoMode;
9
+ export declare const parseHashAlgorithm: (value?: string) => HashAlgorithm;
10
+ export declare const parseSignatureAlgorithm: (value?: string) => SignatureAlgorithm;
11
+ export declare const parseKeyProvider: (value?: string) => KeyProvider;
12
+ /**
13
+ * Unlike the other settings, an invalid value is not echoed: a value set
14
+ * in the wrong variable can be a real secret (a token pasted into
15
+ * PARMANA_SECRETS_PROVIDER, say), and this message reaches logs. Kept
16
+ * separate from parse() so the value never reaches its message.
17
+ */
18
+ export declare const parseSecretsProvider: (value?: string) => SecretsProvider;
19
+ export declare const parseTrustProfile: (value?: string) => TrustProfile;
20
+ /**
21
+ * Parses PARMANA_API_KEYS: a JSON array of
22
+ * { "callerId": string, "keyHash": string } entries.
23
+ *
24
+ * Returns an empty array when unset — callers of this
25
+ * function decide what an empty result means (the
26
+ * caller-authenticator bootstrap treats it as "refuse to
27
+ * start unless auth is explicitly disabled").
28
+ */
29
+ export declare function parseApiKeys(value?: string): ApiKeyEntry[];
30
+ //# sourceMappingURL=ConfigValidation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigValidation.d.ts","sourceRoot":"","sources":["../../src/config/ConfigValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EAEf,KAAK,aAAa,EAElB,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAItE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAkBpD,eAAO,MAAM,oBAAoB,WAAY,MAAM,KAAG,eAarD,CAAC;AAEF,eAAO,MAAM,eAAe,WAAY,MAAM,KAAG,UACa,CAAC;AAE/D,eAAO,MAAM,kBAAkB,WAAY,MAAM,KAAG,aACkB,CAAC;AAgBvE,eAAO,MAAM,uBAAuB,WAAY,MAAM,KAAG,kBAMtD,CAAC;AAEJ,eAAO,MAAM,gBAAgB,WAAY,MAAM,KAAG,WACc,CAAC;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,WAAY,MAAM,KAAG,eAerD,CAAC;AAEF,eAAO,MAAM,iBAAiB,WAAY,MAAM,KAAG,YACa,CAAC;AAIjE;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE,CAuJ1D"}
@@ -0,0 +1,170 @@
1
+ import { CryptoModes, HashAlgorithms, SignatureAlgorithms, } from "./CryptoAlgorithms.js";
2
+ import { StorageProviders } from "./StorageProviders.js";
3
+ import { KeyProviders } from "./KeyProviders.js";
4
+ import { SecretsProviders } from "./SecretsProviders.js";
5
+ import { TrustProfiles } from "./TrustProfiles.js";
6
+ import { createPublicKey } from "node:crypto";
7
+ import { AuthorityType } from "../domain/authority.js";
8
+ function parse(value, values, name, defaultValue) {
9
+ const resolved = value ?? defaultValue;
10
+ if (Object.values(values).includes(resolved)) {
11
+ return resolved;
12
+ }
13
+ throw new Error(`Invalid ${name}: ${resolved}`);
14
+ }
15
+ export const parseStorageProvider = (value) => {
16
+ if (process.env.DATABASE_PROVIDER !== undefined) {
17
+ throw new Error("DATABASE_PROVIDER is no longer read; set PARMANA_STORAGE instead.");
18
+ }
19
+ return parse(value, StorageProviders, "PARMANA_STORAGE", StorageProviders.MEMORY);
20
+ };
21
+ export const parseCryptoMode = (value) => parse(value, CryptoModes, "CRYPTO_MODE", CryptoModes.SINGLE);
22
+ export const parseHashAlgorithm = (value) => parse(value, HashAlgorithms, "HASH_PROVIDER", HashAlgorithms.SHA256);
23
+ /**
24
+ * Accepted input aliases for a SignatureAlgorithm config value, resolved
25
+ * to the canonical internal identifier before validation. Additive only:
26
+ * the canonical identifiers themselves (SignatureAlgorithms' own values,
27
+ * e.g. "dilithium3") are never renamed, so an existing
28
+ * PRIMARY_SIGNATURE_PROVIDER=dilithium3 deployment is unaffected. Lets a
29
+ * new deployment use "ml-dsa-65" (the NIST/FIPS 204 standard name this
30
+ * codebase's own docs already use when describing "dilithium3" to
31
+ * readers) without a breaking rename of the internal identifier itself.
32
+ */
33
+ const SIGNATURE_ALGORITHM_ALIASES = {
34
+ "ml-dsa-65": SignatureAlgorithms.DILITHIUM3,
35
+ };
36
+ export const parseSignatureAlgorithm = (value) => parse(value !== undefined ? (SIGNATURE_ALGORITHM_ALIASES[value] ?? value) : value, SignatureAlgorithms, "SIGNATURE_PROVIDER", SignatureAlgorithms.ED25519);
37
+ export const parseKeyProvider = (value) => parse(value, KeyProviders, "KEY_PROVIDER", KeyProviders.LOCAL);
38
+ /**
39
+ * Unlike the other settings, an invalid value is not echoed: a value set
40
+ * in the wrong variable can be a real secret (a token pasted into
41
+ * PARMANA_SECRETS_PROVIDER, say), and this message reaches logs. Kept
42
+ * separate from parse() so the value never reaches its message.
43
+ */
44
+ export const parseSecretsProvider = (value) => {
45
+ const accepted = Object.values(SecretsProviders);
46
+ const match = accepted.find((provider) => provider === value);
47
+ if (value === undefined) {
48
+ return SecretsProviders.ENV;
49
+ }
50
+ if (match === undefined) {
51
+ throw new Error(`Invalid PARMANA_SECRETS_PROVIDER: expected one of ${accepted.join(", ")}`);
52
+ }
53
+ return match;
54
+ };
55
+ export const parseTrustProfile = (value) => parse(value, TrustProfiles, "TRUST_PROFILE", TrustProfiles.V1);
56
+ const API_KEY_HASH_PATTERN = /^[0-9a-f]{64}$/;
57
+ /**
58
+ * Parses PARMANA_API_KEYS: a JSON array of
59
+ * { "callerId": string, "keyHash": string } entries.
60
+ *
61
+ * Returns an empty array when unset — callers of this
62
+ * function decide what an empty result means (the
63
+ * caller-authenticator bootstrap treats it as "refuse to
64
+ * start unless auth is explicitly disabled").
65
+ */
66
+ export function parseApiKeys(value) {
67
+ if (value === undefined || value.trim() === "") {
68
+ return [];
69
+ }
70
+ let parsed;
71
+ try {
72
+ parsed = JSON.parse(value);
73
+ }
74
+ catch {
75
+ throw new Error("PARMANA_API_KEYS is not valid JSON. Expected an array of " +
76
+ '{ "callerId": string, "keyHash": string } entries.');
77
+ }
78
+ if (!Array.isArray(parsed)) {
79
+ throw new Error("PARMANA_API_KEYS must be a JSON array of " +
80
+ '{ "callerId": string, "keyHash": string } entries.');
81
+ }
82
+ return parsed.map((entry, index) => {
83
+ const record = entry;
84
+ const validEntry = typeof entry === "object" &&
85
+ entry !== null &&
86
+ typeof record.callerId === "string" &&
87
+ record.callerId !== "" &&
88
+ typeof record.keyHash === "string" &&
89
+ API_KEY_HASH_PATTERN.test(record.keyHash);
90
+ if (!validEntry) {
91
+ throw new Error(`PARMANA_API_KEYS[${index}] is invalid. Each entry must be ` +
92
+ '{ "callerId": non-empty string, "keyHash": 64-character lowercase hex }.');
93
+ }
94
+ const allowedPrincipalIds = record.allowedPrincipalIds;
95
+ if (allowedPrincipalIds !== undefined) {
96
+ const validAllowedPrincipalIds = Array.isArray(allowedPrincipalIds) &&
97
+ allowedPrincipalIds.every((id) => typeof id === "string" && id !== "");
98
+ if (!validAllowedPrincipalIds) {
99
+ throw new Error(`PARMANA_API_KEYS[${index}].allowedPrincipalIds must be an array ` +
100
+ "of non-empty strings when present.");
101
+ }
102
+ }
103
+ const allowedCapabilities = record.allowedCapabilities;
104
+ if (allowedCapabilities !== undefined) {
105
+ const validAllowedCapabilities = Array.isArray(allowedCapabilities) &&
106
+ allowedCapabilities.every((capability) => typeof capability === "string" && capability !== "");
107
+ if (!validAllowedCapabilities) {
108
+ throw new Error(`PARMANA_API_KEYS[${index}].allowedCapabilities must be an array ` +
109
+ 'of non-empty strings when present. Use "*" as an entry to ' +
110
+ "grant every capability.");
111
+ }
112
+ }
113
+ const allowedTenantIds = record.allowedTenantIds;
114
+ if (allowedTenantIds !== undefined) {
115
+ const validAllowedTenantIds = Array.isArray(allowedTenantIds) &&
116
+ allowedTenantIds.every((id) => typeof id === "string" && id !== "");
117
+ if (!validAllowedTenantIds) {
118
+ throw new Error(`PARMANA_API_KEYS[${index}].allowedTenantIds must be an array ` +
119
+ "of non-empty strings when present.");
120
+ }
121
+ }
122
+ const credentialHolderType = record.credentialHolderType;
123
+ if (credentialHolderType !== undefined) {
124
+ const validCredentialHolderType = typeof credentialHolderType === "string" &&
125
+ Object.values(AuthorityType).includes(credentialHolderType);
126
+ if (!validCredentialHolderType) {
127
+ throw new Error(`PARMANA_API_KEYS[${index}].credentialHolderType must be one of ` +
128
+ `${Object.values(AuthorityType).join(", ")} when present.`);
129
+ }
130
+ }
131
+ const stepUpPublicKey = record.stepUpPublicKey;
132
+ if (stepUpPublicKey !== undefined) {
133
+ const validShape = typeof stepUpPublicKey === "string" && stepUpPublicKey.trim() !== "";
134
+ let validKey = false;
135
+ if (validShape) {
136
+ try {
137
+ const keyObject = createPublicKey(stepUpPublicKey);
138
+ validKey = keyObject.asymmetricKeyType === "ed25519";
139
+ }
140
+ catch {
141
+ validKey = false;
142
+ }
143
+ }
144
+ if (!validShape || !validKey) {
145
+ throw new Error(`PARMANA_API_KEYS[${index}].stepUpPublicKey must be a PEM-encoded ` +
146
+ "Ed25519 public key when present.");
147
+ }
148
+ }
149
+ return {
150
+ callerId: record.callerId,
151
+ keyHash: record.keyHash,
152
+ ...(allowedPrincipalIds !== undefined
153
+ ? { allowedPrincipalIds: allowedPrincipalIds }
154
+ : {}),
155
+ ...(allowedCapabilities !== undefined
156
+ ? { allowedCapabilities: allowedCapabilities }
157
+ : {}),
158
+ ...(allowedTenantIds !== undefined
159
+ ? { allowedTenantIds: allowedTenantIds }
160
+ : {}),
161
+ ...(credentialHolderType !== undefined
162
+ ? { credentialHolderType: credentialHolderType }
163
+ : {}),
164
+ ...(stepUpPublicKey !== undefined
165
+ ? { stepUpPublicKey: stepUpPublicKey }
166
+ : {}),
167
+ };
168
+ });
169
+ }
170
+ //# sourceMappingURL=ConfigValidation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigValidation.js","sourceRoot":"","sources":["../../src/config/ConfigValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEX,cAAc,EAEd,mBAAmB,GAEpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAwB,MAAM,uBAAuB,CAAC;AAE/E,OAAO,EAAE,YAAY,EAAoB,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAwB,MAAM,uBAAuB,CAAC;AAE/E,OAAO,EAAE,aAAa,EAAqB,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,EA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