@scaleway/sdk-key-manager 1.0.1 → 1.1.1
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/v1alpha1/api.gen.cjs +45 -0
- package/dist/v1alpha1/api.gen.d.ts +22 -1
- package/dist/v1alpha1/api.gen.js +46 -1
- package/dist/v1alpha1/index.gen.cjs +5 -0
- package/dist/v1alpha1/index.gen.d.ts +1 -1
- package/dist/v1alpha1/index.gen.js +7 -2
- package/dist/v1alpha1/marshalling.gen.cjs +49 -1
- package/dist/v1alpha1/marshalling.gen.d.ts +6 -1
- package/dist/v1alpha1/marshalling.gen.js +50 -2
- package/dist/v1alpha1/types.gen.d.ts +82 -5
- package/package.json +5 -8
|
@@ -42,6 +42,19 @@ class API extends sdkClient.API {
|
|
|
42
42
|
},
|
|
43
43
|
marshalling_gen.unmarshalKey
|
|
44
44
|
);
|
|
45
|
+
/**
|
|
46
|
+
* Get the public key in PEM format.. Retrieves the public portion of an asymmetric cryptographic key in PEM format.
|
|
47
|
+
*
|
|
48
|
+
* @param request - The request {@link GetPublicKeyRequest}
|
|
49
|
+
* @returns A Promise of PublicKey
|
|
50
|
+
*/
|
|
51
|
+
getPublicKey = (request) => this.client.fetch(
|
|
52
|
+
{
|
|
53
|
+
method: "GET",
|
|
54
|
+
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}/public-key`
|
|
55
|
+
},
|
|
56
|
+
marshalling_gen.unmarshalPublicKey
|
|
57
|
+
);
|
|
45
58
|
/**
|
|
46
59
|
* Update a key. Modify a key's metadata including name, description and tags, specified by the `key_id` and `region` parameters.
|
|
47
60
|
*
|
|
@@ -222,6 +235,38 @@ class API extends sdkClient.API {
|
|
|
222
235
|
},
|
|
223
236
|
marshalling_gen.unmarshalDecryptResponse
|
|
224
237
|
);
|
|
238
|
+
/**
|
|
239
|
+
* Sign a message digest. Use a given key to sign a message digest. The key must have its usage set to `asymmetric_signing`. The digest must be created using the same digest algorithm that is defined in the key's algorithm configuration.
|
|
240
|
+
*
|
|
241
|
+
* @param request - The request {@link SignRequest}
|
|
242
|
+
* @returns A Promise of SignResponse
|
|
243
|
+
*/
|
|
244
|
+
sign = (request) => this.client.fetch(
|
|
245
|
+
{
|
|
246
|
+
body: JSON.stringify(marshalling_gen.marshalSignRequest(request, this.client.settings)),
|
|
247
|
+
headers: jsonContentHeaders,
|
|
248
|
+
method: "POST",
|
|
249
|
+
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}/sign`
|
|
250
|
+
},
|
|
251
|
+
marshalling_gen.unmarshalSignResponse
|
|
252
|
+
);
|
|
253
|
+
/**
|
|
254
|
+
* Verify a message signature. Use a given key to verify a message signature against a message digest. The key must have its usage set to `asymmetric_signing`. The message digest must be generated using the same digest algorithm that is defined in the key's algorithm configuration.
|
|
255
|
+
*
|
|
256
|
+
* @param request - The request {@link VerifyRequest}
|
|
257
|
+
* @returns A Promise of VerifyResponse
|
|
258
|
+
*/
|
|
259
|
+
verify = (request) => this.client.fetch(
|
|
260
|
+
{
|
|
261
|
+
body: JSON.stringify(
|
|
262
|
+
marshalling_gen.marshalVerifyRequest(request, this.client.settings)
|
|
263
|
+
),
|
|
264
|
+
headers: jsonContentHeaders,
|
|
265
|
+
method: "POST",
|
|
266
|
+
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}/verify`
|
|
267
|
+
},
|
|
268
|
+
marshalling_gen.unmarshalVerifyResponse
|
|
269
|
+
);
|
|
225
270
|
/**
|
|
226
271
|
* Import key material. Import externally generated key material into Key Manager to derive a new cryptographic key. The key's origin must be `external`.
|
|
227
272
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { API as ParentAPI } from '@scaleway/sdk-client';
|
|
2
2
|
import type { Region as ScwRegion } from '@scaleway/sdk-client';
|
|
3
|
-
import type { CreateKeyRequest, DataKey, DecryptRequest, DecryptResponse, DeleteKeyMaterialRequest, DeleteKeyRequest, DisableKeyRequest, EnableKeyRequest, EncryptRequest, EncryptResponse, GenerateDataKeyRequest, GetKeyRequest, ImportKeyMaterialRequest, Key, ListKeysRequest, ListKeysResponse, ProtectKeyRequest, RotateKeyRequest, UnprotectKeyRequest, UpdateKeyRequest } from './types.gen';
|
|
3
|
+
import type { CreateKeyRequest, DataKey, DecryptRequest, DecryptResponse, DeleteKeyMaterialRequest, DeleteKeyRequest, DisableKeyRequest, EnableKeyRequest, EncryptRequest, EncryptResponse, GenerateDataKeyRequest, GetKeyRequest, GetPublicKeyRequest, ImportKeyMaterialRequest, Key, ListKeysRequest, ListKeysResponse, ProtectKeyRequest, PublicKey, RotateKeyRequest, SignRequest, SignResponse, UnprotectKeyRequest, UpdateKeyRequest, VerifyRequest, VerifyResponse } from './types.gen';
|
|
4
4
|
/**
|
|
5
5
|
* Key Manager API.
|
|
6
6
|
|
|
@@ -23,6 +23,13 @@ export declare class API extends ParentAPI {
|
|
|
23
23
|
* @returns A Promise of Key
|
|
24
24
|
*/
|
|
25
25
|
getKey: (request: Readonly<GetKeyRequest>) => Promise<Key>;
|
|
26
|
+
/**
|
|
27
|
+
* Get the public key in PEM format.. Retrieves the public portion of an asymmetric cryptographic key in PEM format.
|
|
28
|
+
*
|
|
29
|
+
* @param request - The request {@link GetPublicKeyRequest}
|
|
30
|
+
* @returns A Promise of PublicKey
|
|
31
|
+
*/
|
|
32
|
+
getPublicKey: (request: Readonly<GetPublicKeyRequest>) => Promise<PublicKey>;
|
|
26
33
|
/**
|
|
27
34
|
* Update a key. Modify a key's metadata including name, description and tags, specified by the `key_id` and `region` parameters.
|
|
28
35
|
*
|
|
@@ -105,6 +112,20 @@ export declare class API extends ParentAPI {
|
|
|
105
112
|
* @returns A Promise of DecryptResponse
|
|
106
113
|
*/
|
|
107
114
|
decrypt: (request: Readonly<DecryptRequest>) => Promise<DecryptResponse>;
|
|
115
|
+
/**
|
|
116
|
+
* Sign a message digest. Use a given key to sign a message digest. The key must have its usage set to `asymmetric_signing`. The digest must be created using the same digest algorithm that is defined in the key's algorithm configuration.
|
|
117
|
+
*
|
|
118
|
+
* @param request - The request {@link SignRequest}
|
|
119
|
+
* @returns A Promise of SignResponse
|
|
120
|
+
*/
|
|
121
|
+
sign: (request: Readonly<SignRequest>) => Promise<SignResponse>;
|
|
122
|
+
/**
|
|
123
|
+
* Verify a message signature. Use a given key to verify a message signature against a message digest. The key must have its usage set to `asymmetric_signing`. The message digest must be generated using the same digest algorithm that is defined in the key's algorithm configuration.
|
|
124
|
+
*
|
|
125
|
+
* @param request - The request {@link VerifyRequest}
|
|
126
|
+
* @returns A Promise of VerifyResponse
|
|
127
|
+
*/
|
|
128
|
+
verify: (request: Readonly<VerifyRequest>) => Promise<VerifyResponse>;
|
|
108
129
|
/**
|
|
109
130
|
* Import key material. Import externally generated key material into Key Manager to derive a new cryptographic key. The key's origin must be `external`.
|
|
110
131
|
*
|
package/dist/v1alpha1/api.gen.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { API as API$1, validatePathParam, urlParams, enrichForPagination } from "@scaleway/sdk-client";
|
|
2
|
-
import { marshalCreateKeyRequest, unmarshalKey, marshalUpdateKeyRequest, unmarshalListKeysResponse, marshalGenerateDataKeyRequest, unmarshalDataKey, marshalEncryptRequest, unmarshalEncryptResponse, marshalDecryptRequest, unmarshalDecryptResponse, marshalImportKeyMaterialRequest } from "./marshalling.gen.js";
|
|
2
|
+
import { marshalCreateKeyRequest, unmarshalKey, unmarshalPublicKey, marshalUpdateKeyRequest, unmarshalListKeysResponse, marshalGenerateDataKeyRequest, unmarshalDataKey, marshalEncryptRequest, unmarshalEncryptResponse, marshalDecryptRequest, unmarshalDecryptResponse, marshalSignRequest, unmarshalSignResponse, marshalVerifyRequest, unmarshalVerifyResponse, marshalImportKeyMaterialRequest } from "./marshalling.gen.js";
|
|
3
3
|
const jsonContentHeaders = {
|
|
4
4
|
"Content-Type": "application/json; charset=utf-8"
|
|
5
5
|
};
|
|
@@ -40,6 +40,19 @@ class API extends API$1 {
|
|
|
40
40
|
},
|
|
41
41
|
unmarshalKey
|
|
42
42
|
);
|
|
43
|
+
/**
|
|
44
|
+
* Get the public key in PEM format.. Retrieves the public portion of an asymmetric cryptographic key in PEM format.
|
|
45
|
+
*
|
|
46
|
+
* @param request - The request {@link GetPublicKeyRequest}
|
|
47
|
+
* @returns A Promise of PublicKey
|
|
48
|
+
*/
|
|
49
|
+
getPublicKey = (request) => this.client.fetch(
|
|
50
|
+
{
|
|
51
|
+
method: "GET",
|
|
52
|
+
path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/public-key`
|
|
53
|
+
},
|
|
54
|
+
unmarshalPublicKey
|
|
55
|
+
);
|
|
43
56
|
/**
|
|
44
57
|
* Update a key. Modify a key's metadata including name, description and tags, specified by the `key_id` and `region` parameters.
|
|
45
58
|
*
|
|
@@ -220,6 +233,38 @@ class API extends API$1 {
|
|
|
220
233
|
},
|
|
221
234
|
unmarshalDecryptResponse
|
|
222
235
|
);
|
|
236
|
+
/**
|
|
237
|
+
* Sign a message digest. Use a given key to sign a message digest. The key must have its usage set to `asymmetric_signing`. The digest must be created using the same digest algorithm that is defined in the key's algorithm configuration.
|
|
238
|
+
*
|
|
239
|
+
* @param request - The request {@link SignRequest}
|
|
240
|
+
* @returns A Promise of SignResponse
|
|
241
|
+
*/
|
|
242
|
+
sign = (request) => this.client.fetch(
|
|
243
|
+
{
|
|
244
|
+
body: JSON.stringify(marshalSignRequest(request, this.client.settings)),
|
|
245
|
+
headers: jsonContentHeaders,
|
|
246
|
+
method: "POST",
|
|
247
|
+
path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/sign`
|
|
248
|
+
},
|
|
249
|
+
unmarshalSignResponse
|
|
250
|
+
);
|
|
251
|
+
/**
|
|
252
|
+
* Verify a message signature. Use a given key to verify a message signature against a message digest. The key must have its usage set to `asymmetric_signing`. The message digest must be generated using the same digest algorithm that is defined in the key's algorithm configuration.
|
|
253
|
+
*
|
|
254
|
+
* @param request - The request {@link VerifyRequest}
|
|
255
|
+
* @returns A Promise of VerifyResponse
|
|
256
|
+
*/
|
|
257
|
+
verify = (request) => this.client.fetch(
|
|
258
|
+
{
|
|
259
|
+
body: JSON.stringify(
|
|
260
|
+
marshalVerifyRequest(request, this.client.settings)
|
|
261
|
+
),
|
|
262
|
+
headers: jsonContentHeaders,
|
|
263
|
+
method: "POST",
|
|
264
|
+
path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/verify`
|
|
265
|
+
},
|
|
266
|
+
unmarshalVerifyResponse
|
|
267
|
+
);
|
|
223
268
|
/**
|
|
224
269
|
* Import key material. Import externally generated key material into Key Manager to derive a new cryptographic key. The key's origin must be `external`.
|
|
225
270
|
*
|
|
@@ -8,9 +8,14 @@ exports.marshalDecryptRequest = marshalling_gen.marshalDecryptRequest;
|
|
|
8
8
|
exports.marshalEncryptRequest = marshalling_gen.marshalEncryptRequest;
|
|
9
9
|
exports.marshalGenerateDataKeyRequest = marshalling_gen.marshalGenerateDataKeyRequest;
|
|
10
10
|
exports.marshalImportKeyMaterialRequest = marshalling_gen.marshalImportKeyMaterialRequest;
|
|
11
|
+
exports.marshalSignRequest = marshalling_gen.marshalSignRequest;
|
|
11
12
|
exports.marshalUpdateKeyRequest = marshalling_gen.marshalUpdateKeyRequest;
|
|
13
|
+
exports.marshalVerifyRequest = marshalling_gen.marshalVerifyRequest;
|
|
12
14
|
exports.unmarshalDataKey = marshalling_gen.unmarshalDataKey;
|
|
13
15
|
exports.unmarshalDecryptResponse = marshalling_gen.unmarshalDecryptResponse;
|
|
14
16
|
exports.unmarshalEncryptResponse = marshalling_gen.unmarshalEncryptResponse;
|
|
15
17
|
exports.unmarshalKey = marshalling_gen.unmarshalKey;
|
|
16
18
|
exports.unmarshalListKeysResponse = marshalling_gen.unmarshalListKeysResponse;
|
|
19
|
+
exports.unmarshalPublicKey = marshalling_gen.unmarshalPublicKey;
|
|
20
|
+
exports.unmarshalSignResponse = marshalling_gen.unmarshalSignResponse;
|
|
21
|
+
exports.unmarshalVerifyResponse = marshalling_gen.unmarshalVerifyResponse;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { API } from './api.gen';
|
|
2
2
|
export * from './marshalling.gen';
|
|
3
|
-
export type { CreateKeyRequest, DataKey, DataKeyAlgorithmSymmetricEncryption, DecryptRequest, DecryptResponse, DeleteKeyMaterialRequest, DeleteKeyRequest, DisableKeyRequest, EnableKeyRequest, EncryptRequest, EncryptResponse, GenerateDataKeyRequest, GetKeyRequest, ImportKeyMaterialRequest, Key, KeyAlgorithmSymmetricEncryption, KeyOrigin, KeyRotationPolicy, KeyState, KeyUsage, ListKeysRequest, ListKeysRequestOrderBy, ListKeysResponse, ProtectKeyRequest, RotateKeyRequest, UnprotectKeyRequest, UpdateKeyRequest, } from './types.gen';
|
|
3
|
+
export type { CreateKeyRequest, DataKey, DataKeyAlgorithmSymmetricEncryption, DecryptRequest, DecryptResponse, DeleteKeyMaterialRequest, DeleteKeyRequest, DisableKeyRequest, EnableKeyRequest, EncryptRequest, EncryptResponse, GenerateDataKeyRequest, GetKeyRequest, GetPublicKeyRequest, ImportKeyMaterialRequest, Key, KeyAlgorithmAsymmetricEncryption, KeyAlgorithmAsymmetricSigning, KeyAlgorithmSymmetricEncryption, KeyOrigin, KeyRotationPolicy, KeyState, KeyUsage, ListKeysRequest, ListKeysRequestOrderBy, ListKeysResponse, ProtectKeyRequest, PublicKey, RotateKeyRequest, SignRequest, SignResponse, UnprotectKeyRequest, UpdateKeyRequest, VerifyRequest, VerifyResponse, } from './types.gen';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { API } from "./api.gen.js";
|
|
2
|
-
import { marshalCreateKeyRequest, marshalDecryptRequest, marshalEncryptRequest, marshalGenerateDataKeyRequest, marshalImportKeyMaterialRequest, marshalUpdateKeyRequest, unmarshalDataKey, unmarshalDecryptResponse, unmarshalEncryptResponse, unmarshalKey, unmarshalListKeysResponse } from "./marshalling.gen.js";
|
|
2
|
+
import { marshalCreateKeyRequest, marshalDecryptRequest, marshalEncryptRequest, marshalGenerateDataKeyRequest, marshalImportKeyMaterialRequest, marshalSignRequest, marshalUpdateKeyRequest, marshalVerifyRequest, unmarshalDataKey, unmarshalDecryptResponse, unmarshalEncryptResponse, unmarshalKey, unmarshalListKeysResponse, unmarshalPublicKey, unmarshalSignResponse, unmarshalVerifyResponse } from "./marshalling.gen.js";
|
|
3
3
|
export {
|
|
4
4
|
API,
|
|
5
5
|
marshalCreateKeyRequest,
|
|
@@ -7,10 +7,15 @@ export {
|
|
|
7
7
|
marshalEncryptRequest,
|
|
8
8
|
marshalGenerateDataKeyRequest,
|
|
9
9
|
marshalImportKeyMaterialRequest,
|
|
10
|
+
marshalSignRequest,
|
|
10
11
|
marshalUpdateKeyRequest,
|
|
12
|
+
marshalVerifyRequest,
|
|
11
13
|
unmarshalDataKey,
|
|
12
14
|
unmarshalDecryptResponse,
|
|
13
15
|
unmarshalEncryptResponse,
|
|
14
16
|
unmarshalKey,
|
|
15
|
-
unmarshalListKeysResponse
|
|
17
|
+
unmarshalListKeysResponse,
|
|
18
|
+
unmarshalPublicKey,
|
|
19
|
+
unmarshalSignResponse,
|
|
20
|
+
unmarshalVerifyResponse
|
|
16
21
|
};
|
|
@@ -19,6 +19,8 @@ const unmarshalKeyUsage = (data) => {
|
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
21
|
return {
|
|
22
|
+
asymmetricEncryption: data.asymmetric_encryption ? data.asymmetric_encryption : void 0,
|
|
23
|
+
asymmetricSigning: data.asymmetric_signing ? data.asymmetric_signing : void 0,
|
|
22
24
|
symmetricEncryption: data.symmetric_encryption ? data.symmetric_encryption : void 0
|
|
23
25
|
};
|
|
24
26
|
};
|
|
@@ -95,13 +97,47 @@ const unmarshalListKeysResponse = (data) => {
|
|
|
95
97
|
totalCount: data.total_count
|
|
96
98
|
};
|
|
97
99
|
};
|
|
100
|
+
const unmarshalPublicKey = (data) => {
|
|
101
|
+
if (!sdkClient.isJSONObject(data)) {
|
|
102
|
+
throw new TypeError(
|
|
103
|
+
`Unmarshalling the type 'PublicKey' failed as data isn't a dictionary.`
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
pem: data.pem
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
const unmarshalSignResponse = (data) => {
|
|
111
|
+
if (!sdkClient.isJSONObject(data)) {
|
|
112
|
+
throw new TypeError(
|
|
113
|
+
`Unmarshalling the type 'SignResponse' failed as data isn't a dictionary.`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
keyId: data.key_id,
|
|
118
|
+
signature: data.signature
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
const unmarshalVerifyResponse = (data) => {
|
|
122
|
+
if (!sdkClient.isJSONObject(data)) {
|
|
123
|
+
throw new TypeError(
|
|
124
|
+
`Unmarshalling the type 'VerifyResponse' failed as data isn't a dictionary.`
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
keyId: data.key_id,
|
|
129
|
+
valid: data.valid
|
|
130
|
+
};
|
|
131
|
+
};
|
|
98
132
|
const marshalKeyRotationPolicy = (request, defaults) => ({
|
|
99
133
|
next_rotation_at: request.nextRotationAt,
|
|
100
134
|
rotation_period: request.rotationPeriod
|
|
101
135
|
});
|
|
102
136
|
const marshalKeyUsage = (request, defaults) => ({
|
|
103
137
|
...sdkClient.resolveOneOf([
|
|
104
|
-
{ param: "symmetric_encryption", value: request.symmetricEncryption }
|
|
138
|
+
{ param: "symmetric_encryption", value: request.symmetricEncryption },
|
|
139
|
+
{ param: "asymmetric_encryption", value: request.asymmetricEncryption },
|
|
140
|
+
{ param: "asymmetric_signing", value: request.asymmetricSigning }
|
|
105
141
|
])
|
|
106
142
|
});
|
|
107
143
|
const marshalCreateKeyRequest = (request, defaults) => ({
|
|
@@ -130,20 +166,32 @@ const marshalImportKeyMaterialRequest = (request, defaults) => ({
|
|
|
130
166
|
key_material: request.keyMaterial,
|
|
131
167
|
salt: request.salt
|
|
132
168
|
});
|
|
169
|
+
const marshalSignRequest = (request, defaults) => ({
|
|
170
|
+
digest: request.digest
|
|
171
|
+
});
|
|
133
172
|
const marshalUpdateKeyRequest = (request, defaults) => ({
|
|
134
173
|
description: request.description,
|
|
135
174
|
name: request.name,
|
|
136
175
|
rotation_policy: request.rotationPolicy !== void 0 ? marshalKeyRotationPolicy(request.rotationPolicy) : void 0,
|
|
137
176
|
tags: request.tags
|
|
138
177
|
});
|
|
178
|
+
const marshalVerifyRequest = (request, defaults) => ({
|
|
179
|
+
digest: request.digest,
|
|
180
|
+
signature: request.signature
|
|
181
|
+
});
|
|
139
182
|
exports.marshalCreateKeyRequest = marshalCreateKeyRequest;
|
|
140
183
|
exports.marshalDecryptRequest = marshalDecryptRequest;
|
|
141
184
|
exports.marshalEncryptRequest = marshalEncryptRequest;
|
|
142
185
|
exports.marshalGenerateDataKeyRequest = marshalGenerateDataKeyRequest;
|
|
143
186
|
exports.marshalImportKeyMaterialRequest = marshalImportKeyMaterialRequest;
|
|
187
|
+
exports.marshalSignRequest = marshalSignRequest;
|
|
144
188
|
exports.marshalUpdateKeyRequest = marshalUpdateKeyRequest;
|
|
189
|
+
exports.marshalVerifyRequest = marshalVerifyRequest;
|
|
145
190
|
exports.unmarshalDataKey = unmarshalDataKey;
|
|
146
191
|
exports.unmarshalDecryptResponse = unmarshalDecryptResponse;
|
|
147
192
|
exports.unmarshalEncryptResponse = unmarshalEncryptResponse;
|
|
148
193
|
exports.unmarshalKey = unmarshalKey;
|
|
149
194
|
exports.unmarshalListKeysResponse = unmarshalListKeysResponse;
|
|
195
|
+
exports.unmarshalPublicKey = unmarshalPublicKey;
|
|
196
|
+
exports.unmarshalSignResponse = unmarshalSignResponse;
|
|
197
|
+
exports.unmarshalVerifyResponse = unmarshalVerifyResponse;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import type { DefaultValues } from '@scaleway/sdk-client';
|
|
2
|
-
import type { CreateKeyRequest, DataKey, DecryptRequest, DecryptResponse, EncryptRequest, EncryptResponse, GenerateDataKeyRequest, ImportKeyMaterialRequest, Key, ListKeysResponse, UpdateKeyRequest } from './types.gen';
|
|
2
|
+
import type { CreateKeyRequest, DataKey, DecryptRequest, DecryptResponse, EncryptRequest, EncryptResponse, GenerateDataKeyRequest, ImportKeyMaterialRequest, Key, ListKeysResponse, PublicKey, SignRequest, SignResponse, UpdateKeyRequest, VerifyRequest, VerifyResponse } from './types.gen';
|
|
3
3
|
export declare const unmarshalKey: (data: unknown) => Key;
|
|
4
4
|
export declare const unmarshalDataKey: (data: unknown) => DataKey;
|
|
5
5
|
export declare const unmarshalDecryptResponse: (data: unknown) => DecryptResponse;
|
|
6
6
|
export declare const unmarshalEncryptResponse: (data: unknown) => EncryptResponse;
|
|
7
7
|
export declare const unmarshalListKeysResponse: (data: unknown) => ListKeysResponse;
|
|
8
|
+
export declare const unmarshalPublicKey: (data: unknown) => PublicKey;
|
|
9
|
+
export declare const unmarshalSignResponse: (data: unknown) => SignResponse;
|
|
10
|
+
export declare const unmarshalVerifyResponse: (data: unknown) => VerifyResponse;
|
|
8
11
|
export declare const marshalCreateKeyRequest: (request: CreateKeyRequest, defaults: DefaultValues) => Record<string, unknown>;
|
|
9
12
|
export declare const marshalDecryptRequest: (request: DecryptRequest, defaults: DefaultValues) => Record<string, unknown>;
|
|
10
13
|
export declare const marshalEncryptRequest: (request: EncryptRequest, defaults: DefaultValues) => Record<string, unknown>;
|
|
11
14
|
export declare const marshalGenerateDataKeyRequest: (request: GenerateDataKeyRequest, defaults: DefaultValues) => Record<string, unknown>;
|
|
12
15
|
export declare const marshalImportKeyMaterialRequest: (request: ImportKeyMaterialRequest, defaults: DefaultValues) => Record<string, unknown>;
|
|
16
|
+
export declare const marshalSignRequest: (request: SignRequest, defaults: DefaultValues) => Record<string, unknown>;
|
|
13
17
|
export declare const marshalUpdateKeyRequest: (request: UpdateKeyRequest, defaults: DefaultValues) => Record<string, unknown>;
|
|
18
|
+
export declare const marshalVerifyRequest: (request: VerifyRequest, defaults: DefaultValues) => Record<string, unknown>;
|
|
@@ -17,6 +17,8 @@ const unmarshalKeyUsage = (data) => {
|
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
19
|
return {
|
|
20
|
+
asymmetricEncryption: data.asymmetric_encryption ? data.asymmetric_encryption : void 0,
|
|
21
|
+
asymmetricSigning: data.asymmetric_signing ? data.asymmetric_signing : void 0,
|
|
20
22
|
symmetricEncryption: data.symmetric_encryption ? data.symmetric_encryption : void 0
|
|
21
23
|
};
|
|
22
24
|
};
|
|
@@ -93,13 +95,47 @@ const unmarshalListKeysResponse = (data) => {
|
|
|
93
95
|
totalCount: data.total_count
|
|
94
96
|
};
|
|
95
97
|
};
|
|
98
|
+
const unmarshalPublicKey = (data) => {
|
|
99
|
+
if (!isJSONObject(data)) {
|
|
100
|
+
throw new TypeError(
|
|
101
|
+
`Unmarshalling the type 'PublicKey' failed as data isn't a dictionary.`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
pem: data.pem
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
const unmarshalSignResponse = (data) => {
|
|
109
|
+
if (!isJSONObject(data)) {
|
|
110
|
+
throw new TypeError(
|
|
111
|
+
`Unmarshalling the type 'SignResponse' failed as data isn't a dictionary.`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
keyId: data.key_id,
|
|
116
|
+
signature: data.signature
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
const unmarshalVerifyResponse = (data) => {
|
|
120
|
+
if (!isJSONObject(data)) {
|
|
121
|
+
throw new TypeError(
|
|
122
|
+
`Unmarshalling the type 'VerifyResponse' failed as data isn't a dictionary.`
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
keyId: data.key_id,
|
|
127
|
+
valid: data.valid
|
|
128
|
+
};
|
|
129
|
+
};
|
|
96
130
|
const marshalKeyRotationPolicy = (request, defaults) => ({
|
|
97
131
|
next_rotation_at: request.nextRotationAt,
|
|
98
132
|
rotation_period: request.rotationPeriod
|
|
99
133
|
});
|
|
100
134
|
const marshalKeyUsage = (request, defaults) => ({
|
|
101
135
|
...resolveOneOf([
|
|
102
|
-
{ param: "symmetric_encryption", value: request.symmetricEncryption }
|
|
136
|
+
{ param: "symmetric_encryption", value: request.symmetricEncryption },
|
|
137
|
+
{ param: "asymmetric_encryption", value: request.asymmetricEncryption },
|
|
138
|
+
{ param: "asymmetric_signing", value: request.asymmetricSigning }
|
|
103
139
|
])
|
|
104
140
|
});
|
|
105
141
|
const marshalCreateKeyRequest = (request, defaults) => ({
|
|
@@ -128,22 +164,34 @@ const marshalImportKeyMaterialRequest = (request, defaults) => ({
|
|
|
128
164
|
key_material: request.keyMaterial,
|
|
129
165
|
salt: request.salt
|
|
130
166
|
});
|
|
167
|
+
const marshalSignRequest = (request, defaults) => ({
|
|
168
|
+
digest: request.digest
|
|
169
|
+
});
|
|
131
170
|
const marshalUpdateKeyRequest = (request, defaults) => ({
|
|
132
171
|
description: request.description,
|
|
133
172
|
name: request.name,
|
|
134
173
|
rotation_policy: request.rotationPolicy !== void 0 ? marshalKeyRotationPolicy(request.rotationPolicy) : void 0,
|
|
135
174
|
tags: request.tags
|
|
136
175
|
});
|
|
176
|
+
const marshalVerifyRequest = (request, defaults) => ({
|
|
177
|
+
digest: request.digest,
|
|
178
|
+
signature: request.signature
|
|
179
|
+
});
|
|
137
180
|
export {
|
|
138
181
|
marshalCreateKeyRequest,
|
|
139
182
|
marshalDecryptRequest,
|
|
140
183
|
marshalEncryptRequest,
|
|
141
184
|
marshalGenerateDataKeyRequest,
|
|
142
185
|
marshalImportKeyMaterialRequest,
|
|
186
|
+
marshalSignRequest,
|
|
143
187
|
marshalUpdateKeyRequest,
|
|
188
|
+
marshalVerifyRequest,
|
|
144
189
|
unmarshalDataKey,
|
|
145
190
|
unmarshalDecryptResponse,
|
|
146
191
|
unmarshalEncryptResponse,
|
|
147
192
|
unmarshalKey,
|
|
148
|
-
unmarshalListKeysResponse
|
|
193
|
+
unmarshalListKeysResponse,
|
|
194
|
+
unmarshalPublicKey,
|
|
195
|
+
unmarshalSignResponse,
|
|
196
|
+
unmarshalVerifyResponse
|
|
149
197
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Region as ScwRegion } from '@scaleway/sdk-client';
|
|
2
2
|
export type DataKeyAlgorithmSymmetricEncryption = 'unknown_symmetric_encryption' | 'aes_256_gcm';
|
|
3
|
+
export type KeyAlgorithmAsymmetricEncryption = 'unknown_asymmetric_encryption' | 'rsa_oaep_2048_sha256' | 'rsa_oaep_3072_sha256' | 'rsa_oaep_4096_sha256';
|
|
4
|
+
export type KeyAlgorithmAsymmetricSigning = 'unknown_asymmetric_signing' | 'ec_p256_sha256' | 'ec_p384_sha384' | 'rsa_pss_2048_sha256' | 'rsa_pss_3072_sha256' | 'rsa_pss_4096_sha256' | 'rsa_pkcs1_2048_sha256' | 'rsa_pkcs1_3072_sha256' | 'rsa_pkcs1_4096_sha256';
|
|
3
5
|
export type KeyAlgorithmSymmetricEncryption = 'unknown_symmetric_encryption' | 'aes_256_gcm';
|
|
4
6
|
export type KeyOrigin = 'unknown_origin' | 'scaleway_kms' | 'external';
|
|
5
7
|
export type KeyState = 'unknown_state' | 'enabled' | 'disabled' | 'pending_key_material';
|
|
@@ -18,9 +20,19 @@ export interface KeyUsage {
|
|
|
18
20
|
/**
|
|
19
21
|
* See the `Key.Algorithm.SymmetricEncryption` enum for a description of values.
|
|
20
22
|
*
|
|
21
|
-
* One-of ('usage'): at most one of 'symmetricEncryption' could be set.
|
|
23
|
+
* One-of ('usage'): at most one of 'symmetricEncryption', 'asymmetricEncryption', 'asymmetricSigning' could be set.
|
|
22
24
|
*/
|
|
23
25
|
symmetricEncryption?: KeyAlgorithmSymmetricEncryption;
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* One-of ('usage'): at most one of 'symmetricEncryption', 'asymmetricEncryption', 'asymmetricSigning' could be set.
|
|
29
|
+
*/
|
|
30
|
+
asymmetricEncryption?: KeyAlgorithmAsymmetricEncryption;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* One-of ('usage'): at most one of 'symmetricEncryption', 'asymmetricEncryption', 'asymmetricSigning' could be set.
|
|
34
|
+
*/
|
|
35
|
+
asymmetricSigning?: KeyAlgorithmAsymmetricSigning;
|
|
24
36
|
}
|
|
25
37
|
export interface Key {
|
|
26
38
|
/**
|
|
@@ -154,7 +166,7 @@ export type DecryptRequest = {
|
|
|
154
166
|
*/
|
|
155
167
|
region?: ScwRegion;
|
|
156
168
|
/**
|
|
157
|
-
*
|
|
169
|
+
* The key must have an usage set to `symmetric_encryption` or `asymmetric_encryption`.
|
|
158
170
|
*/
|
|
159
171
|
keyId: string;
|
|
160
172
|
/**
|
|
@@ -162,7 +174,7 @@ export type DecryptRequest = {
|
|
|
162
174
|
*/
|
|
163
175
|
ciphertext: string;
|
|
164
176
|
/**
|
|
165
|
-
* The additional data must match the value passed in the encryption request.
|
|
177
|
+
* The additional data must match the value passed in the encryption request. Only supported by keys with a usage set to `symmetric_encryption`.
|
|
166
178
|
*/
|
|
167
179
|
associatedData?: string;
|
|
168
180
|
};
|
|
@@ -226,7 +238,7 @@ export type EncryptRequest = {
|
|
|
226
238
|
*/
|
|
227
239
|
region?: ScwRegion;
|
|
228
240
|
/**
|
|
229
|
-
*
|
|
241
|
+
* The key must have an usage set to `symmetric_encryption` or `asymmetric_encryption`.
|
|
230
242
|
*/
|
|
231
243
|
keyId: string;
|
|
232
244
|
/**
|
|
@@ -234,7 +246,7 @@ export type EncryptRequest = {
|
|
|
234
246
|
*/
|
|
235
247
|
plaintext: string;
|
|
236
248
|
/**
|
|
237
|
-
* Additional data which will not be encrypted, but authenticated and appended to the encrypted payload.
|
|
249
|
+
* Additional data which will not be encrypted, but authenticated and appended to the encrypted payload. Only supported by keys with a usage set to `symmetric_encryption`.
|
|
238
250
|
*/
|
|
239
251
|
associatedData?: string;
|
|
240
252
|
};
|
|
@@ -277,6 +289,16 @@ export type GetKeyRequest = {
|
|
|
277
289
|
*/
|
|
278
290
|
keyId: string;
|
|
279
291
|
};
|
|
292
|
+
export type GetPublicKeyRequest = {
|
|
293
|
+
/**
|
|
294
|
+
* Region to target. If none is passed will use default region from the config.
|
|
295
|
+
*/
|
|
296
|
+
region?: ScwRegion;
|
|
297
|
+
/**
|
|
298
|
+
* ID of the key.
|
|
299
|
+
*/
|
|
300
|
+
keyId: string;
|
|
301
|
+
};
|
|
280
302
|
export type ImportKeyMaterialRequest = {
|
|
281
303
|
/**
|
|
282
304
|
* Region to target. If none is passed will use default region from the config.
|
|
@@ -340,6 +362,9 @@ export type ProtectKeyRequest = {
|
|
|
340
362
|
*/
|
|
341
363
|
keyId: string;
|
|
342
364
|
};
|
|
365
|
+
export interface PublicKey {
|
|
366
|
+
pem: string;
|
|
367
|
+
}
|
|
343
368
|
export type RotateKeyRequest = {
|
|
344
369
|
/**
|
|
345
370
|
* Region to target. If none is passed will use default region from the config.
|
|
@@ -350,6 +375,30 @@ export type RotateKeyRequest = {
|
|
|
350
375
|
*/
|
|
351
376
|
keyId: string;
|
|
352
377
|
};
|
|
378
|
+
export type SignRequest = {
|
|
379
|
+
/**
|
|
380
|
+
* Region to target. If none is passed will use default region from the config.
|
|
381
|
+
*/
|
|
382
|
+
region?: ScwRegion;
|
|
383
|
+
/**
|
|
384
|
+
* ID of the key to use for signing.
|
|
385
|
+
*/
|
|
386
|
+
keyId: string;
|
|
387
|
+
/**
|
|
388
|
+
* The digest must be generated using the same algorithm defined in the key’s algorithm settings.
|
|
389
|
+
*/
|
|
390
|
+
digest: string;
|
|
391
|
+
};
|
|
392
|
+
export interface SignResponse {
|
|
393
|
+
/**
|
|
394
|
+
* ID of the key used to generate the signature.
|
|
395
|
+
*/
|
|
396
|
+
keyId: string;
|
|
397
|
+
/**
|
|
398
|
+
* The message signature.
|
|
399
|
+
*/
|
|
400
|
+
signature: string;
|
|
401
|
+
}
|
|
353
402
|
export type UnprotectKeyRequest = {
|
|
354
403
|
/**
|
|
355
404
|
* Region to target. If none is passed will use default region from the config.
|
|
@@ -386,3 +435,31 @@ export type UpdateKeyRequest = {
|
|
|
386
435
|
*/
|
|
387
436
|
rotationPolicy?: KeyRotationPolicy;
|
|
388
437
|
};
|
|
438
|
+
export type VerifyRequest = {
|
|
439
|
+
/**
|
|
440
|
+
* Region to target. If none is passed will use default region from the config.
|
|
441
|
+
*/
|
|
442
|
+
region?: ScwRegion;
|
|
443
|
+
/**
|
|
444
|
+
* ID of the key to use for signature verification.
|
|
445
|
+
*/
|
|
446
|
+
keyId: string;
|
|
447
|
+
/**
|
|
448
|
+
* Must be generated using the same algorithm specified in the key’s configuration.
|
|
449
|
+
*/
|
|
450
|
+
digest: string;
|
|
451
|
+
/**
|
|
452
|
+
* The message signature to verify.
|
|
453
|
+
*/
|
|
454
|
+
signature: string;
|
|
455
|
+
};
|
|
456
|
+
export interface VerifyResponse {
|
|
457
|
+
/**
|
|
458
|
+
* ID of the key used for verification.
|
|
459
|
+
*/
|
|
460
|
+
keyId: string;
|
|
461
|
+
/**
|
|
462
|
+
* Returns `true` if the signature is valid for the digest and key, `false` otherwise.
|
|
463
|
+
*/
|
|
464
|
+
valid: boolean;
|
|
465
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleway/sdk-key-manager",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Scaleway SDK key-manager",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -26,21 +26,18 @@
|
|
|
26
26
|
"directory": "packages_generated/key-manager"
|
|
27
27
|
},
|
|
28
28
|
"engines": {
|
|
29
|
-
"node": ">=20.
|
|
29
|
+
"node": ">=20.19.1"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@scaleway/random-name": "5.1.1",
|
|
33
|
-
"@scaleway/sdk-std": "1.0.
|
|
33
|
+
"@scaleway/sdk-std": "1.0.3"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@scaleway/sdk-client": "^1.2.
|
|
36
|
+
"@scaleway/sdk-client": "^1.2.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@scaleway/sdk-client": "^1.2.
|
|
39
|
+
"@scaleway/sdk-client": "^1.2.2"
|
|
40
40
|
},
|
|
41
|
-
"bundledDependencies": [
|
|
42
|
-
"@scaleway/random-name"
|
|
43
|
-
],
|
|
44
41
|
"scripts": {
|
|
45
42
|
"package:check": "pnpm publint",
|
|
46
43
|
"typecheck": "tsc --noEmit",
|