@getpara/user-management-client 1.12.0 → 2.0.0-alpha.5

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.
@@ -115,6 +115,13 @@ class Client {
115
115
  retrieveSessionCookie,
116
116
  persistSessionCookie
117
117
  }) {
118
+ this.signUpOrLogIn = (body) => __async(this, null, function* () {
119
+ const res = yield this.baseRequest.post(`/users/init`, body);
120
+ return res.data;
121
+ });
122
+ /**
123
+ * @deprecated
124
+ */
118
125
  this.createUser = (body) => __async(this, null, function* () {
119
126
  const res = yield this.baseRequest.post(`/users`, body);
120
127
  return res.data;
@@ -126,26 +133,46 @@ class Client {
126
133
  return res;
127
134
  });
128
135
  this.verifyTelegram = (authObject) => __async(this, null, function* () {
129
- return (yield this.baseRequest.post("/users/telegram", {
136
+ return (yield this.baseRequest.post("/users/telegram/v2", {
130
137
  authObject
131
138
  })).data;
132
139
  });
133
- this.externalWalletLogin = (body) => __async(this, null, function* () {
134
- const res = yield this.baseRequest.post(`/users/external-wallets/login`, body);
140
+ this.verifyOAuth = () => __async(this, null, function* () {
141
+ const res = yield this.baseRequest.post("/users/verify-oauth");
142
+ return res.data;
143
+ });
144
+ this.loginExternalWallet = (_0) => __async(this, [_0], function* ({
145
+ externalWallet,
146
+ shouldTrackUser
147
+ }) {
148
+ const res = yield this.baseRequest.post(`/users/external-wallets/login/v2`, {
149
+ externalWallet,
150
+ shouldTrackUser
151
+ });
152
+ return res.data;
153
+ });
154
+ this.verifyNewAccount = (userId, body) => __async(this, null, function* () {
155
+ const res = yield this.baseRequest.post(`/users/${userId}/verify`, body);
135
156
  return res.data;
136
157
  });
137
158
  // POST /users/:userId/verify-email
159
+ /**
160
+ * @deprecated
161
+ */
138
162
  this.verifyEmail = (userId, body) => __async(this, null, function* () {
139
163
  const res = yield this.baseRequest.post(`/users/${userId}/verify-email`, body);
140
164
  return res;
141
165
  });
166
+ /**
167
+ * @deprecated
168
+ */
142
169
  this.verifyPhone = (userId, body) => __async(this, null, function* () {
143
170
  const res = yield this.baseRequest.post(`/users/${userId}/verify-identifier`, body);
144
171
  return res;
145
172
  });
146
173
  this.verifyExternalWallet = (userId, body) => __async(this, null, function* () {
147
- const res = yield this.baseRequest.post(`/users/${userId}/external-wallets/verify`, body);
148
- return res;
174
+ const res = yield this.baseRequest.post(`/users/${userId}/external-wallets/verify/v2`, body);
175
+ return res.data;
149
176
  });
150
177
  // POST /users/:userId/biometrics/key
151
178
  this.addSessionPublicKey = (userId, body) => __async(this, null, function* () {
@@ -158,8 +185,10 @@ class Client {
158
185
  return res;
159
186
  });
160
187
  // GET /biometrics/location-hints
161
- this.getBiometricLocationHints = (params) => __async(this, null, function* () {
162
- const res = yield this.baseRequest.get(`/biometrics/location-hints`, { params });
188
+ this.getBiometricLocationHints = (auth) => __async(this, null, function* () {
189
+ const res = yield this.baseRequest.get(`/biometrics/location-hints`, {
190
+ params: auth
191
+ });
163
192
  return res.data.hints;
164
193
  });
165
194
  // GET /users/:userId/biometrics/:biometricId
@@ -185,10 +214,8 @@ class Client {
185
214
  });
186
215
  // POST /touch
187
216
  this.touchSession = (regenerate) => __async(this, null, function* () {
188
- const res = yield this.baseRequest.post(
189
- `/touch?regenerate=${!!regenerate}`
190
- );
191
- return res;
217
+ const res = yield this.baseRequest.post(`/touch?regenerate=${!!regenerate}`);
218
+ return res.data;
192
219
  });
193
220
  // GET /session/origin
194
221
  this.sessionOrigin = (sessionLookupId) => __async(this, null, function* () {
@@ -224,14 +251,12 @@ class Client {
224
251
  const res = yield this.baseRequest.post(`/wallets/pregen`, body);
225
252
  return res.data;
226
253
  });
227
- // GET /wallets/pregen?pregenIdentifier={pregenIdentifier}&pregenIdentifierType={pregenIdentifierType}
228
254
  this.getPregenWallets = (pregenIds, isPortal = false, userId) => __async(this, null, function* () {
229
255
  const res = yield this.baseRequest.get("/wallets/pregen", {
230
256
  params: { ids: pregenIds, expand: isPortal, userId }
231
257
  });
232
258
  return res.data;
233
259
  });
234
- // POST /wallets/pregen/claim
235
260
  this.claimPregenWallets = (body) => __async(this, null, function* () {
236
261
  const res = yield this.baseRequest.post(`/wallets/pregen/claim`, body);
237
262
  return res.data;
@@ -341,12 +366,8 @@ class Client {
341
366
  return res;
342
367
  });
343
368
  // GET /users/:userId/wallets/:walletId/balance
344
- this.getWalletBalance = (_0) => __async(this, [_0], function* ({
345
- userId,
346
- walletId,
347
- rpcUrl
348
- }) {
349
- const res = yield this.baseRequest.get(`/users/${userId}/wallets/${walletId}/balance`, {
369
+ this.getWalletBalance = (_0) => __async(this, [_0], function* ({ walletId, rpcUrl }) {
370
+ const res = yield this.baseRequest.get(`/wallets/${walletId}/balance`, {
350
371
  params: {
351
372
  rpcUrl
352
373
  }
@@ -510,11 +531,10 @@ class Client {
510
531
  return res;
511
532
  });
512
533
  }
513
- // POST '/2fa/users/:userId/setup'
514
534
  setup2FA(userId) {
515
535
  return __async(this, null, function* () {
516
536
  const res = yield this.baseRequest.post(`/2fa/users/${userId}/setup`);
517
- return res;
537
+ return res.data;
518
538
  });
519
539
  }
520
540
  // POST /recovery/init
@@ -531,11 +551,10 @@ class Client {
531
551
  return res;
532
552
  });
533
553
  }
534
- // POST /auth/farcaster/status
535
554
  getFarcasterAuthStatus() {
536
555
  return __async(this, null, function* () {
537
- const res = yield this.baseRequest.post(`/auth/farcaster/status`);
538
- return res;
556
+ const res = yield this.baseRequest.post(`/auth/farcaster/status/v2`);
557
+ return res.data;
539
558
  });
540
559
  }
541
560
  // POST /recovery/init
@@ -575,18 +594,20 @@ class Client {
575
594
  return res;
576
595
  });
577
596
  }
578
- // POST /2fa/verify
579
- verify2FA(email, verificationCode) {
597
+ verify2FA(auth, verificationCode) {
580
598
  return __async(this, null, function* () {
581
- const body = { email, verificationCode };
599
+ const body = __spreadProps(__spreadValues({}, auth), { verificationCode });
582
600
  const res = yield this.baseRequest.post("/2fa/verify", body);
583
- return res;
601
+ return res.data;
584
602
  });
585
603
  }
586
604
  // POST /2fa/phone/verify
587
- verify2FAForPhone(phone, countryCode, verificationCode) {
605
+ /**
606
+ * @deprecated
607
+ */
608
+ verify2FAForPhone(phone, verificationCode) {
588
609
  return __async(this, null, function* () {
589
- const body = { phone, countryCode, verificationCode };
610
+ const body = { phone, verificationCode };
590
611
  const res = yield this.baseRequest.post("/2fa/verify", body);
591
612
  return res;
592
613
  });
@@ -882,14 +903,7 @@ class Client {
882
903
  params: { partnerId }
883
904
  });
884
905
  return {
885
- accountMetadata: Object.entries(res.data.accountMetadata || {}).reduce(
886
- (acc, [method, obj]) => __spreadProps(__spreadValues({}, acc), {
887
- [method]: __spreadProps(__spreadValues({}, obj), {
888
- date: new Date(obj.date)
889
- })
890
- }),
891
- {}
892
- )
906
+ accountMetadata: (0, import_utils.fromAccountMetadata)(res.data.accountMetadata)
893
907
  };
894
908
  });
895
909
  }
package/dist/cjs/index.js CHANGED
@@ -34,11 +34,13 @@ module.exports = __toCommonJS(src_exports);
34
34
  __reExport(src_exports, require("./client.js"), module.exports);
35
35
  __reExport(src_exports, require("./types/index.js"), module.exports);
36
36
  __reExport(src_exports, require("./utils.js"), module.exports);
37
+ __reExport(src_exports, require("./error.js"), module.exports);
37
38
  var import_client = __toESM(require("./client.js"));
38
39
  var src_default = import_client.default;
39
40
  // Annotate the CommonJS export names for ESM import in node:
40
41
  0 && (module.exports = {
41
42
  ...require("./client.js"),
42
43
  ...require("./types/index.js"),
43
- ...require("./utils.js")
44
+ ...require("./utils.js"),
45
+ ...require("./error.js")
44
46
  });
@@ -17,15 +17,30 @@ var __copyProps = (to, from, except, desc) => {
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
  var auth_exports = {};
19
19
  __export(auth_exports, {
20
+ AUTH_TYPES: () => AUTH_TYPES,
20
21
  AuthMethod: () => AuthMethod,
21
22
  EncryptorType: () => EncryptorType,
22
23
  KeyShareType: () => KeyShareType,
24
+ OAUTH_METHODS: () => OAUTH_METHODS,
23
25
  OAuthMethod: () => OAuthMethod,
24
26
  PasswordStatus: () => PasswordStatus,
25
27
  PublicKeyStatus: () => PublicKeyStatus,
26
28
  PublicKeyType: () => PublicKeyType
27
29
  });
28
30
  module.exports = __toCommonJS(auth_exports);
31
+ const AUTH_TYPES = [
32
+ "email",
33
+ "phone",
34
+ "phoneLegacy",
35
+ "farcaster",
36
+ "telegram",
37
+ "userId",
38
+ "externalWallet",
39
+ "discord",
40
+ "x",
41
+ "customId",
42
+ "guestId"
43
+ ];
29
44
  var EncryptorType = /* @__PURE__ */ ((EncryptorType2) => {
30
45
  EncryptorType2["USER"] = "USER";
31
46
  EncryptorType2["RECOVERY"] = "RECOVERY";
@@ -63,6 +78,7 @@ var OAuthMethod = /* @__PURE__ */ ((OAuthMethod2) => {
63
78
  OAuthMethod2["TELEGRAM"] = "TELEGRAM";
64
79
  return OAuthMethod2;
65
80
  })(OAuthMethod || {});
81
+ const OAUTH_METHODS = ["GOOGLE", "TWITTER", "APPLE", "DISCORD", "FACEBOOK", "FARCASTER", "TELEGRAM"];
66
82
  var AuthMethod = /* @__PURE__ */ ((AuthMethod2) => {
67
83
  AuthMethod2["PASSWORD"] = "PASSWORD";
68
84
  AuthMethod2["PASSKEY"] = "PASSKEY";
@@ -70,9 +86,11 @@ var AuthMethod = /* @__PURE__ */ ((AuthMethod2) => {
70
86
  })(AuthMethod || {});
71
87
  // Annotate the CommonJS export names for ESM import in node:
72
88
  0 && (module.exports = {
89
+ AUTH_TYPES,
73
90
  AuthMethod,
74
91
  EncryptorType,
75
92
  KeyShareType,
93
+ OAUTH_METHODS,
76
94
  OAuthMethod,
77
95
  PasswordStatus,
78
96
  PublicKeyStatus,
@@ -21,6 +21,8 @@ __export(wallet_exports, {
21
21
  NON_ED25519: () => NON_ED25519,
22
22
  Network: () => Network,
23
23
  PREGEN_IDENTIFIER_TYPES: () => PREGEN_IDENTIFIER_TYPES,
24
+ WALLET_SCHEMES: () => WALLET_SCHEMES,
25
+ WALLET_TYPES: () => WALLET_TYPES,
24
26
  WalletScheme: () => WalletScheme,
25
27
  WalletType: () => WalletType
26
28
  });
@@ -31,12 +33,14 @@ var WalletScheme = /* @__PURE__ */ ((WalletScheme2) => {
31
33
  WalletScheme2["ED25519"] = "ED25519";
32
34
  return WalletScheme2;
33
35
  })(WalletScheme || {});
36
+ const WALLET_SCHEMES = ["DKLS", "CGGMP", "ED25519"];
34
37
  var WalletType = /* @__PURE__ */ ((WalletType2) => {
35
38
  WalletType2["EVM"] = "EVM";
36
39
  WalletType2["SOLANA"] = "SOLANA";
37
40
  WalletType2["COSMOS"] = "COSMOS";
38
41
  return WalletType2;
39
42
  })(WalletType || {});
43
+ const WALLET_TYPES = ["EVM", "SOLANA", "COSMOS"];
40
44
  var Chain = /* @__PURE__ */ ((Chain2) => {
41
45
  Chain2["ETH"] = "ETH";
42
46
  Chain2["CELO"] = "CELO";
@@ -64,15 +68,18 @@ const PREGEN_IDENTIFIER_TYPES = [
64
68
  "GUEST_ID",
65
69
  "DISCORD",
66
70
  "TWITTER",
67
- "TELEGRAM"
71
+ "TELEGRAM",
72
+ "FARCASTER"
68
73
  ];
69
- const NON_ED25519 = ["DKLS" /* DKLS */, "CGGMP" /* CGGMP */];
74
+ const NON_ED25519 = ["DKLS", "CGGMP"];
70
75
  // Annotate the CommonJS export names for ESM import in node:
71
76
  0 && (module.exports = {
72
77
  Chain,
73
78
  NON_ED25519,
74
79
  Network,
75
80
  PREGEN_IDENTIFIER_TYPES,
81
+ WALLET_SCHEMES,
82
+ WALLET_TYPES,
76
83
  WalletScheme,
77
84
  WalletType
78
85
  });
package/dist/cjs/utils.js CHANGED
@@ -1,7 +1,26 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
2
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
3
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
4
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
5
24
  var __export = (target, all) => {
6
25
  for (var name in all)
7
26
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -14,21 +33,41 @@ var __copyProps = (to, from, except, desc) => {
14
33
  }
15
34
  return to;
16
35
  };
36
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
37
+ // If the importer is in node compatibility mode or this is not an ESM
38
+ // file that has been converted to a CommonJS file using a Babel-
39
+ // compatible transform (i.e. "__esModule" has not been set), then set
40
+ // "default" to the CommonJS "module.exports" for node compatibility.
41
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
42
+ mod
43
+ ));
17
44
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
45
  var utils_exports = {};
19
46
  __export(utils_exports, {
20
47
  extractAuthInfo: () => extractAuthInfo,
21
48
  extractWalletRef: () => extractWalletRef,
49
+ fromAccountMetadata: () => fromAccountMetadata,
50
+ isCustomId: () => isCustomId,
51
+ isDiscord: () => isDiscord,
22
52
  isEmail: () => isEmail,
23
53
  isExternalWallet: () => isExternalWallet,
24
54
  isExternalWalletAddress: () => isExternalWalletAddress,
25
55
  isFarcaster: () => isFarcaster,
56
+ isGuestId: () => isGuestId,
26
57
  isPhone: () => isPhone,
58
+ isPhoneLegacy: () => isPhoneLegacy,
59
+ isPregenAuth: () => isPregenAuth,
60
+ isPrimary: () => isPrimary,
27
61
  isTelegram: () => isTelegram,
28
62
  isUserId: () => isUserId,
29
- isWalletId: () => isWalletId
63
+ isVerifiedAuth: () => isVerifiedAuth,
64
+ isWalletId: () => isWalletId,
65
+ isX: () => isX,
66
+ toPregenIds: () => toPregenIds,
67
+ toPregenTypeAndId: () => toPregenTypeAndId
30
68
  });
31
69
  module.exports = __toCommonJS(utils_exports);
70
+ var import_libphonenumber_js = __toESM(require("libphonenumber-js"));
32
71
  function isWalletId(params) {
33
72
  return !!params.walletId && !params.externalWalletAddress;
34
73
  }
@@ -47,74 +86,185 @@ function isValid(s) {
47
86
  return !!s && s !== "null" && s !== "undefined" && s !== "";
48
87
  }
49
88
  function isEmail(params) {
50
- return isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.externalWalletUserId);
89
+ 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);
51
90
  }
52
91
  function isPhone(params) {
53
- return isValid(params.phone) && isValid(params.countryCode) && !isValid(params.email) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.externalWalletUserId);
92
+ 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);
93
+ }
94
+ function isPhoneLegacy(params) {
95
+ 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);
54
96
  }
55
97
  function isFarcaster(params) {
56
- return isValid(params.farcasterUsername) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.telegramUserId) && !isValid(params.externalWalletUserId);
98
+ 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);
57
99
  }
58
100
  function isTelegram(params) {
59
- return isValid(params.telegramUserId) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.externalWalletUserId);
101
+ 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);
102
+ }
103
+ function isExternalWallet(params) {
104
+ 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);
105
+ }
106
+ function isX(params) {
107
+ 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);
108
+ }
109
+ function isDiscord(params) {
110
+ 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);
111
+ }
112
+ function isCustomId(params) {
113
+ 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);
114
+ }
115
+ function isGuestId(params) {
116
+ return !!params && isValid(params.guestId) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.xUsername) && !isValid(params.discordUsername) && !isValid(params.customId) && !isValid(params.externalWalletAddress);
60
117
  }
61
118
  function isUserId(params) {
62
- return isValid(params.userId) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.externalWalletUserId);
119
+ 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);
63
120
  }
64
- function isExternalWallet(params) {
65
- return isValid(params.externalWalletAddress) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId);
121
+ function isPrimary(params) {
122
+ return isEmail(params) || isPhone(params) || isFarcaster(params) || isTelegram(params) || isExternalWallet(params);
66
123
  }
67
- function extractAuthInfo(obj, { allowUserId = false, isRequired = false } = {}) {
124
+ function isVerifiedAuth(params) {
125
+ return isEmail(params) || isPhone(params);
126
+ }
127
+ function isPregenAuth(params) {
128
+ return isPrimary(params) && !isExternalWallet(params) || isX(params) || isDiscord(params) || isCustomId(params);
129
+ }
130
+ function extractAuthInfo(obj, { allowUserId = false, allowPregen = false, isRequired = false } = {}) {
131
+ obj = Object.entries(obj || {}).reduce((acc, [k, v]) => {
132
+ return __spreadValues(__spreadValues({}, acc), !!v && v !== "null" && v !== "undefined" && v !== "" ? { [k]: v } : {});
133
+ }, {});
134
+ let error;
68
135
  switch (true) {
69
136
  case isEmail(obj):
70
- return { auth: { email: obj.email }, authType: "email", identifier: obj.email, publicKeyIdentifier: obj.email };
137
+ return {
138
+ auth: { email: obj.email },
139
+ authType: "email",
140
+ identifier: obj.email
141
+ };
71
142
  case isPhone(obj):
143
+ if (!(0, import_libphonenumber_js.default)(obj.phone)) {
144
+ error = "invalid phone number";
145
+ break;
146
+ }
72
147
  return {
73
- auth: { phone: obj.phone, countryCode: obj.countryCode },
148
+ auth: { phone: obj.phone },
74
149
  authType: "phone",
75
- identifier: `${obj.countryCode}${obj.phone}`,
76
- publicKeyIdentifier: `${obj.countryCode}${obj.phone}`
150
+ identifier: obj.phone
151
+ };
152
+ case isPhoneLegacy(obj):
153
+ const identifier = `${obj.countryCode.startsWith("+") ? "" : "+"}${obj.countryCode}${obj.phone}`;
154
+ if (!(0, import_libphonenumber_js.default)(identifier)) {
155
+ error = "invalid phone number";
156
+ break;
157
+ }
158
+ return {
159
+ auth: { phone: identifier },
160
+ authType: "phone",
161
+ identifier
77
162
  };
78
163
  case isFarcaster(obj):
79
164
  return {
80
165
  auth: { farcasterUsername: obj.farcasterUsername },
81
166
  authType: "farcaster",
82
- identifier: obj.farcasterUsername,
83
- publicKeyIdentifier: `${obj.farcasterUsername}-farcaster`
167
+ identifier: obj.farcasterUsername
84
168
  };
85
169
  case isTelegram(obj):
86
170
  return {
87
171
  auth: { telegramUserId: obj.telegramUserId },
88
172
  authType: "telegram",
89
- identifier: obj.telegramUserId,
90
- publicKeyIdentifier: `${obj.telegramUserId}-telegram`
173
+ identifier: obj.telegramUserId
91
174
  };
92
175
  case isExternalWallet(obj):
93
176
  return {
94
177
  auth: { externalWalletAddress: obj.externalWalletAddress },
95
178
  authType: "externalWallet",
96
- identifier: obj.externalWalletAddress,
97
- publicKeyIdentifier: `${obj.externalWalletAddress}-external-wallet`
179
+ identifier: obj.externalWalletAddress
180
+ };
181
+ case (allowPregen && isX(obj)):
182
+ return {
183
+ auth: { xUsername: obj.xUsername },
184
+ authType: "x",
185
+ identifier: obj.xUsername
186
+ };
187
+ case (allowPregen && isDiscord(obj)):
188
+ return {
189
+ auth: { discordUsername: obj.discordUsername },
190
+ authType: "discord",
191
+ identifier: obj.discordUsername
192
+ };
193
+ case (allowPregen && isCustomId(obj)):
194
+ return {
195
+ auth: { customId: obj.customId },
196
+ authType: "customId",
197
+ identifier: obj.customId
198
+ };
199
+ case (allowPregen && isGuestId(obj)):
200
+ return {
201
+ auth: { guestId: obj.guestId },
202
+ authType: "guestId",
203
+ identifier: obj.guestId
98
204
  };
99
205
  case (isUserId(obj) && allowUserId):
100
- return { auth: { userId: obj.userId }, authType: "userId", identifier: obj.userId, publicKeyIdentifier: obj.userId };
206
+ return {
207
+ auth: { userId: obj.userId },
208
+ authType: "userId",
209
+ identifier: obj.userId
210
+ };
101
211
  default:
102
- if (isRequired) {
103
- throw new Error("invalid auth object");
104
- }
105
- return void 0;
212
+ break;
106
213
  }
214
+ if (isRequired) {
215
+ throw new Error(error != null ? error : "invalid auth object");
216
+ }
217
+ return void 0;
218
+ }
219
+ function toPregenTypeAndId(auth) {
220
+ const { authType, identifier: pregenIdentifier } = extractAuthInfo(auth, { isRequired: true, allowPregen: true });
221
+ const pregenIdentifierType = {
222
+ email: "EMAIL",
223
+ phone: "PHONE",
224
+ farcaster: "FARCASTER",
225
+ telegram: "TELEGRAM",
226
+ discord: "DISCORD",
227
+ x: "TWITTER",
228
+ customId: "CUSTOM_ID",
229
+ guestId: "GUEST_ID"
230
+ }[authType];
231
+ return [pregenIdentifierType, pregenIdentifier];
232
+ }
233
+ function toPregenIds(auth) {
234
+ const [pregenIdentifierType, pregenIdentifier] = toPregenTypeAndId(auth);
235
+ return { [pregenIdentifierType]: [pregenIdentifier] };
236
+ }
237
+ function fromAccountMetadata(obj) {
238
+ return Object.entries(obj || {}).reduce(
239
+ (acc, [method, obj2]) => __spreadProps(__spreadValues({}, acc), {
240
+ [method]: __spreadProps(__spreadValues({}, obj2), {
241
+ date: new Date(obj2.date)
242
+ })
243
+ }),
244
+ {}
245
+ );
107
246
  }
108
247
  // Annotate the CommonJS export names for ESM import in node:
109
248
  0 && (module.exports = {
110
249
  extractAuthInfo,
111
250
  extractWalletRef,
251
+ fromAccountMetadata,
252
+ isCustomId,
253
+ isDiscord,
112
254
  isEmail,
113
255
  isExternalWallet,
114
256
  isExternalWalletAddress,
115
257
  isFarcaster,
258
+ isGuestId,
116
259
  isPhone,
260
+ isPhoneLegacy,
261
+ isPregenAuth,
262
+ isPrimary,
117
263
  isTelegram,
118
264
  isUserId,
119
- isWalletId
265
+ isVerifiedAuth,
266
+ isWalletId,
267
+ isX,
268
+ toPregenIds,
269
+ toPregenTypeAndId
120
270
  });