@internxt/sdk 1.5.25 → 1.6.3
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.d.ts +127 -122
- package/dist/auth/index.js +378 -310
- package/dist/auth/types.d.ts +67 -54
- package/dist/auth/types.js +26 -26
- package/dist/drive/backups/index.d.ts +18 -18
- package/dist/drive/backups/index.js +40 -40
- package/dist/drive/backups/types.d.ts +27 -27
- package/dist/drive/backups/types.js +2 -2
- package/dist/drive/index.d.ts +7 -7
- package/dist/drive/index.js +23 -19
- package/dist/drive/payments/index.d.ts +66 -71
- package/dist/drive/payments/index.js +206 -208
- package/dist/drive/payments/types.d.ts +180 -176
- package/dist/drive/payments/types.js +37 -37
- package/dist/drive/referrals/index.d.ts +19 -19
- package/dist/drive/referrals/index.js +54 -50
- package/dist/drive/referrals/types.d.ts +21 -21
- package/dist/drive/referrals/types.js +18 -18
- package/dist/drive/share/index.d.ts +319 -319
- package/dist/drive/share/index.js +544 -540
- package/dist/drive/share/types.d.ts +360 -360
- package/dist/drive/share/types.js +2 -2
- package/dist/drive/storage/index.d.ts +315 -315
- package/dist/drive/storage/index.js +634 -630
- package/dist/drive/storage/types.d.ts +480 -473
- package/dist/drive/storage/types.js +13 -13
- package/dist/drive/trash/index.d.ts +75 -75
- package/dist/drive/trash/index.js +184 -180
- package/dist/drive/trash/types.d.ts +29 -29
- package/dist/drive/trash/types.js +2 -2
- package/dist/drive/users/index.d.ts +135 -135
- package/dist/drive/users/index.js +208 -204
- package/dist/drive/users/types.d.ts +53 -51
- package/dist/drive/users/types.js +2 -2
- package/dist/index.d.ts +6 -6
- package/dist/index.js +35 -31
- package/dist/network/download.d.ts +8 -8
- package/dist/network/download.js +123 -123
- package/dist/network/errors/codes.d.ts +24 -24
- package/dist/network/errors/codes.js +48 -48
- package/dist/network/errors/context.d.ts +35 -35
- package/dist/network/errors/context.js +39 -39
- package/dist/network/errors/download.d.ts +4 -4
- package/dist/network/errors/download.js +52 -48
- package/dist/network/errors/index.d.ts +3 -3
- package/dist/network/errors/index.js +19 -15
- package/dist/network/errors/upload.d.ts +13 -13
- package/dist/network/errors/upload.js +82 -78
- package/dist/network/index.d.ts +70 -70
- package/dist/network/index.js +315 -311
- package/dist/network/types.d.ts +102 -102
- package/dist/network/types.js +18 -18
- package/dist/network/upload.d.ts +4 -4
- package/dist/network/upload.js +158 -159
- package/dist/photos/devices/index.d.ts +10 -10
- package/dist/photos/devices/index.js +79 -79
- package/dist/photos/index.d.ts +17 -17
- package/dist/photos/index.js +56 -52
- package/dist/photos/photos/index.d.ts +60 -60
- package/dist/photos/photos/index.js +225 -225
- package/dist/photos/shares/index.d.ts +8 -8
- package/dist/photos/shares/index.js +34 -34
- package/dist/photos/types.d.ts +154 -154
- package/dist/photos/types.js +19 -19
- package/dist/photos/users/index.d.ts +7 -7
- package/dist/photos/users/index.js +46 -46
- package/dist/shared/headers/index.d.ts +21 -21
- package/dist/shared/headers/index.js +78 -79
- package/dist/shared/http/client.d.ts +85 -85
- package/dist/shared/http/client.js +172 -172
- package/dist/shared/http/types.d.ts +7 -7
- package/dist/shared/http/types.js +2 -2
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.js +17 -13
- package/dist/shared/types/apiConnection.d.ts +12 -12
- package/dist/shared/types/apiConnection.js +2 -2
- package/dist/shared/types/appsumo.d.ts +16 -16
- package/dist/shared/types/appsumo.js +12 -12
- package/dist/shared/types/errors.d.ts +5 -5
- package/dist/shared/types/errors.js +28 -28
- package/dist/shared/types/teams.d.ts +9 -9
- package/dist/shared/types/teams.js +2 -2
- package/dist/shared/types/userSettings.d.ts +43 -29
- package/dist/shared/types/userSettings.js +2 -2
- package/dist/utils.d.ts +3 -3
- package/dist/utils.js +24 -25
- package/dist/workspaces/index.d.ts +176 -176
- package/dist/workspaces/index.js +419 -415
- package/dist/workspaces/index.test.d.ts +1 -1
- package/dist/workspaces/index.test.js +908 -903
- package/dist/workspaces/types.d.ts +294 -291
- package/dist/workspaces/types.js +2 -2
- package/package.json +13 -13
package/dist/auth/index.js
CHANGED
|
@@ -1,310 +1,378 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (t[
|
|
41
|
-
_.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
|
-
/**
|
|
275
|
-
*
|
|
276
|
-
* @param
|
|
277
|
-
* @param
|
|
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
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.Auth = void 0;
|
|
54
|
+
var headers_1 = require("../shared/headers");
|
|
55
|
+
var client_1 = require("../shared/http/client");
|
|
56
|
+
__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);
|
|
60
|
+
this.appDetails = appDetails;
|
|
61
|
+
this.apiSecurity = apiSecurity;
|
|
62
|
+
this.apiUrl = apiUrl;
|
|
63
|
+
}
|
|
64
|
+
Auth.client = function (apiUrl, appDetails, apiSecurity) {
|
|
65
|
+
return new Auth(apiUrl, appDetails, apiSecurity);
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Tries to register a new user
|
|
69
|
+
* @param registerDetails
|
|
70
|
+
*/
|
|
71
|
+
Auth.prototype.register = function (registerDetails) {
|
|
72
|
+
return this.client.post('/users', {
|
|
73
|
+
name: registerDetails.name,
|
|
74
|
+
captcha: registerDetails.captcha,
|
|
75
|
+
lastname: registerDetails.lastname,
|
|
76
|
+
email: registerDetails.email,
|
|
77
|
+
password: registerDetails.password,
|
|
78
|
+
mnemonic: registerDetails.mnemonic,
|
|
79
|
+
salt: registerDetails.salt,
|
|
80
|
+
/**
|
|
81
|
+
/ @deprecated The individual fields for keys should not be used
|
|
82
|
+
*/
|
|
83
|
+
privateKey: registerDetails.keys.privateKeyEncrypted,
|
|
84
|
+
publicKey: registerDetails.keys.publicKey,
|
|
85
|
+
revocationKey: registerDetails.keys.revocationCertificate,
|
|
86
|
+
keys: {
|
|
87
|
+
ecc: {
|
|
88
|
+
privateKey: registerDetails.keys.keys.ecc.privateKeyEncrypted,
|
|
89
|
+
publicKey: registerDetails.keys.keys.ecc.publicKey,
|
|
90
|
+
},
|
|
91
|
+
kyber: {
|
|
92
|
+
privateKey: registerDetails.keys.keys.kyber.privateKeyEncrypted,
|
|
93
|
+
publicKey: registerDetails.keys.keys.kyber.publicKey,
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
referral: registerDetails.referral,
|
|
97
|
+
referrer: registerDetails.referrer,
|
|
98
|
+
}, this.basicHeaders());
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Registers a precreated user
|
|
102
|
+
* @param registerDetails
|
|
103
|
+
* @returns {Promise<RegisterPreCreatedUserResponse>} Returns sign in token, user data and uuid.
|
|
104
|
+
*/
|
|
105
|
+
Auth.prototype.registerPreCreatedUser = function (registerDetails) {
|
|
106
|
+
return this.client.post('users/pre-created-users/register', {
|
|
107
|
+
name: registerDetails.name,
|
|
108
|
+
captcha: registerDetails.captcha,
|
|
109
|
+
lastname: registerDetails.lastname,
|
|
110
|
+
email: registerDetails.email,
|
|
111
|
+
password: registerDetails.password,
|
|
112
|
+
mnemonic: registerDetails.mnemonic,
|
|
113
|
+
salt: registerDetails.salt,
|
|
114
|
+
/**
|
|
115
|
+
/ @deprecated The individual fields for keys should not be used
|
|
116
|
+
*/
|
|
117
|
+
privateKey: registerDetails.keys.privateKeyEncrypted,
|
|
118
|
+
publicKey: registerDetails.keys.publicKey,
|
|
119
|
+
revocationKey: registerDetails.keys.revocationCertificate,
|
|
120
|
+
keys: {
|
|
121
|
+
ecc: {
|
|
122
|
+
privateKey: registerDetails.keys.keys.ecc.privateKeyEncrypted,
|
|
123
|
+
publicKey: registerDetails.keys.keys.ecc.publicKey,
|
|
124
|
+
},
|
|
125
|
+
kyber: {
|
|
126
|
+
privateKey: registerDetails.keys.keys.kyber.privateKeyEncrypted,
|
|
127
|
+
publicKey: registerDetails.keys.keys.kyber.publicKey,
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
referral: registerDetails.referral,
|
|
131
|
+
referrer: registerDetails.referrer,
|
|
132
|
+
invitationId: registerDetails.invitationId,
|
|
133
|
+
}, this.basicHeaders());
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Requests account unblock email
|
|
137
|
+
*
|
|
138
|
+
* @param {string} email - The email address associated with the account.
|
|
139
|
+
* @returns {Promise<void>} - Resolves when the email is sent.
|
|
140
|
+
*/
|
|
141
|
+
Auth.prototype.requestUnblockAccount = function (email) {
|
|
142
|
+
return this.client.post('users/unblock-account', {
|
|
143
|
+
email: email,
|
|
144
|
+
}, this.basicHeaders());
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Unblocks account with token
|
|
148
|
+
*
|
|
149
|
+
* @param {string} token - The token received via email to verify and unblock the account.
|
|
150
|
+
* @returns {Promise<void>} - Resolves successfuly when account is unblocked
|
|
151
|
+
*/
|
|
152
|
+
Auth.prototype.unblockAccount = function (token) {
|
|
153
|
+
return this.client.put('users/unblock-account', { token: token }, this.basicHeaders());
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Tries to log in a user given its login details
|
|
157
|
+
* @param details
|
|
158
|
+
* @param cryptoProvider
|
|
159
|
+
*/
|
|
160
|
+
Auth.prototype.login = function (details, cryptoProvider) {
|
|
161
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
162
|
+
var securityDetails, encryptedSalt, encryptedPasswordHash, keys;
|
|
163
|
+
return __generator(this, function (_a) {
|
|
164
|
+
switch (_a.label) {
|
|
165
|
+
case 0: return [4 /*yield*/, this.securityDetails(details.email)];
|
|
166
|
+
case 1:
|
|
167
|
+
securityDetails = _a.sent();
|
|
168
|
+
encryptedSalt = securityDetails.encryptedSalt;
|
|
169
|
+
return [4 /*yield*/, cryptoProvider.encryptPasswordHash(details.password, encryptedSalt)];
|
|
170
|
+
case 2:
|
|
171
|
+
encryptedPasswordHash = _a.sent();
|
|
172
|
+
return [4 /*yield*/, cryptoProvider.generateKeys(details.password)];
|
|
173
|
+
case 3:
|
|
174
|
+
keys = _a.sent();
|
|
175
|
+
return [2 /*return*/, this.client
|
|
176
|
+
.post('/access', {
|
|
177
|
+
email: details.email,
|
|
178
|
+
password: encryptedPasswordHash,
|
|
179
|
+
tfa: details.tfaCode,
|
|
180
|
+
/**
|
|
181
|
+
/ @deprecated The individual fields for keys should not be used
|
|
182
|
+
*/
|
|
183
|
+
privateKey: keys.privateKeyEncrypted,
|
|
184
|
+
publicKey: keys.publicKey,
|
|
185
|
+
revocateKey: keys.revocationCertificate,
|
|
186
|
+
keys: {
|
|
187
|
+
ecc: {
|
|
188
|
+
privateKey: keys.keys.ecc.privateKeyEncrypted,
|
|
189
|
+
publicKey: keys.keys.ecc.publicKey,
|
|
190
|
+
},
|
|
191
|
+
kyber: {
|
|
192
|
+
privateKey: keys.keys.kyber.privateKeyEncrypted,
|
|
193
|
+
publicKey: keys.keys.kyber.publicKey,
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
}, this.basicHeaders())
|
|
197
|
+
.then(function (data) {
|
|
198
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
199
|
+
// @ts-ignore
|
|
200
|
+
data.user.revocationKey = data.user.revocateKey; // TODO : remove when all projects use SDK
|
|
201
|
+
return data;
|
|
202
|
+
})];
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Updates the asymmetric keys
|
|
209
|
+
* @param keys
|
|
210
|
+
* @param token
|
|
211
|
+
*/
|
|
212
|
+
Auth.prototype.updateKeys = function (keys, token) {
|
|
213
|
+
return this.client.patch('/user/keys', {
|
|
214
|
+
/**
|
|
215
|
+
/ @deprecated The individual fields for keys should not be used
|
|
216
|
+
*/
|
|
217
|
+
publicKey: keys.publicKey,
|
|
218
|
+
privateKey: keys.privateKeyEncrypted,
|
|
219
|
+
revocationKey: keys.revocationCertificate,
|
|
220
|
+
keys: {
|
|
221
|
+
ecc: {
|
|
222
|
+
privateKey: keys.keys.ecc.privateKeyEncrypted,
|
|
223
|
+
publicKey: keys.keys.ecc.publicKey,
|
|
224
|
+
},
|
|
225
|
+
kyber: {
|
|
226
|
+
privateKey: keys.keys.kyber.privateKeyEncrypted,
|
|
227
|
+
publicKey: keys.keys.kyber.publicKey,
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
}, this.headersWithToken(token));
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* Returns general security details
|
|
234
|
+
* @param email
|
|
235
|
+
*/
|
|
236
|
+
Auth.prototype.securityDetails = function (email) {
|
|
237
|
+
return this.client
|
|
238
|
+
.post('/login', {
|
|
239
|
+
email: email,
|
|
240
|
+
}, this.basicHeaders())
|
|
241
|
+
.then(function (data) {
|
|
242
|
+
return {
|
|
243
|
+
encryptedSalt: data.sKey,
|
|
244
|
+
tfaEnabled: data.tfa === true,
|
|
245
|
+
};
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* Generates a new TwoFactorAuth code
|
|
250
|
+
*/
|
|
251
|
+
Auth.prototype.generateTwoFactorAuthQR = function () {
|
|
252
|
+
var _a;
|
|
253
|
+
return this.client
|
|
254
|
+
.get('/tfa', this.headersWithToken((_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token))
|
|
255
|
+
.then(function (data) {
|
|
256
|
+
return {
|
|
257
|
+
qr: data.qr,
|
|
258
|
+
backupKey: data.code,
|
|
259
|
+
};
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* Disables TwoFactorAuthentication
|
|
264
|
+
* @param pass
|
|
265
|
+
* @param code
|
|
266
|
+
*/
|
|
267
|
+
Auth.prototype.disableTwoFactorAuth = function (pass, code) {
|
|
268
|
+
var _a;
|
|
269
|
+
return this.client.delete('/tfa', this.headersWithToken((_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token), {
|
|
270
|
+
pass: pass,
|
|
271
|
+
code: code,
|
|
272
|
+
});
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* Store TwoFactorAuthentication details
|
|
276
|
+
* @param backupKey
|
|
277
|
+
* @param code
|
|
278
|
+
*/
|
|
279
|
+
Auth.prototype.storeTwoFactorAuthKey = function (backupKey, code) {
|
|
280
|
+
var _a;
|
|
281
|
+
return this.client.put('/tfa', {
|
|
282
|
+
key: backupKey,
|
|
283
|
+
code: code,
|
|
284
|
+
}, this.headersWithToken((_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token));
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* Sends request to send the email to delete the account
|
|
288
|
+
* @param email
|
|
289
|
+
*/
|
|
290
|
+
Auth.prototype.sendDeactivationEmail = function (email) {
|
|
291
|
+
return this.client.get("/deactivate/".concat(email), this.basicHeaders());
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* Confirms the account deactivation
|
|
295
|
+
* @param token
|
|
296
|
+
*/
|
|
297
|
+
Auth.prototype.confirmDeactivation = function (token) {
|
|
298
|
+
return this.client.get("/confirmDeactivation/".concat(token), this.basicHeaders());
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Checks if the password is correct for this email
|
|
302
|
+
* @param email
|
|
303
|
+
* @param hashedPassword
|
|
304
|
+
* @returns
|
|
305
|
+
*/
|
|
306
|
+
Auth.prototype.areCredentialsCorrect = function (email, hashedPassword) {
|
|
307
|
+
var _a;
|
|
308
|
+
// Uses fetch instead of httpClient since a 401 response
|
|
309
|
+
// would log out the user
|
|
310
|
+
return fetch("".concat(this.apiUrl, "/are-credentials-correct?email=").concat(email, "&hashedPassword=").concat(hashedPassword), {
|
|
311
|
+
headers: this.headersWithToken((_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token),
|
|
312
|
+
}).then(function (res) {
|
|
313
|
+
if (res.ok) {
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
else if (res.status === 401) {
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
else
|
|
320
|
+
throw new Error("Request failed with error ".concat(res.status));
|
|
321
|
+
});
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* Send email to change password
|
|
325
|
+
* @param email
|
|
326
|
+
*/
|
|
327
|
+
Auth.prototype.sendChangePasswordEmail = function (email) {
|
|
328
|
+
return this.client.post('/users/recover-account', {
|
|
329
|
+
email: email,
|
|
330
|
+
}, this.basicHeaders());
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* Upgrade hash in the database
|
|
334
|
+
* @param newHash
|
|
335
|
+
*/
|
|
336
|
+
Auth.prototype.upgradeHash = function (newHash) {
|
|
337
|
+
return this.client.patch('/users/:id', {
|
|
338
|
+
newPassword: newHash,
|
|
339
|
+
newSalt: '',
|
|
340
|
+
}, this.basicHeaders());
|
|
341
|
+
};
|
|
342
|
+
/**
|
|
343
|
+
* Restore password with email link
|
|
344
|
+
* @param token
|
|
345
|
+
* @param password
|
|
346
|
+
* @param salt
|
|
347
|
+
* @param mnemonic
|
|
348
|
+
*/
|
|
349
|
+
Auth.prototype.changePasswordWithLink = function (token, password, salt, mnemonic) {
|
|
350
|
+
return this.client.put("/users/recover-account?token=".concat(token, "&reset=false"), {
|
|
351
|
+
password: password,
|
|
352
|
+
salt: salt,
|
|
353
|
+
mnemonic: mnemonic,
|
|
354
|
+
}, this.basicHeaders());
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* Reset account with token
|
|
358
|
+
* @param token
|
|
359
|
+
* @param password
|
|
360
|
+
* @param salt
|
|
361
|
+
* @param mnemonic
|
|
362
|
+
*/
|
|
363
|
+
Auth.prototype.resetAccountWithToken = function (token, password, salt, mnemonic) {
|
|
364
|
+
return this.client.put("/users/recover-account?token=".concat(token, "&reset=true"), {
|
|
365
|
+
password: password,
|
|
366
|
+
salt: salt,
|
|
367
|
+
mnemonic: mnemonic,
|
|
368
|
+
}, this.basicHeaders());
|
|
369
|
+
};
|
|
370
|
+
Auth.prototype.basicHeaders = function () {
|
|
371
|
+
return (0, headers_1.basicHeaders)(this.appDetails.clientName, this.appDetails.clientVersion);
|
|
372
|
+
};
|
|
373
|
+
Auth.prototype.headersWithToken = function (token) {
|
|
374
|
+
return (0, headers_1.headersWithToken)(this.appDetails.clientName, this.appDetails.clientVersion, token);
|
|
375
|
+
};
|
|
376
|
+
return Auth;
|
|
377
|
+
}());
|
|
378
|
+
exports.Auth = Auth;
|