@sebastienrousseau/crypto-kms 0.0.8 → 0.0.24
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/providers/aws.d.ts +8 -0
- package/dist/providers/aws.d.ts.map +1 -1
- package/dist/providers/aws.js +14 -6
- package/dist/providers/gcp.d.ts +25 -12
- package/dist/providers/gcp.d.ts.map +1 -1
- package/dist/providers/gcp.js +207 -25
- package/dist/providers/local.d.ts +8 -0
- package/dist/providers/local.d.ts.map +1 -1
- package/dist/providers/local.js +8 -0
- package/dist/providers/vault.d.ts +25 -12
- package/dist/providers/vault.d.ts.map +1 -1
- package/dist/providers/vault.js +196 -27
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +13 -11
package/dist/providers/aws.d.ts
CHANGED
|
@@ -32,5 +32,13 @@ export declare class AwsKmsProvider implements KmsProvider {
|
|
|
32
32
|
plaintext: Uint8Array;
|
|
33
33
|
ciphertext: string;
|
|
34
34
|
}>;
|
|
35
|
+
wrapKey(keyId: string, unwrappedKey: Uint8Array, context?: Record<string, string>): Promise<{
|
|
36
|
+
wrappedKey: string;
|
|
37
|
+
keyId: string;
|
|
38
|
+
}>;
|
|
39
|
+
unwrapKey(keyId: string, wrappedKey: string, context?: Record<string, string>): Promise<{
|
|
40
|
+
unwrappedKey: Uint8Array;
|
|
41
|
+
keyId: string;
|
|
42
|
+
}>;
|
|
35
43
|
}
|
|
36
44
|
//# sourceMappingURL=aws.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aws.d.ts","sourceRoot":"","sources":["../../src/providers/aws.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACd,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"aws.d.ts","sourceRoot":"","sources":["../../src/providers/aws.ts"],"names":[],"mappings":"AAK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MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC,gBAAgB,CAAC;IAqBtB,OAAO,CACX,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC,gBAAgB,CAAC;IAiBtB,IAAI,CACR,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,UAAU,EAChB,SAAS,SAAuB,GAC/B,OAAO,CAAC,aAAa,CAAC;IAmBnB,MAAM,CACV,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,MAAM,EACjB,SAAS,SAAuB,GAC/B,OAAO,CAAC,OAAO,CAAC;IAgBb,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAQjD,eAAe,CACnB,KAAK,EAAE,MAAM,EACb,OAAO,SAAY,GAClB,OAAO,CAAC;QAET,SAAS,EAAE,UAAU,CAAC;QAEtB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IAgBI,OAAO,CACX,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,UAAU,EACxB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAM3C,SAAS,CACb,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC;QAAE,YAAY,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAIxD"}
|
package/dist/providers/aws.js
CHANGED
|
@@ -80,13 +80,13 @@ class AwsKmsProvider {
|
|
|
80
80
|
const client = await this.getClient();
|
|
81
81
|
const { DescribeKeyCommand } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-kms")));
|
|
82
82
|
const result = await client.send(new DescribeKeyCommand({ KeyId: keyId }));
|
|
83
|
-
const meta = result.KeyMetadata;
|
|
83
|
+
const meta = result.KeyMetadata ?? {};
|
|
84
84
|
return {
|
|
85
|
-
keyId: meta
|
|
86
|
-
algorithm: meta
|
|
87
|
-
usage: meta
|
|
88
|
-
createdAt: meta
|
|
89
|
-
enabled: meta
|
|
85
|
+
keyId: meta.KeyId ?? keyId,
|
|
86
|
+
algorithm: meta.KeySpec ?? "unknown",
|
|
87
|
+
usage: meta.KeyUsage === "SIGN_VERIFY" ? "sign" : "encrypt",
|
|
88
|
+
createdAt: meta.CreationDate?.toISOString() ?? new Date().toISOString(),
|
|
89
|
+
enabled: meta.Enabled ?? true,
|
|
90
90
|
provider: "aws",
|
|
91
91
|
};
|
|
92
92
|
}
|
|
@@ -209,6 +209,14 @@ class AwsKmsProvider {
|
|
|
209
209
|
ciphertext: Buffer.from(result.CiphertextBlob).toString("base64"),
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
|
+
async wrapKey(keyId, unwrappedKey, context) {
|
|
213
|
+
const enc = await this.encrypt(keyId, unwrappedKey, context);
|
|
214
|
+
return { wrappedKey: enc.ciphertext, keyId: enc.keyId };
|
|
215
|
+
}
|
|
216
|
+
async unwrapKey(keyId, wrappedKey, context) {
|
|
217
|
+
const dec = await this.decrypt(keyId, wrappedKey, context);
|
|
218
|
+
return { unwrappedKey: dec.plaintext, keyId: dec.keyId };
|
|
219
|
+
}
|
|
212
220
|
}
|
|
213
221
|
exports.AwsKmsProvider = AwsKmsProvider;
|
|
214
222
|
//# sourceMappingURL=aws.js.map
|
package/dist/providers/gcp.d.ts
CHANGED
|
@@ -3,29 +3,42 @@ export interface GcpKmsOptions {
|
|
|
3
3
|
projectId: string;
|
|
4
4
|
locationId: string;
|
|
5
5
|
keyRingId: string;
|
|
6
|
+
token?: string;
|
|
7
|
+
endpoint?: string;
|
|
6
8
|
}
|
|
7
9
|
export declare class GcpKmsProvider implements KmsProvider {
|
|
8
10
|
readonly name = "gcp";
|
|
9
11
|
private readonly options;
|
|
10
12
|
constructor(options: GcpKmsOptions);
|
|
11
13
|
private getParent;
|
|
12
|
-
|
|
14
|
+
private getKeyName;
|
|
15
|
+
private buildUrl;
|
|
16
|
+
private request;
|
|
17
|
+
listKeys(filters?: {
|
|
13
18
|
usage?: string;
|
|
14
19
|
enabled?: boolean;
|
|
15
20
|
}): Promise<KmsKeyMetadata[]>;
|
|
16
|
-
getKey(
|
|
17
|
-
createKey(
|
|
18
|
-
enableKey(
|
|
19
|
-
disableKey(
|
|
20
|
-
scheduleKeyDeletion(
|
|
21
|
-
encrypt(
|
|
22
|
-
decrypt(
|
|
23
|
-
sign(
|
|
24
|
-
verify(
|
|
25
|
-
rotateKey(
|
|
26
|
-
generateDataKey(
|
|
21
|
+
getKey(keyId: string): Promise<KmsKeyMetadata>;
|
|
22
|
+
createKey(algorithm: string, usage: "encrypt" | "sign" | "wrap", metadata?: Record<string, string>): Promise<KmsKeyMetadata>;
|
|
23
|
+
enableKey(keyId: string): Promise<void>;
|
|
24
|
+
disableKey(keyId: string): Promise<void>;
|
|
25
|
+
scheduleKeyDeletion(keyId: string, _pendingWindowDays?: number): Promise<void>;
|
|
26
|
+
encrypt(keyId: string, plaintext: Uint8Array, context?: Record<string, string>): Promise<KmsEncryptResult>;
|
|
27
|
+
decrypt(keyId: string, ciphertext: string, context?: Record<string, string>): Promise<KmsDecryptResult>;
|
|
28
|
+
sign(keyId: string, data: Uint8Array, algorithm?: string): Promise<KmsSignResult>;
|
|
29
|
+
verify(keyId: string, data: Uint8Array, signature: string, _algorithm?: string): Promise<boolean>;
|
|
30
|
+
rotateKey(keyId: string): Promise<KmsKeyMetadata>;
|
|
31
|
+
generateDataKey(keyId: string, keySpec?: string): Promise<{
|
|
27
32
|
plaintext: Uint8Array;
|
|
28
33
|
ciphertext: string;
|
|
29
34
|
}>;
|
|
35
|
+
wrapKey(keyId: string, unwrappedKey: Uint8Array, context?: Record<string, string>): Promise<{
|
|
36
|
+
wrappedKey: string;
|
|
37
|
+
keyId: string;
|
|
38
|
+
}>;
|
|
39
|
+
unwrapKey(keyId: string, wrappedKey: string, context?: Record<string, string>): Promise<{
|
|
40
|
+
unwrappedKey: Uint8Array;
|
|
41
|
+
keyId: string;
|
|
42
|
+
}>;
|
|
30
43
|
}
|
|
31
44
|
//# sourceMappingURL=gcp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gcp.d.ts","sourceRoot":"","sources":["../../src/providers/gcp.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACd,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"gcp.d.ts","sourceRoot":"","sources":["../../src/providers/gcp.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACd,MAAM,UAAU,CAAC;AAgBlB,MAAM,WAAW,aAAa;IAE5B,SAAS,EAAE,MAAM,CAAC;IAElB,UAAU,EAAE,MAAM,CAAC;IAEnB,SAAS,EAAE,MAAM,CAAC;IAElB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAoGD,qBAAa,cAAe,YAAW,WAAW;IAEhD,QAAQ,CAAC,IAAI,SAAS;IAEtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;gBAG5B,OAAO,EAAE,aAAa;IAKlC,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,UAAU;IAMlB,OAAO,CAAC,QAAQ;YAWF,OAAO;IAoCf,QAAQ,CAAC,OAAO,CAAC,EAAE;QACvB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,GAAG,OAAO,CAAC,cAA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AAU,CAAC;QACtB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IAYI,OAAO,CACX,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,UAAU,EACxB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAM3C,SAAS,CACb,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC;QAAE,YAAY,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAIxD"}
|
package/dist/providers/gcp.js
CHANGED
|
@@ -2,6 +2,57 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GcpKmsProvider = void 0;
|
|
4
4
|
const errors_1 = require("../errors");
|
|
5
|
+
function parseGcpResponse(text) {
|
|
6
|
+
if (!text)
|
|
7
|
+
return {};
|
|
8
|
+
try {
|
|
9
|
+
return JSON.parse(text);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function handleGcpError(res, json, keyId) {
|
|
16
|
+
const errMsg = json.error?.message ?? `HTTP ${res.status}`;
|
|
17
|
+
if (res.status === 404 || /not found/i.test(errMsg)) {
|
|
18
|
+
throw new errors_1.KmsError("NOT_FOUND", errMsg, keyId);
|
|
19
|
+
}
|
|
20
|
+
if (res.status === 400 && /decryption|ciphertext/i.test(errMsg)) {
|
|
21
|
+
throw new errors_1.KmsError("DECRYPTION_FAILED", errMsg, keyId);
|
|
22
|
+
}
|
|
23
|
+
if (/disabled|destroy/i.test(errMsg)) {
|
|
24
|
+
throw new errors_1.KmsError("DISABLED", errMsg, keyId);
|
|
25
|
+
}
|
|
26
|
+
throw new errors_1.KmsError("INVALID_ARGUMENT", `GCP KMS error: ${errMsg}`, keyId);
|
|
27
|
+
}
|
|
28
|
+
function mapGcpAlgorithm(algorithm, usage) {
|
|
29
|
+
const upper = algorithm.toUpperCase();
|
|
30
|
+
if (usage === "sign") {
|
|
31
|
+
if (upper.includes("EC") || upper.includes("P256")) {
|
|
32
|
+
return "EC_SIGN_P256_SHA256";
|
|
33
|
+
}
|
|
34
|
+
return "RSA_SIGN_PSS_2048_SHA256";
|
|
35
|
+
}
|
|
36
|
+
return "GOOGLE_SYMMETRIC_ENCRYPTION";
|
|
37
|
+
}
|
|
38
|
+
function extractGcpKeyId(fullName) {
|
|
39
|
+
if (!fullName)
|
|
40
|
+
return "";
|
|
41
|
+
const idx = fullName.lastIndexOf("/");
|
|
42
|
+
return idx >= 0 ? fullName.slice(idx + 1) : fullName;
|
|
43
|
+
}
|
|
44
|
+
function mapGcpKey(raw, fallbackId) {
|
|
45
|
+
const keyId = extractGcpKeyId(raw.name) || fallbackId;
|
|
46
|
+
const isSign = raw.purpose === "ASYMMETRIC_SIGN";
|
|
47
|
+
return {
|
|
48
|
+
keyId,
|
|
49
|
+
algorithm: raw.primary?.algorithm ?? "GOOGLE_SYMMETRIC_ENCRYPTION",
|
|
50
|
+
usage: isSign ? "sign" : "encrypt",
|
|
51
|
+
createdAt: raw.createTime ?? new Date().toISOString(),
|
|
52
|
+
enabled: raw.primary?.state !== "DISABLED" && raw.primary?.state !== "DESTROYED",
|
|
53
|
+
provider: "gcp",
|
|
54
|
+
};
|
|
55
|
+
}
|
|
5
56
|
class GcpKmsProvider {
|
|
6
57
|
name = "gcp";
|
|
7
58
|
options;
|
|
@@ -11,42 +62,173 @@ class GcpKmsProvider {
|
|
|
11
62
|
getParent() {
|
|
12
63
|
return `projects/${this.options.projectId}/locations/${this.options.locationId}/keyRings/${this.options.keyRingId}`;
|
|
13
64
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
65
|
+
getKeyName(keyId) {
|
|
66
|
+
if (keyId.startsWith("projects/"))
|
|
67
|
+
return keyId;
|
|
68
|
+
return `${this.getParent()}/cryptoKeys/${keyId}`;
|
|
69
|
+
}
|
|
70
|
+
buildUrl(path) {
|
|
71
|
+
if (!/^[a-zA-Z0-9_\-/:.?=&]+$/.test(path) || path.includes("..")) {
|
|
72
|
+
throw new errors_1.KmsError("INVALID_ARGUMENT", "Invalid GCP KMS path", path);
|
|
73
|
+
}
|
|
74
|
+
const endpoint = this.options.endpoint ?? "https://cloudkms.googleapis.com/v1";
|
|
75
|
+
const base = `${endpoint.replace(/\/+$/, "")}/`;
|
|
76
|
+
return new URL(path, base).href;
|
|
77
|
+
}
|
|
78
|
+
async request(path, method = "GET", body) {
|
|
79
|
+
const url = this.buildUrl(path);
|
|
80
|
+
const headers = {
|
|
81
|
+
"Content-Type": "application/json",
|
|
82
|
+
};
|
|
83
|
+
if (this.options.token) {
|
|
84
|
+
headers["Authorization"] = `Bearer ${this.options.token}`;
|
|
85
|
+
}
|
|
86
|
+
const reqInit = {
|
|
87
|
+
method,
|
|
88
|
+
headers,
|
|
89
|
+
...(body ? { body: JSON.stringify(body) } : {}),
|
|
90
|
+
};
|
|
91
|
+
let res;
|
|
92
|
+
try {
|
|
93
|
+
res = await fetch(url, reqInit);
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
throw new errors_1.KmsError("INVALID_ARGUMENT", `GCP KMS network error: ${err.message}`, path);
|
|
97
|
+
}
|
|
98
|
+
const text = await res.text();
|
|
99
|
+
const json = parseGcpResponse(text);
|
|
100
|
+
if (!res.ok) {
|
|
101
|
+
handleGcpError(res, json, path);
|
|
102
|
+
}
|
|
103
|
+
return (json.data ?? json);
|
|
104
|
+
}
|
|
105
|
+
async listKeys(filters) {
|
|
106
|
+
const path = `${this.getParent()}/cryptoKeys`;
|
|
107
|
+
const res = await this.request(path);
|
|
108
|
+
let keys = (res.cryptoKeys ?? []).map((k) => mapGcpKey(k, ""));
|
|
109
|
+
if (filters?.usage) {
|
|
110
|
+
keys = keys.filter((k) => k.usage === filters.usage);
|
|
111
|
+
}
|
|
112
|
+
if (filters?.enabled !== undefined) {
|
|
113
|
+
keys = keys.filter((k) => k.enabled === filters.enabled);
|
|
114
|
+
}
|
|
115
|
+
return keys;
|
|
116
|
+
}
|
|
117
|
+
async getKey(keyId) {
|
|
118
|
+
const path = this.getKeyName(keyId);
|
|
119
|
+
const res = await this.request(path);
|
|
120
|
+
return mapGcpKey(res, keyId);
|
|
121
|
+
}
|
|
122
|
+
async createKey(algorithm, usage, metadata) {
|
|
123
|
+
const keyId = `key-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
124
|
+
const path = `${this.getParent()}/cryptoKeys?cryptoKeyId=${keyId}`;
|
|
125
|
+
const purpose = usage === "sign" ? "ASYMMETRIC_SIGN" : "ENCRYPT_DECRYPT";
|
|
126
|
+
const body = {
|
|
127
|
+
purpose,
|
|
128
|
+
versionTemplate: {
|
|
129
|
+
algorithm: mapGcpAlgorithm(algorithm, usage),
|
|
130
|
+
},
|
|
131
|
+
...(metadata ? { labels: metadata } : {}),
|
|
132
|
+
};
|
|
133
|
+
const res = await this.request(path, "POST", body);
|
|
134
|
+
return mapGcpKey(res, keyId);
|
|
17
135
|
}
|
|
18
|
-
|
|
19
|
-
|
|
136
|
+
async enableKey(keyId) {
|
|
137
|
+
const path = `${this.getKeyName(keyId)}/cryptoKeyVersions/1?updateMask=state`;
|
|
138
|
+
await this.request(path, "PATCH", { state: "ENABLED" });
|
|
20
139
|
}
|
|
21
|
-
|
|
22
|
-
|
|
140
|
+
async disableKey(keyId) {
|
|
141
|
+
const path = `${this.getKeyName(keyId)}/cryptoKeyVersions/1?updateMask=state`;
|
|
142
|
+
await this.request(path, "PATCH", { state: "DISABLED" });
|
|
23
143
|
}
|
|
24
|
-
|
|
25
|
-
|
|
144
|
+
async scheduleKeyDeletion(keyId, _pendingWindowDays) {
|
|
145
|
+
const path = `${this.getKeyName(keyId)}/cryptoKeyVersions/1:destroy`;
|
|
146
|
+
await this.request(path, "POST", {});
|
|
26
147
|
}
|
|
27
|
-
|
|
28
|
-
|
|
148
|
+
async encrypt(keyId, plaintext, context) {
|
|
149
|
+
const path = `${this.getKeyName(keyId)}:encrypt`;
|
|
150
|
+
const body = {
|
|
151
|
+
plaintext: Buffer.from(plaintext).toString("base64"),
|
|
152
|
+
...(context
|
|
153
|
+
? {
|
|
154
|
+
additionalAuthenticatedData: Buffer.from(JSON.stringify(context)).toString("base64"),
|
|
155
|
+
}
|
|
156
|
+
: {}),
|
|
157
|
+
};
|
|
158
|
+
const res = await this.request(path, "POST", body);
|
|
159
|
+
const out = {
|
|
160
|
+
ciphertext: res.ciphertext,
|
|
161
|
+
keyId,
|
|
162
|
+
};
|
|
163
|
+
if (context) {
|
|
164
|
+
out.context = context;
|
|
165
|
+
}
|
|
166
|
+
return out;
|
|
29
167
|
}
|
|
30
|
-
|
|
31
|
-
|
|
168
|
+
async decrypt(keyId, ciphertext, context) {
|
|
169
|
+
const path = `${this.getKeyName(keyId)}:decrypt`;
|
|
170
|
+
const body = {
|
|
171
|
+
ciphertext,
|
|
172
|
+
...(context
|
|
173
|
+
? {
|
|
174
|
+
additionalAuthenticatedData: Buffer.from(JSON.stringify(context)).toString("base64"),
|
|
175
|
+
}
|
|
176
|
+
: {}),
|
|
177
|
+
};
|
|
178
|
+
const res = await this.request(path, "POST", body);
|
|
179
|
+
return {
|
|
180
|
+
plaintext: new Uint8Array(Buffer.from(res.plaintext, "base64")),
|
|
181
|
+
keyId,
|
|
182
|
+
};
|
|
32
183
|
}
|
|
33
|
-
|
|
34
|
-
|
|
184
|
+
async sign(keyId, data, algorithm) {
|
|
185
|
+
const path = `${this.getKeyName(keyId)}/cryptoKeyVersions/1:asymmetricSign`;
|
|
186
|
+
const body = {
|
|
187
|
+
data: Buffer.from(data).toString("base64"),
|
|
188
|
+
};
|
|
189
|
+
const res = await this.request(path, "POST", body);
|
|
190
|
+
return {
|
|
191
|
+
signature: res.signature,
|
|
192
|
+
keyId,
|
|
193
|
+
algorithm: algorithm ?? "RSA_SIGN_PSS_2048_SHA256",
|
|
194
|
+
};
|
|
35
195
|
}
|
|
36
|
-
|
|
37
|
-
|
|
196
|
+
async verify(keyId, data, signature, _algorithm) {
|
|
197
|
+
try {
|
|
198
|
+
const path = `${this.getKeyName(keyId)}/cryptoKeyVersions/1:macVerify`;
|
|
199
|
+
const body = {
|
|
200
|
+
data: Buffer.from(data).toString("base64"),
|
|
201
|
+
mac: signature,
|
|
202
|
+
};
|
|
203
|
+
const res = await this.request(path, "POST", body);
|
|
204
|
+
return Boolean(res.success);
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
38
209
|
}
|
|
39
|
-
|
|
40
|
-
|
|
210
|
+
async rotateKey(keyId) {
|
|
211
|
+
const path = `${this.getKeyName(keyId)}/cryptoKeyVersions`;
|
|
212
|
+
await this.request(path, "POST", {});
|
|
213
|
+
return this.getKey(keyId);
|
|
41
214
|
}
|
|
42
|
-
|
|
43
|
-
|
|
215
|
+
async generateDataKey(keyId, keySpec) {
|
|
216
|
+
const len = keySpec === "AES_128" ? 16 : 32;
|
|
217
|
+
const plaintext = new Uint8Array(len);
|
|
218
|
+
crypto.getRandomValues(plaintext);
|
|
219
|
+
const enc = await this.encrypt(keyId, plaintext);
|
|
220
|
+
return {
|
|
221
|
+
plaintext,
|
|
222
|
+
ciphertext: enc.ciphertext,
|
|
223
|
+
};
|
|
44
224
|
}
|
|
45
|
-
|
|
46
|
-
|
|
225
|
+
async wrapKey(keyId, unwrappedKey, context) {
|
|
226
|
+
const enc = await this.encrypt(keyId, unwrappedKey, context);
|
|
227
|
+
return { wrappedKey: enc.ciphertext, keyId };
|
|
47
228
|
}
|
|
48
|
-
|
|
49
|
-
|
|
229
|
+
async unwrapKey(keyId, wrappedKey, context) {
|
|
230
|
+
const dec = await this.decrypt(keyId, wrappedKey, context);
|
|
231
|
+
return { unwrappedKey: dec.plaintext, keyId };
|
|
50
232
|
}
|
|
51
233
|
}
|
|
52
234
|
exports.GcpKmsProvider = GcpKmsProvider;
|
|
@@ -26,5 +26,13 @@ export declare class LocalKmsProvider implements KmsProvider {
|
|
|
26
26
|
plaintext: Uint8Array;
|
|
27
27
|
ciphertext: string;
|
|
28
28
|
}>;
|
|
29
|
+
wrapKey(keyId: string, unwrappedKey: Uint8Array, context?: Record<string, string>): Promise<{
|
|
30
|
+
wrappedKey: string;
|
|
31
|
+
keyId: string;
|
|
32
|
+
}>;
|
|
33
|
+
unwrapKey(keyId: string, wrappedKey: string, context?: Record<string, string>): Promise<{
|
|
34
|
+
unwrappedKey: Uint8Array;
|
|
35
|
+
keyId: string;
|
|
36
|
+
}>;
|
|
29
37
|
}
|
|
30
38
|
//# sourceMappingURL=local.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../src/providers/local.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACd,MAAM,UAAU,CAAC;AAqDlB,qBAAa,gBAAiB,YAAW,WAAW;IAElD,QAAQ,CAAC,IAAI,WAAW;IAExB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqC;IAG3D,OAAO,CAAC,MAAM;IASd,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,YAAY;IAapB,OAAO,CAAC,QAAQ;IAQV,QAAQ,CAAC,OAAO,CAAC,EAAE;QACvB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAevB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAK9C,SAAS,CACb,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,SAAS,GAAG,MAAM,GAA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AE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC,gBAAgB,CAAC;IAO5B,OAAO,CAAC,aAAa;IAYf,IAAI,CACR,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,UAAU,EAChB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,aAAa,CAAC;IAanB,MAAM,CACV,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,OAAO,CAAC;IASb,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAajD,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhE,eAAe,CACnB,KAAK,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;QAET,SAAS,EAAE,UAAU,CAAC;QAEtB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IAUI,OAAO,CACX,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,UAAU,EACxB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAM3C,SAAS,CACb,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC;QAAE,YAAY,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAIxD"}
|
package/dist/providers/local.js
CHANGED
|
@@ -134,6 +134,14 @@ class LocalKmsProvider {
|
|
|
134
134
|
const wrapped = await this.encrypt(keyId, dek);
|
|
135
135
|
return { plaintext: dek, ciphertext: wrapped.ciphertext };
|
|
136
136
|
}
|
|
137
|
+
async wrapKey(keyId, unwrappedKey, context) {
|
|
138
|
+
const enc = await this.encrypt(keyId, unwrappedKey, context);
|
|
139
|
+
return { wrappedKey: enc.ciphertext, keyId: enc.keyId };
|
|
140
|
+
}
|
|
141
|
+
async unwrapKey(keyId, wrappedKey, context) {
|
|
142
|
+
const dec = await this.decrypt(keyId, wrappedKey, context);
|
|
143
|
+
return { unwrappedKey: dec.plaintext, keyId: dec.keyId };
|
|
144
|
+
}
|
|
137
145
|
}
|
|
138
146
|
exports.LocalKmsProvider = LocalKmsProvider;
|
|
139
147
|
//# sourceMappingURL=local.js.map
|
|
@@ -3,32 +3,45 @@ export interface VaultKmsOptions {
|
|
|
3
3
|
address: string;
|
|
4
4
|
token: string;
|
|
5
5
|
mountPath?: string;
|
|
6
|
+
namespace?: string;
|
|
6
7
|
}
|
|
7
8
|
export declare class VaultKmsProvider implements KmsProvider {
|
|
8
9
|
readonly name = "vault";
|
|
9
10
|
private readonly _address;
|
|
10
11
|
private readonly _token;
|
|
11
12
|
private readonly _mount;
|
|
13
|
+
private readonly _namespace?;
|
|
12
14
|
constructor(options: VaultKmsOptions);
|
|
13
15
|
buildUrl(path: string): string;
|
|
14
16
|
buildHeaders(): Record<string, string>;
|
|
15
|
-
|
|
17
|
+
private request;
|
|
18
|
+
private mapMetadata;
|
|
19
|
+
listKeys(filters?: {
|
|
16
20
|
usage?: string;
|
|
17
21
|
enabled?: boolean;
|
|
18
22
|
}): Promise<KmsKeyMetadata[]>;
|
|
19
|
-
getKey(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
getKey(keyId: string): Promise<KmsKeyMetadata>;
|
|
24
|
+
private resolveVaultType;
|
|
25
|
+
createKey(algorithm: string, usage: "encrypt" | "sign" | "wrap", metadata?: Record<string, string>): Promise<KmsKeyMetadata>;
|
|
26
|
+
enableKey(keyId: string): Promise<void>;
|
|
27
|
+
disableKey(keyId: string): Promise<void>;
|
|
28
|
+
scheduleKeyDeletion(keyId: string, _pendingWindowDays?: number): Promise<void>;
|
|
29
|
+
encrypt(keyId: string, plaintext: Uint8Array, context?: Record<string, string>): Promise<KmsEncryptResult>;
|
|
30
|
+
decrypt(keyId: string, ciphertext: string, context?: Record<string, string>): Promise<KmsDecryptResult>;
|
|
31
|
+
sign(keyId: string, data: Uint8Array, algorithm?: string): Promise<KmsSignResult>;
|
|
32
|
+
verify(keyId: string, data: Uint8Array, signature: string, algorithm?: string): Promise<boolean>;
|
|
33
|
+
rotateKey(keyId: string): Promise<KmsKeyMetadata>;
|
|
34
|
+
generateDataKey(keyId: string, keySpec?: string): Promise<{
|
|
30
35
|
plaintext: Uint8Array;
|
|
31
36
|
ciphertext: string;
|
|
32
37
|
}>;
|
|
38
|
+
wrapKey(keyId: string, unwrappedKey: Uint8Array, context?: Record<string, string>): Promise<{
|
|
39
|
+
wrappedKey: string;
|
|
40
|
+
keyId: string;
|
|
41
|
+
}>;
|
|
42
|
+
unwrapKey(keyId: string, wrappedKey: string, context?: Record<string, string>): Promise<{
|
|
43
|
+
unwrappedKey: Uint8Array;
|
|
44
|
+
keyId: string;
|
|
45
|
+
}>;
|
|
33
46
|
}
|
|
34
47
|
//# sourceMappingURL=vault.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vault.d.ts","sourceRoot":"","sources":["../../src/providers/vault.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACd,MAAM,UAAU,CAAC;AAelB,MAAM,WAAW,eAAe;IAE9B,OAAO,EAAE,MAAM,CAAC;IAEhB,KAAK,EAAE,MAAM,CAAC;IAEd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"vault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,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC;QAAE,YAAY,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAIxD"}
|
package/dist/providers/vault.js
CHANGED
|
@@ -2,61 +2,230 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VaultKmsProvider = void 0;
|
|
4
4
|
const errors_1 = require("../errors");
|
|
5
|
+
function parseVaultResponse(text) {
|
|
6
|
+
if (!text)
|
|
7
|
+
return {};
|
|
8
|
+
try {
|
|
9
|
+
return JSON.parse(text);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function handleVaultError(res, json, keyId) {
|
|
16
|
+
const errMsg = json.errors?.join(", ") ?? `HTTP ${res.status}`;
|
|
17
|
+
if (res.status === 400 &&
|
|
18
|
+
/ciphertext.*invalid|decryption failed/i.test(errMsg)) {
|
|
19
|
+
throw new errors_1.KmsError("DECRYPTION_FAILED", errMsg, keyId);
|
|
20
|
+
}
|
|
21
|
+
if (/disabled/i.test(errMsg)) {
|
|
22
|
+
throw new errors_1.KmsError("DISABLED", errMsg, keyId);
|
|
23
|
+
}
|
|
24
|
+
throw new errors_1.KmsError("INVALID_ARGUMENT", `Vault error: ${errMsg}`, keyId);
|
|
25
|
+
}
|
|
5
26
|
class VaultKmsProvider {
|
|
6
27
|
name = "vault";
|
|
7
28
|
_address;
|
|
8
29
|
_token;
|
|
9
30
|
_mount;
|
|
31
|
+
_namespace;
|
|
10
32
|
constructor(options) {
|
|
11
33
|
this._address = options.address;
|
|
12
34
|
this._token = options.token;
|
|
13
35
|
this._mount = options.mountPath ?? "transit";
|
|
36
|
+
this._namespace = options.namespace;
|
|
14
37
|
}
|
|
15
38
|
buildUrl(path) {
|
|
16
|
-
|
|
17
|
-
|
|
39
|
+
if (!/^[a-zA-Z0-9_\-/:.?=&]+$/.test(path) || path.includes("..")) {
|
|
40
|
+
throw new errors_1.KmsError("INVALID_ARGUMENT", "Invalid Vault path", path);
|
|
41
|
+
}
|
|
42
|
+
const address = this._address.startsWith("http://") ||
|
|
43
|
+
this._address.startsWith("https://")
|
|
44
|
+
? this._address
|
|
45
|
+
: `http://${this._address}`;
|
|
46
|
+
const cleanMount = encodeURIComponent(this._mount);
|
|
47
|
+
const base = `${address.replace(/\/+$/, "")}/v1/${cleanMount}/`;
|
|
48
|
+
return new URL(path, base).href;
|
|
18
49
|
}
|
|
19
50
|
buildHeaders() {
|
|
20
|
-
|
|
51
|
+
const headers = {
|
|
21
52
|
"X-Vault-Token": this._token,
|
|
22
53
|
"Content-Type": "application/json",
|
|
23
54
|
};
|
|
55
|
+
if (this._namespace) {
|
|
56
|
+
headers["X-Vault-Namespace"] = this._namespace;
|
|
57
|
+
}
|
|
58
|
+
return headers;
|
|
24
59
|
}
|
|
25
|
-
|
|
26
|
-
|
|
60
|
+
async request(path, method = "GET", body, keyId) {
|
|
61
|
+
const url = this.buildUrl(path);
|
|
62
|
+
const reqInit = {
|
|
63
|
+
method,
|
|
64
|
+
headers: this.buildHeaders(),
|
|
65
|
+
};
|
|
66
|
+
if (body !== undefined) {
|
|
67
|
+
reqInit.body = JSON.stringify(body);
|
|
68
|
+
}
|
|
69
|
+
let res;
|
|
70
|
+
try {
|
|
71
|
+
res = await fetch(url, reqInit);
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
throw new errors_1.KmsError("INVALID_ARGUMENT", `Vault request failed: ${err.message}`, keyId);
|
|
75
|
+
}
|
|
76
|
+
if (res.status === 404) {
|
|
77
|
+
throw new errors_1.KmsError("NOT_FOUND", `Vault path not found: ${path}`, keyId);
|
|
78
|
+
}
|
|
79
|
+
const text = await res.text();
|
|
80
|
+
const json = parseVaultResponse(text);
|
|
81
|
+
if (!res.ok) {
|
|
82
|
+
handleVaultError(res, json, keyId);
|
|
83
|
+
}
|
|
84
|
+
return (json.data ?? json);
|
|
27
85
|
}
|
|
28
|
-
|
|
29
|
-
|
|
86
|
+
mapMetadata(keyId, details) {
|
|
87
|
+
const usage = details.supports_signing ? "sign" : "encrypt";
|
|
88
|
+
const minEnc = details.min_encryption_version ?? 0;
|
|
89
|
+
const latest = details.latest_version ?? 1;
|
|
90
|
+
const enabled = minEnc <= latest;
|
|
91
|
+
const meta = {
|
|
92
|
+
keyId,
|
|
93
|
+
algorithm: details.type ?? "aes256-gcm96",
|
|
94
|
+
usage,
|
|
95
|
+
createdAt: new Date().toISOString(),
|
|
96
|
+
enabled,
|
|
97
|
+
provider: "vault",
|
|
98
|
+
};
|
|
99
|
+
if (details.latest_version !== undefined) {
|
|
100
|
+
meta.currentVersion = details.latest_version;
|
|
101
|
+
}
|
|
102
|
+
return meta;
|
|
30
103
|
}
|
|
31
|
-
|
|
32
|
-
|
|
104
|
+
async listKeys(filters) {
|
|
105
|
+
const res = await this.request("keys?list=true");
|
|
106
|
+
const keyNames = res.keys ?? [];
|
|
107
|
+
const list = [];
|
|
108
|
+
for (const name of keyNames) {
|
|
109
|
+
try {
|
|
110
|
+
const meta = await this.getKey(name);
|
|
111
|
+
if (filters?.usage && meta.usage !== filters.usage)
|
|
112
|
+
continue;
|
|
113
|
+
if (filters?.enabled !== undefined && meta.enabled !== filters.enabled)
|
|
114
|
+
continue;
|
|
115
|
+
list.push(meta);
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return list;
|
|
33
121
|
}
|
|
34
|
-
|
|
35
|
-
|
|
122
|
+
async getKey(keyId) {
|
|
123
|
+
const details = await this.request(`keys/${keyId}`, "GET", undefined, keyId);
|
|
124
|
+
return this.mapMetadata(keyId, details);
|
|
36
125
|
}
|
|
37
|
-
|
|
38
|
-
|
|
126
|
+
resolveVaultType(algorithm, usage) {
|
|
127
|
+
const lower = algorithm.toLowerCase();
|
|
128
|
+
if (lower.includes("p256") || lower.includes("ecdsa"))
|
|
129
|
+
return "ecdsa-p256";
|
|
130
|
+
if (lower.includes("rsa-4096"))
|
|
131
|
+
return "rsa-4096";
|
|
132
|
+
if (lower.includes("rsa"))
|
|
133
|
+
return "rsa-2048";
|
|
134
|
+
if (lower.includes("chacha"))
|
|
135
|
+
return "chacha20-poly1305";
|
|
136
|
+
if (lower.includes("ed25519"))
|
|
137
|
+
return "ed25519";
|
|
138
|
+
if (usage === "sign")
|
|
139
|
+
return "ed25519";
|
|
140
|
+
return "aes256-gcm96";
|
|
39
141
|
}
|
|
40
|
-
|
|
41
|
-
|
|
142
|
+
async createKey(algorithm, usage, metadata) {
|
|
143
|
+
const keyId = metadata?.["keyId"] ??
|
|
144
|
+
`vault-${Date.now()}-${Math.floor(Math.random() * 1e6)}`;
|
|
145
|
+
const vaultType = this.resolveVaultType(algorithm, usage);
|
|
146
|
+
await this.request(`keys/${keyId}`, "POST", { type: vaultType }, keyId);
|
|
147
|
+
return this.getKey(keyId);
|
|
42
148
|
}
|
|
43
|
-
|
|
44
|
-
|
|
149
|
+
async enableKey(keyId) {
|
|
150
|
+
await this.request(`keys/${keyId}/config`, "POST", { min_encryption_version: 0 }, keyId);
|
|
45
151
|
}
|
|
46
|
-
|
|
47
|
-
|
|
152
|
+
async disableKey(keyId) {
|
|
153
|
+
const meta = await this.getKey(keyId);
|
|
154
|
+
const disableVersion = (meta.currentVersion ?? 1) + 1;
|
|
155
|
+
await this.request(`keys/${keyId}/config`, "POST", { min_encryption_version: disableVersion }, keyId);
|
|
48
156
|
}
|
|
49
|
-
|
|
50
|
-
|
|
157
|
+
async scheduleKeyDeletion(keyId, _pendingWindowDays) {
|
|
158
|
+
await this.request(`keys/${keyId}/config`, "POST", { deletion_allowed: true }, keyId);
|
|
159
|
+
await this.request(`keys/${keyId}`, "DELETE", undefined, keyId);
|
|
160
|
+
}
|
|
161
|
+
async encrypt(keyId, plaintext, context) {
|
|
162
|
+
const b64Plaintext = Buffer.from(plaintext).toString("base64");
|
|
163
|
+
const b64Context = context
|
|
164
|
+
? Buffer.from(JSON.stringify(context)).toString("base64")
|
|
165
|
+
: undefined;
|
|
166
|
+
const body = { plaintext: b64Plaintext };
|
|
167
|
+
if (b64Context)
|
|
168
|
+
body.context = b64Context;
|
|
169
|
+
const res = await this.request(`encrypt/${keyId}`, "POST", body, keyId);
|
|
170
|
+
const out = {
|
|
171
|
+
ciphertext: res.ciphertext,
|
|
172
|
+
keyId,
|
|
173
|
+
};
|
|
174
|
+
if (context)
|
|
175
|
+
out.context = context;
|
|
176
|
+
return out;
|
|
51
177
|
}
|
|
52
|
-
|
|
53
|
-
|
|
178
|
+
async decrypt(keyId, ciphertext, context) {
|
|
179
|
+
const b64Context = context
|
|
180
|
+
? Buffer.from(JSON.stringify(context)).toString("base64")
|
|
181
|
+
: undefined;
|
|
182
|
+
const body = { ciphertext };
|
|
183
|
+
if (b64Context)
|
|
184
|
+
body.context = b64Context;
|
|
185
|
+
const res = await this.request(`decrypt/${keyId}`, "POST", body, keyId);
|
|
186
|
+
return {
|
|
187
|
+
plaintext: new Uint8Array(Buffer.from(res.plaintext, "base64")),
|
|
188
|
+
keyId,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
async sign(keyId, data, algorithm = "sha2-256") {
|
|
192
|
+
const input = Buffer.from(data).toString("base64");
|
|
193
|
+
const res = await this.request(`sign/${keyId}`, "POST", { input, signature_algorithm: algorithm }, keyId);
|
|
194
|
+
return {
|
|
195
|
+
signature: res.signature,
|
|
196
|
+
keyId,
|
|
197
|
+
algorithm,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
async verify(keyId, data, signature, algorithm = "sha2-256") {
|
|
201
|
+
const input = Buffer.from(data).toString("base64");
|
|
202
|
+
try {
|
|
203
|
+
const res = await this.request(`verify/${keyId}`, "POST", { input, signature, signature_algorithm: algorithm }, keyId);
|
|
204
|
+
return Boolean(res.valid);
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
async rotateKey(keyId) {
|
|
211
|
+
await this.request(`keys/${keyId}/rotate`, "POST", undefined, keyId);
|
|
212
|
+
return this.getKey(keyId);
|
|
213
|
+
}
|
|
214
|
+
async generateDataKey(keyId, keySpec = "AES_256") {
|
|
215
|
+
const bits = keySpec.includes("128") ? 128 : 256;
|
|
216
|
+
const res = await this.request(`datakey/plaintext/${keyId}`, "POST", { bits }, keyId);
|
|
217
|
+
return {
|
|
218
|
+
plaintext: new Uint8Array(Buffer.from(res.plaintext, "base64")),
|
|
219
|
+
ciphertext: res.ciphertext,
|
|
220
|
+
};
|
|
54
221
|
}
|
|
55
|
-
|
|
56
|
-
|
|
222
|
+
async wrapKey(keyId, unwrappedKey, context) {
|
|
223
|
+
const enc = await this.encrypt(keyId, unwrappedKey, context);
|
|
224
|
+
return { wrappedKey: enc.ciphertext, keyId: enc.keyId };
|
|
57
225
|
}
|
|
58
|
-
|
|
59
|
-
|
|
226
|
+
async unwrapKey(keyId, wrappedKey, context) {
|
|
227
|
+
const dec = await this.decrypt(keyId, wrappedKey, context);
|
|
228
|
+
return { unwrappedKey: dec.plaintext, keyId: dec.keyId };
|
|
60
229
|
}
|
|
61
230
|
}
|
|
62
231
|
exports.VaultKmsProvider = VaultKmsProvider;
|
package/dist/types.d.ts
CHANGED
|
@@ -44,5 +44,13 @@ export interface KmsProvider {
|
|
|
44
44
|
plaintext: Uint8Array;
|
|
45
45
|
ciphertext: string;
|
|
46
46
|
}>;
|
|
47
|
+
wrapKey?(keyId: string, unwrappedKey: Uint8Array, context?: Record<string, string>): Promise<{
|
|
48
|
+
wrappedKey: string;
|
|
49
|
+
keyId: string;
|
|
50
|
+
}>;
|
|
51
|
+
unwrapKey?(keyId: string, wrappedKey: string, context?: Record<string, string>): Promise<{
|
|
52
|
+
unwrappedKey: Uint8Array;
|
|
53
|
+
keyId: string;
|
|
54
|
+
}>;
|
|
47
55
|
}
|
|
48
56
|
//# sourceMappingURL=types.d.ts.map
|
package/d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CAAC;QAEtB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;IAGH,OAAO,CAAC,CACN,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,UAAU,EACxB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAGlD,SAAS,CAAC,CACR,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,OAAO,CAAC;QAAE,YAAY,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACzD"}
|
package/package.json
CHANGED
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebastienrousseau/crypto-kms",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"description": "Enterprise key management adapters for AWS KMS, Google Cloud KMS, Azure Key Vault, and HashiCorp Vault.",
|
|
5
5
|
"author": "Sebastien Rousseau <sebastienrousseau@users.noreply.github.com>",
|
|
6
6
|
"license": "MIT OR Apache-2.0",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=22.0.0"
|
|
9
9
|
},
|
|
10
|
+
"type": "commonjs",
|
|
10
11
|
"main": "./dist/index.js",
|
|
11
12
|
"types": "./dist/index.d.ts",
|
|
12
|
-
"sideEffects": false,
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
16
|
"require": "./dist/index.js",
|
|
17
|
-
"
|
|
18
|
-
}
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./package.json": "./package.json"
|
|
19
20
|
},
|
|
21
|
+
"sideEffects": false,
|
|
20
22
|
"files": [
|
|
21
23
|
"dist/**/*.js",
|
|
22
24
|
"dist/**/*.d.ts",
|
|
23
25
|
"dist/**/*.d.ts.map"
|
|
24
26
|
],
|
|
25
27
|
"dependencies": {
|
|
26
|
-
"@sebastienrousseau/crypto-lib": "0.0.
|
|
28
|
+
"@sebastienrousseau/crypto-lib": "0.0.24"
|
|
27
29
|
},
|
|
28
30
|
"peerDependencies": {
|
|
29
31
|
"@aws-sdk/client-kms": "^3.0.0",
|
|
@@ -42,12 +44,12 @@
|
|
|
42
44
|
}
|
|
43
45
|
},
|
|
44
46
|
"devDependencies": {
|
|
45
|
-
"@types/chai": "^
|
|
46
|
-
"@types/mocha": "^10.0.
|
|
47
|
+
"@types/chai": "^5.2.3",
|
|
48
|
+
"@types/mocha": "^10.0.10",
|
|
47
49
|
"@types/node": "^26.6.3",
|
|
48
50
|
"c8": "^12.0.0",
|
|
49
|
-
"chai": "^
|
|
50
|
-
"mocha": "^
|
|
51
|
+
"chai": "^6.3.0",
|
|
52
|
+
"mocha": "^12.0.3",
|
|
51
53
|
"rimraf": "^6.1.3",
|
|
52
54
|
"ts-node": "^10.9.2",
|
|
53
55
|
"typedoc": "^0.28.20",
|
|
@@ -68,8 +70,8 @@
|
|
|
68
70
|
"clean": "rimraf ./coverage ./dist ./docs",
|
|
69
71
|
"test": "c8 --check-coverage --lines 100 --branches 100 --functions 100 --reporter=lcov --reporter=text mocha --config=.mocharc.cjs",
|
|
70
72
|
"docs": "typedoc",
|
|
71
|
-
"lint": "eslint
|
|
72
|
-
"lint:fix": "eslint --cache --fix
|
|
73
|
+
"lint": "eslint src __tests__",
|
|
74
|
+
"lint:fix": "eslint --cache --fix src __tests__",
|
|
73
75
|
"format": "prettier --write src/**/*.ts",
|
|
74
76
|
"format:check": "prettier --check \"src/**/*.ts\""
|
|
75
77
|
}
|