pgstencil ships pgstencil, @pgstencil/auth and @pgstencil/stripe as packed tarballs (PACKAGES.md). This file states what the Better Auth integration in @pgstencil/auth, the Billing class in @pgstencil/stripe, and pgstencil itself guarantee to a consuming application, as conditions an auditor can check at one commit; each section ends with the tests that pin them. Bare names are under packages/auth/src/, packages/auth/better-auth-migrations/, packages/stripe/migrations/ or tests/; in the billing sections a bare method or constant is a member of Billing, or an export, in packages/stripe/src/index.ts.
The application owns everything outside the packages: TLS and its origin gate, the CSP of its own pages, secret and credential storage, database provisioning, provider registration, and — only when it opts in with ipAddressHeaders — a proxy that overwrites those headers on every request. For billing it also owns: authenticating the owner before every Billing call that takes an owner ID, and never taking that ID, a customer, Price, quantity or URL from the browser; CSRF and exact-origin checks on its billing routes; handing each webhook's raw body and Stripe-Signature header to webhook or verifyWebhook unaltered, under a body limit, and answering 2xx only after webhook resolves; storing the Stripe secret key and the webhook signing secret; and the Stripe account itself — its Prices, a customer portal that offers no Price outside prices, no quantity change and no second subscription, and a webhook endpoint created at STRIPE_API_VERSION. The example in examples/better-auth/ shows one way to do this, exercised by integration/billing-http.test.ts.
- FAIL IF an HTTPS deployment's auth cookies lack
__Host-,Secure,HttpOnly,Path=/orSameSite=Lax, or carryDomain; inspectbetter-auth.tsandbetter-auth-security.ts. - FAIL IF a session token, a provider access/refresh/ID token or the internal
singleSession/emailAuthenticatedfields reach browser JSON, a stored sessiontokenauthenticates without the server's cookie signature, or a bearer or API-key plugin is enabled; inspectpublicAuthResponseandplugins. - FAIL IF sessions outlive 24 hours, refresh on use, come from a cookie cache instead of the database, or session creation stops being serialized per user; inspect
sessioninbetter-auth.tsand002_security_policy.sql. - FAIL IF
sessionPolicy: 'single'leaves another device signed in,'multiple'(the default) revokes one, or sign-out revokes another session; inspectdatabaseHooks.session. - FAIL IF the readable
rememberLoginMethodcookie grants authority, records a failed attempt or an explicit link, or is written to the database; inspectlastLoginMethodinbetter-auth.ts. - FAIL IF an application hook receives anything but the login method, runs before its write commits, fires for an explicit link or a failed attempt, or can fail or delay the auth response by throwing, rejecting or never settling; inspect
runHook,loginMethodanddatabaseHooksinbetter-auth.ts, andhooksinbetter-auth-workers.ts.
Pinned by integration/better-auth.test.ts: email policy: secret-keyed codes, cross-browser redemption, concurrent single use and no token exposure, Better Auth time: 23 hours, expiration boundary, isolated async contexts and unchanged host clock, session policy: single, session policy: multiple; integration/better-auth-oauth.test.ts: Last login method remembers only successful sign-ins and survives logout, Auth hooks see each sign-up and login after it commits, and never a link or a failure,