Skip to main content

Injection APIs

The injection APIs can be accessed through the global window object when your mini app runs inside Fedi's in-app browser.

WebLN

Provides methods documented in the WebLN Standard

Global Object

// Available as window.webln inside Fedi
interface InjectionWebLNProvider {
isEnabled: boolean
enable(): Promise<void>
getInfo(): Promise<GetInfoResponse>
sendPayment(paymentRequest: string): Promise<SendPaymentResponse>
keysend(args: KeysendArgs): Promise<SendPaymentResponse>
makeInvoice(args: string | number | RequestInvoiceArgs): Promise<RequestInvoiceResponse>
signMessage(message: string): Promise<SignMessageResponse>
verifyMessage(signature: string, message: string): Promise<void>
}

Properties

PropertyTypeDescription
isEnabledbooleanWhether WebLN has been enabled successfully via the webln.enable() method

Methods

SignatureDescription
enable(): Promise<void>Enables all the WebLN methods. [docs]
getInfo(): Promise<GetInfoResponse>Get information about the connected node and what WebLN methods it supports. [docs]
sendPayment(paymentRequest: string): Promise<SendPaymentResponse>Request that the user sends a payment for an invoice. [docs]
keysend(args: KeysendArgs): Promise<SendPaymentResponse>Request the user to send a keysend payment. [docs]
makeInvoice(args: string | number | RequestInvoiceArgs): Promise<RequestInvoiceResponse>Request that the user creates a Bolt11 invoice. [docs]
signMessage(message: string): Promise<SignMessageResponse>Requests that the user signs an arbitrary string message. [docs]
verifyMessage(signature: string, message: string): Promise<void>Opens a view where the user verifies the signature against the raw message. [docs]

Nostr

Provides basic functions to interact with the Nostr Protocol

Global Object

// Available as window.nostr inside Fedi
interface InjectionNostrProvider {
getPublicKey(): Promise<string>
signEvent(event: UnsignedNostrEvent): Promise<SignedNostrEvent>
nip44: {
encrypt(pubkey: string, plaintext: string): Promise<string>
decrypt(pubkey: string, ciphertext: string): Promise<string>
}
nip04: {
encrypt(pubkey: string, plaintext: string): Promise<string>
decrypt(pubkey: string, ciphertext: string): Promise<string>
}
}

Methods

SignatureDescription
getPublicKey(): Promise<string>Returns the user's Nostr Public Key
signEvent(event: UnsignedNostrEvent): Promise<SignedNostrEvent>Requests that the user sign a Nostr event
nip44.encrypt(pubkey, plaintext): Promise<string>NIP-44 encryption (recommended)
nip44.decrypt(pubkey, ciphertext): Promise<string>NIP-44 decryption (recommended)
nip04.encrypt(pubkey, plaintext): Promise<string>NIP-04 encryption (legacy)
nip04.decrypt(pubkey, ciphertext): Promise<string>NIP-04 decryption (legacy)

Fedi

Provides functions to interact with the Fedi App

Global Object

// Available as window.fedi inside Fedi
interface InjectionFediAPIProvider {
version: number
generateEcash(args: GenerateEcashArgs): Promise<{ notes: string }>
receiveEcash(notes: string): Promise<{ msats: number }>
getAuthenticatedMember(): Promise<{ id: string; username: string }>
getCurrencyCode(): Promise<SupportedCurrency>
getLanguageCode(): Promise<string>
}

Properties

PropertyTypeDescription
versionnumberThe Fedi API version

Methods

SignatureDescription
generateEcash(args: GenerateEcashArgs): Promise<{ notes: string }>Generates Ecash notes
receiveEcash(notes: string): Promise<{ msats: number }>Claims Ecash notes
getAuthenticatedMember(): Promise<{ id, username }>Returns the ID and username of the current Fedi member
getCurrencyCode(): Promise<SupportedCurrency>Returns the user's selected three-letter currency code
getLanguageCode(): Promise<string>Returns the user's selected two-letter language code