@sphereon/oid4vci-common
Advanced tools
Comparing version 0.7.1-next.12 to 0.7.1-next.13
@@ -11,3 +11,3 @@ import { CredentialIssuerMetadata, CredentialSupported, CredentialSupportedTypeV1_0_08, CredentialSupportedV1_0_08, IssuerMetadataV1_0_08, MetadataDisplay, OID4VCICredentialFormat, OpenId4VCIVersion } from '../types'; | ||
version: OpenId4VCIVersion; | ||
types?: string[]; | ||
types?: string | string[]; | ||
format?: (OID4VCICredentialFormat | string) | (OID4VCICredentialFormat | string)[]; | ||
@@ -14,0 +14,0 @@ }): CredentialSupported[]; |
@@ -44,6 +44,17 @@ "use strict"; | ||
*/ | ||
const initiationTypes = version === types_1.OpenId4VCIVersion.VER_1_0_08 && !types ? formats : types; | ||
const supportedFormats = formats !== null && formats !== void 0 ? formats : ['jwt_vc_json', 'jwt_vc_json-ld', 'ldp_vc']; | ||
let initiationTypes; | ||
if (opts === null || opts === void 0 ? void 0 : opts.types) { | ||
if (typeof opts.types === 'string') { | ||
initiationTypes = [opts.types]; | ||
} | ||
else { | ||
initiationTypes = opts.types; | ||
} | ||
} | ||
if (version === types_1.OpenId4VCIVersion.VER_1_0_08 && (!initiationTypes || (initiationTypes === null || initiationTypes === void 0 ? void 0 : initiationTypes.length) === 0)) { | ||
initiationTypes = formats; | ||
} | ||
const supportedFormats = formats && formats.length > 0 ? formats : ['jwt_vc_json', 'jwt_vc_json-ld', 'ldp_vc']; | ||
const credentialSupportedOverlap = []; | ||
if (initiationTypes.length === 1) { | ||
if (initiationTypes && Array.isArray(initiationTypes) && initiationTypes.length === 1) { | ||
const supported = credentialsSupported.filter((sup) => sup.id === initiationTypes[0] || (arrayEqualsIgnoreOrder(sup.types, initiationTypes) && sup.types.includes(initiationTypes[0]))); | ||
@@ -56,3 +67,3 @@ if (supported) { | ||
// Make sure we include Verifiable Credential both on the offer side as well as in the metadata side, to ensure consistency of the issuer does not. | ||
if (!initiationTypes.includes('VerifiableCredential')) { | ||
if (initiationTypes && !initiationTypes.includes('VerifiableCredential')) { | ||
initiationTypes.push('VerifiableCredential'); | ||
@@ -65,3 +76,3 @@ } | ||
} | ||
return arrayEqualsIgnoreOrder(supTypes, initiationTypes) && supportedFormats.includes(sup.format); | ||
return (!initiationTypes || arrayEqualsIgnoreOrder(supTypes, initiationTypes)) && supportedFormats.includes(sup.format); | ||
}); | ||
@@ -68,0 +79,0 @@ if (supported) { |
@@ -10,4 +10,4 @@ import { | ||
OID4VCICredentialFormat, | ||
OpenId4VCIVersion, | ||
} from '../types'; | ||
OpenId4VCIVersion | ||
} from '../types' | ||
@@ -29,3 +29,3 @@ export function getSupportedCredentials(opts?: { | ||
version: OpenId4VCIVersion; | ||
types?: string[]; | ||
types?: string | string[]; | ||
format?: (OID4VCICredentialFormat | string) | (OID4VCICredentialFormat | string)[]; | ||
@@ -61,9 +61,19 @@ }): CredentialSupported[] { | ||
*/ | ||
const initiationTypes = version === OpenId4VCIVersion.VER_1_0_08 && !types ? formats : types; | ||
const supportedFormats: (CredentialOfferFormat | string)[] = formats ?? ['jwt_vc_json', 'jwt_vc_json-ld', 'ldp_vc']; | ||
let initiationTypes :string[] | undefined | ||
if (opts?.types) { | ||
if (typeof opts.types === 'string') { | ||
initiationTypes = [opts.types] | ||
} else { | ||
initiationTypes = opts.types | ||
} | ||
} | ||
if (version === OpenId4VCIVersion.VER_1_0_08 && (!initiationTypes || initiationTypes?.length === 0)) { | ||
initiationTypes = formats | ||
} | ||
const supportedFormats: (CredentialOfferFormat | string)[] = formats && formats.length > 0 ? formats : ['jwt_vc_json', 'jwt_vc_json-ld', 'ldp_vc']; | ||
const credentialSupportedOverlap: CredentialSupported[] = []; | ||
if (initiationTypes.length === 1) { | ||
if (initiationTypes && Array.isArray(initiationTypes) && initiationTypes.length === 1) { | ||
const supported = credentialsSupported.filter( | ||
(sup) => sup.id === initiationTypes[0] || (arrayEqualsIgnoreOrder(sup.types, initiationTypes) && sup.types.includes(initiationTypes[0])), | ||
(sup) => sup.id === initiationTypes![0] || (arrayEqualsIgnoreOrder(sup.types, initiationTypes!) && sup.types.includes(initiationTypes![0])), | ||
); | ||
@@ -75,3 +85,3 @@ if (supported) { | ||
// Make sure we include Verifiable Credential both on the offer side as well as in the metadata side, to ensure consistency of the issuer does not. | ||
if (!initiationTypes.includes('VerifiableCredential')) { | ||
if (initiationTypes && !initiationTypes.includes('VerifiableCredential')) { | ||
initiationTypes.push('VerifiableCredential'); | ||
@@ -84,3 +94,3 @@ } | ||
} | ||
return arrayEqualsIgnoreOrder(supTypes, initiationTypes) && supportedFormats.includes(sup.format); | ||
return (!initiationTypes || arrayEqualsIgnoreOrder(supTypes, initiationTypes)) && supportedFormats.includes(sup.format); | ||
}); | ||
@@ -87,0 +97,0 @@ if (supported) { |
{ | ||
"name": "@sphereon/oid4vci-common", | ||
"version": "0.7.1-next.12+6f4f23a", | ||
"version": "0.7.1-next.13+b79027f", | ||
"description": "OpenID 4 Verifiable Credential Issuance Common Types", | ||
@@ -48,3 +48,3 @@ "source": "lib/index.ts", | ||
}, | ||
"gitHead": "6f4f23ada8952baa47fcf5ca1f28ec67682ff7f3" | ||
"gitHead": "b79027fe601ecccb1373ba399419e14f5ec2d7ff" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
241327
3610