@freedomofpress/sigstore-browser 0.1.14 → 0.1.16

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 (132) hide show
  1. package/README.md +20 -16
  2. package/dist/bundle.d.ts +3 -2
  3. package/dist/bundle.js +66 -1
  4. package/dist/bundle.js.map +1 -1
  5. package/dist/cli.d.ts +0 -1
  6. package/dist/cli.js.map +1 -1
  7. package/dist/dsse.d.ts +0 -1
  8. package/dist/dsse.js.map +1 -1
  9. package/dist/errors.d.ts +0 -1
  10. package/dist/errors.js.map +1 -1
  11. package/dist/index.d.ts +9 -10
  12. package/dist/index.js +5 -5
  13. package/dist/index.js.map +1 -1
  14. package/dist/interfaces.d.ts +18 -4
  15. package/dist/interfaces.js +15 -1
  16. package/dist/interfaces.js.map +1 -1
  17. package/dist/oid.d.ts +0 -1
  18. package/dist/oid.js.map +1 -1
  19. package/dist/policy.d.ts +3 -4
  20. package/dist/policy.js +5 -5
  21. package/dist/policy.js.map +1 -1
  22. package/dist/rfc3161/error.d.ts +0 -1
  23. package/dist/rfc3161/error.js.map +1 -1
  24. package/dist/rfc3161/index.d.ts +0 -1
  25. package/dist/rfc3161/index.js.map +1 -1
  26. package/dist/rfc3161/timestamp.d.ts +0 -1
  27. package/dist/rfc3161/timestamp.js.map +1 -1
  28. package/dist/rfc3161/tstinfo.d.ts +0 -1
  29. package/dist/rfc3161/tstinfo.js.map +1 -1
  30. package/dist/sigstore.d.ts +10 -20
  31. package/dist/sigstore.js +167 -400
  32. package/dist/sigstore.js.map +1 -1
  33. package/dist/timestamp/tsa.d.ts +6 -3
  34. package/dist/timestamp/tsa.js +16 -19
  35. package/dist/timestamp/tsa.js.map +1 -1
  36. package/dist/tlog/body.d.ts +3 -2
  37. package/dist/tlog/body.js +19 -6
  38. package/dist/tlog/body.js.map +1 -1
  39. package/dist/tlog/checkpoint.d.ts +2 -3
  40. package/dist/tlog/checkpoint.js +17 -95
  41. package/dist/tlog/checkpoint.js.map +1 -1
  42. package/dist/tlog/dsse.d.ts +3 -3
  43. package/dist/tlog/dsse.js +11 -5
  44. package/dist/tlog/dsse.js.map +1 -1
  45. package/dist/tlog/hashedrekord.d.ts +3 -3
  46. package/dist/tlog/hashedrekord.js +8 -5
  47. package/dist/tlog/hashedrekord.js.map +1 -1
  48. package/dist/tlog/intoto.d.ts +3 -3
  49. package/dist/tlog/intoto.js +3 -1
  50. package/dist/tlog/intoto.js.map +1 -1
  51. package/dist/tlog/merkle.d.ts +0 -1
  52. package/dist/tlog/merkle.js.map +1 -1
  53. package/dist/trust/tuf-root.d.ts +0 -1
  54. package/dist/trust/tuf-root.js.map +1 -1
  55. package/dist/trust/tuf.d.ts +0 -1
  56. package/dist/trust/tuf.js.map +1 -1
  57. package/dist/x509/cert.d.ts +0 -1
  58. package/dist/x509/cert.js +1 -1
  59. package/dist/x509/cert.js.map +1 -1
  60. package/dist/x509/chain.d.ts +0 -1
  61. package/dist/x509/chain.js +2 -2
  62. package/dist/x509/chain.js.map +1 -1
  63. package/dist/x509/ext.d.ts +0 -1
  64. package/dist/x509/ext.js.map +1 -1
  65. package/dist/x509/index.d.ts +1 -2
  66. package/dist/x509/index.js +1 -1
  67. package/dist/x509/index.js.map +1 -1
  68. package/dist/x509/sct.d.ts +0 -1
  69. package/dist/x509/sct.js.map +1 -1
  70. package/package.json +15 -8
  71. package/.github/workflows/conformance.yml +0 -29
  72. package/.github/workflows/publish.yml +0 -47
  73. package/dist/bundle.d.ts.map +0 -1
  74. package/dist/cli.d.ts.map +0 -1
  75. package/dist/dsse.d.ts.map +0 -1
  76. package/dist/errors.d.ts.map +0 -1
  77. package/dist/index.d.ts.map +0 -1
  78. package/dist/interfaces.d.ts.map +0 -1
  79. package/dist/oid.d.ts.map +0 -1
  80. package/dist/policy.d.ts.map +0 -1
  81. package/dist/rfc3161/error.d.ts.map +0 -1
  82. package/dist/rfc3161/index.d.ts.map +0 -1
  83. package/dist/rfc3161/timestamp.d.ts.map +0 -1
  84. package/dist/rfc3161/tstinfo.d.ts.map +0 -1
  85. package/dist/sigstore.d.ts.map +0 -1
  86. package/dist/timestamp/tsa.d.ts.map +0 -1
  87. package/dist/tlog/body.d.ts.map +0 -1
  88. package/dist/tlog/checkpoint.d.ts.map +0 -1
  89. package/dist/tlog/dsse.d.ts.map +0 -1
  90. package/dist/tlog/hashedrekord.d.ts.map +0 -1
  91. package/dist/tlog/intoto.d.ts.map +0 -1
  92. package/dist/tlog/merkle.d.ts.map +0 -1
  93. package/dist/trust/tuf-root.d.ts.map +0 -1
  94. package/dist/trust/tuf.d.ts.map +0 -1
  95. package/dist/x509/cert.d.ts.map +0 -1
  96. package/dist/x509/chain.d.ts.map +0 -1
  97. package/dist/x509/ext.d.ts.map +0 -1
  98. package/dist/x509/index.d.ts.map +0 -1
  99. package/dist/x509/sct.d.ts.map +0 -1
  100. package/eslint.config.mjs +0 -31
  101. package/src/bundle.ts +0 -99
  102. package/src/cli.ts +0 -290
  103. package/src/dsse.ts +0 -49
  104. package/src/errors.ts +0 -82
  105. package/src/index.browser.test.ts +0 -290
  106. package/src/index.ts +0 -93
  107. package/src/interfaces.ts +0 -123
  108. package/src/oid.ts +0 -34
  109. package/src/policy.ts +0 -476
  110. package/src/rfc3161/error.ts +0 -16
  111. package/src/rfc3161/index.ts +0 -17
  112. package/src/rfc3161/timestamp.ts +0 -268
  113. package/src/rfc3161/tstinfo.ts +0 -78
  114. package/src/sigstore.ts +0 -948
  115. package/src/timestamp/tsa.ts +0 -211
  116. package/src/tlog/body.ts +0 -65
  117. package/src/tlog/checkpoint.ts +0 -254
  118. package/src/tlog/dsse.ts +0 -147
  119. package/src/tlog/hashedrekord.ts +0 -130
  120. package/src/tlog/intoto.ts +0 -106
  121. package/src/tlog/merkle.ts +0 -152
  122. package/src/trust/README.md +0 -38
  123. package/src/trust/tuf-root.ts +0 -3
  124. package/src/trust/tuf.ts +0 -233
  125. package/src/x509/cert.ts +0 -569
  126. package/src/x509/chain.ts +0 -212
  127. package/src/x509/ext.ts +0 -356
  128. package/src/x509/index.ts +0 -19
  129. package/src/x509/sct.ts +0 -156
  130. package/tsconfig.json +0 -18
  131. package/vite.config.playwright.ts +0 -14
  132. package/vite.config.ts +0 -18
package/src/x509/sct.ts DELETED
@@ -1,156 +0,0 @@
1
- /*
2
- Copyright 2023 The Sigstore Authors.
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
- import { ByteStream, readBigInt64BE, verifySignature } from "@freedomofpress/crypto-browser";
17
-
18
- interface SCTOptions {
19
- version: number;
20
- logID: Uint8Array;
21
- timestamp: Uint8Array;
22
- extensions: Uint8Array;
23
- hashAlgorithm: number;
24
- signatureAlgorithm: number;
25
- signature: Uint8Array;
26
- }
27
-
28
- export class SignedCertificateTimestamp {
29
- readonly version: number;
30
- readonly logID: Uint8Array;
31
- readonly timestamp: Uint8Array;
32
- readonly extensions: Uint8Array;
33
- readonly hashAlgorithm: number;
34
- readonly signatureAlgorithm: number;
35
- readonly signature: Uint8Array;
36
-
37
- constructor(options: SCTOptions) {
38
- this.version = options.version;
39
- this.logID = options.logID;
40
- this.timestamp = options.timestamp;
41
- this.extensions = options.extensions;
42
- this.hashAlgorithm = options.hashAlgorithm;
43
- this.signatureAlgorithm = options.signatureAlgorithm;
44
- this.signature = options.signature;
45
- }
46
-
47
- get datetime(): Date {
48
- return new Date(Number(readBigInt64BE(this.timestamp)));
49
- }
50
-
51
- // Returns the hash algorithm used to generate the SCT's signature.
52
- // https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.4.1
53
- get algorithm(): string {
54
- switch (this.hashAlgorithm) {
55
- /* istanbul ignore next */
56
- case 0:
57
- return "none";
58
- /* istanbul ignore next */
59
- case 1:
60
- return "md5";
61
- /* istanbul ignore next */
62
- case 2:
63
- return "sha1";
64
- /* istanbul ignore next */
65
- case 3:
66
- return "sha224";
67
- case 4:
68
- return "sha256";
69
- /* istanbul ignore next */
70
- case 5:
71
- return "sha384";
72
- /* istanbul ignore next */
73
- case 6:
74
- return "sha512";
75
- /* istanbul ignore next */
76
- default:
77
- return "unknown";
78
- }
79
- }
80
-
81
- public async verify(preCert: Uint8Array, key: CryptoKey): Promise<boolean> {
82
- // Assemble the digitally-signed struct (the data over which the signature
83
- // was generated).
84
- // https://www.rfc-editor.org/rfc/rfc6962#section-3.2
85
- const stream = new ByteStream();
86
- stream.appendChar(this.version);
87
- stream.appendChar(0x00); // SignatureType = certificate_timestamp(0)
88
- stream.appendView(this.timestamp);
89
- stream.appendUint16(0x01); // LogEntryType = precert_entry(1)
90
- stream.appendView(preCert);
91
- stream.appendUint16(this.extensions.byteLength);
92
-
93
- /* istanbul ignore next - extensions are very uncommon */
94
- if (this.extensions.byteLength > 0) {
95
- stream.appendView(this.extensions);
96
- }
97
-
98
- return await verifySignature(
99
- key,
100
- stream.buffer,
101
- this.signature,
102
- this.algorithm,
103
- );
104
- }
105
-
106
- // Parses a SignedCertificateTimestamp from a buffer. SCTs are encoded using
107
- // TLS encoding which means the fields and lengths of most fields are
108
- // specified as part of the SCT and TLS specs.
109
- // https://www.rfc-editor.org/rfc/rfc6962#section-3.2
110
- // https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.4.1
111
- public static parse(buf: Uint8Array): SignedCertificateTimestamp {
112
- const stream = new ByteStream(buf);
113
-
114
- // Version - enum { v1(0), (255) }
115
- // RFC 6962 specifies only v1(0) is valid (for now)
116
- const version = stream.getUint8();
117
- if (version !== 0) {
118
- throw new Error(`Unsupported SCT version: ${version} (expected 0 for v1)`);
119
- }
120
-
121
- // Log ID - struct { opaque key_id[32]; }
122
- const logID = stream.getBlock(32);
123
-
124
- // Timestamp - uint64
125
- const timestamp = stream.getBlock(8);
126
-
127
- // Extensions - opaque extensions<0..2^16-1>;
128
- const extenstionLength = stream.getUint16();
129
- const extensions = stream.getBlock(extenstionLength);
130
-
131
- // Hash algo - enum { sha256(4), . . . (255) }
132
- const hashAlgorithm = stream.getUint8();
133
-
134
- // Signature algo - enum { anonymous(0), rsa(1), dsa(2), ecdsa(3), (255) }
135
- const signatureAlgorithm = stream.getUint8();
136
-
137
- // Signature - opaque signature<0..2^16-1>;
138
- const sigLength = stream.getUint16();
139
- const signature = stream.getBlock(sigLength);
140
-
141
- // Check that we read the entire buffer
142
- if (stream.position !== buf.length) {
143
- throw new Error("SCT buffer length mismatch");
144
- }
145
-
146
- return new SignedCertificateTimestamp({
147
- version,
148
- logID,
149
- timestamp,
150
- extensions,
151
- hashAlgorithm,
152
- signatureAlgorithm,
153
- signature,
154
- });
155
- }
156
- }
package/tsconfig.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "lib": ["DOM", "ES2020"],
5
- "module": "ESNext",
6
- "sourceMap": true,
7
- "moduleResolution": "node",
8
- "resolveJsonModule": true,
9
- "strict": true,
10
- "esModuleInterop": true,
11
- "skipLibCheck": true,
12
- "outDir": "./dist",
13
- "declaration": true,
14
- "declarationMap": true
15
- },
16
- "include": ["./src/**/*.ts"],
17
- "exclude": ["node_modules", "**/*.test.ts"]
18
- }
@@ -1,14 +0,0 @@
1
- /// <reference types="vitest" />
2
- import { defineConfig } from "vite";
3
-
4
- export default defineConfig({
5
- test: {
6
- include: ["**/*.browser.test.ts"],
7
- browser: {
8
- enabled: true,
9
- provider: "playwright",
10
- headless: true,
11
- instances: [{ browser: "chromium" }],
12
- },
13
- },
14
- });
package/vite.config.ts DELETED
@@ -1,18 +0,0 @@
1
- /// <reference types="vitest" />
2
- import { defineConfig } from "vite";
3
-
4
- export default defineConfig({
5
- build: {
6
- outDir: "dist",
7
- target: "es2020",
8
- lib: {
9
- entry: "src/index.ts",
10
- formats: ["es"],
11
- fileName: "index",
12
- },
13
- },
14
- test: {
15
- globals: true,
16
- environment: "node",
17
- },
18
- });