@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.
package/dist/esm/index.js CHANGED
@@ -1,1140 +1,9 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
- var __async = (__this, __arguments, generator) => {
33
- return new Promise((resolve, reject) => {
34
- var fulfilled = (value) => {
35
- try {
36
- step(generator.next(value));
37
- } catch (e) {
38
- reject(e);
39
- }
40
- };
41
- var rejected = (value) => {
42
- try {
43
- step(generator.throw(value));
44
- } catch (e) {
45
- reject(e);
46
- }
47
- };
48
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
- step((generator = generator.apply(__this, __arguments)).next());
50
- });
51
- };
52
-
53
- // src/client.ts
54
- import axios from "axios";
55
- import qs from "qs";
56
-
57
- // src/utils.ts
58
- function isWalletId(params) {
59
- return !!params.walletId && !params.externalWalletAddress;
60
- }
61
- function isExternalWalletAddress(params) {
62
- return !!params.externalWalletAddress && !params.walletId;
63
- }
64
- function extractWalletRef(params) {
65
- if (isWalletId(params)) {
66
- return ["walletId", params.walletId];
67
- } else if (isExternalWalletAddress(params)) {
68
- return ["externalWalletAddress", params.externalWalletAddress];
69
- }
70
- throw new Error("invalid wallet params");
71
- }
72
- function isValid(s) {
73
- return !!s && s !== "null" && s !== "undefined" && s !== "";
74
- }
75
- function isEmail(params) {
76
- return isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.externalWalletUserId);
77
- }
78
- function isPhone(params) {
79
- return isValid(params.phone) && isValid(params.countryCode) && !isValid(params.email) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.externalWalletUserId);
80
- }
81
- function isFarcaster(params) {
82
- return isValid(params.farcasterUsername) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.telegramUserId) && !isValid(params.externalWalletUserId);
83
- }
84
- function isTelegram(params) {
85
- return isValid(params.telegramUserId) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.externalWalletUserId);
86
- }
87
- function isUserId(params) {
88
- return isValid(params.userId) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.externalWalletUserId);
89
- }
90
- function isExternalWallet(params) {
91
- return isValid(params.externalWalletAddress) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId);
92
- }
93
- function extractAuthInfo(obj, { allowUserId = false, isRequired = false } = {}) {
94
- switch (true) {
95
- case isEmail(obj):
96
- return { auth: { email: obj.email }, authType: "email", identifier: obj.email, publicKeyIdentifier: obj.email };
97
- case isPhone(obj):
98
- return {
99
- auth: { phone: obj.phone, countryCode: obj.countryCode },
100
- authType: "phone",
101
- identifier: `${obj.countryCode}${obj.phone}`,
102
- publicKeyIdentifier: `${obj.countryCode}${obj.phone}`
103
- };
104
- case isFarcaster(obj):
105
- return {
106
- auth: { farcasterUsername: obj.farcasterUsername },
107
- authType: "farcaster",
108
- identifier: obj.farcasterUsername,
109
- publicKeyIdentifier: `${obj.farcasterUsername}-farcaster`
110
- };
111
- case isTelegram(obj):
112
- return {
113
- auth: { telegramUserId: obj.telegramUserId },
114
- authType: "telegram",
115
- identifier: obj.telegramUserId,
116
- publicKeyIdentifier: `${obj.telegramUserId}-telegram`
117
- };
118
- case isExternalWallet(obj):
119
- return {
120
- auth: { externalWalletAddress: obj.externalWalletAddress },
121
- authType: "externalWallet",
122
- identifier: obj.externalWalletAddress,
123
- publicKeyIdentifier: `${obj.externalWalletAddress}-external-wallet`
124
- };
125
- case (isUserId(obj) && allowUserId):
126
- return { auth: { userId: obj.userId }, authType: "userId", identifier: obj.userId, publicKeyIdentifier: obj.userId };
127
- default:
128
- if (isRequired) {
129
- throw new Error("invalid auth object");
130
- }
131
- return void 0;
132
- }
133
- }
134
-
135
- // src/consts.ts
136
- var SESSION_COOKIE_HEADER_NAME = "x-capsule-sid";
137
- var VERSION_HEADER_NAME = "x-para-version";
138
- var PARTNER_ID_HEADER_NAME = "x-partner-id";
139
- var API_KEY_HEADER_NAME = "X-External-API-Key";
140
-
141
- // src/error.ts
142
- function ParaApiError(message, code, status, responseURL) {
143
- Error.call(this);
144
- if (Error.captureStackTrace) {
145
- Error.captureStackTrace(this, this.constructor);
146
- } else {
147
- this.stack = new Error().stack;
148
- }
149
- this.message = message;
150
- this.name = "ParaApiError";
151
- code && (this.code = code);
152
- status && (this.status = status);
153
- responseURL && (this.responseURL = responseURL);
154
- }
155
- var prototype = ParaApiError.prototype;
156
- Object.defineProperty(prototype, "isParaApiError", { value: true });
157
-
158
- // src/client.ts
159
- var handleResponseSuccess = (response) => {
160
- if (response.status === 200) {
161
- return response;
162
- }
163
- throw new ParaApiError("Invalid status code");
164
- };
165
- var handleResponseError = (error) => {
166
- var _a, _b, _c;
167
- if (error === null) throw new ParaApiError("Error is null");
168
- if (axios.isAxiosError(error)) {
169
- let message = (_b = (_a = error.response) == null ? void 0 : _a.data) != null ? _b : "Unknown error";
170
- if (error.code === "ERR_NETWORK") {
171
- message = "Connection error";
172
- } else if (error.code === "ERR_CANCELED") {
173
- message = "Connection canceled";
174
- }
175
- throw new ParaApiError(message, error.code, error.response.status, (_c = error.request) == null ? void 0 : _c.responseURL);
176
- }
177
- throw new ParaApiError("Unknown error");
178
- };
179
- var Client = class {
180
- constructor({
181
- userManagementHost,
182
- apiKey,
183
- partnerId,
184
- version,
185
- opts,
186
- retrieveSessionCookie,
187
- persistSessionCookie
188
- }) {
189
- this.createUser = (body) => __async(this, null, function* () {
190
- const res = yield this.baseRequest.post(`/users`, body);
191
- return res.data;
192
- });
193
- this.checkUserExists = (auth) => __async(this, null, function* () {
194
- const res = yield this.baseRequest.get("/users/exists", {
195
- params: __spreadValues({}, auth)
196
- });
197
- return res;
198
- });
199
- this.verifyTelegram = (authObject) => __async(this, null, function* () {
200
- return (yield this.baseRequest.post("/users/telegram", {
201
- authObject
202
- })).data;
203
- });
204
- this.externalWalletLogin = (body) => __async(this, null, function* () {
205
- const res = yield this.baseRequest.post(`/users/external-wallets/login`, body);
206
- return res.data;
207
- });
208
- // POST /users/:userId/verify-email
209
- this.verifyEmail = (userId, body) => __async(this, null, function* () {
210
- const res = yield this.baseRequest.post(`/users/${userId}/verify-email`, body);
211
- return res;
212
- });
213
- this.verifyPhone = (userId, body) => __async(this, null, function* () {
214
- const res = yield this.baseRequest.post(`/users/${userId}/verify-identifier`, body);
215
- return res;
216
- });
217
- this.verifyExternalWallet = (userId, body) => __async(this, null, function* () {
218
- const res = yield this.baseRequest.post(`/users/${userId}/external-wallets/verify`, body);
219
- return res;
220
- });
221
- // POST /users/:userId/biometrics/key
222
- this.addSessionPublicKey = (userId, body) => __async(this, null, function* () {
223
- const res = yield this.baseRequest.post(`/users/${userId}/biometrics/key`, body);
224
- return res;
225
- });
226
- // GET /users/:userId/biometrics/keys
227
- this.getSessionPublicKeys = (userId) => __async(this, null, function* () {
228
- const res = yield this.baseRequest.get(`/users/${userId}/biometrics/keys`);
229
- return res;
230
- });
231
- // GET /biometrics/location-hints
232
- this.getBiometricLocationHints = (params) => __async(this, null, function* () {
233
- const res = yield this.baseRequest.get(`/biometrics/location-hints`, { params });
234
- return res.data.hints;
235
- });
236
- // GET /users/:userId/biometrics/:biometricId
237
- this.getSessionPublicKey = (userId, biometricId) => __async(this, null, function* () {
238
- const res = yield this.baseRequest.get(`/users/${userId}/biometrics/${biometricId}`);
239
- return res;
240
- });
241
- // PATCH /users/:userId/biometrics/:biometricId
242
- this.patchSessionPublicKey = (partnerId, userId, biometricId, body) => __async(this, null, function* () {
243
- const res = yield this.baseRequest.patch(`/users/${userId}/biometrics/${biometricId}`, body, {
244
- headers: {
245
- [PARTNER_ID_HEADER_NAME]: partnerId
246
- }
247
- });
248
- return res;
249
- });
250
- // GET /biometrics/challenge?email&publicKey
251
- this.getWebChallenge = (auth) => __async(this, null, function* () {
252
- const res = yield this.baseRequest.get("/biometrics/challenge", {
253
- params: __spreadValues({}, auth || {})
254
- });
255
- return res.data;
256
- });
257
- // POST /touch
258
- this.touchSession = (regenerate) => __async(this, null, function* () {
259
- const res = yield this.baseRequest.post(
260
- `/touch?regenerate=${!!regenerate}`
261
- );
262
- return res;
263
- });
264
- // GET /session/origin
265
- this.sessionOrigin = (sessionLookupId) => __async(this, null, function* () {
266
- const res = yield this.baseRequest.get(`/sessions/${sessionLookupId}/origin`);
267
- return res.data;
268
- });
269
- // POST /biometrics/verify
270
- this.verifyWebChallenge = (partnerId, body) => __async(this, null, function* () {
271
- const res = yield this.baseRequest.post(`/biometrics/verify`, body, {
272
- headers: {
273
- [PARTNER_ID_HEADER_NAME]: partnerId
274
- }
275
- });
276
- return res;
277
- });
278
- // GET /users/:userId/biometrics/challenge
279
- this.getSessionChallenge = (userId) => __async(this, null, function* () {
280
- const res = yield this.baseRequest.get(`/users/${userId}/biometrics/challenge`);
281
- return res;
282
- });
283
- // POST /users/:userId/biometrics/verify
284
- this.verifySessionChallenge = (userId, body) => __async(this, null, function* () {
285
- const res = yield this.baseRequest.post(`/users/${userId}/biometrics/verify`, body);
286
- return res;
287
- });
288
- // POST /users/:userId/wallets
289
- this.createWallet = (userId, body) => __async(this, null, function* () {
290
- const res = yield this.baseRequest.post(`/users/${userId}/wallets`, body);
291
- return res.data;
292
- });
293
- // POST /wallets/pregen
294
- this.createPregenWallet = (body) => __async(this, null, function* () {
295
- const res = yield this.baseRequest.post(`/wallets/pregen`, body);
296
- return res.data;
297
- });
298
- // GET /wallets/pregen?pregenIdentifier={pregenIdentifier}&pregenIdentifierType={pregenIdentifierType}
299
- this.getPregenWallets = (pregenIds, isPortal = false, userId) => __async(this, null, function* () {
300
- const res = yield this.baseRequest.get("/wallets/pregen", {
301
- params: { ids: pregenIds, expand: isPortal, userId }
302
- });
303
- return res.data;
304
- });
305
- // POST /wallets/pregen/claim
306
- this.claimPregenWallets = (body) => __async(this, null, function* () {
307
- const res = yield this.baseRequest.post(`/wallets/pregen/claim`, body);
308
- return res.data;
309
- });
310
- // POST /users/:userId/wallets/:walletId/transactions/send
311
- this.sendTransaction = (userId, walletId, body) => __async(this, null, function* () {
312
- const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/transactions/send`, body);
313
- return res;
314
- });
315
- // functionality changed to only sign transactions and not send them
316
- // POST /users/:userId/wallets/:walletId/transactions/sign
317
- this.signTransaction = (userId, walletId, body) => __async(this, null, function* () {
318
- const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/transactions/sign`, body);
319
- return res;
320
- });
321
- // POST /users/:userId/wallets/:walletId/refresh
322
- this.refreshKeys = (userId, walletId, oldPartnerId, newPartnerId, keyShareProtocolId) => __async(this, null, function* () {
323
- const body = { oldPartnerId, newPartnerId, keyShareProtocolId };
324
- const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/refresh`, body);
325
- return res;
326
- });
327
- // PATCH /wallets/pregen/:walletId
328
- this.updatePregenWallet = (walletId, body) => __async(this, null, function* () {
329
- const res = yield this.baseRequest.patch(`/wallets/pregen/${walletId}`, body);
330
- return res.data;
331
- });
332
- // GET /users/:userId/wallets
333
- this.getWallets = (userId, includePartnerData) => __async(this, null, function* () {
334
- const res = yield this.baseRequest.get(
335
- `/users/${userId}/wallets${includePartnerData ? `?includePartnerData=${encodeURIComponent(includePartnerData)}` : ""}`
336
- );
337
- return res;
338
- });
339
- // GET /users/:userId/all-wallets
340
- this.getAllWallets = (userId) => __async(this, null, function* () {
341
- const res = yield this.baseRequest.get(`/users/${userId}/all-wallets`);
342
- return res;
343
- });
344
- // POST /users/:userId/wallets/set
345
- this.setCurrentWalletIds = (userId, walletIds, needsWallet = false, sessionLookupId, newDeviceSessionLookupId) => __async(this, null, function* () {
346
- const res = yield this.baseRequest.post(`/users/${userId}/wallets/set`, {
347
- walletIds,
348
- needsWallet,
349
- sessionLookupId,
350
- newDeviceSessionLookupId
351
- });
352
- return res;
353
- });
354
- // POST /login
355
- this.login = (props) => __async(this, null, function* () {
356
- const body = props;
357
- const res = yield this.baseRequest.post("/login", body);
358
- return res;
359
- });
360
- // POST /login
361
- this.verifyLogin = (verificationCode) => __async(this, null, function* () {
362
- const body = { verificationCode };
363
- const res = yield this.baseRequest.post("/login/verify-email", body);
364
- return res;
365
- });
366
- // GET /logout
367
- this.logout = () => __async(this, null, function* () {
368
- const res = yield this.baseRequest.get("/logout");
369
- return res;
370
- });
371
- // POST /recovery/verification
372
- this.recoveryVerification = (email, verificationCode) => __async(this, null, function* () {
373
- const body = { email, verificationCode };
374
- const res = yield this.baseRequest.post("/recovery/verification", body);
375
- return res;
376
- });
377
- // POST /recovery
378
- this.recoveryInit = (email) => __async(this, null, function* () {
379
- const body = { email };
380
- const res = yield this.baseRequest.post("/recovery", body);
381
- return res;
382
- });
383
- this.preSignMessage = (userId, walletId, message, scheme, cosmosSignDoc) => __async(this, null, function* () {
384
- const body = { message, scheme, cosmosSignDoc };
385
- const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/messages/sign`, body);
386
- return res.data;
387
- });
388
- //DELETE /users/:userId
389
- this.deleteSelf = (userId) => __async(this, null, function* () {
390
- const res = yield this.baseRequest.delete(`/users/${userId}`);
391
- return res;
392
- });
393
- // GET /users/:userId/wallets/:walletId/capsule-share
394
- this.getParaShare = (userId, walletId) => __async(this, null, function* () {
395
- const res = yield this.baseRequest.get(`/users/${userId}/wallets/${walletId}/capsule-share`);
396
- return res.data.share;
397
- });
398
- // GET /users/:userId/wallets/:walletId/download-backup-kit
399
- this.getBackupKit = (userId, walletId) => __async(this, null, function* () {
400
- const res = yield this.baseRequest.get(`/users/${userId}/wallets/${walletId}/download-backup-kit`, {
401
- responseType: "blob"
402
- });
403
- return res;
404
- });
405
- // PATCH /users/:userId/biometrics/:biometricId
406
- this.patchSessionPassword = (partnerId, userId, passwordId, body) => __async(this, null, function* () {
407
- const res = yield this.baseRequest.patch(`/users/${userId}/passwords/${passwordId}`, body, {
408
- headers: {
409
- [PARTNER_ID_HEADER_NAME]: partnerId
410
- }
411
- });
412
- return res;
413
- });
414
- const headers = __spreadValues(__spreadValues({}, apiKey && { [API_KEY_HEADER_NAME]: apiKey }), partnerId && { [PARTNER_ID_HEADER_NAME]: partnerId });
415
- const axiosConfig = {
416
- baseURL: userManagementHost,
417
- withCredentials: true,
418
- headers
419
- };
420
- if (retrieveSessionCookie) {
421
- const defaultTransformRequest = Array.isArray(axios.defaults.transformRequest) ? axios.defaults.transformRequest : [axios.defaults.transformRequest];
422
- axiosConfig.transformRequest = [
423
- function(data, headers2) {
424
- const currentSessionCookie = retrieveSessionCookie();
425
- if (currentSessionCookie) {
426
- headers2[SESSION_COOKIE_HEADER_NAME] = currentSessionCookie;
427
- }
428
- if (version) {
429
- headers2[VERSION_HEADER_NAME] = version;
430
- }
431
- return data;
432
- },
433
- ...defaultTransformRequest
434
- ];
435
- }
436
- if (persistSessionCookie) {
437
- const defaultTransformResponse = Array.isArray(axios.defaults.transformResponse) ? axios.defaults.transformResponse : [axios.defaults.transformResponse];
438
- axiosConfig.transformResponse = [
439
- ...defaultTransformResponse,
440
- function(data, headers2, _status) {
441
- if (headers2 == null ? void 0 : headers2[SESSION_COOKIE_HEADER_NAME]) {
442
- persistSessionCookie(headers2[SESSION_COOKIE_HEADER_NAME]);
443
- }
444
- return data;
445
- }
446
- ];
447
- }
448
- this.baseRequest = axios.create(axiosConfig);
449
- if (opts == null ? void 0 : opts.useFetchAdapter) {
450
- axios.defaults.adapter = function(config) {
451
- return fetch(config.baseURL + config.url.substring(1), {
452
- method: config.method,
453
- headers: config.headers,
454
- body: config.data,
455
- credentials: config.withCredentials ? "include" : void 0
456
- }).then(
457
- (response) => response.text().then((text) => ({
458
- data: text,
459
- status: response.status,
460
- statusText: response.statusText,
461
- headers: response.headers,
462
- config,
463
- request: fetch
464
- }))
465
- ).catch(function(reason) {
466
- throw reason;
467
- });
468
- };
469
- }
470
- this.baseRequest.interceptors.response.use(handleResponseSuccess, handleResponseError);
471
- }
472
- // DEPRECATED: use uploadUserKeyShares instead
473
- // POST /users/:userId/wallets/:walletId/key-shares
474
- uploadKeyshares(userId, walletId, encryptedKeyshares) {
475
- return __async(this, null, function* () {
476
- const body = { keyShares: encryptedKeyshares };
477
- const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/key-shares`, body);
478
- return res;
479
- });
480
- }
481
- // POST /users/:userId/key-shares
482
- uploadUserKeyShares(userId, encryptedKeyshares) {
483
- return __async(this, null, function* () {
484
- const body = { keyShares: encryptedKeyshares };
485
- const res = yield this.baseRequest.post(`/users/${userId}/key-shares`, body);
486
- return res;
487
- });
488
- }
489
- // GET /users/:userId/wallets/:walletId/key-shares
490
- getKeyshare(userId, walletId, type, encryptor) {
491
- return __async(this, null, function* () {
492
- const res = yield this.baseRequest.get(
493
- `/users/${userId}/wallets/${walletId}/key-shares?type=${type}${encryptor ? `&encryptor=${encryptor}` : ""}`
494
- );
495
- return res;
496
- });
497
- }
498
- // GET /users/:userId/biometrics/key-shares
499
- getBiometricKeyshares(userId, biometricPublicKey, getAll) {
500
- return __async(this, null, function* () {
501
- const res = yield this.baseRequest.get(
502
- `/users/${userId}/biometrics/key-shares?publicKey=${biometricPublicKey}&all=${!!getAll}`
503
- );
504
- return res;
505
- });
506
- }
507
- // GET /users/:userId/key-shares
508
- getPasswordKeyshares(userId, passwordId, getAll) {
509
- return __async(this, null, function* () {
510
- const res = yield this.baseRequest.get(
511
- `/users/${userId}/passwords/key-shares?passwordId=${passwordId}&all=${!!getAll}`
512
- );
513
- return res;
514
- });
515
- }
516
- // POST '/users/:userId/temporary-shares',
517
- uploadTransmissionKeyshares(userId, shares) {
518
- return __async(this, null, function* () {
519
- const body = { shares };
520
- const res = yield this.baseRequest.post(`/users/${userId}/temporary-shares`, body);
521
- return res;
522
- });
523
- }
524
- // GET /users/:userId/temporary-shares returns { temporaryShares: { userId: string, walletId: string, encryptedShare: string, encryptedKey?: string }[] }
525
- getTransmissionKeyshares(userId, sessionLookupId) {
526
- return __async(this, null, function* () {
527
- const res = yield this.baseRequest.get(`/users/${userId}/temporary-shares?sessionLookupId=${sessionLookupId}`);
528
- return res;
529
- });
530
- }
531
- // POST '/users/:userId/resend-verification-code
532
- resendVerificationCode(_a) {
533
- return __async(this, null, function* () {
534
- var _b = _a, { userId } = _b, rest = __objRest(_b, ["userId"]);
535
- const res = yield this.baseRequest.post(`/users/${userId}/resend-verification-code`, rest);
536
- return res;
537
- });
538
- }
539
- // POST '/users/:userId/resend-verification-code-by-phone
540
- resendVerificationCodeByPhone(_c) {
541
- return __async(this, null, function* () {
542
- var _d = _c, { userId } = _d, rest = __objRest(_d, ["userId"]);
543
- const res = yield this.baseRequest.post(`/users/${userId}/resend-verification-code-by-phone`, rest);
544
- return res;
545
- });
546
- }
547
- // POST recovery/cancel
548
- cancelRecoveryAttempt(email) {
549
- return __async(this, null, function* () {
550
- const res = yield this.baseRequest.post(`/recovery/cancel`, { email });
551
- return res;
552
- });
553
- }
554
- // GET '/2fa/users/:userId/check-status'
555
- check2FAStatus(userId) {
556
- return __async(this, null, function* () {
557
- const res = yield this.baseRequest.get(`/2fa/users/${userId}/check-status`);
558
- return res;
559
- });
560
- }
561
- // POST '/2fa/users/:userId/enable'
562
- enable2FA(userId, verificationCode) {
563
- return __async(this, null, function* () {
564
- const res = yield this.baseRequest.post(`/2fa/users/${userId}/enable`, { verificationCode });
565
- return res;
566
- });
567
- }
568
- // POST '/2fa/users/:userId/setup'
569
- setup2FA(userId) {
570
- return __async(this, null, function* () {
571
- const res = yield this.baseRequest.post(`/2fa/users/${userId}/setup`);
572
- return res;
573
- });
574
- }
575
- // POST /recovery/init
576
- initializeRecovery(email) {
577
- return __async(this, null, function* () {
578
- const res = yield this.baseRequest.post(`/recovery/init`, { email });
579
- return res;
580
- });
581
- }
582
- // POST /auth/farcaster/init
583
- initializeFarcasterLogin() {
584
- return __async(this, null, function* () {
585
- const res = yield this.baseRequest.post(`/auth/farcaster/init`);
586
- return res;
587
- });
588
- }
589
- // POST /auth/farcaster/status
590
- getFarcasterAuthStatus() {
591
- return __async(this, null, function* () {
592
- const res = yield this.baseRequest.post(`/auth/farcaster/status`);
593
- return res;
594
- });
595
- }
596
- // POST /recovery/init
597
- initializeRecoveryForPhone(phone, countryCode) {
598
- return __async(this, null, function* () {
599
- const res = yield this.baseRequest.post(`/recovery/init`, { phone, countryCode });
600
- return res;
601
- });
602
- }
603
- // POST /recovery/users/:userId/wallets/:walletId/finish
604
- finalizeRecovery(userId, walletId) {
605
- return __async(this, null, function* () {
606
- const res = yield this.baseRequest.post(`/recovery/users/${userId}/wallets/${walletId}/finish`);
607
- return res;
608
- });
609
- }
610
- // GET /recovery/users/:userId/wallets/:walletId/key-shares
611
- recoverUserShares(userId, walletId) {
612
- return __async(this, null, function* () {
613
- const res = yield this.baseRequest.get(`/recovery/users/${userId}/wallets/${walletId}/key-shares?type=USER&encryptor=RECOVERY`);
614
- return res;
615
- });
616
- }
617
- // POST /recovery/verify-email
618
- verifyEmailForRecovery(email, verificationCode) {
619
- return __async(this, null, function* () {
620
- const body = { email, verificationCode };
621
- const res = yield this.baseRequest.post(`/recovery/verify-email`, body);
622
- return res;
623
- });
624
- }
625
- // POST /recovery/verify-identifier
626
- verifyPhoneForRecovery(phone, countryCode, verificationCode) {
627
- return __async(this, null, function* () {
628
- const body = { phone, countryCode, verificationCode };
629
- const res = yield this.baseRequest.post(`/recovery/verify-identifier`, body);
630
- return res;
631
- });
632
- }
633
- // POST /2fa/verify
634
- verify2FA(email, verificationCode) {
635
- return __async(this, null, function* () {
636
- const body = { email, verificationCode };
637
- const res = yield this.baseRequest.post("/2fa/verify", body);
638
- return res;
639
- });
640
- }
641
- // POST /2fa/phone/verify
642
- verify2FAForPhone(phone, countryCode, verificationCode) {
643
- return __async(this, null, function* () {
644
- const body = { phone, countryCode, verificationCode };
645
- const res = yield this.baseRequest.post("/2fa/verify", body);
646
- return res;
647
- });
648
- }
649
- tempTrasmissionInit(message, userId) {
650
- return __async(this, null, function* () {
651
- const body = { message, userId };
652
- const res = yield this.baseRequest.post("/temporary-transmissions", body);
653
- return res;
654
- });
655
- }
656
- tempTrasmission(id) {
657
- return __async(this, null, function* () {
658
- const res = yield this.baseRequest.get(`/temporary-transmissions/${id}`);
659
- return res;
660
- });
661
- }
662
- getPartner(partnerId) {
663
- return __async(this, null, function* () {
664
- const res = yield this.baseRequest.get(`/partners/${partnerId}`);
665
- return res;
666
- });
667
- }
668
- acceptScopes(userId, walletId, body) {
669
- return __async(this, null, function* () {
670
- const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/scopes/accept`, body);
671
- return res;
672
- });
673
- }
674
- getPendingTransaction(userId, pendingTransactionId) {
675
- return __async(this, null, function* () {
676
- const res = yield this.baseRequest.get(`/users/${userId}/pending-transactions/${pendingTransactionId}`);
677
- return res;
678
- });
679
- }
680
- acceptPendingTransaction(userId, pendingTransactionId) {
681
- return __async(this, null, function* () {
682
- const res = yield this.baseRequest.post(`/users/${userId}/pending-transactions/${pendingTransactionId}/accept`);
683
- return res;
684
- });
685
- }
686
- getOnRampConfig() {
687
- return __async(this, null, function* () {
688
- const res = yield this.baseRequest.get(`/on-ramp-config`);
689
- return res.data;
690
- });
691
- }
692
- createOnRampPurchase(_e) {
693
- return __async(this, null, function* () {
694
- var _f = _e, {
695
- userId,
696
- params: {
697
- type,
698
- walletType,
699
- address,
700
- provider,
701
- networks,
702
- assets,
703
- defaultNetwork,
704
- defaultAsset,
705
- fiat,
706
- fiatQuantity,
707
- testMode = false
708
- }
709
- } = _f, params = __objRest(_f, [
710
- "userId",
711
- "params"
712
- ]);
713
- const [key, identifier] = extractWalletRef(params);
714
- const walletString = key === "walletId" ? `wallets/${identifier}` : `external-wallets/${identifier}`;
715
- const res = yield this.baseRequest.post(`/users/${userId}/${walletString}/purchases`, {
716
- type,
717
- provider,
718
- walletType,
719
- address,
720
- networks,
721
- assets,
722
- defaultAsset,
723
- defaultNetwork,
724
- fiat,
725
- fiatQuantity,
726
- testMode
727
- });
728
- return res.data;
729
- });
730
- }
731
- updateOnRampPurchase(_g) {
732
- return __async(this, null, function* () {
733
- var _h = _g, {
734
- userId,
735
- purchaseId,
736
- updates
737
- } = _h, params = __objRest(_h, [
738
- "userId",
739
- "purchaseId",
740
- "updates"
741
- ]);
742
- const [key, identifier] = extractWalletRef(params);
743
- const walletString = key === "walletId" ? `wallets/${identifier}` : `external-wallets/${identifier}`;
744
- const res = yield this.baseRequest.patch(
745
- `/users/${userId}/${walletString}/purchases/${purchaseId}`,
746
- updates
747
- );
748
- return res.data;
749
- });
750
- }
751
- getOnRampPurchase(_i) {
752
- return __async(this, null, function* () {
753
- var _j = _i, {
754
- userId,
755
- purchaseId
756
- } = _j, params = __objRest(_j, [
757
- "userId",
758
- "purchaseId"
759
- ]);
760
- const [key, identifier] = extractWalletRef(params);
761
- const walletString = key === "walletId" ? `wallets/${identifier}` : `external-wallets/${identifier}`;
762
- const res = yield this.baseRequest.get(`/users/${userId}/${walletString}/purchases/${purchaseId}`);
763
- return res;
764
- });
765
- }
766
- signMoonPayUrl(_0, _1) {
767
- return __async(this, arguments, function* (userId, {
768
- url,
769
- type,
770
- cosmosPrefix,
771
- testMode,
772
- walletId,
773
- externalWalletAddress
774
- }) {
775
- const walletString = walletId ? `wallets/${walletId}` : `external-wallets/${externalWalletAddress}`;
776
- const res = yield this.baseRequest.post(`/users/${userId}/${walletString}/moonpay-sign`, {
777
- url,
778
- type,
779
- cosmosPrefix,
780
- testMode
781
- });
782
- return res;
783
- });
784
- }
785
- generateOffRampTx(_0, _1) {
786
- return __async(this, arguments, function* (userId, {
787
- provider,
788
- chainId,
789
- contractAddress,
790
- testMode,
791
- walletId,
792
- walletType,
793
- destinationAddress,
794
- sourceAddress,
795
- assetQuantity
796
- }) {
797
- const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/offramp-generate`, {
798
- provider,
799
- testMode,
800
- chainId,
801
- contractAddress,
802
- walletId,
803
- walletType,
804
- destinationAddress,
805
- sourceAddress,
806
- assetQuantity
807
- });
808
- return res.data;
809
- });
810
- }
811
- sendOffRampTx(_0, _1) {
812
- return __async(this, arguments, function* (userId, {
813
- tx,
814
- signature,
815
- network,
816
- walletId,
817
- walletType
818
- }) {
819
- const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/offramp-send`, {
820
- tx,
821
- signature,
822
- network,
823
- walletType
824
- });
825
- return res.data;
826
- });
827
- }
828
- distributeParaShare(_k) {
829
- return __async(this, null, function* () {
830
- var _l = _k, {
831
- userId,
832
- walletId
833
- } = _l, rest = __objRest(_l, [
834
- "userId",
835
- "walletId"
836
- ]);
837
- const body = rest;
838
- const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/capsule-share/distribute`, body);
839
- return res;
840
- });
841
- }
842
- keepSessionAlive(userId) {
843
- return __async(this, null, function* () {
844
- const res = yield this.baseRequest.post(`/users/${userId}/session/keep-alive`);
845
- return res.data;
846
- });
847
- }
848
- persistRecoveryPublicKeys(userId, publicKeys) {
849
- return __async(this, null, function* () {
850
- const res = yield this.baseRequest.post(`/users/${userId}/recovery-public-keys`, { publicKeys });
851
- return res.data;
852
- });
853
- }
854
- getRecoveryPublicKeys(userId) {
855
- return __async(this, null, function* () {
856
- const res = yield this.baseRequest.get(`/users/${userId}/recovery-public-keys`);
857
- return res.data;
858
- });
859
- }
860
- uploadEncryptedWalletPrivateKey(userId, encryptedWalletPrivateKey, encryptionKeyHash, biometricPublicKey, passwordId) {
861
- return __async(this, null, function* () {
862
- const body = { encryptedWalletPrivateKey, encryptionKeyHash, biometricPublicKey, passwordId };
863
- const res = yield this.baseRequest.post(`/users/${userId}/encrypted-wallet-private-keys`, body);
864
- return res.data;
865
- });
866
- }
867
- getEncryptedWalletPrivateKeys(userId, encryptionKeyHash) {
868
- return __async(this, null, function* () {
869
- const res = yield this.baseRequest.get(`/users/${userId}/encrypted-wallet-private-keys/${encryptionKeyHash}`);
870
- return res.data;
871
- });
872
- }
873
- getConversionRate(chainId, symbol, currency) {
874
- return __async(this, null, function* () {
875
- const params = { symbol, currency };
876
- const res = yield this.baseRequest.get(`/chains/${chainId}/conversion-rate`, { params });
877
- return res.data;
878
- });
879
- }
880
- getGasEstimate(chainId, totalGasPrice) {
881
- return __async(this, null, function* () {
882
- const params = { totalGasPrice };
883
- const res = yield this.baseRequest.get(`/chains/${chainId}/gas-estimate`, { params });
884
- return res.data;
885
- });
886
- }
887
- getGasOracle(chainId) {
888
- return __async(this, null, function* () {
889
- const res = yield this.baseRequest.get(`/chains/${chainId}/gas-oracle`);
890
- return res.data;
891
- });
892
- }
893
- // GET /users/:userId/wallets/:walletId/refresh-done
894
- isRefreshDone(userId, walletId, partnerId, protocolId) {
895
- return __async(this, null, function* () {
896
- const queryParams = {};
897
- if (partnerId) queryParams["partnerId"] = partnerId;
898
- if (protocolId) queryParams["protocolId"] = protocolId;
899
- const query = qs.stringify(queryParams);
900
- const res = yield this.baseRequest.get(`/users/${userId}/wallets/${walletId}/refresh-done?${query}`);
901
- return res.data;
902
- });
903
- }
904
- deletePendingTransaction(userId, pendingTransactionId) {
905
- return __async(this, null, function* () {
906
- const res = yield this.baseRequest.delete(`/users/${userId}/pending-transactions/${pendingTransactionId}`);
907
- return res.data;
908
- });
909
- }
910
- // POST /users/:userId/passwords/key
911
- addSessionPasswordPublicKey(userId, body) {
912
- return __async(this, null, function* () {
913
- const res = yield this.baseRequest.post(`/users/${userId}/passwords/key`, body);
914
- return res;
915
- });
916
- }
917
- getSupportedAuthMethods(auth) {
918
- return __async(this, null, function* () {
919
- const res = yield this.baseRequest.get("/users/supported-auth-methods", {
920
- params: __spreadValues({}, auth)
921
- });
922
- return res.data;
923
- });
924
- }
925
- getPasswords(auth) {
926
- return __async(this, null, function* () {
927
- const res = yield this.baseRequest.get("/users/passwords", {
928
- params: __spreadValues({}, auth)
929
- });
930
- return res.data.passwords;
931
- });
932
- }
933
- // POST /passwords/verify
934
- verifyPasswordChallenge(partnerId, body) {
935
- return __async(this, null, function* () {
936
- const res = yield this.baseRequest.post(`/passwords/verify`, body, {
937
- headers: {
938
- [PARTNER_ID_HEADER_NAME]: partnerId
939
- }
940
- });
941
- return res;
942
- });
943
- }
944
- getEncryptedWalletPrivateKey(passwordId) {
945
- return __async(this, null, function* () {
946
- const queryParams = {};
947
- queryParams["passwordId"] = passwordId;
948
- const query = qs.stringify(queryParams);
949
- const res = yield this.baseRequest.get(`/encrypted-wallet-private-keys?${query}`);
950
- return res;
951
- });
952
- }
953
- // GET /users/:userId
954
- getUser(userId) {
955
- return __async(this, null, function* () {
956
- const res = yield this.baseRequest.get(`/users/${userId}`);
957
- return res.data;
958
- });
959
- }
960
- // GET /users/:userId/accounts
961
- getAccountMetadata(userId, partnerId) {
962
- return __async(this, null, function* () {
963
- const res = yield this.baseRequest.get(`/users/${userId}/oauth/accounts`, {
964
- params: { partnerId }
965
- });
966
- return {
967
- accountMetadata: Object.entries(res.data.accountMetadata || {}).reduce(
968
- (acc, [method, obj]) => __spreadProps(__spreadValues({}, acc), {
969
- [method]: __spreadProps(__spreadValues({}, obj), {
970
- date: new Date(obj.date)
971
- })
972
- }),
973
- {}
974
- )
975
- };
976
- });
977
- }
978
- };
979
- var client_default = Client;
980
-
981
- // src/types/auth.ts
982
- var EncryptorType = /* @__PURE__ */ ((EncryptorType2) => {
983
- EncryptorType2["USER"] = "USER";
984
- EncryptorType2["RECOVERY"] = "RECOVERY";
985
- EncryptorType2["BIOMETRICS"] = "BIOMETRICS";
986
- EncryptorType2["PASSWORD"] = "PASSWORD";
987
- return EncryptorType2;
988
- })(EncryptorType || {});
989
- var KeyShareType = /* @__PURE__ */ ((KeyShareType2) => {
990
- KeyShareType2["USER"] = "USER";
991
- KeyShareType2["RECOVERY"] = "RECOVERY";
992
- return KeyShareType2;
993
- })(KeyShareType || {});
994
- var PasswordStatus = /* @__PURE__ */ ((PasswordStatus2) => {
995
- PasswordStatus2["PENDING"] = "PENDING";
996
- PasswordStatus2["COMPLETE"] = "COMPLETE";
997
- return PasswordStatus2;
998
- })(PasswordStatus || {});
999
- var PublicKeyStatus = /* @__PURE__ */ ((PublicKeyStatus2) => {
1000
- PublicKeyStatus2["PENDING"] = "PENDING";
1001
- PublicKeyStatus2["COMPLETE"] = "COMPLETE";
1002
- return PublicKeyStatus2;
1003
- })(PublicKeyStatus || {});
1004
- var PublicKeyType = /* @__PURE__ */ ((PublicKeyType2) => {
1005
- PublicKeyType2["MOBILE"] = "MOBILE";
1006
- PublicKeyType2["WEB"] = "WEB";
1007
- return PublicKeyType2;
1008
- })(PublicKeyType || {});
1009
- var OAuthMethod = /* @__PURE__ */ ((OAuthMethod2) => {
1010
- OAuthMethod2["GOOGLE"] = "GOOGLE";
1011
- OAuthMethod2["TWITTER"] = "TWITTER";
1012
- OAuthMethod2["APPLE"] = "APPLE";
1013
- OAuthMethod2["DISCORD"] = "DISCORD";
1014
- OAuthMethod2["FACEBOOK"] = "FACEBOOK";
1015
- OAuthMethod2["FARCASTER"] = "FARCASTER";
1016
- OAuthMethod2["TELEGRAM"] = "TELEGRAM";
1017
- return OAuthMethod2;
1018
- })(OAuthMethod || {});
1019
- var AuthMethod = /* @__PURE__ */ ((AuthMethod2) => {
1020
- AuthMethod2["PASSWORD"] = "PASSWORD";
1021
- AuthMethod2["PASSKEY"] = "PASSKEY";
1022
- return AuthMethod2;
1023
- })(AuthMethod || {});
1024
-
1025
- // src/types/email.ts
1026
- var EmailTheme = /* @__PURE__ */ ((EmailTheme2) => {
1027
- EmailTheme2["LIGHT"] = "light";
1028
- EmailTheme2["DARK"] = "dark";
1029
- return EmailTheme2;
1030
- })(EmailTheme || {});
1031
-
1032
- // src/types/onRamp.ts
1033
- var OnRampProvider = /* @__PURE__ */ ((OnRampProvider2) => {
1034
- OnRampProvider2["RAMP"] = "RAMP";
1035
- OnRampProvider2["STRIPE"] = "STRIPE";
1036
- OnRampProvider2["MOONPAY"] = "MOONPAY";
1037
- return OnRampProvider2;
1038
- })(OnRampProvider || {});
1039
- var OnRampAsset = /* @__PURE__ */ ((OnRampAsset2) => {
1040
- OnRampAsset2["ETHEREUM"] = "ETHEREUM";
1041
- OnRampAsset2["USDC"] = "USDC";
1042
- OnRampAsset2["TETHER"] = "TETHER";
1043
- OnRampAsset2["POLYGON"] = "POLYGON";
1044
- OnRampAsset2["SOLANA"] = "SOLANA";
1045
- OnRampAsset2["ATOM"] = "ATOM";
1046
- OnRampAsset2["CELO"] = "CELO";
1047
- OnRampAsset2["CUSD"] = "CUSD";
1048
- OnRampAsset2["CEUR"] = "CEUR";
1049
- OnRampAsset2["CREAL"] = "CREAL";
1050
- return OnRampAsset2;
1051
- })(OnRampAsset || {});
1052
- var OnRampPurchaseStatus = /* @__PURE__ */ ((OnRampPurchaseStatus2) => {
1053
- OnRampPurchaseStatus2["INITIATED"] = "INITIATED";
1054
- OnRampPurchaseStatus2["FINISHED"] = "FINISHED";
1055
- OnRampPurchaseStatus2["CANCELLED"] = "CANCELLED";
1056
- return OnRampPurchaseStatus2;
1057
- })(OnRampPurchaseStatus || {});
1058
- var OnRampPurchaseType = /* @__PURE__ */ ((OnRampPurchaseType2) => {
1059
- OnRampPurchaseType2["BUY"] = "BUY";
1060
- OnRampPurchaseType2["SELL"] = "SELL";
1061
- return OnRampPurchaseType2;
1062
- })(OnRampPurchaseType || {});
1063
-
1064
- // src/types/wallet.ts
1065
- var WalletScheme = /* @__PURE__ */ ((WalletScheme2) => {
1066
- WalletScheme2["DKLS"] = "DKLS";
1067
- WalletScheme2["CGGMP"] = "CGGMP";
1068
- WalletScheme2["ED25519"] = "ED25519";
1069
- return WalletScheme2;
1070
- })(WalletScheme || {});
1071
- var WalletType = /* @__PURE__ */ ((WalletType2) => {
1072
- WalletType2["EVM"] = "EVM";
1073
- WalletType2["SOLANA"] = "SOLANA";
1074
- WalletType2["COSMOS"] = "COSMOS";
1075
- return WalletType2;
1076
- })(WalletType || {});
1077
- var Chain = /* @__PURE__ */ ((Chain2) => {
1078
- Chain2["ETH"] = "ETH";
1079
- Chain2["CELO"] = "CELO";
1080
- Chain2["MATIC"] = "MATIC";
1081
- return Chain2;
1082
- })(Chain || {});
1083
- var Network = /* @__PURE__ */ ((Network2) => {
1084
- Network2["ETHEREUM"] = "ETHEREUM";
1085
- Network2["SEPOLIA"] = "SEPOLIA";
1086
- Network2["ARBITRUM"] = "ARBITRUM";
1087
- Network2["BASE"] = "BASE";
1088
- Network2["OPTIMISM"] = "OPTIMISM";
1089
- Network2["POLYGON"] = "POLYGON";
1090
- Network2["SOLANA"] = "SOLANA";
1091
- Network2["COSMOS"] = "COSMOS";
1092
- Network2["CELO"] = "CELO";
1093
- Network2["NOBLE"] = "NOBLE";
1094
- return Network2;
1095
- })(Network || {});
1096
- var PREGEN_IDENTIFIER_TYPES = [
1097
- "EMAIL",
1098
- "PHONE",
1099
- "CUSTOM_ID",
1100
- "DISCORD" /* DISCORD */,
1101
- "TWITTER" /* TWITTER */,
1102
- "TELEGRAM" /* TELEGRAM */
1103
- ];
1104
- var NON_ED25519 = ["DKLS" /* DKLS */, "CGGMP" /* CGGMP */];
1105
-
1106
- // src/index.ts
1107
- var src_default = client_default;
1
+ import "./chunk-BBZEL7EG.js";
2
+ export * from "./client.js";
3
+ export * from "./types/index.js";
4
+ export * from "./utils.js";
5
+ import Client from "./client.js";
6
+ var src_default = Client;
1108
7
  export {
1109
- AuthMethod,
1110
- Chain,
1111
- EmailTheme,
1112
- EncryptorType,
1113
- KeyShareType,
1114
- NON_ED25519,
1115
- Network,
1116
- OAuthMethod,
1117
- OnRampAsset,
1118
- OnRampProvider,
1119
- OnRampPurchaseStatus,
1120
- OnRampPurchaseType,
1121
- PREGEN_IDENTIFIER_TYPES,
1122
- PasswordStatus,
1123
- PublicKeyStatus,
1124
- PublicKeyType,
1125
- WalletScheme,
1126
- WalletType,
1127
- src_default as default,
1128
- extractAuthInfo,
1129
- extractWalletRef,
1130
- handleResponseError,
1131
- handleResponseSuccess,
1132
- isEmail,
1133
- isExternalWallet,
1134
- isExternalWalletAddress,
1135
- isFarcaster,
1136
- isPhone,
1137
- isTelegram,
1138
- isUserId,
1139
- isWalletId
8
+ src_default as default
1140
9
  };