Skip to content

Commit

Permalink
fix: default export, npm package, include dist
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwynr committed Feb 1, 2024
1 parent 73a0fc9 commit 7f27a26
Show file tree
Hide file tree
Showing 49 changed files with 710 additions and 57 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
dist/**/*
node_modules/**/*
src/test/**/*
5 changes: 1 addition & 4 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
dist/**/*
node_modules/**/*
src/test/**/*
docs/**/*
__tests__/**/*
src/test/**/*
3 changes: 3 additions & 0 deletions dist/bundle.browser.js

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions dist/bundle.browser.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/

/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */

/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */

/** @preserve
* Counter block mode compatible with Dr Brian Gladman fileenc.c
* derived from CryptoJS.mode.CTR
* Jan Hruby [email protected]
*/

/** @preserve
(c) 2012 by Cédric Mesnil. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
1 change: 1 addition & 0 deletions dist/bundle.browser.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dist/bundle.node.js

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions dist/bundle.node.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*!
* mime-db
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2015-2022 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* mime-types
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/

/** @preserve
* Counter block mode compatible with Dr Brian Gladman fileenc.c
* derived from CryptoJS.mode.CTR
* Jan Hruby [email protected]
*/

/** @preserve
(c) 2012 by Cédric Mesnil. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
1 change: 1 addition & 0 deletions dist/bundle.node.js.map

Large diffs are not rendered by default.

85 changes: 85 additions & 0 deletions dist/types/api/client.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
export type APIClientConfig = {
apiKey: string;
};
export type BaseRequestParameters = {
endpoint: string;
url?: string;
signal?: AbortSignal;
timeout?: number;
maxRetries?: number;
retryTimeout?: number;
};
export type GetRequestParameters = BaseRequestParameters & {
method: "GET";
};
export type PostRequestParameters = BaseRequestParameters & {
method: "POST";
data: Record<string, unknown>;
};
export type RequestParameters = GetRequestParameters | PostRequestParameters;
export declare const APIClientDefaults: {
readonly url: "https://gateway.filen.io";
readonly timeout: 300000;
readonly maxRetries: 3;
readonly retryTimeout: 1000;
};
/**
* APIClient
* @date 2/1/2024 - 2:45:15 AM
*
* @export
* @class APIClient
* @typedef {APIClient}
*/
export declare class APIClient {
private readonly config;
/**
* Creates an instance of APIClient.
* @date 1/31/2024 - 4:09:17 PM
*
* @constructor
* @public
* @param {APIClientConfig} params
*/
constructor(params: APIClientConfig);
/**
* Build API request headers
* @date 1/31/2024 - 4:09:33 PM
*
* @private
* @returns {Record<string, string>}
*/
private buildHeaders;
/**
* Send a POST request.
* @date 2/1/2024 - 2:48:57 AM
*
* @private
* @async
* @param {PostRequestParameters} params
* @returns {unknown}
*/
private post;
/**
* Send a GET request.
* @date 2/1/2024 - 2:49:04 AM
*
* @private
* @async
* @param {GetRequestParameters} params
* @returns {unknown}
*/
private get;
/**
* Sends the request to the API.
* @date 2/1/2024 - 2:49:20 AM
*
* @public
* @async
* @template T
* @param {RequestParameters} params
* @returns {Promise<T>}
*/
request<T>(params: RequestParameters): Promise<T>;
}
export default APIClient;
38 changes: 38 additions & 0 deletions dist/types/api/dir/content.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type APIClient from "../client";
import type { FileEncryptionVersion } from "../../types";
export type DirContentUpload = {
uuid: string;
metadata: string;
rm: string;
timestamp: number;
chunks: number;
size: number;
bucket: string;
region: string;
parent: string;
version: FileEncryptionVersion;
favorited: 0 | 1;
};
export type DirContentFolder = {
uuid: string;
name: string;
parent: string;
color: string | null;
timestamp: number;
favorited: 0 | 1;
is_sync: 0 | 1;
is_default: 0 | 1;
};
export type DirContentResponse = {
uploads: DirContentUpload[];
folders: DirContentFolder[];
};
export default class DirContent {
private readonly apiClient;
constructor({ apiClient }: {
apiClient: APIClient;
});
get({ uuid }: {
uuid: string;
}): Promise<DirContentResponse>;
}
8 changes: 8 additions & 0 deletions dist/types/api/health/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type APIClient from "../client";
export default class Health {
private readonly apiClient;
constructor({ apiClient }: {
apiClient: APIClient;
});
get(): Promise<string>;
}
17 changes: 17 additions & 0 deletions dist/types/api/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import V3Health from "./v3/health";
import V3DirContent from "./v3/dir/content";
export type APIConfig = {
apiKey: string;
};
export declare class API {
private readonly config;
private apiClient;
constructor(params: APIConfig);
v3(): {
health: () => V3Health;
dir: () => {
content: () => V3DirContent;
};
};
}
export default API;
57 changes: 57 additions & 0 deletions dist/types/api/v3/dir/content.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import type APIClient from "../../client";
import type { FileEncryptionVersion } from "../../../types";
export type DirContentUpload = {
uuid: string;
metadata: string;
rm: string;
timestamp: number;
chunks: number;
size: number;
bucket: string;
region: string;
parent: string;
version: FileEncryptionVersion;
favorited: 0 | 1;
};
export type DirContentFolder = {
uuid: string;
name: string;
parent: string;
color: string | null;
timestamp: number;
favorited: 0 | 1;
is_sync: 0 | 1;
is_default: 0 | 1;
};
export type DirContentResponse = {
uploads: DirContentUpload[];
folders: DirContentFolder[];
};
/**
* DirContent
* @date 2/1/2024 - 3:22:32 AM
*
* @export
* @class DirContent
* @typedef {DirContent}
*/
export declare class DirContent {
private readonly apiClient;
constructor({ apiClient }: {
apiClient: APIClient;
});
/**
* Returns all files and folders inside a folder.
* @date 2/1/2024 - 3:22:42 AM
*
* @public
* @async
* @param {{ uuid: string }} param0
* @param {string} param0.uuid
* @returns {Promise<DirContentResponse>}
*/
fetch({ uuid }: {
uuid: string;
}): Promise<DirContentResponse>;
}
export default DirContent;
25 changes: 25 additions & 0 deletions dist/types/api/v3/health/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type APIClient from "../../client";
/**
* Health
* @date 2/1/2024 - 3:23:04 AM
*
* @export
* @class Health
* @typedef {Health}
*/
export declare class Health {
private readonly apiClient;
constructor({ apiClient }: {
apiClient: APIClient;
});
/**
* Returns "OK" when API is healthy.
* @date 2/1/2024 - 3:23:14 AM
*
* @public
* @async
* @returns {Promise<"OK">}
*/
fetch(): Promise<"OK">;
}
export default Health;
1 change: 1 addition & 0 deletions dist/types/constants.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const environment: "node" | "react-native" | "browser";
66 changes: 66 additions & 0 deletions dist/types/crypto/decrypt.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import type { CryptoConfig } from ".";
import type { FileMetadata, FolderMetadata } from "../types";
/**
* Decrypt
* @date 1/31/2024 - 6:36:57 PM
*
* @export
* @class Decrypt
* @typedef {Decrypt}
*/
export declare class Decrypt {
private readonly config;
private readonly textEncoder;
private readonly textDecoder;
/**
* Creates an instance of Decrypt.
* @date 1/31/2024 - 3:59:10 PM
*
* @constructor
* @public
* @param {CryptoConfig} params
*/
constructor(params: CryptoConfig);
/**
* Decrypt a string with the given key.
* @date 1/31/2024 - 3:58:27 PM
*
* @public
* @async
* @param {{ data: string; key: string }} param0
* @param {string} param0.data
* @param {string} param0.key
* @returns {Promise<string>}
*/
metadata({ metadata, key }: {
metadata: string;
key: string;
}): Promise<string>;
/**
* Decrypt file metadata.
* @date 1/31/2024 - 4:20:32 PM
*
* @public
* @async
* @param {{ metadata: string }} param0
* @param {string} param0.metadata
* @returns {Promise<FileMetadata>}
*/
fileMetadata({ metadata }: {
metadata: string;
}): Promise<FileMetadata>;
/**
* Decrypt folder metadata.
* @date 1/31/2024 - 4:26:11 PM
*
* @public
* @async
* @param {{ metadata: string }} param0
* @param {string} param0.metadata
* @returns {Promise<FolderMetadata>}
*/
folderMetadata({ metadata }: {
metadata: string;
}): Promise<FolderMetadata>;
}
export default Decrypt;
Loading

0 comments on commit 7f27a26

Please sign in to comment.