Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vanilla JS client library #408

Merged
merged 45 commits into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
7a0b3dd
added js lb
fomalhautb Jan 28, 2025
0f596aa
added redirectMethod
fomalhautb Jan 28, 2025
6d050dc
added errors for oauth
fomalhautb Jan 29, 2025
2add4f3
import stack app from js lib
fomalhautb Jan 29, 2025
46a8314
removed unused deps
fomalhautb Jan 29, 2025
8aca978
added template gen
fomalhautb Jan 29, 2025
62c6bd7
added macros
fomalhautb Jan 29, 2025
073f565
gen stack
fomalhautb Jan 29, 2025
ca177a1
gen stack
fomalhautb Jan 29, 2025
654ece3
moved stack content back
fomalhautb Jan 29, 2025
000008b
updated import file
fomalhautb Jan 29, 2025
bf8a58e
fixed template
fomalhautb Jan 29, 2025
e6c8a17
fixed bugs
fomalhautb Jan 30, 2025
51e9c48
stack app gen for js lib
fomalhautb Jan 30, 2025
a45c3c6
fixed redirectMethod
fomalhautb Jan 30, 2025
4712343
Merge branch 'dev' into js-lib
fomalhautb Jan 30, 2025
3a01ca8
updated copy file
fomalhautb Jan 30, 2025
a50fae7
improved performance
fomalhautb Jan 30, 2025
0ab9230
improved generation
fomalhautb Jan 30, 2025
e3525a0
added if elseif else
fomalhautb Jan 30, 2025
e2b6214
fixed js package.json
fomalhautb Jan 30, 2025
c3ef12c
added js example
fomalhautb Jan 30, 2025
80313d0
improved copy function
fomalhautb Jan 30, 2025
41303c1
moved generate from template to top level
fomalhautb Jan 30, 2025
b01fc6c
commit package.json
fomalhautb Jan 31, 2025
3e833d5
added package.json
fomalhautb Jan 31, 2025
ac9a522
fixed git ignores
fomalhautb Jan 31, 2025
fc7ce13
added generate pre-install
fomalhautb Jan 31, 2025
3772b15
added watch update
fomalhautb Jan 31, 2025
2f7ac8e
updated package.json
fomalhautb Jan 31, 2025
569a89c
fixed bugs
fomalhautb Jan 31, 2025
b5020a0
fixed bugs
fomalhautb Jan 31, 2025
50c8c61
Merge branch 'dev' into js-lib
fomalhautb Jan 31, 2025
d2968f1
fixed docker build
fomalhautb Jan 31, 2025
83990c0
fixed lint
fomalhautb Jan 31, 2025
bd3bcdf
optional generate from templates
fomalhautb Jan 31, 2025
91c4f76
updated next line only to next line platform
fomalhautb Feb 1, 2025
590d58f
Update packages/template/src/lib/cookie.ts
fomalhautb Feb 5, 2025
0c648d0
Merge branch 'dev' into js-lib
fomalhautb Feb 6, 2025
d9fddc6
Merge branch 'dev' into js-lib
fomalhautb Feb 6, 2025
e0d7223
fixed pre script
fomalhautb Feb 8, 2025
c22b762
added warning comments
fomalhautb Feb 8, 2025
1f7309d
keep shebang
fomalhautb Feb 8, 2025
6aeccd4
added comments
fomalhautb Feb 8, 2025
b1f10df
formatting
fomalhautb Feb 8, 2025
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
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 [email protected] --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