Compare commits

...

76 Commits

Author SHA1 Message Date
semantic-release-bot a3396e438d chore(release): 0.0.2-develop.1 [skip ci]
## [0.0.2-develop.1](https://git.lumeweb.com/LumeWeb/interface-relay/compare/v0.0.1...v0.0.2-develop.1) (2023-07-04)
2023-07-04 08:19:09 +00:00
Derrick Hammer eed6804640
ci: add .presetterrc.json 2023-07-04 04:18:05 -04:00
Derrick Hammer 66d2112d2f
ci: add npm-shrinkwrap.json 2023-07-04 04:14:40 -04:00
Derrick Hammer 830a349d6c
ci: add missing config settings 2023-07-04 04:14:09 -04:00
Derrick Hammer 78a58db9c0
dep: update deps 2023-07-04 04:12:59 -04:00
Derrick Hammer 21341f6af4
refactor: DHTCache no longer used 2023-07-04 04:12:20 -04:00
Derrick Hammer 0030db4237
refactor: move to ci and update deps 2023-07-04 03:59:00 -04:00
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
Derrick Hammer 3ae45da896
*Update package name 2023-03-18 04:55:51 -04:00
Derrick Hammer b1d11e4d1c
*Switch to pnpm 2023-02-06 10:38:38 -05:00
Derrick Hammer 4f7a3bf728
*Update dist 2023-01-07 23:46:42 -05:00
Derrick Hammer 4e460a182d
*Update dist 2023-01-07 23:40:24 -05:00
Derrick Hammer 65211fe144
*Ensure all imports are type imports 2023-01-07 23:40:08 -05:00
Derrick Hammer e6941a34e2
*add plugin util types 2023-01-07 23:39:42 -05:00
Derrick Hammer 5a3226e0b9
*Update dist 2023-01-07 23:07:26 -05:00
Derrick Hammer 6bcb61e3c6
*Add handleRequest 2023-01-07 23:07:11 -05:00
Derrick Hammer 7c3c193b4a
*Update dist 2022-12-30 01:08:54 -05:00
Derrick Hammer baf8ebd511
*Update dist 2022-12-30 01:06:52 -05:00
Derrick Hammer 815c7a824c
*Add protocol manager api 2022-12-30 01:06:29 -05:00
Derrick Hammer 0d6219837a
*Update dist 2022-12-21 15:19:10 -05:00
Derrick Hammer c476a94b0e
*Don't bundle cfg types 2022-12-21 15:18:48 -05:00
Derrick Hammer b5b1a8bbb9
*Remove private property references 2022-12-21 15:01:15 -05:00
Derrick Hammer f1da2249ac
*Update dist 2022-12-19 15:19:47 -05:00
Derrick Hammer 632bd19635
*add dhtCache to RPCCache 2022-12-19 15:19:27 -05:00
Derrick Hammer b139bba69a
*Update dist 2022-12-19 15:13:43 -05:00
Derrick Hammer b3519688d4
*PluginAPI needs to be exported 2022-12-19 15:13:20 -05:00
Derrick Hammer 6da33f1352
*Update dist 2022-12-19 15:09:07 -05:00
Derrick Hammer a4c4920839
remove files types 2022-12-19 15:08:50 -05:00
Derrick Hammer 66c879033a
*add typescript dep 2022-12-19 15:08:28 -05:00
Derrick Hammer f105bab780
*Remove @lumeweb/cfg 2022-12-19 15:03:45 -05:00
Derrick Hammer 5242c16367
*Update types to reflect relay refactoring and new plugin api
*Clean up old code
2022-12-19 12:37:59 -05:00
Derrick Hammer 2d7bed64d5
*Update dist 2022-12-15 04:47:36 -05:00
Derrick Hammer 998076824d
*ts-ignore 2022-12-15 04:46:56 -05:00
Derrick Hammer 2f3ca517b3
*Add timeout to RPCBroadcastRequest 2022-12-15 04:45:50 -05:00
Derrick Hammer 298d043b39
*Update dist 2022-11-28 02:22:12 -05:00
Derrick Hammer ae10937bb8
*RPCCache.data now returns NodeCache 2022-11-28 02:21:57 -05:00
Derrick Hammer 33b87a1075
*Update dist 2022-11-28 00:17:29 -05:00
Derrick Hammer e8d4c0c756
*Remove getNodeQuery 2022-11-28 00:17:11 -05:00
Derrick Hammer 90beb40785
*Update dist 2022-11-27 18:09:10 -05:00
Derrick Hammer b6ea4e687c
*RPC Clear Cache types not needed 2022-11-27 18:08:44 -05:00
Derrick Hammer 75bb30db99
*Update dist 2022-11-27 18:05:52 -05:00
Derrick Hammer e95e8d830f
*RPCClearCacheRequest not needed as we will generalize it through broadcast request 2022-11-27 18:05:29 -05:00
Derrick Hammer 4c618a311d
*Update dist 2022-11-26 02:54:14 -05:00
Derrick Hammer 516e82b7c1
*Organize types
*Refactor RPC JSON again
*Add types for rpc clear cache and broadcast request/response
*Add declares for new core classes
2022-11-26 02:53:45 -05:00
Derrick Hammer 4c04f4b11a
*Update dist 2022-09-21 16:15:33 -04:00
Derrick Hammer efcc37871d
*add @lumeweb/cfg for types 2022-09-21 16:15:12 -04:00
Derrick Hammer 83b831b621
*Update dist 2022-09-21 07:21:38 -04:00
Derrick Hammer b02c78fcb6
*Add setCheck to ssl api 2022-09-21 07:21:12 -04:00
Derrick Hammer c21fa3ea15
*Update dist 2022-09-09 06:22:17 -04:00
Derrick Hammer 54ef04d959
*Have the DnsProvider be passed the domain so we don't need to read it from the config 2022-09-09 06:22:04 -04:00
Derrick Hammer cd8e8c6489
*Update dist 2022-09-09 04:19:58 -04:00
Derrick Hammer 14cfb55f85
*Add dns api 2022-09-09 04:19:28 -04:00
Derrick Hammer ce5e713f6a
*Update dist 2022-09-09 04:09:44 -04:00
Derrick Hammer d435344353
*Update getSaved return 2022-09-09 04:09:32 -04:00
Derrick Hammer 568dd8ff9b
*Update dist 2022-09-09 04:06:52 -04:00
Derrick Hammer b04f609592
*Add SavedSslData type 2022-09-09 04:05:23 -04:00
Derrick Hammer 727dffed67
*Update dist 2022-09-09 04:02:09 -04:00
Derrick Hammer bc75b57397
*SslData should just be Uint8Array's 2022-09-09 04:01:57 -04:00
Derrick Hammer bc6d683477
*Update dist 2022-09-09 03:57:07 -04:00
Derrick Hammer 24aa7201e2
*Change ssl set and SslData to allow Uint8Arrays 2022-09-09 03:56:33 -04:00
Derrick Hammer 3bf6ccb1f0
*Update dist 2022-09-09 03:42:21 -04:00
Derrick Hammer 56a54b48ae
*add getSeed to api 2022-09-09 03:41:38 -04:00
Derrick Hammer 789542e2a6
*Add files api 2022-09-09 03:41:27 -04:00
Derrick Hammer 17fa55f156
*Update dist 2022-09-09 03:20:52 -04:00
Derrick Hammer 648c366b6d
*Add plugin api for ssl, approuter, and logger
*Move IndependentFile types to types repo as it will be used by plugins
2022-09-09 03:20:31 -04:00
Derrick Hammer 9768e2dc9d
*Update dist 2022-08-28 22:17:28 -04:00
Derrick Hammer a9e069bafe
*Only emits types 2022-08-28 22:17:21 -04:00
Derrick Hammer ea7a23e824
*Update dist 2022-08-28 22:16:18 -04:00
Derrick Hammer d94c3c8e5a
*Remove schema and keep in relay 2022-08-28 22:15:58 -04:00
Derrick Hammer 1a77bb0469
*Update dist 2022-08-28 22:11:57 -04:00
Derrick Hammer 6a91a5f4fd
*Fix package name 2022-08-28 22:09:16 -04:00
Derrick Hammer 890d593cff
*Add dist 2022-08-28 22:02:11 -04:00
Derrick Hammer eb2d441670
*Initial version extracted from @lumeweb/relay 2022-08-28 22:01:51 -04:00
12 changed files with 19944 additions and 1 deletions

13
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,13 @@
name: Build/Publish
on:
push:
branches:
- master
- develop
- develop-*
jobs:
main:
uses: lumeweb/github-node-deploy-workflow/.github/workflows/main.yml@master
secrets: inherit

5
.presetterrc.json Normal file
View File

@ -0,0 +1,5 @@
{
"preset": [
"@lumeweb/node-library-preset"
]
}

1
CHANGELOG.md Normal file
View File

@ -0,0 +1 @@
## [0.0.2-develop.1](https://git.lumeweb.com/LumeWeb/interface-relay/compare/v0.0.1...v0.0.2-develop.1) (2023-07-04)

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2022 Lume Web Copyright (c) 2022 Hammmer Technologies LLC
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

19731
npm-shrinkwrap.json generated Normal file

File diff suppressed because it is too large Load Diff

36
package.json Normal file
View File

@ -0,0 +1,36 @@
{
"name": "@lumeweb/interface-relay",
"version": "0.0.2-develop.1",
"main": "lib/index.js",
"type": "module",
"types": "lib/index.d.ts",
"repository": {
"type": "git",
"url": "gitea@git.lumeweb.com:LumeWeb/interface-relay.git"
},
"devDependencies": {
"@lumeweb/node-library-preset": "^0.2.7",
"@types/b4a": "^1.6.0",
"compact-encoding": "^2.12.0",
"ed25519-keygen": "^0.4.1",
"eventemitter2": "^6.4.9",
"fastify": "^4.19.2",
"node-cache": "^5.1.2",
"presetter": "*"
},
"readme": "ERROR: No README data found!",
"scripts": {
"prepare": "presetter bootstrap",
"build": "run build",
"semantic-release": "semantic-release"
},
"dependencies": {
"@lumeweb/relay-cfg": "0.1.9"
},
"publishConfig": {
"access": "public"
},
"files": [
"lib"
]
}

3
src/index.ts Normal file
View File

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

45
src/plugin.ts Normal file
View File

@ -0,0 +1,45 @@
import type { EventEmitter2 } from "eventemitter2";
import type { RPCMethod, RPCServer } from "./rpc.js";
import type { Logger } from "pino";
import type SSLManager from "./ssl.js";
import type { HDKey } from "ed25519-keygen/hdkey";
import type { Config } from "@lumeweb/relay-cfg";
import type { ProtocolManager } from "./swarm.js";
import type { Util } from "./util.js";
import type { FastifyInstance } from "fastify";
export type PluginFunction = (api: PluginAPI) => Promise<void>;
export interface Plugin {
name: string;
plugin: PluginFunction;
exports?: any;
default?: Plugin;
}
export declare class PluginAPI extends EventEmitter2 {
constructor({
config,
logger,
server,
swarm,
}: {
config: Config;
logger: Logger;
server: RPCServer;
swarm: any;
});
get util(): Util;
get swarm(): any;
get config(): Config;
get pluginConfig(): Config;
get logger(): Logger;
get rpcServer(): RPCServer;
get seed(): Uint8Array;
get identity(): HDKey;
get ssl(): SSLManager;
get protocols(): ProtocolManager;
get app(): FastifyInstance;
loadPlugin(moduleName: string): (moduleName: string) => Promise<Plugin>;
registerMethod(methodName: string, method: RPCMethod): void;
}

66
src/rpc.ts Normal file
View File

@ -0,0 +1,66 @@
import type EventEmitter from "events";
import type NodeCache from "node-cache";
export interface RPCRequest {
module: string;
method: string;
data: any;
}
export interface ClientRPCRequest extends RPCRequest {
bypassCache?: boolean;
}
export interface RPCResponse {
updated?: number;
data?: any | RPCResponse;
error?: string;
signature?: string;
signedField?: string;
}
export interface RPCMethod {
cacheable: boolean;
handler: (req: any) => Promise<any>;
}
export interface RPCCacheData {
[query: string]: RPCCacheItem | null;
}
export interface RPCCacheItem extends RPCResponse {
value: RPCResponse;
signature: string;
}
export interface RPCBroadcastRequest {
request: RPCRequest;
relays: string[];
timeout: number;
}
export interface RPCBroadcastResponse extends RPCResponse {
relays: { [relay: string]: RPCResponse };
}
export declare class RPCServer extends EventEmitter {
get cache(): RPCCache;
registerMethod(
moduleName: string,
methodName: string,
options: RPCMethod,
): void;
public getMethods(): string[];
public setup(stream: any): any;
public signData(data: any): string;
public static hashQuery(query: RPCRequest): string;
public handleRequest(request: RPCRequest): Promise<RPCResponse>;
}
export declare class RPCCache extends EventEmitter {
get data(): NodeCache;
constructor(server: RPCServer);
public signResponse(item: RPCCacheItem): any;
public verifyResponse(pubkey: Buffer, item: RPCCacheItem): boolean | Buffer;
public addItem(query: RPCRequest, response: RPCResponse): void;
public deleteItem(queryHash: string): boolean;
}

25
src/ssl.ts Normal file
View File

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

6
src/swarm.ts Normal file
View File

@ -0,0 +1,6 @@
export type ProtocolHandler = (peer: any, muxer: any) => void;
export declare class ProtocolManager {
constructor(swarm: any);
register(name: string, handler: ProtocolHandler): boolean;
}

12
src/util.ts Normal file
View File

@ -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;
}