@blackbelt-technology/pi-dashboard-gmail-plugin 0.11.0 → 0.12.0
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/README.md +22 -37
- package/package.json +3 -3
- package/src/bridge/lease-client.ts +127 -7
- package/src/bridge/tools.ts +1 -1
- package/src/client/GmailSettings.tsx +52 -1137
- package/src/i18n.ts +9 -619
- package/src/server/accounts.ts +17 -4
- package/src/server/google-link.ts +81 -0
- package/src/server/google-oauth.ts +2 -2
- package/src/server/index.ts +31 -21
- package/src/server/lease.ts +3 -2
- package/src/server/routes.ts +37 -296
- package/src/shared/client-json.ts +2 -2
- package/src/shared/protocol.ts +18 -0
- package/src/shared/scopes.ts +2 -2
- package/src/shared/setup.ts +2 -2
- package/src/client/AutoSetup.tsx +0 -787
- package/src/client/auto-setup.ts +0 -124
- package/src/client/ui.ts +0 -24
- package/src/client/wizard.ts +0 -196
- package/src/server/gmail-rest.ts +0 -27
- package/src/server/setup/browser-service.ts +0 -55
- package/src/server/setup/capture.ts +0 -96
- package/src/server/setup/cdp-page.ts +0 -308
- package/src/server/setup/errors.ts +0 -36
- package/src/server/setup/local.ts +0 -27
- package/src/server/setup/mask.ts +0 -11
- package/src/server/setup/run.ts +0 -723
- package/src/server/setup/setup-routes.ts +0 -123
- package/src/server/setup/steps.ts +0 -458
- package/src/server/store-client.ts +0 -30
- package/src/shared/auto-setup.ts +0 -132
- package/src/shared/flow-codes.ts +0 -36
package/src/shared/auto-setup.ts
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Automatic Google Cloud setup — wire types shared by the gmail server run engine
|
|
3
|
-
* and the settings client. Pure types + two constants; no I/O.
|
|
4
|
-
* The run view is secret-free by construction: it carries no client secret and no
|
|
5
|
-
* dedicated-browser `instanceId`. See change: add-gmail-auto-setup.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/** Recipe step ids, in execution order. */
|
|
9
|
-
export const SETUP_STEP_IDS = ["project", "api", "branding", "publish", "client", "capture"] as const;
|
|
10
|
-
export type SetupStepId = (typeof SETUP_STEP_IDS)[number];
|
|
11
|
-
|
|
12
|
-
export type SetupStepStatus = "pending" | "running" | "done" | "skipped" | "handoff";
|
|
13
|
-
|
|
14
|
-
/** Manual wizard step (1–4 in `client/wizard.ts`) a recipe step maps to. */
|
|
15
|
-
export type WizardStepNumber = 1 | 2 | 3 | 4;
|
|
16
|
-
|
|
17
|
-
/** `project`,`api` → 1; `branding` → 2; `publish` → 3; `client`,`capture` → 4. */
|
|
18
|
-
export const WIZARD_STEP_OF: Record<SetupStepId, WizardStepNumber> = {
|
|
19
|
-
project: 1,
|
|
20
|
-
api: 1,
|
|
21
|
-
branding: 2,
|
|
22
|
-
publish: 3,
|
|
23
|
-
client: 4,
|
|
24
|
-
capture: 4,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export type SetupRunState =
|
|
28
|
-
| "starting"
|
|
29
|
-
| "running"
|
|
30
|
-
| "waiting_user"
|
|
31
|
-
| "waiting_decision"
|
|
32
|
-
| "busy"
|
|
33
|
-
| "done"
|
|
34
|
-
| "handoff"
|
|
35
|
-
| "cancelled";
|
|
36
|
-
|
|
37
|
-
/** Human checkpoints the run waits on; it never performs these clicks itself. */
|
|
38
|
-
export type CheckpointKind = "sign_in" | "console_terms" | "policy" | "publish";
|
|
39
|
-
|
|
40
|
-
/** Dedicated-browser refusals that hand off at `project`. */
|
|
41
|
-
export type BrowserRefusalReason =
|
|
42
|
-
| "disabled"
|
|
43
|
-
| "unloaded"
|
|
44
|
-
| "no-chrome"
|
|
45
|
-
| "no-display"
|
|
46
|
-
| "owned-by-other-server"
|
|
47
|
-
| "profile-in-use"
|
|
48
|
-
| "launch-failed";
|
|
49
|
-
|
|
50
|
-
export type HandoffReason =
|
|
51
|
-
| "unexpected_page"
|
|
52
|
-
| "locale"
|
|
53
|
-
| "domain_blocked"
|
|
54
|
-
| "publish_cancelled"
|
|
55
|
-
| "timeout"
|
|
56
|
-
| "secret_capture_failed"
|
|
57
|
-
| "client_in_use"
|
|
58
|
-
| "browser_closed"
|
|
59
|
-
| BrowserRefusalReason;
|
|
60
|
-
|
|
61
|
-
export type Audience = "internal" | "external";
|
|
62
|
-
|
|
63
|
-
export interface PublishLinks {
|
|
64
|
-
homePage: string;
|
|
65
|
-
privacyPolicy: string;
|
|
66
|
-
authorizedDomain: string;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export type SetupDecision =
|
|
70
|
-
| { kind: "audience"; detected: Audience; org?: string }
|
|
71
|
-
| { kind: "links"; links: PublishLinks };
|
|
72
|
-
|
|
73
|
-
export interface SetupRunView {
|
|
74
|
-
runId: string;
|
|
75
|
-
state: SetupRunState;
|
|
76
|
-
/** Step being worked on (or the one that stopped the run). */
|
|
77
|
-
step: SetupStepId;
|
|
78
|
-
steps: Array<{ id: SetupStepId; status: SetupStepStatus }>;
|
|
79
|
-
checkpoint?: { kind: CheckpointKind };
|
|
80
|
-
decision?: SetupDecision;
|
|
81
|
-
/** Holder label (session id or client label) of the dedicated profile; never an instance id. */
|
|
82
|
-
busy?: { holder?: string };
|
|
83
|
-
handoff?: {
|
|
84
|
-
step: SetupStepId;
|
|
85
|
-
wizardStep: WizardStepNumber;
|
|
86
|
-
reason: HandoffReason;
|
|
87
|
-
/** `domain_blocked` only: the domains the dedicated browser must allow. */
|
|
88
|
-
domains?: string[];
|
|
89
|
-
};
|
|
90
|
-
projectId?: string;
|
|
91
|
-
/** Resources this run made on Google's side, so a hand-off can name them. */
|
|
92
|
-
created: { projectId?: string; clients: string[] };
|
|
93
|
-
/** Set once the client is stored (done). */
|
|
94
|
-
clientId?: string;
|
|
95
|
-
ownerEmail?: string;
|
|
96
|
-
/** Audience the run chose, or the one already configured on a re-run (reported, not asked). */
|
|
97
|
-
audience?: Audience;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/** `GET /state` → `autoSetup`. */
|
|
101
|
-
export interface AutoSetupState {
|
|
102
|
-
available: boolean;
|
|
103
|
-
/** Why unavailable: a `BrowserRefusalReason`, `service_missing`, `remote_dashboard`, `run_active`. */
|
|
104
|
-
reason?: string;
|
|
105
|
-
/** The request came from a genuinely local peer. */
|
|
106
|
-
local: boolean;
|
|
107
|
-
/** A configured client without accounts would be replaced by the new one. */
|
|
108
|
-
replacesClient?: boolean;
|
|
109
|
-
/** Id of the live (or last, unacknowledged) run, so a reloaded settings page can re-attach to it. */
|
|
110
|
-
runId?: string;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/** `POST setup/run` body. */
|
|
114
|
-
export interface SetupRunRequest {
|
|
115
|
-
mode: "new" | "existing";
|
|
116
|
-
projectId?: string;
|
|
117
|
-
ownerEmail: string;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/** `POST setup/run/:id/continue` body (answers a decision or acknowledges a checkpoint). */
|
|
121
|
-
export interface SetupContinueRequest {
|
|
122
|
-
audience?: Audience;
|
|
123
|
-
links?: PublishLinks;
|
|
124
|
-
confirmLinks?: boolean;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/** Defaults for External publishing (design D7). */
|
|
128
|
-
export const DEFAULT_PUBLISH_LINKS: PublishLinks = {
|
|
129
|
-
homePage: "https://github.com/BlackBeltTechnology/pi-agent-dashboard",
|
|
130
|
-
privacyPolicy: "https://github.com/BlackBeltTechnology/pi-agent-dashboard",
|
|
131
|
-
authorizedDomain: "github.com",
|
|
132
|
-
};
|
package/src/shared/flow-codes.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Closed set of fixed, input-free codes a Gmail sign-in flow can terminate
|
|
3
|
-
* with (design D2/D3). Shared by the server failure log (allow-list) and the
|
|
4
|
-
* client error table. See change: improve-gmail-settings-ux.
|
|
5
|
-
*/
|
|
6
|
-
export const KNOWN_FLOW_CODES = [
|
|
7
|
-
"org_internal",
|
|
8
|
-
"access_denied",
|
|
9
|
-
"admin_policy_enforced",
|
|
10
|
-
"redirect_uri_mismatch",
|
|
11
|
-
"invalid_client",
|
|
12
|
-
"scope_missing",
|
|
13
|
-
"account_mismatch",
|
|
14
|
-
"missing_refresh",
|
|
15
|
-
"email_unverified",
|
|
16
|
-
"invalid_redirect",
|
|
17
|
-
"state_mismatch",
|
|
18
|
-
"callback_failed",
|
|
19
|
-
"token_exchange_failed",
|
|
20
|
-
"id_token_invalid",
|
|
21
|
-
"authorization_failed",
|
|
22
|
-
"timeout",
|
|
23
|
-
"start_timeout",
|
|
24
|
-
"login_failed",
|
|
25
|
-
"cancelled",
|
|
26
|
-
"aborted",
|
|
27
|
-
] as const;
|
|
28
|
-
|
|
29
|
-
export type FlowCode = (typeof KNOWN_FLOW_CODES)[number];
|
|
30
|
-
|
|
31
|
-
const KNOWN = new Set<string>(KNOWN_FLOW_CODES);
|
|
32
|
-
|
|
33
|
-
/** `code` when it is a string in {@link KNOWN_FLOW_CODES}, else `null` (exact match). */
|
|
34
|
-
export function knownFlowCode(code: unknown): FlowCode | null {
|
|
35
|
-
return typeof code === "string" && KNOWN.has(code) ? (code as FlowCode) : null;
|
|
36
|
-
}
|