Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Commit 15f96dc

Browse files
author
Akim
authored
feat(js-client)!: Remove getter for secret key (#416)
* Remove secret key * Node -> Relay * Fix doc
1 parent 4d90414 commit 15f96dc

File tree

4 files changed

+15
-31
lines changed

4 files changed

+15
-31
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ Here is an example using the JSDELIVR CDN:
3333
```html
3434
<head>
3535
<title>Cool App</title>
36-
<script
37-
type="module"
38-
src="https://cdn.jsdelivr.net/npm/@fluencelabs/js-client/dist/browser/index.min.js"
39-
></script>
4036
<script type="module">
4137
import {
4238
Fluence,

packages/core/js-client/src/clientPeer/ClientPeer.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ export class ClientPeer extends FluencePeer implements IFluenceClient {
9090
);
9191
}
9292

93-
getPeerSecretKey(): Uint8Array {
94-
return this.keyPair.toEd25519PrivateKey();
95-
}
96-
9793
connectionState: ConnectionState = "disconnected";
9894
connectionStateChangeHandler: (state: ConnectionState) => void = () => {};
9995

packages/core/js-client/src/clientPeer/types.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,25 @@ import { z } from "zod";
2121
*/
2222
export type PeerIdB58 = string;
2323

24+
const relaySchema = z.object({
25+
peerId: z.string(),
26+
multiaddr: z.string(),
27+
});
28+
2429
/**
25-
* Node of the Fluence network specified as a pair of node's multiaddr and it's peer id
30+
* Relay of the Fluence network specified as a pair of node's multiaddr and it's peer id
2631
*/
27-
export type Node = {
28-
peerId: PeerIdB58;
29-
multiaddr: string;
30-
};
31-
32-
export const relaySchema = z.union([
33-
z.string(),
34-
z.object({
35-
peerId: z.string(),
36-
multiaddr: z.string(),
37-
}),
38-
]);
32+
export type Relay = z.infer<typeof relaySchema>;
33+
34+
export const relayOptionsSchema = z.union([z.string(), relaySchema]);
3935

4036
/**
41-
* A node in Fluence network a client can connect to.
37+
* A relay in Fluence network a client can connect to.
4238
* Can be in the form of:
4339
* - string: multiaddr in string format
44-
* - Node: node structure, @see Node
40+
* - Relay: relay structure, @see Relay
4541
*/
46-
export type RelayOptions = z.infer<typeof relaySchema>;
42+
export type RelayOptions = z.infer<typeof relayOptionsSchema>;
4743

4844
/**
4945
* Fluence Peer's key pair types
@@ -102,11 +98,6 @@ export interface IFluenceClient {
10298
handler: (state: ConnectionState) => void,
10399
): ConnectionState;
104100

105-
/**
106-
* Return peer's secret key as byte array.
107-
*/
108-
getPeerSecretKey(): Uint8Array;
109-
110101
/**
111102
* Return peer's public key as a base58 string (multihash/CIDv0).
112103
*/

packages/core/js-client/src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
configSchema,
2323
ConnectionState,
2424
RelayOptions,
25-
relaySchema,
25+
relayOptionsSchema,
2626
} from "./clientPeer/types.js";
2727
import { callAquaFunction } from "./compilerSupport/callFunction.js";
2828
import { registerService } from "./compilerSupport/registerService.js";
@@ -36,7 +36,7 @@ const createClient = async (
3636
config: ClientConfig = {},
3737
): Promise<ClientPeer> => {
3838
try {
39-
relay = relaySchema.parse(relay);
39+
relay = relayOptionsSchema.parse(relay);
4040
config = configSchema.parse(config);
4141
} catch (e) {
4242
if (e instanceof ZodError) {
@@ -125,6 +125,7 @@ export type {
125125
ClientConfig,
126126
IFluenceClient,
127127
ConnectionState,
128+
Relay,
128129
RelayOptions,
129130
KeyPairOptions,
130131
} from "./clientPeer/types.js";

0 commit comments

Comments
 (0)