Functional Weave
Code in TypeScript

Suites · saas-starter

SaaS app starter: sign-in, payments, email and uploads

The I/O a new web app needs first, each behind one interface with a real provider and a development stand-in: OAuth/OIDC sign-in with sessions, Stripe checkout and webhooks, transactional email, and signed upload URLs.

14 capabilities (4 core, 10 optional) and 6 gaps, in build order. Put each line in the file that calls it, then fune build.

These are integrations: they do I/O and read secrets from the environment. Set the variables `fune secrets` lists (never commit their values), and send one real request through each provider from a staging environment before going live.

Core coverage: 40%

4 of 10 needs met by verified capabilities. The needs are this suite's 4 core members and its 6 named gaps; a core member counts when a version of it is verified (by the sandbox, or the registry's seed) and not yanked, and a gap never counts. Optional members are not needs.

Baseline: a hand-written app with no suite meets 0 of the same 10. Method fune-coverage/1, computed 2026-11-22T20:50:30.016Z.

1. Sign-in

Sign people in with an identity provider and keep them signed in.

auth.oauth-sign-in core
OAuth 2.0 / OpenID Connect with PKCE (Google, Microsoft, Auth0, any OIDC issuer, or GitHub), and a signed session cookie.
Sign users in with OpenID Connect or GitHub (authorisation code + PKCE), and keep them in a signed session cookie.
import { beginSignIn, completeSignIn, createSession, readSession, sessionCookie } from "#fune/auth.oauth-sign-in@^1";
auth.normalise-email optional
Normalises the email a provider returns, so one address is one account.
Trim an email address and lower-case its domain for storage and lookup, or null if it is not a plausible address.
import { normaliseEmail } from "#fune/auth.normalise-email@^1";
auth.account-link optional
Decides whether a provider sign-in signs in, links to an existing account by verified email, or creates one.
Decide whether an OAuth sign-in signs in, links to an existing account by verified email, creates one, or is refused.
import { decideAccountLink } from "#fune/auth.account-link@^1";
auth.email-token optional
Hashed single-use tokens for email verification and magic-link sign-in.
Hashed single-use tokens for email verification, password reset and magic links, with expiry, as pure steps.
import { generateEmailToken, hashEmailToken, checkEmailToken, consumeEmailToken } from "#fune/auth.email-token@^1";
auth.rbac optional
Roles with inheritance, wildcard permissions and ownership checks, with generated access tests.
Roles with inheritance, permission checks with wildcards and ownership, and a generated per-role access-test matrix.
import { resolveRoles, hasPermission, checkAccess, accessMatrix } from "#fune/auth.rbac@^1";
  • users-table The users table and the table of linked provider identities are yours.

2. Payments

Take a payment or start a subscription, and learn reliably that it succeeded.

payments.stripe-checkout core
Creates a Stripe Checkout session and verifies Stripe's webhook signatures; a local provider stands in during development.
Start a Stripe Checkout session and verify Stripe's signed webhooks, with a local stand-in for development.
import { createCheckoutSession, verifyWebhook, signWebhook } from "#fune/payments.stripe-checkout@^1";
payments.stripe-portal optional
Sends a customer to Stripe's portal to change plan, update a card or cancel; a local provider stands in during development.
Open Stripe's customer portal so a customer manages plan, card and invoices, with a local stand-in.
import { createPortalSession } from "#fune/payments.stripe-portal@^1";
subscriptions.stripe-state optional
Folds Stripe's subscription and invoice webhooks into one subscription state, idempotently and in order.
Folds Stripe's subscription and invoice webhook events into one normalised subscription state, in any order.
import { applyStripeEvent } from "#fune/subscriptions.stripe-state@^1";
subscriptions.proration optional
Prorates a mid-cycle plan change, when you price upgrades yourself.
Mid-cycle plan change: credit for unused time on the old plan and charge for the rest of the period on the new one.
import { prorateChange } from "#fune/subscriptions.proration@^1";
  • fulfilment Storing the state per customer and fulfilling one-off orders from the webhook event are yours.

3. Email

Send transactional email: welcome, verification, reset, receipts.

email.send core
Sends one email through Resend, any SMTP server, or the log in development.
Send a transactional email through Resend, any SMTP server or the log, behind one call.
import { sendEmail } from "#fune/email.send@^1";
validation.email optional
Checks an address's syntax before you send to it.
Is this a plausible email address? A documented, pragmatic subset of RFC 5322, not the full grammar.
import { isEmail } from "#fune/validation.email@^1";
  • email-templates The emails' wording, HTML templates and their translations.

4. File uploads

Let browsers upload and download files straight to object storage.

storage.signed-url core
Signed PUT and GET URLs for S3 (or R2, MinIO) and Google Cloud Storage, so files never pass through your server.
Signed URLs for a browser to upload a file straight to S3 or Google Cloud Storage, and to download it.
import { signUpload, signDownload } from "#fune/storage.signed-url@^1";
form.file-check optional
Checks a file's type and size in the browser and again before signing its upload URL.
Check files chosen in an upload field: accept types, size, empty files and how many, with GOV.UK messages.
import { validateFiles, acceptsFile, formatFileSize } from "#fune/form.file-check@^1";
react.form.file-upload optional
The accessible file upload field that hands its files to the signed URL (React).
A labelled file upload field: accept, size and how-many checked by form.file-check, the chosen files listed with errors.
import { FileUpload } from "#fune/react.form.file-upload@^1";
  • upload-scanning Virus scanning, image resizing and checking what was uploaded are yours.

Gaps

What this kind of app usually needs that Functional Weave does not have yet: write these yourself, or use a service.

  • background-jobs Retries and queues for slow I/O (sending email after the response, webhook processing) are your platform's.
  • rate-limiting Rate limiting sign-in and checkout endpoints by IP across instances needs a shared store.