burnledger 0.4.0 → 0.6.0

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 (104) hide show
  1. package/README.md +11 -4
  2. package/dist/cjs/anchor.d.ts +71 -0
  3. package/dist/cjs/anchor.d.ts.map +1 -0
  4. package/dist/cjs/anchor.js +279 -0
  5. package/dist/cjs/anchor.js.map +1 -0
  6. package/dist/cjs/client.d.ts +26 -2
  7. package/dist/cjs/client.d.ts.map +1 -1
  8. package/dist/cjs/client.js +27 -5
  9. package/dist/cjs/client.js.map +1 -1
  10. package/dist/cjs/enclave-seal.d.ts +101 -0
  11. package/dist/cjs/enclave-seal.d.ts.map +1 -0
  12. package/dist/cjs/enclave-seal.js +479 -0
  13. package/dist/cjs/enclave-seal.js.map +1 -0
  14. package/dist/cjs/errors.d.ts +42 -1
  15. package/dist/cjs/errors.d.ts.map +1 -1
  16. package/dist/cjs/errors.js +44 -2
  17. package/dist/cjs/errors.js.map +1 -1
  18. package/dist/cjs/http.d.ts +21 -1
  19. package/dist/cjs/http.d.ts.map +1 -1
  20. package/dist/cjs/http.js +76 -12
  21. package/dist/cjs/http.js.map +1 -1
  22. package/dist/cjs/index.browser.d.ts +2 -4
  23. package/dist/cjs/index.browser.d.ts.map +1 -1
  24. package/dist/cjs/index.browser.js.map +1 -1
  25. package/dist/cjs/index.d.ts +16 -11
  26. package/dist/cjs/index.d.ts.map +1 -1
  27. package/dist/cjs/index.js +20 -1
  28. package/dist/cjs/index.js.map +1 -1
  29. package/dist/cjs/keys.d.ts +66 -0
  30. package/dist/cjs/keys.d.ts.map +1 -1
  31. package/dist/cjs/keys.js +128 -3
  32. package/dist/cjs/keys.js.map +1 -1
  33. package/dist/cjs/models.d.ts +41 -3
  34. package/dist/cjs/models.d.ts.map +1 -1
  35. package/dist/cjs/models.js +25 -4
  36. package/dist/cjs/models.js.map +1 -1
  37. package/dist/cjs/verify.d.ts +72 -6
  38. package/dist/cjs/verify.d.ts.map +1 -1
  39. package/dist/cjs/verify.js +392 -62
  40. package/dist/cjs/verify.js.map +1 -1
  41. package/dist/cjs/web-verifier.d.ts +54 -5
  42. package/dist/cjs/web-verifier.d.ts.map +1 -1
  43. package/dist/cjs/web-verifier.js +36 -3
  44. package/dist/cjs/web-verifier.js.map +1 -1
  45. package/dist/esm/anchor.d.ts +71 -0
  46. package/dist/esm/anchor.d.ts.map +1 -0
  47. package/dist/esm/anchor.js +275 -0
  48. package/dist/esm/anchor.js.map +1 -0
  49. package/dist/esm/cli.d.ts +45 -14
  50. package/dist/esm/cli.d.ts.map +1 -1
  51. package/dist/esm/cli.js +357 -50
  52. package/dist/esm/cli.js.map +1 -1
  53. package/dist/esm/client.d.ts +26 -2
  54. package/dist/esm/client.d.ts.map +1 -1
  55. package/dist/esm/client.js +27 -5
  56. package/dist/esm/client.js.map +1 -1
  57. package/dist/esm/enclave-seal.d.ts +101 -0
  58. package/dist/esm/enclave-seal.d.ts.map +1 -0
  59. package/dist/esm/enclave-seal.js +472 -0
  60. package/dist/esm/enclave-seal.js.map +1 -0
  61. package/dist/esm/errors.d.ts +42 -1
  62. package/dist/esm/errors.d.ts.map +1 -1
  63. package/dist/esm/errors.js +43 -1
  64. package/dist/esm/errors.js.map +1 -1
  65. package/dist/esm/http.d.ts +21 -1
  66. package/dist/esm/http.d.ts.map +1 -1
  67. package/dist/esm/http.js +75 -12
  68. package/dist/esm/http.js.map +1 -1
  69. package/dist/esm/index.browser.d.ts +2 -4
  70. package/dist/esm/index.browser.d.ts.map +1 -1
  71. package/dist/esm/index.browser.js.map +1 -1
  72. package/dist/esm/index.d.ts +16 -11
  73. package/dist/esm/index.d.ts.map +1 -1
  74. package/dist/esm/index.js +11 -2
  75. package/dist/esm/index.js.map +1 -1
  76. package/dist/esm/keys.d.ts +66 -0
  77. package/dist/esm/keys.d.ts.map +1 -1
  78. package/dist/esm/keys.js +125 -3
  79. package/dist/esm/keys.js.map +1 -1
  80. package/dist/esm/models.d.ts +41 -3
  81. package/dist/esm/models.d.ts.map +1 -1
  82. package/dist/esm/models.js +24 -4
  83. package/dist/esm/models.js.map +1 -1
  84. package/dist/esm/verify.d.ts +72 -6
  85. package/dist/esm/verify.d.ts.map +1 -1
  86. package/dist/esm/verify.js +390 -63
  87. package/dist/esm/verify.js.map +1 -1
  88. package/dist/esm/web-verifier.d.ts +54 -5
  89. package/dist/esm/web-verifier.d.ts.map +1 -1
  90. package/dist/esm/web-verifier.js +40 -3
  91. package/dist/esm/web-verifier.js.map +1 -1
  92. package/package.json +1 -1
  93. package/src/anchor.ts +330 -0
  94. package/src/cli.ts +389 -54
  95. package/src/client.ts +46 -4
  96. package/src/enclave-seal.ts +582 -0
  97. package/src/errors.ts +47 -2
  98. package/src/http.ts +79 -12
  99. package/src/index.browser.ts +2 -2
  100. package/src/index.ts +28 -9
  101. package/src/keys.ts +176 -3
  102. package/src/models.ts +72 -7
  103. package/src/verify.ts +467 -72
  104. package/src/web-verifier.ts +58 -5
@@ -4,9 +4,9 @@
4
4
  * Imports the leaf modules directly rather than re-exporting from
5
5
  * `index.browser.ts`: that entry pulls in the HTTP client, which imports
6
6
  * `node:fs/promises` and cannot be bundled for a browser at all. The page needs
7
- * four functions, so this exposes four functions — the surface a relying party's
8
- * browser is handed is then something you can read in one screen instead of
9
- * inferring from a minified artifact.
7
+ * a handful of functions and two error codes, so that is what this exposes — the surface
8
+ * a relying party's browser is handed is then something you can read in one
9
+ * screen instead of inferring from a minified artifact.
10
10
  *
11
11
  * Built by `scripts/build-web-verifier.mjs`. The bundle this replaces was built
12
12
  * by hand once and never regenerated, and had drifted into disagreeing with the
@@ -15,14 +15,24 @@
15
15
  * offset (#457). It also contained `ed25519Supported`, which existed in no
16
16
  * source file anywhere in the repository.
17
17
  */
18
+ import {
19
+ ANCHOR_CONFIRMED,
20
+ ANCHOR_INCONSISTENT,
21
+ ANCHOR_UNVERIFIED,
22
+ checkStatementAnchor as _checkStatementAnchor,
23
+ } from "./anchor.js";
24
+ import type { AnchorResult } from "./anchor.js";
18
25
  import { browserCrypto } from "./crypto-browser.js";
26
+ import { CERTIFICATE_REVOKED, UNSUPPORTED_FORMAT_VERSION } from "./errors.js";
19
27
  import {
20
28
  verifyCertificate as _verifyCertificate,
21
29
  verifyCertificateWithStatus as _verifyCertificateWithStatus,
22
30
  verifyTransparency as _verifyTransparency,
23
31
  publicKeyFromHex as _publicKeyFromHex,
24
32
  } from "./verify.js";
25
- import type { PublicKeyInfo } from "./verify.js";
33
+ import type { PublicKeyInfo, PublicKeyOptions } from "./verify.js";
34
+ import { parseKeyListDocument, verifyKeyList as _verifyKeyList } from "./keys.js";
35
+ import type { KeyListDocument, KeyListEvidence } from "./keys.js";
26
36
  import type { VerificationResult, TransparencyResult } from "./models.js";
27
37
 
28
38
  type Cert = Record<string, unknown>;
@@ -50,6 +60,33 @@ export function verifyCertificateWithStatus(
50
60
  return _verifyCertificateWithStatus(browserCrypto, certificate, publicKeys, status, now);
51
61
  }
52
62
 
63
+ /**
64
+ * The `code` a VerificationError carries when a status statement verified and
65
+ * says REVOKED. The page needs it to tell that fact apart from a statement it
66
+ * could not authenticate, which is a different claim and must not be painted
67
+ * as a revocation.
68
+ */
69
+ export { CERTIFICATE_REVOKED, UNSUPPORTED_FORMAT_VERSION };
70
+
71
+ /**
72
+ * Test a status statement's signed log anchor against the log's own signed
73
+ * head, exactly as `burnledger check --online` does (see anchor.ts). The page
74
+ * calls this after it has fetched and authenticated a statement, with `apiUrl`
75
+ * empty so the requests are same-origin like the status fetch itself. Until
76
+ * this was exported the browser re-verified the statement's signature and
77
+ * nothing else, so a statement anchored to a tree the log never had passed
78
+ * here and failed in every CLI.
79
+ */
80
+ export function checkStatementAnchor(
81
+ apiUrl: string,
82
+ statement: Record<string, unknown>,
83
+ key: PublicKeyInfo,
84
+ ): Promise<AnchorResult> {
85
+ return _checkStatementAnchor(browserCrypto, apiUrl, statement, key);
86
+ }
87
+
88
+ export { ANCHOR_CONFIRMED, ANCHOR_INCONSISTENT, ANCHOR_UNVERIFIED };
89
+
53
90
  /** Verify the transparency proof embedded in a certificate. */
54
91
  export function verifyTransparency(
55
92
  certificate: Cert,
@@ -58,10 +95,26 @@ export function verifyTransparency(
58
95
  return _verifyTransparency(browserCrypto, certificate, publicKeys);
59
96
  }
60
97
 
98
+ /**
99
+ * Read the published key set in any shape the endpoint has served, keeping
100
+ * the signed key_list.v3 statement fields when present (ADR-017 §5a).
101
+ */
102
+ export { parseKeyListDocument };
103
+
104
+ /**
105
+ * What the published key set establishes about the key STATUSES: whether it
106
+ * carried a signed statement, and how that statement verified at `now`
107
+ * against the key it names inside itself. The key identities are
108
+ * self-checking either way; this is about the mutable half.
109
+ */
110
+ export function verifyKeyList(doc: KeyListDocument, now?: Date): Promise<KeyListEvidence> {
111
+ return _verifyKeyList(browserCrypto, doc, now ?? new Date());
112
+ }
113
+
61
114
  /** Construct a PublicKeyInfo from a hex-encoded Ed25519 public key. */
62
115
  export function publicKeyFromHex(
63
116
  hexKey: string,
64
- opts?: { revoked?: boolean },
117
+ opts?: PublicKeyOptions,
65
118
  ): Promise<PublicKeyInfo> {
66
119
  return _publicKeyFromHex(browserCrypto, hexKey, opts);
67
120
  }