mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-01-24 19:03:12 +00:00
* chore: upgrade libp2p to v2 and related deps * chore: fix ENR * chore(core): remove CustomEvent polyfill import * chore: `peer-id-factory` has been removed * chore(discovery): fix local-cache & remove CustomEvent imports * chore(sdk): update config * chore(tests): update tests without peer-id-factory * fix: spec tests * chore: fix test * chore: upgrade dataset-core * chore: upgrade libp2p and stale references * chore: upgrade playwright * chore: rm console log * fix: lock
14 lines
483 B
TypeScript
14 lines
483 B
TypeScript
import { publicKeyFromRaw } from "@libp2p/crypto/keys";
|
|
import { type PeerId } from "@libp2p/interface";
|
|
import { peerIdFromPublicKey } from "@libp2p/peer-id";
|
|
|
|
export const ERR_TYPE_NOT_IMPLEMENTED = "Keypair type not implemented";
|
|
|
|
export function createPeerIdFromPublicKey(publicKey: Uint8Array): PeerId {
|
|
const pubKey = publicKeyFromRaw(publicKey);
|
|
if (pubKey.type !== "secp256k1") {
|
|
throw new Error(ERR_TYPE_NOT_IMPLEMENTED);
|
|
}
|
|
return peerIdFromPublicKey(pubKey);
|
|
}
|