applesauce-signer
Advanced tools
Comparing version 0.0.0-next-20241213180142 to 0.0.0-next-20241218172722
@@ -1,9 +0,12 @@ | ||
import { EventTemplate, VerifiedEvent } from "nostr-tools"; | ||
import { EventTemplate, NostrEvent } from "nostr-tools"; | ||
export type Nip07Interface = { | ||
getPublicKey: () => Promise<string> | string; | ||
signEvent: (template: EventTemplate) => Promise<VerifiedEvent> | VerifiedEvent; | ||
signEvent: (template: EventTemplate) => Promise<NostrEvent> | NostrEvent; | ||
getRelays?: () => Record<string, { | ||
read: boolean; | ||
write: boolean; | ||
}> | string[]; | ||
}> | Promise<Record<string, { | ||
read: boolean; | ||
write: boolean; | ||
}>>; | ||
nip04?: { | ||
@@ -10,0 +13,0 @@ encrypt: (pubkey: string, plaintext: string) => Promise<string> | string; |
@@ -13,10 +13,10 @@ import { EventTemplate, VerifiedEvent, verifyEvent } from "nostr-tools"; | ||
verifyEvent: typeof verifyEvent; | ||
nip04?: { | ||
nip04: { | ||
encrypt: (pubkey: string, plaintext: string) => Promise<string> | string; | ||
decrypt: (pubkey: string, ciphertext: string) => Promise<string> | string; | ||
} | undefined; | ||
nip44?: { | ||
}; | ||
nip44: { | ||
encrypt: (pubkey: string, plaintext: string) => Promise<string> | string; | ||
decrypt: (pubkey: string, ciphertext: string) => Promise<string> | string; | ||
} | undefined; | ||
}; | ||
constructor(); | ||
@@ -23,0 +23,0 @@ private onVisibilityChange; |
export * from "./amber-clipboard-signer.js"; | ||
export * from "./extension-signer.js"; | ||
export * from "./nostr-connect-signer.js"; | ||
export * from "./password-signer.js"; | ||
export * from "./readonly-signer.js"; | ||
export * from "./serial-port-signer.js"; | ||
export * from "./simple-signer.js"; | ||
export * from "./serial-port-signer.js"; | ||
export * from "./nostr-connect-signer.js"; |
export * from "./amber-clipboard-signer.js"; | ||
export * from "./extension-signer.js"; | ||
export * from "./nostr-connect-signer.js"; | ||
export * from "./password-signer.js"; | ||
export * from "./readonly-signer.js"; | ||
export * from "./serial-port-signer.js"; | ||
export * from "./simple-signer.js"; | ||
export * from "./serial-port-signer.js"; | ||
export * from "./nostr-connect-signer.js"; |
@@ -8,10 +8,10 @@ import { EventTemplate } from "nostr-tools"; | ||
ncryptsec?: string; | ||
nip04?: { | ||
nip04: { | ||
encrypt: (pubkey: string, plaintext: string) => Promise<string> | string; | ||
decrypt: (pubkey: string, ciphertext: string) => Promise<string> | string; | ||
} | undefined; | ||
nip44?: { | ||
}; | ||
nip44: { | ||
encrypt: (pubkey: string, plaintext: string) => Promise<string> | string; | ||
decrypt: (pubkey: string, ciphertext: string) => Promise<string> | string; | ||
} | undefined; | ||
}; | ||
get unlocked(): boolean; | ||
@@ -18,0 +18,0 @@ constructor(); |
@@ -18,6 +18,6 @@ import { EventTemplate, verifyEvent } from "nostr-tools"; | ||
verifyEvent: typeof verifyEvent; | ||
nip04?: { | ||
nip04: { | ||
encrypt: (pubkey: string, plaintext: string) => Promise<string> | string; | ||
decrypt: (pubkey: string, ciphertext: string) => Promise<string> | string; | ||
} | undefined; | ||
}; | ||
constructor(); | ||
@@ -38,6 +38,11 @@ protected lastCommand: Deferred<string> | null; | ||
nip04Decrypt(pubkey: string, data: string): Promise<string>; | ||
/** Returns the public key on the device */ | ||
getPublicKey(): Promise<string>; | ||
/** Sets the secret key used on the device */ | ||
restore(secretKey: Uint8Array): Promise<void>; | ||
/** Requires the device to sign an event */ | ||
signEvent(draft: EventTemplate & { | ||
pubkey?: string; | ||
}): Promise<import("nostr-tools").VerifiedEvent>; | ||
/** Pings to device to see if the connection is open */ | ||
ping(): void; | ||
@@ -50,4 +55,5 @@ static SUPPORTED: boolean; | ||
static METHOD_PUBLIC_KEY: string; | ||
static METHOD_RESTORE: string; | ||
static PUBLIC_METHODS: string[]; | ||
} | ||
export {}; |
/// <reference types="@types/dom-serial" /> | ||
import { getEventHash, verifyEvent } from "nostr-tools"; | ||
import { base64 } from "@scure/base"; | ||
import { randomBytes, hexToBytes } from "@noble/hashes/utils"; | ||
import { randomBytes, hexToBytes, bytesToHex } from "@noble/hashes/utils"; | ||
import { Point } from "@noble/secp256k1"; | ||
@@ -189,2 +189,3 @@ import { createDefer } from "applesauce-core/promise"; | ||
} | ||
/** Returns the public key on the device */ | ||
async getPublicKey() { | ||
@@ -195,2 +196,7 @@ const pubkey = await this.callMethodOnDevice(SerialPortSigner.METHOD_PUBLIC_KEY, []); | ||
} | ||
/** Sets the secret key used on the device */ | ||
async restore(secretKey) { | ||
await this.callMethodOnDevice(SerialPortSigner.METHOD_RESTORE, [bytesToHex(secretKey)]); | ||
} | ||
/** Requires the device to sign an event */ | ||
async signEvent(draft) { | ||
@@ -207,2 +213,3 @@ const pubkey = draft.pubkey || this.pubkey; | ||
} | ||
/** Pings to device to see if the connection is open */ | ||
ping() { | ||
@@ -218,2 +225,3 @@ this.sendCommand(SerialPortSigner.METHOD_PING, [window.location.host]); | ||
static METHOD_PUBLIC_KEY = "/public-key"; | ||
static METHOD_RESTORE = "/restore"; | ||
static PUBLIC_METHODS = [ | ||
@@ -223,3 +231,4 @@ SerialPortSigner.METHOD_PUBLIC_KEY, | ||
SerialPortSigner.METHOD_SHARED_SECRET, | ||
SerialPortSigner.METHOD_RESTORE, | ||
]; | ||
} |
{ | ||
"name": "applesauce-signer", | ||
"version": "0.0.0-next-20241213180142", | ||
"version": "0.0.0-next-20241218172722", | ||
"description": "Signer classes for applesauce", | ||
@@ -35,4 +35,4 @@ "type": "module", | ||
"@types/dom-serial": "^1.0.6", | ||
"applesauce-core": "0.0.0-next-20241213180142", | ||
"applesauce-net": "0.0.0-next-20241213180142", | ||
"applesauce-core": "^0.10.0", | ||
"applesauce-net": "^0.10.0", | ||
"debug": "^4.3.7", | ||
@@ -39,0 +39,0 @@ "nanoid": "^5.0.7", |
50772
25
1221
+ Addedapplesauce-core@0.10.0(transitive)
+ Addedapplesauce-net@0.10.0(transitive)
- Removedapplesauce-core@0.0.0-next-20241213180142(transitive)
- Removedapplesauce-net@0.0.0-next-20241213180142(transitive)
Updatedapplesauce-core@^0.10.0
Updatedapplesauce-net@^0.10.0