import { Filter, VerifiedEvent, UnsignedEvent } from "nostr-tools"; import { NostrSubscribe, Unsubscribe } from "./types"; export declare function buildAppKeysFilter(authors?: string | string[]): Filter; export declare function isAppKeysEvent(event: Pick): boolean; /** * Device identity entry - contains only identity information. * identityPubkey serves as the device identifier. * Invite crypto material (ephemeral keys, shared secret) is in separate Invite events. */ export interface DeviceEntry { /** Identity public key - also serves as device identifier */ identityPubkey: string; createdAt: number; } export interface DeviceLabels { deviceLabel?: string; clientLabel?: string; updatedAt: number; } interface DeviceLabelsEntry extends DeviceLabels { identityPubkey: string; } /** * Manages a consolidated list of device invites (kind 30078, d-tag "double-ratchet/app-keys"). * Single atomic event containing all device invites for a user. * Uses union merge strategy for conflict resolution. * * Note: ownerPublicKey is not stored - it's passed to getEvent() when publishing, * and NDK's signer sets the correct pubkey during signing anyway. */ export declare class AppKeys { private devices; private deviceLabels; constructor(devices?: DeviceEntry[], deviceLabels?: DeviceLabelsEntry[]); /** * Creates a new device identity entry. * Note: This only creates the identity entry. The device must separately * create and publish its own Invite event with ephemeral keys. */ createDeviceEntry(identityPubkey: string): DeviceEntry; addDevice(device: DeviceEntry): void; removeDevice(identityPubkey: string): void; getDevice(identityPubkey: string): DeviceEntry | undefined; getAllDevices(): DeviceEntry[]; setDeviceLabels(identityPubkey: string, labels: { deviceLabel?: string; clientLabel?: string; }, updatedAt?: number): void; getDeviceLabels(identityPubkey: string): DeviceLabels | undefined; getAllDeviceLabels(): DeviceLabelsEntry[]; private getEncryptedContent; private loadEncryptedContent; getEvent(ownerPrivateKey?: Uint8Array): UnsignedEvent; static fromEvent(event: VerifiedEvent, ownerPrivateKey?: Uint8Array): AppKeys; serialize(): string; static deserialize(json: string): AppKeys; merge(other: AppKeys): AppKeys; /** * Subscribe to AppKeys events from a user. * Similar to Invite.fromUser pattern. */ static fromUser(user: string, subscribe: NostrSubscribe, onAppKeysList: (appKeys: AppKeys) => void, ownerPrivateKey?: Uint8Array): Unsubscribe; /** * Wait for AppKeys from a user with timeout. * Returns the most recent AppKeys received within the timeout, or null. * Note: Uses the most recent event by created_at, not merging, since * device revocation is determined by absence from the list. */ static waitFor(user: string, subscribe: NostrSubscribe, timeoutMs?: number, ownerPrivateKey?: Uint8Array): Promise; static waitForSnapshot(user: string, subscribe: NostrSubscribe, timeoutMs?: number, ownerPrivateKey?: Uint8Array): Promise<{ appKeys: AppKeys; createdAt: number; } | null>; } export {}; //# sourceMappingURL=AppKeys.d.ts.map