mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2024-12-03 17:40:18 +00:00
feat(js-client)!: Remove getter for secret key (#416)
* Remove secret key * Node -> Relay * Fix doc
This commit is contained in:
parent
4d90414190
commit
15f96dc5f7
@ -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,
|
||||
|
@ -90,10 +90,6 @@ export class ClientPeer extends FluencePeer implements IFluenceClient {
|
||||
);
|
||||
}
|
||||
|
||||
getPeerSecretKey(): Uint8Array {
|
||||
return this.keyPair.toEd25519PrivateKey();
|
||||
}
|
||||
|
||||
connectionState: ConnectionState = "disconnected";
|
||||
connectionStateChangeHandler: (state: ConnectionState) => void = () => {};
|
||||
|
||||
|
@ -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).
|
||||
*/
|
||||
|
@ -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";
|
||||
|
Loading…
Reference in New Issue
Block a user