curtain-web-api 1.0.62 → 1.0.64
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/build/classes/curtain-api.d.ts +64 -2
- package/build/classes/curtain-api.js +342 -226
- package/build/classes/curtain-encryption.js +92 -166
- package/build/classes/curtain-user.js +4 -11
- package/build/index.d.ts +2 -2
- package/build/index.js +6 -36
- package/build/utilities.js +13 -53
- package/package.json +9 -1
- package/src/classes/curtain-api.ts +264 -4
- package/src/index.ts +17 -1
- package/tsconfig.json +4 -3
|
@@ -1,53 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.CurtainWebAPI = exports.reviver = exports.replacer = void 0;
|
|
46
|
-
const curtain_user_1 = require("./curtain-user");
|
|
47
|
-
const axios_1 = __importStar(require("axios"));
|
|
48
|
-
const curtain_encryption_1 = require("./curtain-encryption");
|
|
1
|
+
import { User } from "./curtain-user";
|
|
2
|
+
import axios, { AxiosHeaders } from "axios";
|
|
3
|
+
import { arrayBufferToBase64String, base64ToArrayBuffer, encryptAESData, encryptAESKey, exportAESKey, generateAESKey } from "./curtain-encryption";
|
|
49
4
|
const base = "https://celsus.muttsu.xyz/";
|
|
50
|
-
const replacer = (key, value) => {
|
|
5
|
+
export const replacer = (key, value) => {
|
|
51
6
|
if (value instanceof Map) {
|
|
52
7
|
return {
|
|
53
8
|
dataType: 'Map',
|
|
@@ -58,8 +13,7 @@ const replacer = (key, value) => {
|
|
|
58
13
|
return value;
|
|
59
14
|
}
|
|
60
15
|
};
|
|
61
|
-
|
|
62
|
-
const reviver = (key, value) => {
|
|
16
|
+
export const reviver = (key, value) => {
|
|
63
17
|
if (typeof value === 'object' && value !== null) {
|
|
64
18
|
if (value.dataType === 'Map') {
|
|
65
19
|
return new Map(value.value);
|
|
@@ -67,8 +21,7 @@ const reviver = (key, value) => {
|
|
|
67
21
|
}
|
|
68
22
|
return value;
|
|
69
23
|
};
|
|
70
|
-
|
|
71
|
-
class CurtainWebAPI {
|
|
24
|
+
export class CurtainWebAPI {
|
|
72
25
|
constructor(baseURL = base) {
|
|
73
26
|
this.loginURL = "";
|
|
74
27
|
this.logoutURL = "";
|
|
@@ -77,9 +30,9 @@ class CurtainWebAPI {
|
|
|
77
30
|
this.userInfoURL = "";
|
|
78
31
|
this.curtainURL = "";
|
|
79
32
|
this.dataciteURL = "";
|
|
80
|
-
this.user = new
|
|
33
|
+
this.user = new User();
|
|
81
34
|
this.isRefreshing = false;
|
|
82
|
-
this.axiosInstance =
|
|
35
|
+
this.axiosInstance = axios.create();
|
|
83
36
|
this.baseURL = base;
|
|
84
37
|
this.baseURL = baseURL;
|
|
85
38
|
this.loginURL = baseURL + "token/";
|
|
@@ -143,7 +96,7 @@ class CurtainWebAPI {
|
|
|
143
96
|
return this.axiosInstance.request(error.config);
|
|
144
97
|
}).catch((error) => {
|
|
145
98
|
this.isRefreshing = false;
|
|
146
|
-
this.user = new
|
|
99
|
+
this.user = new User();
|
|
147
100
|
return error;
|
|
148
101
|
});
|
|
149
102
|
}
|
|
@@ -154,7 +107,7 @@ class CurtainWebAPI {
|
|
|
154
107
|
});
|
|
155
108
|
}
|
|
156
109
|
login(username, password) {
|
|
157
|
-
let headers = new
|
|
110
|
+
let headers = new AxiosHeaders();
|
|
158
111
|
headers["Accept"] = "application/json";
|
|
159
112
|
headers["Content-Type"] = "application/json";
|
|
160
113
|
headers["withCredentials"] = "true";
|
|
@@ -166,7 +119,7 @@ class CurtainWebAPI {
|
|
|
166
119
|
});
|
|
167
120
|
}
|
|
168
121
|
getUserInfo() {
|
|
169
|
-
const headers = new
|
|
122
|
+
const headers = new AxiosHeaders();
|
|
170
123
|
headers["Accept"] = "application/json";
|
|
171
124
|
headers["Content-Type"] = "application/json";
|
|
172
125
|
console.log(this.user);
|
|
@@ -185,7 +138,7 @@ class CurtainWebAPI {
|
|
|
185
138
|
});
|
|
186
139
|
}
|
|
187
140
|
logout() {
|
|
188
|
-
let headers = new
|
|
141
|
+
let headers = new AxiosHeaders();
|
|
189
142
|
headers["Accept"] = "application/json";
|
|
190
143
|
headers["Content-Type"] = "application/json";
|
|
191
144
|
return this.axiosInstance.post(this.logoutURL, { refresh_token: this.user.refresh_token }, { headers: headers, responseType: "json" }).then((response) => {
|
|
@@ -194,7 +147,7 @@ class CurtainWebAPI {
|
|
|
194
147
|
}
|
|
195
148
|
refresh() {
|
|
196
149
|
this.isRefreshing = true;
|
|
197
|
-
let headers = new
|
|
150
|
+
let headers = new AxiosHeaders();
|
|
198
151
|
headers["Accept"] = "application/json";
|
|
199
152
|
headers["Content-Type"] = "application/json";
|
|
200
153
|
return this.axiosInstance.post(this.refereshURL, { refresh: this.user.refresh_token }, { headers: headers, responseType: "json" }).then((response) => {
|
|
@@ -204,7 +157,7 @@ class CurtainWebAPI {
|
|
|
204
157
|
});
|
|
205
158
|
}
|
|
206
159
|
ORCIDLogin(authorizationCode, redirectURI) {
|
|
207
|
-
let headers = new
|
|
160
|
+
let headers = new AxiosHeaders();
|
|
208
161
|
headers["Accept"] = "application/json";
|
|
209
162
|
headers["Content-Type"] = "application/json";
|
|
210
163
|
return this.user.loadFromDB().then((response) => {
|
|
@@ -224,81 +177,82 @@ class CurtainWebAPI {
|
|
|
224
177
|
return 24 <= Math.abs(Math.round(diff));
|
|
225
178
|
}
|
|
226
179
|
deleteCurtainLink(curtainLinkID) {
|
|
227
|
-
let headers = new
|
|
180
|
+
let headers = new AxiosHeaders();
|
|
228
181
|
headers["Accept"] = "application/json";
|
|
229
182
|
headers["Content-Type"] = "application/json";
|
|
230
183
|
return this.axiosInstance.delete(this.baseURL + "curtain/" + curtainLinkID + "/", { headers: headers, responseType: "json" }).then((response) => {
|
|
231
184
|
return response;
|
|
232
185
|
});
|
|
233
186
|
}
|
|
234
|
-
putSettings(
|
|
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
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
form.append("
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
187
|
+
async putSettings(settings, enable = true, description = "", sessionType = "TP", encryption = {
|
|
188
|
+
encrypted: false,
|
|
189
|
+
e2e: false,
|
|
190
|
+
}, permanent = false, expiry_duration, onUploadProgress = undefined) {
|
|
191
|
+
let form = new FormData();
|
|
192
|
+
let data = JSON.stringify(settings, replacer);
|
|
193
|
+
if (enable) {
|
|
194
|
+
form.append("enable", "True");
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
form.append("enable", "False");
|
|
198
|
+
}
|
|
199
|
+
if (encryption.encrypted) {
|
|
200
|
+
form.append("encrypted", "True");
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
form.append("encrypted", "False");
|
|
204
|
+
}
|
|
205
|
+
if (encryption.e2e) {
|
|
206
|
+
form.append("e2e", "True");
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
form.append("e2e", "False");
|
|
210
|
+
}
|
|
211
|
+
if (permanent) {
|
|
212
|
+
form.append("permanent", "True");
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
form.append("permanent", "False");
|
|
216
|
+
}
|
|
217
|
+
if (expiry_duration !== undefined) {
|
|
218
|
+
form.append("expiry_duration", expiry_duration.toString());
|
|
219
|
+
}
|
|
220
|
+
if (encryption.encrypted && encryption.e2e && encryption.publicKey !== undefined) {
|
|
221
|
+
const aesKey = await generateAESKey();
|
|
222
|
+
console.log("Encrypting data");
|
|
223
|
+
const encryptedData = await encryptAESData(aesKey, data);
|
|
224
|
+
const encryptedKey = await encryptAESKey(encryption.publicKey, await exportAESKey(aesKey));
|
|
225
|
+
console.log(encryptedKey);
|
|
226
|
+
const encryptedIV = await encryptAESKey(encryption.publicKey, base64ToArrayBuffer(encryptedData.iv));
|
|
227
|
+
console.log(encryptedIV);
|
|
228
|
+
const payload = {
|
|
229
|
+
encryptedData: encryptedData.encrypted,
|
|
230
|
+
encryptedKey: arrayBufferToBase64String(encryptedKey),
|
|
231
|
+
encryptedIV: arrayBufferToBase64String(encryptedIV)
|
|
232
|
+
};
|
|
233
|
+
console.log(payload);
|
|
234
|
+
form.append("encryptedKey", payload.encryptedKey);
|
|
235
|
+
form.append("encryptedIV", payload.encryptedIV);
|
|
236
|
+
form.append("file", new Blob([payload.encryptedData], { type: 'text/json' }), "curtain-settings.json");
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
form.append("file", new Blob([data], { type: 'text/json' }), "curtain-settings.json");
|
|
240
|
+
}
|
|
241
|
+
form.append("description", description);
|
|
242
|
+
form.append("curtain_type", sessionType);
|
|
243
|
+
let headers = new AxiosHeaders();
|
|
244
|
+
headers["Accept"] = "application/json";
|
|
245
|
+
headers["Content-Type"] = "multipart/form-data";
|
|
246
|
+
console.log(form);
|
|
247
|
+
if (onUploadProgress !== undefined) {
|
|
248
|
+
return await this.axiosInstance.post(this.baseURL + "curtain/", form, { headers: headers, responseType: "json", onUploadProgress: onUploadProgress });
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
return await this.axiosInstance.post(this.baseURL + "curtain/", form, { headers: headers, responseType: "json" });
|
|
252
|
+
}
|
|
299
253
|
}
|
|
300
254
|
postSettings(id, token, onDownloadProgress = undefined, url = undefined) {
|
|
301
|
-
let headers = new
|
|
255
|
+
let headers = new AxiosHeaders();
|
|
302
256
|
headers["Accept"] = "application/json";
|
|
303
257
|
if (url !== undefined) {
|
|
304
258
|
return this.axiosInstance.get(url, { responseType: "json" }).then((response) => {
|
|
@@ -329,88 +283,89 @@ class CurtainWebAPI {
|
|
|
329
283
|
});
|
|
330
284
|
}
|
|
331
285
|
getPrideData(accession) {
|
|
332
|
-
let headers = new
|
|
286
|
+
let headers = new AxiosHeaders();
|
|
333
287
|
headers["Accept"] = "application/json";
|
|
334
|
-
return
|
|
288
|
+
return axios.get("https://www.ebi.ac.uk/pride/ws/archive/v2/projects/" + accession, { responseType: "json" }).then((response) => {
|
|
335
289
|
return response;
|
|
336
290
|
});
|
|
337
291
|
}
|
|
338
292
|
generateTemporarySession(linkId, lifetime) {
|
|
339
|
-
let headers = new
|
|
293
|
+
let headers = new AxiosHeaders();
|
|
340
294
|
headers["Accept"] = "application/json";
|
|
341
295
|
headers["Content-Type"] = "application/json";
|
|
342
296
|
return this.axiosInstance.post(this.baseURL + "curtain/" + linkId + "/generate_token/", { lifetime: lifetime }, { headers: headers, responseType: "json" }).then((response) => {
|
|
343
297
|
return response;
|
|
344
298
|
});
|
|
345
299
|
}
|
|
346
|
-
updateSession(
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
form.append("file", new Blob([payload.encryptedData], { type: 'text/json' }), "curtain-settings.json");
|
|
367
|
-
}
|
|
368
|
-
else {
|
|
369
|
-
form.append("file", new Blob([data], { type: 'text/json' }), "curtain-settings.json");
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
if ("enable" in sessionData) {
|
|
373
|
-
if (sessionData["enable"]) {
|
|
374
|
-
form.append("enable", "True");
|
|
375
|
-
}
|
|
376
|
-
else {
|
|
377
|
-
form.append("enable", "False");
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
if (encryption.encrypted) {
|
|
381
|
-
form.append("encrypted", "True");
|
|
300
|
+
async updateSession(sessionData, linkId, encryption = {
|
|
301
|
+
encrypted: false,
|
|
302
|
+
e2e: false,
|
|
303
|
+
}) {
|
|
304
|
+
let form = new FormData();
|
|
305
|
+
if ("file" in sessionData) {
|
|
306
|
+
let data = JSON.stringify(sessionData["file"], replacer);
|
|
307
|
+
if (encryption.encrypted && encryption.e2e && encryption.publicKey !== undefined) {
|
|
308
|
+
const aesKey = await generateAESKey();
|
|
309
|
+
const encryptedData = await encryptAESData(aesKey, data);
|
|
310
|
+
const encryptedKey = await encryptAESKey(encryption.publicKey, await exportAESKey(aesKey));
|
|
311
|
+
const encryptedIV = await encryptAESKey(encryption.publicKey, base64ToArrayBuffer(encryptedData.iv));
|
|
312
|
+
const payload = {
|
|
313
|
+
encryptedData: encryptedData.encrypted,
|
|
314
|
+
encryptedKey: arrayBufferToBase64String(encryptedKey),
|
|
315
|
+
encryptedIV: arrayBufferToBase64String(encryptedIV)
|
|
316
|
+
};
|
|
317
|
+
form.append("encryptedKey", payload.encryptedKey);
|
|
318
|
+
form.append("encryptedIV", payload.encryptedIV);
|
|
319
|
+
form.append("file", new Blob([payload.encryptedData], { type: 'text/json' }), "curtain-settings.json");
|
|
382
320
|
}
|
|
383
321
|
else {
|
|
384
|
-
form.append("
|
|
322
|
+
form.append("file", new Blob([data], { type: 'text/json' }), "curtain-settings.json");
|
|
385
323
|
}
|
|
386
|
-
|
|
387
|
-
|
|
324
|
+
}
|
|
325
|
+
if ("enable" in sessionData) {
|
|
326
|
+
if (sessionData["enable"]) {
|
|
327
|
+
form.append("enable", "True");
|
|
388
328
|
}
|
|
389
329
|
else {
|
|
390
|
-
form.append("
|
|
330
|
+
form.append("enable", "False");
|
|
391
331
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
332
|
+
}
|
|
333
|
+
if ("expiry_duration" in sessionData) {
|
|
334
|
+
form.append("expiry_duration", sessionData["expiry_duration"].toString());
|
|
335
|
+
}
|
|
336
|
+
if (encryption.encrypted) {
|
|
337
|
+
form.append("encrypted", "True");
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
form.append("encrypted", "False");
|
|
341
|
+
}
|
|
342
|
+
if (encryption.e2e) {
|
|
343
|
+
form.append("e2e", "True");
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
form.append("e2e", "False");
|
|
347
|
+
}
|
|
348
|
+
let headers = new AxiosHeaders();
|
|
349
|
+
headers["Accept"] = "application/json";
|
|
350
|
+
headers["Content-Type"] = "multipart/form-data";
|
|
351
|
+
return this.axiosInstance.patch(this.baseURL + "curtain/" + linkId + "/", form, { responseType: "json" });
|
|
397
352
|
}
|
|
398
353
|
getSessionSettings(linkId) {
|
|
399
|
-
let headers = new
|
|
354
|
+
let headers = new AxiosHeaders();
|
|
400
355
|
headers["Accept"] = "application/json";
|
|
401
356
|
return this.axiosInstance.get(this.baseURL + "curtain/" + linkId + "/", { headers: headers, responseType: "json" }).then((response) => {
|
|
402
357
|
return response;
|
|
403
358
|
});
|
|
404
359
|
}
|
|
405
360
|
getOwnership(linkId) {
|
|
406
|
-
let headers = new
|
|
361
|
+
let headers = new AxiosHeaders();
|
|
407
362
|
headers["Accept"] = "application/json";
|
|
408
363
|
return this.axiosInstance.get(this.baseURL + "curtain/" + linkId + "/get_ownership/", { headers: headers, responseType: "json" }).then((response) => {
|
|
409
364
|
return response;
|
|
410
365
|
});
|
|
411
366
|
}
|
|
412
367
|
getOwners(linkId) {
|
|
413
|
-
let headers = new
|
|
368
|
+
let headers = new AxiosHeaders();
|
|
414
369
|
headers["Accept"] = "application/json";
|
|
415
370
|
return this.axiosInstance.get(this.baseURL + "curtain/" + linkId + "/get_owners/", { headers: headers, responseType: "json" }).then((response) => {
|
|
416
371
|
return response;
|
|
@@ -419,7 +374,7 @@ class CurtainWebAPI {
|
|
|
419
374
|
addOwner(linkId, owner) {
|
|
420
375
|
let form = new FormData();
|
|
421
376
|
form.append("username", owner);
|
|
422
|
-
let headers = new
|
|
377
|
+
let headers = new AxiosHeaders();
|
|
423
378
|
headers["Accept"] = "application/json";
|
|
424
379
|
headers["Content-Type"] = "multipart/form-data";
|
|
425
380
|
return this.axiosInstance.patch(this.baseURL + "curtain/" + linkId + "/add_owner/", form, { headers: headers, responseType: "json" }).then((response) => {
|
|
@@ -427,7 +382,7 @@ class CurtainWebAPI {
|
|
|
427
382
|
});
|
|
428
383
|
}
|
|
429
384
|
getCurtainLinks(username, sessionDescription = "", offset = 0, sessionType = "TP") {
|
|
430
|
-
let headers = new
|
|
385
|
+
let headers = new AxiosHeaders();
|
|
431
386
|
headers["Accept"] = "application/json";
|
|
432
387
|
let params = new URLSearchParams();
|
|
433
388
|
params.append("username", username);
|
|
@@ -440,14 +395,12 @@ class CurtainWebAPI {
|
|
|
440
395
|
});
|
|
441
396
|
}
|
|
442
397
|
getSiteProperties() {
|
|
443
|
-
let headers = new
|
|
398
|
+
let headers = new AxiosHeaders();
|
|
444
399
|
headers["Accept"] = "application/json";
|
|
445
|
-
return this.axiosInstance.get(this.baseURL + "site-properties/", { headers: headers, responseType: "json" })
|
|
446
|
-
return response;
|
|
447
|
-
});
|
|
400
|
+
return this.axiosInstance.get(this.baseURL + "site-properties/", { headers: headers, responseType: "json" });
|
|
448
401
|
}
|
|
449
402
|
saveDataFilterList(name, data, category = "") {
|
|
450
|
-
let headers = new
|
|
403
|
+
let headers = new AxiosHeaders();
|
|
451
404
|
headers["Accept"] = "application/json";
|
|
452
405
|
headers["Content-Type"] = "application/json";
|
|
453
406
|
return this.axiosInstance.post(this.baseURL + "data_filter_list/", { name: name, data: data, category: category }, { headers: headers, responseType: "json" }).then((response) => {
|
|
@@ -455,7 +408,7 @@ class CurtainWebAPI {
|
|
|
455
408
|
});
|
|
456
409
|
}
|
|
457
410
|
getDataFilterListByID(id, limit = 100) {
|
|
458
|
-
let headers = new
|
|
411
|
+
let headers = new AxiosHeaders();
|
|
459
412
|
headers["Accept"] = "application/json";
|
|
460
413
|
let params = { limit: limit.toString() };
|
|
461
414
|
return this.axiosInstance.get(this.baseURL + "data_filter_list/" + id + "/", { headers: headers, responseType: "json", }).then((response) => {
|
|
@@ -483,14 +436,14 @@ class CurtainWebAPI {
|
|
|
483
436
|
return this.axiosInstance.get(this.baseURL + "data_filter_list/", { responseType: "json", params });
|
|
484
437
|
}
|
|
485
438
|
deleteDataFilterList(id) {
|
|
486
|
-
let headers = new
|
|
439
|
+
let headers = new AxiosHeaders();
|
|
487
440
|
headers["Accept"] = "application/json";
|
|
488
441
|
return this.axiosInstance.delete(this.baseURL + "data_filter_list/" + id + "/", { headers: headers, responseType: "json" }).then((response) => {
|
|
489
442
|
return response;
|
|
490
443
|
});
|
|
491
444
|
}
|
|
492
445
|
updateDataFilterList(id, name, data, category) {
|
|
493
|
-
let headers = new
|
|
446
|
+
let headers = new AxiosHeaders();
|
|
494
447
|
headers["Accept"] = "application/json";
|
|
495
448
|
headers["Content-Type"] = "application/json";
|
|
496
449
|
const updateData = {};
|
|
@@ -505,9 +458,9 @@ class CurtainWebAPI {
|
|
|
505
458
|
});
|
|
506
459
|
}
|
|
507
460
|
downloadStats() {
|
|
508
|
-
let headers = new
|
|
461
|
+
let headers = new AxiosHeaders();
|
|
509
462
|
headers["Accept"] = "application/json";
|
|
510
|
-
return
|
|
463
|
+
return axios.get(this.baseURL + "stats/download/", { headers: headers, responseType: "json" }).then((response) => {
|
|
511
464
|
return response;
|
|
512
465
|
});
|
|
513
466
|
}
|
|
@@ -522,89 +475,87 @@ class CurtainWebAPI {
|
|
|
522
475
|
searchTermArray.push("search_term_array%5B%5D=" + g);
|
|
523
476
|
}
|
|
524
477
|
const data = "http://www.interactome-atlas.org/search_results_interactions?" + params.toString() + "&" + searchTermArray.join("&");
|
|
525
|
-
let headers = new
|
|
478
|
+
let headers = new AxiosHeaders();
|
|
526
479
|
headers["Accept"] = "application/json";
|
|
527
480
|
headers["Content-Type"] = "application/json";
|
|
528
|
-
return
|
|
481
|
+
return axios.post(this.baseURL + "interactome-atlas-proxy/", { link: data }, { headers: headers, responseType: "json" }).then((response) => {
|
|
529
482
|
return response;
|
|
530
483
|
});
|
|
531
484
|
}
|
|
532
485
|
postPrimitiveStatsTest(data, type = "t-test") {
|
|
533
|
-
let headers = new
|
|
486
|
+
let headers = new AxiosHeaders();
|
|
534
487
|
headers["Accept"] = "application/json";
|
|
535
488
|
headers["Content-Type"] = "application/json";
|
|
536
|
-
return
|
|
489
|
+
return axios.post(this.baseURL + "primitive-stats-test/", { data, type }).then((response) => {
|
|
537
490
|
return response;
|
|
538
491
|
});
|
|
539
492
|
}
|
|
540
493
|
getDataAllListCategory() {
|
|
541
|
-
let headers = new
|
|
494
|
+
let headers = new AxiosHeaders();
|
|
542
495
|
headers["Accept"] = "application/json";
|
|
543
496
|
headers["Content-Type"] = "application/json";
|
|
544
|
-
return
|
|
497
|
+
return axios.get(this.baseURL + "data_filter_list/get_all_category/", { headers: headers, responseType: "json" }).then((response) => { return response; });
|
|
545
498
|
}
|
|
546
499
|
postCompareSession(idList, matchType, studyList, sessionId) {
|
|
547
|
-
let headers = new
|
|
500
|
+
let headers = new AxiosHeaders();
|
|
548
501
|
headers["Accept"] = "application/json";
|
|
549
502
|
headers["Content-Type"] = "application/json";
|
|
550
|
-
return
|
|
503
|
+
return axios.post(this.baseURL + "compare-session/", { matchType, studyList, idList, sessionId }, { headers: headers, responseType: "json" }).then((response) => { return response; });
|
|
551
504
|
}
|
|
552
505
|
getStatsSummary(lastNDays) {
|
|
553
|
-
let headers = new
|
|
506
|
+
let headers = new AxiosHeaders();
|
|
554
507
|
headers["Accept"] = "application/json";
|
|
555
508
|
headers["Content-Type"] = "application/json";
|
|
556
509
|
return this.axiosInstance.get(this.baseURL + `stats/summary/${lastNDays}/`, { responseType: "json", headers });
|
|
557
510
|
}
|
|
558
511
|
postEncryptionFactors(encryptedAESKey, encryptedIV, linkId) {
|
|
559
|
-
let headers = new
|
|
512
|
+
let headers = new AxiosHeaders();
|
|
560
513
|
headers["Accept"] = "application/json";
|
|
561
514
|
headers["Content-Type"] = "application/json";
|
|
562
515
|
return this.axiosInstance.post(this.baseURL + "curtain/" + linkId + "/set_encryption_factors/", { encryption_key: encryptedAESKey, encryption_iv: encryptedIV }, { headers: headers, responseType: "json" }).then((response) => { return response; });
|
|
563
516
|
}
|
|
564
|
-
getEncryptionFactors(linkId) {
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
return yield this.axiosInstance.get(this.baseURL + "curtain/" + linkId + "/get_encryption_factors/", { headers: headers, responseType: "json" });
|
|
570
|
-
});
|
|
517
|
+
async getEncryptionFactors(linkId) {
|
|
518
|
+
let headers = new AxiosHeaders();
|
|
519
|
+
headers["Accept"] = "application/json";
|
|
520
|
+
headers["Content-Type"] = "application/json";
|
|
521
|
+
return await this.axiosInstance.get(this.baseURL + "curtain/" + linkId + "/get_encryption_factors/", { headers: headers, responseType: "json" });
|
|
571
522
|
}
|
|
572
523
|
createCurtainAPIKey(name) {
|
|
573
|
-
let headers = new
|
|
524
|
+
let headers = new AxiosHeaders();
|
|
574
525
|
headers["Accept"] = "application/json";
|
|
575
526
|
headers["Content-Type"] = "application/json";
|
|
576
527
|
return this.axiosInstance.post(this.baseURL + "api_key/", { name: name }, { headers: headers, responseType: "json" });
|
|
577
528
|
}
|
|
578
529
|
getCurtainAPIKeys() {
|
|
579
|
-
let headers = new
|
|
530
|
+
let headers = new AxiosHeaders();
|
|
580
531
|
headers["Accept"] = "application/json";
|
|
581
532
|
headers["Content-Type"] = "application/json";
|
|
582
533
|
return this.axiosInstance.get(this.baseURL + "api_key/", { headers: headers, responseType: "json" });
|
|
583
534
|
}
|
|
584
535
|
deleteCurtainAPIKey(id) {
|
|
585
|
-
let headers = new
|
|
536
|
+
let headers = new AxiosHeaders();
|
|
586
537
|
headers["Accept"] = "application/json";
|
|
587
538
|
headers["Content-Type"] = "application/json";
|
|
588
539
|
return this.axiosInstance.delete(this.baseURL + "api_key/" + id + "/", { headers: headers, responseType: "json" });
|
|
589
540
|
}
|
|
590
541
|
getRandomDataCiteSuffix() {
|
|
591
|
-
let headers = new
|
|
542
|
+
let headers = new AxiosHeaders();
|
|
592
543
|
headers["Accept"] = "application/json";
|
|
593
544
|
return this.axiosInstance.get(this.baseURL + "datacite/get_random_suffix/", { headers: headers, responseType: "json" });
|
|
594
545
|
}
|
|
595
546
|
submitDataCite(data) {
|
|
596
|
-
let headers = new
|
|
547
|
+
let headers = new AxiosHeaders();
|
|
597
548
|
headers["Accept"] = "application/json";
|
|
598
549
|
headers["Content-Type"] = "application/json";
|
|
599
550
|
return this.axiosInstance.post(this.baseURL + "datacite/", data, { headers: headers, responseType: "json" });
|
|
600
551
|
}
|
|
601
552
|
getDataCite(id) {
|
|
602
|
-
let headers = new
|
|
553
|
+
let headers = new AxiosHeaders();
|
|
603
554
|
headers["Accept"] = "application/json";
|
|
604
555
|
return this.axiosInstance.get(this.baseURL + "datacite/" + id + "/", { headers: headers, responseType: "json" });
|
|
605
556
|
}
|
|
606
557
|
getDataCites(url, title, status, limit = 10, offset = 0, manage = false, curtain_type = "TP") {
|
|
607
|
-
let headers = new
|
|
558
|
+
let headers = new AxiosHeaders();
|
|
608
559
|
headers["Accept"] = "application/json";
|
|
609
560
|
let params = new URLSearchParams();
|
|
610
561
|
if (url !== undefined) {
|
|
@@ -627,59 +578,224 @@ class CurtainWebAPI {
|
|
|
627
578
|
return this.axiosInstance.get(this.baseURL + "datacite/", { headers: headers, params: params, responseType: "json" });
|
|
628
579
|
}
|
|
629
580
|
getDataCiteTimeLimitedPermissionToken(suffix) {
|
|
630
|
-
let headers = new
|
|
581
|
+
let headers = new AxiosHeaders();
|
|
631
582
|
headers["Accept"] = "application/json";
|
|
632
583
|
return this.axiosInstance.get(this.baseURL + "datacite/get_time_limited_permission_token/?suffix=" + suffix, { headers: headers, responseType: "json" });
|
|
633
584
|
}
|
|
634
585
|
getDataCiteProxyOrcidPublicRecord(orcid) {
|
|
635
|
-
let headers = new
|
|
586
|
+
let headers = new AxiosHeaders();
|
|
636
587
|
headers["Accept"] = "application/json";
|
|
637
588
|
return this.axiosInstance.get(this.baseURL + "datacite/proxy_orcid/?orcid=" + orcid, { headers: headers, responseType: "json" });
|
|
638
589
|
}
|
|
639
590
|
getDataCiteQuota() {
|
|
640
|
-
let headers = new
|
|
591
|
+
let headers = new AxiosHeaders();
|
|
641
592
|
headers["Accept"] = "application/json";
|
|
642
593
|
return this.axiosInstance.get(this.baseURL + "datacite/get_quota/", { headers: headers, responseType: "json" });
|
|
643
594
|
}
|
|
644
595
|
updateDataCite(id, data) {
|
|
645
|
-
let headers = new
|
|
596
|
+
let headers = new AxiosHeaders();
|
|
646
597
|
headers["Accept"] = "application/json";
|
|
647
598
|
headers["Content-Type"] = "application/json";
|
|
648
599
|
return this.axiosInstance.post(this.baseURL + "datacite/" + id + "/", data, { headers: headers, responseType: "json" });
|
|
649
600
|
}
|
|
650
601
|
deleteDataCite(id) {
|
|
651
|
-
let headers = new
|
|
602
|
+
let headers = new AxiosHeaders();
|
|
652
603
|
headers["Accept"] = "application/json";
|
|
653
604
|
return this.axiosInstance.delete(this.baseURL + "datacite/" + id + "/", { headers: headers, responseType: "json" });
|
|
654
605
|
}
|
|
655
606
|
changeDataCiteStatus(id, status) {
|
|
656
|
-
let headers = new
|
|
607
|
+
let headers = new AxiosHeaders();
|
|
657
608
|
headers["Accept"] = "application/json";
|
|
658
609
|
headers["Content-Type"] = "application/json";
|
|
659
610
|
return this.axiosInstance.post(this.baseURL + "datacite/" + id + "/change_status/", { status: status }, { headers: headers, responseType: "json" });
|
|
660
611
|
}
|
|
661
612
|
lockDataCite(id, lock) {
|
|
662
|
-
let headers = new
|
|
613
|
+
let headers = new AxiosHeaders();
|
|
663
614
|
headers["Accept"] = "application/json";
|
|
664
615
|
headers["Content-Type"] = "application/json";
|
|
665
616
|
return this.axiosInstance.post(this.baseURL + "datacite/" + id + "/lock/", { lock: lock }, { headers: headers, responseType: "json" });
|
|
666
617
|
}
|
|
667
618
|
getKinaseLibraryProxy(sequence) {
|
|
668
|
-
let headers = new
|
|
619
|
+
let headers = new AxiosHeaders();
|
|
669
620
|
headers["Accept"] = "application/json";
|
|
670
621
|
let params = new URLSearchParams();
|
|
671
622
|
params.append("sequence", sequence);
|
|
672
623
|
return this.axiosInstance.get(this.baseURL + "kinase_library_proxy/", { headers: headers, params: params, responseType: "json" });
|
|
673
624
|
}
|
|
674
625
|
getJobResult(job_id) {
|
|
675
|
-
let headers = new
|
|
626
|
+
let headers = new AxiosHeaders();
|
|
676
627
|
headers["Accept"] = "application/json";
|
|
677
628
|
return this.axiosInstance.get(this.baseURL + "job/" + job_id + "/", { headers: headers, responseType: "json" });
|
|
678
629
|
}
|
|
679
630
|
getDataCiteFile(datacite_id) {
|
|
680
|
-
let headers = new
|
|
631
|
+
let headers = new AxiosHeaders();
|
|
681
632
|
headers["Accept"] = "application/json";
|
|
682
633
|
return this.axiosInstance.get(this.baseURL + "datacite/file/" + datacite_id + "/", { headers: headers, responseType: "blob" });
|
|
683
634
|
}
|
|
635
|
+
uploadCurtainChunk(request, uploadId, offset, totalSize) {
|
|
636
|
+
const formData = new FormData();
|
|
637
|
+
formData.append('file', request.file);
|
|
638
|
+
if (request.filename) {
|
|
639
|
+
formData.append('filename', request.filename);
|
|
640
|
+
}
|
|
641
|
+
if (request.upload_session_id) {
|
|
642
|
+
formData.append('upload_session_id', request.upload_session_id);
|
|
643
|
+
}
|
|
644
|
+
if (request.description) {
|
|
645
|
+
formData.append('description', request.description);
|
|
646
|
+
}
|
|
647
|
+
if (request.curtain_type) {
|
|
648
|
+
formData.append('curtain_type', request.curtain_type);
|
|
649
|
+
}
|
|
650
|
+
if (request.permanent !== undefined) {
|
|
651
|
+
formData.append('permanent', request.permanent.toString());
|
|
652
|
+
}
|
|
653
|
+
if (request.encrypted !== undefined) {
|
|
654
|
+
formData.append('encrypted', request.encrypted.toString());
|
|
655
|
+
}
|
|
656
|
+
if (request.expiry_duration !== undefined) {
|
|
657
|
+
formData.append('expiry_duration', request.expiry_duration.toString());
|
|
658
|
+
}
|
|
659
|
+
if (request.enable !== undefined) {
|
|
660
|
+
formData.append('enable', request.enable.toString());
|
|
661
|
+
}
|
|
662
|
+
const url = uploadId
|
|
663
|
+
? `${this.baseURL}curtain-chunked-upload/${uploadId}/`
|
|
664
|
+
: `${this.baseURL}curtain-chunked-upload/`;
|
|
665
|
+
const headers = new AxiosHeaders();
|
|
666
|
+
headers["Accept"] = "application/json";
|
|
667
|
+
const isChunkedUpload = offset !== undefined && totalSize !== undefined;
|
|
668
|
+
if (isChunkedUpload && offset !== undefined && totalSize !== undefined) {
|
|
669
|
+
const chunkEnd = offset + request.file.size - 1;
|
|
670
|
+
headers["Content-Range"] = `bytes ${offset}-${chunkEnd}/${totalSize}`;
|
|
671
|
+
}
|
|
672
|
+
if (isChunkedUpload || uploadId) {
|
|
673
|
+
return this.axiosInstance.put(url, formData, { headers: headers });
|
|
674
|
+
}
|
|
675
|
+
else {
|
|
676
|
+
return this.axiosInstance.post(url, formData, { headers: headers });
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
getCurtainUploadStatus(uploadId) {
|
|
680
|
+
let headers = new AxiosHeaders();
|
|
681
|
+
headers["Accept"] = "application/json";
|
|
682
|
+
return this.axiosInstance.get(`${this.baseURL}curtain-chunked-upload/${uploadId}/`, { headers: headers });
|
|
683
|
+
}
|
|
684
|
+
completeCurtainUpload(uploadId, request) {
|
|
685
|
+
const formData = new FormData();
|
|
686
|
+
if (request?.md5) {
|
|
687
|
+
formData.append('md5', request.md5);
|
|
688
|
+
}
|
|
689
|
+
if (request?.description) {
|
|
690
|
+
formData.append('description', request.description);
|
|
691
|
+
}
|
|
692
|
+
if (request?.curtain_type) {
|
|
693
|
+
formData.append('curtain_type', request.curtain_type);
|
|
694
|
+
}
|
|
695
|
+
if (request?.permanent !== undefined) {
|
|
696
|
+
formData.append('permanent', request.permanent.toString());
|
|
697
|
+
}
|
|
698
|
+
if (request?.encrypted !== undefined) {
|
|
699
|
+
formData.append('encrypted', request.encrypted.toString());
|
|
700
|
+
}
|
|
701
|
+
if (request?.expiry_duration !== undefined) {
|
|
702
|
+
formData.append('expiry_duration', request.expiry_duration.toString());
|
|
703
|
+
}
|
|
704
|
+
if (request?.enable !== undefined) {
|
|
705
|
+
formData.append('enable', request.enable.toString());
|
|
706
|
+
}
|
|
707
|
+
let headers = new AxiosHeaders();
|
|
708
|
+
headers["Accept"] = "application/json";
|
|
709
|
+
return this.axiosInstance.put(`${this.baseURL}curtain-chunked-upload/${uploadId}/`, formData, { headers: headers });
|
|
710
|
+
}
|
|
711
|
+
cancelCurtainUpload(uploadId) {
|
|
712
|
+
let headers = new AxiosHeaders();
|
|
713
|
+
headers["Accept"] = "application/json";
|
|
714
|
+
return this.axiosInstance.delete(`${this.baseURL}curtain-chunked-upload/${uploadId}/`, { headers: headers });
|
|
715
|
+
}
|
|
716
|
+
async uploadCurtainFileInChunks(file, chunkSize = 1024 * 1024, options) {
|
|
717
|
+
return new Promise(async (resolve, reject) => {
|
|
718
|
+
let uploadId;
|
|
719
|
+
let offset = 0;
|
|
720
|
+
const totalSize = file.size;
|
|
721
|
+
if (totalSize <= chunkSize) {
|
|
722
|
+
try {
|
|
723
|
+
const response = await this.uploadCurtainChunk({
|
|
724
|
+
file: file,
|
|
725
|
+
filename: file.name,
|
|
726
|
+
upload_session_id: options?.upload_session_id,
|
|
727
|
+
description: options?.description,
|
|
728
|
+
curtain_type: options?.curtain_type,
|
|
729
|
+
permanent: options?.permanent,
|
|
730
|
+
encrypted: options?.encrypted,
|
|
731
|
+
expiry_duration: options?.expiry_duration,
|
|
732
|
+
enable: options?.enable
|
|
733
|
+
});
|
|
734
|
+
const completionResponse = await this.completeCurtainUpload(response.data.id, {
|
|
735
|
+
description: options?.description,
|
|
736
|
+
curtain_type: options?.curtain_type,
|
|
737
|
+
permanent: options?.permanent,
|
|
738
|
+
encrypted: options?.encrypted,
|
|
739
|
+
expiry_duration: options?.expiry_duration,
|
|
740
|
+
enable: options?.enable
|
|
741
|
+
});
|
|
742
|
+
resolve(completionResponse.data);
|
|
743
|
+
}
|
|
744
|
+
catch (error) {
|
|
745
|
+
reject(error);
|
|
746
|
+
}
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
const uploadNextChunk = async () => {
|
|
750
|
+
if (offset >= totalSize) {
|
|
751
|
+
if (uploadId) {
|
|
752
|
+
try {
|
|
753
|
+
const completionResponse = await this.completeCurtainUpload(uploadId, {
|
|
754
|
+
description: options?.description,
|
|
755
|
+
curtain_type: options?.curtain_type,
|
|
756
|
+
permanent: options?.permanent,
|
|
757
|
+
encrypted: options?.encrypted,
|
|
758
|
+
expiry_duration: options?.expiry_duration,
|
|
759
|
+
enable: options?.enable
|
|
760
|
+
});
|
|
761
|
+
resolve(completionResponse.data);
|
|
762
|
+
}
|
|
763
|
+
catch (error) {
|
|
764
|
+
reject(error);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
else {
|
|
768
|
+
reject(new Error('Upload failed: No upload ID'));
|
|
769
|
+
}
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
const end = Math.min(offset + chunkSize, totalSize);
|
|
773
|
+
const chunk = file.slice(offset, end);
|
|
774
|
+
try {
|
|
775
|
+
const response = await this.uploadCurtainChunk({
|
|
776
|
+
file: chunk,
|
|
777
|
+
filename: file.name,
|
|
778
|
+
upload_session_id: options?.upload_session_id,
|
|
779
|
+
description: options?.description,
|
|
780
|
+
curtain_type: options?.curtain_type,
|
|
781
|
+
permanent: options?.permanent,
|
|
782
|
+
encrypted: options?.encrypted,
|
|
783
|
+
expiry_duration: options?.expiry_duration,
|
|
784
|
+
enable: options?.enable
|
|
785
|
+
}, uploadId, offset, totalSize);
|
|
786
|
+
uploadId = response.data.id;
|
|
787
|
+
offset = response.data.offset;
|
|
788
|
+
const progress = (offset / totalSize) * 100;
|
|
789
|
+
if (options?.onProgress) {
|
|
790
|
+
options.onProgress(progress);
|
|
791
|
+
}
|
|
792
|
+
uploadNextChunk();
|
|
793
|
+
}
|
|
794
|
+
catch (error) {
|
|
795
|
+
reject(error);
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
uploadNextChunk();
|
|
799
|
+
});
|
|
800
|
+
}
|
|
684
801
|
}
|
|
685
|
-
exports.CurtainWebAPI = CurtainWebAPI;
|