Compare commits

..

4 Commits

Author SHA1 Message Date
Derrick Hammer 9401b0420c
*Update dist 2023-04-18 22:56:10 -04:00
Derrick Hammer 8bad551b29
*add app getter 2023-04-18 22:56:00 -04:00
Derrick Hammer 4995bdcefe
*Update dist 2023-04-18 22:54:51 -04:00
Derrick Hammer 3231c18e08
*Update SSL types 2023-04-18 22:54:35 -04:00
7 changed files with 28 additions and 18 deletions

2
dist/plugin.d.ts vendored
View File

@ -6,6 +6,7 @@ import type { HDKey } from "micro-ed25519-hdkey";
import type Config from "@lumeweb/cfg"; import type Config from "@lumeweb/cfg";
import type { ProtocolManager } from "./swarm.js"; import type { ProtocolManager } from "./swarm.js";
import type { Util } from "./util.js"; import type { Util } from "./util.js";
import type { FastifyInstance } from "fastify";
export type PluginFunction = (api: PluginAPI) => Promise<void>; export type PluginFunction = (api: PluginAPI) => Promise<void>;
export interface Plugin { export interface Plugin {
name: string; name: string;
@ -35,6 +36,7 @@ export declare class PluginAPI extends EventEmitter2 {
get identity(): HDKey; get identity(): HDKey;
get ssl(): SSLManager; get ssl(): SSLManager;
get protocols(): ProtocolManager; get protocols(): ProtocolManager;
get app(): FastifyInstance;
loadPlugin(moduleName: string): (moduleName: string) => Promise<Plugin>; loadPlugin(moduleName: string): (moduleName: string) => Promise<Plugin>;
registerMethod(methodName: string, method: RPCMethod): void; registerMethod(methodName: string, method: RPCMethod): void;
} }

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,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,UAAU,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,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KAAK,CAAC;IACtB,IAAI,GAAG,IAAI,UAAU,CAAC;IACtB,IAAI,SAAS,IAAI,eAAe,CAAC;IACjC,IAAI,GAAG,IAAI,eAAe,CAAC;IAC3B,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"}

14
dist/ssl.d.ts vendored
View File

@ -2,19 +2,17 @@
/// <reference types="node" /> /// <reference types="node" />
import type tls from "tls"; import type tls from "tls";
export type SSLManagerRenewHandler = (domain: string) => Promise<boolean>; export type SSLManagerRenewHandler = (domain: string) => Promise<boolean>;
export type SSLCert = string | Buffer | Array<string | Buffer>;
declare class SSLManager { declare class SSLManager {
private _context?;
private _key?;
private _cert?;
private _domain;
private _renewHandler?;
constructor(domain: string); constructor(domain: string);
get context(): tls.SecureContext; get context(): tls.SecureContext;
set privateKey(key: Buffer); set privateKey(key: Buffer);
set cert(cert: Buffer); set cert(cert: SSLCert);
private _maybeUpdateContext;
renew(): Promise<boolean>; renew(): Promise<boolean>;
get enabled(): any; get enabled(): boolean;
get ready(): boolean;
get renewHandler(): SSLManagerRenewHandler;
set renewHandler(value: SSLManagerRenewHandler);
} }
export default SSLManager; export default SSLManager;
//# sourceMappingURL=ssl.d.ts.map //# sourceMappingURL=ssl.d.ts.map

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

@ -1 +1 @@
{"version":3,"file":"ssl.d.ts","sourceRoot":"","sources":["../src/ssl.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B,MAAM,MAAM,sBAAsB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAC1E,OAAO,OAAO,UAAU;IACtB,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClB,OAAO,CAAC,IAAI,CAAC,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1.1",
"express": "^4.18.1", "express": "^4.18.1",
"fastify": "^4.15.0",
"node-cache": "^5.1.2", "node-cache": "^5.1.2",
"prettier": "^2.8.1", "prettier": "^2.8.1",
"typescript": "^4.9.4" "typescript": "^4.9.4"

View File

@ -6,6 +6,7 @@ import type { HDKey } from "micro-ed25519-hdkey";
import type Config from "@lumeweb/cfg"; import type Config from "@lumeweb/cfg";
import type { ProtocolManager } from "./swarm.js"; import type { ProtocolManager } from "./swarm.js";
import type { Util } from "./util.js"; import type { Util } from "./util.js";
import type { FastifyInstance } from "fastify";
export type PluginFunction = (api: PluginAPI) => Promise<void>; export type PluginFunction = (api: PluginAPI) => Promise<void>;
@ -38,6 +39,7 @@ export declare class PluginAPI extends EventEmitter2 {
get identity(): HDKey; get identity(): HDKey;
get ssl(): SSLManager; get ssl(): SSLManager;
get protocols(): ProtocolManager; get protocols(): ProtocolManager;
get app(): FastifyInstance;
loadPlugin(moduleName: string): (moduleName: string) => Promise<Plugin>; loadPlugin(moduleName: string): (moduleName: string) => Promise<Plugin>;
registerMethod(methodName: string, method: RPCMethod): void; registerMethod(methodName: string, method: RPCMethod): void;
} }

View File

@ -1,18 +1,25 @@
import type tls from "tls"; import type tls from "tls";
export type SSLManagerRenewHandler = (domain: string) => Promise<boolean>; export type SSLManagerRenewHandler = (domain: string) => Promise<boolean>;
export type SSLCert = string | Buffer | Array<string | Buffer>;
declare class SSLManager { declare class SSLManager {
private _context?;
private _key?;
private _cert?;
private _domain;
private _renewHandler?;
constructor(domain: string); constructor(domain: string);
get context(): tls.SecureContext; get context(): tls.SecureContext;
set privateKey(key: Buffer); set privateKey(key: Buffer);
set cert(cert: Buffer);
private _maybeUpdateContext; set cert(cert: SSLCert);
renew(): Promise<boolean>; renew(): Promise<boolean>;
get enabled(): any;
get enabled(): boolean;
get ready(): boolean;
get renewHandler(): SSLManagerRenewHandler;
set renewHandler(value: SSLManagerRenewHandler);
} }
export default SSLManager; export default SSLManager;