Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Make SIWE session statement optional
Sebastian Martinez committed 4 years ago
commit a89e792aed8aa3b8c5ee2f62525b38899ab7ff85
parent c56a9497781b698a36c04729b51ec83317fec21b
2 files changed +6 -8
modified src/session.ts
@@ -314,7 +314,7 @@ export function loadSeedSessions(): { [key: string]: SeedSession } {
    // We only keep the sessions that are still valid, and remove expired ones from `localStorage`.
    // For a session to be valid the expiration time has to be bigger or equal than the current time.
    const activeSessions = Object.fromEntries(Object.entries(siwe).filter(([, value]) => {
-
      return value.expiration_time >= unixTime();
+
      return value.expirationTime >= unixTime();
    }));
    window.localStorage.setItem("siwe", JSON.stringify({ ...activeSessions }));

modified src/siwe.ts
@@ -2,20 +2,19 @@
import { SiweMessage } from "siwe";
import { Request, type Host } from '@app/api';
import type { Config } from "@app/config";
-
import { removePrefix } from "@app/utils";
import { connectSeed } from "@app/session";
import type { Seed } from "@app/base/seeds/Seed";

export interface SeedSession {
  domain: string;
  address: string;
-
  statement: string;
+
  statement?: string;
  uri: string;
  version: string;
-
  chain_id: string;
+
  chainId: string;
  nonce: string;
-
  issued_at: number;
-
  expiration_time: number;
+
  issuedAt: number;
+
  expirationTime: number;
  resources: string[];
}

@@ -26,7 +25,6 @@ export function createSiweMessage(seed: Seed, address: string, nonce: string, co
  const message = new SiweMessage({
    domain: seed.api.host,
    address,
-
    statement: `${seed.api.host} wants you to sign in with Ethereum`,
    uri: window.location.origin,
    nonce,
    version: '1',
@@ -56,7 +54,7 @@ export async function signInWithEthereum(seed: Seed, config: Config): Promise<{
    id: string;
    session: SeedSession;
  } = await new Request(`sessions/${result.id}`, seed.api)
-
    .put({ message, signature: removePrefix(signature) });
+
    .put({ message, signature });

  connectSeed({ id: result.id, session: auth.session });