Skip to content

feat: add view secret value parameter to get/list secrets #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,22 @@ const allSecrets = await client.secrets().listSecrets({
environment: "dev",
projectId: "<your-project-id>",
expandSecretReferences: true,
viewSecretValue: true,
includeImports: false,
recursive: false,
secretPath: "/foo/bar"
secretPath: "/foo/bar",
});
```

**Parameters:**
- `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 `<hidden-by-infisical>`. 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.
Expand All @@ -136,6 +138,7 @@ const allSecrets = await client.secrets().listSecretsWithImports({
environment: "dev",
projectId: "<your-project-id>",
expandSecretReferences: true,
viewSecretValue: true,
recursive: false,
secretPath: "/foo/bar"
});
Expand All @@ -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 `<hidden-by-infisical>`. 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.
Expand Down Expand Up @@ -236,6 +240,7 @@ const updatedSecret = await client.secrets().updateSecret("SECRET_TO_UPDATE", {
projectId: "<your-project-id>",
secretName: "DATABASE_URL",
expandSecretReferences: true, // Optional
viewSecretValue: true, // Optional
includeImports: true, // Optional
secretPath: "/foo/bar", // Optional
type: "shared", // Optional
Expand All @@ -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 `<hidden-by-infisical>`. 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.
Expand Down
4 changes: 4 additions & 0 deletions src/custom/secrets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type ListSecretsOptions = {
recursive?: boolean;
secretPath?: string;
tagSlugs?: string[];
viewSecretValue?: boolean;
};

type GetSecretOptions = {
Expand All @@ -32,6 +33,7 @@ type GetSecretOptions = {
type?: SecretType;
version?: number;
projectId: string;
viewSecretValue?: boolean;
};

export type UpdateSecretOptions = Omit<DefaultApiApiV3SecretsRawSecretNamePatchRequest["apiV3SecretsRawSecretNamePatchRequest"], "workspaceId"> & {
Expand Down Expand Up @@ -66,6 +68,7 @@ export default class SecretsClient {
try {
const res = await this.#apiInstance.apiV3SecretsRawGet(
{
viewSecretValue: convertBool(options.viewSecretValue ?? true),
environment: options.environment,
workspaceId: options.projectId,
expandSecretReferences: convertBool(options.expandSecretReferences),
Expand Down Expand Up @@ -122,6 +125,7 @@ export default class SecretsClient {
try {
const res = await this.#apiInstance.apiV3SecretsRawSecretNameGet(
{
viewSecretValue: convertBool(options.viewSecretValue ?? true),
environment: options.environment,
secretName: options.secretName,
workspaceId: options.projectId,
Expand Down