From 9e8521c35bbae71c80780ce476fcfdf507b555c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Sat, 11 Apr 2026 21:27:41 +0300 Subject: [PATCH] add types and constants --- lib/constants/index.ts | 1 + lib/constants/security-events.const.ts | 32 ++++++++++++++++++++++++++ lib/index.ts | 2 ++ lib/types/client-context.type.ts | 4 ++++ lib/types/index.ts | 1 + package.json | 2 +- 6 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 lib/constants/index.ts create mode 100644 lib/constants/security-events.const.ts create mode 100644 lib/types/client-context.type.ts create mode 100644 lib/types/index.ts diff --git a/lib/constants/index.ts b/lib/constants/index.ts new file mode 100644 index 0000000..fe8f013 --- /dev/null +++ b/lib/constants/index.ts @@ -0,0 +1 @@ +export * from './security-events.const' diff --git a/lib/constants/security-events.const.ts b/lib/constants/security-events.const.ts new file mode 100644 index 0000000..a25f49d --- /dev/null +++ b/lib/constants/security-events.const.ts @@ -0,0 +1,32 @@ +export const SecurityEventType = { + AUTH: 'AUTH', // Логины, логауты + SESSION: 'SESSION', // Блокировки, кража токенов + PROFILE: 'PROFILE', // Смена пароля, пин-кода + SYSTEM: 'SYSTEM' // Системные события, например, блокировка IP, изменение ролей и т.д. +} as const + +export const SecurityEventAction = { + LOGIN_SUCCESS: 'LOGIN_SUCCESS', + LOGIN_FAILED: 'LOGIN_FAILED', + LOGOUT: 'LOGOUT', + TOKEN_STOLEN: 'TOKEN_STOLEN', + SET_PIN: 'SET_PIN', + PIN_CHANGED: 'PIN_CHANGED', + PIN_LOCKED: 'PIN_LOCKED', + REMOVE_PIN: 'REMOVE_PIN', + TWOFA_ENABLED: 'TWOFA_ENABLED', + TWOFA_DISABLED: 'TWOFA_DISABLED', + UNLOCK_PIN_FAILED: 'UNLOCK_PIN_FAILED', + PASSWORD_CHANGE_SUCCESS: 'PASSWORD_CHANGE_SUCCESS', + PASSWORD_CHANGE_FAILED: 'PASSWORD_CHANGE_FAILED', + CHANGE_DATA_SUCCESS: 'CHANGE_DATA_SUCCESS', + CHANGE_DATA_FAILED: 'CHANGE_DATA_FAILED', + DELETE_ACCOUNT: 'DELETE_ACCOUNT', + ASSIGN_ROLE: 'ASSIGN_ROLE', + REVOKE_ROLE: 'REVOKE_ROLE', + IP_UNBLACKLISTED: 'IP_UNBLACKLISTED', + IP_BLACKLISTED: 'IP_BLACKLISTED', + USER_BLOCKED: 'USER_BLOCKED', + USER_UNBLOCKED: 'USER_UNBLOCKED', + SEARCH_SYNC_MANUAL: 'SEARCH_SYNC_MANUAL' +} as const diff --git a/lib/index.ts b/lib/index.ts index ea0abe7..9414044 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -1,2 +1,4 @@ export * from './enums' export * from './utils' +export * from './types' +export * from './constants' diff --git a/lib/types/client-context.type.ts b/lib/types/client-context.type.ts new file mode 100644 index 0000000..1c2d46c --- /dev/null +++ b/lib/types/client-context.type.ts @@ -0,0 +1,4 @@ +export type ClientContext = { + ipAddress: string + userAgent: string +} diff --git a/lib/types/index.ts b/lib/types/index.ts new file mode 100644 index 0000000..bbfc485 --- /dev/null +++ b/lib/types/index.ts @@ -0,0 +1 @@ +export * from './client-context.type' diff --git a/package.json b/package.json index d338a5b..09b55a0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lendry-erp/common", - "version": "1.1.0", + "version": "1.1.1", "description": "Core shared components for Lendry-ERP microservice ecosystem", "main": "dist/index.js", "type": "dist/index.d.ts",