Skip to content

API reference

secret declares static, random, and generated secrets with version-aware runtime access.

Terminal window
import { secret } from "@layeron/modules"

Declare a static secret reference.

TypeSpec operation: secretStatic.

Terminal window
secret.static(options: StaticSecretOptions): SecretModule

Previous-version retention policy.

FieldTypeDescription
modeSecretRetentionModeRetention mode.
daysint32 | undefinedDays to retain previous versions when mode is retain_for.

Rotation policy for random secrets and generated secret metadata.

FieldTypeDescription
everyDaysint32 | undefinedRotation interval in days.
startAtstring | undefinedRFC3339 time for the first scheduled rotation.
retainSecretRetentionOptions | undefinedPrevious-version retention policy.

Runtime value format options.

FieldTypeDescription
formatSecretValueFormat | undefinedFormat used when reading the secret.

Runtime consumption settings.

FieldTypeDescription
addressstring | undefinedTyped runtime address used by generated bindings.
expose”current” | “versioned” | undefinedWhether runtime consumers can see only current or versioned values.

Ownership metadata for product-owned secrets.

FieldTypeDescription
ownerProductstring | undefinedOwning product name.
ownerInstanceIdstring | undefinedOwning product instance id.
purposestring | undefinedBusiness purpose for this secret.

Common options accepted by secret constructors.

FieldTypeDescription
namestringStable secret name.
namespacestring | undefinedPlatform namespace for the instance. Defaults to default.
rotationSecretRotationOptions | undefinedRotation policy.
valueSecretValueOptions | undefinedValue format settings.
consumeSecretConsumeOptions | undefinedRuntime consumption settings.
ownershipSecretOwnershipOptions | undefinedOwnership metadata for product-owned secrets.

Options accepted by secret.static().

FieldTypeDescription

Options accepted by secret.random().

FieldTypeDescription
bytesint32 | undefinedNumber of random bytes to generate. Defaults to 32.

Options accepted by secret.generated(). The value is generated outside application code and stored in the user’s Cloudflare Secrets Store.

FieldTypeDescription
bytesint32 | undefinedExpected generated byte count when known.

Generated secret metadata recorded in normalized module config.

FieldTypeDescription
type”random” | “custom”Generated value source type.
bytesint32 | undefinedGenerated byte count when known.

Normalized Layeron secret module configuration.

FieldTypeDescription
kind”secret”Module config kind.
namestringStable secret name.
namespacestringPlatform namespace for the instance. Defaults to default.
secretKindSecretKindSecret value source kind.
bytesint32 | undefinedGenerated byte count when applicable.
rotationSecretRotationOptions | undefinedRotation policy.
valueSecretValueOptionsValue format settings.
consumeSecretConsumeOptionsRuntime consumption settings.
ownershipSecretOwnershipOptions | undefinedOwnership metadata for product-owned secrets.
generatedSecretGeneratedMetadata | undefinedGenerated secret metadata when the declaration creates or expects a generated value.

Selector accepted by secret version reads.

FieldTypeDescription
kind”current” | “version” | “at” | “active”Selector kind.
versionstring | undefinedVersion id when kind is version.
atstring | undefinedRFC3339 timestamp when kind is at or active.

One resolved secret version.

FieldTypeDescription
valuestringSecret value encoded according to the configured value format.
versionstring | undefinedVersion id.
activeFromstring | undefinedActivation timestamp.
expiresAtstring | undefinedExpiration timestamp.
currentboolean | undefinedWhether this is the current version.

Result returned by secret reads.

FieldTypeDescription
valuesSecretVersionResult[]Matching secret versions.

Layeron secret module returned by secret constructors.

FieldTypeDescription
name”secret”Module name.
configSecretModuleConfigNormalized module configuration.

Retention mode for previous secret versions.

ValueDescription
noneRetire previous versions immediately.
retain_forRetain previous versions for a fixed number of days.
retain_foreverRetain previous versions until explicit cleanup.

Secret value serialization format.

ValueDescription
textPlain text value.
jsonJSON value.
kvKey-value shaped JSON value.

Secret value source kind.

ValueDescription
staticThe value is supplied outside the app declaration.
randomLayeron creates a random value during controlled secret creation.
generatedLayeron records a generated value source that is fulfilled by local CLI or product-specific apply flows.

Declare a random generated secret.

TypeSpec operation: secretRandom.

Terminal window
secret.random(options: RandomSecretOptions): SecretModule

Declare generated secret metadata for a value produced outside application code.

TypeSpec operation: secretGenerated.

Terminal window
secret.generated(options: GeneratedSecretOptions): SecretModule

Read one or more secret versions.

Terminal window
secretGet(input: SecretGetInput): SecretGetResult
MethodDescription
hmac()Sign a message with the current secret value as an HMAC key.
verifyHmac()Verify an HMAC signature with the current secret value.
signJwt()Sign a JWT with the current secret or an explicit key.
verifyJwt()Verify a JWT with the current secret or an explicit key.