itd-api 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1398,7 +1398,7 @@ interface RawRequestOptions extends RequestOptions {
1398
1398
  }
1399
1399
 
1400
1400
  /** Версия библиотеки. Попадает в `User-Agent`. */
1401
- declare const LIBRARY_VERSION = "0.0.10";
1401
+ declare const LIBRARY_VERSION = "0.0.11";
1402
1402
 
1403
1403
  /** Базовый URL API итд.com. Домен записан в punycode: `итд.com`. */
1404
1404
  declare const DEFAULT_BASE_URL = "https://xn--d1ah4a.com";
@@ -1421,7 +1421,7 @@ declare const DEFAULT_TIMEOUT = 30000;
1421
1421
  * В браузере заголовок не выставляется — `User-Agent` там запрещён к изменению, и среда
1422
1422
  * молча его игнорирует.
1423
1423
  */
1424
- declare const DEFAULT_USER_AGENT = "Mozilla/5.0 (compatible; itd-api/0.0.10; +https://github.com/KiowDev/itd-api)";
1424
+ declare const DEFAULT_USER_AGENT = "Mozilla/5.0 (compatible; itd-api/0.0.11; +https://github.com/KiowDev/itd-api)";
1425
1425
  /** Настройки очереди со всеми значениями по умолчанию. */
1426
1426
  interface ResolvedRateLimitOptions {
1427
1427
  concurrency: number;
@@ -1635,6 +1635,17 @@ interface AuthEvents {
1635
1635
  error: unknown;
1636
1636
  };
1637
1637
  }
1638
+ /** Области аккаунта и конкретной сессии для локального состояния плагинов. */
1639
+ interface AuthIdentity {
1640
+ /** Идентификатор пользователя; отсутствует у непрозрачного или повреждённого токена. */
1641
+ userId?: UserId | undefined;
1642
+ /** Идентификатор серверной сессии; отсутствует у непрозрачного или повреждённого токена. */
1643
+ sessionId?: string | undefined;
1644
+ }
1645
+ interface AuthManagerHooks {
1646
+ /** Вызывается синхронно перед заменой владельца авторизации. */
1647
+ onAccountChange?: (() => void) | undefined;
1648
+ }
1638
1649
  /**
1639
1650
  * Хранит сессию и продлевает её.
1640
1651
  *
@@ -1645,13 +1656,22 @@ interface AuthEvents {
1645
1656
  */
1646
1657
  declare class AuthManager {
1647
1658
  #private;
1648
- constructor(config: AuthConfig, send: RequestHandler, jar: CookieJar);
1659
+ constructor(config: AuthConfig, send: RequestHandler, jar: CookieJar, hooks?: AuthManagerHooks);
1649
1660
  /** Подписка на события авторизации. */
1650
1661
  get on(): Emitter<AuthEvents>['on'];
1651
1662
  /** Подписка на одно срабатывание. */
1652
1663
  get once(): Emitter<AuthEvents>['once'];
1653
- /** Непрозрачная область авторизации; токен и идентификатор пользователя не раскрываются. */
1664
+ /**
1665
+ * Непрозрачная fallback-область авторизации.
1666
+ *
1667
+ * Изолирует состояние плагинов, когда идентичность аккаунта из JWT недоступна (непрозрачный
1668
+ * токен): значение уникально для владельца и сменяется при замене или очистке сессии.
1669
+ */
1654
1670
  getAuthScope(): string;
1671
+ /** Загружает сессию и возвращает идентификаторы аккаунта и сессии для плагинов. */
1672
+ getAuthIdentity(): Promise<AuthIdentity>;
1673
+ /** Идентификаторы аккаунта и сессии без чтения хранилища. @internal */
1674
+ getCurrentAuthIdentity(): AuthIdentity;
1655
1675
  /**
1656
1676
  * Есть ли признак живой refresh-сессии.
1657
1677
  *
@@ -1740,13 +1760,19 @@ interface PluginContext {
1740
1760
  /** Отладочный вывод клиента, если он включён. */
1741
1761
  logger: Logger | undefined;
1742
1762
  /**
1743
- * Непрозрачная область текущей авторизации.
1763
+ * Непрозрачная fallback-область текущей авторизации.
1744
1764
  *
1745
- * Значение уникально для клиента и меняется при замене либо очистке его сессии. Плагин может
1746
- * использовать его только для разделения состояния; идентификатор пользователя и токен в нём
1747
- * не раскрываются.
1765
+ * Нужна плагинам, которые обязаны безопасно изолировать непрозрачный токен. Для объединения
1766
+ * состояния копий одного аккаунта используйте {@link getAuthIdentity}.
1748
1767
  */
1749
1768
  getAuthScope?: (() => string) | undefined;
1769
+ /**
1770
+ * Загружает сессию и возвращает идентификаторы аккаунта и конкретной сессии из JWT.
1771
+ *
1772
+ * Предпочтительнее {@link getAuthScope} для состояния, которое должно объединяться между
1773
+ * несколькими экземплярами клиента одного аккаунта.
1774
+ */
1775
+ getAuthIdentity?: (() => Promise<AuthIdentity>) | undefined;
1750
1776
  /** Добавляет обёртку запроса. Подключённые раньше оказываются снаружи. */
1751
1777
  use(transformer: Transformer): void;
1752
1778
  }
@@ -2104,6 +2130,10 @@ interface RealtimeDeps {
2104
2130
  fetch: typeof fetch;
2105
2131
  /** Общие заголовки клиента для адреса — см. {@link TransportContext.baseHeaders}. */
2106
2132
  baseHeaders: (url: string) => Promise<Headers>;
2133
+ /** Идентификаторы аккаунта и сессии создавшего поток клиента. */
2134
+ getAuthIdentity?: (() => AuthIdentity) | undefined;
2135
+ /** Непрозрачная область авторизации создавшего поток клиента. */
2136
+ getAuthScope?: (() => string) | undefined;
2107
2137
  getToken: () => Promise<string | null>;
2108
2138
  /** Обновляет токен после отказа авторизации. Возвращает `true`, если удалось. */
2109
2139
  refresh: () => Promise<boolean>;
@@ -2140,6 +2170,12 @@ declare class ItdRealtime {
2140
2170
  get status(): RealtimeStatus;
2141
2171
  /** Какой транспорт используется: `sse` или `poll`. */
2142
2172
  get transport(): string;
2173
+ /** Базовый URL клиента, создавшего поток. @internal */
2174
+ get baseUrl(): string;
2175
+ /** Идентификаторы аккаунта и сессии клиента, создавшего поток. @internal */
2176
+ getAuthIdentity(): AuthIdentity | undefined;
2177
+ /** Непрозрачная область авторизации создавшего поток клиента. @internal */
2178
+ getAuthScope(): string | undefined;
2143
2179
  /** Подписывается на событие потока. @returns функция отписки */
2144
2180
  on<K extends keyof RealtimeEvents>(event: K, listener: Listener<RealtimeEvents[K]>): Unsubscribe;
2145
2181
  /** Подписывается на одно срабатывание. */
@@ -4009,7 +4045,8 @@ declare class ItdClient {
4009
4045
  * Создаёт поток уведомлений в реальном времени.
4010
4046
  *
4011
4047
  * Каждый вызов даёт новый независимый поток; обычно он нужен один на приложение.
4012
- * Соединение поднимается методом `connect()` и держится само.
4048
+ * Соединение поднимается методом `connect()` и держится само. Замена авторизации на токен
4049
+ * другого пользователя завершает все потоки клиента; смена только сессии их не затрагивает.
4013
4050
  *
4014
4051
  * @example
4015
4052
  * ```ts
@@ -4818,4 +4855,4 @@ interface RenderSpansOptions {
4818
4855
  */
4819
4856
  declare function renderSpans(content: string, spans?: readonly Span[] | null | undefined, options?: RenderSpansOptions): string;
4820
4857
 
4821
- export { DetectedRuntime as $, ALLOWED_MIME_TYPES as A, BUILT_IN_SERVICES as B, type CaptchaCredentials as C, type ClientHooks as D, type Comment as E, type FileReader as F, CommentBuilder as G, type CommentInput as H, type ItdSession as I, type CommentReplyTo as J, CommentSort as K, type CommentsParams as L, type MultiTokenStorage as M, CommentsResource as N, type CreateCommentInput as O, type CreatePollInput as P, type CreatePostInput as Q, type CreateReportInput as R, type Credentials as S, type TokenStorage as T, type CredentialsAuth as U, DEFAULT_BASE_URL as V, DEFAULT_STATUS_BASE_URL as W, DEFAULT_TIMEOUT as X, DEFAULT_UPLOAD_TIMEOUT as Y, DEFAULT_USER_AGENT as Z, DEVICE_ID_HEADER as _, ItdAccounts as a, type PageState as a$, type DwellEntry as a0, type ErrorContextHook as a1, type FeedParams as a2, FeedTab as a3, type FileInput as a4, FilesResource as a5, type FollowResult as a6, type ForgotPasswordInput as a7, type Hashtag as a8, type HashtagPostsParams as a9, ItdServerError as aA, ItdTimeoutError as aB, ItdValidationError as aC, LIBRARY_VERSION as aD, type LikeResult as aE, LikesVisibility as aF, type Listener as aG, LocalStorageTokenStorage as aH, type Logger as aI, type Loose as aJ, MAX_RECONNECT_ATTEMPTS as aK, MarkupBuilder as aL, type MarkupContent as aM, type MarkupInput as aN, type MarkupSpan as aO, MemoryMultiTokenStorage as aP, MemoryTokenStorage as aQ, type MyProfile as aR, NOTIFICATION_TYPE_ALIASES as aS, type Notification as aT, type NotificationEvent as aU, type NotificationListParams as aV, type NotificationSettings as aW, NotificationType as aX, NotificationsResource as aY, OAuthProvider as aZ, type Page as a_, HashtagsResource as aa, IMAGE_MIME_TYPES as ab, type ImageMimeType as ac, IncidentKind as ad, type InteractionEntry as ae, InteractionType as af, type IsoDate as ag, ItdAbortError as ah, ItdApiError as ai, type ItdApiErrorInit as aj, ItdApiErrorKind as ak, ItdAuthError as al, type ItdBuilder as am, ItdConfigError as an, ItdConflictError as ao, ItdError as ap, ItdErrorCode as aq, ItdErrorKind as ar, type ItdFieldErrors as as, ItdForbiddenError as at, ItdNetworkError as au, ItdNotFoundError as av, ItdPhoneVerificationError as aw, type ItdPlugin as ax, ItdRateLimitError as ay, ItdRealtime as az, type ItdAccountsOptions as b, type ServiceDefinition as b$, PaginationMode as b0, Paginator as b1, type PaginatorOptions as b2, type PaymentMethod as b3, type Pin as b4, type PinPostResult as b5, type PinsResult as b6, PlatformResource as b7, type PlatformStatus as b8, type PluginContext as b9, type RealtimeEvents as bA, type RealtimeOptions as bB, RealtimeStatus as bC, type RealtimeTransport as bD, RealtimeTransportKind as bE, type ReconnectOptions as bF, type RecordStorageSource as bG, type RemoveAccountOptions as bH, type RenderSpansOptions as bI, type RepliesParams as bJ, type Report as bK, ReportBuilder as bL, type ReportInput as bM, ReportReason as bN, ReportTargetType as bO, ReportsResource as bP, type RequestContext as bQ, type RequestOptions as bR, type ResetPasswordInput as bS, type ResponseContext as bT, type RetryContext as bU, type RetryOptions as bV, RuntimeMode as bW, STATUS_SERVICE as bX, STREAM_PATH as bY, SearchResource as bZ, type SearchResult as b_, type Poll as ba, PollBuilder as bb, type PollInput as bc, type PollOption as bd, type PollTransportOptions as be, type Portal as bf, type Post as bg, PostBuilder as bh, type PostInput as bi, type PostStats as bj, type PostUpdateInput as bk, PostsResource as bl, type PrivacySettings as bm, type Profile as bn, type PublicProfile as bo, type QueryParams as bp, type QueryValue as bq, RECONNECT_BACKOFF as br, RECONNECT_JITTER as bs, REFRESH_COOKIE as bt, REFRESH_COOKIE_PATH as bu, REQUEST_OPTION_KEYS as bv, type RateLimitOptions as bw, type RateLimitScope as bx, type RawRequestOptions as by, type RealtimeDeps as bz, ItdClient as c, mapPage as c$, ServiceRegistry as c0, ServiceState as c1, type ServiceStatus as c2, type Session as c3, type SignInResult as c4, SignInStatus as c5, type Span as c6, type SpanRenderFormat as c7, SpanType as c8, type SseTransportOptions as c9, VIDEO_MIME_TYPES as cA, VerificationResource as cB, type VerificationStatus as cC, type VideoMimeType as cD, ViewReason as cE, ViewSource as cF, WallAccess as cG, autoSpans as cH, canonicalNotificationType as cI, comment as cJ, createMultiTokenStorage as cK, createRecordMultiStorage as cL, createTokenStorage as cM, formatNotificationText as cN, isBuilder as cO, isItdApiError as cP, isItdAuthError as cQ, isItdConflictError as cR, isItdError as cS, isItdForbiddenError as cT, isItdNotFoundError as cU, isItdPhoneVerificationError as cV, isItdRateLimitError as cW, isItdServerError as cX, isItdValidationError as cY, isKnownNotificationType as cZ, isMyProfile as c_, type StatusDay as ca, type StatusIncidentLine as cb, type Subscription as cc, SubscriptionResource as cd, type SubscriptionState as ce, TURNSTILE_SITE_KEY as cf, type TelemetryOptions as cg, TelemetryResource as ch, type TextMarkup as ci, type Transformer as cj, type TransportContext as ck, type TransportEvent as cl, UnauthorizedStreamError as cm, type Unsubscribe as cn, type UpdateNotificationSettingsInput as co, type UpdatePostInput as cp, type UpdatePrivacyInput as cq, type UpdateProfileInput as cr, type UploadOptions as cs, type UploadedFile as ct, type UserId as cu, type UserListParams as cv, type UserPostsParams as cw, type UserRef as cx, type UserSummary as cy, UsersResource as cz, type ItdClientOptions as d, markup as d0, normalizeNotification as d1, poll as d2, post as d3, readNotificationEvent as d4, readUnreadCountEvent as d5, renderSpans as d6, report as d7, resolveNotificationUrl as d8, scopedTokenStorage as d9, statusDays as da, toDate as db, utcStampToIso as dc, createAccounts as dd, createClient as de, type ItdClientInternals as e, AUDIO_MIME_TYPES as f, AUTH_FLAG_COOKIE as g, AUTH_PATHS as h, AccessType as i, type AccountEvents as j, type Actor as k, type AddAccountOptions as l, type AllowedMimeType as m, type Announcement as n, type AnnouncementButton as o, type Attachment as p, AttachmentType as q, type AudioMimeType as r, type AuthEvents as s, type AuthInput as t, AuthResource as u, type Author as v, type AutoSpansOptions as w, type BuilderInput as x, type ChangelogEntry as y, type Clan as z };
4858
+ export { DEVICE_ID_HEADER as $, ALLOWED_MIME_TYPES as A, BUILT_IN_SERVICES as B, type CaptchaCredentials as C, type Clan as D, type ClientHooks as E, type FileReader as F, type Comment as G, CommentBuilder as H, type ItdSession as I, type CommentInput as J, type CommentReplyTo as K, CommentSort as L, type MultiTokenStorage as M, type CommentsParams as N, CommentsResource as O, type CreateCommentInput as P, type CreatePollInput as Q, type CreatePostInput as R, type CreateReportInput as S, type TokenStorage as T, type Credentials as U, type CredentialsAuth as V, DEFAULT_BASE_URL as W, DEFAULT_STATUS_BASE_URL as X, DEFAULT_TIMEOUT as Y, DEFAULT_UPLOAD_TIMEOUT as Z, DEFAULT_USER_AGENT as _, ItdAccounts as a, type Page as a$, DetectedRuntime as a0, type DwellEntry as a1, type ErrorContextHook as a2, type FeedParams as a3, FeedTab as a4, type FileInput as a5, FilesResource as a6, type FollowResult as a7, type ForgotPasswordInput as a8, type Hashtag as a9, ItdRealtime as aA, ItdServerError as aB, ItdTimeoutError as aC, ItdValidationError as aD, LIBRARY_VERSION as aE, type LikeResult as aF, LikesVisibility as aG, type Listener as aH, LocalStorageTokenStorage as aI, type Logger as aJ, type Loose as aK, MAX_RECONNECT_ATTEMPTS as aL, MarkupBuilder as aM, type MarkupContent as aN, type MarkupInput as aO, type MarkupSpan as aP, MemoryMultiTokenStorage as aQ, MemoryTokenStorage as aR, type MyProfile as aS, NOTIFICATION_TYPE_ALIASES as aT, type Notification as aU, type NotificationEvent as aV, type NotificationListParams as aW, type NotificationSettings as aX, NotificationType as aY, NotificationsResource as aZ, OAuthProvider as a_, type HashtagPostsParams as aa, HashtagsResource as ab, IMAGE_MIME_TYPES as ac, type ImageMimeType as ad, IncidentKind as ae, type InteractionEntry as af, InteractionType as ag, type IsoDate as ah, ItdAbortError as ai, ItdApiError as aj, type ItdApiErrorInit as ak, ItdApiErrorKind as al, ItdAuthError as am, type ItdBuilder as an, ItdConfigError as ao, ItdConflictError as ap, ItdError as aq, ItdErrorCode as ar, ItdErrorKind as as, type ItdFieldErrors as at, ItdForbiddenError as au, ItdNetworkError as av, ItdNotFoundError as aw, ItdPhoneVerificationError as ax, type ItdPlugin as ay, ItdRateLimitError as az, type ItdAccountsOptions as b, type SearchResult as b$, type PageState as b0, PaginationMode as b1, Paginator as b2, type PaginatorOptions as b3, type PaymentMethod as b4, type Pin as b5, type PinPostResult as b6, type PinsResult as b7, PlatformResource as b8, type PlatformStatus as b9, type RealtimeDeps as bA, type RealtimeEvents as bB, type RealtimeOptions as bC, RealtimeStatus as bD, type RealtimeTransport as bE, RealtimeTransportKind as bF, type ReconnectOptions as bG, type RecordStorageSource as bH, type RemoveAccountOptions as bI, type RenderSpansOptions as bJ, type RepliesParams as bK, type Report as bL, ReportBuilder as bM, type ReportInput as bN, ReportReason as bO, ReportTargetType as bP, ReportsResource as bQ, type RequestContext as bR, type RequestOptions as bS, type ResetPasswordInput as bT, type ResponseContext as bU, type RetryContext as bV, type RetryOptions as bW, RuntimeMode as bX, STATUS_SERVICE as bY, STREAM_PATH as bZ, SearchResource as b_, type PluginContext as ba, type Poll as bb, PollBuilder as bc, type PollInput as bd, type PollOption as be, type PollTransportOptions as bf, type Portal as bg, type Post as bh, PostBuilder as bi, type PostInput as bj, type PostStats as bk, type PostUpdateInput as bl, PostsResource as bm, type PrivacySettings as bn, type Profile as bo, type PublicProfile as bp, type QueryParams as bq, type QueryValue as br, RECONNECT_BACKOFF as bs, RECONNECT_JITTER as bt, REFRESH_COOKIE as bu, REFRESH_COOKIE_PATH as bv, REQUEST_OPTION_KEYS as bw, type RateLimitOptions as bx, type RateLimitScope as by, type RawRequestOptions as bz, ItdClient as c, isMyProfile as c$, type ServiceDefinition as c0, ServiceRegistry as c1, ServiceState as c2, type ServiceStatus as c3, type Session as c4, type SignInResult as c5, SignInStatus as c6, type Span as c7, type SpanRenderFormat as c8, SpanType as c9, UsersResource as cA, VIDEO_MIME_TYPES as cB, VerificationResource as cC, type VerificationStatus as cD, type VideoMimeType as cE, ViewReason as cF, ViewSource as cG, WallAccess as cH, autoSpans as cI, canonicalNotificationType as cJ, comment as cK, createMultiTokenStorage as cL, createRecordMultiStorage as cM, createTokenStorage as cN, formatNotificationText as cO, isBuilder as cP, isItdApiError as cQ, isItdAuthError as cR, isItdConflictError as cS, isItdError as cT, isItdForbiddenError as cU, isItdNotFoundError as cV, isItdPhoneVerificationError as cW, isItdRateLimitError as cX, isItdServerError as cY, isItdValidationError as cZ, isKnownNotificationType as c_, type SseTransportOptions as ca, type StatusDay as cb, type StatusIncidentLine as cc, type Subscription as cd, SubscriptionResource as ce, type SubscriptionState as cf, TURNSTILE_SITE_KEY as cg, type TelemetryOptions as ch, TelemetryResource as ci, type TextMarkup as cj, type Transformer as ck, type TransportContext as cl, type TransportEvent as cm, UnauthorizedStreamError as cn, type Unsubscribe as co, type UpdateNotificationSettingsInput as cp, type UpdatePostInput as cq, type UpdatePrivacyInput as cr, type UpdateProfileInput as cs, type UploadOptions as ct, type UploadedFile as cu, type UserId as cv, type UserListParams as cw, type UserPostsParams as cx, type UserRef as cy, type UserSummary as cz, type ItdClientOptions as d, mapPage as d0, markup as d1, normalizeNotification as d2, poll as d3, post as d4, readNotificationEvent as d5, readUnreadCountEvent as d6, renderSpans as d7, report as d8, resolveNotificationUrl as d9, scopedTokenStorage as da, statusDays as db, toDate as dc, utcStampToIso as dd, createAccounts as de, createClient as df, type ItdClientInternals as e, AUDIO_MIME_TYPES as f, AUTH_FLAG_COOKIE as g, AUTH_PATHS as h, AccessType as i, type AccountEvents as j, type Actor as k, type AddAccountOptions as l, type AllowedMimeType as m, type Announcement as n, type AnnouncementButton as o, type Attachment as p, AttachmentType as q, type AudioMimeType as r, type AuthEvents as s, type AuthIdentity as t, type AuthInput as u, AuthResource as v, type Author as w, type AutoSpansOptions as x, type BuilderInput as y, type ChangelogEntry as z };
@@ -1398,7 +1398,7 @@ interface RawRequestOptions extends RequestOptions {
1398
1398
  }
1399
1399
 
1400
1400
  /** Версия библиотеки. Попадает в `User-Agent`. */
1401
- declare const LIBRARY_VERSION = "0.0.10";
1401
+ declare const LIBRARY_VERSION = "0.0.11";
1402
1402
 
1403
1403
  /** Базовый URL API итд.com. Домен записан в punycode: `итд.com`. */
1404
1404
  declare const DEFAULT_BASE_URL = "https://xn--d1ah4a.com";
@@ -1421,7 +1421,7 @@ declare const DEFAULT_TIMEOUT = 30000;
1421
1421
  * В браузере заголовок не выставляется — `User-Agent` там запрещён к изменению, и среда
1422
1422
  * молча его игнорирует.
1423
1423
  */
1424
- declare const DEFAULT_USER_AGENT = "Mozilla/5.0 (compatible; itd-api/0.0.10; +https://github.com/KiowDev/itd-api)";
1424
+ declare const DEFAULT_USER_AGENT = "Mozilla/5.0 (compatible; itd-api/0.0.11; +https://github.com/KiowDev/itd-api)";
1425
1425
  /** Настройки очереди со всеми значениями по умолчанию. */
1426
1426
  interface ResolvedRateLimitOptions {
1427
1427
  concurrency: number;
@@ -1635,6 +1635,17 @@ interface AuthEvents {
1635
1635
  error: unknown;
1636
1636
  };
1637
1637
  }
1638
+ /** Области аккаунта и конкретной сессии для локального состояния плагинов. */
1639
+ interface AuthIdentity {
1640
+ /** Идентификатор пользователя; отсутствует у непрозрачного или повреждённого токена. */
1641
+ userId?: UserId | undefined;
1642
+ /** Идентификатор серверной сессии; отсутствует у непрозрачного или повреждённого токена. */
1643
+ sessionId?: string | undefined;
1644
+ }
1645
+ interface AuthManagerHooks {
1646
+ /** Вызывается синхронно перед заменой владельца авторизации. */
1647
+ onAccountChange?: (() => void) | undefined;
1648
+ }
1638
1649
  /**
1639
1650
  * Хранит сессию и продлевает её.
1640
1651
  *
@@ -1645,13 +1656,22 @@ interface AuthEvents {
1645
1656
  */
1646
1657
  declare class AuthManager {
1647
1658
  #private;
1648
- constructor(config: AuthConfig, send: RequestHandler, jar: CookieJar);
1659
+ constructor(config: AuthConfig, send: RequestHandler, jar: CookieJar, hooks?: AuthManagerHooks);
1649
1660
  /** Подписка на события авторизации. */
1650
1661
  get on(): Emitter<AuthEvents>['on'];
1651
1662
  /** Подписка на одно срабатывание. */
1652
1663
  get once(): Emitter<AuthEvents>['once'];
1653
- /** Непрозрачная область авторизации; токен и идентификатор пользователя не раскрываются. */
1664
+ /**
1665
+ * Непрозрачная fallback-область авторизации.
1666
+ *
1667
+ * Изолирует состояние плагинов, когда идентичность аккаунта из JWT недоступна (непрозрачный
1668
+ * токен): значение уникально для владельца и сменяется при замене или очистке сессии.
1669
+ */
1654
1670
  getAuthScope(): string;
1671
+ /** Загружает сессию и возвращает идентификаторы аккаунта и сессии для плагинов. */
1672
+ getAuthIdentity(): Promise<AuthIdentity>;
1673
+ /** Идентификаторы аккаунта и сессии без чтения хранилища. @internal */
1674
+ getCurrentAuthIdentity(): AuthIdentity;
1655
1675
  /**
1656
1676
  * Есть ли признак живой refresh-сессии.
1657
1677
  *
@@ -1740,13 +1760,19 @@ interface PluginContext {
1740
1760
  /** Отладочный вывод клиента, если он включён. */
1741
1761
  logger: Logger | undefined;
1742
1762
  /**
1743
- * Непрозрачная область текущей авторизации.
1763
+ * Непрозрачная fallback-область текущей авторизации.
1744
1764
  *
1745
- * Значение уникально для клиента и меняется при замене либо очистке его сессии. Плагин может
1746
- * использовать его только для разделения состояния; идентификатор пользователя и токен в нём
1747
- * не раскрываются.
1765
+ * Нужна плагинам, которые обязаны безопасно изолировать непрозрачный токен. Для объединения
1766
+ * состояния копий одного аккаунта используйте {@link getAuthIdentity}.
1748
1767
  */
1749
1768
  getAuthScope?: (() => string) | undefined;
1769
+ /**
1770
+ * Загружает сессию и возвращает идентификаторы аккаунта и конкретной сессии из JWT.
1771
+ *
1772
+ * Предпочтительнее {@link getAuthScope} для состояния, которое должно объединяться между
1773
+ * несколькими экземплярами клиента одного аккаунта.
1774
+ */
1775
+ getAuthIdentity?: (() => Promise<AuthIdentity>) | undefined;
1750
1776
  /** Добавляет обёртку запроса. Подключённые раньше оказываются снаружи. */
1751
1777
  use(transformer: Transformer): void;
1752
1778
  }
@@ -2104,6 +2130,10 @@ interface RealtimeDeps {
2104
2130
  fetch: typeof fetch;
2105
2131
  /** Общие заголовки клиента для адреса — см. {@link TransportContext.baseHeaders}. */
2106
2132
  baseHeaders: (url: string) => Promise<Headers>;
2133
+ /** Идентификаторы аккаунта и сессии создавшего поток клиента. */
2134
+ getAuthIdentity?: (() => AuthIdentity) | undefined;
2135
+ /** Непрозрачная область авторизации создавшего поток клиента. */
2136
+ getAuthScope?: (() => string) | undefined;
2107
2137
  getToken: () => Promise<string | null>;
2108
2138
  /** Обновляет токен после отказа авторизации. Возвращает `true`, если удалось. */
2109
2139
  refresh: () => Promise<boolean>;
@@ -2140,6 +2170,12 @@ declare class ItdRealtime {
2140
2170
  get status(): RealtimeStatus;
2141
2171
  /** Какой транспорт используется: `sse` или `poll`. */
2142
2172
  get transport(): string;
2173
+ /** Базовый URL клиента, создавшего поток. @internal */
2174
+ get baseUrl(): string;
2175
+ /** Идентификаторы аккаунта и сессии клиента, создавшего поток. @internal */
2176
+ getAuthIdentity(): AuthIdentity | undefined;
2177
+ /** Непрозрачная область авторизации создавшего поток клиента. @internal */
2178
+ getAuthScope(): string | undefined;
2143
2179
  /** Подписывается на событие потока. @returns функция отписки */
2144
2180
  on<K extends keyof RealtimeEvents>(event: K, listener: Listener<RealtimeEvents[K]>): Unsubscribe;
2145
2181
  /** Подписывается на одно срабатывание. */
@@ -4009,7 +4045,8 @@ declare class ItdClient {
4009
4045
  * Создаёт поток уведомлений в реальном времени.
4010
4046
  *
4011
4047
  * Каждый вызов даёт новый независимый поток; обычно он нужен один на приложение.
4012
- * Соединение поднимается методом `connect()` и держится само.
4048
+ * Соединение поднимается методом `connect()` и держится само. Замена авторизации на токен
4049
+ * другого пользователя завершает все потоки клиента; смена только сессии их не затрагивает.
4013
4050
  *
4014
4051
  * @example
4015
4052
  * ```ts
@@ -4818,4 +4855,4 @@ interface RenderSpansOptions {
4818
4855
  */
4819
4856
  declare function renderSpans(content: string, spans?: readonly Span[] | null | undefined, options?: RenderSpansOptions): string;
4820
4857
 
4821
- export { DetectedRuntime as $, ALLOWED_MIME_TYPES as A, BUILT_IN_SERVICES as B, type CaptchaCredentials as C, type ClientHooks as D, type Comment as E, type FileReader as F, CommentBuilder as G, type CommentInput as H, type ItdSession as I, type CommentReplyTo as J, CommentSort as K, type CommentsParams as L, type MultiTokenStorage as M, CommentsResource as N, type CreateCommentInput as O, type CreatePollInput as P, type CreatePostInput as Q, type CreateReportInput as R, type Credentials as S, type TokenStorage as T, type CredentialsAuth as U, DEFAULT_BASE_URL as V, DEFAULT_STATUS_BASE_URL as W, DEFAULT_TIMEOUT as X, DEFAULT_UPLOAD_TIMEOUT as Y, DEFAULT_USER_AGENT as Z, DEVICE_ID_HEADER as _, ItdAccounts as a, type PageState as a$, type DwellEntry as a0, type ErrorContextHook as a1, type FeedParams as a2, FeedTab as a3, type FileInput as a4, FilesResource as a5, type FollowResult as a6, type ForgotPasswordInput as a7, type Hashtag as a8, type HashtagPostsParams as a9, ItdServerError as aA, ItdTimeoutError as aB, ItdValidationError as aC, LIBRARY_VERSION as aD, type LikeResult as aE, LikesVisibility as aF, type Listener as aG, LocalStorageTokenStorage as aH, type Logger as aI, type Loose as aJ, MAX_RECONNECT_ATTEMPTS as aK, MarkupBuilder as aL, type MarkupContent as aM, type MarkupInput as aN, type MarkupSpan as aO, MemoryMultiTokenStorage as aP, MemoryTokenStorage as aQ, type MyProfile as aR, NOTIFICATION_TYPE_ALIASES as aS, type Notification as aT, type NotificationEvent as aU, type NotificationListParams as aV, type NotificationSettings as aW, NotificationType as aX, NotificationsResource as aY, OAuthProvider as aZ, type Page as a_, HashtagsResource as aa, IMAGE_MIME_TYPES as ab, type ImageMimeType as ac, IncidentKind as ad, type InteractionEntry as ae, InteractionType as af, type IsoDate as ag, ItdAbortError as ah, ItdApiError as ai, type ItdApiErrorInit as aj, ItdApiErrorKind as ak, ItdAuthError as al, type ItdBuilder as am, ItdConfigError as an, ItdConflictError as ao, ItdError as ap, ItdErrorCode as aq, ItdErrorKind as ar, type ItdFieldErrors as as, ItdForbiddenError as at, ItdNetworkError as au, ItdNotFoundError as av, ItdPhoneVerificationError as aw, type ItdPlugin as ax, ItdRateLimitError as ay, ItdRealtime as az, type ItdAccountsOptions as b, type ServiceDefinition as b$, PaginationMode as b0, Paginator as b1, type PaginatorOptions as b2, type PaymentMethod as b3, type Pin as b4, type PinPostResult as b5, type PinsResult as b6, PlatformResource as b7, type PlatformStatus as b8, type PluginContext as b9, type RealtimeEvents as bA, type RealtimeOptions as bB, RealtimeStatus as bC, type RealtimeTransport as bD, RealtimeTransportKind as bE, type ReconnectOptions as bF, type RecordStorageSource as bG, type RemoveAccountOptions as bH, type RenderSpansOptions as bI, type RepliesParams as bJ, type Report as bK, ReportBuilder as bL, type ReportInput as bM, ReportReason as bN, ReportTargetType as bO, ReportsResource as bP, type RequestContext as bQ, type RequestOptions as bR, type ResetPasswordInput as bS, type ResponseContext as bT, type RetryContext as bU, type RetryOptions as bV, RuntimeMode as bW, STATUS_SERVICE as bX, STREAM_PATH as bY, SearchResource as bZ, type SearchResult as b_, type Poll as ba, PollBuilder as bb, type PollInput as bc, type PollOption as bd, type PollTransportOptions as be, type Portal as bf, type Post as bg, PostBuilder as bh, type PostInput as bi, type PostStats as bj, type PostUpdateInput as bk, PostsResource as bl, type PrivacySettings as bm, type Profile as bn, type PublicProfile as bo, type QueryParams as bp, type QueryValue as bq, RECONNECT_BACKOFF as br, RECONNECT_JITTER as bs, REFRESH_COOKIE as bt, REFRESH_COOKIE_PATH as bu, REQUEST_OPTION_KEYS as bv, type RateLimitOptions as bw, type RateLimitScope as bx, type RawRequestOptions as by, type RealtimeDeps as bz, ItdClient as c, mapPage as c$, ServiceRegistry as c0, ServiceState as c1, type ServiceStatus as c2, type Session as c3, type SignInResult as c4, SignInStatus as c5, type Span as c6, type SpanRenderFormat as c7, SpanType as c8, type SseTransportOptions as c9, VIDEO_MIME_TYPES as cA, VerificationResource as cB, type VerificationStatus as cC, type VideoMimeType as cD, ViewReason as cE, ViewSource as cF, WallAccess as cG, autoSpans as cH, canonicalNotificationType as cI, comment as cJ, createMultiTokenStorage as cK, createRecordMultiStorage as cL, createTokenStorage as cM, formatNotificationText as cN, isBuilder as cO, isItdApiError as cP, isItdAuthError as cQ, isItdConflictError as cR, isItdError as cS, isItdForbiddenError as cT, isItdNotFoundError as cU, isItdPhoneVerificationError as cV, isItdRateLimitError as cW, isItdServerError as cX, isItdValidationError as cY, isKnownNotificationType as cZ, isMyProfile as c_, type StatusDay as ca, type StatusIncidentLine as cb, type Subscription as cc, SubscriptionResource as cd, type SubscriptionState as ce, TURNSTILE_SITE_KEY as cf, type TelemetryOptions as cg, TelemetryResource as ch, type TextMarkup as ci, type Transformer as cj, type TransportContext as ck, type TransportEvent as cl, UnauthorizedStreamError as cm, type Unsubscribe as cn, type UpdateNotificationSettingsInput as co, type UpdatePostInput as cp, type UpdatePrivacyInput as cq, type UpdateProfileInput as cr, type UploadOptions as cs, type UploadedFile as ct, type UserId as cu, type UserListParams as cv, type UserPostsParams as cw, type UserRef as cx, type UserSummary as cy, UsersResource as cz, type ItdClientOptions as d, markup as d0, normalizeNotification as d1, poll as d2, post as d3, readNotificationEvent as d4, readUnreadCountEvent as d5, renderSpans as d6, report as d7, resolveNotificationUrl as d8, scopedTokenStorage as d9, statusDays as da, toDate as db, utcStampToIso as dc, createAccounts as dd, createClient as de, type ItdClientInternals as e, AUDIO_MIME_TYPES as f, AUTH_FLAG_COOKIE as g, AUTH_PATHS as h, AccessType as i, type AccountEvents as j, type Actor as k, type AddAccountOptions as l, type AllowedMimeType as m, type Announcement as n, type AnnouncementButton as o, type Attachment as p, AttachmentType as q, type AudioMimeType as r, type AuthEvents as s, type AuthInput as t, AuthResource as u, type Author as v, type AutoSpansOptions as w, type BuilderInput as x, type ChangelogEntry as y, type Clan as z };
4858
+ export { DEVICE_ID_HEADER as $, ALLOWED_MIME_TYPES as A, BUILT_IN_SERVICES as B, type CaptchaCredentials as C, type Clan as D, type ClientHooks as E, type FileReader as F, type Comment as G, CommentBuilder as H, type ItdSession as I, type CommentInput as J, type CommentReplyTo as K, CommentSort as L, type MultiTokenStorage as M, type CommentsParams as N, CommentsResource as O, type CreateCommentInput as P, type CreatePollInput as Q, type CreatePostInput as R, type CreateReportInput as S, type TokenStorage as T, type Credentials as U, type CredentialsAuth as V, DEFAULT_BASE_URL as W, DEFAULT_STATUS_BASE_URL as X, DEFAULT_TIMEOUT as Y, DEFAULT_UPLOAD_TIMEOUT as Z, DEFAULT_USER_AGENT as _, ItdAccounts as a, type Page as a$, DetectedRuntime as a0, type DwellEntry as a1, type ErrorContextHook as a2, type FeedParams as a3, FeedTab as a4, type FileInput as a5, FilesResource as a6, type FollowResult as a7, type ForgotPasswordInput as a8, type Hashtag as a9, ItdRealtime as aA, ItdServerError as aB, ItdTimeoutError as aC, ItdValidationError as aD, LIBRARY_VERSION as aE, type LikeResult as aF, LikesVisibility as aG, type Listener as aH, LocalStorageTokenStorage as aI, type Logger as aJ, type Loose as aK, MAX_RECONNECT_ATTEMPTS as aL, MarkupBuilder as aM, type MarkupContent as aN, type MarkupInput as aO, type MarkupSpan as aP, MemoryMultiTokenStorage as aQ, MemoryTokenStorage as aR, type MyProfile as aS, NOTIFICATION_TYPE_ALIASES as aT, type Notification as aU, type NotificationEvent as aV, type NotificationListParams as aW, type NotificationSettings as aX, NotificationType as aY, NotificationsResource as aZ, OAuthProvider as a_, type HashtagPostsParams as aa, HashtagsResource as ab, IMAGE_MIME_TYPES as ac, type ImageMimeType as ad, IncidentKind as ae, type InteractionEntry as af, InteractionType as ag, type IsoDate as ah, ItdAbortError as ai, ItdApiError as aj, type ItdApiErrorInit as ak, ItdApiErrorKind as al, ItdAuthError as am, type ItdBuilder as an, ItdConfigError as ao, ItdConflictError as ap, ItdError as aq, ItdErrorCode as ar, ItdErrorKind as as, type ItdFieldErrors as at, ItdForbiddenError as au, ItdNetworkError as av, ItdNotFoundError as aw, ItdPhoneVerificationError as ax, type ItdPlugin as ay, ItdRateLimitError as az, type ItdAccountsOptions as b, type SearchResult as b$, type PageState as b0, PaginationMode as b1, Paginator as b2, type PaginatorOptions as b3, type PaymentMethod as b4, type Pin as b5, type PinPostResult as b6, type PinsResult as b7, PlatformResource as b8, type PlatformStatus as b9, type RealtimeDeps as bA, type RealtimeEvents as bB, type RealtimeOptions as bC, RealtimeStatus as bD, type RealtimeTransport as bE, RealtimeTransportKind as bF, type ReconnectOptions as bG, type RecordStorageSource as bH, type RemoveAccountOptions as bI, type RenderSpansOptions as bJ, type RepliesParams as bK, type Report as bL, ReportBuilder as bM, type ReportInput as bN, ReportReason as bO, ReportTargetType as bP, ReportsResource as bQ, type RequestContext as bR, type RequestOptions as bS, type ResetPasswordInput as bT, type ResponseContext as bU, type RetryContext as bV, type RetryOptions as bW, RuntimeMode as bX, STATUS_SERVICE as bY, STREAM_PATH as bZ, SearchResource as b_, type PluginContext as ba, type Poll as bb, PollBuilder as bc, type PollInput as bd, type PollOption as be, type PollTransportOptions as bf, type Portal as bg, type Post as bh, PostBuilder as bi, type PostInput as bj, type PostStats as bk, type PostUpdateInput as bl, PostsResource as bm, type PrivacySettings as bn, type Profile as bo, type PublicProfile as bp, type QueryParams as bq, type QueryValue as br, RECONNECT_BACKOFF as bs, RECONNECT_JITTER as bt, REFRESH_COOKIE as bu, REFRESH_COOKIE_PATH as bv, REQUEST_OPTION_KEYS as bw, type RateLimitOptions as bx, type RateLimitScope as by, type RawRequestOptions as bz, ItdClient as c, isMyProfile as c$, type ServiceDefinition as c0, ServiceRegistry as c1, ServiceState as c2, type ServiceStatus as c3, type Session as c4, type SignInResult as c5, SignInStatus as c6, type Span as c7, type SpanRenderFormat as c8, SpanType as c9, UsersResource as cA, VIDEO_MIME_TYPES as cB, VerificationResource as cC, type VerificationStatus as cD, type VideoMimeType as cE, ViewReason as cF, ViewSource as cG, WallAccess as cH, autoSpans as cI, canonicalNotificationType as cJ, comment as cK, createMultiTokenStorage as cL, createRecordMultiStorage as cM, createTokenStorage as cN, formatNotificationText as cO, isBuilder as cP, isItdApiError as cQ, isItdAuthError as cR, isItdConflictError as cS, isItdError as cT, isItdForbiddenError as cU, isItdNotFoundError as cV, isItdPhoneVerificationError as cW, isItdRateLimitError as cX, isItdServerError as cY, isItdValidationError as cZ, isKnownNotificationType as c_, type SseTransportOptions as ca, type StatusDay as cb, type StatusIncidentLine as cc, type Subscription as cd, SubscriptionResource as ce, type SubscriptionState as cf, TURNSTILE_SITE_KEY as cg, type TelemetryOptions as ch, TelemetryResource as ci, type TextMarkup as cj, type Transformer as ck, type TransportContext as cl, type TransportEvent as cm, UnauthorizedStreamError as cn, type Unsubscribe as co, type UpdateNotificationSettingsInput as cp, type UpdatePostInput as cq, type UpdatePrivacyInput as cr, type UpdateProfileInput as cs, type UploadOptions as ct, type UploadedFile as cu, type UserId as cv, type UserListParams as cw, type UserPostsParams as cx, type UserRef as cy, type UserSummary as cz, type ItdClientOptions as d, mapPage as d0, markup as d1, normalizeNotification as d2, poll as d3, post as d4, readNotificationEvent as d5, readUnreadCountEvent as d6, renderSpans as d7, report as d8, resolveNotificationUrl as d9, scopedTokenStorage as da, statusDays as db, toDate as dc, utcStampToIso as dd, createAccounts as de, createClient as df, type ItdClientInternals as e, AUDIO_MIME_TYPES as f, AUTH_FLAG_COOKIE as g, AUTH_PATHS as h, AccessType as i, type AccountEvents as j, type Actor as k, type AddAccountOptions as l, type AllowedMimeType as m, type Announcement as n, type AnnouncementButton as o, type Attachment as p, AttachmentType as q, type AudioMimeType as r, type AuthEvents as s, type AuthIdentity as t, type AuthInput as u, AuthResource as v, type Author as w, type AutoSpansOptions as x, type BuilderInput as y, type ChangelogEntry as z };