@purpleschool/gptbot 0.5.45 → 0.5.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/api/controllers/http/index.ts +1 -0
  2. package/api/controllers/http/telegram-auth.ts +7 -0
  3. package/api/routes.ts +6 -0
  4. package/build/api/controllers/http/index.js +1 -0
  5. package/build/api/controllers/http/telegram-auth.js +9 -0
  6. package/build/api/routes.js +5 -0
  7. package/build/commands/index.js +1 -0
  8. package/build/commands/telegram-auth/create-telegram-auth-link.command.js +13 -0
  9. package/build/commands/telegram-auth/get-telegram-auth-session-status.command.js +18 -0
  10. package/build/commands/telegram-auth/index.js +19 -0
  11. package/build/commands/telegram-auth/redeem-telegram-auth-session.command.js +15 -0
  12. package/build/constants/errors/errors.js +20 -0
  13. package/build/constants/telegram/index.js +1 -0
  14. package/build/constants/telegram/telegram-auth/enums/index.js +17 -0
  15. package/build/constants/telegram/telegram-auth/enums/telegram-auth-status.enum.js +10 -0
  16. package/build/constants/telegram/telegram-auth/index.js +17 -0
  17. package/commands/index.ts +1 -0
  18. package/commands/telegram-auth/create-telegram-auth-link.command.ts +11 -0
  19. package/commands/telegram-auth/get-telegram-auth-session-status.command.ts +19 -0
  20. package/commands/telegram-auth/index.ts +3 -0
  21. package/commands/telegram-auth/redeem-telegram-auth-session.command.ts +16 -0
  22. package/constants/errors/errors.ts +20 -0
  23. package/constants/telegram/index.ts +1 -0
  24. package/constants/telegram/telegram-auth/enums/index.ts +1 -0
  25. package/constants/telegram/telegram-auth/enums/telegram-auth-status.enum.ts +6 -0
  26. package/constants/telegram/telegram-auth/index.ts +1 -0
  27. package/package.json +1 -1
@@ -18,6 +18,7 @@ export * from './product';
18
18
  export * from './question';
19
19
  export * from './subscription';
20
20
  export * from './task';
21
+ export * from './telegram-auth';
21
22
  export * from './telegram-connect';
22
23
  export * from './telegram-profile';
23
24
  export * from './unregistered-user';
@@ -0,0 +1,7 @@
1
+ export const TELEGRAM_AUTH_CONTROLLER = 'telegram-auth';
2
+
3
+ export const TELEGRAM_AUTH_ROUTES = {
4
+ CREATE_SESSION: '',
5
+ STATUS: (uuid: string) => `${uuid}/status`,
6
+ REDEEM: 'redeem',
7
+ };
package/api/routes.ts CHANGED
@@ -165,4 +165,10 @@ export const REST_API = {
165
165
  VALIDATE_PUBLIC: (code: string) =>
166
166
  `${ROOT}/${CONTROLLERS.PROMOCODE_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMOCODE_ROUTES.VALIDATE}/${code}`,
167
167
  },
168
+ TELEGRAM_AUTH: {
169
+ CREATE_SESSION: `${ROOT}/${CONTROLLERS.TELEGRAM_AUTH_CONTROLLER}`,
170
+ STATUS: (uuid: string) =>
171
+ `${ROOT}/${CONTROLLERS.TELEGRAM_AUTH_CONTROLLER}/${CONTROLLERS.TELEGRAM_AUTH_ROUTES.STATUS(uuid)}`,
172
+ REDEEM: `${ROOT}/${CONTROLLERS.TELEGRAM_AUTH_CONTROLLER}/${CONTROLLERS.TELEGRAM_AUTH_ROUTES.REDEEM}`,
173
+ },
168
174
  } as const;
@@ -34,6 +34,7 @@ __exportStar(require("./product"), exports);
34
34
  __exportStar(require("./question"), exports);
35
35
  __exportStar(require("./subscription"), exports);
36
36
  __exportStar(require("./task"), exports);
37
+ __exportStar(require("./telegram-auth"), exports);
37
38
  __exportStar(require("./telegram-connect"), exports);
38
39
  __exportStar(require("./telegram-profile"), exports);
39
40
  __exportStar(require("./unregistered-user"), exports);
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TELEGRAM_AUTH_ROUTES = exports.TELEGRAM_AUTH_CONTROLLER = void 0;
4
+ exports.TELEGRAM_AUTH_CONTROLLER = 'telegram-auth';
5
+ exports.TELEGRAM_AUTH_ROUTES = {
6
+ CREATE_SESSION: '',
7
+ STATUS: (uuid) => `${uuid}/status`,
8
+ REDEEM: 'redeem',
9
+ };
@@ -170,4 +170,9 @@ exports.REST_API = {
170
170
  VALIDATE_PRIVATE: (code) => `${exports.ROOT}/${CONTROLLERS.PROMOCODE_PRIVATE_CONTROLLER}/${CONTROLLERS.PROMOCODE_ROUTES.VALIDATE}/${code}`,
171
171
  VALIDATE_PUBLIC: (code) => `${exports.ROOT}/${CONTROLLERS.PROMOCODE_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMOCODE_ROUTES.VALIDATE}/${code}`,
172
172
  },
173
+ TELEGRAM_AUTH: {
174
+ CREATE_SESSION: `${exports.ROOT}/${CONTROLLERS.TELEGRAM_AUTH_CONTROLLER}`,
175
+ STATUS: (uuid) => `${exports.ROOT}/${CONTROLLERS.TELEGRAM_AUTH_CONTROLLER}/${CONTROLLERS.TELEGRAM_AUTH_ROUTES.STATUS(uuid)}`,
176
+ REDEEM: `${exports.ROOT}/${CONTROLLERS.TELEGRAM_AUTH_CONTROLLER}/${CONTROLLERS.TELEGRAM_AUTH_ROUTES.REDEEM}`,
177
+ },
173
178
  };
@@ -33,6 +33,7 @@ __exportStar(require("./referral"), exports);
33
33
  __exportStar(require("./subscription"), exports);
34
34
  __exportStar(require("./task"), exports);
35
35
  __exportStar(require("./telegram"), exports);
36
+ __exportStar(require("./telegram-auth"), exports);
36
37
  __exportStar(require("./telegram-profile"), exports);
37
38
  __exportStar(require("./unregistered-user"), exports);
38
39
  __exportStar(require("./user"), exports);
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateTelegramAuthLinkCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ var CreateTelegramAuthLinkCommand;
6
+ (function (CreateTelegramAuthLinkCommand) {
7
+ CreateTelegramAuthLinkCommand.ResponseSchema = zod_1.z.object({
8
+ data: zod_1.z.object({
9
+ uuid: zod_1.z.string().uuid(),
10
+ link: zod_1.z.string(),
11
+ }),
12
+ });
13
+ })(CreateTelegramAuthLinkCommand || (exports.CreateTelegramAuthLinkCommand = CreateTelegramAuthLinkCommand = {}));
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetTelegramAuthSessionStatusCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const constants_1 = require("../../constants");
6
+ var GetTelegramAuthSessionStatusCommand;
7
+ (function (GetTelegramAuthSessionStatusCommand) {
8
+ GetTelegramAuthSessionStatusCommand.RequestParamsSchema = zod_1.z.object({
9
+ uuid: zod_1.z.string().uuid(),
10
+ });
11
+ GetTelegramAuthSessionStatusCommand.ResponseSchema = zod_1.z.object({
12
+ data: zod_1.z.object({
13
+ uuid: zod_1.z.string().uuid(),
14
+ status: zod_1.z.nativeEnum(constants_1.TELEGRAM_AUTH_STATUS),
15
+ expiresAt: zod_1.z.date(),
16
+ }),
17
+ });
18
+ })(GetTelegramAuthSessionStatusCommand || (exports.GetTelegramAuthSessionStatusCommand = GetTelegramAuthSessionStatusCommand = {}));
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./create-telegram-auth-link.command"), exports);
18
+ __exportStar(require("./get-telegram-auth-session-status.command"), exports);
19
+ __exportStar(require("./redeem-telegram-auth-session.command"), exports);
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RedeemTelegramAuthSessionCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ var RedeemTelegramAuthSessionCommand;
6
+ (function (RedeemTelegramAuthSessionCommand) {
7
+ RedeemTelegramAuthSessionCommand.RequestSchema = zod_1.z.object({
8
+ uuid: zod_1.z.string().uuid(),
9
+ });
10
+ RedeemTelegramAuthSessionCommand.ResponseSchema = zod_1.z.object({
11
+ data: zod_1.z.object({
12
+ accessToken: zod_1.z.string(),
13
+ }),
14
+ });
15
+ })(RedeemTelegramAuthSessionCommand || (exports.RedeemTelegramAuthSessionCommand = RedeemTelegramAuthSessionCommand = {}));
@@ -915,4 +915,24 @@ exports.ERRORS = {
915
915
  message: 'Промокод не провалидирован',
916
916
  httpCode: 500,
917
917
  },
918
+ TELEGRAM_AUTH_CODE_CREATE_ERROR: {
919
+ code: 'A209',
920
+ message: 'Произошла ошибка при создании ссылки для авторизации через Telegram',
921
+ httpCode: 500,
922
+ },
923
+ TELEGRAM_AUTH_CODE_INVALID: {
924
+ code: 'A210',
925
+ message: 'Ссылка для авторизации через Telegram недействительна или устарела',
926
+ httpCode: 400,
927
+ },
928
+ TELEGRAM_AUTH_SESSION_UPDATE_ERROR: {
929
+ code: 'A211',
930
+ message: 'Произошла ошибка при обновлении сессии авторизации через Telegram',
931
+ httpCode: 500,
932
+ },
933
+ TELEGRAM_AUTH_CODE_ALREADY_USED: {
934
+ code: 'A212',
935
+ message: 'Ссылка для авторизации через телеграм уже была использована',
936
+ httpCode: 400,
937
+ },
918
938
  };
@@ -14,5 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./telegram-auth"), exports);
17
18
  __exportStar(require("./telegram-auth-log"), exports);
18
19
  __exportStar(require("./telegram-connect"), exports);
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./telegram-auth-status.enum"), exports);
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TELEGRAM_AUTH_STATUS = void 0;
4
+ var TELEGRAM_AUTH_STATUS;
5
+ (function (TELEGRAM_AUTH_STATUS) {
6
+ TELEGRAM_AUTH_STATUS["PENDING"] = "pending";
7
+ TELEGRAM_AUTH_STATUS["APPROVED"] = "approved";
8
+ TELEGRAM_AUTH_STATUS["REDEEMED"] = "redeemed";
9
+ TELEGRAM_AUTH_STATUS["EXPIRED"] = "expired";
10
+ })(TELEGRAM_AUTH_STATUS || (exports.TELEGRAM_AUTH_STATUS = TELEGRAM_AUTH_STATUS = {}));
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./enums"), exports);
package/commands/index.ts CHANGED
@@ -17,6 +17,7 @@ export * from './referral';
17
17
  export * from './subscription';
18
18
  export * from './task';
19
19
  export * from './telegram';
20
+ export * from './telegram-auth';
20
21
  export * from './telegram-profile';
21
22
  export * from './unregistered-user';
22
23
  export * from './user';
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace CreateTelegramAuthLinkCommand {
4
+ export const ResponseSchema = z.object({
5
+ data: z.object({
6
+ uuid: z.string().uuid(),
7
+ link: z.string(),
8
+ }),
9
+ });
10
+ export type Response = z.infer<typeof ResponseSchema>;
11
+ }
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ import { TELEGRAM_AUTH_STATUS } from '../../constants';
3
+
4
+ export namespace GetTelegramAuthSessionStatusCommand {
5
+ export const RequestParamsSchema = z.object({
6
+ uuid: z.string().uuid(),
7
+ });
8
+
9
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
10
+
11
+ export const ResponseSchema = z.object({
12
+ data: z.object({
13
+ uuid: z.string().uuid(),
14
+ status: z.nativeEnum(TELEGRAM_AUTH_STATUS),
15
+ expiresAt: z.date(),
16
+ }),
17
+ });
18
+ export type Response = z.infer<typeof ResponseSchema>;
19
+ }
@@ -0,0 +1,3 @@
1
+ export * from './create-telegram-auth-link.command';
2
+ export * from './get-telegram-auth-session-status.command';
3
+ export * from './redeem-telegram-auth-session.command';
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace RedeemTelegramAuthSessionCommand {
4
+ export const RequestSchema = z.object({
5
+ uuid: z.string().uuid(),
6
+ });
7
+
8
+ export type Request = z.infer<typeof RequestSchema>;
9
+
10
+ export const ResponseSchema = z.object({
11
+ data: z.object({
12
+ accessToken: z.string(),
13
+ }),
14
+ });
15
+ export type Response = z.infer<typeof ResponseSchema>;
16
+ }
@@ -917,4 +917,24 @@ export const ERRORS = {
917
917
  message: 'Промокод не провалидирован',
918
918
  httpCode: 500,
919
919
  },
920
+ TELEGRAM_AUTH_CODE_CREATE_ERROR: {
921
+ code: 'A209',
922
+ message: 'Произошла ошибка при создании ссылки для авторизации через Telegram',
923
+ httpCode: 500,
924
+ },
925
+ TELEGRAM_AUTH_CODE_INVALID: {
926
+ code: 'A210',
927
+ message: 'Ссылка для авторизации через Telegram недействительна или устарела',
928
+ httpCode: 400,
929
+ },
930
+ TELEGRAM_AUTH_SESSION_UPDATE_ERROR: {
931
+ code: 'A211',
932
+ message: 'Произошла ошибка при обновлении сессии авторизации через Telegram',
933
+ httpCode: 500,
934
+ },
935
+ TELEGRAM_AUTH_CODE_ALREADY_USED: {
936
+ code: 'A212',
937
+ message: 'Ссылка для авторизации через телеграм уже была использована',
938
+ httpCode: 400,
939
+ },
920
940
  };
@@ -1,2 +1,3 @@
1
+ export * from './telegram-auth';
1
2
  export * from './telegram-auth-log';
2
3
  export * from './telegram-connect';
@@ -0,0 +1 @@
1
+ export * from './telegram-auth-status.enum';
@@ -0,0 +1,6 @@
1
+ export enum TELEGRAM_AUTH_STATUS {
2
+ PENDING = 'pending',
3
+ APPROVED = 'approved',
4
+ REDEEMED = 'redeemed',
5
+ EXPIRED = 'expired',
6
+ }
@@ -0,0 +1 @@
1
+ export * from './enums';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.5.45",
3
+ "version": "0.5.46",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",