diff --git a/.changeset/plenty-garlics-fly.md b/.changeset/plenty-garlics-fly.md new file mode 100644 index 00000000000..b8acbc528e8 --- /dev/null +++ b/.changeset/plenty-garlics-fly.md @@ -0,0 +1,10 @@ +--- +"@wso2is/admin.server-configurations.v1": minor +"@wso2is/admin.sms-providers.v1": minor +"@wso2is/admin.connections.v1": minor +"@wso2is/admin.extensions.v1": minor +"@wso2is/admin.validation.v1": minor +"@wso2is/admin.core.v1": minor +--- + +Completely refactor the admin.extensions.v1/components directly and move the logic to related features. diff --git a/features/admin.connections.v1/api/connections.ts b/features/admin.connections.v1/api/connections.ts index 8d717291641..559f64b48f3 100644 --- a/features/admin.connections.v1/api/connections.ts +++ b/features/admin.connections.v1/api/connections.ts @@ -28,7 +28,6 @@ import { IdentityAppsApiException } from "@wso2is/core/exceptions"; import { HttpMethods } from "@wso2is/core/models"; import { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios"; import { ConnectionUIConstants } from "../constants/connection-ui-constants"; -import { NotificationSenderSMSInterface } from "../models/authenticators"; import { ApplicationBasicInterface, ConnectedAppsInterface, @@ -1071,35 +1070,6 @@ export const updateImplicitAssociationConfig = ( }); }; -/** - * Hook to get all sms notification senders with name SMSPublisher. - * - * @returns A promise containing the response. - */ -export const useSMSNotificationSenders = (): - RequestResultInterface => { - const { resourceEndpoints } = useResourceEndpoints(); - - const requestConfig: RequestConfigInterface = { - headers: { - "Accept": "application/json", - "Content-Type": "application/json" - }, - method: HttpMethods.GET, - url: resourceEndpoints.notificationSendersEndPoint + "/sms" - }; - - const { data, error, isValidating, mutate } = useRequest(requestConfig); - - return { - data, - error: error, - isLoading: !error && !data, - isValidating, - mutate: mutate - }; -}; - /** * Get connection groups list. * diff --git a/features/admin.connections.v1/components/edit/connection-edit.tsx b/features/admin.connections.v1/components/edit/connection-edit.tsx index 9859517b302..8b382c2f5a3 100644 --- a/features/admin.connections.v1/components/edit/connection-edit.tsx +++ b/features/admin.connections.v1/components/edit/connection-edit.tsx @@ -34,8 +34,10 @@ import React, { useEffect, useState } from "react"; +import { useTranslation } from "react-i18next"; import { useSelector } from "react-redux"; import { TabProps } from "semantic-ui-react"; +import QuickStartTab from "./quick-start-tab"; import { AdvanceSettings, AttributeSettings, @@ -153,6 +155,8 @@ export const EditConnection: FunctionComponent = ( [ "data-testid" ]: testId } = props; + const { t } = useTranslation(); + const featureConfig : FeatureConfigInterface = useSelector((state: AppState) => state.config.ui.features); const [ tabPaneExtensions, setTabPaneExtensions ] = useState(undefined); @@ -375,24 +379,40 @@ export const EditConnection: FunctionComponent = ( let extensions: ResourceTabPaneInterface[] = []; if (typeof connectionSettingsMetaData?.edit?.tabs?.quickStart === "string") { - extensions = identityProviderConfig - .editIdentityProvider.getTabExtensions({ - content: lazy( - () => import(`../../resources/guides/${ - connectionSettingsMetaData?.edit?.tabs?.quickStart - }/quick-start.tsx`) - ), - identityProvider: identityProvider, - template: template - }); + extensions = [ + { + componentId: "quick-start", + menuItem: t("console:develop.componentExtensions.component.application.quickStart.title"), + render: () => ( + + import( + `../../resources/guides/${ + connectionSettingsMetaData?.edit?.tabs?.quickStart + }/quick-start.tsx` + ) + ) } + identityProvider={ identityProvider } + template={ template } + /> + ) + } + ]; } else { - extensions = identityProviderConfig - .editIdentityProvider.getTabExtensions({ - content: lazy(() => import("./connection-quick-start")), - identityProvider: identityProvider, - quickStartContent: connectionSettingsMetaData?.edit?.tabs?.quickStart, - template: template - }); + extensions = [ + { + componentId: "quick-start", + menuItem: t("console:develop.componentExtensions.component.application.quickStart.title"), + render: () => ( + import("./connection-quick-start")) } + identityProvider={ identityProvider } + quickStartContent={ connectionSettingsMetaData?.edit?.tabs?.quickStart } + template={ template } + /> + ) + } + ]; } if (Array.isArray(extensions) && extensions.length > 0) { diff --git a/features/admin.connections.v1/components/edit/edit-multi-factor-authenticator.tsx b/features/admin.connections.v1/components/edit/edit-multi-factor-authenticator.tsx index 0b593f3ebd1..9a813c26077 100644 --- a/features/admin.connections.v1/components/edit/edit-multi-factor-authenticator.tsx +++ b/features/admin.connections.v1/components/edit/edit-multi-factor-authenticator.tsx @@ -16,10 +16,7 @@ * under the License. */ -import { - AuthenticatorExtensionsConfigInterface, - identityProviderConfig -} from "@wso2is/admin.extensions.v1"; +import { AuthenticatorExtensionsConfigInterface } from "@wso2is/admin.extensions.v1"; import { authenticatorConfig } from "@wso2is/admin.extensions.v1/configs/authenticator"; import { AuthenticatorFormFactory } from "@wso2is/admin.identity-providers.v1/components/forms"; import { IdentityAppsApiException } from "@wso2is/core/exceptions"; @@ -32,6 +29,7 @@ import { useTranslation } from "react-i18next"; import { useDispatch } from "react-redux"; import { Dispatch } from "redux"; import { Grid, SemanticShorthandItem, TabPaneProps } from "semantic-ui-react"; +import QuickStartTab from "./quick-start-tab"; import { updateMultiFactorAuthenticatorDetails } from "../../api/authenticators"; import { LocalAuthenticatorConstants } from "../../constants/local-authenticator-constants"; import { AuthenticatorMeta } from "../../meta/authenticator-meta"; @@ -116,10 +114,13 @@ export const EditMultiFactorAuthenticator: FunctionComponent + } + ]; setTabPaneExtensions(extensions); }, [ authenticator, tabPaneExtensions ]); diff --git a/features/admin.extensions.v1/components/component-extensions/application/quick-start-tab.tsx b/features/admin.connections.v1/components/edit/quick-start-tab.tsx similarity index 71% rename from features/admin.extensions.v1/components/component-extensions/application/quick-start-tab.tsx rename to features/admin.connections.v1/components/edit/quick-start-tab.tsx index 0ae0019e03c..09033371efd 100644 --- a/features/admin.extensions.v1/components/component-extensions/application/quick-start-tab.tsx +++ b/features/admin.connections.v1/components/edit/quick-start-tab.tsx @@ -1,5 +1,5 @@ /** - * Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + * Copyright (c) 2020-2024, WSO2 LLC. (https://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -21,28 +21,36 @@ import { ResourceTab } from "@wso2is/react-components"; import React, { ElementType, FunctionComponent, ReactElement } from "react"; import { Grid } from "semantic-ui-react"; +/** + * Props interface for the QuickStartTab component. + */ interface QuickStartTabPropsInterface extends TestableComponentInterface { + /** + * Content to be rendered. + */ content: ElementType; + /** + * Dynamic attributes for the component. + */ + [key: string]: any; } /** - * A function returning a ReactElement to render tab panes. + * QuickStartTab component. + * + * @param props - Props injected to the component. + * @returns The QuickStartTab component. */ -const QuickStartTab: FunctionComponent = ( - props: QuickStartTabPropsInterface -): ReactElement => { - - const { - content: Content, - [ "data-testid" ]: testId, - ...rest - } = props; - +const QuickStartTab: FunctionComponent = ({ + content: Content, + ["data-testid"]: testId, + ...rest +}: QuickStartTabPropsInterface): ReactElement => { return ( - + diff --git a/features/admin.extensions.v1/components/identity-providers/constants/swe-constants.ts b/features/admin.connections.v1/constants/siwe-constants.ts similarity index 94% rename from features/admin.extensions.v1/components/identity-providers/constants/swe-constants.ts rename to features/admin.connections.v1/constants/siwe-constants.ts index 47a4e996a68..05a5ab848b6 100644 --- a/features/admin.extensions.v1/components/identity-providers/constants/swe-constants.ts +++ b/features/admin.connections.v1/constants/siwe-constants.ts @@ -19,18 +19,15 @@ /** * Class containing Sign In With Ethereum IDP constants. */ -export class SIWEConstants { +class SIWEConstants { + /** + * Private constructor to avoid object instantiation from outside the class. + */ + private constructor() {} public static readonly SIWE_REGISTRATION_INVALID_STATUS_CODE_ERROR_CODE: string = "ASG-CON-SIWE-00001"; public static readonly SIWE_REGISTRATION_ERROR_CODE: string = "ASG-CON-SIWE-00002"; - /** - * Private constructor to avoid object instantiation from outside - * the class. - * -] */ - private constructor() { } - public static readonly SIWE_CLIENT_REGISTRATION_DOCS_URL: string = "https://docs.login.xyz/servers/" + "oidc-provider/hosted-oidc-provider#openid-connect-client-registration"; @@ -52,5 +49,7 @@ export class SIWEConstants { CALLBACK_URL: "callbackUrl", CLIENT_ID: "ClientId", CLIENT_SECRET: "ClientSecret" - } + }; } + +export default SIWEConstants; diff --git a/features/admin.connections.v1/models/authenticators.ts b/features/admin.connections.v1/models/authenticators.ts index 9f5051d5f0d..b9b2e097f3c 100644 --- a/features/admin.connections.v1/models/authenticators.ts +++ b/features/admin.connections.v1/models/authenticators.ts @@ -193,17 +193,3 @@ export type CommonAuthenticatorFormPropertyInterface = CommonPluggableComponentP export interface CommonAuthenticatorFormFieldInterface extends CommonAuthenticatorFormPropertyInterface { meta: CommonPluggableComponentMetaPropertyInterface; } - -/** - * Interface for SMS Notification Sender Details. - **/ -export interface NotificationSenderSMSInterface { - name: string; - provider: string; - providerURL: string; - contentType: string; - properties?: { - key: string; - value: string; - }[]; -} diff --git a/features/admin.extensions.v1/components/identity-providers/models/swe.ts b/features/admin.connections.v1/models/siwe.ts similarity index 92% rename from features/admin.extensions.v1/components/identity-providers/models/swe.ts rename to features/admin.connections.v1/models/siwe.ts index 88a966634a0..688bc642037 100644 --- a/features/admin.extensions.v1/components/identity-providers/models/swe.ts +++ b/features/admin.connections.v1/models/siwe.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + * Copyright (c) 2022-2024, WSO2 LLC. (https://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except diff --git a/features/admin.core.v1/configs/app.ts b/features/admin.core.v1/configs/app.ts index ccb7c08d18e..3590685c17c 100644 --- a/features/admin.core.v1/configs/app.ts +++ b/features/admin.core.v1/configs/app.ts @@ -39,6 +39,7 @@ import { getRemoteFetchConfigResourceEndpoints } from "@wso2is/admin.remote-repo import { getRolesResourceEndpoints } from "@wso2is/admin.roles.v2/configs/endpoints"; import { getSecretsManagementEndpoints } from "@wso2is/admin.secrets.v1/configs/endpoints"; import { getServerConfigurationsResourceEndpoints } from "@wso2is/admin.server-configurations.v1"; +import { getSMSProvidersResourceEndpoints } from "@wso2is/admin.sms-providers.v1/configs/endpoints"; import { getExtensionTemplatesEndpoints } from "@wso2is/admin.template-core.v1/configs/endpoints"; import { getTenantResourceEndpoints } from "@wso2is/admin.tenants.v1/configs/endpoints"; import { getUsersResourceEndpoints } from "@wso2is/admin.users.v1/configs/endpoints"; @@ -266,6 +267,7 @@ export class Config { ...getExtensionTemplatesEndpoints(this.resolveServerHost()), ...getApplicationTemplatesResourcesEndpoints(this.resolveServerHost()), ...getActionsResourceEndpoints(this.resolveServerHost()), + ...getSMSProvidersResourceEndpoints(this.resolveServerHost()), CORSOrigins: `${ this.getDeploymentConfig()?.serverHost }/api/server/v1/cors/origins`, // TODO: Remove this endpoint and use ID token to get the details me: `${ this.getDeploymentConfig()?.serverHost }/scim2/Me`, diff --git a/features/admin.core.v1/models/config.ts b/features/admin.core.v1/models/config.ts index 4f2bb5ce693..f6b68a2ebf0 100644 --- a/features/admin.core.v1/models/config.ts +++ b/features/admin.core.v1/models/config.ts @@ -34,6 +34,7 @@ import { OrganizationResourceEndpointsInterface } from "@wso2is/admin.organizati import { RolesResourceEndpointsInterface } from "@wso2is/admin.roles.v2/models/endpoints"; import { SecretsManagementEndpoints } from "@wso2is/admin.secrets.v1/models/endpoints"; import { ServerConfigurationsResourceEndpointsInterface } from "@wso2is/admin.server-configurations.v1"; +import { SMSProvidersResourceEndpointsInterface } from "@wso2is/admin.sms-providers.v1/models/endpoints"; import { ExtensionTemplatesEndpointsInterface } from "@wso2is/admin.template-core.v1/models/endpoints"; import { TenantResourceEndpointsInterface } from "@wso2is/admin.tenants.v1/models/endpoints"; import { UsersResourceEndpointsInterface } from "@wso2is/admin.users.v1/models/endpoints"; @@ -541,7 +542,8 @@ export interface ServiceResourceEndpointsInterface extends ClaimResourceEndpoint ConsoleSettingsResourceEndpointsInterface, ExtensionTemplatesEndpointsInterface, ApplicationsTemplatesEndpointsInterface, - ActionsResourceEndpointsInterface { + ActionsResourceEndpointsInterface, + SMSProvidersResourceEndpointsInterface { CORSOrigins: string; // TODO: Remove this endpoint and use ID token to get the details diff --git a/features/admin.core.v1/store/reducers/config.ts b/features/admin.core.v1/store/reducers/config.ts index d87ee6379a3..eb0e4494efb 100644 --- a/features/admin.core.v1/store/reducers/config.ts +++ b/features/admin.core.v1/store/reducers/config.ts @@ -152,6 +152,8 @@ export const commonConfigReducerInitialState: CommonConfigReducerStateInterface< selfSignUp: "", serverConfigurations: "", serverSupportedSchemas: "", + smsPublisher: "", + smsSender: "", tenantAssociationApi: "", tenantManagementApi: "", tenantSubscriptionApi: "", diff --git a/features/admin.extensions.v1/components/claims/api/claims.ts b/features/admin.extensions.v1/components/claims/api/claims.ts deleted file mode 100644 index a4cdf047e67..00000000000 --- a/features/admin.extensions.v1/components/claims/api/claims.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2021, WSO2 LLC. (https://www.wso2.com). - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { AsgardeoSPAClient } from "@asgardeo/auth-react"; -import { store } from "@wso2is/admin.core.v1"; -import { HttpMethods } from "@wso2is/core/models"; - -/** - * Get an axios instance. - * - */ -const httpClient = AsgardeoSPAClient.getInstance().httpRequest.bind(AsgardeoSPAClient.getInstance()); - -export const getDialects = (): Promise => { - const requestConfig = { - headers: { - Accept: "application/json", - "Access-Control-Allow-Origin": store.getState().config.deployment.clientHost, - "Content-Type": "application/json" - }, - method: HttpMethods.GET, - url: `${store.getState().config.endpoints.claims}/` - }; - - return httpClient(requestConfig) - .then((response) => { - if (response.status !== 200) { - return Promise.reject(`An error occurred. The server returned ${response.status}`); - } - - return Promise.resolve(response.data); - }) - .catch((error) => { - return Promise.reject(error?.response?.data); - }); -}; - -export const getClaimsForDialect = (dialectID: string): Promise => { - const requestConfig = { - headers: { - Accept: "application/json", - "Access-Control-Allow-Origin": store.getState().config.deployment.clientHost, - "Content-Type": "application/json" - }, - method: HttpMethods.GET, - url: `${store.getState().config.endpoints.externalClaims.replace("{}", dialectID)}/` - }; - - return httpClient(requestConfig) - .then((response) => { - if (response.status !== 200) { - return Promise.reject(`An error occurred. The server returned ${response.status}`); - } - - return Promise.resolve(response.data); - }) - .catch((error) => { - return Promise.reject(error?.response?.data); - }); -}; diff --git a/features/admin.extensions.v1/components/claims/api/index.ts b/features/admin.extensions.v1/components/claims/api/index.ts deleted file mode 100644 index c09b932918f..00000000000 --- a/features/admin.extensions.v1/components/claims/api/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2021, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export * from "./claims"; diff --git a/features/admin.extensions.v1/components/component-extensions/tests/__mocks__/mock.application.js b/features/admin.extensions.v1/components/component-extensions/tests/__mocks__/mock.application.js deleted file mode 100644 index bc97e71f8f6..00000000000 --- a/features/admin.extensions.v1/components/component-extensions/tests/__mocks__/mock.application.js +++ /dev/null @@ -1,81 +0,0 @@ - -/** - * Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -// Note : Charachter limit is ignored since it's a mock response file. -module.exports = () => { - return { - "id": "08d07118-ab66-4341-90ff-8c7626b327ca", - "name": "MobitelSelfCare", - "description": "Front-end applications that consume REST APIs.", - "templateId": "6a90e4b0-fbff-42d7-bfde-1efd98f07cd7", - "claimConfiguration": { - "dialect": "LOCAL", - "claimMappings": [], - "requestedClaims": [], - "subject": { - "claim": { - "uri": "http://wso2.org/claims/username" - }, - "includeUserDomain": false, - "includeTenantDomain": false, - "useMappedLocalSubject": false - }, - "role": { - "includeUserDomain": true, - "claim": { - "uri": "http://wso2.org/claims/role" - } - } - }, - "inboundProtocols": [ - { - "type": "oauth2", - "self": "/t/carbon.super/api/server/v1/applications/08d07118-ab66-4341-90ff-8c7626b327ca/inbound-protocols/oidc" - } - ], - "authenticationSequence": { - "type": "DEFAULT", - "steps": [ - { - "id": 1, - "options": [ - { - "idp": "LOCAL", - "authenticator": "BasicAuthenticator" - } - ] - } - ], - "requestPathAuthenticators": [], - "subjectStepId": 1, - "attributeStepId": 1 - }, - "advancedConfigurations": { - "saas": false, - "discoverableByEndUsers": false, - "skipLoginConsent": true, - "skipLogoutConsent": true, - "returnAuthenticatedIdpList": false, - "enableAuthorization": false - }, - "provisioningConfigurations": { - "outboundProvisioningIdps": [] - } - } -} diff --git a/features/admin.extensions.v1/components/component-extensions/tests/__mocks__/mock.oidcconfig.js b/features/admin.extensions.v1/components/component-extensions/tests/__mocks__/mock.oidcconfig.js deleted file mode 100644 index fc9bb2b3304..00000000000 --- a/features/admin.extensions.v1/components/component-extensions/tests/__mocks__/mock.oidcconfig.js +++ /dev/null @@ -1,384 +0,0 @@ -/** - * Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -// Note : Charachter limit is ignored since it's a mock response file. -module.exports = { - "groupedTemplates": [ - { - "authenticationProtocol": "", - "category": "DEFAULT_CUSTOM", - "description": "Manually configure the inbound authentication protocol, authentication flow, etc.", - "displayOrder": 0, - "id": "custom-application", - "image": "customApp", - "name": "Custom Application", - "self": "", - "types": [ - - ] - }, - { - "category": "DEFAULT_GROUP", - "description": "Regular web applications which uses re-directions inside browsers.", - "id": "web-application", - "image": "oidcWebApp", - "name": "Web Application", - "subTemplatesSectionTitle": "Protocols", - "subTemplates": [ - { - "id": "b9c5e11e-fc78-484b-9bec-015d247561b8", - "name": "OpenID Connect", - "description": "Regular web applications which uses re-directions inside browsers.", - "image": "oidc", - "authenticationProtocol": "oidc", - "types": [ - "java", - "dotNet" - ], - "category": "DEFAULT", - "displayOrder": 1, - "templateGroup": "web-application", - "self": "/t/carbon.super/api/server/v1/applications/templates/b9c5e11e-fc78-484b-9bec-015d247561b8" - }, - { - "id": "776a73da-fd8e-490b-84ff-93009f8ede85", - "name": "SAML", - "description": "Regular web applications which uses redirections inside browsers.", - "image": "saml", - "authenticationProtocol": "saml", - "types": [ - "java", - "dotNet" - ], - "category": "DEFAULT", - "displayOrder": 2, - "templateGroup": "web-application", - "self": "/t/carbon.super/api/server/v1/applications/templates/776a73da-fd8e-490b-84ff-93009f8ede85" - } - ] - }, - { - "id": "6a90e4b0-fbff-42d7-bfde-1efd98f07cd7", - "name": "Single-Page Application", - "description": "Front-end applications that consume REST APIs.", - "image": "spa", - "authenticationProtocol": "oidc", - "types": [ - "react", - "angular", - "vue" - ], - "category": "DEFAULT", - "displayOrder": 3, - "templateGroup": "spa", - "self": "/t/carbon.super/api/server/v1/applications/templates/6a90e4b0-fbff-42d7-bfde-1efd98f07cd7" - }, - { - "category": "DEFAULT_GROUP", - "description": "Applications developed to target native desktops.", - "id": "desktop", - "image": "windowsNative", - "name": "Desktop Application", - "subTemplatesSectionTitle": "Technology", - "subTemplates": [ - { - "id": "df929521-6768-44f5-8586-624126ec3f8b", - "name": "Windows", - "description": "Applications developed to target windows desktops.", - "image": "windows", - "authenticationProtocol": "oidc", - "types": [ - "dotNet" - ], - "category": "DEFAULT", - "displayOrder": 4, - "templateGroup": "desktop", - "self": "/t/carbon.super/api/server/v1/applications/templates/df929521-6768-44f5-8586-624126ec3f8b" - } - ] - }, - { - "category": "DEFAULT_GROUP", - "description": "Applications developed to target mobiles devices.", - "id": "mobile", - "image": "oidcMobile", - "name": "Mobile Application", - "subTemplatesSectionTitle": "Technology", - "subTemplates": [ - { - "id": "44a2d9d9-bc0c-4b54-85df-1cf08f4002ec", - "name": "Android", - "description": "Applications developed to target Android mobiles devices.", - "image": "android", - "authenticationProtocol": "oidc", - "types": [ - "android" - ], - "category": "DEFAULT", - "displayOrder": 5, - "templateGroup": "mobile", - "self": "/t/carbon.super/api/server/v1/applications/templates/44a2d9d9-bc0c-4b54-85df-1cf08f4002ec" - } - ] - }, - { - "id": "h9c5e23e-fc78-484b-9bec-015d242361b8", - "name": "Box", - "description": "Cloud content management and file sharing service for businesses.", - "image": "box", - "authenticationProtocol": "oidc", - "types": [ - "Communication" - ], - "category": "VENDOR", - "displayOrder": 6, - "self": "/t/carbon.super/api/server/v1/applications/templates/h9c5e23e-fc78-484b-9bec-015d242361b8" - }, - { - "id": "z345e11e-fc78-484b-9bec-015d2475u341r", - "name": "Slack", - "description": "Business communication platform with persistent chat rooms.", - "image": "slack", - "authenticationProtocol": "oidc", - "types": [ - "Communication", - "Community" - ], - "category": "VENDOR", - "displayOrder": 7, - "self": "/t/carbon.super/api/server/v1/applications/templates/z345e11e-fc78-484b-9bec-015d2475u341r" - }, - { - "id": "r565e11e-fc78-484b-9bec-015d24753456", - "name": "Workday", - "description": "On‑demand financial management and human capital management.", - "image": "workday", - "authenticationProtocol": "oidc", - "types": [ - "HR" - ], - "category": "VENDOR", - "displayOrder": 8, - "self": "/t/carbon.super/api/server/v1/applications/templates/r565e11e-fc78-484b-9bec-015d24753456" - }, - { - "id": "t565e11e-fc78-484b-9bec-015d2472008", - "name": "Zoom", - "description": "Enterprise video communications through online chat services.", - "image": "zoom", - "authenticationProtocol": "oidc", - "types": [ - "Communication" - ], - "category": "VENDOR", - "displayOrder": 9, - "self": "/t/carbon.super/api/server/v1/applications/templates/t565e11e-fc78-484b-9bec-015d2472008" - } - ], - "meta": { - "customInboundProtocolChecked": false, - "customInboundProtocols": [ - - ], - "inboundProtocols": [ - { - "displayName": "OpenID Connect", - "enabled": true, - "id": "oidc", - "logo": "oidc", - "name": "oidc", - "type": "oauth2" - }, - { - "displayName": "SAML 2.0", - "enabled": true, - "id": "saml", - "logo": "saml", - "name": "saml", - "type": "samlsso" - }, - { - "displayName": "WS-Trust", - "enabled": true, - "id": "ws-trust", - "logo": "wsTrust", - "name": "ws-trust", - "type": "wstrust" - } - ], - "protocolMeta": { - - } - }, - "oidcConfigurations": { - "authorizeEndpoint": "https://localhost:9443/oauth2/authorize", - "introspectionEndpoint": "https://localhost:9443/oauth2/introspect", - "jwksEndpoint": "https://localhost:9443/oauth2/jwks", - "tokenEndpoint": "https://localhost:9443/oauth2/token", - "userEndpoint": "https://localhost:9443/oauth2/userinfo" - }, - "samlConfigurations": { - "certificate": "MIIDqTCCApGgAwIBAgIEXbABozANBgkqhkiG9w0BAQsFADBkMQswCQYDVQQGEwJVUzELMAkGA1UE\nCAwCQ0ExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxDTALBgNVBAoMBFdTTzIxDTALBgNVBAsMBFdT\nTzIxEjAQBgNVBAMMCWxvY2FsaG9zdDAeFw0xOTEwMjMwNzMwNDNaFw0yMjAxMjUwNzMwNDNaMGQx\nCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDQTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzENMAsGA1UE\nCgwEV1NPMjENMAsGA1UECwwEV1NPMjESMBAGA1UEAwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0B\nAQEFAAOCAQ8AMIIBCgKCAQEAxeqoZYbQ/Sr8DOFQ+/qbEbCp6Vzb5hzH7oa3hf2FZxRKF0H6b8CO\nMzz8+0mvEdYVvb/31jMEL2CIQhkQRol1IruD6nBOmkjuXJSBficklMaJZORhuCrB4roHxzoG19aW\nmscA0gnfBKo2oGXSjJmnZxIh+2X6syHCfyMZZ00LzDyrgoXWQXyFvCA2ax54s7sKiHOM3P4A9W4Q\nUwmoEi4HQmPgJjIM4eGVPh0GtIANN+BOQ1KkUI7OzteHCTLu3VjxM0sw8QRayZdhniPF+U9n3fa1\nmO4KLBsW4mDLjg8R/JuAGTX/SEEGj0B5HWQAP6myxKFz2xwDaCGvT+rdvkktOwIDAQABo2MwYTAU\nBgNVHREEDTALgglsb2NhbGhvc3QwHQYDVR0OBBYEFEDpLB4PDgzsdxD2FV3rVnOr/A0DMB0GA1Ud\nJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjALBgNVHQ8EBAMCBPAwDQYJKoZIhvcNAQELBQADggEB\nAE8H/axAgXjt93HGCYGumULW2lKkgqEvXryP2QkRpbyQSsTYcL7ZLSVB7MVVHtIsHh8f1C4Xq6Qu\n8NUrqu5ZLC1pUByaqR2ZIzcj/OWLGYRjSTHSVmVIq9QqBq1j7r6f3BWqaOIiknmTzEuqIVlOTY0g\nO+SHdS62vr2FCz4yOrBEulGAvomsU8sqg4PhFnkhxI4M912Ly+2RgN9L7AkhzK+EzXY1/QtlI/Vy\nsNfS6zrHasKz6CrKKCGqQnBnSvSTyF9OR5KFHnkAwE995IZrcSQicMxsLhTMUHDLQ/gRyy7V/ZpD\nMfAWR+5OeQiNAp/bG4fjJoTdoqkul51+2bHHVrU=", - "issuer": "localhost", - "metadata": "MIIDqTCCApGgAwIBAgIEXbABozANBgkqhkiG9w0BAQsFADBkMQswCQYDVQQGEwJVUzELMAkGA1UE\nCAwCQ0ExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxDTALBgNVBAoMBFdTTzIxDTALBgNVBAsMBFdT\nTzIxEjAQBgNVBAMMCWxvY2FsaG9zdDAeFw0xOTEwMjMwNzMwNDNaFw0yMjAxMjUwNzMwNDNaMGQx\nCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDQTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzENMAsGA1UE\nCgwEV1NPMjENMAsGA1UECwwEV1NPMjESMBAGA1UEAwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0B\nAQEFAAOCAQ8AMIIBCgKCAQEAxeqoZYbQ/Sr8DOFQ+/qbEbCp6Vzb5hzH7oa3hf2FZxRKF0H6b8CO\nMzz8+0mvEdYVvb/31jMEL2CIQhkQRol1IruD6nBOmkjuXJSBficklMaJZORhuCrB4roHxzoG19aW\nmscA0gnfBKo2oGXSjJmnZxIh+2X6syHCfyMZZ00LzDyrgoXWQXyFvCA2ax54s7sKiHOM3P4A9W4Q\nUwmoEi4HQmPgJjIM4eGVPh0GtIANN+BOQ1KkUI7OzteHCTLu3VjxM0sw8QRayZdhniPF+U9n3fa1\nmO4KLBsW4mDLjg8R/JuAGTX/SEEGj0B5HWQAP6myxKFz2xwDaCGvT+rdvkktOwIDAQABo2MwYTAU\nBgNVHREEDTALgglsb2NhbGhvc3QwHQYDVR0OBBYEFEDpLB4PDgzsdxD2FV3rVnOr/A0DMB0GA1Ud\nJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjALBgNVHQ8EBAMCBPAwDQYJKoZIhvcNAQELBQADggEB\nAE8H/axAgXjt93HGCYGumULW2lKkgqEvXryP2QkRpbyQSsTYcL7ZLSVB7MVVHtIsHh8f1C4Xq6Qu\n8NUrqu5ZLC1pUByaqR2ZIzcj/OWLGYRjSTHSVmVIq9QqBq1j7r6f3BWqaOIiknmTzEuqIVlOTY0g\nO+SHdS62vr2FCz4yOrBEulGAvomsU8sqg4PhFnkhxI4M912Ly+2RgN9L7AkhzK+EzXY1/QtlI/Vy\nsNfS6zrHasKz6CrKKCGqQnBnSvSTyF9OR5KFHnkAwE995IZrcSQicMxsLhTMUHDLQ/gRyy7V/ZpD\nMfAWR+5OeQiNAp/bG4fjJoTdoqkul51+2bHHVrU=", - "sloUrl": "https://localhost:9443/samlsso", - "ssoUrl": "https://localhost:9443/samlsso" - }, - "templates": [ - { - "authenticationProtocol": "", - "category": "DEFAULT_CUSTOM", - "description": "Manually configure the inbound authentication protocol, authentication flow, etc.", - "displayOrder": 0, - "id": "custom-application", - "image": "customApp", - "name": "Custom Application", - "self": "", - "types": [ - - ] - }, - { - "id": "b9c5e11e-fc78-484b-9bec-015d247561b8", - "name": "OpenID Connect", - "description": "Regular web applications which uses re-directions inside browsers.", - "image": "oidc", - "authenticationProtocol": "oidc", - "types": [ - "java", - "dotNet" - ], - "category": "DEFAULT", - "displayOrder": 1, - "templateGroup": "web-application", - "self": "/t/carbon.super/api/server/v1/applications/templates/b9c5e11e-fc78-484b-9bec-015d247561b8" - }, - { - "id": "776a73da-fd8e-490b-84ff-93009f8ede85", - "name": "SAML", - "description": "Regular web applications which uses redirections inside browsers.", - "image": "saml", - "authenticationProtocol": "saml", - "types": [ - "java", - "dotNet" - ], - "category": "DEFAULT", - "displayOrder": 2, - "templateGroup": "web-application", - "self": "/t/carbon.super/api/server/v1/applications/templates/776a73da-fd8e-490b-84ff-93009f8ede85" - }, - { - "id": "6a90e4b0-fbff-42d7-bfde-1efd98f07cd7", - "name": "Single-Page Application", - "description": "Front-end applications that consume REST APIs.", - "image": "spa", - "authenticationProtocol": "oidc", - "types": [ - "react", - "angular", - "vue" - ], - "category": "DEFAULT", - "displayOrder": 3, - "templateGroup": "spa", - "self": "/t/carbon.super/api/server/v1/applications/templates/6a90e4b0-fbff-42d7-bfde-1efd98f07cd7" - }, - { - "id": "df929521-6768-44f5-8586-624126ec3f8b", - "name": "Windows", - "description": "Applications developed to target windows desktops.", - "image": "windows", - "authenticationProtocol": "oidc", - "types": [ - "dotNet" - ], - "category": "DEFAULT", - "displayOrder": 4, - "templateGroup": "desktop", - "self": "/t/carbon.super/api/server/v1/applications/templates/df929521-6768-44f5-8586-624126ec3f8b" - }, - { - "id": "44a2d9d9-bc0c-4b54-85df-1cf08f4002ec", - "name": "Android", - "description": "Applications developed to target Android mobiles devices.", - "image": "android", - "authenticationProtocol": "oidc", - "types": [ - "android" - ], - "category": "DEFAULT", - "displayOrder": 5, - "templateGroup": "mobile", - "self": "/t/carbon.super/api/server/v1/applications/templates/44a2d9d9-bc0c-4b54-85df-1cf08f4002ec" - }, - { - "id": "h9c5e23e-fc78-484b-9bec-015d242361b8", - "name": "Box", - "description": "Cloud content management and file sharing service for businesses.", - "image": "box", - "authenticationProtocol": "oidc", - "types": [ - "Communication" - ], - "category": "VENDOR", - "displayOrder": 6, - "self": "/t/carbon.super/api/server/v1/applications/templates/h9c5e23e-fc78-484b-9bec-015d242361b8" - }, - { - "id": "z345e11e-fc78-484b-9bec-015d2475u341r", - "name": "Slack", - "description": "Business communication platform with persistent chat rooms.", - "image": "slack", - "authenticationProtocol": "oidc", - "types": [ - "Communication", - "Community" - ], - "category": "VENDOR", - "displayOrder": 7, - "self": "/t/carbon.super/api/server/v1/applications/templates/z345e11e-fc78-484b-9bec-015d2475u341r" - }, - { - "id": "r565e11e-fc78-484b-9bec-015d24753456", - "name": "Workday", - "description": "On‑demand financial management and human capital management.", - "image": "workday", - "authenticationProtocol": "oidc", - "types": [ - "HR" - ], - "category": "VENDOR", - "displayOrder": 8, - "self": "/t/carbon.super/api/server/v1/applications/templates/r565e11e-fc78-484b-9bec-015d24753456" - }, - { - "id": "t565e11e-fc78-484b-9bec-015d2472008", - "name": "Zoom", - "description": "Enterprise video communications through online chat services.", - "image": "zoom", - "authenticationProtocol": "oidc", - "types": [ - "Communication" - ], - "category": "VENDOR", - "displayOrder": 9, - "self": "/t/carbon.super/api/server/v1/applications/templates/t565e11e-fc78-484b-9bec-015d2472008" - } - ] -} diff --git a/features/admin.extensions.v1/components/component-extensions/tests/integrate.test.tsx b/features/admin.extensions.v1/components/component-extensions/tests/integrate.test.tsx deleted file mode 100644 index d082d81166a..00000000000 --- a/features/admin.extensions.v1/components/component-extensions/tests/integrate.test.tsx +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2020-2024, WSO2 LLC. (https://www.wso2.com). - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { render, screen } from "@testing-library/react"; -import React from "react"; -import { Provider } from "react-redux"; -// import { IntegrateAppComponent } from "../application/integrate"; -import configureStore from "redux-mock-store"; -// import MockApplication from "./__mocks__/mock.application"; - -/** - * Test refactoring effort will be tracked in the following issue. - *@see {@link https://github.com/wso2-enterprise/asgardeo-product/issues/1368} - */ -describe("Test Suite - Integrate Extension Component.", () => { - const mockStore: any = configureStore(); - const store: any = mockStore({}); - - test.skip("Test proper rendering of Integrate Component", () => { - render( - - { /**/ } - - ); - }); - - test.skip("Test react technology selection button is in document.", () => { - render( - - { /**/ } - - ); - expect(screen.getByTestId("integrate-technology-react")).toBeInTheDocument(); - }); - - test.skip("Test react technology selection button click.", () => { - render( - - { /**/ } - - ); - // userEvent.click(screen.getByTestId("integrate-technology-react")); - expect(screen.getByTestId("integrate-react-config")).toBeInTheDocument(); - }); -}); diff --git a/features/admin.extensions.v1/components/component-extensions/tests/overview.test.tsx b/features/admin.extensions.v1/components/component-extensions/tests/overview.test.tsx deleted file mode 100644 index 3b7f7f3a60b..00000000000 --- a/features/admin.extensions.v1/components/component-extensions/tests/overview.test.tsx +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { render } from "@testing-library/react"; -import React from "react"; -// import { HelpPanelOverview } from "../application/overview"; -import { Provider } from "react-redux"; -import configureStore from "redux-mock-store"; -// import MockApplication from "./__mocks__/mock.application"; -import MockOidc from "./__mocks__/mock.oidcconfig"; - -/** - * Test refactoring effort will be tracked in the following issue. - *@see {@link https://github.com/wso2-enterprise/asgardeo-product/issues/1368} - */ -describe("Test Suite - Overview Extension Component.", () => { - const mockStore: any= configureStore(); - const store: any = mockStore({ - application: { - ...MockOidc - } - }); - - test.skip("Test proper rendering of Overview Component", () => { - render( - - { /**/ } - - ); - }); -}); diff --git a/features/admin.extensions.v1/components/component-extensions/tests/try-out.test.tsx b/features/admin.extensions.v1/components/component-extensions/tests/try-out.test.tsx deleted file mode 100644 index 503f5020786..00000000000 --- a/features/admin.extensions.v1/components/component-extensions/tests/try-out.test.tsx +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { fireEvent, render, screen } from "@testing-library/react"; -import React from "react"; -// import { TryOutComponent } from "../application/try-out"; -import { Provider } from "react-redux"; -import configureStore from "redux-mock-store"; -// import MockApplication from "./__mocks__/mock.application"; - -/** - * Test refactoring effort will be tracked in the following issue. - *@see {@link https://github.com/wso2-enterprise/asgardeo-product/issues/1368} - */ -describe("Test Suite - Try Out Extension Component.", () => { - const mockStore: any = configureStore(); - const store: any = mockStore({}); - - test.skip("Test proper rendering of Try Out Page", () => { - render( - - { /**/ } - ); - }); - - test.skip("Test download react sample button to be in the document", () => { - render( - - { /**/ } - - ); - expect(screen.getByTestId("try-out-download-react-sample")).toBeInTheDocument(); - }); - - test.skip("Test download config button to be in the document", () => { - render( - - { /* */ } - - ); - expect(screen.getByTestId("try-out-download-config")).toBeInTheDocument(); - }); - - test.skip("Test click event of react sample download button", () => { - const openSpy: any = jest.spyOn(window, "open"); - - render( - - { /**/ } - - ); - fireEvent.click(screen.getByTestId("try-out-download-react-sample")); - expect(openSpy).toHaveBeenCalled(); - }); -}); diff --git a/features/admin.extensions.v1/components/identity-providers/api/identity-provider.ts b/features/admin.extensions.v1/components/identity-providers/api/identity-provider.ts deleted file mode 100644 index 68f1808ad70..00000000000 --- a/features/admin.extensions.v1/components/identity-providers/api/identity-provider.ts +++ /dev/null @@ -1,160 +0,0 @@ -/** - * Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com). - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { AsgardeoSPAClient, HttpClientInstance } from "@asgardeo/auth-react"; -import { store } from "@wso2is/admin.core.v1"; -import useRequest, { - RequestConfigInterface, - RequestErrorInterface, - RequestResultInterface -} from "@wso2is/admin.core.v1/hooks/use-request"; -import { IdentityAppsApiException } from "@wso2is/core/exceptions"; -import { HttpMethods } from "@wso2is/core/models"; -import { AxiosError, AxiosResponse } from "axios"; -import { SMSOTPConstants } from "../constants"; -import { NotificationSenderSMSInterface } from "../models"; - -const httpClient: HttpClientInstance = AsgardeoSPAClient.getInstance().httpRequest - .bind(AsgardeoSPAClient.getInstance()); - -/** - * Hook to get all sms notification senders with name SMSPublisher. - * - * @returns A promise containing the response. - */ -export const useSMSNotificationSenders = (): - RequestResultInterface => { - - const requestConfig: RequestConfigInterface = { - headers: { - "Accept": "application/json", - "Access-Control-Allow-Origin": store.getState().config.deployment.clientHost, - "Content-Type": "application/json" - }, - method: HttpMethods.GET, - url: store.getState().config.endpoints.notificationSendersEndPoint + "/sms" - }; - - const { data, error, isValidating, mutate } = useRequest(requestConfig); - - return { - data, - error: error, - isLoading: !error && !data, - isValidating, - mutate: mutate - }; -}; - -/** - * Add sms notification senders with name SMSPublisher. - * - * @returns A promise containing the response. - */ -export const addSMSPublisher = (): Promise => { - //SMS Notification sender with name SMSPublisher. - const smsProvider: NotificationSenderSMSInterface = { - contentType: "FORM", - name: "SMSPublisher", - properties: [ - { - key: "channel.type", - value: "choreo" - } - ], - provider: "choreo", - providerURL: "https://console.choreo.dev/" - }; - - const requestConfig: RequestConfigInterface = { - data: smsProvider, - headers: { - "Accept": "application/json", - "Access-Control-Allow-Origin": store.getState().config.deployment.clientHost, - "Content-Type": "application/json" - }, - method: HttpMethods.POST, - url: store.getState().config.endpoints.notificationSendersEndPoint + "/sms" - }; - - return httpClient(requestConfig) - .then((response: AxiosResponse) => { - if (response.status !== 201) { - throw new IdentityAppsApiException( - SMSOTPConstants.ERROR_IN_CREATING_SMS_NOTIFICATION_SENDER, - null, - response.status, - response.request, - response, - response.config); - } - - return Promise.resolve(response.data as NotificationSenderSMSInterface); - }).catch((error: AxiosError) => { - throw new IdentityAppsApiException( - SMSOTPConstants.ERROR_IN_CREATING_SMS_NOTIFICATION_SENDER, - error.stack, - error.code, - error.request, - error.response, - error.config); - }); -}; - -/** - * Delete sms notification senders with name SMSPublisher. - * - * @returns A promise containing the response. - */ -export const deleteSMSPublisher = (): Promise => { - const requestConfig: RequestConfigInterface = { - headers: { - "Accept": "application/json", - "Access-Control-Allow-Origin": store.getState().config.deployment.clientHost, - "Content-Type": "application/json" - }, - method: HttpMethods.DELETE, - url: store.getState().config.endpoints.notificationSendersEndPoint + "/sms/SMSPublisher" - }; - - return httpClient(requestConfig) - .then((response: AxiosResponse) => { - if (response.status !== 204) { - throw new IdentityAppsApiException( - SMSOTPConstants.ERROR_IN_DELETING_SMS_NOTIFICATION_SENDER, - null, - response.status, - response.request, - response, - response.config); - } - - return Promise.resolve(response.data); - }).catch((error: AxiosError) => { - let errorMessage: string = SMSOTPConstants.ERROR_IN_DELETING_SMS_NOTIFICATION_SENDER; - - if (error.response?.data?.code === - SMSOTPConstants.ErrorMessages.SMS_NOTIFICATION_SENDER_DELETION_ERROR_ACTIVE_SUBS.getErrorCode()) { - errorMessage = SMSOTPConstants.ErrorMessages.SMS_NOTIFICATION_SENDER_DELETION_ERROR_ACTIVE_SUBS - .getErrorMessage(); - } - throw new IdentityAppsApiException(errorMessage, error.stack, error.response?.data?.code, error.request, - error.response, error.config); - - }); -}; diff --git a/features/admin.extensions.v1/components/identity-providers/api/index.ts b/features/admin.extensions.v1/components/identity-providers/api/index.ts deleted file mode 100644 index 8c2d42018a5..00000000000 --- a/features/admin.extensions.v1/components/identity-providers/api/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export * from "./identity-provider"; diff --git a/features/admin.extensions.v1/components/identity-providers/constants/index.ts b/features/admin.extensions.v1/components/identity-providers/constants/index.ts deleted file mode 100644 index 78db778fffa..00000000000 --- a/features/admin.extensions.v1/components/identity-providers/constants/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export * from "./swe-constants"; -export * from "./sms-otp-constants"; diff --git a/features/admin.extensions.v1/components/identity-providers/models/index.ts b/features/admin.extensions.v1/components/identity-providers/models/index.ts deleted file mode 100644 index 1f11dd954d2..00000000000 --- a/features/admin.extensions.v1/components/identity-providers/models/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export * from "./swe"; -export * from "./sms-otp"; diff --git a/features/admin.extensions.v1/components/password-expiry/api/index.ts b/features/admin.extensions.v1/components/password-expiry/api/index.ts deleted file mode 100644 index 16a62fdc24a..00000000000 --- a/features/admin.extensions.v1/components/password-expiry/api/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export * from "./password-expiry"; diff --git a/features/admin.extensions.v1/components/password-expiry/components/index.ts b/features/admin.extensions.v1/components/password-expiry/components/index.ts deleted file mode 100644 index 16a62fdc24a..00000000000 --- a/features/admin.extensions.v1/components/password-expiry/components/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export * from "./password-expiry"; diff --git a/features/admin.extensions.v1/components/password-expiry/components/password-expiry.tsx b/features/admin.extensions.v1/components/password-expiry/components/password-expiry.tsx deleted file mode 100644 index 66bb8eabfe9..00000000000 --- a/features/admin.extensions.v1/components/password-expiry/components/password-expiry.tsx +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { - GovernanceConnectorConstants -} from "@wso2is/admin.server-configurations.v1/constants/governance-connector-constants"; -import { Field } from "@wso2is/form/src"; -import { Heading } from "@wso2is/react-components"; -import React, { ReactElement } from "react"; -import { TFunction } from "react-i18next"; - -export const generatePasswordExpiry = ( - componentId: string, - passwordExpiryEnabled: boolean, - setPasswordExpiryEnabled: (value: boolean) => void, - t: TFunction<"translation", undefined>, - isReadOnly: boolean = false -): ReactElement => { - return ( - <> - - { t("extensions:manage.serverConfigurations.passwordExpiry.heading") } - -
- { - setPasswordExpiryEnabled(value); - } } - width={ 16 } - data-testid={ `${ componentId }-password-expiry-toggle` } - readOnly={ isReadOnly } - /> -
- - ); -}; diff --git a/features/admin.extensions.v1/components/password-history-count/api/index.ts b/features/admin.extensions.v1/components/password-history-count/api/index.ts deleted file mode 100644 index bb3f3598146..00000000000 --- a/features/admin.extensions.v1/components/password-history-count/api/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export * from "./password-history-count"; diff --git a/features/admin.extensions.v1/components/password-history-count/components/index.ts b/features/admin.extensions.v1/components/password-history-count/components/index.ts deleted file mode 100644 index bb3f3598146..00000000000 --- a/features/admin.extensions.v1/components/password-history-count/components/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export * from "./password-history-count"; diff --git a/features/admin.extensions.v1/components/password-history-count/components/password-history-count.tsx b/features/admin.extensions.v1/components/password-history-count/components/password-history-count.tsx deleted file mode 100644 index 03cb206df58..00000000000 --- a/features/admin.extensions.v1/components/password-history-count/components/password-history-count.tsx +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import Alert from "@oxygen-ui/react/Alert"; -import { Field } from "@wso2is/form/src"; -import { Heading } from "@wso2is/react-components"; -import React, { ReactElement } from "react"; -import { TFunction } from "react-i18next"; - -export const generatePasswordHistoryCount = ( - componentId: string, - passwordHistoryEnabled: boolean, - setPasswordHistoryEnabled: (value: boolean) => void, - t: TFunction<"translation", undefined>, - isReadOnly: boolean = false -): ReactElement => { - return ( - <> - - { t("extensions:manage.serverConfigurations.passwordHistoryCount.heading") } - - - { t("extensions:manage.serverConfigurations.passwordHistoryCount.message") } - -
- { - setPasswordHistoryEnabled(value); - } } - width={ 16 } - data-testid={ `${ componentId }-password-history-count-toggle` } - readOnly={ isReadOnly } - /> -
- - ); -}; diff --git a/features/admin.extensions.v1/configs/attribute.ts b/features/admin.extensions.v1/configs/attribute.ts index c6a97147f52..7d9ad82827f 100644 --- a/features/admin.extensions.v1/configs/attribute.ts +++ b/features/admin.extensions.v1/configs/attribute.ts @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -import { deleteADialect } from "@wso2is/admin.claims.v1/api/claims"; +import { deleteADialect, getDialects, getExternalClaims } from "@wso2is/admin.claims.v1/api/claims"; import { ClaimManagementConstants } from "@wso2is/admin.claims.v1/constants/claim-management-constants"; import { getUserStoreList } from "@wso2is/admin.userstores.v1/api"; import { UserStoreListItem } from "@wso2is/admin.userstores.v1/models"; @@ -24,7 +24,6 @@ import { I18n } from "@wso2is/i18n"; import { AxiosResponse } from "axios"; import { SemanticICONS } from "semantic-ui-react"; import { AttributeConfig } from "./models"; -import { getClaimsForDialect, getDialects } from "../components/claims/api"; /** * Check whether claims is identity claims or not. @@ -148,7 +147,7 @@ export const attributeConfig: AttributeConfig = { let dialectID: string = ""; let noCustomClaims: boolean = false; - await getDialects() + await getDialects(null) .then((response: Claim[] | ClaimDialect[]) => { response.map((dialect: Claim | ClaimDialect) => { if (dialect.dialectURI === "urn:scim:wso2:schema") { @@ -157,7 +156,7 @@ export const attributeConfig: AttributeConfig = { }); }); - await getClaimsForDialect(dialectID) + await getExternalClaims(dialectID) .then((response: Claim[] | ClaimDialect[]) => { if (response.length === 0) { noCustomClaims = true; @@ -238,7 +237,7 @@ export const attributeConfig: AttributeConfig = { .set("OIDC", true); if (protocol === "OIDC" || protocol === "BOTH" ) { - await getClaimsForDialect(ClaimManagementConstants.ATTRIBUTE_DIALECT_IDS.get("OIDC")) + await getExternalClaims(ClaimManagementConstants.ATTRIBUTE_DIALECT_IDS.get("OIDC")) .then((response: Claim[] | ExternalClaim[]) => { response.map((attrib: Claim | ExternalClaim) => { if (attrib.claimURI === attributeName) { @@ -249,7 +248,7 @@ export const attributeConfig: AttributeConfig = { } if (protocol === "SCIM" || protocol === "BOTH" ) { - await getDialects() + await getDialects(null) .then((response: Claim[] | ClaimDialect[]) => { response.map((dialect: Claim | ClaimDialect) => { if (dialect.dialectURI === "urn:scim:wso2:schema") { @@ -259,7 +258,7 @@ export const attributeConfig: AttributeConfig = { }); if (dialectID !== "") { - await getClaimsForDialect(dialectID) + await getExternalClaims(dialectID) .then((response: Claim[] | ExternalClaim[]) => { response.map((attrib: Claim | ExternalClaim) => { if (attrib.claimURI === "urn:scim:wso2:schema:" + attributeName) { @@ -289,7 +288,7 @@ export const attributeConfig: AttributeConfig = { getDialect: async (dialectURI: string): Promise => { let dialectObject: Claim | ClaimDialect; - await getDialects() + await getDialects(null) .then((response: Claim[] | ClaimDialect[]) => { response.map((dialect: Claim | ClaimDialect) => { if (dialect.dialectURI === dialectURI) { @@ -303,7 +302,7 @@ export const attributeConfig: AttributeConfig = { isSCIMCustomDialectAvailable: async (): Promise => { let dialectID: string = ""; - await getDialects() + await getDialects(null) .then((response: Claim[] | ClaimDialect[]) => { response.map((dialect: Claim | ClaimDialect) => { if (dialect.dialectURI === "urn:scim:wso2:schema") { diff --git a/features/admin.extensions.v1/configs/endpoints.ts b/features/admin.extensions.v1/configs/endpoints.ts index 4e7a78df406..7d51a3eac82 100644 --- a/features/admin.extensions.v1/configs/endpoints.ts +++ b/features/admin.extensions.v1/configs/endpoints.ts @@ -41,11 +41,9 @@ export const getExtendedFeatureResourceEndpoints = (serverHost: string, eventsEndpoint: `${ serverHost }/api/event-configurations/v1/events`, inviteEndpoint: `${ serverHost }/api/asgardeo-guest/v1/users/invite`, inviteLinkEndpoint: "/api/users/v1/offline-invite-link", - notificationSendersEndPoint: `${ serverHost }/api/server/v1/notification-senders`, organizationEndpoint: `${ serverHost }/api/asgardeo-enterprise-login/v1/business-user-login/{organization}`, organizationPatchEndpoint: `${ serverHost }/api/asgardeo-enterprise-login/v1/business-user-login`, resendEndpoint: `${ serverHost }/api/asgardeo-guest/v1/users/invite/{}/resend`, - smsProviderEndpoint: `${ serverHost }/api/server/v1/notification-senders/sms`, userEndpoint: `${ serverHost }/api/asgardeo-guest/v1/users`, userStoreAgentConnection: `${ serverHost }/api/onprem-userstore/v1/connection`, userStoreAgentToken: `${ serverHost }/api/onprem-userstore/v1/token` diff --git a/features/admin.extensions.v1/configs/identity-provider.tsx b/features/admin.extensions.v1/configs/identity-provider.tsx index 5b30413583b..d8bdf1d47b4 100644 --- a/features/admin.extensions.v1/configs/identity-provider.tsx +++ b/features/admin.extensions.v1/configs/identity-provider.tsx @@ -28,11 +28,8 @@ import { } from "@wso2is/admin.connections.v1/constants/federated-authenticator-constants"; import { LocalAuthenticatorConstants } from "@wso2is/admin.connections.v1/constants/local-authenticator-constants"; import { IdentityProviderTabTypes } from "@wso2is/admin.identity-providers.v1/models"; -import { I18n } from "@wso2is/i18n"; -import { ResourceTabPaneInterface } from "@wso2is/react-components"; -import React, { ElementType, ReactElement } from "react"; +import React, { ReactElement } from "react"; import { IdentityProviderConfig } from "./models"; -import QuickStartTab from "../components/component-extensions/application/quick-start-tab"; import { SIWEAuthenticatorForm } from "../identity-provider-templates/templates/swe/swe-authenticator-form"; import SIWEIdPTemplate from "../identity-provider-templates/templates/swe/swe.json"; @@ -92,19 +89,6 @@ export const identityProviderConfig: IdentityProviderConfig = { return null; }, - getTabExtensions: (props: Record): ResourceTabPaneInterface[] => { - const { content, ...rest } = props; - - return [ - { - componentId: "quick-start", - menuItem: I18n.instance.t( - "console:develop.componentExtensions.component.application.quickStart.title" - ), - render: () => - } - ]; - }, isTabEnabledForIdP: (templateType: string, tabType: ConnectionTabTypes): boolean | undefined => { const templateMapping: Map> = new Map>([ diff --git a/features/admin.extensions.v1/configs/models/endpoints.ts b/features/admin.extensions.v1/configs/models/endpoints.ts index 91084a0150b..b96fa9e492a 100644 --- a/features/admin.extensions.v1/configs/models/endpoints.ts +++ b/features/admin.extensions.v1/configs/models/endpoints.ts @@ -54,11 +54,6 @@ export interface ExtendedFeatureResourceEndpointsInterface { */ emailProviderEndpoint : string; - /** - * SMS Publishing API endpoint. - */ - smsProviderEndpoint : string; - /** * Event Publishing API endpoint. */ @@ -69,11 +64,6 @@ export interface ExtendedFeatureResourceEndpointsInterface { */ choreoEventingEndpoint : string; - /** - * Notification senders API endpoint. - */ - notificationSendersEndPoint: string; - /** * Authorization Service API endpoint. */ diff --git a/features/admin.extensions.v1/configs/models/identity-providers.ts b/features/admin.extensions.v1/configs/models/identity-providers.ts index 8de3eceed72..64d5a54a188 100644 --- a/features/admin.extensions.v1/configs/models/identity-providers.ts +++ b/features/admin.extensions.v1/configs/models/identity-providers.ts @@ -17,7 +17,6 @@ */ import { ConnectionTabTypes } from "@wso2is/admin.connections.v1/models/connection"; -import { ResourceTabPaneInterface } from "@wso2is/react-components"; import { ReactElement, ReactNode } from "react"; export interface ExtendedSamlConfigInterface { @@ -41,12 +40,6 @@ export interface IdentityProviderConfig { showIssuerSettings: boolean; showJitProvisioning: boolean; showOutboundProvisioning: boolean; - /** - * Get the list of passible tab extensions. - * @param props - Props for the component. - * @returns Array of tab extensions. - */ - getTabExtensions: (props: Record) => ResourceTabPaneInterface[]; /** * Used enable/disable certain tabs for certain IDP template type. * @param templateId - The IDP Template Type. diff --git a/features/admin.extensions.v1/configs/models/server-configuration.ts b/features/admin.extensions.v1/configs/models/server-configuration.ts index 6dce8b76e87..82a5abce0ef 100644 --- a/features/admin.extensions.v1/configs/models/server-configuration.ts +++ b/features/admin.extensions.v1/configs/models/server-configuration.ts @@ -16,11 +16,9 @@ * under the License. */ -import { RequestErrorInterface, RequestResultInterface } from "@wso2is/admin.core.v1/hooks/use-request"; import { GovernanceConnectorInterface } from "@wso2is/admin.server-configurations.v1"; import { ValidationFormInterface } from "@wso2is/admin.validation.v1/models"; import { ReactElement, ReactNode } from "react"; -import { TFunction } from "react-i18next"; export interface ServerConfigurationConfig { autoEnableConnectorToggleProperty: boolean; @@ -49,28 +47,12 @@ export interface ServerConfigurationConfig { showConnectorsOnTheSidePanel: boolean; showGovernanceConnectorCategories: boolean; showPageHeading: boolean; - usePasswordHistory: () => RequestResultInterface; processInitialValues: ( initialValues: ValidationFormInterface, passwordHistoryCount: GovernanceConnectorInterface, setPasswordHistoryEnabled: (state: boolean) => void ) => PasswordHistoryCountInterface; processPasswordCountSubmitData: (data: ValidationFormInterface) => Promise; - passwordHistoryCountComponent: ( - componentId: string, - passwordHistoryEnabled: boolean, - setPasswordHistoryEnabled: (state: boolean) => void, - t: TFunction<"translation", undefined>, - isReadOnly?: boolean - ) => ReactElement; - passwordExpiryComponent: ( - componentId: string, - passwordExpiryEnabled: boolean, - setPasswordExpiryEnabled: (state: boolean) => void, - t: TFunction<"translation", undefined>, - isReadOnly?: boolean - ) => ReactElement; - usePasswordExpiry: () => RequestResultInterface; processPasswordExpiryInitialValues: ( initialValues: ValidationFormInterface, passwordExpiryTime: GovernanceConnectorInterface, diff --git a/features/admin.extensions.v1/configs/server-configuration.tsx b/features/admin.extensions.v1/configs/server-configuration.tsx index a582e96b25f..76cd5238ace 100644 --- a/features/admin.extensions.v1/configs/server-configuration.tsx +++ b/features/admin.extensions.v1/configs/server-configuration.tsx @@ -29,9 +29,11 @@ import { import { ServerConfigurationsConstants } from "@wso2is/admin.server-configurations.v1/constants/server-configurations-constants"; +import updatePasswordExpiryProperties from "@wso2is/admin.validation.v1/api/update-password-expiry-properties"; +import updatePasswordHistoryCount from "@wso2is/admin.validation.v1/api/update-password-history-count"; +import updatePasswordPolicyProperties from "@wso2is/admin.validation.v1/api/update-password-policy-properties"; import { ValidationFormInterface } from "@wso2is/admin.validation.v1/models"; import React, { ReactElement, ReactNode } from "react"; -import { TFunction } from "react-i18next"; import { Card, Divider, Grid, Header } from "semantic-ui-react"; import { PasswordExpiryInterface, @@ -39,17 +41,6 @@ import { PasswordPoliciesInterface, ServerConfigurationConfig } from "./models/server-configuration"; -import { - updatePasswordExpiryProperties, - useGetPasswordExpiryProperties -} from "../components/password-expiry/api/password-expiry"; -import { generatePasswordExpiry } from "../components/password-expiry/components/password-expiry"; -import { - updatePasswordHistoryCount, - useGetPasswordHistoryCount -} from "../components/password-history-count/api"; -import { generatePasswordHistoryCount } from "../components/password-history-count/components"; -import { updatePasswordPolicyProperties } from "../components/password-policies/api/password-policies"; const serverConfigurationConfig: ServerConfigurationConfig = { autoEnableConnectorToggleProperty: false, @@ -98,36 +89,6 @@ const serverConfigurationConfig: ServerConfigurationConfig = { dynamicConnectors: true, extendedConnectors: [], intendSettings: false, - passwordExpiryComponent: ( - componentId: string, - passwordExpiryEnabled: boolean, - setPasswordExpiryEnabled: (state: boolean) => void, - t: TFunction<"translation", undefined>, - isReadOnly: boolean = false - ): ReactElement => { - return generatePasswordExpiry( - componentId, - passwordExpiryEnabled, - setPasswordExpiryEnabled, - t, - isReadOnly - ); - }, - passwordHistoryCountComponent: ( - componentId: string, - passwordHistoryEnabled: boolean, - setPasswordHistoryEnabled: (state: boolean) => void, - t: TFunction<"translation", undefined>, - isReadOnly: boolean = false - ): ReactElement => { - return generatePasswordHistoryCount( - componentId, - passwordHistoryEnabled, - setPasswordHistoryEnabled, - t, - isReadOnly - ); - }, predefinedConnectorCategories: [ "UGFzc3dvcmQgUG9saWNpZXM", "VXNlciBPbmJvYXJkaW5n", @@ -395,10 +356,7 @@ const serverConfigurationConfig: ServerConfigurationConfig = { renderConnectorWithinEmphasizedSegment: false, showConnectorsOnTheSidePanel: false, showGovernanceConnectorCategories: false, - showPageHeading: true, - usePasswordExpiry: useGetPasswordExpiryProperties, - usePasswordHistory: useGetPasswordHistoryCount + showPageHeading: true }; - export { serverConfigurationConfig }; diff --git a/features/admin.extensions.v1/identity-provider-templates/templates/swe/swe-authenticator-form.tsx b/features/admin.extensions.v1/identity-provider-templates/templates/swe/swe-authenticator-form.tsx index 9f61936fe88..e89ce5ea9d4 100644 --- a/features/admin.extensions.v1/identity-provider-templates/templates/swe/swe-authenticator-form.tsx +++ b/features/admin.extensions.v1/identity-provider-templates/templates/swe/swe-authenticator-form.tsx @@ -17,6 +17,7 @@ */ import { ConnectionUIConstants } from "@wso2is/admin.connections.v1/constants/connection-ui-constants"; +import SIWEConstants from "@wso2is/admin.connections.v1/constants/siwe-constants"; import { CommonAuthenticatorFormFieldInterface, CommonAuthenticatorFormFieldMetaInterface, @@ -32,7 +33,6 @@ import isEmpty from "lodash-es/isEmpty"; import React, { FunctionComponent, ReactElement, ReactNode, useEffect, useState } from "react"; import { Trans, useTranslation } from "react-i18next"; import { Icon, SemanticICONS } from "semantic-ui-react"; -import { SIWEConstants } from "../../../components/identity-providers/constants"; /** * Interface for SIWE Authenticator Settings Form props. diff --git a/features/admin.server-configurations.v1/forms/analytics-form.tsx b/features/admin.server-configurations.v1/forms/analytics-form.tsx index 2caf0caae53..2e0ab34c9d1 100644 --- a/features/admin.server-configurations.v1/forms/analytics-form.tsx +++ b/features/admin.server-configurations.v1/forms/analytics-form.tsx @@ -16,10 +16,6 @@ * under the License. */ -import { - AnalyticsAPIRequestInterface, - AnalyticsFormValuesInterface -} from "@wso2is/admin.extensions.v1/components/governance-connectors/models/analytics"; import { ConnectorPropertyInterface, GovernanceConnectorInterface, @@ -33,6 +29,7 @@ import React, { FunctionComponent, ReactElement, useEffect, useState } from "rea import { useTranslation } from "react-i18next"; import { Label } from "semantic-ui-react"; import { GovernanceConnectorConstants } from "../constants/governance-connector-constants"; +import { AnalyticsAPIRequestInterface, AnalyticsFormValuesInterface } from "../models/analytics"; /** * Interface for Password Recovery Configuration Form props. diff --git a/features/admin.extensions.v1/components/governance-connectors/models/analytics.ts b/features/admin.server-configurations.v1/models/analytics.ts similarity index 100% rename from features/admin.extensions.v1/components/governance-connectors/models/analytics.ts rename to features/admin.server-configurations.v1/models/analytics.ts diff --git a/features/admin.sms-providers.v1/api/add-sms-publisher.ts b/features/admin.sms-providers.v1/api/add-sms-publisher.ts new file mode 100644 index 00000000000..6f08ae0c0df --- /dev/null +++ b/features/admin.sms-providers.v1/api/add-sms-publisher.ts @@ -0,0 +1,86 @@ +/** + * Copyright (c) 2022-2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { AsgardeoSPAClient, HttpClientInstance } from "@asgardeo/auth-react"; +import { store } from "@wso2is/admin.core.v1"; +import { RequestConfigInterface } from "@wso2is/admin.core.v1/hooks/use-request"; +import { IdentityAppsApiException } from "@wso2is/core/exceptions"; +import { HttpMethods } from "@wso2is/core/models"; +import { AxiosError, AxiosResponse } from "axios"; +import SMSSenderConstants from "../constants/sms-sender-constants"; +import { NotificationSenderSMSInterface } from "../models/sms-senders"; + +const httpClient: HttpClientInstance = AsgardeoSPAClient.getInstance().httpRequest + .bind(AsgardeoSPAClient.getInstance()); + +/** + * Add sms notification senders with name SMSPublisher. + * + * @returns A promise containing the response. + */ +const addSMSPublisher = (): Promise => { + const smsProvider: NotificationSenderSMSInterface = { + contentType: "FORM", + name: "SMSPublisher", + properties: [ + { + key: "channel.type", + value: "choreo" + } + ], + provider: "choreo", + // TODO: Get the URL from the Config + providerURL: "https://console.choreo.dev/" + }; + + const requestConfig: RequestConfigInterface = { + data: smsProvider, + headers: { + "Accept": "application/json", + "Access-Control-Allow-Origin": store.getState().config.deployment.clientHost, + "Content-Type": "application/json" + }, + method: HttpMethods.POST, + url: store.getState().config.endpoints.smsSender + }; + + return httpClient(requestConfig) + .then((response: AxiosResponse) => { + if (response.status !== 201) { + throw new IdentityAppsApiException( + SMSSenderConstants.ERROR_IN_CREATING_SMS_NOTIFICATION_SENDER, + null, + response.status, + response.request, + response, + response.config); + } + + return Promise.resolve(response.data as NotificationSenderSMSInterface); + }).catch((error: AxiosError) => { + throw new IdentityAppsApiException( + SMSSenderConstants.ERROR_IN_CREATING_SMS_NOTIFICATION_SENDER, + error.stack, + error.code, + error.request, + error.response, + error.config); + }); +}; + +export default addSMSPublisher; diff --git a/features/admin.sms-providers.v1/api/delete-sms-publisher.ts b/features/admin.sms-providers.v1/api/delete-sms-publisher.ts new file mode 100644 index 00000000000..40d55715cdb --- /dev/null +++ b/features/admin.sms-providers.v1/api/delete-sms-publisher.ts @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2022-2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { AsgardeoSPAClient, HttpClientInstance } from "@asgardeo/auth-react"; +import { store } from "@wso2is/admin.core.v1"; +import { RequestConfigInterface } from "@wso2is/admin.core.v1/hooks/use-request"; +import { IdentityAppsApiException } from "@wso2is/core/exceptions"; +import { HttpMethods } from "@wso2is/core/models"; +import { AxiosError, AxiosResponse } from "axios"; +import SMSSenderConstants from "../constants/sms-sender-constants"; + +const httpClient: HttpClientInstance = AsgardeoSPAClient.getInstance().httpRequest + .bind(AsgardeoSPAClient.getInstance()); + +/** + * Delete sms notification senders with name SMSPublisher. + * + * @returns A promise containing the response. + */ +const deleteSMSPublisher = (): Promise => { + const requestConfig: RequestConfigInterface = { + headers: { + "Accept": "application/json", + "Access-Control-Allow-Origin": store.getState().config.deployment.clientHost, + "Content-Type": "application/json" + }, + method: HttpMethods.DELETE, + url: store.getState().config.endpoints.smsPublisher + }; + + return httpClient(requestConfig) + .then((response: AxiosResponse) => { + if (response.status !== 204) { + throw new IdentityAppsApiException( + SMSSenderConstants.ERROR_IN_DELETING_SMS_NOTIFICATION_SENDER, + null, + response.status, + response.request, + response, + response.config); + } + + return Promise.resolve(response.data); + }).catch((error: AxiosError) => { + let errorMessage: string = SMSSenderConstants.ERROR_IN_DELETING_SMS_NOTIFICATION_SENDER; + + if (error.response?.data?.code === + SMSSenderConstants.ErrorMessages.SMS_NOTIFICATION_SENDER_DELETION_ERROR_ACTIVE_SUBS.getErrorCode()) { + errorMessage = SMSSenderConstants.ErrorMessages.SMS_NOTIFICATION_SENDER_DELETION_ERROR_ACTIVE_SUBS + .getErrorMessage(); + } + throw new IdentityAppsApiException(errorMessage, error.stack, error.response?.data?.code, error.request, + error.response, error.config); + + }); +}; + +export default deleteSMSPublisher; diff --git a/features/admin.sms-providers.v1/api/sms-provider.ts b/features/admin.sms-providers.v1/api/sms-provider.ts index 55bd4f70296..31e5ca0ea35 100644 --- a/features/admin.sms-providers.v1/api/sms-provider.ts +++ b/features/admin.sms-providers.v1/api/sms-provider.ts @@ -49,7 +49,7 @@ export const useSMSProviders = (requestConfig); @@ -74,7 +74,7 @@ export const createSMSProvider = ( "Content-Type": "application/json" }, method: HttpMethods.POST, - url: store.getState().config.endpoints.smsProviderEndpoint + url: store.getState().config.endpoints.smsSender }; return httpClient(requestConfig) @@ -113,7 +113,7 @@ export const updateSMSProvider = ( "Content-Type": "application/json" }, method: HttpMethods.PUT, - url: store.getState().config.endpoints.smsProviderEndpoint + "/SMSPublisher" + url: store.getState().config.endpoints.smsPublisher }; return httpClient(requestConfig) @@ -148,7 +148,7 @@ export const deleteSMSProviders = (): Promise = "Content-Type": "application/json" }, method: HttpMethods.DELETE, - url: store.getState().config.endpoints.smsProviderEndpoint + "/SMSPublisher" + url: store.getState().config.endpoints.smsPublisher }; return httpClient(requestConfig) diff --git a/features/admin.extensions.v1/components/example.tsx b/features/admin.sms-providers.v1/configs/endpoints.ts similarity index 51% rename from features/admin.extensions.v1/components/example.tsx rename to features/admin.sms-providers.v1/configs/endpoints.ts index b7f6579bf46..cbbda4c7cbf 100644 --- a/features/admin.extensions.v1/components/example.tsx +++ b/features/admin.sms-providers.v1/configs/endpoints.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + * Copyright (c) 2022-2024, WSO2 LLC. (https://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -16,14 +16,17 @@ * under the License. */ -import { Section } from "@wso2is/react-components"; -import React, { ReactElement } from "react"; +import { SMSProvidersResourceEndpointsInterface } from "../models/endpoints"; -export default (): ReactElement => { - return ( -
- ); +/** + * Get the resource endpoints for the SMS Providers feature. + * + * @param serverHost - Server Host. + * @returns Endpoint URLs. + */ +export const getSMSProvidersResourceEndpoints = (serverHost: string): SMSProvidersResourceEndpointsInterface => { + return { + smsPublisher: `${ serverHost }/api/server/v1/notification-senders/sms/SMSPublisher`, + smsSender: `${ serverHost }/api/server/v1/notification-senders/sms` + }; }; diff --git a/features/admin.extensions.v1/components/identity-providers/constants/sms-otp-constants.ts b/features/admin.sms-providers.v1/constants/sms-sender-constants.ts similarity index 82% rename from features/admin.extensions.v1/components/identity-providers/constants/sms-otp-constants.ts rename to features/admin.sms-providers.v1/constants/sms-sender-constants.ts index 10126af1c01..c2955ebb0a0 100644 --- a/features/admin.extensions.v1/components/identity-providers/constants/sms-otp-constants.ts +++ b/features/admin.sms-providers.v1/constants/sms-sender-constants.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + * Copyright (c) 2022-2024, WSO2 LLC. (https://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -18,7 +18,14 @@ import { IdentityAppsError } from "@wso2is/core/errors"; -export class SMSOTPConstants { +/** + * Class containing constants related to SMS sender operations. + */ +class SMSSenderConstants { + /** + * Private constructor to avoid object instantiation from outside the class. + */ + private constructor() {} public static readonly ERROR_IN_CREATING_SMS_NOTIFICATION_SENDER: string = "An error occurred while adding SMS " + "Notification Sender"; @@ -38,5 +45,7 @@ export class SMSOTPConstants { "NSM-60008", "There are applications using this connection." ) - } + }; } + +export default SMSSenderConstants; diff --git a/features/admin.extensions.v1/components/identity-providers/models/sms-otp.ts b/features/admin.sms-providers.v1/models/endpoints.ts similarity index 63% rename from features/admin.extensions.v1/components/identity-providers/models/sms-otp.ts rename to features/admin.sms-providers.v1/models/endpoints.ts index 2e0cfdb90fd..9524325c944 100644 --- a/features/admin.extensions.v1/components/identity-providers/models/sms-otp.ts +++ b/features/admin.sms-providers.v1/models/endpoints.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + * Copyright (c) 2022-2024, WSO2 LLC. (https://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -17,15 +17,15 @@ */ /** - * Interface for SMS Notification Sender Details. - **/ -export interface NotificationSenderSMSInterface { - name: string; - provider: string; - providerURL: string; - contentType: string; - properties?: { - key: string; - value: string; - }[]; + * Interface for the SMS Providers feature resource endpoints. + */ +export interface SMSProvidersResourceEndpointsInterface { + /** + * Endpoint for the SMS Publisher. + */ + smsPublisher: string; + /** + * Endpoint for the SMS Sender. + */ + smsSender: string; } diff --git a/features/admin.sms-providers.v1/models/sms-senders.ts b/features/admin.sms-providers.v1/models/sms-senders.ts new file mode 100644 index 00000000000..dcc9a074b98 --- /dev/null +++ b/features/admin.sms-providers.v1/models/sms-senders.ts @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2022-2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Interface representing an SMS notification sender. + */ +export interface NotificationSenderSMSInterface { + /** + * The name of the SMS notification sender. + */ + name: string; + /** + * The provider of the SMS notification service. + */ + provider: string; + /** + * The URL of the SMS notification provider. + */ + providerURL: string; + /** + * The content type of the SMS notification. + */ + contentType: string; + /** + * Optional properties for the SMS notification sender. + */ + properties?: { + /** + * The key of the property. + */ + key: string; + + /** + * The value of the property. + */ + value: string; + }[]; +} diff --git a/features/admin.extensions.v1/components/password-expiry/api/password-expiry.ts b/features/admin.validation.v1/api/update-password-expiry-properties.ts similarity index 66% rename from features/admin.extensions.v1/components/password-expiry/api/password-expiry.ts rename to features/admin.validation.v1/api/update-password-expiry-properties.ts index 2bed1a29d50..4fc4b179563 100644 --- a/features/admin.extensions.v1/components/password-expiry/api/password-expiry.ts +++ b/features/admin.validation.v1/api/update-password-expiry-properties.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). + * Copyright (c) 2023-2024, WSO2 LLC. (https://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -18,15 +18,7 @@ import { AsgardeoSPAClient, HttpRequestConfig } from "@asgardeo/auth-react"; import { store } from "@wso2is/admin.core.v1"; -import useRequest, { - RequestConfigInterface, - RequestErrorInterface, - RequestResultInterface -} from "@wso2is/admin.core.v1/hooks/use-request"; -import { - GovernanceConnectorInterface, - UpdateGovernanceConnectorConfigInterface -} from "@wso2is/admin.server-configurations.v1"; +import { UpdateGovernanceConnectorConfigInterface } from "@wso2is/admin.server-configurations.v1"; import { IdentityAppsApiException } from "@wso2is/core/exceptions"; import { HttpMethods } from "@wso2is/core/models"; import { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios"; @@ -40,35 +32,20 @@ const httpClient: ( AsgardeoSPAClient.getInstance() ); -export const useGetPasswordExpiryProperties = < - Data = GovernanceConnectorInterface, - Error = RequestErrorInterface ->(): RequestResultInterface => { - const requestConfig: RequestConfigInterface = { - headers: { - Accept: "application/json", - "Content-Type": "application/json" - }, - method: HttpMethods.GET, - url: store.getState()?.config?.endpoints?.passwordExpiry - }; - - const { data, error, isValidating, mutate } = useRequest( - requestConfig - ); - - return { - data, - error, - isLoading: !data && !error, - isValidating, - mutate - }; -}; - -export const updatePasswordExpiryProperties = ( - data: UpdateGovernanceConnectorConfigInterface -): Promise => { +/** + * Updates the password expiry properties. + * + * @param data - The data to update the governance connector configuration. + * @returns A promise that resolves with the response data or rejects with an error. + * + * @throws IdentityAppsApiException If the response status is not 200 or if an error occurs during the request. + * + * @example + * updatePasswordExpiryProperties(data) + * .then(...) + * .catch(...); + */ +const updatePasswordExpiryProperties = (data: UpdateGovernanceConnectorConfigInterface): Promise => { const requestConfig: AxiosRequestConfig = { data, headers: { @@ -104,3 +81,5 @@ export const updatePasswordExpiryProperties = ( ); }); }; + +export default updatePasswordExpiryProperties; diff --git a/features/admin.extensions.v1/components/password-history-count/api/password-history-count.ts b/features/admin.validation.v1/api/update-password-history-count.ts similarity index 68% rename from features/admin.extensions.v1/components/password-history-count/api/password-history-count.ts rename to features/admin.validation.v1/api/update-password-history-count.ts index 1606c7e182e..1f89335aba6 100644 --- a/features/admin.extensions.v1/components/password-history-count/api/password-history-count.ts +++ b/features/admin.validation.v1/api/update-password-history-count.ts @@ -18,15 +18,7 @@ import { AsgardeoSPAClient, HttpRequestConfig } from "@asgardeo/auth-react"; import { store } from "@wso2is/admin.core.v1"; -import useRequest, { - RequestConfigInterface, - RequestErrorInterface, - RequestResultInterface -} from "@wso2is/admin.core.v1/hooks/use-request"; -import { - GovernanceConnectorInterface, - UpdateGovernanceConnectorConfigInterface -} from "@wso2is/admin.server-configurations.v1"; +import { UpdateGovernanceConnectorConfigInterface } from "@wso2is/admin.server-configurations.v1"; import { IdentityAppsApiException } from "@wso2is/core/exceptions"; import { HttpMethods } from "@wso2is/core/models"; import { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios"; @@ -41,35 +33,20 @@ const httpClient: ( AsgardeoSPAClient.getInstance() ); -export const useGetPasswordHistoryCount = < - Data = GovernanceConnectorInterface, - Error = RequestErrorInterface ->(): RequestResultInterface => { - const requestConfig: RequestConfigInterface = { - headers: { - Accept: "application/json", - "Content-Type": "application/json" - }, - method: HttpMethods.GET, - url: store.getState()?.config?.endpoints?.passwordHistory - }; - - const { data, error, isValidating, mutate } = useRequest( - requestConfig - ); - - return { - data, - error, - isLoading: !data && !error, - isValidating, - mutate - }; -}; - -export const updatePasswordHistoryCount = ( - data: UpdateGovernanceConnectorConfigInterface -): Promise => { +/** + * Updates the password history count properties. + * + * @param data - The data to update the governance connector configuration. + * @returns A promise that resolves with the response data or rejects with an error. + * + * @throws IdentityAppsApiException If the response status is not 200 or if an error occurs during the request. + * + * @example + * updatePasswordHistoryCount(data) + * .then(...) + * .catch(...); + */ +const updatePasswordHistoryCount = (data: UpdateGovernanceConnectorConfigInterface): Promise => { const requestConfig: AxiosRequestConfig = { data, headers: { @@ -105,3 +82,5 @@ export const updatePasswordHistoryCount = ( ); }); }; + +export default updatePasswordHistoryCount; diff --git a/features/admin.extensions.v1/components/password-policies/api/password-policies.ts b/features/admin.validation.v1/api/update-password-policy-properties.ts similarity index 77% rename from features/admin.extensions.v1/components/password-policies/api/password-policies.ts rename to features/admin.validation.v1/api/update-password-policy-properties.ts index 8252c23b24a..17cffc0a4b2 100644 --- a/features/admin.extensions.v1/components/password-policies/api/password-policies.ts +++ b/features/admin.validation.v1/api/update-password-policy-properties.ts @@ -18,9 +18,7 @@ import { AsgardeoSPAClient, HttpRequestConfig } from "@asgardeo/auth-react"; import { store } from "@wso2is/admin.core.v1"; -import { - UpdateMultipleGovernanceConnectorsInterface -} from "@wso2is/admin.server-configurations.v1"; +import { UpdateMultipleGovernanceConnectorsInterface } from "@wso2is/admin.server-configurations.v1"; import { IdentityAppsApiException } from "@wso2is/core/exceptions"; import { HttpMethods } from "@wso2is/core/models"; import { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios"; @@ -34,9 +32,20 @@ const httpClient: ( AsgardeoSPAClient.getInstance() ); -export const updatePasswordPolicyProperties = ( - data: UpdateMultipleGovernanceConnectorsInterface -): Promise => { +/** + * Updates the password policy properties. + * + * @param data - The data to update multiple governance connectors configuration. + * @returns A promise that resolves when the update is successful or rejects with an error. + * + * @throws IdentityAppsApiException If the response status is not 200 or if an error occurs during the request. + * + * @example + * updatePasswordPolicyProperties(data) + * .then(...) + * .catch(...); + */ +const updatePasswordPolicyProperties = (data: UpdateMultipleGovernanceConnectorsInterface): Promise => { const requestConfig: AxiosRequestConfig = { data, headers: { @@ -72,3 +81,5 @@ export const updatePasswordPolicyProperties = ( ); }); }; + +export default updatePasswordPolicyProperties; diff --git a/features/admin.validation.v1/api/use-get-password-expiry-properties.ts b/features/admin.validation.v1/api/use-get-password-expiry-properties.ts new file mode 100644 index 00000000000..6b5f6d6fdb3 --- /dev/null +++ b/features/admin.validation.v1/api/use-get-password-expiry-properties.ts @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2023-2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { store } from "@wso2is/admin.core.v1"; +import useRequest, { + RequestConfigInterface, + RequestErrorInterface, + RequestResultInterface +} from "@wso2is/admin.core.v1/hooks/use-request"; +import { GovernanceConnectorInterface } from "@wso2is/admin.server-configurations.v1"; +import { HttpMethods } from "@wso2is/core/models"; + +/** + * Custom hook to get the password expiry properties. + * + * @param Data - The type of the data returned by the request. Defaults to GovernanceConnectorInterface. + * @param Error - The type of the error returned by the request. Defaults to RequestErrorInterface. + * @returns The result of the request, including data, error, loading state, and mutate function. + * + * @example + * `const { data, error, isLoading, isValidating, mutate } = useGetPasswordExpiryProperties();` + */ +const useGetPasswordExpiryProperties = < + Data = GovernanceConnectorInterface, + Error = RequestErrorInterface +>(): RequestResultInterface => { + const requestConfig: RequestConfigInterface = { + headers: { + Accept: "application/json", + "Content-Type": "application/json" + }, + method: HttpMethods.GET, + url: store.getState()?.config?.endpoints?.passwordExpiry + }; + + const { data, error, isValidating, mutate } = useRequest( + requestConfig + ); + + return { + data, + error, + isLoading: !data && !error, + isValidating, + mutate + }; +}; + +export default useGetPasswordExpiryProperties; diff --git a/features/admin.validation.v1/api/use-get-password-history-count.ts b/features/admin.validation.v1/api/use-get-password-history-count.ts new file mode 100644 index 00000000000..81b5e436901 --- /dev/null +++ b/features/admin.validation.v1/api/use-get-password-history-count.ts @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2023-2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { store } from "@wso2is/admin.core.v1"; +import useRequest, { + RequestConfigInterface, + RequestErrorInterface, + RequestResultInterface +} from "@wso2is/admin.core.v1/hooks/use-request"; +import { GovernanceConnectorInterface } from "@wso2is/admin.server-configurations.v1"; +import { HttpMethods } from "@wso2is/core/models"; + +/** + * Custom hook to get the password history count properties. + * + * @param Data - The type of the data returned by the request. Defaults to GovernanceConnectorInterface. + * @param Error - The type of the error returned by the request. Defaults to RequestErrorInterface. + * @returns The result of the request, including data, error, loading state, and mutate function. + * + * @example + * `const { data, error, isLoading, isValidating, mutate } = useGetPasswordHistoryCount();` + */ +const useGetPasswordHistoryCount = < + Data = GovernanceConnectorInterface, + Error = RequestErrorInterface +>(): RequestResultInterface => { + const requestConfig: RequestConfigInterface = { + headers: { + Accept: "application/json", + "Content-Type": "application/json" + }, + method: HttpMethods.GET, + url: store.getState()?.config?.endpoints?.passwordHistory + }; + + const { data, error, isValidating, mutate } = useRequest( + requestConfig + ); + + return { + data, + error, + isLoading: !data && !error, + isValidating, + mutate + }; +}; + +export default useGetPasswordHistoryCount; diff --git a/features/admin.validation.v1/pages/validation-config-edit.tsx b/features/admin.validation.v1/pages/validation-config-edit.tsx index e2a9ee58237..9352b65ef1a 100644 --- a/features/admin.validation.v1/pages/validation-config-edit.tsx +++ b/features/admin.validation.v1/pages/validation-config-edit.tsx @@ -16,6 +16,7 @@ * under the License. */ +import Alert from "@oxygen-ui/react/Alert"; import Switch from "@oxygen-ui/react/Switch"; import { useRequiredScopes } from "@wso2is/access-control"; import { AppConstants, AppState, FeatureConfigInterface, history } from "@wso2is/admin.core.v1"; @@ -29,6 +30,9 @@ import { ServerConfigurationsConstants, getConnectorDetails } from "@wso2is/admin.server-configurations.v1"; +import { + GovernanceConnectorConstants +} from "@wso2is/admin.server-configurations.v1/constants/governance-connector-constants"; import { getConfiguration } from "@wso2is/admin.users.v1/utils/generate-password.utils"; import { AlertLevels, @@ -60,6 +64,8 @@ import { useDispatch, useSelector } from "react-redux"; import { Dispatch } from "redux"; import { Divider, Grid, Ref } from "semantic-ui-react"; import { updateValidationConfigData, useValidationConfigData } from "../api"; +import useGetPasswordExpiryProperties from "../api/use-get-password-expiry-properties"; +import useGetPasswordHistoryCount from "../api/use-get-password-history-count"; import { PasswordExpiryRuleList } from "../components/password-expiry-rule-list"; import { ValidationConfigConstants } from "../constants/validation-config-constants"; import { @@ -142,13 +148,13 @@ export const ValidationConfigEditPage: FunctionComponent void, + isReadOnly: boolean = false + ): ReactElement => { + return ( + <> + + { t("extensions:manage.serverConfigurations.passwordExpiry.heading") } + +
+ { + setPasswordExpiryEnabled(value); + } } + width={ 16 } + data-testid={ `${ componentId }-password-expiry-toggle` } + readOnly={ isReadOnly } + /> +
+ + ); + }; + + const generatePasswordHistoryCount = ( + componentId: string, + passwordHistoryEnabled: boolean, + setPasswordHistoryEnabled: (value: boolean) => void, + isReadOnly: boolean = false + ): ReactElement => { + return ( + <> + + { t("extensions:manage.serverConfigurations.passwordHistoryCount.heading") } + + + { t("extensions:manage.serverConfigurations.passwordHistoryCount.message") } + +
+ { + setPasswordHistoryEnabled(value); + } } + width={ 16 } + data-testid={ `${ componentId }-password-history-count-toggle` } + readOnly={ isReadOnly } + /> +
+ + ); + }; + return ( { isRuleBasedPasswordExpiryDisabled - ? serverConfigurationConfig.passwordExpiryComponent( + ? generatePasswordExpiry( componentId, passwordExpiryEnabled, setPasswordExpiryEnabled, - t, - isReadOnly ) + isReadOnly + ) : resolvePasswordExpiration() } - { serverConfigurationConfig.passwordHistoryCountComponent( + { generatePasswordHistoryCount( componentId, passwordHistoryEnabled, setPasswordHistoryEnabled, - t, isReadOnly ) }