Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Revert "refactor(secret-sync): remove cloudflare workers plaintext and json toggle"

DimitrisStaratzisc83e7ebe4c84
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 22cab7efb3..b7371d31a6 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -3316,6 +3316,10 @@ export const SecretSyncs = {
disableCertificateImport:
"Whether Infisical should skip importing certificate objects from Azure Key Vault when syncing secrets."
},
+ CLOUDFLARE_WORKERS: {
+ syncNonSecretBindings:
+ "Whether Infisical should also sync plaintext and JSON variable bindings in addition to secret bindings. Only applies when variableType is secret_text or omitted."
+ },
SPACELIFT: {
writeOnly:
"Whether secrets should be marked as secret in Spacelift. Secret values are only available to Runs and Tasks and are not accessible in the web GUI or through the API."
@@ -3505,7 +3509,7 @@ export const SecretSyncs = {
CLOUDFLARE_WORKERS: {
scriptId: "The ID of the Cloudflare Workers script to sync secrets to.",
variableType:
- "The type of variable to sync secrets as: secret_text (default), plain_text or json. Infisical converts a secret or variable of the same name to this type and only deletes variables of this type."
+ "The type of variable to sync secrets as: secret_text (the default for new syncs), plain_text or json. Infisical converts a secret or variable of the same name to this type, except that with syncNonSecretBindings on, existing plaintext and JSON variables keep their type. Infisical only deletes variables of this type. Syncs created before this option existed have no type and skip keys that already exist as plaintext or JSON variables."
},
CLOUDFLARE_SECRETS_STORE: {
storeId: "The ID of the Cloudflare Secrets Store to sync secrets to.",
diff --git a/backend/src/services/secret-sync/cloudflare-workers/cloudflare-workers-fns.test.ts b/backend/src/services/secret-sync/cloudflare-workers/cloudflare-workers-fns.test.ts
index c19b219be2..e0f6ff4782 100644
--- a/backend/src/services/secret-sync/cloudflare-workers/cloudflare-workers-fns.test.ts
+++ b/backend/src/services/secret-sync/cloudflare-workers/cloudflare-workers-fns.test.ts
@@ -95,29 +95,31 @@ describe("CloudflareWorkersSyncFns", () => {
expect(patch).not.toHaveBeenCalled();
});
- it.each([CloudflareWorkersVariableType.Secret, undefined])(
- "with type %s, converts a same-name text variable into a secret and leaves other text variables alone",
- async (variableType) => {
- stubWorker([
- { type: "plain_text", name: "API_URL", text: "old" },
- { type: "plain_text", name: "OTHER", text: "keep" },
- { type: "kv_namespace", name: "CACHE" }
- ]);
-
- await CloudflareWorkersSyncFns.syncSecrets(syncWith(variableType), payloadOf({ API_URL: "new", NEW_KEY: "v" }));
-
- expect(patch).toHaveBeenCalledTimes(2);
- expect(await patchedBindings()).toEqual([
- { type: "secret_text", name: "API_URL", text: "new" },
- { type: "plain_text", name: "OTHER", text: "keep" },
- { type: "kv_namespace", name: "CACHE" }
- ]);
- expect(patch.mock.calls[1][0]).toMatch(/\/secrets-bulk$/);
- expect(patch.mock.calls[1][1]).toEqual({
- secrets: { NEW_KEY: { name: "NEW_KEY", text: "v", type: "secret_text" } }
- });
- }
- );
+ it("converts a same-name text variable into a secret when Secret is chosen", async () => {
+ stubWorker([
+ { type: "plain_text", name: "API_URL", text: "old" },
+ { type: "kv_namespace", name: "CACHE" }
+ ]);
+
+ await CloudflareWorkersSyncFns.syncSecrets(
+ syncWith(CloudflareWorkersVariableType.Secret),
+ payloadOf({ API_URL: "new" })
+ );
+
+ expect(patch).toHaveBeenCalledTimes(1);
+ expect(await patchedBindings()).toEqual([
+ { type: "secret_text", name: "API_URL", text: "new" },
+ { type: "kv_namespace", name: "CACHE" }
+ ]);
+ });
+
+ it("keeps skipping same-name text variables for syncs saved without a type", async () => {
+ stubWorker([{ type: "plain_text", name: "API_URL", text: "old" }]);
+
+ await CloudflareWorkersSyncFns.syncSecrets(syncWith(), payloadOf({ API_URL: "new" }));
+
+ expect(patch).not.toHaveBeenCalled();
+ });
it("removes only variables of the sync's type", async () => {
stubWorker([
diff --git a/backend/src/services/secret-sync/cloudflare-workers/cloudflare-workers-fns.ts b/backend/src/services/secret-sync/cloudflare-workers/cloudflare-workers-fns.ts
index 14b2d86b64..7d71bd6d5e 100644
--- a/backend/src/services/secret-sync/cloudflare-workers/cloudflare-workers-fns.ts
+++ b/backend/src/services/secret-sync/cloudflare-workers/cloudflare-workers-fns.ts
@@ -1,6 +1,7 @@
import { AxiosError } from "axios";
import { request } from "@app/lib/config/request";
+import { BadRequestError } from "@app/lib/errors";
import { chunkArray } from "@app/lib/fn";
import { IntegrationUrls } from "@app/services/integration-auth/integration-list";
import { SecretSyncError } from "@app/services/secret-sync/secret-sync-errors";
@@ -30,6 +31,27 @@ type TCloudflareSecretMetadata = {
type: string;
};
+const $validateJsonBindings = (
+ bindings: Array<{ type: string; name: string }>,
+ updatedBindingMap: Record<string, { value: string }>
+) => {
+ const invalidJsonBindings: string[] = [];
+ for (const binding of bindings) {
+ if (binding.type === "json" && updatedBindingMap[binding.name] !== undefined) {
+ try {
+ JSON.parse(updatedBindingMap[binding.name].value);
+ } catch {
+ invalidJsonBindings.push(binding.name);
+ }
+ }
+ }
+ if (invalidJsonBindings.length > 0) {
+ throw new BadRequestError({
+ message: `The following bindings already exist in Cloudflare as JSON variables but the values provided are not valid JSON: ${invalidJsonBindings.join(", ")}`
+ });
+ }
+};
+
const $getCloudflareErrors = (data: unknown): Array<{ code: number; message: string }> => {
if (typeof data !== "object" || data === null) return [];
const { errors } = data as TCloudflareApiResponse;
@@ -128,16 +150,18 @@ const getCloudflareBindings = async (
return { secrets, nonSecretBindings };
};
-// A sync only owns variables of its type, so syncs of different types can share a Worker.
+// A text or JSON sync only owns variables of its type, so syncs of different types can share a Worker.
const $getManagedBindings = (
secretSync: TCloudflareWorkersSyncWithCredentials,
{ secrets, nonSecretBindings }: TCloudflareBindings
) => {
const { variableType = CloudflareWorkersVariableType.Secret } = secretSync.destinationConfig;
- return variableType === CloudflareWorkersVariableType.Secret
- ? secrets
- : nonSecretBindings.filter((binding) => binding.type === variableType);
+ if (variableType !== CloudflareWorkersVariableType.Secret) {
+ return nonSecretBindings.filter((binding) => binding.type === variableType);
+ }
+
+ return secretSync.syncOptions.syncNonSecretBindings ? [...secrets, ...nonSecretBindings] : secrets;
};
// Text and JSON variables are bindings in the Worker's settings, which take the full binding list. One
@@ -243,19 +267,43 @@ export const CloudflareWorkersSyncFns = {
return;
}
+ const shouldSyncNonSecretBindings = Boolean(secretSync.syncOptions.syncNonSecretBindings);
const cloudflareBindings = await getCloudflareBindings(secretSync);
+
const existingSecrets = $getManagedBindings(secretSync, cloudflareBindings);
+
+ const nonSecretBindingKeys = new Set(cloudflareBindings.nonSecretBindings.map((b) => b.key));
+ const existingSecretsMap = Object.fromEntries(existingSecrets.map(({ key, type }) => [key, type]));
const secretMapKeys = new Set(Object.keys(secretMap));
// Cloudflare rejects a secret with the same name as a plaintext or JSON variable, so those keys can't go
- // through secrets-bulk. They are turned into secrets in a settings update instead, in one step so a
- // failure can't leave them missing.
+ // through secrets-bulk. A sync with Secret chosen explicitly turns them into secrets in the settings
+ // update below, in one step so a failure can't leave them missing. Syncs saved before the type could be
+ // chosen skip them, unless shouldSyncNonSecretBindings updates them in place.
const bindingKeysToConvert = new Set(
- cloudflareBindings.nonSecretBindings.map((binding) => binding.key).filter((key) => secretMapKeys.has(key))
+ variableType === CloudflareWorkersVariableType.Secret && !shouldSyncNonSecretBindings
+ ? Object.keys(secretMap).filter((key) => nonSecretBindingKeys.has(key))
+ : []
);
+ const syncableEntries = Object.entries(secretMap).filter(
+ ([key]) => shouldSyncNonSecretBindings || !nonSecretBindingKeys.has(key)
+ );
+
+ const bindingEntries: Array<[string, { value: string }]> = [];
+ const secretEntries: Array<[string, { value: string }]> = [];
+
+ for (const [key, val] of syncableEntries) {
+ const existingType = existingSecretsMap[key];
+ if (existingType && existingType !== CLOUDFLARE_SECRET_TYPE) {
+ bindingEntries.push([key, val]);
+ } else {
+ secretEntries.push([key, val]);
+ }
+ }
+
try {
- if (bindingKeysToConvert.size > 0) {
+ if (bindingEntries.length > 0 || bindingKeysToConvert.size > 0) {
const { data: settingsData } = await request.get<{
result: { bindings: Array<{ type: string; name: string; text?: string; json?: string }> };
}>(
@@ -268,11 +316,24 @@ export const CloudflareWorkersSyncFns = {
}
);
- const updatedBindings = (settingsData.result.bindings ?? []).map((binding) =>
- bindingKeysToConvert.has(binding.name)
- ? { type: CLOUDFLARE_SECRET_TYPE, name: binding.name, text: secretMap[binding.name].value }
- : binding
- );
+ const updatedBindingMap = Object.fromEntries(bindingEntries);
+
+ $validateJsonBindings(settingsData.result.bindings, updatedBindingMap);
+
+ const updatedBindings = settingsData.result.bindings.map((binding) => {
+ if (bindingKeysToConvert.has(binding.name)) {
+ return { type: CLOUDFLARE_SECRET_TYPE, name: binding.name, text: secretMap[binding.name].value };
+ }
+ if (binding.type !== CLOUDFLARE_SECRET_TYPE && updatedBindingMap[binding.name] !== undefined) {
+ const newValue = updatedBindingMap[binding.name].value;
+ if (binding.type === "json") {
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
+ return { ...binding, json: JSON.parse(newValue) };
+ }
+ return { ...binding, text: newValue };
+ }
+ return binding;
+ });
const formData = new FormData();
formData.append(
@@ -301,14 +362,13 @@ export const CloudflareWorkersSyncFns = {
null
) as Record<string, { name: string; text: string; type: string } | null>;
- for (const [key, val] of Object.entries(secretMap)) {
- if (!bindingKeysToConvert.has(key)) {
- bulkSecrets[key] = { name: key, text: val.value, type: CLOUDFLARE_SECRET_TYPE };
- }
+ for (const [key, val] of secretEntries) {
+ bulkSecrets[key] = { name: key, text: val.value, type: CLOUDFLARE_SECRET_TYPE };
}
if (!secretSync.syncOptions.disableSecretDeletion) {
const secretTypeToDelete = existingSecrets.filter((existingSecret) => {
+ if (existingSecret.type !== CLOUDFLARE_SECRET_TYPE) return false;
const isManagedBySchema = matchesSchema(
existingSecret.key,
secretSync.environment?.slug || "",
@@ -348,6 +408,58 @@ export const CloudflareWorkersSyncFns = {
} catch (err) {
throwOnCloudflareRequestError(err);
}
+
+ if (!secretSync.syncOptions.disableSecretDeletion) {
+ const bindingTypeToDelete = existingSecrets.filter((existingSecret) => {
+ if (existingSecret.type === CLOUDFLARE_SECRET_TYPE) return false;
+ const isManagedBySchema = matchesSchema(
+ existingSecret.key,
+ secretSync.environment?.slug || "",
+ secretSync.syncOptions.keySchema
+ );
+ return !secretMapKeys.has(existingSecret.key) && isManagedBySchema;
+ });
+
+ if (bindingTypeToDelete.length > 0) {
+ try {
+ const bindingKeysToDelete = new Set(bindingTypeToDelete.map((b) => b.key));
+
+ const { data: settingsData } = await request.get<{
+ result: { bindings: Array<{ type: string; name: string; text?: string; json?: string }> };
+ }>(
+ `${IntegrationUrls.CLOUDFLARE_WORKERS_API_URL}/client/v4/accounts/${accountId}/workers/scripts/${scriptId}/settings`,
+ {
+ headers: {
+ Authorization: `Bearer ${apiToken}`,
+ Accept: "application/json"
+ }
+ }
+ );
+
+ const filteredBindings = settingsData.result.bindings.filter(
+ (binding) => !bindingKeysToDelete.has(binding.name)
+ );
+
+ const formData = new FormData();
+ formData.append(
+ "settings",
+ new Blob([JSON.stringify({ bindings: filteredBindings })], { type: "application/json" })
+ );
+
+ await request.patch(
+ `${IntegrationUrls.CLOUDFLARE_WORKERS_API_URL}/client/v4/accounts/${accountId}/workers/scripts/${scriptId}/settings`,
+ formData,
+ {
+ headers: {
+ Authorization: `Bearer ${apiToken}`
+ }
+ }
+ );
+ } catch (err) {
+ throwOnCloudflareRequestError(err);
+ }
+ }
+ }
},
getSecrets: async (secretSync: TCloudflareWorkersSyncWithCredentials): Promise<TSecretMap> => {
diff --git a/backend/src/services/secret-sync/cloudflare-workers/cloudflare-workers-schemas.ts b/backend/src/services/secret-sync/cloudflare-workers/cloudflare-workers-schemas.ts
index a20c3d153c..f962f462b7 100644
--- a/backend/src/services/secret-sync/cloudflare-workers/cloudflare-workers-schemas.ts
+++ b/backend/src/services/secret-sync/cloudflare-workers/cloudflare-workers-schemas.ts
@@ -30,11 +30,19 @@ const CloudflareWorkersSyncDestinationConfigSchema = z.object({
.describe(SecretSyncs.DESTINATION_CONFIG.CLOUDFLARE_WORKERS.variableType)
});
+const CloudflareWorkersSyncAdditionalOptionsSchema = z.object({
+ syncNonSecretBindings: z
+ .boolean()
+ .optional()
+ .describe(SecretSyncs.ADDITIONAL_SYNC_OPTIONS.CLOUDFLARE_WORKERS.syncNonSecretBindings)
+});
+
const CloudflareWorkersSyncOptionsConfig: TSyncOptionsConfig = { canImportSecrets: false };
export const CloudflareWorkersSyncSchema = BaseSecretSyncSchema(
SecretSync.CloudflareWorkers,
- CloudflareWorkersSyncOptionsConfig
+ CloudflareWorkersSyncOptionsConfig,
+ CloudflareWorkersSyncAdditionalOptionsSchema
)
.extend({
destination: z.literal(SecretSync.CloudflareWorkers),
@@ -44,9 +52,11 @@ export const CloudflareWorkersSyncSchema = BaseSecretSyncSchema(
export const CreateCloudflareWorkersSyncSchema = GenericCreateSecretSyncFieldsSchema(
SecretSync.CloudflareWorkers,
- CloudflareWorkersSyncOptionsConfig
+ CloudflareWorkersSyncOptionsConfig,
+ CloudflareWorkersSyncAdditionalOptionsSchema
).extend({
- // Syncs created before the type existed have none and sync as secrets, so it stays optional elsewhere.
+ // New syncs default to Secret. The type stays optional elsewhere because syncs created before it existed
+ // have none, and they keep skipping same-name plaintext and JSON variables.
destinationConfig: CloudflareWorkersSyncDestinationConfigSchema.extend({
variableType: z
.nativeEnum(CloudflareWorkersVariableType)
@@ -57,7 +67,8 @@ export const CreateCloudflareWorkersSyncSchema = GenericCreateSecretSyncFieldsSc
export const UpdateCloudflareWorkersSyncSchema = GenericUpdateSecretSyncFieldsSchema(
SecretSync.CloudflareWorkers,
- CloudflareWorkersSyncOptionsConfig
+ CloudflareWorkersSyncOptionsConfig,
+ CloudflareWorkersSyncAdditionalOptionsSchema
).extend({
destinationConfig: CloudflareWorkersSyncDestinationConfigSchema.optional()
});
diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncOptionsFields/CloudflareWorkersSyncOptionsFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncOptionsFields/CloudflareWorkersSyncOptionsFields.tsx
index 3203ed5086..a9fd2a62ad 100644
--- a/frontend/src/components/secret-syncs/forms/SecretSyncOptionsFields/CloudflareWorkersSyncOptionsFields.tsx
+++ b/frontend/src/components/secret-syncs/forms/SecretSyncOptionsFields/CloudflareWorkersSyncOptionsFields.tsx
@@ -1,16 +1,22 @@
import { Controller, useFormContext } from "react-hook-form";
+import { TriangleAlert } from "lucide-react";
import {
+ Alert,
+ AlertDescription,
+ AlertTitle,
Field,
FieldContent,
FieldDescription,
FieldError,
FieldLabel,
+ Label,
Select,
SelectContent,
SelectItem,
SelectTrigger,
- SelectValue
+ SelectValue,
+ Toggle
} from "@app/components/v3";
import { CLOUDFLARE_WORKERS_VARIABLE_TYPE_LABELS } from "@app/helpers/secretSyncs";
import { SecretSync } from "@app/hooks/api/secretSyncs";
@@ -19,42 +25,96 @@ import { CloudflareWorkersVariableType } from "@app/hooks/api/secretSyncs/types/
import { TSecretSyncForm } from "../schemas";
export const CloudflareWorkersSyncOptionsFields = () => {
- const { control } = useFormContext<
+ const { control, watch } = useFormContext<
TSecretSyncForm & { destination: SecretSync.CloudflareWorkers }
>();
+ const disableSecretDeletion = watch("syncOptions.disableSecretDeletion");
+ const syncNonSecretBindings = watch("syncOptions.syncNonSecretBindings");
+ const variableType = watch(
+ "destinationConfig.variableType",
+ CloudflareWorkersVariableType.Secret
+ );
+
return (
- <Controller
- name="destinationConfig.variableType"
- control={control}
- defaultValue={CloudflareWorkersVariableType.Secret}
- render={({ field: { value, onChange }, fieldState: { error } }) => (
- <Field className="mb-4">
- <FieldLabel htmlFor="cloudflare-workers-variable-type">Variable type</FieldLabel>
- <FieldContent>
- <Select value={value} onValueChange={onChange}>
- <SelectTrigger
- id="cloudflare-workers-variable-type"
- className="w-full"
- isError={Boolean(error)}
+ <>
+ <Controller
+ name="destinationConfig.variableType"
+ control={control}
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <Field className="mb-4">
+ <FieldLabel htmlFor="cloudflare-workers-variable-type">Variable type</FieldLabel>
+ <FieldContent>
+ {/* Only a type the user picks is saved, so editing an older sync keeps its behavior */}
+ <Select
+ value={value ?? CloudflareWorkersVariableType.Secret}
+ onValueChange={onChange}
>
- <SelectValue />
- </SelectTrigger>
- <SelectContent position="popper">
- {Object.entries(CLOUDFLARE_WORKERS_VARIABLE_TYPE_LABELS).map(([type, label]) => (
- <SelectItem value={type} key={type}>
- {label}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- <FieldDescription>
- Secrets are encrypted in Cloudflare, while text and JSON variables stay readable.
- </FieldDescription>
- <FieldError errors={[error]} />
- </FieldContent>
- </Field>
+ <SelectTrigger
+ id="cloudflare-workers-variable-type"
+ className="w-full"
+ isError={Boolean(error)}
+ >
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent position="popper">
+ {Object.entries(CLOUDFLARE_WORKERS_VARIABLE_TYPE_LABELS).map(([type, label]) => (
+ <SelectItem value={type} key={type}>
+ {label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ <FieldDescription>
+ Secrets are encrypted in Cloudflare, while text and JSON variables stay readable.
+ </FieldDescription>
+ <FieldError errors={[error]} />
+ </FieldContent>
+ </Field>
+ )}
+ />
+ {variableType === CloudflareWorkersVariableType.Secret && (
+ <>
+ <Controller
+ name="syncOptions.syncNonSecretBindings"
+ control={control}
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <Field className="mb-4">
+ <Field orientation="horizontal">
+ <FieldContent>
+ <Label htmlFor="sync-non-secret-bindings">
+ Sync plaintext and JSON variables
+ </Label>
+ <FieldDescription>
+ Keep existing plaintext and JSON variables as their type and update their
+ values, instead of converting them to secrets.
+ </FieldDescription>
+ </FieldContent>
+ <Toggle
+ id="sync-non-secret-bindings"
+ variant="project"
+ checked={value}
+ onCheckedChange={onChange}
+ />
+ </Field>
+ <FieldError errors={[error]} />
+ </Field>
+ )}
+ />
+ {syncNonSecretBindings && !disableSecretDeletion && (
+ <Alert variant="warning" className="mb-4">
+ <TriangleAlert />
+ <AlertTitle>Plaintext and JSON variables may be deleted</AlertTitle>
+ <AlertDescription>
+ With &quot;Prevent secret deletion&quot; turned off and non-secret binding sync
+ turned on, any plaintext or JSON variables in Cloudflare Workers that are not
+ present in Infisical will be removed during a sync. Turn on &quot;Prevent secret
+ deletion&quot; above to keep them.
+ </AlertDescription>
+ </Alert>
+ )}
+ </>
)}
- />
+ </>
);
};
diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/CloudflareWorkersReviewFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/CloudflareWorkersReviewFields.tsx
index 7eae159d6f..55ba457200 100644
--- a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/CloudflareWorkersReviewFields.tsx
+++ b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/CloudflareWorkersReviewFields.tsx
@@ -1,7 +1,7 @@
import { useFormContext } from "react-hook-form";
import { TSecretSyncForm } from "@app/components/secret-syncs/forms/schemas";
-import { Detail, DetailLabel, DetailValue } from "@app/components/v3";
+import { Badge, Detail, DetailLabel, DetailValue } from "@app/components/v3";
import { CLOUDFLARE_WORKERS_VARIABLE_TYPE_LABELS } from "@app/helpers/secretSyncs";
import { SecretSync } from "@app/hooks/api/secretSyncs";
import { CloudflareWorkersVariableType } from "@app/hooks/api/secretSyncs/types/cloudflare-workers-sync";
@@ -11,14 +11,28 @@ export const CloudflareWorkersSyncOptionsReviewFields = () => {
TSecretSyncForm & { destination: SecretSync.CloudflareWorkers }
>();
- const variableType =
- watch("destinationConfig.variableType") ?? CloudflareWorkersVariableType.Secret;
+ const [{ syncNonSecretBindings }, variableType = CloudflareWorkersVariableType.Secret] = watch([
+ "syncOptions",
+ "destinationConfig.variableType"
+ ]);
return (
- <Detail>
- <DetailLabel>Variable Type</DetailLabel>
- <DetailValue>{CLOUDFLARE_WORKERS_VARIABLE_TYPE_LABELS[variableType]}</DetailValue>
- </Detail>
+ <>
+ <Detail>
+ <DetailLabel>Variable Type</DetailLabel>
+ <DetailValue>{CLOUDFLARE_WORKERS_VARIABLE_TYPE_LABELS[variableType]}</DetailValue>
+ </Detail>
+ {variableType === CloudflareWorkersVariableType.Secret && (
+ <Detail>
+ <DetailLabel>Sync Plaintext and JSON Variables</DetailLabel>
+ <DetailValue>
+ <Badge variant={syncNonSecretBindings ? "success" : "danger"}>
+ {syncNonSecretBindings ? "Enabled" : "Disabled"}
+ </Badge>
+ </DetailValue>
+ </Detail>
+ )}
+ </>
);
};
diff --git a/frontend/src/components/secret-syncs/forms/schemas/cloudflare-workers-sync-destination-schema.ts b/frontend/src/components/secret-syncs/forms/schemas/cloudflare-workers-sync-destination-schema.ts
index 9ddaa618e7..ad03fb7a5b 100644
--- a/frontend/src/components/secret-syncs/forms/schemas/cloudflare-workers-sync-destination-schema.ts
+++ b/frontend/src/components/secret-syncs/forms/schemas/cloudflare-workers-sync-destination-schema.ts
@@ -4,7 +4,11 @@ import { BaseSecretSyncSchema } from "@app/components/secret-syncs/forms/schemas
import { SecretSync } from "@app/hooks/api/secretSyncs/enums";
import { CloudflareWorkersVariableType } from "@app/hooks/api/secretSyncs/types/cloudflare-workers-sync";
-export const CloudflareWorkersSyncDestinationSchema = BaseSecretSyncSchema().merge(
+export const CloudflareWorkersSyncDestinationSchema = BaseSecretSyncSchema(
+ z.object({
+ syncNonSecretBindings: z.boolean().optional().default(false)
+ })
+).merge(
z.object({
destination: z.literal(SecretSync.CloudflareWorkers),
destinationConfig: z.object({
@@ -14,9 +18,7 @@ export const CloudflareWorkersSyncDestinationSchema = BaseSecretSyncSchema().mer
.min(1, "Script ID is required")
.max(64)
.regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/, "Invalid script ID format"),
- variableType: z
- .nativeEnum(CloudflareWorkersVariableType)
- .default(CloudflareWorkersVariableType.Secret)
+ variableType: z.nativeEnum(CloudflareWorkersVariableType).optional()
})
})
);
diff --git a/frontend/src/hooks/api/secretSyncs/types/cloudflare-workers-sync.ts b/frontend/src/hooks/api/secretSyncs/types/cloudflare-workers-sync.ts
index 76c995791b..0a9790e9cd 100644
--- a/frontend/src/hooks/api/secretSyncs/types/cloudflare-workers-sync.ts
+++ b/frontend/src/hooks/api/secretSyncs/types/cloudflare-workers-sync.ts
@@ -1,6 +1,6 @@
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import { SecretSync } from "@app/hooks/api/secretSyncs";
-import { TRootSecretSync } from "@app/hooks/api/secretSyncs/types/root-sync";
+import { RootSyncOptions, TRootSecretSync } from "@app/hooks/api/secretSyncs/types/root-sync";
export enum CloudflareWorkersVariableType {
Secret = "secret_text",
@@ -19,4 +19,7 @@ export type TCloudflareWorkersSync = TRootSecretSync & {
name: string;
id: string;
};
+ syncOptions: RootSyncOptions & {
+ syncNonSecretBindings?: boolean;
+ };
};