@epam/ai-dial-chat-hooks 1.3.0-dev.296 → 1.3.0-dev.304
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/catalog/application-credentials.d.ts.map +1 -1
- package/catalog/application-credentials.js +20 -25
- package/catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.d.ts.map +1 -1
- package/catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.js +72 -77
- package/conversation/useConversationScroll/useConversationScroll.d.ts.map +1 -1
- package/conversation/useConversationScroll/useConversationScroll.js +64 -63
- package/external-services/useExternalServiceLogin.d.ts +3 -13
- package/external-services/useExternalServiceLogin.d.ts.map +1 -1
- package/external-services/useExternalServiceLogin.js +49 -58
- package/index.js +168 -168
- package/mcp-apps/useMcpAppTools/useMcpAppTools.d.ts.map +1 -1
- package/mcp-apps/useMcpAppTools/useMcpAppTools.js +42 -39
- package/oauth/authorize-url.d.ts +7 -1
- package/oauth/authorize-url.d.ts.map +1 -1
- package/oauth/authorize-url.js +13 -3
- package/oauth/models.d.ts +25 -0
- package/oauth/models.d.ts.map +1 -1
- package/oauth/useToolsetLogin/useToolsetLogin.d.ts.map +1 -1
- package/oauth/useToolsetLogin/useToolsetLogin.js +45 -56
- package/oauth.js +7 -7
- package/package.json +17 -17
|
@@ -1,88 +1,79 @@
|
|
|
1
|
-
import { OAuthResourceKind as e,
|
|
2
|
-
import { waitForToolsetOAuthResult as
|
|
3
|
-
import { navigateToolsetOAuthPopup as
|
|
4
|
-
import { OfflineCredentialsLoginOutcomeType as
|
|
5
|
-
import { buildExternalServiceScopeId as
|
|
6
|
-
import { useCallback as
|
|
1
|
+
import { OAuthResourceKind as e, ToolsetCredentialsLevel as t, ToolsetOAuthInitiationResultType as n, ToolsetOAuthResultType as r } from "../oauth/types.js";
|
|
2
|
+
import { waitForToolsetOAuthResult as i } from "../oauth/handshake.js";
|
|
3
|
+
import { navigateToolsetOAuthPopup as a, openToolsetOAuthPopup as o } from "../oauth/popup.js";
|
|
4
|
+
import { OfflineCredentialsLoginOutcomeType as s } from "../offline-credentials/useOfflineCredentialsLogin/useOfflineCredentialsLogin.js";
|
|
5
|
+
import { buildExternalServiceScopeId as c } from "../shared/external-services.js";
|
|
6
|
+
import { useCallback as l } from "react";
|
|
7
7
|
//#region src/external-services/useExternalServiceLogin.ts
|
|
8
|
-
var
|
|
8
|
+
var u = /* @__PURE__ */ function(e) {
|
|
9
9
|
return e.None = "NONE", e.ApiKey = "API_KEY", e.OAuth = "OAUTH", e.DialNative = "DIAL_NATIVE", e;
|
|
10
|
-
}({}),
|
|
10
|
+
}({}), d = /* @__PURE__ */ function(e) {
|
|
11
11
|
return e.SignedIn = "SIGNED_IN", e.SignedOut = "SIGNED_OUT", e.Failed = "FAILED", e;
|
|
12
|
-
}({}),
|
|
12
|
+
}({}), f = /* @__PURE__ */ function(e) {
|
|
13
13
|
return e.Global = "GLOBAL", e.Application = "APPLICATION", e.User = "USER", e;
|
|
14
|
-
}({}),
|
|
14
|
+
}({}), p = /* @__PURE__ */ function(e) {
|
|
15
15
|
return e.Success = "success", e.Failure = "failure", e.PopupBlocked = "popup-blocked", e.Cancelled = "cancelled", e.AdminConsentRequired = "admin-consent-required", e.OfflineUnavailable = "offline-unavailable", e;
|
|
16
|
-
}({}),
|
|
17
|
-
let
|
|
18
|
-
let r = n ??
|
|
16
|
+
}({}), m = (e) => e === "GLOBAL" ? t.Global : t.User, h = ({ callbackPath: t, getExternalService: u, signInExternalService: d, signOutExternalService: f, getOfflineCredentials: p, loginOfflineCredentials: h }) => {
|
|
17
|
+
let g = l(async ({ appId: e, serviceId: t, popup: n }) => {
|
|
18
|
+
let r = n ?? o();
|
|
19
19
|
if (!r) return { type: "popup-blocked" };
|
|
20
20
|
try {
|
|
21
|
-
let n = await
|
|
21
|
+
let n = await u(e, t);
|
|
22
22
|
if (n.appLevelAuthStatus !== "SIGNED_IN") return r.close(), { type: n.appLevelAuthStatus === "SIGNED_OUT" ? "admin-consent-required" : "failure" };
|
|
23
|
-
let i = await
|
|
23
|
+
let i = await p();
|
|
24
24
|
if (i.connected) return r.close(), { type: "success" };
|
|
25
25
|
if (!i.available || !i.connect) return r.close(), { type: "offline-unavailable" };
|
|
26
|
-
let a = await
|
|
27
|
-
if (a.type ===
|
|
28
|
-
let n = await
|
|
26
|
+
let a = await h(i.connect, p, r);
|
|
27
|
+
if (a.type === s.Success) {
|
|
28
|
+
let n = await u(e, t);
|
|
29
29
|
return { type: n.appLevelAuthStatus === "SIGNED_IN" ? "success" : n.appLevelAuthStatus === "SIGNED_OUT" ? "admin-consent-required" : "failure" };
|
|
30
30
|
}
|
|
31
|
-
return a.type ===
|
|
31
|
+
return a.type === s.Cancelled ? { type: "cancelled" } : { type: "failure" };
|
|
32
32
|
} catch {
|
|
33
33
|
return r.close(), { type: "failure" };
|
|
34
34
|
}
|
|
35
35
|
}, [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
]),
|
|
36
|
+
h,
|
|
37
|
+
u,
|
|
38
|
+
p
|
|
39
|
+
]), _ = l(async (e, t, n, r) => {
|
|
40
40
|
try {
|
|
41
|
-
await
|
|
41
|
+
await f(e, t, {
|
|
42
42
|
credentialsLevel: n,
|
|
43
43
|
authenticationType: r
|
|
44
44
|
});
|
|
45
45
|
} catch {}
|
|
46
|
-
}, [
|
|
47
|
-
let { appId:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
isLoggedIn: !1,
|
|
51
|
-
clientId: h?.clientId,
|
|
52
|
-
authorizationEndpoint: h?.authorizationEndpoint,
|
|
53
|
-
scopes: h?.scopes,
|
|
54
|
-
codeChallenge: h?.codeChallenge,
|
|
55
|
-
codeChallengeMethod: h?.codeChallengeMethod
|
|
56
|
-
}, w = b ?? c();
|
|
57
|
-
if (!w) return { type: "popup-blocked" };
|
|
58
|
-
_ && await y(d, p, m, "OAUTH");
|
|
46
|
+
}, [f]), v = l(async (s) => {
|
|
47
|
+
let { appId: l, serviceId: d, credentialsLevel: f, oauthSettings: p, forceStale: h, offlineUsageConsent: g, popup: v } = s, y = c(l, d), b = m(f), x = v ?? o();
|
|
48
|
+
if (!x) return { type: "popup-blocked" };
|
|
49
|
+
h && await _(l, d, f, "OAUTH");
|
|
59
50
|
try {
|
|
60
|
-
let
|
|
61
|
-
if (
|
|
62
|
-
let
|
|
63
|
-
toolsetId:
|
|
64
|
-
credentialsLevel:
|
|
65
|
-
callbackPath:
|
|
51
|
+
let o = a(x, p ?? {}, y, t, b, e.ExternalService, g);
|
|
52
|
+
if (o.type !== n.Started) return { type: "failure" };
|
|
53
|
+
let s = await i(o.popup, o.flowId, {
|
|
54
|
+
toolsetId: y,
|
|
55
|
+
credentialsLevel: b,
|
|
56
|
+
callbackPath: t
|
|
66
57
|
});
|
|
67
|
-
if (
|
|
68
|
-
if (
|
|
58
|
+
if (s.type === r.Success) return { type: "success" };
|
|
59
|
+
if (s.type === r.Failure) return { type: "failure" };
|
|
69
60
|
try {
|
|
70
|
-
let e = await
|
|
71
|
-
if ((
|
|
61
|
+
let e = await u(l, d);
|
|
62
|
+
if ((f === "USER" ? e.userLevelAuthStatus : e.globalAuthStatus) === "SIGNED_IN") return { type: "success" };
|
|
72
63
|
} catch {}
|
|
73
64
|
return { type: "cancelled" };
|
|
74
65
|
} catch {
|
|
75
|
-
return
|
|
66
|
+
return x.close(), { type: "failure" };
|
|
76
67
|
}
|
|
77
68
|
}, [
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
]),
|
|
69
|
+
_,
|
|
70
|
+
t,
|
|
71
|
+
u
|
|
72
|
+
]), y = l(async (e) => {
|
|
82
73
|
let { appId: t, serviceId: n, credentialsLevel: r, authenticationType: i, apiKey: a, forceStale: o, offlineUsageConsent: s } = e;
|
|
83
74
|
if (i === "DIAL_NATIVE") return { type: "failure" };
|
|
84
75
|
try {
|
|
85
|
-
return o && await
|
|
76
|
+
return o && await _(t, n, r, i), await d(t, n, {
|
|
86
77
|
credentialsLevel: r,
|
|
87
78
|
authenticationType: i,
|
|
88
79
|
apiKey: a?.trim(),
|
|
@@ -91,12 +82,12 @@ var f = /* @__PURE__ */ function(e) {
|
|
|
91
82
|
} catch {
|
|
92
83
|
return { type: "failure" };
|
|
93
84
|
}
|
|
94
|
-
}, [
|
|
95
|
-
return { login:
|
|
85
|
+
}, [_, d]);
|
|
86
|
+
return { login: l((e) => e.authenticationType === "DIAL_NATIVE" ? g(e) : e.authenticationType === "OAUTH" ? v(e) : y(e), [
|
|
87
|
+
g,
|
|
96
88
|
v,
|
|
97
|
-
|
|
98
|
-
x
|
|
89
|
+
y
|
|
99
90
|
]) };
|
|
100
91
|
};
|
|
101
92
|
//#endregion
|
|
102
|
-
export {
|
|
93
|
+
export { d as ExternalServiceAuthStatus, u as ExternalServiceAuthType, f as ExternalServiceCredentialsLevel, p as ExternalServiceLoginOutcomeType, h as useExternalServiceLogin };
|