@pplethai/cli 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pplethai/cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,12 +40,20 @@ import { PPLEMiniApp } from "@pplethai/pple-today-miniapp-sdk";
40
40
  // Production (Today or browser): sdk.init() → getAccessToken() → { kind: "signed-in" }
41
41
  ```
42
42
 
43
- OAuth client values (`VITE_OAUTH_URL`, `VITE_OAUTH_CLIENT_ID`,
44
- `VITE_OAUTH_REDIRECT_URI`) are provisioned per app and injected at build
45
- time — Builders do not register clients by hand. The redirect URI defaults
46
- to the app's own origin, which matches the mini-app URL the platform
47
- registers as an allowed redirect on that OAuth client
48
- (`docs/integration/today-sso-changes.md` §5).
43
+ OAuth client values are provisioned per app — Builders do not register
44
+ clients by hand. The SPA reads them at **build time** via Vite
45
+ (`VITE_OAUTH_URL`, `VITE_OAUTH_CLIENT_ID`), so the platform bakes them into
46
+ the `env:` block of the deploy workflow it owns in each app repo
47
+ (`.github/workflows/deploy.yml`), where `npm run build` can see them. Because
48
+ that workflow is reconciled on every deploy (ADR-0004), an app self-heals
49
+ these values on its next deploy. `VITE_OAUTH_REDIRECT_URI` is not baked in:
50
+ it defaults to the app's own origin (`window.location.origin`), which matches
51
+ the mini-app URL the platform registers as an allowed redirect on that OAuth
52
+ client (`docs/integration/today-sso-changes.md` §5).
53
+
54
+ A build that runs without `VITE_OAUTH_URL` set produces a bundle with an
55
+ empty `oauthUrl`; the template's `bootstrap()` catches that and shows an
56
+ "app is misconfigured" error instead of the raw `oidc-client-ts` failure.
49
57
 
50
58
  ## Worker: validating the token
51
59
 
@@ -9,8 +9,11 @@
9
9
  // / callback) and hands back an access token.
10
10
  import { PPLEMiniApp } from "@pplethai/pple-today-miniapp-sdk";
11
11
 
12
- // Provisioned per app, injected at build time. Needed for the SDK in both
13
- // PPLE Today and the browser (browser login uses the OIDC redirect flow).
12
+ // Provisioned per app and baked into this bundle at build time by the
13
+ // platform deploy workflow's env (VITE_OAUTH_URL / VITE_OAUTH_CLIENT_ID).
14
+ // Needed for the SDK in both PPLE Today and the browser (browser login uses
15
+ // the OIDC redirect flow). Empty here means the build var was missing —
16
+ // bootstrap() below turns that into a legible error.
14
17
  const OAUTH_URL = import.meta.env.VITE_OAUTH_URL ?? "";
15
18
  const OAUTH_CLIENT_ID = import.meta.env.VITE_OAUTH_CLIENT_ID ?? "";
16
19
  // Must match a redirect URI on the app's PPLE ID OAuth client. Provisioning
@@ -35,6 +38,19 @@ export async function bootstrap(): Promise<Bootstrap> {
35
38
  return { kind: "signed-in" };
36
39
  }
37
40
 
41
+ // The OAuth config is baked in at build time by the platform deploy
42
+ // workflow (VITE_OAUTH_URL / VITE_OAUTH_CLIENT_ID). If it's missing the
43
+ // SDK throws a bare "No authority or metadataUrl configured on settings"
44
+ // from oidc-client-ts — turn that into something a Builder can act on
45
+ // instead of a stack trace they can't read (issue #115).
46
+ if (!OAUTH_URL || !OAUTH_CLIENT_ID) {
47
+ return {
48
+ kind: "error",
49
+ message:
50
+ "This app is misconfigured: its PPLE ID sign-in settings were not set when it was built. Redeploy the app from the platform to fix it.",
51
+ };
52
+ }
53
+
38
54
  const sdk = new PPLEMiniApp({
39
55
  oauthUrl: OAUTH_URL,
40
56
  oauthClientId: OAUTH_CLIENT_ID,