Repository navigation
Retire the legacy auth; add the pgstencil CLI, billing security rules and email options - #100
Merged
Merged
Conversation
…ledger
synchronize read one page of 100 subscriptions and threw when Stripe
reported more, so an owner past 100 subscriptions, ended ones included,
failed every reconciliation and webhook. It now reads every page under
the same owner lock.
pruneEvents({ olderThanDays }) deletes processed ledger events older than
30 to 3650 days for a scheduled job. Unprocessed and failed events are
always kept.
StripeDev's subscription list honours limit and starting_after and
reports has_more. billing.test.ts takes its schema from the billing
package's own migrations rather than the login example.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
The email-code message was composed inline with a hard-coded [email protected] sender. createAuthApp and createBetterAuthWorker now take emailFrom and renderEmail; the default sender is signin@ the origin's hostname, and defaultSignInEmail is exported. A rendered message must be addressed to the requested recipient alone, or nothing is sent. Core pgstencil exports escapeHtml for values placed in an email's HTML. postmarkEmail reports Postmark's numeric ErrorCode on HTTP errors too. The Better Auth test takes its deterministic bundle from a shared support module. Co-Authored-By: Claude Fable 5.2 <[email protected]>
@pgstencil/auth is now only the Better Auth integration. The original implementation is removed: its source modules and subpath exports, the package's migrations directory, the openid-client dependency, and the examples/login and examples/workers applications with their tests and snapshots. The package root re-exports the Better Auth module. examples/better-auth is the one example. It gains billing routes behind its sign-in, the persistent dev entry with the local inbox and StripeDev, and the deployable Workers entry. The infrastructure tests (database, parallel, query types) run on a small fixture schema and fixture app of their own instead of auth tables. The pgstencil command in the core package replaces the private scripts/db.ts: status, validate, migrate, create, schema, types, verify, reset, gc and stop, configured by pgstencil.json (migrations, schema, types). kysely-codegen becomes an optional tooling peer. defaultMigrations is now always a list, and pgstencil.json is validated strictly. The billing schema's Kysely declarations are generated to packages/stripe/src/db.generated.ts, and the hand-written BillingDB is compared with them column by column at typecheck. CHANGELOG.md, added with the docs later in this branch, says how an application adapts. Co-Authored-By: Claude Fable 5.2 <[email protected]>
SECURITY.md stated rules only for the Better Auth integration and core. It now carries FAIL IF rules for Stripe webhooks, checkout and entitlement, each pinned by a test, with what the application owns for billing and what is not defended. billing-security.test.ts adds the pinning tests that did not exist yet. The auditor's scope and commands include the stripe package and the billing suites, and name the auth suites directly now that the test:better-auth script is gone. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Node was named in three places that disagreed: engines and .nvmrc said 24, while every workflow ran 26, so the declared minimum was never tested. The root package.json now pins 24.22.2 in devEngines.runtime with onFail: download: pnpm fetches that version and runs every script with it, and check, release and security-audit read the same pin through node-version-file. .nvmrc is removed. check.yml pins its actions to commits like the other two workflows and builds the Workers entry from the Better Auth example. The audit job's timeout rises from 40 to 50 minutes now that billing is in its scope, staying under the 55 minutes release.yml waits for its verdict. Co-Authored-By: Claude Fable 5.2 <[email protected]>
README, PACKAGES, BILLING and WORKERS are rewritten around the single Better Auth example, the pgstencil command and the new options, with hand-typed version numbers removed. CHANGELOG.md records the unreleased breaking changes and how an application adapts to each. AGENTS.md gains working notes for the repository. PLAN.md and DISTRIBUTION_AND_BILLING_PLAN.md described finished work, and LOGIN_FLOW.md and OAUTH.md the removed implementation; all four are deleted. Provider registration notes that still apply moved to the example's README. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Keeps this branch's root manifest and takes main's Miniflare 5.20261104.0-beta and Renovate grouping; the lockfile is regenerated from the merged manifests. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes the original code/link authentication, leaving
@pgstencil/authas the Better Auth integration only, and makes the changes that depended on that. These are breaking, so they should release as 0.5.0. This PR does not raise the version, so merging it does not stage a release.CHANGELOG.md lists every breaking change with how an application adapts.
What changes
migrations/directory,openid-client, and theexamples/loginandexamples/workersapplications are gone, with their tests and snapshots. The package root now re-exports the Better Auth module.examples/better-authgains billing routes behind its sign-in, thepnpm deventry with the local inbox and StripeDev, and the deployable Workers entry.pgstencilcommand. The core package ships the database commands thatscripts/db.tsran privately, configured bypgstencil.json.kysely-codegenis a new optional tooling peer.defaultMigrationsis now always a list.emailFromandrenderEmailoncreateAuthAppandcreateBetterAuthWorker; the default sender issignin@<origin hostname>instead of[email protected]. Core exportsescapeHtml.Billing.pruneEvents({ olderThanDays })trims the webhook ledger.BillingDBis compared with generated declarations at typecheck.SECURITY.mdgainsFAIL IFrules for Stripe webhooks, checkout and entitlement, each pinned by a test, and the release-gating audit's scope now includes the stripe package. Its timeout rises from 40 to 50 minutes.devEngines.runtime; pnpm and all three workflows read it. CI ran only Node 26 before, so the declared minimum of 24 was untested..nvmrcis removed.PLAN.md,DISTRIBUTION_AND_BILLING_PLAN.md,LOGIN_FLOW.mdandOAUTH.mdare deleted.CHANGELOG.mdandAGENTS.mdare new.Verification
Run locally on the branch tip, under Node 24.22.2:
pnpm check(formatting, typecheck, script tests, 178 Vitest tests): passpnpm db:verify: passpnpm --filter @pgstencil/example-better-auth build: passpnpm packages:verify, including the provenance check and the CLI run from the packed tarball: passOnly the tip was run. The six commits are grouped by theme and were not each checked on their own.
For the reviewer
001_auth.sql,002_oauth.sqland004_oauth_workers.sqlas a source of its own, byte for byte, because the package no longer ships them and applied SQL stays under checksum validation.mainis worth watching against the new 50-minute limit.gitleaksis not installed where this was prepared, so.gitleaksignorewas not rechecked. The rewritten billing HTTP test still contains a local test secret and may need a new fingerprint.email.delivery.faileddiagnostic is recorded. This predates the PR and is now documented.🤖 Generated with Claude Code