anixapi 0.3.0 → 0.3.1

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/README.md CHANGED
@@ -2,13 +2,13 @@
2
2
  > **Дисклеймер.** Проект создан в **ознакомительных и исследовательских целях**. Автор **не поддерживает и осуждает** использование библиотеки для авторегистрации, спам-ботов, накрутки, обхода ограничений сервиса и любого злоупотребления API Anixart. Вы используете библиотеку **на свой страх и риск** и несёте ответственность за соблюдение правил Anixart и применимого законодательства.
3
3
 
4
4
  > [!CAUTION]
5
- > **Миграция с [theDesConnet/AnixartJS](https://github.com/theDesConnet/AnixartJS).** Плавного перехода на AnixApi **не будет**. Изменились структура `src/api`, имена эндпоинтов, типы, обработка ошибок (`AnixApiError`) и покрытие API 9.0 beta 11. При переносе с версии DesConnet закладывайте время на переписывание вызовов, импортов и проверку ответов. Подробности — в [документации](docs/DOCUMENTATION.md).
5
+ > **Миграция с [theDesConnet/AnixartJS](https://github.com/theDesConnet/AnixartJS).** Плавного перехода на AnixApi **не будет**. Изменились структура `src/api`, имена эндпоинтов, типы, обработка ошибок (`AnixApiError`) и покрытие API 9.0. При переносе с версии DesConnet закладывайте время на переписывание вызовов, импортов и проверку ответов. Подробности — в [документации](docs/DOCUMENTATION.md).
6
6
 
7
7
  <h2 align="center">AnixApi</h2>
8
8
 
9
9
  <p align="center">
10
10
  TypeScript-обёртка над API Anixart 9.x для Node.js.<br>
11
- 275 эндпоинтов · типизация · доменные классы · обработка ошибок
11
+ 286 эндпоинтов · OAuth (VK / Google / Telegram / Yandex) · типизация · доменные классы
12
12
  </p>
13
13
 
14
14
  <p align="center">
@@ -16,6 +16,10 @@
16
16
  <a href="LICENSE">Лицензия GPL-2.0</a>
17
17
  </p>
18
18
 
19
+ <p align="center">
20
+ <code>anixapi@0.3.1</code> · актуально под <strong>Anixart 9.0 BETA 21</strong> (build <code>26080522</code>)
21
+ </p>
22
+
19
23
  ---
20
24
 
21
25
  ## О проекте
@@ -30,7 +34,7 @@
30
34
  |---|---|
31
35
  | **Оригинальный репозиторий** | https://github.com/theDesConnet/AnixartJS |
32
36
  | **Базовая архитектура API** | DesConnet |
33
- | **Расширения** | полное покрытие API 9.0 beta 11, реструктуризация `src/api`, типы, `AnixApiError`, `typecheck` в сборке |
37
+ | **Расширения** | покрытие API 9.0 (до beta 21), реструктуризация `src/api`, типы, `AnixApiError`, OAuth-провайдеры, `typecheck` в сборке |
34
38
 
35
39
  При публикации изменений обязательно сохраняйте указание на оригинальный проект и условия GPL-2.0.
36
40
 
@@ -54,14 +58,47 @@ if (code === DefaultResult.Ok) {
54
58
  }
55
59
  ```
56
60
 
61
+ ### OAuth (VK / Google / Telegram / Yandex)
62
+
63
+ ```javascript
64
+ const { Anixart, DefaultResult, OAuthAuthResult } = require("anixapi");
65
+
66
+ const client = new Anixart();
67
+
68
+ // Вход: при code === 3 (NotRegistered) нужно signUpWith*
69
+ const res = await client.endpoints.auth.signInWithYandex({
70
+ yandexAccessToken: "...",
71
+ });
72
+
73
+ if (res.code === DefaultResult.Ok && res.profileToken) {
74
+ client.setToken(res.profileToken.token);
75
+ } else if (res.code === OAuthAuthResult.NotRegistered) {
76
+ await client.endpoints.auth.signUpWithYandex({
77
+ login: "newuser",
78
+ email: res.email || "user@example.com",
79
+ yandexAccessToken: "...",
80
+ });
81
+ }
82
+ ```
83
+
84
+ | Провайдер | Sign-in | Поле токена |
85
+ |-----------|---------|-------------|
86
+ | VK | `signInWithVk` | `vkAccessToken` |
87
+ | Google | `signInWithGoogle` | `googleIdToken` |
88
+ | Telegram | `signInWithTelegram` | `telegramIdToken` |
89
+ | Yandex | `signInWithYandex` | `yandexAccessToken` |
90
+
91
+ Флаги доступности: `GET config/urls` → `vk_auth_available`, `google_auth_available`, `telegram_auth_available`, `yandex_auth_available`.
92
+
57
93
  Подробные примеры, структура API и обработка ошибок — в **[документации](docs/DOCUMENTATION.md)**.
58
94
 
59
95
  ---
60
96
 
61
97
  ## Возможности
62
98
 
63
- - **275 эндпоинтов** — `client.endpoints.*`
64
- - **TypeScript** — типы запросов, ответов и enum-кодов (`LoginResult`, `CommentAddResult`, )
99
+ - **286 эндпоинтов** — `client.endpoints.*` (Anixart 9.0 BETA 21)
100
+ - **OAuth** — VK, Google, Telegram, Yandex (sign-in / sign-up / bind / unbind)
101
+ - **TypeScript** — типы запросов, ответов и enum-кодов (`LoginResult`, `OAuthAuthResult`, …)
65
102
  - **Доменные классы** — `Article`, `Channel`, `Release`, `FullProfile`, `Collection`
66
103
  - **Ошибки** — `AnixApiError`, `describeResultCode()`, опция `throwOnApiError`
67
104
 
@@ -69,8 +106,9 @@ if (code === DefaultResult.Ok) {
69
106
 
70
107
  ## TODO
71
108
 
72
- - [x] Все эндпоинты API (275)
73
- - [x] Типы / схемы / Swagger-документация
109
+ - [x] Все эндпоинты API (286, beta 21)
110
+ - [x] OAuth: VK / Google / Telegram / Yandex
111
+ - [x] Типы и документация
74
112
  - [x] Классы для коллекций
75
113
  - [ ] Возможность использовать библиотеку в браузере полностью
76
114
 
@@ -1,5 +1,5 @@
1
1
  import { Anixart } from "../client";
2
- import { IBaseApiParams, ICheckLoginRequest, ICheckLoginResponse, ILoginRequest, ILoginResponse, IOAuthGoogleSignInRequest, IOAuthGoogleSignUpRequest, IOAuthTelegramSignInRequest, IOAuthTelegramSignUpRequest, IOAuthVkSignInRequest, IOAuthVkSignUpRequest, IRegisterResponse, IResendRequest, IResponse, IRestoreEmailRequest, IRestoreResendRequest, IRestoreVerifyRequest, ISignUpRequest, ISignUpVerifyRequest, ITelegramAuthResponse } from "../types";
2
+ import { IBaseApiParams, ICheckLoginRequest, ICheckLoginResponse, IGoogleAuthResponse, ILoginRequest, ILoginResponse, IOAuthGoogleSignInRequest, IOAuthGoogleSignUpRequest, IOAuthTelegramSignInRequest, IOAuthTelegramSignUpRequest, IOAuthVkSignInRequest, IOAuthVkSignUpRequest, IOAuthYandexSignInRequest, IOAuthYandexSignUpRequest, IRegisterResponse, IResendRequest, IResponse, IRestoreEmailRequest, IRestoreResendRequest, IRestoreVerifyRequest, ISignUpRequest, ISignUpVerifyRequest, ITelegramAuthResponse, IVkAuthResponse, IYandexAuthResponse } from "../types";
3
3
  /**
4
4
  * Класс с эндпоинтами авторизации
5
5
  */
@@ -79,13 +79,13 @@ export declare class Auth {
79
79
  /**
80
80
  * POST auth/google
81
81
  *
82
- * Возможные коды ответа: {@link LoginResult}
83
- * @returns {@link ILoginResponse}
82
+ * Возможные коды ответа: {@link GoogleAuthResult}
83
+ * @returns {@link IGoogleAuthResponse}
84
84
  *
85
85
  * @example
86
86
  * const result = await client.endpoints.auth.signInWithGoogle(...);
87
87
  */
88
- signInWithGoogle(data: IOAuthGoogleSignInRequest, options?: IBaseApiParams): Promise<ILoginResponse>;
88
+ signInWithGoogle(data: IOAuthGoogleSignInRequest, options?: IBaseApiParams): Promise<IGoogleAuthResponse>;
89
89
  /**
90
90
  * POST auth/telegram
91
91
  *
@@ -99,13 +99,23 @@ export declare class Auth {
99
99
  /**
100
100
  * POST auth/vk
101
101
  *
102
- * Возможные коды ответа: {@link LoginResult}
103
- * @returns {@link ILoginResponse}
102
+ * Возможные коды ответа: {@link OAuthAuthResult}
103
+ * @returns {@link IVkAuthResponse}
104
104
  *
105
105
  * @example
106
106
  * const result = await client.endpoints.auth.signInWithVk(...);
107
107
  */
108
- signInWithVk(data: IOAuthVkSignInRequest, options?: IBaseApiParams): Promise<ILoginResponse>;
108
+ signInWithVk(data: IOAuthVkSignInRequest, options?: IBaseApiParams): Promise<IVkAuthResponse>;
109
+ /**
110
+ * POST auth/yandex (с beta 21)
111
+ *
112
+ * Возможные коды ответа: {@link OAuthAuthResult}
113
+ * @returns {@link IYandexAuthResponse}
114
+ *
115
+ * @example
116
+ * const result = await client.endpoints.auth.signInWithYandex({ yandexAccessToken });
117
+ */
118
+ signInWithYandex(data: IOAuthYandexSignInRequest, options?: IBaseApiParams): Promise<IYandexAuthResponse>;
109
119
  /**
110
120
  * POST auth/signUp
111
121
  *
@@ -119,13 +129,13 @@ export declare class Auth {
119
129
  /**
120
130
  * POST auth/google
121
131
  *
122
- * Возможные коды ответа: {@link LoginResult}
123
- * @returns {@link ILoginResponse}
132
+ * Возможные коды ответа: {@link GoogleAuthResult}
133
+ * @returns {@link IGoogleAuthResponse}
124
134
  *
125
135
  * @example
126
136
  * const result = await client.endpoints.auth.signUpWithGoogle(...);
127
137
  */
128
- signUpWithGoogle(data: IOAuthGoogleSignUpRequest, options?: IBaseApiParams): Promise<ILoginResponse>;
138
+ signUpWithGoogle(data: IOAuthGoogleSignUpRequest, options?: IBaseApiParams): Promise<IGoogleAuthResponse>;
129
139
  /**
130
140
  * POST auth/telegram
131
141
  *
@@ -139,13 +149,23 @@ export declare class Auth {
139
149
  /**
140
150
  * POST auth/vk
141
151
  *
142
- * Возможные коды ответа: {@link LoginResult}
143
- * @returns {@link ILoginResponse}
152
+ * Возможные коды ответа: {@link OAuthAuthResult}
153
+ * @returns {@link IVkAuthResponse}
144
154
  *
145
155
  * @example
146
156
  * const result = await client.endpoints.auth.signUpWithVk(...);
147
157
  */
148
- signUpWithVk(data: IOAuthVkSignUpRequest, options?: IBaseApiParams): Promise<ILoginResponse>;
158
+ signUpWithVk(data: IOAuthVkSignUpRequest, options?: IBaseApiParams): Promise<IVkAuthResponse>;
159
+ /**
160
+ * POST auth/yandex (с beta 21)
161
+ *
162
+ * Возможные коды ответа: {@link OAuthAuthResult}
163
+ * @returns {@link IYandexAuthResponse}
164
+ *
165
+ * @example
166
+ * const result = await client.endpoints.auth.signUpWithYandex({ login, email, yandexAccessToken });
167
+ */
168
+ signUpWithYandex(data: IOAuthYandexSignUpRequest, options?: IBaseApiParams): Promise<IYandexAuthResponse>;
149
169
  /**
150
170
  * POST auth/verify
151
171
  *
package/dist/api/auth.js CHANGED
@@ -95,8 +95,8 @@ class Auth {
95
95
  /**
96
96
  * POST auth/google
97
97
  *
98
- * Возможные коды ответа: {@link LoginResult}
99
- * @returns {@link ILoginResponse}
98
+ * Возможные коды ответа: {@link GoogleAuthResult}
99
+ * @returns {@link IGoogleAuthResponse}
100
100
  *
101
101
  * @example
102
102
  * const result = await client.endpoints.auth.signInWithGoogle(...);
@@ -119,8 +119,8 @@ class Auth {
119
119
  /**
120
120
  * POST auth/vk
121
121
  *
122
- * Возможные коды ответа: {@link LoginResult}
123
- * @returns {@link ILoginResponse}
122
+ * Возможные коды ответа: {@link OAuthAuthResult}
123
+ * @returns {@link IVkAuthResponse}
124
124
  *
125
125
  * @example
126
126
  * const result = await client.endpoints.auth.signInWithVk(...);
@@ -128,6 +128,18 @@ class Auth {
128
128
  async signInWithVk(data, options) {
129
129
  return await this.client.call({ path: `/auth/vk`, method: 'POST', urlEncoded: data, ...options });
130
130
  }
131
+ /**
132
+ * POST auth/yandex (с beta 21)
133
+ *
134
+ * Возможные коды ответа: {@link OAuthAuthResult}
135
+ * @returns {@link IYandexAuthResponse}
136
+ *
137
+ * @example
138
+ * const result = await client.endpoints.auth.signInWithYandex({ yandexAccessToken });
139
+ */
140
+ async signInWithYandex(data, options) {
141
+ return await this.client.call({ path: `/auth/yandex`, method: 'POST', urlEncoded: data, ...options });
142
+ }
131
143
  /**
132
144
  * POST auth/signUp
133
145
  *
@@ -143,8 +155,8 @@ class Auth {
143
155
  /**
144
156
  * POST auth/google
145
157
  *
146
- * Возможные коды ответа: {@link LoginResult}
147
- * @returns {@link ILoginResponse}
158
+ * Возможные коды ответа: {@link GoogleAuthResult}
159
+ * @returns {@link IGoogleAuthResponse}
148
160
  *
149
161
  * @example
150
162
  * const result = await client.endpoints.auth.signUpWithGoogle(...);
@@ -167,8 +179,8 @@ class Auth {
167
179
  /**
168
180
  * POST auth/vk
169
181
  *
170
- * Возможные коды ответа: {@link LoginResult}
171
- * @returns {@link ILoginResponse}
182
+ * Возможные коды ответа: {@link OAuthAuthResult}
183
+ * @returns {@link IVkAuthResponse}
172
184
  *
173
185
  * @example
174
186
  * const result = await client.endpoints.auth.signUpWithVk(...);
@@ -176,6 +188,18 @@ class Auth {
176
188
  async signUpWithVk(data, options) {
177
189
  return await this.client.call({ path: `/auth/vk`, method: 'POST', urlEncoded: data, ...options });
178
190
  }
191
+ /**
192
+ * POST auth/yandex (с beta 21)
193
+ *
194
+ * Возможные коды ответа: {@link OAuthAuthResult}
195
+ * @returns {@link IYandexAuthResponse}
196
+ *
197
+ * @example
198
+ * const result = await client.endpoints.auth.signUpWithYandex({ login, email, yandexAccessToken });
199
+ */
200
+ async signUpWithYandex(data, options) {
201
+ return await this.client.call({ path: `/auth/yandex`, method: 'POST', urlEncoded: data, ...options });
202
+ }
179
203
  /**
180
204
  * POST auth/verify
181
205
  *
@@ -1,5 +1,5 @@
1
1
  import { Anixart } from "../../client";
2
- import { IBaseApiParams, IChangeEmailResendResponse, IChangeEmailResponse, IChangeEmailVerifyResponse, IChangeLoginInfoResponse, IChangeLoginResponse, IChangePasswordResponse, IEmailChangeRequest, IEmailChangeResendRequest, IGoogleBindResponse, IGoogleUnbindResponse, IPasswordChangeRequest, IPrivacyEditRequest, IProfileSettingsResponse, IProfileSocialResponse, IResponse, ISelectPinnedSectionRequest, ISelectThemeRequest, ISocialEditResponse, ISocialPagesEditRequest, IStatusEditRequest, ITelegramBindRequest, ITelegramBindResponse, ITelegramUnbindResponse, IVkBindResponse, IVkUnbindResponse } from "../../types";
2
+ import { IBaseApiParams, IChangeEmailResendResponse, IChangeEmailResponse, IChangeEmailVerifyResponse, IChangeLoginInfoResponse, IChangeLoginResponse, IChangePasswordResponse, IEmailChangeRequest, IEmailChangeResendRequest, IGoogleBindRequest, IGoogleBindResponse, IGoogleUnbindResponse, IPasswordChangeRequest, IPrivacyEditRequest, IProfileSettingsResponse, IProfileSocialResponse, IResponse, ISelectPinnedSectionRequest, ISelectThemeRequest, ISocialEditResponse, ISocialPagesEditRequest, IStatusEditRequest, ITelegramBindRequest, ITelegramBindResponse, ITelegramUnbindResponse, IVkBindRequest, IVkBindResponse, IVkUnbindResponse, IYandexBindRequest, IYandexBindResponse, IYandexUnbindResponse } from "../../types";
3
3
  /**
4
4
  * Класс с эндпоинтами настроек профиля
5
5
  */
@@ -99,21 +99,21 @@ export declare class ProfilePreference {
99
99
  /**
100
100
  * POST profile/preference/google/bind
101
101
  *
102
- * Возможные коды ответа: {@link DefaultResult}
102
+ * Возможные коды ответа: {@link GoogleBindResult}
103
103
  * @returns {@link IGoogleBindResponse}
104
104
  *
105
105
  * @example
106
- * const result = await client.endpoints.profilePreference.googleBind(...);
106
+ * const result = await client.endpoints.profilePreference.googleBind({ idToken });
107
107
  */
108
- googleBind(data?: Record<string, string | number | undefined>, options?: IBaseApiParams): Promise<IGoogleBindResponse>;
108
+ googleBind(data: IGoogleBindRequest, options?: IBaseApiParams): Promise<IGoogleBindResponse>;
109
109
  /**
110
110
  * POST profile/preference/google/unbind
111
111
  *
112
- * Возможные коды ответа: {@link DefaultResult}
112
+ * Возможные коды ответа: {@link GoogleUnbindResult}
113
113
  * @returns {@link IGoogleUnbindResponse}
114
114
  *
115
115
  * @example
116
- * const result = await client.endpoints.profilePreference.googleUnbind(...);
116
+ * const result = await client.endpoints.profilePreference.googleUnbind();
117
117
  */
118
118
  googleUnbind(options?: IBaseApiParams): Promise<IGoogleUnbindResponse>;
119
119
  /**
@@ -249,21 +249,41 @@ export declare class ProfilePreference {
249
249
  /**
250
250
  * POST profile/preference/vk/bind
251
251
  *
252
- * Возможные коды ответа: {@link DefaultResult}
252
+ * Возможные коды ответа: {@link VkBindResult}
253
253
  * @returns {@link IVkBindResponse}
254
254
  *
255
255
  * @example
256
- * const result = await client.endpoints.profilePreference.vkBind(...);
256
+ * const result = await client.endpoints.profilePreference.vkBind({ accessToken });
257
257
  */
258
- vkBind(data?: Record<string, string | number | undefined>, options?: IBaseApiParams): Promise<IVkBindResponse>;
258
+ vkBind(data: IVkBindRequest, options?: IBaseApiParams): Promise<IVkBindResponse>;
259
259
  /**
260
260
  * POST profile/preference/vk/unbind
261
261
  *
262
- * Возможные коды ответа: {@link DefaultResult}
262
+ * Возможные коды ответа: {@link VkUnbindResult}
263
263
  * @returns {@link IVkUnbindResponse}
264
264
  *
265
265
  * @example
266
- * const result = await client.endpoints.profilePreference.vkUnbind(...);
266
+ * const result = await client.endpoints.profilePreference.vkUnbind();
267
267
  */
268
268
  vkUnbind(options?: IBaseApiParams): Promise<IVkUnbindResponse>;
269
+ /**
270
+ * POST profile/preference/yandex/bind (с beta 21)
271
+ *
272
+ * Возможные коды ответа: {@link YandexBindResult}
273
+ * @returns {@link IYandexBindResponse}
274
+ *
275
+ * @example
276
+ * const result = await client.endpoints.profilePreference.yandexBind({ accessToken });
277
+ */
278
+ yandexBind(data: IYandexBindRequest, options?: IBaseApiParams): Promise<IYandexBindResponse>;
279
+ /**
280
+ * POST profile/preference/yandex/unbind (с beta 21)
281
+ *
282
+ * Возможные коды ответа: {@link YandexUnbindResult}
283
+ * @returns {@link IYandexUnbindResponse}
284
+ *
285
+ * @example
286
+ * const result = await client.endpoints.profilePreference.yandexUnbind();
287
+ */
288
+ yandexUnbind(options?: IBaseApiParams): Promise<IYandexUnbindResponse>;
269
289
  }
@@ -119,11 +119,11 @@ class ProfilePreference {
119
119
  /**
120
120
  * POST profile/preference/google/bind
121
121
  *
122
- * Возможные коды ответа: {@link DefaultResult}
122
+ * Возможные коды ответа: {@link GoogleBindResult}
123
123
  * @returns {@link IGoogleBindResponse}
124
124
  *
125
125
  * @example
126
- * const result = await client.endpoints.profilePreference.googleBind(...);
126
+ * const result = await client.endpoints.profilePreference.googleBind({ idToken });
127
127
  */
128
128
  async googleBind(data, options) {
129
129
  return await this.client.call({ path: `/profile/preference/google/bind`, method: 'POST', urlEncoded: data, ...options });
@@ -131,11 +131,11 @@ class ProfilePreference {
131
131
  /**
132
132
  * POST profile/preference/google/unbind
133
133
  *
134
- * Возможные коды ответа: {@link DefaultResult}
134
+ * Возможные коды ответа: {@link GoogleUnbindResult}
135
135
  * @returns {@link IGoogleUnbindResponse}
136
136
  *
137
137
  * @example
138
- * const result = await client.endpoints.profilePreference.googleUnbind(...);
138
+ * const result = await client.endpoints.profilePreference.googleUnbind();
139
139
  */
140
140
  async googleUnbind(options) {
141
141
  return await this.client.call({ path: `/profile/preference/google/unbind`, method: 'POST', ...options });
@@ -299,11 +299,11 @@ class ProfilePreference {
299
299
  /**
300
300
  * POST profile/preference/vk/bind
301
301
  *
302
- * Возможные коды ответа: {@link DefaultResult}
302
+ * Возможные коды ответа: {@link VkBindResult}
303
303
  * @returns {@link IVkBindResponse}
304
304
  *
305
305
  * @example
306
- * const result = await client.endpoints.profilePreference.vkBind(...);
306
+ * const result = await client.endpoints.profilePreference.vkBind({ accessToken });
307
307
  */
308
308
  async vkBind(data, options) {
309
309
  return await this.client.call({ path: `/profile/preference/vk/bind`, method: 'POST', urlEncoded: data, ...options });
@@ -311,14 +311,38 @@ class ProfilePreference {
311
311
  /**
312
312
  * POST profile/preference/vk/unbind
313
313
  *
314
- * Возможные коды ответа: {@link DefaultResult}
314
+ * Возможные коды ответа: {@link VkUnbindResult}
315
315
  * @returns {@link IVkUnbindResponse}
316
316
  *
317
317
  * @example
318
- * const result = await client.endpoints.profilePreference.vkUnbind(...);
318
+ * const result = await client.endpoints.profilePreference.vkUnbind();
319
319
  */
320
320
  async vkUnbind(options) {
321
321
  return await this.client.call({ path: `/profile/preference/vk/unbind`, method: 'POST', ...options });
322
322
  }
323
+ /**
324
+ * POST profile/preference/yandex/bind (с beta 21)
325
+ *
326
+ * Возможные коды ответа: {@link YandexBindResult}
327
+ * @returns {@link IYandexBindResponse}
328
+ *
329
+ * @example
330
+ * const result = await client.endpoints.profilePreference.yandexBind({ accessToken });
331
+ */
332
+ async yandexBind(data, options) {
333
+ return await this.client.call({ path: `/profile/preference/yandex/bind`, method: 'POST', urlEncoded: data, ...options });
334
+ }
335
+ /**
336
+ * POST profile/preference/yandex/unbind (с beta 21)
337
+ *
338
+ * Возможные коды ответа: {@link YandexUnbindResult}
339
+ * @returns {@link IYandexUnbindResponse}
340
+ *
341
+ * @example
342
+ * const result = await client.endpoints.profilePreference.yandexUnbind();
343
+ */
344
+ async yandexUnbind(options) {
345
+ return await this.client.call({ path: `/profile/preference/yandex/unbind`, method: 'POST', ...options });
346
+ }
323
347
  }
324
348
  exports.ProfilePreference = ProfilePreference;
@@ -14,6 +14,7 @@ export declare class Dubber {
14
14
  readonly pinned: boolean;
15
15
  readonly viewCount: number;
16
16
  readonly workers: string;
17
+ readonly quality: number | null;
17
18
  constructor(client: Anixart, dubberResponce: IDubber, release: Release);
18
19
  getSources(): Promise<Source[]>;
19
20
  }
@@ -15,6 +15,7 @@ class Dubber {
15
15
  this.pinned = dubberResponce.pinned,
16
16
  this.viewCount = dubberResponce.view_count;
17
17
  this.workers = dubberResponce.workers;
18
+ this.quality = typeof dubberResponce.quality === 'number' ? dubberResponce.quality : null;
18
19
  }
19
20
  async getSources() {
20
21
  const request = await this.client.endpoints.episode.sources(this.release.id, this.id);
@@ -31,6 +31,8 @@ export declare class FullProfile extends BaseProfile {
31
31
  readonly isBookmarksTransferred: boolean;
32
32
  readonly isVkBound: boolean;
33
33
  readonly isGoogleBound: boolean;
34
+ readonly isTelegramBound: boolean;
35
+ readonly isYandexBound: boolean;
34
36
  readonly isReleaseTypeNotificationsEnabled: boolean;
35
37
  readonly isEpisodeNotificationsEnabled: boolean;
36
38
  readonly isFirstEpisodeNotificationEnabled: boolean;
@@ -5,7 +5,7 @@ const BaseProfile_1 = require("./BaseProfile");
5
5
  const Release_1 = require("./Release");
6
6
  class FullProfile extends BaseProfile_1.BaseProfile {
7
7
  constructor(client, profile) {
8
- var _a, _b, _c, _d, _e, _f, _g, _h;
8
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
9
9
  super(client, {
10
10
  id: profile.id,
11
11
  login: profile.login,
@@ -52,6 +52,8 @@ class FullProfile extends BaseProfile_1.BaseProfile {
52
52
  this.isBookmarksTransferred = profile.is_bookmarks_transferred;
53
53
  this.isVkBound = profile.is_vk_bound;
54
54
  this.isGoogleBound = profile.is_google_bound;
55
+ this.isTelegramBound = (_j = profile.is_telegram_bound) !== null && _j !== void 0 ? _j : false;
56
+ this.isYandexBound = (_k = profile.is_yandex_bound) !== null && _k !== void 0 ? _k : false;
55
57
  this.isReleaseTypeNotificationsEnabled = profile.is_release_type_notifications_enabled;
56
58
  this.isEpisodeNotificationsEnabled = profile.is_episode_notifications_enabled;
57
59
  this.isFirstEpisodeNotificationEnabled = profile.is_first_episode_notification_enabled;
@@ -76,6 +76,7 @@ export interface ISignUpVerifyRequest extends ISignUpRequest {
76
76
  vkAccessToken?: string;
77
77
  googleIdToken?: string;
78
78
  telegramIdToken?: string;
79
+ yandexAccessToken?: string;
79
80
  hash: string;
80
81
  code: number;
81
82
  }
@@ -100,6 +101,29 @@ export interface IOAuthTelegramSignUpRequest {
100
101
  email: string;
101
102
  telegramIdToken: string;
102
103
  }
104
+ /** POST auth/yandex (sign-in) */
105
+ export interface IOAuthYandexSignInRequest {
106
+ yandexAccessToken: string;
107
+ }
108
+ /** POST auth/yandex (sign-up) */
109
+ export interface IOAuthYandexSignUpRequest {
110
+ login: string;
111
+ email: string;
112
+ yandexAccessToken: string;
113
+ }
114
+ /** Общие коды OAuth: VK / Telegram / Yandex (beta 21) */
115
+ export declare enum OAuthAuthResult {
116
+ InvalidRequest = 2,
117
+ NotRegistered = 3,
118
+ InvalidLogin = 4,
119
+ InvalidEmail = 5,
120
+ LoginAlreadyTaken = 6,
121
+ EmailAlreadyTaken = 7,
122
+ CodeAlreadySend = 8,
123
+ EmailServiceDisallowed = 9,
124
+ TooManyRegistrations = 10
125
+ }
126
+ /** @deprecated используйте {@link OAuthAuthResult} */
103
127
  export declare enum TelegramAuthResult {
104
128
  InvalidRequest = 2,
105
129
  NotRegistered = 3,
@@ -111,13 +135,39 @@ export declare enum TelegramAuthResult {
111
135
  EmailServiceDisallowed = 9,
112
136
  TooManyRegistrations = 10
113
137
  }
114
- export interface ITelegramAuthResponse extends IResponse<TelegramAuthResult> {
138
+ /** Коды Google OAuth (отличаются от VK/TG/Yandex) */
139
+ export declare enum GoogleAuthResult {
140
+ InvalidRequest = 2,
141
+ NotRegistered = 3,
142
+ InvalidLogin = 4,
143
+ InvalidEmail = 5,
144
+ LoginAlreadyTaken = 6,
145
+ EmailAlreadyTaken = 7,
146
+ EmailChanged = 8,
147
+ EmailChangedAndCodeAlreadySend = 9,
148
+ EmailServiceDisallowed = 10,
149
+ TooManyRegistrations = 11
150
+ }
151
+ export type VkAuthResult = OAuthAuthResult;
152
+ export type YandexAuthResult = OAuthAuthResult;
153
+ /** Базовый ответ OAuth sign-in / sign-up */
154
+ export interface IOAuthAuthResponse<T extends number = OAuthAuthResult> extends IResponse<T> {
115
155
  profile?: IProfile;
116
156
  profileToken?: IProfileToken;
117
157
  hash?: string;
118
158
  codeTimestampExpires?: number;
119
159
  suggested_logins?: string[] | null;
120
160
  }
161
+ export interface ITelegramAuthResponse extends IOAuthAuthResponse<TelegramAuthResult> {
162
+ }
163
+ export interface IVkAuthResponse extends IOAuthAuthResponse<OAuthAuthResult> {
164
+ }
165
+ export interface IGoogleAuthResponse extends IOAuthAuthResponse<GoogleAuthResult> {
166
+ }
167
+ /** Yandex дополнительно отдаёт email при регистрации */
168
+ export interface IYandexAuthResponse extends IOAuthAuthResponse<OAuthAuthResult> {
169
+ email?: string | null;
170
+ }
121
171
  export interface ILoginRequest {
122
172
  login: string;
123
173
  password: string;
@@ -129,6 +179,7 @@ export interface IResendRequest {
129
179
  vkAccessToken?: string;
130
180
  googleIdToken?: string;
131
181
  telegramIdToken?: string;
182
+ yandexAccessToken?: string;
132
183
  hash: string;
133
184
  }
134
185
  export interface IRestoreResendRequest {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TelegramAuthResult = exports.CheckLoginResult = exports.RestorePasswordVerifyResult = exports.RestorePasswordResult = exports.RegisterVerifyResult = exports.RegisterResult = exports.LoginResult = void 0;
3
+ exports.GoogleAuthResult = exports.TelegramAuthResult = exports.OAuthAuthResult = exports.CheckLoginResult = exports.RestorePasswordVerifyResult = exports.RestorePasswordResult = exports.RegisterVerifyResult = exports.RegisterResult = exports.LoginResult = void 0;
4
4
  var LoginResult;
5
5
  (function (LoginResult) {
6
6
  LoginResult[LoginResult["InvalidLogin"] = 2] = "InvalidLogin";
@@ -49,6 +49,20 @@ var CheckLoginResult;
49
49
  (function (CheckLoginResult) {
50
50
  CheckLoginResult[CheckLoginResult["InvalidLogin"] = 2] = "InvalidLogin";
51
51
  })(CheckLoginResult || (exports.CheckLoginResult = CheckLoginResult = {}));
52
+ /** Общие коды OAuth: VK / Telegram / Yandex (beta 21) */
53
+ var OAuthAuthResult;
54
+ (function (OAuthAuthResult) {
55
+ OAuthAuthResult[OAuthAuthResult["InvalidRequest"] = 2] = "InvalidRequest";
56
+ OAuthAuthResult[OAuthAuthResult["NotRegistered"] = 3] = "NotRegistered";
57
+ OAuthAuthResult[OAuthAuthResult["InvalidLogin"] = 4] = "InvalidLogin";
58
+ OAuthAuthResult[OAuthAuthResult["InvalidEmail"] = 5] = "InvalidEmail";
59
+ OAuthAuthResult[OAuthAuthResult["LoginAlreadyTaken"] = 6] = "LoginAlreadyTaken";
60
+ OAuthAuthResult[OAuthAuthResult["EmailAlreadyTaken"] = 7] = "EmailAlreadyTaken";
61
+ OAuthAuthResult[OAuthAuthResult["CodeAlreadySend"] = 8] = "CodeAlreadySend";
62
+ OAuthAuthResult[OAuthAuthResult["EmailServiceDisallowed"] = 9] = "EmailServiceDisallowed";
63
+ OAuthAuthResult[OAuthAuthResult["TooManyRegistrations"] = 10] = "TooManyRegistrations";
64
+ })(OAuthAuthResult || (exports.OAuthAuthResult = OAuthAuthResult = {}));
65
+ /** @deprecated используйте {@link OAuthAuthResult} */
52
66
  var TelegramAuthResult;
53
67
  (function (TelegramAuthResult) {
54
68
  TelegramAuthResult[TelegramAuthResult["InvalidRequest"] = 2] = "InvalidRequest";
@@ -61,3 +75,17 @@ var TelegramAuthResult;
61
75
  TelegramAuthResult[TelegramAuthResult["EmailServiceDisallowed"] = 9] = "EmailServiceDisallowed";
62
76
  TelegramAuthResult[TelegramAuthResult["TooManyRegistrations"] = 10] = "TooManyRegistrations";
63
77
  })(TelegramAuthResult || (exports.TelegramAuthResult = TelegramAuthResult = {}));
78
+ /** Коды Google OAuth (отличаются от VK/TG/Yandex) */
79
+ var GoogleAuthResult;
80
+ (function (GoogleAuthResult) {
81
+ GoogleAuthResult[GoogleAuthResult["InvalidRequest"] = 2] = "InvalidRequest";
82
+ GoogleAuthResult[GoogleAuthResult["NotRegistered"] = 3] = "NotRegistered";
83
+ GoogleAuthResult[GoogleAuthResult["InvalidLogin"] = 4] = "InvalidLogin";
84
+ GoogleAuthResult[GoogleAuthResult["InvalidEmail"] = 5] = "InvalidEmail";
85
+ GoogleAuthResult[GoogleAuthResult["LoginAlreadyTaken"] = 6] = "LoginAlreadyTaken";
86
+ GoogleAuthResult[GoogleAuthResult["EmailAlreadyTaken"] = 7] = "EmailAlreadyTaken";
87
+ GoogleAuthResult[GoogleAuthResult["EmailChanged"] = 8] = "EmailChanged";
88
+ GoogleAuthResult[GoogleAuthResult["EmailChangedAndCodeAlreadySend"] = 9] = "EmailChangedAndCodeAlreadySend";
89
+ GoogleAuthResult[GoogleAuthResult["EmailServiceDisallowed"] = 10] = "EmailServiceDisallowed";
90
+ GoogleAuthResult[GoogleAuthResult["TooManyRegistrations"] = 11] = "TooManyRegistrations";
91
+ })(GoogleAuthResult || (exports.GoogleAuthResult = GoogleAuthResult = {}));
@@ -1,5 +1,6 @@
1
1
  import { IResponse } from "./response";
2
- export declare const DEFAULT_VERSION_CODE = 26073118;
2
+ /** Anixart 9.0 BETA 21 */
3
+ export declare const DEFAULT_VERSION_CODE = 26080522;
3
4
  export interface IConfigRequest {
4
5
  versionCode?: number;
5
6
  beta?: boolean;
@@ -10,6 +11,11 @@ export interface IConfigUrlsResponse extends IResponse {
10
11
  editor_url?: string;
11
12
  static_domain?: string;
12
13
  should_use_mirror_urls: boolean;
14
+ google_auth_available?: boolean;
15
+ telegram_auth_available?: boolean;
16
+ vk_auth_available?: boolean;
17
+ yandex_auth_available?: boolean;
18
+ consent_required?: boolean;
13
19
  }
14
20
  export interface ITogglesResponse extends IResponse {
15
21
  minVersionCode?: number;
@@ -34,6 +40,8 @@ export interface ITogglesResponse extends IResponse {
34
40
  googleAuthAvailable?: boolean;
35
41
  vkAuthAvailable?: boolean;
36
42
  telegramAuthAvailable?: boolean;
43
+ yandexAuthAvailable?: boolean;
44
+ consentRequired?: boolean;
37
45
  [key: string]: unknown;
38
46
  }
39
47
  export interface ILatestArticleResponse extends IResponse {
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DEFAULT_VERSION_CODE = void 0;
4
- exports.DEFAULT_VERSION_CODE = 26073118;
4
+ /** Anixart 9.0 BETA 21 */
5
+ exports.DEFAULT_VERSION_CODE = 26080522;
@@ -78,6 +78,8 @@ export interface IProfile {
78
78
  is_sponsor_transferred: boolean;
79
79
  is_vk_bound: boolean;
80
80
  is_google_bound: boolean;
81
+ is_telegram_bound?: boolean;
82
+ is_yandex_bound?: boolean;
81
83
  is_article_notifications_enabled: boolean;
82
84
  is_release_type_notifications_enabled: boolean;
83
85
  is_episode_notifications_enabled: boolean;
@@ -266,6 +266,7 @@ export interface IDubber {
266
266
  episode_count: number;
267
267
  view_count: number;
268
268
  pinned: boolean;
269
+ quality?: number;
269
270
  }
270
271
  export interface IDubbersResponse extends IResponse {
271
272
  types: IDubber[];
@@ -276,6 +277,7 @@ export interface ISource {
276
277
  name: string;
277
278
  type: IDubber | number;
278
279
  episode_count: number;
280
+ quality?: number;
279
281
  }
280
282
  export interface ISourcesResponse extends IResponse {
281
283
  sources: ISource[];
@@ -17,6 +17,8 @@ export interface IProfileSettingsResponse extends IResponse {
17
17
  isGoogleBound: boolean;
18
18
  is_telegram_bound?: boolean;
19
19
  isTelegramBound?: boolean;
20
+ is_yandex_bound?: boolean;
21
+ isYandexBound?: boolean;
20
22
  episode_channel_widgets_hidden?: boolean;
21
23
  is_login_changed: boolean;
22
24
  isLoginChanged: boolean;
@@ -54,6 +56,18 @@ export interface IPasswordChangeRequest {
54
56
  export interface ITelegramBindRequest {
55
57
  idToken: string;
56
58
  }
59
+ /** POST profile/preference/google/bind */
60
+ export interface IGoogleBindRequest {
61
+ idToken: string;
62
+ }
63
+ /** POST profile/preference/vk/bind | yandex/bind */
64
+ export interface IAccessTokenBindRequest {
65
+ accessToken: string;
66
+ }
67
+ /** @alias IAccessTokenBindRequest */
68
+ export type IVkBindRequest = IAccessTokenBindRequest;
69
+ /** @alias IAccessTokenBindRequest */
70
+ export type IYandexBindRequest = IAccessTokenBindRequest;
57
71
  export interface ILoginInfoResponse extends IResponse {
58
72
  login: string;
59
73
  avatar: string;
@@ -100,6 +114,27 @@ export declare enum TelegramBindResult {
100
114
  export declare enum TelegramUnbindResult {
101
115
  TelegramNotBound = 2
102
116
  }
117
+ export declare enum GoogleBindResult {
118
+ InvalidRequest = 2,
119
+ GoogleAlreadyBound = 3
120
+ }
121
+ export declare enum GoogleUnbindResult {
122
+ GoogleNotBound = 2
123
+ }
124
+ export declare enum VkBindResult {
125
+ InvalidRequest = 2,
126
+ VkAlreadyBound = 3
127
+ }
128
+ export declare enum VkUnbindResult {
129
+ VkNotBound = 2
130
+ }
131
+ export declare enum YandexBindResult {
132
+ InvalidRequest = 2,
133
+ YandexAlreadyBound = 3
134
+ }
135
+ export declare enum YandexUnbindResult {
136
+ YandexNotBound = 2
137
+ }
103
138
  export declare enum ChangeEmailConfirmResult {
104
139
  InvalidPassword = 2
105
140
  }
@@ -148,17 +183,21 @@ export interface IChangeLoginResponse extends IResponse {
148
183
  export interface IChangePasswordResponse extends IResponse<ChangePasswordResult> {
149
184
  token?: string;
150
185
  }
151
- export interface IGoogleBindResponse extends IResponse {
186
+ export interface IGoogleBindResponse extends IResponse<GoogleBindResult> {
152
187
  }
153
- export interface IGoogleUnbindResponse extends IResponse {
188
+ export interface IGoogleUnbindResponse extends IResponse<GoogleUnbindResult> {
154
189
  }
155
190
  export interface ITelegramBindResponse extends IResponse<TelegramBindResult> {
156
191
  }
157
192
  export interface ITelegramUnbindResponse extends IResponse<TelegramUnbindResult> {
158
193
  }
159
- export interface IVkBindResponse extends IResponse {
194
+ export interface IVkBindResponse extends IResponse<VkBindResult> {
195
+ }
196
+ export interface IVkUnbindResponse extends IResponse<VkUnbindResult> {
197
+ }
198
+ export interface IYandexBindResponse extends IResponse<YandexBindResult> {
160
199
  }
161
- export interface IVkUnbindResponse extends IResponse {
200
+ export interface IYandexUnbindResponse extends IResponse<YandexUnbindResult> {
162
201
  }
163
202
  export interface ISocialEditResponse extends IResponse {
164
203
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PrivacyFriendRequestState = exports.PrivacyState = exports.PasswordChangeResult = exports.ChangePasswordResult = exports.ChangeEmailConfirmResult = exports.TelegramUnbindResult = exports.TelegramBindResult = exports.ChangeEmailResendResult = exports.ChangeEmailResult = exports.ChangeLoginResult = exports.SocialEditResult = void 0;
3
+ exports.PrivacyFriendRequestState = exports.PrivacyState = exports.PasswordChangeResult = exports.ChangePasswordResult = exports.ChangeEmailConfirmResult = exports.YandexUnbindResult = exports.YandexBindResult = exports.VkUnbindResult = exports.VkBindResult = exports.GoogleUnbindResult = exports.GoogleBindResult = exports.TelegramUnbindResult = exports.TelegramBindResult = exports.ChangeEmailResendResult = exports.ChangeEmailResult = exports.ChangeLoginResult = exports.SocialEditResult = void 0;
4
4
  var SocialEditResult;
5
5
  (function (SocialEditResult) {
6
6
  SocialEditResult[SocialEditResult["InvalidVk"] = 2] = "InvalidVk";
@@ -40,6 +40,33 @@ var TelegramUnbindResult;
40
40
  (function (TelegramUnbindResult) {
41
41
  TelegramUnbindResult[TelegramUnbindResult["TelegramNotBound"] = 2] = "TelegramNotBound";
42
42
  })(TelegramUnbindResult || (exports.TelegramUnbindResult = TelegramUnbindResult = {}));
43
+ var GoogleBindResult;
44
+ (function (GoogleBindResult) {
45
+ GoogleBindResult[GoogleBindResult["InvalidRequest"] = 2] = "InvalidRequest";
46
+ GoogleBindResult[GoogleBindResult["GoogleAlreadyBound"] = 3] = "GoogleAlreadyBound";
47
+ })(GoogleBindResult || (exports.GoogleBindResult = GoogleBindResult = {}));
48
+ var GoogleUnbindResult;
49
+ (function (GoogleUnbindResult) {
50
+ GoogleUnbindResult[GoogleUnbindResult["GoogleNotBound"] = 2] = "GoogleNotBound";
51
+ })(GoogleUnbindResult || (exports.GoogleUnbindResult = GoogleUnbindResult = {}));
52
+ var VkBindResult;
53
+ (function (VkBindResult) {
54
+ VkBindResult[VkBindResult["InvalidRequest"] = 2] = "InvalidRequest";
55
+ VkBindResult[VkBindResult["VkAlreadyBound"] = 3] = "VkAlreadyBound";
56
+ })(VkBindResult || (exports.VkBindResult = VkBindResult = {}));
57
+ var VkUnbindResult;
58
+ (function (VkUnbindResult) {
59
+ VkUnbindResult[VkUnbindResult["VkNotBound"] = 2] = "VkNotBound";
60
+ })(VkUnbindResult || (exports.VkUnbindResult = VkUnbindResult = {}));
61
+ var YandexBindResult;
62
+ (function (YandexBindResult) {
63
+ YandexBindResult[YandexBindResult["InvalidRequest"] = 2] = "InvalidRequest";
64
+ YandexBindResult[YandexBindResult["YandexAlreadyBound"] = 3] = "YandexAlreadyBound";
65
+ })(YandexBindResult || (exports.YandexBindResult = YandexBindResult = {}));
66
+ var YandexUnbindResult;
67
+ (function (YandexUnbindResult) {
68
+ YandexUnbindResult[YandexUnbindResult["YandexNotBound"] = 2] = "YandexNotBound";
69
+ })(YandexUnbindResult || (exports.YandexUnbindResult = YandexUnbindResult = {}));
43
70
  var ChangeEmailConfirmResult;
44
71
  (function (ChangeEmailConfirmResult) {
45
72
  ChangeEmailConfirmResult[ChangeEmailConfirmResult["InvalidPassword"] = 2] = "InvalidPassword";
@@ -108,14 +108,30 @@ const client = new Anixart({ token: "existing-token" });
108
108
  ### OAuth и регистрация
109
109
 
110
110
  ```typescript
111
- // Вход через VK
112
- await client.endpoints.auth.signInWithVk({ vkAccessToken: "..." });
111
+ import { OAuthAuthResult, GoogleAuthResult } from "anixapi";
112
+
113
+ // Вход через VK / Google / Telegram / Yandex
114
+ const vk = await client.endpoints.auth.signInWithVk({ vkAccessToken: "..." });
115
+ const google = await client.endpoints.auth.signInWithGoogle({ googleIdToken: "..." });
116
+ const tg = await client.endpoints.auth.signInWithTelegram({ telegramIdToken: "..." });
117
+ const ya = await client.endpoints.auth.signInWithYandex({ yandexAccessToken: "..." });
118
+
119
+ // code === OAuthAuthResult.NotRegistered (3) → нужно signUpWith*
120
+ if (ya.code === OAuthAuthResult.NotRegistered) {
121
+ await client.endpoints.auth.signUpWithYandex({
122
+ login: "newuser",
123
+ email: ya.email ?? "user@example.com",
124
+ yandexAccessToken: "...",
125
+ });
126
+ }
113
127
 
114
- // Регистрация
128
+ // Регистрация по email
115
129
  await client.endpoints.auth.signUp({ login, email, password });
116
130
  await client.endpoints.auth.verify({ login, email, password, code, hash });
117
131
  ```
118
132
 
133
+ Флаги доступности провайдеров: `GET config/urls` → `vk_auth_available`, `google_auth_available`, `telegram_auth_available`, `yandex_auth_available`.
134
+
119
135
  Полный список методов: `client.endpoints.auth.*`
120
136
 
121
137
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anixapi",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Unofficial Anixart API wrapper for Node.js (TypeScript)",
5
5
  "type": "commonjs",
6
6
  "main": "dist/index.js",