@getpara/user-management-client 1.7.1 → 2.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +196 -75
- package/dist/cjs/index.js.br +0 -0
- package/dist/cjs/index.js.gz +0 -0
- package/dist/esm/index.js +184 -74
- package/dist/esm/index.js.br +0 -0
- package/dist/esm/index.js.gz +0 -0
- package/dist/types/client.d.ts +38 -49
- package/dist/types/index.d.ts +1 -0
- package/dist/types/types/auth.d.ts +123 -15
- package/dist/types/types/partner.d.ts +7 -0
- package/dist/types/types/wallet.d.ts +7 -4
- package/dist/types/utils.d.ts +39 -9
- package/package.json +2 -2
- package/dist/cjs/package.json +0 -3
- package/dist/esm/package.json +0 -4
package/dist/esm/index.js
CHANGED
|
@@ -55,6 +55,7 @@ import axios from "axios";
|
|
|
55
55
|
import qs from "qs";
|
|
56
56
|
|
|
57
57
|
// src/utils.ts
|
|
58
|
+
import parsePhoneNumberFromString from "libphonenumber-js";
|
|
58
59
|
function isWalletId(params) {
|
|
59
60
|
return !!params.walletId && !params.externalWalletAddress;
|
|
60
61
|
}
|
|
@@ -73,63 +74,143 @@ function isValid(s) {
|
|
|
73
74
|
return !!s && s !== "null" && s !== "undefined" && s !== "";
|
|
74
75
|
}
|
|
75
76
|
function isEmail(params) {
|
|
76
|
-
return isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.
|
|
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);
|
|
77
78
|
}
|
|
78
79
|
function isPhone(params) {
|
|
79
|
-
return isValid(params.phone) && isValid(params.countryCode) && !isValid(params.email) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.
|
|
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);
|
|
81
|
+
}
|
|
82
|
+
function isPhoneLegacy(params) {
|
|
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);
|
|
80
84
|
}
|
|
81
85
|
function isFarcaster(params) {
|
|
82
|
-
return isValid(params.farcasterUsername) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.telegramUserId) && !isValid(params.
|
|
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);
|
|
83
87
|
}
|
|
84
88
|
function isTelegram(params) {
|
|
85
|
-
return isValid(params.telegramUserId) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.
|
|
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
|
+
}
|
|
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) && !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);
|
|
86
102
|
}
|
|
87
103
|
function isUserId(params) {
|
|
88
|
-
return isValid(params.userId) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.
|
|
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);
|
|
89
105
|
}
|
|
90
|
-
function
|
|
91
|
-
return
|
|
106
|
+
function isPrimary(params) {
|
|
107
|
+
return isEmail(params) || isPhone(params) || isFarcaster(params) || isTelegram(params) || isExternalWallet(params);
|
|
108
|
+
}
|
|
109
|
+
function isVerifiedAuth(params) {
|
|
110
|
+
return isEmail(params) || isPhone(params);
|
|
92
111
|
}
|
|
93
|
-
function
|
|
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 } = {}) {
|
|
116
|
+
obj = Object.entries(obj || {}).reduce((acc, [k, v]) => {
|
|
117
|
+
return __spreadValues(__spreadValues({}, acc), !!v && v !== "null" && v !== "undefined" && v !== "" ? { [k]: v } : {});
|
|
118
|
+
}, {});
|
|
119
|
+
let error;
|
|
94
120
|
switch (true) {
|
|
95
121
|
case isEmail(obj):
|
|
96
|
-
return {
|
|
122
|
+
return {
|
|
123
|
+
auth: { email: obj.email },
|
|
124
|
+
authType: "email",
|
|
125
|
+
identifier: obj.email
|
|
126
|
+
};
|
|
97
127
|
case isPhone(obj):
|
|
128
|
+
if (!parsePhoneNumberFromString(obj.phone)) {
|
|
129
|
+
error = "invalid phone number";
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
98
132
|
return {
|
|
99
|
-
auth: { phone: obj.phone
|
|
133
|
+
auth: { phone: obj.phone },
|
|
100
134
|
authType: "phone",
|
|
101
|
-
identifier:
|
|
102
|
-
|
|
135
|
+
identifier: obj.phone
|
|
136
|
+
};
|
|
137
|
+
case isPhoneLegacy(obj):
|
|
138
|
+
const identifier = `${obj.countryCode.startsWith("+") ? "" : "+"}${obj.countryCode}${obj.phone}`;
|
|
139
|
+
if (!parsePhoneNumberFromString(identifier)) {
|
|
140
|
+
error = "invalid phone number";
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
auth: { phone: identifier },
|
|
145
|
+
authType: "phone",
|
|
146
|
+
identifier
|
|
103
147
|
};
|
|
104
148
|
case isFarcaster(obj):
|
|
105
149
|
return {
|
|
106
150
|
auth: { farcasterUsername: obj.farcasterUsername },
|
|
107
151
|
authType: "farcaster",
|
|
108
|
-
identifier: obj.farcasterUsername
|
|
109
|
-
publicKeyIdentifier: `${obj.farcasterUsername}-farcaster`
|
|
152
|
+
identifier: obj.farcasterUsername
|
|
110
153
|
};
|
|
111
154
|
case isTelegram(obj):
|
|
112
155
|
return {
|
|
113
156
|
auth: { telegramUserId: obj.telegramUserId },
|
|
114
157
|
authType: "telegram",
|
|
115
|
-
identifier: obj.telegramUserId
|
|
116
|
-
publicKeyIdentifier: `${obj.telegramUserId}-telegram`
|
|
158
|
+
identifier: obj.telegramUserId
|
|
117
159
|
};
|
|
118
160
|
case isExternalWallet(obj):
|
|
119
161
|
return {
|
|
120
162
|
auth: { externalWalletAddress: obj.externalWalletAddress },
|
|
121
163
|
authType: "externalWallet",
|
|
122
|
-
identifier: obj.externalWalletAddress
|
|
123
|
-
|
|
164
|
+
identifier: obj.externalWalletAddress
|
|
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
|
|
124
183
|
};
|
|
125
184
|
case (isUserId(obj) && allowUserId):
|
|
126
|
-
return {
|
|
185
|
+
return {
|
|
186
|
+
auth: { userId: obj.userId },
|
|
187
|
+
authType: "userId",
|
|
188
|
+
identifier: obj.userId
|
|
189
|
+
};
|
|
127
190
|
default:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
if (isRequired) {
|
|
194
|
+
throw new Error(error != null ? error : "invalid auth object");
|
|
132
195
|
}
|
|
196
|
+
return void 0;
|
|
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] };
|
|
133
214
|
}
|
|
134
215
|
|
|
135
216
|
// src/consts.ts
|
|
@@ -186,6 +267,13 @@ var Client = class {
|
|
|
186
267
|
retrieveSessionCookie,
|
|
187
268
|
persistSessionCookie
|
|
188
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
|
+
*/
|
|
189
277
|
this.createUser = (body) => __async(this, null, function* () {
|
|
190
278
|
const res = yield this.baseRequest.post(`/users`, body);
|
|
191
279
|
return res.data;
|
|
@@ -197,26 +285,46 @@ var Client = class {
|
|
|
197
285
|
return res;
|
|
198
286
|
});
|
|
199
287
|
this.verifyTelegram = (authObject) => __async(this, null, function* () {
|
|
200
|
-
return (yield this.baseRequest.post("/users/telegram", {
|
|
288
|
+
return (yield this.baseRequest.post("/users/telegram/v2", {
|
|
201
289
|
authObject
|
|
202
290
|
})).data;
|
|
203
291
|
});
|
|
204
|
-
this.
|
|
205
|
-
const res = yield this.baseRequest.post(
|
|
292
|
+
this.verifyOAuth = () => __async(this, null, function* () {
|
|
293
|
+
const res = yield this.baseRequest.post("/users/verify-oauth");
|
|
294
|
+
return res.data;
|
|
295
|
+
});
|
|
296
|
+
this.loginExternalWallet = (_0) => __async(this, [_0], function* ({
|
|
297
|
+
externalWallet,
|
|
298
|
+
shouldTrackUser
|
|
299
|
+
}) {
|
|
300
|
+
const res = yield this.baseRequest.post(`/users/external-wallets/login/v2`, {
|
|
301
|
+
externalWallet,
|
|
302
|
+
shouldTrackUser
|
|
303
|
+
});
|
|
304
|
+
return res.data;
|
|
305
|
+
});
|
|
306
|
+
this.verifyNewAccount = (userId, body) => __async(this, null, function* () {
|
|
307
|
+
const res = yield this.baseRequest.post(`/users/${userId}/verify`, body);
|
|
206
308
|
return res.data;
|
|
207
309
|
});
|
|
208
310
|
// POST /users/:userId/verify-email
|
|
311
|
+
/**
|
|
312
|
+
* @deprecated
|
|
313
|
+
*/
|
|
209
314
|
this.verifyEmail = (userId, body) => __async(this, null, function* () {
|
|
210
315
|
const res = yield this.baseRequest.post(`/users/${userId}/verify-email`, body);
|
|
211
316
|
return res;
|
|
212
317
|
});
|
|
318
|
+
/**
|
|
319
|
+
* @deprecated
|
|
320
|
+
*/
|
|
213
321
|
this.verifyPhone = (userId, body) => __async(this, null, function* () {
|
|
214
322
|
const res = yield this.baseRequest.post(`/users/${userId}/verify-identifier`, body);
|
|
215
323
|
return res;
|
|
216
324
|
});
|
|
217
325
|
this.verifyExternalWallet = (userId, body) => __async(this, null, function* () {
|
|
218
|
-
const res = yield this.baseRequest.post(`/users/${userId}/external-wallets/verify`, body);
|
|
219
|
-
return res;
|
|
326
|
+
const res = yield this.baseRequest.post(`/users/${userId}/external-wallets/verify/v2`, body);
|
|
327
|
+
return res.data;
|
|
220
328
|
});
|
|
221
329
|
// POST /users/:userId/biometrics/key
|
|
222
330
|
this.addSessionPublicKey = (userId, body) => __async(this, null, function* () {
|
|
@@ -229,8 +337,10 @@ var Client = class {
|
|
|
229
337
|
return res;
|
|
230
338
|
});
|
|
231
339
|
// GET /biometrics/location-hints
|
|
232
|
-
this.getBiometricLocationHints = (
|
|
233
|
-
const res = yield this.baseRequest.get(`/biometrics/location-hints`, {
|
|
340
|
+
this.getBiometricLocationHints = (auth) => __async(this, null, function* () {
|
|
341
|
+
const res = yield this.baseRequest.get(`/biometrics/location-hints`, {
|
|
342
|
+
params: auth
|
|
343
|
+
});
|
|
234
344
|
return res.data.hints;
|
|
235
345
|
});
|
|
236
346
|
// GET /users/:userId/biometrics/:biometricId
|
|
@@ -256,10 +366,8 @@ var Client = class {
|
|
|
256
366
|
});
|
|
257
367
|
// POST /touch
|
|
258
368
|
this.touchSession = (regenerate) => __async(this, null, function* () {
|
|
259
|
-
const res = yield this.baseRequest.post(
|
|
260
|
-
|
|
261
|
-
);
|
|
262
|
-
return res;
|
|
369
|
+
const res = yield this.baseRequest.post(`/touch?regenerate=${!!regenerate}`);
|
|
370
|
+
return res.data;
|
|
263
371
|
});
|
|
264
372
|
// GET /session/origin
|
|
265
373
|
this.sessionOrigin = (sessionLookupId) => __async(this, null, function* () {
|
|
@@ -295,14 +403,12 @@ var Client = class {
|
|
|
295
403
|
const res = yield this.baseRequest.post(`/wallets/pregen`, body);
|
|
296
404
|
return res.data;
|
|
297
405
|
});
|
|
298
|
-
// GET /wallets/pregen?pregenIdentifier={pregenIdentifier}&pregenIdentifierType={pregenIdentifierType}
|
|
299
406
|
this.getPregenWallets = (pregenIds, isPortal = false, userId) => __async(this, null, function* () {
|
|
300
407
|
const res = yield this.baseRequest.get("/wallets/pregen", {
|
|
301
408
|
params: { ids: pregenIds, expand: isPortal, userId }
|
|
302
409
|
});
|
|
303
410
|
return res.data;
|
|
304
411
|
});
|
|
305
|
-
// POST /wallets/pregen/claim
|
|
306
412
|
this.claimPregenWallets = (body) => __async(this, null, function* () {
|
|
307
413
|
const res = yield this.baseRequest.post(`/wallets/pregen/claim`, body);
|
|
308
414
|
return res.data;
|
|
@@ -395,11 +501,9 @@ var Client = class {
|
|
|
395
501
|
const res = yield this.baseRequest.get(`/users/${userId}/wallets/${walletId}/capsule-share`);
|
|
396
502
|
return res.data.share;
|
|
397
503
|
});
|
|
398
|
-
// GET /
|
|
399
|
-
this.getBackupKit = (userId
|
|
400
|
-
const res = yield this.baseRequest.get(`/
|
|
401
|
-
responseType: "blob"
|
|
402
|
-
});
|
|
504
|
+
// GET /download-backup-kit/:userId
|
|
505
|
+
this.getBackupKit = (userId) => __async(this, null, function* () {
|
|
506
|
+
const res = yield this.baseRequest.get(`/download-backup-kit/${userId}`, { responseType: "blob" });
|
|
403
507
|
return res;
|
|
404
508
|
});
|
|
405
509
|
// PATCH /users/:userId/biometrics/:biometricId
|
|
@@ -565,11 +669,10 @@ var Client = class {
|
|
|
565
669
|
return res;
|
|
566
670
|
});
|
|
567
671
|
}
|
|
568
|
-
// POST '/2fa/users/:userId/setup'
|
|
569
672
|
setup2FA(userId) {
|
|
570
673
|
return __async(this, null, function* () {
|
|
571
674
|
const res = yield this.baseRequest.post(`/2fa/users/${userId}/setup`);
|
|
572
|
-
return res;
|
|
675
|
+
return res.data;
|
|
573
676
|
});
|
|
574
677
|
}
|
|
575
678
|
// POST /recovery/init
|
|
@@ -586,11 +689,10 @@ var Client = class {
|
|
|
586
689
|
return res;
|
|
587
690
|
});
|
|
588
691
|
}
|
|
589
|
-
// POST /auth/farcaster/status
|
|
590
692
|
getFarcasterAuthStatus() {
|
|
591
693
|
return __async(this, null, function* () {
|
|
592
|
-
const res = yield this.baseRequest.post(`/auth/farcaster/status`);
|
|
593
|
-
return res;
|
|
694
|
+
const res = yield this.baseRequest.post(`/auth/farcaster/status/v2`);
|
|
695
|
+
return res.data;
|
|
594
696
|
});
|
|
595
697
|
}
|
|
596
698
|
// POST /recovery/init
|
|
@@ -630,18 +732,20 @@ var Client = class {
|
|
|
630
732
|
return res;
|
|
631
733
|
});
|
|
632
734
|
}
|
|
633
|
-
|
|
634
|
-
verify2FA(email, verificationCode) {
|
|
735
|
+
verify2FA(auth, verificationCode) {
|
|
635
736
|
return __async(this, null, function* () {
|
|
636
|
-
const body = {
|
|
737
|
+
const body = __spreadProps(__spreadValues({}, auth), { verificationCode });
|
|
637
738
|
const res = yield this.baseRequest.post("/2fa/verify", body);
|
|
638
|
-
return res;
|
|
739
|
+
return res.data;
|
|
639
740
|
});
|
|
640
741
|
}
|
|
641
742
|
// POST /2fa/phone/verify
|
|
642
|
-
|
|
743
|
+
/**
|
|
744
|
+
* @deprecated
|
|
745
|
+
*/
|
|
746
|
+
verify2FAForPhone(phone, verificationCode) {
|
|
643
747
|
return __async(this, null, function* () {
|
|
644
|
-
const body = { phone,
|
|
748
|
+
const body = { phone, verificationCode };
|
|
645
749
|
const res = yield this.baseRequest.post("/2fa/verify", body);
|
|
646
750
|
return res;
|
|
647
751
|
});
|
|
@@ -957,28 +1061,22 @@ var Client = class {
|
|
|
957
1061
|
return res.data;
|
|
958
1062
|
});
|
|
959
1063
|
}
|
|
960
|
-
// GET /users/:userId/accounts
|
|
961
|
-
getAccountMetadata(userId, partnerId) {
|
|
962
|
-
return __async(this, null, function* () {
|
|
963
|
-
const res = yield this.baseRequest.get(`/users/${userId}/oauth/accounts`, {
|
|
964
|
-
params: { partnerId }
|
|
965
|
-
});
|
|
966
|
-
return {
|
|
967
|
-
accountMetadata: Object.entries(res.data.accountMetadata || {}).reduce(
|
|
968
|
-
(acc, [method, obj]) => __spreadProps(__spreadValues({}, acc), {
|
|
969
|
-
[method]: __spreadProps(__spreadValues({}, obj), {
|
|
970
|
-
date: new Date(obj.date)
|
|
971
|
-
})
|
|
972
|
-
}),
|
|
973
|
-
{}
|
|
974
|
-
)
|
|
975
|
-
};
|
|
976
|
-
});
|
|
977
|
-
}
|
|
978
1064
|
};
|
|
979
1065
|
var client_default = Client;
|
|
980
1066
|
|
|
981
1067
|
// src/types/auth.ts
|
|
1068
|
+
var AUTH_TYPES = [
|
|
1069
|
+
"email",
|
|
1070
|
+
"phone",
|
|
1071
|
+
"phoneLegacy",
|
|
1072
|
+
"farcaster",
|
|
1073
|
+
"telegram",
|
|
1074
|
+
"userId",
|
|
1075
|
+
"externalWallet",
|
|
1076
|
+
"discord",
|
|
1077
|
+
"x",
|
|
1078
|
+
"customId"
|
|
1079
|
+
];
|
|
982
1080
|
var EncryptorType = /* @__PURE__ */ ((EncryptorType2) => {
|
|
983
1081
|
EncryptorType2["USER"] = "USER";
|
|
984
1082
|
EncryptorType2["RECOVERY"] = "RECOVERY";
|
|
@@ -1097,15 +1195,17 @@ var PREGEN_IDENTIFIER_TYPES = [
|
|
|
1097
1195
|
"EMAIL",
|
|
1098
1196
|
"PHONE",
|
|
1099
1197
|
"CUSTOM_ID",
|
|
1100
|
-
"DISCORD"
|
|
1101
|
-
"TWITTER"
|
|
1102
|
-
"TELEGRAM"
|
|
1198
|
+
"DISCORD",
|
|
1199
|
+
"TWITTER",
|
|
1200
|
+
"TELEGRAM",
|
|
1201
|
+
"FARCASTER"
|
|
1103
1202
|
];
|
|
1104
1203
|
var NON_ED25519 = ["DKLS" /* DKLS */, "CGGMP" /* CGGMP */];
|
|
1105
1204
|
|
|
1106
1205
|
// src/index.ts
|
|
1107
1206
|
var src_default = client_default;
|
|
1108
1207
|
export {
|
|
1208
|
+
AUTH_TYPES,
|
|
1109
1209
|
AuthMethod,
|
|
1110
1210
|
Chain,
|
|
1111
1211
|
EmailTheme,
|
|
@@ -1119,6 +1219,7 @@ export {
|
|
|
1119
1219
|
OnRampPurchaseStatus,
|
|
1120
1220
|
OnRampPurchaseType,
|
|
1121
1221
|
PREGEN_IDENTIFIER_TYPES,
|
|
1222
|
+
ParaApiError,
|
|
1122
1223
|
PasswordStatus,
|
|
1123
1224
|
PublicKeyStatus,
|
|
1124
1225
|
PublicKeyType,
|
|
@@ -1129,12 +1230,21 @@ export {
|
|
|
1129
1230
|
extractWalletRef,
|
|
1130
1231
|
handleResponseError,
|
|
1131
1232
|
handleResponseSuccess,
|
|
1233
|
+
isCustomId,
|
|
1234
|
+
isDiscord,
|
|
1132
1235
|
isEmail,
|
|
1133
1236
|
isExternalWallet,
|
|
1134
1237
|
isExternalWalletAddress,
|
|
1135
1238
|
isFarcaster,
|
|
1136
1239
|
isPhone,
|
|
1240
|
+
isPhoneLegacy,
|
|
1241
|
+
isPregenAuth,
|
|
1242
|
+
isPrimary,
|
|
1137
1243
|
isTelegram,
|
|
1138
1244
|
isUserId,
|
|
1139
|
-
|
|
1245
|
+
isVerifiedAuth,
|
|
1246
|
+
isWalletId,
|
|
1247
|
+
isX,
|
|
1248
|
+
toPregenIds,
|
|
1249
|
+
toPregenTypeAndId
|
|
1140
1250
|
};
|
package/dist/esm/index.js.br
CHANGED
|
Binary file
|
package/dist/esm/index.js.gz
CHANGED
|
Binary file
|
package/dist/types/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
|
-
import {
|
|
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
|
}
|
|
@@ -7,30 +7,11 @@ type ClientConfig = {
|
|
|
7
7
|
userManagementHost: string;
|
|
8
8
|
version?: string;
|
|
9
9
|
partnerId?: string;
|
|
10
|
-
apiKey
|
|
10
|
+
apiKey: string;
|
|
11
11
|
opts?: ConfigOpts;
|
|
12
12
|
retrieveSessionCookie?: () => string | undefined;
|
|
13
13
|
persistSessionCookie?: (cookie: string) => void;
|
|
14
14
|
};
|
|
15
|
-
interface createUserBody {
|
|
16
|
-
email: string;
|
|
17
|
-
}
|
|
18
|
-
interface createUserBodyForPhone {
|
|
19
|
-
phone: string;
|
|
20
|
-
countryCode: string;
|
|
21
|
-
}
|
|
22
|
-
interface ExternalWalletLoginBody {
|
|
23
|
-
externalAddress: string;
|
|
24
|
-
type: 'EVM' | 'SOLANA' | 'COSMOS';
|
|
25
|
-
externalWalletProvider?: string;
|
|
26
|
-
shouldTrackUser?: boolean;
|
|
27
|
-
}
|
|
28
|
-
export interface ExternalWalletLoginRes {
|
|
29
|
-
userId: string;
|
|
30
|
-
userExists: boolean;
|
|
31
|
-
isVerified: boolean;
|
|
32
|
-
signatureVerificationMessage: string;
|
|
33
|
-
}
|
|
34
15
|
interface createUserIdRes {
|
|
35
16
|
protocolId: string;
|
|
36
17
|
userId: string;
|
|
@@ -38,12 +19,6 @@ interface createUserIdRes {
|
|
|
38
19
|
interface verifyBody {
|
|
39
20
|
verificationCode: string;
|
|
40
21
|
}
|
|
41
|
-
interface verifyExternalWalletBody {
|
|
42
|
-
address: string;
|
|
43
|
-
signedMessage: string;
|
|
44
|
-
cosmosPublicKeyHex?: string;
|
|
45
|
-
cosmosSigner?: string;
|
|
46
|
-
}
|
|
47
22
|
interface getWebChallengeRes {
|
|
48
23
|
challenge: string;
|
|
49
24
|
allowedPublicKeys?: string[];
|
|
@@ -138,7 +113,6 @@ interface sessionPasswordBody {
|
|
|
138
113
|
encryptedWalletPrivateKey?: string;
|
|
139
114
|
encryptionKeyHash?: string;
|
|
140
115
|
}
|
|
141
|
-
type BiometricLocationHintParams = AuthParams;
|
|
142
116
|
export type VerifyTelegramRes = {
|
|
143
117
|
isValid: true;
|
|
144
118
|
userId: string;
|
|
@@ -154,20 +128,35 @@ export declare const handleResponseError: (error: any) => never;
|
|
|
154
128
|
declare class Client {
|
|
155
129
|
private baseRequest;
|
|
156
130
|
constructor({ userManagementHost, apiKey, partnerId, version, opts, retrieveSessionCookie, persistSessionCookie, }: ClientConfig);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
131
|
+
signUpOrLogIn: (body: VerifiedAuth & VerificationEmailProps) => Promise<SignUpOrLogInResponse>;
|
|
132
|
+
/**
|
|
133
|
+
* @deprecated
|
|
134
|
+
*/
|
|
135
|
+
createUser: (body: VerifiedAuth & VerificationEmailProps) => Promise<createUserIdRes>;
|
|
136
|
+
checkUserExists: (auth: VerifiedAuth) => Promise<any>;
|
|
137
|
+
verifyTelegram: (authObject: TelegramAuthResponse) => Promise<VerifyTelegramResponse>;
|
|
138
|
+
verifyOAuth: () => Promise<VerifyThirdPartyAuth | null>;
|
|
139
|
+
loginExternalWallet: ({ externalWallet, shouldTrackUser, }: {
|
|
140
|
+
externalWallet: ExternalWalletInfo;
|
|
141
|
+
shouldTrackUser?: boolean;
|
|
142
|
+
}) => Promise<LoginExternalWalletResponse>;
|
|
143
|
+
verifyNewAccount: (userId: string, body: verifyBody) => Promise<ServerAuthStateSignup>;
|
|
144
|
+
/**
|
|
145
|
+
* @deprecated
|
|
146
|
+
*/
|
|
161
147
|
verifyEmail: (userId: string, body: verifyBody) => Promise<any>;
|
|
148
|
+
/**
|
|
149
|
+
* @deprecated
|
|
150
|
+
*/
|
|
162
151
|
verifyPhone: (userId: string, body: verifyBody) => Promise<any>;
|
|
163
|
-
verifyExternalWallet: (userId: string, body:
|
|
152
|
+
verifyExternalWallet: (userId: string, body: VerifyExternalWalletParams) => Promise<ServerAuthStateSignup>;
|
|
164
153
|
addSessionPublicKey: (userId: string, body: sessionPublicKeyBody) => Promise<any>;
|
|
165
154
|
getSessionPublicKeys: (userId: string) => Promise<any>;
|
|
166
|
-
getBiometricLocationHints: (
|
|
155
|
+
getBiometricLocationHints: (auth: PrimaryAuth) => Promise<BiometricLocationHint[]>;
|
|
167
156
|
getSessionPublicKey: (userId: string, biometricId: string) => Promise<any>;
|
|
168
157
|
patchSessionPublicKey: (partnerId: string, userId: string, biometricId: string, body: sessionPublicKeyBody) => Promise<any>;
|
|
169
|
-
getWebChallenge: (auth?: Auth) => Promise<getWebChallengeRes>;
|
|
170
|
-
touchSession: (regenerate?: boolean) => Promise<
|
|
158
|
+
getWebChallenge: (auth?: PrimaryAuth | Auth<"userId">) => Promise<getWebChallengeRes>;
|
|
159
|
+
touchSession: (regenerate?: boolean) => Promise<SessionInfo>;
|
|
171
160
|
sessionOrigin: (sessionLookupId: string) => Promise<{
|
|
172
161
|
origin?: string;
|
|
173
162
|
}>;
|
|
@@ -176,12 +165,12 @@ declare class Client {
|
|
|
176
165
|
verifySessionChallenge: (userId: string, body: verifySessionChallengeBody) => Promise<any>;
|
|
177
166
|
createWallet: (userId: string, body?: createWalletBody) => Promise<createWalletRes>;
|
|
178
167
|
createPregenWallet: (body?: createPregenWalletBody) => Promise<createWalletRes>;
|
|
179
|
-
getPregenWallets:
|
|
168
|
+
getPregenWallets: (pregenIds: PregenIds, isPortal?: boolean, userId?: string) => Promise<{
|
|
180
169
|
wallets: WalletEntity[];
|
|
181
|
-
}
|
|
182
|
-
claimPregenWallets:
|
|
183
|
-
walletIds
|
|
184
|
-
}
|
|
170
|
+
}>;
|
|
171
|
+
claimPregenWallets: (body?: claimPreGenWalletsBody) => Promise<{
|
|
172
|
+
walletIds: string[];
|
|
173
|
+
}>;
|
|
185
174
|
sendTransaction: (userId: string, walletId: string, body: sendTransactionBody) => Promise<any>;
|
|
186
175
|
signTransaction: (userId: string, walletId: string, body: signTransactionBody) => Promise<any>;
|
|
187
176
|
refreshKeys: (userId: string, walletId: string, oldPartnerId?: string, newPartnerId?: string, keyShareProtocolId?: string) => Promise<any>;
|
|
@@ -213,7 +202,7 @@ declare class Client {
|
|
|
213
202
|
}[]): Promise<any>;
|
|
214
203
|
getTransmissionKeyshares(userId: string, sessionLookupId: string): Promise<any>;
|
|
215
204
|
getParaShare: (userId: string, walletId: string) => Promise<string>;
|
|
216
|
-
getBackupKit: (userId: string
|
|
205
|
+
getBackupKit: (userId: string) => Promise<any>;
|
|
217
206
|
resendVerificationCode({ userId, ...rest }: {
|
|
218
207
|
userId: string;
|
|
219
208
|
} & VerificationEmailProps): Promise<AxiosResponse<any, any>>;
|
|
@@ -223,10 +212,10 @@ declare class Client {
|
|
|
223
212
|
cancelRecoveryAttempt(email: string): Promise<AxiosResponse<any, any>>;
|
|
224
213
|
check2FAStatus(userId: string): Promise<AxiosResponse<any, any>>;
|
|
225
214
|
enable2FA(userId: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
|
|
226
|
-
setup2FA(userId: string): Promise<
|
|
215
|
+
setup2FA(userId: string): Promise<Setup2faResponse>;
|
|
227
216
|
initializeRecovery(email: string): Promise<AxiosResponse<any, any>>;
|
|
228
217
|
initializeFarcasterLogin(): Promise<AxiosResponse<any, any>>;
|
|
229
|
-
getFarcasterAuthStatus(): Promise<
|
|
218
|
+
getFarcasterAuthStatus(): Promise<VerifyFarcasterResponse>;
|
|
230
219
|
initializeRecoveryForPhone(phone: string, countryCode: string): Promise<AxiosResponse<any, any>>;
|
|
231
220
|
finalizeRecovery(userId: string, walletId: string): Promise<AxiosResponse<any, any>>;
|
|
232
221
|
recoverUserShares(userId: string, walletId: string): Promise<AxiosResponse<{
|
|
@@ -245,8 +234,11 @@ declare class Client {
|
|
|
245
234
|
}, any>>;
|
|
246
235
|
verifyEmailForRecovery(email: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
|
|
247
236
|
verifyPhoneForRecovery(phone: string, countryCode: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
|
|
248
|
-
verify2FA(
|
|
249
|
-
|
|
237
|
+
verify2FA(auth: VerifiedAuth, verificationCode: string): Promise<any>;
|
|
238
|
+
/**
|
|
239
|
+
* @deprecated
|
|
240
|
+
*/
|
|
241
|
+
verify2FAForPhone(phone: AuthIdentifier<'phone'>, verificationCode: string): Promise<AxiosResponse<any, any>>;
|
|
250
242
|
tempTrasmissionInit(message: string, userId?: string): Promise<AxiosResponse<any, any>>;
|
|
251
243
|
tempTrasmission(id: string): Promise<AxiosResponse<any, any>>;
|
|
252
244
|
getPartner(partnerId: string): Promise<AxiosResponse<any, any>>;
|
|
@@ -335,8 +327,5 @@ declare class Client {
|
|
|
335
327
|
verifyPasswordChallenge(partnerId: string, body: verifyPasswordChallengeBody): Promise<any>;
|
|
336
328
|
getEncryptedWalletPrivateKey(passwordId: string): Promise<any>;
|
|
337
329
|
getUser(userId: string): Promise<any>;
|
|
338
|
-
getAccountMetadata(userId: string, partnerId: string): Promise<{
|
|
339
|
-
accountMetadata: AccountMetadata;
|
|
340
|
-
}>;
|
|
341
330
|
}
|
|
342
331
|
export default Client;
|