@getastro/contracts 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
1
  export declare const PROTO_PATHS: {
2
2
  readonly AUTH: string;
3
+ readonly ACCOUNT: string;
3
4
  };
@@ -4,4 +4,5 @@ exports.PROTO_PATHS = void 0;
4
4
  const path_1 = require("path");
5
5
  exports.PROTO_PATHS = {
6
6
  AUTH: (0, path_1.join)(__dirname, '../../proto/auth.proto'),
7
+ ACCOUNT: (0, path_1.join)(__dirname, '../../proto/account.proto'),
7
8
  };
package/gen/account.ts ADDED
@@ -0,0 +1,67 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.2
4
+ // protoc v3.21.12
5
+ // source: account.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { Observable } from "rxjs";
10
+
11
+ export const protobufPackage = "account.v1";
12
+
13
+ export enum Role {
14
+ USER = 0,
15
+ ADMIN = 1,
16
+ UNRECOGNIZED = -1,
17
+ }
18
+
19
+ export interface GetAccountRequest {
20
+ id: string;
21
+ }
22
+
23
+ export interface GetAccountResponse {
24
+ id: string;
25
+ phone: string;
26
+ email: string;
27
+ isPhoneVerified: boolean;
28
+ isEmailVerified: boolean;
29
+ role: Role;
30
+ }
31
+
32
+ export const ACCOUNT_V1_PACKAGE_NAME = "account.v1";
33
+
34
+ /** Сервис для управления аккаунтами пользователей. */
35
+
36
+ export interface AccountServiceClient {
37
+ /** Получает информацию об аккаунте по access token. */
38
+
39
+ getAccount(request: GetAccountRequest): Observable<GetAccountResponse>;
40
+ }
41
+
42
+ /** Сервис для управления аккаунтами пользователей. */
43
+
44
+ export interface AccountServiceController {
45
+ /** Получает информацию об аккаунте по access token. */
46
+
47
+ getAccount(
48
+ request: GetAccountRequest,
49
+ ): Promise<GetAccountResponse> | Observable<GetAccountResponse> | GetAccountResponse;
50
+ }
51
+
52
+ export function AccountServiceControllerMethods() {
53
+ return function (constructor: Function) {
54
+ const grpcMethods: string[] = ["getAccount"];
55
+ for (const method of grpcMethods) {
56
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
57
+ GrpcMethod("AccountService", method)(constructor.prototype[method], method, descriptor);
58
+ }
59
+ const grpcStreamMethods: string[] = [];
60
+ for (const method of grpcStreamMethods) {
61
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
62
+ GrpcStreamMethod("AccountService", method)(constructor.prototype[method], method, descriptor);
63
+ }
64
+ };
65
+ }
66
+
67
+ export const ACCOUNT_SERVICE_NAME = "AccountService";
package/gen/auth.ts CHANGED
@@ -30,6 +30,15 @@ export interface VerifyOtpResponse {
30
30
  refreshToken: string;
31
31
  }
32
32
 
33
+ export interface RefreshRequest {
34
+ refreshToken: string;
35
+ }
36
+
37
+ export interface RefreshResponse {
38
+ accessToken: string;
39
+ refreshToken: string;
40
+ }
41
+
33
42
  export const AUTH_V1_PACKAGE_NAME = "auth.v1";
34
43
 
35
44
  /** Сервис аутентификации для управления одноразовыми паролями (OTP) и токенами. */
@@ -42,6 +51,10 @@ export interface AuthServiceClient {
42
51
  /** Проверяет код и возвращает пару JWT токенов при успехе. */
43
52
 
44
53
  verifyOtp(request: VerifyOtpRequest): Observable<VerifyOtpResponse>;
54
+
55
+ /** Обновляет access token, используя refresh token. */
56
+
57
+ refresh(request: RefreshRequest): Observable<RefreshResponse>;
45
58
  }
46
59
 
47
60
  /** Сервис аутентификации для управления одноразовыми паролями (OTP) и токенами. */
@@ -54,11 +67,15 @@ export interface AuthServiceController {
54
67
  /** Проверяет код и возвращает пару JWT токенов при успехе. */
55
68
 
56
69
  verifyOtp(request: VerifyOtpRequest): Promise<VerifyOtpResponse> | Observable<VerifyOtpResponse> | VerifyOtpResponse;
70
+
71
+ /** Обновляет access token, используя refresh token. */
72
+
73
+ refresh(request: RefreshRequest): Promise<RefreshResponse> | Observable<RefreshResponse> | RefreshResponse;
57
74
  }
58
75
 
59
76
  export function AuthServiceControllerMethods() {
60
77
  return function (constructor: Function) {
61
- const grpcMethods: string[] = ["sendOtp", "verifyOtp"];
78
+ const grpcMethods: string[] = ["sendOtp", "verifyOtp", "refresh"];
62
79
  for (const method of grpcMethods) {
63
80
  const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
64
81
  GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getastro/contracts",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Protobuf definitions and generated TypeScript types",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,28 @@
1
+ syntax = "proto3";
2
+
3
+ package account.v1;
4
+
5
+ // Сервис для управления аккаунтами пользователей.
6
+ service AccountService {
7
+ // Получает информацию об аккаунте по access token.
8
+ rpc GetAccount (GetAccountRequest) returns (GetAccountResponse);
9
+ }
10
+
11
+ message GetAccountRequest {
12
+ string id = 1;
13
+ }
14
+
15
+ message GetAccountResponse {
16
+ string id = 1;
17
+ string phone = 2;
18
+ string email = 3;
19
+ bool is_phone_verified = 4;
20
+ bool is_email_verified = 5;
21
+ Role role = 6;
22
+ }
23
+
24
+ enum Role {
25
+ USER = 0;
26
+ ADMIN = 1;
27
+ }
28
+
package/proto/auth.proto CHANGED
@@ -9,6 +9,9 @@ service AuthService {
9
9
 
10
10
  // Проверяет код и возвращает пару JWT токенов при успехе.
11
11
  rpc VerifyOtp (VerifyOtpRequest) returns (VerifyOtpResponse);
12
+
13
+ // Обновляет access token, используя refresh token.
14
+ rpc Refresh (RefreshRequest) returns (RefreshResponse);
12
15
  }
13
16
 
14
17
  message SendOtpRequest {
@@ -29,4 +32,13 @@ message VerifyOtpRequest {
29
32
  message VerifyOtpResponse {
30
33
  string access_token = 1;
31
34
  string refresh_token = 2;
35
+ }
36
+
37
+ message RefreshRequest {
38
+ string refresh_token = 1;
39
+ }
40
+
41
+ message RefreshResponse {
42
+ string access_token = 1;
43
+ string refresh_token = 2;
32
44
  }