@ternent/core 0.0.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 (313) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/config.json +17 -0
  3. package/.github/workflows/deploy-armour.yml +42 -0
  4. package/.github/workflows/deploy-identity.yml +42 -0
  5. package/.github/workflows/deploy-seal.yml +42 -0
  6. package/.github/workflows/deploy-ui.yml +42 -0
  7. package/.github/workflows/deploy-utils.yml +42 -0
  8. package/.github/workflows/release-create.yml +59 -0
  9. package/.github/workflows/release-publish.yml +54 -0
  10. package/.nvmrc +1 -0
  11. package/.ops/publish.mjs +31 -0
  12. package/package.json +16 -0
  13. package/packages/README.md +0 -0
  14. package/packages/armour/CHANGELOG.md +66 -0
  15. package/packages/armour/CLAUDE.md +8 -0
  16. package/packages/armour/README.md +103 -0
  17. package/packages/armour/SPEC.md +92 -0
  18. package/packages/armour/package.json +45 -0
  19. package/packages/armour/src/constants.ts +5 -0
  20. package/packages/armour/src/deps.d.ts +56 -0
  21. package/packages/armour/src/errors.ts +172 -0
  22. package/packages/armour/src/files.ts +73 -0
  23. package/packages/armour/src/identity.ts +72 -0
  24. package/packages/armour/src/index.ts +56 -0
  25. package/packages/armour/src/init.ts +10 -0
  26. package/packages/armour/src/passphrase.ts +33 -0
  27. package/packages/armour/src/recipients.ts +73 -0
  28. package/packages/armour/src/text.ts +68 -0
  29. package/packages/armour/src/types.ts +93 -0
  30. package/packages/armour/test/armour.test.ts +270 -0
  31. package/packages/armour/tsconfig.build.json +12 -0
  32. package/packages/armour/tsconfig.json +12 -0
  33. package/packages/armour/vite.config.ts +29 -0
  34. package/packages/concord/CHANGELOG.md +83 -0
  35. package/packages/concord/CLAUDE.md +9 -0
  36. package/packages/concord/README.md +146 -0
  37. package/packages/concord/SPEC.md +287 -0
  38. package/packages/concord/package.json +51 -0
  39. package/packages/concord/src/app.ts +717 -0
  40. package/packages/concord/src/errors.ts +9 -0
  41. package/packages/concord/src/index.ts +20 -0
  42. package/packages/concord/src/types.ts +127 -0
  43. package/packages/concord/test/concord.test.ts +978 -0
  44. package/packages/concord/tsconfig.json +12 -0
  45. package/packages/concord/vite.browser.config.ts +27 -0
  46. package/packages/concord/vite.config.ts +35 -0
  47. package/packages/concord/vite.config.ts.timestamp-1774262297922-ffd76e35ea668.mjs +83 -0
  48. package/packages/identity/CHANGELOG.md +47 -0
  49. package/packages/identity/README.md +236 -0
  50. package/packages/identity/package.json +41 -0
  51. package/packages/identity/src/index.ts +538 -0
  52. package/packages/identity/test/identity.test.ts +172 -0
  53. package/packages/identity/tsconfig.build.json +12 -0
  54. package/packages/identity/vite.config.ts +17 -0
  55. package/packages/ledger/CHANGELOG.md +69 -0
  56. package/packages/ledger/CLAUDE.md +9 -0
  57. package/packages/ledger/SPEC.md +304 -0
  58. package/packages/ledger/package.json +48 -0
  59. package/packages/ledger/src/index.ts +2 -0
  60. package/packages/ledger/src/ledger.ts +1286 -0
  61. package/packages/ledger/src/seal-cli.d.ts +25 -0
  62. package/packages/ledger/src/types.ts +294 -0
  63. package/packages/ledger/test/ledger.test.ts +838 -0
  64. package/packages/ledger/tsconfig.json +12 -0
  65. package/packages/ledger/vite.browser.config.ts +27 -0
  66. package/packages/ledger/vite.config.ts +39 -0
  67. package/packages/seal/CHANGELOG.md +137 -0
  68. package/packages/seal/CLAUDE.md +8 -0
  69. package/packages/seal/README.md +258 -0
  70. package/packages/seal/bin/seal +6 -0
  71. package/packages/seal/package.json +59 -0
  72. package/packages/seal/src/artifact.ts +380 -0
  73. package/packages/seal/src/cli.ts +372 -0
  74. package/packages/seal/src/commands/identity.ts +52 -0
  75. package/packages/seal/src/commands/manifest.ts +71 -0
  76. package/packages/seal/src/commands/publicKey.ts +7 -0
  77. package/packages/seal/src/commands/sign.ts +56 -0
  78. package/packages/seal/src/commands/verify.ts +54 -0
  79. package/packages/seal/src/crypto.ts +85 -0
  80. package/packages/seal/src/errors.ts +88 -0
  81. package/packages/seal/src/index.ts +5 -0
  82. package/packages/seal/src/manifest.ts +114 -0
  83. package/packages/seal/src/node.ts +18 -0
  84. package/packages/seal/src/proof.ts +344 -0
  85. package/packages/seal/test/artifact.test.ts +86 -0
  86. package/packages/seal/test/cli.test.ts +208 -0
  87. package/packages/seal/test/crypto.test.ts +21 -0
  88. package/packages/seal/test/manifest.test.ts +32 -0
  89. package/packages/seal/test/proof.test.ts +60 -0
  90. package/packages/seal/tsconfig.json +12 -0
  91. package/packages/seal/vite.config.ts +54 -0
  92. package/packages/ui/CHANGELOG.md +393 -0
  93. package/packages/ui/README.md +57 -0
  94. package/packages/ui/jsconfig.json +19 -0
  95. package/packages/ui/package.json +64 -0
  96. package/packages/ui/scripts/check-tokens.js +56 -0
  97. package/packages/ui/scripts/generate-theme-css.mjs +85 -0
  98. package/packages/ui/src/design-system/base.css +8 -0
  99. package/packages/ui/src/design-system/docs/ACCESSIBILITY_RULES.md +186 -0
  100. package/packages/ui/src/design-system/docs/AI_SYSTEM.md +281 -0
  101. package/packages/ui/src/design-system/docs/PATTERN_RULES.md +83 -0
  102. package/packages/ui/src/design-system/docs/PRIMITIVE_RULES.md +258 -0
  103. package/packages/ui/src/design-system/docs/TOKEN_RULES.md +235 -0
  104. package/packages/ui/src/design-system/docs/VISUAL_DIRECTION.md +68 -0
  105. package/packages/ui/src/design-system/foundation.js +420 -0
  106. package/packages/ui/src/design-system/tokens.css +140 -0
  107. package/packages/ui/src/design-system/tokens.js +327 -0
  108. package/packages/ui/src/design-system/utils.js +246 -0
  109. package/packages/ui/src/main.js +4 -0
  110. package/packages/ui/src/patterns/FeatureCard/FeatureCard.spec.md +24 -0
  111. package/packages/ui/src/patterns/FeatureCard/FeatureCard.types.ts +8 -0
  112. package/packages/ui/src/patterns/FeatureCard/FeatureCard.vue +175 -0
  113. package/packages/ui/src/patterns/FormField/FormField.spec.md +65 -0
  114. package/packages/ui/src/patterns/FormField/FormField.types.ts +11 -0
  115. package/packages/ui/src/patterns/FormField/FormField.vue +87 -0
  116. package/packages/ui/src/patterns/IdentityGlyph/IdentityGlyph.vue +61 -0
  117. package/packages/ui/src/patterns/IdentityGlyph/IdentityHandle.vue +58 -0
  118. package/packages/ui/src/patterns/IdentityGlyph/identityGlyph.types.ts +36 -0
  119. package/packages/ui/src/patterns/IdentityGlyph/identityGlyph.utils.ts +585 -0
  120. package/packages/ui/src/patterns/IdentityGlyph/index.ts +5 -0
  121. package/packages/ui/src/patterns/KeyValueList/KeyValueList.spec.md +28 -0
  122. package/packages/ui/src/patterns/KeyValueList/KeyValueList.types.ts +16 -0
  123. package/packages/ui/src/patterns/KeyValueList/KeyValueList.vue +50 -0
  124. package/packages/ui/src/patterns/LandingPage/LandingIcon.vue +90 -0
  125. package/packages/ui/src/patterns/LandingPage/LandingPage.spec.md +24 -0
  126. package/packages/ui/src/patterns/LandingPage/LandingPage.types.ts +212 -0
  127. package/packages/ui/src/patterns/LandingPage/LandingPage.vue +599 -0
  128. package/packages/ui/src/patterns/ListWorkspaceLayout/ListWorkspaceLayout.test.ts +33 -0
  129. package/packages/ui/src/patterns/ListWorkspaceLayout/ListWorkspaceLayout.vue +44 -0
  130. package/packages/ui/src/patterns/Logo/Logo.spec.md +22 -0
  131. package/packages/ui/src/patterns/Logo/Logo.vue +160 -0
  132. package/packages/ui/src/patterns/PageSurface/PageSurface.spec.md +15 -0
  133. package/packages/ui/src/patterns/PageSurface/PageSurface.vue +85 -0
  134. package/packages/ui/src/patterns/PanelChrome/PanelChrome.spec.md +39 -0
  135. package/packages/ui/src/patterns/PanelChrome/PanelChrome.types.ts +1 -0
  136. package/packages/ui/src/patterns/PanelChrome/PanelChrome.vue +187 -0
  137. package/packages/ui/src/patterns/PreviewPanel/PreviewPanel.spec.md +31 -0
  138. package/packages/ui/src/patterns/PreviewPanel/PreviewPanel.types.ts +23 -0
  139. package/packages/ui/src/patterns/PreviewPanel/PreviewPanel.vue +354 -0
  140. package/packages/ui/src/patterns/RecordList/RecordList.spec.md +35 -0
  141. package/packages/ui/src/patterns/RecordList/RecordList.test.ts +42 -0
  142. package/packages/ui/src/patterns/RecordList/RecordList.types.ts +9 -0
  143. package/packages/ui/src/patterns/RecordList/RecordList.utils.ts +5 -0
  144. package/packages/ui/src/patterns/RecordList/RecordList.vue +134 -0
  145. package/packages/ui/src/patterns/SectionClarifier/SectionClarifier.vue +85 -0
  146. package/packages/ui/src/patterns/SectionIntro/SectionIntro.spec.md +25 -0
  147. package/packages/ui/src/patterns/SectionIntro/SectionIntro.types.ts +7 -0
  148. package/packages/ui/src/patterns/SectionIntro/SectionIntro.vue +141 -0
  149. package/packages/ui/src/patterns/SidebarNav/SidebarNav.spec.md +34 -0
  150. package/packages/ui/src/patterns/SidebarNav/SidebarNav.types.ts +17 -0
  151. package/packages/ui/src/patterns/SidebarNav/SidebarNav.vue +110 -0
  152. package/packages/ui/src/patterns/SplitView/SplitView.spec.md +28 -0
  153. package/packages/ui/src/patterns/SplitView/SplitView.test.ts +22 -0
  154. package/packages/ui/src/patterns/SplitView/SplitView.types.ts +3 -0
  155. package/packages/ui/src/patterns/SplitView/SplitView.utils.ts +13 -0
  156. package/packages/ui/src/patterns/SplitView/SplitView.vue +39 -0
  157. package/packages/ui/src/patterns/StepList/StepList.spec.md +15 -0
  158. package/packages/ui/src/patterns/StepList/StepList.types.ts +4 -0
  159. package/packages/ui/src/patterns/StepList/StepList.vue +91 -0
  160. package/packages/ui/src/patterns/Verification/VerificationBadge.vue +97 -0
  161. package/packages/ui/src/patterns/Verification/VerificationComponents.test.ts +153 -0
  162. package/packages/ui/src/patterns/Verification/VerificationDetailsPanel.vue +270 -0
  163. package/packages/ui/src/patterns/Verification/VerificationSummary.vue +171 -0
  164. package/packages/ui/src/patterns/Verification/index.ts +6 -0
  165. package/packages/ui/src/patterns/Verification/verification.types.ts +8 -0
  166. package/packages/ui/src/patterns/Verification/verification.utils.test.ts +37 -0
  167. package/packages/ui/src/patterns/Verification/verification.utils.ts +75 -0
  168. package/packages/ui/src/patterns/index.ts +25 -0
  169. package/packages/ui/src/primitives/Accordian/Accordian.vue +11 -0
  170. package/packages/ui/src/primitives/Accordian/AccordianItem.vue +14 -0
  171. package/packages/ui/src/primitives/Accordion/Accordion.props.ts +21 -0
  172. package/packages/ui/src/primitives/Accordion/Accordion.spec.md +50 -0
  173. package/packages/ui/src/primitives/Accordion/Accordion.types.ts +4 -0
  174. package/packages/ui/src/primitives/Accordion/Accordion.variants.ts +12 -0
  175. package/packages/ui/src/primitives/Accordion/Accordion.vue +71 -0
  176. package/packages/ui/src/primitives/Accordion/AccordionItem.props.ts +14 -0
  177. package/packages/ui/src/primitives/Accordion/AccordionItem.vue +40 -0
  178. package/packages/ui/src/primitives/Badge/Badge.props.ts +17 -0
  179. package/packages/ui/src/primitives/Badge/Badge.spec.md +17 -0
  180. package/packages/ui/src/primitives/Badge/Badge.types.ts +15 -0
  181. package/packages/ui/src/primitives/Badge/Badge.variants.ts +48 -0
  182. package/packages/ui/src/primitives/Badge/Badge.vue +31 -0
  183. package/packages/ui/src/primitives/Button/Button.props.ts +29 -0
  184. package/packages/ui/src/primitives/Button/Button.spec.md +139 -0
  185. package/packages/ui/src/primitives/Button/Button.types.ts +19 -0
  186. package/packages/ui/src/primitives/Button/Button.variants.ts +72 -0
  187. package/packages/ui/src/primitives/Button/Button.vue +90 -0
  188. package/packages/ui/src/primitives/Card/Card.props.ts +17 -0
  189. package/packages/ui/src/primitives/Card/Card.spec.md +29 -0
  190. package/packages/ui/src/primitives/Card/Card.types.ts +12 -0
  191. package/packages/ui/src/primitives/Card/Card.variants.ts +27 -0
  192. package/packages/ui/src/primitives/Card/Card.vue +37 -0
  193. package/packages/ui/src/primitives/Checkbox/Checkbox.props.ts +21 -0
  194. package/packages/ui/src/primitives/Checkbox/Checkbox.spec.md +51 -0
  195. package/packages/ui/src/primitives/Checkbox/Checkbox.types.ts +4 -0
  196. package/packages/ui/src/primitives/Checkbox/Checkbox.variants.ts +34 -0
  197. package/packages/ui/src/primitives/Checkbox/Checkbox.vue +92 -0
  198. package/packages/ui/src/primitives/Dialog/Dialog.props.ts +29 -0
  199. package/packages/ui/src/primitives/Dialog/Dialog.spec.md +52 -0
  200. package/packages/ui/src/primitives/Dialog/Dialog.types.ts +3 -0
  201. package/packages/ui/src/primitives/Dialog/Dialog.variants.ts +27 -0
  202. package/packages/ui/src/primitives/Dialog/Dialog.vue +78 -0
  203. package/packages/ui/src/primitives/Drawer/Drawer.props.ts +33 -0
  204. package/packages/ui/src/primitives/Drawer/Drawer.spec.md +50 -0
  205. package/packages/ui/src/primitives/Drawer/Drawer.types.ts +5 -0
  206. package/packages/ui/src/primitives/Drawer/Drawer.variants.ts +35 -0
  207. package/packages/ui/src/primitives/Drawer/Drawer.vue +88 -0
  208. package/packages/ui/src/primitives/FieldMessage/FieldMessage.props.ts +17 -0
  209. package/packages/ui/src/primitives/FieldMessage/FieldMessage.spec.md +35 -0
  210. package/packages/ui/src/primitives/FieldMessage/FieldMessage.types.ts +5 -0
  211. package/packages/ui/src/primitives/FieldMessage/FieldMessage.variants.ts +14 -0
  212. package/packages/ui/src/primitives/FieldMessage/FieldMessage.vue +40 -0
  213. package/packages/ui/src/primitives/FileInput/FileInput.props.ts +41 -0
  214. package/packages/ui/src/primitives/FileInput/FileInput.types.ts +6 -0
  215. package/packages/ui/src/primitives/FileInput/FileInput.variants.ts +46 -0
  216. package/packages/ui/src/primitives/FileInput/FileInput.vue +163 -0
  217. package/packages/ui/src/primitives/Input/Input.props.ts +29 -0
  218. package/packages/ui/src/primitives/Input/Input.spec.md +79 -0
  219. package/packages/ui/src/primitives/Input/Input.types.ts +13 -0
  220. package/packages/ui/src/primitives/Input/Input.variants.ts +54 -0
  221. package/packages/ui/src/primitives/Input/Input.vue +99 -0
  222. package/packages/ui/src/primitives/Label/Label.props.ts +25 -0
  223. package/packages/ui/src/primitives/Label/Label.spec.md +31 -0
  224. package/packages/ui/src/primitives/Label/Label.types.ts +3 -0
  225. package/packages/ui/src/primitives/Label/Label.variants.ts +17 -0
  226. package/packages/ui/src/primitives/Label/Label.vue +38 -0
  227. package/packages/ui/src/primitives/Menu/Menu.props.ts +17 -0
  228. package/packages/ui/src/primitives/Menu/Menu.spec.md +38 -0
  229. package/packages/ui/src/primitives/Menu/Menu.types.ts +10 -0
  230. package/packages/ui/src/primitives/Menu/Menu.variants.ts +10 -0
  231. package/packages/ui/src/primitives/Menu/Menu.vue +57 -0
  232. package/packages/ui/src/primitives/Popover/Popover.props.ts +25 -0
  233. package/packages/ui/src/primitives/Popover/Popover.spec.md +49 -0
  234. package/packages/ui/src/primitives/Popover/Popover.types.ts +3 -0
  235. package/packages/ui/src/primitives/Popover/Popover.variants.ts +18 -0
  236. package/packages/ui/src/primitives/Popover/Popover.vue +74 -0
  237. package/packages/ui/src/primitives/RadioGroup/RadioGroup.props.ts +29 -0
  238. package/packages/ui/src/primitives/RadioGroup/RadioGroup.spec.md +50 -0
  239. package/packages/ui/src/primitives/RadioGroup/RadioGroup.types.ts +12 -0
  240. package/packages/ui/src/primitives/RadioGroup/RadioGroup.variants.ts +48 -0
  241. package/packages/ui/src/primitives/RadioGroup/RadioGroup.vue +87 -0
  242. package/packages/ui/src/primitives/Separator/Separator.props.ts +9 -0
  243. package/packages/ui/src/primitives/Separator/Separator.spec.md +15 -0
  244. package/packages/ui/src/primitives/Separator/Separator.types.ts +3 -0
  245. package/packages/ui/src/primitives/Separator/Separator.variants.ts +8 -0
  246. package/packages/ui/src/primitives/Separator/Separator.vue +23 -0
  247. package/packages/ui/src/primitives/Skeleton/Skeleton.props.ts +21 -0
  248. package/packages/ui/src/primitives/Skeleton/Skeleton.spec.md +18 -0
  249. package/packages/ui/src/primitives/Skeleton/Skeleton.types.ts +5 -0
  250. package/packages/ui/src/primitives/Skeleton/Skeleton.variants.ts +18 -0
  251. package/packages/ui/src/primitives/Skeleton/Skeleton.vue +37 -0
  252. package/packages/ui/src/primitives/Spinner/Spinner.props.ts +13 -0
  253. package/packages/ui/src/primitives/Spinner/Spinner.spec.md +16 -0
  254. package/packages/ui/src/primitives/Spinner/Spinner.types.ts +5 -0
  255. package/packages/ui/src/primitives/Spinner/Spinner.variants.ts +15 -0
  256. package/packages/ui/src/primitives/Spinner/Spinner.vue +33 -0
  257. package/packages/ui/src/primitives/SplitButton/SplitButton.vue +108 -0
  258. package/packages/ui/src/primitives/Switch/Switch.props.ts +21 -0
  259. package/packages/ui/src/primitives/Switch/Switch.spec.md +49 -0
  260. package/packages/ui/src/primitives/Switch/Switch.types.ts +3 -0
  261. package/packages/ui/src/primitives/Switch/Switch.variants.ts +34 -0
  262. package/packages/ui/src/primitives/Switch/Switch.vue +71 -0
  263. package/packages/ui/src/primitives/Tabs/Tabs.props.ts +25 -0
  264. package/packages/ui/src/primitives/Tabs/Tabs.spec.md +48 -0
  265. package/packages/ui/src/primitives/Tabs/Tabs.types.ts +11 -0
  266. package/packages/ui/src/primitives/Tabs/Tabs.variants.ts +28 -0
  267. package/packages/ui/src/primitives/Tabs/Tabs.vue +59 -0
  268. package/packages/ui/src/primitives/Textarea/Textarea.props.ts +33 -0
  269. package/packages/ui/src/primitives/Textarea/Textarea.spec.md +59 -0
  270. package/packages/ui/src/primitives/Textarea/Textarea.types.ts +5 -0
  271. package/packages/ui/src/primitives/Textarea/Textarea.variants.ts +27 -0
  272. package/packages/ui/src/primitives/Textarea/Textarea.vue +74 -0
  273. package/packages/ui/src/primitives/Tooltip/Tooltip.props.ts +21 -0
  274. package/packages/ui/src/primitives/Tooltip/Tooltip.spec.md +45 -0
  275. package/packages/ui/src/primitives/Tooltip/Tooltip.types.ts +3 -0
  276. package/packages/ui/src/primitives/Tooltip/Tooltip.variants.ts +4 -0
  277. package/packages/ui/src/primitives/Tooltip/Tooltip.vue +31 -0
  278. package/packages/ui/src/primitives/TreeView/TreeView.types.ts +10 -0
  279. package/packages/ui/src/primitives/TreeView/TreeView.vue +113 -0
  280. package/packages/ui/src/primitives/TreeView/TreeViewNode.vue +190 -0
  281. package/packages/ui/src/primitives/index.ts +29 -0
  282. package/packages/ui/src/style.css +7 -0
  283. package/packages/ui/src/style.js +1 -0
  284. package/packages/ui/src/themes/armour.css +147 -0
  285. package/packages/ui/src/themes/aurora.css +147 -0
  286. package/packages/ui/src/themes/citrine-ash.css +147 -0
  287. package/packages/ui/src/themes/concord.css +147 -0
  288. package/packages/ui/src/themes/garnet-honey.css +147 -0
  289. package/packages/ui/src/themes/harbor-rose.css +147 -0
  290. package/packages/ui/src/themes/ledger.css +147 -0
  291. package/packages/ui/src/themes/neon-noir.css +74 -0
  292. package/packages/ui/src/themes/obsidian-iris.css +147 -0
  293. package/packages/ui/src/themes/pixpax.css +147 -0
  294. package/packages/ui/src/themes/print.css +147 -0
  295. package/packages/ui/src/themes/prism.css +147 -0
  296. package/packages/ui/src/themes/proof.css +145 -0
  297. package/packages/ui/src/themes/semanticThemeContract.js +2256 -0
  298. package/packages/ui/src/themes/spruce-ink.css +147 -0
  299. package/packages/ui/src/themes/sunset.css +147 -0
  300. package/packages/ui/tailwind.config.js +64 -0
  301. package/packages/ui/vite.config.js +35 -0
  302. package/packages/ui/vite.config.js.timestamp-1780697224943-89fbc929987bc.mjs +38 -0
  303. package/packages/utils/CHANGELOG.md +111 -0
  304. package/packages/utils/README.md +3 -0
  305. package/packages/utils/package.json +46 -0
  306. package/packages/utils/src/index.test.js +39 -0
  307. package/packages/utils/src/index.ts +289 -0
  308. package/packages/utils/tsconfig.build.json +12 -0
  309. package/packages/utils/vite.config.js +28 -0
  310. package/pnpm-workspace.yaml +8 -0
  311. package/scripts/vite/package-lib-config.ts +59 -0
  312. package/tsconfig.json +24 -0
  313. package/tsconfig.node.json +9 -0
@@ -0,0 +1,289 @@
1
+ type BufferLike = {
2
+ from: (
3
+ value: Uint8Array | string,
4
+ encoding?: string,
5
+ ) => {
6
+ toString: (encoding: string) => string;
7
+ };
8
+ };
9
+
10
+ function getBufferCtor(): BufferLike | null {
11
+ const maybeBuffer = (globalThis as { Buffer?: BufferLike }).Buffer;
12
+ return maybeBuffer ?? null;
13
+ }
14
+
15
+ /**
16
+ * addNewLines function - TODO: Add description
17
+ * @param TODO - Add parameters
18
+ * @returns TODO - Add return type description
19
+ */
20
+ export function addNewLines(str: string): string {
21
+ let finalString = "";
22
+ while (str.length > 0) {
23
+ finalString += str.substring(0, 64) + "\n";
24
+ str = str.substring(64);
25
+ }
26
+
27
+ return finalString;
28
+ }
29
+
30
+ /**
31
+ * removeLines function - TODO: Add description
32
+ * @param TODO - Add parameters
33
+ * @returns TODO - Add return type description
34
+ */
35
+ export function removeLines(str: string): string {
36
+ return str.replaceAll("\n", "");
37
+ }
38
+
39
+ /**
40
+ * stripIdentityKey function - TODO: Add description
41
+ * @param TODO - Add parameters
42
+ * @returns TODO - Add return type description
43
+ */
44
+ export function stripIdentityKey(key: string) {
45
+ return key.replace("-----BEGIN PUBLIC KEY-----\n", "").replace("\n-----END PUBLIC KEY-----", "");
46
+ }
47
+
48
+ /**
49
+ * formatIdentityKey function - TODO: Add description
50
+ * @param TODO - Add parameters
51
+ * @returns TODO - Add return type description
52
+ */
53
+ export function formatIdentityKey(key: string) {
54
+ return `-----BEGIN PUBLIC KEY-----\n${key}\n-----END PUBLIC KEY-----`;
55
+ }
56
+
57
+ /**
58
+ * stripEncryptionFile function - TODO: Add description
59
+ * @param TODO - Add parameters
60
+ * @returns TODO - Add return type description
61
+ */
62
+ export function stripEncryptionFile(file: string) {
63
+ return file
64
+ .replace("-----BEGIN AGE ENCRYPTED FILE-----\n", "")
65
+ .replace("\n-----END AGE ENCRYPTED FILE-----\n", "");
66
+ }
67
+
68
+ /**
69
+ * formatEncryptionFile function - TODO: Add description
70
+ * @param TODO - Add parameters
71
+ * @returns TODO - Add return type description
72
+ */
73
+ export function formatEncryptionFile(file: string) {
74
+ return `-----BEGIN AGE ENCRYPTED FILE-----\n${file}\n-----END AGE ENCRYPTED FILE-----\n`;
75
+ }
76
+
77
+ /**
78
+ * generateId function - TODO: Add description
79
+ * @param TODO - Add parameters
80
+ * @returns TODO - Add return type description
81
+ */
82
+ export function generateId() {
83
+ const uint32 = crypto.getRandomValues(new Uint32Array(1))[0];
84
+ return uint32.toString(16);
85
+ }
86
+
87
+ /**
88
+ * arrayBufferToBase64 function - TODO: Add description
89
+ * @param TODO - Add parameters
90
+ * @returns TODO - Add return type description
91
+ */
92
+ export function arrayBufferToBase64(arrayBuffer: ArrayBuffer): string {
93
+ const byteArray = new Uint8Array(arrayBuffer);
94
+ const bufferCtor = getBufferCtor();
95
+ if (bufferCtor) {
96
+ return bufferCtor.from(byteArray).toString("base64");
97
+ }
98
+ let byteString = "";
99
+ for (let i = 0; i < byteArray.byteLength; i++) {
100
+ byteString += String.fromCharCode(byteArray[i]);
101
+ }
102
+ return btoa(byteString);
103
+ }
104
+
105
+ /**
106
+ * base64ToArrayBuffer function - TODO: Add description
107
+ * @param TODO - Add parameters
108
+ * @returns TODO - Add return type description
109
+ */
110
+ export function base64ToArrayBuffer(b64: string): ArrayBuffer {
111
+ const bufferCtor = getBufferCtor();
112
+ if (bufferCtor) {
113
+ const bytes = Uint8Array.from(bufferCtor.from(b64, "base64").toString("binary"), (char) =>
114
+ char.charCodeAt(0),
115
+ );
116
+ return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
117
+ }
118
+ const byteString = atob(b64);
119
+ const byteArray = new Uint8Array(byteString.length);
120
+ for (let i = 0; i < byteString.length; i++) {
121
+ byteArray[i] = byteString.charCodeAt(i);
122
+ }
123
+
124
+ return byteArray.buffer;
125
+ }
126
+
127
+ /**
128
+ * b64encode function - TODO: Add description
129
+ * @param TODO - Add parameters
130
+ * @returns TODO - Add return type description
131
+ */
132
+ export function b64encode(buf: ArrayBuffer): string {
133
+ return arrayBufferToBase64(buf);
134
+ }
135
+
136
+ /**
137
+ * b64decode function - TODO: Add description
138
+ * @param TODO - Add parameters
139
+ * @returns TODO - Add return type description
140
+ */
141
+ export function b64decode(str: string): ArrayBuffer {
142
+ return base64ToArrayBuffer(str);
143
+ }
144
+
145
+ // Encode JSON object to UTF-8 Buffer
146
+ /**
147
+ * encode function - TODO: Add description
148
+ * @param TODO - Add parameters
149
+ * @returns TODO - Add return type description
150
+ */
151
+ export function encode(data: string | object | number): Uint8Array {
152
+ const payload = typeof data === "string" ? data : JSON.stringify(data);
153
+ return new TextEncoder().encode(payload);
154
+ }
155
+
156
+ /**
157
+ * decode function - TODO: Add description
158
+ * @param TODO - Add parameters
159
+ * @returns TODO - Add return type description
160
+ */
161
+ export function decode(data: Uint8Array): string {
162
+ return new TextDecoder("utf-8").decode(new Uint8Array(data));
163
+ }
164
+
165
+ function toCryptoBuffer(data: Uint8Array | ArrayBuffer): ArrayBuffer {
166
+ const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
167
+ return Uint8Array.from(bytes).buffer;
168
+ }
169
+
170
+ /**
171
+ * getHashBuffer function - TODO: Add description
172
+ * @param TODO - Add parameters
173
+ * @returns TODO - Add return type description
174
+ */
175
+ export function getHashBuffer(data: string | object | number): Promise<ArrayBuffer> {
176
+ return crypto.subtle.digest("SHA-256", toCryptoBuffer(encode(data)));
177
+ }
178
+
179
+ /**
180
+ * getHashArray function - TODO: Add description
181
+ * @param TODO - Add parameters
182
+ * @returns TODO - Add return type description
183
+ */
184
+ export function getHashArray(hash: ArrayBuffer): Array<number> {
185
+ return Array.from(new Uint8Array(hash));
186
+ }
187
+
188
+ /**
189
+ * getHashHex function - TODO: Add description
190
+ * @param TODO - Add parameters
191
+ * @returns TODO - Add return type description
192
+ */
193
+ export function getHashHex(hash: Array<number>): string {
194
+ return hash.map((buf) => buf.toString(16).padStart(2, "0")).join("");
195
+ }
196
+
197
+ function canonicalize(
198
+ value: unknown,
199
+ seen: WeakSet<object>,
200
+ ): string | number | boolean | null | Array<unknown> | Record<string, unknown> {
201
+ if (value === undefined) {
202
+ throw new TypeError("Cannot hash undefined");
203
+ }
204
+ const valueType = typeof value;
205
+ if (valueType === "function" || valueType === "symbol") {
206
+ throw new TypeError(`Cannot hash ${valueType} values`);
207
+ }
208
+ if (
209
+ value === null ||
210
+ valueType === "string" ||
211
+ valueType === "number" ||
212
+ valueType === "boolean"
213
+ ) {
214
+ return value as string | number | boolean | null;
215
+ }
216
+ if (valueType === "bigint") {
217
+ throw new TypeError("Cannot hash bigint values");
218
+ }
219
+
220
+ if (typeof (value as { toJSON?: () => unknown }).toJSON === "function") {
221
+ return canonicalize((value as { toJSON: () => unknown }).toJSON(), seen);
222
+ }
223
+
224
+ if (Array.isArray(value)) {
225
+ return value.map((item) => canonicalize(item, seen));
226
+ }
227
+
228
+ if (typeof value === "object") {
229
+ if (seen.has(value as object)) {
230
+ throw new TypeError("Cannot hash circular references");
231
+ }
232
+ seen.add(value as object);
233
+ const entries = Object.keys(value as Record<string, unknown>).sort();
234
+ const result: Record<string, unknown> = {};
235
+ for (const key of entries) {
236
+ result[key] = canonicalize((value as Record<string, unknown>)[key], seen);
237
+ }
238
+ seen.delete(value as object);
239
+ return result;
240
+ }
241
+
242
+ throw new TypeError(`Cannot hash unsupported value type: ${valueType}`);
243
+ }
244
+
245
+ export function canonicalStringify(data: string | object | number): string {
246
+ return JSON.stringify(canonicalize(data, new WeakSet()));
247
+ }
248
+
249
+ export async function hashData(data: string | object | number): Promise<string> {
250
+ const hash_buffer = await getHashBuffer(canonicalStringify(data));
251
+ const hash_array = getHashArray(hash_buffer);
252
+ return getHashHex(hash_array);
253
+ }
254
+
255
+ export async function hashBytes(input: Uint8Array | ArrayBuffer): Promise<string> {
256
+ const hashBuffer = await crypto.subtle.digest("SHA-256", toCryptoBuffer(input));
257
+ return getHashHex(getHashArray(hashBuffer));
258
+ }
259
+
260
+ // utils/gradientUtils.js
261
+ /**
262
+ * generateColorStops function - TODO: Add description
263
+ * @param TODO - Add parameters
264
+ * @returns TODO - Add return type description
265
+ */
266
+ export function generateColorStops(primaryColor: string, secondaryColor: string, steps: number) {
267
+ const colors = [];
268
+ for (let i = 0; i <= steps; i++) {
269
+ const ratio = i / steps;
270
+ const color = lerpColor(primaryColor, secondaryColor, ratio);
271
+ colors.push(color);
272
+ }
273
+ return colors;
274
+ }
275
+
276
+ function lerpColor(color1: string, color2: string, ratio: number) {
277
+ const r1 = parseInt(color1.substring(1, 3), 16);
278
+ const g1 = parseInt(color1.substring(3, 5), 16);
279
+ const b1 = parseInt(color1.substring(5, 7), 16);
280
+ const r2 = parseInt(color2.substring(1, 3), 16);
281
+ const g2 = parseInt(color2.substring(3, 5), 16);
282
+ const b2 = parseInt(color2.substring(5, 7), 16);
283
+
284
+ const r = Math.round(r1 + (r2 - r1) * ratio);
285
+ const g = Math.round(g1 + (g2 - g1) * ratio);
286
+ const b = Math.round(b1 + (b2 - b1) * ratio);
287
+
288
+ return `#${((1 << 24) | (r << 16) | (g << 8) | b).toString(16).slice(1).toUpperCase()}`;
289
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ "outDir": "./dist",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "emitDeclarationOnly": true
9
+ },
10
+ "include": ["src/**/*.ts"],
11
+ "exclude": ["src/**/*.test.*", "dist", "node_modules"]
12
+ }
@@ -0,0 +1,28 @@
1
+ import { dirname, resolve } from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import { defineConfig } from "vite";
4
+
5
+ const configDir = dirname(fileURLToPath(import.meta.url));
6
+
7
+ // https://vitejs.dev/config/
8
+ export default defineConfig({
9
+ output: {
10
+ exports: "named",
11
+ },
12
+ build: {
13
+ outDir: "dist",
14
+ minify: false,
15
+ lib: {
16
+ entry: resolve(configDir, "src/index.ts"),
17
+ name: "ternent-utils",
18
+ fileName: "utils",
19
+ formats: ["es"],
20
+ },
21
+ rollupOptions: {
22
+ output: {
23
+ format: "es",
24
+ entryFileNames: "utils.es.js",
25
+ },
26
+ },
27
+ },
28
+ });
@@ -0,0 +1,8 @@
1
+ packages:
2
+ - "packages/armour"
3
+ # - "packages/concord"
4
+ - "packages/identity"
5
+ # - "packages/ledger"
6
+ - "packages/seal"
7
+ - "packages/ui"
8
+ - "packages/utils"
@@ -0,0 +1,59 @@
1
+ import { builtinModules } from "node:module";
2
+ import { readFileSync } from "node:fs";
3
+ import { dirname, resolve } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ type PackageJsonShape = {
7
+ dependencies?: Record<string, string>;
8
+ peerDependencies?: Record<string, string>;
9
+ optionalDependencies?: Record<string, string>;
10
+ };
11
+
12
+ function loadPackageJson(packageDir: string): PackageJsonShape {
13
+ const packageJsonPath = resolve(packageDir, "package.json");
14
+ return JSON.parse(readFileSync(packageJsonPath, "utf8")) as PackageJsonShape;
15
+ }
16
+
17
+ function createPackageNames(packageJson: PackageJsonShape) {
18
+ return new Set([
19
+ ...Object.keys(packageJson.dependencies || {}),
20
+ ...Object.keys(packageJson.peerDependencies || {}),
21
+ ...Object.keys(packageJson.optionalDependencies || {}),
22
+ ]);
23
+ }
24
+
25
+ function isExternalId(id: string, packageNames: Set<string>, includeNodeBuiltins: boolean) {
26
+ if (includeNodeBuiltins) {
27
+ if (builtinModules.includes(id) || builtinModules.includes(id.replace(/^node:/, ""))) {
28
+ return true;
29
+ }
30
+ if (id.startsWith("node:")) {
31
+ return true;
32
+ }
33
+ }
34
+
35
+ for (const packageName of packageNames) {
36
+ if (id === packageName || id.startsWith(`${packageName}/`)) {
37
+ return true;
38
+ }
39
+ }
40
+
41
+ return false;
42
+ }
43
+
44
+ export function createPackageExternal(
45
+ packageDir: string,
46
+ options: { includeNodeBuiltins?: boolean } = {},
47
+ ) {
48
+ const packageJson = loadPackageJson(packageDir);
49
+ const packageNames = createPackageNames(packageJson);
50
+ const includeNodeBuiltins = options.includeNodeBuiltins === true;
51
+
52
+ return function external(id: string) {
53
+ return isExternalId(id, packageNames, includeNodeBuiltins);
54
+ };
55
+ }
56
+
57
+ export function resolvePackageDir(metaUrl: string) {
58
+ return dirname(fileURLToPath(metaUrl));
59
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "useDefineForClassFields": true,
5
+ "module": "ESNext",
6
+ "moduleResolution": "Node",
7
+ "strict": true,
8
+ "jsx": "preserve",
9
+ "sourceMap": true,
10
+ "resolveJsonModule": true,
11
+ "isolatedModules": true,
12
+ "esModuleInterop": true,
13
+ "lib": ["ESNext", "DOM"],
14
+ "skipLibCheck": true,
15
+ "allowJs": true,
16
+ "declaration": true,
17
+ "declarationMap": true,
18
+ "paths": {
19
+ "@/*": ["./src"]
20
+ }
21
+ },
22
+ "include": ["**/*.ts", "**/*.d.ts", "**/*.tsx", "**/*.vue"],
23
+ "references": [{ "path": "./tsconfig.node.json" }]
24
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "module": "ESNext",
5
+ "moduleResolution": "Node",
6
+ "allowSyntheticDefaultImports": true
7
+ },
8
+ "include": ["apps/footballsocial/vite.config.ts", "packages/identity/vite.config.ts"]
9
+ }