@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.
- package/dist/auth/index.js +180 -262
- package/dist/auth/types.js +2 -22
- package/dist/drive/backups/index.js +34 -32
- package/dist/drive/payments/index.js +96 -149
- package/dist/drive/payments/object-storage.js +34 -36
- package/dist/drive/referrals/index.js +19 -17
- package/dist/drive/share/index.js +168 -235
- package/dist/drive/storage/index.js +213 -302
- package/dist/drive/trash/index.js +40 -84
- package/dist/drive/users/index.js +95 -140
- package/dist/mail/index.d.ts +124 -2
- package/dist/mail/index.js +170 -16
- package/dist/mail/types.d.ts +50 -0
- package/dist/mail/types.js +6 -0
- package/dist/meet/index.js +31 -99
- package/dist/misc/location/index.js +10 -50
- package/dist/network/download.js +38 -107
- package/dist/network/errors/codes.js +8 -24
- package/dist/network/errors/context.js +9 -26
- package/dist/network/errors/download.js +6 -24
- package/dist/network/errors/upload.js +21 -48
- package/dist/network/index.js +120 -277
- package/dist/network/types.js +3 -4
- package/dist/network/upload.js +63 -133
- package/dist/payments/checkout.js +57 -69
- package/dist/send/send.js +17 -27
- package/dist/shared/headers/index.js +56 -42
- package/dist/shared/http/client.js +95 -207
- package/dist/shared/http/retryWithBackoff.js +36 -110
- package/dist/shared/types/errors.js +37 -51
- package/dist/workspaces/index.js +224 -264
- package/package.json +14 -15
- package/dist/mail/api.d.ts +0 -126
- package/dist/mail/api.js +0 -288
- package/dist/mail/crypto.d.ts +0 -66
- package/dist/mail/crypto.js +0 -156
- package/dist/mail/mail.d.ts +0 -162
- package/dist/mail/mail.js +0 -382
package/dist/auth/index.js
CHANGED
|
@@ -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
|
-
|
|
55
|
-
|
|
18
|
+
const headers_1 = require("../shared/headers");
|
|
19
|
+
const client_1 = require("../shared/http/client");
|
|
56
20
|
__exportStar(require("./types"), exports);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
41
|
+
registerOpaqueStart(email, registrationRequest) {
|
|
74
42
|
return this.client.post('/register-opaque/start', {
|
|
75
|
-
email
|
|
76
|
-
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
143
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
184
|
+
requestUnblockAccount(email) {
|
|
217
185
|
return this.client.post('users/unblock-account', {
|
|
218
|
-
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
|
-
|
|
228
|
-
return this.client.put('users/unblock-account', { token
|
|
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
|
-
|
|
238
|
-
return
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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
|
-
|
|
253
|
-
return
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
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
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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
|
-
|
|
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
|
-
|
|
337
|
+
securityDetails(email) {
|
|
409
338
|
return this.client
|
|
410
339
|
.post('/auth/login', {
|
|
411
340
|
email: email,
|
|
412
341
|
}, this.basicHeaders())
|
|
413
|
-
.then(
|
|
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
|
-
|
|
425
|
-
|
|
426
|
-
|
|
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
|
-
|
|
432
|
-
var _a;
|
|
359
|
+
generateTwoFactorAuthQR(token) {
|
|
433
360
|
return this.client
|
|
434
|
-
.get('/auth/tfa', this.headersWithToken(token
|
|
435
|
-
.then(
|
|
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
|
-
|
|
448
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
472
|
-
return this.client.get(
|
|
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
|
-
|
|
478
|
-
|
|
479
|
-
|
|
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
|
-
|
|
487
|
-
return this.client.get(
|
|
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
|
-
|
|
494
|
-
var _a;
|
|
417
|
+
confirmUserDeactivation(deactivationToken, token) {
|
|
495
418
|
return this.client.post('/users/deactivation/confirm', {
|
|
496
419
|
token: deactivationToken,
|
|
497
|
-
}, this.headersWithToken(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
|
-
|
|
505
|
-
|
|
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
|
|
509
|
-
.then(
|
|
430
|
+
.getWithParams(url, { hashedPassword }, this.headersWithToken(token ?? this.apiSecurity?.token))
|
|
431
|
+
.then((res) => {
|
|
510
432
|
return res;
|
|
511
433
|
})
|
|
512
|
-
.catch(
|
|
513
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
538
|
-
return this.client.put(
|
|
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
|
-
|
|
554
|
-
return this.client.put(
|
|
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
|
|
559
|
-
publicKeys: keys
|
|
479
|
+
privateKeys: keys?.private,
|
|
480
|
+
publicKeys: keys?.public,
|
|
560
481
|
}, this.basicHeaders());
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
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
|
|
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
|
-
|
|
585
|
-
return this.client.put(
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
524
|
+
workspaceToken: this.apiSecurity?.workspaceToken,
|
|
606
525
|
desktopToken: this.appDetails.desktopHeader,
|
|
607
526
|
customHeaders: this.appDetails.customHeaders,
|
|
608
527
|
});
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
}());
|
|
528
|
+
}
|
|
529
|
+
}
|
|
612
530
|
exports.Auth = Auth;
|