feat: add verify to auth proto
All checks were successful
Publish / Publish npm package action (push) Successful in 17s

This commit is contained in:
Sergey Krylov 2026-01-24 14:55:39 +03:00
parent 80f62ccbe5
commit fa73b7d5c6
3 changed files with 30 additions and 2 deletions

View File

@ -19,19 +19,34 @@ export interface SendOtpResponse {
ok: boolean; ok: boolean;
} }
export interface VerifyOtpRequest {
identifier: string;
type: string;
code: string;
}
export interface VerifyOtpResponse {
accessToken: string;
refreshToken: string;
}
export const AUTH_V1_PACKAGE_NAME = "auth.v1"; export const AUTH_V1_PACKAGE_NAME = "auth.v1";
export interface AuthServiceClient { export interface AuthServiceClient {
sendOtp(request: SendOtpRequest): Observable<SendOtpResponse>; sendOtp(request: SendOtpRequest): Observable<SendOtpResponse>;
verifyOtp(request: VerifyOtpRequest): Observable<VerifyOtpResponse>;
} }
export interface AuthServiceController { export interface AuthServiceController {
sendOtp(request: SendOtpRequest): Promise<SendOtpResponse> | Observable<SendOtpResponse> | SendOtpResponse; sendOtp(request: SendOtpRequest): Promise<SendOtpResponse> | Observable<SendOtpResponse> | SendOtpResponse;
verifyOtp(request: VerifyOtpRequest): Promise<VerifyOtpResponse> | Observable<VerifyOtpResponse> | VerifyOtpResponse;
} }
export function AuthServiceControllerMethods() { export function AuthServiceControllerMethods() {
return function (constructor: Function) { return function (constructor: Function) {
const grpcMethods: string[] = ["sendOtp"]; const grpcMethods: string[] = ["sendOtp", "verifyOtp"];
for (const method of grpcMethods) { for (const method of grpcMethods) {
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor); GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);

View File

@ -1,6 +1,6 @@
{ {
"name": "@teacinema/contracts", "name": "@teacinema/contracts",
"version": "1.0.0", "version": "1.0.1",
"description": "Protocol Buffers contracts for microservices", "description": "Protocol Buffers contracts for microservices",
"scripts": { "scripts": {
"generate": "npx protoc -I ./proto ./proto/*.proto --ts_proto_out=./gen --ts_proto_opt=nestJs=true,package=omit" "generate": "npx protoc -I ./proto ./proto/*.proto --ts_proto_out=./gen --ts_proto_opt=nestJs=true,package=omit"

View File

@ -4,6 +4,7 @@ package auth.v1;
service AuthService { service AuthService {
rpc SendOtp(SendOtpRequest) returns (SendOtpResponse); rpc SendOtp(SendOtpRequest) returns (SendOtpResponse);
rpc VerifyOtp(VerifyOtpRequest) returns (VerifyOtpResponse);
} }
message SendOtpRequest { message SendOtpRequest {
@ -14,3 +15,15 @@ message SendOtpRequest {
message SendOtpResponse { message SendOtpResponse {
bool ok = 1; bool ok = 1;
} }
message VerifyOtpRequest {
string identifier = 1;
string type = 2;
string code = 3;
}
message VerifyOtpResponse {
string access_token = 1;
string refresh_token = 2;
}