@persistica/flux-agent 0.0.1 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/index.js +1103 -0
- package/package.json +21 -22
- package/src/index.d.ts +1 -1
- package/src/lib/channel/channel.type.d.ts +10 -0
- package/src/lib/connector/auth/register-client.auth.d.ts +18 -0
- package/src/lib/connector/flux-client-data.class.d.ts +11 -0
- package/src/lib/connector/low-level-com/web-rtc/ice-connection.d.ts +34 -0
- package/src/lib/connector/rpc/NOT-USED-network-authority.class.d.ts +4 -0
- package/src/lib/connector/state-machines/connect-to-remote-client.d.ts +6 -0
- package/src/lib/flux-agent.class.d.ts +43 -0
- package/src/lib/flux-interface.class.d.ts +12 -0
- package/src/lib/flux-remote-client.class.d.ts +10 -0
- package/src/lib/route-transport-coordinator.d.ts +8 -0
- package/src/lib/utils/obscuring/decrypt.utils.d.ts +13 -0
- package/src/lib/utils/obscuring/encyprt.utils.d.ts +12 -0
- package/src/lib/utils/obscuring/shared.utils.d.ts +9 -0
- package/index.cjs +0 -35
- package/src/lib/persistica-flux-agent-2.d.ts +0 -1
package/package.json
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"module": "./index.js"
|
|
2
|
+
"name": "@persistica/flux-agent",
|
|
3
|
+
"version": "0.0.6",
|
|
4
|
+
"description": "Persistica Flux Agent",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [],
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"exports": "./index.js",
|
|
11
|
+
"main": "./index.js",
|
|
12
|
+
"types": "./src/index.d.ts",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/rujorgensen/persistica.git"
|
|
16
|
+
},
|
|
17
|
+
"author": "pixl.prophet",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/rujorgensen/persistica/issues"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/rujorgensen/persistica#readme"
|
|
24
23
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { FluxAgent, } from './lib/flux-agent.class';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TChannelName } from '@flux/shared/types';
|
|
2
|
+
/**
|
|
3
|
+
* Callback function to authorize a channel connection.
|
|
4
|
+
*
|
|
5
|
+
* @param { TChannelName } channelTopic - the topic to subscribe to
|
|
6
|
+
* @param { unknown } identification - whatever identification the authority requires
|
|
7
|
+
*
|
|
8
|
+
* @returns { Promise<boolean> } - true if the channel connection is authorized, false otherwise
|
|
9
|
+
*/
|
|
10
|
+
export type TChannnelAuthCallback<T> = (channelTopic: TChannelName, identification: T) => Promise<boolean>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type TAuthenticationTicket, type TAgentOwnUId, type TNetworkId_S } from '@flux/shared/types';
|
|
2
|
+
import { type TFluxClientUID } from '@flux/shared/utils';
|
|
3
|
+
/**
|
|
4
|
+
* Authenticates with the server and returns a ticket for connecting the websocket.
|
|
5
|
+
*
|
|
6
|
+
* This client -> flux server -> authority client -> flux server -> this client.
|
|
7
|
+
*
|
|
8
|
+
* @param { string } domain The domain of the authority server.
|
|
9
|
+
* @param { unknown } unknownIdentificationPayload The payload to send to the authority server.
|
|
10
|
+
* @param { string } [password]
|
|
11
|
+
* @param { TAgentOwnUId } [agentOwnUId]
|
|
12
|
+
*
|
|
13
|
+
* @returns { Promise<TAuthenticationTicket> }
|
|
14
|
+
*/
|
|
15
|
+
export declare const authenticateAgentOrThrow: (networkId: TNetworkId_S, domain: string, unknownIdentificationPayload: unknown, clientInfo: {
|
|
16
|
+
clientUId?: TAgentOwnUId;
|
|
17
|
+
machineUID?: TFluxClientUID;
|
|
18
|
+
}, password?: string) => Promise<TAuthenticationTicket>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collects data from any source (currently WS or WebRTC)
|
|
3
|
+
*/
|
|
4
|
+
import type { TMessageCallback } from '@flux/shared/ws';
|
|
5
|
+
import type { FluxWebSocketConnection } from '@flux/shared/connection';
|
|
6
|
+
export declare class FluxClientData {
|
|
7
|
+
private readonly callbacks;
|
|
8
|
+
private fluxWebSocketConnection;
|
|
9
|
+
updateWsConnection(fluxWebSocketConnection: FluxWebSocketConnection): void;
|
|
10
|
+
onMessage(cb: TMessageCallback): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One device calls createOffer() and shares the generated offer with the second device.
|
|
3
|
+
* The second device calls acceptOffer(offer), generates an answer, and shares it back with the first device.
|
|
4
|
+
* Both devices exchange ICE candidates (logged in the console) to establish the P2P connection.
|
|
5
|
+
* Once connected, messages can be sent between devices.
|
|
6
|
+
*/
|
|
7
|
+
import type { TRTCState } from '@flux/shared/utils';
|
|
8
|
+
import type { FluxWebSocketClientConnection } from '@flux/shared/ws';
|
|
9
|
+
export declare class ICEConnection {
|
|
10
|
+
private readonly _fluxWebSocketClientConnection;
|
|
11
|
+
private readonly _stateChange;
|
|
12
|
+
private readonly peerConnection;
|
|
13
|
+
private dataChannel;
|
|
14
|
+
private offerSDP;
|
|
15
|
+
constructor(_fluxWebSocketClientConnection: FluxWebSocketClientConnection, _stateChange: (state: TRTCState) => void);
|
|
16
|
+
/**
|
|
17
|
+
* This offer must be sent to the other peer.
|
|
18
|
+
*/
|
|
19
|
+
private createOffer;
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param { RTCSessionDescriptionInit } offer
|
|
23
|
+
*/
|
|
24
|
+
private acceptOffer;
|
|
25
|
+
private acceptAnswer;
|
|
26
|
+
/**
|
|
27
|
+
* If remote (not initiator) the answer was accepted.
|
|
28
|
+
*
|
|
29
|
+
* @param answer
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
private answerAcceptedByInitiator;
|
|
33
|
+
sendMessage(message: string): void;
|
|
34
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
var agentLoadCount: number | null | undefined;
|
|
3
|
+
}
|
|
4
|
+
import type { TMessageCallback } from '@flux/shared/ws';
|
|
5
|
+
import type { FluxAgentNetworkConnection } from '@flux/shared/connection';
|
|
6
|
+
export declare class FluxAgent {
|
|
7
|
+
private readonly networkId;
|
|
8
|
+
private readonly options?;
|
|
9
|
+
readonly id: string;
|
|
10
|
+
private fluxWebSocketConnection;
|
|
11
|
+
private readonly fluxClientData;
|
|
12
|
+
private readonly stateManager;
|
|
13
|
+
constructor(networkId: string, options?: {
|
|
14
|
+
domain?: string;
|
|
15
|
+
secretKey?: string;
|
|
16
|
+
retries?: number;
|
|
17
|
+
} | undefined);
|
|
18
|
+
/**
|
|
19
|
+
* Connect to the network using provided identification.
|
|
20
|
+
*
|
|
21
|
+
* @param { unknown } identification
|
|
22
|
+
* @param { string } [clientUId]
|
|
23
|
+
*
|
|
24
|
+
* @returns { Promise<FluxAgentNetworkConnection> }
|
|
25
|
+
*/
|
|
26
|
+
connect(identification: unknown, clientUId?: string): Promise<FluxAgentNetworkConnection>;
|
|
27
|
+
disconnect(): void;
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @param fn
|
|
31
|
+
*
|
|
32
|
+
* @returns { void }
|
|
33
|
+
*/
|
|
34
|
+
onWebRTConnectionState: (fn: (rtcState: import("@flux/shared/utils").TRTCState) => void) => void;
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param fn
|
|
38
|
+
*
|
|
39
|
+
* @returns { void }
|
|
40
|
+
*/
|
|
41
|
+
onNetworkState: (fn: (networkState: import("@flux/shared/utils").TNetworkConnectionState) => void) => void;
|
|
42
|
+
onMessage(cb: TMessageCallback): void;
|
|
43
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface to the flux platform:
|
|
3
|
+
*
|
|
4
|
+
* Requires socket connectivity to the Flux platform, and a verified network.
|
|
5
|
+
*/
|
|
6
|
+
import type { IPackageStatus } from '@flux/shared/types';
|
|
7
|
+
import type { FluxWebSocketConnection } from '../../../../../libs/flux/shared/connection/src/lib/flux-ws-connection';
|
|
8
|
+
export declare class FluxInterface {
|
|
9
|
+
private readonly socketConnection;
|
|
10
|
+
constructor(socketConnection: FluxWebSocketConnection);
|
|
11
|
+
messageReport(packageStatus: Omit<IPackageStatus, 'txNode'>): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A connection to another known client
|
|
3
|
+
*/
|
|
4
|
+
import { ICEConnection } from './connector/low-level-com/web-rtc/ice-connection';
|
|
5
|
+
export declare class FluxRemoteClient {
|
|
6
|
+
private readonly iceConnection;
|
|
7
|
+
constructor(iceConnection: ICEConnection);
|
|
8
|
+
callProcedure(): void;
|
|
9
|
+
send(message: string): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface IEncryptedData {
|
|
2
|
+
encrypted: string;
|
|
3
|
+
iv: string;
|
|
4
|
+
salt: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Decrypts an AES-256-GCM encrypted JSON object using a password
|
|
8
|
+
* @param {IEncryptedData} encryptedData - The encrypted data object
|
|
9
|
+
* @param {string} password - The password
|
|
10
|
+
* @returns {Promise<Object>} - Decrypted JSON object
|
|
11
|
+
*/
|
|
12
|
+
export declare function decrypt(encryptedData: IEncryptedData, password: string): Promise<any>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encrypts a JSON object using AES-256-GCM with password-derived key
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} data - The data to encrypt
|
|
5
|
+
* @param {string} password - The password
|
|
6
|
+
* @returns {Promise<Object>} - Encrypted data (Base64 format)
|
|
7
|
+
*/
|
|
8
|
+
export declare function encrypt(data: string, password: string): Promise<{
|
|
9
|
+
encrypted: string;
|
|
10
|
+
iv: string;
|
|
11
|
+
salt: string;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derive a cryptographic key from a password using PBKDF2
|
|
3
|
+
*
|
|
4
|
+
* @param { string } password - User-provided password
|
|
5
|
+
* @param { Uint8Array } salt - Salt for key derivation
|
|
6
|
+
*
|
|
7
|
+
* @returns { Promise<CryptoKey> } - AES-256-GCM key
|
|
8
|
+
*/
|
|
9
|
+
export declare function deriveKey(password: string, salt: any): Promise<CryptoKey>;
|
package/index.cjs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/flux/agent-2/src/index.ts
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
persisticaFluxAgent2: () => persisticaFluxAgent2
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(src_exports);
|
|
26
|
-
|
|
27
|
-
// packages/flux/agent-2/src/lib/persistica-flux-agent-2.ts
|
|
28
|
-
function persisticaFluxAgent2() {
|
|
29
|
-
return "persistica-flux-agent-2";
|
|
30
|
-
}
|
|
31
|
-
console.log("Hello from persistica-flux-agent!");
|
|
32
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
-
0 && (module.exports = {
|
|
34
|
-
persisticaFluxAgent2
|
|
35
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function persisticaFluxAgent2(): string;
|