@vrtmrz/livesync-commonlib 0.1.0-rc.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/LICENSE +21 -0
- package/README.md +49 -0
- package/dist/API/DirectFileManipulator.d.ts +2 -0
- package/dist/API/DirectFileManipulator.js +4 -0
- package/dist/API/DirectFileManipulatorV2.d.ts +150 -0
- package/dist/API/DirectFileManipulatorV2.js +424 -0
- package/dist/API/processSetting.d.ts +41 -0
- package/dist/API/processSetting.js +140 -0
- package/dist/ContentSplitter/ContentSplitter.d.ts +28 -0
- package/dist/ContentSplitter/ContentSplitter.js +5 -0
- package/dist/ContentSplitter/ContentSplitterBase.d.ts +51 -0
- package/dist/ContentSplitter/ContentSplitterBase.js +83 -0
- package/dist/ContentSplitter/ContentSplitterRabinKarp.d.ts +9 -0
- package/dist/ContentSplitter/ContentSplitterRabinKarp.js +32 -0
- package/dist/ContentSplitter/ContentSplitterV1.d.ts +9 -0
- package/dist/ContentSplitter/ContentSplitterV1.js +34 -0
- package/dist/ContentSplitter/ContentSplitterV2.d.ts +9 -0
- package/dist/ContentSplitter/ContentSplitterV2.js +34 -0
- package/dist/ContentSplitter/ContentSplitters.d.ts +12 -0
- package/dist/ContentSplitter/ContentSplitters.js +29 -0
- package/dist/bureau/bureau.d.ts +7 -0
- package/dist/bureau/bureau.js +5 -0
- package/dist/common/ConnectionString.d.ts +30 -0
- package/dist/common/ConnectionString.js +179 -0
- package/dist/common/LSError.d.ts +48 -0
- package/dist/common/LSError.js +112 -0
- package/dist/common/configForDoc.d.ts +79 -0
- package/dist/common/configForDoc.js +312 -0
- package/dist/common/coreEnvFunctions.d.ts +21 -0
- package/dist/common/coreEnvFunctions.js +22 -0
- package/dist/common/coreEnvVars.d.ts +3 -0
- package/dist/common/coreEnvVars.js +6 -0
- package/dist/common/i18n.d.ts +18 -0
- package/dist/common/i18n.js +7193 -0
- package/dist/common/logger.d.ts +2 -0
- package/dist/common/logger.js +1 -0
- package/dist/common/messages/combinedMessages.dev.d.ts +7 -0
- package/dist/common/messages/combinedMessages.dev.js +44 -0
- package/dist/common/messages/combinedMessages.prod.d.ts +9264 -0
- package/dist/common/messages/combinedMessages.prod.js +9271 -0
- package/dist/common/messages/de.d.ts +297 -0
- package/dist/common/messages/de.js +7 -0
- package/dist/common/messages/def.d.ts +1119 -0
- package/dist/common/messages/def.js +7 -0
- package/dist/common/messages/es.d.ts +689 -0
- package/dist/common/messages/es.js +7 -0
- package/dist/common/messages/fr.d.ts +582 -0
- package/dist/common/messages/fr.js +7 -0
- package/dist/common/messages/he.d.ts +583 -0
- package/dist/common/messages/he.js +7 -0
- package/dist/common/messages/ja.d.ts +838 -0
- package/dist/common/messages/ja.js +7 -0
- package/dist/common/messages/ko.d.ts +800 -0
- package/dist/common/messages/ko.js +7 -0
- package/dist/common/messages/ru.d.ts +858 -0
- package/dist/common/messages/ru.js +7 -0
- package/dist/common/messages/zh-tw.d.ts +384 -0
- package/dist/common/messages/zh-tw.js +7 -0
- package/dist/common/messages/zh.d.ts +1093 -0
- package/dist/common/messages/zh.js +7 -0
- package/dist/common/messagesJson/de.json +295 -0
- package/dist/common/messagesJson/en.json +1117 -0
- package/dist/common/messagesJson/es.json +687 -0
- package/dist/common/messagesJson/fr.json +580 -0
- package/dist/common/messagesJson/he.json +581 -0
- package/dist/common/messagesJson/ja.json +836 -0
- package/dist/common/messagesJson/ko.json +798 -0
- package/dist/common/messagesJson/ru.json +856 -0
- package/dist/common/messagesJson/zh-tw.json +382 -0
- package/dist/common/messagesJson/zh.json +1091 -0
- package/dist/common/models/auth.type.d.ts +41 -0
- package/dist/common/models/auth.type.js +0 -0
- package/dist/common/models/db.const.d.ts +20 -0
- package/dist/common/models/db.const.js +28 -0
- package/dist/common/models/db.definition.d.ts +56 -0
- package/dist/common/models/db.definition.js +6 -0
- package/dist/common/models/db.type.d.ts +142 -0
- package/dist/common/models/db.type.js +0 -0
- package/dist/common/models/diff.definition.d.ts +16 -0
- package/dist/common/models/diff.definition.js +0 -0
- package/dist/common/models/fileaccess.const.d.ts +7 -0
- package/dist/common/models/fileaccess.const.js +16 -0
- package/dist/common/models/fileaccess.type.d.ts +72 -0
- package/dist/common/models/fileaccess.type.js +0 -0
- package/dist/common/models/redflag.const.d.ts +32 -0
- package/dist/common/models/redflag.const.js +27 -0
- package/dist/common/models/setting.const.d.ts +49 -0
- package/dist/common/models/setting.const.defaults.d.ts +3 -0
- package/dist/common/models/setting.const.defaults.js +185 -0
- package/dist/common/models/setting.const.js +68 -0
- package/dist/common/models/setting.const.preferred.d.ts +5 -0
- package/dist/common/models/setting.const.preferred.js +35 -0
- package/dist/common/models/setting.const.qr.d.ts +2 -0
- package/dist/common/models/setting.const.qr.js +174 -0
- package/dist/common/models/setting.type.d.ts +900 -0
- package/dist/common/models/setting.type.js +8 -0
- package/dist/common/models/shared.const.behabiour.d.ts +28 -0
- package/dist/common/models/shared.const.behabiour.js +36 -0
- package/dist/common/models/shared.const.d.ts +5 -0
- package/dist/common/models/shared.const.js +12 -0
- package/dist/common/models/shared.const.symbols.d.ts +9 -0
- package/dist/common/models/shared.const.symbols.js +20 -0
- package/dist/common/models/shared.definition.configNames.d.ts +36 -0
- package/dist/common/models/shared.definition.configNames.js +203 -0
- package/dist/common/models/shared.definition.d.ts +22 -0
- package/dist/common/models/shared.definition.js +24 -0
- package/dist/common/models/shared.type.util.d.ts +8 -0
- package/dist/common/models/shared.type.util.js +0 -0
- package/dist/common/models/sync.definition.d.ts +18 -0
- package/dist/common/models/sync.definition.js +20 -0
- package/dist/common/models/tweak.definition.d.ts +191 -0
- package/dist/common/models/tweak.definition.js +77 -0
- package/dist/common/rosetta.d.ts +42 -0
- package/dist/common/rosetta.js +57 -0
- package/dist/common/settingConstants.d.ts +216 -0
- package/dist/common/settingConstants.js +434 -0
- package/dist/common/typeUtils.d.ts +17 -0
- package/dist/common/typeUtils.js +51 -0
- package/dist/common/types.d.ts +107 -0
- package/dist/common/types.js +212 -0
- package/dist/common/utils.d.ts +129 -0
- package/dist/common/utils.doc.d.ts +11 -0
- package/dist/common/utils.doc.js +35 -0
- package/dist/common/utils.js +583 -0
- package/dist/common/utils.object.d.ts +2 -0
- package/dist/common/utils.object.js +14 -0
- package/dist/common/utils.patch.d.ts +8 -0
- package/dist/common/utils.patch.js +178 -0
- package/dist/common/utils.type.d.ts +1 -0
- package/dist/common/utils.type.js +0 -0
- package/dist/context.d.ts +8 -0
- package/dist/context.js +14 -0
- package/dist/databases/IndexedDBKeyValueDatabase.d.ts +26 -0
- package/dist/databases/IndexedDBKeyValueDatabase.js +130 -0
- package/dist/dataobject/StoredMap.d.ts +12 -0
- package/dist/dataobject/StoredMap.js +47 -0
- package/dist/dev/checks.d.ts +5 -0
- package/dist/dev/checks.js +38 -0
- package/dist/encryption/encryptHKDF.d.ts +3 -0
- package/dist/encryption/encryptHKDF.js +7 -0
- package/dist/encryption/stringEncryption.d.ts +27 -0
- package/dist/encryption/stringEncryption.js +59 -0
- package/dist/events/coreEvents.d.ts +54 -0
- package/dist/events/coreEvents.js +46 -0
- package/dist/hub/hub.d.ts +11 -0
- package/dist/hub/hub.js +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -0
- package/dist/interfaces/AsyncActivityRunner.d.ts +18 -0
- package/dist/interfaces/AsyncActivityRunner.js +7 -0
- package/dist/interfaces/Confirm.d.ts +17 -0
- package/dist/interfaces/Confirm.js +0 -0
- package/dist/interfaces/DatabaseFileAccess.d.ts +14 -0
- package/dist/interfaces/DatabaseFileAccess.js +0 -0
- package/dist/interfaces/DatabaseRebuilder.d.ts +13 -0
- package/dist/interfaces/DatabaseRebuilder.js +0 -0
- package/dist/interfaces/FileHandler.d.ts +13 -0
- package/dist/interfaces/FileHandler.js +0 -0
- package/dist/interfaces/KeyValueDatabase.d.ts +11 -0
- package/dist/interfaces/KeyValueDatabase.js +0 -0
- package/dist/interfaces/ServiceModule.d.ts +59 -0
- package/dist/interfaces/ServiceModule.js +19 -0
- package/dist/interfaces/StorageAccess.d.ts +44 -0
- package/dist/interfaces/StorageAccess.js +0 -0
- package/dist/interfaces/StorageEventManager.d.ts +16 -0
- package/dist/interfaces/StorageEventManager.js +5 -0
- package/dist/managers/ChangeManager.d.ts +61 -0
- package/dist/managers/ChangeManager.js +104 -0
- package/dist/managers/ChunkDeliveryCoordinator.d.ts +51 -0
- package/dist/managers/ChunkDeliveryCoordinator.js +136 -0
- package/dist/managers/ChunkFetcher.d.ts +44 -0
- package/dist/managers/ChunkFetcher.js +251 -0
- package/dist/managers/ChunkManager.d.ts +2 -0
- package/dist/managers/ChunkManager.js +4 -0
- package/dist/managers/ConflictManager.d.ts +37 -0
- package/dist/managers/ConflictManager.js +322 -0
- package/dist/managers/EntryManager/EntryManager.d.ts +37 -0
- package/dist/managers/EntryManager/EntryManager.js +73 -0
- package/dist/managers/EntryManager/EntryManagerImpls.d.ts +74 -0
- package/dist/managers/EntryManager/EntryManagerImpls.js +499 -0
- package/dist/managers/HashManager/HashManager.d.ts +60 -0
- package/dist/managers/HashManager/HashManager.js +97 -0
- package/dist/managers/HashManager/HashManagerCore.d.ts +114 -0
- package/dist/managers/HashManager/HashManagerCore.js +99 -0
- package/dist/managers/HashManager/PureJSHashManager.d.ts +77 -0
- package/dist/managers/HashManager/PureJSHashManager.js +84 -0
- package/dist/managers/HashManager/XXHashHashManager.d.ts +96 -0
- package/dist/managers/HashManager/XXHashHashManager.js +111 -0
- package/dist/managers/LayeredChunkManager/ArrivalWaitLayer.d.ts +30 -0
- package/dist/managers/LayeredChunkManager/ArrivalWaitLayer.js +115 -0
- package/dist/managers/LayeredChunkManager/CacheLayer.d.ts +59 -0
- package/dist/managers/LayeredChunkManager/CacheLayer.js +161 -0
- package/dist/managers/LayeredChunkManager/ChunkLayerInterfaces.d.ts +37 -0
- package/dist/managers/LayeredChunkManager/ChunkLayerInterfaces.js +0 -0
- package/dist/managers/LayeredChunkManager/DatabaseReadLayer.d.ts +14 -0
- package/dist/managers/LayeredChunkManager/DatabaseReadLayer.js +78 -0
- package/dist/managers/LayeredChunkManager/DatabaseWriteLayer.d.ts +11 -0
- package/dist/managers/LayeredChunkManager/DatabaseWriteLayer.js +43 -0
- package/dist/managers/LayeredChunkManager/HotPackLayer.d.ts +9 -0
- package/dist/managers/LayeredChunkManager/HotPackLayer.js +8 -0
- package/dist/managers/LayeredChunkManager/types.d.ts +39 -0
- package/dist/managers/LayeredChunkManager/types.js +0 -0
- package/dist/managers/LayeredChunkManager.d.ts +53 -0
- package/dist/managers/LayeredChunkManager.js +240 -0
- package/dist/managers/LiveSyncManagers.d.ts +48 -0
- package/dist/managers/LiveSyncManagers.js +136 -0
- package/dist/managers/StorageEventManager.d.ts +135 -0
- package/dist/managers/StorageEventManager.js +564 -0
- package/dist/managers/StorageProcessingManager.d.ts +14 -0
- package/dist/managers/StorageProcessingManager.js +48 -0
- package/dist/managers/adapters/IStorageEventConverterAdapter.d.ts +16 -0
- package/dist/managers/adapters/IStorageEventConverterAdapter.js +0 -0
- package/dist/managers/adapters/IStorageEventManagerAdapter.d.ts +18 -0
- package/dist/managers/adapters/IStorageEventManagerAdapter.js +0 -0
- package/dist/managers/adapters/IStorageEventPersistenceAdapter.d.ts +15 -0
- package/dist/managers/adapters/IStorageEventPersistenceAdapter.js +0 -0
- package/dist/managers/adapters/IStorageEventStatusAdapter.d.ts +13 -0
- package/dist/managers/adapters/IStorageEventStatusAdapter.js +0 -0
- package/dist/managers/adapters/IStorageEventTypeGuardAdapter.d.ts +16 -0
- package/dist/managers/adapters/IStorageEventTypeGuardAdapter.js +0 -0
- package/dist/managers/adapters/IStorageEventWatchAdapter.d.ts +21 -0
- package/dist/managers/adapters/IStorageEventWatchAdapter.js +0 -0
- package/dist/managers/adapters/index.d.ts +6 -0
- package/dist/managers/adapters/index.js +0 -0
- package/dist/mock_and_interop/stores.d.ts +21 -0
- package/dist/mock_and_interop/stores.js +15 -0
- package/dist/mock_and_interop/wrapper.d.ts +7 -0
- package/dist/mock_and_interop/wrapper.js +37 -0
- package/dist/mods.d.ts +1 -0
- package/dist/mods.js +18 -0
- package/dist/platform/browser/index.d.ts +1 -0
- package/dist/platform/browser/index.js +10 -0
- package/dist/platform/browser/storage.d.ts +35 -0
- package/dist/platform/browser/storage.js +139 -0
- package/dist/platform/node/index.d.ts +23 -0
- package/dist/platform/node/index.js +33 -0
- package/dist/platform/node/storage.d.ts +31 -0
- package/dist/platform/node/storage.js +104 -0
- package/dist/platform/storagePath.d.ts +7 -0
- package/dist/platform/storagePath.js +20 -0
- package/dist/pouchdb/LiveSyncDBFunctions.d.ts +14 -0
- package/dist/pouchdb/LiveSyncDBFunctions.js +129 -0
- package/dist/pouchdb/LiveSyncLocalDB.d.ts +196 -0
- package/dist/pouchdb/LiveSyncLocalDB.js +381 -0
- package/dist/pouchdb/PouchDBConstructor.d.ts +3 -0
- package/dist/pouchdb/PouchDBConstructor.js +0 -0
- package/dist/pouchdb/ReplicatorShim.d.ts +51 -0
- package/dist/pouchdb/ReplicatorShim.js +109 -0
- package/dist/pouchdb/StreamingFetch.d.ts +19 -0
- package/dist/pouchdb/StreamingFetch.js +263 -0
- package/dist/pouchdb/chunks.d.ts +38 -0
- package/dist/pouchdb/chunks.js +314 -0
- package/dist/pouchdb/compress.d.ts +11 -0
- package/dist/pouchdb/compress.js +99 -0
- package/dist/pouchdb/encryption.d.ts +20 -0
- package/dist/pouchdb/encryption.js +458 -0
- package/dist/pouchdb/negotiation.d.ts +9 -0
- package/dist/pouchdb/negotiation.js +109 -0
- package/dist/pouchdb/pouchdb-browser.d.ts +2 -0
- package/dist/pouchdb/pouchdb-browser.js +96 -0
- package/dist/pouchdb/pouchdb-http.d.ts +2 -0
- package/dist/pouchdb/pouchdb-http.js +94 -0
- package/dist/pouchdb/pouchdb-test.d.ts +2 -0
- package/dist/pouchdb/pouchdb-test.js +12 -0
- package/dist/pouchdb/utils_couchdb.d.ts +4 -0
- package/dist/pouchdb/utils_couchdb.js +38 -0
- package/dist/replication/LiveSyncAbstractReplicator.d.ts +69 -0
- package/dist/replication/LiveSyncAbstractReplicator.js +92 -0
- package/dist/replication/SyncParamsHandler.d.ts +35 -0
- package/dist/replication/SyncParamsHandler.js +118 -0
- package/dist/replication/couchdb/LiveSyncReplicator.d.ts +85 -0
- package/dist/replication/couchdb/LiveSyncReplicator.js +1132 -0
- package/dist/replication/httplib.d.ts +75 -0
- package/dist/replication/httplib.js +187 -0
- package/dist/replication/journal/JournalSyncCore.d.ts +70 -0
- package/dist/replication/journal/JournalSyncCore.js +737 -0
- package/dist/replication/journal/JournalSyncTypes.d.ts +9 -0
- package/dist/replication/journal/JournalSyncTypes.js +11 -0
- package/dist/replication/journal/LiveSyncJournalReplicator.d.ts +40 -0
- package/dist/replication/journal/LiveSyncJournalReplicator.js +294 -0
- package/dist/replication/journal/LiveSyncJournalReplicatorEnv.d.ts +3 -0
- package/dist/replication/journal/LiveSyncJournalReplicatorEnv.js +0 -0
- package/dist/replication/journal/objectstore/JournalStorageAdapter.d.ts +15 -0
- package/dist/replication/journal/objectstore/JournalStorageAdapter.js +0 -0
- package/dist/replication/journal/objectstore/MinioStorageAdapter.d.ts +21 -0
- package/dist/replication/journal/objectstore/MinioStorageAdapter.js +204 -0
- package/dist/replication/trystero/LiveSyncTrysteroReplicator.d.ts +90 -0
- package/dist/replication/trystero/LiveSyncTrysteroReplicator.js +380 -0
- package/dist/replication/trystero/P2PLogCollector.d.ts +8 -0
- package/dist/replication/trystero/P2PLogCollector.js +91 -0
- package/dist/replication/trystero/P2PReplicatorBase.d.ts +19 -0
- package/dist/replication/trystero/P2PReplicatorBase.js +0 -0
- package/dist/replication/trystero/P2PReplicatorCore.d.ts +12 -0
- package/dist/replication/trystero/P2PReplicatorCore.js +126 -0
- package/dist/replication/trystero/P2PReplicatorPaneCommon.d.ts +41 -0
- package/dist/replication/trystero/P2PReplicatorPaneCommon.js +20 -0
- package/dist/replication/trystero/ProxiedDB.d.ts +13 -0
- package/dist/replication/trystero/ProxiedDB.js +20 -0
- package/dist/replication/trystero/TrysteroReplicator.d.ts +152 -0
- package/dist/replication/trystero/TrysteroReplicator.js +683 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PClient.d.ts +19 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PClient.js +80 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PConnection.d.ts +2 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PConnection.js +4 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.d.ts +117 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.js +540 -0
- package/dist/replication/trystero/UseP2PReplicatorResult.d.ts +11 -0
- package/dist/replication/trystero/UseP2PReplicatorResult.js +0 -0
- package/dist/replication/trystero/addP2PEventHandlers.d.ts +35 -0
- package/dist/replication/trystero/addP2PEventHandlers.js +43 -0
- package/dist/replication/trystero/rpcCompat.d.ts +1 -0
- package/dist/replication/trystero/rpcCompat.js +9 -0
- package/dist/replication/trystero/types.d.ts +95 -0
- package/dist/replication/trystero/types.js +27 -0
- package/dist/replication/trystero/useP2PReplicatorCommands.d.ts +7 -0
- package/dist/replication/trystero/useP2PReplicatorCommands.js +25 -0
- package/dist/replication/trystero/useP2PReplicatorFeature.d.ts +17 -0
- package/dist/replication/trystero/useP2PReplicatorFeature.js +82 -0
- package/dist/rpc/RpcRoom.d.ts +24 -0
- package/dist/rpc/RpcRoom.js +300 -0
- package/dist/rpc/RpcSession.d.ts +9 -0
- package/dist/rpc/RpcSession.js +32 -0
- package/dist/rpc/chunking.d.ts +11 -0
- package/dist/rpc/chunking.js +58 -0
- package/dist/rpc/errors.d.ts +8 -0
- package/dist/rpc/errors.js +26 -0
- package/dist/rpc/index.d.ts +6 -0
- package/dist/rpc/index.js +12 -0
- package/dist/rpc/pouchdb/RpcPouchDBProxy.d.ts +75 -0
- package/dist/rpc/pouchdb/RpcPouchDBProxy.js +115 -0
- package/dist/rpc/pouchdb/RpcPouchDBServer.d.ts +16 -0
- package/dist/rpc/pouchdb/RpcPouchDBServer.js +55 -0
- package/dist/rpc/transports/DiagRTCPeerConnections.d.ts +24 -0
- package/dist/rpc/transports/DiagRTCPeerConnections.js +208 -0
- package/dist/rpc/transports/DiagRTCPeerConnections.types.d.ts +64 -0
- package/dist/rpc/transports/DiagRTCPeerConnections.types.js +12 -0
- package/dist/rpc/transports/DiagRTCPeerConnections.utils.d.ts +33 -0
- package/dist/rpc/transports/DiagRTCPeerConnections.utils.js +217 -0
- package/dist/rpc/transports/TrysteroTransport.d.ts +216 -0
- package/dist/rpc/transports/TrysteroTransport.js +134 -0
- package/dist/rpc/transports/trysteroUtils.d.ts +3 -0
- package/dist/rpc/transports/trysteroUtils.js +37 -0
- package/dist/rpc/types.d.ts +75 -0
- package/dist/rpc/types.js +6 -0
- package/dist/serviceFeatures/checkRemoteSize.d.ts +28 -0
- package/dist/serviceFeatures/checkRemoteSize.js +178 -0
- package/dist/serviceFeatures/offlineScanner.d.ts +128 -0
- package/dist/serviceFeatures/offlineScanner.js +553 -0
- package/dist/serviceFeatures/prepareDatabaseForUse.d.ts +20 -0
- package/dist/serviceFeatures/prepareDatabaseForUse.js +39 -0
- package/dist/serviceFeatures/remoteConfig.d.ts +46 -0
- package/dist/serviceFeatures/remoteConfig.js +247 -0
- package/dist/serviceFeatures/setupObsidian/qrCode.d.ts +4 -0
- package/dist/serviceFeatures/setupObsidian/qrCode.js +67 -0
- package/dist/serviceFeatures/setupObsidian/setupUri.d.ts +7 -0
- package/dist/serviceFeatures/setupObsidian/setupUri.js +70 -0
- package/dist/serviceFeatures/setupObsidian/types.d.ts +2 -0
- package/dist/serviceFeatures/setupObsidian/types.js +0 -0
- package/dist/serviceFeatures/targetFilter.d.ts +24 -0
- package/dist/serviceFeatures/targetFilter.js +178 -0
- package/dist/serviceModules/FileAccessBase.d.ts +93 -0
- package/dist/serviceModules/FileAccessBase.js +219 -0
- package/dist/serviceModules/Rebuilder.d.ts +92 -0
- package/dist/serviceModules/Rebuilder.js +449 -0
- package/dist/serviceModules/ServiceDatabaseFileAccessBase.d.ts +40 -0
- package/dist/serviceModules/ServiceDatabaseFileAccessBase.js +306 -0
- package/dist/serviceModules/ServiceFileAccessBase.d.ts +64 -0
- package/dist/serviceModules/ServiceFileAccessBase.js +312 -0
- package/dist/serviceModules/ServiceFileHandlerBase.d.ts +52 -0
- package/dist/serviceModules/ServiceFileHandlerBase.js +493 -0
- package/dist/serviceModules/ServiceModuleBase.d.ts +10 -0
- package/dist/serviceModules/ServiceModuleBase.js +13 -0
- package/dist/serviceModules/adapters/IConversionAdapter.d.ts +15 -0
- package/dist/serviceModules/adapters/IConversionAdapter.js +0 -0
- package/dist/serviceModules/adapters/IFileSystemAdapter.d.ts +47 -0
- package/dist/serviceModules/adapters/IFileSystemAdapter.js +0 -0
- package/dist/serviceModules/adapters/IPathAdapter.d.ts +15 -0
- package/dist/serviceModules/adapters/IPathAdapter.js +0 -0
- package/dist/serviceModules/adapters/IStorageAdapter.d.ts +56 -0
- package/dist/serviceModules/adapters/IStorageAdapter.js +0 -0
- package/dist/serviceModules/adapters/ITypeGuardAdapter.d.ts +14 -0
- package/dist/serviceModules/adapters/ITypeGuardAdapter.js +0 -0
- package/dist/serviceModules/adapters/IVaultAdapter.d.ts +51 -0
- package/dist/serviceModules/adapters/IVaultAdapter.js +0 -0
- package/dist/serviceModules/adapters/index.d.ts +6 -0
- package/dist/serviceModules/adapters/index.js +0 -0
- package/dist/services/BrowserServices.d.ts +36 -0
- package/dist/services/BrowserServices.js +123 -0
- package/dist/services/HeadlessServices.d.ts +14 -0
- package/dist/services/HeadlessServices.js +144 -0
- package/dist/services/InjectableServices.d.ts +1 -0
- package/dist/services/InjectableServices.js +4 -0
- package/dist/services/ServiceHub.d.ts +82 -0
- package/dist/services/ServiceHub.js +66 -0
- package/dist/services/base/APIService.d.ts +93 -0
- package/dist/services/base/APIService.js +44 -0
- package/dist/services/base/AppLifecycleService.d.ts +132 -0
- package/dist/services/base/AppLifecycleService.js +123 -0
- package/dist/services/base/ConfigService.d.ts +7 -0
- package/dist/services/base/ConfigService.js +6 -0
- package/dist/services/base/ConflictService.d.ts +54 -0
- package/dist/services/base/ConflictService.js +22 -0
- package/dist/services/base/ControlService.d.ts +54 -0
- package/dist/services/base/ControlService.js +103 -0
- package/dist/services/base/DatabaseEventService.d.ts +38 -0
- package/dist/services/base/DatabaseEventService.js +38 -0
- package/dist/services/base/DatabaseService.d.ts +40 -0
- package/dist/services/base/DatabaseService.js +79 -0
- package/dist/services/base/FileProcessingService.d.ts +25 -0
- package/dist/services/base/FileProcessingService.js +28 -0
- package/dist/services/base/IService.d.ts +284 -0
- package/dist/services/base/IService.js +1 -0
- package/dist/services/base/KeyValueDBService.d.ts +42 -0
- package/dist/services/base/KeyValueDBService.js +133 -0
- package/dist/services/base/MessageTranslator.d.ts +6 -0
- package/dist/services/base/MessageTranslator.js +4 -0
- package/dist/services/base/PathService.d.ts +38 -0
- package/dist/services/base/PathService.js +66 -0
- package/dist/services/base/RemoteService.d.ts +61 -0
- package/dist/services/base/RemoteService.js +212 -0
- package/dist/services/base/ReplicationService.d.ts +92 -0
- package/dist/services/base/ReplicationService.js +261 -0
- package/dist/services/base/ReplicatorService.d.ts +66 -0
- package/dist/services/base/ReplicatorService.js +164 -0
- package/dist/services/base/ServiceBase.d.ts +33 -0
- package/dist/services/base/ServiceBase.js +27 -0
- package/dist/services/base/SettingService.d.ts +112 -0
- package/dist/services/base/SettingService.js +543 -0
- package/dist/services/base/TestService.d.ts +28 -0
- package/dist/services/base/TestService.js +19 -0
- package/dist/services/base/TweakValueService.d.ts +40 -0
- package/dist/services/base/TweakValueService.js +6 -0
- package/dist/services/base/UnresolvedErrorManager.d.ts +15 -0
- package/dist/services/base/UnresolvedErrorManager.js +44 -0
- package/dist/services/base/VaultService.d.ts +69 -0
- package/dist/services/base/VaultService.js +70 -0
- package/dist/services/implements/base/SvelteDialog.d.ts +79 -0
- package/dist/services/implements/base/SvelteDialog.js +134 -0
- package/dist/services/implements/base/UIService.d.ts +24 -0
- package/dist/services/implements/base/UIService.js +37 -0
- package/dist/services/implements/browser/BrowserAPIService.d.ts +54 -0
- package/dist/services/implements/browser/BrowserAPIService.js +298 -0
- package/dist/services/implements/browser/BrowserDatabaseService.d.ts +7 -0
- package/dist/services/implements/browser/BrowserDatabaseService.js +10 -0
- package/dist/services/implements/browser/ConfigServiceBrowserCompat.d.ts +16 -0
- package/dist/services/implements/browser/ConfigServiceBrowserCompat.js +23 -0
- package/dist/services/implements/headless/HeadlessAPIService.d.ts +52 -0
- package/dist/services/implements/headless/HeadlessAPIService.js +127 -0
- package/dist/services/implements/headless/HeadlessDatabaseService.d.ts +7 -0
- package/dist/services/implements/headless/HeadlessDatabaseService.js +10 -0
- package/dist/services/implements/injectable/InjectableAPIService.d.ts +7 -0
- package/dist/services/implements/injectable/InjectableAPIService.js +18 -0
- package/dist/services/implements/injectable/InjectableAppLifecycleService.d.ts +11 -0
- package/dist/services/implements/injectable/InjectableAppLifecycleService.js +14 -0
- package/dist/services/implements/injectable/InjectableConflictService.d.ts +11 -0
- package/dist/services/implements/injectable/InjectableConflictService.js +14 -0
- package/dist/services/implements/injectable/InjectableDatabaseEventService.d.ts +4 -0
- package/dist/services/implements/injectable/InjectableDatabaseEventService.js +7 -0
- package/dist/services/implements/injectable/InjectableFileProcessingService.d.ts +4 -0
- package/dist/services/implements/injectable/InjectableFileProcessingService.js +6 -0
- package/dist/services/implements/injectable/InjectablePathService.d.ts +12 -0
- package/dist/services/implements/injectable/InjectablePathService.js +36 -0
- package/dist/services/implements/injectable/InjectableRemoteService.d.ts +4 -0
- package/dist/services/implements/injectable/InjectableRemoteService.js +7 -0
- package/dist/services/implements/injectable/InjectableReplicationService.d.ts +4 -0
- package/dist/services/implements/injectable/InjectableReplicationService.js +6 -0
- package/dist/services/implements/injectable/InjectableReplicatorService.d.ts +4 -0
- package/dist/services/implements/injectable/InjectableReplicatorService.js +7 -0
- package/dist/services/implements/injectable/InjectableServiceHub.d.ts +72 -0
- package/dist/services/implements/injectable/InjectableServiceHub.js +125 -0
- package/dist/services/implements/injectable/InjectableServices.d.ts +36 -0
- package/dist/services/implements/injectable/InjectableServices.js +1 -0
- package/dist/services/implements/injectable/InjectableSettingService.d.ts +11 -0
- package/dist/services/implements/injectable/InjectableSettingService.js +33 -0
- package/dist/services/implements/injectable/InjectableTestService.d.ts +5 -0
- package/dist/services/implements/injectable/InjectableTestService.js +8 -0
- package/dist/services/implements/injectable/InjectableTweakValueService.d.ts +15 -0
- package/dist/services/implements/injectable/InjectableTweakValueService.js +12 -0
- package/dist/services/implements/injectable/InjectableVaultService.d.ts +9 -0
- package/dist/services/implements/injectable/InjectableVaultService.js +20 -0
- package/dist/services/lib/HandlerUtils.d.ts +374 -0
- package/dist/services/lib/HandlerUtils.js +412 -0
- package/dist/services/lib/logUtils.d.ts +13 -0
- package/dist/services/lib/logUtils.js +28 -0
- package/dist/services/lib/remoteActivity.d.ts +13 -0
- package/dist/services/lib/remoteActivity.js +11 -0
- package/dist/string_and_binary/chunks.d.ts +10 -0
- package/dist/string_and_binary/chunks.js +561 -0
- package/dist/string_and_binary/convert.d.ts +8 -0
- package/dist/string_and_binary/convert.js +46 -0
- package/dist/string_and_binary/hash.d.ts +2 -0
- package/dist/string_and_binary/hash.js +1 -0
- package/dist/string_and_binary/path.d.ts +35 -0
- package/dist/string_and_binary/path.js +240 -0
- package/dist/worker/bg.common.d.ts +2 -0
- package/dist/worker/bg.common.js +6 -0
- package/dist/worker/bg.worker.d.ts +1 -0
- package/dist/worker/bg.worker.encryption.d.ts +7 -0
- package/dist/worker/bg.worker.encryption.js +30 -0
- package/dist/worker/bg.worker.js +14 -0
- package/dist/worker/bg.worker.splitting.d.ts +6 -0
- package/dist/worker/bg.worker.splitting.js +36 -0
- package/dist/worker/bgWorker.d.ts +25 -0
- package/dist/worker/bgWorker.direct.d.ts +40 -0
- package/dist/worker/bgWorker.direct.js +65 -0
- package/dist/worker/bgWorker.encryption.d.ts +22 -0
- package/dist/worker/bgWorker.encryption.js +40 -0
- package/dist/worker/bgWorker.js +348 -0
- package/dist/worker/bgWorker.splitting.d.ts +27 -0
- package/dist/worker/bgWorker.splitting.js +123 -0
- package/dist/worker/universalTypes.d.ts +63 -0
- package/dist/worker/universalTypes.js +4 -0
- package/docs/development.md +51 -0
- package/docs/platform-storage.md +60 -0
- package/docs/releasing.md +69 -0
- package/package.json +693 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { Minimatch } from "minimatch";
|
|
2
|
+
import { getWebCrypto } from "../mods.js";
|
|
3
|
+
import {
|
|
4
|
+
FLAGMD_REDFLAG,
|
|
5
|
+
FLAGMD_REDFLAG2,
|
|
6
|
+
FLAGMD_REDFLAG3,
|
|
7
|
+
PREFIX_OBFUSCATED,
|
|
8
|
+
PREFIXMD_LOGFILE,
|
|
9
|
+
FLAGMD_REDFLAG2_HR,
|
|
10
|
+
FLAGMD_REDFLAG3_HR,
|
|
11
|
+
PREFIXMD_LOGFILE_UC
|
|
12
|
+
} from "../common/types.js";
|
|
13
|
+
import { memorizeFuncWithLRUCache } from "../common/utils.js";
|
|
14
|
+
import { uint8ArrayToHexString, writeString } from "./convert.js";
|
|
15
|
+
import { unique } from "octagonal-wheels/collection.js";
|
|
16
|
+
function isValidFilenameInWidows(filename) {
|
|
17
|
+
const regex = /[\u0000-\u001f]|[\\":?<>|*#]/g;
|
|
18
|
+
if (regex.test(filename)) return false;
|
|
19
|
+
const win = /(\\|\/)(COM\d|LPT\d|CON|PRN|AUX|NUL|CLOCK$)($|\.)/gi;
|
|
20
|
+
if (win.test(filename)) return false;
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
function isValidFilenameInDarwin(filename) {
|
|
24
|
+
const regex = /[\u0000-\u001f]|[:]/g;
|
|
25
|
+
return !regex.test(filename);
|
|
26
|
+
}
|
|
27
|
+
function isValidFilenameInLinux(filename) {
|
|
28
|
+
const regex = /[\u0000-\u001f]|[:]/g;
|
|
29
|
+
return !regex.test(filename);
|
|
30
|
+
}
|
|
31
|
+
function isValidFilenameInAndroid(filename) {
|
|
32
|
+
const regex = /[\u0000-\u001f]|[\\":?<>|*#]/g;
|
|
33
|
+
return !regex.test(filename);
|
|
34
|
+
}
|
|
35
|
+
function isFilePath(path) {
|
|
36
|
+
if (path.indexOf(":") === -1) return true;
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
function stripAllPrefixes(prefixedPath) {
|
|
40
|
+
if (isFilePath(prefixedPath)) return prefixedPath;
|
|
41
|
+
const [, body] = expandFilePathPrefix(prefixedPath);
|
|
42
|
+
return stripAllPrefixes(body);
|
|
43
|
+
}
|
|
44
|
+
function addPrefix(path, prefix) {
|
|
45
|
+
if (prefix && path.startsWith(prefix)) return path;
|
|
46
|
+
return `${prefix ?? ""}${path}`;
|
|
47
|
+
}
|
|
48
|
+
function expandFilePathPrefix(path) {
|
|
49
|
+
let [prefix, body] = path.split(":", 2);
|
|
50
|
+
if (!body) {
|
|
51
|
+
body = prefix;
|
|
52
|
+
prefix = "";
|
|
53
|
+
} else {
|
|
54
|
+
prefix = prefix + ":";
|
|
55
|
+
}
|
|
56
|
+
return [prefix, body];
|
|
57
|
+
}
|
|
58
|
+
function expandDocumentIDPrefix(id) {
|
|
59
|
+
let [prefix, body] = id.split(":", 2);
|
|
60
|
+
if (!body) {
|
|
61
|
+
body = prefix;
|
|
62
|
+
prefix = "";
|
|
63
|
+
} else {
|
|
64
|
+
prefix = prefix + ":";
|
|
65
|
+
}
|
|
66
|
+
return [prefix, body];
|
|
67
|
+
}
|
|
68
|
+
const _hashString = memorizeFuncWithLRUCache(async (key) => {
|
|
69
|
+
const buff = writeString(key);
|
|
70
|
+
const webcrypto = await getWebCrypto();
|
|
71
|
+
let digest = await webcrypto.subtle.digest("SHA-256", buff);
|
|
72
|
+
const len = key.length;
|
|
73
|
+
for (let i = 0; i < len; i++) {
|
|
74
|
+
digest = await webcrypto.subtle.digest("SHA-256", buff);
|
|
75
|
+
}
|
|
76
|
+
return uint8ArrayToHexString(new Uint8Array(digest));
|
|
77
|
+
});
|
|
78
|
+
function hashString(key) {
|
|
79
|
+
return _hashString(key);
|
|
80
|
+
}
|
|
81
|
+
async function path2id_base(filenameSrc, obfuscatePassphrase, caseInsensitive) {
|
|
82
|
+
if (filenameSrc.startsWith(PREFIX_OBFUSCATED)) return `${filenameSrc}`;
|
|
83
|
+
let filename = `${filenameSrc}`;
|
|
84
|
+
const newPrefix = obfuscatePassphrase ? PREFIX_OBFUSCATED : "";
|
|
85
|
+
if (caseInsensitive) {
|
|
86
|
+
filename = filename.toLowerCase();
|
|
87
|
+
}
|
|
88
|
+
let x = filename;
|
|
89
|
+
if (x.startsWith("_")) x = "/" + x;
|
|
90
|
+
if (!obfuscatePassphrase) {
|
|
91
|
+
return newPrefix + x;
|
|
92
|
+
}
|
|
93
|
+
const [prefix, body] = expandFilePathPrefix(x);
|
|
94
|
+
if (body.startsWith(PREFIX_OBFUSCATED)) return newPrefix + x;
|
|
95
|
+
const hashedPassphrase = await hashString(obfuscatePassphrase);
|
|
96
|
+
const out = await hashString(`${hashedPassphrase}:${filename}`);
|
|
97
|
+
return prefix + newPrefix + out;
|
|
98
|
+
}
|
|
99
|
+
function id2path_base(id, entry) {
|
|
100
|
+
if (entry && entry?.path) {
|
|
101
|
+
return id2path_base(entry.path);
|
|
102
|
+
}
|
|
103
|
+
if (id.startsWith(PREFIX_OBFUSCATED)) throw new Error("Entry has been obfuscated!");
|
|
104
|
+
const [prefix, body] = expandDocumentIDPrefix(id);
|
|
105
|
+
if (body.startsWith(PREFIX_OBFUSCATED)) throw new Error("Entry has been obfuscated!");
|
|
106
|
+
if (body.startsWith("/")) {
|
|
107
|
+
return body.substring(1);
|
|
108
|
+
}
|
|
109
|
+
return prefix + body;
|
|
110
|
+
}
|
|
111
|
+
function getPath(entry) {
|
|
112
|
+
return id2path_base(entry._id, entry);
|
|
113
|
+
}
|
|
114
|
+
function getPathWithoutPrefix(entry) {
|
|
115
|
+
const f = getPath(entry);
|
|
116
|
+
return stripAllPrefixes(f);
|
|
117
|
+
}
|
|
118
|
+
function stripPrefix(prefixedPath) {
|
|
119
|
+
const [prefix, body] = prefixedPath.split(":", 2);
|
|
120
|
+
if (!body) {
|
|
121
|
+
return prefix;
|
|
122
|
+
}
|
|
123
|
+
return body;
|
|
124
|
+
}
|
|
125
|
+
function shouldBeIgnored(filename) {
|
|
126
|
+
if (filename == FLAGMD_REDFLAG) {
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
if (filename == FLAGMD_REDFLAG2) {
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
if (filename == FLAGMD_REDFLAG2_HR) {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
if (filename == FLAGMD_REDFLAG3) {
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
if (filename == FLAGMD_REDFLAG3_HR) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
if (filename.startsWith(PREFIXMD_LOGFILE)) {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
if (filename.startsWith(PREFIXMD_LOGFILE_UC)) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
function isPlainText(filename) {
|
|
150
|
+
if (filename.endsWith(".md")) return true;
|
|
151
|
+
if (filename.endsWith(".txt")) return true;
|
|
152
|
+
if (filename.endsWith(".svg")) return true;
|
|
153
|
+
if (filename.endsWith(".html")) return true;
|
|
154
|
+
if (filename.endsWith(".csv")) return true;
|
|
155
|
+
if (filename.endsWith(".css")) return true;
|
|
156
|
+
if (filename.endsWith(".js")) return true;
|
|
157
|
+
if (filename.endsWith(".xml")) return true;
|
|
158
|
+
if (filename.endsWith(".canvas")) return true;
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
function shouldSplitAsPlainText(filename) {
|
|
162
|
+
if (filename.endsWith(".md")) return true;
|
|
163
|
+
if (filename.endsWith(".txt")) return true;
|
|
164
|
+
if (filename.endsWith(".canvas")) return true;
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
const matchOpts = { platform: "linux", dot: true, flipNegate: true, nocase: true };
|
|
168
|
+
const matcherCache = /* @__PURE__ */ new WeakMap();
|
|
169
|
+
function matchIgnoredPath(path, pattern, ignore) {
|
|
170
|
+
let matchers = matcherCache.get(ignore);
|
|
171
|
+
if (matchers === void 0) {
|
|
172
|
+
matchers = /* @__PURE__ */ new Map();
|
|
173
|
+
matcherCache.set(ignore, matchers);
|
|
174
|
+
}
|
|
175
|
+
let matcher = matchers.get(pattern);
|
|
176
|
+
if (matcher === void 0) {
|
|
177
|
+
matcher = new Minimatch(pattern, matchOpts);
|
|
178
|
+
matchers.set(pattern, matcher);
|
|
179
|
+
}
|
|
180
|
+
return matcher.match(path);
|
|
181
|
+
}
|
|
182
|
+
function isAccepted(path, ignore) {
|
|
183
|
+
if (path.indexOf("./") !== -1 || path.indexOf("../") !== -1) {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
const patterns = ignore.map((e) => e.trim()).filter((e) => e.length > 0 && !e.startsWith("#"));
|
|
187
|
+
let result = void 0;
|
|
188
|
+
for (const pattern of patterns) {
|
|
189
|
+
if (pattern.endsWith("/")) {
|
|
190
|
+
if (matchIgnoredPath(path, `${pattern}**`, ignore)) {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const newResult = pattern.startsWith("!");
|
|
195
|
+
const matched = matchIgnoredPath(path, pattern, ignore) || !pattern.endsWith("/") && matchIgnoredPath(path, pattern + "/**", ignore);
|
|
196
|
+
if (matched) {
|
|
197
|
+
result = newResult;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return result;
|
|
201
|
+
}
|
|
202
|
+
async function isAcceptedAll(path, ignoreFiles, getList) {
|
|
203
|
+
const pathBase = path.substring(0, path.lastIndexOf("/"));
|
|
204
|
+
const intermediatePaths = unique(
|
|
205
|
+
pathBase.split("/").reduce((p, c) => [...p, p[p.length - 1] + "/" + c], [""]).map((e) => e.substring(1))
|
|
206
|
+
).reverse();
|
|
207
|
+
for (const intermediatePath of intermediatePaths) {
|
|
208
|
+
for (const ignoreFile of ignoreFiles) {
|
|
209
|
+
const ignoreFilePath = intermediatePath + "/" + ignoreFile;
|
|
210
|
+
const list = await getList(ignoreFilePath);
|
|
211
|
+
if (list === false) continue;
|
|
212
|
+
const result = isAccepted(path.substring(intermediatePath.length ? intermediatePath.length + 1 : 0), list);
|
|
213
|
+
if (result !== void 0) {
|
|
214
|
+
return result;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
export {
|
|
221
|
+
addPrefix,
|
|
222
|
+
expandDocumentIDPrefix,
|
|
223
|
+
expandFilePathPrefix,
|
|
224
|
+
getPath,
|
|
225
|
+
getPathWithoutPrefix,
|
|
226
|
+
id2path_base,
|
|
227
|
+
isAccepted,
|
|
228
|
+
isAcceptedAll,
|
|
229
|
+
isFilePath,
|
|
230
|
+
isPlainText,
|
|
231
|
+
isValidFilenameInAndroid,
|
|
232
|
+
isValidFilenameInDarwin,
|
|
233
|
+
isValidFilenameInLinux,
|
|
234
|
+
isValidFilenameInWidows,
|
|
235
|
+
path2id_base,
|
|
236
|
+
shouldBeIgnored,
|
|
237
|
+
shouldSplitAsPlainText,
|
|
238
|
+
stripAllPrefixes,
|
|
239
|
+
stripPrefix
|
|
240
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { EncryptHKDFArguments } from "./universalTypes.js";
|
|
2
|
+
import type { EncryptArguments } from "./universalTypes.js";
|
|
3
|
+
/**
|
|
4
|
+
* Processes the encryption of data.
|
|
5
|
+
* @param data The data to be encrypted or decrypted.
|
|
6
|
+
*/
|
|
7
|
+
export declare function processEncryption(data: EncryptArguments | EncryptHKDFArguments): Promise<void>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { encrypt, decrypt } from "octagonal-wheels/encryption";
|
|
2
|
+
import { encrypt as encryptHKDF, decrypt as decryptHKDF } from "octagonal-wheels/encryption/hkdf";
|
|
3
|
+
async function processEncryption(data) {
|
|
4
|
+
const key = data.key;
|
|
5
|
+
const { type, input, passphrase } = data;
|
|
6
|
+
try {
|
|
7
|
+
if (type == "encrypt") {
|
|
8
|
+
const autoCalculateIterations = data.autoCalculateIterations;
|
|
9
|
+
const result = await encrypt(input, passphrase, autoCalculateIterations);
|
|
10
|
+
self.postMessage({ key, result });
|
|
11
|
+
} else if (type == "decrypt") {
|
|
12
|
+
const autoCalculateIterations = data.autoCalculateIterations;
|
|
13
|
+
const result = await decrypt(input, passphrase, autoCalculateIterations);
|
|
14
|
+
self.postMessage({ key, result });
|
|
15
|
+
} else if (type == "encryptHKDF") {
|
|
16
|
+
const pbkdf2Salt = data.pbkdf2Salt;
|
|
17
|
+
const result = await encryptHKDF(input, passphrase, pbkdf2Salt);
|
|
18
|
+
self.postMessage({ key, result });
|
|
19
|
+
} else if (type == "decryptHKDF") {
|
|
20
|
+
const pbkdf2Salt = data.pbkdf2Salt;
|
|
21
|
+
const result = await decryptHKDF(input, passphrase, pbkdf2Salt);
|
|
22
|
+
self.postMessage({ key, result });
|
|
23
|
+
}
|
|
24
|
+
} catch (ex) {
|
|
25
|
+
self.postMessage({ key, error: ex });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
processEncryption
|
|
30
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { processSplit } from "./bg.worker.splitting.js";
|
|
2
|
+
import { processEncryption } from "./bg.worker.encryption.js";
|
|
3
|
+
self.onmessage = (e) => {
|
|
4
|
+
const data = e.data.data;
|
|
5
|
+
if (data.type === "split") {
|
|
6
|
+
return processSplit(data);
|
|
7
|
+
} else if (data.type === "encrypt" || data.type === "decrypt") {
|
|
8
|
+
return processEncryption(data);
|
|
9
|
+
} else if (data.type === "encryptHKDF" || data.type === "decryptHKDF") {
|
|
10
|
+
return processEncryption(data);
|
|
11
|
+
} else {
|
|
12
|
+
self.postMessage({ key: data.key, error: new Error("Invalid type") });
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { splitPiecesRabinKarp, splitPieces2V2, splitPieces2 } from "../string_and_binary/chunks.js";
|
|
2
|
+
import { postBack } from "./bg.common.js";
|
|
3
|
+
import { END_OF_DATA } from "./universalTypes.js";
|
|
4
|
+
function getMainThreadPostBack(key) {
|
|
5
|
+
const _key = key;
|
|
6
|
+
let seq = 0;
|
|
7
|
+
return function(data) {
|
|
8
|
+
if (data === END_OF_DATA) {
|
|
9
|
+
if (seq === 0) {
|
|
10
|
+
postBack(_key, seq++, "");
|
|
11
|
+
}
|
|
12
|
+
postBack(_key, seq++, END_OF_DATA);
|
|
13
|
+
} else {
|
|
14
|
+
postBack(_key, seq++, data);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
async function processSplit(data) {
|
|
19
|
+
const key = data.key;
|
|
20
|
+
const dataSrc = data.dataSrc;
|
|
21
|
+
const pieceSize = data.pieceSize;
|
|
22
|
+
const plainSplit = data.plainSplit;
|
|
23
|
+
const minimumChunkSize = data.minimumChunkSize;
|
|
24
|
+
const filename = data.filename;
|
|
25
|
+
const useSegmenter = data.useSegmenter;
|
|
26
|
+
const func = data.splitVersion == 3 ? splitPiecesRabinKarp : data.splitVersion == 2 ? splitPieces2V2 : splitPieces2;
|
|
27
|
+
const gen = await func(dataSrc, pieceSize, plainSplit, minimumChunkSize, filename, useSegmenter);
|
|
28
|
+
const emit = getMainThreadPostBack(key);
|
|
29
|
+
for await (const v of gen()) {
|
|
30
|
+
emit(v);
|
|
31
|
+
}
|
|
32
|
+
emit(END_OF_DATA);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
processSplit
|
|
36
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { LiveSyncEventHub } from "../hub/hub.js";
|
|
2
|
+
import type { EncryptArguments, EncryptHKDFArguments, EncryptHKDFProcessItem, EncryptProcessItem, ProcessItem, SplitArguments, SplitProcessItem } from "./universalTypes.js";
|
|
3
|
+
export type WorkerInstance = {
|
|
4
|
+
worker: Worker;
|
|
5
|
+
processing: number;
|
|
6
|
+
/** Keys of tasks currently dispatched to this worker instance. */
|
|
7
|
+
taskKeys: Set<number>;
|
|
8
|
+
};
|
|
9
|
+
export declare function splitPieces2Worker(dataSrc: Blob, pieceSize: number, plainSplit: boolean, minimumChunkSize: number, filename?: string, useSegmenter?: boolean): () => AsyncGenerator<string, void, unknown>;
|
|
10
|
+
export declare function splitPieces2WorkerV2(dataSrc: Blob, pieceSize: number, plainSplit: boolean, minimumChunkSize: number, filename?: string, useSegmenter?: boolean): () => AsyncGenerator<string, void, unknown>;
|
|
11
|
+
export declare function splitPieces2WorkerRabinKarp(dataSrc: Blob, pieceSize: number, plainSplit: boolean, minimumChunkSize: number, filename?: string, useSegmenter?: boolean): () => AsyncGenerator<string, void, unknown>;
|
|
12
|
+
export declare function encryptWorker(input: string, passphrase: string, autoCalculateIterations: boolean): Promise<string>;
|
|
13
|
+
export declare function decryptWorker(input: string, passphrase: string, autoCalculateIterations: boolean): Promise<string>;
|
|
14
|
+
export declare function encryptHKDFWorker(input: string, passphrase: string, pbkdf2Salt: Uint8Array<ArrayBuffer>): Promise<string>;
|
|
15
|
+
export declare function decryptHKDFWorker(input: string, passphrase: string, pbkdf2Salt: Uint8Array<ArrayBuffer>): Promise<string>;
|
|
16
|
+
export declare const tasks: Map<number, ProcessItem>;
|
|
17
|
+
/**
|
|
18
|
+
* Remove a completed (or aborted) task from both the tasks map and its worker's taskKeys set.
|
|
19
|
+
*/
|
|
20
|
+
export declare function removeTask(key: number): void;
|
|
21
|
+
export declare function initialiseWorkerModule(events: LiveSyncEventHub): void;
|
|
22
|
+
export declare function startWorker(data: Omit<EncryptHKDFArguments, "key">): EncryptHKDFProcessItem;
|
|
23
|
+
export declare function startWorker(data: Omit<EncryptArguments, "key">): EncryptProcessItem;
|
|
24
|
+
export declare function startWorker(data: Omit<SplitArguments, "key">): SplitProcessItem;
|
|
25
|
+
export declare function terminateWorker(): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { EncryptHKDFProcessItem, EncryptProcessItem, SplitProcessItem, ProcessItem } from "./universalTypes.js";
|
|
2
|
+
import type { LiveSyncEventHub } from "../hub/hub.js";
|
|
3
|
+
export type SplitArguments = {
|
|
4
|
+
key: number;
|
|
5
|
+
type: "split";
|
|
6
|
+
dataSrc: Blob;
|
|
7
|
+
pieceSize: number;
|
|
8
|
+
plainSplit: boolean;
|
|
9
|
+
minimumChunkSize: number;
|
|
10
|
+
filename?: string;
|
|
11
|
+
useV2: boolean;
|
|
12
|
+
useSegmenter: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type EncryptArguments = {
|
|
15
|
+
key: number;
|
|
16
|
+
type: "encrypt" | "decrypt";
|
|
17
|
+
input: string;
|
|
18
|
+
passphrase: string;
|
|
19
|
+
autoCalculateIterations: boolean;
|
|
20
|
+
};
|
|
21
|
+
export type EncryptHKDFArguments = {
|
|
22
|
+
key: number;
|
|
23
|
+
type: "encryptHKDF" | "decryptHKDF";
|
|
24
|
+
input: string;
|
|
25
|
+
passphrase: string;
|
|
26
|
+
pbkdf2Salt: Uint8Array;
|
|
27
|
+
};
|
|
28
|
+
export declare function terminateWorker(): void;
|
|
29
|
+
export declare function splitPieces2Worker(dataSrc: Blob, pieceSize: number, plainSplit: boolean, minimumChunkSize: number, filename?: string, useSegmenter?: boolean): Promise<(() => Generator<string>) | (() => AsyncGenerator<string>)>;
|
|
30
|
+
export declare function splitPieces2WorkerV2(dataSrc: Blob, pieceSize: number, plainSplit: boolean, minimumChunkSize: number, filename?: string, useSegmenter?: boolean): Promise<(() => Generator<string>) | (() => AsyncGenerator<string>)>;
|
|
31
|
+
export declare function splitPieces2WorkerRabinKarp(dataSrc: Blob, pieceSize: number, plainSplit: boolean, minimumChunkSize: number, filename?: string, useSegmenter?: boolean): () => AsyncGenerator<string, void, unknown>;
|
|
32
|
+
export declare function encryptWorker(input: string, passphrase: string, autoCalculateIterations: boolean): Promise<string>;
|
|
33
|
+
export declare function decryptWorker(input: string, passphrase: string, autoCalculateIterations: boolean): Promise<string>;
|
|
34
|
+
export declare function encryptHKDFWorker(input: string, passphrase: string, pbkdf2Salt: Uint8Array<ArrayBuffer>): Promise<string>;
|
|
35
|
+
export declare function decryptHKDFWorker(input: string, passphrase: string, pbkdf2Salt: Uint8Array<ArrayBuffer>): Promise<string>;
|
|
36
|
+
export declare function startWorker(data: Omit<EncryptHKDFArguments, "key">): EncryptHKDFProcessItem;
|
|
37
|
+
export declare function startWorker(data: Omit<EncryptArguments, "key">): EncryptProcessItem;
|
|
38
|
+
export declare function startWorker(data: Omit<SplitArguments, "key">): SplitProcessItem;
|
|
39
|
+
export declare const tasks: Map<number, ProcessItem>;
|
|
40
|
+
export declare function initialiseWorkerModule(_events: LiveSyncEventHub): void;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { decrypt, encrypt } from "octagonal-wheels/encryption/index.js";
|
|
2
|
+
import { encrypt as encryptHKDF, decrypt as decryptHKDF } from "octagonal-wheels/encryption/hkdf";
|
|
3
|
+
import { splitPieces2, splitPieces2V2, splitPiecesRabinKarp } from "../string_and_binary/chunks.js";
|
|
4
|
+
import { promiseWithResolvers } from "octagonal-wheels/promises";
|
|
5
|
+
function terminateWorker() {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
function splitPieces2Worker(dataSrc, pieceSize, plainSplit, minimumChunkSize, filename, useSegmenter) {
|
|
9
|
+
return splitPieces2(dataSrc, pieceSize, plainSplit, minimumChunkSize, filename, useSegmenter ?? false);
|
|
10
|
+
}
|
|
11
|
+
function splitPieces2WorkerV2(dataSrc, pieceSize, plainSplit, minimumChunkSize, filename, useSegmenter) {
|
|
12
|
+
return splitPieces2V2(dataSrc, pieceSize, plainSplit, minimumChunkSize, filename, useSegmenter ?? false);
|
|
13
|
+
}
|
|
14
|
+
function splitPieces2WorkerRabinKarp(dataSrc, pieceSize, plainSplit, minimumChunkSize, filename, useSegmenter) {
|
|
15
|
+
return async function* () {
|
|
16
|
+
const splitter = await splitPiecesRabinKarp(
|
|
17
|
+
dataSrc,
|
|
18
|
+
pieceSize,
|
|
19
|
+
plainSplit,
|
|
20
|
+
minimumChunkSize,
|
|
21
|
+
filename,
|
|
22
|
+
useSegmenter ?? false
|
|
23
|
+
);
|
|
24
|
+
yield* splitter();
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function encryptWorker(input, passphrase, autoCalculateIterations) {
|
|
28
|
+
return encrypt(input, passphrase, autoCalculateIterations);
|
|
29
|
+
}
|
|
30
|
+
function decryptWorker(input, passphrase, autoCalculateIterations) {
|
|
31
|
+
return decrypt(input, passphrase, autoCalculateIterations);
|
|
32
|
+
}
|
|
33
|
+
function encryptHKDFWorker(input, passphrase, pbkdf2Salt) {
|
|
34
|
+
return encryptHKDF(input, passphrase, pbkdf2Salt);
|
|
35
|
+
}
|
|
36
|
+
function decryptHKDFWorker(input, passphrase, pbkdf2Salt) {
|
|
37
|
+
return decryptHKDF(input, passphrase, pbkdf2Salt);
|
|
38
|
+
}
|
|
39
|
+
function startWorker(data) {
|
|
40
|
+
const task = promiseWithResolvers();
|
|
41
|
+
task.resolve("");
|
|
42
|
+
return {
|
|
43
|
+
task,
|
|
44
|
+
key: 0,
|
|
45
|
+
type: data.type,
|
|
46
|
+
finalize: () => {
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const tasks = /* @__PURE__ */ new Map();
|
|
51
|
+
function initialiseWorkerModule(_events) {
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
decryptHKDFWorker,
|
|
55
|
+
decryptWorker,
|
|
56
|
+
encryptHKDFWorker,
|
|
57
|
+
encryptWorker,
|
|
58
|
+
initialiseWorkerModule,
|
|
59
|
+
splitPieces2Worker,
|
|
60
|
+
splitPieces2WorkerRabinKarp,
|
|
61
|
+
splitPieces2WorkerV2,
|
|
62
|
+
startWorker,
|
|
63
|
+
tasks,
|
|
64
|
+
terminateWorker
|
|
65
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type EncryptHKDFProcessItem, type ResultPayload } from "./universalTypes.js";
|
|
2
|
+
import { type EncryptProcessItem } from "./universalTypes.js";
|
|
3
|
+
import { type EncryptHKDFArguments } from "./universalTypes.js";
|
|
4
|
+
import { type EncryptArguments } from "./universalTypes.js";
|
|
5
|
+
/**
|
|
6
|
+
* Offloads encryption to a web worker.
|
|
7
|
+
* @param data The data to be encrypted.
|
|
8
|
+
* @returns A promise that resolves with the encryption result.
|
|
9
|
+
*/
|
|
10
|
+
export declare function encryptionOnWorker(data: Omit<EncryptArguments, "key">): Promise<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Offloads HKDF encryption to a web worker.
|
|
13
|
+
* @param data The data to be encrypted.
|
|
14
|
+
* @returns A promise that resolves with the encryption result.
|
|
15
|
+
*/
|
|
16
|
+
export declare function encryptionHKDFOnWorker(data: Omit<EncryptHKDFArguments, "key">): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Handles the encryption callbacks
|
|
19
|
+
* @param process The process item associated with the task.
|
|
20
|
+
* @param data The data to be processed.
|
|
21
|
+
*/
|
|
22
|
+
export declare function handleTaskEncrypt(process: EncryptProcessItem | EncryptHKDFProcessItem, data: ResultPayload): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { startWorker, removeTask } from "./bgWorker.js";
|
|
2
|
+
import {} from "./universalTypes.js";
|
|
3
|
+
import {} from "./universalTypes.js";
|
|
4
|
+
import {} from "./universalTypes.js";
|
|
5
|
+
import {} from "./universalTypes.js";
|
|
6
|
+
function encryptionOnWorker(data) {
|
|
7
|
+
const process = startWorker(data);
|
|
8
|
+
return (async () => {
|
|
9
|
+
const ret = await process.task.promise;
|
|
10
|
+
process.finalize();
|
|
11
|
+
return ret;
|
|
12
|
+
})();
|
|
13
|
+
}
|
|
14
|
+
function encryptionHKDFOnWorker(data) {
|
|
15
|
+
const process = startWorker(data);
|
|
16
|
+
return (async () => {
|
|
17
|
+
const ret = await process.task.promise;
|
|
18
|
+
process.finalize();
|
|
19
|
+
return ret;
|
|
20
|
+
})();
|
|
21
|
+
}
|
|
22
|
+
function handleTaskEncrypt(process, data) {
|
|
23
|
+
const key = data.key;
|
|
24
|
+
const task = process.task;
|
|
25
|
+
if ("result" in data) {
|
|
26
|
+
task.resolve(data.result);
|
|
27
|
+
} else {
|
|
28
|
+
if (data.error) {
|
|
29
|
+
task.reject(data.error);
|
|
30
|
+
} else {
|
|
31
|
+
task.reject(new Error("Unknown error in background encryption"));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
removeTask(key);
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
encryptionHKDFOnWorker,
|
|
38
|
+
encryptionOnWorker,
|
|
39
|
+
handleTaskEncrypt
|
|
40
|
+
};
|