From 458bc0775ca9922834086ac7af85197a3f4afcb6 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Fri, 8 Dec 2023 09:52:59 -0300 Subject: [PATCH] review --- .../license/src/MockedLicenseBuilder.ts | 7 ++---- .../license/src/definition/ILicenseTag.ts | 1 - .../license/src/definition/ILicenseV2.ts | 1 - .../license/src/definition/ILicenseV3.ts | 1 - .../license/src/definition/LicenseBehavior.ts | 1 - .../license/src/definition/LicenseInfo.ts | 1 - .../license/src/definition/LicenseLimit.ts | 1 - .../license/src/definition/LicenseModule.ts | 1 - .../license/src/definition/LicensePeriod.ts | 1 - .../definition/LicenseValidationOptions.ts | 1 - .../license/src/definition/LimitContext.ts | 1 - ee/packages/license/src/definition/events.ts | 1 - ee/packages/license/src/deprecated.ts | 3 ++- ee/packages/license/src/events/deprecated.ts | 3 ++- ee/packages/license/src/events/emitter.ts | 4 ++-- ee/packages/license/src/events/listeners.ts | 5 ++--- .../src/events/overwriteClassOnLicense.ts | 3 ++- ee/packages/license/src/index.ts | 14 ++---------- ee/packages/license/src/isItemAllowed.ts | 4 +--- ee/packages/license/src/license.ts | 22 +++++++++++-------- ee/packages/license/src/modules.ts | 3 ++- ee/packages/license/src/showLicense.ts | 3 ++- ee/packages/license/src/tags.ts | 3 ++- ee/packages/license/src/token.ts | 3 +-- ee/packages/license/src/v2/bundles.ts | 2 +- ee/packages/license/src/v2/convertToV3.ts | 5 ++--- 26 files changed, 38 insertions(+), 57 deletions(-) delete mode 100644 ee/packages/license/src/definition/ILicenseTag.ts delete mode 100644 ee/packages/license/src/definition/ILicenseV2.ts delete mode 100644 ee/packages/license/src/definition/ILicenseV3.ts delete mode 100644 ee/packages/license/src/definition/LicenseBehavior.ts delete mode 100644 ee/packages/license/src/definition/LicenseInfo.ts delete mode 100644 ee/packages/license/src/definition/LicenseLimit.ts delete mode 100644 ee/packages/license/src/definition/LicenseModule.ts delete mode 100644 ee/packages/license/src/definition/LicensePeriod.ts delete mode 100644 ee/packages/license/src/definition/LicenseValidationOptions.ts delete mode 100644 ee/packages/license/src/definition/LimitContext.ts delete mode 100644 ee/packages/license/src/definition/events.ts diff --git a/ee/packages/license/src/MockedLicenseBuilder.ts b/ee/packages/license/src/MockedLicenseBuilder.ts index da9e833e06c4c..4c3cab7b660fe 100644 --- a/ee/packages/license/src/MockedLicenseBuilder.ts +++ b/ee/packages/license/src/MockedLicenseBuilder.ts @@ -1,8 +1,5 @@ -import type { ILicenseTag } from './definition/ILicenseTag'; -import type { ILicenseV3 } from './definition/ILicenseV3'; -import type { LicenseLimit } from './definition/LicenseLimit'; -import type { LicenseModule } from './definition/LicenseModule'; -import type { LicensePeriod, Timestamp } from './definition/LicensePeriod'; +import type { ILicenseTag, ILicenseV3, LicenseLimit, LicenseModule, LicensePeriod, Timestamp } from '@rocket.chat/core-typings'; + import { encrypt } from './token'; export class MockedLicenseBuilder { diff --git a/ee/packages/license/src/definition/ILicenseTag.ts b/ee/packages/license/src/definition/ILicenseTag.ts deleted file mode 100644 index 6b55f67f35f73..0000000000000 --- a/ee/packages/license/src/definition/ILicenseTag.ts +++ /dev/null @@ -1 +0,0 @@ -export { ILicenseTag } from '@rocket.chat/core-typings'; diff --git a/ee/packages/license/src/definition/ILicenseV2.ts b/ee/packages/license/src/definition/ILicenseV2.ts deleted file mode 100644 index 1efcbc4e42e37..0000000000000 --- a/ee/packages/license/src/definition/ILicenseV2.ts +++ /dev/null @@ -1 +0,0 @@ -export { ILicenseV2, LicenseAppSources } from '@rocket.chat/core-typings'; diff --git a/ee/packages/license/src/definition/ILicenseV3.ts b/ee/packages/license/src/definition/ILicenseV3.ts deleted file mode 100644 index f4c43347bb869..0000000000000 --- a/ee/packages/license/src/definition/ILicenseV3.ts +++ /dev/null @@ -1 +0,0 @@ -export { ILicenseV3, LicenseLimitKind } from '@rocket.chat/core-typings'; diff --git a/ee/packages/license/src/definition/LicenseBehavior.ts b/ee/packages/license/src/definition/LicenseBehavior.ts deleted file mode 100644 index 789ffbeea22b0..0000000000000 --- a/ee/packages/license/src/definition/LicenseBehavior.ts +++ /dev/null @@ -1 +0,0 @@ -export { LicenseBehavior, BehaviorWithContext } from '@rocket.chat/core-typings'; diff --git a/ee/packages/license/src/definition/LicenseInfo.ts b/ee/packages/license/src/definition/LicenseInfo.ts deleted file mode 100644 index a3565b4671e8c..0000000000000 --- a/ee/packages/license/src/definition/LicenseInfo.ts +++ /dev/null @@ -1 +0,0 @@ -export { LicenseInfo } from '@rocket.chat/core-typings'; diff --git a/ee/packages/license/src/definition/LicenseLimit.ts b/ee/packages/license/src/definition/LicenseLimit.ts deleted file mode 100644 index 7a6872c544d91..0000000000000 --- a/ee/packages/license/src/definition/LicenseLimit.ts +++ /dev/null @@ -1 +0,0 @@ -export { LicenseLimit } from '@rocket.chat/core-typings'; diff --git a/ee/packages/license/src/definition/LicenseModule.ts b/ee/packages/license/src/definition/LicenseModule.ts deleted file mode 100644 index c71217c1aa22b..0000000000000 --- a/ee/packages/license/src/definition/LicenseModule.ts +++ /dev/null @@ -1 +0,0 @@ -export { LicenseModule } from '@rocket.chat/core-typings'; diff --git a/ee/packages/license/src/definition/LicensePeriod.ts b/ee/packages/license/src/definition/LicensePeriod.ts deleted file mode 100644 index db04940eddbfa..0000000000000 --- a/ee/packages/license/src/definition/LicensePeriod.ts +++ /dev/null @@ -1 +0,0 @@ -export { LicensePeriod, LicensePeriodBehavior, Timestamp } from '@rocket.chat/core-typings'; diff --git a/ee/packages/license/src/definition/LicenseValidationOptions.ts b/ee/packages/license/src/definition/LicenseValidationOptions.ts deleted file mode 100644 index a8c1d7dc167c9..0000000000000 --- a/ee/packages/license/src/definition/LicenseValidationOptions.ts +++ /dev/null @@ -1 +0,0 @@ -export { LicenseValidationOptions } from '@rocket.chat/core-typings'; diff --git a/ee/packages/license/src/definition/LimitContext.ts b/ee/packages/license/src/definition/LimitContext.ts deleted file mode 100644 index 19642546b8714..0000000000000 --- a/ee/packages/license/src/definition/LimitContext.ts +++ /dev/null @@ -1 +0,0 @@ -export { LimitContext } from '@rocket.chat/core-typings'; diff --git a/ee/packages/license/src/definition/events.ts b/ee/packages/license/src/definition/events.ts deleted file mode 100644 index 36e9e28e1673a..0000000000000 --- a/ee/packages/license/src/definition/events.ts +++ /dev/null @@ -1 +0,0 @@ -export { LicenseEvents } from '@rocket.chat/core-typings'; diff --git a/ee/packages/license/src/deprecated.ts b/ee/packages/license/src/deprecated.ts index bbd137cc81230..e4d7bd22293af 100644 --- a/ee/packages/license/src/deprecated.ts +++ b/ee/packages/license/src/deprecated.ts @@ -1,4 +1,5 @@ -import type { ILicenseV3, LicenseLimitKind } from './definition/ILicenseV3'; +import type { ILicenseV3, LicenseLimitKind } from '@rocket.chat/core-typings'; + import type { LicenseManager } from './license'; import { getModules } from './modules'; import { defaultLimits } from './validation/validateDefaultLimits'; diff --git a/ee/packages/license/src/events/deprecated.ts b/ee/packages/license/src/events/deprecated.ts index 8ebfe4729292c..b120815c0aae8 100644 --- a/ee/packages/license/src/events/deprecated.ts +++ b/ee/packages/license/src/events/deprecated.ts @@ -1,4 +1,5 @@ -import type { LicenseModule } from '../definition/LicenseModule'; +import type { LicenseModule } from '@rocket.chat/core-typings'; + import type { LicenseManager } from '../license'; import { hasModule } from '../modules'; diff --git a/ee/packages/license/src/events/emitter.ts b/ee/packages/license/src/events/emitter.ts index dde10d68563f9..b4406abaa81b2 100644 --- a/ee/packages/license/src/events/emitter.ts +++ b/ee/packages/license/src/events/emitter.ts @@ -1,5 +1,5 @@ -import type { BehaviorWithContext } from '../definition/LicenseBehavior'; -import type { LicenseModule } from '../definition/LicenseModule'; +import type { BehaviorWithContext, LicenseModule } from '@rocket.chat/core-typings'; + import type { LicenseManager } from '../license'; import { logger } from '../logger'; diff --git a/ee/packages/license/src/events/listeners.ts b/ee/packages/license/src/events/listeners.ts index add2f397ba8ff..7b7eaf0baed93 100644 --- a/ee/packages/license/src/events/listeners.ts +++ b/ee/packages/license/src/events/listeners.ts @@ -1,6 +1,5 @@ -import type { LicenseLimitKind } from '../definition/ILicenseV3'; -import type { BehaviorWithContext, LicenseBehavior } from '../definition/LicenseBehavior'; -import type { LicenseModule } from '../definition/LicenseModule'; +import type { LicenseLimitKind, LicenseModule, BehaviorWithContext, LicenseBehavior } from '@rocket.chat/core-typings'; + import type { LicenseManager } from '../license'; import { hasModule } from '../modules'; diff --git a/ee/packages/license/src/events/overwriteClassOnLicense.ts b/ee/packages/license/src/events/overwriteClassOnLicense.ts index 00a690d8f4134..7ca686b58a504 100644 --- a/ee/packages/license/src/events/overwriteClassOnLicense.ts +++ b/ee/packages/license/src/events/overwriteClassOnLicense.ts @@ -1,4 +1,5 @@ -import type { LicenseModule } from '../definition/LicenseModule'; +import type { LicenseModule } from '@rocket.chat/core-typings'; + import type { LicenseManager } from '../license'; import { onLicense } from './deprecated'; diff --git a/ee/packages/license/src/index.ts b/ee/packages/license/src/index.ts index cf0bc0c74f4b2..cb07323d4678c 100644 --- a/ee/packages/license/src/index.ts +++ b/ee/packages/license/src/index.ts @@ -1,6 +1,5 @@ -import type { LicenseLimitKind } from './definition/ILicenseV3'; -import type { LicenseInfo } from './definition/LicenseInfo'; -import type { LimitContext } from './definition/LimitContext'; +import type { LicenseLimitKind, LicenseInfo, LimitContext } from '@rocket.chat/core-typings'; + import { getAppsConfig, getMaxActiveUsers, getUnmodifiedLicenseAndModules } from './deprecated'; import { onLicense } from './events/deprecated'; import { @@ -28,15 +27,6 @@ import { getCurrentValueForLicenseLimit, setLicenseLimitCounter } from './valida import { validateFormat } from './validation/validateFormat'; export { DuplicatedLicenseError } from './errors/DuplicatedLicenseError'; -export * from './definition/ILicenseTag'; -export * from './definition/ILicenseV2'; -export * from './definition/ILicenseV3'; -export * from './definition/LicenseBehavior'; -export * from './definition/LicenseInfo'; -export * from './definition/LicenseLimit'; -export * from './definition/LicenseModule'; -export * from './definition/LicensePeriod'; -export * from './definition/LimitContext'; export * from './MockedLicenseBuilder'; // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/ee/packages/license/src/isItemAllowed.ts b/ee/packages/license/src/isItemAllowed.ts index 16787cdf9c4d7..3eb9651a8fc96 100644 --- a/ee/packages/license/src/isItemAllowed.ts +++ b/ee/packages/license/src/isItemAllowed.ts @@ -1,6 +1,4 @@ -import type { LicenseLimitKind } from './definition/ILicenseV3'; -import type { LicenseBehavior } from './definition/LicenseBehavior'; -import type { LicenseValidationOptions } from './definition/LicenseValidationOptions'; +import type { LicenseLimitKind, LicenseBehavior, LicenseValidationOptions } from '@rocket.chat/core-typings'; const isItemAllowed = (item: T, allowList?: T[]): boolean => { return !allowList || allowList.includes(item); diff --git a/ee/packages/license/src/license.ts b/ee/packages/license/src/license.ts index 5d4a33024f8b3..a8d8f1bca5105 100644 --- a/ee/packages/license/src/license.ts +++ b/ee/packages/license/src/license.ts @@ -1,14 +1,18 @@ +import type { + ILicenseTag, + LicenseEvents, + ILicenseV2, + ILicenseV3, + LicenseLimitKind, + BehaviorWithContext, + LicenseBehavior, + LicenseInfo, + LicenseModule, + LicenseValidationOptions, + LimitContext, +} from '@rocket.chat/core-typings'; import { Emitter } from '@rocket.chat/emitter'; -import { type ILicenseTag } from './definition/ILicenseTag'; -import type { ILicenseV2 } from './definition/ILicenseV2'; -import type { ILicenseV3, LicenseLimitKind } from './definition/ILicenseV3'; -import type { BehaviorWithContext, LicenseBehavior } from './definition/LicenseBehavior'; -import type { LicenseInfo } from './definition/LicenseInfo'; -import type { LicenseModule } from './definition/LicenseModule'; -import type { LicenseValidationOptions } from './definition/LicenseValidationOptions'; -import type { LimitContext } from './definition/LimitContext'; -import type { LicenseEvents } from './definition/events'; import { getLicenseLimit } from './deprecated'; import { DuplicatedLicenseError } from './errors/DuplicatedLicenseError'; import { InvalidLicenseError } from './errors/InvalidLicenseError'; diff --git a/ee/packages/license/src/modules.ts b/ee/packages/license/src/modules.ts index 6931fb7a6a5d2..7a6f41c07ec1c 100644 --- a/ee/packages/license/src/modules.ts +++ b/ee/packages/license/src/modules.ts @@ -1,4 +1,5 @@ -import type { LicenseModule } from './definition/LicenseModule'; +import type { LicenseModule } from '@rocket.chat/core-typings'; + import { moduleRemoved, moduleValidated } from './events/emitter'; import type { LicenseManager } from './license'; diff --git a/ee/packages/license/src/showLicense.ts b/ee/packages/license/src/showLicense.ts index 3dda60a43b765..cbf708019856b 100644 --- a/ee/packages/license/src/showLicense.ts +++ b/ee/packages/license/src/showLicense.ts @@ -1,4 +1,5 @@ -import type { ILicenseV3 } from './definition/ILicenseV3'; +import type { ILicenseV3 } from '@rocket.chat/core-typings'; + import type { LicenseManager } from './license'; import { getModules } from './modules'; diff --git a/ee/packages/license/src/tags.ts b/ee/packages/license/src/tags.ts index 33434cae116d5..d918c4cd0cfc1 100644 --- a/ee/packages/license/src/tags.ts +++ b/ee/packages/license/src/tags.ts @@ -1,4 +1,5 @@ -import type { ILicenseTag } from './definition/ILicenseTag'; +import type { ILicenseTag } from '@rocket.chat/core-typings'; + import { type LicenseManager } from './license'; export function addTag(this: LicenseManager, tag: ILicenseTag) { diff --git a/ee/packages/license/src/token.ts b/ee/packages/license/src/token.ts index 8e34d7cf2621b..09ad5a940b587 100644 --- a/ee/packages/license/src/token.ts +++ b/ee/packages/license/src/token.ts @@ -1,9 +1,8 @@ import crypto from 'crypto'; +import type { ILicenseV3 } from '@rocket.chat/core-typings'; import { verify, sign, getPairs } from '@rocket.chat/jwt'; -import type { ILicenseV3 } from './definition/ILicenseV3'; - const PUBLIC_LICENSE_KEY_V2 = 'LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQ0lqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FnOEFNSUlDQ2dLQ0FnRUFxV1Nza2Q5LzZ6Ung4a3lQY2ljcwpiMzJ3Mnd4VnV3N3lCVDk2clEvOEQreU1lQ01POXdTU3BIYS85bkZ5d293RXRpZ3B0L3dyb1BOK1ZHU3didHdQCkZYQmVxRWxCbmRHRkFsODZlNStFbGlIOEt6L2hHbkNtSk5tWHB4RUsyUkUwM1g0SXhzWVg3RERCN010eC9pcXMKY2pCL091dlNCa2ppU2xlUzdibE5JVC9kQTdLNC9DSjNvaXUwMmJMNEV4Y2xDSGVwenFOTWVQM3dVWmdweE9uZgpOT3VkOElYWUs3M3pTY3VFOEUxNTdZd3B6Q0twVmFIWDdaSmY4UXVOc09PNVcvYUlqS2wzTDYyNjkrZUlPRXJHCndPTm1hSG56Zmc5RkxwSmh6Z3BPMzhhVm43NnZENUtLakJhaldza1krNGEyZ1NRbUtOZUZxYXFPb3p5RUZNMGUKY0ZXWlZWWjNMZWg0dkVNb1lWUHlJeng5Nng4ZjIveW1QbmhJdXZRdjV3TjRmeWVwYTdFWTVVQ2NwNzF6OGtmUAo0RmNVelBBMElEV3lNaWhYUi9HNlhnUVFaNEdiL3FCQmh2cnZpSkNGemZZRGNKZ0w3RmVnRllIUDNQR0wwN1FnCnZMZXZNSytpUVpQcnhyYnh5U3FkUE9rZ3VyS2pWclhUVXI0QTlUZ2lMeUlYNVVsSnEzRS9SVjdtZk9xWm5MVGEKU0NWWEhCaHVQbG5DR1pSMDFUb1RDZktoTUcxdTBDRm5MMisxNWhDOWZxT21XdjlRa2U0M3FsSjBQZ0YzVkovWAp1eC9tVHBuazlnbmJHOUpIK21mSDM5Um9GdlROaW5Zd1NNdll6dXRWT242OXNPemR3aERsYTkwbDNBQ2g0eENWCks3Sk9YK3VIa29OdTNnMmlWeGlaVU0wQ0F3RUFBUT09Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo='; diff --git a/ee/packages/license/src/v2/bundles.ts b/ee/packages/license/src/v2/bundles.ts index 0ff1cd6c41a95..1e384fff0bdd1 100644 --- a/ee/packages/license/src/v2/bundles.ts +++ b/ee/packages/license/src/v2/bundles.ts @@ -1,4 +1,4 @@ -import type { LicenseModule } from '../definition/LicenseModule'; +import type { LicenseModule } from '@rocket.chat/core-typings'; interface IBundle { [key: string]: LicenseModule[]; diff --git a/ee/packages/license/src/v2/convertToV3.ts b/ee/packages/license/src/v2/convertToV3.ts index 94e94a868e54b..a7b67ada2c6ed 100644 --- a/ee/packages/license/src/v2/convertToV3.ts +++ b/ee/packages/license/src/v2/convertToV3.ts @@ -3,9 +3,8 @@ * Transform a License V2 into a V3 representation. */ -import type { ILicenseV2 } from '../definition/ILicenseV2'; -import type { ILicenseV3 } from '../definition/ILicenseV3'; -import type { LicenseModule } from '../definition/LicenseModule'; +import type { ILicenseV2, ILicenseV3, LicenseModule } from '@rocket.chat/core-typings'; + import { isBundle, getBundleFromModule, getBundleModules } from './bundles'; import { getTagColor } from './getTagColor';