Skip to content
Merged
74 changes: 42 additions & 32 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,49 +1,59 @@
name: ci
name: CI

on:
push:
branches:
- master
paths:
- ".github/workflows/**"
- "configs/**"
- "packages/**"
- "pnpm-lock.yaml"
pull_request:
branches:
- master
paths:
- ".github/workflows/**"
- "configs/**"
- "packages/**"
- "pnpm-lock.yaml"
workflow_dispatch:

concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}

jobs:
type-check:
name: Type Check
node:
name: Node.js
runs-on: ubuntu-latest
timeout-minutes: 25

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "24.x"
- uses: pnpm/action-setup@v4
- run: pnpm install --frozen-lockfile
- run: pnpm build --filter="./packages/*"

- run: pnpm type-check
- name: Set up pnpm
uses: pnpm/action-setup@v4

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/setup-node@v6
with:
node-version: "24.x"
- uses: pnpm/action-setup@v4
- run: pnpm install --frozen-lockfile
- run: pnpm build --filter="./packages/*"
- run: pnpm test

build:
name: Build
runs-on: ubuntu-latest
needs: [type-check, test]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "24.x"
- uses: pnpm/action-setup@v4
- run: pnpm install --frozen-lockfile
- run: pnpm build --filter="./packages/*"
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build packages
run: pnpm build:prod

- name: Run type checks
run: pnpm type-check

- name: Run tests
run: pnpm test
4 changes: 2 additions & 2 deletions apps/astro/src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createAuth } from "@aura-stack/auth"
import { createAuth, type AuthInstance } from "@aura-stack/auth"
import { builtInOAuthProviders, type BuiltInOAuthProvider } from "@aura-stack/auth/oauth/index"

export const oauth = Object.keys(builtInOAuthProviders) as BuiltInOAuthProvider[]

export const { handlers, jose } = createAuth({
export const { handlers, jose }: AuthInstance = createAuth({
oauth,
basePath: "/api/auth",
trustedOrigins: ["https://*.vercel.app"],
Expand Down
4 changes: 2 additions & 2 deletions apps/bun/src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type AuthInstance, createAuth } from "@aura-stack/auth"

export const { handlers, jose } = createAuth({
export const { handlers, jose }: AuthInstance = createAuth({
oauth: ["github"],
basePath: "/api/auth",
trustedOrigins: ["http://localhost:3000", "https://*.vercel.app"],
}) as AuthInstance
})
4 changes: 2 additions & 2 deletions apps/cloudflare/src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type AuthInstance, createAuth } from "@aura-stack/auth"

export const { handlers, jose } = createAuth({
export const { handlers, jose }: AuthInstance = createAuth({
oauth: ["github"],
basePath: "/api/auth",
trustedOrigins: ["http://127.0.0.1:8787", "http://localhost:8787"],
}) as AuthInstance
})
4 changes: 2 additions & 2 deletions apps/deno/src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type AuthInstance, createAuth } from "@aura-stack/auth"

export const { handlers, jose } = createAuth({
export const { handlers, jose }: AuthInstance = createAuth({
oauth: ["github"],
basePath: "/api/auth",
trustedOrigins: ["http://localhost:3000", "https://*.vercel.app"],
}) as AuthInstance
})
4 changes: 2 additions & 2 deletions apps/elysia/src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type AuthInstance, createAuth } from "@aura-stack/auth"

export const { handlers, jose } = createAuth({
export const { handlers, jose }: AuthInstance = createAuth({
oauth: ["github"],
basePath: "/api/auth",
trustedOrigins: ["http://localhost:3000", "https://*.vercel.app"],
}) as AuthInstance
})
4 changes: 2 additions & 2 deletions apps/express/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { builtInOAuthProviders, type BuiltInOAuthProvider } from "@aura-stack/au

export const oauth = Object.keys(builtInOAuthProviders) as BuiltInOAuthProvider[]

export const { handlers, jose } = createAuth({
export const { handlers, jose }: AuthInstance = createAuth({
oauth: ["github"],
basePath: "/api/auth",
trustedOrigins: ["http://localhost:3000", "http://localhost:3001", "https://*.vercel.app"],
}) as AuthInstance
})
4 changes: 2 additions & 2 deletions apps/hono/src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AuthInstance, createAuth } from "@aura-stack/auth"

export const { handlers, jose } = createAuth({
export const { handlers, jose }: AuthInstance = createAuth({
oauth: ["github"],
basePath: "/api/auth",
trustedOrigins: ["http://localhost:3000", "https://*.vercel.app"],
}) as AuthInstance
})
6 changes: 2 additions & 4 deletions apps/nextjs/app-router/src/app/auth/[...aura]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { auth } from "@/auth"
import { handlers } from "@/auth"

export const {
handlers: { GET, POST },
} = auth
export const { GET, POST } = handlers
4 changes: 2 additions & 2 deletions apps/nextjs/app-router/src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createAuth } from "@aura-stack/auth"
import { type AuthInstance, createAuth } from "@aura-stack/auth"
import { builtInOAuthProviders, type BuiltInOAuthProvider } from "@aura-stack/auth/oauth/index"

export const oauth = Object.keys(builtInOAuthProviders) as BuiltInOAuthProvider[]

export const auth = createAuth({
export const { handlers, jose }: AuthInstance = createAuth({
oauth,
trustedOrigins: ["http://localhost:3000", "https://*.vercel.app"],
})
24 changes: 17 additions & 7 deletions apps/nextjs/app-router/src/lib/server.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
"use server"

import { redirect } from "next/navigation"
import { cookies, headers } from "next/headers"
import { createClient, type Session, type LiteralUnion, type BuiltInOAuthProvider } from "@aura-stack/auth"

const toHeaders = (incoming: Awaited<ReturnType<typeof headers>>) => {
return Object.fromEntries(incoming.entries())
}

/**
* @todo: fix bug related to rendered statically
* @see https://nextjs.org/docs/messages/dynamic-server-error
*/
const client = createClient({
baseURL: typeof window !== "undefined" ? window.location.origin : (process.env.AUTH_URL ?? "http://localhost:3000"),
basePath: "/auth",
cache: "no-store",
credentials: "include",
headers: async () => {
"use server"
const headersStore = await headers()
return Object.fromEntries(headersStore.entries())
},
})

export const getCSRFToken = async (): Promise<string | null> => {
try {
const response = await client.get("/csrfToken")
const response = await client.get("/csrfToken", {
headers: toHeaders(await headers()),
})
if (!response.ok) return null
const json = await response.json()
return json && json?.csrfToken ? json.csrfToken : null
Expand All @@ -28,8 +34,11 @@ export const getCSRFToken = async (): Promise<string | null> => {
}

export const getSession = async (): Promise<Session | null> => {
"use server"
try {
const response = await client.get("/session")
const response = await client.get("/session", {
headers: toHeaders(await headers()),
})
if (!response.ok) return null
const session = await response.json()
return session && session?.user ? session : null
Expand Down Expand Up @@ -58,6 +67,7 @@ export const signOut = async (redirectTo: string = "/") => {
token_type_hint: "session_token",
},
headers: {
...toHeaders(await headers()),
"X-CSRF-Token": csrfToken,
},
})
Expand Down
5 changes: 2 additions & 3 deletions apps/nextjs/pages-router/src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { createAuth } from "@aura-stack/auth"
import { type AuthInstance, createAuth } from "@aura-stack/auth"
import { builtInOAuthProviders, type BuiltInOAuthProvider } from "@aura-stack/auth/oauth/index"

export const oauth = Object.keys(builtInOAuthProviders) as BuiltInOAuthProvider[]

export const { handlers, jose } = createAuth({
export const { handlers, jose }: AuthInstance = createAuth({
oauth,
basePath: "/api/auth",
trustedProxyHeaders: true,
})
17 changes: 17 additions & 0 deletions apps/nuxt/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ export default defineNuxtConfig({
devtools: { enabled: true },
css: ["~/assets/css/tailwind.css"],
vite: {
// @ts-expect-error - Nuxt/Vite plugin typing mismatch for `@tailwindcss/vite`
plugins: [tailwindcss()],
build: {
target: "es2022",
sourcemap: false,
},
optimizeDeps: {
esbuildOptions: {
target: "es2022",
},
},
},
nitro: {
esbuild: {
options: {
target: "es2022",
},
},
},
})
4 changes: 2 additions & 2 deletions apps/nuxt/shared/auth.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createAuth } from "@aura-stack/auth"
import { type AuthInstance, createAuth } from "@aura-stack/auth"
import { builtInOAuthProviders, type BuiltInOAuthProvider } from "@aura-stack/auth/oauth/index"

export const oauth = Object.keys(builtInOAuthProviders) as BuiltInOAuthProvider[]

export const { handlers, jose } = createAuth({
export const { handlers, jose }: AuthInstance = createAuth({
oauth,
basePath: "/api/auth",
trustedProxyHeaders: true,
Expand Down
4 changes: 2 additions & 2 deletions apps/oak/src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type AuthInstance, createAuth } from "@aura-stack/auth"

export const { handlers, jose } = createAuth({
export const { handlers, jose }: AuthInstance = createAuth({
oauth: ["github"],
basePath: "/api/auth",
trustedOrigins: ["http://localhost:3000", "https://*.vercel.app"],
}) as AuthInstance
})
2 changes: 1 addition & 1 deletion apps/react-router/app/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createAuth } from "@aura-stack/auth"
import { type AuthInstance, createAuth } from "@aura-stack/auth"
import { builtInOAuthProviders, type BuiltInOAuthProvider } from "@aura-stack/auth/oauth/index"

export const oauth = Object.keys(builtInOAuthProviders) as BuiltInOAuthProvider[]
Expand Down
4 changes: 2 additions & 2 deletions apps/supabase/functions/_shared/auth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type AuthInstance, createAuth } from "@aura-stack/auth"

export const { handlers, jose } = createAuth({
export const { handlers, jose }: AuthInstance = createAuth({
oauth: ["github"],
basePath: "/api/auth",
trustedOrigins: ["http://localhost:3000", "http://127.0.0.1:3000"],
}) as AuthInstance
})
4 changes: 2 additions & 2 deletions apps/tanstack-start/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"build": "vite build",
"preview": "vite preview",
"type-check": "tsc --noEmit",
"format": "prettier --write .",
"format:check": "prettier --check ."
"format": "prettier --write . --cache --cache-location .cache/.prettiercache",
"format:check": "prettier --check . --cache --cache-location .cache/.prettiercache"
},
"dependencies": {
"@hookform/resolvers": "^5.2.2",
Expand Down
4 changes: 2 additions & 2 deletions apps/tanstack-start/src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createAuth } from "@aura-stack/auth"
import { type AuthInstance, createAuth } from "@aura-stack/auth"
import { builtInOAuthProviders, type BuiltInOAuthProvider } from "@aura-stack/auth/oauth/index"

export const oauth = Object.keys(builtInOAuthProviders) as BuiltInOAuthProvider[]

export const { handlers, jose } = createAuth({
export const { handlers, jose }: AuthInstance = createAuth({
oauth,
trustedProxyHeaders: true,
})
2 changes: 1 addition & 1 deletion apps/tanstack-start/src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState } from "react"
import { Link, useRouter } from "@tanstack/react-router"
import { Button } from "./ui/button"
import { Menu, X } from "lucide-react"
import { signOut } from "@/lib/auth.client"
import { signOut } from "@/lib/auth-client"
import { useSession } from "@/contexts/auth"

export const Header = () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/tanstack-start/src/contexts/auth.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createContext, use, useEffect, useState } from "react"
import { getSession } from "@/lib/auth.client"
import { getSession } from "@/lib/auth-client"
import type { Session } from "@aura-stack/auth"
import type { AuthContextValue } from "@/@types/types"
import type { AuthProviderProps } from "@/@types/props"
Expand Down
Loading