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

chore: fixes #270

Merged
merged 1 commit into from
Nov 8, 2024
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
2 changes: 2 additions & 0 deletions packages/oid4vci-holder/src/localization/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"oid4vci_machine_store_credential_error_title": "Store credential",
"oid4vci_machine_add_contact_identity_error_title": "Add contact identity",
"oid4vci_machine_retrieve_credentials_error_title": "Retrieve credentials",
"oid4vci_machine_retrieve_issuer_branding_error_title": "Retrieve issuer branding",
"oid4vci_machine_store_issuer_branding_error_title": "Store issuer branding",
"oid4vci_machine_retrieve_contact_error_title": "Retrieve contact",
"oid4vci_machine_credential_selection_error_title": "Credential selection",
"oid4vci_machine_initiation_error_title": "Initiate OID4VCI provider",
Expand Down
2 changes: 2 additions & 0 deletions packages/oid4vci-holder/src/localization/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"oid4vci_machine_store_credential_error_title": "Opslaan credential",
"oid4vci_machine_add_contact_identity_error_title": "Toevoegen identiteit contact",
"oid4vci_machine_retrieve_credentials_error_title": "Ophalen credential",
"oid4vci_machine_retrieve_issuer_branding_error_title": "Ophalen issuer branding",
"oid4vci_machine_store_issuer_branding_error_title": "Opslaan issuer branding",
"oid4vci_machine_retrieve_contact_error_title": "Ophalen contact",
"oid4vci_machine_credential_selection_error_title": "Credential selectie",
"oid4vci_machine_initiation_error_title": "Initiëren OID4VCI provider",
Expand Down
25 changes: 23 additions & 2 deletions packages/oid4vci-holder/src/machine/oid4vciMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ const oid4vciHasSelectedCredentialsGuard = (_ctx: OID4VCIMachineContext, _event:

const oid4vciIsOIDFOriginGuard = (_ctx: OID4VCIMachineContext, _event: OID4VCIMachineEventTypes): boolean => {
// TODO in the future we need to establish if a origin is a IDF origin. So we need to check if this metadata is on the well-known location
const { trustAnchors } = _ctx
return trustAnchors.length > 0
const { trustAnchors, contact } = _ctx
return trustAnchors.length > 0 && contact === undefined
}

const oid4vciNoAuthorizationGuard = (ctx: OID4VCIMachineContext, _event: OID4VCIMachineEventTypes): boolean => {
Expand Down Expand Up @@ -271,11 +271,22 @@ const createOID4VCIMachine = (opts?: CreateOID4VCIMachineOpts): OID4VCIStateMach
issuerBranding: (_ctx: OID4VCIMachineContext, _event: DoneInvokeEvent<Array<IIssuerLocaleBranding | IBasicIssuerLocaleBranding>>) => _event.data
})
},
onError: {
target: OID4VCIMachineStates.handleError,
actions: assign({
error: (_ctx: OID4VCIMachineContext, _event: DoneInvokeEvent<Error>): ErrorDetails => ({
title: translate('oid4vci_machine_retrieve_issuer_branding_error_title'),
message: _event.data.message,
stack: _event.data.stack,
}),
}),
},
},
},
[OID4VCIMachineStates.transitionFromSetup]: {
id: OID4VCIMachineStates.transitionFromSetup,
always: [
// TODO improve getFederationTrust machine logic and where we call this in the machine. we only need this for new contacts, as it is only displayed on the add contact screen
{
target: OID4VCIMachineStates.getFederationTrust,
cond: OID4VCIMachineGuards.oid4vciIsOIDFOriginGuard
Expand Down Expand Up @@ -367,6 +378,16 @@ const createOID4VCIMachine = (opts?: CreateOID4VCIMachineOpts): OID4VCIStateMach
onDone: {
target: OID4VCIMachineStates.transitionFromContactSetup,
},
onError: {
target: OID4VCIMachineStates.handleError,
actions: assign({
error: (_ctx: OID4VCIMachineContext, _event: DoneInvokeEvent<Error>): ErrorDetails => ({
title: translate('oid4vci_machine_store_issuer_branding_error_title'),
message: _event.data.message,
stack: _event.data.stack,
}),
}),
},
},
},
[OID4VCIMachineStates.transitionFromContactSetup]: {
Expand Down