Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ Here is an example using the JSDELIVR CDN:
```html
<head>
<title>Cool App</title>
<script
type="module"
src="https://cdn.jsdelivr.net/npm/@fluencelabs/js-client/dist/browser/index.min.js"
></script>
<script type="module">
import {
Fluence,
Expand Down
4 changes: 0 additions & 4 deletions packages/core/js-client/src/clientPeer/ClientPeer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ export class ClientPeer extends FluencePeer implements IFluenceClient {
);
}

getPeerSecretKey(): Uint8Array {
return this.keyPair.toEd25519PrivateKey();
}

connectionState: ConnectionState = "disconnected";
connectionStateChangeHandler: (state: ConnectionState) => void = () => {};

Expand Down
33 changes: 12 additions & 21 deletions packages/core/js-client/src/clientPeer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,25 @@ import { z } from "zod";
*/
export type PeerIdB58 = string;

const relaySchema = z.object({
peerId: z.string(),
multiaddr: z.string(),
});

/**
* Node of the Fluence network specified as a pair of node's multiaddr and it's peer id
* Relay of the Fluence network specified as a pair of node's multiaddr and it's peer id
*/
export type Node = {
peerId: PeerIdB58;
multiaddr: string;
};

export const relaySchema = z.union([
z.string(),
z.object({
peerId: z.string(),
multiaddr: z.string(),
}),
]);
export type Relay = z.infer<typeof relaySchema>;

export const relayOptionsSchema = z.union([z.string(), relaySchema]);

/**
* A node in Fluence network a client can connect to.
* A relay in Fluence network a client can connect to.
* Can be in the form of:
* - string: multiaddr in string format
* - Node: node structure, @see Node
* - Relay: relay structure, @see Relay
*/
export type RelayOptions = z.infer<typeof relaySchema>;
export type RelayOptions = z.infer<typeof relayOptionsSchema>;

/**
* Fluence Peer's key pair types
Expand Down Expand Up @@ -102,11 +98,6 @@ export interface IFluenceClient {
handler: (state: ConnectionState) => void,
): ConnectionState;

/**
* Return peer's secret key as byte array.
*/
getPeerSecretKey(): Uint8Array;

/**
* Return peer's public key as a base58 string (multihash/CIDv0).
*/
Expand Down
5 changes: 3 additions & 2 deletions packages/core/js-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
configSchema,
ConnectionState,
RelayOptions,
relaySchema,
relayOptionsSchema,
} from "./clientPeer/types.js";
import { callAquaFunction } from "./compilerSupport/callFunction.js";
import { registerService } from "./compilerSupport/registerService.js";
Expand All @@ -36,7 +36,7 @@ const createClient = async (
config: ClientConfig = {},
): Promise<ClientPeer> => {
try {
relay = relaySchema.parse(relay);
relay = relayOptionsSchema.parse(relay);
config = configSchema.parse(config);
} catch (e) {
if (e instanceof ZodError) {
Expand Down Expand Up @@ -125,6 +125,7 @@ export type {
ClientConfig,
IFluenceClient,
ConnectionState,
Relay,
RelayOptions,
KeyPairOptions,
} from "./clientPeer/types.js";
Expand Down