I want to perform a mutation to create a post. When I try to run it, I get the error Error: Can not verify signature for commit bagc...rmza: Capability does not have appropriate permissions to update this Stream
.
My mutation query function:
const createPost = async (title: string, text: string) => {
try {
if (composeClient.did !== undefined) {
const post = await composeClient.executeQuery(`
mutation {
createPost(input: {
content: {
title: "${title}"
text: "${text}"
created: "${new Date().toISOString()}"
}
}) {
document {
id
title
text
created
}
}
}
`);
console.log("created", post);
}
throw new Error("No user is autheticated");
} catch (e: any) {
console.log("Error", e.messagae);
}
};
My userAuth method for connecting using metamask
const composeClient = new ComposeClient({
ceramic: "http://localhost:7007",
definition: definition as RuntimeCompositeDefinition,
});
const ceramic = new CeramicClient("http://localhost:7007");
const authUserSession = async () => {
// Check if user session already in storage
const sessionStr = localStorage.getItem("ceramic:eth_did");
let session;
if (sessionStr) {
session = await DIDSession.fromSession(sessionStr);
setUserSession(session);
console.log("succesfully gotten session");
}
if (!session || (session.hasSession && session.isExpired)) {
// We enable the ethereum provider to get the user's addresses.
const ethProvider = (window as any).ethereum;
// request ethereum accounts.
const addresses = await ethProvider.enable({
method: "eth_requestAccounts",
});
const accountId = await getAccountId(ethProvider, addresses[0]);
const authMethod = await EthereumWebAuth.getAuthMethod(
ethProvider,
accountId
);
session = await DIDSession.authorize(authMethod, {
resources: composeClient.resources,
});
setUserSession(session);
console.log("succesfully gotten session");
// Set the session in localStorage.
localStorage.setItem("ceramic:eth_did", session.serialize());
}
// Set our Ceramic DID to be our session DID.
composeClient.setDID(session.did);
ceramic.did = session.did;
console.log("ceramic", ceramic)
return;
};
My dependencies
"dependencies": {
"@ceramicnetwork/http-client": "^2.23.0",
"@composedb/client": "^0.4.4",
"@composedb/types": "^0.4.4",
"@didtools/pkh-ethereum": "^0.3.0",
"did-session": "^2.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@composedb/devtools": "^0.4.4",
"@composedb/devtools-node": "^0.4.4",
"@didtools/cacao": "^2.0.0",
"@types/react": "^18.0.37",
"@types/react-dom": "^18.0.11",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"@vitejs/plugin-react": "^4.0.0",
"eslint": "^8.38.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.3.4",
"typescript": "^5.0.2",
"vite": "^4.3.9"
}
The versions of my cli
ceramic-cli: 2.31.0
@composedb/cli/0.4.5 darwin-arm64 node-v20.2.0
I do not know if this is worth mentioning but i always downgrade my node version to 18.16.0 to get my ceramic node to run.