import { VerifiedEvent, UnsignedEvent } from "nostr-tools"; import { NostrSubscribe, Unsubscribe, EncryptFunction, DecryptFunction } from "./types"; import { Session } from "./Session.ts"; export type InvitePurpose = "chat" | "link"; export interface InviteLinkOptions { purpose?: InvitePurpose; ownerPubkey?: string; } /** * Invite is a safe way to exchange session keys and initiate secret sessions. * * It can be shared privately as an URL (e.g. QR code) or published as a Nostr event. * * Even if inviter's or invitee's long-term private key (identity key) and the shared secret (link) is compromised, * forward secrecy is preserved as long as the session keys are not compromised. * * Also make sure to keep the session key safe. */ export declare class Invite { inviterEphemeralPublicKey: string; sharedSecret: string; inviter: string; inviterEphemeralPrivateKey?: Uint8Array | undefined; deviceId?: string | undefined; maxUses?: number | undefined; usedBy: string[]; createdAt: number; purpose?: InvitePurpose | undefined; ownerPubkey?: string | undefined; constructor(inviterEphemeralPublicKey: string, sharedSecret: string, inviter: string, inviterEphemeralPrivateKey?: Uint8Array | undefined, deviceId?: string | undefined, maxUses?: number | undefined, usedBy?: string[], createdAt?: number, purpose?: InvitePurpose | undefined, ownerPubkey?: string | undefined); static createNew(inviter: string, deviceId?: string, maxUses?: number, options?: InviteLinkOptions): Invite; static fromUrl(url: string): Invite; static deserialize(json: string): Invite; static fromEvent(event: VerifiedEvent): Invite; static fromUser(user: string, subscribe: NostrSubscribe, onInvite: (_invite: Invite) => void): Unsubscribe; static waitFor(user: string, subscribe: NostrSubscribe, timeoutMs?: number): Promise; /** * Save Invite as JSON. Includes the inviter's session private key, so don't share this. */ serialize(): string; /** * Invite parameters are in the URL's hash so they are not sent to the server. */ getUrl(root?: string): string; getEvent(): UnsignedEvent; /** * Creates a tombstone event that replaces the invite, signaling device revocation. * The tombstone has the same d-tag but no keys, making it invalid as an invite. */ getDeletionEvent(): UnsignedEvent; /** * Called by the invitee. Accepts the invite and creates a new session with the inviter. * * @param inviteePublicKey - The invitee's identity public key (also serves as device ID) * @param encryptor - The invitee's secret key or a signing/encrypt function * @param ownerPublicKey - The invitee's owner/Nostr identity public key (optional for single-device users) * @returns An object containing the new session and an event to be published * * 1. Inner event: No signature, content encrypted with DH(inviter, invitee). * Purpose: Authenticate invitee. Contains invitee session key and ownerPublicKey. * 2. Envelope: No signature, content encrypted with DH(inviter, random key). * Purpose: Contains inner event. Hides invitee from others who might have the shared Nostr key. * Note: You need to publish the returned event on Nostr using NDK or another Nostr system of your choice, * so the inviter can create the session on their side. */ accept(inviteePublicKey: string, encryptor: Uint8Array | EncryptFunction, ownerPublicKey?: string): Promise<{ session: Session; event: VerifiedEvent; }>; listen(decryptor: Uint8Array | DecryptFunction, nostrSubscribe: NostrSubscribe, onSession: (_session: Session, _identity: string) => void): Unsubscribe; } //# sourceMappingURL=Invite.d.ts.map