@getpara/user-management-client 1.7.1 → 2.0.0-dev.0
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 +72 -55
- package/dist/cjs/index.js.br +0 -0
- package/dist/cjs/index.js.gz +0 -0
- package/dist/esm/index.js +69 -55
- package/dist/esm/index.js.br +0 -0
- package/dist/esm/index.js.gz +0 -0
- package/dist/types/client.d.ts +9 -20
- package/dist/types/types/auth.d.ts +30 -13
- package/dist/types/types/partner.d.ts +6 -0
- package/dist/types/types/wallet.d.ts +4 -2
- package/dist/types/utils.d.ts +22 -9
- package/package.json +2 -2
- package/dist/cjs/package.json +0 -3
- package/dist/esm/package.json +0 -4
package/dist/cjs/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
5
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
@@ -20,7 +18,6 @@ var __spreadValues = (a, b) => {
|
|
|
20
18
|
}
|
|
21
19
|
return a;
|
|
22
20
|
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
21
|
var __objRest = (source, exclude) => {
|
|
25
22
|
var target = {};
|
|
26
23
|
for (var prop in source)
|
|
@@ -106,8 +103,11 @@ __export(src_exports, {
|
|
|
106
103
|
isExternalWalletAddress: () => isExternalWalletAddress,
|
|
107
104
|
isFarcaster: () => isFarcaster,
|
|
108
105
|
isPhone: () => isPhone,
|
|
106
|
+
isPhoneLegacy: () => isPhoneLegacy,
|
|
107
|
+
isPrimary: () => isPrimary,
|
|
109
108
|
isTelegram: () => isTelegram,
|
|
110
109
|
isUserId: () => isUserId,
|
|
110
|
+
isVerifiedAuth: () => isVerifiedAuth,
|
|
111
111
|
isWalletId: () => isWalletId
|
|
112
112
|
});
|
|
113
113
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -117,6 +117,7 @@ var import_axios = __toESM(require("axios"));
|
|
|
117
117
|
var import_qs = __toESM(require("qs"));
|
|
118
118
|
|
|
119
119
|
// src/utils.ts
|
|
120
|
+
var import_libphonenumber_js = __toESM(require("libphonenumber-js"));
|
|
120
121
|
function isWalletId(params) {
|
|
121
122
|
return !!params.walletId && !params.externalWalletAddress;
|
|
122
123
|
}
|
|
@@ -135,63 +136,96 @@ function isValid(s) {
|
|
|
135
136
|
return !!s && s !== "null" && s !== "undefined" && s !== "";
|
|
136
137
|
}
|
|
137
138
|
function isEmail(params) {
|
|
138
|
-
return isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.
|
|
139
|
+
return !!params && isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.externalWalletAddress);
|
|
139
140
|
}
|
|
140
141
|
function isPhone(params) {
|
|
141
|
-
return isValid(params.phone) && isValid(params.countryCode) && !isValid(params.email) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(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);
|
|
143
|
+
}
|
|
144
|
+
function isPhoneLegacy(params) {
|
|
145
|
+
return !!params && isValid(params.phone) && isValid(params.countryCode) && !isValid(params.email) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.externalWalletAddress);
|
|
142
146
|
}
|
|
143
147
|
function isFarcaster(params) {
|
|
144
|
-
return isValid(params.farcasterUsername) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.telegramUserId) && !isValid(params.
|
|
148
|
+
return !!params && isValid(params.farcasterUsername) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.telegramUserId) && !isValid(params.externalWalletAddress);
|
|
145
149
|
}
|
|
146
150
|
function isTelegram(params) {
|
|
147
|
-
return isValid(params.telegramUserId) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.
|
|
151
|
+
return !!params && isValid(params.telegramUserId) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.externalWalletAddress);
|
|
148
152
|
}
|
|
149
153
|
function isUserId(params) {
|
|
150
|
-
return isValid(params.userId) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(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);
|
|
151
155
|
}
|
|
152
156
|
function isExternalWallet(params) {
|
|
153
|
-
return isValid(params.externalWalletAddress) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId);
|
|
157
|
+
return !!params && isValid(params.externalWalletAddress) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId);
|
|
158
|
+
}
|
|
159
|
+
function isPrimary(params) {
|
|
160
|
+
return isEmail(params) || isPhone(params) || isFarcaster(params) || isTelegram(params);
|
|
161
|
+
}
|
|
162
|
+
function isVerifiedAuth(params) {
|
|
163
|
+
return isEmail(params) || isPhone(params);
|
|
154
164
|
}
|
|
155
165
|
function extractAuthInfo(obj, { allowUserId = false, isRequired = false } = {}) {
|
|
166
|
+
obj = Object.entries(obj || {}).reduce((acc, [k, v]) => {
|
|
167
|
+
return __spreadValues(__spreadValues({}, acc), !!v && v !== "null" && v !== "undefined" && v !== "" ? { [k]: v } : {});
|
|
168
|
+
}, {});
|
|
169
|
+
let error;
|
|
156
170
|
switch (true) {
|
|
157
171
|
case isEmail(obj):
|
|
158
|
-
return {
|
|
172
|
+
return {
|
|
173
|
+
auth: { email: obj.email },
|
|
174
|
+
authType: "email",
|
|
175
|
+
identifier: obj.email
|
|
176
|
+
};
|
|
159
177
|
case isPhone(obj):
|
|
178
|
+
if (!(0, import_libphonenumber_js.default)(obj.phone)) {
|
|
179
|
+
error = "invalid phone number";
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
160
182
|
return {
|
|
161
|
-
auth: { phone: obj.phone
|
|
183
|
+
auth: { phone: obj.phone },
|
|
162
184
|
authType: "phone",
|
|
163
|
-
identifier:
|
|
164
|
-
|
|
185
|
+
identifier: obj.phone
|
|
186
|
+
};
|
|
187
|
+
case isPhoneLegacy(obj):
|
|
188
|
+
const identifier = `${obj.countryCode.startsWith("+") ? "" : "+"}${obj.countryCode}${obj.phone}`;
|
|
189
|
+
if (!(0, import_libphonenumber_js.default)(identifier)) {
|
|
190
|
+
error = "invalid phone number";
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
auth: { phone: identifier },
|
|
195
|
+
authType: "phone",
|
|
196
|
+
identifier
|
|
165
197
|
};
|
|
166
198
|
case isFarcaster(obj):
|
|
167
199
|
return {
|
|
168
200
|
auth: { farcasterUsername: obj.farcasterUsername },
|
|
169
201
|
authType: "farcaster",
|
|
170
|
-
identifier: obj.farcasterUsername
|
|
171
|
-
publicKeyIdentifier: `${obj.farcasterUsername}-farcaster`
|
|
202
|
+
identifier: obj.farcasterUsername
|
|
172
203
|
};
|
|
173
204
|
case isTelegram(obj):
|
|
174
205
|
return {
|
|
175
206
|
auth: { telegramUserId: obj.telegramUserId },
|
|
176
207
|
authType: "telegram",
|
|
177
|
-
identifier: obj.telegramUserId
|
|
178
|
-
publicKeyIdentifier: `${obj.telegramUserId}-telegram`
|
|
208
|
+
identifier: obj.telegramUserId
|
|
179
209
|
};
|
|
180
210
|
case isExternalWallet(obj):
|
|
181
211
|
return {
|
|
182
212
|
auth: { externalWalletAddress: obj.externalWalletAddress },
|
|
183
213
|
authType: "externalWallet",
|
|
184
|
-
identifier: obj.externalWalletAddress
|
|
185
|
-
publicKeyIdentifier: `${obj.externalWalletAddress}-external-wallet`
|
|
214
|
+
identifier: obj.externalWalletAddress
|
|
186
215
|
};
|
|
187
216
|
case (isUserId(obj) && allowUserId):
|
|
188
|
-
return {
|
|
217
|
+
return {
|
|
218
|
+
auth: { userId: obj.userId },
|
|
219
|
+
authType: "userId",
|
|
220
|
+
identifier: obj.userId
|
|
221
|
+
};
|
|
189
222
|
default:
|
|
190
|
-
|
|
191
|
-
throw new Error("invalid auth object");
|
|
192
|
-
}
|
|
193
|
-
return void 0;
|
|
223
|
+
break;
|
|
194
224
|
}
|
|
225
|
+
if (isRequired) {
|
|
226
|
+
throw new Error(error != null ? error : "invalid auth object");
|
|
227
|
+
}
|
|
228
|
+
return void 0;
|
|
195
229
|
}
|
|
196
230
|
|
|
197
231
|
// src/consts.ts
|
|
@@ -291,8 +325,10 @@ var Client = class {
|
|
|
291
325
|
return res;
|
|
292
326
|
});
|
|
293
327
|
// GET /biometrics/location-hints
|
|
294
|
-
this.getBiometricLocationHints = (
|
|
295
|
-
const res = yield this.baseRequest.get(`/biometrics/location-hints`, {
|
|
328
|
+
this.getBiometricLocationHints = (auth) => __async(this, null, function* () {
|
|
329
|
+
const res = yield this.baseRequest.get(`/biometrics/location-hints`, {
|
|
330
|
+
params: auth
|
|
331
|
+
});
|
|
296
332
|
return res.data.hints;
|
|
297
333
|
});
|
|
298
334
|
// GET /users/:userId/biometrics/:biometricId
|
|
@@ -318,10 +354,8 @@ var Client = class {
|
|
|
318
354
|
});
|
|
319
355
|
// POST /touch
|
|
320
356
|
this.touchSession = (regenerate) => __async(this, null, function* () {
|
|
321
|
-
const res = yield this.baseRequest.post(
|
|
322
|
-
|
|
323
|
-
);
|
|
324
|
-
return res;
|
|
357
|
+
const res = yield this.baseRequest.post(`/touch?regenerate=${!!regenerate}`);
|
|
358
|
+
return res.data;
|
|
325
359
|
});
|
|
326
360
|
// GET /session/origin
|
|
327
361
|
this.sessionOrigin = (sessionLookupId) => __async(this, null, function* () {
|
|
@@ -457,11 +491,9 @@ var Client = class {
|
|
|
457
491
|
const res = yield this.baseRequest.get(`/users/${userId}/wallets/${walletId}/capsule-share`);
|
|
458
492
|
return res.data.share;
|
|
459
493
|
});
|
|
460
|
-
// GET /
|
|
461
|
-
this.getBackupKit = (userId
|
|
462
|
-
const res = yield this.baseRequest.get(`/
|
|
463
|
-
responseType: "blob"
|
|
464
|
-
});
|
|
494
|
+
// GET /download-backup-kit/:userId
|
|
495
|
+
this.getBackupKit = (userId) => __async(this, null, function* () {
|
|
496
|
+
const res = yield this.baseRequest.get(`/download-backup-kit/${userId}`, { responseType: "blob" });
|
|
465
497
|
return res;
|
|
466
498
|
});
|
|
467
499
|
// PATCH /users/:userId/biometrics/:biometricId
|
|
@@ -701,9 +733,9 @@ var Client = class {
|
|
|
701
733
|
});
|
|
702
734
|
}
|
|
703
735
|
// POST /2fa/phone/verify
|
|
704
|
-
verify2FAForPhone(phone,
|
|
736
|
+
verify2FAForPhone(phone, verificationCode) {
|
|
705
737
|
return __async(this, null, function* () {
|
|
706
|
-
const body = { phone,
|
|
738
|
+
const body = { phone, verificationCode };
|
|
707
739
|
const res = yield this.baseRequest.post("/2fa/verify", body);
|
|
708
740
|
return res;
|
|
709
741
|
});
|
|
@@ -1019,24 +1051,6 @@ var Client = class {
|
|
|
1019
1051
|
return res.data;
|
|
1020
1052
|
});
|
|
1021
1053
|
}
|
|
1022
|
-
// GET /users/:userId/accounts
|
|
1023
|
-
getAccountMetadata(userId, partnerId) {
|
|
1024
|
-
return __async(this, null, function* () {
|
|
1025
|
-
const res = yield this.baseRequest.get(`/users/${userId}/oauth/accounts`, {
|
|
1026
|
-
params: { partnerId }
|
|
1027
|
-
});
|
|
1028
|
-
return {
|
|
1029
|
-
accountMetadata: Object.entries(res.data.accountMetadata || {}).reduce(
|
|
1030
|
-
(acc, [method, obj]) => __spreadProps(__spreadValues({}, acc), {
|
|
1031
|
-
[method]: __spreadProps(__spreadValues({}, obj), {
|
|
1032
|
-
date: new Date(obj.date)
|
|
1033
|
-
})
|
|
1034
|
-
}),
|
|
1035
|
-
{}
|
|
1036
|
-
)
|
|
1037
|
-
};
|
|
1038
|
-
});
|
|
1039
|
-
}
|
|
1040
1054
|
};
|
|
1041
1055
|
var client_default = Client;
|
|
1042
1056
|
|
|
@@ -1196,7 +1210,10 @@ var src_default = client_default;
|
|
|
1196
1210
|
isExternalWalletAddress,
|
|
1197
1211
|
isFarcaster,
|
|
1198
1212
|
isPhone,
|
|
1213
|
+
isPhoneLegacy,
|
|
1214
|
+
isPrimary,
|
|
1199
1215
|
isTelegram,
|
|
1200
1216
|
isUserId,
|
|
1217
|
+
isVerifiedAuth,
|
|
1201
1218
|
isWalletId
|
|
1202
1219
|
});
|
package/dist/cjs/index.js.br
CHANGED
|
Binary file
|
package/dist/cjs/index.js.gz
CHANGED
|
Binary file
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
2
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
3
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
4
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -16,7 +14,6 @@ var __spreadValues = (a, b) => {
|
|
|
16
14
|
}
|
|
17
15
|
return a;
|
|
18
16
|
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
17
|
var __objRest = (source, exclude) => {
|
|
21
18
|
var target = {};
|
|
22
19
|
for (var prop in source)
|
|
@@ -55,6 +52,7 @@ import axios from "axios";
|
|
|
55
52
|
import qs from "qs";
|
|
56
53
|
|
|
57
54
|
// src/utils.ts
|
|
55
|
+
import parsePhoneNumberFromString from "libphonenumber-js";
|
|
58
56
|
function isWalletId(params) {
|
|
59
57
|
return !!params.walletId && !params.externalWalletAddress;
|
|
60
58
|
}
|
|
@@ -73,63 +71,96 @@ function isValid(s) {
|
|
|
73
71
|
return !!s && s !== "null" && s !== "undefined" && s !== "";
|
|
74
72
|
}
|
|
75
73
|
function isEmail(params) {
|
|
76
|
-
return isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.
|
|
74
|
+
return !!params && isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.externalWalletAddress);
|
|
77
75
|
}
|
|
78
76
|
function isPhone(params) {
|
|
79
|
-
return isValid(params.phone) && isValid(params.countryCode) && !isValid(params.email) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.
|
|
77
|
+
return !!params && isValid(params.phone) && /^\+\d+$/.test(params.phone) && !isValid(params.countryCode) && !isValid(params.email) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.userId) && !isValid(params.externalWalletAddress);
|
|
78
|
+
}
|
|
79
|
+
function isPhoneLegacy(params) {
|
|
80
|
+
return !!params && isValid(params.phone) && isValid(params.countryCode) && !isValid(params.email) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.externalWalletAddress);
|
|
80
81
|
}
|
|
81
82
|
function isFarcaster(params) {
|
|
82
|
-
return isValid(params.farcasterUsername) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.telegramUserId) && !isValid(params.
|
|
83
|
+
return !!params && isValid(params.farcasterUsername) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.telegramUserId) && !isValid(params.externalWalletAddress);
|
|
83
84
|
}
|
|
84
85
|
function isTelegram(params) {
|
|
85
|
-
return isValid(params.telegramUserId) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.
|
|
86
|
+
return !!params && isValid(params.telegramUserId) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.externalWalletAddress);
|
|
86
87
|
}
|
|
87
88
|
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.
|
|
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
90
|
}
|
|
90
91
|
function isExternalWallet(params) {
|
|
91
|
-
return 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);
|
|
93
|
+
}
|
|
94
|
+
function isPrimary(params) {
|
|
95
|
+
return isEmail(params) || isPhone(params) || isFarcaster(params) || isTelegram(params);
|
|
96
|
+
}
|
|
97
|
+
function isVerifiedAuth(params) {
|
|
98
|
+
return isEmail(params) || isPhone(params);
|
|
92
99
|
}
|
|
93
100
|
function extractAuthInfo(obj, { allowUserId = false, isRequired = false } = {}) {
|
|
101
|
+
obj = Object.entries(obj || {}).reduce((acc, [k, v]) => {
|
|
102
|
+
return __spreadValues(__spreadValues({}, acc), !!v && v !== "null" && v !== "undefined" && v !== "" ? { [k]: v } : {});
|
|
103
|
+
}, {});
|
|
104
|
+
let error;
|
|
94
105
|
switch (true) {
|
|
95
106
|
case isEmail(obj):
|
|
96
|
-
return {
|
|
107
|
+
return {
|
|
108
|
+
auth: { email: obj.email },
|
|
109
|
+
authType: "email",
|
|
110
|
+
identifier: obj.email
|
|
111
|
+
};
|
|
97
112
|
case isPhone(obj):
|
|
113
|
+
if (!parsePhoneNumberFromString(obj.phone)) {
|
|
114
|
+
error = "invalid phone number";
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
98
117
|
return {
|
|
99
|
-
auth: { phone: obj.phone
|
|
118
|
+
auth: { phone: obj.phone },
|
|
100
119
|
authType: "phone",
|
|
101
|
-
identifier:
|
|
102
|
-
|
|
120
|
+
identifier: obj.phone
|
|
121
|
+
};
|
|
122
|
+
case isPhoneLegacy(obj):
|
|
123
|
+
const identifier = `${obj.countryCode.startsWith("+") ? "" : "+"}${obj.countryCode}${obj.phone}`;
|
|
124
|
+
if (!parsePhoneNumberFromString(identifier)) {
|
|
125
|
+
error = "invalid phone number";
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
auth: { phone: identifier },
|
|
130
|
+
authType: "phone",
|
|
131
|
+
identifier
|
|
103
132
|
};
|
|
104
133
|
case isFarcaster(obj):
|
|
105
134
|
return {
|
|
106
135
|
auth: { farcasterUsername: obj.farcasterUsername },
|
|
107
136
|
authType: "farcaster",
|
|
108
|
-
identifier: obj.farcasterUsername
|
|
109
|
-
publicKeyIdentifier: `${obj.farcasterUsername}-farcaster`
|
|
137
|
+
identifier: obj.farcasterUsername
|
|
110
138
|
};
|
|
111
139
|
case isTelegram(obj):
|
|
112
140
|
return {
|
|
113
141
|
auth: { telegramUserId: obj.telegramUserId },
|
|
114
142
|
authType: "telegram",
|
|
115
|
-
identifier: obj.telegramUserId
|
|
116
|
-
publicKeyIdentifier: `${obj.telegramUserId}-telegram`
|
|
143
|
+
identifier: obj.telegramUserId
|
|
117
144
|
};
|
|
118
145
|
case isExternalWallet(obj):
|
|
119
146
|
return {
|
|
120
147
|
auth: { externalWalletAddress: obj.externalWalletAddress },
|
|
121
148
|
authType: "externalWallet",
|
|
122
|
-
identifier: obj.externalWalletAddress
|
|
123
|
-
publicKeyIdentifier: `${obj.externalWalletAddress}-external-wallet`
|
|
149
|
+
identifier: obj.externalWalletAddress
|
|
124
150
|
};
|
|
125
151
|
case (isUserId(obj) && allowUserId):
|
|
126
|
-
return {
|
|
152
|
+
return {
|
|
153
|
+
auth: { userId: obj.userId },
|
|
154
|
+
authType: "userId",
|
|
155
|
+
identifier: obj.userId
|
|
156
|
+
};
|
|
127
157
|
default:
|
|
128
|
-
|
|
129
|
-
throw new Error("invalid auth object");
|
|
130
|
-
}
|
|
131
|
-
return void 0;
|
|
158
|
+
break;
|
|
132
159
|
}
|
|
160
|
+
if (isRequired) {
|
|
161
|
+
throw new Error(error != null ? error : "invalid auth object");
|
|
162
|
+
}
|
|
163
|
+
return void 0;
|
|
133
164
|
}
|
|
134
165
|
|
|
135
166
|
// src/consts.ts
|
|
@@ -229,8 +260,10 @@ var Client = class {
|
|
|
229
260
|
return res;
|
|
230
261
|
});
|
|
231
262
|
// GET /biometrics/location-hints
|
|
232
|
-
this.getBiometricLocationHints = (
|
|
233
|
-
const res = yield this.baseRequest.get(`/biometrics/location-hints`, {
|
|
263
|
+
this.getBiometricLocationHints = (auth) => __async(this, null, function* () {
|
|
264
|
+
const res = yield this.baseRequest.get(`/biometrics/location-hints`, {
|
|
265
|
+
params: auth
|
|
266
|
+
});
|
|
234
267
|
return res.data.hints;
|
|
235
268
|
});
|
|
236
269
|
// GET /users/:userId/biometrics/:biometricId
|
|
@@ -256,10 +289,8 @@ var Client = class {
|
|
|
256
289
|
});
|
|
257
290
|
// POST /touch
|
|
258
291
|
this.touchSession = (regenerate) => __async(this, null, function* () {
|
|
259
|
-
const res = yield this.baseRequest.post(
|
|
260
|
-
|
|
261
|
-
);
|
|
262
|
-
return res;
|
|
292
|
+
const res = yield this.baseRequest.post(`/touch?regenerate=${!!regenerate}`);
|
|
293
|
+
return res.data;
|
|
263
294
|
});
|
|
264
295
|
// GET /session/origin
|
|
265
296
|
this.sessionOrigin = (sessionLookupId) => __async(this, null, function* () {
|
|
@@ -395,11 +426,9 @@ var Client = class {
|
|
|
395
426
|
const res = yield this.baseRequest.get(`/users/${userId}/wallets/${walletId}/capsule-share`);
|
|
396
427
|
return res.data.share;
|
|
397
428
|
});
|
|
398
|
-
// GET /
|
|
399
|
-
this.getBackupKit = (userId
|
|
400
|
-
const res = yield this.baseRequest.get(`/
|
|
401
|
-
responseType: "blob"
|
|
402
|
-
});
|
|
429
|
+
// GET /download-backup-kit/:userId
|
|
430
|
+
this.getBackupKit = (userId) => __async(this, null, function* () {
|
|
431
|
+
const res = yield this.baseRequest.get(`/download-backup-kit/${userId}`, { responseType: "blob" });
|
|
403
432
|
return res;
|
|
404
433
|
});
|
|
405
434
|
// PATCH /users/:userId/biometrics/:biometricId
|
|
@@ -639,9 +668,9 @@ var Client = class {
|
|
|
639
668
|
});
|
|
640
669
|
}
|
|
641
670
|
// POST /2fa/phone/verify
|
|
642
|
-
verify2FAForPhone(phone,
|
|
671
|
+
verify2FAForPhone(phone, verificationCode) {
|
|
643
672
|
return __async(this, null, function* () {
|
|
644
|
-
const body = { phone,
|
|
673
|
+
const body = { phone, verificationCode };
|
|
645
674
|
const res = yield this.baseRequest.post("/2fa/verify", body);
|
|
646
675
|
return res;
|
|
647
676
|
});
|
|
@@ -957,24 +986,6 @@ var Client = class {
|
|
|
957
986
|
return res.data;
|
|
958
987
|
});
|
|
959
988
|
}
|
|
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
989
|
};
|
|
979
990
|
var client_default = Client;
|
|
980
991
|
|
|
@@ -1134,7 +1145,10 @@ export {
|
|
|
1134
1145
|
isExternalWalletAddress,
|
|
1135
1146
|
isFarcaster,
|
|
1136
1147
|
isPhone,
|
|
1148
|
+
isPhoneLegacy,
|
|
1149
|
+
isPrimary,
|
|
1137
1150
|
isTelegram,
|
|
1138
1151
|
isUserId,
|
|
1152
|
+
isVerifiedAuth,
|
|
1139
1153
|
isWalletId
|
|
1140
1154
|
};
|
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, 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';
|
|
3
3
|
interface ConfigOpts {
|
|
4
4
|
useFetchAdapter?: boolean;
|
|
5
5
|
}
|
|
@@ -7,18 +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
15
|
interface ExternalWalletLoginBody {
|
|
23
16
|
externalAddress: string;
|
|
24
17
|
type: 'EVM' | 'SOLANA' | 'COSMOS';
|
|
@@ -138,7 +131,6 @@ interface sessionPasswordBody {
|
|
|
138
131
|
encryptedWalletPrivateKey?: string;
|
|
139
132
|
encryptionKeyHash?: string;
|
|
140
133
|
}
|
|
141
|
-
type BiometricLocationHintParams = AuthParams;
|
|
142
134
|
export type VerifyTelegramRes = {
|
|
143
135
|
isValid: true;
|
|
144
136
|
userId: string;
|
|
@@ -154,8 +146,8 @@ export declare const handleResponseError: (error: any) => never;
|
|
|
154
146
|
declare class Client {
|
|
155
147
|
private baseRequest;
|
|
156
148
|
constructor({ userManagementHost, apiKey, partnerId, version, opts, retrieveSessionCookie, persistSessionCookie, }: ClientConfig);
|
|
157
|
-
createUser: (body:
|
|
158
|
-
checkUserExists: (auth:
|
|
149
|
+
createUser: (body: VerifiedAuth & VerificationEmailProps) => Promise<createUserIdRes>;
|
|
150
|
+
checkUserExists: (auth: VerifiedAuth) => Promise<any>;
|
|
159
151
|
verifyTelegram: (authObject: TelegramAuthResponse) => Promise<VerifyTelegramRes>;
|
|
160
152
|
externalWalletLogin: (body: ExternalWalletLoginBody) => Promise<ExternalWalletLoginRes>;
|
|
161
153
|
verifyEmail: (userId: string, body: verifyBody) => Promise<any>;
|
|
@@ -163,11 +155,11 @@ declare class Client {
|
|
|
163
155
|
verifyExternalWallet: (userId: string, body: verifyExternalWalletBody) => Promise<any>;
|
|
164
156
|
addSessionPublicKey: (userId: string, body: sessionPublicKeyBody) => Promise<any>;
|
|
165
157
|
getSessionPublicKeys: (userId: string) => Promise<any>;
|
|
166
|
-
getBiometricLocationHints: (
|
|
158
|
+
getBiometricLocationHints: (auth: PrimaryAuth) => Promise<BiometricLocationHint[]>;
|
|
167
159
|
getSessionPublicKey: (userId: string, biometricId: string) => Promise<any>;
|
|
168
160
|
patchSessionPublicKey: (partnerId: string, userId: string, biometricId: string, body: sessionPublicKeyBody) => Promise<any>;
|
|
169
|
-
getWebChallenge: (auth?:
|
|
170
|
-
touchSession: (regenerate?: boolean) => Promise<
|
|
161
|
+
getWebChallenge: (auth?: PrimaryAuth) => Promise<getWebChallengeRes>;
|
|
162
|
+
touchSession: (regenerate?: boolean) => Promise<SessionInfo>;
|
|
171
163
|
sessionOrigin: (sessionLookupId: string) => Promise<{
|
|
172
164
|
origin?: string;
|
|
173
165
|
}>;
|
|
@@ -213,7 +205,7 @@ declare class Client {
|
|
|
213
205
|
}[]): Promise<any>;
|
|
214
206
|
getTransmissionKeyshares(userId: string, sessionLookupId: string): Promise<any>;
|
|
215
207
|
getParaShare: (userId: string, walletId: string) => Promise<string>;
|
|
216
|
-
getBackupKit: (userId: string
|
|
208
|
+
getBackupKit: (userId: string) => Promise<any>;
|
|
217
209
|
resendVerificationCode({ userId, ...rest }: {
|
|
218
210
|
userId: string;
|
|
219
211
|
} & VerificationEmailProps): Promise<AxiosResponse<any, any>>;
|
|
@@ -246,7 +238,7 @@ declare class Client {
|
|
|
246
238
|
verifyEmailForRecovery(email: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
|
|
247
239
|
verifyPhoneForRecovery(phone: string, countryCode: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
|
|
248
240
|
verify2FA(email: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
|
|
249
|
-
verify2FAForPhone(phone:
|
|
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;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
export type
|
|
1
|
+
import { CurrentWalletIds, SupportedWalletTypes } from './wallet.js';
|
|
2
|
+
export type AuthType = 'email' | 'phone' | 'phoneLegacy' | 'farcaster' | 'telegram' | 'userId' | 'externalWallet';
|
|
3
|
+
export type PrimaryAuthType = Extract<AuthType, 'email' | 'phone' | 'farcaster' | 'telegram' | 'externalWallet'>;
|
|
4
|
+
export type VerifiedAuthType = Extract<PrimaryAuthType, 'email' | 'phone'>;
|
|
5
|
+
export type AuthIdentifier<T extends AuthType | never> = T extends 'phone' ? `+${number}` : string;
|
|
6
|
+
export type AuthInfo<T extends Exclude<AuthType, 'phoneLegacy'> = Exclude<AuthType, 'phoneLegacy'>> = {
|
|
3
7
|
auth: Auth<T>;
|
|
4
8
|
authType: T;
|
|
5
|
-
identifier:
|
|
6
|
-
publicKeyIdentifier: string;
|
|
9
|
+
identifier: AuthIdentifier<T>;
|
|
7
10
|
};
|
|
8
|
-
export type
|
|
11
|
+
export type PrimaryAuthInfo = AuthInfo<PrimaryAuthType>;
|
|
12
|
+
export type VerifiedAuthInfo = AuthInfo<VerifiedAuthType>;
|
|
9
13
|
export type AuthParams = Record<string, any> & {
|
|
10
14
|
email?: string;
|
|
11
15
|
phone?: string;
|
|
@@ -17,18 +21,22 @@ export type AuthParams = Record<string, any> & {
|
|
|
17
21
|
};
|
|
18
22
|
export type Auth<T extends AuthType = AuthType> = T extends 'email' ? {
|
|
19
23
|
email: string;
|
|
20
|
-
} : T extends '
|
|
24
|
+
} : T extends 'phoneLegacy' ? {
|
|
21
25
|
phone: string;
|
|
22
26
|
countryCode: string;
|
|
27
|
+
} : T extends 'phone' ? {
|
|
28
|
+
phone: AuthIdentifier<'phone'>;
|
|
23
29
|
} : T extends 'farcaster' ? {
|
|
24
|
-
farcasterUsername:
|
|
30
|
+
farcasterUsername: AuthIdentifier<'farcaster'>;
|
|
25
31
|
} : T extends 'telegram' ? {
|
|
26
|
-
telegramUserId:
|
|
32
|
+
telegramUserId: AuthIdentifier<'telegram'>;
|
|
27
33
|
} : T extends 'externalWallet' ? {
|
|
28
34
|
externalWalletAddress: string;
|
|
29
35
|
} : {
|
|
30
36
|
userId: string;
|
|
31
37
|
};
|
|
38
|
+
export type PrimaryAuth = Auth<PrimaryAuthType>;
|
|
39
|
+
export type VerifiedAuth = Auth<VerifiedAuthType>;
|
|
32
40
|
export declare enum EncryptorType {
|
|
33
41
|
USER = "USER",
|
|
34
42
|
RECOVERY = "RECOVERY",
|
|
@@ -87,8 +95,17 @@ export type TelegramAuthResponse = {
|
|
|
87
95
|
photo_url?: string;
|
|
88
96
|
username?: string;
|
|
89
97
|
};
|
|
90
|
-
export type
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
export type SessionInfo = {
|
|
99
|
+
userId?: string;
|
|
100
|
+
sessionId?: string;
|
|
101
|
+
sessionLookupId?: string;
|
|
102
|
+
partnerId: string;
|
|
103
|
+
biometricVerifiedAt?: number;
|
|
104
|
+
currentWalletIds?: CurrentWalletIds;
|
|
105
|
+
needsWallet?: boolean;
|
|
106
|
+
isAuthenticated?: boolean;
|
|
107
|
+
supportedWalletTypes: SupportedWalletTypes;
|
|
108
|
+
cosmosPrefix?: string;
|
|
109
|
+
origin?: string;
|
|
110
|
+
email?: string;
|
|
111
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { AuthMethod } from './auth.js';
|
|
2
|
+
import { SupportedWalletTypes } from './wallet.js';
|
|
1
3
|
export interface PartnerEntity {
|
|
2
4
|
id: string;
|
|
3
5
|
displayName: string;
|
|
@@ -10,4 +12,8 @@ export interface PartnerEntity {
|
|
|
10
12
|
accentColor?: string;
|
|
11
13
|
font?: string;
|
|
12
14
|
themeMode?: 'light' | 'dark';
|
|
15
|
+
portalUrl?: string;
|
|
16
|
+
supportedAuthMethods?: AuthMethod[];
|
|
17
|
+
supportedWalletTypes?: SupportedWalletTypes;
|
|
18
|
+
cosmosPrefix?: string;
|
|
13
19
|
}
|
|
@@ -54,8 +54,10 @@ export interface WalletEntity {
|
|
|
54
54
|
lastUsedAt: string | null;
|
|
55
55
|
lastUsedPartnerId?: string;
|
|
56
56
|
lastUsedPartner?: PartnerEntity;
|
|
57
|
-
ensName?: string | null;
|
|
58
|
-
ensAvatar?: string | null;
|
|
59
57
|
}
|
|
60
58
|
export type CurrentWalletIds = Partial<Record<WalletType, string[]>>;
|
|
61
59
|
export declare const NON_ED25519: WalletScheme[];
|
|
60
|
+
export type SupportedWalletTypes = {
|
|
61
|
+
type: WalletType;
|
|
62
|
+
optional?: boolean;
|
|
63
|
+
}[];
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Auth, AuthParams,
|
|
1
|
+
import { Auth, AuthInfo, AuthParams, PrimaryAuth, PrimaryAuthInfo, VerifiedAuth, WalletParams, WalletRef } from './types/index.js';
|
|
2
2
|
export declare function isWalletId(params: WalletParams): params is {
|
|
3
3
|
walletId: string;
|
|
4
4
|
};
|
|
@@ -6,18 +6,31 @@ export declare function isExternalWalletAddress(params: WalletParams): params is
|
|
|
6
6
|
externalWalletAddress: string;
|
|
7
7
|
};
|
|
8
8
|
export declare function extractWalletRef(params: WalletParams): [WalletRef, string];
|
|
9
|
-
export declare function isEmail(params: AuthParams): params is Auth<'email'>;
|
|
10
|
-
export declare function isPhone(params: AuthParams): params is Auth<'phone'>;
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
9
|
+
export declare function isEmail(params: AuthParams | undefined): params is Auth<'email'>;
|
|
10
|
+
export declare function isPhone(params: AuthParams | undefined): params is Auth<'phone'>;
|
|
11
|
+
export declare function isPhoneLegacy(params: AuthParams | undefined): params is Auth<'phoneLegacy'>;
|
|
12
|
+
export declare function isFarcaster(params: AuthParams | undefined): params is Auth<'farcaster'>;
|
|
13
|
+
export declare function isTelegram(params: AuthParams | undefined): params is Auth<'telegram'>;
|
|
14
|
+
export declare function isUserId(params: AuthParams | undefined): params is Auth<'userId'>;
|
|
15
|
+
export declare function isExternalWallet(params: AuthParams | undefined): params is Auth<'externalWallet'>;
|
|
16
|
+
export declare function isPrimary(params: AuthParams | undefined): params is PrimaryAuth;
|
|
17
|
+
export declare function isVerifiedAuth(params: AuthParams | undefined): params is VerifiedAuth;
|
|
15
18
|
type ExtractAuthOpts = {
|
|
16
19
|
allowUserId?: boolean;
|
|
17
20
|
isRequired?: boolean;
|
|
18
21
|
};
|
|
22
|
+
export declare function extractAuthInfo(obj: AuthParams): PrimaryAuthInfo | undefined;
|
|
19
23
|
export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
|
|
24
|
+
allowUserId: false | undefined;
|
|
25
|
+
}): PrimaryAuthInfo | undefined;
|
|
26
|
+
export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
|
|
27
|
+
isRequired: true;
|
|
28
|
+
}): PrimaryAuthInfo;
|
|
29
|
+
export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
|
|
30
|
+
allowUserId: true;
|
|
31
|
+
}): AuthInfo | undefined;
|
|
32
|
+
export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
|
|
33
|
+
allowUserId: true;
|
|
20
34
|
isRequired: true;
|
|
21
|
-
}):
|
|
22
|
-
export declare function extractAuthInfo(obj: AuthParams, opts?: ExtractAuthOpts): ExtractAuth | undefined;
|
|
35
|
+
}): AuthInfo;
|
|
23
36
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/user-management-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-dev.0",
|
|
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": "
|
|
36
|
+
"gitHead": "f94ef031ef0e1894f5f0800e55f6ca2904641780"
|
|
37
37
|
}
|
package/dist/cjs/package.json
DELETED
package/dist/esm/package.json
DELETED