@citec-spbu/contracts 1.0.2 → 1.0.4

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 node_path_1 = require("node:path");
5
5
  exports.PROTO_PATHS = {
6
6
  AUTH: (0, node_path_1.join)(__dirname, "../../proto/auth.proto"),
7
+ ACCOUNT: (0, node_path_1.join)(__dirname, "../../proto/account.proto"),
7
8
  };
@@ -0,0 +1,57 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.10.1
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
+ ROLE_UNSPECIFIED = 0,
15
+ ROLE_USER = 1,
16
+ ROLE_SUPERVISOR = 2,
17
+ ROLE_ADMIN = 3,
18
+ UNRECOGNIZED = -1,
19
+ }
20
+
21
+ export interface GetAccountRequest {
22
+ id: string;
23
+ }
24
+
25
+ export interface GetAccountResponse {
26
+ id: string;
27
+ role: Role;
28
+ }
29
+
30
+ export const ACCOUNT_V1_PACKAGE_NAME = "account.v1";
31
+
32
+ export interface AccountServiceClient {
33
+ getAccount(request: GetAccountRequest): Observable<GetAccountResponse>;
34
+ }
35
+
36
+ export interface AccountServiceController {
37
+ getAccount(
38
+ request: GetAccountRequest,
39
+ ): Promise<GetAccountResponse> | Observable<GetAccountResponse> | GetAccountResponse;
40
+ }
41
+
42
+ export function AccountServiceControllerMethods() {
43
+ return function (constructor: Function) {
44
+ const grpcMethods: string[] = ["getAccount"];
45
+ for (const method of grpcMethods) {
46
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
47
+ GrpcMethod("AccountService", method)(constructor.prototype[method], method, descriptor);
48
+ }
49
+ const grpcStreamMethods: string[] = [];
50
+ for (const method of grpcStreamMethods) {
51
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
52
+ GrpcStreamMethod("AccountService", method)(constructor.prototype[method], method, descriptor);
53
+ }
54
+ };
55
+ }
56
+
57
+ export const ACCOUNT_SERVICE_NAME = "AccountService";
package/gen/ts/auth.ts CHANGED
@@ -10,64 +10,62 @@ import { Observable } from "rxjs";
10
10
 
11
11
  export const protobufPackage = "auth.v1";
12
12
 
13
- export interface GithubInitRequest {
14
- state: string;
13
+ export interface GenerateJwtRequest {
14
+ provider: string;
15
+ providerId: string;
15
16
  }
16
17
 
17
- export interface GithubInitResponse {
18
- redirectUrl: string;
18
+ export interface GenerateJwtResponse {
19
+ tokens: TokenPair | undefined;
19
20
  }
20
21
 
21
- export interface GithubCallbackRequest {
22
- code: string;
23
- state: string;
22
+ export interface ValidateJwtRequest {
23
+ accessToken: string;
24
24
  }
25
25
 
26
- export interface GithubCallbackResponse {
27
- tokens: TokenPair | undefined;
26
+ export interface ValidateJwtResponse {
27
+ valid: boolean;
28
+ accountId: string;
28
29
  }
29
30
 
30
- export interface RefreshTokenRequest {
31
+ export interface RefreshRequest {
31
32
  refreshToken: string;
32
33
  }
33
34
 
34
- export interface RefreshTokenResponse {
35
+ export interface RefreshResponse {
35
36
  tokens: TokenPair | undefined;
36
37
  }
37
38
 
38
39
  export interface TokenPair {
39
40
  accessToken: string;
40
41
  refreshToken: string;
41
- expiresIn: number;
42
42
  }
43
43
 
44
44
  export const AUTH_V1_PACKAGE_NAME = "auth.v1";
45
45
 
46
46
  export interface AuthServiceClient {
47
- githubInit(request: GithubInitRequest): Observable<GithubInitResponse>;
47
+ generateJwt(request: GenerateJwtRequest): Observable<GenerateJwtResponse>;
48
48
 
49
- githubCallback(request: GithubCallbackRequest): Observable<GithubCallbackResponse>;
49
+ validateJwt(request: ValidateJwtRequest): Observable<ValidateJwtResponse>;
50
50
 
51
- refresh(request: RefreshTokenRequest): Observable<RefreshTokenResponse>;
51
+ refresh(request: RefreshRequest): Observable<RefreshResponse>;
52
52
  }
53
53
 
54
54
  export interface AuthServiceController {
55
- githubInit(
56
- request: GithubInitRequest,
57
- ): Promise<GithubInitResponse> | Observable<GithubInitResponse> | GithubInitResponse;
55
+ generateJwt(
56
+ request: GenerateJwtRequest,
57
+ ): Promise<GenerateJwtResponse> | Observable<GenerateJwtResponse> | GenerateJwtResponse;
58
58
 
59
- githubCallback(
60
- request: GithubCallbackRequest,
61
- ): Promise<GithubCallbackResponse> | Observable<GithubCallbackResponse> | GithubCallbackResponse;
59
+ validateJwt(
60
+ request: ValidateJwtRequest,
61
+ ): Promise<ValidateJwtResponse> | Observable<ValidateJwtResponse> | ValidateJwtResponse;
62
62
 
63
- refresh(
64
- request: RefreshTokenRequest,
65
- ): Promise<RefreshTokenResponse> | Observable<RefreshTokenResponse> | RefreshTokenResponse;
63
+ refresh(request: RefreshRequest): Promise<RefreshResponse> | Observable<RefreshResponse> | RefreshResponse;
66
64
  }
67
65
 
68
66
  export function AuthServiceControllerMethods() {
69
67
  return function (constructor: Function) {
70
- const grpcMethods: string[] = ["githubInit", "githubCallback", "refresh"];
68
+ const grpcMethods: string[] = ["generateJwt", "validateJwt", "refresh"];
71
69
  for (const method of grpcMethods) {
72
70
  const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
73
71
  GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@citec-spbu/contracts",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Protobuf definitions and generated TypeScript types",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",
@@ -0,0 +1,23 @@
1
+ syntax = "proto3";
2
+
3
+ package account.v1;
4
+
5
+ service AccountService {
6
+ rpc GetAccount(GetAccountRequest) returns (GetAccountResponse);
7
+ }
8
+
9
+ message GetAccountRequest {
10
+ string id = 1;
11
+ }
12
+
13
+ message GetAccountResponse {
14
+ string id = 1;
15
+ Role role = 2;
16
+ }
17
+
18
+ enum Role {
19
+ ROLE_UNSPECIFIED = 0;
20
+ ROLE_USER = 1;
21
+ ROLE_SUPERVISOR = 2;
22
+ ROLE_ADMIN = 3;
23
+ }
package/proto/auth.proto CHANGED
@@ -3,40 +3,40 @@ syntax = "proto3";
3
3
  package auth.v1;
4
4
 
5
5
  service AuthService {
6
- rpc GithubInit(GithubInitRequest) returns (GithubInitResponse) {}
6
+ rpc GenerateJwt(GenerateJwtRequest) returns (GenerateJwtResponse);
7
7
 
8
- rpc GithubCallback(GithubCallbackRequest) returns (GithubCallbackResponse) {}
8
+ rpc ValidateJwt(ValidateJwtRequest) returns (ValidateJwtResponse);
9
9
 
10
- rpc Refresh(RefreshTokenRequest) returns (RefreshTokenResponse) {}
10
+ rpc Refresh(RefreshRequest) returns (RefreshResponse);
11
11
  }
12
12
 
13
- message GithubInitRequest {
14
- string state = 1;
13
+ message GenerateJwtRequest {
14
+ string provider = 1;
15
+ string provider_id = 2;
15
16
  }
16
17
 
17
- message GithubInitResponse {
18
- string redirect_url = 1;
18
+ message GenerateJwtResponse {
19
+ TokenPair tokens = 1;
19
20
  }
20
21
 
21
- message GithubCallbackRequest {
22
- string code = 1;
23
- string state = 2;
22
+ message ValidateJwtRequest {
23
+ string access_token = 1;
24
24
  }
25
25
 
26
- message GithubCallbackResponse {
27
- TokenPair tokens = 1;
26
+ message ValidateJwtResponse {
27
+ bool valid = 1;
28
+ string account_id = 2;
28
29
  }
29
30
 
30
- message RefreshTokenRequest {
31
+ message RefreshRequest {
31
32
  string refresh_token = 1;
32
33
  }
33
34
 
34
- message RefreshTokenResponse {
35
+ message RefreshResponse {
35
36
  TokenPair tokens = 1;
36
37
  }
37
38
 
38
39
  message TokenPair {
39
40
  string access_token = 1;
40
41
  string refresh_token = 2;
41
- int64 expires_in = 3;
42
42
  }