@citec-spbu/contracts 1.0.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/gen/ts/auth.ts ADDED
@@ -0,0 +1,83 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.10.1
4
+ // protoc v6.33.1
5
+ // source: auth.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { Observable } from "rxjs";
10
+
11
+ export const protobufPackage = "auth.v1";
12
+
13
+ export interface GithubInitRequest {
14
+ state: string;
15
+ }
16
+
17
+ export interface GithubInitResponse {
18
+ redirectUrl: string;
19
+ }
20
+
21
+ export interface GithubCallbackRequest {
22
+ code: string;
23
+ state: string;
24
+ }
25
+
26
+ export interface GithubCallbackResponse {
27
+ tokens: TokenPair | undefined;
28
+ }
29
+
30
+ export interface RefreshTokenRequest {
31
+ refreshToken: string;
32
+ }
33
+
34
+ export interface RefreshTokenResponse {
35
+ tokens: TokenPair | undefined;
36
+ }
37
+
38
+ export interface TokenPair {
39
+ accessToken: string;
40
+ refreshToken: string;
41
+ expiresIn: number;
42
+ }
43
+
44
+ export const AUTH_V1_PACKAGE_NAME = "auth.v1";
45
+
46
+ export interface AuthServiceClient {
47
+ githubInit(request: GithubInitRequest): Observable<GithubInitResponse>;
48
+
49
+ githubCallback(request: GithubCallbackRequest): Observable<GithubCallbackResponse>;
50
+
51
+ refresh(request: RefreshTokenRequest): Observable<RefreshTokenResponse>;
52
+ }
53
+
54
+ export interface AuthServiceController {
55
+ githubInit(
56
+ request: GithubInitRequest,
57
+ ): Promise<GithubInitResponse> | Observable<GithubInitResponse> | GithubInitResponse;
58
+
59
+ githubCallback(
60
+ request: GithubCallbackRequest,
61
+ ): Promise<GithubCallbackResponse> | Observable<GithubCallbackResponse> | GithubCallbackResponse;
62
+
63
+ refresh(
64
+ request: RefreshTokenRequest,
65
+ ): Promise<RefreshTokenResponse> | Observable<RefreshTokenResponse> | RefreshTokenResponse;
66
+ }
67
+
68
+ export function AuthServiceControllerMethods() {
69
+ return function (constructor: Function) {
70
+ const grpcMethods: string[] = ["githubInit", "githubCallback", "refresh"];
71
+ for (const method of grpcMethods) {
72
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
73
+ GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
74
+ }
75
+ const grpcStreamMethods: string[] = [];
76
+ for (const method of grpcStreamMethods) {
77
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
78
+ GrpcStreamMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
79
+ }
80
+ };
81
+ }
82
+
83
+ export const AUTH_SERVICE_NAME = "AuthService";
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@citec-spbu/contracts",
3
+ "version": "1.0.0",
4
+ "description": "Protobuf definitions and generated TypeScript types",
5
+ "scripts": {
6
+ "generate": "protoc -I ./proto ./proto/*.proto --ts_proto_out=./gen/ts --ts_proto_opt=nestJs=true,package=omit"
7
+ },
8
+ "files": [
9
+ "proto",
10
+ "gen"
11
+ ],
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "dependencies": {
16
+ "@nestjs/microservices": "^11.1.11",
17
+ "rxjs": "^7.8.2",
18
+ "ts-proto": "^2.10.1"
19
+ }
20
+ }
@@ -0,0 +1,42 @@
1
+ syntax = "proto3";
2
+
3
+ package auth.v1;
4
+
5
+ service AuthService {
6
+ rpc GithubInit(GithubInitRequest) returns (GithubInitResponse) {}
7
+
8
+ rpc GithubCallback(GithubCallbackRequest) returns (GithubCallbackResponse) {}
9
+
10
+ rpc Refresh(RefreshTokenRequest) returns (RefreshTokenResponse) {}
11
+ }
12
+
13
+ message GithubInitRequest {
14
+ string state = 1;
15
+ }
16
+
17
+ message GithubInitResponse {
18
+ string redirect_url = 1;
19
+ }
20
+
21
+ message GithubCallbackRequest {
22
+ string code = 1;
23
+ string state = 2;
24
+ }
25
+
26
+ message GithubCallbackResponse {
27
+ TokenPair tokens = 1;
28
+ }
29
+
30
+ message RefreshTokenRequest {
31
+ string refresh_token = 1;
32
+ }
33
+
34
+ message RefreshTokenResponse {
35
+ TokenPair tokens = 1;
36
+ }
37
+
38
+ message TokenPair {
39
+ string access_token = 1;
40
+ string refresh_token = 2;
41
+ int64 expires_in = 3;
42
+ }