Skip to content

feat(issuance): optional validUntil on manual and programmatic issuance - #6

Merged
ottenhoff merged 4 commits into
LongsightGroup:mainfrom
DiegoDAF:pr/valid-until
Oct 7, 2026
Merged

ottenhoff merged 4 commits into
LongsightGroup:mainfrom
DiegoDAF:pr/valid-until

Conversation

@DiegoDAF

@DiegoDAF DiegoDAF commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Badges issued by a renewable rule already carry an expiry (validUntil in the credential, assertions.valid_until, the expired lifecycle state), but a badge issued by hand or through the programmatic API could not be given one — event badges, one-year memberships and the like.

This adds an optional validUntil (ISO 8601 timestamp) to the issue request and threads it through every issuance entry point:

  • Manual JSON API (POST /v1/tenants/:tenantId/assertions/manual-issue): validUntil in the body.
  • Admin issue form: a "Valid until (optional)" date field; the credential expires at the end of that day (UTC). Invalid or past dates are echoed back with the usual validation feedback.
  • Programmatic API (POST /v1/programmatic/issue): validUntil in the body, carried in the queued issue_badge job payload.

Behaviour:

  • Issuance rejects an expiry that is not later than the issue date with 422 Valid until must be later than the issue date.
  • A renewable rule keeps its own validity cycle and ignores the field.
  • The issuance email lists "Valid until" when the credential has one.
  • Credentials issued without the field keep not expiring, as before. No schema migration: assertions.valid_until already exists (0087).

Second commit: the expiry is also visible wherever the credential is presented — the public badge page shows "Valid until" under the issue date, the PDF lists it in the record block (next to the identifiers, where a revocation is shown), and the Add to LinkedIn profile link sends expirationYear/expirationMonth so the certification's expiration date is prefilled.

Third commit: the issuance email now carries the same Add to LinkedIn link as the public badge page (tenant's LinkedIn organization when configured, otherwise the issuer name; the credential identifier the page uses; issue date and, when present, expiration date), so people can add the certification straight from the notification.

Tests

  • credentials.test.ts: validUntil accepted on manual and programmatic requests; non-ISO values rejected.
  • manual-issue.test.ts: the issued credential and the stored assertion carry validUntil; a past expiry is rejected with 422 and nothing is issued.
  • queue-ingress-programmatic.test.ts: the queued payload carries validUntil.
  • manual-issue-section.test.tsx: the form offers the date field and echoes it back on validation feedback.
  • tenant-operations-admin-routes.test.ts: the calendar-date → end-of-day UTC conversion and its rejections.
  • send-issuance-email.test.ts: the expiry shows up in the email.
  • display-format.test.ts: LinkedIn link carries the expiration date, and omits it without one.
  • public-badge-page.test.ts: the page shows "Valid until" and the profile share link carries the expiration.
  • send-issuance-email.test.ts: the email offers Add to LinkedIn with issuer, credential and dates, and the organization ID when configured.

Full suite, oxfmt --check, oxlint --deny-warnings and tsc --noEmit pass.

Context

Follow-up to #2: we run CredTrail self-hosted for community events and needed event badges that expire.

DiegoDAF and others added 4 commits October 7, 2026 10:18
Badges issued by a renewable rule already expire (validUntil in the
credential, assertions.valid_until, lifecycle expired), but there was no
way to give an expiry to a badge issued by hand or through the
programmatic API: event badges, memberships for a year, and the like.

The issue request now takes an optional validUntil (ISO timestamp). It
flows through the manual JSON API, the admin issue form (as a calendar
date, expiring at the end of that day in UTC) and the programmatic API,
including the queued job payload. Issuance rejects an expiry that is not
later than the issue date (422). A renewable rule keeps its own cycle
and ignores the field. The issuance email shows the expiry when there
is one.

Credentials issued without the field keep expiring never, as before.
…and the LinkedIn link

A credential with validUntil was issued with the date in the signed
document and in the assertion, but nothing visible carried it: the
public badge page only said when it was issued, the PDF had no expiry
field, and the Add to LinkedIn link left LinkedIn's expiration date
empty for the person to type.

The public page now shows "Valid until" under the issue date, the PDF
record block lists it next to the credential identifiers (the same spot
that shows a revocation), and the LinkedIn profile link sends
expirationYear/expirationMonth. Credentials without an expiry render
exactly as before.
The public badge page offers "Add to LinkedIn Profile", but the email
that tells someone they earned a badge did not: they had to open the
page first and find the button. The issuance email now carries the same
link as a secondary action, built the same way as on the page: the
tenant's LinkedIn organization when one is configured (otherwise the
issuer name), the credential identifier the page uses, the issue date
and, when the credential has one, the expiration date.

Direct issuance and the admin retry read the tenant's LinkedIn setting
next to the tenant itself.
Reuse the tracked public LinkedIn sharing route and include expiry in queue replay identity. Reject expired commands before enqueueing, terminate delayed expiry failures without retries, and preserve saved admin receipts after expiry.

Measure PDF record fields and grow the page to keep expiry and revocation details visible. Add boundary and Postgres regression coverage and regenerate the programmatic API contract.

Validation: lint, formatting, strict TypeScript, and all 2,124 tests passed with UTC Postgres sessions.
@ottenhoff
ottenhoff merged commit 59c5d17 into LongsightGroup:main Oct 7, 2026
4 checks passed
@DiegoDAF
DiegoDAF deleted the pr/valid-until branch October 7, 2026 18:48
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.

2 participants