fix(web): export showAuthScreen to window so topbar Login works

The Login button (onclick=window.showAuthScreen()) was dead — showAuthScreen
was defined but never exported via Object.assign. Also drop dead code from
the e2e suite (unused createReadStream import, unused s3StreamRequest).
This commit is contained in:
asepharyana
2026-08-01 20:34:22 +07:00
parent 2653e23283
commit 90d6c7dd6f
3 changed files with 3 additions and 47 deletions
+1 -1
View File
@@ -363,7 +363,7 @@
const init=async()=>{await checkAuth();await loadBuckets();};
document.getElementById('authLoginBtn').addEventListener('click',handleLogin);
document.getElementById('authTokenInput').addEventListener('keydown',e=>{if(e.key==='Enter')handleLogin();});
Object.assign(window, { switchBucket, navigateTo, debouncedSearch, downloadObject, copyLink, deleteObject, closeModal, showCreateBucketModal, createBucket, showCredentialsModal, logout });
Object.assign(window, { switchBucket, navigateTo, debouncedSearch, downloadObject, copyLink, deleteObject, closeModal, showCreateBucketModal, createBucket, showCredentialsModal, showAuthScreen, logout });
init();
</script>
</body>
+1 -1
View File
@@ -363,7 +363,7 @@
const init=async()=>{await checkAuth();await loadBuckets();};
document.getElementById('authLoginBtn').addEventListener('click',handleLogin);
document.getElementById('authTokenInput').addEventListener('keydown',e=>{if(e.key==='Enter')handleLogin();});
Object.assign(window, { switchBucket, navigateTo, debouncedSearch, downloadObject, copyLink, deleteObject, closeModal, showCreateBucketModal, createBucket, showCredentialsModal, logout });
Object.assign(window, { switchBucket, navigateTo, debouncedSearch, downloadObject, copyLink, deleteObject, closeModal, showCreateBucketModal, createBucket, showCredentialsModal, showAuthScreen, logout });
init();
</script>
</body>
+1 -45
View File
@@ -18,7 +18,7 @@
*/
import { afterAll, beforeAll, describe, expect, it } from 'bun:test';
import { createReadStream, existsSync } from 'node:fs';
import { existsSync } from 'node:fs';
// ── Config ───────────────────────────────────────────────────────────────────
const BASE_URL = process.env.BASE_URL || 'https://upload.asepharyana.my.id';
@@ -127,50 +127,6 @@ async function s3Request(
});
}
/**
* Issue a SigV4-signed S3 request with a streaming body using
* "UNSIGNED-PAYLOAD" so we don't need to load the entire file into
* memory to compute a SHA-256 hash.
*
* The server's verifyBodyHash() skips verification when the header
* value is "UNSIGNED-PAYLOAD". This lets us send large files without
* pre-computing the body hash.
*
* The body is sent as a ReadableStream, which triggers chunked
* transfer encoding. This avoids setting Content-Length, which helps
* bypass intermediate proxy limits.
*/
async function s3StreamRequest(
method: string,
path: string,
opts: {
stream: ReadableStream | NodeJS.ReadableStream;
query?: Record<string, string>;
extraHeaders?: Record<string, string>;
},
): Promise<Response> {
const url = new URL(path, BASE_URL);
if (opts.query) {
for (const [k, v] of Object.entries(opts.query)) url.searchParams.set(k, v);
}
const payloadHash = 'UNSIGNED-PAYLOAD';
const headers = s3Headers(
method,
url.host,
url.pathname,
url.searchParams.toString(),
payloadHash,
opts.extraHeaders,
);
// Omit Content-Type for streaming bodies so Bun uses chunked encoding
// and does not set Content-Length.
return fetch(url.toString(), {
method,
headers: { ...headers },
body: opts.stream,
});
}
// ── Web API helper ───────────────────────────────────────────────────────────
const api = (p: string) => `${BASE_URL}/api/v1${p}`;
const authHeaders: Record<string, string> = AUTH_TOKEN