From 57c66f40970198be488b2954da4925207c538a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=80=E4=B9=8B?= Date: Sun, 22 Mar 2026 11:18:48 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=20WebDA?= =?UTF-8?q?V=20=E5=90=8C=E6=AD=A5=E8=AF=B7=E6=B1=82=E6=90=BA=E5=B8=A6?= =?UTF-8?q?=E6=B5=8F=E8=A7=88=E5=99=A8=20cookies=20=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=E5=86=B2=E7=AA=81=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#1297)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/filesystem/webdav/webdav.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/filesystem/webdav/webdav.ts b/packages/filesystem/webdav/webdav.ts index a3dde3e86..c019256cf 100644 --- a/packages/filesystem/webdav/webdav.ts +++ b/packages/filesystem/webdav/webdav.ts @@ -1,11 +1,17 @@ import type { AuthType, FileStat, WebDAVClient } from "webdav"; -import { createClient } from "webdav"; +import { createClient, getPatcher } from "webdav"; import type FileSystem from "../filesystem"; import type { FileInfo, FileCreateOptions, FileReader, FileWriter } from "../filesystem"; import { joinPath } from "../utils"; import { WebDAVFileReader, WebDAVFileWriter } from "./rw"; import { WarpTokenError } from "../error"; +// 禁止 WebDAV 请求携带浏览器 cookies,只通过账号密码认证 (#1297) +getPatcher().patch("fetch", (...args: unknown[]) => { + const options = (args[1] as RequestInit) || {}; + return fetch(args[0] as RequestInfo | URL, { ...options, credentials: "omit" }); +}); + export default class WebDAVFileSystem implements FileSystem { client: WebDAVClient; From 804601b72edd6d417f1addb2a1a0286d632a2040 Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Sun, 22 Mar 2026 12:38:53 +0900 Subject: [PATCH 02/12] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/filesystem/webdav/webdav.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/filesystem/webdav/webdav.ts b/packages/filesystem/webdav/webdav.ts index c019256cf..8453451d1 100644 --- a/packages/filesystem/webdav/webdav.ts +++ b/packages/filesystem/webdav/webdav.ts @@ -7,10 +7,20 @@ import { WebDAVFileReader, WebDAVFileWriter } from "./rw"; import { WarpTokenError } from "../error"; // 禁止 WebDAV 请求携带浏览器 cookies,只通过账号密码认证 (#1297) -getPatcher().patch("fetch", (...args: unknown[]) => { - const options = (args[1] as RequestInit) || {}; - return fetch(args[0] as RequestInfo | URL, { ...options, credentials: "omit" }); -}); +// 全局单次注册 +let webDavPatched = false; +const initWebDAVPatch = () => { + webDavPatched = true; + return getPatcher().patch("fetch", (...args: unknown[]) => { + const options = (args[1] as RequestInit) || {}; + const headers = new Headers((options.headers as HeadersInit) || {}); + return fetch(args[0] as RequestInfo | URL, { + ...options, + headers, + credentials: "omit", + }); + }); +}; export default class WebDAVFileSystem implements FileSystem { client: WebDAVClient; @@ -26,6 +36,7 @@ export default class WebDAVFileSystem implements FileSystem { this.url = username!; } else { this.url = url!; + if (!webDavPatched) initWebDAVPatch(); this.client = createClient(url!, { authType, username, From 6669b42f51a3c8895ad8c3063abedba44577a4a6 Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Sun, 22 Mar 2026 12:39:43 +0900 Subject: [PATCH 03/12] webDavPatched -> patched --- packages/filesystem/webdav/webdav.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/filesystem/webdav/webdav.ts b/packages/filesystem/webdav/webdav.ts index 8453451d1..de8463aae 100644 --- a/packages/filesystem/webdav/webdav.ts +++ b/packages/filesystem/webdav/webdav.ts @@ -8,9 +8,9 @@ import { WarpTokenError } from "../error"; // 禁止 WebDAV 请求携带浏览器 cookies,只通过账号密码认证 (#1297) // 全局单次注册 -let webDavPatched = false; +let patched = false; const initWebDAVPatch = () => { - webDavPatched = true; + patched = true; return getPatcher().patch("fetch", (...args: unknown[]) => { const options = (args[1] as RequestInit) || {}; const headers = new Headers((options.headers as HeadersInit) || {}); @@ -36,7 +36,7 @@ export default class WebDAVFileSystem implements FileSystem { this.url = username!; } else { this.url = url!; - if (!webDavPatched) initWebDAVPatch(); + if (!patched) initWebDAVPatch(); this.client = createClient(url!, { authType, username, From bdae0411af7723a1b301cd5a21ccb9318b60feef Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Sun, 22 Mar 2026 13:01:38 +0900 Subject: [PATCH 04/12] =?UTF-8?q?webdav.ts:=20=E4=BF=AE=E6=AD=A3=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=E4=BB=A3=E7=A0=81=E5=86=99=E6=B3=95=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/filesystem/factory.ts | 2 +- packages/filesystem/webdav/webdav.ts | 48 ++++++++++++++++------------ 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/packages/filesystem/factory.ts b/packages/filesystem/factory.ts index bdeb26e16..083df1185 100644 --- a/packages/filesystem/factory.ts +++ b/packages/filesystem/factory.ts @@ -27,7 +27,7 @@ export default class FileSystemFactory { fs = new ZipFileSystem(params); break; case "webdav": - fs = new WebDAVFileSystem(params.authType, params.url, params.username, params.password); + fs = WebDAVFileSystem.fromCredentials(params.url, params.authType, params.username, params.password); break; case "baidu-netdsik": fs = new BaiduFileSystem(); diff --git a/packages/filesystem/webdav/webdav.ts b/packages/filesystem/webdav/webdav.ts index de8463aae..d8bdbcf9f 100644 --- a/packages/filesystem/webdav/webdav.ts +++ b/packages/filesystem/webdav/webdav.ts @@ -8,9 +8,10 @@ import { WarpTokenError } from "../error"; // 禁止 WebDAV 请求携带浏览器 cookies,只通过账号密码认证 (#1297) // 全局单次注册 -let patched = false; +let patchInited = false; const initWebDAVPatch = () => { - patched = true; + if (patchInited) return; + patchInited = true; return getPatcher().patch("fetch", (...args: unknown[]) => { const options = (args[1] as RequestInit) || {}; const headers = new Headers((options.headers as HeadersInit) || {}); @@ -29,30 +30,29 @@ export default class WebDAVFileSystem implements FileSystem { basePath: string = "/"; - constructor(authType: AuthType | WebDAVClient, url?: string, username?: string, password?: string) { - if (typeof authType === "object") { - this.client = authType; - this.basePath = joinPath(url || ""); - this.url = username!; - } else { - this.url = url!; - if (!patched) initWebDAVPatch(); - this.client = createClient(url!, { - authType, - username, - password, - }); - } + static fromCredentials(url: string, authType: AuthType, username: string, password: string) { + return new WebDAVFileSystem(createClient(url, { authType, username, password }), url, "/"); + } + + static fromSameClient(fs: WebDAVFileSystem, basePath: string = "/") { + return new WebDAVFileSystem(fs.client, fs.url, basePath); + } + + private constructor(client: WebDAVClient, url: string, basePath: string) { + initWebDAVPatch(); + this.client = client; + this.url = url; + this.basePath = basePath; } async verify(): Promise { try { await this.client.getQuota(); } catch (e: any) { - if (e.response && e.response.status === 401) { + if (e.response?.status === 401) { throw new WarpTokenError(e); } - throw new Error("verify failed"); + throw new Error(`WebDAV verify failed: ${e.message}`); // 保留原始信息 } } @@ -61,7 +61,7 @@ export default class WebDAVFileSystem implements FileSystem { } async openDir(path: string): Promise { - return new WebDAVFileSystem(this.client, joinPath(this.basePath, path), this.url); + return WebDAVFileSystem.fromSameClient(this, joinPath(this.basePath, path)); } async create(path: string, _opts?: FileCreateOptions): Promise { @@ -73,7 +73,7 @@ export default class WebDAVFileSystem implements FileSystem { await this.client.createDirectory(joinPath(this.basePath, path)); } catch (e: any) { // 如果是405错误,则忽略 - if (e.message.includes("405")) { + if (e.response?.status === 405 || e.message?.includes("405")) { return; } throw e; @@ -85,7 +85,13 @@ export default class WebDAVFileSystem implements FileSystem { } async list(): Promise { - const dir = (await this.client.getDirectoryContents(this.basePath)) as FileStat[]; + let dir: FileStat[]; + try { + dir = (await this.client.getDirectoryContents(this.basePath)) as FileStat[]; + } catch (e: any) { + if (e.response?.status === 404) return [] as FileInfo[]; // 目录不存在视为空 + throw e; + } const ret: FileInfo[] = []; for (const item of dir) { if (item.type !== "file") { From 875ea6c36ccfc56e932773c18246296dc69b0b89 Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Sun, 22 Mar 2026 13:03:23 +0900 Subject: [PATCH 05/12] =?UTF-8?q?=E6=AC=A1=E5=BA=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/filesystem/webdav/webdav.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/filesystem/webdav/webdav.ts b/packages/filesystem/webdav/webdav.ts index d8bdbcf9f..855aeb404 100644 --- a/packages/filesystem/webdav/webdav.ts +++ b/packages/filesystem/webdav/webdav.ts @@ -31,6 +31,7 @@ export default class WebDAVFileSystem implements FileSystem { basePath: string = "/"; static fromCredentials(url: string, authType: AuthType, username: string, password: string) { + initWebDAVPatch(); return new WebDAVFileSystem(createClient(url, { authType, username, password }), url, "/"); } @@ -39,7 +40,6 @@ export default class WebDAVFileSystem implements FileSystem { } private constructor(client: WebDAVClient, url: string, basePath: string) { - initWebDAVPatch(); this.client = client; this.url = url; this.basePath = basePath; From 2b84cd333d6df902dfaab812bc741230dcb9c942 Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Sun, 22 Mar 2026 13:05:25 +0900 Subject: [PATCH 06/12] Update webdav.ts --- packages/filesystem/webdav/webdav.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/filesystem/webdav/webdav.ts b/packages/filesystem/webdav/webdav.ts index 855aeb404..f8b93966e 100644 --- a/packages/filesystem/webdav/webdav.ts +++ b/packages/filesystem/webdav/webdav.ts @@ -35,7 +35,7 @@ export default class WebDAVFileSystem implements FileSystem { return new WebDAVFileSystem(createClient(url, { authType, username, password }), url, "/"); } - static fromSameClient(fs: WebDAVFileSystem, basePath: string = "/") { + static fromSameClient(fs: WebDAVFileSystem, basePath: string) { return new WebDAVFileSystem(fs.client, fs.url, basePath); } From e79a233dedf4a7fa05789bf03d42b190289a8935 Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Sun, 22 Mar 2026 13:49:29 +0900 Subject: [PATCH 07/12] =?UTF-8?q?=E5=8A=A0=E5=85=A5=20visibilityFor=20?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3UI=E6=98=BE=E7=A4=BA=EF=BC=8C=E5=AE=9E?= =?UTF-8?q?=E4=BD=9C=20token=20=E5=92=8C=20none=20=E7=AD=89=20authType?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/filesystem/factory.ts | 32 ++++- packages/filesystem/webdav/webdav.ts | 13 +- .../components/FileSystemParams/index.tsx | 112 ++++++++++-------- 3 files changed, 99 insertions(+), 58 deletions(-) diff --git a/packages/filesystem/factory.ts b/packages/filesystem/factory.ts index 083df1185..651b81e9a 100644 --- a/packages/filesystem/factory.ts +++ b/packages/filesystem/factory.ts @@ -16,18 +16,43 @@ export type FileSystemParams = { title: string; type?: "select" | "authorize" | "password"; options?: string[]; + visibilityFor?: string[]; }; }; export default class FileSystemFactory { static create(type: FileSystemType, params: any): Promise { let fs: FileSystem; + let options; switch (type) { case "zip": fs = new ZipFileSystem(params); break; case "webdav": - fs = WebDAVFileSystem.fromCredentials(params.url, params.authType, params.username, params.password); + /* + Auto = "auto", + Digest = "digest", // 需要避免密码直接传输 + None = "none", // 公开资源 / 自定义认证 + Password = "password", // 普通 WebDAV 服务,需要确保 HTTPS / Nextcloud 生产环境 + Token = "token" // OAuth2 / 现代云服务 / Nextcloud 生产环境 + */ + if (params.authType === "none") { + options = { + authType: params.authType, + }; + } else if (params.authType === "token") { + options = { + authType: params.authType, + token: params.token, + }; + } else { + options = { + authType: params.authType || "auto", + username: params.username, + password: params.password, + }; + } + fs = WebDAVFileSystem.fromCredentials(params.url, options); break; case "baidu-netdsik": fs = new BaiduFileSystem(); @@ -66,8 +91,9 @@ export default class FileSystemFactory { options: ["password", "digest", "none", "token"], }, url: { title: t("url") }, - username: { title: t("username") }, - password: { title: t("password"), type: "password" }, + username: { title: t("username"), visibilityFor: ["password", "digest"] }, + password: { title: t("password"), type: "password", visibilityFor: ["password", "digest"] }, + token: { title: t("token"), visibilityFor: ["token"] }, }, "baidu-netdsik": {}, onedrive: {}, diff --git a/packages/filesystem/webdav/webdav.ts b/packages/filesystem/webdav/webdav.ts index f8b93966e..10ea10b21 100644 --- a/packages/filesystem/webdav/webdav.ts +++ b/packages/filesystem/webdav/webdav.ts @@ -1,4 +1,4 @@ -import type { AuthType, FileStat, WebDAVClient } from "webdav"; +import type { FileStat, WebDAVClient, WebDAVClientOptions } from "webdav"; import { createClient, getPatcher } from "webdav"; import type FileSystem from "../filesystem"; import type { FileInfo, FileCreateOptions, FileReader, FileWriter } from "../filesystem"; @@ -30,9 +30,16 @@ export default class WebDAVFileSystem implements FileSystem { basePath: string = "/"; - static fromCredentials(url: string, authType: AuthType, username: string, password: string) { + static fromCredentials(url: string, options: WebDAVClientOptions) { initWebDAVPatch(); - return new WebDAVFileSystem(createClient(url, { authType, username, password }), url, "/"); + options = { + ...options, + headers: { + "X-Requested-With": "XMLHttpRequest", // Nextcloud 等需要 + // "requesttoken": csrfToken, // 按账号各自传入 + }, + }; + return new WebDAVFileSystem(createClient(url, options), url, "/"); } static fromSameClient(fs: WebDAVFileSystem, basePath: string) { diff --git a/src/pages/components/FileSystemParams/index.tsx b/src/pages/components/FileSystemParams/index.tsx index ebf74473a..e732c9fe4 100644 --- a/src/pages/components/FileSystemParams/index.tsx +++ b/src/pages/components/FileSystemParams/index.tsx @@ -65,6 +65,7 @@ const FileSystemParams: React.FC<{ ]; const netDiskName = netDiskType ? fileSystemList.find((item) => item.key === fileSystemType)?.name : null; + const fsParam = fsParams[fileSystemType]; return ( <> @@ -110,58 +111,65 @@ const FileSystemParams: React.FC<{ marginTop: 4, }} > - {Object.keys(fsParams[fileSystemType]).map((key) => ( -
- {fsParams[fileSystemType][key].type === "select" && ( - <> - {fsParams[fileSystemType][key].title} - - - )} - {fsParams[fileSystemType][key].type === "password" && ( - <> - {fsParams[fileSystemType][key].title} - { - onChangeFileSystemParams({ - ...fileSystemParams, - [key]: value, - }); - }} - /> - - )} - {!fsParams[fileSystemType][key].type && ( - <> - {fsParams[fileSystemType][key].title} - { - onChangeFileSystemParams({ - ...fileSystemParams, - [key]: value, - }); - }} - /> - - )} -
- ))} + {Object.keys(fsParam).map((key) => { + const props = fsParam[key]; + const selectAuth = fsParam?.authType?.options?.[0]; // webDAV + return ( +
+ {props.type === "select" && ( + <> + {props.title} + + + )} + {props.type === "password" && ( + <> + {props.title} + { + onChangeFileSystemParams({ + ...fileSystemParams, + [key]: value, + }); + }} + /> + + )} + {!props.type && ( + <> + {props.title} + { + onChangeFileSystemParams({ + ...fileSystemParams, + [key]: value, + }); + }} + /> + + )} +
+ ); + })} ); From 2dbf8ab7985e7a578d8d50f5d8bd6c28ad870e6c Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Sun, 22 Mar 2026 13:53:30 +0900 Subject: [PATCH 08/12] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/filesystem/factory.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/filesystem/factory.ts b/packages/filesystem/factory.ts index 651b81e9a..2129042c5 100644 --- a/packages/filesystem/factory.ts +++ b/packages/filesystem/factory.ts @@ -47,7 +47,7 @@ export default class FileSystemFactory { }; } else { options = { - authType: params.authType || "auto", + authType: params.authType || "auto", // UI 问题,有undefined机会。undefined等价于 password, 但此处用 webdav 本身的 auto 侦测算了 username: params.username, password: params.password, }; From 219c6219ec8867cebb28a46222d3343f1789fdc9 Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Sun, 22 Mar 2026 13:54:53 +0900 Subject: [PATCH 09/12] type check --- packages/filesystem/factory.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/filesystem/factory.ts b/packages/filesystem/factory.ts index 2129042c5..5c8116959 100644 --- a/packages/filesystem/factory.ts +++ b/packages/filesystem/factory.ts @@ -8,6 +8,7 @@ import ZipFileSystem from "./zip/zip"; import S3FileSystem from "./s3/s3"; import { t } from "@App/locales/locales"; import LimiterFileSystem from "./limiter"; +import type { WebDAVClientOptions } from "webdav"; export type FileSystemType = "zip" | "webdav" | "baidu-netdsik" | "onedrive" | "googledrive" | "dropbox" | "s3"; @@ -39,18 +40,18 @@ export default class FileSystemFactory { if (params.authType === "none") { options = { authType: params.authType, - }; + } satisfies WebDAVClientOptions; } else if (params.authType === "token") { options = { authType: params.authType, token: params.token, - }; + } satisfies WebDAVClientOptions; } else { options = { authType: params.authType || "auto", // UI 问题,有undefined机会。undefined等价于 password, 但此处用 webdav 本身的 auto 侦测算了 username: params.username, password: params.password, - }; + } satisfies WebDAVClientOptions; } fs = WebDAVFileSystem.fromCredentials(params.url, options); break; From 88f4d6051345cfa7d240386f1c4479ef3d4227ee Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Sun, 22 Mar 2026 14:05:18 +0900 Subject: [PATCH 10/12] UI Fix --- packages/filesystem/factory.ts | 2 ++ src/pages/components/FileSystemParams/index.tsx | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/filesystem/factory.ts b/packages/filesystem/factory.ts index 5c8116959..4d3845cf2 100644 --- a/packages/filesystem/factory.ts +++ b/packages/filesystem/factory.ts @@ -18,6 +18,7 @@ export type FileSystemParams = { type?: "select" | "authorize" | "password"; options?: string[]; visibilityFor?: string[]; + minWidth?: string; }; }; @@ -90,6 +91,7 @@ export default class FileSystemFactory { title: t("auth_type"), type: "select", options: ["password", "digest", "none", "token"], + minWidth: "140px", }, url: { title: t("url") }, username: { title: t("username"), visibilityFor: ["password", "digest"] }, diff --git a/src/pages/components/FileSystemParams/index.tsx b/src/pages/components/FileSystemParams/index.tsx index e732c9fe4..2cec8cfb9 100644 --- a/src/pages/components/FileSystemParams/index.tsx +++ b/src/pages/components/FileSystemParams/index.tsx @@ -114,11 +114,11 @@ const FileSystemParams: React.FC<{ {Object.keys(fsParam).map((key) => { const props = fsParam[key]; const selectAuth = fsParam?.authType?.options?.[0]; // webDAV + if (selectAuth && props?.visibilityFor?.includes(fileSystemParams?.authType || selectAuth) === false) { + return null; + } return ( -
+
{props.type === "select" && ( <> {props.title} @@ -130,6 +130,7 @@ const FileSystemParams: React.FC<{ [key]: value, }); }} + style={{ minWidth: props.minWidth }} > {props.options!.map((option) => ( From 1631230b4441106279cf622ae3ed3192523960bf Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Sun, 22 Mar 2026 15:32:11 +0900 Subject: [PATCH 11/12] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20token=20auth?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/filesystem/factory.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/filesystem/factory.ts b/packages/filesystem/factory.ts index 4d3845cf2..1c4983a4f 100644 --- a/packages/filesystem/factory.ts +++ b/packages/filesystem/factory.ts @@ -8,7 +8,7 @@ import ZipFileSystem from "./zip/zip"; import S3FileSystem from "./s3/s3"; import { t } from "@App/locales/locales"; import LimiterFileSystem from "./limiter"; -import type { WebDAVClientOptions } from "webdav"; +import type { WebDAVClientOptions, OAuthToken } from "webdav"; export type FileSystemType = "zip" | "webdav" | "baidu-netdsik" | "onedrive" | "googledrive" | "dropbox" | "s3"; @@ -45,7 +45,10 @@ export default class FileSystemFactory { } else if (params.authType === "token") { options = { authType: params.authType, - token: params.token, + token: { + token_type: "Bearer", + access_token: params.token, + } satisfies OAuthToken, } satisfies WebDAVClientOptions; } else { options = { From b02e4a3551ea1c9da66e258bdaa0d53a4fa8728f Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Sun, 22 Mar 2026 15:36:43 +0900 Subject: [PATCH 12/12] accessToken & UI display --- packages/filesystem/factory.ts | 4 ++-- src/locales/ach-UG/translation.json | 1 + src/locales/de-DE/translation.json | 1 + src/locales/en-US/translation.json | 1 + src/locales/ja-JP/translation.json | 1 + src/locales/ru-RU/translation.json | 1 + src/locales/vi-VN/translation.json | 1 + src/locales/zh-CN/translation.json | 1 + src/locales/zh-TW/translation.json | 1 + 9 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/filesystem/factory.ts b/packages/filesystem/factory.ts index 1c4983a4f..99dfa5d0e 100644 --- a/packages/filesystem/factory.ts +++ b/packages/filesystem/factory.ts @@ -47,7 +47,7 @@ export default class FileSystemFactory { authType: params.authType, token: { token_type: "Bearer", - access_token: params.token, + access_token: params.accessToken, } satisfies OAuthToken, } satisfies WebDAVClientOptions; } else { @@ -99,7 +99,7 @@ export default class FileSystemFactory { url: { title: t("url") }, username: { title: t("username"), visibilityFor: ["password", "digest"] }, password: { title: t("password"), type: "password", visibilityFor: ["password", "digest"] }, - token: { title: t("token"), visibilityFor: ["token"] }, + accessToken: { title: t("access_token_bearer"), visibilityFor: ["token"] }, }, "baidu-netdsik": {}, onedrive: {}, diff --git a/src/locales/ach-UG/translation.json b/src/locales/ach-UG/translation.json index e6f3850b5..c1b8b441f 100644 --- a/src/locales/ach-UG/translation.json +++ b/src/locales/ach-UG/translation.json @@ -378,6 +378,7 @@ "url": "crwdns8544:0crwdne8544:0", "username": "crwdns8546:0crwdne8546:0", "password": "crwdns8548:0crwdne8548:0", + "access_token_bearer": "Access Token (Bearer)", "s3_bucket_name": "Bucket Name", "s3_region": "Region", "s3_access_key_id": "Access Key ID", diff --git a/src/locales/de-DE/translation.json b/src/locales/de-DE/translation.json index 9df67cfd8..27ed68826 100644 --- a/src/locales/de-DE/translation.json +++ b/src/locales/de-DE/translation.json @@ -387,6 +387,7 @@ "url": "URL", "username": "Benutzername", "password": "Passwort", + "access_token_bearer": "Zugriffstoken (Bearer)", "s3_bucket_name": "Bucket-Name", "s3_region": "Region", "s3_access_key_id": "Zugriffs-Schlüssel-ID", diff --git a/src/locales/en-US/translation.json b/src/locales/en-US/translation.json index 9769ef7f7..e24a9def9 100644 --- a/src/locales/en-US/translation.json +++ b/src/locales/en-US/translation.json @@ -387,6 +387,7 @@ "url": "URL", "username": "Username", "password": "Password", + "access_token_bearer": "Access Token (Bearer)", "s3_bucket_name": "Bucket Name", "s3_region": "Region", "s3_access_key_id": "Access Key ID", diff --git a/src/locales/ja-JP/translation.json b/src/locales/ja-JP/translation.json index 823949c52..af059852e 100644 --- a/src/locales/ja-JP/translation.json +++ b/src/locales/ja-JP/translation.json @@ -387,6 +387,7 @@ "url": "URL", "username": "ユーザー名", "password": "パスワード", + "access_token_bearer": "アクセストークン(Bearer)", "s3_bucket_name": "バケット名", "s3_region": "リージョン", "s3_access_key_id": "アクセスキーID", diff --git a/src/locales/ru-RU/translation.json b/src/locales/ru-RU/translation.json index 1b6b72973..553a2d196 100644 --- a/src/locales/ru-RU/translation.json +++ b/src/locales/ru-RU/translation.json @@ -387,6 +387,7 @@ "url": "URL", "username": "Имя пользователя", "password": "Пароль", + "access_token_bearer": "Токен доступа (Bearer)", "s3_bucket_name": "Имя корзины", "s3_region": "Регион", "s3_access_key_id": "Идентификатор ключа доступа", diff --git a/src/locales/vi-VN/translation.json b/src/locales/vi-VN/translation.json index c69cb10be..8f3124057 100644 --- a/src/locales/vi-VN/translation.json +++ b/src/locales/vi-VN/translation.json @@ -387,6 +387,7 @@ "url": "Url", "username": "Tên người dùng", "password": "Mật khẩu", + "access_token_bearer": "Mã truy cập (Bearer)", "s3_bucket_name": "Tên Bucket", "s3_region": "Vùng", "s3_access_key_id": "ID Khóa Truy Cập", diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.json index 1267d3472..f6b36020d 100644 --- a/src/locales/zh-CN/translation.json +++ b/src/locales/zh-CN/translation.json @@ -387,6 +387,7 @@ "url": "URL", "username": "用户名", "password": "密码", + "access_token_bearer": "访问令牌(Bearer)", "s3_bucket_name": "存储桶名称", "s3_region": "区域", "s3_access_key_id": "访问密钥 ID", diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.json index a56ddd57e..275b20d19 100644 --- a/src/locales/zh-TW/translation.json +++ b/src/locales/zh-TW/translation.json @@ -387,6 +387,7 @@ "url": "網址", "username": "使用者名稱", "password": "密碼", + "access_token_bearer": "存取權杖(Bearer)", "s3_bucket_name": "儲存貯體名稱", "s3_region": "區域", "s3_access_key_id": "存取金鑰 ID",