itd-api 0.9.2 → 0.10.0

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.
Files changed (38) hide show
  1. package/README.md +9 -8
  2. package/dist/events/index.cjs +2 -2
  3. package/dist/events/index.d.cts +2 -2
  4. package/dist/events/index.d.ts +2 -2
  5. package/dist/events/index.js +2 -2
  6. package/dist/index.cjs +489 -92
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.cts +186 -36
  9. package/dist/index.d.ts +186 -36
  10. package/dist/index.js +485 -94
  11. package/dist/index.js.map +1 -1
  12. package/dist/rest/index.cjs +2 -2
  13. package/dist/rest/index.d.cts +2 -2
  14. package/dist/rest/index.d.ts +2 -2
  15. package/dist/rest/index.js +2 -2
  16. package/dist/shared/{events-BIBO2Jif.js → events-B0Wtn4cF.js} +3 -3
  17. package/dist/shared/{events-BIBO2Jif.js.map → events-B0Wtn4cF.js.map} +1 -1
  18. package/dist/shared/{events-BsRm_Fba.cjs → events-BB791aPk.cjs} +8 -2
  19. package/dist/shared/{events-BsRm_Fba.cjs.map → events-BB791aPk.cjs.map} +1 -1
  20. package/dist/shared/{events-BCn5LRnT.d.cts → events-BNGjJVI3.d.cts} +2 -2
  21. package/dist/shared/{events-t1uGgpkf.d.ts → events-CJO6q93Z.d.ts} +2 -2
  22. package/dist/shared/{render-DqVzx68r.cjs → render-BimHjOhw.cjs} +2 -30
  23. package/dist/shared/render-BimHjOhw.cjs.map +1 -0
  24. package/dist/shared/{render-DA83gS0f.d.cts → render-C1A57W-5.d.cts} +2 -14
  25. package/dist/shared/{render--ZXmYEf-.js → render-CkhvH_yh.js} +2 -30
  26. package/dist/shared/render-CkhvH_yh.js.map +1 -0
  27. package/dist/shared/{render-BdnBV-aT.d.ts → render-DC5nvqcP.d.ts} +2 -14
  28. package/dist/shared/{url-i2f-X1hX.js → url-BA5hEwj2.js} +95 -16
  29. package/dist/shared/url-BA5hEwj2.js.map +1 -0
  30. package/dist/shared/{url-Doc0XXW_.cjs → url-CDVgMIq5.cjs} +130 -15
  31. package/dist/shared/url-CDVgMIq5.cjs.map +1 -0
  32. package/dist/shared/{url-Dbj6V6fk.d.cts → url-DkMueFAT.d.cts} +76 -17
  33. package/dist/shared/{url-Dbj6V6fk.d.ts → url-DkMueFAT.d.ts} +76 -17
  34. package/package.json +4 -3
  35. package/dist/shared/render--ZXmYEf-.js.map +0 -1
  36. package/dist/shared/render-DqVzx68r.cjs.map +0 -1
  37. package/dist/shared/url-Doc0XXW_.cjs.map +0 -1
  38. package/dist/shared/url-i2f-X1hX.js.map +0 -1
@@ -114,6 +114,44 @@ declare const ReportReason: Readonly<{
114
114
  readonly Other: "other";
115
115
  }>;
116
116
  type ReportReason = (typeof ReportReason)[keyof typeof ReportReason];
117
+ /**
118
+ * Провайдер капчи, которую сервер требует пройти при входе. Тип открытый.
119
+ *
120
+ * Активного сообщает `itd.auth.captchaProvider()`.
121
+ */
122
+ declare const CaptchaType: Readonly<{
123
+ /** Собственная капча ИТД. */
124
+ readonly Itd: "itd";
125
+ /** Cloudflare Turnstile. */
126
+ readonly Cloudflare: "cloudflare";
127
+ }>;
128
+ type CaptchaType = Loose<(typeof CaptchaType)[keyof typeof CaptchaType]>;
129
+ /**
130
+ * Какую капчу решать при входе по логину и паролю.
131
+ *
132
+ * `CaptchaChoice.Auto` — спросить сервер перед каждым входом; названный провайдер
133
+ * решается без этого запроса.
134
+ */
135
+ declare const CaptchaChoice: Readonly<{
136
+ /** Провайдера называет сервер. */
137
+ readonly Auto: "auto";
138
+ readonly Itd: "itd";
139
+ readonly Cloudflare: "cloudflare";
140
+ }>;
141
+ type CaptchaChoice = Loose<(typeof CaptchaChoice)[keyof typeof CaptchaChoice]>;
142
+ /**
143
+ * Поле тела запроса, в котором сервер ждёт токен капчи. Тип открытый.
144
+ *
145
+ * При `CaptchaChoice.Auto` имя берётся из ответа сервера; эти значения — умолчания
146
+ * для явно выбранного провайдера.
147
+ */
148
+ declare const CaptchaField: Readonly<{
149
+ /** Поле собственной капчи ИТД. */
150
+ readonly Itd: "token";
151
+ /** Поле Cloudflare Turnstile. */
152
+ readonly Cloudflare: "turnstileToken";
153
+ }>;
154
+ type CaptchaField = Loose<(typeof CaptchaField)[keyof typeof CaptchaField]>;
117
155
  /** Состояние соединения событийного канала. */
118
156
  declare const EventChannelStatus: Readonly<{
119
157
  readonly Connecting: "connecting";
@@ -295,6 +333,8 @@ declare const ItdErrorCode: Readonly<{
295
333
  readonly CAPTCHA_FAILED: "CAPTCHA_FAILED";
296
334
  /** Капча не пройдена: токен Turnstile недействителен, просрочен или уже использован. */
297
335
  readonly TURNSTILE_VERIFICATION_FAILED: "TURNSTILE_VERIFICATION_FAILED";
336
+ /** Собственная captcha ИТД не подтвердила целостность проверки. */
337
+ readonly INTEGRITY_CHECK_FAILED: "INTEGRITY_CHECK_FAILED";
298
338
  readonly OTP_INVALID: "OTP_INVALID";
299
339
  /** `flowToken` неизвестен или просрочен — поток подтверждения нужно начинать заново. */
300
340
  readonly INVALID_FLOW_TOKEN: "INVALID_FLOW_TOKEN";
@@ -311,6 +351,12 @@ declare const ItdErrorCode: Readonly<{
311
351
  /** Cookie `refresh_token` есть, но сессии за ней уже нет: отозвана или истекла. */
312
352
  readonly SESSION_NOT_FOUND: "SESSION_NOT_FOUND";
313
353
  readonly MISSING_FLOW_TOKEN: "MISSING_FLOW_TOKEN";
354
+ readonly QR_EXPIRED: "QR_EXPIRED";
355
+ readonly QR_TOKEN_MISMATCH: "QR_TOKEN_MISMATCH";
356
+ readonly QR_ALREADY_USED: "QR_ALREADY_USED";
357
+ readonly QR_NOT_SCANNED: "QR_NOT_SCANNED";
358
+ readonly USER_INACTIVE: "USER_INACTIVE";
359
+ readonly TOO_MANY_REQUESTS: "TOO_MANY_REQUESTS";
314
360
  readonly PROFILE_USERNAME_TAKEN: "PROFILE_USERNAME_TAKEN";
315
361
  readonly PROFILE_USERNAME_RESERVED: "PROFILE_USERNAME_RESERVED";
316
362
  readonly PROFILE_RESTRICTION_ACTIVE: "PROFILE_RESTRICTION_ACTIVE";
@@ -391,6 +437,8 @@ declare const BUCKET_LIMITS: Readonly<{
391
437
  readonly 'files.get': 40;
392
438
  readonly auth: 35;
393
439
  readonly 'auth.refresh': 25;
440
+ readonly 'auth.qrStart': 40;
441
+ readonly 'auth.qrClaim': 300;
394
442
  readonly search: 25;
395
443
  readonly 'comments.like': 22;
396
444
  readonly 'files.upload': 15;
@@ -435,6 +483,11 @@ declare const OPERATIONS: Readonly<{
435
483
  readonly method: "GET";
436
484
  readonly retrySafety: "safe";
437
485
  }>;
486
+ readonly 'auth.captchaProvider': Readonly<{
487
+ readonly method: "GET";
488
+ readonly retrySafety: "safe";
489
+ readonly bucket: "auth";
490
+ }>;
438
491
  readonly 'auth.signUp': Readonly<{
439
492
  readonly method: "POST";
440
493
  readonly retrySafety: "unsafe";
@@ -495,6 +548,16 @@ declare const OPERATIONS: Readonly<{
495
548
  readonly retrySafety: "unsafe";
496
549
  readonly bucket: "auth";
497
550
  }>;
551
+ readonly 'auth.qrStart': Readonly<{
552
+ readonly method: "POST";
553
+ readonly retrySafety: "unsafe";
554
+ readonly bucket: "auth.qrStart";
555
+ }>;
556
+ readonly 'auth.qrClaim': Readonly<{
557
+ readonly method: "POST";
558
+ readonly retrySafety: "unsafe";
559
+ readonly bucket: "auth.qrClaim";
560
+ }>;
498
561
  readonly 'users.me': Readonly<{
499
562
  readonly method: "GET";
500
563
  readonly retrySafety: "safe";
@@ -527,11 +590,6 @@ declare const OPERATIONS: Readonly<{
527
590
  readonly retrySafety: "safe";
528
591
  readonly bucket: "users";
529
592
  }>;
530
- readonly 'users.search': Readonly<{
531
- readonly method: "GET";
532
- readonly retrySafety: "safe";
533
- readonly bucket: "users";
534
- }>;
535
593
  readonly 'users.whoToFollow': Readonly<{
536
594
  readonly method: "GET";
537
595
  readonly retrySafety: "safe";
@@ -768,11 +826,6 @@ declare const OPERATIONS: Readonly<{
768
826
  readonly retrySafety: "safe";
769
827
  readonly bucket: "notifications";
770
828
  }>;
771
- readonly 'hashtags.search': Readonly<{
772
- readonly method: "GET";
773
- readonly retrySafety: "safe";
774
- readonly bucket: "hashtags";
775
- }>;
776
829
  readonly 'hashtags.trending': Readonly<{
777
830
  readonly method: "GET";
778
831
  readonly retrySafety: "safe";
@@ -1296,7 +1349,7 @@ interface RawRequestOptions extends RequestOptions {
1296
1349
  * токен автоматически отправляется только основному хосту и его поддоменам.
1297
1350
  */
1298
1351
  skipAuth?: boolean | undefined;
1299
- /** Не пытаться обновить токен при `401` — используется самими эндпоинтами авторизации. */
1352
+ /** Не обновлять токен заранее и при `401` — используется эндпоинтами авторизации. */
1300
1353
  skipAuthRefresh?: boolean | undefined;
1301
1354
  /**
1302
1355
  * Выполнить запрос мимо очереди.
@@ -1364,7 +1417,7 @@ interface OperationDefinition extends OperationMetadata {
1364
1417
  //#endregion
1365
1418
  //#region src/core/version.d.ts
1366
1419
  /** Версия библиотеки. Попадает в `User-Agent`. */
1367
- declare const LIBRARY_VERSION = "0.9.2";
1420
+ declare const LIBRARY_VERSION = "0.10.0";
1368
1421
  //#endregion
1369
1422
  //#region src/core/config.d.ts
1370
1423
  /** Базовый URL API итд.com. Домен записан в punycode: `итд.com`. */
@@ -1442,11 +1495,13 @@ interface AuthProvider {
1442
1495
  */
1443
1496
  token(): Promise<string | null>;
1444
1497
  /**
1445
- * Готовит состояние авторизации до входа транспортной попытки в очередь.
1498
+ * Один раз готовит авторизацию до retry исходного запроса.
1499
+ * Вложенные auth-операции используют собственную retry-политику.
1446
1500
  *
1447
- * Чтение хранилища, обращение к внешнему источнику токена и отложенный вход асинхронны,
1448
- * поэтому обязаны завершиться до захвата слота очереди.
1501
+ * @param allowRefresh можно ли заранее обновить токен
1449
1502
  */
1503
+ preflight?(allowRefresh: boolean): Promise<void>;
1504
+ /** Перед каждой попыткой читает внешний источник токена до захвата слота очереди. */
1450
1505
  prepare(): Promise<void>;
1451
1506
  /**
1452
1507
  * Заголовки уже подготовленной авторизации.
@@ -1515,6 +1570,10 @@ interface ClientConnection {
1515
1570
  readonly fetch: typeof fetch;
1516
1571
  readonly clock: ItdClock;
1517
1572
  readonly logger: Logger | undefined;
1573
+ /** Терминальная отмена владельца соединения. @internal */
1574
+ readonly signal?: AbortSignal | undefined;
1575
+ /** Проверяет, что владелец соединения ещё принимает новые операции. @internal */
1576
+ readonly assertActive?: ((action: string) => void) | undefined;
1518
1577
  /** Заголовки платформы и сервиса без Bearer-токена. */
1519
1578
  baseHeaders(url: string): Promise<Headers>;
1520
1579
  /** Текущий токен; способ его передачи выбирает транспорт. */
@@ -2206,5 +2265,5 @@ declare function isKnownNotificationType(type: string): boolean;
2206
2265
  */
2207
2266
  declare function resolveNotificationUrl(notification: Notification): string;
2208
2267
  //#endregion
2209
- export { isItdStateError as $, DEFAULT_RATE_LIMIT_BUCKET as $t, ItdErrorKind as A, RequestOptions as At, ItdStateError as B, RuntimeMode as Bt, ItdApiError as C, PaginationOptions as Ct, ItdConfigError as D, RawRequestOptions as Dt, ItdAuthError as E, RateLimitOptions as Et, ItdNetworkError as F, RuntimeOptions as Ft, isItdConflictError as G, ItdOperationDefinition as Gt, ItdValidationError as H, systemClock as Ht, ItdNotFoundError as I, QueryParams as It, isItdForbiddenError as J, isBuiltInOperationId as Jt, isItdError as K, OPERATIONS as Kt, ItdPhoneVerificationError as L, QueryValue as Lt, ItdFileError as M, RetryContext as Mt, ItdFileErrorReason as N, RetryDecisionContext as Nt, ItdConflictError as O, RequestContext as Ot, ItdForbiddenError as P, RetryOptions as Pt, isItdServerError as Q, BUCKET_LIMITS as Qt, ItdRateLimitError as R, ServiceDefinition as Rt, ItdAbortError as S, WallAccess as Sn, OperationRequestOptions as St, ItdApiErrorKind as T, RateLimitBucketOverride as Tt, isItdApiError as U, BuiltInOperationId as Ut, ItdTimeoutError as V, ItdClock as Vt, isItdAuthError as W, CustomOperationId as Wt, isItdPhoneVerificationError as X, operationMethod as Xt, isItdNotFoundError as Y, operationBucket as Yt, isItdRateLimitError as Z, operationRetrySafety as Zt, PrivacySettings as _, ReportTargetType as _n, OperationMethod as _t, NotificationEvent as a, AccessType as an, bearerToken as at, SubscriptionState as b, ViewReason as bn, ErrorContextHook as bt, NotificationSettings as c, EventChannelStatus as cn, Listener as ct, AuthUser as d, InteractionType as dn, STATUS_SERVICE as dt, RateLimitBucket as en, isItdValidationError as et, Author as f, ItdErrorCode as fn, LIBRARY_VERSION as ft, PinsResult as g, ReportReason as gn, OperationMetadata as gt, Pin as h, NotificationType as hn, OperationContract as ht, formatNotificationText as i, UserRef as in, anonymousAuth as it, ItdFieldErrors as j, ResponseContext as jt, ItdError as k, RequestExtensions as kt, Actor as l, FeedTab as ln, Unsubscribe as lt, MyProfile as m, Loose as mn, OperationAnnotations as mt, canonicalNotificationType as n, Span as nn, AuthIdentity as nt, normalizeNotification as o, AttachmentType as on, tokenProvider as ot, FollowResult as p, LikesVisibility as pn, FeatureOperationId as pt, isItdFileError as q, OperationId as qt, isKnownNotificationType as r, UserId as rn, AuthProvider as rt, Notification as s, CommentSort as sn, Emitter as st, resolveNotificationUrl as t, IsoDate as tn, ClientConnection as tt, AuthState as u, IncidentKind as un, DEFAULT_BASE_URL as ut, Profile as v, ServiceState as vn, RetrySafety as vt, ItdApiErrorInit as w, RateLimitBucketContext as wt, UserSummary as x, ViewSource as xn, Logger as xt, PublicProfile as y, SpanType as yn, ClientHooks as yt, ItdServerError as z, RateLimitPacing as zt };
2210
- //# sourceMappingURL=url-Dbj6V6fk.d.cts.map
2268
+ export { isItdStateError as $, DEFAULT_RATE_LIMIT_BUCKET as $t, ItdErrorKind as A, RequestOptions as At, ItdStateError as B, RuntimeMode as Bt, ItdApiError as C, ViewReason as Cn, PaginationOptions as Ct, ItdConfigError as D, RawRequestOptions as Dt, ItdAuthError as E, RateLimitOptions as Et, ItdNetworkError as F, RuntimeOptions as Ft, isItdConflictError as G, ItdOperationDefinition as Gt, ItdValidationError as H, systemClock as Ht, ItdNotFoundError as I, QueryParams as It, isItdForbiddenError as J, isBuiltInOperationId as Jt, isItdError as K, OPERATIONS as Kt, ItdPhoneVerificationError as L, QueryValue as Lt, ItdFileError as M, RetryContext as Mt, ItdFileErrorReason as N, RetryDecisionContext as Nt, ItdConflictError as O, RequestContext as Ot, ItdForbiddenError as P, RetryOptions as Pt, isItdServerError as Q, BUCKET_LIMITS as Qt, ItdRateLimitError as R, ServiceDefinition as Rt, ItdAbortError as S, SpanType as Sn, OperationRequestOptions as St, ItdApiErrorKind as T, WallAccess as Tn, RateLimitBucketOverride as Tt, isItdApiError as U, BuiltInOperationId as Ut, ItdTimeoutError as V, ItdClock as Vt, isItdAuthError as W, CustomOperationId as Wt, isItdPhoneVerificationError as X, operationMethod as Xt, isItdNotFoundError as Y, operationBucket as Yt, isItdRateLimitError as Z, operationRetrySafety as Zt, PrivacySettings as _, Loose as _n, OperationMethod as _t, NotificationEvent as a, AccessType as an, bearerToken as at, SubscriptionState as b, ReportTargetType as bn, ErrorContextHook as bt, NotificationSettings as c, CaptchaField as cn, Listener as ct, AuthUser as d, EventChannelStatus as dn, STATUS_SERVICE as dt, RateLimitBucket as en, isItdValidationError as et, Author as f, FeedTab as fn, LIBRARY_VERSION as ft, PinsResult as g, LikesVisibility as gn, OperationMetadata as gt, Pin as h, ItdErrorCode as hn, OperationContract as ht, formatNotificationText as i, UserRef as in, anonymousAuth as it, ItdFieldErrors as j, ResponseContext as jt, ItdError as k, RequestExtensions as kt, Actor as l, CaptchaType as ln, Unsubscribe as lt, MyProfile as m, InteractionType as mn, OperationAnnotations as mt, canonicalNotificationType as n, Span as nn, AuthIdentity as nt, normalizeNotification as o, AttachmentType as on, tokenProvider as ot, FollowResult as p, IncidentKind as pn, FeatureOperationId as pt, isItdFileError as q, OperationId as qt, isKnownNotificationType as r, UserId as rn, AuthProvider as rt, Notification as s, CaptchaChoice as sn, Emitter as st, resolveNotificationUrl as t, IsoDate as tn, ClientConnection as tt, AuthState as u, CommentSort as un, DEFAULT_BASE_URL as ut, Profile as v, NotificationType as vn, RetrySafety as vt, ItdApiErrorInit as w, ViewSource as wn, RateLimitBucketContext as wt, UserSummary as x, ServiceState as xn, Logger as xt, PublicProfile as y, ReportReason as yn, ClientHooks as yt, ItdServerError as z, RateLimitPacing as zt };
2269
+ //# sourceMappingURL=url-DkMueFAT.d.cts.map
@@ -114,6 +114,44 @@ declare const ReportReason: Readonly<{
114
114
  readonly Other: "other";
115
115
  }>;
116
116
  type ReportReason = (typeof ReportReason)[keyof typeof ReportReason];
117
+ /**
118
+ * Провайдер капчи, которую сервер требует пройти при входе. Тип открытый.
119
+ *
120
+ * Активного сообщает `itd.auth.captchaProvider()`.
121
+ */
122
+ declare const CaptchaType: Readonly<{
123
+ /** Собственная капча ИТД. */
124
+ readonly Itd: "itd";
125
+ /** Cloudflare Turnstile. */
126
+ readonly Cloudflare: "cloudflare";
127
+ }>;
128
+ type CaptchaType = Loose<(typeof CaptchaType)[keyof typeof CaptchaType]>;
129
+ /**
130
+ * Какую капчу решать при входе по логину и паролю.
131
+ *
132
+ * `CaptchaChoice.Auto` — спросить сервер перед каждым входом; названный провайдер
133
+ * решается без этого запроса.
134
+ */
135
+ declare const CaptchaChoice: Readonly<{
136
+ /** Провайдера называет сервер. */
137
+ readonly Auto: "auto";
138
+ readonly Itd: "itd";
139
+ readonly Cloudflare: "cloudflare";
140
+ }>;
141
+ type CaptchaChoice = Loose<(typeof CaptchaChoice)[keyof typeof CaptchaChoice]>;
142
+ /**
143
+ * Поле тела запроса, в котором сервер ждёт токен капчи. Тип открытый.
144
+ *
145
+ * При `CaptchaChoice.Auto` имя берётся из ответа сервера; эти значения — умолчания
146
+ * для явно выбранного провайдера.
147
+ */
148
+ declare const CaptchaField: Readonly<{
149
+ /** Поле собственной капчи ИТД. */
150
+ readonly Itd: "token";
151
+ /** Поле Cloudflare Turnstile. */
152
+ readonly Cloudflare: "turnstileToken";
153
+ }>;
154
+ type CaptchaField = Loose<(typeof CaptchaField)[keyof typeof CaptchaField]>;
117
155
  /** Состояние соединения событийного канала. */
118
156
  declare const EventChannelStatus: Readonly<{
119
157
  readonly Connecting: "connecting";
@@ -295,6 +333,8 @@ declare const ItdErrorCode: Readonly<{
295
333
  readonly CAPTCHA_FAILED: "CAPTCHA_FAILED";
296
334
  /** Капча не пройдена: токен Turnstile недействителен, просрочен или уже использован. */
297
335
  readonly TURNSTILE_VERIFICATION_FAILED: "TURNSTILE_VERIFICATION_FAILED";
336
+ /** Собственная captcha ИТД не подтвердила целостность проверки. */
337
+ readonly INTEGRITY_CHECK_FAILED: "INTEGRITY_CHECK_FAILED";
298
338
  readonly OTP_INVALID: "OTP_INVALID";
299
339
  /** `flowToken` неизвестен или просрочен — поток подтверждения нужно начинать заново. */
300
340
  readonly INVALID_FLOW_TOKEN: "INVALID_FLOW_TOKEN";
@@ -311,6 +351,12 @@ declare const ItdErrorCode: Readonly<{
311
351
  /** Cookie `refresh_token` есть, но сессии за ней уже нет: отозвана или истекла. */
312
352
  readonly SESSION_NOT_FOUND: "SESSION_NOT_FOUND";
313
353
  readonly MISSING_FLOW_TOKEN: "MISSING_FLOW_TOKEN";
354
+ readonly QR_EXPIRED: "QR_EXPIRED";
355
+ readonly QR_TOKEN_MISMATCH: "QR_TOKEN_MISMATCH";
356
+ readonly QR_ALREADY_USED: "QR_ALREADY_USED";
357
+ readonly QR_NOT_SCANNED: "QR_NOT_SCANNED";
358
+ readonly USER_INACTIVE: "USER_INACTIVE";
359
+ readonly TOO_MANY_REQUESTS: "TOO_MANY_REQUESTS";
314
360
  readonly PROFILE_USERNAME_TAKEN: "PROFILE_USERNAME_TAKEN";
315
361
  readonly PROFILE_USERNAME_RESERVED: "PROFILE_USERNAME_RESERVED";
316
362
  readonly PROFILE_RESTRICTION_ACTIVE: "PROFILE_RESTRICTION_ACTIVE";
@@ -391,6 +437,8 @@ declare const BUCKET_LIMITS: Readonly<{
391
437
  readonly 'files.get': 40;
392
438
  readonly auth: 35;
393
439
  readonly 'auth.refresh': 25;
440
+ readonly 'auth.qrStart': 40;
441
+ readonly 'auth.qrClaim': 300;
394
442
  readonly search: 25;
395
443
  readonly 'comments.like': 22;
396
444
  readonly 'files.upload': 15;
@@ -435,6 +483,11 @@ declare const OPERATIONS: Readonly<{
435
483
  readonly method: "GET";
436
484
  readonly retrySafety: "safe";
437
485
  }>;
486
+ readonly 'auth.captchaProvider': Readonly<{
487
+ readonly method: "GET";
488
+ readonly retrySafety: "safe";
489
+ readonly bucket: "auth";
490
+ }>;
438
491
  readonly 'auth.signUp': Readonly<{
439
492
  readonly method: "POST";
440
493
  readonly retrySafety: "unsafe";
@@ -495,6 +548,16 @@ declare const OPERATIONS: Readonly<{
495
548
  readonly retrySafety: "unsafe";
496
549
  readonly bucket: "auth";
497
550
  }>;
551
+ readonly 'auth.qrStart': Readonly<{
552
+ readonly method: "POST";
553
+ readonly retrySafety: "unsafe";
554
+ readonly bucket: "auth.qrStart";
555
+ }>;
556
+ readonly 'auth.qrClaim': Readonly<{
557
+ readonly method: "POST";
558
+ readonly retrySafety: "unsafe";
559
+ readonly bucket: "auth.qrClaim";
560
+ }>;
498
561
  readonly 'users.me': Readonly<{
499
562
  readonly method: "GET";
500
563
  readonly retrySafety: "safe";
@@ -527,11 +590,6 @@ declare const OPERATIONS: Readonly<{
527
590
  readonly retrySafety: "safe";
528
591
  readonly bucket: "users";
529
592
  }>;
530
- readonly 'users.search': Readonly<{
531
- readonly method: "GET";
532
- readonly retrySafety: "safe";
533
- readonly bucket: "users";
534
- }>;
535
593
  readonly 'users.whoToFollow': Readonly<{
536
594
  readonly method: "GET";
537
595
  readonly retrySafety: "safe";
@@ -768,11 +826,6 @@ declare const OPERATIONS: Readonly<{
768
826
  readonly retrySafety: "safe";
769
827
  readonly bucket: "notifications";
770
828
  }>;
771
- readonly 'hashtags.search': Readonly<{
772
- readonly method: "GET";
773
- readonly retrySafety: "safe";
774
- readonly bucket: "hashtags";
775
- }>;
776
829
  readonly 'hashtags.trending': Readonly<{
777
830
  readonly method: "GET";
778
831
  readonly retrySafety: "safe";
@@ -1296,7 +1349,7 @@ interface RawRequestOptions extends RequestOptions {
1296
1349
  * токен автоматически отправляется только основному хосту и его поддоменам.
1297
1350
  */
1298
1351
  skipAuth?: boolean | undefined;
1299
- /** Не пытаться обновить токен при `401` — используется самими эндпоинтами авторизации. */
1352
+ /** Не обновлять токен заранее и при `401` — используется эндпоинтами авторизации. */
1300
1353
  skipAuthRefresh?: boolean | undefined;
1301
1354
  /**
1302
1355
  * Выполнить запрос мимо очереди.
@@ -1364,7 +1417,7 @@ interface OperationDefinition extends OperationMetadata {
1364
1417
  //#endregion
1365
1418
  //#region src/core/version.d.ts
1366
1419
  /** Версия библиотеки. Попадает в `User-Agent`. */
1367
- declare const LIBRARY_VERSION = "0.9.2";
1420
+ declare const LIBRARY_VERSION = "0.10.0";
1368
1421
  //#endregion
1369
1422
  //#region src/core/config.d.ts
1370
1423
  /** Базовый URL API итд.com. Домен записан в punycode: `итд.com`. */
@@ -1442,11 +1495,13 @@ interface AuthProvider {
1442
1495
  */
1443
1496
  token(): Promise<string | null>;
1444
1497
  /**
1445
- * Готовит состояние авторизации до входа транспортной попытки в очередь.
1498
+ * Один раз готовит авторизацию до retry исходного запроса.
1499
+ * Вложенные auth-операции используют собственную retry-политику.
1446
1500
  *
1447
- * Чтение хранилища, обращение к внешнему источнику токена и отложенный вход асинхронны,
1448
- * поэтому обязаны завершиться до захвата слота очереди.
1501
+ * @param allowRefresh можно ли заранее обновить токен
1449
1502
  */
1503
+ preflight?(allowRefresh: boolean): Promise<void>;
1504
+ /** Перед каждой попыткой читает внешний источник токена до захвата слота очереди. */
1450
1505
  prepare(): Promise<void>;
1451
1506
  /**
1452
1507
  * Заголовки уже подготовленной авторизации.
@@ -1515,6 +1570,10 @@ interface ClientConnection {
1515
1570
  readonly fetch: typeof fetch;
1516
1571
  readonly clock: ItdClock;
1517
1572
  readonly logger: Logger | undefined;
1573
+ /** Терминальная отмена владельца соединения. @internal */
1574
+ readonly signal?: AbortSignal | undefined;
1575
+ /** Проверяет, что владелец соединения ещё принимает новые операции. @internal */
1576
+ readonly assertActive?: ((action: string) => void) | undefined;
1518
1577
  /** Заголовки платформы и сервиса без Bearer-токена. */
1519
1578
  baseHeaders(url: string): Promise<Headers>;
1520
1579
  /** Текущий токен; способ его передачи выбирает транспорт. */
@@ -2206,5 +2265,5 @@ declare function isKnownNotificationType(type: string): boolean;
2206
2265
  */
2207
2266
  declare function resolveNotificationUrl(notification: Notification): string;
2208
2267
  //#endregion
2209
- export { isItdStateError as $, DEFAULT_RATE_LIMIT_BUCKET as $t, ItdErrorKind as A, RequestOptions as At, ItdStateError as B, RuntimeMode as Bt, ItdApiError as C, PaginationOptions as Ct, ItdConfigError as D, RawRequestOptions as Dt, ItdAuthError as E, RateLimitOptions as Et, ItdNetworkError as F, RuntimeOptions as Ft, isItdConflictError as G, ItdOperationDefinition as Gt, ItdValidationError as H, systemClock as Ht, ItdNotFoundError as I, QueryParams as It, isItdForbiddenError as J, isBuiltInOperationId as Jt, isItdError as K, OPERATIONS as Kt, ItdPhoneVerificationError as L, QueryValue as Lt, ItdFileError as M, RetryContext as Mt, ItdFileErrorReason as N, RetryDecisionContext as Nt, ItdConflictError as O, RequestContext as Ot, ItdForbiddenError as P, RetryOptions as Pt, isItdServerError as Q, BUCKET_LIMITS as Qt, ItdRateLimitError as R, ServiceDefinition as Rt, ItdAbortError as S, WallAccess as Sn, OperationRequestOptions as St, ItdApiErrorKind as T, RateLimitBucketOverride as Tt, isItdApiError as U, BuiltInOperationId as Ut, ItdTimeoutError as V, ItdClock as Vt, isItdAuthError as W, CustomOperationId as Wt, isItdPhoneVerificationError as X, operationMethod as Xt, isItdNotFoundError as Y, operationBucket as Yt, isItdRateLimitError as Z, operationRetrySafety as Zt, PrivacySettings as _, ReportTargetType as _n, OperationMethod as _t, NotificationEvent as a, AccessType as an, bearerToken as at, SubscriptionState as b, ViewReason as bn, ErrorContextHook as bt, NotificationSettings as c, EventChannelStatus as cn, Listener as ct, AuthUser as d, InteractionType as dn, STATUS_SERVICE as dt, RateLimitBucket as en, isItdValidationError as et, Author as f, ItdErrorCode as fn, LIBRARY_VERSION as ft, PinsResult as g, ReportReason as gn, OperationMetadata as gt, Pin as h, NotificationType as hn, OperationContract as ht, formatNotificationText as i, UserRef as in, anonymousAuth as it, ItdFieldErrors as j, ResponseContext as jt, ItdError as k, RequestExtensions as kt, Actor as l, FeedTab as ln, Unsubscribe as lt, MyProfile as m, Loose as mn, OperationAnnotations as mt, canonicalNotificationType as n, Span as nn, AuthIdentity as nt, normalizeNotification as o, AttachmentType as on, tokenProvider as ot, FollowResult as p, LikesVisibility as pn, FeatureOperationId as pt, isItdFileError as q, OperationId as qt, isKnownNotificationType as r, UserId as rn, AuthProvider as rt, Notification as s, CommentSort as sn, Emitter as st, resolveNotificationUrl as t, IsoDate as tn, ClientConnection as tt, AuthState as u, IncidentKind as un, DEFAULT_BASE_URL as ut, Profile as v, ServiceState as vn, RetrySafety as vt, ItdApiErrorInit as w, RateLimitBucketContext as wt, UserSummary as x, ViewSource as xn, Logger as xt, PublicProfile as y, SpanType as yn, ClientHooks as yt, ItdServerError as z, RateLimitPacing as zt };
2210
- //# sourceMappingURL=url-Dbj6V6fk.d.ts.map
2268
+ export { isItdStateError as $, DEFAULT_RATE_LIMIT_BUCKET as $t, ItdErrorKind as A, RequestOptions as At, ItdStateError as B, RuntimeMode as Bt, ItdApiError as C, ViewReason as Cn, PaginationOptions as Ct, ItdConfigError as D, RawRequestOptions as Dt, ItdAuthError as E, RateLimitOptions as Et, ItdNetworkError as F, RuntimeOptions as Ft, isItdConflictError as G, ItdOperationDefinition as Gt, ItdValidationError as H, systemClock as Ht, ItdNotFoundError as I, QueryParams as It, isItdForbiddenError as J, isBuiltInOperationId as Jt, isItdError as K, OPERATIONS as Kt, ItdPhoneVerificationError as L, QueryValue as Lt, ItdFileError as M, RetryContext as Mt, ItdFileErrorReason as N, RetryDecisionContext as Nt, ItdConflictError as O, RequestContext as Ot, ItdForbiddenError as P, RetryOptions as Pt, isItdServerError as Q, BUCKET_LIMITS as Qt, ItdRateLimitError as R, ServiceDefinition as Rt, ItdAbortError as S, SpanType as Sn, OperationRequestOptions as St, ItdApiErrorKind as T, WallAccess as Tn, RateLimitBucketOverride as Tt, isItdApiError as U, BuiltInOperationId as Ut, ItdTimeoutError as V, ItdClock as Vt, isItdAuthError as W, CustomOperationId as Wt, isItdPhoneVerificationError as X, operationMethod as Xt, isItdNotFoundError as Y, operationBucket as Yt, isItdRateLimitError as Z, operationRetrySafety as Zt, PrivacySettings as _, Loose as _n, OperationMethod as _t, NotificationEvent as a, AccessType as an, bearerToken as at, SubscriptionState as b, ReportTargetType as bn, ErrorContextHook as bt, NotificationSettings as c, CaptchaField as cn, Listener as ct, AuthUser as d, EventChannelStatus as dn, STATUS_SERVICE as dt, RateLimitBucket as en, isItdValidationError as et, Author as f, FeedTab as fn, LIBRARY_VERSION as ft, PinsResult as g, LikesVisibility as gn, OperationMetadata as gt, Pin as h, ItdErrorCode as hn, OperationContract as ht, formatNotificationText as i, UserRef as in, anonymousAuth as it, ItdFieldErrors as j, ResponseContext as jt, ItdError as k, RequestExtensions as kt, Actor as l, CaptchaType as ln, Unsubscribe as lt, MyProfile as m, InteractionType as mn, OperationAnnotations as mt, canonicalNotificationType as n, Span as nn, AuthIdentity as nt, normalizeNotification as o, AttachmentType as on, tokenProvider as ot, FollowResult as p, IncidentKind as pn, FeatureOperationId as pt, isItdFileError as q, OperationId as qt, isKnownNotificationType as r, UserId as rn, AuthProvider as rt, Notification as s, CaptchaChoice as sn, Emitter as st, resolveNotificationUrl as t, IsoDate as tn, ClientConnection as tt, AuthState as u, CommentSort as un, DEFAULT_BASE_URL as ut, Profile as v, NotificationType as vn, RetrySafety as vt, ItdApiErrorInit as w, ViewSource as wn, RateLimitBucketContext as wt, UserSummary as x, ServiceState as xn, Logger as xt, PublicProfile as y, ReportReason as yn, ClientHooks as yt, ItdServerError as z, RateLimitPacing as zt };
2269
+ //# sourceMappingURL=url-DkMueFAT.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itd-api",
3
- "version": "0.9.2",
3
+ "version": "0.10.0",
4
4
  "description": "JS/TS SDK & API клиент для соцсети ИТД (итд.com)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -117,6 +117,7 @@
117
117
  "prebuild": "npm run sync-version",
118
118
  "build": "tsdown",
119
119
  "dev": "tsdown --watch",
120
+ "example:qr": "npm run build && npm run build --workspace @itd-api/captcha && node guides/authentication/examples/qr-login-server.mjs",
120
121
  "test": "vitest run",
121
122
  "test:all": "npm run test && npm run test --workspaces --if-present",
122
123
  "test:watch": "vitest",
@@ -139,11 +140,11 @@
139
140
  },
140
141
  "devDependencies": {
141
142
  "@arethetypeswrong/cli": "^0.18.5",
142
- "@biomejs/biome": "^2.5.9",
143
+ "@biomejs/biome": "^2.5.10",
143
144
  "@types/node": "^26.2.0",
144
145
  "@vitest/coverage-v8": "^4.1.11",
145
146
  "eventsource-parser": "^3.1.1",
146
- "publint": "^0.3.23",
147
+ "publint": "^0.3.24",
147
148
  "set-cookie-parser": "^3.1.2",
148
149
  "tsdown": "^0.22.14",
149
150
  "typedoc": "^0.28.20",