applesauce-signers 7.2.0 → 7.3.0
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.
- package/dist/signers/amber-clipboard-signer.d.ts +7 -1
- package/dist/signers/amber-clipboard-signer.js +6 -2
- package/dist/signers/android-native-signer.d.ts +7 -1
- package/dist/signers/android-native-signer.js +6 -2
- package/dist/signers/extension-signer.d.ts +9 -1
- package/dist/signers/extension-signer.js +8 -1
- package/dist/signers/serial-port-signer.d.ts +7 -1
- package/dist/signers/serial-port-signer.js +6 -2
- package/package.json +1 -1
|
@@ -9,6 +9,9 @@ export declare class AmberClipboardSigner implements ISigner {
|
|
|
9
9
|
static SUPPORTED: false | (() => Promise<string>);
|
|
10
10
|
private pendingRequest;
|
|
11
11
|
pubkey?: string;
|
|
12
|
+
/** The default event verifier for new instances */
|
|
13
|
+
static verifyEvent: typeof verifyEvent;
|
|
14
|
+
/** A synchronous method that verifies event hashes and signatures returned by the signer */
|
|
12
15
|
verifyEvent: typeof verifyEvent;
|
|
13
16
|
nip04: {
|
|
14
17
|
encrypt: (pubkey: string, plaintext: string) => Promise<string>;
|
|
@@ -18,7 +21,10 @@ export declare class AmberClipboardSigner implements ISigner {
|
|
|
18
21
|
encrypt: (pubkey: string, plaintext: string) => Promise<string>;
|
|
19
22
|
decrypt: (pubkey: string, ciphertext: string) => Promise<string>;
|
|
20
23
|
};
|
|
21
|
-
constructor(
|
|
24
|
+
constructor(options?: {
|
|
25
|
+
/** A synchronous method that verifies event hashes and signatures returned by the signer */
|
|
26
|
+
verifyEvent?: typeof verifyEvent;
|
|
27
|
+
});
|
|
22
28
|
private onVisibilityChange;
|
|
23
29
|
private intentRequest;
|
|
24
30
|
/** Reject the currently pending request */
|
|
@@ -13,10 +13,14 @@ export class AmberClipboardSigner {
|
|
|
13
13
|
navigator.clipboard.readText;
|
|
14
14
|
pendingRequest = null;
|
|
15
15
|
pubkey;
|
|
16
|
-
|
|
16
|
+
/** The default event verifier for new instances */
|
|
17
|
+
static verifyEvent = verifyEvent;
|
|
18
|
+
/** A synchronous method that verifies event hashes and signatures returned by the signer */
|
|
19
|
+
verifyEvent;
|
|
17
20
|
nip04;
|
|
18
21
|
nip44;
|
|
19
|
-
constructor() {
|
|
22
|
+
constructor(options) {
|
|
23
|
+
this.verifyEvent = options?.verifyEvent ?? AmberClipboardSigner.verifyEvent;
|
|
20
24
|
document.addEventListener("visibilitychange", this.onVisibilityChange);
|
|
21
25
|
this.nip04 = {
|
|
22
26
|
encrypt: this.nip04Encrypt.bind(this),
|
|
@@ -6,6 +6,9 @@ export declare class AndroidNativeSigner implements ISigner {
|
|
|
6
6
|
connected: boolean;
|
|
7
7
|
permissions: Permission[];
|
|
8
8
|
private pubkey;
|
|
9
|
+
/** The default event verifier for new instances */
|
|
10
|
+
static verifyEvent: typeof verifyEvent;
|
|
11
|
+
/** A synchronous method that verifies event hashes and signatures returned by the signer */
|
|
9
12
|
verifyEvent: typeof verifyEvent;
|
|
10
13
|
nip04: {
|
|
11
14
|
encrypt: (pubkey: string, plaintext: string) => Promise<string>;
|
|
@@ -15,7 +18,10 @@ export declare class AndroidNativeSigner implements ISigner {
|
|
|
15
18
|
encrypt: (pubkey: string, plaintext: string) => Promise<string>;
|
|
16
19
|
decrypt: (pubkey: string, ciphertext: string) => Promise<string>;
|
|
17
20
|
};
|
|
18
|
-
constructor(packageName: string, pubkey?: string
|
|
21
|
+
constructor(packageName: string, pubkey?: string, options?: {
|
|
22
|
+
/** A synchronous method that verifies event hashes and signatures returned by the signer */
|
|
23
|
+
verifyEvent?: typeof verifyEvent;
|
|
24
|
+
});
|
|
19
25
|
static getSignerApps(): Promise<AppInfo[]>;
|
|
20
26
|
setup(): Promise<void>;
|
|
21
27
|
getPublicKey(): Promise<string>;
|
|
@@ -6,11 +6,15 @@ export class AndroidNativeSigner {
|
|
|
6
6
|
connected = false;
|
|
7
7
|
permissions = [];
|
|
8
8
|
pubkey = null;
|
|
9
|
-
|
|
9
|
+
/** The default event verifier for new instances */
|
|
10
|
+
static verifyEvent = verifyEvent;
|
|
11
|
+
/** A synchronous method that verifies event hashes and signatures returned by the signer */
|
|
12
|
+
verifyEvent;
|
|
10
13
|
nip04;
|
|
11
14
|
nip44;
|
|
12
|
-
constructor(packageName, pubkey) {
|
|
15
|
+
constructor(packageName, pubkey, options) {
|
|
13
16
|
this.packageName = packageName;
|
|
17
|
+
this.verifyEvent = options?.verifyEvent ?? AndroidNativeSigner.verifyEvent;
|
|
14
18
|
this.pubkey = pubkey ?? null;
|
|
15
19
|
this.nip04 = {
|
|
16
20
|
encrypt: this.nip04Encrypt.bind(this),
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import { EventTemplate, VerifiedEvent } from "applesauce-core/helpers/event";
|
|
1
|
+
import { EventTemplate, VerifiedEvent, verifyEvent } from "applesauce-core/helpers/event";
|
|
2
2
|
import { ISigner } from "../interop.js";
|
|
3
3
|
/** AN error that is throw when the window.nostr extension is missing */
|
|
4
4
|
export declare class ExtensionMissingError extends Error {
|
|
5
5
|
}
|
|
6
6
|
/** A signer that is a proxy for window.nostr */
|
|
7
7
|
export declare class ExtensionSigner implements ISigner {
|
|
8
|
+
/** The default event verifier for new instances */
|
|
9
|
+
static verifyEvent: typeof verifyEvent;
|
|
10
|
+
/** A synchronous method that verifies event hashes and signatures returned by the signer */
|
|
11
|
+
verifyEvent: typeof verifyEvent;
|
|
12
|
+
constructor(options?: {
|
|
13
|
+
/** A synchronous method that verifies event hashes and signatures returned by the signer */
|
|
14
|
+
verifyEvent?: typeof verifyEvent;
|
|
15
|
+
});
|
|
8
16
|
get nip04(): {
|
|
9
17
|
encrypt: (pubkey: string, plaintext: string) => Promise<string>;
|
|
10
18
|
decrypt: (pubkey: string, ciphertext: string) => Promise<string>;
|
|
@@ -5,6 +5,13 @@ export class ExtensionMissingError extends Error {
|
|
|
5
5
|
}
|
|
6
6
|
/** A signer that is a proxy for window.nostr */
|
|
7
7
|
export class ExtensionSigner {
|
|
8
|
+
/** The default event verifier for new instances */
|
|
9
|
+
static verifyEvent = verifyEvent;
|
|
10
|
+
/** A synchronous method that verifies event hashes and signatures returned by the signer */
|
|
11
|
+
verifyEvent;
|
|
12
|
+
constructor(options) {
|
|
13
|
+
this.verifyEvent = options?.verifyEvent ?? ExtensionSigner.verifyEvent;
|
|
14
|
+
}
|
|
8
15
|
get nip04() {
|
|
9
16
|
return window.nostr?.nip04;
|
|
10
17
|
}
|
|
@@ -27,7 +34,7 @@ export class ExtensionSigner {
|
|
|
27
34
|
if (!window.nostr)
|
|
28
35
|
throw new ExtensionMissingError("Signer extension missing");
|
|
29
36
|
const event = await window.nostr.signEvent(template);
|
|
30
|
-
if (!verifyEvent(event))
|
|
37
|
+
if (!this.verifyEvent(event))
|
|
31
38
|
throw new Error("Extension returned an invalid event");
|
|
32
39
|
return event;
|
|
33
40
|
}
|
|
@@ -15,12 +15,18 @@ export declare class SerialPortSigner implements ISigner {
|
|
|
15
15
|
protected writer: WritableStreamDefaultWriter<string> | null;
|
|
16
16
|
pubkey?: string;
|
|
17
17
|
get isConnected(): boolean;
|
|
18
|
+
/** The default event verifier for new instances */
|
|
19
|
+
static verifyEvent: typeof verifyEvent;
|
|
20
|
+
/** A synchronous method that verifies event hashes and signatures returned by the signer */
|
|
18
21
|
verifyEvent: typeof verifyEvent;
|
|
19
22
|
nip04: {
|
|
20
23
|
encrypt: (pubkey: string, plaintext: string) => Promise<string>;
|
|
21
24
|
decrypt: (pubkey: string, ciphertext: string) => Promise<string>;
|
|
22
25
|
};
|
|
23
|
-
constructor(
|
|
26
|
+
constructor(options?: {
|
|
27
|
+
/** A synchronous method that verifies event hashes and signatures returned by the signer */
|
|
28
|
+
verifyEvent?: typeof verifyEvent;
|
|
29
|
+
});
|
|
24
30
|
protected lastCommand: Deferred<string> | null;
|
|
25
31
|
callMethodOnDevice(method: string, params: string[], opts?: DeviceOpts): Promise<string>;
|
|
26
32
|
connectToDevice({ onConnect, onDisconnect, onError, onDone }: DeviceOpts): Promise<void>;
|
|
@@ -26,9 +26,13 @@ export class SerialPortSigner {
|
|
|
26
26
|
get isConnected() {
|
|
27
27
|
return !!this.writer;
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
/** The default event verifier for new instances */
|
|
30
|
+
static verifyEvent = verifyEvent;
|
|
31
|
+
/** A synchronous method that verifies event hashes and signatures returned by the signer */
|
|
32
|
+
verifyEvent;
|
|
30
33
|
nip04;
|
|
31
|
-
constructor() {
|
|
34
|
+
constructor(options) {
|
|
35
|
+
this.verifyEvent = options?.verifyEvent ?? SerialPortSigner.verifyEvent;
|
|
32
36
|
this.nip04 = {
|
|
33
37
|
encrypt: this.nip04Encrypt.bind(this),
|
|
34
38
|
decrypt: this.nip04Decrypt.bind(this),
|