@gruu6y/page-clean-login 0.2.9 → 0.2.11
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/lib/account-browser.mjs +459 -0
- package/lib/account-exit.mjs +604 -0
- package/lib/account-proxies.mjs +376 -36
- package/lib/agent-cli.mjs +22 -0
- package/lib/agent-surface.mjs +41 -2
- package/lib/browser-launcher.mjs +142 -36
- package/lib/renew-hosting.mjs +90 -38
- package/lib/server.mjs +247 -83
- package/lib/signin-flow.mjs +51 -25
- package/package.json +1 -1
- package/ui/account-view.js +178 -6
- package/ui/app.js +422 -2
- package/ui/index.html +5 -0
- package/ui/style.css +33 -0
package/ui/app.js
CHANGED
|
@@ -60,7 +60,9 @@ import {
|
|
|
60
60
|
} from "./account-state.js";
|
|
61
61
|
import {
|
|
62
62
|
EXPIRING_SOON_MS,
|
|
63
|
+
accountBrowserPath,
|
|
63
64
|
accountView,
|
|
65
|
+
browserStateSummary,
|
|
64
66
|
countAccountsByProxy,
|
|
65
67
|
filterAccounts,
|
|
66
68
|
formatCheckSummary,
|
|
@@ -69,6 +71,7 @@ import {
|
|
|
69
71
|
hostingStateLabel,
|
|
70
72
|
hostingTone,
|
|
71
73
|
isHostingPaused,
|
|
74
|
+
normalizeAccountBrowser,
|
|
72
75
|
normalizeHosting,
|
|
73
76
|
sortAccounts,
|
|
74
77
|
} from "./account-view.js";
|
|
@@ -428,6 +431,7 @@ const messages = {
|
|
|
428
431
|
accountFingerprintPinned: "Pinned {time}",
|
|
429
432
|
accountFingerprintNone: "No pinned fingerprint",
|
|
430
433
|
accountExitDirect: "Direct",
|
|
434
|
+
accountExitCustom: "Custom exit",
|
|
431
435
|
accountLastLoginAt: "{time} · {exit}",
|
|
432
436
|
accountCheckExposure: "{count} places may expose you",
|
|
433
437
|
accountRelogin: "Sign in again",
|
|
@@ -691,6 +695,32 @@ const messages = {
|
|
|
691
695
|
accountDetailMethod: "Sign-in method",
|
|
692
696
|
accountDetailExpiresAt: "Token expires",
|
|
693
697
|
signInEgressWarning: "Warning: {detail}",
|
|
698
|
+
accountBrowserOpen: "Open browser",
|
|
699
|
+
accountBrowserClose: "Close browser",
|
|
700
|
+
accountBrowserOpening: "Opening…",
|
|
701
|
+
accountBrowserClosing: "Closing…",
|
|
702
|
+
accountBrowserOpenTitle: "Open this account's fingerprint browser with its current exit.",
|
|
703
|
+
accountBrowserCloseTitle: "Close this account's open fingerprint browser.",
|
|
704
|
+
accountBrowserNoFingerprintTitle: "This account has no pinned fingerprint yet. Sign in through Clean Login once first.",
|
|
705
|
+
accountBrowserStatusOpen: "Browser open · {exit}",
|
|
706
|
+
accountBrowserClosed: "Fingerprint browser: closed",
|
|
707
|
+
accountBrowserExitChanged: "Exit changed; close and reopen the browser to apply.",
|
|
708
|
+
toastBrowserOpened: "Fingerprint browser opened.",
|
|
709
|
+
toastBrowserClosed: "Fingerprint browser closed.",
|
|
710
|
+
browserErrorIdentityMissing: "This account has no pinned fingerprint yet. Sign in through Clean Login once first.",
|
|
711
|
+
browserErrorExecutableMissing: "The isolated browser is not prepared yet. Prepare the login browser first.",
|
|
712
|
+
browserErrorAlreadyOpen: "This account's fingerprint browser is already open.",
|
|
713
|
+
errorAccountBrowserOpen: "Close this account's fingerprint browser before continuing.",
|
|
714
|
+
browserErrorSignInRunning: "A sign-in flow is currently running for this account. Finish or cancel it first.",
|
|
715
|
+
browserErrorRenewalRunning: "Hosted renewal is currently running for this account. Wait for it to finish.",
|
|
716
|
+
browserErrorProvidersInvalid: "magpie's providers.json is invalid, so this account's exit could not be resolved.",
|
|
717
|
+
browserErrorProvidersUnreadable: "Could not read magpie's providers.json to resolve this account's exit.",
|
|
718
|
+
browserErrorInvalidExitUrl: "This account's configured exit URL is invalid. Fix the exit in account details first.",
|
|
719
|
+
browserErrorExitMissing: "This account's configured exit is no longer in the proxy list. Choose another exit in account details.",
|
|
720
|
+
browserErrorExitUnknown: "Could not determine which exit this account should use. Check its exit setting in account details.",
|
|
721
|
+
browserErrorLaunchFailed: "The fingerprint browser failed to start. The browser directory may be busy or damaged.",
|
|
722
|
+
browserErrorLaunchTimeout: "The fingerprint browser took too long to start.",
|
|
723
|
+
browserErrorInvalidUrl: "The requested page address is not allowed.",
|
|
694
724
|
},
|
|
695
725
|
"zh-Hans": {
|
|
696
726
|
title: "干净登录",
|
|
@@ -1013,6 +1043,7 @@ const messages = {
|
|
|
1013
1043
|
accountFingerprintPinned: "固定于 {time}",
|
|
1014
1044
|
accountFingerprintNone: "没有固定指纹",
|
|
1015
1045
|
accountExitDirect: "直连",
|
|
1046
|
+
accountExitCustom: "自定义出口",
|
|
1016
1047
|
accountLastLoginAt: "{time} · {exit}",
|
|
1017
1048
|
accountCheckExposure: "{count} 处可能暴露你",
|
|
1018
1049
|
accountRelogin: "重新登录",
|
|
@@ -1276,6 +1307,32 @@ const messages = {
|
|
|
1276
1307
|
accountDetailMethod: "登录方式",
|
|
1277
1308
|
accountDetailExpiresAt: "凭证过期时间",
|
|
1278
1309
|
signInEgressWarning: "提示:{detail}",
|
|
1310
|
+
accountBrowserOpen: "打开浏览器",
|
|
1311
|
+
accountBrowserClose: "关闭浏览器",
|
|
1312
|
+
accountBrowserOpening: "打开中…",
|
|
1313
|
+
accountBrowserClosing: "关闭中…",
|
|
1314
|
+
accountBrowserOpenTitle: "用这个账号的固定指纹和当前出口打开隔离浏览器。",
|
|
1315
|
+
accountBrowserCloseTitle: "关闭这个账号已打开的指纹浏览器。",
|
|
1316
|
+
accountBrowserNoFingerprintTitle: "这个账号还没有固定指纹,请先通过干净登录登录一次。",
|
|
1317
|
+
accountBrowserStatusOpen: "浏览器已打开 · {exit}",
|
|
1318
|
+
accountBrowserClosed: "指纹浏览器:未打开",
|
|
1319
|
+
accountBrowserExitChanged: "出口已变更,关闭并重新打开浏览器后生效。",
|
|
1320
|
+
toastBrowserOpened: "已打开指纹浏览器。",
|
|
1321
|
+
toastBrowserClosed: "已关闭指纹浏览器。",
|
|
1322
|
+
browserErrorIdentityMissing: "这个账号还没有固定指纹,请先通过干净登录登录一次。",
|
|
1323
|
+
browserErrorExecutableMissing: "隔离浏览器尚未准备好,请先准备登录浏览器。",
|
|
1324
|
+
browserErrorAlreadyOpen: "这个账号的指纹浏览器已经打开了。",
|
|
1325
|
+
errorAccountBrowserOpen: "请先关闭这个账号的指纹浏览器后再操作。",
|
|
1326
|
+
browserErrorSignInRunning: "这个账号正在进行登录流程,请先完成或取消登录。",
|
|
1327
|
+
browserErrorRenewalRunning: "这个账号正在执行托管续期,请等待续期完成。",
|
|
1328
|
+
browserErrorProvidersInvalid: "magpie 的 providers.json 格式无效,无法解析这个账号的出口。",
|
|
1329
|
+
browserErrorProvidersUnreadable: "无法读取 magpie 的 providers.json,暂时不能解析这个账号的出口。",
|
|
1330
|
+
browserErrorInvalidExitUrl: "这个账号配置的出口地址无效,请先在账号详情里修正出口。",
|
|
1331
|
+
browserErrorExitMissing: "这个账号绑定的出口已不在代理列表里,请先在账号详情里重新选择出口。",
|
|
1332
|
+
browserErrorExitUnknown: "无法确定这个账号应使用的出口,请在账号详情里检查出口设置。",
|
|
1333
|
+
browserErrorLaunchFailed: "指纹浏览器启动失败,可能是安装目录被占用或文件缺失。",
|
|
1334
|
+
browserErrorLaunchTimeout: "指纹浏览器启动超时。",
|
|
1335
|
+
browserErrorInvalidUrl: "不允许打开这个页面地址。",
|
|
1279
1336
|
},
|
|
1280
1337
|
"zh-Hant": {
|
|
1281
1338
|
title: "乾淨登入",
|
|
@@ -1598,6 +1655,7 @@ const messages = {
|
|
|
1598
1655
|
accountFingerprintPinned: "固定於 {time}",
|
|
1599
1656
|
accountFingerprintNone: "沒有固定指紋",
|
|
1600
1657
|
accountExitDirect: "直連",
|
|
1658
|
+
accountExitCustom: "自訂出口",
|
|
1601
1659
|
accountLastLoginAt: "{time} · {exit}",
|
|
1602
1660
|
accountCheckExposure: "{count} 處可能暴露你",
|
|
1603
1661
|
accountRelogin: "重新登入",
|
|
@@ -1861,6 +1919,32 @@ const messages = {
|
|
|
1861
1919
|
accountDetailMethod: "登入方式",
|
|
1862
1920
|
accountDetailExpiresAt: "憑證過期時間",
|
|
1863
1921
|
signInEgressWarning: "提示:{detail}",
|
|
1922
|
+
accountBrowserOpen: "開啟瀏覽器",
|
|
1923
|
+
accountBrowserClose: "關閉瀏覽器",
|
|
1924
|
+
accountBrowserOpening: "開啟中…",
|
|
1925
|
+
accountBrowserClosing: "關閉中…",
|
|
1926
|
+
accountBrowserOpenTitle: "用這個帳號的固定指紋和目前出口開啟隔離瀏覽器。",
|
|
1927
|
+
accountBrowserCloseTitle: "關閉這個帳號已開啟的指紋瀏覽器。",
|
|
1928
|
+
accountBrowserNoFingerprintTitle: "這個帳號還沒有固定指紋,請先透過乾淨登入登入一次。",
|
|
1929
|
+
accountBrowserStatusOpen: "瀏覽器已開啟 · {exit}",
|
|
1930
|
+
accountBrowserClosed: "指紋瀏覽器:未開啟",
|
|
1931
|
+
accountBrowserExitChanged: "出口已變更,關閉並重新開啟瀏覽器後生效。",
|
|
1932
|
+
toastBrowserOpened: "已開啟指紋瀏覽器。",
|
|
1933
|
+
toastBrowserClosed: "已關閉指紋瀏覽器。",
|
|
1934
|
+
browserErrorIdentityMissing: "這個帳號還沒有固定指紋,請先透過乾淨登入登入一次。",
|
|
1935
|
+
browserErrorExecutableMissing: "隔離瀏覽器尚未準備好,請先準備登入瀏覽器。",
|
|
1936
|
+
browserErrorAlreadyOpen: "這個帳號的指紋瀏覽器已經開啟了。",
|
|
1937
|
+
errorAccountBrowserOpen: "請先關閉這個帳號的指紋瀏覽器後再操作。",
|
|
1938
|
+
browserErrorSignInRunning: "這個帳號正在進行登入流程,請先完成或取消登入。",
|
|
1939
|
+
browserErrorRenewalRunning: "這個帳號正在執行託管續期,請等待續期完成。",
|
|
1940
|
+
browserErrorProvidersInvalid: "magpie 的 providers.json 格式無效,無法解析這個帳號的出口。",
|
|
1941
|
+
browserErrorProvidersUnreadable: "無法讀取 magpie 的 providers.json,暫時不能解析這個帳號的出口。",
|
|
1942
|
+
browserErrorInvalidExitUrl: "這個帳號設定的出口網址無效,請先在帳號詳情裡修正出口。",
|
|
1943
|
+
browserErrorExitMissing: "這個帳號綁定的出口已不在代理清單裡,請先在帳號詳情裡重新選擇出口。",
|
|
1944
|
+
browserErrorExitUnknown: "無法確定這個帳號應使用的出口,請在帳號詳情裡檢查出口設定。",
|
|
1945
|
+
browserErrorLaunchFailed: "指紋瀏覽器啟動失敗,可能是安裝目錄被佔用或檔案缺失。",
|
|
1946
|
+
browserErrorLaunchTimeout: "指紋瀏覽器啟動逾時。",
|
|
1947
|
+
browserErrorInvalidUrl: "不允許開啟這個頁面位址。",
|
|
1864
1948
|
},
|
|
1865
1949
|
ja: {
|
|
1866
1950
|
title: "クリーンログイン",
|
|
@@ -2183,6 +2267,7 @@ const messages = {
|
|
|
2183
2267
|
accountFingerprintPinned: "{time} に固定",
|
|
2184
2268
|
accountFingerprintNone: "固定された指紋がありません",
|
|
2185
2269
|
accountExitDirect: "直接接続",
|
|
2270
|
+
accountExitCustom: "カスタム出口",
|
|
2186
2271
|
accountLastLoginAt: "{time} · {exit}",
|
|
2187
2272
|
accountCheckExposure: "{count} 箇所で情報が漏れる可能性",
|
|
2188
2273
|
accountRelogin: "再ログイン",
|
|
@@ -2446,6 +2531,32 @@ const messages = {
|
|
|
2446
2531
|
accountDetailMethod: "ログイン方式",
|
|
2447
2532
|
accountDetailExpiresAt: "有効期限",
|
|
2448
2533
|
signInEgressWarning: "注意:{detail}",
|
|
2534
|
+
accountBrowserOpen: "ブラウザーを開く",
|
|
2535
|
+
accountBrowserClose: "ブラウザーを閉じる",
|
|
2536
|
+
accountBrowserOpening: "起動中…",
|
|
2537
|
+
accountBrowserClosing: "終了中…",
|
|
2538
|
+
accountBrowserOpenTitle: "このアカウントの固定フィンガープリントと現在の出口で分離ブラウザーを開きます。",
|
|
2539
|
+
accountBrowserCloseTitle: "このアカウントで開いているフィンガープリントブラウザーを閉じます。",
|
|
2540
|
+
accountBrowserNoFingerprintTitle: "このアカウントには固定フィンガープリントがまだありません。先にクリーンログインで一度ログインしてください。",
|
|
2541
|
+
accountBrowserStatusOpen: "ブラウザー起動中 · {exit}",
|
|
2542
|
+
accountBrowserClosed: "フィンガープリントブラウザー:閉じています",
|
|
2543
|
+
accountBrowserExitChanged: "出口が変更されました。反映するにはブラウザーを閉じて開き直してください。",
|
|
2544
|
+
toastBrowserOpened: "フィンガープリントブラウザーを開きました。",
|
|
2545
|
+
toastBrowserClosed: "フィンガープリントブラウザーを閉じました。",
|
|
2546
|
+
browserErrorIdentityMissing: "このアカウントには固定フィンガープリントがまだありません。先にクリーンログインで一度ログインしてください。",
|
|
2547
|
+
browserErrorExecutableMissing: "分離ブラウザーがまだ準備されていません。先にログイン用ブラウザーを準備してください。",
|
|
2548
|
+
browserErrorAlreadyOpen: "このアカウントのフィンガープリントブラウザーはすでに開いています。",
|
|
2549
|
+
errorAccountBrowserOpen: "続行する前に、このアカウントのフィンガープリントブラウザーを閉じてください。",
|
|
2550
|
+
browserErrorSignInRunning: "このアカウントのログイン処理が進行中です。先に完了するか中止してください。",
|
|
2551
|
+
browserErrorRenewalRunning: "このアカウントの自動更新が実行中です。完了するまでお待ちください。",
|
|
2552
|
+
browserErrorProvidersInvalid: "magpie の providers.json が不正なため、このアカウントの出口を解決できませんでした。",
|
|
2553
|
+
browserErrorProvidersUnreadable: "magpie の providers.json を読み取れず、このアカウントの出口を解決できませんでした。",
|
|
2554
|
+
browserErrorInvalidExitUrl: "このアカウントに設定されている出口 URL が無効です。先にアカウント詳細で出口を修正してください。",
|
|
2555
|
+
browserErrorExitMissing: "このアカウントに設定された出口はプロキシ一覧に見つかりません。アカウント詳細で別の出口を選んでください。",
|
|
2556
|
+
browserErrorExitUnknown: "このアカウントが使用する出口を特定できませんでした。アカウント詳細で出口設定を確認してください。",
|
|
2557
|
+
browserErrorLaunchFailed: "フィンガープリントブラウザーを起動できませんでした。インストール先が使用中か、ファイルが不足している可能性があります。",
|
|
2558
|
+
browserErrorLaunchTimeout: "フィンガープリントブラウザーの起動がタイムアウトしました。",
|
|
2559
|
+
browserErrorInvalidUrl: "指定されたページアドレスは許可されていません。",
|
|
2449
2560
|
},
|
|
2450
2561
|
};
|
|
2451
2562
|
|
|
@@ -2627,6 +2738,11 @@ let detailExitController = null;
|
|
|
2627
2738
|
// is static markup, so without this a value left by the previous dialog would
|
|
2628
2739
|
// look like a fresh user choice when the next account opens.
|
|
2629
2740
|
let detailExitRenderedFor = null;
|
|
2741
|
+
// Per-account pending browser action ("opening" | "closing") keyed by
|
|
2742
|
+
// `${provider}\u0000${key}` so concurrent opens/closes on different accounts
|
|
2743
|
+
// stay independent while preventing double clicks on the same account.
|
|
2744
|
+
const accountBrowserBusy = new Map();
|
|
2745
|
+
const detailBrowserGuard = createRequestGuard();
|
|
2630
2746
|
// The hosting dialog polls only while it is open, and only for the one account
|
|
2631
2747
|
// it was opened for. Nothing polls on the user's behalf in the background.
|
|
2632
2748
|
let accountHostingContext = null;
|
|
@@ -2639,6 +2755,7 @@ const NOTE_MAX_LENGTH = 200;
|
|
|
2639
2755
|
|
|
2640
2756
|
const errorKeys = {
|
|
2641
2757
|
signed_in: "errorAccountSignedIn",
|
|
2758
|
+
browser_open: "errorAccountBrowserOpen",
|
|
2642
2759
|
auth_unreadable: "errorAccountAuthUnreadable",
|
|
2643
2760
|
retired_missing: "errorAccountRetiredMissing",
|
|
2644
2761
|
identity_mismatch: "errorAccountMismatch",
|
|
@@ -2693,6 +2810,7 @@ function apiErrorText(error) {
|
|
|
2693
2810
|
const accountErrorKeys = {
|
|
2694
2811
|
not_found: "errorAccountNotFound",
|
|
2695
2812
|
signed_in: "errorAccountSignedIn",
|
|
2813
|
+
browser_open: "errorAccountBrowserOpen",
|
|
2696
2814
|
auth_unreadable: "errorAccountAuthUnreadable",
|
|
2697
2815
|
invalid_account: "errorAccountInvalid",
|
|
2698
2816
|
retired_missing: "errorAccountRetiredMissing",
|
|
@@ -2703,6 +2821,30 @@ function accountErrorText(error) {
|
|
|
2703
2821
|
return text[accountErrorKeys[error?.code]] || serverErrorText(error);
|
|
2704
2822
|
}
|
|
2705
2823
|
|
|
2824
|
+
const accountBrowserErrorKeys = {
|
|
2825
|
+
not_found: "errorAccountNotFound",
|
|
2826
|
+
identity_missing: "browserErrorIdentityMissing",
|
|
2827
|
+
executable_missing: "browserErrorExecutableMissing",
|
|
2828
|
+
browser_missing: "browserErrorExecutableMissing",
|
|
2829
|
+
runtime_missing: "browserErrorExecutableMissing",
|
|
2830
|
+
browser_already_open: "browserErrorAlreadyOpen",
|
|
2831
|
+
browser_open: "errorAccountBrowserOpen",
|
|
2832
|
+
signin_running: "browserErrorSignInRunning",
|
|
2833
|
+
renewal_running: "browserErrorRenewalRunning",
|
|
2834
|
+
providers_invalid: "browserErrorProvidersInvalid",
|
|
2835
|
+
providers_unreadable: "browserErrorProvidersUnreadable",
|
|
2836
|
+
invalid_exit_url: "browserErrorInvalidExitUrl",
|
|
2837
|
+
exit_missing: "browserErrorExitMissing",
|
|
2838
|
+
exit_unknown: "browserErrorExitUnknown",
|
|
2839
|
+
launch_failed: "browserErrorLaunchFailed",
|
|
2840
|
+
launch_timeout: "browserErrorLaunchTimeout",
|
|
2841
|
+
invalid_url: "browserErrorInvalidUrl",
|
|
2842
|
+
};
|
|
2843
|
+
|
|
2844
|
+
function accountBrowserErrorText(error) {
|
|
2845
|
+
return text[accountBrowserErrorKeys[error?.code]] || serverErrorText(error);
|
|
2846
|
+
}
|
|
2847
|
+
|
|
2706
2848
|
// The asset routes report their own codes. `not_found` means an asset row, not
|
|
2707
2849
|
// an account, so it gets its own wording instead of the shared proxy text.
|
|
2708
2850
|
const assetErrorKeys = {
|
|
@@ -2908,6 +3050,7 @@ function applyText() {
|
|
|
2908
3050
|
byId("account-detail-note-hint").textContent = text.accountDetailNoteHint;
|
|
2909
3051
|
byId("account-detail-history-title").textContent = text.accountDetailHistoryTitle;
|
|
2910
3052
|
byId("account-detail-dismiss").textContent = text.accountDetailDismiss;
|
|
3053
|
+
byId("account-detail-browser").textContent = text.accountBrowserOpen;
|
|
2911
3054
|
byId("account-detail-check").textContent = text.accountCheckStart;
|
|
2912
3055
|
byId("account-detail-note-save").textContent = text.accountDetailNoteSave;
|
|
2913
3056
|
byId("account-detail-exit-label").textContent = text.accountDetailExitLabel;
|
|
@@ -4502,6 +4645,13 @@ async function loadAccountIdentities() {
|
|
|
4502
4645
|
} catch (error) {
|
|
4503
4646
|
accountIdentitiesError = serverErrorText(error);
|
|
4504
4647
|
} finally {
|
|
4648
|
+
if (accountDetailContext) {
|
|
4649
|
+
const updated = findAccountRecord(accountDetailContext.provider, accountDetailContext.key);
|
|
4650
|
+
if (updated) {
|
|
4651
|
+
accountDetailContext.account = updated;
|
|
4652
|
+
renderDetailBrowser();
|
|
4653
|
+
}
|
|
4654
|
+
}
|
|
4505
4655
|
renderAccounts();
|
|
4506
4656
|
// The counts order the main list, so the cards are laid out again once the
|
|
4507
4657
|
// identities arrive. The split does not depend on them: no card moves
|
|
@@ -6557,6 +6707,13 @@ function accountForList(account) {
|
|
|
6557
6707
|
// clear the flag, so it only ever told people their own working account looked
|
|
6558
6708
|
// suspicious.
|
|
6559
6709
|
|
|
6710
|
+
function accountExitLabels() {
|
|
6711
|
+
return {
|
|
6712
|
+
custom: text.accountExitCustom,
|
|
6713
|
+
inherit: text.accountDetailExitInherit,
|
|
6714
|
+
};
|
|
6715
|
+
}
|
|
6716
|
+
|
|
6560
6717
|
function gradeTone(grade) {
|
|
6561
6718
|
if (grade === "A" || grade === "B") return "good";
|
|
6562
6719
|
if (grade === "C") return "warn";
|
|
@@ -6623,7 +6780,10 @@ function accountRow(account) {
|
|
|
6623
6780
|
// there is no current setting does it fall back to the last login's exit.
|
|
6624
6781
|
lastLogin.textContent = text.accountLastLoginAt
|
|
6625
6782
|
.replace("{time}", formatTime(view.lastLogin?.at || view.signedInAt))
|
|
6626
|
-
.replace(
|
|
6783
|
+
.replace(
|
|
6784
|
+
"{exit}",
|
|
6785
|
+
formatExit(view.exit ?? view.lastLogin, text.accountExitDirect, accountExitLabels()),
|
|
6786
|
+
);
|
|
6627
6787
|
|
|
6628
6788
|
const checkCell = accountCell("proxy-score-cell account-cell-check", text.accountColCheck);
|
|
6629
6789
|
if (accountRunningFor(view.provider, view.key)) {
|
|
@@ -6674,6 +6834,19 @@ function accountRow(account) {
|
|
|
6674
6834
|
expiryNode.textContent = expiry.label;
|
|
6675
6835
|
statusCell.append(expiryNode);
|
|
6676
6836
|
}
|
|
6837
|
+
const browserSummary = browserStateSummary(view.browser, accountBrowserLabels());
|
|
6838
|
+
if (browserSummary.open) {
|
|
6839
|
+
const browserLine = document.createElement("small");
|
|
6840
|
+
browserLine.className = `account-browser-line is-${browserSummary.tone}`;
|
|
6841
|
+
browserLine.textContent = browserSummary.statusText;
|
|
6842
|
+
statusCell.append(browserLine);
|
|
6843
|
+
if (browserSummary.noticeText) {
|
|
6844
|
+
const browserNotice = document.createElement("small");
|
|
6845
|
+
browserNotice.className = "account-browser-notice";
|
|
6846
|
+
browserNotice.textContent = browserSummary.noticeText;
|
|
6847
|
+
statusCell.append(browserNotice);
|
|
6848
|
+
}
|
|
6849
|
+
}
|
|
6677
6850
|
|
|
6678
6851
|
const actions = accountCell("proxy-actions account-cell-actions", text.accountColActions);
|
|
6679
6852
|
const busy = Boolean(accountCheckContext?.active);
|
|
@@ -6697,6 +6870,27 @@ function accountRow(account) {
|
|
|
6697
6870
|
rotate.title = text.accountRotateTitle;
|
|
6698
6871
|
actions.append(rotate);
|
|
6699
6872
|
}
|
|
6873
|
+
const browserPending = accountBrowserPendingState(view.provider, view.key);
|
|
6874
|
+
const browserOpen = view.browser.open;
|
|
6875
|
+
const hasFingerprint = Boolean(view.fingerprint.id);
|
|
6876
|
+
const browserLabel =
|
|
6877
|
+
browserPending === "opening" ? text.accountBrowserOpening
|
|
6878
|
+
: browserPending === "closing" ? text.accountBrowserClosing
|
|
6879
|
+
: browserOpen ? text.accountBrowserClose
|
|
6880
|
+
: text.accountBrowserOpen;
|
|
6881
|
+
const browserButton = miniButton(browserLabel, () => {
|
|
6882
|
+
void toggleAccountBrowser(account);
|
|
6883
|
+
});
|
|
6884
|
+
browserButton.dataset.accountBrowserAction = browserOpen ? "close" : "open";
|
|
6885
|
+
if (browserOpen) browserButton.classList.add("is-active");
|
|
6886
|
+
browserButton.disabled = Boolean(browserPending) || (!browserOpen && !hasFingerprint);
|
|
6887
|
+
browserButton.title =
|
|
6888
|
+
browserPending === "opening" ? text.accountBrowserOpening
|
|
6889
|
+
: browserPending === "closing" ? text.accountBrowserClosing
|
|
6890
|
+
: !browserOpen && !hasFingerprint ? text.accountBrowserNoFingerprintTitle
|
|
6891
|
+
: browserOpen ? text.accountBrowserCloseTitle
|
|
6892
|
+
: text.accountBrowserOpenTitle;
|
|
6893
|
+
actions.append(browserButton);
|
|
6700
6894
|
const checkButton = miniButton(text.accountCheck, () => openAccountCheck(account));
|
|
6701
6895
|
checkButton.disabled = busy;
|
|
6702
6896
|
if (busy) checkButton.title = text.accountCheckBusy;
|
|
@@ -7333,6 +7527,219 @@ async function loadAccountExit(context) {
|
|
|
7333
7527
|
}
|
|
7334
7528
|
}
|
|
7335
7529
|
|
|
7530
|
+
// --- account browser controls ---------------------------------------------
|
|
7531
|
+
|
|
7532
|
+
function accountBrowserKey(provider, key) {
|
|
7533
|
+
return `${String(provider ?? "")}\u0000${String(key ?? "")}`;
|
|
7534
|
+
}
|
|
7535
|
+
|
|
7536
|
+
function accountBrowserPendingState(provider, key) {
|
|
7537
|
+
return accountBrowserBusy.get(accountBrowserKey(provider, key)) || "";
|
|
7538
|
+
}
|
|
7539
|
+
|
|
7540
|
+
function accountBrowserLabels() {
|
|
7541
|
+
return {
|
|
7542
|
+
direct: text.accountExitDirect,
|
|
7543
|
+
custom: text.accountExitCustom,
|
|
7544
|
+
inherit: text.accountDetailExitInherit,
|
|
7545
|
+
openWithExit: text.accountBrowserStatusOpen,
|
|
7546
|
+
closed: text.accountBrowserClosed,
|
|
7547
|
+
exitChanged: text.accountBrowserExitChanged,
|
|
7548
|
+
};
|
|
7549
|
+
}
|
|
7550
|
+
|
|
7551
|
+
function findAccountRecord(provider, key) {
|
|
7552
|
+
return accountIdentities.find(
|
|
7553
|
+
(item) => item?.provider === provider && item?.key === key,
|
|
7554
|
+
) || null;
|
|
7555
|
+
}
|
|
7556
|
+
|
|
7557
|
+
function isAccountDetailFor(provider, key) {
|
|
7558
|
+
return Boolean(
|
|
7559
|
+
accountDetailContext &&
|
|
7560
|
+
accountDetailContext.provider === provider &&
|
|
7561
|
+
accountDetailContext.key === key,
|
|
7562
|
+
);
|
|
7563
|
+
}
|
|
7564
|
+
|
|
7565
|
+
function updateAccountBrowserRecord(provider, key, browser) {
|
|
7566
|
+
const normalized = normalizeAccountBrowser(browser);
|
|
7567
|
+
const index = accountIdentities.findIndex(
|
|
7568
|
+
(item) => item?.provider === provider && item?.key === key,
|
|
7569
|
+
);
|
|
7570
|
+
if (index >= 0) {
|
|
7571
|
+
accountIdentities[index] = { ...accountIdentities[index], browser: normalized };
|
|
7572
|
+
}
|
|
7573
|
+
if (isAccountDetailFor(provider, key)) {
|
|
7574
|
+
accountDetailContext.account = {
|
|
7575
|
+
...(accountDetailContext.account || {}),
|
|
7576
|
+
browser: normalized,
|
|
7577
|
+
};
|
|
7578
|
+
}
|
|
7579
|
+
}
|
|
7580
|
+
|
|
7581
|
+
async function refreshAccountBrowserState(provider, key) {
|
|
7582
|
+
const busyKey = accountBrowserKey(provider, key);
|
|
7583
|
+
if (accountBrowserBusy.has(busyKey)) return;
|
|
7584
|
+
try {
|
|
7585
|
+
const data = await api(accountBrowserPath(provider, key));
|
|
7586
|
+
if (accountBrowserBusy.has(busyKey)) return;
|
|
7587
|
+
if (data?.browser) {
|
|
7588
|
+
updateAccountBrowserRecord(provider, key, data.browser);
|
|
7589
|
+
if (isAccountDetailFor(provider, key)) renderDetailBrowser();
|
|
7590
|
+
renderAccounts();
|
|
7591
|
+
}
|
|
7592
|
+
} catch {
|
|
7593
|
+
// Keep the current display if the background status check fails.
|
|
7594
|
+
}
|
|
7595
|
+
}
|
|
7596
|
+
|
|
7597
|
+
async function toggleAccountBrowser(account, { fromDetail = false } = {}) {
|
|
7598
|
+
const latest = findAccountRecord(account?.provider, account?.key) || account;
|
|
7599
|
+
const view = accountDisplay(latest);
|
|
7600
|
+
const provider = view.provider;
|
|
7601
|
+
const key = view.key;
|
|
7602
|
+
if (!provider || !key) return;
|
|
7603
|
+
const busyKey = accountBrowserKey(provider, key);
|
|
7604
|
+
if (accountBrowserBusy.has(busyKey)) return;
|
|
7605
|
+
const closing = view.browser.open;
|
|
7606
|
+
if (!closing && !view.fingerprint.id) {
|
|
7607
|
+
const message = text.browserErrorIdentityMissing;
|
|
7608
|
+
if (fromDetail && isAccountDetailFor(provider, key)) setDetailError(message);
|
|
7609
|
+
else accountIdentitiesError = message;
|
|
7610
|
+
toast(message);
|
|
7611
|
+
renderAccounts();
|
|
7612
|
+
return;
|
|
7613
|
+
}
|
|
7614
|
+
accountBrowserBusy.set(busyKey, closing ? "closing" : "opening");
|
|
7615
|
+
if (isAccountDetailFor(provider, key)) {
|
|
7616
|
+
detailBrowserGuard.cancel();
|
|
7617
|
+
setDetailError("");
|
|
7618
|
+
renderDetailBrowser();
|
|
7619
|
+
}
|
|
7620
|
+
if (!fromDetail) {
|
|
7621
|
+
accountIdentitiesError = "";
|
|
7622
|
+
accountsNotice = "";
|
|
7623
|
+
}
|
|
7624
|
+
renderAccounts();
|
|
7625
|
+
let syncOpenAfter = false;
|
|
7626
|
+
try {
|
|
7627
|
+
if (closing) {
|
|
7628
|
+
const data = await api(accountBrowserPath(provider, key), { method: "DELETE" });
|
|
7629
|
+
updateAccountBrowserRecord(
|
|
7630
|
+
provider,
|
|
7631
|
+
key,
|
|
7632
|
+
data?.browser ?? { open: false, openedAt: null, exit: null, exitChanged: false },
|
|
7633
|
+
);
|
|
7634
|
+
toast(text.toastBrowserClosed);
|
|
7635
|
+
} else {
|
|
7636
|
+
const data = await api(accountBrowserPath(provider, key), { method: "POST", body: {} });
|
|
7637
|
+
updateAccountBrowserRecord(
|
|
7638
|
+
provider,
|
|
7639
|
+
key,
|
|
7640
|
+
data?.browser ?? { open: true, openedAt: null, exit: null, exitChanged: false },
|
|
7641
|
+
);
|
|
7642
|
+
toast(text.toastBrowserOpened);
|
|
7643
|
+
}
|
|
7644
|
+
} catch (error) {
|
|
7645
|
+
const message = accountBrowserErrorText(error);
|
|
7646
|
+
if (fromDetail && isAccountDetailFor(provider, key)) setDetailError(message);
|
|
7647
|
+
else accountIdentitiesError = message;
|
|
7648
|
+
toast(message);
|
|
7649
|
+
if (error?.code === "browser_already_open") syncOpenAfter = true;
|
|
7650
|
+
} finally {
|
|
7651
|
+
accountBrowserBusy.delete(busyKey);
|
|
7652
|
+
if (isAccountDetailFor(provider, key)) renderDetailBrowser();
|
|
7653
|
+
renderAccounts();
|
|
7654
|
+
}
|
|
7655
|
+
if (syncOpenAfter) {
|
|
7656
|
+
void refreshAccountBrowserState(provider, key);
|
|
7657
|
+
}
|
|
7658
|
+
}
|
|
7659
|
+
|
|
7660
|
+
function renderDetailBrowser() {
|
|
7661
|
+
const button = byId("account-detail-browser");
|
|
7662
|
+
const status = byId("account-detail-browser-status");
|
|
7663
|
+
const notice = byId("account-detail-browser-notice");
|
|
7664
|
+
const context = accountDetailContext;
|
|
7665
|
+
if (!context) {
|
|
7666
|
+
button.textContent = text.accountBrowserOpen;
|
|
7667
|
+
button.disabled = false;
|
|
7668
|
+
button.title = "";
|
|
7669
|
+
status.textContent = "";
|
|
7670
|
+
status.hidden = true;
|
|
7671
|
+
status.className = "setup-note account-browser-status";
|
|
7672
|
+
notice.textContent = "";
|
|
7673
|
+
notice.hidden = true;
|
|
7674
|
+
return;
|
|
7675
|
+
}
|
|
7676
|
+
const latest = findAccountRecord(context.provider, context.key) || context.account;
|
|
7677
|
+
const view = accountDisplay(latest);
|
|
7678
|
+
const pending = accountBrowserPendingState(view.provider, view.key);
|
|
7679
|
+
const open = view.browser.open;
|
|
7680
|
+
const hasFingerprint = Boolean(view.fingerprint.id);
|
|
7681
|
+
const summary = browserStateSummary(view.browser, accountBrowserLabels());
|
|
7682
|
+
|
|
7683
|
+
button.textContent =
|
|
7684
|
+
pending === "opening" ? text.accountBrowserOpening
|
|
7685
|
+
: pending === "closing" ? text.accountBrowserClosing
|
|
7686
|
+
: open ? text.accountBrowserClose
|
|
7687
|
+
: text.accountBrowserOpen;
|
|
7688
|
+
button.disabled = Boolean(pending) || (!open && !hasFingerprint);
|
|
7689
|
+
button.title =
|
|
7690
|
+
pending === "opening" ? text.accountBrowserOpening
|
|
7691
|
+
: pending === "closing" ? text.accountBrowserClosing
|
|
7692
|
+
: !open && !hasFingerprint ? text.accountBrowserNoFingerprintTitle
|
|
7693
|
+
: open ? text.accountBrowserCloseTitle
|
|
7694
|
+
: text.accountBrowserOpenTitle;
|
|
7695
|
+
|
|
7696
|
+
if (summary.open) {
|
|
7697
|
+
status.textContent = summary.statusText;
|
|
7698
|
+
status.className = `setup-note account-browser-status is-${summary.tone}`;
|
|
7699
|
+
status.hidden = false;
|
|
7700
|
+
} else if (!hasFingerprint) {
|
|
7701
|
+
status.textContent = text.accountBrowserNoFingerprintTitle;
|
|
7702
|
+
status.className = "setup-note account-browser-status";
|
|
7703
|
+
status.hidden = false;
|
|
7704
|
+
} else {
|
|
7705
|
+
status.textContent = text.accountBrowserClosed;
|
|
7706
|
+
status.className = "setup-note account-browser-status";
|
|
7707
|
+
status.hidden = false;
|
|
7708
|
+
}
|
|
7709
|
+
|
|
7710
|
+
if (summary.open && summary.noticeText) {
|
|
7711
|
+
notice.textContent = summary.noticeText;
|
|
7712
|
+
notice.hidden = false;
|
|
7713
|
+
} else {
|
|
7714
|
+
notice.textContent = "";
|
|
7715
|
+
notice.hidden = true;
|
|
7716
|
+
}
|
|
7717
|
+
}
|
|
7718
|
+
|
|
7719
|
+
async function loadAccountBrowser(context) {
|
|
7720
|
+
const token = detailBrowserGuard.begin();
|
|
7721
|
+
let data;
|
|
7722
|
+
try {
|
|
7723
|
+
data = await api(accountBrowserPath(context.provider, context.key));
|
|
7724
|
+
} catch {
|
|
7725
|
+
return;
|
|
7726
|
+
}
|
|
7727
|
+
if (!detailBrowserGuard.isCurrent(token) || accountDetailContext !== context) return;
|
|
7728
|
+
if (accountBrowserBusy.has(accountBrowserKey(context.provider, context.key))) return;
|
|
7729
|
+
if (data?.browser) {
|
|
7730
|
+
updateAccountBrowserRecord(context.provider, context.key, data.browser);
|
|
7731
|
+
renderDetailBrowser();
|
|
7732
|
+
renderAccounts();
|
|
7733
|
+
}
|
|
7734
|
+
}
|
|
7735
|
+
|
|
7736
|
+
function toggleBrowserFromDetail() {
|
|
7737
|
+
const context = accountDetailContext;
|
|
7738
|
+
if (!context) return;
|
|
7739
|
+
const account = findAccountRecord(context.provider, context.key) || context.account;
|
|
7740
|
+
void toggleAccountBrowser(account, { fromDetail: true });
|
|
7741
|
+
}
|
|
7742
|
+
|
|
7336
7743
|
function openAccountDetail(account) {
|
|
7337
7744
|
const dialog = byId("account-detail-dialog");
|
|
7338
7745
|
const view = accountDisplay(account);
|
|
@@ -7340,12 +7747,14 @@ function openAccountDetail(account) {
|
|
|
7340
7747
|
byId("account-detail-title").textContent = view.name;
|
|
7341
7748
|
byId("account-detail-copy").textContent = `${view.providerLabel} · ${view.key}`;
|
|
7342
7749
|
renderDetailFacts(view);
|
|
7750
|
+
renderDetailBrowser();
|
|
7343
7751
|
byId("account-detail-note").value = view.note;
|
|
7344
7752
|
setDetailError("");
|
|
7345
7753
|
setDetailStatus(view.signedIn ? text.accountDetailSigninHint : text.accountDetailRetiredHint);
|
|
7346
7754
|
renderDetailHistory(view.checks);
|
|
7347
7755
|
if (!dialog.open) dialog.showModal();
|
|
7348
7756
|
void loadAccountExit(accountDetailContext);
|
|
7757
|
+
void loadAccountBrowser(accountDetailContext);
|
|
7349
7758
|
}
|
|
7350
7759
|
|
|
7351
7760
|
function closeAccountDetail() {
|
|
@@ -7355,6 +7764,7 @@ function closeAccountDetail() {
|
|
|
7355
7764
|
|
|
7356
7765
|
function cleanupAccountDetail() {
|
|
7357
7766
|
detailExitProxyGuard.cancel();
|
|
7767
|
+
detailBrowserGuard.cancel();
|
|
7358
7768
|
if (detailExitController) {
|
|
7359
7769
|
detailExitController.abort();
|
|
7360
7770
|
detailExitController = null;
|
|
@@ -7368,6 +7778,7 @@ function cleanupAccountDetail() {
|
|
|
7368
7778
|
const status = byId("account-detail-exit-status");
|
|
7369
7779
|
status.textContent = "";
|
|
7370
7780
|
status.hidden = true;
|
|
7781
|
+
renderDetailBrowser();
|
|
7371
7782
|
setDetailError("");
|
|
7372
7783
|
}
|
|
7373
7784
|
|
|
@@ -7392,6 +7803,7 @@ const HOSTING_REASON_KEYS = {
|
|
|
7392
7803
|
no_browser_method: "accountHostingReasonNoBrowserMethod",
|
|
7393
7804
|
method_not_found: "accountHostingReasonMethodNotFound",
|
|
7394
7805
|
unavailable: "accountHostingReasonUnavailable",
|
|
7806
|
+
browser_open: "errorAccountBrowserOpen",
|
|
7395
7807
|
};
|
|
7396
7808
|
|
|
7397
7809
|
// A known reason gets the page's own wording; an unknown one still shows the
|
|
@@ -7450,7 +7862,10 @@ function renderHostingFacts(view, inspect) {
|
|
|
7450
7862
|
? text.accountHostingNextNone
|
|
7451
7863
|
: text.accountHostingNextOff],
|
|
7452
7864
|
[text.accountHostingLastLabel, last],
|
|
7453
|
-
[
|
|
7865
|
+
[
|
|
7866
|
+
text.accountHostingExitLabel,
|
|
7867
|
+
formatExit(view.exit ?? view.lastLogin, text.accountExitDirect, accountExitLabels()),
|
|
7868
|
+
],
|
|
7454
7869
|
[text.accountHostingFingerprintLabel, view.fingerprint.id || text.accountFingerprintNone],
|
|
7455
7870
|
]) {
|
|
7456
7871
|
const wrap = document.createElement("div");
|
|
@@ -7699,12 +8114,14 @@ async function saveAccountNote() {
|
|
|
7699
8114
|
// Only the row the service returned is applied; never a locally invented
|
|
7700
8115
|
// account object. The PATCH response is the source of truth for the note.
|
|
7701
8116
|
if (data?.account) {
|
|
8117
|
+
detailBrowserGuard.cancel();
|
|
7702
8118
|
const index = accountIdentities.findIndex(
|
|
7703
8119
|
(item) => item?.provider === context.provider && item?.key === context.key,
|
|
7704
8120
|
);
|
|
7705
8121
|
if (index >= 0) accountIdentities[index] = data.account;
|
|
7706
8122
|
context.account = data.account;
|
|
7707
8123
|
renderDetailFacts(accountDisplay(data.account));
|
|
8124
|
+
renderDetailBrowser();
|
|
7708
8125
|
renderDetailHistory(accountView(data.account).checks);
|
|
7709
8126
|
}
|
|
7710
8127
|
setDetailStatus(text.accountDetailSaved);
|
|
@@ -7746,6 +8163,7 @@ async function saveAccountExit() {
|
|
|
7746
8163
|
if (accountDetailContext !== context) return;
|
|
7747
8164
|
accountDetailExit = data?.exit ?? accountDetailExit;
|
|
7748
8165
|
if (data?.account) {
|
|
8166
|
+
detailBrowserGuard.cancel();
|
|
7749
8167
|
const index = accountIdentities.findIndex(
|
|
7750
8168
|
(item) => item?.provider === context.provider && item?.key === context.key,
|
|
7751
8169
|
);
|
|
@@ -7757,6 +8175,7 @@ async function saveAccountExit() {
|
|
|
7757
8175
|
// Redraw after the shared identity list carries the new exit: the sign-in
|
|
7758
8176
|
// dialog and this picker must agree on which nodes are already assigned.
|
|
7759
8177
|
renderDetailExit();
|
|
8178
|
+
renderDetailBrowser();
|
|
7760
8179
|
if (data?.account) renderAccounts();
|
|
7761
8180
|
const status = byId("account-detail-exit-status");
|
|
7762
8181
|
status.textContent = text.accountDetailExitSaved;
|
|
@@ -8368,6 +8787,7 @@ document.addEventListener("keydown", (nativeEvent) => {
|
|
|
8368
8787
|
});
|
|
8369
8788
|
byId("account-detail-close").addEventListener("click", closeAccountDetail);
|
|
8370
8789
|
byId("account-detail-dismiss").addEventListener("click", closeAccountDetail);
|
|
8790
|
+
byId("account-detail-browser").addEventListener("click", toggleBrowserFromDetail);
|
|
8371
8791
|
byId("account-detail-check").addEventListener("click", openCheckFromDetail);
|
|
8372
8792
|
byId("account-detail-note-save").addEventListener("click", saveAccountNote);
|
|
8373
8793
|
byId("account-detail-exit-save").addEventListener("click", saveAccountExit);
|
package/ui/index.html
CHANGED
|
@@ -660,6 +660,10 @@
|
|
|
660
660
|
<p class="field-hint" id="account-detail-exit-hint"></p>
|
|
661
661
|
<p class="setup-note" id="account-detail-exit-status" role="status" hidden></p>
|
|
662
662
|
</div>
|
|
663
|
+
<div class="account-browser-box" id="account-detail-browser-box">
|
|
664
|
+
<p class="setup-note account-browser-status" id="account-detail-browser-status" role="status"></p>
|
|
665
|
+
<p class="setup-note account-browser-notice" id="account-detail-browser-notice" role="status" hidden></p>
|
|
666
|
+
</div>
|
|
663
667
|
<div class="field account-note-field">
|
|
664
668
|
<label for="account-detail-note" id="account-detail-note-label">Note</label>
|
|
665
669
|
<textarea id="account-detail-note" rows="3" maxlength="200"
|
|
@@ -673,6 +677,7 @@
|
|
|
673
677
|
</div>
|
|
674
678
|
<div class="dialog-footer">
|
|
675
679
|
<button class="button" id="account-detail-dismiss" type="button">Close</button>
|
|
680
|
+
<button class="button" id="account-detail-browser" type="button">Open browser</button>
|
|
676
681
|
<button class="button" id="account-detail-check" type="button">Check</button>
|
|
677
682
|
<button class="button" id="account-detail-exit-save" type="button">Save exit</button>
|
|
678
683
|
<button class="button primary" id="account-detail-note-save" type="button">Save note</button>
|