Compare commits
24 Commits
f5d18a63e5
...
v1.0.12
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f1a68df5a | ||
|
|
9f5afc5a36 | ||
|
|
6666bb1a74 | ||
|
|
f6366f14b5 | ||
|
|
39d0e360a2 | ||
|
|
4f038b0f92 | ||
|
|
f592ccc021 | ||
|
|
b16f526fb5 | ||
|
|
55cf38c8c2 | ||
|
|
c5e57adf5b | ||
|
|
ea6a3e7777 | ||
|
|
3ef32ab618 | ||
|
|
d81e20c41a | ||
|
|
b8715f8f31 | ||
|
|
0d3bf2ca36 | ||
|
|
970873d536 | ||
|
|
b7d9039783 | ||
|
|
e530608121 | ||
|
|
91c262e2a6 | ||
|
|
60eb6068ec | ||
|
|
a225dd4a48 | ||
|
|
b00a823b50 | ||
|
|
15c2ed57c7 | ||
|
|
273bdd685b |
39
.github/workflows/publish.yml
vendored
39
.github/workflows/publish.yml
vendored
@@ -9,6 +9,8 @@ jobs:
|
||||
publish:
|
||||
name: Publish Job
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
@@ -20,6 +22,19 @@ jobs:
|
||||
registry-url: "https://git.lendry.ru/api/packages/lendry-erp/npm/"
|
||||
scope: "@lendry-erp"
|
||||
|
||||
# 1. Устанавливаем Go (нужен для скачивания плагинов генерации)
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.22" # Можно указать нужную тебе версию
|
||||
|
||||
# 2. Устанавливаем плагины генерации для Go и добавляем их в PATH
|
||||
- name: Install Go Protoc Plugins
|
||||
run: |
|
||||
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
|
||||
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
|
||||
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Install protoc
|
||||
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
|
||||
|
||||
@@ -29,10 +44,26 @@ jobs:
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
- name: Generate TS Protobuf
|
||||
run: npm run generate
|
||||
# 3. Исправленный шаг генерации (команды разделены, добавлено создание папки)
|
||||
- name: Generate Protobuf
|
||||
run: |
|
||||
npm install -g ts-proto
|
||||
mkdir -p ./gen/go # Создаем вложенную папку для Go
|
||||
protoc -I ./proto ./proto/*.proto \
|
||||
--ts_proto_out=nestJs=true,package=omit:./gen \
|
||||
--go_out=paths=source_relative:./gen/go \
|
||||
--go-grpc_out=paths=source_relative:./gen/go
|
||||
|
||||
- name: Commit and push changes
|
||||
run: |
|
||||
# Представляемся Git-ботом
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
# Добавляем папку gen в индекс
|
||||
git add ./gen
|
||||
|
||||
# Проверяем, есть ли изменения. Если есть — коммитим и пушим.
|
||||
git diff --quiet && git diff --staged --quiet || (git commit -m "chore: auto-generate protobuf files [skip ci]" && git push)
|
||||
- name: Publish package
|
||||
run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
1
.npmrc
Normal file
1
.npmrc
Normal file
@@ -0,0 +1 @@
|
||||
@lendry-erp:registry=https://git.lendry.ru/api/packages/lendry-erp/npm/
|
||||
@@ -1,16 +0,0 @@
|
||||
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-ts_proto v2.11.6
|
||||
// protoc v7.34.1
|
||||
// source: google/protobuf/any.proto
|
||||
|
||||
/* eslint-disable */
|
||||
|
||||
export const protobufPackage = "google.protobuf";
|
||||
|
||||
export interface Any {
|
||||
typeUrl: string;
|
||||
value: Uint8Array;
|
||||
}
|
||||
|
||||
export const GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf";
|
||||
@@ -1,18 +0,0 @@
|
||||
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-ts_proto v2.11.6
|
||||
// protoc v7.34.1
|
||||
// source: google/rpc/status.proto
|
||||
|
||||
/* eslint-disable */
|
||||
import { Any } from "../protobuf/any";
|
||||
|
||||
export const protobufPackage = "google.rpc";
|
||||
|
||||
export interface Status {
|
||||
code: number;
|
||||
message: string;
|
||||
details: Any[];
|
||||
}
|
||||
|
||||
export const GOOGLE_RPC_PACKAGE_NAME = "google.rpc";
|
||||
@@ -2,14 +2,14 @@
|
||||
// versions:
|
||||
// protoc-gen-ts_proto v2.11.6
|
||||
// protoc v7.34.1
|
||||
// source: auth.proto
|
||||
// source: identity.proto
|
||||
|
||||
/* eslint-disable */
|
||||
import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
|
||||
import { Observable } from "rxjs";
|
||||
import { Status } from "./google/rpc/status";
|
||||
|
||||
export const protobufPackage = "auth.v1";
|
||||
export const protobufPackage = "identity";
|
||||
|
||||
export interface LoginRequest {
|
||||
username: string;
|
||||
@@ -18,34 +18,52 @@ export interface LoginRequest {
|
||||
|
||||
export interface LoginResponse {
|
||||
accessToken: string;
|
||||
refreshToken: string;
|
||||
status: string;
|
||||
need2fa: boolean;
|
||||
tempToken: string;
|
||||
tempToken?: string | undefined;
|
||||
message?: string | undefined;
|
||||
errorCode?: string | undefined;
|
||||
error?: Status | undefined;
|
||||
}
|
||||
|
||||
export interface RefreshRequest {
|
||||
refreshToken: string;
|
||||
}
|
||||
|
||||
export interface RefreshResponse {
|
||||
accessToken: string;
|
||||
refreshToken: string;
|
||||
}
|
||||
|
||||
export interface LogoutRequest {
|
||||
accessToken: string;
|
||||
}
|
||||
|
||||
export interface LogoutResponse {
|
||||
success: boolean;
|
||||
message: string;
|
||||
errorCode: string;
|
||||
error: Status | undefined;
|
||||
}
|
||||
|
||||
export interface RegisterRequest {
|
||||
username: string;
|
||||
password: string;
|
||||
export interface UnlockPinRequest {
|
||||
accessToken: string;
|
||||
pinCode: string;
|
||||
}
|
||||
|
||||
export interface RegisterResponse {
|
||||
userId: string;
|
||||
status: string;
|
||||
export interface UnlockPinResponse {
|
||||
success: boolean;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface Verify2FaRequest {
|
||||
tempToken: string;
|
||||
totpCode: string;
|
||||
telegramCode: string;
|
||||
reserveCode: string;
|
||||
totpCode?: string | undefined;
|
||||
telegramCode?: string | undefined;
|
||||
}
|
||||
|
||||
export interface Verify2FaResponse {
|
||||
accessToken: string;
|
||||
refreshToken: string;
|
||||
status: string;
|
||||
message: string;
|
||||
reserveCodes: string[];
|
||||
@@ -130,12 +148,16 @@ export interface DisableTelegramResponse {
|
||||
message: string;
|
||||
}
|
||||
|
||||
export const AUTH_V1_PACKAGE_NAME = "auth.v1";
|
||||
export const IDENTITY_PACKAGE_NAME = "identity";
|
||||
|
||||
export interface AuthServiceClient {
|
||||
login(request: LoginRequest): Observable<LoginResponse>;
|
||||
|
||||
register(request: RegisterRequest): Observable<RegisterResponse>;
|
||||
refresh(request: RefreshRequest): Observable<RefreshResponse>;
|
||||
|
||||
logout(request: LogoutRequest): Observable<LogoutResponse>;
|
||||
|
||||
unlockPin(request: UnlockPinRequest): Observable<UnlockPinResponse>;
|
||||
|
||||
verify2Fa(request: Verify2FaRequest): Observable<Verify2FaResponse>;
|
||||
}
|
||||
@@ -143,14 +165,18 @@ export interface AuthServiceClient {
|
||||
export interface AuthServiceController {
|
||||
login(request: LoginRequest): Promise<LoginResponse> | Observable<LoginResponse> | LoginResponse;
|
||||
|
||||
register(request: RegisterRequest): Promise<RegisterResponse> | Observable<RegisterResponse> | RegisterResponse;
|
||||
refresh(request: RefreshRequest): Promise<RefreshResponse> | Observable<RefreshResponse> | RefreshResponse;
|
||||
|
||||
logout(request: LogoutRequest): Promise<LogoutResponse> | Observable<LogoutResponse> | LogoutResponse;
|
||||
|
||||
unlockPin(request: UnlockPinRequest): Promise<UnlockPinResponse> | Observable<UnlockPinResponse> | UnlockPinResponse;
|
||||
|
||||
verify2Fa(request: Verify2FaRequest): Promise<Verify2FaResponse> | Observable<Verify2FaResponse> | Verify2FaResponse;
|
||||
}
|
||||
|
||||
export function AuthServiceControllerMethods() {
|
||||
return function (constructor: Function) {
|
||||
const grpcMethods: string[] = ["login", "register", "verify2Fa"];
|
||||
const grpcMethods: string[] = ["login", "refresh", "logout", "unlockPin", "verify2Fa"];
|
||||
for (const method of grpcMethods) {
|
||||
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
||||
GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
|
||||
@@ -165,7 +191,7 @@ export function AuthServiceControllerMethods() {
|
||||
|
||||
export const AUTH_SERVICE_NAME = "AuthService";
|
||||
|
||||
export interface TwoFaSrviceClient {
|
||||
export interface TwoFaServiceClient {
|
||||
getTwoFaStatus(request: GetTwoFaStatusRequest): Observable<GetTwoFaStatusResponse>;
|
||||
|
||||
startTotpEnrollment(request: AuthenticatedAccessRequest): Observable<StartTotpEnrollmentResponse>;
|
||||
@@ -183,7 +209,7 @@ export interface TwoFaSrviceClient {
|
||||
disableTelegram(request: DisableTelegramRequest): Observable<DisableTelegramResponse>;
|
||||
}
|
||||
|
||||
export interface TwoFaSrviceController {
|
||||
export interface TwoFaServiceController {
|
||||
getTwoFaStatus(
|
||||
request: GetTwoFaStatusRequest,
|
||||
): Promise<GetTwoFaStatusResponse> | Observable<GetTwoFaStatusResponse> | GetTwoFaStatusResponse;
|
||||
@@ -223,7 +249,7 @@ export interface TwoFaSrviceController {
|
||||
): Promise<DisableTelegramResponse> | Observable<DisableTelegramResponse> | DisableTelegramResponse;
|
||||
}
|
||||
|
||||
export function TwoFaSrviceControllerMethods() {
|
||||
export function TwoFaServiceControllerMethods() {
|
||||
return function (constructor: Function) {
|
||||
const grpcMethods: string[] = [
|
||||
"getTwoFaStatus",
|
||||
@@ -237,14 +263,14 @@ export function TwoFaSrviceControllerMethods() {
|
||||
];
|
||||
for (const method of grpcMethods) {
|
||||
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
||||
GrpcMethod("TwoFaSrvice", method)(constructor.prototype[method], method, descriptor);
|
||||
GrpcMethod("TwoFaService", method)(constructor.prototype[method], method, descriptor);
|
||||
}
|
||||
const grpcStreamMethods: string[] = [];
|
||||
for (const method of grpcStreamMethods) {
|
||||
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
||||
GrpcStreamMethod("TwoFaSrvice", method)(constructor.prototype[method], method, descriptor);
|
||||
GrpcStreamMethod("TwoFaService", method)(constructor.prototype[method], method, descriptor);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const TWO_FA_SRVICE_SERVICE_NAME = "TwoFaSrvice";
|
||||
export const TWO_FA_SERVICE_NAME = "TwoFaService";
|
||||
15
package-lock.json
generated
15
package-lock.json
generated
@@ -1,13 +1,14 @@
|
||||
{
|
||||
"name": "@lendry-erp/contracts",
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@lendry-erp/contracts",
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.2",
|
||||
"dependencies": {
|
||||
"@lendry-erp/contracts": "^1.0.2",
|
||||
"@nestjs/microservices": "^11.1.17",
|
||||
"rxjs": "^7.8.2",
|
||||
"ts-proto": "^2.11.6"
|
||||
@@ -34,6 +35,16 @@
|
||||
"integrity": "sha512-sBXGT13cpmPR5BMgHE6UEEfEaShh5Ror6rfN3yEK5si7QVrtZg8LEPQb0VVhiLRUslD2yLnXtnRzG035J/mZXQ==",
|
||||
"license": "(Apache-2.0 AND BSD-3-Clause)"
|
||||
},
|
||||
"node_modules/@lendry-erp/contracts": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://git.lendry.ru/api/packages/lendry-erp/npm/%40lendry-erp%2Fcontracts/-/1.0.2/contracts-1.0.2.tgz",
|
||||
"integrity": "sha512-39NulQ6mn3dmrX/GXwzYYPyX/rE+4gO1En+uJJR9bHXZ3awWi0U3drIvgwM25gyi829Ae0U8vVtzMaP3gON90A==",
|
||||
"dependencies": {
|
||||
"@nestjs/microservices": "^11.1.17",
|
||||
"rxjs": "^7.8.2",
|
||||
"ts-proto": "^2.11.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@lukeed/csprng": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@lukeed/csprng/-/csprng-1.1.0.tgz",
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
{
|
||||
"name": "@lendry-erp/contracts",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.11",
|
||||
"description": "Protobuf definitions and generated TypeScript types",
|
||||
"type": "commonjs",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.build.json",
|
||||
"generate": "protoc -I ./proto ./proto/*.proto --ts_proto_out=./gen --ts_proto_opt=nestJs=true,package=omit"
|
||||
"build": "tsc -p tsconfig.build.json"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package google.protobuf;
|
||||
|
||||
message Any {
|
||||
string type_url = 1;
|
||||
bytes value = 2;
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package google.rpc;
|
||||
|
||||
import "google/protobuf/any.proto";
|
||||
|
||||
message Status {
|
||||
int32 code = 1;
|
||||
string message = 2;
|
||||
repeated google.protobuf.Any details = 3;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package identity;
|
||||
import "google/rpc/status.proto";
|
||||
|
||||
option go_package = './gen';
|
||||
|
||||
service AuthService {
|
||||
rpc Login (LoginRequest) returns (LoginResponse);
|
||||
rpc Register (RegisterRequest) returns (RegisterResponse);
|
||||
rpc Refresh (RefreshRequest) returns (RefreshResponse);
|
||||
rpc Logout (LogoutRequest) returns (LogoutResponse);
|
||||
rpc UnlockPin (UnlockPinRequest) returns (UnlockPinResponse);
|
||||
rpc Verify2Fa (Verify2FaRequest) returns (Verify2FaResponse);
|
||||
}
|
||||
|
||||
@@ -31,23 +33,40 @@ message LoginResponse {
|
||||
string refresh_token = 2;
|
||||
string status = 3;
|
||||
bool need2fa = 4;
|
||||
string temp_token = 5;
|
||||
string message = 6;
|
||||
string error_code = 7;
|
||||
google.rpc.Status error = 8;
|
||||
optional string temp_token = 5;
|
||||
optional string message = 6;
|
||||
optional string error_code = 7;
|
||||
}
|
||||
|
||||
message RegisterRequest {
|
||||
string username = 1;
|
||||
string password = 2;
|
||||
message RefreshRequest {
|
||||
string refresh_token = 1;
|
||||
}
|
||||
|
||||
message RegisterResponse {
|
||||
string user_id = 1;
|
||||
string status = 2;
|
||||
string message = 3;
|
||||
message RefreshResponse {
|
||||
string access_token = 1;
|
||||
string refresh_token = 2;
|
||||
}
|
||||
|
||||
message LogoutRequest {
|
||||
string access_token = 1;
|
||||
}
|
||||
|
||||
message LogoutResponse {
|
||||
bool success = 1;
|
||||
string message = 2;
|
||||
}
|
||||
|
||||
message UnlockPinRequest {
|
||||
string access_token = 1;
|
||||
string pin_code = 2;
|
||||
}
|
||||
|
||||
message UnlockPinResponse {
|
||||
bool success = 1;
|
||||
string message = 2;
|
||||
}
|
||||
|
||||
|
||||
message Verify2FaRequest {
|
||||
string temp_token = 1;
|
||||
optional string totp_code = 2;
|
||||
|
||||
28
proto/ldap.proto
Normal file
28
proto/ldap.proto
Normal file
@@ -0,0 +1,28 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package ldap_service;
|
||||
|
||||
option go_package = "git.lendry.ru/lendry-erp/gen;ldap_service";
|
||||
|
||||
service LdapAuth {
|
||||
rpc VerifyUser (VerifyRequest) returns (VerifyResponse);
|
||||
}
|
||||
|
||||
message VerifyRequest {
|
||||
string username = 1;
|
||||
string password = 2;
|
||||
}
|
||||
|
||||
message VerifyResponse {
|
||||
bool success = 1;
|
||||
string error_message = 2;
|
||||
UserData user = 3;
|
||||
}
|
||||
|
||||
message UserData {
|
||||
string dn = 1;
|
||||
string display_name = 2;
|
||||
repeated string groups = 3;
|
||||
bool is_active = 4;
|
||||
}
|
||||
|
||||
@@ -2,4 +2,5 @@ import { join } from "path";
|
||||
|
||||
export const PROTO_PATHS = {
|
||||
AUTH: join(__dirname, "../../proto/identity.proto"),
|
||||
LDAP: join(__dirname, "../../proto/ldap.proto"),
|
||||
} as const;
|
||||
|
||||
Reference in New Issue
Block a user