@raybase/cli 0.3.10 → 0.3.12
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/index.js +28 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -53,7 +53,7 @@ const FRAMEWORK_HELP = `Frameworks (each has a built-in starter):
|
|
|
53
53
|
// through the pro plugin (reapplyProSkillsOverlay).
|
|
54
54
|
const PRO_PROJECT_COMMANDS = new Set(["doctor", "check", "jobs", "ai", "retrieval", "search", "migrate", "dev", "connect", "deploy", "backup", "backups", "export", "restore", "invite", "update", "modules"]);
|
|
55
55
|
const PRO_NAMESPACE_DELEGATE_COMMANDS = new Set(["upgrade", "provision", "skills", "attach", "install", "control-plane", "dev", "deploy"]);
|
|
56
|
-
const CLI_VERSION = "0.3.
|
|
56
|
+
const CLI_VERSION = "0.3.12";
|
|
57
57
|
// Pro's package took its own scope in 0.3.4. An app made before then declares
|
|
58
58
|
// the old name; the CLI finds Pro under either, and doctor says which to move to.
|
|
59
59
|
const PRO_PACKAGE = "@raybase-pro/pro";
|
|
@@ -2103,7 +2103,7 @@ program
|
|
|
2103
2103
|
.action(async (options) => {
|
|
2104
2104
|
if (!options.owner)
|
|
2105
2105
|
throw new Error("Only --owner is supported by this command in the MVP.");
|
|
2106
|
-
const authSecret =
|
|
2106
|
+
const authSecret = ownerLinkSecret(process.cwd(), String(options.url));
|
|
2107
2107
|
// recovery: true lets this deliberately minted link claim ownership even
|
|
2108
2108
|
// when an owner already exists (locked-out owner recovery). Routine
|
|
2109
2109
|
// deploy links stay non-recovery and are rejected once an owner exists.
|
|
@@ -9337,6 +9337,32 @@ function readPackageName(cwd) {
|
|
|
9337
9337
|
function normalizePath(path) {
|
|
9338
9338
|
return path.startsWith("/") ? path : `/${path}`;
|
|
9339
9339
|
}
|
|
9340
|
+
// The secret an owner link must be signed with is the one the app at that
|
|
9341
|
+
// address checks: the local dev Worker reads BETTER_AUTH_SECRET from
|
|
9342
|
+
// .dev.vars, and a deployed app was given .raybase/better-auth-secret by
|
|
9343
|
+
// raybase deploy. Neither is ever made up here; a link signed with a secret
|
|
9344
|
+
// the app doesn't hold would only be refused (Northflare's RCR-34).
|
|
9345
|
+
function ownerLinkSecret(cwd, url) {
|
|
9346
|
+
let hostname;
|
|
9347
|
+
try {
|
|
9348
|
+
hostname = new URL(url).hostname.toLowerCase().replace(/^\[(.*)\]$/, "$1");
|
|
9349
|
+
}
|
|
9350
|
+
catch {
|
|
9351
|
+
throw new Error(`--url must be the app's address, such as http://localhost:8787 (got ${JSON.stringify(url)}).`);
|
|
9352
|
+
}
|
|
9353
|
+
const local = hostname === "localhost" || hostname.endsWith(".localhost") || hostname === "::1" || /^127(?:\.\d{1,3}){3}$/.test(hostname);
|
|
9354
|
+
if (local) {
|
|
9355
|
+
const secret = readDevVars(cwd).BETTER_AUTH_SECRET;
|
|
9356
|
+
if (!secret)
|
|
9357
|
+
throw new Error("The local app's BETTER_AUTH_SECRET is not in .dev.vars, which the local dev Worker checks owner links with. Run raybase dev once, or add it there, then mint the link again.");
|
|
9358
|
+
return secret;
|
|
9359
|
+
}
|
|
9360
|
+
const file = join(cwd, ".raybase", "better-auth-secret");
|
|
9361
|
+
if (!existsSync(file)) {
|
|
9362
|
+
throw new Error(`This machine does not hold the auth secret the app at ${url} checks owner links with (.raybase/better-auth-secret, written by raybase deploy). Mint the link where the app was deployed from.`);
|
|
9363
|
+
}
|
|
9364
|
+
return readFileSync(file, "utf8").trim();
|
|
9365
|
+
}
|
|
9340
9366
|
function ensureAuthSecret(cwd) {
|
|
9341
9367
|
const dir = join(cwd, ".raybase");
|
|
9342
9368
|
const file = join(dir, "better-auth-secret");
|