renlabs-dev / commune-ts

This is a monorepo for the AGIc typescript ecosystem. It uses Turborepo and contains the code for our web apps.
https://www.communeai.org/
5 stars 1 forks source link

Feat: signed sessions #79

Closed gabrielcipriano closed 1 month ago

gabrielcipriano commented 3 months ago

A proposal for signed endpoints, so we have "authentication" at request level

using it on client side example:

import { useCommune } from "@commune-ts/providers/use-commune";
import { signData, createSessionData} from "@commune-ts/api";

const { signHex } = useCommune();

const useStartSession = api.auth.startSession.useMutation();

const handleStartSession = async () => {
  const sessionData = createSessionData(window);
  const signedData = signData(signHex, sessionData);

  const result = await useStartSession.mutateAsync(signedData);

  console.log("token: ", result.token);
  console.log("authenticationType: ", result.authenticationType); // Bearer

  const authorization = `${result.authenticationType} ${result.token}`; // "Bearer <token>"

  // Set the token as authorization header
  // ...
}
cloudflare-workers-and-pages[bot] commented 2 months ago

Deploying commune-wallet with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8558673
Status:🚫  Build failed.

View logs

EdSDR commented 1 month ago

This will be closed since front end integration PR has all the contents of this branch