Skip to content

Commit d40ddd5

Browse files
committed
fix nip07 bad commit
1 parent 36bdc2e commit d40ddd5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

ndk/src/events/nip04.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff 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(/\?iv=/) ? 'nip04' : 'nip44';
49+
}
50+
4651
this.content = (await signer?.decrypt(sender, this.content, type)) as string;
4752
}

ndk/src/signers/nip07/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ declare global {
256256
decrypt(senderHexPubKey: string, value: string): Promise<string>;
257257
};
258258
nip44?: Nip44;
259-
};
260259
};
261260
}
262261
}

0 commit comments

Comments
 (0)