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