@getpara/user-management-client 2.0.0-dev.1 → 2.0.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client.js +964 -0
- package/dist/cjs/consts.js +36 -0
- package/dist/cjs/error.js +41 -0
- package/dist/cjs/index.js +12 -1342
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/types/auth.js +112 -0
- package/dist/cjs/types/email.js +31 -0
- package/dist/cjs/types/index.js +29 -0
- package/dist/cjs/types/onRamp.js +63 -0
- package/dist/cjs/types/partner.js +15 -0
- package/dist/cjs/types/wallet.js +112 -0
- package/dist/cjs/utils.js +282 -0
- package/dist/esm/chunk-BBZEL7EG.js +58 -0
- package/dist/esm/client.js +887 -0
- package/dist/esm/consts.js +11 -0
- package/dist/esm/error.js +19 -0
- package/dist/esm/index.js +8 -1301
- package/dist/esm/package.json +4 -0
- package/dist/esm/types/auth.js +81 -0
- package/dist/esm/types/email.js +9 -0
- package/dist/esm/types/index.js +5 -0
- package/dist/esm/types/onRamp.js +38 -0
- package/dist/esm/types/partner.js +0 -0
- package/dist/esm/types/wallet.js +79 -0
- package/dist/esm/utils.js +215 -0
- package/dist/types/client.d.ts +101 -61
- package/dist/types/types/auth.d.ts +64 -3
- package/dist/types/types/email.d.ts +5 -0
- package/dist/types/types/onRamp.d.ts +5 -4
- package/dist/types/types/partner.d.ts +2 -1
- package/dist/types/types/wallet.d.ts +23 -8
- package/dist/types/utils.d.ts +8 -2
- package/package.json +22 -23
- package/dist/cjs/index.js.br +0 -0
- package/dist/cjs/index.js.gz +0 -0
- package/dist/esm/index.js.br +0 -0
- package/dist/esm/index.js.gz +0 -0
|
@@ -0,0 +1,964 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
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));
|
|
24
|
+
var __objRest = (source, exclude) => {
|
|
25
|
+
var target = {};
|
|
26
|
+
for (var prop in source)
|
|
27
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
if (source != null && __getOwnPropSymbols)
|
|
30
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
+
target[prop] = source[prop];
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
36
|
+
var __export = (target, all) => {
|
|
37
|
+
for (var name in all)
|
|
38
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
39
|
+
};
|
|
40
|
+
var __copyProps = (to, from, except, desc) => {
|
|
41
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
42
|
+
for (let key of __getOwnPropNames(from))
|
|
43
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
44
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
45
|
+
}
|
|
46
|
+
return to;
|
|
47
|
+
};
|
|
48
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
49
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
50
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
51
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
52
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
53
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
54
|
+
mod
|
|
55
|
+
));
|
|
56
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
57
|
+
var __async = (__this, __arguments, generator) => {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
var fulfilled = (value) => {
|
|
60
|
+
try {
|
|
61
|
+
step(generator.next(value));
|
|
62
|
+
} catch (e) {
|
|
63
|
+
reject(e);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var rejected = (value) => {
|
|
67
|
+
try {
|
|
68
|
+
step(generator.throw(value));
|
|
69
|
+
} catch (e) {
|
|
70
|
+
reject(e);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
74
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
var client_exports = {};
|
|
78
|
+
__export(client_exports, {
|
|
79
|
+
default: () => client_default,
|
|
80
|
+
handleResponseError: () => handleResponseError,
|
|
81
|
+
handleResponseSuccess: () => handleResponseSuccess
|
|
82
|
+
});
|
|
83
|
+
module.exports = __toCommonJS(client_exports);
|
|
84
|
+
var import_axios = __toESM(require("axios"));
|
|
85
|
+
var import_utils = require("./utils.js");
|
|
86
|
+
var import_consts = require("./consts.js");
|
|
87
|
+
var import_error = require("./error.js");
|
|
88
|
+
const handleResponseSuccess = (response) => {
|
|
89
|
+
if (response.status === 200) {
|
|
90
|
+
return response;
|
|
91
|
+
}
|
|
92
|
+
throw new import_error.ParaApiError("Invalid status code");
|
|
93
|
+
};
|
|
94
|
+
const handleResponseError = (error) => {
|
|
95
|
+
var _a, _b, _c;
|
|
96
|
+
if (error === null) throw new import_error.ParaApiError("Error is null");
|
|
97
|
+
if (import_axios.default.isAxiosError(error)) {
|
|
98
|
+
let message = (_b = (_a = error.response) == null ? void 0 : _a.data) != null ? _b : "Unknown error";
|
|
99
|
+
if (error.code === "ERR_NETWORK") {
|
|
100
|
+
message = "Connection error";
|
|
101
|
+
} else if (error.code === "ERR_CANCELED") {
|
|
102
|
+
message = "Connection canceled";
|
|
103
|
+
}
|
|
104
|
+
throw new import_error.ParaApiError(message, error.code, error.response.status, (_c = error.request) == null ? void 0 : _c.responseURL);
|
|
105
|
+
}
|
|
106
|
+
throw new import_error.ParaApiError("Unknown error");
|
|
107
|
+
};
|
|
108
|
+
class Client {
|
|
109
|
+
constructor({
|
|
110
|
+
userManagementHost,
|
|
111
|
+
apiKey,
|
|
112
|
+
partnerId,
|
|
113
|
+
version,
|
|
114
|
+
opts,
|
|
115
|
+
retrieveSessionCookie,
|
|
116
|
+
persistSessionCookie
|
|
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
|
+
*/
|
|
125
|
+
this.createUser = (body) => __async(this, null, function* () {
|
|
126
|
+
const res = yield this.baseRequest.post(`/users`, body);
|
|
127
|
+
return res.data;
|
|
128
|
+
});
|
|
129
|
+
this.checkUserExists = (auth) => __async(this, null, function* () {
|
|
130
|
+
const res = yield this.baseRequest.get("/users/exists", {
|
|
131
|
+
params: __spreadValues({}, auth)
|
|
132
|
+
});
|
|
133
|
+
return res.data;
|
|
134
|
+
});
|
|
135
|
+
this.verifyTelegram = (authObject) => __async(this, null, function* () {
|
|
136
|
+
return (yield this.baseRequest.post("/users/telegram/v2", {
|
|
137
|
+
authObject
|
|
138
|
+
})).data;
|
|
139
|
+
});
|
|
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);
|
|
156
|
+
return res.data;
|
|
157
|
+
});
|
|
158
|
+
this.getLinkedAccounts = (_0) => __async(this, [_0], function* ({
|
|
159
|
+
userId,
|
|
160
|
+
withMetadata = false
|
|
161
|
+
}) {
|
|
162
|
+
const res = yield this.baseRequest.get(
|
|
163
|
+
`/users/${userId}/linked-accounts`,
|
|
164
|
+
...withMetadata ? [
|
|
165
|
+
{
|
|
166
|
+
params: { withMetadata }
|
|
167
|
+
}
|
|
168
|
+
] : []
|
|
169
|
+
);
|
|
170
|
+
return { accounts: (0, import_utils.fromLinkedAccounts)(res.data.accounts) };
|
|
171
|
+
});
|
|
172
|
+
this.linkAccount = (_a) => __async(this, null, function* () {
|
|
173
|
+
var _b = _a, { userId } = _b, opts = __objRest(_b, ["userId"]);
|
|
174
|
+
const res = yield this.baseRequest.post(`/users/${userId}/linked-accounts`, opts);
|
|
175
|
+
return res.data;
|
|
176
|
+
});
|
|
177
|
+
this.verifyLink = (_c) => __async(this, null, function* () {
|
|
178
|
+
var _d = _c, {
|
|
179
|
+
linkedAccountId,
|
|
180
|
+
userId
|
|
181
|
+
} = _d, opts = __objRest(_d, [
|
|
182
|
+
"linkedAccountId",
|
|
183
|
+
"userId"
|
|
184
|
+
]);
|
|
185
|
+
const res = yield this.baseRequest.post(
|
|
186
|
+
`/users/${userId}/linked-accounts/${linkedAccountId}/verify`,
|
|
187
|
+
opts
|
|
188
|
+
);
|
|
189
|
+
if ("isConflict" in res.data) {
|
|
190
|
+
return res.data;
|
|
191
|
+
}
|
|
192
|
+
const { accounts } = res.data;
|
|
193
|
+
return { accounts: (0, import_utils.fromLinkedAccounts)(accounts) };
|
|
194
|
+
});
|
|
195
|
+
this.unlinkAccount = (_0) => __async(this, [_0], function* ({ linkedAccountId, userId }) {
|
|
196
|
+
const res = yield this.baseRequest.delete(`/users/${userId}/linked-accounts/${linkedAccountId}`);
|
|
197
|
+
return res.data;
|
|
198
|
+
});
|
|
199
|
+
// POST /users/:userId/verify-email
|
|
200
|
+
/**
|
|
201
|
+
* @deprecated
|
|
202
|
+
*/
|
|
203
|
+
this.verifyEmail = (userId, body) => __async(this, null, function* () {
|
|
204
|
+
const res = yield this.baseRequest.post(`/users/${userId}/verify-email`, body);
|
|
205
|
+
return res;
|
|
206
|
+
});
|
|
207
|
+
/**
|
|
208
|
+
* @deprecated
|
|
209
|
+
*/
|
|
210
|
+
this.verifyPhone = (userId, body) => __async(this, null, function* () {
|
|
211
|
+
const res = yield this.baseRequest.post(`/users/${userId}/verify-identifier`, body);
|
|
212
|
+
return res;
|
|
213
|
+
});
|
|
214
|
+
this.verifyExternalWallet = (userId, body) => __async(this, null, function* () {
|
|
215
|
+
const res = yield this.baseRequest.post(`/users/${userId}/external-wallets/verify/v2`, body);
|
|
216
|
+
return res.data;
|
|
217
|
+
});
|
|
218
|
+
// POST /users/:userId/biometrics/key
|
|
219
|
+
this.addSessionPublicKey = (userId, body) => __async(this, null, function* () {
|
|
220
|
+
const res = yield this.baseRequest.post(`/users/${userId}/biometrics/key`, body);
|
|
221
|
+
return res;
|
|
222
|
+
});
|
|
223
|
+
// GET /users/:userId/biometrics/keys
|
|
224
|
+
this.getSessionPublicKeys = (userId) => __async(this, null, function* () {
|
|
225
|
+
const res = yield this.baseRequest.get(`/users/${userId}/biometrics/keys`);
|
|
226
|
+
return res;
|
|
227
|
+
});
|
|
228
|
+
// GET /biometrics/location-hints
|
|
229
|
+
this.getBiometricLocationHints = (auth) => __async(this, null, function* () {
|
|
230
|
+
const res = yield this.baseRequest.get(`/biometrics/location-hints`, {
|
|
231
|
+
params: auth
|
|
232
|
+
});
|
|
233
|
+
return res.data.hints;
|
|
234
|
+
});
|
|
235
|
+
// GET /users/:userId/biometrics/:biometricId
|
|
236
|
+
this.getSessionPublicKey = (userId, biometricId) => __async(this, null, function* () {
|
|
237
|
+
const res = yield this.baseRequest.get(`/users/${userId}/biometrics/${biometricId}`);
|
|
238
|
+
return res;
|
|
239
|
+
});
|
|
240
|
+
// PATCH /users/:userId/biometrics/:biometricId
|
|
241
|
+
this.patchSessionPublicKey = (partnerId, userId, biometricId, body) => __async(this, null, function* () {
|
|
242
|
+
const res = yield this.baseRequest.patch(`/users/${userId}/biometrics/${biometricId}`, body, {
|
|
243
|
+
headers: {
|
|
244
|
+
[import_consts.PARTNER_ID_HEADER_NAME]: partnerId
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
return res;
|
|
248
|
+
});
|
|
249
|
+
// GET /biometrics/challenge?email&publicKey
|
|
250
|
+
this.getWebChallenge = (auth) => __async(this, null, function* () {
|
|
251
|
+
const res = yield this.baseRequest.get("/biometrics/challenge", {
|
|
252
|
+
params: __spreadValues({}, auth || {})
|
|
253
|
+
});
|
|
254
|
+
return res.data;
|
|
255
|
+
});
|
|
256
|
+
// POST /touch
|
|
257
|
+
this.touchSession = (regenerate) => __async(this, null, function* () {
|
|
258
|
+
const res = yield this.baseRequest.post(`/touch?regenerate=${!!regenerate}`);
|
|
259
|
+
return res.data;
|
|
260
|
+
});
|
|
261
|
+
// GET /session/origin
|
|
262
|
+
this.sessionOrigin = (sessionLookupId) => __async(this, null, function* () {
|
|
263
|
+
const res = yield this.baseRequest.get(`/sessions/${sessionLookupId}/origin`);
|
|
264
|
+
return res.data;
|
|
265
|
+
});
|
|
266
|
+
// POST /biometrics/verify
|
|
267
|
+
this.verifyWebChallenge = (partnerId, body) => __async(this, null, function* () {
|
|
268
|
+
const res = yield this.baseRequest.post(`/biometrics/verify`, body, {
|
|
269
|
+
headers: {
|
|
270
|
+
[import_consts.PARTNER_ID_HEADER_NAME]: partnerId
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
return res;
|
|
274
|
+
});
|
|
275
|
+
// GET /users/:userId/biometrics/challenge
|
|
276
|
+
this.getSessionChallenge = (userId) => __async(this, null, function* () {
|
|
277
|
+
const res = yield this.baseRequest.get(`/users/${userId}/biometrics/challenge`);
|
|
278
|
+
return res;
|
|
279
|
+
});
|
|
280
|
+
// POST /users/:userId/biometrics/verify
|
|
281
|
+
this.verifySessionChallenge = (userId, body) => __async(this, null, function* () {
|
|
282
|
+
const res = yield this.baseRequest.post(`/users/${userId}/biometrics/verify`, body);
|
|
283
|
+
return res;
|
|
284
|
+
});
|
|
285
|
+
// POST /users/:userId/wallets
|
|
286
|
+
this.createWallet = (userId, body) => __async(this, null, function* () {
|
|
287
|
+
const res = yield this.baseRequest.post(`/users/${userId}/wallets`, body);
|
|
288
|
+
return res.data;
|
|
289
|
+
});
|
|
290
|
+
// POST /wallets/pregen
|
|
291
|
+
this.createPregenWallet = (body) => __async(this, null, function* () {
|
|
292
|
+
const res = yield this.baseRequest.post(`/wallets/pregen`, body);
|
|
293
|
+
return res.data;
|
|
294
|
+
});
|
|
295
|
+
this.getPregenWallets = (pregenIds, isPortal = false, userId) => __async(this, null, function* () {
|
|
296
|
+
const res = yield this.baseRequest.get("/wallets/pregen", {
|
|
297
|
+
params: { ids: pregenIds, expand: isPortal, userId }
|
|
298
|
+
});
|
|
299
|
+
return res.data;
|
|
300
|
+
});
|
|
301
|
+
this.claimPregenWallets = (body) => __async(this, null, function* () {
|
|
302
|
+
const res = yield this.baseRequest.post(`/wallets/pregen/claim`, body);
|
|
303
|
+
return res.data;
|
|
304
|
+
});
|
|
305
|
+
// POST /users/:userId/wallets/:walletId/transactions/send
|
|
306
|
+
this.sendTransaction = (userId, walletId, body) => __async(this, null, function* () {
|
|
307
|
+
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/transactions/send`, body);
|
|
308
|
+
return res;
|
|
309
|
+
});
|
|
310
|
+
// functionality changed to only sign transactions and not send them
|
|
311
|
+
// POST /users/:userId/wallets/:walletId/transactions/sign
|
|
312
|
+
this.signTransaction = (userId, walletId, body) => __async(this, null, function* () {
|
|
313
|
+
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/transactions/sign`, body);
|
|
314
|
+
return res;
|
|
315
|
+
});
|
|
316
|
+
// POST /users/:userId/wallets/:walletId/refresh
|
|
317
|
+
this.refreshKeys = (userId, walletId, oldPartnerId, newPartnerId, keyShareProtocolId) => __async(this, null, function* () {
|
|
318
|
+
const body = { oldPartnerId, newPartnerId, keyShareProtocolId };
|
|
319
|
+
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/refresh`, body);
|
|
320
|
+
return res;
|
|
321
|
+
});
|
|
322
|
+
// PATCH /wallets/pregen/:walletId
|
|
323
|
+
this.updatePregenWallet = (walletId, body) => __async(this, null, function* () {
|
|
324
|
+
const res = yield this.baseRequest.patch(`/wallets/pregen/${walletId}`, body);
|
|
325
|
+
return res.data;
|
|
326
|
+
});
|
|
327
|
+
// GET /users/:userId/wallets
|
|
328
|
+
this.getWallets = (userId, includePartnerData) => __async(this, null, function* () {
|
|
329
|
+
const res = yield this.baseRequest.get(
|
|
330
|
+
`/users/${userId}/wallets${includePartnerData ? `?includePartnerData=${encodeURIComponent(includePartnerData)}` : ""}`
|
|
331
|
+
);
|
|
332
|
+
return res;
|
|
333
|
+
});
|
|
334
|
+
// GET /users/:userId/all-wallets
|
|
335
|
+
this.getAllWallets = (userId) => __async(this, null, function* () {
|
|
336
|
+
const res = yield this.baseRequest.get(`/users/${userId}/all-wallets`);
|
|
337
|
+
return res;
|
|
338
|
+
});
|
|
339
|
+
// POST /users/:userId/wallets/set
|
|
340
|
+
this.setCurrentWalletIds = (userId, walletIds, needsWallet = false, sessionLookupId, newDeviceSessionLookupId) => __async(this, null, function* () {
|
|
341
|
+
const res = yield this.baseRequest.post(`/users/${userId}/wallets/set`, {
|
|
342
|
+
walletIds,
|
|
343
|
+
needsWallet,
|
|
344
|
+
sessionLookupId,
|
|
345
|
+
newDeviceSessionLookupId
|
|
346
|
+
});
|
|
347
|
+
return res;
|
|
348
|
+
});
|
|
349
|
+
// POST /login
|
|
350
|
+
this.login = (props) => __async(this, null, function* () {
|
|
351
|
+
const body = props;
|
|
352
|
+
const res = yield this.baseRequest.post("/login", body);
|
|
353
|
+
return res;
|
|
354
|
+
});
|
|
355
|
+
// POST /login
|
|
356
|
+
this.verifyLogin = (verificationCode) => __async(this, null, function* () {
|
|
357
|
+
const body = { verificationCode };
|
|
358
|
+
const res = yield this.baseRequest.post("/login/verify-email", body);
|
|
359
|
+
return res;
|
|
360
|
+
});
|
|
361
|
+
// GET /logout
|
|
362
|
+
this.logout = () => __async(this, null, function* () {
|
|
363
|
+
const res = yield this.baseRequest.get("/logout");
|
|
364
|
+
return res;
|
|
365
|
+
});
|
|
366
|
+
// POST /recovery/verification
|
|
367
|
+
this.recoveryVerification = (email, verificationCode) => __async(this, null, function* () {
|
|
368
|
+
const body = { email, verificationCode };
|
|
369
|
+
const res = yield this.baseRequest.post("/recovery/verification", body);
|
|
370
|
+
return res;
|
|
371
|
+
});
|
|
372
|
+
// POST /recovery
|
|
373
|
+
this.recoveryInit = (email) => __async(this, null, function* () {
|
|
374
|
+
const body = { email };
|
|
375
|
+
const res = yield this.baseRequest.post("/recovery", body);
|
|
376
|
+
return res;
|
|
377
|
+
});
|
|
378
|
+
this.preSignMessage = (userId, walletId, message, scheme, cosmosSignDoc, protocolId) => __async(this, null, function* () {
|
|
379
|
+
const body = { message, scheme, cosmosSignDoc, protocolId };
|
|
380
|
+
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/messages/sign`, body);
|
|
381
|
+
return res.data;
|
|
382
|
+
});
|
|
383
|
+
//DELETE /users/:userId
|
|
384
|
+
this.deleteSelf = (userId) => __async(this, null, function* () {
|
|
385
|
+
const res = yield this.baseRequest.delete(`/users/${userId}`);
|
|
386
|
+
return res;
|
|
387
|
+
});
|
|
388
|
+
// GET /users/:userId/wallets/:walletId/capsule-share
|
|
389
|
+
this.getParaShare = (userId, walletId) => __async(this, null, function* () {
|
|
390
|
+
const res = yield this.baseRequest.get(`/users/${userId}/wallets/${walletId}/capsule-share`);
|
|
391
|
+
return res.data.share;
|
|
392
|
+
});
|
|
393
|
+
// GET /users/:userId/wallets/:walletId/download-backup-kit
|
|
394
|
+
this.getBackupKit = (userId, walletId) => __async(this, null, function* () {
|
|
395
|
+
const res = yield this.baseRequest.get(`/users/${userId}/wallets/${walletId}/download-backup-kit`, {
|
|
396
|
+
responseType: "blob"
|
|
397
|
+
});
|
|
398
|
+
return res;
|
|
399
|
+
});
|
|
400
|
+
// PATCH /users/:userId/biometrics/:biometricId
|
|
401
|
+
this.patchSessionPassword = (partnerId, userId, passwordId, body) => __async(this, null, function* () {
|
|
402
|
+
const res = yield this.baseRequest.patch(`/users/${userId}/passwords/${passwordId}`, body, {
|
|
403
|
+
headers: {
|
|
404
|
+
[import_consts.PARTNER_ID_HEADER_NAME]: partnerId
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
return res;
|
|
408
|
+
});
|
|
409
|
+
// GET /users/:userId/wallets/:walletId/balance
|
|
410
|
+
this.getWalletBalance = (_0) => __async(this, [_0], function* ({ walletId, rpcUrl }) {
|
|
411
|
+
const res = yield this.baseRequest.get(`/wallets/${walletId}/balance`, {
|
|
412
|
+
params: {
|
|
413
|
+
rpcUrl
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
return res.data;
|
|
417
|
+
});
|
|
418
|
+
this.issueJwt = (..._0) => __async(this, [..._0], function* ({ keyIndex = 0 } = {}) {
|
|
419
|
+
const res = yield this.baseRequest.post(`/auth/jwt`, { keyIndex });
|
|
420
|
+
return res.data;
|
|
421
|
+
});
|
|
422
|
+
this.trackError = (opts) => __async(this, null, function* () {
|
|
423
|
+
yield this.baseRequest.post("/errors/sdk", opts);
|
|
424
|
+
});
|
|
425
|
+
this.trackReactSdkAnalytics = (opts) => __async(this, null, function* () {
|
|
426
|
+
yield this.baseRequest.post("/partners/analytics/react-sdk", opts);
|
|
427
|
+
});
|
|
428
|
+
const headers = __spreadValues(__spreadValues({}, apiKey && { [import_consts.API_KEY_HEADER_NAME]: apiKey }), partnerId && { [import_consts.PARTNER_ID_HEADER_NAME]: partnerId });
|
|
429
|
+
const axiosConfig = {
|
|
430
|
+
baseURL: userManagementHost,
|
|
431
|
+
withCredentials: true,
|
|
432
|
+
headers
|
|
433
|
+
};
|
|
434
|
+
if (retrieveSessionCookie) {
|
|
435
|
+
const defaultTransformRequest = Array.isArray(import_axios.default.defaults.transformRequest) ? import_axios.default.defaults.transformRequest : [import_axios.default.defaults.transformRequest];
|
|
436
|
+
axiosConfig.transformRequest = [
|
|
437
|
+
function(data, headers2) {
|
|
438
|
+
const currentSessionCookie = retrieveSessionCookie();
|
|
439
|
+
if (currentSessionCookie) {
|
|
440
|
+
headers2[import_consts.SESSION_COOKIE_HEADER_NAME] = currentSessionCookie;
|
|
441
|
+
}
|
|
442
|
+
if (version) {
|
|
443
|
+
headers2[import_consts.VERSION_HEADER_NAME] = version;
|
|
444
|
+
}
|
|
445
|
+
return data;
|
|
446
|
+
},
|
|
447
|
+
...defaultTransformRequest
|
|
448
|
+
];
|
|
449
|
+
}
|
|
450
|
+
if (persistSessionCookie) {
|
|
451
|
+
const defaultTransformResponse = Array.isArray(import_axios.default.defaults.transformResponse) ? import_axios.default.defaults.transformResponse : [import_axios.default.defaults.transformResponse];
|
|
452
|
+
axiosConfig.transformResponse = [
|
|
453
|
+
...defaultTransformResponse,
|
|
454
|
+
function(data, headers2, _status) {
|
|
455
|
+
if (headers2 == null ? void 0 : headers2[import_consts.SESSION_COOKIE_HEADER_NAME]) {
|
|
456
|
+
persistSessionCookie(headers2[import_consts.SESSION_COOKIE_HEADER_NAME]);
|
|
457
|
+
}
|
|
458
|
+
return data;
|
|
459
|
+
}
|
|
460
|
+
];
|
|
461
|
+
}
|
|
462
|
+
this.baseRequest = import_axios.default.create(axiosConfig);
|
|
463
|
+
if (opts == null ? void 0 : opts.useFetchAdapter) {
|
|
464
|
+
import_axios.default.defaults.adapter = function(config) {
|
|
465
|
+
return fetch(config.baseURL + config.url.substring(1), {
|
|
466
|
+
method: config.method,
|
|
467
|
+
headers: config.headers,
|
|
468
|
+
body: config.data,
|
|
469
|
+
credentials: config.withCredentials ? "include" : void 0
|
|
470
|
+
}).then(
|
|
471
|
+
(response) => response.text().then((text) => ({
|
|
472
|
+
data: text,
|
|
473
|
+
status: response.status,
|
|
474
|
+
statusText: response.statusText,
|
|
475
|
+
headers: response.headers,
|
|
476
|
+
config,
|
|
477
|
+
request: fetch
|
|
478
|
+
}))
|
|
479
|
+
).catch(function(reason) {
|
|
480
|
+
throw reason;
|
|
481
|
+
});
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
this.baseRequest.interceptors.response.use(handleResponseSuccess, handleResponseError);
|
|
485
|
+
}
|
|
486
|
+
// DEPRECATED: use uploadUserKeyShares instead
|
|
487
|
+
// POST /users/:userId/wallets/:walletId/key-shares
|
|
488
|
+
uploadKeyshares(userId, walletId, encryptedKeyshares) {
|
|
489
|
+
return __async(this, null, function* () {
|
|
490
|
+
const body = { keyShares: encryptedKeyshares };
|
|
491
|
+
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/key-shares`, body);
|
|
492
|
+
return res;
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
// POST /users/:userId/key-shares
|
|
496
|
+
uploadUserKeyShares(userId, encryptedKeyshares) {
|
|
497
|
+
return __async(this, null, function* () {
|
|
498
|
+
const body = { keyShares: encryptedKeyshares };
|
|
499
|
+
const res = yield this.baseRequest.post(`/users/${userId}/key-shares`, body);
|
|
500
|
+
return res;
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
// GET /users/:userId/wallets/:walletId/key-shares
|
|
504
|
+
getKeyshare(userId, walletId, type, encryptor) {
|
|
505
|
+
return __async(this, null, function* () {
|
|
506
|
+
const res = yield this.baseRequest.get(
|
|
507
|
+
`/users/${userId}/wallets/${walletId}/key-shares?type=${type}${encryptor ? `&encryptor=${encryptor}` : ""}`
|
|
508
|
+
);
|
|
509
|
+
return res;
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
// GET /users/:userId/biometrics/key-shares
|
|
513
|
+
getBiometricKeyshares(userId, biometricPublicKey, getAll) {
|
|
514
|
+
return __async(this, null, function* () {
|
|
515
|
+
const res = yield this.baseRequest.get(
|
|
516
|
+
`/users/${userId}/biometrics/key-shares?publicKey=${biometricPublicKey}&all=${!!getAll}`
|
|
517
|
+
);
|
|
518
|
+
return res;
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
// GET /users/:userId/key-shares
|
|
522
|
+
getPasswordKeyshares(userId, passwordId, getAll) {
|
|
523
|
+
return __async(this, null, function* () {
|
|
524
|
+
const res = yield this.baseRequest.get(
|
|
525
|
+
`/users/${userId}/passwords/key-shares?passwordId=${passwordId}&all=${!!getAll}`
|
|
526
|
+
);
|
|
527
|
+
return res;
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
// POST '/users/:userId/temporary-shares',
|
|
531
|
+
uploadTransmissionKeyshares(userId, shares) {
|
|
532
|
+
return __async(this, null, function* () {
|
|
533
|
+
const body = { shares };
|
|
534
|
+
const res = yield this.baseRequest.post(`/users/${userId}/temporary-shares`, body);
|
|
535
|
+
return res;
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
// GET /users/:userId/temporary-shares returns { temporaryShares: { userId: string, walletId: string, encryptedShare: string, encryptedKey?: string }[] }
|
|
539
|
+
getTransmissionKeyshares(userId, sessionLookupId) {
|
|
540
|
+
return __async(this, null, function* () {
|
|
541
|
+
const res = yield this.baseRequest.get(`/users/${userId}/temporary-shares?sessionLookupId=${sessionLookupId}`);
|
|
542
|
+
return res;
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
// POST '/users/:userId/resend-verification-code
|
|
546
|
+
resendVerificationCode(_e) {
|
|
547
|
+
return __async(this, null, function* () {
|
|
548
|
+
var _f = _e, { userId } = _f, rest = __objRest(_f, ["userId"]);
|
|
549
|
+
const res = yield this.baseRequest.post(`/users/${userId}/resend-verification-code`, rest);
|
|
550
|
+
return res;
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
// POST '/users/:userId/resend-verification-code-by-phone
|
|
554
|
+
resendVerificationCodeByPhone(_g) {
|
|
555
|
+
return __async(this, null, function* () {
|
|
556
|
+
var _h = _g, { userId } = _h, rest = __objRest(_h, ["userId"]);
|
|
557
|
+
const res = yield this.baseRequest.post(`/users/${userId}/resend-verification-code-by-phone`, rest);
|
|
558
|
+
return res;
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
// POST recovery/cancel
|
|
562
|
+
cancelRecoveryAttempt(email) {
|
|
563
|
+
return __async(this, null, function* () {
|
|
564
|
+
const res = yield this.baseRequest.post(`/recovery/cancel`, { email });
|
|
565
|
+
return res;
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
// GET '/2fa/users/:userId/check-status'
|
|
569
|
+
check2FAStatus(userId) {
|
|
570
|
+
return __async(this, null, function* () {
|
|
571
|
+
const res = yield this.baseRequest.get(`/2fa/users/${userId}/check-status`);
|
|
572
|
+
return res;
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
// POST '/2fa/users/:userId/enable'
|
|
576
|
+
enable2FA(userId, verificationCode) {
|
|
577
|
+
return __async(this, null, function* () {
|
|
578
|
+
const res = yield this.baseRequest.post(`/2fa/users/${userId}/enable`, { verificationCode });
|
|
579
|
+
return res;
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
setup2FA(userId) {
|
|
583
|
+
return __async(this, null, function* () {
|
|
584
|
+
const res = yield this.baseRequest.post(`/2fa/users/${userId}/setup`);
|
|
585
|
+
return res.data;
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
// POST /recovery/init
|
|
589
|
+
initializeRecovery(email) {
|
|
590
|
+
return __async(this, null, function* () {
|
|
591
|
+
const res = yield this.baseRequest.post(`/recovery/init`, { email });
|
|
592
|
+
return res;
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
// POST /auth/farcaster/init
|
|
596
|
+
initializeFarcasterLogin() {
|
|
597
|
+
return __async(this, arguments, function* ({ appScheme } = {}) {
|
|
598
|
+
const res = yield this.baseRequest.post(`/auth/farcaster/init`, { appScheme });
|
|
599
|
+
return res.data;
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
getFarcasterAuthStatus() {
|
|
603
|
+
return __async(this, null, function* () {
|
|
604
|
+
const res = yield this.baseRequest.post(`/auth/farcaster/status/v2`);
|
|
605
|
+
return res.data;
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
// POST /recovery/init
|
|
609
|
+
initializeRecoveryForPhone(phone, countryCode) {
|
|
610
|
+
return __async(this, null, function* () {
|
|
611
|
+
const res = yield this.baseRequest.post(`/recovery/init`, { phone, countryCode });
|
|
612
|
+
return res;
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
// POST /recovery/users/:userId/wallets/:walletId/finish
|
|
616
|
+
finalizeRecovery(userId, walletId) {
|
|
617
|
+
return __async(this, null, function* () {
|
|
618
|
+
const res = yield this.baseRequest.post(`/recovery/users/${userId}/wallets/${walletId}/finish`);
|
|
619
|
+
return res;
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
// GET /recovery/users/:userId/wallets/:walletId/key-shares
|
|
623
|
+
recoverUserShares(userId, walletId) {
|
|
624
|
+
return __async(this, null, function* () {
|
|
625
|
+
const res = yield this.baseRequest.get(`/recovery/users/${userId}/wallets/${walletId}/key-shares?type=USER&encryptor=RECOVERY`);
|
|
626
|
+
return res;
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
// POST /recovery/verify-email
|
|
630
|
+
verifyEmailForRecovery(email, verificationCode) {
|
|
631
|
+
return __async(this, null, function* () {
|
|
632
|
+
const body = { email, verificationCode };
|
|
633
|
+
const res = yield this.baseRequest.post(`/recovery/verify-email`, body);
|
|
634
|
+
return res;
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
// POST /recovery/verify-identifier
|
|
638
|
+
verifyPhoneForRecovery(phone, countryCode, verificationCode) {
|
|
639
|
+
return __async(this, null, function* () {
|
|
640
|
+
const body = { phone, countryCode, verificationCode };
|
|
641
|
+
const res = yield this.baseRequest.post(`/recovery/verify-identifier`, body);
|
|
642
|
+
return res;
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
verify2FA(auth, verificationCode) {
|
|
646
|
+
return __async(this, null, function* () {
|
|
647
|
+
const body = __spreadProps(__spreadValues({}, auth), { verificationCode });
|
|
648
|
+
const res = yield this.baseRequest.post("/2fa/verify", body);
|
|
649
|
+
return res.data;
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
// POST /2fa/phone/verify
|
|
653
|
+
/**
|
|
654
|
+
* @deprecated
|
|
655
|
+
*/
|
|
656
|
+
verify2FAForPhone(phone, verificationCode) {
|
|
657
|
+
return __async(this, null, function* () {
|
|
658
|
+
const body = { phone, verificationCode };
|
|
659
|
+
const res = yield this.baseRequest.post("/2fa/verify", body);
|
|
660
|
+
return res;
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
tempTrasmissionInit(message, userId) {
|
|
664
|
+
return __async(this, null, function* () {
|
|
665
|
+
const body = { message, userId };
|
|
666
|
+
const res = yield this.baseRequest.post("/temporary-transmissions", body);
|
|
667
|
+
return res;
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
tempTrasmission(id) {
|
|
671
|
+
return __async(this, null, function* () {
|
|
672
|
+
const res = yield this.baseRequest.get(`/temporary-transmissions/${id}`);
|
|
673
|
+
return res;
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
getPartner(partnerId) {
|
|
677
|
+
return __async(this, null, function* () {
|
|
678
|
+
const res = yield this.baseRequest.get(`/partners/${partnerId}`);
|
|
679
|
+
return res;
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
acceptScopes(userId, walletId, body) {
|
|
683
|
+
return __async(this, null, function* () {
|
|
684
|
+
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/scopes/accept`, body);
|
|
685
|
+
return res;
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
getPendingTransaction(userId, pendingTransactionId) {
|
|
689
|
+
return __async(this, null, function* () {
|
|
690
|
+
const res = yield this.baseRequest.get(`/users/${userId}/pending-transactions/${pendingTransactionId}`);
|
|
691
|
+
return res;
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
acceptPendingTransaction(userId, pendingTransactionId) {
|
|
695
|
+
return __async(this, null, function* () {
|
|
696
|
+
const res = yield this.baseRequest.post(`/users/${userId}/pending-transactions/${pendingTransactionId}/accept`);
|
|
697
|
+
return res;
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
getOnRampConfig() {
|
|
701
|
+
return __async(this, null, function* () {
|
|
702
|
+
const res = yield this.baseRequest.get(`/on-ramp-config`);
|
|
703
|
+
return res.data;
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
createOnRampPurchase(_i) {
|
|
707
|
+
return __async(this, null, function* () {
|
|
708
|
+
var _j = _i, {
|
|
709
|
+
userId,
|
|
710
|
+
params
|
|
711
|
+
} = _j, walletParams = __objRest(_j, [
|
|
712
|
+
"userId",
|
|
713
|
+
"params"
|
|
714
|
+
]);
|
|
715
|
+
const [key, identifier] = (0, import_utils.extractWalletRef)(walletParams);
|
|
716
|
+
const walletString = key === "walletId" ? `wallets/${identifier}` : `external-wallets/${identifier}`;
|
|
717
|
+
const res = yield this.baseRequest.post(`/users/${userId}/${walletString}/purchases`, params);
|
|
718
|
+
return res.data;
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
updateOnRampPurchase(_k) {
|
|
722
|
+
return __async(this, null, function* () {
|
|
723
|
+
var _l = _k, {
|
|
724
|
+
userId,
|
|
725
|
+
purchaseId,
|
|
726
|
+
updates
|
|
727
|
+
} = _l, params = __objRest(_l, [
|
|
728
|
+
"userId",
|
|
729
|
+
"purchaseId",
|
|
730
|
+
"updates"
|
|
731
|
+
]);
|
|
732
|
+
const [key, identifier] = (0, import_utils.extractWalletRef)(params);
|
|
733
|
+
const walletString = key === "walletId" ? `wallets/${identifier}` : `external-wallets/${identifier}`;
|
|
734
|
+
const res = yield this.baseRequest.patch(
|
|
735
|
+
`/users/${userId}/${walletString}/purchases/${purchaseId}`,
|
|
736
|
+
updates
|
|
737
|
+
);
|
|
738
|
+
return res.data;
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
getOnRampPurchase(_m) {
|
|
742
|
+
return __async(this, null, function* () {
|
|
743
|
+
var _n = _m, {
|
|
744
|
+
userId,
|
|
745
|
+
purchaseId
|
|
746
|
+
} = _n, params = __objRest(_n, [
|
|
747
|
+
"userId",
|
|
748
|
+
"purchaseId"
|
|
749
|
+
]);
|
|
750
|
+
const [key, identifier] = (0, import_utils.extractWalletRef)(params);
|
|
751
|
+
const walletString = key === "walletId" ? `wallets/${identifier}` : `external-wallets/${identifier}`;
|
|
752
|
+
const res = yield this.baseRequest.get(`/users/${userId}/${walletString}/purchases/${purchaseId}`);
|
|
753
|
+
return res;
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
signMoonPayUrl(_0, _1) {
|
|
757
|
+
return __async(this, arguments, function* (userId, {
|
|
758
|
+
url,
|
|
759
|
+
type,
|
|
760
|
+
cosmosPrefix,
|
|
761
|
+
testMode,
|
|
762
|
+
walletId,
|
|
763
|
+
externalWalletAddress
|
|
764
|
+
}) {
|
|
765
|
+
const walletString = walletId ? `wallets/${walletId}` : `external-wallets/${externalWalletAddress}`;
|
|
766
|
+
const res = yield this.baseRequest.post(`/users/${userId}/${walletString}/moonpay-sign`, {
|
|
767
|
+
url,
|
|
768
|
+
type,
|
|
769
|
+
cosmosPrefix,
|
|
770
|
+
testMode
|
|
771
|
+
});
|
|
772
|
+
return res;
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
generateOffRampTx(_0, _1) {
|
|
776
|
+
return __async(this, arguments, function* (userId, {
|
|
777
|
+
provider,
|
|
778
|
+
chainId,
|
|
779
|
+
contractAddress,
|
|
780
|
+
testMode,
|
|
781
|
+
walletId,
|
|
782
|
+
walletType,
|
|
783
|
+
destinationAddress,
|
|
784
|
+
sourceAddress,
|
|
785
|
+
assetQuantity
|
|
786
|
+
}) {
|
|
787
|
+
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/offramp-generate`, {
|
|
788
|
+
provider,
|
|
789
|
+
testMode,
|
|
790
|
+
chainId,
|
|
791
|
+
contractAddress,
|
|
792
|
+
walletId,
|
|
793
|
+
walletType,
|
|
794
|
+
destinationAddress,
|
|
795
|
+
sourceAddress,
|
|
796
|
+
assetQuantity
|
|
797
|
+
});
|
|
798
|
+
return res.data;
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
sendOffRampTx(_0, _1) {
|
|
802
|
+
return __async(this, arguments, function* (userId, {
|
|
803
|
+
tx,
|
|
804
|
+
signature,
|
|
805
|
+
sourceAddress,
|
|
806
|
+
network,
|
|
807
|
+
walletId,
|
|
808
|
+
walletType
|
|
809
|
+
}) {
|
|
810
|
+
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/offramp-send`, {
|
|
811
|
+
tx,
|
|
812
|
+
signature,
|
|
813
|
+
sourceAddress,
|
|
814
|
+
network,
|
|
815
|
+
walletType
|
|
816
|
+
});
|
|
817
|
+
return res.data;
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
distributeParaShare(_o) {
|
|
821
|
+
return __async(this, null, function* () {
|
|
822
|
+
var _p = _o, {
|
|
823
|
+
userId,
|
|
824
|
+
walletId
|
|
825
|
+
} = _p, rest = __objRest(_p, [
|
|
826
|
+
"userId",
|
|
827
|
+
"walletId"
|
|
828
|
+
]);
|
|
829
|
+
const body = rest;
|
|
830
|
+
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/capsule-share/distribute`, body);
|
|
831
|
+
return res;
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
keepSessionAlive(userId) {
|
|
835
|
+
return __async(this, null, function* () {
|
|
836
|
+
const res = yield this.baseRequest.post(`/users/${userId}/session/keep-alive`);
|
|
837
|
+
return res.data;
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
persistRecoveryPublicKeys(userId, publicKeys) {
|
|
841
|
+
return __async(this, null, function* () {
|
|
842
|
+
const res = yield this.baseRequest.post(`/users/${userId}/recovery-public-keys`, { publicKeys });
|
|
843
|
+
return res.data;
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
getRecoveryPublicKeys(userId) {
|
|
847
|
+
return __async(this, null, function* () {
|
|
848
|
+
const res = yield this.baseRequest.get(`/users/${userId}/recovery-public-keys`);
|
|
849
|
+
return res.data;
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
uploadEncryptedWalletPrivateKey(userId, encryptedWalletPrivateKey, encryptionKeyHash, biometricPublicKey, passwordId) {
|
|
853
|
+
return __async(this, null, function* () {
|
|
854
|
+
const body = { encryptedWalletPrivateKey, encryptionKeyHash, biometricPublicKey, passwordId };
|
|
855
|
+
const res = yield this.baseRequest.post(`/users/${userId}/encrypted-wallet-private-keys`, body);
|
|
856
|
+
return res.data;
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
getEncryptedWalletPrivateKeys(userId, encryptionKeyHash) {
|
|
860
|
+
return __async(this, null, function* () {
|
|
861
|
+
const res = yield this.baseRequest.get(`/users/${userId}/encrypted-wallet-private-keys/${encryptionKeyHash}`);
|
|
862
|
+
return res.data;
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
getConversionRate(chainId, symbol, currency) {
|
|
866
|
+
return __async(this, null, function* () {
|
|
867
|
+
const params = { symbol, currency };
|
|
868
|
+
const res = yield this.baseRequest.get(`/chains/${chainId}/conversion-rate`, { params });
|
|
869
|
+
return res.data;
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
getGasEstimate(chainId, totalGasPrice) {
|
|
873
|
+
return __async(this, null, function* () {
|
|
874
|
+
const params = { totalGasPrice };
|
|
875
|
+
const res = yield this.baseRequest.get(`/chains/${chainId}/gas-estimate`, { params });
|
|
876
|
+
return res.data;
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
getGasOracle(chainId) {
|
|
880
|
+
return __async(this, null, function* () {
|
|
881
|
+
const res = yield this.baseRequest.get(`/chains/${chainId}/gas-oracle`);
|
|
882
|
+
return res.data;
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
// GET /users/:userId/wallets/:walletId/refresh-done
|
|
886
|
+
isRefreshDone(userId, walletId, partnerId, protocolId) {
|
|
887
|
+
return __async(this, null, function* () {
|
|
888
|
+
const query = new URLSearchParams(__spreadValues(__spreadValues({}, partnerId ? { partnerId } : {}), protocolId ? { protocolId } : {})).toString();
|
|
889
|
+
const res = yield this.baseRequest.get(`/users/${userId}/wallets/${walletId}/refresh-done?${query}`);
|
|
890
|
+
return res.data;
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
deletePendingTransaction(userId, pendingTransactionId) {
|
|
894
|
+
return __async(this, null, function* () {
|
|
895
|
+
const res = yield this.baseRequest.delete(`/users/${userId}/pending-transactions/${pendingTransactionId}`);
|
|
896
|
+
return res.data;
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
// POST /users/:userId/passwords/key
|
|
900
|
+
addSessionPasswordPublicKey(userId, body) {
|
|
901
|
+
return __async(this, null, function* () {
|
|
902
|
+
const res = yield this.baseRequest.post(`/users/${userId}/passwords/key`, body);
|
|
903
|
+
return res;
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
getSupportedAuthMethods(auth) {
|
|
907
|
+
return __async(this, null, function* () {
|
|
908
|
+
const res = yield this.baseRequest.get("/users/supported-auth-methods", {
|
|
909
|
+
params: __spreadValues({}, auth)
|
|
910
|
+
});
|
|
911
|
+
return res.data;
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
getPasswords(auth) {
|
|
915
|
+
return __async(this, null, function* () {
|
|
916
|
+
const res = yield this.baseRequest.get("/users/passwords", {
|
|
917
|
+
params: __spreadValues({}, auth)
|
|
918
|
+
});
|
|
919
|
+
return res.data.passwords;
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
// POST /passwords/verify
|
|
923
|
+
verifyPasswordChallenge(partnerId, body) {
|
|
924
|
+
return __async(this, null, function* () {
|
|
925
|
+
const res = yield this.baseRequest.post(`/passwords/verify`, body, {
|
|
926
|
+
headers: {
|
|
927
|
+
[import_consts.PARTNER_ID_HEADER_NAME]: partnerId
|
|
928
|
+
}
|
|
929
|
+
});
|
|
930
|
+
return res;
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
getEncryptedWalletPrivateKey(passwordId) {
|
|
934
|
+
return __async(this, null, function* () {
|
|
935
|
+
const query = new URLSearchParams({ passwordId }).toString();
|
|
936
|
+
const res = yield this.baseRequest.get(`/encrypted-wallet-private-keys?${query}`);
|
|
937
|
+
return res;
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
// GET /users/:userId
|
|
941
|
+
getUser(userId) {
|
|
942
|
+
return __async(this, null, function* () {
|
|
943
|
+
const res = yield this.baseRequest.get(`/users/${userId}`);
|
|
944
|
+
return res.data;
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
// GET /users/:userId/accounts
|
|
948
|
+
getAccountMetadata(userId, partnerId) {
|
|
949
|
+
return __async(this, null, function* () {
|
|
950
|
+
const res = yield this.baseRequest.get(`/users/${userId}/oauth/accounts`, {
|
|
951
|
+
params: { partnerId }
|
|
952
|
+
});
|
|
953
|
+
return {
|
|
954
|
+
accountMetadata: (0, import_utils.fromAccountMetadata)(res.data.accountMetadata)
|
|
955
|
+
};
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
var client_default = Client;
|
|
960
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
961
|
+
0 && (module.exports = {
|
|
962
|
+
handleResponseError,
|
|
963
|
+
handleResponseSuccess
|
|
964
|
+
});
|