Make SIWE session statement optional

Signed-off-by: Sebastian Martinez <sebastinez@me.com>
This commit is contained in:
Sebastian Martinez
2022-05-18 15:45:47 +02:00
committed by Alexis Sellier
parent c56a949778
commit a89e792aed
2 changed files with 6 additions and 8 deletions
+1 -1
View File
@@ -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 }));
+5 -7
View File
@@ -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 });