cloudflare
Version:
The official TypeScript library for the Cloudflare API
440 lines • 15.8 kB
text/typescript
import { APIResource } from "../../../core/resource.mjs";
import { APIPromise } from "../../../core/api-promise.mjs";
import { PagePromise, SinglePage } from "../../../core/pagination.mjs";
import { RequestOptions } from "../../../internal/request-options.mjs";
export declare class BaseSecrets extends APIResource {
static readonly _key: readonly ['workers', 'scripts', 'secrets'];
/**
* Add a secret to a Worker script by creating a new version with that secret.
*
* When changing more than one secret at a time, prefer the "Patch multiple script
* secrets" API instead of changing many secrets individually.
*
* @example
* ```ts
* const secret = await client.workers.scripts.secrets.update(
* 'this-is_my_script-01',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* name: 'myBinding',
* text: 'My secret.',
* type: 'secret_text',
* },
* );
* ```
*/
update(scriptName: string, params: SecretUpdateParams, options?: RequestOptions): APIPromise<SecretUpdateResponse>;
/**
* List the names of secrets bound to a Worker script.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const secretListResponse of client.workers.scripts.secrets.list(
* 'this-is_my_script-01',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(scriptName: string, params: SecretListParams, options?: RequestOptions): PagePromise<SecretListResponsesSinglePage, SecretListResponse>;
/**
* Remove a secret from a Worker script by creating a new version without that
* secret.
*
* When changing more than one secret at a time, prefer the "Patch multiple script
* secrets" API instead of changing many secrets individually.
*
* @example
* ```ts
* const secret = await client.workers.scripts.secrets.delete(
* 'mySecret',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* script_name: 'this-is_my_script-01',
* },
* );
* ```
*/
delete(secretName: string, params: SecretDeleteParams, options?: RequestOptions): APIPromise<SecretDeleteResponse | null>;
/**
* Create, update, or delete multiple secrets on a Worker script in a single
* operation using JSON Merge Patch (RFC 7396). This operation creates a single
* version with all changes included. Prefer this API instead of changing many
* secrets individually.
*
* Usage:
*
* - To create or update a secret, set its value to a secret object.
* - To delete a secret, set its value to `null`.
* - Secrets not included in the request are left unchanged.
*
* @example
* ```ts
* const response =
* await client.workers.scripts.secrets.bulkUpdate(
* 'this-is_my_script-01',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
bulkUpdate(scriptName: string, params: SecretBulkUpdateParams, options?: RequestOptions): APIPromise<SecretBulkUpdateResponse>;
/**
* Get a given secret binding (value omitted) on a Worker script.
*
* @example
* ```ts
* const secret = await client.workers.scripts.secrets.get(
* 'mySecret',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* script_name: 'this-is_my_script-01',
* },
* );
* ```
*/
get(secretName: string, params: SecretGetParams, options?: RequestOptions): APIPromise<SecretGetResponse>;
}
export declare class Secrets extends BaseSecrets {
}
export type SecretListResponsesSinglePage = SinglePage<SecretListResponse>;
/**
* A secret value accessible through a binding.
*/
export type SecretUpdateResponse = SecretUpdateResponse.WorkersBindingKindSecretText | SecretUpdateResponse.WorkersBindingKindSecretKey;
export declare namespace SecretUpdateResponse {
interface WorkersBindingKindSecretText {
/**
* A JavaScript variable name for the binding.
*/
name: string;
/**
* The kind of resource that the binding provides.
*/
type: 'secret_text';
}
interface WorkersBindingKindSecretKey {
/**
* Algorithm-specific key parameters.
* [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
*/
algorithm: unknown;
/**
* Data format of the key.
* [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
*/
format: 'raw' | 'pkcs8' | 'spki' | 'jwk';
/**
* A JavaScript variable name for the binding.
*/
name: string;
/**
* The kind of resource that the binding provides.
*/
type: 'secret_key';
/**
* Allowed operations with the key.
* [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
*/
usages: Array<'encrypt' | 'decrypt' | 'sign' | 'verify' | 'deriveKey' | 'deriveBits' | 'wrapKey' | 'unwrapKey'>;
}
}
/**
* A secret value accessible through a binding.
*/
export type SecretListResponse = SecretListResponse.WorkersBindingKindSecretText | SecretListResponse.WorkersBindingKindSecretKey;
export declare namespace SecretListResponse {
interface WorkersBindingKindSecretText {
/**
* A JavaScript variable name for the binding.
*/
name: string;
/**
* The kind of resource that the binding provides.
*/
type: 'secret_text';
}
interface WorkersBindingKindSecretKey {
/**
* Algorithm-specific key parameters.
* [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
*/
algorithm: unknown;
/**
* Data format of the key.
* [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
*/
format: 'raw' | 'pkcs8' | 'spki' | 'jwk';
/**
* A JavaScript variable name for the binding.
*/
name: string;
/**
* The kind of resource that the binding provides.
*/
type: 'secret_key';
/**
* Allowed operations with the key.
* [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
*/
usages: Array<'encrypt' | 'decrypt' | 'sign' | 'verify' | 'deriveKey' | 'deriveBits' | 'wrapKey' | 'unwrapKey'>;
}
}
export type SecretDeleteResponse = unknown;
/**
* Map of secret names to secret metadata for resulting secrets.
*/
export type SecretBulkUpdateResponse = {
[]: SecretBulkUpdateResponse.WorkersBindingKindSecretText | SecretBulkUpdateResponse.WorkersBindingKindSecretKey;
};
export declare namespace SecretBulkUpdateResponse {
interface WorkersBindingKindSecretText {
/**
* A JavaScript variable name for the binding.
*/
name: string;
/**
* The kind of resource that the binding provides.
*/
type: 'secret_text';
}
interface WorkersBindingKindSecretKey {
/**
* Algorithm-specific key parameters.
* [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
*/
algorithm: unknown;
/**
* Data format of the key.
* [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
*/
format: 'raw' | 'pkcs8' | 'spki' | 'jwk';
/**
* A JavaScript variable name for the binding.
*/
name: string;
/**
* The kind of resource that the binding provides.
*/
type: 'secret_key';
/**
* Allowed operations with the key.
* [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
*/
usages: Array<'encrypt' | 'decrypt' | 'sign' | 'verify' | 'deriveKey' | 'deriveBits' | 'wrapKey' | 'unwrapKey'>;
}
}
/**
* A secret value accessible through a binding.
*/
export type SecretGetResponse = SecretGetResponse.WorkersBindingKindSecretText | SecretGetResponse.WorkersBindingKindSecretKey;
export declare namespace SecretGetResponse {
interface WorkersBindingKindSecretText {
/**
* A JavaScript variable name for the binding.
*/
name: string;
/**
* The kind of resource that the binding provides.
*/
type: 'secret_text';
}
interface WorkersBindingKindSecretKey {
/**
* Algorithm-specific key parameters.
* [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
*/
algorithm: unknown;
/**
* Data format of the key.
* [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
*/
format: 'raw' | 'pkcs8' | 'spki' | 'jwk';
/**
* A JavaScript variable name for the binding.
*/
name: string;
/**
* The kind of resource that the binding provides.
*/
type: 'secret_key';
/**
* Allowed operations with the key.
* [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
*/
usages: Array<'encrypt' | 'decrypt' | 'sign' | 'verify' | 'deriveKey' | 'deriveBits' | 'wrapKey' | 'unwrapKey'>;
}
}
export type SecretUpdateParams = SecretUpdateParams.WorkersBindingKindSecretText | SecretUpdateParams.WorkersBindingKindSecretKey;
export declare namespace SecretUpdateParams {
interface WorkersBindingKindSecretText {
/**
* Path param: Identifier.
*/
account_id: string;
/**
* Body param: A JavaScript variable name for the binding.
*/
name: string;
/**
* Body param: The secret value to use.
*/
text: string;
/**
* Body param: The kind of resource that the binding provides.
*/
type: 'secret_text';
}
interface WorkersBindingKindSecretKey {
/**
* Path param: Identifier.
*/
account_id: string;
/**
* Body param: Algorithm-specific key parameters.
* [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
*/
algorithm: unknown;
/**
* Body param: Data format of the key.
* [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
*/
format: 'raw' | 'pkcs8' | 'spki' | 'jwk';
/**
* Body param: A JavaScript variable name for the binding.
*/
name: string;
/**
* Body param: The kind of resource that the binding provides.
*/
type: 'secret_key';
/**
* Body param: Allowed operations with the key.
* [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
*/
usages: Array<'encrypt' | 'decrypt' | 'sign' | 'verify' | 'deriveKey' | 'deriveBits' | 'wrapKey' | 'unwrapKey'>;
/**
* Body param: Base64-encoded key data. Required if `format` is "raw", "pkcs8", or
* "spki".
*/
key_base64?: string;
/**
* Body param: Key data in
* [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key)
* format. Required if `format` is "jwk".
*/
key_jwk?: unknown;
}
}
export interface SecretListParams {
/**
* Identifier.
*/
account_id: string;
}
export interface SecretDeleteParams {
/**
* Path param: Identifier.
*/
account_id: string;
/**
* Path param: Name of the script.
*/
script_name: string;
/**
* Query param: Flag that indicates whether the secret name is URL encoded.
*/
url_encoded?: boolean;
}
export interface SecretBulkUpdateParams {
/**
* Path param: Identifier.
*/
account_id: string;
/**
* Body param: Map of secret names to secret values:
*
* - Set to a secret object to create or update.
* - Set to `null` to delete.
* - Omit to leave unchanged.
*/
secrets?: {
[]: SecretBulkUpdateParams.WorkersBindingKindSecretText | SecretBulkUpdateParams.WorkersBindingKindSecretKey | null;
};
/**
* Body param: Optional version tags to apply to the new script version.
*/
version_tags?: {
[]: unknown;
};
}
export declare namespace SecretBulkUpdateParams {
interface WorkersBindingKindSecretText {
/**
* A JavaScript variable name for the binding.
*/
name: string;
/**
* The secret value to use.
*/
text: string;
/**
* The kind of resource that the binding provides.
*/
type: 'secret_text';
}
interface WorkersBindingKindSecretKey {
/**
* Algorithm-specific key parameters.
* [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
*/
algorithm: unknown;
/**
* Data format of the key.
* [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
*/
format: 'raw' | 'pkcs8' | 'spki' | 'jwk';
/**
* A JavaScript variable name for the binding.
*/
name: string;
/**
* The kind of resource that the binding provides.
*/
type: 'secret_key';
/**
* Allowed operations with the key.
* [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
*/
usages: Array<'encrypt' | 'decrypt' | 'sign' | 'verify' | 'deriveKey' | 'deriveBits' | 'wrapKey' | 'unwrapKey'>;
/**
* Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
*/
key_base64?: string;
/**
* Key data in
* [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key)
* format. Required if `format` is "jwk".
*/
key_jwk?: unknown;
}
}
export interface SecretGetParams {
/**
* Path param: Identifier.
*/
account_id: string;
/**
* Path param: Name of the script.
*/
script_name: string;
/**
* Query param: Flag that indicates whether the secret name is URL encoded.
*/
url_encoded?: boolean;
}
export declare namespace Secrets {
export { type SecretUpdateResponse as SecretUpdateResponse, type SecretListResponse as SecretListResponse, type SecretDeleteResponse as SecretDeleteResponse, type SecretBulkUpdateResponse as SecretBulkUpdateResponse, type SecretGetResponse as SecretGetResponse, type SecretListResponsesSinglePage as SecretListResponsesSinglePage, type SecretUpdateParams as SecretUpdateParams, type SecretListParams as SecretListParams, type SecretDeleteParams as SecretDeleteParams, type SecretBulkUpdateParams as SecretBulkUpdateParams, type SecretGetParams as SecretGetParams, };
}
//# sourceMappingURL=secrets.d.mts.map