@buildinternet/uploads 0.46.2 → 0.46.3
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/login.d.ts +4 -4
- package/dist/commands/login.js +5 -5
- package/dist/config.d.ts +8 -1
- package/dist/config.js +10 -3
- package/dist/session-cli-version.js +1 -1
- package/package.json +1 -1
package/dist/commands/login.d.ts
CHANGED
|
@@ -17,10 +17,10 @@ export declare function resolveEnrollmentCode(parsed: ReturnType<typeof parseCom
|
|
|
17
17
|
hiddenPrompt: () => Promise<string>;
|
|
18
18
|
}): Promise<string>;
|
|
19
19
|
/**
|
|
20
|
-
* Auth
|
|
21
|
-
*
|
|
22
|
-
* auth runs on a different loopback port
|
|
23
|
-
* --auth-url / UPLOADS_AUTH_URL.
|
|
20
|
+
* Auth base URL: explicit flag > UPLOADS_AUTH_URL > derived from the API base
|
|
21
|
+
* (`api.<domain>` → `<domain>`, same-origin auth since #731) > the production
|
|
22
|
+
* default. Local multi-worker dev (where auth runs on a different loopback port
|
|
23
|
+
* than the API) needs an explicit --auth-url / UPLOADS_AUTH_URL.
|
|
24
24
|
*/
|
|
25
25
|
export declare function resolveAuthUrl(parsed: ReturnType<typeof parseCommandArgs>, apiUrl: string): string;
|
|
26
26
|
export interface DeviceLoginIo {
|
package/dist/commands/login.js
CHANGED
|
@@ -25,7 +25,7 @@ Options:
|
|
|
25
25
|
--scopes <list> Comma-separated scopes (default:
|
|
26
26
|
files:read,files:write,files:delete)
|
|
27
27
|
--label <text> Token label (default: this machine's hostname)
|
|
28
|
-
--auth-url <url> Auth base (default: https://
|
|
28
|
+
--auth-url <url> Auth base (default: https://uploads.sh)
|
|
29
29
|
--no-open Don't try to open a browser automatically
|
|
30
30
|
--code <code> Fallback: use a pre-existing enrollment code instead of
|
|
31
31
|
device login (visible in shell history)
|
|
@@ -160,10 +160,10 @@ function hasEnrollmentSource(parsed) {
|
|
|
160
160
|
Boolean(process.env.UPLOADS_ENROLLMENT_CODE));
|
|
161
161
|
}
|
|
162
162
|
/**
|
|
163
|
-
* Auth
|
|
164
|
-
*
|
|
165
|
-
* auth runs on a different loopback port
|
|
166
|
-
* --auth-url / UPLOADS_AUTH_URL.
|
|
163
|
+
* Auth base URL: explicit flag > UPLOADS_AUTH_URL > derived from the API base
|
|
164
|
+
* (`api.<domain>` → `<domain>`, same-origin auth since #731) > the production
|
|
165
|
+
* default. Local multi-worker dev (where auth runs on a different loopback port
|
|
166
|
+
* than the API) needs an explicit --auth-url / UPLOADS_AUTH_URL.
|
|
167
167
|
*/
|
|
168
168
|
export function resolveAuthUrl(parsed, apiUrl) {
|
|
169
169
|
const explicit = flagString(parsed.flags, "--auth-url") ?? process.env.UPLOADS_AUTH_URL;
|
package/dist/config.d.ts
CHANGED
|
@@ -4,7 +4,14 @@ export interface UploadsClientConfig {
|
|
|
4
4
|
workspace: string;
|
|
5
5
|
token: string;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Derive the auth base URL from an API base. Since #731 the auth endpoints are
|
|
9
|
+
* served same-origin on the app origin (`<origin>/api/auth`, web proxies to the
|
|
10
|
+
* auth worker), not an `auth.` subdomain — so the canonical `api.<domain>`
|
|
11
|
+
* shape maps to its parent (`api.uploads.sh` → `uploads.sh`). Falls back to the
|
|
12
|
+
* production origin. Local multi-worker dev, where auth listens on a different
|
|
13
|
+
* loopback port, still needs an explicit `--auth-url` / `UPLOADS_AUTH_URL`.
|
|
14
|
+
*/
|
|
8
15
|
export declare function authUrlFromApi(apiUrl: string): string;
|
|
9
16
|
export declare const DEFAULT_API_URL = "https://api.uploads.sh";
|
|
10
17
|
export declare const DEFAULT_WORKSPACE = "default";
|
package/dist/config.js
CHANGED
|
@@ -2,19 +2,26 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
2
2
|
import { loadConfigFile, resolveConfigPath } from "./config-file.js";
|
|
3
3
|
import { UploadsError } from "./errors.js";
|
|
4
4
|
export { defaultConfigPath, resolveConfigPath, loadConfigFile, redactToken, writeConfigKeys, removeConfigKeys, configValuesFromClient, putDefaultsToConfigValues, resolvePutDefaults, mergePutDefaults, resolveScreenshotDefaults, UPLOADS_CONFIG_KEYS, } from "./config-file.js";
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Derive the auth base URL from an API base. Since #731 the auth endpoints are
|
|
7
|
+
* served same-origin on the app origin (`<origin>/api/auth`, web proxies to the
|
|
8
|
+
* auth worker), not an `auth.` subdomain — so the canonical `api.<domain>`
|
|
9
|
+
* shape maps to its parent (`api.uploads.sh` → `uploads.sh`). Falls back to the
|
|
10
|
+
* production origin. Local multi-worker dev, where auth listens on a different
|
|
11
|
+
* loopback port, still needs an explicit `--auth-url` / `UPLOADS_AUTH_URL`.
|
|
12
|
+
*/
|
|
6
13
|
export function authUrlFromApi(apiUrl) {
|
|
7
14
|
try {
|
|
8
15
|
const url = new URL(apiUrl);
|
|
9
16
|
if (url.hostname.startsWith("api.")) {
|
|
10
|
-
url.hostname =
|
|
17
|
+
url.hostname = url.hostname.slice(4);
|
|
11
18
|
return url.origin;
|
|
12
19
|
}
|
|
13
20
|
}
|
|
14
21
|
catch {
|
|
15
22
|
// fall through
|
|
16
23
|
}
|
|
17
|
-
return "https://
|
|
24
|
+
return "https://uploads.sh";
|
|
18
25
|
}
|
|
19
26
|
export const DEFAULT_API_URL = "https://api.uploads.sh";
|
|
20
27
|
export const DEFAULT_WORKSPACE = "default";
|
|
@@ -47,7 +47,7 @@ export async function syncSessionCliVersion(opts = {}) {
|
|
|
47
47
|
const apiUrl = opts.apiUrl ?? fromFile.UPLOADS_API_URL ?? process.env.UPLOADS_API_URL;
|
|
48
48
|
const authUrl = (opts.authUrl ??
|
|
49
49
|
process.env.UPLOADS_AUTH_URL ??
|
|
50
|
-
(apiUrl ? authUrlFromApi(apiUrl) : "https://
|
|
50
|
+
(apiUrl ? authUrlFromApi(apiUrl) : "https://uploads.sh")).replace(/\/$/, "");
|
|
51
51
|
const controller = new AbortController();
|
|
52
52
|
const timer = setTimeout(() => controller.abort(), POST_TIMEOUT_MS);
|
|
53
53
|
try {
|