Compare commits
3 Commits
f105bab780
...
6da33f1352
Author | SHA1 | Date |
---|---|---|
Derrick Hammer | 6da33f1352 | |
Derrick Hammer | a4c4920839 | |
Derrick Hammer | 66c879033a |
|
@ -1,4 +1,3 @@
|
||||||
export * from "./rpc.js";
|
export * from "./rpc.js";
|
||||||
export * from "./plugin.js";
|
export * from "./plugin.js";
|
||||||
export * from "./files.js";
|
|
||||||
//# sourceMappingURL=index.d.ts.map
|
//# sourceMappingURL=index.d.ts.map
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
|
|
@ -1,62 +1,41 @@
|
||||||
/// <reference types="node" />
|
import type { EventEmitter2 } from "eventemitter2";
|
||||||
import Config from "@lumeweb/cfg";
|
|
||||||
import tls from "tls";
|
|
||||||
import { Logger } from "loglevel";
|
|
||||||
import { RPCMethod, RPCServer } from "./rpc.js";
|
import { RPCMethod, RPCServer } from "./rpc.js";
|
||||||
import { IndependentFileSmall, SavedSslData, SslData } from "./files.js";
|
import { Logger } from "pino";
|
||||||
import type { express } from "express";
|
import SSLManager from "./ssl.js";
|
||||||
import type { Err } from "libskynet";
|
import type { HDKey } from "micro-ed25519-hdkey";
|
||||||
|
import Config from "./config.js";
|
||||||
export type PluginFunction = (api: PluginAPI) => Promise<void>;
|
export type PluginFunction = (api: PluginAPI) => Promise<void>;
|
||||||
export type DnsProvider = (ipAddress: string, domain: string) => Promise<void>;
|
|
||||||
export type OverwriteDataFn = (newData: Uint8Array) => Promise<Err>;
|
|
||||||
export type ReadDataFn = () => Promise<[Uint8Array, Err]>;
|
|
||||||
export interface Plugin {
|
export interface Plugin {
|
||||||
name: string;
|
name: string;
|
||||||
plugin: PluginFunction;
|
plugin: PluginFunction;
|
||||||
exports?: any;
|
exports?: any;
|
||||||
default?: Plugin;
|
default?: Plugin;
|
||||||
}
|
}
|
||||||
export interface PluginAPI {
|
declare class PluginAPI extends EventEmitter2 {
|
||||||
config: Config;
|
private _server;
|
||||||
registerMethod: (methodName: string, method: RPCMethod) => void;
|
constructor({
|
||||||
loadPlugin: (moduleName: string) => Promise<Plugin>;
|
config,
|
||||||
getRpcServer: () => RPCServer;
|
logger,
|
||||||
ssl: {
|
server,
|
||||||
setContext: (context: tls.SecureContext) => void;
|
swarm,
|
||||||
getContext: () => tls.SecureContext;
|
}: {
|
||||||
getSaved: (retry: boolean) => Promise<boolean | SavedSslData>;
|
config: Config;
|
||||||
set: (
|
logger: Logger;
|
||||||
cert: IndependentFileSmall | Uint8Array,
|
server: RPCServer;
|
||||||
key: IndependentFileSmall | Uint8Array
|
swarm: any;
|
||||||
) => void;
|
});
|
||||||
get: () => SslData;
|
private _swarm;
|
||||||
save: () => Promise<void>;
|
get swarm(): any;
|
||||||
setCheck(checker: () => Promise<void>): void;
|
private _config;
|
||||||
};
|
get config(): Config;
|
||||||
appRouter: {
|
private _logger;
|
||||||
get: () => express.Router;
|
get logger(): Logger;
|
||||||
set: (newRouter: express.Router) => void;
|
get rpcServer(): RPCServer;
|
||||||
reset: () => void;
|
get seed(): Uint8Array;
|
||||||
};
|
get identity(): HDKey;
|
||||||
files: {
|
get ssl(): SSLManager;
|
||||||
createIndependentFileSmall(
|
loadPlugin(moduleName: string): (moduleName: string) => Promise<Plugin>;
|
||||||
seed: Uint8Array,
|
registerMethod(methodName: string, method: RPCMethod): void;
|
||||||
userInode: string,
|
|
||||||
fileData: Uint8Array
|
|
||||||
): Promise<[IndependentFileSmall, Err]>;
|
|
||||||
openIndependentFileSmall(
|
|
||||||
seed: Uint8Array,
|
|
||||||
userInode: string
|
|
||||||
): Promise<[IndependentFileSmall, Err]>;
|
|
||||||
overwriteIndependentFileSmall(
|
|
||||||
file: IndependentFileSmall,
|
|
||||||
newData: Uint8Array
|
|
||||||
): Promise<Err>;
|
|
||||||
};
|
|
||||||
dns: {
|
|
||||||
setProvider(provider: DnsProvider): void;
|
|
||||||
};
|
|
||||||
logger: Logger;
|
|
||||||
getSeed: () => Uint8Array;
|
|
||||||
}
|
}
|
||||||
|
export {};
|
||||||
//# sourceMappingURL=plugin.d.ts.map
|
//# sourceMappingURL=plugin.d.ts.map
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE/D,MAAM,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE/E,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEpE,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC;AAE1D,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,cAAc,C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;KACZ;IACD,OAAO,CAAC,MAAM,CAAC;IACf,IAAI,KAAK,IAAI,GAAG,CAAC;IACjB,OAAO,CAAC,OAAO,CAAC;IAChB,IAAI,MAAM,IAAI,MAAM,CAAC;IACrB,OAAO,CAAC,OAAO,CAAC;IAChB,IAAI,MAAM,IAAI,MAAM,CAAC;IACrB,IAAI,SAAS,IAAI,SAAS,CAAC;IAC3B,IAAI,IAAI,IAAI,UAAU,CAAC;IACvB,IAAI,QAAQ,IAAI,KAAK,CAAC;IACtB,IAAI,GAAG,IAAI,UAAU,CAAC;IACtB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC;IACvE,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI;CAC5D"}
|
|
@ -7,7 +7,8 @@
|
||||||
"@types/node": "^18.11.17",
|
"@types/node": "^18.11.17",
|
||||||
"express": "^4.18.1",
|
"express": "^4.18.1",
|
||||||
"node-cache": "^5.1.2",
|
"node-cache": "^5.1.2",
|
||||||
"prettier": "^2.8.1"
|
"prettier": "^2.8.1",
|
||||||
|
"typescript": "^4.9.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/eventemitter2": "^4.1.0",
|
"@types/eventemitter2": "^4.1.0",
|
||||||
|
|
34
src/files.ts
34
src/files.ts
|
@ -1,34 +0,0 @@
|
||||||
// @ts-ignore
|
|
||||||
import type { Ed25519Keypair, Err } from "libskynet";
|
|
||||||
import { OverwriteDataFn, ReadDataFn } from "./index.js";
|
|
||||||
|
|
||||||
export interface IndependentFileSmallMetadata {
|
|
||||||
largestHistoricSize: bigint;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IndependentFileSmall {
|
|
||||||
dataKey: Uint8Array;
|
|
||||||
fileData: Uint8Array;
|
|
||||||
inode: string;
|
|
||||||
keypair: Ed25519Keypair;
|
|
||||||
metadata: IndependentFileSmallMetadata;
|
|
||||||
revision: bigint;
|
|
||||||
seed: Uint8Array;
|
|
||||||
|
|
||||||
skylink: string;
|
|
||||||
viewKey: string;
|
|
||||||
|
|
||||||
overwriteData: OverwriteDataFn;
|
|
||||||
|
|
||||||
readData: ReadDataFn;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SslData {
|
|
||||||
cert?: Uint8Array;
|
|
||||||
key?: Uint8Array;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SavedSslData {
|
|
||||||
cert?: IndependentFileSmall;
|
|
||||||
key?: IndependentFileSmall;
|
|
||||||
}
|
|
|
@ -1,3 +1,2 @@
|
||||||
export * from "./rpc.js";
|
export * from "./rpc.js";
|
||||||
export * from "./plugin.js";
|
export * from "./plugin.js";
|
||||||
export * from "./files.js";
|
|
||||||
|
|
Loading…
Reference in New Issue