import URI from "urijs"; export { deriveKey, ready } from "./Crypto"; export * from "./Exceptions"; import { base64 } from "./Helpers"; import { CollectionAccessLevel, EncryptedCollection, EncryptedCollectionItem, SignedInvitationRead, SignedInvitationWrite, ChunkJson } from "./EncryptedModels"; export interface User { username: string; email: string; } export interface LoginResponseUser extends User { pubkey: Uint8Array; encryptedContent: Uint8Array; } export interface UserProfile { pubkey: Uint8Array; } export declare type LoginChallange = { challenge: Uint8Array; salt: Uint8Array; version: number; }; export declare type LoginChallangeResponse = { challenge: Uint8Array; host: string; }; export declare type LoginResponse = { token: string; user: LoginResponseUser; }; export interface ListResponse { data: T[]; done: boolean; } export interface CollectionItemListResponse extends ListResponse { stoken: string; } export interface CollectionListResponse extends CollectionItemListResponse { removedMemberships?: RemovedCollection[]; } export interface IteratorListResponse extends ListResponse { iterator: string; } export declare type CollectionMemberListResponse = IteratorListResponse; export declare type CollectionInvitationListResponse = IteratorListResponse; export interface RemovedCollection { uid: base64; } export interface CollectionMember { username: string; accessLevel: CollectionAccessLevel; } export interface AcceptedInvitation { encryptionKey: Uint8Array; } export declare enum PrefetchOption { Auto = "auto", Medium = "medium" } export interface ListFetchOptions { limit?: number; } export interface FetchOptions extends ListFetchOptions { stoken?: string | null; prefetch?: PrefetchOption; } export interface ItemFetchOptions extends FetchOptions { withCollection?: boolean; } export interface IteratorFetchOptions extends ListFetchOptions { iterator?: string | null; } export declare type MemberFetchOptions = IteratorFetchOptions; export declare type InvitationFetchOptions = IteratorFetchOptions; export interface RevisionsFetchOptions extends IteratorFetchOptions { prefetch?: PrefetchOption; } export interface WebSocketTicketRequest { collection: string; } export interface WebSocketTicketResponse { ticket: string; } interface AccountOnlineData { serverUrl: string; authToken: string | null; } declare class BaseNetwork { apiBase: URI; constructor(apiBase: string); newCall(segments?: string[], extra?: RequestInit, apiBaseIn?: URI): Promise; } export declare class Authenticator extends BaseNetwork { constructor(apiBase: string); isEtebase(): Promise; signup(user: User, salt: Uint8Array, loginPubkey: Uint8Array, pubkey: Uint8Array, encryptedContent: Uint8Array): Promise; getLoginChallenge(username: string): Promise; login(response: Uint8Array, signature: Uint8Array): Promise; logout(authToken: string): Promise; changePassword(authToken: string, response: Uint8Array, signature: Uint8Array): Promise; getDashboardUrl(authToken: string): Promise; } declare class BaseManager extends BaseNetwork { protected etebase: AccountOnlineData; constructor(etebase: AccountOnlineData, segments: string[]); newCall(segments?: string[], extra?: RequestInit, apiBase?: URI): Promise; protected urlFromFetchOptions(options?: ItemFetchOptions & IteratorFetchOptions): URI; } export declare class CollectionManagerOnline extends BaseManager { constructor(etebase: AccountOnlineData); fetch(colUid: string, options?: FetchOptions): Promise; list(collectionTypes: Uint8Array[], options?: FetchOptions): Promise>; create(collection: EncryptedCollection, options?: FetchOptions): Promise<{}>; } export declare class CollectionItemManagerOnline extends BaseManager { constructor(etebase: AccountOnlineData, colUid: string); fetch(itemUid: string, options?: ItemFetchOptions): Promise; list(options?: ItemFetchOptions): Promise>; itemRevisions(item: EncryptedCollectionItem, options?: RevisionsFetchOptions): Promise>; create(item: EncryptedCollectionItem): Promise<{}>; fetchUpdates(items: EncryptedCollectionItem[], options?: ItemFetchOptions): Promise>; fetchMulti(items: base64[], options?: ItemFetchOptions): Promise>; batch(items: EncryptedCollectionItem[], deps?: EncryptedCollectionItem[], options?: ItemFetchOptions): Promise<{}>; transaction(items: EncryptedCollectionItem[], deps?: EncryptedCollectionItem[], options?: ItemFetchOptions): Promise<{}>; chunkUpload(item: EncryptedCollectionItem, chunk: ChunkJson, options?: ItemFetchOptions): Promise<{}>; chunkDownload(item: EncryptedCollectionItem, chunkUid: base64, options?: ItemFetchOptions): Promise; subscribeChanges(cb: (data: CollectionItemListResponse) => void, options_?: ItemFetchOptions): Promise; } export declare class CollectionInvitationManagerOnline extends BaseManager { constructor(etebase: AccountOnlineData); listIncoming(options?: InvitationFetchOptions): Promise>; listOutgoing(options?: InvitationFetchOptions): Promise>; accept(invitation: SignedInvitationRead, collectionType: Uint8Array, encryptionKey: Uint8Array): Promise<{}>; reject(invitation: SignedInvitationRead): Promise<{}>; fetchUserProfile(username: string): Promise; invite(invitation: SignedInvitationWrite): Promise<{}>; disinvite(invitation: SignedInvitationRead): Promise<{}>; } export declare class CollectionMemberManagerOnline extends BaseManager { constructor(etebase: AccountOnlineData, colUid: string); list(options?: MemberFetchOptions): Promise>; remove(username: string): Promise<{}>; leave(): Promise<{}>; modifyAccessLevel(username: string, accessLevel: CollectionAccessLevel): Promise<{}>; } export declare type WebSocketCbType = (message: Uint8Array) => void; export declare class WebSocketHandle { private rws; connected: boolean; constructor(urlProvider: () => Promise, cb: WebSocketCbType); unsubscribe(): Promise; } interface WebSocketUrlOptions { ticket: string; fetchOptions?: FetchOptions; } export declare class WebSocketManagerOnline extends BaseManager { private readonly getUrlOptions; constructor(etebase: AccountOnlineData, getUrlOptions: () => Promise); subscribe(cb: WebSocketCbType): Promise; }