@getpara/user-management-client 1.7.1 → 1.8.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.
@@ -0,0 +1,927 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __objRest = (source, exclude) => {
25
+ var target = {};
26
+ for (var prop in source)
27
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
28
+ target[prop] = source[prop];
29
+ if (source != null && __getOwnPropSymbols)
30
+ for (var prop of __getOwnPropSymbols(source)) {
31
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
32
+ target[prop] = source[prop];
33
+ }
34
+ return target;
35
+ };
36
+ var __export = (target, all) => {
37
+ for (var name in all)
38
+ __defProp(target, name, { get: all[name], enumerable: true });
39
+ };
40
+ var __copyProps = (to, from, except, desc) => {
41
+ if (from && typeof from === "object" || typeof from === "function") {
42
+ for (let key of __getOwnPropNames(from))
43
+ if (!__hasOwnProp.call(to, key) && key !== except)
44
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
45
+ }
46
+ return to;
47
+ };
48
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
49
+ // If the importer is in node compatibility mode or this is not an ESM
50
+ // file that has been converted to a CommonJS file using a Babel-
51
+ // compatible transform (i.e. "__esModule" has not been set), then set
52
+ // "default" to the CommonJS "module.exports" for node compatibility.
53
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
54
+ mod
55
+ ));
56
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
57
+ var __async = (__this, __arguments, generator) => {
58
+ return new Promise((resolve, reject) => {
59
+ var fulfilled = (value) => {
60
+ try {
61
+ step(generator.next(value));
62
+ } catch (e) {
63
+ reject(e);
64
+ }
65
+ };
66
+ var rejected = (value) => {
67
+ try {
68
+ step(generator.throw(value));
69
+ } catch (e) {
70
+ reject(e);
71
+ }
72
+ };
73
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
74
+ step((generator = generator.apply(__this, __arguments)).next());
75
+ });
76
+ };
77
+ var client_exports = {};
78
+ __export(client_exports, {
79
+ default: () => client_default,
80
+ handleResponseError: () => handleResponseError,
81
+ handleResponseSuccess: () => handleResponseSuccess
82
+ });
83
+ module.exports = __toCommonJS(client_exports);
84
+ var import_axios = __toESM(require("axios"));
85
+ var import_qs = __toESM(require("qs"));
86
+ var import_utils = require("./utils.js");
87
+ var import_consts = require("./consts.js");
88
+ var import_error = require("./error.js");
89
+ const handleResponseSuccess = (response) => {
90
+ if (response.status === 200) {
91
+ return response;
92
+ }
93
+ throw new import_error.ParaApiError("Invalid status code");
94
+ };
95
+ const handleResponseError = (error) => {
96
+ var _a, _b, _c;
97
+ if (error === null) throw new import_error.ParaApiError("Error is null");
98
+ if (import_axios.default.isAxiosError(error)) {
99
+ let message = (_b = (_a = error.response) == null ? void 0 : _a.data) != null ? _b : "Unknown error";
100
+ if (error.code === "ERR_NETWORK") {
101
+ message = "Connection error";
102
+ } else if (error.code === "ERR_CANCELED") {
103
+ message = "Connection canceled";
104
+ }
105
+ throw new import_error.ParaApiError(message, error.code, error.response.status, (_c = error.request) == null ? void 0 : _c.responseURL);
106
+ }
107
+ throw new import_error.ParaApiError("Unknown error");
108
+ };
109
+ class Client {
110
+ constructor({
111
+ userManagementHost,
112
+ apiKey,
113
+ partnerId,
114
+ version,
115
+ opts,
116
+ retrieveSessionCookie,
117
+ persistSessionCookie
118
+ }) {
119
+ this.createUser = (body) => __async(this, null, function* () {
120
+ const res = yield this.baseRequest.post(`/users`, body);
121
+ return res.data;
122
+ });
123
+ this.checkUserExists = (auth) => __async(this, null, function* () {
124
+ const res = yield this.baseRequest.get("/users/exists", {
125
+ params: __spreadValues({}, auth)
126
+ });
127
+ return res;
128
+ });
129
+ this.verifyTelegram = (authObject) => __async(this, null, function* () {
130
+ return (yield this.baseRequest.post("/users/telegram", {
131
+ authObject
132
+ })).data;
133
+ });
134
+ this.externalWalletLogin = (body) => __async(this, null, function* () {
135
+ const res = yield this.baseRequest.post(`/users/external-wallets/login`, body);
136
+ return res.data;
137
+ });
138
+ // POST /users/:userId/verify-email
139
+ this.verifyEmail = (userId, body) => __async(this, null, function* () {
140
+ const res = yield this.baseRequest.post(`/users/${userId}/verify-email`, body);
141
+ return res;
142
+ });
143
+ this.verifyPhone = (userId, body) => __async(this, null, function* () {
144
+ const res = yield this.baseRequest.post(`/users/${userId}/verify-identifier`, body);
145
+ return res;
146
+ });
147
+ this.verifyExternalWallet = (userId, body) => __async(this, null, function* () {
148
+ const res = yield this.baseRequest.post(`/users/${userId}/external-wallets/verify`, body);
149
+ return res;
150
+ });
151
+ // POST /users/:userId/biometrics/key
152
+ this.addSessionPublicKey = (userId, body) => __async(this, null, function* () {
153
+ const res = yield this.baseRequest.post(`/users/${userId}/biometrics/key`, body);
154
+ return res;
155
+ });
156
+ // GET /users/:userId/biometrics/keys
157
+ this.getSessionPublicKeys = (userId) => __async(this, null, function* () {
158
+ const res = yield this.baseRequest.get(`/users/${userId}/biometrics/keys`);
159
+ return res;
160
+ });
161
+ // GET /biometrics/location-hints
162
+ this.getBiometricLocationHints = (params) => __async(this, null, function* () {
163
+ const res = yield this.baseRequest.get(`/biometrics/location-hints`, { params });
164
+ return res.data.hints;
165
+ });
166
+ // GET /users/:userId/biometrics/:biometricId
167
+ this.getSessionPublicKey = (userId, biometricId) => __async(this, null, function* () {
168
+ const res = yield this.baseRequest.get(`/users/${userId}/biometrics/${biometricId}`);
169
+ return res;
170
+ });
171
+ // PATCH /users/:userId/biometrics/:biometricId
172
+ this.patchSessionPublicKey = (partnerId, userId, biometricId, body) => __async(this, null, function* () {
173
+ const res = yield this.baseRequest.patch(`/users/${userId}/biometrics/${biometricId}`, body, {
174
+ headers: {
175
+ [import_consts.PARTNER_ID_HEADER_NAME]: partnerId
176
+ }
177
+ });
178
+ return res;
179
+ });
180
+ // GET /biometrics/challenge?email&publicKey
181
+ this.getWebChallenge = (auth) => __async(this, null, function* () {
182
+ const res = yield this.baseRequest.get("/biometrics/challenge", {
183
+ params: __spreadValues({}, auth || {})
184
+ });
185
+ return res.data;
186
+ });
187
+ // POST /touch
188
+ this.touchSession = (regenerate) => __async(this, null, function* () {
189
+ const res = yield this.baseRequest.post(
190
+ `/touch?regenerate=${!!regenerate}`
191
+ );
192
+ return res;
193
+ });
194
+ // GET /session/origin
195
+ this.sessionOrigin = (sessionLookupId) => __async(this, null, function* () {
196
+ const res = yield this.baseRequest.get(`/sessions/${sessionLookupId}/origin`);
197
+ return res.data;
198
+ });
199
+ // POST /biometrics/verify
200
+ this.verifyWebChallenge = (partnerId, body) => __async(this, null, function* () {
201
+ const res = yield this.baseRequest.post(`/biometrics/verify`, body, {
202
+ headers: {
203
+ [import_consts.PARTNER_ID_HEADER_NAME]: partnerId
204
+ }
205
+ });
206
+ return res;
207
+ });
208
+ // GET /users/:userId/biometrics/challenge
209
+ this.getSessionChallenge = (userId) => __async(this, null, function* () {
210
+ const res = yield this.baseRequest.get(`/users/${userId}/biometrics/challenge`);
211
+ return res;
212
+ });
213
+ // POST /users/:userId/biometrics/verify
214
+ this.verifySessionChallenge = (userId, body) => __async(this, null, function* () {
215
+ const res = yield this.baseRequest.post(`/users/${userId}/biometrics/verify`, body);
216
+ return res;
217
+ });
218
+ // POST /users/:userId/wallets
219
+ this.createWallet = (userId, body) => __async(this, null, function* () {
220
+ const res = yield this.baseRequest.post(`/users/${userId}/wallets`, body);
221
+ return res.data;
222
+ });
223
+ // POST /wallets/pregen
224
+ this.createPregenWallet = (body) => __async(this, null, function* () {
225
+ const res = yield this.baseRequest.post(`/wallets/pregen`, body);
226
+ return res.data;
227
+ });
228
+ // GET /wallets/pregen?pregenIdentifier={pregenIdentifier}&pregenIdentifierType={pregenIdentifierType}
229
+ this.getPregenWallets = (pregenIds, isPortal = false, userId) => __async(this, null, function* () {
230
+ const res = yield this.baseRequest.get("/wallets/pregen", {
231
+ params: { ids: pregenIds, expand: isPortal, userId }
232
+ });
233
+ return res.data;
234
+ });
235
+ // POST /wallets/pregen/claim
236
+ this.claimPregenWallets = (body) => __async(this, null, function* () {
237
+ const res = yield this.baseRequest.post(`/wallets/pregen/claim`, body);
238
+ return res.data;
239
+ });
240
+ // POST /users/:userId/wallets/:walletId/transactions/send
241
+ this.sendTransaction = (userId, walletId, body) => __async(this, null, function* () {
242
+ const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/transactions/send`, body);
243
+ return res;
244
+ });
245
+ // functionality changed to only sign transactions and not send them
246
+ // POST /users/:userId/wallets/:walletId/transactions/sign
247
+ this.signTransaction = (userId, walletId, body) => __async(this, null, function* () {
248
+ const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/transactions/sign`, body);
249
+ return res;
250
+ });
251
+ // POST /users/:userId/wallets/:walletId/refresh
252
+ this.refreshKeys = (userId, walletId, oldPartnerId, newPartnerId, keyShareProtocolId) => __async(this, null, function* () {
253
+ const body = { oldPartnerId, newPartnerId, keyShareProtocolId };
254
+ const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/refresh`, body);
255
+ return res;
256
+ });
257
+ // PATCH /wallets/pregen/:walletId
258
+ this.updatePregenWallet = (walletId, body) => __async(this, null, function* () {
259
+ const res = yield this.baseRequest.patch(`/wallets/pregen/${walletId}`, body);
260
+ return res.data;
261
+ });
262
+ // GET /users/:userId/wallets
263
+ this.getWallets = (userId, includePartnerData) => __async(this, null, function* () {
264
+ const res = yield this.baseRequest.get(
265
+ `/users/${userId}/wallets${includePartnerData ? `?includePartnerData=${encodeURIComponent(includePartnerData)}` : ""}`
266
+ );
267
+ return res;
268
+ });
269
+ // GET /users/:userId/all-wallets
270
+ this.getAllWallets = (userId) => __async(this, null, function* () {
271
+ const res = yield this.baseRequest.get(`/users/${userId}/all-wallets`);
272
+ return res;
273
+ });
274
+ // POST /users/:userId/wallets/set
275
+ this.setCurrentWalletIds = (userId, walletIds, needsWallet = false, sessionLookupId, newDeviceSessionLookupId) => __async(this, null, function* () {
276
+ const res = yield this.baseRequest.post(`/users/${userId}/wallets/set`, {
277
+ walletIds,
278
+ needsWallet,
279
+ sessionLookupId,
280
+ newDeviceSessionLookupId
281
+ });
282
+ return res;
283
+ });
284
+ // POST /login
285
+ this.login = (props) => __async(this, null, function* () {
286
+ const body = props;
287
+ const res = yield this.baseRequest.post("/login", body);
288
+ return res;
289
+ });
290
+ // POST /login
291
+ this.verifyLogin = (verificationCode) => __async(this, null, function* () {
292
+ const body = { verificationCode };
293
+ const res = yield this.baseRequest.post("/login/verify-email", body);
294
+ return res;
295
+ });
296
+ // GET /logout
297
+ this.logout = () => __async(this, null, function* () {
298
+ const res = yield this.baseRequest.get("/logout");
299
+ return res;
300
+ });
301
+ // POST /recovery/verification
302
+ this.recoveryVerification = (email, verificationCode) => __async(this, null, function* () {
303
+ const body = { email, verificationCode };
304
+ const res = yield this.baseRequest.post("/recovery/verification", body);
305
+ return res;
306
+ });
307
+ // POST /recovery
308
+ this.recoveryInit = (email) => __async(this, null, function* () {
309
+ const body = { email };
310
+ const res = yield this.baseRequest.post("/recovery", body);
311
+ return res;
312
+ });
313
+ this.preSignMessage = (userId, walletId, message, scheme, cosmosSignDoc) => __async(this, null, function* () {
314
+ const body = { message, scheme, cosmosSignDoc };
315
+ const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/messages/sign`, body);
316
+ return res.data;
317
+ });
318
+ //DELETE /users/:userId
319
+ this.deleteSelf = (userId) => __async(this, null, function* () {
320
+ const res = yield this.baseRequest.delete(`/users/${userId}`);
321
+ return res;
322
+ });
323
+ // GET /users/:userId/wallets/:walletId/capsule-share
324
+ this.getParaShare = (userId, walletId) => __async(this, null, function* () {
325
+ const res = yield this.baseRequest.get(`/users/${userId}/wallets/${walletId}/capsule-share`);
326
+ return res.data.share;
327
+ });
328
+ // GET /users/:userId/wallets/:walletId/download-backup-kit
329
+ this.getBackupKit = (userId, walletId) => __async(this, null, function* () {
330
+ const res = yield this.baseRequest.get(`/users/${userId}/wallets/${walletId}/download-backup-kit`, {
331
+ responseType: "blob"
332
+ });
333
+ return res;
334
+ });
335
+ // PATCH /users/:userId/biometrics/:biometricId
336
+ this.patchSessionPassword = (partnerId, userId, passwordId, body) => __async(this, null, function* () {
337
+ const res = yield this.baseRequest.patch(`/users/${userId}/passwords/${passwordId}`, body, {
338
+ headers: {
339
+ [import_consts.PARTNER_ID_HEADER_NAME]: partnerId
340
+ }
341
+ });
342
+ return res;
343
+ });
344
+ // GET /users/:userId/wallets/:walletId/balance
345
+ this.getWalletBalance = (_0) => __async(this, [_0], function* ({
346
+ userId,
347
+ walletId,
348
+ rpcUrl
349
+ }) {
350
+ const res = yield this.baseRequest.get(`/users/${userId}/wallets/${walletId}/balance`, {
351
+ params: {
352
+ rpcUrl
353
+ }
354
+ });
355
+ return res.data;
356
+ });
357
+ const headers = __spreadValues(__spreadValues({}, apiKey && { [import_consts.API_KEY_HEADER_NAME]: apiKey }), partnerId && { [import_consts.PARTNER_ID_HEADER_NAME]: partnerId });
358
+ const axiosConfig = {
359
+ baseURL: userManagementHost,
360
+ withCredentials: true,
361
+ headers
362
+ };
363
+ if (retrieveSessionCookie) {
364
+ const defaultTransformRequest = Array.isArray(import_axios.default.defaults.transformRequest) ? import_axios.default.defaults.transformRequest : [import_axios.default.defaults.transformRequest];
365
+ axiosConfig.transformRequest = [
366
+ function(data, headers2) {
367
+ const currentSessionCookie = retrieveSessionCookie();
368
+ if (currentSessionCookie) {
369
+ headers2[import_consts.SESSION_COOKIE_HEADER_NAME] = currentSessionCookie;
370
+ }
371
+ if (version) {
372
+ headers2[import_consts.VERSION_HEADER_NAME] = version;
373
+ }
374
+ return data;
375
+ },
376
+ ...defaultTransformRequest
377
+ ];
378
+ }
379
+ if (persistSessionCookie) {
380
+ const defaultTransformResponse = Array.isArray(import_axios.default.defaults.transformResponse) ? import_axios.default.defaults.transformResponse : [import_axios.default.defaults.transformResponse];
381
+ axiosConfig.transformResponse = [
382
+ ...defaultTransformResponse,
383
+ function(data, headers2, _status) {
384
+ if (headers2 == null ? void 0 : headers2[import_consts.SESSION_COOKIE_HEADER_NAME]) {
385
+ persistSessionCookie(headers2[import_consts.SESSION_COOKIE_HEADER_NAME]);
386
+ }
387
+ return data;
388
+ }
389
+ ];
390
+ }
391
+ this.baseRequest = import_axios.default.create(axiosConfig);
392
+ if (opts == null ? void 0 : opts.useFetchAdapter) {
393
+ import_axios.default.defaults.adapter = function(config) {
394
+ return fetch(config.baseURL + config.url.substring(1), {
395
+ method: config.method,
396
+ headers: config.headers,
397
+ body: config.data,
398
+ credentials: config.withCredentials ? "include" : void 0
399
+ }).then(
400
+ (response) => response.text().then((text) => ({
401
+ data: text,
402
+ status: response.status,
403
+ statusText: response.statusText,
404
+ headers: response.headers,
405
+ config,
406
+ request: fetch
407
+ }))
408
+ ).catch(function(reason) {
409
+ throw reason;
410
+ });
411
+ };
412
+ }
413
+ this.baseRequest.interceptors.response.use(handleResponseSuccess, handleResponseError);
414
+ }
415
+ // DEPRECATED: use uploadUserKeyShares instead
416
+ // POST /users/:userId/wallets/:walletId/key-shares
417
+ uploadKeyshares(userId, walletId, encryptedKeyshares) {
418
+ return __async(this, null, function* () {
419
+ const body = { keyShares: encryptedKeyshares };
420
+ const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/key-shares`, body);
421
+ return res;
422
+ });
423
+ }
424
+ // POST /users/:userId/key-shares
425
+ uploadUserKeyShares(userId, encryptedKeyshares) {
426
+ return __async(this, null, function* () {
427
+ const body = { keyShares: encryptedKeyshares };
428
+ const res = yield this.baseRequest.post(`/users/${userId}/key-shares`, body);
429
+ return res;
430
+ });
431
+ }
432
+ // GET /users/:userId/wallets/:walletId/key-shares
433
+ getKeyshare(userId, walletId, type, encryptor) {
434
+ return __async(this, null, function* () {
435
+ const res = yield this.baseRequest.get(
436
+ `/users/${userId}/wallets/${walletId}/key-shares?type=${type}${encryptor ? `&encryptor=${encryptor}` : ""}`
437
+ );
438
+ return res;
439
+ });
440
+ }
441
+ // GET /users/:userId/biometrics/key-shares
442
+ getBiometricKeyshares(userId, biometricPublicKey, getAll) {
443
+ return __async(this, null, function* () {
444
+ const res = yield this.baseRequest.get(
445
+ `/users/${userId}/biometrics/key-shares?publicKey=${biometricPublicKey}&all=${!!getAll}`
446
+ );
447
+ return res;
448
+ });
449
+ }
450
+ // GET /users/:userId/key-shares
451
+ getPasswordKeyshares(userId, passwordId, getAll) {
452
+ return __async(this, null, function* () {
453
+ const res = yield this.baseRequest.get(
454
+ `/users/${userId}/passwords/key-shares?passwordId=${passwordId}&all=${!!getAll}`
455
+ );
456
+ return res;
457
+ });
458
+ }
459
+ // POST '/users/:userId/temporary-shares',
460
+ uploadTransmissionKeyshares(userId, shares) {
461
+ return __async(this, null, function* () {
462
+ const body = { shares };
463
+ const res = yield this.baseRequest.post(`/users/${userId}/temporary-shares`, body);
464
+ return res;
465
+ });
466
+ }
467
+ // GET /users/:userId/temporary-shares returns { temporaryShares: { userId: string, walletId: string, encryptedShare: string, encryptedKey?: string }[] }
468
+ getTransmissionKeyshares(userId, sessionLookupId) {
469
+ return __async(this, null, function* () {
470
+ const res = yield this.baseRequest.get(`/users/${userId}/temporary-shares?sessionLookupId=${sessionLookupId}`);
471
+ return res;
472
+ });
473
+ }
474
+ // POST '/users/:userId/resend-verification-code
475
+ resendVerificationCode(_a) {
476
+ return __async(this, null, function* () {
477
+ var _b = _a, { userId } = _b, rest = __objRest(_b, ["userId"]);
478
+ const res = yield this.baseRequest.post(`/users/${userId}/resend-verification-code`, rest);
479
+ return res;
480
+ });
481
+ }
482
+ // POST '/users/:userId/resend-verification-code-by-phone
483
+ resendVerificationCodeByPhone(_c) {
484
+ return __async(this, null, function* () {
485
+ var _d = _c, { userId } = _d, rest = __objRest(_d, ["userId"]);
486
+ const res = yield this.baseRequest.post(`/users/${userId}/resend-verification-code-by-phone`, rest);
487
+ return res;
488
+ });
489
+ }
490
+ // POST recovery/cancel
491
+ cancelRecoveryAttempt(email) {
492
+ return __async(this, null, function* () {
493
+ const res = yield this.baseRequest.post(`/recovery/cancel`, { email });
494
+ return res;
495
+ });
496
+ }
497
+ // GET '/2fa/users/:userId/check-status'
498
+ check2FAStatus(userId) {
499
+ return __async(this, null, function* () {
500
+ const res = yield this.baseRequest.get(`/2fa/users/${userId}/check-status`);
501
+ return res;
502
+ });
503
+ }
504
+ // POST '/2fa/users/:userId/enable'
505
+ enable2FA(userId, verificationCode) {
506
+ return __async(this, null, function* () {
507
+ const res = yield this.baseRequest.post(`/2fa/users/${userId}/enable`, { verificationCode });
508
+ return res;
509
+ });
510
+ }
511
+ // POST '/2fa/users/:userId/setup'
512
+ setup2FA(userId) {
513
+ return __async(this, null, function* () {
514
+ const res = yield this.baseRequest.post(`/2fa/users/${userId}/setup`);
515
+ return res;
516
+ });
517
+ }
518
+ // POST /recovery/init
519
+ initializeRecovery(email) {
520
+ return __async(this, null, function* () {
521
+ const res = yield this.baseRequest.post(`/recovery/init`, { email });
522
+ return res;
523
+ });
524
+ }
525
+ // POST /auth/farcaster/init
526
+ initializeFarcasterLogin() {
527
+ return __async(this, null, function* () {
528
+ const res = yield this.baseRequest.post(`/auth/farcaster/init`);
529
+ return res;
530
+ });
531
+ }
532
+ // POST /auth/farcaster/status
533
+ getFarcasterAuthStatus() {
534
+ return __async(this, null, function* () {
535
+ const res = yield this.baseRequest.post(`/auth/farcaster/status`);
536
+ return res;
537
+ });
538
+ }
539
+ // POST /recovery/init
540
+ initializeRecoveryForPhone(phone, countryCode) {
541
+ return __async(this, null, function* () {
542
+ const res = yield this.baseRequest.post(`/recovery/init`, { phone, countryCode });
543
+ return res;
544
+ });
545
+ }
546
+ // POST /recovery/users/:userId/wallets/:walletId/finish
547
+ finalizeRecovery(userId, walletId) {
548
+ return __async(this, null, function* () {
549
+ const res = yield this.baseRequest.post(`/recovery/users/${userId}/wallets/${walletId}/finish`);
550
+ return res;
551
+ });
552
+ }
553
+ // GET /recovery/users/:userId/wallets/:walletId/key-shares
554
+ recoverUserShares(userId, walletId) {
555
+ return __async(this, null, function* () {
556
+ const res = yield this.baseRequest.get(`/recovery/users/${userId}/wallets/${walletId}/key-shares?type=USER&encryptor=RECOVERY`);
557
+ return res;
558
+ });
559
+ }
560
+ // POST /recovery/verify-email
561
+ verifyEmailForRecovery(email, verificationCode) {
562
+ return __async(this, null, function* () {
563
+ const body = { email, verificationCode };
564
+ const res = yield this.baseRequest.post(`/recovery/verify-email`, body);
565
+ return res;
566
+ });
567
+ }
568
+ // POST /recovery/verify-identifier
569
+ verifyPhoneForRecovery(phone, countryCode, verificationCode) {
570
+ return __async(this, null, function* () {
571
+ const body = { phone, countryCode, verificationCode };
572
+ const res = yield this.baseRequest.post(`/recovery/verify-identifier`, body);
573
+ return res;
574
+ });
575
+ }
576
+ // POST /2fa/verify
577
+ verify2FA(email, verificationCode) {
578
+ return __async(this, null, function* () {
579
+ const body = { email, verificationCode };
580
+ const res = yield this.baseRequest.post("/2fa/verify", body);
581
+ return res;
582
+ });
583
+ }
584
+ // POST /2fa/phone/verify
585
+ verify2FAForPhone(phone, countryCode, verificationCode) {
586
+ return __async(this, null, function* () {
587
+ const body = { phone, countryCode, verificationCode };
588
+ const res = yield this.baseRequest.post("/2fa/verify", body);
589
+ return res;
590
+ });
591
+ }
592
+ tempTrasmissionInit(message, userId) {
593
+ return __async(this, null, function* () {
594
+ const body = { message, userId };
595
+ const res = yield this.baseRequest.post("/temporary-transmissions", body);
596
+ return res;
597
+ });
598
+ }
599
+ tempTrasmission(id) {
600
+ return __async(this, null, function* () {
601
+ const res = yield this.baseRequest.get(`/temporary-transmissions/${id}`);
602
+ return res;
603
+ });
604
+ }
605
+ getPartner(partnerId) {
606
+ return __async(this, null, function* () {
607
+ const res = yield this.baseRequest.get(`/partners/${partnerId}`);
608
+ return res;
609
+ });
610
+ }
611
+ acceptScopes(userId, walletId, body) {
612
+ return __async(this, null, function* () {
613
+ const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/scopes/accept`, body);
614
+ return res;
615
+ });
616
+ }
617
+ getPendingTransaction(userId, pendingTransactionId) {
618
+ return __async(this, null, function* () {
619
+ const res = yield this.baseRequest.get(`/users/${userId}/pending-transactions/${pendingTransactionId}`);
620
+ return res;
621
+ });
622
+ }
623
+ acceptPendingTransaction(userId, pendingTransactionId) {
624
+ return __async(this, null, function* () {
625
+ const res = yield this.baseRequest.post(`/users/${userId}/pending-transactions/${pendingTransactionId}/accept`);
626
+ return res;
627
+ });
628
+ }
629
+ getOnRampConfig() {
630
+ return __async(this, null, function* () {
631
+ const res = yield this.baseRequest.get(`/on-ramp-config`);
632
+ return res.data;
633
+ });
634
+ }
635
+ createOnRampPurchase(_e) {
636
+ return __async(this, null, function* () {
637
+ var _f = _e, {
638
+ userId,
639
+ params: {
640
+ type,
641
+ walletType,
642
+ address,
643
+ provider,
644
+ networks,
645
+ assets,
646
+ defaultNetwork,
647
+ defaultAsset,
648
+ fiat,
649
+ fiatQuantity,
650
+ testMode = false
651
+ }
652
+ } = _f, params = __objRest(_f, [
653
+ "userId",
654
+ "params"
655
+ ]);
656
+ const [key, identifier] = (0, import_utils.extractWalletRef)(params);
657
+ const walletString = key === "walletId" ? `wallets/${identifier}` : `external-wallets/${identifier}`;
658
+ const res = yield this.baseRequest.post(`/users/${userId}/${walletString}/purchases`, {
659
+ type,
660
+ provider,
661
+ walletType,
662
+ address,
663
+ networks,
664
+ assets,
665
+ defaultAsset,
666
+ defaultNetwork,
667
+ fiat,
668
+ fiatQuantity,
669
+ testMode
670
+ });
671
+ return res.data;
672
+ });
673
+ }
674
+ updateOnRampPurchase(_g) {
675
+ return __async(this, null, function* () {
676
+ var _h = _g, {
677
+ userId,
678
+ purchaseId,
679
+ updates
680
+ } = _h, params = __objRest(_h, [
681
+ "userId",
682
+ "purchaseId",
683
+ "updates"
684
+ ]);
685
+ const [key, identifier] = (0, import_utils.extractWalletRef)(params);
686
+ const walletString = key === "walletId" ? `wallets/${identifier}` : `external-wallets/${identifier}`;
687
+ const res = yield this.baseRequest.patch(
688
+ `/users/${userId}/${walletString}/purchases/${purchaseId}`,
689
+ updates
690
+ );
691
+ return res.data;
692
+ });
693
+ }
694
+ getOnRampPurchase(_i) {
695
+ return __async(this, null, function* () {
696
+ var _j = _i, {
697
+ userId,
698
+ purchaseId
699
+ } = _j, params = __objRest(_j, [
700
+ "userId",
701
+ "purchaseId"
702
+ ]);
703
+ const [key, identifier] = (0, import_utils.extractWalletRef)(params);
704
+ const walletString = key === "walletId" ? `wallets/${identifier}` : `external-wallets/${identifier}`;
705
+ const res = yield this.baseRequest.get(`/users/${userId}/${walletString}/purchases/${purchaseId}`);
706
+ return res;
707
+ });
708
+ }
709
+ signMoonPayUrl(_0, _1) {
710
+ return __async(this, arguments, function* (userId, {
711
+ url,
712
+ type,
713
+ cosmosPrefix,
714
+ testMode,
715
+ walletId,
716
+ externalWalletAddress
717
+ }) {
718
+ const walletString = walletId ? `wallets/${walletId}` : `external-wallets/${externalWalletAddress}`;
719
+ const res = yield this.baseRequest.post(`/users/${userId}/${walletString}/moonpay-sign`, {
720
+ url,
721
+ type,
722
+ cosmosPrefix,
723
+ testMode
724
+ });
725
+ return res;
726
+ });
727
+ }
728
+ generateOffRampTx(_0, _1) {
729
+ return __async(this, arguments, function* (userId, {
730
+ provider,
731
+ chainId,
732
+ contractAddress,
733
+ testMode,
734
+ walletId,
735
+ walletType,
736
+ destinationAddress,
737
+ sourceAddress,
738
+ assetQuantity
739
+ }) {
740
+ const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/offramp-generate`, {
741
+ provider,
742
+ testMode,
743
+ chainId,
744
+ contractAddress,
745
+ walletId,
746
+ walletType,
747
+ destinationAddress,
748
+ sourceAddress,
749
+ assetQuantity
750
+ });
751
+ return res.data;
752
+ });
753
+ }
754
+ sendOffRampTx(_0, _1) {
755
+ return __async(this, arguments, function* (userId, {
756
+ tx,
757
+ signature,
758
+ network,
759
+ walletId,
760
+ walletType
761
+ }) {
762
+ const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/offramp-send`, {
763
+ tx,
764
+ signature,
765
+ network,
766
+ walletType
767
+ });
768
+ return res.data;
769
+ });
770
+ }
771
+ distributeParaShare(_k) {
772
+ return __async(this, null, function* () {
773
+ var _l = _k, {
774
+ userId,
775
+ walletId
776
+ } = _l, rest = __objRest(_l, [
777
+ "userId",
778
+ "walletId"
779
+ ]);
780
+ const body = rest;
781
+ const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/capsule-share/distribute`, body);
782
+ return res;
783
+ });
784
+ }
785
+ keepSessionAlive(userId) {
786
+ return __async(this, null, function* () {
787
+ const res = yield this.baseRequest.post(`/users/${userId}/session/keep-alive`);
788
+ return res.data;
789
+ });
790
+ }
791
+ persistRecoveryPublicKeys(userId, publicKeys) {
792
+ return __async(this, null, function* () {
793
+ const res = yield this.baseRequest.post(`/users/${userId}/recovery-public-keys`, { publicKeys });
794
+ return res.data;
795
+ });
796
+ }
797
+ getRecoveryPublicKeys(userId) {
798
+ return __async(this, null, function* () {
799
+ const res = yield this.baseRequest.get(`/users/${userId}/recovery-public-keys`);
800
+ return res.data;
801
+ });
802
+ }
803
+ uploadEncryptedWalletPrivateKey(userId, encryptedWalletPrivateKey, encryptionKeyHash, biometricPublicKey, passwordId) {
804
+ return __async(this, null, function* () {
805
+ const body = { encryptedWalletPrivateKey, encryptionKeyHash, biometricPublicKey, passwordId };
806
+ const res = yield this.baseRequest.post(`/users/${userId}/encrypted-wallet-private-keys`, body);
807
+ return res.data;
808
+ });
809
+ }
810
+ getEncryptedWalletPrivateKeys(userId, encryptionKeyHash) {
811
+ return __async(this, null, function* () {
812
+ const res = yield this.baseRequest.get(`/users/${userId}/encrypted-wallet-private-keys/${encryptionKeyHash}`);
813
+ return res.data;
814
+ });
815
+ }
816
+ getConversionRate(chainId, symbol, currency) {
817
+ return __async(this, null, function* () {
818
+ const params = { symbol, currency };
819
+ const res = yield this.baseRequest.get(`/chains/${chainId}/conversion-rate`, { params });
820
+ return res.data;
821
+ });
822
+ }
823
+ getGasEstimate(chainId, totalGasPrice) {
824
+ return __async(this, null, function* () {
825
+ const params = { totalGasPrice };
826
+ const res = yield this.baseRequest.get(`/chains/${chainId}/gas-estimate`, { params });
827
+ return res.data;
828
+ });
829
+ }
830
+ getGasOracle(chainId) {
831
+ return __async(this, null, function* () {
832
+ const res = yield this.baseRequest.get(`/chains/${chainId}/gas-oracle`);
833
+ return res.data;
834
+ });
835
+ }
836
+ // GET /users/:userId/wallets/:walletId/refresh-done
837
+ isRefreshDone(userId, walletId, partnerId, protocolId) {
838
+ return __async(this, null, function* () {
839
+ const queryParams = {};
840
+ if (partnerId) queryParams["partnerId"] = partnerId;
841
+ if (protocolId) queryParams["protocolId"] = protocolId;
842
+ const query = import_qs.default.stringify(queryParams);
843
+ const res = yield this.baseRequest.get(`/users/${userId}/wallets/${walletId}/refresh-done?${query}`);
844
+ return res.data;
845
+ });
846
+ }
847
+ deletePendingTransaction(userId, pendingTransactionId) {
848
+ return __async(this, null, function* () {
849
+ const res = yield this.baseRequest.delete(`/users/${userId}/pending-transactions/${pendingTransactionId}`);
850
+ return res.data;
851
+ });
852
+ }
853
+ // POST /users/:userId/passwords/key
854
+ addSessionPasswordPublicKey(userId, body) {
855
+ return __async(this, null, function* () {
856
+ const res = yield this.baseRequest.post(`/users/${userId}/passwords/key`, body);
857
+ return res;
858
+ });
859
+ }
860
+ getSupportedAuthMethods(auth) {
861
+ return __async(this, null, function* () {
862
+ const res = yield this.baseRequest.get("/users/supported-auth-methods", {
863
+ params: __spreadValues({}, auth)
864
+ });
865
+ return res.data;
866
+ });
867
+ }
868
+ getPasswords(auth) {
869
+ return __async(this, null, function* () {
870
+ const res = yield this.baseRequest.get("/users/passwords", {
871
+ params: __spreadValues({}, auth)
872
+ });
873
+ return res.data.passwords;
874
+ });
875
+ }
876
+ // POST /passwords/verify
877
+ verifyPasswordChallenge(partnerId, body) {
878
+ return __async(this, null, function* () {
879
+ const res = yield this.baseRequest.post(`/passwords/verify`, body, {
880
+ headers: {
881
+ [import_consts.PARTNER_ID_HEADER_NAME]: partnerId
882
+ }
883
+ });
884
+ return res;
885
+ });
886
+ }
887
+ getEncryptedWalletPrivateKey(passwordId) {
888
+ return __async(this, null, function* () {
889
+ const queryParams = {};
890
+ queryParams["passwordId"] = passwordId;
891
+ const query = import_qs.default.stringify(queryParams);
892
+ const res = yield this.baseRequest.get(`/encrypted-wallet-private-keys?${query}`);
893
+ return res;
894
+ });
895
+ }
896
+ // GET /users/:userId
897
+ getUser(userId) {
898
+ return __async(this, null, function* () {
899
+ const res = yield this.baseRequest.get(`/users/${userId}`);
900
+ return res.data;
901
+ });
902
+ }
903
+ // GET /users/:userId/accounts
904
+ getAccountMetadata(userId, partnerId) {
905
+ return __async(this, null, function* () {
906
+ const res = yield this.baseRequest.get(`/users/${userId}/oauth/accounts`, {
907
+ params: { partnerId }
908
+ });
909
+ return {
910
+ accountMetadata: Object.entries(res.data.accountMetadata || {}).reduce(
911
+ (acc, [method, obj]) => __spreadProps(__spreadValues({}, acc), {
912
+ [method]: __spreadProps(__spreadValues({}, obj), {
913
+ date: new Date(obj.date)
914
+ })
915
+ }),
916
+ {}
917
+ )
918
+ };
919
+ });
920
+ }
921
+ }
922
+ var client_default = Client;
923
+ // Annotate the CommonJS export names for ESM import in node:
924
+ 0 && (module.exports = {
925
+ handleResponseError,
926
+ handleResponseSuccess
927
+ });