@pagopa/io-react-native-wallet 0.28.1 → 0.29.0
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/README.md +43 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js +5 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +17 -3
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/05-authorize-access.js +5 -0
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +13 -2
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +10 -0
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/presentation/01-start-flow.js +14 -14
- package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js +4 -2
- package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
- package/lib/commonjs/credential/presentation/03-get-request-object.js +2 -2
- package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/05-verify-request-object.js +11 -4
- package/lib/commonjs/credential/presentation/05-verify-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +54 -14
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +26 -7
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js +4 -4
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/commonjs/credential/presentation/README.md +96 -2
- package/lib/commonjs/credential/presentation/errors.js +16 -19
- package/lib/commonjs/credential/presentation/errors.js.map +1 -1
- package/lib/commonjs/credential/presentation/index.js +27 -2
- package/lib/commonjs/credential/presentation/index.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 +2 -0
- package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -1
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +3 -0
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +1 -1
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js +5 -0
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js.map +1 -1
- package/lib/commonjs/index.js +3 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/decoder.js +2 -0
- package/lib/commonjs/utils/decoder.js.map +1 -1
- package/lib/commonjs/utils/logging.js +68 -0
- package/lib/commonjs/utils/logging.js.map +1 -0
- package/lib/commonjs/utils/misc.js +2 -0
- package/lib/commonjs/utils/misc.js.map +1 -1
- package/lib/commonjs/utils/par.js +2 -0
- package/lib/commonjs/utils/par.js.map +1 -1
- package/lib/commonjs/wallet-instance/index.js +4 -0
- package/lib/commonjs/wallet-instance/index.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/issuing.js +5 -0
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/credential/issuance/03-start-user-authorization.js +5 -0
- package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js +17 -3
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/05-authorize-access.js +5 -0
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +13 -2
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +10 -0
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/presentation/01-start-flow.js +14 -14
- package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/module/credential/presentation/02-evaluate-rp-trust.js +4 -2
- package/lib/module/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
- package/lib/module/credential/presentation/03-get-request-object.js +2 -2
- package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/module/credential/presentation/05-verify-request-object.js +11 -4
- package/lib/module/credential/presentation/05-verify-request-object.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js +55 -14
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +25 -6
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/module/credential/presentation/08-send-authorization-response.js +4 -4
- package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/module/credential/presentation/README.md +96 -2
- package/lib/module/credential/presentation/errors.js +13 -16
- package/lib/module/credential/presentation/errors.js.map +1 -1
- package/lib/module/credential/presentation/index.js +4 -3
- package/lib/module/credential/presentation/index.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 +2 -0
- package/lib/module/credential/status/02-status-attestation.js.map +1 -1
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +3 -0
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +1 -1
- package/lib/module/credential/trustmark/get-credential-trustmark.js +5 -0
- package/lib/module/credential/trustmark/get-credential-trustmark.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/decoder.js +2 -0
- package/lib/module/utils/decoder.js.map +1 -1
- package/lib/module/utils/logging.js +62 -0
- package/lib/module/utils/logging.js.map +1 -0
- package/lib/module/utils/misc.js +2 -0
- package/lib/module/utils/misc.js.map +1 -1
- package/lib/module/utils/par.js +2 -0
- package/lib/module/utils/par.js.map +1 -1
- package/lib/module/wallet-instance/index.js +4 -0
- package/lib/module/wallet-instance/index.js.map +1 -1
- package/lib/module/wallet-instance-attestation/issuing.js +5 -0
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +2 -2
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +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/presentation/01-start-flow.d.ts +17 -19
- package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts +1 -0
- package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts +1 -4
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts +4 -2
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +13 -5
- 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 +7 -2
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +3 -3
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/errors.d.ts +14 -9
- package/lib/typescript/credential/presentation/errors.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/index.d.ts +5 -4
- package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/types.d.ts +3 -3
- package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -1
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +1 -1
- package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/decoder.d.ts.map +1 -1
- package/lib/typescript/utils/logging.d.ts +35 -0
- package/lib/typescript/utils/logging.d.ts.map +1 -0
- package/lib/typescript/utils/misc.d.ts.map +1 -1
- package/lib/typescript/utils/par.d.ts.map +1 -1
- package/lib/typescript/wallet-instance/index.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/credential/issuance/03-start-user-authorization.ts +18 -0
- package/src/credential/issuance/04-complete-user-authorization.ts +57 -3
- package/src/credential/issuance/05-authorize-access.ts +16 -0
- package/src/credential/issuance/06-obtain-credential.ts +31 -2
- package/src/credential/issuance/07-verify-and-parse-credential.ts +27 -1
- package/src/credential/presentation/01-start-flow.ts +18 -20
- package/src/credential/presentation/02-evaluate-rp-trust.ts +3 -2
- package/src/credential/presentation/03-get-request-object.ts +4 -6
- package/src/credential/presentation/05-verify-request-object.ts +17 -6
- package/src/credential/presentation/07-evaluate-dcql-query.ts +60 -17
- package/src/credential/presentation/07-evaluate-input-descriptor.ts +53 -39
- package/src/credential/presentation/08-send-authorization-response.ts +9 -7
- package/src/credential/presentation/README.md +96 -2
- package/src/credential/presentation/errors.ts +21 -14
- package/src/credential/presentation/index.ts +22 -4
- package/src/credential/presentation/types.ts +1 -1
- package/src/credential/status/02-status-attestation.ts +3 -0
- package/src/credential/status/03-verify-and-parse-status-attestation.ts +10 -0
- package/src/credential/trustmark/get-credential-trustmark.ts +19 -0
- package/src/index.ts +2 -0
- package/src/utils/decoder.ts +5 -0
- package/src/utils/logging.ts +68 -0
- package/src/utils/misc.ts +5 -0
- package/src/utils/par.ts +6 -0
- package/src/wallet-instance/index.ts +17 -1
- package/src/wallet-instance-attestation/issuing.ts +19 -0
@@ -1,6 +1,7 @@
|
|
1
1
|
import { generateRandomAlphaNumericString } from "../../utils/misc";
|
2
2
|
import { makeParRequest } from "../../utils/par";
|
3
3
|
import { ASSERTION_TYPE } from "./const";
|
4
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
4
5
|
/**
|
5
6
|
* Ensures that the credential type requested is supported by the issuer and contained in the
|
6
7
|
* issuer configuration.
|
@@ -20,6 +21,7 @@ const selectCredentialDefinition = (issuerConf, credentialType) => {
|
|
20
21
|
type: "openid_credential"
|
21
22
|
}));
|
22
23
|
if (!result) {
|
24
|
+
Logger.log(LogLevel.ERROR, `Requested credential type ${credentialType} is not supported by the issuer according to its configuration ${JSON.stringify(credential_configurations_supported)}`);
|
23
25
|
throw new Error(`No credential support the type '${credentialType}'`);
|
24
26
|
}
|
25
27
|
return result;
|
@@ -34,7 +36,9 @@ const selectCredentialDefinition = (issuerConf, credentialType) => {
|
|
34
36
|
const selectResponseMode = (issuerConf, credentialType) => {
|
35
37
|
const responseModeSupported = issuerConf.oauth_authorization_server.response_modes_supported;
|
36
38
|
const responseMode = credentialType === "PersonIdentificationData" ? "query" : "form_post.jwt";
|
39
|
+
Logger.log(LogLevel.DEBUG, `Selected response mode ${responseMode} for credential type ${credentialType}`);
|
37
40
|
if (!responseModeSupported.includes(responseMode)) {
|
41
|
+
Logger.log(LogLevel.ERROR, `Requested response mode ${responseMode} is not supported by the issuer according to its configuration ${JSON.stringify(responseModeSupported)}`);
|
38
42
|
throw new Error(`No response mode support the type '${credentialType}'`);
|
39
43
|
}
|
40
44
|
return responseMode;
|
@@ -67,6 +71,7 @@ export const startUserAuthorization = async (issuerConf, credentialType, ctx) =>
|
|
67
71
|
} = ctx;
|
68
72
|
const clientId = await wiaCryptoContext.getPublicKey().then(_ => _.kid);
|
69
73
|
if (!clientId) {
|
74
|
+
Logger.log(LogLevel.ERROR, `Public key associated with kid ${clientId} not found in the device`);
|
70
75
|
throw new Error("No public key found");
|
71
76
|
}
|
72
77
|
const codeVerifier = generateRandomAlphaNumericString(64);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["generateRandomAlphaNumericString","makeParRequest","ASSERTION_TYPE","selectCredentialDefinition","issuerConf","credentialType","credential_configurations_supported","openid_credential_issuer","result","Object","keys","filter","e","includes","map","credential_configuration_id","format","type","Error","selectResponseMode","responseModeSupported","oauth_authorization_server","response_modes_supported","responseMode","startUserAuthorization","ctx","wiaCryptoContext","walletInstanceAttestation","redirectUri","appFetch","fetch","clientId","getPublicKey","then","_","kid","codeVerifier","parEndpoint","pushed_authorization_request_endpoint","credentialDefinition","getPar","issuerRequestUri"],"sourceRoot":"../../../../src","sources":["credential/issuance/03-start-user-authorization.ts"],"mappings":"AAEA,SAASA,gCAAgC,QAAkB,kBAAkB;AAG7E,SAA8BC,cAAc,QAAQ,iBAAiB;AACrE,SAASC,cAAc,QAAQ,SAAS;
|
1
|
+
{"version":3,"names":["generateRandomAlphaNumericString","makeParRequest","ASSERTION_TYPE","LogLevel","Logger","selectCredentialDefinition","issuerConf","credentialType","credential_configurations_supported","openid_credential_issuer","result","Object","keys","filter","e","includes","map","credential_configuration_id","format","type","log","ERROR","JSON","stringify","Error","selectResponseMode","responseModeSupported","oauth_authorization_server","response_modes_supported","responseMode","DEBUG","startUserAuthorization","ctx","wiaCryptoContext","walletInstanceAttestation","redirectUri","appFetch","fetch","clientId","getPublicKey","then","_","kid","codeVerifier","parEndpoint","pushed_authorization_request_endpoint","credentialDefinition","getPar","issuerRequestUri"],"sourceRoot":"../../../../src","sources":["credential/issuance/03-start-user-authorization.ts"],"mappings":"AAEA,SAASA,gCAAgC,QAAkB,kBAAkB;AA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M,CACnCT,QAAQ,EACRK,YAAY,EACZR,WAAW,EACXN,YAAY,EACZe,WAAW,EACXV,yBAAyB,EACzB,CAACY,oBAAoB,CAAC,EACtB5C,cACF,CAAC;EAED,OAAO;IAAE8C,gBAAgB;IAAEV,QAAQ;IAAEK,YAAY;IAAEG;EAAqB,CAAC;AAC3E,CAAC"}
|
@@ -8,6 +8,7 @@ import { v4 as uuidv4 } from "uuid";
|
|
8
8
|
import { ResponseUriResultShape } from "./types";
|
9
9
|
import { getJwtFromFormPost } from "../../utils/decoder";
|
10
10
|
import { AuthorizationError, AuthorizationIdpError } from "./errors";
|
11
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
11
12
|
|
12
13
|
/**
|
13
14
|
* 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.
|
@@ -19,16 +20,18 @@ import { AuthorizationError, AuthorizationIdpError } from "./errors";
|
|
19
20
|
* @param issuerRequestUri the URI of the issuer where the request is sent
|
20
21
|
* @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
|
21
22
|
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
22
|
-
* @param idpHint Unique identifier of the IDP selected by the user
|
23
|
+
* @param idpHint Unique identifier of the IDP selected by the user (optional)
|
23
24
|
* @returns An object containing the authorization URL
|
24
25
|
*/
|
25
26
|
export const buildAuthorizationUrl = async (issuerRequestUri, clientId, issuerConf, idpHint) => {
|
26
27
|
const authzRequestEndpoint = issuerConf.oauth_authorization_server.authorization_endpoint;
|
27
28
|
const params = new URLSearchParams({
|
28
29
|
client_id: clientId,
|
29
|
-
request_uri: issuerRequestUri
|
30
|
-
idphint: idpHint
|
30
|
+
request_uri: issuerRequestUri
|
31
31
|
});
|
32
|
+
if (idpHint) {
|
33
|
+
params.append("idphint", idpHint);
|
34
|
+
}
|
32
35
|
const authUrl = `${authzRequestEndpoint}?${params}`;
|
33
36
|
return {
|
34
37
|
authUrl
|
@@ -43,6 +46,7 @@ export const buildAuthorizationUrl = async (issuerRequestUri, clientId, issuerCo
|
|
43
46
|
* @returns the authorization response which contains code, state and iss
|
44
47
|
*/
|
45
48
|
export const completeUserAuthorizationWithQueryMode = async authRedirectUrl => {
|
49
|
+
Logger.log(LogLevel.DEBUG, `The requeste credential is a PersonIdentificationData, completing the user authorization with query mode`);
|
46
50
|
const query = parseUrl(authRedirectUrl).query;
|
47
51
|
return parseAuthorizationResponse(query);
|
48
52
|
};
|
@@ -61,15 +65,18 @@ export const completeUserAuthorizationWithQueryMode = async authRedirectUrl => {
|
|
61
65
|
*/
|
62
66
|
export const getRequestedCredentialToBePresented = async function (issuerRequestUri, clientId, issuerConf) {
|
63
67
|
let appFetch = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : fetch;
|
68
|
+
Logger.log(LogLevel.DEBUG, `The requeste credential is not a PersonIdentificationData, requesting the credential to be presented`);
|
64
69
|
const authzRequestEndpoint = issuerConf.oauth_authorization_server.authorization_endpoint;
|
65
70
|
const params = new URLSearchParams({
|
66
71
|
client_id: clientId,
|
67
72
|
request_uri: issuerRequestUri
|
68
73
|
});
|
74
|
+
Logger.log(LogLevel.DEBUG, `Requesting the request object to ${authzRequestEndpoint}?${params.toString()}`);
|
69
75
|
const requestObject = await appFetch(`${authzRequestEndpoint}?${params.toString()}`, {
|
70
76
|
method: "GET"
|
71
77
|
}).then(hasStatusOrThrow(200, IssuerResponseError)).then(res => res.text()).then(jws => decode(jws)).then(reqObj => RequestObject.safeParse(reqObj.payload));
|
72
78
|
if (!requestObject.success) {
|
79
|
+
Logger.log(LogLevel.ERROR, `Error while validating the response object: ${requestObject.error.message}`);
|
73
80
|
throw new ValidationFailed({
|
74
81
|
message: "Request Object validation failed",
|
75
82
|
reason: requestObject.error.message
|
@@ -95,6 +102,7 @@ export const getRequestedCredentialToBePresented = async function (issuerRequest
|
|
95
102
|
* @returns the authorization response which contains code, state and iss
|
96
103
|
*/
|
97
104
|
export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject, ctx) => {
|
105
|
+
Logger.log(LogLevel.DEBUG, `The requeste credential is not a PersonIdentificationData, completing the user authorization with form_post.jwt mode`);
|
98
106
|
const {
|
99
107
|
wiaCryptoContext,
|
100
108
|
pidCryptoContext,
|
@@ -118,6 +126,7 @@ export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject
|
|
118
126
|
jti: uuidv4().toString(),
|
119
127
|
nonce: requestObject.nonce
|
120
128
|
}).setIssuedAt().setExpirationTime("5m").setAudience(requestObject.response_uri).sign();
|
129
|
+
Logger.log(LogLevel.DEBUG, `Wallet instance attestation JWT token: ${wiaWpToken}`);
|
121
130
|
|
122
131
|
/* The path parameter refers to the vp_token variable of the authzResponsePayload and must point to the plain credential which
|
123
132
|
* is cointaned in the `vp` property of the signed jwt token payload
|
@@ -135,11 +144,13 @@ export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject
|
|
135
144
|
format: "jwt"
|
136
145
|
}]
|
137
146
|
};
|
147
|
+
Logger.log(LogLevel.DEBUG, `Presentation submission: ${JSON.stringify(presentationSubmission)}`);
|
138
148
|
const authzResponsePayload = encodeBase64(JSON.stringify({
|
139
149
|
state: requestObject.state,
|
140
150
|
presentation_submission: presentationSubmission,
|
141
151
|
vp_token: [pidWpToken, wiaWpToken]
|
142
152
|
}));
|
153
|
+
Logger.log(LogLevel.DEBUG, `Authz response payload: ${authzResponsePayload}`);
|
143
154
|
|
144
155
|
// Note: according to the spec, the response should be encrypted with the public key of the RP however this is not implemented yet
|
145
156
|
// https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#name-signed-and-encrypted-response
|
@@ -162,6 +173,7 @@ export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject
|
|
162
173
|
}).then(hasStatusOrThrow(200, IssuerResponseError)).then(reqUri => reqUri.json());
|
163
174
|
const responseUri = ResponseUriResultShape.safeParse(resUriRes);
|
164
175
|
if (!responseUri.success) {
|
176
|
+
Logger.log(LogLevel.ERROR, `Error while validating the response uri: ${responseUri.error.message}`);
|
165
177
|
throw new ValidationFailed({
|
166
178
|
message: "Response Uri validation failed",
|
167
179
|
reason: responseUri.error.message
|
@@ -182,9 +194,11 @@ export const parseAuthorizationResponse = authRes => {
|
|
182
194
|
if (!authResParsed.success) {
|
183
195
|
const authErr = AuthorizationErrorShape.safeParse(authRes);
|
184
196
|
if (!authErr.success) {
|
197
|
+
Logger.log(LogLevel.ERROR, `Error while parsing the authorization response: ${authResParsed.error.message}`);
|
185
198
|
throw new AuthorizationError(authResParsed.error.message); // an error occured while parsing the result and the error
|
186
199
|
}
|
187
200
|
|
201
|
+
Logger.log(LogLevel.ERROR, `Error while authorizating with the idp: ${JSON.stringify(authErr)}`);
|
188
202
|
throw new AuthorizationIdpError(authErr.data.error, authErr.data.error_description);
|
189
203
|
}
|
190
204
|
return authResParsed.data;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","hasStatusOrThrow","parseUrl","IssuerResponseError","ValidationFailed","decode","encodeBase64","SignJWT","RequestObject","v4","uuidv4","ResponseUriResultShape","getJwtFromFormPost","AuthorizationError","AuthorizationIdpError","buildAuthorizationUrl","issuerRequestUri","clientId","issuerConf","idpHint","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","
|
1
|
+
{"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","hasStatusOrThrow","parseUrl","IssuerResponseError","ValidationFailed","decode","encodeBase64","SignJWT","RequestObject","v4","uuidv4","ResponseUriResultShape","getJwtFromFormPost","AuthorizationError","AuthorizationIdpError","LogLevel","Logger","buildAuthorizationUrl","issuerRequestUri","clientId","issuerConf","idpHint","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","append","authUrl","completeUserAuthorizationWithQueryMode","authRedirectUrl","log","DEBUG","query","parseAuthorizationResponse","getRequestedCredentialToBePresented","appFetch","arguments","length","undefined","fetch","toString","requestObject","method","then","res","text","jws","reqObj","safeParse","payload","success","ERROR","error","message","reason","data","completeUserAuthorizationWithFormPostJwtMode","ctx","wiaCryptoContext","pidCryptoContext","pid","walletInstanceAttestation","wiaWpToken","setProtectedHeader","alg","typ","setPayload","vp","jti","nonce","setIssuedAt","setExpirationTime","setAudience","response_uri","sign","pidWpToken","presentationSubmission","definition_id","id","descriptor_map","path","format","JSON","stringify","authzResponsePayload","state","presentation_submission","vp_token","body","response","resUriRes","headers","reqUri","json","responseUri","redirect_uri","cbRes","decodedJwt","authRes","authResParsed","authErr","error_description"],"sourceRoot":"../../../../src","sources":["credential/issuance/04-complete-user-authorization.ts"],"mappings":"AAAA,SACEA,uBAAuB,EACvBC,wBAAwB,QAEnB,kBAAkB;AACzB,SAASC,gBAAgB,QAAkB,kBAAkB;AAE7D,OAAOC,QAAQ,MAAM,WAAW;AAChC,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,oBAAoB;AAE1E,SACEC,MAAM,EACNC,YAAY,EACZC,OAAO,QAEF,6BAA6B;AACpC,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,sBAAsB,QAAQ,SAAS;AAChD,SAASC,kBAAkB,QAAQ,qBAAqB;AACxD,SAASC,kBAAkB,EAAEC,qBAAqB,QAAQ,UAAU;AACpE,SAASC,QAAQ,EAAEC,MAAM,QAAQ,qBAAqB;;AAEtD;AACA;AACA;;AAgCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,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,eAAe,CAAC;IACjCC,SAAS,EAAER,QAAQ;IACnBS,WAAW,EAAEV;EACf,CAAC,CAAC;EAEF,IAAIG,OAAO,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G,EAAEE,mBAAmB,CAAC,CAAC,CAChD2C,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBF,IAAI,CAAClC,kBAAkB,CAAC,CACxBkC,IAAI,CAAEqD,KAAK,IAAK/D,0BAA0B,CAAC+D,KAAK,CAACC,UAAU,CAAChD,OAAO,CAAC,CAAC;AAC1E,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMhB,0BAA0B,GACrCiE,OAAgB,IACQ;EACxB,MAAMC,aAAa,GAAGtG,wBAAwB,CAACmD,SAAS,CAACkD,OAAO,CAAC;EACjE,IAAI,CAACC,aAAa,CAACjD,OAAO,EAAE;IAC1B,MAAMkD,OAAO,GAAGxG,uBAAuB,CAACoD,SAAS,CAACkD,OAAO,CAAC;IAC1D,IAAI,CAACE,OAAO,CAAClD,OAAO,EAAE;MACpBrC,MAAM,CAACiB,GAAG,CACRlB,QAAQ,CAACuC,KAAK,EACb,mDAAkDgD,aAAa,CAAC/C,KAAK,CAACC,OAAQ,EACjF,CAAC;MACD,MAAM,IAAI3C,kBAAkB,CAACyF,aAAa,CAAC/C,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC;IAC7D;;IACAxC,MAAM,CAACiB,GAAG,CACRlB,QAAQ,CAACuC,KAAK,EACb,2CAA0C+B,IAAI,CAACC,SAAS,CAACiB,OAAO,CAAE,EACrE,CAAC;IACD,MAAM,IAAIzF,qBAAqB,CAC7ByF,OAAO,CAAC7C,IAAI,CAACH,KAAK,EAClBgD,OAAO,CAAC7C,IAAI,CAAC8C,iBACf,CAAC;EACH;EACA,OAAOF,aAAa,CAAC5C,IAAI;AAC3B,CAAC"}
|
@@ -6,6 +6,7 @@ import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
|
|
6
6
|
import { ASSERTION_TYPE } from "./const";
|
7
7
|
import { TokenResponse } from "./types";
|
8
8
|
import { IssuerResponseError, ValidationFailed } from "../../utils/errors";
|
9
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
9
10
|
/**
|
10
11
|
* Creates and sends the DPoP Proof JWT to be presented with the authorization code to the /token endpoint of the authorization server
|
11
12
|
* for requesting the issuance of an access token bound to the public key of the Wallet Instance contained within the DPoP.
|
@@ -41,11 +42,13 @@ export const authorizeAccess = async (issuerConf, code, clientId, redirectUri, c
|
|
41
42
|
htu: tokenUrl,
|
42
43
|
jti: `${uuidv4()}`
|
43
44
|
}, dPopCryptoContext);
|
45
|
+
Logger.log(LogLevel.DEBUG, `Token request DPoP: ${tokenRequestSignedDPop}`);
|
44
46
|
const signedWiaPoP = await createPopToken({
|
45
47
|
jti: `${uuidv4()}`,
|
46
48
|
aud,
|
47
49
|
iss
|
48
50
|
}, wiaCryptoContext);
|
51
|
+
Logger.log(LogLevel.DEBUG, `WIA DPoP token: ${signedWiaPoP}`);
|
49
52
|
const requestBody = {
|
50
53
|
grant_type: "authorization_code",
|
51
54
|
client_id: clientId,
|
@@ -56,6 +59,7 @@ export const authorizeAccess = async (issuerConf, code, clientId, redirectUri, c
|
|
56
59
|
client_assertion: walletInstanceAttestation + "~" + signedWiaPoP
|
57
60
|
};
|
58
61
|
const authorizationRequestFormBody = new URLSearchParams(requestBody);
|
62
|
+
Logger.log(LogLevel.DEBUG, `Auth form request body: ${authorizationRequestFormBody}`);
|
59
63
|
const tokenRes = await appFetch(tokenUrl, {
|
60
64
|
method: "POST",
|
61
65
|
headers: {
|
@@ -65,6 +69,7 @@ export const authorizeAccess = async (issuerConf, code, clientId, redirectUri, c
|
|
65
69
|
body: authorizationRequestFormBody.toString()
|
66
70
|
}).then(hasStatusOrThrow(200, IssuerResponseError)).then(res => res.json()).then(body => TokenResponse.safeParse(body));
|
67
71
|
if (!tokenRes.success) {
|
72
|
+
Logger.log(LogLevel.ERROR, `Token Response validation failed: ${tokenRes.error.message}`);
|
68
73
|
throw new ValidationFailed({
|
69
74
|
message: "Token Response validation failed",
|
70
75
|
reason: tokenRes.error.message
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["hasStatusOrThrow","createDPopToken","v4","uuidv4","createPopToken","WalletInstanceAttestation","ASSERTION_TYPE","TokenResponse","IssuerResponseError","ValidationFailed","authorizeAccess","issuerConf","code","clientId","redirectUri","codeVerifier","context","appFetch","fetch","walletInstanceAttestation","wiaCryptoContext","dPopCryptoContext","parEndpoint","oauth_authorization_server","pushed_authorization_request_endpoint","parUrl","URL","aud","protocol","hostname","iss","decode","payload","cnf","jwk","kid","tokenUrl","token_endpoint","tokenRequestSignedDPop","htm","htu","jti","signedWiaPoP","requestBody","grant_type","client_id","redirect_uri","code_verifier","client_assertion_type","client_assertion","authorizationRequestFormBody","URLSearchParams","tokenRes","method","headers","DPoP","body","toString","then","res","json","safeParse","success","
|
1
|
+
{"version":3,"names":["hasStatusOrThrow","createDPopToken","v4","uuidv4","createPopToken","WalletInstanceAttestation","ASSERTION_TYPE","TokenResponse","IssuerResponseError","ValidationFailed","LogLevel","Logger","authorizeAccess","issuerConf","code","clientId","redirectUri","codeVerifier","context","appFetch","fetch","walletInstanceAttestation","wiaCryptoContext","dPopCryptoContext","parEndpoint","oauth_authorization_server","pushed_authorization_request_endpoint","parUrl","URL","aud","protocol","hostname","iss","decode","payload","cnf","jwk","kid","tokenUrl","token_endpoint","tokenRequestSignedDPop","htm","htu","jti","log","DEBUG","signedWiaPoP","requestBody","grant_type","client_id","redirect_uri","code_verifier","client_assertion_type","client_assertion","authorizationRequestFormBody","URLSearchParams","tokenRes","method","headers","DPoP","body","toString","then","res","json","safeParse","success","ERROR","error","message","reason","accessToken","data"],"sourceRoot":"../../../../src","sources":["credential/issuance/05-authorize-access.ts"],"mappings":"AAAA,SAASA,gBAAgB,QAAkB,kBAAkB;AAG7D,SAASC,eAAe,QAAQ,kBAAkB;AAClD,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,cAAc,QAAQ,iBAAiB;AAChD,OAAO,KAAKC,yBAAyB,MAAM,mCAAmC;A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ACY,KAAK,CAACC;IACzB,CAAC,CAAC;EACJ;EAEA,OAAO;IAAEE,WAAW,EAAEf,QAAQ,CAACgB;EAAK,CAAC;AACvC,CAAC"}
|
@@ -4,6 +4,7 @@ import { IssuerResponseError, IssuerResponseErrorCodes, ResponseErrorBuilder, Un
|
|
4
4
|
import { CredentialResponse } from "./types";
|
5
5
|
import { createDPopToken } from "../../utils/dpop";
|
6
6
|
import { v4 as uuidv4 } from "uuid";
|
7
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
7
8
|
export const createNonceProof = async (nonce, issuer, audience, ctx) => {
|
8
9
|
const jwk = await ctx.getPublicKey();
|
9
10
|
return new SignJWT(ctx).setPayload({
|
@@ -30,7 +31,7 @@ export const createNonceProof = async (nonce, issuer, audience, ctx) => {
|
|
30
31
|
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
31
32
|
* @returns The credential response containing the credential
|
32
33
|
*/
|
33
|
-
export const obtainCredential = async (issuerConf, accessToken, clientId, credentialDefinition, context) => {
|
34
|
+
export const obtainCredential = async (issuerConf, accessToken, clientId, credentialDefinition, context, operationType) => {
|
34
35
|
const {
|
35
36
|
credentialCryptoContext,
|
36
37
|
appFetch = fetch,
|
@@ -44,10 +45,12 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
|
|
44
45
|
* @see https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-proof-types
|
45
46
|
*/
|
46
47
|
const signedNonceProof = await createNonceProof(accessToken.c_nonce, clientId, credentialUrl, credentialCryptoContext);
|
48
|
+
Logger.log(LogLevel.DEBUG, `Signed nonce proof: ${signedNonceProof}`);
|
47
49
|
|
48
50
|
// Validation of accessTokenResponse.authorization_details if contain credentialDefinition
|
49
51
|
const containsCredentialDefinition = accessToken.authorization_details.some(c => c.credential_configuration_id === credentialDefinition.credential_configuration_id && c.format === credentialDefinition.format && c.type === credentialDefinition.type);
|
50
52
|
if (!containsCredentialDefinition) {
|
53
|
+
Logger.log(LogLevel.ERROR, `Credential definition not found in the access token response ${accessToken.authorization_details}`);
|
51
54
|
throw new ValidationFailed({
|
52
55
|
message: "The access token response does not contain the requested credential"
|
53
56
|
});
|
@@ -64,27 +67,34 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
|
|
64
67
|
proof_type: "jwt"
|
65
68
|
}
|
66
69
|
};
|
70
|
+
Logger.log(LogLevel.DEBUG, `Credential request body: ${JSON.stringify(credentialRequestFormBody)}`);
|
67
71
|
const tokenRequestSignedDPop = await createDPopToken({
|
68
72
|
htm: "POST",
|
69
73
|
htu: credentialUrl,
|
70
74
|
jti: `${uuidv4()}`,
|
71
75
|
ath: await sha256ToBase64(accessToken.access_token)
|
72
76
|
}, dPopCryptoContext);
|
77
|
+
Logger.log(LogLevel.DEBUG, `Token request DPoP: ${tokenRequestSignedDPop}`);
|
73
78
|
const credentialRes = await appFetch(credentialUrl, {
|
74
79
|
method: "POST",
|
75
80
|
headers: {
|
76
81
|
"Content-Type": "application/json",
|
77
82
|
DPoP: tokenRequestSignedDPop,
|
78
|
-
Authorization: `${accessToken.token_type} ${accessToken.access_token}
|
83
|
+
Authorization: `${accessToken.token_type} ${accessToken.access_token}`,
|
84
|
+
...(operationType === "reissuing" && {
|
85
|
+
operationType
|
86
|
+
})
|
79
87
|
},
|
80
88
|
body: JSON.stringify(credentialRequestFormBody)
|
81
89
|
}).then(hasStatusOrThrow(200)).then(res => res.json()).then(body => CredentialResponse.safeParse(body)).catch(handleObtainCredentialError);
|
82
90
|
if (!credentialRes.success) {
|
91
|
+
Logger.log(LogLevel.ERROR, `Credential Response validation failed: ${credentialRes.error.message}`);
|
83
92
|
throw new ValidationFailed({
|
84
93
|
message: "Credential Response validation failed",
|
85
94
|
reason: credentialRes.error.message
|
86
95
|
});
|
87
96
|
}
|
97
|
+
Logger.log(LogLevel.DEBUG, `Credential Response: ${JSON.stringify(credentialRes.data)}`);
|
88
98
|
return credentialRes.data;
|
89
99
|
};
|
90
100
|
|
@@ -95,6 +105,7 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
|
|
95
105
|
* @throws {IssuerResponseError} with a specific code for more context
|
96
106
|
*/
|
97
107
|
const handleObtainCredentialError = e => {
|
108
|
+
Logger.log(LogLevel.ERROR, `Error occurred while obtaining credential: ${e}`);
|
98
109
|
if (!(e instanceof UnexpectedStatusCodeError)) {
|
99
110
|
throw e;
|
100
111
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["sha256ToBase64","SignJWT","hasStatusOrThrow","IssuerResponseError","IssuerResponseErrorCodes","ResponseErrorBuilder","UnexpectedStatusCodeError","ValidationFailed","CredentialResponse","createDPopToken","v4","uuidv4","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","obtainCredential","issuerConf","accessToken","clientId","credentialDefinition","context","credentialCryptoContext","appFetch","fetch","dPopCryptoContext","credentialUrl","openid_credential_issuer","credential_endpoint","signedNonceProof","c_nonce","containsCredentialDefinition","authorization_details","some","c","credential_configuration_id","format","type","message","credentialRequestFormBody","credential_definition","proof","jwt","proof_type","tokenRequestSignedDPop","htm","htu","jti","ath","access_token","credentialRes","method","headers","DPoP","Authorization","token_type","body","
|
1
|
+
{"version":3,"names":["sha256ToBase64","SignJWT","hasStatusOrThrow","IssuerResponseError","IssuerResponseErrorCodes","ResponseErrorBuilder","UnexpectedStatusCodeError","ValidationFailed","CredentialResponse","createDPopToken","v4","uuidv4","LogLevel","Logger","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","obtainCredential","issuerConf","accessToken","clientId","credentialDefinition","context","operationType","credentialCryptoContext","appFetch","fetch","dPopCryptoContext","credentialUrl","openid_credential_issuer","credential_endpoint","signedNonceProof","c_nonce","log","DEBUG","containsCredentialDefinition","authorization_details","some","c","credential_configuration_id","format","type","ERROR","message","credentialRequestFormBody","credential_definition","proof","jwt","proof_type","JSON","stringify","tokenRequestSignedDPop","htm","htu","jti","ath","access_token","credentialRes","method","headers","DPoP","Authorization","token_type","body","then","res","json","safeParse","catch","handleObtainCredentialError","success","error","reason","data","e","handle","code","CredentialIssuingNotSynchronous","CredentialInvalidStatus","CredentialRequestFailed","buildFrom"],"sourceRoot":"../../../../src","sources":["credential/issuance/06-obtain-credential.ts"],"mappings":"AAAA,SAEEA,cAAc,EACdC,OAAO,QACF,6BAA6B;AAGpC,SAASC,gBAAgB,QAAkB,kBAAkB;AAE7D,SACEC,mBAAmB,EACnBC,wBAAwB,EACxBC,oBAAoB,EACpBC,yBAAyB,EACzBC,gBAAgB,QACX,oBAAoB;AAC3B,SAASC,kBAAkB,QAAQ,SAAS;AAC5C,SAASC,eAAe,QAAQ,kBAAkB;AAClD,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,QAAQ,EAAEC,MAAM,QAAQ,qBAAqB;AAetD,OAAO,MAAMC,gBAAgB,GAAG,MAAAA,CAC9BC,KAAa,EACbC,MAAc,EACdC,QAAgB,EAChBC,GAAkB,KACE;EACpB,MAAMC,GAAG,GAAG,MAAMD,GAAG,CAACE,YAAY,CAAC,CAAC;EACpC,OAAO,IAAInB,OAAO,CAACiB,GAAG,CAAC,CACpBG,UAAU,CAAC;IACVN;EACF,CAAC,CAAC,CACDO,kBAAkB,CAAC;IAClBC,GAAG,EAAE,sBAAsB;IAC3BJ;EACF,CAAC,CAAC,CACDK,WAAW,CAACP,QAAQ,CAAC,CACrBQ,SAAS,CAACT,MAAM,CAAC,CACjBU,WAAW,CAAC,CAAC,CACbC,iBAAiB,CAAC,MAAM,CAAC,CACzBC,IAAI,CAAC,CAAC;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAkC,GAAG,MAAAA,CAChDC,UAAU,EACVC,WAAW,EACXC,Q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AAM,EAAEf,aAAa,CAACc,KAAK,CAAC5B;IAC9B,CAAC,CAAC;EACJ;EAEA1C,MAAM,CAACgC,GAAG,CACRjC,QAAQ,CAACkC,KAAK,EACb,wBAAuBe,IAAI,CAACC,SAAS,CAACO,aAAa,CAACgB,IAAI,CAAE,EAC7D,CAAC;EAED,OAAOhB,aAAa,CAACgB,IAAI;AAC3B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMJ,2BAA2B,GAAIK,CAAU,IAAK;EAClDzE,MAAM,CAACgC,GAAG,CAACjC,QAAQ,CAAC0C,KAAK,EAAG,8CAA6CgC,CAAE,EAAC,CAAC;EAE7E,IAAI,EAAEA,CAAC,YAAYhF,yBAAyB,CAAC,EAAE;IAC7C,MAAMgF,CAAC;EACT;EAEA,MAAM,IAAIjF,oBAAoB,CAACF,mBAAmB,CAAC,CAChDoF,MAAM,CAAC,GAAG,EAAE;IACX;IACA;IACAC,IAAI,EAAEpF,wBAAwB,CAACqF,+BAA+B;IAC9DlC,OAAO,EACL;EACJ,CAAC,CAAC,CACDgC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEpF,wBAAwB,CAACsF,uBAAuB;IACtDnC,OAAO,EAAE;EACX,CAAC,CAAC,CACDgC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEpF,wBAAwB,CAACsF,uBAAuB;IACtDnC,OAAO,EAAE;EACX,CAAC,CAAC,CACDgC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEpF,wBAAwB,CAACuF,uBAAuB;IACtDpC,OAAO,EAAE;EACX,CAAC,CAAC,CACDqC,SAAS,CAACN,CAAC,CAAC;AACjB,CAAC"}
|
@@ -2,6 +2,7 @@ import { IoWalletError } from "../../utils/errors";
|
|
2
2
|
import { SdJwt4VC } from "../../sd-jwt/types";
|
3
3
|
import { verify as verifySdJwt } from "../../sd-jwt";
|
4
4
|
import { getValueFromDisclosures } from "../../sd-jwt/converters";
|
5
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
5
6
|
|
6
7
|
// The credential as a collection of attributes in plain value
|
7
8
|
|
@@ -16,14 +17,17 @@ const parseCredentialSdJwt = function (credentials_supported, _ref) {
|
|
16
17
|
let includeUndefinedAttributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
17
18
|
const credentialSubject = credentials_supported[sdJwt.payload.vct];
|
18
19
|
if (!credentialSubject) {
|
20
|
+
Logger.log(LogLevel.ERROR, `Credential type not supported by the issuer: ${sdJwt.payload.vct}`);
|
19
21
|
throw new IoWalletError("Credential type not supported by the issuer");
|
20
22
|
}
|
21
23
|
if (credentialSubject.format !== sdJwt.header.typ) {
|
24
|
+
Logger.log(LogLevel.ERROR, `Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}'`);
|
22
25
|
throw new IoWalletError(`Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}', `);
|
23
26
|
}
|
24
27
|
|
25
28
|
// transfrom a record { key: value } in an iterable of pairs [key, value]
|
26
29
|
if (!credentialSubject.claims) {
|
30
|
+
Logger.log(LogLevel.ERROR, "Missing claims in the credential subject");
|
27
31
|
throw new IoWalletError("Missing claims in the credential subject"); // TODO [SIW-1268]: should not be optional
|
28
32
|
}
|
29
33
|
|
@@ -41,6 +45,7 @@ const parseCredentialSdJwt = function (credentials_supported, _ref) {
|
|
41
45
|
const missing = attrsNotInDisclosures.map(_ => _[0 /* key */]).join(", ");
|
42
46
|
const received = disclosures.map(_ => _[1 /* name */]).join(", ");
|
43
47
|
if (!ignoreMissingAttributes) {
|
48
|
+
Logger.log(LogLevel.ERROR, `Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`);
|
44
49
|
throw new IoWalletError(`Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`);
|
45
50
|
}
|
46
51
|
}
|
@@ -119,6 +124,7 @@ async function verifyCredentialSdJwt(rawCredential, issuerKeys, holderBindingCon
|
|
119
124
|
cnf
|
120
125
|
} = decodedCredential.sdJwt.payload;
|
121
126
|
if (!cnf.jwk.kid || cnf.jwk.kid !== holderBindingKey.kid) {
|
127
|
+
Logger.log(LogLevel.ERROR, `Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`);
|
122
128
|
throw new IoWalletError(`Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`);
|
123
129
|
}
|
124
130
|
return decodedCredential;
|
@@ -133,8 +139,10 @@ const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) =
|
|
133
139
|
includeUndefinedAttributes
|
134
140
|
} = _ref8;
|
135
141
|
const decoded = await verifyCredentialSdJwt(credential, issuerConf.openid_credential_issuer.jwks.keys, credentialCryptoContext);
|
142
|
+
Logger.log(LogLevel.DEBUG, `Decoded credential: ${JSON.stringify(decoded)}`);
|
136
143
|
const parsedCredential = parseCredentialSdJwt(issuerConf.openid_credential_issuer.credential_configurations_supported, decoded, ignoreMissingAttributes, includeUndefinedAttributes);
|
137
144
|
const maybeIssuedAt = getValueFromDisclosures(decoded.disclosures, "iat");
|
145
|
+
Logger.log(LogLevel.DEBUG, `Parsed credential: ${JSON.stringify(parsedCredential)}\nIssued at: ${maybeIssuedAt}`);
|
138
146
|
return {
|
139
147
|
parsedCredential,
|
140
148
|
expiration: new Date(decoded.sdJwt.payload.exp * 1000),
|
@@ -157,8 +165,10 @@ const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) =
|
|
157
165
|
*/
|
158
166
|
export const verifyAndParseCredential = async (issuerConf, credential, format, context) => {
|
159
167
|
if (format === "vc+sd-jwt") {
|
168
|
+
Logger.log(LogLevel.DEBUG, "Parsing credential in vc+sd-jwt format");
|
160
169
|
return verifyAndParseCredentialSdJwt(issuerConf, credential, format, context);
|
161
170
|
}
|
171
|
+
Logger.log(LogLevel.ERROR, `Unsupported credential format: ${format}`);
|
162
172
|
throw new IoWalletError(`Unsupported credential format: ${format}`);
|
163
173
|
};
|
164
174
|
//# sourceMappingURL=07-verify-and-parse-credential.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["IoWalletError","SdJwt4VC","verify","verifySdJwt","getValueFromDisclosures","parseCredentialSdJwt","credentials_supported","_ref","sdJwt","disclosures","ignoreMissingAttributes","arguments","length","undefined","includeUndefinedAttributes","credentialSubject","payload","vct","format","header","typ","claims","attrDefinitions","Object","entries","attrsNotInDisclosures","filter","_ref2","attrKey","some","_ref3","name","missing","map","_","join","received","definedValues","fromEntries","_ref4","_disclosures$find","definition","value","find","_ref5","display","reduce","names","_ref6","locale","undefinedValues","keys","includes","_ref7","key","verifyCredentialSdJwt","rawCredential","issuerKeys","holderBindingContext","decodedCredential","holderBindingKey","Promise","all","getPublicKey","cnf","jwk","kid","verifyAndParseCredentialSdJwt","issuerConf","credential","_ref8","credentialCryptoContext","decoded","openid_credential_issuer","jwks","parsedCredential","credential_configurations_supported","maybeIssuedAt","expiration","Date","exp","issuedAt","verifyAndParseCredential","context"],"sourceRoot":"../../../../src","sources":["credential/issuance/07-verify-and-parse-credential.ts"],"mappings":"AAGA,SAASA,aAAa,QAAQ,oBAAoB;AAClD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,MAAM,IAAIC,WAAW,QAAQ,cAAc;AACpD,SAASC,uBAAuB,QAAQ,yBAAyB;;
|
1
|
+
{"version":3,"names":["IoWalletError","SdJwt4VC","verify","verifySdJwt","getValueFromDisclosures","LogLevel","Logger","parseCredentialSdJwt","credentials_supported","_ref","sdJwt","disclosures","ignoreMissingAttributes","arguments","length","undefined","includeUndefinedAttributes","credentialSubject","payload","vct","log","ERROR","format","header","typ","claims","attrDefinitions","Object","entries","attrsNotInDisclosures","filter","_ref2","attrKey","some","_ref3","name","missing","map","_","join","received","definedValues","fromEntries","_ref4","_disclosures$find","definition","value","find","_ref5","display","reduce","names","_ref6","locale","undefinedValues","keys","includes","_ref7","key","verifyCredentialSdJwt","rawCredential","issuerKeys","holderBindingContext","decodedCredential","holderBindingKey","Promise","all","getPublicKey","cnf","jwk","kid","verifyAndParseCredentialSdJwt","issuerConf","credential","_ref8","credentialCryptoContext","decoded","openid_credential_issuer","jwks","DEBUG","JSON","stringify","parsedCredential","credential_configurations_supported","maybeIssuedAt","expiration","Date","exp","issuedAt","verifyAndParseCredential","context"],"sourceRoot":"../../../../src","sources":["credential/issuance/07-verify-and-parse-credential.ts"],"mappings":"AAGA,SAASA,aAAa,QAAQ,oBAAoB;AAClD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,MAAM,IAAIC,WAAW,QAAQ,cAAc;AACpD,SAASC,uBAAuB,QAAQ,yBAAyB;AAGjE,SAASC,QAAQ,EAAEC,MAAM,QAAQ,qBAAqB;;AAuBtD;;AAkBA;;AAKA,MAAMC,oBAAoB,GAAG,SAAAA,CAE3BC,qBAAgI,EAAAC,IAAA,EAI3G;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,MAAMI,iBAAiB,GAAGT,qBAAqB,CAACE,KAAK,CAACQ,OAAO,CAACC,GAAG,CAAC;EAElE,IAAI,CAACF,iBAAiB,EAAE;IACtBX,MAAM,CAACc,GAAG,CACRf,QAAQ,CAACgB,KAAK,EACb,gDAA+CX,KAAK,CAACQ,OAAO,CAACC,GAAI,EACpE,CAAC;IACD,MAAM,IAAInB,aAAa,CAAC,6CAA6C,CAAC;EACxE;EAEA,IAAIiB,iBAAiB,CAACK,MAAM,KAAKZ,KAAK,CAACa,MAAM,CAACC,GAAG,EAAE;IACjDlB,MAA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AC;IACpE,OAAOR,6BAA6B,CAClCC,UAAU,EACVC,UAAU,EACVnD,MAAM,EACNoE,OACF,CAAC;EACH;EAEApF,MAAM,CAACc,GAAG,CAACf,QAAQ,CAACgB,KAAK,EAAG,kCAAiCC,MAAO,EAAC,CAAC;EACtE,MAAM,IAAItB,aAAa,CAAE,kCAAiCsB,MAAO,EAAC,CAAC;AACrE,CAAC"}
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import * as z from "zod";
|
2
|
-
import {
|
2
|
+
import { InvalidQRCodeError } from "./errors";
|
3
3
|
const PresentationParams = z.object({
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
client_id: z.string().nonempty(),
|
5
|
+
request_uri: z.string().url(),
|
6
|
+
request_uri_method: z.enum(["get", "post"]),
|
7
7
|
state: z.string().optional()
|
8
8
|
});
|
9
9
|
|
@@ -11,26 +11,26 @@ const PresentationParams = z.object({
|
|
11
11
|
* The beginning of the presentation flow.
|
12
12
|
* To be implemented accordind to the user touchpoint
|
13
13
|
*
|
14
|
-
* @param params Presentation parameters, depending on the starting
|
14
|
+
* @param params Presentation parameters, depending on the starting touchpoint
|
15
15
|
* @returns The url for the Relying Party to connect with
|
16
16
|
*/
|
17
17
|
|
18
18
|
/**
|
19
|
-
* Start a presentation flow by
|
19
|
+
* Start a presentation flow by validating the required parameters.
|
20
|
+
* Parameters are extracted from a url encoded in a QR code or in a deep link.
|
20
21
|
*
|
21
|
-
* @param params The
|
22
|
+
* @param params The parameters to be validated
|
22
23
|
* @returns The url for the Relying Party to connect with
|
23
|
-
* @throws If the provided
|
24
|
+
* @throws If the provided parameters are not valid
|
24
25
|
*/
|
25
26
|
export const startFlowFromQR = params => {
|
26
|
-
const result = PresentationParams.safeParse(
|
27
|
+
const result = PresentationParams.safeParse({
|
28
|
+
...params,
|
29
|
+
request_uri_method: params.request_uri_method ?? "get"
|
30
|
+
});
|
27
31
|
if (result.success) {
|
28
32
|
return result.data;
|
29
|
-
} else {
|
30
|
-
throw new ValidationFailed({
|
31
|
-
message: "Invalid parameters provided",
|
32
|
-
reason: result.error.message
|
33
|
-
});
|
34
33
|
}
|
34
|
+
throw new InvalidQRCodeError(result.error.message);
|
35
35
|
};
|
36
36
|
//# sourceMappingURL=01-start-flow.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["z","
|
1
|
+
{"version":3,"names":["z","InvalidQRCodeError","PresentationParams","object","client_id","string","nonempty","request_uri","url","request_uri_method","enum","state","optional","startFlowFromQR","params","result","safeParse","success","data","error","message"],"sourceRoot":"../../../../src","sources":["credential/presentation/01-start-flow.ts"],"mappings":"AAAA,OAAO,KAAKA,CAAC,MAAM,KAAK;AACxB,SAASC,kBAAkB,QAAQ,UAAU;AAE7C,MAAMC,kBAAkB,GAAGF,CAAC,CAACG,MAAM,CAAC;EAClCC,SAAS,EAAEJ,CAAC,CAACK,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAChCC,WAAW,EAAEP,CAAC,CAACK,MAAM,CAAC,CAAC,CAACG,GAAG,CAAC,CAAC;EAC7BC,kBAAkB,EAAET,CAAC,CAACU,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;EAC3CC,KAAK,EAAEX,CAAC,CAACK,MAAM,CAAC,CAAC,CAACO,QAAQ,CAAC;AAC7B,CAAC,CAAC;;AAGF;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAA0B,GAAIC,MAAM,IAAK;EACpD,MAAMC,MAAM,GAAGb,kBAAkB,CAACc,SAAS,CAAC;IAC1C,GAAGF,MAAM;IACTL,kBAAkB,EAAEK,MAAM,CAACL,kBAAkB,IAAI;EACnD,CAAC,CAAC;EAEF,IAAIM,MAAM,CAACE,OAAO,EAAE;IAClB,OAAOF,MAAM,CAACG,IAAI;EACpB;EAEA,MAAM,IAAIjB,kBAAkB,CAACc,MAAM,CAACI,KAAK,CAACC,OAAO,CAAC;AACpD,CAAC"}
|
@@ -13,13 +13,15 @@ export const evaluateRelyingPartyTrust = async function (rpUrl) {
|
|
13
13
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
14
14
|
const {
|
15
15
|
payload: {
|
16
|
-
metadata: rpConf
|
16
|
+
metadata: rpConf,
|
17
|
+
sub
|
17
18
|
}
|
18
19
|
} = await getRelyingPartyEntityConfiguration(rpUrl, {
|
19
20
|
appFetch
|
20
21
|
});
|
21
22
|
return {
|
22
|
-
rpConf
|
23
|
+
rpConf,
|
24
|
+
subject: sub
|
23
25
|
};
|
24
26
|
};
|
25
27
|
//# sourceMappingURL=02-evaluate-rp-trust.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["getRelyingPartyEntityConfiguration","evaluateRelyingPartyTrust","rpUrl","appFetch","fetch","arguments","length","undefined","payload","metadata","rpConf"],"sourceRoot":"../../../../src","sources":["credential/presentation/02-evaluate-rp-trust.ts"],"mappings":"AAAA,SAASA,kCAAkC,QAAQ,aAAa;
|
1
|
+
{"version":3,"names":["getRelyingPartyEntityConfiguration","evaluateRelyingPartyTrust","rpUrl","appFetch","fetch","arguments","length","undefined","payload","metadata","rpConf","sub","subject"],"sourceRoot":"../../../../src","sources":["credential/presentation/02-evaluate-rp-trust.ts"],"mappings":"AAAA,SAASA,kCAAkC,QAAQ,aAAa;AAehE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,yBAAoD,GAAG,eAAAA,CAClEC,KAAK,EAEF;EAAA,IADH;IAAEC,QAAQ,GAAGC;EAAM,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAEzB,MAAM;IACJG,OAAO,EAAE;MAAEC,QAAQ,EAAEC,MAAM;MAAEC;IAAI;EACnC,CAAC,GAAG,MAAMX,kCAAkC,CAACE,KAAK,EAAE;IAClDC;EACF,CAAC,CAAC;EACF,OAAO;IAAEO,MAAM;IAAEE,OAAO,EAAED;EAAI,CAAC;AACjC,CAAC"}
|
@@ -10,11 +10,11 @@ import { RequestObjectWalletCapabilities } from "./types";
|
|
10
10
|
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
11
11
|
* @returns The Request Object that describes the presentation
|
12
12
|
*/
|
13
|
-
export const getRequestObject = async (requestUri
|
13
|
+
export const getRequestObject = async function (requestUri) {
|
14
14
|
let {
|
15
15
|
appFetch = fetch,
|
16
16
|
walletCapabilities
|
17
|
-
} =
|
17
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
18
18
|
if (walletCapabilities) {
|
19
19
|
// Validate external input
|
20
20
|
const {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["hasStatusOrThrow","RequestObjectWalletCapabilities","getRequestObject","requestUri","
|
1
|
+
{"version":3,"names":["hasStatusOrThrow","RequestObjectWalletCapabilities","getRequestObject","requestUri","appFetch","fetch","walletCapabilities","arguments","length","undefined","wallet_metadata","wallet_nonce","parse","formUrlEncodedBody","URLSearchParams","JSON","stringify","requestObjectEncodedJwt","method","headers","body","toString","then","res","text"],"sourceRoot":"../../../../src","sources":["credential/presentation/03-get-request-object.ts"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,kBAAkB;AACnD,SAASC,+BAA+B,QAAQ,SAAS;AAUzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAkC,GAAG,eAAAA,CAChDC,UAAU,EAEP;EAAA,IADH;IAAEC,QAAQ,GAAGC,KAAK;IAAEC;EAAmB,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAE7C,IAAID,kBAAkB,EAAE;IACtB;IACA,MAAM;MAAEI,eAAe;MAAEC;IAAa,CAAC,GACrCV,+BAA+B,CAACW,KAAK,CAACN,kBAAkB,CAAC;IAE3D,MAA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