Welcome to the Jose Madrid Salsa developer docs — explore features, APIs, and deployment guides.
Jose Madrid SalsaJMS Docs

Credential Vault

Encrypted storage for third-party service credentials, and the grants that control who can read them.

Credential Vault

Third-party logins that do not belong in environment variables — a carrier portal, a supplier account, a bank login — are stored encrypted in the database and read through /admin/credentials.

Storage

ServiceCredential holds one credential:

FieldPurpose
serviceName, labelWhat this is
usernameOptional
encValue, encIv, encTagThe secret, AES-256-GCM
url, notesWhere to use it, and anything else
createdById, updatedByIdWho touched it
passwordChangedAtLast rotation

Encryption is lib/crypto.ts: AES-256-GCM with a 128-bit IV and a 128-bit auth tag, keyed by MASTER_KEY (ENCRYPTION_KEY is used for the same machinery elsewhere). Both must be valid hex of the right length — crypto.ts validates before decrypting rather than surfacing a raw cipher error.

Lose MASTER_KEY and every stored credential is unrecoverable. It is not derivable from anything else. Keep it in Vercel environment variables and in whatever the team uses for break-glass secrets — never in the repository.

The same encryption path secures QuickBooks OAuth tokens, social platform tokens, and admin-entered API credentials.

Who can read what

Two gates must both pass:

  1. CredentialAccessGrant — a row keyed by email, with per-action flags canView, canAdd, canEdit, canDelete, canUpload, and a revokedAt that turns the grant off without deleting the audit trail.
  2. The RBAC permission system — the CREDENTIALS permission category.

checkCredentialAccess(email, role) in lib/credentials.ts evaluates both and returns 'read', 'write', or null. The designated super-admin account bypasses the grant table, matching the admin page's own bypass.

Grant access with:

npm run credentials:grant-access --workspace @jose-madrid/storefront

If the credential_access_grants table is missing, isMissingTableError catches the Prisma P2021 and logs a warning rather than crashing the admin panel — the same safe-degradation pattern used for permissions.

How is this guide?

Edit on GitHub

Last updated on

On this page