Skip to content

Commit 2a2fa25

Browse files
ksroda-saclaude
andcommitted
UI quickstart improvements (AUT-13537)
- Remove VITE_ prefix from env vars for cleaner user experience - Use Vite define + loadEnv to explicitly expose unprefixed env vars - Clean up placeholder-map.yaml (remove unused process.env patterns) - Add run_command field to manifest and snippet extraction - Fix tsconfig types for Node.js in scripts Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3763038 commit 2a2fa25

10 files changed

Lines changed: 55 additions & 38 deletions

File tree

placeholder-map.yaml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,13 @@
33
# with generic {{PLACEHOLDER}} tokens in extracted snippets.
44

55
js:
6-
- pattern: "import.meta.env.VITE_ISSUER_URL"
6+
- pattern: "import.meta.env.ISSUER_URL"
77
placeholder: "{{ISSUER_URL}}"
8-
- pattern: "import.meta.env.VITE_CLIENT_ID"
8+
- pattern: "import.meta.env.CLIENT_ID"
99
placeholder: "{{CLIENT_ID}}"
10-
- pattern: "import.meta.env.VITE_REDIRECT_URI"
10+
- pattern: "import.meta.env.REDIRECT_URI"
1111
placeholder: "{{REDIRECT_URI}}"
12-
- pattern: "import.meta.env.VITE_SCOPES"
12+
- pattern: "import.meta.env.SCOPES"
1313
placeholder: "{{SCOPES}}"
14-
- pattern: "import.meta.env.VITE_POST_LOGOUT_URI"
14+
- pattern: "import.meta.env.POST_LOGOUT_URI"
1515
placeholder: "{{POST_LOGOUT_URI}}"
16-
- pattern: "process.env.REACT_APP_ISSUER_URL"
17-
placeholder: "{{ISSUER_URL}}"
18-
- pattern: "process.env.REACT_APP_CLIENT_ID"
19-
placeholder: "{{CLIENT_ID}}"
20-
- pattern: "process.env.REACT_APP_REDIRECT_URI"
21-
placeholder: "{{REDIRECT_URI}}"
22-
- pattern: "process.env.SA_ISSUER_URL"
23-
placeholder: "{{ISSUER_URL}}"
24-
- pattern: "process.env.SA_CLIENT_ID"
25-
placeholder: "{{CLIENT_ID}}"
26-
- pattern: "process.env.SA_CLIENT_SECRET"
27-
placeholder: "{{CLIENT_SECRET}}"
28-
- pattern: "process.env.SA_REDIRECT_URI"
29-
placeholder: "{{REDIRECT_URI}}"
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
VITE_ISSUER_URL=https://your-tenant.us.secureauth.com/your-workspace
2-
VITE_CLIENT_ID=your-client-id
3-
VITE_REDIRECT_URI=http://localhost:3000/callback
4-
VITE_POST_LOGOUT_URI=http://localhost:3000
5-
VITE_SCOPES=openid profile email
1+
ISSUER_URL=https://your-tenant.us.secureauth.com/your-workspace
2+
CLIENT_ID=your-client-id
3+
REDIRECT_URI=http://localhost:3000/callback
4+
POST_LOGOUT_URI=http://localhost:3000
5+
SCOPES=openid profile email

samples/react/login-pkce/src/App.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { AuthProvider, useAuth } from "react-oidc-context";
66
// @snippet:step2:start
77
// @description Configure the OIDC client with your SecureAuth app settings
88
const oidcConfig = {
9-
authority: import.meta.env.VITE_ISSUER_URL,
10-
client_id: import.meta.env.VITE_CLIENT_ID,
11-
redirect_uri: import.meta.env.VITE_REDIRECT_URI,
12-
post_logout_redirect_uri: import.meta.env.VITE_POST_LOGOUT_URI,
13-
scope: import.meta.env.VITE_SCOPES,
9+
authority: import.meta.env.ISSUER_URL,
10+
client_id: import.meta.env.CLIENT_ID,
11+
redirect_uri: import.meta.env.REDIRECT_URI,
12+
post_logout_redirect_uri: import.meta.env.POST_LOGOUT_URI,
13+
scope: import.meta.env.SCOPES,
1414
};
1515
// @snippet:step2:end
1616

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
import react from "@vitejs/plugin-react";
2-
import { defineConfig } from "vite";
2+
import { defineConfig, loadEnv } from "vite";
33

4-
export default defineConfig({
5-
plugins: [react()],
6-
server: {
7-
port: 3000,
8-
},
4+
const exposedEnvVars = [
5+
"ISSUER_URL",
6+
"CLIENT_ID",
7+
"REDIRECT_URI",
8+
"POST_LOGOUT_URI",
9+
"SCOPES",
10+
];
11+
12+
export default defineConfig(({ mode }) => {
13+
const env = loadEnv(mode, process.cwd(), "");
14+
return {
15+
plugins: [react()],
16+
define: Object.fromEntries(
17+
exposedEnvVars.map((key) => [
18+
`import.meta.env.${key}`,
19+
JSON.stringify(env[key]),
20+
]),
21+
),
22+
server: {
23+
port: 3000,
24+
},
25+
};
926
});

samples/react/manifest.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ scenarios:
1111
grant: "Auth Code + PKCE"
1212
description: "Redirect users to SecureAuth for login. PKCE protects against code interception."
1313
callout: "Uses PKCE — no client secret needed. The browser generates a code_verifier/code_challenge pair."
14+
run_command: "yarn install && yarn dev"
1415
config_rows:
1516
- label: "Client ID"
1617
value: "{{CLIENT_ID}}"

scripts/aggregate-manifests.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface ScenarioManifest {
1616
description: string;
1717
callout?: string;
1818
extends?: string;
19+
run_command?: string;
1920
config_rows: ConfigRow[];
2021
}
2122

scripts/extract-snippets.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ interface FrameworkSnippet {
2929
lib_version: string;
3030
install: string;
3131
repo_path: string;
32+
run_command?: string;
33+
}
34+
35+
interface ScenarioMeta {
36+
run_command?: string;
37+
[key: string]: unknown;
3238
}
3339

3440
interface FrameworkManifest {
@@ -37,7 +43,7 @@ interface FrameworkManifest {
3743
lang: string;
3844
lib: string;
3945
docs_url: string;
40-
scenarios: Record<string, unknown>;
46+
scenarios: Record<string, ScenarioMeta>;
4147
}
4248

4349
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
@@ -207,6 +213,9 @@ async function main() {
207213
lib_version: getLibVersion(scenarioDir, frameworkDir),
208214
install: getInstallCommand(scenarioDir),
209215
repo_path: `samples/${path.relative(SAMPLES, scenarioDir)}`,
216+
...(manifest.scenarios[scenarioId]?.run_command && {
217+
run_command: manifest.scenarios[scenarioId].run_command,
218+
}),
210219
};
211220
}
212221
}

scripts/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"esModuleInterop": true,
88
"skipLibCheck": true,
99
"outDir": "dist",
10-
"resolveJsonModule": true
10+
"resolveJsonModule": true,
11+
"types": ["node"]
1112
},
1213
"include": ["*.ts"]
1314
}

snippet-manifest.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ scenarios:
1212
grant: Auth Code + PKCE
1313
description: Redirect users to SecureAuth for login. PKCE protects against code interception.
1414
callout: Uses PKCE — no client secret needed. The browser generates a code_verifier/code_challenge pair.
15+
run_command: yarn install && yarn dev
1516
config_rows:
1617
- label: Client ID
1718
value: "{{CLIENT_ID}}"

snippets.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"lib": "react-oidc-context",
4040
"lib_version": "3.3.1",
4141
"install": "oidc-client-ts react-oidc-context",
42-
"repo_path": "samples/react/login-pkce"
42+
"repo_path": "samples/react/login-pkce",
43+
"run_command": "yarn install && yarn dev"
4344
}
4445
}
4546
}

0 commit comments

Comments
 (0)