@sisense/sdk-rest-client 1.19.0 → 1.21.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/dist/helpers.d.ts
CHANGED
package/dist/helpers.js
CHANGED
package/dist/http-client.js
CHANGED
|
@@ -7,7 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import fetchIntercept from 'fetch-intercept';
|
|
11
10
|
import { getResponseInterceptor, errorInterceptor } from './interceptors.js';
|
|
12
11
|
import { isSsoAuthenticator } from './sso-authenticator.js';
|
|
13
12
|
import { addQueryParamsToUrl } from './helpers.js';
|
|
@@ -19,10 +18,6 @@ export class HttpClient {
|
|
|
19
18
|
this.url = url;
|
|
20
19
|
this.auth = auth;
|
|
21
20
|
this.env = env;
|
|
22
|
-
fetchIntercept.register({
|
|
23
|
-
response: getResponseInterceptor(auth),
|
|
24
|
-
responseError: errorInterceptor,
|
|
25
|
-
});
|
|
26
21
|
}
|
|
27
22
|
login() {
|
|
28
23
|
return this.auth.authenticate();
|
|
@@ -43,7 +38,9 @@ export class HttpClient {
|
|
|
43
38
|
: addQueryParamsToUrl(url, {
|
|
44
39
|
trc: this.env,
|
|
45
40
|
});
|
|
46
|
-
const response = yield fetch(fetchUrl, config)
|
|
41
|
+
const response = yield fetch(fetchUrl, config)
|
|
42
|
+
.then(getResponseInterceptor(this.auth))
|
|
43
|
+
.catch(errorInterceptor);
|
|
47
44
|
if (response.status === 204 || // No content
|
|
48
45
|
response.status === 304 // Not modified
|
|
49
46
|
) {
|
package/dist/interceptors.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { FetchInterceptorResponse } from 'fetch-intercept';
|
|
2
1
|
import { Authenticator } from './interfaces.js';
|
|
3
|
-
export declare const getResponseInterceptor: (auth: Authenticator) => (response:
|
|
2
|
+
export declare const getResponseInterceptor: (auth: Authenticator) => (response: Response) => Response;
|
|
4
3
|
export declare const errorInterceptor: (error: Error) => Promise<never>;
|
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { BaseAuthenticator } from './base-authenticator.js';
|
|
11
11
|
import { appendHeaders } from './helpers.js';
|
|
12
|
+
import { errorInterceptor } from './interceptors.js';
|
|
12
13
|
export class PasswordAuthenticator extends BaseAuthenticator {
|
|
13
14
|
constructor(url, user, pass) {
|
|
14
15
|
super('password');
|
|
@@ -33,7 +34,7 @@ export class PasswordAuthenticator extends BaseAuthenticator {
|
|
|
33
34
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
34
35
|
},
|
|
35
36
|
body: this.body,
|
|
36
|
-
});
|
|
37
|
+
}).catch(errorInterceptor);
|
|
37
38
|
if (response.ok) {
|
|
38
39
|
const json = yield response.json();
|
|
39
40
|
this._authheader = json.access_token;
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
import { BaseAuthenticator } from './base-authenticator.js';
|
|
12
12
|
import { TranslatableError } from './translation/translatable-error.js';
|
|
13
|
+
import { errorInterceptor } from './interceptors.js';
|
|
13
14
|
export class SsoAuthenticator extends BaseAuthenticator {
|
|
14
15
|
constructor(url, enableSilentPreAuth = false) {
|
|
15
16
|
super('sso');
|
|
@@ -63,7 +64,7 @@ export class SsoAuthenticator extends BaseAuthenticator {
|
|
|
63
64
|
const response = yield fetch(fetchUrl, {
|
|
64
65
|
headers: { Internal: 'true' },
|
|
65
66
|
credentials: 'include',
|
|
66
|
-
});
|
|
67
|
+
}).catch(errorInterceptor);
|
|
67
68
|
const result = yield response.json();
|
|
68
69
|
if (!result.isAuthenticated) {
|
|
69
70
|
if (!result.ssoEnabled) {
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
import { BaseAuthenticator } from './base-authenticator.js';
|
|
12
12
|
import { appendHeaders } from './helpers.js';
|
|
13
13
|
import { TranslatableError } from './translation/translatable-error.js';
|
|
14
|
+
import { errorInterceptor } from './interceptors.js';
|
|
14
15
|
export class WatAuthenticator extends BaseAuthenticator {
|
|
15
16
|
constructor(url, wat) {
|
|
16
17
|
super('wat');
|
|
@@ -32,7 +33,7 @@ export class WatAuthenticator extends BaseAuthenticator {
|
|
|
32
33
|
'Content-Type': 'application/json',
|
|
33
34
|
},
|
|
34
35
|
body: this.body,
|
|
35
|
-
});
|
|
36
|
+
}).catch(errorInterceptor);
|
|
36
37
|
if (response.ok) {
|
|
37
38
|
const responseJson = yield response.json();
|
|
38
39
|
this._initialiser = responseJson.initialiser;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"Sisense",
|
|
12
12
|
"Compose SDK"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.21.0",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": "./dist/index.js",
|
|
17
17
|
"main": "./dist/index.js",
|
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
"author": "Sisense",
|
|
21
21
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@sisense/sdk-common": "^1.
|
|
24
|
-
"fetch-intercept": "^2.4.0"
|
|
23
|
+
"@sisense/sdk-common": "^1.21.0"
|
|
25
24
|
},
|
|
26
25
|
"scripts": {
|
|
27
26
|
"type-check": "tsc --noEmit",
|