From e2e8265d431a7981f38c3d5c29084072e9f32a85 Mon Sep 17 00:00:00 2001 From: fyears <1142836+fyears@users.noreply.github.com> Date: Mon, 25 Mar 2024 00:43:13 +0800 Subject: [PATCH] add https checking --- src/remoteForS3.ts | 9 ++++++++- src/remoteForWebdav.ts | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/remoteForS3.ts b/src/remoteForS3.ts index 02fbe5d..5d85750 100644 --- a/src/remoteForS3.ts +++ b/src/remoteForS3.ts @@ -22,7 +22,7 @@ import { buildQueryString } from "@smithy/querystring-builder"; import { HeaderBag, HttpHandlerOptions, Provider } from "@aws-sdk/types"; import { Buffer } from "buffer"; import * as mime from "mime-types"; -import { Vault, requestUrl, RequestUrlParam } from "obsidian"; +import { Vault, requestUrl, RequestUrlParam, Platform } from "obsidian"; import { Readable } from "stream"; import * as path from "path"; import AggregateError from "aggregate-error"; @@ -770,6 +770,13 @@ export const checkConnectivity = async ( callbackFunc?: any ) => { try { + // TODO: no universal way now, just check this in connectivity + if (Platform.isIosApp && !s3Config.s3Endpoint.startsWith("https")) { + throw Error( + `Your s3 endpoint could only be https, not http, because of the iOS restriction.` + ); + } + // const results = await s3Client.send( // new HeadBucketCommand({ Bucket: s3Config.s3BucketName }) // ); diff --git a/src/remoteForWebdav.ts b/src/remoteForWebdav.ts index 96ccf0b..07f1923 100644 --- a/src/remoteForWebdav.ts +++ b/src/remoteForWebdav.ts @@ -228,6 +228,13 @@ export class WrappedWebdavClient { if (this.client !== undefined) { return; } + + if (Platform.isIosApp && !this.webdavConfig.address.startsWith("https")) { + throw Error( + `Your webdav address could only be https, not http, because of the iOS restriction.` + ); + } + const headers = { "Cache-Control": "no-cache", };