@adaas/a-frame 0.0.22 → 0.1.1

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 (379) hide show
  1. package/.conf/tsconfig.browser.json +13 -0
  2. package/.conf/tsconfig.node.json +14 -0
  3. package/.env.example +12 -0
  4. package/dist/browser/A-FrameBrowserStorageBlobs.context-OEQr85oq.d.mts +40 -0
  5. package/dist/browser/A-FrameBundle.types-DaaUvViw.d.mts +33 -0
  6. package/dist/browser/A-FrameChannel.types-DWOEUs28.d.mts +142 -0
  7. package/dist/browser/A-FrameDefinition.entity-DWGN_Ujr.d.mts +329 -0
  8. package/dist/browser/A-FrameDynamicStructure.entity-DaBgSRCR.d.mts +188 -0
  9. package/dist/browser/A-FrameLogger.component.env-browser-BIPAP4oQ.d.mts +112 -0
  10. package/dist/browser/A-FrameNamespace.entity-rCm1AavP.d.mts +125 -0
  11. package/dist/browser/bundle.d.mts +8 -0
  12. package/dist/browser/bundle.mjs +2 -0
  13. package/dist/browser/bundle.mjs.map +1 -0
  14. package/dist/browser/channel.d.mts +165 -0
  15. package/dist/browser/channel.mjs +3 -0
  16. package/dist/browser/channel.mjs.map +1 -0
  17. package/dist/browser/chunk-5TTVFB3G.mjs +2 -0
  18. package/dist/browser/chunk-5TTVFB3G.mjs.map +1 -0
  19. package/dist/browser/chunk-AYN7KUQT.mjs +3 -0
  20. package/dist/browser/chunk-AYN7KUQT.mjs.map +1 -0
  21. package/dist/browser/chunk-DMGQW3AO.mjs +2 -0
  22. package/dist/browser/chunk-DMGQW3AO.mjs.map +1 -0
  23. package/dist/browser/chunk-G66IL2DR.mjs +2 -0
  24. package/dist/browser/chunk-G66IL2DR.mjs.map +1 -0
  25. package/dist/browser/chunk-GOADBDTE.mjs +2 -0
  26. package/dist/browser/chunk-GOADBDTE.mjs.map +1 -0
  27. package/dist/browser/chunk-H6OZP4ZV.mjs +2 -0
  28. package/dist/browser/chunk-H6OZP4ZV.mjs.map +1 -0
  29. package/dist/browser/chunk-INS7RO3B.mjs +2 -0
  30. package/dist/browser/chunk-INS7RO3B.mjs.map +1 -0
  31. package/dist/browser/chunk-K4MZY4ME.mjs +2 -0
  32. package/dist/browser/chunk-K4MZY4ME.mjs.map +1 -0
  33. package/dist/browser/chunk-OFKV5GNB.mjs +3 -0
  34. package/dist/browser/chunk-OFKV5GNB.mjs.map +1 -0
  35. package/dist/browser/chunk-QATIN7CO.mjs +3 -0
  36. package/dist/browser/chunk-QATIN7CO.mjs.map +1 -0
  37. package/dist/browser/chunk-QBBQ37P3.mjs +2 -0
  38. package/dist/browser/chunk-QBBQ37P3.mjs.map +1 -0
  39. package/dist/browser/chunk-VDVJWU5T.mjs +2 -0
  40. package/dist/browser/chunk-VDVJWU5T.mjs.map +1 -0
  41. package/dist/browser/chunk-X3C4I6YJ.mjs +2 -0
  42. package/dist/browser/chunk-X3C4I6YJ.mjs.map +1 -0
  43. package/dist/browser/chunk-YQJFTBGV.mjs +3 -0
  44. package/dist/browser/chunk-YQJFTBGV.mjs.map +1 -0
  45. package/dist/browser/chunk-ZVCTU2DN.mjs +3 -0
  46. package/dist/browser/chunk-ZVCTU2DN.mjs.map +1 -0
  47. package/dist/browser/core.d.mts +97 -0
  48. package/dist/browser/core.mjs +2 -0
  49. package/dist/browser/core.mjs.map +1 -0
  50. package/dist/browser/crypto.d.mts +35 -0
  51. package/dist/browser/crypto.mjs +2 -0
  52. package/dist/browser/crypto.mjs.map +1 -0
  53. package/dist/browser/definition.d.mts +13 -0
  54. package/dist/browser/definition.mjs +2 -0
  55. package/dist/browser/definition.mjs.map +1 -0
  56. package/dist/browser/dynamic-feature.d.mts +10 -0
  57. package/dist/browser/dynamic-feature.mjs +2 -0
  58. package/dist/browser/dynamic-feature.mjs.map +1 -0
  59. package/dist/browser/dynamic-structure.d.mts +12 -0
  60. package/dist/browser/dynamic-structure.mjs +2 -0
  61. package/dist/browser/dynamic-structure.mjs.map +1 -0
  62. package/dist/browser/env.d.mts +2 -0
  63. package/dist/browser/env.mjs +2 -0
  64. package/dist/browser/env.mjs.map +1 -0
  65. package/dist/browser/frame-index.d.mts +95 -0
  66. package/dist/browser/frame-index.mjs +2 -0
  67. package/dist/browser/frame-index.mjs.map +1 -0
  68. package/dist/browser/index.browser-CZlhzfSP.d.mts +22 -0
  69. package/dist/browser/index.d.mts +1 -144
  70. package/dist/browser/index.mjs +1 -1
  71. package/dist/browser/index.mjs.map +1 -1
  72. package/dist/browser/logger.d.mts +41 -0
  73. package/dist/browser/logger.mjs +2 -0
  74. package/dist/browser/logger.mjs.map +1 -0
  75. package/dist/browser/namespace.d.mts +13 -0
  76. package/dist/browser/namespace.mjs +2 -0
  77. package/dist/browser/namespace.mjs.map +1 -0
  78. package/dist/browser/storage.d.mts +194 -0
  79. package/dist/browser/storage.mjs +2 -0
  80. package/dist/browser/storage.mjs.map +1 -0
  81. package/dist/browser/vector.d.mts +15 -0
  82. package/dist/browser/vector.mjs +2 -0
  83. package/dist/browser/vector.mjs.map +1 -0
  84. package/dist/index.cjs +0 -0
  85. package/dist/node/A-FrameChannel.component-BfBcs734.d.ts +62 -0
  86. package/dist/node/A-FrameChannel.component-NNKcFViw.d.mts +62 -0
  87. package/dist/node/A-FrameChannel.types-DQF-IiRq.d.mts +146 -0
  88. package/dist/node/A-FrameChannel.types-DQF-IiRq.d.ts +146 -0
  89. package/dist/node/A-FrameDefinition.entity-CAUOdEvU.d.ts +329 -0
  90. package/dist/node/A-FrameDefinition.entity-DWGN_Ujr.d.mts +329 -0
  91. package/dist/node/A-FrameDynamicStructure.entity-DaBgSRCR.d.mts +188 -0
  92. package/dist/node/A-FrameDynamicStructure.entity-DaBgSRCR.d.ts +188 -0
  93. package/dist/node/A-FrameNamespace.entity-D3fZBGDx.d.ts +125 -0
  94. package/dist/node/A-FrameNamespace.entity-rCm1AavP.d.mts +125 -0
  95. package/dist/node/A-FrameStorage.component-BYjHfHJJ.d.mts +107 -0
  96. package/dist/node/A-FrameStorage.component-CT01fs-t.d.ts +107 -0
  97. package/dist/node/bundle.cjs +101 -0
  98. package/dist/node/bundle.cjs.map +1 -0
  99. package/dist/node/bundle.d.mts +69 -0
  100. package/dist/node/bundle.d.ts +69 -0
  101. package/dist/node/bundle.mjs +76 -0
  102. package/dist/node/bundle.mjs.map +1 -0
  103. package/dist/node/channel.cjs +60 -0
  104. package/dist/node/channel.cjs.map +1 -0
  105. package/dist/node/channel.d.mts +61 -0
  106. package/dist/node/channel.d.ts +61 -0
  107. package/dist/node/channel.mjs +11 -0
  108. package/dist/node/channel.mjs.map +1 -0
  109. package/dist/node/chunk-3LOMGNWA.cjs +8 -0
  110. package/dist/node/chunk-3LOMGNWA.cjs.map +1 -0
  111. package/dist/node/chunk-3ONWH75E.mjs +257 -0
  112. package/dist/node/chunk-3ONWH75E.mjs.map +1 -0
  113. package/dist/node/chunk-3TD2PEDZ.mjs +53 -0
  114. package/dist/node/chunk-3TD2PEDZ.mjs.map +1 -0
  115. package/dist/node/chunk-442DXGOD.mjs +16 -0
  116. package/dist/node/chunk-442DXGOD.mjs.map +1 -0
  117. package/dist/node/chunk-5BKCX2RO.mjs +33 -0
  118. package/dist/node/chunk-5BKCX2RO.mjs.map +1 -0
  119. package/dist/node/chunk-6EFXNUL4.mjs +6 -0
  120. package/dist/node/chunk-6EFXNUL4.mjs.map +1 -0
  121. package/dist/node/chunk-6KAGWGTE.mjs +529 -0
  122. package/dist/node/chunk-6KAGWGTE.mjs.map +1 -0
  123. package/dist/node/chunk-7A6XGT5J.cjs +541 -0
  124. package/dist/node/chunk-7A6XGT5J.cjs.map +1 -0
  125. package/dist/node/chunk-AOQRXZPC.mjs +207 -0
  126. package/dist/node/chunk-AOQRXZPC.mjs.map +1 -0
  127. package/dist/node/chunk-APRYHBEF.mjs +171 -0
  128. package/dist/node/chunk-APRYHBEF.mjs.map +1 -0
  129. package/dist/node/chunk-B7BXP7K4.mjs +253 -0
  130. package/dist/node/chunk-B7BXP7K4.mjs.map +1 -0
  131. package/dist/node/chunk-B7ZDJXD3.cjs +35 -0
  132. package/dist/node/chunk-B7ZDJXD3.cjs.map +1 -0
  133. package/dist/node/chunk-CP6JHUU6.cjs +541 -0
  134. package/dist/node/chunk-CP6JHUU6.cjs.map +1 -0
  135. package/dist/node/chunk-DDCEMKBP.mjs +655 -0
  136. package/dist/node/chunk-DDCEMKBP.mjs.map +1 -0
  137. package/dist/node/chunk-DMY44VUG.mjs +655 -0
  138. package/dist/node/chunk-DMY44VUG.mjs.map +1 -0
  139. package/dist/node/chunk-F46TSY2K.cjs +541 -0
  140. package/dist/node/chunk-F46TSY2K.cjs.map +1 -0
  141. package/dist/node/chunk-F4UCOZW5.mjs +33 -0
  142. package/dist/node/chunk-F4UCOZW5.mjs.map +1 -0
  143. package/dist/node/chunk-GBTFMT3K.cjs +256 -0
  144. package/dist/node/chunk-GBTFMT3K.cjs.map +1 -0
  145. package/dist/node/chunk-GNVXVK2B.cjs +8 -0
  146. package/dist/node/chunk-GNVXVK2B.cjs.map +1 -0
  147. package/dist/node/chunk-GRR6NNWY.cjs +688 -0
  148. package/dist/node/chunk-GRR6NNWY.cjs.map +1 -0
  149. package/dist/node/chunk-IIVYTS5M.mjs +239 -0
  150. package/dist/node/chunk-IIVYTS5M.mjs.map +1 -0
  151. package/dist/node/chunk-JQBYDEMW.mjs +33 -0
  152. package/dist/node/chunk-JQBYDEMW.mjs.map +1 -0
  153. package/dist/node/chunk-K4MZY4ME.mjs +3 -0
  154. package/dist/node/chunk-K4MZY4ME.mjs.map +1 -0
  155. package/dist/node/chunk-KK64VLZN.cjs +4 -0
  156. package/dist/node/chunk-KK64VLZN.cjs.map +1 -0
  157. package/dist/node/chunk-KLG6HKFU.cjs +175 -0
  158. package/dist/node/chunk-KLG6HKFU.cjs.map +1 -0
  159. package/dist/node/chunk-LJIZ47HO.cjs +688 -0
  160. package/dist/node/chunk-LJIZ47HO.cjs.map +1 -0
  161. package/dist/node/chunk-NIXKAQVP.cjs +35 -0
  162. package/dist/node/chunk-NIXKAQVP.cjs.map +1 -0
  163. package/dist/node/chunk-OI76LHVT.mjs +21 -0
  164. package/dist/node/chunk-OI76LHVT.mjs.map +1 -0
  165. package/dist/node/chunk-OJGCQNAH.mjs +529 -0
  166. package/dist/node/chunk-OJGCQNAH.mjs.map +1 -0
  167. package/dist/node/chunk-OYC6L5NX.mjs +6 -0
  168. package/dist/node/chunk-OYC6L5NX.mjs.map +1 -0
  169. package/dist/node/chunk-QFHZIG7Y.cjs +25 -0
  170. package/dist/node/chunk-QFHZIG7Y.cjs.map +1 -0
  171. package/dist/node/chunk-QFUZVN4Y.cjs +259 -0
  172. package/dist/node/chunk-QFUZVN4Y.cjs.map +1 -0
  173. package/dist/node/chunk-R2H234YO.cjs +8 -0
  174. package/dist/node/chunk-R2H234YO.cjs.map +1 -0
  175. package/dist/node/chunk-RRLTGGM7.cjs +209 -0
  176. package/dist/node/chunk-RRLTGGM7.cjs.map +1 -0
  177. package/dist/node/chunk-SDKIJDMH.mjs +655 -0
  178. package/dist/node/chunk-SDKIJDMH.mjs.map +1 -0
  179. package/dist/node/chunk-TO4BPKCY.mjs +6 -0
  180. package/dist/node/chunk-TO4BPKCY.mjs.map +1 -0
  181. package/dist/node/chunk-UKKCN7CQ.cjs +688 -0
  182. package/dist/node/chunk-UKKCN7CQ.cjs.map +1 -0
  183. package/dist/node/chunk-UPA7VN4R.mjs +153 -0
  184. package/dist/node/chunk-UPA7VN4R.mjs.map +1 -0
  185. package/dist/node/chunk-UTJ7CVVB.cjs +248 -0
  186. package/dist/node/chunk-UTJ7CVVB.cjs.map +1 -0
  187. package/dist/node/chunk-XFUF7SDO.cjs +35 -0
  188. package/dist/node/chunk-XFUF7SDO.cjs.map +1 -0
  189. package/dist/node/chunk-YVX4W6SI.cjs +155 -0
  190. package/dist/node/chunk-YVX4W6SI.cjs.map +1 -0
  191. package/dist/node/chunk-YWWGJ6EJ.cjs +55 -0
  192. package/dist/node/chunk-YWWGJ6EJ.cjs.map +1 -0
  193. package/dist/node/chunk-Z4HUCRK2.mjs +529 -0
  194. package/dist/node/chunk-Z4HUCRK2.mjs.map +1 -0
  195. package/dist/node/chunk-ZM2RLVVH.cjs +18 -0
  196. package/dist/node/chunk-ZM2RLVVH.cjs.map +1 -0
  197. package/dist/node/core.cjs +259 -0
  198. package/dist/node/core.cjs.map +1 -0
  199. package/dist/node/core.d.mts +76 -0
  200. package/dist/node/core.d.ts +76 -0
  201. package/dist/node/core.mjs +248 -0
  202. package/dist/node/core.mjs.map +1 -0
  203. package/dist/node/crypto.cjs +13 -0
  204. package/dist/node/crypto.cjs.map +1 -0
  205. package/dist/node/crypto.d.mts +44 -0
  206. package/dist/node/crypto.d.ts +44 -0
  207. package/dist/node/crypto.mjs +4 -0
  208. package/dist/node/crypto.mjs.map +1 -0
  209. package/dist/node/definition.cjs +19 -0
  210. package/dist/node/definition.cjs.map +1 -0
  211. package/dist/node/definition.d.mts +13 -0
  212. package/dist/node/definition.d.ts +13 -0
  213. package/dist/node/definition.mjs +6 -0
  214. package/dist/node/definition.mjs.map +1 -0
  215. package/dist/node/dynamic-feature.cjs +14 -0
  216. package/dist/node/dynamic-feature.cjs.map +1 -0
  217. package/dist/node/dynamic-feature.d.mts +10 -0
  218. package/dist/node/dynamic-feature.d.ts +10 -0
  219. package/dist/node/dynamic-feature.mjs +12 -0
  220. package/dist/node/dynamic-feature.mjs.map +1 -0
  221. package/dist/node/dynamic-structure.cjs +143 -0
  222. package/dist/node/dynamic-structure.cjs.map +1 -0
  223. package/dist/node/dynamic-structure.d.mts +12 -0
  224. package/dist/node/dynamic-structure.d.ts +12 -0
  225. package/dist/node/dynamic-structure.mjs +138 -0
  226. package/dist/node/dynamic-structure.mjs.map +1 -0
  227. package/dist/node/env.cjs +14 -0
  228. package/dist/node/env.cjs.map +1 -0
  229. package/dist/node/env.d.mts +22 -0
  230. package/dist/node/env.d.ts +22 -0
  231. package/dist/node/env.mjs +5 -0
  232. package/dist/node/env.mjs.map +1 -0
  233. package/dist/node/frame-index.cjs +16 -0
  234. package/dist/node/frame-index.cjs.map +1 -0
  235. package/dist/node/frame-index.d.mts +95 -0
  236. package/dist/node/frame-index.d.ts +95 -0
  237. package/dist/node/frame-index.mjs +7 -0
  238. package/dist/node/frame-index.mjs.map +1 -0
  239. package/dist/node/index.cjs +0 -288
  240. package/dist/node/index.cjs.map +1 -1
  241. package/dist/node/index.d.mts +1 -144
  242. package/dist/node/index.d.ts +1 -144
  243. package/dist/node/index.mjs +0 -284
  244. package/dist/node/index.mjs.map +1 -1
  245. package/dist/node/logger.cjs +41 -0
  246. package/dist/node/logger.cjs.map +1 -0
  247. package/dist/node/logger.d.mts +150 -0
  248. package/dist/node/logger.d.ts +150 -0
  249. package/dist/node/logger.mjs +4 -0
  250. package/dist/node/logger.mjs.map +1 -0
  251. package/dist/node/namespace.cjs +24 -0
  252. package/dist/node/namespace.cjs.map +1 -0
  253. package/dist/node/namespace.d.mts +13 -0
  254. package/dist/node/namespace.d.ts +13 -0
  255. package/dist/node/namespace.mjs +7 -0
  256. package/dist/node/namespace.mjs.map +1 -0
  257. package/dist/node/storage.cjs +42 -0
  258. package/dist/node/storage.cjs.map +1 -0
  259. package/dist/node/storage.d.mts +110 -0
  260. package/dist/node/storage.d.ts +110 -0
  261. package/dist/node/storage.mjs +13 -0
  262. package/dist/node/storage.mjs.map +1 -0
  263. package/dist/node/vector.cjs +13 -0
  264. package/dist/node/vector.cjs.map +1 -0
  265. package/dist/node/vector.d.mts +15 -0
  266. package/dist/node/vector.d.ts +15 -0
  267. package/dist/node/vector.mjs +4 -0
  268. package/dist/node/vector.mjs.map +1 -0
  269. package/jest.config.browser.ts +41 -0
  270. package/jest.config.ts +18 -8
  271. package/package.json +125 -13
  272. package/{index.ts → src/concept.ts} +5 -2
  273. package/src/helpers/Hash.helper.ts +14 -0
  274. package/src/index.ts +0 -24
  275. package/src/lib/A-Frame/A-Frame.component.env-browser.ts +126 -0
  276. package/src/lib/A-Frame/A-Frame.component.env-node.ts +105 -0
  277. package/src/lib/A-Frame/A-Frame.component.ts +62 -0
  278. package/src/lib/A-Frame/A-Frame.context.ts +40 -0
  279. package/src/lib/{components/Index.component.ts/Index.error.ts → A-Frame/A-Frame.error.ts} +1 -1
  280. package/src/lib/{components/Index.component.ts/Index.guard.ts → A-Frame/A-Frame.guard.ts} +9 -6
  281. package/src/lib/A-Frame/A-Frame.meta.ts +27 -0
  282. package/src/lib/{components/Index.component.ts/Index.types.ts → A-Frame/A-Frame.types.ts} +52 -17
  283. package/src/lib/A-Frame/decorators/A-FrameDefine.decorator.ts +104 -0
  284. package/src/lib/A-Frame/decorators/A-FrameNamespace.decorator.ts +33 -0
  285. package/src/lib/A-Frame/index.browser.ts +10 -0
  286. package/src/lib/A-Frame/index.ts +10 -0
  287. package/src/lib/A-FrameBundle/A-FrameBundle.builder.env-node.ts +95 -0
  288. package/src/lib/A-FrameBundle/A-FrameBundle.constants.ts +5 -0
  289. package/src/lib/A-FrameBundle/A-FrameBundle.types.ts +31 -0
  290. package/src/lib/A-FrameBundle/index.browser.ts +6 -0
  291. package/src/lib/A-FrameBundle/index.ts +7 -0
  292. package/src/lib/A-FrameCLI/A-FrameCLI.container.ts +333 -0
  293. package/src/lib/A-FrameChannel/A-FrameChannel.component.env-browser.ts +63 -0
  294. package/src/lib/A-FrameChannel/A-FrameChannel.component.env-node.ts +586 -0
  295. package/src/lib/A-FrameChannel/A-FrameChannel.component.ts +273 -0
  296. package/src/lib/A-FrameChannel/A-FrameChannel.constants.ts +39 -0
  297. package/src/lib/A-FrameChannel/A-FrameChannel.error.ts +10 -0
  298. package/src/lib/A-FrameChannel/A-FrameChannel.types.ts +143 -0
  299. package/src/lib/A-FrameChannel/A-FrameChannelEvent.context.ts +28 -0
  300. package/src/lib/A-FrameChannel/A-FrameChannelRequest.context.ts +36 -0
  301. package/src/lib/A-FrameChannel/A-FrameChannelSocket.entity.ts +189 -0
  302. package/src/lib/A-FrameChannel/A-FrameChannelStream.entity.ts +144 -0
  303. package/src/lib/A-FrameChannel/index.browser.ts +3 -0
  304. package/src/lib/A-FrameChannel/index.ts +10 -0
  305. package/src/lib/A-FrameCrypto/A-FrameCrypto.component.env-browser.ts +123 -0
  306. package/src/lib/A-FrameCrypto/A-FrameCrypto.component.env-node.ts +204 -0
  307. package/src/lib/A-FrameCrypto/index.browser.ts +1 -0
  308. package/src/lib/A-FrameCrypto/index.ts +1 -0
  309. package/src/lib/A-FrameDefinition/A-FrameDefinition.constants.ts +8 -0
  310. package/src/lib/A-FrameDefinition/A-FrameDefinition.entity.ts +290 -0
  311. package/src/lib/A-FrameDefinition/A-FrameDefinition.types.ts +109 -0
  312. package/src/lib/A-FrameDefinition/index.ts +3 -0
  313. package/src/lib/A-FrameDynamicFeature/A-FrameDynamicFeature.entity.ts +13 -0
  314. package/src/lib/A-FrameDynamicFeature/A-FrameDynamicFeature.types.ts +10 -0
  315. package/src/lib/A-FrameDynamicFeature/index.ts +2 -0
  316. package/src/lib/A-FrameDynamicPatch/A-FrameDynamicPatch.entity.ts +38 -0
  317. package/src/lib/A-FrameDynamicPatch/A-FrameDynamicPatch.types.ts +20 -0
  318. package/src/lib/A-FrameDynamicSession/A-FrameDynamicSession.constants.ts +9 -0
  319. package/src/lib/A-FrameDynamicSession/A-FrameDynamicSession.entity.ts +91 -0
  320. package/src/lib/A-FrameDynamicSession/A-FrameDynamicSession.types.ts +18 -0
  321. package/src/lib/A-FrameDynamicStructure/A-FrameDynamicStructure.constants.ts +13 -0
  322. package/src/lib/A-FrameDynamicStructure/A-FrameDynamicStructure.entity.ts +187 -0
  323. package/src/lib/A-FrameDynamicStructure/A-FrameDynamicStructure.error.ts +13 -0
  324. package/src/lib/A-FrameDynamicStructure/A-FrameDynamicStructure.types.ts +128 -0
  325. package/src/lib/A-FrameDynamicStructure/A-FrameDynamicStructureOperation.context.ts +32 -0
  326. package/src/lib/A-FrameDynamicStructure/index.ts +5 -0
  327. package/src/lib/A-FrameEnv/A-FrameEnv.fragment.env-browser.ts +31 -0
  328. package/src/lib/A-FrameEnv/A-FrameEnv.fragment.env-node.ts +39 -0
  329. package/src/lib/A-FrameEnv/A-FrameEnv.types.ts +7 -0
  330. package/src/lib/A-FrameEnv/index.browser.ts +1 -0
  331. package/src/lib/A-FrameEnv/index.ts +1 -0
  332. package/src/lib/A-FrameIndex/A-FrameIndex.context.ts +321 -0
  333. package/src/lib/A-FrameIndex/A-FrameIndex.types.ts +63 -0
  334. package/src/lib/A-FrameIndex/index.browser.ts +3 -0
  335. package/src/lib/A-FrameIndex/index.ts +3 -0
  336. package/src/lib/A-FrameLogger/A-FrameLogger.component.env-browser.ts +99 -0
  337. package/src/lib/A-FrameLogger/A-FrameLogger.component.env-node.ts +129 -0
  338. package/src/lib/A-FrameLogger/A-FrameLogger.component.ts +123 -0
  339. package/src/lib/A-FrameLogger/A-FrameLogger.constants.ts +66 -0
  340. package/src/lib/A-FrameLogger/A-FrameLogger.types.ts +67 -0
  341. package/src/lib/A-FrameLogger/index.browser.ts +4 -0
  342. package/src/lib/A-FrameLogger/index.ts +4 -0
  343. package/src/lib/A-FrameNamespace/A-FrameNamespace.constants.ts +12 -0
  344. package/src/lib/A-FrameNamespace/A-FrameNamespace.entity.ts +211 -0
  345. package/src/lib/A-FrameNamespace/A-FrameNamespace.types.ts +72 -0
  346. package/src/lib/A-FrameNamespace/index.ts +3 -0
  347. package/src/lib/A-FrameStorage/A-FrameStorage.codec.ts +338 -0
  348. package/src/lib/A-FrameStorage/A-FrameStorage.component.ts +191 -0
  349. package/src/lib/A-FrameStorage/A-FrameStorage.constants.ts +11 -0
  350. package/src/lib/A-FrameStorage/A-FrameStorage.error.ts +13 -0
  351. package/src/lib/A-FrameStorage/A-FrameStorage.types.ts +98 -0
  352. package/src/lib/A-FrameStorage/A-FrameStorageOperation.context.ts +59 -0
  353. package/src/lib/A-FrameStorage/browser/A-FrameBrowserStorage.component.ts +312 -0
  354. package/src/lib/A-FrameStorage/browser/A-FrameBrowserStorageBlobs.context.ts +77 -0
  355. package/src/lib/A-FrameStorage/index.browser.ts +11 -0
  356. package/src/lib/A-FrameStorage/index.ts +10 -0
  357. package/src/lib/A-FrameStorage/node/A-FrameNodeStorage.component.ts +464 -0
  358. package/src/lib/A-FrameStorage/server/A-FrameServerStorage.component.ts +177 -0
  359. package/src/lib/{entities/A_FrameVector/A_FrameVector.entity.ts → A-FrameVector/A-FrameVector.entity.ts} +10 -0
  360. package/src/lib/A-FrameVector/index.ts +3 -0
  361. package/tests/A-Frame.browser.test.ts +94 -0
  362. package/tests/A-Frame.test.ts +74 -67
  363. package/tests/jest.browser-environment.js +30 -0
  364. package/tests/jest.polyfills.browser.ts +13 -0
  365. package/tests/jest.setup.browser.ts +33 -0
  366. package/tsconfig.browser.json +54 -0
  367. package/tsconfig.json +16 -0
  368. package/tsup.config.ts +32 -2
  369. package/src/lib/components/Builder.component.ts/Builder.component.ts +0 -0
  370. package/src/lib/components/Index.component.ts/Index.component.ts +0 -79
  371. package/src/lib/components/Index.component.ts/Index.constants.ts +0 -0
  372. package/src/lib/components/Index.component.ts/Index.meta.ts +0 -28
  373. package/src/lib/components/Index.component.ts/IndexConfigurations.meta.ts +0 -78
  374. package/src/lib/components/Index.component.ts/decorators/IndexComponent.decorator.ts +0 -97
  375. package/src/lib/components/Index.component.ts/decorators/IndexDescribe.decorator.ts +0 -59
  376. package/src/lib/components/Index.component.ts/decorators/IndexNamespace.decorator.ts +0 -57
  377. package/src/lib/components/Search/A_FrameSearch.component.ts +0 -66
  378. package/src/lib/containers/CLI.container.ts +0 -27
  379. package/src/lib/entities/Namespace/Namespace.entity.ts +0 -8
@@ -0,0 +1,189 @@
1
+ import { A_Context, A_Entity, A_Error, A_Feature, A_Scope } from "@adaas/a-concept";
2
+ import {
3
+ A_FrameChannelSocket_Init,
4
+ A_FrameChannelSocket_Serialized,
5
+ A_FrameChannelSocketStatusNames,
6
+ } from "./A-FrameChannel.types";
7
+ import { A_FrameChannelSocketFeatures, A_FrameChannelSocketStatuses } from "./A-FrameChannel.constants";
8
+ import { A_FrameChannelEvent } from "./A-FrameChannelEvent.context";
9
+ import { A_FrameChannelError } from "./A-FrameChannel.error";
10
+
11
+
12
+ /**
13
+ * A_FrameChannelSocket — bidirectional WebSocket session entity.
14
+ *
15
+ * Lifecycle:
16
+ * 1. Instantiate with `new A_FrameChannelSocket({ method: 'GET', path: '/ws/...' })`.
17
+ * 2. Register event handlers via `@A_FrameChannelSocket.onEvent('type')` on a subclass.
18
+ * 3. Pass the instance to `A_FrameChannel.connect(socket)` which performs the
19
+ * WebSocket handshake and sets the internal send capability.
20
+ * 4. While the connection is open, call `socket.send(event)` to push frames to
21
+ * the server. Incoming frames are dispatched via `propagate()`.
22
+ * 5. The socket transitions to Closed when the server sends a close frame or the
23
+ * underlying transport ends.
24
+ */
25
+ export class A_FrameChannelSocket<
26
+ T extends Record<string, any> = Record<string, any>
27
+ > extends A_Entity<
28
+ A_FrameChannelSocket_Init<T>,
29
+ A_FrameChannelSocket_Serialized<T>
30
+ > {
31
+
32
+ // ─── Static decorator ──────────────────────────────────────────────────────
33
+
34
+ /**
35
+ * Registers a method as a handler for a specific WebSocket event type sent
36
+ * by the server. Mirrors `A_FrameChannelStream.onEvent()`.
37
+ *
38
+ * Usage (inside a subclass):
39
+ * @A_FrameChannelSocket.onEvent('my_event')
40
+ * async onMyEvent(@A_Inject(A_FrameChannelEvent) event: A_FrameChannelEvent) { ... }
41
+ *
42
+ * Omit the name (or use `'all'`) to receive every event type.
43
+ */
44
+ static onEvent(name?: string) {
45
+ const featureName = (name || 'all') + A_FrameChannelSocketFeatures.onEvent;
46
+
47
+ return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
48
+ return A_Feature.Extend({
49
+ name: featureName,
50
+ scope: [target.constructor],
51
+ })(target, propertyKey, descriptor);
52
+ };
53
+ }
54
+
55
+ // ─── Protected state ──────────────────────────────────────────────────────
56
+
57
+ protected _method!: string;
58
+ protected _path!: string;
59
+ protected _body?: T;
60
+ protected _scope!: A_Scope;
61
+ protected _error?: A_Error;
62
+ protected _status!: A_FrameChannelSocketStatusNames;
63
+ protected _initDate!: string;
64
+
65
+ // ──────────────────────────────────────────────────────────────────────────
66
+ // SEND CAPABILITY
67
+ // Attached by the connect feature once the WebSocket handshake succeeds.
68
+ // Calling it serialises `data` to JSON and writes a masked WS text frame to
69
+ // the underlying raw socket. Cleared to null on close / failure.
70
+ // ──────────────────────────────────────────────────────────────────────────
71
+ protected _sendFn: ((data: string) => void) | null = null;
72
+
73
+ // ─── Computed getters ─────────────────────────────────────────────────────
74
+
75
+ /** Scope allocated for the lifetime of this socket session. */
76
+ get scope(): A_Scope {
77
+ if (!this._scope) {
78
+ this._scope = A_Context.allocate(this, new A_Scope({ name: `${this.aseid.id}-scope` }));
79
+ }
80
+ return this._scope;
81
+ }
82
+
83
+ get method(): string { return this._method; }
84
+ get path(): string { return this._path; }
85
+ get body(): T | undefined { return this._body; }
86
+ get status(): A_FrameChannelSocketStatusNames { return this._status; }
87
+ get error(): A_Error | undefined { return this._error; }
88
+ get initDate(): Date { return new Date(this._initDate); }
89
+
90
+ // ─── Connect-feature interface ────────────────────────────────────────────
91
+
92
+ /**
93
+ * Called by the connect feature immediately after a successful handshake.
94
+ * Transitions status Connecting → Open and stores the send callback.
95
+ */
96
+ attachSendFn(fn: (data: string) => void): void {
97
+ this._sendFn = fn;
98
+ this._status = A_FrameChannelSocketStatuses.Open;
99
+ }
100
+
101
+ // ─── Public API ───────────────────────────────────────────────────────────
102
+
103
+ /**
104
+ * Send an event to the server over the open WebSocket connection.
105
+ *
106
+ * The event is serialised as `{ type, data }`, matching the shape the server
107
+ * uses for events it pushes to the client — keeping both directions symmetric.
108
+ *
109
+ * @throws {A_FrameChannelError} if the socket is not open.
110
+ */
111
+ send(event: A_FrameChannelEvent): void {
112
+ if (!this._sendFn || this._status !== A_FrameChannelSocketStatuses.Open) {
113
+ throw new A_FrameChannelError({
114
+ title: A_FrameChannelError.InvalidRequest,
115
+ description: `Cannot send event "${event.name}": WebSocket is not open (status: ${this._status})`,
116
+ });
117
+ }
118
+
119
+ this._sendFn(JSON.stringify({ type: event.name, data: event.data }));
120
+ }
121
+
122
+ // ─── Lifecycle ────────────────────────────────────────────────────────────
123
+
124
+ complete(): void {
125
+ this._sendFn = null;
126
+ this._status = A_FrameChannelSocketStatuses.Closed;
127
+ }
128
+
129
+ fail(error: A_Error): void {
130
+ this._sendFn = null;
131
+ this._status = A_FrameChannelSocketStatuses.Closed;
132
+ this._error = error;
133
+ }
134
+
135
+ destroy(): Promise<void> | void {
136
+ this.scope.destroy();
137
+ }
138
+
139
+ /**
140
+ * Dispatch an incoming server event to all registered `@onEvent` handlers.
141
+ * Mirrors `A_FrameChannelStream.propagate()`.
142
+ */
143
+ async propagate<D extends Record<string, any>>(name: string, data?: D): Promise<void> {
144
+ const eventFragment = new A_FrameChannelEvent<D>(name, data);
145
+
146
+ const executionScope = new A_Scope({
147
+ name: 'A_FrameChannelSocket.propagate',
148
+ fragments: [eventFragment],
149
+ }).inherit(A_Context.scope(this));
150
+
151
+ try {
152
+ const callName = (name || 'all') + A_FrameChannelSocketFeatures.onEvent;
153
+ await this.call(callName, executionScope);
154
+ executionScope.destroy();
155
+ } catch {
156
+ executionScope.destroy();
157
+ }
158
+ }
159
+
160
+ // ─── A_Entity serialisation ───────────────────────────────────────────────
161
+
162
+ fromNew(newEntity: A_FrameChannelSocket_Init<T>): void {
163
+ this._method = newEntity.method;
164
+ this._path = newEntity.path;
165
+ this._body = newEntity.body;
166
+ this._status = A_FrameChannelSocketStatuses.Connecting;
167
+ this._initDate = new Date().toISOString();
168
+ }
169
+
170
+ fromJSON(serialized: A_FrameChannelSocket_Serialized<T>): void {
171
+ this._method = serialized.method;
172
+ this._path = serialized.path;
173
+ this._body = serialized.body;
174
+ this._status = serialized.status;
175
+ this._initDate = serialized.initDate;
176
+ }
177
+
178
+ toJSON(): A_FrameChannelSocket_Serialized<T> {
179
+ return {
180
+ ...super.toJSON(),
181
+ initDate: this._initDate,
182
+ status: this._status,
183
+ error: this._error ? this._error.toJSON() : undefined,
184
+ method: this._method,
185
+ path: this._path,
186
+ body: this._body,
187
+ };
188
+ }
189
+ }
@@ -0,0 +1,144 @@
1
+ import { A_Context, A_Entity, A_Error, A_Feature, A_Scope } from "@adaas/a-concept";
2
+ import { A_FrameChannelStream_Init, A_FrameChannelStream_Serialized, A_FrameChannelStreamStatusNames } from "./A-FrameChannel.types";
3
+ import { A_FrameChannelStreamFeatures, A_FrameChannelStreamStatuses } from "./A-FrameChannel.constants";
4
+ import { A_FrameChannelEvent } from "./A-FrameChannelEvent.context";
5
+
6
+
7
+
8
+ export class A_FrameChannelStream<
9
+ T extends Record<string, any> = Record<string, any>
10
+ > extends A_Entity<
11
+ A_FrameChannelStream_Init<T>,
12
+ A_FrameChannelStream_Serialized<T>
13
+ > {
14
+
15
+
16
+ static onEvent(name?: string) {
17
+
18
+ const eventName = (name || 'all') + A_FrameChannelStreamFeatures.onEvent;
19
+
20
+
21
+ return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
22
+ return A_Feature.Extend({
23
+ name: eventName,
24
+ scope: [target.constructor],
25
+ })(target, propertyKey, descriptor);
26
+ }
27
+ }
28
+
29
+
30
+ protected _method!: string;
31
+ protected _path!: string;
32
+ protected _body?: T;
33
+ protected _scope!: A_Scope
34
+ protected _error?: A_Error;
35
+ protected _status!: A_FrameChannelStreamStatusNames;
36
+ protected _initDate!: string;
37
+
38
+ /**
39
+ * The scope of the session, Will be destroyed after the session is closed.
40
+ */
41
+ get scope(): A_Scope {
42
+
43
+ if (!this._scope) {
44
+ this._scope = A_Context.allocate(this, new A_Scope({ name: `${this.aseid.id}-scope` }));
45
+ }
46
+
47
+ return this._scope;
48
+ }
49
+
50
+ get method(): string {
51
+ return this._method;
52
+ }
53
+
54
+ get path(): string {
55
+ return this._path;
56
+ }
57
+
58
+ get body(): T | undefined {
59
+ return this._body;
60
+ }
61
+
62
+ get status(): A_FrameChannelStreamStatusNames {
63
+ return this._status;
64
+ }
65
+
66
+ get error(): A_Error | undefined {
67
+ return this._error;
68
+ }
69
+
70
+ get initDate(): Date {
71
+ return new Date(this._initDate);
72
+ }
73
+
74
+ complete(): void {
75
+ this._status = A_FrameChannelStreamStatuses.Closed;
76
+ }
77
+
78
+ fail(error: A_Error): void {
79
+ this._status = A_FrameChannelStreamStatuses.Closed;
80
+ this._error = error;
81
+ }
82
+
83
+ destroy(): Promise<void> | void {
84
+ this.scope.destroy();
85
+ }
86
+
87
+ async open(){
88
+ await this.call(A_FrameChannelStreamFeatures.open);
89
+ }
90
+
91
+ async send(){
92
+ await this.call(A_FrameChannelStreamFeatures.send);
93
+ }
94
+
95
+
96
+ async propagate<T extends Record<string, any>>(name: string, data?: T): Promise<void> {
97
+ const request = new A_FrameChannelEvent<T>(name, data);
98
+
99
+ const executionScope = new A_Scope({
100
+ name: 'A_FrameChannelStream.propagate',
101
+ fragments: [request],
102
+ })
103
+ .inherit(this.scope);
104
+
105
+ try {
106
+
107
+ const callName = (name || 'all') + A_FrameChannelStreamFeatures.onEvent;
108
+
109
+ await this.call(callName, executionScope);
110
+ executionScope.destroy();
111
+
112
+ } catch {
113
+ executionScope.destroy();
114
+ }
115
+ }
116
+
117
+ fromNew(newEntity: A_FrameChannelStream_Init<T>): void {
118
+ this._method = newEntity.method;
119
+ this._path = newEntity.path;
120
+ this._body = newEntity.body;
121
+ this._initDate = new Date().toISOString();
122
+ }
123
+
124
+ fromJSON(serialized: A_FrameChannelStream_Serialized<T>): void {
125
+ this._method = serialized.method;
126
+ this._path = serialized.path;
127
+ this._body = serialized.body;
128
+ this._initDate = serialized.initDate;
129
+ }
130
+
131
+
132
+ toJSON(): A_FrameChannelStream_Serialized<T> {
133
+ return {
134
+ ...super.toJSON(),
135
+ initDate: this._initDate,
136
+ status: this._status,
137
+ error: this._error ? this._error.toJSON() : undefined,
138
+ method: this._method,
139
+ path: this._path,
140
+ body: this._body,
141
+ }
142
+ }
143
+
144
+ }
@@ -0,0 +1,3 @@
1
+ export * from './A-FrameChannel.component.env-browser';
2
+ export { A_FrameChannelSocket } from './A-FrameChannelSocket.entity';
3
+ export * from './A-FrameChannel.types';
@@ -0,0 +1,10 @@
1
+ export * from './A-FrameChannel.component';
2
+ export * from './A-FrameChannel.types';
3
+ export * from './A-FrameChannel.error';
4
+ export * from './A-FrameChannel.constants';
5
+
6
+ export * from './A-FrameChannelStream.entity';
7
+ export * from './A-FrameChannelEvent.context';
8
+ export * from './A-FrameChannelRequest.context';
9
+
10
+ export * from './A-FrameChannel.component.env-node';
@@ -0,0 +1,123 @@
1
+ import { A_Component } from "@adaas/a-concept";
2
+
3
+ /**
4
+ * A_FrameCrypto — Browser environment
5
+ *
6
+ * AES-256-GCM encryption + SHA-256 hashing via globalThis.crypto.subtle.
7
+ * No Node.js-specific require() calls — safe to include in browser bundles.
8
+ *
9
+ * Binary payload format on disk:
10
+ * IV (12B) + AuthTag (16B) + Ciphertext (NB)
11
+ */
12
+ export class A_FrameCrypto extends A_Component {
13
+
14
+ // ─── Internal helpers ─────────────────────────────────────────────────────
15
+
16
+ private static getSubtle(): SubtleCrypto {
17
+ return globalThis.crypto.subtle;
18
+ }
19
+
20
+ /**
21
+ * Ensure a Uint8Array is backed by a plain ArrayBuffer.
22
+ * SubtleCrypto rejects ArrayBufferLike (e.g. SharedArrayBuffer) on strict TS targets.
23
+ */
24
+ private static bytes(u: Uint8Array): Uint8Array {
25
+ if (u.buffer instanceof ArrayBuffer) return u;
26
+ return new Uint8Array(u);
27
+ }
28
+
29
+ private static async importKey(keyBase64: string): Promise<CryptoKey> {
30
+ const raw = A_FrameCrypto.base64ToBytes(keyBase64);
31
+ return A_FrameCrypto.getSubtle().importKey(
32
+ 'raw', raw.buffer as ArrayBuffer, { name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']
33
+ );
34
+ }
35
+
36
+
37
+ // ─── Encrypt ─────────────────────────────────────────────────────────────
38
+
39
+ /** Encrypt a Uint8Array → IV(12) + AuthTag(16) + Ciphertext */
40
+ static async encryptBytes(plain: Uint8Array, keyBase64: string): Promise<Uint8Array> {
41
+ const key = await A_FrameCrypto.importKey(keyBase64);
42
+ const iv = new Uint8Array(12);
43
+ globalThis.crypto.getRandomValues(iv);
44
+
45
+ const cipherWithTag = new Uint8Array(
46
+ await A_FrameCrypto.getSubtle().encrypt({ name: 'AES-GCM', iv, tagLength: 128 }, key, A_FrameCrypto.bytes(plain))
47
+ );
48
+ const ciphertext = cipherWithTag.slice(0, cipherWithTag.length - 16);
49
+ const authTag = cipherWithTag.slice(cipherWithTag.length - 16);
50
+
51
+ const out = new Uint8Array(12 + 16 + ciphertext.length);
52
+ out.set(iv, 0);
53
+ out.set(authTag, 12);
54
+ out.set(ciphertext, 28);
55
+ return out;
56
+ }
57
+
58
+ /** Encrypt a UTF-8 string → base64 payload string */
59
+ static async encrypt(plain: string, keyBase64: string): Promise<string> {
60
+ const bytes = new TextEncoder().encode(plain);
61
+ const encrypted = await A_FrameCrypto.encryptBytes(bytes, keyBase64);
62
+ return A_FrameCrypto.bytesToBase64(encrypted);
63
+ }
64
+
65
+
66
+ // ─── Decrypt ─────────────────────────────────────────────────────────────
67
+
68
+ /** Decrypt a Uint8Array payload produced by encryptBytes() */
69
+ static async decryptBytes(payload: Uint8Array, keyBase64: string): Promise<Uint8Array> {
70
+ if (payload.length < 28) throw new Error('Payload too short to decrypt');
71
+
72
+ const key = await A_FrameCrypto.importKey(keyBase64);
73
+ const iv = payload.slice(0, 12);
74
+ const authTag = payload.slice(12, 28);
75
+ const ciphertext = payload.slice(28);
76
+
77
+ const cipherWithTag = new Uint8Array(ciphertext.length + 16);
78
+ cipherWithTag.set(ciphertext, 0);
79
+ cipherWithTag.set(authTag, ciphertext.length);
80
+
81
+ const plain = await A_FrameCrypto.getSubtle().decrypt(
82
+ { name: 'AES-GCM', iv: A_FrameCrypto.bytes(iv), tagLength: 128 }, key, cipherWithTag
83
+ );
84
+ return new Uint8Array(plain);
85
+ }
86
+
87
+ /** Decrypt a base64 payload string → UTF-8 string */
88
+ static async decrypt(payloadBase64: string, keyBase64: string): Promise<string> {
89
+ const payload = A_FrameCrypto.base64ToBytes(payloadBase64);
90
+ const plain = await A_FrameCrypto.decryptBytes(payload, keyBase64);
91
+ return new TextDecoder().decode(plain);
92
+ }
93
+
94
+
95
+ // ─── Hashing ─────────────────────────────────────────────────────────────
96
+
97
+ /** SHA-256 of a string → hex string */
98
+ static async sha256hex(input: string): Promise<string> {
99
+ const data = new TextEncoder().encode(input);
100
+ const hashBuffer = await A_FrameCrypto.getSubtle().digest('SHA-256', data);
101
+ return A_FrameCrypto.bytesToHex(new Uint8Array(hashBuffer));
102
+ }
103
+
104
+
105
+ // ─── Encode helpers ───────────────────────────────────────────────────────
106
+
107
+ static bytesToBase64(bytes: Uint8Array): string {
108
+ let bin = '';
109
+ for (const b of bytes) bin += String.fromCharCode(b);
110
+ return btoa(bin);
111
+ }
112
+
113
+ static base64ToBytes(b64: string): Uint8Array {
114
+ const bin = atob(b64);
115
+ const bytes = new Uint8Array(bin.length);
116
+ for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
117
+ return bytes;
118
+ }
119
+
120
+ static bytesToHex(bytes: Uint8Array): string {
121
+ return Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join('');
122
+ }
123
+ }
@@ -0,0 +1,204 @@
1
+ import { A_Component } from "@adaas/a-concept";
2
+
3
+ /**
4
+ * A_FrameCrypto — Node.js environment
5
+ *
6
+ * AES-256-GCM encryption + SHA-256 hashing via the Web Crypto API.
7
+ * Falls back to node:crypto for Node < 19 that lack globalThis.crypto.
8
+ *
9
+ * Binary payload format on disk:
10
+ * IV (12B) + AuthTag (16B) + Ciphertext (NB)
11
+ */
12
+ export class A_FrameCrypto extends A_Component {
13
+
14
+ // ─── Internal helpers ─────────────────────────────────────────────────────
15
+
16
+ private static getSubtle(): SubtleCrypto {
17
+ if (typeof globalThis.crypto?.subtle !== 'undefined') {
18
+ return globalThis.crypto.subtle;
19
+ }
20
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
21
+ const nodeCrypto = require('node:crypto') as typeof import('node:crypto');
22
+ return nodeCrypto.webcrypto.subtle as unknown as SubtleCrypto;
23
+ }
24
+
25
+ private static getRandomBytes(n: number): Uint8Array {
26
+ const buf = new Uint8Array(n);
27
+ if (typeof globalThis.crypto?.getRandomValues !== 'undefined') {
28
+ globalThis.crypto.getRandomValues(buf);
29
+ } else {
30
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
31
+ const nodeCrypto = require('node:crypto') as typeof import('node:crypto');
32
+ buf.set(nodeCrypto.randomBytes(n));
33
+ }
34
+ return buf;
35
+ }
36
+
37
+ /**
38
+ * Ensure a Uint8Array is backed by a plain ArrayBuffer and return it.
39
+ * SubtleCrypto rejects ArrayBufferLike (e.g. SharedArrayBuffer) on strict TS targets.
40
+ */
41
+ private static bytes(u: Uint8Array): ArrayBuffer {
42
+ if (u.buffer instanceof ArrayBuffer && u.byteOffset === 0 && u.byteLength === u.buffer.byteLength) {
43
+ return u.buffer as ArrayBuffer;
44
+ }
45
+ return new Uint8Array(u).buffer as ArrayBuffer;
46
+ }
47
+
48
+ private static async importKey(keyBase64: string): Promise<CryptoKey> {
49
+ const raw = A_FrameCrypto.base64ToBytes(keyBase64);
50
+ return A_FrameCrypto.getSubtle().importKey(
51
+ 'raw', raw.buffer as ArrayBuffer, { name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']
52
+ );
53
+ }
54
+
55
+
56
+ // ─── Encrypt ──────────────────────────────────────────────────────────────
57
+
58
+ /** Encrypt a Uint8Array → IV(12) + AuthTag(16) + Ciphertext */
59
+ static async encryptBytes(plain: Uint8Array, keyBase64: string): Promise<Uint8Array> {
60
+ const key = await A_FrameCrypto.importKey(keyBase64);
61
+ const iv = A_FrameCrypto.getRandomBytes(12);
62
+
63
+ const cipherWithTag = new Uint8Array(
64
+ await A_FrameCrypto.getSubtle().encrypt({ name: 'AES-GCM', iv: A_FrameCrypto.bytes(iv), tagLength: 128 }, key, A_FrameCrypto.bytes(plain))
65
+ );
66
+ const ciphertext = cipherWithTag.slice(0, cipherWithTag.length - 16);
67
+ const authTag = cipherWithTag.slice(cipherWithTag.length - 16);
68
+
69
+ const out = new Uint8Array(12 + 16 + ciphertext.length);
70
+ out.set(iv, 0);
71
+ out.set(authTag, 12);
72
+ out.set(ciphertext, 28);
73
+ return out;
74
+ }
75
+
76
+
77
+ /** Encrypt a UTF-8 string → base64 payload string */
78
+ static async encrypt(plain: string, keyBase64: string): Promise<string> {
79
+ const bytes = new TextEncoder().encode(plain);
80
+ const encrypted = await A_FrameCrypto.encryptBytes(bytes, keyBase64);
81
+ return A_FrameCrypto.bytesToBase64(encrypted);
82
+ }
83
+
84
+
85
+ // ─── Decrypt ─────────────────────────────────────────────────────────────
86
+
87
+ /** Decrypt a Uint8Array payload produced by encryptBytes() */
88
+ static async decryptBytes(payload: Uint8Array, keyBase64: string): Promise<Uint8Array> {
89
+ if (payload.length < 28) throw new Error('Payload too short to decrypt');
90
+
91
+ const key = await A_FrameCrypto.importKey(keyBase64);
92
+ const iv = payload.slice(0, 12);
93
+ const authTag = payload.slice(12, 28);
94
+ const ciphertext = payload.slice(28);
95
+
96
+ const cipherWithTag = new Uint8Array(ciphertext.length + 16);
97
+ cipherWithTag.set(ciphertext, 0);
98
+ cipherWithTag.set(authTag, ciphertext.length);
99
+
100
+ const plain = await A_FrameCrypto.getSubtle().decrypt(
101
+ { name: 'AES-GCM', iv: A_FrameCrypto.bytes(iv), tagLength: 128 }, key, A_FrameCrypto.bytes(cipherWithTag)
102
+ );
103
+ return new Uint8Array(plain);
104
+ }
105
+
106
+
107
+ /** Decrypt a base64 payload string → UTF-8 string */
108
+ static async decrypt(payloadBase64: string, keyBase64: string): Promise<string> {
109
+ const payload = A_FrameCrypto.base64ToBytes(payloadBase64);
110
+ const plain = await A_FrameCrypto.decryptBytes(payload, keyBase64);
111
+ return new TextDecoder().decode(plain);
112
+ }
113
+
114
+
115
+
116
+
117
+ // ─── Hashing ──────────────────────────────────────────────────────────────
118
+
119
+ /** SHA-256 of a string → hex string */
120
+ static async sha256hex(input: string): Promise<string> {
121
+ const data = new TextEncoder().encode(input);
122
+ try {
123
+ const hashBuffer = await A_FrameCrypto.getSubtle().digest('SHA-256', A_FrameCrypto.bytes(data));
124
+ return A_FrameCrypto.bytesToHex(new Uint8Array(hashBuffer));
125
+ } catch {
126
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
127
+ const nodeCrypto = require('node:crypto') as typeof import('node:crypto');
128
+ return nodeCrypto.createHash('sha256').update(input).digest('hex');
129
+ }
130
+ }
131
+
132
+
133
+
134
+
135
+ // ─── Encode helpers ───────────────────────────────────────────────────────
136
+
137
+ static bytesToBase64(bytes: Uint8Array): string {
138
+ if (typeof Buffer !== 'undefined') {
139
+ return Buffer.from(bytes).toString('base64');
140
+ }
141
+ let bin = '';
142
+ for (const b of bytes) bin += String.fromCharCode(b);
143
+ return btoa(bin);
144
+ }
145
+
146
+
147
+
148
+
149
+ static base64ToBytes(b64: string): Uint8Array {
150
+ if (typeof Buffer !== 'undefined') {
151
+ return new Uint8Array(Buffer.from(b64, 'base64'));
152
+ }
153
+ const bin = atob(b64);
154
+ const bytes = new Uint8Array(bin.length);
155
+ for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
156
+ return bytes;
157
+ }
158
+
159
+
160
+
161
+
162
+ static bytesToHex(bytes: Uint8Array): string {
163
+ return Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join('');
164
+ }
165
+
166
+ // =================================================================================
167
+ // Instance methods just call the static versions for convenient injection into other components
168
+ // =================================================================================
169
+
170
+
171
+ encryptBytes(plain: Uint8Array, keyBase64: string): Promise<Uint8Array> {
172
+ return A_FrameCrypto.encryptBytes(plain, keyBase64);
173
+ }
174
+
175
+
176
+ encrypt(plain: string, keyBase64: string): Promise<string> {
177
+ return A_FrameCrypto.encrypt(plain, keyBase64);
178
+ }
179
+
180
+ decryptBytes(payload: Uint8Array, keyBase64: string): Promise<Uint8Array> {
181
+ return A_FrameCrypto.decryptBytes(payload, keyBase64);
182
+ }
183
+
184
+
185
+ decrypt(payloadBase64: string, keyBase64: string): Promise<string> {
186
+ return A_FrameCrypto.decrypt(payloadBase64, keyBase64);
187
+ }
188
+
189
+ sha256hex(input: string): Promise<string> {
190
+ return A_FrameCrypto.sha256hex(input);
191
+ }
192
+
193
+ bytesToBase64(bytes: Uint8Array): string {
194
+ return A_FrameCrypto.bytesToBase64(bytes);
195
+ }
196
+
197
+ base64ToBytes(b64: string): Uint8Array {
198
+ return A_FrameCrypto.base64ToBytes(b64);
199
+ }
200
+
201
+ bytesToHex(bytes: Uint8Array): string {
202
+ return A_FrameCrypto.bytesToHex(bytes);
203
+ }
204
+ }
@@ -0,0 +1 @@
1
+ export * from './A-FrameCrypto.component.env-browser';
@@ -0,0 +1 @@
1
+ export * from './A-FrameCrypto.component.env-node';