@jr2804/livesync-cli 1.0.16-cli.1 → 1.0.17-cli.1

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 (2) hide show
  1. package/dist/index.cjs +120 -21
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -4028,6 +4028,16 @@ var RemoteTypes = {
4028
4028
  var REMOTE_COUCHDB = RemoteTypes.REMOTE_COUCHDB;
4029
4029
  var REMOTE_MINIO = RemoteTypes.REMOTE_MINIO;
4030
4030
  var REMOTE_P2P = RemoteTypes.REMOTE_P2P;
4031
+ var P2PConnectionPaths = {
4032
+ Automatic: "automatic",
4033
+ Relay: "relay"
4034
+ };
4035
+ var P2PMessageSizePresets = {
4036
+ Standard: 15360,
4037
+ Reduced: 2048,
4038
+ Conservative: 1024,
4039
+ MaximumCompatibility: 800
4040
+ };
4031
4041
  var E2EEAlgorithms = {
4032
4042
  V1: "",
4033
4043
  V2: "v2",
@@ -4053,6 +4063,33 @@ var ChunkAlgorithms = {
4053
4063
  RabinKarp: "v3-rabin-karp"
4054
4064
  };
4055
4065
  //#endregion
4066
+ //#region ../../../node_modules/@vrtmrz/livesync-commonlib/dist/common/models/setting.p2p.js
4067
+ function normaliseP2PMaxWirePayloadBytes(value) {
4068
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < P2PMessageSizePresets.MaximumCompatibility || value > P2PMessageSizePresets.Standard) return P2PMessageSizePresets.Standard;
4069
+ return value;
4070
+ }
4071
+ function normaliseP2PConnectionPath(value) {
4072
+ return value === P2PConnectionPaths.Relay ? P2PConnectionPaths.Relay : P2PConnectionPaths.Automatic;
4073
+ }
4074
+ function splitP2PTurnServerUrls(value) {
4075
+ return value.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0);
4076
+ }
4077
+ function isValidP2PTurnServerUrl(value) {
4078
+ const candidate = value.trim();
4079
+ if (!candidate || /\s/.test(candidate)) return false;
4080
+ try {
4081
+ const parsed = new URL(candidate);
4082
+ const protocol = parsed.protocol.toLowerCase();
4083
+ if (protocol !== "turn:" && protocol !== "turns:") return false;
4084
+ return (parsed.hostname || parsed.pathname).length > 0;
4085
+ } catch {
4086
+ return false;
4087
+ }
4088
+ }
4089
+ function hasValidP2PTurnServerUrl(value) {
4090
+ return splitP2PTurnServerUrls(value).some(isValidP2PTurnServerUrl);
4091
+ }
4092
+ //#endregion
4056
4093
  //#region ../../../node_modules/@vrtmrz/livesync-commonlib/dist/common/models/setting.const.preferred.js
4057
4094
  var PREFERRED_BASE = {
4058
4095
  syncMaxSizeInMB: 50,
@@ -4086,6 +4123,8 @@ var P2P_DEFAULT_SETTINGS = {
4086
4123
  P2P_turnServers: "",
4087
4124
  P2P_turnUsername: "",
4088
4125
  P2P_turnCredential: "",
4126
+ P2P_maxWirePayloadBytes: P2PMessageSizePresets.Standard,
4127
+ P2P_connectionPath: P2PConnectionPaths.Automatic,
4089
4128
  P2P_useDiagRTC: false
4090
4129
  };
4091
4130
  var SETTINGS_SCHEMA_DEFAULTS = {
@@ -4522,6 +4561,14 @@ var configurationNames = {
4522
4561
  desc: "The credential/password for the TURN servers.",
4523
4562
  isHidden: true
4524
4563
  },
4564
+ P2P_maxWirePayloadBytes: {
4565
+ name: "P2P Message Size",
4566
+ desc: "The maximum outgoing RPC wire payload before Commonlib splits it for the P2P transport."
4567
+ },
4568
+ P2P_connectionPath: {
4569
+ name: "Connection Path",
4570
+ desc: "Select the WebRTC route automatically or require a configured TURN relay."
4571
+ },
4525
4572
  useOnlyLocalChunk: {
4526
4573
  name: "Use Only Local Chunks",
4527
4574
  desc: "If enabled, the plugin will not attempt to connect to the remote database even if the chunk was not found locally.",
@@ -4545,10 +4592,6 @@ function statusDisplay(status) {
4545
4592
  if (status == "BETA") return ` (Beta)`;
4546
4593
  return ` (${status})`;
4547
4594
  }
4548
- function confName(key, alt = "") {
4549
- if (key in configurationNames) return `${configurationNames[key]?.name}${statusDisplay(configurationNames[key]?.status)}`;
4550
- else return `${alt || ""}`;
4551
- }
4552
4595
  //#endregion
4553
4596
  //#region ../../../node_modules/@vrtmrz/livesync-commonlib/dist/common/models/sync.definition.js
4554
4597
  var ProtocolVersions = {
@@ -10414,10 +10457,10 @@ var HeadlessAPIService = class extends InjectableAPIService {
10414
10457
  return "headless-app";
10415
10458
  }
10416
10459
  getAppVersion() {
10417
- return `1.0.16`;
10460
+ return `1.0.17`;
10418
10461
  }
10419
10462
  getPluginVersion() {
10420
- return `1.0.16`;
10463
+ return `1.0.17`;
10421
10464
  }
10422
10465
  getPlatform() {
10423
10466
  return "server";
@@ -11042,7 +11085,9 @@ var ConnectionStringParser = class {
11042
11085
  P2P_AutoBroadcast: searchParams.get("autoBroadcast") === "true",
11043
11086
  P2P_turnServers: searchParams.get("turnServers") || "",
11044
11087
  P2P_turnUsername: searchParams.get("turnUser") || "",
11045
- P2P_turnCredential: searchParams.get("turnPass") || ""
11088
+ P2P_turnCredential: searchParams.get("turnPass") || "",
11089
+ P2P_maxWirePayloadBytes: normaliseP2PMaxWirePayloadBytes(Number(searchParams.get("maxWirePayloadBytes"))),
11090
+ P2P_connectionPath: normaliseP2PConnectionPath(searchParams.get("connectionPath"))
11046
11091
  };
11047
11092
  }
11048
11093
  static serializeP2P(settings) {
@@ -11055,6 +11100,8 @@ var ConnectionStringParser = class {
11055
11100
  if (settings.P2P_turnServers) searchParams.set("turnServers", settings.P2P_turnServers);
11056
11101
  if (settings.P2P_turnUsername) searchParams.set("turnUser", settings.P2P_turnUsername);
11057
11102
  if (settings.P2P_turnCredential) searchParams.set("turnPass", settings.P2P_turnCredential);
11103
+ searchParams.set("maxWirePayloadBytes", String(normaliseP2PMaxWirePayloadBytes(settings.P2P_maxWirePayloadBytes)));
11104
+ searchParams.set("connectionPath", normaliseP2PConnectionPath(settings.P2P_connectionPath));
11058
11105
  return `sls+p2p://${settings.P2P_passphrase ? `:${encodeURIComponent(settings.P2P_passphrase)}@` : ""}${encodeURIComponent(settings.P2P_roomID)}${searchParams.toString() ? `?${searchParams.toString()}` : ""}`;
11059
11106
  }
11060
11107
  };
@@ -32134,6 +32181,17 @@ var liveSyncProvisionalEnglishMessages = {
32134
32181
  "Learn more about P2P connections": "Learn more about P2P connections",
32135
32182
  "Learn more about signalling and TURN": "Learn more about signalling and TURN",
32136
32183
  "TURN relays the encrypted WebRTC connection only when a direct path cannot be established. A TURN provider cannot read encrypted Vault contents, but it can observe connection metadata and traffic volume. Use a provider you trust.": "TURN relays the encrypted WebRTC connection only when a direct path cannot be established. A TURN provider cannot read encrypted Vault contents, but it can observe connection metadata and traffic volume. Use a provider you trust.",
32184
+ "Connection compatibility": "Connection compatibility",
32185
+ "P2P message size": "P2P message size",
32186
+ Standard: "Standard",
32187
+ Reduced: "Reduced",
32188
+ Conservative: "Conservative",
32189
+ "Maximum compatibility": "Maximum compatibility",
32190
+ "Smaller messages can improve compatibility on paths which fragment or drop larger WebRTC messages. This setting limits outgoing P2P messages, so use a compatible profile on each sending device when required.": "Smaller messages can improve compatibility on paths which fragment or drop larger WebRTC messages. This setting limits outgoing P2P messages, so use a compatible profile on each sending device when required.",
32191
+ "Connection path": "Connection path",
32192
+ "TURN relay only": "TURN relay only",
32193
+ "TURN relay only is available when at least one valid TURN server URL is configured under Advanced Settings.": "TURN relay only is available when at least one valid TURN server URL is configured under Advanced Settings.",
32194
+ "TURN relay only requires at least one valid TURN server URL. Connection path has been restored to Automatic.": "TURN relay only requires at least one valid TURN server URL. Connection path has been restored to Automatic.",
32137
32195
  "Announce changes": "Announce changes",
32138
32196
  "Announce changes automatically after connecting": "Announce changes automatically after connecting",
32139
32197
  "When enabled, this device notifies connected peers after a local change. The notification contains no Vault data; a peer which follows this device then fetches the change through the encrypted P2P connection.": "When enabled, this device notifies connected peers after a local change. The notification contains no Vault data; a peer which follows this device then fetches the change through the encrypted P2P connection.",
@@ -32309,6 +32367,10 @@ function $t(message, lang) {
32309
32367
  if (lang !== void 0) return _getMessage(message, lang);
32310
32368
  return getMessage(message);
32311
32369
  }
32370
+ function translateIfAvailable(message, lang) {
32371
+ if (message.trim() == "" || !isLiveSyncMessageKey(message) && !isCommonlibMessageKey(message)) return message;
32372
+ return $t(message, lang);
32373
+ }
32312
32374
  function isCommonlibMessageKey(key) {
32313
32375
  return key in commonlibEnglishMessages;
32314
32376
  }
@@ -54643,6 +54705,15 @@ var ModuleConflictResolver = class extends AbstractModule {
54643
54705
  };
54644
54706
  //#endregion
54645
54707
  //#region ../../modules/coreFeatures/ModuleResolveMismatchedTweaks.ts
54708
+ /**
54709
+ * Localised counterpart of Commonlib's `confName()`, which takes no translator.
54710
+ * Same shape: label plus status suffix, and an empty string for an unknown key.
54711
+ */
54712
+ function localisedConfName(key) {
54713
+ const info = configurationNames[key];
54714
+ if (!info) return "";
54715
+ return `${translateIfAvailable(info.name)}${statusDisplay(info.status)}`;
54716
+ }
54646
54717
  function valueToString(value) {
54647
54718
  if (typeof value === "boolean") return value ? "true" : "false";
54648
54719
  if (typeof value === "object") return JSON.stringify(value);
@@ -54730,7 +54801,7 @@ var ModuleResolvingMismatchedTweaks = class extends AbstractModule {
54730
54801
  }
54731
54802
  if (CompatibleButLossyChanges.indexOf(key) !== -1) rebuildRecommended = true;
54732
54803
  tableRows.push($msg("TweakMismatchResolve.Table.Row", {
54733
- name: confName(key),
54804
+ name: localisedConfName(key),
54734
54805
  self: valueToString(valueMine),
54735
54806
  remote: valueToString(valuePreferred)
54736
54807
  }));
@@ -54860,7 +54931,7 @@ var ModuleResolvingMismatchedTweaks = class extends AbstractModule {
54860
54931
  if (CompatibleButLossyChanges.indexOf(key) !== -1) rebuildRecommended = true;
54861
54932
  } else continue;
54862
54933
  tableRows.push($msg("TweakMismatchResolve.Table.Row", {
54863
- name: confName(key),
54934
+ name: localisedConfName(key),
54864
54935
  self: currentValueForDisplay,
54865
54936
  remote: remoteValueForDisplay
54866
54937
  }));
@@ -54919,8 +54990,8 @@ var ModuleResolvingMismatchedTweaks = class extends AbstractModule {
54919
54990
  };
54920
54991
  //#endregion
54921
54992
  //#region ../../../node_modules/@vrtmrz/livesync-commonlib/dist/common/coreEnvVars.js
54922
- var manifestVersion = "1.0.16";
54923
- var packageVersion = "1.0.16";
54993
+ var manifestVersion = "1.0.17";
54994
+ var packageVersion = "1.0.17";
54924
54995
  //#endregion
54925
54996
  //#region ../../modules/main/ModuleLiveSyncMain.ts
54926
54997
  var ModuleLiveSyncMain = class extends AbstractModule {
@@ -65839,7 +65910,7 @@ function generateJoinRoomOptions(settings) {
65839
65910
  const passphraseNumbers = mixedHash(settings.P2P_passphrase, 0);
65840
65911
  const passphrase = passphraseNumbers[0].toString(36) + passphraseNumbers[1].toString(36);
65841
65912
  const relays = settings.P2P_relays.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
65842
- const turnServers = settings.P2P_turnServers.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
65913
+ const turnServers = splitP2PTurnServerUrls(settings.P2P_turnServers);
65843
65914
  const relayConfig = {
65844
65915
  manualReconnection: true,
65845
65916
  urls: relays
@@ -65856,6 +65927,7 @@ function generateJoinRoomOptions(settings) {
65856
65927
  username: settings.P2P_turnUsername,
65857
65928
  credential: settings.P2P_turnCredential
65858
65929
  }];
65930
+ if (normaliseP2PConnectionPath(settings.P2P_connectionPath) === P2PConnectionPaths.Relay && hasValidP2PTurnServerUrl(settings.P2P_turnServers)) options.rtcConfig = { iceTransportPolicy: "relay" };
65859
65931
  return options;
65860
65932
  }
65861
65933
  //#endregion
@@ -65899,6 +65971,12 @@ var TRYSTERO_RPC_DEFAULTS = {
65899
65971
  /** SCTP guarantees delivery; retransmission is a last-resort safety net. */
65900
65972
  chunkMissingRetryMs: 150
65901
65973
  };
65974
+ function resolveTrysteroRpcOptions(settings) {
65975
+ return {
65976
+ ...TRYSTERO_RPC_DEFAULTS,
65977
+ maxWirePayloadBytes: normaliseP2PMaxWirePayloadBytes(settings.P2P_maxWirePayloadBytes)
65978
+ };
65979
+ }
65902
65980
  //#endregion
65903
65981
  //#region ../../../node_modules/@vrtmrz/livesync-commonlib/dist/replication/trystero/TrysteroReplicatorP2PServer.js
65904
65982
  var EVENT_SERVER_STATUS = "p2p-server-status";
@@ -66207,7 +66285,7 @@ You can chose as follows:
66207
66285
  };
66208
66286
  this._rpcRoom?.close();
66209
66287
  this._rpcRoom = new RpcRoom({
66210
- ...TRYSTERO_RPC_DEFAULTS,
66288
+ ...resolveTrysteroRpcOptions(this.settings),
66211
66289
  transport,
66212
66290
  canAcceptRequest: async (peerId, method) => {
66213
66291
  if (method === toRpcMethodName("!reqAuth")) return true;
@@ -66852,6 +66930,7 @@ var LiveSyncTrysteroReplicator = class extends LiveSyncAbstractReplicator {
66852
66930
  _replicator;
66853
66931
  _lifecycleOperation = Promise.resolve();
66854
66932
  _shouldBeOpen = false;
66933
+ _activeTransportCompatibilitySignature;
66855
66934
  get openReplicationUI() {
66856
66935
  return this.env.openReplicationUI;
66857
66936
  }
@@ -66905,6 +66984,25 @@ var LiveSyncTrysteroReplicator = class extends LiveSyncAbstractReplicator {
66905
66984
  this._lifecycleOperation = queued.catch(() => void 0);
66906
66985
  return queued;
66907
66986
  }
66987
+ /**
66988
+ * Capture settings which are fixed when the active P2P transport joins its room.
66989
+ * A later open request can remain idempotent only while these effective values match.
66990
+ */
66991
+ _getTransportCompatibilitySignature() {
66992
+ const settings = this.env.services.setting.currentSettings();
66993
+ const effectivePath = normaliseP2PConnectionPath(settings.P2P_connectionPath) === P2PConnectionPaths.Relay && hasValidP2PTurnServerUrl(settings.P2P_turnServers ?? "") ? P2PConnectionPaths.Relay : P2PConnectionPaths.Automatic;
66994
+ return `${normaliseP2PMaxWirePayloadBytes(settings.P2P_maxWirePayloadBytes)}:${effectivePath}`;
66995
+ }
66996
+ /** Close and forget the transport without changing the requested lifecycle state. */
66997
+ async _closeTransport() {
66998
+ if (this._replicator) {
66999
+ this._replicator.disableBroadcastChanges();
67000
+ await this._replicator.close();
67001
+ this._replicator = void 0;
67002
+ }
67003
+ this._p2pHost = void 0;
67004
+ this._activeTransportCompatibilitySignature = void 0;
67005
+ }
66908
67006
  async open() {
66909
67007
  if (!this.env.services.setting.currentSettings().P2P_Enabled) {
66910
67008
  Logger(this.translate("P2P.NotEnabled"), 64);
@@ -66913,9 +67011,13 @@ var LiveSyncTrysteroReplicator = class extends LiveSyncAbstractReplicator {
66913
67011
  this._shouldBeOpen = true;
66914
67012
  await this._enqueueLifecycleOperation(async () => {
66915
67013
  if (!this._shouldBeOpen) return;
67014
+ const compatibilitySignature = this._getTransportCompatibilitySignature();
66916
67015
  if (this._replicator && this._p2pHost?.isServing) {
66917
- Logger("P2P replicator is already open.");
66918
- return;
67016
+ if (this._activeTransportCompatibilitySignature === compatibilitySignature) {
67017
+ Logger("P2P replicator is already open.");
67018
+ return;
67019
+ }
67020
+ await this._closeTransport();
66919
67021
  }
66920
67022
  try {
66921
67023
  const env = this._buildEnv();
@@ -66924,23 +67026,20 @@ var LiveSyncTrysteroReplicator = class extends LiveSyncAbstractReplicator {
66924
67026
  this._p2pHost = host;
66925
67027
  this._replicator = replicator;
66926
67028
  await replicator.open();
67029
+ this._activeTransportCompatibilitySignature = compatibilitySignature;
66927
67030
  } catch (e) {
66928
67031
  Logger(e instanceof Error ? e.message : "Error while opening P2P connection", 64);
66929
67032
  Logger(e, 16);
66930
67033
  this._p2pHost = void 0;
66931
67034
  this._replicator = void 0;
67035
+ this._activeTransportCompatibilitySignature = void 0;
66932
67036
  }
66933
67037
  });
66934
67038
  }
66935
67039
  async close() {
66936
67040
  this._shouldBeOpen = false;
66937
67041
  await this._enqueueLifecycleOperation(async () => {
66938
- if (this._replicator) {
66939
- this._replicator.disableBroadcastChanges();
66940
- await this._replicator.close();
66941
- this._replicator = void 0;
66942
- }
66943
- this._p2pHost = void 0;
67042
+ await this._closeTransport();
66944
67043
  });
66945
67044
  }
66946
67045
  closeReplication() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jr2804/livesync-cli",
3
- "version": "1.0.16-cli.1",
3
+ "version": "1.0.17-cli.1",
4
4
  "description": "SEA-packaged livesync-cli from vrtmrz/obsidian-livesync — multiplatform binaries + npm",
5
5
  "type": "module",
6
6
  "bin": {