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

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,6 +1,8 @@
1
1
  var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
7
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
8
  var __getProtoOf = Object.getPrototypeOf;
@@ -18,6 +20,7 @@ var __spreadValues = (a, b) => {
18
20
  }
19
21
  return a;
20
22
  };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
24
  var __objRest = (source, exclude) => {
22
25
  var target = {};
23
26
  for (var prop in source)
@@ -75,6 +78,7 @@ var __async = (__this, __arguments, generator) => {
75
78
  // src/index.ts
76
79
  var src_exports = {};
77
80
  __export(src_exports, {
81
+ AUTH_TYPES: () => AUTH_TYPES,
78
82
  AuthMethod: () => AuthMethod,
79
83
  Chain: () => Chain,
80
84
  EmailTheme: () => EmailTheme,
@@ -88,6 +92,7 @@ __export(src_exports, {
88
92
  OnRampPurchaseStatus: () => OnRampPurchaseStatus,
89
93
  OnRampPurchaseType: () => OnRampPurchaseType,
90
94
  PREGEN_IDENTIFIER_TYPES: () => PREGEN_IDENTIFIER_TYPES,
95
+ ParaApiError: () => ParaApiError,
91
96
  PasswordStatus: () => PasswordStatus,
92
97
  PublicKeyStatus: () => PublicKeyStatus,
93
98
  PublicKeyType: () => PublicKeyType,
@@ -98,17 +103,23 @@ __export(src_exports, {
98
103
  extractWalletRef: () => extractWalletRef,
99
104
  handleResponseError: () => handleResponseError,
100
105
  handleResponseSuccess: () => handleResponseSuccess,
106
+ isCustomId: () => isCustomId,
107
+ isDiscord: () => isDiscord,
101
108
  isEmail: () => isEmail,
102
109
  isExternalWallet: () => isExternalWallet,
103
110
  isExternalWalletAddress: () => isExternalWalletAddress,
104
111
  isFarcaster: () => isFarcaster,
105
112
  isPhone: () => isPhone,
106
113
  isPhoneLegacy: () => isPhoneLegacy,
114
+ isPregenAuth: () => isPregenAuth,
107
115
  isPrimary: () => isPrimary,
108
116
  isTelegram: () => isTelegram,
109
117
  isUserId: () => isUserId,
110
118
  isVerifiedAuth: () => isVerifiedAuth,
111
- isWalletId: () => isWalletId
119
+ isWalletId: () => isWalletId,
120
+ isX: () => isX,
121
+ toPregenIds: () => toPregenIds,
122
+ toPregenTypeAndId: () => toPregenTypeAndId
112
123
  });
113
124
  module.exports = __toCommonJS(src_exports);
114
125
 
@@ -136,33 +147,45 @@ function isValid(s) {
136
147
  return !!s && s !== "null" && s !== "undefined" && s !== "";
137
148
  }
138
149
  function isEmail(params) {
139
- return !!params && isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.externalWalletAddress);
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);
140
151
  }
141
152
  function isPhone(params) {
142
- 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);
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);
143
154
  }
144
155
  function isPhoneLegacy(params) {
145
- return !!params && isValid(params.phone) && isValid(params.countryCode) && !isValid(params.email) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.externalWalletAddress);
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);
146
157
  }
147
158
  function isFarcaster(params) {
148
- return !!params && isValid(params.farcasterUsername) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.telegramUserId) && !isValid(params.externalWalletAddress);
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);
149
160
  }
150
161
  function isTelegram(params) {
151
- return !!params && isValid(params.telegramUserId) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.externalWalletAddress);
152
- }
153
- function isUserId(params) {
154
- return !!params && isValid(params.userId) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.externalWalletAddress);
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);
155
163
  }
156
164
  function isExternalWallet(params) {
157
- return !!params && isValid(params.externalWalletAddress) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId);
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);
158
178
  }
159
179
  function isPrimary(params) {
160
- return isEmail(params) || isPhone(params) || isFarcaster(params) || isTelegram(params);
180
+ return isEmail(params) || isPhone(params) || isFarcaster(params) || isTelegram(params) || isExternalWallet(params);
161
181
  }
162
182
  function isVerifiedAuth(params) {
163
183
  return isEmail(params) || isPhone(params);
164
184
  }
165
- function extractAuthInfo(obj, { allowUserId = false, isRequired = false } = {}) {
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 } = {}) {
166
189
  obj = Object.entries(obj || {}).reduce((acc, [k, v]) => {
167
190
  return __spreadValues(__spreadValues({}, acc), !!v && v !== "null" && v !== "undefined" && v !== "" ? { [k]: v } : {});
168
191
  }, {});
@@ -213,6 +236,24 @@ function extractAuthInfo(obj, { allowUserId = false, isRequired = false } = {})
213
236
  authType: "externalWallet",
214
237
  identifier: obj.externalWalletAddress
215
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
+ };
216
257
  case (isUserId(obj) && allowUserId):
217
258
  return {
218
259
  auth: { userId: obj.userId },
@@ -227,6 +268,23 @@ function extractAuthInfo(obj, { allowUserId = false, isRequired = false } = {})
227
268
  }
228
269
  return void 0;
229
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
+ }
230
288
 
231
289
  // src/consts.ts
232
290
  var SESSION_COOKIE_HEADER_NAME = "x-capsule-sid";
@@ -282,6 +340,13 @@ var Client = class {
282
340
  retrieveSessionCookie,
283
341
  persistSessionCookie
284
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
+ */
285
350
  this.createUser = (body) => __async(this, null, function* () {
286
351
  const res = yield this.baseRequest.post(`/users`, body);
287
352
  return res.data;
@@ -292,20 +357,55 @@ var Client = class {
292
357
  });
293
358
  return res;
294
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
+ });
295
366
  this.verifyTelegram = (authObject) => __async(this, null, function* () {
296
367
  return (yield this.baseRequest.post("/users/telegram", {
297
368
  authObject
298
369
  })).data;
299
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
+ });
300
380
  this.externalWalletLogin = (body) => __async(this, null, function* () {
301
381
  const res = yield this.baseRequest.post(`/users/external-wallets/login`, body);
302
382
  return res.data;
303
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
+ });
304
398
  // POST /users/:userId/verify-email
399
+ /**
400
+ * @deprecated
401
+ */
305
402
  this.verifyEmail = (userId, body) => __async(this, null, function* () {
306
403
  const res = yield this.baseRequest.post(`/users/${userId}/verify-email`, body);
307
404
  return res;
308
405
  });
406
+ /**
407
+ * @deprecated
408
+ */
309
409
  this.verifyPhone = (userId, body) => __async(this, null, function* () {
310
410
  const res = yield this.baseRequest.post(`/users/${userId}/verify-identifier`, body);
311
411
  return res;
@@ -314,6 +414,10 @@ var Client = class {
314
414
  const res = yield this.baseRequest.post(`/users/${userId}/external-wallets/verify`, body);
315
415
  return res;
316
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
+ });
317
421
  // POST /users/:userId/biometrics/key
318
422
  this.addSessionPublicKey = (userId, body) => __async(this, null, function* () {
319
423
  const res = yield this.baseRequest.post(`/users/${userId}/biometrics/key`, body);
@@ -398,11 +502,21 @@ var Client = class {
398
502
  });
399
503
  return res.data;
400
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
+ });
401
511
  // POST /wallets/pregen/claim
402
512
  this.claimPregenWallets = (body) => __async(this, null, function* () {
403
513
  const res = yield this.baseRequest.post(`/wallets/pregen/claim`, body);
404
514
  return res.data;
405
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
+ });
406
520
  // POST /users/:userId/wallets/:walletId/transactions/send
407
521
  this.sendTransaction = (userId, walletId, body) => __async(this, null, function* () {
408
522
  const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/transactions/send`, body);
@@ -666,6 +780,12 @@ var Client = class {
666
780
  return res;
667
781
  });
668
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
+ }
669
789
  // POST /recovery/init
670
790
  initializeRecovery(email) {
671
791
  return __async(this, null, function* () {
@@ -687,6 +807,12 @@ var Client = class {
687
807
  return res;
688
808
  });
689
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
+ }
690
816
  // POST /recovery/init
691
817
  initializeRecoveryForPhone(phone, countryCode) {
692
818
  return __async(this, null, function* () {
@@ -732,7 +858,17 @@ var Client = class {
732
858
  return res;
733
859
  });
734
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
+ }
735
868
  // POST /2fa/phone/verify
869
+ /**
870
+ * @deprecated
871
+ */
736
872
  verify2FAForPhone(phone, verificationCode) {
737
873
  return __async(this, null, function* () {
738
874
  const body = { phone, verificationCode };
@@ -1055,6 +1191,18 @@ var Client = class {
1055
1191
  var client_default = Client;
1056
1192
 
1057
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
+ ];
1058
1206
  var EncryptorType = /* @__PURE__ */ ((EncryptorType2) => {
1059
1207
  EncryptorType2["USER"] = "USER";
1060
1208
  EncryptorType2["RECOVERY"] = "RECOVERY";
@@ -1173,9 +1321,10 @@ var PREGEN_IDENTIFIER_TYPES = [
1173
1321
  "EMAIL",
1174
1322
  "PHONE",
1175
1323
  "CUSTOM_ID",
1176
- "DISCORD" /* DISCORD */,
1177
- "TWITTER" /* TWITTER */,
1178
- "TELEGRAM" /* TELEGRAM */
1324
+ "DISCORD",
1325
+ "TWITTER",
1326
+ "TELEGRAM",
1327
+ "FARCASTER"
1179
1328
  ];
1180
1329
  var NON_ED25519 = ["DKLS" /* DKLS */, "CGGMP" /* CGGMP */];
1181
1330
 
@@ -1183,6 +1332,7 @@ var NON_ED25519 = ["DKLS" /* DKLS */, "CGGMP" /* CGGMP */];
1183
1332
  var src_default = client_default;
1184
1333
  // Annotate the CommonJS export names for ESM import in node:
1185
1334
  0 && (module.exports = {
1335
+ AUTH_TYPES,
1186
1336
  AuthMethod,
1187
1337
  Chain,
1188
1338
  EmailTheme,
@@ -1196,6 +1346,7 @@ var src_default = client_default;
1196
1346
  OnRampPurchaseStatus,
1197
1347
  OnRampPurchaseType,
1198
1348
  PREGEN_IDENTIFIER_TYPES,
1349
+ ParaApiError,
1199
1350
  PasswordStatus,
1200
1351
  PublicKeyStatus,
1201
1352
  PublicKeyType,
@@ -1205,15 +1356,21 @@ var src_default = client_default;
1205
1356
  extractWalletRef,
1206
1357
  handleResponseError,
1207
1358
  handleResponseSuccess,
1359
+ isCustomId,
1360
+ isDiscord,
1208
1361
  isEmail,
1209
1362
  isExternalWallet,
1210
1363
  isExternalWalletAddress,
1211
1364
  isFarcaster,
1212
1365
  isPhone,
1213
1366
  isPhoneLegacy,
1367
+ isPregenAuth,
1214
1368
  isPrimary,
1215
1369
  isTelegram,
1216
1370
  isUserId,
1217
1371
  isVerifiedAuth,
1218
- isWalletId
1372
+ isWalletId,
1373
+ isX,
1374
+ toPregenIds,
1375
+ toPregenTypeAndId
1219
1376
  });
Binary file
Binary file
package/dist/esm/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
2
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
4
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -14,6 +16,7 @@ var __spreadValues = (a, b) => {
14
16
  }
15
17
  return a;
16
18
  };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
17
20
  var __objRest = (source, exclude) => {
18
21
  var target = {};
19
22
  for (var prop in source)
@@ -71,33 +74,45 @@ function isValid(s) {
71
74
  return !!s && s !== "null" && s !== "undefined" && s !== "";
72
75
  }
73
76
  function isEmail(params) {
74
- return !!params && isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.externalWalletAddress);
77
+ 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);
75
78
  }
76
79
  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);
80
+ 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);
78
81
  }
79
82
  function isPhoneLegacy(params) {
80
- return !!params && isValid(params.phone) && isValid(params.countryCode) && !isValid(params.email) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.externalWalletAddress);
83
+ 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);
81
84
  }
82
85
  function isFarcaster(params) {
83
- return !!params && isValid(params.farcasterUsername) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.telegramUserId) && !isValid(params.externalWalletAddress);
86
+ 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);
84
87
  }
85
88
  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);
89
+ 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);
90
90
  }
91
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);
92
+ 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);
93
+ }
94
+ function isX(params) {
95
+ 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);
96
+ }
97
+ function isDiscord(params) {
98
+ 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);
99
+ }
100
+ function isCustomId(params) {
101
+ 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);
102
+ }
103
+ function isUserId(params) {
104
+ 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);
93
105
  }
94
106
  function isPrimary(params) {
95
- return isEmail(params) || isPhone(params) || isFarcaster(params) || isTelegram(params);
107
+ return isEmail(params) || isPhone(params) || isFarcaster(params) || isTelegram(params) || isExternalWallet(params);
96
108
  }
97
109
  function isVerifiedAuth(params) {
98
110
  return isEmail(params) || isPhone(params);
99
111
  }
100
- function extractAuthInfo(obj, { allowUserId = false, isRequired = false } = {}) {
112
+ function isPregenAuth(params) {
113
+ return isPrimary(params) && !isExternalWallet(params) || isX(params) || isDiscord(params) || isCustomId(params);
114
+ }
115
+ function extractAuthInfo(obj, { allowUserId = false, allowPregen = false, isRequired = false } = {}) {
101
116
  obj = Object.entries(obj || {}).reduce((acc, [k, v]) => {
102
117
  return __spreadValues(__spreadValues({}, acc), !!v && v !== "null" && v !== "undefined" && v !== "" ? { [k]: v } : {});
103
118
  }, {});
@@ -148,6 +163,24 @@ function extractAuthInfo(obj, { allowUserId = false, isRequired = false } = {})
148
163
  authType: "externalWallet",
149
164
  identifier: obj.externalWalletAddress
150
165
  };
166
+ case (allowPregen && isX(obj)):
167
+ return {
168
+ auth: { xUsername: obj.xUsername },
169
+ authType: "x",
170
+ identifier: obj.xUsername
171
+ };
172
+ case (allowPregen && isDiscord(obj)):
173
+ return {
174
+ auth: { discordUsername: obj.discordUsername },
175
+ authType: "discord",
176
+ identifier: obj.discordUsername
177
+ };
178
+ case (allowPregen && isCustomId(obj)):
179
+ return {
180
+ auth: { customId: obj.customId },
181
+ authType: "customId",
182
+ identifier: obj.customId
183
+ };
151
184
  case (isUserId(obj) && allowUserId):
152
185
  return {
153
186
  auth: { userId: obj.userId },
@@ -162,6 +195,23 @@ function extractAuthInfo(obj, { allowUserId = false, isRequired = false } = {})
162
195
  }
163
196
  return void 0;
164
197
  }
198
+ function toPregenTypeAndId(auth) {
199
+ const { authType, identifier: pregenIdentifier } = extractAuthInfo(auth, { isRequired: true, allowPregen: true });
200
+ const pregenIdentifierType = {
201
+ email: "EMAIL",
202
+ phone: "PHONE",
203
+ farcaster: "FARCASTER",
204
+ telegram: "TELEGRAM",
205
+ discord: "DISCORD",
206
+ x: "TWITTER",
207
+ customId: "CUSTOM_ID"
208
+ }[authType];
209
+ return [pregenIdentifierType, pregenIdentifier];
210
+ }
211
+ function toPregenIds(auth) {
212
+ const [pregenIdentifierType, pregenIdentifier] = toPregenTypeAndId(auth);
213
+ return { [pregenIdentifierType]: [pregenIdentifier] };
214
+ }
165
215
 
166
216
  // src/consts.ts
167
217
  var SESSION_COOKIE_HEADER_NAME = "x-capsule-sid";
@@ -217,6 +267,13 @@ var Client = class {
217
267
  retrieveSessionCookie,
218
268
  persistSessionCookie
219
269
  }) {
270
+ this.signUpOrLogIn = (body) => __async(this, null, function* () {
271
+ const res = yield this.baseRequest.post(`/users/init`, body);
272
+ return res.data;
273
+ });
274
+ /**
275
+ * @deprecated
276
+ */
220
277
  this.createUser = (body) => __async(this, null, function* () {
221
278
  const res = yield this.baseRequest.post(`/users`, body);
222
279
  return res.data;
@@ -227,20 +284,55 @@ var Client = class {
227
284
  });
228
285
  return res;
229
286
  });
287
+ this.checkUserExistsV2 = (auth) => __async(this, null, function* () {
288
+ const res = yield this.baseRequest.get("/users/exists", {
289
+ params: __spreadValues({}, auth)
290
+ });
291
+ return res.data;
292
+ });
230
293
  this.verifyTelegram = (authObject) => __async(this, null, function* () {
231
294
  return (yield this.baseRequest.post("/users/telegram", {
232
295
  authObject
233
296
  })).data;
234
297
  });
298
+ this.verifyTelegramV2 = (authObject) => __async(this, null, function* () {
299
+ return (yield this.baseRequest.post("/users/telegram/v2", {
300
+ authObject
301
+ })).data;
302
+ });
303
+ this.verifyOAuth = () => __async(this, null, function* () {
304
+ const res = yield this.baseRequest.post("/users/verify-oauth");
305
+ return res.data;
306
+ });
235
307
  this.externalWalletLogin = (body) => __async(this, null, function* () {
236
308
  const res = yield this.baseRequest.post(`/users/external-wallets/login`, body);
237
309
  return res.data;
238
310
  });
311
+ this.loginExternalWalletV2 = (_0) => __async(this, [_0], function* ({
312
+ externalWallet,
313
+ shouldTrackUser
314
+ }) {
315
+ const res = yield this.baseRequest.post(`/users/external-wallets/login/v2`, {
316
+ externalWallet,
317
+ shouldTrackUser
318
+ });
319
+ return res.data;
320
+ });
321
+ this.verifyNewAccount = (userId, body) => __async(this, null, function* () {
322
+ const res = yield this.baseRequest.post(`/users/${userId}/verify`, body);
323
+ return res.data;
324
+ });
239
325
  // POST /users/:userId/verify-email
326
+ /**
327
+ * @deprecated
328
+ */
240
329
  this.verifyEmail = (userId, body) => __async(this, null, function* () {
241
330
  const res = yield this.baseRequest.post(`/users/${userId}/verify-email`, body);
242
331
  return res;
243
332
  });
333
+ /**
334
+ * @deprecated
335
+ */
244
336
  this.verifyPhone = (userId, body) => __async(this, null, function* () {
245
337
  const res = yield this.baseRequest.post(`/users/${userId}/verify-identifier`, body);
246
338
  return res;
@@ -249,6 +341,10 @@ var Client = class {
249
341
  const res = yield this.baseRequest.post(`/users/${userId}/external-wallets/verify`, body);
250
342
  return res;
251
343
  });
344
+ this.verifyExternalWalletV2 = (userId, body) => __async(this, null, function* () {
345
+ const res = yield this.baseRequest.post(`/users/${userId}/external-wallets/verify/v2`, body);
346
+ return res.data;
347
+ });
252
348
  // POST /users/:userId/biometrics/key
253
349
  this.addSessionPublicKey = (userId, body) => __async(this, null, function* () {
254
350
  const res = yield this.baseRequest.post(`/users/${userId}/biometrics/key`, body);
@@ -333,11 +429,21 @@ var Client = class {
333
429
  });
334
430
  return res.data;
335
431
  });
432
+ this.getPregenWalletsV2 = (pregenIds, isPortal = false, userId) => __async(this, null, function* () {
433
+ const res = yield this.baseRequest.get("/wallets/pregen", {
434
+ params: { ids: pregenIds, expand: isPortal, userId }
435
+ });
436
+ return res.data;
437
+ });
336
438
  // POST /wallets/pregen/claim
337
439
  this.claimPregenWallets = (body) => __async(this, null, function* () {
338
440
  const res = yield this.baseRequest.post(`/wallets/pregen/claim`, body);
339
441
  return res.data;
340
442
  });
443
+ this.claimPregenWalletsV2 = (body) => __async(this, null, function* () {
444
+ const res = yield this.baseRequest.post(`/wallets/pregen/claim`, body);
445
+ return res.data;
446
+ });
341
447
  // POST /users/:userId/wallets/:walletId/transactions/send
342
448
  this.sendTransaction = (userId, walletId, body) => __async(this, null, function* () {
343
449
  const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/transactions/send`, body);
@@ -601,6 +707,12 @@ var Client = class {
601
707
  return res;
602
708
  });
603
709
  }
710
+ setup2FAV2(userId) {
711
+ return __async(this, null, function* () {
712
+ const res = yield this.baseRequest.post(`/2fa/users/${userId}/setup`);
713
+ return res.data;
714
+ });
715
+ }
604
716
  // POST /recovery/init
605
717
  initializeRecovery(email) {
606
718
  return __async(this, null, function* () {
@@ -622,6 +734,12 @@ var Client = class {
622
734
  return res;
623
735
  });
624
736
  }
737
+ getFarcasterAuthStatusV2() {
738
+ return __async(this, null, function* () {
739
+ const res = yield this.baseRequest.post(`/auth/farcaster/status/v2`);
740
+ return res.data;
741
+ });
742
+ }
625
743
  // POST /recovery/init
626
744
  initializeRecoveryForPhone(phone, countryCode) {
627
745
  return __async(this, null, function* () {
@@ -667,7 +785,17 @@ var Client = class {
667
785
  return res;
668
786
  });
669
787
  }
788
+ verify2FAV2(auth, verificationCode) {
789
+ return __async(this, null, function* () {
790
+ const body = __spreadProps(__spreadValues({}, auth), { verificationCode });
791
+ const res = yield this.baseRequest.post("/2fa/verify", body);
792
+ return res.data;
793
+ });
794
+ }
670
795
  // POST /2fa/phone/verify
796
+ /**
797
+ * @deprecated
798
+ */
671
799
  verify2FAForPhone(phone, verificationCode) {
672
800
  return __async(this, null, function* () {
673
801
  const body = { phone, verificationCode };
@@ -990,6 +1118,18 @@ var Client = class {
990
1118
  var client_default = Client;
991
1119
 
992
1120
  // src/types/auth.ts
1121
+ var AUTH_TYPES = [
1122
+ "email",
1123
+ "phone",
1124
+ "phoneLegacy",
1125
+ "farcaster",
1126
+ "telegram",
1127
+ "userId",
1128
+ "externalWallet",
1129
+ "discord",
1130
+ "x",
1131
+ "customId"
1132
+ ];
993
1133
  var EncryptorType = /* @__PURE__ */ ((EncryptorType2) => {
994
1134
  EncryptorType2["USER"] = "USER";
995
1135
  EncryptorType2["RECOVERY"] = "RECOVERY";
@@ -1108,15 +1248,17 @@ var PREGEN_IDENTIFIER_TYPES = [
1108
1248
  "EMAIL",
1109
1249
  "PHONE",
1110
1250
  "CUSTOM_ID",
1111
- "DISCORD" /* DISCORD */,
1112
- "TWITTER" /* TWITTER */,
1113
- "TELEGRAM" /* TELEGRAM */
1251
+ "DISCORD",
1252
+ "TWITTER",
1253
+ "TELEGRAM",
1254
+ "FARCASTER"
1114
1255
  ];
1115
1256
  var NON_ED25519 = ["DKLS" /* DKLS */, "CGGMP" /* CGGMP */];
1116
1257
 
1117
1258
  // src/index.ts
1118
1259
  var src_default = client_default;
1119
1260
  export {
1261
+ AUTH_TYPES,
1120
1262
  AuthMethod,
1121
1263
  Chain,
1122
1264
  EmailTheme,
@@ -1130,6 +1272,7 @@ export {
1130
1272
  OnRampPurchaseStatus,
1131
1273
  OnRampPurchaseType,
1132
1274
  PREGEN_IDENTIFIER_TYPES,
1275
+ ParaApiError,
1133
1276
  PasswordStatus,
1134
1277
  PublicKeyStatus,
1135
1278
  PublicKeyType,
@@ -1140,15 +1283,21 @@ export {
1140
1283
  extractWalletRef,
1141
1284
  handleResponseError,
1142
1285
  handleResponseSuccess,
1286
+ isCustomId,
1287
+ isDiscord,
1143
1288
  isEmail,
1144
1289
  isExternalWallet,
1145
1290
  isExternalWalletAddress,
1146
1291
  isFarcaster,
1147
1292
  isPhone,
1148
1293
  isPhoneLegacy,
1294
+ isPregenAuth,
1149
1295
  isPrimary,
1150
1296
  isTelegram,
1151
1297
  isUserId,
1152
1298
  isVerifiedAuth,
1153
- isWalletId
1299
+ isWalletId,
1300
+ isX,
1301
+ toPregenIds,
1302
+ toPregenTypeAndId
1154
1303
  };
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  import { AxiosResponse } from 'axios';
2
- import { Auth, AuthIdentifier, AuthMethod, BackupKitEmailProps, BiometricLocationHint, Chain, CurrentWalletIds, EncryptedKeyShare, EncryptorType, KeyShareType, Network, OnRampAsset, OnRampConfig, OnRampProvider, OnRampPurchase, OnRampPurchaseCreateParams, OnRampPurchaseUpdateParams, PasswordStatus, PregenIds, PrimaryAuth, PublicKeyStatus, PublicKeyType, SessionInfo, TelegramAuthResponse, TPregenIdentifierType, VerificationEmailProps, VerifiedAuth, WalletEntity, WalletParams, WalletScheme, WalletType } from './types/index.js';
2
+ import { Auth, AuthIdentifier, AuthMethod, BackupKitEmailProps, BiometricLocationHint, Chain, CurrentWalletIds, EncryptedKeyShare, EncryptorType, ExternalWalletInfo, LoginExternalWalletResponse, KeyShareType, Network, OnRampAsset, OnRampConfig, OnRampProvider, OnRampPurchase, OnRampPurchaseCreateParams, OnRampPurchaseUpdateParams, PasswordStatus, PregenIds, PrimaryAuth, PublicKeyStatus, PublicKeyType, ServerAuthStateSignup, SessionInfo, Setup2faResponse, SignUpOrLogInResponse, TelegramAuthResponse, TPregenIdentifierType, VerificationEmailProps, VerifiedAuth, VerifyFarcasterResponse, VerifyTelegramResponse, VerifyThirdPartyAuth, WalletEntity, WalletParams, WalletScheme, WalletType, VerifyExternalWalletParams } from './types/index.js';
3
3
  interface ConfigOpts {
4
4
  useFetchAdapter?: boolean;
5
5
  }
@@ -146,13 +146,34 @@ export declare const handleResponseError: (error: any) => never;
146
146
  declare class Client {
147
147
  private baseRequest;
148
148
  constructor({ userManagementHost, apiKey, partnerId, version, opts, retrieveSessionCookie, persistSessionCookie, }: ClientConfig);
149
+ signUpOrLogIn: (body: VerifiedAuth & VerificationEmailProps) => Promise<SignUpOrLogInResponse>;
150
+ /**
151
+ * @deprecated
152
+ */
149
153
  createUser: (body: VerifiedAuth & VerificationEmailProps) => Promise<createUserIdRes>;
150
154
  checkUserExists: (auth: VerifiedAuth) => Promise<any>;
155
+ checkUserExistsV2: (auth: VerifiedAuth) => Promise<{
156
+ exists: boolean;
157
+ }>;
151
158
  verifyTelegram: (authObject: TelegramAuthResponse) => Promise<VerifyTelegramRes>;
159
+ verifyTelegramV2: (authObject: TelegramAuthResponse) => Promise<VerifyTelegramResponse>;
160
+ verifyOAuth: () => Promise<VerifyThirdPartyAuth | null>;
152
161
  externalWalletLogin: (body: ExternalWalletLoginBody) => Promise<ExternalWalletLoginRes>;
162
+ loginExternalWalletV2: ({ externalWallet, shouldTrackUser, }: {
163
+ externalWallet: ExternalWalletInfo;
164
+ shouldTrackUser?: boolean;
165
+ }) => Promise<LoginExternalWalletResponse>;
166
+ verifyNewAccount: (userId: string, body: verifyBody) => Promise<ServerAuthStateSignup>;
167
+ /**
168
+ * @deprecated
169
+ */
153
170
  verifyEmail: (userId: string, body: verifyBody) => Promise<any>;
171
+ /**
172
+ * @deprecated
173
+ */
154
174
  verifyPhone: (userId: string, body: verifyBody) => Promise<any>;
155
175
  verifyExternalWallet: (userId: string, body: verifyExternalWalletBody) => Promise<any>;
176
+ verifyExternalWalletV2: (userId: string, body: VerifyExternalWalletParams) => Promise<ServerAuthStateSignup>;
156
177
  addSessionPublicKey: (userId: string, body: sessionPublicKeyBody) => Promise<any>;
157
178
  getSessionPublicKeys: (userId: string) => Promise<any>;
158
179
  getBiometricLocationHints: (auth: PrimaryAuth) => Promise<BiometricLocationHint[]>;
@@ -171,9 +192,15 @@ declare class Client {
171
192
  getPregenWallets: <ReturnType = {
172
193
  wallets: WalletEntity[];
173
194
  }>(pregenIds: PregenIds, isPortal?: boolean, userId?: string) => Promise<ReturnType>;
195
+ getPregenWalletsV2: (pregenIds: PregenIds, isPortal?: boolean, userId?: string) => Promise<{
196
+ wallets: WalletEntity[];
197
+ }>;
174
198
  claimPregenWallets: <ReturnType = {
175
199
  walletIds?: string[];
176
200
  }>(body?: claimPreGenWalletsBody) => Promise<ReturnType>;
201
+ claimPregenWalletsV2: (body?: claimPreGenWalletsBody) => Promise<{
202
+ walletIds: string[];
203
+ }>;
177
204
  sendTransaction: (userId: string, walletId: string, body: sendTransactionBody) => Promise<any>;
178
205
  signTransaction: (userId: string, walletId: string, body: signTransactionBody) => Promise<any>;
179
206
  refreshKeys: (userId: string, walletId: string, oldPartnerId?: string, newPartnerId?: string, keyShareProtocolId?: string) => Promise<any>;
@@ -216,9 +243,11 @@ declare class Client {
216
243
  check2FAStatus(userId: string): Promise<AxiosResponse<any, any>>;
217
244
  enable2FA(userId: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
218
245
  setup2FA(userId: string): Promise<AxiosResponse<any, any>>;
246
+ setup2FAV2(userId: string): Promise<Setup2faResponse>;
219
247
  initializeRecovery(email: string): Promise<AxiosResponse<any, any>>;
220
248
  initializeFarcasterLogin(): Promise<AxiosResponse<any, any>>;
221
249
  getFarcasterAuthStatus(): Promise<AxiosResponse<any, any>>;
250
+ getFarcasterAuthStatusV2(): Promise<VerifyFarcasterResponse>;
222
251
  initializeRecoveryForPhone(phone: string, countryCode: string): Promise<AxiosResponse<any, any>>;
223
252
  finalizeRecovery(userId: string, walletId: string): Promise<AxiosResponse<any, any>>;
224
253
  recoverUserShares(userId: string, walletId: string): Promise<AxiosResponse<{
@@ -238,6 +267,10 @@ declare class Client {
238
267
  verifyEmailForRecovery(email: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
239
268
  verifyPhoneForRecovery(phone: string, countryCode: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
240
269
  verify2FA(email: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
270
+ verify2FAV2(auth: VerifiedAuth, verificationCode: string): Promise<any>;
271
+ /**
272
+ * @deprecated
273
+ */
241
274
  verify2FAForPhone(phone: AuthIdentifier<'phone'>, verificationCode: string): Promise<AxiosResponse<any, any>>;
242
275
  tempTrasmissionInit(message: string, userId?: string): Promise<AxiosResponse<any, any>>;
243
276
  tempTrasmission(id: string): Promise<AxiosResponse<any, any>>;
@@ -1,5 +1,6 @@
1
1
  export * from './client.js';
2
2
  export * from './types/index.js';
3
3
  export * from './utils.js';
4
+ export * from './error.js';
4
5
  import Client from './client.js';
5
6
  export default Client;
@@ -1,7 +1,9 @@
1
- import { CurrentWalletIds, SupportedWalletTypes } from './wallet.js';
2
- export type AuthType = 'email' | 'phone' | 'phoneLegacy' | 'farcaster' | 'telegram' | 'userId' | 'externalWallet';
1
+ import { CurrentWalletIds, ExternalWalletType, SupportedWalletTypes } from './wallet.js';
2
+ export declare const AUTH_TYPES: readonly ["email", "phone", "phoneLegacy", "farcaster", "telegram", "userId", "externalWallet", "discord", "x", "customId"];
3
+ export type AuthType = 'email' | 'phone' | 'phoneLegacy' | 'farcaster' | 'telegram' | 'userId' | 'externalWallet' | 'discord' | 'x' | 'customId';
3
4
  export type PrimaryAuthType = Extract<AuthType, 'email' | 'phone' | 'farcaster' | 'telegram' | 'externalWallet'>;
4
- export type VerifiedAuthType = Extract<PrimaryAuthType, 'email' | 'phone'>;
5
+ export type VerifiedAuthType = Extract<PrimaryAuthType, 'email' | 'phone' | 'externalWallet'>;
6
+ export type PregenAuthType = Exclude<PrimaryAuthType, 'externalWallet'> | Extract<AuthType, 'discord' | 'x' | 'customId'>;
5
7
  export type AuthIdentifier<T extends AuthType | never> = T extends 'phone' ? `+${number}` : string;
6
8
  export type AuthInfo<T extends Exclude<AuthType, 'phoneLegacy'> = Exclude<AuthType, 'phoneLegacy'>> = {
7
9
  auth: Auth<T>;
@@ -10,6 +12,7 @@ export type AuthInfo<T extends Exclude<AuthType, 'phoneLegacy'> = Exclude<AuthTy
10
12
  };
11
13
  export type PrimaryAuthInfo = AuthInfo<PrimaryAuthType>;
12
14
  export type VerifiedAuthInfo = AuthInfo<VerifiedAuthType>;
15
+ export type PregenAuthInfo = AuthInfo<PregenAuthType>;
13
16
  export type AuthParams = Record<string, any> & {
14
17
  email?: string;
15
18
  phone?: string;
@@ -31,12 +34,37 @@ export type Auth<T extends AuthType = AuthType> = T extends 'email' ? {
31
34
  } : T extends 'telegram' ? {
32
35
  telegramUserId: AuthIdentifier<'telegram'>;
33
36
  } : T extends 'externalWallet' ? {
34
- externalWalletAddress: string;
37
+ externalWalletAddress: AuthIdentifier<'externalWallet'>;
38
+ } : T extends 'x' ? {
39
+ xUsername: AuthIdentifier<'x'>;
40
+ } : T extends 'discord' ? {
41
+ discordUsername: AuthIdentifier<'discord'>;
42
+ } : T extends 'customId' ? {
43
+ customId: AuthIdentifier<'customId'>;
35
44
  } : {
36
- userId: string;
45
+ userId: AuthIdentifier<'userId'>;
37
46
  };
38
47
  export type PrimaryAuth = Auth<PrimaryAuthType>;
39
48
  export type VerifiedAuth = Auth<VerifiedAuthType>;
49
+ export type PregenAuth = Auth<PregenAuthType>;
50
+ export type AuthExtras = {
51
+ /**
52
+ * The current user's third-party username.
53
+ */
54
+ username?: string;
55
+ /**
56
+ * The current user's third-party display name.
57
+ */
58
+ displayName?: string;
59
+ /**
60
+ * The current user's third-party profile picture URL.
61
+ */
62
+ pfpUrl?: string;
63
+ /**
64
+ * The current user's external wallet information.
65
+ */
66
+ externalWallet?: ExternalWalletInfo;
67
+ };
40
68
  export declare enum EncryptorType {
41
69
  USER = "USER",
42
70
  RECOVERY = "RECOVERY",
@@ -109,3 +137,66 @@ export type SessionInfo = {
109
137
  origin?: string;
110
138
  email?: string;
111
139
  };
140
+ export type ServerAuthStateBase = AuthExtras & {
141
+ auth: PrimaryAuth;
142
+ userId: string;
143
+ };
144
+ export type ServerAuthStateVerify = ServerAuthStateBase & {
145
+ stage: 'verify';
146
+ signatureVerificationMessage?: string;
147
+ };
148
+ export type ServerAuthStateSignup = ServerAuthStateBase & {
149
+ stage: 'signup';
150
+ signupAuthMethods: AuthMethod[];
151
+ };
152
+ export type ServerAuthStateLogin = ServerAuthStateBase & {
153
+ stage: 'login';
154
+ biometricHints?: BiometricLocationHint[];
155
+ loginAuthMethods: AuthMethod[];
156
+ };
157
+ export type VerifyThirdPartyAuth = ServerAuthStateSignup | ServerAuthStateLogin;
158
+ export type ExternalWalletInfo = {
159
+ address: string;
160
+ type: ExternalWalletType;
161
+ provider?: string;
162
+ addressBech32?: string;
163
+ withFullParaAuth?: boolean;
164
+ };
165
+ export type VerifyExternalWalletParams = {
166
+ /**
167
+ * The external wallet information to verify.
168
+ */
169
+ externalWallet: ExternalWalletInfo;
170
+ /**
171
+ * The signature of the signed verification string.
172
+ */
173
+ signedMessage: string;
174
+ /**
175
+ * For Cosmos wallets, the wallet's public key as a hex string.
176
+ */
177
+ cosmosPublicKeyHex?: string;
178
+ /**
179
+ * For Cosmos wallets, the base64 signer string.
180
+ */
181
+ cosmosSigner?: string;
182
+ };
183
+ export type LoginExternalWalletResponse = ServerAuthStateLogin | (ServerAuthStateVerify & {
184
+ signatureVerificationMessage: string;
185
+ });
186
+ export type VerifyTelegramResponse = VerifyThirdPartyAuth;
187
+ export type VerifyFarcasterResponse = VerifyThirdPartyAuth | Record<string, never>;
188
+ export type ServerAuthState = ServerAuthStateVerify | ServerAuthStateSignup | ServerAuthStateLogin;
189
+ export type SignUpOrLogInResponse = ServerAuthStateVerify | ServerAuthStateLogin;
190
+ export type Setup2faResponse = {
191
+ /**
192
+ * Indicates whether 2FA has already been set up for the current user.
193
+ */
194
+ isSetup: true;
195
+ uri: undefined;
196
+ } | {
197
+ isSetup?: false;
198
+ /**
199
+ * A URI for the user to set up two-factor authentication.
200
+ */
201
+ uri: string;
202
+ };
@@ -3,6 +3,7 @@ import { SupportedWalletTypes } from './wallet.js';
3
3
  export interface PartnerEntity {
4
4
  id: string;
5
5
  displayName: string;
6
+ apiKey?: string;
6
7
  logoUrl?: string;
7
8
  iconUrl?: string;
8
9
  portalHeaderLogoUrl?: string;
@@ -1,4 +1,3 @@
1
- import { OAuthMethod } from './auth.js';
2
1
  import { PartnerEntity } from './partner.js';
3
2
  export declare enum WalletScheme {
4
3
  DKLS = "DKLS",
@@ -32,7 +31,9 @@ export type WalletParams = Partial<{
32
31
  walletId?: string;
33
32
  externalWalletAddress?: string;
34
33
  }>;
35
- export declare const PREGEN_IDENTIFIER_TYPES: readonly ["EMAIL", "PHONE", "CUSTOM_ID", OAuthMethod.DISCORD, OAuthMethod.TWITTER, OAuthMethod.TELEGRAM];
34
+ export type EmbeddedWalletType = Exclude<WalletType, never>;
35
+ export type ExternalWalletType = Exclude<WalletType, never>;
36
+ export declare const PREGEN_IDENTIFIER_TYPES: readonly ["EMAIL", "PHONE", "CUSTOM_ID", "DISCORD", "TWITTER", "TELEGRAM", "FARCASTER"];
36
37
  export type TPregenIdentifierType = (typeof PREGEN_IDENTIFIER_TYPES)[number];
37
38
  export type PregenIds = Partial<Record<TPregenIdentifierType, string[]>>;
38
39
  export interface WalletEntity {
@@ -1,4 +1,6 @@
1
1
  import { Auth, AuthInfo, AuthParams, PrimaryAuth, PrimaryAuthInfo, VerifiedAuth, WalletParams, WalletRef } from './types/index.js';
2
+ import { PregenAuth, PregenAuthInfo } from './types/auth.js';
3
+ import { PregenIds, TPregenIdentifierType } from './types/wallet.js';
2
4
  export declare function isWalletId(params: WalletParams): params is {
3
5
  walletId: string;
4
6
  };
@@ -11,12 +13,17 @@ export declare function isPhone(params: AuthParams | undefined): params is Auth<
11
13
  export declare function isPhoneLegacy(params: AuthParams | undefined): params is Auth<'phoneLegacy'>;
12
14
  export declare function isFarcaster(params: AuthParams | undefined): params is Auth<'farcaster'>;
13
15
  export declare function isTelegram(params: AuthParams | undefined): params is Auth<'telegram'>;
14
- export declare function isUserId(params: AuthParams | undefined): params is Auth<'userId'>;
15
16
  export declare function isExternalWallet(params: AuthParams | undefined): params is Auth<'externalWallet'>;
17
+ export declare function isX(params: AuthParams | undefined): params is Auth<'x'>;
18
+ export declare function isDiscord(params: AuthParams | undefined): params is Auth<'discord'>;
19
+ export declare function isCustomId(params: AuthParams | undefined): params is Auth<'customId'>;
20
+ export declare function isUserId(params: AuthParams | undefined): params is Auth<'userId'>;
16
21
  export declare function isPrimary(params: AuthParams | undefined): params is PrimaryAuth;
17
22
  export declare function isVerifiedAuth(params: AuthParams | undefined): params is VerifiedAuth;
23
+ export declare function isPregenAuth(params: AuthParams | undefined): params is PregenAuth;
18
24
  type ExtractAuthOpts = {
19
25
  allowUserId?: boolean;
26
+ allowPregen?: boolean;
20
27
  isRequired?: boolean;
21
28
  };
22
29
  export declare function extractAuthInfo(obj: AuthParams): PrimaryAuthInfo | undefined;
@@ -25,12 +32,22 @@ export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts &
25
32
  }): PrimaryAuthInfo | undefined;
26
33
  export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
27
34
  isRequired: true;
35
+ allowPregen?: undefined | false;
28
36
  }): PrimaryAuthInfo;
29
37
  export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
30
38
  allowUserId: true;
31
- }): AuthInfo | undefined;
39
+ }): PrimaryAuthInfo | AuthInfo<'userId'> | undefined;
32
40
  export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
33
41
  allowUserId: true;
34
42
  isRequired: true;
35
- }): AuthInfo;
43
+ }): PrimaryAuthInfo | AuthInfo<'userId'>;
44
+ export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
45
+ allowPregen: true;
46
+ }): PregenAuthInfo | undefined;
47
+ export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
48
+ allowPregen: true;
49
+ isRequired: true;
50
+ }): PregenAuthInfo;
51
+ export declare function toPregenTypeAndId(auth: PregenAuth): [TPregenIdentifierType, string];
52
+ export declare function toPregenIds(auth: PregenAuth): PregenIds;
36
53
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/user-management-client",
3
- "version": "2.0.0-dev.0",
3
+ "version": "2.0.0-dev.1",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -33,5 +33,5 @@
33
33
  "require": "./dist/cjs/index.js"
34
34
  }
35
35
  },
36
- "gitHead": "f94ef031ef0e1894f5f0800e55f6ca2904641780"
36
+ "gitHead": "426e843bd6084fb2e5f30ab87b02c79fc2f52832"
37
37
  }