commit
0060e06ee1
@ -1,3 +0,0 @@
|
||||
{
|
||||
"rust-analyzer.cargo.features": ["sqlite"]
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
export declare class Authenticator {
|
||||
init(): Promise<void>;
|
||||
register(challenge: string, application: string): Promise<string>;
|
||||
verifyRegistration(challenge: string, application: string, registerData: string, clientData: string): Promise<string>;
|
||||
sign(challenge: string, application: string, keyHandle: string): Promise<string>;
|
||||
verifySignature(challenge: string, application: string, signData: string, clientData: string, keyHandle: string, pubkey: string): Promise<number>;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
export declare function isEnabled(): Promise<boolean>;
|
||||
export declare function enable(): Promise<void>;
|
||||
export declare function disable(): Promise<void>;
|
@ -0,0 +1,87 @@
|
||||
export interface Permissions {
|
||||
/**
|
||||
* `true` if these permissions describe a readonly (unwritable) file.
|
||||
*/
|
||||
readonly: boolean;
|
||||
/**
|
||||
* The underlying raw `st_mode` bits that contain the standard Unix permissions for this file.
|
||||
*/
|
||||
mode: number | undefined;
|
||||
}
|
||||
/**
|
||||
* Metadata information about a file.
|
||||
* This structure is returned from the `metadata` function or method
|
||||
* and represents known metadata about a file such as its permissions, size, modification times, etc.
|
||||
*/
|
||||
export interface Metadata {
|
||||
/**
|
||||
* The last access time of this metadata.
|
||||
*/
|
||||
accessedAt: Date;
|
||||
/**
|
||||
* The creation time listed in this metadata.
|
||||
*/
|
||||
createdAt: Date;
|
||||
/**
|
||||
* The last modification time listed in this metadata.
|
||||
*/
|
||||
modifiedAt: Date;
|
||||
/**
|
||||
* `true` if this metadata is for a directory.
|
||||
*/
|
||||
isDir: boolean;
|
||||
/**
|
||||
* `true` if this metadata is for a regular file.
|
||||
*/
|
||||
isFile: boolean;
|
||||
/**
|
||||
* `true` if this metadata is for a symbolic link.
|
||||
*/
|
||||
isSymlink: boolean;
|
||||
/**
|
||||
* The size of the file, in bytes, this metadata is for.
|
||||
*/
|
||||
size: number;
|
||||
/**
|
||||
* The permissions of the file this metadata is for.
|
||||
*/
|
||||
permissions: Permissions;
|
||||
/**
|
||||
* The ID of the device containing the file. Only available on Unix.
|
||||
*/
|
||||
dev: number | undefined;
|
||||
/**
|
||||
* The inode number. Only available on Unix.
|
||||
*/
|
||||
ino: number | undefined;
|
||||
/**
|
||||
* The rights applied to this file. Only available on Unix.
|
||||
*/
|
||||
mode: number | undefined;
|
||||
/**
|
||||
* The number of hard links pointing to this file. Only available on Unix.
|
||||
*/
|
||||
nlink: number | undefined;
|
||||
/**
|
||||
* The user ID of the owner of this file. Only available on Unix.
|
||||
*/
|
||||
uid: number | undefined;
|
||||
/**
|
||||
* The group ID of the owner of this file. Only available on Unix.
|
||||
*/
|
||||
gid: number | undefined;
|
||||
/**
|
||||
* The device ID of this file (if it is a special one). Only available on Unix.
|
||||
*/
|
||||
rdev: number | undefined;
|
||||
/**
|
||||
* The block size for filesystem I/O. Only available on Unix.
|
||||
*/
|
||||
blksize: number | undefined;
|
||||
/**
|
||||
* The number of blocks allocated to the file, in 512-byte units. Only available on Unix.
|
||||
*/
|
||||
blocks: number | undefined;
|
||||
}
|
||||
export declare function metadata(path: string): Promise<Metadata>;
|
||||
export declare function exists(path: string): Promise<boolean>;
|
@ -0,0 +1,45 @@
|
||||
import { UnlistenFn } from "@tauri-apps/api/event";
|
||||
export interface WatchOptions {
|
||||
recursive?: boolean;
|
||||
}
|
||||
export interface DebouncedWatchOptions extends WatchOptions {
|
||||
delayMs?: number;
|
||||
}
|
||||
export interface RawEvent {
|
||||
path: string | null;
|
||||
operation: number;
|
||||
cookie: number | null;
|
||||
}
|
||||
export type DebouncedEvent = {
|
||||
type: "NoticeWrite";
|
||||
payload: string;
|
||||
} | {
|
||||
type: "NoticeRemove";
|
||||
payload: string;
|
||||
} | {
|
||||
type: "Create";
|
||||
payload: string;
|
||||
} | {
|
||||
type: "Write";
|
||||
payload: string;
|
||||
} | {
|
||||
type: "Chmod";
|
||||
payload: string;
|
||||
} | {
|
||||
type: "Remove";
|
||||
payload: string;
|
||||
} | {
|
||||
type: "Rename";
|
||||
payload: string;
|
||||
} | {
|
||||
type: "Rescan";
|
||||
payload: null;
|
||||
} | {
|
||||
type: "Error";
|
||||
payload: {
|
||||
error: string;
|
||||
path: string | null;
|
||||
};
|
||||
};
|
||||
export declare function watch(paths: string | string[], options: DebouncedWatchOptions, cb: (event: DebouncedEvent) => void): Promise<UnlistenFn>;
|
||||
export declare function watchImmediate(paths: string | string[], options: WatchOptions, cb: (event: RawEvent) => void): Promise<UnlistenFn>;
|
@ -0,0 +1,87 @@
|
||||
import { UnlistenFn } from "@tauri-apps/api/event";
|
||||
export type LogOptions = {
|
||||
file?: string;
|
||||
line?: number;
|
||||
} & Record<string, string | undefined>;
|
||||
/**
|
||||
* Logs a message at the error level.
|
||||
*
|
||||
* @param message
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* ```js
|
||||
* import { error } from 'tauri-plugin-log-api';
|
||||
*
|
||||
* const err_info = "No connection";
|
||||
* const port = 22;
|
||||
*
|
||||
* error(`Error: ${err_info} on port ${port}`);
|
||||
* ```
|
||||
*/
|
||||
export declare function error(message: string, options?: LogOptions): Promise<void>;
|
||||
/**
|
||||
* Logs a message at the warn level.
|
||||
*
|
||||
* @param message
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* ```js
|
||||
* import { warn } from 'tauri-plugin-log-api';
|
||||
*
|
||||
* const warn_description = "Invalid Input";
|
||||
*
|
||||
* warn(`Warning! {warn_description}!`);
|
||||
* ```
|
||||
*/
|
||||
export declare function warn(message: string, options?: LogOptions): Promise<void>;
|
||||
/**
|
||||
* Logs a message at the info level.
|
||||
*
|
||||
* @param message
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* ```js
|
||||
* import { info } from 'tauri-plugin-log-api';
|
||||
*
|
||||
* const conn_info = { port: 40, speed: 3.20 };
|
||||
*
|
||||
* info(`Connected to port {conn_info.port} at {conn_info.speed} Mb/s`);
|
||||
* ```
|
||||
*/
|
||||
export declare function info(message: string, options?: LogOptions): Promise<void>;
|
||||
/**
|
||||
* Logs a message at the debug level.
|
||||
*
|
||||
* @param message
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* ```js
|
||||
* import { debug } from 'tauri-plugin-log-api';
|
||||
*
|
||||
* const pos = { x: 3.234, y: -1.223 };
|
||||
*
|
||||
* debug(`New position: x: {pos.x}, y: {pos.y}`);
|
||||
* ```
|
||||
*/
|
||||
export declare function debug(message: string, options?: LogOptions): Promise<void>;
|
||||
/**
|
||||
* Logs a message at the trace level.
|
||||
*
|
||||
* @param message
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* ```js
|
||||
* import { trace } from 'tauri-plugin-log-api';
|
||||
*
|
||||
* let pos = { x: 3.234, y: -1.223 };
|
||||
*
|
||||
* trace(`Position is: x: {pos.x}, y: {pos.y}`);
|
||||
* ```
|
||||
*/
|
||||
export declare function trace(message: string, options?: LogOptions): Promise<void>;
|
||||
export declare function attachConsole(): Promise<UnlistenFn>;
|
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Well known window positions.
|
||||
*/
|
||||
export declare enum Position {
|
||||
TopLeft = 0,
|
||||
TopRight = 1,
|
||||
BottomLeft = 2,
|
||||
BottomRight = 3,
|
||||
TopCenter = 4,
|
||||
BottomCenter = 5,
|
||||
LeftCenter = 6,
|
||||
RightCenter = 7,
|
||||
Center = 8,
|
||||
TrayLeft = 9,
|
||||
TrayBottomLeft = 10,
|
||||
TrayRight = 11,
|
||||
TrayBottomRight = 12,
|
||||
TrayCenter = 13,
|
||||
TrayBottomCenter = 14
|
||||
}
|
||||
/**
|
||||
* Moves the `Window` to the given {@link Position} using `WindowExt.move_window()`
|
||||
* All positions are relative to the **current** screen.
|
||||
*
|
||||
* @param to The {@link Position} to move to.
|
||||
*/
|
||||
export declare function moveWindow(to: Position): Promise<void>;
|
@ -0,0 +1,95 @@
|
||||
export interface QueryResult {
|
||||
/** The number of rows affected by the query. */
|
||||
rowsAffected: number;
|
||||
/**
|
||||
* The last inserted `id`.
|
||||
*
|
||||
* This value is always `0` when using the Postgres driver. If the
|
||||
* last inserted id is required on Postgres, the `select` function
|
||||
* must be used, with a `RETURNING` clause
|
||||
* (`INSERT INTO todos (title) VALUES ($1) RETURNING id`).
|
||||
*/
|
||||
lastInsertId: number;
|
||||
}
|
||||
/**
|
||||
* **Database**
|
||||
*
|
||||
* The `Database` class serves as the primary interface for
|
||||
* communicating with the rust side of the sql plugin.
|
||||
*/
|
||||
export default class Database {
|
||||
path: string;
|
||||
constructor(path: string);
|
||||
/**
|
||||
* **load**
|
||||
*
|
||||
* A static initializer which connects to the underlying database and
|
||||
* returns a `Database` instance once a connection to the database is established.
|
||||
*
|
||||
* # Sqlite
|
||||
*
|
||||
* The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const db = await Database.load("sqlite:test.db");
|
||||
* ```
|
||||
*/
|
||||
static load(path: string): Promise<Database>;
|
||||
/**
|
||||
* **get**
|
||||
*
|
||||
* A static initializer which synchronously returns an instance of
|
||||
* the Database class while deferring the actual database connection
|
||||
* until the first invocation or selection on the database.
|
||||
*
|
||||
* # Sqlite
|
||||
*
|
||||
* The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const db = Database.get("sqlite:test.db");
|
||||
* ```
|
||||
*/
|
||||
static get(path: string): Database;
|
||||
/**
|
||||
* **execute**
|
||||
*
|
||||
* Passes a SQL expression to the database for execution.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const result = await db.execute(
|
||||
* "UPDATE todos SET title = $1, completed = $2 WHERE id = $3",
|
||||
* [ todos.title, todos.status, todos.id ]
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
execute(query: string, bindValues?: unknown[]): Promise<QueryResult>;
|
||||
/**
|
||||
* **select**
|
||||
*
|
||||
* Passes in a SELECT query to the database for execution.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const result = await db.select(
|
||||
* "SELECT * from todos WHERE id = $1", id
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
select<T>(query: string, bindValues?: unknown[]): Promise<T>;
|
||||
/**
|
||||
* **close**
|
||||
*
|
||||
* Closes the database connection pool.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const success = await db.close()
|
||||
* ```
|
||||
* @param db - Optionally state the name of a database if you are managing more than one. Otherwise, all database pools will be in scope.
|
||||
*/
|
||||
close(db?: string): Promise<boolean>;
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
import { UnlistenFn } from "@tauri-apps/api/event";
|
||||
/**
|
||||
* A key-value store persisted by the backend layer.
|
||||
*/
|
||||
export declare class Store {
|
||||
path: string;
|
||||
constructor(path: string);
|
||||
/**
|
||||
* Inserts a key-value pair into the store.
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @returns
|
||||
*/
|
||||
set(key: string, value: unknown): Promise<void>;
|
||||
/**
|
||||
* Returns the value for the given `key` or `null` the key does not exist.
|
||||
*
|
||||
* @param key
|
||||
* @returns
|
||||
*/
|
||||
get<T>(key: string): Promise<T | null>;
|
||||
/**
|
||||
* Returns `true` if the given `key` exists in the store.
|
||||
*
|
||||
* @param key
|
||||
* @returns
|
||||
*/
|
||||
has(key: string): Promise<boolean>;
|
||||
/**
|
||||
* Removes a key-value pair from the store.
|
||||
*
|
||||
* @param key
|
||||
* @returns
|
||||
*/
|
||||
delete(key: string): Promise<boolean>;
|
||||
/**
|
||||
* Clears the store, removing all key-value pairs.
|
||||
*
|
||||
* Note: To clear the storage and reset it to it's `default` value, use `reset` instead.
|
||||
* @returns
|
||||
*/
|
||||
clear(): Promise<void>;
|
||||
/**
|
||||
* Resets the store to it's `default` value.
|
||||
*
|
||||
* If no default value has been set, this method behaves identical to `clear`.
|
||||
* @returns
|
||||
*/
|
||||
reset(): Promise<void>;
|
||||
/**
|
||||
* Returns a list of all key in the store.
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
keys(): Promise<string[]>;
|
||||
/**
|
||||
* Returns a list of all values in the store.
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
values(): Promise<string[]>;
|
||||
/**
|
||||
* Returns a list of all entries in the store.
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
entries<T>(): Promise<Array<[key: string, value: T]>>;
|
||||
/**
|
||||
* Returns the number of key-value pairs in the store.
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
length(): Promise<string[]>;
|
||||
/**
|
||||
* Attempts to load the on-disk state at the stores `path` into memory.
|
||||
*
|
||||
* This method is useful if the on-disk state was edited by the user and you want to synchronize the changes.
|
||||
*
|
||||
* Note: This method does not emit change events.
|
||||
* @returns
|
||||
*/
|
||||
load(): Promise<void>;
|
||||
/**
|
||||
* Saves the store to disk at the stores `path`.
|
||||
*
|
||||
* As the store is only persistet to disk before the apps exit, changes might be lost in a crash.
|
||||
* This method let's you persist the store to disk whenever you deem necessary.
|
||||
* @returns
|
||||
*/
|
||||
save(): Promise<void>;
|
||||
/**
|
||||
* Listen to changes on a store key.
|
||||
* @param key
|
||||
* @param cb
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
*/
|
||||
onKeyChange<T>(key: string, cb: (value: T | null) => void): Promise<UnlistenFn>;
|
||||
/**
|
||||
* Listen to changes on the store.
|
||||
* @param cb
|
||||
* @returns A promise resolving to a function to unlisten to the event.
|
||||
*/
|
||||
onChange(cb: (key: string, value: unknown) => void): Promise<UnlistenFn>;
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
type BytesDto = string | number[];
|
||||
export type ClientPath = string | Iterable<number> | ArrayLike<number> | ArrayBuffer;
|
||||
export type VaultPath = string | Iterable<number> | ArrayLike<number> | ArrayBuffer;
|
||||
export type RecordPath = string | Iterable<number> | ArrayLike<number> | ArrayBuffer;
|
||||
export type StoreKey = string | Iterable<number> | ArrayLike<number> | ArrayBuffer;
|
||||
export interface ConnectionLimits {
|
||||
maxPendingIncoming?: number;
|
||||
maxPendingOutgoing?: number;
|
||||
maxEstablishedIncoming?: number;
|
||||
maxEstablishedOutgoing?: number;
|
||||
maxEstablishedPerPeer?: number;
|
||||
maxEstablishedTotal?: number;
|
||||
}
|
||||
export interface PeerAddress {
|
||||
known: string[];
|
||||
use_relay_fallback: boolean;
|
||||
}
|
||||
export interface AddressInfo {
|
||||
peers: Map<string, PeerAddress>;
|
||||
relays: string[];
|
||||
}
|
||||
export interface ClientAccess {
|
||||
useVaultDefault?: boolean;
|
||||
useVaultExceptions?: Map<VaultPath, boolean>;
|
||||
writeVaultDefault?: boolean;
|
||||
writeVaultExceptions?: Map<VaultPath, boolean>;
|
||||
cloneVaultDefault?: boolean;
|
||||
cloneVaultExceptions?: Map<VaultPath, boolean>;
|
||||
readStore?: boolean;
|
||||
writeStore?: boolean;
|
||||
}
|
||||
export interface Permissions {
|
||||
default?: ClientAccess;
|
||||
exceptions?: Map<VaultPath, ClientAccess>;
|
||||
}
|
||||
export interface NetworkConfig {
|
||||
requestTimeout?: Duration;
|
||||
connectionTimeout?: Duration;
|
||||
connectionsLimit?: ConnectionLimits;
|
||||
enableMdns?: boolean;
|
||||
enableRelay?: boolean;
|
||||
addresses?: AddressInfo;
|
||||
peerPermissions?: Map<string, Permissions>;
|
||||
permissionsDefault?: Permissions;
|
||||
}
|
||||
export interface Duration {
|
||||
millis: number;
|
||||
nanos: number;
|
||||
}
|
||||
export declare class Location {
|
||||
type: string;
|
||||
payload: Record<string, unknown>;
|
||||
constructor(type: string, payload: Record<string, unknown>);
|
||||
static generic(vault: VaultPath, record: RecordPath): Location;
|
||||
static counter(vault: VaultPath, counter: number): Location;
|
||||
}
|
||||
declare class ProcedureExecutor {
|
||||
procedureArgs: Record<string, unknown>;
|
||||
constructor(procedureArgs: Record<string, unknown>);
|
||||
generateSLIP10Seed(outputLocation: Location, sizeBytes?: number): Promise<Uint8Array>;
|
||||
deriveSLIP10(chain: number[], source: "Seed" | "Key", sourceLocation: Location, outputLocation: Location): Promise<Uint8Array>;
|
||||
recoverBIP39(mnemonic: string, outputLocation: Location, passphrase?: string): Promise<Uint8Array>;
|
||||
generateBIP39(outputLocation: Location, passphrase?: string): Promise<Uint8Array>;
|
||||
getEd25519PublicKey(privateKeyLocation: Location): Promise<Uint8Array>;
|
||||
signEd25519(privateKeyLocation: Location, msg: string): Promise<Uint8Array>;
|
||||
}
|
||||
export declare class Client {
|
||||
path: string;
|
||||
name: BytesDto;
|
||||
constructor(path: string, name: ClientPath);
|
||||
getVault(name: VaultPath): Vault;
|
||||
getStore(): Store;
|
||||
}
|
||||
export declare class Store {
|
||||
path: string;
|
||||
client: BytesDto;
|
||||
constructor(path: string, client: BytesDto);
|
||||
get(key: StoreKey): Promise<Uint8Array>;
|
||||
insert(key: StoreKey, value: number[], lifetime?: Duration): Promise<void>;
|
||||
remove(key: StoreKey): Promise<Uint8Array | null>;
|
||||
}
|
||||
export declare class Vault extends ProcedureExecutor {
|
||||
path: string;
|
||||
client: BytesDto;
|
||||
name: BytesDto;
|
||||
constructor(path: string, client: ClientPath, name: VaultPath);
|
||||
insert(recordPath: RecordPath, secret: number[]): Promise<void>;
|
||||
remove(location: Location): Promise<void>;
|
||||
}
|
||||
export declare class Stronghold {
|
||||
path: string;
|
||||
constructor(path: string, password: string);
|
||||
private reload;
|
||||
unload(): Promise<void>;
|
||||
loadClient(client: ClientPath): Promise<Client>;
|
||||
createClient(client: ClientPath): Promise<Client>;
|
||||
save(): Promise<void>;
|
||||
}
|
||||
export {};
|
@ -0,0 +1,3 @@
|
||||
type ProgressHandler = (progress: number, total: number) => void;
|
||||
export default function upload(url: string, filePath: string, progressHandler?: ProgressHandler, headers?: Map<string, string>): Promise<void>;
|
||||
export {};
|
@ -0,0 +1,18 @@
|
||||
export interface MessageKind<T, D> {
|
||||
type: T;
|
||||
data: D;
|
||||
}
|
||||
export interface CloseFrame {
|
||||
code: number;
|
||||
reason: string;
|
||||
}
|
||||
export type Message = MessageKind<"Text", string> | MessageKind<"Binary", number[]> | MessageKind<"Ping", number[]> | MessageKind<"Pong", number[]> | MessageKind<"Close", CloseFrame | null>;
|
||||
export default class WebSocket {
|
||||
id: number;
|
||||
private readonly listeners;
|
||||
constructor(id: number, listeners: Array<(arg: Message) => void>);
|
||||
static connect(url: string, options?: unknown): Promise<WebSocket>;
|
||||
addListener(cb: (arg: Message) => void): void;
|
||||
send(message: Message | string | number[]): Promise<void>;
|
||||
disconnect(): Promise<void>;
|
||||
}
|
Loading…
Reference in new issue