import { AppKeys, DeviceEntry, DeviceLabels } from "./AppKeys"; import { Invite } from "./Invite"; import { NostrSubscribe, NostrPublish } from "./types"; import { StorageAdapter } from "./StorageAdapter"; import { SessionManager } from "./SessionManager"; export interface DelegatePayload { identityPubkey: string; deviceLabel?: string; clientLabel?: string; } /** * Options for AppKeysManager (authority for AppKeys) */ export interface AppKeysManagerOptions { nostrPublish: NostrPublish; storage?: StorageAdapter; ownerIdentityKey?: Uint8Array; } /** * Options for DelegateManager (device identity) */ export interface DelegateManagerOptions { nostrSubscribe: NostrSubscribe; nostrPublish: NostrPublish; storage?: StorageAdapter; } /** * AppKeysManager - Authority for AppKeys. * Manages local AppKeys and publishes to relays. * Does NOT have device identity (no Invite, no SessionManager creation). */ export declare class AppKeysManager { private readonly nostrPublish; private readonly storage; private readonly ownerIdentityKey?; private appKeys; private initialized; private readonly storageVersion; private get versionPrefix(); constructor(options: AppKeysManagerOptions); init(): Promise; getAppKeys(): AppKeys | null; getOwnDevices(): DeviceEntry[]; /** * Add a device to the AppKeys. * Only adds identity info - the device publishes its own Invite separately. * This is a local-only operation - call publish() to publish to relays. */ addDevice(payload: DelegatePayload): void; setDeviceLabels(identityPubkey: string, labels: { deviceLabel?: string; clientLabel?: string; }): void; getDeviceLabels(identityPubkey: string): DeviceLabels | undefined; /** * Revoke a device from the AppKeys. * This is a local-only operation - call publish() to publish to relays. */ revokeDevice(identityPubkey: string): void; /** * Publish the current AppKeys to relays. * This is the only way to publish - addDevice/revokeDevice are local-only. */ publish(): Promise; /** * Replace the local AppKeys with the given list and save to storage. * Used for authority transfer - receive list from another device, then call publish(). */ setAppKeys(list: AppKeys): Promise; /** * Cleanup resources. Currently a no-op but kept for API consistency. */ close(): void; private appKeysKey; private loadAppKeys; private saveAppKeys; } /** * DelegateManager - Device identity manager. * ALL devices (including main) use this for their device identity. * Publishes own Invite events, used for SessionManager DH encryption. */ export declare class DelegateManager { private readonly nostrSubscribe; private readonly nostrPublish; private readonly storage; private devicePublicKey; private devicePrivateKey; private invite; private ownerPubkeyFromActivation?; private initialized; private subscriptions; private readonly storageVersion; private get versionPrefix(); constructor(options: DelegateManagerOptions); init(): Promise; /** * Get the registration payload for adding this device to an AppKeysManager. * Must be called after init(). */ getRegistrationPayload(): DelegatePayload; getIdentityPublicKey(): string; getIdentityKey(): Uint8Array; getInvite(): Invite | null; getOwnerPublicKey(): string | null; /** * Publish the current device invite. * Clients should call this only after activation/session-manager setup so * invite responses are observed by the active listener. */ publishInvite(): Promise; /** * Rotate this device's invite - generates new ephemeral keys and shared secret. */ rotateInvite(): Promise; /** * Activate this device with a known owner. * Use this when you know the device has been added (e.g., main device adding itself). * Skips fetching from relay - just stores the owner pubkey. */ activate(ownerPublicKey: string): Promise; /** * Wait for this device to be activated (added to an AppKeys). * Returns the owner's public key once activated. * For delegate devices that don't know the owner ahead of time. */ waitForActivation(timeoutMs?: number): Promise; /** * Check if this device has been revoked from the owner's AppKeys. * @param options.timeoutMs - Timeout for each attempt (default 2000ms) * @param options.retries - Number of retry attempts (default 2) */ isRevoked(options?: { timeoutMs?: number; retries?: number; }): Promise; close(): void; /** * Create a SessionManager for this device. */ createSessionManager(sessionStorage?: StorageAdapter): SessionManager; createRuntimeSessionManager(sessionStorage?: StorageAdapter): SessionManager; private ownerPubkeyKey; private inviteKey; private loadInvite; private saveInvite; private identityPublicKeyKey; private identityPrivateKeyKey; } export { AppKeysManager as ApplicationManager }; export type { AppKeysManagerOptions as ApplicationManagerOptions }; //# sourceMappingURL=AppKeysManager.d.ts.map