Primeiro commit do projeto Angular

This commit is contained in:
2026-03-14 20:41:55 +00:00
parent 9bebe1de72
commit 94f4f46395
22413 changed files with 3221690 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
import { crypto } from '@sigstore/core';
import type { Envelope } from '@sigstore/bundle';
import type { SignatureContent } from '../shared.types';
export declare class DSSESignatureContent implements SignatureContent {
private readonly env;
constructor(env: Envelope);
compareDigest(digest: Buffer): boolean;
compareSignature(signature: Buffer): boolean;
verifySignature(key: crypto.KeyObject): boolean;
get signature(): Buffer;
private get preAuthEncoding();
}
+44
View File
@@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DSSESignatureContent = void 0;
/*
Copyright 2023 The Sigstore Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
const core_1 = require("@sigstore/core");
class DSSESignatureContent {
env;
constructor(env) {
this.env = env;
}
compareDigest(digest) {
return core_1.crypto.bufferEqual(digest, core_1.crypto.digest('sha256', this.env.payload));
}
compareSignature(signature) {
return core_1.crypto.bufferEqual(signature, this.signature);
}
verifySignature(key) {
return core_1.crypto.verify(this.preAuthEncoding, key, this.signature);
}
get signature() {
return this.env.signatures.length > 0
? this.env.signatures[0].sig
: Buffer.from('');
}
// DSSE Pre-Authentication Encoding
get preAuthEncoding() {
return core_1.dsse.preAuthEncoding(this.env.payloadType, this.env.payload);
}
}
exports.DSSESignatureContent = DSSESignatureContent;
+4
View File
@@ -0,0 +1,4 @@
import { Bundle } from '@sigstore/bundle';
import type { SignatureContent, SignedEntity } from '../shared.types';
export declare function toSignedEntity(bundle: Bundle, artifact?: Buffer): SignedEntity;
export declare function signatureContent(bundle: Bundle, artifact?: Buffer): SignatureContent;
+59
View File
@@ -0,0 +1,59 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toSignedEntity = toSignedEntity;
exports.signatureContent = signatureContent;
const core_1 = require("@sigstore/core");
const dsse_1 = require("./dsse");
const message_1 = require("./message");
function toSignedEntity(bundle, artifact) {
const { tlogEntries, timestampVerificationData } = bundle.verificationMaterial;
const timestamps = [];
for (const entry of tlogEntries) {
if (entry.integratedTime && entry.integratedTime !== '0') {
timestamps.push({
$case: 'transparency-log',
tlogEntry: entry,
});
}
}
for (const ts of timestampVerificationData?.rfc3161Timestamps ?? []) {
timestamps.push({
$case: 'timestamp-authority',
timestamp: core_1.RFC3161Timestamp.parse(Buffer.from(ts.signedTimestamp)),
});
}
return {
signature: signatureContent(bundle, artifact),
key: key(bundle),
tlogEntries,
timestamps,
};
}
function signatureContent(bundle, artifact) {
switch (bundle.content.$case) {
case 'dsseEnvelope':
return new dsse_1.DSSESignatureContent(bundle.content.dsseEnvelope);
case 'messageSignature':
return new message_1.MessageSignatureContent(bundle.content.messageSignature, artifact);
}
}
function key(bundle) {
switch (bundle.verificationMaterial.content.$case) {
case 'publicKey':
return {
$case: 'public-key',
hint: bundle.verificationMaterial.content.publicKey.hint,
};
case 'x509CertificateChain':
return {
$case: 'certificate',
certificate: core_1.X509Certificate.parse(Buffer.from(bundle.verificationMaterial.content.x509CertificateChain
.certificates[0].rawBytes)),
};
case 'certificate':
return {
$case: 'certificate',
certificate: core_1.X509Certificate.parse(Buffer.from(bundle.verificationMaterial.content.certificate.rawBytes)),
};
}
}
+13
View File
@@ -0,0 +1,13 @@
import { crypto } from '@sigstore/core';
import type { MessageSignature } from '@sigstore/bundle';
import type { SignatureContent } from '../shared.types';
export declare class MessageSignatureContent implements SignatureContent {
readonly signature: Buffer;
private readonly messageDigest;
private readonly artifact;
private readonly hashAlgorithm;
constructor(messageSignature: MessageSignature, artifact: Buffer);
compareSignature(signature: Buffer): boolean;
compareDigest(digest: Buffer): boolean;
verifySignature(key: crypto.KeyObject): boolean;
}
+54
View File
@@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MessageSignatureContent = void 0;
/*
Copyright 2023 The Sigstore Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
const core_1 = require("@sigstore/core");
const protobuf_specs_1 = require("@sigstore/protobuf-specs");
// Map from the Sigstore protobuf HashAlgorithm enum to
// the string values used by the Node.js crypto module.
const HASH_ALGORITHM_MAP = {
[protobuf_specs_1.HashAlgorithm.HASH_ALGORITHM_UNSPECIFIED]: 'sha256',
[protobuf_specs_1.HashAlgorithm.SHA2_256]: 'sha256',
[protobuf_specs_1.HashAlgorithm.SHA2_384]: 'sha384',
[protobuf_specs_1.HashAlgorithm.SHA2_512]: 'sha512',
[protobuf_specs_1.HashAlgorithm.SHA3_256]: 'sha3-256',
[protobuf_specs_1.HashAlgorithm.SHA3_384]: 'sha3-384',
};
class MessageSignatureContent {
signature;
messageDigest;
artifact;
hashAlgorithm;
constructor(messageSignature, artifact) {
this.signature = messageSignature.signature;
this.messageDigest = messageSignature.messageDigest.digest;
this.artifact = artifact;
this.hashAlgorithm =
HASH_ALGORITHM_MAP[messageSignature.messageDigest.algorithm] ??
/* istanbul ignore next */ 'sha256';
}
compareSignature(signature) {
return core_1.crypto.bufferEqual(signature, this.signature);
}
compareDigest(digest) {
return core_1.crypto.bufferEqual(digest, this.messageDigest);
}
verifySignature(key) {
return core_1.crypto.verify(this.artifact, key, this.signature, this.hashAlgorithm);
}
}
exports.MessageSignatureContent = MessageSignatureContent;