diff --git a/ios/Inji.xcodeproj/project.pbxproj b/ios/Inji.xcodeproj/project.pbxproj index f67e4d5971..d9bcc4cd82 100644 --- a/ios/Inji.xcodeproj/project.pbxproj +++ b/ios/Inji.xcodeproj/project.pbxproj @@ -557,4 +557,4 @@ /* End XCConfigurationList section */ }; rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; -} +} \ No newline at end of file diff --git a/machines/store.typegen.ts b/machines/store.typegen.ts index 804f958af5..fce816aaba 100644 --- a/machines/store.typegen.ts +++ b/machines/store.typegen.ts @@ -1,54 +1,5 @@ +// This file was automatically generated. Edits will be overwritten -<<<<<<< HEAD - // This file was automatically generated. Edits will be overwritten - - export interface Typegen0 { - '@@xstate/typegen': true; - internalEvents: { - "done.invoke._store": { type: "done.invoke._store"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; -"done.invoke.store.resettingStorage:invocation[0]": { type: "done.invoke.store.resettingStorage:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; -"error.platform._store": { type: "error.platform._store"; data: unknown }; -"xstate.init": { type: "xstate.init" }; - }; - invokeSrcNameMap: { - "checkStorageInitialisedOrNot": "done.invoke.store.checkStorageInitialisation:invocation[0]"; -"clear": "done.invoke.store.resettingStorage:invocation[0]"; -"generateEncryptionKey": "done.invoke.store.generatingEncryptionKey:invocation[0]"; -"getEncryptionKey": "done.invoke.store.gettingEncryptionKey:invocation[0]"; -"hasAndroidEncryptionKey": "done.invoke.store.checkEncryptionKey:invocation[0]"; -"store": "done.invoke._store"; - }; - missingImplementations: { - actions: "logKey"; - delays: never; - guards: never; - services: never; - }; - eventsCausingActions: { - "forwardStoreRequest": "APPEND" | "CLEAR" | "GET" | "PREPEND" | "REMOVE" | "REMOVE_ITEMS" | "REMOVE_VC_METADATA" | "SET" | "UPDATE"; -"logKey": "KEY_RECEIVED"; -"notifyParent": "KEY_RECEIVED" | "READY" | "done.invoke.store.resettingStorage:invocation[0]"; -"setEncryptionKey": "KEY_RECEIVED"; - }; - eventsCausingDelays: { - - }; - eventsCausingGuards: { - "isCustomSecureKeystore": "KEY_RECEIVED"; - }; - eventsCausingServices: { - "checkStorageInitialisedOrNot": "ERROR"; -"clear": "KEY_RECEIVED"; -"generateEncryptionKey": "ERROR" | "IGNORE" | "READY"; -"getEncryptionKey": "TRY_AGAIN"; -"hasAndroidEncryptionKey": never; -"store": "KEY_RECEIVED" | "READY" | "done.invoke.store.resettingStorage:invocation[0]"; - }; - matchesStates: "checkEncryptionKey" | "checkStorageInitialisation" | "failedReadingKey" | "generatingEncryptionKey" | "gettingEncryptionKey" | "ready" | "resettingStorage"; - tags: never; - } - -======= export interface Typegen0 { '@@xstate/typegen': true; internalEvents: { @@ -95,9 +46,7 @@ export interface Typegen0 { | 'KEY_RECEIVED' | 'READY' | 'done.invoke.store.resettingStorage:invocation[0]'; - resetIsTamperedVc: 'RESET_IS_TAMPERED'; setEncryptionKey: 'KEY_RECEIVED'; - setIsTamperedVc: 'TAMPERED_VC'; }; eventsCausingDelays: {}; eventsCausingGuards: { @@ -124,4 +73,3 @@ export interface Typegen0 { | 'resettingStorage'; tags: never; } ->>>>>>> 5b53b069 (refactor(INJI-205): Check Internet before OIDC AuthZ) diff --git a/screens/Home/MyVcs/AddVcModal.tsx b/screens/Home/MyVcs/AddVcModal.tsx index f67824bbb2..0bd2ba78be 100644 --- a/screens/Home/MyVcs/AddVcModal.tsx +++ b/screens/Home/MyVcs/AddVcModal.tsx @@ -4,19 +4,32 @@ import { AddVcModalProps, useAddVcModal } from './AddVcModalController'; import { OtpVerificationModal } from './OtpVerificationModal'; import { IdInputModal } from './IdInputModal'; import { useTranslation } from 'react-i18next'; +import { GET_INDIVIDUAL_ID } from '../../../shared/constants'; export const AddVcModal: React.FC = (props) => { const { t } = useTranslation('AddVcModal'); const controller = useAddVcModal(props); + const shouldShowAddVcModal = () => { + if (controller.isRequestingCredential) { + GET_INDIVIDUAL_ID({id: '', idType: 'UIN'}); + } + return ( + !controller.isAcceptingOtpInput && !controller.isRequestingCredential + ); + }; + + const dismissIdInputModal = () => { + GET_INDIVIDUAL_ID({id: '', idType: 'UIN'}); + controller.DISMISS(); + }; + return ( diff --git a/screens/Home/MyVcs/AddVcModalMachine.ts b/screens/Home/MyVcs/AddVcModalMachine.ts index 31d399a8a5..4097ba6617 100644 --- a/screens/Home/MyVcs/AddVcModalMachine.ts +++ b/screens/Home/MyVcs/AddVcModalMachine.ts @@ -57,6 +57,9 @@ export const AddVcModalMachine = INPUT_ID: { actions: 'setId', }, + SELECT_ID_TYPE: { + actions: ['clearIdError', 'setIdType'], + }, }, states: { acceptingIdInput: { diff --git a/screens/Home/MyVcs/GetVcModalMachine.ts b/screens/Home/MyVcs/GetVcModalMachine.ts index 76f1f52f67..1f3f382c7d 100644 --- a/screens/Home/MyVcs/GetVcModalMachine.ts +++ b/screens/Home/MyVcs/GetVcModalMachine.ts @@ -1,4 +1,4 @@ -import { TextInput } from 'react-native'; +import {TextInput} from 'react-native'; import { assign, ErrorPlatformEvent, @@ -7,11 +7,11 @@ import { sendParent, StateFrom, } from 'xstate'; -import { createModel } from 'xstate/lib/model'; -import { BackendResponseError, request } from '../../../shared/request'; +import {createModel} from 'xstate/lib/model'; +import {BackendResponseError, request} from '../../../shared/request'; import i18n from '../../../i18n'; -import { AddVcModalMachine } from './AddVcModalMachine'; -import { GET_INDIVIDUAL_ID } from '../../../shared/constants'; +import {AddVcModalMachine} from './AddVcModalMachine'; +import {GET_INDIVIDUAL_ID, IndividualId} from '../../../shared/constants'; const model = createModel( { @@ -26,16 +26,16 @@ const model = createModel( }, { events: { - INPUT_ID: (id: string) => ({ id }), - INPUT_OTP: (otp: string) => ({ otp }), + INPUT_ID: (id: string) => ({id}), + INPUT_OTP: (otp: string) => ({otp}), VALIDATE_INPUT: () => ({}), ACTIVATE_ICON_COLOR: () => ({}), DEACTIVATE_ICON_COLOR: () => ({}), - READY: (idInputRef: TextInput) => ({ idInputRef }), + READY: (idInputRef: TextInput) => ({idInputRef}), DISMISS: () => ({}), - GOT_ID: (id: string) => ({ id }), + GOT_ID: (id: string) => ({id}), }, - } + }, ); export const GetVcModalEvents = model.events; @@ -222,13 +222,14 @@ export const GetVcModalMachine = transactionId: () => String(new Date().valueOf()).substring(3, 13), }), - setIndividualId: (_context, event) => - GET_INDIVIDUAL_ID((event as DoneInvokeEvent).data), + setIndividualId: (_context, event) => { + GET_INDIVIDUAL_ID((event as DoneInvokeEvent).data); + }, setIdBackendError: assign({ idError: (context, event) => { if ((event as ErrorPlatformEvent).data == 'IDA-MLC-001') { - return i18n.t('errors.backend.timeOut', { ns: 'GetVcModal' }); + return i18n.t('errors.backend.timeOut', {ns: 'GetVcModal'}); } const message = (event as ErrorPlatformEvent).data.message; @@ -246,15 +247,15 @@ export const GetVcModalMachine = }, }), - clearIdError: model.assign({ idError: '' }), + clearIdError: model.assign({idError: ''}), setIdErrorEmpty: model.assign({ - idError: () => i18n.t('errors.input.empty', { ns: 'GetVcModal' }), + idError: () => i18n.t('errors.input.empty', {ns: 'GetVcModal'}), }), setIdErrorWrongFormat: model.assign({ idError: () => - i18n.t('errors.input.invalidFormat', { ns: 'GetVcModal' }), + i18n.t('errors.input.invalidFormat', {ns: 'GetVcModal'}), }), setOtpError: assign({ @@ -282,17 +283,17 @@ export const GetVcModalMachine = }, }), - clearOtp: assign({ otp: '' }), + clearOtp: assign({otp: ''}), - setIconColorActivate: assign({ iconColor: true }), + setIconColorActivate: assign({iconColor: true}), - setIconColorDeactivate: assign({ iconColor: false }), + setIconColorDeactivate: assign({iconColor: false}), - focusInput: (context) => context.idInputRef.focus(), + focusInput: context => context.idInputRef.focus(), }, services: { - requestOtp: async (context) => { + requestOtp: async context => { return await request( 'POST', '/residentmobileapp/req/individualId/otp', @@ -304,11 +305,11 @@ export const GetVcModalMachine = requestTime: String(new Date().toISOString()), transactionID: context.transactionId, version: '1.0', - } + }, ); }, - requestingUinVid: async (context) => { + requestingUinVid: async context => { const response = await request( 'POST', '/residentmobileapp/aid/get-individual-id', @@ -316,23 +317,26 @@ export const GetVcModalMachine = aid: context.id, otp: context.otp, transactionID: context.transactionId, - } + }, ); - return response.response.individualId; + return { + id: response.response.individualId, + idType: response.response.individualIdType || 'UIN', + }; }, }, guards: { - isEmptyId: ({ id }) => !id || !id.length, + isEmptyId: ({id}) => !id || !id.length, - isWrongIdFormat: ({ id }) => !/^\d{14,29}$/.test(id), + isWrongIdFormat: ({id}) => !/^\d{14,29}$/.test(id), isIdInvalid: (_context, event: unknown) => ['RES-SER-449', 'IDA-MLC-001'].includes( - (event as BackendResponseError).name + (event as BackendResponseError).name, ), }, - } + }, ); type State = StateFrom; diff --git a/screens/Home/MyVcs/IdInputModal.tsx b/screens/Home/MyVcs/IdInputModal.tsx index 866990855c..2eff40a0fb 100644 --- a/screens/Home/MyVcs/IdInputModal.tsx +++ b/screens/Home/MyVcs/IdInputModal.tsx @@ -23,12 +23,13 @@ export const IdInputModal: React.FC = props => { const controller = useIdInputModal(props); const setIndividualID = () => { - controller.INPUT_ID(individualId); + controller.INPUT_ID(individualId.id); + controller.SELECT_ID_TYPE(individualId.idType); }; const dismissInput = () => { props.onDismiss(); - GET_INDIVIDUAL_ID(''); + GET_INDIVIDUAL_ID({id: '', idType: 'UIN'}); }; const inputLabel = t('enterId', {idType: controller.idType}); diff --git a/screens/Home/MyVcsTab.tsx b/screens/Home/MyVcsTab.tsx index 9908ca27e7..16df6db75f 100644 --- a/screens/Home/MyVcsTab.tsx +++ b/screens/Home/MyVcsTab.tsx @@ -36,7 +36,7 @@ export const MyVcsTab: React.FC = props => { }; const clearIndividualId = () => { - GET_INDIVIDUAL_ID(''); + GET_INDIVIDUAL_ID({id: '', idType: 'UIN'}); }; useEffect(() => { diff --git a/shared/constants.ts b/shared/constants.ts index cce9377d04..09b62c6f7e 100644 --- a/shared/constants.ts +++ b/shared/constants.ts @@ -6,6 +6,7 @@ import { DEBUG_MODE, } from 'react-native-dotenv'; import {Argon2iConfig} from './commonUtil'; +import {VcIdType} from '../types/vc'; export let MIMOTO_BASE_URL = MIMOTO_HOST; export let ESIGNET_BASE_URL = ESIGNET_HOST; @@ -20,10 +21,10 @@ export const RECEIVED_VCS_STORE_KEY = 'receivedVCs'; export const MY_LOGIN_STORE_KEY = 'myLogins'; -export let individualId = ''; +export let individualId = {id: '', idType: 'UIN' as VcIdType}; -export const GET_INDIVIDUAL_ID = (ind_Id: string) => { - individualId = ind_Id; +export const GET_INDIVIDUAL_ID = (currentIndividualId: IndividualId) => { + individualId = currentIndividualId; }; export const ACTIVITY_LOG_STORE_KEY = 'activityLog'; @@ -69,5 +70,9 @@ export const argon2iConfigForUinVid: Argon2iConfig = { export const argon2iSalt = '1234567891011121314151617181920212223242526272829303132333435363'; +export type IndividualId = { + id: string; + idType: VcIdType; +}; export const NETWORK_REQUEST_FAILED = 'Network request failed'; export const REQUEST_TIMEOUT = 'request timedout';