mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2024-12-04 18:00: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
|
```html
|
||||||
<head>
|
<head>
|
||||||
<title>Cool App</title>
|
<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">
|
<script type="module">
|
||||||
import {
|
import {
|
||||||
Fluence,
|
Fluence,
|
||||||
|
@ -90,10 +90,6 @@ export class ClientPeer extends FluencePeer implements IFluenceClient {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPeerSecretKey(): Uint8Array {
|
|
||||||
return this.keyPair.toEd25519PrivateKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
connectionState: ConnectionState = "disconnected";
|
connectionState: ConnectionState = "disconnected";
|
||||||
connectionStateChangeHandler: (state: ConnectionState) => void = () => {};
|
connectionStateChangeHandler: (state: ConnectionState) => void = () => {};
|
||||||
|
|
||||||
|
@ -21,29 +21,25 @@ import { z } from "zod";
|
|||||||
*/
|
*/
|
||||||
export type PeerIdB58 = string;
|
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 = {
|
export type Relay = z.infer<typeof relaySchema>;
|
||||||
peerId: PeerIdB58;
|
|
||||||
multiaddr: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const relaySchema = z.union([
|
export const relayOptionsSchema = z.union([z.string(), relaySchema]);
|
||||||
z.string(),
|
|
||||||
z.object({
|
|
||||||
peerId: z.string(),
|
|
||||||
multiaddr: z.string(),
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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:
|
* Can be in the form of:
|
||||||
* - string: multiaddr in string format
|
* - 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
|
* Fluence Peer's key pair types
|
||||||
@ -102,11 +98,6 @@ export interface IFluenceClient {
|
|||||||
handler: (state: ConnectionState) => void,
|
handler: (state: ConnectionState) => void,
|
||||||
): ConnectionState;
|
): ConnectionState;
|
||||||
|
|
||||||
/**
|
|
||||||
* Return peer's secret key as byte array.
|
|
||||||
*/
|
|
||||||
getPeerSecretKey(): Uint8Array;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return peer's public key as a base58 string (multihash/CIDv0).
|
* Return peer's public key as a base58 string (multihash/CIDv0).
|
||||||
*/
|
*/
|
||||||
|
@ -22,7 +22,7 @@ import {
|
|||||||
configSchema,
|
configSchema,
|
||||||
ConnectionState,
|
ConnectionState,
|
||||||
RelayOptions,
|
RelayOptions,
|
||||||
relaySchema,
|
relayOptionsSchema,
|
||||||
} from "./clientPeer/types.js";
|
} from "./clientPeer/types.js";
|
||||||
import { callAquaFunction } from "./compilerSupport/callFunction.js";
|
import { callAquaFunction } from "./compilerSupport/callFunction.js";
|
||||||
import { registerService } from "./compilerSupport/registerService.js";
|
import { registerService } from "./compilerSupport/registerService.js";
|
||||||
@ -36,7 +36,7 @@ const createClient = async (
|
|||||||
config: ClientConfig = {},
|
config: ClientConfig = {},
|
||||||
): Promise<ClientPeer> => {
|
): Promise<ClientPeer> => {
|
||||||
try {
|
try {
|
||||||
relay = relaySchema.parse(relay);
|
relay = relayOptionsSchema.parse(relay);
|
||||||
config = configSchema.parse(config);
|
config = configSchema.parse(config);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof ZodError) {
|
if (e instanceof ZodError) {
|
||||||
@ -125,6 +125,7 @@ export type {
|
|||||||
ClientConfig,
|
ClientConfig,
|
||||||
IFluenceClient,
|
IFluenceClient,
|
||||||
ConnectionState,
|
ConnectionState,
|
||||||
|
Relay,
|
||||||
RelayOptions,
|
RelayOptions,
|
||||||
KeyPairOptions,
|
KeyPairOptions,
|
||||||
} from "./clientPeer/types.js";
|
} from "./clientPeer/types.js";
|
||||||
|
Loading…
Reference in New Issue
Block a user