diff --git a/.changeset/ten-houses-repair.md b/.changeset/ten-houses-repair.md new file mode 100644 index 000000000000..7d3cd67ce15f --- /dev/null +++ b/.changeset/ten-houses-repair.md @@ -0,0 +1,6 @@ +--- +'@rocket.chat/rest-typings': major +'@rocket.chat/meteor': major +--- + +Removes deprecated endpoints `licenses.isEnterprise` and `licenses.get`. Moving forward use the endpoint `licenses.info.` diff --git a/apps/meteor/client/hooks/useIsEnterprise.ts b/apps/meteor/client/hooks/useIsEnterprise.ts index e2622d8b695d..dffaf8b36877 100644 --- a/apps/meteor/client/hooks/useIsEnterprise.ts +++ b/apps/meteor/client/hooks/useIsEnterprise.ts @@ -1,8 +1,7 @@ -import type { OperationResult } from '@rocket.chat/rest-typings'; import type { UseQueryResult } from '@tanstack/react-query'; import { useLicenseBase } from './useLicense'; -export const useIsEnterprise = (): UseQueryResult> => { +export const useIsEnterprise = (): UseQueryResult<{ isEnterprise: boolean }> => { return useLicenseBase({ select: (data) => ({ isEnterprise: Boolean(data?.license.license) }) }); }; diff --git a/apps/meteor/ee/server/api/licenses.ts b/apps/meteor/ee/server/api/licenses.ts index 22ddbda9e31e..9d8d60c0be51 100644 --- a/apps/meteor/ee/server/api/licenses.ts +++ b/apps/meteor/ee/server/api/licenses.ts @@ -7,23 +7,6 @@ import { API } from '../../../app/api/server/api'; import { hasPermissionAsync } from '../../../app/authorization/server/functions/hasPermission'; import { notifyOnSettingChangedById } from '../../../app/lib/server/lib/notifyListener'; -API.v1.addRoute( - 'licenses.get', - { authRequired: true, deprecation: { version: '7.0.0', alternatives: ['licenses.info'] } }, - { - async get() { - if (!(await hasPermissionAsync(this.userId, 'view-privileged-setting'))) { - return API.v1.unauthorized(); - } - - const license = License.getUnmodifiedLicenseAndModules(); - const licenses = license ? [license] : []; - - return API.v1.success({ licenses }); - }, - }, -); - API.v1.addRoute( 'licenses.info', { authRequired: true, validateParams: isLicensesInfoProps }, @@ -73,14 +56,3 @@ API.v1.addRoute( }, }, ); - -API.v1.addRoute( - 'licenses.isEnterprise', - { authOrAnonRequired: true, deprecation: { version: '7.0.0', alternatives: ['licenses.info'] } }, - { - get() { - const isEnterpriseEdition = License.hasValidLicense(); - return API.v1.success({ isEnterprise: isEnterpriseEdition }); - }, - }, -); diff --git a/apps/meteor/tests/end-to-end/api/licenses.ts b/apps/meteor/tests/end-to-end/api/licenses.ts index 10dce4177aec..931f9958846b 100644 --- a/apps/meteor/tests/end-to-end/api/licenses.ts +++ b/apps/meteor/tests/end-to-end/api/licenses.ts @@ -70,46 +70,6 @@ describe('licenses', () => { }); }); - describe('[/licenses.get]', () => { - it('should fail if not logged in', (done) => { - void request - .get(api('licenses.get')) - .expect('Content-Type', 'application/json') - .expect(401) - .expect((res) => { - expect(res.body).to.have.property('status', 'error'); - expect(res.body).to.have.property('message'); - }) - .end(done); - }); - - it('should fail if user is unauthorized', (done) => { - void request - .get(api('licenses.get')) - .set(unauthorizedUserCredentials) - .expect('Content-Type', 'application/json') - .expect(403) - .expect((res) => { - expect(res.body).to.have.property('success', false); - expect(res.body).to.have.property('error', 'unauthorized'); - }) - .end(done); - }); - - it('should return licenses if user is logged in and is authorized', (done) => { - void request - .get(api('licenses.get')) - .set(credentials) - .expect(200) - .expect((res) => { - expect(res.body).to.have.property('success', true); - expect(res.body).to.have.property('licenses').and.to.be.an('array'); - }) - - .end(done); - }); - }); - describe('[/licenses.info]', () => { it('should fail if not logged in', (done) => { void request @@ -155,42 +115,4 @@ describe('licenses', () => { .end(done); }); }); - - describe('[/licenses.isEnterprise]', () => { - it('should fail if not logged in', (done) => { - void request - .get(api('licenses.isEnterprise')) - .expect('Content-Type', 'application/json') - .expect(401) - .expect((res) => { - expect(res.body).to.have.property('status', 'error'); - expect(res.body).to.have.property('message'); - }) - .end(done); - }); - - it('should pass if user has user role', (done) => { - void request - .get(api('licenses.isEnterprise')) - .set(unauthorizedUserCredentials) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.property('isEnterprise', Boolean(process.env.IS_EE)); - }) - .end(done); - }); - - it('should pass if user has admin role', (done) => { - void request - .get(api('licenses.isEnterprise')) - .set(credentials) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.property('isEnterprise', Boolean(process.env.IS_EE)); - }) - .end(done); - }); - }); }); diff --git a/packages/mock-providers/src/MockedServerContext.tsx b/packages/mock-providers/src/MockedServerContext.tsx index 1f30cd6f1c2f..84bca6c1d69d 100644 --- a/packages/mock-providers/src/MockedServerContext.tsx +++ b/packages/mock-providers/src/MockedServerContext.tsx @@ -9,8 +9,6 @@ export const MockedServerContext = ({ handleRequest, handleMethod, children, - - isEnterprise, }: { handleRequest?: (args: { method: TMethod; @@ -41,14 +39,6 @@ export const MockedServerContext = ({ keys: UrlParams; params: OperationParams; }) => { - if (isEnterprise !== undefined) { - if (args.method === 'GET' && args.pathPattern === '/v1/licenses.isEnterprise') { - return { - isEnterprise, - } as any; - } - } - return handleRequest?.(args); }, getStream: () => () => undefined, diff --git a/packages/rest-typings/src/v1/licenses.ts b/packages/rest-typings/src/v1/licenses.ts index 4a18bc113a6c..99ba936e3492 100644 --- a/packages/rest-typings/src/v1/licenses.ts +++ b/packages/rest-typings/src/v1/licenses.ts @@ -1,4 +1,4 @@ -import type { ILicenseV2, ILicenseV3, LicenseInfo } from '@rocket.chat/core-typings'; +import type { LicenseInfo } from '@rocket.chat/core-typings'; import Ajv from 'ajv'; const ajv = new Ajv({ @@ -40,9 +40,6 @@ const licensesInfoPropsSchema = { export const isLicensesInfoProps = ajv.compile(licensesInfoPropsSchema); export type LicensesEndpoints = { - '/v1/licenses.get': { - GET: () => { licenses: Array }; - }; '/v1/licenses.info': { GET: (params: licensesInfoProps) => { license: LicenseInfo; @@ -57,7 +54,4 @@ export type LicensesEndpoints = { '/v1/licenses.requestSeatsLink': { GET: () => { url: string }; }; - '/v1/licenses.isEnterprise': { - GET: () => { isEnterprise: boolean }; - }; };