curtain-web-api 1.0.44 → 1.0.46
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 +3 -0
- package/build/classes/curtain-api.js +18 -0
- package/build/classes/curtain-encryption.d.ts +1 -0
- package/build/classes/curtain-encryption.js +11 -1
- package/package.json +1 -1
- package/src/classes/curtain-api.ts +21 -0
- package/src/classes/curtain-encryption.ts +7 -1
|
@@ -45,4 +45,7 @@ export declare class CurtainWebAPI {
|
|
|
45
45
|
getStatsSummary(lastNDays: number): Promise<import("axios").AxiosResponse<any, any>>;
|
|
46
46
|
postEncryptionFactors(encryptedAESKey: string, encryptedIV: string, linkId: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
47
47
|
getEncryptionFactors(linkId: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
48
|
+
createCurtainAPIKey(name: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
49
|
+
getCurtainAPIKeys(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
50
|
+
deleteCurtainAPIKey(id: number): Promise<import("axios").AxiosResponse<any, any>>;
|
|
48
51
|
}
|
|
@@ -521,5 +521,23 @@ class CurtainWebAPI {
|
|
|
521
521
|
return yield this.axiosInstance.get(this.baseURL + "curtain/" + linkId + "/get_encryption_factors/", { headers: headers, responseType: "json" });
|
|
522
522
|
});
|
|
523
523
|
}
|
|
524
|
+
createCurtainAPIKey(name) {
|
|
525
|
+
let headers = new axios_1.AxiosHeaders();
|
|
526
|
+
headers["Accept"] = "application/json";
|
|
527
|
+
headers["Content-Type"] = "application/json";
|
|
528
|
+
return this.axiosInstance.post(this.baseURL + "api_key/", { name: name }, { headers: headers, responseType: "json" });
|
|
529
|
+
}
|
|
530
|
+
getCurtainAPIKeys() {
|
|
531
|
+
let headers = new axios_1.AxiosHeaders();
|
|
532
|
+
headers["Accept"] = "application/json";
|
|
533
|
+
headers["Content-Type"] = "application/json";
|
|
534
|
+
return this.axiosInstance.get(this.baseURL + "api_key/", { headers: headers, responseType: "json" });
|
|
535
|
+
}
|
|
536
|
+
deleteCurtainAPIKey(id) {
|
|
537
|
+
let headers = new axios_1.AxiosHeaders();
|
|
538
|
+
headers["Accept"] = "application/json";
|
|
539
|
+
headers["Content-Type"] = "application/json";
|
|
540
|
+
return this.axiosInstance.delete(this.baseURL + "api_key/" + id + "/", { headers: headers, responseType: "json" });
|
|
541
|
+
}
|
|
524
542
|
}
|
|
525
543
|
exports.CurtainWebAPI = CurtainWebAPI;
|
|
@@ -36,3 +36,4 @@ export declare function encryptDataAES(data: string, publicKey: CryptoKey): Prom
|
|
|
36
36
|
};
|
|
37
37
|
}>;
|
|
38
38
|
export declare function decryptDataAES(encryptedKey: ArrayBuffer, encryptedData: string, iv: string, privateKey: CryptoKey): Promise<string>;
|
|
39
|
+
export declare function hashData(data: string): Promise<string>;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.decryptDataAES = exports.encryptDataAES = exports.importAESKey = exports.exportAESKey = exports.decryptAESKey = exports.decryptAESData = exports.encryptAESData = exports.generateAESKey = exports.encryptAESKey = exports.pemToArrayBuffer = exports.base64ToArrayBuffer = exports.removeLines = exports.arrayBufferToBase64String = exports.loadFromLocalStorage = exports.saveToLocalStorage = exports.exportKeyString = exports.importKey = exports.exportPrivateKey = exports.exportPublicKey = exports.generateKeyPair = exports.importPrivateKey = exports.importPublicKey = exports.decryptDataRSA = exports.encryptDataRSA = void 0;
|
|
12
|
+
exports.hashData = exports.decryptDataAES = exports.encryptDataAES = exports.importAESKey = exports.exportAESKey = exports.decryptAESKey = exports.decryptAESData = exports.encryptAESData = exports.generateAESKey = exports.encryptAESKey = exports.pemToArrayBuffer = exports.base64ToArrayBuffer = exports.removeLines = exports.arrayBufferToBase64String = exports.loadFromLocalStorage = exports.saveToLocalStorage = exports.exportKeyString = exports.importKey = exports.exportPrivateKey = exports.exportPublicKey = exports.generateKeyPair = exports.importPrivateKey = exports.importPublicKey = exports.decryptDataRSA = exports.encryptDataRSA = void 0;
|
|
13
13
|
function encryptDataRSA(data, publicKey) {
|
|
14
14
|
return crypto.subtle.encrypt({ name: 'RSA-OAEP' }, publicKey, new TextEncoder().encode(data));
|
|
15
15
|
}
|
|
@@ -202,3 +202,13 @@ function decryptDataAES(encryptedKey, encryptedData, iv, privateKey) {
|
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
204
|
exports.decryptDataAES = decryptDataAES;
|
|
205
|
+
// a function to calculate sha-256 hash of a large string
|
|
206
|
+
function hashData(data) {
|
|
207
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
208
|
+
const enc = new TextEncoder();
|
|
209
|
+
const encoded = enc.encode(data);
|
|
210
|
+
const hash = yield crypto.subtle.digest("SHA-256", encoded);
|
|
211
|
+
return arrayBufferToBase64String(hash);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
exports.hashData = hashData;
|
package/package.json
CHANGED
|
@@ -531,5 +531,26 @@ export class CurtainWebAPI {
|
|
|
531
531
|
headers["Content-Type"] = "application/json";
|
|
532
532
|
return await this.axiosInstance.get(this.baseURL + "curtain/" + linkId + "/get_encryption_factors/", {headers: headers, responseType: "json"})
|
|
533
533
|
}
|
|
534
|
+
|
|
535
|
+
createCurtainAPIKey(name: string) {
|
|
536
|
+
let headers = new AxiosHeaders()
|
|
537
|
+
headers["Accept"] = "application/json"
|
|
538
|
+
headers["Content-Type"] = "application/json"
|
|
539
|
+
return this.axiosInstance.post(this.baseURL + "api_key/", {name: name}, {headers: headers, responseType: "json"})
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
getCurtainAPIKeys() {
|
|
543
|
+
let headers = new AxiosHeaders()
|
|
544
|
+
headers["Accept"] = "application/json"
|
|
545
|
+
headers["Content-Type"] = "application/json"
|
|
546
|
+
return this.axiosInstance.get(this.baseURL + "api_key/", {headers: headers, responseType: "json"})
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
deleteCurtainAPIKey(id: number) {
|
|
550
|
+
let headers = new AxiosHeaders()
|
|
551
|
+
headers["Accept"] = "application/json"
|
|
552
|
+
headers["Content-Type"] = "application/json"
|
|
553
|
+
return this.axiosInstance.delete(this.baseURL + "api_key/" + id + "/", {headers: headers, responseType: "json"})
|
|
554
|
+
}
|
|
534
555
|
}
|
|
535
556
|
|
|
@@ -167,4 +167,10 @@ export async function decryptDataAES(encryptedKey: ArrayBuffer, encryptedData: s
|
|
|
167
167
|
return await decryptAESData(await importAESKey(aesKey), encryptedData, iv)
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
// a function to calculate sha-256 hash of a large string
|
|
171
|
+
export async function hashData(data: string) {
|
|
172
|
+
const enc = new TextEncoder()
|
|
173
|
+
const encoded = enc.encode(data)
|
|
174
|
+
const hash = await crypto.subtle.digest("SHA-256", encoded)
|
|
175
|
+
return arrayBufferToBase64String(hash)
|
|
176
|
+
}
|