Comparing version 4.0.3-beta to 4.0.4-beta
@@ -170,6 +170,4 @@ "use strict"; | ||
if (!url) { | ||
var _config$extraPath; | ||
const portalUrl = await this.portalUrl(); | ||
url = (0, _url.makeUrl)(portalUrl, config.endpointPath, (_config$extraPath = config.extraPath) !== null && _config$extraPath !== void 0 ? _config$extraPath : ""); | ||
url = (0, _url.makeUrl)(portalUrl, config.endpointPath, config.extraPath ?? ""); | ||
} | ||
@@ -176,0 +174,0 @@ |
@@ -129,4 +129,2 @@ "use strict"; | ||
function getSkylinkUrlForPortal(portalUrl, skylinkUrl, customOptions) { | ||
var _opts$query; | ||
(0, _validation.validateString)("portalUrl", portalUrl, "parameter"); | ||
@@ -138,3 +136,3 @@ (0, _validation.validateString)("skylinkUrl", skylinkUrl, "parameter"); | ||
}; | ||
const query = (_opts$query = opts.query) !== null && _opts$query !== void 0 ? _opts$query : {}; | ||
const query = opts.query ?? {}; | ||
@@ -156,3 +154,3 @@ if (opts.download) { | ||
if (typeof opts.path !== "string") { | ||
throw new Error("opts.path has to be a string, ".concat(typeof opts.path, " provided")); | ||
throw new Error(`opts.path has to be a string, ${typeof opts.path} provided`); | ||
} // Encode each element of the path separately and join them. | ||
@@ -171,8 +169,6 @@ // | ||
if (opts.subdomain) { | ||
var _parseSkylink; | ||
// Get the path from the skylink. Use the empty string if not found. | ||
const skylinkPath = (_parseSkylink = (0, _parse.parseSkylink)(skylinkUrl, { | ||
const skylinkPath = (0, _parse.parseSkylink)(skylinkUrl, { | ||
onlyPath: true | ||
})) !== null && _parseSkylink !== void 0 ? _parseSkylink : ""; // Get just the skylink. | ||
}) ?? ""; // Get just the skylink. | ||
@@ -182,3 +178,3 @@ let skylink = (0, _parse.parseSkylink)(skylinkUrl); | ||
if (skylink === null) { | ||
throw new Error("Could not get skylink out of input '".concat(skylinkUrl, "'")); | ||
throw new Error(`Could not get skylink out of input '${skylinkUrl}'`); | ||
} // Convert the skylink (without the path) to base32. | ||
@@ -197,3 +193,3 @@ | ||
if (skylink === null) { | ||
throw new Error("Could not get skylink with path out of input '".concat(skylinkUrl, "'")); | ||
throw new Error(`Could not get skylink with path out of input '${skylinkUrl}'`); | ||
} // Add additional path if passed in. | ||
@@ -220,4 +216,2 @@ | ||
async function getHnsUrl(domain, customOptions) { | ||
var _opts$query2; | ||
(0, _validation.validateString)("domain", domain, "parameter"); | ||
@@ -229,3 +223,3 @@ (0, _validation.validateOptionalObject)("customOptions", customOptions, "parameter", defaultDownloadHnsOptions); | ||
}; | ||
const query = (_opts$query2 = opts.query) !== null && _opts$query2 !== void 0 ? _opts$query2 : {}; | ||
const query = opts.query ?? {}; | ||
@@ -281,4 +275,2 @@ if (opts.download) { | ||
async function getMetadata(skylinkUrl, customOptions) { | ||
var _response$headers$con, _response$headers$sky; | ||
// Validation is done in `getSkylinkUrl`. | ||
@@ -300,5 +292,5 @@ const opts = { ...defaultDownloadOptions, | ||
const contentType = (_response$headers$con = response.headers["content-type"]) !== null && _response$headers$con !== void 0 ? _response$headers$con : ""; | ||
const contentType = response.headers["content-type"] ?? ""; | ||
const metadata = response.headers["skynet-file-metadata"] ? JSON.parse(response.headers["skynet-file-metadata"]) : {}; | ||
const portalUrl = (_response$headers$sky = response.headers["skynet-portal-api"]) !== null && _response$headers$sky !== void 0 ? _response$headers$sky : ""; | ||
const portalUrl = response.headers["skynet-portal-api"] ?? ""; | ||
const skylink = response.headers["skynet-skylink"] ? (0, _format.formatSkylink)(response.headers["skynet-skylink"]) : ""; | ||
@@ -366,4 +358,2 @@ return { | ||
async function getFileContentRequest(url, customOptions) { | ||
var _response$headers$con2, _response$headers$sky2; | ||
// Not publicly available, don't validate input. | ||
@@ -389,5 +379,5 @@ const opts = { ...defaultDownloadOptions, | ||
const contentType = (_response$headers$con2 = response.headers["content-type"]) !== null && _response$headers$con2 !== void 0 ? _response$headers$con2 : ""; | ||
const contentType = response.headers["content-type"] ?? ""; | ||
const metadata = response.headers["skynet-file-metadata"] ? JSON.parse(response.headers["skynet-file-metadata"]) : {}; | ||
const portalUrl = (_response$headers$sky2 = response.headers["skynet-portal-api"]) !== null && _response$headers$sky2 !== void 0 ? _response$headers$sky2 : ""; | ||
const portalUrl = response.headers["skynet-portal-api"] ?? ""; | ||
const skylink = response.headers["skynet-skylink"] ? (0, _format.formatSkylink)(response.headers["skynet-skylink"]) : ""; | ||
@@ -484,4 +474,4 @@ return { | ||
} catch (err) { | ||
throw new Error("Did not get a complete resolve HNS response despite a successful request. Please try again and report this issue to the devs if it persists. Error: ".concat(err)); | ||
throw new Error(`Did not get a complete resolve HNS response despite a successful request. Please try again and report this issue to the devs if it persists. Error: ${err}`); | ||
} | ||
} |
@@ -21,11 +21,11 @@ "use strict"; | ||
const skylinkUrl = (0, _download.getSkylinkUrlForPortal)(portalUrl, skylink); | ||
const sialink = "".concat(_index.uriSkynetPrefix).concat(skylink); | ||
const validSkylinkVariations = (0, _testing.combineStrings)(["", "sia:", "sia://", "https://siasky.net/", "https://foo.siasky.net/", "https://".concat(skylinkBase32, ".siasky.net/")], [skylink], ["", "/", "//", "/foo", "/foo/", "/foo/bar", "/foo/bar/", "/foo/bar//"], ["", "?", "?foo=bar", "?foo=bar&bar=baz"], ["", "#", "#foo", "#foo?bar"]); | ||
const validHnsLinkVariations = [hnsLink, "hns:".concat(hnsLink), "hns://".concat(hnsLink)]; | ||
const validHnsresLinkVariations = [hnsLink, "hnsres:".concat(hnsLink), "hnsres://".concat(hnsLink)]; | ||
const sialink = `${_index.uriSkynetPrefix}${skylink}`; | ||
const validSkylinkVariations = (0, _testing.combineStrings)(["", "sia:", "sia://", "https://siasky.net/", "https://foo.siasky.net/", `https://${skylinkBase32}.siasky.net/`], [skylink], ["", "/", "//", "/foo", "/foo/", "/foo/bar", "/foo/bar/", "/foo/bar//"], ["", "?", "?foo=bar", "?foo=bar&bar=baz"], ["", "#", "#foo", "#foo?bar"]); | ||
const validHnsLinkVariations = [hnsLink, `hns:${hnsLink}`, `hns://${hnsLink}`]; | ||
const validHnsresLinkVariations = [hnsLink, `hnsres:${hnsLink}`, `hnsres://${hnsLink}`]; | ||
const attachment = "?attachment=true"; | ||
const expectedUrl = "".concat(portalUrl, "/").concat(skylink); | ||
const expectedHnsUrl = "".concat(portalUrl, "/hns/").concat(hnsLink); | ||
const expectedHnsUrlSubdomain = "https://".concat(hnsLink, ".hns.siasky.net"); | ||
const expectedHnsresUrl = "".concat(portalUrl, "/hnsres/").concat(hnsLink); | ||
const expectedUrl = `${portalUrl}/${skylink}`; | ||
const expectedHnsUrl = `${portalUrl}/hns/${hnsLink}`; | ||
const expectedHnsUrlSubdomain = `https://${hnsLink}.hns.siasky.net`; | ||
const expectedHnsresUrl = `${portalUrl}/hnsres/${hnsLink}`; | ||
const mockLocationAssign = jest.fn(); | ||
@@ -43,3 +43,3 @@ Object.defineProperty(window, "location", { | ||
const path = (0, _testing.extractNonSkylinkPath)(fullSkylink, skylink); | ||
let fullExpectedUrl = "".concat(expectedUrl).concat(path).concat(attachment); // Change ?attachment=true to &attachment=true if need be. | ||
let fullExpectedUrl = `${expectedUrl}${path}${attachment}`; // Change ?attachment=true to &attachment=true if need be. | ||
@@ -57,3 +57,3 @@ if ((fullExpectedUrl.match(/\?/g) || []).length > 1) { | ||
}); | ||
expect(url).toEqual("".concat(expectedUrl, "/dir/test%3Fencoding").concat(attachment)); | ||
expect(url).toEqual(`${expectedUrl}/dir/test%3Fencoding${attachment}`); | ||
}); | ||
@@ -66,3 +66,3 @@ it("should download with query parameters being appended to the URL", async () => { | ||
}); | ||
expect(url).toEqual("".concat(expectedUrl, "?name=test&attachment=true")); | ||
expect(url).toEqual(`${expectedUrl}?name=test&attachment=true`); | ||
}); | ||
@@ -73,3 +73,3 @@ }); | ||
const url = await client.downloadFileHns(input); | ||
expect(url).toEqual("".concat(expectedHnsUrl).concat(attachment)); | ||
expect(url).toEqual(`${expectedHnsUrl}${attachment}`); | ||
}); | ||
@@ -88,3 +88,3 @@ }); | ||
}); | ||
expect(url).toEqual("".concat(expectedHnsUrl).concat(attachment)); | ||
expect(url).toEqual(`${expectedHnsUrl}${attachment}`); | ||
}); | ||
@@ -95,3 +95,3 @@ it("should return correctly formed hns URL with no-response-metadata set", async () => { | ||
}); | ||
expect(url).toEqual("".concat(expectedHnsUrl, "?no-response-metadata=true")); | ||
expect(url).toEqual(`${expectedHnsUrl}?no-response-metadata=true`); | ||
}); | ||
@@ -105,6 +105,6 @@ }); | ||
describe("getSkylinkUrl", () => { | ||
const expectedUrl = "".concat(portalUrl, "/").concat(skylink); | ||
const expectedUrl = `${portalUrl}/${skylink}`; | ||
it.each(validSkylinkVariations)("should return correctly formed skylink URL using skylink %s", async fullSkylink => { | ||
const path = (0, _testing.extractNonSkylinkPath)(fullSkylink, skylink); | ||
expect(await client.getSkylinkUrl(fullSkylink)).toEqual("".concat(expectedUrl).concat(path)); | ||
expect(await client.getSkylinkUrl(fullSkylink)).toEqual(`${expectedUrl}${path}`); | ||
}); | ||
@@ -114,6 +114,6 @@ it("should return correctly formed URLs when path is given", async () => { | ||
path: "foo/bar" | ||
})).toEqual("".concat(expectedUrl, "/foo/bar")); | ||
})).toEqual(`${expectedUrl}/foo/bar`); | ||
expect(await client.getSkylinkUrl(skylink, { | ||
path: "foo?bar" | ||
})).toEqual("".concat(expectedUrl, "/foo%3Fbar")); | ||
})).toEqual(`${expectedUrl}/foo%3Fbar`); | ||
}); | ||
@@ -125,3 +125,3 @@ it("should return correctly formed URL with forced download", async () => { | ||
}); | ||
expect(url).toEqual("".concat(portalUrl, "/skynet/skylink/").concat(skylink).concat(attachment)); | ||
expect(url).toEqual(`${portalUrl}/skynet/skylink/${skylink}${attachment}`); | ||
}); | ||
@@ -133,3 +133,3 @@ it("should return correctly formed URLs with forced download and path", async () => { | ||
}); | ||
expect(url).toEqual("".concat(expectedUrl, "/foo%3Fbar").concat(attachment)); | ||
expect(url).toEqual(`${expectedUrl}/foo%3Fbar${attachment}`); | ||
}); | ||
@@ -140,3 +140,3 @@ it("should return correctly formed URLs with no-response-metadata set", async () => { | ||
}); | ||
expect(url).toEqual("".concat(expectedUrl, "?no-response-metadata=true")); | ||
expect(url).toEqual(`${expectedUrl}?no-response-metadata=true`); | ||
}); | ||
@@ -148,5 +148,5 @@ it("should return correctly formed URLs with no-response-metadata set and with forced download", async () => { | ||
}); | ||
expect(url).toEqual("".concat(expectedUrl, "?attachment=true&no-response-metadata=true")); | ||
expect(url).toEqual(`${expectedUrl}?attachment=true&no-response-metadata=true`); | ||
}); | ||
const expectedBase32 = "https://".concat(skylinkBase32, ".siasky.net"); | ||
const expectedBase32 = `https://${skylinkBase32}.siasky.net`; | ||
it.each(validSkylinkVariations)("should convert base64 skylink to base32 using skylink %s", async fullSkylink => { | ||
@@ -157,3 +157,3 @@ const path = (0, _testing.extractNonSkylinkPath)(fullSkylink, skylink); | ||
}); | ||
expect(url).toEqual("".concat(expectedBase32).concat(path)); | ||
expect(url).toEqual(`${expectedBase32}${path}`); | ||
}); | ||
@@ -166,3 +166,3 @@ it("should throw if passing a non-string path", async () => { | ||
}); | ||
const invalidCases = ["123", "".concat(skylink, "xxx"), "".concat(skylink, "xxx/foo"), "".concat(skylink, "xxx?foo")]; | ||
const invalidCases = ["123", `${skylink}xxx`, `${skylink}xxx/foo`, `${skylink}xxx?foo`]; | ||
it.each(invalidCases)("should throw on invalid skylink %s", async invalidSkylink => { | ||
@@ -298,3 +298,3 @@ await expect(client.getSkylinkUrl(invalidSkylink)).rejects.toThrow(); | ||
expect(windowOpen).toHaveBeenCalledTimes(1); | ||
expect(windowOpen).toHaveBeenCalledWith("".concat(expectedUrl).concat(path), "_blank"); | ||
expect(windowOpen).toHaveBeenCalledWith(`${expectedUrl}${path}`, "_blank"); | ||
}); | ||
@@ -310,3 +310,3 @@ }); | ||
describe("openFileHns", () => { | ||
const hnsUrl = "".concat(portalUrl, "/hns/").concat(hnsLink); | ||
const hnsUrl = `${portalUrl}/hns/${hnsLink}`; | ||
let mock; | ||
@@ -313,0 +313,0 @@ beforeEach(() => { |
@@ -13,3 +13,3 @@ "use strict"; | ||
pass: false, | ||
message: () => "expected ".concat(received, " to equal ").concat(argument) | ||
message: () => `expected ${received} to equal ${argument}` | ||
}; | ||
@@ -22,3 +22,3 @@ } | ||
pass: false, | ||
message: () => "expected ".concat(received, " to equal ").concat(argument) | ||
message: () => `expected ${received} to equal ${argument}` | ||
}; | ||
@@ -30,3 +30,3 @@ } | ||
pass: true, | ||
message: () => "expected ".concat(received, " not to equal ").concat(argument) | ||
message: () => `expected ${received} not to equal ${argument}` | ||
}; | ||
@@ -33,0 +33,0 @@ } |
@@ -15,3 +15,3 @@ "use strict"; | ||
it("should ensure the skylink starts with the prefix", () => { | ||
const prefixedSkylink = "sia:".concat(skylink); | ||
const prefixedSkylink = `sia:${skylink}`; | ||
expect((0, _format.formatSkylink)(skylink)).toEqual(prefixedSkylink); | ||
@@ -18,0 +18,0 @@ expect((0, _format.formatSkylink)(prefixedSkylink)).toEqual(prefixedSkylink); |
@@ -13,3 +13,3 @@ "use strict"; | ||
toEqualPortalUrl(received, argument) { | ||
const prefix = "".concat(received.split("//", 1)[0], "//"); | ||
const prefix = `${received.split("//", 1)[0]}//`; | ||
const expectedUrl = (0, _string.trimPrefix)(argument, prefix); | ||
@@ -21,3 +21,3 @@ const receivedUrl = (0, _string.trimPrefix)(received, prefix); // Support the case where we receive siasky.net while expecting eu-fin-1.siasky.net. | ||
pass: false, | ||
message: () => "expected ".concat(received, " to equal ").concat(argument) | ||
message: () => `expected ${received} to equal ${argument}` | ||
}; | ||
@@ -28,3 +28,3 @@ } | ||
pass: true, | ||
message: () => "expected ".concat(received, " not to equal ").concat(argument) | ||
message: () => `expected ${received} not to equal ${argument}` | ||
}; | ||
@@ -34,3 +34,3 @@ } | ||
}); | ||
describe("Integration test for portal ".concat(portal), () => { | ||
describe(`Integration test for portal ${portal}`, () => { | ||
describe("File API integration tests", () => { | ||
@@ -195,53 +195,46 @@ it("Should get existing File API data", async () => { | ||
} | ||
}; | ||
it("Should upload and download directories", async () => { | ||
const directory = { | ||
"i-am-not/file1.jpeg": new File(["foo1"], "i-am-not/file1.jpeg"), | ||
"i-am-not/file2.jpeg": new File(["foo2"], "i-am-not/file2.jpeg"), | ||
"i-am-not/me-neither/file3.jpeg": new File(["foo3"], "i-am-not/me-neither/file3.jpeg") | ||
}; | ||
const dirMetadata = { | ||
filename: "dirname", | ||
length: 12, | ||
subfiles: { | ||
"i-am-not:file1.jpeg": { | ||
contenttype: "image/jpeg", | ||
filename: "i-am-not:file1.jpeg", | ||
len: 4 | ||
}, | ||
"i-am-not:file2.jpeg": { | ||
contenttype: "image/jpeg", | ||
filename: "i-am-not:file2.jpeg", | ||
len: 4, | ||
offset: 4 | ||
}, | ||
"i-am-not:me-neither:file3.jpeg": { | ||
contenttype: "image/jpeg", | ||
filename: "i-am-not:me-neither:file3.jpeg", | ||
len: 4, | ||
offset: 8 | ||
} | ||
} | ||
}; | ||
const dirname = "dirname"; | ||
const dirType = "application/zip"; | ||
const { | ||
skylink | ||
} = await client.uploadDirectory(directory, dirname); | ||
expect(skylink).not.toEqual(""); // Get file content and check returned values. | ||
}; // TODO: This test is broken in Node. | ||
// it("Should upload and download directories", async () => { | ||
// const directory = { | ||
// "i-am-not/file1.jpeg": new File(["foo1"], "i-am-not/file1.jpeg"), | ||
// "i-am-not/file2.jpeg": new File(["foo2"], "i-am-not/file2.jpeg"), | ||
// "i-am-not/me-neither/file3.jpeg": new File(["foo3"], "i-am-not/me-neither/file3.jpeg"), | ||
// }; | ||
// const dirMetadata = { | ||
// filename: "dirname", | ||
// length: 12, | ||
// subfiles: { | ||
// "i-am-not:file1.jpeg": { | ||
// contenttype: "image/jpeg", | ||
// filename: "i-am-not:file1.jpeg", | ||
// len: 4, | ||
// }, | ||
// "i-am-not:file2.jpeg": { | ||
// contenttype: "image/jpeg", | ||
// filename: "i-am-not:file2.jpeg", | ||
// len: 4, | ||
// offset: 4, | ||
// }, | ||
// "i-am-not:me-neither:file3.jpeg": { | ||
// contenttype: "image/jpeg", | ||
// filename: "i-am-not:me-neither:file3.jpeg", | ||
// len: 4, | ||
// offset: 8, | ||
// }, | ||
// }, | ||
// }; | ||
// const dirname = "dirname"; | ||
// const dirType = "application/zip"; | ||
// const { skylink } = await client.uploadDirectory(directory, dirname); | ||
// expect(skylink).not.toEqual(""); | ||
// // Get file content and check returned values. | ||
// const resp = await client.getFileContent(skylink); | ||
// const { data, contentType, metadata, portalUrl, skylink: returnedSkylink } = resp; | ||
// expect(data).toEqual(expect.any(String)); | ||
// expect(contentType).toEqual(dirType); | ||
// expect(metadata).toEqual(dirMetadata); | ||
// expect(portalUrl).toEqualPortalUrl(portal); | ||
// expect(skylink).toEqual(returnedSkylink); | ||
// }); | ||
const resp = await client.getFileContent(skylink); | ||
const { | ||
data, | ||
contentType, | ||
metadata, | ||
portalUrl, | ||
skylink: returnedSkylink | ||
} = resp; | ||
expect(data).toEqual(expect.any(String)); | ||
expect(contentType).toEqual(dirType); | ||
expect(metadata).toEqual(dirMetadata); | ||
expect(portalUrl).toEqualPortalUrl(portal); | ||
expect(skylink).toEqual(returnedSkylink); | ||
}); | ||
it("Should get plaintext file contents", async () => { | ||
@@ -309,3 +302,3 @@ // Upload the data to acquire its skylink. | ||
// Upload the data to acquire its skylink. Content type is inferred from filename. | ||
const file = new File([JSON.stringify(json)], "".concat(dataKey, ".json")); | ||
const file = new File([JSON.stringify(json)], `${dataKey}.json`); | ||
const { | ||
@@ -312,0 +305,0 @@ skylink |
@@ -5,2 +5,3 @@ export type { CustomConnectorOptions } from "./connector"; | ||
import { Permission } from "skynet-mysky-utils"; | ||
import type { CustomUserIDOptions } from "skynet-mysky-utils"; | ||
import { Connector, CustomConnectorOptions } from "./connector"; | ||
@@ -12,6 +13,6 @@ import { SkynetClient } from "../client"; | ||
import { Signature } from "../crypto"; | ||
export declare function loadMySky(this: SkynetClient, skappDomain?: string, customOptions?: CustomConnectorOptions): Promise<MySky>; | ||
export declare const mySkyDomain = "skynet-mysky.hns"; | ||
export declare const mySkyDevDomain = "skynet-mysky-dev.hns"; | ||
export declare const mySkyAlphaDomain = "sandbridge.hns"; | ||
export declare function loadMySky(this: SkynetClient, skappDomain?: string, customOptions?: CustomConnectorOptions): Promise<MySky>; | ||
export declare class MySky { | ||
@@ -44,3 +45,3 @@ protected connector: Connector; | ||
requestLoginAccess(): Promise<boolean>; | ||
userID(): Promise<string>; | ||
userID(opts?: CustomUserIDOptions): Promise<string>; | ||
/** | ||
@@ -47,0 +48,0 @@ * Gets Discoverable JSON at the given path through MySky, if the user has given permissions to do so. |
@@ -41,7 +41,2 @@ "use strict"; | ||
async function loadMySky(skappDomain, customOptions) { | ||
const mySky = await MySky.New(this, skappDomain, customOptions); | ||
return mySky; | ||
} | ||
const mySkyDomain = "skynet-mysky.hns"; | ||
@@ -57,2 +52,7 @@ exports.mySkyDomain = mySkyDomain; | ||
async function loadMySky(skappDomain, customOptions) { | ||
const mySky = await MySky.New(this, skappDomain, customOptions); | ||
return mySky; | ||
} | ||
class MySky { | ||
@@ -227,4 +227,4 @@ // ============ | ||
async userID() { | ||
return await this.connector.connection.remoteHandle().call("userID"); | ||
async userID(opts) { | ||
return await this.connector.connection.remoteHandle().call("userID", opts); | ||
} | ||
@@ -321,3 +321,3 @@ /** | ||
if (!childWindow) { | ||
throw new Error("Could not open window at '".concat(uiUrl, "'")); | ||
throw new Error(`Could not open window at '${uiUrl}'`); | ||
} | ||
@@ -324,0 +324,0 @@ |
@@ -46,3 +46,9 @@ "use strict"; | ||
const top = (height - h) / 2 / systemZoom + dualScreenTop; | ||
const newWindow = window.open(url, title, "\nscrollbars=yes,\nwidth=".concat(w / systemZoom, ",\nheight=").concat(h / systemZoom, ",\ntop=").concat(top, ",\nleft=").concat(left, "\n")); | ||
const newWindow = window.open(url, title, ` | ||
scrollbars=yes, | ||
width=${w / systemZoom}, | ||
height=${h / systemZoom}, | ||
top=${top}, | ||
left=${left} | ||
`); | ||
@@ -49,0 +55,0 @@ if (!newWindow) { |
@@ -10,3 +10,3 @@ "use strict"; | ||
describe("parseSkylink", () => { | ||
const basicCases = (0, _testing.combineStrings)(["", "sia:", "sia://", "https://siasky.net/", "https://foo.siasky.net/", "https://".concat(skylinkBase32, ".siasky.net/")], [skylink], ["", "/", "//", "/foo", "/foo/", "/foo/bar", "/foo/bar/"], ["", "?", "?foo=bar", "?foo=bar&bar=baz"], ["", "#", "#foo", "#foo?bar"]); | ||
const basicCases = (0, _testing.combineStrings)(["", "sia:", "sia://", "https://siasky.net/", "https://foo.siasky.net/", `https://${skylinkBase32}.siasky.net/`], [skylink], ["", "/", "//", "/foo", "/foo/", "/foo/bar", "/foo/bar/"], ["", "?", "?foo=bar", "?foo=bar&bar=baz"], ["", "#", "#foo", "#foo?bar"]); | ||
it.each(basicCases)("should extract skylink and path from %s", fullSkylink => { | ||
@@ -16,3 +16,3 @@ expect((0, _parse.parseSkylink)(fullSkylink)).toEqual(skylink); // Check that we extract the path correctly. | ||
const path = (0, _testing.extractNonSkylinkPath)(fullSkylink, skylink); | ||
const fullPath = "".concat(skylink).concat(path); | ||
const fullPath = `${skylink}${path}`; | ||
expect((0, _parse.parseSkylink)(fullSkylink, { | ||
@@ -25,3 +25,3 @@ includePath: true | ||
}); | ||
const subdomainCases = (0, _testing.combineStrings)(["https://"], [skylinkBase32], [".siasky.net", ".foo.siasky.net"], ["", "/", "//", "/foo", "/foo", "/foo/", "/foo/bar", "/foo/bar/", "/".concat(skylink)], ["", "?", "?foo=bar", "?foo=bar&bar=baz"], ["", "#", "#foo", "#foo?bar"]); | ||
const subdomainCases = (0, _testing.combineStrings)(["https://"], [skylinkBase32], [".siasky.net", ".foo.siasky.net"], ["", "/", "//", "/foo", "/foo", "/foo/", "/foo/bar", "/foo/bar/", `/${skylink}`], ["", "?", "?foo=bar", "?foo=bar&bar=baz"], ["", "#", "#foo", "#foo?bar"]); | ||
it.each(subdomainCases)("should extract base32 skylink from %s", fullSkylink => { | ||
@@ -46,3 +46,3 @@ expect((0, _parse.parseSkylink)(fullSkylink, { | ||
}); | ||
const invalidCases = ["123", "".concat(skylink, "xxx"), "".concat(skylink, "xxx/foo"), "".concat(skylink, "xxx?foo")]; | ||
const invalidCases = ["123", `${skylink}xxx`, `${skylink}xxx/foo`, `${skylink}xxx?foo`]; | ||
it.each(invalidCases)("should return null on invalid case %s", fullSkylink => { | ||
@@ -52,3 +52,3 @@ expect((0, _parse.parseSkylink)(fullSkylink)).toBeNull(); | ||
it("should return null on invalid base32 subdomain", () => { | ||
const badUrl = "https://".concat(skylinkBase32, "xxx.siasky.net"); | ||
const badUrl = `https://${skylinkBase32}xxx.siasky.net`; | ||
expect((0, _parse.parseSkylink)(badUrl, { | ||
@@ -55,0 +55,0 @@ fromSubdomain: true |
@@ -120,3 +120,3 @@ "use strict"; | ||
} catch (err) { | ||
throw new Error("Did not get a complete entry response despite a successful request. Please try again and report this issue to the devs if it persists. Error: ".concat(err)); | ||
throw new Error(`Did not get a complete entry response despite a successful request. Please try again and report this issue to the devs if it persists. Error: ${err}`); | ||
} // Use empty string if the data is empty. | ||
@@ -192,3 +192,3 @@ | ||
if (!(0, _string.isHexString)(publicKey)) { | ||
throw new Error("Given public key '".concat(publicKey, "' is not a valid hex-encoded string or contains an invalid prefix")); | ||
throw new Error(`Given public key '${publicKey}' is not a valid hex-encoded string or contains an invalid prefix`); | ||
} // Hash and hex encode the given data key if it is not a hash already. | ||
@@ -204,3 +204,3 @@ | ||
const query = { | ||
publickey: "ed25519:".concat(publicKey), | ||
publickey: `ed25519:${publicKey}`, | ||
datakey: dataKeyHashHex, | ||
@@ -236,3 +236,3 @@ timeout: DEFAULT_GET_ENTRY_TIMEOUT | ||
if (!(0, _string.isHexString)(publicKey)) { | ||
throw new Error("Given public key '".concat(publicKey, "' is not a valid hex-encoded string or contains an invalid prefix")); | ||
throw new Error(`Given public key '${publicKey}' is not a valid hex-encoded string or contains an invalid prefix`); | ||
} | ||
@@ -337,5 +337,5 @@ | ||
(0, _validation.validateObject)(name, value, valueKind); | ||
(0, _validation.validateString)("".concat(name, ".dataKey"), value.dataKey, "".concat(valueKind, " field")); | ||
(0, _validation.validateString)("".concat(name, ".data"), value.data, "".concat(valueKind, " field")); | ||
(0, _validation.validateBigint)("".concat(name, ".revision"), value.revision, "".concat(valueKind, " field")); | ||
(0, _validation.validateString)(`${name}.dataKey`, value.dataKey, `${valueKind} field`); | ||
(0, _validation.validateString)(`${name}.data`, value.data, `${valueKind} field`); | ||
(0, _validation.validateBigint)(`${name}.revision`, value.revision, `${valueKind} field`); | ||
} | ||
@@ -354,3 +354,3 @@ /** | ||
if (!err.response) { | ||
throw new Error("Error response field not found, incomplete Axios error. Full error: ".concat(err)); | ||
throw new Error(`Error response field not found, incomplete Axios error. Full error: ${err}`); | ||
} | ||
@@ -361,3 +361,3 @@ /* istanbul ignore next */ | ||
if (!err.response.status) { | ||
throw new Error("Error response did not contain expected field 'status'. Full error: ".concat(err)); | ||
throw new Error(`Error response did not contain expected field 'status'. Full error: ${err}`); | ||
} // Check if status was 404 "not found" and return null if so. | ||
@@ -364,0 +364,0 @@ |
@@ -36,3 +36,9 @@ "use strict"; | ||
it("should throw if the response status is not in the 200s and not 404 and HTML is returned", async () => { | ||
const responseHTML = "\n<head><title>429 Too Many Requests</title></head>\n<body>\n<center><h1>429 Too Many Requests</h1></center>\n<hr><center>openresty/1.19.3.1</center>\n</body>\n</html>"; | ||
const responseHTML = ` | ||
<head><title>429 Too Many Requests</title></head> | ||
<body> | ||
<center><h1>429 Too Many Requests</h1></center> | ||
<hr><center>openresty/1.19.3.1</center> | ||
</body> | ||
</html>`; | ||
mock.onGet(registryLookupUrl).replyOnce(429, responseHTML); | ||
@@ -77,3 +83,3 @@ await expect(client.registry.getEntry(publicKey, dataKey)).rejects.toThrowError("Request failed with status code 429"); | ||
const url = await client.registry.getEntryUrl(publicKey, dataKey); | ||
expect(url).toEqual("".concat(portalUrl, "/skynet/registry?publickey=").concat(encodedPK, "&datakey=").concat(encodedDK, "&timeout=5")); | ||
expect(url).toEqual(`${portalUrl}/skynet/registry?publickey=${encodedPK}&datakey=${encodedDK}&timeout=5`); | ||
}); | ||
@@ -90,4 +96,4 @@ it("Should throw if a timeout is provided", async () => { | ||
it("should trim the prefix if it is provided", async () => { | ||
const url = await client.registry.getEntryUrl("ed25519:".concat(publicKey), dataKey); | ||
expect(url).toEqual("".concat(portalUrl, "/skynet/registry?publickey=").concat(encodedPK, "&datakey=").concat(encodedDK, "&timeout=5")); | ||
const url = await client.registry.getEntryUrl(`ed25519:${publicKey}`, dataKey); | ||
expect(url).toEqual(`${portalUrl}/skynet/registry?publickey=${encodedPK}&datakey=${encodedDK}&timeout=5`); | ||
}); | ||
@@ -94,0 +100,0 @@ }); |
@@ -13,3 +13,3 @@ "use strict"; | ||
pass: false, | ||
message: () => "expected ".concat(received, " to equal ").concat(argument) | ||
message: () => `expected ${received} to equal ${argument}` | ||
}; | ||
@@ -22,3 +22,3 @@ } | ||
pass: false, | ||
message: () => "expected ".concat(received, " to equal ").concat(argument) | ||
message: () => `expected ${received} to equal ${argument}` | ||
}; | ||
@@ -30,3 +30,3 @@ } | ||
pass: true, | ||
message: () => "expected ".concat(received, " not to equal ").concat(argument) | ||
message: () => `expected ${received} not to equal ${argument}` | ||
}; | ||
@@ -33,0 +33,0 @@ } |
@@ -83,3 +83,3 @@ "use strict"; | ||
if (typeof data !== "object" || data === null) { | ||
throw new Error("File data for the entry at data key '".concat(dataKey, "' is not JSON.")); | ||
throw new Error(`File data for the entry at data key '${dataKey}' is not JSON.`); | ||
} | ||
@@ -98,3 +98,3 @@ | ||
if (typeof actualData !== "object" || data === null) { | ||
throw new Error("File data '_data' for the entry at data key '".concat(dataKey, "' is not JSON.")); | ||
throw new Error(`File data '_data' for the entry at data key '${dataKey}' is not JSON.`); | ||
} | ||
@@ -161,3 +161,3 @@ | ||
const file = new File([JSON.stringify(data)], "dk:".concat(dataKeyHex), { | ||
const file = new File([JSON.stringify(data)], `dk:${dataKeyHex}`, { | ||
type: "application/json" | ||
@@ -164,0 +164,0 @@ }); // Start file upload, do not block. |
@@ -37,5 +37,5 @@ "use strict"; | ||
const client = new _index.SkynetClient(portalUrl); | ||
const registryUrl = "".concat(portalUrl, "/skynet/registry"); | ||
const registryUrl = `${portalUrl}/skynet/registry`; | ||
const registryLookupUrl = (0, _registry.getEntryUrlForPortal)(portalUrl, publicKey, dataKey); | ||
const uploadUrl = "".concat(portalUrl, "/skynet/skyfile"); | ||
const uploadUrl = `${portalUrl}/skynet/skyfile`; | ||
const skylinkUrl = (0, _download.getSkylinkUrlForPortal)(portalUrl, skylink); | ||
@@ -87,3 +87,3 @@ const data = "43414241425f31447430464a73787173755f4a34546f644e4362434776744666315579735f3345677a4f6c546367"; | ||
mock.onGet(skylinkUrl).reply(200, "thisistext", {}); | ||
await expect(client.db.getJSON(publicKey, dataKey)).rejects.toThrowError("File data for the entry at data key '".concat(dataKey, "' is not JSON.")); | ||
await expect(client.db.getJSON(publicKey, dataKey)).rejects.toThrowError(`File data for the entry at data key '${dataKey}' is not JSON.`); | ||
}); | ||
@@ -117,3 +117,3 @@ }); | ||
expect(returnedData).toEqual(jsonData); | ||
expect(returnedSkylink).toEqual("sia:".concat(skylink)); // assert our request history contains the expected amount of requests | ||
expect(returnedSkylink).toEqual(`sia:${skylink}`); // assert our request history contains the expected amount of requests | ||
@@ -120,0 +120,0 @@ expect(mock.history.get.length).toBe(1); |
@@ -44,3 +44,3 @@ "use strict"; | ||
if (!skylink.startsWith(_url.uriSkynetPrefix)) { | ||
skylink = "".concat(_url.uriSkynetPrefix).concat(skylink); | ||
skylink = `${_url.uriSkynetPrefix}${skylink}`; | ||
} | ||
@@ -47,0 +47,0 @@ |
@@ -15,3 +15,3 @@ "use strict"; | ||
it("should ensure the skylink starts with the prefix", () => { | ||
const prefixedSkylink = "sia:".concat(skylink); | ||
const prefixedSkylink = `sia:${skylink}`; | ||
expect((0, _format.formatSkylink)(skylink)).toEqual(prefixedSkylink); | ||
@@ -18,0 +18,0 @@ expect((0, _format.formatSkylink)(prefixedSkylink)).toEqual(prefixedSkylink); |
@@ -26,5 +26,5 @@ "use strict"; | ||
const SKYLINK_MATCHER_SUBDOMAIN = "([a-z0-9_-]{55})"; | ||
const SKYLINK_DIRECT_REGEX = new RegExp("^".concat(SKYLINK_MATCHER, "$")); | ||
const SKYLINK_PATHNAME_REGEX = new RegExp("^/?".concat(SKYLINK_MATCHER, "((/.*)?)$")); | ||
const SKYLINK_SUBDOMAIN_REGEX = new RegExp("^".concat(SKYLINK_MATCHER_SUBDOMAIN, "(\\..*)?$")); | ||
const SKYLINK_DIRECT_REGEX = new RegExp(`^${SKYLINK_MATCHER}$`); | ||
const SKYLINK_PATHNAME_REGEX = new RegExp(`^/?${SKYLINK_MATCHER}((/.*)?)$`); | ||
const SKYLINK_SUBDOMAIN_REGEX = new RegExp(`^${SKYLINK_MATCHER_SUBDOMAIN}(\\..*)?$`); | ||
const SKYLINK_DIRECT_MATCH_POSITION = 1; | ||
@@ -31,0 +31,0 @@ const SKYLINK_PATH_MATCH_POSITION = 2; |
@@ -10,3 +10,3 @@ "use strict"; | ||
describe("parseSkylink", () => { | ||
const basicCases = (0, _testing.combineStrings)(["", "sia:", "sia://", "https://siasky.net/", "https://foo.siasky.net/", "https://".concat(skylinkBase32, ".siasky.net/")], [skylink], ["", "/", "//", "/foo", "/foo/", "/foo/bar", "/foo/bar/"], ["", "?", "?foo=bar", "?foo=bar&bar=baz"], ["", "#", "#foo", "#foo?bar"]); | ||
const basicCases = (0, _testing.combineStrings)(["", "sia:", "sia://", "https://siasky.net/", "https://foo.siasky.net/", `https://${skylinkBase32}.siasky.net/`], [skylink], ["", "/", "//", "/foo", "/foo/", "/foo/bar", "/foo/bar/"], ["", "?", "?foo=bar", "?foo=bar&bar=baz"], ["", "#", "#foo", "#foo?bar"]); | ||
it.each(basicCases)("should extract skylink and path from %s", fullSkylink => { | ||
@@ -16,3 +16,3 @@ expect((0, _parse.parseSkylink)(fullSkylink)).toEqual(skylink); // Check that we extract the path correctly. | ||
const path = (0, _testing.extractNonSkylinkPath)(fullSkylink, skylink); | ||
const fullPath = "".concat(skylink).concat(path); | ||
const fullPath = `${skylink}${path}`; | ||
expect((0, _parse.parseSkylink)(fullSkylink, { | ||
@@ -25,3 +25,3 @@ includePath: true | ||
}); | ||
const subdomainCases = (0, _testing.combineStrings)(["https://"], [skylinkBase32], [".siasky.net", ".foo.siasky.net"], ["", "/", "//", "/foo", "/foo", "/foo/", "/foo/bar", "/foo/bar/", "/".concat(skylink)], ["", "?", "?foo=bar", "?foo=bar&bar=baz"], ["", "#", "#foo", "#foo?bar"]); | ||
const subdomainCases = (0, _testing.combineStrings)(["https://"], [skylinkBase32], [".siasky.net", ".foo.siasky.net"], ["", "/", "//", "/foo", "/foo", "/foo/", "/foo/bar", "/foo/bar/", `/${skylink}`], ["", "?", "?foo=bar", "?foo=bar&bar=baz"], ["", "#", "#foo", "#foo?bar"]); | ||
it.each(subdomainCases)("should extract base32 skylink from %s", fullSkylink => { | ||
@@ -46,3 +46,3 @@ expect((0, _parse.parseSkylink)(fullSkylink, { | ||
}); | ||
const invalidCases = ["123", "".concat(skylink, "xxx"), "".concat(skylink, "xxx/foo"), "".concat(skylink, "xxx?foo")]; | ||
const invalidCases = ["123", `${skylink}xxx`, `${skylink}xxx/foo`, `${skylink}xxx?foo`]; | ||
it.each(invalidCases)("should return null on invalid case %s", fullSkylink => { | ||
@@ -52,3 +52,3 @@ expect((0, _parse.parseSkylink)(fullSkylink)).toBeNull(); | ||
it("should return null on invalid base32 subdomain", () => { | ||
const badUrl = "https://".concat(skylinkBase32, "xxx.siasky.net"); | ||
const badUrl = `https://${skylinkBase32}xxx.siasky.net`; | ||
expect((0, _parse.parseSkylink)(badUrl, { | ||
@@ -55,0 +55,0 @@ fromSubdomain: true |
@@ -13,3 +13,3 @@ "use strict"; | ||
pass: false, | ||
message: () => "expected ".concat(received, " to equal ").concat(argument) | ||
message: () => `expected ${received} to equal ${argument}` | ||
}; | ||
@@ -22,3 +22,3 @@ } | ||
pass: false, | ||
message: () => "expected ".concat(received, " to equal ").concat(argument) | ||
message: () => `expected ${received} to equal ${argument}` | ||
}; | ||
@@ -30,3 +30,3 @@ } | ||
pass: true, | ||
message: () => "expected ".concat(received, " not to equal ").concat(argument) | ||
message: () => `expected ${received} not to equal ${argument}` | ||
}; | ||
@@ -33,0 +33,0 @@ } |
@@ -21,3 +21,3 @@ "use strict"; | ||
pass: false, | ||
message: () => "expected ".concat(received, " to equal ").concat(argument) | ||
message: () => `expected ${received} to equal ${argument}` | ||
}; | ||
@@ -30,3 +30,3 @@ } | ||
pass: false, | ||
message: () => "expected ".concat(received, " to equal ").concat(argument) | ||
message: () => `expected ${received} to equal ${argument}` | ||
}; | ||
@@ -38,3 +38,3 @@ } | ||
pass: true, | ||
message: () => "expected ".concat(received, " not to equal ").concat(argument) | ||
message: () => `expected ${received} not to equal ${argument}` | ||
}; | ||
@@ -65,3 +65,3 @@ } | ||
it.each(invalidHexStrings)("should throw on invalid input '%s'", str => { | ||
expect(() => (0, _string.hexToUint8Array)(str)).toThrowError("Expected parameter 'str' to be a hex-encoded string, was '".concat(str, "'")); | ||
expect(() => (0, _string.hexToUint8Array)(str)).toThrowError(`Expected parameter 'str' to be a hex-encoded string, was '${str}'`); | ||
}); | ||
@@ -71,4 +71,4 @@ }); | ||
it("should correctly parse hns prefixed link", () => { | ||
const validHnsLinkVariations = [hnsLink, "hns:".concat(hnsLink), "hns://".concat(hnsLink)]; | ||
const validHnsresLinkVariations = [hnsresLink, "hnsres:".concat(hnsresLink), "hnsres://".concat(hnsresLink)]; | ||
const validHnsLinkVariations = [hnsLink, `hns:${hnsLink}`, `hns://${hnsLink}`]; | ||
const validHnsresLinkVariations = [hnsresLink, `hnsres:${hnsresLink}`, `hnsres://${hnsresLink}`]; | ||
validHnsLinkVariations.forEach(input => { | ||
@@ -75,0 +75,0 @@ expect((0, _string.trimUriPrefix)(input, _url.uriHandshakePrefix)).toEqual(hnsLink); |
@@ -202,4 +202,4 @@ "use strict"; | ||
} catch (err) { | ||
throw new Error("Did not get a complete upload response despite a successful request. Please try again and report this issue to the devs if it persists. Error: ".concat(err)); | ||
throw new Error(`Did not get a complete upload response despite a successful request. Please try again and report this issue to the devs if it persists. Error: ${err}`); | ||
} | ||
} |
@@ -16,3 +16,3 @@ "use strict"; | ||
const skylink = "XABvi7JtJbQSMAcDwnUnmp2FKDPjg8_tTTFP4BwMSxVdEg"; | ||
const sialink = "".concat(_index.uriSkynetPrefix).concat(skylink); | ||
const sialink = `${_index.uriSkynetPrefix}${skylink}`; | ||
const merkleroot = "QAf9Q7dBSbMarLvyeE6HTQmwhr7RX9VMrP9xIMzpU3I"; | ||
@@ -27,3 +27,3 @@ const bitfield = 2048; | ||
describe("uploadFile", () => { | ||
const url = "".concat(portalUrl, "/skynet/skyfile"); | ||
const url = `${portalUrl}/skynet/skyfile`; | ||
const filename = "bar.txt"; | ||
@@ -56,3 +56,3 @@ const file = new File(["foo"], filename, { | ||
const newPortal = "https://my-portal.net"; | ||
const url = "".concat(newPortal, "/skynet/skyfile"); | ||
const url = `${newPortal}/skynet/skyfile`; | ||
const client = new _index.SkynetClient(newPortal); | ||
@@ -127,3 +127,3 @@ mock.onHead(newPortal).replyOnce(200, {}, { | ||
const portalUrl = "https://portal.net"; | ||
const url = "".concat(portalUrl, "/skynet/skyfile"); | ||
const url = `${portalUrl}/skynet/skyfile`; | ||
const client = new _index.SkynetClient(portalUrl, { | ||
@@ -135,3 +135,3 @@ customUserAgent: "Sia-Agent" | ||
}); | ||
mock.onPost("".concat(url, "?file=test")).replyOnce(200, data); | ||
mock.onPost(`${url}?file=test`).replyOnce(200, data); | ||
const query = { | ||
@@ -168,3 +168,3 @@ file: "test" | ||
}; | ||
const url = "".concat(portalUrl, "/skynet/skyfile?filename=").concat(filename); | ||
const url = `${portalUrl}/skynet/skyfile?filename=${filename}`; | ||
beforeEach(() => { | ||
@@ -196,3 +196,3 @@ mock = new _axiosMockAdapter.default(_axios.default); | ||
const filename = "encoding?test"; | ||
const url = "".concat(portalUrl, "/skynet/skyfile?filename=encoding%3Ftest"); | ||
const url = `${portalUrl}/skynet/skyfile?filename=encoding%3Ftest`; | ||
mock.resetHandlers(); | ||
@@ -199,0 +199,0 @@ mock.onPost(url).replyOnce(200, data); |
@@ -14,26 +14,26 @@ "use strict"; | ||
filename: "test" | ||
})).toEqual("".concat(portalUrl, "?filename=test")); | ||
expect((0, _url.addUrlQuery)("".concat(portalUrl, "/path/"), { | ||
})).toEqual(`${portalUrl}?filename=test`); | ||
expect((0, _url.addUrlQuery)(`${portalUrl}/path/`, { | ||
download: true | ||
})).toEqual("".concat(portalUrl, "/path/?download=true")); | ||
expect((0, _url.addUrlQuery)("".concat(portalUrl, "/skynet/"), { | ||
})).toEqual(`${portalUrl}/path/?download=true`); | ||
expect((0, _url.addUrlQuery)(`${portalUrl}/skynet/`, { | ||
foo: 1, | ||
bar: 2 | ||
})).toEqual("".concat(portalUrl, "/skynet/?foo=1&bar=2")); | ||
expect((0, _url.addUrlQuery)("".concat(portalUrl, "/"), { | ||
})).toEqual(`${portalUrl}/skynet/?foo=1&bar=2`); | ||
expect((0, _url.addUrlQuery)(`${portalUrl}/`, { | ||
attachment: true | ||
})).toEqual("".concat(portalUrl, "/?attachment=true")); | ||
expect((0, _url.addUrlQuery)("".concat(portalUrl, "?foo=bar"), { | ||
})).toEqual(`${portalUrl}/?attachment=true`); | ||
expect((0, _url.addUrlQuery)(`${portalUrl}?foo=bar`, { | ||
attachment: true | ||
})).toEqual("".concat(portalUrl, "?foo=bar&attachment=true")); | ||
expect((0, _url.addUrlQuery)("".concat(portalUrl, "/?attachment=true"), { | ||
})).toEqual(`${portalUrl}?foo=bar&attachment=true`); | ||
expect((0, _url.addUrlQuery)(`${portalUrl}/?attachment=true`, { | ||
foo: "bar" | ||
})).toEqual("".concat(portalUrl, "/?attachment=true&foo=bar")); | ||
expect((0, _url.addUrlQuery)("".concat(portalUrl, "#foobar"), { | ||
})).toEqual(`${portalUrl}/?attachment=true&foo=bar`); | ||
expect((0, _url.addUrlQuery)(`${portalUrl}#foobar`, { | ||
foo: "bar" | ||
})).toEqual("".concat(portalUrl, "?foo=bar#foobar")); | ||
})).toEqual(`${portalUrl}?foo=bar#foobar`); | ||
}); | ||
}); | ||
describe("getFullDomainUrlForPortal", () => { | ||
const domains = [["dac.hns", "https://dac.hns.siasky.net"], ["dac.hns/", "https://dac.hns.siasky.net"], [skylinkBase32, "https://".concat(skylinkBase32, ".siasky.net")]]; | ||
const domains = [["dac.hns", "https://dac.hns.siasky.net"], ["dac.hns/", "https://dac.hns.siasky.net"], [skylinkBase32, `https://${skylinkBase32}.siasky.net`]]; | ||
it.each(domains)("domain %s should return correctly formed full URL %s", (domain, fullUrl) => { | ||
@@ -45,3 +45,3 @@ const url = (0, _url.getFullDomainUrlForPortal)(portalUrl, domain); | ||
describe("extractDomainForPortal", () => { | ||
const domains = [["dac.hns.siasky.net", "dac.hns"], ["".concat(skylinkBase32, ".siasky.net"), skylinkBase32], ["localhost", "localhost"]]; | ||
const domains = [["dac.hns.siasky.net", "dac.hns"], [`${skylinkBase32}.siasky.net`, skylinkBase32], ["localhost", "localhost"]]; | ||
it.each(domains)("should extract domain %s out of full url %s", (fullDomain, domain) => { | ||
@@ -54,11 +54,11 @@ const receivedDomain = (0, _url.extractDomainForPortal)(portalUrl, fullDomain); | ||
it("should return correctly formed URLs", () => { | ||
expect((0, _url.makeUrl)(portalUrl, "/")).toEqual("".concat(portalUrl, "/")); | ||
expect((0, _url.makeUrl)(portalUrl, "/skynet")).toEqual("".concat(portalUrl, "/skynet")); | ||
expect((0, _url.makeUrl)(portalUrl, "/skynet/")).toEqual("".concat(portalUrl, "/skynet/")); | ||
expect((0, _url.makeUrl)(portalUrl, "/", skylink)).toEqual("".concat(portalUrl, "/").concat(skylink)); | ||
expect((0, _url.makeUrl)(portalUrl, "/skynet", skylink)).toEqual("".concat(portalUrl, "/skynet/").concat(skylink)); | ||
expect((0, _url.makeUrl)(portalUrl, "//skynet/", skylink)).toEqual("".concat(portalUrl, "/skynet/").concat(skylink)); | ||
expect((0, _url.makeUrl)(portalUrl, "/skynet/", "".concat(skylink, "?foo=bar"))).toEqual("".concat(portalUrl, "/skynet/").concat(skylink, "?foo=bar")); | ||
expect((0, _url.makeUrl)(portalUrl, "".concat(skylink, "/?foo=bar"))).toEqual("".concat(portalUrl, "/").concat(skylink, "?foo=bar")); | ||
expect((0, _url.makeUrl)(portalUrl, "".concat(skylink, "#foobar"))).toEqual("".concat(portalUrl, "/").concat(skylink, "#foobar")); | ||
expect((0, _url.makeUrl)(portalUrl, "/")).toEqual(`${portalUrl}/`); | ||
expect((0, _url.makeUrl)(portalUrl, "/skynet")).toEqual(`${portalUrl}/skynet`); | ||
expect((0, _url.makeUrl)(portalUrl, "/skynet/")).toEqual(`${portalUrl}/skynet/`); | ||
expect((0, _url.makeUrl)(portalUrl, "/", skylink)).toEqual(`${portalUrl}/${skylink}`); | ||
expect((0, _url.makeUrl)(portalUrl, "/skynet", skylink)).toEqual(`${portalUrl}/skynet/${skylink}`); | ||
expect((0, _url.makeUrl)(portalUrl, "//skynet/", skylink)).toEqual(`${portalUrl}/skynet/${skylink}`); | ||
expect((0, _url.makeUrl)(portalUrl, "/skynet/", `${skylink}?foo=bar`)).toEqual(`${portalUrl}/skynet/${skylink}?foo=bar`); | ||
expect((0, _url.makeUrl)(portalUrl, `${skylink}/?foo=bar`)).toEqual(`${portalUrl}/${skylink}?foo=bar`); | ||
expect((0, _url.makeUrl)(portalUrl, `${skylink}#foobar`)).toEqual(`${portalUrl}/${skylink}#foobar`); | ||
}); | ||
@@ -65,0 +65,0 @@ }); |
@@ -13,3 +13,3 @@ "use strict"; | ||
pass: false, | ||
message: () => "expected ".concat(received, " to equal ").concat(argument) | ||
message: () => `expected ${received} to equal ${argument}` | ||
}; | ||
@@ -22,3 +22,3 @@ } | ||
pass: false, | ||
message: () => "expected ".concat(received, " to equal ").concat(argument) | ||
message: () => `expected ${received} to equal ${argument}` | ||
}; | ||
@@ -30,3 +30,3 @@ } | ||
pass: true, | ||
message: () => "expected ".concat(received, " not to equal ").concat(argument) | ||
message: () => `expected ${received} not to equal ${argument}` | ||
}; | ||
@@ -33,0 +33,0 @@ } |
@@ -30,8 +30,8 @@ "use strict"; | ||
if (int < BigInt(0)) { | ||
throw new Error("Argument ".concat(int, " must be an unsigned 64-bit integer; was negative")); | ||
throw new Error(`Argument ${int} must be an unsigned 64-bit integer; was negative`); | ||
} | ||
if (int > MAX_REVISION) { | ||
throw new Error("Argument ".concat(int, " does not fit in a 64-bit unsigned integer; exceeds 2^64-1")); | ||
throw new Error(`Argument ${int} does not fit in a 64-bit unsigned integer; exceeds 2^64-1`); | ||
} | ||
} |
@@ -105,3 +105,3 @@ "use strict"; | ||
function trimUriPrefix(str, prefix) { | ||
const longPrefix = "".concat(prefix, "//"); | ||
const longPrefix = `${prefix}//`; | ||
@@ -108,0 +108,0 @@ if (str.startsWith(longPrefix)) { |
@@ -21,3 +21,3 @@ "use strict"; | ||
pass: false, | ||
message: () => "expected ".concat(received, " to equal ").concat(argument) | ||
message: () => `expected ${received} to equal ${argument}` | ||
}; | ||
@@ -30,3 +30,3 @@ } | ||
pass: false, | ||
message: () => "expected ".concat(received, " to equal ").concat(argument) | ||
message: () => `expected ${received} to equal ${argument}` | ||
}; | ||
@@ -38,3 +38,3 @@ } | ||
pass: true, | ||
message: () => "expected ".concat(received, " not to equal ").concat(argument) | ||
message: () => `expected ${received} not to equal ${argument}` | ||
}; | ||
@@ -65,3 +65,3 @@ } | ||
it.each(invalidHexStrings)("should throw on invalid input '%s'", str => { | ||
expect(() => (0, _string.hexToUint8Array)(str)).toThrowError("Expected parameter 'str' to be a hex-encoded string, was '".concat(str, "'")); | ||
expect(() => (0, _string.hexToUint8Array)(str)).toThrowError(`Expected parameter 'str' to be a hex-encoded string, was '${str}'`); | ||
}); | ||
@@ -71,4 +71,4 @@ }); | ||
it("should correctly parse hns prefixed link", () => { | ||
const validHnsLinkVariations = [hnsLink, "hns:".concat(hnsLink), "hns://".concat(hnsLink)]; | ||
const validHnsresLinkVariations = [hnsresLink, "hnsres:".concat(hnsresLink), "hnsres://".concat(hnsresLink)]; | ||
const validHnsLinkVariations = [hnsLink, `hns:${hnsLink}`, `hns://${hnsLink}`]; | ||
const validHnsresLinkVariations = [hnsresLink, `hnsres:${hnsresLink}`, `hnsres://${hnsresLink}`]; | ||
validHnsLinkVariations.forEach(input => { | ||
@@ -75,0 +75,0 @@ expect((0, _string.trimUriPrefix)(input, _url.uriHandshakePrefix)).toEqual(hnsLink); |
@@ -58,3 +58,3 @@ "use strict"; | ||
const urlObj = new URL(url); | ||
urlObj.hostname = "".concat(subdomain, ".").concat(urlObj.hostname); | ||
urlObj.hostname = `${subdomain}.${urlObj.hostname}`; | ||
const str = urlObj.toString(); | ||
@@ -61,0 +61,0 @@ return (0, _string.trimSuffix)(str, "/"); |
@@ -14,26 +14,26 @@ "use strict"; | ||
filename: "test" | ||
})).toEqual("".concat(portalUrl, "?filename=test")); | ||
expect((0, _url.addUrlQuery)("".concat(portalUrl, "/path/"), { | ||
})).toEqual(`${portalUrl}?filename=test`); | ||
expect((0, _url.addUrlQuery)(`${portalUrl}/path/`, { | ||
download: true | ||
})).toEqual("".concat(portalUrl, "/path/?download=true")); | ||
expect((0, _url.addUrlQuery)("".concat(portalUrl, "/skynet/"), { | ||
})).toEqual(`${portalUrl}/path/?download=true`); | ||
expect((0, _url.addUrlQuery)(`${portalUrl}/skynet/`, { | ||
foo: 1, | ||
bar: 2 | ||
})).toEqual("".concat(portalUrl, "/skynet/?foo=1&bar=2")); | ||
expect((0, _url.addUrlQuery)("".concat(portalUrl, "/"), { | ||
})).toEqual(`${portalUrl}/skynet/?foo=1&bar=2`); | ||
expect((0, _url.addUrlQuery)(`${portalUrl}/`, { | ||
attachment: true | ||
})).toEqual("".concat(portalUrl, "/?attachment=true")); | ||
expect((0, _url.addUrlQuery)("".concat(portalUrl, "?foo=bar"), { | ||
})).toEqual(`${portalUrl}/?attachment=true`); | ||
expect((0, _url.addUrlQuery)(`${portalUrl}?foo=bar`, { | ||
attachment: true | ||
})).toEqual("".concat(portalUrl, "?foo=bar&attachment=true")); | ||
expect((0, _url.addUrlQuery)("".concat(portalUrl, "/?attachment=true"), { | ||
})).toEqual(`${portalUrl}?foo=bar&attachment=true`); | ||
expect((0, _url.addUrlQuery)(`${portalUrl}/?attachment=true`, { | ||
foo: "bar" | ||
})).toEqual("".concat(portalUrl, "/?attachment=true&foo=bar")); | ||
expect((0, _url.addUrlQuery)("".concat(portalUrl, "#foobar"), { | ||
})).toEqual(`${portalUrl}/?attachment=true&foo=bar`); | ||
expect((0, _url.addUrlQuery)(`${portalUrl}#foobar`, { | ||
foo: "bar" | ||
})).toEqual("".concat(portalUrl, "?foo=bar#foobar")); | ||
})).toEqual(`${portalUrl}?foo=bar#foobar`); | ||
}); | ||
}); | ||
describe("getFullDomainUrlForPortal", () => { | ||
const domains = [["dac.hns", "https://dac.hns.siasky.net"], ["dac.hns/", "https://dac.hns.siasky.net"], [skylinkBase32, "https://".concat(skylinkBase32, ".siasky.net")]]; | ||
const domains = [["dac.hns", "https://dac.hns.siasky.net"], ["dac.hns/", "https://dac.hns.siasky.net"], [skylinkBase32, `https://${skylinkBase32}.siasky.net`]]; | ||
it.each(domains)("domain %s should return correctly formed full URL %s", (domain, fullUrl) => { | ||
@@ -45,3 +45,3 @@ const url = (0, _url.getFullDomainUrlForPortal)(portalUrl, domain); | ||
describe("extractDomainForPortal", () => { | ||
const domains = [["dac.hns.siasky.net", "dac.hns"], ["".concat(skylinkBase32, ".siasky.net"), skylinkBase32], ["localhost", "localhost"]]; | ||
const domains = [["dac.hns.siasky.net", "dac.hns"], [`${skylinkBase32}.siasky.net`, skylinkBase32], ["localhost", "localhost"]]; | ||
it.each(domains)("should extract domain %s out of full url %s", (fullDomain, domain) => { | ||
@@ -54,11 +54,11 @@ const receivedDomain = (0, _url.extractDomainForPortal)(portalUrl, fullDomain); | ||
it("should return correctly formed URLs", () => { | ||
expect((0, _url.makeUrl)(portalUrl, "/")).toEqual("".concat(portalUrl, "/")); | ||
expect((0, _url.makeUrl)(portalUrl, "/skynet")).toEqual("".concat(portalUrl, "/skynet")); | ||
expect((0, _url.makeUrl)(portalUrl, "/skynet/")).toEqual("".concat(portalUrl, "/skynet/")); | ||
expect((0, _url.makeUrl)(portalUrl, "/", skylink)).toEqual("".concat(portalUrl, "/").concat(skylink)); | ||
expect((0, _url.makeUrl)(portalUrl, "/skynet", skylink)).toEqual("".concat(portalUrl, "/skynet/").concat(skylink)); | ||
expect((0, _url.makeUrl)(portalUrl, "//skynet/", skylink)).toEqual("".concat(portalUrl, "/skynet/").concat(skylink)); | ||
expect((0, _url.makeUrl)(portalUrl, "/skynet/", "".concat(skylink, "?foo=bar"))).toEqual("".concat(portalUrl, "/skynet/").concat(skylink, "?foo=bar")); | ||
expect((0, _url.makeUrl)(portalUrl, "".concat(skylink, "/?foo=bar"))).toEqual("".concat(portalUrl, "/").concat(skylink, "?foo=bar")); | ||
expect((0, _url.makeUrl)(portalUrl, "".concat(skylink, "#foobar"))).toEqual("".concat(portalUrl, "/").concat(skylink, "#foobar")); | ||
expect((0, _url.makeUrl)(portalUrl, "/")).toEqual(`${portalUrl}/`); | ||
expect((0, _url.makeUrl)(portalUrl, "/skynet")).toEqual(`${portalUrl}/skynet`); | ||
expect((0, _url.makeUrl)(portalUrl, "/skynet/")).toEqual(`${portalUrl}/skynet/`); | ||
expect((0, _url.makeUrl)(portalUrl, "/", skylink)).toEqual(`${portalUrl}/${skylink}`); | ||
expect((0, _url.makeUrl)(portalUrl, "/skynet", skylink)).toEqual(`${portalUrl}/skynet/${skylink}`); | ||
expect((0, _url.makeUrl)(portalUrl, "//skynet/", skylink)).toEqual(`${portalUrl}/skynet/${skylink}`); | ||
expect((0, _url.makeUrl)(portalUrl, "/skynet/", `${skylink}?foo=bar`)).toEqual(`${portalUrl}/skynet/${skylink}?foo=bar`); | ||
expect((0, _url.makeUrl)(portalUrl, `${skylink}/?foo=bar`)).toEqual(`${portalUrl}/${skylink}?foo=bar`); | ||
expect((0, _url.makeUrl)(portalUrl, `${skylink}#foobar`)).toEqual(`${portalUrl}/${skylink}#foobar`); | ||
}); | ||
@@ -65,0 +65,0 @@ }); |
@@ -71,3 +71,3 @@ "use strict"; | ||
if (!(property in model)) { | ||
throw new Error("Object ".concat(valueKind, " '").concat(name, "' contains unexpected property '").concat(property, "'")); | ||
throw new Error(`Object ${valueKind} '${name}' contains unexpected property '${property}'`); | ||
} | ||
@@ -154,3 +154,3 @@ } | ||
if (actualLen !== len) { | ||
throwValidationError(name, value, valueKind, "'Uint8Array' of length ".concat(len, ", was length ").concat(actualLen)); | ||
throwValidationError(name, value, valueKind, `'Uint8Array' of length ${len}, was length ${actualLen}`); | ||
} | ||
@@ -170,3 +170,3 @@ } | ||
function throwValidationError(name, value, valueKind, expected) { | ||
throw new Error("Expected ".concat(valueKind, " '").concat(name, "' to be ").concat(expected, ", was '").concat(value, "'")); | ||
throw new Error(`Expected ${valueKind} '${name}' to be ${expected}, was '${value}'`); | ||
} |
{ | ||
"name": "skynet-js", | ||
"version": "4.0.3-beta", | ||
"version": "4.0.4-beta", | ||
"description": "Sia Skynet Javascript Client", | ||
@@ -79,3 +79,3 @@ "main": "dist/index.js", | ||
"sjcl": "^1.0.8", | ||
"skynet-mysky-utils": "^0.2.0", | ||
"skynet-mysky-utils": "^0.2.2", | ||
"tweetnacl": "^1.0.3", | ||
@@ -82,0 +82,0 @@ "url-join": "^4.0.1", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
289692
6075
Updatedskynet-mysky-utils@^0.2.2