@internxt/sdk 1.15.13 → 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 (39) 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.d.ts +7 -0
  29. package/dist/shared/http/client.js +101 -188
  30. package/dist/shared/http/retryWithBackoff.js +36 -110
  31. package/dist/shared/types/errors.js +37 -51
  32. package/dist/workspaces/index.js +224 -264
  33. package/package.json +14 -15
  34. package/dist/mail/api.d.ts +0 -126
  35. package/dist/mail/api.js +0 -288
  36. package/dist/mail/crypto.d.ts +0 -66
  37. package/dist/mail/crypto.js +0 -156
  38. package/dist/mail/mail.d.ts +0 -162
  39. package/dist/mail/mail.js +0 -382
@@ -32,84 +32,43 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- var __generator = (this && this.__generator) || function (thisArg, body) {
45
- 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);
46
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
47
- function verb(n) { return function (v) { return step([n, v]); }; }
48
- function step(op) {
49
- if (f) throw new TypeError("Generator is already executing.");
50
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
51
- 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;
52
- if (y = 0, t) op = [op[0] & 2, t.value];
53
- switch (op[0]) {
54
- case 0: case 1: t = op; break;
55
- case 4: _.label++; return { value: op[1], done: false };
56
- case 5: _.label++; y = op[1]; op = [0]; continue;
57
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
58
- default:
59
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
60
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
61
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
62
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
63
- if (t[2]) _.ops.pop();
64
- _.trys.pop(); continue;
65
- }
66
- op = body.call(thisArg, _);
67
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
68
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
69
- }
70
- };
71
35
  Object.defineProperty(exports, "__esModule", { value: true });
72
36
  exports.Trash = exports.TrashTypes = void 0;
73
- var headers_1 = require("../../shared/headers");
74
- var client_1 = require("../../shared/http/client");
37
+ const headers_1 = require("../../shared/headers");
38
+ const client_1 = require("../../shared/http/client");
75
39
  exports.TrashTypes = __importStar(require("./types"));
76
- var Trash = /** @class */ (function () {
77
- function Trash(apiUrl, appDetails, apiSecurity) {
40
+ class Trash {
41
+ client;
42
+ appDetails;
43
+ apiSecurity;
44
+ static client(apiUrl, appDetails, apiSecurity) {
45
+ return new Trash(apiUrl, appDetails, apiSecurity);
46
+ }
47
+ constructor(apiUrl, appDetails, apiSecurity) {
78
48
  this.client = client_1.HttpClient.create(apiUrl, apiSecurity.unauthorizedCallback, apiSecurity.retryOptions);
79
49
  this.appDetails = appDetails;
80
50
  this.apiSecurity = apiSecurity;
81
51
  }
82
- Trash.client = function (apiUrl, appDetails, apiSecurity) {
83
- return new Trash(apiUrl, appDetails, apiSecurity);
84
- };
85
52
  /**
86
53
  * Removes a specific folder from the centralized persistence
87
54
  * @param folderId
88
55
  */
89
- Trash.prototype.deleteFolder = function (folderId) {
90
- return __awaiter(this, void 0, void 0, function () {
91
- return __generator(this, function (_a) {
92
- return [2 /*return*/, this.client.delete("/storage/folder/".concat(folderId), this.headers())];
93
- });
94
- });
95
- };
56
+ async deleteFolder(folderId) {
57
+ return this.client.delete(`/storage/folder/${folderId}`, this.headers());
58
+ }
96
59
  /**
97
60
  * Deletes a specific file entry
98
61
  * @param payload
99
62
  */
100
- Trash.prototype.deleteFile = function (payload) {
101
- return __awaiter(this, void 0, void 0, function () {
102
- return __generator(this, function (_a) {
103
- return [2 /*return*/, this.client.delete("/storage/folder/".concat(payload.folderId, "/file/").concat(payload.fileId), this.headers())];
104
- });
105
- });
106
- };
63
+ async deleteFile(payload) {
64
+ return this.client.delete(`/storage/folder/${payload.folderId}/file/${payload.fileId}`, this.headers());
65
+ }
107
66
  /**
108
67
  * Returns a list of items in trash
109
68
  */
110
- Trash.prototype.getTrash = function () {
69
+ getTrash() {
111
70
  return this.client.get('/storage/trash', this.headers());
112
- };
71
+ }
113
72
  /**
114
73
  * Retrieves a paginated list of trashed files or folders.
115
74
  * @param {number} limit - The number of items to retrieve per page.
@@ -120,13 +79,12 @@ var Trash = /** @class */ (function () {
120
79
  * @param {number} [folderId] - The ID of the folder to retrieve content from.
121
80
  * @returns {Promise<FetchTrashContentResponse>} - A promise that resolves with the paginated list of trashed content.
122
81
  */
123
- Trash.prototype.getTrashedFilesPaginated = function (limit, offset, type, root, folderId) {
124
- if (offset === void 0) { offset = 0; }
125
- var endpoint = '/storage/trash/paginated';
126
- var folderIdQuery = folderId !== undefined ? "folderId=".concat(folderId, "&") : '';
127
- var url = "".concat(endpoint, "?").concat(folderIdQuery, "limit=").concat(limit, "&offset=").concat(offset, "&type=").concat(type, "&root=").concat(root);
82
+ getTrashedFilesPaginated(limit, offset = 0, type, root, folderId) {
83
+ const endpoint = '/storage/trash/paginated';
84
+ const folderIdQuery = folderId !== undefined ? `folderId=${folderId}&` : '';
85
+ const url = `${endpoint}?${folderIdQuery}limit=${limit}&offset=${offset}&type=${type}&root=${root}`;
128
86
  return this.client.get(url, this.headers());
129
- };
87
+ }
130
88
  /**
131
89
  * Retrieves a sorted list of trashed files or folders.
132
90
  * @param {number} limit - The number of items to retrieve per page.
@@ -139,54 +97,53 @@ var Trash = /** @class */ (function () {
139
97
  * @param {number} [folderId] - The ID of the folder to retrieve content from.
140
98
  * @returns {Promise<FetchTrashContentResponse>} - A promise that resolves with the paginated list of trashed content.
141
99
  */
142
- Trash.prototype.getTrashedItemsSorted = function (limit, offset, type, root, sort, order, folderId) {
143
- if (offset === void 0) { offset = 0; }
144
- var endpoint = '/storage/trash/paginated';
145
- var folderIdQuery = folderId !== undefined ? "folderId=".concat(folderId, "&") : '';
146
- var params = "limit=".concat(limit, "&offset=").concat(offset, "&type=").concat(type, "&root=").concat(root, "&sort=").concat(sort, "&order=").concat(order);
147
- var url = "".concat(endpoint, "?").concat(folderIdQuery).concat(params);
100
+ getTrashedItemsSorted(limit, offset = 0, type, root, sort, order, folderId) {
101
+ const endpoint = '/storage/trash/paginated';
102
+ const folderIdQuery = folderId !== undefined ? `folderId=${folderId}&` : '';
103
+ const params = `limit=${limit}&offset=${offset}&type=${type}&root=${root}&sort=${sort}&order=${order}`;
104
+ const url = `${endpoint}?${folderIdQuery}${params}`;
148
105
  return this.client.get(url, this.headers());
149
- };
106
+ }
150
107
  /**
151
108
  * Add Items to Trash
152
109
  * @param payload
153
110
  */
154
- Trash.prototype.addItemsToTrash = function (payload) {
111
+ addItemsToTrash(payload) {
155
112
  return this.client.post('/storage/trash/add', {
156
113
  items: payload.items,
157
114
  }, this.headers());
158
- };
115
+ }
159
116
  /**
160
117
  * Removes all items from the trash
161
118
  */
162
- Trash.prototype.clearTrash = function () {
119
+ clearTrash() {
163
120
  return this.client.delete('/storage/trash/all', this.headers());
164
- };
121
+ }
165
122
  /**
166
123
  * Deletes trashed items permanently
167
124
  * @param payload
168
125
  */
169
- Trash.prototype.deleteItemsPermanently = function (payload) {
126
+ deleteItemsPermanently(payload) {
170
127
  return this.client.delete('/storage/trash', this.headers(), {
171
128
  items: payload.items,
172
129
  });
173
- };
130
+ }
174
131
  /**
175
132
  * Deletes trashed items permanently by UUID.
176
133
  *
177
134
  * @param {DeleteItemsPermanentlyByUUIDPayload} payload - The payload containing the items to be deleted.
178
135
  * @return {Promise<void>} A promise that resolves when the items are deleted permanently.
179
136
  */
180
- Trash.prototype.deleteItemsPermanentlyByUUID = function (payload) {
137
+ deleteItemsPermanentlyByUUID(payload) {
181
138
  return this.client.delete('/storage/trash', this.headers(), {
182
139
  items: payload.items,
183
140
  });
184
- };
141
+ }
185
142
  /**
186
143
  * Returns the needed headers for the module requests
187
144
  * @private
188
145
  */
189
- Trash.prototype.headers = function () {
146
+ headers() {
190
147
  return (0, headers_1.headersWithToken)({
191
148
  clientName: this.appDetails.clientName,
192
149
  clientVersion: this.appDetails.clientVersion,
@@ -195,7 +152,6 @@ var Trash = /** @class */ (function () {
195
152
  desktopToken: this.appDetails.desktopHeader,
196
153
  customHeaders: this.appDetails.customHeaders,
197
154
  });
198
- };
199
- return Trash;
200
- }());
155
+ }
156
+ }
201
157
  exports.Trash = Trash;
@@ -32,98 +32,65 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- var __generator = (this && this.__generator) || function (thisArg, body) {
45
- 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);
46
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
47
- function verb(n) { return function (v) { return step([n, v]); }; }
48
- function step(op) {
49
- if (f) throw new TypeError("Generator is already executing.");
50
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
51
- 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;
52
- if (y = 0, t) op = [op[0] & 2, t.value];
53
- switch (op[0]) {
54
- case 0: case 1: t = op; break;
55
- case 4: _.label++; return { value: op[1], done: false };
56
- case 5: _.label++; y = op[1]; op = [0]; continue;
57
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
58
- default:
59
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
60
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
61
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
62
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
63
- if (t[2]) _.ops.pop();
64
- _.trys.pop(); continue;
65
- }
66
- op = body.call(thisArg, _);
67
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
68
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
69
- }
70
- };
71
35
  Object.defineProperty(exports, "__esModule", { value: true });
72
36
  exports.Users = exports.UserTypes = void 0;
73
- var headers_1 = require("../../shared/headers");
74
- var client_1 = require("../../shared/http/client");
37
+ const headers_1 = require("../../shared/headers");
38
+ const client_1 = require("../../shared/http/client");
75
39
  exports.UserTypes = __importStar(require("./types"));
76
- var Users = /** @class */ (function () {
77
- function Users(apiUrl, appDetails, apiSecurity) {
78
- 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);
40
+ class Users {
41
+ client;
42
+ appDetails;
43
+ apiSecurity;
44
+ static client(apiUrl, appDetails, apiSecurity) {
45
+ return new Users(apiUrl, appDetails, apiSecurity);
46
+ }
47
+ constructor(apiUrl, appDetails, apiSecurity) {
48
+ this.client = client_1.HttpClient.create(apiUrl, apiSecurity?.unauthorizedCallback, apiSecurity?.retryOptions);
79
49
  this.appDetails = appDetails;
80
50
  this.apiSecurity = apiSecurity;
81
51
  }
82
- Users.client = function (apiUrl, appDetails, apiSecurity) {
83
- return new Users(apiUrl, appDetails, apiSecurity);
84
- };
85
52
  /**
86
53
  * Sends an invitation to the specified email
87
54
  * @param email
88
55
  */
89
- Users.prototype.sendInvitation = function (email) {
56
+ sendInvitation(email) {
90
57
  return this.client.post('/user/invite', {
91
58
  email: email,
92
59
  }, this.headers());
93
- };
60
+ }
94
61
  /**
95
62
  * Initialize basic state of user and returns data after registration process
96
63
  * @param email
97
64
  * @param mnemonic
98
65
  */
99
- Users.prototype.initialize = function (email, mnemonic) {
66
+ initialize(email, mnemonic) {
100
67
  return this.client
101
68
  .post('/initialize', {
102
69
  email: email,
103
70
  mnemonic: mnemonic,
104
71
  }, this.headers())
105
- .then(function (data) {
72
+ .then((data) => {
106
73
  return data.user;
107
74
  });
108
- };
75
+ }
109
76
  /**
110
77
  * Returns fresh data of the user
111
78
  */
112
- Users.prototype.refreshUser = function () {
79
+ refreshUser() {
113
80
  return this.client.get('/users/refresh', this.headers());
114
- };
81
+ }
115
82
  /**
116
83
  * Returns fresh data of the user
117
84
  */
118
- Users.prototype.refreshUserCredentials = function () {
85
+ refreshUserCredentials() {
119
86
  return this.client.get('/users/cli/refresh', this.headers());
120
- };
87
+ }
121
88
  /**
122
89
  * Returns fresh avatar URL of the user
123
90
  */
124
- Users.prototype.refreshAvatarUser = function () {
91
+ refreshAvatarUser() {
125
92
  return this.client.get('/users/avatar/refresh', this.headers());
126
- };
93
+ }
127
94
  /**
128
95
  * @deprecated Use `refreshUser` instead.
129
96
  *
@@ -136,17 +103,16 @@ var Users = /** @class */ (function () {
136
103
  * - `oldToken` (string): The old drive token of the user.
137
104
  * - `user` (UserSettings): The user data.
138
105
  */
139
- Users.prototype.getUserData = function (_a) {
140
- var userUuid = _a.userUuid;
141
- return this.client.get("/users/c/".concat(userUuid), this.headers());
142
- };
106
+ getUserData({ userUuid }) {
107
+ return this.client.get(`/users/c/${userUuid}`, this.headers());
108
+ }
143
109
  /**
144
110
  * Updates the authentication credentials and invalidates previous tokens (Legacy backend (drive-server))
145
111
  * @param payload
146
112
  *
147
113
  * @returns {Promise<{token: string, newToken: string}>} A promise that returns new tokens for this user.
148
114
  */
149
- Users.prototype.changePasswordLegacy = function (payload) {
115
+ changePasswordLegacy(payload) {
150
116
  return this.client.patch('/user/password', {
151
117
  currentPassword: payload.currentEncryptedPassword,
152
118
  newPassword: payload.newEncryptedPassword,
@@ -154,14 +120,14 @@ var Users = /** @class */ (function () {
154
120
  mnemonic: payload.encryptedMnemonic,
155
121
  privateKey: payload.encryptedPrivateKey,
156
122
  }, this.headers());
157
- };
123
+ }
158
124
  /**
159
125
  * Updates the authentication credentials and invalidates previous tokens (New backend (drive-server-wip))
160
126
  * @param payload
161
127
  *
162
128
  * @returns {Promise<{token: string, newToken: string}>} A promise that returns new tokens for this user.
163
129
  */
164
- Users.prototype.changePassword = function (payload) {
130
+ changePassword(payload) {
165
131
  return this.client.patch('/users/password', {
166
132
  currentPassword: payload.currentEncryptedPassword,
167
133
  newPassword: payload.newEncryptedPassword,
@@ -171,7 +137,7 @@ var Users = /** @class */ (function () {
171
137
  privateKyberKey: payload.keys.encryptedPrivateKyberKey,
172
138
  encryptVersion: payload.encryptVersion,
173
139
  }, this.headers());
174
- };
140
+ }
175
141
  /**
176
142
  * Runs the first phase (out of 2) of the password change.
177
143
  * @param hmac - The HMAC to authenticate request.
@@ -179,13 +145,13 @@ var Users = /** @class */ (function () {
179
145
  * @param registrationRequest - The opaque registration request.
180
146
  * @returns {Promise<string>} A promise that returns opaque registration response.
181
147
  */
182
- Users.prototype.changePwdOpaqueStart = function (hmac, sessionID, registrationRequest) {
148
+ changePwdOpaqueStart(hmac, sessionID, registrationRequest) {
183
149
  return this.client.patch('/users/password-opaque/start', {
184
- hmac: hmac,
185
- sessionID: sessionID,
186
- registrationRequest: registrationRequest,
150
+ hmac,
151
+ sessionID,
152
+ registrationRequest,
187
153
  }, this.headers());
188
- };
154
+ }
189
155
  /**
190
156
  * Runs the second phase (out of 2) of the password change.
191
157
  * @param hmac - The HMAC to authenticate request.
@@ -196,99 +162,91 @@ var Users = /** @class */ (function () {
196
162
  * @param startLoginRequest - The opaque start login request.
197
163
  * @returns {Promise<string>} A promise that returns opaque login response.
198
164
  */
199
- Users.prototype.changePwdOpaqueFinish = function (hmac, sessionID, registrationRecord, mnemonic, keys, startLoginRequest) {
165
+ changePwdOpaqueFinish(hmac, sessionID, registrationRecord, mnemonic, keys, startLoginRequest) {
200
166
  return this.client.patch('/users/password-opaque/finish', {
201
- hmac: hmac,
202
- sessionID: sessionID,
203
- keys: keys,
204
- mnemonic: mnemonic,
205
- registrationRecord: registrationRecord,
206
- startLoginRequest: startLoginRequest,
167
+ hmac,
168
+ sessionID,
169
+ keys,
170
+ mnemonic,
171
+ registrationRecord,
172
+ startLoginRequest,
207
173
  }, this.headers());
208
- };
174
+ }
209
175
  /**
210
176
  * Pre registers an email
211
177
  * @param email
212
178
  * @returns {Promise<PreCreateUserResponse>} A promise that returns a public key for this user.
213
179
  */
214
- Users.prototype.preRegister = function (email) {
180
+ preRegister(email) {
215
181
  return this.client.post('/users/pre-create', {
216
- email: email,
182
+ email,
217
183
  }, this.headers());
218
- };
184
+ }
219
185
  /**
220
186
  * @deprecated Use `updateUserProfile` instead.
221
187
  * Updates a user profile
222
188
  * @param payload
223
189
  */
224
- Users.prototype.updateProfile = function (payload) {
190
+ updateProfile(payload) {
225
191
  return this.client.patch('/user/profile', payload, this.headers());
226
- };
192
+ }
227
193
  /**
228
194
  * Updates a user profile
229
195
  * @param payload
230
196
  */
231
- Users.prototype.updateUserProfile = function (payload, token) {
232
- var _a;
233
- return this.client.patch('/users/profile', payload, this.headersWithToken(token !== null && token !== void 0 ? token : (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token));
234
- };
197
+ updateUserProfile(payload, token) {
198
+ return this.client.patch('/users/profile', payload, this.headersWithToken(token ?? this.apiSecurity?.token));
199
+ }
235
200
  /**
236
201
  * @deprecated Use `updateUserAvatar` instead.
237
202
  * Updates a user avatar
238
203
  * @param payload
239
204
  */
240
- Users.prototype.updateAvatar = function (payload) {
205
+ updateAvatar(payload) {
241
206
  return this.client.putForm('/user/avatar', {
242
207
  avatar: payload.avatar,
243
208
  }, this.headers());
244
- };
209
+ }
245
210
  /**
246
211
  * Updates a user avatar
247
212
  * @param payload
248
213
  */
249
- Users.prototype.updateUserAvatar = function (payload, token) {
250
- return __awaiter(this, void 0, void 0, function () {
251
- var _a;
252
- return __generator(this, function (_b) {
253
- return [2 /*return*/, this.client.putForm('/users/avatar', {
254
- avatar: payload.avatar,
255
- }, this.headersWithToken(token !== null && token !== void 0 ? token : (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token))];
256
- });
257
- });
258
- };
214
+ async updateUserAvatar(payload, token) {
215
+ return this.client.putForm('/users/avatar', {
216
+ avatar: payload.avatar,
217
+ }, this.headersWithToken(token ?? this.apiSecurity?.token));
218
+ }
259
219
  /**
260
220
  * @deprecated Use `deleteUserAvatar` instead.
261
221
  * Delete current user avatar
262
222
  */
263
- Users.prototype.deleteAvatar = function () {
223
+ deleteAvatar() {
264
224
  return this.client.delete('/user/avatar', this.headers());
265
- };
225
+ }
266
226
  /**
267
227
  * Delete current user avatar
268
228
  */
269
- Users.prototype.deleteUserAvatar = function (token) {
270
- var _a;
271
- return this.client.delete('/users/avatar', this.headersWithToken(token !== null && token !== void 0 ? token : (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token));
272
- };
229
+ deleteUserAvatar(token) {
230
+ return this.client.delete('/users/avatar', this.headersWithToken(token ?? this.apiSecurity?.token));
231
+ }
273
232
  /**
274
233
  * Gets all friend invites created by this user
275
234
  */
276
- Users.prototype.getFriendInvites = function () {
235
+ getFriendInvites() {
277
236
  return this.client.get('/user/invite', this.headers());
278
- };
237
+ }
279
238
  /**
280
239
  * Sends verification email
281
240
  */
282
- Users.prototype.sendVerificationEmail = function (token) {
283
- var _a;
284
- return this.client.post('/users/email-verification/send', {}, this.headersWithToken(token !== null && token !== void 0 ? token : (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token));
285
- };
241
+ sendVerificationEmail(token) {
242
+ return this.client.post('/users/email-verification/send', {}, this.headersWithToken(token ?? this.apiSecurity?.token));
243
+ }
286
244
  /**
287
245
  * Verifies user email
288
246
  */
289
- Users.prototype.verifyEmail = function (payload) {
247
+ verifyEmail(payload) {
290
248
  return this.client.post('/users/email-verification', payload, this.headers());
291
- };
249
+ }
292
250
  /**
293
251
  * Change user email by new email
294
252
  *
@@ -296,11 +254,11 @@ var Users = /** @class */ (function () {
296
254
  *
297
255
  * @returns {Promise<void>}
298
256
  */
299
- Users.prototype.changeUserEmail = function (newEmail) {
257
+ changeUserEmail(newEmail) {
300
258
  return this.client.post('users/attempt-change-email', {
301
- newEmail: newEmail,
259
+ newEmail,
302
260
  }, this.headers());
303
- };
261
+ }
304
262
  /**
305
263
  * Verify user email change
306
264
  *
@@ -308,9 +266,9 @@ var Users = /** @class */ (function () {
308
266
  *
309
267
  * @returns {Promise<VerifyEmailChangeResponse>}
310
268
  */
311
- Users.prototype.verifyEmailChange = function (encryptedAttemptChangeEmailId) {
312
- return this.client.post("users/attempt-change-email/".concat(encryptedAttemptChangeEmailId, "/accept"), {}, this.headers());
313
- };
269
+ verifyEmailChange(encryptedAttemptChangeEmailId) {
270
+ return this.client.post(`users/attempt-change-email/${encryptedAttemptChangeEmailId}/accept`, {}, this.headers());
271
+ }
314
272
  /**
315
273
  * Check if user email change verification link is expired
316
274
  *
@@ -318,49 +276,47 @@ var Users = /** @class */ (function () {
318
276
  *
319
277
  * @returns {Promise<CheckChangeEmailExpirationResponse>}
320
278
  */
321
- Users.prototype.checkChangeEmailExpiration = function (encryptedAttemptChangeEmailId) {
322
- return this.client.get("users/attempt-change-email/".concat(encryptedAttemptChangeEmailId, "/verify-expiration"), this.headers());
323
- };
279
+ checkChangeEmailExpiration(encryptedAttemptChangeEmailId) {
280
+ return this.client.get(`users/attempt-change-email/${encryptedAttemptChangeEmailId}/verify-expiration`, this.headers());
281
+ }
324
282
  /**
325
283
  * Get public key of given email
326
284
  */
327
- Users.prototype.getPublicKeyByEmail = function (_a) {
328
- var email = _a.email;
329
- return this.client.get("/users/public-key/".concat(email), this.headers());
330
- };
285
+ getPublicKeyByEmail({ email }) {
286
+ return this.client.get(`/users/public-key/${email}`, this.headers());
287
+ }
331
288
  /**
332
289
  * Get public key of given email, if not exists it pre-create user with this email
333
290
  * and returns public key
334
291
  * @param email
335
292
  * @returns {Promise<UserPublicKeyWithCreationResponse>} A promise that returns the public keys of given user
336
293
  */
337
- Users.prototype.getPublicKeyWithPrecreation = function (_a) {
338
- var email = _a.email;
339
- return this.client.put("/users/public-key/".concat(email), {}, this.headers());
340
- };
294
+ getPublicKeyWithPrecreation({ email }) {
295
+ return this.client.put(`/users/public-key/${email}`, {}, this.headers());
296
+ }
341
297
  /**
342
298
  * Generate mnemonic
343
299
  */
344
- Users.prototype.generateMnemonic = function () {
300
+ generateMnemonic() {
345
301
  return this.client.get('/users/generate-mnemonic', this.basicHeaders());
346
- };
302
+ }
347
303
  /**
348
304
  * Tracks incomplete checkout event and sends notification email when user abandons checkout process
349
305
  * @param payload - The incomplete checkout data containing checkout URL, plan name and price
350
306
  * @returns A promise that resolves when the event is tracked successfully
351
307
  */
352
- Users.prototype.handleIncompleteCheckout = function (payload) {
308
+ handleIncompleteCheckout(payload) {
353
309
  return this.client.post('/users/payments/incomplete-checkout', payload, this.headers());
354
- };
355
- Users.prototype.basicHeaders = function () {
310
+ }
311
+ basicHeaders() {
356
312
  return (0, headers_1.basicHeaders)({
357
313
  clientName: this.appDetails.clientName,
358
314
  clientVersion: this.appDetails.clientVersion,
359
315
  desktopToken: this.appDetails.desktopHeader,
360
316
  customHeaders: this.appDetails.customHeaders,
361
317
  });
362
- };
363
- Users.prototype.headers = function () {
318
+ }
319
+ headers() {
364
320
  return (0, headers_1.headersWithToken)({
365
321
  clientName: this.appDetails.clientName,
366
322
  clientVersion: this.appDetails.clientVersion,
@@ -369,8 +325,8 @@ var Users = /** @class */ (function () {
369
325
  desktopToken: this.appDetails.desktopHeader,
370
326
  customHeaders: this.appDetails.customHeaders,
371
327
  });
372
- };
373
- Users.prototype.headersWithToken = function (token) {
328
+ }
329
+ headersWithToken(token) {
374
330
  return (0, headers_1.headersWithToken)({
375
331
  clientName: this.appDetails.clientName,
376
332
  clientVersion: this.appDetails.clientVersion,
@@ -379,7 +335,6 @@ var Users = /** @class */ (function () {
379
335
  desktopToken: this.appDetails.desktopHeader,
380
336
  customHeaders: this.appDetails.customHeaders,
381
337
  });
382
- };
383
- return Users;
384
- }());
338
+ }
339
+ }
385
340
  exports.Users = Users;