@mnemom/mnemom 0.16.1 → 0.16.2
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/commands/try-me.js +7 -1
- package/dist/lib/config.d.ts +2 -0
- package/dist/lib/config.js +19 -3
- package/package.json +1 -1
package/dist/commands/try-me.js
CHANGED
|
@@ -28,7 +28,7 @@ import { putAlignmentCard, putProtectionCard, listOrgAgents, MnemomApiError } fr
|
|
|
28
28
|
import { resolveAuth, loginWithBrowser, loginWithDeviceFlow } from "../lib/auth.js";
|
|
29
29
|
import { openBrowser } from "../lib/oauth.js";
|
|
30
30
|
import { askSelect, askInput, askYesNo, isInteractive } from "../lib/prompt.js";
|
|
31
|
-
import { getApiUrl } from "../lib/config.js";
|
|
31
|
+
import { getApiUrl, setApiUrlOverride } from "../lib/config.js";
|
|
32
32
|
import { fmt } from "../lib/format.js";
|
|
33
33
|
const POLL_INTERVAL_MS = 3000;
|
|
34
34
|
/**
|
|
@@ -58,6 +58,12 @@ export async function tryMeCommand(token, options = {}) {
|
|
|
58
58
|
throw new Error(`'${token}' doesn't look like a try-me token (expected e.g. tryme_…). ` +
|
|
59
59
|
"Copy the token from your Dojo /try-me invite.");
|
|
60
60
|
}
|
|
61
|
+
// Point EVERY API surface for this run at the ring the operator chose via
|
|
62
|
+
// `--api` — including OAuth discovery + the one-click claim login, which
|
|
63
|
+
// otherwise fall back to getApiUrl()'s prod default and leak the sign-in to
|
|
64
|
+
// prod even though resolve/birth ran on the ring.
|
|
65
|
+
if (options.api)
|
|
66
|
+
setApiUrlOverride(options.api);
|
|
61
67
|
// ── State: resolve ────────────────────────────────────────────────────────
|
|
62
68
|
say(fmt.header("Mnemom Dojo — try-me"));
|
|
63
69
|
say();
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export type Environment = "production" | "staging" | "local";
|
|
|
13
13
|
* Defaults to production.
|
|
14
14
|
*/
|
|
15
15
|
export declare function getEnvironment(): Environment;
|
|
16
|
+
/** Override the active API base for this process (clears on undefined/empty). */
|
|
17
|
+
export declare function setApiUrlOverride(url: string | undefined): void;
|
|
16
18
|
export declare function getApiUrl(): string;
|
|
17
19
|
export declare function getGatewayUrl(): string;
|
|
18
20
|
export declare function getWebsiteUrl(): string;
|
package/dist/lib/config.js
CHANGED
|
@@ -34,12 +34,28 @@ export function getEnvironment() {
|
|
|
34
34
|
return env;
|
|
35
35
|
return "production";
|
|
36
36
|
}
|
|
37
|
+
// Process-level base overrides. MNEMOM_ENV only selects prod/staging/local;
|
|
38
|
+
// to target an arbitrary ring (preview/us-1, test) a command can set an
|
|
39
|
+
// explicit override (e.g. `try-me --api <ring>`) or the operator can export
|
|
40
|
+
// MNEMOM_API_URL / MNEMOM_GATEWAY_URL / MNEMOM_WEBSITE_URL. Crucially these
|
|
41
|
+
// flow through EVERY surface — including OAuth discovery + the one-click claim
|
|
42
|
+
// login — so a non-prod ring's sign-in no longer falls back to the prod AS.
|
|
43
|
+
let apiUrlOverride;
|
|
44
|
+
/** Override the active API base for this process (clears on undefined/empty). */
|
|
45
|
+
export function setApiUrlOverride(url) {
|
|
46
|
+
const trimmed = url?.trim().replace(/\/+$/, "");
|
|
47
|
+
apiUrlOverride = trimmed || undefined;
|
|
48
|
+
}
|
|
49
|
+
function envBase(name) {
|
|
50
|
+
const v = process.env[name]?.trim();
|
|
51
|
+
return v ? v.replace(/\/+$/, "") : undefined;
|
|
52
|
+
}
|
|
37
53
|
export function getApiUrl() {
|
|
38
|
-
return API_URLS[getEnvironment()];
|
|
54
|
+
return apiUrlOverride ?? envBase("MNEMOM_API_URL") ?? API_URLS[getEnvironment()];
|
|
39
55
|
}
|
|
40
56
|
export function getGatewayUrl() {
|
|
41
|
-
return GATEWAY_URLS[getEnvironment()];
|
|
57
|
+
return envBase("MNEMOM_GATEWAY_URL") ?? GATEWAY_URLS[getEnvironment()];
|
|
42
58
|
}
|
|
43
59
|
export function getWebsiteUrl() {
|
|
44
|
-
return WEBSITE_URLS[getEnvironment()];
|
|
60
|
+
return envBase("MNEMOM_WEBSITE_URL") ?? WEBSITE_URLS[getEnvironment()];
|
|
45
61
|
}
|