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

ibCredentialLocaleBrandingFrom error handling #179

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
18 changes: 12 additions & 6 deletions src/providers/credential/OpenId4VcIssuanceProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,16 +324,22 @@ class OpenId4VcIssuanceProvider {
if (!this._issuerBranding) {
this._issuerBranding = this._serverMetadata.credentialIssuerMetadata?.display;
}

if (!this._credentialBranding) {
this._credentialBranding = new Map<string, Array<IBasicCredentialLocaleBranding>>();
await Promise.all(
this._credentialsSupported.map(async (metadata: CredentialSupported): Promise<void> => {
const localeBranding: Array<IBasicCredentialLocaleBranding> = await Promise.all(
(metadata.display ?? []).map(
async (display: CredentialsSupportedDisplay): Promise<IBasicCredentialLocaleBranding> =>
await ibCredentialLocaleBrandingFrom({localeBranding: await credentialLocaleBrandingFrom(display)}),
),
const optionalLocaleBranding: Array<IBasicCredentialLocaleBranding | undefined> = await Promise.all(
(metadata.display ?? []).map(async (display: CredentialsSupportedDisplay): Promise<IBasicCredentialLocaleBranding | undefined> => {
try {
return await ibCredentialLocaleBrandingFrom({localeBranding: await credentialLocaleBrandingFrom(display)});
} catch (e) {
console.error(`Could not fetch branding. Branding data: ${JSON.stringify(display)}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

i am not sure if this is the way we should handle this. Also what situation did you have where the branding was not present?

Copy link
Contributor

Choose a reason for hiding this comment

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

Images could be unavailable because of a network issue for instance. I rather have us accept the credential without branding then having an error because of branding issues.

If I remember correctly it was a case where the image could not be found, right @sander

Copy link
Contributor

Choose a reason for hiding this comment

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

should we then not fix that in the plugin instead of the wallet?

}
}),
);

const localeBranding: Array<IBasicCredentialLocaleBranding> = optionalLocaleBranding.filter(
(branding): branding is IBasicCredentialLocaleBranding => branding !== undefined,
);

const credentialTypes: Array<string> =
Expand Down