@thoughtspot/visual-embed-sdk 1.11.0-alpha.0 → 1.11.0-auth.10
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/dist/src/auth.d.ts +7 -5
- package/dist/src/embed/base.d.ts +5 -4
- package/dist/src/embed/pinboard.d.ts +91 -0
- package/dist/src/embed/ts-embed.d.ts +1 -0
- package/dist/src/index.d.ts +2 -2
- package/dist/src/types.d.ts +5 -0
- package/dist/src/utils/authService.d.ts +1 -0
- package/dist/src/utils/plugin.d.ts +0 -0
- package/dist/src/v1/api.d.ts +19 -0
- package/dist/tsembed.es.js +78 -17
- package/dist/tsembed.js +78 -16
- package/lib/package.json +1 -1
- package/lib/src/auth.d.ts +7 -5
- package/lib/src/auth.js +37 -7
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.js +16 -11
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/embed/base.d.ts +5 -4
- package/lib/src/embed/base.js +4 -1
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +1 -1
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/pinboard.d.ts +91 -0
- package/lib/src/embed/pinboard.js +110 -0
- package/lib/src/embed/pinboard.js.map +1 -0
- package/lib/src/embed/ts-embed.d.ts +1 -0
- package/lib/src/embed/ts-embed.js +16 -6
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +16 -6
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/index.d.ts +2 -2
- package/lib/src/index.js +2 -2
- package/lib/src/index.js.map +1 -1
- package/lib/src/test/test-utils.js +1 -1
- package/lib/src/test/test-utils.js.map +1 -1
- package/lib/src/types.d.ts +5 -0
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/authService.d.ts +1 -0
- package/lib/src/utils/authService.js +21 -3
- package/lib/src/utils/authService.js.map +1 -1
- package/lib/src/utils/authService.spec.js +11 -5
- package/lib/src/utils/authService.spec.js.map +1 -1
- package/lib/src/utils/plugin.d.ts +0 -0
- package/lib/src/utils/plugin.js +1 -0
- package/lib/src/utils/plugin.js.map +1 -0
- package/lib/src/visual-embed-sdk.d.ts +12 -6
- package/package.json +1 -1
- package/src/auth.spec.ts +24 -11
- package/src/auth.ts +51 -11
- package/src/embed/base.spec.ts +1 -1
- package/src/embed/base.ts +9 -5
- package/src/embed/ts-embed.spec.ts +19 -9
- package/src/embed/ts-embed.ts +18 -6
- package/src/index.ts +2 -1
- package/src/test/test-utils.ts +1 -1
- package/src/types.ts +6 -0
- package/src/utils/authService.spec.ts +18 -5
- package/src/utils/authService.ts +28 -3
package/src/utils/authService.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-cycle
|
|
2
2
|
import { EndPoints } from '../auth';
|
|
3
3
|
|
|
4
|
+
function failureLoggedFetch(
|
|
5
|
+
url: string,
|
|
6
|
+
options: RequestInit = {},
|
|
7
|
+
): Promise<Response> {
|
|
8
|
+
return fetch(url, options).then(async (r) => {
|
|
9
|
+
if (!r.ok && r.type !== 'opaqueredirect') {
|
|
10
|
+
console.error('Failure', await r.text());
|
|
11
|
+
}
|
|
12
|
+
return r;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
4
16
|
export function fetchSessionInfoService(
|
|
5
17
|
authVerificationUrl: string,
|
|
6
18
|
): Promise<any> {
|
|
7
|
-
return
|
|
19
|
+
return failureLoggedFetch(authVerificationUrl, {
|
|
8
20
|
credentials: 'include',
|
|
9
21
|
});
|
|
10
22
|
}
|
|
@@ -20,10 +32,12 @@ export async function fetchAuthService(
|
|
|
20
32
|
username: string,
|
|
21
33
|
authToken: string,
|
|
22
34
|
): Promise<any> {
|
|
23
|
-
return
|
|
35
|
+
return failureLoggedFetch(
|
|
24
36
|
`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`,
|
|
25
37
|
{
|
|
26
38
|
credentials: 'include',
|
|
39
|
+
// We do not want to follow the redirect, as it starts giving a CORS error
|
|
40
|
+
redirect: 'manual',
|
|
27
41
|
},
|
|
28
42
|
);
|
|
29
43
|
}
|
|
@@ -33,7 +47,7 @@ export async function fetchBasicAuthService(
|
|
|
33
47
|
username: string,
|
|
34
48
|
password: string,
|
|
35
49
|
): Promise<any> {
|
|
36
|
-
return
|
|
50
|
+
return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.BASIC_LOGIN}`, {
|
|
37
51
|
method: 'POST',
|
|
38
52
|
headers: {
|
|
39
53
|
'content-type': 'application/x-www-form-urlencoded',
|
|
@@ -45,3 +59,14 @@ export async function fetchBasicAuthService(
|
|
|
45
59
|
credentials: 'include',
|
|
46
60
|
});
|
|
47
61
|
}
|
|
62
|
+
|
|
63
|
+
export async function fetchLogoutService(
|
|
64
|
+
thoughtSpotHost: string,
|
|
65
|
+
): Promise<any> {
|
|
66
|
+
return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.LOGOUT}`, {
|
|
67
|
+
credentials: 'include',
|
|
68
|
+
headers: {
|
|
69
|
+
'x-requested-by': 'ThoughtSpot',
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|