curtain-web-api 1.0.63 → 1.0.65
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 +56 -0
- package/build/classes/curtain-api.js +341 -229
- package/build/classes/curtain-encryption.js +92 -166
- package/build/classes/curtain-user.js +4 -11
- package/build/index.d.ts +3 -3
- package/build/index.js +6 -36
- package/build/utilities.js +13 -53
- package/package.json +9 -1
- package/src/classes/curtain-api.ts +248 -0
- package/src/index.ts +48 -2
- 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,84 +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
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
});
|
|
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
|
+
}
|
|
302
253
|
}
|
|
303
254
|
postSettings(id, token, onDownloadProgress = undefined, url = undefined) {
|
|
304
|
-
let headers = new
|
|
255
|
+
let headers = new AxiosHeaders();
|
|
305
256
|
headers["Accept"] = "application/json";
|
|
306
257
|
if (url !== undefined) {
|
|
307
258
|
return this.axiosInstance.get(url, { responseType: "json" }).then((response) => {
|
|
@@ -332,91 +283,89 @@ class CurtainWebAPI {
|
|
|
332
283
|
});
|
|
333
284
|
}
|
|
334
285
|
getPrideData(accession) {
|
|
335
|
-
let headers = new
|
|
286
|
+
let headers = new AxiosHeaders();
|
|
336
287
|
headers["Accept"] = "application/json";
|
|
337
|
-
return
|
|
288
|
+
return axios.get("https://www.ebi.ac.uk/pride/ws/archive/v2/projects/" + accession, { responseType: "json" }).then((response) => {
|
|
338
289
|
return response;
|
|
339
290
|
});
|
|
340
291
|
}
|
|
341
292
|
generateTemporarySession(linkId, lifetime) {
|
|
342
|
-
let headers = new
|
|
293
|
+
let headers = new AxiosHeaders();
|
|
343
294
|
headers["Accept"] = "application/json";
|
|
344
295
|
headers["Content-Type"] = "application/json";
|
|
345
296
|
return this.axiosInstance.post(this.baseURL + "curtain/" + linkId + "/generate_token/", { lifetime: lifetime }, { headers: headers, responseType: "json" }).then((response) => {
|
|
346
297
|
return response;
|
|
347
298
|
});
|
|
348
299
|
}
|
|
349
|
-
updateSession(
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
form.append("file", new Blob([payload.encryptedData], { type: 'text/json' }), "curtain-settings.json");
|
|
370
|
-
}
|
|
371
|
-
else {
|
|
372
|
-
form.append("file", new Blob([data], { type: 'text/json' }), "curtain-settings.json");
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
if ("enable" in sessionData) {
|
|
376
|
-
if (sessionData["enable"]) {
|
|
377
|
-
form.append("enable", "True");
|
|
378
|
-
}
|
|
379
|
-
else {
|
|
380
|
-
form.append("enable", "False");
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
if ("expiry_duration" in sessionData) {
|
|
384
|
-
form.append("expiry_duration", sessionData["expiry_duration"].toString());
|
|
385
|
-
}
|
|
386
|
-
if (encryption.encrypted) {
|
|
387
|
-
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");
|
|
388
320
|
}
|
|
389
321
|
else {
|
|
390
|
-
form.append("
|
|
322
|
+
form.append("file", new Blob([data], { type: 'text/json' }), "curtain-settings.json");
|
|
391
323
|
}
|
|
392
|
-
|
|
393
|
-
|
|
324
|
+
}
|
|
325
|
+
if ("enable" in sessionData) {
|
|
326
|
+
if (sessionData["enable"]) {
|
|
327
|
+
form.append("enable", "True");
|
|
394
328
|
}
|
|
395
329
|
else {
|
|
396
|
-
form.append("
|
|
330
|
+
form.append("enable", "False");
|
|
397
331
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
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" });
|
|
403
352
|
}
|
|
404
353
|
getSessionSettings(linkId) {
|
|
405
|
-
let headers = new
|
|
354
|
+
let headers = new AxiosHeaders();
|
|
406
355
|
headers["Accept"] = "application/json";
|
|
407
356
|
return this.axiosInstance.get(this.baseURL + "curtain/" + linkId + "/", { headers: headers, responseType: "json" }).then((response) => {
|
|
408
357
|
return response;
|
|
409
358
|
});
|
|
410
359
|
}
|
|
411
360
|
getOwnership(linkId) {
|
|
412
|
-
let headers = new
|
|
361
|
+
let headers = new AxiosHeaders();
|
|
413
362
|
headers["Accept"] = "application/json";
|
|
414
363
|
return this.axiosInstance.get(this.baseURL + "curtain/" + linkId + "/get_ownership/", { headers: headers, responseType: "json" }).then((response) => {
|
|
415
364
|
return response;
|
|
416
365
|
});
|
|
417
366
|
}
|
|
418
367
|
getOwners(linkId) {
|
|
419
|
-
let headers = new
|
|
368
|
+
let headers = new AxiosHeaders();
|
|
420
369
|
headers["Accept"] = "application/json";
|
|
421
370
|
return this.axiosInstance.get(this.baseURL + "curtain/" + linkId + "/get_owners/", { headers: headers, responseType: "json" }).then((response) => {
|
|
422
371
|
return response;
|
|
@@ -425,7 +374,7 @@ class CurtainWebAPI {
|
|
|
425
374
|
addOwner(linkId, owner) {
|
|
426
375
|
let form = new FormData();
|
|
427
376
|
form.append("username", owner);
|
|
428
|
-
let headers = new
|
|
377
|
+
let headers = new AxiosHeaders();
|
|
429
378
|
headers["Accept"] = "application/json";
|
|
430
379
|
headers["Content-Type"] = "multipart/form-data";
|
|
431
380
|
return this.axiosInstance.patch(this.baseURL + "curtain/" + linkId + "/add_owner/", form, { headers: headers, responseType: "json" }).then((response) => {
|
|
@@ -433,7 +382,7 @@ class CurtainWebAPI {
|
|
|
433
382
|
});
|
|
434
383
|
}
|
|
435
384
|
getCurtainLinks(username, sessionDescription = "", offset = 0, sessionType = "TP") {
|
|
436
|
-
let headers = new
|
|
385
|
+
let headers = new AxiosHeaders();
|
|
437
386
|
headers["Accept"] = "application/json";
|
|
438
387
|
let params = new URLSearchParams();
|
|
439
388
|
params.append("username", username);
|
|
@@ -446,12 +395,12 @@ class CurtainWebAPI {
|
|
|
446
395
|
});
|
|
447
396
|
}
|
|
448
397
|
getSiteProperties() {
|
|
449
|
-
let headers = new
|
|
398
|
+
let headers = new AxiosHeaders();
|
|
450
399
|
headers["Accept"] = "application/json";
|
|
451
400
|
return this.axiosInstance.get(this.baseURL + "site-properties/", { headers: headers, responseType: "json" });
|
|
452
401
|
}
|
|
453
402
|
saveDataFilterList(name, data, category = "") {
|
|
454
|
-
let headers = new
|
|
403
|
+
let headers = new AxiosHeaders();
|
|
455
404
|
headers["Accept"] = "application/json";
|
|
456
405
|
headers["Content-Type"] = "application/json";
|
|
457
406
|
return this.axiosInstance.post(this.baseURL + "data_filter_list/", { name: name, data: data, category: category }, { headers: headers, responseType: "json" }).then((response) => {
|
|
@@ -459,7 +408,7 @@ class CurtainWebAPI {
|
|
|
459
408
|
});
|
|
460
409
|
}
|
|
461
410
|
getDataFilterListByID(id, limit = 100) {
|
|
462
|
-
let headers = new
|
|
411
|
+
let headers = new AxiosHeaders();
|
|
463
412
|
headers["Accept"] = "application/json";
|
|
464
413
|
let params = { limit: limit.toString() };
|
|
465
414
|
return this.axiosInstance.get(this.baseURL + "data_filter_list/" + id + "/", { headers: headers, responseType: "json", }).then((response) => {
|
|
@@ -487,14 +436,14 @@ class CurtainWebAPI {
|
|
|
487
436
|
return this.axiosInstance.get(this.baseURL + "data_filter_list/", { responseType: "json", params });
|
|
488
437
|
}
|
|
489
438
|
deleteDataFilterList(id) {
|
|
490
|
-
let headers = new
|
|
439
|
+
let headers = new AxiosHeaders();
|
|
491
440
|
headers["Accept"] = "application/json";
|
|
492
441
|
return this.axiosInstance.delete(this.baseURL + "data_filter_list/" + id + "/", { headers: headers, responseType: "json" }).then((response) => {
|
|
493
442
|
return response;
|
|
494
443
|
});
|
|
495
444
|
}
|
|
496
445
|
updateDataFilterList(id, name, data, category) {
|
|
497
|
-
let headers = new
|
|
446
|
+
let headers = new AxiosHeaders();
|
|
498
447
|
headers["Accept"] = "application/json";
|
|
499
448
|
headers["Content-Type"] = "application/json";
|
|
500
449
|
const updateData = {};
|
|
@@ -509,9 +458,9 @@ class CurtainWebAPI {
|
|
|
509
458
|
});
|
|
510
459
|
}
|
|
511
460
|
downloadStats() {
|
|
512
|
-
let headers = new
|
|
461
|
+
let headers = new AxiosHeaders();
|
|
513
462
|
headers["Accept"] = "application/json";
|
|
514
|
-
return
|
|
463
|
+
return axios.get(this.baseURL + "stats/download/", { headers: headers, responseType: "json" }).then((response) => {
|
|
515
464
|
return response;
|
|
516
465
|
});
|
|
517
466
|
}
|
|
@@ -526,89 +475,87 @@ class CurtainWebAPI {
|
|
|
526
475
|
searchTermArray.push("search_term_array%5B%5D=" + g);
|
|
527
476
|
}
|
|
528
477
|
const data = "http://www.interactome-atlas.org/search_results_interactions?" + params.toString() + "&" + searchTermArray.join("&");
|
|
529
|
-
let headers = new
|
|
478
|
+
let headers = new AxiosHeaders();
|
|
530
479
|
headers["Accept"] = "application/json";
|
|
531
480
|
headers["Content-Type"] = "application/json";
|
|
532
|
-
return
|
|
481
|
+
return axios.post(this.baseURL + "interactome-atlas-proxy/", { link: data }, { headers: headers, responseType: "json" }).then((response) => {
|
|
533
482
|
return response;
|
|
534
483
|
});
|
|
535
484
|
}
|
|
536
485
|
postPrimitiveStatsTest(data, type = "t-test") {
|
|
537
|
-
let headers = new
|
|
486
|
+
let headers = new AxiosHeaders();
|
|
538
487
|
headers["Accept"] = "application/json";
|
|
539
488
|
headers["Content-Type"] = "application/json";
|
|
540
|
-
return
|
|
489
|
+
return axios.post(this.baseURL + "primitive-stats-test/", { data, type }).then((response) => {
|
|
541
490
|
return response;
|
|
542
491
|
});
|
|
543
492
|
}
|
|
544
493
|
getDataAllListCategory() {
|
|
545
|
-
let headers = new
|
|
494
|
+
let headers = new AxiosHeaders();
|
|
546
495
|
headers["Accept"] = "application/json";
|
|
547
496
|
headers["Content-Type"] = "application/json";
|
|
548
|
-
return
|
|
497
|
+
return axios.get(this.baseURL + "data_filter_list/get_all_category/", { headers: headers, responseType: "json" }).then((response) => { return response; });
|
|
549
498
|
}
|
|
550
499
|
postCompareSession(idList, matchType, studyList, sessionId) {
|
|
551
|
-
let headers = new
|
|
500
|
+
let headers = new AxiosHeaders();
|
|
552
501
|
headers["Accept"] = "application/json";
|
|
553
502
|
headers["Content-Type"] = "application/json";
|
|
554
|
-
return
|
|
503
|
+
return axios.post(this.baseURL + "compare-session/", { matchType, studyList, idList, sessionId }, { headers: headers, responseType: "json" }).then((response) => { return response; });
|
|
555
504
|
}
|
|
556
505
|
getStatsSummary(lastNDays) {
|
|
557
|
-
let headers = new
|
|
506
|
+
let headers = new AxiosHeaders();
|
|
558
507
|
headers["Accept"] = "application/json";
|
|
559
508
|
headers["Content-Type"] = "application/json";
|
|
560
509
|
return this.axiosInstance.get(this.baseURL + `stats/summary/${lastNDays}/`, { responseType: "json", headers });
|
|
561
510
|
}
|
|
562
511
|
postEncryptionFactors(encryptedAESKey, encryptedIV, linkId) {
|
|
563
|
-
let headers = new
|
|
512
|
+
let headers = new AxiosHeaders();
|
|
564
513
|
headers["Accept"] = "application/json";
|
|
565
514
|
headers["Content-Type"] = "application/json";
|
|
566
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; });
|
|
567
516
|
}
|
|
568
|
-
getEncryptionFactors(linkId) {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
return yield this.axiosInstance.get(this.baseURL + "curtain/" + linkId + "/get_encryption_factors/", { headers: headers, responseType: "json" });
|
|
574
|
-
});
|
|
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" });
|
|
575
522
|
}
|
|
576
523
|
createCurtainAPIKey(name) {
|
|
577
|
-
let headers = new
|
|
524
|
+
let headers = new AxiosHeaders();
|
|
578
525
|
headers["Accept"] = "application/json";
|
|
579
526
|
headers["Content-Type"] = "application/json";
|
|
580
527
|
return this.axiosInstance.post(this.baseURL + "api_key/", { name: name }, { headers: headers, responseType: "json" });
|
|
581
528
|
}
|
|
582
529
|
getCurtainAPIKeys() {
|
|
583
|
-
let headers = new
|
|
530
|
+
let headers = new AxiosHeaders();
|
|
584
531
|
headers["Accept"] = "application/json";
|
|
585
532
|
headers["Content-Type"] = "application/json";
|
|
586
533
|
return this.axiosInstance.get(this.baseURL + "api_key/", { headers: headers, responseType: "json" });
|
|
587
534
|
}
|
|
588
535
|
deleteCurtainAPIKey(id) {
|
|
589
|
-
let headers = new
|
|
536
|
+
let headers = new AxiosHeaders();
|
|
590
537
|
headers["Accept"] = "application/json";
|
|
591
538
|
headers["Content-Type"] = "application/json";
|
|
592
539
|
return this.axiosInstance.delete(this.baseURL + "api_key/" + id + "/", { headers: headers, responseType: "json" });
|
|
593
540
|
}
|
|
594
541
|
getRandomDataCiteSuffix() {
|
|
595
|
-
let headers = new
|
|
542
|
+
let headers = new AxiosHeaders();
|
|
596
543
|
headers["Accept"] = "application/json";
|
|
597
544
|
return this.axiosInstance.get(this.baseURL + "datacite/get_random_suffix/", { headers: headers, responseType: "json" });
|
|
598
545
|
}
|
|
599
546
|
submitDataCite(data) {
|
|
600
|
-
let headers = new
|
|
547
|
+
let headers = new AxiosHeaders();
|
|
601
548
|
headers["Accept"] = "application/json";
|
|
602
549
|
headers["Content-Type"] = "application/json";
|
|
603
550
|
return this.axiosInstance.post(this.baseURL + "datacite/", data, { headers: headers, responseType: "json" });
|
|
604
551
|
}
|
|
605
552
|
getDataCite(id) {
|
|
606
|
-
let headers = new
|
|
553
|
+
let headers = new AxiosHeaders();
|
|
607
554
|
headers["Accept"] = "application/json";
|
|
608
555
|
return this.axiosInstance.get(this.baseURL + "datacite/" + id + "/", { headers: headers, responseType: "json" });
|
|
609
556
|
}
|
|
610
557
|
getDataCites(url, title, status, limit = 10, offset = 0, manage = false, curtain_type = "TP") {
|
|
611
|
-
let headers = new
|
|
558
|
+
let headers = new AxiosHeaders();
|
|
612
559
|
headers["Accept"] = "application/json";
|
|
613
560
|
let params = new URLSearchParams();
|
|
614
561
|
if (url !== undefined) {
|
|
@@ -631,59 +578,224 @@ class CurtainWebAPI {
|
|
|
631
578
|
return this.axiosInstance.get(this.baseURL + "datacite/", { headers: headers, params: params, responseType: "json" });
|
|
632
579
|
}
|
|
633
580
|
getDataCiteTimeLimitedPermissionToken(suffix) {
|
|
634
|
-
let headers = new
|
|
581
|
+
let headers = new AxiosHeaders();
|
|
635
582
|
headers["Accept"] = "application/json";
|
|
636
583
|
return this.axiosInstance.get(this.baseURL + "datacite/get_time_limited_permission_token/?suffix=" + suffix, { headers: headers, responseType: "json" });
|
|
637
584
|
}
|
|
638
585
|
getDataCiteProxyOrcidPublicRecord(orcid) {
|
|
639
|
-
let headers = new
|
|
586
|
+
let headers = new AxiosHeaders();
|
|
640
587
|
headers["Accept"] = "application/json";
|
|
641
588
|
return this.axiosInstance.get(this.baseURL + "datacite/proxy_orcid/?orcid=" + orcid, { headers: headers, responseType: "json" });
|
|
642
589
|
}
|
|
643
590
|
getDataCiteQuota() {
|
|
644
|
-
let headers = new
|
|
591
|
+
let headers = new AxiosHeaders();
|
|
645
592
|
headers["Accept"] = "application/json";
|
|
646
593
|
return this.axiosInstance.get(this.baseURL + "datacite/get_quota/", { headers: headers, responseType: "json" });
|
|
647
594
|
}
|
|
648
595
|
updateDataCite(id, data) {
|
|
649
|
-
let headers = new
|
|
596
|
+
let headers = new AxiosHeaders();
|
|
650
597
|
headers["Accept"] = "application/json";
|
|
651
598
|
headers["Content-Type"] = "application/json";
|
|
652
599
|
return this.axiosInstance.post(this.baseURL + "datacite/" + id + "/", data, { headers: headers, responseType: "json" });
|
|
653
600
|
}
|
|
654
601
|
deleteDataCite(id) {
|
|
655
|
-
let headers = new
|
|
602
|
+
let headers = new AxiosHeaders();
|
|
656
603
|
headers["Accept"] = "application/json";
|
|
657
604
|
return this.axiosInstance.delete(this.baseURL + "datacite/" + id + "/", { headers: headers, responseType: "json" });
|
|
658
605
|
}
|
|
659
606
|
changeDataCiteStatus(id, status) {
|
|
660
|
-
let headers = new
|
|
607
|
+
let headers = new AxiosHeaders();
|
|
661
608
|
headers["Accept"] = "application/json";
|
|
662
609
|
headers["Content-Type"] = "application/json";
|
|
663
610
|
return this.axiosInstance.post(this.baseURL + "datacite/" + id + "/change_status/", { status: status }, { headers: headers, responseType: "json" });
|
|
664
611
|
}
|
|
665
612
|
lockDataCite(id, lock) {
|
|
666
|
-
let headers = new
|
|
613
|
+
let headers = new AxiosHeaders();
|
|
667
614
|
headers["Accept"] = "application/json";
|
|
668
615
|
headers["Content-Type"] = "application/json";
|
|
669
616
|
return this.axiosInstance.post(this.baseURL + "datacite/" + id + "/lock/", { lock: lock }, { headers: headers, responseType: "json" });
|
|
670
617
|
}
|
|
671
618
|
getKinaseLibraryProxy(sequence) {
|
|
672
|
-
let headers = new
|
|
619
|
+
let headers = new AxiosHeaders();
|
|
673
620
|
headers["Accept"] = "application/json";
|
|
674
621
|
let params = new URLSearchParams();
|
|
675
622
|
params.append("sequence", sequence);
|
|
676
623
|
return this.axiosInstance.get(this.baseURL + "kinase_library_proxy/", { headers: headers, params: params, responseType: "json" });
|
|
677
624
|
}
|
|
678
625
|
getJobResult(job_id) {
|
|
679
|
-
let headers = new
|
|
626
|
+
let headers = new AxiosHeaders();
|
|
680
627
|
headers["Accept"] = "application/json";
|
|
681
628
|
return this.axiosInstance.get(this.baseURL + "job/" + job_id + "/", { headers: headers, responseType: "json" });
|
|
682
629
|
}
|
|
683
630
|
getDataCiteFile(datacite_id) {
|
|
684
|
-
let headers = new
|
|
631
|
+
let headers = new AxiosHeaders();
|
|
685
632
|
headers["Accept"] = "application/json";
|
|
686
633
|
return this.axiosInstance.get(this.baseURL + "datacite/file/" + datacite_id + "/", { headers: headers, responseType: "blob" });
|
|
687
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
|
+
}
|
|
688
801
|
}
|
|
689
|
-
exports.CurtainWebAPI = CurtainWebAPI;
|