@countinghouse/ch-local 0.0.0-stage → 1.0.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.
- package/LICENSE +202 -0
- package/README.md +361 -2
- package/bin/ch-local.js +472 -0
- package/clients/claude-code/.claude-plugin/plugin.json +6 -0
- package/clients/claude-code/.mcp.json +11 -0
- package/clients/claude-code/bin/launch.js +235 -0
- package/clients/claude-code/bin/win-acl.js +420 -0
- package/clients/claude-code/skills/ci-failure-triage/SKILL.md +21 -0
- package/clients/claude-code/skills/countinghouse-module/SKILL.md +177 -0
- package/clients/claude-code/skills/countinghouse-setup/SKILL.md +74 -0
- package/lib/allowlist.js +65 -0
- package/lib/aside.js +16 -0
- package/lib/atomic.js +45 -0
- package/lib/auto-apply.js +245 -0
- package/lib/auto-upgrade.js +98 -0
- package/lib/availability.js +307 -0
- package/lib/ceiling.js +280 -0
- package/lib/clean-text.js +20 -0
- package/lib/cli-change.js +38 -0
- package/lib/client-conditions-fixtures.js +143 -0
- package/lib/client-conditions.js +656 -0
- package/lib/clients.js +179 -0
- package/lib/command-line.js +202 -0
- package/lib/conditions-command.js +116 -0
- package/lib/control.js +134 -0
- package/lib/credential-store.js +414 -0
- package/lib/credentials-command.js +344 -0
- package/lib/daemon-requests.js +137 -0
- package/lib/daemon.js +888 -0
- package/lib/describe-module.js +137 -0
- package/lib/description-check.js +175 -0
- package/lib/failed-json.js +43 -0
- package/lib/gc.js +274 -0
- package/lib/github-token.js +57 -0
- package/lib/handoff-io.js +73 -0
- package/lib/held-back.js +116 -0
- package/lib/hidden-input.js +64 -0
- package/lib/history.js +49 -0
- package/lib/home.js +372 -0
- package/lib/in-place.js +1036 -0
- package/lib/install-plan.js +142 -0
- package/lib/install.js +846 -0
- package/lib/installed-description.js +153 -0
- package/lib/integrity.js +7 -0
- package/lib/lock.js +456 -0
- package/lib/lockfile-rules.js +98 -0
- package/lib/machine.js +20 -0
- package/lib/module-credentials.js +403 -0
- package/lib/module-record.js +298 -0
- package/lib/module-roles.js +44 -0
- package/lib/module-seams.js +26 -0
- package/lib/module-store.js +202 -0
- package/lib/module-values.js +334 -0
- package/lib/names.js +31 -0
- package/lib/next-steps.js +8 -0
- package/lib/node-check.js +56 -0
- package/lib/npm-fetch.js +123 -0
- package/lib/npm-release.js +99 -0
- package/lib/npm-upgrade.js +146 -0
- package/lib/npm.js +41 -0
- package/lib/outside-edits.js +162 -0
- package/lib/own-applied.js +175 -0
- package/lib/own-command.js +380 -0
- package/lib/own-file.js +120 -0
- package/lib/own-record.js +96 -0
- package/lib/own-tree.js +336 -0
- package/lib/pack-table.js +290 -0
- package/lib/packs-command.js +570 -0
- package/lib/packs.js +219 -0
- package/lib/pins.js +64 -0
- package/lib/pipe-probe.js +82 -0
- package/lib/plain-read.js +63 -0
- package/lib/private-file.js +90 -0
- package/lib/private-write.js +33 -0
- package/lib/provenance.js +234 -0
- package/lib/record.js +82 -0
- package/lib/registry.js +22 -0
- package/lib/release-pins.js +350 -0
- package/lib/release-pins.json +4225 -0
- package/lib/release-tags.js +12 -0
- package/lib/release.js +36 -0
- package/lib/restart-command.js +161 -0
- package/lib/rollback.js +227 -0
- package/lib/run-liveness.js +15 -0
- package/lib/runtime-log.js +287 -0
- package/lib/sandbox-support.js +17 -0
- package/lib/semver-order.js +40 -0
- package/lib/session-socket.js +69 -0
- package/lib/session-table.js +238 -0
- package/lib/session.js +281 -0
- package/lib/settings-command.js +82 -0
- package/lib/settings.js +564 -0
- package/lib/shim-binary.js +152 -0
- package/lib/shim-config.js +159 -0
- package/lib/shim-install.js +365 -0
- package/lib/sigstore/README.md +44 -0
- package/lib/sigstore/npm-keys.json +18 -0
- package/lib/sigstore/trusted-root.json +126 -0
- package/lib/snippets.js +76 -0
- package/lib/start.js +721 -0
- package/lib/store-files.js +48 -0
- package/lib/store-paths.js +33 -0
- package/lib/swap-preload.js +38 -0
- package/lib/tar.js +220 -0
- package/lib/uninstall.js +314 -0
- package/lib/unpack.js +41 -0
- package/lib/upgrade-stamp.js +63 -0
- package/lib/upgrade.js +281 -0
- package/lib/watch.js +40 -0
- package/lib/win-acl.js +420 -0
- package/node_modules/@sigstore/bundle/LICENSE +202 -0
- package/node_modules/@sigstore/bundle/README.md +19 -0
- package/node_modules/@sigstore/bundle/dist/build.d.ts +18 -0
- package/node_modules/@sigstore/bundle/dist/build.js +100 -0
- package/node_modules/@sigstore/bundle/dist/bundle.d.ts +74 -0
- package/node_modules/@sigstore/bundle/dist/bundle.js +24 -0
- package/node_modules/@sigstore/bundle/dist/error.d.ts +4 -0
- package/node_modules/@sigstore/bundle/dist/error.js +25 -0
- package/node_modules/@sigstore/bundle/dist/index.d.ts +8 -0
- package/node_modules/@sigstore/bundle/dist/index.js +43 -0
- package/node_modules/@sigstore/bundle/dist/serialized.d.ts +74 -0
- package/node_modules/@sigstore/bundle/dist/serialized.js +49 -0
- package/node_modules/@sigstore/bundle/dist/utility.d.ts +14 -0
- package/node_modules/@sigstore/bundle/dist/utility.js +2 -0
- package/node_modules/@sigstore/bundle/dist/validate.d.ts +7 -0
- package/node_modules/@sigstore/bundle/dist/validate.js +199 -0
- package/node_modules/@sigstore/bundle/package.json +35 -0
- package/node_modules/@sigstore/core/LICENSE +202 -0
- package/node_modules/@sigstore/core/README.md +10 -0
- package/node_modules/@sigstore/core/dist/asn1/error.d.ts +4 -0
- package/node_modules/@sigstore/core/dist/asn1/error.js +24 -0
- package/node_modules/@sigstore/core/dist/asn1/index.d.ts +1 -0
- package/node_modules/@sigstore/core/dist/asn1/index.js +20 -0
- package/node_modules/@sigstore/core/dist/asn1/length.d.ts +3 -0
- package/node_modules/@sigstore/core/dist/asn1/length.js +62 -0
- package/node_modules/@sigstore/core/dist/asn1/obj.d.ts +14 -0
- package/node_modules/@sigstore/core/dist/asn1/obj.js +155 -0
- package/node_modules/@sigstore/core/dist/asn1/parse.d.ts +6 -0
- package/node_modules/@sigstore/core/dist/asn1/parse.js +124 -0
- package/node_modules/@sigstore/core/dist/asn1/tag.d.ts +16 -0
- package/node_modules/@sigstore/core/dist/asn1/tag.js +89 -0
- package/node_modules/@sigstore/core/dist/crypto.d.ts +6 -0
- package/node_modules/@sigstore/core/dist/crypto.js +69 -0
- package/node_modules/@sigstore/core/dist/dsse.d.ts +1 -0
- package/node_modules/@sigstore/core/dist/dsse.js +29 -0
- package/node_modules/@sigstore/core/dist/encoding.d.ts +2 -0
- package/node_modules/@sigstore/core/dist/encoding.js +27 -0
- package/node_modules/@sigstore/core/dist/index.d.ts +9 -0
- package/node_modules/@sigstore/core/dist/index.js +66 -0
- package/node_modules/@sigstore/core/dist/json.d.ts +1 -0
- package/node_modules/@sigstore/core/dist/json.js +60 -0
- package/node_modules/@sigstore/core/dist/oid.d.ts +3 -0
- package/node_modules/@sigstore/core/dist/oid.js +20 -0
- package/node_modules/@sigstore/core/dist/pem.d.ts +2 -0
- package/node_modules/@sigstore/core/dist/pem.js +43 -0
- package/node_modules/@sigstore/core/dist/rfc3161/error.d.ts +2 -0
- package/node_modules/@sigstore/core/dist/rfc3161/error.js +21 -0
- package/node_modules/@sigstore/core/dist/rfc3161/index.d.ts +1 -0
- package/node_modules/@sigstore/core/dist/rfc3161/index.js +20 -0
- package/node_modules/@sigstore/core/dist/rfc3161/timestamp.d.ts +36 -0
- package/node_modules/@sigstore/core/dist/rfc3161/timestamp.js +212 -0
- package/node_modules/@sigstore/core/dist/rfc3161/tstinfo.d.ts +12 -0
- package/node_modules/@sigstore/core/dist/rfc3161/tstinfo.js +72 -0
- package/node_modules/@sigstore/core/dist/stream.d.ts +21 -0
- package/node_modules/@sigstore/core/dist/stream.js +117 -0
- package/node_modules/@sigstore/core/dist/x509/cert.d.ts +43 -0
- package/node_modules/@sigstore/core/dist/x509/cert.js +245 -0
- package/node_modules/@sigstore/core/dist/x509/ext.d.ts +41 -0
- package/node_modules/@sigstore/core/dist/x509/ext.js +146 -0
- package/node_modules/@sigstore/core/dist/x509/index.d.ts +2 -0
- package/node_modules/@sigstore/core/dist/x509/index.js +23 -0
- package/node_modules/@sigstore/core/dist/x509/sct.d.ts +25 -0
- package/node_modules/@sigstore/core/dist/x509/sct.js +158 -0
- package/node_modules/@sigstore/core/package.json +31 -0
- package/node_modules/@sigstore/protobuf-specs/LICENSE +202 -0
- package/node_modules/@sigstore/protobuf-specs/README.md +5 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/envelope.d.ts +44 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/envelope.js +59 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/events.d.ts +64 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/events.js +174 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/api/field_behavior.d.ts +74 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/api/field_behavior.js +141 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/protobuf/any.d.ts +74 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/protobuf/any.js +35 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/protobuf/descriptor.d.ts +1309 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/protobuf/descriptor.js +2191 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/protobuf/timestamp.d.ts +113 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/protobuf/timestamp.js +29 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/dsse.d.ts +23 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/dsse.js +55 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/entry.d.ts +43 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/entry.js +81 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/hashedrekord.d.ts +22 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/hashedrekord.js +56 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/verifier.d.ts +35 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/verifier.js +74 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_bundle.d.ts +146 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_bundle.js +103 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_common.d.ts +304 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_common.js +612 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_monitor.d.ts +33 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_monitor.js +55 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_rekor.d.ts +144 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_rekor.js +137 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_trustroot.d.ts +386 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_trustroot.js +284 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_verification.d.ts +191 -0
- package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_verification.js +281 -0
- package/node_modules/@sigstore/protobuf-specs/dist/index.d.ts +6 -0
- package/node_modules/@sigstore/protobuf-specs/dist/index.js +37 -0
- package/node_modules/@sigstore/protobuf-specs/dist/rekor/v2/index.d.ts +4 -0
- package/node_modules/@sigstore/protobuf-specs/dist/rekor/v2/index.js +35 -0
- package/node_modules/@sigstore/protobuf-specs/package.json +35 -0
- package/node_modules/@sigstore/verify/README.md +9 -0
- package/node_modules/@sigstore/verify/dist/bundle/dsse.d.ts +12 -0
- package/node_modules/@sigstore/verify/dist/bundle/dsse.js +44 -0
- package/node_modules/@sigstore/verify/dist/bundle/index.d.ts +4 -0
- package/node_modules/@sigstore/verify/dist/bundle/index.js +59 -0
- package/node_modules/@sigstore/verify/dist/bundle/message.d.ts +13 -0
- package/node_modules/@sigstore/verify/dist/bundle/message.js +54 -0
- package/node_modules/@sigstore/verify/dist/error.d.ts +16 -0
- package/node_modules/@sigstore/verify/dist/error.js +34 -0
- package/node_modules/@sigstore/verify/dist/index.d.ts +6 -0
- package/node_modules/@sigstore/verify/dist/index.js +28 -0
- package/node_modules/@sigstore/verify/dist/key/certificate.d.ts +21 -0
- package/node_modules/@sigstore/verify/dist/key/certificate.js +216 -0
- package/node_modules/@sigstore/verify/dist/key/index.d.ts +10 -0
- package/node_modules/@sigstore/verify/dist/key/index.js +75 -0
- package/node_modules/@sigstore/verify/dist/key/sct.d.ts +4 -0
- package/node_modules/@sigstore/verify/dist/key/sct.js +78 -0
- package/node_modules/@sigstore/verify/dist/policy.d.ts +5 -0
- package/node_modules/@sigstore/verify/dist/policy.js +50 -0
- package/node_modules/@sigstore/verify/dist/shared.types.d.ts +50 -0
- package/node_modules/@sigstore/verify/dist/shared.types.js +2 -0
- package/node_modules/@sigstore/verify/dist/timestamp/index.d.ts +11 -0
- package/node_modules/@sigstore/verify/dist/timestamp/index.js +24 -0
- package/node_modules/@sigstore/verify/dist/timestamp/tsa.d.ts +3 -0
- package/node_modules/@sigstore/verify/dist/timestamp/tsa.js +63 -0
- package/node_modules/@sigstore/verify/dist/tlog/checkpoint.d.ts +11 -0
- package/node_modules/@sigstore/verify/dist/tlog/checkpoint.js +154 -0
- package/node_modules/@sigstore/verify/dist/tlog/dsse.d.ts +6 -0
- package/node_modules/@sigstore/verify/dist/tlog/dsse.js +106 -0
- package/node_modules/@sigstore/verify/dist/tlog/hashedrekord.d.ts +6 -0
- package/node_modules/@sigstore/verify/dist/tlog/hashedrekord.js +94 -0
- package/node_modules/@sigstore/verify/dist/tlog/index.d.ts +5 -0
- package/node_modules/@sigstore/verify/dist/tlog/index.js +92 -0
- package/node_modules/@sigstore/verify/dist/tlog/intoto.d.ts +3 -0
- package/node_modules/@sigstore/verify/dist/tlog/intoto.js +62 -0
- package/node_modules/@sigstore/verify/dist/tlog/merkle.d.ts +3 -0
- package/node_modules/@sigstore/verify/dist/tlog/merkle.js +104 -0
- package/node_modules/@sigstore/verify/dist/tlog/set.d.ts +3 -0
- package/node_modules/@sigstore/verify/dist/tlog/set.js +60 -0
- package/node_modules/@sigstore/verify/dist/trust/filter.d.ts +8 -0
- package/node_modules/@sigstore/verify/dist/trust/filter.js +23 -0
- package/node_modules/@sigstore/verify/dist/trust/index.d.ts +5 -0
- package/node_modules/@sigstore/verify/dist/trust/index.js +90 -0
- package/node_modules/@sigstore/verify/dist/trust/trust.types.d.ts +29 -0
- package/node_modules/@sigstore/verify/dist/trust/trust.types.js +2 -0
- package/node_modules/@sigstore/verify/dist/verifier.d.ts +31 -0
- package/node_modules/@sigstore/verify/dist/verifier.js +160 -0
- package/node_modules/@sigstore/verify/package.json +36 -0
- package/package.json +37 -4
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseInteger = parseInteger;
|
|
4
|
+
exports.parseStringASCII = parseStringASCII;
|
|
5
|
+
exports.parseTime = parseTime;
|
|
6
|
+
exports.parseOID = parseOID;
|
|
7
|
+
exports.parseBoolean = parseBoolean;
|
|
8
|
+
exports.parseBitString = parseBitString;
|
|
9
|
+
/*
|
|
10
|
+
Copyright 2023 The Sigstore Authors.
|
|
11
|
+
|
|
12
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
you may not use this file except in compliance with the License.
|
|
14
|
+
You may obtain a copy of the License at
|
|
15
|
+
|
|
16
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
|
|
18
|
+
Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
See the License for the specific language governing permissions and
|
|
22
|
+
limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
const RE_TIME_SHORT_YEAR = /^(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\.\d{3})?Z$/;
|
|
25
|
+
const RE_TIME_LONG_YEAR = /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\.\d{3})?Z$/;
|
|
26
|
+
// Parse a BigInt from the DER-encoded buffer
|
|
27
|
+
// https://learn.microsoft.com/en-us/windows/win32/seccertenroll/about-integer
|
|
28
|
+
function parseInteger(buf) {
|
|
29
|
+
let pos = 0;
|
|
30
|
+
const end = buf.length;
|
|
31
|
+
let val = buf[pos];
|
|
32
|
+
const neg = val > 0x7f;
|
|
33
|
+
// Consume any padding bytes
|
|
34
|
+
const pad = neg ? 0xff : 0x00;
|
|
35
|
+
while (val == pad && ++pos < end) {
|
|
36
|
+
val = buf[pos];
|
|
37
|
+
}
|
|
38
|
+
// Calculate remaining bytes to read
|
|
39
|
+
const len = end - pos;
|
|
40
|
+
if (len === 0)
|
|
41
|
+
return BigInt(neg ? -1 : 0);
|
|
42
|
+
// Handle two's complement for negative numbers
|
|
43
|
+
val = neg ? val - 256 : val;
|
|
44
|
+
// Parse remaining bytes
|
|
45
|
+
let n = BigInt(val);
|
|
46
|
+
for (let i = pos + 1; i < end; ++i) {
|
|
47
|
+
n = n * BigInt(256) + BigInt(buf[i]);
|
|
48
|
+
}
|
|
49
|
+
return n;
|
|
50
|
+
}
|
|
51
|
+
// Parse an ASCII string from the DER-encoded buffer
|
|
52
|
+
// https://learn.microsoft.com/en-us/windows/win32/seccertenroll/about-basic-types#boolean
|
|
53
|
+
function parseStringASCII(buf) {
|
|
54
|
+
return buf.toString('ascii');
|
|
55
|
+
}
|
|
56
|
+
// Parse a Date from the DER-encoded buffer
|
|
57
|
+
// https://www.rfc-editor.org/rfc/rfc5280#section-4.1.2.5.1
|
|
58
|
+
function parseTime(buf, shortYear) {
|
|
59
|
+
const timeStr = parseStringASCII(buf);
|
|
60
|
+
// Parse the time string into matches - captured groups start at index 1
|
|
61
|
+
const m = shortYear
|
|
62
|
+
? RE_TIME_SHORT_YEAR.exec(timeStr)
|
|
63
|
+
: RE_TIME_LONG_YEAR.exec(timeStr);
|
|
64
|
+
if (!m) {
|
|
65
|
+
throw new Error('invalid time');
|
|
66
|
+
}
|
|
67
|
+
// Translate dates with a 2-digit year to 4 digits per the spec
|
|
68
|
+
if (shortYear) {
|
|
69
|
+
let year = Number(m[1]);
|
|
70
|
+
year += year >= 50 ? 1900 : 2000;
|
|
71
|
+
m[1] = year.toString();
|
|
72
|
+
}
|
|
73
|
+
// Translate to ISO8601 format and parse
|
|
74
|
+
return new Date(`${m[1]}-${m[2]}-${m[3]}T${m[4]}:${m[5]}:${m[6]}Z`);
|
|
75
|
+
}
|
|
76
|
+
// Parse an OID from the DER-encoded buffer
|
|
77
|
+
// https://learn.microsoft.com/en-us/windows/win32/seccertenroll/about-object-identifier
|
|
78
|
+
function parseOID(buf) {
|
|
79
|
+
let pos = 0;
|
|
80
|
+
const end = buf.length;
|
|
81
|
+
// Consume first byte which encodes the first two OID components
|
|
82
|
+
let n = buf[pos++];
|
|
83
|
+
const first = Math.floor(n / 40);
|
|
84
|
+
const second = n % 40;
|
|
85
|
+
let oid = `${first}.${second}`;
|
|
86
|
+
// Consume remaining bytes
|
|
87
|
+
let val = 0;
|
|
88
|
+
for (; pos < end; ++pos) {
|
|
89
|
+
n = buf[pos];
|
|
90
|
+
val = (val << 7) + (n & 0x7f);
|
|
91
|
+
// If the left-most bit is NOT set, then this is the last byte in the
|
|
92
|
+
// sequence and we can add the value to the OID and reset the accumulator
|
|
93
|
+
if ((n & 0x80) === 0) {
|
|
94
|
+
oid += `.${val}`;
|
|
95
|
+
val = 0;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return oid;
|
|
99
|
+
}
|
|
100
|
+
// Parse a boolean from the DER-encoded buffer
|
|
101
|
+
// https://learn.microsoft.com/en-us/windows/win32/seccertenroll/about-basic-types#boolean
|
|
102
|
+
function parseBoolean(buf) {
|
|
103
|
+
return buf[0] !== 0;
|
|
104
|
+
}
|
|
105
|
+
// Parse a bit string from the DER-encoded buffer
|
|
106
|
+
// https://learn.microsoft.com/en-us/windows/win32/seccertenroll/about-bit-string
|
|
107
|
+
function parseBitString(buf) {
|
|
108
|
+
// First byte tell us how many unused bits are in the last byte
|
|
109
|
+
const unused = buf[0];
|
|
110
|
+
const start = 1;
|
|
111
|
+
const end = buf.length;
|
|
112
|
+
const bits = [];
|
|
113
|
+
for (let i = start; i < end; ++i) {
|
|
114
|
+
const byte = buf[i];
|
|
115
|
+
// The skip value is only used for the last byte
|
|
116
|
+
const skip = i === end - 1 ? unused : 0;
|
|
117
|
+
// Iterate over each bit in the byte (most significant first)
|
|
118
|
+
for (let j = 7; j >= skip; --j) {
|
|
119
|
+
// Read the bit and add it to the bit string
|
|
120
|
+
bits.push((byte >> j) & 0x01);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return bits;
|
|
124
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class ASN1Tag {
|
|
2
|
+
readonly number: number;
|
|
3
|
+
readonly constructed: boolean;
|
|
4
|
+
readonly class: number;
|
|
5
|
+
constructor(enc: number);
|
|
6
|
+
isUniversal(): boolean;
|
|
7
|
+
isContextSpecific(num?: number): boolean;
|
|
8
|
+
isBoolean(): boolean;
|
|
9
|
+
isInteger(): boolean;
|
|
10
|
+
isBitString(): boolean;
|
|
11
|
+
isOctetString(): boolean;
|
|
12
|
+
isOID(): boolean;
|
|
13
|
+
isUTCTime(): boolean;
|
|
14
|
+
isGeneralizedTime(): boolean;
|
|
15
|
+
toDER(): number;
|
|
16
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ASN1Tag = void 0;
|
|
4
|
+
/*
|
|
5
|
+
Copyright 2023 The Sigstore Authors.
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
const error_1 = require("./error");
|
|
20
|
+
const UNIVERSAL_TAG = {
|
|
21
|
+
BOOLEAN: 0x01,
|
|
22
|
+
INTEGER: 0x02,
|
|
23
|
+
BIT_STRING: 0x03,
|
|
24
|
+
OCTET_STRING: 0x04,
|
|
25
|
+
OBJECT_IDENTIFIER: 0x06,
|
|
26
|
+
SEQUENCE: 0x10,
|
|
27
|
+
SET: 0x11,
|
|
28
|
+
PRINTABLE_STRING: 0x13,
|
|
29
|
+
UTC_TIME: 0x17,
|
|
30
|
+
GENERALIZED_TIME: 0x18,
|
|
31
|
+
};
|
|
32
|
+
const TAG_CLASS = {
|
|
33
|
+
UNIVERSAL: 0x00,
|
|
34
|
+
APPLICATION: 0x01,
|
|
35
|
+
CONTEXT_SPECIFIC: 0x02,
|
|
36
|
+
PRIVATE: 0x03,
|
|
37
|
+
};
|
|
38
|
+
// https://learn.microsoft.com/en-us/windows/win32/seccertenroll/about-encoded-tag-bytes
|
|
39
|
+
class ASN1Tag {
|
|
40
|
+
number;
|
|
41
|
+
constructed;
|
|
42
|
+
class;
|
|
43
|
+
constructor(enc) {
|
|
44
|
+
// Bits 0 through 4 are the tag number
|
|
45
|
+
this.number = enc & 0x1f;
|
|
46
|
+
// Bit 5 is the constructed bit
|
|
47
|
+
this.constructed = (enc & 0x20) === 0x20;
|
|
48
|
+
// Bit 6 & 7 are the class
|
|
49
|
+
this.class = enc >> 6;
|
|
50
|
+
if (this.number === 0x1f) {
|
|
51
|
+
throw new error_1.ASN1ParseError('long form tags not supported');
|
|
52
|
+
}
|
|
53
|
+
if (this.class === TAG_CLASS.UNIVERSAL && this.number === 0x00) {
|
|
54
|
+
throw new error_1.ASN1ParseError('unsupported tag 0x00');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
isUniversal() {
|
|
58
|
+
return this.class === TAG_CLASS.UNIVERSAL;
|
|
59
|
+
}
|
|
60
|
+
isContextSpecific(num) {
|
|
61
|
+
const res = this.class === TAG_CLASS.CONTEXT_SPECIFIC;
|
|
62
|
+
return num !== undefined ? res && this.number === num : res;
|
|
63
|
+
}
|
|
64
|
+
isBoolean() {
|
|
65
|
+
return this.isUniversal() && this.number === UNIVERSAL_TAG.BOOLEAN;
|
|
66
|
+
}
|
|
67
|
+
isInteger() {
|
|
68
|
+
return this.isUniversal() && this.number === UNIVERSAL_TAG.INTEGER;
|
|
69
|
+
}
|
|
70
|
+
isBitString() {
|
|
71
|
+
return this.isUniversal() && this.number === UNIVERSAL_TAG.BIT_STRING;
|
|
72
|
+
}
|
|
73
|
+
isOctetString() {
|
|
74
|
+
return this.isUniversal() && this.number === UNIVERSAL_TAG.OCTET_STRING;
|
|
75
|
+
}
|
|
76
|
+
isOID() {
|
|
77
|
+
return (this.isUniversal() && this.number === UNIVERSAL_TAG.OBJECT_IDENTIFIER);
|
|
78
|
+
}
|
|
79
|
+
isUTCTime() {
|
|
80
|
+
return this.isUniversal() && this.number === UNIVERSAL_TAG.UTC_TIME;
|
|
81
|
+
}
|
|
82
|
+
isGeneralizedTime() {
|
|
83
|
+
return this.isUniversal() && this.number === UNIVERSAL_TAG.GENERALIZED_TIME;
|
|
84
|
+
}
|
|
85
|
+
toDER() {
|
|
86
|
+
return this.number | (this.constructed ? 0x20 : 0x00) | (this.class << 6);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.ASN1Tag = ASN1Tag;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import crypto, { BinaryLike } from 'crypto';
|
|
2
|
+
export type { KeyObject } from 'crypto';
|
|
3
|
+
export declare function createPublicKey(key: string | Buffer, type?: 'spki' | 'pkcs1'): crypto.KeyObject;
|
|
4
|
+
export declare function digest(algorithm: string, ...data: BinaryLike[]): Buffer;
|
|
5
|
+
export declare function verify(data: Buffer, key: crypto.KeyLike, signature: Buffer, algorithm?: string): boolean;
|
|
6
|
+
export declare function bufferEqual(a: Buffer, b: Buffer): boolean;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createPublicKey = createPublicKey;
|
|
7
|
+
exports.digest = digest;
|
|
8
|
+
exports.verify = verify;
|
|
9
|
+
exports.bufferEqual = bufferEqual;
|
|
10
|
+
/*
|
|
11
|
+
Copyright 2023 The Sigstore Authors.
|
|
12
|
+
|
|
13
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
you may not use this file except in compliance with the License.
|
|
15
|
+
You may obtain a copy of the License at
|
|
16
|
+
|
|
17
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
|
|
19
|
+
Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
See the License for the specific language governing permissions and
|
|
23
|
+
limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
26
|
+
function createPublicKey(key, type = 'spki') {
|
|
27
|
+
if (typeof key === 'string') {
|
|
28
|
+
if (key.startsWith('-----')) {
|
|
29
|
+
return crypto_1.default.createPublicKey(key);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return crypto_1.default.createPublicKey({
|
|
33
|
+
key: Buffer.from(key, 'base64'),
|
|
34
|
+
format: 'der',
|
|
35
|
+
type: type,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return crypto_1.default.createPublicKey({ key, format: 'der', type: type });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function digest(algorithm, ...data) {
|
|
44
|
+
const hash = crypto_1.default.createHash(algorithm);
|
|
45
|
+
for (const d of data) {
|
|
46
|
+
hash.update(d);
|
|
47
|
+
}
|
|
48
|
+
return hash.digest();
|
|
49
|
+
}
|
|
50
|
+
function verify(data, key, signature, algorithm) {
|
|
51
|
+
// The try/catch is to work around an issue in Node 14.x where verify throws
|
|
52
|
+
// an error in some scenarios if the signature is invalid.
|
|
53
|
+
try {
|
|
54
|
+
return crypto_1.default.verify(algorithm, data, key, signature);
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
/* istanbul ignore next */
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function bufferEqual(a, b) {
|
|
62
|
+
try {
|
|
63
|
+
return crypto_1.default.timingSafeEqual(a, b);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
/* istanbul ignore next */
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function preAuthEncoding(payloadType: string, payload: Buffer): Buffer;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.preAuthEncoding = preAuthEncoding;
|
|
4
|
+
/*
|
|
5
|
+
Copyright 2023 The Sigstore Authors.
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
const PAE_PREFIX = 'DSSEv1';
|
|
20
|
+
// DSSE Pre-Authentication Encoding
|
|
21
|
+
function preAuthEncoding(payloadType, payload) {
|
|
22
|
+
const typeBytes = Buffer.from(payloadType, 'utf-8');
|
|
23
|
+
return Buffer.concat([
|
|
24
|
+
Buffer.from(`${PAE_PREFIX} ${typeBytes.length} `, 'ascii'),
|
|
25
|
+
typeBytes,
|
|
26
|
+
Buffer.from(` ${payload.length} `, 'ascii'),
|
|
27
|
+
payload,
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.base64Encode = base64Encode;
|
|
4
|
+
exports.base64Decode = base64Decode;
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2023 The Sigstore Authors.
|
|
7
|
+
|
|
8
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
you may not use this file except in compliance with the License.
|
|
10
|
+
You may obtain a copy of the License at
|
|
11
|
+
|
|
12
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
|
|
14
|
+
Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
See the License for the specific language governing permissions and
|
|
18
|
+
limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
const BASE64_ENCODING = 'base64';
|
|
21
|
+
const UTF8_ENCODING = 'utf-8';
|
|
22
|
+
function base64Encode(str) {
|
|
23
|
+
return Buffer.from(str, UTF8_ENCODING).toString(BASE64_ENCODING);
|
|
24
|
+
}
|
|
25
|
+
function base64Decode(str) {
|
|
26
|
+
return Buffer.from(str, BASE64_ENCODING).toString(UTF8_ENCODING);
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { ASN1Obj } from './asn1';
|
|
2
|
+
export * as crypto from './crypto';
|
|
3
|
+
export * as dsse from './dsse';
|
|
4
|
+
export * as encoding from './encoding';
|
|
5
|
+
export * as json from './json';
|
|
6
|
+
export * as pem from './pem';
|
|
7
|
+
export { RFC3161Timestamp } from './rfc3161';
|
|
8
|
+
export { ByteStream } from './stream';
|
|
9
|
+
export { EXTENSION_OID_SCT, X509Certificate, X509SCTExtension } from './x509';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.X509SCTExtension = exports.X509Certificate = exports.EXTENSION_OID_SCT = exports.ByteStream = exports.RFC3161Timestamp = exports.pem = exports.json = exports.encoding = exports.dsse = exports.crypto = exports.ASN1Obj = void 0;
|
|
37
|
+
/*
|
|
38
|
+
Copyright 2023 The Sigstore Authors.
|
|
39
|
+
|
|
40
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
41
|
+
you may not use this file except in compliance with the License.
|
|
42
|
+
You may obtain a copy of the License at
|
|
43
|
+
|
|
44
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
45
|
+
|
|
46
|
+
Unless required by applicable law or agreed to in writing, software
|
|
47
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
48
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
49
|
+
See the License for the specific language governing permissions and
|
|
50
|
+
limitations under the License.
|
|
51
|
+
*/
|
|
52
|
+
var asn1_1 = require("./asn1");
|
|
53
|
+
Object.defineProperty(exports, "ASN1Obj", { enumerable: true, get: function () { return asn1_1.ASN1Obj; } });
|
|
54
|
+
exports.crypto = __importStar(require("./crypto"));
|
|
55
|
+
exports.dsse = __importStar(require("./dsse"));
|
|
56
|
+
exports.encoding = __importStar(require("./encoding"));
|
|
57
|
+
exports.json = __importStar(require("./json"));
|
|
58
|
+
exports.pem = __importStar(require("./pem"));
|
|
59
|
+
var rfc3161_1 = require("./rfc3161");
|
|
60
|
+
Object.defineProperty(exports, "RFC3161Timestamp", { enumerable: true, get: function () { return rfc3161_1.RFC3161Timestamp; } });
|
|
61
|
+
var stream_1 = require("./stream");
|
|
62
|
+
Object.defineProperty(exports, "ByteStream", { enumerable: true, get: function () { return stream_1.ByteStream; } });
|
|
63
|
+
var x509_1 = require("./x509");
|
|
64
|
+
Object.defineProperty(exports, "EXTENSION_OID_SCT", { enumerable: true, get: function () { return x509_1.EXTENSION_OID_SCT; } });
|
|
65
|
+
Object.defineProperty(exports, "X509Certificate", { enumerable: true, get: function () { return x509_1.X509Certificate; } });
|
|
66
|
+
Object.defineProperty(exports, "X509SCTExtension", { enumerable: true, get: function () { return x509_1.X509SCTExtension; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function canonicalize(object: any): string;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2023 The Sigstore Authors.
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.canonicalize = canonicalize;
|
|
19
|
+
// JSON canonicalization per https://github.com/cyberphone/json-canonicalization
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
function canonicalize(object) {
|
|
22
|
+
let buffer = '';
|
|
23
|
+
if (object === null || typeof object !== 'object' || object.toJSON != null) {
|
|
24
|
+
// Primitives or toJSONable objects
|
|
25
|
+
buffer += JSON.stringify(object);
|
|
26
|
+
}
|
|
27
|
+
else if (Array.isArray(object)) {
|
|
28
|
+
// Array - maintain element order
|
|
29
|
+
buffer += '[';
|
|
30
|
+
let first = true;
|
|
31
|
+
object.forEach((element) => {
|
|
32
|
+
if (!first) {
|
|
33
|
+
buffer += ',';
|
|
34
|
+
}
|
|
35
|
+
first = false;
|
|
36
|
+
// recursive call
|
|
37
|
+
buffer += canonicalize(element);
|
|
38
|
+
});
|
|
39
|
+
buffer += ']';
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// Object - Sort properties before serializing
|
|
43
|
+
buffer += '{';
|
|
44
|
+
let first = true;
|
|
45
|
+
Object.keys(object)
|
|
46
|
+
.sort()
|
|
47
|
+
.forEach((property) => {
|
|
48
|
+
if (!first) {
|
|
49
|
+
buffer += ',';
|
|
50
|
+
}
|
|
51
|
+
first = false;
|
|
52
|
+
buffer += JSON.stringify(property);
|
|
53
|
+
buffer += ':';
|
|
54
|
+
// recursive call
|
|
55
|
+
buffer += canonicalize(object[property]);
|
|
56
|
+
});
|
|
57
|
+
buffer += '}';
|
|
58
|
+
}
|
|
59
|
+
return buffer;
|
|
60
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SHA2_HASH_ALGOS = exports.RSA_SIGNATURE_ALGOS = exports.ECDSA_SIGNATURE_ALGOS = void 0;
|
|
4
|
+
exports.ECDSA_SIGNATURE_ALGOS = {
|
|
5
|
+
'1.2.840.10045.4.3.1': 'sha224',
|
|
6
|
+
'1.2.840.10045.4.3.2': 'sha256',
|
|
7
|
+
'1.2.840.10045.4.3.3': 'sha384',
|
|
8
|
+
'1.2.840.10045.4.3.4': 'sha512',
|
|
9
|
+
};
|
|
10
|
+
exports.RSA_SIGNATURE_ALGOS = {
|
|
11
|
+
'1.2.840.113549.1.1.14': 'sha224',
|
|
12
|
+
'1.2.840.113549.1.1.11': 'sha256',
|
|
13
|
+
'1.2.840.113549.1.1.12': 'sha384',
|
|
14
|
+
'1.2.840.113549.1.1.13': 'sha512',
|
|
15
|
+
};
|
|
16
|
+
exports.SHA2_HASH_ALGOS = {
|
|
17
|
+
'2.16.840.1.101.3.4.2.1': 'sha256',
|
|
18
|
+
'2.16.840.1.101.3.4.2.2': 'sha384',
|
|
19
|
+
'2.16.840.1.101.3.4.2.3': 'sha512',
|
|
20
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toDER = toDER;
|
|
4
|
+
exports.fromDER = fromDER;
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2023 The Sigstore Authors.
|
|
7
|
+
|
|
8
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
you may not use this file except in compliance with the License.
|
|
10
|
+
You may obtain a copy of the License at
|
|
11
|
+
|
|
12
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
|
|
14
|
+
Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
See the License for the specific language governing permissions and
|
|
18
|
+
limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
const PEM_HEADER = /-----BEGIN (.*)-----/;
|
|
21
|
+
const PEM_FOOTER = /-----END (.*)-----/;
|
|
22
|
+
function toDER(certificate) {
|
|
23
|
+
let der = '';
|
|
24
|
+
certificate.split('\n').forEach((line) => {
|
|
25
|
+
if (line.match(PEM_HEADER) || line.match(PEM_FOOTER)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
der += line;
|
|
29
|
+
});
|
|
30
|
+
return Buffer.from(der, 'base64');
|
|
31
|
+
}
|
|
32
|
+
// Translates a DER-encoded buffer into a PEM-encoded string. Standard PEM
|
|
33
|
+
// encoding dictates that each certificate should have a trailing newline after
|
|
34
|
+
// the footer.
|
|
35
|
+
function fromDER(certificate, type = 'CERTIFICATE') {
|
|
36
|
+
// Base64-encode the certificate.
|
|
37
|
+
const der = certificate.toString('base64');
|
|
38
|
+
// Split the certificate into lines of 64 characters.
|
|
39
|
+
const lines = der.match(/.{1,64}/g) || '';
|
|
40
|
+
return [`-----BEGIN ${type}-----`, ...lines, `-----END ${type}-----`]
|
|
41
|
+
.join('\n')
|
|
42
|
+
.concat('\n');
|
|
43
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RFC3161TimestampVerificationError = void 0;
|
|
4
|
+
/*
|
|
5
|
+
Copyright 2023 The Sigstore Authors.
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
class RFC3161TimestampVerificationError extends Error {
|
|
20
|
+
}
|
|
21
|
+
exports.RFC3161TimestampVerificationError = RFC3161TimestampVerificationError;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RFC3161Timestamp } from './timestamp';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2023 The Sigstore Authors.
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.RFC3161Timestamp = void 0;
|
|
19
|
+
var timestamp_1 = require("./timestamp");
|
|
20
|
+
Object.defineProperty(exports, "RFC3161Timestamp", { enumerable: true, get: function () { return timestamp_1.RFC3161Timestamp; } });
|