Update docs

This commit is contained in:
Jon Staab
2025-09-30 09:39:11 -07:00
parent 4a0d4c9b85
commit b417525cd3
3 changed files with 84 additions and 30 deletions
+8 -5
View File
@@ -47,19 +47,22 @@ export declare const makeBlossomAuthEvent: (opts: BlossomAuthEventOpts) => Event
export declare const buildBlobUrl: (server: string, sha256: string, extension?: string) => string
// Checks if a blob exists on server
export declare const checkBlobExists: (server: string, sha256: string, options?: { authEvent?: SignedEvent }) => Promise<{exists: boolean; size?: number}>
export declare const checkBlobExists: (server: string, sha256: string, options?: { headers?: Record<string, string>; authEvent?: SignedEvent }) => Promise<{exists: boolean; size?: number}>
// Downloads blob from server
export declare const getBlob: (server: string, sha256: string, options?: { authEvent?: SignedEvent; range?: {start: number; end?: number} }) => Promise<Response>
export declare const getBlob: (server: string, sha256: string, options?: { headers?: Record<string, string>; authEvent?: SignedEvent; range?: {start: number; end?: number} }) => Promise<Response>
// Checks if uploads are allowed (HEAD request to /upload)
export declare const canUploadBlob: (server: string, options?: { headers?: Record<string, string>; authEvent?: SignedEvent }) => Promise<Response>
// Uploads blob to server
export declare const uploadBlob: (server: string, blob: Blob | ArrayBuffer, options?: { authEvent?: SignedEvent }) => Promise<Response>
export declare const uploadBlob: (server: string, blob: Blob | ArrayBuffer, options?: { headers?: Record<string, string>; authEvent?: SignedEvent }) => Promise<Response>
// Deletes blob from server
export declare const deleteBlob: (server: string, sha256: string, options?: { authEvent?: SignedEvent }) => Promise<Response>
export declare const deleteBlob: (server: string, sha256: string, options?: { headers?: Record<string, string>; authEvent?: SignedEvent }) => Promise<Response>
// Lists blobs for a pubkey
export declare const listBlobs: (server: string, pubkey: string, options?: { authEvent?: SignedEvent; since?: number; until?: number }) => Promise<Response>
export declare const listBlobs: (server: string, pubkey: string, options?: { headers?: Record<string, string>; authEvent?: SignedEvent; since?: number; until?: number }) => Promise<Response>
```
## File Encryption
+76
View File
@@ -0,0 +1,76 @@
# Wallet
Types and utilities for working with Lightning wallet integrations in Nostr applications.
## Types
```typescript
export enum WalletType {
WebLN = "webln",
NWC = "nwc",
}
export type WebLNInfo = {
enabled: boolean
}
export type NWCInfo = {
pubkey: string
relay: string
secret: string
}
export type WebLNWallet = {
type: WalletType.WebLN
info: WebLNInfo
}
export type NWCWallet = {
type: WalletType.NWC
info: NWCInfo
}
export type Wallet = WebLNWallet | NWCWallet
```
## Type Guards
```typescript
// Check if a wallet is a WebLN wallet
export declare const isWebLNWallet: (wallet: Wallet) => wallet is WebLNWallet
// Check if a wallet is a Nostr Wallet Connect wallet
export declare const isNWCWallet: (wallet: Wallet) => wallet is NWCWallet
```
## Usage
```typescript
import { Wallet, WalletType, isWebLNWallet, isNWCWallet } from '@welshman/util'
function handleWallet(wallet: Wallet) {
if (isWebLNWallet(wallet)) {
// TypeScript knows wallet.info is WebLNInfo
console.log('WebLN enabled:', wallet.info.enabled)
} else if (isNWCWallet(wallet)) {
// TypeScript knows wallet.info is NWCInfo
console.log('NWC relay:', wallet.info.relay)
}
}
// Create a WebLN wallet
const weblnWallet: Wallet = {
type: WalletType.WebLN,
info: { enabled: true }
}
// Create an NWC wallet
const nwcWallet: Wallet = {
type: WalletType.NWC,
info: {
pubkey: "...",
relay: "wss://relay.example.com",
secret: "..."
}
}
```