@scaleway/sdk-key-manager 1.0.1 → 1.2.0
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 +47 -1
- package/dist/v1alpha1/api.gen.d.ts +22 -1
- package/dist/v1alpha1/api.gen.js +48 -2
- 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 +87 -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
|
*
|
|
@@ -157,7 +170,8 @@ class API extends sdkClient.API {
|
|
|
157
170
|
request.pageSize ?? this.client.settings.defaultPageSize
|
|
158
171
|
],
|
|
159
172
|
["project_id", request.projectId],
|
|
160
|
-
["tags", request.tags]
|
|
173
|
+
["tags", request.tags],
|
|
174
|
+
["usage", request.usage]
|
|
161
175
|
)
|
|
162
176
|
},
|
|
163
177
|
marshalling_gen.unmarshalListKeysResponse
|
|
@@ -222,6 +236,38 @@ class API extends sdkClient.API {
|
|
|
222
236
|
},
|
|
223
237
|
marshalling_gen.unmarshalDecryptResponse
|
|
224
238
|
);
|
|
239
|
+
/**
|
|
240
|
+
* 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.
|
|
241
|
+
*
|
|
242
|
+
* @param request - The request {@link SignRequest}
|
|
243
|
+
* @returns A Promise of SignResponse
|
|
244
|
+
*/
|
|
245
|
+
sign = (request) => this.client.fetch(
|
|
246
|
+
{
|
|
247
|
+
body: JSON.stringify(marshalling_gen.marshalSignRequest(request, this.client.settings)),
|
|
248
|
+
headers: jsonContentHeaders,
|
|
249
|
+
method: "POST",
|
|
250
|
+
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}/sign`
|
|
251
|
+
},
|
|
252
|
+
marshalling_gen.unmarshalSignResponse
|
|
253
|
+
);
|
|
254
|
+
/**
|
|
255
|
+
* 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.
|
|
256
|
+
*
|
|
257
|
+
* @param request - The request {@link VerifyRequest}
|
|
258
|
+
* @returns A Promise of VerifyResponse
|
|
259
|
+
*/
|
|
260
|
+
verify = (request) => this.client.fetch(
|
|
261
|
+
{
|
|
262
|
+
body: JSON.stringify(
|
|
263
|
+
marshalling_gen.marshalVerifyRequest(request, this.client.settings)
|
|
264
|
+
),
|
|
265
|
+
headers: jsonContentHeaders,
|
|
266
|
+
method: "POST",
|
|
267
|
+
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}/verify`
|
|
268
|
+
},
|
|
269
|
+
marshalling_gen.unmarshalVerifyResponse
|
|
270
|
+
);
|
|
225
271
|
/**
|
|
226
272
|
* 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
273
|
*
|
|
@@ -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
|
*
|
|
@@ -155,7 +168,8 @@ class API extends API$1 {
|
|
|
155
168
|
request.pageSize ?? this.client.settings.defaultPageSize
|
|
156
169
|
],
|
|
157
170
|
["project_id", request.projectId],
|
|
158
|
-
["tags", request.tags]
|
|
171
|
+
["tags", request.tags],
|
|
172
|
+
["usage", request.usage]
|
|
159
173
|
)
|
|
160
174
|
},
|
|
161
175
|
unmarshalListKeysResponse
|
|
@@ -220,6 +234,38 @@ class API extends API$1 {
|
|
|
220
234
|
},
|
|
221
235
|
unmarshalDecryptResponse
|
|
222
236
|
);
|
|
237
|
+
/**
|
|
238
|
+
* 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.
|
|
239
|
+
*
|
|
240
|
+
* @param request - The request {@link SignRequest}
|
|
241
|
+
* @returns A Promise of SignResponse
|
|
242
|
+
*/
|
|
243
|
+
sign = (request) => this.client.fetch(
|
|
244
|
+
{
|
|
245
|
+
body: JSON.stringify(marshalSignRequest(request, this.client.settings)),
|
|
246
|
+
headers: jsonContentHeaders,
|
|
247
|
+
method: "POST",
|
|
248
|
+
path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/sign`
|
|
249
|
+
},
|
|
250
|
+
unmarshalSignResponse
|
|
251
|
+
);
|
|
252
|
+
/**
|
|
253
|
+
* 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.
|
|
254
|
+
*
|
|
255
|
+
* @param request - The request {@link VerifyRequest}
|
|
256
|
+
* @returns A Promise of VerifyResponse
|
|
257
|
+
*/
|
|
258
|
+
verify = (request) => this.client.fetch(
|
|
259
|
+
{
|
|
260
|
+
body: JSON.stringify(
|
|
261
|
+
marshalVerifyRequest(request, this.client.settings)
|
|
262
|
+
),
|
|
263
|
+
headers: jsonContentHeaders,
|
|
264
|
+
method: "POST",
|
|
265
|
+
path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/verify`
|
|
266
|
+
},
|
|
267
|
+
unmarshalVerifyResponse
|
|
268
|
+
);
|
|
223
269
|
/**
|
|
224
270
|
* 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
271
|
*
|
|
@@ -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, ListKeysRequestUsage, 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,9 +1,12 @@
|
|
|
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';
|
|
6
8
|
export type ListKeysRequestOrderBy = 'name_asc' | 'name_desc' | 'created_at_asc' | 'created_at_desc' | 'updated_at_asc' | 'updated_at_desc';
|
|
9
|
+
export type ListKeysRequestUsage = 'unknown_usage' | 'symmetric_encryption' | 'asymmetric_encryption' | 'asymmetric_signing';
|
|
7
10
|
export interface KeyRotationPolicy {
|
|
8
11
|
/**
|
|
9
12
|
* Time interval between two key rotations. The minimum duration is 24 hours and the maximum duration is 1 year (876000 hours).
|
|
@@ -18,9 +21,19 @@ export interface KeyUsage {
|
|
|
18
21
|
/**
|
|
19
22
|
* See the `Key.Algorithm.SymmetricEncryption` enum for a description of values.
|
|
20
23
|
*
|
|
21
|
-
* One-of ('usage'): at most one of 'symmetricEncryption' could be set.
|
|
24
|
+
* One-of ('usage'): at most one of 'symmetricEncryption', 'asymmetricEncryption', 'asymmetricSigning' could be set.
|
|
22
25
|
*/
|
|
23
26
|
symmetricEncryption?: KeyAlgorithmSymmetricEncryption;
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* One-of ('usage'): at most one of 'symmetricEncryption', 'asymmetricEncryption', 'asymmetricSigning' could be set.
|
|
30
|
+
*/
|
|
31
|
+
asymmetricEncryption?: KeyAlgorithmAsymmetricEncryption;
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* One-of ('usage'): at most one of 'symmetricEncryption', 'asymmetricEncryption', 'asymmetricSigning' could be set.
|
|
35
|
+
*/
|
|
36
|
+
asymmetricSigning?: KeyAlgorithmAsymmetricSigning;
|
|
24
37
|
}
|
|
25
38
|
export interface Key {
|
|
26
39
|
/**
|
|
@@ -154,7 +167,7 @@ export type DecryptRequest = {
|
|
|
154
167
|
*/
|
|
155
168
|
region?: ScwRegion;
|
|
156
169
|
/**
|
|
157
|
-
*
|
|
170
|
+
* The key must have an usage set to `symmetric_encryption` or `asymmetric_encryption`.
|
|
158
171
|
*/
|
|
159
172
|
keyId: string;
|
|
160
173
|
/**
|
|
@@ -162,7 +175,7 @@ export type DecryptRequest = {
|
|
|
162
175
|
*/
|
|
163
176
|
ciphertext: string;
|
|
164
177
|
/**
|
|
165
|
-
* The additional data must match the value passed in the encryption request.
|
|
178
|
+
* The additional data must match the value passed in the encryption request. Only supported by keys with a usage set to `symmetric_encryption`.
|
|
166
179
|
*/
|
|
167
180
|
associatedData?: string;
|
|
168
181
|
};
|
|
@@ -226,7 +239,7 @@ export type EncryptRequest = {
|
|
|
226
239
|
*/
|
|
227
240
|
region?: ScwRegion;
|
|
228
241
|
/**
|
|
229
|
-
*
|
|
242
|
+
* The key must have an usage set to `symmetric_encryption` or `asymmetric_encryption`.
|
|
230
243
|
*/
|
|
231
244
|
keyId: string;
|
|
232
245
|
/**
|
|
@@ -234,7 +247,7 @@ export type EncryptRequest = {
|
|
|
234
247
|
*/
|
|
235
248
|
plaintext: string;
|
|
236
249
|
/**
|
|
237
|
-
* Additional data which will not be encrypted, but authenticated and appended to the encrypted payload.
|
|
250
|
+
* 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
251
|
*/
|
|
239
252
|
associatedData?: string;
|
|
240
253
|
};
|
|
@@ -277,6 +290,16 @@ export type GetKeyRequest = {
|
|
|
277
290
|
*/
|
|
278
291
|
keyId: string;
|
|
279
292
|
};
|
|
293
|
+
export type GetPublicKeyRequest = {
|
|
294
|
+
/**
|
|
295
|
+
* Region to target. If none is passed will use default region from the config.
|
|
296
|
+
*/
|
|
297
|
+
region?: ScwRegion;
|
|
298
|
+
/**
|
|
299
|
+
* ID of the key.
|
|
300
|
+
*/
|
|
301
|
+
keyId: string;
|
|
302
|
+
};
|
|
280
303
|
export type ImportKeyMaterialRequest = {
|
|
281
304
|
/**
|
|
282
305
|
* Region to target. If none is passed will use default region from the config.
|
|
@@ -319,6 +342,10 @@ export type ListKeysRequest = {
|
|
|
319
342
|
* (Optional) Filter by key name.
|
|
320
343
|
*/
|
|
321
344
|
name?: string;
|
|
345
|
+
/**
|
|
346
|
+
* Select from symmetric encryption, asymmetric encryption, or asymmetric signing.
|
|
347
|
+
*/
|
|
348
|
+
usage?: ListKeysRequestUsage;
|
|
322
349
|
};
|
|
323
350
|
export interface ListKeysResponse {
|
|
324
351
|
/**
|
|
@@ -340,6 +367,9 @@ export type ProtectKeyRequest = {
|
|
|
340
367
|
*/
|
|
341
368
|
keyId: string;
|
|
342
369
|
};
|
|
370
|
+
export interface PublicKey {
|
|
371
|
+
pem: string;
|
|
372
|
+
}
|
|
343
373
|
export type RotateKeyRequest = {
|
|
344
374
|
/**
|
|
345
375
|
* Region to target. If none is passed will use default region from the config.
|
|
@@ -350,6 +380,30 @@ export type RotateKeyRequest = {
|
|
|
350
380
|
*/
|
|
351
381
|
keyId: string;
|
|
352
382
|
};
|
|
383
|
+
export type SignRequest = {
|
|
384
|
+
/**
|
|
385
|
+
* Region to target. If none is passed will use default region from the config.
|
|
386
|
+
*/
|
|
387
|
+
region?: ScwRegion;
|
|
388
|
+
/**
|
|
389
|
+
* ID of the key to use for signing.
|
|
390
|
+
*/
|
|
391
|
+
keyId: string;
|
|
392
|
+
/**
|
|
393
|
+
* The digest must be generated using the same algorithm defined in the key’s algorithm settings.
|
|
394
|
+
*/
|
|
395
|
+
digest: string;
|
|
396
|
+
};
|
|
397
|
+
export interface SignResponse {
|
|
398
|
+
/**
|
|
399
|
+
* ID of the key used to generate the signature.
|
|
400
|
+
*/
|
|
401
|
+
keyId: string;
|
|
402
|
+
/**
|
|
403
|
+
* The message signature.
|
|
404
|
+
*/
|
|
405
|
+
signature: string;
|
|
406
|
+
}
|
|
353
407
|
export type UnprotectKeyRequest = {
|
|
354
408
|
/**
|
|
355
409
|
* Region to target. If none is passed will use default region from the config.
|
|
@@ -386,3 +440,31 @@ export type UpdateKeyRequest = {
|
|
|
386
440
|
*/
|
|
387
441
|
rotationPolicy?: KeyRotationPolicy;
|
|
388
442
|
};
|
|
443
|
+
export type VerifyRequest = {
|
|
444
|
+
/**
|
|
445
|
+
* Region to target. If none is passed will use default region from the config.
|
|
446
|
+
*/
|
|
447
|
+
region?: ScwRegion;
|
|
448
|
+
/**
|
|
449
|
+
* ID of the key to use for signature verification.
|
|
450
|
+
*/
|
|
451
|
+
keyId: string;
|
|
452
|
+
/**
|
|
453
|
+
* Must be generated using the same algorithm specified in the key’s configuration.
|
|
454
|
+
*/
|
|
455
|
+
digest: string;
|
|
456
|
+
/**
|
|
457
|
+
* The message signature to verify.
|
|
458
|
+
*/
|
|
459
|
+
signature: string;
|
|
460
|
+
};
|
|
461
|
+
export interface VerifyResponse {
|
|
462
|
+
/**
|
|
463
|
+
* ID of the key used for verification.
|
|
464
|
+
*/
|
|
465
|
+
keyId: string;
|
|
466
|
+
/**
|
|
467
|
+
* Returns `true` if the signature is valid for the digest and key, `false` otherwise.
|
|
468
|
+
*/
|
|
469
|
+
valid: boolean;
|
|
470
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleway/sdk-key-manager",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
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",
|