avo-inspector
Version:
[](https://badge.fury.io/js/avo-inspector)
59 lines (58 loc) • 1.84 kB
TypeScript
/**
* AvoStreamId manages an ephemeral stream identifier.
*
* The stream ID is generated and stored persistently, but resets after:
* - 4 hours of total age AND
* - 2 hours of idle time (no activity)
*
* This ensures the ID is truly anonymous by not persisting indefinitely,
* while still maintaining session continuity during active usage.
*/
export declare class AvoStreamId {
private static _streamId;
private static _createdAt;
private static _lastActivityAt;
private static readonly MAX_AGE_MS;
private static readonly IDLE_THRESHOLD_MS;
private static readonly STREAM_ID_KEY;
private static readonly CREATED_AT_KEY;
private static readonly LAST_ACTIVITY_KEY;
/**
* Get the stream ID. If it doesn't exist or has expired, generates a new one.
* Returns "unknown" if storage is not initialized.
*/
static get streamId(): string;
/**
* Check if the stream ID should be reset based on age and idle time.
*/
private static shouldReset;
/**
* Load stream ID and timestamps from storage into cache.
*/
private static loadFromStorage;
/**
* Generate a new stream ID and store it with timestamps.
*/
private static generateAndStoreNew;
/**
* Update the last activity timestamp.
*/
private static updateLastActivity;
/**
* The storage key used to persist the stream ID.
*/
static get storageKey(): string;
/**
* The storage key for created at timestamp.
*/
static get createdAtKey(): string;
/**
* The storage key for last activity timestamp.
*/
static get lastActivityKey(): string;
/**
* Clear the cached stream ID. The next access will reload from storage.
* This is primarily useful for testing.
*/
static clearCache(): void;
}