Skip to content

Commit

Permalink
fix: added generic union types for frequently used types
Browse files Browse the repository at this point in the history
  • Loading branch information
sksadjad committed May 17, 2024
1 parent da039f0 commit 72474d6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 3 additions & 1 deletion packages/common/lib/functions/IssuerMetadataUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ export function getTypesFromCredentialSupported(
credentialSupported.format === 'jwt_vc_json-ld' ||
credentialSupported.format === 'ldp_vc'
) {
types = credentialSupported.types;
types = credentialSupported.types? credentialSupported.types as string[]: 'credential_definition' in credentialSupported? credentialSupported.credential_definition.type: [];
} else if (credentialSupported.format === 'vc+sd-jwt') {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
types = [credentialSupported.vct];
}

Expand Down
8 changes: 5 additions & 3 deletions packages/common/lib/types/Generic.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
EndpointMetadataResultV1_0_11
} from './v1_0_11.types'
import {
CredentialConfigurationSupportedV1_0_13,
CredentialRequestV1_0_13,
EndpointMetadataResultV1_0_13,
IssuerMetadataV1_0_13
Expand Down Expand Up @@ -156,8 +157,8 @@ export interface CredentialSupportedSdJwtVc extends CommonCredentialSupported {
order?: string[]; //An array of claims.display.name values that lists them in the order they should be displayed by the Wallet.
}

export type CredentialSupported = CommonCredentialSupported &
(CredentialSupportedJwtVcJson | CredentialSupportedJwtVcJsonLdAndLdpVc | CredentialSupportedSdJwtVc);
export type CredentialSupported = CredentialConfigurationSupportedV1_0_13 | (CommonCredentialSupported &
(CredentialSupportedJwtVcJson | CredentialSupportedJwtVcJsonLdAndLdpVc | CredentialSupportedSdJwtVc));

export interface CommonCredentialOfferFormat {
format: OID4VCICredentialFormat | string;
Expand Down Expand Up @@ -364,4 +365,5 @@ export const PRE_AUTH_CODE_LITERAL = 'pre-authorized_code';

export type EndpointMetadataResult = EndpointMetadataResultV1_0_13 | EndpointMetadataResultV1_0_11

export type IssuerMetadata = IssuerMetadataV1_0_13 | IssuerMetadataV1_0_08
export type IssuerMetadata = IssuerMetadataV1_0_13 | IssuerMetadataV1_0_08

4 changes: 0 additions & 4 deletions packages/common/lib/types/v1_0_13.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ export type CredentialDefinitionV1_0_13 = {

export type CredentialConfigurationSupportedV1_0_13 = {
credential_definition: CredentialDefinitionV1_0_13;
/**
* TODO: These two (vct and id) are solely added because of backward compatibility with sd-jwt. as soons as we have a clear understanding of the new sd-jwt issuer protocol we can remove this
*/
vct?: string;
id?: string;
format: OID4VCICredentialFormat; //REQUIRED. A JSON string identifying the format of this credential, e.g. jwt_vc_json or ldp_vc.
scope?: string; // OPTIONAL. A JSON string identifying the scope value that this Credential Issuer supports for this particular Credential. The value can be the same across multiple credential_configurations_supported objects. The Authorization Server MUST be able to uniquely identify the Credential Issuer based on the scope value. The Wallet can use this value in the Authorization Request as defined in Section 5.1.2. Scope values in this Credential Issuer metadata MAY duplicate those in the scopes_supported parameter of the Authorization Server.
Expand Down

0 comments on commit 72474d6

Please sign in to comment.