@naylence/advanced-security 0.3.7-test.114 → 0.3.7-test.115

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 (421) hide show
  1. package/dist/browser/index.cjs +9864 -0
  2. package/dist/browser/index.mjs +9811 -0
  3. package/dist/cjs/advanced-security-isomorphic.js +82 -0
  4. package/dist/cjs/advanced-security-isomorphic.js.map +1 -0
  5. package/dist/cjs/browser.js +25 -0
  6. package/dist/cjs/browser.js.map +1 -0
  7. package/dist/cjs/index.js +2 -0
  8. package/dist/cjs/index.js.map +1 -0
  9. package/dist/cjs/install-env.js +2 -0
  10. package/dist/cjs/install-env.js.map +1 -0
  11. package/dist/cjs/naylence/fame/factory-manifest.js +39 -0
  12. package/dist/cjs/naylence/fame/factory-manifest.js.map +1 -0
  13. package/dist/cjs/naylence/fame/security/cert/browser-csr.js +103 -0
  14. package/dist/cjs/naylence/fame/security/cert/browser-csr.js.map +1 -0
  15. package/dist/cjs/naylence/fame/security/cert/ca-server-cli.js +30 -0
  16. package/dist/cjs/naylence/fame/security/cert/ca-server-cli.js.map +1 -0
  17. package/dist/cjs/naylence/fame/security/cert/ca-server.js +223 -0
  18. package/dist/cjs/naylence/fame/security/cert/ca-server.js.map +1 -0
  19. package/dist/cjs/naylence/fame/security/cert/ca-service-client.js +585 -0
  20. package/dist/cjs/naylence/fame/security/cert/ca-service-client.js.map +1 -0
  21. package/dist/cjs/naylence/fame/security/cert/ca-service-factory.js +61 -0
  22. package/dist/cjs/naylence/fame/security/cert/ca-service-factory.js.map +1 -0
  23. package/dist/cjs/naylence/fame/security/cert/ca-types.js +39 -0
  24. package/dist/cjs/naylence/fame/security/cert/ca-types.js.map +1 -0
  25. package/dist/cjs/naylence/fame/security/cert/csr-types.js +2 -0
  26. package/dist/cjs/naylence/fame/security/cert/csr-types.js.map +1 -0
  27. package/dist/cjs/naylence/fame/security/cert/default-ca-service-factory.js +66 -0
  28. package/dist/cjs/naylence/fame/security/cert/default-ca-service-factory.js.map +1 -0
  29. package/dist/cjs/naylence/fame/security/cert/default-ca-service.js +364 -0
  30. package/dist/cjs/naylence/fame/security/cert/default-ca-service.js.map +1 -0
  31. package/dist/cjs/naylence/fame/security/cert/default-certificate-manager-factory.js +73 -0
  32. package/dist/cjs/naylence/fame/security/cert/default-certificate-manager-factory.js.map +1 -0
  33. package/dist/cjs/naylence/fame/security/cert/default-certificate-manager.js +815 -0
  34. package/dist/cjs/naylence/fame/security/cert/default-certificate-manager.js.map +1 -0
  35. package/dist/cjs/naylence/fame/security/cert/grants.js +2 -0
  36. package/dist/cjs/naylence/fame/security/cert/grants.js.map +1 -0
  37. package/dist/cjs/naylence/fame/security/cert/index.js +18 -0
  38. package/dist/cjs/naylence/fame/security/cert/index.js.map +1 -0
  39. package/dist/cjs/naylence/fame/security/cert/internal-ca-service.js +741 -0
  40. package/dist/cjs/naylence/fame/security/cert/internal-ca-service.js.map +1 -0
  41. package/dist/cjs/naylence/fame/security/cert/node-ed25519-csr.js +156 -0
  42. package/dist/cjs/naylence/fame/security/cert/node-ed25519-csr.js.map +1 -0
  43. package/dist/cjs/naylence/fame/security/cert/oid-constants.js +7 -0
  44. package/dist/cjs/naylence/fame/security/cert/oid-constants.js.map +1 -0
  45. package/dist/cjs/naylence/fame/security/cert/trust-store/anchor-utils.js +119 -0
  46. package/dist/cjs/naylence/fame/security/cert/trust-store/anchor-utils.js.map +1 -0
  47. package/dist/cjs/naylence/fame/security/cert/trust-store/browser-trust-store-provider-factory.js +82 -0
  48. package/dist/cjs/naylence/fame/security/cert/trust-store/browser-trust-store-provider-factory.js.map +1 -0
  49. package/dist/cjs/naylence/fame/security/cert/trust-store/env-provider.js +168 -0
  50. package/dist/cjs/naylence/fame/security/cert/trust-store/env-provider.js.map +1 -0
  51. package/dist/cjs/naylence/fame/security/cert/trust-store/fame-ca-certs-parser.js +257 -0
  52. package/dist/cjs/naylence/fame/security/cert/trust-store/fame-ca-certs-parser.js.map +1 -0
  53. package/dist/cjs/naylence/fame/security/cert/trust-store/http-bundle-provider.js +497 -0
  54. package/dist/cjs/naylence/fame/security/cert/trust-store/http-bundle-provider.js.map +1 -0
  55. package/dist/cjs/naylence/fame/security/cert/trust-store/http-signed-bundle-provider.js +2 -0
  56. package/dist/cjs/naylence/fame/security/cert/trust-store/http-signed-bundle-provider.js.map +1 -0
  57. package/dist/cjs/naylence/fame/security/cert/trust-store/node-trust-store-provider-factory.js +61 -0
  58. package/dist/cjs/naylence/fame/security/cert/trust-store/node-trust-store-provider-factory.js.map +1 -0
  59. package/dist/cjs/naylence/fame/security/cert/trust-store/static-bundle-provider.js +44 -0
  60. package/dist/cjs/naylence/fame/security/cert/trust-store/static-bundle-provider.js.map +1 -0
  61. package/dist/cjs/naylence/fame/security/cert/trust-store/trust-store-provider-factory.js +40 -0
  62. package/dist/cjs/naylence/fame/security/cert/trust-store/trust-store-provider-factory.js.map +1 -0
  63. package/dist/cjs/naylence/fame/security/cert/trust-store/trust-store-provider.js +2 -0
  64. package/dist/cjs/naylence/fame/security/cert/trust-store/trust-store-provider.js.map +1 -0
  65. package/dist/cjs/naylence/fame/security/cert/util.js +515 -0
  66. package/dist/cjs/naylence/fame/security/cert/util.js.map +1 -0
  67. package/dist/cjs/naylence/fame/security/encryption/channel/channel-encryption-manager-factory.js +85 -0
  68. package/dist/cjs/naylence/fame/security/encryption/channel/channel-encryption-manager-factory.js.map +1 -0
  69. package/dist/cjs/naylence/fame/security/encryption/channel/channel-encryption-manager.js +743 -0
  70. package/dist/cjs/naylence/fame/security/encryption/channel/channel-encryption-manager.js.map +1 -0
  71. package/dist/cjs/naylence/fame/security/encryption/channel/index.js +3 -0
  72. package/dist/cjs/naylence/fame/security/encryption/channel/index.js.map +1 -0
  73. package/dist/cjs/naylence/fame/security/encryption/composite-encryption-manager-factory.js +113 -0
  74. package/dist/cjs/naylence/fame/security/encryption/composite-encryption-manager-factory.js.map +1 -0
  75. package/dist/cjs/naylence/fame/security/encryption/composite-encryption-manager.js +321 -0
  76. package/dist/cjs/naylence/fame/security/encryption/composite-encryption-manager.js.map +1 -0
  77. package/dist/cjs/naylence/fame/security/encryption/default-secure-channel-manager-factory.js +53 -0
  78. package/dist/cjs/naylence/fame/security/encryption/default-secure-channel-manager-factory.js.map +1 -0
  79. package/dist/cjs/naylence/fame/security/encryption/default-secure-channel-manager.js +278 -0
  80. package/dist/cjs/naylence/fame/security/encryption/default-secure-channel-manager.js.map +1 -0
  81. package/dist/cjs/naylence/fame/security/encryption/encryption-manager-registry.js +167 -0
  82. package/dist/cjs/naylence/fame/security/encryption/encryption-manager-registry.js.map +1 -0
  83. package/dist/cjs/naylence/fame/security/encryption/index.js +7 -0
  84. package/dist/cjs/naylence/fame/security/encryption/index.js.map +1 -0
  85. package/dist/cjs/naylence/fame/security/encryption/sealed/index.js +3 -0
  86. package/dist/cjs/naylence/fame/security/encryption/sealed/index.js.map +1 -0
  87. package/dist/cjs/naylence/fame/security/encryption/sealed/x25519-encryption-manager-factory.js +82 -0
  88. package/dist/cjs/naylence/fame/security/encryption/sealed/x25519-encryption-manager-factory.js.map +1 -0
  89. package/dist/cjs/naylence/fame/security/encryption/sealed/x25519-encryption-manager.js +542 -0
  90. package/dist/cjs/naylence/fame/security/encryption/sealed/x25519-encryption-manager.js.map +1 -0
  91. package/dist/cjs/naylence/fame/security/index.js +6 -0
  92. package/dist/cjs/naylence/fame/security/index.js.map +1 -0
  93. package/dist/cjs/naylence/fame/security/keys/index.js +3 -0
  94. package/dist/cjs/naylence/fame/security/keys/index.js.map +1 -0
  95. package/dist/cjs/naylence/fame/security/keys/x5c-key-manager-factory.js +36 -0
  96. package/dist/cjs/naylence/fame/security/keys/x5c-key-manager-factory.js.map +1 -0
  97. package/dist/cjs/naylence/fame/security/keys/x5c-key-manager.js +405 -0
  98. package/dist/cjs/naylence/fame/security/keys/x5c-key-manager.js.map +1 -0
  99. package/dist/cjs/naylence/fame/security/register-advanced-security-factories.js +283 -0
  100. package/dist/cjs/naylence/fame/security/register-advanced-security-factories.js.map +1 -0
  101. package/dist/cjs/naylence/fame/security/signing/eddsa-envelope-signer-factory.js +34 -0
  102. package/dist/cjs/naylence/fame/security/signing/eddsa-envelope-signer-factory.js.map +1 -0
  103. package/dist/cjs/naylence/fame/security/signing/eddsa-envelope-verifier-factory.js +33 -0
  104. package/dist/cjs/naylence/fame/security/signing/eddsa-envelope-verifier-factory.js.map +1 -0
  105. package/dist/cjs/naylence/fame/security/signing/eddsa-envelope-verifier.js +189 -0
  106. package/dist/cjs/naylence/fame/security/signing/eddsa-envelope-verifier.js.map +1 -0
  107. package/dist/cjs/naylence/fame/stickiness/aft-helper.js +72 -0
  108. package/dist/cjs/naylence/fame/stickiness/aft-helper.js.map +1 -0
  109. package/dist/cjs/naylence/fame/stickiness/aft-load-balancer-stickiness-manager-factory.js +65 -0
  110. package/dist/cjs/naylence/fame/stickiness/aft-load-balancer-stickiness-manager-factory.js.map +1 -0
  111. package/dist/cjs/naylence/fame/stickiness/aft-load-balancer-stickiness-manager.js +447 -0
  112. package/dist/cjs/naylence/fame/stickiness/aft-load-balancer-stickiness-manager.js.map +1 -0
  113. package/dist/cjs/naylence/fame/stickiness/aft-model.js +54 -0
  114. package/dist/cjs/naylence/fame/stickiness/aft-model.js.map +1 -0
  115. package/dist/cjs/naylence/fame/stickiness/aft-replica-stickiness-manager-factory.js +50 -0
  116. package/dist/cjs/naylence/fame/stickiness/aft-replica-stickiness-manager-factory.js.map +1 -0
  117. package/dist/cjs/naylence/fame/stickiness/aft-replica-stickiness-manager.js +203 -0
  118. package/dist/cjs/naylence/fame/stickiness/aft-replica-stickiness-manager.js.map +1 -0
  119. package/dist/cjs/naylence/fame/stickiness/aft-signer.js +147 -0
  120. package/dist/cjs/naylence/fame/stickiness/aft-signer.js.map +1 -0
  121. package/dist/cjs/naylence/fame/stickiness/aft-utils.js +90 -0
  122. package/dist/cjs/naylence/fame/stickiness/aft-utils.js.map +1 -0
  123. package/dist/cjs/naylence/fame/stickiness/aft-verifier.js +290 -0
  124. package/dist/cjs/naylence/fame/stickiness/aft-verifier.js.map +1 -0
  125. package/dist/cjs/naylence/fame/stickiness/index.js +11 -0
  126. package/dist/cjs/naylence/fame/stickiness/index.js.map +1 -0
  127. package/dist/cjs/naylence/fame/stickiness/stickiness-mode.js +24 -0
  128. package/dist/cjs/naylence/fame/stickiness/stickiness-mode.js.map +1 -0
  129. package/dist/cjs/naylence/fame/welcome/advanced-welcome-service-factory.js +93 -0
  130. package/dist/cjs/naylence/fame/welcome/advanced-welcome-service-factory.js.map +1 -0
  131. package/dist/cjs/naylence/fame/welcome/advanced-welcome-service.js +212 -0
  132. package/dist/cjs/naylence/fame/welcome/advanced-welcome-service.js.map +1 -0
  133. package/dist/cjs/naylence/fame/welcome/index.js +3 -0
  134. package/dist/cjs/naylence/fame/welcome/index.js.map +1 -0
  135. package/dist/cjs/node.js +11 -0
  136. package/dist/cjs/node.js.map +1 -0
  137. package/dist/cjs/plugin.js +39 -0
  138. package/dist/cjs/plugin.js.map +1 -0
  139. package/dist/cjs/version.js +8 -0
  140. package/dist/cjs/version.js.map +1 -0
  141. package/dist/esm/advanced-security-isomorphic.js +82 -0
  142. package/dist/esm/advanced-security-isomorphic.js.map +1 -0
  143. package/dist/esm/browser.js +25 -0
  144. package/dist/esm/browser.js.map +1 -0
  145. package/dist/esm/index.js +2 -0
  146. package/dist/esm/index.js.map +1 -0
  147. package/dist/esm/install-env.js +2 -0
  148. package/dist/esm/install-env.js.map +1 -0
  149. package/dist/esm/naylence/fame/factory-manifest.js +39 -0
  150. package/dist/esm/naylence/fame/factory-manifest.js.map +1 -0
  151. package/dist/esm/naylence/fame/security/cert/browser-csr.js +103 -0
  152. package/dist/esm/naylence/fame/security/cert/browser-csr.js.map +1 -0
  153. package/dist/esm/naylence/fame/security/cert/ca-server-cli.js +30 -0
  154. package/dist/esm/naylence/fame/security/cert/ca-server-cli.js.map +1 -0
  155. package/dist/esm/naylence/fame/security/cert/ca-server.js +223 -0
  156. package/dist/esm/naylence/fame/security/cert/ca-server.js.map +1 -0
  157. package/dist/esm/naylence/fame/security/cert/ca-service-client.js +585 -0
  158. package/dist/esm/naylence/fame/security/cert/ca-service-client.js.map +1 -0
  159. package/dist/esm/naylence/fame/security/cert/ca-service-factory.js +61 -0
  160. package/dist/esm/naylence/fame/security/cert/ca-service-factory.js.map +1 -0
  161. package/dist/esm/naylence/fame/security/cert/ca-types.js +39 -0
  162. package/dist/esm/naylence/fame/security/cert/ca-types.js.map +1 -0
  163. package/dist/esm/naylence/fame/security/cert/csr-types.js +2 -0
  164. package/dist/esm/naylence/fame/security/cert/csr-types.js.map +1 -0
  165. package/dist/esm/naylence/fame/security/cert/default-ca-service-factory.js +66 -0
  166. package/dist/esm/naylence/fame/security/cert/default-ca-service-factory.js.map +1 -0
  167. package/dist/esm/naylence/fame/security/cert/default-ca-service.js +364 -0
  168. package/dist/esm/naylence/fame/security/cert/default-ca-service.js.map +1 -0
  169. package/dist/esm/naylence/fame/security/cert/default-certificate-manager-factory.js +73 -0
  170. package/dist/esm/naylence/fame/security/cert/default-certificate-manager-factory.js.map +1 -0
  171. package/dist/esm/naylence/fame/security/cert/default-certificate-manager.js +815 -0
  172. package/dist/esm/naylence/fame/security/cert/default-certificate-manager.js.map +1 -0
  173. package/dist/esm/naylence/fame/security/cert/grants.js +2 -0
  174. package/dist/esm/naylence/fame/security/cert/grants.js.map +1 -0
  175. package/dist/esm/naylence/fame/security/cert/index.js +18 -0
  176. package/dist/esm/naylence/fame/security/cert/index.js.map +1 -0
  177. package/dist/esm/naylence/fame/security/cert/internal-ca-service.js +741 -0
  178. package/dist/esm/naylence/fame/security/cert/internal-ca-service.js.map +1 -0
  179. package/dist/esm/naylence/fame/security/cert/node-ed25519-csr.js +156 -0
  180. package/dist/esm/naylence/fame/security/cert/node-ed25519-csr.js.map +1 -0
  181. package/dist/esm/naylence/fame/security/cert/oid-constants.js +7 -0
  182. package/dist/esm/naylence/fame/security/cert/oid-constants.js.map +1 -0
  183. package/dist/esm/naylence/fame/security/cert/trust-store/anchor-utils.js +119 -0
  184. package/dist/esm/naylence/fame/security/cert/trust-store/anchor-utils.js.map +1 -0
  185. package/dist/esm/naylence/fame/security/cert/trust-store/browser-trust-store-provider-factory.js +82 -0
  186. package/dist/esm/naylence/fame/security/cert/trust-store/browser-trust-store-provider-factory.js.map +1 -0
  187. package/dist/esm/naylence/fame/security/cert/trust-store/env-provider.js +168 -0
  188. package/dist/esm/naylence/fame/security/cert/trust-store/env-provider.js.map +1 -0
  189. package/dist/esm/naylence/fame/security/cert/trust-store/fame-ca-certs-parser.js +257 -0
  190. package/dist/esm/naylence/fame/security/cert/trust-store/fame-ca-certs-parser.js.map +1 -0
  191. package/dist/esm/naylence/fame/security/cert/trust-store/http-bundle-provider.js +497 -0
  192. package/dist/esm/naylence/fame/security/cert/trust-store/http-bundle-provider.js.map +1 -0
  193. package/dist/esm/naylence/fame/security/cert/trust-store/http-signed-bundle-provider.js +2 -0
  194. package/dist/esm/naylence/fame/security/cert/trust-store/http-signed-bundle-provider.js.map +1 -0
  195. package/dist/esm/naylence/fame/security/cert/trust-store/node-trust-store-provider-factory.js +61 -0
  196. package/dist/esm/naylence/fame/security/cert/trust-store/node-trust-store-provider-factory.js.map +1 -0
  197. package/dist/esm/naylence/fame/security/cert/trust-store/static-bundle-provider.js +44 -0
  198. package/dist/esm/naylence/fame/security/cert/trust-store/static-bundle-provider.js.map +1 -0
  199. package/dist/esm/naylence/fame/security/cert/trust-store/trust-store-provider-factory.js +40 -0
  200. package/dist/esm/naylence/fame/security/cert/trust-store/trust-store-provider-factory.js.map +1 -0
  201. package/dist/esm/naylence/fame/security/cert/trust-store/trust-store-provider.js +2 -0
  202. package/dist/esm/naylence/fame/security/cert/trust-store/trust-store-provider.js.map +1 -0
  203. package/dist/esm/naylence/fame/security/cert/util.js +515 -0
  204. package/dist/esm/naylence/fame/security/cert/util.js.map +1 -0
  205. package/dist/esm/naylence/fame/security/encryption/channel/channel-encryption-manager-factory.js +85 -0
  206. package/dist/esm/naylence/fame/security/encryption/channel/channel-encryption-manager-factory.js.map +1 -0
  207. package/dist/esm/naylence/fame/security/encryption/channel/channel-encryption-manager.js +743 -0
  208. package/dist/esm/naylence/fame/security/encryption/channel/channel-encryption-manager.js.map +1 -0
  209. package/dist/esm/naylence/fame/security/encryption/channel/index.js +3 -0
  210. package/dist/esm/naylence/fame/security/encryption/channel/index.js.map +1 -0
  211. package/dist/esm/naylence/fame/security/encryption/composite-encryption-manager-factory.js +113 -0
  212. package/dist/esm/naylence/fame/security/encryption/composite-encryption-manager-factory.js.map +1 -0
  213. package/dist/esm/naylence/fame/security/encryption/composite-encryption-manager.js +321 -0
  214. package/dist/esm/naylence/fame/security/encryption/composite-encryption-manager.js.map +1 -0
  215. package/dist/esm/naylence/fame/security/encryption/default-secure-channel-manager-factory.js +53 -0
  216. package/dist/esm/naylence/fame/security/encryption/default-secure-channel-manager-factory.js.map +1 -0
  217. package/dist/esm/naylence/fame/security/encryption/default-secure-channel-manager.js +278 -0
  218. package/dist/esm/naylence/fame/security/encryption/default-secure-channel-manager.js.map +1 -0
  219. package/dist/esm/naylence/fame/security/encryption/encryption-manager-registry.js +167 -0
  220. package/dist/esm/naylence/fame/security/encryption/encryption-manager-registry.js.map +1 -0
  221. package/dist/esm/naylence/fame/security/encryption/index.js +7 -0
  222. package/dist/esm/naylence/fame/security/encryption/index.js.map +1 -0
  223. package/dist/esm/naylence/fame/security/encryption/sealed/index.js +3 -0
  224. package/dist/esm/naylence/fame/security/encryption/sealed/index.js.map +1 -0
  225. package/dist/esm/naylence/fame/security/encryption/sealed/x25519-encryption-manager-factory.js +82 -0
  226. package/dist/esm/naylence/fame/security/encryption/sealed/x25519-encryption-manager-factory.js.map +1 -0
  227. package/dist/esm/naylence/fame/security/encryption/sealed/x25519-encryption-manager.js +542 -0
  228. package/dist/esm/naylence/fame/security/encryption/sealed/x25519-encryption-manager.js.map +1 -0
  229. package/dist/esm/naylence/fame/security/index.js +6 -0
  230. package/dist/esm/naylence/fame/security/index.js.map +1 -0
  231. package/dist/esm/naylence/fame/security/keys/index.js +3 -0
  232. package/dist/esm/naylence/fame/security/keys/index.js.map +1 -0
  233. package/dist/esm/naylence/fame/security/keys/x5c-key-manager-factory.js +36 -0
  234. package/dist/esm/naylence/fame/security/keys/x5c-key-manager-factory.js.map +1 -0
  235. package/dist/esm/naylence/fame/security/keys/x5c-key-manager.js +405 -0
  236. package/dist/esm/naylence/fame/security/keys/x5c-key-manager.js.map +1 -0
  237. package/dist/esm/naylence/fame/security/register-advanced-security-factories.js +283 -0
  238. package/dist/esm/naylence/fame/security/register-advanced-security-factories.js.map +1 -0
  239. package/dist/esm/naylence/fame/security/signing/eddsa-envelope-signer-factory.js +34 -0
  240. package/dist/esm/naylence/fame/security/signing/eddsa-envelope-signer-factory.js.map +1 -0
  241. package/dist/esm/naylence/fame/security/signing/eddsa-envelope-verifier-factory.js +33 -0
  242. package/dist/esm/naylence/fame/security/signing/eddsa-envelope-verifier-factory.js.map +1 -0
  243. package/dist/esm/naylence/fame/security/signing/eddsa-envelope-verifier.js +189 -0
  244. package/dist/esm/naylence/fame/security/signing/eddsa-envelope-verifier.js.map +1 -0
  245. package/dist/esm/naylence/fame/stickiness/aft-helper.js +72 -0
  246. package/dist/esm/naylence/fame/stickiness/aft-helper.js.map +1 -0
  247. package/dist/esm/naylence/fame/stickiness/aft-load-balancer-stickiness-manager-factory.js +65 -0
  248. package/dist/esm/naylence/fame/stickiness/aft-load-balancer-stickiness-manager-factory.js.map +1 -0
  249. package/dist/esm/naylence/fame/stickiness/aft-load-balancer-stickiness-manager.js +447 -0
  250. package/dist/esm/naylence/fame/stickiness/aft-load-balancer-stickiness-manager.js.map +1 -0
  251. package/dist/esm/naylence/fame/stickiness/aft-model.js +54 -0
  252. package/dist/esm/naylence/fame/stickiness/aft-model.js.map +1 -0
  253. package/dist/esm/naylence/fame/stickiness/aft-replica-stickiness-manager-factory.js +50 -0
  254. package/dist/esm/naylence/fame/stickiness/aft-replica-stickiness-manager-factory.js.map +1 -0
  255. package/dist/esm/naylence/fame/stickiness/aft-replica-stickiness-manager.js +203 -0
  256. package/dist/esm/naylence/fame/stickiness/aft-replica-stickiness-manager.js.map +1 -0
  257. package/dist/esm/naylence/fame/stickiness/aft-signer.js +147 -0
  258. package/dist/esm/naylence/fame/stickiness/aft-signer.js.map +1 -0
  259. package/dist/esm/naylence/fame/stickiness/aft-utils.js +90 -0
  260. package/dist/esm/naylence/fame/stickiness/aft-utils.js.map +1 -0
  261. package/dist/esm/naylence/fame/stickiness/aft-verifier.js +290 -0
  262. package/dist/esm/naylence/fame/stickiness/aft-verifier.js.map +1 -0
  263. package/dist/esm/naylence/fame/stickiness/index.js +11 -0
  264. package/dist/esm/naylence/fame/stickiness/index.js.map +1 -0
  265. package/dist/esm/naylence/fame/stickiness/stickiness-mode.js +24 -0
  266. package/dist/esm/naylence/fame/stickiness/stickiness-mode.js.map +1 -0
  267. package/dist/esm/naylence/fame/welcome/advanced-welcome-service-factory.js +93 -0
  268. package/dist/esm/naylence/fame/welcome/advanced-welcome-service-factory.js.map +1 -0
  269. package/dist/esm/naylence/fame/welcome/advanced-welcome-service.js +212 -0
  270. package/dist/esm/naylence/fame/welcome/advanced-welcome-service.js.map +1 -0
  271. package/dist/esm/naylence/fame/welcome/index.js +3 -0
  272. package/dist/esm/naylence/fame/welcome/index.js.map +1 -0
  273. package/dist/esm/node.js +11 -0
  274. package/dist/esm/node.js.map +1 -0
  275. package/dist/esm/plugin.js +39 -0
  276. package/dist/esm/plugin.js.map +1 -0
  277. package/dist/esm/version.js +8 -0
  278. package/dist/esm/version.js.map +1 -0
  279. package/dist/node/index.cjs +9855 -0
  280. package/dist/node/index.mjs +9800 -0
  281. package/dist/node/node.cjs +10139 -0
  282. package/dist/node/node.mjs +10046 -0
  283. package/dist/types/advanced-security-isomorphic.d.ts +24 -0
  284. package/dist/types/advanced-security-isomorphic.d.ts.map +1 -0
  285. package/dist/types/browser.d.ts +19 -0
  286. package/dist/types/browser.d.ts.map +1 -0
  287. package/dist/types/index.d.ts +2 -0
  288. package/dist/types/index.d.ts.map +1 -0
  289. package/dist/types/install-env.d.ts +3 -0
  290. package/dist/types/install-env.d.ts.map +1 -0
  291. package/dist/types/naylence/fame/factory-manifest.d.ts +11 -0
  292. package/dist/types/naylence/fame/factory-manifest.d.ts.map +1 -0
  293. package/dist/types/naylence/fame/security/cert/browser-csr.d.ts +9 -0
  294. package/dist/types/naylence/fame/security/cert/browser-csr.d.ts.map +1 -0
  295. package/dist/types/naylence/fame/security/cert/ca-server-cli.d.ts +3 -0
  296. package/dist/types/naylence/fame/security/cert/ca-server-cli.d.ts.map +1 -0
  297. package/dist/types/naylence/fame/security/cert/ca-server.d.ts +19 -0
  298. package/dist/types/naylence/fame/security/cert/ca-server.d.ts.map +1 -0
  299. package/dist/types/naylence/fame/security/cert/ca-service-client.d.ts +75 -0
  300. package/dist/types/naylence/fame/security/cert/ca-service-client.d.ts.map +1 -0
  301. package/dist/types/naylence/fame/security/cert/ca-service-factory.d.ts +43 -0
  302. package/dist/types/naylence/fame/security/cert/ca-service-factory.d.ts.map +1 -0
  303. package/dist/types/naylence/fame/security/cert/ca-types.d.ts +129 -0
  304. package/dist/types/naylence/fame/security/cert/ca-types.d.ts.map +1 -0
  305. package/dist/types/naylence/fame/security/cert/csr-types.d.ts +5 -0
  306. package/dist/types/naylence/fame/security/cert/csr-types.d.ts.map +1 -0
  307. package/dist/types/naylence/fame/security/cert/default-ca-service-factory.d.ts +55 -0
  308. package/dist/types/naylence/fame/security/cert/default-ca-service-factory.d.ts.map +1 -0
  309. package/dist/types/naylence/fame/security/cert/default-ca-service.d.ts +85 -0
  310. package/dist/types/naylence/fame/security/cert/default-ca-service.d.ts.map +1 -0
  311. package/dist/types/naylence/fame/security/cert/default-certificate-manager-factory.d.ts +25 -0
  312. package/dist/types/naylence/fame/security/cert/default-certificate-manager-factory.d.ts.map +1 -0
  313. package/dist/types/naylence/fame/security/cert/default-certificate-manager.d.ts +70 -0
  314. package/dist/types/naylence/fame/security/cert/default-certificate-manager.d.ts.map +1 -0
  315. package/dist/types/naylence/fame/security/cert/grants.d.ts +2 -0
  316. package/dist/types/naylence/fame/security/cert/grants.d.ts.map +1 -0
  317. package/dist/types/naylence/fame/security/cert/index.d.ts +19 -0
  318. package/dist/types/naylence/fame/security/cert/index.d.ts.map +1 -0
  319. package/dist/types/naylence/fame/security/cert/internal-ca-service.d.ts +129 -0
  320. package/dist/types/naylence/fame/security/cert/internal-ca-service.d.ts.map +1 -0
  321. package/dist/types/naylence/fame/security/cert/node-ed25519-csr.d.ts +9 -0
  322. package/dist/types/naylence/fame/security/cert/node-ed25519-csr.d.ts.map +1 -0
  323. package/dist/types/naylence/fame/security/cert/oid-constants.d.ts +7 -0
  324. package/dist/types/naylence/fame/security/cert/oid-constants.d.ts.map +1 -0
  325. package/dist/types/naylence/fame/security/cert/trust-store/anchor-utils.d.ts +12 -0
  326. package/dist/types/naylence/fame/security/cert/trust-store/anchor-utils.d.ts.map +1 -0
  327. package/dist/types/naylence/fame/security/cert/trust-store/browser-trust-store-provider-factory.d.ts +29 -0
  328. package/dist/types/naylence/fame/security/cert/trust-store/browser-trust-store-provider-factory.d.ts.map +1 -0
  329. package/dist/types/naylence/fame/security/cert/trust-store/env-provider.d.ts +7 -0
  330. package/dist/types/naylence/fame/security/cert/trust-store/env-provider.d.ts.map +1 -0
  331. package/dist/types/naylence/fame/security/cert/trust-store/fame-ca-certs-parser.d.ts +9 -0
  332. package/dist/types/naylence/fame/security/cert/trust-store/fame-ca-certs-parser.d.ts.map +1 -0
  333. package/dist/types/naylence/fame/security/cert/trust-store/http-bundle-provider.d.ts +35 -0
  334. package/dist/types/naylence/fame/security/cert/trust-store/http-bundle-provider.d.ts.map +1 -0
  335. package/dist/types/naylence/fame/security/cert/trust-store/http-signed-bundle-provider.d.ts +2 -0
  336. package/dist/types/naylence/fame/security/cert/trust-store/http-signed-bundle-provider.d.ts.map +1 -0
  337. package/dist/types/naylence/fame/security/cert/trust-store/node-trust-store-provider-factory.d.ts +23 -0
  338. package/dist/types/naylence/fame/security/cert/trust-store/node-trust-store-provider-factory.d.ts.map +1 -0
  339. package/dist/types/naylence/fame/security/cert/trust-store/static-bundle-provider.d.ts +15 -0
  340. package/dist/types/naylence/fame/security/cert/trust-store/static-bundle-provider.d.ts.map +1 -0
  341. package/dist/types/naylence/fame/security/cert/trust-store/trust-store-provider-factory.d.ts +28 -0
  342. package/dist/types/naylence/fame/security/cert/trust-store/trust-store-provider-factory.d.ts.map +1 -0
  343. package/dist/types/naylence/fame/security/cert/trust-store/trust-store-provider.d.ts +43 -0
  344. package/dist/types/naylence/fame/security/cert/trust-store/trust-store-provider.d.ts.map +1 -0
  345. package/dist/types/naylence/fame/security/cert/util.d.ts +25 -0
  346. package/dist/types/naylence/fame/security/cert/util.d.ts.map +1 -0
  347. package/dist/types/naylence/fame/security/encryption/channel/channel-encryption-manager-factory.d.ts +29 -0
  348. package/dist/types/naylence/fame/security/encryption/channel/channel-encryption-manager-factory.d.ts.map +1 -0
  349. package/dist/types/naylence/fame/security/encryption/channel/channel-encryption-manager.d.ts +51 -0
  350. package/dist/types/naylence/fame/security/encryption/channel/channel-encryption-manager.d.ts.map +1 -0
  351. package/dist/types/naylence/fame/security/encryption/channel/index.d.ts +3 -0
  352. package/dist/types/naylence/fame/security/encryption/channel/index.d.ts.map +1 -0
  353. package/dist/types/naylence/fame/security/encryption/composite-encryption-manager-factory.d.ts +32 -0
  354. package/dist/types/naylence/fame/security/encryption/composite-encryption-manager-factory.d.ts.map +1 -0
  355. package/dist/types/naylence/fame/security/encryption/composite-encryption-manager.d.ts +52 -0
  356. package/dist/types/naylence/fame/security/encryption/composite-encryption-manager.d.ts.map +1 -0
  357. package/dist/types/naylence/fame/security/encryption/default-secure-channel-manager-factory.d.ts +23 -0
  358. package/dist/types/naylence/fame/security/encryption/default-secure-channel-manager-factory.d.ts.map +1 -0
  359. package/dist/types/naylence/fame/security/encryption/default-secure-channel-manager.d.ts +37 -0
  360. package/dist/types/naylence/fame/security/encryption/default-secure-channel-manager.d.ts.map +1 -0
  361. package/dist/types/naylence/fame/security/encryption/encryption-manager-registry.d.ts +34 -0
  362. package/dist/types/naylence/fame/security/encryption/encryption-manager-registry.d.ts.map +1 -0
  363. package/dist/types/naylence/fame/security/encryption/index.d.ts +7 -0
  364. package/dist/types/naylence/fame/security/encryption/index.d.ts.map +1 -0
  365. package/dist/types/naylence/fame/security/encryption/sealed/index.d.ts +3 -0
  366. package/dist/types/naylence/fame/security/encryption/sealed/index.d.ts.map +1 -0
  367. package/dist/types/naylence/fame/security/encryption/sealed/x25519-encryption-manager-factory.d.ts +28 -0
  368. package/dist/types/naylence/fame/security/encryption/sealed/x25519-encryption-manager-factory.d.ts.map +1 -0
  369. package/dist/types/naylence/fame/security/encryption/sealed/x25519-encryption-manager.d.ts +43 -0
  370. package/dist/types/naylence/fame/security/encryption/sealed/x25519-encryption-manager.d.ts.map +1 -0
  371. package/dist/types/naylence/fame/security/index.d.ts +6 -0
  372. package/dist/types/naylence/fame/security/index.d.ts.map +1 -0
  373. package/dist/types/naylence/fame/security/keys/index.d.ts +3 -0
  374. package/dist/types/naylence/fame/security/keys/index.d.ts.map +1 -0
  375. package/dist/types/naylence/fame/security/keys/x5c-key-manager-factory.d.ts +19 -0
  376. package/dist/types/naylence/fame/security/keys/x5c-key-manager-factory.d.ts.map +1 -0
  377. package/dist/types/naylence/fame/security/keys/x5c-key-manager.d.ts +39 -0
  378. package/dist/types/naylence/fame/security/keys/x5c-key-manager.d.ts.map +1 -0
  379. package/dist/types/naylence/fame/security/register-advanced-security-factories.d.ts +8 -0
  380. package/dist/types/naylence/fame/security/register-advanced-security-factories.d.ts.map +1 -0
  381. package/dist/types/naylence/fame/security/signing/eddsa-envelope-signer-factory.d.ts +20 -0
  382. package/dist/types/naylence/fame/security/signing/eddsa-envelope-signer-factory.d.ts.map +1 -0
  383. package/dist/types/naylence/fame/security/signing/eddsa-envelope-verifier-factory.d.ts +21 -0
  384. package/dist/types/naylence/fame/security/signing/eddsa-envelope-verifier-factory.d.ts.map +1 -0
  385. package/dist/types/naylence/fame/security/signing/eddsa-envelope-verifier.d.ts +22 -0
  386. package/dist/types/naylence/fame/security/signing/eddsa-envelope-verifier.d.ts.map +1 -0
  387. package/dist/types/naylence/fame/stickiness/aft-helper.d.ts +29 -0
  388. package/dist/types/naylence/fame/stickiness/aft-helper.d.ts.map +1 -0
  389. package/dist/types/naylence/fame/stickiness/aft-load-balancer-stickiness-manager-factory.d.ts +25 -0
  390. package/dist/types/naylence/fame/stickiness/aft-load-balancer-stickiness-manager-factory.d.ts.map +1 -0
  391. package/dist/types/naylence/fame/stickiness/aft-load-balancer-stickiness-manager.d.ts +33 -0
  392. package/dist/types/naylence/fame/stickiness/aft-load-balancer-stickiness-manager.d.ts.map +1 -0
  393. package/dist/types/naylence/fame/stickiness/aft-model.d.ts +33 -0
  394. package/dist/types/naylence/fame/stickiness/aft-model.d.ts.map +1 -0
  395. package/dist/types/naylence/fame/stickiness/aft-replica-stickiness-manager-factory.d.ts +23 -0
  396. package/dist/types/naylence/fame/stickiness/aft-replica-stickiness-manager-factory.d.ts.map +1 -0
  397. package/dist/types/naylence/fame/stickiness/aft-replica-stickiness-manager.d.ts +31 -0
  398. package/dist/types/naylence/fame/stickiness/aft-replica-stickiness-manager.d.ts.map +1 -0
  399. package/dist/types/naylence/fame/stickiness/aft-signer.d.ts +55 -0
  400. package/dist/types/naylence/fame/stickiness/aft-signer.d.ts.map +1 -0
  401. package/dist/types/naylence/fame/stickiness/aft-utils.d.ts +4 -0
  402. package/dist/types/naylence/fame/stickiness/aft-utils.d.ts.map +1 -0
  403. package/dist/types/naylence/fame/stickiness/aft-verifier.d.ts +50 -0
  404. package/dist/types/naylence/fame/stickiness/aft-verifier.d.ts.map +1 -0
  405. package/dist/types/naylence/fame/stickiness/index.d.ts +15 -0
  406. package/dist/types/naylence/fame/stickiness/index.d.ts.map +1 -0
  407. package/dist/types/naylence/fame/stickiness/stickiness-mode.d.ts +7 -0
  408. package/dist/types/naylence/fame/stickiness/stickiness-mode.d.ts.map +1 -0
  409. package/dist/types/naylence/fame/welcome/advanced-welcome-service-factory.d.ts +21 -0
  410. package/dist/types/naylence/fame/welcome/advanced-welcome-service-factory.d.ts.map +1 -0
  411. package/dist/types/naylence/fame/welcome/advanced-welcome-service.d.ts +21 -0
  412. package/dist/types/naylence/fame/welcome/advanced-welcome-service.d.ts.map +1 -0
  413. package/dist/types/naylence/fame/welcome/index.d.ts +3 -0
  414. package/dist/types/naylence/fame/welcome/index.d.ts.map +1 -0
  415. package/dist/types/node.d.ts +11 -0
  416. package/dist/types/node.d.ts.map +1 -0
  417. package/dist/types/plugin.d.ts +11 -0
  418. package/dist/types/plugin.d.ts.map +1 -0
  419. package/dist/types/version.d.ts +6 -0
  420. package/dist/types/version.d.ts.map +1 -0
  421. package/package.json +1 -1
@@ -0,0 +1,743 @@
1
+ import { chacha20poly1305 } from "@noble/ciphers/chacha.js";
2
+ import { FameAddress, formatAddress, localDeliveryContext, } from "@naylence/core";
3
+ import { EncryptionResult, } from "@naylence/runtime";
4
+ import { requireCryptoSupport } from "@naylence/runtime";
5
+ import { getLogger } from "@naylence/runtime";
6
+ import { generateId } from "@naylence/core";
7
+ import { urlsafeBase64Decode } from "@naylence/runtime";
8
+ const logger = getLogger("naylence.fame.security.encryption.channel.channel_encryption_manager");
9
+ const SUPPORTED_CHANNEL_ALGORITHMS = ["chacha20-poly1305-channel"];
10
+ const CHANNEL_ENCRYPTION_ALGORITHM = "chacha20-poly1305-channel";
11
+ const HANDSHAKE_ALGORITHM = "CHACHA20P1305";
12
+ const SYSTEM_INBOX = "__sys__";
13
+ const NONCE_LENGTH = 12;
14
+ function isTaskSpawnerLike(value) {
15
+ return Boolean(value && typeof value.spawn === "function");
16
+ }
17
+ function toUint8Array(value) {
18
+ if (value instanceof Uint8Array) {
19
+ return value;
20
+ }
21
+ if (typeof ArrayBuffer !== "undefined") {
22
+ if (value instanceof ArrayBuffer) {
23
+ return new Uint8Array(value);
24
+ }
25
+ if (ArrayBuffer.isView(value)) {
26
+ const view = value;
27
+ return new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
28
+ }
29
+ }
30
+ if (Array.isArray(value)) {
31
+ return Uint8Array.from(value);
32
+ }
33
+ return null;
34
+ }
35
+ function encodeBase64(data) {
36
+ if (typeof Buffer !== "undefined") {
37
+ return Buffer.from(data).toString("base64");
38
+ }
39
+ let binary = "";
40
+ for (const byte of data) {
41
+ binary += String.fromCharCode(byte);
42
+ }
43
+ if (typeof btoa === "function") {
44
+ return btoa(binary);
45
+ }
46
+ throw new Error("Base64 encoding not supported in this environment");
47
+ }
48
+ function decodeBase64(encoded) {
49
+ if (typeof Buffer !== "undefined") {
50
+ return Uint8Array.from(Buffer.from(encoded, "base64"));
51
+ }
52
+ if (typeof atob === "function") {
53
+ const binary = atob(encoded);
54
+ const bytes = new Uint8Array(binary.length);
55
+ for (let i = 0; i < binary.length; i += 1) {
56
+ bytes[i] = binary.charCodeAt(i);
57
+ }
58
+ return bytes;
59
+ }
60
+ throw new Error("Base64 decoding not supported in this environment");
61
+ }
62
+ let cachedCrypto;
63
+ function resolveCrypto() {
64
+ if (cachedCrypto !== undefined) {
65
+ return cachedCrypto;
66
+ }
67
+ cachedCrypto = null;
68
+ if (typeof globalThis !== "undefined") {
69
+ const scoped = globalThis;
70
+ const nativeCrypto = scoped.crypto;
71
+ if (nativeCrypto && typeof nativeCrypto.getRandomValues === "function") {
72
+ cachedCrypto = nativeCrypto;
73
+ return cachedCrypto;
74
+ }
75
+ const webcrypto = scoped.webcrypto;
76
+ if (webcrypto && typeof webcrypto.getRandomValues === "function") {
77
+ cachedCrypto = webcrypto;
78
+ return cachedCrypto;
79
+ }
80
+ }
81
+ return cachedCrypto;
82
+ }
83
+ function randomBytes(length) {
84
+ const cryptoApi = resolveCrypto();
85
+ if (!cryptoApi) {
86
+ throw new Error("Secure random source is not available in this environment");
87
+ }
88
+ const buffer = new Uint8Array(length);
89
+ cryptoApi.getRandomValues(buffer);
90
+ return buffer;
91
+ }
92
+ function toFameAddress(value) {
93
+ if (!value) {
94
+ return null;
95
+ }
96
+ if (value instanceof FameAddress) {
97
+ return value;
98
+ }
99
+ return new FameAddress(String(value));
100
+ }
101
+ function toDestinationString(value) {
102
+ if (!value) {
103
+ return null;
104
+ }
105
+ if (value instanceof FameAddress) {
106
+ return value.toString();
107
+ }
108
+ if (typeof value === "string") {
109
+ return value;
110
+ }
111
+ return null;
112
+ }
113
+ function makeJsonSerializable(value) {
114
+ if (value === null || value === undefined) {
115
+ return null;
116
+ }
117
+ if (Array.isArray(value)) {
118
+ return value.map((item) => makeJsonSerializable(item));
119
+ }
120
+ if (value instanceof Uint8Array) {
121
+ return Array.from(value);
122
+ }
123
+ if (typeof value === "object") {
124
+ const candidate = value;
125
+ if (typeof candidate.toJSON === "function") {
126
+ return candidate.toJSON();
127
+ }
128
+ if (typeof candidate.model_dump === "function") {
129
+ return candidate.model_dump();
130
+ }
131
+ if (typeof candidate.dict === "function") {
132
+ return candidate.dict();
133
+ }
134
+ return { ...candidate };
135
+ }
136
+ return value;
137
+ }
138
+ export class ChannelEncryptionManager {
139
+ constructor({ secureChannelManager = null, nodeLike = null, taskSpawner = null, } = {}) {
140
+ this.pendingEnvelopes = new Map();
141
+ this.handshakeInProgress = new Set();
142
+ this.addrChannelMap = new Map();
143
+ this.secureChannelManager = secureChannelManager ?? null;
144
+ this.nodeLike = nodeLike ?? null;
145
+ this.taskSpawner =
146
+ taskSpawner ?? (isTaskSpawnerLike(nodeLike) ? nodeLike : taskSpawner);
147
+ }
148
+ async encryptEnvelope(envelope, opts = null) {
149
+ const frame = envelope.frame;
150
+ if (!this.isDataFrame(frame)) {
151
+ return EncryptionResult.skipped(envelope);
152
+ }
153
+ if (frame.payload === null || typeof frame.payload === "undefined") {
154
+ return EncryptionResult.skipped(envelope);
155
+ }
156
+ const destination = opts?.destination ?? envelope.to ?? null;
157
+ const destinationStr = toDestinationString(destination);
158
+ if (!destinationStr) {
159
+ logger.warning("no_destination_for_channel_encryption", {
160
+ envelope_id: envelope.id,
161
+ });
162
+ return EncryptionResult.skipped(envelope);
163
+ }
164
+ if (!this.secureChannelManager) {
165
+ logger.warning("no_secure_channel_manager_available", {
166
+ envelope_id: envelope.id,
167
+ });
168
+ return EncryptionResult.skipped(envelope);
169
+ }
170
+ const existingChannelId = this.findExistingChannel(destinationStr);
171
+ if (existingChannelId) {
172
+ try {
173
+ return this.encryptWithChannel(envelope, existingChannelId);
174
+ }
175
+ catch (error) {
176
+ logger.error("channel_encryption_failed", {
177
+ error: error instanceof Error ? error.message : String(error),
178
+ channel_id: existingChannelId,
179
+ });
180
+ return EncryptionResult.skipped(envelope);
181
+ }
182
+ }
183
+ await this.queueAndInitiateHandshake(envelope, destination, destinationStr, opts ?? null);
184
+ return EncryptionResult.queued();
185
+ }
186
+ async decryptEnvelope(envelope, opts = null) {
187
+ void opts;
188
+ requireCryptoSupport();
189
+ const frame = envelope.frame;
190
+ if (!this.isDataFrame(frame) ||
191
+ frame.payload === null ||
192
+ typeof frame.payload === "undefined") {
193
+ return envelope;
194
+ }
195
+ if (!envelope.sec || !envelope.sec.enc) {
196
+ return envelope;
197
+ }
198
+ const encHeader = envelope.sec.enc;
199
+ if (!encHeader.alg || !this.isChannelAlgorithm(encHeader.alg)) {
200
+ return envelope;
201
+ }
202
+ const channelId = encHeader.kid;
203
+ if (!channelId) {
204
+ logger.error("missing_channel_id_in_encryption_header", {
205
+ envelope_id: envelope.id,
206
+ });
207
+ return envelope;
208
+ }
209
+ const nonce = this.decodeNonceValue(encHeader.val ?? "");
210
+ if (!nonce) {
211
+ logger.error("invalid_nonce_in_encryption_header", {
212
+ envelope_id: envelope.id,
213
+ value_present: Boolean(encHeader.val),
214
+ });
215
+ return envelope;
216
+ }
217
+ if (!this.secureChannelManager) {
218
+ logger.warning("no_secure_channel_manager_for_decryption", {
219
+ envelope_id: envelope.id,
220
+ });
221
+ return envelope;
222
+ }
223
+ const channelState = this.getChannelState(channelId);
224
+ if (!channelState) {
225
+ logger.error("channel_not_available_for_decryption", {
226
+ channel_id: channelId,
227
+ });
228
+ return envelope;
229
+ }
230
+ const ciphertext = this.extractCiphertext(frame.payload);
231
+ if (!ciphertext) {
232
+ logger.error("invalid_ciphertext_payload", { envelope_id: envelope.id });
233
+ return envelope;
234
+ }
235
+ try {
236
+ const aad = new TextEncoder().encode(channelId);
237
+ const aead = chacha20poly1305(channelState.key, nonce, aad);
238
+ const plaintextBytes = aead.decrypt(ciphertext);
239
+ const decodedPayload = this.deserializePayload(plaintextBytes);
240
+ frame.payload = decodedPayload;
241
+ frame.codec = "json";
242
+ if (envelope.sec) {
243
+ delete envelope.sec.enc;
244
+ if (!envelope.sec.sig) {
245
+ envelope.sec = undefined;
246
+ }
247
+ }
248
+ if (envelope.replyTo) {
249
+ this.addrChannelMap.set(String(envelope.replyTo), channelId);
250
+ }
251
+ if (envelope.sid) {
252
+ this.addrChannelMap.set(envelope.sid, channelId);
253
+ }
254
+ return envelope;
255
+ }
256
+ catch (error) {
257
+ logger.error("channel_decryption_failed", {
258
+ channel_id: channelId,
259
+ error: error instanceof Error ? error.message : String(error),
260
+ });
261
+ return envelope;
262
+ }
263
+ }
264
+ async notifyChannelEstablished(channelId) {
265
+ logger.debug("channel_encryption_manager_notified", {
266
+ channel_id: channelId,
267
+ manager_type: "channel",
268
+ });
269
+ if (!channelId.startsWith("auto-")) {
270
+ logger.warning("unexpected_channel_id_format", { channel_id: channelId });
271
+ return;
272
+ }
273
+ const destinationStr = this.extractDestinationFromChannelId(channelId);
274
+ if (!destinationStr) {
275
+ logger.warning("cannot_parse_destination_from_channel_id", {
276
+ channel_id: channelId,
277
+ });
278
+ return;
279
+ }
280
+ this.handshakeInProgress.delete(destinationStr);
281
+ if (!this.pendingEnvelopes.has(destinationStr)) {
282
+ logger.debug("no_pending_queue_for_destination", {
283
+ destination: destinationStr,
284
+ });
285
+ return;
286
+ }
287
+ const queuedEnvelopes = this.pendingEnvelopes.get(destinationStr) ?? [];
288
+ this.pendingEnvelopes.delete(destinationStr);
289
+ if (!this.secureChannelManager) {
290
+ logger.error("no_secure_channel_manager_for_queue_drain", {
291
+ channel_id: channelId,
292
+ });
293
+ return;
294
+ }
295
+ for (const envelope of queuedEnvelopes) {
296
+ try {
297
+ const result = this.encryptWithChannel(envelope, channelId);
298
+ if (!result.envelope) {
299
+ logger.warning("failed_to_encrypt_queued_envelope", {
300
+ envelope_id: envelope.id,
301
+ channel_id: channelId,
302
+ });
303
+ continue;
304
+ }
305
+ const encryptedEnvelope = result.envelope;
306
+ this.runAsyncTask(() => this.deliverEnvelope(encryptedEnvelope), `deliver-queued-${envelope.id}`);
307
+ }
308
+ catch (error) {
309
+ logger.error("failed_to_encrypt_queued_envelope", {
310
+ envelope_id: envelope.id,
311
+ error: error instanceof Error ? error.message : String(error),
312
+ });
313
+ }
314
+ }
315
+ }
316
+ async notifyChannelFailed(channelId, reason = "handshake_failed") {
317
+ logger.debug("channel_encryption_manager_notified_failure", {
318
+ channel_id: channelId,
319
+ reason,
320
+ });
321
+ if (!channelId.startsWith("auto-")) {
322
+ logger.warning("unexpected_channel_id_format_on_failure", {
323
+ channel_id: channelId,
324
+ });
325
+ return;
326
+ }
327
+ const destinationStr = this.extractDestinationFromChannelId(channelId);
328
+ if (!destinationStr) {
329
+ logger.warning("cannot_parse_destination_from_channel_id_on_failure", {
330
+ channel_id: channelId,
331
+ });
332
+ return;
333
+ }
334
+ this.handshakeInProgress.delete(destinationStr);
335
+ // Clear any cached channel mapping for this destination since the channel failed
336
+ const cachedChannelId = this.addrChannelMap.get(destinationStr);
337
+ if (cachedChannelId === channelId) {
338
+ this.addrChannelMap.delete(destinationStr);
339
+ logger.debug("cleared_channel_cache_for_failed_channel", {
340
+ destination: destinationStr,
341
+ channel_id: channelId,
342
+ });
343
+ }
344
+ const queuedEnvelopes = this.pendingEnvelopes.get(destinationStr);
345
+ if (!queuedEnvelopes || queuedEnvelopes.length === 0) {
346
+ logger.debug("no_pending_queue_for_failed_destination", {
347
+ destination: destinationStr,
348
+ });
349
+ return;
350
+ }
351
+ this.pendingEnvelopes.delete(destinationStr);
352
+ for (const envelope of queuedEnvelopes) {
353
+ await this.handleFailedEnvelope(envelope, destinationStr, channelId, reason);
354
+ }
355
+ }
356
+ /**
357
+ * Clear cached channel mappings for a destination.
358
+ * This should be called when routes are removed or channels are closed
359
+ * to prevent using stale channel references.
360
+ */
361
+ clearChannelCacheForDestination(destination) {
362
+ const cached = this.addrChannelMap.get(destination);
363
+ if (cached) {
364
+ this.addrChannelMap.delete(destination);
365
+ logger.debug("cleared_channel_cache_for_destination", {
366
+ destination,
367
+ cached_channel_id: cached,
368
+ });
369
+ }
370
+ }
371
+ isChannelAlgorithm(algorithm) {
372
+ return SUPPORTED_CHANNEL_ALGORITHMS.includes(algorithm);
373
+ }
374
+ isDataFrame(frame) {
375
+ return Boolean(frame && frame.type === "Data");
376
+ }
377
+ findExistingChannel(destination) {
378
+ if (!this.secureChannelManager) {
379
+ return null;
380
+ }
381
+ const cached = this.addrChannelMap.get(destination);
382
+ if (cached && this.getChannelState(cached)) {
383
+ logger.debug("using_cached_channel", { destination, channel_id: cached });
384
+ return cached;
385
+ }
386
+ const channels = this.secureChannelManager.channels;
387
+ for (const channelId of Object.keys(channels)) {
388
+ if (channelId.startsWith(`auto-${destination}-`)) {
389
+ this.addrChannelMap.set(destination, channelId);
390
+ logger.debug("using_existing_channel", {
391
+ destination,
392
+ channel_id: channelId,
393
+ });
394
+ return channelId;
395
+ }
396
+ }
397
+ return null;
398
+ }
399
+ async queueAndInitiateHandshake(envelope, destination, destinationStr, opts) {
400
+ const queue = this.pendingEnvelopes.get(destinationStr) ?? [];
401
+ queue.push(envelope);
402
+ this.pendingEnvelopes.set(destinationStr, queue);
403
+ logger.debug("queued_envelope_for_channel_handshake", {
404
+ envelope_id: envelope.id,
405
+ destination: destinationStr,
406
+ });
407
+ if (this.handshakeInProgress.has(destinationStr)) {
408
+ logger.debug("handshake_already_in_progress", {
409
+ destination: destinationStr,
410
+ });
411
+ return;
412
+ }
413
+ this.handshakeInProgress.add(destinationStr);
414
+ const taskName = `handshake-${destinationStr}`;
415
+ this.runAsyncTask(async () => {
416
+ try {
417
+ await this.initiateChannelHandshakeAsync(destination ?? destinationStr, destinationStr, opts);
418
+ }
419
+ finally {
420
+ this.handshakeInProgress.delete(destinationStr);
421
+ }
422
+ }, taskName);
423
+ }
424
+ async initiateChannelHandshakeAsync(destination, destinationStr, opts) {
425
+ void opts;
426
+ if (!this.secureChannelManager) {
427
+ logger.error("no_secure_channel_manager_for_async_handshake_initiation");
428
+ return;
429
+ }
430
+ const channelId = this.generateChannelId(destinationStr);
431
+ try {
432
+ const openFrame = this.secureChannelManager.generateOpenFrame(channelId, HANDSHAKE_ALGORITHM);
433
+ const success = await this.sendSecureOpenFrameAsync(openFrame, destination);
434
+ if (success) {
435
+ logger.debug("sent_secure_open_frame_async", {
436
+ channel_id: channelId,
437
+ destination: destinationStr,
438
+ });
439
+ }
440
+ else {
441
+ logger.warning("failed_to_send_secure_open_frame_async", {
442
+ channel_id: channelId,
443
+ });
444
+ }
445
+ }
446
+ catch (error) {
447
+ logger.error("async_channel_handshake_initiation_failed", {
448
+ destination: destinationStr,
449
+ error: error instanceof Error ? error.message : String(error),
450
+ });
451
+ }
452
+ }
453
+ async sendSecureOpenFrameAsync(openFrame, destination) {
454
+ const node = this.nodeLike;
455
+ if (!node) {
456
+ logger.error("no_node_available_for_sending_secure_open_async");
457
+ return false;
458
+ }
459
+ const envelopeFactory = node.envelopeFactory;
460
+ if (!envelopeFactory) {
461
+ logger.error("no_envelope_factory_available_for_secure_open_async");
462
+ return false;
463
+ }
464
+ const replyTo = this.buildSystemReplyTo();
465
+ if (!replyTo) {
466
+ logger.error("no_physical_path_available_for_reply_to_async");
467
+ return false;
468
+ }
469
+ const toAddress = toFameAddress(destination);
470
+ if (!toAddress) {
471
+ logger.error("invalid_destination_for_secure_open", {
472
+ destination: String(destination),
473
+ });
474
+ return false;
475
+ }
476
+ const envelope = envelopeFactory.createEnvelope({
477
+ to: toAddress,
478
+ frame: openFrame,
479
+ replyTo,
480
+ corrId: generateId(),
481
+ });
482
+ await this.deliverEnvelope(envelope);
483
+ logger.debug("delivered_secure_open_frame_async", {
484
+ channel_id: openFrame.cid,
485
+ });
486
+ return true;
487
+ }
488
+ async deliverEnvelope(envelope) {
489
+ const node = this.nodeLike;
490
+ if (!node) {
491
+ logger.error("no_node_available_for_delivery", {
492
+ envelope_id: envelope.id,
493
+ });
494
+ return;
495
+ }
496
+ const context = localDeliveryContext(node.sid ?? undefined);
497
+ await node.deliver(envelope, context);
498
+ }
499
+ encryptWithChannel(envelope, channelId) {
500
+ if (!this.secureChannelManager) {
501
+ logger.error("no_secure_channel_manager_for_encryption");
502
+ return EncryptionResult.skipped(envelope);
503
+ }
504
+ const frame = envelope.frame;
505
+ if (!this.isDataFrame(frame)) {
506
+ logger.error("attempted_to_encrypt_non_dataframe", {
507
+ frame_type: frame.type ?? typeof frame,
508
+ });
509
+ return EncryptionResult.skipped(envelope);
510
+ }
511
+ const channelState = this.getChannelState(channelId);
512
+ if (!channelState) {
513
+ logger.error("channel_not_in_channels", { channel_id: channelId });
514
+ return EncryptionResult.skipped(envelope);
515
+ }
516
+ const payloadBytes = this.serializePayload(frame.payload);
517
+ if (!payloadBytes) {
518
+ return EncryptionResult.skipped(envelope);
519
+ }
520
+ const nonce = randomBytes(NONCE_LENGTH);
521
+ const aad = new TextEncoder().encode(channelId);
522
+ const aead = chacha20poly1305(channelState.key, nonce, aad);
523
+ const ciphertext = aead.encrypt(payloadBytes);
524
+ const encryptionHeader = {
525
+ alg: CHANNEL_ENCRYPTION_ALGORITHM,
526
+ val: Array.from(nonce)
527
+ .map((byte) => byte.toString(16).padStart(2, "0"))
528
+ .join(""), // Hex encoding (Python reference)
529
+ kid: channelId,
530
+ };
531
+ const encodedCiphertext = encodeBase64(ciphertext);
532
+ frame.payload = encodedCiphertext;
533
+ frame.codec = "b64";
534
+ if (envelope.sec) {
535
+ envelope.sec.enc = encryptionHeader;
536
+ }
537
+ else {
538
+ envelope.sec = { enc: encryptionHeader };
539
+ }
540
+ return EncryptionResult.ok(envelope);
541
+ }
542
+ serializePayload(payload) {
543
+ if (payload === null || typeof payload === "undefined") {
544
+ return null;
545
+ }
546
+ if (payload instanceof Uint8Array) {
547
+ return payload;
548
+ }
549
+ if (typeof ArrayBuffer !== "undefined") {
550
+ if (payload instanceof ArrayBuffer || ArrayBuffer.isView(payload)) {
551
+ return toUint8Array(payload);
552
+ }
553
+ }
554
+ if (typeof payload === "string") {
555
+ return new TextEncoder().encode(payload);
556
+ }
557
+ if (typeof payload === "number" || typeof payload === "boolean") {
558
+ return new TextEncoder().encode(JSON.stringify(payload));
559
+ }
560
+ const serializable = makeJsonSerializable(payload);
561
+ return new TextEncoder().encode(JSON.stringify(serializable));
562
+ }
563
+ extractCiphertext(payload) {
564
+ if (payload instanceof Uint8Array) {
565
+ return payload;
566
+ }
567
+ if (typeof payload === "string") {
568
+ try {
569
+ return decodeBase64(payload);
570
+ }
571
+ catch (error) {
572
+ logger.error("failed_to_decode_base64_ciphertext", {
573
+ error: error instanceof Error ? error.message : String(error),
574
+ });
575
+ return null;
576
+ }
577
+ }
578
+ if (payload instanceof ArrayBuffer ||
579
+ ArrayBuffer.isView(payload)) {
580
+ return toUint8Array(payload);
581
+ }
582
+ return null;
583
+ }
584
+ deserializePayload(bytes) {
585
+ const decoder = new TextDecoder();
586
+ const decoded = decoder.decode(bytes);
587
+ try {
588
+ return JSON.parse(decoded);
589
+ }
590
+ catch {
591
+ return decoded;
592
+ }
593
+ }
594
+ extractDestinationFromChannelId(channelId) {
595
+ const parts = channelId.split("-");
596
+ if (parts.length < 3) {
597
+ return null;
598
+ }
599
+ return parts.slice(1, -1).join("-");
600
+ }
601
+ async handleFailedEnvelope(envelope, destinationStr, channelId, reason) {
602
+ logger.warning("envelope_failed_due_to_channel_handshake_failure", {
603
+ envelope_id: envelope.id,
604
+ destination: destinationStr,
605
+ channel_id: channelId,
606
+ reason,
607
+ });
608
+ const frame = envelope.frame;
609
+ if (!this.isDataFrame(frame)) {
610
+ logger.debug("skipping_nack_for_non_dataframe", {
611
+ envelope_id: envelope.id,
612
+ frame_type: frame.type ?? typeof frame,
613
+ });
614
+ return;
615
+ }
616
+ if (!envelope.replyTo) {
617
+ logger.debug("skipping_nack_no_reply_to", { envelope_id: envelope.id });
618
+ return;
619
+ }
620
+ await this.sendDeliveryNack(envelope, `channel_handshake_failed: ${reason}`);
621
+ }
622
+ async sendDeliveryNack(envelope, failureReason) {
623
+ const node = this.nodeLike;
624
+ if (!node) {
625
+ logger.error("no_node_available_for_sending_delivery_nack");
626
+ return;
627
+ }
628
+ const envelopeFactory = node.envelopeFactory;
629
+ if (!envelopeFactory) {
630
+ logger.error("no_envelope_factory_available_for_delivery_nack");
631
+ return;
632
+ }
633
+ const replyTo = toFameAddress(envelope.replyTo ?? null);
634
+ if (!replyTo) {
635
+ logger.error("invalid_reply_to_for_delivery_nack", {
636
+ reply_to: envelope.replyTo,
637
+ });
638
+ return;
639
+ }
640
+ const nackFrame = {
641
+ type: "DeliveryAck",
642
+ ok: false,
643
+ code: "channel_handshake_failed",
644
+ reason: failureReason,
645
+ };
646
+ const nackEnvelope = envelopeFactory.createEnvelope({
647
+ to: replyTo,
648
+ frame: nackFrame,
649
+ corrId: envelope.corrId ?? generateId(),
650
+ });
651
+ await this.deliverEnvelope(nackEnvelope);
652
+ logger.debug("delivered_delivery_nack", {
653
+ original_envelope_id: envelope.id,
654
+ nack_envelope_id: nackEnvelope.id,
655
+ });
656
+ }
657
+ getChannelState(channelId) {
658
+ if (!this.secureChannelManager) {
659
+ return null;
660
+ }
661
+ const channelState = this.secureChannelManager.channels[channelId];
662
+ return channelState ?? null;
663
+ }
664
+ buildSystemReplyTo() {
665
+ const node = this.nodeLike;
666
+ if (!node) {
667
+ return null;
668
+ }
669
+ const physicalPath = node.physicalPath ?? "";
670
+ if (!physicalPath) {
671
+ return null;
672
+ }
673
+ return formatAddress(SYSTEM_INBOX, physicalPath);
674
+ }
675
+ generateChannelId(destinationStr) {
676
+ return `auto-${destinationStr}-${generateId()}`;
677
+ }
678
+ runAsyncTask(task, name) {
679
+ if (this.taskSpawner) {
680
+ this.taskSpawner.spawn(async () => {
681
+ await task();
682
+ }, { name });
683
+ return;
684
+ }
685
+ (async () => {
686
+ try {
687
+ await task();
688
+ }
689
+ catch (error) {
690
+ logger.error("async_task_failed", {
691
+ task_name: name,
692
+ error: error instanceof Error ? error.message : String(error),
693
+ });
694
+ }
695
+ })().catch(() => {
696
+ // Swallow to avoid unhandled rejection; error already logged above.
697
+ });
698
+ }
699
+ decodeNonceValue(value) {
700
+ if (!value) {
701
+ return null;
702
+ }
703
+ const hexCandidate = value.trim();
704
+ if (hexCandidate.length % 2 === 0 && /^[0-9a-fA-F]+$/.test(hexCandidate)) {
705
+ const bytes = new Uint8Array(hexCandidate.length / 2);
706
+ for (let i = 0; i < hexCandidate.length; i += 2) {
707
+ bytes[i / 2] = parseInt(hexCandidate.slice(i, i + 2), 16);
708
+ }
709
+ if (bytes.length > 0) {
710
+ return bytes;
711
+ }
712
+ }
713
+ const base64Candidates = [
714
+ value,
715
+ value.replace(/-/g, "+").replace(/_/g, "/"),
716
+ ];
717
+ for (const candidate of base64Candidates) {
718
+ try {
719
+ // Standard base64 decode first (Buffer), then urlsafe fallback
720
+ if (typeof Buffer !== "undefined") {
721
+ const decoded = Uint8Array.from(Buffer.from(candidate, "base64"));
722
+ if (decoded.length > 0) {
723
+ return decoded;
724
+ }
725
+ }
726
+ }
727
+ catch {
728
+ // ignore and try next
729
+ }
730
+ try {
731
+ const decoded = urlsafeBase64Decode(candidate);
732
+ if (decoded.length > 0) {
733
+ return decoded;
734
+ }
735
+ }
736
+ catch {
737
+ // ignore and continue
738
+ }
739
+ }
740
+ return null;
741
+ }
742
+ }
743
+ //# sourceMappingURL=channel-encryption-manager.js.map