@getpara/user-management-client 2.0.0-dev.0 → 2.0.0-dev.2

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