@molecule/app-secret-row-svelte

Feature · secret-row · App (browser) · v1.2.2 · Apache-2.0

Secret/credential row: masked value + reveal/copy + rotation status + version

npm install @molecule/app-secret-row-svelte

npm · Source on GitHub

How it works

@molecule/app-secret-row-svelte is a ready-made secret-row feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

<script lang="ts">
  import { SecretRow } from '@molecule/app-secret-row-svelte'

  const secret = {
    id: 'sk-1',
    key: 'STRIPE_SECRET_KEY',
    value: 'sk_live_abc123',
    description: 'Stripe API key',
    daysUntilRotation: 14,
  }
</script>

<SecretRow {secret} onRotate={(s) => rotate(s.id)} onDelete={(s) => remove(s.id)} />

Works with: @molecule/app-clipboard, @molecule/app-svelte, @molecule/app-ui, @molecule/app-ui-svelte

Reference

Svelte vault-style secret / credential row.

Exports SecretRow and the SecretRowData type ({ id, key, value, version?, daysUntilRotation?, lastRotatedAt?, description? }). Renders key + masked value with Show/Hide and Copy buttons, an optional rotation status (an "Expired" tag / "Rotate in {n}d" countdown / "Last rotated {value}" note), plus optional Rotate / Delete buttons (shown only when onRotate / onDelete are passed). maskChar customizes the mask glyph (default '•'). It is the Svelte counterpart of @molecule/app-secret-row-react: the same props (React names) and the same DOM for the same input.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

<script lang="ts">
  import { SecretRow } from '@molecule/app-secret-row-svelte'

  const secret = {
    id: 'sk-1',
    key: 'STRIPE_SECRET_KEY',
    value: 'sk_live_abc123',
    description: 'Stripe API key',
    daysUntilRotation: 14,
  }
</script>

<SecretRow {secret} onRotate={(s) => rotate(s.id)} onDelete={(s) => remove(s.id)} />

Type

feature

Installation

npm install @molecule/app-secret-row-svelte @molecule/app-clipboard @molecule/app-svelte @molecule/app-ui @molecule/app-ui-svelte svelte

API

Interfaces

SecretRowData

Data model for a single secret/credential entry in a vault UI.

interface SecretRowData {
  /** Stable identity of the secret. */
  id: string
  /** The credential's name (`STRIPE_SECRET_KEY`). */
  key: string
  /** Current value (revealed only after the user clicks "Show"). */
  value: string
  /** Version number / label (React's `ReactNode`: text or a snippet). */
  version?: Snippet | string | number
  /**
   * Days until the secret should be rotated. A negative value renders an
   * "Expired" tag; zero or a positive value renders a "Rotate in {n}d"
   * countdown.
   */
  daysUntilRotation?: number
  /** Last-rotation timestamp (ISO string or any node); rendered as "Last rotated {value}". */
  lastRotatedAt?: Snippet | string | number
  /** Additional description (e.g. "Stripe API key"). */
  description?: Snippet | string | number
}

SecretRowProps

Props accepted by the SecretRow component.

interface SecretRowProps {
  /** The secret to display. */
  secret: SecretRowData
  /** Called when the user clicks Rotate. */
  onRotate?: (secret: SecretRowData) => void
  /** Called when the user clicks Delete. */
  onDelete?: (secret: SecretRowData) => void
  /** Mask character for the hidden value. Defaults to `'•'`. */
  maskChar?: string
  /** Extra classes. */
  className?: string
}

Constants

SecretRow

const SecretRow: LegacyComponentType

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-clipboard ^1.0.1
  • @molecule/app-svelte ^3.5.0 || ^4.0.0
  • @molecule/app-ui ^1.4.0
  • @molecule/app-ui-svelte ^1.1.0
  • svelte ^5.0.0

Runtime Dependencies

  • @molecule/app-clipboard

  • @molecule/app-svelte

  • @molecule/app-ui

  • @molecule/app-ui-svelte

  • svelte

  • Rotation status renders from two fields: daysUntilRotation < 0 shows an "Expired" tag, daysUntilRotation >= 0 shows a "Rotate in {n}d" countdown, and lastRotatedAt (when set) renders a "Last rotated {value}" note. Omit a field to hide its chip.

  • Copying goes through copyTextWithFallback (@molecule/app-clipboard): the Clipboard API through the bonded clipboard provider when one is wired, the legacy copy command otherwise — so it also works on plain-HTTP pages and inside iframes. The function never throws; when the copy is blocked the button shows no feedback.

  • The version chip renders as v{version} — pass version="2", not "v2".

  • Delete fires immediately — add your own confirmation dialog before calling a destructive API.

  • Throws unless the binding's i18n context is set and a ClassMap is bonded. Translations: @molecule/app-locales-secret-row.

Translations

Translation strings are provided by @molecule/app-locales-secret-row.