From 5f81a0f3cb8dfe8a53543af959b7679e03b71254 Mon Sep 17 00:00:00 2001 From: Luis Mauro <1216941+lmauromb@users.noreply.github.com> Date: Thu, 28 Sep 2023 16:17:27 -0600 Subject: [PATCH] feat: License V3 (#30287) Co-authored-by: Pierre Lehnen Co-authored-by: Guilherme Gazzo --- .changeset/twelve-files-deny.md | 22 + apps/meteor/app/api/server/v1/federation.ts | 4 +- .../app/statistics/server/lib/statistics.ts | 2 +- .../client/views/hooks/useUpgradeTabParams.ts | 10 +- .../ee/app/api-enterprise/server/index.ts | 4 +- .../authorization/server/validateUserRoles.js | 29 - .../authorization/server/validateUserRoles.ts | 43 ++ .../ee/app/canned-responses/server/index.ts | 4 +- .../ee/app/license/server/canEnableApp.ts | 25 + apps/meteor/ee/app/license/server/decrypt.ts | 10 - .../ee/app/license/server/getStatistics.ts | 9 +- apps/meteor/ee/app/license/server/index.ts | 2 - .../ee/app/license/server/lib/getAppCount.ts | 21 + .../license/server/lib/isUnderAppLimits.ts | 26 - .../license/server/license.internalService.ts | 20 +- apps/meteor/ee/app/license/server/license.ts | 467 ------------- apps/meteor/ee/app/license/server/methods.ts | 12 +- apps/meteor/ee/app/license/server/settings.ts | 18 +- apps/meteor/ee/app/license/server/startup.ts | 23 +- .../server/business-hour/Helper.ts | 4 +- .../app/livechat-enterprise/server/index.ts | 4 +- .../server/lib/LivechatEnterprise.ts | 6 +- .../app/message-read-receipt/server/index.ts | 4 +- .../meteor/ee/app/settings/server/settings.ts | 8 +- .../server/services/voipService.ts | 4 +- .../ee/client/hooks/useHasLicenseModule.ts | 5 +- apps/meteor/ee/client/lib/onToggledFeature.ts | 4 +- .../client/views/admin/users/useSeatsCap.ts | 1 + apps/meteor/ee/server/api/api.ts | 5 +- apps/meteor/ee/server/api/chat.ts | 4 +- apps/meteor/ee/server/api/licenses.ts | 21 +- apps/meteor/ee/server/api/roles.ts | 6 +- apps/meteor/ee/server/api/sessions.ts | 14 +- .../endpoints/appsCountHandler.ts | 4 +- .../ee/server/apps/communication/rest.ts | 5 +- apps/meteor/ee/server/apps/orchestrator.js | 2 +- apps/meteor/ee/server/configuration/ldap.ts | 4 +- apps/meteor/ee/server/configuration/oauth.ts | 4 +- .../server/configuration/outlookCalendar.ts | 4 +- apps/meteor/ee/server/configuration/saml.ts | 6 +- .../server/configuration/videoConference.ts | 4 +- apps/meteor/ee/server/lib/EnterpriseCheck.ts | 2 +- apps/meteor/ee/server/lib/syncUserRoles.ts | 4 +- .../server/local-services/instance/service.ts | 2 +- .../ee/server/methods/getReadReceipts.ts | 4 +- apps/meteor/ee/server/models/startup.ts | 4 +- .../ee/server/startup/apps/trialExpiration.ts | 4 +- apps/meteor/ee/server/startup/audit.ts | 5 +- .../ee/server/startup/deviceManagement.ts | 5 +- .../ee/server/startup/engagementDashboard.ts | 5 +- .../ee/server/startup/maxRoomsPerGuest.ts | 7 +- apps/meteor/ee/server/startup/seatsCap.ts | 38 +- apps/meteor/ee/server/startup/services.ts | 6 +- apps/meteor/ee/server/startup/upsell.ts | 17 +- ...getInstallationSourceFromAppStorageItem.ts | 3 +- apps/meteor/package.json | 2 + .../server/services/authorization/service.ts | 2 +- apps/meteor/server/startup/migrations/v278.ts | 4 +- ee/apps/account-service/Dockerfile | 9 + ee/apps/authorization-service/Dockerfile | 9 + ee/apps/ddp-streamer/Dockerfile | 12 +- ee/apps/omnichannel-transcript/Dockerfile | 12 +- ee/apps/presence-service/Dockerfile | 9 + ee/apps/queue-worker/Dockerfile | 12 +- ee/apps/stream-hub-service/Dockerfile | 6 + ee/packages/license/.eslintrc.json | 4 + .../license/__tests__/MockedLicenseBuilder.ts | 209 ++++++ ee/packages/license/__tests__/emitter.spec.ts | 66 ++ .../license/__tests__/setLicense.spec.ts | 103 +++ ee/packages/license/babel.config.json | 11 + ee/packages/license/jest.config.ts | 16 + ee/packages/license/package.json | 47 ++ .../license/src}/definition/ILicenseTag.ts | 0 .../license/src/definition/ILicenseV2.ts | 2 +- .../license/src/definition/ILicenseV3.ts | 64 ++ .../license/src/definition/LicenseBehavior.ts | 8 + .../license/src/definition/LicenseLimit.ts | 7 + .../license/src/definition/LicenseModule.ts | 18 + .../license/src/definition/LicensePeriod.ts | 13 + .../license/src/definition/LimitContext.ts | 5 + ee/packages/license/src/deprecated.ts | 38 + .../src/errors/DuplicatedLicenseError.ts | 6 + .../license/src/errors/InvalidLicenseError.ts | 6 + .../src/errors/NotReadyForValidation.ts | 6 + ee/packages/license/src/events/deprecated.ts | 12 + ee/packages/license/src/events/emitter.ts | 30 + ee/packages/license/src/events/listeners.ts | 75 ++ .../src/events/overwriteClassOnLicense.ts | 26 + ee/packages/license/src/index.ts | 106 +++ ee/packages/license/src/license.spec.ts | 42 ++ ee/packages/license/src/license.ts | 230 ++++++ ee/packages/license/src/logger.ts | 3 + ee/packages/license/src/modules.ts | 50 ++ ee/packages/license/src/pendingLicense.ts | 32 + ee/packages/license/src/showLicense.ts | 27 + ee/packages/license/src/tags.ts | 23 + ee/packages/license/src/token.ts | 59 ++ .../packages/license/src/v2}/bundles.ts | 0 ee/packages/license/src/v2/convertToV3.ts | 114 +++ .../packages/license/src/v2}/getTagColor.ts | 0 .../getCurrentValueForLicenseLimit.ts | 40 ++ .../src/validation/getModulesToDisable.ts | 15 + .../src/validation/getResultingBehavior.ts | 20 + .../src/validation/isBehaviorsInResult.ts | 4 + .../src/validation/isReadyForValidation.ts | 7 + .../src/validation/runValidation.spec.ts | 38 + .../license/src/validation/runValidation.ts | 22 + .../license/src/validation/validateFormat.ts | 16 + .../src/validation/validateLicenseLimits.ts | 39 ++ .../src/validation/validateLicensePeriods.ts | 38 + .../src/validation/validateLicenseUrl.ts | 59 ++ ee/packages/license/tsconfig.json | 9 + .../src/OmnichannelTranscript.ts | 2 +- .../omnichannel-services/src/QueueWorker.ts | 2 +- ee/packages/presence/src/Presence.ts | 2 +- packages/core-services/src/types/ILicense.ts | 4 +- .../core-typings/src/ee/ILicense/ILicense.ts | 20 - .../src/ee/ILicense/ILicenseTag.ts | 4 - packages/core-typings/src/index.ts | 1 - packages/jwt/.eslintrc.json | 4 + packages/jwt/__tests__/jwt.spec.ts | 90 +++ packages/jwt/jest.config.js | 5 + packages/jwt/package.json | 31 + packages/jwt/src/index.ts | 29 + packages/jwt/tsconfig.json | 10 + .../model-typings/src/models/IUsersModel.ts | 2 +- packages/rest-typings/package.json | 1 + packages/rest-typings/src/v1/licenses.ts | 4 +- yarn.lock | 659 +++++++++++------- 129 files changed, 2687 insertions(+), 1005 deletions(-) create mode 100644 .changeset/twelve-files-deny.md delete mode 100644 apps/meteor/ee/app/authorization/server/validateUserRoles.js create mode 100644 apps/meteor/ee/app/authorization/server/validateUserRoles.ts create mode 100644 apps/meteor/ee/app/license/server/canEnableApp.ts delete mode 100644 apps/meteor/ee/app/license/server/decrypt.ts create mode 100644 apps/meteor/ee/app/license/server/lib/getAppCount.ts delete mode 100644 apps/meteor/ee/app/license/server/lib/isUnderAppLimits.ts delete mode 100644 apps/meteor/ee/app/license/server/license.ts create mode 100644 ee/packages/license/.eslintrc.json create mode 100644 ee/packages/license/__tests__/MockedLicenseBuilder.ts create mode 100644 ee/packages/license/__tests__/emitter.spec.ts create mode 100644 ee/packages/license/__tests__/setLicense.spec.ts create mode 100644 ee/packages/license/babel.config.json create mode 100644 ee/packages/license/jest.config.ts create mode 100644 ee/packages/license/package.json rename {apps/meteor/ee/app/license => ee/packages/license/src}/definition/ILicenseTag.ts (100%) rename apps/meteor/ee/app/license/definition/ILicense.ts => ee/packages/license/src/definition/ILicenseV2.ts (93%) create mode 100644 ee/packages/license/src/definition/ILicenseV3.ts create mode 100644 ee/packages/license/src/definition/LicenseBehavior.ts create mode 100644 ee/packages/license/src/definition/LicenseLimit.ts create mode 100644 ee/packages/license/src/definition/LicenseModule.ts create mode 100644 ee/packages/license/src/definition/LicensePeriod.ts create mode 100644 ee/packages/license/src/definition/LimitContext.ts create mode 100644 ee/packages/license/src/deprecated.ts create mode 100644 ee/packages/license/src/errors/DuplicatedLicenseError.ts create mode 100644 ee/packages/license/src/errors/InvalidLicenseError.ts create mode 100644 ee/packages/license/src/errors/NotReadyForValidation.ts create mode 100644 ee/packages/license/src/events/deprecated.ts create mode 100644 ee/packages/license/src/events/emitter.ts create mode 100644 ee/packages/license/src/events/listeners.ts create mode 100644 ee/packages/license/src/events/overwriteClassOnLicense.ts create mode 100644 ee/packages/license/src/index.ts create mode 100644 ee/packages/license/src/license.spec.ts create mode 100644 ee/packages/license/src/license.ts create mode 100644 ee/packages/license/src/logger.ts create mode 100644 ee/packages/license/src/modules.ts create mode 100644 ee/packages/license/src/pendingLicense.ts create mode 100644 ee/packages/license/src/showLicense.ts create mode 100644 ee/packages/license/src/tags.ts create mode 100644 ee/packages/license/src/token.ts rename {apps/meteor/ee/app/license/server => ee/packages/license/src/v2}/bundles.ts (100%) create mode 100644 ee/packages/license/src/v2/convertToV3.ts rename {apps/meteor/ee/app/license/server => ee/packages/license/src/v2}/getTagColor.ts (100%) create mode 100644 ee/packages/license/src/validation/getCurrentValueForLicenseLimit.ts create mode 100644 ee/packages/license/src/validation/getModulesToDisable.ts create mode 100644 ee/packages/license/src/validation/getResultingBehavior.ts create mode 100644 ee/packages/license/src/validation/isBehaviorsInResult.ts create mode 100644 ee/packages/license/src/validation/isReadyForValidation.ts create mode 100644 ee/packages/license/src/validation/runValidation.spec.ts create mode 100644 ee/packages/license/src/validation/runValidation.ts create mode 100644 ee/packages/license/src/validation/validateFormat.ts create mode 100644 ee/packages/license/src/validation/validateLicenseLimits.ts create mode 100644 ee/packages/license/src/validation/validateLicensePeriods.ts create mode 100644 ee/packages/license/src/validation/validateLicenseUrl.ts create mode 100644 ee/packages/license/tsconfig.json delete mode 100644 packages/core-typings/src/ee/ILicense/ILicense.ts delete mode 100644 packages/core-typings/src/ee/ILicense/ILicenseTag.ts create mode 100644 packages/jwt/.eslintrc.json create mode 100644 packages/jwt/__tests__/jwt.spec.ts create mode 100644 packages/jwt/jest.config.js create mode 100644 packages/jwt/package.json create mode 100644 packages/jwt/src/index.ts create mode 100644 packages/jwt/tsconfig.json diff --git a/.changeset/twelve-files-deny.md b/.changeset/twelve-files-deny.md new file mode 100644 index 000000000000..123bf0a7764b --- /dev/null +++ b/.changeset/twelve-files-deny.md @@ -0,0 +1,22 @@ +--- +'@rocket.chat/license': minor +'@rocket.chat/jwt': minor +'@rocket.chat/omnichannel-services': minor +'@rocket.chat/omnichannel-transcript': minor +'@rocket.chat/authorization-service': minor +'@rocket.chat/stream-hub-service': minor +'@rocket.chat/presence-service': minor +'@rocket.chat/account-service': minor +'@rocket.chat/core-services': minor +'@rocket.chat/model-typings': minor +'@rocket.chat/core-typings': minor +'@rocket.chat/rest-typings': minor +'@rocket.chat/ddp-streamer': minor +'@rocket.chat/queue-worker': minor +'@rocket.chat/presence': minor +'@rocket.chat/meteor': minor +--- + +Implemented the License library, it is used to handle the functionality like expiration date, modules, limits, etc. +Also added a version v3 of the license, which contains an extended list of features. +v2 is still supported, since we convert it to v3 on the fly. diff --git a/apps/meteor/app/api/server/v1/federation.ts b/apps/meteor/app/api/server/v1/federation.ts index 02fc30763eeb..7be5b1fc13fe 100644 --- a/apps/meteor/app/api/server/v1/federation.ts +++ b/apps/meteor/app/api/server/v1/federation.ts @@ -1,7 +1,7 @@ import { Federation, FederationEE } from '@rocket.chat/core-services'; +import { License } from '@rocket.chat/license'; import { isFederationVerifyMatrixIdProps } from '@rocket.chat/rest-typings'; -import { isEnterprise } from '../../../../ee/app/license/server'; import { API } from '../api'; API.v1.addRoute( @@ -14,7 +14,7 @@ API.v1.addRoute( async get() { const { matrixIds } = this.queryParams; - const federationService = isEnterprise() ? FederationEE : Federation; + const federationService = License.hasValidLicense() ? FederationEE : Federation; const results = await federationService.verifyMatrixIds(matrixIds); diff --git a/apps/meteor/app/statistics/server/lib/statistics.ts b/apps/meteor/app/statistics/server/lib/statistics.ts index 8cfe45b42232..54470a209196 100644 --- a/apps/meteor/app/statistics/server/lib/statistics.ts +++ b/apps/meteor/app/statistics/server/lib/statistics.ts @@ -27,7 +27,7 @@ import { } from '@rocket.chat/models'; import { MongoInternals } from 'meteor/mongo'; -import { getStatistics as getEnterpriseStatistics } from '../../../../ee/app/license/server'; +import { getStatistics as getEnterpriseStatistics } from '../../../../ee/app/license/server/getStatistics'; import { readSecondaryPreferred } from '../../../../server/database/readSecondaryPreferred'; import { isRunningMs } from '../../../../server/lib/isRunningMs'; import { getControl } from '../../../../server/lib/migrations'; diff --git a/apps/meteor/client/views/hooks/useUpgradeTabParams.ts b/apps/meteor/client/views/hooks/useUpgradeTabParams.ts index e051b69db8fa..65dd4cb1e396 100644 --- a/apps/meteor/client/views/hooks/useUpgradeTabParams.ts +++ b/apps/meteor/client/views/hooks/useUpgradeTabParams.ts @@ -1,3 +1,4 @@ +import type { ILicenseV2, ILicenseV3 } from '@rocket.chat/license'; import { useSetting } from '@rocket.chat/ui-contexts'; import { format } from 'date-fns'; @@ -16,9 +17,12 @@ export const useUpgradeTabParams = (): { tabType: UpgradeTabVariant | false; tri const hasValidLicense = licensesData?.licenses.some((license) => license.modules.length > 0) ?? false; const hadExpiredTrials = cloudWorkspaceHadTrial ?? false; - const trialLicense = licensesData?.licenses?.find(({ meta }) => meta?.trial); - const isTrial = licensesData?.licenses?.every(({ meta }) => meta?.trial) ?? false; - const trialEndDate = trialLicense?.meta ? format(new Date(trialLicense.meta.trialEnd), 'yyyy-MM-dd') : undefined; + const licenses = (licensesData?.licenses || []) as (Partial & { modules: string[] })[]; + + const trialLicense = licenses.find(({ meta, information }) => information?.trial ?? meta?.trial); + const isTrial = Boolean(trialLicense); + const trialEndDateStr = trialLicense?.information?.visualExpiration || trialLicense?.meta?.trialEnd || trialLicense?.cloudMeta?.trialEnd; + const trialEndDate = trialEndDateStr ? format(new Date(trialEndDateStr), 'yyyy-MM-dd') : undefined; const upgradeTabType = getUpgradeTabType({ registered, diff --git a/apps/meteor/ee/app/api-enterprise/server/index.ts b/apps/meteor/ee/app/api-enterprise/server/index.ts index 6af539bda36c..7a528a4ec2f4 100644 --- a/apps/meteor/ee/app/api-enterprise/server/index.ts +++ b/apps/meteor/ee/app/api-enterprise/server/index.ts @@ -1,5 +1,5 @@ -import { onLicense } from '../../license/server'; +import { License } from '@rocket.chat/license'; -await onLicense('canned-responses', async () => { +await License.onLicense('canned-responses', async () => { await import('./canned-responses'); }); diff --git a/apps/meteor/ee/app/authorization/server/validateUserRoles.js b/apps/meteor/ee/app/authorization/server/validateUserRoles.js deleted file mode 100644 index fe8e3410bc01..000000000000 --- a/apps/meteor/ee/app/authorization/server/validateUserRoles.js +++ /dev/null @@ -1,29 +0,0 @@ -import { Users } from '@rocket.chat/models'; -import { Meteor } from 'meteor/meteor'; - -import { isEnterprise, getMaxGuestUsers } from '../../license/server'; - -export const validateUserRoles = async function (userId, userData) { - if (!isEnterprise()) { - return; - } - - if (!userData.roles.includes('guest')) { - return; - } - - if (userData.roles.length >= 2) { - throw new Meteor.Error('error-guests-cant-have-other-roles', "Guest users can't receive any other role", { - method: 'insertOrUpdateUser', - field: 'Assign_role', - }); - } - - const guestCount = await Users.getActiveLocalGuestCount(userData._id); - if (guestCount >= getMaxGuestUsers()) { - throw new Meteor.Error('error-max-guests-number-reached', 'Maximum number of guests reached.', { - method: 'insertOrUpdateUser', - field: 'Assign_role', - }); - } -}; diff --git a/apps/meteor/ee/app/authorization/server/validateUserRoles.ts b/apps/meteor/ee/app/authorization/server/validateUserRoles.ts new file mode 100644 index 000000000000..a07165b8c5d8 --- /dev/null +++ b/apps/meteor/ee/app/authorization/server/validateUserRoles.ts @@ -0,0 +1,43 @@ +import type { IUser } from '@rocket.chat/core-typings'; +import { License } from '@rocket.chat/license'; +import { Users } from '@rocket.chat/models'; +import { Meteor } from 'meteor/meteor'; + +import { i18n } from '../../../../server/lib/i18n'; + +export const validateUserRoles = async function (userData: Partial) { + if (!License.hasValidLicense()) { + return; + } + + const isGuest = Boolean(userData.roles?.includes('guest') && userData.roles.length === 1); + const currentUserData = userData._id ? await Users.findOneById(userData._id) : null; + const wasGuest = Boolean(currentUserData?.roles?.includes('guest') && currentUserData.roles.length === 1); + + if (currentUserData?.type === 'app') { + return; + } + + if (isGuest) { + if (wasGuest) { + return; + } + + if (await License.shouldPreventAction('guestUsers')) { + throw new Meteor.Error('error-max-guests-number-reached', 'Maximum number of guests reached.', { + method: 'insertOrUpdateUser', + field: 'Assign_role', + }); + } + + return; + } + + if (!wasGuest && userData._id) { + return; + } + + if (await License.shouldPreventAction('activeUsers')) { + throw new Meteor.Error('error-license-user-limit-reached', i18n.t('error-license-user-limit-reached')); + } +}; diff --git a/apps/meteor/ee/app/canned-responses/server/index.ts b/apps/meteor/ee/app/canned-responses/server/index.ts index 47249c017b83..99254b037380 100644 --- a/apps/meteor/ee/app/canned-responses/server/index.ts +++ b/apps/meteor/ee/app/canned-responses/server/index.ts @@ -1,6 +1,6 @@ -import { onLicense } from '../../license/server'; +import { License } from '@rocket.chat/license'; -await onLicense('canned-responses', async () => { +await License.onLicense('canned-responses', async () => { const { createSettings } = await import('./settings'); await import('./permissions'); await import('./hooks/onRemoveAgentDepartment'); diff --git a/apps/meteor/ee/app/license/server/canEnableApp.ts b/apps/meteor/ee/app/license/server/canEnableApp.ts new file mode 100644 index 000000000000..72220e27acad --- /dev/null +++ b/apps/meteor/ee/app/license/server/canEnableApp.ts @@ -0,0 +1,25 @@ +import type { IAppStorageItem } from '@rocket.chat/apps-engine/server/storage'; +import { Apps } from '@rocket.chat/core-services'; +import { License } from '@rocket.chat/license'; + +import { getInstallationSourceFromAppStorageItem } from '../../../../lib/apps/getInstallationSourceFromAppStorageItem'; + +export const canEnableApp = async (app: IAppStorageItem): Promise => { + if (!(await Apps.isInitialized())) { + return false; + } + + // Migrated apps were installed before the validation was implemented + // so they're always allowed to be enabled + if (app.migrated) { + return true; + } + + const source = getInstallationSourceFromAppStorageItem(app); + switch (source) { + case 'private': + return !(await License.shouldPreventAction('privateApps')); + default: + return !(await License.shouldPreventAction('marketplaceApps')); + } +}; diff --git a/apps/meteor/ee/app/license/server/decrypt.ts b/apps/meteor/ee/app/license/server/decrypt.ts deleted file mode 100644 index 62e34817aec6..000000000000 --- a/apps/meteor/ee/app/license/server/decrypt.ts +++ /dev/null @@ -1,10 +0,0 @@ -import crypto from 'crypto'; - -const publicKey = - 'LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQ0lqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FnOEFNSUlDQ2dLQ0FnRUFxV1Nza2Q5LzZ6Ung4a3lQY2ljcwpiMzJ3Mnd4VnV3N3lCVDk2clEvOEQreU1lQ01POXdTU3BIYS85bkZ5d293RXRpZ3B0L3dyb1BOK1ZHU3didHdQCkZYQmVxRWxCbmRHRkFsODZlNStFbGlIOEt6L2hHbkNtSk5tWHB4RUsyUkUwM1g0SXhzWVg3RERCN010eC9pcXMKY2pCL091dlNCa2ppU2xlUzdibE5JVC9kQTdLNC9DSjNvaXUwMmJMNEV4Y2xDSGVwenFOTWVQM3dVWmdweE9uZgpOT3VkOElYWUs3M3pTY3VFOEUxNTdZd3B6Q0twVmFIWDdaSmY4UXVOc09PNVcvYUlqS2wzTDYyNjkrZUlPRXJHCndPTm1hSG56Zmc5RkxwSmh6Z3BPMzhhVm43NnZENUtLakJhaldza1krNGEyZ1NRbUtOZUZxYXFPb3p5RUZNMGUKY0ZXWlZWWjNMZWg0dkVNb1lWUHlJeng5Nng4ZjIveW1QbmhJdXZRdjV3TjRmeWVwYTdFWTVVQ2NwNzF6OGtmUAo0RmNVelBBMElEV3lNaWhYUi9HNlhnUVFaNEdiL3FCQmh2cnZpSkNGemZZRGNKZ0w3RmVnRllIUDNQR0wwN1FnCnZMZXZNSytpUVpQcnhyYnh5U3FkUE9rZ3VyS2pWclhUVXI0QTlUZ2lMeUlYNVVsSnEzRS9SVjdtZk9xWm5MVGEKU0NWWEhCaHVQbG5DR1pSMDFUb1RDZktoTUcxdTBDRm5MMisxNWhDOWZxT21XdjlRa2U0M3FsSjBQZ0YzVkovWAp1eC9tVHBuazlnbmJHOUpIK21mSDM5Um9GdlROaW5Zd1NNdll6dXRWT242OXNPemR3aERsYTkwbDNBQ2g0eENWCks3Sk9YK3VIa29OdTNnMmlWeGlaVU0wQ0F3RUFBUT09Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo='; - -export default function decrypt(encrypted: string): string { - const decrypted = crypto.publicDecrypt(Buffer.from(publicKey, 'base64').toString('utf-8'), Buffer.from(encrypted, 'base64')); - - return decrypted.toString('utf-8'); -} diff --git a/apps/meteor/ee/app/license/server/getStatistics.ts b/apps/meteor/ee/app/license/server/getStatistics.ts index d7f81e416bfd..e8ff402ea1ca 100644 --- a/apps/meteor/ee/app/license/server/getStatistics.ts +++ b/apps/meteor/ee/app/license/server/getStatistics.ts @@ -1,10 +1,9 @@ import { log } from 'console'; import { Analytics } from '@rocket.chat/core-services'; +import { License } from '@rocket.chat/license'; import { CannedResponse, OmnichannelServiceLevelAgreements, LivechatRooms, LivechatTag, LivechatUnit, Users } from '@rocket.chat/models'; -import { getModules, getTags, hasLicense } from './license'; - type ENTERPRISE_STATISTICS = GenericStats & Partial; type GenericStats = { @@ -28,8 +27,8 @@ type EEOnlyStats = { export async function getStatistics(): Promise { const genericStats: GenericStats = { - modules: getModules(), - tags: getTags().map(({ name }) => name), + modules: License.getModules(), + tags: License.getTags().map(({ name }) => name), seatRequests: await Analytics.getSeatRequestCount(), }; @@ -45,7 +44,7 @@ export async function getStatistics(): Promise { // These models are only available on EE license so don't import them inside CE license as it will break the build async function getEEStatistics(): Promise { - if (!hasLicense('livechat-enterprise')) { + if (!License.hasModule('livechat-enterprise')) { return; } diff --git a/apps/meteor/ee/app/license/server/index.ts b/apps/meteor/ee/app/license/server/index.ts index f7d83ed388b8..403922524fa8 100644 --- a/apps/meteor/ee/app/license/server/index.ts +++ b/apps/meteor/ee/app/license/server/index.ts @@ -2,6 +2,4 @@ import './settings'; import './methods'; import './startup'; -export { onLicense, overwriteClassOnLicense, isEnterprise, getMaxGuestUsers } from './license'; - export { getStatistics } from './getStatistics'; diff --git a/apps/meteor/ee/app/license/server/lib/getAppCount.ts b/apps/meteor/ee/app/license/server/lib/getAppCount.ts new file mode 100644 index 000000000000..a05813f596bb --- /dev/null +++ b/apps/meteor/ee/app/license/server/lib/getAppCount.ts @@ -0,0 +1,21 @@ +import { Apps } from '@rocket.chat/core-services'; +import type { LicenseAppSources } from '@rocket.chat/license'; + +import { getInstallationSourceFromAppStorageItem } from '../../../../../lib/apps/getInstallationSourceFromAppStorageItem'; + +export async function getAppCount(source: LicenseAppSources): Promise { + if (!(await Apps.isInitialized())) { + return 0; + } + + const apps = await Apps.getApps({ enabled: true }); + + if (!apps || !Array.isArray(apps)) { + return 0; + } + + const storageItems = await Promise.all(apps.map((app) => Apps.getAppStorageItemById(app.id))); + const activeAppsFromSameSource = storageItems.filter((item) => item && getInstallationSourceFromAppStorageItem(item) === source); + + return activeAppsFromSameSource.length; +} diff --git a/apps/meteor/ee/app/license/server/lib/isUnderAppLimits.ts b/apps/meteor/ee/app/license/server/lib/isUnderAppLimits.ts deleted file mode 100644 index b53b6512e2a1..000000000000 --- a/apps/meteor/ee/app/license/server/lib/isUnderAppLimits.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Apps } from '@rocket.chat/core-services'; - -import { getInstallationSourceFromAppStorageItem } from '../../../../../lib/apps/getInstallationSourceFromAppStorageItem'; -import type { ILicense, LicenseAppSources } from '../../definition/ILicense'; - -export async function isUnderAppLimits(licenseAppsConfig: NonNullable, source: LicenseAppSources): Promise { - const apps = await Apps.getApps({ enabled: true }); - - if (!apps || !Array.isArray(apps)) { - return true; - } - - const storageItems = await Promise.all(apps.map((app) => Apps.getAppStorageItemById(app.id))); - const activeAppsFromSameSource = storageItems.filter((item) => item && getInstallationSourceFromAppStorageItem(item) === source); - - const configKey = `max${source.charAt(0).toUpperCase()}${source.slice(1)}Apps` as keyof typeof licenseAppsConfig; - const configLimit = licenseAppsConfig[configKey]; - - // If the workspace can install unlimited apps - // the config will be -1 - if (configLimit === -1) { - return true; - } - - return activeAppsFromSameSource.length < configLimit; -} diff --git a/apps/meteor/ee/app/license/server/license.internalService.ts b/apps/meteor/ee/app/license/server/license.internalService.ts index 047a67d323ff..9036a9b1848c 100644 --- a/apps/meteor/ee/app/license/server/license.internalService.ts +++ b/apps/meteor/ee/app/license/server/license.internalService.ts @@ -1,9 +1,9 @@ import type { ILicense } from '@rocket.chat/core-services'; import { api, ServiceClassInternal } from '@rocket.chat/core-services'; +import { License, type LicenseModule } from '@rocket.chat/license'; import { guestPermissions } from '../../authorization/lib/guestPermissions'; import { resetEnterprisePermissions } from '../../authorization/server/resetEnterprisePermissions'; -import { getModules, hasLicense, isEnterprise, onModule, onValidateLicenses } from './license'; export class LicenseService extends ServiceClassInternal implements ILicense { protected name = 'license'; @@ -11,8 +11,8 @@ export class LicenseService extends ServiceClassInternal implements ILicense { constructor() { super(); - onValidateLicenses((): void => { - if (!isEnterprise()) { + License.onValidateLicense((): void => { + if (!License.hasValidLicense()) { return; } @@ -20,13 +20,13 @@ export class LicenseService extends ServiceClassInternal implements ILicense { void resetEnterprisePermissions(); }); - onModule((licenseModule) => { + License.onModule((licenseModule) => { void api.broadcast('license.module', licenseModule); }); } async started(): Promise { - if (!isEnterprise()) { + if (!License.hasValidLicense()) { return; } @@ -34,16 +34,16 @@ export class LicenseService extends ServiceClassInternal implements ILicense { await resetEnterprisePermissions(); } - hasLicense(feature: string): boolean { - return hasLicense(feature); + hasModule(feature: LicenseModule): boolean { + return License.hasModule(feature); } - isEnterprise(): boolean { - return isEnterprise(); + hasValidLicense(): boolean { + return License.hasValidLicense(); } getModules(): string[] { - return getModules(); + return License.getModules(); } getGuestPermissions(): string[] { diff --git a/apps/meteor/ee/app/license/server/license.ts b/apps/meteor/ee/app/license/server/license.ts deleted file mode 100644 index fe0b22a0ee45..000000000000 --- a/apps/meteor/ee/app/license/server/license.ts +++ /dev/null @@ -1,467 +0,0 @@ -import { EventEmitter } from 'events'; - -import type { IAppStorageItem } from '@rocket.chat/apps-engine/server/storage'; -import { Apps } from '@rocket.chat/core-services'; -import { Users } from '@rocket.chat/models'; - -import { getInstallationSourceFromAppStorageItem } from '../../../../lib/apps/getInstallationSourceFromAppStorageItem'; -import type { ILicense } from '../definition/ILicense'; -import type { ILicenseTag } from '../definition/ILicenseTag'; -import type { BundleFeature } from './bundles'; -import { getBundleModules, isBundle, getBundleFromModule } from './bundles'; -import decrypt from './decrypt'; -import { getTagColor } from './getTagColor'; -import { isUnderAppLimits } from './lib/isUnderAppLimits'; - -const EnterpriseLicenses = new EventEmitter(); - -interface IValidLicense { - valid?: boolean; - license: ILicense; -} - -let maxGuestUsers = 0; -let maxRoomsPerGuest = 0; -let maxActiveUsers = 0; - -class LicenseClass { - private url: string | null = null; - - private licenses: IValidLicense[] = []; - - private encryptedLicenses = new Set(); - - private tags = new Set(); - - private modules = new Set(); - - private appsConfig: NonNullable = { - maxPrivateApps: 3, - maxMarketplaceApps: 5, - }; - - private _validateExpiration(expiration: string): boolean { - return new Date() > new Date(expiration); - } - - private _validateURL(licenseURL: string, url: string): boolean { - licenseURL = licenseURL - .replace(/\./g, '\\.') // convert dots to literal - .replace(/\*/g, '.*'); // convert * to .* - const regex = new RegExp(`^${licenseURL}$`, 'i'); - - return !!regex.exec(url); - } - - private _setAppsConfig(license: ILicense): void { - // If the license is valid, no limit is going to be applied to apps installation for now - // This guarantees that upgraded workspaces won't be affected by the new limit right away - // and gives us time to propagate the new limit schema to all licenses - const { maxPrivateApps = -1, maxMarketplaceApps = -1 } = license.apps || {}; - - if (maxPrivateApps === -1 || maxPrivateApps > this.appsConfig.maxPrivateApps) { - this.appsConfig.maxPrivateApps = maxPrivateApps; - } - - if (maxMarketplaceApps === -1 || maxMarketplaceApps > this.appsConfig.maxMarketplaceApps) { - this.appsConfig.maxMarketplaceApps = maxMarketplaceApps; - } - } - - private _validModules(licenseModules: string[]): void { - licenseModules.forEach((licenseModule) => { - const modules = isBundle(licenseModule) ? getBundleModules(licenseModule) : [licenseModule]; - - modules.forEach((module) => { - this.modules.add(module); - EnterpriseLicenses.emit('module', { module, valid: true }); - EnterpriseLicenses.emit(`valid:${module}`); - }); - }); - } - - private _invalidModules(licenseModules: string[]): void { - licenseModules.forEach((licenseModule) => { - const modules = isBundle(licenseModule) ? getBundleModules(licenseModule) : [licenseModule]; - - modules.forEach((module) => { - EnterpriseLicenses.emit('module', { module, valid: false }); - EnterpriseLicenses.emit(`invalid:${module}`); - }); - }); - } - - private _addTags(license: ILicense): void { - // if no tag present, it means it is an old license, so try check for bundles and use them as tags - if (typeof license.tag === 'undefined') { - license.modules - .filter(isBundle) - .map(getBundleFromModule) - .forEach((tag) => tag && this._addTag({ name: tag, color: getTagColor(tag) })); - return; - } - - this._addTag(license.tag); - } - - private _addTag(tag: ILicenseTag): void { - // make sure to not add duplicated tag names - for (const addedTag of this.tags) { - if (addedTag.name.toLowerCase() === tag.name.toLowerCase()) { - return; - } - } - - this.tags.add(tag); - } - - addLicense(license: ILicense): void { - this.licenses.push({ - valid: undefined, - license, - }); - - this.validate(); - } - - lockLicense(encryptedLicense: string): void { - this.encryptedLicenses.add(encryptedLicense); - } - - isLicenseDuplicate(encryptedLicense: string): boolean { - if (this.encryptedLicenses.has(encryptedLicense)) { - return true; - } - - return false; - } - - hasModule(module: string): boolean { - return this.modules.has(module); - } - - hasAnyValidLicense(): boolean { - return this.licenses.some((item) => item.valid); - } - - getLicenses(): IValidLicense[] { - return this.licenses; - } - - getModules(): string[] { - return [...this.modules]; - } - - getTags(): ILicenseTag[] { - return [...this.tags]; - } - - getAppsConfig(): NonNullable { - return this.appsConfig; - } - - setURL(url: string): void { - this.url = url.replace(/\/$/, '').replace(/^https?:\/\/(.*)$/, '$1'); - - this.validate(); - } - - validate(): void { - this.licenses = this.licenses.map((item) => { - const { license } = item; - - if (license.url) { - if (!this.url) { - return item; - } - if (!this._validateURL(license.url, this.url)) { - this.invalidate(item); - console.error(`#### License error: invalid url, licensed to ${license.url}, used on ${this.url}`); - this._invalidModules(license.modules); - return item; - } - } - - if (license.expiry && this._validateExpiration(license.expiry)) { - this.invalidate(item); - console.error(`#### License error: expired, valid until ${license.expiry}`); - this._invalidModules(license.modules); - return item; - } - - if (license.maxGuestUsers > maxGuestUsers) { - maxGuestUsers = license.maxGuestUsers; - } - - if (license.maxRoomsPerGuest > maxRoomsPerGuest) { - maxRoomsPerGuest = license.maxRoomsPerGuest; - } - - if (license.maxActiveUsers > maxActiveUsers) { - maxActiveUsers = license.maxActiveUsers; - } - - this._setAppsConfig(license); - - this._validModules(license.modules); - - this._addTags(license); - - console.log('#### License validated:', license.modules.join(', ')); - - item.valid = true; - return item; - }); - - EnterpriseLicenses.emit('validate'); - this.showLicenses(); - } - - invalidate(item: IValidLicense): void { - item.valid = false; - - EnterpriseLicenses.emit('invalidate'); - } - - async canAddNewUser(userCount = 1): Promise { - if (!maxActiveUsers) { - return true; - } - - return maxActiveUsers > (await Users.getActiveLocalUserCount()) + userCount; - } - - async canEnableApp(app: IAppStorageItem): Promise { - if (!(await Apps.isInitialized())) { - return false; - } - - // Migrated apps were installed before the validation was implemented - // so they're always allowed to be enabled - if (app.migrated) { - return true; - } - - return isUnderAppLimits(this.appsConfig, getInstallationSourceFromAppStorageItem(app)); - } - - showLicenses(): void { - if (!process.env.LICENSE_DEBUG || process.env.LICENSE_DEBUG === 'false') { - return; - } - - this.licenses - .filter((item) => item.valid) - .forEach((item) => { - const { license } = item; - - console.log('---- License enabled ----'); - console.log(' url ->', license.url); - console.log(' expiry ->', license.expiry); - console.log(' maxActiveUsers ->', license.maxActiveUsers); - console.log(' maxGuestUsers ->', license.maxGuestUsers); - console.log(' maxRoomsPerGuest ->', license.maxRoomsPerGuest); - console.log(' modules ->', license.modules.join(', ')); - console.log('-------------------------'); - }); - } -} - -const License = new LicenseClass(); - -export function addLicense(encryptedLicense: string): boolean { - if (!encryptedLicense || String(encryptedLicense).trim() === '' || License.isLicenseDuplicate(encryptedLicense)) { - return false; - } - - console.log('### New Enterprise License'); - - try { - const decrypted = decrypt(encryptedLicense); - if (!decrypted) { - return false; - } - - if (process.env.LICENSE_DEBUG && process.env.LICENSE_DEBUG !== 'false') { - console.log('##### Raw license ->', decrypted); - } - - License.addLicense(JSON.parse(decrypted)); - License.lockLicense(encryptedLicense); - - return true; - } catch (e) { - console.error('##### Invalid license'); - if (process.env.LICENSE_DEBUG && process.env.LICENSE_DEBUG !== 'false') { - console.error('##### Invalid raw license ->', encryptedLicense, e); - } - return false; - } -} - -export function validateFormat(encryptedLicense: string): boolean { - if (!encryptedLicense || String(encryptedLicense).trim() === '') { - return false; - } - - const decrypted = decrypt(encryptedLicense); - if (!decrypted) { - return false; - } - - return true; -} - -export function setURL(url: string): void { - License.setURL(url); -} - -export function hasLicense(feature: string): boolean { - return License.hasModule(feature); -} - -export function isEnterprise(): boolean { - return License.hasAnyValidLicense(); -} - -export function getMaxGuestUsers(): number { - return maxGuestUsers; -} - -export function getMaxRoomsPerGuest(): number { - return maxRoomsPerGuest; -} - -export function getMaxActiveUsers(): number { - return maxActiveUsers; -} - -export function getLicenses(): IValidLicense[] { - return License.getLicenses(); -} - -export function getModules(): string[] { - return License.getModules(); -} - -export function getTags(): ILicenseTag[] { - return License.getTags(); -} - -export function getAppsConfig(): NonNullable { - return License.getAppsConfig(); -} - -export async function canAddNewUser(userCount = 1): Promise { - return License.canAddNewUser(userCount); -} - -export async function canEnableApp(app: IAppStorageItem): Promise { - return License.canEnableApp(app); -} - -export function onLicense(feature: BundleFeature, cb: (...args: any[]) => void): void | Promise { - if (hasLicense(feature)) { - return cb(); - } - - EnterpriseLicenses.once(`valid:${feature}`, cb); -} - -function onValidFeature(feature: BundleFeature, cb: () => void): () => void { - EnterpriseLicenses.on(`valid:${feature}`, cb); - - if (hasLicense(feature)) { - cb(); - } - - return (): void => { - EnterpriseLicenses.off(`valid:${feature}`, cb); - }; -} - -function onInvalidFeature(feature: BundleFeature, cb: () => void): () => void { - EnterpriseLicenses.on(`invalid:${feature}`, cb); - - if (!hasLicense(feature)) { - cb(); - } - - return (): void => { - EnterpriseLicenses.off(`invalid:${feature}`, cb); - }; -} - -export function onToggledFeature( - feature: BundleFeature, - { - up, - down, - }: { - up?: () => Promise | void; - down?: () => Promise | void; - }, -): () => void { - let enabled = hasLicense(feature); - - const offValidFeature = onValidFeature(feature, () => { - if (!enabled) { - void up?.(); - enabled = true; - } - }); - - const offInvalidFeature = onInvalidFeature(feature, () => { - if (enabled) { - void down?.(); - enabled = false; - } - }); - - if (enabled) { - void up?.(); - } - - return (): void => { - offValidFeature(); - offInvalidFeature(); - }; -} - -export function onModule(cb: (...args: any[]) => void): void { - EnterpriseLicenses.on('module', cb); -} - -export function onValidateLicenses(cb: (...args: any[]) => void): void { - EnterpriseLicenses.on('validate', cb); -} - -export function onInvalidateLicense(cb: (...args: any[]) => void): void { - EnterpriseLicenses.on('invalidate', cb); -} - -export function flatModules(modulesAndBundles: string[]): string[] { - const bundles = modulesAndBundles.filter(isBundle); - const modules = modulesAndBundles.filter((x) => !isBundle(x)); - - const modulesFromBundles = bundles.map(getBundleModules).flat(); - - return modules.concat(modulesFromBundles); -} - -interface IOverrideClassProperties { - [key: string]: (...args: any[]) => any; -} - -type Class = { new (...args: any[]): any }; - -export async function overwriteClassOnLicense(license: BundleFeature, original: Class, overwrite: IOverrideClassProperties): Promise { - await onLicense(license, () => { - Object.entries(overwrite).forEach(([key, value]) => { - const originalFn = original.prototype[key]; - original.prototype[key] = function (...args: any[]): any { - return value.call(this, originalFn, ...args); - }; - }); - }); -} diff --git a/apps/meteor/ee/app/license/server/methods.ts b/apps/meteor/ee/app/license/server/methods.ts index 96978fad6d9a..39d14326a79a 100644 --- a/apps/meteor/ee/app/license/server/methods.ts +++ b/apps/meteor/ee/app/license/server/methods.ts @@ -1,10 +1,8 @@ +import { License, type ILicenseTag, type LicenseModule } from '@rocket.chat/license'; import type { ServerMethods } from '@rocket.chat/ui-contexts'; import { check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; -import type { ILicenseTag } from '../definition/ILicenseTag'; -import { getModules, getTags, hasLicense, isEnterprise } from './license'; - declare module '@rocket.chat/ui-contexts' { // eslint-disable-next-line @typescript-eslint/naming-convention interface ServerMethods { @@ -19,15 +17,15 @@ Meteor.methods({ 'license:hasLicense'(feature: string) { check(feature, String); - return hasLicense(feature); + return License.hasModule(feature as LicenseModule); }, 'license:getModules'() { - return getModules(); + return License.getModules(); }, 'license:getTags'() { - return getTags(); + return License.getTags(); }, 'license:isEnterprise'() { - return isEnterprise(); + return License.hasValidLicense(); }, }); diff --git a/apps/meteor/ee/app/license/server/settings.ts b/apps/meteor/ee/app/license/server/settings.ts index a5a07ba0200f..1bec7126ae85 100644 --- a/apps/meteor/ee/app/license/server/settings.ts +++ b/apps/meteor/ee/app/license/server/settings.ts @@ -1,8 +1,8 @@ +import { License } from '@rocket.chat/license'; import { Settings } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; import { settings, settingsRegistry } from '../../../../app/settings/server'; -import { addLicense } from './license'; Meteor.startup(async () => { await settingsRegistry.addGroup('Enterprise', async function () { @@ -29,16 +29,24 @@ settings.watch('Enterprise_License', async (license) => { return; } - if (!addLicense(license)) { - await Settings.updateValueById('Enterprise_License_Status', 'Invalid'); - return; + try { + if (!(await License.setLicense(license))) { + await Settings.updateValueById('Enterprise_License_Status', 'Invalid'); + return; + } + } catch (_error) { + // do nothing } await Settings.updateValueById('Enterprise_License_Status', 'Valid'); }); if (process.env.ROCKETCHAT_LICENSE) { - addLicense(process.env.ROCKETCHAT_LICENSE); + try { + await License.setLicense(process.env.ROCKETCHAT_LICENSE); + } catch (_error) { + // do nothing + } Meteor.startup(async () => { if (settings.get('Enterprise_License')) { diff --git a/apps/meteor/ee/app/license/server/startup.ts b/apps/meteor/ee/app/license/server/startup.ts index 4a7a0776fc0d..d3523282d1e8 100644 --- a/apps/meteor/ee/app/license/server/startup.ts +++ b/apps/meteor/ee/app/license/server/startup.ts @@ -1,13 +1,28 @@ +import { License } from '@rocket.chat/license'; +import { Subscriptions, Users } from '@rocket.chat/models'; + import { settings } from '../../../../app/settings/server'; import { callbacks } from '../../../../lib/callbacks'; -import { addLicense, setURL } from './license'; +import { getAppCount } from './lib/getAppCount'; settings.watch('Site_Url', (value) => { if (value) { - setURL(value); + void License.setWorkspaceUrl(value); } }); -callbacks.add('workspaceLicenseChanged', (updatedLicense) => { - addLicense(updatedLicense); +callbacks.add('workspaceLicenseChanged', async (updatedLicense) => { + try { + await License.setLicense(updatedLicense); + } catch (_error) { + // Ignore + } }); + +License.setLicenseLimitCounter('activeUsers', () => Users.getActiveLocalUserCount()); +License.setLicenseLimitCounter('guestUsers', () => Users.getActiveLocalGuestCount()); +License.setLicenseLimitCounter('roomsPerGuest', async (context) => (context?.userId ? Subscriptions.countByUserId(context.userId) : 0)); +License.setLicenseLimitCounter('privateApps', () => getAppCount('private')); +License.setLicenseLimitCounter('marketplaceApps', () => getAppCount('marketplace')); +// #TODO: Get real value +License.setLicenseLimitCounter('monthlyActiveContacts', async () => 0); diff --git a/apps/meteor/ee/app/livechat-enterprise/server/business-hour/Helper.ts b/apps/meteor/ee/app/livechat-enterprise/server/business-hour/Helper.ts index 5839b717349d..a441e122ef99 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/business-hour/Helper.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/business-hour/Helper.ts @@ -1,10 +1,10 @@ import type { ILivechatBusinessHour } from '@rocket.chat/core-typings'; import { LivechatBusinessHourTypes } from '@rocket.chat/core-typings'; +import { License } from '@rocket.chat/license'; import { LivechatBusinessHours, LivechatDepartment, LivechatDepartmentAgents, Users } from '@rocket.chat/models'; import moment from 'moment-timezone'; import { businessHourLogger } from '../../../../../app/livechat/server/lib/logger'; -import { isEnterprise } from '../../../license/server/license'; const getAllAgentIdsWithoutDepartment = async (): Promise => { // Fetch departments with agents excluding archived ones (disabled ones still can be tied to business hours) @@ -105,7 +105,7 @@ export const removeBusinessHourByAgentIds = async (agentIds: string[], businessH }; export const resetDefaultBusinessHourIfNeeded = async (): Promise => { - if (isEnterprise()) { + if (License.hasValidLicense()) { return; } diff --git a/apps/meteor/ee/app/livechat-enterprise/server/index.ts b/apps/meteor/ee/app/livechat-enterprise/server/index.ts index 13ebdd6a3521..13676e7cbedb 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/index.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/index.ts @@ -1,3 +1,4 @@ +import { License } from '@rocket.chat/license'; import { Meteor } from 'meteor/meteor'; import './methods/addMonitor'; @@ -25,11 +26,10 @@ import './hooks/onTransferFailure'; import './lib/routing/LoadBalancing'; import './lib/routing/LoadRotation'; import './lib/AutoCloseOnHoldScheduler'; -import { onLicense } from '../../license/server'; import './business-hour'; import { createDefaultPriorities } from './priorities'; -await onLicense('livechat-enterprise', async () => { +await License.onLicense('livechat-enterprise', async () => { require('./api'); require('./hooks'); await import('./startup'); diff --git a/apps/meteor/ee/app/livechat-enterprise/server/lib/LivechatEnterprise.ts b/apps/meteor/ee/app/livechat-enterprise/server/lib/LivechatEnterprise.ts index 83a2963a54d8..ec228e420abd 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/lib/LivechatEnterprise.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/lib/LivechatEnterprise.ts @@ -1,4 +1,5 @@ import type { IOmnichannelBusinessUnit, IOmnichannelServiceLevelAgreements, LivechatDepartmentDTO } from '@rocket.chat/core-typings'; +import { License } from '@rocket.chat/license'; import { Users, LivechatDepartment as LivechatDepartmentRaw, @@ -14,7 +15,6 @@ import { updateDepartmentAgents } from '../../../../../app/livechat/server/lib/H import { callbacks } from '../../../../../lib/callbacks'; import { addUserRolesAsync } from '../../../../../server/lib/roles/addUserRoles'; import { removeUserFromRolesAsync } from '../../../../../server/lib/roles/removeUserFromRoles'; -import { hasLicense } from '../../../license/server/license'; import { updateSLAInquiries } from './Helper'; import { removeSLAFromRooms } from './SlaHelper'; @@ -195,7 +195,7 @@ export const LivechatEnterprise = { const department = _id ? await LivechatDepartmentRaw.findOneById(_id, { projection: { _id: 1, archived: 1, enabled: 1 } }) : null; - if (!hasLicense('livechat-enterprise')) { + if (!License.hasModule('livechat-enterprise')) { const totalDepartments = await LivechatDepartmentRaw.countTotal(); if (!department && totalDepartments >= 1) { throw new Meteor.Error('error-max-departments-number-reached', 'Maximum number of departments reached', { @@ -279,6 +279,6 @@ export const LivechatEnterprise = { }, async isDepartmentCreationAvailable() { - return hasLicense('livechat-enterprise') || (await LivechatDepartmentRaw.countTotal()) === 0; + return License.hasModule('livechat-enterprise') || (await LivechatDepartmentRaw.countTotal()) === 0; }, }; diff --git a/apps/meteor/ee/app/message-read-receipt/server/index.ts b/apps/meteor/ee/app/message-read-receipt/server/index.ts index a7682e4165f0..bb405c0eaffd 100644 --- a/apps/meteor/ee/app/message-read-receipt/server/index.ts +++ b/apps/meteor/ee/app/message-read-receipt/server/index.ts @@ -1,5 +1,5 @@ -import { onLicense } from '../../license/server'; +import { License } from '@rocket.chat/license'; -await onLicense('message-read-receipt', async () => { +await License.onLicense('message-read-receipt', async () => { await import('./hooks'); }); diff --git a/apps/meteor/ee/app/settings/server/settings.ts b/apps/meteor/ee/app/settings/server/settings.ts index afb5a4378ec8..76ce7c15155a 100644 --- a/apps/meteor/ee/app/settings/server/settings.ts +++ b/apps/meteor/ee/app/settings/server/settings.ts @@ -1,17 +1,17 @@ import type { ISetting, SettingValue } from '@rocket.chat/core-typings'; +import { License, type LicenseModule } from '@rocket.chat/license'; import { Settings } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; import { settings, SettingsEvents } from '../../../../app/settings/server'; import { use } from '../../../../app/settings/server/Middleware'; -import { isEnterprise, hasLicense, onValidateLicenses } from '../../license/server/license'; export function changeSettingValue(record: ISetting): SettingValue { if (!record.enterprise) { return record.value; } - if (!isEnterprise()) { + if (!License.hasValidLicense()) { return record.invalidValue; } @@ -20,7 +20,7 @@ export function changeSettingValue(record: ISetting): SettingValue { } for (const moduleName of record.modules) { - if (!hasLicense(moduleName)) { + if (!License.hasModule(moduleName as LicenseModule)) { return record.invalidValue; } } @@ -58,5 +58,5 @@ async function updateSettings(): Promise { Meteor.startup(async () => { await updateSettings(); - onValidateLicenses(updateSettings); + License.onValidateLicense(updateSettings); }); diff --git a/apps/meteor/ee/app/voip-enterprise/server/services/voipService.ts b/apps/meteor/ee/app/voip-enterprise/server/services/voipService.ts index a28e459e57fb..f5524ee026dc 100644 --- a/apps/meteor/ee/app/voip-enterprise/server/services/voipService.ts +++ b/apps/meteor/ee/app/voip-enterprise/server/services/voipService.ts @@ -1,11 +1,11 @@ import type { ILivechatAgent, ILivechatVisitor, IVoipRoomClosingInfo, IUser, IVoipRoom } from '@rocket.chat/core-typings'; +import { License } from '@rocket.chat/license'; import type { IOmniRoomClosingMessage } from '../../../../../server/services/omnichannel-voip/internalTypes'; import { OmnichannelVoipService } from '../../../../../server/services/omnichannel-voip/service'; -import { overwriteClassOnLicense } from '../../../license/server'; import { calculateOnHoldTimeForRoom } from '../lib/calculateOnHoldTimeForRoom'; -await overwriteClassOnLicense('voip-enterprise', OmnichannelVoipService, { +await License.overwriteClassOnLicense('voip-enterprise', OmnichannelVoipService, { async getRoomClosingData( _originalFn: ( closer: ILivechatVisitor | ILivechatAgent, diff --git a/apps/meteor/ee/client/hooks/useHasLicenseModule.ts b/apps/meteor/ee/client/hooks/useHasLicenseModule.ts index a1492d39a013..c7d76b093c3b 100644 --- a/apps/meteor/ee/client/hooks/useHasLicenseModule.ts +++ b/apps/meteor/ee/client/hooks/useHasLicenseModule.ts @@ -1,9 +1,8 @@ +import type { LicenseModule } from '@rocket.chat/license'; import { useMethod, useUserId } from '@rocket.chat/ui-contexts'; import { useQuery } from '@tanstack/react-query'; -import type { BundleFeature } from '../../app/license/server/bundles'; - -export const useHasLicenseModule = (licenseName: BundleFeature): 'loading' | boolean => { +export const useHasLicenseModule = (licenseName: LicenseModule): 'loading' | boolean => { const method = useMethod('license:getModules'); const uid = useUserId(); diff --git a/apps/meteor/ee/client/lib/onToggledFeature.ts b/apps/meteor/ee/client/lib/onToggledFeature.ts index 86ab08723745..ae2e4ad9f4a8 100644 --- a/apps/meteor/ee/client/lib/onToggledFeature.ts +++ b/apps/meteor/ee/client/lib/onToggledFeature.ts @@ -1,11 +1,11 @@ +import type { LicenseModule } from '@rocket.chat/license'; import { QueryObserver } from '@tanstack/react-query'; import { queryClient } from '../../../client/lib/queryClient'; -import type { BundleFeature } from '../../app/license/server/bundles'; import { fetchFeatures } from './fetchFeatures'; export const onToggledFeature = ( - feature: BundleFeature, + feature: LicenseModule, { up, down, diff --git a/apps/meteor/ee/client/views/admin/users/useSeatsCap.ts b/apps/meteor/ee/client/views/admin/users/useSeatsCap.ts index eb029d91f537..b4a45b49dda5 100644 --- a/apps/meteor/ee/client/views/admin/users/useSeatsCap.ts +++ b/apps/meteor/ee/client/views/admin/users/useSeatsCap.ts @@ -8,6 +8,7 @@ export type SeatCapProps = { }; export const useSeatsCap = (): SeatCapProps | undefined => { + // #TODO: Stop using this endpoint const fetch = useEndpoint('GET', '/v1/licenses.maxActiveUsers'); const result = useQuery(['/v1/licenses.maxActiveUsers'], () => fetch()); diff --git a/apps/meteor/ee/server/api/api.ts b/apps/meteor/ee/server/api/api.ts index f152a94ebcbf..ee2049bb70ae 100644 --- a/apps/meteor/ee/server/api/api.ts +++ b/apps/meteor/ee/server/api/api.ts @@ -1,7 +1,8 @@ +import { License } from '@rocket.chat/license'; + import { API } from '../../../app/api/server/api'; import type { NonEnterpriseTwoFactorOptions, Options } from '../../../app/api/server/definition'; import { use } from '../../../app/settings/server/Middleware'; -import { isEnterprise } from '../../app/license/server/license'; // Overwrites two factor method to enforce 2FA check for enterprise APIs when // no license was provided to prevent abuse on enterprise APIs. @@ -10,7 +11,7 @@ const isNonEnterpriseTwoFactorOptions = (options?: Options): options is NonEnter !!options && 'forceTwoFactorAuthenticationForNonEnterprise' in options && Boolean(options.forceTwoFactorAuthenticationForNonEnterprise); API.v1.processTwoFactor = use(API.v1.processTwoFactor, ([params, ...context], next) => { - if (isNonEnterpriseTwoFactorOptions(params.options) && !isEnterprise()) { + if (isNonEnterpriseTwoFactorOptions(params.options) && !License.hasValidLicense()) { const options: NonEnterpriseTwoFactorOptions = { ...params.options, twoFactorOptions: { diff --git a/apps/meteor/ee/server/api/chat.ts b/apps/meteor/ee/server/api/chat.ts index 5d21b20f2038..2c8f8c5ca605 100644 --- a/apps/meteor/ee/server/api/chat.ts +++ b/apps/meteor/ee/server/api/chat.ts @@ -1,8 +1,8 @@ import type { IMessage, ReadReceipt } from '@rocket.chat/core-typings'; +import { License } from '@rocket.chat/license'; import { Meteor } from 'meteor/meteor'; import { API } from '../../../app/api/server/api'; -import { hasLicense } from '../../app/license/server/license'; type GetMessageReadReceiptsProps = { messageId: IMessage['_id']; @@ -24,7 +24,7 @@ API.v1.addRoute( { authRequired: true }, { async get() { - if (!hasLicense('message-read-receipt')) { + if (!License.hasModule('message-read-receipt')) { throw new Meteor.Error('error-action-not-allowed', 'This is an enterprise feature'); } diff --git a/apps/meteor/ee/server/api/licenses.ts b/apps/meteor/ee/server/api/licenses.ts index ab8d72164a97..cfd657a1f0e9 100644 --- a/apps/meteor/ee/server/api/licenses.ts +++ b/apps/meteor/ee/server/api/licenses.ts @@ -1,17 +1,9 @@ +import { License } from '@rocket.chat/license'; import { Settings, Users } from '@rocket.chat/models'; import { check } from 'meteor/check'; import { API } from '../../../app/api/server/api'; import { hasPermissionAsync } from '../../../app/authorization/server/functions/hasPermission'; -import type { ILicense } from '../../app/license/definition/ILicense'; -import { getLicenses, validateFormat, flatModules, getMaxActiveUsers, isEnterprise } from '../../app/license/server/license'; - -function licenseTransform(license: ILicense): ILicense { - return { - ...license, - modules: flatModules(license.modules), - }; -} API.v1.addRoute( 'licenses.get', @@ -22,9 +14,8 @@ API.v1.addRoute( return API.v1.unauthorized(); } - const licenses = getLicenses() - .filter(({ valid }) => valid) - .map(({ license }) => licenseTransform(license)); + const license = License.getUnmodifiedLicenseAndModules(); + const licenses = license ? [license] : []; return API.v1.success({ licenses }); }, @@ -45,7 +36,7 @@ API.v1.addRoute( } const { license } = this.bodyParams; - if (!validateFormat(license)) { + if (!(await License.validateFormat(license))) { return API.v1.failure('Invalid license'); } @@ -61,7 +52,7 @@ API.v1.addRoute( { authRequired: true }, { async get() { - const maxActiveUsers = getMaxActiveUsers() || null; + const maxActiveUsers = License.getMaxActiveUsers() || null; const activeUsers = await Users.getActiveLocalUserCount(); return API.v1.success({ maxActiveUsers, activeUsers }); @@ -74,7 +65,7 @@ API.v1.addRoute( { authOrAnonRequired: true }, { get() { - const isEnterpriseEdtion = isEnterprise(); + const isEnterpriseEdtion = License.hasValidLicense(); return API.v1.success({ isEnterprise: isEnterpriseEdtion }); }, }, diff --git a/apps/meteor/ee/server/api/roles.ts b/apps/meteor/ee/server/api/roles.ts index 712e7583b709..c10c32c3ee1a 100644 --- a/apps/meteor/ee/server/api/roles.ts +++ b/apps/meteor/ee/server/api/roles.ts @@ -1,11 +1,11 @@ import type { IRole } from '@rocket.chat/core-typings'; +import { License } from '@rocket.chat/license'; import { Roles } from '@rocket.chat/models'; import Ajv from 'ajv'; import { API } from '../../../app/api/server/api'; import { hasPermissionAsync } from '../../../app/authorization/server/functions/hasPermission'; import { settings } from '../../../app/settings/server/index'; -import { isEnterprise } from '../../app/license/server'; import { insertRoleAsync } from '../lib/roles/insertRole'; import { updateRole } from '../lib/roles/updateRole'; @@ -96,7 +96,7 @@ API.v1.addRoute( { authRequired: true }, { async post() { - if (!isEnterprise()) { + if (!License.hasValidLicense()) { throw new Meteor.Error('error-action-not-allowed', 'This is an enterprise feature'); } @@ -154,7 +154,7 @@ API.v1.addRoute( const role = await Roles.findOne(roleId); - if (!isEnterprise() && !role?.protected) { + if (!License.hasValidLicense() && !role?.protected) { throw new Meteor.Error('error-action-not-allowed', 'This is an enterprise feature'); } diff --git a/apps/meteor/ee/server/api/sessions.ts b/apps/meteor/ee/server/api/sessions.ts index 41c30aba401b..cdd454fd5bee 100644 --- a/apps/meteor/ee/server/api/sessions.ts +++ b/apps/meteor/ee/server/api/sessions.ts @@ -1,4 +1,5 @@ import type { IUser, ISession, DeviceManagementSession, DeviceManagementPopulatedSession } from '@rocket.chat/core-typings'; +import { License } from '@rocket.chat/license'; import { Users, Sessions } from '@rocket.chat/models'; import type { PaginatedResult, PaginatedRequest } from '@rocket.chat/rest-typings'; import { escapeRegExp } from '@rocket.chat/string-helpers'; @@ -7,7 +8,6 @@ import Ajv from 'ajv'; import { API } from '../../../app/api/server/api'; import { getPaginationItems } from '../../../app/api/server/helpers/getPaginationItems'; import { Notifications } from '../../../app/notifications/server'; -import { hasLicense } from '../../app/license/server/license'; const ajv = new Ajv({ coerceTypes: true }); @@ -85,7 +85,7 @@ API.v1.addRoute( { authRequired: true, validateParams: isSessionsPaginateProps }, { async get() { - if (!hasLicense('device-management')) { + if (!License.hasModule('device-management')) { return API.v1.unauthorized(); } @@ -108,7 +108,7 @@ API.v1.addRoute( { authRequired: true, validateParams: isSessionsProps }, { async get() { - if (!hasLicense('device-management')) { + if (!License.hasModule('device-management')) { return API.v1.unauthorized(); } @@ -127,7 +127,7 @@ API.v1.addRoute( { authRequired: true, validateParams: isSessionsProps }, { async post() { - if (!hasLicense('device-management')) { + if (!License.hasModule('device-management')) { return API.v1.unauthorized(); } @@ -153,7 +153,7 @@ API.v1.addRoute( { authRequired: true, twoFactorRequired: true, validateParams: isSessionsPaginateProps, permissionsRequired: ['view-device-management'] }, { async get() { - if (!hasLicense('device-management')) { + if (!License.hasModule('device-management')) { return API.v1.unauthorized(); } @@ -193,7 +193,7 @@ API.v1.addRoute( { authRequired: true, twoFactorRequired: true, validateParams: isSessionsProps, permissionsRequired: ['view-device-management'] }, { async get() { - if (!hasLicense('device-management')) { + if (!License.hasModule('device-management')) { return API.v1.unauthorized(); } @@ -212,7 +212,7 @@ API.v1.addRoute( { authRequired: true, twoFactorRequired: true, validateParams: isSessionsProps, permissionsRequired: ['logout-device-management'] }, { async post() { - if (!hasLicense('device-management')) { + if (!License.hasModule('device-management')) { return API.v1.unauthorized(); } diff --git a/apps/meteor/ee/server/apps/communication/endpoints/appsCountHandler.ts b/apps/meteor/ee/server/apps/communication/endpoints/appsCountHandler.ts index 96247e704545..fc436b8229cf 100644 --- a/apps/meteor/ee/server/apps/communication/endpoints/appsCountHandler.ts +++ b/apps/meteor/ee/server/apps/communication/endpoints/appsCountHandler.ts @@ -1,9 +1,9 @@ import type { AppManager } from '@rocket.chat/apps-engine/server/AppManager'; +import { License } from '@rocket.chat/license'; import { API } from '../../../../../app/api/server'; import type { SuccessResult } from '../../../../../app/api/server/definition'; import { getInstallationSourceFromAppStorageItem } from '../../../../../lib/apps/getInstallationSourceFromAppStorageItem'; -import { getAppsConfig } from '../../../../app/license/server/license'; import type { AppsRestApi } from '../rest'; type AppsCountResult = { @@ -23,7 +23,7 @@ export const appsCountHandler = (apiManager: AppsRestApi) => const manager = apiManager._manager as AppManager; const apps = manager.get({ enabled: true }); - const { maxMarketplaceApps, maxPrivateApps } = getAppsConfig(); + const { maxMarketplaceApps, maxPrivateApps } = License.getAppsConfig(); return API.v1.success({ totalMarketplaceEnabled: apps.filter((app) => getInstallationSourceFromAppStorageItem(app.getStorageItem()) === 'marketplace') diff --git a/apps/meteor/ee/server/apps/communication/rest.ts b/apps/meteor/ee/server/apps/communication/rest.ts index 1203d0d8c911..f356f3e45a18 100644 --- a/apps/meteor/ee/server/apps/communication/rest.ts +++ b/apps/meteor/ee/server/apps/communication/rest.ts @@ -3,6 +3,7 @@ import type { IAppInfo } from '@rocket.chat/apps-engine/definition/metadata'; import type { AppManager } from '@rocket.chat/apps-engine/server/AppManager'; import { AppInstallationSource } from '@rocket.chat/apps-engine/server/storage'; import type { IUser, IMessage } from '@rocket.chat/core-typings'; +import { License } from '@rocket.chat/license'; import { Settings, Users } from '@rocket.chat/models'; import { serverFetch as fetch } from '@rocket.chat/server-fetch'; import { Meteor } from 'meteor/meteor'; @@ -17,7 +18,7 @@ import { settings } from '../../../../app/settings/server'; import { Info } from '../../../../app/utils/rocketchat.info'; import { i18n } from '../../../../server/lib/i18n'; import { sendMessagesToAdmins } from '../../../../server/lib/sendMessagesToAdmins'; -import { canEnableApp, isEnterprise } from '../../../app/license/server/license'; +import { canEnableApp } from '../../../app/license/server/canEnableApp'; import { formatAppInstanceForRest } from '../../../lib/misc/formatAppInstanceForRest'; import { appEnableCheck } from '../marketplace/appEnableCheck'; import { notifyAppInstall } from '../marketplace/appInstall'; @@ -1149,7 +1150,7 @@ export class AppsRestApi { const storedApp = prl.getStorageItem(); const { installationSource, marketplaceInfo } = storedApp; - if (!isEnterprise() && installationSource === AppInstallationSource.MARKETPLACE) { + if (!License.hasValidLicense() && installationSource === AppInstallationSource.MARKETPLACE) { try { const baseUrl = orchestrator.getMarketplaceUrl() as string; const headers = getDefaultHeaders(); diff --git a/apps/meteor/ee/server/apps/orchestrator.js b/apps/meteor/ee/server/apps/orchestrator.js index c21508cbc626..9e4d6f00e7f0 100644 --- a/apps/meteor/ee/server/apps/orchestrator.js +++ b/apps/meteor/ee/server/apps/orchestrator.js @@ -19,7 +19,7 @@ import { } from '../../../app/apps/server/converters'; import { AppThreadsConverter } from '../../../app/apps/server/converters/threads'; import { settings, settingsRegistry } from '../../../app/settings/server'; -import { canEnableApp } from '../../app/license/server/license'; +import { canEnableApp } from '../../app/license/server/canEnableApp'; import { AppServerNotifier, AppsRestApi, AppUIKitInteractionApi } from './communication'; import { AppRealLogsStorage, AppRealStorage, ConfigurableAppSourceStorage } from './storage'; diff --git a/apps/meteor/ee/server/configuration/ldap.ts b/apps/meteor/ee/server/configuration/ldap.ts index 40815e213b0c..5f1a84557d70 100644 --- a/apps/meteor/ee/server/configuration/ldap.ts +++ b/apps/meteor/ee/server/configuration/ldap.ts @@ -1,18 +1,18 @@ import type { IImportUser, ILDAPEntry, IUser } from '@rocket.chat/core-typings'; import { cronJobs } from '@rocket.chat/cron'; +import { License } from '@rocket.chat/license'; import { Meteor } from 'meteor/meteor'; import { settings } from '../../../app/settings/server'; import { callbacks } from '../../../lib/callbacks'; import type { LDAPConnection } from '../../../server/lib/ldap/Connection'; import { logger } from '../../../server/lib/ldap/Logger'; -import { onLicense } from '../../app/license/server'; import { LDAPEEManager } from '../lib/ldap/Manager'; import { LDAPEE } from '../sdk'; import { addSettings, ldapIntervalValuesToCronMap } from '../settings/ldap'; Meteor.startup(async () => { - await onLicense('ldap-enterprise', async () => { + await License.onLicense('ldap-enterprise', async () => { await addSettings(); // Configure background sync cronjob diff --git a/apps/meteor/ee/server/configuration/oauth.ts b/apps/meteor/ee/server/configuration/oauth.ts index 984670af6003..aa66a46caf69 100644 --- a/apps/meteor/ee/server/configuration/oauth.ts +++ b/apps/meteor/ee/server/configuration/oauth.ts @@ -1,11 +1,11 @@ import type { IUser } from '@rocket.chat/core-typings'; +import { License } from '@rocket.chat/license'; import { Logger } from '@rocket.chat/logger'; import { Roles } from '@rocket.chat/models'; import { capitalize } from '@rocket.chat/string-helpers'; import { settings } from '../../../app/settings/server'; import { callbacks } from '../../../lib/callbacks'; -import { onLicense } from '../../app/license/server'; import { OAuthEEManager } from '../lib/oauth/Manager'; interface IOAuthUserService { @@ -54,7 +54,7 @@ function getChannelsMap(channelsMap: string): Record | undefined { } } -await onLicense('oauth-enterprise', () => { +await License.onLicense('oauth-enterprise', () => { callbacks.add('afterProcessOAuthUser', async (auth: IOAuthUserService) => { auth.serviceName = capitalize(auth.serviceName); const settings = getOAuthSettings(auth.serviceName); diff --git a/apps/meteor/ee/server/configuration/outlookCalendar.ts b/apps/meteor/ee/server/configuration/outlookCalendar.ts index cf36ddeb0cab..67c8d7945030 100644 --- a/apps/meteor/ee/server/configuration/outlookCalendar.ts +++ b/apps/meteor/ee/server/configuration/outlookCalendar.ts @@ -1,11 +1,11 @@ import { Calendar } from '@rocket.chat/core-services'; +import { License } from '@rocket.chat/license'; import { Meteor } from 'meteor/meteor'; -import { onLicense } from '../../app/license/server'; import { addSettings } from '../settings/outlookCalendar'; Meteor.startup(() => - onLicense('outlook-calendar', async () => { + License.onLicense('outlook-calendar', async () => { addSettings(); await Calendar.setupNextNotification(); diff --git a/apps/meteor/ee/server/configuration/saml.ts b/apps/meteor/ee/server/configuration/saml.ts index 1e50fc7160b5..96dca07829c6 100644 --- a/apps/meteor/ee/server/configuration/saml.ts +++ b/apps/meteor/ee/server/configuration/saml.ts @@ -1,13 +1,13 @@ +import { License } from '@rocket.chat/license'; import { Roles, Users } from '@rocket.chat/models'; import type { ISAMLUser } from '../../../app/meteor-accounts-saml/server/definition/ISAMLUser'; import { SAMLUtils } from '../../../app/meteor-accounts-saml/server/lib/Utils'; import { settings } from '../../../app/settings/server'; import { ensureArray } from '../../../lib/utils/arrayUtils'; -import { onLicense } from '../../app/license/server'; import { addSettings } from '../settings/saml'; -await onLicense('saml-enterprise', () => { +await License.onLicense('saml-enterprise', () => { SAMLUtils.events.on('mapUser', async ({ profile, userObject }: { profile: Record; userObject: ISAMLUser }) => { const roleAttributeName = settings.get('SAML_Custom_Default_role_attribute_name') as string; const roleAttributeSync = settings.get('SAML_Custom_Default_role_attribute_sync'); @@ -67,4 +67,4 @@ await onLicense('saml-enterprise', () => { }); // For setting creation we add the listener first because the event is emmited during startup -SAMLUtils.events.on('addSettings', (name: string): void | Promise => onLicense('saml-enterprise', () => addSettings(name))); +SAMLUtils.events.on('addSettings', (name: string): void | Promise => License.onLicense('saml-enterprise', () => addSettings(name))); diff --git a/apps/meteor/ee/server/configuration/videoConference.ts b/apps/meteor/ee/server/configuration/videoConference.ts index a9debed01b19..035110904840 100644 --- a/apps/meteor/ee/server/configuration/videoConference.ts +++ b/apps/meteor/ee/server/configuration/videoConference.ts @@ -1,16 +1,16 @@ import { VideoConf } from '@rocket.chat/core-services'; import type { IRoom, IUser, VideoConference } from '@rocket.chat/core-typings'; import { VideoConferenceStatus } from '@rocket.chat/core-typings'; +import { License } from '@rocket.chat/license'; import { Rooms, Subscriptions } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; import { callbacks } from '../../../lib/callbacks'; import { videoConfTypes } from '../../../server/lib/videoConfTypes'; -import { onLicense } from '../../app/license/server'; import { addSettings } from '../settings/video-conference'; Meteor.startup(async () => { - await onLicense('videoconference-enterprise', async () => { + await License.onLicense('videoconference-enterprise', async () => { await addSettings(); videoConfTypes.registerVideoConferenceType( diff --git a/apps/meteor/ee/server/lib/EnterpriseCheck.ts b/apps/meteor/ee/server/lib/EnterpriseCheck.ts index 8bccfed59071..ca8cd1e25b10 100644 --- a/apps/meteor/ee/server/lib/EnterpriseCheck.ts +++ b/apps/meteor/ee/server/lib/EnterpriseCheck.ts @@ -41,7 +41,7 @@ export const EnterpriseCheck: ServiceSchema = { async started(): Promise { setInterval(async () => { try { - const hasLicense = await this.broker.call('license.hasLicense', ['scalability']); + const hasLicense = await this.broker.call('license.hasValidLicense', ['scalability']); if (hasLicense) { checkFails = 0; return; diff --git a/apps/meteor/ee/server/lib/syncUserRoles.ts b/apps/meteor/ee/server/lib/syncUserRoles.ts index e38f9de3c310..f3a380a8f228 100644 --- a/apps/meteor/ee/server/lib/syncUserRoles.ts +++ b/apps/meteor/ee/server/lib/syncUserRoles.ts @@ -1,11 +1,11 @@ import { api } from '@rocket.chat/core-services'; import type { IUser, IRole, AtLeast } from '@rocket.chat/core-typings'; +import { License } from '@rocket.chat/license'; import { Users } from '@rocket.chat/models'; import { settings } from '../../../app/settings/server'; import { addUserRolesAsync } from '../../../server/lib/roles/addUserRoles'; import { removeUserFromRolesAsync } from '../../../server/lib/roles/removeUserFromRoles'; -import { canAddNewUser } from '../../app/license/server/license'; type setUserRolesOptions = { // If specified, the function will not add nor remove any role that is not on this list. @@ -72,7 +72,7 @@ export async function syncUserRoles( } const wasGuest = existingRoles.length === 1 && existingRoles[0] === 'guest'; - if (wasGuest && !(await canAddNewUser())) { + if (wasGuest && (await License.shouldPreventAction('activeUsers'))) { throw new Error('error-license-user-limit-reached'); } diff --git a/apps/meteor/ee/server/local-services/instance/service.ts b/apps/meteor/ee/server/local-services/instance/service.ts index 85c021f74769..5bb755ee347f 100644 --- a/apps/meteor/ee/server/local-services/instance/service.ts +++ b/apps/meteor/ee/server/local-services/instance/service.ts @@ -143,7 +143,7 @@ export class InstanceService extends ServiceClassInternal implements IInstanceSe await InstanceStatus.registerInstance('rocket.chat', instance); - const hasLicense = await License.hasLicense('scalability'); + const hasLicense = await License.hasModule('scalability'); if (!hasLicense) { return; } diff --git a/apps/meteor/ee/server/methods/getReadReceipts.ts b/apps/meteor/ee/server/methods/getReadReceipts.ts index a30eec300c41..78fe8a4d967e 100644 --- a/apps/meteor/ee/server/methods/getReadReceipts.ts +++ b/apps/meteor/ee/server/methods/getReadReceipts.ts @@ -1,11 +1,11 @@ import type { ReadReceipt as ReadReceiptType, IMessage } from '@rocket.chat/core-typings'; +import { License } from '@rocket.chat/license'; import { Messages } from '@rocket.chat/models'; import type { ServerMethods } from '@rocket.chat/ui-contexts'; import { check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; import { canAccessRoomIdAsync } from '../../../app/authorization/server/functions/canAccessRoom'; -import { hasLicense } from '../../app/license/server/license'; import { ReadReceipt } from '../lib/message-read-receipt/ReadReceipt'; declare module '@rocket.chat/ui-contexts' { @@ -17,7 +17,7 @@ declare module '@rocket.chat/ui-contexts' { Meteor.methods({ async getReadReceipts({ messageId }) { - if (!hasLicense('message-read-receipt')) { + if (!License.hasModule('message-read-receipt')) { throw new Meteor.Error('error-action-not-allowed', 'This is an enterprise feature', { method: 'getReadReceipts' }); } diff --git a/apps/meteor/ee/server/models/startup.ts b/apps/meteor/ee/server/models/startup.ts index 580f4c025e07..4fd8433358ca 100644 --- a/apps/meteor/ee/server/models/startup.ts +++ b/apps/meteor/ee/server/models/startup.ts @@ -1,4 +1,4 @@ -import { onLicense } from '../../app/license/server/license'; +import { License } from '@rocket.chat/license'; // To facilitate our lives with the stream // Collection will be registered on CE too @@ -8,7 +8,7 @@ import('./OmnichannelServiceLevelAgreements'); import('./AuditLog'); import('./ReadReceipts'); -await onLicense('livechat-enterprise', () => { +await License.onLicense('livechat-enterprise', () => { import('./CannedResponse'); import('./LivechatTag'); import('./LivechatUnit'); diff --git a/apps/meteor/ee/server/startup/apps/trialExpiration.ts b/apps/meteor/ee/server/startup/apps/trialExpiration.ts index 1c214ba0a406..eec50e91b7dd 100644 --- a/apps/meteor/ee/server/startup/apps/trialExpiration.ts +++ b/apps/meteor/ee/server/startup/apps/trialExpiration.ts @@ -1,10 +1,10 @@ +import { License } from '@rocket.chat/license'; import { Meteor } from 'meteor/meteor'; -import { onInvalidateLicense } from '../../../app/license/server/license'; import { Apps } from '../../apps'; Meteor.startup(() => { - onInvalidateLicense(() => { + License.onInvalidateLicense(() => { void Apps.disableApps(); }); }); diff --git a/apps/meteor/ee/server/startup/audit.ts b/apps/meteor/ee/server/startup/audit.ts index 441429e51b22..c38794a7582e 100644 --- a/apps/meteor/ee/server/startup/audit.ts +++ b/apps/meteor/ee/server/startup/audit.ts @@ -1,7 +1,8 @@ -import { onLicense } from '../../app/license/server'; +import { License } from '@rocket.chat/license'; + import { createPermissions } from '../lib/audit/startup'; -await onLicense('auditing', async () => { +await License.onLicense('auditing', async () => { await import('../lib/audit/methods'); await createPermissions(); diff --git a/apps/meteor/ee/server/startup/deviceManagement.ts b/apps/meteor/ee/server/startup/deviceManagement.ts index a9a1c805f72d..2ad5fd3b8a4f 100644 --- a/apps/meteor/ee/server/startup/deviceManagement.ts +++ b/apps/meteor/ee/server/startup/deviceManagement.ts @@ -1,8 +1,9 @@ -import { onToggledFeature } from '../../app/license/server/license'; +import { License } from '@rocket.chat/license'; + import { addSettings } from '../settings/deviceManagement'; let stopListening: (() => void) | undefined; -onToggledFeature('device-management', { +License.onToggledFeature('device-management', { up: async () => { const { createPermissions, createEmailTemplates } = await import('../lib/deviceManagement/startup'); const { listenSessionLogin } = await import('../lib/deviceManagement/session'); diff --git a/apps/meteor/ee/server/startup/engagementDashboard.ts b/apps/meteor/ee/server/startup/engagementDashboard.ts index 2fc393379bf3..ca5dda577bb0 100644 --- a/apps/meteor/ee/server/startup/engagementDashboard.ts +++ b/apps/meteor/ee/server/startup/engagementDashboard.ts @@ -1,8 +1,7 @@ +import { License } from '@rocket.chat/license'; import { Meteor } from 'meteor/meteor'; -import { onToggledFeature } from '../../app/license/server/license'; - -onToggledFeature('engagement-dashboard', { +License.onToggledFeature('engagement-dashboard', { up: () => Meteor.startup(async () => { const { prepareAnalytics, attachCallbacks } = await import('../lib/engagementDashboard/startup'); diff --git a/apps/meteor/ee/server/startup/maxRoomsPerGuest.ts b/apps/meteor/ee/server/startup/maxRoomsPerGuest.ts index f4e2452ec806..5731ca0d1deb 100644 --- a/apps/meteor/ee/server/startup/maxRoomsPerGuest.ts +++ b/apps/meteor/ee/server/startup/maxRoomsPerGuest.ts @@ -1,17 +1,14 @@ -import { Subscriptions } from '@rocket.chat/models'; +import { License } from '@rocket.chat/license'; import { Meteor } from 'meteor/meteor'; import { callbacks } from '../../../lib/callbacks'; import { i18n } from '../../../server/lib/i18n'; -import { getMaxRoomsPerGuest } from '../../app/license/server/license'; callbacks.add( 'beforeAddedToRoom', async ({ user }) => { if (user.roles?.includes('guest')) { - const totalSubscriptions = await Subscriptions.countByUserId(user._id); - - if (totalSubscriptions >= getMaxRoomsPerGuest()) { + if (await License.shouldPreventAction('roomsPerGuest', { userId: user._id })) { throw new Meteor.Error('error-max-rooms-per-guest-reached', i18n.t('error-max-rooms-per-guest-reached')); } } diff --git a/apps/meteor/ee/server/startup/seatsCap.ts b/apps/meteor/ee/server/startup/seatsCap.ts index b390539ad6b1..f6d42823cb97 100644 --- a/apps/meteor/ee/server/startup/seatsCap.ts +++ b/apps/meteor/ee/server/startup/seatsCap.ts @@ -1,4 +1,5 @@ import type { IUser } from '@rocket.chat/core-typings'; +import { License } from '@rocket.chat/license'; import { Users } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; import { throttle } from 'underscore'; @@ -6,7 +7,6 @@ import { throttle } from 'underscore'; import { callbacks } from '../../../lib/callbacks'; import { i18n } from '../../../server/lib/i18n'; import { validateUserRoles } from '../../app/authorization/server/validateUserRoles'; -import { canAddNewUser, getMaxActiveUsers, onValidateLicenses } from '../../app/license/server/license'; import { createSeatsLimitBanners, disableDangerBannerDiscardingDismissal, @@ -22,7 +22,7 @@ callbacks.add( return; } - if (!(await canAddNewUser())) { + if (await License.shouldPreventAction('activeUsers')) { throw new Meteor.Error('error-license-user-limit-reached', i18n.t('error-license-user-limit-reached')); } }, @@ -33,7 +33,7 @@ callbacks.add( callbacks.add( 'beforeUserImport', async ({ userCount }) => { - if (!(await canAddNewUser(userCount))) { + if (await License.shouldPreventAction('activeUsers', {}, userCount)) { throw new Meteor.Error('error-license-user-limit-reached', i18n.t('error-license-user-limit-reached')); } }, @@ -52,7 +52,7 @@ callbacks.add( return; } - if (!(await canAddNewUser())) { + if (await License.shouldPreventAction('activeUsers')) { throw new Meteor.Error('error-license-user-limit-reached', i18n.t('error-license-user-limit-reached')); } }, @@ -62,37 +62,13 @@ callbacks.add( callbacks.add( 'validateUserRoles', - async (userData: Partial) => { - const isGuest = userData.roles?.includes('guest'); - if (isGuest) { - await validateUserRoles(Meteor.userId(), userData); - return; - } - - if (!userData._id) { - return; - } - - const currentUserData = await Users.findOneById(userData._id); - if (currentUserData?.type === 'app') { - return; - } - - const wasGuest = currentUserData?.roles?.length === 1 && currentUserData.roles.includes('guest'); - if (!wasGuest) { - return; - } - - if (!(await canAddNewUser())) { - throw new Meteor.Error('error-license-user-limit-reached', i18n.t('error-license-user-limit-reached')); - } - }, + async (userData: Partial) => validateUserRoles(userData), callbacks.priority.MEDIUM, 'check-max-user-seats', ); const handleMaxSeatsBanners = throttle(async function _handleMaxSeatsBanners() { - const maxActiveUsers = getMaxActiveUsers(); + const maxActiveUsers = License.getMaxActiveUsers(); if (!maxActiveUsers) { await disableWarningBannerDiscardingDismissal(); @@ -137,5 +113,5 @@ Meteor.startup(async () => { await handleMaxSeatsBanners(); - onValidateLicenses(handleMaxSeatsBanners); + License.onValidateLicense(handleMaxSeatsBanners); }); diff --git a/apps/meteor/ee/server/startup/services.ts b/apps/meteor/ee/server/startup/services.ts index 5288b9a8e10e..37aec21bfe56 100644 --- a/apps/meteor/ee/server/startup/services.ts +++ b/apps/meteor/ee/server/startup/services.ts @@ -1,8 +1,8 @@ import { api } from '@rocket.chat/core-services'; +import { License } from '@rocket.chat/license'; import { isRunningMs } from '../../../server/lib/isRunningMs'; import { FederationService } from '../../../server/services/federation/service'; -import { isEnterprise, onLicense } from '../../app/license/server'; import { LicenseService } from '../../app/license/server/license.internalService'; import { OmnichannelEE } from '../../app/livechat-enterprise/server/services/omnichannel.internalService'; import { EnterpriseSettings } from '../../app/settings/server/settings.internalService'; @@ -26,13 +26,13 @@ if (!isRunningMs()) { let federationService: FederationService; void (async () => { - if (!isEnterprise()) { + if (!License.hasValidLicense()) { federationService = await FederationService.createFederationService(); api.registerService(federationService); } })(); -await onLicense('federation', async () => { +await License.onLicense('federation', async () => { const federationServiceEE = new FederationServiceEE(); if (federationService) { api.destroyService(federationService); diff --git a/apps/meteor/ee/server/startup/upsell.ts b/apps/meteor/ee/server/startup/upsell.ts index c9e4c513276c..b31bf0635060 100644 --- a/apps/meteor/ee/server/startup/upsell.ts +++ b/apps/meteor/ee/server/startup/upsell.ts @@ -1,20 +1,13 @@ +import { License } from '@rocket.chat/license'; import { Settings } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; -import { onValidateLicenses, getLicenses } from '../../app/license/server/license'; - const handleHadTrial = (): void => { - getLicenses().forEach(({ valid, license }): void => { - if (!valid) { - return; - } - - if (license.meta?.trial) { - void Settings.updateValueById('Cloud_Workspace_Had_Trial', true); - } - }); + if (License.getLicense()?.information.trial) { + void Settings.updateValueById('Cloud_Workspace_Had_Trial', true); + } }; Meteor.startup(() => { - onValidateLicenses(handleHadTrial); + License.onValidateLicense(handleHadTrial); }); diff --git a/apps/meteor/lib/apps/getInstallationSourceFromAppStorageItem.ts b/apps/meteor/lib/apps/getInstallationSourceFromAppStorageItem.ts index 0af2cee0c377..8ac29d191576 100644 --- a/apps/meteor/lib/apps/getInstallationSourceFromAppStorageItem.ts +++ b/apps/meteor/lib/apps/getInstallationSourceFromAppStorageItem.ts @@ -1,6 +1,5 @@ import type { IAppStorageItem } from '@rocket.chat/apps-engine/server/storage'; - -import type { LicenseAppSources } from '../../ee/app/license/definition/ILicense'; +import type { LicenseAppSources } from '@rocket.chat/license'; /** * There have been reports of apps not being correctly migrated from versions prior to 6.0 diff --git a/apps/meteor/package.json b/apps/meteor/package.json index 5dea47ff3a10..69bd345bc8fb 100644 --- a/apps/meteor/package.json +++ b/apps/meteor/package.json @@ -246,7 +246,9 @@ "@rocket.chat/i18n": "workspace:^", "@rocket.chat/icons": "^0.32.0", "@rocket.chat/instance-status": "workspace:^", + "@rocket.chat/jwt": "workspace:^", "@rocket.chat/layout": "next", + "@rocket.chat/license": "workspace:^", "@rocket.chat/log-format": "workspace:^", "@rocket.chat/logger": "workspace:^", "@rocket.chat/logo": "^0.31.27", diff --git a/apps/meteor/server/services/authorization/service.ts b/apps/meteor/server/services/authorization/service.ts index 99863305f7c1..6918d40af871 100644 --- a/apps/meteor/server/services/authorization/service.ts +++ b/apps/meteor/server/services/authorization/service.ts @@ -39,7 +39,7 @@ export class Authorization extends ServiceClass implements IAuthorization { } async started(): Promise { - if (!(await License.isEnterprise())) { + if (!(await License.hasValidLicense())) { return; } diff --git a/apps/meteor/server/startup/migrations/v278.ts b/apps/meteor/server/startup/migrations/v278.ts index 57986fd1064f..068d86499ff9 100644 --- a/apps/meteor/server/startup/migrations/v278.ts +++ b/apps/meteor/server/startup/migrations/v278.ts @@ -1,7 +1,7 @@ +import { License } from '@rocket.chat/license'; import { Banners, Settings } from '@rocket.chat/models'; import { settings } from '../../../app/settings/server'; -import { isEnterprise } from '../../../ee/app/license/server'; import { addMigration } from '../../lib/migrations'; addMigration({ @@ -16,7 +16,7 @@ addMigration({ const LDAPEnabled = settings.get('LDAP_Enable'); const SAMLEnabled = settings.get('SAML_Custom_Default'); - const isEE = isEnterprise(); + const isEE = License.hasValidLicense(); if (!isEE && (isCustomOAuthEnabled || LDAPEnabled || SAMLEnabled)) { return; diff --git a/ee/apps/account-service/Dockerfile b/ee/apps/account-service/Dockerfile index d7ccb734071b..dbd8717e8716 100644 --- a/ee/apps/account-service/Dockerfile +++ b/ee/apps/account-service/Dockerfile @@ -19,9 +19,18 @@ COPY ./packages/rest-typings/dist packages/rest-typings/dist COPY ./packages/model-typings/package.json packages/model-typings/package.json COPY ./packages/model-typings/dist packages/model-typings/dist +COPY ./packages/jwt/package.json packages/jwt/package.json +COPY ./packages/jwt/dist packages/jwt/dist + COPY ./packages/models/package.json packages/models/package.json COPY ./packages/models/dist packages/models/dist +COPY ./packages/logger/package.json packages/logger/package.json +COPY ./packages/logger/dist packages/logger/dist + +COPY ./ee/packages/license/package.json packages/license/package.json +COPY ./ee/packages/license/dist packages/license/dist + COPY ./ee/apps/${SERVICE}/dist . COPY ./package.json . diff --git a/ee/apps/authorization-service/Dockerfile b/ee/apps/authorization-service/Dockerfile index d7ccb734071b..dbd8717e8716 100644 --- a/ee/apps/authorization-service/Dockerfile +++ b/ee/apps/authorization-service/Dockerfile @@ -19,9 +19,18 @@ COPY ./packages/rest-typings/dist packages/rest-typings/dist COPY ./packages/model-typings/package.json packages/model-typings/package.json COPY ./packages/model-typings/dist packages/model-typings/dist +COPY ./packages/jwt/package.json packages/jwt/package.json +COPY ./packages/jwt/dist packages/jwt/dist + COPY ./packages/models/package.json packages/models/package.json COPY ./packages/models/dist packages/models/dist +COPY ./packages/logger/package.json packages/logger/package.json +COPY ./packages/logger/dist packages/logger/dist + +COPY ./ee/packages/license/package.json packages/license/package.json +COPY ./ee/packages/license/dist packages/license/dist + COPY ./ee/apps/${SERVICE}/dist . COPY ./package.json . diff --git a/ee/apps/ddp-streamer/Dockerfile b/ee/apps/ddp-streamer/Dockerfile index 5250e48bf106..9386aac4f21e 100644 --- a/ee/apps/ddp-streamer/Dockerfile +++ b/ee/apps/ddp-streamer/Dockerfile @@ -25,15 +25,21 @@ COPY ./packages/ui-contexts/dist packages/ui-contexts/dist COPY ./packages/model-typings/package.json packages/model-typings/package.json COPY ./packages/model-typings/dist packages/model-typings/dist +COPY ./packages/jwt/package.json packages/jwt/package.json +COPY ./packages/jwt/dist packages/jwt/dist + COPY ./packages/models/package.json packages/models/package.json COPY ./packages/models/dist packages/models/dist -COPY ./packages/instance-status/package.json packages/instance-status/package.json -COPY ./packages/instance-status/dist packages/instance-status/dist - COPY ./packages/logger/package.json packages/logger/package.json COPY ./packages/logger/dist packages/logger/dist +COPY ./ee/packages/license/package.json packages/license/package.json +COPY ./ee/packages/license/dist packages/license/dist + +COPY ./packages/instance-status/package.json packages/instance-status/package.json +COPY ./packages/instance-status/dist packages/instance-status/dist + COPY ./ee/apps/${SERVICE}/dist . COPY ./package.json . diff --git a/ee/apps/omnichannel-transcript/Dockerfile b/ee/apps/omnichannel-transcript/Dockerfile index 95fb836e9f27..e6a1aa00fc88 100644 --- a/ee/apps/omnichannel-transcript/Dockerfile +++ b/ee/apps/omnichannel-transcript/Dockerfile @@ -19,9 +19,18 @@ COPY ./packages/rest-typings/dist packages/rest-typings/dist COPY ./packages/model-typings/package.json packages/model-typings/package.json COPY ./packages/model-typings/dist packages/model-typings/dist +COPY ./packages/jwt/package.json packages/jwt/package.json +COPY ./packages/jwt/dist packages/jwt/dist + COPY ./packages/models/package.json packages/models/package.json COPY ./packages/models/dist packages/models/dist +COPY ./packages/logger/package.json packages/logger/package.json +COPY ./packages/logger/dist packages/logger/dist + +COPY ./ee/packages/license/package.json packages/license/package.json +COPY ./ee/packages/license/dist packages/license/dist + COPY ./ee/packages/omnichannel-services/package.json ee/packages/omnichannel-services/package.json COPY ./ee/packages/omnichannel-services/dist ee/packages/omnichannel-services/dist @@ -31,9 +40,6 @@ COPY ./ee/packages/pdf-worker/dist ee/packages/pdf-worker/dist COPY ./packages/tools/package.json packages/tools/package.json COPY ./packages/tools/dist packages/tools/dist -COPY ./packages/logger/package.json packages/logger/package.json -COPY ./packages/logger/dist packages/logger/dist - COPY ./ee/apps/${SERVICE}/dist . COPY ./package.json . diff --git a/ee/apps/presence-service/Dockerfile b/ee/apps/presence-service/Dockerfile index f85c45246f29..aabf78295b8f 100644 --- a/ee/apps/presence-service/Dockerfile +++ b/ee/apps/presence-service/Dockerfile @@ -22,9 +22,18 @@ COPY ./packages/rest-typings/dist packages/rest-typings/dist COPY ./packages/model-typings/package.json packages/model-typings/package.json COPY ./packages/model-typings/dist packages/model-typings/dist +COPY ./packages/jwt/package.json packages/jwt/package.json +COPY ./packages/jwt/dist packages/jwt/dist + COPY ./packages/models/package.json packages/models/package.json COPY ./packages/models/dist packages/models/dist +COPY ./packages/logger/package.json packages/logger/package.json +COPY ./packages/logger/dist packages/logger/dist + +COPY ./ee/packages/license/package.json packages/license/package.json +COPY ./ee/packages/license/dist packages/license/dist + COPY ./packages/ui-contexts/package.json packages/ui-contexts/package.json COPY ./packages/ui-contexts/dist packages/ui-contexts/dist diff --git a/ee/apps/queue-worker/Dockerfile b/ee/apps/queue-worker/Dockerfile index 95fb836e9f27..e6a1aa00fc88 100644 --- a/ee/apps/queue-worker/Dockerfile +++ b/ee/apps/queue-worker/Dockerfile @@ -19,9 +19,18 @@ COPY ./packages/rest-typings/dist packages/rest-typings/dist COPY ./packages/model-typings/package.json packages/model-typings/package.json COPY ./packages/model-typings/dist packages/model-typings/dist +COPY ./packages/jwt/package.json packages/jwt/package.json +COPY ./packages/jwt/dist packages/jwt/dist + COPY ./packages/models/package.json packages/models/package.json COPY ./packages/models/dist packages/models/dist +COPY ./packages/logger/package.json packages/logger/package.json +COPY ./packages/logger/dist packages/logger/dist + +COPY ./ee/packages/license/package.json packages/license/package.json +COPY ./ee/packages/license/dist packages/license/dist + COPY ./ee/packages/omnichannel-services/package.json ee/packages/omnichannel-services/package.json COPY ./ee/packages/omnichannel-services/dist ee/packages/omnichannel-services/dist @@ -31,9 +40,6 @@ COPY ./ee/packages/pdf-worker/dist ee/packages/pdf-worker/dist COPY ./packages/tools/package.json packages/tools/package.json COPY ./packages/tools/dist packages/tools/dist -COPY ./packages/logger/package.json packages/logger/package.json -COPY ./packages/logger/dist packages/logger/dist - COPY ./ee/apps/${SERVICE}/dist . COPY ./package.json . diff --git a/ee/apps/stream-hub-service/Dockerfile b/ee/apps/stream-hub-service/Dockerfile index c06115c887f5..dbd8717e8716 100644 --- a/ee/apps/stream-hub-service/Dockerfile +++ b/ee/apps/stream-hub-service/Dockerfile @@ -19,12 +19,18 @@ COPY ./packages/rest-typings/dist packages/rest-typings/dist COPY ./packages/model-typings/package.json packages/model-typings/package.json COPY ./packages/model-typings/dist packages/model-typings/dist +COPY ./packages/jwt/package.json packages/jwt/package.json +COPY ./packages/jwt/dist packages/jwt/dist + COPY ./packages/models/package.json packages/models/package.json COPY ./packages/models/dist packages/models/dist COPY ./packages/logger/package.json packages/logger/package.json COPY ./packages/logger/dist packages/logger/dist +COPY ./ee/packages/license/package.json packages/license/package.json +COPY ./ee/packages/license/dist packages/license/dist + COPY ./ee/apps/${SERVICE}/dist . COPY ./package.json . diff --git a/ee/packages/license/.eslintrc.json b/ee/packages/license/.eslintrc.json new file mode 100644 index 000000000000..a83aeda48e66 --- /dev/null +++ b/ee/packages/license/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": ["@rocket.chat/eslint-config"], + "ignorePatterns": ["**/dist"] +} diff --git a/ee/packages/license/__tests__/MockedLicenseBuilder.ts b/ee/packages/license/__tests__/MockedLicenseBuilder.ts new file mode 100644 index 000000000000..316261744da5 --- /dev/null +++ b/ee/packages/license/__tests__/MockedLicenseBuilder.ts @@ -0,0 +1,209 @@ +import { LicenseImp } from '../src'; +import type { ILicenseTag } from '../src/definition/ILicenseTag'; +import type { ILicenseV3 } from '../src/definition/ILicenseV3'; +import type { LicenseLimit } from '../src/definition/LicenseLimit'; +import type { LicenseModule } from '../src/definition/LicenseModule'; +import type { LicensePeriod, Timestamp } from '../src/definition/LicensePeriod'; +import { encrypt } from '../src/token'; + +export class MockedLicenseBuilder { + information: { + id?: string; + autoRenew: boolean; + visualExpiration: Timestamp; + notifyAdminsAt?: Timestamp; + notifyUsersAt?: Timestamp; + trial: boolean; + offline: boolean; + createdAt: Timestamp; + grantedBy: { + method: 'manual' | 'self-service' | 'sales' | 'support' | 'reseller'; + seller?: string; + }; + grantedTo?: { + name?: string; + company?: string; + email?: string; + }; + legalText?: string; + notes?: string; + tags?: ILicenseTag[]; + }; + + validation: { + serverUrls: { + value: string; + type: 'url' | 'regex' | 'hash'; + }[]; + + serverVersions?: { + value: string; + }[]; + + serverUniqueId?: string; + cloudWorkspaceId?: string; + validPeriods: LicensePeriod[]; + legalTextAgreement?: { + type: 'required' | 'not-required' | 'accepted'; + acceptedVia?: 'cloud'; + }; + + statisticsReport: { + required: boolean; + allowedStaleInDays?: number; + }; + }; + + constructor() { + this.information = { + autoRenew: true, + // expires in 1 year + visualExpiration: new Date(new Date().setFullYear(new Date().getFullYear() + 1)).toISOString(), + // 15 days before expiration + notifyAdminsAt: new Date(new Date().setDate(new Date().getDate() + 15)).toISOString(), + // 30 days before expiration + notifyUsersAt: new Date(new Date().setDate(new Date().getDate() + 30)).toISOString(), + trial: false, + offline: false, + createdAt: new Date().toISOString(), + grantedBy: { + method: 'manual', + seller: 'Rocket.Cat', + }, + tags: [ + { + name: 'Test', + color: 'blue', + }, + ], + }; + + this.validation = { + serverUrls: [ + { + value: 'localhost:3000', + type: 'url', + }, + ], + serverVersions: [ + { + value: '3.0.0', + }, + ], + + serverUniqueId: '1234567890', + cloudWorkspaceId: '1234567890', + + validPeriods: [ + { + invalidBehavior: 'disable_modules', + modules: ['livechat-enterprise'], + validFrom: new Date(new Date().setFullYear(new Date().getFullYear() - 1)).toISOString(), + validUntil: new Date(new Date().setFullYear(new Date().getFullYear() + 1)).toISOString(), + }, + ], + + statisticsReport: { + required: true, + allowedStaleInDays: 30, + }, + }; + } + + public resetValidPeriods(): this { + this.validation.validPeriods = []; + return this; + } + + public withValidPeriod(period: LicensePeriod): this { + this.validation.validPeriods.push(period); + return this; + } + + public withGrantedTo(grantedTo: { name?: string; company?: string; email?: string }): this { + this.information.grantedTo = grantedTo; + return this; + } + + grantedModules: { + module: LicenseModule; + }[]; + + limits: { + activeUsers?: LicenseLimit[]; + guestUsers?: LicenseLimit[]; + roomsPerGuest?: LicenseLimit<'prevent_action'>[]; + privateApps?: LicenseLimit[]; + marketplaceApps?: LicenseLimit[]; + monthlyActiveContacts?: LicenseLimit[]; + }; + + cloudMeta?: Record; + + public withServerUrls(urls: { value: string; type: 'url' | 'regex' | 'hash' }): this { + this.validation.serverUrls = this.validation.serverUrls ?? []; + this.validation.serverUrls.push(urls); + return this; + } + + public withServerVersions(versions: { value: string }): this { + this.validation.serverVersions = this.validation.serverVersions ?? []; + this.validation.serverVersions.push(versions); + return this; + } + + public withGratedModules(modules: LicenseModule[]): this { + this.grantedModules = this.grantedModules ?? []; + this.grantedModules.push(...modules.map((module) => ({ module }))); + return this; + } + + withNoGratedModules(modules: LicenseModule[]): this { + this.grantedModules = this.grantedModules ?? []; + this.grantedModules = this.grantedModules.filter(({ module }) => !modules.includes(module)); + return this; + } + + public withLimits(key: K, value: ILicenseV3['limits'][K]): this { + this.limits = this.limits ?? {}; + this.limits[key] = value; + return this; + } + + public build(): ILicenseV3 { + return { + version: '3.0', + information: this.information, + validation: this.validation, + grantedModules: [...new Set(this.grantedModules)], + limits: { + activeUsers: [], + guestUsers: [], + roomsPerGuest: [], + privateApps: [], + marketplaceApps: [], + monthlyActiveContacts: [], + ...this.limits, + }, + cloudMeta: this.cloudMeta, + }; + } + + public sign(): Promise { + return encrypt(this.build()); + } +} + +export const getReadyLicenseManager = async () => { + const license = new LicenseImp(); + await license.setWorkspaceUrl('http://localhost:3000'); + await license.setWorkspaceUrl('http://localhost:3000'); + + license.setLicenseLimitCounter('activeUsers', () => 0); + license.setLicenseLimitCounter('guestUsers', () => 0); + license.setLicenseLimitCounter('roomsPerGuest', async () => 0); + license.setLicenseLimitCounter('privateApps', () => 0); + license.setLicenseLimitCounter('marketplaceApps', () => 0); + license.setLicenseLimitCounter('monthlyActiveContacts', async () => 0); + return license; +}; diff --git a/ee/packages/license/__tests__/emitter.spec.ts b/ee/packages/license/__tests__/emitter.spec.ts new file mode 100644 index 000000000000..4c7c5a8255d1 --- /dev/null +++ b/ee/packages/license/__tests__/emitter.spec.ts @@ -0,0 +1,66 @@ +/** + * @jest-environment node + */ + +import { MockedLicenseBuilder, getReadyLicenseManager } from './MockedLicenseBuilder'; + +describe('Event License behaviors', () => { + it('should call the module as they are enabled/disabled', async () => { + const license = await getReadyLicenseManager(); + const validFn = jest.fn(); + const invalidFn = jest.fn(); + + license.onValidFeature('livechat-enterprise', validFn); + license.onInvalidFeature('livechat-enterprise', invalidFn); + + const mocked = await new MockedLicenseBuilder(); + const oldToken = await mocked.sign(); + + const newToken = await mocked.withGratedModules(['livechat-enterprise']).sign(); + + // apply license + await expect(license.setLicense(oldToken)).resolves.toBe(true); + await expect(license.hasValidLicense()).toBe(true); + + await expect(license.hasModule('livechat-enterprise')).toBe(false); + + await expect(validFn).not.toBeCalled(); + await expect(invalidFn).toBeCalledTimes(1); + + // apply license containing livechat-enterprise module + + validFn.mockClear(); + invalidFn.mockClear(); + + await expect(license.setLicense(newToken)).resolves.toBe(true); + await expect(license.hasValidLicense()).toBe(true); + await expect(license.hasModule('livechat-enterprise')).toBe(true); + + await expect(validFn).toBeCalledTimes(1); + await expect(invalidFn).toBeCalledTimes(0); + + // apply the old license again + + validFn.mockClear(); + invalidFn.mockClear(); + await expect(license.setLicense(oldToken)).resolves.toBe(true); + await expect(license.hasValidLicense()).toBe(true); + await expect(license.hasModule('livechat-enterprise')).toBe(false); + await expect(validFn).toBeCalledTimes(0); + await expect(invalidFn).toBeCalledTimes(1); + }); + + it('should call `onValidateLicense` when a valid license is applied', async () => { + const license = await getReadyLicenseManager(); + const fn = jest.fn(); + + license.onValidateLicense(fn); + + const mocked = await new MockedLicenseBuilder(); + const token = await mocked.sign(); + + await expect(license.setLicense(token)).resolves.toBe(true); + await expect(license.hasValidLicense()).toBe(true); + await expect(fn).toBeCalledTimes(1); + }); +}); diff --git a/ee/packages/license/__tests__/setLicense.spec.ts b/ee/packages/license/__tests__/setLicense.spec.ts new file mode 100644 index 000000000000..962f591750ad --- /dev/null +++ b/ee/packages/license/__tests__/setLicense.spec.ts @@ -0,0 +1,103 @@ +/** + * @jest-environment node + */ + +import { LicenseImp } from '../src'; +import { DuplicatedLicenseError } from '../src/errors/DuplicatedLicenseError'; +import { InvalidLicenseError } from '../src/errors/InvalidLicenseError'; +import { NotReadyForValidation } from '../src/errors/NotReadyForValidation'; +import { MockedLicenseBuilder, getReadyLicenseManager } from './MockedLicenseBuilder'; + +// Same license used on ci tasks so no I didnt leak it +const VALID_LICENSE = + 'WMa5i+/t/LZbYOj8u3XUkivRhWBtWO6ycUjaZoVAw2DxMfdyBIAa2gMMI4x7Z2BrTZIZhFEImfOxcXcgD0QbXHGBJaMI+eYG+eofnVWi2VA7RWbpvWTULgPFgyJ4UEFeCOzVjcBLTQbmMSam3u0RlekWJkfAO0KnmLtsaEYNNA2rz1U+CLI/CdNGfdqrBu5PZZbGkH0KEzyIZMaykOjzvX+C6vd7fRxh23HecwhkBbqE8eQsCBt2ad0qC4MoVXsDaSOmSzGW+aXjuXt/9zjvrLlsmWQTSlkrEHdNkdywm0UkGxqz3+CP99n0WggUBioUiChjMuNMoceWvDvmxYP9Ml2NpYU7SnfhjmMFyXOah8ofzv8w509Y7XODvQBz+iB4Co9YnF3vT96HDDQyAV5t4jATE+0t37EAXmwjTi3qqyP7DLGK/revl+mlcwJ5kS4zZBsm1E4519FkXQOZSyWRnPdjqvh4mCLqoispZ49wKvklDvjPxCSP9us6cVXLDg7NTJr/4pfxLPOkvv7qCgugDvlDx17bXpQFPSDxmpw66FLzvb5Id0dkWjOzrRYSXb0bFWoUQjtHFzmcpFkyVhOKrQ9zA9+Zm7vXmU9Y2l2dK79EloOuHMSYAqsPEag8GMW6vI/cT4iIjHGGDePKnD0HblvTEKzql11cfT/abf2IiaY='; + +describe('License set license procedures', () => { + describe('Invalid formats', () => { + it('by default it should have no license', async () => { + const license = new LicenseImp(); + + expect(license.hasValidLicense()).toBe(false); + expect(license.getLicense()).toBeUndefined(); + }); + + it('should throw an error if the license applied is empty', async () => { + const license = new LicenseImp(); + await expect(license.setLicense('')).rejects.toThrow(InvalidLicenseError); + }); + + it('should throw an error if the license applied is invalid', async () => { + const license = new LicenseImp(); + await expect(license.setLicense('invalid')).rejects.toThrow(InvalidLicenseError); + }); + }); + + it('should throw an error if the license is duplicated', async () => { + const license = await getReadyLicenseManager(); + + await expect(license.setLicense(VALID_LICENSE)).resolves.toBe(true); + await expect(license.setLicense(VALID_LICENSE)).rejects.toThrow(DuplicatedLicenseError); + }); + + it('should keep a valid license if a new invalid license is applied', async () => { + const license = await getReadyLicenseManager(); + + await expect(license.setLicense(VALID_LICENSE)).resolves.toBe(true); + await expect(license.hasValidLicense()).toBe(true); + + await expect(license.setLicense('invalid')).rejects.toThrow(InvalidLicenseError); + await expect(license.hasValidLicense()).toBe(true); + }); + + describe('Pending cases', () => { + it('should return an error if the license is not ready for validation yet - missing workspace url', async () => { + const license = new LicenseImp(); + await expect(license.setLicense(VALID_LICENSE)).rejects.toThrow(NotReadyForValidation); + }); + + it('should return an error if the license is not ready for validation yet - missing counters', async () => { + const license = new LicenseImp(); + await license.setWorkspaceUrl('http://localhost:3000'); + + expect(license.getWorkspaceUrl()).toBe('localhost:3000'); + + await expect(license.setLicense(VALID_LICENSE)).rejects.toThrow(NotReadyForValidation); + + await expect(license.hasValidLicense()).toBe(false); + }); + + it('should return a valid license if the license is ready for validation', async () => { + const license = await getReadyLicenseManager(); + + await expect(license.setLicense(VALID_LICENSE)).resolves.toBe(true); + await expect(license.hasValidLicense()).toBe(true); + }); + }); + + describe('License V3', () => { + it('should return a valid license if the license is ready for validation', async () => { + const license = await getReadyLicenseManager(); + const token = await new MockedLicenseBuilder().sign(); + + await expect(license.setLicense(token)).resolves.toBe(true); + await expect(license.hasValidLicense()).toBe(true); + }); + + it('should accept new licenses', async () => { + const license = await getReadyLicenseManager(); + const mocked = await new MockedLicenseBuilder(); + const oldToken = await mocked.sign(); + + const newToken = await mocked.withGratedModules(['livechat-enterprise']).sign(); + + await expect(license.setLicense(oldToken)).resolves.toBe(true); + await expect(license.hasValidLicense()).toBe(true); + + await expect(license.hasModule('livechat-enterprise')).toBe(false); + + await expect(license.setLicense(newToken)).resolves.toBe(true); + await expect(license.hasValidLicense()).toBe(true); + await expect(license.hasModule('livechat-enterprise')).toBe(true); + }); + }); +}); diff --git a/ee/packages/license/babel.config.json b/ee/packages/license/babel.config.json new file mode 100644 index 000000000000..e154c0813530 --- /dev/null +++ b/ee/packages/license/babel.config.json @@ -0,0 +1,11 @@ +{ + "presets": ["@babel/preset-typescript"], + "plugins": [ + [ + "transform-inline-environment-variables", + { + "include": ["LICENSE_PUBLIC_KEY_V3"] + } + ] + ] +} diff --git a/ee/packages/license/jest.config.ts b/ee/packages/license/jest.config.ts new file mode 100644 index 000000000000..21121603f6e0 --- /dev/null +++ b/ee/packages/license/jest.config.ts @@ -0,0 +1,16 @@ +export default { + preset: 'ts-jest', + errorOnDeprecated: true, + modulePathIgnorePatterns: ['/dist/'], + testMatch: ['**/**.spec.ts'], + transform: { + '^.+\\.(t|j)sx?$': '@swc/jest', + }, + // transformIgnorePatterns: ['!node_modules/jose'], + moduleNameMapper: { + '\\.css$': 'identity-obj-proxy', + '^jose$': require.resolve('jose'), + }, + collectCoverage: true, + collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'], +}; diff --git a/ee/packages/license/package.json b/ee/packages/license/package.json new file mode 100644 index 000000000000..f6a1e7a2b7d5 --- /dev/null +++ b/ee/packages/license/package.json @@ -0,0 +1,47 @@ +{ + "name": "@rocket.chat/license", + "version": "0.0.1", + "private": true, + "devDependencies": { + "@babel/cli": "^7.23.0", + "@babel/core": "^7.23.0", + "@babel/preset-env": "^7.22.20", + "@babel/preset-typescript": "^7.23.0", + "@swc/core": "^1.3.66", + "@swc/jest": "^0.2.26", + "@types/babel__core": "^7", + "@types/babel__preset-env": "^7", + "@types/jest": "~29.5.3", + "@types/ws": "^8.5.5", + "babel-plugin-transform-inline-environment-variables": "^0.4.4", + "eslint": "~8.45.0", + "jest": "~29.6.1", + "jest-environment-jsdom": "~29.6.1", + "jest-websocket-mock": "^2.4.0", + "ts-jest": "~29.0.5", + "typescript": "^5.2.2" + }, + "scripts": { + "lint": "eslint --ext .js,.jsx,.ts,.tsx .", + "lint:fix": "eslint --ext .js,.jsx,.ts,.tsx . --fix", + "test": "jest", + "testunit": "jest", + "build": "npm run build:types && npm run build:js", + "build:types": "tsc --emitDeclarationOnly", + "build:js": "babel src --out-dir dist --extensions \".ts,.tsx\" --source-maps inline", + "dev": "tsc -p tsconfig.json --watch --preserveWatchOutput" + }, + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "files": [ + "/dist" + ], + "volta": { + "extends": "../../../package.json" + }, + "dependencies": { + "@rocket.chat/core-typings": "workspace:^", + "@rocket.chat/jwt": "workspace:^", + "@rocket.chat/logger": "workspace:^" + } +} diff --git a/apps/meteor/ee/app/license/definition/ILicenseTag.ts b/ee/packages/license/src/definition/ILicenseTag.ts similarity index 100% rename from apps/meteor/ee/app/license/definition/ILicenseTag.ts rename to ee/packages/license/src/definition/ILicenseTag.ts diff --git a/apps/meteor/ee/app/license/definition/ILicense.ts b/ee/packages/license/src/definition/ILicenseV2.ts similarity index 93% rename from apps/meteor/ee/app/license/definition/ILicense.ts rename to ee/packages/license/src/definition/ILicenseV2.ts index 7ac4bafdc7b5..57d921a24907 100644 --- a/apps/meteor/ee/app/license/definition/ILicense.ts +++ b/ee/packages/license/src/definition/ILicenseV2.ts @@ -1,6 +1,6 @@ import type { ILicenseTag } from './ILicenseTag'; -export interface ILicense { +export interface ILicenseV2 { url: string; expiry: string; maxActiveUsers: number; diff --git a/ee/packages/license/src/definition/ILicenseV3.ts b/ee/packages/license/src/definition/ILicenseV3.ts new file mode 100644 index 000000000000..d3a2d7f572a3 --- /dev/null +++ b/ee/packages/license/src/definition/ILicenseV3.ts @@ -0,0 +1,64 @@ +import type { ILicenseTag } from './ILicenseTag'; +import type { LicenseLimit } from './LicenseLimit'; +import type { LicenseModule } from './LicenseModule'; +import type { LicensePeriod, Timestamp } from './LicensePeriod'; + +export interface ILicenseV3 { + version: '3.0'; + information: { + id?: string; + autoRenew: boolean; + visualExpiration: Timestamp; + notifyAdminsAt?: Timestamp; + notifyUsersAt?: Timestamp; + trial: boolean; + offline: boolean; + createdAt: Timestamp; + grantedBy: { + method: 'manual' | 'self-service' | 'sales' | 'support' | 'reseller'; + seller?: string; + }; + grantedTo?: { + name?: string; + company?: string; + email?: string; + }; + legalText?: string; + notes?: string; + tags?: ILicenseTag[]; + }; + validation: { + serverUrls: { + value: string; + type: 'url' | 'regex' | 'hash'; + }[]; + serverVersions?: { + value: string; + }[]; + serverUniqueId?: string; + cloudWorkspaceId?: string; + validPeriods: LicensePeriod[]; + legalTextAgreement?: { + type: 'required' | 'not-required' | 'accepted'; + acceptedVia?: 'cloud'; + }; + statisticsReport: { + required: boolean; + allowedStaleInDays?: number; + }; + }; + grantedModules: { + module: LicenseModule; + }[]; + limits: { + activeUsers?: LicenseLimit[]; + guestUsers?: LicenseLimit[]; + roomsPerGuest?: LicenseLimit<'prevent_action'>[]; + privateApps?: LicenseLimit[]; + marketplaceApps?: LicenseLimit[]; + monthlyActiveContacts?: LicenseLimit[]; + }; + cloudMeta?: Record; +} + +export type LicenseLimitKind = keyof ILicenseV3['limits']; diff --git a/ee/packages/license/src/definition/LicenseBehavior.ts b/ee/packages/license/src/definition/LicenseBehavior.ts new file mode 100644 index 000000000000..b6d52bbfa8c5 --- /dev/null +++ b/ee/packages/license/src/definition/LicenseBehavior.ts @@ -0,0 +1,8 @@ +import type { LicenseModule } from './LicenseModule'; + +export type LicenseBehavior = 'invalidate_license' | 'start_fair_policy' | 'prevent_action' | 'prevent_installation' | 'disable_modules'; + +export type BehaviorWithContext = { + behavior: LicenseBehavior; + modules?: LicenseModule[]; +}; diff --git a/ee/packages/license/src/definition/LicenseLimit.ts b/ee/packages/license/src/definition/LicenseLimit.ts new file mode 100644 index 000000000000..40e5a62f597a --- /dev/null +++ b/ee/packages/license/src/definition/LicenseLimit.ts @@ -0,0 +1,7 @@ +import type { LicenseBehavior } from './LicenseBehavior'; +import type { LicenseModule } from './LicenseModule'; + +export type LicenseLimit = { + max: number; + behavior: T; +} & (T extends 'disable_modules' ? { behavior: T; modules: LicenseModule[] } : { behavior: T }); diff --git a/ee/packages/license/src/definition/LicenseModule.ts b/ee/packages/license/src/definition/LicenseModule.ts new file mode 100644 index 000000000000..8ecebba1983b --- /dev/null +++ b/ee/packages/license/src/definition/LicenseModule.ts @@ -0,0 +1,18 @@ +export type LicenseModule = + | 'auditing' + | 'canned-responses' + | 'ldap-enterprise' + | 'livechat-enterprise' + | 'voip-enterprise' + | 'omnichannel-mobile-enterprise' + | 'engagement-dashboard' + | 'push-privacy' + | 'scalability' + | 'teams-mention' + | 'saml-enterprise' + | 'oauth-enterprise' + | 'device-management' + | 'federation' + | 'videoconference-enterprise' + | 'message-read-receipt' + | 'outlook-calendar'; diff --git a/ee/packages/license/src/definition/LicensePeriod.ts b/ee/packages/license/src/definition/LicensePeriod.ts new file mode 100644 index 000000000000..d9bae6198fde --- /dev/null +++ b/ee/packages/license/src/definition/LicensePeriod.ts @@ -0,0 +1,13 @@ +import type { LicenseBehavior } from './LicenseBehavior'; +import type { LicenseModule } from './LicenseModule'; + +export type Timestamp = string; + +export type LicensePeriod = { + validFrom?: Timestamp; + validUntil?: Timestamp; + invalidBehavior: LicenseBehavior; +} & ({ validFrom: Timestamp } | { validUntil: Timestamp }) & + ({ invalidBehavior: 'disable_modules'; modules: LicenseModule[] } | { invalidBehavior: Exclude }); + +export type LicensePeriodBehavior = Exclude; diff --git a/ee/packages/license/src/definition/LimitContext.ts b/ee/packages/license/src/definition/LimitContext.ts new file mode 100644 index 000000000000..a2c44744bd75 --- /dev/null +++ b/ee/packages/license/src/definition/LimitContext.ts @@ -0,0 +1,5 @@ +import type { IUser } from '@rocket.chat/core-typings'; + +import type { LicenseLimitKind } from './ILicenseV3'; + +export type LimitContext = T extends 'roomsPerGuest' ? { userId: IUser['_id'] } : Record; diff --git a/ee/packages/license/src/deprecated.ts b/ee/packages/license/src/deprecated.ts new file mode 100644 index 000000000000..65851a79c7eb --- /dev/null +++ b/ee/packages/license/src/deprecated.ts @@ -0,0 +1,38 @@ +import type { ILicenseV3, LicenseLimitKind } from './definition/ILicenseV3'; +import type { LicenseManager } from './license'; +import { getModules } from './modules'; + +const getLicenseLimit = (license: ILicenseV3 | undefined, kind: LicenseLimitKind) => { + if (!license) { + return; + } + + const limitList = license.limits[kind]; + if (!limitList?.length) { + return; + } + + return Math.min(...limitList.map(({ max }) => max)); +}; + +// #TODO: Remove references to those functions + +export function getMaxActiveUsers(this: LicenseManager) { + return getLicenseLimit(this.getLicense(), 'activeUsers') ?? 0; +} + +export function getAppsConfig(this: LicenseManager) { + return { + maxPrivateApps: getLicenseLimit(this.getLicense(), 'privateApps') ?? -1, + maxMarketplaceApps: getLicenseLimit(this.getLicense(), 'marketplaceApps') ?? -1, + }; +} + +export function getUnmodifiedLicenseAndModules(this: LicenseManager) { + if (this.valid && this.unmodifiedLicense) { + return { + license: this.unmodifiedLicense, + modules: getModules.call(this), + }; + } +} diff --git a/ee/packages/license/src/errors/DuplicatedLicenseError.ts b/ee/packages/license/src/errors/DuplicatedLicenseError.ts new file mode 100644 index 000000000000..70b962d53105 --- /dev/null +++ b/ee/packages/license/src/errors/DuplicatedLicenseError.ts @@ -0,0 +1,6 @@ +export class DuplicatedLicenseError extends Error { + constructor(message = 'Duplicated license') { + super(message); + this.name = 'DuplicatedLicense'; + } +} diff --git a/ee/packages/license/src/errors/InvalidLicenseError.ts b/ee/packages/license/src/errors/InvalidLicenseError.ts new file mode 100644 index 000000000000..a1eb328acd46 --- /dev/null +++ b/ee/packages/license/src/errors/InvalidLicenseError.ts @@ -0,0 +1,6 @@ +export class InvalidLicenseError extends Error { + constructor(message = 'Invalid license') { + super(message); + this.name = 'InvalidLicenseError'; + } +} diff --git a/ee/packages/license/src/errors/NotReadyForValidation.ts b/ee/packages/license/src/errors/NotReadyForValidation.ts new file mode 100644 index 000000000000..ccb99e054500 --- /dev/null +++ b/ee/packages/license/src/errors/NotReadyForValidation.ts @@ -0,0 +1,6 @@ +export class NotReadyForValidation extends Error { + constructor(message = 'Not ready for validation') { + super(message); + this.name = 'NotReadyForValidation'; + } +} diff --git a/ee/packages/license/src/events/deprecated.ts b/ee/packages/license/src/events/deprecated.ts new file mode 100644 index 000000000000..8ebfe4729292 --- /dev/null +++ b/ee/packages/license/src/events/deprecated.ts @@ -0,0 +1,12 @@ +import type { LicenseModule } from '../definition/LicenseModule'; +import type { LicenseManager } from '../license'; +import { hasModule } from '../modules'; + +// #TODO: Remove this onLicense handler +export function onLicense(this: LicenseManager, feature: LicenseModule, cb: (...args: any[]) => void): void | Promise { + if (hasModule.call(this, feature)) { + return cb(); + } + + this.once(`valid:${feature}`, cb); +} diff --git a/ee/packages/license/src/events/emitter.ts b/ee/packages/license/src/events/emitter.ts new file mode 100644 index 000000000000..9d4025e4bce3 --- /dev/null +++ b/ee/packages/license/src/events/emitter.ts @@ -0,0 +1,30 @@ +import type { LicenseLimitKind } from '../definition/ILicenseV3'; +import type { LicenseModule } from '../definition/LicenseModule'; +import type { LicenseManager } from '../license'; +import { logger } from '../logger'; + +export function moduleValidated(this: LicenseManager, module: LicenseModule) { + try { + this.emit('module', { module, valid: true }); + this.emit(`valid:${module}`); + } catch (error) { + logger.error({ msg: 'Error running module added event', error }); + } +} + +export function moduleRemoved(this: LicenseManager, module: LicenseModule) { + try { + this.emit('module', { module, valid: false }); + this.emit(`invalid:${module}`); + } catch (error) { + logger.error({ msg: 'Error running module removed event', error }); + } +} + +export function limitReached(this: LicenseManager, limitKind: LicenseLimitKind) { + try { + this.emit(`limitReached:${limitKind}`); + } catch (error) { + logger.error({ msg: 'Error running limit reached event', error }); + } +} diff --git a/ee/packages/license/src/events/listeners.ts b/ee/packages/license/src/events/listeners.ts new file mode 100644 index 000000000000..d6e9fb016f2c --- /dev/null +++ b/ee/packages/license/src/events/listeners.ts @@ -0,0 +1,75 @@ +import type { LicenseLimitKind } from '../definition/ILicenseV3'; +import type { LicenseModule } from '../definition/LicenseModule'; +import type { LicenseManager } from '../license'; +import { hasModule } from '../modules'; + +export function onValidFeature(this: LicenseManager, feature: LicenseModule, cb: () => void) { + this.on(`valid:${feature}`, cb); + + if (hasModule.call(this, feature)) { + cb(); + } + + return (): void => { + this.off(`valid:${feature}`, cb); + }; +} + +export function onInvalidFeature(this: LicenseManager, feature: LicenseModule, cb: () => void) { + this.on(`invalid:${feature}`, cb); + + if (!hasModule.call(this, feature)) { + cb(); + } + + return (): void => { + this.off(`invalid:${feature}`, cb); + }; +} + +export function onToggledFeature( + this: LicenseManager, + feature: LicenseModule, + { up, down }: { up?: () => Promise | void; down?: () => Promise | void }, +): () => void { + let enabled = hasModule.call(this, feature); + + const offValidFeature = onValidFeature.bind(this)(feature, () => { + if (!enabled) { + void up?.(); + enabled = true; + } + }); + + const offInvalidFeature = onInvalidFeature.bind(this)(feature, () => { + if (enabled) { + void down?.(); + enabled = false; + } + }); + + if (enabled) { + void up?.(); + } + + return (): void => { + offValidFeature(); + offInvalidFeature(); + }; +} + +export function onModule(this: LicenseManager, cb: (...args: any[]) => void) { + this.on('module', cb); +} + +export function onValidateLicense(this: LicenseManager, cb: (...args: any[]) => void) { + this.on('validate', cb); +} + +export function onInvalidateLicense(this: LicenseManager, cb: (...args: any[]) => void) { + this.on('invalidate', cb); +} + +export function onLimitReached(this: LicenseManager, limitKind: LicenseLimitKind, cb: (...args: any[]) => void) { + this.on(`limitReached:${limitKind}`, cb); +} diff --git a/ee/packages/license/src/events/overwriteClassOnLicense.ts b/ee/packages/license/src/events/overwriteClassOnLicense.ts new file mode 100644 index 000000000000..00a690d8f413 --- /dev/null +++ b/ee/packages/license/src/events/overwriteClassOnLicense.ts @@ -0,0 +1,26 @@ +import type { LicenseModule } from '../definition/LicenseModule'; +import type { LicenseManager } from '../license'; +import { onLicense } from './deprecated'; + +interface IOverrideClassProperties { + [key: string]: (...args: any[]) => any; +} + +type Class = { new (...args: any[]): any }; + +export async function overwriteClassOnLicense( + this: LicenseManager, + + license: LicenseModule, + original: Class, + overwrite: IOverrideClassProperties, +): Promise { + await onLicense.call(this, license, () => { + Object.entries(overwrite).forEach(([key, value]) => { + const originalFn = original.prototype[key]; + original.prototype[key] = function (...args: any[]): any { + return value.call(this, originalFn, ...args); + }; + }); + }); +} diff --git a/ee/packages/license/src/index.ts b/ee/packages/license/src/index.ts new file mode 100644 index 000000000000..9dbd94db53ed --- /dev/null +++ b/ee/packages/license/src/index.ts @@ -0,0 +1,106 @@ +import type { LicenseLimitKind } from './definition/ILicenseV3'; +import type { LimitContext } from './definition/LimitContext'; +import { getAppsConfig, getMaxActiveUsers, getUnmodifiedLicenseAndModules } from './deprecated'; +import { onLicense } from './events/deprecated'; +import { + onInvalidFeature, + onInvalidateLicense, + onLimitReached, + onModule, + onToggledFeature, + onValidFeature, + onValidateLicense, +} from './events/listeners'; +import { overwriteClassOnLicense } from './events/overwriteClassOnLicense'; +import { LicenseManager } from './license'; +import { getModules, hasModule } from './modules'; +import { getTags } from './tags'; +import { getCurrentValueForLicenseLimit, setLicenseLimitCounter } from './validation/getCurrentValueForLicenseLimit'; +import { validateFormat } from './validation/validateFormat'; + +export * from './definition/ILicenseTag'; +export * from './definition/ILicenseV2'; +export * from './definition/ILicenseV3'; +export * from './definition/LicenseBehavior'; +export * from './definition/LicenseLimit'; +export * from './definition/LicenseModule'; +export * from './definition/LicensePeriod'; +export * from './definition/LimitContext'; + +// eslint-disable-next-line @typescript-eslint/naming-convention +interface License { + validateFormat: typeof validateFormat; + hasModule: typeof hasModule; + getModules: typeof getModules; + getTags: typeof getTags; + overwriteClassOnLicense: typeof overwriteClassOnLicense; + setLicenseLimitCounter: typeof setLicenseLimitCounter; + getCurrentValueForLicenseLimit: typeof getCurrentValueForLicenseLimit; + isLimitReached: (action: T, context?: Partial>) => Promise; + onValidFeature: typeof onValidFeature; + onInvalidFeature: typeof onInvalidFeature; + onToggledFeature: typeof onToggledFeature; + onModule: typeof onModule; + onValidateLicense: typeof onValidateLicense; + onInvalidateLicense: typeof onInvalidateLicense; + onLimitReached: typeof onLimitReached; + + // Deprecated: + onLicense: typeof onLicense; + // Deprecated: + getMaxActiveUsers: typeof getMaxActiveUsers; + // Deprecated: + getAppsConfig: typeof getAppsConfig; + // Deprecated: + getUnmodifiedLicenseAndModules: typeof getUnmodifiedLicenseAndModules; +} + +export class LicenseImp extends LicenseManager implements License { + validateFormat = validateFormat; + + hasModule = hasModule; + + getModules = getModules; + + getTags = getTags; + + overwriteClassOnLicense = overwriteClassOnLicense; + + public setLicenseLimitCounter = setLicenseLimitCounter; + + getCurrentValueForLicenseLimit = getCurrentValueForLicenseLimit; + + public async isLimitReached(action: T, context?: Partial>) { + return this.shouldPreventAction(action, context, 0); + } + + onValidFeature = onValidFeature; + + onInvalidFeature = onInvalidFeature; + + onToggledFeature = onToggledFeature; + + onModule = onModule; + + onValidateLicense = onValidateLicense; + + onInvalidateLicense = onInvalidateLicense; + + onLimitReached = onLimitReached; + + // Deprecated: + onLicense = onLicense; + + // Deprecated: + getMaxActiveUsers = getMaxActiveUsers; + + // Deprecated: + getAppsConfig = getAppsConfig; + + // Deprecated: + getUnmodifiedLicenseAndModules = getUnmodifiedLicenseAndModules; +} + +const license = new LicenseImp(); + +export { license as License }; diff --git a/ee/packages/license/src/license.spec.ts b/ee/packages/license/src/license.spec.ts new file mode 100644 index 000000000000..36744585d59f --- /dev/null +++ b/ee/packages/license/src/license.spec.ts @@ -0,0 +1,42 @@ +import { MockedLicenseBuilder, getReadyLicenseManager } from '../__tests__/MockedLicenseBuilder'; + +it('should not prevent if there is no license', async () => { + const license = await getReadyLicenseManager(); + const result = await license.shouldPreventAction('activeUsers'); + expect(result).toBe(false); +}); + +it('should not prevent if the counter is under the limit', async () => { + const licenseManager = await getReadyLicenseManager(); + + const license = await new MockedLicenseBuilder().withLimits('activeUsers', [ + { + max: 10, + behavior: 'prevent_action', + }, + ]); + + await expect(licenseManager.setLicense(await license.sign())).resolves.toBe(true); + + licenseManager.setLicenseLimitCounter('activeUsers', () => 5); + await expect(licenseManager.shouldPreventAction('activeUsers')).resolves.toBe(false); +}); + +it('should prevent if the counter is equal or over the limit', async () => { + const licenseManager = await getReadyLicenseManager(); + + const license = await new MockedLicenseBuilder().withLimits('activeUsers', [ + { + max: 10, + behavior: 'prevent_action', + }, + ]); + + await expect(licenseManager.setLicense(await license.sign())).resolves.toBe(true); + + licenseManager.setLicenseLimitCounter('activeUsers', () => 10); + await expect(licenseManager.shouldPreventAction('activeUsers')).resolves.toBe(true); + + licenseManager.setLicenseLimitCounter('activeUsers', () => 11); + await expect(licenseManager.shouldPreventAction('activeUsers')).resolves.toBe(true); +}); diff --git a/ee/packages/license/src/license.ts b/ee/packages/license/src/license.ts new file mode 100644 index 000000000000..2fb25b0e3b4f --- /dev/null +++ b/ee/packages/license/src/license.ts @@ -0,0 +1,230 @@ +import { Emitter } from '@rocket.chat/emitter'; + +import type { ILicenseV2 } from './definition/ILicenseV2'; +import type { ILicenseV3, LicenseLimitKind } from './definition/ILicenseV3'; +import type { BehaviorWithContext } from './definition/LicenseBehavior'; +import type { LicenseModule } from './definition/LicenseModule'; +import type { LimitContext } from './definition/LimitContext'; +import { DuplicatedLicenseError } from './errors/DuplicatedLicenseError'; +import { InvalidLicenseError } from './errors/InvalidLicenseError'; +import { NotReadyForValidation } from './errors/NotReadyForValidation'; +import { logger } from './logger'; +import { invalidateAll, replaceModules } from './modules'; +import { applyPendingLicense, clearPendingLicense, hasPendingLicense, isPendingLicense, setPendingLicense } from './pendingLicense'; +import { showLicense } from './showLicense'; +import { replaceTags } from './tags'; +import { decrypt } from './token'; +import { convertToV3 } from './v2/convertToV3'; +import { getCurrentValueForLicenseLimit } from './validation/getCurrentValueForLicenseLimit'; +import { getModulesToDisable } from './validation/getModulesToDisable'; +import { isBehaviorsInResult } from './validation/isBehaviorsInResult'; +import { isReadyForValidation } from './validation/isReadyForValidation'; +import { runValidation } from './validation/runValidation'; +import { validateFormat } from './validation/validateFormat'; + +export class LicenseManager extends Emitter< + Record<`limitReached:${LicenseLimitKind}` | `${'invalid' | 'valid'}:${LicenseModule}`, undefined> & { + validate: undefined; + invalidate: undefined; + module: { module: LicenseModule; valid: boolean }; + } +> { + dataCounters = new Map) => Promise>(); + + pendingLicense = ''; + + modules = new Set(); + + private workspaceUrl: string | undefined; + + private _license: ILicenseV3 | undefined; + + private _unmodifiedLicense: ILicenseV2 | ILicenseV3 | undefined; + + private _valid: boolean | undefined; + + private _inFairPolicy: boolean | undefined; + + private _lockedLicense: string | undefined; + + public get license(): ILicenseV3 | undefined { + return this._license; + } + + public get unmodifiedLicense(): ILicenseV2 | ILicenseV3 | undefined { + return this._unmodifiedLicense; + } + + public get valid(): boolean | undefined { + return this._valid; + } + + public get inFairPolicy(): boolean { + return Boolean(this._inFairPolicy); + } + + public async setWorkspaceUrl(url: string) { + this.workspaceUrl = url.replace(/\/$/, '').replace(/^https?:\/\/(.*)$/, '$1'); + + if (hasPendingLicense.call(this)) { + await applyPendingLicense.call(this); + } + } + + public getWorkspaceUrl() { + return this.workspaceUrl; + } + + private clearLicenseData(): void { + this._license = undefined; + this._unmodifiedLicense = undefined; + this._inFairPolicy = undefined; + this._valid = false; + this._lockedLicense = undefined; + clearPendingLicense.call(this); + } + + private async setLicenseV3(newLicense: ILicenseV3, encryptedLicense: string, originalLicense?: ILicenseV2 | ILicenseV3): Promise { + const hadValidLicense = this.hasValidLicense(); + this.clearLicenseData(); + + try { + this._unmodifiedLicense = originalLicense || newLicense; + this._license = newLicense; + + await this.validateLicense(); + + this._lockedLicense = encryptedLicense; + } finally { + if (hadValidLicense && !this.hasValidLicense()) { + this.emit('invalidate'); + invalidateAll.call(this); + } + } + } + + private async setLicenseV2(newLicense: ILicenseV2, encryptedLicense: string): Promise { + return this.setLicenseV3(convertToV3(newLicense), encryptedLicense, newLicense); + } + + private isLicenseDuplicated(encryptedLicense: string): boolean { + return Boolean(this._lockedLicense && this._lockedLicense === encryptedLicense); + } + + private async validateLicense(): Promise { + if (!this._license) { + throw new InvalidLicenseError(); + } + + if (!isReadyForValidation.call(this)) { + throw new NotReadyForValidation(); + } + + // #TODO: Only include 'prevent_installation' here if this is actually the initial installation of the license + const validationResult = await runValidation.call(this, this._license, [ + 'invalidate_license', + 'prevent_installation', + 'start_fair_policy', + 'disable_modules', + ]); + + this.processValidationResult(validationResult); + } + + public async setLicense(encryptedLicense: string): Promise { + if (!(await validateFormat(encryptedLicense))) { + throw new InvalidLicenseError(); + } + + if (this.isLicenseDuplicated(encryptedLicense)) { + // If there is a pending license but the user is trying to revert to the license that is currently active + if (hasPendingLicense.call(this) && !isPendingLicense.call(this, encryptedLicense)) { + // simply remove the pending license + clearPendingLicense.call(this); + throw new Error('Invalid license 1'); + } + + throw new DuplicatedLicenseError(); + } + + if (!isReadyForValidation.call(this)) { + // If we can't validate the license data yet, but is a valid license string, store it to validate when we can + setPendingLicense.call(this, encryptedLicense); + throw new NotReadyForValidation(); + } + + logger.info('New Enterprise License'); + try { + const decrypted = JSON.parse(await decrypt(encryptedLicense)); + + logger.debug({ msg: 'license', decrypted }); + + if (!encryptedLicense.startsWith('RCV3_')) { + await this.setLicenseV2(decrypted, encryptedLicense); + return true; + } + await this.setLicenseV3(decrypted, encryptedLicense); + + return true; + } catch (e) { + logger.error('Invalid license'); + + logger.error({ msg: 'Invalid raw license', encryptedLicense, e }); + + throw new InvalidLicenseError(); + } + } + + private processValidationResult(result: BehaviorWithContext[]): void { + if (!this._license || isBehaviorsInResult(result, ['invalidate_license', 'prevent_installation'])) { + return; + } + + this._valid = true; + this._inFairPolicy = isBehaviorsInResult(result, ['start_fair_policy']); + + if (this._license.information.tags) { + replaceTags(this._license.information.tags); + } + + const disabledModules = getModulesToDisable(result); + const modulesToEnable = this._license.grantedModules.filter(({ module }) => !disabledModules.includes(module)); + + replaceModules.call( + this, + modulesToEnable.map(({ module }) => module), + ); + logger.log({ msg: 'License validated', modules: modulesToEnable }); + + this.emit('validate'); + showLicense.call(this, this._license, this._valid); + } + + public hasValidLicense(): boolean { + return Boolean(this.getLicense()); + } + + public getLicense(): ILicenseV3 | undefined { + if (this._valid && this._license) { + return this._license; + } + } + + public async shouldPreventAction( + action: T, + context?: Partial>, + newCount = 1, + ): Promise { + const license = this.getLicense(); + if (!license) { + return false; + } + + const currentValue = (await getCurrentValueForLicenseLimit.call(this, action, context)) + newCount; + return Boolean( + license.limits[action] + ?.filter(({ behavior, max }) => behavior === 'prevent_action' && max >= 0) + .some(({ max }) => max < currentValue), + ); + } +} diff --git a/ee/packages/license/src/logger.ts b/ee/packages/license/src/logger.ts new file mode 100644 index 000000000000..120b08691c6c --- /dev/null +++ b/ee/packages/license/src/logger.ts @@ -0,0 +1,3 @@ +import { Logger } from '@rocket.chat/logger'; + +export const logger = new Logger('License'); diff --git a/ee/packages/license/src/modules.ts b/ee/packages/license/src/modules.ts new file mode 100644 index 000000000000..7570ec525fc7 --- /dev/null +++ b/ee/packages/license/src/modules.ts @@ -0,0 +1,50 @@ +import type { LicenseModule } from './definition/LicenseModule'; +import { moduleRemoved, moduleValidated } from './events/emitter'; +import type { LicenseManager } from './license'; + +export function notifyValidatedModules(this: LicenseManager, licenseModules: LicenseModule[]) { + licenseModules.forEach((module) => { + this.modules.add(module); + moduleValidated.call(this, module); + }); +} + +export function notifyInvalidatedModules(this: LicenseManager, licenseModules: LicenseModule[]) { + licenseModules.forEach((module) => { + moduleRemoved.call(this, module); + this.modules.delete(module); + }); +} + +export function invalidateAll(this: LicenseManager) { + notifyInvalidatedModules.call(this, [...this.modules]); + this.modules.clear(); +} + +export function getModules(this: LicenseManager) { + return [...this.modules]; +} + +export function hasModule(this: LicenseManager, module: LicenseModule) { + return this.modules.has(module); +} + +export function replaceModules(this: LicenseManager, newModules: LicenseModule[]) { + for (const moduleName of newModules) { + if (this.modules.has(moduleName)) { + continue; + } + + this.modules.add(moduleName); + moduleValidated.call(this, moduleName); + } + + for (const moduleName of this.modules) { + if (newModules.includes(moduleName)) { + continue; + } + + moduleRemoved.call(this, moduleName); + this.modules.delete(moduleName); + } +} diff --git a/ee/packages/license/src/pendingLicense.ts b/ee/packages/license/src/pendingLicense.ts new file mode 100644 index 000000000000..2c2140044336 --- /dev/null +++ b/ee/packages/license/src/pendingLicense.ts @@ -0,0 +1,32 @@ +import type { LicenseManager } from './license'; +import { logger } from './logger'; + +export function setPendingLicense(this: LicenseManager, encryptedLicense: string) { + this.pendingLicense = encryptedLicense; + if (this.pendingLicense) { + logger.info('Storing license as pending validation.'); + } +} + +export function applyPendingLicense(this: LicenseManager) { + if (this.pendingLicense) { + logger.info('Applying pending license.'); + this.setLicense(this.pendingLicense); + } +} + +export function hasPendingLicense(this: LicenseManager) { + return Boolean(this.pendingLicense); +} + +export function isPendingLicense(this: LicenseManager, encryptedLicense: string) { + return !!this.pendingLicense && this.pendingLicense === encryptedLicense; +} + +export function clearPendingLicense(this: LicenseManager) { + if (this.pendingLicense) { + logger.info('Removing pending license.'); + } + + this.pendingLicense = ''; +} diff --git a/ee/packages/license/src/showLicense.ts b/ee/packages/license/src/showLicense.ts new file mode 100644 index 000000000000..3dda60a43b76 --- /dev/null +++ b/ee/packages/license/src/showLicense.ts @@ -0,0 +1,27 @@ +import type { ILicenseV3 } from './definition/ILicenseV3'; +import type { LicenseManager } from './license'; +import { getModules } from './modules'; + +export function showLicense(this: LicenseManager, license: ILicenseV3 | undefined, valid: boolean | undefined) { + if (!process.env.LICENSE_DEBUG || process.env.LICENSE_DEBUG === 'false') { + return; + } + + if (!license || !valid) { + return; + } + + const { + validation: { serverUrls, validPeriods }, + limits, + } = license; + + const modules = getModules.call(this); + + console.log('---- License enabled ----'); + console.log(' url ->', JSON.stringify(serverUrls)); + console.log(' periods ->', JSON.stringify(validPeriods)); + console.log(' limits ->', JSON.stringify(limits)); + console.log(' modules ->', modules.join(', ')); + console.log('-------------------------'); +} diff --git a/ee/packages/license/src/tags.ts b/ee/packages/license/src/tags.ts new file mode 100644 index 000000000000..ca2639678475 --- /dev/null +++ b/ee/packages/license/src/tags.ts @@ -0,0 +1,23 @@ +import type { ILicenseTag } from './definition/ILicenseTag'; + +export const tags = new Set(); + +export const addTag = (tag: ILicenseTag) => { + // make sure to not add duplicated tag names + for (const addedTag of tags) { + if (addedTag.name.toLowerCase() === tag.name.toLowerCase()) { + return; + } + } + + tags.add(tag); +}; + +export const replaceTags = (newTags: ILicenseTag[]) => { + tags.clear(); + for (const tag of newTags) { + addTag(tag); + } +}; + +export const getTags = () => [...tags]; diff --git a/ee/packages/license/src/token.ts b/ee/packages/license/src/token.ts new file mode 100644 index 000000000000..80ecc29b4a3f --- /dev/null +++ b/ee/packages/license/src/token.ts @@ -0,0 +1,59 @@ +import crypto from 'crypto'; + +import { verify, sign, getPairs } from '@rocket.chat/jwt'; + +import type { ILicenseV3 } from './definition/ILicenseV3'; + +const PUBLIC_KEY_V2 = + 'LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQ0lqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FnOEFNSUlDQ2dLQ0FnRUFxV1Nza2Q5LzZ6Ung4a3lQY2ljcwpiMzJ3Mnd4VnV3N3lCVDk2clEvOEQreU1lQ01POXdTU3BIYS85bkZ5d293RXRpZ3B0L3dyb1BOK1ZHU3didHdQCkZYQmVxRWxCbmRHRkFsODZlNStFbGlIOEt6L2hHbkNtSk5tWHB4RUsyUkUwM1g0SXhzWVg3RERCN010eC9pcXMKY2pCL091dlNCa2ppU2xlUzdibE5JVC9kQTdLNC9DSjNvaXUwMmJMNEV4Y2xDSGVwenFOTWVQM3dVWmdweE9uZgpOT3VkOElYWUs3M3pTY3VFOEUxNTdZd3B6Q0twVmFIWDdaSmY4UXVOc09PNVcvYUlqS2wzTDYyNjkrZUlPRXJHCndPTm1hSG56Zmc5RkxwSmh6Z3BPMzhhVm43NnZENUtLakJhaldza1krNGEyZ1NRbUtOZUZxYXFPb3p5RUZNMGUKY0ZXWlZWWjNMZWg0dkVNb1lWUHlJeng5Nng4ZjIveW1QbmhJdXZRdjV3TjRmeWVwYTdFWTVVQ2NwNzF6OGtmUAo0RmNVelBBMElEV3lNaWhYUi9HNlhnUVFaNEdiL3FCQmh2cnZpSkNGemZZRGNKZ0w3RmVnRllIUDNQR0wwN1FnCnZMZXZNSytpUVpQcnhyYnh5U3FkUE9rZ3VyS2pWclhUVXI0QTlUZ2lMeUlYNVVsSnEzRS9SVjdtZk9xWm5MVGEKU0NWWEhCaHVQbG5DR1pSMDFUb1RDZktoTUcxdTBDRm5MMisxNWhDOWZxT21XdjlRa2U0M3FsSjBQZ0YzVkovWAp1eC9tVHBuazlnbmJHOUpIK21mSDM5Um9GdlROaW5Zd1NNdll6dXRWT242OXNPemR3aERsYTkwbDNBQ2g0eENWCks3Sk9YK3VIa29OdTNnMmlWeGlaVU0wQ0F3RUFBUT09Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo='; + +const PUBLIC_KEY_V3 = ''; + +let TEST_KEYS: [string, string] | undefined = undefined; + +export async function decrypt(encrypted: string): Promise { + if (process.env.NODE_ENV === 'test') { + if (encrypted.startsWith('RCV3_')) { + const jwt = encrypted.substring(5); + + TEST_KEYS = TEST_KEYS ?? (await getPairs()); + + if (!TEST_KEYS) { + throw new Error('Missing LICENSE_PUBLIC_KEY_V3'); + } + + const [spki] = TEST_KEYS; + + const [payload] = await verify(jwt, spki); + return JSON.stringify(payload); + } + } + + // handle V3 + if (encrypted.startsWith('RCV3_')) { + const jwt = encrypted.substring(5); + const [payload] = await verify(jwt, PUBLIC_KEY_V3); + + return JSON.stringify(payload); + } + + const decrypted = crypto.publicDecrypt(Buffer.from(PUBLIC_KEY_V2, 'base64').toString('utf-8'), Buffer.from(encrypted, 'base64')); + + return decrypted.toString('utf-8'); +} + +export async function encrypt(license: ILicenseV3): Promise { + if (process.env.NODE_ENV !== 'test') { + throw new Error('This function should only be used in tests'); + } + + TEST_KEYS = TEST_KEYS ?? (await getPairs()); + + if (!TEST_KEYS) { + throw new Error('Missing LICENSE_PUBLIC_KEY_V3'); + } + + const [, pkcs8] = TEST_KEYS; + + return `RCV3_${await sign(license, pkcs8)}`; +} diff --git a/apps/meteor/ee/app/license/server/bundles.ts b/ee/packages/license/src/v2/bundles.ts similarity index 100% rename from apps/meteor/ee/app/license/server/bundles.ts rename to ee/packages/license/src/v2/bundles.ts diff --git a/ee/packages/license/src/v2/convertToV3.ts b/ee/packages/license/src/v2/convertToV3.ts new file mode 100644 index 000000000000..7586f54c8c54 --- /dev/null +++ b/ee/packages/license/src/v2/convertToV3.ts @@ -0,0 +1,114 @@ +/** + * FromV2ToV3 + * 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 { isBundle, getBundleFromModule, getBundleModules } from './bundles'; +import { getTagColor } from './getTagColor'; + +export const convertToV3 = (v2: ILicenseV2): ILicenseV3 => { + return { + version: '3.0', + information: { + autoRenew: false, + visualExpiration: new Date(Date.parse(v2.meta?.trialEnd || v2.expiry)).toISOString(), + trial: v2.meta?.trial || false, + offline: false, + createdAt: new Date().toISOString(), + grantedBy: { + method: 'manual', + seller: 'V2', + }, + // if no tag present, it means it is an old license, so try check for bundles and use them as tags + tags: v2.tag + ? [v2.tag] + : [ + ...(v2.modules.filter(isBundle).map(getBundleFromModule).filter(Boolean) as string[]).map((tag) => ({ + name: tag, + color: getTagColor(tag), + })), + ], + }, + validation: { + serverUrls: [ + { + value: v2.url, + type: 'url', + }, + ], + validPeriods: [ + { + validUntil: new Date(Date.parse(v2.expiry)).toISOString(), + invalidBehavior: 'invalidate_license', + }, + ], + statisticsReport: { + required: true, + }, + }, + grantedModules: [ + ...new Set( + v2.modules + .map((licenseModule) => (isBundle(licenseModule) ? getBundleModules(licenseModule) : [licenseModule])) + .reduce((prev, curr) => [...prev, ...curr], []) + .map((licenseModule) => ({ module: licenseModule as LicenseModule })), + ), + ], + limits: { + ...(v2.maxActiveUsers + ? { + activeUsers: [ + { + max: v2.maxActiveUsers, + behavior: 'prevent_action', + }, + ], + } + : {}), + ...(v2.maxGuestUsers + ? { + guestUsers: [ + { + max: v2.maxGuestUsers, + behavior: 'prevent_action', + }, + ], + } + : {}), + ...(v2.maxRoomsPerGuest + ? { + roomsPerGuest: [ + { + max: v2.maxRoomsPerGuest, + behavior: 'prevent_action', + }, + ], + } + : {}), + ...(v2.apps?.maxPrivateApps + ? { + privateApps: [ + { + max: v2.apps.maxPrivateApps, + behavior: 'prevent_action', + }, + ], + } + : {}), + ...(v2.apps?.maxMarketplaceApps + ? { + marketplaceApps: [ + { + max: v2.apps.maxMarketplaceApps, + behavior: 'prevent_action', + }, + ], + } + : {}), + }, + cloudMeta: v2.meta, + }; +}; diff --git a/apps/meteor/ee/app/license/server/getTagColor.ts b/ee/packages/license/src/v2/getTagColor.ts similarity index 100% rename from apps/meteor/ee/app/license/server/getTagColor.ts rename to ee/packages/license/src/v2/getTagColor.ts diff --git a/ee/packages/license/src/validation/getCurrentValueForLicenseLimit.ts b/ee/packages/license/src/validation/getCurrentValueForLicenseLimit.ts new file mode 100644 index 000000000000..88cedc6c7bc9 --- /dev/null +++ b/ee/packages/license/src/validation/getCurrentValueForLicenseLimit.ts @@ -0,0 +1,40 @@ +import type { IUser } from '@rocket.chat/core-typings'; + +import type { LicenseLimitKind } from '../definition/ILicenseV3'; +import type { LicenseManager } from '../license'; +import { logger } from '../logger'; +import { applyPendingLicense, hasPendingLicense } from '../pendingLicense'; + +type LimitContext = T extends 'roomsPerGuest' ? { userId: IUser['_id'] } : Record; + +export function setLicenseLimitCounter( + this: LicenseManager, + limitKey: T, + fn: (context?: LimitContext) => Promise | number, +) { + this.dataCounters.set(limitKey, fn as (context?: LimitContext) => Promise); + + if (hasPendingLicense.call(this) && hasAllDataCounters.call(this)) { + void applyPendingLicense.call(this); + } +} + +export async function getCurrentValueForLicenseLimit( + this: LicenseManager, + limitKey: T, + context?: Partial>, +): Promise { + const counterFn = this.dataCounters.get(limitKey); + if (!counterFn) { + logger.error({ msg: 'Unable to validate license limit due to missing data counter.', limitKey }); + throw new Error('Unable to validate license limit due to missing data counter.'); + } + + return counterFn(context as LimitContext | undefined); +} + +export function hasAllDataCounters(this: LicenseManager) { + return ( + ['activeUsers', 'guestUsers', 'roomsPerGuest', 'privateApps', 'marketplaceApps', 'monthlyActiveContacts'] as LicenseLimitKind[] + ).every((limitKey) => this.dataCounters.has(limitKey)); +} diff --git a/ee/packages/license/src/validation/getModulesToDisable.ts b/ee/packages/license/src/validation/getModulesToDisable.ts new file mode 100644 index 000000000000..d42426e8af26 --- /dev/null +++ b/ee/packages/license/src/validation/getModulesToDisable.ts @@ -0,0 +1,15 @@ +import type { BehaviorWithContext, LicenseBehavior } from '../definition/LicenseBehavior'; +import type { LicenseModule } from '../definition/LicenseModule'; + +const filterValidationResult = (result: BehaviorWithContext[], expectedBehavior: LicenseBehavior) => + result.filter(({ behavior }) => behavior === expectedBehavior) as BehaviorWithContext[]; + +export const getModulesToDisable = (validationResult: BehaviorWithContext[]): LicenseModule[] => { + return [ + ...new Set([ + ...filterValidationResult(validationResult, 'disable_modules') + .map(({ modules }) => modules || []) + .flat(), + ]), + ]; +}; diff --git a/ee/packages/license/src/validation/getResultingBehavior.ts b/ee/packages/license/src/validation/getResultingBehavior.ts new file mode 100644 index 000000000000..47e2d91b8b89 --- /dev/null +++ b/ee/packages/license/src/validation/getResultingBehavior.ts @@ -0,0 +1,20 @@ +import type { BehaviorWithContext } from '../definition/LicenseBehavior'; +import type { LicenseLimit } from '../definition/LicenseLimit'; +import type { LicensePeriod } from '../definition/LicensePeriod'; + +export const getResultingBehavior = (data: LicenseLimit | LicensePeriod | Partial): BehaviorWithContext => { + const behavior = 'invalidBehavior' in data ? data.invalidBehavior : data.behavior; + + switch (behavior) { + case 'disable_modules': + return { + behavior, + modules: ('modules' in data && data.modules) || [], + }; + + default: + return { + behavior, + } as BehaviorWithContext; + } +}; diff --git a/ee/packages/license/src/validation/isBehaviorsInResult.ts b/ee/packages/license/src/validation/isBehaviorsInResult.ts new file mode 100644 index 000000000000..7e6ed89db8ec --- /dev/null +++ b/ee/packages/license/src/validation/isBehaviorsInResult.ts @@ -0,0 +1,4 @@ +import type { BehaviorWithContext, LicenseBehavior } from '../definition/LicenseBehavior'; + +export const isBehaviorsInResult = (result: BehaviorWithContext[], expectedBehaviors: LicenseBehavior[]) => + result.some(({ behavior }) => expectedBehaviors.includes(behavior)); diff --git a/ee/packages/license/src/validation/isReadyForValidation.ts b/ee/packages/license/src/validation/isReadyForValidation.ts new file mode 100644 index 000000000000..aa763bf7f353 --- /dev/null +++ b/ee/packages/license/src/validation/isReadyForValidation.ts @@ -0,0 +1,7 @@ +import type { LicenseManager } from '../license'; +import { hasAllDataCounters } from './getCurrentValueForLicenseLimit'; + +// Can only validate licenses once the workspace URL and the data counter functions are set +export function isReadyForValidation(this: LicenseManager) { + return Boolean(this.getWorkspaceUrl() && hasAllDataCounters.call(this)); +} diff --git a/ee/packages/license/src/validation/runValidation.spec.ts b/ee/packages/license/src/validation/runValidation.spec.ts new file mode 100644 index 000000000000..98797c86cd27 --- /dev/null +++ b/ee/packages/license/src/validation/runValidation.spec.ts @@ -0,0 +1,38 @@ +/** + * @jest-environment node + */ + +import { MockedLicenseBuilder, getReadyLicenseManager } from '../../__tests__/MockedLicenseBuilder'; +import { runValidation } from './runValidation'; + +describe('Validation behaviors', () => { + it('should return a behavior if the license period is invalid', async () => { + const licenseManager = await getReadyLicenseManager(); + + // two days ago + const validFrom = new Date(new Date().setDate(new Date().getDate() - 2)); + // one day ago + const validUntil = new Date(new Date().setDate(new Date().getDate() - 1)); + + const license = await new MockedLicenseBuilder().resetValidPeriods().withValidPeriod({ + validFrom: validFrom.toISOString(), + validUntil: validUntil.toISOString(), + invalidBehavior: 'disable_modules', + modules: ['livechat-enterprise'], + }); + + await expect( + runValidation.call(licenseManager, await license.build(), [ + 'invalidate_license', + 'prevent_installation', + 'start_fair_policy', + 'disable_modules', + ]), + ).resolves.toStrictEqual([ + { + behavior: 'disable_modules', + modules: ['livechat-enterprise'], + }, + ]); + }); +}); diff --git a/ee/packages/license/src/validation/runValidation.ts b/ee/packages/license/src/validation/runValidation.ts new file mode 100644 index 000000000000..9cb623b8eae0 --- /dev/null +++ b/ee/packages/license/src/validation/runValidation.ts @@ -0,0 +1,22 @@ +import type { ILicenseV3 } from '../definition/ILicenseV3'; +import type { LicenseBehavior, BehaviorWithContext } from '../definition/LicenseBehavior'; +import type { LicenseManager } from '../license'; +import { validateLicenseLimits } from './validateLicenseLimits'; +import { validateLicensePeriods } from './validateLicensePeriods'; +import { validateLicenseUrl } from './validateLicenseUrl'; + +export async function runValidation( + this: LicenseManager, + license: ILicenseV3, + behaviorsToValidate: LicenseBehavior[] = [], +): Promise { + const shouldValidateBehavior = (behavior: LicenseBehavior) => !behaviorsToValidate.length || behaviorsToValidate.includes(behavior); + + return [ + ...new Set([ + ...validateLicenseUrl.call(this, license, shouldValidateBehavior), + ...validateLicensePeriods(license, shouldValidateBehavior), + ...(await validateLicenseLimits.call(this, license, shouldValidateBehavior)), + ]), + ]; +} diff --git a/ee/packages/license/src/validation/validateFormat.ts b/ee/packages/license/src/validation/validateFormat.ts new file mode 100644 index 000000000000..a8c2488cd9fc --- /dev/null +++ b/ee/packages/license/src/validation/validateFormat.ts @@ -0,0 +1,16 @@ +import { InvalidLicenseError } from '../errors/InvalidLicenseError'; +import { decrypt } from '../token'; + +export const validateFormat = async (encryptedLicense: string): Promise => { + if (!encryptedLicense || String(encryptedLicense).trim() === '') { + throw new InvalidLicenseError('Empty license'); + } + + try { + await decrypt(encryptedLicense); + } catch (e) { + throw new InvalidLicenseError(); + } + + return true; +}; diff --git a/ee/packages/license/src/validation/validateLicenseLimits.ts b/ee/packages/license/src/validation/validateLicenseLimits.ts new file mode 100644 index 000000000000..168effe6a250 --- /dev/null +++ b/ee/packages/license/src/validation/validateLicenseLimits.ts @@ -0,0 +1,39 @@ +import type { ILicenseV3 } from '../definition/ILicenseV3'; +import type { BehaviorWithContext, LicenseBehavior } from '../definition/LicenseBehavior'; +import type { LicenseManager } from '../license'; +import { logger } from '../logger'; +import { getCurrentValueForLicenseLimit } from './getCurrentValueForLicenseLimit'; +import { getResultingBehavior } from './getResultingBehavior'; + +export async function validateLicenseLimits( + this: LicenseManager, + license: ILicenseV3, + behaviorFilter: (behavior: LicenseBehavior) => boolean, +): Promise { + const { limits } = license; + + const limitKeys = Object.keys(limits) as (keyof ILicenseV3['limits'])[]; + return ( + await Promise.all( + limitKeys.map(async (limitKey) => { + // Filter the limit list before running any query in the database so we don't end up loading some value we won't use. + const limitList = limits[limitKey]?.filter(({ behavior, max }) => max >= 0 && behaviorFilter(behavior)); + if (!limitList?.length) { + return []; + } + + const currentValue = await getCurrentValueForLicenseLimit.call(this, limitKey); + return limitList + .filter(({ max }) => max < currentValue) + .map((limit) => { + logger.error({ + msg: 'Limit validation failed', + kind: limitKey, + limit, + }); + return getResultingBehavior(limit); + }); + }), + ) + ).flat(); +} diff --git a/ee/packages/license/src/validation/validateLicensePeriods.ts b/ee/packages/license/src/validation/validateLicensePeriods.ts new file mode 100644 index 000000000000..5b3fae433e38 --- /dev/null +++ b/ee/packages/license/src/validation/validateLicensePeriods.ts @@ -0,0 +1,38 @@ +import type { ILicenseV3 } from '../definition/ILicenseV3'; +import type { BehaviorWithContext, LicenseBehavior } from '../definition/LicenseBehavior'; +import type { Timestamp } from '../definition/LicensePeriod'; +import { logger } from '../logger'; +import { getResultingBehavior } from './getResultingBehavior'; + +export const isPeriodInvalid = (from: Timestamp | undefined, until: Timestamp | undefined) => { + const now = new Date(); + + if (from && now < new Date(from)) { + return true; + } + + if (until && now > new Date(until)) { + return true; + } + + return false; +}; + +export const validateLicensePeriods = ( + license: ILicenseV3, + behaviorFilter: (behavior: LicenseBehavior) => boolean, +): BehaviorWithContext[] => { + const { + validation: { validPeriods }, + } = license; + + return validPeriods + .filter(({ validFrom, validUntil, invalidBehavior }) => behaviorFilter(invalidBehavior) && isPeriodInvalid(validFrom, validUntil)) + .map((period) => { + logger.error({ + msg: 'Period validation failed', + period, + }); + return getResultingBehavior(period); + }); +}; diff --git a/ee/packages/license/src/validation/validateLicenseUrl.ts b/ee/packages/license/src/validation/validateLicenseUrl.ts new file mode 100644 index 000000000000..55cd076c4378 --- /dev/null +++ b/ee/packages/license/src/validation/validateLicenseUrl.ts @@ -0,0 +1,59 @@ +import type { ILicenseV3 } from '../definition/ILicenseV3'; +import type { BehaviorWithContext, LicenseBehavior } from '../definition/LicenseBehavior'; +import type { LicenseManager } from '../license'; +import { logger } from '../logger'; +import { getResultingBehavior } from './getResultingBehavior'; + +export const validateUrl = (licenseURL: string, url: string) => { + licenseURL = licenseURL + .replace(/\./g, '\\.') // convert dots to literal + .replace(/\*/g, '.*'); // convert * to .* + const regex = new RegExp(`^${licenseURL}$`, 'i'); + + return !!regex.exec(url); +}; + +export function validateLicenseUrl( + this: LicenseManager, + license: ILicenseV3, + behaviorFilter: (behavior: LicenseBehavior) => boolean, +): BehaviorWithContext[] { + if (!behaviorFilter('invalidate_license')) { + return []; + } + + const { + validation: { serverUrls }, + } = license; + + const workspaceUrl = this.getWorkspaceUrl(); + + if (!workspaceUrl) { + logger.error('Unable to validate license URL without knowing the workspace URL.'); + return [getResultingBehavior({ behavior: 'invalidate_license' })]; + } + + return serverUrls + .filter((url) => { + switch (url.type) { + case 'regex': + // #TODO + break; + case 'hash': + // #TODO + break; + case 'url': + return !validateUrl(url.value, workspaceUrl); + } + + return false; + }) + .map((url) => { + logger.error({ + msg: 'Url validation failed', + url, + workspaceUrl, + }); + return getResultingBehavior({ behavior: 'invalidate_license' }); + }); +} diff --git a/ee/packages/license/tsconfig.json b/ee/packages/license/tsconfig.json new file mode 100644 index 000000000000..539d1c0af1b8 --- /dev/null +++ b/ee/packages/license/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../../tsconfig.base.server.json", + "compilerOptions": { + "declaration": true, + "rootDir": "./src", + "outDir": "./dist" + }, + "include": ["./src/**/*"] +} diff --git a/ee/packages/omnichannel-services/src/OmnichannelTranscript.ts b/ee/packages/omnichannel-services/src/OmnichannelTranscript.ts index 802a6e15d0eb..899d298fb445 100644 --- a/ee/packages/omnichannel-services/src/OmnichannelTranscript.ts +++ b/ee/packages/omnichannel-services/src/OmnichannelTranscript.ts @@ -78,7 +78,7 @@ export class OmnichannelTranscript extends ServiceClass implements IOmnichannelT async started(): Promise { try { - this.shouldWork = await licenseService.hasLicense('scalability'); + this.shouldWork = await licenseService.hasModule('scalability'); } catch (e: unknown) { // ignore } diff --git a/ee/packages/omnichannel-services/src/QueueWorker.ts b/ee/packages/omnichannel-services/src/QueueWorker.ts index 141cb937f475..bfb69362fac6 100644 --- a/ee/packages/omnichannel-services/src/QueueWorker.ts +++ b/ee/packages/omnichannel-services/src/QueueWorker.ts @@ -35,7 +35,7 @@ export class QueueWorker extends ServiceClass implements IQueueWorkerService { async started(): Promise { try { - this.shouldWork = await License.hasLicense('scalability'); + this.shouldWork = await License.hasModule('scalability'); } catch (e: unknown) { // ignore } diff --git a/ee/packages/presence/src/Presence.ts b/ee/packages/presence/src/Presence.ts index 238cd445def4..fb656fc3e158 100755 --- a/ee/packages/presence/src/Presence.ts +++ b/ee/packages/presence/src/Presence.ts @@ -65,7 +65,7 @@ export class Presence extends ServiceClass implements IPresence { try { await Settings.updateValueById('Presence_broadcast_disabled', false); - this.hasLicense = await License.hasLicense('scalability'); + this.hasLicense = await License.hasModule('scalability'); } catch (e: unknown) { // ignore } diff --git a/packages/core-services/src/types/ILicense.ts b/packages/core-services/src/types/ILicense.ts index 7b89a006bfc0..c9247f8887ce 100644 --- a/packages/core-services/src/types/ILicense.ts +++ b/packages/core-services/src/types/ILicense.ts @@ -1,9 +1,9 @@ import type { IServiceClass } from './ServiceClass'; export interface ILicense extends IServiceClass { - hasLicense(feature: string): boolean; + hasModule(feature: string): boolean; - isEnterprise(): boolean; + hasValidLicense(): boolean; getModules(): string[]; diff --git a/packages/core-typings/src/ee/ILicense/ILicense.ts b/packages/core-typings/src/ee/ILicense/ILicense.ts deleted file mode 100644 index 8490ab1d7cbe..000000000000 --- a/packages/core-typings/src/ee/ILicense/ILicense.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { ILicenseTag } from './ILicenseTag'; - -export interface ILicense { - url: string; - expiry: string; - maxActiveUsers: number; - modules: string[]; - maxGuestUsers: number; - maxRoomsPerGuest: number; - tag?: ILicenseTag; - meta?: { - trial: boolean; - trialEnd: string; - workspaceId: string; - }; - apps?: { - maxPrivateApps: number; - maxMarketplaceApps: number; - }; -} diff --git a/packages/core-typings/src/ee/ILicense/ILicenseTag.ts b/packages/core-typings/src/ee/ILicense/ILicenseTag.ts deleted file mode 100644 index 2f11fdebd5db..000000000000 --- a/packages/core-typings/src/ee/ILicense/ILicenseTag.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface ILicenseTag { - name: string; - color: string; -} diff --git a/packages/core-typings/src/index.ts b/packages/core-typings/src/index.ts index 8cd004dd09f1..459e5680900b 100644 --- a/packages/core-typings/src/index.ts +++ b/packages/core-typings/src/index.ts @@ -39,7 +39,6 @@ export * from './IUserSession'; export * from './IUserStatus'; export * from './IUser'; -export * from './ee/ILicense/ILicense'; export * from './ee/IAuditLog'; export * from './import'; diff --git a/packages/jwt/.eslintrc.json b/packages/jwt/.eslintrc.json new file mode 100644 index 000000000000..a83aeda48e66 --- /dev/null +++ b/packages/jwt/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": ["@rocket.chat/eslint-config"], + "ignorePatterns": ["**/dist"] +} diff --git a/packages/jwt/__tests__/jwt.spec.ts b/packages/jwt/__tests__/jwt.spec.ts new file mode 100644 index 000000000000..302cfdf22c96 --- /dev/null +++ b/packages/jwt/__tests__/jwt.spec.ts @@ -0,0 +1,90 @@ +import { generateKeyPair, exportPKCS8, exportSPKI } from 'jose'; + +import { sign, verify } from '../src/index'; + +it('should sign and verify a jwt with RS256', async () => { + const { publicKey, privateKey } = await generateKeyPair('RS256'); + const spki = await exportSPKI(publicKey); + const pkcs8 = await exportPKCS8(privateKey); + + const licenseV3 = { + information: { + id: '64d28d096400df50b6ace670', + autoRenew: true, + createdAt: '2023-08-08T18:44:25.719+0000', + visualExpiration: '2024-09-08T18:44:25.719+0000', + notifyAdminsAt: '2024-09-01T18:44:25.719+0000', + notifyUsersAt: '2024-09-05T18:44:25.719+0000', + trial: false, + offline: false, + grantedBy: { method: 'manual', seller: 'john.rocketseed@rocket.chat' }, + grantedTo: { name: 'Alice Clientseed', company: 'Client', email: 'alice.clientseed@client.com' }, + legalText: "This license can't be used for reselling", + notes: 'Plan Premium', + tags: [{ name: 'Enterprise', color: '#CCCCCC' }], + }, + validation: { + serverUrls: [{ value: 'https://localhost:3000', type: 'url' }], + serverVersions: [{ value: '6.4' }], + cloudWorkspaceId: 'alks-a9sj0diba09shdiasodjha9s0diha9s9duabsiuhdai0sdh0a9hs09da09s8d09a80s9d8', + serverUniqueId: '64d28d096400df50b6ace670', + validUntil: '2024-09-18T18:44:25.719+0000', + validFrom: '2024-07-08T18:44:25.719+0000', + installationAllowedUntil: '2024-07-09T18:44:25.719+0000', + legalTextAgreement: { type: 'accepted', acceptedVia: 'cloud' }, + statisticsReport: { required: true, allowedStaleInDays: 5 }, + }, + grantedModules: [ + { module: 'auditing' }, + { module: 'canned-responses' }, + { module: 'ldap-enterprise' }, + { module: 'livechat-enterprise' }, + { module: 'voip-enterprise' }, + { module: 'omnichannel-mobile-enterprise' }, + { module: 'engagement-dashboard' }, + { module: 'push-privacy' }, + { module: 'scalability' }, + { module: 'teams-mention' }, + { module: 'saml-enterprise' }, + { module: 'oauth-enterprise' }, + { module: 'device-management' }, + { module: 'federation' }, + { module: 'videoconference-enterprise' }, + { module: 'message-read-receipt' }, + { module: 'outlook-calendar' }, + ], + limits: { + activeUsers: [ + { max: 500, behavior: 'start_fair_policy' }, + { max: 1000, behavior: 'prevent_action' }, + { max: 1100, behavior: 'invalidate_license' }, + ], + guestUsers: [ + { max: 200, behavior: 'start_fair_policy' }, + { max: 400, behavior: 'prevent_action' }, + { max: 500, behavior: 'invalidate_license' }, + ], + roomsPerGuest: [ + { max: 5, behavior: 'start_fair_policy' }, + { max: 10, behavior: 'prevent_action' }, + ], + privateApps: [ + { max: 5, behavior: 'start_fair_policy' }, + { max: 10, behavior: 'prevent_action' }, + { max: 11, behavior: 'invalidate_license' }, + ], + marketplaceApps: [ + { max: 5, behavior: 'start_fair_policy' }, + { max: 10, behavior: 'prevent_action' }, + { max: 11, behavior: 'invalidate_license' }, + ], + }, + cloudMeta: { lastStatisticId: '64d28d096400df50b6ace671' }, + }; + + const token = await sign(licenseV3, pkcs8); + const [payload, protectedHeader] = await verify(token, spki); + + expect(protectedHeader).toEqual({ alg: 'RS256', typ: 'JWT' }); + expect(payload).toEqual(licenseV3); +}); diff --git a/packages/jwt/jest.config.js b/packages/jwt/jest.config.js new file mode 100644 index 000000000000..6231bde11685 --- /dev/null +++ b/packages/jwt/jest.config.js @@ -0,0 +1,5 @@ +/** @type {import('ts-jest').JestConfigWithTsJest} */ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node', +}; diff --git a/packages/jwt/package.json b/packages/jwt/package.json new file mode 100644 index 000000000000..b6be368917c3 --- /dev/null +++ b/packages/jwt/package.json @@ -0,0 +1,31 @@ +{ + "name": "@rocket.chat/jwt", + "version": "0.0.1", + "private": true, + "devDependencies": { + "@types/jest": "~29.5.3", + "eslint": "~8.45.0", + "jest": "~29.6.1", + "ts-jest": "^29.1.1", + "typescript": "~5.2.2" + }, + "scripts": { + "lint": "eslint --ext .js,.jsx,.ts,.tsx .", + "lint:fix": "eslint --ext .js,.jsx,.ts,.tsx . --fix", + "test": "jest", + "testunit": "jest", + "build": "rm -rf dist && tsc -p tsconfig.json", + "dev": "tsc -p tsconfig.json --watch --preserveWatchOutput" + }, + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "files": [ + "/dist" + ], + "volta": { + "extends": "../../package.json" + }, + "dependencies": { + "jose": "^4.14.4" + } +} diff --git a/packages/jwt/src/index.ts b/packages/jwt/src/index.ts new file mode 100644 index 000000000000..3508471f9d81 --- /dev/null +++ b/packages/jwt/src/index.ts @@ -0,0 +1,29 @@ +import { SignJWT, importPKCS8, jwtVerify, importSPKI, generateKeyPair, exportSPKI, exportPKCS8 } from 'jose'; +import type { JWTPayload } from 'jose'; + +export async function sign(keyObject: object, pkcs8: string, alg = 'RS256') { + const privateKey = await importPKCS8(pkcs8, alg); + + const token = await new SignJWT(keyObject as JWTPayload).setProtectedHeader({ alg, typ: 'JWT' }).sign(privateKey); + + return token; +} + +export async function verify(jwt: string, spki: string, alg = 'RS256') { + const publicKey = await importSPKI(spki, alg); + + const { payload, protectedHeader } = await jwtVerify(jwt, publicKey, {}); + + return [payload, protectedHeader]; +} + +export async function getPairs(): Promise<[string, string]> { + if (process.env.NODE_ENV !== 'test') { + throw new Error('This function should only be used in tests'); + } + const { publicKey, privateKey } = await generateKeyPair('RS256'); + const spki = await exportSPKI(publicKey); + const pkcs8 = await exportPKCS8(privateKey); + + return [spki, pkcs8]; +} diff --git a/packages/jwt/tsconfig.json b/packages/jwt/tsconfig.json new file mode 100644 index 000000000000..f236186070e8 --- /dev/null +++ b/packages/jwt/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.server.json", + "compilerOptions": { + "declaration": true, + "module": "commonjs", + "rootDir": "./src", + "outDir": "./dist" + }, + "include": ["./src/**/*"] +} diff --git a/packages/model-typings/src/models/IUsersModel.ts b/packages/model-typings/src/models/IUsersModel.ts index c0ce51f79f45..1ee2a432c3df 100644 --- a/packages/model-typings/src/models/IUsersModel.ts +++ b/packages/model-typings/src/models/IUsersModel.ts @@ -372,7 +372,7 @@ export interface IUsersModel extends IBaseModel { getUsersToSendOfflineEmail(userIds: string[]): FindCursor>; countActiveUsersByService(service: string, options?: FindOptions): Promise; getActiveLocalUserCount(): Promise; - getActiveLocalGuestCount(): Promise; + getActiveLocalGuestCount(exceptions?: IUser['_id'] | IUser['_id'][]): Promise; removeOlderResumeTokensByUserId(userId: string, fromDate: Date): Promise; findAllUsersWithPendingAvatar(): FindCursor; updateCustomFieldsById(userId: string, customFields: Record): Promise; diff --git a/packages/rest-typings/package.json b/packages/rest-typings/package.json index 8b6f60f294b3..9da7694d28b9 100644 --- a/packages/rest-typings/package.json +++ b/packages/rest-typings/package.json @@ -26,6 +26,7 @@ "dependencies": { "@rocket.chat/apps-engine": "1.41.0-alpha.290", "@rocket.chat/core-typings": "workspace:^", + "@rocket.chat/license": "workspace:^", "@rocket.chat/message-parser": "next", "@rocket.chat/ui-kit": "^0.32.1", "ajv": "^8.11.0", diff --git a/packages/rest-typings/src/v1/licenses.ts b/packages/rest-typings/src/v1/licenses.ts index c6d102a967e4..96c67e2654bb 100644 --- a/packages/rest-typings/src/v1/licenses.ts +++ b/packages/rest-typings/src/v1/licenses.ts @@ -1,4 +1,4 @@ -import type { ILicense } from '@rocket.chat/core-typings'; +import type { ILicenseV2, ILicenseV3 } from '@rocket.chat/license'; import Ajv from 'ajv'; const ajv = new Ajv({ @@ -24,7 +24,7 @@ export const isLicensesAddProps = ajv.compile(licensesAddProps export type LicensesEndpoints = { '/v1/licenses.get': { - GET: () => { licenses: Array }; + GET: () => { licenses: Array }; }; '/v1/licenses.add': { POST: (params: licensesAddProps) => void; diff --git a/yarn.lock b/yarn.lock index 145079c6eb7a..a3d8d34c8906 100644 --- a/yarn.lock +++ b/yarn.lock @@ -966,6 +966,33 @@ __metadata: languageName: node linkType: hard +"@babel/cli@npm:^7.23.0": + version: 7.23.0 + resolution: "@babel/cli@npm:7.23.0" + dependencies: + "@jridgewell/trace-mapping": ^0.3.17 + "@nicolo-ribaudo/chokidar-2": 2.1.8-no-fsevents.3 + chokidar: ^3.4.0 + commander: ^4.0.1 + convert-source-map: ^2.0.0 + fs-readdir-recursive: ^1.1.0 + glob: ^7.2.0 + make-dir: ^2.1.0 + slash: ^2.0.0 + peerDependencies: + "@babel/core": ^7.0.0-0 + dependenciesMeta: + "@nicolo-ribaudo/chokidar-2": + optional: true + chokidar: + optional: true + bin: + babel: ./bin/babel.js + babel-external-helpers: ./bin/babel-external-helpers.js + checksum: beeb189560bf9c4ea951ef637eefa5214654678fb09c4aaa6695921037059c1e1553c610fe95fbd19a9cdfd9f5598a812fc13df40a6b9a9ea899e43fc6c42052 + languageName: node + linkType: hard + "@babel/code-frame@npm:7.12.11": version: 7.12.11 resolution: "@babel/code-frame@npm:7.12.11" @@ -975,20 +1002,20 @@ __metadata: languageName: node linkType: hard -"@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.10.4, @babel/code-frame@npm:^7.12.13, @babel/code-frame@npm:^7.22.10, @babel/code-frame@npm:^7.22.5, @babel/code-frame@npm:^7.5.5, @babel/code-frame@npm:^7.8.3": - version: 7.22.10 - resolution: "@babel/code-frame@npm:7.22.10" +"@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.10.4, @babel/code-frame@npm:^7.12.13, @babel/code-frame@npm:^7.22.10, @babel/code-frame@npm:^7.22.13, @babel/code-frame@npm:^7.5.5, @babel/code-frame@npm:^7.8.3": + version: 7.22.13 + resolution: "@babel/code-frame@npm:7.22.13" dependencies: - "@babel/highlight": ^7.22.10 + "@babel/highlight": ^7.22.13 chalk: ^2.4.2 - checksum: 89a06534ad19759da6203a71bad120b1d7b2ddc016c8e07d4c56b35dea25e7396c6da60a754e8532a86733092b131ae7f661dbe6ba5d165ea777555daa2ed3c9 + checksum: 22e342c8077c8b77eeb11f554ecca2ba14153f707b85294fcf6070b6f6150aae88a7b7436dd88d8c9289970585f3fe5b9b941c5aa3aa26a6d5a8ef3f292da058 languageName: node linkType: hard -"@babel/compat-data@npm:^7.20.5, @babel/compat-data@npm:^7.22.5, @babel/compat-data@npm:^7.22.6, @babel/compat-data@npm:^7.22.9": - version: 7.22.9 - resolution: "@babel/compat-data@npm:7.22.9" - checksum: bed77d9044ce948b4327b30dd0de0779fa9f3a7ed1f2d31638714ed00229fa71fc4d1617ae0eb1fad419338d3658d0e9a5a083297451e09e73e078d0347ff808 +"@babel/compat-data@npm:^7.20.5, @babel/compat-data@npm:^7.22.20, @babel/compat-data@npm:^7.22.6, @babel/compat-data@npm:^7.22.9": + version: 7.22.20 + resolution: "@babel/compat-data@npm:7.22.20" + checksum: efedd1d18878c10fde95e4d82b1236a9aba41395ef798cbb651f58dbf5632dbff475736c507b8d13d4c8f44809d41c0eb2ef0d694283af9ba5dd8339b6dab451 languageName: node linkType: hard @@ -1016,7 +1043,30 @@ __metadata: languageName: node linkType: hard -"@babel/core@npm:^7.1.0, @babel/core@npm:^7.11.6, @babel/core@npm:^7.12.10, @babel/core@npm:^7.12.3, @babel/core@npm:^7.20.7, @babel/core@npm:^7.21.4, @babel/core@npm:^7.7.5, @babel/core@npm:~7.22.10, @babel/core@npm:~7.22.9": +"@babel/core@npm:^7.1.0, @babel/core@npm:^7.11.6, @babel/core@npm:^7.12.10, @babel/core@npm:^7.12.3, @babel/core@npm:^7.20.7, @babel/core@npm:^7.21.4, @babel/core@npm:^7.23.0, @babel/core@npm:^7.7.5": + version: 7.23.0 + resolution: "@babel/core@npm:7.23.0" + dependencies: + "@ampproject/remapping": ^2.2.0 + "@babel/code-frame": ^7.22.13 + "@babel/generator": ^7.23.0 + "@babel/helper-compilation-targets": ^7.22.15 + "@babel/helper-module-transforms": ^7.23.0 + "@babel/helpers": ^7.23.0 + "@babel/parser": ^7.23.0 + "@babel/template": ^7.22.15 + "@babel/traverse": ^7.23.0 + "@babel/types": ^7.23.0 + convert-source-map: ^2.0.0 + debug: ^4.1.0 + gensync: ^1.0.0-beta.2 + json5: ^2.2.3 + semver: ^6.3.1 + checksum: cebd9b48dbc970a7548522f207f245c69567e5ea17ebb1a4e4de563823cf20a01177fe8d2fe19b6e1461361f92fa169fd0b29f8ee9d44eeec84842be1feee5f2 + languageName: node + linkType: hard + +"@babel/core@npm:~7.22.10, @babel/core@npm:~7.22.9": version: 7.22.10 resolution: "@babel/core@npm:7.22.10" dependencies: @@ -1053,15 +1103,15 @@ __metadata: languageName: node linkType: hard -"@babel/generator@npm:^7.12.11, @babel/generator@npm:^7.12.5, @babel/generator@npm:^7.22.10, @babel/generator@npm:^7.7.2": - version: 7.22.10 - resolution: "@babel/generator@npm:7.22.10" +"@babel/generator@npm:^7.12.11, @babel/generator@npm:^7.12.5, @babel/generator@npm:^7.22.10, @babel/generator@npm:^7.23.0, @babel/generator@npm:^7.7.2": + version: 7.23.0 + resolution: "@babel/generator@npm:7.23.0" dependencies: - "@babel/types": ^7.22.10 + "@babel/types": ^7.23.0 "@jridgewell/gen-mapping": ^0.3.2 "@jridgewell/trace-mapping": ^0.3.17 jsesc: ^2.5.1 - checksum: 59a79730abdff9070692834bd3af179e7a9413fa2ff7f83dff3eb888765aeaeb2bfc7b0238a49613ed56e1af05956eff303cc139f2407eda8df974813e486074 + checksum: 8efe24adad34300f1f8ea2add420b28171a646edc70f2a1b3e1683842f23b8b7ffa7e35ef0119294e1901f45bfea5b3dc70abe1f10a1917ccdfb41bed69be5f1 languageName: node linkType: hard @@ -1083,35 +1133,35 @@ __metadata: languageName: node linkType: hard -"@babel/helper-compilation-targets@npm:^7.13.0, @babel/helper-compilation-targets@npm:^7.20.7, @babel/helper-compilation-targets@npm:^7.22.10, @babel/helper-compilation-targets@npm:^7.22.5, @babel/helper-compilation-targets@npm:^7.22.6": - version: 7.22.10 - resolution: "@babel/helper-compilation-targets@npm:7.22.10" +"@babel/helper-compilation-targets@npm:^7.13.0, @babel/helper-compilation-targets@npm:^7.20.7, @babel/helper-compilation-targets@npm:^7.22.10, @babel/helper-compilation-targets@npm:^7.22.15, @babel/helper-compilation-targets@npm:^7.22.5, @babel/helper-compilation-targets@npm:^7.22.6": + version: 7.22.15 + resolution: "@babel/helper-compilation-targets@npm:7.22.15" dependencies: "@babel/compat-data": ^7.22.9 - "@babel/helper-validator-option": ^7.22.5 + "@babel/helper-validator-option": ^7.22.15 browserslist: ^4.21.9 lru-cache: ^5.1.1 semver: ^6.3.1 - checksum: f6f1896816392bcff671bbe6e277307729aee53befb4a66ea126e2a91eda78d819a70d06fa384c74ef46c1595544b94dca50bef6c78438d9ffd31776dafbd435 + checksum: ce85196769e091ae54dd39e4a80c2a9df1793da8588e335c383d536d54f06baf648d0a08fc873044f226398c4ded15c4ae9120ee18e7dfd7c639a68e3cdc9980 languageName: node linkType: hard -"@babel/helper-create-class-features-plugin@npm:^7.17.6, @babel/helper-create-class-features-plugin@npm:^7.18.6, @babel/helper-create-class-features-plugin@npm:^7.21.0, @babel/helper-create-class-features-plugin@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/helper-create-class-features-plugin@npm:7.22.5" +"@babel/helper-create-class-features-plugin@npm:^7.17.6, @babel/helper-create-class-features-plugin@npm:^7.18.6, @babel/helper-create-class-features-plugin@npm:^7.21.0, @babel/helper-create-class-features-plugin@npm:^7.22.11, @babel/helper-create-class-features-plugin@npm:^7.22.15, @babel/helper-create-class-features-plugin@npm:^7.22.5": + version: 7.22.15 + resolution: "@babel/helper-create-class-features-plugin@npm:7.22.15" dependencies: "@babel/helper-annotate-as-pure": ^7.22.5 "@babel/helper-environment-visitor": ^7.22.5 "@babel/helper-function-name": ^7.22.5 - "@babel/helper-member-expression-to-functions": ^7.22.5 + "@babel/helper-member-expression-to-functions": ^7.22.15 "@babel/helper-optimise-call-expression": ^7.22.5 - "@babel/helper-replace-supers": ^7.22.5 + "@babel/helper-replace-supers": ^7.22.9 "@babel/helper-skip-transparent-expression-wrappers": ^7.22.5 - "@babel/helper-split-export-declaration": ^7.22.5 - semver: ^6.3.0 + "@babel/helper-split-export-declaration": ^7.22.6 + semver: ^6.3.1 peerDependencies: "@babel/core": ^7.0.0 - checksum: f1e91deae06dbee6dd956c0346bca600adfbc7955427795d9d8825f0439a3c3290c789ba2b4a02a1cdf6c1a1bd163dfa16d3d5e96b02a8efb639d2a774e88ed9 + checksum: 52c500d8d164abb3a360b1b7c4b8fff77bc4a5920d3a2b41ae6e1d30617b0dc0b972c1f5db35b1752007e04a748908b4a99bc872b73549ae837e87dcdde005a3 languageName: node linkType: hard @@ -1161,20 +1211,20 @@ __metadata: languageName: node linkType: hard -"@babel/helper-environment-visitor@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/helper-environment-visitor@npm:7.22.5" - checksum: 248532077d732a34cd0844eb7b078ff917c3a8ec81a7f133593f71a860a582f05b60f818dc5049c2212e5baa12289c27889a4b81d56ef409b4863db49646c4b1 +"@babel/helper-environment-visitor@npm:^7.22.20, @babel/helper-environment-visitor@npm:^7.22.5": + version: 7.22.20 + resolution: "@babel/helper-environment-visitor@npm:7.22.20" + checksum: d80ee98ff66f41e233f36ca1921774c37e88a803b2f7dca3db7c057a5fea0473804db9fb6729e5dbfd07f4bed722d60f7852035c2c739382e84c335661590b69 languageName: node linkType: hard -"@babel/helper-function-name@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/helper-function-name@npm:7.22.5" +"@babel/helper-function-name@npm:^7.22.5, @babel/helper-function-name@npm:^7.23.0": + version: 7.23.0 + resolution: "@babel/helper-function-name@npm:7.23.0" dependencies: - "@babel/template": ^7.22.5 - "@babel/types": ^7.22.5 - checksum: 6b1f6ce1b1f4e513bf2c8385a557ea0dd7fa37971b9002ad19268ca4384bbe90c09681fe4c076013f33deabc63a53b341ed91e792de741b4b35e01c00238177a + "@babel/template": ^7.22.15 + "@babel/types": ^7.23.0 + checksum: e44542257b2d4634a1f979244eb2a4ad8e6d75eb6761b4cfceb56b562f7db150d134bc538c8e6adca3783e3bc31be949071527aa8e3aab7867d1ad2d84a26e10 languageName: node linkType: hard @@ -1187,36 +1237,36 @@ __metadata: languageName: node linkType: hard -"@babel/helper-member-expression-to-functions@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/helper-member-expression-to-functions@npm:7.22.5" +"@babel/helper-member-expression-to-functions@npm:^7.22.15": + version: 7.23.0 + resolution: "@babel/helper-member-expression-to-functions@npm:7.23.0" dependencies: - "@babel/types": ^7.22.5 - checksum: 4bd5791529c280c00743e8bdc669ef0d4cd1620d6e3d35e0d42b862f8262bc2364973e5968007f960780344c539a4b9cf92ab41f5b4f94560a9620f536de2a39 + "@babel/types": ^7.23.0 + checksum: 494659361370c979ada711ca685e2efe9460683c36db1b283b446122596602c901e291e09f2f980ecedfe6e0f2bd5386cb59768285446530df10c14df1024e75 languageName: node linkType: hard -"@babel/helper-module-imports@npm:^7.12.13, @babel/helper-module-imports@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/helper-module-imports@npm:7.22.5" +"@babel/helper-module-imports@npm:^7.12.13, @babel/helper-module-imports@npm:^7.22.15, @babel/helper-module-imports@npm:^7.22.5": + version: 7.22.15 + resolution: "@babel/helper-module-imports@npm:7.22.15" dependencies: - "@babel/types": ^7.22.5 - checksum: 9ac2b0404fa38b80bdf2653fbeaf8e8a43ccb41bd505f9741d820ed95d3c4e037c62a1bcdcb6c9527d7798d2e595924c4d025daed73283badc180ada2c9c49ad + "@babel/types": ^7.22.15 + checksum: ecd7e457df0a46f889228f943ef9b4a47d485d82e030676767e6a2fdcbdaa63594d8124d4b55fd160b41c201025aec01fc27580352b1c87a37c9c6f33d116702 languageName: node linkType: hard -"@babel/helper-module-transforms@npm:^7.12.1, @babel/helper-module-transforms@npm:^7.22.5, @babel/helper-module-transforms@npm:^7.22.9": - version: 7.22.9 - resolution: "@babel/helper-module-transforms@npm:7.22.9" +"@babel/helper-module-transforms@npm:^7.12.1, @babel/helper-module-transforms@npm:^7.22.5, @babel/helper-module-transforms@npm:^7.22.9, @babel/helper-module-transforms@npm:^7.23.0": + version: 7.23.0 + resolution: "@babel/helper-module-transforms@npm:7.23.0" dependencies: - "@babel/helper-environment-visitor": ^7.22.5 - "@babel/helper-module-imports": ^7.22.5 + "@babel/helper-environment-visitor": ^7.22.20 + "@babel/helper-module-imports": ^7.22.15 "@babel/helper-simple-access": ^7.22.5 "@babel/helper-split-export-declaration": ^7.22.6 - "@babel/helper-validator-identifier": ^7.22.5 + "@babel/helper-validator-identifier": ^7.22.20 peerDependencies: "@babel/core": ^7.0.0 - checksum: 2751f77660518cf4ff027514d6f4794f04598c6393be7b04b8e46c6e21606e11c19f3f57ab6129a9c21bacdf8b3ffe3af87bb401d972f34af2d0ffde02ac3001 + checksum: 6e2afffb058cf3f8ce92f5116f710dda4341c81cfcd872f9a0197ea594f7ce0ab3cb940b0590af2fe99e60d2e5448bfba6bca8156ed70a2ed4be2adc8586c891 languageName: node linkType: hard @@ -1256,17 +1306,16 @@ __metadata: languageName: node linkType: hard -"@babel/helper-replace-supers@npm:^7.16.7, @babel/helper-replace-supers@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/helper-replace-supers@npm:7.22.5" +"@babel/helper-replace-supers@npm:^7.16.7, @babel/helper-replace-supers@npm:^7.22.5, @babel/helper-replace-supers@npm:^7.22.9": + version: 7.22.20 + resolution: "@babel/helper-replace-supers@npm:7.22.20" dependencies: - "@babel/helper-environment-visitor": ^7.22.5 - "@babel/helper-member-expression-to-functions": ^7.22.5 + "@babel/helper-environment-visitor": ^7.22.20 + "@babel/helper-member-expression-to-functions": ^7.22.15 "@babel/helper-optimise-call-expression": ^7.22.5 - "@babel/template": ^7.22.5 - "@babel/traverse": ^7.22.5 - "@babel/types": ^7.22.5 - checksum: af29deff6c6dc3fa2d1a517390716aa3f4d329855e8689f1d5c3cb07c1b898e614a5e175f1826bb58e9ff1480e6552885a71a9a0ba5161787aaafa2c79b216cc + peerDependencies: + "@babel/core": ^7.0.0 + checksum: a0008332e24daedea2e9498733e3c39b389d6d4512637e000f96f62b797e702ee24a407ccbcd7a236a551590a38f31282829a8ef35c50a3c0457d88218cae639 languageName: node linkType: hard @@ -1288,7 +1337,7 @@ __metadata: languageName: node linkType: hard -"@babel/helper-split-export-declaration@npm:^7.22.5, @babel/helper-split-export-declaration@npm:^7.22.6": +"@babel/helper-split-export-declaration@npm:^7.22.6": version: 7.22.6 resolution: "@babel/helper-split-export-declaration@npm:7.22.6" dependencies: @@ -1304,17 +1353,17 @@ __metadata: languageName: node linkType: hard -"@babel/helper-validator-identifier@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/helper-validator-identifier@npm:7.22.5" - checksum: 7f0f30113474a28298c12161763b49de5018732290ca4de13cdaefd4fd0d635a6fe3f6686c37a02905fb1e64f21a5ee2b55140cf7b070e729f1bd66866506aea +"@babel/helper-validator-identifier@npm:^7.22.20": + version: 7.22.20 + resolution: "@babel/helper-validator-identifier@npm:7.22.20" + checksum: 136412784d9428266bcdd4d91c32bcf9ff0e8d25534a9d94b044f77fe76bc50f941a90319b05aafd1ec04f7d127cd57a179a3716009ff7f3412ef835ada95bdc languageName: node linkType: hard -"@babel/helper-validator-option@npm:^7.16.7, @babel/helper-validator-option@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/helper-validator-option@npm:7.22.5" - checksum: bbeca8a85ee86990215c0424997438b388b8d642d69b9f86c375a174d3cdeb270efafd1ff128bc7a1d370923d13b6e45829ba8581c027620e83e3a80c5c414b3 +"@babel/helper-validator-option@npm:^7.16.7, @babel/helper-validator-option@npm:^7.22.15, @babel/helper-validator-option@npm:^7.22.5": + version: 7.22.15 + resolution: "@babel/helper-validator-option@npm:7.22.15" + checksum: 68da52b1e10002a543161494c4bc0f4d0398c8fdf361d5f7f4272e95c45d5b32d974896d44f6a0ea7378c9204988879d73613ca683e13bd1304e46d25ff67a8d languageName: node linkType: hard @@ -1329,58 +1378,58 @@ __metadata: languageName: node linkType: hard -"@babel/helpers@npm:^7.12.5, @babel/helpers@npm:^7.22.10": - version: 7.22.10 - resolution: "@babel/helpers@npm:7.22.10" +"@babel/helpers@npm:^7.12.5, @babel/helpers@npm:^7.22.10, @babel/helpers@npm:^7.23.0": + version: 7.23.1 + resolution: "@babel/helpers@npm:7.23.1" dependencies: - "@babel/template": ^7.22.5 - "@babel/traverse": ^7.22.10 - "@babel/types": ^7.22.10 - checksum: 3b1219e362df390b6c5d94b75a53fc1c2eb42927ced0b8022d6a29b833a839696206b9bdad45b4805d05591df49fc16b6fb7db758c9c2ecfe99e3e94cb13020f + "@babel/template": ^7.22.15 + "@babel/traverse": ^7.23.0 + "@babel/types": ^7.23.0 + checksum: acfc345102045c24ea2a4d60e00dcf8220e215af3add4520e2167700661338e6a80bd56baf44bb764af05ec6621101c9afc315dc107e18c61fa6da8acbdbb893 languageName: node linkType: hard -"@babel/highlight@npm:^7.10.4, @babel/highlight@npm:^7.22.10": - version: 7.22.10 - resolution: "@babel/highlight@npm:7.22.10" +"@babel/highlight@npm:^7.10.4, @babel/highlight@npm:^7.22.13": + version: 7.22.20 + resolution: "@babel/highlight@npm:7.22.20" dependencies: - "@babel/helper-validator-identifier": ^7.22.5 + "@babel/helper-validator-identifier": ^7.22.20 chalk: ^2.4.2 js-tokens: ^4.0.0 - checksum: f714a1e1a72dd9d72f6383f4f30fd342e21a8df32d984a4ea8f5eab691bb6ba6db2f8823d4b4cf135d98869e7a98925b81306aa32ee3c429f8cfa52c75889e1b + checksum: 84bd034dca309a5e680083cd827a766780ca63cef37308404f17653d32366ea76262bd2364b2d38776232f2d01b649f26721417d507e8b4b6da3e4e739f6d134 languageName: node linkType: hard -"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.12.11, @babel/parser@npm:^7.12.7, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.20.7, @babel/parser@npm:^7.22.10, @babel/parser@npm:^7.22.5": - version: 7.22.10 - resolution: "@babel/parser@npm:7.22.10" +"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.12.11, @babel/parser@npm:^7.12.7, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.20.7, @babel/parser@npm:^7.22.10, @babel/parser@npm:^7.22.15, @babel/parser@npm:^7.23.0": + version: 7.23.0 + resolution: "@babel/parser@npm:7.23.0" bin: parser: ./bin/babel-parser.js - checksum: af51567b7d3cdf523bc608eae057397486c7fa6c2e5753027c01fe5c36f0767b2d01ce3049b222841326cc5b8c7fda1d810ac1a01af0a97bb04679e2ef9f7049 + checksum: 453fdf8b9e2c2b7d7b02139e0ce003d1af21947bbc03eb350fb248ee335c9b85e4ab41697ddbdd97079698de825a265e45a0846bb2ed47a2c7c1df833f42a354 languageName: node linkType: hard -"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@npm:7.22.5" +"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@npm:^7.22.15": + version: 7.22.15 + resolution: "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@npm:7.22.15" dependencies: "@babel/helper-plugin-utils": ^7.22.5 peerDependencies: "@babel/core": ^7.0.0 - checksum: 1e353a060fb2cd8f1256d28cd768f16fb02513f905b9b6d656fb0242c96c341a196fa188b27c2701506a6e27515359fbcc1a5ca7fa8b9b530cf88fbd137baefc + checksum: 8910ca21a7ec7c06f7b247d4b86c97c5aa15ef321518f44f6f490c5912fdf82c605aaa02b90892e375d82ccbedeadfdeadd922c1b836c9dd4c596871bf654753 languageName: node linkType: hard -"@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@npm:7.22.5" +"@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@npm:^7.22.15": + version: 7.22.15 + resolution: "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@npm:7.22.15" dependencies: "@babel/helper-plugin-utils": ^7.22.5 "@babel/helper-skip-transparent-expression-wrappers": ^7.22.5 - "@babel/plugin-transform-optional-chaining": ^7.22.5 + "@babel/plugin-transform-optional-chaining": ^7.22.15 peerDependencies: "@babel/core": ^7.13.0 - checksum: 16e7a5f3bf2f2ac0ca032a70bf0ebd7e886d84dbb712b55c0643c04c495f0f221fbcbca14b5f8f8027fa6c87a3dafae0934022ad2b409384af6c5c356495b7bd + checksum: fbefedc0da014c37f1a50a8094ce7dbbf2181ae93243f23d6ecba2499b5b20196c2124d6a4dfe3e9e0125798e80593103e456352a4beb4e5c6f7c75efb80fdac languageName: node linkType: hard @@ -1798,9 +1847,9 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-async-generator-functions@npm:^7.22.10": - version: 7.22.10 - resolution: "@babel/plugin-transform-async-generator-functions@npm:7.22.10" +"@babel/plugin-transform-async-generator-functions@npm:^7.22.15": + version: 7.22.15 + resolution: "@babel/plugin-transform-async-generator-functions@npm:7.22.15" dependencies: "@babel/helper-environment-visitor": ^7.22.5 "@babel/helper-plugin-utils": ^7.22.5 @@ -1808,7 +1857,7 @@ __metadata: "@babel/plugin-syntax-async-generators": ^7.8.4 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 87d77b66fda05b42450aa285fa031aa3963c52aab00190f95f6c3ddefbed683035c1f314347c888f8406fba5d436b888ff75b5e36b8ab23afd4ca4c3f086f88c + checksum: fad98786b446ce63bde0d14a221e2617eef5a7bbca62b49d96f16ab5e1694521234cfba6145b830fbf9af16d60a8a3dbf148e8694830bd91796fe333b0599e73 languageName: node linkType: hard @@ -1836,14 +1885,14 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-block-scoping@npm:^7.12.12, @babel/plugin-transform-block-scoping@npm:^7.22.10": - version: 7.22.10 - resolution: "@babel/plugin-transform-block-scoping@npm:7.22.10" +"@babel/plugin-transform-block-scoping@npm:^7.12.12, @babel/plugin-transform-block-scoping@npm:^7.22.15": + version: 7.23.0 + resolution: "@babel/plugin-transform-block-scoping@npm:7.23.0" dependencies: "@babel/helper-plugin-utils": ^7.22.5 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: b1d06f358dedcb748a57e5feea4b9285c60593fb2912b921f22898c57c552c78fe18128678c8f84dd4ea1d4e5aebede8783830b24cd63f22c30261156d78bc77 + checksum: 0cfe925cc3b5a3ad407e2253fab3ceeaa117a4b291c9cb245578880872999bca91bd83ffa0128ae9ca356330702e1ef1dcb26804f28d2cef678239caf629f73e languageName: node linkType: hard @@ -1859,35 +1908,35 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-class-static-block@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/plugin-transform-class-static-block@npm:7.22.5" +"@babel/plugin-transform-class-static-block@npm:^7.22.11": + version: 7.22.11 + resolution: "@babel/plugin-transform-class-static-block@npm:7.22.11" dependencies: - "@babel/helper-create-class-features-plugin": ^7.22.5 + "@babel/helper-create-class-features-plugin": ^7.22.11 "@babel/helper-plugin-utils": ^7.22.5 "@babel/plugin-syntax-class-static-block": ^7.14.5 peerDependencies: "@babel/core": ^7.12.0 - checksum: bc48b92dbaf625a14f2bf62382384eef01e0515802426841636ae9146e27395d068c7a8a45e9e15699491b0a01d990f38f179cbc9dc89274a393f85648772f12 + checksum: 69f040506fad66f1c6918d288d0e0edbc5c8a07c8b4462c1184ad2f9f08995d68b057126c213871c0853ae0c72afc60ec87492049dfacb20902e32346a448bcb languageName: node linkType: hard -"@babel/plugin-transform-classes@npm:^7.12.1, @babel/plugin-transform-classes@npm:^7.22.6": - version: 7.22.6 - resolution: "@babel/plugin-transform-classes@npm:7.22.6" +"@babel/plugin-transform-classes@npm:^7.12.1, @babel/plugin-transform-classes@npm:^7.22.15": + version: 7.22.15 + resolution: "@babel/plugin-transform-classes@npm:7.22.15" dependencies: "@babel/helper-annotate-as-pure": ^7.22.5 - "@babel/helper-compilation-targets": ^7.22.6 + "@babel/helper-compilation-targets": ^7.22.15 "@babel/helper-environment-visitor": ^7.22.5 "@babel/helper-function-name": ^7.22.5 "@babel/helper-optimise-call-expression": ^7.22.5 "@babel/helper-plugin-utils": ^7.22.5 - "@babel/helper-replace-supers": ^7.22.5 + "@babel/helper-replace-supers": ^7.22.9 "@babel/helper-split-export-declaration": ^7.22.6 globals: ^11.1.0 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 8380e855c01033dbc7460d9acfbc1fc37c880350fa798c2de8c594ef818ade0e4c96173ec72f05f2a4549d8d37135e18cb62548352d51557b45a0fb4388d2f3f + checksum: d3f4d0c107dd8a3557ea3575cc777fab27efa92958b41e4a9822f7499725c1f554beae58855de16ddec0a7b694e45f59a26cea8fbde4275563f72f09c6e039a0 languageName: node linkType: hard @@ -1903,14 +1952,14 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-destructuring@npm:^7.12.1, @babel/plugin-transform-destructuring@npm:^7.22.10": - version: 7.22.10 - resolution: "@babel/plugin-transform-destructuring@npm:7.22.10" +"@babel/plugin-transform-destructuring@npm:^7.12.1, @babel/plugin-transform-destructuring@npm:^7.22.15": + version: 7.23.0 + resolution: "@babel/plugin-transform-destructuring@npm:7.23.0" dependencies: "@babel/helper-plugin-utils": ^7.22.5 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 011707801bd0029fd4f0523d24d06fdc0cbe8c9da280d75728f76713d639c4dc976e1b56a1ba7bff25468f86867efb71c9b4cac81140adbdd0abf2324b19a8bb + checksum: cd6dd454ccc2766be551e4f8a04b1acc2aa539fa19e5c7501c56cc2f8cc921dd41a7ffb78455b4c4b2f954fcab8ca4561ba7c9c7bd5af9f19465243603d18cc3 languageName: node linkType: hard @@ -1937,15 +1986,15 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-dynamic-import@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/plugin-transform-dynamic-import@npm:7.22.5" +"@babel/plugin-transform-dynamic-import@npm:^7.22.11": + version: 7.22.11 + resolution: "@babel/plugin-transform-dynamic-import@npm:7.22.11" dependencies: "@babel/helper-plugin-utils": ^7.22.5 "@babel/plugin-syntax-dynamic-import": ^7.8.3 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 186a6d59f36eb3c5824739fc9c22ed0f4ca68e001662aa3a302634346a8b785cb9579b23b0c158f4570604d697d19598ca09b58c60a7fa2894da1163c4eb1907 + checksum: 78fc9c532210bf9e8f231747f542318568ac360ee6c27e80853962c984283c73da3f8f8aebe83c2096090a435b356b092ed85de617a156cbe0729d847632be45 languageName: node linkType: hard @@ -1961,15 +2010,15 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-export-namespace-from@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/plugin-transform-export-namespace-from@npm:7.22.5" +"@babel/plugin-transform-export-namespace-from@npm:^7.22.11": + version: 7.22.11 + resolution: "@babel/plugin-transform-export-namespace-from@npm:7.22.11" dependencies: "@babel/helper-plugin-utils": ^7.22.5 "@babel/plugin-syntax-export-namespace-from": ^7.8.3 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 3d197b788758044983c96b9c49bed4b456055f35a388521a405968db0f6e2ffb6fd59110e3931f4dcc5e126ae9e5e00e154a0afb47a7ea359d8d0dea79f480d7 + checksum: 73af5883a321ed56a4bfd43c8a7de0164faebe619287706896fc6ee2f7a4e69042adaa1338c0b8b4bdb9f7e5fdceb016fb1d40694cb43ca3b8827429e8aac4bf languageName: node linkType: hard @@ -1985,14 +2034,14 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-for-of@npm:^7.12.1, @babel/plugin-transform-for-of@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/plugin-transform-for-of@npm:7.22.5" +"@babel/plugin-transform-for-of@npm:^7.12.1, @babel/plugin-transform-for-of@npm:^7.22.15": + version: 7.22.15 + resolution: "@babel/plugin-transform-for-of@npm:7.22.15" dependencies: "@babel/helper-plugin-utils": ^7.22.5 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: d7b8d4db010bce7273674caa95c4e6abd909362866ce297e86a2ecaa9ae636e05d525415811db9b3c942155df7f3651d19b91dd6c41f142f7308a97c7cb06023 + checksum: f395ae7bce31e14961460f56cf751b5d6e37dd27d7df5b1f4e49fec1c11b6f9cf71991c7ffbe6549878591e87df0d66af798cf26edfa4bfa6b4c3dba1fb2f73a languageName: node linkType: hard @@ -2009,15 +2058,15 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-json-strings@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/plugin-transform-json-strings@npm:7.22.5" +"@babel/plugin-transform-json-strings@npm:^7.22.11": + version: 7.22.11 + resolution: "@babel/plugin-transform-json-strings@npm:7.22.11" dependencies: "@babel/helper-plugin-utils": ^7.22.5 "@babel/plugin-syntax-json-strings": ^7.8.3 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 4e00b902487a670b6c8948f33f9108133fd745cf9d1478aca515fb460b9b2f12e137988ebc1663630fb82070a870aed8b0c1aa4d007a841c18004619798f255c + checksum: 50665e5979e66358c50e90a26db53c55917f78175127ac2fa05c7888d156d418ffb930ec0a109353db0a7c5f57c756ce01bfc9825d24cbfd2b3ec453f2ed8cba languageName: node linkType: hard @@ -2032,15 +2081,15 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-logical-assignment-operators@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/plugin-transform-logical-assignment-operators@npm:7.22.5" +"@babel/plugin-transform-logical-assignment-operators@npm:^7.22.11": + version: 7.22.11 + resolution: "@babel/plugin-transform-logical-assignment-operators@npm:7.22.11" dependencies: "@babel/helper-plugin-utils": ^7.22.5 "@babel/plugin-syntax-logical-assignment-operators": ^7.10.4 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 18748e953c08f64885f18c224eac58df10a13eac4d845d16b5d9b6276907da7ca2530dfebe6ed41cdc5f8a75d9db3e36d8eb54ddce7cd0364af1cab09b435302 + checksum: c664e9798e85afa7f92f07b867682dee7392046181d82f5d21bae6f2ca26dfe9c8375cdc52b7483c3fc09a983c1989f60eff9fbc4f373b0c0a74090553d05739 languageName: node linkType: hard @@ -2067,30 +2116,30 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-modules-commonjs@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/plugin-transform-modules-commonjs@npm:7.22.5" +"@babel/plugin-transform-modules-commonjs@npm:^7.22.15, @babel/plugin-transform-modules-commonjs@npm:^7.22.5, @babel/plugin-transform-modules-commonjs@npm:^7.23.0": + version: 7.23.0 + resolution: "@babel/plugin-transform-modules-commonjs@npm:7.23.0" dependencies: - "@babel/helper-module-transforms": ^7.22.5 + "@babel/helper-module-transforms": ^7.23.0 "@babel/helper-plugin-utils": ^7.22.5 "@babel/helper-simple-access": ^7.22.5 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 2067aca8f6454d54ffcce69b02c457cfa61428e11372f6a1d99ff4fcfbb55c396ed2ca6ca886bf06c852e38c1a205b8095921b2364fd0243f3e66bc1dda61caa + checksum: 7fb25997194053e167c4207c319ff05362392da841bd9f42ddb3caf9c8798a5d203bd926d23ddf5830fdf05eddc82c2810f40d1287e3a4f80b07eff13d1024b5 languageName: node linkType: hard -"@babel/plugin-transform-modules-systemjs@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/plugin-transform-modules-systemjs@npm:7.22.5" +"@babel/plugin-transform-modules-systemjs@npm:^7.22.11": + version: 7.23.0 + resolution: "@babel/plugin-transform-modules-systemjs@npm:7.23.0" dependencies: "@babel/helper-hoist-variables": ^7.22.5 - "@babel/helper-module-transforms": ^7.22.5 + "@babel/helper-module-transforms": ^7.23.0 "@babel/helper-plugin-utils": ^7.22.5 - "@babel/helper-validator-identifier": ^7.22.5 + "@babel/helper-validator-identifier": ^7.22.20 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 04f4178589543396b3c24330a67a59c5e69af5e96119c9adda730c0f20122deaff54671ebbc72ad2df6495a5db8a758bd96942de95fba7ad427de9c80b1b38c8 + checksum: 2d481458b22605046badea2317d5cc5c94ac3031c2293e34c96f02063f5b02af0979c4da6a8fbc67cc249541575dc9c6d710db6b919ede70b7337a22d9fd57a7 languageName: node linkType: hard @@ -2129,42 +2178,42 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-nullish-coalescing-operator@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/plugin-transform-nullish-coalescing-operator@npm:7.22.5" +"@babel/plugin-transform-nullish-coalescing-operator@npm:^7.22.11": + version: 7.22.11 + resolution: "@babel/plugin-transform-nullish-coalescing-operator@npm:7.22.11" dependencies: "@babel/helper-plugin-utils": ^7.22.5 "@babel/plugin-syntax-nullish-coalescing-operator": ^7.8.3 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: e6a059169d257fc61322d0708edae423072449b7c33de396261e68dee582aec5396789a1c22bce84e5bd88a169623c2e750b513fc222930979e6accd52a44bf2 + checksum: 167babecc8b8fe70796a7b7d34af667ebbf43da166c21689502e5e8cc93180b7a85979c77c9f64b7cce431b36718bd0a6df9e5e0ffea4ae22afb22cfef886372 languageName: node linkType: hard -"@babel/plugin-transform-numeric-separator@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/plugin-transform-numeric-separator@npm:7.22.5" +"@babel/plugin-transform-numeric-separator@npm:^7.22.11": + version: 7.22.11 + resolution: "@babel/plugin-transform-numeric-separator@npm:7.22.11" dependencies: "@babel/helper-plugin-utils": ^7.22.5 "@babel/plugin-syntax-numeric-separator": ^7.10.4 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 9e7837d4eae04f211ebaa034fe5003d2927b6bf6d5b9dc09f2b1183c01482cdde5a75b8bd5c7ff195c2abc7b923339eb0b2a9d27cb78359d38248a3b2c2367c4 + checksum: af064d06a4a041767ec396a5f258103f64785df290e038bba9f0ef454e6c914f2ac45d862bbdad8fac2c7ad47fa4e95356f29053c60c100a0160b02a995fe2a3 languageName: node linkType: hard -"@babel/plugin-transform-object-rest-spread@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/plugin-transform-object-rest-spread@npm:7.22.5" +"@babel/plugin-transform-object-rest-spread@npm:^7.22.15": + version: 7.22.15 + resolution: "@babel/plugin-transform-object-rest-spread@npm:7.22.15" dependencies: - "@babel/compat-data": ^7.22.5 - "@babel/helper-compilation-targets": ^7.22.5 + "@babel/compat-data": ^7.22.9 + "@babel/helper-compilation-targets": ^7.22.15 "@babel/helper-plugin-utils": ^7.22.5 "@babel/plugin-syntax-object-rest-spread": ^7.8.3 - "@babel/plugin-transform-parameters": ^7.22.5 + "@babel/plugin-transform-parameters": ^7.22.15 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 3b5e091f0dc67108f2e41ed5a97e15bbe4381a19d9a7eea80b71c7de1d8169fd28784e1e41a3d2ad12709ab212e58fc481282a5bb65d591fae7b443048de3330 + checksum: 62197a6f12289c1c1bd57f3bed9f0f765ca32390bfe91e0b5561dd94dd9770f4480c4162dec98da094bc0ba99d2c2ebba68de47c019454041b0b7a68ba2ec66d languageName: node linkType: hard @@ -2180,39 +2229,39 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-optional-catch-binding@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/plugin-transform-optional-catch-binding@npm:7.22.5" +"@babel/plugin-transform-optional-catch-binding@npm:^7.22.11": + version: 7.22.11 + resolution: "@babel/plugin-transform-optional-catch-binding@npm:7.22.11" dependencies: "@babel/helper-plugin-utils": ^7.22.5 "@babel/plugin-syntax-optional-catch-binding": ^7.8.3 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: b0e8b4233ff06b5c9d285257f49c5bd441f883189b24282e6200f9ebdf5db29aeeebbffae57fbbcd5df9f4387b3e66e5d322aaae5652a78e89685ddbae46bbd1 + checksum: f17abd90e1de67c84d63afea29c8021c74abb2794d3a6eeafb0bbe7372d3db32aefca386e392116ec63884537a4a2815d090d26264d259bacc08f6e3ed05294c languageName: node linkType: hard -"@babel/plugin-transform-optional-chaining@npm:^7.22.10, @babel/plugin-transform-optional-chaining@npm:^7.22.5": - version: 7.22.10 - resolution: "@babel/plugin-transform-optional-chaining@npm:7.22.10" +"@babel/plugin-transform-optional-chaining@npm:^7.22.15": + version: 7.23.0 + resolution: "@babel/plugin-transform-optional-chaining@npm:7.23.0" dependencies: "@babel/helper-plugin-utils": ^7.22.5 "@babel/helper-skip-transparent-expression-wrappers": ^7.22.5 "@babel/plugin-syntax-optional-chaining": ^7.8.3 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 522d6214bb9f6ede8a2fc56a873e791aabd62f0b3be78fb8e62ca801a9033bcadabfb77aec6739f0e67f0f15f7c739c08bafafd66d3676edf1941fe6429cebcd + checksum: f702634f2b97e5260dbec0d4bde05ccb6f4d96d7bfa946481aeacfa205ca846cb6e096a38312f9d51fdbdac1f258f211138c5f7075952e46a5bf8574de6a1329 languageName: node linkType: hard -"@babel/plugin-transform-parameters@npm:^7.12.1, @babel/plugin-transform-parameters@npm:^7.20.7, @babel/plugin-transform-parameters@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/plugin-transform-parameters@npm:7.22.5" +"@babel/plugin-transform-parameters@npm:^7.12.1, @babel/plugin-transform-parameters@npm:^7.20.7, @babel/plugin-transform-parameters@npm:^7.22.15": + version: 7.22.15 + resolution: "@babel/plugin-transform-parameters@npm:7.22.15" dependencies: "@babel/helper-plugin-utils": ^7.22.5 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: b44f89cf97daf23903776ba27c2ab13b439d80d8c8a95be5c476ab65023b1e0c0e94c28d3745f3b60a58edc4e590fa0cd4287a0293e51401ca7d29a2ddb13b8e + checksum: 541188bb7d1876cad87687b5c7daf90f63d8208ae83df24acb1e2b05020ad1c78786b2723ca4054a83fcb74fb6509f30c4cacc5b538ee684224261ad5fb047c1 languageName: node linkType: hard @@ -2228,17 +2277,17 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-private-property-in-object@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/plugin-transform-private-property-in-object@npm:7.22.5" +"@babel/plugin-transform-private-property-in-object@npm:^7.22.11": + version: 7.22.11 + resolution: "@babel/plugin-transform-private-property-in-object@npm:7.22.11" dependencies: "@babel/helper-annotate-as-pure": ^7.22.5 - "@babel/helper-create-class-features-plugin": ^7.22.5 + "@babel/helper-create-class-features-plugin": ^7.22.11 "@babel/helper-plugin-utils": ^7.22.5 "@babel/plugin-syntax-private-property-in-object": ^7.14.5 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 9ac019fb2772f3af6278a7f4b8b14b0663accb3fd123d87142ceb2fbc57fd1afa07c945d1329029b026b9ee122096ef71a3f34f257a9e04cf4245b87298c38b4 + checksum: 4d029d84901e53c46dead7a46e2990a7bc62470f4e4ca58a0d063394f86652fd58fe4eea1eb941da3669cd536b559b9d058b342b59300026346b7a2a51badac8 languageName: node linkType: hard @@ -2403,17 +2452,17 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-typescript@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/plugin-transform-typescript@npm:7.22.5" +"@babel/plugin-transform-typescript@npm:^7.22.15, @babel/plugin-transform-typescript@npm:^7.22.5": + version: 7.22.15 + resolution: "@babel/plugin-transform-typescript@npm:7.22.15" dependencies: "@babel/helper-annotate-as-pure": ^7.22.5 - "@babel/helper-create-class-features-plugin": ^7.22.5 + "@babel/helper-create-class-features-plugin": ^7.22.15 "@babel/helper-plugin-utils": ^7.22.5 "@babel/plugin-syntax-typescript": ^7.22.5 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: d12f1ca1ef1f2a54432eb044d2999705d1205ebe211c2a7f05b12e8eb2d2a461fd7657b5486b2f2f1efe7c0c0dc8e80725b767073d40fe4ae059a7af057b05e4 + checksum: c5d96cdbf0e1512707aa1c1e3ac6b370a25fd9c545d26008ce44eb13a47bd7fd67a1eb799c98b5ccc82e33a345fda55c0055e1fe3ed97646ed405dd13020b226 languageName: node linkType: hard @@ -2464,16 +2513,16 @@ __metadata: languageName: node linkType: hard -"@babel/preset-env@npm:^7.12.11, @babel/preset-env@npm:~7.22.10, @babel/preset-env@npm:~7.22.9": - version: 7.22.10 - resolution: "@babel/preset-env@npm:7.22.10" +"@babel/preset-env@npm:^7.12.11, @babel/preset-env@npm:^7.22.20, @babel/preset-env@npm:~7.22.10, @babel/preset-env@npm:~7.22.9": + version: 7.22.20 + resolution: "@babel/preset-env@npm:7.22.20" dependencies: - "@babel/compat-data": ^7.22.9 - "@babel/helper-compilation-targets": ^7.22.10 + "@babel/compat-data": ^7.22.20 + "@babel/helper-compilation-targets": ^7.22.15 "@babel/helper-plugin-utils": ^7.22.5 - "@babel/helper-validator-option": ^7.22.5 - "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": ^7.22.5 - "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": ^7.22.5 + "@babel/helper-validator-option": ^7.22.15 + "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": ^7.22.15 + "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": ^7.22.15 "@babel/plugin-proposal-private-property-in-object": 7.21.0-placeholder-for-preset-env.2 "@babel/plugin-syntax-async-generators": ^7.8.4 "@babel/plugin-syntax-class-properties": ^7.12.13 @@ -2494,41 +2543,41 @@ __metadata: "@babel/plugin-syntax-top-level-await": ^7.14.5 "@babel/plugin-syntax-unicode-sets-regex": ^7.18.6 "@babel/plugin-transform-arrow-functions": ^7.22.5 - "@babel/plugin-transform-async-generator-functions": ^7.22.10 + "@babel/plugin-transform-async-generator-functions": ^7.22.15 "@babel/plugin-transform-async-to-generator": ^7.22.5 "@babel/plugin-transform-block-scoped-functions": ^7.22.5 - "@babel/plugin-transform-block-scoping": ^7.22.10 + "@babel/plugin-transform-block-scoping": ^7.22.15 "@babel/plugin-transform-class-properties": ^7.22.5 - "@babel/plugin-transform-class-static-block": ^7.22.5 - "@babel/plugin-transform-classes": ^7.22.6 + "@babel/plugin-transform-class-static-block": ^7.22.11 + "@babel/plugin-transform-classes": ^7.22.15 "@babel/plugin-transform-computed-properties": ^7.22.5 - "@babel/plugin-transform-destructuring": ^7.22.10 + "@babel/plugin-transform-destructuring": ^7.22.15 "@babel/plugin-transform-dotall-regex": ^7.22.5 "@babel/plugin-transform-duplicate-keys": ^7.22.5 - "@babel/plugin-transform-dynamic-import": ^7.22.5 + "@babel/plugin-transform-dynamic-import": ^7.22.11 "@babel/plugin-transform-exponentiation-operator": ^7.22.5 - "@babel/plugin-transform-export-namespace-from": ^7.22.5 - "@babel/plugin-transform-for-of": ^7.22.5 + "@babel/plugin-transform-export-namespace-from": ^7.22.11 + "@babel/plugin-transform-for-of": ^7.22.15 "@babel/plugin-transform-function-name": ^7.22.5 - "@babel/plugin-transform-json-strings": ^7.22.5 + "@babel/plugin-transform-json-strings": ^7.22.11 "@babel/plugin-transform-literals": ^7.22.5 - "@babel/plugin-transform-logical-assignment-operators": ^7.22.5 + "@babel/plugin-transform-logical-assignment-operators": ^7.22.11 "@babel/plugin-transform-member-expression-literals": ^7.22.5 "@babel/plugin-transform-modules-amd": ^7.22.5 - "@babel/plugin-transform-modules-commonjs": ^7.22.5 - "@babel/plugin-transform-modules-systemjs": ^7.22.5 + "@babel/plugin-transform-modules-commonjs": ^7.22.15 + "@babel/plugin-transform-modules-systemjs": ^7.22.11 "@babel/plugin-transform-modules-umd": ^7.22.5 "@babel/plugin-transform-named-capturing-groups-regex": ^7.22.5 "@babel/plugin-transform-new-target": ^7.22.5 - "@babel/plugin-transform-nullish-coalescing-operator": ^7.22.5 - "@babel/plugin-transform-numeric-separator": ^7.22.5 - "@babel/plugin-transform-object-rest-spread": ^7.22.5 + "@babel/plugin-transform-nullish-coalescing-operator": ^7.22.11 + "@babel/plugin-transform-numeric-separator": ^7.22.11 + "@babel/plugin-transform-object-rest-spread": ^7.22.15 "@babel/plugin-transform-object-super": ^7.22.5 - "@babel/plugin-transform-optional-catch-binding": ^7.22.5 - "@babel/plugin-transform-optional-chaining": ^7.22.10 - "@babel/plugin-transform-parameters": ^7.22.5 + "@babel/plugin-transform-optional-catch-binding": ^7.22.11 + "@babel/plugin-transform-optional-chaining": ^7.22.15 + "@babel/plugin-transform-parameters": ^7.22.15 "@babel/plugin-transform-private-methods": ^7.22.5 - "@babel/plugin-transform-private-property-in-object": ^7.22.5 + "@babel/plugin-transform-private-property-in-object": ^7.22.11 "@babel/plugin-transform-property-literals": ^7.22.5 "@babel/plugin-transform-regenerator": ^7.22.10 "@babel/plugin-transform-reserved-words": ^7.22.5 @@ -2542,7 +2591,7 @@ __metadata: "@babel/plugin-transform-unicode-regex": ^7.22.5 "@babel/plugin-transform-unicode-sets-regex": ^7.22.5 "@babel/preset-modules": 0.1.6-no-external-plugins - "@babel/types": ^7.22.10 + "@babel/types": ^7.22.19 babel-plugin-polyfill-corejs2: ^0.4.5 babel-plugin-polyfill-corejs3: ^0.8.3 babel-plugin-polyfill-regenerator: ^0.5.2 @@ -2550,7 +2599,7 @@ __metadata: semver: ^6.3.1 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 4145a660a7b05e21e6d8b6cdf348c6931238abb15282a258bdb5e04cd3cca9356dc120ecfe0d1b977819ade4aac50163127c86db2300227ff60392d24daa0b7c + checksum: 99357a5cb30f53bacdc0d1cd6dff0f052ea6c2d1ba874d969bba69897ef716e87283e84a59dc52fb49aa31fd1b6f55ed756c64c04f5678380700239f6030b881 languageName: node linkType: hard @@ -2596,7 +2645,22 @@ __metadata: languageName: node linkType: hard -"@babel/preset-typescript@npm:^7.12.7, @babel/preset-typescript@npm:~7.22.5": +"@babel/preset-typescript@npm:^7.12.7, @babel/preset-typescript@npm:^7.23.0": + version: 7.23.0 + resolution: "@babel/preset-typescript@npm:7.23.0" + dependencies: + "@babel/helper-plugin-utils": ^7.22.5 + "@babel/helper-validator-option": ^7.22.15 + "@babel/plugin-syntax-jsx": ^7.22.5 + "@babel/plugin-transform-modules-commonjs": ^7.23.0 + "@babel/plugin-transform-typescript": ^7.22.15 + peerDependencies: + "@babel/core": ^7.0.0-0 + checksum: 3d5fce83e83f11c07e0ea13542bca181abb3b482b8981ec9c64e6add9d7beed3c54d063dc4bc9fd383165c71114a245abef89a289680833c5a8552fe3e7c4407 + languageName: node + linkType: hard + +"@babel/preset-typescript@npm:~7.22.5": version: 7.22.5 resolution: "@babel/preset-typescript@npm:7.22.5" dependencies: @@ -2660,43 +2724,43 @@ __metadata: languageName: node linkType: hard -"@babel/template@npm:^7.12.7, @babel/template@npm:^7.22.5, @babel/template@npm:^7.3.3": - version: 7.22.5 - resolution: "@babel/template@npm:7.22.5" +"@babel/template@npm:^7.12.7, @babel/template@npm:^7.22.15, @babel/template@npm:^7.22.5, @babel/template@npm:^7.3.3": + version: 7.22.15 + resolution: "@babel/template@npm:7.22.15" dependencies: - "@babel/code-frame": ^7.22.5 - "@babel/parser": ^7.22.5 - "@babel/types": ^7.22.5 - checksum: c5746410164039aca61829cdb42e9a55410f43cace6f51ca443313f3d0bdfa9a5a330d0b0df73dc17ef885c72104234ae05efede37c1cc8a72dc9f93425977a3 + "@babel/code-frame": ^7.22.13 + "@babel/parser": ^7.22.15 + "@babel/types": ^7.22.15 + checksum: 1f3e7dcd6c44f5904c184b3f7fe280394b191f2fed819919ffa1e529c259d5b197da8981b6ca491c235aee8dbad4a50b7e31304aa531271cb823a4a24a0dd8fd languageName: node linkType: hard -"@babel/traverse@npm:^7.1.6, @babel/traverse@npm:^7.12.11, @babel/traverse@npm:^7.12.9, @babel/traverse@npm:^7.13.0, @babel/traverse@npm:^7.22.10, @babel/traverse@npm:^7.22.5": - version: 7.22.10 - resolution: "@babel/traverse@npm:7.22.10" +"@babel/traverse@npm:^7.1.6, @babel/traverse@npm:^7.12.11, @babel/traverse@npm:^7.12.9, @babel/traverse@npm:^7.13.0, @babel/traverse@npm:^7.22.10, @babel/traverse@npm:^7.23.0": + version: 7.23.0 + resolution: "@babel/traverse@npm:7.23.0" dependencies: - "@babel/code-frame": ^7.22.10 - "@babel/generator": ^7.22.10 - "@babel/helper-environment-visitor": ^7.22.5 - "@babel/helper-function-name": ^7.22.5 + "@babel/code-frame": ^7.22.13 + "@babel/generator": ^7.23.0 + "@babel/helper-environment-visitor": ^7.22.20 + "@babel/helper-function-name": ^7.23.0 "@babel/helper-hoist-variables": ^7.22.5 "@babel/helper-split-export-declaration": ^7.22.6 - "@babel/parser": ^7.22.10 - "@babel/types": ^7.22.10 + "@babel/parser": ^7.23.0 + "@babel/types": ^7.23.0 debug: ^4.1.0 globals: ^11.1.0 - checksum: 9f7b358563bfb0f57ac4ed639f50e5c29a36b821a1ce1eea0c7db084f5b925e3275846d0de63bde01ca407c85d9804e0efbe370d92cd2baaafde3bd13b0f4cdb + checksum: 0b17fae53269e1af2cd3edba00892bc2975ad5df9eea7b84815dab07dfec2928c451066d51bc65b4be61d8499e77db7e547ce69ef2a7b0eca3f96269cb43a0b0 languageName: node linkType: hard -"@babel/types@npm:^7.0.0, @babel/types@npm:^7.12.11, @babel/types@npm:^7.12.7, @babel/types@npm:^7.2.0, @babel/types@npm:^7.20.7, @babel/types@npm:^7.22.10, @babel/types@npm:^7.22.5, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4, @babel/types@npm:^7.8.3": - version: 7.22.10 - resolution: "@babel/types@npm:7.22.10" +"@babel/types@npm:^7.0.0, @babel/types@npm:^7.12.11, @babel/types@npm:^7.12.7, @babel/types@npm:^7.2.0, @babel/types@npm:^7.20.7, @babel/types@npm:^7.22.10, @babel/types@npm:^7.22.15, @babel/types@npm:^7.22.19, @babel/types@npm:^7.22.5, @babel/types@npm:^7.23.0, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4, @babel/types@npm:^7.8.3": + version: 7.23.0 + resolution: "@babel/types@npm:7.23.0" dependencies: "@babel/helper-string-parser": ^7.22.5 - "@babel/helper-validator-identifier": ^7.22.5 + "@babel/helper-validator-identifier": ^7.22.20 to-fast-properties: ^2.0.0 - checksum: 095c4f4b7503fa816e4094113f0ec2351ef96ff32012010b771693066ff628c7c664b21c6bd3fb93aeb46fe7c61f6b3a3c9e4ed0034d6a2481201c417371c8af + checksum: 215fe04bd7feef79eeb4d33374b39909ce9cad1611c4135a4f7fdf41fe3280594105af6d7094354751514625ea92d0875aba355f53e86a92600f290e77b0e604 languageName: node linkType: hard @@ -4524,6 +4588,13 @@ __metadata: languageName: node linkType: hard +"@nicolo-ribaudo/chokidar-2@npm:2.1.8-no-fsevents.3": + version: 2.1.8-no-fsevents.3 + resolution: "@nicolo-ribaudo/chokidar-2@npm:2.1.8-no-fsevents.3" + checksum: ee55cc9241aeea7eb94b8a8551bfa4246c56c53bc71ecda0a2104018fcc328ba5723b33686bdf9cc65d4df4ae65e8016b89e0bbdeb94e0309fe91bb9ced42344 + languageName: node + linkType: hard + "@nicolo-ribaudo/eslint-scope-5-internals@npm:5.1.1-v1": version: 5.1.1-v1 resolution: "@nicolo-ribaudo/eslint-scope-5-internals@npm:5.1.1-v1" @@ -8365,6 +8436,19 @@ __metadata: languageName: unknown linkType: soft +"@rocket.chat/jwt@workspace:^, @rocket.chat/jwt@workspace:packages/jwt": + version: 0.0.0-use.local + resolution: "@rocket.chat/jwt@workspace:packages/jwt" + dependencies: + "@types/jest": ~29.5.3 + eslint: ~8.45.0 + jest: ~29.6.1 + jose: ^4.14.4 + ts-jest: ^29.1.1 + typescript: ~5.2.2 + languageName: unknown + linkType: soft + "@rocket.chat/layout@npm:next": version: 0.32.0-dev.312 resolution: "@rocket.chat/layout@npm:0.32.0-dev.312" @@ -8377,6 +8461,33 @@ __metadata: languageName: node linkType: hard +"@rocket.chat/license@workspace:^, @rocket.chat/license@workspace:ee/packages/license": + version: 0.0.0-use.local + resolution: "@rocket.chat/license@workspace:ee/packages/license" + dependencies: + "@babel/cli": ^7.23.0 + "@babel/core": ^7.23.0 + "@babel/preset-env": ^7.22.20 + "@babel/preset-typescript": ^7.23.0 + "@rocket.chat/core-typings": "workspace:^" + "@rocket.chat/jwt": "workspace:^" + "@rocket.chat/logger": "workspace:^" + "@swc/core": ^1.3.66 + "@swc/jest": ^0.2.26 + "@types/babel__core": ^7 + "@types/babel__preset-env": ^7 + "@types/jest": ~29.5.3 + "@types/ws": ^8.5.5 + babel-plugin-transform-inline-environment-variables: ^0.4.4 + eslint: ~8.45.0 + jest: ~29.6.1 + jest-environment-jsdom: ~29.6.1 + jest-websocket-mock: ^2.4.0 + ts-jest: ~29.0.5 + typescript: ^5.2.2 + languageName: unknown + linkType: soft + "@rocket.chat/livechat@workspace:^, @rocket.chat/livechat@workspace:packages/livechat": version: 0.0.0-use.local resolution: "@rocket.chat/livechat@workspace:packages/livechat" @@ -8587,7 +8698,9 @@ __metadata: "@rocket.chat/i18n": "workspace:^" "@rocket.chat/icons": ^0.32.0 "@rocket.chat/instance-status": "workspace:^" + "@rocket.chat/jwt": "workspace:^" "@rocket.chat/layout": next + "@rocket.chat/license": "workspace:^" "@rocket.chat/livechat": "workspace:^" "@rocket.chat/log-format": "workspace:^" "@rocket.chat/logger": "workspace:^" @@ -9262,6 +9375,7 @@ __metadata: "@rocket.chat/apps-engine": 1.41.0-alpha.290 "@rocket.chat/core-typings": "workspace:^" "@rocket.chat/eslint-config": "workspace:^" + "@rocket.chat/license": "workspace:^" "@rocket.chat/message-parser": next "@rocket.chat/ui-kit": ^0.32.1 "@types/jest": ~29.5.3 @@ -15271,6 +15385,13 @@ __metadata: languageName: node linkType: hard +"babel-plugin-transform-inline-environment-variables@npm:^0.4.4": + version: 0.4.4 + resolution: "babel-plugin-transform-inline-environment-variables@npm:0.4.4" + checksum: fa361287411301237fd8ce332aff4f8e8ccb8db30e87a2ddc7224c8bf7cd792eda47aca24dc2e09e70bce4c027bc8cbe22f4999056be37a25d2472945df21ef5 + languageName: node + linkType: hard + "babel-polyfill@npm:^6.2.0": version: 6.26.0 resolution: "babel-polyfill@npm:6.26.0" @@ -16795,7 +16916,7 @@ __metadata: languageName: node linkType: hard -"chokidar@npm:3.5.3, chokidar@npm:>=3.0.0 <4.0.0, chokidar@npm:^3.4.1, chokidar@npm:^3.4.2, chokidar@npm:^3.5.1, chokidar@npm:^3.5.3": +"chokidar@npm:3.5.3, chokidar@npm:>=3.0.0 <4.0.0, chokidar@npm:^3.4.0, chokidar@npm:^3.4.1, chokidar@npm:^3.4.2, chokidar@npm:^3.5.1, chokidar@npm:^3.5.3": version: 3.5.3 resolution: "chokidar@npm:3.5.3" dependencies: @@ -17337,7 +17458,7 @@ __metadata: languageName: node linkType: hard -"commander@npm:^4.0.0, commander@npm:^4.1.1": +"commander@npm:^4.0.0, commander@npm:^4.0.1, commander@npm:^4.1.1": version: 4.1.1 resolution: "commander@npm:4.1.1" checksum: d7b9913ff92cae20cb577a4ac6fcc121bd6223319e54a40f51a14740a681ad5c574fd29a57da478a5f234a6fa6c52cbf0b7c641353e03c648b1ae85ba670b977 @@ -21944,6 +22065,13 @@ __metadata: languageName: node linkType: hard +"fs-readdir-recursive@npm:^1.1.0": + version: 1.1.0 + resolution: "fs-readdir-recursive@npm:1.1.0" + checksum: 29d50f3d2128391c7fc9fd051c8b7ea45bcc8aa84daf31ef52b17218e20bfd2bd34d02382742801954cc8d1905832b68227f6b680a666ce525d8b6b75068ad1e + languageName: node + linkType: hard + "fs-write-stream-atomic@npm:^1.0.8": version: 1.0.10 resolution: "fs-write-stream-atomic@npm:1.0.10" @@ -26021,10 +26149,10 @@ __metadata: languageName: node linkType: hard -"jose@npm:^4.11.1": - version: 4.12.0 - resolution: "jose@npm:4.12.0" - checksum: 09e67611768127ab54b6b507401de4b1f87e1e285cf2c2fc917e931e001b7e584c90081b421f483f13a6eec4fc44936e4a5f4b8ae2d59928061e886e35d33fa2 +"jose@npm:^4.11.1, jose@npm:^4.14.4": + version: 4.14.6 + resolution: "jose@npm:4.14.6" + checksum: eae81a234e7bf1446b1bd80722b3462b014e3835b155c3a7799c1c5043163a53a0dc28d347004151b031e6b7b863403aabf8814d9cc217ce21f8c2f3ebd4b335 languageName: node linkType: hard @@ -37241,6 +37369,39 @@ __metadata: languageName: node linkType: hard +"ts-jest@npm:^29.1.1": + version: 29.1.1 + resolution: "ts-jest@npm:29.1.1" + dependencies: + bs-logger: 0.x + fast-json-stable-stringify: 2.x + jest-util: ^29.0.0 + json5: ^2.2.3 + lodash.memoize: 4.x + make-error: 1.x + semver: ^7.5.3 + yargs-parser: ^21.0.1 + peerDependencies: + "@babel/core": ">=7.0.0-beta.0 <8" + "@jest/types": ^29.0.0 + babel-jest: ^29.0.0 + jest: ^29.0.0 + typescript: ">=4.3 <6" + peerDependenciesMeta: + "@babel/core": + optional: true + "@jest/types": + optional: true + babel-jest: + optional: true + esbuild: + optional: true + bin: + ts-jest: cli.js + checksum: a8c9e284ed4f819526749f6e4dc6421ec666f20ab44d31b0f02b4ed979975f7580b18aea4813172d43e39b29464a71899f8893dd29b06b4a351a3af8ba47b402 + languageName: node + linkType: hard + "ts-jest@npm:~29.0.5": version: 29.0.5 resolution: "ts-jest@npm:29.0.5" @@ -37717,7 +37878,7 @@ __metadata: languageName: node linkType: hard -"typescript@npm:~5.2.2": +"typescript@npm:^5.2.2, typescript@npm:~5.2.2": version: 5.2.2 resolution: "typescript@npm:5.2.2" bin: @@ -37727,7 +37888,7 @@ __metadata: languageName: node linkType: hard -"typescript@patch:typescript@~5.2.2#~builtin": +"typescript@patch:typescript@^5.2.2#~builtin, typescript@patch:typescript@~5.2.2#~builtin": version: 5.2.2 resolution: "typescript@patch:typescript@npm%3A5.2.2#~builtin::version=5.2.2&hash=f456af" bin: