Compare commits

..

No commits in common. "v0.2.0-develop.16" and "v0.2.0-develop.15" have entirely different histories.

6 changed files with 1154 additions and 165 deletions

View File

@ -1,10 +1,3 @@
# [0.2.0-develop.16](https://git.lumeweb.com/LumeWeb/libweb/compare/v0.2.0-develop.15...v0.2.0-develop.16) (2023-06-26)
### Features
* add initial upload method ([7126203](https://git.lumeweb.com/LumeWeb/libweb/commit/7126203cd3c97485de422e8759442a04074a8f64))
# [0.2.0-develop.15](https://git.lumeweb.com/LumeWeb/libweb/compare/v0.2.0-develop.14...v0.2.0-develop.15) (2023-06-25)
# [0.2.0-develop.14](https://git.lumeweb.com/LumeWeb/libweb/compare/v0.2.0-develop.13...v0.2.0-develop.14) (2023-06-24)

1263
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@lumeweb/libweb",
"version": "0.2.0-develop.16",
"version": "0.2.0-develop.15",
"main": "lib/index.js",
"type": "module",
"repository": {
@ -22,8 +22,8 @@
},
"dependencies": {
"@lumeweb/community-portals": "^0.1.0-develop.2",
"@lumeweb/libportal": "^0.2.0-develop.10",
"@lumeweb/node-library-preset": "git+https://git.lumeweb.com/LumeWeb/node-library-preset.git",
"@lumeweb/libportal": "0.2.0-develop.8",
"@lumeweb/node-library-preset": "https://git.lumeweb.com/LumeWeb/node-library-preset/archive/v0.1.1-develop.11.tar.gz",
"@noble/curves": "^1.1.0",
"@noble/hashes": "^1.3.1"
},

View File

@ -1,5 +1,4 @@
import { objAsString } from "./objAsString.js";
import { ErrTuple } from "#types.js";
// addContextToErr is a helper function that standardizes the formatting of
// adding context to an error.
@ -15,5 +14,3 @@ function addContextToErr(err: any, context: string): string {
}
export { addContextToErr };
export const NO_PORTALS_ERROR = [null, "no active portals"] as ErrTuple;

View File

@ -11,6 +11,5 @@ export * from "./cid.js";
export * from "./encoding.js";
export * from "./keys.js";
export * from "./download.js";
export * from "./upload.js";
export * from "./portal.js";
export { ed25519, sha512 };

View File

@ -1,39 +0,0 @@
import { ErrTuple } from "#types.js";
import { getActivePortals } from "#portal.js";
import { NO_PORTALS_ERROR } from "#err.js";
export async function uploadObject(
file:
| ReadableStream<Uint8Array>
| import("stream").Readable
| Uint8Array
| Blob,
size?: bigint,
): Promise<ErrTuple> {
const activePortals = getActivePortals();
if (!activePortals.length) {
return NO_PORTALS_ERROR;
}
for (const portal of activePortals) {
if (!(await portal.isLoggedIn())) {
try {
await portal.register();
} catch {}
await portal.login();
}
let upload;
try {
upload = await portal.uploadFile(file as any, size);
} catch {
continue;
}
return [upload, null];
}
return NO_PORTALS_ERROR;
}