Repository navigation
Deploy the published Identity provider - #12
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 05c92859d7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| <strong>Authorization Core → its consumers.</strong> Its public <code>0.x</code> packages | ||
| now exist, and this reference application composes the Identity claims adapter with | ||
| first-party Identity and Sessions. Broader consumer migrations still determine when those | ||
| contracts are stable enough for <code>1.0</code>. |
There was a problem hiding this comment.
Compile the new roadmap facts instead of hard-coding them
These assertions about Authorization, Identity, Mail, and Rate Limit are component-status facts written directly into the roadmap, so future component-plan changes can leave this section contradicting the compiled table above it. Pull these facts from the source repositories through the roadmap compiler rather than maintaining them in page prose.
AGENTS.md reference: AGENTS.md:L28-L30
Useful? React with 👍 / 👎.
| # Token must include Workers Edit in addition to Pages Edit — see | ||
| # Token must include Workers Edit and D1 Edit in addition to Pages Edit — see | ||
| # docs/PROJECT_PLAN.md Phase 2. | ||
| - name: Apply pegma-dev-identity D1 migrations |
There was a problem hiding this comment.
Activate the backend before publishing the account UI
The checked workflow publishes Pages at lines 32–39 before this migration and the Worker deployment at lines 43–65. If either backend step fails, /account remains successfully released while the previous Worker has no identity routes, leaving the production account flow broken until a later successful run; migrate and activate the Worker before exposing the dependent Pages build, or add an equivalent rollback/gate.
Useful? React with 👍 / 👎.
| cloudflare: true, | ||
| datadog: Boolean(env.DATADOG_API_KEY), | ||
| }), | ||
| createDetailCheck('identity', { |
There was a problem hiding this comment.
Make the identity health check exercise identity readiness
When the email-code secret is absent or invalid, or D1 is unavailable, /api/identity/* returns 503, but /api/health reaches this static createDetailCheck before constructing the runtime and still reports the identity check as healthy with HTTP 200. This prevents health monitoring from detecting a completely unavailable account service; validate runtime/storage readiness in this check or avoid reporting it as an identity health check.
Useful? React with 👍 / 👎.
| ## Endpoints | ||
|
|
||
| - `GET /` or `GET /health` — JSON from `@pegma/health` | ||
| - `GET /`, `GET /health`, or `GET /api/health` — JSON from `@pegma/health` |
There was a problem hiding this comment.
Restrict documented health URLs to the routed endpoint
With workers_dev and preview URLs disabled and the sole production route set to pegma.dev/api/*, only /api/health reaches this Worker: / is the Pages homepage and /health is also served by Pages rather than returning the documented JSON. Operators following this endpoint list therefore receive HTML or a Pages 404, so document only /api/health or add explicit Worker routes for the other paths.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
This PR turns the repository’s existing Cloudflare Worker (“pegma-dev-api”) into a first-party Identity reference consumer for pegma.dev, wiring the published Pegma Identity/Sessions/Mail/Rate Limit/Storage packages behind a same-origin /api/identity/* boundary, plus adding the static /account shell and CI/deploy updates to support production rollout.
Changes:
- Compose and expose a production Identity runtime + HTTP API boundary in the Worker, including scheduled maintenance lanes and a Resend mail adapter (kept fail-closed unless explicitly enabled).
- Add the
/accountpage + client script and update site copy/registry/roadmap to reflect published component status. - Split PR CI from main-only deploy; add Worker typechecking/tests to the build gate and apply D1 migrations in deploy.
Reviewed changes
Copilot reviewed 27 out of 30 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| worker/wrangler.jsonc | Configure production routing, D1 binding, cron trigger, and Identity vars for the Worker. |
| worker/tsconfig.json | Add Worker-specific TS config and include wrangler-generated types. |
| worker/src/resend-mail.ts | Implement Resend provider adapter + renderer + failure classification for @pegma/mail/Identity MailWorker. |
| worker/src/resend-mail.test.ts | Unit tests for Resend adapter behavior, rendering, and failure classification. |
| worker/src/index.ts | Route /api/identity/*, extend health details, and run scheduled Identity maintenance. |
| worker/src/identity-runtime.ts | Compose exact published Identity + Sessions + rate limits + D1 store + mail worker. |
| worker/src/identity-runtime.test.ts | Validate composition works end-to-end with MemoryStore and MailWorker scheduling behavior. |
| worker/src/identity-maintenance.ts | Implement cron-driven cursor-persisted hygiene lanes (Identity sweeps, mail lanes, sessions, limiters). |
| worker/src/identity-maintenance.test.ts | Verify cursor persistence and lane isolation behavior under failures. |
| worker/src/identity-contracts.ts | Define narrow “published surface” ports consumed by the HTTP boundary. |
| worker/src/identity-api.ts | Implement same-origin, no-store account API with CSRF/session protections and flow gating. |
| worker/src/identity-api.test.ts | Extensive boundary/security tests for sessions, CSRF, composition fail-closed behavior, and request limits. |
| worker/README.md | Document the Worker’s Identity composition, operational gates, and endpoint surface. |
| worker/migrations/0001_pegma_storage.sql | Add initial D1 schema required by the storage adapter. |
| tsconfig.json | Remove Worker sources/types from the site TS config; Worker is typechecked via its own project. |
| src/styles/global.css | Add account page styling and minor formatting tweaks. |
| src/pages/roadmap.astro | Update roadmap narrative to reflect the now-published components and Cloudflare consumer. |
| src/pages/account.astro | Add static /account shell that talks to same-origin /api/identity/*. |
| src/layouts/Base.astro | Add “Account” to global navigation. |
| src/data/components.ts | Update component registry statuses/packages to published versions and add D1 adapter + authorization-identity. |
| README.md | Update repository overview to reflect the Worker’s current Identity consumer role. |
| public/llms.txt | Update LLM-facing package/status listing and add Account page description. |
| public/account.js | Add browser client for passkey flows, email-code flows, session/CSRF handling, and account UI. |
| public/_headers | Update CSP/Permissions-Policy for account/WebAuthn support (currently applied site-wide). |
| package.json | Add check (including Worker tsc) and test scripts; pin/introduce Pegma dependencies; add vitest. |
| docs/PROJECT_PLAN.md | Update plan to mark Phase 4 in progress and document Identity consumer gates. |
| .github/workflows/deploy.yml | Main-only deploy: run check/test/build; apply D1 migrations; deploy Pages + Worker. |
| .github/workflows/ci.yml | New PR-only workflow to run check/test/build without production credentials. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Content-Security-Policy: default-src 'self'; connect-src 'self'; img-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none' | ||
| Permissions-Policy: camera=(), microphone=(), geolocation=(), publickey-credentials-create=(self), publickey-credentials-get=(self) |
| async function saveCursor( | ||
| store: Store, | ||
| name: CursorName, | ||
| next: string | null, | ||
| ): Promise<void> { | ||
| await store.collection(maintenance).update(KEY, (current) => ({ | ||
| action: 'write', | ||
| value: { | ||
| ...(current ?? emptyRecord()), | ||
| partition: KEY.partition, | ||
| id: KEY.id, | ||
| [name]: next, | ||
| }, | ||
| })); | ||
| } |
Summary
@pegma/identity@0.1.0with@pegma/authorization-identity@0.1.2,@pegma/sessions@0.1.0, durable rate limits, Mail, and the Cloudflare D1 adapterEmail delivery remains explicitly disabled (
IDENTITY_EMAIL_ENABLED=false) until the sender domain, provider credential, audited operator acknowledgement workflow, and end-to-end delivery smoke test are complete. The stable Identity HMAC secret is already installed in Cloudflare's managed secret store.Verification
npm ci,npm run check, 38/38 tests, static buildnpm run check, 38/38 tests, static buildnpm audit --audit-level=high: 0 vulnerabilities