mindwire 0.1.28 → 0.1.30

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/dist/index.js CHANGED
@@ -786,11 +786,19 @@ var ComputerApi = class {
786
786
  pairing(id) {
787
787
  return this.client.http.request("GET", `/computer/pairings/${encodeURIComponent(id)}`);
788
788
  }
789
+ /** pairingVersion >= 2. Releases an unused QR when a saved phone reconnects.
790
+ * Returns false if a phone already submitted a request, which must be handled. */
791
+ closeUnusedPairing(id) {
792
+ return this.client.http.request("DELETE", `/computer/pairings/${encodeURIComponent(id)}`);
793
+ }
789
794
  completePairing(id, requestId) {
790
795
  return this.client.http.request("POST", `/computer/pairings/${encodeURIComponent(id)}/complete`, { body: { requestId } });
791
796
  }
792
- decide(id, requestId, approve) {
793
- return this.client.http.request("POST", `/computer/pairings/${encodeURIComponent(id)}/decision`, { body: { requestId, approve } });
797
+ async decide(id, requestId, approve, options = {}) {
798
+ if (options.replaceDeviceIds?.length && ((await this.info()).pairingVersion ?? 0) < 2) {
799
+ throw new Error("Update the Mindwire service before replacing saved phone approvals.");
800
+ }
801
+ return this.client.http.request("POST", `/computer/pairings/${encodeURIComponent(id)}/decision`, { body: { requestId, approve, ...options } });
794
802
  }
795
803
  devices() {
796
804
  return this.client.http.request("GET", "/computer/devices");
@@ -823,7 +831,16 @@ function computerPairingURI(invitation) {
823
831
  }
824
832
 
825
833
  // src/version.ts
826
- var SDK_VERSION = "0.1.28" ;
834
+ var SDK_VERSION = "0.1.30" ;
835
+ function versionAtLeast(actual, desired) {
836
+ if (actual === desired) return true;
837
+ if (!actual || !/^\d+\.\d+\.\d+$/.test(actual) || !/^\d+\.\d+\.\d+$/.test(desired)) return false;
838
+ const a = actual.split(".").map(Number), b = desired.split(".").map(Number);
839
+ for (let i = 0; i < 3; i++) {
840
+ if (a[i] !== b[i]) return a[i] > b[i];
841
+ }
842
+ return true;
843
+ }
827
844
 
828
845
  // src/daemon-binary.ts
829
846
  function supported(platform, arch) {
@@ -1693,15 +1710,6 @@ var NotifyApi = class {
1693
1710
  };
1694
1711
 
1695
1712
  // src/target/host.ts
1696
- function versionAtLeast(actual, desired) {
1697
- if (actual === desired) return true;
1698
- if (!actual || !/^\d+\.\d+\.\d+$/.test(actual) || !/^\d+\.\d+\.\d+$/.test(desired)) return false;
1699
- const a = actual.split(".").map(Number), b = desired.split(".").map(Number);
1700
- for (let i = 0; i < 3; i++) {
1701
- if (a[i] !== b[i]) return a[i] > b[i];
1702
- }
1703
- return true;
1704
- }
1705
1713
  var versionCheckScript = String.raw`version_at_least() {
1706
1714
  [ "$1" != "$2" ] || return 0
1707
1715
  [[ "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && [[ "$2" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || return 1