import { encodeDIDWithLit, Secp256k1ProviderWithLit, } from "key-did-provider-secp256k1-with-lit"; import { CeramicClient } from "@ceramicnetwork/http-client"; import { TileDocument } from "@ceramicnetwork/stream-tile"; import { getResolver } from "key-did-resolver"; import { DID } from "dids"; const litActionCode = ` const go = async () => { // this is the string "Hello World" for testing const toSign = [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]; // this requests a signature share from the Lit Node // the signature share will be automatically returned in the HTTP response from the node const sigShare = await LitActions.signEcdsa({ toSign, publicKey , sigName }); }; go();` export async function keyTest() { console.log('-------> start of keyTest') const ceramic: any = new CeramicClient("http://localhost:7007"); // -- get your encode did with your PKP public key const encodedDID = await encodeDIDWithLit({ pkpPublicKey: "036e8c904562e22b63ac4eb035937bedf41a607235d2f0d5d5298e8d6b3a78cb48", }); // -- static lit action code hosted on https://ipfs.io/ipfs/QmYrfiMf6TDuU3NiTbZANiELNBCyn2f66Zok3gEuzRTYmL const provider = new Secp256k1ProviderWithLit({ did: encodedDID, // ipfsId: "QmWu4Z3j7jLP4k9XknzqCuw2thDT1z41xZcAdVjiA8FHxv", litCode: litActionCode }); const did = new DID({provider, resolver: getResolver()}); // -- authenticate await did.authenticate(); ceramic.did = did; console.log("DID:", did); // -- write to ceramic stream const doc = await TileDocument.create(ceramic, "Hola hola ¿Cómo estás?"); console.log("Doc/StreamID:", doc.id.toString()); // -- read a ceramic stream var loadDoc = await TileDocument.load(ceramic, doc.id.toString()); console.log("Specific doc:", loadDoc.content); }