Skip to content

feat(fields): add a token field, and use it for the Sync token - #41

Merged
xiaodoudou merged 4 commits into
devfrom
feat/token-field
Oct 11, 2026
Merged

xiaodoudou merged 4 commits into
devfrom
feat/token-field

Conversation

@xiaodoudou

Copy link
Copy Markdown
Owner

A new field type, input: 'token', holds a key, a secret or an id that two systems share. You can type it, paste it, or click Generate to make a random one. The Copy button appears once the field has a value. Options set the number of random bytes (8 to 128, 32 by default), a prefix such as key_, and the format (base64url or hex). With autoGenerate, a new record gets a token by itself: the form fills the field when it opens, and the server fills it for a record created over the API without one. An update never makes a new token.

The local token of the Sync settings now uses this field, with the prefix sync_, so a node's token can be generated and copied from the form instead of being made up by hand. The remote token stays a plain text field, because it is pasted from the other node.

The catalogue has two examples in resources/text_formats.js: apiKey (prefix, typed or generated) and hexToken (8 bytes in hex, filled on creation). docs/reference/fields/token.md describes the field and has three screenshots taken with npm run docs:screenshots -- --only ^token, and FIELDS.md lists it, which brings the count of input types to 36.

New tests cover the token options and generation on both sides, the server filling on create, and the component (typing and pasting, Generate, Copy, auto-fill for a new record only, read-only). Frontend suite: 123 files, 2869 tests pass, and ESLint is clean. Backend suite: 1895 tests pass. Three fail on Windows for reasons that have nothing to do with the branch: the admin start-up test expects a 503 while a dev server was answering on its port, and two tests can't remove their temp folders in cleanup (EBUSY, cms command options and CMS class). The backend suite was not run on Linux here.

input: 'token' holds a key or an id another system uses. A new record gets one as its form opens, and the server makes one for a record created over the API without it. The field is read-only, with Copy and Regenerate, and options.length, options.prefix and options.format shape the token. The docs count of input types was out of date and now says 36.
…c token

The token field was read-only and filled itself. It is now a text field with Generate and Copy buttons: a token is typed, pasted, or made at random. options.autoGenerate gives a new record one by itself, in the admin and over the API; it is off by default. The Token under This CMS in the Sync settings is a token field, so its secret no longer has to be invented by hand; the token of the other CMS stays a text field, where it is pasted.
@xiaodoudou
xiaodoudou merged commit 359297f into dev Oct 11, 2026
3 checks passed
xiaodoudou added a commit that referenced this pull request Oct 12, 2026
feat(fields): add a token field, and use it for the Sync token
@xiaodoudou
xiaodoudou deleted the feat/token-field branch October 12, 2026 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant