Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
539 changes: 539 additions & 0 deletions packages/api-client/src/schema.d.ts

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions packages/api/.dev.vars.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ POSTMARK_SERVER_TOKEN=
# Must be verified in Postmark (plain email address).
POSTMARK_FROM_EMAIL=
POSTMARK_MESSAGE_STREAM=outbound

# Optional Google OAuth web client for Factorize sign-in (separate from MCP OAuth).
# Register <APP_ORIGIN>/oauth/google/sign-in/callback with Google.
GOOGLE_SIGN_IN_CLIENT_ID=
GOOGLE_SIGN_IN_CLIENT_SECRET=
31 changes: 31 additions & 0 deletions packages/api/migrations/0104_google_sign_in.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
CREATE TABLE app.google_sign_in_attempts (
id uuid PRIMARY KEY,
browser_digest text NOT NULL UNIQUE,
verifier text,
nonce text NOT NULL,
return_to text NOT NULL,
connection_id uuid REFERENCES app.oauth_connections(id) ON DELETE CASCADE,
google_subject text,
email text,
existing_user_id uuid REFERENCES app.auth_users(id) ON DELETE CASCADE,
email_confirmed boolean NOT NULL DEFAULT false,
email_token_digest text,
email_sent_at timestamptz,
password_attempts integer NOT NULL DEFAULT 0,
expires_at timestamptz NOT NULL
);
CREATE INDEX google_sign_in_attempts_expiry ON app.google_sign_in_attempts(expires_at);
CREATE UNIQUE INDEX auth_accounts_google_user_unique ON app.auth_accounts(user_id) WHERE provider='google';

ALTER TABLE app.auth_users
ADD COLUMN google_recovery_managed boolean NOT NULL DEFAULT false,
ADD COLUMN google_recovery_candidate text,
ADD COLUMN google_recovery_address_confirmed boolean NOT NULL DEFAULT false,
ADD COLUMN google_recovery_suspended boolean NOT NULL DEFAULT false,
ADD COLUMN google_recovery_observed_at integer NOT NULL DEFAULT 0,
ADD COLUMN google_recovery_revision integer NOT NULL DEFAULT 0;
ALTER TABLE app.google_sign_in_attempts
ADD COLUMN password_user_id uuid REFERENCES app.auth_users(id) ON DELETE CASCADE,
ADD COLUMN recovery_revision integer,
ADD COLUMN provider_observed_at integer NOT NULL DEFAULT 0,
ADD COLUMN provider_managed_email boolean NOT NULL DEFAULT false;
11 changes: 10 additions & 1 deletion packages/api/src/api-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {

import { X_OAUTH_SCOPES } from "./x-oauth";
import document from "./api-document.json";
import { authInputs, authSuccess, continuationSuccess, connectionStartInput, connectionStartSuccess, connectionResumeInput, loginSuccess, sessionResponse, type AuthAction } from "./auth-api";
import { authInputs, authSuccess, continuationSuccess, connectionStartInput, connectionStartSuccess, connectionResumeInput, loginSuccess, sessionResponse, googleAvailability, googleStartResult, googlePendingResult, googleUsernameResult, type AuthAction } from "./auth-api";
import { flyConnectionInput, flyConnectionMetadata } from "./fly-account-client";
import { eventDefinitionInput, eventDefinitionUpdate, eventDefinitionResponse, eventDefinitionList, eventOccurrenceQuery, eventOccurrencePage } from "./event-contracts";
import { vmGrantInput, vmGrantList, vmGrantRef, vmGrantResult, vmRevokeResult } from "./vm-grant-contracts";
Expand Down Expand Up @@ -232,6 +232,15 @@ export const API_ROUTES: RouteContract[] = [
{...authRoute("GET", "/api/v1/profile", "profile", "Read your profile; interactive owner browser session required", profileResponse),ownerSession:true},
{...authRoute("PUT", "/api/v1/profile", "profile-update", "Change your globally unique username; interactive owner browser session required", profileResponse, profileInput),ownerSession:true},
authRoute("GET", "/api/v1/session", "session", "Get current browser session", sessionResponse),
authRoute("GET", "/api/v1/auth/google", "google-available", "Check whether Google sign-in is configured", googleAvailability),
authRoute("POST", "/api/v1/auth/google/start", "google-start", "Start browser-bound Google sign-in", googleStartResult, authInputs.googleStart),
authRoute("GET", "/api/v1/auth/google/pending", "google-pending", "Read Google signup or linking steps for the current browser", googlePendingResult),
authRoute("POST", "/api/v1/auth/google/email/request", "google-email-request", "Send a verification link for a new Google signup", authSuccess),
authRoute("POST", "/api/v1/auth/google/email/verify", "google-email-verify", "Verify the signup email in the initiating browser", authSuccess, authInputs.verify),
authRoute("POST", "/api/v1/auth/google/username", "google-username", "Check username availability during Google signup", googleUsernameResult, authInputs.googleUsername),
authRoute("POST", "/api/v1/auth/google/password/complete", "google-password-complete", "Set the Factorize password with fresh Google proof and email confirmation", loginSuccess, authInputs.reset),
authRoute("POST", "/api/v1/auth/google/finish", "google-finish", "Choose a username or confirm your existing Factorize password", loginSuccess, authInputs.googleFinish),
{...authRoute("POST", "/api/v1/auth/password/set-request", "password-set-request", "Start fresh Google verification before setting or recovering a password", googleStartResult),ownerSession:true},
authRoute("POST", "/api/v1/auth/login", "login", "Sign in", loginSuccess, authInputs.login),
authRoute("POST", "/api/v1/auth/signup", "signup", "Request signup; existing accounts return the same accepted response", authSuccess, authInputs.signup, 202),
authRoute("POST", "/api/v1/auth/email-verification/request", "verification-request", "Request email verification", authSuccess, authInputs.request),
Expand Down
Loading
Loading