@getpara/user-management-client 2.0.0-dev.1 → 2.0.0-dev.3

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