@vrtmrz/livesync-commonlib 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -5
- package/dist/API/DirectFileManipulatorV2.d.ts +1 -0
- package/dist/API/DirectFileManipulatorV2.js +3 -1
- package/dist/API/processSetting.d.ts +1 -0
- package/dist/API/processSetting.js +3 -0
- package/dist/common/models/setting.const.defaults.js +1 -0
- package/dist/common/models/setting.const.qr.js +2 -1
- package/dist/common/models/setting.encryption.d.ts +2 -0
- package/dist/common/models/setting.encryption.js +6 -0
- package/dist/common/models/setting.lifecycle.js +7 -2
- package/dist/common/models/setting.policy.d.ts +4 -0
- package/dist/common/models/setting.policy.js +9 -0
- package/dist/common/models/setting.type.d.ts +2 -0
- package/dist/common/models/shared.definition.configNames.js +5 -0
- package/dist/common/models/tweak.definition.d.ts +1 -0
- package/dist/common/settingConstants.d.ts +1 -0
- package/dist/common/utils.js +5 -4
- package/dist/diagnostics/couchdb.js +4 -2
- package/dist/interfaces/StorageAccess.d.ts +8 -2
- package/dist/managers/ChunkFetcher.js +27 -4
- package/dist/managers/chunkFetcher.helper.js +1 -1
- package/dist/platform/FilePathIndex.d.ts +110 -0
- package/dist/platform/FilePathIndex.js +146 -0
- package/dist/pouchdb/StreamingFetch.d.ts +1 -2
- package/dist/pouchdb/encryption.d.ts +5 -10
- package/dist/pouchdb/encryption.eden.d.ts +11 -0
- package/dist/pouchdb/encryption.eden.js +37 -0
- package/dist/pouchdb/encryption.js +67 -63
- package/dist/pouchdb/encryption.policy.d.ts +9 -0
- package/dist/pouchdb/encryption.policy.js +125 -0
- package/dist/replication/UnencryptedContentRejectedError.d.ts +16 -0
- package/dist/replication/UnencryptedContentRejectedError.js +44 -0
- package/dist/replication/couchdb/LiveSyncReplicator.js +41 -4
- package/dist/replication/index.d.ts +2 -0
- package/dist/replication/index.js +3 -0
- package/dist/replication/trystero/LiveSyncTrysteroReplicator.d.ts +3 -3
- package/dist/replication/trystero/P2PAutomationCoordinator.d.ts +1 -1
- package/dist/replication/trystero/P2PReplicationWire.d.ts +1 -1
- package/dist/replication/trystero/TrysteroReplicator/changeRelay.d.ts +133 -0
- package/dist/replication/trystero/TrysteroReplicator/changeRelay.js +176 -0
- package/dist/replication/trystero/TrysteroReplicator/configurationExchange.d.ts +55 -0
- package/dist/replication/trystero/TrysteroReplicator/configurationExchange.js +99 -0
- package/dist/replication/trystero/TrysteroReplicator/configuredTargets.d.ts +83 -0
- package/dist/replication/trystero/TrysteroReplicator/configuredTargets.js +121 -0
- package/dist/replication/trystero/TrysteroReplicator/peerAgreement.d.ts +75 -0
- package/dist/replication/trystero/TrysteroReplicator/peerAgreement.js +131 -0
- package/dist/replication/trystero/TrysteroReplicator/progress.d.ts +57 -0
- package/dist/replication/trystero/TrysteroReplicator/progress.js +84 -0
- package/dist/replication/trystero/TrysteroReplicator/relayControl.d.ts +20 -0
- package/dist/replication/trystero/TrysteroReplicator/relayControl.js +25 -0
- package/dist/replication/trystero/TrysteroReplicator/transfers.d.ts +125 -0
- package/dist/replication/trystero/TrysteroReplicator/transfers.js +278 -0
- package/dist/replication/trystero/TrysteroReplicator.d.ts +65 -481
- package/dist/replication/trystero/TrysteroReplicator.js +240 -673
- package/dist/replication/trystero/TrysteroReplicatorP2PClient.d.ts +19 -6
- package/dist/replication/trystero/TrysteroReplicatorP2PClient.js +29 -25
- package/dist/replication/trystero/TrysteroReplicatorP2PServer/peerAdmission.d.ts +66 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PServer/peerAdmission.js +142 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.d.ts +19 -16
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.js +33 -93
- package/dist/replication/trystero/p2pReplicationDiagnostics.d.ts +1 -1
- package/dist/replication/trystero/p2pReplicationProgress.d.ts +2 -11
- package/dist/replication/trystero/replicationTypes.d.ts +88 -0
- package/dist/replication/trystero/replicationTypes.js +0 -0
- package/dist/replication/trystero/rpcSessionProvider.d.ts +13 -0
- package/dist/replication/trystero/rpcSessionProvider.js +0 -0
- package/dist/replication/unencryptedContentMessages.d.ts +8 -0
- package/dist/replication/unencryptedContentMessages.js +12 -0
- package/dist/rpc/RpcRoom/pendingInvocations.d.ts +141 -0
- package/dist/rpc/RpcRoom/pendingInvocations.js +225 -0
- package/dist/rpc/RpcRoom.d.ts +9 -4
- package/dist/rpc/RpcRoom.js +73 -118
- package/dist/rpc/RpcSession.d.ts +6 -0
- package/dist/rpc/RpcSession.js +11 -0
- package/dist/rpc/types.d.ts +2 -0
- package/dist/serviceFeatures/targetFilter.d.ts +1 -1
- package/dist/serviceFeatures/targetFilter.js +8 -38
- package/dist/serviceModules/FileAccessBase.d.ts +4 -0
- package/dist/serviceModules/FileAccessBase.js +10 -0
- package/dist/serviceModules/Rebuilder.js +29 -5
- package/dist/serviceModules/ServiceFileAccessBase/fileNames.d.ts +54 -0
- package/dist/serviceModules/ServiceFileAccessBase/fileNames.js +57 -0
- package/dist/serviceModules/ServiceFileAccessBase.d.ts +5 -1
- package/dist/serviceModules/ServiceFileAccessBase.js +18 -3
- package/dist/serviceModules/adapters/IFileSystemAdapter.d.ts +3 -0
- package/dist/services/base/RemoteConnection.d.ts +2 -0
- package/dist/services/base/RemoteService.js +2 -1
- package/dist/services/base/SettingService.js +2 -0
- package/dist/settings.d.ts +2 -1
- package/dist/settings.js +2 -0
- package/dist/storage.d.ts +2 -0
- package/dist/storage.js +2 -0
- package/dist/worker/bgWorker.js +1 -1
- package/docs/development.md +103 -0
- package/docs/offline-scanner.md +2 -1
- package/docs/p2p-transport-lifecycle.md +24 -0
- package/docs/platform-storage.md +22 -0
- package/docs/releasing.md +6 -0
- package/docs/settings-lifecycle.md +6 -0
- package/package.json +1 -1
|
@@ -2,17 +2,23 @@ import { LOG_LEVEL_INFO, LOG_LEVEL_VERBOSE } from "octagonal-wheels/common/logge
|
|
|
2
2
|
import { ServiceModuleBase } from "./ServiceModuleBase.js";
|
|
3
3
|
import { StorageEventManager } from "../interfaces/StorageEventManager.js";
|
|
4
4
|
import { createBlob, fireAndForget } from "../common/utils.js";
|
|
5
|
+
import { createFallbackFileNameLookup } from "./ServiceFileAccessBase/fileNames.js";
|
|
5
6
|
class ServiceFileAccessBase extends ServiceModuleBase {
|
|
6
7
|
vaultAccess;
|
|
7
8
|
vaultManager;
|
|
8
9
|
vault;
|
|
9
10
|
setting;
|
|
11
|
+
fallbackFileNames;
|
|
10
12
|
constructor(services) {
|
|
11
13
|
super(services);
|
|
12
14
|
this.vault = services.vault;
|
|
13
15
|
this.setting = services.setting;
|
|
14
16
|
this.vaultManager = services.storageEventManager;
|
|
15
17
|
this.vaultAccess = services.vaultAccess;
|
|
18
|
+
this.fallbackFileNames = createFallbackFileNameLookup({
|
|
19
|
+
getFileNames: () => this.getFileNames(),
|
|
20
|
+
getStorageFileEventCount: () => services.fileProcessing.totalStorageFileEventCount
|
|
21
|
+
});
|
|
16
22
|
services.appLifecycle.onFirstInitialise.addHandler(this._everyOnFirstInitialize.bind(this));
|
|
17
23
|
services.fileProcessing.commitPendingFileEvents.addHandler(this._everyCommitPendingFileEvent.bind(this));
|
|
18
24
|
services.appLifecycle.onBeforeUnload.addHandler(async () => {
|
|
@@ -214,9 +220,18 @@ class ServiceFileAccessBase extends ServiceModuleBase {
|
|
|
214
220
|
const files = await this.vaultAccess.getFiles();
|
|
215
221
|
return files.map((f) => this.vaultAccess.nativeFileToUXFileInfoStub(f));
|
|
216
222
|
}
|
|
217
|
-
async getFileNames() {
|
|
218
|
-
|
|
219
|
-
|
|
223
|
+
async getFileNames(options) {
|
|
224
|
+
if (options?.fresh) {
|
|
225
|
+
this.fallbackFileNames.invalidate();
|
|
226
|
+
}
|
|
227
|
+
return await this.vaultAccess.getFileNames(options);
|
|
228
|
+
}
|
|
229
|
+
async findPathIdentityCandidates(path, policy) {
|
|
230
|
+
const indexedCandidates = this.vaultAccess.findPathIdentityCandidates(path, policy);
|
|
231
|
+
if (indexedCandidates) {
|
|
232
|
+
return await indexedCandidates;
|
|
233
|
+
}
|
|
234
|
+
return await this.fallbackFileNames.findPathIdentityCandidates(path, policy);
|
|
220
235
|
}
|
|
221
236
|
async getFilesIncludeHidden(basePath, includeFilter, excludeFilter, skipFolder = [".git", ".trash", "node_modules"]) {
|
|
222
237
|
let w;
|
|
@@ -4,6 +4,7 @@ import type { ITypeGuardAdapter } from "./ITypeGuardAdapter.js";
|
|
|
4
4
|
import type { IConversionAdapter } from "./IConversionAdapter.js";
|
|
5
5
|
import type { IStorageAdapter } from "./IStorageAdapter.js";
|
|
6
6
|
import type { IVaultAdapter } from "./IVaultAdapter.js";
|
|
7
|
+
import type { FileNameLookup } from "../../platform/FilePathIndex.js";
|
|
7
8
|
/**
|
|
8
9
|
* Main file system adapter interface
|
|
9
10
|
* Composes all other adapters and provides platform-specific operations
|
|
@@ -17,6 +18,8 @@ export interface IFileSystemAdapter<TNativeAbstractFile = any, TNativeFile = any
|
|
|
17
18
|
readonly conversion: IConversionAdapter<TNativeFile, TNativeFolder>;
|
|
18
19
|
/** Storage operations */
|
|
19
20
|
readonly storage: IStorageAdapter<TStat>;
|
|
21
|
+
/** Optional maintained file-name inventory and candidate lookup. */
|
|
22
|
+
readonly fileNameLookup?: FileNameLookup;
|
|
20
23
|
/** Vault operations */
|
|
21
24
|
readonly vault: IVaultAdapter<TNativeFile>;
|
|
22
25
|
/**
|
|
@@ -8,6 +8,8 @@ export interface RemoteConnectionOpenOptions {
|
|
|
8
8
|
readonly encryptionAlgorithm?: E2EEAlgorithm;
|
|
9
9
|
/** Apply HKDF Metadata encryption to obfuscated internal entries on writes. */
|
|
10
10
|
readonly encryptInternalMetadata?: boolean;
|
|
11
|
+
/** Accept plaintext file content on reads while E2EE is enabled. */
|
|
12
|
+
readonly acceptUnencryptedContent?: boolean;
|
|
11
13
|
/** Use HTTP headers alone for cache control; an absent value is false. */
|
|
12
14
|
readonly useCouchDBCacheControlHeadersOnly?: boolean;
|
|
13
15
|
/**
|
|
@@ -316,7 +316,8 @@ class RemoteService extends ServiceBase {
|
|
|
316
316
|
false,
|
|
317
317
|
getPBKDF2Salt,
|
|
318
318
|
encryptionAlgorithm,
|
|
319
|
-
connectionOptions.encryptInternalMetadata ?? false
|
|
319
|
+
connectionOptions.encryptInternalMetadata ?? false,
|
|
320
|
+
connectionOptions.acceptUnencryptedContent ?? false
|
|
320
321
|
);
|
|
321
322
|
}
|
|
322
323
|
} catch (ex) {
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { handlers } from "../lib/HandlerUtils.js";
|
|
13
13
|
import { ServiceBase } from "./ServiceBase.js";
|
|
14
14
|
import { createInstanceLogFunction } from "../lib/logUtils.js";
|
|
15
|
+
import { normaliseAcceptUnencryptedContent } from "../../common/models/setting.encryption.js";
|
|
15
16
|
import { isCloudantURI } from "../../pouchdb/utils_couchdb.js";
|
|
16
17
|
import { decryptString, encryptString } from "../../encryption/stringEncryption.js";
|
|
17
18
|
import { encryptWithEphemeralSalt, HKDF_SALTED_ENCRYPTED_PREFIX } from "octagonal-wheels/encryption/hkdf";
|
|
@@ -78,6 +79,7 @@ class SettingService extends ServiceBase {
|
|
|
78
79
|
* @param settings The settings to adjust.
|
|
79
80
|
*/
|
|
80
81
|
adjustSettings(settings) {
|
|
82
|
+
settings.acceptUnencryptedContent = normaliseAcceptUnencryptedContent(settings.acceptUnencryptedContent);
|
|
81
83
|
if (migrateLegacyRemoteConfigurationsInPlace(settings, (message) => {
|
|
82
84
|
this._log(message, LOG_LEVEL_NOTICE);
|
|
83
85
|
})) {
|
package/dist/settings.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
export { DEFAULT_SETTINGS, NEW_VAULT_SETTINGS, P2P_DEFAULT_SETTINGS, SETTINGS_SCHEMA_DEFAULTS, createNewVaultSettings, } from "./common/models/setting.const.defaults.js";
|
|
7
7
|
export { PREFERRED_BASE, PREFERRED_JOURNAL_SYNC, PREFERRED_SETTING_CLOUDANT, PREFERRED_SETTING_SELF_HOSTED, } from "./common/models/setting.const.preferred.js";
|
|
8
8
|
export { CURRENT_SETTING_VERSION } from "./common/models/setting.const.js";
|
|
9
|
+
export { normaliseAcceptUnencryptedContent } from "./common/models/setting.encryption.js";
|
|
9
10
|
export { deriveIdKey, deriveOrImportIdKey, formatIdRecoveryCode, configuredIdKey, ID_DERIVATION_VERSION, ID_RECOVERY_CODE_PREFIX, } from "./common/idDerivation.js";
|
|
10
11
|
export { getPathNormalizationVersion, normalisePathForIdentity } from "./common/pathNormalization.js";
|
|
11
12
|
export type { PathNormalizationVersion, PathIdentitySettings } from "./common/models/setting.type.js";
|
|
@@ -13,5 +14,5 @@ export { prepareSettingsForLoad, SettingsMigrationReviewCodes, type PreparedSett
|
|
|
13
14
|
export { assessTweakCompatibility } from "./common/models/tweak.compatibility.js";
|
|
14
15
|
export type { TweakAssessment, TweakAssessmentEntry, TweakAssessmentRelation, TweakAssessmentValue, TweakTransition, TweakTransitionReason, } from "./common/models/tweak.compatibility.js";
|
|
15
16
|
export type { TweakReconstruction, TweakValues } from "./common/models/tweak.definition.js";
|
|
16
|
-
export type { ObsidianLiveSyncSettings, RemoteDBSettings, RemoteTypeSettings } from "./common/models/setting.type.js";
|
|
17
|
+
export type { EncryptionSettings, ObsidianLiveSyncSettings, RemoteDBSettings, RemoteTypeSettings, } from "./common/models/setting.type.js";
|
|
17
18
|
export { SETTINGS_PROPERTY_POLICY, SettingPolicies, createMarkdownSettings, mergeMarkdownSettings, type SettingPropertyPolicy, type MarkdownSettings, type CredentialFreeMarkdownSettings, type PersistedSettings, } from "./common/models/setting.policy.js";
|
package/dist/settings.js
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
PREFERRED_SETTING_SELF_HOSTED
|
|
13
13
|
} from "./common/models/setting.const.preferred.js";
|
|
14
14
|
import { CURRENT_SETTING_VERSION } from "./common/models/setting.const.js";
|
|
15
|
+
import { normaliseAcceptUnencryptedContent } from "./common/models/setting.encryption.js";
|
|
15
16
|
import {
|
|
16
17
|
deriveIdKey,
|
|
17
18
|
deriveOrImportIdKey,
|
|
@@ -56,6 +57,7 @@ export {
|
|
|
56
57
|
formatIdRecoveryCode,
|
|
57
58
|
getPathNormalizationVersion,
|
|
58
59
|
mergeMarkdownSettings,
|
|
60
|
+
normaliseAcceptUnencryptedContent,
|
|
59
61
|
normalisePathForIdentity,
|
|
60
62
|
prepareSettingsForLoad
|
|
61
63
|
};
|
package/dist/storage.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/** Host-neutral path identity, namespace, and storage resolution contracts. */
|
|
2
2
|
export type { FilePath, DocumentPath, StoragePath, PathComparisonKey, PathComparisonSettings, DocumentPathParts, DirectoryEntry, ReadDirectory, ResolvedRename, StorageEntry, StoragePathResolver, StoragePathResolverOptions, } from "./platform/pathTypes.js";
|
|
3
|
+
export { FilePathIndex } from "./platform/FilePathIndex.js";
|
|
4
|
+
export type { FileNameLookup, FileNameReadOptions, FilePathDelta } from "./platform/FilePathIndex.js";
|
|
3
5
|
export { parseFilePath, parseDocumentPath, splitDocumentPath, joinDocumentPath, getStoragePathComparisonKey, getDocumentPathComparisonKey, } from "./platform/pathComparison.js";
|
|
4
6
|
export { createStoragePathResolver, AmbiguousNormalisedPathError } from "./platform/storagePathResolution.js";
|
package/dist/storage.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FilePathIndex } from "./platform/FilePathIndex.js";
|
|
1
2
|
import {
|
|
2
3
|
parseFilePath,
|
|
3
4
|
parseDocumentPath,
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
import { createStoragePathResolver, AmbiguousNormalisedPathError } from "./platform/storagePathResolution.js";
|
|
10
11
|
export {
|
|
11
12
|
AmbiguousNormalisedPathError,
|
|
13
|
+
FilePathIndex,
|
|
12
14
|
createStoragePathResolver,
|
|
13
15
|
getDocumentPathComparisonKey,
|
|
14
16
|
getStoragePathComparisonKey,
|