@pplethai/cli 0.1.0 → 0.2.0
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/dist/deps.js
CHANGED
|
@@ -3,7 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
export const DEFAULT_CONFIG = {
|
|
5
5
|
apiBase: "https://api.ppleth.ai",
|
|
6
|
-
ssoBase: "https://
|
|
6
|
+
ssoBase: "https://id.peoplesparty.or.th",
|
|
7
7
|
clientId: "382216793067947795",
|
|
8
8
|
repoBase: "https://github.com",
|
|
9
9
|
registryBase: "https://registry.npmjs.org",
|
package/dist/device-flow.js
CHANGED
|
@@ -18,17 +18,24 @@ function form(fields) {
|
|
|
18
18
|
body: new URLSearchParams(fields).toString(),
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Name the host we failed to reach. "Check your internet connection" sends a
|
|
23
|
+
* Builder to their wifi when the real fault is a bad `ssoBase` — the host it
|
|
24
|
+
* couldn't reach is the one fact that tells the two apart.
|
|
25
|
+
*/
|
|
26
|
+
function unreachable(ssoBase) {
|
|
27
|
+
return new CliError(`Couldn't reach PPLE ID (${ssoBase}) to sign you in.`, "Check your internet connection and try `pple auth login` again.");
|
|
28
|
+
}
|
|
22
29
|
export async function requestDeviceCode(deps) {
|
|
23
30
|
const { ssoBase, clientId } = deps.config;
|
|
24
31
|
const res = await deps
|
|
25
32
|
.fetch(`${ssoBase}${DEVICE_AUTHORIZATION_PATH}`, form({ client_id: clientId, scope: SCOPES }))
|
|
26
33
|
.catch(() => null);
|
|
27
34
|
if (!res || !res.ok)
|
|
28
|
-
throw
|
|
35
|
+
throw unreachable(ssoBase);
|
|
29
36
|
const body = (await res.json().catch(() => ({})));
|
|
30
37
|
if (!body.device_code || !body.user_code || !body.verification_uri) {
|
|
31
|
-
throw
|
|
38
|
+
throw unreachable(ssoBase);
|
|
32
39
|
}
|
|
33
40
|
return {
|
|
34
41
|
deviceCode: body.device_code,
|
|
@@ -59,7 +66,7 @@ export async function awaitToken(deps, device) {
|
|
|
59
66
|
}))
|
|
60
67
|
.catch(() => null);
|
|
61
68
|
if (!res)
|
|
62
|
-
throw
|
|
69
|
+
throw unreachable(ssoBase);
|
|
63
70
|
const body = (await res.json().catch(() => ({})));
|
|
64
71
|
if (res.ok && body.access_token)
|
|
65
72
|
return toTokenSet(deps, body);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# These are the app's PPLE ID OIDC client details, used by the mini-app SDK
|
|
3
3
|
# when running inside PPLE Today. They are public values, safe to ship.
|
|
4
4
|
# The platform injects them at deploy time; copy to `.env` to set locally.
|
|
5
|
-
VITE_OAUTH_URL="https://
|
|
5
|
+
VITE_OAUTH_URL="https://id.peoplesparty.or.th"
|
|
6
6
|
VITE_OAUTH_CLIENT_ID=""
|
|
7
7
|
# Defaults to the app's own origin if unset.
|
|
8
8
|
# VITE_OAUTH_REDIRECT_URI=""
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
|
|
40
40
|
"vars": {
|
|
41
41
|
// PPLE ID (identity). The Worker validates bearer tokens against this.
|
|
42
|
-
"SSO_BASE_URL": "https://
|
|
42
|
+
"SSO_BASE_URL": "https://id.peoplesparty.or.th",
|
|
43
43
|
// Audience-bound notification endpoint (see src/notify.ts): the base that
|
|
44
44
|
// `${NOTIFY_API_BASE}/notifications` is posted to. The platform sets the
|
|
45
45
|
// real value; empty locally so notify is a no-op unless you wire it up in
|