curtain-web-api 1.0.39 → 1.0.40
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.js +47 -40
- package/package.json +1 -1
- package/src/classes/curtain-api.ts +7 -11
|
@@ -22,6 +22,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
25
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
35
|
exports.CurtainWebAPI = exports.reviver = exports.replacer = void 0;
|
|
27
36
|
const curtain_user_1 = require("./curtain-user");
|
|
@@ -213,46 +222,44 @@ class CurtainWebAPI {
|
|
|
213
222
|
encrypted: false,
|
|
214
223
|
e2e: false,
|
|
215
224
|
}, onUploadProgress = undefined) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
(
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
return
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
return this.axiosInstance.post(this.baseURL + "curtain/", form, { headers: headers, responseType: "json" }).then((response) => {
|
|
255
|
-
return response;
|
|
225
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
226
|
+
let form = new FormData();
|
|
227
|
+
let data = JSON.stringify(settings, exports.replacer);
|
|
228
|
+
if (enable) {
|
|
229
|
+
form.append("enable", "True");
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
form.append("enable", "False");
|
|
233
|
+
}
|
|
234
|
+
if (encryption.encrypted) {
|
|
235
|
+
form.append("encrypted", "True");
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
form.append("encrypted", "False");
|
|
239
|
+
}
|
|
240
|
+
if (encryption.e2e) {
|
|
241
|
+
form.append("e2e", "True");
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
form.append("e2e", "False");
|
|
245
|
+
}
|
|
246
|
+
if (encryption.encrypted && encryption.e2e && encryption.publicKey !== undefined) {
|
|
247
|
+
const response = yield (0, curtain_encryption_1.encryptDataRSA)(data, encryption.publicKey);
|
|
248
|
+
const base64String = (0, curtain_encryption_1.arrayBufferToBase64String)(response);
|
|
249
|
+
form.append("file", new Blob([base64String], { type: 'text/json' }), "curtain-settings.json");
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
form.append("file", new Blob([data], { type: 'text/json' }), "curtain-settings.json");
|
|
253
|
+
}
|
|
254
|
+
form.append("description", description);
|
|
255
|
+
form.append("curtain_type", sessionType);
|
|
256
|
+
let headers = new axios_1.AxiosHeaders();
|
|
257
|
+
headers["Accept"] = "application/json";
|
|
258
|
+
headers["Content-Type"] = "multipart/form-data";
|
|
259
|
+
if (onUploadProgress !== undefined) {
|
|
260
|
+
return yield this.axiosInstance.post(this.baseURL + "curtain/", form, { headers: headers, responseType: "json", onUploadProgress: onUploadProgress });
|
|
261
|
+
}
|
|
262
|
+
return yield this.axiosInstance.post(this.baseURL + "curtain/", form, { headers: headers, responseType: "json" });
|
|
256
263
|
});
|
|
257
264
|
}
|
|
258
265
|
postSettings(id, token, onDownloadProgress = undefined) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {User} from "./curtain-user";
|
|
2
2
|
import axios, {AxiosHeaders} from "axios";
|
|
3
|
-
import {CurtainEncryption, encryptDataRSA} from "./curtain-encryption";
|
|
3
|
+
import {arrayBufferToBase64String, CurtainEncryption, encryptDataRSA} from "./curtain-encryption";
|
|
4
4
|
|
|
5
5
|
const base: string = "https://celsus.muttsu.xyz/"
|
|
6
6
|
|
|
@@ -199,7 +199,7 @@ export class CurtainWebAPI {
|
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
|
|
202
|
-
putSettings(settings: any, enable: boolean = true, description: string = "", sessionType: string = "TP", encryption: CurtainEncryption = {
|
|
202
|
+
async putSettings(settings: any, enable: boolean = true, description: string = "", sessionType: string = "TP", encryption: CurtainEncryption = {
|
|
203
203
|
encrypted: false,
|
|
204
204
|
e2e: false,
|
|
205
205
|
}, onUploadProgress: any = undefined) {
|
|
@@ -222,9 +222,9 @@ export class CurtainWebAPI {
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
if (encryption.encrypted && encryption.e2e && encryption.publicKey !== undefined) {
|
|
225
|
-
encryptDataRSA(data, encryption.publicKey)
|
|
226
|
-
|
|
227
|
-
})
|
|
225
|
+
const response = await encryptDataRSA(data, encryption.publicKey)
|
|
226
|
+
const base64String = arrayBufferToBase64String(response)
|
|
227
|
+
form.append("file", new Blob([base64String], {type: 'text/json'}), "curtain-settings.json")
|
|
228
228
|
} else {
|
|
229
229
|
form.append("file", new Blob([data], {type: 'text/json'}), "curtain-settings.json")
|
|
230
230
|
}
|
|
@@ -235,13 +235,9 @@ export class CurtainWebAPI {
|
|
|
235
235
|
headers["Accept"] = "application/json";
|
|
236
236
|
headers["Content-Type"] = "multipart/form-data";
|
|
237
237
|
if (onUploadProgress !== undefined) {
|
|
238
|
-
return this.axiosInstance.post(this.baseURL + "curtain/", form, {headers: headers, responseType:"json", onUploadProgress: onUploadProgress})
|
|
239
|
-
return response;
|
|
240
|
-
});
|
|
238
|
+
return await this.axiosInstance.post(this.baseURL + "curtain/", form, {headers: headers, responseType:"json", onUploadProgress: onUploadProgress})
|
|
241
239
|
}
|
|
242
|
-
return this.axiosInstance.post(this.baseURL + "curtain/", form, {headers: headers, responseType:"json"})
|
|
243
|
-
return response;
|
|
244
|
-
});
|
|
240
|
+
return await this.axiosInstance.post(this.baseURL + "curtain/", form, {headers: headers, responseType:"json"})
|
|
245
241
|
}
|
|
246
242
|
|
|
247
243
|
postSettings(id: string, token: string, onDownloadProgress: any = undefined) {
|