@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,25 @@
1
+ declare module "@ternent/seal-cli" {
2
+ export function createSealHash(bytes: Uint8Array | ArrayBuffer): Promise<`sha256:${string}`>;
3
+
4
+ export function createSealProof(input: {
5
+ createdAt?: string;
6
+ signer: { identity: unknown };
7
+ subject: {
8
+ kind: "file" | "manifest" | "artifact";
9
+ path: string;
10
+ hash: `sha256:${string}`;
11
+ };
12
+ }): Promise<unknown>;
13
+
14
+ export function verifySealProofAgainstBytes(
15
+ proof: unknown,
16
+ bytes: Uint8Array | ArrayBuffer,
17
+ ): Promise<{
18
+ valid: boolean;
19
+ hashMatch: boolean;
20
+ signatureValid: boolean;
21
+ keyId: string;
22
+ algorithm: string;
23
+ subjectHash: `sha256:${string}`;
24
+ }>;
25
+ }
@@ -0,0 +1,294 @@
1
+ import type { SerializedIdentity } from "@ternent/identity";
2
+
3
+ export type SealProof = {
4
+ version: string;
5
+ type: "seal-proof";
6
+ algorithm: string;
7
+ createdAt: string;
8
+ subject: {
9
+ kind: "file" | "manifest" | "artifact";
10
+ path: string;
11
+ hash: `sha256:${string}`;
12
+ };
13
+ signer: {
14
+ publicKey: string;
15
+ keyId: string;
16
+ };
17
+ signature: string;
18
+ };
19
+
20
+ export type SealSigner = {
21
+ identity: SerializedIdentity;
22
+ };
23
+
24
+ export type LedgerDecryptor = {
25
+ identity: SerializedIdentity;
26
+ };
27
+
28
+ export type LedgerRecipientResolver = (recipients: string[]) => Promise<string[]> | string[];
29
+
30
+ export type LedgerIdentityContext = {
31
+ signer: SealSigner;
32
+ authorResolver: () => Promise<string> | string;
33
+ recipientResolver?: LedgerRecipientResolver;
34
+ decryptor?: LedgerDecryptor;
35
+ };
36
+
37
+ export type LedgerPlainPayloadRecord = {
38
+ type: "plain";
39
+ data: unknown;
40
+ };
41
+
42
+ export type LedgerEncryptedPayloadRecord = {
43
+ type: "encrypted";
44
+ scheme: "age";
45
+ mode: "recipients";
46
+ encoding: "armor" | "binary";
47
+ data: string;
48
+ payloadHash: `sha256:${string}` | string;
49
+ };
50
+
51
+ export type LedgerPayloadRecord = LedgerPlainPayloadRecord | LedgerEncryptedPayloadRecord;
52
+
53
+ export type LedgerEntryRecord = {
54
+ entryId: string;
55
+ kind: string;
56
+ authoredAt: string;
57
+ author: string;
58
+ meta: Record<string, unknown> | null;
59
+ payload: LedgerPayloadRecord;
60
+ seal: SealProof;
61
+ };
62
+
63
+ export type LedgerCommitRecord = {
64
+ commitId: string;
65
+ parentCommitId: string | null;
66
+ committedAt: string;
67
+ metadata: Record<string, unknown> | null;
68
+ entryIds: string[];
69
+ seal: SealProof;
70
+ };
71
+
72
+ export type LedgerUnsignedCommitRecord = Omit<LedgerCommitRecord, "commitId" | "seal">;
73
+
74
+ export type LedgerContainer = {
75
+ format: "concord-ledger";
76
+ version: "1";
77
+ commits: Record<string, LedgerCommitRecord>;
78
+ entries: Record<string, LedgerEntryRecord>;
79
+ head: string;
80
+ };
81
+
82
+ export type LedgerVerificationSnapshot = {
83
+ valid: boolean;
84
+ checkedAt: string;
85
+ };
86
+
87
+ export type LedgerState<P> = {
88
+ container: LedgerContainer | null;
89
+ staged: LedgerEntryRecord[];
90
+ projection: P;
91
+ verification: LedgerVerificationSnapshot | null;
92
+ };
93
+
94
+ export type LedgerProtectionInput =
95
+ | { type: "none" }
96
+ | {
97
+ type: "recipients";
98
+ recipients: string[];
99
+ encoding?: "armor" | "binary";
100
+ };
101
+
102
+ export type LedgerAppendInput = {
103
+ kind: string;
104
+ payload?: unknown;
105
+ meta?: Record<string, unknown>;
106
+ protection?: LedgerProtectionInput;
107
+ };
108
+
109
+ export type LedgerAppendResult = {
110
+ entry: LedgerEntryRecord;
111
+ stagedCount: number;
112
+ };
113
+
114
+ export type LedgerCommitInput = {
115
+ metadata?: Record<string, unknown>;
116
+ };
117
+
118
+ export type LedgerCommitResult = {
119
+ commit: LedgerCommitRecord;
120
+ committedEntries: LedgerEntryRecord[];
121
+ committedEntryIds: string[];
122
+ };
123
+
124
+ export type LedgerReplayOptions = {
125
+ fromEntryId?: string;
126
+ toEntryId?: string;
127
+ verify?: boolean;
128
+ decrypt?: boolean;
129
+ };
130
+
131
+ export type LedgerVerifyOptions = {
132
+ includeProofs?: boolean;
133
+ includePayloadHashes?: boolean;
134
+ };
135
+
136
+ export type LedgerReplayEntry =
137
+ | {
138
+ entryId: string;
139
+ kind: string;
140
+ author: string;
141
+ authoredAt: string;
142
+ meta: Record<string, unknown> | null;
143
+ payload: { type: "plain"; data: unknown };
144
+ verified: true;
145
+ }
146
+ | {
147
+ entryId: string;
148
+ kind: string;
149
+ author: string;
150
+ authoredAt: string;
151
+ meta: Record<string, unknown> | null;
152
+ payload: {
153
+ type: "encrypted";
154
+ scheme: "age";
155
+ mode: "recipients";
156
+ encoding: "armor" | "binary";
157
+ data: string;
158
+ };
159
+ verified: true;
160
+ decrypted: false;
161
+ }
162
+ | {
163
+ entryId: string;
164
+ kind: string;
165
+ author: string;
166
+ authoredAt: string;
167
+ meta: Record<string, unknown> | null;
168
+ payload: {
169
+ type: "decrypted";
170
+ original: "encrypted";
171
+ data: unknown;
172
+ };
173
+ verified: true;
174
+ decrypted: true;
175
+ };
176
+
177
+ export type LedgerProjector<P> = (projection: P, entry: LedgerReplayEntry) => P;
178
+
179
+ export type LedgerVerificationResult = {
180
+ valid: boolean;
181
+ committedHistoryValid: boolean;
182
+ commitChainValid: boolean;
183
+ commitProofsValid: boolean;
184
+ entriesValid: boolean;
185
+ entryProofsValid: boolean;
186
+ payloadHashesValid: boolean;
187
+ proofsValid: boolean;
188
+ invalidCommitIds: string[];
189
+ invalidEntryIds: string[];
190
+ };
191
+
192
+ export type LedgerPersistenceSnapshot = {
193
+ container: LedgerContainer | null;
194
+ staged: LedgerEntryRecord[];
195
+ };
196
+
197
+ export type LedgerStorageAdapter = {
198
+ name: string;
199
+ load(): Promise<LedgerPersistenceSnapshot | null>;
200
+ save(snapshot: LedgerPersistenceSnapshot): Promise<void>;
201
+ clear?(): Promise<void>;
202
+ };
203
+
204
+ export type LedgerReplayPolicy = {
205
+ verify?: boolean;
206
+ decrypt?: boolean;
207
+ };
208
+
209
+ export type LedgerProtocolContract = {
210
+ canonicalizePayload: (value: unknown) => string;
211
+ getEntrySubjectBytes: (entry: Omit<LedgerEntryRecord, "entryId" | "seal">) => Uint8Array;
212
+ getCommitSubjectBytes: (commit: LedgerUnsignedCommitRecord) => Uint8Array;
213
+ deriveEntryId: (entry: LedgerEntryRecord) => Promise<string>;
214
+ deriveCommitId: (commit: LedgerUnsignedCommitRecord) => Promise<string>;
215
+ getCommitChain: (container: LedgerContainer) => string[];
216
+ validateContainer: (container: LedgerContainer) => {
217
+ ok: boolean;
218
+ errors: string[];
219
+ };
220
+ };
221
+
222
+ export type LedgerSealContract = {
223
+ createEntryProof: (input: {
224
+ entry: Omit<LedgerEntryRecord, "entryId" | "seal">;
225
+ subjectBytes: Uint8Array;
226
+ signer: SealSigner;
227
+ }) => Promise<SealProof>;
228
+ verifyEntryProof: (input: {
229
+ entry: LedgerEntryRecord;
230
+ subjectBytes: Uint8Array;
231
+ proof: SealProof;
232
+ }) => Promise<boolean>;
233
+ createCommitProof: (input: {
234
+ commit: LedgerUnsignedCommitRecord;
235
+ commitId: string;
236
+ subjectBytes: Uint8Array;
237
+ signer: SealSigner;
238
+ }) => Promise<SealProof>;
239
+ verifyCommitProof: (input: {
240
+ commit: LedgerCommitRecord;
241
+ subjectBytes: Uint8Array;
242
+ proof: SealProof;
243
+ }) => Promise<boolean>;
244
+ };
245
+
246
+ export type LedgerArmourContract = {
247
+ encrypt: (input: {
248
+ recipients: string[];
249
+ data: Uint8Array;
250
+ encoding: "armor" | "binary";
251
+ }) => Promise<{
252
+ data: string;
253
+ payloadHash: `sha256:${string}` | string;
254
+ }>;
255
+ decrypt: (input: {
256
+ payload: LedgerEncryptedPayloadRecord;
257
+ decryptor: LedgerDecryptor;
258
+ }) => Promise<unknown>;
259
+ };
260
+
261
+ export type CreateLedgerParams = {
262
+ metadata?: Record<string, unknown>;
263
+ };
264
+
265
+ export type CreateLedgerConfig<P> = {
266
+ identity: LedgerIdentityContext;
267
+ initialProjection: P;
268
+ projector: LedgerProjector<P>;
269
+ storage?: LedgerStorageAdapter;
270
+ protocol?: LedgerProtocolContract;
271
+ seal?: LedgerSealContract;
272
+ armour?: LedgerArmourContract;
273
+ now?: () => string;
274
+ autoCommit?: boolean;
275
+ replayPolicy?: LedgerReplayPolicy;
276
+ };
277
+
278
+ export type LedgerInstance<P> = {
279
+ create(params?: CreateLedgerParams): Promise<void>;
280
+ load(container: LedgerContainer): Promise<void>;
281
+ loadFromStorage(): Promise<boolean>;
282
+ append(input: LedgerAppendInput): Promise<LedgerAppendResult>;
283
+ appendMany(inputs: LedgerAppendInput[]): Promise<LedgerAppendResult[]>;
284
+ commit(input?: LedgerCommitInput): Promise<LedgerCommitResult>;
285
+ replay(options?: LedgerReplayOptions): Promise<P>;
286
+ recompute(): Promise<P>;
287
+ verify(options?: LedgerVerifyOptions): Promise<LedgerVerificationResult>;
288
+ export(): Promise<LedgerContainer>;
289
+ import(container: LedgerContainer): Promise<void>;
290
+ getState(): Readonly<LedgerState<P>>;
291
+ subscribe(listener: (state: Readonly<LedgerState<P>>) => void): () => void;
292
+ clearStaged(): Promise<void>;
293
+ destroy(): Promise<void>;
294
+ };