@clef-sh/runtime 0.1.6-beta.32
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/decrypt.d.ts +25 -0
- package/dist/decrypt.d.ts.map +1 -0
- package/dist/decrypt.js +82 -0
- package/dist/decrypt.js.map +1 -0
- package/dist/disk-cache.d.ts +22 -0
- package/dist/disk-cache.d.ts.map +1 -0
- package/dist/disk-cache.js +113 -0
- package/dist/disk-cache.js.map +1 -0
- package/dist/index.d.ts +96 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +165 -0
- package/dist/index.js.map +1 -0
- package/dist/kms/aws.d.ts +15 -0
- package/dist/kms/aws.d.ts.map +1 -0
- package/dist/kms/aws.js +92 -0
- package/dist/kms/aws.js.map +1 -0
- package/dist/kms/azure.d.ts +16 -0
- package/dist/kms/azure.d.ts.map +1 -0
- package/dist/kms/azure.js +85 -0
- package/dist/kms/azure.js.map +1 -0
- package/dist/kms/gcp.d.ts +17 -0
- package/dist/kms/gcp.d.ts.map +1 -0
- package/dist/kms/gcp.js +87 -0
- package/dist/kms/gcp.js.map +1 -0
- package/dist/kms/index.d.ts +12 -0
- package/dist/kms/index.d.ts.map +1 -0
- package/dist/kms/index.js +29 -0
- package/dist/kms/index.js.map +1 -0
- package/dist/kms/types.d.ts +10 -0
- package/dist/kms/types.d.ts.map +1 -0
- package/dist/kms/types.js +3 -0
- package/dist/kms/types.js.map +1 -0
- package/dist/poller.d.ts +80 -0
- package/dist/poller.d.ts.map +1 -0
- package/dist/poller.js +329 -0
- package/dist/poller.js.map +1 -0
- package/dist/secrets-cache.d.ts +23 -0
- package/dist/secrets-cache.d.ts.map +1 -0
- package/dist/secrets-cache.js +51 -0
- package/dist/secrets-cache.js.map +1 -0
- package/dist/sources/file.d.ts +9 -0
- package/dist/sources/file.d.ts.map +1 -0
- package/dist/sources/file.js +53 -0
- package/dist/sources/file.js.map +1 -0
- package/dist/sources/http.d.ts +9 -0
- package/dist/sources/http.d.ts.map +1 -0
- package/dist/sources/http.js +24 -0
- package/dist/sources/http.js.map +1 -0
- package/dist/sources/index.d.ts +5 -0
- package/dist/sources/index.d.ts.map +1 -0
- package/dist/sources/index.js +10 -0
- package/dist/sources/index.js.map +1 -0
- package/dist/sources/types.d.ts +15 -0
- package/dist/sources/types.d.ts.map +1 -0
- package/dist/sources/types.js +3 -0
- package/dist/sources/types.js.map +1 -0
- package/dist/sources/vcs.d.ts +13 -0
- package/dist/sources/vcs.d.ts.map +1 -0
- package/dist/sources/vcs.js +25 -0
- package/dist/sources/vcs.js.map +1 -0
- package/dist/telemetry.d.ts +129 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +192 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/vcs/bitbucket.d.ts +11 -0
- package/dist/vcs/bitbucket.d.ts.map +1 -0
- package/dist/vcs/bitbucket.js +43 -0
- package/dist/vcs/bitbucket.js.map +1 -0
- package/dist/vcs/github.d.ts +11 -0
- package/dist/vcs/github.d.ts.map +1 -0
- package/dist/vcs/github.js +35 -0
- package/dist/vcs/github.js.map +1 -0
- package/dist/vcs/gitlab.d.ts +11 -0
- package/dist/vcs/gitlab.d.ts.map +1 -0
- package/dist/vcs/gitlab.js +36 -0
- package/dist/vcs/gitlab.js.map +1 -0
- package/dist/vcs/index.d.ts +8 -0
- package/dist/vcs/index.d.ts.map +1 -0
- package/dist/vcs/index.js +27 -0
- package/dist/vcs/index.js.map +1 -0
- package/dist/vcs/types.d.ts +29 -0
- package/dist/vcs/types.d.ts.map +1 -0
- package/dist/vcs/types.js +3 -0
- package/dist/vcs/types.js.map +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decrypts age-encrypted ciphertext using the age-encryption npm package.
|
|
3
|
+
*
|
|
4
|
+
* Follows the same dynamic import pattern as the bundle runtime to handle
|
|
5
|
+
* the ESM-only age-encryption package from CJS context.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AgeDecryptor {
|
|
8
|
+
/**
|
|
9
|
+
* Decrypt an age-encrypted PEM-armored ciphertext string.
|
|
10
|
+
*
|
|
11
|
+
* @param ciphertext - PEM-armored age ciphertext.
|
|
12
|
+
* @param privateKey - Age private key string (AGE-SECRET-KEY-...).
|
|
13
|
+
* @returns The decrypted plaintext string.
|
|
14
|
+
*/
|
|
15
|
+
decrypt(ciphertext: string, privateKey: string): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the age private key from either an inline value or a file path.
|
|
18
|
+
*
|
|
19
|
+
* @param ageKey - Inline age private key, if set.
|
|
20
|
+
* @param ageKeyFile - Path to age key file, if set.
|
|
21
|
+
* @returns The age private key string.
|
|
22
|
+
*/
|
|
23
|
+
resolveKey(ageKey?: string, ageKeyFile?: string): string;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=decrypt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decrypt.d.ts","sourceRoot":"","sources":["../src/decrypt.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,qBAAa,YAAY;IACvB;;;;;;OAMG;IACG,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQtE;;;;;;OAMG;IACH,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM;CAazD"}
|
package/dist/decrypt.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
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.AgeDecryptor = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
/**
|
|
39
|
+
* Decrypts age-encrypted ciphertext using the age-encryption npm package.
|
|
40
|
+
*
|
|
41
|
+
* Follows the same dynamic import pattern as the bundle runtime to handle
|
|
42
|
+
* the ESM-only age-encryption package from CJS context.
|
|
43
|
+
*/
|
|
44
|
+
class AgeDecryptor {
|
|
45
|
+
/**
|
|
46
|
+
* Decrypt an age-encrypted PEM-armored ciphertext string.
|
|
47
|
+
*
|
|
48
|
+
* @param ciphertext - PEM-armored age ciphertext.
|
|
49
|
+
* @param privateKey - Age private key string (AGE-SECRET-KEY-...).
|
|
50
|
+
* @returns The decrypted plaintext string.
|
|
51
|
+
*/
|
|
52
|
+
async decrypt(ciphertext, privateKey) {
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- dynamic ESM import of CJS-incompatible package
|
|
54
|
+
const { Decrypter } = await Promise.resolve(`${"age-encryption"}`).then(s => __importStar(require(s)));
|
|
55
|
+
const d = new Decrypter();
|
|
56
|
+
d.addIdentity(privateKey);
|
|
57
|
+
return d.decrypt(ciphertext, "text");
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Resolve the age private key from either an inline value or a file path.
|
|
61
|
+
*
|
|
62
|
+
* @param ageKey - Inline age private key, if set.
|
|
63
|
+
* @param ageKeyFile - Path to age key file, if set.
|
|
64
|
+
* @returns The age private key string.
|
|
65
|
+
*/
|
|
66
|
+
resolveKey(ageKey, ageKeyFile) {
|
|
67
|
+
if (ageKey)
|
|
68
|
+
return ageKey.trim();
|
|
69
|
+
if (ageKeyFile) {
|
|
70
|
+
const content = fs.readFileSync(ageKeyFile, "utf-8").trim();
|
|
71
|
+
// age key files can contain comments — extract the actual key line
|
|
72
|
+
const lines = content.split("\n").filter((l) => l.startsWith("AGE-SECRET-KEY-"));
|
|
73
|
+
if (lines.length === 0) {
|
|
74
|
+
throw new Error(`No age secret key found in file: ${ageKeyFile}`);
|
|
75
|
+
}
|
|
76
|
+
return lines[0].trim();
|
|
77
|
+
}
|
|
78
|
+
throw new Error("No age key available. Set CLEF_AGE_KEY or CLEF_AGE_KEY_FILE.");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.AgeDecryptor = AgeDecryptor;
|
|
82
|
+
//# sourceMappingURL=decrypt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decrypt.js","sourceRoot":"","sources":["../src/decrypt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;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
* from VCS API failures by falling back to the last known good artifact.
|
|
6
|
+
*/
|
|
7
|
+
export declare class DiskCache {
|
|
8
|
+
private readonly artifactPath;
|
|
9
|
+
private readonly metaPath;
|
|
10
|
+
constructor(cachePath: string, identity: string, environment: string);
|
|
11
|
+
/** Write an artifact and optional metadata to disk (atomic via tmp+rename). */
|
|
12
|
+
write(raw: string, sha?: string): void;
|
|
13
|
+
/** Read the cached artifact. Returns null if no cache file exists. */
|
|
14
|
+
read(): string | null;
|
|
15
|
+
/** Get the SHA from the cached metadata, if available. */
|
|
16
|
+
getCachedSha(): string | undefined;
|
|
17
|
+
/** Get the fetchedAt timestamp from metadata, if available. */
|
|
18
|
+
getFetchedAt(): string | undefined;
|
|
19
|
+
/** Remove cached artifact and metadata files. */
|
|
20
|
+
purge(): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=disk-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disk-cache.d.ts","sourceRoot":"","sources":["../src/disk-cache.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAEtB,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAMpE,+EAA+E;IAC/E,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI;IActC,sEAAsE;IACtE,IAAI,IAAI,MAAM,GAAG,IAAI;IAQrB,0DAA0D;IAC1D,YAAY,IAAI,MAAM,GAAG,SAAS;IAUlC,+DAA+D;IAC/D,YAAY,IAAI,MAAM,GAAG,SAAS;IAUlC,iDAAiD;IACjD,KAAK,IAAI,IAAI;CAYd"}
|
|
@@ -0,0 +1,113 @@
|
|
|
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.DiskCache = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
/**
|
|
40
|
+
* Disk-based cache for artifact fallback.
|
|
41
|
+
*
|
|
42
|
+
* Writes artifact JSON and metadata to disk so the runtime can recover
|
|
43
|
+
* from VCS API failures by falling back to the last known good artifact.
|
|
44
|
+
*/
|
|
45
|
+
class DiskCache {
|
|
46
|
+
artifactPath;
|
|
47
|
+
metaPath;
|
|
48
|
+
constructor(cachePath, identity, environment) {
|
|
49
|
+
const dir = path.join(cachePath, identity);
|
|
50
|
+
this.artifactPath = path.join(dir, `${environment}.age.json`);
|
|
51
|
+
this.metaPath = path.join(dir, `${environment}.meta`);
|
|
52
|
+
}
|
|
53
|
+
/** Write an artifact and optional metadata to disk (atomic via tmp+rename). */
|
|
54
|
+
write(raw, sha) {
|
|
55
|
+
const dir = path.dirname(this.artifactPath);
|
|
56
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
57
|
+
const tmpArtifact = `${this.artifactPath}.tmp.${process.pid}`;
|
|
58
|
+
fs.writeFileSync(tmpArtifact, raw, "utf-8");
|
|
59
|
+
fs.renameSync(tmpArtifact, this.artifactPath);
|
|
60
|
+
const meta = { sha, fetchedAt: new Date().toISOString() };
|
|
61
|
+
const tmpMeta = `${this.metaPath}.tmp.${process.pid}`;
|
|
62
|
+
fs.writeFileSync(tmpMeta, JSON.stringify(meta), "utf-8");
|
|
63
|
+
fs.renameSync(tmpMeta, this.metaPath);
|
|
64
|
+
}
|
|
65
|
+
/** Read the cached artifact. Returns null if no cache file exists. */
|
|
66
|
+
read() {
|
|
67
|
+
try {
|
|
68
|
+
return fs.readFileSync(this.artifactPath, "utf-8");
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** Get the SHA from the cached metadata, if available. */
|
|
75
|
+
getCachedSha() {
|
|
76
|
+
try {
|
|
77
|
+
const raw = fs.readFileSync(this.metaPath, "utf-8");
|
|
78
|
+
const meta = JSON.parse(raw);
|
|
79
|
+
return meta.sha;
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** Get the fetchedAt timestamp from metadata, if available. */
|
|
86
|
+
getFetchedAt() {
|
|
87
|
+
try {
|
|
88
|
+
const raw = fs.readFileSync(this.metaPath, "utf-8");
|
|
89
|
+
const meta = JSON.parse(raw);
|
|
90
|
+
return meta.fetchedAt;
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** Remove cached artifact and metadata files. */
|
|
97
|
+
purge() {
|
|
98
|
+
try {
|
|
99
|
+
fs.unlinkSync(this.artifactPath);
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
// ENOENT is fine
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
fs.unlinkSync(this.metaPath);
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// ENOENT is fine
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.DiskCache = DiskCache;
|
|
113
|
+
//# sourceMappingURL=disk-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disk-cache.js","sourceRoot":"","sources":["../src/disk-cache.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAO7B;;;;;GAKG;AACH,MAAa,SAAS;IACH,YAAY,CAAS;IACrB,QAAQ,CAAS;IAElC,YAAY,SAAiB,EAAE,QAAgB,EAAE,WAAmB;QAClE,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAC3C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,WAAW,WAAW,CAAC,CAAC;QAC9D,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,WAAW,OAAO,CAAC,CAAC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AAC;YAC7D,OAAO,IAAI,CAAC,GAAG,CAAC;QAClB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED,+DAA+D;IAC/D,YAAY;QACV,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACpD,MAAM,IAAI,GAAkB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAkB,CAAC;YAC7D,OAAO,IAAI,CAAC,SAAS,CAAC;QACxB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED,iDAAiD;IACjD,KAAK;QACH,IAAI,CAAC;YACH,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACnC,CAAC;QAAC,MAAM,CAAC;YACP,iBAAiB;QACnB,CAAC;QACD,IAAI,CAAC;YACH,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACP,iBAAiB;QACnB,CAAC;IACH,CAAC;CACF;AArED,8BAqEC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export { SecretsCache } from "./secrets-cache";
|
|
2
|
+
export { DiskCache } from "./disk-cache";
|
|
3
|
+
export { AgeDecryptor } from "./decrypt";
|
|
4
|
+
export { ArtifactPoller } from "./poller";
|
|
5
|
+
export type { PollerOptions, ArtifactEnvelope } from "./poller";
|
|
6
|
+
export { TelemetryEmitter } from "./telemetry";
|
|
7
|
+
export type { TelemetryOptions, TelemetryEvent, AgentStartedEvent, AgentStoppedEvent, ArtifactRefreshedEvent, ArtifactRevokedEvent, ArtifactExpiredEvent, FetchFailedEvent, CacheExpiredEvent, ArtifactInvalidEvent, } from "./telemetry";
|
|
8
|
+
export type { VcsProvider, VcsProviderConfig, VcsFileResult } from "./vcs/types";
|
|
9
|
+
export { GitHubProvider } from "./vcs/github";
|
|
10
|
+
export { GitLabProvider } from "./vcs/gitlab";
|
|
11
|
+
export { BitbucketProvider } from "./vcs/bitbucket";
|
|
12
|
+
export { createVcsProvider } from "./vcs/index";
|
|
13
|
+
export type { KmsProvider, KmsWrapResult, KmsProviderType } from "./kms";
|
|
14
|
+
export { AwsKmsProvider } from "./kms";
|
|
15
|
+
export { createKmsProvider } from "./kms";
|
|
16
|
+
export type { ArtifactSource, ArtifactFetchResult } from "./sources/types";
|
|
17
|
+
export { HttpArtifactSource } from "./sources/http";
|
|
18
|
+
export { FileArtifactSource } from "./sources/file";
|
|
19
|
+
export { VcsArtifactSource } from "./sources/vcs";
|
|
20
|
+
import { SecretsCache } from "./secrets-cache";
|
|
21
|
+
import { ArtifactPoller } from "./poller";
|
|
22
|
+
import { TelemetryEmitter } from "./telemetry";
|
|
23
|
+
/**
|
|
24
|
+
* Configuration for {@link ClefRuntime}.
|
|
25
|
+
*
|
|
26
|
+
* Supply **either** VCS fields (`provider`, `repo`, `token`, `identity`, `environment`)
|
|
27
|
+
* **or** a `source` URL/path. VCS is the recommended approach — the runtime fetches
|
|
28
|
+
* packed artifacts directly from your git repository via the provider API.
|
|
29
|
+
*/
|
|
30
|
+
export interface RuntimeConfig {
|
|
31
|
+
/** VCS platform: `"github"`, `"gitlab"`, or `"bitbucket"`. */
|
|
32
|
+
provider?: "github" | "gitlab" | "bitbucket";
|
|
33
|
+
/** Repository identifier, e.g. `"org/secrets"`. */
|
|
34
|
+
repo?: string;
|
|
35
|
+
/** Service identity name as declared in `clef.yaml`. */
|
|
36
|
+
identity?: string;
|
|
37
|
+
/** Target environment (e.g. `"production"`). */
|
|
38
|
+
environment?: string;
|
|
39
|
+
/** VCS authentication token (GitHub PAT, GitLab PAT, Bitbucket app password). */
|
|
40
|
+
token?: string;
|
|
41
|
+
/** Git ref — branch, tag, or commit SHA. Defaults to the repo's default branch. */
|
|
42
|
+
ref?: string;
|
|
43
|
+
/** Custom VCS API base URL for self-hosted instances. */
|
|
44
|
+
apiUrl?: string;
|
|
45
|
+
/** HTTP URL or local file path to a packed artifact (alternative to VCS). */
|
|
46
|
+
source?: string;
|
|
47
|
+
/** Inline age private key (`AGE-SECRET-KEY-...`). */
|
|
48
|
+
ageKey?: string;
|
|
49
|
+
/** Path to an age key file. */
|
|
50
|
+
ageKeyFile?: string;
|
|
51
|
+
/** Disk cache directory. Enables fallback to the last fetched artifact on VCS failure. */
|
|
52
|
+
cachePath?: string;
|
|
53
|
+
/** Max seconds the runtime serves secrets without a successful refresh. */
|
|
54
|
+
cacheTtl?: number;
|
|
55
|
+
/** Optional telemetry emitter for event reporting. */
|
|
56
|
+
telemetry?: TelemetryEmitter;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* High-level runtime for fetching and caching secrets.
|
|
60
|
+
*
|
|
61
|
+
* Supports VCS providers (GitHub, GitLab, Bitbucket), HTTP URLs, and
|
|
62
|
+
* local file sources. Decrypts age-encrypted artifacts and serves
|
|
63
|
+
* secrets from an in-memory cache with optional background polling.
|
|
64
|
+
*/
|
|
65
|
+
export declare class ClefRuntime {
|
|
66
|
+
private readonly cache;
|
|
67
|
+
private readonly poller;
|
|
68
|
+
private readonly config;
|
|
69
|
+
constructor(config: RuntimeConfig);
|
|
70
|
+
/** Initial fetch + decrypt. Must be called before get/getAll. */
|
|
71
|
+
start(): Promise<void>;
|
|
72
|
+
/** Start background polling. Schedule is derived from artifact expiresAt or cacheTtl. */
|
|
73
|
+
startPolling(): void;
|
|
74
|
+
/** Stop background polling. */
|
|
75
|
+
stopPolling(): void;
|
|
76
|
+
/** Get a single secret value by key. */
|
|
77
|
+
get(key: string): string | undefined;
|
|
78
|
+
/** Get all secrets as key-value map. */
|
|
79
|
+
getAll(): Record<string, string>;
|
|
80
|
+
/** Alias for getAll() — convenience for env injection. */
|
|
81
|
+
env(): Record<string, string>;
|
|
82
|
+
/** List available key names. */
|
|
83
|
+
keys(): string[];
|
|
84
|
+
/** Current artifact revision. */
|
|
85
|
+
get revision(): string;
|
|
86
|
+
/** Whether secrets have been loaded. */
|
|
87
|
+
get ready(): boolean;
|
|
88
|
+
/** Get the underlying poller (for agent integration). */
|
|
89
|
+
getPoller(): ArtifactPoller;
|
|
90
|
+
/** Get the underlying cache (for agent integration). */
|
|
91
|
+
getCache(): SecretsCache;
|
|
92
|
+
private resolveSource;
|
|
93
|
+
}
|
|
94
|
+
/** Convenience one-shot function (no polling). Initializes and returns a ready runtime. */
|
|
95
|
+
export declare function init(config: RuntimeConfig): Promise<ClefRuntime>;
|
|
96
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAGrB,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAA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AA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,sDAAsD;IACtD,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsB;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;gBAE3B,MAAM,EAAE,aAAa;IA+BjC,iEAAiE;IAC3D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,yFAAyF;IACzF,YAAY,IAAI,IAAI;IAIpB,+BAA+B;IAC/B,WAAW,IAAI,IAAI;IAInB,wCAAwC;IACxC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIpC,wCAAwC;IACxC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIhC,0DAA0D;IAC1D,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAI7B,gCAAgC;IAChC,IAAI,IAAI,MAAM,EAAE;IAIhB,iCAAiC;IACjC,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,wCAAwC;IACxC,IAAI,KAAK,IAAI,OAAO,CAEnB;IAED,yDAAyD;IACzD,SAAS,IAAI,cAAc;IAI3B,wDAAwD;IACxD,QAAQ,IAAI,YAAY;IAIxB,OAAO,CAAC,aAAa;CA0CtB;AAED,2FAA2F;AAC3F,wBAAsB,IAAI,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,CAItE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClefRuntime = exports.VcsArtifactSource = exports.FileArtifactSource = exports.HttpArtifactSource = exports.createKmsProvider = exports.AwsKmsProvider = exports.createVcsProvider = exports.BitbucketProvider = exports.GitLabProvider = exports.GitHubProvider = exports.TelemetryEmitter = exports.ArtifactPoller = exports.AgeDecryptor = exports.DiskCache = exports.SecretsCache = void 0;
|
|
4
|
+
exports.init = init;
|
|
5
|
+
// Core modules
|
|
6
|
+
var secrets_cache_1 = require("./secrets-cache");
|
|
7
|
+
Object.defineProperty(exports, "SecretsCache", { enumerable: true, get: function () { return secrets_cache_1.SecretsCache; } });
|
|
8
|
+
var disk_cache_1 = require("./disk-cache");
|
|
9
|
+
Object.defineProperty(exports, "DiskCache", { enumerable: true, get: function () { return disk_cache_1.DiskCache; } });
|
|
10
|
+
var decrypt_1 = require("./decrypt");
|
|
11
|
+
Object.defineProperty(exports, "AgeDecryptor", { enumerable: true, get: function () { return decrypt_1.AgeDecryptor; } });
|
|
12
|
+
var poller_1 = require("./poller");
|
|
13
|
+
Object.defineProperty(exports, "ArtifactPoller", { enumerable: true, get: function () { return poller_1.ArtifactPoller; } });
|
|
14
|
+
// Telemetry
|
|
15
|
+
var telemetry_1 = require("./telemetry");
|
|
16
|
+
Object.defineProperty(exports, "TelemetryEmitter", { enumerable: true, get: function () { return telemetry_1.TelemetryEmitter; } });
|
|
17
|
+
var github_1 = require("./vcs/github");
|
|
18
|
+
Object.defineProperty(exports, "GitHubProvider", { enumerable: true, get: function () { return github_1.GitHubProvider; } });
|
|
19
|
+
var gitlab_1 = require("./vcs/gitlab");
|
|
20
|
+
Object.defineProperty(exports, "GitLabProvider", { enumerable: true, get: function () { return gitlab_1.GitLabProvider; } });
|
|
21
|
+
var bitbucket_1 = require("./vcs/bitbucket");
|
|
22
|
+
Object.defineProperty(exports, "BitbucketProvider", { enumerable: true, get: function () { return bitbucket_1.BitbucketProvider; } });
|
|
23
|
+
var index_1 = require("./vcs/index");
|
|
24
|
+
Object.defineProperty(exports, "createVcsProvider", { enumerable: true, get: function () { return index_1.createVcsProvider; } });
|
|
25
|
+
var kms_1 = require("./kms");
|
|
26
|
+
Object.defineProperty(exports, "AwsKmsProvider", { enumerable: true, get: function () { return kms_1.AwsKmsProvider; } });
|
|
27
|
+
var kms_2 = require("./kms");
|
|
28
|
+
Object.defineProperty(exports, "createKmsProvider", { enumerable: true, get: function () { return kms_2.createKmsProvider; } });
|
|
29
|
+
var http_1 = require("./sources/http");
|
|
30
|
+
Object.defineProperty(exports, "HttpArtifactSource", { enumerable: true, get: function () { return http_1.HttpArtifactSource; } });
|
|
31
|
+
var file_1 = require("./sources/file");
|
|
32
|
+
Object.defineProperty(exports, "FileArtifactSource", { enumerable: true, get: function () { return file_1.FileArtifactSource; } });
|
|
33
|
+
var vcs_1 = require("./sources/vcs");
|
|
34
|
+
Object.defineProperty(exports, "VcsArtifactSource", { enumerable: true, get: function () { return vcs_1.VcsArtifactSource; } });
|
|
35
|
+
// High-level API
|
|
36
|
+
const secrets_cache_2 = require("./secrets-cache");
|
|
37
|
+
const disk_cache_2 = require("./disk-cache");
|
|
38
|
+
const decrypt_2 = require("./decrypt");
|
|
39
|
+
const poller_2 = require("./poller");
|
|
40
|
+
const index_2 = require("./vcs/index");
|
|
41
|
+
const vcs_2 = require("./sources/vcs");
|
|
42
|
+
const http_2 = require("./sources/http");
|
|
43
|
+
const file_2 = require("./sources/file");
|
|
44
|
+
/**
|
|
45
|
+
* High-level runtime for fetching and caching secrets.
|
|
46
|
+
*
|
|
47
|
+
* Supports VCS providers (GitHub, GitLab, Bitbucket), HTTP URLs, and
|
|
48
|
+
* local file sources. Decrypts age-encrypted artifacts and serves
|
|
49
|
+
* secrets from an in-memory cache with optional background polling.
|
|
50
|
+
*/
|
|
51
|
+
class ClefRuntime {
|
|
52
|
+
cache = new secrets_cache_2.SecretsCache();
|
|
53
|
+
poller;
|
|
54
|
+
config;
|
|
55
|
+
constructor(config) {
|
|
56
|
+
this.config = config;
|
|
57
|
+
// Age key is optional — KMS envelope artifacts don't need one
|
|
58
|
+
let privateKey;
|
|
59
|
+
try {
|
|
60
|
+
const decryptor = new decrypt_2.AgeDecryptor();
|
|
61
|
+
privateKey = decryptor.resolveKey(config.ageKey, config.ageKeyFile);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// OK — will work if artifact uses KMS envelope encryption
|
|
65
|
+
}
|
|
66
|
+
const source = this.resolveSource(config);
|
|
67
|
+
const diskCache = config.cachePath
|
|
68
|
+
? new disk_cache_2.DiskCache(config.cachePath, config.identity ?? "default", config.environment ?? "default")
|
|
69
|
+
: undefined;
|
|
70
|
+
this.poller = new poller_2.ArtifactPoller({
|
|
71
|
+
source,
|
|
72
|
+
privateKey,
|
|
73
|
+
cache: this.cache,
|
|
74
|
+
diskCache,
|
|
75
|
+
cacheTtl: config.cacheTtl,
|
|
76
|
+
telemetry: config.telemetry,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/** Initial fetch + decrypt. Must be called before get/getAll. */
|
|
80
|
+
async start() {
|
|
81
|
+
await this.poller.fetchAndDecrypt();
|
|
82
|
+
}
|
|
83
|
+
/** Start background polling. Schedule is derived from artifact expiresAt or cacheTtl. */
|
|
84
|
+
startPolling() {
|
|
85
|
+
this.poller.startPolling();
|
|
86
|
+
}
|
|
87
|
+
/** Stop background polling. */
|
|
88
|
+
stopPolling() {
|
|
89
|
+
this.poller.stop();
|
|
90
|
+
}
|
|
91
|
+
/** Get a single secret value by key. */
|
|
92
|
+
get(key) {
|
|
93
|
+
return this.cache.get(key);
|
|
94
|
+
}
|
|
95
|
+
/** Get all secrets as key-value map. */
|
|
96
|
+
getAll() {
|
|
97
|
+
return this.cache.getAll() ?? {};
|
|
98
|
+
}
|
|
99
|
+
/** Alias for getAll() — convenience for env injection. */
|
|
100
|
+
env() {
|
|
101
|
+
return this.getAll();
|
|
102
|
+
}
|
|
103
|
+
/** List available key names. */
|
|
104
|
+
keys() {
|
|
105
|
+
return this.cache.getKeys();
|
|
106
|
+
}
|
|
107
|
+
/** Current artifact revision. */
|
|
108
|
+
get revision() {
|
|
109
|
+
return this.cache.getRevision() ?? "";
|
|
110
|
+
}
|
|
111
|
+
/** Whether secrets have been loaded. */
|
|
112
|
+
get ready() {
|
|
113
|
+
return this.cache.isReady();
|
|
114
|
+
}
|
|
115
|
+
/** Get the underlying poller (for agent integration). */
|
|
116
|
+
getPoller() {
|
|
117
|
+
return this.poller;
|
|
118
|
+
}
|
|
119
|
+
/** Get the underlying cache (for agent integration). */
|
|
120
|
+
getCache() {
|
|
121
|
+
return this.cache;
|
|
122
|
+
}
|
|
123
|
+
resolveSource(config) {
|
|
124
|
+
// VCS source
|
|
125
|
+
const vcsFields = {
|
|
126
|
+
provider: config.provider,
|
|
127
|
+
repo: config.repo,
|
|
128
|
+
token: config.token,
|
|
129
|
+
identity: config.identity,
|
|
130
|
+
environment: config.environment,
|
|
131
|
+
};
|
|
132
|
+
const presentVcs = Object.entries(vcsFields).filter(([, v]) => !!v);
|
|
133
|
+
const missingVcs = Object.entries(vcsFields).filter(([, v]) => !v);
|
|
134
|
+
if (presentVcs.length > 0 && missingVcs.length > 0) {
|
|
135
|
+
const missing = missingVcs.map(([k]) => k).join(", ");
|
|
136
|
+
throw new Error(`Partial VCS config detected. Missing: ${missing}. Provide all VCS fields (provider, repo, token, identity, environment) or use a source URL/path instead.`);
|
|
137
|
+
}
|
|
138
|
+
if (presentVcs.length === Object.keys(vcsFields).length) {
|
|
139
|
+
const provider = (0, index_2.createVcsProvider)({
|
|
140
|
+
provider: config.provider,
|
|
141
|
+
repo: config.repo,
|
|
142
|
+
token: config.token,
|
|
143
|
+
ref: config.ref,
|
|
144
|
+
apiUrl: config.apiUrl,
|
|
145
|
+
});
|
|
146
|
+
return new vcs_2.VcsArtifactSource(provider, config.identity, config.environment);
|
|
147
|
+
}
|
|
148
|
+
// HTTP or file source
|
|
149
|
+
if (config.source) {
|
|
150
|
+
if (config.source.startsWith("http://") || config.source.startsWith("https://")) {
|
|
151
|
+
return new http_2.HttpArtifactSource(config.source);
|
|
152
|
+
}
|
|
153
|
+
return new file_2.FileArtifactSource(config.source);
|
|
154
|
+
}
|
|
155
|
+
throw new Error("No artifact source configured. Provide VCS config (provider, repo, token, identity, environment) or a source URL/path.");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
exports.ClefRuntime = ClefRuntime;
|
|
159
|
+
/** Convenience one-shot function (no polling). Initializes and returns a ready runtime. */
|
|
160
|
+
async function init(config) {
|
|
161
|
+
const runtime = new ClefRuntime(config);
|
|
162
|
+
await runtime.start();
|
|
163
|
+
return runtime;
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AA2OA,oBAIC;AA/OD,eAAe;AACf,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,qCAAyC;AAAhC,uGAAA,YAAY,OAAA;AACrB,mCAA0C;AAAjC,wGAAA,cAAc,OAAA;AAGvB,YAAY;AACZ,yCAA+C;AAAtC,6GAAA,gBAAgB,OAAA;AAgBzB,uCAA8C;AAArC,wGAAA,cAAc,OAAA;AACvB,uCAA8C;AAArC,wGAAA,cAAc,OAAA;AACvB,6CAAoD;AAA3C,8GAAA,iBAAiB,OAAA;AAC1B,qCAAgD;AAAvC,0GAAA,iBAAiB,OAAA;AAI1B,6BAAuC;AAA9B,qGAAA,cAAc,OAAA;AACvB,6BAA0C;AAAjC,wGAAA,iBAAiB,OAAA;AAI1B,uCAAoD;AAA3C,0GAAA,kBAAkB,OAAA;AAC3B,uCAAoD;AAA3C,0GAAA,kBAAkB,OAAA;AAC3B,qCAAkD;AAAzC,wGAAA,iBAAiB,OAAA;AAE1B,iBAAiB;AACjB,mDAA+C;AAC/C,6CAAyC;AACzC,uCAAyC;AACzC,qCAA0C;AAC1C,uCAAgD;AAChD,uCAAkD;AAClD,yCAAoD;AACpD,yCAAoD;AA4CpD;;;;;;GAMG;AACH,MAAa,WAAW;IACL,KAAK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IAC9C,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;IACtB,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { KmsProvider, KmsWrapResult } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* AWS KMS provider for envelope encryption.
|
|
4
|
+
* Dynamically imports `@aws-sdk/client-kms` — the SDK is an optional dependency.
|
|
5
|
+
*/
|
|
6
|
+
export declare class AwsKmsProvider implements KmsProvider {
|
|
7
|
+
private client;
|
|
8
|
+
private sdk;
|
|
9
|
+
private readonly region?;
|
|
10
|
+
constructor(region?: string);
|
|
11
|
+
private ensureClient;
|
|
12
|
+
wrap(keyId: string, plaintext: Buffer): Promise<KmsWrapResult>;
|
|
13
|
+
unwrap(keyId: string, wrappedKey: Buffer, algorithm: string): Promise<Buffer>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=aws.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aws.d.ts","sourceRoot":"","sources":["../../src/kms/aws.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAErD;;;GAGG;AACH,qBAAa,cAAe,YAAW,WAAW;IAEhD,OAAO,CAAC,MAAM,CAAM;IAEpB,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAS;gBAErB,MAAM,CAAC,EAAE,MAAM;YAIb,YAAY;IAYpB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAmB9D,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAepF"}
|
package/dist/kms/aws.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
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.AwsKmsProvider = void 0;
|
|
37
|
+
/**
|
|
38
|
+
* AWS KMS provider for envelope encryption.
|
|
39
|
+
* Dynamically imports `@aws-sdk/client-kms` — the SDK is an optional dependency.
|
|
40
|
+
*/
|
|
41
|
+
class AwsKmsProvider {
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- lazy-loaded SDK client
|
|
43
|
+
client;
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- lazy-loaded SDK module
|
|
45
|
+
sdk;
|
|
46
|
+
region;
|
|
47
|
+
constructor(region) {
|
|
48
|
+
this.region = region;
|
|
49
|
+
}
|
|
50
|
+
async ensureClient() {
|
|
51
|
+
if (this.client)
|
|
52
|
+
return;
|
|
53
|
+
try {
|
|
54
|
+
this.sdk = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-kms")));
|
|
55
|
+
this.client = new this.sdk.KMSClient({ region: this.region });
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
throw new Error("AWS KMS requires @aws-sdk/client-kms. Install it with: npm install @aws-sdk/client-kms");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async wrap(keyId, plaintext) {
|
|
62
|
+
await this.ensureClient();
|
|
63
|
+
const command = new this.sdk.EncryptCommand({
|
|
64
|
+
KeyId: keyId,
|
|
65
|
+
Plaintext: plaintext,
|
|
66
|
+
EncryptionAlgorithm: "SYMMETRIC_DEFAULT",
|
|
67
|
+
});
|
|
68
|
+
const response = await this.client.send(command);
|
|
69
|
+
if (!response.CiphertextBlob) {
|
|
70
|
+
throw new Error("AWS KMS Encrypt returned no ciphertext.");
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
wrappedKey: Buffer.from(response.CiphertextBlob),
|
|
74
|
+
algorithm: "SYMMETRIC_DEFAULT",
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
async unwrap(keyId, wrappedKey, algorithm) {
|
|
78
|
+
await this.ensureClient();
|
|
79
|
+
const command = new this.sdk.DecryptCommand({
|
|
80
|
+
KeyId: keyId,
|
|
81
|
+
CiphertextBlob: wrappedKey,
|
|
82
|
+
EncryptionAlgorithm: algorithm,
|
|
83
|
+
});
|
|
84
|
+
const response = await this.client.send(command);
|
|
85
|
+
if (!response.Plaintext) {
|
|
86
|
+
throw new Error("AWS KMS Decrypt returned no plaintext.");
|
|
87
|
+
}
|
|
88
|
+
return Buffer.from(response.Plaintext);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.AwsKmsProvider = AwsKmsProvider;
|
|
92
|
+
//# sourceMappingURL=aws.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aws.js","sourceRoot":"","sources":["../../src/kms/aws.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;;GAGG;AACH,MAAa,cAAc;IACzB,wFAAwF;IAChF,MAAM,CAAM;IACpB,wFAAwF;IAChF,GAAG,CAAM;IACA,MAAM,CAAU;IAEjC,YAAY,MAAe;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,YAAY;QACxB,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QACxB,IAAI,CAAC;YACH,IAAI,CAAC,GAAG,GAAG,wDAAa,qBAAqB,GAAC,CAAC;YAC/C,IAAI,CAAC,MAAM,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAChE,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,KAAK,CACb,wFAAwF,CACzF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAa,EAAE,SAAiB;QACzC,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QAC1B,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC;YAC1C,KAAK,EAAE,KAAK;YACZ,SAAS,EAAE,SAAS;YACpB,m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