@prodoctors/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/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/dist/proto/index.d.ts +1 -0
- package/dist/proto/index.js +17 -0
- package/dist/proto/paths.d.ts +3 -0
- package/dist/proto/paths.js +7 -0
- package/gen/auth.ts +127 -0
- package/package.json +28 -0
- package/proto/auth.proto +68 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './proto';
|
package/dist/index.js
ADDED
|
@@ -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("./proto"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './paths';
|
|
@@ -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("./paths"), exports);
|
package/gen/auth.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v2.11.4
|
|
4
|
+
// protoc v7.34.0
|
|
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 LoginRequest {
|
|
14
|
+
login: string;
|
|
15
|
+
password: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface LoginResponse {
|
|
19
|
+
accessToken: string;
|
|
20
|
+
refreshToken: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface RegisterRequest {
|
|
24
|
+
name: string;
|
|
25
|
+
username: string;
|
|
26
|
+
password: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface RegisterResponse {
|
|
30
|
+
ok: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface SendOtpRequest {
|
|
34
|
+
identifier: string;
|
|
35
|
+
type: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface SendOtpResponse {
|
|
39
|
+
ok: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface VerifyOtpRequest {
|
|
43
|
+
identifier: string;
|
|
44
|
+
type: string;
|
|
45
|
+
code: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface VerifyOtpResponse {
|
|
49
|
+
accessToken: string;
|
|
50
|
+
refreshToken: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface RefreshRequest {
|
|
54
|
+
refreshToken: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface RefreshResponse {
|
|
58
|
+
accessToken: string;
|
|
59
|
+
refreshToken: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const AUTH_V1_PACKAGE_NAME = "auth.v1";
|
|
63
|
+
|
|
64
|
+
/** Authentication service for sending and verifying OTPs */
|
|
65
|
+
|
|
66
|
+
export interface AuthServiceClient {
|
|
67
|
+
/** Authoriration user */
|
|
68
|
+
|
|
69
|
+
login(request: LoginRequest): Observable<LoginResponse>;
|
|
70
|
+
|
|
71
|
+
/** Registration user */
|
|
72
|
+
|
|
73
|
+
register(request: RegisterRequest): Observable<RegisterResponse>;
|
|
74
|
+
|
|
75
|
+
/** Send OTP to the user */
|
|
76
|
+
|
|
77
|
+
sendOtp(request: SendOtpRequest): Observable<SendOtpResponse>;
|
|
78
|
+
|
|
79
|
+
/** Verify the OTP sent to the user */
|
|
80
|
+
|
|
81
|
+
verifyOtp(request: VerifyOtpRequest): Observable<VerifyOtpResponse>;
|
|
82
|
+
|
|
83
|
+
/** Refersh token */
|
|
84
|
+
|
|
85
|
+
refresh(request: RefreshRequest): Observable<RefreshResponse>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Authentication service for sending and verifying OTPs */
|
|
89
|
+
|
|
90
|
+
export interface AuthServiceController {
|
|
91
|
+
/** Authoriration user */
|
|
92
|
+
|
|
93
|
+
login(request: LoginRequest): Promise<LoginResponse> | Observable<LoginResponse> | LoginResponse;
|
|
94
|
+
|
|
95
|
+
/** Registration user */
|
|
96
|
+
|
|
97
|
+
register(request: RegisterRequest): Promise<RegisterResponse> | Observable<RegisterResponse> | RegisterResponse;
|
|
98
|
+
|
|
99
|
+
/** Send OTP to the user */
|
|
100
|
+
|
|
101
|
+
sendOtp(request: SendOtpRequest): Promise<SendOtpResponse> | Observable<SendOtpResponse> | SendOtpResponse;
|
|
102
|
+
|
|
103
|
+
/** Verify the OTP sent to the user */
|
|
104
|
+
|
|
105
|
+
verifyOtp(request: VerifyOtpRequest): Promise<VerifyOtpResponse> | Observable<VerifyOtpResponse> | VerifyOtpResponse;
|
|
106
|
+
|
|
107
|
+
/** Refersh token */
|
|
108
|
+
|
|
109
|
+
refresh(request: RefreshRequest): Promise<RefreshResponse> | Observable<RefreshResponse> | RefreshResponse;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function AuthServiceControllerMethods() {
|
|
113
|
+
return function (constructor: Function) {
|
|
114
|
+
const grpcMethods: string[] = ["login", "register", "sendOtp", "verifyOtp", "refresh"];
|
|
115
|
+
for (const method of grpcMethods) {
|
|
116
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
117
|
+
GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
|
|
118
|
+
}
|
|
119
|
+
const grpcStreamMethods: string[] = [];
|
|
120
|
+
for (const method of grpcStreamMethods) {
|
|
121
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
122
|
+
GrpcStreamMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export const AUTH_SERVICE_NAME = "AuthService";
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@prodoctors/contracts",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Protobuf definitions and generated Typescript types for ProDoctors",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc -p tsconfig.build.json",
|
|
9
|
+
"generate": "protoc -I ./proto ./proto/*.proto --ts_proto_out=./gen --ts_proto_opt=nestJs=true,package=omit"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"proto",
|
|
13
|
+
"gen",
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@nestjs/microservices": "^11.1.15",
|
|
21
|
+
"rxjs": "^7.8.2",
|
|
22
|
+
"ts-proto": "^2.11.4"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^25.3.5",
|
|
26
|
+
"typescript": "^5.9.3"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/proto/auth.proto
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package auth.v1;
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
// Authentication service for sending and verifying OTPs
|
|
7
|
+
service AuthService {
|
|
8
|
+
// Authoriration user
|
|
9
|
+
rpc Login (LoginRequest) returns (LoginResponse);
|
|
10
|
+
|
|
11
|
+
// Registration user
|
|
12
|
+
rpc Register (RegisterRequest) returns (RegisterResponse);
|
|
13
|
+
|
|
14
|
+
// Send OTP to the user
|
|
15
|
+
rpc SendOtp (SendOtpRequest) returns (SendOtpResponse);
|
|
16
|
+
|
|
17
|
+
// Verify the OTP sent to the user
|
|
18
|
+
rpc VerifyOtp (VerifyOtpRequest) returns (VerifyOtpResponse);
|
|
19
|
+
|
|
20
|
+
// Refersh token
|
|
21
|
+
rpc Refresh (RefreshRequest) returns (RefreshResponse);
|
|
22
|
+
}
|
|
23
|
+
message LoginRequest {
|
|
24
|
+
string login = 1;
|
|
25
|
+
string password = 2;
|
|
26
|
+
}
|
|
27
|
+
message LoginResponse {
|
|
28
|
+
string access_token = 1;
|
|
29
|
+
string refresh_token = 2;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
message RegisterRequest {
|
|
33
|
+
string name = 1;
|
|
34
|
+
string username = 2;
|
|
35
|
+
string password = 3;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
message RegisterResponse {
|
|
39
|
+
bool ok = 1;
|
|
40
|
+
}
|
|
41
|
+
message SendOtpRequest {
|
|
42
|
+
string identifier = 1;
|
|
43
|
+
string type = 2;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
message SendOtpResponse {
|
|
47
|
+
bool ok = 1;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
message VerifyOtpRequest {
|
|
51
|
+
string identifier = 1;
|
|
52
|
+
string type = 2;
|
|
53
|
+
string code = 3;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
message VerifyOtpResponse {
|
|
57
|
+
string access_token = 1;
|
|
58
|
+
string refresh_token = 2;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
message RefreshRequest {
|
|
62
|
+
string refresh_token = 1;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
message RefreshResponse {
|
|
66
|
+
string access_token = 1;
|
|
67
|
+
string refresh_token = 2;
|
|
68
|
+
}
|