@internxt/sdk 1.15.14 → 1.16.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.
Files changed (38) hide show
  1. package/dist/auth/index.js +180 -262
  2. package/dist/auth/types.js +2 -22
  3. package/dist/drive/backups/index.js +34 -32
  4. package/dist/drive/payments/index.js +96 -149
  5. package/dist/drive/payments/object-storage.js +34 -36
  6. package/dist/drive/referrals/index.js +19 -17
  7. package/dist/drive/share/index.js +168 -235
  8. package/dist/drive/storage/index.js +213 -302
  9. package/dist/drive/trash/index.js +40 -84
  10. package/dist/drive/users/index.js +95 -140
  11. package/dist/mail/index.d.ts +124 -2
  12. package/dist/mail/index.js +170 -16
  13. package/dist/mail/types.d.ts +50 -0
  14. package/dist/mail/types.js +6 -0
  15. package/dist/meet/index.js +31 -99
  16. package/dist/misc/location/index.js +10 -50
  17. package/dist/network/download.js +38 -107
  18. package/dist/network/errors/codes.js +8 -24
  19. package/dist/network/errors/context.js +9 -26
  20. package/dist/network/errors/download.js +6 -24
  21. package/dist/network/errors/upload.js +21 -48
  22. package/dist/network/index.js +120 -277
  23. package/dist/network/types.js +3 -4
  24. package/dist/network/upload.js +63 -133
  25. package/dist/payments/checkout.js +57 -69
  26. package/dist/send/send.js +17 -27
  27. package/dist/shared/headers/index.js +56 -42
  28. package/dist/shared/http/client.js +95 -207
  29. package/dist/shared/http/retryWithBackoff.js +36 -110
  30. package/dist/shared/types/errors.js +37 -51
  31. package/dist/workspaces/index.js +224 -264
  32. package/package.json +14 -15
  33. package/dist/mail/api.d.ts +0 -126
  34. package/dist/mail/api.js +0 -288
  35. package/dist/mail/crypto.d.ts +0 -66
  36. package/dist/mail/crypto.js +0 -156
  37. package/dist/mail/mail.d.ts +0 -162
  38. package/dist/mail/mail.js +0 -382
@@ -13,69 +13,37 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
13
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- };
25
- var __generator = (this && this.__generator) || function (thisArg, body) {
26
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
27
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
- function verb(n) { return function (v) { return step([n, v]); }; }
29
- function step(op) {
30
- if (f) throw new TypeError("Generator is already executing.");
31
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
32
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
33
- if (y = 0, t) op = [op[0] & 2, t.value];
34
- switch (op[0]) {
35
- case 0: case 1: t = op; break;
36
- case 4: _.label++; return { value: op[1], done: false };
37
- case 5: _.label++; y = op[1]; op = [0]; continue;
38
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
- default:
40
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
- if (t[2]) _.ops.pop();
45
- _.trys.pop(); continue;
46
- }
47
- op = body.call(thisArg, _);
48
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
- }
51
- };
52
16
  Object.defineProperty(exports, "__esModule", { value: true });
53
17
  exports.Auth = void 0;
54
- var headers_1 = require("../shared/headers");
55
- var client_1 = require("../shared/http/client");
18
+ const headers_1 = require("../shared/headers");
19
+ const client_1 = require("../shared/http/client");
56
20
  __exportStar(require("./types"), exports);
57
- var Auth = /** @class */ (function () {
58
- function Auth(apiUrl, appDetails, apiSecurity) {
59
- this.client = client_1.HttpClient.create(apiUrl, apiSecurity === null || apiSecurity === void 0 ? void 0 : apiSecurity.unauthorizedCallback, apiSecurity === null || apiSecurity === void 0 ? void 0 : apiSecurity.retryOptions);
21
+ class Auth {
22
+ client;
23
+ appDetails;
24
+ apiSecurity;
25
+ apiUrl;
26
+ static client(apiUrl, appDetails, apiSecurity) {
27
+ return new Auth(apiUrl, appDetails, apiSecurity);
28
+ }
29
+ constructor(apiUrl, appDetails, apiSecurity) {
30
+ this.client = client_1.HttpClient.create(apiUrl, apiSecurity?.unauthorizedCallback, apiSecurity?.retryOptions);
60
31
  this.appDetails = appDetails;
61
32
  this.apiSecurity = apiSecurity;
62
33
  this.apiUrl = apiUrl;
63
34
  }
64
- Auth.client = function (apiUrl, appDetails, apiSecurity) {
65
- return new Auth(apiUrl, appDetails, apiSecurity);
66
- };
67
35
  /**
68
36
  * Runs the first phase (out of 2) of opaque registation of a new user
69
37
  * @param email - The user email.
70
38
  * @param registrationRequest - The opaque registration request.
71
39
  * @returns The opaque sign up response.
72
40
  */
73
- Auth.prototype.registerOpaqueStart = function (email, registrationRequest) {
41
+ registerOpaqueStart(email, registrationRequest) {
74
42
  return this.client.post('/register-opaque/start', {
75
- email: email,
76
- registrationRequest: registrationRequest,
43
+ email,
44
+ registrationRequest,
77
45
  }, this.basicHeaders());
78
- };
46
+ }
79
47
  /**
80
48
  * Runs the second phase (out of 2) of opaque registation of a new user
81
49
  * @param registrationRecord - The opaque registration record.
@@ -83,12 +51,12 @@ var Auth = /** @class */ (function () {
83
51
  * @param startLoginRequest - The opaque start login request.
84
52
  * @returns The opaque login response.
85
53
  */
86
- Auth.prototype.registerOpaqueFinish = function (registrationRecord, registerDetails, startLoginRequest) {
54
+ registerOpaqueFinish(registrationRecord, registerDetails, startLoginRequest) {
87
55
  return this.client.post('/register-opaque/finish', {
88
56
  name: registerDetails.name,
89
57
  lastname: registerDetails.lastname,
90
58
  email: registerDetails.email,
91
- registrationRecord: registrationRecord,
59
+ registrationRecord,
92
60
  keys: {
93
61
  ecc: {
94
62
  publicKey: registerDetails.keys.ecc.publicKey,
@@ -99,14 +67,14 @@ var Auth = /** @class */ (function () {
99
67
  privateKey: registerDetails.keys.kyber.privateKey,
100
68
  },
101
69
  },
102
- startLoginRequest: startLoginRequest,
70
+ startLoginRequest,
103
71
  }, this.basicHeaders());
104
- };
72
+ }
105
73
  /**
106
74
  * Tries to register a new user
107
75
  * @param registerDetails
108
76
  */
109
- Auth.prototype.register = function (registerDetails) {
77
+ register(registerDetails) {
110
78
  return this.client.post('/users', {
111
79
  name: registerDetails.name,
112
80
  captcha: registerDetails.captcha,
@@ -134,13 +102,13 @@ var Auth = /** @class */ (function () {
134
102
  referral: registerDetails.referral,
135
103
  referrer: registerDetails.referrer,
136
104
  }, this.basicHeaders());
137
- };
105
+ }
138
106
  /**
139
107
  * Tries to register a new user without sending keys
140
108
  * @param registerDetails
141
109
  */
142
- Auth.prototype.registerWithoutKeys = function (registerDetails) {
143
- var body = {
110
+ registerWithoutKeys(registerDetails) {
111
+ const body = {
144
112
  name: registerDetails.name,
145
113
  captcha: registerDetails.captcha,
146
114
  lastname: registerDetails.lastname,
@@ -152,13 +120,13 @@ var Auth = /** @class */ (function () {
152
120
  referrer: registerDetails.referrer,
153
121
  };
154
122
  return this.client.post('/users', body, this.basicHeaders());
155
- };
123
+ }
156
124
  /**
157
125
  * Registers a precreated user
158
126
  * @param registerDetails
159
127
  * @returns {Promise<RegisterPreCreatedUserResponse>} Returns sign in token, user data and uuid.
160
128
  */
161
- Auth.prototype.registerPreCreatedUser = function (registerDetails) {
129
+ registerPreCreatedUser(registerDetails) {
162
130
  return this.client.post('users/pre-created-users/register', {
163
131
  name: registerDetails.name,
164
132
  captcha: registerDetails.captcha,
@@ -187,13 +155,13 @@ var Auth = /** @class */ (function () {
187
155
  referrer: registerDetails.referrer,
188
156
  invitationId: registerDetails.invitationId,
189
157
  }, this.basicHeaders());
190
- };
158
+ }
191
159
  /**
192
160
  * Registers a precreated user without sending keys
193
161
  * @param registerDetails
194
162
  * @returns {Promise<RegisterPreCreatedUserResponse>} Returns sign in token, user data and uuid.
195
163
  */
196
- Auth.prototype.registerPreCreatedUserWithoutKeys = function (registerDetails) {
164
+ registerPreCreatedUserWithoutKeys(registerDetails) {
197
165
  return this.client.post('users/pre-created-users/register', {
198
166
  name: registerDetails.name,
199
167
  captcha: registerDetails.captcha,
@@ -206,27 +174,27 @@ var Auth = /** @class */ (function () {
206
174
  referrer: registerDetails.referrer,
207
175
  invitationId: registerDetails.invitationId,
208
176
  }, this.basicHeaders());
209
- };
177
+ }
210
178
  /**
211
179
  * Requests account unblock email
212
180
  *
213
181
  * @param {string} email - The email address associated with the account.
214
182
  * @returns {Promise<void>} - Resolves when the email is sent.
215
183
  */
216
- Auth.prototype.requestUnblockAccount = function (email) {
184
+ requestUnblockAccount(email) {
217
185
  return this.client.post('users/unblock-account', {
218
- email: email,
186
+ email,
219
187
  }, this.basicHeaders());
220
- };
188
+ }
221
189
  /**
222
190
  * Unblocks account with token
223
191
  *
224
192
  * @param {string} token - The token received via email to verify and unblock the account.
225
193
  * @returns {Promise<void>} - Resolves successfuly when account is unblocked
226
194
  */
227
- Auth.prototype.unblockAccount = function (token) {
228
- return this.client.put('users/unblock-account', { token: token }, this.basicHeaders());
229
- };
195
+ unblockAccount(token) {
196
+ return this.client.put('users/unblock-account', { token }, this.basicHeaders());
197
+ }
230
198
  /**
231
199
  * Runs the first phase (out of 2) of opaque log for the given user
232
200
  * @param email - The user email.
@@ -234,156 +202,117 @@ var Auth = /** @class */ (function () {
234
202
  * @param tfa - The two factor auth code.
235
203
  * @returns The opaque login response.
236
204
  */
237
- Auth.prototype.loginOpaqueStart = function (email, startLoginRequest) {
238
- return __awaiter(this, void 0, void 0, function () {
239
- return __generator(this, function (_a) {
240
- return [2 /*return*/, this.client.post('/auth/login-opaque/start', {
241
- email: email,
242
- startLoginRequest: startLoginRequest,
243
- }, this.basicHeaders())];
244
- });
245
- });
246
- };
205
+ async loginOpaqueStart(email, startLoginRequest) {
206
+ return this.client.post('/auth/login-opaque/start', {
207
+ email,
208
+ startLoginRequest,
209
+ }, this.basicHeaders());
210
+ }
247
211
  /**
248
212
  * Runs the second phase (out of 2) of opaque log for the given user
249
213
  * @param email
250
214
  * @param finishLoginRequest
251
215
  */
252
- Auth.prototype.loginOpaqueFinish = function (email, finishLoginRequest, tfa) {
253
- return __awaiter(this, void 0, void 0, function () {
254
- return __generator(this, function (_a) {
255
- return [2 /*return*/, this.client.post('/auth/login-opaque/finish', {
256
- email: email,
257
- finishLoginRequest: finishLoginRequest,
258
- tfa: tfa,
259
- }, this.basicHeaders())];
260
- });
261
- });
262
- };
216
+ async loginOpaqueFinish(email, finishLoginRequest, tfa) {
217
+ return this.client.post('/auth/login-opaque/finish', {
218
+ email,
219
+ finishLoginRequest,
220
+ tfa,
221
+ }, this.basicHeaders());
222
+ }
263
223
  /**
264
224
  * Tries to log in a user given its login details
265
225
  * @param details
266
226
  * @param cryptoProvider
267
227
  */
268
- Auth.prototype.login = function (details, cryptoProvider) {
269
- return __awaiter(this, void 0, void 0, function () {
270
- var securityDetails, encryptedSalt, encryptedPasswordHash, keys;
271
- return __generator(this, function (_a) {
272
- switch (_a.label) {
273
- case 0: return [4 /*yield*/, this.securityDetails(details.email)];
274
- case 1:
275
- securityDetails = _a.sent();
276
- encryptedSalt = securityDetails.encryptedSalt;
277
- encryptedPasswordHash = cryptoProvider.encryptPasswordHash(details.password, encryptedSalt);
278
- return [4 /*yield*/, cryptoProvider.generateKeys(details.password)];
279
- case 2:
280
- keys = _a.sent();
281
- return [2 /*return*/, this.client
282
- .post('/auth/login/access', {
283
- email: details.email,
284
- password: encryptedPasswordHash,
285
- tfa: details.tfaCode,
286
- /**
287
- / @deprecated The individual fields for keys should not be used
288
- */
289
- privateKey: keys.privateKeyEncrypted,
290
- publicKey: keys.publicKey,
291
- revocateKey: keys.revocationCertificate,
292
- keys: {
293
- ecc: {
294
- publicKey: keys.ecc.publicKey,
295
- privateKey: keys.ecc.privateKeyEncrypted,
296
- },
297
- kyber: {
298
- publicKey: keys.kyber.publicKey,
299
- privateKey: keys.kyber.privateKeyEncrypted,
300
- },
301
- },
302
- }, this.basicHeaders())
303
- .then(function (data) {
304
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
305
- // @ts-ignore
306
- data.user.revocationKey = data.user.revocateKey; // TODO : remove when all projects use SDK
307
- return data;
308
- })];
309
- }
310
- });
228
+ async login(details, cryptoProvider) {
229
+ const securityDetails = await this.securityDetails(details.email);
230
+ const encryptedSalt = securityDetails.encryptedSalt;
231
+ const encryptedPasswordHash = cryptoProvider.encryptPasswordHash(details.password, encryptedSalt);
232
+ const keys = await cryptoProvider.generateKeys(details.password);
233
+ return this.client
234
+ .post('/auth/login/access', {
235
+ email: details.email,
236
+ password: encryptedPasswordHash,
237
+ tfa: details.tfaCode,
238
+ /**
239
+ / @deprecated The individual fields for keys should not be used
240
+ */
241
+ privateKey: keys.privateKeyEncrypted,
242
+ publicKey: keys.publicKey,
243
+ revocateKey: keys.revocationCertificate,
244
+ keys: {
245
+ ecc: {
246
+ publicKey: keys.ecc.publicKey,
247
+ privateKey: keys.ecc.privateKeyEncrypted,
248
+ },
249
+ kyber: {
250
+ publicKey: keys.kyber.publicKey,
251
+ privateKey: keys.kyber.privateKeyEncrypted,
252
+ },
253
+ },
254
+ }, this.basicHeaders())
255
+ .then((data) => {
256
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
257
+ // @ts-ignore
258
+ data.user.revocationKey = data.user.revocateKey; // TODO : remove when all projects use SDK
259
+ return data;
311
260
  });
312
- };
261
+ }
313
262
  /**
314
263
  * Tries to log in a user given its cli login details
315
264
  * @param details
316
265
  * @param cryptoProvider
317
266
  */
318
- Auth.prototype.loginAccess = function (details, cryptoProvider) {
319
- return __awaiter(this, void 0, void 0, function () {
320
- var securityDetails, encryptedSalt, encryptedPasswordHash, keys;
321
- return __generator(this, function (_a) {
322
- switch (_a.label) {
323
- case 0: return [4 /*yield*/, this.securityDetails(details.email)];
324
- case 1:
325
- securityDetails = _a.sent();
326
- encryptedSalt = securityDetails.encryptedSalt;
327
- encryptedPasswordHash = cryptoProvider.encryptPasswordHash(details.password, encryptedSalt);
328
- return [4 /*yield*/, cryptoProvider.generateKeys(details.password)];
329
- case 2:
330
- keys = _a.sent();
331
- return [2 /*return*/, this.client.post('/auth/cli/login/access', {
332
- email: details.email,
333
- password: encryptedPasswordHash,
334
- tfa: details.tfaCode,
335
- keys: {
336
- ecc: {
337
- publicKey: keys.ecc.publicKey,
338
- privateKey: keys.ecc.privateKeyEncrypted,
339
- },
340
- kyber: {
341
- publicKey: keys.kyber.publicKey,
342
- privateKey: keys.kyber.privateKeyEncrypted,
343
- },
344
- },
345
- }, this.basicHeaders())];
346
- }
347
- });
348
- });
349
- };
267
+ async loginAccess(details, cryptoProvider) {
268
+ const securityDetails = await this.securityDetails(details.email);
269
+ const encryptedSalt = securityDetails.encryptedSalt;
270
+ const encryptedPasswordHash = cryptoProvider.encryptPasswordHash(details.password, encryptedSalt);
271
+ const keys = await cryptoProvider.generateKeys(details.password);
272
+ return this.client.post('/auth/cli/login/access', {
273
+ email: details.email,
274
+ password: encryptedPasswordHash,
275
+ tfa: details.tfaCode,
276
+ keys: {
277
+ ecc: {
278
+ publicKey: keys.ecc.publicKey,
279
+ privateKey: keys.ecc.privateKeyEncrypted,
280
+ },
281
+ kyber: {
282
+ publicKey: keys.kyber.publicKey,
283
+ privateKey: keys.kyber.privateKeyEncrypted,
284
+ },
285
+ },
286
+ }, this.basicHeaders());
287
+ }
350
288
  /**
351
289
  * Tries to log in a user given its login details without sending keys
352
290
  * @param details
353
291
  * @param cryptoProvider
354
292
  */
355
- Auth.prototype.loginWithoutKeys = function (details, cryptoProvider) {
356
- return __awaiter(this, void 0, void 0, function () {
357
- var securityDetails, encryptedSalt, encryptedPasswordHash;
358
- return __generator(this, function (_a) {
359
- switch (_a.label) {
360
- case 0: return [4 /*yield*/, this.securityDetails(details.email)];
361
- case 1:
362
- securityDetails = _a.sent();
363
- encryptedSalt = securityDetails.encryptedSalt;
364
- encryptedPasswordHash = cryptoProvider.encryptPasswordHash(details.password, encryptedSalt);
365
- return [2 /*return*/, this.client
366
- .post('/auth/login/access', {
367
- email: details.email,
368
- password: encryptedPasswordHash,
369
- tfa: details.tfaCode,
370
- }, this.basicHeaders())
371
- .then(function (data) {
372
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
373
- // @ts-ignore
374
- data.user.revocationKey = data.user.revocateKey; // TODO : remove when all projects use SDK
375
- return data;
376
- })];
377
- }
378
- });
293
+ async loginWithoutKeys(details, cryptoProvider) {
294
+ const securityDetails = await this.securityDetails(details.email);
295
+ const encryptedSalt = securityDetails.encryptedSalt;
296
+ const encryptedPasswordHash = cryptoProvider.encryptPasswordHash(details.password, encryptedSalt);
297
+ return this.client
298
+ .post('/auth/login/access', {
299
+ email: details.email,
300
+ password: encryptedPasswordHash,
301
+ tfa: details.tfaCode,
302
+ }, this.basicHeaders())
303
+ .then((data) => {
304
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
305
+ // @ts-ignore
306
+ data.user.revocationKey = data.user.revocateKey; // TODO : remove when all projects use SDK
307
+ return data;
379
308
  });
380
- };
309
+ }
381
310
  /**
382
311
  * Updates the asymmetric keys
383
312
  * @param keys
384
313
  * @param token
385
314
  */
386
- Auth.prototype.updateKeys = function (keys, token) {
315
+ updateKeys(keys, token) {
387
316
  return this.client.patch('/user/keys', {
388
317
  /**
389
318
  / @deprecated The individual fields for keys should not be used
@@ -400,132 +329,124 @@ var Auth = /** @class */ (function () {
400
329
  privateKey: keys.kyber.privateKeyEncrypted,
401
330
  },
402
331
  }, this.headersWithToken(token));
403
- };
332
+ }
404
333
  /**
405
334
  * Returns general security details
406
335
  * @param email
407
336
  */
408
- Auth.prototype.securityDetails = function (email) {
337
+ securityDetails(email) {
409
338
  return this.client
410
339
  .post('/auth/login', {
411
340
  email: email,
412
341
  }, this.basicHeaders())
413
- .then(function (data) {
342
+ .then((data) => {
414
343
  return {
415
344
  encryptedSalt: data.sKey,
416
345
  tfaEnabled: data.tfa === true,
417
346
  useOpaqueLogin: data.useOpaqueLogin === true,
418
347
  };
419
348
  });
420
- };
349
+ }
421
350
  /**
422
351
  * Logout
423
352
  */
424
- Auth.prototype.logout = function (token) {
425
- var _a;
426
- return this.client.get('/auth/logout', this.headersWithToken(token !== null && token !== void 0 ? token : (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token));
427
- };
353
+ logout(token) {
354
+ return this.client.get('/auth/logout', this.headersWithToken(token ?? this.apiSecurity?.token));
355
+ }
428
356
  /**
429
357
  * Generates a new TwoFactorAuth code
430
358
  */
431
- Auth.prototype.generateTwoFactorAuthQR = function (token) {
432
- var _a;
359
+ generateTwoFactorAuthQR(token) {
433
360
  return this.client
434
- .get('/auth/tfa', this.headersWithToken(token !== null && token !== void 0 ? token : (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token))
435
- .then(function (data) {
361
+ .get('/auth/tfa', this.headersWithToken(token ?? this.apiSecurity?.token))
362
+ .then((data) => {
436
363
  return {
437
364
  qr: data.qr,
438
365
  backupKey: data.code,
439
366
  };
440
367
  });
441
- };
368
+ }
442
369
  /**
443
370
  * Disables TwoFactorAuthentication
444
371
  * @param pass
445
372
  * @param code
446
373
  */
447
- Auth.prototype.disableTwoFactorAuth = function (pass, code, token) {
448
- var _a;
449
- return this.client.delete('/auth/tfa', this.headersWithToken(token !== null && token !== void 0 ? token : (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token), {
374
+ disableTwoFactorAuth(pass, code, token) {
375
+ return this.client.delete('/auth/tfa', this.headersWithToken(token ?? this.apiSecurity?.token), {
450
376
  pass: pass,
451
377
  code: code,
452
378
  });
453
- };
379
+ }
454
380
  /**
455
381
  * Store TwoFactorAuthentication details
456
382
  * @param backupKey
457
383
  * @param code
458
384
  */
459
- Auth.prototype.storeTwoFactorAuthKey = function (backupKey, code, token) {
460
- var _a;
385
+ storeTwoFactorAuthKey(backupKey, code, token) {
461
386
  return this.client.put('/auth/tfa', {
462
387
  key: backupKey,
463
388
  code: code,
464
- }, this.headersWithToken(token !== null && token !== void 0 ? token : (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token));
465
- };
389
+ }, this.headersWithToken(token ?? this.apiSecurity?.token));
390
+ }
466
391
  /**
467
392
  * @deprecated Use `sendUserDeactivationEmail` instead.
468
393
  * Sends request to send the email to delete the account
469
394
  * @param email
470
395
  */
471
- Auth.prototype.sendDeactivationEmail = function (email) {
472
- return this.client.get("/deactivate/".concat(email), this.basicHeaders());
473
- };
396
+ sendDeactivationEmail(email) {
397
+ return this.client.get(`/deactivate/${email}`, this.basicHeaders());
398
+ }
474
399
  /**
475
400
  * Sends request to send the email to delete the account
476
401
  */
477
- Auth.prototype.sendUserDeactivationEmail = function (token) {
478
- var _a;
479
- return this.client.post('/users/deactivation/send', {}, this.headersWithToken(token !== null && token !== void 0 ? token : (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token));
480
- };
402
+ sendUserDeactivationEmail(token) {
403
+ return this.client.post('/users/deactivation/send', {}, this.headersWithToken(token ?? this.apiSecurity?.token));
404
+ }
481
405
  /**
482
406
  * @deprecated Use `confirmUserDeactivation` instead.
483
407
  * Confirms the account deactivation
484
408
  * @param token
485
409
  */
486
- Auth.prototype.confirmDeactivation = function (token) {
487
- return this.client.get("/confirmDeactivation/".concat(token), this.basicHeaders());
488
- };
410
+ confirmDeactivation(token) {
411
+ return this.client.get(`/confirmDeactivation/${token}`, this.basicHeaders());
412
+ }
489
413
  /**
490
414
  * Confirms the account deactivation
491
415
  * @param token
492
416
  */
493
- Auth.prototype.confirmUserDeactivation = function (deactivationToken, token) {
494
- var _a;
417
+ confirmUserDeactivation(deactivationToken, token) {
495
418
  return this.client.post('/users/deactivation/confirm', {
496
419
  token: deactivationToken,
497
- }, this.headersWithToken(token !== null && token !== void 0 ? token : (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token));
498
- };
420
+ }, this.headersWithToken(token ?? this.apiSecurity?.token));
421
+ }
499
422
  /**
500
423
  * Check credentials
501
424
  * @param hashedPassword
502
425
  * @returns
503
426
  */
504
- Auth.prototype.areCredentialsCorrect = function (hashedPassword, token) {
505
- var _a;
506
- var url = '/auth/are-credentials-correct';
427
+ areCredentialsCorrect(hashedPassword, token) {
428
+ const url = '/auth/are-credentials-correct';
507
429
  return this.client
508
- .getWithParams(url, { hashedPassword: hashedPassword }, this.headersWithToken(token !== null && token !== void 0 ? token : (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token))
509
- .then(function (res) {
430
+ .getWithParams(url, { hashedPassword }, this.headersWithToken(token ?? this.apiSecurity?.token))
431
+ .then((res) => {
510
432
  return res;
511
433
  })
512
- .catch(function (error) {
513
- var _a, _b, _c;
514
- if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
434
+ .catch((error) => {
435
+ if (error.response?.status === 401) {
515
436
  return false;
516
437
  }
517
- throw new Error("Request failed with status ".concat((_b = error.response) === null || _b === void 0 ? void 0 : _b.status, ": ").concat((_c = error.response) === null || _c === void 0 ? void 0 : _c.data));
438
+ throw new Error(`Request failed with status ${error.response?.status}: ${error.response?.data}`);
518
439
  });
519
- };
440
+ }
520
441
  /**
521
442
  * Send email to change password
522
443
  * @param email
523
444
  */
524
- Auth.prototype.sendChangePasswordEmail = function (email) {
445
+ sendChangePasswordEmail(email) {
525
446
  return this.client.post('/users/recover-account', {
526
447
  email: email,
527
448
  }, this.basicHeaders());
528
- };
449
+ }
529
450
  /**
530
451
  * Restore password with email link
531
452
  * @param token
@@ -534,14 +455,14 @@ var Auth = /** @class */ (function () {
534
455
  * @param mnemonic
535
456
  * @param keys
536
457
  */
537
- Auth.prototype.changePasswordWithLink = function (token, password, salt, mnemonic, keys) {
538
- return this.client.put("/users/recover-account?token=".concat(token, "&reset=false"), {
458
+ changePasswordWithLink(token, password, salt, mnemonic, keys) {
459
+ return this.client.put(`/users/recover-account?token=${token}&reset=false`, {
539
460
  password: password,
540
461
  salt: salt,
541
462
  mnemonic: mnemonic,
542
463
  privateKeys: keys,
543
464
  }, this.basicHeaders());
544
- };
465
+ }
545
466
  /**
546
467
  * Restore password with email link
547
468
  * @param token
@@ -550,19 +471,18 @@ var Auth = /** @class */ (function () {
550
471
  * @param mnemonic
551
472
  * @param keys
552
473
  */
553
- Auth.prototype.changePasswordWithLinkV2 = function (token, password, salt, mnemonic, keys) {
554
- return this.client.put("/users/recover-account-v2?token=".concat(token, "&reset=false"), {
474
+ changePasswordWithLinkV2(token, password, salt, mnemonic, keys) {
475
+ return this.client.put(`/users/recover-account-v2?token=${token}&reset=false`, {
555
476
  password: password,
556
477
  salt: salt,
557
478
  mnemonic: mnemonic,
558
- privateKeys: keys === null || keys === void 0 ? void 0 : keys.private,
559
- publicKeys: keys === null || keys === void 0 ? void 0 : keys.public,
479
+ privateKeys: keys?.private,
480
+ publicKeys: keys?.public,
560
481
  }, this.basicHeaders());
561
- };
562
- Auth.prototype.legacyRecoverAccount = function (_a) {
563
- var token = _a.token, encryptedPassword = _a.encryptedPassword, encryptedSalt = _a.encryptedSalt, encryptedMnemonic = _a.encryptedMnemonic, eccEncryptedMnemonic = _a.eccEncryptedMnemonic, kyberEncryptedMnemonic = _a.kyberEncryptedMnemonic, keys = _a.keys;
564
- var accountRecoverPayload = {
565
- token: token,
482
+ }
483
+ legacyRecoverAccount({ token, encryptedPassword, encryptedSalt, encryptedMnemonic, eccEncryptedMnemonic, kyberEncryptedMnemonic, keys, }) {
484
+ const accountRecoverPayload = {
485
+ token,
566
486
  password: encryptedPassword,
567
487
  salt: encryptedSalt,
568
488
  mnemonic: encryptedMnemonic,
@@ -570,10 +490,10 @@ var Auth = /** @class */ (function () {
570
490
  ecc: eccEncryptedMnemonic,
571
491
  hybrid: kyberEncryptedMnemonic,
572
492
  },
573
- keys: keys,
493
+ keys,
574
494
  };
575
495
  return this.client.put('/users/legacy-recover-account', accountRecoverPayload, this.basicHeaders());
576
- };
496
+ }
577
497
  /**
578
498
  * Reset account with token
579
499
  * @param token
@@ -581,32 +501,30 @@ var Auth = /** @class */ (function () {
581
501
  * @param salt
582
502
  * @param mnemonic
583
503
  */
584
- Auth.prototype.resetAccountWithToken = function (token, password, salt, mnemonic) {
585
- return this.client.put("/users/recover-account?token=".concat(token, "&reset=true"), {
504
+ resetAccountWithToken(token, password, salt, mnemonic) {
505
+ return this.client.put(`/users/recover-account?token=${token}&reset=true`, {
586
506
  password: password,
587
507
  salt: salt,
588
508
  mnemonic: mnemonic,
589
509
  }, this.basicHeaders());
590
- };
591
- Auth.prototype.basicHeaders = function () {
510
+ }
511
+ basicHeaders() {
592
512
  return (0, headers_1.basicHeaders)({
593
513
  clientName: this.appDetails.clientName,
594
514
  clientVersion: this.appDetails.clientVersion,
595
515
  desktopToken: this.appDetails.desktopHeader,
596
516
  customHeaders: this.appDetails.customHeaders,
597
517
  });
598
- };
599
- Auth.prototype.headersWithToken = function (token) {
600
- var _a;
518
+ }
519
+ headersWithToken(token) {
601
520
  return (0, headers_1.headersWithToken)({
602
521
  clientName: this.appDetails.clientName,
603
522
  clientVersion: this.appDetails.clientVersion,
604
523
  token: token,
605
- workspaceToken: (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.workspaceToken,
524
+ workspaceToken: this.apiSecurity?.workspaceToken,
606
525
  desktopToken: this.appDetails.desktopHeader,
607
526
  customHeaders: this.appDetails.customHeaders,
608
527
  });
609
- };
610
- return Auth;
611
- }());
528
+ }
529
+ }
612
530
  exports.Auth = Auth;