diff --git a/src/components/Footer/Footer.tsx b/src/components/Footer/Footer.tsx index 17140e4..ead7cec 100644 --- a/src/components/Footer/Footer.tsx +++ b/src/components/Footer/Footer.tsx @@ -121,7 +121,7 @@ export const Footer = () =>
Built by  - + Nostr Dev {' '} 2024. diff --git a/src/pages/nostr/index.tsx b/src/pages/nostr/index.tsx index 5d9467f..4c9bc5e 100644 --- a/src/pages/nostr/index.tsx +++ b/src/pages/nostr/index.tsx @@ -1,3 +1,5 @@ +import { launch as launchNostrLoginDialog } from 'nostr-login' + import { Button, Divider, TextField } from '@mui/material' import { getPublicKey, nip19 } from 'nostr-tools' import { useEffect, useState } from 'react' @@ -424,6 +426,32 @@ export const Nostr = () => { )} + + + + or + ({ @@ -22,6 +24,13 @@ export const updateLoginMethod = ( payload }) +export const updateNostrLoginAuthMethod = ( + payload: NostrLoginAuthMethod | undefined +): UpdateNostrLoginAuthMethod => ({ + type: ActionTypes.UPDATE_NOSTR_LOGIN_AUTH_METHOD, + payload +}) + export const updateKeyPair = (payload: Keys | undefined): UpdateKeyPair => ({ type: ActionTypes.UPDATE_KEYPAIR, payload diff --git a/src/store/auth/reducer.ts b/src/store/auth/reducer.ts index dea4ed5..e87662b 100644 --- a/src/store/auth/reducer.ts +++ b/src/store/auth/reducer.ts @@ -30,6 +30,15 @@ const reducer = ( } } + case ActionTypes.UPDATE_NOSTR_LOGIN_AUTH_METHOD: { + const { payload } = action + + return { + ...state, + nostrLoginAuthMethod: payload + } + } + case ActionTypes.UPDATE_KEYPAIR: { const { payload } = action diff --git a/src/store/auth/types.ts b/src/store/auth/types.ts index a134a7b..d83fa87 100644 --- a/src/store/auth/types.ts +++ b/src/store/auth/types.ts @@ -1,6 +1,14 @@ import * as ActionTypes from '../actionTypes' import { RestoreState, UserLogout } from '../actions' +export enum NostrLoginAuthMethod { + Connect = 'connect', + ReadOnly = 'readOnly', + Extension = 'extension', + Local = 'local', + OTP = 'otp' +} + export enum LoginMethods { extension = 'extension', privateKey = 'privateKey', @@ -17,6 +25,7 @@ export interface AuthState { loggedIn: boolean usersPubkey?: string loginMethod?: LoginMethods + nostrLoginAuthMethod?: NostrLoginAuthMethod keyPair?: Keys nsecBunkerPubkey?: string nsecBunkerRelays?: string[] @@ -32,6 +41,11 @@ export interface UpdateLoginMethod { payload: LoginMethods | undefined } +export interface UpdateNostrLoginAuthMethod { + type: typeof ActionTypes.UPDATE_NOSTR_LOGIN_AUTH_METHOD + payload: NostrLoginAuthMethod | undefined +} + export interface UpdateKeyPair { type: typeof ActionTypes.UPDATE_KEYPAIR payload: Keys | undefined @@ -51,6 +65,7 @@ export type AuthDispatchTypes = | RestoreState | SetAuthState | UpdateLoginMethod + | UpdateNostrLoginAuthMethod | UpdateKeyPair | UpdateNsecBunkerPubkey | UpdateNsecBunkerRelays diff --git a/src/store/metadata/reducer.ts b/src/store/metadata/reducer.ts index 9223ef3..e81d675 100644 --- a/src/store/metadata/reducer.ts +++ b/src/store/metadata/reducer.ts @@ -2,7 +2,15 @@ import * as ActionTypes from '../actionTypes' import { MetadataDispatchTypes } from './types' import { Event } from 'nostr-tools' -const initialState: Event | null = null +const initialState: Event = { + content: '', + created_at: 0, + id: '', + kind: 0, + pubkey: '', + sig: '', + tags: [] +} const reducer = ( state = initialState, diff --git a/src/utils/nostr.ts b/src/utils/nostr.ts index 248f71a..d6be22e 100644 --- a/src/utils/nostr.ts +++ b/src/utils/nostr.ts @@ -426,6 +426,8 @@ export const getUsersAppData = async (): Promise => { // Handle case where the encrypted content is an empty object if (encryptedContent === '{}') { + // Generate ephemeral key pair + // https://docs.sigit.io/#/technical?id=storing-app-data const secret = generateSecretKey() const pubKey = getPublicKey(secret)