@clef-sh/core 0.1.7-beta.45 → 0.1.8-beta.52
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/dist/artifact/packer.d.ts.map +1 -1
- package/dist/artifact/signer.d.ts +66 -0
- package/dist/artifact/signer.d.ts.map +1 -0
- package/dist/artifact/types.d.ts +10 -0
- package/dist/artifact/types.d.ts.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +119 -10
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +108 -5
- package/dist/index.mjs.map +4 -4
- package/dist/kms/types.d.ts +2 -0
- package/dist/kms/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packer.d.ts","sourceRoot":"","sources":["../../src/artifact/packer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAiB,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAkB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"packer.d.ts","sourceRoot":"","sources":["../../src/artifact/packer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAiB,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAkB,MAAM,SAAS,CAAC;AAIjE;;;;;GAKG;AACH,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAFJ,UAAU,EAAE,iBAAiB,EAC7B,aAAa,EAAE,aAAa,EAC5B,GAAG,CAAC,EAAE,WAAW,YAAA;IAGpC;;;OAGG;IACG,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAoI9F"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { PackedArtifact, SignatureAlgorithm } from "./types";
|
|
2
|
+
import type { KmsProvider } from "../kms";
|
|
3
|
+
/**
|
|
4
|
+
* Build the canonical signing payload from an artifact.
|
|
5
|
+
*
|
|
6
|
+
* The payload is a deterministic newline-separated string of all
|
|
7
|
+
* security-relevant fields. The signature covers everything the
|
|
8
|
+
* runtime acts on — version, identity, environment, revision, timing,
|
|
9
|
+
* integrity hash, key list, expiry, and envelope fields.
|
|
10
|
+
*
|
|
11
|
+
* `ciphertextHash` transitively covers the ciphertext content, so the
|
|
12
|
+
* (potentially large) ciphertext itself is not included.
|
|
13
|
+
*
|
|
14
|
+
* Keys are sorted to ensure deterministic ordering regardless of
|
|
15
|
+
* insertion order in the source object.
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildSigningPayload(artifact: PackedArtifact): Buffer;
|
|
18
|
+
/**
|
|
19
|
+
* Generate an Ed25519 signing key pair.
|
|
20
|
+
* Returns base64-encoded DER keys (SPKI for public, PKCS8 for private).
|
|
21
|
+
*/
|
|
22
|
+
export declare function generateSigningKeyPair(): {
|
|
23
|
+
publicKey: string;
|
|
24
|
+
privateKey: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Sign an artifact payload with an Ed25519 private key.
|
|
28
|
+
*
|
|
29
|
+
* @param payload - Canonical signing payload from {@link buildSigningPayload}
|
|
30
|
+
* @param privateKeyBase64 - Base64-encoded DER PKCS8 private key
|
|
31
|
+
* @returns Base64-encoded Ed25519 signature
|
|
32
|
+
*/
|
|
33
|
+
export declare function signEd25519(payload: Buffer, privateKeyBase64: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Sign an artifact payload with a KMS asymmetric signing key (ECDSA_SHA_256).
|
|
36
|
+
*
|
|
37
|
+
* The KMS `sign` method receives a SHA-256 digest (not the raw payload),
|
|
38
|
+
* matching AWS KMS `MessageType: "DIGEST"` semantics.
|
|
39
|
+
*
|
|
40
|
+
* @param payload - Canonical signing payload from {@link buildSigningPayload}
|
|
41
|
+
* @param kms - KMS provider with `sign` method
|
|
42
|
+
* @param signingKeyId - ARN or ID of the KMS asymmetric signing key
|
|
43
|
+
* @returns Base64-encoded ECDSA signature
|
|
44
|
+
*/
|
|
45
|
+
export declare function signKms(payload: Buffer, kms: KmsProvider, signingKeyId: string): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Verify a signature against a public key.
|
|
48
|
+
*
|
|
49
|
+
* The algorithm is derived from the key's type (Ed25519 or EC), not from
|
|
50
|
+
* the artifact's claimed `signatureAlgorithm` field. This prevents an
|
|
51
|
+
* attacker from downgrading the verification algorithm.
|
|
52
|
+
*
|
|
53
|
+
* @param payload - Canonical signing payload from {@link buildSigningPayload}
|
|
54
|
+
* @param signatureBase64 - Base64-encoded signature to verify
|
|
55
|
+
* @param publicKeyBase64 - Base64-encoded DER SPKI public key
|
|
56
|
+
* @returns true if the signature is valid
|
|
57
|
+
*/
|
|
58
|
+
export declare function verifySignature(payload: Buffer, signatureBase64: string, publicKeyBase64: string): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Detect the signature algorithm from a DER SPKI public key.
|
|
61
|
+
*
|
|
62
|
+
* @param publicKeyBase64 - Base64-encoded DER SPKI public key
|
|
63
|
+
* @returns The corresponding SignatureAlgorithm
|
|
64
|
+
*/
|
|
65
|
+
export declare function detectAlgorithm(publicKeyBase64: string): SignatureAlgorithm;
|
|
66
|
+
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/artifact/signer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE1C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAiBpE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAUlF;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAQ7E;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,OAAO,CAC3B,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,WAAW,EAChB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,CASjB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,MAAM,GACtB,OAAO,CAgBT;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,eAAe,EAAE,MAAM,GAAG,kBAAkB,CAU3E"}
|
package/dist/artifact/types.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export interface ArtifactEnvelope {
|
|
|
9
9
|
/** KMS encryption algorithm (e.g. "SYMMETRIC_DEFAULT"). */
|
|
10
10
|
algorithm: string;
|
|
11
11
|
}
|
|
12
|
+
/** Supported artifact signature algorithms. */
|
|
13
|
+
export type SignatureAlgorithm = "Ed25519" | "ECDSA_SHA256";
|
|
12
14
|
/** JSON envelope for a packed artifact. Language-agnostic, forward-compatible. */
|
|
13
15
|
export interface PackedArtifact {
|
|
14
16
|
version: 1;
|
|
@@ -30,6 +32,10 @@ export interface PackedArtifact {
|
|
|
30
32
|
envelope?: ArtifactEnvelope;
|
|
31
33
|
/** ISO-8601 expiry timestamp. Artifact is rejected after this time. */
|
|
32
34
|
expiresAt?: string;
|
|
35
|
+
/** Base64-encoded cryptographic signature over the canonical artifact payload. */
|
|
36
|
+
signature?: string;
|
|
37
|
+
/** Algorithm used to produce the signature. */
|
|
38
|
+
signatureAlgorithm?: SignatureAlgorithm;
|
|
33
39
|
}
|
|
34
40
|
/** Configuration for the `pack` command. */
|
|
35
41
|
export interface PackConfig {
|
|
@@ -41,6 +47,10 @@ export interface PackConfig {
|
|
|
41
47
|
outputPath: string;
|
|
42
48
|
/** TTL in seconds — embeds an `expiresAt` timestamp in the artifact envelope. */
|
|
43
49
|
ttl?: number;
|
|
50
|
+
/** Ed25519 private key for artifact signing (base64-encoded DER PKCS8). */
|
|
51
|
+
signingKey?: string;
|
|
52
|
+
/** KMS asymmetric signing key ARN/ID (ECDSA_SHA_256). Mutually exclusive with signingKey. */
|
|
53
|
+
signingKmsKeyId?: string;
|
|
44
54
|
}
|
|
45
55
|
/** Result of a pack operation. */
|
|
46
56
|
export interface PackResult {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/artifact/types.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,QAAQ,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,KAAK,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,UAAU,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,kFAAkF;AAClF,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,CAAC,CAAC;IACX,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,+BA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CAAC,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED,4CAA4C;AAC5C,MAAM,WAAW,UAAU;IACzB,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,UAAU,EAAE,MAAM,CAAC;IACnB,iFAAiF;IACjF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6FAA6F;IAC7F,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,kCAAkC;AAClC,MAAM,WAAW,UAAU;IACzB,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,0CAA0C;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/index.d.mts
CHANGED
|
@@ -34,6 +34,7 @@ export { ServiceIdentityManager, PartialRotationError } from "./service-identity
|
|
|
34
34
|
export { resolveIdentitySecrets } from "./artifact/resolve";
|
|
35
35
|
export type { ResolvedSecrets } from "./artifact/resolve";
|
|
36
36
|
export { ArtifactPacker } from "./artifact/packer";
|
|
37
|
-
export type { PackedArtifact, PackConfig, PackResult, ArtifactEnvelope } from "./artifact/types";
|
|
37
|
+
export type { PackedArtifact, PackConfig, PackResult, ArtifactEnvelope, SignatureAlgorithm, } from "./artifact/types";
|
|
38
|
+
export { buildSigningPayload, generateSigningKeyPair, signEd25519, signKms, verifySignature, detectAlgorithm, } from "./artifact/signer";
|
|
38
39
|
export type { KmsProvider, KmsWrapResult, KmsProviderType } from "./kms";
|
|
39
40
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export { ServiceIdentityManager, PartialRotationError } from "./service-identity
|
|
|
34
34
|
export { resolveIdentitySecrets } from "./artifact/resolve";
|
|
35
35
|
export type { ResolvedSecrets } from "./artifact/resolve";
|
|
36
36
|
export { ArtifactPacker } from "./artifact/packer";
|
|
37
|
-
export type { PackedArtifact, PackConfig, PackResult, ArtifactEnvelope } from "./artifact/types";
|
|
37
|
+
export type { PackedArtifact, PackConfig, PackResult, ArtifactEnvelope, SignatureAlgorithm, } from "./artifact/types";
|
|
38
|
+
export { buildSigningPayload, generateSigningKeyPair, signEd25519, signKms, verifySignature, detectAlgorithm, } from "./artifact/signer";
|
|
38
39
|
export type { KmsProvider, KmsWrapResult, KmsProviderType } from "./kms";
|
|
39
40
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EACL,UAAU,EACV,cAAc,EACd,aAAa,EACb,aAAa,EACb,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAA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C;AAC/D,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,IAAI,mBAAmB,EACpC,WAAW,GACZ,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EACL,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EACV,cAAc,EACd,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,WAAW,EACX,OAAO,EACP,eAAe,EACf,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3633,13 +3633,13 @@ var require_age_encryption = __commonJS({
|
|
|
3633
3633
|
}
|
|
3634
3634
|
return { seed, k2sig };
|
|
3635
3635
|
}
|
|
3636
|
-
function
|
|
3636
|
+
function sign2(message, secretKey, opts2 = {}) {
|
|
3637
3637
|
const { seed, k2sig } = prepSig(message, secretKey, opts2);
|
|
3638
3638
|
const drbg = createHmacDrbg(hash.outputLen, Fn.BYTES, hmac4);
|
|
3639
3639
|
const sig = drbg(seed, k2sig);
|
|
3640
3640
|
return sig.toBytes(opts2.format);
|
|
3641
3641
|
}
|
|
3642
|
-
function
|
|
3642
|
+
function verify2(signature, message, publicKey, opts2 = {}) {
|
|
3643
3643
|
const { lowS, prehash, format } = validateSigOpts(opts2, defaultSigOpts);
|
|
3644
3644
|
publicKey = abytes4(publicKey, void 0, "publicKey");
|
|
3645
3645
|
message = validateMsgAndHash(message, prehash);
|
|
@@ -3679,8 +3679,8 @@ var require_age_encryption = __commonJS({
|
|
|
3679
3679
|
utils,
|
|
3680
3680
|
lengths,
|
|
3681
3681
|
Point,
|
|
3682
|
-
sign,
|
|
3683
|
-
verify,
|
|
3682
|
+
sign: sign2,
|
|
3683
|
+
verify: verify2,
|
|
3684
3684
|
recoverPublicKey,
|
|
3685
3685
|
Signature,
|
|
3686
3686
|
hash
|
|
@@ -6950,15 +6950,18 @@ __export(src_exports, {
|
|
|
6950
6950
|
SopsMissingError: () => SopsMissingError,
|
|
6951
6951
|
SopsVersionError: () => SopsVersionError,
|
|
6952
6952
|
assertSops: () => assertSops,
|
|
6953
|
+
buildSigningPayload: () => buildSigningPayload,
|
|
6953
6954
|
checkAll: () => checkAll,
|
|
6954
6955
|
checkDependency: () => checkDependency,
|
|
6955
6956
|
collectCIContext: () => collectCIContext,
|
|
6956
6957
|
deriveAgePublicKey: () => deriveAgePublicKey,
|
|
6958
|
+
detectAlgorithm: () => detectAlgorithm,
|
|
6957
6959
|
detectFormat: () => detectFormat,
|
|
6958
6960
|
findRequest: () => findRequest,
|
|
6959
6961
|
formatAgeKeyFile: () => formatAgeKeyFile,
|
|
6960
6962
|
generateAgeIdentity: () => generateAgeIdentity,
|
|
6961
6963
|
generateRandomValue: () => generateRandomValue,
|
|
6964
|
+
generateSigningKeyPair: () => generateSigningKeyPair,
|
|
6962
6965
|
getPendingKeys: () => getPendingKeys,
|
|
6963
6966
|
isHighEntropy: () => isHighEntropy,
|
|
6964
6967
|
isKmsEnvelope: () => isKmsEnvelope,
|
|
@@ -6990,8 +6993,11 @@ __export(src_exports, {
|
|
|
6990
6993
|
shannonEntropy: () => shannonEntropy,
|
|
6991
6994
|
shouldIgnoreFile: () => shouldIgnoreFile,
|
|
6992
6995
|
shouldIgnoreMatch: () => shouldIgnoreMatch,
|
|
6996
|
+
signEd25519: () => signEd25519,
|
|
6997
|
+
signKms: () => signKms,
|
|
6993
6998
|
upsertRequest: () => upsertRequest,
|
|
6994
|
-
validateAgePublicKey: () => validateAgePublicKey
|
|
6999
|
+
validateAgePublicKey: () => validateAgePublicKey,
|
|
7000
|
+
verifySignature: () => verifySignature
|
|
6995
7001
|
});
|
|
6996
7002
|
module.exports = __toCommonJS(src_exports);
|
|
6997
7003
|
|
|
@@ -11447,7 +11453,87 @@ async function resolveIdentitySecrets(identityName, environment, manifest, repoR
|
|
|
11447
11453
|
// src/artifact/packer.ts
|
|
11448
11454
|
var fs16 = __toESM(require("fs"));
|
|
11449
11455
|
var path18 = __toESM(require("path"));
|
|
11456
|
+
var crypto4 = __toESM(require("crypto"));
|
|
11457
|
+
|
|
11458
|
+
// src/artifact/signer.ts
|
|
11450
11459
|
var crypto3 = __toESM(require("crypto"));
|
|
11460
|
+
function buildSigningPayload(artifact) {
|
|
11461
|
+
const fields = [
|
|
11462
|
+
"clef-sig-v1",
|
|
11463
|
+
String(artifact.version),
|
|
11464
|
+
artifact.identity,
|
|
11465
|
+
artifact.environment,
|
|
11466
|
+
artifact.revision,
|
|
11467
|
+
artifact.packedAt,
|
|
11468
|
+
artifact.ciphertextHash,
|
|
11469
|
+
[...artifact.keys].sort().join(","),
|
|
11470
|
+
artifact.expiresAt ?? "",
|
|
11471
|
+
artifact.envelope?.provider ?? "",
|
|
11472
|
+
artifact.envelope?.keyId ?? "",
|
|
11473
|
+
artifact.envelope?.wrappedKey ?? "",
|
|
11474
|
+
artifact.envelope?.algorithm ?? ""
|
|
11475
|
+
];
|
|
11476
|
+
return Buffer.from(fields.join("\n"), "utf-8");
|
|
11477
|
+
}
|
|
11478
|
+
function generateSigningKeyPair() {
|
|
11479
|
+
const pair = crypto3.generateKeyPairSync("ed25519");
|
|
11480
|
+
return {
|
|
11481
|
+
publicKey: pair.publicKey.export({ type: "spki", format: "der" }).toString(
|
|
11482
|
+
"base64"
|
|
11483
|
+
),
|
|
11484
|
+
privateKey: pair.privateKey.export({ type: "pkcs8", format: "der" }).toString(
|
|
11485
|
+
"base64"
|
|
11486
|
+
)
|
|
11487
|
+
};
|
|
11488
|
+
}
|
|
11489
|
+
function signEd25519(payload, privateKeyBase64) {
|
|
11490
|
+
const keyObj = crypto3.createPrivateKey({
|
|
11491
|
+
key: Buffer.from(privateKeyBase64, "base64"),
|
|
11492
|
+
format: "der",
|
|
11493
|
+
type: "pkcs8"
|
|
11494
|
+
});
|
|
11495
|
+
const signature = crypto3.sign(null, payload, keyObj);
|
|
11496
|
+
return signature.toString("base64");
|
|
11497
|
+
}
|
|
11498
|
+
async function signKms(payload, kms, signingKeyId) {
|
|
11499
|
+
if (!kms.sign) {
|
|
11500
|
+
throw new Error(
|
|
11501
|
+
"KMS provider does not support signing. Ensure the provider implements the sign() method."
|
|
11502
|
+
);
|
|
11503
|
+
}
|
|
11504
|
+
const digest = crypto3.createHash("sha256").update(payload).digest();
|
|
11505
|
+
const signature = await kms.sign(signingKeyId, digest);
|
|
11506
|
+
return signature.toString("base64");
|
|
11507
|
+
}
|
|
11508
|
+
function verifySignature(payload, signatureBase64, publicKeyBase64) {
|
|
11509
|
+
const keyObj = crypto3.createPublicKey({
|
|
11510
|
+
key: Buffer.from(publicKeyBase64, "base64"),
|
|
11511
|
+
format: "der",
|
|
11512
|
+
type: "spki"
|
|
11513
|
+
});
|
|
11514
|
+
const signature = Buffer.from(signatureBase64, "base64");
|
|
11515
|
+
const keyType = keyObj.asymmetricKeyType;
|
|
11516
|
+
if (keyType === "ed25519") {
|
|
11517
|
+
return crypto3.verify(null, payload, keyObj, signature);
|
|
11518
|
+
}
|
|
11519
|
+
if (keyType === "ec") {
|
|
11520
|
+
return crypto3.verify("sha256", payload, keyObj, signature);
|
|
11521
|
+
}
|
|
11522
|
+
throw new Error(`Unsupported key type for signature verification: ${keyType}`);
|
|
11523
|
+
}
|
|
11524
|
+
function detectAlgorithm(publicKeyBase64) {
|
|
11525
|
+
const keyObj = crypto3.createPublicKey({
|
|
11526
|
+
key: Buffer.from(publicKeyBase64, "base64"),
|
|
11527
|
+
format: "der",
|
|
11528
|
+
type: "spki"
|
|
11529
|
+
});
|
|
11530
|
+
const keyType = keyObj.asymmetricKeyType;
|
|
11531
|
+
if (keyType === "ed25519") return "Ed25519";
|
|
11532
|
+
if (keyType === "ec") return "ECDSA_SHA256";
|
|
11533
|
+
throw new Error(`Unsupported key type: ${keyType}`);
|
|
11534
|
+
}
|
|
11535
|
+
|
|
11536
|
+
// src/artifact/packer.ts
|
|
11451
11537
|
var ArtifactPacker = class {
|
|
11452
11538
|
constructor(encryption, matrixManager, kms) {
|
|
11453
11539
|
this.encryption = encryption;
|
|
@@ -11459,6 +11545,11 @@ var ArtifactPacker = class {
|
|
|
11459
11545
|
* values to the service identity's recipient, and write a JSON envelope.
|
|
11460
11546
|
*/
|
|
11461
11547
|
async pack(config, manifest, repoRoot) {
|
|
11548
|
+
if (config.signingKey && config.signingKmsKeyId) {
|
|
11549
|
+
throw new Error(
|
|
11550
|
+
"Cannot specify both signingKey (Ed25519) and signingKmsKeyId (KMS). Choose one."
|
|
11551
|
+
);
|
|
11552
|
+
}
|
|
11462
11553
|
const resolved = await resolveIdentitySecrets(
|
|
11463
11554
|
config.identity,
|
|
11464
11555
|
config.environment,
|
|
@@ -11487,8 +11578,8 @@ var ArtifactPacker = class {
|
|
|
11487
11578
|
}
|
|
11488
11579
|
const kmsConfig = resolved.envConfig.kms;
|
|
11489
11580
|
const wrapped = await this.kms.wrap(kmsConfig.keyId, Buffer.from(ephemeralPrivateKey));
|
|
11490
|
-
const revision = `${Date.now()}-${
|
|
11491
|
-
const ciphertextHash =
|
|
11581
|
+
const revision = `${Date.now()}-${crypto4.randomBytes(4).toString("hex")}`;
|
|
11582
|
+
const ciphertextHash = crypto4.createHash("sha256").update(ciphertext).digest("hex");
|
|
11492
11583
|
artifact = {
|
|
11493
11584
|
version: 1,
|
|
11494
11585
|
identity: config.identity,
|
|
@@ -11515,8 +11606,8 @@ var ArtifactPacker = class {
|
|
|
11515
11606
|
} catch {
|
|
11516
11607
|
throw new Error("Failed to age-encrypt artifact. Check recipient key.");
|
|
11517
11608
|
}
|
|
11518
|
-
const revision = `${Date.now()}-${
|
|
11519
|
-
const ciphertextHash =
|
|
11609
|
+
const revision = `${Date.now()}-${crypto4.randomBytes(4).toString("hex")}`;
|
|
11610
|
+
const ciphertextHash = crypto4.createHash("sha256").update(ciphertext).digest("hex");
|
|
11520
11611
|
artifact = {
|
|
11521
11612
|
version: 1,
|
|
11522
11613
|
identity: config.identity,
|
|
@@ -11535,6 +11626,18 @@ var ArtifactPacker = class {
|
|
|
11535
11626
|
if (config.ttl && config.ttl > 0) {
|
|
11536
11627
|
artifact.expiresAt = new Date(Date.now() + config.ttl * 1e3).toISOString();
|
|
11537
11628
|
}
|
|
11629
|
+
if (config.signingKey) {
|
|
11630
|
+
const payload = buildSigningPayload(artifact);
|
|
11631
|
+
artifact.signature = signEd25519(payload, config.signingKey);
|
|
11632
|
+
artifact.signatureAlgorithm = "Ed25519";
|
|
11633
|
+
} else if (config.signingKmsKeyId) {
|
|
11634
|
+
if (!this.kms) {
|
|
11635
|
+
throw new Error("KMS provider required for KMS signing but none was provided.");
|
|
11636
|
+
}
|
|
11637
|
+
const payload = buildSigningPayload(artifact);
|
|
11638
|
+
artifact.signature = await signKms(payload, this.kms, config.signingKmsKeyId);
|
|
11639
|
+
artifact.signatureAlgorithm = "ECDSA_SHA256";
|
|
11640
|
+
}
|
|
11538
11641
|
const json = JSON.stringify(artifact, null, 2);
|
|
11539
11642
|
const tmpOutput = `${config.outputPath}.tmp.${process.pid}`;
|
|
11540
11643
|
fs16.writeFileSync(tmpOutput, json, "utf-8");
|
|
@@ -11587,15 +11690,18 @@ var ArtifactPacker = class {
|
|
|
11587
11690
|
SopsMissingError,
|
|
11588
11691
|
SopsVersionError,
|
|
11589
11692
|
assertSops,
|
|
11693
|
+
buildSigningPayload,
|
|
11590
11694
|
checkAll,
|
|
11591
11695
|
checkDependency,
|
|
11592
11696
|
collectCIContext,
|
|
11593
11697
|
deriveAgePublicKey,
|
|
11698
|
+
detectAlgorithm,
|
|
11594
11699
|
detectFormat,
|
|
11595
11700
|
findRequest,
|
|
11596
11701
|
formatAgeKeyFile,
|
|
11597
11702
|
generateAgeIdentity,
|
|
11598
11703
|
generateRandomValue,
|
|
11704
|
+
generateSigningKeyPair,
|
|
11599
11705
|
getPendingKeys,
|
|
11600
11706
|
isHighEntropy,
|
|
11601
11707
|
isKmsEnvelope,
|
|
@@ -11627,8 +11733,11 @@ var ArtifactPacker = class {
|
|
|
11627
11733
|
shannonEntropy,
|
|
11628
11734
|
shouldIgnoreFile,
|
|
11629
11735
|
shouldIgnoreMatch,
|
|
11736
|
+
signEd25519,
|
|
11737
|
+
signKms,
|
|
11630
11738
|
upsertRequest,
|
|
11631
|
-
validateAgePublicKey
|
|
11739
|
+
validateAgePublicKey,
|
|
11740
|
+
verifySignature
|
|
11632
11741
|
});
|
|
11633
11742
|
/*! Bundled license information:
|
|
11634
11743
|
|