@pagopa/io-react-native-wallet 2.0.0-next.3 → 2.0.0-next.5
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/lib/commonjs/credential/issuance/04-complete-user-authorization.js +75 -57
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +3 -3
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/README.md +45 -34
- package/lib/commonjs/credential/issuance/types.js +1 -0
- package/lib/commonjs/credential/issuance/types.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +6 -13
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +7 -8
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/commonjs/credential/presentation/types.js +1 -1
- package/lib/commonjs/credential/presentation/types.js.map +1 -1
- package/lib/commonjs/credential/status/{02-status-attestation.js → 02-status-assertion.js} +28 -22
- package/lib/commonjs/credential/status/02-status-assertion.js.map +1 -0
- package/lib/commonjs/credential/status/03-verify-and-parse-status-assertion.js +85 -0
- package/lib/commonjs/credential/status/03-verify-and-parse-status-assertion.js.map +1 -0
- package/lib/commonjs/credential/status/README.md +22 -20
- package/lib/commonjs/credential/status/index.js +6 -6
- package/lib/commonjs/credential/status/index.js.map +1 -1
- package/lib/commonjs/credential/status/types.js +48 -15
- package/lib/commonjs/credential/status/types.js.map +1 -1
- package/lib/commonjs/sd-jwt/index.js +6 -1
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/commonjs/sd-jwt/types.js +25 -9
- package/lib/commonjs/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/utils/credentials.js +33 -0
- package/lib/commonjs/utils/credentials.js.map +1 -0
- package/lib/commonjs/utils/crypto.js +1 -7
- package/lib/commonjs/utils/crypto.js.map +1 -1
- package/lib/commonjs/utils/jwk.js +12 -0
- package/lib/commonjs/utils/jwk.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/types.js +1 -2
- package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js +76 -58
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +4 -4
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/issuance/README.md +45 -34
- package/lib/module/credential/issuance/types.js +1 -0
- package/lib/module/credential/issuance/types.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js +6 -13
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +7 -8
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/module/credential/presentation/types.js +1 -1
- package/lib/module/credential/presentation/types.js.map +1 -1
- package/lib/module/credential/status/{02-status-attestation.js → 02-status-assertion.js} +28 -22
- package/lib/module/credential/status/02-status-assertion.js.map +1 -0
- package/lib/module/credential/status/03-verify-and-parse-status-assertion.js +78 -0
- package/lib/module/credential/status/03-verify-and-parse-status-assertion.js.map +1 -0
- package/lib/module/credential/status/README.md +22 -20
- package/lib/module/credential/status/index.js +3 -3
- package/lib/module/credential/status/index.js.map +1 -1
- package/lib/module/credential/status/types.js +43 -12
- package/lib/module/credential/status/types.js.map +1 -1
- package/lib/module/sd-jwt/index.js +6 -1
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/module/sd-jwt/types.js +25 -9
- package/lib/module/sd-jwt/types.js.map +1 -1
- package/lib/module/utils/credentials.js +26 -0
- package/lib/module/utils/credentials.js.map +1 -0
- package/lib/module/utils/crypto.js +2 -8
- package/lib/module/utils/crypto.js.map +1 -1
- package/lib/module/utils/jwk.js +11 -1
- package/lib/module/utils/jwk.js.map +1 -1
- package/lib/module/wallet-instance-attestation/types.js +1 -2
- package/lib/module/wallet-instance-attestation/types.js.map +1 -1
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +7 -14
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/types.d.ts +3 -0
- package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/01-start-flow.d.ts +2 -2
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +4 -3
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +9 -5
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/types.d.ts +3 -4
- package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
- package/lib/typescript/credential/status/02-status-assertion.d.ts +23 -0
- package/lib/typescript/credential/status/02-status-assertion.d.ts.map +1 -0
- package/lib/typescript/credential/status/03-verify-and-parse-status-assertion.d.ts +21 -0
- package/lib/typescript/credential/status/03-verify-and-parse-status-assertion.d.ts.map +1 -0
- package/lib/typescript/credential/status/index.d.ts +4 -4
- package/lib/typescript/credential/status/index.d.ts.map +1 -1
- package/lib/typescript/credential/status/types.d.ts +499 -22
- package/lib/typescript/credential/status/types.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/index.d.ts +68 -40
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/types.d.ts +97 -46
- package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/utils/credentials.d.ts +11 -0
- package/lib/typescript/utils/credentials.d.ts.map +1 -0
- package/lib/typescript/utils/crypto.d.ts.map +1 -1
- package/lib/typescript/utils/jwk.d.ts +7 -0
- package/lib/typescript/utils/jwk.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/credential/issuance/04-complete-user-authorization.ts +79 -85
- package/src/credential/issuance/06-obtain-credential.ts +4 -1
- package/src/credential/issuance/07-verify-and-parse-credential.ts +4 -6
- package/src/credential/issuance/README.md +45 -34
- package/src/credential/issuance/types.ts +1 -0
- package/src/credential/presentation/07-evaluate-dcql-query.ts +16 -17
- package/src/credential/presentation/07-evaluate-input-descriptor.ts +16 -13
- package/src/credential/presentation/types.ts +1 -2
- package/src/credential/status/{02-status-attestation.ts → 02-status-assertion.ts} +37 -28
- package/src/credential/status/03-verify-and-parse-status-assertion.ts +109 -0
- package/src/credential/status/README.md +22 -20
- package/src/credential/status/index.ts +7 -14
- package/src/credential/status/types.ts +62 -15
- package/src/sd-jwt/index.ts +5 -1
- package/src/sd-jwt/types.ts +24 -10
- package/src/utils/credentials.ts +29 -0
- package/src/utils/crypto.ts +12 -20
- package/src/utils/jwk.ts +15 -1
- package/src/wallet-instance-attestation/types.ts +1 -1
- package/lib/commonjs/credential/status/02-status-attestation.js.map +0 -1
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +0 -55
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +0 -1
- package/lib/module/credential/status/02-status-attestation.js.map +0 -1
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +0 -49
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +0 -1
- package/lib/typescript/credential/status/02-status-attestation.d.ts +0 -19
- package/lib/typescript/credential/status/02-status-attestation.d.ts.map +0 -1
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts +0 -24
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +0 -1
- package/src/credential/status/03-verify-and-parse-status-attestation.ts +0 -70
@@ -10,11 +10,11 @@ var _parseUrl = _interopRequireDefault(require("parse-url"));
|
|
10
10
|
var _errors = require("../../utils/errors");
|
11
11
|
var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
|
12
12
|
var _types = require("../presentation/types");
|
13
|
-
var _uuid = require("uuid");
|
14
13
|
var _types2 = require("./types");
|
15
14
|
var _decoder = require("../../utils/decoder");
|
16
15
|
var _errors2 = require("./errors");
|
17
16
|
var _logging = require("../../utils/logging");
|
17
|
+
var _ = require("..");
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
19
|
/**
|
20
20
|
* The interface of the phase to complete User authorization via strong identification when the response mode is "query" and the request credential is a PersonIdentificationData.
|
@@ -94,71 +94,47 @@ const getRequestedCredentialToBePresented = async function (issuerRequestUri, cl
|
|
94
94
|
};
|
95
95
|
|
96
96
|
/**
|
97
|
-
* WARNING: This function must be called after {@link
|
97
|
+
* WARNING: This function must be called after {@link getRequestedCredentialToBePresented}. The next function to be called is {@link authorizeAccess}.
|
98
98
|
* The interface of the phase to complete User authorization via presentation of existing credentials when the response mode is "form_post.jwt".
|
99
|
-
*
|
100
|
-
*
|
101
|
-
* @param
|
102
|
-
* @param
|
103
|
-
* @param
|
104
|
-
* @param context.walletInstanceAccestation the Wallet Instance's attestation to be presented
|
105
|
-
* @param context.pid the PID to be presented
|
106
|
-
* @param context.wiaCryptoContext The Wallet Instance's crypto context associated with the walletInstanceAttestation parameter
|
107
|
-
* @param context.pidCryptoContext The PID crypto context associated with the pid parameter
|
108
|
-
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
99
|
+
* The information is obtained by performing a POST request to the endpoint received in the response_uri field of the requestObject, where the Authorization Response payload is posted.
|
100
|
+
* Following this,the redirect_uri from the response is used to obtain the final authorization response.
|
101
|
+
* @param requestObject - The request object containing the necessary parameters for authorization.
|
102
|
+
* @param pid The `PID` that must be presented for the issuance of credentials.
|
103
|
+
* @param appFetch (optional) fetch api implementation. Default: built-in fetch
|
109
104
|
* @throws {ValidationFailed} if an error while validating the response
|
110
105
|
* @returns the authorization response which contains code, state and iss
|
111
106
|
*/
|
112
107
|
exports.getRequestedCredentialToBePresented = getRequestedCredentialToBePresented;
|
113
|
-
const completeUserAuthorizationWithFormPostJwtMode = async (requestObject,
|
114
|
-
|
115
|
-
const {
|
108
|
+
const completeUserAuthorizationWithFormPostJwtMode = async (requestObject, pid, _ref) => {
|
109
|
+
let {
|
116
110
|
wiaCryptoContext,
|
117
111
|
pidCryptoContext,
|
118
|
-
pid,
|
119
|
-
walletInstanceAttestation,
|
120
112
|
appFetch = fetch
|
121
|
-
} =
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
}
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
*/
|
143
|
-
const presentationSubmission = {
|
144
|
-
definition_id: `${(0, _uuid.v4)()}`,
|
145
|
-
id: `${(0, _uuid.v4)()}`,
|
146
|
-
descriptor_map: [{
|
147
|
-
id: "PersonIdentificationData",
|
148
|
-
path: "$.vp_token[0].vp",
|
149
|
-
format: "vc+sd-jwt"
|
150
|
-
}, {
|
151
|
-
id: "WalletAttestation",
|
152
|
-
path: "$.vp_token[1].vp",
|
153
|
-
format: "jwt"
|
154
|
-
}]
|
155
|
-
};
|
156
|
-
_logging.Logger.log(_logging.LogLevel.DEBUG, `Presentation submission: ${JSON.stringify(presentationSubmission)}`);
|
157
|
-
const authzResponsePayload = (0, _ioReactNativeJwt.encodeBase64)(JSON.stringify({
|
113
|
+
} = _ref;
|
114
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `The requeste credential is not a PersonIdentificationData, completing the user authorization with form_post.jwt mode`);
|
115
|
+
if (!requestObject.dcql_query) {
|
116
|
+
throw new Error("Invalid request object");
|
117
|
+
}
|
118
|
+
const dcqlQueryResult = _.Presentation.evaluateDcqlQuery([[pidCryptoContext, pid]], requestObject.dcql_query);
|
119
|
+
const credentialsToPresent = dcqlQueryResult.map(_ref2 => {
|
120
|
+
let {
|
121
|
+
requiredDisclosures,
|
122
|
+
...rest
|
123
|
+
} = _ref2;
|
124
|
+
return {
|
125
|
+
...rest,
|
126
|
+
requestedClaims: requiredDisclosures.map(_ref3 => {
|
127
|
+
let [, claimName] = _ref3;
|
128
|
+
return claimName;
|
129
|
+
})
|
130
|
+
};
|
131
|
+
});
|
132
|
+
const remotePresentations = await _.Presentation.prepareRemotePresentations(credentialsToPresent, requestObject.nonce, requestObject.client_id);
|
133
|
+
const authzResponsePayload = await createAuthzResponsePayload({
|
158
134
|
state: requestObject.state,
|
159
|
-
|
160
|
-
|
161
|
-
})
|
135
|
+
remotePresentations,
|
136
|
+
wiaCryptoContext
|
137
|
+
});
|
162
138
|
_logging.Logger.log(_logging.LogLevel.DEBUG, `Authz response payload: ${authzResponsePayload}`);
|
163
139
|
|
164
140
|
// Note: according to the spec, the response should be encrypted with the public key of the RP however this is not implemented yet
|
@@ -213,5 +189,47 @@ const parseAuthorizationResponse = authRes => {
|
|
213
189
|
}
|
214
190
|
return authResParsed.data;
|
215
191
|
};
|
192
|
+
|
193
|
+
/**
|
194
|
+
* Creates the authorization response payload to be sent.
|
195
|
+
* This payload includes the state and the VP tokens for the presented credentials.
|
196
|
+
* The payload is encoded in Base64.
|
197
|
+
* @param state - The state parameter from the request object (optional).
|
198
|
+
* @param remotePresentations - An array of remote presentations containing credential IDs and their corresponding VP tokens.
|
199
|
+
* @returns The Base64 encoded authorization response payload.
|
200
|
+
*/
|
216
201
|
exports.parseAuthorizationResponse = parseAuthorizationResponse;
|
202
|
+
const createAuthzResponsePayload = async _ref4 => {
|
203
|
+
let {
|
204
|
+
state,
|
205
|
+
remotePresentations,
|
206
|
+
wiaCryptoContext
|
207
|
+
} = _ref4;
|
208
|
+
const {
|
209
|
+
kid
|
210
|
+
} = await wiaCryptoContext.getPublicKey();
|
211
|
+
return new _ioReactNativeJwt.SignJWT(wiaCryptoContext).setProtectedHeader({
|
212
|
+
typ: "jwt",
|
213
|
+
kid
|
214
|
+
}).setPayload({
|
215
|
+
/**
|
216
|
+
* TODO [SIW-2264]: `state` coming from `requestObject` is marked as `optional`
|
217
|
+
* At the moment, it is not entirely clear whether this value can indeed be omitted
|
218
|
+
* and, if so, what the consequences of its absence might be.
|
219
|
+
*/
|
220
|
+
...(state ? {
|
221
|
+
state
|
222
|
+
} : {}),
|
223
|
+
vp_token: remotePresentations.reduce((vp_token, _ref5) => {
|
224
|
+
let {
|
225
|
+
credentialId,
|
226
|
+
vpToken
|
227
|
+
} = _ref5;
|
228
|
+
return {
|
229
|
+
...vp_token,
|
230
|
+
[credentialId]: vpToken
|
231
|
+
};
|
232
|
+
}, {})
|
233
|
+
}).setIssuedAt().setExpirationTime("1h").sign();
|
234
|
+
};
|
217
235
|
//# sourceMappingURL=04-complete-user-authorization.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_auth","require","_misc","_parseUrl","_interopRequireDefault","_errors","_ioReactNativeJwt","_types","
|
1
|
+
{"version":3,"names":["_auth","require","_misc","_parseUrl","_interopRequireDefault","_errors","_ioReactNativeJwt","_types","_types2","_decoder","_errors2","_logging","_","obj","__esModule","default","buildAuthorizationUrl","issuerRequestUri","clientId","issuerConf","idpHint","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","append","authUrl","exports","completeUserAuthorizationWithQueryMode","authRedirectUrl","Logger","log","LogLevel","DEBUG","query","parseUrl","parseAuthorizationResponse","getRequestedCredentialToBePresented","appFetch","arguments","length","undefined","fetch","toString","requestObject","method","then","hasStatusOrThrow","IssuerResponseError","res","text","jws","decode","reqObj","RequestObject","safeParse","payload","success","ERROR","error","message","ValidationFailed","reason","data","completeUserAuthorizationWithFormPostJwtMode","pid","_ref","wiaCryptoContext","pidCryptoContext","dcql_query","Error","dcqlQueryResult","Presentation","evaluateDcqlQuery","credentialsToPresent","map","_ref2","requiredDisclosures","rest","requestedClaims","_ref3","claimName","remotePresentations","prepareRemotePresentations","nonce","authzResponsePayload","createAuthzResponsePayload","state","body","response","resUriRes","response_uri","headers","reqUri","json","responseUri","ResponseUriResultShape","redirect_uri","getJwtFromFormPost","cbRes","decodedJwt","authRes","authResParsed","AuthorizationResultShape","authErr","AuthorizationErrorShape","AuthorizationError","JSON","stringify","AuthorizationIdpError","error_description","_ref4","kid","getPublicKey","SignJWT","setProtectedHeader","typ","setPayload","vp_token","reduce","_ref5","credentialId","vpToken","setIssuedAt","setExpirationTime","sign"],"sourceRoot":"../../../../src","sources":["credential/issuance/04-complete-user-authorization.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAEA,IAAAK,iBAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;AACA,IAAAW,CAAA,GAAAX,OAAA;AAAkC,SAAAG,uBAAAS,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAGlC;AACA;AACA;;AA+BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,qBAA4C,GAAG,MAAAA,CAC1DC,gBAAgB,EAChBC,QAAQ,EACRC,UAAU,EACVC,OAAO,KACJ;EACH,MAAMC,oBAAoB,GACxBF,UAAU,CAACG,0BAA0B,CAACC,sBAAsB;EAE9D,MAAMC,MAAM,GAAG,IAAIC,e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AC,CAAC;AACX,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_ioReactNativeJwt","require","_misc","_errors","_types","_dpop","_uuid","_logging","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","SignJWT","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","exports","obtainCredential","issuerConf","accessToken","clientId","credentialDefinition","context","operationType","credentialCryptoContext","appFetch","fetch","dPopCryptoContext","credential_configuration_id","credential_identifier","credentialUrl","openid_credential_issuer","credential_endpoint","issuerUrl","oauth_authorization_server","nonceUrl","nonce_endpoint","c_nonce","method","headers","then","hasStatusOrThrow","res","json","body","NonceResponse","parse","signedNonceProof","Logger","log","LogLevel","DEBUG","containsCredentialDefinition","authorization_details","some","c","credential_identifiers","includes","ERROR","ValidationFailed","message","credentialRequestFormBody","proof","jwt","proof_type","JSON","stringify","tokenRequestSignedDPop","createDPopToken","htm","htu","jti","uuidv4","ath","sha256ToBase64","access_token","credentialRes","DPoP","Authorization","token_type","CredentialResponse","safeParse","catch","handleObtainCredentialError","success","error","reason","data","issuerCredentialConfig","credential_configurations_supported","credential","credentials","at","format","e","UnexpectedStatusCodeError","ResponseErrorBuilder","IssuerResponseError","handle","code","IssuerResponseErrorCodes","CredentialIssuingNotSynchronous","CredentialInvalidStatus","CredentialRequestFailed","buildFrom"],"sourceRoot":"../../../../src","sources":["credential/issuance/06-obtain-credential.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAOA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAOA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;
|
1
|
+
{"version":3,"names":["_ioReactNativeJwt","require","_misc","_errors","_types","_dpop","_uuid","_logging","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","SignJWT","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","exports","obtainCredential","issuerConf","accessToken","clientId","credentialDefinition","context","operationType","credentialCryptoContext","appFetch","fetch","dPopCryptoContext","credential_configuration_id","credential_identifier","credentialUrl","openid_credential_issuer","credential_endpoint","issuerUrl","oauth_authorization_server","nonceUrl","nonce_endpoint","c_nonce","method","headers","then","hasStatusOrThrow","res","json","body","NonceResponse","parse","signedNonceProof","Logger","log","LogLevel","DEBUG","containsCredentialDefinition","authorization_details","some","c","credential_identifiers","includes","ERROR","ValidationFailed","message","credentialRequestFormBody","proof","jwt","proof_type","JSON","stringify","tokenRequestSignedDPop","createDPopToken","htm","htu","jti","uuidv4","ath","sha256ToBase64","access_token","credentialRes","DPoP","Authorization","token_type","CredentialResponse","safeParse","catch","handleObtainCredentialError","success","error","reason","data","issuerCredentialConfig","credential_configurations_supported","credential","credentials","at","format","e","UnexpectedStatusCodeError","ResponseErrorBuilder","IssuerResponseError","handle","code","IssuerResponseErrorCodes","CredentialIssuingNotSynchronous","CredentialInvalidStatus","CredentialRequestFailed","buildFrom"],"sourceRoot":"../../../../src","sources":["credential/issuance/06-obtain-credential.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAOA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAOA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAqBO,MAAMO,gBAAgB,GAAG,MAAAA,CAC9BC,KAAa,EACbC,MAAc,EACdC,QAAgB,EAChBC,GAAkB,KACE;EACpB,MAAMC,GAAG,GAAG,MAAMD,GAAG,CAACE,YAAY,CAAC,CAAC;EACpC,OAAO,IAAIC,yBAAO,CAACH,GAAG,CAAC,CACpBI,UAAU,CAAC;IACVP;EACF,CAA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ED;EACA,MAAMC,sBAAsB,GAC1BtE,UAAU,CAACa,wBAAwB,CAAC0D,mCAAmC,CACrE7D,2BAA2B,CAC5B;;EAEH;EACA,OAAO;IACL8D,UAAU,EAAEd,aAAa,CAACW,IAAI,CAACI,WAAW,CAACC,EAAE,CAAC,CAAC,CAAC,CAAEF,UAAU;IAC5DG,MAAM,EAAEL,sBAAsB,CAAEK;EAClC,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA7E,OAAA,CAAAC,gBAAA,GAAAA,gBAAA;AAMA,MAAMkE,2BAA2B,GAAIW,CAAU,IAAK;EAClD9C,eAAM,CAACC,GAAG,CAACC,iBAAQ,CAACQ,KAAK,EAAG,8CAA6CoC,CAAE,EAAC,CAAC;EAE7E,IAAI,EAAEA,CAAC,YAAYC,iCAAyB,CAAC,EAAE;IAC7C,MAAMD,CAAC;EACT;EAEA,MAAM,IAAIE,4BAAoB,CAACC,2BAAmB,CAAC,CAChDC,MAAM,CAAC,GAAG,EAAE;IACX;IACA;IACAC,IAAI,EAAEC,gCAAwB,CAACC,+BAA+B;IAC9DzC,OAAO,EACL;EACJ,CAAC,CAAC,CACDsC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,gCAAwB,CAACE,uBAAuB;IACtD1C,OAAO,EAAE;EACX,CAAC,CAAC,CACDsC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,gCAAwB,CAACE,uBAAuB;IACtD1C,OAAO,EAAE;EACX,CAAC,CAAC,CACDsC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,gCAAwB,CAACG,uBAAuB;IACtD3C,OAAO,EAAE;EACX,CAAC,CAAC,CACD4C,SAAS,CAACV,CAAC,CAAC;AACjB,CAAC"}
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.verifyAndParseCredential = void 0;
|
7
7
|
var _errors = require("../../utils/errors");
|
8
|
-
var _types = require("../../sd-jwt/types");
|
9
8
|
var _sdJwt = require("../../sd-jwt");
|
10
9
|
var _converters = require("../../sd-jwt/converters");
|
10
|
+
var _jwk = require("../../utils/jwk");
|
11
11
|
var _logging = require("../../utils/logging");
|
12
12
|
// The credential as a collection of attributes in plain value
|
13
13
|
|
@@ -121,11 +121,11 @@ const parseCredentialSdJwt = function (credentialConfig, _ref) {
|
|
121
121
|
async function verifyCredentialSdJwt(rawCredential, issuerKeys, holderBindingContext) {
|
122
122
|
const [decodedCredential, holderBindingKey] =
|
123
123
|
// parallel for optimization
|
124
|
-
await Promise.all([(0, _sdJwt.verify)(rawCredential, issuerKeys,
|
124
|
+
await Promise.all([(0, _sdJwt.verify)(rawCredential, issuerKeys, _sdJwt.SdJwt4VC), holderBindingContext.getPublicKey()]);
|
125
125
|
const {
|
126
126
|
cnf
|
127
127
|
} = decodedCredential.sdJwt.payload;
|
128
|
-
if (!
|
128
|
+
if (!(await (0, _jwk.isSameThumbprint)(cnf.jwk, holderBindingKey))) {
|
129
129
|
const message = `Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`;
|
130
130
|
_logging.Logger.log(_logging.LogLevel.ERROR, message);
|
131
131
|
throw new _errors.IoWalletError(message);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_errors","require","
|
1
|
+
{"version":3,"names":["_errors","require","_sdJwt","_converters","_jwk","_logging","parseCredentialSdJwt","credentialConfig","_ref","sdJwt","disclosures","ignoreMissingAttributes","arguments","length","undefined","includeUndefinedAttributes","format","header","typ","message","Logger","log","LogLevel","ERROR","IoWalletError","claims","attrDefinitions","attrsNotInDisclosures","filter","definition","some","_ref2","name","path","missing","map","_","join","received","definedValues","Object","fromEntries","_ref3","_disclosures$find","value","find","_ref4","attrKey","display","reduce","names","_ref5","locale","undefinedValues","keys","includes","_ref6","key","verifyCredentialSdJwt","rawCredential","issuerKeys","holderBindingContext","decodedCredential","holderBindingKey","Promise","all","verifySdJwt","SdJwt4VC","getPublicKey","cnf","payload","isSameThumbprint","jwk","kid","verifyAndParseCredentialSdJwt","issuerConf","credential","credentialConfigurationId","_ref7","credentialCryptoContext","decoded","openid_credential_issuer","jwks","DEBUG","JSON","stringify","credential_configurations_supported","parsedCredential","maybeIssuedAt","getValueFromDisclosures","expiration","Date","exp","issuedAt","verifyAndParseCredential","context","_issuerConf$openid_cr","exports"],"sourceRoot":"../../../../src","sources":["credential/issuance/07-verify-and-parse-credential.ts"],"mappings":";;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAJ,OAAA;AA2BA;;AAkBA;;AAKA,MAAMK,oBAAoB,GAAG,SAAAA,CAE3BC,gBAAgC,EAAAC,IAAA,EAIX;EAAA,IAHrB;IAAEC,KAAK;IAAEC;EAAoC,CAAC,GAAAF,IAAA;EAAA,IAC9CG,uBAAgC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAAA,IACxCG,0BAAmC,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAE3C,IAAIL,gBAAgB,CAACS,MAAM,KAAKP,KAAK,CAACQ,MAAM,CAACC,GAAG,EAAE;IAChD,MAAMC,OAAO,GAAI,gEAA+DZ,gBAAgB,CAACS,MAAO,gBAAeP,KAAK,CAACQ,MAAM,CAACC,GAAI,GAAE;IAC1IE,eAAM,CAACC,GAAG,CAACC,iBAAQ,CAACC,KAAK,EAAEJ,OAAO,CAAC;IACnC,MAAM,IAAIK,qBAAa,CAACL,OAAO,CAAC;EAClC;EAEA,IAAI,CAACZ,gBAAgB,CAACkB,MAAM,EAAE;IAC5BL,eAAM,CAACC,GAAG,CAACC,iBAAQ,CA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,EACVC,UAAU,EACVC,yBAAyB,EACzBkB,OACF,CAAC;EACH;EAEA,MAAM5E,OAAO,GAAI,kCAAiCH,MAAO,EAAC;EAC1DI,eAAM,CAACC,GAAG,CAACC,iBAAQ,CAACC,KAAK,EAAEJ,OAAO,CAAC;EACnC,MAAM,IAAIK,qBAAa,CAACL,OAAO,CAAC;AAClC,CAAC;AAAC8E,OAAA,CAAAH,wBAAA,GAAAA,wBAAA"}
|
@@ -72,8 +72,6 @@ The expected result from the authentication process is in `form_post.jwt` format
|
|
72
72
|
<summary>Credential issuance flow</summary>
|
73
73
|
|
74
74
|
```ts
|
75
|
-
// TODO: [SIW-2209] update documentation in PR #219
|
76
|
-
|
77
75
|
// Retrieve the integrity key tag from the store and create its context
|
78
76
|
const integrityKeyTag = "example"; // Let's assume this is the key tag used to create the wallet instance
|
79
77
|
const integrityContext = getIntegrityContext(integrityKeyTag);
|
@@ -98,17 +96,13 @@ const walletInstanceAttestation =
|
|
98
96
|
appFetch,
|
99
97
|
});
|
100
98
|
|
101
|
-
const
|
102
|
-
|
103
|
-
const eid = {
|
99
|
+
const pid = {
|
104
100
|
credential: "example",
|
105
101
|
parsedCredential: "example"
|
106
102
|
keyTag: "example";
|
107
|
-
credentialType: "
|
103
|
+
credentialType: "PersonIdentificationData";
|
108
104
|
};
|
109
105
|
|
110
|
-
const eidCryptoContext = createCryptoContextFor(eid.keyTag);
|
111
|
-
|
112
106
|
// Create credential crypto context
|
113
107
|
const credentialKeyTag = uuidv4().toString();
|
114
108
|
await generate(credentialKeyTag); // Let's assume this function generates a new hardware-backed key pair
|
@@ -117,22 +111,26 @@ const credentialCryptoContext = createCryptoContextFor(credentialKeyTag);
|
|
117
111
|
// Start the issuance flow
|
118
112
|
const startFlow: Credential.Issuance.StartFlow = () => ({
|
119
113
|
issuerUrl: WALLET_EAA_PROVIDER_BASE_URL,
|
120
|
-
|
114
|
+
credentialId: "someCredentialId",
|
121
115
|
});
|
122
116
|
|
123
|
-
const { issuerUrl } = startFlow();
|
117
|
+
const { issuerUrl, credentialId } = startFlow();
|
124
118
|
|
125
119
|
// Evaluate issuer trust
|
126
120
|
const { issuerConf } = await Credential.Issuance.evaluateIssuerTrust(issuerUrl);
|
127
121
|
|
128
122
|
// Start user authorization
|
129
|
-
const { issuerRequestUri, clientId, codeVerifier
|
130
|
-
await Credential.Issuance.startUserAuthorization(
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
123
|
+
const { issuerRequestUri, clientId, codeVerifier } =
|
124
|
+
await Credential.Issuance.startUserAuthorization(
|
125
|
+
issuerConf,
|
126
|
+
[credentialId],
|
127
|
+
{
|
128
|
+
walletInstanceAttestation,
|
129
|
+
redirectUri: REDIRECT_URI,
|
130
|
+
wiaCryptoContext,
|
131
|
+
appFetch,
|
132
|
+
}
|
133
|
+
);
|
136
134
|
|
137
135
|
const requestObject =
|
138
136
|
await Credential.Issuance.getRequestedCredentialToBePresented(
|
@@ -142,13 +140,12 @@ const requestObject =
|
|
142
140
|
appFetch
|
143
141
|
);
|
144
142
|
|
145
|
-
// The app here should ask the user to confirm the required data contained in the requestObject
|
146
|
-
|
147
143
|
// Complete the user authorization via form_post.jwt mode
|
148
144
|
const { code } =
|
149
145
|
await Credential.Issuance.completeUserAuthorizationWithFormPostJwtMode(
|
150
146
|
requestObject,
|
151
|
-
|
147
|
+
pid.credential,
|
148
|
+
{ wiaCryptoContext, pidCryptoContext: createCryptoContextFor(pid.keyTag) }
|
152
149
|
);
|
153
150
|
|
154
151
|
// Generate the DPoP context which will be used for the whole issuance flow
|
@@ -159,7 +156,7 @@ const { accessToken } = await Credential.Issuance.authorizeAccess(
|
|
159
156
|
issuerConf,
|
160
157
|
code,
|
161
158
|
clientId,
|
162
|
-
redirectUri,
|
159
|
+
redirectUri: REDIRECT_URI,
|
163
160
|
codeVerifier,
|
164
161
|
{
|
165
162
|
walletInstanceAttestation,
|
@@ -169,12 +166,19 @@ const { accessToken } = await Credential.Issuance.authorizeAccess(
|
|
169
166
|
}
|
170
167
|
);
|
171
168
|
|
172
|
-
//
|
173
|
-
const {
|
169
|
+
// For simplicity, in this example flow we work on a single credential.
|
170
|
+
const { credential_configuration_id, credential_identifiers } =
|
171
|
+
accessToken.authorization_details[0]!;
|
172
|
+
|
173
|
+
// Obtain the credential
|
174
|
+
const { credential } = await Credential.Issuance.obtainCredential(
|
174
175
|
issuerConf,
|
175
176
|
accessToken,
|
176
177
|
clientId,
|
177
|
-
|
178
|
+
{
|
179
|
+
credential_configuration_id,
|
180
|
+
credential_identifier: credential_identifiers[0],
|
181
|
+
},
|
178
182
|
{
|
179
183
|
credentialCryptoContext,
|
180
184
|
dPopCryptoContext,
|
@@ -186,22 +190,29 @@ const { credential, format } = await Credential.Issuance.obtainCredential(
|
|
186
190
|
* Parse and verify the credential. The ignoreMissingAttributes flag must be set to false or omitted in production.
|
187
191
|
* WARNING: includeUndefinedAttributes should not be set to true in production in order to get only claims explicitly declared by the issuer.
|
188
192
|
*/
|
189
|
-
const { parsedCredential } =
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
193
|
+
const { parsedCredential } =
|
194
|
+
await Credential.Issuance.verifyAndParseCredential(
|
195
|
+
issuerConf,
|
196
|
+
credential,
|
197
|
+
credential_configuration_id,
|
198
|
+
{
|
199
|
+
credentialCryptoContext,
|
200
|
+
ignoreMissingAttributes: true,
|
201
|
+
includeUndefinedAttributes: false
|
202
|
+
}
|
203
|
+
);
|
204
|
+
|
205
|
+
const credentialType =
|
206
|
+
issuerConf.openid_credential_issuer.credential_configurations_supported[
|
207
|
+
credential_configuration_id
|
208
|
+
].scope;
|
199
209
|
|
200
210
|
return {
|
201
211
|
parsedCredential,
|
202
212
|
credential,
|
203
213
|
keyTag: credentialKeyTag,
|
204
214
|
credentialType,
|
215
|
+
credentialConfigurationId: credential_configuration_id,
|
205
216
|
};
|
206
217
|
```
|
207
218
|
|
@@ -15,6 +15,7 @@ const AuthorizationDetail = z.object({
|
|
15
15
|
exports.AuthorizationDetail = AuthorizationDetail;
|
16
16
|
const TokenResponse = z.object({
|
17
17
|
access_token: z.string(),
|
18
|
+
refresh_token: z.string().optional(),
|
18
19
|
authorization_details: z.array(AuthorizationDetail),
|
19
20
|
expires_in: z.number(),
|
20
21
|
token_type: z.string()
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["z","_interopRequireWildcard","require","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AuthorizationDetail","object","type","literal","credential_configuration_id","string","credential_identifiers","array","exports","TokenResponse","access_token","authorization_details","expires_in","number","token_type","CredentialResponse","credentials","credential","notification_id","
|
1
|
+
{"version":3,"names":["z","_interopRequireWildcard","require","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AuthorizationDetail","object","type","literal","credential_configuration_id","string","credential_identifiers","array","exports","TokenResponse","access_token","refresh_token","optional","authorization_details","expires_in","number","token_type","CredentialResponse","credentials","credential","notification_id","ResponseUriResultShape","redirect_uri","NonceResponse","c_nonce"],"sourceRoot":"../../../../src","sources":["credential/issuance/types.ts"],"mappings":";;;;;;AAAA,IAAAA,CAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAyB,SAAAC,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,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EnC,CAAC,CAAC8B,MAAM,CAAC,CAAC;EACxBM,aAAa,EAAEpC,CAAC,CAAC8B,MAAM,CAAC,CAAC,CAACO,QAAQ,CAAC,CAAC;EACpCC,qBAAqB,EAAEtC,CAAC,CAACgC,KAAK,CAACP,mBAAmB,CAAC;EACnDc,UAAU,EAAEvC,CAAC,CAACwC,MAAM,CAAC,CAAC;EACtBC,UAAU,EAAEzC,CAAC,CAAC8B,MAAM,CAAC;AACvB,CAAC,CAAC;AAACG,OAAA,CAAAC,aAAA,GAAAA,aAAA;AAII,MAAMQ,kBAAkB,GAAG1C,CAAC,CAAC0B,MAAM,CAAC;EACzCiB,WAAW,EAAE3C,CAAC,CAACgC,KAAK,CAClBhC,CAAC,CAAC0B,MAAM,CAAC;IACPkB,UAAU,EAAE5C,CAAC,CAAC8B,MAAM,CAAC;EACvB,CAAC,CACH,CAAC;EACDe,eAAe,EAAE7C,CAAC,CAAC8B,MAAM,CAAC,CAAC,CAACO,QAAQ,CAAC;AACvC,CAAC,CAAC;;AAEF;AACA;AACA;AAFAJ,OAAA,CAAAS,kBAAA,GAAAA,kBAAA;AAGO,MAAMI,sBAAsB,GAAG9C,CAAC,CAAC0B,MAAM,CAAC;EAC7CqB,YAAY,EAAE/C,CAAC,CAAC8B,MAAM,CAAC;AACzB,CAAC,CAAC;AAACG,OAAA,CAAAa,sBAAA,GAAAA,sBAAA;AAKI,MAAME,aAAa,GAAGhD,CAAC,CAAC0B,MAAM,CAAC;EACpCuB,OAAO,EAAEjD,CAAC,CAAC8B,MAAM,CAAC;AACpB,CAAC,CAAC;AAACG,OAAA,CAAAe,aAAA,GAAAA,aAAA"}
|
@@ -7,7 +7,6 @@ exports.prepareRemotePresentations = exports.evaluateDcqlQuery = void 0;
|
|
7
7
|
var _dcql = require("dcql");
|
8
8
|
var _valibot = require("valibot");
|
9
9
|
var _sdJwt = require("../../sd-jwt");
|
10
|
-
var _crypto = require("../../utils/crypto");
|
11
10
|
var _errors = require("./errors");
|
12
11
|
/**
|
13
12
|
* The purpose for the credential request by the RP.
|
@@ -23,11 +22,6 @@ const mapCredentialToObject = jwt => {
|
|
23
22
|
disclosures
|
24
23
|
} = (0, _sdJwt.decode)(jwt);
|
25
24
|
const credentialFormat = sdJwt.header.typ;
|
26
|
-
|
27
|
-
// TODO [SIW-2082]: support MDOC credentials
|
28
|
-
if (credentialFormat !== "dc+sd-jwt") {
|
29
|
-
throw new Error(`Unsupported credential format: ${credentialFormat}`);
|
30
|
-
}
|
31
25
|
return {
|
32
26
|
vct: sdJwt.payload.vct,
|
33
27
|
credential_format: credentialFormat,
|
@@ -64,7 +58,7 @@ const extractMissingCredentials = (queryResult, originalQuery) => {
|
|
64
58
|
var _credential$meta;
|
65
59
|
let [id] = _ref3;
|
66
60
|
const credential = originalQuery.credentials.find(c => c.id === id);
|
67
|
-
if ((credential === null || credential === void 0 ? void 0 : credential.format) !== "dc+sd-jwt") {
|
61
|
+
if ((credential === null || credential === void 0 ? void 0 : credential.format) !== "dc+sd-jwt" && (credential === null || credential === void 0 ? void 0 : credential.format) !== "vc+sd-jwt") {
|
68
62
|
throw new Error("Unsupported format"); // TODO [SIW-2082]: support MDOC credentials
|
69
63
|
}
|
70
64
|
|
@@ -96,7 +90,7 @@ const evaluateDcqlQuery = (credentialsSdJwt, query) => {
|
|
96
90
|
return getDcqlQueryMatches(queryResult).map(_ref5 => {
|
97
91
|
var _queryResult$credenti;
|
98
92
|
let [id, match] = _ref5;
|
99
|
-
if (match.output.credential_format !== "dc+sd-jwt") {
|
93
|
+
if (match.output.credential_format !== "dc+sd-jwt" && match.output.credential_format !== "vc+sd-jwt") {
|
100
94
|
throw new Error("Unsupported format"); // TODO [SIW-2082]: support MDOC credentials
|
101
95
|
}
|
102
96
|
|
@@ -114,12 +108,12 @@ const evaluateDcqlQuery = (credentialsSdJwt, query) => {
|
|
114
108
|
required: Boolean(credentialSet.required)
|
115
109
|
};
|
116
110
|
});
|
117
|
-
const [
|
111
|
+
const [cryptoContext, credential] = credentialsSdJwtByVct[vct];
|
118
112
|
const requiredDisclosures = Object.values(claims);
|
119
113
|
return {
|
120
114
|
id,
|
121
115
|
vct,
|
122
|
-
|
116
|
+
cryptoContext,
|
123
117
|
credential,
|
124
118
|
requiredDisclosures,
|
125
119
|
// When it is a match but no credential_sets are found, the credential is required by default
|
@@ -148,12 +142,11 @@ const prepareRemotePresentations = async (credentials, nonce, clientId) => {
|
|
148
142
|
return Promise.all(credentials.map(async item => {
|
149
143
|
const {
|
150
144
|
vp_token
|
151
|
-
} = await (0, _sdJwt.prepareVpToken)(nonce, clientId, [item.credential, item.requestedClaims,
|
145
|
+
} = await (0, _sdJwt.prepareVpToken)(nonce, clientId, [item.credential, item.requestedClaims, item.cryptoContext]);
|
152
146
|
return {
|
153
147
|
credentialId: item.id,
|
154
148
|
requestedClaims: item.requestedClaims,
|
155
|
-
vpToken: vp_token
|
156
|
-
format: "dc+sd-jwt"
|
149
|
+
vpToken: vp_token
|
157
150
|
};
|
158
151
|
}));
|
159
152
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_dcql","require","_valibot","_sdJwt","
|
1
|
+
{"version":3,"names":["_dcql","require","_valibot","_sdJwt","_errors","mapCredentialToObject","jwt","sdJwt","disclosures","decode","credentialFormat","header","typ","vct","payload","credential_format","claims","reduce","acc","disclosure","decoded","getDcqlQueryMatches","result","Object","entries","credential_matches","filter","_ref","match","success","getDcqlQueryFailedMatches","_ref2","extractMissingCredentials","queryResult","originalQuery","map","_ref3","_credential$meta","id","credential","credentials","find","c","format","Error","vctValues","meta","vct_values","evaluateDcqlQuery","credentialsSdJwt","query","_ref4","parsedQuery","DcqlQuery","parse","validate","canBeSatisfied","CredentialsNotFoundError","credentialsSdJwtByVct","i","_ref5","_queryResult$credenti","output","purposes","credential_sets","set","_set$matching_options","matching_options","flat","includes","credentialSet","_credentialSet$purpos","description","purpose","toString","required","Boolean","cryptoContext","requiredDisclosures","values","error","isValiError","DcqlError","message","code","cause","issues","exports","prepareRemotePresentations","nonce","clientId","Promise","all","item","vp_token","prepareVpToken","requestedClaims","credentialId","vpToken"],"sourceRoot":"../../../../src","sources":["credential/presentation/07-evaluate-dcql-query.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAGA,IAAAG,OAAA,GAAAH,OAAA;AAGA;AACA;AACA;;AAuCA;AACA;AACA;AACA;AACA,MAAMI,qBAAqB,GAAIC,GAAW,IAAK;EAC7C,MAAM;IAAEC,KAAK;IAAEC;EAAY,CAAC,GAAG,IAAAC,aAAM,EAACH,GAAG,CAAC;EAC1C,MAAMI,gBAAgB,GAAGH,KAAK,CAACI,MAAM,CAACC,GAAG;EAEzC,OAAO;IACLC,GAAG,EAAEN,KAAK,CAACO,OAAO,CAACD,GAAG;IACtBE,iBAAiB,EAAEL,gBAAgB;IACnCM,MAAM,EAAER,WAAW,CAACS,MAAM,CACxB,CAACC,GAAG,EAAEC,UAAU,MAAM;MACpB,GAAGD,GAAG;MACN,CAACC,UAAU,CAACC,OAAO,CAAC,CAAC,CAAC,GAAGD,UAAU,CAACC;IACtC,CAAC,CAAC,EACF,CAAC,CACH;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA,MAAMC,mBAAmB,GAAIC,MAAuB,IAClDC,MAAM,CAACC,OAAO,CAACF,MAAM,CAACG,kBAAkB,CAAC,CAACC,MAAM,CAC9CC,IAAA;EAAA,IAAC,GAAGC,KAAK,CAAC,GAAAD,IAAA;EAAA,OAAKC,KAAK,CAACC,OAAO,KAAK,IAAI;AAAA,CACvC,CAAiC;;AAEnC;AACA;AACA;AACA,MAAMC,yBAAyB,GAAIR,MAAuB,IACxDC,MAAM,CAACC,OAAO,CAACF,MAAM,CAACG,kBAAkB,CAAC,CAACC,MAAM,CAC9CK,KAAA;EAAA,IAAC,GAAGH,KAAK,CAAC,GAAAG,KAAA;EAAA,OAAKH,KAA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