feat(js-client)!: Remove getter for secret key (#416)

* Remove secret key

* Node -> Relay

* Fix doc
This commit is contained in:
Akim 2024-01-12 15:25:45 +07:00 committed by GitHub
parent 4d90414190
commit 15f96dc5f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 30 deletions

View File

@ -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,

View File

@ -90,10 +90,6 @@ export class ClientPeer extends FluencePeer implements IFluenceClient {
);
}
getPeerSecretKey(): Uint8Array {
return this.keyPair.toEd25519PrivateKey();
}
connectionState: ConnectionState = "disconnected";
connectionStateChangeHandler: (state: ConnectionState) => void = () => {};

View File

@ -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 type Relay = z.infer<typeof relaySchema>;
export const relaySchema = z.union([
z.string(),
z.object({
peerId: z.string(),
multiaddr: z.string(),
}),
]);
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
@ -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).
*/

View File

@ -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";
@ -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) {
@ -125,6 +125,7 @@ export type {
ClientConfig,
IFluenceClient,
ConnectionState,
Relay,
RelayOptions,
KeyPairOptions,
} from "./clientPeer/types.js";