A big commit Squashed commit of CORS:

commit 8cffa38ebae2a46b7c8e855c7b21a124e35adc89
Author: fyears <1142836+fyears@users.noreply.github.com>
Date:   Thu Mar 10 23:52:56 2022 +0800

    bypass more cors for onedrive

commit 1b59ac1e58032099068aab55d22ef96c6396f203
Author: fyears <1142836+fyears@users.noreply.github.com>
Date:   Wed Mar 9 23:58:28 2022 +0800

    change wordings for webdav cors

commit 73142eb18b59fff20839680e866f51cfcb0a6226
Author: fyears <1142836+fyears@users.noreply.github.com>
Date:   Wed Mar 9 23:38:58 2022 +0800

    remove cors hint for webdav

commit 7dbb0b49d50e529b2b72e55ea2c8503ba7fa9268
Author: fyears <1142836+fyears@users.noreply.github.com>
Date:   Wed Mar 9 23:31:54 2022 +0800

    fix webdav

commit c28c4e19720a56230d483acf306463d42e619fa4
Author: fyears <1142836+fyears@users.noreply.github.com>
Date:   Wed Mar 9 23:31:35 2022 +0800

    remove more headers

commit 4eeae7043fa68d669a5c23c5549c14c1260ce638
Author: fyears <1142836+fyears@users.noreply.github.com>
Date:   Wed Mar 9 23:18:32 2022 +0800

    polish cors hints for s3

commit d9e55a91a1c413e9419cd6b30a3a6e3b403d483b
Author: fyears <1142836+fyears@users.noreply.github.com>
Date:   Wed Mar 9 22:40:37 2022 +0800

    fix format

commit b780a3eb4e37b05b8e8b92d6a2f9283b3459d738
Author: fyears <1142836+fyears@users.noreply.github.com>
Date:   Wed Mar 9 22:37:02 2022 +0800

    finally correctly inject requestUrl into s3

commit 6a55a1a43d7653d65579ab88aa816e5d54cd276a
Author: fyears <1142836+fyears@users.noreply.github.com>
Date:   Wed Mar 9 22:33:18 2022 +0800

    to arraybuffer from view

commit 2f2607b4f0a3d9db5943528ced57cb2fdb419607
Author: fyears <1142836+fyears@users.noreply.github.com>
Date:   Wed Mar 9 13:31:22 2022 +0800

    add split ranges

commit ea24da24dea83fdb770e7e391cf8a2e4fea78d0d
Author: fyears <1142836+fyears@users.noreply.github.com>
Date:   Sun Mar 6 22:57:50 2022 +0800

    add settings of bypassing for s3

commit 2f099dc8ca1e66ea137b28dd329be50968734ba6
Author: fyears <1142836+fyears@users.noreply.github.com>
Date:   Sun Mar 6 22:38:07 2022 +0800

    use api ver var

commit 74c7ce2449a88cbe7c7f50cbb687b36ff3732c04
Author: fyears <1142836+fyears@users.noreply.github.com>
Date:   Sun Mar 6 22:37:25 2022 +0800

    correct way to inject s3

commit f29945d73132d21b2c44472ec2cafc06b9d71e8f
Author: fyears <1142836+fyears@users.noreply.github.com>
Date:   Tue Mar 1 00:09:57 2022 +0800

    add new http handler

commit d55104cb08e168cbcc243cf901cbd7f46f2e324b
Author: fyears <1142836+fyears@users.noreply.github.com>
Date:   Mon Feb 28 22:59:55 2022 +0800

    add types for patch

commit 50b79ade7188ee7dfab9c1d03119585db358ba6f
Author: fyears <1142836+fyears@users.noreply.github.com>
Date:   Mon Feb 28 08:25:19 2022 +0800

    remove verbose

commit 83f0e71aa15aa7586f6d4e105cd77c25c2e113ce
Author: fyears <1142836+fyears@users.noreply.github.com>
Date:   Mon Feb 28 08:25:04 2022 +0800

    patch webdav!
This commit is contained in:
fyears
2022-03-10 23:54:35 +08:00
parent 5402baed0a
commit c04876e0c5
9 changed files with 503 additions and 90 deletions
+69 -14
View File
@@ -5,8 +5,13 @@ import {
PluginSettingTab,
Setting,
Platform,
requireApiVersion,
} from "obsidian";
import type { SUPPORTED_SERVICES_TYPE, WebdavAuthType } from "./baseTypes";
import {
API_VER_REQURL,
SUPPORTED_SERVICES_TYPE,
WebdavAuthType,
} from "./baseTypes";
import { exportVaultSyncPlansToFiles } from "./debugMode";
import { exportQrCodeUri } from "./importExport";
import {
@@ -595,9 +600,11 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
cls: "s3-disclaimer",
});
s3Div.createEl("p", {
text: "You need to configure CORS to allow requests from origin app://obsidian.md and capacitor://localhost and http://localhost",
});
if (!requireApiVersion(API_VER_REQURL)) {
s3Div.createEl("p", {
text: "You need to configure CORS to allow requests from origin app://obsidian.md and capacitor://localhost and http://localhost",
});
}
s3Div.createEl("p", {
text: "Some Amazon S3 official docs for references:",
@@ -615,10 +622,12 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
text: "Access key ID and Secret access key info",
});
s3LinksUl.createEl("li").createEl("a", {
href: "https://docs.aws.amazon.com/AmazonS3/latest/userguide/enabling-cors-examples.html",
text: "Configuring CORS",
});
if (!requireApiVersion(API_VER_REQURL)) {
s3LinksUl.createEl("li").createEl("a", {
href: "https://docs.aws.amazon.com/AmazonS3/latest/userguide/enabling-cors-examples.html",
text: "Configuring CORS",
});
}
new Setting(s3Div)
.setName("s3Endpoint")
@@ -687,6 +696,34 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
})
);
if (requireApiVersion(API_VER_REQURL)) {
new Setting(s3Div)
.setName("bypass CORS issue locally")
.setDesc(
`The plugin allows skipping server CORS config in new version (Obsidian>=${API_VER_REQURL}). If you encounter any issues, please disable this setting and config CORS (app://obsidian.md and capacitor://localhost and http://localhost) on server.`
)
.addDropdown((dropdown) => {
dropdown
.addOption("disable", "disable")
.addOption("enable", "enable");
dropdown
.setValue(
`${
this.plugin.settings.s3.bypassCorsLocally ? "enable" : "disable"
}`
)
.onChange(async (value) => {
if (value === "enable") {
this.plugin.settings.s3.bypassCorsLocally = true;
} else {
this.plugin.settings.s3.bypassCorsLocally = false;
}
await this.plugin.saveSettings();
});
});
}
new Setting(s3Div)
.setName("check connectivity")
.setDesc("check connectivity")
@@ -960,9 +997,11 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
cls: "webdav-disclaimer",
});
webdavDiv.createEl("p", {
text: "You need to configure CORS to allow requests from origin app://obsidian.md and capacitor://localhost and http://localhost",
});
if (!requireApiVersion(API_VER_REQURL)) {
webdavDiv.createEl("p", {
text: "You need to configure CORS to allow requests from origin app://obsidian.md and capacitor://localhost and http://localhost",
});
}
webdavDiv.createEl("p", {
text: `We will create and sync inside the folder /${this.app.vault.getName()} on your server.`,
@@ -1010,9 +1049,20 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
new Setting(webdavDiv)
.setName("server auth type")
.setDesc("If no password, this option would be ignored.")
.addDropdown((dropdown) => {
.addDropdown(async (dropdown) => {
dropdown.addOption("basic", "basic");
// dropdown.addOption("digest", "digest");
if (requireApiVersion(API_VER_REQURL)) {
dropdown.addOption("digest", "digest");
}
// new version config, copied to old version, we need to reset it
if (
!requireApiVersion(API_VER_REQURL) &&
this.plugin.settings.webdav.authType !== "basic"
) {
this.plugin.settings.webdav.authType = "basic";
await this.plugin.saveSettings();
}
dropdown
.setValue(this.plugin.settings.webdav.authType)
@@ -1067,8 +1117,13 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
if (res) {
new Notice("Great! The webdav server can be accessed.");
} else {
let corsErrMsg = "/CORS";
if (requireApiVersion(API_VER_REQURL)) {
corsErrMsg = "";
}
new Notice(
"The webdav server cannot be reached (possible to be any of address/username/password/authtype/CORS errors)."
`The webdav server cannot be reached (possible to be any of address/username/password/authtype${corsErrMsg} errors).`
);
}
});