UNPKG

micro-stacks

Version:

Tiny libraries for building Stacks apps.

92 lines (81 loc) 3.46 kB
import { Json, EncryptionOptions } from 'micro-stacks/crypto'; import { GaiaHubConfig as GaiaHubConfig$1 } from 'micro-stacks/storage'; interface GaiaHubConfig { address: string; url_prefix: string; token: string; max_file_upload_size_megabytes: number; server: string; } interface UploadResponse { publicURL: string; etag?: string; } interface HubInfo { challenge_text: string; latest_auth_version: string; max_file_upload_size_megabytes: number | null; read_url_prefix: string; } declare type ScopeTypes = 'putFile' | 'putFilePrefix' | 'deleteFile' | 'deleteFilePrefix' | 'putFileArchival' | 'putFileArchivalPrefix'; interface GaiaAuthScope { scope: ScopeTypes; path: string; } interface ScopedGaiaTokenOptions { hubInfo: HubInfo; privateKey: string; gaiaHubUrl: string; associationToken?: string; scopes?: GaiaAuthScope[]; } interface GenerateGaiaHubConfigOptions { gaiaHubUrl: string; privateKey: string; associationToken?: string; scopes?: GaiaAuthScope[]; } declare function makeScopedGaiaAuthTokenPayload(options: ScopedGaiaTokenOptions): Json; declare function makeScopedGaiaAuthToken(options: ScopedGaiaTokenOptions): Promise<string>; declare function makeScopedGaiaAuthTokenSync(options: ScopedGaiaTokenOptions): string; declare function generateGaiaHubConfig(options: GenerateGaiaHubConfigOptions, fetchHubInfo?: boolean): Promise<GaiaHubConfig>; declare function generateGaiaHubConfigSync(options: GenerateGaiaHubConfigOptions): GaiaHubConfig; interface UploadToGaiaHub { filename: string; contents: Blob | Uint8Array | ArrayBufferView | string; hubConfig: GaiaHubConfig; contentType?: string; } declare function uploadToGaiaHub(options: UploadToGaiaHub): Promise<any>; declare function getFullReadUrl(filename: string, hubConfig: GaiaHubConfig): Promise<string>; interface PutFileOptions extends EncryptionOptions { contentType?: string; encrypt?: boolean | string; gaiaHubConfig: GaiaHubConfig; privateKey?: string; } interface GetFileUrlOptions { username?: string; app?: string; zoneFileLookupURL?: string; } interface GetFileOptions extends GetFileUrlOptions { decrypt?: boolean | string; verify?: boolean; gaiaHubConfig: GaiaHubConfig; privateKey?: string; } interface ProfileLookupOptions { username: string; verify?: boolean; zoneFileLookupURL?: string; } declare function putFile(path: string, content: string | Uint8Array | ArrayBufferView | Blob, options: PutFileOptions): Promise<string>; declare function getFile(path: string, getFileOptions: GetFileOptions): Promise<string | Uint8Array | null>; declare function deleteFile(path: string, options: { wasSigned?: boolean; gaiaHubConfig: GaiaHubConfig$1; }): Promise<void>; declare function deleteFromGaiaHub(path: string, gaiaHubConfig: GaiaHubConfig$1): Promise<void>; declare function lookupProfile(options: ProfileLookupOptions): Promise<Record<string, any> | null>; export { GaiaAuthScope, GaiaHubConfig, GenerateGaiaHubConfigOptions, GetFileOptions, GetFileUrlOptions, HubInfo, ProfileLookupOptions, PutFileOptions, ScopeTypes, ScopedGaiaTokenOptions, UploadResponse, deleteFile, deleteFromGaiaHub, generateGaiaHubConfig, generateGaiaHubConfigSync, getFile, getFullReadUrl, lookupProfile, makeScopedGaiaAuthToken, makeScopedGaiaAuthTokenPayload, makeScopedGaiaAuthTokenSync, putFile, uploadToGaiaHub };