@getpara/user-management-client 3.3.0 → 3.4.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/cjs/client.js +23 -8
- package/dist/esm/client.js +23 -8
- package/dist/types/client.d.ts +9 -2
- package/package.json +2 -2
package/dist/cjs/client.js
CHANGED
|
@@ -99,17 +99,29 @@ const handleResponseSuccess = (response) => {
|
|
|
99
99
|
}
|
|
100
100
|
throw new import_error.ParaApiError("Invalid status code");
|
|
101
101
|
};
|
|
102
|
+
const UNKNOWN_ERROR_MESSAGE = "Unknown error";
|
|
103
|
+
const hasUsableString = (value) => typeof value === "string" && value.trim().length > 0;
|
|
104
|
+
const getFallbackErrorMessage = (error) => {
|
|
105
|
+
if (hasUsableString(error == null ? void 0 : error.message)) return error.message;
|
|
106
|
+
if (hasUsableString(error == null ? void 0 : error.code)) return error.code;
|
|
107
|
+
return UNKNOWN_ERROR_MESSAGE;
|
|
108
|
+
};
|
|
109
|
+
const throwParaApiError = (message, code, status, responseURL, data, cause) => {
|
|
110
|
+
const paraApiError = new import_error.ParaApiError(message, code, status, responseURL, data);
|
|
111
|
+
if (cause !== void 0) paraApiError.cause = cause;
|
|
112
|
+
throw paraApiError;
|
|
113
|
+
};
|
|
102
114
|
const handleResponseError = (error) => {
|
|
103
115
|
var _a, _b, _c;
|
|
104
116
|
if (error === null) throw new import_error.ParaApiError("Error is null");
|
|
105
117
|
if (import_axios.default.isAxiosError(error)) {
|
|
106
118
|
const data = (_a = error.response) == null ? void 0 : _a.data;
|
|
107
|
-
let message =
|
|
119
|
+
let message = hasUsableString(data) ? data : getFallbackErrorMessage(error);
|
|
108
120
|
let serverCode;
|
|
109
121
|
let serverData;
|
|
110
122
|
if (data && typeof data === "object") {
|
|
111
123
|
const body = data;
|
|
112
|
-
if (
|
|
124
|
+
if (hasUsableString(body.message)) message = body.message;
|
|
113
125
|
serverCode = body.code;
|
|
114
126
|
serverData = body.data;
|
|
115
127
|
}
|
|
@@ -118,15 +130,16 @@ const handleResponseError = (error) => {
|
|
|
118
130
|
} else if (error.code === "ERR_CANCELED") {
|
|
119
131
|
message = "Connection canceled";
|
|
120
132
|
}
|
|
121
|
-
|
|
133
|
+
throwParaApiError(
|
|
122
134
|
message,
|
|
123
135
|
serverCode != null ? serverCode : error.code,
|
|
124
136
|
(_b = error.response) == null ? void 0 : _b.status,
|
|
125
137
|
(_c = error.request) == null ? void 0 : _c.responseURL,
|
|
126
|
-
serverData
|
|
138
|
+
serverData,
|
|
139
|
+
error
|
|
127
140
|
);
|
|
128
141
|
}
|
|
129
|
-
|
|
142
|
+
throwParaApiError(getFallbackErrorMessage(error), void 0, void 0, void 0, void 0, error);
|
|
130
143
|
};
|
|
131
144
|
const isRetryableError = (error) => {
|
|
132
145
|
var _a, _b, _c, _d;
|
|
@@ -143,7 +156,9 @@ class Client {
|
|
|
143
156
|
retrieveSessionCookie,
|
|
144
157
|
persistSessionCookie,
|
|
145
158
|
partnerConfigOverride,
|
|
146
|
-
staticTraceContext
|
|
159
|
+
staticTraceContext,
|
|
160
|
+
httpAgent,
|
|
161
|
+
httpsAgent
|
|
147
162
|
}) {
|
|
148
163
|
this.inFlightFaucetRequests = /* @__PURE__ */ new Map();
|
|
149
164
|
this.signUpOrLogIn = (body) => __async(this, null, function* () {
|
|
@@ -636,12 +651,12 @@ class Client {
|
|
|
636
651
|
// plain-text bodies for backward compat with older SDKs.
|
|
637
652
|
[import_shared.STRUCTURED_ERRORS_HEADER]: "1"
|
|
638
653
|
});
|
|
639
|
-
const axiosConfig = {
|
|
654
|
+
const axiosConfig = __spreadValues(__spreadValues({
|
|
640
655
|
baseURL: userManagementHost,
|
|
641
656
|
withCredentials: true,
|
|
642
657
|
timeout: 6e4,
|
|
643
658
|
headers
|
|
644
|
-
};
|
|
659
|
+
}, httpAgent ? { httpAgent } : {}), httpsAgent ? { httpsAgent } : {});
|
|
645
660
|
if (retrieveSessionCookie) {
|
|
646
661
|
const defaultTransformRequest = Array.isArray(import_axios.default.defaults.transformRequest) ? import_axios.default.defaults.transformRequest : [import_axios.default.defaults.transformRequest];
|
|
647
662
|
axiosConfig.transformRequest = [
|
package/dist/esm/client.js
CHANGED
|
@@ -30,17 +30,29 @@ const handleResponseSuccess = (response) => {
|
|
|
30
30
|
}
|
|
31
31
|
throw new ParaApiError("Invalid status code");
|
|
32
32
|
};
|
|
33
|
+
const UNKNOWN_ERROR_MESSAGE = "Unknown error";
|
|
34
|
+
const hasUsableString = (value) => typeof value === "string" && value.trim().length > 0;
|
|
35
|
+
const getFallbackErrorMessage = (error) => {
|
|
36
|
+
if (hasUsableString(error == null ? void 0 : error.message)) return error.message;
|
|
37
|
+
if (hasUsableString(error == null ? void 0 : error.code)) return error.code;
|
|
38
|
+
return UNKNOWN_ERROR_MESSAGE;
|
|
39
|
+
};
|
|
40
|
+
const throwParaApiError = (message, code, status, responseURL, data, cause) => {
|
|
41
|
+
const paraApiError = new ParaApiError(message, code, status, responseURL, data);
|
|
42
|
+
if (cause !== void 0) paraApiError.cause = cause;
|
|
43
|
+
throw paraApiError;
|
|
44
|
+
};
|
|
33
45
|
const handleResponseError = (error) => {
|
|
34
46
|
var _a, _b, _c;
|
|
35
47
|
if (error === null) throw new ParaApiError("Error is null");
|
|
36
48
|
if (axios.isAxiosError(error)) {
|
|
37
49
|
const data = (_a = error.response) == null ? void 0 : _a.data;
|
|
38
|
-
let message =
|
|
50
|
+
let message = hasUsableString(data) ? data : getFallbackErrorMessage(error);
|
|
39
51
|
let serverCode;
|
|
40
52
|
let serverData;
|
|
41
53
|
if (data && typeof data === "object") {
|
|
42
54
|
const body = data;
|
|
43
|
-
if (
|
|
55
|
+
if (hasUsableString(body.message)) message = body.message;
|
|
44
56
|
serverCode = body.code;
|
|
45
57
|
serverData = body.data;
|
|
46
58
|
}
|
|
@@ -49,15 +61,16 @@ const handleResponseError = (error) => {
|
|
|
49
61
|
} else if (error.code === "ERR_CANCELED") {
|
|
50
62
|
message = "Connection canceled";
|
|
51
63
|
}
|
|
52
|
-
|
|
64
|
+
throwParaApiError(
|
|
53
65
|
message,
|
|
54
66
|
serverCode != null ? serverCode : error.code,
|
|
55
67
|
(_b = error.response) == null ? void 0 : _b.status,
|
|
56
68
|
(_c = error.request) == null ? void 0 : _c.responseURL,
|
|
57
|
-
serverData
|
|
69
|
+
serverData,
|
|
70
|
+
error
|
|
58
71
|
);
|
|
59
72
|
}
|
|
60
|
-
|
|
73
|
+
throwParaApiError(getFallbackErrorMessage(error), void 0, void 0, void 0, void 0, error);
|
|
61
74
|
};
|
|
62
75
|
const isRetryableError = (error) => {
|
|
63
76
|
var _a, _b, _c, _d;
|
|
@@ -74,7 +87,9 @@ class Client {
|
|
|
74
87
|
retrieveSessionCookie,
|
|
75
88
|
persistSessionCookie,
|
|
76
89
|
partnerConfigOverride,
|
|
77
|
-
staticTraceContext
|
|
90
|
+
staticTraceContext,
|
|
91
|
+
httpAgent,
|
|
92
|
+
httpsAgent
|
|
78
93
|
}) {
|
|
79
94
|
this.inFlightFaucetRequests = /* @__PURE__ */ new Map();
|
|
80
95
|
this.signUpOrLogIn = (body) => __async(this, null, function* () {
|
|
@@ -567,12 +582,12 @@ class Client {
|
|
|
567
582
|
// plain-text bodies for backward compat with older SDKs.
|
|
568
583
|
[STRUCTURED_ERRORS_HEADER]: "1"
|
|
569
584
|
});
|
|
570
|
-
const axiosConfig = {
|
|
585
|
+
const axiosConfig = __spreadValues(__spreadValues({
|
|
571
586
|
baseURL: userManagementHost,
|
|
572
587
|
withCredentials: true,
|
|
573
588
|
timeout: 6e4,
|
|
574
589
|
headers
|
|
575
|
-
};
|
|
590
|
+
}, httpAgent ? { httpAgent } : {}), httpsAgent ? { httpsAgent } : {});
|
|
576
591
|
if (retrieveSessionCookie) {
|
|
577
592
|
const defaultTransformRequest = Array.isArray(axios.defaults.transformRequest) ? axios.defaults.transformRequest : [axios.defaults.transformRequest];
|
|
578
593
|
axiosConfig.transformRequest = [
|
package/dist/types/client.d.ts
CHANGED
|
@@ -24,6 +24,13 @@ type ClientConfig = {
|
|
|
24
24
|
* interceptor that pulls from context.active().
|
|
25
25
|
*/
|
|
26
26
|
staticTraceContext?: Record<string, string>;
|
|
27
|
+
/**
|
|
28
|
+
* Node-only keep-alive agents, set by the server SDK so server-to-server
|
|
29
|
+
* callers reuse connections instead of re-handshaking TCP+TLS per request.
|
|
30
|
+
* Left undefined in the browser, where the runtime pools sockets itself.
|
|
31
|
+
*/
|
|
32
|
+
httpAgent?: unknown;
|
|
33
|
+
httpsAgent?: unknown;
|
|
27
34
|
};
|
|
28
35
|
interface createUserIdRes {
|
|
29
36
|
protocolId: string;
|
|
@@ -168,12 +175,12 @@ export type VerifyTelegramRes = {
|
|
|
168
175
|
isValid: false;
|
|
169
176
|
};
|
|
170
177
|
export declare const handleResponseSuccess: (response: AxiosResponse<any, any>) => AxiosResponse<any, any>;
|
|
171
|
-
export declare const handleResponseError: (error: any) =>
|
|
178
|
+
export declare const handleResponseError: (error: any) => void;
|
|
172
179
|
export declare const isRetryableError: (error: AxiosError) => boolean;
|
|
173
180
|
declare class Client {
|
|
174
181
|
private baseRequest;
|
|
175
182
|
private inFlightFaucetRequests;
|
|
176
|
-
constructor({ userManagementHost, apiKey, partnerId, version, clientType, opts, retrieveSessionCookie, persistSessionCookie, partnerConfigOverride, staticTraceContext, }: ClientConfig);
|
|
183
|
+
constructor({ userManagementHost, apiKey, partnerId, version, clientType, opts, retrieveSessionCookie, persistSessionCookie, partnerConfigOverride, staticTraceContext, httpAgent, httpsAgent, }: ClientConfig);
|
|
177
184
|
signUpOrLogIn: (body: VerifiedAuth & VerificationEmailProps) => Promise<SignUpOrLogInResponse>;
|
|
178
185
|
/**
|
|
179
186
|
* @deprecated
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/user-management-client",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@getpara/shared": "^1.21.0",
|
|
6
6
|
"@opentelemetry/api": "^1.9.1",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dist",
|
|
23
23
|
"package.json"
|
|
24
24
|
],
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "795829c50bb71817a84bdbf5e6561ca4df3a827d",
|
|
26
26
|
"main": "dist/cjs/index.js",
|
|
27
27
|
"module": "dist/esm/index.js",
|
|
28
28
|
"scripts": {
|