mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-15 22:38:47 +00:00
/api/file/upload Endpoint에서의 dekVersion 제한 완화 및 파일 업로드 중 페이지를 떠나려는 경우 경고 표시 기능 구현
dekVersion의 경우, Request를 받은 시점으로부터 하루 전 ~ 1분 후 사이에 있어야 하도록 완화했습니다. 기존에는 1분 전 ~ 1분 후 사이에 있어야 했습니다. 파일을 한 번에 업로드하는 경우 오류가 발생하는 것을 방지하기 위한 조치입니다.
This commit is contained in:
@@ -97,9 +97,9 @@ export const uploadFile = async (
|
|||||||
params: Omit<NewFileParams, "path">,
|
params: Omit<NewFileParams, "path">,
|
||||||
encContentStream: Readable,
|
encContentStream: Readable,
|
||||||
) => {
|
) => {
|
||||||
const oneMinuteAgo = new Date(Date.now() - 60 * 1000);
|
const oneDayAgo = new Date(Date.now() - 24 * 60 * 60 * 1000);
|
||||||
const oneMinuteLater = new Date(Date.now() + 60 * 1000);
|
const oneMinuteLater = new Date(Date.now() + 60 * 1000);
|
||||||
if (params.dekVersion <= oneMinuteAgo || params.dekVersion >= oneMinuteLater) {
|
if (params.dekVersion <= oneDayAgo || params.dekVersion >= oneMinuteLater) {
|
||||||
error(400, "Invalid DEK version");
|
error(400, "Invalid DEK version");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,28 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
|
import { get } from "svelte/store";
|
||||||
import { goto as svelteGoto } from "$app/navigation";
|
import { goto as svelteGoto } from "$app/navigation";
|
||||||
import { clientKeyStore, masterKeyStore } from "$lib/stores";
|
import { fileUploadStatusStore, clientKeyStore, masterKeyStore } from "$lib/stores";
|
||||||
import "../app.css";
|
import "../app.css";
|
||||||
|
|
||||||
let { children } = $props();
|
let { children } = $props();
|
||||||
|
|
||||||
|
const checkFileUploadStatus = (e: BeforeUnloadEvent) => {
|
||||||
|
if (
|
||||||
|
$fileUploadStatusStore.some((statusStore) => {
|
||||||
|
const status = get(statusStore);
|
||||||
|
return (
|
||||||
|
status.status === "encryption-pending" ||
|
||||||
|
status.status === "encrypting" ||
|
||||||
|
status.status === "upload-pending" ||
|
||||||
|
status.status === "uploading"
|
||||||
|
);
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
const goto = async (url: string) => {
|
const goto = async (url: string) => {
|
||||||
const whitelist = ["/auth/login", "/key", "/client/pending"];
|
const whitelist = ["/auth/login", "/key", "/client/pending"];
|
||||||
@@ -24,4 +41,6 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<svelte:window onbeforeunload={checkFileUploadStatus} />
|
||||||
|
|
||||||
{@render children()}
|
{@render children()}
|
||||||
|
|||||||
Reference in New Issue
Block a user