curtain-web-api 1.0.63 → 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 +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 +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 +248 -0
- package/src/index.ts +16 -1
- package/tsconfig.json +4 -3
|
@@ -1,113 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.encryptDataRSA = encryptDataRSA;
|
|
13
|
-
exports.decryptDataRSA = decryptDataRSA;
|
|
14
|
-
exports.importPublicKey = importPublicKey;
|
|
15
|
-
exports.importPrivateKey = importPrivateKey;
|
|
16
|
-
exports.generateKeyPair = generateKeyPair;
|
|
17
|
-
exports.exportPublicKey = exportPublicKey;
|
|
18
|
-
exports.exportPrivateKey = exportPrivateKey;
|
|
19
|
-
exports.importKey = importKey;
|
|
20
|
-
exports.exportKeyString = exportKeyString;
|
|
21
|
-
exports.saveToLocalStorage = saveToLocalStorage;
|
|
22
|
-
exports.loadFromLocalStorage = loadFromLocalStorage;
|
|
23
|
-
exports.arrayBufferToBase64String = arrayBufferToBase64String;
|
|
24
|
-
exports.removeLines = removeLines;
|
|
25
|
-
exports.base64ToArrayBuffer = base64ToArrayBuffer;
|
|
26
|
-
exports.pemToArrayBuffer = pemToArrayBuffer;
|
|
27
|
-
exports.encryptAESKey = encryptAESKey;
|
|
28
|
-
exports.generateAESKey = generateAESKey;
|
|
29
|
-
exports.encryptAESData = encryptAESData;
|
|
30
|
-
exports.decryptAESData = decryptAESData;
|
|
31
|
-
exports.decryptAESKey = decryptAESKey;
|
|
32
|
-
exports.exportAESKey = exportAESKey;
|
|
33
|
-
exports.importAESKey = importAESKey;
|
|
34
|
-
exports.encryptDataAES = encryptDataAES;
|
|
35
|
-
exports.decryptDataAES = decryptDataAES;
|
|
36
|
-
exports.hashData = hashData;
|
|
37
|
-
function encryptDataRSA(data, publicKey) {
|
|
1
|
+
export function encryptDataRSA(data, publicKey) {
|
|
38
2
|
return crypto.subtle.encrypt({ name: 'RSA-OAEP' }, publicKey, new TextEncoder().encode(data));
|
|
39
3
|
}
|
|
40
|
-
function decryptDataRSA(data, privateKey) {
|
|
4
|
+
export function decryptDataRSA(data, privateKey) {
|
|
41
5
|
return crypto.subtle.decrypt({ name: 'RSA-OAEP' }, privateKey, new TextEncoder().encode(data));
|
|
42
6
|
}
|
|
43
|
-
function importPublicKey(key) {
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
return
|
|
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
|
-
function saveToLocalStorage(key, type) {
|
|
96
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
-
const k = yield exportKeyString(key, type);
|
|
98
|
-
localStorage.setItem(type + "_key", k);
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
function loadFromLocalStorage(type) {
|
|
102
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
const k = localStorage.getItem(type + "_key");
|
|
104
|
-
if (k) {
|
|
105
|
-
return yield importKey(pemToArrayBuffer(k), type);
|
|
106
|
-
}
|
|
107
|
-
return undefined;
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
function arrayBufferToBase64String(arrayBuffer) {
|
|
7
|
+
export async function importPublicKey(key) {
|
|
8
|
+
return await crypto.subtle.importKey('spki', key, { name: 'RSA-OAEP', hash: 'SHA-256' }, true, ['encrypt']);
|
|
9
|
+
}
|
|
10
|
+
export async function importPrivateKey(key) {
|
|
11
|
+
return await crypto.subtle.importKey('pkcs8', key, { name: 'RSA-OAEP', hash: 'SHA-256' }, true, ['decrypt']);
|
|
12
|
+
}
|
|
13
|
+
export async function generateKeyPair(modulusLength = 2048, publicExponent = new Uint8Array([1, 0, 1])) {
|
|
14
|
+
return await crypto.subtle.generateKey({
|
|
15
|
+
name: "RSA-OAEP",
|
|
16
|
+
modulusLength: modulusLength,
|
|
17
|
+
publicExponent: publicExponent,
|
|
18
|
+
hash: "SHA-256",
|
|
19
|
+
}, true, ["encrypt", "decrypt"]);
|
|
20
|
+
}
|
|
21
|
+
export async function exportPublicKey(key) {
|
|
22
|
+
return await crypto.subtle.exportKey('spki', key);
|
|
23
|
+
}
|
|
24
|
+
export async function exportPrivateKey(key) {
|
|
25
|
+
return await crypto.subtle.exportKey('pkcs8', key);
|
|
26
|
+
}
|
|
27
|
+
export async function importKey(key, type) {
|
|
28
|
+
if (type === "public") {
|
|
29
|
+
return await importPublicKey(key);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return await importPrivateKey(key);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export async function exportKeyString(key, type) {
|
|
36
|
+
if (type === "public") {
|
|
37
|
+
const k = await exportPublicKey(key);
|
|
38
|
+
return arrayBufferToBase64String(k);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const k = await exportPrivateKey(key);
|
|
42
|
+
return arrayBufferToBase64String(k);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export async function saveToLocalStorage(key, type) {
|
|
46
|
+
const k = await exportKeyString(key, type);
|
|
47
|
+
localStorage.setItem(type + "_key", k);
|
|
48
|
+
}
|
|
49
|
+
export async function loadFromLocalStorage(type) {
|
|
50
|
+
const k = localStorage.getItem(type + "_key");
|
|
51
|
+
if (k) {
|
|
52
|
+
return await importKey(pemToArrayBuffer(k), type);
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
export function arrayBufferToBase64String(arrayBuffer) {
|
|
111
57
|
const byteArray = new Uint8Array(arrayBuffer);
|
|
112
58
|
let byteString = '';
|
|
113
59
|
for (let i = 0; i < byteArray.byteLength; i++) {
|
|
@@ -115,10 +61,10 @@ function arrayBufferToBase64String(arrayBuffer) {
|
|
|
115
61
|
}
|
|
116
62
|
return btoa(byteString);
|
|
117
63
|
}
|
|
118
|
-
function removeLines(str_data) {
|
|
64
|
+
export function removeLines(str_data) {
|
|
119
65
|
return str_data.replace("\n", "");
|
|
120
66
|
}
|
|
121
|
-
function base64ToArrayBuffer(b64) {
|
|
67
|
+
export function base64ToArrayBuffer(b64) {
|
|
122
68
|
const byteString = atob(b64);
|
|
123
69
|
const byteArray = new Uint8Array(byteString.length);
|
|
124
70
|
for (let i = 0; i < byteString.length; i++) {
|
|
@@ -126,7 +72,7 @@ function base64ToArrayBuffer(b64) {
|
|
|
126
72
|
}
|
|
127
73
|
return byteArray.buffer;
|
|
128
74
|
}
|
|
129
|
-
function pemToArrayBuffer(pem) {
|
|
75
|
+
export function pemToArrayBuffer(pem) {
|
|
130
76
|
const b64Lines = removeLines(pem);
|
|
131
77
|
let b64Prefix = b64Lines.replace('-----BEGIN PRIVATE KEY-----', '');
|
|
132
78
|
b64Prefix = b64Prefix.replace('-----BEGIN PUBLIC KEY-----', '');
|
|
@@ -135,79 +81,59 @@ function pemToArrayBuffer(pem) {
|
|
|
135
81
|
return base64ToArrayBuffer(b64Final);
|
|
136
82
|
}
|
|
137
83
|
// a function to generate to encrypt an aes key arraybuffer with a public key
|
|
138
|
-
function encryptAESKey(publicKey, aesKey) {
|
|
139
|
-
return
|
|
140
|
-
return yield crypto.subtle.encrypt({ name: "RSA-OAEP" }, publicKey, aesKey);
|
|
141
|
-
});
|
|
84
|
+
export async function encryptAESKey(publicKey, aesKey) {
|
|
85
|
+
return await crypto.subtle.encrypt({ name: "RSA-OAEP" }, publicKey, aesKey);
|
|
142
86
|
}
|
|
143
87
|
// a function to generate an aes key in GCM mode with a length of 256 bits
|
|
144
|
-
function generateAESKey() {
|
|
145
|
-
return
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}, true, ["encrypt", "decrypt"]);
|
|
150
|
-
});
|
|
88
|
+
export async function generateAESKey() {
|
|
89
|
+
return await crypto.subtle.generateKey({
|
|
90
|
+
name: "AES-GCM",
|
|
91
|
+
length: 256,
|
|
92
|
+
}, true, ["encrypt", "decrypt"]);
|
|
151
93
|
}
|
|
152
94
|
// a function to encrypt a string with an aes key
|
|
153
|
-
function encryptAESData(aesKey, data) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return { encrypted: arrayBufferToBase64String(encrypted), iv: arrayBufferToBase64String(iv.buffer) };
|
|
160
|
-
});
|
|
95
|
+
export async function encryptAESData(aesKey, data) {
|
|
96
|
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
97
|
+
const enc = new TextEncoder();
|
|
98
|
+
const encoded = enc.encode(data);
|
|
99
|
+
const encrypted = await crypto.subtle.encrypt({ name: "AES-GCM", iv: iv }, aesKey, encoded);
|
|
100
|
+
return { encrypted: arrayBufferToBase64String(encrypted), iv: arrayBufferToBase64String(iv.buffer) };
|
|
161
101
|
}
|
|
162
102
|
// a function to decrypt a string with an aes key
|
|
163
|
-
function decryptAESData(aesKey, data, iv) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return dec.decode(decrypted);
|
|
168
|
-
});
|
|
103
|
+
export async function decryptAESData(aesKey, data, iv) {
|
|
104
|
+
const dec = new TextDecoder();
|
|
105
|
+
const decrypted = await crypto.subtle.decrypt({ name: "AES-GCM", iv: base64ToArrayBuffer(iv) }, aesKey, base64ToArrayBuffer(data));
|
|
106
|
+
return dec.decode(decrypted);
|
|
169
107
|
}
|
|
170
108
|
// a function to decrypt an aes key with a private key
|
|
171
|
-
function decryptAESKey(privateKey, encryptedKey) {
|
|
172
|
-
return
|
|
173
|
-
return yield crypto.subtle.decrypt({ name: "RSA-OAEP" }, privateKey, encryptedKey);
|
|
174
|
-
});
|
|
109
|
+
export async function decryptAESKey(privateKey, encryptedKey) {
|
|
110
|
+
return await crypto.subtle.decrypt({ name: "RSA-OAEP" }, privateKey, encryptedKey);
|
|
175
111
|
}
|
|
176
112
|
// a function to export an aes key to a string
|
|
177
|
-
function exportAESKey(key) {
|
|
178
|
-
return
|
|
179
|
-
return yield crypto.subtle.exportKey("raw", key);
|
|
180
|
-
});
|
|
113
|
+
export async function exportAESKey(key) {
|
|
114
|
+
return await crypto.subtle.exportKey("raw", key);
|
|
181
115
|
}
|
|
182
116
|
// a function to import an aes key from a string
|
|
183
|
-
function importAESKey(key) {
|
|
184
|
-
return
|
|
185
|
-
return yield crypto.subtle.importKey("raw", key, "AES-GCM", true, ["encrypt", "decrypt"]);
|
|
186
|
-
});
|
|
117
|
+
export async function importAESKey(key) {
|
|
118
|
+
return await crypto.subtle.importKey("raw", key, "AES-GCM", true, ["encrypt", "decrypt"]);
|
|
187
119
|
}
|
|
188
120
|
// a function to encrypt aes key with a public key and also use the aes key to encrypt a large string then return the encrypted aes key and the encrypted string
|
|
189
|
-
function encryptDataAES(data, publicKey) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
return { encryptedKey: arrayBufferToBase64String(encryptedKey), encryptedData: encryptedData };
|
|
195
|
-
});
|
|
121
|
+
export async function encryptDataAES(data, publicKey) {
|
|
122
|
+
const aesKey = await generateAESKey();
|
|
123
|
+
const encryptedKey = await encryptAESKey(publicKey, await exportAESKey(aesKey));
|
|
124
|
+
const encryptedData = await encryptAESData(aesKey, data);
|
|
125
|
+
return { encryptedKey: arrayBufferToBase64String(encryptedKey), encryptedData: encryptedData };
|
|
196
126
|
}
|
|
197
127
|
// a function to decrypt an aes key with a private key and use the aes key to decrypt a large string
|
|
198
|
-
function decryptDataAES(encryptedKey, encryptedData, iv, privateKey) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
return yield decryptAESData(yield importAESKey(aesKey), encryptedData, iv);
|
|
203
|
-
});
|
|
128
|
+
export async function decryptDataAES(encryptedKey, encryptedData, iv, privateKey) {
|
|
129
|
+
const aesKey = await decryptAESKey(privateKey, encryptedKey);
|
|
130
|
+
//import aes key
|
|
131
|
+
return await decryptAESData(await importAESKey(aesKey), encryptedData, iv);
|
|
204
132
|
}
|
|
205
133
|
// a function to calculate sha-256 hash of a large string
|
|
206
|
-
function hashData(data) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return arrayBufferToBase64String(hash);
|
|
212
|
-
});
|
|
134
|
+
export async function hashData(data) {
|
|
135
|
+
const enc = new TextEncoder();
|
|
136
|
+
const encoded = enc.encode(data);
|
|
137
|
+
const hash = await crypto.subtle.digest("SHA-256", encoded);
|
|
138
|
+
return arrayBufferToBase64String(hash);
|
|
213
139
|
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.User = void 0;
|
|
7
|
-
const pouchdb_1 = __importDefault(require("pouchdb"));
|
|
8
|
-
class User {
|
|
1
|
+
import PouchDB from "pouchdb";
|
|
2
|
+
export class User {
|
|
9
3
|
get refresh_token() {
|
|
10
4
|
return this._refresh_token;
|
|
11
5
|
}
|
|
@@ -33,7 +27,7 @@ class User {
|
|
|
33
27
|
this.curtainLinkLimitExceeded = false;
|
|
34
28
|
this.lastAccessTokenUpdate = new Date();
|
|
35
29
|
this.lastRefreshTokenUpdate = new Date();
|
|
36
|
-
this.db = new
|
|
30
|
+
this.db = new PouchDB("curtainuser");
|
|
37
31
|
}
|
|
38
32
|
init() {
|
|
39
33
|
return this.db.get("user").then((doc) => {
|
|
@@ -152,7 +146,7 @@ class User {
|
|
|
152
146
|
clearDB() {
|
|
153
147
|
return this.db.destroy().then((response) => {
|
|
154
148
|
this.reset();
|
|
155
|
-
this.db = new
|
|
149
|
+
this.db = new PouchDB("curtainuser");
|
|
156
150
|
return this.initiateDB();
|
|
157
151
|
}).catch((error) => {
|
|
158
152
|
console.log(error);
|
|
@@ -173,4 +167,3 @@ class User {
|
|
|
173
167
|
this.lastRefreshTokenUpdate = new Date();
|
|
174
168
|
}
|
|
175
169
|
}
|
|
176
|
-
exports.User = User;
|
package/build/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CurtainWebAPI, replacer, reviver, SiteProperties } from "./classes/curtain-api";
|
|
1
|
+
import { CurtainWebAPI, replacer, reviver, SiteProperties, CurtainChunkedUploadStatus, CurtainChunkedUploadRequest, CurtainChunkedUploadResponse, CurtainChunkedUploadCompletionRequest, CurtainChunkedUploadCompletionResponse } from "./classes/curtain-api";
|
|
2
2
|
import { User } from "./classes/curtain-user";
|
|
3
3
|
import { getProteomicsData, getPrideData, getEBIAlpha, getInteractomeAtlas, getStringDBInteractions } from "./utilities";
|
|
4
4
|
import { importKey, importPrivateKey, exportPrivateKey, exportKeyString, exportPublicKey, importPublicKey, CurtainEncryption, generateKeyPair, encryptDataRSA, decryptDataRSA, loadFromLocalStorage, saveToLocalStorage, pemToArrayBuffer, base64ToArrayBuffer, arrayBufferToBase64String, removeLines } from "./classes/curtain-encryption";
|
|
5
5
|
import PouchDB from "pouchdb";
|
|
6
|
-
export { CurtainWebAPI, User, getProteomicsData, getPrideData, getEBIAlpha, getInteractomeAtlas, getStringDBInteractions, replacer, reviver, SiteProperties, importKey, importPrivateKey, exportPrivateKey, exportKeyString, exportPublicKey, importPublicKey, CurtainEncryption, generateKeyPair, encryptDataRSA, decryptDataRSA, loadFromLocalStorage, saveToLocalStorage, pemToArrayBuffer, base64ToArrayBuffer, arrayBufferToBase64String, removeLines, PouchDB };
|
|
6
|
+
export { CurtainWebAPI, User, getProteomicsData, getPrideData, getEBIAlpha, getInteractomeAtlas, getStringDBInteractions, replacer, reviver, SiteProperties, CurtainChunkedUploadStatus, CurtainChunkedUploadRequest, CurtainChunkedUploadResponse, CurtainChunkedUploadCompletionRequest, CurtainChunkedUploadCompletionResponse, importKey, importPrivateKey, exportPrivateKey, exportKeyString, exportPublicKey, importPublicKey, CurtainEncryption, generateKeyPair, encryptDataRSA, decryptDataRSA, loadFromLocalStorage, saveToLocalStorage, pemToArrayBuffer, base64ToArrayBuffer, arrayBufferToBase64String, removeLines, PouchDB };
|
package/build/index.js
CHANGED
|
@@ -1,36 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const curtain_api_1 = require("./classes/curtain-api");
|
|
8
|
-
Object.defineProperty(exports, "CurtainWebAPI", { enumerable: true, get: function () { return curtain_api_1.CurtainWebAPI; } });
|
|
9
|
-
Object.defineProperty(exports, "replacer", { enumerable: true, get: function () { return curtain_api_1.replacer; } });
|
|
10
|
-
Object.defineProperty(exports, "reviver", { enumerable: true, get: function () { return curtain_api_1.reviver; } });
|
|
11
|
-
const curtain_user_1 = require("./classes/curtain-user");
|
|
12
|
-
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return curtain_user_1.User; } });
|
|
13
|
-
const utilities_1 = require("./utilities");
|
|
14
|
-
Object.defineProperty(exports, "getProteomicsData", { enumerable: true, get: function () { return utilities_1.getProteomicsData; } });
|
|
15
|
-
Object.defineProperty(exports, "getPrideData", { enumerable: true, get: function () { return utilities_1.getPrideData; } });
|
|
16
|
-
Object.defineProperty(exports, "getEBIAlpha", { enumerable: true, get: function () { return utilities_1.getEBIAlpha; } });
|
|
17
|
-
Object.defineProperty(exports, "getInteractomeAtlas", { enumerable: true, get: function () { return utilities_1.getInteractomeAtlas; } });
|
|
18
|
-
Object.defineProperty(exports, "getStringDBInteractions", { enumerable: true, get: function () { return utilities_1.getStringDBInteractions; } });
|
|
19
|
-
const curtain_encryption_1 = require("./classes/curtain-encryption");
|
|
20
|
-
Object.defineProperty(exports, "importKey", { enumerable: true, get: function () { return curtain_encryption_1.importKey; } });
|
|
21
|
-
Object.defineProperty(exports, "importPrivateKey", { enumerable: true, get: function () { return curtain_encryption_1.importPrivateKey; } });
|
|
22
|
-
Object.defineProperty(exports, "exportPrivateKey", { enumerable: true, get: function () { return curtain_encryption_1.exportPrivateKey; } });
|
|
23
|
-
Object.defineProperty(exports, "exportKeyString", { enumerable: true, get: function () { return curtain_encryption_1.exportKeyString; } });
|
|
24
|
-
Object.defineProperty(exports, "exportPublicKey", { enumerable: true, get: function () { return curtain_encryption_1.exportPublicKey; } });
|
|
25
|
-
Object.defineProperty(exports, "importPublicKey", { enumerable: true, get: function () { return curtain_encryption_1.importPublicKey; } });
|
|
26
|
-
Object.defineProperty(exports, "generateKeyPair", { enumerable: true, get: function () { return curtain_encryption_1.generateKeyPair; } });
|
|
27
|
-
Object.defineProperty(exports, "encryptDataRSA", { enumerable: true, get: function () { return curtain_encryption_1.encryptDataRSA; } });
|
|
28
|
-
Object.defineProperty(exports, "decryptDataRSA", { enumerable: true, get: function () { return curtain_encryption_1.decryptDataRSA; } });
|
|
29
|
-
Object.defineProperty(exports, "loadFromLocalStorage", { enumerable: true, get: function () { return curtain_encryption_1.loadFromLocalStorage; } });
|
|
30
|
-
Object.defineProperty(exports, "saveToLocalStorage", { enumerable: true, get: function () { return curtain_encryption_1.saveToLocalStorage; } });
|
|
31
|
-
Object.defineProperty(exports, "pemToArrayBuffer", { enumerable: true, get: function () { return curtain_encryption_1.pemToArrayBuffer; } });
|
|
32
|
-
Object.defineProperty(exports, "base64ToArrayBuffer", { enumerable: true, get: function () { return curtain_encryption_1.base64ToArrayBuffer; } });
|
|
33
|
-
Object.defineProperty(exports, "arrayBufferToBase64String", { enumerable: true, get: function () { return curtain_encryption_1.arrayBufferToBase64String; } });
|
|
34
|
-
Object.defineProperty(exports, "removeLines", { enumerable: true, get: function () { return curtain_encryption_1.removeLines; } });
|
|
35
|
-
const pouchdb_1 = __importDefault(require("pouchdb"));
|
|
36
|
-
exports.PouchDB = pouchdb_1.default;
|
|
1
|
+
import { CurtainWebAPI, replacer, reviver } from "./classes/curtain-api";
|
|
2
|
+
import { User } from "./classes/curtain-user";
|
|
3
|
+
import { getProteomicsData, getPrideData, getEBIAlpha, getInteractomeAtlas, getStringDBInteractions } from "./utilities";
|
|
4
|
+
import { importKey, importPrivateKey, exportPrivateKey, exportKeyString, exportPublicKey, importPublicKey, generateKeyPair, encryptDataRSA, decryptDataRSA, loadFromLocalStorage, saveToLocalStorage, pemToArrayBuffer, base64ToArrayBuffer, arrayBufferToBase64String, removeLines } from "./classes/curtain-encryption";
|
|
5
|
+
import PouchDB from "pouchdb";
|
|
6
|
+
export { CurtainWebAPI, User, getProteomicsData, getPrideData, getEBIAlpha, getInteractomeAtlas, getStringDBInteractions, replacer, reviver, importKey, importPrivateKey, exportPrivateKey, exportKeyString, exportPublicKey, importPublicKey, generateKeyPair, encryptDataRSA, decryptDataRSA, loadFromLocalStorage, saveToLocalStorage, pemToArrayBuffer, base64ToArrayBuffer, arrayBufferToBase64String, removeLines, PouchDB };
|
package/build/utilities.js
CHANGED
|
@@ -1,68 +1,28 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.getProteomicsData = getProteomicsData;
|
|
37
|
-
exports.getPrideData = getPrideData;
|
|
38
|
-
exports.getEBIAlpha = getEBIAlpha;
|
|
39
|
-
exports.getStringDBInteractions = getStringDBInteractions;
|
|
40
|
-
exports.getInteractomeAtlas = getInteractomeAtlas;
|
|
41
|
-
const axios_1 = __importStar(require("axios"));
|
|
42
|
-
function getProteomicsData(acc, tissueType) {
|
|
43
|
-
let headers = new axios_1.AxiosHeaders();
|
|
1
|
+
import axios, { AxiosHeaders } from "axios";
|
|
2
|
+
export function getProteomicsData(acc, tissueType) {
|
|
3
|
+
let headers = new AxiosHeaders();
|
|
44
4
|
headers["Accept"] = "application/json";
|
|
45
5
|
headers["Content-Type"] = "application/json";
|
|
46
|
-
return
|
|
6
|
+
return axios.get("https://www.proteomicsdb.org/proteomicsdb/logic/api/proteinexpression.xsodata/InputParams(PROTEINFILTER='" + acc + "',MS_LEVEL=1,TISSUE_ID_SELECTION='',TISSUE_CATEGORY_SELECTION='" + tissueType + "',SCOPE_SELECTION=1,GROUP_BY_TISSUE=1,CALCULATION_METHOD=0,EXP_ID=-1)/Results?$select=UNIQUE_IDENTIFIER,TISSUE_ID,TISSUE_NAME,TISSUE_SAP_SYNONYM,SAMPLE_ID,SAMPLE_NAME,AFFINITY_PURIFICATION,EXPERIMENT_ID,EXPERIMENT_NAME,EXPERIMENT_SCOPE,EXPERIMENT_SCOPE_NAME,PROJECT_ID,PROJECT_NAME,PROJECT_STATUS,UNNORMALIZED_INTENSITY,NORMALIZED_INTENSITY,MIN_NORMALIZED_INTENSITY,MAX_NORMALIZED_INTENSITY,SAMPLES&$format=json", { responseType: "json" });
|
|
47
7
|
}
|
|
48
|
-
function getPrideData(acc) {
|
|
49
|
-
let headers = new
|
|
8
|
+
export function getPrideData(acc) {
|
|
9
|
+
let headers = new AxiosHeaders();
|
|
50
10
|
headers["Accept"] = "application/json";
|
|
51
11
|
headers["Content-Type"] = "application/json";
|
|
52
|
-
return
|
|
12
|
+
return axios.get("https://www.ebi.ac.uk/pride/ws/archive/v2/projects/" + acc, { responseType: "json", headers: headers });
|
|
53
13
|
}
|
|
54
|
-
function getEBIAlpha(id) {
|
|
55
|
-
return
|
|
14
|
+
export function getEBIAlpha(id) {
|
|
15
|
+
return axios.get("https://alphafold.ebi.ac.uk/" + "/api/prediction/" + id, { responseType: "json" });
|
|
56
16
|
}
|
|
57
|
-
function getStringDBInteractions(genes, organism, score = 400, networkType = "functional") {
|
|
17
|
+
export function getStringDBInteractions(genes, organism, score = 400, networkType = "functional") {
|
|
58
18
|
let params = new URLSearchParams();
|
|
59
19
|
params.append("identifiers", genes.join("%0d"));
|
|
60
20
|
params.append("required_score", score.toString());
|
|
61
21
|
params.append("species", organism);
|
|
62
22
|
params.append("network_type", networkType);
|
|
63
|
-
return
|
|
23
|
+
return axios.get("https://string-db.org/api/tsv/network?", { responseType: "text", params: params });
|
|
64
24
|
}
|
|
65
|
-
function getInteractomeAtlas(genes, filterParameter = "None") {
|
|
25
|
+
export function getInteractomeAtlas(genes, filterParameter = "None") {
|
|
66
26
|
let params = new URLSearchParams();
|
|
67
27
|
params.append("query_interactors", "query");
|
|
68
28
|
params.append("query_id_array", genes.join("%2C"));
|
|
@@ -72,7 +32,7 @@ function getInteractomeAtlas(genes, filterParameter = "None") {
|
|
|
72
32
|
for (const g of genes) {
|
|
73
33
|
searchTermArray.push("search_term_array%5B%5D=" + g);
|
|
74
34
|
}
|
|
75
|
-
return
|
|
35
|
+
return axios.get("https://www.interactome-atlas.org/search_results_interactions?" + params.toString() + "&" + searchTermArray.join("&"), { responseType: "json" }).then((res) => {
|
|
76
36
|
return JSON.parse(res.data);
|
|
77
37
|
});
|
|
78
38
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "curtain-web-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.64",
|
|
4
4
|
"description": "",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "./build/index.js",
|
|
6
7
|
"types": "./build/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./build/index.js",
|
|
11
|
+
"types": "./build/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
7
14
|
"scripts": {
|
|
8
15
|
"test": "ts-mocha --timeout 10000 -p tsconfig.json src/**/*.spec.ts",
|
|
9
16
|
"build": "tsc -p tsconfig.json"
|
|
@@ -16,6 +23,7 @@
|
|
|
16
23
|
"license": "MIT",
|
|
17
24
|
"dependencies": {
|
|
18
25
|
"axios": "^1.3.5",
|
|
26
|
+
"jssha": "^3.3.1",
|
|
19
27
|
"pouchdb": "^9.0.0"
|
|
20
28
|
},
|
|
21
29
|
"devDependencies": {
|