@scaleway/sdk-key-manager 2.8.2 → 2.10.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.
@@ -0,0 +1,3 @@
1
+ # Licenses
2
+
3
+ The app does not bundle any dependencies with licenses.
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * This file is automatically generated
3
+ * PLEASE DO NOT EDIT HERE
4
+ */
5
+ export * as KeyManagerv1alpha1 from './v1alpha1/index.gen.js';
@@ -0,0 +1,2 @@
1
+ import { index_gen_exports } from "./v1alpha1/index.gen.js";
2
+ export { index_gen_exports as KeyManagerv1alpha1 };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file is automatically generated
3
+ * PLEASE DO NOT EDIT HERE
4
+ */
5
+ export declare const pkgMetadata: {
6
+ readonly name: "@scaleway/sdk-key-manager";
7
+ readonly namespace: "key-manager";
8
+ readonly displayName: "Key Manager";
9
+ readonly versions: readonly ["v1alpha1"];
10
+ };
11
+ export type Metadata = typeof pkgMetadata;
12
+ export default pkgMetadata;
@@ -0,0 +1,13 @@
1
+ //#region src/metadata.gen.ts
2
+ /**
3
+ * This file is automatically generated
4
+ * PLEASE DO NOT EDIT HERE
5
+ */
6
+ const pkgMetadata = {
7
+ name: "@scaleway/sdk-key-manager",
8
+ namespace: "key-manager",
9
+ displayName: "Key Manager",
10
+ versions: ["v1alpha1"]
11
+ };
12
+ //#endregion
13
+ export { pkgMetadata as default, pkgMetadata };
@@ -0,0 +1,162 @@
1
+ import { API as ParentAPI } from '@scaleway/sdk-client';
2
+ import type { ApiLocality } from '@scaleway/sdk-client';
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
+ /**
5
+ * Key Manager API.
6
+
7
+ This API allows you to create, manage and use cryptographic keys in a centralized and secure service.
8
+ */
9
+ export declare class API extends ParentAPI {
10
+ /**
11
+ * Locality of this API.
12
+ * type ∈ {'zone','region','global','unspecified'}
13
+ */
14
+ static readonly LOCALITY: ApiLocality;
15
+ /**
16
+ * 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**.
17
+ *
18
+ * @param request - The request {@link CreateKeyRequest}
19
+ * @returns A Promise of Key
20
+ */
21
+ createKey: (request: Readonly<CreateKeyRequest>) => Promise<Key>;
22
+ /**
23
+ * Get key metadata. Retrieve metadata for a specified key using the `region` and `key_id` parameters.
24
+ *
25
+ * @param request - The request {@link GetKeyRequest}
26
+ * @returns A Promise of Key
27
+ */
28
+ getKey: (request: Readonly<GetKeyRequest>) => Promise<Key>;
29
+ /**
30
+ * Get the public key in PEM format.. Retrieves the public portion of an asymmetric cryptographic key in PEM format.
31
+ *
32
+ * @param request - The request {@link GetPublicKeyRequest}
33
+ * @returns A Promise of PublicKey
34
+ */
35
+ getPublicKey: (request: Readonly<GetPublicKeyRequest>) => Promise<PublicKey>;
36
+ /**
37
+ * Update a key. Modify a key's metadata including name, description and tags, specified by the `key_id` and `region` parameters.
38
+ *
39
+ * @param request - The request {@link UpdateKeyRequest}
40
+ * @returns A Promise of Key
41
+ */
42
+ updateKey: (request: Readonly<UpdateKeyRequest>) => Promise<Key>;
43
+ /**
44
+ * 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.
45
+ *
46
+ * @param request - The request {@link DeleteKeyRequest}
47
+ */
48
+ deleteKey: (request: Readonly<DeleteKeyRequest>) => Promise<void>;
49
+ /**
50
+ * 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.
51
+ *
52
+ * @param request - The request {@link RotateKeyRequest}
53
+ * @returns A Promise of Key
54
+ */
55
+ rotateKey: (request: Readonly<RotateKeyRequest>) => Promise<Key>;
56
+ /**
57
+ * 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.
58
+ *
59
+ * @param request - The request {@link ProtectKeyRequest}
60
+ * @returns A Promise of Key
61
+ */
62
+ protectKey: (request: Readonly<ProtectKeyRequest>) => Promise<Key>;
63
+ /**
64
+ * 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.
65
+ *
66
+ * @param request - The request {@link UnprotectKeyRequest}
67
+ * @returns A Promise of Key
68
+ */
69
+ unprotectKey: (request: Readonly<UnprotectKeyRequest>) => Promise<Key>;
70
+ /**
71
+ * 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.
72
+ *
73
+ * @param request - The request {@link EnableKeyRequest}
74
+ * @returns A Promise of Key
75
+ */
76
+ enableKey: (request: Readonly<EnableKeyRequest>) => Promise<Key>;
77
+ /**
78
+ * 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.
79
+ *
80
+ * @param request - The request {@link DisableKeyRequest}
81
+ * @returns A Promise of Key
82
+ */
83
+ disableKey: (request: Readonly<DisableKeyRequest>) => Promise<Key>;
84
+ protected pageOfListKeys: (request: Readonly<ListKeysRequest>) => Promise<ListKeysResponse>;
85
+ /**
86
+ * List keys. Retrieve a list of keys across all Projects in an Organization or within a specific Project.
87
+ If the user has permissions for all current and future projects: Either organization_id or project_id is required.
88
+ If the user has permissions for all current projects or only specific projects: The project_id is required.
89
+ The `region` parameter in path is needed in both case.
90
+ *
91
+ * @param request - The request {@link ListKeysRequest}
92
+ * @returns A Promise of ListKeysResponse
93
+ */
94
+ listKeys: (request: Readonly<ListKeysRequest>) => Promise<ListKeysResponse> & {
95
+ all: () => Promise<Key[]>;
96
+ [Symbol.asyncIterator]: () => AsyncGenerator<Key[], void, void>;
97
+ };
98
+ /**
99
+ * 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.
100
+
101
+ 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.
102
+ *
103
+ * @param request - The request {@link GenerateDataKeyRequest}
104
+ * @returns A Promise of DataKey
105
+ */
106
+ generateDataKey: (request: Readonly<GenerateDataKeyRequest>) => Promise<DataKey>;
107
+ /**
108
+ * 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.
109
+ *
110
+ * @param request - The request {@link EncryptRequest}
111
+ * @returns A Promise of EncryptResponse
112
+ */
113
+ encrypt: (request: Readonly<EncryptRequest>) => Promise<EncryptResponse>;
114
+ /**
115
+ * 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).
116
+ *
117
+ * @param request - The request {@link DecryptRequest}
118
+ * @returns A Promise of DecryptResponse
119
+ */
120
+ decrypt: (request: Readonly<DecryptRequest>) => Promise<DecryptResponse>;
121
+ /**
122
+ * 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.
123
+ *
124
+ * @param request - The request {@link SignRequest}
125
+ * @returns A Promise of SignResponse
126
+ */
127
+ sign: (request: Readonly<SignRequest>) => Promise<SignResponse>;
128
+ /**
129
+ * 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.
130
+ *
131
+ * @param request - The request {@link VerifyRequest}
132
+ * @returns A Promise of VerifyResponse
133
+ */
134
+ verify: (request: Readonly<VerifyRequest>) => Promise<VerifyResponse>;
135
+ /**
136
+ * Import key material. Import externally generated key material into Key Manager to derive a new cryptographic key. The key's origin must be `external`.
137
+ *
138
+ * @param request - The request {@link ImportKeyMaterialRequest}
139
+ * @returns A Promise of Key
140
+ */
141
+ importKeyMaterial: (request: Readonly<ImportKeyMaterialRequest>) => Promise<Key>;
142
+ /**
143
+ * 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`.
144
+ *
145
+ * @param request - The request {@link DeleteKeyMaterialRequest}
146
+ */
147
+ deleteKeyMaterial: (request: Readonly<DeleteKeyMaterialRequest>) => Promise<void>;
148
+ /**
149
+ * Restore a key. Restore a key and all its rotations scheduled for deletion specified by the `region` and `key_id` parameters.
150
+ *
151
+ * @param request - The request {@link RestoreKeyRequest}
152
+ * @returns A Promise of Key
153
+ */
154
+ restoreKey: (request: Readonly<RestoreKeyRequest>) => Promise<Key>;
155
+ /**
156
+ * List all available algorithms. Lists all cryptographic algorithms supported by the Key Manager service.
157
+ *
158
+ * @param request - The request {@link ListAlgorithmsRequest}
159
+ * @returns A Promise of ListAlgorithmsResponse
160
+ */
161
+ listAlgorithms: (request?: Readonly<ListAlgorithmsRequest>) => Promise<ListAlgorithmsResponse>;
162
+ }
@@ -0,0 +1,136 @@
1
+ import { marshalCreateKeyRequest, marshalDecryptRequest, marshalEncryptRequest, marshalGenerateDataKeyRequest, marshalImportKeyMaterialRequest, marshalSignRequest, marshalUpdateKeyRequest, marshalVerifyRequest, unmarshalDataKey, unmarshalDecryptResponse, unmarshalEncryptResponse, unmarshalKey, unmarshalListAlgorithmsResponse, unmarshalListKeysResponse, unmarshalPublicKey, unmarshalSignResponse, unmarshalVerifyResponse } from "./marshalling.gen.js";
2
+ import { API as API$1, enrichForPagination, toApiLocality, urlParams, validatePathParam } from "@scaleway/sdk-client";
3
+ //#region src/v1alpha1/api.gen.ts
4
+ const jsonContentHeaders = { "Content-Type": "application/json; charset=utf-8" };
5
+ /**
6
+ * Key Manager API.
7
+
8
+ This API allows you to create, manage and use cryptographic keys in a centralized and secure service.
9
+ */
10
+ var API = class extends API$1 {
11
+ constructor(..._args) {
12
+ super(..._args);
13
+ this.createKey = (request) => this.client.fetch({
14
+ body: JSON.stringify(marshalCreateKeyRequest(request, this.client.settings)),
15
+ headers: jsonContentHeaders,
16
+ method: "POST",
17
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys`
18
+ }, unmarshalKey);
19
+ this.getKey = (request) => this.client.fetch({
20
+ method: "GET",
21
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}`
22
+ }, unmarshalKey);
23
+ this.getPublicKey = (request) => this.client.fetch({
24
+ method: "GET",
25
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/public-key`
26
+ }, unmarshalPublicKey);
27
+ this.updateKey = (request) => this.client.fetch({
28
+ body: JSON.stringify(marshalUpdateKeyRequest(request, this.client.settings)),
29
+ headers: jsonContentHeaders,
30
+ method: "PATCH",
31
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}`
32
+ }, unmarshalKey);
33
+ this.deleteKey = (request) => this.client.fetch({
34
+ method: "DELETE",
35
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}`
36
+ });
37
+ this.rotateKey = (request) => this.client.fetch({
38
+ body: "{}",
39
+ headers: jsonContentHeaders,
40
+ method: "POST",
41
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/rotate`
42
+ }, unmarshalKey);
43
+ this.protectKey = (request) => this.client.fetch({
44
+ body: "{}",
45
+ headers: jsonContentHeaders,
46
+ method: "POST",
47
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/protect`
48
+ }, unmarshalKey);
49
+ this.unprotectKey = (request) => this.client.fetch({
50
+ body: "{}",
51
+ headers: jsonContentHeaders,
52
+ method: "POST",
53
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/unprotect`
54
+ }, unmarshalKey);
55
+ this.enableKey = (request) => this.client.fetch({
56
+ body: "{}",
57
+ headers: jsonContentHeaders,
58
+ method: "POST",
59
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/enable`
60
+ }, unmarshalKey);
61
+ this.disableKey = (request) => this.client.fetch({
62
+ body: "{}",
63
+ headers: jsonContentHeaders,
64
+ method: "POST",
65
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/disable`
66
+ }, unmarshalKey);
67
+ this.pageOfListKeys = (request) => this.client.fetch({
68
+ method: "GET",
69
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys`,
70
+ urlParams: urlParams(["name", request.name], ["order_by", request.orderBy], ["organization_id", request.organizationId], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["project_id", request.projectId], ["scheduled_for_deletion", request.scheduledForDeletion], ["tags", request.tags], ["usage", request.usage])
71
+ }, unmarshalListKeysResponse);
72
+ this.listKeys = (request) => enrichForPagination("keys", this.pageOfListKeys, request);
73
+ this.generateDataKey = (request) => this.client.fetch({
74
+ body: JSON.stringify(marshalGenerateDataKeyRequest(request, this.client.settings)),
75
+ headers: jsonContentHeaders,
76
+ method: "POST",
77
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/generate-data-key`
78
+ }, unmarshalDataKey);
79
+ this.encrypt = (request) => this.client.fetch({
80
+ body: JSON.stringify(marshalEncryptRequest(request, this.client.settings)),
81
+ headers: jsonContentHeaders,
82
+ method: "POST",
83
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/encrypt`
84
+ }, unmarshalEncryptResponse);
85
+ this.decrypt = (request) => this.client.fetch({
86
+ body: JSON.stringify(marshalDecryptRequest(request, this.client.settings)),
87
+ headers: jsonContentHeaders,
88
+ method: "POST",
89
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/decrypt`
90
+ }, unmarshalDecryptResponse);
91
+ this.sign = (request) => this.client.fetch({
92
+ body: JSON.stringify(marshalSignRequest(request, this.client.settings)),
93
+ headers: jsonContentHeaders,
94
+ method: "POST",
95
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/sign`
96
+ }, unmarshalSignResponse);
97
+ this.verify = (request) => this.client.fetch({
98
+ body: JSON.stringify(marshalVerifyRequest(request, this.client.settings)),
99
+ headers: jsonContentHeaders,
100
+ method: "POST",
101
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/verify`
102
+ }, unmarshalVerifyResponse);
103
+ this.importKeyMaterial = (request) => this.client.fetch({
104
+ body: JSON.stringify(marshalImportKeyMaterialRequest(request, this.client.settings)),
105
+ headers: jsonContentHeaders,
106
+ method: "POST",
107
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/import-key-material`
108
+ }, unmarshalKey);
109
+ this.deleteKeyMaterial = (request) => this.client.fetch({
110
+ body: "{}",
111
+ headers: jsonContentHeaders,
112
+ method: "POST",
113
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/delete-key-material`
114
+ });
115
+ this.restoreKey = (request) => this.client.fetch({
116
+ body: "{}",
117
+ headers: jsonContentHeaders,
118
+ method: "POST",
119
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam("keyId", request.keyId)}/restore`
120
+ }, unmarshalKey);
121
+ this.listAlgorithms = (request = {}) => this.client.fetch({
122
+ method: "GET",
123
+ path: `/key-manager/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/algorithms`,
124
+ urlParams: urlParams(["usages", request.usages])
125
+ }, unmarshalListAlgorithmsResponse);
126
+ }
127
+ static {
128
+ this.LOCALITY = toApiLocality({ regions: [
129
+ "fr-par",
130
+ "nl-ams",
131
+ "pl-waw"
132
+ ] });
133
+ }
134
+ };
135
+ //#endregion
136
+ export { API };
@@ -0,0 +1,3 @@
1
+ export { API, } from './api.gen.js';
2
+ export * from './marshalling.gen.js';
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';
@@ -0,0 +1,26 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { marshalCreateKeyRequest, marshalDecryptRequest, marshalEncryptRequest, marshalGenerateDataKeyRequest, marshalImportKeyMaterialRequest, marshalSignRequest, marshalUpdateKeyRequest, marshalVerifyRequest, unmarshalDataKey, unmarshalDecryptResponse, unmarshalEncryptResponse, unmarshalKey, unmarshalListAlgorithmsResponse, unmarshalListKeysResponse, unmarshalPublicKey, unmarshalSignResponse, unmarshalVerifyResponse } from "./marshalling.gen.js";
3
+ import { API } from "./api.gen.js";
4
+ //#region src/v1alpha1/index.gen.ts
5
+ var index_gen_exports = /* @__PURE__ */ __exportAll({
6
+ API: () => API,
7
+ marshalCreateKeyRequest: () => marshalCreateKeyRequest,
8
+ marshalDecryptRequest: () => marshalDecryptRequest,
9
+ marshalEncryptRequest: () => marshalEncryptRequest,
10
+ marshalGenerateDataKeyRequest: () => marshalGenerateDataKeyRequest,
11
+ marshalImportKeyMaterialRequest: () => marshalImportKeyMaterialRequest,
12
+ marshalSignRequest: () => marshalSignRequest,
13
+ marshalUpdateKeyRequest: () => marshalUpdateKeyRequest,
14
+ marshalVerifyRequest: () => marshalVerifyRequest,
15
+ unmarshalDataKey: () => unmarshalDataKey,
16
+ unmarshalDecryptResponse: () => unmarshalDecryptResponse,
17
+ unmarshalEncryptResponse: () => unmarshalEncryptResponse,
18
+ unmarshalKey: () => unmarshalKey,
19
+ unmarshalListAlgorithmsResponse: () => unmarshalListAlgorithmsResponse,
20
+ unmarshalListKeysResponse: () => unmarshalListKeysResponse,
21
+ unmarshalPublicKey: () => unmarshalPublicKey,
22
+ unmarshalSignResponse: () => unmarshalSignResponse,
23
+ unmarshalVerifyResponse: () => unmarshalVerifyResponse
24
+ });
25
+ //#endregion
26
+ export { API, index_gen_exports, marshalCreateKeyRequest, marshalDecryptRequest, marshalEncryptRequest, marshalGenerateDataKeyRequest, marshalImportKeyMaterialRequest, marshalSignRequest, marshalUpdateKeyRequest, marshalVerifyRequest, unmarshalDataKey, unmarshalDecryptResponse, unmarshalEncryptResponse, unmarshalKey, unmarshalListAlgorithmsResponse, unmarshalListKeysResponse, unmarshalPublicKey, unmarshalSignResponse, unmarshalVerifyResponse };
@@ -0,0 +1,19 @@
1
+ import type { DefaultValues } from '@scaleway/sdk-client';
2
+ import type { Key, DataKey, DecryptResponse, EncryptResponse, ListAlgorithmsResponse, ListKeysResponse, PublicKey, SignResponse, VerifyResponse, CreateKeyRequest, DecryptRequest, EncryptRequest, GenerateDataKeyRequest, ImportKeyMaterialRequest, SignRequest, UpdateKeyRequest, VerifyRequest } from './types.gen.js';
3
+ export declare const unmarshalKey: (data: unknown) => Key;
4
+ export declare const unmarshalDataKey: (data: unknown) => DataKey;
5
+ export declare const unmarshalDecryptResponse: (data: unknown) => DecryptResponse;
6
+ export declare const unmarshalEncryptResponse: (data: unknown) => EncryptResponse;
7
+ export declare const unmarshalListAlgorithmsResponse: (data: unknown) => ListAlgorithmsResponse;
8
+ export declare const unmarshalListKeysResponse: (data: unknown) => ListKeysResponse;
9
+ export declare const unmarshalPublicKey: (data: unknown) => PublicKey;
10
+ export declare const unmarshalSignResponse: (data: unknown) => SignResponse;
11
+ export declare const unmarshalVerifyResponse: (data: unknown) => VerifyResponse;
12
+ export declare const marshalCreateKeyRequest: (request: CreateKeyRequest, defaults: DefaultValues) => Record<string, unknown>;
13
+ export declare const marshalDecryptRequest: (request: DecryptRequest, defaults: DefaultValues) => Record<string, unknown>;
14
+ export declare const marshalEncryptRequest: (request: EncryptRequest, defaults: DefaultValues) => Record<string, unknown>;
15
+ export declare const marshalGenerateDataKeyRequest: (request: GenerateDataKeyRequest, defaults: DefaultValues) => Record<string, unknown>;
16
+ export declare const marshalImportKeyMaterialRequest: (request: ImportKeyMaterialRequest, defaults: DefaultValues) => Record<string, unknown>;
17
+ export declare const marshalSignRequest: (request: SignRequest, defaults: DefaultValues) => Record<string, unknown>;
18
+ export declare const marshalUpdateKeyRequest: (request: UpdateKeyRequest, defaults: DefaultValues) => Record<string, unknown>;
19
+ export declare const marshalVerifyRequest: (request: VerifyRequest, defaults: DefaultValues) => Record<string, unknown>;
@@ -0,0 +1,158 @@
1
+ import { isJSONObject, resolveOneOf, unmarshalArrayOfObject, unmarshalDate } from "@scaleway/sdk-client";
2
+ //#region src/v1alpha1/marshalling.gen.ts
3
+ const unmarshalKeyRotationPolicy = (data) => {
4
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'KeyRotationPolicy' failed as data isn't a dictionary.`);
5
+ return {
6
+ nextRotationAt: unmarshalDate(data.next_rotation_at),
7
+ rotationPeriod: data.rotation_period
8
+ };
9
+ };
10
+ const unmarshalKeyUsage = (data) => {
11
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'KeyUsage' failed as data isn't a dictionary.`);
12
+ return {
13
+ asymmetricEncryption: data.asymmetric_encryption ? data.asymmetric_encryption : void 0,
14
+ asymmetricSigning: data.asymmetric_signing ? data.asymmetric_signing : void 0,
15
+ symmetricEncryption: data.symmetric_encryption ? data.symmetric_encryption : void 0
16
+ };
17
+ };
18
+ const unmarshalKey = (data) => {
19
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'Key' failed as data isn't a dictionary.`);
20
+ return {
21
+ createdAt: unmarshalDate(data.created_at),
22
+ deletionRequestedAt: unmarshalDate(data.deletion_requested_at),
23
+ description: data.description,
24
+ id: data.id,
25
+ locked: data.locked,
26
+ name: data.name,
27
+ origin: data.origin,
28
+ projectId: data.project_id,
29
+ protected: data.protected,
30
+ region: data.region,
31
+ rotatedAt: unmarshalDate(data.rotated_at),
32
+ rotationCount: data.rotation_count,
33
+ rotationPolicy: data.rotation_policy ? unmarshalKeyRotationPolicy(data.rotation_policy) : void 0,
34
+ state: data.state,
35
+ tags: data.tags,
36
+ updatedAt: unmarshalDate(data.updated_at),
37
+ usage: data.usage ? unmarshalKeyUsage(data.usage) : void 0
38
+ };
39
+ };
40
+ const unmarshalDataKey = (data) => {
41
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'DataKey' failed as data isn't a dictionary.`);
42
+ return {
43
+ algorithm: data.algorithm,
44
+ ciphertext: data.ciphertext,
45
+ createdAt: unmarshalDate(data.created_at),
46
+ keyId: data.key_id,
47
+ plaintext: data.plaintext
48
+ };
49
+ };
50
+ const unmarshalDecryptResponse = (data) => {
51
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'DecryptResponse' failed as data isn't a dictionary.`);
52
+ return {
53
+ ciphertext: data.ciphertext,
54
+ keyId: data.key_id,
55
+ plaintext: data.plaintext
56
+ };
57
+ };
58
+ const unmarshalEncryptResponse = (data) => {
59
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'EncryptResponse' failed as data isn't a dictionary.`);
60
+ return {
61
+ ciphertext: data.ciphertext,
62
+ keyId: data.key_id
63
+ };
64
+ };
65
+ const unmarshalListAlgorithmsResponseAlgorithm = (data) => {
66
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'ListAlgorithmsResponseAlgorithm' failed as data isn't a dictionary.`);
67
+ return {
68
+ name: data.name,
69
+ recommended: data.recommended,
70
+ usage: data.usage
71
+ };
72
+ };
73
+ const unmarshalListAlgorithmsResponse = (data) => {
74
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'ListAlgorithmsResponse' failed as data isn't a dictionary.`);
75
+ return { algorithms: unmarshalArrayOfObject(data.algorithms, unmarshalListAlgorithmsResponseAlgorithm) };
76
+ };
77
+ const unmarshalListKeysResponse = (data) => {
78
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'ListKeysResponse' failed as data isn't a dictionary.`);
79
+ return {
80
+ keys: unmarshalArrayOfObject(data.keys, unmarshalKey),
81
+ totalCount: data.total_count
82
+ };
83
+ };
84
+ const unmarshalPublicKey = (data) => {
85
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'PublicKey' failed as data isn't a dictionary.`);
86
+ return { pem: data.pem };
87
+ };
88
+ const unmarshalSignResponse = (data) => {
89
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'SignResponse' failed as data isn't a dictionary.`);
90
+ return {
91
+ keyId: data.key_id,
92
+ signature: data.signature
93
+ };
94
+ };
95
+ const unmarshalVerifyResponse = (data) => {
96
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'VerifyResponse' failed as data isn't a dictionary.`);
97
+ return {
98
+ keyId: data.key_id,
99
+ valid: data.valid
100
+ };
101
+ };
102
+ const marshalKeyRotationPolicy = (request, defaults) => ({
103
+ next_rotation_at: request.nextRotationAt,
104
+ rotation_period: request.rotationPeriod
105
+ });
106
+ const marshalKeyUsage = (request, defaults) => ({ ...resolveOneOf([
107
+ {
108
+ param: "symmetric_encryption",
109
+ value: request.symmetricEncryption
110
+ },
111
+ {
112
+ param: "asymmetric_encryption",
113
+ value: request.asymmetricEncryption
114
+ },
115
+ {
116
+ param: "asymmetric_signing",
117
+ value: request.asymmetricSigning
118
+ }
119
+ ]) });
120
+ const marshalCreateKeyRequest = (request, defaults) => ({
121
+ description: request.description,
122
+ name: request.name,
123
+ origin: request.origin,
124
+ project_id: request.projectId ?? defaults.defaultProjectId,
125
+ rotation_policy: request.rotationPolicy !== void 0 ? marshalKeyRotationPolicy(request.rotationPolicy, defaults) : void 0,
126
+ tags: request.tags,
127
+ unprotected: request.unprotected,
128
+ usage: request.usage !== void 0 ? marshalKeyUsage(request.usage, defaults) : void 0
129
+ });
130
+ const marshalDecryptRequest = (request, defaults) => ({
131
+ associated_data: request.associatedData,
132
+ ciphertext: request.ciphertext
133
+ });
134
+ const marshalEncryptRequest = (request, defaults) => ({
135
+ associated_data: request.associatedData,
136
+ plaintext: request.plaintext
137
+ });
138
+ const marshalGenerateDataKeyRequest = (request, defaults) => ({
139
+ algorithm: request.algorithm,
140
+ without_plaintext: request.withoutPlaintext
141
+ });
142
+ const marshalImportKeyMaterialRequest = (request, defaults) => ({
143
+ key_material: request.keyMaterial,
144
+ salt: request.salt
145
+ });
146
+ const marshalSignRequest = (request, defaults) => ({ digest: request.digest });
147
+ const marshalUpdateKeyRequest = (request, defaults) => ({
148
+ description: request.description,
149
+ name: request.name,
150
+ rotation_policy: request.rotationPolicy !== void 0 ? marshalKeyRotationPolicy(request.rotationPolicy, defaults) : void 0,
151
+ tags: request.tags
152
+ });
153
+ const marshalVerifyRequest = (request, defaults) => ({
154
+ digest: request.digest,
155
+ signature: request.signature
156
+ });
157
+ //#endregion
158
+ export { marshalCreateKeyRequest, marshalDecryptRequest, marshalEncryptRequest, marshalGenerateDataKeyRequest, marshalImportKeyMaterialRequest, marshalSignRequest, marshalUpdateKeyRequest, marshalVerifyRequest, unmarshalDataKey, unmarshalDecryptResponse, unmarshalEncryptResponse, unmarshalKey, unmarshalListAlgorithmsResponse, unmarshalListKeysResponse, unmarshalPublicKey, unmarshalSignResponse, unmarshalVerifyResponse };
@@ -0,0 +1,48 @@
1
+ export declare const queriesMetadata: {
2
+ readonly namespace: 'key_manager';
3
+ readonly version: 'v1alpha1';
4
+ readonly folderName: 'keyManagerv1alpha1';
5
+ readonly services: readonly [{
6
+ readonly apiClass: 'API';
7
+ readonly methods: readonly [{
8
+ readonly methodName: 'getKey';
9
+ readonly protoName: 'GetKey';
10
+ readonly paramsType: 'GetKeyRequest';
11
+ readonly returnType: 'Key';
12
+ readonly isList: false;
13
+ readonly paginationType: 'none';
14
+ readonly isPrivate: false;
15
+ readonly description: '"';
16
+ }, {
17
+ readonly methodName: 'getPublicKey';
18
+ readonly protoName: 'GetPublicKey';
19
+ readonly paramsType: 'GetPublicKeyRequest';
20
+ readonly returnType: 'PublicKey';
21
+ readonly isList: false;
22
+ readonly paginationType: 'none';
23
+ readonly isPrivate: false;
24
+ readonly description: '"';
25
+ }, {
26
+ readonly methodName: 'listKeys';
27
+ readonly protoName: 'ListKeys';
28
+ readonly paramsType: 'ListKeysRequest';
29
+ readonly returnType: 'ListKeysResponse';
30
+ readonly isList: true;
31
+ readonly paginationType: 'offset';
32
+ readonly pageParamKey: 'page';
33
+ readonly listItemType: 'Key';
34
+ readonly isPrivate: false;
35
+ readonly description: '"';
36
+ }, {
37
+ readonly methodName: 'listAlgorithms';
38
+ readonly protoName: 'ListAlgorithms';
39
+ readonly paramsType: 'ListAlgorithmsRequest';
40
+ readonly returnType: 'ListAlgorithmsResponse';
41
+ readonly isList: false;
42
+ readonly paginationType: 'none';
43
+ readonly isPrivate: false;
44
+ readonly description: '"';
45
+ }];
46
+ }];
47
+ };
48
+ export type QueriesMetadata = typeof queriesMetadata;