From e6941a34e249e1f8aebbc5774c77502264861e69 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 7 Jan 2023 23:39:42 -0500 Subject: [PATCH] *add plugin util types --- package.json | 2 ++ src/plugin.ts | 2 ++ src/util.ts | 12 ++++++++++++ 3 files changed, 16 insertions(+) create mode 100644 src/util.ts diff --git a/package.json b/package.json index 2f5554e..4e66c7b 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,9 @@ "type": "module", "devDependencies": { "@lumeweb/cfg": "https://git.lumeweb.com/LumeWeb/cfg.git", + "@types/b4a": "^1.6.0", "@types/node": "^18.11.17", + "c": "^1.1.1", "express": "^4.18.1", "node-cache": "^5.1.2", "prettier": "^2.8.1", diff --git a/src/plugin.ts b/src/plugin.ts index d908f27..2bf44cb 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -5,6 +5,7 @@ import SSLManager from "./ssl.js"; import type { HDKey } from "micro-ed25519-hdkey"; import type Config from "@lumeweb/cfg"; import type { ProtocolManager } from "./swarm.js"; +import type { Util } from "./util.js"; export type PluginFunction = (api: PluginAPI) => Promise; @@ -27,6 +28,7 @@ export declare class PluginAPI extends EventEmitter2 { server: RPCServer; swarm: any; }); + get util(): Util; get swarm(): any; get config(): Config; get pluginConfig(): Config; diff --git a/src/util.ts b/src/util.ts new file mode 100644 index 0000000..a9a6ef2 --- /dev/null +++ b/src/util.ts @@ -0,0 +1,12 @@ +import type b4a from "b4a"; +import type c from "compact-encoding"; +export declare class Util { + private _crypto; + get crypto(): Crypto; + get bufferEncoding(): typeof b4a; + get binaryEncoding(): typeof c; +} + +export declare class Crypto { + createHash(data: string): Buffer; +}