@getpara/user-management-client 3.0.0-alpha.1 → 3.0.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 +60 -14
- package/dist/cjs/error.js +2 -1
- package/dist/esm/client.js +62 -14
- package/dist/esm/error.js +2 -1
- package/dist/types/client.d.ts +24 -8
- package/dist/types/error.d.ts +1 -1
- package/package.json +4 -3
package/dist/cjs/client.js
CHANGED
|
@@ -84,9 +84,15 @@ __export(client_exports, {
|
|
|
84
84
|
module.exports = __toCommonJS(client_exports);
|
|
85
85
|
var import_axios = __toESM(require("axios"));
|
|
86
86
|
var import_axios_retry = __toESM(require("axios-retry"));
|
|
87
|
+
var import_api = require("@opentelemetry/api");
|
|
88
|
+
var import_shared = require("@getpara/shared");
|
|
87
89
|
var import_utils = require("./utils.js");
|
|
88
90
|
var import_consts = require("./consts.js");
|
|
89
91
|
var import_error = require("./error.js");
|
|
92
|
+
const DISABLE_AXIOS_RETRY_CONFIG = {
|
|
93
|
+
"axios-retry": { retries: 0 }
|
|
94
|
+
};
|
|
95
|
+
const DEFAULT_FAUCET_CHAIN = "ETHEREUM_SEPOLIA";
|
|
90
96
|
const handleResponseSuccess = (response) => {
|
|
91
97
|
if (response.status === 200) {
|
|
92
98
|
return response;
|
|
@@ -94,16 +100,31 @@ const handleResponseSuccess = (response) => {
|
|
|
94
100
|
throw new import_error.ParaApiError("Invalid status code");
|
|
95
101
|
};
|
|
96
102
|
const handleResponseError = (error) => {
|
|
97
|
-
var _a, _b, _c
|
|
103
|
+
var _a, _b, _c;
|
|
98
104
|
if (error === null) throw new import_error.ParaApiError("Error is null");
|
|
99
105
|
if (import_axios.default.isAxiosError(error)) {
|
|
100
|
-
|
|
106
|
+
const data = (_a = error.response) == null ? void 0 : _a.data;
|
|
107
|
+
let message = typeof data === "string" ? data : "Unknown error";
|
|
108
|
+
let serverCode;
|
|
109
|
+
let serverData;
|
|
110
|
+
if (data && typeof data === "object") {
|
|
111
|
+
const body = data;
|
|
112
|
+
if (typeof body.message === "string") message = body.message;
|
|
113
|
+
serverCode = body.code;
|
|
114
|
+
serverData = body.data;
|
|
115
|
+
}
|
|
101
116
|
if (error.code === "ERR_NETWORK") {
|
|
102
117
|
message = "Connection error";
|
|
103
118
|
} else if (error.code === "ERR_CANCELED") {
|
|
104
119
|
message = "Connection canceled";
|
|
105
120
|
}
|
|
106
|
-
throw new import_error.ParaApiError(
|
|
121
|
+
throw new import_error.ParaApiError(
|
|
122
|
+
message,
|
|
123
|
+
serverCode != null ? serverCode : error.code,
|
|
124
|
+
(_b = error.response) == null ? void 0 : _b.status,
|
|
125
|
+
(_c = error.request) == null ? void 0 : _c.responseURL,
|
|
126
|
+
serverData
|
|
127
|
+
);
|
|
107
128
|
}
|
|
108
129
|
throw new import_error.ParaApiError("Unknown error");
|
|
109
130
|
};
|
|
@@ -120,8 +141,10 @@ class Client {
|
|
|
120
141
|
opts,
|
|
121
142
|
retrieveSessionCookie,
|
|
122
143
|
persistSessionCookie,
|
|
123
|
-
partnerConfigOverride
|
|
144
|
+
partnerConfigOverride,
|
|
145
|
+
staticTraceContext
|
|
124
146
|
}) {
|
|
147
|
+
this.inFlightFaucetRequests = /* @__PURE__ */ new Map();
|
|
125
148
|
this.signUpOrLogIn = (body) => __async(this, null, function* () {
|
|
126
149
|
const res = yield this.baseRequest.post(`/users/init`, body);
|
|
127
150
|
return res.data;
|
|
@@ -166,10 +189,11 @@ class Client {
|
|
|
166
189
|
});
|
|
167
190
|
return res.data;
|
|
168
191
|
});
|
|
169
|
-
this.verifyAccount = (userId, body) => __async(this, null, function* () {
|
|
192
|
+
this.verifyAccount = (userId, body, traceCarrier) => __async(this, null, function* () {
|
|
170
193
|
const res = yield this.baseRequest.post(
|
|
171
194
|
`/users/${userId}/verify`,
|
|
172
|
-
body
|
|
195
|
+
body,
|
|
196
|
+
traceCarrier ? { headers: traceCarrier } : void 0
|
|
173
197
|
);
|
|
174
198
|
return res.data;
|
|
175
199
|
});
|
|
@@ -338,19 +362,17 @@ class Client {
|
|
|
338
362
|
const res = yield this.baseRequest.post(`/users/${userId}/wallets`, body);
|
|
339
363
|
return res.data;
|
|
340
364
|
});
|
|
341
|
-
|
|
365
|
+
// POST /wallets/pregen
|
|
342
366
|
this.createPregenWallet = (body) => __async(this, null, function* () {
|
|
343
367
|
const res = yield this.baseRequest.post(`/wallets/pregen`, body);
|
|
344
368
|
return res.data;
|
|
345
369
|
});
|
|
346
|
-
/** @deprecated Use the REST API (`GET /v1/wallets`) instead. See https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen */
|
|
347
370
|
this.getPregenWallets = (pregenIds, isPortal = false, userId) => __async(this, null, function* () {
|
|
348
371
|
const res = yield this.baseRequest.get("/wallets/pregen", {
|
|
349
372
|
params: { ids: pregenIds, expand: isPortal, userId }
|
|
350
373
|
});
|
|
351
374
|
return res.data;
|
|
352
375
|
});
|
|
353
|
-
/** @deprecated Use the REST API (`POST /v1/wallets`) instead. See https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen */
|
|
354
376
|
this.claimPregenWallets = (body) => __async(this, null, function* () {
|
|
355
377
|
const res = yield this.baseRequest.post(`/wallets/pregen/claim`, body);
|
|
356
378
|
return res.data;
|
|
@@ -372,7 +394,7 @@ class Client {
|
|
|
372
394
|
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/refresh`, body);
|
|
373
395
|
return res;
|
|
374
396
|
});
|
|
375
|
-
|
|
397
|
+
// PATCH /wallets/pregen/:walletId
|
|
376
398
|
this.updatePregenWallet = (walletId, body) => __async(this, null, function* () {
|
|
377
399
|
const res = yield this.baseRequest.patch(`/wallets/pregen/${walletId}`, body);
|
|
378
400
|
return res.data;
|
|
@@ -469,8 +491,14 @@ class Client {
|
|
|
469
491
|
return res.data;
|
|
470
492
|
});
|
|
471
493
|
this.requestFaucet = (_0) => __async(this, [_0], function* ({ walletId, chain }) {
|
|
472
|
-
const
|
|
473
|
-
|
|
494
|
+
const requestKey = `${walletId}:${chain != null ? chain : DEFAULT_FAUCET_CHAIN}`;
|
|
495
|
+
const inFlightRequest = this.inFlightFaucetRequests.get(requestKey);
|
|
496
|
+
if (inFlightRequest !== void 0) return yield inFlightRequest;
|
|
497
|
+
const request = this.baseRequest.post("/faucet", { walletId, chain }, DISABLE_AXIOS_RETRY_CONFIG).then((res) => res.data).finally(() => {
|
|
498
|
+
this.inFlightFaucetRequests.delete(requestKey);
|
|
499
|
+
});
|
|
500
|
+
this.inFlightFaucetRequests.set(requestKey, request);
|
|
501
|
+
return yield request;
|
|
474
502
|
});
|
|
475
503
|
this.issueJwt = (..._0) => __async(this, [..._0], function* ({ keyIndex = 0 } = {}) {
|
|
476
504
|
const res = yield this.baseRequest.post(`/auth/jwt`, { keyIndex });
|
|
@@ -601,7 +629,12 @@ class Client {
|
|
|
601
629
|
});
|
|
602
630
|
return { success: res.data.success };
|
|
603
631
|
});
|
|
604
|
-
const headers = __spreadValues(__spreadValues(__spreadValues({}, apiKey && { [import_consts.API_KEY_HEADER_NAME]: apiKey }), partnerId && { [import_consts.PARTNER_ID_HEADER_NAME]: partnerId }), partnerConfigOverride && { [import_consts.PARTNER_CONFIG_OVERRIDE_HEADER_NAME]: JSON.stringify(partnerConfigOverride) })
|
|
632
|
+
const headers = __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, apiKey && { [import_consts.API_KEY_HEADER_NAME]: apiKey }), partnerId && { [import_consts.PARTNER_ID_HEADER_NAME]: partnerId }), partnerConfigOverride && { [import_consts.PARTNER_CONFIG_OVERRIDE_HEADER_NAME]: JSON.stringify(partnerConfigOverride) }), {
|
|
633
|
+
// Opts into structured-JSON error responses for OTP error classes (server-side
|
|
634
|
+
// contract added in @getpara/shared 1.16.0). Without it the server falls back to
|
|
635
|
+
// plain-text bodies for backward compat with older SDKs.
|
|
636
|
+
[import_shared.STRUCTURED_ERRORS_HEADER]: "1"
|
|
637
|
+
});
|
|
605
638
|
const axiosConfig = {
|
|
606
639
|
baseURL: userManagementHost,
|
|
607
640
|
withCredentials: true,
|
|
@@ -647,6 +680,19 @@ class Client {
|
|
|
647
680
|
if (version) {
|
|
648
681
|
config.headers.set(import_consts.VERSION_HEADER_NAME, version);
|
|
649
682
|
}
|
|
683
|
+
const g = globalThis;
|
|
684
|
+
const isBrowserMainThread = typeof g.window !== "undefined" && typeof g.WorkerGlobalScope === "undefined";
|
|
685
|
+
if (staticTraceContext) {
|
|
686
|
+
for (const [key, value] of Object.entries(staticTraceContext)) {
|
|
687
|
+
config.headers.set(key, value);
|
|
688
|
+
}
|
|
689
|
+
} else if (!isBrowserMainThread) {
|
|
690
|
+
import_api.propagation.inject(import_api.context.active(), config.headers, {
|
|
691
|
+
set: (carrier, key, value) => {
|
|
692
|
+
carrier.set(key, value);
|
|
693
|
+
}
|
|
694
|
+
});
|
|
695
|
+
}
|
|
650
696
|
return config;
|
|
651
697
|
});
|
|
652
698
|
if (opts == null ? void 0 : opts.useFetchAdapter) {
|
|
@@ -748,7 +794,7 @@ class Client {
|
|
|
748
794
|
return __async(this, null, function* () {
|
|
749
795
|
var _f = _e, { userId } = _f, rest = __objRest(_f, ["userId"]);
|
|
750
796
|
const res = yield this.baseRequest.post(`/users/${userId}/resend-verification-code`, rest);
|
|
751
|
-
return res;
|
|
797
|
+
return res.data;
|
|
752
798
|
});
|
|
753
799
|
}
|
|
754
800
|
// POST '/users/:userId/resend-verification-code-by-phone
|
package/dist/cjs/error.js
CHANGED
|
@@ -20,7 +20,7 @@ __export(error_exports, {
|
|
|
20
20
|
ParaApiError: () => ParaApiError
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(error_exports);
|
|
23
|
-
function ParaApiError(message, code, status, responseURL) {
|
|
23
|
+
function ParaApiError(message, code, status, responseURL, data) {
|
|
24
24
|
Error.call(this);
|
|
25
25
|
if (Error.captureStackTrace) {
|
|
26
26
|
Error.captureStackTrace(this, this.constructor);
|
|
@@ -32,6 +32,7 @@ function ParaApiError(message, code, status, responseURL) {
|
|
|
32
32
|
code && (this.code = code);
|
|
33
33
|
status && (this.status = status);
|
|
34
34
|
responseURL && (this.responseURL = responseURL);
|
|
35
|
+
data && (this.data = data);
|
|
35
36
|
}
|
|
36
37
|
const prototype = ParaApiError.prototype;
|
|
37
38
|
Object.defineProperty(prototype, "isParaApiError", { value: true });
|
package/dist/esm/client.js
CHANGED
|
@@ -6,6 +6,10 @@ import {
|
|
|
6
6
|
} from "./chunk-BBZEL7EG.js";
|
|
7
7
|
import axios from "axios";
|
|
8
8
|
import axiosRetry from "axios-retry";
|
|
9
|
+
import { context, propagation } from "@opentelemetry/api";
|
|
10
|
+
import {
|
|
11
|
+
STRUCTURED_ERRORS_HEADER
|
|
12
|
+
} from "@getpara/shared";
|
|
9
13
|
import { extractWalletRef, fromAccountMetadata, fromLinkedAccounts } from "./utils.js";
|
|
10
14
|
import {
|
|
11
15
|
SESSION_COOKIE_HEADER_NAME,
|
|
@@ -15,6 +19,10 @@ import {
|
|
|
15
19
|
PARTNER_CONFIG_OVERRIDE_HEADER_NAME
|
|
16
20
|
} from "./consts.js";
|
|
17
21
|
import { ParaApiError } from "./error.js";
|
|
22
|
+
const DISABLE_AXIOS_RETRY_CONFIG = {
|
|
23
|
+
"axios-retry": { retries: 0 }
|
|
24
|
+
};
|
|
25
|
+
const DEFAULT_FAUCET_CHAIN = "ETHEREUM_SEPOLIA";
|
|
18
26
|
const handleResponseSuccess = (response) => {
|
|
19
27
|
if (response.status === 200) {
|
|
20
28
|
return response;
|
|
@@ -22,16 +30,31 @@ const handleResponseSuccess = (response) => {
|
|
|
22
30
|
throw new ParaApiError("Invalid status code");
|
|
23
31
|
};
|
|
24
32
|
const handleResponseError = (error) => {
|
|
25
|
-
var _a, _b, _c
|
|
33
|
+
var _a, _b, _c;
|
|
26
34
|
if (error === null) throw new ParaApiError("Error is null");
|
|
27
35
|
if (axios.isAxiosError(error)) {
|
|
28
|
-
|
|
36
|
+
const data = (_a = error.response) == null ? void 0 : _a.data;
|
|
37
|
+
let message = typeof data === "string" ? data : "Unknown error";
|
|
38
|
+
let serverCode;
|
|
39
|
+
let serverData;
|
|
40
|
+
if (data && typeof data === "object") {
|
|
41
|
+
const body = data;
|
|
42
|
+
if (typeof body.message === "string") message = body.message;
|
|
43
|
+
serverCode = body.code;
|
|
44
|
+
serverData = body.data;
|
|
45
|
+
}
|
|
29
46
|
if (error.code === "ERR_NETWORK") {
|
|
30
47
|
message = "Connection error";
|
|
31
48
|
} else if (error.code === "ERR_CANCELED") {
|
|
32
49
|
message = "Connection canceled";
|
|
33
50
|
}
|
|
34
|
-
throw new ParaApiError(
|
|
51
|
+
throw new ParaApiError(
|
|
52
|
+
message,
|
|
53
|
+
serverCode != null ? serverCode : error.code,
|
|
54
|
+
(_b = error.response) == null ? void 0 : _b.status,
|
|
55
|
+
(_c = error.request) == null ? void 0 : _c.responseURL,
|
|
56
|
+
serverData
|
|
57
|
+
);
|
|
35
58
|
}
|
|
36
59
|
throw new ParaApiError("Unknown error");
|
|
37
60
|
};
|
|
@@ -48,8 +71,10 @@ class Client {
|
|
|
48
71
|
opts,
|
|
49
72
|
retrieveSessionCookie,
|
|
50
73
|
persistSessionCookie,
|
|
51
|
-
partnerConfigOverride
|
|
74
|
+
partnerConfigOverride,
|
|
75
|
+
staticTraceContext
|
|
52
76
|
}) {
|
|
77
|
+
this.inFlightFaucetRequests = /* @__PURE__ */ new Map();
|
|
53
78
|
this.signUpOrLogIn = (body) => __async(this, null, function* () {
|
|
54
79
|
const res = yield this.baseRequest.post(`/users/init`, body);
|
|
55
80
|
return res.data;
|
|
@@ -94,10 +119,11 @@ class Client {
|
|
|
94
119
|
});
|
|
95
120
|
return res.data;
|
|
96
121
|
});
|
|
97
|
-
this.verifyAccount = (userId, body) => __async(this, null, function* () {
|
|
122
|
+
this.verifyAccount = (userId, body, traceCarrier) => __async(this, null, function* () {
|
|
98
123
|
const res = yield this.baseRequest.post(
|
|
99
124
|
`/users/${userId}/verify`,
|
|
100
|
-
body
|
|
125
|
+
body,
|
|
126
|
+
traceCarrier ? { headers: traceCarrier } : void 0
|
|
101
127
|
);
|
|
102
128
|
return res.data;
|
|
103
129
|
});
|
|
@@ -266,19 +292,17 @@ class Client {
|
|
|
266
292
|
const res = yield this.baseRequest.post(`/users/${userId}/wallets`, body);
|
|
267
293
|
return res.data;
|
|
268
294
|
});
|
|
269
|
-
|
|
295
|
+
// POST /wallets/pregen
|
|
270
296
|
this.createPregenWallet = (body) => __async(this, null, function* () {
|
|
271
297
|
const res = yield this.baseRequest.post(`/wallets/pregen`, body);
|
|
272
298
|
return res.data;
|
|
273
299
|
});
|
|
274
|
-
/** @deprecated Use the REST API (`GET /v1/wallets`) instead. See https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen */
|
|
275
300
|
this.getPregenWallets = (pregenIds, isPortal = false, userId) => __async(this, null, function* () {
|
|
276
301
|
const res = yield this.baseRequest.get("/wallets/pregen", {
|
|
277
302
|
params: { ids: pregenIds, expand: isPortal, userId }
|
|
278
303
|
});
|
|
279
304
|
return res.data;
|
|
280
305
|
});
|
|
281
|
-
/** @deprecated Use the REST API (`POST /v1/wallets`) instead. See https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen */
|
|
282
306
|
this.claimPregenWallets = (body) => __async(this, null, function* () {
|
|
283
307
|
const res = yield this.baseRequest.post(`/wallets/pregen/claim`, body);
|
|
284
308
|
return res.data;
|
|
@@ -300,7 +324,7 @@ class Client {
|
|
|
300
324
|
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/refresh`, body);
|
|
301
325
|
return res;
|
|
302
326
|
});
|
|
303
|
-
|
|
327
|
+
// PATCH /wallets/pregen/:walletId
|
|
304
328
|
this.updatePregenWallet = (walletId, body) => __async(this, null, function* () {
|
|
305
329
|
const res = yield this.baseRequest.patch(`/wallets/pregen/${walletId}`, body);
|
|
306
330
|
return res.data;
|
|
@@ -397,8 +421,14 @@ class Client {
|
|
|
397
421
|
return res.data;
|
|
398
422
|
});
|
|
399
423
|
this.requestFaucet = (_0) => __async(this, [_0], function* ({ walletId, chain }) {
|
|
400
|
-
const
|
|
401
|
-
|
|
424
|
+
const requestKey = `${walletId}:${chain != null ? chain : DEFAULT_FAUCET_CHAIN}`;
|
|
425
|
+
const inFlightRequest = this.inFlightFaucetRequests.get(requestKey);
|
|
426
|
+
if (inFlightRequest !== void 0) return yield inFlightRequest;
|
|
427
|
+
const request = this.baseRequest.post("/faucet", { walletId, chain }, DISABLE_AXIOS_RETRY_CONFIG).then((res) => res.data).finally(() => {
|
|
428
|
+
this.inFlightFaucetRequests.delete(requestKey);
|
|
429
|
+
});
|
|
430
|
+
this.inFlightFaucetRequests.set(requestKey, request);
|
|
431
|
+
return yield request;
|
|
402
432
|
});
|
|
403
433
|
this.issueJwt = (..._0) => __async(this, [..._0], function* ({ keyIndex = 0 } = {}) {
|
|
404
434
|
const res = yield this.baseRequest.post(`/auth/jwt`, { keyIndex });
|
|
@@ -529,7 +559,12 @@ class Client {
|
|
|
529
559
|
});
|
|
530
560
|
return { success: res.data.success };
|
|
531
561
|
});
|
|
532
|
-
const headers = __spreadValues(__spreadValues(__spreadValues({}, apiKey && { [API_KEY_HEADER_NAME]: apiKey }), partnerId && { [PARTNER_ID_HEADER_NAME]: partnerId }), partnerConfigOverride && { [PARTNER_CONFIG_OVERRIDE_HEADER_NAME]: JSON.stringify(partnerConfigOverride) })
|
|
562
|
+
const headers = __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, apiKey && { [API_KEY_HEADER_NAME]: apiKey }), partnerId && { [PARTNER_ID_HEADER_NAME]: partnerId }), partnerConfigOverride && { [PARTNER_CONFIG_OVERRIDE_HEADER_NAME]: JSON.stringify(partnerConfigOverride) }), {
|
|
563
|
+
// Opts into structured-JSON error responses for OTP error classes (server-side
|
|
564
|
+
// contract added in @getpara/shared 1.16.0). Without it the server falls back to
|
|
565
|
+
// plain-text bodies for backward compat with older SDKs.
|
|
566
|
+
[STRUCTURED_ERRORS_HEADER]: "1"
|
|
567
|
+
});
|
|
533
568
|
const axiosConfig = {
|
|
534
569
|
baseURL: userManagementHost,
|
|
535
570
|
withCredentials: true,
|
|
@@ -575,6 +610,19 @@ class Client {
|
|
|
575
610
|
if (version) {
|
|
576
611
|
config.headers.set(VERSION_HEADER_NAME, version);
|
|
577
612
|
}
|
|
613
|
+
const g = globalThis;
|
|
614
|
+
const isBrowserMainThread = typeof g.window !== "undefined" && typeof g.WorkerGlobalScope === "undefined";
|
|
615
|
+
if (staticTraceContext) {
|
|
616
|
+
for (const [key, value] of Object.entries(staticTraceContext)) {
|
|
617
|
+
config.headers.set(key, value);
|
|
618
|
+
}
|
|
619
|
+
} else if (!isBrowserMainThread) {
|
|
620
|
+
propagation.inject(context.active(), config.headers, {
|
|
621
|
+
set: (carrier, key, value) => {
|
|
622
|
+
carrier.set(key, value);
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
}
|
|
578
626
|
return config;
|
|
579
627
|
});
|
|
580
628
|
if (opts == null ? void 0 : opts.useFetchAdapter) {
|
|
@@ -676,7 +724,7 @@ class Client {
|
|
|
676
724
|
return __async(this, null, function* () {
|
|
677
725
|
var _f = _e, { userId } = _f, rest = __objRest(_f, ["userId"]);
|
|
678
726
|
const res = yield this.baseRequest.post(`/users/${userId}/resend-verification-code`, rest);
|
|
679
|
-
return res;
|
|
727
|
+
return res.data;
|
|
680
728
|
});
|
|
681
729
|
}
|
|
682
730
|
// POST '/users/:userId/resend-verification-code-by-phone
|
package/dist/esm/error.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./chunk-BBZEL7EG.js";
|
|
2
|
-
function ParaApiError(message, code, status, responseURL) {
|
|
2
|
+
function ParaApiError(message, code, status, responseURL, data) {
|
|
3
3
|
Error.call(this);
|
|
4
4
|
if (Error.captureStackTrace) {
|
|
5
5
|
Error.captureStackTrace(this, this.constructor);
|
|
@@ -11,6 +11,7 @@ function ParaApiError(message, code, status, responseURL) {
|
|
|
11
11
|
code && (this.code = code);
|
|
12
12
|
status && (this.status = status);
|
|
13
13
|
responseURL && (this.responseURL = responseURL);
|
|
14
|
+
data && (this.data = data);
|
|
14
15
|
}
|
|
15
16
|
const prototype = ParaApiError.prototype;
|
|
16
17
|
Object.defineProperty(prototype, "isParaApiError", { value: true });
|
package/dist/types/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosError, AxiosResponse } from 'axios';
|
|
2
|
-
import { AccountMetadata, Auth, AuthIdentifier, AuthMethod, BackupKitEmailProps, BiometricLocationHint, Chain, CurrentWalletIds, EncryptedKeyShare, EncryptorType, ExternalWalletInfo, LoginExternalWalletResponse, KeyShareType, Network, OnRampAsset, OnRampConfig, OnRampProvider, OnRampPurchase, OnRampPurchaseCreateParams, OnRampPurchaseUpdateParams, AuthMethodStatus, PregenIds, PrimaryAuth, PublicKeyType, ServerAuthStateSignup, SessionInfo, Setup2faResponse, SignUpOrLogInResponse, TelegramAuthResponse, TPregenIdentifierType, VerificationEmailProps, VerifiedAuth, VerifyFarcasterResponse, VerifyTelegramResponse, VerifyThirdPartyAuth, WalletEntity, WalletParams, TWalletScheme, TWalletType, VerifyExternalWalletParams, IssueJwtParams, IssueJwtResponse, LinkAccountParams, LinkedAccounts, ResendVerificationCodeParams, AssetMetadataIndexed, GetProfileBalanceParams, ProfileBalance, LegacyAuthMethod, PrimaryAuthInfo, ServerAuthStateLogin, ServerAuthStateDone, UserPreferences, EstimateTransactionOpts, EstimateTransactionResult, BroadcastTransactionOpts, BroadcastTransactionResult, TExternalWalletType, GetPendingTransactionResponse } from '@getpara/shared';
|
|
2
|
+
import { AccountMetadata, Auth, AuthIdentifier, AuthMethod, BackupKitEmailProps, BiometricLocationHint, Chain, CurrentWalletIds, EncryptedKeyShare, EncryptorType, ExternalWalletInfo, LoginExternalWalletResponse, KeyShareType, Network, OnRampAsset, OnRampConfig, OnRampProvider, OnRampPurchase, OnRampPurchaseCreateParams, OnRampPurchaseUpdateParams, AuthMethodStatus, PregenIds, PrimaryAuth, PublicKeyType, ServerAuthStateSignup, SessionInfo, Setup2faResponse, SignUpOrLogInResponse, TelegramAuthResponse, TPregenIdentifierType, VerificationEmailProps, VerifiedAuth, VerifyFarcasterResponse, VerifyTelegramResponse, VerifyThirdPartyAuth, WalletEntity, WalletParams, TWalletScheme, TWalletType, VerifyExternalWalletParams, IssueJwtParams, IssueJwtResponse, LinkAccountParams, LinkedAccounts, ResendVerificationCodeParams, AssetMetadataIndexed, GetProfileBalanceParams, ProfileBalance, DeliveryChannel, LegacyAuthMethod, PrimaryAuthInfo, ServerAuthStateLogin, ServerAuthStateDone, UserPreferences, EstimateTransactionOpts, EstimateTransactionResult, BroadcastTransactionOpts, BroadcastTransactionResult, TExternalWalletType, GetPendingTransactionResponse } from '@getpara/shared';
|
|
3
3
|
interface ConfigOpts {
|
|
4
4
|
useFetchAdapter?: boolean;
|
|
5
5
|
}
|
|
@@ -13,6 +13,15 @@ type ClientConfig = {
|
|
|
13
13
|
persistSessionCookie?: (cookie: string) => void;
|
|
14
14
|
/** E2E only: partner config overrides sent via X-Partner-Config-Override header. */
|
|
15
15
|
partnerConfigOverride?: Record<string, unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* Pre-captured W3C Trace Context headers (traceparent / tracestate) injected
|
|
18
|
+
* onto every outgoing request. Used by the MPC worker — it has no OTel SDK
|
|
19
|
+
* and no shared async context with the main thread, so the parent inject's
|
|
20
|
+
* carrier is passed across postMessage and threaded in here. main-thread
|
|
21
|
+
* callers leave this undefined and rely on the OTel-driven request
|
|
22
|
+
* interceptor that pulls from context.active().
|
|
23
|
+
*/
|
|
24
|
+
staticTraceContext?: Record<string, string>;
|
|
16
25
|
};
|
|
17
26
|
interface createUserIdRes {
|
|
18
27
|
protocolId: string;
|
|
@@ -94,6 +103,7 @@ interface RequestFaucetBody {
|
|
|
94
103
|
chain?: string;
|
|
95
104
|
}
|
|
96
105
|
interface RequestFaucetRes {
|
|
106
|
+
/** Hash for the submitted faucet transaction. Wait for confirmation before assuming funds are spendable. */
|
|
97
107
|
transactionHash: string;
|
|
98
108
|
amount: string;
|
|
99
109
|
chain: string;
|
|
@@ -158,7 +168,8 @@ export declare const handleResponseError: (error: any) => never;
|
|
|
158
168
|
export declare const isRetryableError: (error: AxiosError) => boolean;
|
|
159
169
|
declare class Client {
|
|
160
170
|
private baseRequest;
|
|
161
|
-
|
|
171
|
+
private inFlightFaucetRequests;
|
|
172
|
+
constructor({ userManagementHost, apiKey, partnerId, version, opts, retrieveSessionCookie, persistSessionCookie, partnerConfigOverride, staticTraceContext, }: ClientConfig);
|
|
162
173
|
signUpOrLogIn: (body: VerifiedAuth & VerificationEmailProps) => Promise<SignUpOrLogInResponse>;
|
|
163
174
|
/**
|
|
164
175
|
* @deprecated
|
|
@@ -176,9 +187,13 @@ declare class Client {
|
|
|
176
187
|
chainId?: string;
|
|
177
188
|
uri?: string;
|
|
178
189
|
}) => Promise<LoginExternalWalletResponse>;
|
|
179
|
-
verifyAccount: (userId: string, body: verifyBody) => Promise<ServerAuthStateSignup | ServerAuthStateLogin | ServerAuthStateDone>;
|
|
190
|
+
verifyAccount: (userId: string, body: verifyBody, traceCarrier?: Record<string, string>) => Promise<ServerAuthStateSignup | ServerAuthStateLogin | ServerAuthStateDone>;
|
|
180
191
|
sendLoginVerificationCode: (auth: PrimaryAuthInfo, isRecovery?: boolean) => Promise<{
|
|
181
192
|
userId: string;
|
|
193
|
+
deliveryChannel?: DeliveryChannel;
|
|
194
|
+
fallbackUsed?: boolean;
|
|
195
|
+
fallbackChannel?: DeliveryChannel;
|
|
196
|
+
isSmsAllowed?: boolean;
|
|
182
197
|
}>;
|
|
183
198
|
getLinkedAccounts: ({ userId, withMetadata, }: {
|
|
184
199
|
userId: string;
|
|
@@ -253,20 +268,16 @@ declare class Client {
|
|
|
253
268
|
getSessionChallenge: (userId: string) => Promise<any>;
|
|
254
269
|
verifySessionChallenge: (userId: string, body: verifySessionChallengeBody) => Promise<any>;
|
|
255
270
|
createWallet: (userId: string, body?: createWalletBody) => Promise<createWalletRes>;
|
|
256
|
-
/** @deprecated Use the REST API (`POST /v1/wallets`) instead. See https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen */
|
|
257
271
|
createPregenWallet: (body?: createPregenWalletBody) => Promise<createWalletRes>;
|
|
258
|
-
/** @deprecated Use the REST API (`GET /v1/wallets`) instead. See https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen */
|
|
259
272
|
getPregenWallets: (pregenIds: PregenIds, isPortal?: boolean, userId?: string) => Promise<{
|
|
260
273
|
wallets: WalletEntity[];
|
|
261
274
|
}>;
|
|
262
|
-
/** @deprecated Use the REST API (`POST /v1/wallets`) instead. See https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen */
|
|
263
275
|
claimPregenWallets: (body?: claimPreGenWalletsBody) => Promise<{
|
|
264
276
|
walletIds: string[];
|
|
265
277
|
}>;
|
|
266
278
|
sendTransaction: (userId: string, walletId: string, body: sendTransactionBody) => Promise<any>;
|
|
267
279
|
signTransaction: (userId: string, walletId: string, body: signTransactionBody) => Promise<any>;
|
|
268
280
|
refreshKeys: (userId: string, walletId: string, oldPartnerId?: string, newPartnerId?: string, keyShareProtocolId?: string) => Promise<any>;
|
|
269
|
-
/** @deprecated Use the REST API (`PATCH /v1/wallets/:id`) instead. See https://docs.getpara.com/v2/rest/migrate-from-sdk-pregen */
|
|
270
281
|
updatePregenWallet: (walletId: string, body: updatePregenWalletBody) => Promise<any>;
|
|
271
282
|
getWallets: (userId: string, includePartnerData?: boolean) => Promise<AxiosResponse<GetWalletsRes, any>>;
|
|
272
283
|
getAllWallets: (userId: string) => Promise<AxiosResponse<GetWalletsRes, any>>;
|
|
@@ -296,7 +307,12 @@ declare class Client {
|
|
|
296
307
|
getTransmissionKeyshares(userId: string, sessionLookupId: string): Promise<any>;
|
|
297
308
|
getParaShare: (userId: string, walletId: string) => Promise<string>;
|
|
298
309
|
getBackupKit: (userId: string, walletId: string) => Promise<any>;
|
|
299
|
-
resendVerificationCode({ userId, ...rest }: ResendVerificationCodeParams): Promise<
|
|
310
|
+
resendVerificationCode({ userId, ...rest }: ResendVerificationCodeParams): Promise<{
|
|
311
|
+
deliveryChannel?: DeliveryChannel;
|
|
312
|
+
fallbackUsed?: boolean;
|
|
313
|
+
fallbackChannel?: DeliveryChannel;
|
|
314
|
+
isSmsAllowed?: boolean;
|
|
315
|
+
}>;
|
|
300
316
|
resendVerificationCodeByPhone({ userId, ...rest }: {
|
|
301
317
|
userId: string;
|
|
302
318
|
} & VerificationEmailProps): Promise<AxiosResponse<any, any>>;
|
package/dist/types/error.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function ParaApiError(message: string, code?: string, status?: number, responseURL?: string): void;
|
|
1
|
+
export declare function ParaApiError(message: string, code?: string, status?: number, responseURL?: string, data?: Record<string, unknown>): void;
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/user-management-client",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@getpara/shared": "^1.
|
|
5
|
+
"@getpara/shared": "^1.21.0",
|
|
6
|
+
"@opentelemetry/api": "^1.9.1",
|
|
6
7
|
"axios": "^1.8.4",
|
|
7
8
|
"axios-retry": "^4.5.0",
|
|
8
9
|
"libphonenumber-js": "^1.11.7"
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
"dist",
|
|
22
23
|
"package.json"
|
|
23
24
|
],
|
|
24
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "e6c42e42adfcfadb0114b1ac65ba5203e6274712",
|
|
25
26
|
"main": "dist/cjs/index.js",
|
|
26
27
|
"module": "dist/esm/index.js",
|
|
27
28
|
"scripts": {
|