@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.
- package/README.md +20 -16
- package/dist/bundle.d.ts +3 -2
- package/dist/bundle.js +66 -1
- package/dist/bundle.js.map +1 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js.map +1 -1
- package/dist/dsse.d.ts +0 -1
- package/dist/dsse.js.map +1 -1
- package/dist/errors.d.ts +0 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +9 -10
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +18 -4
- package/dist/interfaces.js +15 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/oid.d.ts +0 -1
- package/dist/oid.js.map +1 -1
- package/dist/policy.d.ts +3 -4
- package/dist/policy.js +5 -5
- package/dist/policy.js.map +1 -1
- package/dist/rfc3161/error.d.ts +0 -1
- package/dist/rfc3161/error.js.map +1 -1
- package/dist/rfc3161/index.d.ts +0 -1
- package/dist/rfc3161/index.js.map +1 -1
- package/dist/rfc3161/timestamp.d.ts +0 -1
- package/dist/rfc3161/timestamp.js.map +1 -1
- package/dist/rfc3161/tstinfo.d.ts +0 -1
- package/dist/rfc3161/tstinfo.js.map +1 -1
- package/dist/sigstore.d.ts +10 -20
- package/dist/sigstore.js +167 -400
- package/dist/sigstore.js.map +1 -1
- package/dist/timestamp/tsa.d.ts +6 -3
- package/dist/timestamp/tsa.js +16 -19
- package/dist/timestamp/tsa.js.map +1 -1
- package/dist/tlog/body.d.ts +3 -2
- package/dist/tlog/body.js +19 -6
- package/dist/tlog/body.js.map +1 -1
- package/dist/tlog/checkpoint.d.ts +2 -3
- package/dist/tlog/checkpoint.js +17 -95
- package/dist/tlog/checkpoint.js.map +1 -1
- package/dist/tlog/dsse.d.ts +3 -3
- package/dist/tlog/dsse.js +11 -5
- package/dist/tlog/dsse.js.map +1 -1
- package/dist/tlog/hashedrekord.d.ts +3 -3
- package/dist/tlog/hashedrekord.js +8 -5
- package/dist/tlog/hashedrekord.js.map +1 -1
- package/dist/tlog/intoto.d.ts +3 -3
- package/dist/tlog/intoto.js +3 -1
- package/dist/tlog/intoto.js.map +1 -1
- package/dist/tlog/merkle.d.ts +0 -1
- package/dist/tlog/merkle.js.map +1 -1
- package/dist/trust/tuf-root.d.ts +0 -1
- package/dist/trust/tuf-root.js.map +1 -1
- package/dist/trust/tuf.d.ts +0 -1
- package/dist/trust/tuf.js.map +1 -1
- package/dist/x509/cert.d.ts +0 -1
- package/dist/x509/cert.js +1 -1
- package/dist/x509/cert.js.map +1 -1
- package/dist/x509/chain.d.ts +0 -1
- package/dist/x509/chain.js +2 -2
- package/dist/x509/chain.js.map +1 -1
- package/dist/x509/ext.d.ts +0 -1
- package/dist/x509/ext.js.map +1 -1
- package/dist/x509/index.d.ts +1 -2
- package/dist/x509/index.js +1 -1
- package/dist/x509/index.js.map +1 -1
- package/dist/x509/sct.d.ts +0 -1
- package/dist/x509/sct.js.map +1 -1
- package/package.json +15 -8
- package/.github/workflows/conformance.yml +0 -29
- package/.github/workflows/publish.yml +0 -47
- package/dist/bundle.d.ts.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/dsse.d.ts.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/interfaces.d.ts.map +0 -1
- package/dist/oid.d.ts.map +0 -1
- package/dist/policy.d.ts.map +0 -1
- package/dist/rfc3161/error.d.ts.map +0 -1
- package/dist/rfc3161/index.d.ts.map +0 -1
- package/dist/rfc3161/timestamp.d.ts.map +0 -1
- package/dist/rfc3161/tstinfo.d.ts.map +0 -1
- package/dist/sigstore.d.ts.map +0 -1
- package/dist/timestamp/tsa.d.ts.map +0 -1
- package/dist/tlog/body.d.ts.map +0 -1
- package/dist/tlog/checkpoint.d.ts.map +0 -1
- package/dist/tlog/dsse.d.ts.map +0 -1
- package/dist/tlog/hashedrekord.d.ts.map +0 -1
- package/dist/tlog/intoto.d.ts.map +0 -1
- package/dist/tlog/merkle.d.ts.map +0 -1
- package/dist/trust/tuf-root.d.ts.map +0 -1
- package/dist/trust/tuf.d.ts.map +0 -1
- package/dist/x509/cert.d.ts.map +0 -1
- package/dist/x509/chain.d.ts.map +0 -1
- package/dist/x509/ext.d.ts.map +0 -1
- package/dist/x509/index.d.ts.map +0 -1
- package/dist/x509/sct.d.ts.map +0 -1
- package/eslint.config.mjs +0 -31
- package/src/bundle.ts +0 -99
- package/src/cli.ts +0 -290
- package/src/dsse.ts +0 -49
- package/src/errors.ts +0 -82
- package/src/index.browser.test.ts +0 -290
- package/src/index.ts +0 -93
- package/src/interfaces.ts +0 -123
- package/src/oid.ts +0 -34
- package/src/policy.ts +0 -476
- package/src/rfc3161/error.ts +0 -16
- package/src/rfc3161/index.ts +0 -17
- package/src/rfc3161/timestamp.ts +0 -268
- package/src/rfc3161/tstinfo.ts +0 -78
- package/src/sigstore.ts +0 -948
- package/src/timestamp/tsa.ts +0 -211
- package/src/tlog/body.ts +0 -65
- package/src/tlog/checkpoint.ts +0 -254
- package/src/tlog/dsse.ts +0 -147
- package/src/tlog/hashedrekord.ts +0 -130
- package/src/tlog/intoto.ts +0 -106
- package/src/tlog/merkle.ts +0 -152
- package/src/trust/README.md +0 -38
- package/src/trust/tuf-root.ts +0 -3
- package/src/trust/tuf.ts +0 -233
- package/src/x509/cert.ts +0 -569
- package/src/x509/chain.ts +0 -212
- package/src/x509/ext.ts +0 -356
- package/src/x509/index.ts +0 -19
- package/src/x509/sct.ts +0 -156
- package/tsconfig.json +0 -18
- package/vite.config.playwright.ts +0 -14
- 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
|
-
});
|