itd-api 0.10.0 → 0.10.2
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.
- package/dist/events/index.cjs +2 -2
- package/dist/events/index.d.cts +2 -2
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.js +2 -2
- package/dist/index.cjs +175 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +216 -132
- package/dist/index.d.ts +216 -132
- package/dist/index.js +175 -60
- package/dist/index.js.map +1 -1
- package/dist/rest/index.cjs +2 -2
- package/dist/rest/index.d.cts +2 -2
- package/dist/rest/index.d.ts +2 -2
- package/dist/rest/index.js +2 -2
- package/dist/shared/{events-B0Wtn4cF.js → events-0I_Pixnq.js} +2 -2
- package/dist/shared/{events-B0Wtn4cF.js.map → events-0I_Pixnq.js.map} +1 -1
- package/dist/shared/{events-BB791aPk.cjs → events-8OLqvKwQ.cjs} +2 -2
- package/dist/shared/{events-BB791aPk.cjs.map → events-8OLqvKwQ.cjs.map} +1 -1
- package/dist/shared/{events-BNGjJVI3.d.cts → events-Cr1Mc2Gl.d.cts} +2 -2
- package/dist/shared/{events-CJO6q93Z.d.ts → events-DXooQkyB.d.ts} +2 -2
- package/dist/shared/{render-C1A57W-5.d.cts → render-BxPM234w.d.cts} +29 -3
- package/dist/shared/{render-BimHjOhw.cjs → render-CnpKoGO8.cjs} +2 -2
- package/dist/shared/{render-BimHjOhw.cjs.map → render-CnpKoGO8.cjs.map} +1 -1
- package/dist/shared/{render-DC5nvqcP.d.ts → render-D69bOsxu.d.ts} +29 -3
- package/dist/shared/{render-CkhvH_yh.js → render-GQw5m1-o.js} +2 -2
- package/dist/shared/{render-CkhvH_yh.js.map → render-GQw5m1-o.js.map} +1 -1
- package/dist/shared/{url-CDVgMIq5.cjs → url-BnaioEsz.cjs} +44 -6
- package/dist/shared/{url-CDVgMIq5.cjs.map → url-BnaioEsz.cjs.map} +1 -1
- package/dist/shared/{url-BA5hEwj2.js → url-D0KJ5pws.js} +39 -7
- package/dist/shared/{url-BA5hEwj2.js.map → url-D0KJ5pws.js.map} +1 -1
- package/dist/shared/{url-DkMueFAT.d.ts → url-Qv7smwHP.d.cts} +40 -7
- package/dist/shared/{url-DkMueFAT.d.cts → url-Qv7smwHP.d.ts} +40 -7
- package/package.json +1 -1
package/dist/events/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_url = require("../shared/url-
|
|
2
|
+
const require_url = require("../shared/url-BnaioEsz.cjs");
|
|
3
3
|
const require_errors = require("../shared/errors-BmP3TKoW.cjs");
|
|
4
4
|
const require_redact = require("../shared/redact-lAmck1Z6.cjs");
|
|
5
|
-
const require_events = require("../shared/events-
|
|
5
|
+
const require_events = require("../shared/events-8OLqvKwQ.cjs");
|
|
6
6
|
exports.DEFAULT_BASE_URL = require_url.DEFAULT_BASE_URL;
|
|
7
7
|
exports.EventChannel = require_events.EventChannel;
|
|
8
8
|
exports.EventChannelStatus = require_url.EventChannelStatus;
|
package/dist/events/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as isItdStateError, A as ItdErrorKind, B as ItdStateError, Bt as RuntimeMode, C as ItdApiError, D as ItdConfigError, E as ItdAuthError, F as ItdNetworkError, Ft as RuntimeOptions, H as ItdValidationError, Ht as systemClock, I as ItdNotFoundError, K as isItdError, P as ItdForbiddenError, R as ItdRateLimitError, S as ItdAbortError, T as ItdApiErrorKind, U as isItdApiError, V as ItdTimeoutError, Vt as ItdClock, W as isItdAuthError, Z as isItdRateLimitError, _n as Loose, a as NotificationEvent, at as bearerToken, c as NotificationSettings, ct as Listener, dn as EventChannelStatus, et as isItdValidationError, ft as LIBRARY_VERSION, i as formatNotificationText, it as anonymousAuth, k as ItdError, lt as Unsubscribe, n as canonicalNotificationType, nt as AuthIdentity, o as normalizeNotification, ot as tokenProvider, r as isKnownNotificationType, rt as AuthProvider, s as Notification, t as resolveNotificationUrl, tt as ClientConnection, ut as DEFAULT_BASE_URL, vn as NotificationType, xt as Logger, yt as ClientHooks, z as ItdServerError } from "../shared/url-
|
|
2
|
-
import { $ as EventTransportContext, A as EventHandler, B as NotificationEventContext, C as EventChannelDeps, D as EventSession, E as EventEnqueueOptions, F as EventSequentializer, G as NotificationOfType, H as NotificationEventOfType, I as EventTypeGuard, J as NotificationUpdateOrigin, K as NotificationUpdate, L as runEventMiddleware, M as EventMiddlewareObject, N as EventNext, O as EventSyncReason, P as EventPredicate, Q as EventTransport, R as EventContext, S as EventChannel, T as EventChannelOptions, U as NotificationEventSelector, V as NotificationEventFilter, W as NotificationEventsUpdate, X as UnknownNotificationUpdate, Y as NotificationUpdateType, Z as UnreadCountUpdate, _ as createNotificationEventsClient, a as WebSocketTransportOptions, b as NotificationEventsOptions, c as EventErrorContext, d as EventMiddlewareLike, et as EventTransportFrame, f as EventRouteTable, g as NotificationEventsClientOptions, h as NotificationEventsClient, i as WebSocketTransport, j as EventMiddleware, k as ReconnectOptions, l as EventFilter, m as EventRouter, n as WebSocketLike, o as EventComposer, p as EventRouteSelector, q as NotificationUpdateOfType, r as WebSocketOpenFailureClassifier, s as EventErrorBoundary, t as WebSocketImplementationOptions, tt as UnauthorizedStreamError, u as EventMiddlewareGroup, v as NotificationEvents, w as EventChannelEvents, x as NotificationEventsTransport, y as NotificationEventsMap, z as NotificationContext } from "../shared/events-
|
|
1
|
+
import { $ as isItdStateError, A as ItdErrorKind, B as ItdStateError, Bt as RuntimeMode, C as ItdApiError, D as ItdConfigError, E as ItdAuthError, F as ItdNetworkError, Ft as RuntimeOptions, H as ItdValidationError, Ht as systemClock, I as ItdNotFoundError, K as isItdError, P as ItdForbiddenError, R as ItdRateLimitError, S as ItdAbortError, T as ItdApiErrorKind, U as isItdApiError, V as ItdTimeoutError, Vt as ItdClock, W as isItdAuthError, Z as isItdRateLimitError, _n as Loose, a as NotificationEvent, at as bearerToken, c as NotificationSettings, ct as Listener, dn as EventChannelStatus, et as isItdValidationError, ft as LIBRARY_VERSION, i as formatNotificationText, it as anonymousAuth, k as ItdError, lt as Unsubscribe, n as canonicalNotificationType, nt as AuthIdentity, o as normalizeNotification, ot as tokenProvider, r as isKnownNotificationType, rt as AuthProvider, s as Notification, t as resolveNotificationUrl, tt as ClientConnection, ut as DEFAULT_BASE_URL, vn as NotificationType, xt as Logger, yt as ClientHooks, z as ItdServerError } from "../shared/url-Qv7smwHP.cjs";
|
|
2
|
+
import { $ as EventTransportContext, A as EventHandler, B as NotificationEventContext, C as EventChannelDeps, D as EventSession, E as EventEnqueueOptions, F as EventSequentializer, G as NotificationOfType, H as NotificationEventOfType, I as EventTypeGuard, J as NotificationUpdateOrigin, K as NotificationUpdate, L as runEventMiddleware, M as EventMiddlewareObject, N as EventNext, O as EventSyncReason, P as EventPredicate, Q as EventTransport, R as EventContext, S as EventChannel, T as EventChannelOptions, U as NotificationEventSelector, V as NotificationEventFilter, W as NotificationEventsUpdate, X as UnknownNotificationUpdate, Y as NotificationUpdateType, Z as UnreadCountUpdate, _ as createNotificationEventsClient, a as WebSocketTransportOptions, b as NotificationEventsOptions, c as EventErrorContext, d as EventMiddlewareLike, et as EventTransportFrame, f as EventRouteTable, g as NotificationEventsClientOptions, h as NotificationEventsClient, i as WebSocketTransport, j as EventMiddleware, k as ReconnectOptions, l as EventFilter, m as EventRouter, n as WebSocketLike, o as EventComposer, p as EventRouteSelector, q as NotificationUpdateOfType, r as WebSocketOpenFailureClassifier, s as EventErrorBoundary, t as WebSocketImplementationOptions, tt as UnauthorizedStreamError, u as EventMiddlewareGroup, v as NotificationEvents, w as EventChannelEvents, x as NotificationEventsTransport, y as NotificationEventsMap, z as NotificationContext } from "../shared/events-Cr1Mc2Gl.cjs";
|
|
3
3
|
export { type AuthIdentity, type AuthProvider, type ClientConnection, type ClientHooks, DEFAULT_BASE_URL, EventChannel, type EventChannelDeps, type EventChannelEvents, type EventChannelOptions, EventChannelStatus, EventComposer, type EventContext, type EventEnqueueOptions, type EventErrorBoundary, type EventErrorContext, type EventFilter, type EventHandler, type EventMiddleware, type EventMiddlewareGroup, type EventMiddlewareLike, type EventMiddlewareObject, type EventNext, type EventPredicate, type EventRouteSelector, type EventRouteTable, EventRouter, type EventSequentializer, type EventSession, type EventSyncReason, type EventTransport, type EventTransportContext, type EventTransportFrame, type EventTypeGuard, ItdAbortError, ItdApiError, ItdApiErrorKind, ItdAuthError, type ItdClock, ItdConfigError, ItdError, ItdErrorKind, ItdForbiddenError, ItdNetworkError, ItdNotFoundError, ItdRateLimitError, ItdServerError, ItdStateError, ItdTimeoutError, ItdValidationError, LIBRARY_VERSION, type Listener, type Logger, type Loose, type Notification, type NotificationContext, type NotificationEvent, type NotificationEventContext, type NotificationEventFilter, type NotificationEventOfType, type NotificationEventSelector, NotificationEvents, NotificationEventsClient, type NotificationEventsClientOptions, type NotificationEventsMap, type NotificationEventsOptions, NotificationEventsTransport, type NotificationEventsUpdate, type NotificationOfType, type NotificationSettings, NotificationType, type NotificationUpdate, type NotificationUpdateOfType, NotificationUpdateOrigin, NotificationUpdateType, type ReconnectOptions, RuntimeMode, type RuntimeOptions, UnauthorizedStreamError, type UnknownNotificationUpdate, type UnreadCountUpdate, type Unsubscribe, type WebSocketImplementationOptions, type WebSocketLike, type WebSocketOpenFailureClassifier, WebSocketTransport, type WebSocketTransportOptions, anonymousAuth, bearerToken, canonicalNotificationType, createNotificationEventsClient, formatNotificationText, isItdApiError, isItdAuthError, isItdError, isItdRateLimitError, isItdStateError, isItdValidationError, isKnownNotificationType, normalizeNotification, resolveNotificationUrl, runEventMiddleware, systemClock, tokenProvider };
|
package/dist/events/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as isItdStateError, A as ItdErrorKind, B as ItdStateError, Bt as RuntimeMode, C as ItdApiError, D as ItdConfigError, E as ItdAuthError, F as ItdNetworkError, Ft as RuntimeOptions, H as ItdValidationError, Ht as systemClock, I as ItdNotFoundError, K as isItdError, P as ItdForbiddenError, R as ItdRateLimitError, S as ItdAbortError, T as ItdApiErrorKind, U as isItdApiError, V as ItdTimeoutError, Vt as ItdClock, W as isItdAuthError, Z as isItdRateLimitError, _n as Loose, a as NotificationEvent, at as bearerToken, c as NotificationSettings, ct as Listener, dn as EventChannelStatus, et as isItdValidationError, ft as LIBRARY_VERSION, i as formatNotificationText, it as anonymousAuth, k as ItdError, lt as Unsubscribe, n as canonicalNotificationType, nt as AuthIdentity, o as normalizeNotification, ot as tokenProvider, r as isKnownNotificationType, rt as AuthProvider, s as Notification, t as resolveNotificationUrl, tt as ClientConnection, ut as DEFAULT_BASE_URL, vn as NotificationType, xt as Logger, yt as ClientHooks, z as ItdServerError } from "../shared/url-
|
|
2
|
-
import { $ as EventTransportContext, A as EventHandler, B as NotificationEventContext, C as EventChannelDeps, D as EventSession, E as EventEnqueueOptions, F as EventSequentializer, G as NotificationOfType, H as NotificationEventOfType, I as EventTypeGuard, J as NotificationUpdateOrigin, K as NotificationUpdate, L as runEventMiddleware, M as EventMiddlewareObject, N as EventNext, O as EventSyncReason, P as EventPredicate, Q as EventTransport, R as EventContext, S as EventChannel, T as EventChannelOptions, U as NotificationEventSelector, V as NotificationEventFilter, W as NotificationEventsUpdate, X as UnknownNotificationUpdate, Y as NotificationUpdateType, Z as UnreadCountUpdate, _ as createNotificationEventsClient, a as WebSocketTransportOptions, b as NotificationEventsOptions, c as EventErrorContext, d as EventMiddlewareLike, et as EventTransportFrame, f as EventRouteTable, g as NotificationEventsClientOptions, h as NotificationEventsClient, i as WebSocketTransport, j as EventMiddleware, k as ReconnectOptions, l as EventFilter, m as EventRouter, n as WebSocketLike, o as EventComposer, p as EventRouteSelector, q as NotificationUpdateOfType, r as WebSocketOpenFailureClassifier, s as EventErrorBoundary, t as WebSocketImplementationOptions, tt as UnauthorizedStreamError, u as EventMiddlewareGroup, v as NotificationEvents, w as EventChannelEvents, x as NotificationEventsTransport, y as NotificationEventsMap, z as NotificationContext } from "../shared/events-
|
|
1
|
+
import { $ as isItdStateError, A as ItdErrorKind, B as ItdStateError, Bt as RuntimeMode, C as ItdApiError, D as ItdConfigError, E as ItdAuthError, F as ItdNetworkError, Ft as RuntimeOptions, H as ItdValidationError, Ht as systemClock, I as ItdNotFoundError, K as isItdError, P as ItdForbiddenError, R as ItdRateLimitError, S as ItdAbortError, T as ItdApiErrorKind, U as isItdApiError, V as ItdTimeoutError, Vt as ItdClock, W as isItdAuthError, Z as isItdRateLimitError, _n as Loose, a as NotificationEvent, at as bearerToken, c as NotificationSettings, ct as Listener, dn as EventChannelStatus, et as isItdValidationError, ft as LIBRARY_VERSION, i as formatNotificationText, it as anonymousAuth, k as ItdError, lt as Unsubscribe, n as canonicalNotificationType, nt as AuthIdentity, o as normalizeNotification, ot as tokenProvider, r as isKnownNotificationType, rt as AuthProvider, s as Notification, t as resolveNotificationUrl, tt as ClientConnection, ut as DEFAULT_BASE_URL, vn as NotificationType, xt as Logger, yt as ClientHooks, z as ItdServerError } from "../shared/url-Qv7smwHP.js";
|
|
2
|
+
import { $ as EventTransportContext, A as EventHandler, B as NotificationEventContext, C as EventChannelDeps, D as EventSession, E as EventEnqueueOptions, F as EventSequentializer, G as NotificationOfType, H as NotificationEventOfType, I as EventTypeGuard, J as NotificationUpdateOrigin, K as NotificationUpdate, L as runEventMiddleware, M as EventMiddlewareObject, N as EventNext, O as EventSyncReason, P as EventPredicate, Q as EventTransport, R as EventContext, S as EventChannel, T as EventChannelOptions, U as NotificationEventSelector, V as NotificationEventFilter, W as NotificationEventsUpdate, X as UnknownNotificationUpdate, Y as NotificationUpdateType, Z as UnreadCountUpdate, _ as createNotificationEventsClient, a as WebSocketTransportOptions, b as NotificationEventsOptions, c as EventErrorContext, d as EventMiddlewareLike, et as EventTransportFrame, f as EventRouteTable, g as NotificationEventsClientOptions, h as NotificationEventsClient, i as WebSocketTransport, j as EventMiddleware, k as ReconnectOptions, l as EventFilter, m as EventRouter, n as WebSocketLike, o as EventComposer, p as EventRouteSelector, q as NotificationUpdateOfType, r as WebSocketOpenFailureClassifier, s as EventErrorBoundary, t as WebSocketImplementationOptions, tt as UnauthorizedStreamError, u as EventMiddlewareGroup, v as NotificationEvents, w as EventChannelEvents, x as NotificationEventsTransport, y as NotificationEventsMap, z as NotificationContext } from "../shared/events-DXooQkyB.js";
|
|
3
3
|
export { type AuthIdentity, type AuthProvider, type ClientConnection, type ClientHooks, DEFAULT_BASE_URL, EventChannel, type EventChannelDeps, type EventChannelEvents, type EventChannelOptions, EventChannelStatus, EventComposer, type EventContext, type EventEnqueueOptions, type EventErrorBoundary, type EventErrorContext, type EventFilter, type EventHandler, type EventMiddleware, type EventMiddlewareGroup, type EventMiddlewareLike, type EventMiddlewareObject, type EventNext, type EventPredicate, type EventRouteSelector, type EventRouteTable, EventRouter, type EventSequentializer, type EventSession, type EventSyncReason, type EventTransport, type EventTransportContext, type EventTransportFrame, type EventTypeGuard, ItdAbortError, ItdApiError, ItdApiErrorKind, ItdAuthError, type ItdClock, ItdConfigError, ItdError, ItdErrorKind, ItdForbiddenError, ItdNetworkError, ItdNotFoundError, ItdRateLimitError, ItdServerError, ItdStateError, ItdTimeoutError, ItdValidationError, LIBRARY_VERSION, type Listener, type Logger, type Loose, type Notification, type NotificationContext, type NotificationEvent, type NotificationEventContext, type NotificationEventFilter, type NotificationEventOfType, type NotificationEventSelector, NotificationEvents, NotificationEventsClient, type NotificationEventsClientOptions, type NotificationEventsMap, type NotificationEventsOptions, NotificationEventsTransport, type NotificationEventsUpdate, type NotificationOfType, type NotificationSettings, NotificationType, type NotificationUpdate, type NotificationUpdateOfType, NotificationUpdateOrigin, NotificationUpdateType, type ReconnectOptions, RuntimeMode, type RuntimeOptions, UnauthorizedStreamError, type UnknownNotificationUpdate, type UnreadCountUpdate, type Unsubscribe, type WebSocketImplementationOptions, type WebSocketLike, type WebSocketOpenFailureClassifier, WebSocketTransport, type WebSocketTransportOptions, anonymousAuth, bearerToken, canonicalNotificationType, createNotificationEventsClient, formatNotificationText, isItdApiError, isItdAuthError, isItdError, isItdRateLimitError, isItdStateError, isItdValidationError, isKnownNotificationType, normalizeNotification, resolveNotificationUrl, runEventMiddleware, systemClock, tokenProvider };
|
package/dist/events/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as NotificationType, a as tokenProvider, c as normalizeNotification, d as canonicalNotificationType, f as isKnownNotificationType,
|
|
1
|
+
import { T as NotificationType, a as tokenProvider, c as normalizeNotification, d as canonicalNotificationType, dt as LIBRARY_VERSION, f as isKnownNotificationType, gt as systemClock, i as bearerToken, n as formatNotificationText, r as anonymousAuth, st as DEFAULT_BASE_URL, t as resolveNotificationUrl, y as EventChannelStatus } from "../shared/url-D0KJ5pws.js";
|
|
2
2
|
import { A as isItdStateError, C as isItdError, O as isItdRateLimitError, _ as ItdStateError, a as ItdConfigError, b as isItdApiError, c as ItdErrorKind, d as ItdForbiddenError, f as ItdNetworkError, g as ItdServerError, h as ItdRateLimitError, i as ItdAuthError, j as isItdValidationError, n as ItdApiError, p as ItdNotFoundError, r as ItdApiErrorKind, s as ItdError, t as ItdAbortError, v as ItdTimeoutError, x as isItdAuthError, y as ItdValidationError } from "../shared/errors-GI10kZxk.js";
|
|
3
3
|
import { v as RuntimeMode } from "../shared/redact-DJV0XM3n.js";
|
|
4
|
-
import { a as WebSocketTransport, c as NotificationEventsTransport, d as NotificationUpdateOrigin, f as NotificationUpdateType, g as runEventMiddleware, h as UnauthorizedStreamError, i as createNotificationEventsClient, m as EventChannel, n as EventRouter, r as NotificationEventsClient, s as NotificationEvents, t as EventComposer } from "../shared/events-
|
|
4
|
+
import { a as WebSocketTransport, c as NotificationEventsTransport, d as NotificationUpdateOrigin, f as NotificationUpdateType, g as runEventMiddleware, h as UnauthorizedStreamError, i as createNotificationEventsClient, m as EventChannel, n as EventRouter, r as NotificationEventsClient, s as NotificationEvents, t as EventComposer } from "../shared/events-0I_Pixnq.js";
|
|
5
5
|
export { DEFAULT_BASE_URL, EventChannel, EventChannelStatus, EventComposer, EventRouter, ItdAbortError, ItdApiError, ItdApiErrorKind, ItdAuthError, ItdConfigError, ItdError, ItdErrorKind, ItdForbiddenError, ItdNetworkError, ItdNotFoundError, ItdRateLimitError, ItdServerError, ItdStateError, ItdTimeoutError, ItdValidationError, LIBRARY_VERSION, NotificationEvents, NotificationEventsClient, NotificationEventsTransport, NotificationType, NotificationUpdateOrigin, NotificationUpdateType, RuntimeMode, UnauthorizedStreamError, WebSocketTransport, anonymousAuth, bearerToken, canonicalNotificationType, createNotificationEventsClient, formatNotificationText, isItdApiError, isItdAuthError, isItdError, isItdRateLimitError, isItdStateError, isItdValidationError, isKnownNotificationType, normalizeNotification, resolveNotificationUrl, runEventMiddleware, systemClock, tokenProvider };
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_url = require("./shared/url-
|
|
2
|
+
const require_url = require("./shared/url-BnaioEsz.cjs");
|
|
3
3
|
const require_errors = require("./shared/errors-BmP3TKoW.cjs");
|
|
4
4
|
const require_redact = require("./shared/redact-lAmck1Z6.cjs");
|
|
5
|
-
const require_render = require("./shared/render-
|
|
5
|
+
const require_render = require("./shared/render-CnpKoGO8.cjs");
|
|
6
6
|
const require_options = require("./shared/options-DjEtbVaf.cjs");
|
|
7
|
-
const require_events = require("./shared/events-
|
|
7
|
+
const require_events = require("./shared/events-8OLqvKwQ.cjs");
|
|
8
8
|
const require_key_value_store = require("./shared/key-value-store-B5GYVEYZ.cjs");
|
|
9
9
|
const require_storage = require("./shared/storage-CZJZoaz9.cjs");
|
|
10
10
|
const require_multi_storage = require("./shared/multi-storage-s-fPtjoy.cjs");
|
|
@@ -63,6 +63,7 @@ function requireString(body, key, message) {
|
|
|
63
63
|
}
|
|
64
64
|
const AUTH_CHECK = require_url.passthroughOperation("auth.check");
|
|
65
65
|
const AUTH_CAPTCHA_PROVIDER = require_url.passthroughOperation("auth.captchaProvider");
|
|
66
|
+
const AUTH_CAPTCHA_PAGE = require_url.passthroughOperation("auth.captchaPage");
|
|
66
67
|
const AUTH_SIGN_UP = require_url.defineBuiltInOperation("auth.signUp", (body) => requireString(body, "flowToken", "Сервер не вернул flowToken при регистрации"));
|
|
67
68
|
const AUTH_SIGN_IN = require_url.defineBuiltInOperation("auth.signIn", (body) => {
|
|
68
69
|
const accessToken = require_url.pickString(body, "accessToken");
|
|
@@ -86,27 +87,45 @@ const AUTH_REVOKE_SESSION = require_url.voidOperation("auth.revokeSession");
|
|
|
86
87
|
const AUTH_REVOKE_OTHER_SESSIONS = require_url.voidOperation("auth.revokeOtherSessions");
|
|
87
88
|
const AUTH_QR_START = require_url.passthroughOperation("auth.qrStart");
|
|
88
89
|
const AUTH_QR_CLAIM = require_url.passthroughOperation("auth.qrClaim");
|
|
90
|
+
const AUTH_QR_SCAN = require_url.passthroughOperation("auth.qrScan");
|
|
91
|
+
const AUTH_QR_APPROVE = require_url.voidOperation("auth.qrApprove");
|
|
92
|
+
const AUTH_QR_REJECT = require_url.voidOperation("auth.qrReject");
|
|
89
93
|
//#endregion
|
|
90
94
|
//#region src/session/captcha.ts
|
|
91
95
|
function requireCaptchaText(value, field) {
|
|
92
96
|
if (value !== void 0 && (typeof value !== "string" || value.trim() === "")) throw new require_errors.ItdConfigError(`${field} должен быть непустой строкой`);
|
|
93
97
|
}
|
|
94
98
|
/**
|
|
95
|
-
* Проверяет форму
|
|
99
|
+
* Проверяет форму источника токена и приводит его к объекту.
|
|
96
100
|
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
101
|
+
* Сам объект сохраняется как есть: `getToken` вызывается на нём, чтобы источнику остался
|
|
102
|
+
* доступен собственный `this`.
|
|
99
103
|
*
|
|
100
104
|
* @throws {ItdConfigError} при некорректных значениях
|
|
101
105
|
*/
|
|
102
|
-
function
|
|
106
|
+
function resolveCaptchaSolver(captcha) {
|
|
107
|
+
if (captcha === void 0) return void 0;
|
|
108
|
+
if (typeof captcha === "function") return { getToken: captcha };
|
|
109
|
+
if (!require_url.isRecord$1(captcha)) throw new require_errors.ItdConfigError("captcha должен быть функцией либо объектом с getToken");
|
|
110
|
+
const { getToken, type, field } = captcha;
|
|
111
|
+
if (typeof getToken !== "function") throw new require_errors.ItdConfigError("captcha.getToken должен быть функцией");
|
|
112
|
+
requireCaptchaText(type, "captcha.type");
|
|
113
|
+
requireCaptchaText(field, "captcha.field");
|
|
114
|
+
return captcha;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Проверяет форму готового токена капчи.
|
|
118
|
+
*
|
|
119
|
+
* @param path имя опции или аргумента для текста ошибки
|
|
120
|
+
* @throws {ItdConfigError} если токен или его тип не указаны
|
|
121
|
+
*/
|
|
122
|
+
function validateCaptchaToken(captcha, path) {
|
|
103
123
|
if (captcha === void 0) return;
|
|
104
|
-
if (!require_url.isRecord$1(captcha)) throw new require_errors.ItdConfigError(
|
|
105
|
-
const { type, token,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
requireCaptchaText(field,
|
|
109
|
-
if (getToken !== void 0 && typeof getToken !== "function") throw new require_errors.ItdConfigError("auth.captcha.getToken должен быть функцией");
|
|
124
|
+
if (!require_url.isRecord$1(captcha)) throw new require_errors.ItdConfigError(`${path} должен быть объектом { type, token }`);
|
|
125
|
+
const { type, token, field } = captcha;
|
|
126
|
+
if (typeof token !== "string" || token.trim() === "") throw new require_errors.ItdConfigError(`${path}.token должен быть непустой строкой`);
|
|
127
|
+
if (typeof type !== "string" || type.trim() === "") throw new require_errors.ItdConfigError(`${path}.type должен быть непустой строкой`);
|
|
128
|
+
requireCaptchaText(field, `${path}.field`);
|
|
110
129
|
}
|
|
111
130
|
/** Разбирает ответ `GET /api/v1/auth/captcha/provider` для автоматического входа. */
|
|
112
131
|
function readCaptchaProvider(body) {
|
|
@@ -123,43 +142,40 @@ function readCaptchaProvider(body) {
|
|
|
123
142
|
function resolveField(type, configured) {
|
|
124
143
|
const field = configured ?? CAPTCHA_FIELDS[type];
|
|
125
144
|
if (field) return field;
|
|
126
|
-
throw new require_errors.ItdConfigError(`Неизвестно, в каком поле сервер ждёт токен капчи «${type}». Передайте
|
|
145
|
+
throw new require_errors.ItdConfigError(`Неизвестно, в каком поле сервер ждёт токен капчи «${type}». Передайте captcha.field либо оставьте captcha.type = ${require_url.CaptchaChoice.Auto}, чтобы поле назвал сервер.`);
|
|
127
146
|
}
|
|
128
|
-
/** Спрашивает
|
|
129
|
-
async function
|
|
130
|
-
const token = await
|
|
131
|
-
if (token) return token;
|
|
132
|
-
throw new require_errors.ItdConfigError(`Источник капчи не вернул токен для провайдера «${type}». Проверьте
|
|
147
|
+
/** Спрашивает токен у источника и убеждается, что он непустой. */
|
|
148
|
+
async function requireSolvedToken(solver, type) {
|
|
149
|
+
const token = await solver.getToken(type);
|
|
150
|
+
if (typeof token === "string" && token.trim() !== "") return token;
|
|
151
|
+
throw new require_errors.ItdConfigError(`Источник капчи не вернул токен для провайдера «${type}». Проверьте captcha.getToken.`);
|
|
133
152
|
}
|
|
134
153
|
/**
|
|
135
|
-
* Готовит фрагмент тела
|
|
154
|
+
* Готовит фрагмент тела запроса, взяв токен у источника.
|
|
136
155
|
*
|
|
137
156
|
* При `CaptchaChoice.Auto` провайдер спрашивается у сервера — тогда и тип виджета,
|
|
138
|
-
* и имя поля приходят оттуда. Явно названный тип
|
|
157
|
+
* и имя поля приходят оттуда. Явно названный тип обходится без этого запроса.
|
|
139
158
|
*
|
|
140
159
|
* @param askProvider как спросить активного провайдера; вызывается, только если это нужно
|
|
141
|
-
* @throws {ItdConfigError} если
|
|
160
|
+
* @throws {ItdConfigError} если токен получить не удалось
|
|
142
161
|
*/
|
|
143
|
-
async function
|
|
144
|
-
|
|
145
|
-
const choice = captcha.type ?? require_url.CaptchaChoice.Auto;
|
|
162
|
+
async function solveCaptchaBody(solver, askProvider) {
|
|
163
|
+
const choice = solver.type ?? require_url.CaptchaChoice.Auto;
|
|
146
164
|
if (choice === require_url.CaptchaChoice.Auto) {
|
|
147
165
|
const { provider, field } = await askProvider();
|
|
148
|
-
return { [field]: await
|
|
166
|
+
return { [field]: await requireSolvedToken(solver, provider) };
|
|
149
167
|
}
|
|
150
|
-
return { [resolveField(choice,
|
|
168
|
+
return { [resolveField(choice, solver.field)]: await requireSolvedToken(solver, choice) };
|
|
151
169
|
}
|
|
152
170
|
/**
|
|
153
|
-
* Готовит фрагмент тела
|
|
171
|
+
* Готовит фрагмент тела из готового токена.
|
|
154
172
|
*
|
|
155
|
-
* Поле берётся из самого
|
|
173
|
+
* Поле берётся из самого токена либо из умолчания провайдера; запроса к серверу нет.
|
|
156
174
|
*
|
|
157
|
-
* @throws {ItdConfigError} если
|
|
175
|
+
* @throws {ItdConfigError} если токен или его тип не указаны
|
|
158
176
|
*/
|
|
159
177
|
function captchaBody(captcha) {
|
|
160
|
-
|
|
161
|
-
if (typeof captcha.token !== "string" || captcha.token.trim() === "") throw new require_errors.ItdConfigError("captcha.token должен быть непустой строкой");
|
|
162
|
-
if (typeof captcha.type !== "string" || captcha.type.trim() === "") throw new require_errors.ItdConfigError("captcha.type должен быть непустой строкой");
|
|
178
|
+
validateCaptchaToken(captcha, "captcha");
|
|
163
179
|
return { [resolveField(captcha.type, captcha.field)]: captcha.token };
|
|
164
180
|
}
|
|
165
181
|
//#endregion
|
|
@@ -237,7 +253,7 @@ function validateAuth(auth) {
|
|
|
237
253
|
const { email, password, captcha } = auth;
|
|
238
254
|
if (typeof email !== "string" || email.trim() === "") throw new require_errors.ItdConfigError("auth.email должен быть непустой строкой");
|
|
239
255
|
if (typeof password !== "string" || password === "") throw new require_errors.ItdConfigError("auth.password должен быть непустой строкой");
|
|
240
|
-
|
|
256
|
+
validateCaptchaToken(captcha, "auth.captcha");
|
|
241
257
|
return { ...auth };
|
|
242
258
|
}
|
|
243
259
|
throw new require_errors.ItdConfigError("auth не распознан. Ожидается строка с accessToken либо объект { accessToken }, { email, password } или { getToken }");
|
|
@@ -266,6 +282,7 @@ function resolveSessionConfig(options, runtime) {
|
|
|
266
282
|
return {
|
|
267
283
|
...runtime,
|
|
268
284
|
auth: validateAuth(options.auth),
|
|
285
|
+
captcha: resolveCaptchaSolver(options.captcha),
|
|
269
286
|
storage: resolveStorage(options.storage),
|
|
270
287
|
deviceId: options.deviceId,
|
|
271
288
|
autoRefresh: options.autoRefresh ?? true,
|
|
@@ -285,6 +302,7 @@ function createItdAuth(options, deps) {
|
|
|
285
302
|
/** Пути эндпоинтов авторизации. */
|
|
286
303
|
const AUTH_PATHS = {
|
|
287
304
|
captchaProvider: "/api/v1/auth/captcha/provider",
|
|
305
|
+
captchaPage: "/api/v1/auth/captcha/page",
|
|
288
306
|
signUp: "/api/v1/auth/sign-up",
|
|
289
307
|
signIn: "/api/v1/auth/sign-in",
|
|
290
308
|
verifyOtp: "/api/v1/auth/verify-otp",
|
|
@@ -297,7 +315,10 @@ const AUTH_PATHS = {
|
|
|
297
315
|
sessions: "/api/v1/auth/sessions",
|
|
298
316
|
qrStart: "/api/v1/auth/qr/start",
|
|
299
317
|
qrClaim: "/api/v1/auth/qr/claim",
|
|
300
|
-
qrStream: "/api/v1/auth/qr/stream"
|
|
318
|
+
qrStream: "/api/v1/auth/qr/stream",
|
|
319
|
+
qrScan: "/api/v1/auth/qr/scan",
|
|
320
|
+
qrApprove: "/api/v1/auth/qr/approve",
|
|
321
|
+
qrReject: "/api/v1/auth/qr/reject"
|
|
301
322
|
};
|
|
302
323
|
/**
|
|
303
324
|
* Публичный ключ Cloudflare Turnstile платформы итд.com.
|
|
@@ -437,6 +458,8 @@ var AuthManager = class {
|
|
|
437
458
|
*/
|
|
438
459
|
#authEpoch = 0;
|
|
439
460
|
#externalReadGeneration = 0;
|
|
461
|
+
/** Разовый токен из `auth.captcha` тратится ровно на один запрос. */
|
|
462
|
+
#configCaptchaSpent = false;
|
|
440
463
|
#disposed = false;
|
|
441
464
|
#persistence = Promise.resolve();
|
|
442
465
|
constructor(config, http, jar, hooks = {}) {
|
|
@@ -964,6 +987,34 @@ var AuthManager = class {
|
|
|
964
987
|
this.#signingIn = promise;
|
|
965
988
|
return promise;
|
|
966
989
|
}
|
|
990
|
+
/**
|
|
991
|
+
* Готовит фрагмент тела с токеном капчи для запроса, который её требует.
|
|
992
|
+
*
|
|
993
|
+
* Источники в порядке убывания приоритета: токен, переданный в сам вызов; разовый токен
|
|
994
|
+
* из `auth.captcha`; опция `captcha`. Когда ни одного нет, фрагмент пустой: нужна ли
|
|
995
|
+
* капча этому запросу, решает сервер.
|
|
996
|
+
*
|
|
997
|
+
* @param explicit готовый токен, переданный в вызов
|
|
998
|
+
* @throws {ItdConfigError} если токен неполный или источник его не вернул
|
|
999
|
+
*/
|
|
1000
|
+
async captchaBody(explicit) {
|
|
1001
|
+
if (explicit) return captchaBody(explicit);
|
|
1002
|
+
const configured = this.#takeConfiguredCaptcha();
|
|
1003
|
+
if (configured) return captchaBody(configured);
|
|
1004
|
+
const solver = this.#config.captcha;
|
|
1005
|
+
if (solver) return solveCaptchaBody(solver, () => this.#resolveCaptchaProvider());
|
|
1006
|
+
this.#config.logger?.debug("Запрос уходит без токена капчи: не передан аргумент captcha и не задана опция captcha");
|
|
1007
|
+
return {};
|
|
1008
|
+
}
|
|
1009
|
+
/** Отдаёт разовый токен из `auth.captcha`, помечая его потраченным. */
|
|
1010
|
+
#takeConfiguredCaptcha() {
|
|
1011
|
+
if (this.#configCaptchaSpent) return void 0;
|
|
1012
|
+
const auth = this.#config.auth;
|
|
1013
|
+
const captcha = require_url.isRecord$1(auth) ? auth.captcha : void 0;
|
|
1014
|
+
if (!captcha) return void 0;
|
|
1015
|
+
this.#configCaptchaSpent = true;
|
|
1016
|
+
return captcha;
|
|
1017
|
+
}
|
|
967
1018
|
/** Спрашивает у сервера активного провайдера и поле, в котором он ждёт токен. */
|
|
968
1019
|
async #resolveCaptchaProvider() {
|
|
969
1020
|
return readCaptchaProvider(await this.#http.execute(AUTH_CAPTCHA_PROVIDER, {
|
|
@@ -973,7 +1024,7 @@ var AuthManager = class {
|
|
|
973
1024
|
}));
|
|
974
1025
|
}
|
|
975
1026
|
async #performSignIn(credentials, revision) {
|
|
976
|
-
const captcha = await
|
|
1027
|
+
const captcha = await this.captchaBody();
|
|
977
1028
|
const flowCookies = new require_redact.CookieJar();
|
|
978
1029
|
const result = await this.#http.execute(AUTH_SIGN_IN, {
|
|
979
1030
|
path: AUTH_PATHS.signIn,
|
|
@@ -1154,7 +1205,8 @@ var AuthResource = class extends require_render.BaseResource {
|
|
|
1154
1205
|
if (existing) return existing;
|
|
1155
1206
|
const flow = {
|
|
1156
1207
|
cookies: this.#auth.createCookieFlow(false),
|
|
1157
|
-
expiresAt: void 0
|
|
1208
|
+
expiresAt: void 0,
|
|
1209
|
+
captchaRequired: false
|
|
1158
1210
|
};
|
|
1159
1211
|
this.#qrFlows.set(qrId, flow);
|
|
1160
1212
|
return flow;
|
|
@@ -1192,6 +1244,21 @@ var AuthResource = class extends require_render.BaseResource {
|
|
|
1192
1244
|
...options
|
|
1193
1245
|
});
|
|
1194
1246
|
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Узнаёт активного провайдера капчи вместе с адресом страницы виджета.
|
|
1249
|
+
*
|
|
1250
|
+
* То же, что {@link captchaProvider}, плюс `url` — готовая страница на домене итд.com,
|
|
1251
|
+
* где ключ виджета действителен. Пригодится встроенному браузеру: открыть её и забрать
|
|
1252
|
+
* токен, ничего не собирая самому.
|
|
1253
|
+
*/
|
|
1254
|
+
captchaPage(options = {}) {
|
|
1255
|
+
return this.http.execute(AUTH_CAPTCHA_PAGE, {
|
|
1256
|
+
path: AUTH_PATHS.captchaPage,
|
|
1257
|
+
skipAuth: true,
|
|
1258
|
+
skipAuthRefresh: true,
|
|
1259
|
+
...options
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1195
1262
|
/** Создаёт короткоживущую сессию QR-входа. */
|
|
1196
1263
|
async startQrLogin(options = {}) {
|
|
1197
1264
|
const cookies = this.#auth.createCookieFlow(false);
|
|
@@ -1205,7 +1272,8 @@ var AuthResource = class extends require_render.BaseResource {
|
|
|
1205
1272
|
if (typeof result.qrId === "string" && result.qrId !== "") {
|
|
1206
1273
|
const flow = {
|
|
1207
1274
|
cookies,
|
|
1208
|
-
expiresAt: void 0
|
|
1275
|
+
expiresAt: void 0,
|
|
1276
|
+
captchaRequired: false
|
|
1209
1277
|
};
|
|
1210
1278
|
this.#touchQrFlow(flow, result.expiresIn);
|
|
1211
1279
|
this.#qrFlows.set(result.qrId, flow);
|
|
@@ -1215,20 +1283,21 @@ var AuthResource = class extends require_render.BaseResource {
|
|
|
1215
1283
|
/**
|
|
1216
1284
|
* Проверяет QR-сессию и завершает вход после подтверждения на другом устройстве.
|
|
1217
1285
|
*
|
|
1218
|
-
* До подтверждения возвращает промежуточный статус.
|
|
1219
|
-
*
|
|
1220
|
-
* Полученный `accessToken` автоматически сохраняется в клиенте.
|
|
1286
|
+
* До подтверждения возвращает промежуточный статус. Токен капчи добывается, только когда
|
|
1287
|
+
* сервер о ней попросил — статусом `captcha_required` на прошлой проверке, — либо когда
|
|
1288
|
+
* передан в сам вызов. Полученный `accessToken` автоматически сохраняется в клиенте.
|
|
1221
1289
|
*/
|
|
1222
1290
|
async claimQrLogin(input, options = {}) {
|
|
1223
1291
|
const revision = this.#auth.revision();
|
|
1224
1292
|
const flow = this.#qrFlow(input.qrId);
|
|
1225
1293
|
try {
|
|
1226
1294
|
const { captcha, ...rest } = input;
|
|
1295
|
+
const needsCaptcha = captcha !== void 0 || flow.captchaRequired;
|
|
1227
1296
|
const result = await this.http.execute(AUTH_QR_CLAIM, {
|
|
1228
1297
|
path: AUTH_PATHS.qrClaim,
|
|
1229
1298
|
body: {
|
|
1230
1299
|
...rest,
|
|
1231
|
-
...
|
|
1300
|
+
...needsCaptcha ? await this.#auth.captchaBody(captcha) : {}
|
|
1232
1301
|
},
|
|
1233
1302
|
skipAuth: true,
|
|
1234
1303
|
skipAuthRefresh: true,
|
|
@@ -1236,6 +1305,7 @@ var AuthResource = class extends require_render.BaseResource {
|
|
|
1236
1305
|
...options
|
|
1237
1306
|
});
|
|
1238
1307
|
this.#touchQrFlow(flow, result.expiresIn);
|
|
1308
|
+
if (result.status === QrLoginStatus.CaptchaRequired) flow.captchaRequired = true;
|
|
1239
1309
|
if (result.status === QrLoginStatus.Authorized) {
|
|
1240
1310
|
await this.#auth.commitAuthFlow(result.accessToken, flow.cookies, revision);
|
|
1241
1311
|
this.#qrFlows.delete(input.qrId);
|
|
@@ -1267,17 +1337,62 @@ var AuthResource = class extends require_render.BaseResource {
|
|
|
1267
1337
|
}
|
|
1268
1338
|
}
|
|
1269
1339
|
/**
|
|
1340
|
+
* Отмечает QR-код отсканированным и узнаёт, кого впускают.
|
|
1341
|
+
*
|
|
1342
|
+
* Обратная сторона QR-входа: этот и два соседних метода вызывает устройство, где сессия
|
|
1343
|
+
* уже есть. Показывающая сторона увидит статус `scanned`, но вход ещё не состоится —
|
|
1344
|
+
* его завершают {@link approveQrLogin} или {@link rejectQrLogin}.
|
|
1345
|
+
*
|
|
1346
|
+
* Сервер принимает только сессию, созданную мобильным клиентом. Обычный web access token
|
|
1347
|
+
* отклоняется с кодом `QR_APPROVER_NOT_ALLOWED`, даже если добавить мобильные заголовки
|
|
1348
|
+
* уже после выдачи токена.
|
|
1349
|
+
*
|
|
1350
|
+
* @param input секреты из отсканированного кода — см. {@link QrLoginSecrets}
|
|
1351
|
+
* @returns описание устройства, которое просит вход
|
|
1352
|
+
*/
|
|
1353
|
+
scanQrLogin(input, options = {}) {
|
|
1354
|
+
return this.http.execute(AUTH_QR_SCAN, {
|
|
1355
|
+
path: AUTH_PATHS.qrScan,
|
|
1356
|
+
body: input,
|
|
1357
|
+
...options
|
|
1358
|
+
});
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* Подтверждает вход по QR-коду: показавшее код устройство получит access token.
|
|
1362
|
+
*
|
|
1363
|
+
* Осмысленно после {@link scanQrLogin} — человек должен увидеть, что подтверждает.
|
|
1364
|
+
* Требует мобильную сессию, как и `scanQrLogin()`.
|
|
1365
|
+
*/
|
|
1366
|
+
approveQrLogin(input, options = {}) {
|
|
1367
|
+
return this.voidOperation(AUTH_QR_APPROVE, {
|
|
1368
|
+
path: AUTH_PATHS.qrApprove,
|
|
1369
|
+
body: input,
|
|
1370
|
+
...options
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
/**
|
|
1374
|
+
* Отклоняет вход по QR-коду: показавшее код устройство получит статус `rejected`.
|
|
1375
|
+
* Требует мобильную сессию, как и `scanQrLogin()`.
|
|
1376
|
+
*/
|
|
1377
|
+
rejectQrLogin(input, options = {}) {
|
|
1378
|
+
return this.voidOperation(AUTH_QR_REJECT, {
|
|
1379
|
+
path: AUTH_PATHS.qrReject,
|
|
1380
|
+
body: input,
|
|
1381
|
+
...options
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1270
1385
|
* Регистрирует аккаунт и запускает подтверждение по коду.
|
|
1271
1386
|
*
|
|
1272
1387
|
* @returns `flowToken`, который нужно передать в {@link verifyOtp}
|
|
1273
1388
|
*/
|
|
1274
|
-
signUp(credentials, options = {}) {
|
|
1389
|
+
async signUp(credentials, options = {}) {
|
|
1275
1390
|
const { captcha, ...rest } = credentials;
|
|
1276
1391
|
return this.http.execute(AUTH_SIGN_UP, {
|
|
1277
1392
|
path: AUTH_PATHS.signUp,
|
|
1278
1393
|
body: {
|
|
1279
1394
|
...rest,
|
|
1280
|
-
...captchaBody(captcha)
|
|
1395
|
+
...await this.#auth.captchaBody(captcha)
|
|
1281
1396
|
},
|
|
1282
1397
|
skipAuth: true,
|
|
1283
1398
|
skipAuthRefresh: true,
|
|
@@ -1292,18 +1407,19 @@ var AuthResource = class extends require_render.BaseResource {
|
|
|
1292
1407
|
*
|
|
1293
1408
|
* При успешном входе токен сохраняется в клиенте автоматически.
|
|
1294
1409
|
*
|
|
1295
|
-
* @param credentials email, пароль и
|
|
1410
|
+
* @param credentials email, пароль и токен капчи — см. {@link CredentialsWithCaptcha}
|
|
1296
1411
|
*/
|
|
1297
1412
|
async signIn(credentials, options = {}) {
|
|
1298
1413
|
const { captcha, ...rest } = credentials;
|
|
1299
1414
|
const revision = this.#auth.revision();
|
|
1300
1415
|
const cookies = this.#auth.createCookieFlow(false);
|
|
1416
|
+
const body = {
|
|
1417
|
+
...rest,
|
|
1418
|
+
...await this.#auth.captchaBody(captcha)
|
|
1419
|
+
};
|
|
1301
1420
|
const result = await this.http.execute(AUTH_SIGN_IN, {
|
|
1302
1421
|
path: AUTH_PATHS.signIn,
|
|
1303
|
-
body
|
|
1304
|
-
...rest,
|
|
1305
|
-
...captchaBody(captcha)
|
|
1306
|
-
},
|
|
1422
|
+
body,
|
|
1307
1423
|
skipAuth: true,
|
|
1308
1424
|
skipAuthRefresh: true,
|
|
1309
1425
|
cookieJar: cookies,
|
|
@@ -1431,12 +1547,12 @@ var AuthResource = class extends require_render.BaseResource {
|
|
|
1431
1547
|
*
|
|
1432
1548
|
* @returns `flowToken`, который нужно передать в {@link resetPassword}
|
|
1433
1549
|
*/
|
|
1434
|
-
forgotPassword(input, options = {}) {
|
|
1550
|
+
async forgotPassword(input, options = {}) {
|
|
1435
1551
|
return this.http.execute(AUTH_FORGOT_PASSWORD, {
|
|
1436
1552
|
path: AUTH_PATHS.forgotPassword,
|
|
1437
1553
|
body: {
|
|
1438
1554
|
email: input.email,
|
|
1439
|
-
...captchaBody(input.captcha)
|
|
1555
|
+
...await this.#auth.captchaBody(input.captcha)
|
|
1440
1556
|
},
|
|
1441
1557
|
skipAuth: true,
|
|
1442
1558
|
skipAuthRefresh: true,
|
|
@@ -1571,8 +1687,9 @@ function createManagedClient(options, internals) {
|
|
|
1571
1687
|
* const itd = new ItdClient({
|
|
1572
1688
|
* // `auth` не обязателен: когда хранилище уже содержит сессию, токен берётся оттуда,
|
|
1573
1689
|
* // а истёкший продлевается сам. Здесь он нужен на первый запуск.
|
|
1574
|
-
*
|
|
1575
|
-
*
|
|
1690
|
+
* auth: { email, password },
|
|
1691
|
+
* // Капчу входа решает пакет @itd-api/captcha — см. CaptchaSolver.
|
|
1692
|
+
* captcha: createCaptchaSolver(),
|
|
1576
1693
|
* storage: new FileTokenStorage('./.itd-session.json'),
|
|
1577
1694
|
* rateLimit: { concurrency: 4, rps: 8 },
|
|
1578
1695
|
* });
|
|
@@ -2086,6 +2203,8 @@ function assertAccountsActive(accounts, action) {
|
|
|
2086
2203
|
*
|
|
2087
2204
|
* await using accounts = new ItdAccounts({
|
|
2088
2205
|
* storage: new FileMultiTokenStorage('./.itd-sessions.json'),
|
|
2206
|
+
* // Общие опции достаются каждому аккаунту: один источник токена капчи на всех.
|
|
2207
|
+
* captcha: createCaptchaSolver(),
|
|
2089
2208
|
* rateLimit: { concurrency: 4 },
|
|
2090
2209
|
* });
|
|
2091
2210
|
*
|
|
@@ -2093,9 +2212,7 @@ function assertAccountsActive(accounts, action) {
|
|
|
2093
2212
|
* await accounts.restore();
|
|
2094
2213
|
*
|
|
2095
2214
|
* if (!accounts.has('kiow')) {
|
|
2096
|
-
* accounts.addAccount('kiow', {
|
|
2097
|
-
* auth: { email, password, captcha: createCaptchaSolver() },
|
|
2098
|
-
* });
|
|
2215
|
+
* accounts.addAccount('kiow', { auth: { email, password } });
|
|
2099
2216
|
* }
|
|
2100
2217
|
*
|
|
2101
2218
|
* await accounts.account('kiow').posts.create({ content: 'привет' });
|
|
@@ -2174,9 +2291,7 @@ var ItdAccounts = class ItdAccounts {
|
|
|
2174
2291
|
*
|
|
2175
2292
|
* @example
|
|
2176
2293
|
* ```ts
|
|
2177
|
-
* accounts.addAccount('bot', {
|
|
2178
|
-
* auth: { email, password, captcha: createCaptchaSolver() },
|
|
2179
|
-
* });
|
|
2294
|
+
* accounts.addAccount('bot', { auth: { email, password } });
|
|
2180
2295
|
* accounts.addAccount('reader', { auth: '<accessToken>' });
|
|
2181
2296
|
* accounts.addAccount('через-прокси', { fetch: proxyFetch('socks5://…') });
|
|
2182
2297
|
* ```
|
|
@@ -2567,6 +2682,7 @@ exports.NotificationUpdateType = require_events.NotificationUpdateType;
|
|
|
2567
2682
|
exports.OPERATIONS = require_url.OPERATIONS;
|
|
2568
2683
|
exports.PaginationMode = require_render.PaginationMode;
|
|
2569
2684
|
exports.Paginator = require_render.Paginator;
|
|
2685
|
+
exports.QrLocationPrecision = require_url.QrLocationPrecision;
|
|
2570
2686
|
exports.QrLoginStatus = QrLoginStatus;
|
|
2571
2687
|
exports.QrLoginStreamStatus = QrLoginStreamStatus;
|
|
2572
2688
|
exports.RateLimitPacing = require_url.RateLimitPacing;
|