Skip to content

Commit

Permalink
Vanilla JS client library (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
fomalhautb authored and N2D4 committed Feb 8, 2025
1 parent f704f31 commit 4a8fbea
Show file tree
Hide file tree
Showing 80 changed files with 1,606 additions and 387 deletions.
59 changes: 36 additions & 23 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
# Docker ignore rules
.changeset
.git
.github
.turbo
**/.turbo
.vscode

.env
.env.*
**/.env
**/.env.*
**/.next

**/dist

examples

node_modules
**/node_modules

deploy
!deploy/docker/**/entrypoint.sh
docker-compose.yaml



# Git ignore rules
*.untracked
*.untracked.*
Expand Down Expand Up @@ -113,27 +140,13 @@ docs/docs/reference/adapter
__pycache__/
.venv/

# Docker ignore rules
.changeset
.git
.github
.turbo
**/.turbo
.vscode
# Generated packages
packages/js/*
packages/react/*
packages/next/*
packages/stack/*
!packages/js/package.json
!packages/react/package.json
!packages/next/package.json
!packages/stack/package.json

.env
.env.*
**/.env
**/.env.*
**/.next

**/dist

examples

node_modules
**/node_modules

deploy
!deploy/docker/**/entrypoint.sh
docker-compose.yaml
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,13 @@ docs/docs/reference/adapter
# Python
__pycache__/
.venv/

# Generated packages
packages/js/*
packages/react/*
packages/next/*
packages/stack/*
!packages/js/package.json
!packages/react/package.json
!packages/next/package.json
!packages/stack/package.json
5 changes: 4 additions & 1 deletion docker/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ ENV PATH=$PNPM_HOME:$PATH
RUN corepack enable
RUN corepack prepare pnpm@10.0.0 --activate
RUN pnpm add -g turbo
RUN pnpm add -g tsx


# Prune stage
FROM base AS pruner

COPY . .

RUN tsx ./scripts/generate-from-template.ts

# https://turbo.build/repo/docs/guides/tools/docker
RUN turbo prune --scope=@stackframe/stack-backend --scope=@stackframe/stack-dashboard --docker

Expand All @@ -36,7 +39,7 @@ COPY .gitignore .
COPY pnpm-workspace.yaml .
COPY turbo.json .
RUN cat ./pnpm-lock.yaml
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN --mount=type=cache,id=pnpm,target=/pnpm/store STACK_SKIP_TEMPLATE_GENERATION=true pnpm install --frozen-lockfile

# copy over the rest of the code for the build
COPY --from=pruner /app/out/full/ .
Expand Down
6 changes: 6 additions & 0 deletions examples/js-example/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Contains the credentials for the internal project of Stack's default development environment setup.
# Do not use in a production environment, instead replace it with actual values gathered from https://app.stack-auth.com.
NEXT_PUBLIC_STACK_API_URL=http://localhost:8102
NEXT_PUBLIC_STACK_PROJECT_ID=internal
NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=this-publishable-client-key-is-for-local-development-only
STACK_SECRET_SERVER_KEY=this-secret-server-key-is-for-local-development-only
13 changes: 13 additions & 0 deletions examples/js-example/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { StackServerApp } from "@stackframe/js";

const stackServerApp = new StackServerApp({
tokenStore: 'memory',
});

stackServerApp.listUsers().then((users) => {
console.log(users);
});

stackServerApp.getUser().then((user) => {
console.log(user);
});
16 changes: 16 additions & 0 deletions examples/js-example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "@stackframe/js-example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "dotenv -e .env.development -- tsx index.ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@stackframe/js": "workspace:*",
"dotenv-cli": "^7.4.1"
}
}
67 changes: 35 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,44 @@
"private": true,
"repository": "",
"scripts": {
"preinstall": "npx -y only-allow pnpm",
"typecheck": "only-allow pnpm && turbo typecheck",
"build:dev": "NODE_ENV=development pnpm run build",
"build": "only-allow pnpm && turbo build",
"build:backend": "only-allow pnpm && turbo run build --filter=@stackframe/stack-backend...",
"build:dashboard": "only-allow pnpm && turbo run build --filter=@stackframe/stack-dashboard...",
"build:demo": "only-allow pnpm && turbo run build --filter=demo-app...",
"build:packages": "only-allow pnpm && turbo run build --filter=./packages/*",
"clean": "only-allow pnpm && turbo run clean && rimraf --glob **/.next && rimraf --glob **/.turbo && rimraf .turbo && rimraf --glob **/node_modules",
"codegen": "only-allow pnpm && turbo run codegen",
"pre": "npx -y only-allow pnpm && node -e \"if(process.env.STACK_SKIP_TEMPLATE_GENERATION !== 'true') require('child_process').execSync('npx --package=ts-node ts-node ./scripts/generate-from-template.ts')\"",
"preinstall": "pnpm pre",
"typecheck": "pnpm pre && turbo typecheck",
"build:dev": "pnpm pre && NODE_ENV=development pnpm run build",
"build": "pnpm pre && turbo build",
"build:backend": "pnpm pre && turbo run build --filter=@stackframe/stack-backend...",
"build:dashboard": "pnpm pre && turbo run build --filter=@stackframe/stack-dashboard...",
"build:demo": "pnpm pre && turbo run build --filter=demo-app...",
"build:packages": "pnpm pre && turbo run build --filter=./packages/*",
"clean": "pnpm pre && turbo run clean && rimraf --glob **/.next && rimraf --glob **/.turbo && rimraf .turbo && rimraf --glob **/node_modules",
"codegen": "pnpm pre && turbo run codegen",
"deps-compose": "docker compose -p stack-dependencies -f dependencies.compose.yaml",
"stop-deps": "POSTGRES_DELAY_MS=0 pnpm run deps-compose kill && POSTGRES_DELAY_MS=0 pnpm run deps-compose down -v",
"init-db": "pnpm run prisma db push && pnpm run prisma db seed",
"init-db": "pnpm pre && pnpm run prisma db push && pnpm run prisma db seed",
"wait-until-postgres-is-ready:pg_isready": "until pg_isready -h localhost -p 5432; do sleep 1; done",
"wait-until-postgres-is-ready": "command -v pg_isready >/dev/null 2>&1 && pnpm run wait-until-postgres-is-ready:pg_isready || sleep 10 # not everyone has pg_isready installed, so we fallback to sleeping",
"start-deps:no-delay": "pnpm run deps-compose up --detach --build && pnpm run wait-until-postgres-is-ready && pnpm run init-db && echo \"\\nDependencies started in the background as Docker containers. 'pnpm run stop-deps' to stop them\"n",
"start-deps": "POSTGRES_DELAY_MS=${POSTGRES_DELAY_MS:-10} pnpm run start-deps:no-delay",
"restart-deps": "pnpm run stop-deps && pnpm run start-deps",
"restart-deps:no-delay": "pnpm run stop-deps && pnpm run start-deps:no-delay",
"psql": "only-allow pnpm && pnpm run --filter=@stackframe/stack-backend psql",
"prisma": "only-allow pnpm && pnpm run --filter=@stackframe/stack-backend prisma",
"fern": "only-allow pnpm && pnpm run --filter=@stackframe/docs fern",
"dev": "only-allow pnpm && turbo run dev --concurrency 99999",
"dev:basic": "only-allow pnpm && turbo run dev --concurrency 99999 --filter=@stackframe/stack-backend --filter=@stackframe/stack-dashboard --filter=@stackframe/oauth-mock-server",
"start": "only-allow pnpm && turbo run start --concurrency 99999",
"start:backend": "only-allow pnpm && turbo run start --concurrency 99999 --filter=@stackframe/stack-backend",
"start:dashboard": "only-allow pnpm && turbo run start --concurrency 99999 --filter=@stackframe/stack-dashboard",
"start:oauth-mock-server": "only-allow pnpm && turbo run start --concurrency 99999 --filter=@stackframe/oauth-mock-server",
"lint": "only-allow pnpm && turbo run lint -- --max-warnings=0",
"release": "only-allow pnpm && release",
"peek": "only-allow pnpm && pnpm release --peek",
"changeset": "only-allow pnpm && changeset",
"test": "vitest",
"generate-docs": "only-allow pnpm && turbo run generate-docs",
"generate-keys": "only-allow pnpm && turbo run generate-keys",
"verify-data-integrity": "only-allow pnpm && pnpm -C apps/backend run verify-data-integrity"
"start-deps:no-delay": "pnpm pre && pnpm run deps-compose up --detach --build && pnpm run wait-until-postgres-is-ready && pnpm run init-db && echo \"\\nDependencies started in the background as Docker containers. 'pnpm run stop-deps' to stop them\"n",
"start-deps": "POSTGRES_DELAY_MS=${POSTGRES_DELAY_MS:-20} pnpm run start-deps:no-delay",
"restart-deps": "pnpm pre && pnpm run stop-deps && pnpm run start-deps",
"restart-deps:no-delay": "pnpm pre && pnpm run stop-deps && pnpm run start-deps:no-delay",
"psql": "pnpm pre && pnpm run --filter=@stackframe/stack-backend psql",
"prisma": "pnpm pre && pnpm run --filter=@stackframe/stack-backend prisma",
"fern": "pnpm pre && pnpm run --filter=@stackframe/docs fern",
"dev": "concurrently -k \"pnpm run generate-from-template:watch\" \"turbo run dev --concurrency 99999\"",
"dev:basic": "concurrently -k \"pnpm run generate-from-template:watch\" \"turbo run dev --concurrency 99999 --filter=@stackframe/stack-backend --filter=@stackframe/stack-dashboard --filter=@stackframe/oauth-mock-server\"",
"start": "pnpm pre && turbo run start --concurrency 99999",
"start:backend": "pnpm pre && turbo run start --concurrency 99999 --filter=@stackframe/stack-backend",
"start:dashboard": "pnpm pre && turbo run start --concurrency 99999 --filter=@stackframe/stack-dashboard",
"start:oauth-mock-server": "pnpm pre && turbo run start --concurrency 99999 --filter=@stackframe/oauth-mock-server",
"lint": "pnpm pre && turbo run lint -- --max-warnings=0",
"release": "pnpm pre && release",
"peek": "pnpm pre && pnpm release --peek",
"changeset": "pnpm pre && changeset",
"test": "pnpm pre && vitest",
"verify-data-integrity": "pnpm pre && pnpm -C apps/backend run verify-data-integrity",
"generate-docs": "pnpm pre && turbo run generate-docs",
"generate-keys": "pnpm pre && turbo run generate-keys",
"generate-from-template:watch": "chokidar --silent -c 'tsx ./scripts/generate-from-template.ts' './packages/template' --ignore '**/node_modules/**' --ignore '**/dist/**' --ignore '**/.turbo/**' --throttle 1000"
},
"devDependencies": {
"@changesets/cli": "^2.27.9",
Expand All @@ -49,6 +51,7 @@
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vitejs/plugin-react": "^4.3.3",
"chokidar-cli": "^3.0.0",
"concurrently": "^8.2.2",
"eslint": "8.30.0",
"eslint-config-next": "^14.2.17",
Expand Down
69 changes: 69 additions & 0 deletions packages/js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"//": "THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY",
"name": "@stackframe/js",
"version": "2.7.8",
"sideEffects": false,
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": {
"default": "./dist/esm/index.js"
},
"require": {
"default": "./dist/index.js"
}
}
},
"homepage": "https://stack-auth.com",
"scripts": {
"typecheck": "tsc --noEmit",
"clean": "rimraf dist && rimraf node_modules",
"lint": "eslint --ext .tsx,.ts .",
"build": "rimraf dist && tsup-node",
"dev": "rimraf dist && tsup-node --watch"
},
"files": [
"README.md",
"dist",
"CHANGELOG.md",
"LICENSE"
],
"dependencies": {
"@hookform/resolvers": "^3.3.4",
"@simplewebauthn/browser": "^11.0.0",
"@stackframe/stack-sc": "workspace:*",
"@stackframe/stack-shared": "workspace:*",
"color": "^4.2.3",
"cookie": "^0.6.0",
"jose": "^5.2.2",
"js-cookie": "^3.0.5",
"oauth4webapi": "^2.10.3",
"oslo": "^1.2.1",
"qrcode": "^1.5.4",
"rimraf": "^5.0.5",
"tsx": "^4.7.2",
"yup": "^1.4.0"
},
"devDependencies": {
"@quetzallabs/i18n": "^0.1.19",
"@types/color": "^3.0.6",
"@types/cookie": "^0.6.0",
"@types/js-cookie": "^3.0.6",
"@types/qrcode": "^1.5.5",
"@types/react-avatar-editor": "^13.0.3",
"autoprefixer": "^10.4.17",
"chokidar-cli": "^3.0.0",
"esbuild": "^0.20.2",
"i18next": "^23.14.0",
"i18next-parser": "^9.0.2",
"next": "^14.1.0",
"postcss": "^8.4.38",
"postcss-nested": "^6.0.1",
"react": "^18.2.0",
"rimraf": "^5.0.5",
"tailwindcss": "^3.4.4",
"tsup": "^8.0.2"
}
}
11 changes: 6 additions & 5 deletions packages/stack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"//": "THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY",
"name": "@stackframe/stack",
"version": "2.7.12",
"version": "2.7.8",
"sideEffects": false,
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand All @@ -18,12 +19,12 @@
"homepage": "https://stack-auth.com",
"scripts": {
"typecheck": "tsc --noEmit",
"clean": "rimraf dist && rimraf node_modules",
"lint": "eslint --ext .tsx,.ts .",
"build": "rimraf dist && pnpm run css && tsup-node",
"dev": "rimraf dist && concurrently -n \"build,codegen\" -k \"tsup-node --watch\" \"pnpm run codegen:watch\"",
"codegen": "pnpm run css && pnpm run quetzal",
"codegen:watch": "concurrently -n \"css,quetzal\" -k \"pnpm run css:watch\" \"pnpm run quetzal:watch\"",
"clean": "rimraf dist && rimraf node_modules",
"dev": "rimraf dist && concurrently -n \"build,codegen\" -k \"tsup-node --watch\" \"pnpm run codegen:watch\"",
"lint": "eslint --ext .tsx,.ts .",
"css": "pnpm run css-tw && pnpm run css-sc",
"css:watch": "concurrently -n \"tw,sc\" -k \"pnpm run css-tw:watch\" \"pnpm run css-sc:watch\"",
"css-tw:watch": "tailwindcss -i ./src/global.css -o ./src/generated/tailwind.css --watch",
Expand Down Expand Up @@ -99,4 +100,4 @@
"tailwindcss": "^3.4.4",
"tsup": "^8.0.2"
}
}
}
6 changes: 0 additions & 6 deletions packages/stack/src/utils/email.tsx

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 4a8fbea

Please sign in to comment.