Compare commits

..

No commits in common. "6da33f1352305c509f0b87546e23ad9ad6f791d4" and "f105bab7807ee168fad36af290f3613c2961f6b3" have entirely different histories.

7 changed files with 91 additions and 35 deletions

1
dist/index.d.ts vendored
View File

@ -1,3 +1,4 @@
export * from "./rpc.js";
export * from "./plugin.js";
export * from "./files.js";
//# sourceMappingURL=index.d.ts.map

2
dist/index.d.ts.map vendored
View File

@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
{"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"}

83
dist/plugin.d.ts vendored
View File

@ -1,41 +1,62 @@
import type { EventEmitter2 } from "eventemitter2";
/// <reference types="node" />
import Config from "@lumeweb/cfg";
import tls from "tls";
import { Logger } from "loglevel";
import { RPCMethod, RPCServer } from "./rpc.js";
import { Logger } from "pino";
import SSLManager from "./ssl.js";
import type { HDKey } from "micro-ed25519-hdkey";
import Config from "./config.js";
import { IndependentFileSmall, SavedSslData, SslData } from "./files.js";
import type { express } from "express";
import type { Err } from "libskynet";
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 {
name: string;
plugin: PluginFunction;
exports?: any;
default?: Plugin;
}
declare class PluginAPI extends EventEmitter2 {
private _server;
constructor({
config,
logger,
server,
swarm,
}: {
config: Config;
logger: Logger;
server: RPCServer;
swarm: any;
});
private _swarm;
get swarm(): any;
private _config;
get config(): Config;
private _logger;
get logger(): Logger;
get rpcServer(): RPCServer;
get seed(): Uint8Array;
get identity(): HDKey;
get ssl(): SSLManager;
loadPlugin(moduleName: string): (moduleName: string) => Promise<Plugin>;
registerMethod(methodName: string, method: RPCMethod): void;
export interface PluginAPI {
config: Config;
registerMethod: (methodName: string, method: RPCMethod) => void;
loadPlugin: (moduleName: string) => Promise<Plugin>;
getRpcServer: () => RPCServer;
ssl: {
setContext: (context: tls.SecureContext) => void;
getContext: () => tls.SecureContext;
getSaved: (retry: boolean) => Promise<boolean | SavedSslData>;
set: (
cert: IndependentFileSmall | Uint8Array,
key: IndependentFileSmall | Uint8Array
) => void;
get: () => SslData;
save: () => Promise<void>;
setCheck(checker: () => Promise<void>): void;
};
appRouter: {
get: () => express.Router;
set: (newRouter: express.Router) => void;
reset: () => void;
};
files: {
createIndependentFileSmall(
seed: Uint8Array,
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

View File

@ -1 +1 @@
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,UAAU,MAAM,UAAU,CAAC;AAClC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE/D,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;I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E,MAAM,OAAO,CAAC;QACnB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;KAC9C,CAAC;IACF,SAAS,EAAE;QACT,GAAG,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC;QAC1B,GAAG,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC;QACzC,KAAK,EAAE,MAAM,IAAI,CAAC;KACnB,CAAC;IACF,KAAK,EAAE;QACL,0BAA0B,CACxB,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,UAAU,GACnB,OAAO,CAAC,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC,CAAC;QACxC,wBAAwB,CACtB,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC,CAAC;QACxC,6BAA6B,CAC3B,IAAI,EAAE,oBAAoB,EAC1B,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,GAAG,CAAC,CAAC;KACjB,CAAC;IACF,GAAG,EAAE;QACH,WAAW,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC;KAC1C,CAAC;IACF,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,UAAU,CAAC;CAC3B"}

View File

@ -7,8 +7,7 @@
"@types/node": "^18.11.17",
"express": "^4.18.1",
"node-cache": "^5.1.2",
"prettier": "^2.8.1",
"typescript": "^4.9.4"
"prettier": "^2.8.1"
},
"dependencies": {
"@types/eventemitter2": "^4.1.0",

34
src/files.ts Normal file
View File

@ -0,0 +1,34 @@
// @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;
}

View File

@ -1,2 +1,3 @@
export * from "./rpc.js";
export * from "./plugin.js";
export * from "./files.js";