Add sign timeout to thunk
This commit is contained in:
@@ -20,8 +20,11 @@ import { makeEvent } from '@welshman/util'
|
||||
import { ISigner, Nip01Signer, makeSecret } from '@welshman/signer'
|
||||
|
||||
const signer: ISigner = new Nip01Signer(makeSecret())
|
||||
const options = {
|
||||
signal: AbortSignal.timeout(10_000),
|
||||
}
|
||||
|
||||
signer.sign(makeEvent(1)).then(signedEvent => console.log(signedEvent))
|
||||
signer.sign(makeEvent(1), options).then(signedEvent => console.log(signedEvent))
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -5,9 +5,15 @@ It includes methods for signing messages, verifying signatures, and encrypting/d
|
||||
|
||||
|
||||
```typescript
|
||||
export type SignOptions = {
|
||||
signal?: AbortSignal
|
||||
}
|
||||
|
||||
export type SignWithOptions = (event: StampedEvent, options?: SignOptions) => Promise<SignedEvent>
|
||||
|
||||
interface ISigner {
|
||||
// Core signing functionality
|
||||
sign: (event: StampedEvent) => Promise<SignedEvent>
|
||||
sign: SignWithOptions
|
||||
getPubkey: () => Promise<string>
|
||||
|
||||
// Encryption capabilities
|
||||
|
||||
@@ -8,7 +8,7 @@ class Nip01Signer implements ISigner {
|
||||
constructor(private secret: string)
|
||||
|
||||
// ISigner implementation
|
||||
sign: (event: StampedEvent) => Promise<SignedEvent>
|
||||
sign: SignWithOptions
|
||||
getPubkey: () => Promise<string>
|
||||
nip04: { encrypt, decrypt }
|
||||
nip44: { encrypt, decrypt }
|
||||
|
||||
@@ -55,7 +55,7 @@ class Nip55Signer implements ISigner {
|
||||
constructor(private secret: string)
|
||||
|
||||
// ISigner implementation
|
||||
sign: (event: StampedEvent) => Promise<SignedEvent>
|
||||
sign: SignWithOptions
|
||||
getPubkey: () => Promise<string>
|
||||
nip04: { encrypt, decrypt }
|
||||
nip44: { encrypt, decrypt }
|
||||
|
||||
Reference in New Issue
Block a user