Skip to content

feat: per-owner store limits and reassign, user-linked API keys, shared passkey domain, include-aware authoring tools (#731, #732, #729, #733) - #737

Merged
jimhoyd merged 7 commits into
mainfrom
claude/sleepy-shannon-xvazgl
Sep 25, 2026
Merged

jimhoyd merged 7 commits into
mainfrom
claude/sleepy-shannon-xvazgl

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Problem and change

  • Closes [Request]: per-owner record limit for owned store collections #731: per-owner record limit. Owned collections can declare maxRecordsPerOwner, from 1 up to the collection's maxRecords.
    • Where it is refused: on shared collections, at activation.
    • When it applies: it is enforced inside create, in the collection's one-at-a-time write sequence.
    • Response: 409 owner_quota_exceeded with no counts in the body. maxRecords is still the collection-wide ceiling.
    • Counting: counts are rebuilt from the data file, so they are correct after a restart and after ownerless operations. Ownerless records count toward no owner, and an idempotent replay is refused before anything is counted.
  • Closes [Request]: transfer store records owned by an API key when the key is rotated or revoked #732 (owner decision: both parts).
    • auth: issueApiKey({…, userId?}) and the CLI accept an optional userId, which must be an existing active user. A user-linked key sets the principal to that user id, so owned records belong to the user and survive key rotation. It still acts only within the key's scopes.
      • Locked user: if the user is locked or has requested deletion, their linked keys get 401. The keys work again if the account is restored.
      • Purged user: purging revokes the keys permanently.
      • Unlinked keys: keep the apikey:<id> principal.
      • Migration: additive nullable user_id column.
    • store: urlcode-store reassign --directory --project --from --to [--collection] [--dry-run] and reassignOwner().
      • Scope: owned collections only, and it takes the directory lock.
      • Per-owner limit: checked for every affected collection before anything is written, and the whole run is refused if any would exceed it.
      • What changes: only _owner.
  • Closes [Request]: passkey sign-in on operator alias origins #729 (owner decision: opt-in shared relying-party domain).
    • Setting: --passkey-rp-id <domain>, the passkeyRpId option, or URLCODE_PASSKEY_RP_ID. Operator-only, never YAML.
    • Validation:
      • a lowercase DNS name that equals, or is a parent domain of, the canonical host and every alias host;
      • not an IP or a single label, and not a listed public suffix (a short built-in list; browsers enforce the full list anyway).
    • auth behaviour: PasskeyProvider.withSite() uses the shared relying-party ID and accepts any site origin.
    • Default: unchanged, so existing passkeys keep working. The docs warn that changing the relying-party ID invalidates existing passkeys. Recording the relying-party ID per credential, for a startup warning, is follow-up auth: record each passkey's RP ID and warn at startup when the operator RP ID differs #736.
  • Closes [Request]: fixture suggestions and change summaries should follow project includes #733: authoring tools follow project includes. In project mode (urlcode fixtures suggest, urlcode diff with a directory side, and MCP without an explicit yaml), includes are resolved through loadDocument(project, {sources: true}), so the loader's own containment and limits apply. Results then carry file, movedFrom, sides and routes.unresolved (mixed mode only). The text-mode public API (@jimhoyd/urlcode/agent-context) is unchanged and still text-only.
  • Package budgets:
    • Core: raised to 720 KiB packed and 2900 KiB unpacked (703205 / 2863298 bytes measured, under 4 KiB from the old limits).
    • Store: unpacked raised to 150 KiB.
    • The rationale is recorded next to each budget.

Verification

Run on Node v26.10.0:

Compatibility and security

  • All opt-in or additive. Behaviour is unchanged unless maxRecordsPerOwner, userId, --passkey-rp-id or project mode is used.

  • Known limits:

    • Passkey behaviour was not tested with real browsers or authenticators.
    • reassign replaces files one at a time, so a disk error between collections can leave a partial move; re-running completes it. This is documented.
  • Not an independent security review.

  • Changes match the documented portable contract; docs/examples are updated where needed.

  • Relevant tests and package checks pass, or limitations are explained above.

  • No credentials, customer data or private project material are included.

  • Runtime/starter changes remain aligned where applicable.

🤖 Generated with Claude Code

https://claude.ai/code/session_014jmv9dMggduiprzSsNd7iP


Generated by Claude Code

An owned collection may declare maxRecordsPerOwner (at most its maxRecords;
refused on a shared collection). A create by a principal already holding that
many records answers 409 owner_quota_exceeded with a fixed message that states
no count, limit or collection total; maxRecords stays the collection-wide
ceiling. Per-owner counts are derived from the loaded records on activation and
after every commit, so they stay correct across restart and after
ownerless-assign/ownerless-delete; ownerless records count toward no owner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014jmv9dMggduiprzSsNd7iP
…ncludes (#733)

Project mode (urlcode fixtures suggest, urlcode diff with a directory side,
MCP suggest_fixtures without yaml and summarize_yaml_change without after)
now reads the project's YAML through loadDocument, so include resolution,
root containment and the nesting/duplicate/size rules are the loader's own.
loadDocument({sources: true}) additionally returns the file each route and
extension declaration came from. Included routes are analysed like entry
routes (no blanket include gaps or include-shadowing), and every entry names
its file.

urlcode diff takes a YAML file or a project directory on either side. Project
sides report each route's file and movedFrom for routes that moved; a mixed
comparison sets aside project-side routes from includes the text side lists
but does not read (routes.unresolved) instead of guessing.

Text mode (the agent-context SDK and MCP with supplied YAML) is unchanged:
text only, includes reported as gaps, same result shape.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014jmv9dMggduiprzSsNd7iP
… origins (#729)

Operators can set one shared WebAuthn RP ID beside --origin/--alias-origin:
--passkey-rp-id on dev/serve/validate/test/routes/audit/benchmark,
passkeyRpId on createRuntime/startServer/runProjectTests and the AWS/Vercel
handlers, or URLCODE_PASSKEY_RP_ID. Never project YAML.

Core refuses it before loading the project (ConfigError invalid-passkey-rp-id)
unless it is a lowercase ASCII DNS name, not an IP address, not a single label
(localhost only for a localhost canonical host), not in a short documented
public-suffix list (Node ships no PSL; browsers enforce the full list), and the
host or a label-boundary parent domain of the canonical and every alias origin.
Activations receive it as passkeyRpId only when set.

Auth rebinds its passkey provider with the new withSite({rpId, origins}): options
carry the shared RP ID and verification accepts any site origin. Unset, nothing
changes (canonical host, canonical origin only). Auth does not record per-
credential RP IDs, so no startup warning is possible yet (#736); docs warn that
changing the RP ID strands existing passkeys.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014jmv9dMggduiprzSsNd7iP
…rotation (#732)

issueApiKey({name, scopes, quota?, userId?}) and the api-key-issue JSON accept an
optional userId naming an existing, active account (an unknown, locked, pending-
deletion or purged user is refused with invalid_api_key_user, checked in the
insert's transaction). A user-linked key sets the request principal to that user's
id instead of apikey:<key id>, so records it creates in an owned store collection
belong to the user and survive rotating the key; it still acts only within its own
scopes, never the user's roles. The key authenticates only while its user is
active: locking the account or starting its deletion disables it on the next
request (unlocking or cancelling re-enables it), and purgeDeleted revokes a purged
account's keys. authenticateApiKey returns userId, listApiKeys/api-key-list return
userId and userDisabled, and the auth-principal context header carries userId for
a linked key. Keys without userId are unchanged; existing databases gain a nullable
auth_api_keys.user_id column (and index) in place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014jmv9dMggduiprzSsNd7iP
…ipals (#732)

urlcode-store reassign --directory <dir> --project <app> --from <principal id>
--to <principal id> [--collection <name>] [--dry-run] moves every record one
principal owns to another, for example a rotated service API key's apikey:<id>
records to its replacement. It reads the project through core's loader to find the
ownership: owner collections and their maxRecordsPerOwner (only those are
touched; --collection limits it to one, a shared or undeclared name is refused),
validates both ids with core's principalIdPattern, takes the directory lock like
the ownerless commands (so it refuses while the server runs) and prints per-
collection counts; --dry-run writes nothing. When the move would put --to over any
affected collection's maxRecordsPerOwner the whole operation is refused, naming the
collection, and no file is written. Exported as reassignOwner. The store package's
unpacked budget rises from 140 to 150 KiB for it and #731.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014jmv9dMggduiprzSsNd7iP
Comment thread test/site-origins.test.ts Fixed

jimhoyd commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator Author

Blocked: CodeQL reports 1 new high-severity alert in code changed by this PR. All other CI checks are green.

The alert's location isn't reachable from the tooling in this session: the check output only links to the code-scanning page, and annotations aren't exposed. I checked the likely causes in the diff:

  • SQL in api-key-store.ts and auth-store.ts is parameterized.
  • The new regexes (dnsName in passkeys.ts, dnsLabel in site-origins.ts) run only on operator configuration, not request data.
  • No RegExp is built from input, and no secrets are logged.

None of these is conclusive. I'm not merging until the alert is identified and fixed. Needed: the rule ID and file:line from https://github.com/jimhoyd-com/urlcode/security/code-scanning?query=pr%3A737+tool%3ACodeQL+is%3Aopen


Generated by Claude Code

)

CodeQL's incomplete-URL-substring rule read the array membership check
passkeyPublicSuffixes.includes('co.uk') as a host substring match; a Set
lookup states the intent and clears the false positive.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014jmv9dMggduiprzSsNd7iP
@jimhoyd
jimhoyd merged commit 02057fa into main Sep 25, 2026
23 checks passed
@jimhoyd
jimhoyd deleted the claude/sleepy-shannon-xvazgl branch September 25, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants