Skip to content

Commit

Permalink
Refactor authorization_details in jwt_vc_json format: Move vct and cl…
Browse files Browse the repository at this point in the history
…aims properties to same level as authorization_details
  • Loading branch information
Vijay Shiyani committed Feb 13, 2024
1 parent 4742c6f commit 39705b2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/types/create-credential-offer.types.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export type CredentialMetadata = {
credential_definition: {
type?: string[];
vct?: string;
};
display: Array<{ name: string }>;
format: string;
id: string;
types?: string[];
vct?: string;
};

export type Credential = {
Expand Down
2 changes: 1 addition & 1 deletion src/types/openid.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export enum GRANT_TYPES {
export type SupportedCredential = {
credential_definition: {
type?: string[];
vct?: string;
};
cryptographic_binding_methods_supported: string[];
cryptographic_suites_supported: string[];
Expand All @@ -24,6 +23,7 @@ export type SupportedCredential = {
];
format: string;
id: string;
vct?: string;
};

export type SupportedCredentialMap = {
Expand Down
10 changes: 4 additions & 6 deletions src/utils/openid/vci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class CredentialOfferError extends Error {
}

function parseSupportedCredential(credentialIdentifier: string, credential: CredentialMetadata): CredentialChoice {
const credentialTypes = credential.credential_definition.type ??
credential.credential_definition.type ?? [credential.credential_definition.vct as string];
const credentialTypes = credential?.credential_definition?.type ??
credential?.credential_definition?.type ?? [credential.vct as string];

const vc: Credential = {
credentialIdentifier,
Expand Down Expand Up @@ -170,9 +170,9 @@ async function exchangePreauthCodeWithToken(endpoint: string, code: string, user
type CredentialOfferMetadata = {
credential_definition?: {
type?: string[];
vct?: string;
};
format: string;
vct?: string;
};

export async function issueVC(issuer: string, endpoint: string, token: TokenSet, metadata: CredentialOfferMetadata) {
Expand Down Expand Up @@ -215,10 +215,8 @@ export function getCredentialInfo(

return isVcSdJwt(credentialMetadata)
? {
credential_definition: {
vct: credentialMetadata.credential_definition.vct as string,
},
format: credentialMetadata.format,
vct: credentialMetadata.vct,
}
: {
credential_definition: {
Expand Down

0 comments on commit 39705b2

Please sign in to comment.