Add the LogicSRC OpenCreds specification

Leaving a password manager means writing every secret you own to disk in
the clear, and losing whatever the spreadsheet had no column for. A CSV
is plaintext by construction, lossy by omission, and carries no
integrity: nothing in it says which rows were meant to be there, so a
truncated import looks exactly like a complete one.

The same gap showed up inside LogicSRC. `logicsrc credentials` moves
.env secrets and SSH keys through end-to-end-encrypted team vaults, but
it can only model a key/value pair. A card, a passport, a login with a
TOTP seed, or an OAuth account with a refresh token are all things
people already keep in a vault, and none of them are a key/value pair.

OpenCreds defines three things: the item, the vault, and the database.

- Six item types (login, card, identity, note, key, account) as one
  record with a type and a named field group, so everything the user
  typed lives in a single encrypted blob. Codes 1-4 match MarkSyncr's
  deployed vault and are not renumbered; compatibility is cheaper than
  elegance.
- AES-256-GCM over that record with the item id bound as AAD. Without
  it, anyone with storage write access could move a low-value login's
  ciphertext into a high-value row and watch what the user does next.
- A key hierarchy where the user key is random, not derived, so a
  password change re-wraps 32 bytes rather than re-encrypting a vault.
  The auth hash comes out of a different HKDF label than the wrap key,
  which is what lets it reach a server at all.
- A portable .opencreds file, encrypted by default, whose header is the
  AAD over the payload -- so the manifest is authenticated by the same
  tag as the data and a truncated import fails rather than reporting
  success. The plaintext form exists because people move to products
  that read nothing else; it is opt-in, confirmed, 0600, and labelled
  "protected": false in its own header.

Namespaces are carried as data, not fixed by the spec: labels are
compiled into every ciphertext a vault has written, so editing one does
not migrate a vault, it makes it undecryptable. MarkSyncr's deployed
vault is conformant by declaring `marksyncr`.

Ships: prd/0004, nine spec pages under docs/opencreds/, six JSON
Schemas, the @logicsrc/opencreds reference implementation with CSV
importers for five products, `logicsrc vault` and the standalone
`opencreds` binary, and the spec page at logicsrc.com/opencreds.

`vault` rather than `creds` because `creds` is already an alias of
`logicsrc credentials`, and the two are different: one moves a pair
between providers, the other stores a record.

@logicsrc/validators now registers every schema by $id before
compiling, so the database schema can $ref the item and manifest
schemas rather than restating them.

120 tests, including CLI end-to-end coverage of the masking rules,
exit codes, and the manifest-mismatch path.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QRQrfuwuYKKV5UB9kLHuX5
This commit is contained in:
Anthony Ettinger 2026-08-29 10:00:07 +00:00
parent b1805d08e5
commit 13519e631a
51 changed files with 8105 additions and 8 deletions

View file

@ -0,0 +1,180 @@
# The OpenCreds item model
One record, six types, one field group each. This page specifies the groups
field by field. The record shape around them is [spec.md §3](./spec.md#3-the-item).
Every field in every group is a string unless stated otherwise, and every field
is OPTIONAL with an empty string as its default. A vault holds half-filled
records — someone knows the card number and not the issuing bank — and a model
that requires fields produces importers that invent them.
## login (code 1)
| Field | Type | Notes |
| --- | --- | --- |
| `username` | string | |
| `password` | string | |
| `totp` | string | An `otpauth://` URI, or a bare base32 seed. Store the URI where you have it: it carries the algorithm, digits and period, and a bare seed loses them. |
| `uris` | array | Matching URIs, see below. |
```json
{ "uri": "https://github.com", "match": "domain" }
```
`match` MUST be one of `domain`, `host`, `startsWith`, `exact`, `regex`, or
`never`. It is carried so that a move does not silently widen where a credential
will be offered; an implementation that does not autofill still round-trips it.
`login` is the only type with `history` ([spec.md §3.5](./spec.md#35-password-history)).
## card (code 2)
| Field | Notes |
| --- | --- |
| `cardholderName` | |
| `brand` | `Visa`, `Mastercard`, `Amex`, … Free text; issuers add brands. |
| `number` | Full PAN. |
| `expMonth` | `1`–`12`, no leading zero required. |
| `expYear` | Four digits. Two-digit years from an import are expanded to 20xx. |
| `code` | CVV/CVC. |
## identity (code 3)
| Field | Notes |
| --- | --- |
| `title` | Mr, Ms, Dr, … |
| `firstName`, `middleName`, `lastName` | |
| `username` | An identity's handle, distinct from a login's. |
| `company` | |
| `email`, `phone` | |
| `address1`, `address2`, `address3` | |
| `city`, `state`, `postalCode`, `country` | |
| `ssn` | National identity number. Named `ssn` for import compatibility; it is not US-specific. |
| `passportNumber` | |
| `licenseNumber` | |
## note (code 4)
No field group. The content is the record's `notes` field. A `note` item that
also carries custom `fields` is valid and common — it is how people store the
things a vault has no type for.
## key (code 5)
Introduced by OpenCreds. Covers SSH keys, PGP keys, API tokens, certificates,
and the `.env` secrets that `logicsrc credentials` synchronizes.
| Field | Notes |
| --- | --- |
| `keyType` | One of `ssh`, `pgp`, `api`, `symmetric`, `certificate`, `env`. |
| `algorithm` | `ed25519`, `rsa-4096`, `ecdsa-p256`, … |
| `publicKey` | Armoured/OpenSSH public key text. |
| `privateKey` | Armoured/PEM private key text. |
| `passphrase` | The private key's own passphrase, where it has one. |
| `fingerprint` | `SHA256:…` — a public, non-secret identifier. |
| `value` | The secret for key types that are one opaque string (`api`, `env`, `symmetric`). |
| `path` | Where the key belongs on disk, e.g. `~/.ssh/id_ed25519`. |
| `mode` | POSIX mode as an octal string, e.g. `"0600"`. |
| `expiresAt` | RFC 3339, where the key expires. |
`path` and `mode` exist so a restore is total: a private key written back with
the wrong mode is a key `ssh` will refuse to use, and a key written to the wrong
path is a key nothing finds. They carry the same information as the
self-describing envelope the `ssh` credential provider already writes.
An `.env` secret becomes `{ "keyType": "env", "value": "…" }` with the variable
name as the item `name`. That is the bridge between the two specs: Credential
Sharing moves a key/value pair between providers, OpenCreds is what it looks
like when stored.
## account (code 6)
Introduced by OpenCreds. A provider account and the tokens that authorize acting
as it — a connected Google account, a social account, a service account.
| Field | Notes |
| --- | --- |
| `provider` | `google`, `github`, `x`, `stripe`, … An OpenOntology entity id where one is in use. |
| `accountId` | The provider's own id for the account. |
| `handle` | The username or handle at that provider. |
| `email` | |
| `accessToken` | |
| `refreshToken` | |
| `tokenType` | `bearer`, … |
| `scopes` | Array of strings. |
| `expiresAt` | RFC 3339 expiry of `accessToken`. |
| `environment` | `production`, `sandbox`, … A test key and a live key look identical and are not. |
An `account` is deliberately not a `login`. A login is what a *person* types at
a sign-in form; an account is what a *machine* presents to an API. They expire
differently, they are revoked differently, and conflating them is how a rotated
refresh token ends up in a password history array.
## Folders
A vault MAY carry folders. A folder is `{ "id": "<uuid>", "name": "Work" }` and
is referenced by an item's `folderId`. Folders are flat: a name MAY contain `/`
and an implementation MAY render that as a hierarchy, but the model does not
nest, because every product that nests them disagrees about what a move does.
Folder names are **not** encrypted by the item envelope — they live in the
database payload, which is encrypted as a whole, and in a vault's own storage
they are wherever that implementation puts them. An implementation that stores
folder names in the clear MUST say so; a folder list is a good description of
someone's life.
## Worked examples
A login with history:
```json
{
"v": 1, "id": "6f1e7b3a-1f4e-4f0f-9a1d-6a2f0b6f8d21", "type": "login",
"name": "GitHub", "favorite": true, "folderId": null, "notes": "",
"login": {
"username": "anthony",
"password": "correct-horse-battery-staple",
"totp": "otpauth://totp/GitHub:anthony?secret=JBSWY3DPEHPK3PXP&issuer=GitHub",
"uris": [{ "uri": "https://github.com", "match": "domain" }]
},
"history": [{ "password": "hunter2", "changedAt": "2026-01-04T09:12:00.000Z" }],
"createdAt": "2025-11-02T10:00:00.000Z",
"updatedAt": "2026-01-04T09:12:00.000Z"
}
```
An SSH deploy key:
```json
{
"v": 1, "id": "0c0f7a2e-9d1a-4f6e-b2b7-1f3d5a7c9e11", "type": "key",
"name": "deploy@railway", "notes": "Rotated quarterly",
"key": {
"keyType": "ssh", "algorithm": "ed25519",
"publicKey": "ssh-ed25519 AAAAC3Nza… deploy@railway",
"privateKey": "-----BEGIN OPENSSH PRIVATE KEY-----\n…\n-----END OPENSSH PRIVATE KEY-----\n",
"passphrase": "", "fingerprint": "SHA256:9Vt…",
"path": "~/.ssh/id_ed25519_railway", "mode": "0600", "expiresAt": ""
},
"createdAt": "2026-03-01T00:00:00.000Z",
"updatedAt": "2026-06-01T00:00:00.000Z"
}
```
A connected account:
```json
{
"v": 1, "id": "3a8c1d55-77e2-4b0a-9d3c-2b6e5f8a1c04", "type": "account",
"name": "Stripe (live)",
"account": {
"provider": "stripe", "accountId": "acct_1P…", "handle": "profullstack",
"email": "billing@profullstack.com",
"accessToken": "sk_live_…", "refreshToken": "", "tokenType": "bearer",
"scopes": ["charges:write", "customers:read"],
"expiresAt": "", "environment": "production"
},
"createdAt": "2026-02-14T00:00:00.000Z",
"updatedAt": "2026-02-14T00:00:00.000Z"
}
```