Inji 360 Support different host for mimoto and esignet (#829)

* feat(INJI-360): Add esignet host as env variable and use in QR login flow.

* feat(INJI-360): Fix compile error.

* chore(INJI-360): support esignet and mimoto base url in workflows for Android and iOS

* chore(INJI-360): add ESIGNET_HOST in Fastfile for android.

* chore(INJI-360): remove unnecessary env variables from ios build workflow.
This commit is contained in:
Swati Goel
2023-09-13 11:24:21 +05:30
committed by GitHub
parent ceb89befe3
commit 27efaf6cdd
12 changed files with 65 additions and 31 deletions

6
.env
View File

@@ -1,9 +1,13 @@
# after making changes to the env file, ensure to start the bundler (or the project) with a --reset-cache
# eg . npm build android:newlogic --reset-cache
MIMOTO_HOST=https://api.qa-inji.mosip.net
#MIMOTO_HOST=http://mock.mimoto.newlogic.dev
MIMOTO_HOST=https://api.qa-inji.mosip.net
ESIGNET_HOST=https://api.qa-inji.mosip.net
GOOGLE_NEARBY_MESSAGES_API_KEY=
#Application Theme can be ( orange | purple )
APPLICATION_THEME=orange

View File

@@ -1,7 +1,8 @@
name: Android Beta Build
env:
backendServiceDefaultUrl: https://api.sandbox.mosip.net
mimotoBackendServiceDefaultUrl: https://api.sandbox.mosip.net
esignetBackendServiceDefaultUrl: https://api.sandbox.mosip.net
on:
workflow_dispatch:
@@ -21,8 +22,13 @@ on:
required: true
default: False
type: string
backendServiceUrl:
description: 'Backend service URL'
mimotoBackendServiceUrl:
description: 'Mimoto backend service URL'
required: true
default: 'https://api.sandbox.mosip.net'
type: string
esignetBackendServiceUrl:
description: 'Esignet backend service URL'
required: true
default: 'https://api.sandbox.mosip.net'
type: string
@@ -133,7 +139,8 @@ jobs:
cd android/scripts
./beta-build.sh
env:
MIMOTO_HOST: ${{ github.event.inputs.backendServiceUrl }}
MIMOTO_HOST: ${{ github.event.inputs.mimotoBackendServiceUrl }}
ESIGNET_HOST: ${{ github.event.inputs.esignetBackendServiceUrl }}
APPLICATION_THEME: ${{ github.event.inputs.theme }}
RELEASE_KEYSTORE_ALIAS: androidreleasekey
RELEASE_KEYSTORE_PASSWORD: '${{secrets.INJI_ANDROID_RELEASE_STOREPASS}}'

View File

@@ -1,13 +1,19 @@
name: Android Internal Build
env:
backendServiceDefaultUrl: https://api.sandbox.mosip.net
mimotoBackendServiceDefaultUrl: https://api.sandbox.mosip.net
esignetBackendServiceDefaultUrl: https://api.sandbox.mosip.net
on:
workflow_dispatch:
inputs:
backendServiceUrl:
description: 'Backend service URL'
mimotoBackendServiceUrl:
description: 'Mimoto backend service URL'
required: true
default: 'https://api.sandbox.mosip.net'
type: string
esignetBackendServiceUrl:
description: 'Esignet backend service URL'
required: true
default: 'https://api.sandbox.mosip.net'
type: string
@@ -115,7 +121,8 @@ jobs:
cd android/scripts
./internal-build.sh
env:
MIMOTO_HOST: ${{ github.event.inputs.backendServiceUrl }}
MIMOTO_HOST: ${{ github.event.inputs.mimotoBackendServiceUrl }}
ESIGNET_HOST: ${{ github.event.inputs.esignetBackendServiceUrl }}
APPLICATION_THEME: ${{ github.event.inputs.theme }}
RELEASE_KEYSTORE_ALIAS: androidreleasekey
RELEASE_KEYSTORE_PASSWORD: '${{secrets.INJI_ANDROID_RELEASE_STOREPASS}}'

View File

@@ -3,8 +3,13 @@ name: Inji iOS build
on:
workflow_dispatch:
inputs:
backendServiceUrl:
description: 'Backend service URL'
mimotoBackendServiceUrl:
description: 'Mimoto backend service URL'
required: true
default: 'https://api.sandbox.mosip.net'
type: string
esignetBackendServiceUrl:
description: 'Esignet backend service URL'
required: true
default: 'https://api.sandbox.mosip.net'
type: string
@@ -82,7 +87,5 @@ jobs:
SLACK_URL: '${{ secrets.SLACK_WEBHOOK_DEVOPS }}'
MATCH_PASSWORD: '${{ secrets.INJI_IOS_MATCH_PASSWORD }}'
APPLICATION_THEME: ${{ github.event.inputs.theme }}
CREDENTIAL_REGISTRY_EDIT: ${{ github.event.inputs.registry_edit }}
MIMOTO_HOST: ${{ github.event.inputs.backendServiceUrl }}
TESTFLIGHT_INTERNAL_TESTERS_GROUP: ${{ github.event.inputs.internal-testers }}
TESTFLIGHT_BETA_APP_DESCRIPTION: ${{ github.event.inputs.buildDescription }}

View File

@@ -1,6 +1,7 @@
default_platform(:android)
MIMOTO_HOST = ENV["MIMOTO_HOST"]
ESIGNET_HOST = ENV["ESIGNET_HOST"]
APPLICATION_THEME = ENV["APPLICATION_THEME"]
RELEASE_KEYSTORE_ALIAS = ENV["RELEASE_KEYSTORE_ALIAS"]
RELEASE_KEYSTORE_PASSWORD = ENV["RELEASE_KEYSTORE_PASSWORD"]

View File

@@ -8,7 +8,7 @@ import {
} from 'xstate';
import { createModel } from 'xstate/lib/model';
import { AppServices } from '../shared/GlobalContext';
import { MY_VCS_STORE_KEY } from '../shared/constants';
import { MY_VCS_STORE_KEY, ESIGNET_BASE_URL } from '../shared/constants';
import { StoreEvents } from './store';
import { linkTransactionResponse, VC } from '../types/vc';
import { request } from '../shared/request';
@@ -349,7 +349,8 @@ export const qrLoginMachine =
request: {
linkCode: context.linkCode,
},
}
},
ESIGNET_BASE_URL
);
return response.response;
},
@@ -386,7 +387,8 @@ export const qrLoginMachine =
},
],
},
}
},
ESIGNET_BASE_URL
);
return response.response.linkedTransactionId;
},
@@ -421,7 +423,8 @@ export const qrLoginMachine =
},
],
},
}
},
ESIGNET_BASE_URL
);
var linkedTrnId = response.response.linkedTransactionId;
@@ -437,7 +440,8 @@ export const qrLoginMachine =
),
permittedAuthorizeScopes: context.authorizeScopes,
},
}
},
ESIGNET_BASE_URL
);
console.log(resp.response.linkedTransactionId);
},

View File

@@ -24,8 +24,8 @@ import { request } from '../shared/request';
import {
changeCrendetialRegistry,
SETTINGS_STORE_KEY,
MIMOTO_BASE_URL
} from '../shared/constants';
import { MIMOTO_HOST } from 'react-native-dotenv';
const model = createModel(
{
@@ -328,7 +328,7 @@ export const appMachine = model.createMachine(
loadCredentialRegistryInConstants: (_context, event) => {
changeCrendetialRegistry(
!event.response?.credentialRegistry
? MIMOTO_HOST
? MIMOTO_BASE_URL
: event.response?.credentialRegistry
);
},

View File

@@ -4,7 +4,7 @@ import { AppServices } from '../shared/GlobalContext';
import {
APP_ID_DICTIONARY,
APP_ID_LENGTH,
HOST,
MIMOTO_BASE_URL,
isIOS,
SETTINGS_STORE_KEY,
} from '../shared/constants';
@@ -27,7 +27,7 @@ const model = createModel(
plural: 'Cards',
} as VCLabel,
isBiometricUnlockEnabled: false,
credentialRegistry: HOST,
credentialRegistry: MIMOTO_BASE_URL,
appId: null,
hasUserShownWithHardwareKeystoreNotExists: false,
credentialRegistryResponse: '' as string,

View File

@@ -1,7 +1,7 @@
import { assign, ErrorPlatformEvent, EventFrom, send, StateFrom } from 'xstate';
import { createModel } from 'xstate/lib/model';
import {
HOST,
MIMOTO_BASE_URL,
MY_VCS_STORE_KEY,
VC_ITEM_STORE_KEY,
VC_ITEM_STORE_KEY_AFTER_DOWNLOAD,
@@ -913,7 +913,7 @@ export const vcItemMachine =
storeContext: send(
(context) => {
const { serviceRefs, ...data } = context;
data.credentialRegistry = HOST;
data.credentialRegistry = MIMOTO_BASE_URL;
return StoreEvents.SET(VC_ITEM_STORE_KEY(context), data);
},
{

View File

@@ -2,13 +2,15 @@ import { Platform } from 'react-native';
import { VC } from '../types/vc';
import {
MIMOTO_HOST,
ESIGNET_HOST,
GOOGLE_NEARBY_MESSAGES_API_KEY,
} from 'react-native-dotenv';
import { Argon2iConfig } from './commonUtil';
export let HOST = MIMOTO_HOST;
export let MIMOTO_BASE_URL = MIMOTO_HOST;
export const ESIGNET_BASE_URL = ESIGNET_HOST;
export const changeCrendetialRegistry = (host) => (HOST = host);
export const changeCrendetialRegistry = (host) => (MIMOTO_BASE_URL = host);
export const MY_VCS_STORE_KEY = 'myVCs';

View File

@@ -1,5 +1,5 @@
import { DecodedCredential, VerifiableCredential } from '../types/vc';
import { HOST } from './constants';
import { MIMOTO_BASE_URL } from './constants';
export class BackendResponseError extends Error {
constructor(name: string, message: string) {
@@ -23,14 +23,15 @@ export class AppId {
export async function request(
method: 'GET' | 'POST' | 'PATCH',
path: `/${string}`,
body?: Record<string, unknown>
body?: Record<string, unknown>,
host= MIMOTO_BASE_URL
) {
const headers = {
'Content-Type': 'application/json',
};
if (path.includes('residentmobileapp')) headers['X-AppId'] = AppId.getValue();
const response = await fetch(HOST + path, {
const response = await fetch(host + path, {
method,
headers,
body: JSON.stringify(body),
@@ -39,7 +40,7 @@ export async function request(
const jsonResponse = await response.json();
if (response.status >= 400) {
let backendUrl = HOST + path;
let backendUrl = host + path;
let errorMessage = jsonResponse.message || jsonResponse.error;
console.error(
'The backend API ' +
@@ -51,7 +52,7 @@ export async function request(
}
if (jsonResponse.errors && jsonResponse.errors.length) {
let backendUrl = HOST + path;
let backendUrl = host + path;
const { errorCode, errorMessage } = jsonResponse.errors.shift();
console.error(
'The backend API ' +

View File

@@ -4,6 +4,11 @@ declare module 'react-native-dotenv' {
*/
export const MIMOTO_HOST: string;
/**
* URL for the Esignet backend server
*/
export const ESIGNET_HOST: string;
/**
* API key to use Google Nearby Messages API
*/