changing typescript output to es5

This commit is contained in:
hibas123 2018-03-04 01:09:59 +01:00
parent 88efc8c7fb
commit 96b050254f
3 changed files with 578 additions and 237 deletions

367
index.js
View File

@ -1,10 +1,55 @@
"use strict"; "use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const rsa = require("node-rsa"); var rsa = require("node-rsa");
require("isomorphic-fetch"); require("isomorphic-fetch");
const btb = require("blob-to-buffer"); var btb = require("blob-to-buffer");
class SecureFile { var SecureFile = /** @class */ (function () {
constructor(server, username, private_key) { function SecureFile(server, username, private_key) {
this.Server = server; this.Server = server;
if (this.Server.endsWith("/")) { if (this.Server.endsWith("/")) {
this.Server += "api"; this.Server += "api";
@ -15,115 +60,225 @@ class SecureFile {
this.Username = username; this.Username = username;
this.PrivateKey = private_key; this.PrivateKey = private_key;
} }
async getCode() { SecureFile.prototype.getCode = function () {
let code_res = await fetch(this.Server + "/code?username=" + this.Username); return __awaiter(this, void 0, void 0, function () {
statusParser(code_res); var code_res, code, r;
//ToDo check status Codes return __generator(this, function (_a) {
let code = (await code_res.json()).code; switch (_a.label) {
let r = new rsa(this.PrivateKey, "pkcs1-pem"); case 0: return [4 /*yield*/, fetch(this.Server + "/code?username=" + this.Username)];
return { code: code, signature: r.sign(code).toString("base64") }; case 1:
} code_res = _a.sent();
async makeRequest(endpoint, method, query, body) { statusParser(code_res);
let code = await this.getCode(); return [4 /*yield*/, code_res.json()];
query.code = code.code; case 2:
query.signature = code.signature; code = (_a.sent()).code;
let query_str = "?"; r = new rsa(this.PrivateKey, "pkcs1-pem");
let first = true; return [2 /*return*/, { code: code, signature: r.sign(code).toString("base64") }];
for (let key in query) { }
if (!first)
query_str += "&";
query_str += encodeURIComponent(key) + "=" + encodeURIComponent(query[key]);
first = false;
}
return await fetch(this.Server + endpoint + query_str, { method: method, body: body });
}
async test() {
let res = await this.makeRequest("/test", "GET", {}, undefined);
statusParser(res);
return await res.json();
}
async list(folder) {
if (!folder)
folder = "root";
let res = await this.makeRequest("/files", "GET", { folder: folder }, undefined);
statusParser(res);
return await res.json();
}
async create(name, data, type, folder, encrypt = true, preview) {
let params = { type: type, name: name, no_encryption: !encrypt };
if (preview) {
params.preview = preview;
}
if (folder) {
params.folder = folder;
}
if (!encrypt) {
params.no_encryption = true;
}
let res = await this.makeRequest("/files", "POST", params, data);
statusParser(res);
return res.json();
}
async get(id, version) {
let res;
if (typeof version === "string") {
res = await this.makeRequest(`/files/${id}/history/${version}`, "GET", {}, undefined);
}
else {
res = await this.makeRequest("/files/" + id, "GET", {}, undefined);
}
statusParser(res);
if (res.buffer) {
return res.buffer();
}
else {
return new Promise(async (resolve, reject) => {
btb(await res.blob(), (err, buffer) => {
if (err)
reject(err);
else
resolve(buffer);
});
}); });
} });
} };
async update(id, data, preview) { SecureFile.prototype.makeRequest = function (endpoint, method, query, body) {
let put = {}; return __awaiter(this, void 0, void 0, function () {
if (preview) var code, query_str, first, key;
put.preview = preview; return __generator(this, function (_a) {
let res = await this.makeRequest("/files/" + id, "PUT", put, data); switch (_a.label) {
statusParser(res); case 0: return [4 /*yield*/, this.getCode()];
return res.json(); case 1:
} code = _a.sent();
async delete(id) { query.code = code.code;
let res = await this.makeRequest("/files/" + id, "DELETE", {}, undefined); query.signature = code.signature;
statusParser(res); query_str = "?";
return res.json(); first = true;
} for (key in query) {
async history(id) { if (!first)
let res = await this.makeRequest(`/files/${id}/history`, "GET", {}, undefined); query_str += "&";
statusParser(res); query_str += encodeURIComponent(key) + "=" + encodeURIComponent(query[key]);
return res.json(); first = false;
} }
} return [4 /*yield*/, fetch(this.Server + endpoint + query_str, { method: method, body: body })];
case 2: return [2 /*return*/, _a.sent()];
}
});
});
};
SecureFile.prototype.test = function () {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.makeRequest("/test", "GET", {}, undefined)];
case 1:
res = _a.sent();
statusParser(res);
return [4 /*yield*/, res.json()];
case 2: return [2 /*return*/, _a.sent()];
}
});
});
};
SecureFile.prototype.list = function (folder) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!folder)
folder = "root";
return [4 /*yield*/, this.makeRequest("/files", "GET", { folder: folder }, undefined)];
case 1:
res = _a.sent();
statusParser(res);
return [4 /*yield*/, res.json()];
case 2: return [2 /*return*/, _a.sent()];
}
});
});
};
SecureFile.prototype.create = function (name, data, type, folder, encrypt, preview) {
if (encrypt === void 0) { encrypt = true; }
return __awaiter(this, void 0, void 0, function () {
var params, res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
params = { type: type, name: name, no_encryption: !encrypt };
if (preview) {
params.preview = preview;
}
if (folder) {
params.folder = folder;
}
if (!encrypt) {
params.no_encryption = true;
}
return [4 /*yield*/, this.makeRequest("/files", "POST", params, data)];
case 1:
res = _a.sent();
statusParser(res);
return [2 /*return*/, res.json()];
}
});
});
};
SecureFile.prototype.get = function (id, version) {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(typeof version === "string")) return [3 /*break*/, 2];
return [4 /*yield*/, this.makeRequest("/files/" + id + "/history/" + version, "GET", {}, undefined)];
case 1:
res = _a.sent();
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, this.makeRequest("/files/" + id, "GET", {}, undefined)];
case 3:
res = _a.sent();
_a.label = 4;
case 4:
statusParser(res);
if (res.buffer) {
return [2 /*return*/, res.buffer()];
}
else {
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = btb;
return [4 /*yield*/, res.blob()];
case 1:
_a.apply(void 0, [_b.sent(), function (err, buffer) {
if (err)
reject(err);
else
resolve(buffer);
}]);
return [2 /*return*/];
}
});
}); })];
}
return [2 /*return*/];
}
});
});
};
SecureFile.prototype.update = function (id, data, preview) {
return __awaiter(this, void 0, void 0, function () {
var put, res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
put = {};
if (preview)
put.preview = preview;
return [4 /*yield*/, this.makeRequest("/files/" + id, "PUT", put, data)];
case 1:
res = _a.sent();
statusParser(res);
return [2 /*return*/, res.json()];
}
});
});
};
SecureFile.prototype.delete = function (id) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.makeRequest("/files/" + id, "DELETE", {}, undefined)];
case 1:
res = _a.sent();
statusParser(res);
return [2 /*return*/, res.json()];
}
});
});
};
SecureFile.prototype.history = function (id) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.makeRequest("/files/" + id + "/history", "GET", {}, undefined)];
case 1:
res = _a.sent();
statusParser(res);
return [2 /*return*/, res.json()];
}
});
});
};
return SecureFile;
}());
exports.default = SecureFile; exports.default = SecureFile;
class Unauthorized extends Error { var Unauthorized = /** @class */ (function (_super) {
constructor() { __extends(Unauthorized, _super);
super("Not authorized"); function Unauthorized() {
return _super.call(this, "Not authorized") || this;
} }
} return Unauthorized;
}(Error));
exports.Unauthorized = Unauthorized; exports.Unauthorized = Unauthorized;
class NotFound extends Error { var NotFound = /** @class */ (function (_super) {
constructor() { __extends(NotFound, _super);
super("Not found"); function NotFound() {
return _super.call(this, "Not found") || this;
} }
} return NotFound;
}(Error));
exports.NotFound = NotFound; exports.NotFound = NotFound;
class BadRequest extends Error { var BadRequest = /** @class */ (function (_super) {
constructor() { __extends(BadRequest, _super);
super("Bad request"); function BadRequest() {
return _super.call(this, "Bad request") || this;
} }
} return BadRequest;
}(Error));
exports.BadRequest = BadRequest; exports.BadRequest = BadRequest;
function statusParser(res) { function statusParser(res) {
if (res.status !== 200) { if (res.status !== 200) {

442
test.js
View File

@ -1,149 +1,331 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const rsa = require("node-rsa"); var rsa = require("node-rsa");
const index_1 = require("./index"); var index_1 = require("./index");
const fs_1 = require("fs"); var fs_1 = require("fs");
const buffer_1 = require("buffer"); var buffer_1 = require("buffer");
let sf; var sf;
const testname = "ouiavgbsop687463743"; var testname = "ouiavgbsop687463743";
const testdata = new buffer_1.Buffer("Ich bin ein Test"); var testdata = new buffer_1.Buffer("Ich bin ein Test");
const newTestData = new buffer_1.Buffer("neue test daten"); var newTestData = new buffer_1.Buffer("neue test daten");
const testprev = new buffer_1.Buffer("Ich bin..."); var testprev = new buffer_1.Buffer("Ich bin...");
let testid; var testid;
let testver; var testver;
let testver2; var testver2;
const testfolder = "iabos"; var testfolder = "iabos";
let ftestid; var ftestid;
let e_testid; var e_testid;
let private_key; var private_key;
module.exports = { module.exports = {
setUp: function (finished) { setUp: function (finished) {
let pk = fs_1.readFileSync("./private.pem"); var pk = fs_1.readFileSync("./private.pem");
private_key = pk.toString("utf8"); private_key = pk.toString("utf8");
sf = new index_1.default("http://localhost:3005", "test", private_key); sf = new index_1.default("http://localhost:3005", "test", private_key);
finished(); finished();
}, },
create: async function (test) { create: function (test) {
test.expect(2); return __awaiter(this, void 0, void 0, function () {
let res = await sf.create(testname, testdata, "text", undefined, false, testprev); var res;
test.ok(res); return __generator(this, function (_a) {
test.ok(res._id); switch (_a.label) {
testid = res._id; case 0:
testver = res.version; test.expect(2);
test.done(); return [4 /*yield*/, sf.create(testname, testdata, "text", undefined, false, testprev)];
}, case 1:
test: async function (test) { res = _a.sent();
test.expect(2); test.ok(res);
let res = await sf.test(); test.ok(res._id);
test.ok(res.test); testid = res._id;
test.equal(res.user, "test"); testver = res.version;
test.done(); test.done();
}, return [2 /*return*/];
get: async function (test) {
test.expect(2);
let res = await sf.get(testid);
test.ok(res);
test.equal(res.toString(), testdata.toString());
test.done();
},
list: async function (test) {
test.expect(4);
let res = await sf.list();
test.ok(res);
test.ok(Array.isArray(res), "Is from type Array");
test.ok(res.length > 0, "Do elements exist?");
res.forEach(e => {
if (e._id === testid) {
test.ok(true, "Element is in List");
}
});
test.done();
},
update: async function (test) {
test.expect(5);
let res = await sf.update(testid, newTestData);
test.ok(res);
test.ok(res._id);
test.notEqual(res.version, testver, "Is new version_id generated?");
testver2 = res.version;
let res2 = await sf.get(testid);
test.ok(res2);
test.equal(res2.toString(), newTestData.toString(), "Is fetched data the updated?");
test.done();
},
history: async function (test) {
test.expect(7);
let his = await sf.history(testid);
test.ok(his);
test.ok(his.file);
test.ok(his.history);
test.equal(his.history.length, 1);
test.equal(his.history[0].version, testver);
test.equal(his.file.version, testver2, "Is correct version");
let arch = await sf.get(testid, testver);
test.equal(arch.toString(), testdata.toString(), "Is old version data correct");
test.done();
},
delete: async function (test) {
test.expect(1);
let res = await sf.delete(testid);
test.ok(res);
test.done();
},
folder: {
create: async function (test) {
test.expect(2);
let res = await sf.create(testname, testdata, "text", testfolder, false, testprev);
test.ok(res);
test.ok(res._id);
ftestid = res._id;
testver = res.version;
test.done();
},
list: async function (test) {
test.expect(4);
let res = await sf.list(testfolder);
test.ok(res);
test.ok(Array.isArray(res), "Is from type Array");
test.ok(res.length > 0, "Do elements exist?");
res.forEach(e => {
if (e._id === ftestid) {
test.ok(true, "Element is in List");
} }
}); });
test.done(); });
},
test: function (test) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
test.expect(2);
return [4 /*yield*/, sf.test()];
case 1:
res = _a.sent();
test.ok(res.test);
test.equal(res.user, "test");
test.done();
return [2 /*return*/];
}
});
});
},
get: function (test) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
test.expect(2);
return [4 /*yield*/, sf.get(testid)];
case 1:
res = _a.sent();
test.ok(res);
test.equal(res.toString(), testdata.toString());
test.done();
return [2 /*return*/];
}
});
});
},
list: function (test) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
test.expect(4);
return [4 /*yield*/, sf.list()];
case 1:
res = _a.sent();
test.ok(res);
test.ok(Array.isArray(res), "Is from type Array");
test.ok(res.length > 0, "Do elements exist?");
res.forEach(function (e) {
if (e._id === testid) {
test.ok(true, "Element is in List");
}
});
test.done();
return [2 /*return*/];
}
});
});
},
update: function (test) {
return __awaiter(this, void 0, void 0, function () {
var res, res2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
test.expect(5);
return [4 /*yield*/, sf.update(testid, newTestData)];
case 1:
res = _a.sent();
test.ok(res);
test.ok(res._id);
test.notEqual(res.version, testver, "Is new version_id generated?");
testver2 = res.version;
return [4 /*yield*/, sf.get(testid)];
case 2:
res2 = _a.sent();
test.ok(res2);
test.equal(res2.toString(), newTestData.toString(), "Is fetched data the updated?");
test.done();
return [2 /*return*/];
}
});
});
},
history: function (test) {
return __awaiter(this, void 0, void 0, function () {
var his, arch;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
test.expect(7);
return [4 /*yield*/, sf.history(testid)];
case 1:
his = _a.sent();
test.ok(his);
test.ok(his.file);
test.ok(his.history);
test.equal(his.history.length, 1);
test.equal(his.history[0].version, testver);
test.equal(his.file.version, testver2, "Is correct version");
return [4 /*yield*/, sf.get(testid, testver)];
case 2:
arch = _a.sent();
test.equal(arch.toString(), testdata.toString(), "Is old version data correct");
test.done();
return [2 /*return*/];
}
});
});
},
delete: function (test) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
test.expect(1);
return [4 /*yield*/, sf.delete(testid)];
case 1:
res = _a.sent();
test.ok(res);
test.done();
return [2 /*return*/];
}
});
});
},
folder: {
create: function (test) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
test.expect(2);
return [4 /*yield*/, sf.create(testname, testdata, "text", testfolder, false, testprev)];
case 1:
res = _a.sent();
test.ok(res);
test.ok(res._id);
ftestid = res._id;
testver = res.version;
test.done();
return [2 /*return*/];
}
});
});
}, },
delete: async function (test) { list: function (test) {
test.expect(1); return __awaiter(this, void 0, void 0, function () {
let res = await sf.delete(ftestid); var res;
test.ok(res); return __generator(this, function (_a) {
test.done(); switch (_a.label) {
case 0:
test.expect(4);
return [4 /*yield*/, sf.list(testfolder)];
case 1:
res = _a.sent();
test.ok(res);
test.ok(Array.isArray(res), "Is from type Array");
test.ok(res.length > 0, "Do elements exist?");
res.forEach(function (e) {
if (e._id === ftestid) {
test.ok(true, "Element is in List");
}
});
test.done();
return [2 /*return*/];
}
});
});
},
delete: function (test) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
test.expect(1);
return [4 /*yield*/, sf.delete(ftestid)];
case 1:
res = _a.sent();
test.ok(res);
test.done();
return [2 /*return*/];
}
});
});
}, },
}, },
encryption: { encryption: {
create: async function (test) { create: function (test) {
test.expect(2); return __awaiter(this, void 0, void 0, function () {
let res = await sf.create(testname, testdata, "text", undefined, true, testprev); var res;
test.ok(res); return __generator(this, function (_a) {
test.ok(res._id); switch (_a.label) {
e_testid = res._id; case 0:
testver = res.version; test.expect(2);
test.done(); return [4 /*yield*/, sf.create(testname, testdata, "text", undefined, true, testprev)];
case 1:
res = _a.sent();
test.ok(res);
test.ok(res._id);
e_testid = res._id;
testver = res.version;
test.done();
return [2 /*return*/];
}
});
});
}, },
get: async function (test) { get: function (test) {
let r = new rsa(private_key, "pkcs1-pem"); return __awaiter(this, void 0, void 0, function () {
test.expect(2); var r, res;
let res = await sf.get(e_testid); return __generator(this, function (_a) {
res = r.decrypt(res); switch (_a.label) {
test.ok(res); case 0:
test.equal(res.toString(), testdata.toString()); r = new rsa(private_key, "pkcs1-pem");
test.done(); test.expect(2);
return [4 /*yield*/, sf.get(e_testid)];
case 1:
res = _a.sent();
res = r.decrypt(res);
test.ok(res);
test.equal(res.toString(), testdata.toString());
test.done();
return [2 /*return*/];
}
});
});
}, },
delete: async function (test) { delete: function (test) {
test.expect(1); return __awaiter(this, void 0, void 0, function () {
let res = await sf.delete(e_testid); var res;
test.ok(res); return __generator(this, function (_a) {
test.done(); switch (_a.label) {
case 0:
test.expect(1);
return [4 /*yield*/, sf.delete(e_testid)];
case 1:
res = _a.sent();
test.ok(res);
test.done();
return [2 /*return*/];
}
});
});
}, },
} }
}; };

View File

@ -1,13 +1,17 @@
{ {
"compilerOptions": { "compilerOptions": {
/* Basic Options */ /* Basic Options */
"target": "es2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation: */ // "lib": [], /* Specify library files to be included in the compilation: */
// "allowJs": true, /* Allow javascript files to be compiled. */ // "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */ // "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"declaration": true, /* Generates corresponding '.d.ts' file. */ "declaration": true, /* Generates corresponding '.d.ts' file. */
"lib": [
"es6",
"dom"
],
// "sourceMap": true, /* Generates corresponding '.map' file. */ // "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */ // "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */ // "outDir": "./", /* Redirect output structure to the directory. */