From 90d6c7dd6fbba73e99fc025182142f775f4f011a Mon Sep 17 00:00:00 2001 From: asepharyana Date: Sat, 1 Aug 2026 20:34:22 +0700 Subject: [PATCH] fix(web): export showAuthScreen to window so topbar Login works MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- src/home.html | 2 +- src/interfaces/http/controllers/home.html | 2 +- test/production-e2e.test.ts | 46 +---------------------- 3 files changed, 3 insertions(+), 47 deletions(-) diff --git a/src/home.html b/src/home.html index 28f4019..8ddfd0a 100644 --- a/src/home.html +++ b/src/home.html @@ -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(); diff --git a/src/interfaces/http/controllers/home.html b/src/interfaces/http/controllers/home.html index 28f4019..8ddfd0a 100644 --- a/src/interfaces/http/controllers/home.html +++ b/src/interfaces/http/controllers/home.html @@ -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(); diff --git a/test/production-e2e.test.ts b/test/production-e2e.test.ts index 7d1f1d1..80bb52c 100644 --- a/test/production-e2e.test.ts +++ b/test/production-e2e.test.ts @@ -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; - extraHeaders?: Record; - }, -): Promise { - 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 = AUTH_TOKEN