pi-chrome 0.15.44 → 0.15.46

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Pi Chrome Connector",
4
- "version": "0.15.44",
4
+ "version": "0.15.46",
5
5
  "description": "Lets Pi control tabs in Chrome via a local connector at 127.0.0.1.",
6
6
  "permissions": [
7
7
  "tabs",
@@ -701,6 +701,7 @@ export default function (pi: ExtensionAPI): void {
701
701
  else globalState[PI_CHROME_AUTH_KEY] = { until: chromeAuthorizedUntil };
702
702
  };
703
703
  let chromeToolsRegistered = false;
704
+ let chromeToolsUsable = false;
704
705
  let authExpiryTimer: NodeJS.Timeout | undefined;
705
706
  let countdownInterval: NodeJS.Timeout | undefined;
706
707
  // Remembered so bridge sends can tag tabs with this session's group even when ctx isn't handy.
@@ -734,13 +735,17 @@ export default function (pi: ExtensionAPI): void {
734
735
  return chromeToolsActive(before);
735
736
  };
736
737
 
737
- const logChromeToolChange = (action: "authorized" | "revoked" | "expired", label?: string): void => {
738
- const enabled = action === "authorized";
739
- const content = enabled
740
- ? `Chrome tools enabled by /chrome authorize${label ? ` (${label})` : ""}.`
741
- : action === "expired"
742
- ? "Chrome tools disabled because /chrome authorize grant expired."
743
- : "Chrome tools disabled by /chrome revoke.";
738
+ const logChromeToolChange = (
739
+ action: "authorized" | "reauthorized" | "revoked" | "expired",
740
+ options: { label?: string; authorizedUntil?: number | "indefinite" } = {},
741
+ ): void => {
742
+ const content = action === "authorized"
743
+ ? `Chrome tools enabled by /chrome authorize${options.label ? ` (${options.label})` : ""}.`
744
+ : action === "reauthorized"
745
+ ? `Chrome tool authorization updated by /chrome authorize${options.label ? ` (${options.label})` : ""}.`
746
+ : action === "expired"
747
+ ? "Chrome tools disabled because /chrome authorize grant expired."
748
+ : "Chrome tools disabled by /chrome revoke.";
744
749
  pi.sendMessage({
745
750
  customType: "pi-chrome-tool-change",
746
751
  content,
@@ -748,7 +753,7 @@ export default function (pi: ExtensionAPI): void {
748
753
  details: {
749
754
  action,
750
755
  tools: [...CHROME_TOOL_NAMES],
751
- authorizedUntil: chromeAuthorizedUntil,
756
+ authorizedUntil: options.authorizedUntil,
752
757
  at: Date.now(),
753
758
  },
754
759
  }, { triggerTurn: false });
@@ -766,8 +771,10 @@ export default function (pi: ExtensionAPI): void {
766
771
  const lockChromeControl = (logAction?: "revoked" | "expired"): void => {
767
772
  clearAuthExpiryTimer();
768
773
  clearCountdownInterval();
769
- const hadChromeTools = deactivateChromeTools();
770
- if (logAction && hadChromeTools) logChromeToolChange(logAction);
774
+ const wasUsable = chromeToolsUsable;
775
+ deactivateChromeTools();
776
+ chromeToolsUsable = false;
777
+ if (logAction && wasUsable) logChromeToolChange(logAction, { authorizedUntil: undefined });
771
778
  chromeAuthorizedUntil = undefined;
772
779
  persistAuth();
773
780
  // Revoking control ends pi-chrome's automation for this session; tidy up the target we own.
@@ -908,8 +915,12 @@ export default function (pi: ExtensionAPI): void {
908
915
  // Reestablish in-memory state after a /reload restored chromeAuthorizedUntil from globalThis.
909
916
  if (chromeControlAuthorized()) {
910
917
  activateChromeTools();
918
+ chromeToolsUsable = true;
911
919
  if (typeof chromeAuthorizedUntil === "number") scheduleAuthExpiry(ctx, chromeAuthorizedUntil);
912
920
  else if (chromeAuthorizedUntil === "indefinite") startCountdownTicker(ctx);
921
+ } else {
922
+ deactivateChromeTools();
923
+ chromeToolsUsable = false;
913
924
  }
914
925
  updateChromeStatus(ctx);
915
926
  });
@@ -1063,10 +1074,12 @@ Usage rules:
1063
1074
  ctx.ui.notify("Chrome control remains locked.", "info");
1064
1075
  return;
1065
1076
  }
1077
+ const wasUsable = chromeToolsUsable;
1066
1078
  chromeAuthorizedUntil = until;
1067
1079
  persistAuth();
1068
1080
  activateChromeTools();
1069
- logChromeToolChange("authorized", label);
1081
+ chromeToolsUsable = true;
1082
+ logChromeToolChange(wasUsable ? "reauthorized" : "authorized", { label, authorizedUntil: until });
1070
1083
  scheduleAuthExpiry(ctx, until);
1071
1084
  ctx.ui.notify(`Chrome control authorized for ${label}.`, "info");
1072
1085
  updateChromeStatus(ctx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-chrome",
3
- "version": "0.15.44",
3
+ "version": "0.15.46",
4
4
  "scripts": {
5
5
  "test": "node test-suite/unit/csp-eval.test.mjs && node test-suite/unit/automation-target.test.mjs",
6
6
  "version": "node scripts/sync-manifest-version.js",