mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-04-12 11:58:45 +00:00
#### JWT Authentication - Now we can use JWT Authentication ES512 correctly (#742). - Several misdirections in the Setting dialogues have been fixed (i.e., seconds and minutes confusion...). - The key area in the Setting dialogue has been enlarged and accepts newlines correctly. - Caching of JWT tokens now works correctly - Tokens are now cached and reused until they expire. - They will be kept until 10% of the expiration duration is remaining or 10 seconds, whichever is longer (but at a maximum of 1 minute). - JWT settings are now correctly displayed on the Setting dialogue. #### Other fixes - Receiving non-latest revisions no longer causes unexpected overwrites. - On receiving revisions that made conflicting changes, we are still able to handle them. ### Improved - No longer duplicated message notifications are shown when a connection to the remote server fails. - Instead, a single notification is shown, and it will be kept on the notification area inside the editor until the situation is resolved. - The notification area is no longer imposing, distracting, and overwhelming. - With a pale background, but bordered and with icons.
79 lines
3.2 KiB
TypeScript
79 lines
3.2 KiB
TypeScript
import { escapeStringToHTML } from "octagonal-wheels/string";
|
|
import { E2EEAlgorithmNames, type ObsidianLiveSyncSettings } from "../../../lib/src/common/types";
|
|
import {
|
|
pickCouchDBSyncSettings,
|
|
pickBucketSyncSettings,
|
|
pickP2PSyncSettings,
|
|
pickEncryptionSettings,
|
|
} from "../../../lib/src/common/utils";
|
|
import { getConfig, type AllSettingItemKey } from "./settingConstants";
|
|
|
|
/**
|
|
* Generates a summary of P2P configuration settings
|
|
* @param setting Settings object
|
|
* @param additional Additional summary information to include
|
|
* @param showAdvanced Whether to include advanced settings
|
|
* @returns Summary object
|
|
*/
|
|
export function getP2PConfigSummary(
|
|
setting: ObsidianLiveSyncSettings,
|
|
additional: Record<string, string> = {},
|
|
showAdvanced = false
|
|
) {
|
|
const settingTable: Partial<ObsidianLiveSyncSettings> = pickP2PSyncSettings(setting);
|
|
return { ...getSummaryFromPartialSettings({ ...settingTable }, showAdvanced), ...additional };
|
|
}
|
|
/**
|
|
* Generates a summary of Object Storage configuration settings
|
|
* @param setting Settings object
|
|
* @param showAdvanced Whether to include advanced settings
|
|
* @returns Summary object
|
|
*/
|
|
export function getBucketConfigSummary(setting: ObsidianLiveSyncSettings, showAdvanced = false) {
|
|
const settingTable: Partial<ObsidianLiveSyncSettings> = pickBucketSyncSettings(setting);
|
|
return getSummaryFromPartialSettings(settingTable, showAdvanced);
|
|
}
|
|
/**
|
|
* Generates a summary of CouchDB configuration settings
|
|
* @param setting Settings object
|
|
* @param showAdvanced Whether to include advanced settings
|
|
* @returns Summary object
|
|
*/
|
|
export function getCouchDBConfigSummary(setting: ObsidianLiveSyncSettings, showAdvanced = false) {
|
|
const settingTable: Partial<ObsidianLiveSyncSettings> = pickCouchDBSyncSettings(setting);
|
|
return getSummaryFromPartialSettings(settingTable, showAdvanced || setting.useJWT);
|
|
}
|
|
|
|
/**
|
|
* Generates a summary of E2EE configuration settings
|
|
* @param setting Settings object
|
|
* @param showAdvanced Whether to include advanced settings
|
|
* @returns Summary object
|
|
*/
|
|
export function getE2EEConfigSummary(setting: ObsidianLiveSyncSettings, showAdvanced = false) {
|
|
const settingTable: Partial<ObsidianLiveSyncSettings> = pickEncryptionSettings(setting);
|
|
return getSummaryFromPartialSettings(settingTable, showAdvanced);
|
|
}
|
|
|
|
/**
|
|
* Converts partial settings into a summary object
|
|
* @param setting Partial settings object
|
|
* @param showAdvanced Whether to include advanced settings
|
|
* @returns Summary object
|
|
*/
|
|
export function getSummaryFromPartialSettings(setting: Partial<ObsidianLiveSyncSettings>, showAdvanced = false) {
|
|
const outputSummary: Record<string, string> = {};
|
|
for (const key of Object.keys(setting) as (keyof ObsidianLiveSyncSettings)[]) {
|
|
const config = getConfig(key as AllSettingItemKey);
|
|
if (!config) continue;
|
|
if (config.isAdvanced && !showAdvanced) continue;
|
|
const value =
|
|
key != "E2EEAlgorithm"
|
|
? `${setting[key]}`
|
|
: E2EEAlgorithmNames[`${setting[key]}` as keyof typeof E2EEAlgorithmNames];
|
|
const displayValue = config.isHidden ? "•".repeat(value.length) : escapeStringToHTML(value);
|
|
outputSummary[config.name] = displayValue;
|
|
}
|
|
return outputSummary;
|
|
}
|