@sphereon/ssi-sdk.siopv2-oid4vp-op-auth 0.32.1-feature.SPRIND.89.53 → 0.32.1-feature.SSISDK.5.credential.offer.uri.204
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/agent/DidAuthSiopOpAuthenticator.d.ts +6 -1
- package/dist/agent/DidAuthSiopOpAuthenticator.d.ts.map +1 -1
- package/dist/agent/DidAuthSiopOpAuthenticator.js +91 -22
- package/dist/agent/DidAuthSiopOpAuthenticator.js.map +1 -1
- package/dist/services/Siopv2MachineService.d.ts +2 -0
- package/dist/services/Siopv2MachineService.d.ts.map +1 -1
- package/dist/services/Siopv2MachineService.js +97 -7
- package/dist/services/Siopv2MachineService.js.map +1 -1
- package/dist/session/OpSession.d.ts.map +1 -1
- package/dist/session/OpSession.js +2 -2
- package/dist/session/OpSession.js.map +1 -1
- package/dist/types/IDidAuthSiopOpAuthenticator.d.ts +5 -1
- package/dist/types/IDidAuthSiopOpAuthenticator.d.ts.map +1 -1
- package/dist/types/IDidAuthSiopOpAuthenticator.js.map +1 -1
- package/dist/types/siop-service/index.d.ts +2 -0
- package/dist/types/siop-service/index.d.ts.map +1 -1
- package/dist/types/siop-service/index.js.map +1 -1
- package/dist/utils/CredentialUtils.d.ts +23 -0
- package/dist/utils/CredentialUtils.d.ts.map +1 -0
- package/dist/utils/CredentialUtils.js +65 -0
- package/dist/utils/CredentialUtils.js.map +1 -0
- package/dist/utils/dcql.d.ts +5 -0
- package/dist/utils/dcql.d.ts.map +1 -0
- package/dist/utils/dcql.js +37 -0
- package/dist/utils/dcql.js.map +1 -0
- package/package.json +22 -19
- package/src/agent/DidAuthSiopOpAuthenticator.ts +113 -38
- package/src/services/Siopv2MachineService.ts +115 -12
- package/src/session/OpSession.ts +3 -2
- package/src/types/IDidAuthSiopOpAuthenticator.ts +13 -0
- package/src/types/siop-service/index.ts +2 -0
- package/src/utils/CredentialUtils.ts +71 -0
- package/src/utils/dcql.ts +36 -0
|
@@ -7,6 +7,7 @@ import { IIssuanceBranding } from '@sphereon/ssi-sdk.issuance-branding';
|
|
|
7
7
|
import { IAgentContext, IDIDManager, IIdentifier, IResolver } from '@veramo/core';
|
|
8
8
|
import { IDidAuthSiopOpAuthenticator } from '../IDidAuthSiopOpAuthenticator';
|
|
9
9
|
import { Siopv2MachineContext, Siopv2MachineInterpreter, Siopv2MachineState } from '../machine';
|
|
10
|
+
import { DcqlQuery } from 'dcql';
|
|
10
11
|
import { Hasher } from '@sphereon/ssi-types';
|
|
11
12
|
export type DidAuthSiopOpAuthenticatorOptions = {
|
|
12
13
|
presentationSignCallback?: PresentationSignCallback;
|
|
@@ -59,6 +60,7 @@ export type Siopv2AuthorizationRequestData = {
|
|
|
59
60
|
uri?: URL;
|
|
60
61
|
clientId?: string;
|
|
61
62
|
presentationDefinitions?: PresentationDefinitionWithLocation[];
|
|
63
|
+
dcqlQuery?: DcqlQuery;
|
|
62
64
|
};
|
|
63
65
|
export type SelectableCredentialsMap = Map<string, Array<SelectableCredential>>;
|
|
64
66
|
export type SelectableCredential = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/siop-service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAClC,wBAAwB,EACxB,6BAA6B,EAAE,4BAA4B,EAC5D,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAA;AAClH,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAA;AAC9F,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AACxG,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AACvE,OAAO,EAAE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vI,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/siop-service/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/siop-service/index.ts"],"names":[],"mappings":";;;AA+CA,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,0EAAqD,CAAA;IACrD,8DAAyC,CAAA;AAC3C,CAAC,EAHW,iBAAiB,iCAAjB,iBAAiB,QAG5B;AAED,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,mCAAc,CAAA;IACd,iCAAY,CAAA;AACd,CAAC,EAHW,iBAAiB,iCAAjB,iBAAiB,QAG5B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ICredential, OriginalVerifiableCredential } from '@sphereon/ssi-types';
|
|
2
|
+
import { VerifiableCredential } from '@veramo/core';
|
|
3
|
+
import { UniqueDigitalCredential } from '@sphereon/ssi-sdk.credential-store';
|
|
4
|
+
/**
|
|
5
|
+
* Return the type(s) of a VC minus the VerifiableCredential type which should always be present
|
|
6
|
+
* @param credential The input credential
|
|
7
|
+
*/
|
|
8
|
+
export declare const getCredentialTypeAsString: (credential: ICredential | VerifiableCredential) => string;
|
|
9
|
+
/**
|
|
10
|
+
* Returns a Unique Verifiable Credential (with hash) as stored in Veramo, based upon matching the id of the input VC or the proof value of the input VC
|
|
11
|
+
* @param uniqueVCs The Unique VCs to search in
|
|
12
|
+
* @param searchVC The VC to search for in the unique VCs array
|
|
13
|
+
*/
|
|
14
|
+
export declare const getMatchingUniqueDigitalCredential: (uniqueVCs: UniqueDigitalCredential[], searchVC: OriginalVerifiableCredential) => UniqueDigitalCredential | undefined;
|
|
15
|
+
type InputCredential = UniqueDigitalCredential | VerifiableCredential | ICredential | OriginalVerifiableCredential;
|
|
16
|
+
/**
|
|
17
|
+
* Get an original verifiable credential. Maps to wrapped Verifiable Credential first, to get an original JWT as Veramo stores these with a special proof value
|
|
18
|
+
* @param credential The input VC
|
|
19
|
+
*/
|
|
20
|
+
export declare const getOriginalVerifiableCredential: (credential: InputCredential) => OriginalVerifiableCredential;
|
|
21
|
+
export declare const isUniqueDigitalCredential: (credential: InputCredential) => credential is UniqueDigitalCredential;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=CredentialUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CredentialUtils.d.ts","sourceRoot":"","sources":["../../src/utils/CredentialUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,WAAW,EAAyB,4BAA4B,EAAE,MAAM,qBAAqB,CAAA;AAChI,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAA;AAE5E;;;GAGG;AACH,eAAO,MAAM,yBAAyB,eAAgB,WAAW,GAAG,oBAAoB,KAAG,MAO1F,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,cAClC,uBAAuB,EAAE,YAC1B,4BAA4B,KACrC,uBAAuB,GAAG,SAe5B,CAAA;AAED,KAAK,eAAe,GAAG,uBAAuB,GAAG,oBAAoB,GAAG,WAAW,GAAG,4BAA4B,CAAA;AAElH;;;GAGG;AAEH,eAAO,MAAM,+BAA+B,eAAgB,eAAe,KAAG,4BAS7E,CAAA;AAUD,eAAO,MAAM,yBAAyB,eAAgB,eAAe,KAAG,UAAU,IAAI,uBAErF,CAAA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isUniqueDigitalCredential = exports.getOriginalVerifiableCredential = exports.getMatchingUniqueDigitalCredential = exports.getCredentialTypeAsString = void 0;
|
|
4
|
+
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
5
|
+
/**
|
|
6
|
+
* Return the type(s) of a VC minus the VerifiableCredential type which should always be present
|
|
7
|
+
* @param credential The input credential
|
|
8
|
+
*/
|
|
9
|
+
const getCredentialTypeAsString = (credential) => {
|
|
10
|
+
if (!credential.type) {
|
|
11
|
+
return 'Verifiable Credential';
|
|
12
|
+
}
|
|
13
|
+
else if (typeof credential.type === 'string') {
|
|
14
|
+
return credential.type;
|
|
15
|
+
}
|
|
16
|
+
return credential.type.filter((type) => type !== 'VerifiableCredential').join(', ');
|
|
17
|
+
};
|
|
18
|
+
exports.getCredentialTypeAsString = getCredentialTypeAsString;
|
|
19
|
+
/**
|
|
20
|
+
* Returns a Unique Verifiable Credential (with hash) as stored in Veramo, based upon matching the id of the input VC or the proof value of the input VC
|
|
21
|
+
* @param uniqueVCs The Unique VCs to search in
|
|
22
|
+
* @param searchVC The VC to search for in the unique VCs array
|
|
23
|
+
*/
|
|
24
|
+
const getMatchingUniqueDigitalCredential = (uniqueVCs, searchVC) => {
|
|
25
|
+
// Since an ID is optional in a VC according to VCDM, and we really need the matches, we have a fallback match on something which is guaranteed to be unique for any VC (the proof(s))
|
|
26
|
+
return uniqueVCs.find((uniqueVC) => {
|
|
27
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
28
|
+
return (typeof searchVC !== 'string' &&
|
|
29
|
+
(uniqueVC.id === searchVC.id ||
|
|
30
|
+
uniqueVC.originalVerifiableCredential.proof === searchVC.proof)) ||
|
|
31
|
+
(typeof searchVC === 'string' && ((_b = (_a = uniqueVC.uniformVerifiableCredential) === null || _a === void 0 ? void 0 : _a.proof) === null || _b === void 0 ? void 0 : _b.jwt) === searchVC) ||
|
|
32
|
+
// We are ignoring the signature of the sd-jwt as PEX signs the vc again and it will not match anymore with the jwt in the proof of the stored jsonld vc
|
|
33
|
+
(typeof searchVC === 'string' &&
|
|
34
|
+
ssi_types_1.CredentialMapper.isSdJwtEncoded(searchVC) &&
|
|
35
|
+
((_c = uniqueVC.uniformVerifiableCredential) === null || _c === void 0 ? void 0 : _c.proof) &&
|
|
36
|
+
'jwt' in uniqueVC.uniformVerifiableCredential.proof &&
|
|
37
|
+
((_f = (_e = (_d = uniqueVC.uniformVerifiableCredential.proof.jwt) === null || _d === void 0 ? void 0 : _d.split('.')) === null || _e === void 0 ? void 0 : _e.slice(0, 2)) === null || _f === void 0 ? void 0 : _f.join('.')) === ((_h = (_g = searchVC.split('.')) === null || _g === void 0 ? void 0 : _g.slice(0, 2)) === null || _h === void 0 ? void 0 : _h.join('.')));
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
exports.getMatchingUniqueDigitalCredential = getMatchingUniqueDigitalCredential;
|
|
41
|
+
/**
|
|
42
|
+
* Get an original verifiable credential. Maps to wrapped Verifiable Credential first, to get an original JWT as Veramo stores these with a special proof value
|
|
43
|
+
* @param credential The input VC
|
|
44
|
+
*/
|
|
45
|
+
const getOriginalVerifiableCredential = (credential) => {
|
|
46
|
+
if ((0, exports.isUniqueDigitalCredential)(credential)) {
|
|
47
|
+
if (!credential.originalVerifiableCredential) {
|
|
48
|
+
throw new Error('originalVerifiableCredential is not defined in UniqueDigitalCredential');
|
|
49
|
+
}
|
|
50
|
+
return getCredentialFromProofOrWrapped(credential.originalVerifiableCredential);
|
|
51
|
+
}
|
|
52
|
+
return getCredentialFromProofOrWrapped(credential);
|
|
53
|
+
};
|
|
54
|
+
exports.getOriginalVerifiableCredential = getOriginalVerifiableCredential;
|
|
55
|
+
const getCredentialFromProofOrWrapped = (cred, hasher) => {
|
|
56
|
+
if (typeof cred === 'object' && 'proof' in cred && 'jwt' in cred.proof && ssi_types_1.CredentialMapper.isSdJwtEncoded(cred.proof.jwt)) {
|
|
57
|
+
return cred.proof.jwt;
|
|
58
|
+
}
|
|
59
|
+
return ssi_types_1.CredentialMapper.toWrappedVerifiableCredential(cred, { hasher }).original;
|
|
60
|
+
};
|
|
61
|
+
const isUniqueDigitalCredential = (credential) => {
|
|
62
|
+
return credential.digitalCredential !== undefined;
|
|
63
|
+
};
|
|
64
|
+
exports.isUniqueDigitalCredential = isUniqueDigitalCredential;
|
|
65
|
+
//# sourceMappingURL=CredentialUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CredentialUtils.js","sourceRoot":"","sources":["../../src/utils/CredentialUtils.ts"],"names":[],"mappings":";;;AAAA,mDAAgI;AAIhI;;;GAGG;AACI,MAAM,yBAAyB,GAAG,CAAC,UAA8C,EAAU,EAAE;IAClG,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QACrB,OAAO,uBAAuB,CAAA;IAChC,CAAC;SAAM,IAAI,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC/C,OAAO,UAAU,CAAC,IAAI,CAAA;IACxB,CAAC;IACD,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACtG,CAAC,CAAA;AAPY,QAAA,yBAAyB,6BAOrC;AAED;;;;GAIG;AACI,MAAM,kCAAkC,GAAG,CAChD,SAAoC,EACpC,QAAsC,EACD,EAAE;IACvC,sLAAsL;IACtL,OAAO,SAAS,CAAC,IAAI,CACnB,CAAC,QAAiC,EAAE,EAAE;;QACpC,OAAA,CAAC,OAAO,QAAQ,KAAK,QAAQ;YAC3B,CAAC,QAAQ,CAAC,EAAE,KAA6B,QAAS,CAAC,EAAE;gBAClD,QAAQ,CAAC,4BAAqD,CAAC,KAAK,KAA6B,QAAS,CAAC,KAAK,CAAC,CAAC;YACvH,CAAC,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAA,MAAA,MAAC,QAAQ,CAAC,2BAAoD,0CAAE,KAAK,0CAAE,GAAG,MAAK,QAAQ,CAAC;YACzH,wJAAwJ;YACxJ,CAAC,OAAO,QAAQ,KAAK,QAAQ;gBAC3B,4BAAgB,CAAC,cAAc,CAAC,QAAQ,CAAC;iBACzC,MAAA,QAAQ,CAAC,2B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AAE,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAA;AAClH,CAAC,CAAA;AAEM,MAAM,yBAAyB,GAAG,CAAC,UAA2B,EAAyC,EAAE;IAC9G,OAAQ,UAAsC,CAAC,iBAAiB,KAAK,SAAS,CAAA;AAChF,CAAC,CAAA;AAFY,QAAA,yBAAyB,6BAErC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { UniqueDigitalCredential } from '@sphereon/ssi-sdk.credential-store';
|
|
2
|
+
import { DcqlCredential } from 'dcql';
|
|
3
|
+
import { Hasher, OriginalVerifiableCredential } from '@sphereon/ssi-types';
|
|
4
|
+
export declare function convertToDcqlCredentials(credential: UniqueDigitalCredential | OriginalVerifiableCredential, hasher?: Hasher): DcqlCredential;
|
|
5
|
+
//# sourceMappingURL=dcql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dcql.d.ts","sourceRoot":"","sources":["../../src/utils/dcql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAA;AAC5E,OAAO,EAAE,cAAc,EAA8C,MAAM,MAAM,CAAA;AACjF,OAAO,EAAoB,MAAM,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAA;AAG5F,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,uBAAuB,GAAG,4BAA4B,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,cAAc,CA8B5I"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToDcqlCredentials = convertToDcqlCredentials;
|
|
4
|
+
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
5
|
+
const CredentialUtils_1 = require("./CredentialUtils");
|
|
6
|
+
function convertToDcqlCredentials(credential, hasher) {
|
|
7
|
+
let payload;
|
|
8
|
+
if ((0, CredentialUtils_1.isUniqueDigitalCredential)(credential)) {
|
|
9
|
+
if (!credential.originalVerifiableCredential) {
|
|
10
|
+
throw new Error('originalVerifiableCredential is not defined in UniqueDigitalCredential');
|
|
11
|
+
}
|
|
12
|
+
payload = ssi_types_1.CredentialMapper.decodeVerifiableCredential(credential.originalVerifiableCredential, hasher);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
payload = ssi_types_1.CredentialMapper.decodeVerifiableCredential(credential, hasher);
|
|
16
|
+
}
|
|
17
|
+
if (!payload) {
|
|
18
|
+
throw new Error('No payload found');
|
|
19
|
+
}
|
|
20
|
+
if ('decodedPayload' in payload && payload.decodedPayload) {
|
|
21
|
+
payload = payload.decodedPayload;
|
|
22
|
+
}
|
|
23
|
+
if ('vct' in payload) {
|
|
24
|
+
return { vct: payload.vct, claims: payload, credential_format: 'vc+sd-jwt' }; // TODO dc+sd-jwt support?
|
|
25
|
+
}
|
|
26
|
+
else if ('docType' in payload && 'namespaces' in payload) {
|
|
27
|
+
// mdoc
|
|
28
|
+
return { docType: payload.docType, namespaces: payload.namespaces, claims: payload };
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return {
|
|
32
|
+
claims: payload,
|
|
33
|
+
credential_format: 'jwt_vc_json', // TODO jwt_vc_json-ld support
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=dcql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dcql.js","sourceRoot":"","sources":["../../src/utils/dcql.ts"],"names":[],"mappings":";;AAKA,4DA8BC;AAjCD,mDAA4F;AAC5F,uDAA6D;AAE7D,SAAgB,wBAAwB,CAAC,UAAkE,EAAE,MAAe;IAC1H,IAAI,OAAO,CAAA;IACX,IAAI,IAAA,2CAAyB,EAAC,UAAU,CAAC,EAAE,CAAC;QAC1C,IAAI,CAAC,UAAU,CAAC,4BAA4B,EAAE,CAAC;YAC7C,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAA;QAC3F,CAAC;QACD,OAAO,GAAG,4BAAgB,CAAC,0BAA0B,CAAC,UAAU,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAA;IACxG,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,4BAAgB,CAAC,0BAA0B,CAAC,UAA0C,EAAE,MAAM,CAAC,CAAA;IAC3G,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;IACrC,CAAC;IAED,IAAI,gBAAgB,IAAI,OAAO,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;QAC1D,OAAO,GAAG,OAAO,CAAC,cAAc,CAAA;IAClC,CAAC;IAED,IAAI,KAAK,IAAI,OAAQ,EAAE,CAAC;QACtB,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAkC,CAAA,CAAC,0BAA0B;IACzI,CAAC;SAAM,IAAI,SAAS,IAAI,OAAQ,IAAI,YAAY,IAAI,OAAO,EAAE,CAAC;QAC5D,OAAO;QACP,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA;IACtF,CAAC;SAAM,CAAC;QACN,OAAO;YACL,MAAM,EAAE,OAAO;YACf,iBAAiB,EAAE,aAAa,EAAE,8BAA8B;SAC1C,CAAA;IAC1B,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.siopv2-oid4vp-op-auth",
|
|
3
|
-
"version": "0.32.1-feature.
|
|
3
|
+
"version": "0.32.1-feature.SSISDK.5.credential.offer.uri.204+778a3b98",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,30 +14,31 @@
|
|
|
14
14
|
"build:clean": "tsc --build --clean && tsc --build"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@sphereon/did-auth-siop": "0.16.1-
|
|
18
|
-
"@sphereon/did-auth-siop-adapter": "0.16.1-
|
|
19
|
-
"@sphereon/oid4vc-common": "0.16.1-
|
|
17
|
+
"@sphereon/did-auth-siop": "0.16.1-feature.SSISDK.5.credential.offer.uri.368",
|
|
18
|
+
"@sphereon/did-auth-siop-adapter": "0.16.1-feature.SSISDK.5.credential.offer.uri.368",
|
|
19
|
+
"@sphereon/oid4vc-common": "0.16.1-feature.SSISDK.5.credential.offer.uri.368",
|
|
20
20
|
"@sphereon/pex": "5.0.0-unstable.28",
|
|
21
21
|
"@sphereon/pex-models": "^2.3.2",
|
|
22
22
|
"@sphereon/ssi-sdk-ext.did-utils": "0.27.0",
|
|
23
23
|
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.27.0",
|
|
24
24
|
"@sphereon/ssi-sdk-ext.jwt-service": "0.27.0",
|
|
25
|
-
"@sphereon/ssi-sdk.contact-manager": "0.32.1-feature.
|
|
26
|
-
"@sphereon/ssi-sdk.core": "0.32.1-feature.
|
|
27
|
-
"@sphereon/ssi-sdk.credential-store": "0.32.1-feature.
|
|
28
|
-
"@sphereon/ssi-sdk.credential-validation": "0.32.1-feature.
|
|
29
|
-
"@sphereon/ssi-sdk.data-store": "0.32.1-feature.
|
|
30
|
-
"@sphereon/ssi-sdk.issuance-branding": "0.32.1-feature.
|
|
31
|
-
"@sphereon/ssi-sdk.pd-manager": "0.32.1-feature.
|
|
32
|
-
"@sphereon/ssi-sdk.presentation-exchange": "0.32.1-feature.
|
|
33
|
-
"@sphereon/ssi-sdk.sd-jwt": "0.32.1-feature.
|
|
34
|
-
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.32.1-feature.
|
|
35
|
-
"@sphereon/ssi-sdk.xstate-machine-persistence": "0.32.1-feature.
|
|
36
|
-
"@sphereon/ssi-types": "0.32.1-feature.
|
|
25
|
+
"@sphereon/ssi-sdk.contact-manager": "0.32.1-feature.SSISDK.5.credential.offer.uri.204+778a3b98",
|
|
26
|
+
"@sphereon/ssi-sdk.core": "0.32.1-feature.SSISDK.5.credential.offer.uri.204+778a3b98",
|
|
27
|
+
"@sphereon/ssi-sdk.credential-store": "0.32.1-feature.SSISDK.5.credential.offer.uri.204+778a3b98",
|
|
28
|
+
"@sphereon/ssi-sdk.credential-validation": "0.32.1-feature.SSISDK.5.credential.offer.uri.204+778a3b98",
|
|
29
|
+
"@sphereon/ssi-sdk.data-store": "0.32.1-feature.SSISDK.5.credential.offer.uri.204+778a3b98",
|
|
30
|
+
"@sphereon/ssi-sdk.issuance-branding": "0.32.1-feature.SSISDK.5.credential.offer.uri.204+778a3b98",
|
|
31
|
+
"@sphereon/ssi-sdk.pd-manager": "0.32.1-feature.SSISDK.5.credential.offer.uri.204+778a3b98",
|
|
32
|
+
"@sphereon/ssi-sdk.presentation-exchange": "0.32.1-feature.SSISDK.5.credential.offer.uri.204+778a3b98",
|
|
33
|
+
"@sphereon/ssi-sdk.sd-jwt": "0.32.1-feature.SSISDK.5.credential.offer.uri.204+778a3b98",
|
|
34
|
+
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.32.1-feature.SSISDK.5.credential.offer.uri.204+778a3b98",
|
|
35
|
+
"@sphereon/ssi-sdk.xstate-machine-persistence": "0.32.1-feature.SSISDK.5.credential.offer.uri.204+778a3b98",
|
|
36
|
+
"@sphereon/ssi-types": "0.32.1-feature.SSISDK.5.credential.offer.uri.204+778a3b98",
|
|
37
37
|
"@sphereon/wellknown-dids-client": "^0.1.3",
|
|
38
38
|
"@veramo/core": "4.2.0",
|
|
39
39
|
"@veramo/credential-w3c": "4.2.0",
|
|
40
40
|
"cross-fetch": "^3.1.8",
|
|
41
|
+
"dcql": "0.2.19",
|
|
41
42
|
"did-jwt-vc": "3.1.3",
|
|
42
43
|
"i18n-js": "^3.9.2",
|
|
43
44
|
"lodash.memoize": "^4.1.2",
|
|
@@ -47,18 +48,20 @@
|
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@sphereon/did-uni-client": "^0.6.3",
|
|
49
50
|
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.27.0",
|
|
50
|
-
"@sphereon/ssi-sdk.agent-config": "0.32.1-feature.
|
|
51
|
+
"@sphereon/ssi-sdk.agent-config": "0.32.1-feature.SSISDK.5.credential.offer.uri.204+778a3b98",
|
|
51
52
|
"@types/i18n-js": "^3.8.9",
|
|
52
53
|
"@types/lodash.memoize": "^4.1.9",
|
|
53
54
|
"@types/sha.js": "^2.4.4",
|
|
54
55
|
"@types/uuid": "^9.0.8",
|
|
56
|
+
"@veramo/data-store": "4.2.0",
|
|
55
57
|
"@veramo/did-provider-key": "4.2.0",
|
|
56
58
|
"@veramo/did-resolver": "4.2.0",
|
|
57
59
|
"@veramo/remote-client": "4.2.0",
|
|
58
60
|
"@veramo/remote-server": "4.2.0",
|
|
59
61
|
"@veramo/utils": "4.2.0",
|
|
60
62
|
"did-resolver": "^4.1.0",
|
|
61
|
-
"nock": "^13.5.4"
|
|
63
|
+
"nock": "^13.5.4",
|
|
64
|
+
"typeorm": "^0.3.20"
|
|
62
65
|
},
|
|
63
66
|
"files": [
|
|
64
67
|
"dist/**/*",
|
|
@@ -88,5 +91,5 @@
|
|
|
88
91
|
"Authenticator"
|
|
89
92
|
],
|
|
90
93
|
"nx": {},
|
|
91
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "778a3b98da978e27ae6983500df3da44218dde3d"
|
|
92
95
|
}
|
|
@@ -2,19 +2,22 @@ import { decodeUriAsJson, PresentationSignCallback, SupportedVersion, VerifiedAu
|
|
|
2
2
|
import {
|
|
3
3
|
ConnectionType,
|
|
4
4
|
CorrelationIdentifierType,
|
|
5
|
+
CredentialDocumentFormat,
|
|
5
6
|
CredentialRole,
|
|
7
|
+
DocumentType,
|
|
6
8
|
Identity,
|
|
7
9
|
IdentityOrigin,
|
|
8
10
|
NonPersistedIdentity,
|
|
9
11
|
Party,
|
|
10
12
|
} from '@sphereon/ssi-sdk.data-store'
|
|
11
|
-
import { Hasher, Loggers } from '@sphereon/ssi-types'
|
|
13
|
+
import { Hasher, Loggers, SdJwtDecodedVerifiableCredential } from '@sphereon/ssi-types'
|
|
12
14
|
import { IAgentPlugin } from '@veramo/core'
|
|
13
15
|
import { v4 as uuidv4 } from 'uuid'
|
|
14
16
|
import {
|
|
15
17
|
DidAuthSiopOpAuthenticatorOptions,
|
|
16
18
|
GetSelectableCredentialsArgs,
|
|
17
19
|
IOpSessionArgs,
|
|
20
|
+
Json,
|
|
18
21
|
LOGGER_NAMESPACE,
|
|
19
22
|
RequiredContext,
|
|
20
23
|
schema,
|
|
@@ -47,8 +50,9 @@ import {
|
|
|
47
50
|
Siopv2AuthorizationRequestData,
|
|
48
51
|
Siopv2HolderEvent,
|
|
49
52
|
Siopv2Machine as Siopv2MachineId,
|
|
50
|
-
Siopv2MachineInstanceOpts
|
|
53
|
+
Siopv2MachineInstanceOpts,
|
|
51
54
|
} from '../types'
|
|
55
|
+
import { DcqlCredential, DcqlPresentation, DcqlQuery, DcqlSdJwtVcCredential } from 'dcql'
|
|
52
56
|
|
|
53
57
|
const logger = Loggers.DEFAULT.options(LOGGER_NAMESPACE, {}).get(LOGGER_NAMESPACE)
|
|
54
58
|
|
|
@@ -84,22 +88,16 @@ export class DidAuthSiopOpAuthenticator implements IAgentPlugin {
|
|
|
84
88
|
siopGetSelectableCredentials: this.siopGetSelectableCredentials.bind(this),
|
|
85
89
|
}
|
|
86
90
|
|
|
87
|
-
private readonly hasher?: Hasher
|
|
88
91
|
private readonly sessions: Map<string, OpSession>
|
|
89
92
|
private readonly customApprovals: Record<string, (verifiedAuthorizationRequest: VerifiedAuthorizationRequest, sessionId: string) => Promise<void>>
|
|
90
93
|
private readonly presentationSignCallback?: PresentationSignCallback
|
|
91
94
|
private readonly onContactIdentityCreated?: (args: OnContactIdentityCreatedArgs) => Promise<void>
|
|
92
95
|
private readonly onIdentifierCreated?: (args: OnIdentifierCreatedArgs) => Promise<void>
|
|
93
96
|
private readonly eventEmitter?: EventEmitter
|
|
97
|
+
private readonly hasher?: Hasher
|
|
94
98
|
|
|
95
99
|
constructor(options?: DidAuthSiopOpAuthenticatorOptions) {
|
|
96
|
-
const {
|
|
97
|
-
onContactIdentityCreated,
|
|
98
|
-
onIdentifierCreated,
|
|
99
|
-
hasher,
|
|
100
|
-
customApprovals = {},
|
|
101
|
-
presentationSignCallback
|
|
102
|
-
} = { ...options }
|
|
100
|
+
const { onContactIdentityCreated, onIdentifierCreated, hasher, customApprovals = {}, presentationSignCallback } = { ...options }
|
|
103
101
|
|
|
104
102
|
this.hasher = hasher
|
|
105
103
|
this.onContactIdentityCreated = onContactIdentityCreated
|
|
@@ -214,9 +212,14 @@ export class DidAuthSiopOpAuthenticator implements IAgentPlugin {
|
|
|
214
212
|
}
|
|
215
213
|
const { sessionId, redirectUrl } = didAuthConfig
|
|
216
214
|
|
|
217
|
-
const session: OpSession = await agent
|
|
218
|
-
|
|
219
|
-
|
|
215
|
+
const session: OpSession = await agent.siopGetOPSession({ sessionId }).catch(
|
|
216
|
+
async () =>
|
|
217
|
+
await agent.siopRegisterOPSession({
|
|
218
|
+
requestJwtOrUri: redirectUrl,
|
|
219
|
+
sessionId,
|
|
220
|
+
op: { eventEmitter: this.eventEmitter, hasher: this.hasher },
|
|
221
|
+
}),
|
|
222
|
+
)
|
|
220
223
|
|
|
221
224
|
logger.debug(`session: ${JSON.stringify(session.id, null, 2)}`)
|
|
222
225
|
const verifiedAuthorizationRequest = await session.getAuthorizationRequest()
|
|
@@ -245,6 +248,7 @@ export class DidAuthSiopOpAuthenticator implements IAgentPlugin {
|
|
|
245
248
|
verifiedAuthorizationRequest.presentationDefinitions.length > 0)
|
|
246
249
|
? verifiedAuthorizationRequest.presentationDefinitions
|
|
247
250
|
: undefined,
|
|
251
|
+
dcqlQuery: verifiedAuthorizationRequest.dcqlQuery,
|
|
248
252
|
}
|
|
249
253
|
}
|
|
250
254
|
|
|
@@ -345,32 +349,73 @@ export class DidAuthSiopOpAuthenticator implements IAgentPlugin {
|
|
|
345
349
|
|
|
346
350
|
const pex = new PEX({ hasher: this.hasher })
|
|
347
351
|
const verifiableCredentialsWithDefinition: Array<VerifiableCredentialsWithDefinition> = []
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
352
|
+
const dcqlCredentialsWithCredentials: Map<DcqlCredential, UniqueDigitalCredential> = new Map()
|
|
353
|
+
|
|
354
|
+
if (Array.isArray(authorizationRequestData.presentationDefinitions) && authorizationRequestData?.presentationDefinitions.length > 0) {
|
|
355
|
+
try {
|
|
356
|
+
authorizationRequestData.presentationDefinitions?.forEach((presentationDefinition) => {
|
|
357
|
+
const { areRequiredCredentialsPresent, verifiableCredential: verifiableCredentials } = pex.selectFrom(
|
|
358
|
+
presentationDefinition.definition,
|
|
359
|
+
selectedCredentials.map((udc) => udc.originalVerifiableCredential!),
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
if (areRequiredCredentialsPresent !== Status.ERROR && verifiableCredentials) {
|
|
363
|
+
let uniqueDigitalCredentials: UniqueDigitalCredential[] = []
|
|
364
|
+
uniqueDigitalCredentials = verifiableCredentials.map((vc) => {
|
|
365
|
+
// @ts-ignore FIXME Funke
|
|
366
|
+
const hash = computeEntryHash(vc)
|
|
367
|
+
const udc = selectedCredentials.find((udc) => udc.hash == hash)
|
|
368
|
+
|
|
369
|
+
if (!udc) {
|
|
370
|
+
throw Error('UniqueDigitalCredential could not be found')
|
|
371
|
+
}
|
|
372
|
+
return udc
|
|
373
|
+
})
|
|
374
|
+
verifiableCredentialsWithDefinition.push({
|
|
375
|
+
definition: presentationDefinition,
|
|
376
|
+
credentials: uniqueDigitalCredentials,
|
|
377
|
+
})
|
|
362
378
|
}
|
|
363
|
-
return udc
|
|
364
|
-
})
|
|
365
|
-
verifiableCredentialsWithDefinition.push({
|
|
366
|
-
definition: presentationDefinition,
|
|
367
|
-
credentials: uniqueDigitalCredentials,
|
|
368
379
|
})
|
|
380
|
+
} catch (e) {
|
|
381
|
+
return Promise.reject(e)
|
|
369
382
|
}
|
|
370
|
-
})
|
|
371
383
|
|
|
372
|
-
|
|
373
|
-
|
|
384
|
+
if (verifiableCredentialsWithDefinition.length === 0) {
|
|
385
|
+
return Promise.reject(Error('None of the selected credentials match any of the presentation definitions.'))
|
|
386
|
+
}
|
|
387
|
+
} else if (authorizationRequestData.dcqlQuery) {
|
|
388
|
+
//TODO Only SD-JWT and MSO MDOC are supported at the moment
|
|
389
|
+
if (this.hasMDocCredentials(selectedCredentials) || this.hasSdJwtCredentials(selectedCredentials)) {
|
|
390
|
+
try {
|
|
391
|
+
selectedCredentials.forEach((vc) => {
|
|
392
|
+
if (this.isSdJwtCredential(vc)) {
|
|
393
|
+
const payload = (vc.originalVerifiableCredential as SdJwtDecodedVerifiableCredential).decodedPayload
|
|
394
|
+
const result: DcqlSdJwtVcCredential = {
|
|
395
|
+
claims: payload as { [x: string]: Json },
|
|
396
|
+
vct: payload.vct,
|
|
397
|
+
credential_format: 'vc+sd-jwt',
|
|
398
|
+
}
|
|
399
|
+
dcqlCredentialsWithCredentials.set(result, vc)
|
|
400
|
+
//FIXME MDoc namespaces are incompatible: array of strings vs complex object - https://sphereon.atlassian.net/browse/SPRIND-143
|
|
401
|
+
} else {
|
|
402
|
+
throw Error(`Invalid credential format: ${vc.digitalCredential.documentFormat}`)
|
|
403
|
+
}
|
|
404
|
+
})
|
|
405
|
+
} catch (e) {
|
|
406
|
+
return Promise.reject(e)
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const dcqlPresentationRecord: DcqlPresentation.Output = {}
|
|
410
|
+
const queryResult = DcqlQuery.query(authorizationRequestData.dcqlQuery, Array.from(dcqlCredentialsWithCredentials.keys()))
|
|
411
|
+
for (const [key, value] of Object.entries(queryResult.credential_matches)) {
|
|
412
|
+
if (value.success) {
|
|
413
|
+
dcqlPresentationRecord[key] = this.retrieveEncodedCredential(dcqlCredentialsWithCredentials.get(value.output)!) as
|
|
414
|
+
| string
|
|
415
|
+
| { [x: string]: Json }
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
374
419
|
}
|
|
375
420
|
|
|
376
421
|
const response = await siopSendAuthorizationResponse(
|
|
@@ -380,7 +425,7 @@ export class DidAuthSiopOpAuthenticator implements IAgentPlugin {
|
|
|
380
425
|
...(args.idOpts && { idOpts: args.idOpts }),
|
|
381
426
|
...(authorizationRequestData.presentationDefinitions !== undefined && { verifiableCredentialsWithDefinition }),
|
|
382
427
|
isFirstParty,
|
|
383
|
-
hasher: this.hasher
|
|
428
|
+
hasher: this.hasher,
|
|
384
429
|
},
|
|
385
430
|
context,
|
|
386
431
|
)
|
|
@@ -395,11 +440,41 @@ export class DidAuthSiopOpAuthenticator implements IAgentPlugin {
|
|
|
395
440
|
|
|
396
441
|
return {
|
|
397
442
|
body: responseBody,
|
|
398
|
-
url: response
|
|
399
|
-
queryParams: decodeUriAsJson(response
|
|
443
|
+
url: response?.url,
|
|
444
|
+
queryParams: decodeUriAsJson(response?.url),
|
|
400
445
|
}
|
|
401
446
|
}
|
|
402
447
|
|
|
448
|
+
private hasMDocCredentials = (credentials: UniqueDigitalCredential[]): boolean => {
|
|
449
|
+
return credentials.some(this.isMDocCredential)
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
private isMDocCredential = (credential: UniqueDigitalCredential) => {
|
|
453
|
+
return (
|
|
454
|
+
credential.digitalCredential.documentFormat === CredentialDocumentFormat.MSO_MDOC &&
|
|
455
|
+
credential.digitalCredential.documentType === DocumentType.VC
|
|
456
|
+
)
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
private hasSdJwtCredentials = (credentials: UniqueDigitalCredential[]): boolean => {
|
|
460
|
+
return credentials.some(this.isSdJwtCredential)
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
private isSdJwtCredential = (credential: UniqueDigitalCredential) => {
|
|
464
|
+
return (
|
|
465
|
+
credential.digitalCredential.documentFormat === CredentialDocumentFormat.SD_JWT && credential.digitalCredential.documentType === DocumentType.VC
|
|
466
|
+
)
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
private retrieveEncodedCredential = (credential: UniqueDigitalCredential) => {
|
|
470
|
+
return credential.originalVerifiableCredential !== undefined &&
|
|
471
|
+
credential.originalVerifiableCredential !== null &&
|
|
472
|
+
(credential?.originalVerifiableCredential as SdJwtDecodedVerifiableCredential)?.compactSdJwtVc !== undefined &&
|
|
473
|
+
(credential?.originalVerifiableCredential as SdJwtDecodedVerifiableCredential)?.compactSdJwtVc !== null
|
|
474
|
+
? (credential.originalVerifiableCredential as SdJwtDecodedVerifiableCredential).compactSdJwtVc
|
|
475
|
+
: credential.originalVerifiableCredential
|
|
476
|
+
}
|
|
477
|
+
|
|
403
478
|
private async siopGetSelectableCredentials(args: GetSelectableCredentialsArgs, context: RequiredContext): Promise<SelectableCredentialsMap> {
|
|
404
479
|
const { authorizationRequestData } = args
|
|
405
480
|
|