Compare commits

..

No commits in common. "v0.2.0-develop.6" and "v0.2.0-develop.5" have entirely different histories.

5 changed files with 21 additions and 207 deletions

183
npm-shrinkwrap.json generated
View File

@ -1,19 +1,18 @@
{ {
"name": "@lumeweb/libportal", "name": "@lumeweb/libportal",
"version": "0.2.0-develop.6", "version": "0.2.0-develop.5",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@lumeweb/libportal", "name": "@lumeweb/libportal",
"version": "0.2.0-develop.6", "version": "0.2.0-develop.5",
"dependencies": { "dependencies": {
"@noble/curves": "^1.1.0", "@noble/curves": "^1.1.0",
"@noble/hashes": "^1.3.1", "@noble/hashes": "^1.3.1",
"cross-fetch": "^3.1.6", "cross-fetch": "^3.1.6",
"detect-node": "^2.1.0", "detect-node": "^2.1.0",
"multiformats": "^11.0.2", "multiformats": "^11.0.2",
"node-fetch": "^3.3.1",
"p-defer": "^4.0.0", "p-defer": "^4.0.0",
"stream-to-blob": "^2.0.1", "stream-to-blob": "^2.0.1",
"tus-js-client": "^3.1.0", "tus-js-client": "^3.1.0",
@ -1806,26 +1805,6 @@
"node": ">= 14" "node": ">= 14"
} }
}, },
"node_modules/@octokit/request/node_modules/node-fetch": {
"version": "2.6.11",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.11.tgz",
"integrity": "sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w==",
"dev": true,
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/@octokit/tsconfig": { "node_modules/@octokit/tsconfig": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/@octokit/tsconfig/-/tsconfig-2.0.0.tgz", "resolved": "https://registry.npmjs.org/@octokit/tsconfig/-/tsconfig-2.0.0.tgz",
@ -4815,25 +4794,6 @@
"node-fetch": "^2.6.11" "node-fetch": "^2.6.11"
} }
}, },
"node_modules/cross-fetch/node_modules/node-fetch": {
"version": "2.6.11",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.11.tgz",
"integrity": "sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w==",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/cross-spawn": { "node_modules/cross-spawn": {
"version": "7.0.3", "version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
@ -4902,14 +4862,6 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/data-uri-to-buffer": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==",
"engines": {
"node": ">= 12"
}
},
"node_modules/dateformat": { "node_modules/dateformat": {
"version": "3.0.3", "version": "3.0.3",
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz",
@ -6162,28 +6114,6 @@
"bser": "2.1.1" "bser": "2.1.1"
} }
}, },
"node_modules/fetch-blob": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "paypal",
"url": "https://paypal.me/jimmywarting"
}
],
"dependencies": {
"node-domexception": "^1.0.0",
"web-streams-polyfill": "^3.0.3"
},
"engines": {
"node": "^12.20 || >= 14.13"
}
},
"node_modules/figures": { "node_modules/figures": {
"version": "3.2.0", "version": "3.2.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz",
@ -6298,17 +6228,6 @@
"is-callable": "^1.1.3" "is-callable": "^1.1.3"
} }
}, },
"node_modules/formdata-polyfill": {
"version": "4.0.10",
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
"dependencies": {
"fetch-blob": "^3.1.2"
},
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/from2": { "node_modules/from2": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz",
@ -9601,24 +9520,6 @@
"dev": true, "dev": true,
"peer": true "peer": true
}, },
"node_modules/node-domexception": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "github",
"url": "https://paypal.me/jimmywarting"
}
],
"engines": {
"node": ">=10.5.0"
}
},
"node_modules/node-emoji": { "node_modules/node-emoji": {
"version": "1.11.0", "version": "1.11.0",
"resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.11.0.tgz", "resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.11.0.tgz",
@ -9629,20 +9530,22 @@
} }
}, },
"node_modules/node-fetch": { "node_modules/node-fetch": {
"version": "3.3.1", "version": "2.6.11",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.1.tgz", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.11.tgz",
"integrity": "sha512-cRVc/kyto/7E5shrWca1Wsea4y6tL9iYJE5FBCius3JQfb/4P4I295PfhgbJQBLTx6lATE4z+wK0rPM4VS2uow==", "integrity": "sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w==",
"dependencies": { "dependencies": {
"data-uri-to-buffer": "^4.0.0", "whatwg-url": "^5.0.0"
"fetch-blob": "^3.1.4",
"formdata-polyfill": "^4.0.10"
}, },
"engines": { "engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" "node": "4.x || >=6.0.0"
}, },
"funding": { "peerDependencies": {
"type": "opencollective", "encoding": "^0.1.0"
"url": "https://opencollective.com/node-fetch" },
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
} }
}, },
"node_modules/node-gyp": { "node_modules/node-gyp": {
@ -19209,17 +19112,6 @@
"is-plain-object": "^5.0.0", "is-plain-object": "^5.0.0",
"node-fetch": "^2.6.7", "node-fetch": "^2.6.7",
"universal-user-agent": "^6.0.0" "universal-user-agent": "^6.0.0"
},
"dependencies": {
"node-fetch": {
"version": "2.6.11",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.11.tgz",
"integrity": "sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w==",
"dev": true,
"requires": {
"whatwg-url": "^5.0.0"
}
}
} }
}, },
"@octokit/request-error": { "@octokit/request-error": {
@ -21469,16 +21361,6 @@
"integrity": "sha512-riRvo06crlE8HiqOwIpQhxwdOk4fOeR7FVM/wXoxchFEqMNUjvbs3bfo4OTgMEMHzppd4DxFBDbyySj8Cv781g==", "integrity": "sha512-riRvo06crlE8HiqOwIpQhxwdOk4fOeR7FVM/wXoxchFEqMNUjvbs3bfo4OTgMEMHzppd4DxFBDbyySj8Cv781g==",
"requires": { "requires": {
"node-fetch": "^2.6.11" "node-fetch": "^2.6.11"
},
"dependencies": {
"node-fetch": {
"version": "2.6.11",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.11.tgz",
"integrity": "sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w==",
"requires": {
"whatwg-url": "^5.0.0"
}
}
} }
}, },
"cross-spawn": { "cross-spawn": {
@ -21527,11 +21409,6 @@
"dev": true, "dev": true,
"peer": true "peer": true
}, },
"data-uri-to-buffer": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A=="
},
"dateformat": { "dateformat": {
"version": "3.0.3", "version": "3.0.3",
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz",
@ -22504,15 +22381,6 @@
"bser": "2.1.1" "bser": "2.1.1"
} }
}, },
"fetch-blob": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
"requires": {
"node-domexception": "^1.0.0",
"web-streams-polyfill": "^3.0.3"
}
},
"figures": { "figures": {
"version": "3.2.0", "version": "3.2.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz",
@ -22599,14 +22467,6 @@
"is-callable": "^1.1.3" "is-callable": "^1.1.3"
} }
}, },
"formdata-polyfill": {
"version": "4.0.10",
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
"requires": {
"fetch-blob": "^3.1.2"
}
},
"from2": { "from2": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz",
@ -25149,11 +25009,6 @@
"dev": true, "dev": true,
"peer": true "peer": true
}, },
"node-domexception": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="
},
"node-emoji": { "node-emoji": {
"version": "1.11.0", "version": "1.11.0",
"resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.11.0.tgz", "resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.11.0.tgz",
@ -25164,13 +25019,11 @@
} }
}, },
"node-fetch": { "node-fetch": {
"version": "3.3.1", "version": "2.6.11",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.1.tgz", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.11.tgz",
"integrity": "sha512-cRVc/kyto/7E5shrWca1Wsea4y6tL9iYJE5FBCius3JQfb/4P4I295PfhgbJQBLTx6lATE4z+wK0rPM4VS2uow==", "integrity": "sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w==",
"requires": { "requires": {
"data-uri-to-buffer": "^4.0.0", "whatwg-url": "^5.0.0"
"fetch-blob": "^3.1.4",
"formdata-polyfill": "^4.0.10"
} }
}, },
"node-gyp": { "node-gyp": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@lumeweb/libportal", "name": "@lumeweb/libportal",
"version": "0.2.0-develop.6", "version": "0.2.0-develop.5",
"main": "lib/index.js", "main": "lib/index.js",
"module": "lib/index.mjs", "module": "lib/index.mjs",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",
@ -39,7 +39,6 @@
"cross-fetch": "^3.1.6", "cross-fetch": "^3.1.6",
"detect-node": "^2.1.0", "detect-node": "^2.1.0",
"multiformats": "^11.0.2", "multiformats": "^11.0.2",
"node-fetch": "^3.3.1",
"p-defer": "^4.0.0", "p-defer": "^4.0.0",
"stream-to-blob": "^2.0.1", "stream-to-blob": "^2.0.1",
"tus-js-client": "^3.1.0", "tus-js-client": "^3.1.0",

View File

@ -212,17 +212,6 @@ export class Client {
if (!(fetchOptions.body instanceof _FormData)) { if (!(fetchOptions.body instanceof _FormData)) {
fetchOptions.headers["Content-Type"] = "application/json"; fetchOptions.headers["Content-Type"] = "application/json";
fetchOptions.body = JSON.stringify(fetchOptions.body); fetchOptions.body = JSON.stringify(fetchOptions.body);
} else {
if (isNode) {
const formDataToBlob = (
await import("formdata-polyfill/formdata-to-blob.js")
).formDataToBlob;
const Blob = (await import("node-fetch")).Blob;
const blob = formDataToBlob(fetchOptions.body, Blob);
// @ts-ignore
fetchOptions.body = Buffer.from(await blob.arrayBuffer());
fetchOptions.headers["Content-Type"] = blob.type;
}
} }
} }
@ -292,8 +281,6 @@ export class Client {
hashStream?: any, hashStream?: any,
size?: bigint, size?: bigint,
): Promise<string> { ): Promise<string> {
const Blob = await this.getBlobObject();
if (stream instanceof Uint8Array || stream instanceof Blob) { if (stream instanceof Uint8Array || stream instanceof Blob) {
size = BigInt(stream.length); size = BigInt(stream.length);
} }
@ -319,8 +306,6 @@ export class Client {
private async uploadFileSmall(stream: Uint8Array): Promise<string>; private async uploadFileSmall(stream: Uint8Array): Promise<string>;
private async uploadFileSmall(stream: NodeJS.ReadableStream): Promise<string>; private async uploadFileSmall(stream: NodeJS.ReadableStream): Promise<string>;
private async uploadFileSmall(stream: any): Promise<string> { private async uploadFileSmall(stream: any): Promise<string> {
const Blob = await this.getBlobObject();
if (stream instanceof ReadableStream) { if (stream instanceof ReadableStream) {
stream = await streamToBlob(stream); stream = await streamToBlob(stream);
} }
@ -529,13 +514,6 @@ export class Client {
return FormData; return FormData;
} }
private async getBlobObject() {
if (isNode) {
return (await import("node-fetch")).Blob;
}
return Blob;
}
private async getNodeReadableObject() { private async getNodeReadableObject() {
if (isNode) { if (isNode) {

View File

@ -1,6 +1,6 @@
// @ts-ignore // @ts-ignore
import baoWasm from "./wasm.js"; import baoWasm from "./wasm/bao.wasm";
import Go from "./go_wasm.js"; import Go from "#go_wasm.js";
export async function getVerifiableStream( export async function getVerifiableStream(
root: Uint8Array, root: Uint8Array,

View File

@ -1,16 +0,0 @@
import isNode from "detect-node";
export default async function (imports) {
if (isNode) {
const fs = await import("fs/promises");
// @ts-ignore
const wasmPath = new URL("wasm/bao.wasm", import.meta.url);
const wasm = await fs.readFile(wasmPath);
return WebAssembly.instantiate(wasm, imports);
}
// @ts-ignore
return await import("./wasm/bao.wasm");
}