add Nostr-login package #217

Merged
enes merged 20 commits from nostr-login-9-30 into staging 2024-10-09 08:54:33 +00:00
5 changed files with 14 additions and 14 deletions
Showing only changes of commit 6c5ed3a69c - Show all commits

View File

@ -58,7 +58,7 @@ export class NostrController extends EventEmitter {
const context = new LoginMethodContext(loginMethod)
// Handle decryption
return await context.nip44EDecrypt(sender, content)
return await context.nip44Decrypt(sender, content)
}
/**
@ -94,7 +94,7 @@ export class NostrController extends EventEmitter {
const loginMethod = (store.getState().auth as AuthState).loginMethod
const context = new LoginMethodContext(loginMethod)
return await context.nip04EDecrypt(sender, content)
return await context.nip04Decrypt(sender, content)
}
/**

View File

@ -28,7 +28,7 @@ export class NostrLoginStrategy extends LoginMethodStrategy {
return encrypted
}
async nip04EDecrypt(sender: string, content: string): Promise<string> {
async nip04Decrypt(sender: string, content: string): Promise<string> {
if (!this.nostr.nip04) {
throw new Error(
`Your nostr extension does not support nip04 encryption & decryption`
@ -51,7 +51,7 @@ export class NostrLoginStrategy extends LoginMethodStrategy {
return encrypted as string
}
async nip44EDecrypt(sender: string, content: string): Promise<string> {
async nip44Decrypt(sender: string, content: string): Promise<string> {
if (!this.nostr.nip44) {
throw new Error(
`Your nostr extension does not support nip44 encryption & decryption`

View File

@ -29,7 +29,7 @@ export class PrivateKeyStrategy extends LoginMethodStrategy {
return encrypted
}
async nip04EDecrypt(sender: string, content: string): Promise<string> {
async nip04Decrypt(sender: string, content: string): Promise<string> {
const keys = (store.getState().auth as AuthState).keyPair
if (!keys) {
@ -71,7 +71,7 @@ export class PrivateKeyStrategy extends LoginMethodStrategy {
return encrypted
}
async nip44EDecrypt(sender: string, content: string): Promise<string> {
async nip44Decrypt(sender: string, content: string): Promise<string> {
const keys = (store.getState().auth as AuthState).keyPair
// Check if the private and public key pair is available.

View File

@ -28,14 +28,14 @@ export class LoginMethodContext implements LoginMethodOperations {
nip04Encrypt(receiver: string, content: string): Promise<string> {
return this.strategy.nip04Encrypt(receiver, content)
}
nip04EDecrypt(sender: string, content: string): Promise<string> {
return this.strategy.nip04EDecrypt(sender, content)
nip04Decrypt(sender: string, content: string): Promise<string> {
return this.strategy.nip04Decrypt(sender, content)
}
nip44Encrypt(receiver: string, content: string): Promise<string> {
return this.strategy.nip44Encrypt(receiver, content)
}
nip44EDecrypt(sender: string, content: string): Promise<string> {
return this.strategy.nip44EDecrypt(sender, content)
nip44Decrypt(sender: string, content: string): Promise<string> {
return this.strategy.nip44Decrypt(sender, content)
}
signEvent(event: UnsignedEvent | EventTemplate): Promise<SignedEvent> {
return this.strategy.signEvent(event)

View File

@ -4,9 +4,9 @@ import { SignedEvent } from '../../types/nostr'
export interface LoginMethodOperations {
nip04Encrypt(receiver: string, content: string): Promise<string>
nip04EDecrypt(sender: string, content: string): Promise<string>
nip04Decrypt(sender: string, content: string): Promise<string>
nip44Encrypt(receiver: string, content: string): Promise<string>
nip44EDecrypt(sender: string, content: string): Promise<string>
nip44Decrypt(sender: string, content: string): Promise<string>
signEvent(event: UnsignedEvent | EventTemplate): Promise<SignedEvent>
}
@ -14,13 +14,13 @@ export class LoginMethodStrategy implements LoginMethodOperations {
async nip04Encrypt(_receiver: string, _content: string): Promise<string> {
throw new Error('Login method strategy is undefined')
}
async nip04EDecrypt(_sender: string, _content: string): Promise<string> {
async nip04Decrypt(_sender: string, _content: string): Promise<string> {
throw new Error('Login method strategy is undefined')
}
async nip44Encrypt(_receiver: string, _content: string): Promise<string> {
throw new Error('Login method strategy is undefined')
}
async nip44EDecrypt(_sender: string, _content: string): Promise<string> {
async nip44Decrypt(_sender: string, _content: string): Promise<string> {
throw new Error('Login method strategy is undefined')
}
async signEvent(_event: UnsignedEvent | EventTemplate): Promise<SignedEvent> {