Compare commits

...

3 Commits

4 changed files with 22 additions and 27 deletions

View File

@ -1,3 +1,5 @@
# [0.2.0-develop.28](https://git.lumeweb.com/LumeWeb/libportal/compare/v0.2.0-develop.27...v0.2.0-develop.28) (2023-09-07)
# [0.2.0-develop.27](https://git.lumeweb.com/LumeWeb/libportal/compare/v0.2.0-develop.26...v0.2.0-develop.27) (2023-09-07) # [0.2.0-develop.27](https://git.lumeweb.com/LumeWeb/libportal/compare/v0.2.0-develop.26...v0.2.0-develop.27) (2023-09-07)
# [0.2.0-develop.26](https://git.lumeweb.com/LumeWeb/libportal/compare/v0.2.0-develop.25...v0.2.0-develop.26) (2023-09-07) # [0.2.0-develop.26](https://git.lumeweb.com/LumeWeb/libportal/compare/v0.2.0-develop.25...v0.2.0-develop.26) (2023-09-07)

4
npm-shrinkwrap.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@lumeweb/libportal", "name": "@lumeweb/libportal",
"version": "0.2.0-develop.27", "version": "0.2.0-develop.28",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@lumeweb/libportal", "name": "@lumeweb/libportal",
"version": "0.2.0-develop.27", "version": "0.2.0-develop.28",
"dependencies": { "dependencies": {
"@lumeweb/libs5": "^0.1.0-develop.50", "@lumeweb/libs5": "^0.1.0-develop.50",
"@noble/curves": "^1.1.0", "@noble/curves": "^1.1.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "@lumeweb/libportal", "name": "@lumeweb/libportal",
"version": "0.2.0-develop.27", "version": "0.2.0-develop.28",
"main": "lib/index.js", "main": "lib/index.js",
"type": "module", "type": "module",
"repository": { "repository": {

View File

@ -288,23 +288,19 @@ export class Client {
); );
} }
async uploadFile(stream: Blob, size?: bigint): Promise<string>; async uploadFile(stream: Blob, size?: bigint): Promise<CID>;
async uploadFile( async uploadFile(
stream: ReadableStream, stream: ReadableStream,
hashStream: ReadableStream, hashStream: ReadableStream,
size: bigint, size: bigint,
): Promise<string>; ): Promise<CID>;
async uploadFile(stream: Uint8Array, size?: bigint): Promise<string>; async uploadFile(stream: Uint8Array, size?: bigint): Promise<CID>;
async uploadFile( async uploadFile(
stream: NodeJS.ReadableStream, stream: NodeJS.ReadableStream,
hashStream: NodeJS.ReadableStream, hashStream: NodeJS.ReadableStream,
size?: bigint, size?: bigint,
): Promise<string>; ): Promise<CID>;
async uploadFile( async uploadFile(stream: any, hashStream?: any, size?: bigint): Promise<CID> {
stream: any,
hashStream?: any,
size?: bigint,
): Promise<string> {
const Blob = await this.getBlobObject(); const Blob = await this.getBlobObject();
if (stream instanceof Uint8Array || stream instanceof Blob) { if (stream instanceof Uint8Array || stream instanceof Blob) {
@ -324,14 +320,14 @@ export class Client {
return this.uploadFileTus(stream, hashStream, size); return this.uploadFileTus(stream, hashStream, size);
} }
private async uploadFileSmall(stream: Blob): Promise<string>; private async uploadFileSmall(stream: Blob): Promise<CID>;
private async uploadFileSmall( private async uploadFileSmall(
stream: ReadableStream, stream: ReadableStream,
hashStream: ReadableStream, hashStream: ReadableStream,
): Promise<string>; ): Promise<CID>;
private async uploadFileSmall(stream: Uint8Array): Promise<string>; private async uploadFileSmall(stream: Uint8Array): Promise<CID>;
private async uploadFileSmall(stream: NodeJS.ReadableStream): Promise<string>; private async uploadFileSmall(stream: NodeJS.ReadableStream): Promise<CID>;
private async uploadFileSmall(stream: any): Promise<string> { private async uploadFileSmall(stream: any): Promise<CID> {
const Blob = await this.getBlobObject(); const Blob = await this.getBlobObject();
if (stream instanceof ReadableStream) { if (stream instanceof ReadableStream) {
@ -373,29 +369,26 @@ export class Client {
{ auth: true }, { auth: true },
); );
return response.cid; return CID.decode(response.cid);
} }
private async uploadFileTus(stream: Blob, size?: bigint): Promise<string>; private async uploadFileTus(stream: Blob, size?: bigint): Promise<CID>;
private async uploadFileTus( private async uploadFileTus(
stream: ReadableStream, stream: ReadableStream,
hashStream: ReadableStream, hashStream: ReadableStream,
size?: bigint, size?: bigint,
): Promise<string>; ): Promise<CID>;
private async uploadFileTus( private async uploadFileTus(stream: Uint8Array, size?: bigint): Promise<CID>;
stream: Uint8Array,
size?: bigint,
): Promise<string>;
private async uploadFileTus( private async uploadFileTus(
stream: NodeJS.ReadableStream, stream: NodeJS.ReadableStream,
hashStream: ReadableStream, hashStream: ReadableStream,
size?: bigint, size?: bigint,
): Promise<string>; ): Promise<CID>;
private async uploadFileTus( private async uploadFileTus(
stream: any, stream: any,
hashStream?: any, hashStream?: any,
size?: bigint, size?: bigint,
): Promise<string> { ): Promise<CID> {
if (["bigint", "number"].includes(typeof hashStream)) { if (["bigint", "number"].includes(typeof hashStream)) {
size = BigInt(hashStream); size = BigInt(hashStream);
hashStream = undefined; hashStream = undefined;
@ -483,7 +476,7 @@ export class Client {
}); });
} }
return cid.toString(); return cid;
} }
async getUploadStatus(cid: string) { async getUploadStatus(cid: string) {