@vrtmrz/livesync-commonlib 0.1.31 → 0.1.32

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.
Files changed (53) hide show
  1. package/README.md +5 -0
  2. package/dist/API/DirectFileManipulatorV2.d.ts +2 -0
  3. package/dist/API/DirectFileManipulatorV2.js +17 -5
  4. package/dist/API/processSetting.d.ts +19 -0
  5. package/dist/API/processSetting.js +91 -6
  6. package/dist/common/idDerivation.d.ts +13 -0
  7. package/dist/common/idDerivation.js +75 -0
  8. package/dist/common/models/db.definition.d.ts +1 -0
  9. package/dist/common/models/setting.const.defaults.js +3 -0
  10. package/dist/common/models/setting.const.qr.js +4 -1
  11. package/dist/common/models/setting.type.d.ts +6 -0
  12. package/dist/common/models/tweak.compatibility.js +6 -2
  13. package/dist/common/models/tweak.definition.d.ts +8 -0
  14. package/dist/common/models/tweak.definition.js +4 -3
  15. package/dist/common/settingConstants.d.ts +3 -0
  16. package/dist/common/utils.js +3 -1
  17. package/dist/events/coreEvents.d.ts +3 -0
  18. package/dist/events/coreEvents.js +2 -0
  19. package/dist/managers/EntryManager/EntryManagerImpls.js +10 -1
  20. package/dist/managers/HashManager/HashManager.d.ts +1 -0
  21. package/dist/managers/HashManager/HashManager.js +13 -1
  22. package/dist/pouchdb/LiveSyncDBFunctions.d.ts +1 -1
  23. package/dist/pouchdb/LiveSyncDBFunctions.js +33 -38
  24. package/dist/pouchdb/negotiation.js +7 -3
  25. package/dist/pouchdb/remoteFeatureCompatibility.d.ts +10 -0
  26. package/dist/pouchdb/remoteFeatureCompatibility.js +12 -1
  27. package/dist/pouchdb/remoteIdCompatibility.d.ts +5 -0
  28. package/dist/pouchdb/remoteIdCompatibility.js +28 -0
  29. package/dist/replication/CentralCompatibility.d.ts +1 -0
  30. package/dist/replication/CentralCompatibility.js +2 -1
  31. package/dist/replication/couchdb/LiveSyncReplicator.d.ts +6 -2
  32. package/dist/replication/couchdb/LiveSyncReplicator.js +24 -5
  33. package/dist/replication/journal/LiveSyncJournalReplicator.d.ts +1 -0
  34. package/dist/replication/journal/LiveSyncJournalReplicator.js +50 -5
  35. package/dist/replication/trystero/TrysteroReplicator.d.ts +369 -5
  36. package/dist/replication/trystero/TrysteroReplicator.js +31 -4
  37. package/dist/services/base/AppLifecycleService.d.ts +2 -0
  38. package/dist/services/base/AppLifecycleService.js +5 -0
  39. package/dist/services/base/IService.d.ts +1 -0
  40. package/dist/services/base/PathService.d.ts +3 -1
  41. package/dist/services/base/PathService.js +9 -4
  42. package/dist/services/base/SettingService.js +47 -0
  43. package/dist/settings.d.ts +2 -1
  44. package/dist/settings.js +14 -0
  45. package/dist/setupUri.d.ts +6 -0
  46. package/dist/setupUri.js +14 -0
  47. package/dist/string_and_binary/path.d.ts +1 -1
  48. package/dist/string_and_binary/path.js +3 -3
  49. package/dist/worker/bgWorker.js +1 -1
  50. package/docs/proven-in-use.md +8 -0
  51. package/docs/releasing.md +1 -1
  52. package/docs/setup-uri.md +58 -0
  53. package/package.json +9 -1
package/dist/settings.js CHANGED
@@ -12,6 +12,14 @@ 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 {
16
+ deriveIdKey,
17
+ deriveOrImportIdKey,
18
+ formatIdRecoveryCode,
19
+ configuredIdKey,
20
+ ID_DERIVATION_VERSION,
21
+ ID_RECOVERY_CODE_PREFIX
22
+ } from "./common/idDerivation.js";
15
23
  import {
16
24
  prepareSettingsForLoad,
17
25
  SettingsMigrationReviewCodes
@@ -20,6 +28,8 @@ import { assessTweakCompatibility } from "./common/models/tweak.compatibility.js
20
28
  export {
21
29
  CURRENT_SETTING_VERSION,
22
30
  DEFAULT_SETTINGS,
31
+ ID_DERIVATION_VERSION,
32
+ ID_RECOVERY_CODE_PREFIX,
23
33
  NEW_VAULT_SETTINGS,
24
34
  P2P_DEFAULT_SETTINGS,
25
35
  PREFERRED_BASE,
@@ -29,6 +39,10 @@ export {
29
39
  SETTINGS_SCHEMA_DEFAULTS,
30
40
  SettingsMigrationReviewCodes,
31
41
  assessTweakCompatibility,
42
+ configuredIdKey,
32
43
  createNewVaultSettings,
44
+ deriveIdKey,
45
+ deriveOrImportIdKey,
46
+ formatIdRecoveryCode,
33
47
  prepareSettingsForLoad
34
48
  };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Setup URI sharing for maintained hosts.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export { encodeSettingsToSetupURI, encodeTimeBoundSetupURI, getTimeBoundSetupURIUsableUntil, isTimeBoundSetupURIUsableNow, decodeSettingsFromSetupURI, type TimeBoundSetupURIOptions, type TimeBoundSetupURIResult, type TimeBoundSetupURIMode, } from "./API/processSetting.js";
@@ -0,0 +1,14 @@
1
+ import {
2
+ encodeSettingsToSetupURI,
3
+ encodeTimeBoundSetupURI,
4
+ getTimeBoundSetupURIUsableUntil,
5
+ isTimeBoundSetupURIUsableNow,
6
+ decodeSettingsFromSetupURI
7
+ } from "./API/processSetting.js";
8
+ export {
9
+ decodeSettingsFromSetupURI,
10
+ encodeSettingsToSetupURI,
11
+ encodeTimeBoundSetupURI,
12
+ getTimeBoundSetupURIUsableUntil,
13
+ isTimeBoundSetupURIUsableNow
14
+ };
@@ -8,7 +8,7 @@ export declare function stripAllPrefixes(prefixedPath: FilePathWithPrefix): File
8
8
  export declare function addPrefix(path: FilePath | FilePathWithPrefix, prefix: string): FilePathWithPrefix;
9
9
  export declare function expandFilePathPrefix(path: FilePathWithPrefix | FilePath): [string, FilePathWithPrefix];
10
10
  export declare function expandDocumentIDPrefix(id: DocumentID): [string, FilePathWithPrefix];
11
- export declare function path2id_base(filenameSrc: FilePathWithPrefix | FilePath, obfuscatePassphrase: string | false, caseInsensitive: boolean): Promise<DocumentID>;
11
+ export declare function path2id_base(filenameSrc: FilePathWithPrefix | FilePath, obfuscatePassphrase: string | false, caseInsensitive: boolean, idDerivationKey?: string): Promise<DocumentID>;
12
12
  export declare function id2path_base(id: DocumentID, entry?: EntryHasPath): FilePathWithPrefix;
13
13
  export declare function getPath(entry: AnyEntry): FilePathWithPrefix;
14
14
  export declare function getPathWithoutPrefix(entry: AnyEntry): FilePath;
@@ -14,6 +14,7 @@ import { memorizeFuncWithLRUCache } from "../common/utils.js";
14
14
  import { uint8ArrayToHexString, writeString } from "./convert.js";
15
15
  import { unique } from "octagonal-wheels/collection.js";
16
16
  import { CHeader, ICHeader, ICXHeader, PSCHeader } from "../common/models/fileaccess.const.js";
17
+ import { computeKeyedId } from "../common/idDerivation.js";
17
18
  function isValidFilenameInWidows(filename) {
18
19
  const regex = /[\u0000-\u001f]|[\\":?<>|*#]/g;
19
20
  if (regex.test(filename)) return false;
@@ -68,7 +69,7 @@ const _hashString = memorizeFuncWithLRUCache(async (key) => {
68
69
  function hashString(key) {
69
70
  return _hashString(key);
70
71
  }
71
- async function path2id_base(filenameSrc, obfuscatePassphrase, caseInsensitive) {
72
+ async function path2id_base(filenameSrc, obfuscatePassphrase, caseInsensitive, idDerivationKey) {
72
73
  if (filenameSrc.startsWith(PREFIX_OBFUSCATED)) return `${filenameSrc}`;
73
74
  let filename = `${filenameSrc}`;
74
75
  const newPrefix = obfuscatePassphrase ? PREFIX_OBFUSCATED : "";
@@ -82,8 +83,7 @@ async function path2id_base(filenameSrc, obfuscatePassphrase, caseInsensitive) {
82
83
  }
83
84
  const [prefix, body] = expandFilePathPrefix(x);
84
85
  if (body.startsWith(PREFIX_OBFUSCATED)) return newPrefix + x;
85
- const hashedPassphrase = await hashString(obfuscatePassphrase);
86
- const out = await hashString(`${hashedPassphrase}:${filename}`);
86
+ const out = idDerivationKey ? await computeKeyedId(idDerivationKey, "document", filename) : await hashString(`${await hashString(obfuscatePassphrase)}:${filename}`);
87
87
  return prefix + newPrefix + out;
88
88
  }
89
89
  function id2path_base(id, entry) {