This repository has been archived on 2019-08-30. You can view files and clone it, but cannot push or open issues or pull requests.
SecureFileWrapper/index.d.ts
2018-03-10 18:33:47 +01:00

49 lines
1.4 KiB
TypeScript

/// <reference types="node" />
import "isomorphic-fetch";
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();
makeRequest(endpoint: string, method: "POST" | "GET" | "PUT" | "DELETE", query: any, body?: Buffer): Promise<Response>;
test(): Promise<{
user: string;
test: true;
}>;
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 NoConnection extends Error {
type: string;
constructor();
}
export declare class Unauthorized extends Error {
type: string;
constructor();
}
export declare class NotFound extends Error {
type: string;
constructor();
}
export declare class BadRequest extends Error {
type: string;
constructor();
}