Skip to content

Commit

Permalink
remove js-client
Browse files Browse the repository at this point in the history
  • Loading branch information
shamsartem committed Dec 20, 2024
1 parent 1e1cf9f commit d77b67c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1,220 deletions.
3 changes: 2 additions & 1 deletion packages/cli/package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@
},
"dependencies": {
"@fluencelabs/deal-ts-clients": "0.22.1",
"@fluencelabs/js-client": "0.9.0",
"@kubernetes/client-node": "github:fluencelabs/kubernetes-client-javascript#e72ee00a52fec4eb4a8327632895d888ee504f4d",
"@libp2p/crypto": "4.0.1",
"@libp2p/peer-id-factory": "4.0.5",
"@mswjs/interceptors": "0.29.1",
"@oclif/color": "1.0.13",
"@oclif/core": "4.0.29",
Expand Down
14 changes: 11 additions & 3 deletions packages/cli/package/src/lib/helpers/getPeerIdFromSecretKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@
import { base64ToUint8Array } from "../keyPairs.js";

export async function getPeerIdFromSecretKey(secretKey: string) {
const { KeyPair } = await import("@fluencelabs/js-client");
const keyPair = await KeyPair.fromEd25519SK(base64ToUint8Array(secretKey));
return keyPair.getPeerId();
const { generateKeyPairFromSeed } = await import("@libp2p/crypto/keys");
const { createFromPrivKey } = await import("@libp2p/peer-id-factory");

const key = await generateKeyPairFromSeed(
"Ed25519",
base64ToUint8Array(secretKey),
256,
);

// eslint-disable-next-line no-restricted-syntax
return (await createFromPrivKey(key)).toString();
}
9 changes: 5 additions & 4 deletions packages/cli/package/src/lib/keyPairs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ export async function genSecretKeyOrReturnExisting(name: string) {
}

async function genSecretKeyString(): Promise<string> {
const { KeyPair } = await import("@fluencelabs/js-client");
const keyPair = await KeyPair.randomEd25519();
const privateKey = keyPair.toEd25519PrivateKey();
return bufferToBase64(Buffer.from(privateKey));
const { generateKeyPair } = await import("@libp2p/crypto/keys");

return bufferToBase64(
Buffer.from((await generateKeyPair("Ed25519")).marshal().subarray(0, 32)),
);
}

export function base64ToUint8Array(base64: string) {
Expand Down
Loading

0 comments on commit d77b67c

Please sign in to comment.