pi-chrome 0.15.45 → 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.
|
@@ -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.
|
|
@@ -735,15 +736,16 @@ export default function (pi: ExtensionAPI): void {
|
|
|
735
736
|
};
|
|
736
737
|
|
|
737
738
|
const logChromeToolChange = (
|
|
738
|
-
action: "authorized" | "revoked" | "expired",
|
|
739
|
+
action: "authorized" | "reauthorized" | "revoked" | "expired",
|
|
739
740
|
options: { label?: string; authorizedUntil?: number | "indefinite" } = {},
|
|
740
741
|
): void => {
|
|
741
|
-
const
|
|
742
|
-
const content = enabled
|
|
742
|
+
const content = action === "authorized"
|
|
743
743
|
? `Chrome tools enabled by /chrome authorize${options.label ? ` (${options.label})` : ""}.`
|
|
744
|
-
: action === "
|
|
745
|
-
?
|
|
746
|
-
:
|
|
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.";
|
|
747
749
|
pi.sendMessage({
|
|
748
750
|
customType: "pi-chrome-tool-change",
|
|
749
751
|
content,
|
|
@@ -769,8 +771,10 @@ export default function (pi: ExtensionAPI): void {
|
|
|
769
771
|
const lockChromeControl = (logAction?: "revoked" | "expired"): void => {
|
|
770
772
|
clearAuthExpiryTimer();
|
|
771
773
|
clearCountdownInterval();
|
|
772
|
-
const
|
|
773
|
-
|
|
774
|
+
const wasUsable = chromeToolsUsable;
|
|
775
|
+
deactivateChromeTools();
|
|
776
|
+
chromeToolsUsable = false;
|
|
777
|
+
if (logAction && wasUsable) logChromeToolChange(logAction, { authorizedUntil: undefined });
|
|
774
778
|
chromeAuthorizedUntil = undefined;
|
|
775
779
|
persistAuth();
|
|
776
780
|
// Revoking control ends pi-chrome's automation for this session; tidy up the target we own.
|
|
@@ -911,8 +915,12 @@ export default function (pi: ExtensionAPI): void {
|
|
|
911
915
|
// Reestablish in-memory state after a /reload restored chromeAuthorizedUntil from globalThis.
|
|
912
916
|
if (chromeControlAuthorized()) {
|
|
913
917
|
activateChromeTools();
|
|
918
|
+
chromeToolsUsable = true;
|
|
914
919
|
if (typeof chromeAuthorizedUntil === "number") scheduleAuthExpiry(ctx, chromeAuthorizedUntil);
|
|
915
920
|
else if (chromeAuthorizedUntil === "indefinite") startCountdownTicker(ctx);
|
|
921
|
+
} else {
|
|
922
|
+
deactivateChromeTools();
|
|
923
|
+
chromeToolsUsable = false;
|
|
916
924
|
}
|
|
917
925
|
updateChromeStatus(ctx);
|
|
918
926
|
});
|
|
@@ -1066,10 +1074,12 @@ Usage rules:
|
|
|
1066
1074
|
ctx.ui.notify("Chrome control remains locked.", "info");
|
|
1067
1075
|
return;
|
|
1068
1076
|
}
|
|
1077
|
+
const wasUsable = chromeToolsUsable;
|
|
1069
1078
|
chromeAuthorizedUntil = until;
|
|
1070
1079
|
persistAuth();
|
|
1071
1080
|
activateChromeTools();
|
|
1072
|
-
|
|
1081
|
+
chromeToolsUsable = true;
|
|
1082
|
+
logChromeToolChange(wasUsable ? "reauthorized" : "authorized", { label, authorizedUntil: until });
|
|
1073
1083
|
scheduleAuthExpiry(ctx, until);
|
|
1074
1084
|
ctx.ui.notify(`Chrome control authorized for ${label}.`, "info");
|
|
1075
1085
|
updateChromeStatus(ctx);
|
package/package.json
CHANGED