@epam/ai-dial-chat-hooks 1.1.0-dev.393 → 1.1.0-dev.396

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epam/ai-dial-chat-hooks",
3
3
  "description": "Framework-level React hooks extracted from AI DIAL Chat for building custom chat interfaces",
4
- "version": "1.1.0-dev.393",
4
+ "version": "1.1.0-dev.396",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -87,20 +87,20 @@
87
87
  },
88
88
  "peerDependencies": {
89
89
  "react": "^19.2.6",
90
- "@epam/ai-dial-attachment-canvas": "1.1.0-dev.393",
91
- "@epam/ai-dial-attachment-input": "1.1.0-dev.393",
92
- "@epam/ai-dial-catalog": "1.1.0-dev.393",
93
- "@epam/ai-dial-chat-api-client": "1.1.0-dev.393",
94
- "@epam/ai-dial-chat-overlay": "1.1.0-dev.393",
95
- "@epam/ai-dial-chat-shared": "1.1.0-dev.393",
96
- "@epam/ai-dial-deployment-creation-form": "1.1.0-dev.393",
97
- "@epam/ai-dial-publish-panel": "1.1.0-dev.393",
98
- "@epam/ai-dial-quotations": "1.1.0-dev.393",
90
+ "@epam/ai-dial-attachment-canvas": "1.1.0-dev.396",
91
+ "@epam/ai-dial-attachment-input": "1.1.0-dev.396",
92
+ "@epam/ai-dial-catalog": "1.1.0-dev.396",
93
+ "@epam/ai-dial-chat-api-client": "1.1.0-dev.396",
94
+ "@epam/ai-dial-chat-overlay": "1.1.0-dev.396",
95
+ "@epam/ai-dial-chat-shared": "1.1.0-dev.396",
96
+ "@epam/ai-dial-deployment-creation-form": "1.1.0-dev.396",
97
+ "@epam/ai-dial-publish-panel": "1.1.0-dev.396",
98
+ "@epam/ai-dial-quotations": "1.1.0-dev.396",
99
99
  "@epam/ai-dial-react-file-manager": "*",
100
- "@epam/ai-dial-scheduled-tasks": "1.1.0-dev.393",
101
- "@epam/ai-dial-share": "1.1.0-dev.393",
102
- "@epam/ai-dial-skill-editor": "1.1.0-dev.393",
103
- "@epam/ai-dial-source-panel": "1.1.0-dev.393",
100
+ "@epam/ai-dial-scheduled-tasks": "1.1.0-dev.396",
101
+ "@epam/ai-dial-share": "1.1.0-dev.396",
102
+ "@epam/ai-dial-skill-editor": "1.1.0-dev.396",
103
+ "@epam/ai-dial-source-panel": "1.1.0-dev.396",
104
104
  "@epam/ai-dial-ui-kit": "*",
105
105
  "@epam/pdf-highlighter-kit": ">=0.0.14"
106
106
  },
@@ -0,0 +1,93 @@
1
+ import { _ as e, c as t, g as n, p as r, v as i, x as a, y as o } from "./useToolsetLogin-B05m134e.js";
2
+ import { useEffect as s, useRef as c, useState as l } from "react";
3
+ //#region src/oauth/useOAuthCallbackCompletion/useOAuthCallbackCompletion.ts
4
+ var u = 500, d = (e) => typeof e == "object" && !!e && "type" in e && e.type === i.ResultAcknowledged, f = () => {
5
+ let e = sessionStorage.getItem(r);
6
+ if (!e) return null;
7
+ try {
8
+ return JSON.parse(e);
9
+ } catch {
10
+ return null;
11
+ }
12
+ }, p = (e) => {
13
+ try {
14
+ window.history.replaceState({}, document.title, `${e.pathname}${e.search}`);
15
+ } catch {}
16
+ }, m = (n, r) => {
17
+ let i = new URL(window.location.pathname, window.location.origin);
18
+ if (i.searchParams.set(e.Result, r.type), r.type === a.Failure && i.searchParams.set(e.FailureReason, r.reason), p(i), !n) {
19
+ window.close();
20
+ return;
21
+ }
22
+ try {
23
+ let e = new BroadcastChannel(t(n));
24
+ e.postMessage(r);
25
+ let i = setInterval(() => {
26
+ e.postMessage(r);
27
+ }, u);
28
+ e.onmessage = (t) => {
29
+ d(t.data) && (clearInterval(i), e.close(), window.close());
30
+ };
31
+ } catch {}
32
+ }, h = ({ searchParams: e, callbackPath: t, exchange: i }) => {
33
+ let [u, d] = l(!0), [h, g] = l(null), _ = c(!1), v = c(i);
34
+ v.current = i;
35
+ let y = c(t);
36
+ return y.current = t, s(() => {
37
+ if (_.current) return;
38
+ _.current = !0;
39
+ let t = (e, t) => {
40
+ m(e, t), d(!1), g(t.type === a.Failure ? t.reason : null);
41
+ };
42
+ (async () => {
43
+ let i = e.get("code"), s = e.get("state"), c = f();
44
+ sessionStorage.removeItem(r);
45
+ let l = c?.state ?? s ?? void 0;
46
+ if (p(new URL(window.location.pathname, window.location.origin)), !i || !c?.toolsetId) {
47
+ t(l, {
48
+ type: a.Failure,
49
+ reason: c?.toolsetId ? o.MissingCode : o.MissingRedirectState
50
+ });
51
+ return;
52
+ }
53
+ if (c.state != null && c.state !== s) {
54
+ t(l, {
55
+ type: a.Failure,
56
+ reason: o.StateMismatch
57
+ });
58
+ return;
59
+ }
60
+ let u = c.credentialsLevel ?? n.User, d = c.redirectUri ?? `${window.location.origin}${y.current}`;
61
+ try {
62
+ let e = await v.current({
63
+ code: i,
64
+ redirectUri: d,
65
+ credentialsLevel: u,
66
+ redirectState: c
67
+ });
68
+ if (e != null) {
69
+ t(l, {
70
+ type: a.Failure,
71
+ reason: e
72
+ });
73
+ return;
74
+ }
75
+ t(l, {
76
+ type: a.Success,
77
+ toolsetId: c.toolsetId,
78
+ credentialsLevel: u
79
+ });
80
+ } catch {
81
+ t(l, {
82
+ type: a.Failure,
83
+ reason: o.LoginRequestFailed
84
+ });
85
+ }
86
+ })();
87
+ }, [e]), {
88
+ isInProgress: u,
89
+ failureReason: h
90
+ };
91
+ };
92
+ //#endregion
93
+ export { h as t };