forked from hibas123/SecureFileWrapper
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
/// <reference types="node" />
|
|
export interface File {
|
|
_id: string;
|
|
type: "binary" | "text";
|
|
name: string;
|
|
time: string;
|
|
preview: string;
|
|
version: string;
|
|
}
|
|
export interface History {
|
|
file: File;
|
|
history: File[];
|
|
}
|
|
export default class SecureFile {
|
|
private Server;
|
|
private Username;
|
|
private PrivateKey;
|
|
constructor(server: string, username: string, private_key: string);
|
|
private getCode();
|
|
private makeRequest(endpoint, method, query, body);
|
|
list(folder?: string): Promise<File[]>;
|
|
create(name: string, data: Buffer, type: "text" | "binary", folder?: string, encrypt?: boolean, preview?: Buffer): Promise<File>;
|
|
get(id: string, version?: string): Promise<Buffer>;
|
|
update(id: string, data: Buffer, preview?: Buffer): Promise<File>;
|
|
delete(id: string): Promise<boolean>;
|
|
history(id: string): Promise<History>;
|
|
}
|
|
export declare class Unauthorized extends Error {
|
|
constructor();
|
|
}
|
|
export declare class NotFound extends Error {
|
|
constructor();
|
|
}
|
|
export declare class BadRequest extends Error {
|
|
constructor();
|
|
}
|