268 lines
7.3 KiB
TypeScript
268 lines
7.3 KiB
TypeScript
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
// versions:
|
|
// protoc-gen-ts_proto v2.11.6
|
|
// protoc v4.25.9
|
|
// source: sso/auth.proto
|
|
|
|
/* eslint-disable */
|
|
import type { Metadata } from "@grpc/grpc-js";
|
|
import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
|
|
import { Observable } from "rxjs";
|
|
|
|
export const protobufPackage = "auth.v1";
|
|
|
|
export interface LoginRequest {
|
|
username: string;
|
|
password: string;
|
|
}
|
|
|
|
export interface LoginResponse {
|
|
accessToken: string;
|
|
refreshToken: string;
|
|
status: string;
|
|
need2fa: boolean;
|
|
tempToken?: string | undefined;
|
|
message?: string | undefined;
|
|
errorCode?: string | undefined;
|
|
}
|
|
|
|
export interface RefreshRequest {
|
|
refreshToken: string;
|
|
}
|
|
|
|
export interface RefreshResponse {
|
|
accessToken: string;
|
|
refreshToken: string;
|
|
}
|
|
|
|
export interface LogoutRequest {
|
|
userId: string;
|
|
sessionId: string;
|
|
}
|
|
|
|
export interface LogoutResponse {
|
|
success: boolean;
|
|
message: string;
|
|
}
|
|
|
|
export interface VerifyTokenRequest {
|
|
token: string;
|
|
}
|
|
|
|
export interface VerifyTokenResponse {
|
|
isValid: boolean;
|
|
errorMessage?: string | undefined;
|
|
id?: string | undefined;
|
|
username?: string | undefined;
|
|
roleLevel?: number | undefined;
|
|
permissions: string[];
|
|
sessionId?: string | undefined;
|
|
requiresPin?: boolean | undefined;
|
|
}
|
|
|
|
export interface GetAccountRoleLevelRequest {
|
|
accountId: string;
|
|
}
|
|
|
|
export interface GetAccountRoleLevelResponse {
|
|
found: boolean;
|
|
roleLevel: number;
|
|
}
|
|
|
|
export interface GetSessionRequest {
|
|
userId: string;
|
|
currentSessionId: string;
|
|
}
|
|
|
|
export interface SessionItem {
|
|
/** Здесь будет лежать захэшированный ID */
|
|
id: string;
|
|
ipAddress: string;
|
|
userAgent: string;
|
|
/** Unix timestamp в миллисекундах */
|
|
lastActivity: number;
|
|
/** Флаг текущей сессии */
|
|
isCurrent: boolean;
|
|
}
|
|
|
|
export interface GetSessionsResponse {
|
|
sessions: SessionItem[];
|
|
}
|
|
|
|
export interface TerminateSessionRequest {
|
|
userId: string;
|
|
/** Хэш сессии, которую нужно убить */
|
|
targetHash: string;
|
|
}
|
|
|
|
export interface TerminateSessionResponse {
|
|
success: boolean;
|
|
message: string;
|
|
}
|
|
|
|
export interface SystemCreateAccountRequest {
|
|
username: string;
|
|
/** Хеш пароля генерирует Admin Service и передает сюда */
|
|
passwordHash: string;
|
|
isLdap: boolean;
|
|
}
|
|
|
|
export interface SystemCreateAccountResponse {
|
|
accountId: string;
|
|
}
|
|
|
|
export interface SystemChangeStatusRequest {
|
|
accountId: string;
|
|
/** 'ACTIVE', 'BLOCKED', 'DELETED' */
|
|
status: string;
|
|
}
|
|
|
|
export interface SystemChangeStatusResponse {
|
|
success: boolean;
|
|
}
|
|
|
|
export interface SystemUpdatePasswordRequest {
|
|
accountId: string;
|
|
newPasswordHash: string;
|
|
}
|
|
|
|
export interface SystemUpdatePasswordResponse {
|
|
success: boolean;
|
|
}
|
|
|
|
export interface SystemUpdatePinRequest {
|
|
accountId: string;
|
|
/** null если удаляем */
|
|
pinHash?: string | undefined;
|
|
}
|
|
|
|
export interface SystemUpdatePinResponse {
|
|
success: boolean;
|
|
}
|
|
|
|
export const AUTH_V1_PACKAGE_NAME = "auth.v1";
|
|
|
|
export interface AuthServiceClient {
|
|
login(request: LoginRequest, metadata?: Metadata): Observable<LoginResponse>;
|
|
|
|
refresh(request: RefreshRequest, metadata?: Metadata): Observable<RefreshResponse>;
|
|
|
|
verifyToken(request: VerifyTokenRequest, metadata?: Metadata): Observable<VerifyTokenResponse>;
|
|
|
|
getAccountRoleLevel(
|
|
request: GetAccountRoleLevelRequest,
|
|
metadata?: Metadata,
|
|
): Observable<GetAccountRoleLevelResponse>;
|
|
|
|
logout(request: LogoutRequest, metadata?: Metadata): Observable<LogoutResponse>;
|
|
|
|
logoutOther(request: LogoutRequest, metadata?: Metadata): Observable<LogoutResponse>;
|
|
|
|
getSessions(request: GetSessionRequest, metadata?: Metadata): Observable<GetSessionsResponse>;
|
|
|
|
terminateSession(request: TerminateSessionRequest, metadata?: Metadata): Observable<TerminateSessionResponse>;
|
|
|
|
systemCreateAccount(
|
|
request: SystemCreateAccountRequest,
|
|
metadata?: Metadata,
|
|
): Observable<SystemCreateAccountResponse>;
|
|
|
|
systemChangeStatus(request: SystemChangeStatusRequest, metadata?: Metadata): Observable<SystemChangeStatusResponse>;
|
|
|
|
systemUpdatePassword(
|
|
request: SystemUpdatePasswordRequest,
|
|
metadata?: Metadata,
|
|
): Observable<SystemUpdatePasswordResponse>;
|
|
|
|
systemUpdatePin(request: SystemUpdatePinRequest, metadata?: Metadata): Observable<SystemUpdatePinResponse>;
|
|
}
|
|
|
|
export interface AuthServiceController {
|
|
login(request: LoginRequest, metadata?: Metadata): Promise<LoginResponse> | Observable<LoginResponse> | LoginResponse;
|
|
|
|
refresh(
|
|
request: RefreshRequest,
|
|
metadata?: Metadata,
|
|
): Promise<RefreshResponse> | Observable<RefreshResponse> | RefreshResponse;
|
|
|
|
verifyToken(
|
|
request: VerifyTokenRequest,
|
|
metadata?: Metadata,
|
|
): Promise<VerifyTokenResponse> | Observable<VerifyTokenResponse> | VerifyTokenResponse;
|
|
|
|
getAccountRoleLevel(
|
|
request: GetAccountRoleLevelRequest,
|
|
metadata?: Metadata,
|
|
): Promise<GetAccountRoleLevelResponse> | Observable<GetAccountRoleLevelResponse> | GetAccountRoleLevelResponse;
|
|
|
|
logout(
|
|
request: LogoutRequest,
|
|
metadata?: Metadata,
|
|
): Promise<LogoutResponse> | Observable<LogoutResponse> | LogoutResponse;
|
|
|
|
logoutOther(
|
|
request: LogoutRequest,
|
|
metadata?: Metadata,
|
|
): Promise<LogoutResponse> | Observable<LogoutResponse> | LogoutResponse;
|
|
|
|
getSessions(
|
|
request: GetSessionRequest,
|
|
metadata?: Metadata,
|
|
): Promise<GetSessionsResponse> | Observable<GetSessionsResponse> | GetSessionsResponse;
|
|
|
|
terminateSession(
|
|
request: TerminateSessionRequest,
|
|
metadata?: Metadata,
|
|
): Promise<TerminateSessionResponse> | Observable<TerminateSessionResponse> | TerminateSessionResponse;
|
|
|
|
systemCreateAccount(
|
|
request: SystemCreateAccountRequest,
|
|
metadata?: Metadata,
|
|
): Promise<SystemCreateAccountResponse> | Observable<SystemCreateAccountResponse> | SystemCreateAccountResponse;
|
|
|
|
systemChangeStatus(
|
|
request: SystemChangeStatusRequest,
|
|
metadata?: Metadata,
|
|
): Promise<SystemChangeStatusResponse> | Observable<SystemChangeStatusResponse> | SystemChangeStatusResponse;
|
|
|
|
systemUpdatePassword(
|
|
request: SystemUpdatePasswordRequest,
|
|
metadata?: Metadata,
|
|
): Promise<SystemUpdatePasswordResponse> | Observable<SystemUpdatePasswordResponse> | SystemUpdatePasswordResponse;
|
|
|
|
systemUpdatePin(
|
|
request: SystemUpdatePinRequest,
|
|
metadata?: Metadata,
|
|
): Promise<SystemUpdatePinResponse> | Observable<SystemUpdatePinResponse> | SystemUpdatePinResponse;
|
|
}
|
|
|
|
export function AuthServiceControllerMethods() {
|
|
return function (constructor: Function) {
|
|
const grpcMethods: string[] = [
|
|
"login",
|
|
"refresh",
|
|
"verifyToken",
|
|
"getAccountRoleLevel",
|
|
"logout",
|
|
"logoutOther",
|
|
"getSessions",
|
|
"terminateSession",
|
|
"systemCreateAccount",
|
|
"systemChangeStatus",
|
|
"systemUpdatePassword",
|
|
"systemUpdatePin",
|
|
];
|
|
for (const method of grpcMethods) {
|
|
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
|
|
}
|
|
const grpcStreamMethods: string[] = [];
|
|
for (const method of grpcStreamMethods) {
|
|
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
GrpcStreamMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
|
|
}
|
|
};
|
|
}
|
|
|
|
export const AUTH_SERVICE_NAME = "AuthService";
|