applesauce-signers 0.0.0-next-20250526151506 → 0.0.0-next-20250606170247
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -17,9 +17,14 @@ export declare class PasswordSigner implements Nip07Interface {
|
|
|
17
17
|
constructor();
|
|
18
18
|
unlockPromise?: Deferred<void>;
|
|
19
19
|
protected requestUnlock(): Deferred<void> | undefined;
|
|
20
|
+
/** Sets the ncryptsec from the key and password */
|
|
20
21
|
setPassword(password: string): Promise<void>;
|
|
22
|
+
/** Tests if the provided password is correct by decrypting the ncryptsec */
|
|
21
23
|
testPassword(password: string): Promise<void>;
|
|
24
|
+
/** Unlocks the signer by decrypting the ncryptsec using the provided password */
|
|
22
25
|
unlock(password: string): Promise<void>;
|
|
26
|
+
/** Locks the signer by removing the unencrypted key from memory */
|
|
27
|
+
lock(): void;
|
|
23
28
|
getPublicKey(): Promise<string>;
|
|
24
29
|
signEvent(event: EventTemplate): Promise<import("nostr-tools").VerifiedEvent>;
|
|
25
30
|
nip04Encrypt(pubkey: string, plaintext: string): Promise<string>;
|
|
@@ -30,11 +30,13 @@ export class PasswordSigner {
|
|
|
30
30
|
this.unlockPromise = p;
|
|
31
31
|
return p;
|
|
32
32
|
}
|
|
33
|
+
/** Sets the ncryptsec from the key and password */
|
|
33
34
|
async setPassword(password) {
|
|
34
35
|
if (!this.key)
|
|
35
36
|
throw new Error("Cant set password until unlocked");
|
|
36
37
|
this.ncryptsec = encrypt(this.key, password);
|
|
37
38
|
}
|
|
39
|
+
/** Tests if the provided password is correct by decrypting the ncryptsec */
|
|
38
40
|
async testPassword(password) {
|
|
39
41
|
if (this.ncryptsec) {
|
|
40
42
|
const key = decrypt(this.ncryptsec, password);
|
|
@@ -44,6 +46,7 @@ export class PasswordSigner {
|
|
|
44
46
|
else
|
|
45
47
|
throw new Error("Missing ncryptsec");
|
|
46
48
|
}
|
|
49
|
+
/** Unlocks the signer by decrypting the ncryptsec using the provided password */
|
|
47
50
|
async unlock(password) {
|
|
48
51
|
if (this.key)
|
|
49
52
|
return;
|
|
@@ -55,6 +58,10 @@ export class PasswordSigner {
|
|
|
55
58
|
else
|
|
56
59
|
throw new Error("Missing ncryptsec");
|
|
57
60
|
}
|
|
61
|
+
/** Locks the signer by removing the unencrypted key from memory */
|
|
62
|
+
lock() {
|
|
63
|
+
this.key = null;
|
|
64
|
+
}
|
|
58
65
|
// public methods
|
|
59
66
|
async getPublicKey() {
|
|
60
67
|
await this.requestUnlock();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "applesauce-signers",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20250606170247",
|
|
4
4
|
"description": "Signer classes for applesauce",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@noble/hashes": "^1.7.1",
|
|
37
37
|
"@noble/secp256k1": "^1.7.1",
|
|
38
38
|
"@scure/base": "^1.2.4",
|
|
39
|
-
"applesauce-core": "0.0.0-next-
|
|
39
|
+
"applesauce-core": "0.0.0-next-20250606170247",
|
|
40
40
|
"debug": "^4.4.0",
|
|
41
41
|
"nanoid": "^5.0.9",
|
|
42
42
|
"nostr-tools": "^2.13"
|