Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into preferred-portal-refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
ro-tex committed Feb 7, 2022
2 parents 73a9983 + bdb884c commit 29ec63f
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 60 deletions.
15 changes: 13 additions & 2 deletions integration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@
import { DEFAULT_SKYNET_PORTAL_URL, SkynetClient } from "../src";
import { trimPrefix } from "../src/utils/string";

// To test a specific server, e.g. SKYNET_JS_INTEGRATION_TEST_SERVER=https://eu-fin-1.siasky.net yarn run jest src/integration.test.ts
// To test a specific server.
//
// Example:
//
// SKYNET_JS_INTEGRATION_TEST_SERVER=https://eu-fin-1.siasky.net yarn run jest integration
export const portal = process.env.SKYNET_JS_INTEGRATION_TEST_SERVER || DEFAULT_SKYNET_PORTAL_URL;
export const client = new SkynetClient(portal);
// Allow setting custom cookies for e.g. authentication for running tests on paid portals.
//
// Example:
//
// SKYNET_JS_INTEGRATION_TEST_CUSTOM_COOKIE=skynet-jwt=foo yarn run jest integration
export const customCookie = process.env.SKYNET_JS_INTEGRATION_TEST_CUSTOM_COOKIE;

export const client = new SkynetClient(portal, { customCookie });

export const dataKey = "HelloWorld";

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"homepage": "https://github.com/SkynetLabs/skynet-js",
"dependencies": {
"async-mutex": "^0.3.2",
"axios": "^0.24.0",
"axios": "^0.25.0",
"base32-decode": "^1.0.0",
"base32-encode": "^1.1.1",
"base64-js": "^1.3.1",
Expand Down
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import { buildRequestHeaders, buildRequestUrl, ExecuteRequestError, Headers } fr
*
* @property [APIKey] - Authentication password to use.
* @property [customUserAgent] - Custom user agent header to set.
* @property [customCookie] - Custom cookie header to set.
* @property [customCookie] - Custom cookie header to set. WARNING: the Cookie header cannot be set in browsers. This is meant for usage in server contexts.
* @property [onDownloadProgress] - Optional callback to track download progress.
* @property [onUploadProgress] - Optional callback to track upload progress.
* @property [loginFn] - A function that, if set, is called when a 401 is returned from the request before re-trying the request.
Expand Down
6 changes: 4 additions & 2 deletions src/mysky/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@ export class MySky {

/**
* Lets you get the share-able path seed, which can be passed to
* file.getJSONEncrypted. Requires Hidden Read permission on the path.
* `file.getJSONEncrypted` (in file.ts). Requires Hidden Read permission on
* the path.
*
* @param path - The given path.
* @param isDirectory - Whether the path is a directory.
Expand All @@ -675,7 +676,8 @@ export class MySky {

/**
* Lets you get the share-able path seed, which can be passed to
* file.getJSONEncrypted. Requires Hidden Read permission on the path.
* `file.getJSONEncrypted` (in file.ts). Requires Hidden Read permission on
* the path.
*
* @param path - The given path.
* @param isDirectory - Whether the path is a directory.
Expand Down
9 changes: 9 additions & 0 deletions src/upload.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,15 @@ describe("splitSizeIntoChunkAlignedParts", () => {
{ start: 40 * mib, end: 40 * mib },
],
],
[
40 * mib,
3,
[
{ start: 0, end: 40 * mib },
{ start: 40 * mib, end: 40 * mib },
{ start: 40 * mib, end: 40 * mib },
],
],
[
41 * mib,
2,
Expand Down
1 change: 0 additions & 1 deletion src/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ export async function uploadLargeFileRequest(
const resp = await this.executeRequest({
...opts,
url: upload.url,
endpointPath: opts.endpointLargeUpload,
method: "head",
headers: { ...headers, "tus-resumable": "1.0.0" },
});
Expand Down
4 changes: 2 additions & 2 deletions src/utils/encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function encodeSkylinkBase64(bytes: Uint8Array): string {
}

/**
* Converts the given number into a uint8 array
* Converts the given number into a uint8 array. Uses little-endian encoding.
*
* @param num - Number to encode.
* @returns - Number encoded as a byte array.
Expand All @@ -79,7 +79,7 @@ export function encodeNumber(num: number): Uint8Array {
}

/**
* Encodes the given bigint into a uint8 array.
* Encodes the given bigint into a uint8 array. Uses little-endian encoding.
*
* @param int - Bigint to encode.
* @returns - Bigint encoded as a byte array.
Expand Down
96 changes: 45 additions & 51 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,14 @@
dependencies:
"@cspotcode/source-map-consumer" "0.8.0"

"@es-joy/jsdoccomment@0.13.0":
version "0.13.0"
resolved "https://registry.yarnpkg.com/@es-joy/jsdoccomment/-/jsdoccomment-0.13.0.tgz#90ffe2006981ff66d3f4fd2f05949487f0fca089"
integrity sha512-APVqbVPGOprb4BmjEnwbSzV+V2e/6DVIUnZG3zdW5uWXWkN0DKMCpiIy2TdBauoANKYO7RQpO8cTjIYNVSKwUA==
"@es-joy/jsdoccomment@~0.18.0":
version "0.18.0"
resolved "https://registry.yarnpkg.com/@es-joy/jsdoccomment/-/jsdoccomment-0.18.0.tgz#2532b2ecb8576d694011b157c447ed6b12534c70"
integrity sha512-TjT8KJULV4I6ZiwIoKr6eMs+XpRejqwJ/VA+QPDeFGe9j6bZFKmMJ81EeFsGm6JNZhnzm37aoxVROmTh2PZoyA==
dependencies:
comment-parser "1.3.0"
esquery "^1.4.0"
jsdoc-type-pratt-parser "2.0.0"
jsdoc-type-pratt-parser "~2.2.2"

"@eslint/eslintrc@^0.4.3":
version "0.4.3"
Expand Down Expand Up @@ -684,9 +684,9 @@
"@types/istanbul-lib-report" "*"

"@types/jest@^27.0.1":
version "27.0.3"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-27.0.3.tgz#0cf9dfe9009e467f70a342f0f94ead19842a783a"
integrity sha512-cmmwv9t7gBYt7hNKH5Spu7Kuu/DotGa+Ff+JGRKZ4db5eh8PnKS4LuebJ3YLUoyOyIHraTGyULn23YtEAm0VSg==
version "27.4.0"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-27.4.0.tgz#037ab8b872067cae842a320841693080f9cb84ed"
integrity sha512-gHl8XuC1RZ8H2j5sHv/JqsaxXkDDM9iDOgu0Wp8sjs4u/snb2PVehyWXJPr+ORA0RPpgw231mnutWI1+0hgjIQ==
dependencies:
jest-diff "^27.0.0"
pretty-format "^27.0.0"
Expand Down Expand Up @@ -1060,12 +1060,12 @@ axios-mock-adapter@^1.18.2:
is-blob "^2.1.0"
is-buffer "^2.0.5"

axios@^0.24.0:
version "0.24.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.24.0.tgz#804e6fa1e4b9c5288501dd9dff56a7a0940d20d6"
integrity sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==
axios@^0.25.0:
version "0.25.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.25.0.tgz#349cfbb31331a9b4453190791760a8d35b093e0a"
integrity sha512-cD8FOb0tRH3uuEe6+evtAbgJtfxr7ly3fQjYcMcuPlgkwVS9xboaVIpcDV+cYQe+yGykgwZCs1pzjntcGa6l5g==
dependencies:
follow-redirects "^1.14.4"
follow-redirects "^1.14.7"

babel-jest@^26.6.3:
version "26.6.3"
Expand Down Expand Up @@ -1736,16 +1736,15 @@ escodegen@^1.14.1:
source-map "~0.6.1"

eslint-plugin-jsdoc@^37.0.3:
version "37.4.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-37.4.0.tgz#6e6eade5494150a392365f63bbd2fb88caeb8d0c"
integrity sha512-XWKMMHFq7eUdC8XMzuQSskevJvlHTDSAJm/2qtEZ7+qhZTZ0YjeqWaUn7KGdrmxLNqtWwtJ67LdIPgrYUZ5EoA==
version "37.7.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-37.7.0.tgz#975d9f18cb0520dde7a2b0db5f4421dfee3fdd17"
integrity sha512-vzy3/ltXoGtabRnjLogaEmhGxxIv5B8HK5MJLIrdxFJUvhBppZjuVuLr71DjIBi0jg6bFomwkYKjojt29cN8PA==
dependencies:
"@es-joy/jsdoccomment" "0.13.0"
"@es-joy/jsdoccomment" "~0.18.0"
comment-parser "1.3.0"
debug "^4.3.3"
escape-string-regexp "^4.0.0"
esquery "^1.4.0"
jsdoc-type-pratt-parser "^2.0.0"
regextras "^0.8.0"
semver "^7.3.5"
spdx-expression-parse "^3.0.1"
Expand Down Expand Up @@ -2079,10 +2078,10 @@ flatted@^3.1.0:
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.1.1.tgz#c4b489e80096d9df1dfc97c79871aea7c617c469"
integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==

follow-redirects@^1.14.4:
version "1.14.5"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.5.tgz#f09a5848981d3c772b5392309778523f8d85c381"
integrity sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA==
follow-redirects@^1.14.7:
version "1.14.7"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.7.tgz#2004c02eb9436eee9a21446a6477debf17e81685"
integrity sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==

for-in@^1.0.2:
version "1.0.2"
Expand Down Expand Up @@ -3051,10 +3050,10 @@ jsbn@~0.1.0:
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM=

jsdoc-type-pratt-parser@2.0.0, jsdoc-type-pratt-parser@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-2.0.0.tgz#ec739a0868922515fcb179852e990e89b52b9044"
integrity sha512-sUuj2j48wxrEpbFjDp1sAesAxPiLT+z0SWVmMafyIINs6Lj5gIPKh3VrkBZu4E/Dv+wHpOot0m6H8zlHQjwqeQ==
jsdoc-type-pratt-parser@~2.2.2:
version "2.2.2"
resolved "https://registry.yarnpkg.com/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-2.2.2.tgz#a85e407ac502b444dc23333aa4d6d0dc83f76187"
integrity sha512-zRokSWcPLSWkoNzsWn9pq7YYSwDhKyEe+cJYT2qaPqLOOJb5sFSi46BPj81vP+e8chvCNdQL9RG86Bi9EI6MDw==

jsdom@^16.4.0:
version "16.4.0"
Expand Down Expand Up @@ -3201,35 +3200,35 @@ lines-and-columns@^1.1.6:
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=

lint-staged@^12.0.2:
version "12.1.3"
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-12.1.3.tgz#a16e885c0a5e77de9cf559724d29a10348670e68"
integrity sha512-ajapdkaFxx+MVhvq6xQRg9zCnCLz49iQLJZP7+w8XaA3U4B35Z9xJJGq9vxmWo73QTvJLG+N2NxhjWiSexbAWQ==
version "12.3.2"
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-12.3.2.tgz#c87fe59dca475b7d1cb56863c5faa03c145e1446"
integrity sha512-gtw4Cbj01SuVSfAOXC6ivd/7VKHTj51yj5xV8TgktFmYNMsZzXuSd5/brqJEA93v63wL7R6iDlunMANOechC0A==
dependencies:
cli-truncate "^3.1.0"
colorette "^2.0.16"
commander "^8.3.0"
debug "^4.3.3"
execa "^5.1.1"
lilconfig "2.0.4"
listr2 "^3.13.5"
listr2 "^4.0.1"
micromatch "^4.0.4"
normalize-path "^3.0.0"
object-inspect "^1.11.1"
object-inspect "^1.12.0"
string-argv "^0.3.1"
supports-color "^9.2.1"
yaml "^1.10.2"

listr2@^3.13.5:
version "3.13.5"
resolved "https://registry.yarnpkg.com/listr2/-/listr2-3.13.5.tgz#105a813f2eb2329c4aae27373a281d610ee4985f"
integrity sha512-3n8heFQDSk+NcwBn3CgxEibZGaRzx+pC64n3YjpMD1qguV4nWus3Al+Oo3KooqFKTQEJ1v7MmnbnyyNspgx3NA==
listr2@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/listr2/-/listr2-4.0.1.tgz#e050c1fd390276e191f582603d6e3531cd6fd2b3"
integrity sha512-D65Nl+zyYHL2jQBGmxtH/pU8koPZo5C8iCNE8EoB04RwPgQG1wuaKwVbeZv9LJpiH4Nxs0FCp+nNcG8OqpniiA==
dependencies:
cli-truncate "^2.1.0"
colorette "^2.0.16"
log-update "^4.0.0"
p-map "^4.0.0"
rfdc "^1.3.0"
rxjs "^7.4.0"
rxjs "^7.5.2"
through "^2.3.8"
wrap-ansi "^7.0.0"

Expand Down Expand Up @@ -3566,7 +3565,7 @@ object-copy@^0.1.0:
define-property "^0.2.5"
kind-of "^3.0.3"

object-inspect@^1.11.1:
object-inspect@^1.12.0:
version "1.12.0"
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.0.tgz#6e2c120e868fd1fd18cb4f18c31741d0d6e776f0"
integrity sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g==
Expand Down Expand Up @@ -4052,12 +4051,12 @@ run-parallel@^1.1.9:
dependencies:
queue-microtask "^1.2.2"

rxjs@^7.4.0:
version "7.4.0"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.4.0.tgz#a12a44d7eebf016f5ff2441b87f28c9a51cebc68"
integrity sha512-7SQDi7xeTMCJpqViXh8gL/lebcwlp3d831F05+9B44A4B0WfsEwUQHR64gsH1kvJ+Ep/J9K2+n1hVl1CsGN23w==
rxjs@^7.5.2:
version "7.5.2"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.5.2.tgz#11e4a3a1dfad85dbf7fb6e33cbba17668497490b"
integrity sha512-PwDt186XaL3QN5qXj/H9DGyHhP3/RYYgZZwqBv9Tv8rsAaiwFH1IsJJlcgD37J7UW5a6O67qX0KWKS3/pu0m4w==
dependencies:
tslib "~2.1.0"
tslib "^2.1.0"

safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.2:
version "5.2.1"
Expand Down Expand Up @@ -4610,16 +4609,11 @@ tslib@^1.8.1:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==

tslib@^2.3.1:
tslib@^2.1.0, tslib@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01"
integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==

tslib@~2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.1.0.tgz#da60860f1c2ecaa5703ab7d39bc05b6bf988b97a"
integrity sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==

tsutils@^3.21.0:
version "3.21.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"
Expand Down Expand Up @@ -4691,9 +4685,9 @@ typedarray-to-buffer@^3.1.5:
is-typedarray "^1.0.0"

typescript@^4.2.4:
version "4.5.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.4.tgz#a17d3a0263bf5c8723b9c52f43c5084edf13c2e8"
integrity sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==
version "4.5.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3"
integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==

union-value@^1.0.0:
version "1.0.1"
Expand Down

0 comments on commit 29ec63f

Please sign in to comment.