Skip to content

Commit

Permalink
fix: fixed type mismatch in some files
Browse files Browse the repository at this point in the history
  • Loading branch information
sksadjad committed May 16, 2024
1 parent 215227e commit a2b3c22
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
12 changes: 6 additions & 6 deletions packages/client/lib/AuthorizationCodeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
AuthorizationRequestOpts,
CodeChallengeMethod,
convertJsonToURI,
CredentialOfferFormat,
CredentialConfigurationSupportedV1_0_13,
CredentialOfferPayloadV1_0_13,
CredentialOfferRequestWithBaseUrl,
CredentialSupported,
Expand All @@ -14,7 +14,7 @@ import {
OpenId4VCIVersion,
PARMode,
PKCEOpts,
PushedAuthorizationResponse,
PushedAuthorizationResponse,
ResponseType
} from '@sphereon/oid4vci-common'
import Debug from 'debug';
Expand All @@ -23,8 +23,8 @@ const debug = Debug('sphereon:oid4vci');

function filterSupportedCredentials(
credentialOffer: CredentialOfferPayloadV1_0_13,
credentialsSupported?: Record<string, CredentialSupported>,
): CredentialSupported[] {
credentialsSupported?: Record<string, CredentialConfigurationSupportedV1_0_13>,
): CredentialConfigurationSupportedV1_0_13[] {
if (!credentialOffer.credential_configuration_ids || !credentialsSupported) {
return [];
}
Expand All @@ -42,7 +42,7 @@ export const createAuthorizationRequestUrl = async ({
endpointMetadata: EndpointMetadataResultV1_0_13;
authorizationRequest: AuthorizationRequestOpts;
credentialOffer?: CredentialOfferRequestWithBaseUrl;
credentialConfigurationSupported?: Record<string, CredentialSupported>;
credentialConfigurationSupported?: Record<string, CredentialConfigurationSupportedV1_0_13>;
}): Promise<string> => {
const { redirectUri, clientId } = authorizationRequest;
let { scope, authorizationDetails } = authorizationRequest;
Expand All @@ -58,7 +58,7 @@ export const createAuthorizationRequestUrl = async ({
if ('credentials' in credentialOffer.credential_offer) {
throw new Error('CredentialOffer format is wrong.');
}
const creds: (CredentialSupported | CredentialOfferFormat | string)[] =
const creds: CredentialConfigurationSupportedV1_0_13[] =
determineSpecVersionFromOffer(credentialOffer.credential_offer) === OpenId4VCIVersion.VER_1_0_13
? filterSupportedCredentials(credentialOffer.credential_offer as CredentialOfferPayloadV1_0_13, credentialConfigurationSupported)
: [];
Expand Down
5 changes: 2 additions & 3 deletions packages/client/lib/OpenID4VCIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import {
AuthorizationRequestOpts,
AuthorizationResponse,
AuthzFlowType,
CodeChallengeMethod,
CodeChallengeMethod, CredentialConfigurationSupportedV1_0_13,
CredentialOfferRequestWithBaseUrl,
CredentialResponse,
CredentialSupported,
DefaultURISchemes,
EndpointMetadataResultV1_0_13,
getClientIdFromCredentialOfferPayload,
Expand Down Expand Up @@ -440,7 +439,7 @@ export class OpenID4VCIClient {

getCredentialsSupported(
format?: (OID4VCICredentialFormat | string) | (OID4VCICredentialFormat | string)[],
): Record<string, CredentialSupported> {
): Record<string, CredentialConfigurationSupportedV1_0_13> {
return getSupportedCredentials({
issuerMetadata: this.endpointMetadata.credentialIssuerMetadata,
version: this.version(),
Expand Down
4 changes: 2 additions & 2 deletions packages/client/lib/OpenID4VCIClientV1_0_11.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ export class OpenID4VCIClientV1_0_11 {
version: this.version(),
format: format,
types: restrictToInitiationTypes ? this.getCredentialOfferTypes() : undefined,
});
}) as Record<string, CredentialSupported>;
}

getCredentialsSupported(
Expand All @@ -466,7 +466,7 @@ export class OpenID4VCIClientV1_0_11 {
version: this.version(),
format: format,
types: undefined,
});
}) as Record<string, CredentialSupported>;
}

getCredentialOfferTypes(): string[][] {
Expand Down
16 changes: 8 additions & 8 deletions packages/common/lib/functions/IssuerMetadataUtils.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import {
AuthorizationServerMetadata,
CredentialSupported,
CredentialConfigurationSupportedV1_0_13,
CredentialIssuerMetadata,
CredentialSupported,
CredentialSupportedTypeV1_0_08,
CredentialSupportedV1_0_08,
IssuerMetadataV1_0_08,
MetadataDisplay,
OID4VCICredentialFormat,
OpenId4VCIVersion,
} from '../types';
OID4VCICredentialFormat, OpenId4VCIVersion
} from '../types'
import { IssuerMetadataV1_0_13 } from '../types';

export function getSupportedCredentials(options?: {
issuerMetadata?: CredentialIssuerMetadata | IssuerMetadataV1_0_08 | IssuerMetadataV1_0_13;
version: OpenId4VCIVersion;
types?: string[][];
format?: OID4VCICredentialFormat | string | (OID4VCICredentialFormat | string)[];
}): Record<string, CredentialSupported> {
}): Record<string, CredentialConfigurationSupportedV1_0_13> {
if (options?.types && Array.isArray(options.types)) {
return options.types
.map((typeSet) => {
Expand All @@ -27,7 +27,7 @@ export function getSupportedCredentials(options?: {
Object.assign(acc, result);
return acc;
},
{} as Record<string, CredentialSupported>,
{} as Record<string, CredentialConfigurationSupportedV1_0_13>,
);
}

Expand All @@ -39,7 +39,7 @@ export function getSupportedCredential(opts?: {
version: OpenId4VCIVersion;
types?: string | string[];
format?: (OID4VCICredentialFormat | string) | (OID4VCICredentialFormat | string)[];
}): Record<string, CredentialSupported> {
}): Record<string, CredentialConfigurationSupportedV1_0_13> {
const { issuerMetadata, types, format } = opts ?? {};

if (!issuerMetadata || !issuerMetadata.credential_configurations_supported) {
Expand All @@ -50,7 +50,7 @@ export function getSupportedCredential(opts?: {
const formats = Array.isArray(format) ? format : format ? [format] : [];
const normalizedTypes = Array.isArray(types) ? types : types ? [types] : [];

const filteredConfigs: Record<string, CredentialSupported> = {};
const filteredConfigs: Record<string, CredentialConfigurationSupportedV1_0_13> = {};
Object.entries(configurations).forEach(([key, value]) => {
const isTypeMatch = normalizedTypes.length === 0 || normalizedTypes.includes(key);
const isFormatMatch = formats.length === 0 || formats.includes(value.format);
Expand Down

0 comments on commit a2b3c22

Please sign in to comment.