Skip to content

Commit

Permalink
Merge pull request #176 from Sphereon-Opensource/feature/WAL-663
Browse files Browse the repository at this point in the history
feature/WAL-663
  • Loading branch information
BtencateSphereon authored Jan 19, 2024
2 parents 99f2f00 + eb3520a commit eaea7a5
Show file tree
Hide file tree
Showing 25 changed files with 1,439 additions and 506 deletions.
88 changes: 44 additions & 44 deletions __tests__/OnboardingScreens.test.tsx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/@config/database/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const sqliteConfig: ExpoConnectionOptions = {
migrationsRun: false, // We run migrations from code to ensure proper ordering with Redux
synchronize: false, // We do not enable synchronize, as we use migrations from code
migrationsTransactionMode: 'each', // protect every migration with a separate transaction
logging: 'all', // 'all' means to enable all logging
logging: ['info', 'warn'],
logger: 'advanced-console',
};

Expand Down
8 changes: 7 additions & 1 deletion src/localization/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,11 @@
"emergency_send_button_caption": "Trigger now!",
"emergency_abort_button_caption": "Abort alarm",
"emergency_title": "Send emergency alert",
"emergency_subtitle": "Your distress call will be send in {{emergencyAlertDelay}} seconds, or you can trigger it immediately by clicking on the Trigger now! button."
"emergency_subtitle": "Your distress call will be send in {{emergencyAlertDelay}} seconds, or you can trigger it immediately by clicking on the Trigger now! button.",
"siopV2_machine_identifier_error_title": "Getting identifier",
"siopV2_machine_create_config_error_title": "Creating siopV2 config",
"siopV2_machine_get_request_error_title": "Getting siopV2 request",
"siopV2_machine_retrieve_contact_error_title": "Retrieve contact",
"siopV2_machine_add_contact_identity_error_title": "Add contact identity",
"siopV2_machine_send_response_error_title": "Sending siopV2 response"
}
8 changes: 7 additions & 1 deletion src/localization/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,11 @@
"emergency_send_button_caption": "Activeer nu!",
"emergency_abort_button_caption": "Alarm afbreken",
"emergency_title": "Stuur een noodwaarschuwing",
"emergency_subtitle": "Uw noodoproep wordt over {{emergencyAlertDelay}} seconden verzonden, of u kunt deze onmiddellijk activeren door op de knop Activeer nu! te klikken."
"emergency_subtitle": "Uw noodoproep wordt over {{emergencyAlertDelay}} seconden verzonden, of u kunt deze onmiddellijk activeren door op de knop Activeer nu! te klikken.",
"siopV2_machine_identifier_error_title": "Identifier ophalen",
"siopV2_machine_create_config_error_title": "SiopV2 configuratie maken",
"siopV2_machine_get_request_error_title": "SiopV2 verzoek ophalen",
"siopV2_machine_retrieve_contact_error_title": "Ophalen credential",
"siopV2_machine_add_contact_identity_error_title": "Toevoegen identiteit contact",
"siopV2_machine_send_response_error_title": "SiopV2 antwoord verzenden"
}
4 changes: 2 additions & 2 deletions src/machines/oid4vciMachine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const createOID4VCIMachine = (opts?: CreateOID4VCIMachineOpts): OID4VCIStateMach
schema: {
events: {} as OID4VCIMachineEventTypes,
guards: {} as
| {type: OID4VCIMachineGuards.hasNotContactGuard}
| {type: OID4VCIMachineGuards.hasNoContactGuard}
| {type: OID4VCIMachineGuards.selectCredentialGuard}
| {type: OID4VCIMachineGuards.requirePinGuard}
| {type: OID4VCIMachineGuards.hasNoContactIdentityGuard}
Expand Down Expand Up @@ -200,7 +200,7 @@ const createOID4VCIMachine = (opts?: CreateOID4VCIMachineOpts): OID4VCIStateMach
always: [
{
target: OID4VCIMachineStates.addContact,
cond: OID4VCIMachineGuards.hasNotContactGuard,
cond: OID4VCIMachineGuards.hasNoContactGuard,
},
{
target: OID4VCIMachineStates.selectCredentials,
Expand Down
122 changes: 61 additions & 61 deletions src/machines/onboardingMachine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import {
OnboardingMachineContext,
NextEvent,
OnboardingContext,
OnboardingEvents,
OnboardingEventTypes,
OnboardingGuards,
OnboardingMachineEvents,
OnboardingMachineEventTypes,
OnboardingMachineGuards,
OnboardingMachineInterpreter,
OnboardingMachineState,
OnboardingStates,
OnboardingMachineStates,
PersonalDataEvent,
PinSetEvent,
PrivacyPolicyEvent,
Expand All @@ -28,15 +28,15 @@ import {
import Debug, {Debugger} from 'debug';
const debug: Debugger = Debug(`${APP_ID}:onboarding`);

const onboardingToSAgreementGuard = (ctx: OnboardingMachineContext, _event: OnboardingEventTypes) =>
const onboardingToSAgreementGuard = (ctx: OnboardingMachineContext, _event: OnboardingMachineEventTypes) =>
ctx.termsConditionsAccepted && ctx.privacyPolicyAccepted;

const onboardingPersonalDataGuard = (ctx: OnboardingMachineContext, _event: OnboardingEventTypes) => {
const onboardingPersonalDataGuard = (ctx: OnboardingMachineContext, _event: OnboardingMachineEventTypes) => {
const {firstName, lastName, emailAddress} = ctx.personalData;
return firstName && firstName.length > 0 && lastName && lastName.length > 0 && emailAddress && EMAIL_ADDRESS_VALIDATION_REGEX.test(emailAddress);
};

const onboardingPinCodeSetGuard = (ctx: OnboardingMachineContext, _event: OnboardingEventTypes) => {
const onboardingPinCodeSetGuard = (ctx: OnboardingMachineContext, _event: OnboardingMachineEventTypes) => {
const {pinCode} = ctx;
return pinCode && pinCode.length === 6;
};
Expand Down Expand Up @@ -71,27 +71,27 @@ const createOnboardingMachine = (opts?: CreateOnboardingMachineOpts) => {
pinCode: '',
} as OnboardingMachineContext;

return createMachine<OnboardingMachineContext, OnboardingEventTypes>({
return createMachine<OnboardingMachineContext, OnboardingMachineEventTypes>({
id: opts?.machineId ?? 'Onboarding',
predictableActionArguments: true,
initial: OnboardingStates.showIntro,
initial: OnboardingMachineStates.showIntro,
schema: {
events: {} as OnboardingEventTypes,
events: {} as OnboardingMachineEventTypes,
guards: {} as
| {
type: OnboardingGuards.onboardingPersonalDataGuard;
type: OnboardingMachineGuards.onboardingPersonalDataGuard;
}
| {
type: OnboardingGuards.onboardingToSAgreementGuard;
type: OnboardingMachineGuards.onboardingToSAgreementGuard;
}
| {
type: OnboardingGuards.onboardingPinCodeSetGuard;
type: OnboardingMachineGuards.onboardingPinCodeSetGuard;
}
| {
type: OnboardingGuards.onboardingPinCodeVerifyGuard;
type: OnboardingMachineGuards.onboardingPinCodeVerifyGuard;
},
services: {} as {
[OnboardingStates.setupWallet]: {
[OnboardingMachineStates.setupWallet]: {
data: WalletSetupServiceResult;
};
},
Expand All @@ -101,101 +101,101 @@ const createOnboardingMachine = (opts?: CreateOnboardingMachineOpts) => {
},

states: {
[OnboardingStates.showIntro]: {
[OnboardingMachineStates.showIntro]: {
on: {
[OnboardingEvents.NEXT]: [
[OnboardingMachineEvents.NEXT]: [
{
target: OnboardingStates.acceptAgreement,
target: OnboardingMachineStates.acceptAgreement,
},
],
},
},
[OnboardingStates.acceptAgreement]: {
[OnboardingMachineStates.acceptAgreement]: {
on: {
[OnboardingEvents.SET_POLICY]: {
[OnboardingMachineEvents.SET_POLICY]: {
actions: assign({privacyPolicyAccepted: (_ctx: OnboardingMachineContext, e: PrivacyPolicyEvent) => e.data}),
},
[OnboardingEvents.SET_TOC]: {
[OnboardingMachineEvents.SET_TOC]: {
actions: assign({termsConditionsAccepted: (_ctx: OnboardingMachineContext, e: TermsConditionsEvent) => e.data}),
},
[OnboardingEvents.DECLINE]: {
target: OnboardingStates.declineOnboarding,
[OnboardingMachineEvents.DECLINE]: {
target: OnboardingMachineStates.declineOnboarding,
},
[OnboardingEvents.NEXT]: {
cond: OnboardingGuards.onboardingToSAgreementGuard,
target: OnboardingStates.enterPersonalDetails,
[OnboardingMachineEvents.NEXT]: {
cond: OnboardingMachineGuards.onboardingToSAgreementGuard,
target: OnboardingMachineStates.enterPersonalDetails,
},
[OnboardingEvents.PREVIOUS]: {target: OnboardingStates.showIntro},
[OnboardingMachineEvents.PREVIOUS]: {target: OnboardingMachineStates.showIntro},
},
},
[OnboardingStates.enterPersonalDetails]: {
[OnboardingMachineStates.enterPersonalDetails]: {
on: {
[OnboardingEvents.SET_PERSONAL_DATA]: {
[OnboardingMachineEvents.SET_PERSONAL_DATA]: {
actions: assign({personalData: (_ctx: OnboardingMachineContext, e: PersonalDataEvent) => e.data}),
},
[OnboardingEvents.NEXT]: {
cond: OnboardingGuards.onboardingPersonalDataGuard,
target: OnboardingStates.enterPin,
[OnboardingMachineEvents.NEXT]: {
cond: OnboardingMachineGuards.onboardingPersonalDataGuard,
target: OnboardingMachineStates.enterPin,
},
[OnboardingEvents.PREVIOUS]: {target: OnboardingStates.acceptAgreement},
[OnboardingMachineEvents.PREVIOUS]: {target: OnboardingMachineStates.acceptAgreement},
},
},
[OnboardingStates.enterPin]: {
[OnboardingMachineStates.enterPin]: {
on: {
[OnboardingEvents.SET_PIN]: {
[OnboardingMachineEvents.SET_PIN]: {
actions: assign({pinCode: (_ctx: OnboardingMachineContext, e: PinSetEvent) => e.data}),
},
[OnboardingEvents.NEXT]: {
cond: OnboardingGuards.onboardingPinCodeSetGuard,
target: OnboardingStates.verifyPin,
[OnboardingMachineEvents.NEXT]: {
cond: OnboardingMachineGuards.onboardingPinCodeSetGuard,
target: OnboardingMachineStates.verifyPin,
},
[OnboardingEvents.PREVIOUS]: {
target: OnboardingStates.enterPersonalDetails,
[OnboardingMachineEvents.PREVIOUS]: {
target: OnboardingMachineStates.enterPersonalDetails,
},
},
},
[OnboardingStates.verifyPin]: {
[OnboardingMachineStates.verifyPin]: {
on: {
[OnboardingEvents.NEXT]: {
cond: OnboardingGuards.onboardingPinCodeVerifyGuard,
target: OnboardingStates.verifyPersonalDetails,
[OnboardingMachineEvents.NEXT]: {
cond: OnboardingMachineGuards.onboardingPinCodeVerifyGuard,
target: OnboardingMachineStates.verifyPersonalDetails,
},
[OnboardingEvents.PREVIOUS]: {
target: OnboardingStates.enterPin,
[OnboardingMachineEvents.PREVIOUS]: {
target: OnboardingMachineStates.enterPin,
},
},
},
[OnboardingStates.verifyPersonalDetails]: {
[OnboardingMachineStates.verifyPersonalDetails]: {
on: {
[OnboardingEvents.NEXT]: {
target: OnboardingStates.setupWallet,
[OnboardingMachineEvents.NEXT]: {
target: OnboardingMachineStates.setupWallet,
},
[OnboardingEvents.PREVIOUS]: {
target: OnboardingStates.enterPin, // We are going back to pin entry and then verify
[OnboardingMachineEvents.PREVIOUS]: {
target: OnboardingMachineStates.enterPin, // We are going back to pin entry and then verify
},
},
},
[OnboardingStates.setupWallet]: {
[OnboardingMachineStates.setupWallet]: {
invoke: {
id: OnboardingStates.setupWallet,
src: OnboardingStates.setupWallet,
id: OnboardingMachineStates.setupWallet,
src: OnboardingMachineStates.setupWallet,
onDone: {
target: OnboardingStates.finishOnboarding,
target: OnboardingMachineStates.finishOnboarding,
},
// todo: On Error
},
},
[OnboardingStates.declineOnboarding]: {
id: OnboardingStates.declineOnboarding,
always: OnboardingStates.showIntro,
[OnboardingMachineStates.declineOnboarding]: {
id: OnboardingMachineStates.declineOnboarding,
always: OnboardingMachineStates.showIntro,
entry: assign({
...initialContext,
}),
// Since we are not allowed to exit an app by Apple/Google, we go back to the onboarding state when the user declines
},
[OnboardingStates.finishOnboarding]: {
[OnboardingMachineStates.finishOnboarding]: {
type: 'final',
id: OnboardingStates.finishOnboarding,
id: OnboardingMachineStates.finishOnboarding,
entry: assign({
pinCode: '',
personalData: undefined,
Expand Down Expand Up @@ -223,7 +223,7 @@ export class OnboardingMachine {
}

static stopInstance(): void {
debug(`Stop instance...`);
debug(`Stopping instance...`);
if (!OnboardingMachine.hasInstance()) {
return;
}
Expand Down
Loading

0 comments on commit eaea7a5

Please sign in to comment.