File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ export async function decrypt(
3232 this : NDKEvent ,
3333 sender ?: NDKUser ,
3434 signer ?: NDKSigner ,
35- type : ENCRYPTION_SCHEMES = DEFAULT_ENCRYPTION_SCHEME
35+ type ? : ENCRYPTION_SCHEMES
3636) : Promise < void > {
3737 if ( ! this . ndk ) throw new Error ( "No NDK instance found!" ) ;
3838 if ( ! signer ) {
@@ -43,5 +43,10 @@ export async function decrypt(
4343 sender = this . author ;
4444 }
4545
46+ // if type is not set, check if this looks like nip04
47+ if ( ! type ) {
48+ type = this . content . match ( / \? i v = / ) ? 'nip04' : 'nip44' ;
49+ }
50+
4651 this . content = ( await signer ?. decrypt ( sender , this . content , type ) ) as string ;
4752}
Original file line number Diff line number Diff line change @@ -256,7 +256,6 @@ declare global {
256256 decrypt ( senderHexPubKey : string , value : string ) : Promise < string > ;
257257 } ;
258258 nip44 ?: Nip44 ;
259- } ;
260259 } ;
261260 }
262261}
You can’t perform that action at this time.
0 commit comments