itd-api 0.12.1 → 0.13.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.
- package/dist/events/index.cjs +4 -4
- package/dist/events/index.d.cts +7 -2
- package/dist/events/index.d.ts +7 -2
- package/dist/events/index.js +4 -4
- package/dist/index.cjs +672 -90
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +497 -46
- package/dist/index.d.ts +497 -46
- package/dist/index.js +664 -91
- package/dist/index.js.map +1 -1
- package/dist/node/index.cjs +6 -7
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +24 -7
- package/dist/node/index.d.ts +24 -7
- package/dist/node/index.js +6 -7
- package/dist/node/index.js.map +1 -1
- package/dist/rest/index.cjs +19 -7
- package/dist/rest/index.cjs.map +1 -1
- package/dist/rest/index.d.cts +28 -7
- package/dist/rest/index.d.ts +28 -7
- package/dist/rest/index.js +17 -8
- package/dist/rest/index.js.map +1 -1
- package/dist/shared/{contracts-BoT7msmq.d.ts → contracts-DEbkC0cB.d.cts} +1 -4
- package/dist/shared/{contracts-BoT7msmq.d.cts → contracts-pxnDIsQP.d.ts} +1 -4
- package/dist/shared/{events-FaXfdle0.d.cts → events-B6uqXOSs.d.cts} +42 -63
- package/dist/shared/{events-_iYo8EP5.js → events-C_MgYlXR.js} +30 -40
- package/dist/shared/events-C_MgYlXR.js.map +1 -0
- package/dist/shared/{events-BKyxZQNw.cjs → events-DV1i1t6J.cjs} +30 -40
- package/dist/shared/events-DV1i1t6J.cjs.map +1 -0
- package/dist/shared/{events-9215JDDd.d.ts → events-D_aMNrPd.d.ts} +2 -23
- package/dist/shared/{key-value-store-DYSPsqwq.cjs → key-value-store-6DHm_iNW.cjs} +3 -4
- package/dist/shared/{key-value-store-DYSPsqwq.cjs.map → key-value-store-6DHm_iNW.cjs.map} +1 -1
- package/dist/shared/{key-value-store-COZaNHZS.d.ts → key-value-store-BGoSgLze.d.cts} +1 -4
- package/dist/shared/{key-value-store-w1Dn5Pjb.js → key-value-store-PnZE_DFC.js} +3 -4
- package/dist/shared/{key-value-store-w1Dn5Pjb.js.map → key-value-store-PnZE_DFC.js.map} +1 -1
- package/dist/shared/{key-value-store-COZaNHZS.d.cts → key-value-store-WUQBeTAr.d.ts} +1 -4
- package/dist/shared/{multi-storage-DiBSx64p.js → multi-storage-DM0skcSO.js} +6 -7
- package/dist/shared/{multi-storage-DiBSx64p.js.map → multi-storage-DM0skcSO.js.map} +1 -1
- package/dist/shared/{multi-storage-LkljOSzA.d.ts → multi-storage-DQiERirK.d.ts} +3 -6
- package/dist/shared/{multi-storage-7Y3KCseI.cjs → multi-storage-DnonVBfO.cjs} +6 -7
- package/dist/shared/multi-storage-DnonVBfO.cjs.map +1 -0
- package/dist/shared/{multi-storage-BEL7tcKn.d.cts → multi-storage-OGWNMK3x.d.cts} +3 -6
- package/dist/shared/{options-D5ttspWk.cjs → options-SvAWOaqT.cjs} +8 -12
- package/dist/shared/{options-D5ttspWk.cjs.map → options-SvAWOaqT.cjs.map} +1 -1
- package/dist/shared/{options-DLlaETn_.js → options-bS27r_gR.js} +8 -12
- package/dist/shared/{options-DLlaETn_.js.map → options-bS27r_gR.js.map} +1 -1
- package/dist/shared/{redact-DSfdmeY7.js → redact-C4b2NzdB.js} +16 -16
- package/dist/shared/redact-C4b2NzdB.js.map +1 -0
- package/dist/shared/{redact-BbhtA9o-.cjs → redact-DDGkv8KF.cjs} +16 -16
- package/dist/shared/redact-DDGkv8KF.cjs.map +1 -0
- package/dist/shared/{render-BQvC5UxF.cjs → render-0-JJPOwb.cjs} +204 -109
- package/dist/shared/render-0-JJPOwb.cjs.map +1 -0
- package/dist/shared/{render-CFoF2WaH.js → render-CF49aBO8.js} +181 -110
- package/dist/shared/render-CF49aBO8.js.map +1 -0
- package/dist/shared/{render-X2JCo1JS.d.cts → render-CYVOc_IW.d.cts} +152 -251
- package/dist/shared/{render-BS09ygcy.d.ts → render-eOxYgdoA.d.ts} +152 -102
- package/dist/shared/{storage-86wiHeXD.js → storage-B6OkSi38.js} +4 -5
- package/dist/shared/{storage-86wiHeXD.js.map → storage-B6OkSi38.js.map} +1 -1
- package/dist/shared/{storage-CTRGT5wF.d.ts → storage-C_ZujAZt.d.ts} +2 -5
- package/dist/shared/{storage-CIjejZDt.cjs → storage-CezF2Mvz.cjs} +4 -5
- package/dist/shared/{storage-CIjejZDt.cjs.map → storage-CezF2Mvz.cjs.map} +1 -1
- package/dist/shared/{storage-BQrtKon9.d.cts → storage-FtS4NIC7.d.cts} +2 -5
- package/dist/shared/{url-CdT4lMxQ.js → url-CPKhcxf1.js} +250 -91
- package/dist/shared/url-CPKhcxf1.js.map +1 -0
- package/dist/shared/{url-_R0oJ7gE.d.ts → url-DCqxoxGX.d.cts} +1903 -1623
- package/dist/shared/{url-_R0oJ7gE.d.cts → url-DL5Mip4L.d.ts} +209 -78
- package/dist/shared/{url-ioIaywDi.cjs → url-DOfjru6L.cjs} +250 -91
- package/dist/shared/url-DOfjru6L.cjs.map +1 -0
- package/dist/shared/{validate-D7_kq3g5.js → validate-B5l_vLKD.js} +5 -7
- package/dist/shared/validate-B5l_vLKD.js.map +1 -0
- package/dist/shared/{validate-CFx2dISs.cjs → validate-CfxCK1BC.cjs} +5 -7
- package/dist/shared/validate-CfxCK1BC.cjs.map +1 -0
- package/dist/web/index.cjs +4 -5
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.d.cts +22 -5
- package/dist/web/index.d.ts +22 -5
- package/dist/web/index.js +4 -5
- package/dist/web/index.js.map +1 -1
- package/package.json +6 -6
- package/dist/shared/events-BKyxZQNw.cjs.map +0 -1
- package/dist/shared/events-_iYo8EP5.js.map +0 -1
- package/dist/shared/multi-storage-7Y3KCseI.cjs.map +0 -1
- package/dist/shared/redact-BbhtA9o-.cjs.map +0 -1
- package/dist/shared/redact-DSfdmeY7.js.map +0 -1
- package/dist/shared/render-BQvC5UxF.cjs.map +0 -1
- package/dist/shared/render-CFoF2WaH.js.map +0 -1
- package/dist/shared/url-CdT4lMxQ.js.map +0 -1
- package/dist/shared/url-ioIaywDi.cjs.map +0 -1
- package/dist/shared/validate-CFx2dISs.cjs.map +0 -1
- package/dist/shared/validate-D7_kq3g5.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { $ as OperationMethod, A as ReportTargetType, B as isBuiltInOperationId, C as ItdErrorCode, D as NotificationType, E as MessageAccess, F as ViewSource, G as DEFAULT_RATE_LIMIT_BUCKET, H as operationMethod, I as WallAccess, J as pickArray, K as createClientRuntime, L as ITD_CATALOG, M as SpanType, N as UsernameUnavailableReason, O as QrLocationPrecision, P as ViewReason, Q as pickString, R as OPERATIONS, S as InteractionType, T as LikesVisibility, U as operationRetrySafety, V as operationBucket, W as BUCKET_LIMITS, _ as CaptchaType, _t as systemClock, at as requestAbortError, b as FeedTab, c as normalizeNotification, ct as assertPluginRemovable, d as canonicalNotificationType, et as RetrySafety, f as isKnownNotificationType, ft as STATUS_SERVICE, g as CaptchaField, h as CaptchaChoice, ht as RateLimitPacing, it as createRequestAbortScope, j as ServiceState, k as ReportReason, lt as orderPluginDefinitions, m as AttachmentType, mt as LIBRARY_VERSION, n as formatNotificationText, o as passthroughOperation, p as AccessType, pt as resolveRateLimit, q as createApiError, s as voidOperation, st as RequestQueuePool, t as resolveNotificationUrl, ut as DEFAULT_BASE_URL, v as CommentSort, vt as installAsyncDisposeFallback, w as LastSeenUnit, x as IncidentKind, y as EventChannelStatus, z as defineBuiltInOperation } from "./shared/url-
|
|
2
|
-
import { A as isItdForbiddenError, C as ItdValidationError, D as isItdConflictError, E as isItdAuthError, F as isItdStateError, I as isItdValidationError, M as isItdPhoneVerificationError, N as isItdRateLimitError, O as isItdError, P as isItdServerError, S as ItdTimeoutError, T as isItdApiError, _ as ItdNotFoundError, a as ItdAbortError, b as ItdServerError, c as ItdAuthError, d as ItdError, f as ItdErrorKind, g as ItdNetworkError, h as ItdForbiddenError, i as requireOptionalBoolean, j as isItdNotFoundError, k as isItdFileError, l as ItdConfigError, m as ItdFileErrorReason, n as isRecord, o as ItdApiError, p as ItdFileError, s as ItdApiErrorKind, t as isObjectLike, u as ItdConflictError, v as ItdPhoneVerificationError, w as TimeoutBudget, x as ItdStateError, y as ItdRateLimitError } from "./shared/validate-
|
|
3
|
-
import { D as
|
|
4
|
-
import {
|
|
5
|
-
import { c as
|
|
6
|
-
import {
|
|
7
|
-
import { a as
|
|
8
|
-
import {
|
|
9
|
-
import { a as
|
|
10
|
-
|
|
1
|
+
import { $ as OperationMethod, A as ReportTargetType, B as isBuiltInOperationId, C as ItdErrorCode, D as NotificationType, E as MessageAccess, F as ViewSource, G as DEFAULT_RATE_LIMIT_BUCKET, H as operationMethod, I as WallAccess, J as pickArray, K as createClientRuntime, L as ITD_CATALOG, M as SpanType, N as UsernameUnavailableReason, O as QrLocationPrecision, P as ViewReason, Q as pickString, R as OPERATIONS, S as InteractionType, T as LikesVisibility, U as operationRetrySafety, V as operationBucket, W as BUCKET_LIMITS, _ as CaptchaType, _t as systemClock, at as requestAbortError, b as FeedTab, c as normalizeNotification, ct as assertPluginRemovable, d as canonicalNotificationType, et as RetrySafety, f as isKnownNotificationType, ft as STATUS_SERVICE, g as CaptchaField, h as CaptchaChoice, ht as RateLimitPacing, it as createRequestAbortScope, j as ServiceState, k as ReportReason, lt as orderPluginDefinitions, m as AttachmentType, mt as LIBRARY_VERSION, n as formatNotificationText, o as passthroughOperation, p as AccessType, pt as resolveRateLimit, q as createApiError, s as voidOperation, st as RequestQueuePool, t as resolveNotificationUrl, ut as DEFAULT_BASE_URL, v as CommentSort, vt as installAsyncDisposeFallback, w as LastSeenUnit, x as IncidentKind, y as EventChannelStatus, z as defineBuiltInOperation } from "./shared/url-CPKhcxf1.js";
|
|
2
|
+
import { A as isItdForbiddenError, C as ItdValidationError, D as isItdConflictError, E as isItdAuthError, F as isItdStateError, I as isItdValidationError, M as isItdPhoneVerificationError, N as isItdRateLimitError, O as isItdError, P as isItdServerError, S as ItdTimeoutError, T as isItdApiError, _ as ItdNotFoundError, a as ItdAbortError, b as ItdServerError, c as ItdAuthError, d as ItdError, f as ItdErrorKind, g as ItdNetworkError, h as ItdForbiddenError, i as requireOptionalBoolean, j as isItdNotFoundError, k as isItdFileError, l as ItdConfigError, m as ItdFileErrorReason, n as isRecord, o as ItdApiError, p as ItdFileError, s as ItdApiErrorKind, t as isObjectLike, u as ItdConflictError, v as ItdPhoneVerificationError, w as TimeoutBudget, x as ItdStateError, y as ItdRateLimitError } from "./shared/validate-B5l_vLKD.js";
|
|
3
|
+
import { A as isBuilder, B as createFeatureHost, C as LegalDocumentBlockType, D as IMAGE_MIME_TYPES, E as AUDIO_MIME_TYPES, F as NotificationsResource, I as BaseResource, L as PaginationMode, M as toDate, N as utcStampToIso, O as VIDEO_MIME_TYPES, P as AccountLifecycleResource, R as Paginator, S as parseMarkdown, T as ALLOWED_MIME_TYPES, V as ExtensibleOperationCatalog, _ as post, a as createShopOrderAccessStorage, b as markup, c as ShopOrderStatus, d as isMyProfile, f as BannerDrawingTool, g as report, h as createResources, i as MemoryShopOrderAccessStorage, j as createStatusFeature, k as comment, l as ShopProductCategory, m as fromUrl, n as renderSpans, o as statusDays, p as fromStream, r as createShopFeature, s as ShopConsentKind, t as SpanRenderFormat, u as ShopProductStatus, v as poll, w as LegalDocumentScope, x as parseHtml, y as autoSpans, z as mapPage } from "./shared/render-CF49aBO8.js";
|
|
4
|
+
import { _ as Emitter, a as WebSocketTransport, c as NotificationEventsTransport, d as NotificationUpdateOrigin, f as NotificationUpdateType, g as runEventMiddleware, h as UnauthorizedStreamError, i as createNotificationEventsClient, l as resolveNotificationEventsOptions, m as EventChannel, n as EventRouter, o as EVENT_OPERATIONS, p as createParser, r as NotificationEventsClient, s as NotificationEvents, t as EventComposer, u as setNotificationEventsConnectGuard, v as reportListenerError } from "./shared/events-C_MgYlXR.js";
|
|
5
|
+
import { D as fallbackLogger, E as LogLevel, c as REFRESH_COOKIE, f as encodePathSegment, h as joinUrl, k as resolveLogger, l as REFRESH_COOKIE_PATH, s as CookieJar, u as isSerializedCookieEntry, v as RuntimeMode, y as createDeviceId } from "./shared/redact-C4b2NzdB.js";
|
|
6
|
+
import { n as copySession, r as createTokenStorage, t as MemoryTokenStorage } from "./shared/storage-B6OkSi38.js";
|
|
7
|
+
import { a as scopedTokenStorage, i as isRestorableSession, n as controlledTokenStorage, r as createMultiTokenStorage, t as MemoryMultiTokenStorage } from "./shared/multi-storage-DM0skcSO.js";
|
|
8
|
+
import { c as FileTransferMode } from "./shared/options-bS27r_gR.js";
|
|
9
|
+
import { a as isEnumerableKeyValueStore, i as createRecordKeyValueStore, o as withCodec, r as createKeyValueStore, s as withNamespace, t as MemoryKeyValueStore } from "./shared/key-value-store-PnZE_DFC.js";
|
|
10
|
+
// src/notifications-api.ts
|
|
11
11
|
var ClientNotifications = class extends NotificationsResource {
|
|
12
12
|
#createEvents;
|
|
13
13
|
#events;
|
|
@@ -24,8 +24,384 @@ var ClientNotifications = class extends NotificationsResource {
|
|
|
24
24
|
function createNotificationsApi(http, createEvents) {
|
|
25
25
|
return new ClientNotifications(http, createEvents);
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
// src/operations/account.ts
|
|
28
|
+
const ACCOUNT_GET_INFO = passthroughOperation("account.getInfo");
|
|
29
|
+
const ACCOUNT_PASSWORD_SET = voidOperation("account.password.set");
|
|
30
|
+
const ACCOUNT_PASSWORD_CHANGE = voidOperation("account.password.change");
|
|
31
|
+
// src/operations/account/changes.ts
|
|
32
|
+
const ACCOUNT_CHANGES_REQUEST_PROOF = passthroughOperation("account.changes.requestProof");
|
|
33
|
+
const ACCOUNT_CHANGES_CONFIRM = voidOperation("account.changes.confirm");
|
|
34
|
+
const ACCOUNT_CHANGES_WAIT = passthroughOperation("account.changes.wait");
|
|
35
|
+
const ACCOUNT_CHANGES_PENDING = defineBuiltInOperation("account.changes.pending", (body) => pickArray(body, "requests"));
|
|
36
|
+
const ACCOUNT_CHANGES_CANCEL_PENDING = voidOperation("account.changes.cancelPending");
|
|
37
|
+
// src/resources/account/request.ts
|
|
38
|
+
/** Выполняет запрос настройки способов входа с текущей авторизацией. */
|
|
39
|
+
function requestAccount(http, operation, path, body, options) {
|
|
40
|
+
const reverse = path.startsWith("/phone/reverse/");
|
|
41
|
+
return http.execute(operation, {
|
|
42
|
+
...options,
|
|
43
|
+
path: `/api/v1/auth${path}`,
|
|
44
|
+
body,
|
|
45
|
+
headers: {
|
|
46
|
+
...options.headers,
|
|
47
|
+
...operation.method === "POST" ? { "X-ITD-Phone-Reverse": "1" } : {},
|
|
48
|
+
...reverse ? { "X-ITD-Reverse-Attempts": "1" } : {}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
// src/resources/account/changes.ts
|
|
53
|
+
/** Завершение смены номера или почты и управление отложенными заявками. */
|
|
54
|
+
var AccountChangesResource = class extends BaseResource {
|
|
55
|
+
/**
|
|
56
|
+
* Запрашивает код на привязанный номер или почту.
|
|
57
|
+
*
|
|
58
|
+
* Возьмите `changeToken` и способ доставки из результата `verifyChange()` или
|
|
59
|
+
* `phone.reverseChangeComplete()`. Полученный код передайте в {@link confirm}.
|
|
60
|
+
*/
|
|
61
|
+
requestProof(input, options = {}) {
|
|
62
|
+
return requestAccount(this.http, ACCOUNT_CHANGES_REQUEST_PROOF, "/change/proof", input, options);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Завершает смену номера или почты.
|
|
66
|
+
*
|
|
67
|
+
* Передайте `changeToken` и код из {@link requestProof} либо облачный
|
|
68
|
+
* пароль, если сервер предложил такой способ подтверждения.
|
|
69
|
+
*/
|
|
70
|
+
confirm(input, options = {}) {
|
|
71
|
+
return requestAccount(this.http, ACCOUNT_CHANGES_CONFIRM, "/change/confirm", input, options);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Создаёт отложенную заявку на смену номера или почты.
|
|
75
|
+
*
|
|
76
|
+
* @returns время применения заявки. До этого её можно отменить через {@link cancelPending}
|
|
77
|
+
*/
|
|
78
|
+
wait(changeToken, options = {}) {
|
|
79
|
+
return requestAccount(this.http, ACCOUNT_CHANGES_WAIT, "/change/wait", { changeToken }, options);
|
|
80
|
+
}
|
|
81
|
+
/** Возвращает отложенные заявки текущего аккаунта. */
|
|
82
|
+
pending(options = {}) {
|
|
83
|
+
return requestAccount(this.http, ACCOUNT_CHANGES_PENDING, "/change/pending", void 0, options);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Отменяет отложенную смену.
|
|
87
|
+
*
|
|
88
|
+
* @param requestId идентификатор заявки из {@link pending}
|
|
89
|
+
*/
|
|
90
|
+
cancelPending(requestId, options = {}) {
|
|
91
|
+
return requestAccount(this.http, ACCOUNT_CHANGES_CANCEL_PENDING, `/change/pending/${encodePathSegment(requestId, "requestId")}`, void 0, options);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
// src/operations/account/email.ts
|
|
95
|
+
/** Извлекает токен для подтверждения адреса почты. */
|
|
96
|
+
function readEmailFlow(body) {
|
|
97
|
+
const flowToken = pickString(body, "flowToken");
|
|
98
|
+
if (!flowToken) throw new ItdConfigError("Сервер не вернул flowToken для подтверждения почты");
|
|
99
|
+
return flowToken;
|
|
100
|
+
}
|
|
101
|
+
const ACCOUNT_EMAIL_ATTACH = defineBuiltInOperation("account.email.attach", readEmailFlow);
|
|
102
|
+
const ACCOUNT_EMAIL_START_CHANGE = defineBuiltInOperation("account.email.startChange", readEmailFlow);
|
|
103
|
+
const ACCOUNT_EMAIL_RESEND_OTP = voidOperation("account.email.resendOtp");
|
|
104
|
+
// src/models/phone-auth.ts
|
|
105
|
+
/** Назначение контекста согласия телефонного входа. @internal */
|
|
106
|
+
const PHONE_CONSENT_FLOW = "phone_entry";
|
|
107
|
+
/** Назначение ответа общего endpoint подтверждения кода. */
|
|
108
|
+
const AuthVerificationMode = Object.freeze({
|
|
109
|
+
SignIn: "signin",
|
|
110
|
+
Change: "change"
|
|
111
|
+
});
|
|
112
|
+
/** Серверные каналы доставки кода. */
|
|
113
|
+
const PhoneDeliveryChannel = Object.freeze({
|
|
114
|
+
MissedCall: "missed_call",
|
|
115
|
+
VoiceCall: "voice_call",
|
|
116
|
+
Sms: "sms",
|
|
117
|
+
Push: "push"
|
|
118
|
+
});
|
|
119
|
+
/** Подтверждение входящим кодом либо исходящим звонком пользователя. */
|
|
120
|
+
const PhoneVerificationMethod = Object.freeze({
|
|
121
|
+
Direct: "direct",
|
|
122
|
+
Reverse: "reverse"
|
|
123
|
+
});
|
|
124
|
+
/** Продолжение телефонного входа, ещё не выдавшее access token. */
|
|
125
|
+
const PhoneLoginStep = Object.freeze({ Password: "password" });
|
|
126
|
+
/** Состояния подтверждения номера исходящим звонком. */
|
|
127
|
+
const PhoneReverseState = Object.freeze({
|
|
128
|
+
NotStarted: "not_started",
|
|
129
|
+
Preparing: "preparing",
|
|
130
|
+
Waiting: "waiting",
|
|
131
|
+
Confirmed: "confirmed",
|
|
132
|
+
Expired: "expired",
|
|
133
|
+
Failed: "failed"
|
|
134
|
+
});
|
|
135
|
+
// src/operations/account/verification.ts
|
|
136
|
+
/** Отделяет ответ смены контакта от результата входа на общем маршруте подтверждения. */
|
|
137
|
+
function readContactChange(body) {
|
|
138
|
+
const changeToken = pickString(body, "changeToken");
|
|
139
|
+
if (!isRecord(body) || body.mode !== void 0 && body.mode !== AuthVerificationMode.Change || !changeToken) throw new ItdConfigError("Сервер не вернул подтверждение смены контакта");
|
|
140
|
+
return {
|
|
141
|
+
changeToken,
|
|
142
|
+
proofs: pickArray(body, "proofs"),
|
|
143
|
+
...typeof body.waitDays === "number" ? { waitDays: body.waitDays } : {}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
const ACCOUNT_VERIFY_ATTACH = passthroughOperation("account.verifyAttach");
|
|
147
|
+
const ACCOUNT_VERIFY_CHANGE = defineBuiltInOperation("account.verifyChange", (body) => {
|
|
148
|
+
if (!isRecord(body) || body.mode !== AuthVerificationMode.Change) throw new ItdConfigError("Сервер не вернул режим смены контакта");
|
|
149
|
+
return readContactChange(body);
|
|
150
|
+
});
|
|
151
|
+
const ACCOUNT_PHONE_REVERSE_ATTACH_COMPLETE = passthroughOperation("account.phone.reverseAttachComplete");
|
|
152
|
+
const ACCOUNT_PHONE_REVERSE_CHANGE_COMPLETE = defineBuiltInOperation("account.phone.reverseChangeComplete", readContactChange);
|
|
153
|
+
// src/resources/account/email.ts
|
|
154
|
+
/** Привязка и смена почты текущего аккаунта. */
|
|
155
|
+
var AccountEmailResource = class extends BaseResource {
|
|
156
|
+
/**
|
|
157
|
+
* Отправляет код на почту для привязки.
|
|
158
|
+
*
|
|
159
|
+
* @returns значение `flowToken` для {@link verifyAttach} или {@link resendOtp}
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* const flowToken = await itd.account.email.attach(email);
|
|
164
|
+
* await itd.account.email.verifyAttach({ email, flowToken, otp: await getOtp() });
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
attach(email, options = {}) {
|
|
168
|
+
return requestAccount(this.http, ACCOUNT_EMAIL_ATTACH, "/email/attach", { email }, options);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Отправляет код на новый адрес почты.
|
|
172
|
+
*
|
|
173
|
+
* @returns значение `flowToken` для {@link verifyChange} или {@link resendOtp}
|
|
174
|
+
*/
|
|
175
|
+
startChange(email, options = {}) {
|
|
176
|
+
return requestAccount(this.http, ACCOUNT_EMAIL_START_CHANGE, "/email/change", { email }, options);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Завершает привязку почты кодом.
|
|
180
|
+
*
|
|
181
|
+
* Передайте тот же адрес и `flowToken` из {@link attach}.
|
|
182
|
+
*/
|
|
183
|
+
verifyAttach(input, options = {}) {
|
|
184
|
+
return requestAccount(this.http, ACCOUNT_VERIFY_ATTACH, "/verify-otp", input, options);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Подтверждает код новой почты, запрошенный через {@link startChange}.
|
|
188
|
+
*
|
|
189
|
+
* @returns `changeToken` и способы завершить смену через `itd.account.changes`
|
|
190
|
+
*/
|
|
191
|
+
verifyChange(input, options = {}) {
|
|
192
|
+
return requestAccount(this.http, ACCOUNT_VERIFY_CHANGE, "/verify-otp", input, options);
|
|
193
|
+
}
|
|
194
|
+
/** Повторно отправляет код на тот же адрес. Передайте `flowToken` из первого запроса. */
|
|
195
|
+
resendOtp(input, options = {}) {
|
|
196
|
+
return requestAccount(this.http, ACCOUNT_EMAIL_RESEND_OTP, "/resend-otp", input, options);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
// src/resources/account/password.ts
|
|
200
|
+
/** Облачный пароль текущего аккаунта. */
|
|
201
|
+
var AccountPasswordResource = class extends BaseResource {
|
|
202
|
+
/**
|
|
203
|
+
* Создаёт облачный пароль для аккаунта без пароля.
|
|
204
|
+
*
|
|
205
|
+
* Наличие пароля можно проверить через `itd.account.getInfo()`.
|
|
206
|
+
*/
|
|
207
|
+
set(password, options = {}) {
|
|
208
|
+
return requestAccount(this.http, ACCOUNT_PASSWORD_SET, "/set-password", { password }, options);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Меняет облачный пароль в действующей сессии.
|
|
212
|
+
*
|
|
213
|
+
* При неверном текущем пароле сервер возвращает `ACCOUNT_CURRENT_PASSWORD_INCORRECT`.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```ts
|
|
217
|
+
* await itd.account.password.change({ currentPassword, newPassword });
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
change({ currentPassword, newPassword }, options = {}) {
|
|
221
|
+
return this.voidOperation(ACCOUNT_PASSWORD_CHANGE, {
|
|
222
|
+
path: "/api/v1/auth/change-password",
|
|
223
|
+
body: {
|
|
224
|
+
currentPassword,
|
|
225
|
+
newPassword
|
|
226
|
+
},
|
|
227
|
+
...options
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
// src/operations/phone-flow.ts
|
|
232
|
+
/** Приводит вложенные и плоские параметры доставки к одному результату. */
|
|
233
|
+
function readPhoneDelivery(body) {
|
|
234
|
+
const response = body;
|
|
235
|
+
const next = response.next ?? response.nextChannel;
|
|
236
|
+
return {
|
|
237
|
+
channel: response.delivery?.type ?? response.channel,
|
|
238
|
+
codeLength: response.delivery?.codeLength ?? response.codeLength,
|
|
239
|
+
retryIn: response.retryIn,
|
|
240
|
+
...response.reverseOnly === true ? { reverseOnly: true } : {},
|
|
241
|
+
nextChannel: next ?? null
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
/** Извлекает `flowToken` и параметры доставки после запуска проверки номера. */
|
|
245
|
+
function readPhoneStart(body) {
|
|
246
|
+
const flowToken = pickString(body, "flowToken");
|
|
247
|
+
if (!flowToken) throw new ItdConfigError("Сервер не вернул flowToken для проверки номера");
|
|
248
|
+
return {
|
|
249
|
+
...readPhoneDelivery(body),
|
|
250
|
+
flowToken
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
// src/operations/account/phone.ts
|
|
254
|
+
const ACCOUNT_PHONE_ATTACH = defineBuiltInOperation("account.phone.attach", readPhoneStart);
|
|
255
|
+
const ACCOUNT_PHONE_START_CHANGE = defineBuiltInOperation("account.phone.startChange", readPhoneStart);
|
|
256
|
+
const ACCOUNT_PHONE_RESEND_OTP = defineBuiltInOperation("account.phone.resendOtp", readPhoneDelivery);
|
|
257
|
+
const ACCOUNT_PHONE_SYNC = passthroughOperation("account.phone.sync");
|
|
258
|
+
const ACCOUNT_PHONE_REVERSE_OPTIONS = passthroughOperation("account.phone.reverseOptions");
|
|
259
|
+
const ACCOUNT_PHONE_REVERSE_START = passthroughOperation("account.phone.reverseStart");
|
|
260
|
+
const ACCOUNT_PHONE_REVERSE_STATUS = passthroughOperation("account.phone.reverseStatus");
|
|
261
|
+
// src/resources/account/phone.ts
|
|
262
|
+
/** Привязка и смена номера текущего аккаунта. */
|
|
263
|
+
var AccountPhoneResource = class extends BaseResource {
|
|
264
|
+
#auth;
|
|
265
|
+
constructor(http, auth) {
|
|
266
|
+
super(http);
|
|
267
|
+
this.#auth = auth;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Запрашивает подтверждение номера для привязки.
|
|
271
|
+
*
|
|
272
|
+
* Передайте номер в международном формате с `+`. Если токен капчи не передан
|
|
273
|
+
* в вызов, SDK использует настроенный источник капчи.
|
|
274
|
+
*
|
|
275
|
+
* @returns параметры доставки и `flowToken` для {@link verifyAttach}
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```ts
|
|
279
|
+
* const { flowToken } = await itd.account.phone.attach({ phone });
|
|
280
|
+
* await itd.account.phone.verifyAttach({ phone, flowToken, otp: await getOtp() });
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
attach(input, options = {}) {
|
|
284
|
+
return this.#start(ACCOUNT_PHONE_ATTACH, "/phone/attach", input, options);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Запрашивает подтверждение нового номера для смены.
|
|
288
|
+
*
|
|
289
|
+
* Формат номера и источник капчи такие же, как у {@link attach}.
|
|
290
|
+
*
|
|
291
|
+
* @returns параметры доставки и `flowToken` для {@link verifyChange}
|
|
292
|
+
*/
|
|
293
|
+
startChange(input, options = {}) {
|
|
294
|
+
return this.#start(ACCOUNT_PHONE_START_CHANGE, "/phone/change", input, options);
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Завершает привязку номера кодом.
|
|
298
|
+
*
|
|
299
|
+
* Передайте номер и `flowToken` из {@link attach}.
|
|
300
|
+
*/
|
|
301
|
+
verifyAttach(input, options = {}) {
|
|
302
|
+
return requestAccount(this.http, ACCOUNT_VERIFY_ATTACH, "/verify-otp", input, options);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Подтверждает код нового номера, запрошенный через {@link startChange}.
|
|
306
|
+
*
|
|
307
|
+
* @returns `changeToken` и способы завершить смену через `itd.account.changes`
|
|
308
|
+
*/
|
|
309
|
+
verifyChange(input, options = {}) {
|
|
310
|
+
return requestAccount(this.http, ACCOUNT_VERIFY_CHANGE, "/verify-otp", input, options);
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Повторно запрашивает код для того же номера. Передайте `flowToken` из первого запроса.
|
|
314
|
+
*
|
|
315
|
+
* @returns актуальные канал, длину кода и паузу до повтора в секундах
|
|
316
|
+
*/
|
|
317
|
+
resendOtp(input, options = {}) {
|
|
318
|
+
return requestAccount(this.http, ACCOUNT_PHONE_RESEND_OTP, "/resend-otp", input, options);
|
|
319
|
+
}
|
|
320
|
+
/** Синхронизирует привязанный номер с профилем. */
|
|
321
|
+
sync(options = {}) {
|
|
322
|
+
return requestAccount(this.http, ACCOUNT_PHONE_SYNC, "/phone/sync", {}, options);
|
|
323
|
+
}
|
|
324
|
+
/** Возвращает доступность исходящего звонка для привязки или смены номера. */
|
|
325
|
+
reverseOptions(input, options = {}) {
|
|
326
|
+
return requestAccount(this.http, ACCOUNT_PHONE_REVERSE_OPTIONS, "/phone/reverse/options", input, options);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Подготавливает номер, на который должен позвонить пользователь.
|
|
330
|
+
*
|
|
331
|
+
* @returns состояние попытки, номер для звонка и срок действия в секундах
|
|
332
|
+
*/
|
|
333
|
+
reverseStart(input, options = {}) {
|
|
334
|
+
return requestAccount(this.http, ACCOUNT_PHONE_REVERSE_START, "/phone/reverse/start", input, options);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Читает состояние исходящего звонка.
|
|
338
|
+
*
|
|
339
|
+
* После подтверждения вызовите {@link reverseAttachComplete} при привязке
|
|
340
|
+
* или {@link reverseChangeComplete} при смене номера.
|
|
341
|
+
*/
|
|
342
|
+
reverseStatus(input, options = {}) {
|
|
343
|
+
return requestAccount(this.http, ACCOUNT_PHONE_REVERSE_STATUS, "/phone/reverse/status", input, options);
|
|
344
|
+
}
|
|
345
|
+
/** Завершает привязку номера после исходящего звонка. */
|
|
346
|
+
reverseAttachComplete(input, options = {}) {
|
|
347
|
+
return requestAccount(this.http, ACCOUNT_PHONE_REVERSE_ATTACH_COMPLETE, "/phone/reverse/complete", input, options);
|
|
348
|
+
}
|
|
349
|
+
/** Подтверждает новый номер звонком и возвращает варианты завершения смены. */
|
|
350
|
+
reverseChangeComplete(input, options = {}) {
|
|
351
|
+
return requestAccount(this.http, ACCOUNT_PHONE_REVERSE_CHANGE_COMPLETE, "/phone/reverse/complete", input, options);
|
|
352
|
+
}
|
|
353
|
+
/** Запускает проверку номера, если за время получения капчи сессия не сменилась. */
|
|
354
|
+
async #start(operation, path, { phone, captcha }, options) {
|
|
355
|
+
const revision = this.#auth.revision();
|
|
356
|
+
const proof = await this.#auth.captchaToken(captcha);
|
|
357
|
+
if (this.#auth.revision() !== revision) throw new ItdStateError("Сессия сменилась во время получения капчи. Начните проверку номера заново.");
|
|
358
|
+
return requestAccount(this.http, operation, path, {
|
|
359
|
+
phone,
|
|
360
|
+
captcha: proof ? {
|
|
361
|
+
provider: proof.type,
|
|
362
|
+
token: proof.token
|
|
363
|
+
} : void 0
|
|
364
|
+
}, options);
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
// src/resources/account.ts
|
|
368
|
+
/**
|
|
369
|
+
* Настройки текущего аккаунта. Доступен как `itd.account`.
|
|
370
|
+
*
|
|
371
|
+
* Здесь можно менять номер, почту и облачный пароль, управлять отложенными
|
|
372
|
+
* заявками, деактивировать и восстановить аккаунт.
|
|
373
|
+
*/
|
|
374
|
+
var AccountResource = class extends AccountLifecycleResource {
|
|
375
|
+
/** Привязка и смена номера. */
|
|
376
|
+
phone;
|
|
377
|
+
/** Привязка и смена почты. */
|
|
378
|
+
email;
|
|
379
|
+
/** Настройка облачного пароля. */
|
|
380
|
+
password;
|
|
381
|
+
/** Завершение смены номера или почты и отложенные заявки. */
|
|
382
|
+
changes;
|
|
383
|
+
constructor(http, auth) {
|
|
384
|
+
super(http);
|
|
385
|
+
this.phone = new AccountPhoneResource(http, auth);
|
|
386
|
+
this.email = new AccountEmailResource(http);
|
|
387
|
+
this.password = new AccountPasswordResource(http);
|
|
388
|
+
this.changes = new AccountChangesResource(http);
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Получает сведения о доступе к текущему аккаунту.
|
|
392
|
+
*
|
|
393
|
+
* @returns привязанные номер и почту и признак наличия облачного пароля
|
|
394
|
+
*
|
|
395
|
+
* @example
|
|
396
|
+
* ```ts
|
|
397
|
+
* const { email, phone, hasPassword } = await itd.account.getInfo();
|
|
398
|
+
* ```
|
|
399
|
+
*/
|
|
400
|
+
getInfo(options = {}) {
|
|
401
|
+
return requestAccount(this.http, ACCOUNT_GET_INFO, "/methods", void 0, options);
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
// src/operations/auth.ts
|
|
29
405
|
/** Чем закончился запрос входа. */
|
|
30
406
|
const SignInStatus = Object.freeze({
|
|
31
407
|
Authenticated: "authenticated",
|
|
@@ -61,8 +437,8 @@ function requireString(body, key, message) {
|
|
|
61
437
|
return value;
|
|
62
438
|
}
|
|
63
439
|
const AUTH_CHECK = passthroughOperation("auth.check");
|
|
64
|
-
passthroughOperation("auth.captchaProvider");
|
|
65
|
-
passthroughOperation("auth.captchaPage");
|
|
440
|
+
const AUTH_CAPTCHA_PROVIDER = passthroughOperation("auth.captchaProvider");
|
|
441
|
+
const AUTH_CAPTCHA_PAGE = passthroughOperation("auth.captchaPage");
|
|
66
442
|
const AUTH_SIGN_UP = defineBuiltInOperation("auth.signUp", (body) => requireString(body, "flowToken", "Сервер не вернул flowToken при регистрации"));
|
|
67
443
|
const AUTH_SIGN_IN = defineBuiltInOperation("auth.signIn", (body) => {
|
|
68
444
|
const accessToken = pickString(body, "accessToken");
|
|
@@ -80,7 +456,6 @@ const AUTH_RESEND_OTP = voidOperation("auth.resendOtp");
|
|
|
80
456
|
const AUTH_LOGOUT = voidOperation("auth.logout");
|
|
81
457
|
const AUTH_FORGOT_PASSWORD = defineBuiltInOperation("auth.forgotPassword", (body) => requireString(body, "flowToken", "Сервер не вернул flowToken при запросе сброса пароля"));
|
|
82
458
|
const AUTH_RESET_PASSWORD = voidOperation("auth.resetPassword");
|
|
83
|
-
const AUTH_CHANGE_PASSWORD = voidOperation("auth.changePassword");
|
|
84
459
|
const AUTH_SESSIONS = defineBuiltInOperation("auth.sessions", (body) => pickArray(body, "sessions"));
|
|
85
460
|
const AUTH_REVOKE_SESSION = voidOperation("auth.revokeSession");
|
|
86
461
|
const AUTH_REVOKE_OTHER_SESSIONS = voidOperation("auth.revokeOtherSessions");
|
|
@@ -89,8 +464,7 @@ const AUTH_QR_CLAIM = passthroughOperation("auth.qrClaim");
|
|
|
89
464
|
const AUTH_QR_SCAN = passthroughOperation("auth.qrScan");
|
|
90
465
|
const AUTH_QR_APPROVE = voidOperation("auth.qrApprove");
|
|
91
466
|
const AUTH_QR_REJECT = voidOperation("auth.qrReject");
|
|
92
|
-
|
|
93
|
-
//#region src/session/captcha.ts
|
|
467
|
+
// src/session/captcha.ts
|
|
94
468
|
function requireCaptchaText(value, field) {
|
|
95
469
|
if (value !== void 0 && (typeof value !== "string" || value.trim() === "")) throw new ItdConfigError(`${field} должен быть непустой строкой`);
|
|
96
470
|
}
|
|
@@ -126,6 +500,17 @@ function validateCaptchaToken(captcha, path) {
|
|
|
126
500
|
if (typeof type !== "string" || type.trim() === "") throw new ItdConfigError(`${path}.type должен быть непустой строкой`);
|
|
127
501
|
requireCaptchaText(field, `${path}.field`);
|
|
128
502
|
}
|
|
503
|
+
/** Разбирает ответ `GET /api/v1/auth/captcha/provider` для автоматического входа. */
|
|
504
|
+
function readCaptchaProvider(body) {
|
|
505
|
+
const config = isRecord(body) ? body : void 0;
|
|
506
|
+
const provider = config?.provider;
|
|
507
|
+
const field = config?.field;
|
|
508
|
+
if (typeof provider !== "string" || provider.trim() === "" || typeof field !== "string" || field.trim() === "") throw new ItdConfigError("Сервер вернул неподдерживаемую конфигурацию капчи");
|
|
509
|
+
return {
|
|
510
|
+
provider,
|
|
511
|
+
field
|
|
512
|
+
};
|
|
513
|
+
}
|
|
129
514
|
/** Куда класть токен: настройка, иначе умолчание провайдера. */
|
|
130
515
|
function resolveField(type, configured) {
|
|
131
516
|
const field = configured ?? CAPTCHA_FIELDS[type];
|
|
@@ -138,37 +523,30 @@ async function requireSolvedToken(solver, type, context) {
|
|
|
138
523
|
if (typeof token === "string" && token.trim() !== "") return token;
|
|
139
524
|
throw new ItdConfigError(`Источник капчи не вернул токен для провайдера «${type}». Проверьте captcha.getToken.`);
|
|
140
525
|
}
|
|
141
|
-
/**
|
|
142
|
-
|
|
143
|
-
*
|
|
144
|
-
* При `CaptchaChoice.Auto` провайдер спрашивается у сервера — тогда и тип виджета,
|
|
145
|
-
* и имя поля приходят оттуда. Явно названный тип обходится без этого запроса.
|
|
146
|
-
*
|
|
147
|
-
* @param askProvider как спросить активного провайдера; вызывается, только если это нужно
|
|
148
|
-
* @param context что источник получает вместе с типом капчи
|
|
149
|
-
* @throws {ItdConfigError} если токен получить не удалось
|
|
150
|
-
*/
|
|
151
|
-
async function solveCaptchaBody(solver, askProvider, context) {
|
|
526
|
+
/** Сохраняет провайдера и токен для API, принимающих доказательство капчи объектом. */
|
|
527
|
+
async function solveCaptchaToken(solver, askProvider, context) {
|
|
152
528
|
const choice = solver.type ?? CaptchaChoice.Auto;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
return {
|
|
529
|
+
const { provider, field } = choice === CaptchaChoice.Auto ? await askProvider() : {
|
|
530
|
+
provider: choice,
|
|
531
|
+
field: solver.field
|
|
532
|
+
};
|
|
533
|
+
return {
|
|
534
|
+
type: provider,
|
|
535
|
+
field,
|
|
536
|
+
token: await requireSolvedToken(solver, provider, context)
|
|
537
|
+
};
|
|
158
538
|
}
|
|
159
539
|
/**
|
|
160
540
|
* Готовит фрагмент тела из готового токена.
|
|
161
541
|
*
|
|
162
542
|
* Поле берётся из самого токена либо из умолчания провайдера; запроса к серверу нет.
|
|
163
543
|
*
|
|
164
|
-
* @throws {ItdConfigError} если
|
|
544
|
+
* @throws {ItdConfigError} если для провайдера не определено поле запроса
|
|
165
545
|
*/
|
|
166
546
|
function captchaBody(captcha) {
|
|
167
|
-
validateCaptchaToken(captcha, "captcha");
|
|
168
547
|
return { [resolveField(captcha.type, captcha.field)]: captcha.token };
|
|
169
548
|
}
|
|
170
|
-
|
|
171
|
-
//#region src/session/jwt.ts
|
|
549
|
+
// src/session/jwt.ts
|
|
172
550
|
/**
|
|
173
551
|
* Разбирает строку base64url.
|
|
174
552
|
*
|
|
@@ -207,8 +585,7 @@ function readTokenMetadata(token) {
|
|
|
207
585
|
...expiresAt !== void 0 && Number.isFinite(expiresAt) ? { expiresAt } : {}
|
|
208
586
|
};
|
|
209
587
|
}
|
|
210
|
-
|
|
211
|
-
//#region src/session/auth.ts
|
|
588
|
+
// src/session/auth.ts
|
|
212
589
|
/** Запас до истечения токена на очередь и выполнение запроса. */
|
|
213
590
|
const ACCESS_TOKEN_REFRESH_LEEWAY_MS = 3e4;
|
|
214
591
|
/**
|
|
@@ -300,7 +677,6 @@ const AUTH_PATHS = {
|
|
|
300
677
|
logout: "/api/v1/auth/logout",
|
|
301
678
|
forgotPassword: "/api/v1/auth/forgot-password",
|
|
302
679
|
resetPassword: "/api/v1/auth/reset-password",
|
|
303
|
-
changePassword: "/api/v1/auth/change-password",
|
|
304
680
|
sessions: "/api/v1/auth/sessions",
|
|
305
681
|
qrStart: "/api/v1/auth/qr/start",
|
|
306
682
|
qrClaim: "/api/v1/auth/qr/claim",
|
|
@@ -992,13 +1368,20 @@ var AuthManager = class {
|
|
|
992
1368
|
* @throws {ItdConfigError} если токен неполный или источник его не вернул
|
|
993
1369
|
*/
|
|
994
1370
|
async captchaBody(explicit) {
|
|
995
|
-
|
|
1371
|
+
const token = await this.captchaToken(explicit);
|
|
1372
|
+
return token ? captchaBody(token) : {};
|
|
1373
|
+
}
|
|
1374
|
+
/** Доказательство капчи с провайдером для телефонного API. @internal */
|
|
1375
|
+
async captchaToken(explicit) {
|
|
1376
|
+
if (explicit) {
|
|
1377
|
+
validateCaptchaToken(explicit, "captcha");
|
|
1378
|
+
return explicit;
|
|
1379
|
+
}
|
|
996
1380
|
const configured = this.#takeConfiguredCaptcha();
|
|
997
|
-
if (configured) return
|
|
1381
|
+
if (configured) return configured;
|
|
998
1382
|
const solver = this.#config.captcha;
|
|
999
|
-
if (solver) return
|
|
1383
|
+
if (solver) return solveCaptchaToken(solver, () => this.#resolveCaptchaProvider(), { logger: this.#config.logger });
|
|
1000
1384
|
this.#config.logger?.debug("Запрос уходит без токена капчи: не передан аргумент captcha и не задана опция captcha");
|
|
1001
|
-
return {};
|
|
1002
1385
|
}
|
|
1003
1386
|
/** Отдаёт разовый токен из `auth.captcha`, помечая его потраченным. */
|
|
1004
1387
|
#takeConfiguredCaptcha() {
|
|
@@ -1011,10 +1394,22 @@ var AuthManager = class {
|
|
|
1011
1394
|
}
|
|
1012
1395
|
/** Спрашивает у сервера активного провайдера и поле, в котором он ждёт токен. */
|
|
1013
1396
|
async #resolveCaptchaProvider() {
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1397
|
+
try {
|
|
1398
|
+
return readCaptchaProvider(await this.#http.execute(AUTH_CAPTCHA_PROVIDER, {
|
|
1399
|
+
path: AUTH_PATHS.captchaProvider,
|
|
1400
|
+
skipAuth: true,
|
|
1401
|
+
skipAuthRefresh: true
|
|
1402
|
+
}));
|
|
1403
|
+
} catch (error) {
|
|
1404
|
+
if (isItdApiError(error) && error.status === 404 && error.code === ItdErrorCode.NOT_FOUND) {
|
|
1405
|
+
this.#config.logger?.warn("Сервер отключил определение провайдера капчи; используется Cloudflare Turnstile");
|
|
1406
|
+
return {
|
|
1407
|
+
provider: CaptchaType.Cloudflare,
|
|
1408
|
+
field: CaptchaField.Cloudflare
|
|
1409
|
+
};
|
|
1410
|
+
}
|
|
1411
|
+
throw error;
|
|
1412
|
+
}
|
|
1018
1413
|
}
|
|
1019
1414
|
async #performSignIn(credentials, revision) {
|
|
1020
1415
|
const captcha = await this.captchaBody();
|
|
@@ -1053,8 +1448,7 @@ var AuthManager = class {
|
|
|
1053
1448
|
return userId ? `: пользователь ${userId}` : "";
|
|
1054
1449
|
}
|
|
1055
1450
|
};
|
|
1056
|
-
|
|
1057
|
-
//#region src/session/qr-stream.ts
|
|
1451
|
+
// src/session/qr-stream.ts
|
|
1058
1452
|
const QR_STREAM_STATUSES = new Set(Object.values(QrLoginStreamStatus));
|
|
1059
1453
|
function readQrLoginStreamEvent(data) {
|
|
1060
1454
|
let value;
|
|
@@ -1170,8 +1564,184 @@ async function openQrLoginStream(connection, cookies, input, onEvent, signal) {
|
|
|
1170
1564
|
abort.cleanup();
|
|
1171
1565
|
}
|
|
1172
1566
|
}
|
|
1173
|
-
|
|
1174
|
-
|
|
1567
|
+
// src/operations/auth/phone.ts
|
|
1568
|
+
/** Отклоняет неизвестный контракт до принятия результата входа. */
|
|
1569
|
+
function invalidResponse() {
|
|
1570
|
+
throw new ItdConfigError("Сервер вернул неподдерживаемый ответ телефонного входа");
|
|
1571
|
+
}
|
|
1572
|
+
/** Требует непустой секрет для продолжения телефонного потока. */
|
|
1573
|
+
function readFlowToken(body) {
|
|
1574
|
+
const value = pickString(body, "flowToken");
|
|
1575
|
+
if (!value) return invalidResponse();
|
|
1576
|
+
return value;
|
|
1577
|
+
}
|
|
1578
|
+
/** Разделяет access token и шаг пароля; режимы привязки/смены контакта не принимает. */
|
|
1579
|
+
function readLoginResult(body) {
|
|
1580
|
+
if (!isRecord(body)) return invalidResponse();
|
|
1581
|
+
if (body.mode !== void 0 && body.mode !== AuthVerificationMode.SignIn) return invalidResponse();
|
|
1582
|
+
const accessToken = pickString(body, "accessToken");
|
|
1583
|
+
if (accessToken) return { accessToken };
|
|
1584
|
+
if (body.step === PhoneLoginStep.Password) return {
|
|
1585
|
+
step: PhoneLoginStep.Password,
|
|
1586
|
+
flowToken: readFlowToken(body)
|
|
1587
|
+
};
|
|
1588
|
+
return invalidResponse();
|
|
1589
|
+
}
|
|
1590
|
+
/** Для завершения по паролю промежуточный шаг вместо access token недопустим. */
|
|
1591
|
+
function readAccessToken(body) {
|
|
1592
|
+
const result = readLoginResult(body);
|
|
1593
|
+
if (!("accessToken" in result)) return invalidResponse();
|
|
1594
|
+
return result.accessToken;
|
|
1595
|
+
}
|
|
1596
|
+
const AUTH_PHONE_CONFIG = passthroughOperation("auth.phone.config");
|
|
1597
|
+
const AUTH_PHONE_CONSENT = passthroughOperation("auth.phone.consent");
|
|
1598
|
+
const AUTH_PHONE_START = defineBuiltInOperation("auth.phone.start", readPhoneStart);
|
|
1599
|
+
const AUTH_PHONE_VERIFY = defineBuiltInOperation("auth.phone.verify", readLoginResult);
|
|
1600
|
+
const AUTH_PHONE_PASSWORD = defineBuiltInOperation("auth.phone.password", readAccessToken);
|
|
1601
|
+
const AUTH_PHONE_RESET_PASSWORD = defineBuiltInOperation("auth.phone.resetPassword", readAccessToken);
|
|
1602
|
+
const AUTH_PHONE_RESEND = defineBuiltInOperation("auth.phone.resend", readPhoneDelivery);
|
|
1603
|
+
const AUTH_PHONE_REVERSE_OPTIONS = passthroughOperation("auth.phone.reverseOptions");
|
|
1604
|
+
const AUTH_PHONE_REVERSE_START = passthroughOperation("auth.phone.reverseStart");
|
|
1605
|
+
const AUTH_PHONE_REVERSE_STATUS = passthroughOperation("auth.phone.reverseStatus");
|
|
1606
|
+
const AUTH_PHONE_REVERSE_COMPLETE = defineBuiltInOperation("auth.phone.reverseComplete", readLoginResult);
|
|
1607
|
+
// src/resources/auth/phone.ts
|
|
1608
|
+
/** Телефонный вход и регистрация. Доступен как `itd.auth.phone`. */
|
|
1609
|
+
var PhoneAuthResource = class extends BaseResource {
|
|
1610
|
+
#auth;
|
|
1611
|
+
constructor(http, deps) {
|
|
1612
|
+
super(http);
|
|
1613
|
+
this.#auth = deps.auth;
|
|
1614
|
+
}
|
|
1615
|
+
/** Разрешённые регионы и примеры номеров. */
|
|
1616
|
+
config(options = {}) {
|
|
1617
|
+
return this.#request(AUTH_PHONE_CONFIG, "/phone/config", void 0, options);
|
|
1618
|
+
}
|
|
1619
|
+
/**
|
|
1620
|
+
* Загружает контекст phone_entry вместе с текстом и редакциями документов.
|
|
1621
|
+
*
|
|
1622
|
+
* До start() покажите документы пользователю. Истёкший контекст и новые редакции
|
|
1623
|
+
* библиотека не заменяет автоматически.
|
|
1624
|
+
*/
|
|
1625
|
+
consent(options = {}) {
|
|
1626
|
+
return this.#request(AUTH_PHONE_CONSENT, `/consent?flow=${PHONE_CONSENT_FLOW}`, void 0, options);
|
|
1627
|
+
}
|
|
1628
|
+
/**
|
|
1629
|
+
* Запрашивает подтверждение номера для входа или регистрации.
|
|
1630
|
+
*
|
|
1631
|
+
* Токен капчи отправляется объектом { provider, token }.
|
|
1632
|
+
*
|
|
1633
|
+
* @returns `flowToken` для продолжения входа, канал доставки, длина кода и пауза повтора в секундах
|
|
1634
|
+
*/
|
|
1635
|
+
async start(input, options = {}) {
|
|
1636
|
+
const captcha = await this.#auth.captchaToken(input.captcha);
|
|
1637
|
+
return this.#request(AUTH_PHONE_START, "/phone/start", {
|
|
1638
|
+
phone: input.phone,
|
|
1639
|
+
captcha: captcha ? {
|
|
1640
|
+
provider: captcha.type,
|
|
1641
|
+
token: captcha.token
|
|
1642
|
+
} : void 0,
|
|
1643
|
+
legal: {
|
|
1644
|
+
protocolVersion: input.consent.protocolVersion,
|
|
1645
|
+
contextToken: input.consent.contextToken
|
|
1646
|
+
}
|
|
1647
|
+
}, {
|
|
1648
|
+
...options,
|
|
1649
|
+
headers: {
|
|
1650
|
+
...options.headers,
|
|
1651
|
+
...input.method === PhoneVerificationMethod.Reverse ? { "X-ITD-Phone-Method": PhoneVerificationMethod.Reverse } : {}
|
|
1652
|
+
}
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
/**
|
|
1656
|
+
* Подтверждает код без email и пароля.
|
|
1657
|
+
*
|
|
1658
|
+
* При accessToken сохраняет новую сессию; при step: 'password' возвращает секрет
|
|
1659
|
+
* для password().
|
|
1660
|
+
*/
|
|
1661
|
+
verify(input, options = {}) {
|
|
1662
|
+
return this.#complete(AUTH_PHONE_VERIFY, "/verify-otp", input, options);
|
|
1663
|
+
}
|
|
1664
|
+
/**
|
|
1665
|
+
* Запрашивает повторную доставку без изменения авторизации.
|
|
1666
|
+
*
|
|
1667
|
+
* Используйте новый channel/codeLength из результата: способ доставки может измениться.
|
|
1668
|
+
* retryIn — секунды до следующего запроса.
|
|
1669
|
+
*/
|
|
1670
|
+
resend(input, options = {}) {
|
|
1671
|
+
return this.#request(AUTH_PHONE_RESEND, "/resend-otp", input, options);
|
|
1672
|
+
}
|
|
1673
|
+
/**
|
|
1674
|
+
* Завершает вход облачным паролем после step: 'password'.
|
|
1675
|
+
*
|
|
1676
|
+
* Передайте flowToken из этого шага. Полученный access token и cookies сохраняются
|
|
1677
|
+
* автоматически, если владелец сессии не сменился во время запроса.
|
|
1678
|
+
*/
|
|
1679
|
+
password(input, options = {}) {
|
|
1680
|
+
return this.#authenticate(AUTH_PHONE_PASSWORD, "/phone/password", input, options);
|
|
1681
|
+
}
|
|
1682
|
+
/** Устанавливает новый пароль после подтверждения номера и сохраняет сессию. */
|
|
1683
|
+
resetPassword(input, options = {}) {
|
|
1684
|
+
return this.#authenticate(AUTH_PHONE_RESET_PASSWORD, "/phone/reset-password", input, options);
|
|
1685
|
+
}
|
|
1686
|
+
/** Проверяет, доступен ли исходящий звонок для подтверждения номера. */
|
|
1687
|
+
reverseOptions(input, options = {}) {
|
|
1688
|
+
return this.#request(AUTH_PHONE_REVERSE_OPTIONS, "/phone/reverse/options", input, options);
|
|
1689
|
+
}
|
|
1690
|
+
/**
|
|
1691
|
+
* Подготавливает номер, на который пользователь должен позвонить.
|
|
1692
|
+
*
|
|
1693
|
+
* Может выделить новую попытку; не повторяется после сетевых ошибок и 5xx. Номер и срок
|
|
1694
|
+
* его действия возвращаются в phone и expiresIn.
|
|
1695
|
+
*/
|
|
1696
|
+
reverseStart(input, options = {}) {
|
|
1697
|
+
return this.#request(AUTH_PHONE_REVERSE_START, "/phone/reverse/start", input, options);
|
|
1698
|
+
}
|
|
1699
|
+
/** Читает состояние звонка через POST, без завершения входа и смены сессии. */
|
|
1700
|
+
reverseStatus(input, options = {}) {
|
|
1701
|
+
return this.#request(AUTH_PHONE_REVERSE_STATUS, "/phone/reverse/status", input, options);
|
|
1702
|
+
}
|
|
1703
|
+
/** Завершает подтверждённый звонок; сервер может потребовать облачный пароль. */
|
|
1704
|
+
reverseComplete(input, options = {}) {
|
|
1705
|
+
return this.#complete(AUTH_PHONE_REVERSE_COMPLETE, "/phone/reverse/complete", input, options);
|
|
1706
|
+
}
|
|
1707
|
+
/** Применяет cookies промежуточного шага либо атомарно сохраняет завершённый вход. */
|
|
1708
|
+
async #complete(operation, path, input, options) {
|
|
1709
|
+
const revision = this.#auth.revision();
|
|
1710
|
+
const cookies = this.#auth.createCookieFlow();
|
|
1711
|
+
const result = await this.#request(operation, path, input, options, cookies);
|
|
1712
|
+
if ("accessToken" in result) await this.#auth.commitAuthFlow(result.accessToken, cookies, revision);
|
|
1713
|
+
else this.#auth.commitCookieFlow(cookies, revision);
|
|
1714
|
+
return result;
|
|
1715
|
+
}
|
|
1716
|
+
/** Сохраняет результат пароля, не позволяя запоздалому ответу сменить нового владельца. */
|
|
1717
|
+
async #authenticate(operation, path, input, options) {
|
|
1718
|
+
const revision = this.#auth.revision();
|
|
1719
|
+
const cookies = this.#auth.createCookieFlow();
|
|
1720
|
+
const token = await this.#request(operation, path, input, options, cookies);
|
|
1721
|
+
await this.#auth.commitAuthFlow(token, cookies, revision);
|
|
1722
|
+
return token;
|
|
1723
|
+
}
|
|
1724
|
+
/**
|
|
1725
|
+
* Выполняет телефонный запрос без Bearer/refresh через общий pipeline.
|
|
1726
|
+
* X-ITD-Phone-Reverse объявляет поддержку обратного звонка и требуется для reverse-операций.
|
|
1727
|
+
*/
|
|
1728
|
+
#request(operation, path, body, options, cookies) {
|
|
1729
|
+
return this.http.execute(operation, {
|
|
1730
|
+
...options,
|
|
1731
|
+
path: `/api/v1/auth${path}`,
|
|
1732
|
+
body,
|
|
1733
|
+
...cookies ? { cookieJar: cookies } : {},
|
|
1734
|
+
skipAuth: true,
|
|
1735
|
+
skipAuthRefresh: true,
|
|
1736
|
+
headers: {
|
|
1737
|
+
...options.headers,
|
|
1738
|
+
...operation.method === "POST" ? { "X-ITD-Phone-Reverse": "1" } : {},
|
|
1739
|
+
...path.startsWith("/phone/reverse/") ? { "X-ITD-Reverse-Attempts": "1" } : {}
|
|
1740
|
+
}
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
};
|
|
1744
|
+
// src/resources/auth.ts
|
|
1175
1745
|
/**
|
|
1176
1746
|
* Результат входа.
|
|
1177
1747
|
*
|
|
@@ -1184,6 +1754,8 @@ async function openQrLoginStream(connection, cookies, input, onEvent, signal) {
|
|
|
1184
1754
|
* Доступна как `itd.auth`.
|
|
1185
1755
|
*/
|
|
1186
1756
|
var AuthResource = class extends BaseResource {
|
|
1757
|
+
/** Вход и регистрация по номеру телефона. */
|
|
1758
|
+
phone;
|
|
1187
1759
|
#auth;
|
|
1188
1760
|
#connection;
|
|
1189
1761
|
#qrFlows = /* @__PURE__ */ new Map();
|
|
@@ -1191,6 +1763,7 @@ var AuthResource = class extends BaseResource {
|
|
|
1191
1763
|
super(http);
|
|
1192
1764
|
this.#auth = deps.auth;
|
|
1193
1765
|
this.#connection = deps.connection;
|
|
1766
|
+
this.phone = new PhoneAuthResource(http, deps);
|
|
1194
1767
|
}
|
|
1195
1768
|
#pruneQrFlows() {
|
|
1196
1769
|
const now = this.#connection.clock.now();
|
|
@@ -1232,13 +1805,13 @@ var AuthResource = class extends BaseResource {
|
|
|
1232
1805
|
*
|
|
1233
1806
|
* Сервер может переключить провайдера или переименовать поле без выпуска новой версии SDK.
|
|
1234
1807
|
* Автоматическому входу этот вызов не нужен — клиент делает его сам.
|
|
1235
|
-
*
|
|
1236
|
-
* @deprecated Сервер отвечает `404`; метод возвращает Cloudflare Turnstile.
|
|
1237
1808
|
*/
|
|
1238
|
-
captchaProvider(
|
|
1239
|
-
return
|
|
1240
|
-
|
|
1241
|
-
|
|
1809
|
+
captchaProvider(options = {}) {
|
|
1810
|
+
return this.http.execute(AUTH_CAPTCHA_PROVIDER, {
|
|
1811
|
+
path: AUTH_PATHS.captchaProvider,
|
|
1812
|
+
skipAuth: true,
|
|
1813
|
+
skipAuthRefresh: true,
|
|
1814
|
+
...options
|
|
1242
1815
|
});
|
|
1243
1816
|
}
|
|
1244
1817
|
/**
|
|
@@ -1247,14 +1820,14 @@ var AuthResource = class extends BaseResource {
|
|
|
1247
1820
|
* То же, что {@link captchaProvider}, плюс `url` — готовая страница на домене итд.com,
|
|
1248
1821
|
* где ключ виджета действителен. Пригодится встроенному браузеру: открыть её и забрать
|
|
1249
1822
|
* токен, ничего не собирая самому.
|
|
1250
|
-
*
|
|
1251
|
-
* @deprecated Сервер отвечает `404`; метод возвращает Cloudflare Turnstile на домене итд.com.
|
|
1252
1823
|
*/
|
|
1253
|
-
|
|
1254
|
-
return {
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1824
|
+
captchaPage(options = {}) {
|
|
1825
|
+
return this.http.execute(AUTH_CAPTCHA_PAGE, {
|
|
1826
|
+
path: AUTH_PATHS.captchaPage,
|
|
1827
|
+
skipAuth: true,
|
|
1828
|
+
skipAuthRefresh: true,
|
|
1829
|
+
...options
|
|
1830
|
+
});
|
|
1258
1831
|
}
|
|
1259
1832
|
/** Создаёт короткоживущую сессию QR-входа. */
|
|
1260
1833
|
async startQrLogin(options = {}) {
|
|
@@ -1382,6 +1955,7 @@ var AuthResource = class extends BaseResource {
|
|
|
1382
1955
|
* Регистрирует аккаунт и запускает подтверждение по коду.
|
|
1383
1956
|
*
|
|
1384
1957
|
* @returns `flowToken`, который нужно передать в {@link verifyOtp}
|
|
1958
|
+
* @deprecated Регистрация по email отключена. Используйте auth.phone.start().
|
|
1385
1959
|
*/
|
|
1386
1960
|
async signUp(credentials, options = {}) {
|
|
1387
1961
|
const { captcha, ...rest } = credentials;
|
|
@@ -1598,26 +2172,6 @@ var AuthResource = class extends BaseResource {
|
|
|
1598
2172
|
newPassword
|
|
1599
2173
|
}, options);
|
|
1600
2174
|
}
|
|
1601
|
-
/**
|
|
1602
|
-
* Меняет пароль. Требует действующей сессии.
|
|
1603
|
-
*
|
|
1604
|
-
* При неверном текущем пароле сервер отвечает `ACCOUNT_CURRENT_PASSWORD_INCORRECT`.
|
|
1605
|
-
*
|
|
1606
|
-
* @example
|
|
1607
|
-
* ```ts
|
|
1608
|
-
* await itd.auth.changePassword({ currentPassword, newPassword });
|
|
1609
|
-
* ```
|
|
1610
|
-
*/
|
|
1611
|
-
changePassword(input, options = {}) {
|
|
1612
|
-
return this.voidOperation(AUTH_CHANGE_PASSWORD, {
|
|
1613
|
-
path: AUTH_PATHS.changePassword,
|
|
1614
|
-
body: {
|
|
1615
|
-
currentPassword: input.currentPassword,
|
|
1616
|
-
newPassword: input.newPassword
|
|
1617
|
-
},
|
|
1618
|
-
...options
|
|
1619
|
-
});
|
|
1620
|
-
}
|
|
1621
2175
|
/** Загружает список активных сессий. У текущей поле `isCurrent` равно `true`. */
|
|
1622
2176
|
sessions(options = {}) {
|
|
1623
2177
|
return this.http.execute(AUTH_SESSIONS, {
|
|
@@ -1640,8 +2194,7 @@ var AuthResource = class extends BaseResource {
|
|
|
1640
2194
|
});
|
|
1641
2195
|
}
|
|
1642
2196
|
};
|
|
1643
|
-
|
|
1644
|
-
//#region src/client.ts
|
|
2197
|
+
// src/client.ts
|
|
1645
2198
|
const CLIENT_PLUGIN_REGISTRIES = /* @__PURE__ */ new WeakMap();
|
|
1646
2199
|
const DISPOSED_CLIENTS = /* @__PURE__ */ new WeakSet();
|
|
1647
2200
|
function assertClientActive(client, action) {
|
|
@@ -1705,6 +2258,7 @@ var ItdClient = class ItdClient {
|
|
|
1705
2258
|
#resources;
|
|
1706
2259
|
/** Сессионный ресурс живёт у фасада: он управляет входом и продлением. */
|
|
1707
2260
|
#auth;
|
|
2261
|
+
#account;
|
|
1708
2262
|
/** Авторизация, сессии и пароли. */
|
|
1709
2263
|
get auth() {
|
|
1710
2264
|
this.#auth ??= new AuthResource(this.#runtime.http, {
|
|
@@ -1713,6 +2267,11 @@ var ItdClient = class ItdClient {
|
|
|
1713
2267
|
});
|
|
1714
2268
|
return this.#auth;
|
|
1715
2269
|
}
|
|
2270
|
+
/** Настройки текущего аккаунта и управление его состоянием. */
|
|
2271
|
+
get account() {
|
|
2272
|
+
this.#account ??= new AccountResource(this.#runtime.http, this.#runtime.auth);
|
|
2273
|
+
return this.#account;
|
|
2274
|
+
}
|
|
1716
2275
|
/** Профили, подписки, блокировки, приватность. */
|
|
1717
2276
|
get users() {
|
|
1718
2277
|
return this.#resources.users;
|
|
@@ -1753,6 +2312,10 @@ var ItdClient = class ItdClient {
|
|
|
1753
2312
|
get subscription() {
|
|
1754
2313
|
return this.#resources.subscription;
|
|
1755
2314
|
}
|
|
2315
|
+
/** Публичные документы ИТД и история их редакций. */
|
|
2316
|
+
get legal() {
|
|
2317
|
+
return this.#resources.legal;
|
|
2318
|
+
}
|
|
1756
2319
|
/** Сведения о платформе: версии приложений, изменения, анонсы, баннер события. */
|
|
1757
2320
|
get platform() {
|
|
1758
2321
|
return this.#resources.platform;
|
|
@@ -2156,8 +2719,7 @@ var ItdClient = class ItdClient {
|
|
|
2156
2719
|
function createClient(options = {}) {
|
|
2157
2720
|
return new ItdClient(options);
|
|
2158
2721
|
}
|
|
2159
|
-
|
|
2160
|
-
//#region src/accounts.ts
|
|
2722
|
+
// src/accounts.ts
|
|
2161
2723
|
/** Как аккаунты делят между собой очередь запросов. */
|
|
2162
2724
|
const RateLimitScope = Object.freeze({
|
|
2163
2725
|
/** У каждого аккаунта своя очередь. */
|
|
@@ -2626,7 +3188,18 @@ var ItdAccounts = class ItdAccounts {
|
|
|
2626
3188
|
function createAccounts(options = {}) {
|
|
2627
3189
|
return new ItdAccounts(options);
|
|
2628
3190
|
}
|
|
2629
|
-
|
|
2630
|
-
|
|
3191
|
+
// src/models/account-access.ts
|
|
3192
|
+
/** Способ подтверждения смены номера или почты. */
|
|
3193
|
+
const ContactProofMethod = Object.freeze({
|
|
3194
|
+
Password: "password",
|
|
3195
|
+
EmailCode: "email_code",
|
|
3196
|
+
PhoneCode: "phone_code"
|
|
3197
|
+
});
|
|
3198
|
+
/** Что меняет отложенная заявка: номер или почту. */
|
|
3199
|
+
const ContactKind = Object.freeze({
|
|
3200
|
+
Email: "email",
|
|
3201
|
+
Phone: "phone"
|
|
3202
|
+
});
|
|
3203
|
+
export { ALLOWED_MIME_TYPES, AUDIO_MIME_TYPES, AccessType, AttachmentType, BUCKET_LIMITS, BannerDrawingTool, CAPTCHA_FIELDS, CaptchaChoice, CaptchaField, CaptchaType, CommentSort, ContactKind, ContactProofMethod, DEFAULT_BASE_URL, DEFAULT_RATE_LIMIT_BUCKET, EventChannel, EventChannelStatus, EventComposer, EventRouter, FeedTab, FileTransferMode, IMAGE_MIME_TYPES, IncidentKind, InteractionType, ItdAbortError, ItdAccounts, ItdApiError, ItdApiErrorKind, ItdAuthError, ItdClient, ItdConfigError, ItdConflictError, ItdError, ItdErrorCode, ItdErrorKind, ItdFileError, ItdFileErrorReason, ItdForbiddenError, ItdNetworkError, ItdNotFoundError, ItdPhoneVerificationError, ItdRateLimitError, ItdServerError, ItdStateError, ItdTimeoutError, ItdValidationError, LIBRARY_VERSION, LastSeenUnit, LegalDocumentBlockType, LegalDocumentScope, LikesVisibility, LogLevel, MemoryKeyValueStore, MemoryMultiTokenStorage, MemoryShopOrderAccessStorage, MemoryTokenStorage, MessageAccess, NotificationEvents, NotificationEventsClient, NotificationEventsTransport, NotificationType, NotificationUpdateOrigin, NotificationUpdateType, OPERATIONS, OperationMethod, PaginationMode, Paginator, PhoneDeliveryChannel, PhoneLoginStep, PhoneReverseState, PhoneVerificationMethod, QrLocationPrecision, QrLoginStatus, QrLoginStreamStatus, RateLimitPacing, RateLimitScope, ReportReason, ReportTargetType, RetrySafety, RuntimeMode, STATUS_SERVICE, ServiceState, ShopConsentKind, ShopOrderStatus, ShopProductCategory, ShopProductStatus, SignInStatus, SpanRenderFormat, SpanType, TURNSTILE_SITE_KEY, TimeoutBudget, UnauthorizedStreamError, UsernameUnavailableReason, VIDEO_MIME_TYPES, ViewReason, ViewSource, WallAccess, WebSocketTransport, autoSpans, canonicalNotificationType, comment, createAccounts, createClient, createKeyValueStore, createMultiTokenStorage, createNotificationEventsClient, createRecordKeyValueStore, createShopFeature, createShopOrderAccessStorage, createTokenStorage, formatNotificationText, fromStream, fromUrl, isBuilder, isBuiltInOperationId, isEnumerableKeyValueStore, isItdApiError, isItdAuthError, isItdConflictError, isItdError, isItdFileError, isItdForbiddenError, isItdNotFoundError, isItdPhoneVerificationError, isItdRateLimitError, isItdServerError, isItdStateError, isItdValidationError, isKnownNotificationType, isMyProfile, mapPage, markup, normalizeNotification, operationBucket, operationMethod, operationRetrySafety, parseHtml, parseMarkdown, poll, post, renderSpans, report, resolveNotificationUrl, runEventMiddleware, scopedTokenStorage, statusDays, systemClock, toDate, utcStampToIso, withCodec, withNamespace };
|
|
2631
3204
|
|
|
2632
3205
|
//# sourceMappingURL=index.js.map
|