@getpara/user-management-client 2.0.0-alpha.3 → 2.0.0-alpha.6

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