Skip to content

Commit d3cca0b

Browse files
authored
Vanilla JS client library (stack-auth#408)
1 parent ccdbb31 commit d3cca0b

File tree

80 files changed

+1606
-387
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1606
-387
lines changed

.dockerignore

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
# Docker ignore rules
2+
.changeset
3+
.git
4+
.github
5+
.turbo
6+
**/.turbo
7+
.vscode
8+
9+
.env
10+
.env.*
11+
**/.env
12+
**/.env.*
13+
**/.next
14+
15+
**/dist
16+
17+
examples
18+
19+
node_modules
20+
**/node_modules
21+
22+
deploy
23+
!deploy/docker/**/entrypoint.sh
24+
docker-compose.yaml
25+
26+
27+
128
# Git ignore rules
229
*.untracked
330
*.untracked.*
@@ -113,27 +140,13 @@ docs/docs/reference/adapter
113140
__pycache__/
114141
.venv/
115142

116-
# Docker ignore rules
117-
.changeset
118-
.git
119-
.github
120-
.turbo
121-
**/.turbo
122-
.vscode
143+
# Generated packages
144+
packages/js/*
145+
packages/react/*
146+
packages/next/*
147+
packages/stack/*
148+
!packages/js/package.json
149+
!packages/react/package.json
150+
!packages/next/package.json
151+
!packages/stack/package.json
123152

124-
.env
125-
.env.*
126-
**/.env
127-
**/.env.*
128-
**/.next
129-
130-
**/dist
131-
132-
examples
133-
134-
node_modules
135-
**/node_modules
136-
137-
deploy
138-
!deploy/docker/**/entrypoint.sh
139-
docker-compose.yaml

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,13 @@ docs/docs/reference/adapter
119119
# Python
120120
__pycache__/
121121
.venv/
122+
123+
# Generated packages
124+
packages/js/*
125+
packages/react/*
126+
packages/next/*
127+
packages/stack/*
128+
!packages/js/package.json
129+
!packages/react/package.json
130+
!packages/next/package.json
131+
!packages/stack/package.json

docker/server/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ ENV PATH=$PNPM_HOME:$PATH
1515
RUN corepack enable
1616
RUN corepack prepare pnpm@10.0.0 --activate
1717
RUN pnpm add -g turbo
18+
RUN pnpm add -g tsx
1819

1920

2021
# Prune stage
2122
FROM base AS pruner
2223

2324
COPY . .
2425

26+
RUN tsx ./scripts/generate-from-template.ts
27+
2528
# https://turbo.build/repo/docs/guides/tools/docker
2629
RUN turbo prune --scope=@stackframe/stack-backend --scope=@stackframe/stack-dashboard --docker
2730

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

4144
# copy over the rest of the code for the build
4245
COPY --from=pruner /app/out/full/ .
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Contains the credentials for the internal project of Stack's default development environment setup.
2+
# Do not use in a production environment, instead replace it with actual values gathered from https://app.stack-auth.com.
3+
NEXT_PUBLIC_STACK_API_URL=http://localhost:8102
4+
NEXT_PUBLIC_STACK_PROJECT_ID=internal
5+
NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=this-publishable-client-key-is-for-local-development-only
6+
STACK_SECRET_SERVER_KEY=this-secret-server-key-is-for-local-development-only

examples/js-example/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { StackServerApp } from "@stackframe/js";
2+
3+
const stackServerApp = new StackServerApp({
4+
tokenStore: 'memory',
5+
});
6+
7+
stackServerApp.listUsers().then((users) => {
8+
console.log(users);
9+
});
10+
11+
stackServerApp.getUser().then((user) => {
12+
console.log(user);
13+
});

examples/js-example/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "@stackframe/js-example",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"start": "dotenv -e .env.development -- tsx index.ts"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "ISC",
12+
"dependencies": {
13+
"@stackframe/js": "workspace:*",
14+
"dotenv-cli": "^7.4.1"
15+
}
16+
}

package.json

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,44 @@
44
"private": true,
55
"repository": "",
66
"scripts": {
7-
"preinstall": "npx -y only-allow pnpm",
8-
"typecheck": "only-allow pnpm && turbo typecheck",
9-
"build:dev": "NODE_ENV=development pnpm run build",
10-
"build": "only-allow pnpm && turbo build",
11-
"build:backend": "only-allow pnpm && turbo run build --filter=@stackframe/stack-backend...",
12-
"build:dashboard": "only-allow pnpm && turbo run build --filter=@stackframe/stack-dashboard...",
13-
"build:demo": "only-allow pnpm && turbo run build --filter=demo-app...",
14-
"build:packages": "only-allow pnpm && turbo run build --filter=./packages/*",
15-
"clean": "only-allow pnpm && turbo run clean && rimraf --glob **/.next && rimraf --glob **/.turbo && rimraf .turbo && rimraf --glob **/node_modules",
16-
"codegen": "only-allow pnpm && turbo run codegen",
7+
"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')\"",
8+
"preinstall": "pnpm pre",
9+
"typecheck": "pnpm pre && turbo typecheck",
10+
"build:dev": "pnpm pre && NODE_ENV=development pnpm run build",
11+
"build": "pnpm pre && turbo build",
12+
"build:backend": "pnpm pre && turbo run build --filter=@stackframe/stack-backend...",
13+
"build:dashboard": "pnpm pre && turbo run build --filter=@stackframe/stack-dashboard...",
14+
"build:demo": "pnpm pre && turbo run build --filter=demo-app...",
15+
"build:packages": "pnpm pre && turbo run build --filter=./packages/*",
16+
"clean": "pnpm pre && turbo run clean && rimraf --glob **/.next && rimraf --glob **/.turbo && rimraf .turbo && rimraf --glob **/node_modules",
17+
"codegen": "pnpm pre && turbo run codegen",
1718
"deps-compose": "docker compose -p stack-dependencies -f dependencies.compose.yaml",
1819
"stop-deps": "POSTGRES_DELAY_MS=0 pnpm run deps-compose kill && POSTGRES_DELAY_MS=0 pnpm run deps-compose down -v",
19-
"init-db": "pnpm run prisma db push && pnpm run prisma db seed",
20+
"init-db": "pnpm pre && pnpm run prisma db push && pnpm run prisma db seed",
2021
"wait-until-postgres-is-ready:pg_isready": "until pg_isready -h localhost -p 5432; do sleep 1; done",
2122
"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",
22-
"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",
23-
"start-deps": "POSTGRES_DELAY_MS=${POSTGRES_DELAY_MS:-10} pnpm run start-deps:no-delay",
24-
"restart-deps": "pnpm run stop-deps && pnpm run start-deps",
25-
"restart-deps:no-delay": "pnpm run stop-deps && pnpm run start-deps:no-delay",
26-
"psql": "only-allow pnpm && pnpm run --filter=@stackframe/stack-backend psql",
27-
"prisma": "only-allow pnpm && pnpm run --filter=@stackframe/stack-backend prisma",
28-
"fern": "only-allow pnpm && pnpm run --filter=@stackframe/docs fern",
29-
"dev": "only-allow pnpm && turbo run dev --concurrency 99999",
30-
"dev:basic": "only-allow pnpm && turbo run dev --concurrency 99999 --filter=@stackframe/stack-backend --filter=@stackframe/stack-dashboard --filter=@stackframe/oauth-mock-server",
31-
"start": "only-allow pnpm && turbo run start --concurrency 99999",
32-
"start:backend": "only-allow pnpm && turbo run start --concurrency 99999 --filter=@stackframe/stack-backend",
33-
"start:dashboard": "only-allow pnpm && turbo run start --concurrency 99999 --filter=@stackframe/stack-dashboard",
34-
"start:oauth-mock-server": "only-allow pnpm && turbo run start --concurrency 99999 --filter=@stackframe/oauth-mock-server",
35-
"lint": "only-allow pnpm && turbo run lint -- --max-warnings=0",
36-
"release": "only-allow pnpm && release",
37-
"peek": "only-allow pnpm && pnpm release --peek",
38-
"changeset": "only-allow pnpm && changeset",
39-
"test": "vitest",
40-
"generate-docs": "only-allow pnpm && turbo run generate-docs",
41-
"generate-keys": "only-allow pnpm && turbo run generate-keys",
42-
"verify-data-integrity": "only-allow pnpm && pnpm -C apps/backend run verify-data-integrity"
23+
"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",
24+
"start-deps": "POSTGRES_DELAY_MS=${POSTGRES_DELAY_MS:-20} pnpm run start-deps:no-delay",
25+
"restart-deps": "pnpm pre && pnpm run stop-deps && pnpm run start-deps",
26+
"restart-deps:no-delay": "pnpm pre && pnpm run stop-deps && pnpm run start-deps:no-delay",
27+
"psql": "pnpm pre && pnpm run --filter=@stackframe/stack-backend psql",
28+
"prisma": "pnpm pre && pnpm run --filter=@stackframe/stack-backend prisma",
29+
"fern": "pnpm pre && pnpm run --filter=@stackframe/docs fern",
30+
"dev": "concurrently -k \"pnpm run generate-from-template:watch\" \"turbo run dev --concurrency 99999\"",
31+
"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\"",
32+
"start": "pnpm pre && turbo run start --concurrency 99999",
33+
"start:backend": "pnpm pre && turbo run start --concurrency 99999 --filter=@stackframe/stack-backend",
34+
"start:dashboard": "pnpm pre && turbo run start --concurrency 99999 --filter=@stackframe/stack-dashboard",
35+
"start:oauth-mock-server": "pnpm pre && turbo run start --concurrency 99999 --filter=@stackframe/oauth-mock-server",
36+
"lint": "pnpm pre && turbo run lint -- --max-warnings=0",
37+
"release": "pnpm pre && release",
38+
"peek": "pnpm pre && pnpm release --peek",
39+
"changeset": "pnpm pre && changeset",
40+
"test": "pnpm pre && vitest",
41+
"verify-data-integrity": "pnpm pre && pnpm -C apps/backend run verify-data-integrity",
42+
"generate-docs": "pnpm pre && turbo run generate-docs",
43+
"generate-keys": "pnpm pre && turbo run generate-keys",
44+
"generate-from-template:watch": "chokidar --silent -c 'tsx ./scripts/generate-from-template.ts' './packages/template' --ignore '**/node_modules/**' --ignore '**/dist/**' --ignore '**/.turbo/**' --throttle 1000"
4345
},
4446
"devDependencies": {
4547
"@changesets/cli": "^2.27.9",
@@ -49,6 +51,7 @@
4951
"@typescript-eslint/eslint-plugin": "^6.21.0",
5052
"@typescript-eslint/parser": "^6.21.0",
5153
"@vitejs/plugin-react": "^4.3.3",
54+
"chokidar-cli": "^3.0.0",
5255
"concurrently": "^8.2.2",
5356
"eslint": "8.30.0",
5457
"eslint-config-next": "^14.2.17",

packages/js/package.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"//": "THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY",
3+
"name": "@stackframe/js",
4+
"version": "2.7.8",
5+
"sideEffects": false,
6+
"main": "./dist/index.js",
7+
"types": "./dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"types": "./dist/index.d.ts",
11+
"import": {
12+
"default": "./dist/esm/index.js"
13+
},
14+
"require": {
15+
"default": "./dist/index.js"
16+
}
17+
}
18+
},
19+
"homepage": "https://stack-auth.com",
20+
"scripts": {
21+
"typecheck": "tsc --noEmit",
22+
"clean": "rimraf dist && rimraf node_modules",
23+
"lint": "eslint --ext .tsx,.ts .",
24+
"build": "rimraf dist && tsup-node",
25+
"dev": "rimraf dist && tsup-node --watch"
26+
},
27+
"files": [
28+
"README.md",
29+
"dist",
30+
"CHANGELOG.md",
31+
"LICENSE"
32+
],
33+
"dependencies": {
34+
"@hookform/resolvers": "^3.3.4",
35+
"@simplewebauthn/browser": "^11.0.0",
36+
"@stackframe/stack-sc": "workspace:*",
37+
"@stackframe/stack-shared": "workspace:*",
38+
"color": "^4.2.3",
39+
"cookie": "^0.6.0",
40+
"jose": "^5.2.2",
41+
"js-cookie": "^3.0.5",
42+
"oauth4webapi": "^2.10.3",
43+
"oslo": "^1.2.1",
44+
"qrcode": "^1.5.4",
45+
"rimraf": "^5.0.5",
46+
"tsx": "^4.7.2",
47+
"yup": "^1.4.0"
48+
},
49+
"devDependencies": {
50+
"@quetzallabs/i18n": "^0.1.19",
51+
"@types/color": "^3.0.6",
52+
"@types/cookie": "^0.6.0",
53+
"@types/js-cookie": "^3.0.6",
54+
"@types/qrcode": "^1.5.5",
55+
"@types/react-avatar-editor": "^13.0.3",
56+
"autoprefixer": "^10.4.17",
57+
"chokidar-cli": "^3.0.0",
58+
"esbuild": "^0.20.2",
59+
"i18next": "^23.14.0",
60+
"i18next-parser": "^9.0.2",
61+
"next": "^14.1.0",
62+
"postcss": "^8.4.38",
63+
"postcss-nested": "^6.0.1",
64+
"react": "^18.2.0",
65+
"rimraf": "^5.0.5",
66+
"tailwindcss": "^3.4.4",
67+
"tsup": "^8.0.2"
68+
}
69+
}

packages/stack/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2+
"//": "THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY",
23
"name": "@stackframe/stack",
3-
"version": "2.7.12",
4+
"version": "2.7.8",
45
"sideEffects": false,
56
"main": "./dist/index.js",
67
"types": "./dist/index.d.ts",
@@ -18,12 +19,12 @@
1819
"homepage": "https://stack-auth.com",
1920
"scripts": {
2021
"typecheck": "tsc --noEmit",
22+
"clean": "rimraf dist && rimraf node_modules",
23+
"lint": "eslint --ext .tsx,.ts .",
2124
"build": "rimraf dist && pnpm run css && tsup-node",
25+
"dev": "rimraf dist && concurrently -n \"build,codegen\" -k \"tsup-node --watch\" \"pnpm run codegen:watch\"",
2226
"codegen": "pnpm run css && pnpm run quetzal",
2327
"codegen:watch": "concurrently -n \"css,quetzal\" -k \"pnpm run css:watch\" \"pnpm run quetzal:watch\"",
24-
"clean": "rimraf dist && rimraf node_modules",
25-
"dev": "rimraf dist && concurrently -n \"build,codegen\" -k \"tsup-node --watch\" \"pnpm run codegen:watch\"",
26-
"lint": "eslint --ext .tsx,.ts .",
2728
"css": "pnpm run css-tw && pnpm run css-sc",
2829
"css:watch": "concurrently -n \"tw,sc\" -k \"pnpm run css-tw:watch\" \"pnpm run css-sc:watch\"",
2930
"css-tw:watch": "tailwindcss -i ./src/global.css -o ./src/generated/tailwind.css --watch",
@@ -99,4 +100,4 @@
99100
"tailwindcss": "^3.4.4",
100101
"tsup": "^8.0.2"
101102
}
102-
}
103+
}

packages/stack/src/utils/email.tsx

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)