@scaleway/sdk-key-manager 1.4.0 → 2.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/README.md +96 -0
- package/dist/v1alpha1/api.gen.d.ts +1 -1
- package/dist/v1alpha1/api.gen.js +26 -17
- package/dist/v1alpha1/index.gen.d.ts +1 -1
- package/dist/v1alpha1/marshalling.gen.js +13 -7
- package/package.json +6 -9
- package/dist/index.gen.cjs +0 -4
- package/dist/v1alpha1/api.gen.cjs +0 -331
- package/dist/v1alpha1/index.gen.cjs +0 -22
- package/dist/v1alpha1/marshalling.gen.cjs +0 -224
package/README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# @scaleway/sdk-key-manager
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@scaleway/sdk-key-manager)
|
|
4
|
+
[](https://www.npmjs.com/package/@scaleway/sdk-key-manager)
|
|
5
|
+
[](https://github.com/scaleway/scaleway-sdk-js/blob/master/LICENSE)
|
|
6
|
+
|
|
7
|
+
Scaleway SDK for Key Manager API.
|
|
8
|
+
|
|
9
|
+
> **Note**
|
|
10
|
+
> This is an automatically generated package that is part of the [Scaleway SDK for JavaScript](https://github.com/scaleway/scaleway-sdk-js).
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @scaleway/sdk-key-manager @scaleway/sdk-client
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
or with pnpm:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pnpm add @scaleway/sdk-key-manager @scaleway/sdk-client
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
or with yarn:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
yarn add @scaleway/sdk-key-manager @scaleway/sdk-client
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Getting Started
|
|
31
|
+
|
|
32
|
+
You'll need a pair of access and secret keys to connect to Scaleway API. Please check the [documentation](https://www.scaleway.com/en/docs/identity-and-access-management/iam/how-to/create-api-keys/) on how to retrieve them.
|
|
33
|
+
|
|
34
|
+
### Basic Usage
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { createClient } from '@scaleway/sdk-client'
|
|
38
|
+
import { KeyManager } from '@scaleway/sdk-key-manager'
|
|
39
|
+
|
|
40
|
+
const client = createClient({
|
|
41
|
+
accessKey: 'SCWXXXXXXXXXXXXXXXXX',
|
|
42
|
+
secretKey: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
|
|
43
|
+
defaultProjectId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
|
|
44
|
+
defaultRegion: 'fr-par',
|
|
45
|
+
defaultZone: 'fr-par-1',
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const api = new KeyManager.v1.API(client)
|
|
49
|
+
|
|
50
|
+
// Use the API
|
|
51
|
+
// Example: await api.listServers()
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Using Configuration Loader
|
|
55
|
+
|
|
56
|
+
For a simpler setup, you can load credentials from the configuration file or environment variables:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { createClient } from '@scaleway/sdk-client'
|
|
60
|
+
import { loadProfileFromConfigurationFile } from '@scaleway/configuration-loader'
|
|
61
|
+
import { KeyManager } from '@scaleway/sdk-key-manager'
|
|
62
|
+
|
|
63
|
+
const profile = loadProfileFromConfigurationFile()
|
|
64
|
+
const client = createClient(profile)
|
|
65
|
+
const api = new KeyManager.v1.API(client)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Documentation
|
|
69
|
+
|
|
70
|
+
- 📚 [Scaleway SDK Reference Documentation](https://scaleway.github.io/scaleway-sdk-js)
|
|
71
|
+
- 🌐 [Scaleway Key Manager API Documentation](https://www.scaleway.com/en/developers/api/key-manager/)
|
|
72
|
+
- 📖 [Main Repository](https://github.com/scaleway/scaleway-sdk-js)
|
|
73
|
+
- 💡 [Example Projects](https://github.com/scaleway/scaleway-sdk-js/tree/master/examples)
|
|
74
|
+
|
|
75
|
+
## Features
|
|
76
|
+
|
|
77
|
+
- ✅ Full TypeScript support with complete type definitions
|
|
78
|
+
- ✅ Promise-based API
|
|
79
|
+
- ✅ Automatic pagination helpers
|
|
80
|
+
- ✅ Built-in error handling
|
|
81
|
+
- ✅ Compatible with Node.js ≥ 20
|
|
82
|
+
|
|
83
|
+
## Support
|
|
84
|
+
|
|
85
|
+
We love feedback! Feel free to reach us on:
|
|
86
|
+
- [Scaleway Slack community](https://slack.scaleway.com/) - Join us on [#opensource](https://scaleway-community.slack.com/app_redirect?channel=opensource)
|
|
87
|
+
- [GitHub Issues](https://github.com/scaleway/scaleway-sdk-js/issues)
|
|
88
|
+
|
|
89
|
+
## Contributing
|
|
90
|
+
|
|
91
|
+
This repository is at its early stage and is still in active development. If you are looking for a way to contribute, please read [CONTRIBUTING.md](https://github.com/scaleway/scaleway-sdk-js/blob/master/CONTRIBUTING.md).
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
This project is Apache 2.0 licensed. See the [LICENSE](https://github.com/scaleway/scaleway-sdk-js/blob/master/LICENSE) file for details.
|
|
96
|
+
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { API as ParentAPI } from '@scaleway/sdk-client';
|
|
2
1
|
import type { ApiLocality } from '@scaleway/sdk-client';
|
|
2
|
+
import { API as ParentAPI } from '@scaleway/sdk-client';
|
|
3
3
|
import type { CreateKeyRequest, DataKey, DecryptRequest, DecryptResponse, DeleteKeyMaterialRequest, DeleteKeyRequest, DisableKeyRequest, EnableKeyRequest, EncryptRequest, EncryptResponse, GenerateDataKeyRequest, GetKeyRequest, GetPublicKeyRequest, ImportKeyMaterialRequest, Key, ListAlgorithmsRequest, ListAlgorithmsResponse, ListKeysRequest, ListKeysResponse, ProtectKeyRequest, PublicKey, RestoreKeyRequest, RotateKeyRequest, SignRequest, SignResponse, UnprotectKeyRequest, UpdateKeyRequest, VerifyRequest, VerifyResponse } from './types.gen.js';
|
|
4
4
|
/**
|
|
5
5
|
* Key Manager API.
|
package/dist/v1alpha1/api.gen.js
CHANGED
|
@@ -9,7 +9,11 @@ class API extends API$1 {
|
|
|
9
9
|
* type ∈ {'zone','region','global','unspecified'}
|
|
10
10
|
*/
|
|
11
11
|
static LOCALITY = toApiLocality({
|
|
12
|
-
regions: [
|
|
12
|
+
regions: [
|
|
13
|
+
"fr-par",
|
|
14
|
+
"nl-ams",
|
|
15
|
+
"pl-waw"
|
|
16
|
+
]
|
|
13
17
|
});
|
|
14
18
|
/**
|
|
15
19
|
* Create a key. Create a key in a given region specified by the `region` parameter. You can use keys to encrypt or decrypt arbitrary payloads, to sign and verify messages or to generate data encryption keys. **Data encryption keys are not stored in Key Manager**.
|
|
@@ -76,10 +80,12 @@ class API extends API$1 {
|
|
|
76
80
|
*
|
|
77
81
|
* @param request - The request {@link DeleteKeyRequest}
|
|
78
82
|
*/
|
|
79
|
-
deleteKey = (request) => this.client.fetch(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
deleteKey = (request) => this.client.fetch(
|
|
84
|
+
{
|
|
85
|
+
method: "DELETE",
|
|
86
|
+
path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}`
|
|
87
|
+
}
|
|
88
|
+
);
|
|
83
89
|
/**
|
|
84
90
|
* Rotate a key. Generate a new version of an existing key with new key material. Previous key versions remain usable to decrypt previously encrypted data, but the key's new version will be used for subsequent encryption operations and data key generation.
|
|
85
91
|
*
|
|
@@ -164,10 +170,7 @@ class API extends API$1 {
|
|
|
164
170
|
["order_by", request.orderBy],
|
|
165
171
|
["organization_id", request.organizationId],
|
|
166
172
|
["page", request.page],
|
|
167
|
-
[
|
|
168
|
-
"page_size",
|
|
169
|
-
request.pageSize ?? this.client.settings.defaultPageSize
|
|
170
|
-
],
|
|
173
|
+
["page_size", request.pageSize ?? this.client.settings.defaultPageSize],
|
|
171
174
|
["project_id", request.projectId],
|
|
172
175
|
["scheduled_for_deletion", request.scheduledForDeletion],
|
|
173
176
|
["tags", request.tags],
|
|
@@ -244,7 +247,9 @@ class API extends API$1 {
|
|
|
244
247
|
*/
|
|
245
248
|
sign = (request) => this.client.fetch(
|
|
246
249
|
{
|
|
247
|
-
body: JSON.stringify(
|
|
250
|
+
body: JSON.stringify(
|
|
251
|
+
marshalSignRequest(request, this.client.settings)
|
|
252
|
+
),
|
|
248
253
|
headers: jsonContentHeaders,
|
|
249
254
|
method: "POST",
|
|
250
255
|
path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/sign`
|
|
@@ -290,12 +295,14 @@ class API extends API$1 {
|
|
|
290
295
|
*
|
|
291
296
|
* @param request - The request {@link DeleteKeyMaterialRequest}
|
|
292
297
|
*/
|
|
293
|
-
deleteKeyMaterial = (request) => this.client.fetch(
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
298
|
+
deleteKeyMaterial = (request) => this.client.fetch(
|
|
299
|
+
{
|
|
300
|
+
body: "{}",
|
|
301
|
+
headers: jsonContentHeaders,
|
|
302
|
+
method: "POST",
|
|
303
|
+
path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/delete-key-material`
|
|
304
|
+
}
|
|
305
|
+
);
|
|
299
306
|
/**
|
|
300
307
|
* Restore a key. Restore a key and all its rotations scheduled for deletion specified by the `region` and `key_id` parameters.
|
|
301
308
|
*
|
|
@@ -321,7 +328,9 @@ class API extends API$1 {
|
|
|
321
328
|
{
|
|
322
329
|
method: "GET",
|
|
323
330
|
path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/algorithms`,
|
|
324
|
-
urlParams: urlParams(
|
|
331
|
+
urlParams: urlParams(
|
|
332
|
+
["usages", request.usages]
|
|
333
|
+
)
|
|
325
334
|
},
|
|
326
335
|
unmarshalListAlgorithmsResponse
|
|
327
336
|
);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { API } from './api.gen.js';
|
|
1
|
+
export { API, } from './api.gen.js';
|
|
2
2
|
export * from './marshalling.gen.js';
|
|
3
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, ListAlgorithmsRequest, ListAlgorithmsRequestUsage, ListAlgorithmsResponse, ListAlgorithmsResponseAlgorithm, ListKeysRequest, ListKeysRequestOrderBy, ListKeysRequestUsage, ListKeysResponse, ProtectKeyRequest, PublicKey, RestoreKeyRequest, RotateKeyRequest, SignRequest, SignResponse, UnprotectKeyRequest, UpdateKeyRequest, VerifyRequest, VerifyResponse, } from './types.gen.js';
|
|
@@ -104,10 +104,7 @@ const unmarshalListAlgorithmsResponse = (data) => {
|
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
106
|
return {
|
|
107
|
-
algorithms: unmarshalArrayOfObject(
|
|
108
|
-
data.algorithms,
|
|
109
|
-
unmarshalListAlgorithmsResponseAlgorithm
|
|
110
|
-
)
|
|
107
|
+
algorithms: unmarshalArrayOfObject(data.algorithms, unmarshalListAlgorithmsResponseAlgorithm)
|
|
111
108
|
};
|
|
112
109
|
};
|
|
113
110
|
const unmarshalListKeysResponse = (data) => {
|
|
@@ -159,9 +156,18 @@ const marshalKeyRotationPolicy = (request, defaults) => ({
|
|
|
159
156
|
});
|
|
160
157
|
const marshalKeyUsage = (request, defaults) => ({
|
|
161
158
|
...resolveOneOf([
|
|
162
|
-
{
|
|
163
|
-
|
|
164
|
-
|
|
159
|
+
{
|
|
160
|
+
param: "symmetric_encryption",
|
|
161
|
+
value: request.symmetricEncryption
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
param: "asymmetric_encryption",
|
|
165
|
+
value: request.asymmetricEncryption
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
param: "asymmetric_signing",
|
|
169
|
+
value: request.asymmetricSigning
|
|
170
|
+
}
|
|
165
171
|
])
|
|
166
172
|
});
|
|
167
173
|
const marshalCreateKeyRequest = (request, defaults) => ({
|
package/package.json
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleway/sdk-key-manager",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Scaleway SDK key-manager",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"files": [
|
|
7
|
+
"README.md",
|
|
7
8
|
"dist"
|
|
8
9
|
],
|
|
9
10
|
"type": "module",
|
|
10
11
|
"exports": {
|
|
11
12
|
".": {
|
|
12
13
|
"types": "./dist/index.gen.d.ts",
|
|
13
|
-
"import": "./dist/index.gen.js",
|
|
14
|
-
"require": "./dist/index.gen.cjs",
|
|
15
14
|
"default": "./dist/index.gen.js"
|
|
16
15
|
},
|
|
17
16
|
"./*": {
|
|
18
17
|
"types": "./dist/*/index.gen.d.ts",
|
|
19
|
-
"import": "./dist/*/index.gen.js",
|
|
20
|
-
"require": "./dist/*/index.gen.cjs",
|
|
21
18
|
"default": "./dist/*/index.gen.js"
|
|
22
19
|
}
|
|
23
20
|
},
|
|
@@ -26,17 +23,17 @@
|
|
|
26
23
|
"directory": "packages_generated/key-manager"
|
|
27
24
|
},
|
|
28
25
|
"engines": {
|
|
29
|
-
"node": ">=20.19.
|
|
26
|
+
"node": ">=20.19.6"
|
|
30
27
|
},
|
|
31
28
|
"dependencies": {
|
|
32
29
|
"@scaleway/random-name": "5.1.2",
|
|
33
|
-
"@scaleway/sdk-std": "
|
|
30
|
+
"@scaleway/sdk-std": "2.1.0"
|
|
34
31
|
},
|
|
35
32
|
"peerDependencies": {
|
|
36
|
-
"@scaleway/sdk-client": "^1.
|
|
33
|
+
"@scaleway/sdk-client": "^2.1.0"
|
|
37
34
|
},
|
|
38
35
|
"devDependencies": {
|
|
39
|
-
"@scaleway/sdk-client": "^1.
|
|
36
|
+
"@scaleway/sdk-client": "^2.1.0"
|
|
40
37
|
},
|
|
41
38
|
"scripts": {
|
|
42
39
|
"package:check": "pnpm publint",
|
package/dist/index.gen.cjs
DELETED
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const sdkClient = require("@scaleway/sdk-client");
|
|
4
|
-
const marshalling_gen = require("./marshalling.gen.cjs");
|
|
5
|
-
const jsonContentHeaders = {
|
|
6
|
-
"Content-Type": "application/json; charset=utf-8"
|
|
7
|
-
};
|
|
8
|
-
class API extends sdkClient.API {
|
|
9
|
-
/**
|
|
10
|
-
* Locality of this API.
|
|
11
|
-
* type ∈ {'zone','region','global','unspecified'}
|
|
12
|
-
*/
|
|
13
|
-
static LOCALITY = sdkClient.toApiLocality({
|
|
14
|
-
regions: ["fr-par", "nl-ams", "pl-waw"]
|
|
15
|
-
});
|
|
16
|
-
/**
|
|
17
|
-
* Create a key. Create a key in a given region specified by the `region` parameter. You can use keys to encrypt or decrypt arbitrary payloads, to sign and verify messages or to generate data encryption keys. **Data encryption keys are not stored in Key Manager**.
|
|
18
|
-
*
|
|
19
|
-
* @param request - The request {@link CreateKeyRequest}
|
|
20
|
-
* @returns A Promise of Key
|
|
21
|
-
*/
|
|
22
|
-
createKey = (request) => this.client.fetch(
|
|
23
|
-
{
|
|
24
|
-
body: JSON.stringify(
|
|
25
|
-
marshalling_gen.marshalCreateKeyRequest(request, this.client.settings)
|
|
26
|
-
),
|
|
27
|
-
headers: jsonContentHeaders,
|
|
28
|
-
method: "POST",
|
|
29
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys`
|
|
30
|
-
},
|
|
31
|
-
marshalling_gen.unmarshalKey
|
|
32
|
-
);
|
|
33
|
-
/**
|
|
34
|
-
* Get key metadata. Retrieve metadata for a specified key using the `region` and `key_id` parameters.
|
|
35
|
-
*
|
|
36
|
-
* @param request - The request {@link GetKeyRequest}
|
|
37
|
-
* @returns A Promise of Key
|
|
38
|
-
*/
|
|
39
|
-
getKey = (request) => this.client.fetch(
|
|
40
|
-
{
|
|
41
|
-
method: "GET",
|
|
42
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}`
|
|
43
|
-
},
|
|
44
|
-
marshalling_gen.unmarshalKey
|
|
45
|
-
);
|
|
46
|
-
/**
|
|
47
|
-
* Get the public key in PEM format.. Retrieves the public portion of an asymmetric cryptographic key in PEM format.
|
|
48
|
-
*
|
|
49
|
-
* @param request - The request {@link GetPublicKeyRequest}
|
|
50
|
-
* @returns A Promise of PublicKey
|
|
51
|
-
*/
|
|
52
|
-
getPublicKey = (request) => this.client.fetch(
|
|
53
|
-
{
|
|
54
|
-
method: "GET",
|
|
55
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}/public-key`
|
|
56
|
-
},
|
|
57
|
-
marshalling_gen.unmarshalPublicKey
|
|
58
|
-
);
|
|
59
|
-
/**
|
|
60
|
-
* Update a key. Modify a key's metadata including name, description and tags, specified by the `key_id` and `region` parameters.
|
|
61
|
-
*
|
|
62
|
-
* @param request - The request {@link UpdateKeyRequest}
|
|
63
|
-
* @returns A Promise of Key
|
|
64
|
-
*/
|
|
65
|
-
updateKey = (request) => this.client.fetch(
|
|
66
|
-
{
|
|
67
|
-
body: JSON.stringify(
|
|
68
|
-
marshalling_gen.marshalUpdateKeyRequest(request, this.client.settings)
|
|
69
|
-
),
|
|
70
|
-
headers: jsonContentHeaders,
|
|
71
|
-
method: "PATCH",
|
|
72
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}`
|
|
73
|
-
},
|
|
74
|
-
marshalling_gen.unmarshalKey
|
|
75
|
-
);
|
|
76
|
-
/**
|
|
77
|
-
* Delete a key. Permanently delete a key specified by the `region` and `key_id` parameters. This action is irreversible. Any data encrypted with this key, including data encryption keys, will no longer be decipherable.
|
|
78
|
-
*
|
|
79
|
-
* @param request - The request {@link DeleteKeyRequest}
|
|
80
|
-
*/
|
|
81
|
-
deleteKey = (request) => this.client.fetch({
|
|
82
|
-
method: "DELETE",
|
|
83
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}`
|
|
84
|
-
});
|
|
85
|
-
/**
|
|
86
|
-
* Rotate a key. Generate a new version of an existing key with new key material. Previous key versions remain usable to decrypt previously encrypted data, but the key's new version will be used for subsequent encryption operations and data key generation.
|
|
87
|
-
*
|
|
88
|
-
* @param request - The request {@link RotateKeyRequest}
|
|
89
|
-
* @returns A Promise of Key
|
|
90
|
-
*/
|
|
91
|
-
rotateKey = (request) => this.client.fetch(
|
|
92
|
-
{
|
|
93
|
-
body: "{}",
|
|
94
|
-
headers: jsonContentHeaders,
|
|
95
|
-
method: "POST",
|
|
96
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}/rotate`
|
|
97
|
-
},
|
|
98
|
-
marshalling_gen.unmarshalKey
|
|
99
|
-
);
|
|
100
|
-
/**
|
|
101
|
-
* Apply key protection. Apply protection to a given key specified by the `key_id` parameter. Applying key protection means that your key can be used and modified, but it cannot be deleted.
|
|
102
|
-
*
|
|
103
|
-
* @param request - The request {@link ProtectKeyRequest}
|
|
104
|
-
* @returns A Promise of Key
|
|
105
|
-
*/
|
|
106
|
-
protectKey = (request) => this.client.fetch(
|
|
107
|
-
{
|
|
108
|
-
body: "{}",
|
|
109
|
-
headers: jsonContentHeaders,
|
|
110
|
-
method: "POST",
|
|
111
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}/protect`
|
|
112
|
-
},
|
|
113
|
-
marshalling_gen.unmarshalKey
|
|
114
|
-
);
|
|
115
|
-
/**
|
|
116
|
-
* Remove key protection. Remove key protection from a given key specified by the `key_id` parameter. Removing key protection means that your key can be deleted anytime.
|
|
117
|
-
*
|
|
118
|
-
* @param request - The request {@link UnprotectKeyRequest}
|
|
119
|
-
* @returns A Promise of Key
|
|
120
|
-
*/
|
|
121
|
-
unprotectKey = (request) => this.client.fetch(
|
|
122
|
-
{
|
|
123
|
-
body: "{}",
|
|
124
|
-
headers: jsonContentHeaders,
|
|
125
|
-
method: "POST",
|
|
126
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}/unprotect`
|
|
127
|
-
},
|
|
128
|
-
marshalling_gen.unmarshalKey
|
|
129
|
-
);
|
|
130
|
-
/**
|
|
131
|
-
* Enable key. Enable a given key to be used for cryptographic operations. Enabling a key allows you to make a disabled key usable again. You must specify the `region` and `key_id` parameters.
|
|
132
|
-
*
|
|
133
|
-
* @param request - The request {@link EnableKeyRequest}
|
|
134
|
-
* @returns A Promise of Key
|
|
135
|
-
*/
|
|
136
|
-
enableKey = (request) => this.client.fetch(
|
|
137
|
-
{
|
|
138
|
-
body: "{}",
|
|
139
|
-
headers: jsonContentHeaders,
|
|
140
|
-
method: "POST",
|
|
141
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}/enable`
|
|
142
|
-
},
|
|
143
|
-
marshalling_gen.unmarshalKey
|
|
144
|
-
);
|
|
145
|
-
/**
|
|
146
|
-
* Disable key. Disable a given key, preventing it to be used for cryptographic operations. Disabling a key renders it unusable. You must specify the `region` and `key_id` parameters.
|
|
147
|
-
*
|
|
148
|
-
* @param request - The request {@link DisableKeyRequest}
|
|
149
|
-
* @returns A Promise of Key
|
|
150
|
-
*/
|
|
151
|
-
disableKey = (request) => this.client.fetch(
|
|
152
|
-
{
|
|
153
|
-
body: "{}",
|
|
154
|
-
headers: jsonContentHeaders,
|
|
155
|
-
method: "POST",
|
|
156
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}/disable`
|
|
157
|
-
},
|
|
158
|
-
marshalling_gen.unmarshalKey
|
|
159
|
-
);
|
|
160
|
-
pageOfListKeys = (request) => this.client.fetch(
|
|
161
|
-
{
|
|
162
|
-
method: "GET",
|
|
163
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys`,
|
|
164
|
-
urlParams: sdkClient.urlParams(
|
|
165
|
-
["name", request.name],
|
|
166
|
-
["order_by", request.orderBy],
|
|
167
|
-
["organization_id", request.organizationId],
|
|
168
|
-
["page", request.page],
|
|
169
|
-
[
|
|
170
|
-
"page_size",
|
|
171
|
-
request.pageSize ?? this.client.settings.defaultPageSize
|
|
172
|
-
],
|
|
173
|
-
["project_id", request.projectId],
|
|
174
|
-
["scheduled_for_deletion", request.scheduledForDeletion],
|
|
175
|
-
["tags", request.tags],
|
|
176
|
-
["usage", request.usage]
|
|
177
|
-
)
|
|
178
|
-
},
|
|
179
|
-
marshalling_gen.unmarshalListKeysResponse
|
|
180
|
-
);
|
|
181
|
-
/**
|
|
182
|
-
* List keys. Retrieve a list of keys across all Projects in an Organization or within a specific Project. You must specify the `region`, and either the `organization_id` or the `project_id`.
|
|
183
|
-
*
|
|
184
|
-
* @param request - The request {@link ListKeysRequest}
|
|
185
|
-
* @returns A Promise of ListKeysResponse
|
|
186
|
-
*/
|
|
187
|
-
listKeys = (request) => sdkClient.enrichForPagination("keys", this.pageOfListKeys, request);
|
|
188
|
-
/**
|
|
189
|
-
* Create a data encryption key. Create a new data encryption key for cryptographic operations outside of Key Manager. The data encryption key is encrypted and must be decrypted using the key you have created in Key Manager.
|
|
190
|
-
|
|
191
|
-
The data encryption key is returned in plaintext and ciphertext but it should only be stored in its encrypted form (ciphertext). Key Manager does not store your data encryption key. To retrieve your key's plaintext, use the `Decrypt` method with your key's ID and ciphertext.
|
|
192
|
-
*
|
|
193
|
-
* @param request - The request {@link GenerateDataKeyRequest}
|
|
194
|
-
* @returns A Promise of DataKey
|
|
195
|
-
*/
|
|
196
|
-
generateDataKey = (request) => this.client.fetch(
|
|
197
|
-
{
|
|
198
|
-
body: JSON.stringify(
|
|
199
|
-
marshalling_gen.marshalGenerateDataKeyRequest(request, this.client.settings)
|
|
200
|
-
),
|
|
201
|
-
headers: jsonContentHeaders,
|
|
202
|
-
method: "POST",
|
|
203
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}/generate-data-key`
|
|
204
|
-
},
|
|
205
|
-
marshalling_gen.unmarshalDataKey
|
|
206
|
-
);
|
|
207
|
-
/**
|
|
208
|
-
* Encrypt a payload. Encrypt a payload using an existing key, specified by the `key_id` parameter. The maximum payload size that can be encrypted is 64 KB of plaintext.
|
|
209
|
-
*
|
|
210
|
-
* @param request - The request {@link EncryptRequest}
|
|
211
|
-
* @returns A Promise of EncryptResponse
|
|
212
|
-
*/
|
|
213
|
-
encrypt = (request) => this.client.fetch(
|
|
214
|
-
{
|
|
215
|
-
body: JSON.stringify(
|
|
216
|
-
marshalling_gen.marshalEncryptRequest(request, this.client.settings)
|
|
217
|
-
),
|
|
218
|
-
headers: jsonContentHeaders,
|
|
219
|
-
method: "POST",
|
|
220
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}/encrypt`
|
|
221
|
-
},
|
|
222
|
-
marshalling_gen.unmarshalEncryptResponse
|
|
223
|
-
);
|
|
224
|
-
/**
|
|
225
|
-
* Decrypt an encrypted payload. Decrypt an encrypted payload using an existing key, specified by the `key_id` parameter. The maximum payload size that can be decrypted is equivalent to the encrypted output of 64 KB of data (around 131 KB).
|
|
226
|
-
*
|
|
227
|
-
* @param request - The request {@link DecryptRequest}
|
|
228
|
-
* @returns A Promise of DecryptResponse
|
|
229
|
-
*/
|
|
230
|
-
decrypt = (request) => this.client.fetch(
|
|
231
|
-
{
|
|
232
|
-
body: JSON.stringify(
|
|
233
|
-
marshalling_gen.marshalDecryptRequest(request, this.client.settings)
|
|
234
|
-
),
|
|
235
|
-
headers: jsonContentHeaders,
|
|
236
|
-
method: "POST",
|
|
237
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}/decrypt`
|
|
238
|
-
},
|
|
239
|
-
marshalling_gen.unmarshalDecryptResponse
|
|
240
|
-
);
|
|
241
|
-
/**
|
|
242
|
-
* 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.
|
|
243
|
-
*
|
|
244
|
-
* @param request - The request {@link SignRequest}
|
|
245
|
-
* @returns A Promise of SignResponse
|
|
246
|
-
*/
|
|
247
|
-
sign = (request) => this.client.fetch(
|
|
248
|
-
{
|
|
249
|
-
body: JSON.stringify(marshalling_gen.marshalSignRequest(request, this.client.settings)),
|
|
250
|
-
headers: jsonContentHeaders,
|
|
251
|
-
method: "POST",
|
|
252
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}/sign`
|
|
253
|
-
},
|
|
254
|
-
marshalling_gen.unmarshalSignResponse
|
|
255
|
-
);
|
|
256
|
-
/**
|
|
257
|
-
* 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.
|
|
258
|
-
*
|
|
259
|
-
* @param request - The request {@link VerifyRequest}
|
|
260
|
-
* @returns A Promise of VerifyResponse
|
|
261
|
-
*/
|
|
262
|
-
verify = (request) => this.client.fetch(
|
|
263
|
-
{
|
|
264
|
-
body: JSON.stringify(
|
|
265
|
-
marshalling_gen.marshalVerifyRequest(request, this.client.settings)
|
|
266
|
-
),
|
|
267
|
-
headers: jsonContentHeaders,
|
|
268
|
-
method: "POST",
|
|
269
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}/verify`
|
|
270
|
-
},
|
|
271
|
-
marshalling_gen.unmarshalVerifyResponse
|
|
272
|
-
);
|
|
273
|
-
/**
|
|
274
|
-
* Import key material. Import externally generated key material into Key Manager to derive a new cryptographic key. The key's origin must be `external`.
|
|
275
|
-
*
|
|
276
|
-
* @param request - The request {@link ImportKeyMaterialRequest}
|
|
277
|
-
* @returns A Promise of Key
|
|
278
|
-
*/
|
|
279
|
-
importKeyMaterial = (request) => this.client.fetch(
|
|
280
|
-
{
|
|
281
|
-
body: JSON.stringify(
|
|
282
|
-
marshalling_gen.marshalImportKeyMaterialRequest(request, this.client.settings)
|
|
283
|
-
),
|
|
284
|
-
headers: jsonContentHeaders,
|
|
285
|
-
method: "POST",
|
|
286
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}/import-key-material`
|
|
287
|
-
},
|
|
288
|
-
marshalling_gen.unmarshalKey
|
|
289
|
-
);
|
|
290
|
-
/**
|
|
291
|
-
* Delete key material. Delete previously imported key material. This renders the associated cryptographic key unusable for any operation. The key's origin must be `external`.
|
|
292
|
-
*
|
|
293
|
-
* @param request - The request {@link DeleteKeyMaterialRequest}
|
|
294
|
-
*/
|
|
295
|
-
deleteKeyMaterial = (request) => this.client.fetch({
|
|
296
|
-
body: "{}",
|
|
297
|
-
headers: jsonContentHeaders,
|
|
298
|
-
method: "POST",
|
|
299
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}/delete-key-material`
|
|
300
|
-
});
|
|
301
|
-
/**
|
|
302
|
-
* Restore a key. Restore a key and all its rotations scheduled for deletion specified by the `region` and `key_id` parameters.
|
|
303
|
-
*
|
|
304
|
-
* @param request - The request {@link RestoreKeyRequest}
|
|
305
|
-
* @returns A Promise of Key
|
|
306
|
-
*/
|
|
307
|
-
restoreKey = (request) => this.client.fetch(
|
|
308
|
-
{
|
|
309
|
-
body: "{}",
|
|
310
|
-
headers: jsonContentHeaders,
|
|
311
|
-
method: "POST",
|
|
312
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${sdkClient.validatePathParam("keyId", request.keyId)}/restore`
|
|
313
|
-
},
|
|
314
|
-
marshalling_gen.unmarshalKey
|
|
315
|
-
);
|
|
316
|
-
/**
|
|
317
|
-
* List all available algorithms. Lists all cryptographic algorithms supported by the Key Manager service.
|
|
318
|
-
*
|
|
319
|
-
* @param request - The request {@link ListAlgorithmsRequest}
|
|
320
|
-
* @returns A Promise of ListAlgorithmsResponse
|
|
321
|
-
*/
|
|
322
|
-
listAlgorithms = (request = {}) => this.client.fetch(
|
|
323
|
-
{
|
|
324
|
-
method: "GET",
|
|
325
|
-
path: `/key-manager/v1alpha1/regions/${sdkClient.validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/algorithms`,
|
|
326
|
-
urlParams: sdkClient.urlParams(["usages", request.usages])
|
|
327
|
-
},
|
|
328
|
-
marshalling_gen.unmarshalListAlgorithmsResponse
|
|
329
|
-
);
|
|
330
|
-
}
|
|
331
|
-
exports.API = API;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const api_gen = require("./api.gen.cjs");
|
|
4
|
-
const marshalling_gen = require("./marshalling.gen.cjs");
|
|
5
|
-
exports.API = api_gen.API;
|
|
6
|
-
exports.marshalCreateKeyRequest = marshalling_gen.marshalCreateKeyRequest;
|
|
7
|
-
exports.marshalDecryptRequest = marshalling_gen.marshalDecryptRequest;
|
|
8
|
-
exports.marshalEncryptRequest = marshalling_gen.marshalEncryptRequest;
|
|
9
|
-
exports.marshalGenerateDataKeyRequest = marshalling_gen.marshalGenerateDataKeyRequest;
|
|
10
|
-
exports.marshalImportKeyMaterialRequest = marshalling_gen.marshalImportKeyMaterialRequest;
|
|
11
|
-
exports.marshalSignRequest = marshalling_gen.marshalSignRequest;
|
|
12
|
-
exports.marshalUpdateKeyRequest = marshalling_gen.marshalUpdateKeyRequest;
|
|
13
|
-
exports.marshalVerifyRequest = marshalling_gen.marshalVerifyRequest;
|
|
14
|
-
exports.unmarshalDataKey = marshalling_gen.unmarshalDataKey;
|
|
15
|
-
exports.unmarshalDecryptResponse = marshalling_gen.unmarshalDecryptResponse;
|
|
16
|
-
exports.unmarshalEncryptResponse = marshalling_gen.unmarshalEncryptResponse;
|
|
17
|
-
exports.unmarshalKey = marshalling_gen.unmarshalKey;
|
|
18
|
-
exports.unmarshalListAlgorithmsResponse = marshalling_gen.unmarshalListAlgorithmsResponse;
|
|
19
|
-
exports.unmarshalListKeysResponse = marshalling_gen.unmarshalListKeysResponse;
|
|
20
|
-
exports.unmarshalPublicKey = marshalling_gen.unmarshalPublicKey;
|
|
21
|
-
exports.unmarshalSignResponse = marshalling_gen.unmarshalSignResponse;
|
|
22
|
-
exports.unmarshalVerifyResponse = marshalling_gen.unmarshalVerifyResponse;
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const sdkClient = require("@scaleway/sdk-client");
|
|
4
|
-
const unmarshalKeyRotationPolicy = (data) => {
|
|
5
|
-
if (!sdkClient.isJSONObject(data)) {
|
|
6
|
-
throw new TypeError(
|
|
7
|
-
`Unmarshalling the type 'KeyRotationPolicy' failed as data isn't a dictionary.`
|
|
8
|
-
);
|
|
9
|
-
}
|
|
10
|
-
return {
|
|
11
|
-
nextRotationAt: sdkClient.unmarshalDate(data.next_rotation_at),
|
|
12
|
-
rotationPeriod: data.rotation_period
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
const unmarshalKeyUsage = (data) => {
|
|
16
|
-
if (!sdkClient.isJSONObject(data)) {
|
|
17
|
-
throw new TypeError(
|
|
18
|
-
`Unmarshalling the type 'KeyUsage' failed as data isn't a dictionary.`
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
asymmetricEncryption: data.asymmetric_encryption ? data.asymmetric_encryption : void 0,
|
|
23
|
-
asymmetricSigning: data.asymmetric_signing ? data.asymmetric_signing : void 0,
|
|
24
|
-
symmetricEncryption: data.symmetric_encryption ? data.symmetric_encryption : void 0
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
const unmarshalKey = (data) => {
|
|
28
|
-
if (!sdkClient.isJSONObject(data)) {
|
|
29
|
-
throw new TypeError(
|
|
30
|
-
`Unmarshalling the type 'Key' failed as data isn't a dictionary.`
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
createdAt: sdkClient.unmarshalDate(data.created_at),
|
|
35
|
-
deletionRequestedAt: sdkClient.unmarshalDate(data.deletion_requested_at),
|
|
36
|
-
description: data.description,
|
|
37
|
-
id: data.id,
|
|
38
|
-
locked: data.locked,
|
|
39
|
-
name: data.name,
|
|
40
|
-
origin: data.origin,
|
|
41
|
-
projectId: data.project_id,
|
|
42
|
-
protected: data.protected,
|
|
43
|
-
region: data.region,
|
|
44
|
-
rotatedAt: sdkClient.unmarshalDate(data.rotated_at),
|
|
45
|
-
rotationCount: data.rotation_count,
|
|
46
|
-
rotationPolicy: data.rotation_policy ? unmarshalKeyRotationPolicy(data.rotation_policy) : void 0,
|
|
47
|
-
state: data.state,
|
|
48
|
-
tags: data.tags,
|
|
49
|
-
updatedAt: sdkClient.unmarshalDate(data.updated_at),
|
|
50
|
-
usage: data.usage ? unmarshalKeyUsage(data.usage) : void 0
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
const unmarshalDataKey = (data) => {
|
|
54
|
-
if (!sdkClient.isJSONObject(data)) {
|
|
55
|
-
throw new TypeError(
|
|
56
|
-
`Unmarshalling the type 'DataKey' failed as data isn't a dictionary.`
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
algorithm: data.algorithm,
|
|
61
|
-
ciphertext: data.ciphertext,
|
|
62
|
-
createdAt: sdkClient.unmarshalDate(data.created_at),
|
|
63
|
-
keyId: data.key_id,
|
|
64
|
-
plaintext: data.plaintext
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
const unmarshalDecryptResponse = (data) => {
|
|
68
|
-
if (!sdkClient.isJSONObject(data)) {
|
|
69
|
-
throw new TypeError(
|
|
70
|
-
`Unmarshalling the type 'DecryptResponse' failed as data isn't a dictionary.`
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
ciphertext: data.ciphertext,
|
|
75
|
-
keyId: data.key_id,
|
|
76
|
-
plaintext: data.plaintext
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
const unmarshalEncryptResponse = (data) => {
|
|
80
|
-
if (!sdkClient.isJSONObject(data)) {
|
|
81
|
-
throw new TypeError(
|
|
82
|
-
`Unmarshalling the type 'EncryptResponse' failed as data isn't a dictionary.`
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
return {
|
|
86
|
-
ciphertext: data.ciphertext,
|
|
87
|
-
keyId: data.key_id
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
const unmarshalListAlgorithmsResponseAlgorithm = (data) => {
|
|
91
|
-
if (!sdkClient.isJSONObject(data)) {
|
|
92
|
-
throw new TypeError(
|
|
93
|
-
`Unmarshalling the type 'ListAlgorithmsResponseAlgorithm' failed as data isn't a dictionary.`
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
name: data.name,
|
|
98
|
-
recommended: data.recommended,
|
|
99
|
-
usage: data.usage
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
const unmarshalListAlgorithmsResponse = (data) => {
|
|
103
|
-
if (!sdkClient.isJSONObject(data)) {
|
|
104
|
-
throw new TypeError(
|
|
105
|
-
`Unmarshalling the type 'ListAlgorithmsResponse' failed as data isn't a dictionary.`
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
return {
|
|
109
|
-
algorithms: sdkClient.unmarshalArrayOfObject(
|
|
110
|
-
data.algorithms,
|
|
111
|
-
unmarshalListAlgorithmsResponseAlgorithm
|
|
112
|
-
)
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
const unmarshalListKeysResponse = (data) => {
|
|
116
|
-
if (!sdkClient.isJSONObject(data)) {
|
|
117
|
-
throw new TypeError(
|
|
118
|
-
`Unmarshalling the type 'ListKeysResponse' failed as data isn't a dictionary.`
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
return {
|
|
122
|
-
keys: sdkClient.unmarshalArrayOfObject(data.keys, unmarshalKey),
|
|
123
|
-
totalCount: data.total_count
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
const unmarshalPublicKey = (data) => {
|
|
127
|
-
if (!sdkClient.isJSONObject(data)) {
|
|
128
|
-
throw new TypeError(
|
|
129
|
-
`Unmarshalling the type 'PublicKey' failed as data isn't a dictionary.`
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
return {
|
|
133
|
-
pem: data.pem
|
|
134
|
-
};
|
|
135
|
-
};
|
|
136
|
-
const unmarshalSignResponse = (data) => {
|
|
137
|
-
if (!sdkClient.isJSONObject(data)) {
|
|
138
|
-
throw new TypeError(
|
|
139
|
-
`Unmarshalling the type 'SignResponse' failed as data isn't a dictionary.`
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
return {
|
|
143
|
-
keyId: data.key_id,
|
|
144
|
-
signature: data.signature
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
const unmarshalVerifyResponse = (data) => {
|
|
148
|
-
if (!sdkClient.isJSONObject(data)) {
|
|
149
|
-
throw new TypeError(
|
|
150
|
-
`Unmarshalling the type 'VerifyResponse' failed as data isn't a dictionary.`
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
return {
|
|
154
|
-
keyId: data.key_id,
|
|
155
|
-
valid: data.valid
|
|
156
|
-
};
|
|
157
|
-
};
|
|
158
|
-
const marshalKeyRotationPolicy = (request, defaults) => ({
|
|
159
|
-
next_rotation_at: request.nextRotationAt,
|
|
160
|
-
rotation_period: request.rotationPeriod
|
|
161
|
-
});
|
|
162
|
-
const marshalKeyUsage = (request, defaults) => ({
|
|
163
|
-
...sdkClient.resolveOneOf([
|
|
164
|
-
{ param: "symmetric_encryption", value: request.symmetricEncryption },
|
|
165
|
-
{ param: "asymmetric_encryption", value: request.asymmetricEncryption },
|
|
166
|
-
{ param: "asymmetric_signing", value: request.asymmetricSigning }
|
|
167
|
-
])
|
|
168
|
-
});
|
|
169
|
-
const marshalCreateKeyRequest = (request, defaults) => ({
|
|
170
|
-
description: request.description,
|
|
171
|
-
name: request.name,
|
|
172
|
-
origin: request.origin,
|
|
173
|
-
project_id: request.projectId ?? defaults.defaultProjectId,
|
|
174
|
-
rotation_policy: request.rotationPolicy !== void 0 ? marshalKeyRotationPolicy(request.rotationPolicy) : void 0,
|
|
175
|
-
tags: request.tags,
|
|
176
|
-
unprotected: request.unprotected,
|
|
177
|
-
usage: request.usage !== void 0 ? marshalKeyUsage(request.usage) : void 0
|
|
178
|
-
});
|
|
179
|
-
const marshalDecryptRequest = (request, defaults) => ({
|
|
180
|
-
associated_data: request.associatedData,
|
|
181
|
-
ciphertext: request.ciphertext
|
|
182
|
-
});
|
|
183
|
-
const marshalEncryptRequest = (request, defaults) => ({
|
|
184
|
-
associated_data: request.associatedData,
|
|
185
|
-
plaintext: request.plaintext
|
|
186
|
-
});
|
|
187
|
-
const marshalGenerateDataKeyRequest = (request, defaults) => ({
|
|
188
|
-
algorithm: request.algorithm,
|
|
189
|
-
without_plaintext: request.withoutPlaintext
|
|
190
|
-
});
|
|
191
|
-
const marshalImportKeyMaterialRequest = (request, defaults) => ({
|
|
192
|
-
key_material: request.keyMaterial,
|
|
193
|
-
salt: request.salt
|
|
194
|
-
});
|
|
195
|
-
const marshalSignRequest = (request, defaults) => ({
|
|
196
|
-
digest: request.digest
|
|
197
|
-
});
|
|
198
|
-
const marshalUpdateKeyRequest = (request, defaults) => ({
|
|
199
|
-
description: request.description,
|
|
200
|
-
name: request.name,
|
|
201
|
-
rotation_policy: request.rotationPolicy !== void 0 ? marshalKeyRotationPolicy(request.rotationPolicy) : void 0,
|
|
202
|
-
tags: request.tags
|
|
203
|
-
});
|
|
204
|
-
const marshalVerifyRequest = (request, defaults) => ({
|
|
205
|
-
digest: request.digest,
|
|
206
|
-
signature: request.signature
|
|
207
|
-
});
|
|
208
|
-
exports.marshalCreateKeyRequest = marshalCreateKeyRequest;
|
|
209
|
-
exports.marshalDecryptRequest = marshalDecryptRequest;
|
|
210
|
-
exports.marshalEncryptRequest = marshalEncryptRequest;
|
|
211
|
-
exports.marshalGenerateDataKeyRequest = marshalGenerateDataKeyRequest;
|
|
212
|
-
exports.marshalImportKeyMaterialRequest = marshalImportKeyMaterialRequest;
|
|
213
|
-
exports.marshalSignRequest = marshalSignRequest;
|
|
214
|
-
exports.marshalUpdateKeyRequest = marshalUpdateKeyRequest;
|
|
215
|
-
exports.marshalVerifyRequest = marshalVerifyRequest;
|
|
216
|
-
exports.unmarshalDataKey = unmarshalDataKey;
|
|
217
|
-
exports.unmarshalDecryptResponse = unmarshalDecryptResponse;
|
|
218
|
-
exports.unmarshalEncryptResponse = unmarshalEncryptResponse;
|
|
219
|
-
exports.unmarshalKey = unmarshalKey;
|
|
220
|
-
exports.unmarshalListAlgorithmsResponse = unmarshalListAlgorithmsResponse;
|
|
221
|
-
exports.unmarshalListKeysResponse = unmarshalListKeysResponse;
|
|
222
|
-
exports.unmarshalPublicKey = unmarshalPublicKey;
|
|
223
|
-
exports.unmarshalSignResponse = unmarshalSignResponse;
|
|
224
|
-
exports.unmarshalVerifyResponse = unmarshalVerifyResponse;
|