Skip to content

Commit

Permalink
chore: Add function to extract types from credential request
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Aug 18, 2023
1 parent 79f626a commit 14d6461
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions packages/common/lib/functions/CredentialRequestUtil.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { CredentialRequestV1_0_11 } from '../types';

export function getIssuerStateAndPreAuthCode(credentialRequest: CredentialRequestV1_0_11) {
console.log('nothing yet: ' + credentialRequest);
export function getTypesFromRequest(credentialRequest: CredentialRequestV1_0_11, opts?: { filterVerifiableCredential: boolean }) {
const types = 'types' in credentialRequest ? credentialRequest.types : credentialRequest.credential_definition.types;
if (!types || types.length === 0) {
throw Error('Could not deduce types from credential request');
}
if (opts?.filterVerifiableCredential) {
return types.filter((type) => type !== 'VerifiableCredential');
}
return types;
}
1 change: 1 addition & 0 deletions packages/common/lib/functions/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './CredentialRequestUtil';
export * from './CredentialOfferUtil';
export * from './Encoding';
export * from './TypeConversionUtils';
3 changes: 1 addition & 2 deletions packages/common/lib/types/v1_0_11.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ export interface CredentialOfferLdpVcV1_0_11 extends CommonCredentialOfferPayloa

export type CredentialOfferJwtVcV1_0_11 = CommonCredentialOfferPayloadV1_0_11;

export type CredentialOfferPayloadV1_0_11 = CommonCredentialOfferPayloadV1_0_11 &
(CredentialOfferLdpVcV1_0_11 | CredentialOfferJwtVcV1_0_11);
export type CredentialOfferPayloadV1_0_11 = CommonCredentialOfferPayloadV1_0_11 & (CredentialOfferLdpVcV1_0_11 | CredentialOfferJwtVcV1_0_11);

export type CredentialRequestV1_0_11 = CommonCredentialRequest & (CredentialRequestJwtVc | CredentialRequestLdpVc);

Expand Down

0 comments on commit 14d6461

Please sign in to comment.