diff --git a/packages/client/graphql.schema.json b/packages/client/graphql.schema.json index feba952fa5..0e734fdd95 100644 --- a/packages/client/graphql.schema.json +++ b/packages/client/graphql.schema.json @@ -9334,6 +9334,39 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "confirmRegistration", + "description": null, + "args": [ + { + "name": "id", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "createBirthRegistration", "description": null, @@ -11079,356 +11112,6 @@ ], "possibleTypes": null }, - { - "kind": "OBJECT", - "name": "OIDPUserAddress", - "description": null, - "fields": [ - { - "name": "city", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "country", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "formatted", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "locality", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "postal_code", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "region", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "street_address", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "OIDPUserInfo", - "description": null, - "fields": [ - { - "name": "address", - "description": null, - "args": [], - "type": { - "kind": "OBJECT", - "name": "OIDPUserAddress", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "birthdate", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "email", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "email_verified", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "family_name", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "gender", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "given_name", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "locale", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "middle_name", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nickname", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "phone_number", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "phone_number_verified", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "picture", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "preferred_username", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "profile", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "sub", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "updated_at", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "website", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "zoneinfo", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, { "kind": "INPUT_OBJECT", "name": "ObservationFHIRIDS", @@ -13241,79 +12924,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "getOIDPUserInfo", - "description": null, - "args": [ - { - "name": "clientId", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "code", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "grantType", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "redirectUri", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - } - ], - "type": { - "kind": "OBJECT", - "name": "UserInfo", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "getRegistrationsListByFilter", "description": null, @@ -19290,65 +18900,6 @@ "enumValues": null, "possibleTypes": null }, - { - "kind": "OBJECT", - "name": "UserInfo", - "description": null, - "fields": [ - { - "name": "districtFhirId", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "locationLevel3FhirId", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "oidpUserInfo", - "description": null, - "args": [], - "type": { - "kind": "OBJECT", - "name": "OIDPUserInfo", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "stateFhirId", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, { "kind": "INPUT_OBJECT", "name": "UserInput", diff --git a/packages/client/src/App.tsx b/packages/client/src/App.tsx index d6b32c5473..78e43a1227 100644 --- a/packages/client/src/App.tsx +++ b/packages/client/src/App.tsx @@ -63,7 +63,6 @@ import { AdministrativeLevels } from '@client/views/Organisation/AdministrativeL import { VerifyCertificatePage } from '@client/views/VerifyCertificate/VerifyCertificatePage' import { IssueCertificate } from '@client/views/IssueCertificate/IssueCertificate' import { IssuePayment } from '@client/views/IssueCertificate/IssueCollectorForm/IssuePayment' -import { OIDPVerificationCallback } from './views/OIDPVerificationCallback/OIDPVerificationCallback' import { ApolloProvider } from '@client/utils/ApolloProvider' import { Home } from '@client/views/OfficeHome/Home' import { PrintRecord } from './views/PrintRecord/PrintRecord' @@ -533,15 +532,6 @@ export function App(props: IAppProps) { } component={IssuePayment} /> - ( (val: string) => setFieldValue(fieldDefinition.name, val), [fieldDefinition.name, setFieldValue] ) - const isOnline = useOnlineStatus() const inputProps = { id: fieldDefinition.name, @@ -615,21 +609,6 @@ const GeneratedInputField = React.memo( ) } - if (fieldDefinition.type === NID_VERIFICATION_BUTTON) { - return ( - - - - ) - } - if (fieldDefinition.type === REDIRECT) { return ( void } interface IDispatchProps { @@ -1120,18 +1098,12 @@ class FormSectionComponent extends React.Component { field.searchableType as LocationType[] ) } - : field.type === NID_VERIFICATION_BUTTON - ? ({ - ...field, - onClick: this.props.onNidAuthenticationClick - } as INidVerificationButton) : field if ( field.type === FETCH_BUTTON || field.type === FIELD_WITH_DYNAMIC_DEFINITIONS || field.type === SELECT_WITH_DYNAMIC_OPTIONS || - field.type === NID_VERIFICATION_BUTTON || field.type === BUTTON ) { return ( @@ -1311,7 +1283,6 @@ export const FormFieldGenerator: React.FC = (props) => { const userDetails = useSelector(getUserDetails) const intl = useIntl() const dispatch = useDispatch() - const { onClick: onNidAuthenticationClick } = useNidAuthentication() return ( @@ -1345,7 +1316,6 @@ export const FormFieldGenerator: React.FC = (props) => { offlineCountryConfig={offlineCountryConfig} userDetails={userDetails} dynamicDispatch={(...args) => dispatch(dynamicDispatch(...args))} - onNidAuthenticationClick={onNidAuthenticationClick} /> )} diff --git a/packages/client/src/forms/index.ts b/packages/client/src/forms/index.ts index 07c69b9426..c157e88245 100644 --- a/packages/client/src/forms/index.ts +++ b/packages/client/src/forms/index.ts @@ -69,7 +69,6 @@ export const DYNAMIC_LIST = 'DYNAMIC_LIST' export const FETCH_BUTTON = 'FETCH_BUTTON' export const LOCATION_SEARCH_INPUT = 'LOCATION_SEARCH_INPUT' export const TIME = 'TIME' -export const NID_VERIFICATION_BUTTON = 'NID_VERIFICATION_BUTTON' export const DIVIDER = 'DIVIDER' export const HEADING3 = 'HEADING3' export const SIGNATURE = 'SIGNATURE' @@ -716,12 +715,6 @@ export interface ITimeFormFIeld extends IFormFieldBase { type: typeof TIME ignorePlaceHolder?: boolean } -export interface INidVerificationButton extends IFormFieldBase { - type: typeof NID_VERIFICATION_BUTTON - labelForVerified: MessageDescriptor - labelForUnverified: MessageDescriptor - labelForOffline: MessageDescriptor -} export interface ISignatureFormField extends IFormFieldBase { type: typeof SIGNATURE @@ -790,7 +783,6 @@ export type IFormField = | ILocationSearchInputFormField | IDateRangePickerFormField | ITimeFormFIeld - | INidVerificationButton | IDividerFormField | ISignatureFormField | IHttpFormField @@ -1231,13 +1223,6 @@ export interface Ii18nLoaderButtonField extends Ii18nFormFieldBase { errorText: string networkErrorText: string } -export interface Ii18nNidVerificationButtonField extends Ii18nFormFieldBase { - type: typeof NID_VERIFICATION_BUTTON - onClick: () => void - labelForVerified: string - labelForUnverified: string - labelForOffline: string -} export interface I18nDividerField extends Ii18nFormFieldBase { type: typeof DIVIDER @@ -1317,7 +1302,6 @@ export type Ii18nFormField = | Ii18nLocationSearchInputFormField | Ii18nDateRangePickerFormField | Ii18nTimeFormField - | Ii18nNidVerificationButtonField | I18nDividerField | I18nHeading3Field | Ii18nSignatureField diff --git a/packages/client/src/forms/utils.ts b/packages/client/src/forms/utils.ts index c732a35549..9c7e35dd56 100644 --- a/packages/client/src/forms/utils.ts +++ b/packages/client/src/forms/utils.ts @@ -41,8 +41,6 @@ import { FIELD_WITH_DYNAMIC_DEFINITIONS, IRadioGroupWithNestedFieldsFormField, ISelectFormFieldWithOptions, - NID_VERIFICATION_BUTTON, - INidVerificationButton, BULLET_LIST, HIDDEN, Ii18nHiddenFormField, @@ -190,18 +188,6 @@ export const internationaliseFieldObject = ( ) } - if (base.type === NID_VERIFICATION_BUTTON) { - ;(base as any).labelForVerified = intl.formatMessage( - (field as INidVerificationButton).labelForVerified - ) - ;(base as any).labelForUnverified = intl.formatMessage( - (field as INidVerificationButton).labelForUnverified - ) - ;(base as any).labelForOffline = intl.formatMessage( - (field as INidVerificationButton).labelForOffline - ) - } - if (isFieldButton(field)) { ;(base as Ii18nButtonFormField).buttonLabel = intl.formatMessage( field.buttonLabel diff --git a/packages/client/src/i18n/messages/views/nidVerificationCallback.ts b/packages/client/src/i18n/messages/views/nidVerificationCallback.ts deleted file mode 100644 index ffda7b5abc..0000000000 --- a/packages/client/src/i18n/messages/views/nidVerificationCallback.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import { defineMessages, MessageDescriptor } from 'react-intl' - -interface INidVerfificationCallBackMessages - extends Record { - authenticatingNid: MessageDescriptor - failedToAuthenticateNid: MessageDescriptor -} - -const messagesToDefine: INidVerfificationCallBackMessages = { - authenticatingNid: { - defaultMessage: 'Authenticating National ID', - id: 'misc.nidCallback.authenticatingNid', - description: 'Label for nid authention ongoing phase' - }, - failedToAuthenticateNid: { - defaultMessage: 'Failed to authenticate National ID', - id: 'misc.nidCallback.failedToAuthenticateNid', - description: 'Label for nid authention failed phase' - } -} - -export const messages: INidVerfificationCallBackMessages = - defineMessages(messagesToDefine) diff --git a/packages/client/src/navigation/routes.ts b/packages/client/src/navigation/routes.ts index 15fae4c974..35395667ab 100644 --- a/packages/client/src/navigation/routes.ts +++ b/packages/client/src/navigation/routes.ts @@ -99,6 +99,4 @@ export const VIEW_RECORD = '/:declarationId/viewRecord' export const VIEW_VERIFY_CERTIFICATE = '/verify-certificate/:declarationId' export const ORGANISATIONS_INDEX = '/organisation/:locationId?' -export const OIDP_VERIFICATION_CALLBACK = '/mosip-callback' - export const PRINT_RECORD = '/print-record/:declarationId' diff --git a/packages/client/src/setupTests.ts b/packages/client/src/setupTests.ts index 9e2c276cdc..bc63507214 100644 --- a/packages/client/src/setupTests.ts +++ b/packages/client/src/setupTests.ts @@ -286,11 +286,3 @@ vi.mock('react-router', async () => ({ section: 'child' })) })) - -vi.mock('@client/views/OIDPVerificationCallback/utils', async () => ({ - ...((await vi.importActual( - '@client/views/OIDPVerificationCallback/utils' - )) as any), - useExtractCallBackState: vi.fn(), - useQueryParams: vi.fn() -})) diff --git a/packages/client/src/tests/schema.graphql b/packages/client/src/tests/schema.graphql index ade59b35fd..eef8e51b9c 100644 --- a/packages/client/src/tests/schema.graphql +++ b/packages/client/src/tests/schema.graphql @@ -1179,39 +1179,6 @@ input ObservationFHIRIDS { lastPreviousLiveBirth: String } -type OIDPUserAddress { - formatted: String - street_address: String - locality: String - region: String - postal_code: String - city: String - country: String -} - -type OIDPUserInfo { - sub: String! - name: String - given_name: String - family_name: String - middle_name: String - nickname: String - preferred_username: String - profile: String - picture: String - website: String - email: String - email_verified: Boolean - gender: String - birthdate: String - zoneinfo: String - locale: String - phone_number: String - phone_number_verified: Boolean - address: OIDPUserAddress - updated_at: Int -} - type OperationHistorySearchSet { operationType: String operatedOn: Date @@ -1455,12 +1422,6 @@ type Query { getActiveCertificatesSVG: [CertificateSVG!] fetchSystem(clientId: ID!): System informantSMSNotifications: [SMSNotification!] - getOIDPUserInfo( - code: String! - clientId: String! - redirectUri: String! - grantType: String - ): UserInfo } type QuestionnaireQuestion { @@ -1944,13 +1905,6 @@ input UserIdentifierInput { value: String } -type UserInfo { - oidpUserInfo: OIDPUserInfo - districtFhirId: String - stateFhirId: String - locationLevel3FhirId: String -} - input UserInput { id: ID name: [HumanNameInput!]! diff --git a/packages/client/src/utils/gateway.ts b/packages/client/src/utils/gateway.ts index 0c6699aacf..3c50650dab 100644 --- a/packages/client/src/utils/gateway.ts +++ b/packages/client/src/utils/gateway.ts @@ -932,6 +932,7 @@ export type Mutation = { changeEmail?: Maybe changePassword?: Maybe changePhone?: Maybe + confirmRegistration: Scalars['ID'] createBirthRegistration: CreatedIds createBirthRegistrationCorrection: Scalars['ID'] createDeathRegistration: CreatedIds @@ -1032,6 +1033,10 @@ export type MutationChangePhoneArgs = { verifyCode: Scalars['String'] } +export type MutationConfirmRegistrationArgs = { + id: Scalars['ID'] +} + export type MutationCreateBirthRegistrationArgs = { details: BirthRegistrationInput } @@ -1234,41 +1239,6 @@ export enum NotificationType { Sms = 'SMS' } -export type OidpUserAddress = { - __typename?: 'OIDPUserAddress' - city?: Maybe - country?: Maybe - formatted?: Maybe - locality?: Maybe - postal_code?: Maybe - region?: Maybe - street_address?: Maybe -} - -export type OidpUserInfo = { - __typename?: 'OIDPUserInfo' - address?: Maybe - birthdate?: Maybe - email?: Maybe - email_verified?: Maybe - family_name?: Maybe - gender?: Maybe - given_name?: Maybe - locale?: Maybe - middle_name?: Maybe - name?: Maybe - nickname?: Maybe - phone_number?: Maybe - phone_number_verified?: Maybe - picture?: Maybe - preferred_username?: Maybe - profile?: Maybe - sub: Scalars['String'] - updated_at?: Maybe - website?: Maybe - zoneinfo?: Maybe -} - export type ObservationFhirids = { attendantAtBirth?: InputMaybe birthType?: InputMaybe @@ -1398,7 +1368,6 @@ export type Query = { getDeclarationsStartedMetrics?: Maybe getEventsWithProgress?: Maybe getLocationStatistics?: Maybe - getOIDPUserInfo?: Maybe getRegistrationsListByFilter?: Maybe getSystemRoles?: Maybe> getTotalCertifications?: Maybe> @@ -1496,13 +1465,6 @@ export type QueryGetLocationStatisticsArgs = { populationYear: Scalars['Int'] } -export type QueryGetOidpUserInfoArgs = { - clientId: Scalars['String'] - code: Scalars['String'] - grantType?: InputMaybe - redirectUri: Scalars['String'] -} - export type QueryGetRegistrationsListByFilterArgs = { event: Scalars['String'] filterBy: Scalars['String'] @@ -2153,14 +2115,6 @@ export type UserIdentifierInput = { value?: InputMaybe } -export type UserInfo = { - __typename?: 'UserInfo' - districtFhirId?: Maybe - locationLevel3FhirId?: Maybe - oidpUserInfo?: Maybe - stateFhirId?: Maybe -} - export type UserInput = { device?: InputMaybe email?: InputMaybe @@ -5328,55 +5282,6 @@ export type MarkEventAsNotDuplicateMutation = { markEventAsNotDuplicate: string } -export type GetOidpUserInfoQueryVariables = Exact<{ - code: Scalars['String'] - clientId: Scalars['String'] - redirectUri: Scalars['String'] - grantType?: InputMaybe -}> - -export type GetOidpUserInfoQuery = { - __typename?: 'Query' - getOIDPUserInfo?: { - __typename?: 'UserInfo' - districtFhirId?: string | null - stateFhirId?: string | null - locationLevel3FhirId?: string | null - oidpUserInfo?: { - __typename?: 'OIDPUserInfo' - sub: string - name?: string | null - given_name?: string | null - family_name?: string | null - middle_name?: string | null - nickname?: string | null - preferred_username?: string | null - profile?: string | null - picture?: string | null - website?: string | null - email?: string | null - email_verified?: boolean | null - gender?: string | null - birthdate?: string | null - zoneinfo?: string | null - locale?: string | null - phone_number?: string | null - phone_number_verified?: boolean | null - updated_at?: number | null - address?: { - __typename?: 'OIDPUserAddress' - formatted?: string | null - street_address?: string | null - locality?: string | null - region?: string | null - postal_code?: string | null - city?: string | null - country?: string | null - } | null - } | null - } | null -} - type EventSearchFields_BirthEventSearchSet_Fragment = { __typename?: 'BirthEventSearchSet' dateOfBirth?: PlainDate | null diff --git a/packages/client/src/views/OIDPVerificationCallback/OIDPVerificationCallback.test.tsx b/packages/client/src/views/OIDPVerificationCallback/OIDPVerificationCallback.test.tsx deleted file mode 100644 index 4b8d9e005b..0000000000 --- a/packages/client/src/views/OIDPVerificationCallback/OIDPVerificationCallback.test.tsx +++ /dev/null @@ -1,164 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import { checkAuth } from '@client/profile/profileActions' -import { queries } from '@client/profile/queries' -import { storage } from '@client/storage' -import { createStore } from '@client/store' -import { createTestComponent, mockUserResponse } from '@client/tests/util' -import { merge } from 'lodash' -import * as React from 'react' -import { waitFor, waitForElement } from '@client/tests/wait-for-element' -import { vi, Mock } from 'vitest' -import { OIDPVerificationCallback } from './OIDPVerificationCallback' -import { URLSearchParams } from 'url' -import { useQueryParams, useExtractCallBackState } from './utils' -import { GET_OIDP_USER_INFO } from './queries' -import { createDeclaration, storeDeclaration } from '@client/declarations' -import { Event } from '@client/utils/gateway' - -const draft = createDeclaration(Event.Birth) -draft.data.mother = {} - -const mockFetchUserDetails = vi.fn() - -const registerScopeToken = - 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJyZWdpc3RlciIsImNlcnRpZnkiLCJkZW1vIl0sImlhdCI6MTU0MjY4ODc3MCwiZXhwIjoxNTQzMjkzNTcwLCJhdWQiOlsib3BlbmNydnM6YXV0aC11c2VyIiwib3BlbmNydnM6dXNlci1tZ250LXVzZXIiLCJvcGVuY3J2czpoZWFydGgtdXNlciIsIm9wZW5jcnZzOmdhdGV3YXktdXNlciIsIm9wZW5jcnZzOm5vdGlmaWNhdGlvbi11c2VyIiwib3BlbmNydnM6d29ya2Zsb3ctdXNlciJdLCJpc3MiOiJvcGVuY3J2czphdXRoLXNlcnZpY2UiLCJzdWIiOiI1YmVhYWY2MDg0ZmRjNDc5MTA3ZjI5OGMifQ.ElQd99Lu7WFX3L_0RecU_Q7-WZClztdNpepo7deNHqzro-Cog4WLN7RW3ZS5PuQtMaiOq1tCb-Fm3h7t4l4KDJgvC11OyT7jD6R2s2OleoRVm3Mcw5LPYuUVHt64lR_moex0x_bCqS72iZmjrjS-fNlnWK5zHfYAjF2PWKceMTGk6wnI9N49f6VwwkinJcwJi6ylsjVkylNbutQZO0qTc7HRP-cBfAzNcKD37FqTRNpVSvHdzQSNcs7oiv3kInDN5aNa2536XSd3H-RiKR9hm9eID9bSIJgFIGzkWRd5jnoYxT70G0t03_mTVnDnqPXDtyI-lmerx24Ost0rQLUNIg' -const getItem = window.localStorage.getItem as Mock -const nameObj = { - data: { - getUser: { - name: [ - { - use: 'en', - firstNames: 'Mohammad', - familyName: 'Ashraful', - __typename: 'HumanName' - }, - { use: 'bn', firstNames: '', familyName: '', __typename: 'HumanName' } - ], - role: { - _id: '778464c0-08f8-4fb7-8a37-b86d1efc462a', - labels: [ - { - lang: 'en', - label: 'DISTRICT_REGISTRAR' - } - ] - } - } - } -} - -merge(mockUserResponse, nameObj) -mockFetchUserDetails.mockReturnValue(mockUserResponse) -queries.fetchUserDetails = mockFetchUserDetails -storage.getItem = vi.fn() -storage.setItem = vi.fn() - -// Define the mock query - -const graphqlMocks = [ - { - request: { - query: GET_OIDP_USER_INFO, - variables: { - code: '1234', - clientId: '7b621732-6c1d-4808-81b2-fd67f05f3af3', - redirectUri: 'http://localhost:3000/mosip-callback' - } - }, - result: { - data: { - getOIDPUserInfo: { - oidpUserInfo: { - sub: '123', - name: 'John Doe', - given_name: 'John', - family_name: 'Doe', - middle_name: null, - nickname: null, - preferred_username: 'jdoe', - profile: 'https://example.com/profile', - picture: 'https://example.com/picture.jpg', - website: 'https://example.com', - email: 'jdoe@example.com', - email_verified: true, - gender: 'male', - birthdate: '1980-01-01', - zoneinfo: 'America/Los_Angeles', - locale: 'en-US', - phone_number: '+1-123-456-7890', - phone_number_verified: true, - address: { - formatted: '123 Main St\nSan Francisco, CA 94105\nUSA', - street_address: '123 Main St', - locality: 'San Francisco', - region: 'CA', - postal_code: '94105', - country: 'USA' - }, - updated_at: '2023-03-30T10:00:00Z' - }, - districtFhirId: '12345', - stateFhirId: '67890' - } - } - } - } -] - -let { store, history } = createStore() - -beforeEach(async () => { - ;({ store, history } = createStore()) - - getItem.mockReturnValue(registerScopeToken) - getItem.mockReturnValue('ea02388') - ;(useExtractCallBackState as Mock).mockImplementation(() => ({ - pathname: 'http://localhost:3000/mosip-callback', - section: 'mother', - declarationId: draft.id - })) - ;(useQueryParams as Mock).mockImplementation( - () => new URLSearchParams({ code: '1234' }) - ) - - await store.dispatch(checkAuth()) - await store.dispatch(storeDeclaration(draft)) -}) - -describe('Nid Verfication Callback page', () => { - it('When nid user is successfully fetched', async () => { - const testComponent = await createTestComponent( - , - { store, history, graphqlMocks: graphqlMocks } - ) - await waitFor(() => testComponent.find('#authenticating-label').length > 0) - - await new Promise((resolve) => { - setTimeout(resolve, 100) - }) - - const declaration = store - .getState() - .declarationsState.declarations.find((d) => d.id === draft.id) - expect(declaration?.data.mother.firstNamesEng).toBe('John') - }) - - it('When nid user info fetch has failed', async () => { - const testComponent = await createTestComponent( - , - { store, history } - ) - - await waitForElement(testComponent, '#authentication-failed-label') - }) -}) diff --git a/packages/client/src/views/OIDPVerificationCallback/OIDPVerificationCallback.tsx b/packages/client/src/views/OIDPVerificationCallback/OIDPVerificationCallback.tsx deleted file mode 100644 index a0686eedbd..0000000000 --- a/packages/client/src/views/OIDPVerificationCallback/OIDPVerificationCallback.tsx +++ /dev/null @@ -1,151 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import { - IDeclaration, - modifyDeclaration, - writeDeclaration -} from '@client/declarations' -import { selectCountryLogo, getOfflineData } from '@client/offline/selectors' -import React from 'react' -import { useIntl } from 'react-intl' -import { useDispatch, useSelector } from 'react-redux' -import { - addNidUserInfoToDeclaration, - useExtractCallBackState, - useQueryParams -} from '@client/views/OIDPVerificationCallback/utils' -import styled from 'styled-components' -import { Link, Stack, Text, Spinner, Button, Icon } from '@opencrvs/components' -import { CountryLogo } from '@opencrvs/components/lib/icons' -import { LogoContainer } from '@client/views/UserSetup/UserSetupPage' -import { buttonMessages } from '@client/i18n/messages' -import { messages as nidCallbackMessages } from '@client/i18n/messages/views/nidVerificationCallback' -import { useQuery } from '@apollo/client' -import { useDeclaration } from '@client/declarations/selectors' -import { GET_OIDP_USER_INFO } from '@client/views/OIDPVerificationCallback/queries' -import { useHistory } from 'react-router' -import { OIDP_VERIFICATION_CALLBACK } from '@client/navigation/routes' - -// OIDP Verification Callback -// -- -// Checks the ?state= query parameter for a JSON string like: { pathname: "/path/somewhere" } -// Redirects to the pathname in state - -const Page = styled.div` - color: ${({ theme }) => theme.colors.copy}; - background: ${({ theme }) => theme.colors.background}; - min-height: 100vh; - display: flex; - flex-direction: column; - text-align: center; -` -const Container = styled.div` - width: 288px; - margin: auto; - margin-top: 10vh; -` - -const UserActionsContainer = styled.div` - background: ${({ theme }) => theme.colors.white}; - padding: 24px 40px; - border: 1px solid ${({ theme }) => theme.colors.grey300}; - border-radius: 10px; -` - -export const OIDPVerificationCallback = () => { - const params = useQueryParams() - const { pathname, declarationId, section } = useExtractCallBackState() - const code = params.get('code') - const offlineData = useSelector(getOfflineData) - const clientId = offlineData.systems.find((s) => s.type === 'NATIONAL_ID') - ?.settings?.openIdProviderClientId - const intl = useIntl() - const logo = useSelector(selectCountryLogo) - const declaration = useDeclaration(declarationId) - const dispatch = useDispatch() - const history = useHistory() - const oidpUserInfoQueryVariables = { - code, - clientId, - redirectUri: `${window.location.origin}${OIDP_VERIFICATION_CALLBACK}` - } - const { loading, error, refetch } = useQuery(GET_OIDP_USER_INFO, { - variables: oidpUserInfoQueryVariables, - notifyOnNetworkStatusChange: true, - onCompleted: (data) => { - addNidUserInfoToDeclaration(declaration, section, data.getOIDPUserInfo) - dispatch(modifyDeclaration(declaration)) - dispatch(writeDeclaration(declaration)) - goToVerificationOrigin() - } - }) - - if (!pathname) { - // Do not redirect and let the hooks throw - return null - } - - const goToVerificationOrigin = () => { - pathname && history.push(pathname) - } - - const handleRetry = () => refetch(oidpUserInfoQueryVariables) - - return ( - - - - - - - - - {loading && ( - <> - - - {intl.formatMessage(nidCallbackMessages.authenticatingNid)} - - - )} - {error && ( - <> - - - {intl.formatMessage( - nidCallbackMessages.failedToAuthenticateNid - )} - - - - )} - - {intl.formatMessage(buttonMessages.cancel)} - - - - - - - ) -} diff --git a/packages/client/src/views/OIDPVerificationCallback/queries.ts b/packages/client/src/views/OIDPVerificationCallback/queries.ts deleted file mode 100644 index 6d3cbb6ab1..0000000000 --- a/packages/client/src/views/OIDPVerificationCallback/queries.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import { gql } from '@apollo/client' - -export const GET_OIDP_USER_INFO = gql` - query getOIDPUserInfo( - $code: String! - $clientId: String! - $redirectUri: String! - $grantType: String - ) { - getOIDPUserInfo( - code: $code - clientId: $clientId - redirectUri: $redirectUri - grantType: $grantType - ) { - oidpUserInfo { - sub - name - given_name - family_name - middle_name - nickname - preferred_username - profile - picture - website - email - email_verified - gender - birthdate - zoneinfo - locale - phone_number - phone_number_verified - address { - formatted - street_address - locality - region - postal_code - city - country - } - updated_at - } - districtFhirId - stateFhirId - locationLevel3FhirId - } - } -` diff --git a/packages/client/src/views/OIDPVerificationCallback/utils.ts b/packages/client/src/views/OIDPVerificationCallback/utils.ts deleted file mode 100644 index 36661fc1ea..0000000000 --- a/packages/client/src/views/OIDPVerificationCallback/utils.ts +++ /dev/null @@ -1,271 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ - -import { IDeclaration, writeDeclaration } from '@client/declarations' -import { useDeclaration } from '@client/declarations/selectors' -import { isDefaultCountry } from '@client/forms/utils' -import { OIDP_VERIFICATION_CALLBACK } from '@client/navigation/routes' -import { IOfflineData } from '@client/offline/reducer' -import { getOfflineData } from '@client/offline/selectors' -import formatDate from '@client/utils/date-formatting' -import { camelCase } from 'lodash' -import { useEffect, useMemo } from 'react' -import { useDispatch, useSelector } from 'react-redux' -import { useLocation, useRouteMatch } from 'react-router' - -interface OIDPUserAddress { - formatted?: string | null - street_address?: string | null - locality?: string | null - region?: string | null - postal_code?: string | null - city?: string | null - country?: string | null -} - -interface oidpUserInfo { - sub: string - name?: string | null - given_name?: string | null - family_name?: string | null - middle_name?: string | null - nickname?: string | null - preferred_username?: string | null - profile?: string | null - picture?: string | null - website?: string | null - email?: string | null - email_verified?: boolean | null - gender?: string | null - birthdate?: string | null - zoneinfo?: string | null - locale?: string | null - phone_number?: string | null - phone_number_verified?: boolean | null - address?: OIDPUserAddress | null - updated_at?: number | null -} - -interface UserInfo { - oidpUserInfo: oidpUserInfo - districtFhirId?: string | null - stateFhirId?: string | null - locationLevel3FhirId?: string | null -} - -interface INidCallbackState { - pathname: string | undefined - declarationId: string - section: string -} - -export function useQueryParams() { - const { search } = useLocation() - - return useMemo(() => new URLSearchParams(search), [search]) -} - -export function addNidUserInfoToDeclaration( - declaration: IDeclaration, - section: string, - nidUserInfo: UserInfo -) { - const oidpUserInfo = nidUserInfo.oidpUserInfo - - // initialise the section (mother/father/informant) if it doesn't exist - if (!declaration.data[section]) { - declaration.data[section] = {} - } - - const declarationDataSection = declaration.data[section] - const fieldsModifiedByNidUserInfo = [] - const splitFullName = splitName(oidpUserInfo.name) - - if (oidpUserInfo.birthdate) { - // Deceased don't have "deceased" -prefix - const dataSection = section === 'deceased' ? '' : section - declarationDataSection[camelCase(`${dataSection}BirthDate`)] = formatDate( - new Date(oidpUserInfo.birthdate), - 'yyyy-MM-dd' - ) - fieldsModifiedByNidUserInfo.push(camelCase(`${dataSection}BirthDate`)) - } - - if (splitFullName.firstName) { - declarationDataSection['firstNamesEng'] = splitFullName.firstName - fieldsModifiedByNidUserInfo.push('firstNamesEng') - } - if (splitFullName.lastName) { - declarationDataSection['familyNameEng'] = splitFullName.lastName - fieldsModifiedByNidUserInfo.push('familyNameEng') - } - - if (oidpUserInfo.address?.country) { - declarationDataSection['countryPrimary'] = oidpUserInfo.address.country - fieldsModifiedByNidUserInfo.push('countryPrimary') - - if (isDefaultCountry(oidpUserInfo.address.country)) { - //populate default country specific address fields - if (nidUserInfo.stateFhirId) { - declarationDataSection['statePrimary'] = nidUserInfo.stateFhirId - fieldsModifiedByNidUserInfo.push('statePrimary') - } - if (nidUserInfo.districtFhirId) { - declarationDataSection['districtPrimary'] = nidUserInfo.districtFhirId - fieldsModifiedByNidUserInfo.push('districtPrimary') - } - if (nidUserInfo.locationLevel3FhirId) { - declarationDataSection['locationLevel3Primary'] = - nidUserInfo.locationLevel3FhirId - fieldsModifiedByNidUserInfo.push('locationLevel3Primary') - } - if (oidpUserInfo.address.street_address) { - declarationDataSection['addressLine2UrbanOptionPrimary'] = - oidpUserInfo.address.street_address - fieldsModifiedByNidUserInfo.push('addressLine2UrbanOptionPrimary') - } - if (oidpUserInfo.address.postal_code) { - declarationDataSection['postCodePrimary'] = - oidpUserInfo.address.postal_code - fieldsModifiedByNidUserInfo.push('postCodePrimary') - } - } else { - //populate international address fields - if (oidpUserInfo.address.region) { - declarationDataSection['internationalStatePrimary'] = - oidpUserInfo.address.region - fieldsModifiedByNidUserInfo.push('internationalStatePrimary') - } - if (oidpUserInfo.address.locality) { - declarationDataSection['internationalDistrictPrimary'] = - oidpUserInfo.address.locality - fieldsModifiedByNidUserInfo.push('internationalDistrictPrimary') - } - if (oidpUserInfo.address.city) { - declarationDataSection['locationLevel3Primary'] = - oidpUserInfo.address.city - fieldsModifiedByNidUserInfo.push('locationLevel3Primary') - } - if (oidpUserInfo.address.street_address) { - declarationDataSection['internationalAddressLine1Primary'] = - oidpUserInfo.address.street_address - fieldsModifiedByNidUserInfo.push('internationalAddressLine1Primary') - } - if (oidpUserInfo.address.postal_code) { - declarationDataSection['internationalPostcodePrimary'] = - oidpUserInfo.address.postal_code - fieldsModifiedByNidUserInfo.push('internationalPostcodePrimary') - } - } - - if (section === 'father') { - declarationDataSection['primaryAddressSameAsOtherPrimary'] = false - } - - if (section === 'spouse') { - declarationDataSection['primaryAddressSameAsOtherPrimary'] = false - } - } - - declarationDataSection['fieldsModifiedByNidUserInfo'] = - fieldsModifiedByNidUserInfo - declarationDataSection[`${section}NidVerification`] = oidpUserInfo.sub -} - -function splitName(name: string | undefined | null = '') { - if (!name) { - return { firstName: '', lastName: '' } - } - - const [firstName, ...lastName] = name.split(' ').filter(Boolean) - return { - firstName: firstName, - lastName: lastName.join(' ') - } -} - -export const useNidAuthentication = () => { - const dispatch = useDispatch() - const match = useRouteMatch() - const matchParams = match.params as { - declarationId: string - groupId: string - pageId: string - } - const offlineCountryConfig = useSelector(getOfflineData) - const declaration = useDeclaration(matchParams.declarationId) - - const onClick = () => - dispatch( - writeDeclaration(declaration, () => { - redirectToNidIntegration( - offlineCountryConfig, - matchParams.declarationId, - matchParams.pageId, - match.url - ) - }) - ) - - return { onClick } -} - -export function redirectToNidIntegration( - offlineCountryConfig: IOfflineData, - declarationId: string, - currentSection: string, - currentPathname: string -) { - const nidSystemSetting = offlineCountryConfig.systems.find( - (s) => s.type === 'NATIONAL_ID' - )?.settings - - if (!nidSystemSetting) { - return - } - const url = new URL(`${nidSystemSetting?.openIdProviderBaseUrl}authorize`) - - url.searchParams.append( - 'client_id', - nidSystemSetting?.openIdProviderClientId || '' - ) - url.searchParams.append( - 'redirect_uri', - `${window.location.origin}${OIDP_VERIFICATION_CALLBACK}` - ) - url.searchParams.append('response_type', 'code') - url.searchParams.append('scope', 'openid profile') - url.searchParams.append('acr_values', 'mosip:idp:acr:static-code') - const stateToBeSent: INidCallbackState = { - pathname: currentPathname, - declarationId: declarationId, - section: currentSection - } - url.searchParams.append('state', JSON.stringify(stateToBeSent)) - url.searchParams.append('claims', nidSystemSetting.openIdProviderClaims || '') - window.location.href = url.toString() -} - -export const useExtractCallBackState = () => { - const params = useQueryParams() - - useEffect(() => { - if (!params.get('state')) { - throw new Error('No state provided from OIDP callback.') - } - }, [params]) - - const { pathname, declarationId, section } = JSON.parse( - params.get('state') ?? '{}' - ) as INidCallbackState - - return { pathname, declarationId, section } -} diff --git a/packages/client/src/views/RegisterForm/review/ReviewSection.tsx b/packages/client/src/views/RegisterForm/review/ReviewSection.tsx index 7cfc1bc072..c2406b6b80 100644 --- a/packages/client/src/views/RegisterForm/review/ReviewSection.tsx +++ b/packages/client/src/views/RegisterForm/review/ReviewSection.tsx @@ -68,7 +68,6 @@ import { SELECT_WITH_DYNAMIC_OPTIONS, SELECT_WITH_OPTIONS, SubmissionAction, - NID_VERIFICATION_BUTTON, WARNING, DIVIDER, HIDDEN @@ -132,7 +131,6 @@ import { } from '@client/views/CorrectionForm/utils' import { ListReview } from '@opencrvs/components/lib/ListReview' import { DuplicateWarning } from '@client/views/Duplicates/DuplicateWarning' -import { VerificationButton } from '@opencrvs/components/lib/VerificationButton' import { DuplicateForm } from '@client/views/RegisterForm/duplicate/DuplicateForm' import { Button } from '@opencrvs/components/lib/Button' import { UserDetails } from '@client/utils/userUtils' @@ -542,25 +540,6 @@ const renderValue = ( ) return (selectedLocation && selectedLocation.displayLabel) || '' } - if (field.type === NID_VERIFICATION_BUTTON) { - return ( - {}} - labelForVerified={intl.formatMessage( - formMessageDescriptors.nidVerified - )} - labelForUnverified={intl.formatMessage( - formMessageDescriptors.nidNotVerified - )} - labelForOffline={intl.formatMessage(formMessageDescriptors.nidOffline)} - reviewLabelForUnverified={intl.formatMessage( - formMessageDescriptors.nidNotVerifiedReviewSection - )} - status={value ? 'verified' : 'unverified'} - useAsReviewLabel={true} - /> - ) - } if (typeof value === 'boolean') { return value diff --git a/packages/components/src/VerificationButton/VerificationButton.stories.tsx b/packages/components/src/VerificationButton/VerificationButton.stories.tsx deleted file mode 100644 index 86c315a0e0..0000000000 --- a/packages/components/src/VerificationButton/VerificationButton.stories.tsx +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import * as React from 'react' -import { ComponentMeta, ComponentStory } from '@storybook/react' -import { VerificationButton } from './VerificationButton' - -export default { - title: 'Controls/Verification button', - component: VerificationButton, - parameters: { - docs: { - description: { - component: ` -\`\` is used for authentication flow. It can show an action button, a verified icon or a disabled button with an offline message.` - } - } - } -} as ComponentMeta - -const Template: ComponentStory = (args) => { - return -} - -export const Unverified = Template.bind({}) -Unverified.args = { - status: 'unverified', - onClick: () => {}, - labelForVerified: 'Authenticated', - labelForUnverified: 'Authenticate', - labelForOffline: - 'National ID authentication is currently not available offline.' -} - -export const Verified = Template.bind({}) -Verified.args = { - status: 'verified', - onClick: () => {}, - labelForVerified: 'Authenticated', - labelForUnverified: 'Authenticate', - labelForOffline: - 'National ID authentication is currently not available offline.' -} - -export const Offline = Template.bind({}) -Offline.args = { - status: 'offline', - onClick: () => {}, - labelForVerified: 'Authenticated', - labelForUnverified: 'Authenticate', - labelForOffline: - 'National ID authentication is currently not available offline.' -} diff --git a/packages/components/src/VerificationButton/VerificationButton.tsx b/packages/components/src/VerificationButton/VerificationButton.tsx deleted file mode 100644 index 5910a4c050..0000000000 --- a/packages/components/src/VerificationButton/VerificationButton.tsx +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import * as React from 'react' -import { Icon } from '../Icon' -import { Button } from '../Button' -import styled from 'styled-components' -import { Text } from '../Text' -import { Stack } from '../Stack' - -export interface VerificationButtonProps { - status?: 'unverified' | 'verified' | 'offline' - id?: string - onClick: () => void - labelForVerified: string - labelForUnverified: string - labelForOffline: string - reviewLabelForUnverified?: string - useAsReviewLabel?: boolean -} - -const VerificationBadge = styled.div` - display: inline-flex; - justify-content: center; - align-items: center; - height: 40px; - color: ${({ theme }) => theme.colors.primary}; - svg { - height: 24px; - width: 24px; - vertical-align: top; - margin-left: -2px; - margin-right: 8px; - pointer-events: none; - } -` - -export const VerificationButton = ({ - status = 'unverified', - onClick, - labelForUnverified, - labelForVerified, - labelForOffline, - reviewLabelForUnverified, - useAsReviewLabel -}: VerificationButtonProps) => { - return ( - <> - {status === 'unverified' && !useAsReviewLabel && ( - - )} - - {status === 'unverified' && useAsReviewLabel && ( - - - - {reviewLabelForUnverified} - - - )} - - {status === 'offline' && ( - - - - {labelForOffline} - - - )} - - {status === 'verified' && ( - - - - {labelForVerified} - - - )} - - ) -} diff --git a/packages/components/src/VerificationButton/index.ts b/packages/components/src/VerificationButton/index.ts deleted file mode 100644 index cae4ae9966..0000000000 --- a/packages/components/src/VerificationButton/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -export * from './VerificationButton' diff --git a/packages/components/src/index.ts b/packages/components/src/index.ts index e8be3cd7af..72f96d9a48 100644 --- a/packages/components/src/index.ts +++ b/packages/components/src/index.ts @@ -76,7 +76,6 @@ export * from './Toggle' export * from './ToggleIcon' export * from './ToggleMenu' export * from './Tooltip' -export * from './VerificationButton' export * from './VerticalBar' export * from './ViewData' export * from './WarningMessage' diff --git a/packages/config/src/handlers/forms/field.ts b/packages/config/src/handlers/forms/field.ts index 0330876d34..8ddcfc0ebc 100644 --- a/packages/config/src/handlers/forms/field.ts +++ b/packages/config/src/handlers/forms/field.ts @@ -106,9 +106,6 @@ const LocationSearchInputField = base.extend({ type: z.literal('LOCATION_SEARCH_INPUT') }) const TimeField = base.extend({ type: z.literal('TIME') }) -const NidVerificationButtonField = base.extend({ - type: z.literal('NID_VERIFICATION_BUTTON') -}) const DividerField = base.extend({ type: z.literal('DIVIDER') }) const Heading3Field = base.extend({ type: z.literal('HEADING3') }) const SignatureField = base.extend({ type: z.literal('SIGNATURE') }) @@ -165,7 +162,6 @@ export const field = z.discriminatedUnion('type', [ FetchButtonField, LocationSearchInputField, TimeField, - NidVerificationButtonField, DividerField, Heading3Field, SignatureField, diff --git a/packages/gateway/src/constants.ts b/packages/gateway/src/constants.ts index 740cc44ad6..039a9f4280 100644 --- a/packages/gateway/src/constants.ts +++ b/packages/gateway/src/constants.ts @@ -50,8 +50,3 @@ export const CONFIG_SMS_CODE_EXPIRY_SECONDS = env.CONFIG_SMS_CODE_EXPIRY_SECONDS export const CONFIG_SYSTEM_TOKEN_EXPIRY_SECONDS = env.CONFIG_SYSTEM_TOKEN_EXPIRY_SECONDS export const MINIO_BUCKET = env.MINIO_BUCKET -export const OIDP_BASE_URL = env.NATIONAL_ID_OIDP_BASE_URL -export const OIDP_TOKEN_URL = env.NATIONAL_ID_OIDP_TOKEN_URL -export const OIDP_USERINFO_URL = env.NATIONAL_ID_OIDP_USERINFO_URL -export const OIDP_CLIENT_PRIVATE_KEY = env.NATIONAL_ID_OIDP_CLIENT_PRIVATE_KEY -export const OIDP_JWT_AUD_CLAIM = env.NATIONAL_ID_OIDP_JWT_AUD_CLAIM diff --git a/packages/gateway/src/environment.ts b/packages/gateway/src/environment.ts index 04f8d7cc5a..7fdc7179d8 100644 --- a/packages/gateway/src/environment.ts +++ b/packages/gateway/src/environment.ts @@ -46,17 +46,5 @@ export const env = cleanEnv(process.env, { CONFIG_TOKEN_EXPIRY_SECONDS: num({ default: 604800 }), // 1 week CONFIG_SMS_CODE_EXPIRY_SECONDS: num({ default: 600 }), // 10 minutes CONFIG_SYSTEM_TOKEN_EXPIRY_SECONDS: num({ default: 600 }), // 10 minutes - MINIO_BUCKET: str({ devDefault: 'ocrvs' }), - - NATIONAL_ID_OIDP_BASE_URL: str({ default: undefined }), - NATIONAL_ID_OIDP_TOKEN_URL: str({ default: undefined }), - NATIONAL_ID_OIDP_USERINFO_URL: str({ default: undefined }), - NATIONAL_ID_OIDP_CLIENT_PRIVATE_KEY: str({ - default: undefined, - desc: 'Base64 encoded RS256 JSON Web Key' - }), - NATIONAL_ID_OIDP_JWT_AUD_CLAIM: str({ - default: undefined, - desc: 'Value for "aud" claim when getting access token for fetching Open ID provider user info' - }) + MINIO_BUCKET: str({ devDefault: 'ocrvs' }) }) diff --git a/packages/gateway/src/features/OIDPUserInfo/oidp-types.ts b/packages/gateway/src/features/OIDPUserInfo/oidp-types.ts deleted file mode 100644 index 68fed026ed..0000000000 --- a/packages/gateway/src/features/OIDPUserInfo/oidp-types.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -type OIDPUserAddress = { - formatted: string - street_address: string - locality: string - region: string - postal_code: string - city: string - country: string -} -export type OIDPUserInfo = { - sub: string - name?: string - given_name?: string - family_name?: string - middle_name?: string - nickname?: string - preferred_username?: string - profile?: string - picture?: string - website?: string - email?: string - email_verified?: boolean - gender?: 'female' | 'male' - birthdate?: string - zoneinfo?: string - locale?: string - phone_number?: string - phone_number_verified?: boolean - address?: Partial - updated_at?: number -} diff --git a/packages/gateway/src/features/OIDPUserInfo/root-resolvers.test.ts b/packages/gateway/src/features/OIDPUserInfo/root-resolvers.test.ts deleted file mode 100644 index 56b1a3a653..0000000000 --- a/packages/gateway/src/features/OIDPUserInfo/root-resolvers.test.ts +++ /dev/null @@ -1,267 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import { resolvers as typeResolvers } from '@gateway/features/OIDPUserInfo/root-resolvers' -import { OIDP_CLIENT_PRIVATE_KEY } from '@gateway/constants' -import * as fetchAny from 'jest-fetch-mock' -import * as jose from 'jose' -import { TestResolvers } from '@gateway/utils/testUtils' -const resolvers = typeResolvers as unknown as TestResolvers -const fetch = fetchAny as fetchAny.FetchMock - -beforeEach(() => { - fetch.resetMocks() -}) - -describe('get user info from OIDP national id integration', () => { - it('returns user info and decrypts JWT properly', async () => { - const jwtPayload = { - sub: '1234567890', - name: 'Pyry Rouvila', - given_name: 'Pyry', - family_name: 'Rouvila', - middle_name: 'Test', - birthdate: '1980-04-01', - address: { - formatted: 'Testingston 1\n12345 Ibombo, Central\nFarajaland', - street_address: 'Tammelankatu 1', - locality: 'Ibombo', - region: 'Central', - postal_code: '12345', - country: 'Farajaland' - } - } - - const decodeKey = Buffer.from( - OIDP_CLIENT_PRIVATE_KEY!, - 'base64' - )?.toString() - const jwkObject = JSON.parse(decodeKey) - const privateKey = await jose.importJWK(jwkObject, 'RS256') - const encoded = await new jose.SignJWT(jwtPayload) - .setProtectedHeader({ alg: 'RS256' }) - .sign(privateKey) - - fetch - .mockResponseOnce( - JSON.stringify({ - access_token: 'some-access-token' - }) - ) - .mockResponseOnce(encoded) - .mockResponseOnce( - JSON.stringify({ - resourceType: 'Bundle', - id: '34abc0a0-912d-4b8b-97fd-def9a2321b0f', - meta: { lastUpdated: '2023-05-19T15:39:21.599+00:00' }, - type: 'searchset', - total: 0, - link: [ - { - relation: 'self', - url: 'http://localhost:7070/location?name=Farajaland' - } - ], - entry: [] - }) - ) - .mockResponseOnce( - JSON.stringify({ - resourceType: 'Bundle', - id: 'c819db15-fc28-4606-9db4-095378a06125', - meta: { - lastUpdated: '2023-03-10T13:46:59.923+00:00' - }, - type: 'searchset', - total: 1, - link: [ - { - relation: 'self', - url: 'http://localhost:7070/location?name=Central' - } - ], - entry: [ - { - fullUrl: - 'http://localhost:7070/location/5dd96001-7c94-4eeb-b96e-8a987957f7a2/_history/b3f14d83-eb74-4cfa-b17e-039d57d222f0', - resource: { - resourceType: 'Location', - identifier: [ - { - system: 'http://opencrvs.org/specs/id/statistical-code', - value: 'ADMIN_STRUCTURE_AWn3s2RqgAN' - }, - { - system: 'http://opencrvs.org/specs/id/jurisdiction-type', - value: 'STATE' - } - ], - name: 'Central', - alias: ['Central'], - description: 'AWn3s2RqgAN', - status: 'active', - mode: 'instance', - partOf: { - reference: 'Location/0' - }, - type: { - coding: [ - { - system: 'http://opencrvs.org/specs/location-type', - code: 'ADMIN_STRUCTURE' - } - ] - }, - physicalType: { - coding: [ - { - code: 'jdn', - display: 'Jurisdiction' - } - ] - }, - extension: [], - meta: { - lastUpdated: '2023-01-18T12:54:05.278+00:00', - versionId: 'b3f14d83-eb74-4cfa-b17e-039d57d222f0' - }, - id: '5dd96001-7c94-4eeb-b96e-8a987957f7a2' - }, - request: { - method: 'PUT', - url: 'Location/5dd96001-7c94-4eeb-b96e-8a987957f7a2' - } - } - ] - }) - ) - .mockResponseOnce( - JSON.stringify({ - resourceType: 'Bundle', - id: 'c6f0f99f-ad27-4e6e-9705-a320c1eb3423', - meta: { - lastUpdated: '2023-03-10T11:55:07.461+00:00' - }, - type: 'searchset', - total: 1, - link: [ - { - relation: 'self', - url: 'http://localhost:7070/location?name=Ibombo&type=ADMIN_STRUCTURE' - } - ], - entry: [ - { - fullUrl: - 'http://localhost:7070/location/ab93d5a5-c078-4dfa-b4ca-d54d1e57bca0/_history/5127621b-de2a-4bd2-b530-6413924f2ed2', - resource: { - resourceType: 'Location', - identifier: [ - { - system: 'http://opencrvs.org/specs/id/statistical-code', - value: 'ADMIN_STRUCTURE_oEBf29y8JP8' - }, - { - system: 'http://opencrvs.org/specs/id/jurisdiction-type', - value: 'DISTRICT' - } - ], - name: 'Ibombo', - alias: ['Ibombo'], - description: 'oEBf29y8JP8', - status: 'active', - mode: 'instance', - partOf: { - reference: 'Location/5dd96001-7c94-4eeb-b96e-8a987957f7a2' - }, - type: { - coding: [ - { - system: 'http://opencrvs.org/specs/location-type', - code: 'ADMIN_STRUCTURE' - } - ] - }, - physicalType: { - coding: [ - { - code: 'jdn', - display: 'Jurisdiction' - } - ] - }, - extension: [], - meta: { - lastUpdated: '2023-01-18T12:54:05.324+00:00', - versionId: '5127621b-de2a-4bd2-b530-6413924f2ed2' - }, - id: 'ab93d5a5-c078-4dfa-b4ca-d54d1e57bca0' - }, - request: { - method: 'PUT', - url: 'Location/ab93d5a5-c078-4dfa-b4ca-d54d1e57bca0' - } - } - ] - }) - ) - - const data = await resolvers.Query!.getOIDPUserInfo( - {}, - { - code: 'some-code', - clientId: 'some-client-id', - redirectUri: 'http://localhost:3000/mosip-callback' - } - ) - expect(fetch.mock.calls[0][0]).toMatch(/oauth\/v2\/token$/) - expect(fetch.mock.calls[1][0]).toMatch(/oidc\/v2\/userinfo$/) - expect(fetch.mock.calls[2][0]).toMatch( - /Location\?name=Farajaland&type=ADMIN_STRUCTURE$/ - ) - expect(fetch.mock.calls[3][0]).toMatch( - /Location\?name=Central&type=ADMIN_STRUCTURE$/ - ) - expect(fetch.mock.calls[4][0]).toMatch( - /Location\?name=Ibombo&type=ADMIN_STRUCTURE$/ - ) - expect(data).toEqual({ - oidpUserInfo: jwtPayload, - districtFhirId: '5dd96001-7c94-4eeb-b96e-8a987957f7a2', - locationLevel3FhirId: 'ab93d5a5-c078-4dfa-b4ca-d54d1e57bca0', - stateFhirId: null - }) - }) - - it('throws an error if no access token is returned', async () => { - fetch.mockResponseOnce( - JSON.stringify({ - error: 'invalid_assertion', - error_description: 'invalid_assertion' - }), - { status: 400 } - ) - - try { - await resolvers.Query!.getOIDPUserInfo( - {}, - { - code: 'some-code', - clientId: 'some-client-id', - redirectUri: 'http://localhost:3000/mosip-callback' - } - ) - } catch (e) { - expect(e.message).toMatch('No access token was returned') - } - - expect.assertions(1) - }) -}) diff --git a/packages/gateway/src/features/OIDPUserInfo/root-resolvers.ts b/packages/gateway/src/features/OIDPUserInfo/root-resolvers.ts deleted file mode 100644 index 1180e016cd..0000000000 --- a/packages/gateway/src/features/OIDPUserInfo/root-resolvers.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import { GQLResolver } from '@gateway/graphql/schema' -import { fetchToken, fetchUserInfo } from './utils' - -export const resolvers: GQLResolver = { - Query: { - getOIDPUserInfo: async (_, { code, clientId, redirectUri, grantType }) => { - const tokenResponse = await fetchToken({ - code, - clientId, - redirectUri, - grantType - }) - - if (!tokenResponse.access_token) { - throw new Error( - 'Something went wrong with the OIDP token request. No access token was returned. Response from OIDP: ' + - JSON.stringify(tokenResponse) - ) - } - - return fetchUserInfo(tokenResponse.access_token) - } - } -} diff --git a/packages/gateway/src/features/OIDPUserInfo/schema.graphql b/packages/gateway/src/features/OIDPUserInfo/schema.graphql deleted file mode 100644 index a3d41fedbc..0000000000 --- a/packages/gateway/src/features/OIDPUserInfo/schema.graphql +++ /dev/null @@ -1,57 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at https://mozilla.org/MPL/2.0/. -# -# OpenCRVS is also distributed under the terms of the Civil Registration -# & Healthcare Disclaimer located at http://opencrvs.org/license. -# -# Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - -type OIDPUserAddress { - formatted: String - street_address: String - locality: String - region: String - postal_code: String - city: String - country: String -} - -type OIDPUserInfo { - sub: String! - name: String - given_name: String - family_name: String - middle_name: String - nickname: String - preferred_username: String - profile: String - picture: String - website: String - email: String - email_verified: Boolean - gender: String - birthdate: String - zoneinfo: String - locale: String - phone_number: String - phone_number_verified: Boolean - address: OIDPUserAddress - updated_at: Int -} - -type UserInfo { - oidpUserInfo: OIDPUserInfo - districtFhirId: String - stateFhirId: String - locationLevel3FhirId: String -} - -type Query { - getOIDPUserInfo( - code: String! - clientId: String! - redirectUri: String! - grantType: String - ): UserInfo -} diff --git a/packages/gateway/src/features/OIDPUserInfo/utils.ts b/packages/gateway/src/features/OIDPUserInfo/utils.ts deleted file mode 100644 index aa42fd4dae..0000000000 --- a/packages/gateway/src/features/OIDPUserInfo/utils.ts +++ /dev/null @@ -1,146 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import * as jwt from 'jsonwebtoken' -import * as jose from 'jose' -import fetch from '@gateway/fetch' -import { - OIDP_CLIENT_PRIVATE_KEY, - OIDP_JWT_AUD_CLAIM, - OIDP_TOKEN_URL, - OIDP_USERINFO_URL -} from '@gateway/constants' - -import { logger } from '@opencrvs/commons' -import { OIDPUserInfo } from './oidp-types' -import { Bundle, Location } from '@opencrvs/commons/types' -import { fetchFromHearth } from '@gateway/features/fhir/service' - -const TOKEN_GRANT_TYPE = 'authorization_code' -const CLIENT_ASSERTION_TYPE = - 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer' - -const JWT_ALG = 'RS256' -const JWT_EXPIRATION_TIME = '1h' - -export type FetchTokenProps = { - code: string - clientId: string - redirectUri: string - grantType?: string -} - -const searchLocationFromHearth = (name: string) => - fetchFromHearth>( - `/Location?${new URLSearchParams({ name, type: 'ADMIN_STRUCTURE' })}` - ) - -const findAdminStructureLocationWithName = async (name: string) => { - const fhirBundleLocations = await searchLocationFromHearth(name) - - if ((fhirBundleLocations.entry?.length ?? 0) > 1) { - throw new Error( - 'Multiple admin structure locations found with the same name' - ) - } - - if ((fhirBundleLocations.entry?.length ?? 0) === 0) { - logger.warn('No admin structure location found with the name: ' + name) - return null - } - - return fhirBundleLocations.entry?.[0].resource?.id -} - -const pickUserInfo = async (userInfo: OIDPUserInfo) => { - const stateFhirId = - userInfo.address?.country && - (await findAdminStructureLocationWithName(userInfo.address.country)) - - return { - oidpUserInfo: userInfo, - stateFhirId, - districtFhirId: - userInfo.address?.region && - (await findAdminStructureLocationWithName(userInfo.address.region)), - locationLevel3FhirId: - userInfo.address?.locality && - (await findAdminStructureLocationWithName(userInfo.address.locality)) - } -} - -export const fetchToken = async ({ - code, - clientId, - redirectUri, - grantType = TOKEN_GRANT_TYPE -}: FetchTokenProps) => { - const body = new URLSearchParams({ - code: code, - client_id: clientId, - redirect_uri: redirectUri, - grant_type: grantType, - client_assertion_type: CLIENT_ASSERTION_TYPE, - client_assertion: await generateSignedJwt(clientId) - }) - - const request = await fetch(OIDP_TOKEN_URL!, { - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded' - }, - body - }) - - const response = await request.json() - return response as { access_token?: string } -} - -export const fetchUserInfo = async (accessToken: string) => { - const request = await fetch(OIDP_USERINFO_URL!, { - headers: { - Authorization: 'Bearer ' + accessToken - } - }) - - const response = await request.text() - const decodedResponse = decodeUserInfoResponse(response) - - logger.info(`OIDP user info response succeeded`) - - return pickUserInfo(decodedResponse) -} - -const generateSignedJwt = async (clientId: string) => { - const header = { - alg: JWT_ALG, - typ: 'JWT' - } - - const payload = { - iss: clientId, - sub: clientId, - aud: OIDP_JWT_AUD_CLAIM - } - - const decodeKey = Buffer.from(OIDP_CLIENT_PRIVATE_KEY!, 'base64')?.toString() - const jwkObject = JSON.parse(decodeKey) - const privateKey = await jose.importJWK(jwkObject, JWT_ALG) - - return new jose.SignJWT(payload) - .setProtectedHeader(header) - .setIssuedAt() - .setExpirationTime(JWT_EXPIRATION_TIME) - .sign(privateKey) -} - -const decodeUserInfoResponse = (response: string) => { - return jwt.decode(response) as OIDPUserInfo -} diff --git a/packages/gateway/src/graphql/config.ts b/packages/gateway/src/graphql/config.ts index fa554e2e35..c0d94db2c8 100644 --- a/packages/gateway/src/graphql/config.ts +++ b/packages/gateway/src/graphql/config.ts @@ -31,7 +31,6 @@ import { searchTypeResolvers } from '@gateway/features/search/type-resolvers' import { resolvers as userRootResolvers } from '@gateway/features/user/root-resolvers' import { resolvers as correctionRootResolvers } from '@gateway/features/correction/root-resolvers' import { resolvers as bookmarkAdvancedSearchResolvers } from '@gateway/features/bookmarkAdvancedSearch/root-resolvers' -import { resolvers as OIDPUserInfoResolvers } from '@gateway/features/OIDPUserInfo/root-resolvers' import { ISystemModelData, IUserModelData, @@ -84,7 +83,6 @@ export const resolvers: StringIndexed = merge( correctionRootResolvers as IResolvers, integrationResolver as IResolvers, bookmarkAdvancedSearchResolvers as IResolvers, - OIDPUserInfoResolvers as IResolvers, { FieldValue: new GraphQLScalarType({ name: 'FieldValue', diff --git a/packages/gateway/src/graphql/index.graphql b/packages/gateway/src/graphql/index.graphql index ab8ca23a04..f9f8634bfd 100644 --- a/packages/gateway/src/graphql/index.graphql +++ b/packages/gateway/src/graphql/index.graphql @@ -19,7 +19,6 @@ # import Mutation.* from '../features/systems/schema.graphql' # import Query.* from '../features/systems/schema.graphql' # import Mutation from '../features/bookmarkAdvancedSearch/schema.graphql' -# import Query.* from '../features/OIDPUserInfo/schema.graphql' # import * from 'common.graphql' # TODO diff --git a/packages/gateway/src/graphql/schema.d.ts b/packages/gateway/src/graphql/schema.d.ts index a02daf1f50..6807e1a9b8 100644 --- a/packages/gateway/src/graphql/schema.d.ts +++ b/packages/gateway/src/graphql/schema.d.ts @@ -50,7 +50,6 @@ export interface GQLQuery { getEventsWithProgress?: GQLEventProgressResultSet getSystemRoles?: Array fetchSystem?: GQLSystem - getOIDPUserInfo?: GQLUserInfo } export interface GQLMutation { @@ -509,13 +508,6 @@ export interface GQLSystem { settings?: GQLSystemSettings } -export interface GQLUserInfo { - oidpUserInfo?: GQLOIDPUserInfo - districtFhirId?: string - stateFhirId?: string - locationLevel3FhirId?: string -} - export interface GQLCorrectionInput { requester: string requesterOther?: string @@ -1019,29 +1011,6 @@ export interface GQLSystemSettings { openIdProviderClaims?: string } -export interface GQLOIDPUserInfo { - sub: string - name?: string - given_name?: string - family_name?: string - middle_name?: string - nickname?: string - preferred_username?: string - profile?: string - picture?: string - website?: string - email?: string - email_verified?: boolean - gender?: string - birthdate?: string - zoneinfo?: string - locale?: string - phone_number?: string - phone_number_verified?: boolean - address?: GQLOIDPUserAddress - updated_at?: number -} - export interface GQLAttachmentInput { _fhirID?: string contentType?: string @@ -1516,16 +1485,6 @@ export interface GQLWebhookPermission { permissions: Array } -export interface GQLOIDPUserAddress { - formatted?: string - street_address?: string - locality?: string - region?: string - postal_code?: string - city?: string - country?: string -} - export const enum GQLAttachmentInputStatus { approved = 'approved', validated = 'validated', @@ -1748,7 +1707,6 @@ export interface GQLResolver { EventProgressResultSet?: GQLEventProgressResultSetTypeResolver SystemRole?: GQLSystemRoleTypeResolver System?: GQLSystemTypeResolver - UserInfo?: GQLUserInfoTypeResolver CreatedIds?: GQLCreatedIdsTypeResolver Reinstated?: GQLReinstatedTypeResolver Avatar?: GQLAvatarTypeResolver @@ -1791,7 +1749,6 @@ export interface GQLResolver { EventProgressSet?: GQLEventProgressSetTypeResolver SystemSettings?: GQLSystemSettingsTypeResolver - OIDPUserInfo?: GQLOIDPUserInfoTypeResolver AssignmentData?: GQLAssignmentDataTypeResolver RegWorkflow?: GQLRegWorkflowTypeResolver Certificate?: GQLCertificateTypeResolver @@ -1815,7 +1772,6 @@ export interface GQLResolver { MarriageEventSearchSet?: GQLMarriageEventSearchSetTypeResolver EventProgressData?: GQLEventProgressDataTypeResolver WebhookPermission?: GQLWebhookPermissionTypeResolver - OIDPUserAddress?: GQLOIDPUserAddressTypeResolver FieldValue?: GraphQLScalarType AuditLogItemBase?: { __resolveType: GQLAuditLogItemBaseTypeResolver @@ -1861,7 +1817,6 @@ export interface GQLQueryTypeResolver { getEventsWithProgress?: QueryToGetEventsWithProgressResolver getSystemRoles?: QueryToGetSystemRolesResolver fetchSystem?: QueryToFetchSystemResolver - getOIDPUserInfo?: QueryToGetOIDPUserInfoResolver } export interface QueryToSendNotificationToAllUsersArgs { @@ -2460,21 +2415,6 @@ export interface QueryToFetchSystemResolver { ): TResult } -export interface QueryToGetOIDPUserInfoArgs { - code: string - clientId: string - redirectUri: string - grantType?: string -} -export interface QueryToGetOIDPUserInfoResolver { - ( - parent: TParent, - args: QueryToGetOIDPUserInfoArgs, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - export interface GQLMutationTypeResolver { requestRegistrationCorrection?: MutationToRequestRegistrationCorrectionResolver rejectRegistrationCorrection?: MutationToRejectRegistrationCorrectionResolver @@ -5470,55 +5410,6 @@ export interface SystemToSettingsResolver { ): TResult } -export interface GQLUserInfoTypeResolver { - oidpUserInfo?: UserInfoToOidpUserInfoResolver - districtFhirId?: UserInfoToDistrictFhirIdResolver - stateFhirId?: UserInfoToStateFhirIdResolver - locationLevel3FhirId?: UserInfoToLocationLevel3FhirIdResolver -} - -export interface UserInfoToOidpUserInfoResolver { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface UserInfoToDistrictFhirIdResolver< - TParent = any, - TResult = any -> { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface UserInfoToStateFhirIdResolver { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface UserInfoToLocationLevel3FhirIdResolver< - TParent = any, - TResult = any -> { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - export interface GQLCreatedIdsTypeResolver { compositionId?: CreatedIdsToCompositionIdResolver trackingId?: CreatedIdsToTrackingIdResolver @@ -7866,233 +7757,6 @@ export interface SystemSettingsToOpenIdProviderClaimsResolver< ): TResult } -export interface GQLOIDPUserInfoTypeResolver { - sub?: OIDPUserInfoToSubResolver - name?: OIDPUserInfoToNameResolver - given_name?: OIDPUserInfoToGiven_nameResolver - family_name?: OIDPUserInfoToFamily_nameResolver - middle_name?: OIDPUserInfoToMiddle_nameResolver - nickname?: OIDPUserInfoToNicknameResolver - preferred_username?: OIDPUserInfoToPreferred_usernameResolver - profile?: OIDPUserInfoToProfileResolver - picture?: OIDPUserInfoToPictureResolver - website?: OIDPUserInfoToWebsiteResolver - email?: OIDPUserInfoToEmailResolver - email_verified?: OIDPUserInfoToEmail_verifiedResolver - gender?: OIDPUserInfoToGenderResolver - birthdate?: OIDPUserInfoToBirthdateResolver - zoneinfo?: OIDPUserInfoToZoneinfoResolver - locale?: OIDPUserInfoToLocaleResolver - phone_number?: OIDPUserInfoToPhone_numberResolver - phone_number_verified?: OIDPUserInfoToPhone_number_verifiedResolver - address?: OIDPUserInfoToAddressResolver - updated_at?: OIDPUserInfoToUpdated_atResolver -} - -export interface OIDPUserInfoToSubResolver { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserInfoToNameResolver { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserInfoToGiven_nameResolver< - TParent = any, - TResult = any -> { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserInfoToFamily_nameResolver< - TParent = any, - TResult = any -> { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserInfoToMiddle_nameResolver< - TParent = any, - TResult = any -> { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserInfoToNicknameResolver { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserInfoToPreferred_usernameResolver< - TParent = any, - TResult = any -> { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserInfoToProfileResolver { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserInfoToPictureResolver { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserInfoToWebsiteResolver { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserInfoToEmailResolver { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserInfoToEmail_verifiedResolver< - TParent = any, - TResult = any -> { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserInfoToGenderResolver { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserInfoToBirthdateResolver { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserInfoToZoneinfoResolver { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserInfoToLocaleResolver { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserInfoToPhone_numberResolver< - TParent = any, - TResult = any -> { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserInfoToPhone_number_verifiedResolver< - TParent = any, - TResult = any -> { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserInfoToAddressResolver { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserInfoToUpdated_atResolver< - TParent = any, - TResult = any -> { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - export interface GQLAssignmentDataTypeResolver { practitionerId?: AssignmentDataToPractitionerIdResolver firstName?: AssignmentDataToFirstNameResolver @@ -10533,94 +10197,6 @@ export interface WebhookPermissionToPermissionsResolver< ): TResult } -export interface GQLOIDPUserAddressTypeResolver { - formatted?: OIDPUserAddressToFormattedResolver - street_address?: OIDPUserAddressToStreet_addressResolver - locality?: OIDPUserAddressToLocalityResolver - region?: OIDPUserAddressToRegionResolver - postal_code?: OIDPUserAddressToPostal_codeResolver - city?: OIDPUserAddressToCityResolver - country?: OIDPUserAddressToCountryResolver -} - -export interface OIDPUserAddressToFormattedResolver< - TParent = any, - TResult = any -> { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserAddressToStreet_addressResolver< - TParent = any, - TResult = any -> { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserAddressToLocalityResolver< - TParent = any, - TResult = any -> { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserAddressToRegionResolver { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserAddressToPostal_codeResolver< - TParent = any, - TResult = any -> { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserAddressToCityResolver { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - -export interface OIDPUserAddressToCountryResolver< - TParent = any, - TResult = any -> { - ( - parent: TParent, - args: {}, - context: Context, - info: GraphQLResolveInfo - ): TResult -} - export interface GQLAuditLogItemBaseTypeResolver { (parent: TParent, context: Context, info: GraphQLResolveInfo): | 'UserAuditLogItemWithComposition' diff --git a/packages/gateway/src/graphql/schema.graphql b/packages/gateway/src/graphql/schema.graphql index ec49396ea5..0dbf8e1d4b 100644 --- a/packages/gateway/src/graphql/schema.graphql +++ b/packages/gateway/src/graphql/schema.graphql @@ -147,12 +147,6 @@ type Query { sortOrder: String ): [SystemRole!] fetchSystem(clientId: ID!): System - getOIDPUserInfo( - code: String! - clientId: String! - redirectUri: String! - grantType: String - ): UserInfo } type Mutation { @@ -635,13 +629,6 @@ type System { settings: SystemSettings } -type UserInfo { - oidpUserInfo: OIDPUserInfo - districtFhirId: String - stateFhirId: String - locationLevel3FhirId: String -} - input CorrectionInput { requester: String! requesterOther: String @@ -1121,29 +1108,6 @@ type SystemSettings { openIdProviderClaims: String } -type OIDPUserInfo { - sub: String! - name: String - given_name: String - family_name: String - middle_name: String - nickname: String - preferred_username: String - profile: String - picture: String - website: String - email: String - email_verified: Boolean - gender: String - birthdate: String - zoneinfo: String - locale: String - phone_number: String - phone_number_verified: Boolean - address: OIDPUserAddress - updated_at: Int -} - input AttachmentInput { _fhirID: ID contentType: String @@ -1617,16 +1581,6 @@ type WebhookPermission { permissions: [String!]! } -type OIDPUserAddress { - formatted: String - street_address: String - locality: String - region: String - postal_code: String - city: String - country: String -} - enum AttachmentInputStatus { approved validated diff --git a/packages/gateway/test/setupJest.ts b/packages/gateway/test/setupJest.ts index 12052b031d..001598ad33 100644 --- a/packages/gateway/test/setupJest.ts +++ b/packages/gateway/test/setupJest.ts @@ -17,12 +17,3 @@ jest.setMock('node-fetch', { default: fetch, Headers: f.Headers }) jest.setMock('@opencrvs/commons/monitoring') process.env.CERT_PUBLIC_KEY_PATH = join(__dirname, './cert.key.pub') -process.env.NATIONAL_ID_OIDP_CLIENT_PRIVATE_KEY = - 'ewogICAgInAiOiAiMVRMMlRPOWxNZnZOWThzeWVReFFrd3F1RThfdll5bV85ZS1yUkxRaV9reWJvLUMwUXJYVklQRFNfN2laV3I4WFB0MGlMWnJkemtjSzU0dGtKWGRkYWk3bEhxM3VyNndLU09uUHVPMURNS0stLXlNR3lCd0RfazdTbUdLUDlsTml3Q0pDT1Q2dDdjWEM1SnBEaVBNc05HQWNEUDZyRGFQQ2tlMzZUcjV5LW5NIiwKICAgICJrdHkiOiAiUlNBIiwKICAgICJxIjogIng4U1FwSHc2UlFnWmxHUC1EdWpiS1pRcUZxczAxU0ZsczFQa1lya25yM01rV1FrUFVGVDlubW5CbTlHWlVwbUV0TU9WZDc4SWVfdHV1UGZFVFo1SWYwTmt0bTNJdS1Pcm9jQzJBU3IzQnF0dUZyUnhUWTRJbnVBVnhHd0VuV0Frd1ZWR1dJQklEVkhSeHhGblAwZUo0YWNmVGVDcWs4QTE1cFRhOUo2MmY4ayIsCiAgICAiZCI6ICJubms3Q2RtT2hucVdyMTU1cW5hc25PY2pPamYyVEJLNlVpYUJOcWw1S1FBMmlJSnJGa0F1ZXFYcmwzM1J0eVgtZFFtOU1NTnhNLUYwMUpac3REME50eW1ZdXlzOVFMbGhKbld2RHlGLXlmMHJHOFJPVHROQkNuZjgxNUE2STQ1UzhqVUlXMGI1dl9lQlAxY1lKdWRLSW5QNlY0NVRZUEFlSjhKQ2hPeFJ2RlJHX2loOFVRaTdDZFZWNXFvVUVpX1lOWXNleTc1cTZpTFRiRVFFOExsNE9lMnRFNDMxTnltMTBaa185R2FNVEp0SU1YMm1iMW01blFfMTZmRC1ZNDZvWDlucW9zUUtUZ19uYmRoUFU3QWQwNW5MSjZFRER0X0JIbDNfc0d1blhrN3BhMjFTN1hfRjBQT0JrdG42dlNUV0FEZjQtM2pXaFNHa21yX3pyR3hLc1EiLAogICAgImUiOiAiQVFBQiIsCiAgICAicWkiOiAiRlpCaE55Uk5nMVhJVW44d1VFVGRCSEh4Qmx0Wk9tbDJhUzNXYlVZb3VuQlN1NDhoVk9BOGpWdFJFaWFBc25xUkxtaGNIN3V0aWVCTHBKazZsZ2pyM3RINnh3WklOSDRCb1NBYnRyUW5DMXd1ZE1fa1FCX1hpRk4tSFhPX0oyU2thV05nb19JSFFING1udXZnRUkxUEdpZGdwZzJ2NnJ6V3R3ZW5rbXhHblJnIiwKICAgICJkcCI6ICJNYkhMVDJ1TnZ2VGVqeUJTQjMwald1TG1hSl9UUU4zLWJLa00xdHJXUFVoR0R4RFZjNmRHb29MXzY3TnZxNE5YTzhQM3I0R2xxZXROVTJOZVdJMVdMT1g1YWdsSTFaSFlZOTU4R0xMVk1vVDgxelQyNDdZRUNFYl9ONTNoeUp6dks3SFFsZDlTVTFZQmM1LXhsajU0VTAwRHZOT3ZzMkkwZkNkb2JPcGZpcGsiLAogICAgImFsZyI6ICJSUzI1NiIsCiAgICAiZHEiOiAiYlJkRjJkMVJRTk5zaktHU1l2ZjhmeGNfYU1PMEJWUElvd2FFS1BsdDE1MHNVMGJrU3YwdXh1eF80eVN4OHU2TkR0M2o2TkcwdzJnS0RnNlg3NzhwWGY0aXFKRUpWcm04eDRkaW5QNm1pY2ppUkpuamFmUFBkMXR0NTZjSldodmYxb2hIOHhxU3ZsdFpFTG5MUlQ0LTZMQ0lJdEkydEpyNWxHTGpzMFJjNnlrIiwKICAgICJuIjogInBsNVE4QWVsT1ozWERyc093ems5T0ExNzR1WEF3ZnpxOW1NVXB2cVEwMC1sMFlKWGljZUlfWU13ZVJnS0tGTnpEMklEajhGNnJqaDh1THEwdjhiTE5oLWQzUEFwRHBTMTVOc3ZhN2U4VFZNR1paLVZJVDVKVGZqMzZsNWR2Q1oxa21MRUJ2ZjJhbzFHOVowMXU0NDNMZDRueEgzNHpkLTlUZU5VRXp4ejAweXUtOFBrRkJ5OGNySGVCR2JmcUlTLV9nbVJ6ZEIwclFQM29GT3hiNWJfa01WYUR6Wm5YSFVVemFIdDRNOEcxcHF2QjJOZzQzUDQ0d2NJME1YMVNHVkRQbGMtZVBfNjFjNW5qTzhoVnhnbUZzOUt0WVR5a0t3OXhsYUh6U1dCbG9ObVZFeG1Yd1ItckVzSTdJczdxOUpWTjdEVzNaNmYzRnk3NVpnN21rZXhTdyIKfQ==' -process.env.NATIONAL_ID_OIDP_BASE_URL = 'http://localhost:27501/v1/oid/' -process.env.NATIONAL_ID_OIDP_TOKEN_URL = - 'http://localhost:27502/v1/esignet/oauth/v2/token' -process.env.NATIONAL_ID_OIDP_USERINFO_URL = - 'http://localhost:27502/v1/esignet/oidc/v2/userinfo' -process.env.NATIONAL_ID_OIDP_JWT_AUD_CLAIM = - 'http://localhost:27501/v1/idp/oauth/token' diff --git a/packages/user-mgnt/src/constants.ts b/packages/user-mgnt/src/constants.ts index 2136746db3..89e256a734 100644 --- a/packages/user-mgnt/src/constants.ts +++ b/packages/user-mgnt/src/constants.ts @@ -26,10 +26,3 @@ export const RECORD_SEARCH_QUOTA = env.RECORD_SEARCH_QUOTA export const FHIR_URL = env.FHIR_URL export const METRICS_URL = env.METRICS_URL - -export const NATIONAL_ID_OIDP_BASE_URL = env.NATIONAL_ID_OIDP_BASE_URL -export const NATIONAL_ID_OIDP_CLIENT_ID = env.NATIONAL_ID_OIDP_CLIENT_ID -export const NATIONAL_ID_OIDP_ESSENTIAL_CLAIMS = - env.NATIONAL_ID_OIDP_ESSENTIAL_CLAIMS -export const NATIONAL_ID_OIDP_VOLUNTARY_CLAIMS = - env.NATIONAL_ID_OIDP_VOLUNTARY_CLAIMS diff --git a/packages/user-mgnt/src/environment.ts b/packages/user-mgnt/src/environment.ts index 8c9b5c22db..1d6026efda 100644 --- a/packages/user-mgnt/src/environment.ts +++ b/packages/user-mgnt/src/environment.ts @@ -24,10 +24,5 @@ export const env = cleanEnv(process.env, { RECORD_SEARCH_QUOTA: num({ default: 2000 }), FHIR_URL: url({ devDefault: 'http://localhost:3447/fhir' }), - METRICS_URL: url({ devDefault: 'http://localhost:1050' }), - - NATIONAL_ID_OIDP_BASE_URL: str({ default: undefined }), - NATIONAL_ID_OIDP_CLIENT_ID: str({ default: undefined }), - NATIONAL_ID_OIDP_ESSENTIAL_CLAIMS: str({ default: undefined }), - NATIONAL_ID_OIDP_VOLUNTARY_CLAIMS: str({ default: undefined }) + METRICS_URL: url({ devDefault: 'http://localhost:1050' }) }) diff --git a/packages/user-mgnt/src/utils/system.ts b/packages/user-mgnt/src/utils/system.ts index 00620af238..ef3a21084c 100644 --- a/packages/user-mgnt/src/utils/system.ts +++ b/packages/user-mgnt/src/utils/system.ts @@ -8,12 +8,6 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import { - NATIONAL_ID_OIDP_CLIENT_ID, - NATIONAL_ID_OIDP_BASE_URL, - NATIONAL_ID_OIDP_ESSENTIAL_CLAIMS, - NATIONAL_ID_OIDP_VOLUNTARY_CLAIMS -} from '@user-mgnt/constants' import { ISystemModel } from '@user-mgnt/model/system' import { pick } from 'lodash' import { Types } from 'mongoose' @@ -33,30 +27,12 @@ export const integratingSystemTypes = { type MongooseQueriedSystem = ISystemModel & { _id: Types.ObjectId } const pickSettings = (system: MongooseQueriedSystem) => { - const openIdProviderClaims = convertClaimsToUserInfoClaims({ - openIdProviderEssentialClaims: NATIONAL_ID_OIDP_ESSENTIAL_CLAIMS, - openIdProviderVoluntaryClaims: NATIONAL_ID_OIDP_VOLUNTARY_CLAIMS - }) - - const openIdConnectUrl = - system.type === 'NATIONAL_ID' && - NATIONAL_ID_OIDP_CLIENT_ID && - NATIONAL_ID_OIDP_BASE_URL && - (NATIONAL_ID_OIDP_ESSENTIAL_CLAIMS || NATIONAL_ID_OIDP_VOLUNTARY_CLAIMS) - ? { - openIdProviderBaseUrl: NATIONAL_ID_OIDP_BASE_URL, - openIdProviderClientId: NATIONAL_ID_OIDP_CLIENT_ID, - openIdProviderClaims - } - : {} - const webhook = system.settings.webhook.map((ite) => ({ event: ite.event, permissions: ite.permissions })) return { - ...openIdConnectUrl, webhook, dailyQuota: system.settings.dailyQuota } @@ -80,26 +56,3 @@ export const pickSystem = (system: MongooseQueriedSystem) => { settings: pickSettings(system) } } - -const convertClaimsToUserInfoClaims = ({ - openIdProviderEssentialClaims, - openIdProviderVoluntaryClaims -}: { - openIdProviderEssentialClaims?: string - openIdProviderVoluntaryClaims?: string -}) => { - const userinfo: Record = {} - - for (const claim of (openIdProviderVoluntaryClaims ?? '').split(',')) { - userinfo[claim] = { essential: false } - } - - for (const claim of (openIdProviderEssentialClaims ?? '').split(',')) { - userinfo[claim] = { essential: true } - } - - return JSON.stringify({ - userinfo, - id_token: {} - }) -}