From 971fc761579bfdf82397c0f64269507e2d9b6870 Mon Sep 17 00:00:00 2001 From: Daniel Hougaard Date: Thu, 20 Feb 2025 08:26:29 +0400 Subject: [PATCH 1/4] Update secrets.ts --- src/custom/secrets.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/custom/secrets.ts b/src/custom/secrets.ts index d5a6839..2d4085d 100644 --- a/src/custom/secrets.ts +++ b/src/custom/secrets.ts @@ -21,6 +21,7 @@ type ListSecretsOptions = { recursive?: boolean; secretPath?: string; tagSlugs?: string[]; + viewSecretValue?: boolean; }; type GetSecretOptions = { @@ -32,6 +33,7 @@ type GetSecretOptions = { type?: SecretType; version?: number; projectId: string; + viewSecretValue?: boolean; }; export type UpdateSecretOptions = Omit & { @@ -66,6 +68,7 @@ export default class SecretsClient { try { const res = await this.#apiInstance.apiV3SecretsRawGet( { + viewSecretValue: convertBool(options.viewSecretValue), environment: options.environment, workspaceId: options.projectId, expandSecretReferences: convertBool(options.expandSecretReferences), @@ -104,6 +107,7 @@ export default class SecretsClient { if (!secrets.find(s => s.secretKey === importedSecret.secretKey)) { secrets.push({ ...importedSecret, + secretValueHidden: false, secretPath: imp.secretPath, // These fields are not returned by the API updatedAt: new Date().toISOString(), @@ -122,6 +126,7 @@ export default class SecretsClient { try { const res = await this.#apiInstance.apiV3SecretsRawSecretNameGet( { + viewSecretValue: convertBool(options.viewSecretValue), environment: options.environment, secretName: options.secretName, workspaceId: options.projectId, From 7fcf6b4a922466221c16d1cca734381ab5e6690f Mon Sep 17 00:00:00 2001 From: Daniel Hougaard Date: Thu, 20 Feb 2025 08:45:27 +0400 Subject: [PATCH 2/4] docs: viewSecretValue parameter --- README.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0fa96d6..d219032 100644 --- a/README.md +++ b/README.md @@ -109,9 +109,10 @@ const allSecrets = await client.secrets().listSecrets({ environment: "dev", projectId: "", expandSecretReferences: true, + viewSecretValue: true, includeImports: false, recursive: false, - secretPath: "/foo/bar" + secretPath: "/foo/bar", }); ``` @@ -119,10 +120,11 @@ const allSecrets = await client.secrets().listSecrets({ - `projectId` (string): The ID of your project. - `environment` (string): The environment in which to list secrets (e.g., "dev"). - `secretPath` (str): The path to the secrets. -- `expandSecretReferences` (bool): Whether to expand secret references. -- `recursive` (bool): Whether to list secrets recursively. -- `includeImports` (bool): Whether to include imported secrets. -- `tagFilters` (string[]): Tags to filter secrets. +- `expandSecretReferences` (bool, optional): Whether to expand secret references. +- `viewSecretValue` (bool, optional): Whether or not to reveal the secret value of the secrets. If set to `false`, the `secretValue` is masked with ``. Defaults to `true. +- `recursive` (bool, optional): Whether to list secrets recursively. +- `includeImports` (bool, optional): Whether to include imported secrets. +- `tagFilters` (string[], optional): Tags to filter secrets. **Returns:** - `ApiV3SecretsRawGet200Response`: The response containing the list of secrets. @@ -136,6 +138,7 @@ const allSecrets = await client.secrets().listSecretsWithImports({ environment: "dev", projectId: "", expandSecretReferences: true, + viewSecretValue: true, recursive: false, secretPath: "/foo/bar" }); @@ -145,9 +148,10 @@ const allSecrets = await client.secrets().listSecretsWithImports({ - `projectId` (string): The ID of your project. - `environment` (string): The environment in which to list secrets (e.g., "dev"). - `secretPath` (str): The path to the secrets. -- `expandSecretReferences` (bool): Whether to expand secret references. -- `recursive` (bool): Whether to list secrets recursively. -- `tagFilters` (string[]): Tags to filter secrets. +- `expandSecretReferences` (bool, optional): Whether to expand secret references. +- `viewSecretValue` (bool, optional): Whether or not to reveal the secret value of the secrets. If set to `false`, the `secretValue` is masked with ``. Defaults to `true. +- `recursive` (bool, optional): Whether to list secrets recursively. +- `tagFilters` (string[], optional): Tags to filter secrets. **Returns:** - `ApiV1DashboardSecretsOverviewGet200ResponseSecretsInner`: The response containing the list of secrets, with imports. @@ -236,6 +240,7 @@ const updatedSecret = await client.secrets().updateSecret("SECRET_TO_UPDATE", { projectId: "", secretName: "DATABASE_URL", expandSecretReferences: true, // Optional + viewSecretValue: true, // Optional includeImports: true, // Optional secretPath: "/foo/bar", // Optional type: "shared", // Optional @@ -249,6 +254,7 @@ const updatedSecret = await client.secrets().updateSecret("SECRET_TO_UPDATE", { - `secretName` (str): The name of the secret. - `secretPath` (str, optional): The path to the secret. - `expandSecretReferences` (bool, optional): Whether to expand secret references. +- `viewSecretValue` (bool, optional): Whether or not to reveal the secret value of the secret. If set to `false`, the `secretValue` is masked with ``. Defaults to `true. - `includeImports` (bool): Whether to include imported secrets. - `version` (str, optional): The version of the secret to retrieve. Fetches the latest by default. - `type` (personal | shared, optional): The type of secret to fetch. From 52b959a010ff8e0f672ded2d7a591f63a6f712fe Mon Sep 17 00:00:00 2001 From: Daniel Hougaard Date: Fri, 14 Mar 2025 04:30:38 +0400 Subject: [PATCH 3/4] requested changes --- README.md | 6 +++--- src/custom/secrets.ts | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d219032..c9dbeb8 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ const allSecrets = await client.secrets().listSecrets({ - `environment` (string): The environment in which to list secrets (e.g., "dev"). - `secretPath` (str): The path to the secrets. - `expandSecretReferences` (bool, optional): Whether to expand secret references. -- `viewSecretValue` (bool, optional): Whether or not to reveal the secret value of the secrets. If set to `false`, the `secretValue` is masked with ``. Defaults to `true. +- `viewSecretValue` (bool, optional): Whether or not to reveal the secret value of the secrets. If set to `false`, the `secretValue` is masked with ``. Defaults to `true`. - `recursive` (bool, optional): Whether to list secrets recursively. - `includeImports` (bool, optional): Whether to include imported secrets. - `tagFilters` (string[], optional): Tags to filter secrets. @@ -149,7 +149,7 @@ const allSecrets = await client.secrets().listSecretsWithImports({ - `environment` (string): The environment in which to list secrets (e.g., "dev"). - `secretPath` (str): The path to the secrets. - `expandSecretReferences` (bool, optional): Whether to expand secret references. -- `viewSecretValue` (bool, optional): Whether or not to reveal the secret value of the secrets. If set to `false`, the `secretValue` is masked with ``. Defaults to `true. +- `viewSecretValue` (bool, optional): Whether or not to reveal the secret value of the secrets. If set to `false`, the `secretValue` is masked with ``. Defaults to `true`. - `recursive` (bool, optional): Whether to list secrets recursively. - `tagFilters` (string[], optional): Tags to filter secrets. @@ -254,7 +254,7 @@ const updatedSecret = await client.secrets().updateSecret("SECRET_TO_UPDATE", { - `secretName` (str): The name of the secret. - `secretPath` (str, optional): The path to the secret. - `expandSecretReferences` (bool, optional): Whether to expand secret references. -- `viewSecretValue` (bool, optional): Whether or not to reveal the secret value of the secret. If set to `false`, the `secretValue` is masked with ``. Defaults to `true. +- `viewSecretValue` (bool, optional): Whether or not to reveal the secret value of the secret. If set to `false`, the `secretValue` is masked with ``. Defaults to `true`. - `includeImports` (bool): Whether to include imported secrets. - `version` (str, optional): The version of the secret to retrieve. Fetches the latest by default. - `type` (personal | shared, optional): The type of secret to fetch. diff --git a/src/custom/secrets.ts b/src/custom/secrets.ts index 2d4085d..29e0e3a 100644 --- a/src/custom/secrets.ts +++ b/src/custom/secrets.ts @@ -68,7 +68,7 @@ export default class SecretsClient { try { const res = await this.#apiInstance.apiV3SecretsRawGet( { - viewSecretValue: convertBool(options.viewSecretValue), + viewSecretValue: options.viewSecretValue ? convertBool(options.viewSecretValue) : undefined, environment: options.environment, workspaceId: options.projectId, expandSecretReferences: convertBool(options.expandSecretReferences), @@ -107,7 +107,6 @@ export default class SecretsClient { if (!secrets.find(s => s.secretKey === importedSecret.secretKey)) { secrets.push({ ...importedSecret, - secretValueHidden: false, secretPath: imp.secretPath, // These fields are not returned by the API updatedAt: new Date().toISOString(), @@ -126,7 +125,7 @@ export default class SecretsClient { try { const res = await this.#apiInstance.apiV3SecretsRawSecretNameGet( { - viewSecretValue: convertBool(options.viewSecretValue), + viewSecretValue: options.viewSecretValue ? convertBool(options.viewSecretValue) : undefined, environment: options.environment, secretName: options.secretName, workspaceId: options.projectId, From ffbd0479fa344fa1a2cee9532aba1a7055e10a00 Mon Sep 17 00:00:00 2001 From: Daniel Hougaard Date: Fri, 14 Mar 2025 05:35:54 +0400 Subject: [PATCH 4/4] Update secrets.ts --- src/custom/secrets.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/custom/secrets.ts b/src/custom/secrets.ts index 29e0e3a..4ae23da 100644 --- a/src/custom/secrets.ts +++ b/src/custom/secrets.ts @@ -68,7 +68,7 @@ export default class SecretsClient { try { const res = await this.#apiInstance.apiV3SecretsRawGet( { - viewSecretValue: options.viewSecretValue ? convertBool(options.viewSecretValue) : undefined, + viewSecretValue: convertBool(options.viewSecretValue ?? true), environment: options.environment, workspaceId: options.projectId, expandSecretReferences: convertBool(options.expandSecretReferences), @@ -125,7 +125,7 @@ export default class SecretsClient { try { const res = await this.#apiInstance.apiV3SecretsRawSecretNameGet( { - viewSecretValue: options.viewSecretValue ? convertBool(options.viewSecretValue) : undefined, + viewSecretValue: convertBool(options.viewSecretValue ?? true), environment: options.environment, secretName: options.secretName, workspaceId: options.projectId,