= T & {
readonly [brand]: K;
};
declare const brand: unique symbol;
/**
* Generic callback
*/
type Callback = [], R = any, E extends Error = Error> = {
(e: E, ...params: Partial
): R;
(e?: null | undefined, ...params: P): R;
};
/**
* Non-empty array
*/
type NonEmptyArray = [T, ...T[]];
/**
* Allows extension of constructors that use POJOs
*/
type AbstractConstructorParameters = ConstructorParameters<(new (...args: any) => any) & T>;
type Initial = T extends [...infer Head, any] ? Head : any[];
type InitialParameters any> = Initial>;
/**
* Any type that can be turned into a string
*/
interface ToString {
toString(): string;
}
/**
* Recursive readonly
*/
type DeepReadonly = {
readonly [K in keyof T]: DeepReadonly;
};
/**
* Recursive partial
*/
type DeepPartial = T extends object ? {
[P in keyof T]?: DeepPartial;
} : T;
/**
* Wrap a type to be reference counted
* Useful for when we need to garbage collect data
*/
type Ref = {
count: number;
object: T;
};
/**
* Use Timer to control timers
*/
type Timer = {
timer: ReturnType;
timedOut: boolean;
timerP: Promise;
};
/**
* Deconstructed promise
*/
type PromiseDeconstructed = {
p: Promise;
resolveP: (value: T | PromiseLike) => void;
rejectP: (reason?: any) => void;
};
/**
* Minimal filesystem type
* Based on the required operations from fs/promises
* Implement this with platform-specific filesystem
*/
interface FileSystem {
promises: {
access: typeof fs.promises.access;
rm: typeof fs.promises.rm;
rmdir: typeof fs.promises.rmdir;
stat: typeof fs.promises.stat;
readFile: typeof fs.promises.readFile;
writeFile: typeof fs.promises.writeFile;
copyFile: typeof fs.promises.copyFile;
mkdir: typeof fs.promises.mkdir;
readdir: typeof fs.promises.readdir;
rename: typeof fs.promises.rename;
open: typeof fs.promises.open;
mkdtemp: typeof fs.promises.mkdtemp;
};
constants: typeof fs.constants;
}
type FileHandle = fs.promises.FileHandle;
type FunctionPropertyNames = {
[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
}[keyof T];
/**
* Functional properties of an object
*/
type FunctionProperties = Pick>;
type NonFunctionPropertyNames = {
[K in keyof T]: T[K] extends (...args: any[]) => any ? never : K;
}[keyof T];
/**
* Non-functional properties of an object
*/
type NonFunctionProperties = Pick>;
/**
* Finds the key type corresponding to a value type for a record type
*/
type RecordKeyFromValue = {
[K in keyof T]: V extends T[K] ? K : never;
}[keyof T];
/**
* Inverses a record type, "flipping a record"
*/
type InverseRecord> = {
[K in M[keyof M]]: RecordKeyFromValue;
};
/**
* Used when an empty object is needed.
* Defined here with a linter override to avoid a false positive.
*/
type ObjectEmpty = {};
/**
* Optional configuration for `PolykeyAgent`.
*/
type PolykeyAgentOptions = {
nodePath: string;
clientServiceHost: string;
clientServicePort: number;
agentServiceHost: string;
agentServicePort: number;
network: string;
seedNodes: SeedNodes;
workers: number;
ipv6Only: boolean;
keys: {
passwordOpsLimit: PasswordOpsLimit;
passwordMemLimit: PasswordMemLimit;
strictMemoryLock: boolean;
certDuration: number;
certRenewLeadTime: number;
recoveryCode: string;
} & (ObjectEmpty | {
recoveryCode: string;
} | {
privateKey: Buffer;
} | {
privateKeyPath: string;
});
client: {
keepAliveTimeoutTime: number;
keepAliveIntervalTime: number;
rpcCallTimeoutTime: number;
rpcParserBufferSize: number;
rpcMiddlewareFactory?: MiddlewareFactory, JSONRPCRequest, JSONRPCResponse, JSONRPCResponse>;
};
nodes: {
connectionIdleTimeoutTimeMin: number;
connectionIdleTimeoutTimeScale: number;
connectionFindConcurrencyLimit: number;
connectionConnectTimeoutTime: number;
connectionKeepAliveTimeoutTime: number;
connectionKeepAliveIntervalTime: number;
connectionHolePunchIntervalTime: number;
connectionInitialMaxStreamsBidi: number;
connectionInitialMaxStreamsUni: number;
rpcCallTimeoutTime: number;
rpcParserBufferSize: number;
dnsServers: Array | undefined;
};
mdns: {
groups: Array;
port: number;
};
versionMetadata: POJO;
};
export type { POJO, JSONValue, Opaque, brand, Callback, NonEmptyArray, AbstractConstructorParameters, Initial, InitialParameters, ToString, DeepReadonly, DeepPartial, Ref, Timer, PromiseDeconstructed, FileSystem, FileHandle, FunctionProperties, NonFunctionProperties, RecordKeyFromValue, InverseRecord, ObjectEmpty, PolykeyAgentOptions, };