@sphereon/oid4vci-common 0.4.1-unstable.261 → 0.4.1-unstable.263

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"IssuerMetadataUtils.d.ts","sourceRoot":"","sources":["../../lib/functions/IssuerMetadataUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACnB,8BAA8B,EAC9B,0BAA0B,EAC1B,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAElB,wBAAgB,uBAAuB,CAAC,IAAI,CAAC,EAAE;IAC7C,cAAc,CAAC,EAAE,wBAAwB,GAAG,qBAAqB,CAAC;IAClE,OAAO,EAAE,iBAAiB,CAAC;IAC3B,eAAe,CAAC,EAAE,CAAC,qBAAqB,GAAG,MAAM,CAAC,EAAE,CAAC;IACrD,aAAa,CAAC,EAAE,qBAAqB,GAAG,MAAM,CAAC;CAChD,GAAG,mBAAmB,EAAE,CAgDxB;AAED,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,8BAA8B,GAAG,mBAAmB,EAAE,CAM9G;AAED,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,0BAA0B,GAAG,mBAAmB,EAAE,CAgBtH"}
1
+ {"version":3,"file":"IssuerMetadataUtils.d.ts","sourceRoot":"","sources":["../../lib/functions/IssuerMetadataUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACnB,8BAA8B,EAC9B,0BAA0B,EAC1B,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAElB,wBAAgB,uBAAuB,CAAC,IAAI,CAAC,EAAE;IAC7C,cAAc,CAAC,EAAE,wBAAwB,GAAG,qBAAqB,CAAC;IAClE,OAAO,EAAE,iBAAiB,CAAC;IAC3B,eAAe,CAAC,EAAE,CAAC,qBAAqB,GAAG,MAAM,CAAC,EAAE,CAAC;IACrD,aAAa,CAAC,EAAE,qBAAqB,GAAG,MAAM,CAAC;CAChD,GAAG,mBAAmB,EAAE,CAgDxB;AAaD,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,8BAA8B,GAAG,mBAAmB,EAAE,CAM9G;AAED,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,0BAA0B,GAAG,mBAAmB,EAAE,CAgBtH"}
@@ -10,7 +10,7 @@ function getSupportedCredentials(opts) {
10
10
  }
11
11
  const { version, credentialTypes, supportedType } = opts !== null && opts !== void 0 ? opts : { version: types_1.OpenId4VCIVersion.VER_1_0_11 };
12
12
  if (version === types_1.OpenId4VCIVersion.VER_1_0_08 || !Array.isArray(issuerMetadata.credentials_supported)) {
13
- credentialsSupported = credentialsSupportedV8ToV11(issuerMetadata.credentials_supported.credentials_supported);
13
+ credentialsSupported = credentialsSupportedV8ToV11(issuerMetadata.credentials_supported);
14
14
  /* const credentialsSupportedV8: CredentialSupportedV1_0_08 = credentialsSupported as CredentialSupportedV1_0_08
15
15
  // const initiationTypes = credentialTypes.map(type => typeof type === 'string' ? [type] : type.types)
16
16
  const supported: IssuerCredentialSubject = {}
@@ -25,7 +25,7 @@ function getSupportedCredentials(opts) {
25
25
  else {
26
26
  credentialsSupported = issuerMetadata.credentials_supported;
27
27
  }
28
- if (!credentialsSupported) {
28
+ if (credentialsSupported === undefined || credentialsSupported.length === 0) {
29
29
  return [];
30
30
  }
31
31
  else if (!credentialTypes || credentialTypes.length === 0) {
@@ -38,13 +38,13 @@ function getSupportedCredentials(opts) {
38
38
  const credentialSupportedOverlap = [];
39
39
  for (const offerType of initiationTypes) {
40
40
  if (typeof offerType === 'string') {
41
- const supported = credentialsSupported.find((sup) => sup.id === offerType);
41
+ const supported = credentialsSupported.find((sup) => sup.id === offerType || sup.types.includes(offerType));
42
42
  if (supported) {
43
43
  credentialSupportedOverlap.push(supported);
44
44
  }
45
45
  }
46
46
  else {
47
- const supported = credentialsSupported.find((sup) => sup.types == offerType.types && sup.format === offerType.format);
47
+ const supported = credentialsSupported.find((sup) => arrayEqualsIgnoreOrder(sup.types, offerType.types) && sup.format === offerType.format);
48
48
  if (supported) {
49
49
  credentialSupportedOverlap.push(supported);
50
50
  }
@@ -53,6 +53,18 @@ function getSupportedCredentials(opts) {
53
53
  return credentialSupportedOverlap;
54
54
  }
55
55
  exports.getSupportedCredentials = getSupportedCredentials;
56
+ function arrayEqualsIgnoreOrder(a, b) {
57
+ if (a.length !== b.length)
58
+ return false;
59
+ const uniqueValues = new Set([...a, ...b]);
60
+ for (const v of uniqueValues) {
61
+ const aCount = a.filter((e) => e === v).length;
62
+ const bCount = b.filter((e) => e === v).length;
63
+ if (aCount !== bCount)
64
+ return false;
65
+ }
66
+ return true;
67
+ }
56
68
  function credentialsSupportedV8ToV11(supportedV8) {
57
69
  return Object.entries(supportedV8).flatMap((entry) => {
58
70
  const type = entry[0];
@@ -1 +1 @@
1
- {"version":3,"file":"IssuerMetadataUtils.js","sourceRoot":"","sources":["../../lib/functions/IssuerMetadataUtils.ts"],"names":[],"mappings":";;;AAAA,oCAQkB;AAElB,SAAgB,uBAAuB,CAAC,IAKvC;IACC,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAC;IACtC,IAAI,oBAA2C,CAAC;IAChD,IAAI,CAAC,cAAc,EAAE;QACnB,OAAO,EAAE,CAAC;KACX;IACD,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,OAAO,EAAE,yBAAiB,CAAC,UAAU,EAAE,CAAC;IACtG,IAAI,OAAO,KAAK,yBAAiB,CAAC,UAAU,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,qBAAqB,CAAC,EAAE;QACpG,oBAAoB,GAAG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AC,KAAK,EAAE,EAAE;QACvD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACxB,MAAM,sBAAsB,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACxC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC9B,MAAM,KAAK,CAAC,2BAA2B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;SAClE;QACD,IAAI,iBAAiB,GAAiC,EAAE,CAAC;QACzD,iBAAiB,iCACf,MAAM,EACN,OAAO,EAAE,WAAW,CAAC,OAAO,IACzB,sBAAsB,KACzB,iBAAiB,EAAE,WAAW,CAAC,MAAM,GACtC,CAAC;QACF,OAAO,iBAAwC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC;AAhBD,gEAgBC"}
@@ -21,7 +21,7 @@ export function getSupportedCredentials(opts?: {
21
21
  }
22
22
  const { version, credentialTypes, supportedType } = opts ?? { version: OpenId4VCIVersion.VER_1_0_11 };
23
23
  if (version === OpenId4VCIVersion.VER_1_0_08 || !Array.isArray(issuerMetadata.credentials_supported)) {
24
- credentialsSupported = credentialsSupportedV8ToV11((issuerMetadata.credentials_supported as IssuerMetadataV1_0_08).credentials_supported);
24
+ credentialsSupported = credentialsSupportedV8ToV11((issuerMetadata as IssuerMetadataV1_0_08).credentials_supported);
25
25
  /* const credentialsSupportedV8: CredentialSupportedV1_0_08 = credentialsSupported as CredentialSupportedV1_0_08
26
26
  // const initiationTypes = credentialTypes.map(type => typeof type === 'string' ? [type] : type.types)
27
27
  const supported: IssuerCredentialSubject = {}
@@ -36,7 +36,7 @@ export function getSupportedCredentials(opts?: {
36
36
  credentialsSupported = (issuerMetadata as CredentialIssuerMetadata).credentials_supported;
37
37
  }
38
38
 
39
- if (!credentialsSupported) {
39
+ if (credentialsSupported === undefined || credentialsSupported.length === 0) {
40
40
  return [];
41
41
  } else if (!credentialTypes || credentialTypes.length === 0) {
42
42
  return credentialsSupported;
@@ -49,12 +49,12 @@ export function getSupportedCredentials(opts?: {
49
49
  const credentialSupportedOverlap: CredentialSupported[] = [];
50
50
  for (const offerType of initiationTypes) {
51
51
  if (typeof offerType === 'string') {
52
- const supported = credentialsSupported.find((sup) => sup.id === offerType);
52
+ const supported = credentialsSupported.find((sup) => sup.id === offerType || sup.types.includes(offerType));
53
53
  if (supported) {
54
54
  credentialSupportedOverlap.push(supported);
55
55
  }
56
56
  } else {
57
- const supported = credentialsSupported.find((sup) => sup.types == offerType.types && sup.format === offerType.format);
57
+ const supported = credentialsSupported.find((sup) => arrayEqualsIgnoreOrder(sup.types, offerType.types) && sup.format === offerType.format);
58
58
  if (supported) {
59
59
  credentialSupportedOverlap.push(supported);
60
60
  }
@@ -63,6 +63,17 @@ export function getSupportedCredentials(opts?: {
63
63
  return credentialSupportedOverlap;
64
64
  }
65
65
 
66
+ function arrayEqualsIgnoreOrder(a: string[], b: string[]) {
67
+ if (a.length !== b.length) return false;
68
+ const uniqueValues = new Set([...a, ...b]);
69
+ for (const v of uniqueValues) {
70
+ const aCount = a.filter((e) => e === v).length;
71
+ const bCount = b.filter((e) => e === v).length;
72
+ if (aCount !== bCount) return false;
73
+ }
74
+ return true;
75
+ }
76
+
66
77
  export function credentialsSupportedV8ToV11(supportedV8: CredentialSupportedTypeV1_0_08): CredentialSupported[] {
67
78
  return Object.entries(supportedV8).flatMap((entry) => {
68
79
  const type = entry[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sphereon/oid4vci-common",
3
- "version": "0.4.1-unstable.261+b06fa22",
3
+ "version": "0.4.1-unstable.263+9059375",
4
4
  "description": "OpenID 4 Verifiable Credential Issuance Common Types",
5
5
  "source": "lib/index.ts",
6
6
  "main": "dist/index.js",
@@ -45,5 +45,5 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
- "gitHead": "b06fa221bed33e69aa76ae0234779f80314f2887"
48
+ "gitHead": "905937514221e72c7ad8a761c7d74b8cc7185744"
49
49
  }