@sphereon/oid4vci-common
Advanced tools
Comparing version 0.4.1-unstable.262 to 0.4.1-unstable.263
@@ -28,3 +28,3 @@ "use strict"; | ||
} | ||
if (credentialsSupported === undefined) { | ||
if (credentialsSupported === undefined || credentialsSupported.length === 0) { | ||
return []; | ||
@@ -42,3 +42,3 @@ } | ||
if (typeof offerType === 'string') { | ||
const supported = credentialsSupported.find((sup) => sup.id === offerType); | ||
const supported = credentialsSupported.find((sup) => sup.id === offerType || sup.types.includes(offerType)); | ||
if (supported) { | ||
@@ -49,3 +49,3 @@ credentialSupportedOverlap.push(supported); | ||
else { | ||
const supported = credentialsSupported.find((sup) => sup.types == offerType.types && sup.format === offerType.format); | ||
const supported = credentialsSupported.find((sup) => arrayEqualsIgnoreOrder(sup.types, offerType.types) && sup.format === offerType.format); | ||
if (supported) { | ||
@@ -59,2 +59,14 @@ credentialSupportedOverlap.push(supported); | ||
exports.getSupportedCredentials = getSupportedCredentials; | ||
function arrayEqualsIgnoreOrder(a, b) { | ||
if (a.length !== b.length) | ||
return false; | ||
const uniqueValues = new Set([...a, ...b]); | ||
for (const v of uniqueValues) { | ||
const aCount = a.filter((e) => e === v).length; | ||
const bCount = b.filter((e) => e === v).length; | ||
if (aCount !== bCount) | ||
return false; | ||
} | ||
return true; | ||
} | ||
function credentialsSupportedV8ToV11(supportedV8) { | ||
@@ -61,0 +73,0 @@ return Object.entries(supportedV8).flatMap((entry) => { |
@@ -39,3 +39,3 @@ import { | ||
if (credentialsSupported === undefined) { | ||
if (credentialsSupported === undefined || credentialsSupported.length === 0) { | ||
return []; | ||
@@ -53,3 +53,3 @@ } else if (!credentialTypes || credentialTypes.length === 0) { | ||
if (typeof offerType === 'string') { | ||
const supported = credentialsSupported.find((sup) => sup.id === offerType); | ||
const supported = credentialsSupported.find((sup) => sup.id === offerType || sup.types.includes(offerType)); | ||
if (supported) { | ||
@@ -59,3 +59,3 @@ credentialSupportedOverlap.push(supported); | ||
} else { | ||
const supported = credentialsSupported.find((sup) => sup.types == offerType.types && sup.format === offerType.format); | ||
const supported = credentialsSupported.find((sup) => arrayEqualsIgnoreOrder(sup.types, offerType.types) && sup.format === offerType.format); | ||
if (supported) { | ||
@@ -69,2 +69,13 @@ credentialSupportedOverlap.push(supported); | ||
function arrayEqualsIgnoreOrder(a: string[], b: string[]) { | ||
if (a.length !== b.length) return false; | ||
const uniqueValues = new Set([...a, ...b]); | ||
for (const v of uniqueValues) { | ||
const aCount = a.filter((e) => e === v).length; | ||
const bCount = b.filter((e) => e === v).length; | ||
if (aCount !== bCount) return false; | ||
} | ||
return true; | ||
} | ||
export function credentialsSupportedV8ToV11(supportedV8: CredentialSupportedTypeV1_0_08): CredentialSupported[] { | ||
@@ -71,0 +82,0 @@ return Object.entries(supportedV8).flatMap((entry) => { |
{ | ||
"name": "@sphereon/oid4vci-common", | ||
"version": "0.4.1-unstable.262+4fc4398", | ||
"version": "0.4.1-unstable.263+9059375", | ||
"description": "OpenID 4 Verifiable Credential Issuance Common Types", | ||
@@ -48,3 +48,3 @@ "source": "lib/index.ts", | ||
}, | ||
"gitHead": "4fc4398509aa08b04cc4a17eb04884aad15a9079" | ||
"gitHead": "905937514221e72c7ad8a761c7d74b8cc7185744" | ||
} |
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
219426
3230