diff --git a/samples/browser/quickstart/.stackblitzrc b/samples/browser/quickstart/.stackblitzrc index 10d058b..5f0a200 100644 --- a/samples/browser/quickstart/.stackblitzrc +++ b/samples/browser/quickstart/.stackblitzrc @@ -1,4 +1,4 @@ { "installDependencies": false, - "startCommand": "node -e \"const fs=require(\\\"fs\\\");const p=JSON.parse(fs.readFileSync(\\\"package.json\\\"));[\\\"dependencies\\\",\\\"devDependencies\\\"].forEach(f=>{if(p[f])Object.keys(p[f]).forEach(k=>{if(p[f][k].startsWith(\\\"workspace:\\\"))p[f][k]=\\\"latest\\\"})});fs.writeFileSync(\\\"package.json\\\",JSON.stringify(p,null,2)+\\\"\\\\n\\\")\" && npm install && npm run dev" + "startCommand": "npm run prepare-dev && npm install && npm run dev" } diff --git a/samples/browser/quickstart/README.md b/samples/browser/quickstart/README.md index f9f4e8b..4dd7245 100644 --- a/samples/browser/quickstart/README.md +++ b/samples/browser/quickstart/README.md @@ -1,6 +1,6 @@ # ThunderID Browser Quickstart -[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/fork/github/thunder-id/javascript-sdks/tree/main/samples/browser/quickstart) +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/fork/github/thunder-id/javascript-sdks/tree/main/samples/browser/quickstart?file=.env&terminal=dev) A minimal Vite + vanilla JS app demonstrating sign-in and sign-out with the ThunderID JavaScript SDK (`@thunderid/browser`). @@ -8,22 +8,7 @@ A minimal Vite + vanilla JS app demonstrating sign-in and sign-out with the Thun - Node.js 18+ - A running ThunderID instance (default: `https://localhost:8090`) -- A configured application with an authorized redirect URI set to your app's origin (see [Import ThunderID Resources](#import-thunderid-resources) below) - -## Import ThunderID Resources - -This sample ships with a `thunderid-config/` directory containing a declarative YAML file that creates the required user type and application in one step. - -1. Open `thunderid-config/thunderid.env` and set your preferred values: - ```bash - BROWSER_QUICKSTART_CLIENT_ID=BROWSER_QUICKSTART - BROWSER_QUICKSTART_REDIRECT_URIS=["http://localhost:5173"] - ``` -2. Import via the ThunderID Console (https://localhost:8090/console): - - **First-time login**: a welcome screen appears with an **Open** button to upload the YAML file directly. - - **Later**: access the same welcome screen from the user profile menu in the top-right corner of the console. - -This creates the `Customer` user type and the `browser-quickstart` application under the default organization unit. +- A configured application with an authorized redirect URI set to your app's origin ## Getting started diff --git a/samples/browser/quickstart/package.json b/samples/browser/quickstart/package.json index fad4066..dbf2860 100644 --- a/samples/browser/quickstart/package.json +++ b/samples/browser/quickstart/package.json @@ -4,6 +4,7 @@ "version": "0.0.0", "type": "module", "scripts": { + "prepare-dev": "node scripts/prepare-dev.cjs", "dev": "vite", "build": "vite build", "preview": "vite preview" diff --git a/samples/browser/quickstart/scripts/prepare-dev.cjs b/samples/browser/quickstart/scripts/prepare-dev.cjs new file mode 100644 index 0000000..6cd6ed3 --- /dev/null +++ b/samples/browser/quickstart/scripts/prepare-dev.cjs @@ -0,0 +1,28 @@ +// Copyright 2026 The ThunderID Authors +// SPDX-License-Identifier: Apache-2.0 + +const fs = require('node:fs'); +const path = require('node:path'); + +const root = path.join(__dirname, '..'); + +const envExample = path.join(root, '.env.example'); +const envTarget = path.join(root, '.env'); +if (fs.existsSync(envExample) && !fs.existsSync(envTarget)) { + fs.copyFileSync(envExample, envTarget); +} + +const pkgPath = path.join(root, 'package.json'); +const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')); + +for (const field of ['dependencies', 'devDependencies']) { + const deps = pkg[field]; + if (!deps) continue; + for (const [name, version] of Object.entries(deps)) { + if (version.startsWith('workspace:')) { + deps[name] = 'latest'; + } + } +} + +fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n'); diff --git a/samples/express/quickstart/.stackblitzrc b/samples/express/quickstart/.stackblitzrc index 10d058b..5f0a200 100644 --- a/samples/express/quickstart/.stackblitzrc +++ b/samples/express/quickstart/.stackblitzrc @@ -1,4 +1,4 @@ { "installDependencies": false, - "startCommand": "node -e \"const fs=require(\\\"fs\\\");const p=JSON.parse(fs.readFileSync(\\\"package.json\\\"));[\\\"dependencies\\\",\\\"devDependencies\\\"].forEach(f=>{if(p[f])Object.keys(p[f]).forEach(k=>{if(p[f][k].startsWith(\\\"workspace:\\\"))p[f][k]=\\\"latest\\\"})});fs.writeFileSync(\\\"package.json\\\",JSON.stringify(p,null,2)+\\\"\\\\n\\\")\" && npm install && npm run dev" + "startCommand": "npm run prepare-dev && npm install && npm run dev" } diff --git a/samples/express/quickstart/README.md b/samples/express/quickstart/README.md index f54bac6..a2b752f 100644 --- a/samples/express/quickstart/README.md +++ b/samples/express/quickstart/README.md @@ -1,6 +1,6 @@ # ThunderID Express Quickstart -[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/fork/github/thunder-id/javascript-sdks/tree/main/samples/express/quickstart) +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/fork/github/thunder-id/javascript-sdks/tree/main/samples/express/quickstart?file=.env&terminal=dev) A minimal Express.js **API** protected by ThunderID access tokens, using the ThunderID JavaScript SDK (`@thunderid/express`). Unlike the browser-focused quickstarts, this sample doesn't have a @@ -16,23 +16,7 @@ Protected routes validate the `Authorization: Bearer ` header against Thu - Node.js 18+ - A running ThunderID instance (default: `https://localhost:8090`) -- A configured application with `http://localhost:3000/login` added as an authorized redirect URI (see [Import ThunderID Resources](#import-thunderid-resources) below) - -## Import ThunderID Resources - -This sample ships with a `thunderid-config/` directory containing a declarative YAML file that creates the required user type and application in one step. - -1. Open `thunderid-config/thunderid.env` and set your preferred values: - ```bash - EXPRESS_QUICKSTART_CLIENT_ID=EXPRESS_QUICKSTART - EXPRESS_QUICKSTART_CLIENT_SECRET= - EXPRESS_QUICKSTART_REDIRECT_URIS=["http://localhost:3000/login"] - ``` -2. Import via the ThunderID Console (https://localhost:8090/console): - - **First-time login**: a welcome screen appears with an **Open** button to upload the YAML file directly. - - **Later**: access the same welcome screen from the user profile menu in the top-right corner of the console. - -This creates the `Customer` user type and the `express-quickstart` application under the default organization unit. +- A configured application with `http://localhost:3000/login` added as an authorized redirect URI ## Getting started diff --git a/samples/express/quickstart/package.json b/samples/express/quickstart/package.json index 1e9a3b1..d903c38 100644 --- a/samples/express/quickstart/package.json +++ b/samples/express/quickstart/package.json @@ -4,6 +4,7 @@ "version": "0.0.0", "type": "module", "scripts": { + "prepare-dev": "node scripts/prepare-dev.cjs", "start": "node --env-file-if-exists=.env index.mjs", "dev": "node --env-file-if-exists=.env --watch index.mjs" }, diff --git a/samples/express/quickstart/scripts/prepare-dev.cjs b/samples/express/quickstart/scripts/prepare-dev.cjs new file mode 100644 index 0000000..6cd6ed3 --- /dev/null +++ b/samples/express/quickstart/scripts/prepare-dev.cjs @@ -0,0 +1,28 @@ +// Copyright 2026 The ThunderID Authors +// SPDX-License-Identifier: Apache-2.0 + +const fs = require('node:fs'); +const path = require('node:path'); + +const root = path.join(__dirname, '..'); + +const envExample = path.join(root, '.env.example'); +const envTarget = path.join(root, '.env'); +if (fs.existsSync(envExample) && !fs.existsSync(envTarget)) { + fs.copyFileSync(envExample, envTarget); +} + +const pkgPath = path.join(root, 'package.json'); +const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')); + +for (const field of ['dependencies', 'devDependencies']) { + const deps = pkg[field]; + if (!deps) continue; + for (const [name, version] of Object.entries(deps)) { + if (version.startsWith('workspace:')) { + deps[name] = 'latest'; + } + } +} + +fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n'); diff --git a/samples/nextjs/quickstart/.stackblitzrc b/samples/nextjs/quickstart/.stackblitzrc index 10d058b..5f0a200 100644 --- a/samples/nextjs/quickstart/.stackblitzrc +++ b/samples/nextjs/quickstart/.stackblitzrc @@ -1,4 +1,4 @@ { "installDependencies": false, - "startCommand": "node -e \"const fs=require(\\\"fs\\\");const p=JSON.parse(fs.readFileSync(\\\"package.json\\\"));[\\\"dependencies\\\",\\\"devDependencies\\\"].forEach(f=>{if(p[f])Object.keys(p[f]).forEach(k=>{if(p[f][k].startsWith(\\\"workspace:\\\"))p[f][k]=\\\"latest\\\"})});fs.writeFileSync(\\\"package.json\\\",JSON.stringify(p,null,2)+\\\"\\\\n\\\")\" && npm install && npm run dev" + "startCommand": "npm run prepare-dev && npm install && npm run dev" } diff --git a/samples/nextjs/quickstart/README.md b/samples/nextjs/quickstart/README.md index 9f9d683..dde9351 100644 --- a/samples/nextjs/quickstart/README.md +++ b/samples/nextjs/quickstart/README.md @@ -1,6 +1,6 @@ # ThunderID Next.js Quickstart -[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/fork/github/thunder-id/javascript-sdks/tree/main/samples/nextjs/quickstart) +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/fork/github/thunder-id/javascript-sdks/tree/main/samples/nextjs/quickstart?file=.env.local&terminal=dev) A minimal Next.js 15 App Router application demonstrating ThunderID authentication with OAuth 2.0, PKCE, and JWT out of the box. @@ -8,26 +8,7 @@ A minimal Next.js 15 App Router application demonstrating ThunderID authenticati - Node.js 18+ - pnpm -- A ThunderID application (see [Import ThunderID Resources](#import-thunderid-resources) below) - -## Import ThunderID Resources - -This sample ships with a `thunderid-config/` directory containing a declarative YAML file that creates the required user type and application in one step. - -1. Open `thunderid-config/thunderid.env` and set your preferred values: - - ```bash - NEXTJS_QUICKSTART_APPLICATION_ID= - NEXTJS_QUICKSTART_CLIENT_ID=NEXTJS_QUICKSTART - NEXTJS_QUICKSTART_CLIENT_SECRET= - NEXTJS_QUICKSTART_REDIRECT_URIS=["http://localhost:3000"] - ``` - -2. Import via the ThunderID Console ([https://localhost:8090/console](https://localhost:8090/console)): - - **First-time login**: a welcome screen appears with an **Open** button to upload the YAML file directly. - - **Later**: access the same welcome screen from the user profile menu in the top-right corner of the console. - -This creates the `Customer` user type and the `nextjs-quickstart` application under the default organization unit. Note the `NEXTJS_QUICKSTART_APPLICATION_ID` value — unlike the client ID, this is a fixed id (not server-assigned) because it also drives the embedded sign-in/sign-up UI, so you'll copy it verbatim into `.env.local` below. +- A ThunderID application ## Getting started diff --git a/samples/nextjs/quickstart/package.json b/samples/nextjs/quickstart/package.json index 8a0a616..f6e8405 100644 --- a/samples/nextjs/quickstart/package.json +++ b/samples/nextjs/quickstart/package.json @@ -3,6 +3,7 @@ "private": true, "version": "0.0.0", "scripts": { + "prepare-dev": "node scripts/prepare-dev.cjs", "dev": "next dev", "build": "next build", "start": "next start" diff --git a/samples/nextjs/quickstart/scripts/prepare-dev.cjs b/samples/nextjs/quickstart/scripts/prepare-dev.cjs new file mode 100644 index 0000000..db57376 --- /dev/null +++ b/samples/nextjs/quickstart/scripts/prepare-dev.cjs @@ -0,0 +1,28 @@ +// Copyright 2026 The ThunderID Authors +// SPDX-License-Identifier: Apache-2.0 + +const fs = require('node:fs'); +const path = require('node:path'); + +const root = path.join(__dirname, '..'); + +const envExample = path.join(root, '.env.example'); +const envTarget = path.join(root, '.env.local'); +if (fs.existsSync(envExample) && !fs.existsSync(envTarget)) { + fs.copyFileSync(envExample, envTarget); +} + +const pkgPath = path.join(root, 'package.json'); +const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')); + +for (const field of ['dependencies', 'devDependencies']) { + const deps = pkg[field]; + if (!deps) continue; + for (const [name, version] of Object.entries(deps)) { + if (version.startsWith('workspace:')) { + deps[name] = 'latest'; + } + } +} + +fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n'); diff --git a/samples/node/quickstart/.stackblitzrc b/samples/node/quickstart/.stackblitzrc index 10d058b..5f0a200 100644 --- a/samples/node/quickstart/.stackblitzrc +++ b/samples/node/quickstart/.stackblitzrc @@ -1,4 +1,4 @@ { "installDependencies": false, - "startCommand": "node -e \"const fs=require(\\\"fs\\\");const p=JSON.parse(fs.readFileSync(\\\"package.json\\\"));[\\\"dependencies\\\",\\\"devDependencies\\\"].forEach(f=>{if(p[f])Object.keys(p[f]).forEach(k=>{if(p[f][k].startsWith(\\\"workspace:\\\"))p[f][k]=\\\"latest\\\"})});fs.writeFileSync(\\\"package.json\\\",JSON.stringify(p,null,2)+\\\"\\\\n\\\")\" && npm install && npm run dev" + "startCommand": "npm run prepare-dev && npm install && npm run dev" } diff --git a/samples/node/quickstart/README.md b/samples/node/quickstart/README.md index a2feec5..37e5f76 100644 --- a/samples/node/quickstart/README.md +++ b/samples/node/quickstart/README.md @@ -1,6 +1,6 @@ # ThunderID Node.js Service Quickstart -[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/fork/github/thunder-id/javascript-sdks/tree/main/samples/node/quickstart) +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/fork/github/thunder-id/javascript-sdks/tree/main/samples/node/quickstart?file=.env&terminal=dev) A minimal machine-to-machine (service-to-service) client, using the ThunderID Node.js SDK (`@thunderid/node`). Unlike the other quickstarts, there's no user and no browser sign-in: this diff --git a/samples/node/quickstart/package.json b/samples/node/quickstart/package.json index 77d90cc..a69445f 100644 --- a/samples/node/quickstart/package.json +++ b/samples/node/quickstart/package.json @@ -4,6 +4,7 @@ "version": "0.0.0", "type": "module", "scripts": { + "prepare-dev": "node scripts/prepare-dev.cjs", "start": "node --env-file-if-exists=.env index.mjs", "dev": "node --env-file-if-exists=.env --watch index.mjs" }, diff --git a/samples/node/quickstart/scripts/prepare-dev.cjs b/samples/node/quickstart/scripts/prepare-dev.cjs new file mode 100644 index 0000000..6cd6ed3 --- /dev/null +++ b/samples/node/quickstart/scripts/prepare-dev.cjs @@ -0,0 +1,28 @@ +// Copyright 2026 The ThunderID Authors +// SPDX-License-Identifier: Apache-2.0 + +const fs = require('node:fs'); +const path = require('node:path'); + +const root = path.join(__dirname, '..'); + +const envExample = path.join(root, '.env.example'); +const envTarget = path.join(root, '.env'); +if (fs.existsSync(envExample) && !fs.existsSync(envTarget)) { + fs.copyFileSync(envExample, envTarget); +} + +const pkgPath = path.join(root, 'package.json'); +const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')); + +for (const field of ['dependencies', 'devDependencies']) { + const deps = pkg[field]; + if (!deps) continue; + for (const [name, version] of Object.entries(deps)) { + if (version.startsWith('workspace:')) { + deps[name] = 'latest'; + } + } +} + +fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n'); diff --git a/samples/nuxt/quickstart/.stackblitzrc b/samples/nuxt/quickstart/.stackblitzrc index 10d058b..5f0a200 100644 --- a/samples/nuxt/quickstart/.stackblitzrc +++ b/samples/nuxt/quickstart/.stackblitzrc @@ -1,4 +1,4 @@ { "installDependencies": false, - "startCommand": "node -e \"const fs=require(\\\"fs\\\");const p=JSON.parse(fs.readFileSync(\\\"package.json\\\"));[\\\"dependencies\\\",\\\"devDependencies\\\"].forEach(f=>{if(p[f])Object.keys(p[f]).forEach(k=>{if(p[f][k].startsWith(\\\"workspace:\\\"))p[f][k]=\\\"latest\\\"})});fs.writeFileSync(\\\"package.json\\\",JSON.stringify(p,null,2)+\\\"\\\\n\\\")\" && npm install && npm run dev" + "startCommand": "npm run prepare-dev && npm install && npm run dev" } diff --git a/samples/nuxt/quickstart/README.md b/samples/nuxt/quickstart/README.md index 394a049..b57c3a4 100644 --- a/samples/nuxt/quickstart/README.md +++ b/samples/nuxt/quickstart/README.md @@ -1,6 +1,6 @@ # ThunderID Nuxt Quickstart -[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/fork/github/thunder-id/javascript-sdks/tree/main/samples/nuxt/quickstart) +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/fork/github/thunder-id/javascript-sdks/tree/main/samples/nuxt/quickstart?file=.env&terminal=dev) A minimal Nuxt 3 application demonstrating ThunderID authentication with OAuth 2.0, PKCE, and JWT out of the box. @@ -8,26 +8,7 @@ A minimal Nuxt 3 application demonstrating ThunderID authentication with OAuth 2 - Node.js 18+ - pnpm -- A ThunderID application (see [Import ThunderID Resources](#import-thunderid-resources) below) - -## Import ThunderID Resources - -This sample ships with a `thunderid-config/` directory containing a declarative YAML file that creates the required user type and application in one step. - -1. Open `thunderid-config/thunderid.env` and set your preferred values: - - ```bash - NUXT_QUICKSTART_APPLICATION_ID= - NUXT_QUICKSTART_CLIENT_ID=NUXT_QUICKSTART - NUXT_QUICKSTART_CLIENT_SECRET= - NUXT_QUICKSTART_REDIRECT_URIS=["http://localhost:3000/api/auth/callback"] - ``` - -2. Import via the ThunderID Console ([https://localhost:8090/console](https://localhost:8090/console)): - - **First-time login**: a welcome screen appears with an **Open** button to upload the YAML file directly. - - **Later**: access the same welcome screen from the user profile menu in the top-right corner of the console. - -This creates the `Customer` user type and the `nuxt-quickstart` application under the default organization unit. Note the `NUXT_QUICKSTART_APPLICATION_ID` value — unlike the client ID, this is a fixed id (not server-assigned) because it also drives the embedded sign-in UI, so you'll copy it verbatim into `.env` below. +- A ThunderID application ## Getting started diff --git a/samples/nuxt/quickstart/package.json b/samples/nuxt/quickstart/package.json index 489eb99..cfc04bf 100644 --- a/samples/nuxt/quickstart/package.json +++ b/samples/nuxt/quickstart/package.json @@ -3,6 +3,7 @@ "private": true, "version": "0.0.0", "scripts": { + "prepare-dev": "node scripts/prepare-dev.cjs", "dev": "TMPDIR=/tmp/nuxt-tmp/ nuxt dev", "build": "nuxt build", "generate": "nuxt generate", diff --git a/samples/nuxt/quickstart/scripts/prepare-dev.cjs b/samples/nuxt/quickstart/scripts/prepare-dev.cjs new file mode 100644 index 0000000..6cd6ed3 --- /dev/null +++ b/samples/nuxt/quickstart/scripts/prepare-dev.cjs @@ -0,0 +1,28 @@ +// Copyright 2026 The ThunderID Authors +// SPDX-License-Identifier: Apache-2.0 + +const fs = require('node:fs'); +const path = require('node:path'); + +const root = path.join(__dirname, '..'); + +const envExample = path.join(root, '.env.example'); +const envTarget = path.join(root, '.env'); +if (fs.existsSync(envExample) && !fs.existsSync(envTarget)) { + fs.copyFileSync(envExample, envTarget); +} + +const pkgPath = path.join(root, 'package.json'); +const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')); + +for (const field of ['dependencies', 'devDependencies']) { + const deps = pkg[field]; + if (!deps) continue; + for (const [name, version] of Object.entries(deps)) { + if (version.startsWith('workspace:')) { + deps[name] = 'latest'; + } + } +} + +fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n'); diff --git a/samples/react/quickstart/.stackblitzrc b/samples/react/quickstart/.stackblitzrc index 10d058b..5f0a200 100644 --- a/samples/react/quickstart/.stackblitzrc +++ b/samples/react/quickstart/.stackblitzrc @@ -1,4 +1,4 @@ { "installDependencies": false, - "startCommand": "node -e \"const fs=require(\\\"fs\\\");const p=JSON.parse(fs.readFileSync(\\\"package.json\\\"));[\\\"dependencies\\\",\\\"devDependencies\\\"].forEach(f=>{if(p[f])Object.keys(p[f]).forEach(k=>{if(p[f][k].startsWith(\\\"workspace:\\\"))p[f][k]=\\\"latest\\\"})});fs.writeFileSync(\\\"package.json\\\",JSON.stringify(p,null,2)+\\\"\\\\n\\\")\" && npm install && npm run dev" + "startCommand": "npm run prepare-dev && npm install && npm run dev" } diff --git a/samples/react/quickstart/README.md b/samples/react/quickstart/README.md index e5aa2f0..5ccbd6f 100644 --- a/samples/react/quickstart/README.md +++ b/samples/react/quickstart/README.md @@ -1,6 +1,6 @@ # ThunderID React Quickstart -[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/fork/github/thunder-id/javascript-sdks/tree/main/samples/react/quickstart) +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/fork/github/thunder-id/javascript-sdks/tree/main/samples/react/quickstart?file=.env&terminal=dev) A minimal React + Vite application demonstrating ThunderID authentication with OAuth 2.0, PKCE, and JWT support using the `@thunderid/react` SDK. @@ -8,22 +8,7 @@ A minimal React + Vite application demonstrating ThunderID authentication with O - Node.js 18+ - pnpm -- A ThunderID application (see [Import ThunderID Resources](#import-thunderid-resources) below) - -## Import ThunderID Resources - -This sample ships with a `thunderid-config/` directory containing a declarative YAML file that creates the required user type and application in one step. - -1. Open `thunderid-config/thunderid.env` and set your preferred values: - ```bash - REACT_QUICKSTART_CLIENT_ID=REACT_QUICKSTART - REACT_QUICKSTART_REDIRECT_URIS=["http://localhost:5173"] - ``` -2. Import via the ThunderID Console (https://localhost:8090/console): - - **First-time login**: a welcome screen appears with an **Open** button to upload the YAML file directly. - - **Later**: access the same welcome screen from the user profile menu in the top-right corner of the console. - -This creates the `Customer` user type and the `react-quickstart` application under the default organization unit. +- A ThunderID application ## Setup diff --git a/samples/react/quickstart/package.json b/samples/react/quickstart/package.json index 1f9905b..98f3930 100644 --- a/samples/react/quickstart/package.json +++ b/samples/react/quickstart/package.json @@ -4,6 +4,7 @@ "version": "0.0.0", "type": "module", "scripts": { + "prepare-dev": "node scripts/prepare-dev.cjs", "dev": "vite", "build": "vite build", "preview": "vite preview" diff --git a/samples/react/quickstart/scripts/prepare-dev.cjs b/samples/react/quickstart/scripts/prepare-dev.cjs new file mode 100644 index 0000000..6cd6ed3 --- /dev/null +++ b/samples/react/quickstart/scripts/prepare-dev.cjs @@ -0,0 +1,28 @@ +// Copyright 2026 The ThunderID Authors +// SPDX-License-Identifier: Apache-2.0 + +const fs = require('node:fs'); +const path = require('node:path'); + +const root = path.join(__dirname, '..'); + +const envExample = path.join(root, '.env.example'); +const envTarget = path.join(root, '.env'); +if (fs.existsSync(envExample) && !fs.existsSync(envTarget)) { + fs.copyFileSync(envExample, envTarget); +} + +const pkgPath = path.join(root, 'package.json'); +const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')); + +for (const field of ['dependencies', 'devDependencies']) { + const deps = pkg[field]; + if (!deps) continue; + for (const [name, version] of Object.entries(deps)) { + if (version.startsWith('workspace:')) { + deps[name] = 'latest'; + } + } +} + +fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n'); diff --git a/samples/vue/quickstart/.stackblitzrc b/samples/vue/quickstart/.stackblitzrc index 10d058b..5f0a200 100644 --- a/samples/vue/quickstart/.stackblitzrc +++ b/samples/vue/quickstart/.stackblitzrc @@ -1,4 +1,4 @@ { "installDependencies": false, - "startCommand": "node -e \"const fs=require(\\\"fs\\\");const p=JSON.parse(fs.readFileSync(\\\"package.json\\\"));[\\\"dependencies\\\",\\\"devDependencies\\\"].forEach(f=>{if(p[f])Object.keys(p[f]).forEach(k=>{if(p[f][k].startsWith(\\\"workspace:\\\"))p[f][k]=\\\"latest\\\"})});fs.writeFileSync(\\\"package.json\\\",JSON.stringify(p,null,2)+\\\"\\\\n\\\")\" && npm install && npm run dev" + "startCommand": "npm run prepare-dev && npm install && npm run dev" } diff --git a/samples/vue/quickstart/README.md b/samples/vue/quickstart/README.md index fc4c48a..93a6c5b 100644 --- a/samples/vue/quickstart/README.md +++ b/samples/vue/quickstart/README.md @@ -1,6 +1,6 @@ # ThunderID Vue Quickstart -[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/fork/github/thunder-id/javascript-sdks/tree/main/samples/vue/quickstart) +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/fork/github/thunder-id/javascript-sdks/tree/main/samples/vue/quickstart?file=.env&terminal=dev) A minimal Vue 3 + Vite application demonstrating ThunderID authentication with OAuth 2.0, PKCE, and JWT support using the `@thunderid/vue` SDK. @@ -8,22 +8,7 @@ A minimal Vue 3 + Vite application demonstrating ThunderID authentication with O - Node.js 18+ - pnpm -- A ThunderID application (see [Import ThunderID Resources](#import-thunderid-resources) below) - -## Import ThunderID Resources - -This sample ships with a `thunderid-config/` directory containing a declarative YAML file that creates the required user type and application in one step. - -1. Open `thunderid-config/thunderid.env` and set your preferred values: - ```bash - VUE_QUICKSTART_CLIENT_ID=VUE_QUICKSTART - VUE_QUICKSTART_REDIRECT_URIS=["http://localhost:5173"] - ``` -2. Import via the ThunderID Console (https://localhost:8090/console): - - **First-time login**: a welcome screen appears with an **Open** button to upload the YAML file directly. - - **Later**: access the same welcome screen from the user profile menu in the top-right corner of the console. - -This creates the `Customer` user type and the `vuejs-quickstart` application under the default organization unit. +- A ThunderID application ## Setup diff --git a/samples/vue/quickstart/package.json b/samples/vue/quickstart/package.json index 6a22fe7..aea34d6 100644 --- a/samples/vue/quickstart/package.json +++ b/samples/vue/quickstart/package.json @@ -4,6 +4,7 @@ "version": "0.0.0", "type": "module", "scripts": { + "prepare-dev": "node scripts/prepare-dev.cjs", "dev": "vite", "build": "vite build", "preview": "vite preview" diff --git a/samples/vue/quickstart/scripts/prepare-dev.cjs b/samples/vue/quickstart/scripts/prepare-dev.cjs new file mode 100644 index 0000000..6cd6ed3 --- /dev/null +++ b/samples/vue/quickstart/scripts/prepare-dev.cjs @@ -0,0 +1,28 @@ +// Copyright 2026 The ThunderID Authors +// SPDX-License-Identifier: Apache-2.0 + +const fs = require('node:fs'); +const path = require('node:path'); + +const root = path.join(__dirname, '..'); + +const envExample = path.join(root, '.env.example'); +const envTarget = path.join(root, '.env'); +if (fs.existsSync(envExample) && !fs.existsSync(envTarget)) { + fs.copyFileSync(envExample, envTarget); +} + +const pkgPath = path.join(root, 'package.json'); +const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')); + +for (const field of ['dependencies', 'devDependencies']) { + const deps = pkg[field]; + if (!deps) continue; + for (const [name, version] of Object.entries(deps)) { + if (version.startsWith('workspace:')) { + deps[name] = 'latest'; + } + } +} + +fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');