@ibgib/core-gib 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (330) hide show
  1. package/.vscode/core-gib-snippets.code-snippets +189 -0
  2. package/.vscode/launch.json +24 -0
  3. package/.vscode/settings.json +56 -0
  4. package/.vscode/tasks.json +37 -0
  5. package/CHANGELOG.md +11 -0
  6. package/README.md +215 -0
  7. package/dist/common/aws-constants.d.mts +7 -0
  8. package/dist/common/aws-constants.d.mts.map +1 -0
  9. package/dist/common/aws-constants.mjs +7 -0
  10. package/dist/common/aws-constants.mjs.map +1 -0
  11. package/dist/common/bin/bin-types.d.mts +17 -0
  12. package/dist/common/bin/bin-types.d.mts.map +1 -0
  13. package/dist/common/bin/bin-types.mjs +3 -0
  14. package/dist/common/bin/bin-types.mjs.map +1 -0
  15. package/dist/common/cache/cache-types.d.mts +57 -0
  16. package/dist/common/cache/cache-types.d.mts.map +1 -0
  17. package/dist/common/cache/cache-types.mjs +2 -0
  18. package/dist/common/cache/cache-types.mjs.map +1 -0
  19. package/dist/common/comment/comment-constants.d.mts +11 -0
  20. package/dist/common/comment/comment-constants.d.mts.map +1 -0
  21. package/dist/common/comment/comment-constants.mjs +11 -0
  22. package/dist/common/comment/comment-constants.mjs.map +1 -0
  23. package/dist/common/comment/comment-helper.d.mts +59 -0
  24. package/dist/common/comment/comment-helper.d.mts.map +1 -0
  25. package/dist/common/comment/comment-helper.mjs +173 -0
  26. package/dist/common/comment/comment-helper.mjs.map +1 -0
  27. package/dist/common/comment/comment-types.d.mts +16 -0
  28. package/dist/common/comment/comment-types.d.mts.map +1 -0
  29. package/dist/common/comment/comment-types.mjs +2 -0
  30. package/dist/common/comment/comment-types.mjs.map +1 -0
  31. package/dist/common/display/display-helper.d.mts +19 -0
  32. package/dist/common/display/display-helper.d.mts.map +1 -0
  33. package/dist/common/display/display-helper.mjs +68 -0
  34. package/dist/common/display/display-helper.mjs.map +1 -0
  35. package/dist/common/display/display-types.d.mts +97 -0
  36. package/dist/common/display/display-types.d.mts.map +1 -0
  37. package/dist/common/display/display-types.mjs +37 -0
  38. package/dist/common/display/display-types.mjs.map +1 -0
  39. package/dist/common/encrypt/encrypt-constants.d.mts +27 -0
  40. package/dist/common/encrypt/encrypt-constants.d.mts.map +1 -0
  41. package/dist/common/encrypt/encrypt-constants.mjs +27 -0
  42. package/dist/common/encrypt/encrypt-constants.mjs.map +1 -0
  43. package/dist/common/encrypt/encrypt-types.d.mts +116 -0
  44. package/dist/common/encrypt/encrypt-types.d.mts.map +1 -0
  45. package/dist/common/encrypt/encrypt-types.mjs +9 -0
  46. package/dist/common/encrypt/encrypt-types.mjs.map +1 -0
  47. package/dist/common/error/error-constants.d.mts +9 -0
  48. package/dist/common/error/error-constants.d.mts.map +1 -0
  49. package/dist/common/error/error-constants.mjs +9 -0
  50. package/dist/common/error/error-constants.mjs.map +1 -0
  51. package/dist/common/error/error-helper.d.mts +43 -0
  52. package/dist/common/error/error-helper.d.mts.map +1 -0
  53. package/dist/common/error/error-helper.mjs +167 -0
  54. package/dist/common/error/error-helper.mjs.map +1 -0
  55. package/dist/common/error/error-types.d.mts +58 -0
  56. package/dist/common/error/error-types.d.mts.map +1 -0
  57. package/dist/common/error/error-types.mjs +2 -0
  58. package/dist/common/error/error-types.mjs.map +1 -0
  59. package/dist/common/form/form-helper.d.mts +97 -0
  60. package/dist/common/form/form-helper.d.mts.map +1 -0
  61. package/dist/common/form/form-helper.mjs +185 -0
  62. package/dist/common/form/form-helper.mjs.map +1 -0
  63. package/dist/common/form/form-items.d.mts +229 -0
  64. package/dist/common/form/form-items.d.mts.map +1 -0
  65. package/dist/common/form/form-items.mjs +63 -0
  66. package/dist/common/form/form-items.mjs.map +1 -0
  67. package/dist/common/import-export/import-export-types.d.mts +18 -0
  68. package/dist/common/import-export/import-export-types.d.mts.map +1 -0
  69. package/dist/common/import-export/import-export-types.mjs +2 -0
  70. package/dist/common/import-export/import-export-types.mjs.map +1 -0
  71. package/dist/common/legacy/legacy-types.d.mts +2 -0
  72. package/dist/common/legacy/legacy-types.d.mts.map +1 -0
  73. package/dist/common/legacy/legacy-types.mjs +2 -0
  74. package/dist/common/legacy/legacy-types.mjs.map +1 -0
  75. package/dist/common/link/link-constants.d.mts +2 -0
  76. package/dist/common/link/link-constants.d.mts.map +1 -0
  77. package/dist/common/link/link-constants.mjs +2 -0
  78. package/dist/common/link/link-constants.mjs.map +1 -0
  79. package/dist/common/link/link-helper.d.mts +37 -0
  80. package/dist/common/link/link-helper.d.mts.map +1 -0
  81. package/dist/common/link/link-helper.mjs +143 -0
  82. package/dist/common/link/link-helper.mjs.map +1 -0
  83. package/dist/common/link/link-types.d.mts +14 -0
  84. package/dist/common/link/link-types.d.mts.map +1 -0
  85. package/dist/common/link/link-types.mjs +2 -0
  86. package/dist/common/link/link-types.mjs.map +1 -0
  87. package/dist/common/other/graph-helper.d.mts +166 -0
  88. package/dist/common/other/graph-helper.d.mts.map +1 -0
  89. package/dist/common/other/graph-helper.mjs +710 -0
  90. package/dist/common/other/graph-helper.mjs.map +1 -0
  91. package/dist/common/other/ibgib-helper.d.mts +245 -0
  92. package/dist/common/other/ibgib-helper.d.mts.map +1 -0
  93. package/dist/common/other/ibgib-helper.mjs +641 -0
  94. package/dist/common/other/ibgib-helper.mjs.map +1 -0
  95. package/dist/common/other/other-constants.d.mts +53 -0
  96. package/dist/common/other/other-constants.d.mts.map +1 -0
  97. package/dist/common/other/other-constants.mjs +67 -0
  98. package/dist/common/other/other-constants.mjs.map +1 -0
  99. package/dist/common/other/other-types.d.mts +166 -0
  100. package/dist/common/other/other-types.d.mts.map +1 -0
  101. package/dist/common/other/other-types.mjs +30 -0
  102. package/dist/common/other/other-types.mjs.map +1 -0
  103. package/dist/common/other/svg-constants.d.mts +2 -0
  104. package/dist/common/other/svg-constants.d.mts.map +1 -0
  105. package/dist/common/other/svg-constants.mjs +2 -0
  106. package/dist/common/other/svg-constants.mjs.map +1 -0
  107. package/dist/common/other/svg-helper.d.mts +54 -0
  108. package/dist/common/other/svg-helper.d.mts.map +1 -0
  109. package/dist/common/other/svg-helper.mjs +170 -0
  110. package/dist/common/other/svg-helper.mjs.map +1 -0
  111. package/dist/common/pic/pic-constants.d.mts +13 -0
  112. package/dist/common/pic/pic-constants.d.mts.map +1 -0
  113. package/dist/common/pic/pic-constants.mjs +13 -0
  114. package/dist/common/pic/pic-constants.mjs.map +1 -0
  115. package/dist/common/pic/pic-helper.d.mts +70 -0
  116. package/dist/common/pic/pic-helper.d.mts.map +1 -0
  117. package/dist/common/pic/pic-helper.mjs +235 -0
  118. package/dist/common/pic/pic-helper.mjs.map +1 -0
  119. package/dist/common/pic/pic-types.d.mts +23 -0
  120. package/dist/common/pic/pic-types.d.mts.map +1 -0
  121. package/dist/common/pic/pic-types.mjs +2 -0
  122. package/dist/common/pic/pic-types.mjs.map +1 -0
  123. package/dist/common/root/root-constants.d.mts +40 -0
  124. package/dist/common/root/root-constants.d.mts.map +1 -0
  125. package/dist/common/root/root-constants.mjs +40 -0
  126. package/dist/common/root/root-constants.mjs.map +1 -0
  127. package/dist/common/root/root-types.d.mts +9 -0
  128. package/dist/common/root/root-types.d.mts.map +1 -0
  129. package/dist/common/root/root-types.mjs +2 -0
  130. package/dist/common/root/root-types.mjs.map +1 -0
  131. package/dist/common/tag/tag-constants.d.mts +21 -0
  132. package/dist/common/tag/tag-constants.d.mts.map +1 -0
  133. package/dist/common/tag/tag-constants.mjs +28 -0
  134. package/dist/common/tag/tag-constants.mjs.map +1 -0
  135. package/dist/common/tag/tag-types.d.mts +14 -0
  136. package/dist/common/tag/tag-types.d.mts.map +1 -0
  137. package/dist/common/tag/tag-types.mjs +2 -0
  138. package/dist/common/tag/tag-types.mjs.map +1 -0
  139. package/dist/core-constants.d.mts +89 -0
  140. package/dist/core-constants.d.mts.map +1 -0
  141. package/dist/core-constants.mjs +484 -0
  142. package/dist/core-constants.mjs.map +1 -0
  143. package/dist/core-helper.d.mts +6 -0
  144. package/dist/core-helper.d.mts.map +1 -0
  145. package/dist/core-helper.mjs +28 -0
  146. package/dist/core-helper.mjs.map +1 -0
  147. package/dist/core-types.d.mts +520 -0
  148. package/dist/core-types.d.mts.map +1 -0
  149. package/dist/core-types.mjs +2 -0
  150. package/dist/core-types.mjs.map +1 -0
  151. package/dist/index.d.mts +2 -0
  152. package/dist/index.d.mts.map +1 -0
  153. package/dist/index.mjs +3 -0
  154. package/dist/index.mjs.map +1 -0
  155. package/dist/witness/app/app-base-v1.d.mts +130 -0
  156. package/dist/witness/app/app-base-v1.d.mts.map +1 -0
  157. package/dist/witness/app/app-base-v1.mjs +462 -0
  158. package/dist/witness/app/app-base-v1.mjs.map +1 -0
  159. package/dist/witness/app/app-constants.d.mts +10 -0
  160. package/dist/witness/app/app-constants.d.mts.map +1 -0
  161. package/dist/witness/app/app-constants.mjs +13 -0
  162. package/dist/witness/app/app-constants.mjs.map +1 -0
  163. package/dist/witness/app/app-helper.d.mts +85 -0
  164. package/dist/witness/app/app-helper.d.mts.map +1 -0
  165. package/dist/witness/app/app-helper.mjs +258 -0
  166. package/dist/witness/app/app-helper.mjs.map +1 -0
  167. package/dist/witness/app/app-types.d.mts +211 -0
  168. package/dist/witness/app/app-types.d.mts.map +1 -0
  169. package/dist/witness/app/app-types.mjs +49 -0
  170. package/dist/witness/app/app-types.mjs.map +1 -0
  171. package/dist/witness/app/chat-app/chat-app-types.d.mts +18 -0
  172. package/dist/witness/app/chat-app/chat-app-types.d.mts.map +1 -0
  173. package/dist/witness/app/chat-app/chat-app-types.mjs +25 -0
  174. package/dist/witness/app/chat-app/chat-app-types.mjs.map +1 -0
  175. package/dist/witness/app/flash-app/flash-app-types.d.mts +16 -0
  176. package/dist/witness/app/flash-app/flash-app-types.d.mts.map +1 -0
  177. package/dist/witness/app/flash-app/flash-app-types.mjs +23 -0
  178. package/dist/witness/app/flash-app/flash-app-types.mjs.map +1 -0
  179. package/dist/witness/app/raw-app/raw-app-types.d.mts +18 -0
  180. package/dist/witness/app/raw-app/raw-app-types.d.mts.map +1 -0
  181. package/dist/witness/app/raw-app/raw-app-types.mjs +25 -0
  182. package/dist/witness/app/raw-app/raw-app-types.mjs.map +1 -0
  183. package/dist/witness/app/todo-app/todo-app-types.d.ts +33 -0
  184. package/dist/witness/app/todo-app/todo-app-types.d.ts.map +1 -0
  185. package/dist/witness/app/todo-app/todo-app-types.js +31 -0
  186. package/dist/witness/app/todo-app/todo-app-types.js.map +1 -0
  187. package/dist/witness/robbot/robbot-base-v1.d.ts +432 -0
  188. package/dist/witness/robbot/robbot-base-v1.d.ts.map +1 -0
  189. package/dist/witness/robbot/robbot-base-v1.js +1407 -0
  190. package/dist/witness/robbot/robbot-base-v1.js.map +1 -0
  191. package/dist/witness/robbot/robbot-constants.d.mts +24 -0
  192. package/dist/witness/robbot/robbot-constants.d.mts.map +1 -0
  193. package/dist/witness/robbot/robbot-constants.mjs +24 -0
  194. package/dist/witness/robbot/robbot-constants.mjs.map +1 -0
  195. package/dist/witness/robbot/robbot-helper.d.mts +152 -0
  196. package/dist/witness/robbot/robbot-helper.d.mts.map +1 -0
  197. package/dist/witness/robbot/robbot-helper.mjs +609 -0
  198. package/dist/witness/robbot/robbot-helper.mjs.map +1 -0
  199. package/dist/witness/robbot/robbot-types.d.mts +539 -0
  200. package/dist/witness/robbot/robbot-types.d.mts.map +1 -0
  201. package/dist/witness/robbot/robbot-types.mjs +294 -0
  202. package/dist/witness/robbot/robbot-types.mjs.map +1 -0
  203. package/dist/witness/space/bootstrap/bootstrap-constants.d.mts +14 -0
  204. package/dist/witness/space/bootstrap/bootstrap-constants.d.mts.map +1 -0
  205. package/dist/witness/space/bootstrap/bootstrap-constants.mjs +15 -0
  206. package/dist/witness/space/bootstrap/bootstrap-constants.mjs.map +1 -0
  207. package/dist/witness/space/inner-space-v1.d.ts +63 -0
  208. package/dist/witness/space/inner-space-v1.d.ts.map +1 -0
  209. package/dist/witness/space/inner-space-v1.js +356 -0
  210. package/dist/witness/space/inner-space-v1.js.map +1 -0
  211. package/dist/witness/space/outer-space/outer-space-constants.d.mts +2 -0
  212. package/dist/witness/space/outer-space/outer-space-constants.d.mts.map +1 -0
  213. package/dist/witness/space/outer-space/outer-space-constants.mjs +2 -0
  214. package/dist/witness/space/outer-space/outer-space-constants.mjs.map +1 -0
  215. package/dist/witness/space/outer-space/outer-space-helper.d.mts +28 -0
  216. package/dist/witness/space/outer-space/outer-space-helper.d.mts.map +1 -0
  217. package/dist/witness/space/outer-space/outer-space-helper.mjs +87 -0
  218. package/dist/witness/space/outer-space/outer-space-helper.mjs.map +1 -0
  219. package/dist/witness/space/outer-space/outer-space-types.d.mts +548 -0
  220. package/dist/witness/space/outer-space/outer-space-types.d.mts.map +1 -0
  221. package/dist/witness/space/outer-space/outer-space-types.mjs +118 -0
  222. package/dist/witness/space/outer-space/outer-space-types.mjs.map +1 -0
  223. package/dist/witness/space/space-base-v1.d.mts +147 -0
  224. package/dist/witness/space/space-base-v1.d.mts.map +1 -0
  225. package/dist/witness/space/space-base-v1.mjs +350 -0
  226. package/dist/witness/space/space-base-v1.mjs.map +1 -0
  227. package/dist/witness/space/space-constants.d.mts +181 -0
  228. package/dist/witness/space/space-constants.d.mts.map +1 -0
  229. package/dist/witness/space/space-constants.mjs +192 -0
  230. package/dist/witness/space/space-constants.mjs.map +1 -0
  231. package/dist/witness/space/space-helper.d.mts +666 -0
  232. package/dist/witness/space/space-helper.d.mts.map +1 -0
  233. package/dist/witness/space/space-helper.mjs +2830 -0
  234. package/dist/witness/space/space-helper.mjs.map +1 -0
  235. package/dist/witness/space/space-types.d.mts +422 -0
  236. package/dist/witness/space/space-types.d.mts.map +1 -0
  237. package/dist/witness/space/space-types.mjs +52 -0
  238. package/dist/witness/space/space-types.mjs.map +1 -0
  239. package/dist/witness/witness-base-v1.d.ts +144 -0
  240. package/dist/witness/witness-base-v1.d.ts.map +1 -0
  241. package/dist/witness/witness-base-v1.js +300 -0
  242. package/dist/witness/witness-base-v1.js.map +1 -0
  243. package/dist/witness/witness-constants.d.mts +3 -0
  244. package/dist/witness/witness-constants.d.mts.map +1 -0
  245. package/dist/witness/witness-constants.mjs +3 -0
  246. package/dist/witness/witness-constants.mjs.map +1 -0
  247. package/dist/witness/witness-form-builder.d.mts +45 -0
  248. package/dist/witness/witness-form-builder.d.mts.map +1 -0
  249. package/dist/witness/witness-form-builder.mjs +95 -0
  250. package/dist/witness/witness-form-builder.mjs.map +1 -0
  251. package/dist/witness/witness-helper.d.mts +89 -0
  252. package/dist/witness/witness-helper.d.mts.map +1 -0
  253. package/dist/witness/witness-helper.mjs +229 -0
  254. package/dist/witness/witness-helper.mjs.map +1 -0
  255. package/dist/witness/witness-types.d.mts +211 -0
  256. package/dist/witness/witness-types.d.mts.map +1 -0
  257. package/dist/witness/witness-types.mjs +2 -0
  258. package/dist/witness/witness-types.mjs.map +1 -0
  259. package/jasmine-browser.json +18 -0
  260. package/jasmine.json +6 -0
  261. package/package.json +67 -0
  262. package/src/assumptions.spec.mts +45 -0
  263. package/src/common/aws-constants.mts +5 -0
  264. package/src/common/bin/bin-types.mts +17 -0
  265. package/src/common/cache/cache-types.mts +53 -0
  266. package/src/common/comment/comment-constants.mts +10 -0
  267. package/src/common/comment/comment-helper.mts +211 -0
  268. package/src/common/comment/comment-types.mts +19 -0
  269. package/src/common/display/display-helper.mts +88 -0
  270. package/src/common/display/display-types.mts +108 -0
  271. package/src/common/encrypt/encrypt-constants.mts +28 -0
  272. package/src/common/encrypt/encrypt-types.mts +130 -0
  273. package/src/common/error/error-constants.mts +8 -0
  274. package/src/common/error/error-helper.mts +155 -0
  275. package/src/common/error/error-types.mts +62 -0
  276. package/src/common/form/form-helper.mts +253 -0
  277. package/src/common/form/form-items.mts +236 -0
  278. package/src/common/import-export/import-export-types.mts +18 -0
  279. package/src/common/legacy/about-legacy.md +0 -0
  280. package/src/common/legacy/legacy-types.mts +0 -0
  281. package/src/common/link/link-constants.mts +1 -0
  282. package/src/common/link/link-helper.mts +155 -0
  283. package/src/common/link/link-types.mts +16 -0
  284. package/src/common/other/graph-helper.mts +853 -0
  285. package/src/common/other/ibgib-helper.mts +671 -0
  286. package/src/common/other/other-constants.mts +76 -0
  287. package/src/common/other/other-types.mts +186 -0
  288. package/src/common/other/svg-constants.mts +1 -0
  289. package/src/common/other/svg-helper.mts +238 -0
  290. package/src/common/pic/pic-constants.mts +13 -0
  291. package/src/common/pic/pic-helper.mts +295 -0
  292. package/src/common/pic/pic-types.mts +29 -0
  293. package/src/common/root/root-constants.mts +41 -0
  294. package/src/common/root/root-types.mts +8 -0
  295. package/src/common/tag/tag-constants.mts +34 -0
  296. package/src/common/tag/tag-types.mts +19 -0
  297. package/src/core-constants.mts +506 -0
  298. package/src/core-helper.mts +33 -0
  299. package/src/core-types.mts +519 -0
  300. package/src/helper.spec.mts +64 -0
  301. package/src/index.mts +1 -0
  302. package/src/witness/app/app-base-v1.mts +584 -0
  303. package/src/witness/app/app-constants.mts +16 -0
  304. package/src/witness/app/app-helper.mts +322 -0
  305. package/src/witness/app/app-types.mts +252 -0
  306. package/src/witness/app/chat-app/chat-app-types.mts +40 -0
  307. package/src/witness/app/flash-app/flash-app-types.mts +38 -0
  308. package/src/witness/app/raw-app/raw-app-types.mts +40 -0
  309. package/src/witness/app/todo-app/todo-app-types.ts +59 -0
  310. package/src/witness/robbot/robbot-base-v1.ts +1531 -0
  311. package/src/witness/robbot/robbot-constants.mts +25 -0
  312. package/src/witness/robbot/robbot-helper.mts +676 -0
  313. package/src/witness/robbot/robbot-helper.spec.mts +135 -0
  314. package/src/witness/robbot/robbot-types.mts +797 -0
  315. package/src/witness/space/bootstrap/bootstrap-constants.mts +15 -0
  316. package/src/witness/space/inner-space-v1.ts +372 -0
  317. package/src/witness/space/outer-space/outer-space-constants.mts +1 -0
  318. package/src/witness/space/outer-space/outer-space-helper.mts +91 -0
  319. package/src/witness/space/outer-space/outer-space-types.mts +627 -0
  320. package/src/witness/space/space-base-v1.mts +414 -0
  321. package/src/witness/space/space-constants.mts +208 -0
  322. package/src/witness/space/space-helper.mts +3242 -0
  323. package/src/witness/space/space-types.mts +476 -0
  324. package/src/witness/witness-base-v1.ts +325 -0
  325. package/src/witness/witness-constants.mts +2 -0
  326. package/src/witness/witness-form-builder.mts +128 -0
  327. package/src/witness/witness-helper.mts +256 -0
  328. package/src/witness/witness-types.mts +249 -0
  329. package/tsconfig.json +15 -0
  330. package/tsconfig.test.json +10 -0
@@ -0,0 +1,130 @@
1
+ import { IbGibRel8ns_V1, IbGib_V1 } from '@ibgib/ts-gib/dist/V1/index.mjs';
2
+ import { IbGibAddr, } from '@ibgib/ts-gib';
3
+ import { HashAlgorithm } from '@ibgib/helper-gib';
4
+ import { SaltStrategy } from '@ibgib/encrypt-gib';
5
+ import { ENCRYPTION_REL8N_NAME } from './encrypt-constants.mjs';
6
+
7
+
8
+ export type SecretType = "password";
9
+ export const SecretType = {
10
+ password: 'password' as SecretType,
11
+ }
12
+ export const VALID_SECRET_TYPES = Object.values(SecretType).concat();
13
+
14
+ export interface SecretInfo {
15
+ name: string;
16
+ description?: string;
17
+ expirationUTC: string;
18
+ type: SecretType;
19
+ }
20
+
21
+ export interface SecretInfo_Password extends SecretInfo {
22
+ type: 'password';
23
+ /**
24
+ * We won't save the entire hash, just the hash.slice(16),
25
+ * because we are not checking to give authority, we are
26
+ * just checking to see if the user entered the same
27
+ * password for their own check.
28
+ *
29
+ * ## warnings
30
+ * NOTHING giving actual authorization should look at this.
31
+ */
32
+ hash16816_SHA256: string;
33
+ /**
34
+ * Public hint to help you remember your secret (or help the bad person
35
+ * attack your secret).
36
+ */
37
+ hint?: string;
38
+ }
39
+ export type SecretData_V1 = SecretInfo; // extend this with logical OR later
40
+
41
+ export interface SecretRel8ns_V1 extends IbGibRel8ns_V1 {
42
+ }
43
+
44
+ export interface SecretIbGib_V1 extends IbGib_V1<SecretData_V1, SecretRel8ns_V1> {
45
+ }
46
+
47
+ export interface EncryptionInfo {
48
+ name: string;
49
+ description?: string;
50
+ method: EncryptionMethod;
51
+ }
52
+
53
+ export type EncryptionMethod = 'encrypt-gib (weak)';
54
+ export const EncryptionMethod = {
55
+ encrypt_gib_weak: 'encrypt-gib (weak)' as EncryptionMethod,
56
+ }
57
+
58
+ export interface EncryptionInfo {
59
+ method: EncryptionMethod,
60
+ }
61
+
62
+ export interface EncryptionInfo_EncryptGib extends EncryptionInfo {
63
+ method: 'encrypt-gib (weak)'
64
+ /**
65
+ * This is the algorithm that encrypt-gib will use in its
66
+ * internal hashing round function to encrypt the data.
67
+ */
68
+ hashAlgorithm: HashAlgorithm;
69
+ /**
70
+ * This is an initial number of recursions to perform to "get farther away"
71
+ * from the password. It is a one-time cost at the beginning of the
72
+ * entire encryption process, so it does not cost more with more data.
73
+ */
74
+ initialRecursions: number;
75
+ /**
76
+ * This is the number of internal hashes per round function, which is per
77
+ * hex character of data. So the more recursions here, the longer it is
78
+ * going to take to encrypt/decrypt.
79
+ */
80
+ recursionsPerHash?: number;
81
+ /**
82
+ * Salt used throughout hashing in encryption/decryption. The longer and
83
+ * more random, the better for security. But there is also a resource cost.
84
+ */
85
+ salt: string;
86
+ /**
87
+ * Stronger are the perHash options.
88
+ *
89
+ * 'prependPerHash' | 'appendPerHash' | 'initialPrepend' | 'initialAppend';
90
+ */
91
+ saltStrategy?: SaltStrategy;
92
+ /**
93
+ * The encrypted data is a delimited list of indices.
94
+ *
95
+ * @default "," (comma-delimited)
96
+ */
97
+ encryptedDataDelimiter?: string;
98
+ }
99
+
100
+ export type EncryptionData_V1 = EncryptionInfo_EncryptGib; // extend this with logical OR later
101
+
102
+ export interface EncryptionRel8ns_V1 extends IbGibRel8ns_V1 { }
103
+
104
+ /**
105
+ * IbGib that represents encryption settings
106
+ */
107
+ export interface EncryptionIbGib extends IbGib_V1<EncryptionData_V1, EncryptionRel8ns_V1> { }
108
+
109
+ /**
110
+ * Data for the actual encrypted ciphertext.
111
+ */
112
+ export interface CiphertextData<TMetadata = any> {
113
+ ciphertext?: string;
114
+ metadata?: TMetadata;
115
+ }
116
+
117
+ /**
118
+ * Rel8ns for the actual encrypted ciphertext
119
+ */
120
+ export interface CiphertextRel8ns extends IbGibRel8ns_V1 {
121
+ [ENCRYPTION_REL8N_NAME]?: IbGibAddr[];
122
+ }
123
+
124
+ /**
125
+ * Ibgib for the actual encrypted content, as opposed to the
126
+ * encryption secret (password) or encryption method/algorithm.
127
+ */
128
+ export interface CiphertextIbGib_V1<TMetadata = any>
129
+ extends IbGib_V1<CiphertextData<TMetadata>, CiphertextRel8ns> {
130
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Used in ErrorIbGib_V1.ib
3
+ */
4
+ export const DEFAULT_ERROR_MSG_IB_SUBSTRING_LENGTH = 20;
5
+ /**
6
+ * regexp for an error ibgib's (ErrorIbGib_V1) ib property.
7
+ */
8
+ export const ERROR_IB_REGEXP = /^error (\w+) ([a-fA-F\d]{32}|undefined)$/;
@@ -0,0 +1,155 @@
1
+ import { Ib } from '@ibgib/ts-gib';
2
+ import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/index.mjs';
3
+
4
+ import { GLOBAL_LOG_A_LOT } from '../../core-constants.mjs';
5
+ import { ErrorData_V1, ErrorIbGib_V1, ErrorRel8ns_V1 } from './error-types.mjs';
6
+ import { constantIbGib } from '../other/ibgib-helper.mjs';
7
+ import { DEFAULT_ERROR_MSG_IB_SUBSTRING_LENGTH, ERROR_IB_REGEXP } from './error-constants.mjs';
8
+ import { ERROR_MSG_LOCATION_ONLY_REGEXP, ERROR_MSG_WITH_ID_CAPTURE_GROUPS_REGEXP } from '@ibgib/helper-gib';
9
+
10
+
11
+ const logalot = GLOBAL_LOG_A_LOT || false;
12
+
13
+ /**
14
+ * Generates an ib based on a raw error msg.
15
+ *
16
+ * ## future
17
+ *
18
+ * If this is changed in the future, then without versioning of some sort, this
19
+ * will change the error constant ibgibs that rely on this functions
20
+ * deterministic qualities.
21
+ *
22
+ * @returns the error's `ib`
23
+ */
24
+ export function getErrorIb({
25
+ rawMsg,
26
+ }: {
27
+ rawMsg: string,
28
+ }): Ib {
29
+ const lc = `[${getErrorIb.name}]`;
30
+ try {
31
+ if (logalot) { console.log(`${lc} starting...`); }
32
+ const parsed = parseRawErrorMsg({ rawMsg });
33
+ const saferText = parsed.body.replace(/\s/g, '_').replace(/\W/g, '');
34
+ let msgSlice: string;
35
+ if (saferText.length > DEFAULT_ERROR_MSG_IB_SUBSTRING_LENGTH) {
36
+ msgSlice =
37
+ saferText.substring(0, DEFAULT_ERROR_MSG_IB_SUBSTRING_LENGTH);
38
+ } else if (saferText.length > 0) {
39
+ msgSlice = saferText;
40
+ } else {
41
+ // msg only has characters/nonalphanumerics ?
42
+ throw new Error(`(UNEXPECTED) error msg should have characters/alphanumerics... (E: a3b9cd11a44cc7892a748819c2885422)`);
43
+ }
44
+
45
+ return `error ${msgSlice} ${parsed.uuid ?? 'undefined'}`;
46
+ } catch (error) {
47
+ console.error(`${lc} ${error.message}`);
48
+ throw error;
49
+ } finally {
50
+ if (logalot) { console.log(`${lc} complete.`); }
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Parses a raw error/exception message.
56
+ *
57
+ * If it has sections that I personally use (usually), then it will break that
58
+ * out. otherwise, it will just have the `rawMsg` as the msg body and raw msg.
59
+ *
60
+ * @see {@link ErrorData_V1}
61
+ */
62
+ export function parseRawErrorMsg({
63
+ rawMsg,
64
+ }: {
65
+ rawMsg: string,
66
+ }): ErrorData_V1 {
67
+ const lc = `[${parseRawErrorMsg.name}]`;
68
+ try {
69
+ if (logalot) { console.log(`${lc} starting...`); }
70
+ if (!rawMsg) { throw new Error(`(UNEXPECTED) rawMsg required (E: e5bd3b433a1781ebe885534cd2495622)`); }
71
+
72
+ let data: ErrorData_V1;
73
+ let regexResult = rawMsg.match(ERROR_MSG_WITH_ID_CAPTURE_GROUPS_REGEXP);
74
+ if (regexResult) {
75
+ // has id section
76
+ const [_, location, unexpectedAtStart, body, idSection, unexpectedAtEnd] = regexResult;
77
+ if (!body) { throw new Error(`invalid error msg body (E: a675e6855cca96519d33d44ea5400922)`); }
78
+ data = {
79
+ success: false,
80
+ raw: rawMsg,
81
+ body: body?.trim(),
82
+ uuid: idSection.slice(4, 36),
83
+ };
84
+ if (location) { data.location = location; }
85
+ if (unexpectedAtStart || unexpectedAtEnd) { data.unexpected = true; }
86
+ } else {
87
+ // no id or unexpected regex (maybe changed?)
88
+ data = {
89
+ success: false,
90
+ raw: rawMsg,
91
+ body: rawMsg,
92
+ };
93
+ let regexResultLocation = rawMsg.match(ERROR_MSG_LOCATION_ONLY_REGEXP);
94
+ if (regexResultLocation) {
95
+ const [_, location] = regexResultLocation;
96
+ data.location = location;
97
+ }
98
+ if (rawMsg.toLowerCase().includes(`(unexpected)`)) {
99
+ data.unexpected = true;
100
+ }
101
+ }
102
+
103
+ return data;
104
+ } catch (error) {
105
+ console.error(`${lc} ${error.message}`);
106
+ throw error;
107
+ } finally {
108
+ if (logalot) { console.log(`${lc} complete.`); }
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Builds a "constant" error ibgib based on the given `rawMsg`.
114
+ *
115
+ * @returns constant error ibgib built from given `rawMsg`
116
+ *
117
+ * @see {@link ErrorData_V1}
118
+ * @see {@link ErrorIbGib_V1}
119
+ */
120
+ export function errorIbGib({ rawMsg }: { rawMsg: string }): Promise<ErrorIbGib_V1> {
121
+ const lc = `[${errorIbGib.name}]`;
122
+ try {
123
+ if (logalot) { console.log(`${lc} starting...`); }
124
+
125
+ return constantIbGib<ErrorData_V1, ErrorRel8ns_V1>({
126
+ parentPrimitiveIb: 'error',
127
+ ib: getErrorIb({ rawMsg }),
128
+ data: parseRawErrorMsg({ rawMsg }),
129
+ ibRegExpPattern: ERROR_IB_REGEXP.source,
130
+ });
131
+ } catch (error) {
132
+ console.error(`${lc} ${error.message}`);
133
+ throw error;
134
+ } finally {
135
+ if (logalot) { console.log(`${lc} complete.`); }
136
+ }
137
+ }
138
+
139
+ export function isError({
140
+ ibGib
141
+ }: {
142
+ ibGib: IbGib_V1
143
+ }): boolean {
144
+ const lc = `[${isError.name}]`;
145
+ try {
146
+ if (logalot) { console.log(`${lc} starting...`); }
147
+ if (!ibGib) { throw new Error(`ibGib required (E: 1d756fbbd96f1734b97ba013537ed522)`); }
148
+ return ibGib.ib.startsWith('error ');
149
+ } catch (error) {
150
+ console.error(`${lc} ${error.message}`);
151
+ throw error;
152
+ } finally {
153
+ if (logalot) { console.log(`${lc} complete.`); }
154
+ }
155
+ }
@@ -0,0 +1,62 @@
1
+ import { IbGibRel8ns_V1, IbGib_V1 } from '@ibgib/ts-gib/dist/V1/index.mjs';
2
+
3
+ /**
4
+ * I format my errors nowadays usually using an id and a possible (unexpected) flag.
5
+ * Sometimes I put the unexpected flag at the beginning, sometimes at the end.
6
+ */
7
+ export interface ErrorData_V1 {
8
+ /**
9
+ * raw error message
10
+ */
11
+ raw: string;
12
+ /**
13
+ * I usually have lc's (log contexts) all over my code, if that isn't obvious or
14
+ * if you're not looking at the code. Anyway, I prepend error/info/warning msgs
15
+ * with the location like this:
16
+ *
17
+ * ```
18
+ * [MyClass][Foo] some error (E: hash123)
19
+ * ```
20
+ *
21
+ * So the bits in the brackets are the location. In this case, it's
22
+ * `[MyClass][Foo]` meaning in the function `Foo` on the class `MyClass`.
23
+ */
24
+ location?: string;
25
+ /**
26
+ * error message sans any metadata
27
+ */
28
+ body: string;
29
+ /**
30
+ * if the error is thrown more of an assertion, and it's an edge case just
31
+ * weird error, then I often add `"(UNEXPECTED)"` to the msg. This flag
32
+ * indicates that.
33
+ */
34
+ unexpected?: boolean;
35
+ /**
36
+ * I often include error ids.
37
+ */
38
+ uuid?: string;
39
+ /**
40
+ * All errors should have `errorIbGib.data.success` = false
41
+ */
42
+ success: false;
43
+ }
44
+
45
+ export interface ErrorRel8ns_V1 extends IbGibRel8ns_V1 {
46
+
47
+ }
48
+
49
+ /**
50
+ * Encapsulates data on errors that are thrown in this code base.
51
+ *
52
+ * ## driving intent
53
+ *
54
+ * I'm creating this for error constant ibgibs when I want to wrap an error
55
+ * message in an ibgib for whatever reason.
56
+ *
57
+ * Specifically I'm working on the random robbot and want the ability to return an error
58
+ * or add an error to a context ibgib.
59
+ */
60
+ export interface ErrorIbGib_V1 extends IbGib_V1<ErrorData_V1, ErrorRel8ns_V1> {
61
+
62
+ }
@@ -0,0 +1,253 @@
1
+
2
+ import { getRegExp, UUID_REGEXP } from '@ibgib/helper-gib';
3
+ // import { DynamicForm, FormItemInfo } from '../../ibgib-forms/types/form-items';
4
+ import { GLOBAL_LOG_A_LOT, SAFE_SPECIAL_CHARS } from '../../core-constants.mjs';
5
+ import { DynamicForm, FormItemInfo } from './form-items.mjs';
6
+ // import { getRegExp } from './utils';
7
+
8
+ const logalot = GLOBAL_LOG_A_LOT || false;
9
+
10
+ /**
11
+ * Fluent-style builder helper class.
12
+ *
13
+ * I'm making this to share common fields' settings among witness classes.
14
+ *
15
+ * Descend from this class for sharing other commonalities.
16
+ */
17
+ export class DynamicFormBuilder {
18
+ protected lc: string = `[${DynamicFormBuilder.name}]`;
19
+ protected items: FormItemInfo[] = [];
20
+ protected what: string = '';
21
+ /**
22
+ * pool of uuids pre-calculated to be passed in to the builder. if this is
23
+ * falsy, then it will use a Math.random() based approach.
24
+ */
25
+ protected idPool: string[] = [];
26
+
27
+ /**
28
+ * hacky wrapper for this.idPool.pop()
29
+ */
30
+ protected getNewId(): string {
31
+ const lc = `${this.lc}[${this.getNewId.name}]`;
32
+ if (this.idPool?.length > 0) {
33
+ return this.idPool.pop() ?? '';
34
+ } else {
35
+ // weak implementation...
36
+ let resultArray: string[] = [];
37
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
38
+ const charLength = chars.length;
39
+ for (let i = 0; i < 32; i++) {
40
+ let charIndex = Math.floor(Math.random() * charLength);
41
+ resultArray.push(chars[charIndex]);
42
+ }
43
+ let id = resultArray.join('');
44
+ if (logalot) { console.log(`${lc} id: ${id} (I: c6591ffee6d5bbea79ed19cfa6630422)`); }
45
+ return id;
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Start fluent calls with this.
51
+ */
52
+ forA({
53
+ what,
54
+ }: {
55
+ /**
56
+ * Common name for the reified concrete type of the witness.
57
+ *
58
+ * Used in things like placeholders, descriptions, etc.
59
+ *
60
+ * @example "robbot" or "space"
61
+ */
62
+ what: string,
63
+ }): DynamicFormBuilder {
64
+ this.what = what || 'thingy';
65
+ return this;
66
+ }
67
+
68
+ protected addItem(item: FormItemInfo) {
69
+ if (!item.uuid) { item.uuid = this.getNewId(); }
70
+ this.items.push(item);
71
+ }
72
+
73
+ /**
74
+ * Empty function simply for more natural looking fluent syntax.
75
+ *
76
+ * You can override this for custom form builders that descend from this
77
+ * class.
78
+ *
79
+ * @returns this
80
+ */
81
+ with<T extends DynamicFormBuilder>({
82
+ idPool,
83
+ }: {
84
+ /**
85
+ * pre-built pool of uuids to draw from. this builder
86
+ * will mutate this array.
87
+ */
88
+ idPool?: string[],
89
+ }): T {
90
+ if (idPool) { this.idPool = idPool; }
91
+ return this as any as T;
92
+ }
93
+
94
+ /**
95
+ * I'm not a great fluent builder writer for TypeScript,
96
+ * and this function acts as a caster for which members of
97
+ * which concrete classes to expose for the proceeding builder lines.
98
+ *
99
+ *
100
+ * Basically, you use this to typecast the builder, possibly redundantly since
101
+ * I don't have any ordering implemented atow.
102
+ *
103
+ * @returns typecasted fluent builder
104
+ */
105
+ and<T extends DynamicFormBuilder>(): T { return this as any as T; }
106
+
107
+ name<T extends DynamicFormBuilder>({
108
+ of: value,
109
+ required = true,
110
+ }: {
111
+ of: string,
112
+ required?: boolean,
113
+ }): T {
114
+ this.addItem({
115
+ // witness.data.name
116
+ name: "name",
117
+ description: `What to call this ${this.what}. Doesn't have to be unique, no spaces, up to 32 alphanumerics/underscores in length.`,
118
+ label: "Name",
119
+ placeholder: `e.g. "bob_the_cool"`,
120
+ regexp: getRegExp({ min: 1, max: 32, noSpaces: true }),
121
+ regexpErrorMsg: '1 to 32 characters, no spaces, underscores allowed.',
122
+ required,
123
+ dataType: 'text',
124
+ value,
125
+ });
126
+ return this as any as T;
127
+ }
128
+
129
+ description({
130
+ of: value,
131
+ required,
132
+ defaultValue,
133
+ }: {
134
+ of: string,
135
+ required?: boolean,
136
+ defaultValue?: string,
137
+ }): DynamicFormBuilder {
138
+ this.addItem({
139
+ // witness.data.description
140
+ name: "description",
141
+ description: `Description/notes for this ${this.what}.`,
142
+ label: "Description",
143
+ placeholder: `Describe these ${this.what} settings here...`,
144
+ regexp: getRegExp({ min: 0, max: 155, chars: SAFE_SPECIAL_CHARS }),
145
+ regexpErrorMsg: `0 to 155 alphanumerics or any of ${SAFE_SPECIAL_CHARS}`,
146
+ // regexpSource: getRegExp({min: 0, max: 155, chars: SAFE_SPECIAL_CHARS}).source,
147
+ dataType: 'textarea',
148
+ required,
149
+ defaultValue,
150
+ value,
151
+ });
152
+ return this;
153
+ }
154
+
155
+ classname({
156
+ of,
157
+ required = true,
158
+ }: {
159
+ of: string,
160
+ required?: boolean,
161
+ }): DynamicFormBuilder {
162
+ this.addItem({
163
+ // witness.data.classname
164
+ name: "classname",
165
+ description: `Technical setting that is the name of the ${this.what}'s class in computer code.`,
166
+ label: "Classname",
167
+ regexp: getRegExp({ min: 1, max: 128, noSpaces: true }),
168
+ regexpErrorMsg: `1 to 128 alphanumerics or underscores without spaces`,
169
+ // regexpSource: getRegExp({min: 1, max: 128, noSpaces: true}).source,
170
+ dataType: 'text',
171
+ value: of,
172
+ readonly: true,
173
+ required,
174
+ });
175
+ return this;
176
+ }
177
+
178
+ uuid({
179
+ of,
180
+ label,
181
+ required,
182
+ }: {
183
+ of: string,
184
+ label?: string,
185
+ required?: boolean,
186
+ }): DynamicFormBuilder {
187
+ this.addItem({
188
+ // witness.data.uuid
189
+ name: "uuid",
190
+ description: `Unique(ish) id of the ${this.what}.`,
191
+ label: label ?? "ID",
192
+ dataType: 'text',
193
+ value: of,
194
+ regexp: UUID_REGEXP,
195
+ regexpErrorMsg: '1 to 256 alphanumerics, underscores, dots, hyphens allowed.',
196
+ readonly: true,
197
+ required,
198
+ });
199
+ return this;
200
+ }
201
+
202
+ version({
203
+ of,
204
+ required,
205
+ }: {
206
+ of: string | undefined,
207
+ required?: boolean,
208
+ }): DynamicFormBuilder {
209
+ this.addItem({
210
+ // witness.data.version
211
+ name: "version",
212
+ description: `Technical setting indicating the version of the ${this.what}.`,
213
+ label: "Version",
214
+ dataType: 'text',
215
+ value: of || '',
216
+ readonly: true,
217
+ required,
218
+ });
219
+ return this;
220
+ }
221
+
222
+ /**
223
+ * To pass in a completely customized item info.
224
+ *
225
+ * @returns `this` for fluent builder
226
+ */
227
+ customItem(item: FormItemInfo): DynamicFormBuilder {
228
+ this.addItem(item);
229
+ return this;
230
+ }
231
+
232
+
233
+ outputItems(): FormItemInfo[] {
234
+ return this.items;
235
+ }
236
+
237
+ outputForm({
238
+ formName,
239
+ label,
240
+ }: {
241
+ formName: string,
242
+ label?: string,
243
+ }): DynamicForm {
244
+ return {
245
+ name: formName,
246
+ // description: this.description ?? `This is a form for a ${this.what}`,
247
+ description: `This is a form for a ${this.what}`,
248
+ label: label ?? this.what,
249
+ items: this.items,
250
+ } as DynamicForm;
251
+ }
252
+ }
253
+