@sphereon/oid4vci-common 0.7.0 → 0.7.1-next.11
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.
- package/dist/functions/Encoding.d.ts.map +1 -1
- package/dist/functions/Encoding.js +0 -1
- package/dist/functions/Encoding.js.map +1 -1
- package/dist/functions/IssuerMetadataUtils.d.ts +9 -3
- package/dist/functions/IssuerMetadataUtils.d.ts.map +1 -1
- package/dist/functions/IssuerMetadataUtils.js +41 -25
- package/dist/functions/IssuerMetadataUtils.js.map +1 -1
- package/lib/functions/Encoding.ts +0 -2
- package/lib/functions/IssuerMetadataUtils.ts +47 -25
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Encoding.d.ts","sourceRoot":"","sources":["../../lib/functions/Encoding.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Encoding.d.ts","sourceRoot":"","sources":["../../lib/functions/Encoding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,mBAAmB,EAAE,mBAAmB,EAAkC,MAAM,UAAU,CAAC;AAEhH;;;;;;GAMG;AAGH,wBAAgB,gBAAgB,CAC9B,IAAI,EACA;IACE,CAAC,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CACpB,GACD,SAAS,CAAC,KAAK,CAAC,GAChB,MAAM,GACN,MAAM,EACV,IAAI,CAAC,EAAE,mBAAmB,GACzB,MAAM,CA2DR;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAMvF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Encoding.js","sourceRoot":"","sources":["../../lib/functions/Encoding.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Encoding.js","sourceRoot":"","sources":["../../lib/functions/Encoding.ts"],"names":[],"mappings":";;;AAAA,oCAAgH;AAEhH;;;;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
|
|
1
|
-
import { CredentialIssuerMetadata,
|
|
1
|
+
import { CredentialIssuerMetadata, CredentialSupported, CredentialSupportedTypeV1_0_08, CredentialSupportedV1_0_08, IssuerMetadataV1_0_08, MetadataDisplay, OID4VCICredentialFormat, OpenId4VCIVersion } from '../types';
|
|
2
2
|
export declare function getSupportedCredentials(opts?: {
|
|
3
3
|
issuerMetadata?: CredentialIssuerMetadata | IssuerMetadataV1_0_08;
|
|
4
4
|
version: OpenId4VCIVersion;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
types?: string[][];
|
|
6
|
+
format?: (OID4VCICredentialFormat | string) | (OID4VCICredentialFormat | string)[];
|
|
7
|
+
}): CredentialSupported[];
|
|
8
|
+
export declare function getSupportedCredential(opts?: {
|
|
9
|
+
issuerMetadata?: CredentialIssuerMetadata | IssuerMetadataV1_0_08;
|
|
10
|
+
version: OpenId4VCIVersion;
|
|
11
|
+
types?: string[];
|
|
12
|
+
format?: (OID4VCICredentialFormat | string) | (OID4VCICredentialFormat | string)[];
|
|
7
13
|
}): CredentialSupported[];
|
|
8
14
|
export declare function credentialsSupportedV8ToV11(supportedV8: CredentialSupportedTypeV1_0_08): CredentialSupported[];
|
|
9
15
|
export declare function credentialSupportedV8ToV11(key: string, supportedV8: CredentialSupportedV1_0_08): CredentialSupported[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IssuerMetadataUtils.d.ts","sourceRoot":"","sources":["../../lib/functions/IssuerMetadataUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,
|
|
1
|
+
{"version":3,"file":"IssuerMetadataUtils.d.ts","sourceRoot":"","sources":["../../lib/functions/IssuerMetadataUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EAExB,mBAAmB,EACnB,8BAA8B,EAC9B,0BAA0B,EAC1B,qBAAqB,EACrB,eAAe,EACf,uBAAuB,EACvB,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,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,CAAC,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAC,uBAAuB,GAAG,MAAM,CAAC,EAAE,CAAC;CACpF,GAAG,mBAAmB,EAAE,CAKxB;AAED,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE;IAC5C,cAAc,CAAC,EAAE,wBAAwB,GAAG,qBAAqB,CAAC;IAClE,OAAO,EAAE,iBAAiB,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAC,uBAAuB,GAAG,MAAM,CAAC,EAAE,CAAC;CACpF,GAAG,mBAAmB,EAAE,CAyDxB;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;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,wBAAwB,GAAG,qBAAqB,EAAE,IAAI,CAAC,EAAE;IAAE,WAAW,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,eAAe,EAAE,CAMjJ"}
|
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getIssuerDisplays = exports.credentialSupportedV8ToV11 = exports.credentialsSupportedV8ToV11 = exports.getSupportedCredentials = void 0;
|
|
3
|
+
exports.getIssuerDisplays = exports.credentialSupportedV8ToV11 = exports.credentialsSupportedV8ToV11 = exports.getSupportedCredential = exports.getSupportedCredentials = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
function getSupportedCredentials(opts) {
|
|
6
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.types) && Array.isArray(opts === null || opts === void 0 ? void 0 : opts.types)) {
|
|
7
|
+
return opts.types.flatMap((types) => getSupportedCredential(Object.assign(Object.assign({}, opts), { types })));
|
|
8
|
+
}
|
|
9
|
+
return getSupportedCredential(opts ? Object.assign(Object.assign({}, opts), { types: undefined }) : undefined);
|
|
10
|
+
}
|
|
11
|
+
exports.getSupportedCredentials = getSupportedCredentials;
|
|
12
|
+
function getSupportedCredential(opts) {
|
|
6
13
|
const { issuerMetadata } = opts !== null && opts !== void 0 ? opts : {};
|
|
14
|
+
let formats;
|
|
15
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.format) && Array.isArray(opts.format)) {
|
|
16
|
+
formats = opts.format;
|
|
17
|
+
}
|
|
18
|
+
else if ((opts === null || opts === void 0 ? void 0 : opts.format) && !Array.isArray(opts.format)) {
|
|
19
|
+
formats = [opts.format];
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
formats = [];
|
|
23
|
+
}
|
|
7
24
|
let credentialsSupported;
|
|
8
25
|
if (!issuerMetadata) {
|
|
9
26
|
return [];
|
|
10
27
|
}
|
|
11
|
-
const { version,
|
|
28
|
+
const { version, types } = opts !== null && opts !== void 0 ? opts : { version: types_1.OpenId4VCIVersion.VER_1_0_11 };
|
|
12
29
|
if (version === types_1.OpenId4VCIVersion.VER_1_0_08 || !Array.isArray(issuerMetadata.credentials_supported)) {
|
|
13
30
|
credentialsSupported = credentialsSupportedV8ToV11(issuerMetadata.credentials_supported);
|
|
14
|
-
/* const credentialsSupportedV8: CredentialSupportedV1_0_08 = credentialsSupported as CredentialSupportedV1_0_08
|
|
15
|
-
// const initiationTypes = credentialTypes.map(type => typeof type === 'string' ? [type] : type.types)
|
|
16
|
-
const supported: IssuerCredentialSubject = {}
|
|
17
|
-
for (const [key, value] of Object.entries(credentialsSupportedV8)) {
|
|
18
|
-
if (initiationTypes.find((type) => (typeof type === 'string' ? type === key : type.types.includes(key)))) {
|
|
19
|
-
supported[key] = value
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
// todo: fix this later. we're returning CredentialSupportedV1_0_08 as a list of CredentialSupported (for v09 onward)
|
|
23
|
-
return supported as unknown as CredentialSupported[]*/
|
|
24
31
|
}
|
|
25
32
|
else {
|
|
26
33
|
credentialsSupported = issuerMetadata.credentials_supported;
|
|
@@ -28,31 +35,40 @@ function getSupportedCredentials(opts) {
|
|
|
28
35
|
if (credentialsSupported === undefined || credentialsSupported.length === 0) {
|
|
29
36
|
return [];
|
|
30
37
|
}
|
|
31
|
-
else if (!
|
|
38
|
+
else if (!types || types.length === 0) {
|
|
32
39
|
return credentialsSupported;
|
|
33
40
|
}
|
|
34
41
|
/**
|
|
35
42
|
* the following (not array part is a legacy code from version 1_0-08 which JFF plugfest 2 implementors used)
|
|
36
43
|
*/
|
|
37
|
-
const initiationTypes =
|
|
44
|
+
const initiationTypes = version === types_1.OpenId4VCIVersion.VER_1_0_08 && !types ? formats : types;
|
|
45
|
+
const supportedFormats = formats !== null && formats !== void 0 ? formats : ['jwt_vc_json', 'jwt_vc_json-ld', 'ldp_vc'];
|
|
38
46
|
const credentialSupportedOverlap = [];
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
if (initiationTypes.length === 1) {
|
|
48
|
+
const supported = credentialsSupported.filter((sup) => sup.id === initiationTypes[0] || (arrayEqualsIgnoreOrder(sup.types, initiationTypes) && sup.types.includes(initiationTypes[0])));
|
|
49
|
+
if (supported) {
|
|
50
|
+
credentialSupportedOverlap.push(...supported);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// 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.
|
|
55
|
+
if (!initiationTypes.includes('VerifiableCredential')) {
|
|
56
|
+
initiationTypes.push('VerifiableCredential');
|
|
45
57
|
}
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
49
|
-
|
|
58
|
+
const supported = credentialsSupported.filter((sup) => {
|
|
59
|
+
const supTypes = sup.types;
|
|
60
|
+
if (!supTypes.includes('VerifiableCredential')) {
|
|
61
|
+
supTypes.push('VerifiableCredential');
|
|
50
62
|
}
|
|
63
|
+
return arrayEqualsIgnoreOrder(supTypes, initiationTypes) && supportedFormats.includes(sup.format);
|
|
64
|
+
});
|
|
65
|
+
if (supported) {
|
|
66
|
+
credentialSupportedOverlap.push(...supported);
|
|
51
67
|
}
|
|
52
68
|
}
|
|
53
69
|
return credentialSupportedOverlap;
|
|
54
70
|
}
|
|
55
|
-
exports.
|
|
71
|
+
exports.getSupportedCredential = getSupportedCredential;
|
|
56
72
|
function arrayEqualsIgnoreOrder(a, b) {
|
|
57
73
|
if (a.length !== b.length)
|
|
58
74
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IssuerMetadataUtils.js","sourceRoot":"","sources":["../../lib/functions/IssuerMetadataUtils.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"IssuerMetadataUtils.js","sourceRoot":"","sources":["../../lib/functions/IssuerMetadataUtils.ts"],"names":[],"mappings":";;;AAAA,oCAUkB;AAElB,SAAgB,uBAAuB,CAAC,IAKvC;IACC,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,KAAI,KAAK,CAAC,OAAO,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAC,EAAE;QAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,sBAAsB,iCAAM,IAAI,KAAE,KAAK,IAAG,CAAC,CAAC;KAClF;IACD,OAAO,sBAAsB,CAAC,IAAI,CAAC,CAAC,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CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA,EAAA,CAAC,CAAC;AACxH,CAAC;AAND,8CAMC"}
|
|
@@ -6,59 +6,81 @@ import {
|
|
|
6
6
|
CredentialSupportedV1_0_08,
|
|
7
7
|
IssuerMetadataV1_0_08,
|
|
8
8
|
MetadataDisplay,
|
|
9
|
+
OID4VCICredentialFormat,
|
|
9
10
|
OpenId4VCIVersion,
|
|
10
11
|
} from '../types';
|
|
11
12
|
|
|
12
13
|
export function getSupportedCredentials(opts?: {
|
|
13
14
|
issuerMetadata?: CredentialIssuerMetadata | IssuerMetadataV1_0_08;
|
|
14
15
|
version: OpenId4VCIVersion;
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
types?: string[][];
|
|
17
|
+
format?: (OID4VCICredentialFormat | string) | (OID4VCICredentialFormat | string)[];
|
|
18
|
+
}): CredentialSupported[] {
|
|
19
|
+
if (opts?.types && Array.isArray(opts?.types)) {
|
|
20
|
+
return opts.types.flatMap((types) => getSupportedCredential({ ...opts, types }));
|
|
21
|
+
}
|
|
22
|
+
return getSupportedCredential(opts ? { ...opts, types: undefined } : undefined);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function getSupportedCredential(opts?: {
|
|
26
|
+
issuerMetadata?: CredentialIssuerMetadata | IssuerMetadataV1_0_08;
|
|
27
|
+
version: OpenId4VCIVersion;
|
|
28
|
+
types?: string[];
|
|
29
|
+
format?: (OID4VCICredentialFormat | string) | (OID4VCICredentialFormat | string)[];
|
|
17
30
|
}): CredentialSupported[] {
|
|
18
31
|
const { issuerMetadata } = opts ?? {};
|
|
32
|
+
let formats: (OID4VCICredentialFormat | string)[];
|
|
33
|
+
if (opts?.format && Array.isArray(opts.format)) {
|
|
34
|
+
formats = opts.format;
|
|
35
|
+
} else if (opts?.format && !Array.isArray(opts.format)) {
|
|
36
|
+
formats = [opts.format];
|
|
37
|
+
} else {
|
|
38
|
+
formats = [];
|
|
39
|
+
}
|
|
19
40
|
let credentialsSupported: CredentialSupported[];
|
|
20
41
|
if (!issuerMetadata) {
|
|
21
42
|
return [];
|
|
22
43
|
}
|
|
23
|
-
const { version,
|
|
44
|
+
const { version, types } = opts ?? { version: OpenId4VCIVersion.VER_1_0_11 };
|
|
24
45
|
if (version === OpenId4VCIVersion.VER_1_0_08 || !Array.isArray(issuerMetadata.credentials_supported)) {
|
|
25
46
|
credentialsSupported = credentialsSupportedV8ToV11((issuerMetadata as IssuerMetadataV1_0_08).credentials_supported);
|
|
26
|
-
/* const credentialsSupportedV8: CredentialSupportedV1_0_08 = credentialsSupported as CredentialSupportedV1_0_08
|
|
27
|
-
// const initiationTypes = credentialTypes.map(type => typeof type === 'string' ? [type] : type.types)
|
|
28
|
-
const supported: IssuerCredentialSubject = {}
|
|
29
|
-
for (const [key, value] of Object.entries(credentialsSupportedV8)) {
|
|
30
|
-
if (initiationTypes.find((type) => (typeof type === 'string' ? type === key : type.types.includes(key)))) {
|
|
31
|
-
supported[key] = value
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
// todo: fix this later. we're returning CredentialSupportedV1_0_08 as a list of CredentialSupported (for v09 onward)
|
|
35
|
-
return supported as unknown as CredentialSupported[]*/
|
|
36
47
|
} else {
|
|
37
48
|
credentialsSupported = (issuerMetadata as CredentialIssuerMetadata).credentials_supported;
|
|
38
49
|
}
|
|
39
50
|
|
|
40
51
|
if (credentialsSupported === undefined || credentialsSupported.length === 0) {
|
|
41
52
|
return [];
|
|
42
|
-
} else if (!
|
|
53
|
+
} else if (!types || types.length === 0) {
|
|
43
54
|
return credentialsSupported;
|
|
44
55
|
}
|
|
45
56
|
/**
|
|
46
57
|
* the following (not array part is a legacy code from version 1_0-08 which JFF plugfest 2 implementors used)
|
|
47
58
|
*/
|
|
48
|
-
const initiationTypes =
|
|
59
|
+
const initiationTypes = version === OpenId4VCIVersion.VER_1_0_08 && !types ? formats : types;
|
|
60
|
+
const supportedFormats: (CredentialOfferFormat | string)[] = formats ?? ['jwt_vc_json', 'jwt_vc_json-ld', 'ldp_vc'];
|
|
49
61
|
|
|
50
62
|
const credentialSupportedOverlap: CredentialSupported[] = [];
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
if (initiationTypes.length === 1) {
|
|
64
|
+
const supported = credentialsSupported.filter(
|
|
65
|
+
(sup) => sup.id === initiationTypes[0] || (arrayEqualsIgnoreOrder(sup.types, initiationTypes) && sup.types.includes(initiationTypes[0])),
|
|
66
|
+
);
|
|
67
|
+
if (supported) {
|
|
68
|
+
credentialSupportedOverlap.push(...supported);
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
// 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.
|
|
72
|
+
if (!initiationTypes.includes('VerifiableCredential')) {
|
|
73
|
+
initiationTypes.push('VerifiableCredential');
|
|
74
|
+
}
|
|
75
|
+
const supported = credentialsSupported.filter((sup) => {
|
|
76
|
+
const supTypes = sup.types;
|
|
77
|
+
if (!supTypes.includes('VerifiableCredential')) {
|
|
78
|
+
supTypes.push('VerifiableCredential');
|
|
61
79
|
}
|
|
80
|
+
return arrayEqualsIgnoreOrder(supTypes, initiationTypes) && supportedFormats.includes(sup.format);
|
|
81
|
+
});
|
|
82
|
+
if (supported) {
|
|
83
|
+
credentialSupportedOverlap.push(...supported);
|
|
62
84
|
}
|
|
63
85
|
}
|
|
64
86
|
return credentialSupportedOverlap;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/oid4vci-common",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1-next.11+9675a47",
|
|
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": "
|
|
48
|
+
"gitHead": "9675a47fdeea8cfb9b3517b489116b6aeb5d2f99"
|
|
49
49
|
}
|