@epam/ai-dial-chat-hooks 1.5.0-dev.33 → 1.5.0-dev.36
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/external-services/useExternalServiceLogin.js +7 -7
- package/external-services.js +3 -3
- package/index.js +247 -247
- package/oauth/batch-channel.d.ts +42 -0
- package/oauth/batch-channel.d.ts.map +1 -0
- package/oauth/batch-channel.js +90 -0
- package/oauth/handshake.d.ts +59 -2
- package/oauth/handshake.d.ts.map +1 -1
- package/oauth/handshake.js +204 -35
- package/oauth/models.d.ts +90 -1
- package/oauth/models.d.ts.map +1 -1
- package/oauth/popup.d.ts +35 -1
- package/oauth/popup.d.ts.map +1 -1
- package/oauth/popup.js +35 -15
- package/oauth/redirect-state.d.ts +12 -0
- package/oauth/redirect-state.d.ts.map +1 -0
- package/oauth/redirect-state.js +20 -0
- package/oauth/types.d.ts +41 -2
- package/oauth/types.d.ts.map +1 -1
- package/oauth/types.js +9 -3
- package/oauth/useOAuthCallbackCompletion/useOAuthCallbackCompletion.d.ts +11 -5
- package/oauth/useOAuthCallbackCompletion/useOAuthCallbackCompletion.d.ts.map +1 -1
- package/oauth/useOAuthCallbackCompletion/useOAuthCallbackCompletion.js +95 -66
- package/oauth/useToolsetLogin/useToolsetLogin.d.ts +11 -1
- package/oauth/useToolsetLogin/useToolsetLogin.d.ts.map +1 -1
- package/oauth/useToolsetLogin/useToolsetLogin.js +96 -45
- package/oauth.js +10 -10
- package/offline-credentials/useOfflineCredentialsLogin/useOfflineCredentialsLogin.js +5 -5
- package/package.json +17 -17
- package/signin-interrupt/models.d.ts +25 -1
- package/signin-interrupt/models.d.ts.map +1 -1
- package/signin-interrupt/types.d.ts +12 -1
- package/signin-interrupt/types.d.ts.map +1 -1
- package/signin-interrupt/types.js +4 -2
- package/signin-interrupt/useSigninInterrupt/useSigninInterrupt.d.ts +29 -5
- package/signin-interrupt/useSigninInterrupt/useSigninInterrupt.d.ts.map +1 -1
- package/signin-interrupt/useSigninInterrupt/useSigninInterrupt.js +412 -134
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ToolsetOAuthBatchMessage, ToolsetOAuthBatchProgress } from './models';
|
|
2
|
+
/** Interval at which the window repeats its ready message. */
|
|
3
|
+
export declare const BATCH_RETRY_INTERVAL_MS = 500;
|
|
4
|
+
/** Time a window waits for a command from its run before it goes idle. */
|
|
5
|
+
export declare const BATCH_WINDOW_IDLE_TIMEOUT_MS: number;
|
|
6
|
+
/** Name of the same-origin channel shared by a bulk sign-in run and its windows. */
|
|
7
|
+
export declare const getToolsetOAuthBatchChannelName: (runId: string) => string;
|
|
8
|
+
/** Whether a channel message is a bulk sign-in message of the given run. */
|
|
9
|
+
export declare const isToolsetOAuthBatchMessage: (value: unknown, runId: string) => value is ToolsetOAuthBatchMessage;
|
|
10
|
+
/** Whether a URL may be navigated to by a bulk sign-in window. */
|
|
11
|
+
export declare const isNavigableProviderUrl: (url: unknown) => url is string;
|
|
12
|
+
/** Run and window a waiting bulk sign-in window belongs to. */
|
|
13
|
+
export interface BatchWindowIdentity {
|
|
14
|
+
/** Run id. */
|
|
15
|
+
runId: string;
|
|
16
|
+
/** Window id within the run. */
|
|
17
|
+
windowId: string;
|
|
18
|
+
}
|
|
19
|
+
/** Reads the run and window a waiting callback page was opened for, or `null`. */
|
|
20
|
+
export declare const readBatchWindowIdentity: (searchParams: URLSearchParams) => BatchWindowIdentity | null;
|
|
21
|
+
/** Options for {@link startBatchWindowWaiting}. */
|
|
22
|
+
export interface StartBatchWindowWaitingOptions extends BatchWindowIdentity {
|
|
23
|
+
/** Last step this window accepted; `0` for a fresh window. */
|
|
24
|
+
lastStepId: number;
|
|
25
|
+
/** Receives each upcoming target the run sends. */
|
|
26
|
+
onProgress: (progress: ToolsetOAuthBatchProgress) => void;
|
|
27
|
+
/** Called once when no command arrived in time. */
|
|
28
|
+
onIdle: () => void;
|
|
29
|
+
/** Navigates this window; defaults to `window.location.assign`. */
|
|
30
|
+
navigate?: (url: string) => void;
|
|
31
|
+
/** Closes this window; defaults to `window.close`. */
|
|
32
|
+
close?: () => void;
|
|
33
|
+
idleTimeoutMs?: number;
|
|
34
|
+
retryIntervalMs?: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Makes this callback window wait for its run's next command: it repeats a
|
|
38
|
+
* ready message, shows progress, runs a later step's navigation once, closes
|
|
39
|
+
* on request, and goes idle when the run falls silent. Returns a cleanup.
|
|
40
|
+
*/
|
|
41
|
+
export declare const startBatchWindowWaiting: ({ runId, windowId, lastStepId, onProgress, onIdle, navigate, close, idleTimeoutMs, retryIntervalMs, }: StartBatchWindowWaitingOptions) => (() => void);
|
|
42
|
+
//# sourceMappingURL=batch-channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-channel.d.ts","sourceRoot":"","sources":["../../src/oauth/batch-channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,UAAU,CAAC;AAelB,8DAA8D;AAC9D,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,0EAA0E;AAC1E,eAAO,MAAM,4BAA4B,QAAY,CAAC;AAItD,oFAAoF;AACpF,eAAO,MAAM,+BAA+B,GAAI,OAAO,MAAM,KAAG,MACf,CAAC;AAMlD,4EAA4E;AAC5E,eAAO,MAAM,0BAA0B,GACrC,OAAO,OAAO,EACd,OAAO,MAAM,KACZ,KAAK,IAAI,wBAOW,CAAC;AAExB,kEAAkE;AAClE,eAAO,MAAM,sBAAsB,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,MAO5D,CAAC;AAEF,+DAA+D;AAC/D,MAAM,WAAW,mBAAmB;IAClC,cAAc;IACd,KAAK,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,kFAAkF;AAClF,eAAO,MAAM,uBAAuB,GAClC,cAAc,eAAe,KAC5B,mBAAmB,GAAG,IAIxB,CAAC;AAEF,mDAAmD;AACnD,MAAM,WAAW,8BAA+B,SAAQ,mBAAmB;IACzE,8DAA8D;IAC9D,UAAU,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,UAAU,EAAE,CAAC,QAAQ,EAAE,yBAAyB,KAAK,IAAI,CAAC;IAC1D,mDAAmD;IACnD,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAAI,uGAUrC,8BAA8B,KAAG,CAAC,MAAM,IAAI,CAgJ9C,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ToolsetOAuthBatchMessageType as e, ToolsetOAuthCallbackQuery as t } from "./types.js";
|
|
2
|
+
import { writeToolsetRedirectState as n } from "./redirect-state.js";
|
|
3
|
+
//#region src/oauth/batch-channel.ts
|
|
4
|
+
var r = "toolset-oauth-batch-", i = 6e4, a = /* @__PURE__ */ new Set(["http:", "https:"]), o = (e) => `${r}${e}`, s = new Set(Object.values(e)), c = (e, t) => typeof e == "object" && !!e && "type" in e && typeof e.type == "string" && s.has(e.type) && "runId" in e && e.runId === t, l = (e) => {
|
|
5
|
+
if (typeof e != "string") return !1;
|
|
6
|
+
try {
|
|
7
|
+
return a.has(new URL(e).protocol);
|
|
8
|
+
} catch {
|
|
9
|
+
return !1;
|
|
10
|
+
}
|
|
11
|
+
}, u = (e) => {
|
|
12
|
+
let n = e.get(t.BatchRun), r = e.get(t.BatchWindow);
|
|
13
|
+
return n && r ? {
|
|
14
|
+
runId: n,
|
|
15
|
+
windowId: r
|
|
16
|
+
} : null;
|
|
17
|
+
}, d = ({ runId: t, windowId: r, lastStepId: a, onProgress: s, onIdle: u, navigate: d = (e) => window.location.assign(e), close: f = () => window.close(), idleTimeoutMs: p = i, retryIntervalMs: m = 500 }) => {
|
|
18
|
+
let h, g, _ = !1, v = !1, y = {}, b = (e) => {
|
|
19
|
+
try {
|
|
20
|
+
h?.postMessage(e);
|
|
21
|
+
} catch {}
|
|
22
|
+
}, x = () => {
|
|
23
|
+
clearInterval(y.ready), clearTimeout(y.idle);
|
|
24
|
+
}, S = () => {
|
|
25
|
+
g != null || _ || v || b({
|
|
26
|
+
type: e.Released,
|
|
27
|
+
runId: t,
|
|
28
|
+
windowId: r
|
|
29
|
+
});
|
|
30
|
+
}, C = () => {
|
|
31
|
+
if (v) return;
|
|
32
|
+
v = !0, x(), window.removeEventListener("pagehide", S);
|
|
33
|
+
let e = h;
|
|
34
|
+
h = void 0, setTimeout(() => e?.close(), 0);
|
|
35
|
+
}, w = () => {
|
|
36
|
+
_ || v || (_ = !0, x(), b({
|
|
37
|
+
type: e.Released,
|
|
38
|
+
runId: t,
|
|
39
|
+
windowId: r
|
|
40
|
+
}), u());
|
|
41
|
+
}, T = () => {
|
|
42
|
+
clearTimeout(y.idle), y.idle = setTimeout(w, p);
|
|
43
|
+
}, E = () => b({
|
|
44
|
+
type: e.Ready,
|
|
45
|
+
runId: t,
|
|
46
|
+
windowId: r,
|
|
47
|
+
lastStepId: a
|
|
48
|
+
}), D = (i) => {
|
|
49
|
+
if (g === i.stepId) {
|
|
50
|
+
b({
|
|
51
|
+
type: e.Accepted,
|
|
52
|
+
runId: t,
|
|
53
|
+
windowId: r,
|
|
54
|
+
stepId: i.stepId
|
|
55
|
+
});
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
let { batch: o } = i.redirectState ?? {};
|
|
59
|
+
g != null || _ || typeof i.stepId != "number" || i.stepId <= a || !l(i.url) || typeof i.redirectState?.toolsetId != "string" || o?.runId !== t || o.windowId !== r || o.stepId !== i.stepId || (g = i.stepId, x(), n(sessionStorage, i.redirectState), b({
|
|
60
|
+
type: e.Accepted,
|
|
61
|
+
runId: t,
|
|
62
|
+
windowId: r,
|
|
63
|
+
stepId: i.stepId
|
|
64
|
+
}), setTimeout(() => d(i.url), 0));
|
|
65
|
+
}, O = (n) => {
|
|
66
|
+
let i = n.data;
|
|
67
|
+
if (!v && c(i, t)) {
|
|
68
|
+
if (i.type === e.Close) {
|
|
69
|
+
if (i.windowId != null && i.windowId !== r) return;
|
|
70
|
+
C(), f();
|
|
71
|
+
} else if (i.windowId === r) switch (i.type) {
|
|
72
|
+
case e.Progress:
|
|
73
|
+
if (_ || g != null) return;
|
|
74
|
+
T(), s(i.progress);
|
|
75
|
+
return;
|
|
76
|
+
case e.Navigate:
|
|
77
|
+
D(i);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
try {
|
|
83
|
+
h = new BroadcastChannel(o(t)), h.onmessage = O;
|
|
84
|
+
} catch {
|
|
85
|
+
return w(), C;
|
|
86
|
+
}
|
|
87
|
+
return window.addEventListener("pagehide", S), E(), y.ready = setInterval(E, m), T(), C;
|
|
88
|
+
};
|
|
89
|
+
//#endregion
|
|
90
|
+
export { i as BATCH_WINDOW_IDLE_TIMEOUT_MS, o as getToolsetOAuthBatchChannelName, l as isNavigableProviderUrl, c as isToolsetOAuthBatchMessage, u as readBatchWindowIdentity, d as startBatchWindowWaiting };
|
package/oauth/handshake.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ToolsetOAuthResult } from './models';
|
|
2
|
-
import { ToolsetCredentialsLevel } from './types';
|
|
1
|
+
import { ToolsetOAuthBatchLateSuccess, ToolsetOAuthBatchProgress, ToolsetOAuthBatchStepOutcome, ToolsetOAuthResult, ToolsetOAuthSettings } from './models';
|
|
2
|
+
import { OAuthResourceKind, ToolsetCredentialsLevel } from './types';
|
|
3
3
|
/** Name of the same-origin `BroadcastChannel` shared by an OAuth flow's opener and its callback popup. */
|
|
4
4
|
export declare const getToolsetOAuthChannelName: (flowId: string) => string;
|
|
5
5
|
/** Options for {@link waitForToolsetOAuthResult}. */
|
|
@@ -27,4 +27,61 @@ export interface WaitForToolsetOAuthResultOptions {
|
|
|
27
27
|
* itself even when the retained WindowProxy was severed.
|
|
28
28
|
*/
|
|
29
29
|
export declare const waitForToolsetOAuthResult: (popup: Window, flowId: string, { toolsetId, credentialsLevel, callbackPath, timeoutMs, pollIntervalMs, }: WaitForToolsetOAuthResultOptions) => Promise<ToolsetOAuthResult>;
|
|
30
|
+
/** Options for {@link createToolsetOAuthBatchSession}. */
|
|
31
|
+
export interface CreateToolsetOAuthBatchSessionOptions {
|
|
32
|
+
/** The host's OAuth callback route; every window of the run waits on it. */
|
|
33
|
+
callbackPath: string;
|
|
34
|
+
/** Receives a success that arrived after its step had resolved as `WindowLost`. */
|
|
35
|
+
onLateSuccess?: (result: ToolsetOAuthBatchLateSuccess) => void;
|
|
36
|
+
/** Called when a window of the run answers again while the session has none. */
|
|
37
|
+
onWindowAvailable?: () => void;
|
|
38
|
+
/** Time a step waits for its window to be ready. Defaults to 30 seconds. */
|
|
39
|
+
readyTimeoutMs?: number;
|
|
40
|
+
/** Time a step waits for its window to accept the navigation. Defaults to 10 seconds. */
|
|
41
|
+
acceptTimeoutMs?: number;
|
|
42
|
+
/** Time a step waits for its provider result. Defaults to 5 minutes. */
|
|
43
|
+
resultTimeoutMs?: number;
|
|
44
|
+
/** Interval at which a navigation command is repeated. Defaults to 500 ms. */
|
|
45
|
+
retryIntervalMs?: number;
|
|
46
|
+
/** Time after `close` during which a window that answers late is still told to close. Defaults to 5 seconds. */
|
|
47
|
+
closeGraceMs?: number;
|
|
48
|
+
}
|
|
49
|
+
/** One provider step for {@link ToolsetOAuthBatchSession.runStep}. */
|
|
50
|
+
export interface ToolsetOAuthBatchStepParams {
|
|
51
|
+
/** OAuth client settings of the target. */
|
|
52
|
+
auth: ToolsetOAuthSettings;
|
|
53
|
+
/** Resource id of the target. */
|
|
54
|
+
toolsetId: string;
|
|
55
|
+
/** Credentials level the step signs in at. */
|
|
56
|
+
credentialsLevel: ToolsetCredentialsLevel;
|
|
57
|
+
/** Resource kind of the target. Defaults to `Toolset`. */
|
|
58
|
+
resourceKind?: OAuthResourceKind;
|
|
59
|
+
/** Offline-use consent the exchange carries. */
|
|
60
|
+
offlineUsageConsent?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/** Initiating-tab side of a bulk sign-in run that reuses one window for successive providers. */
|
|
63
|
+
export interface ToolsetOAuthBatchSession {
|
|
64
|
+
/** Random id of the run. */
|
|
65
|
+
readonly runId: string;
|
|
66
|
+
/** Whether the run currently has a window to run a step in. */
|
|
67
|
+
hasWindow: () => boolean;
|
|
68
|
+
/** Opens a window for the run; call synchronously inside a user gesture. Returns `false` when blocked. */
|
|
69
|
+
openWindow: () => boolean;
|
|
70
|
+
/** Shows the upcoming target in the run's window. */
|
|
71
|
+
showProgress: (progress: ToolsetOAuthBatchProgress) => void;
|
|
72
|
+
/** Runs one provider step in the run's window and resolves its outcome. */
|
|
73
|
+
runStep: (params: ToolsetOAuthBatchStepParams) => Promise<ToolsetOAuthBatchStepOutcome>;
|
|
74
|
+
/** Closes every window of the run and releases all listeners. */
|
|
75
|
+
close: () => void;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Creates the initiating tab's side of a bulk sign-in run. The tab builds
|
|
79
|
+
* each step's `state` and authorize URL and sends them to the run's window
|
|
80
|
+
* over a same-origin channel; the window stores the redirect state and
|
|
81
|
+
* navigates itself, so the run survives a provider that severs this tab's
|
|
82
|
+
* `WindowProxy`. Every step's result listener stays open until `close`, so a
|
|
83
|
+
* success that arrives after its step looked lost still reaches
|
|
84
|
+
* `onLateSuccess`.
|
|
85
|
+
*/
|
|
86
|
+
export declare const createToolsetOAuthBatchSession: ({ callbackPath, onLateSuccess, onWindowAvailable, readyTimeoutMs, acceptTimeoutMs, resultTimeoutMs, retryIntervalMs, closeGraceMs, }: CreateToolsetOAuthBatchSessionOptions) => ToolsetOAuthBatchSession;
|
|
30
87
|
//# sourceMappingURL=handshake.d.ts.map
|
package/oauth/handshake.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handshake.d.ts","sourceRoot":"","sources":["../../src/oauth/handshake.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handshake.d.ts","sourceRoot":"","sources":["../../src/oauth/handshake.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,4BAA4B,EAE5B,yBAAyB,EACzB,4BAA4B,EAE5B,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAKlB,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EAOxB,MAAM,SAAS,CAAC;AAIjB,0GAA0G;AAC1G,eAAO,MAAM,0BAA0B,GAAI,QAAQ,MAAM,KAAG,MAChB,CAAC;AA4B7C,qDAAqD;AACrD,MAAM,WAAW,gCAAgC;IAC/C,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,gBAAgB,EAAE,uBAAuB,CAAC;IAC1C;;;;;OAKG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,GACpC,OAAO,MAAM,EACb,QAAQ,MAAM,EACd,2EAMG,gCAAgC,KAClC,OAAO,CAAC,kBAAkB,CAkHzB,CAAC;AAML,0DAA0D;AAC1D,MAAM,WAAW,qCAAqC;IACpD,4EAA4E;IAC5E,YAAY,EAAE,MAAM,CAAC;IACrB,mFAAmF;IACnF,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,4BAA4B,KAAK,IAAI,CAAC;IAC/D,gFAAgF;IAChF,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,4EAA4E;IAC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etOAuthChannelControlType as r, ToolsetOAuthFailureReason as i, ToolsetOAuthResultType as a } from "./types.js";
|
|
2
|
+
import { getToolsetOAuthBatchChannelName as o, isToolsetOAuthBatchMessage as s } from "./batch-channel.js";
|
|
3
|
+
import { buildToolsetOAuthBatchStep as c, openToolsetOAuthBatchWindow as l } from "./popup.js";
|
|
4
|
+
import { generateUUID as u } from "@epam/ai-dial-chat-shared";
|
|
2
5
|
//#region src/oauth/handshake.ts
|
|
3
|
-
var
|
|
6
|
+
var d = "toolset-oauth-", f = (e) => `${d}${e}`, p = 3e5, m = 500, h = (e) => {
|
|
4
7
|
switch (e) {
|
|
5
|
-
case
|
|
6
|
-
case
|
|
7
|
-
case
|
|
8
|
-
case
|
|
9
|
-
default: return
|
|
8
|
+
case i.MissingCode:
|
|
9
|
+
case i.MissingRedirectState:
|
|
10
|
+
case i.StateMismatch:
|
|
11
|
+
case i.LoginRequestFailed: return e;
|
|
12
|
+
default: return i.LoginRequestFailed;
|
|
10
13
|
}
|
|
11
|
-
},
|
|
12
|
-
let
|
|
13
|
-
let e =
|
|
14
|
-
|
|
14
|
+
}, g = (e) => typeof e == "object" && !!e && "type" in e && (e.type === a.Success || e.type === a.Failure), _ = (e, t, { toolsetId: i, credentialsLevel: o, callbackPath: s, timeoutMs: c = p, pollIntervalMs: l = m }) => new Promise((u) => {
|
|
15
|
+
let d, p = !1, m = () => {
|
|
16
|
+
let e = d;
|
|
17
|
+
d = void 0, e != null && setTimeout(() => e.close(), 0);
|
|
15
18
|
}, _ = (e) => {
|
|
16
|
-
|
|
17
|
-
}, v = (
|
|
18
|
-
|
|
19
|
+
p || (p = !0, clearInterval(x), clearTimeout(S), window.removeEventListener("focus", b), m(), u(e));
|
|
20
|
+
}, v = (t) => {
|
|
21
|
+
d?.postMessage({ type: r.ResultAcknowledged });
|
|
19
22
|
try {
|
|
20
|
-
|
|
23
|
+
e.close();
|
|
21
24
|
} catch {}
|
|
22
|
-
_(
|
|
25
|
+
_(t);
|
|
23
26
|
}, y = () => {
|
|
24
27
|
try {
|
|
25
|
-
let t = new URL(
|
|
26
|
-
if (t.origin !== window.location.origin || t.pathname !==
|
|
27
|
-
let
|
|
28
|
-
if (
|
|
29
|
-
type:
|
|
30
|
-
toolsetId:
|
|
31
|
-
credentialsLevel:
|
|
28
|
+
let t = new URL(e.location.href);
|
|
29
|
+
if (t.origin !== window.location.origin || t.pathname !== s) return null;
|
|
30
|
+
let r = t.searchParams.get(n.Result);
|
|
31
|
+
if (r === a.Success) return {
|
|
32
|
+
type: a.Success,
|
|
33
|
+
toolsetId: i,
|
|
34
|
+
credentialsLevel: o
|
|
32
35
|
};
|
|
33
|
-
if (
|
|
34
|
-
type:
|
|
35
|
-
reason:
|
|
36
|
+
if (r === a.Failure) return {
|
|
37
|
+
type: a.Failure,
|
|
38
|
+
reason: h(t.searchParams.get(n.FailureReason))
|
|
36
39
|
};
|
|
37
40
|
} catch {}
|
|
38
41
|
return null;
|
|
39
42
|
}, b = () => {
|
|
40
|
-
let
|
|
41
|
-
|
|
43
|
+
let t = y();
|
|
44
|
+
t == null ? e.closed && _({ type: a.Cancelled }) : v(t);
|
|
42
45
|
};
|
|
43
46
|
try {
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
d = new BroadcastChannel(f(t)), d.onmessage = (e) => {
|
|
48
|
+
g(e.data) && v(e.data);
|
|
46
49
|
};
|
|
47
50
|
} catch {}
|
|
48
51
|
window.addEventListener("focus", b);
|
|
49
52
|
let x = setInterval(() => {
|
|
50
53
|
let e = y();
|
|
51
54
|
e != null && v(e);
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
},
|
|
55
|
+
}, l), S = setTimeout(() => {
|
|
56
|
+
e.close(), _({ type: a.Cancelled });
|
|
57
|
+
}, c), C = y();
|
|
55
58
|
C != null && v(C);
|
|
56
|
-
})
|
|
59
|
+
}), v = 3e4, y = 1e4, b = 5e3, x = ({ callbackPath: n, onLateSuccess: i, onWindowAvailable: d, readyTimeoutMs: m = v, acceptTimeoutMs: h = y, resultTimeoutMs: _ = p, retryIntervalMs: x = 500, closeGraceMs: S = b }) => {
|
|
60
|
+
let C = u(), w = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Set(), D, O, k, A = 1, j, M = !1, N = () => {
|
|
61
|
+
for (let e of Array.from(E)) e();
|
|
62
|
+
}, P = (e) => {
|
|
63
|
+
try {
|
|
64
|
+
D?.postMessage(e);
|
|
65
|
+
} catch {}
|
|
66
|
+
}, F = (t, n) => {
|
|
67
|
+
n.hasProgress = !0, j != null && P({
|
|
68
|
+
type: e.Progress,
|
|
69
|
+
runId: C,
|
|
70
|
+
windowId: t,
|
|
71
|
+
progress: j
|
|
72
|
+
});
|
|
73
|
+
}, I = (e) => {
|
|
74
|
+
let t = w.get(e);
|
|
75
|
+
t && (t.isReady = !1), O === e && (O = void 0), N();
|
|
76
|
+
}, L = (e, t, n) => new Promise((r) => {
|
|
77
|
+
let i = !1, a = (e) => {
|
|
78
|
+
i || (i = !0, clearTimeout(s), E.delete(o), r(e));
|
|
79
|
+
}, o = () => {
|
|
80
|
+
e() ? a(!0) : t() && a(!1);
|
|
81
|
+
}, s = setTimeout(() => a(!1), n);
|
|
82
|
+
E.add(o), o();
|
|
83
|
+
}), R = (t, n) => {
|
|
84
|
+
let r = w.get(t);
|
|
85
|
+
!r || n < r.minReadyStepId || (O == null ? (O = t, r.isReady = !0, F(t, r), N(), d?.()) : O === t ? (r.isReady = !0, r.hasProgress || F(t, r), N()) : P({
|
|
86
|
+
type: e.Close,
|
|
87
|
+
runId: C,
|
|
88
|
+
windowId: t
|
|
89
|
+
}));
|
|
90
|
+
}, z = (t) => {
|
|
91
|
+
let n = t.data;
|
|
92
|
+
if (!M && s(n, C)) switch (n.type) {
|
|
93
|
+
case e.Ready:
|
|
94
|
+
R(n.windowId, n.lastStepId);
|
|
95
|
+
return;
|
|
96
|
+
case e.Accepted: {
|
|
97
|
+
let e = T.get(n.stepId);
|
|
98
|
+
e && (e.isAccepted = !0), N();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
case e.Released:
|
|
102
|
+
w.has(n.windowId) && I(n.windowId);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
try {
|
|
107
|
+
D = new BroadcastChannel(o(C)), D.onmessage = z;
|
|
108
|
+
} catch {}
|
|
109
|
+
let B = () => {
|
|
110
|
+
k != null && w.get(k)?.proxy.closed && I(k);
|
|
111
|
+
};
|
|
112
|
+
window.addEventListener("focus", B);
|
|
113
|
+
let V = (e, t) => {
|
|
114
|
+
try {
|
|
115
|
+
let n = new BroadcastChannel(f(t));
|
|
116
|
+
n.onmessage = (t) => {
|
|
117
|
+
g(t.data) && (n.postMessage({ type: r.ResultAcknowledged }), e.isLost ? t.data.type === a.Success && !e.hasLateSuccess && (e.hasLateSuccess = !0, i?.({
|
|
118
|
+
toolsetId: e.toolsetId,
|
|
119
|
+
credentialsLevel: e.credentialsLevel
|
|
120
|
+
})) : (e.result ??= t.data, N()));
|
|
121
|
+
}, e.channel = n;
|
|
122
|
+
} catch {}
|
|
123
|
+
}, H = (e, n) => (e.isLost = !0, I(n), { type: t.WindowLost });
|
|
124
|
+
return {
|
|
125
|
+
runId: C,
|
|
126
|
+
hasWindow: () => !M && O != null,
|
|
127
|
+
openWindow: () => {
|
|
128
|
+
if (M) return !1;
|
|
129
|
+
let t = u(), r = l(n, C, t);
|
|
130
|
+
return r != null && (O != null && P({
|
|
131
|
+
type: e.Close,
|
|
132
|
+
runId: C,
|
|
133
|
+
windowId: O
|
|
134
|
+
}), w.set(t, {
|
|
135
|
+
proxy: r,
|
|
136
|
+
minReadyStepId: 0,
|
|
137
|
+
isReady: !1,
|
|
138
|
+
hasProgress: !1
|
|
139
|
+
}), O = t, N(), !0);
|
|
140
|
+
},
|
|
141
|
+
showProgress: (e) => {
|
|
142
|
+
j = e;
|
|
143
|
+
let t = O == null ? void 0 : w.get(O);
|
|
144
|
+
O != null && t != null && (F(O, t), t.hasProgress = t.isReady);
|
|
145
|
+
},
|
|
146
|
+
runStep: async ({ auth: r, toolsetId: i, credentialsLevel: o, resourceKind: s, offlineUsageConsent: l }) => {
|
|
147
|
+
let u = { type: t.Stopped };
|
|
148
|
+
if (M) return u;
|
|
149
|
+
let d = O, f = d == null ? void 0 : w.get(d);
|
|
150
|
+
if (d == null || f == null || D == null) return { type: t.WindowLost };
|
|
151
|
+
let p = () => M || O !== d, g = await L(() => f.isReady && O === d, p, m);
|
|
152
|
+
if (M) return u;
|
|
153
|
+
if (!g) return I(d), { type: t.WindowLost };
|
|
154
|
+
let v = A++, y = c({
|
|
155
|
+
auth: r,
|
|
156
|
+
toolsetId: i,
|
|
157
|
+
callbackPath: n,
|
|
158
|
+
credentialsLevel: o,
|
|
159
|
+
resourceKind: s,
|
|
160
|
+
offlineUsageConsent: l,
|
|
161
|
+
batch: {
|
|
162
|
+
runId: C,
|
|
163
|
+
windowId: d,
|
|
164
|
+
stepId: v
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
if (y == null) return { type: t.InvalidConfig };
|
|
168
|
+
let b = {
|
|
169
|
+
stepId: v,
|
|
170
|
+
toolsetId: i,
|
|
171
|
+
credentialsLevel: o,
|
|
172
|
+
isAccepted: !1,
|
|
173
|
+
isLost: !1,
|
|
174
|
+
hasLateSuccess: !1
|
|
175
|
+
};
|
|
176
|
+
T.set(v, b), V(b, y.flowId);
|
|
177
|
+
let S = () => P({
|
|
178
|
+
type: e.Navigate,
|
|
179
|
+
runId: C,
|
|
180
|
+
windowId: d,
|
|
181
|
+
stepId: v,
|
|
182
|
+
url: y.url,
|
|
183
|
+
redirectState: y.redirectState
|
|
184
|
+
});
|
|
185
|
+
S();
|
|
186
|
+
let E = setInterval(S, x), j = await L(() => b.isAccepted || b.result != null, p, h);
|
|
187
|
+
if (clearInterval(E), M) return u;
|
|
188
|
+
if (!j) return H(b, d);
|
|
189
|
+
f.isReady = !1, f.hasProgress = !1, f.minReadyStepId = v, k = d;
|
|
190
|
+
let N = await L(() => b.result != null, p, _);
|
|
191
|
+
if (k = void 0, M) return u;
|
|
192
|
+
let { result: F } = b;
|
|
193
|
+
return !N || F == null ? H(b, d) : F.type === a.Success ? { type: t.Success } : {
|
|
194
|
+
type: t.Failure,
|
|
195
|
+
reason: F.reason
|
|
196
|
+
};
|
|
197
|
+
},
|
|
198
|
+
close: () => {
|
|
199
|
+
if (M) return;
|
|
200
|
+
M = !0, P({
|
|
201
|
+
type: e.Close,
|
|
202
|
+
runId: C
|
|
203
|
+
});
|
|
204
|
+
for (let { proxy: e } of w.values()) try {
|
|
205
|
+
e.close();
|
|
206
|
+
} catch {}
|
|
207
|
+
window.removeEventListener("focus", B), O = void 0, N();
|
|
208
|
+
let t = D;
|
|
209
|
+
t && (t.onmessage = (n) => {
|
|
210
|
+
let r = n.data;
|
|
211
|
+
s(r, C) && r.type === e.Ready && t.postMessage({
|
|
212
|
+
type: e.Close,
|
|
213
|
+
runId: C,
|
|
214
|
+
windowId: r.windowId
|
|
215
|
+
});
|
|
216
|
+
}, setTimeout(() => {
|
|
217
|
+
D = void 0, t.close();
|
|
218
|
+
}, S));
|
|
219
|
+
let n = Array.from(T.values(), (e) => e.channel);
|
|
220
|
+
setTimeout(() => {
|
|
221
|
+
for (let e of n) e?.close();
|
|
222
|
+
}, 0);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
};
|
|
57
226
|
//#endregion
|
|
58
|
-
export {
|
|
227
|
+
export { x as createToolsetOAuthBatchSession, f as getToolsetOAuthChannelName, _ as waitForToolsetOAuthResult };
|
package/oauth/models.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OAuthResourceKind, ToolsetCredentialsLevel, ToolsetOAuthChannelControlType, ToolsetOAuthFailureReason, ToolsetOAuthInitiationResultType, ToolsetOAuthResultType } from './types';
|
|
1
|
+
import { OAuthResourceKind, ToolsetCredentialsLevel, ToolsetOAuthBatchMessageType, ToolsetOAuthBatchStepOutcomeType, ToolsetOAuthBatchWindowPhase, ToolsetOAuthChannelControlType, ToolsetOAuthFailureReason, ToolsetOAuthInitiationResultType, ToolsetOAuthResultType } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* OAuth client settings needed to build an authorize URL — the narrow subset
|
|
4
4
|
* of a toolset's `authSettings` this module reads. Declared as its own shape
|
|
@@ -70,6 +70,95 @@ export interface ToolsetRedirectState {
|
|
|
70
70
|
* route has no other way to learn it. Absent means "not granted".
|
|
71
71
|
*/
|
|
72
72
|
offlineUsageConsent?: boolean;
|
|
73
|
+
/** Bulk sign-in step this flow belongs to; absent for a single login. */
|
|
74
|
+
batch?: ToolsetOAuthBatchCorrelation;
|
|
75
|
+
}
|
|
76
|
+
/** Non-secret ids that tie one OAuth flow to a bulk sign-in run, its window and its step. */
|
|
77
|
+
export interface ToolsetOAuthBatchCorrelation {
|
|
78
|
+
/** Random id of the run. */
|
|
79
|
+
runId: string;
|
|
80
|
+
/** Random id of the window within the run. */
|
|
81
|
+
windowId: string;
|
|
82
|
+
/** Step number within the run; strictly increasing. */
|
|
83
|
+
stepId: number;
|
|
84
|
+
}
|
|
85
|
+
/** Upcoming target a bulk sign-in window shows. */
|
|
86
|
+
export interface ToolsetOAuthBatchProgress {
|
|
87
|
+
/** Display name of the target. */
|
|
88
|
+
name: string;
|
|
89
|
+
/** One-based position of the target in the run. */
|
|
90
|
+
position: number;
|
|
91
|
+
/** Number of targets in the run. */
|
|
92
|
+
total: number;
|
|
93
|
+
}
|
|
94
|
+
/** What a waiting bulk sign-in window shows. */
|
|
95
|
+
export interface ToolsetOAuthBatchWindowState {
|
|
96
|
+
/** Whether the window waits for a command or has gone idle. */
|
|
97
|
+
phase: ToolsetOAuthBatchWindowPhase;
|
|
98
|
+
/** Upcoming target, once the run has sent one. */
|
|
99
|
+
progress?: ToolsetOAuthBatchProgress;
|
|
100
|
+
}
|
|
101
|
+
/** One provider step built by the initiating tab for a bulk sign-in window. */
|
|
102
|
+
export interface ToolsetOAuthBatchStep {
|
|
103
|
+
/** OAuth `state` of the step; names its result channel. */
|
|
104
|
+
flowId: string;
|
|
105
|
+
/** Provider authorize URL. */
|
|
106
|
+
url: string;
|
|
107
|
+
/** Redirect state the window stores before navigating. */
|
|
108
|
+
redirectState: ToolsetRedirectState;
|
|
109
|
+
}
|
|
110
|
+
/** Message on a bulk sign-in run's window channel. */
|
|
111
|
+
export type ToolsetOAuthBatchMessage = {
|
|
112
|
+
type: ToolsetOAuthBatchMessageType.Ready;
|
|
113
|
+
runId: string;
|
|
114
|
+
windowId: string;
|
|
115
|
+
lastStepId: number;
|
|
116
|
+
} | {
|
|
117
|
+
type: ToolsetOAuthBatchMessageType.Navigate;
|
|
118
|
+
runId: string;
|
|
119
|
+
windowId: string;
|
|
120
|
+
stepId: number;
|
|
121
|
+
url: string;
|
|
122
|
+
redirectState: ToolsetRedirectState;
|
|
123
|
+
} | {
|
|
124
|
+
type: ToolsetOAuthBatchMessageType.Accepted;
|
|
125
|
+
runId: string;
|
|
126
|
+
windowId: string;
|
|
127
|
+
stepId: number;
|
|
128
|
+
} | {
|
|
129
|
+
type: ToolsetOAuthBatchMessageType.Progress;
|
|
130
|
+
runId: string;
|
|
131
|
+
windowId: string;
|
|
132
|
+
progress: ToolsetOAuthBatchProgress;
|
|
133
|
+
} | {
|
|
134
|
+
type: ToolsetOAuthBatchMessageType.Close;
|
|
135
|
+
runId: string;
|
|
136
|
+
/** Window to close; every window of the run when absent. */
|
|
137
|
+
windowId?: string;
|
|
138
|
+
} | {
|
|
139
|
+
type: ToolsetOAuthBatchMessageType.Released;
|
|
140
|
+
runId: string;
|
|
141
|
+
windowId: string;
|
|
142
|
+
};
|
|
143
|
+
/** Outcome of `ToolsetOAuthBatchSession.runStep`. */
|
|
144
|
+
export type ToolsetOAuthBatchStepOutcome = {
|
|
145
|
+
type: ToolsetOAuthBatchStepOutcomeType.Success;
|
|
146
|
+
} | {
|
|
147
|
+
type: ToolsetOAuthBatchStepOutcomeType.Failure;
|
|
148
|
+
reason: ToolsetOAuthFailureReason;
|
|
149
|
+
} | {
|
|
150
|
+
type: ToolsetOAuthBatchStepOutcomeType.WindowLost;
|
|
151
|
+
} | {
|
|
152
|
+
type: ToolsetOAuthBatchStepOutcomeType.InvalidConfig;
|
|
153
|
+
} | {
|
|
154
|
+
type: ToolsetOAuthBatchStepOutcomeType.Stopped;
|
|
155
|
+
};
|
|
156
|
+
/** A success that arrived after its step had already resolved as lost. */
|
|
157
|
+
export interface ToolsetOAuthBatchLateSuccess {
|
|
158
|
+
/** Resource id of the step. */
|
|
159
|
+
toolsetId: string;
|
|
160
|
+
/** Credentials level of the step. */
|
|
161
|
+
credentialsLevel: ToolsetCredentialsLevel;
|
|
73
162
|
}
|
|
74
163
|
export type ToolsetOAuthInitiationResult = {
|
|
75
164
|
type: ToolsetOAuthInitiationResultType.Started;
|
package/oauth/models.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/oauth/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,uBAAuB,EACvB,8BAA8B,EAC9B,yBAAyB,EACzB,gCAAgC,EAChC,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAEjB;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,0BAA0B;IACzC,uBAAuB;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,qBAAqB,CAAC,EAAE,MAAM,CAAC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ToolsetOAuthBatchCorrelation, ToolsetOAuthBatchStep, ToolsetOAuthInitiationResult, ToolsetOAuthSettings } from './models';
|
|
2
2
|
import { OAuthResourceKind, ToolsetCredentialsLevel } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Opens a same-origin, blank popup synchronously — call this as the very
|
|
@@ -27,4 +27,38 @@ export declare const navigateToolsetOAuthPopup: (popup: Window, auth: ToolsetOAu
|
|
|
27
27
|
* already open.
|
|
28
28
|
*/
|
|
29
29
|
export declare const initiateOAuthLogin: (auth: ToolsetOAuthSettings, toolsetId: string, callbackPath: string, credentialsLevel?: ToolsetCredentialsLevel, offlineUsageConsent?: boolean) => ToolsetOAuthInitiationResult;
|
|
30
|
+
/** Returns the same-origin callback URL a bulk sign-in window waits on for its run's commands. */
|
|
31
|
+
export declare const getToolsetOAuthBatchWindowUrl: (callbackPath: string, runId: string, windowId: string) => string;
|
|
32
|
+
/**
|
|
33
|
+
* Opens a bulk sign-in window synchronously — call it before any `await` in
|
|
34
|
+
* the click handler — and points it at the waiting callback page. Returns
|
|
35
|
+
* `null` when the browser blocks it. The window never keeps an opener: it
|
|
36
|
+
* receives its commands over the run's channel, and a provider it later
|
|
37
|
+
* navigates to must not reach the initiating tab.
|
|
38
|
+
*/
|
|
39
|
+
export declare const openToolsetOAuthBatchWindow: (callbackPath: string, runId: string, windowId: string) => Window | null;
|
|
40
|
+
/** Parameters for {@link buildToolsetOAuthBatchStep}. */
|
|
41
|
+
export interface BuildToolsetOAuthBatchStepParams {
|
|
42
|
+
/** OAuth client settings of the target. */
|
|
43
|
+
auth: ToolsetOAuthSettings;
|
|
44
|
+
/** Resource id stored in the redirect state. */
|
|
45
|
+
toolsetId: string;
|
|
46
|
+
/** The host's OAuth callback route. */
|
|
47
|
+
callbackPath: string;
|
|
48
|
+
/** Credentials level the step signs in at. */
|
|
49
|
+
credentialsLevel: ToolsetCredentialsLevel;
|
|
50
|
+
/** Resource kind stored in the redirect state. Defaults to `Toolset`. */
|
|
51
|
+
resourceKind?: OAuthResourceKind;
|
|
52
|
+
/** Offline-use consent stored in the redirect state. */
|
|
53
|
+
offlineUsageConsent?: boolean;
|
|
54
|
+
/** Run, window and step the flow belongs to. */
|
|
55
|
+
batch: ToolsetOAuthBatchCorrelation;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Builds one bulk sign-in step in the initiating tab: a fresh OAuth `state`,
|
|
59
|
+
* the provider authorize URL and the redirect state the window stores before
|
|
60
|
+
* navigating. Returns `null` when the OAuth configuration cannot produce an
|
|
61
|
+
* authorize URL.
|
|
62
|
+
*/
|
|
63
|
+
export declare const buildToolsetOAuthBatchStep: ({ auth, toolsetId, callbackPath, credentialsLevel, resourceKind, offlineUsageConsent, batch, }: BuildToolsetOAuthBatchStepParams) => ToolsetOAuthBatchStep | null;
|
|
30
64
|
//# sourceMappingURL=popup.d.ts.map
|
package/oauth/popup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popup.d.ts","sourceRoot":"","sources":["../../src/oauth/popup.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,4BAA4B,EAC5B,oBAAoB,EAErB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"popup.d.ts","sourceRoot":"","sources":["../../src/oauth/popup.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,4BAA4B,EAC5B,qBAAqB,EACrB,4BAA4B,EAC5B,oBAAoB,EAErB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EAGxB,MAAM,SAAS,CAAC;AA8CjB;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,QAAO,MAAM,GAAG,IACvB,CAAC;AAE5B;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GACpC,OAAO,MAAM,EACb,MAAM,oBAAoB,EAC1B,WAAW,MAAM,EACjB,cAAc,MAAM,EACpB,mBAAkB,uBAAsD,EACxE,eAAc,iBAA6C,EAC3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