Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inji 360 Support different host for mimoto and esignet #829

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -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

Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/android-beta-build.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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}}'
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/android-internal-build.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add the esignet env to Fastfile as well so fastlane will have the env context.

ESIGNET_HOST = ENV["ESIGNET_HOST"]

APPLICATION_THEME: ${{ github.event.inputs.theme }}
RELEASE_KEYSTORE_ALIAS: androidreleasekey
RELEASE_KEYSTORE_PASSWORD: '${{secrets.INJI_ANDROID_RELEASE_STOREPASS}}'
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/ios-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
1 change: 1 addition & 0 deletions android/fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down
14 changes: 9 additions & 5 deletions machines/QrLoginMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -349,7 +349,8 @@ export const qrLoginMachine =
request: {
linkCode: context.linkCode,
},
}
},
ESIGNET_BASE_URL
);
return response.response;
},
Expand Down Expand Up @@ -386,7 +387,8 @@ export const qrLoginMachine =
},
],
},
}
},
ESIGNET_BASE_URL
);
return response.response.linkedTransactionId;
},
Expand Down Expand Up @@ -421,7 +423,8 @@ export const qrLoginMachine =
},
],
},
}
},
ESIGNET_BASE_URL
);
var linkedTrnId = response.response.linkedTransactionId;

Expand All @@ -437,7 +440,8 @@ export const qrLoginMachine =
),
permittedAuthorizeScopes: context.authorizeScopes,
},
}
},
ESIGNET_BASE_URL
);
console.log(resp.response.linkedTransactionId);
},
Expand Down
4 changes: 2 additions & 2 deletions machines/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down Expand Up @@ -328,7 +328,7 @@ export const appMachine = model.createMachine(
loadCredentialRegistryInConstants: (_context, event) => {
changeCrendetialRegistry(
!event.response?.credentialRegistry
? MIMOTO_HOST
? MIMOTO_BASE_URL
: event.response?.credentialRegistry
);
},
Expand Down
4 changes: 2 additions & 2 deletions machines/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions machines/vcItem.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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);
},
{
Expand Down
6 changes: 4 additions & 2 deletions shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
11 changes: 6 additions & 5 deletions shared/request.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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),
Expand All @@ -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 ' +
Expand All @@ -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 ' +
Expand Down
5 changes: 5 additions & 0 deletions types/react-native-dotenv/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down