@shapediver/sdk.platform-api-sdk-v1 2.9.12 → 2.9.14
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.
|
@@ -18,6 +18,11 @@ export declare abstract class SdPlatformResponseError extends SdPlatformError {
|
|
|
18
18
|
readonly http_status_code: number;
|
|
19
19
|
constructor(message: string, http_status_code: number);
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* The server error which can just contain message and status code.
|
|
23
|
+
*/
|
|
24
|
+
export declare class SdPlatformServerResponseError extends SdPlatformResponseError {
|
|
25
|
+
}
|
|
21
26
|
/**
|
|
22
27
|
* Resource response error
|
|
23
28
|
*/
|
|
@@ -26,10 +31,28 @@ export declare class SdPlatformResourceResponseError extends SdPlatformResponseE
|
|
|
26
31
|
readonly error_description: string;
|
|
27
32
|
readonly error_uri?: string | undefined;
|
|
28
33
|
readonly code?: string | number | undefined;
|
|
34
|
+
constructor(message: string, http_status_code: number, error: string, error_description: string, error_uri?: string | undefined, code?: string | number | undefined);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Not found error, returned with 404 status.
|
|
38
|
+
*/
|
|
39
|
+
export declare class SdPlatformNotFoundResponseError extends SdPlatformResourceResponseError {
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Forbidden error, returned with 403 status.
|
|
43
|
+
*/
|
|
44
|
+
export declare class SdPlatformForbiddenResponseError extends SdPlatformResourceResponseError {
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Unauthorized error, returned with 401 status.
|
|
48
|
+
*/
|
|
49
|
+
export declare class SdPlatformUnauthorizedResponseError extends SdPlatformResourceResponseError {
|
|
50
|
+
}
|
|
51
|
+
export declare class SdPlatformValidationResponseError extends SdPlatformResourceResponseError {
|
|
29
52
|
readonly fields?: {
|
|
30
53
|
[key: string]: string[];
|
|
31
54
|
} | undefined;
|
|
32
|
-
constructor(message: string, http_status_code: number, error: string, error_description: string, error_uri?: string
|
|
55
|
+
constructor(message: string, http_status_code: number, error: string, error_description: string, error_uri?: string, code?: number | string, fields?: {
|
|
33
56
|
[key: string]: string[];
|
|
34
57
|
} | undefined);
|
|
35
58
|
}
|
|
@@ -75,4 +98,38 @@ export declare class SdPlatformOAuthResponseError extends SdPlatformResponseErro
|
|
|
75
98
|
information about the error */
|
|
76
99
|
error_uri?: string | undefined);
|
|
77
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Authentication response error.
|
|
103
|
+
* Follows principles of OAuth 2.0
|
|
104
|
+
* Please see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
|
|
105
|
+
*/
|
|
106
|
+
export declare class SdPlatformInvalidRequestOAuthResponseError extends SdPlatformOAuthResponseError {
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Authentication response error.
|
|
110
|
+
* Follows principles of OAuth 2.0
|
|
111
|
+
* Please see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
|
|
112
|
+
*/
|
|
113
|
+
export declare class SdPlatformInvalidClientOAuthResponseError extends SdPlatformOAuthResponseError {
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Authentication response error.
|
|
117
|
+
* Follows principles of OAuth 2.0
|
|
118
|
+
* Please see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
|
|
119
|
+
*/
|
|
120
|
+
export declare class SdPlatformInvalidGrantOAuthResponseError extends SdPlatformOAuthResponseError {
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Authentication response error.
|
|
124
|
+
* Follows principles of OAuth 2.0
|
|
125
|
+
* Please see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
|
|
126
|
+
*/
|
|
127
|
+
export declare class SdPlatformUnauthorizedClientOAuthResponseError extends SdPlatformOAuthResponseError {
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Authentication response error.
|
|
131
|
+
* Follows principles of OAuth 2.0
|
|
132
|
+
* Please see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
|
|
133
|
+
*/ export declare class SdPlatformUnsupportedGrantTypeClientOAuthResponseError extends SdPlatformOAuthResponseError {
|
|
134
|
+
}
|
|
78
135
|
//# sourceMappingURL=SdPlatformErrors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SdPlatformErrors.d.ts","sourceRoot":"","sources":["../src/SdPlatformErrors.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"SdPlatformErrors.d.ts","sourceRoot":"","sources":["../src/SdPlatformErrors.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;gBAG1B,OAAO,EAAE,MAAM;CAK9B;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,eAAe;aAKnC,IAAI,EAAE,MAAM;gBAD5B,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM;CAMnC;AAGD;;GAEG;AACH,8BAAsB,uBAAwB,SAAQ,eAAe;aAK7C,gBAAgB,EAAE,MAAM;gBADxC,OAAO,EAAE,MAAM,EACC,gBAAgB,EAAE,MAAM;CAK/C;AAED;;GAEG;AACH,qBAAa,6BAA8B,SAAQ,uBAAuB;CAGzE;AAED;;GAEG;AACH,qBAAa,+BAAgC,SAAQ,uBAAuB;aAKpD,KAAK,EAAE,MAAM;aACb,iBAAiB,EAAE,MAAM;aACzB,SAAS,CAAC;aACV,IAAI,CAAC;gBALrB,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,MAAM,EACR,KAAK,EAAE,MAAM,EACb,iBAAiB,EAAE,MAAM,EACzB,SAAS,CAAC,oBAAQ,EAClB,IAAI,CAAC,6BAAiB;CAK7C;AAED;;GAEG;AACH,qBAAa,+BAAgC,SAAQ,+BAA+B;CAGnF;AAED;;GAEG;AACF,qBAAa,gCAAiC,SAAQ,+BAA+B;CAGpF;AAED;;GAEG;AACH,qBAAa,mCAAoC,SAAQ,+BAA+B;CAGvF;AAEF,qBAAa,iCAAkC,SAAQ,+BAA+B;aAS9D,MAAM,CAAC;;;gBANvB,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,MAAM,EACxB,KAAK,EAAE,MAAM,EACb,iBAAiB,EAAE,MAAM,EACzB,SAAS,CAAC,EAAE,MAAM,EAClB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EACN,MAAM,CAAC;;iBAA6B;CAI3D;AAGD;;;;GAIG;AACH,qBAAa,4BAA6B,SAAQ,uBAAuB;IAMjE;;;;;;;;;;OAUG;aACa,KAAK,EAAE,MAAM;IAC7B,oEAAoE;aACpD,iBAAiB,EAAE,MAAM;IACzC;mCAC+B;aACf,SAAS,CAAC;gBAlB1B,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,MAAM;IACxB;;;;;;;;;;OAUG;IACa,KAAK,EAAE,MAAM;IAC7B,oEAAoE;IACpD,iBAAiB,EAAE,MAAM;IACzC;mCAC+B;IACf,SAAS,CAAC,oBAAQ;CAMzC;AAED;;;;GAIG;AACH,qBAAa,0CAA2C,SAAQ,4BAA4B;CAG3F;AAED;;;;GAIG;AACH,qBAAa,yCAA0C,SAAQ,4BAA4B;CAG1F;AAGD;;;;GAIG;AACH,qBAAa,wCAAyC,SAAQ,4BAA4B;CAGzF;AAED;;;;GAIG;AACH,qBAAa,8CAA+C,SAAQ,4BAA4B;CAG/F;AAED;;;;GAIG,CAAA,qBAAa,sDAAuD,SAAQ,4BAA4B;CAG1G"}
|
|
@@ -1,27 +1,5 @@
|
|
|
1
1
|
import { AxiosError } from "axios";
|
|
2
2
|
import { SdPlatformError } from "../SdPlatformErrors";
|
|
3
|
-
/**
|
|
4
|
-
* The OAuth error response, returned by server when oauth request fails
|
|
5
|
-
*/
|
|
6
|
-
export interface OAuthErrorResponse {
|
|
7
|
-
readonly error: string;
|
|
8
|
-
readonly error_description: string;
|
|
9
|
-
readonly error_uri?: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* The Resource response error, returned by server when resource request fails.
|
|
13
|
-
*/
|
|
14
|
-
export interface ResourceResponseError {
|
|
15
|
-
readonly error: {
|
|
16
|
-
readonly message: string;
|
|
17
|
-
readonly description: string;
|
|
18
|
-
readonly href?: string;
|
|
19
|
-
readonly code: number;
|
|
20
|
-
readonly fields?: {
|
|
21
|
-
[key: string]: string[];
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
3
|
/**
|
|
26
4
|
* Maps the given error into a ShapeDiver API response error object.
|
|
27
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SdPlatformSdkErrorMapping.d.ts","sourceRoot":"","sources":["../../src/api/SdPlatformSdkErrorMapping.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"SdPlatformSdkErrorMapping.d.ts","sourceRoot":"","sources":["../../src/api/SdPlatformSdkErrorMapping.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,UAAU,EAAiB,MAAM,OAAO,CAAA;AACxD,OACA,EACI,eAAe,EAclB,MAAM,qBAAqB,CAAA;AAwD5B;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,UAAU,GAAG,eAAe,CA6IxE"}
|
package/dist/bundle.js
CHANGED
|
@@ -1620,7 +1620,7 @@ exports.SdPlatformAuthServiceApi = SdPlatformAuthServiceApi;
|
|
|
1620
1620
|
"use strict";
|
|
1621
1621
|
|
|
1622
1622
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1623
|
-
exports.SdPlatformOAuthResponseError = exports.SdPlatformResourceResponseError = exports.SdPlatformResponseError = exports.SdPlatformRequestError = exports.SdPlatformError = void 0;
|
|
1623
|
+
exports.SdPlatformUnsupportedGrantTypeClientOAuthResponseError = exports.SdPlatformUnauthorizedClientOAuthResponseError = exports.SdPlatformInvalidGrantOAuthResponseError = exports.SdPlatformInvalidClientOAuthResponseError = exports.SdPlatformInvalidRequestOAuthResponseError = exports.SdPlatformOAuthResponseError = exports.SdPlatformValidationResponseError = exports.SdPlatformUnauthorizedResponseError = exports.SdPlatformForbiddenResponseError = exports.SdPlatformNotFoundResponseError = exports.SdPlatformResourceResponseError = exports.SdPlatformServerResponseError = exports.SdPlatformResponseError = exports.SdPlatformRequestError = exports.SdPlatformError = void 0;
|
|
1624
1624
|
/**
|
|
1625
1625
|
* Generic error
|
|
1626
1626
|
*/
|
|
@@ -1650,20 +1650,50 @@ class SdPlatformResponseError extends SdPlatformError {
|
|
|
1650
1650
|
}
|
|
1651
1651
|
}
|
|
1652
1652
|
exports.SdPlatformResponseError = SdPlatformResponseError;
|
|
1653
|
+
/**
|
|
1654
|
+
* The server error which can just contain message and status code.
|
|
1655
|
+
*/
|
|
1656
|
+
class SdPlatformServerResponseError extends SdPlatformResponseError {
|
|
1657
|
+
}
|
|
1658
|
+
exports.SdPlatformServerResponseError = SdPlatformServerResponseError;
|
|
1653
1659
|
/**
|
|
1654
1660
|
* Resource response error
|
|
1655
1661
|
*/
|
|
1656
1662
|
class SdPlatformResourceResponseError extends SdPlatformResponseError {
|
|
1657
|
-
constructor(message, http_status_code, error, error_description, error_uri, code
|
|
1663
|
+
constructor(message, http_status_code, error, error_description, error_uri, code) {
|
|
1658
1664
|
super(message, http_status_code);
|
|
1659
1665
|
this.error = error;
|
|
1660
1666
|
this.error_description = error_description;
|
|
1661
1667
|
this.error_uri = error_uri;
|
|
1662
1668
|
this.code = code;
|
|
1663
|
-
this.fields = fields;
|
|
1664
1669
|
}
|
|
1665
1670
|
}
|
|
1666
1671
|
exports.SdPlatformResourceResponseError = SdPlatformResourceResponseError;
|
|
1672
|
+
/**
|
|
1673
|
+
* Not found error, returned with 404 status.
|
|
1674
|
+
*/
|
|
1675
|
+
class SdPlatformNotFoundResponseError extends SdPlatformResourceResponseError {
|
|
1676
|
+
}
|
|
1677
|
+
exports.SdPlatformNotFoundResponseError = SdPlatformNotFoundResponseError;
|
|
1678
|
+
/**
|
|
1679
|
+
* Forbidden error, returned with 403 status.
|
|
1680
|
+
*/
|
|
1681
|
+
class SdPlatformForbiddenResponseError extends SdPlatformResourceResponseError {
|
|
1682
|
+
}
|
|
1683
|
+
exports.SdPlatformForbiddenResponseError = SdPlatformForbiddenResponseError;
|
|
1684
|
+
/**
|
|
1685
|
+
* Unauthorized error, returned with 401 status.
|
|
1686
|
+
*/
|
|
1687
|
+
class SdPlatformUnauthorizedResponseError extends SdPlatformResourceResponseError {
|
|
1688
|
+
}
|
|
1689
|
+
exports.SdPlatformUnauthorizedResponseError = SdPlatformUnauthorizedResponseError;
|
|
1690
|
+
class SdPlatformValidationResponseError extends SdPlatformResourceResponseError {
|
|
1691
|
+
constructor(message, http_status_code, error, error_description, error_uri, code, fields) {
|
|
1692
|
+
super(message, http_status_code, error, error_description, error_uri, code);
|
|
1693
|
+
this.fields = fields;
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
exports.SdPlatformValidationResponseError = SdPlatformValidationResponseError;
|
|
1667
1697
|
/**
|
|
1668
1698
|
* Authentication response error.
|
|
1669
1699
|
* Follows principles of OAuth 2.0
|
|
@@ -1695,6 +1725,45 @@ class SdPlatformOAuthResponseError extends SdPlatformResponseError {
|
|
|
1695
1725
|
}
|
|
1696
1726
|
}
|
|
1697
1727
|
exports.SdPlatformOAuthResponseError = SdPlatformOAuthResponseError;
|
|
1728
|
+
/**
|
|
1729
|
+
* Authentication response error.
|
|
1730
|
+
* Follows principles of OAuth 2.0
|
|
1731
|
+
* Please see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
|
|
1732
|
+
*/
|
|
1733
|
+
class SdPlatformInvalidRequestOAuthResponseError extends SdPlatformOAuthResponseError {
|
|
1734
|
+
}
|
|
1735
|
+
exports.SdPlatformInvalidRequestOAuthResponseError = SdPlatformInvalidRequestOAuthResponseError;
|
|
1736
|
+
/**
|
|
1737
|
+
* Authentication response error.
|
|
1738
|
+
* Follows principles of OAuth 2.0
|
|
1739
|
+
* Please see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
|
|
1740
|
+
*/
|
|
1741
|
+
class SdPlatformInvalidClientOAuthResponseError extends SdPlatformOAuthResponseError {
|
|
1742
|
+
}
|
|
1743
|
+
exports.SdPlatformInvalidClientOAuthResponseError = SdPlatformInvalidClientOAuthResponseError;
|
|
1744
|
+
/**
|
|
1745
|
+
* Authentication response error.
|
|
1746
|
+
* Follows principles of OAuth 2.0
|
|
1747
|
+
* Please see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
|
|
1748
|
+
*/
|
|
1749
|
+
class SdPlatformInvalidGrantOAuthResponseError extends SdPlatformOAuthResponseError {
|
|
1750
|
+
}
|
|
1751
|
+
exports.SdPlatformInvalidGrantOAuthResponseError = SdPlatformInvalidGrantOAuthResponseError;
|
|
1752
|
+
/**
|
|
1753
|
+
* Authentication response error.
|
|
1754
|
+
* Follows principles of OAuth 2.0
|
|
1755
|
+
* Please see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
|
|
1756
|
+
*/
|
|
1757
|
+
class SdPlatformUnauthorizedClientOAuthResponseError extends SdPlatformOAuthResponseError {
|
|
1758
|
+
}
|
|
1759
|
+
exports.SdPlatformUnauthorizedClientOAuthResponseError = SdPlatformUnauthorizedClientOAuthResponseError;
|
|
1760
|
+
/**
|
|
1761
|
+
* Authentication response error.
|
|
1762
|
+
* Follows principles of OAuth 2.0
|
|
1763
|
+
* Please see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
|
|
1764
|
+
*/ class SdPlatformUnsupportedGrantTypeClientOAuthResponseError extends SdPlatformOAuthResponseError {
|
|
1765
|
+
}
|
|
1766
|
+
exports.SdPlatformUnsupportedGrantTypeClientOAuthResponseError = SdPlatformUnsupportedGrantTypeClientOAuthResponseError;
|
|
1698
1767
|
|
|
1699
1768
|
|
|
1700
1769
|
/***/ }),
|
|
@@ -3518,10 +3587,14 @@ function isOAuthResponseError(response) {
|
|
|
3518
3587
|
function isResourceResponseError(response) {
|
|
3519
3588
|
return ("error" in response) && ("message" in response.error);
|
|
3520
3589
|
}
|
|
3590
|
+
function isValidationError(response) {
|
|
3591
|
+
return isResourceResponseError(response) && ("fields" in response.error);
|
|
3592
|
+
}
|
|
3521
3593
|
/**
|
|
3522
3594
|
* Maps the given error into a ShapeDiver API response error object.
|
|
3523
3595
|
*/
|
|
3524
3596
|
function mapToApiError(error) {
|
|
3597
|
+
var _a, _b;
|
|
3525
3598
|
// Handle basic non-axios errors
|
|
3526
3599
|
if (!axios_1.default.isAxiosError(error))
|
|
3527
3600
|
return new SdPlatformErrors_1.SdPlatformError(error.message);
|
|
@@ -3529,11 +3602,41 @@ function mapToApiError(error) {
|
|
|
3529
3602
|
if (axiosError.response) {
|
|
3530
3603
|
// Request was made and server responded with 4xx or 5xx
|
|
3531
3604
|
let data = axiosError.response.data;
|
|
3532
|
-
if (
|
|
3605
|
+
if (axiosError.response.status >= 500) {
|
|
3606
|
+
return new SdPlatformErrors_1.SdPlatformServerResponseError((_b = (_a = data === null || data === void 0 ? void 0 : data.error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : "Server Error.", axiosError.response.status);
|
|
3607
|
+
}
|
|
3608
|
+
else if (data && isOAuthResponseError(data)) {
|
|
3609
|
+
if (data.error == "invalid_client") {
|
|
3610
|
+
return new SdPlatformErrors_1.SdPlatformInvalidClientOAuthResponseError(`${data.error}. ${data.error_description}.`, axiosError.response.status, data.error, data.error_description, data.error_uri);
|
|
3611
|
+
}
|
|
3612
|
+
else if (data.error == "invalid_request") {
|
|
3613
|
+
return new SdPlatformErrors_1.SdPlatformInvalidRequestOAuthResponseError(`${data.error}. ${data.error_description}.`, axiosError.response.status, data.error, data.error_description, data.error_uri);
|
|
3614
|
+
}
|
|
3615
|
+
else if (data.error == "invalid_grant") {
|
|
3616
|
+
return new SdPlatformErrors_1.SdPlatformInvalidGrantOAuthResponseError(`${data.error}. ${data.error_description}.`, axiosError.response.status, data.error, data.error_description, data.error_uri);
|
|
3617
|
+
}
|
|
3618
|
+
else if (data.error == "unauthorized_client") {
|
|
3619
|
+
return new SdPlatformErrors_1.SdPlatformUnauthorizedClientOAuthResponseError(`${data.error}. ${data.error_description}.`, axiosError.response.status, data.error, data.error_description, data.error_uri);
|
|
3620
|
+
}
|
|
3621
|
+
else if (data.error == "unsupported_grant_type") {
|
|
3622
|
+
return new SdPlatformErrors_1.SdPlatformUnsupportedGrantTypeClientOAuthResponseError(`${data.error}. ${data.error_description}.`, axiosError.response.status, data.error, data.error_description, data.error_uri);
|
|
3623
|
+
}
|
|
3533
3624
|
return new SdPlatformErrors_1.SdPlatformOAuthResponseError(`${data.error}. ${data.error_description}.`, axiosError.response.status, data.error, data.error_description, data.error_uri);
|
|
3534
3625
|
}
|
|
3535
|
-
else if (isResourceResponseError(data)) {
|
|
3536
|
-
|
|
3626
|
+
else if (data && isResourceResponseError(data)) {
|
|
3627
|
+
if (isValidationError(data)) {
|
|
3628
|
+
return new SdPlatformErrors_1.SdPlatformValidationResponseError(`${data.error.message}. ${data.error.description}.`, axiosError.response.status, data.error.message, data.error.description, data.error.href, data.error.code, data.error.fields);
|
|
3629
|
+
}
|
|
3630
|
+
switch (axiosError.response.status) {
|
|
3631
|
+
case 404:
|
|
3632
|
+
return new SdPlatformErrors_1.SdPlatformNotFoundResponseError(`${data.error.message}. ${data.error.description}.`, axiosError.response.status, data.error.message, data.error.description, data.error.href, data.error.code);
|
|
3633
|
+
case 403:
|
|
3634
|
+
return new SdPlatformErrors_1.SdPlatformForbiddenResponseError(`${data.error.message}. ${data.error.description}.`, axiosError.response.status, data.error.message, data.error.description, data.error.href, data.error.code);
|
|
3635
|
+
case 401:
|
|
3636
|
+
return new SdPlatformErrors_1.SdPlatformUnauthorizedResponseError(`${data.error.message}. ${data.error.description}.`, axiosError.response.status, data.error.message, data.error.description, data.error.href, data.error.code);
|
|
3637
|
+
default:
|
|
3638
|
+
return new SdPlatformErrors_1.SdPlatformResourceResponseError(`${data.error.message}. ${data.error.description}.`, axiosError.response.status, data.error.message, data.error.description, data.error.href, data.error.code);
|
|
3639
|
+
}
|
|
3537
3640
|
}
|
|
3538
3641
|
else {
|
|
3539
3642
|
// Response was made but an unknown error object was received
|
package/dist/bundle.node.js
CHANGED
|
@@ -1620,7 +1620,7 @@ exports.SdPlatformAuthServiceApi = SdPlatformAuthServiceApi;
|
|
|
1620
1620
|
"use strict";
|
|
1621
1621
|
|
|
1622
1622
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1623
|
-
exports.SdPlatformOAuthResponseError = exports.SdPlatformResourceResponseError = exports.SdPlatformResponseError = exports.SdPlatformRequestError = exports.SdPlatformError = void 0;
|
|
1623
|
+
exports.SdPlatformUnsupportedGrantTypeClientOAuthResponseError = exports.SdPlatformUnauthorizedClientOAuthResponseError = exports.SdPlatformInvalidGrantOAuthResponseError = exports.SdPlatformInvalidClientOAuthResponseError = exports.SdPlatformInvalidRequestOAuthResponseError = exports.SdPlatformOAuthResponseError = exports.SdPlatformValidationResponseError = exports.SdPlatformUnauthorizedResponseError = exports.SdPlatformForbiddenResponseError = exports.SdPlatformNotFoundResponseError = exports.SdPlatformResourceResponseError = exports.SdPlatformServerResponseError = exports.SdPlatformResponseError = exports.SdPlatformRequestError = exports.SdPlatformError = void 0;
|
|
1624
1624
|
/**
|
|
1625
1625
|
* Generic error
|
|
1626
1626
|
*/
|
|
@@ -1650,20 +1650,50 @@ class SdPlatformResponseError extends SdPlatformError {
|
|
|
1650
1650
|
}
|
|
1651
1651
|
}
|
|
1652
1652
|
exports.SdPlatformResponseError = SdPlatformResponseError;
|
|
1653
|
+
/**
|
|
1654
|
+
* The server error which can just contain message and status code.
|
|
1655
|
+
*/
|
|
1656
|
+
class SdPlatformServerResponseError extends SdPlatformResponseError {
|
|
1657
|
+
}
|
|
1658
|
+
exports.SdPlatformServerResponseError = SdPlatformServerResponseError;
|
|
1653
1659
|
/**
|
|
1654
1660
|
* Resource response error
|
|
1655
1661
|
*/
|
|
1656
1662
|
class SdPlatformResourceResponseError extends SdPlatformResponseError {
|
|
1657
|
-
constructor(message, http_status_code, error, error_description, error_uri, code
|
|
1663
|
+
constructor(message, http_status_code, error, error_description, error_uri, code) {
|
|
1658
1664
|
super(message, http_status_code);
|
|
1659
1665
|
this.error = error;
|
|
1660
1666
|
this.error_description = error_description;
|
|
1661
1667
|
this.error_uri = error_uri;
|
|
1662
1668
|
this.code = code;
|
|
1663
|
-
this.fields = fields;
|
|
1664
1669
|
}
|
|
1665
1670
|
}
|
|
1666
1671
|
exports.SdPlatformResourceResponseError = SdPlatformResourceResponseError;
|
|
1672
|
+
/**
|
|
1673
|
+
* Not found error, returned with 404 status.
|
|
1674
|
+
*/
|
|
1675
|
+
class SdPlatformNotFoundResponseError extends SdPlatformResourceResponseError {
|
|
1676
|
+
}
|
|
1677
|
+
exports.SdPlatformNotFoundResponseError = SdPlatformNotFoundResponseError;
|
|
1678
|
+
/**
|
|
1679
|
+
* Forbidden error, returned with 403 status.
|
|
1680
|
+
*/
|
|
1681
|
+
class SdPlatformForbiddenResponseError extends SdPlatformResourceResponseError {
|
|
1682
|
+
}
|
|
1683
|
+
exports.SdPlatformForbiddenResponseError = SdPlatformForbiddenResponseError;
|
|
1684
|
+
/**
|
|
1685
|
+
* Unauthorized error, returned with 401 status.
|
|
1686
|
+
*/
|
|
1687
|
+
class SdPlatformUnauthorizedResponseError extends SdPlatformResourceResponseError {
|
|
1688
|
+
}
|
|
1689
|
+
exports.SdPlatformUnauthorizedResponseError = SdPlatformUnauthorizedResponseError;
|
|
1690
|
+
class SdPlatformValidationResponseError extends SdPlatformResourceResponseError {
|
|
1691
|
+
constructor(message, http_status_code, error, error_description, error_uri, code, fields) {
|
|
1692
|
+
super(message, http_status_code, error, error_description, error_uri, code);
|
|
1693
|
+
this.fields = fields;
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
exports.SdPlatformValidationResponseError = SdPlatformValidationResponseError;
|
|
1667
1697
|
/**
|
|
1668
1698
|
* Authentication response error.
|
|
1669
1699
|
* Follows principles of OAuth 2.0
|
|
@@ -1695,6 +1725,45 @@ class SdPlatformOAuthResponseError extends SdPlatformResponseError {
|
|
|
1695
1725
|
}
|
|
1696
1726
|
}
|
|
1697
1727
|
exports.SdPlatformOAuthResponseError = SdPlatformOAuthResponseError;
|
|
1728
|
+
/**
|
|
1729
|
+
* Authentication response error.
|
|
1730
|
+
* Follows principles of OAuth 2.0
|
|
1731
|
+
* Please see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
|
|
1732
|
+
*/
|
|
1733
|
+
class SdPlatformInvalidRequestOAuthResponseError extends SdPlatformOAuthResponseError {
|
|
1734
|
+
}
|
|
1735
|
+
exports.SdPlatformInvalidRequestOAuthResponseError = SdPlatformInvalidRequestOAuthResponseError;
|
|
1736
|
+
/**
|
|
1737
|
+
* Authentication response error.
|
|
1738
|
+
* Follows principles of OAuth 2.0
|
|
1739
|
+
* Please see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
|
|
1740
|
+
*/
|
|
1741
|
+
class SdPlatformInvalidClientOAuthResponseError extends SdPlatformOAuthResponseError {
|
|
1742
|
+
}
|
|
1743
|
+
exports.SdPlatformInvalidClientOAuthResponseError = SdPlatformInvalidClientOAuthResponseError;
|
|
1744
|
+
/**
|
|
1745
|
+
* Authentication response error.
|
|
1746
|
+
* Follows principles of OAuth 2.0
|
|
1747
|
+
* Please see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
|
|
1748
|
+
*/
|
|
1749
|
+
class SdPlatformInvalidGrantOAuthResponseError extends SdPlatformOAuthResponseError {
|
|
1750
|
+
}
|
|
1751
|
+
exports.SdPlatformInvalidGrantOAuthResponseError = SdPlatformInvalidGrantOAuthResponseError;
|
|
1752
|
+
/**
|
|
1753
|
+
* Authentication response error.
|
|
1754
|
+
* Follows principles of OAuth 2.0
|
|
1755
|
+
* Please see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
|
|
1756
|
+
*/
|
|
1757
|
+
class SdPlatformUnauthorizedClientOAuthResponseError extends SdPlatformOAuthResponseError {
|
|
1758
|
+
}
|
|
1759
|
+
exports.SdPlatformUnauthorizedClientOAuthResponseError = SdPlatformUnauthorizedClientOAuthResponseError;
|
|
1760
|
+
/**
|
|
1761
|
+
* Authentication response error.
|
|
1762
|
+
* Follows principles of OAuth 2.0
|
|
1763
|
+
* Please see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
|
|
1764
|
+
*/ class SdPlatformUnsupportedGrantTypeClientOAuthResponseError extends SdPlatformOAuthResponseError {
|
|
1765
|
+
}
|
|
1766
|
+
exports.SdPlatformUnsupportedGrantTypeClientOAuthResponseError = SdPlatformUnsupportedGrantTypeClientOAuthResponseError;
|
|
1698
1767
|
|
|
1699
1768
|
|
|
1700
1769
|
/***/ }),
|
|
@@ -3518,10 +3587,14 @@ function isOAuthResponseError(response) {
|
|
|
3518
3587
|
function isResourceResponseError(response) {
|
|
3519
3588
|
return ("error" in response) && ("message" in response.error);
|
|
3520
3589
|
}
|
|
3590
|
+
function isValidationError(response) {
|
|
3591
|
+
return isResourceResponseError(response) && ("fields" in response.error);
|
|
3592
|
+
}
|
|
3521
3593
|
/**
|
|
3522
3594
|
* Maps the given error into a ShapeDiver API response error object.
|
|
3523
3595
|
*/
|
|
3524
3596
|
function mapToApiError(error) {
|
|
3597
|
+
var _a, _b;
|
|
3525
3598
|
// Handle basic non-axios errors
|
|
3526
3599
|
if (!axios_1.default.isAxiosError(error))
|
|
3527
3600
|
return new SdPlatformErrors_1.SdPlatformError(error.message);
|
|
@@ -3529,11 +3602,41 @@ function mapToApiError(error) {
|
|
|
3529
3602
|
if (axiosError.response) {
|
|
3530
3603
|
// Request was made and server responded with 4xx or 5xx
|
|
3531
3604
|
let data = axiosError.response.data;
|
|
3532
|
-
if (
|
|
3605
|
+
if (axiosError.response.status >= 500) {
|
|
3606
|
+
return new SdPlatformErrors_1.SdPlatformServerResponseError((_b = (_a = data === null || data === void 0 ? void 0 : data.error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : "Server Error.", axiosError.response.status);
|
|
3607
|
+
}
|
|
3608
|
+
else if (data && isOAuthResponseError(data)) {
|
|
3609
|
+
if (data.error == "invalid_client") {
|
|
3610
|
+
return new SdPlatformErrors_1.SdPlatformInvalidClientOAuthResponseError(`${data.error}. ${data.error_description}.`, axiosError.response.status, data.error, data.error_description, data.error_uri);
|
|
3611
|
+
}
|
|
3612
|
+
else if (data.error == "invalid_request") {
|
|
3613
|
+
return new SdPlatformErrors_1.SdPlatformInvalidRequestOAuthResponseError(`${data.error}. ${data.error_description}.`, axiosError.response.status, data.error, data.error_description, data.error_uri);
|
|
3614
|
+
}
|
|
3615
|
+
else if (data.error == "invalid_grant") {
|
|
3616
|
+
return new SdPlatformErrors_1.SdPlatformInvalidGrantOAuthResponseError(`${data.error}. ${data.error_description}.`, axiosError.response.status, data.error, data.error_description, data.error_uri);
|
|
3617
|
+
}
|
|
3618
|
+
else if (data.error == "unauthorized_client") {
|
|
3619
|
+
return new SdPlatformErrors_1.SdPlatformUnauthorizedClientOAuthResponseError(`${data.error}. ${data.error_description}.`, axiosError.response.status, data.error, data.error_description, data.error_uri);
|
|
3620
|
+
}
|
|
3621
|
+
else if (data.error == "unsupported_grant_type") {
|
|
3622
|
+
return new SdPlatformErrors_1.SdPlatformUnsupportedGrantTypeClientOAuthResponseError(`${data.error}. ${data.error_description}.`, axiosError.response.status, data.error, data.error_description, data.error_uri);
|
|
3623
|
+
}
|
|
3533
3624
|
return new SdPlatformErrors_1.SdPlatformOAuthResponseError(`${data.error}. ${data.error_description}.`, axiosError.response.status, data.error, data.error_description, data.error_uri);
|
|
3534
3625
|
}
|
|
3535
|
-
else if (isResourceResponseError(data)) {
|
|
3536
|
-
|
|
3626
|
+
else if (data && isResourceResponseError(data)) {
|
|
3627
|
+
if (isValidationError(data)) {
|
|
3628
|
+
return new SdPlatformErrors_1.SdPlatformValidationResponseError(`${data.error.message}. ${data.error.description}.`, axiosError.response.status, data.error.message, data.error.description, data.error.href, data.error.code, data.error.fields);
|
|
3629
|
+
}
|
|
3630
|
+
switch (axiosError.response.status) {
|
|
3631
|
+
case 404:
|
|
3632
|
+
return new SdPlatformErrors_1.SdPlatformNotFoundResponseError(`${data.error.message}. ${data.error.description}.`, axiosError.response.status, data.error.message, data.error.description, data.error.href, data.error.code);
|
|
3633
|
+
case 403:
|
|
3634
|
+
return new SdPlatformErrors_1.SdPlatformForbiddenResponseError(`${data.error.message}. ${data.error.description}.`, axiosError.response.status, data.error.message, data.error.description, data.error.href, data.error.code);
|
|
3635
|
+
case 401:
|
|
3636
|
+
return new SdPlatformErrors_1.SdPlatformUnauthorizedResponseError(`${data.error.message}. ${data.error.description}.`, axiosError.response.status, data.error.message, data.error.description, data.error.href, data.error.code);
|
|
3637
|
+
default:
|
|
3638
|
+
return new SdPlatformErrors_1.SdPlatformResourceResponseError(`${data.error.message}. ${data.error.description}.`, axiosError.response.status, data.error.message, data.error.description, data.error.href, data.error.code);
|
|
3639
|
+
}
|
|
3537
3640
|
}
|
|
3538
3641
|
else {
|
|
3539
3642
|
// Response was made but an unknown error object was received
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapediver/sdk.platform-api-sdk-v1",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.14",
|
|
4
4
|
"description": "SDK to communicate with the Platform API version 1",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shapediver",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"build-prod": "bash ../../scripts/build-prod.sh"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@shapediver/api.platform-api-dto-v1": "^2.9.
|
|
42
|
+
"@shapediver/api.platform-api-dto-v1": "^2.9.14",
|
|
43
43
|
"@types/q": "^1.5.5",
|
|
44
44
|
"axios": "^0.26.1",
|
|
45
45
|
"dotenv": "^16.0.0",
|