@molecule/app-secret-row-angular
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-angularHow it works
@molecule/app-secret-row-angular 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.
import { Component } from '@angular/core'
import { SecretRow, type SecretRowData } from '@molecule/app-secret-row-angular'
@Component({
selector: 'app-vault-row',
standalone: true,
imports: [SecretRow],
template: `
<div
mol-secret-row
[secret]="{
id: 'sk-1',
key: 'STRIPE_SECRET_KEY',
value: 'sk_live_abc123',
description: 'Stripe API key',
daysUntilRotation: 14,
}"
[onRotate]="rotate"
[onDelete]="remove"
></div>
`,
})
export class VaultRow {
readonly rotate = (secret: SecretRowData): void => {
console.log('rotate secret', secret.id)
}
readonly remove = (secret: SecretRowData): void => {
console.log('delete secret', secret.id)
}
}Works with: @molecule/app-angular, @molecule/app-clipboard, @molecule/app-ui, @molecule/app-ui-angular
Reference
Angular vault-style secret / credential row — the counterpart of
@molecule/app-secret-row-react: the same props and the same DOM for the
same input.
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 '•').
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.tsJSDoc, not this file.
Quick Start
import { Component } from '@angular/core'
import { SecretRow, type SecretRowData } from '@molecule/app-secret-row-angular'
@Component({
selector: 'app-vault-row',
standalone: true,
imports: [SecretRow],
template: `
<div
mol-secret-row
[secret]="{
id: 'sk-1',
key: 'STRIPE_SECRET_KEY',
value: 'sk_live_abc123',
description: 'Stripe API key',
daysUntilRotation: 14,
}"
[onRotate]="rotate"
[onDelete]="remove"
></div>
`,
})
export class VaultRow {
readonly rotate = (secret: SecretRowData): void => {
console.log('rotate secret', secret.id)
}
readonly remove = (secret: SecretRowData): void => {
console.log('delete secret', secret.id)
}
}
Type
feature
Installation
npm install @molecule/app-secret-row-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-clipboard @molecule/app-ui @molecule/app-ui-angular
API
Interfaces
SecretRowData
Data model for a single secret/credential entry in a vault UI. Node props
(version, lastRotatedAt, description) are templated content in Angular
(an input cannot carry a node), so they are typed unknown: pass plain
text/numbers or <ng-template> refs.
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. */
version?: unknown
/**
* 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?: unknown
/** Additional description (e.g. "Stripe API key"). */
description?: unknown
}
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
}
Classes
SecretRow
SecretRow component.
Secret / credential row for vault UIs. Masked by default; the user toggles
reveal, can copy to clipboard, sees an "Expired" tag when
daysUntilRotation is negative or a "Rotate in {n}d" countdown when it is
zero/positive, and a "Last rotated {value}" note when lastRotatedAt is
set. The Rotate / Delete buttons render only when their handler is passed.
The host IS the root <div> (div[mol-secret-row]), matching React's root
exactly. Node-valued secret fields are ng-template references rendered
through NgTemplateOutlet; string / number fields render as text.
The template's whitespace is semantic: Angular removes whitespace-only text
nodes between elements, so the markup is glued where React renders adjacent
inline nodes (the v before the version and the space before the
last-rotated value are explicit interpolations).
@Component({
selector: 'div[mol-secret-row]',
standalone: true,
imports: [Button, NgTemplateOutlet],
inputs: ['secret', 'onRotate', 'onDelete', 'maskChar', 'className'],
host: { '[class]': 'classes()' },
// prettier-ignore
template: `<div [class]="stackClasses()"><span [class]="keyClass()">{{ secret.key }}</span>@if (secret.description) {<span [class]="descriptionClass()">@if (isNode(secret.description)) {<ng-container [ngTemplateOutlet]="secret.description" />}@else {<ng-container>{{ textOf(secret.description) }}</ng-container>}</span>}@else {<ng-container>{{ textOf(secret.description) }}</ng-container>}</div><code [class]="codeClass()">{{ revealed ? secret.value : masked() }}</code>@if (secret.version) {<span [class]="chipClass()">{{ 'v' }}@if (isNode(secret.version)) {<ng-container [ngTemplateOutlet]="secret.version" />}@else {<ng-container>{{ textOf(secret.version) }}</ng-container>}</span>}@else {<ng-container>{{ textOf(secret.version) }}</ng-container>}@if (expired()) {<span [class]="expiredClass()">{{ expiredText() }}</span>}@if (showCountdown()) {<span [class]="chipClass()">{{ rotateText() }}</span>}@if (showLastRotated()) {<span [class]="mutedClass()">{{ lastRotatedText() + ' ' }}@if (isNode(secret.lastRotatedAt)) {<ng-container [ngTemplateOutlet]="secret.lastRotatedAt" />}@else {<ng-container>{{ textOf(secret.lastRotatedAt) }}</ng-container>}</span>}<button mol-button [variant]="'ghost'" [size]="'sm'" (click)="toggleReveal()">{{ showHideText() }}</button><button mol-button [variant]="'ghost'" [size]="'sm'" (click)="copy()">{{ copyText() }}</button>@if (onRotate) {<button mol-button [variant]="'ghost'" [size]="'sm'" (click)="rotate()">{{ rotateButtonText() }}</button>}@if (onDelete) {<button mol-button [variant]="'ghost'" [size]="'sm'" [color]="'error'" (click)="remove()">{{ deleteButtonText() }}</button>}`,
})
export class SecretRow implements OnDestroy {
/** The secret to display (required, as in React's props). */
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 `'•'` at read time). */
maskChar?: string
/** Extra classes. */
className?: string
/** Whether the value is revealed (Show → Hide). */
revealed = false
/** Whether the Copy button shows its "Copied!" feedback. */
copied = false
/** The pending feedback timer. */
private timer: ReturnType<typeof setTimeout> | undefined
/** The translation function, captured in the injection context. */
private readonly i18n = useTranslation()
/** The current class map. */
cm(): UIClassMap {
return getClassMap()
}
/** The host (root `<div>`) class list (React's `cm.cn(cm.flex({ align: 'center', gap: 'sm' }), cm.sp('py', 2), className)`). */
classes(): string {
return this.cm().cn(
this.cm().flex({ align: 'center', gap: 'sm' }),
this.cm().sp('py', 2),
this.className,
)
}
/** The key/description column's class (`cm.flex1` + `cm.stack(0)`). */
stackClasses(): string {
return this.cm().cn(this.cm().flex1, this.cm().stack(0))
}
/** The key span's class (`cm.fontWeight('semibold')`). */
keyClass(): string {
return this.cm().cn(this.cm().fontWeight('semibold'))
}
/** The description span's class (`cm.textSize('xs')`). */
descriptionClass(): string {
return this.cm().textSize('xs')
}
/** The masked-value `<code>` class (`cm.sp('px', 2)`, `cm.sp('py', 1)`, `cm.textSize('xs')`). */
codeClass(): string {
return this.cm().cn(this.cm().sp('px', 2), this.cm().sp('py', 1), this.cm().textSize('xs'))
}
/** The version / rotation chip class (`cm.textSize('xs')`, `cm.fontWeight('semibold')`). */
chipClass(): string {
return this.cm().cn(this.cm().textSize('xs'), this.cm().fontWeight('semibold'))
}
/** The expired-tag class (`cm.textSize('xs')`, `cm.fontWeight('semibold')`, `cm.textTone('error')`). */
expiredClass(): string {
return this.cm().cn(
this.cm().textSize('xs'),
this.cm().fontWeight('semibold'),
this.cm().textTone('error'),
)
}
/** The last-rotated note's class (`cm.textSize('xs')`, `cm.textMuted`). */
mutedClass(): string {
return this.cm().cn(this.cm().textSize('xs'), this.cm().textMuted)
}
/** The mask shown while the value is hidden — React's `maskChar.repeat(Math.max(8, Math.min(value.length, 24)))`. */
masked(): string {
const maskChar = this.maskChar === undefined ? '•' : this.maskChar
return maskChar.repeat(Math.max(8, Math.min(this.secret.value.length, 24)))
}
/** Whether the rotation chip is the "Expired" tag (a negative countdown). */
expired(): boolean {
return this.secret.daysUntilRotation !== undefined && this.secret.daysUntilRotation < 0
}
/** Whether the "Rotate in {n}d" countdown renders (`daysUntilRotation` is zero or positive). */
showCountdown(): boolean {
return this.secret.daysUntilRotation !== undefined && this.secret.daysUntilRotation >= 0
}
/** Whether the "Last rotated" note renders (React's `!== undefined && !== null` check). */
showLastRotated(): boolean {
return this.secret.lastRotatedAt !== undefined && this.secret.lastRotatedAt !== null
}
/** The translated "Expired" label. */
expiredText(): string {
return this.i18n.t('secretRow.expired', {}, { defaultValue: 'Expired' })
}
/** The translated rotation countdown. */
rotateText(): string {
return this.i18n.t(
'secretRow.rotateIn',
{ days: this.secret.daysUntilRotation ?? 0 },
{ defaultValue: 'Rotate in {{days}}d' },
)
}
/** The translated "Last rotated" label (React renders it then a space then the value). */
lastRotatedText(): string {
return this.i18n.t('secretRow.lastRotated', {}, { defaultValue: 'Last rotated' })
}
/** The Show / Hide button label. */
showHideText(): string {
return this.revealed
? this.i18n.t('secretRow.hide', {}, { defaultValue: 'Hide' })
: this.i18n.t('secretRow.show', {}, { defaultValue: 'Show' })
}
/** The Copy / Copied! button label. */
copyText(): string {
return this.copied
? this.i18n.t('secretRow.copied', {}, { defaultValue: 'Copied!' })
: this.i18n.t('secretRow.copy', {}, { defaultValue: 'Copy' })
}
/**
* The Rotate button label.
* @returns The label text.
*/
rotateButtonText(): string {
return this.i18n.t('secretRow.rotate', {}, { defaultValue: 'Rotate' })
}
/**
* The Delete button label.
* @returns The label text.
*/
deleteButtonText(): string {
return this.i18n.t('secretRow.delete', {}, { defaultValue: 'Delete' })
}
/** Whether a field holds a node (an `ng-template` reference) rather than text. */
isNode(value: unknown): value is TemplateRef<unknown> {
return value instanceof TemplateRef
}
/** The text a field renders (React renders strings and numbers as text). */
textOf(value: unknown): string {
return typeof value === 'string' || typeof value === 'number' ? String(value) : ''
}
/** Toggles the revealed state (React's `setRevealed((x) => !x)`). */
toggleReveal(): void {
this.revealed = !this.revealed
}
/** Copies the value, then shows the "Copied!" feedback for 1.5 s. */
copy(): void {
void copyTextWithFallback(this.secret.value).then((didCopy) => {
if (!didCopy) return
this.copied = true
this.timer = setTimeout(() => {
this.copied = false
}, 1500)
})
}
/** Calls `onRotate` with the secret (React passes the same object). */
rotate(): void {
this.onRotate?.(this.secret)
}
/** Calls `onDelete` with the secret (React passes the same object). */
remove(): void {
this.onDelete?.(this.secret)
}
/** Detaches the feedback timer with the component. */
ngOnDestroy(): void {
clearTimeout(this.timer)
}
}
(The 20 longest member comments are shortened to their first sentence to fit; the full declaration is in node_modules/@molecule/app-secret-row-angular/dist/secret-row.component.d.ts.)
Injection Notes
Requirements
Peer dependencies:
@angular/common^22.0.0@angular/core^22.0.0@angular/platform-browser^22.0.0@molecule/app-angular^3.5.0 || ^4.0.0@molecule/app-clipboard^1.0.1@molecule/app-ui^1.4.0@molecule/app-ui-angular^1.1.0
Runtime Dependencies
-
@angular/common -
@angular/core -
@angular/platform-browser -
@molecule/app-angular -
@molecule/app-clipboard -
@molecule/app-ui -
@molecule/app-ui-angular -
Rotation status renders from two fields:
daysUntilRotation < 0shows an "Expired" tag,daysUntilRotation >= 0shows a "Rotate in {n}d" countdown, andlastRotatedAt(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}— passversion="2", not "v2". -
Delete fires immediately — add your own confirmation dialog before calling a destructive API.
-
Node-valued
secretfields (version,lastRotatedAt,description) are<ng-template>refs or plain strings/numbers. Throws unless the binding's i18n provider is configured and a ClassMap is bonded. Translations:@molecule/app-locales-secret-row.
Translations
Translation strings are provided by @molecule/app-locales-secret-row.