@pagopa/io-react-native-wallet 0.24.1 → 0.26.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +0 -32
- package/lib/commonjs/client/generated/wallet-provider.js +39 -16
- package/lib/commonjs/client/generated/wallet-provider.js.map +1 -1
- package/lib/commonjs/client/index.js +25 -10
- package/lib/commonjs/client/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js +2 -2
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +36 -67
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/05-authorize-access.js +5 -2
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +26 -17
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/README.md +8 -14
- package/lib/commonjs/credential/issuance/errors.js +52 -0
- package/lib/commonjs/credential/issuance/errors.js.map +1 -0
- package/lib/commonjs/credential/issuance/index.js +13 -2
- package/lib/commonjs/credential/issuance/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/types.js +1 -5
- package/lib/commonjs/credential/issuance/types.js.map +1 -1
- package/lib/commonjs/credential/presentation/01-start-flow.js +1 -1
- package/lib/commonjs/credential/presentation/01-start-flow.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/04-send-authorization-response.js +2 -2
- package/lib/commonjs/credential/presentation/04-send-authorization-response.js.map +1 -1
- package/lib/commonjs/credential/presentation/errors.js +49 -0
- package/lib/commonjs/credential/presentation/errors.js.map +1 -0
- package/lib/commonjs/credential/presentation/index.js +5 -0
- package/lib/commonjs/credential/presentation/index.js.map +1 -1
- package/lib/commonjs/credential/status/02-status-attestation.js +8 -6
- package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -1
- package/lib/commonjs/credential/status/README.md +5 -2
- package/lib/commonjs/credential/status/types.js +1 -14
- package/lib/commonjs/credential/status/types.js.map +1 -1
- package/lib/commonjs/sd-jwt/errors.js +40 -0
- package/lib/commonjs/sd-jwt/errors.js.map +1 -0
- package/lib/commonjs/sd-jwt/index.js +8 -4
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/commonjs/sd-jwt/verifier.js +5 -1
- package/lib/commonjs/sd-jwt/verifier.js.map +1 -1
- package/lib/commonjs/trust/index.js +2 -2
- package/lib/commonjs/trust/index.js.map +1 -1
- package/lib/commonjs/utils/decoder.js +3 -1
- package/lib/commonjs/utils/decoder.js.map +1 -1
- package/lib/commonjs/utils/error-codes.js +51 -0
- package/lib/commonjs/utils/error-codes.js.map +1 -0
- package/lib/commonjs/utils/errors.js +119 -463
- package/lib/commonjs/utils/errors.js.map +1 -1
- package/lib/commonjs/utils/misc.js +23 -55
- package/lib/commonjs/utils/misc.js.map +1 -1
- package/lib/commonjs/utils/par.js +2 -1
- package/lib/commonjs/utils/par.js.map +1 -1
- package/lib/commonjs/wallet-instance/README.md +26 -5
- package/lib/commonjs/wallet-instance/index.js +33 -7
- package/lib/commonjs/wallet-instance/index.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/README.md +8 -2
- package/lib/commonjs/wallet-instance-attestation/issuing.js +13 -10
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/client/generated/wallet-provider.js +31 -11
- package/lib/module/client/generated/wallet-provider.js.map +1 -1
- package/lib/module/client/index.js +22 -8
- package/lib/module/client/index.js.map +1 -1
- package/lib/module/credential/issuance/03-start-user-authorization.js +2 -2
- package/lib/module/credential/issuance/04-complete-user-authorization.js +33 -65
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/05-authorize-access.js +7 -4
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +29 -20
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/README.md +8 -14
- package/lib/module/credential/issuance/errors.js +44 -0
- package/lib/module/credential/issuance/errors.js.map +1 -0
- package/lib/module/credential/issuance/index.js +3 -2
- package/lib/module/credential/issuance/index.js.map +1 -1
- package/lib/module/credential/issuance/types.js +0 -3
- package/lib/module/credential/issuance/types.js.map +1 -1
- package/lib/module/credential/presentation/01-start-flow.js +1 -1
- package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/module/credential/presentation/03-get-request-object.js +3 -3
- package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/module/credential/presentation/04-send-authorization-response.js +3 -3
- package/lib/module/credential/presentation/04-send-authorization-response.js.map +1 -1
- package/lib/module/credential/presentation/errors.js +42 -0
- package/lib/module/credential/presentation/errors.js.map +1 -0
- package/lib/module/credential/presentation/index.js +2 -1
- package/lib/module/credential/presentation/index.js.map +1 -1
- package/lib/module/credential/status/02-status-attestation.js +11 -9
- package/lib/module/credential/status/02-status-attestation.js.map +1 -1
- package/lib/module/credential/status/README.md +5 -2
- package/lib/module/credential/status/types.js +0 -12
- package/lib/module/credential/status/types.js.map +1 -1
- package/lib/module/sd-jwt/errors.js +32 -0
- package/lib/module/sd-jwt/errors.js.map +1 -0
- package/lib/module/sd-jwt/index.js +5 -5
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/module/sd-jwt/verifier.js +5 -1
- package/lib/module/sd-jwt/verifier.js.map +1 -1
- package/lib/module/trust/index.js +3 -3
- package/lib/module/trust/index.js.map +1 -1
- package/lib/module/utils/decoder.js +3 -1
- package/lib/module/utils/decoder.js.map +1 -1
- package/lib/module/utils/error-codes.js +43 -0
- package/lib/module/utils/error-codes.js.map +1 -0
- package/lib/module/utils/errors.js +98 -438
- package/lib/module/utils/errors.js.map +1 -1
- package/lib/module/utils/misc.js +19 -49
- package/lib/module/utils/misc.js.map +1 -1
- package/lib/module/utils/par.js +3 -2
- package/lib/module/utils/par.js.map +1 -1
- package/lib/module/wallet-instance/README.md +26 -5
- package/lib/module/wallet-instance/index.js +32 -7
- package/lib/module/wallet-instance/index.js.map +1 -1
- package/lib/module/wallet-instance-attestation/README.md +8 -2
- package/lib/module/wallet-instance-attestation/issuing.js +15 -12
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/typescript/client/generated/wallet-provider.d.ts +138 -27
- package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
- package/lib/typescript/client/index.d.ts +7 -1
- package/lib/typescript/client/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +2 -2
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +17 -16
- 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.map +1 -1
- package/lib/typescript/credential/issuance/errors.d.ts +28 -0
- package/lib/typescript/credential/issuance/errors.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/index.d.ts +4 -3
- package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/types.d.ts +0 -8
- package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/04-send-authorization-response.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/errors.d.ts +25 -0
- package/lib/typescript/credential/presentation/errors.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/index.d.ts +2 -1
- package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
- package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -1
- package/lib/typescript/credential/status/types.d.ts +0 -15
- package/lib/typescript/credential/status/types.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/errors.d.ts +20 -0
- package/lib/typescript/sd-jwt/errors.d.ts.map +1 -0
- package/lib/typescript/sd-jwt/index.d.ts +3 -2
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/utils/error-codes.d.ts +45 -0
- package/lib/typescript/utils/error-codes.d.ts.map +1 -0
- package/lib/typescript/utils/errors.d.ts +88 -225
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/misc.d.ts +9 -24
- 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 +17 -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/lib/typescript/wallet-instance-attestation/types.d.ts +4 -4
- package/package.json +1 -1
- package/src/client/generated/wallet-provider.ts +43 -13
- package/src/client/index.ts +28 -15
- package/src/credential/issuance/03-start-user-authorization.ts +2 -2
- package/src/credential/issuance/04-complete-user-authorization.ts +57 -118
- package/src/credential/issuance/05-authorize-access.ts +7 -4
- package/src/credential/issuance/06-obtain-credential.ts +39 -39
- package/src/credential/issuance/README.md +8 -14
- package/src/credential/issuance/errors.ts +44 -0
- package/src/credential/issuance/index.ts +8 -2
- package/src/credential/issuance/types.ts +0 -8
- package/src/credential/presentation/01-start-flow.ts +1 -1
- package/src/credential/presentation/03-get-request-object.ts +3 -3
- package/src/credential/presentation/04-send-authorization-response.ts +3 -3
- package/src/credential/presentation/errors.ts +41 -0
- package/src/credential/presentation/index.ts +2 -0
- package/src/credential/status/02-status-attestation.ts +17 -25
- package/src/credential/status/README.md +5 -2
- package/src/credential/status/types.ts +0 -15
- package/src/sd-jwt/errors.ts +39 -0
- package/src/sd-jwt/index.ts +5 -8
- package/src/sd-jwt/verifier.ts +5 -5
- package/src/trust/index.ts +3 -3
- package/src/utils/decoder.ts +3 -3
- package/src/utils/error-codes.ts +50 -0
- package/src/utils/errors.ts +152 -476
- package/src/utils/misc.ts +21 -65
- package/src/utils/par.ts +3 -2
- package/src/wallet-instance/README.md +26 -5
- package/src/wallet-instance/index.ts +40 -18
- package/src/wallet-instance-attestation/README.md +8 -2
- package/src/wallet-instance-attestation/issuing.ts +28 -36
@@ -42,7 +42,7 @@ const selectResponseMode = (issuerConf, credentialType) => {
|
|
42
42
|
|
43
43
|
/**
|
44
44
|
* WARNING: This function must be called after {@link evaluateIssuerTrust} and {@link startFlow}. The next steam is {@link compeUserAuthorizationWithQueryMode} or {@link compeUserAuthorizationWithFormPostJwtMode}
|
45
|
-
* Creates and sends a PAR request to the /as/par endpoint of the
|
45
|
+
* Creates and sends a PAR request to the /as/par endpoint of the authorization server.
|
46
46
|
* This starts the authentication flow to obtain an access token.
|
47
47
|
* This token enables the Wallet Instance to request a digital credential from the Credential Endpoint of the Credential Issuer.
|
48
48
|
* This is an HTTP POST request containing the Wallet Instance identifier (client id), the code challenge and challenge method as specified by PKCE according to RFC 9126
|
@@ -51,7 +51,7 @@ const selectResponseMode = (issuerConf, credentialType) => {
|
|
51
51
|
* the application session identifier on the Wallet Instance side (state),
|
52
52
|
* the method (query or form_post.jwt) by which the Authorization Server
|
53
53
|
* should transmit the Authorization Response containing the authorization code issued upon the end user's authentication (response_mode)
|
54
|
-
* to the Wallet Instance's Token Endpoint to obtain the Access Token, and the
|
54
|
+
* to the Wallet Instance's Token Endpoint to obtain the Access Token, and the redirectUri of the Wallet Instance where the Authorization Response
|
55
55
|
* should be delivered. The redirect is achived by using a custom URL scheme that the Wallet Instance is registered to handle.
|
56
56
|
* @param issuerConf The issuer configuration
|
57
57
|
* @param credentialType The type of the credential to be requested returned by {@link selectCredentialDefinition}
|
@@ -1,38 +1,28 @@
|
|
1
1
|
import { AuthorizationErrorShape, AuthorizationResultShape } from "../../utils/auth";
|
2
|
-
import {
|
2
|
+
import { hasStatusOrThrow } from "../../utils/misc";
|
3
3
|
import parseUrl from "parse-url";
|
4
|
-
import {
|
5
|
-
import { Linking } from "react-native";
|
4
|
+
import { IssuerResponseError, ValidationFailed } from "../../utils/errors";
|
6
5
|
import { decode, encodeBase64, SignJWT } from "@pagopa/io-react-native-jwt";
|
7
6
|
import { RequestObject } from "../presentation/types";
|
8
7
|
import uuid from "react-native-uuid";
|
9
8
|
import { ResponseUriResultShape } from "./types";
|
10
9
|
import { getJwtFromFormPost } from "../../utils/decoder";
|
10
|
+
import { AuthorizationError, AuthorizationIdpError } from "./errors";
|
11
11
|
|
12
12
|
/**
|
13
13
|
* 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.
|
14
14
|
*/
|
15
15
|
|
16
16
|
/**
|
17
|
-
* WARNING: This function must be called after {@link startUserAuthorization}. The
|
18
|
-
*
|
19
|
-
* It is used to complete the user authorization by catching the redirectSchema from the authorization server which then contains the authorization response.
|
20
|
-
* This function utilizes the authorization context to open an in-app browser capable of catching the redirectSchema to perform a get request to the authorization endpoint.
|
21
|
-
* If the 302 redirect happens and the redirectSchema is caught, the function will return the authorization response after parsing it from the query string.
|
17
|
+
* WARNING: This function must be called after {@link startUserAuthorization}. The generated authUrl must be used to open a browser or webview capable of catching the redirectSchema to perform a get request to the authorization endpoint.
|
18
|
+
* Builds the authorization URL to which the end user should be redirected to continue the authentication flow.
|
22
19
|
* @param issuerRequestUri the URI of the issuer where the request is sent
|
23
20
|
* @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
|
24
21
|
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
25
|
-
* @param
|
26
|
-
*
|
27
|
-
* @param idphint Unique identifier of the SPID IDP selected by the user
|
28
|
-
* @param redirectUri The url to reach to complete the user authorization which is the custom URL scheme that the Wallet Instance is registered to handle, usually a custom URL or deeplink
|
29
|
-
* @param signal An optional {@link AbortSignal} to abort the operation when using the default browser
|
30
|
-
* @throws {AuthorizationError} if an error occurs during the authorization process
|
31
|
-
* @throws {AuthorizationIdpError} if an error occurs during the authorization process and the error is related to the IDP
|
32
|
-
* @throws {OperationAbortedError} if the caller aborts the operation via the provided signal
|
33
|
-
* @returns the authorization response which contains code, state and iss
|
22
|
+
* @param idpHint Unique identifier of the IDP selected by the user
|
23
|
+
* @returns An object containing the authorization URL
|
34
24
|
*/
|
35
|
-
export const
|
25
|
+
export const buildAuthorizationUrl = async (issuerRequestUri, clientId, issuerConf, idpHint) => {
|
36
26
|
const authzRequestEndpoint = issuerConf.oauth_authorization_server.authorization_endpoint;
|
37
27
|
const params = new URLSearchParams({
|
38
28
|
client_id: clientId,
|
@@ -40,49 +30,21 @@ export const completeUserAuthorizationWithQueryMode = async (issuerRequestUri, c
|
|
40
30
|
idphint: idpHint
|
41
31
|
});
|
42
32
|
const authUrl = `${authzRequestEndpoint}?${params}`;
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
throw new AuthorizationError(e.message);
|
48
|
-
});
|
49
|
-
} else {
|
50
|
-
// handler for redirectUri
|
51
|
-
const urlEventListener = Linking.addEventListener("url", _ref => {
|
52
|
-
let {
|
53
|
-
url
|
54
|
-
} = _ref;
|
55
|
-
if (url.includes(redirectUri)) {
|
56
|
-
authRedirectUrl = url;
|
57
|
-
}
|
58
|
-
});
|
59
|
-
const operationIsAborted = signal ? createAbortPromiseFromSignal(signal) : undefined;
|
60
|
-
await Linking.openURL(authUrl);
|
61
|
-
|
62
|
-
/*
|
63
|
-
* Waits for 120 seconds for the identificationRedirectUrl variable to be set
|
64
|
-
* by the custom url handler. If the timeout is exceeded, throw an exception
|
65
|
-
*/
|
66
|
-
const unitAuthRedirectIsNotUndefined = until(() => authRedirectUrl !== undefined, 120);
|
33
|
+
return {
|
34
|
+
authUrl
|
35
|
+
};
|
36
|
+
};
|
67
37
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
});
|
77
|
-
if (winner === "OPERATION_ABORTED") {
|
78
|
-
throw new OperationAbortedError("DefaultQueryModeAuthorization");
|
79
|
-
}
|
80
|
-
if (authRedirectUrl === undefined) {
|
81
|
-
throw new AuthorizationError("Invalid authentication redirect url");
|
82
|
-
}
|
83
|
-
}
|
38
|
+
/**
|
39
|
+
* WARNING: This function must be called after obtaining the authorization redirect URL from the webviews (SPID and CIE L3) or browser for CIEID.
|
40
|
+
* Complete User authorization via strong identification when the response mode is "query" and the request credential is a PersonIdentificationData.
|
41
|
+
* This function parses the authorization redirect URL to extract the authorization response.
|
42
|
+
* @param authRedirectUrl The URL to which the end user should be redirected to start the authentication flow
|
43
|
+
* @returns the authorization response which contains code, state and iss
|
44
|
+
*/
|
45
|
+
export const completeUserAuthorizationWithQueryMode = async authRedirectUrl => {
|
84
46
|
const query = parseUrl(authRedirectUrl).query;
|
85
|
-
return
|
47
|
+
return parseAuthorizationResponse(query);
|
86
48
|
};
|
87
49
|
|
88
50
|
/**
|
@@ -106,9 +68,12 @@ export const getRequestedCredentialToBePresented = async function (issuerRequest
|
|
106
68
|
});
|
107
69
|
const requestObject = await appFetch(`${authzRequestEndpoint}?${params.toString()}`, {
|
108
70
|
method: "GET"
|
109
|
-
}).then(
|
71
|
+
}).then(hasStatusOrThrow(200, IssuerResponseError)).then(res => res.text()).then(jws => decode(jws)).then(reqObj => RequestObject.safeParse(reqObj.payload));
|
110
72
|
if (!requestObject.success) {
|
111
|
-
throw new ValidationFailed(
|
73
|
+
throw new ValidationFailed({
|
74
|
+
message: "Request Object validation failed",
|
75
|
+
reason: requestObject.error.message
|
76
|
+
});
|
112
77
|
}
|
113
78
|
return requestObject.data;
|
114
79
|
};
|
@@ -194,12 +159,15 @@ export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject
|
|
194
159
|
"Content-Type": "application/x-www-form-urlencoded"
|
195
160
|
},
|
196
161
|
body
|
197
|
-
}).then(
|
162
|
+
}).then(hasStatusOrThrow(200, IssuerResponseError)).then(reqUri => reqUri.json());
|
198
163
|
const responseUri = ResponseUriResultShape.safeParse(resUriRes);
|
199
164
|
if (!responseUri.success) {
|
200
|
-
throw new ValidationFailed(
|
165
|
+
throw new ValidationFailed({
|
166
|
+
message: "Response Uri validation failed",
|
167
|
+
reason: responseUri.error.message
|
168
|
+
});
|
201
169
|
}
|
202
|
-
return await appFetch(responseUri.data.redirect_uri).then(
|
170
|
+
return await appFetch(responseUri.data.redirect_uri).then(hasStatusOrThrow(200, IssuerResponseError)).then(res => res.text()).then(getJwtFromFormPost).then(cbRes => parseAuthorizationResponse(cbRes.decodedJwt.payload));
|
203
171
|
};
|
204
172
|
|
205
173
|
/**
|
@@ -209,7 +177,7 @@ export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject
|
|
209
177
|
* @param authRes the authorization response to be parsed
|
210
178
|
* @returns the authorization result which contains code, state and iss
|
211
179
|
*/
|
212
|
-
export const
|
180
|
+
export const parseAuthorizationResponse = authRes => {
|
213
181
|
const authResParsed = AuthorizationResultShape.safeParse(authRes);
|
214
182
|
if (!authResParsed.success) {
|
215
183
|
const authErr = AuthorizationErrorShape.safeParse(authRes);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","
|
1
|
+
{"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","hasStatusOrThrow","parseUrl","IssuerResponseError","ValidationFailed","decode","encodeBase64","SignJWT","RequestObject","uuid","ResponseUriResultShape","getJwtFromFormPost","AuthorizationError","AuthorizationIdpError","buildAuthorizationUrl","issuerRequestUri","clientId","issuerConf","idpHint","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","idphint","authUrl","completeUserAuthorizationWithQueryMode","authRedirectUrl","query","parseAuthorizationResponse","getRequestedCredentialToBePresented","appFetch","arguments","length","undefined","fetch","requestObject","toString","method","then","res","text","jws","reqObj","safeParse","payload","success","message","reason","error","data","completeUserAuthorizationWithFormPostJwtMode","ctx","wiaCryptoContext","pidCryptoContext","pid","walletInstanceAttestation","wiaWpToken","setProtectedHeader","alg","typ","setPayload","vp","jti","v4","nonce","setIssuedAt","setExpirationTime","setAudience","response_uri","sign","pidWpToken","presentationSubmission","definition_id","id","descriptor_map","path","format","authzResponsePayload","JSON","stringify","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,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,sBAAsB,QAAQ,SAAS;AAChD,SAASC,kBAAkB,QAAQ,qBAAqB;AACxD,SAASC,kBAAkB,EAAEC,qBAAqB,QAAQ,UAAU;;AAEpE;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,gBAAgB;IAC7BW,OAAO,EAAER;EACX,CAAC,CAAC;EAEF,MAAMS,OAAO,GAAI,GAAER,oBAAqB,IAAGG,MAAO,EAAC;EAEnD,OAAO;IAAEK;EAAQ,CAAC;AACpB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sCAA8E,GACzF,MAAOC,eAAe,IAAK;EACzB,MAAMC,KAAK,GAAG5B,QAAQ,CAAC2B,eAAe,CAAC,CAACC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AW,CAACxC,IAAI,CAACyC,YAAY,CAAC,CACjDpD,IAAI,CAACxC,gBAAgB,CAAC,GAAG,EAAEE,mBAAmB,CAAC,CAAC,CAChDsC,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBF,IAAI,CAAC9B,kBAAkB,CAAC,CACxB8B,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,GAAGjG,wBAAwB,CAAC8C,SAAS,CAACkD,OAAO,CAAC;EACjE,IAAI,CAACC,aAAa,CAACjD,OAAO,EAAE;IAC1B,MAAMkD,OAAO,GAAGnG,uBAAuB,CAAC+C,SAAS,CAACkD,OAAO,CAAC;IAC1D,IAAI,CAACE,OAAO,CAAClD,OAAO,EAAE;MACpB,MAAM,IAAIpC,kBAAkB,CAACqF,aAAa,CAAC9C,KAAK,CAACF,OAAO,CAAC,CAAC,CAAC;IAC7D;;IACA,MAAM,IAAIpC,qBAAqB,CAC7BqF,OAAO,CAAC9C,IAAI,CAACD,KAAK,EAClB+C,OAAO,CAAC9C,IAAI,CAAC+C,iBACf,CAAC;EACH;EACA,OAAOF,aAAa,CAAC7C,IAAI;AAC3B,CAAC"}
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import {
|
1
|
+
import { hasStatusOrThrow } from "../../utils/misc";
|
2
2
|
import { createDPopToken } from "../../utils/dpop";
|
3
3
|
import uuid from "react-native-uuid";
|
4
4
|
import { createPopToken } from "../../utils/pop";
|
5
5
|
import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
|
6
6
|
import { ASSERTION_TYPE } from "./const";
|
7
7
|
import { TokenResponse } from "./types";
|
8
|
-
import { ValidationFailed } from "../../utils/errors";
|
8
|
+
import { IssuerResponseError, ValidationFailed } from "../../utils/errors";
|
9
9
|
/**
|
10
10
|
* Creates and sends the DPoP Proof JWT to be presented with the authorization code to the /token endpoint of the authorization server
|
11
11
|
* for requesting the issuance of an access token bound to the public key of the Wallet Instance contained within the DPoP.
|
@@ -62,9 +62,12 @@ export const authorizeAccess = async (issuerConf, code, clientId, redirectUri, c
|
|
62
62
|
DPoP: tokenRequestSignedDPop
|
63
63
|
},
|
64
64
|
body: authorizationRequestFormBody.toString()
|
65
|
-
}).then(
|
65
|
+
}).then(hasStatusOrThrow(200, IssuerResponseError)).then(res => res.json()).then(body => TokenResponse.safeParse(body));
|
66
66
|
if (!tokenRes.success) {
|
67
|
-
throw new ValidationFailed(
|
67
|
+
throw new ValidationFailed({
|
68
|
+
message: "Token Response validation failed",
|
69
|
+
reason: tokenRes.error.message
|
70
|
+
});
|
68
71
|
}
|
69
72
|
return {
|
70
73
|
accessToken: tokenRes.data
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["hasStatusOrThrow","createDPopToken","uuid","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","v4","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","message","reason","error","accessToken","data"],"sourceRoot":"../../../../src","sources":["credential/issuance/05-authorize-access.ts"],"mappings":"AAAA,SAASA,gBAAgB,QAAkB,kBAAkB;AAG7D,SAASC,eAAe,QAAQ,kBAAkB;AAClD,OAA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AAC,EACDV,gBACF,CAAC;EAED,MAAMwB,WAAW,GAAG;IAClBC,UAAU,EAAE,oBAAoB;IAChCC,SAAS,EAAEjC,QAAQ;IACnBD,IAAI;IACJmC,YAAY,EAAEjC,WAAW;IACzBkC,aAAa,EAAEjC,YAAY;IAC3BkC,qBAAqB,EAAE3C,cAAc;IACrC4C,gBAAgB,EAAE/B,yBAAyB,GAAG,GAAG,GAAGwB;EACtD,CAAC;EAED,MAAMQ,4BAA4B,GAAG,IAAIC,eAAe,CAACR,WAAW,CAAC;EACrE,MAAMS,QAAQ,GAAG,MAAMpC,QAAQ,CAACmB,QAAQ,EAAE;IACxCkB,MAAM,EAAE,MAAM;IACdC,OAAO,EAAE;MACP,cAAc,EAAE,mCAAmC;MACnDC,IAAI,EAAElB;IACR,CAAC;IACDmB,IAAI,EAAEN,4BAA4B,CAACO,QAAQ,CAAC;EAC9C,CAAC,CAAC,CACCC,IAAI,CAAC1D,gBAAgB,CAAC,GAAG,EAAEO,mBAAmB,CAAC,CAAC,CAChDmD,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBF,IAAI,CAAEF,IAAI,IAAKlD,aAAa,CAACuD,SAAS,CAACL,IAAI,CAAC,CAAC;EAEhD,IAAI,CAACJ,QAAQ,CAACU,OAAO,EAAE;IACrB,MAAM,IAAItD,gBAAgB,CAAC;MACzBuD,OAAO,EAAE,kCAAkC;MAC3CC,MAAM,EAAEZ,QAAQ,CAACa,KAAK,CAACF;IACzB,CAAC,CAAC;EACJ;EAEA,OAAO;IAAEG,WAAW,EAAEd,QAAQ,CAACe;EAAK,CAAC;AACvC,CAAC"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { sha256ToBase64, SignJWT } from "@pagopa/io-react-native-jwt";
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
2
|
+
import { hasStatusOrThrow } from "../../utils/misc";
|
3
|
+
import { IssuerResponseError, IssuerResponseErrorCodes, ResponseErrorBuilder, UnexpectedStatusCodeError, ValidationFailed } from "../../utils/errors";
|
4
|
+
import { CredentialResponse } from "./types";
|
5
5
|
import { createDPopToken } from "../../utils/dpop";
|
6
6
|
import uuid from "react-native-uuid";
|
7
7
|
export const createNonceProof = async (nonce, issuer, audience, ctx) => {
|
@@ -46,9 +46,11 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
|
|
46
46
|
const signedNonceProof = await createNonceProof(accessToken.c_nonce, clientId, credentialUrl, credentialCryptoContext);
|
47
47
|
|
48
48
|
// Validation of accessTokenResponse.authorization_details if contain credentialDefinition
|
49
|
-
const
|
50
|
-
if (!
|
51
|
-
throw new ValidationFailed(
|
49
|
+
const containsCredentialDefinition = accessToken.authorization_details.some(c => c.credential_configuration_id === credentialDefinition.credential_configuration_id && c.format === credentialDefinition.format && c.type === credentialDefinition.type);
|
50
|
+
if (!containsCredentialDefinition) {
|
51
|
+
throw new ValidationFailed({
|
52
|
+
message: "The access token response does not contain the requested credential"
|
53
|
+
});
|
52
54
|
}
|
53
55
|
|
54
56
|
/** The credential request body */
|
@@ -62,7 +64,7 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
|
|
62
64
|
proof_type: "jwt"
|
63
65
|
}
|
64
66
|
};
|
65
|
-
const tokenRequestSignedDPop = await
|
67
|
+
const tokenRequestSignedDPop = await createDPopToken({
|
66
68
|
htm: "POST",
|
67
69
|
htu: credentialUrl,
|
68
70
|
jti: `${uuid.v4()}`,
|
@@ -76,9 +78,12 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
|
|
76
78
|
Authorization: `${accessToken.token_type} ${accessToken.access_token}`
|
77
79
|
},
|
78
80
|
body: JSON.stringify(credentialRequestFormBody)
|
79
|
-
}).then(
|
81
|
+
}).then(hasStatusOrThrow(200)).then(res => res.json()).then(body => CredentialResponse.safeParse(body)).catch(handleObtainCredentialError);
|
80
82
|
if (!credentialRes.success) {
|
81
|
-
throw new ValidationFailed(
|
83
|
+
throw new ValidationFailed({
|
84
|
+
message: "Credential Response validation failed",
|
85
|
+
reason: credentialRes.error.message
|
86
|
+
});
|
82
87
|
}
|
83
88
|
return credentialRes.data;
|
84
89
|
};
|
@@ -94,16 +99,20 @@ const handleObtainCredentialError = e => {
|
|
94
99
|
if (!(e instanceof UnexpectedStatusCodeError)) {
|
95
100
|
throw e;
|
96
101
|
}
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
}
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
102
|
+
throw new ResponseErrorBuilder(IssuerResponseError).handle(201, {
|
103
|
+
// Although it is technically not an error, we handle it as such to avoid
|
104
|
+
// changing the return type of `obtainCredential` and introduce a breaking change.
|
105
|
+
code: IssuerResponseErrorCodes.CredentialIssuingNotSynchronous,
|
106
|
+
message: "This credential cannot be issued synchronously. It will be available at a later time."
|
107
|
+
}).handle(403, {
|
108
|
+
code: IssuerResponseErrorCodes.CredentialInvalidStatus,
|
109
|
+
message: "Invalid status found for the given credential"
|
110
|
+
}).handle(404, {
|
111
|
+
code: IssuerResponseErrorCodes.CredentialInvalidStatus,
|
112
|
+
message: "Invalid status found for the given credential"
|
113
|
+
}).handle("*", {
|
114
|
+
code: IssuerResponseErrorCodes.CredentialRequestFailed,
|
115
|
+
message: "Unable to obtain the requested credential"
|
116
|
+
}).buildFrom(e);
|
108
117
|
};
|
109
118
|
//# sourceMappingURL=06-obtain-credential.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["sha256ToBase64","SignJWT","
|
1
|
+
{"version":3,"names":["sha256ToBase64","SignJWT","hasStatusOrThrow","IssuerResponseError","IssuerResponseErrorCodes","ResponseErrorBuilder","UnexpectedStatusCodeError","ValidationFailed","CredentialResponse","createDPopToken","uuid","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","v4","ath","access_token","credentialRes","method","headers","DPoP","Authorization","token_type","body","JSON","stringify","then","res","json","safeParse","catch","handleObtainCredentialError","success","reason","error","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,OAAOC,IAAI,MAAM,mBAAmB;AAcpC,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,IAAIhB,OAAO,CAACc,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;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AACgF,uBAAuB;IACtDpC,OAAO,EAAE;EACX,CAAC,CAAC,CACDiC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAE9E,wBAAwB,CAACgF,uBAAuB;IACtDpC,OAAO,EAAE;EACX,CAAC,CAAC,CACDiC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAE9E,wBAAwB,CAACiF,uBAAuB;IACtDrC,OAAO,EAAE;EACX,CAAC,CAAC,CACDsC,SAAS,CAACN,CAAC,CAAC;AACjB,CAAC"}
|
@@ -39,20 +39,14 @@ graph TD;
|
|
39
39
|
|
40
40
|
## Mapped results
|
41
41
|
|
42
|
-
|
42
|
+
The following errors are mapped to a `IssuerResponseError` with specific codes.
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
Although `201 Created` is not considered an error, it is mapped as an error in this context in order to handle the case where the credential issuance is not synchronous.
|
47
|
-
This
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
A `403 Forbidden` response is returned by the credential issuer when the requested credential has an invalid status. It might contain more details in the `errorCode` property.
|
52
|
-
|
53
|
-
### 404 Not Found (CredentialInvalidStatusError)
|
54
|
-
|
55
|
-
A `404 Not Found` response is returned by the credential issuer when the authenticated user is not entitled to receive the requested credential. It might contain more details in the `errorCode` property.
|
44
|
+
|HTTP Status|Error Code|Description|
|
45
|
+
|-----------|----------|-----------|
|
46
|
+
|`201 Created`|`ERR_CREDENTIAL_ISSUING_NOT_SYNCHRONOUS`| This response is returned by the credential issuer when the request has been queued because the credential cannot be issued synchronously. The consumer should try to obtain the credential at a later time. Although `201 Created` is not considered an error, it is mapped as an error in this context in order to handle the case where the credential issuance is not synchronous. This allows keeping the flow consistent and handle the case where the credential is not immediately available.|
|
47
|
+
|`403 Forbidden`|`ERR_CREDENTIAL_INVALID_STATUS`|This response is returned by the credential issuer when the requested credential has an invalid status. It might contain more details in the `reason` property.|
|
48
|
+
|`404 Not Found`|`ERR_CREDENTIAL_INVALID_STATUS`| This response is returned by the credential issuer when the authenticated user is not entitled to receive the requested credential. It might contain more details in the `reason` property.|
|
49
|
+
|`*`|`ERR_ISSUER_GENERIC_ERROR`|This is a generic error code to map unexpected errors that occurred when interacting with the Issuer.|
|
56
50
|
|
57
51
|
## Strong authentication for eID issuance (Query Mode)
|
58
52
|
|
@@ -278,7 +272,7 @@ const { issuerRequestUri, clientId, codeVerifier, credentialDefinition } =
|
|
278
272
|
appFetch,
|
279
273
|
});
|
280
274
|
|
281
|
-
// Complete the
|
275
|
+
// Complete the authorization process with query mode with the authorizationContext which opens the browser
|
282
276
|
const { code } =
|
283
277
|
await Credential.Issuance.completeUserAuthorizationWithQueryMode(
|
284
278
|
issuerRequestUri,
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { IoWalletError, serializeAttrs } from "../../utils/errors";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* An error subclass thrown when an error occurs during the authorization process.
|
5
|
+
*/
|
6
|
+
export class AuthorizationError extends IoWalletError {
|
7
|
+
code = "ERR_IO_WALLET_AUTHORIZATION_ERROR";
|
8
|
+
constructor(message) {
|
9
|
+
super(message);
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
/**
|
14
|
+
* An error subclass thrown when an error occurs during the authorization process with the IDP.
|
15
|
+
* It contains the error and error description returned by the IDP.
|
16
|
+
*/
|
17
|
+
export class AuthorizationIdpError extends IoWalletError {
|
18
|
+
code = "ERR_IO_WALLET_IDENTIFICATION_RESPONSE_PARSING_FAILED";
|
19
|
+
constructor(error, errorDescription) {
|
20
|
+
super(serializeAttrs({
|
21
|
+
error,
|
22
|
+
errorDescription
|
23
|
+
}));
|
24
|
+
this.error = error;
|
25
|
+
this.errorDescription = errorDescription;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Error subclass thrown when an operation has been aborted.
|
31
|
+
*/
|
32
|
+
export class OperationAbortedError extends IoWalletError {
|
33
|
+
code = "ERR_IO_WALLET_OPERATION_ABORTED";
|
34
|
+
|
35
|
+
/** The aborted operation */
|
36
|
+
|
37
|
+
constructor(operation) {
|
38
|
+
super(serializeAttrs({
|
39
|
+
operation
|
40
|
+
}));
|
41
|
+
this.operation = operation;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
//# sourceMappingURL=errors.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["IoWalletError","serializeAttrs","AuthorizationError","code","constructor","message","AuthorizationIdpError","error","errorDescription","OperationAbortedError","operation"],"sourceRoot":"../../../../src","sources":["credential/issuance/errors.ts"],"mappings":"AAAA,SAASA,aAAa,EAAEC,cAAc,QAAQ,oBAAoB;;AAElE;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,SAASF,aAAa,CAAC;EACpDG,IAAI,GAAG,mCAAmC;EAE1CC,WAAWA,CAACC,OAAgB,EAAE;IAC5B,KAAK,CAACA,OAAO,CAAC;EAChB;AACF;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,SAASN,aAAa,CAAC;EACvDG,IAAI,GAAG,sDAAsD;EAK7DC,WAAWA,CAACG,KAAa,EAAEC,gBAAyB,EAAE;IACpD,KAAK,CAACP,cAAc,CAAC;MAAEM,KAAK;MAAEC;IAAiB,CAAC,CAAC,CAAC;IAClD,IAAI,CAACD,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,gBAAgB,GAAGA,gBAAgB;EAC1C;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,SAAST,aAAa,CAAC;EACvDG,IAAI,GAAG,iCAAiC;;EAExC;;EAGAC,WAAWA,CAACM,SAAiB,EAAE;IAC7B,KAAK,CAACT,cAAc,CAAC;MAAES;IAAU,CAAC,CAAC,CAAC;IACpC,IAAI,CAACA,SAAS,GAAGA,SAAS;EAC5B;AACF"}
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import { evaluateIssuerTrust } from "./02-evaluate-issuer-trust";
|
2
2
|
import { startUserAuthorization } from "./03-start-user-authorization";
|
3
|
-
import { completeUserAuthorizationWithQueryMode, completeUserAuthorizationWithFormPostJwtMode,
|
3
|
+
import { completeUserAuthorizationWithQueryMode, completeUserAuthorizationWithFormPostJwtMode, parseAuthorizationResponse, buildAuthorizationUrl, getRequestedCredentialToBePresented } from "./04-complete-user-authorization";
|
4
4
|
import { authorizeAccess } from "./05-authorize-access";
|
5
5
|
import { obtainCredential } from "./06-obtain-credential";
|
6
6
|
import { verifyAndParseCredential } from "./07-verify-and-parse-credential";
|
7
|
-
|
7
|
+
import * as Errors from "./errors";
|
8
|
+
export { evaluateIssuerTrust, startUserAuthorization, buildAuthorizationUrl, completeUserAuthorizationWithQueryMode, getRequestedCredentialToBePresented, completeUserAuthorizationWithFormPostJwtMode, authorizeAccess, obtainCredential, verifyAndParseCredential, parseAuthorizationResponse, Errors };
|
8
9
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["evaluateIssuerTrust","startUserAuthorization","completeUserAuthorizationWithQueryMode","completeUserAuthorizationWithFormPostJwtMode","
|
1
|
+
{"version":3,"names":["evaluateIssuerTrust","startUserAuthorization","completeUserAuthorizationWithQueryMode","completeUserAuthorizationWithFormPostJwtMode","parseAuthorizationResponse","buildAuthorizationUrl","getRequestedCredentialToBePresented","authorizeAccess","obtainCredential","verifyAndParseCredential","Errors"],"sourceRoot":"../../../../src","sources":["credential/issuance/index.ts"],"mappings":"AACA,SACEA,mBAAmB,QAEd,4BAA4B;AACnC,SACEC,sBAAsB,QAEjB,+BAA+B;AACtC,SACEC,sCAAsC,EACtCC,4CAA4C,EAC5CC,0BAA0B,EAC1BC,qBAAqB,EAKrBC,mCAAmC,QAC9B,kCAAkC;AACzC,SAASC,eAAe,QAA8B,uBAAuB;AAC7E,SACEC,gBAAgB,QAEX,wBAAwB;AAC/B,SACEC,wBAAwB,QAEnB,kCAAkC;AACzC,OAAO,KAAKC,MAAM,MAAM,UAAU;AAElC,SACEV,mBAAmB,EACnBC,sBAAsB,EACtBI,qBAAqB,EACrBH,sCAAsC,EACtCI,mCAAmC,EACnCH,4CAA4C,EAC5CI,eAAe,EACfC,gBAAgB,EAChBC,wBAAwB,EACxBL,0BAA0B,EAC1BM,MAAM"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["AuthorizationDetail","z","SupportedCredentialFormat","TokenResponse","object","access_token","string","authorization_details","array","c_nonce","c_nonce_expires_in","number","expires_in","token_type","CredentialResponse","credential","format","ResponseUriResultShape","redirect_uri"
|
1
|
+
{"version":3,"names":["AuthorizationDetail","z","SupportedCredentialFormat","TokenResponse","object","access_token","string","authorization_details","array","c_nonce","c_nonce_expires_in","number","expires_in","token_type","CredentialResponse","credential","format","ResponseUriResultShape","redirect_uri"],"sourceRoot":"../../../../src","sources":["credential/issuance/types.ts"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,iBAAiB;AACrD,OAAO,KAAKC,CAAC,MAAM,KAAK;AACxB,SAASC,yBAAyB,QAAQ,SAAS;AAInD,OAAO,MAAMC,aAAa,GAAGF,CAAC,CAACG,MAAM,CAAC;EACpCC,YAAY,EAAEJ,CAAC,CAACK,MAAM,CAAC,CAAC;EACxBC,qBAAqB,EAAEN,CAAC,CAACO,KAAK,CAACR,mBAAmB,CAAC;EACnDS,OAAO,EAAER,CAAC,CAACK,MAAM,CAAC,CAAC;EACnBI,kBAAkB,EAAET,CAAC,CAACU,MAAM,CAAC,CAAC;EAC9BC,UAAU,EAAEX,CAAC,CAACU,MAAM,CAAC,CAAC;EACtBE,UAAU,EAAEZ,CAAC,CAACK,MAAM,CAAC;AACvB,CAAC,CAAC;AAIF,OAAO,MAAMQ,kBAAkB,GAAGb,CAAC,CAACG,MAAM,CAAC;EACzCK,OAAO,EAAER,CAAC,CAACK,MAAM,CAAC,CAAC;EACnBI,kBAAkB,EAAET,CAAC,CAACU,MAAM,CAAC,CAAC;EAC9BI,UAAU,EAAEd,CAAC,CAACK,MAAM,CAAC,CAAC;EACtBU,MAAM,EAAEd;AACV,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMe,sBAAsB,GAAGhB,CAAC,CAACG,MAAM,CAAC;EAC7Cc,YAAY,EAAEjB,CAAC,CAACK,MAAM,CAAC;AACzB,CAAC,CAAC"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import * as z from "zod";
|
2
2
|
import { decodeBase64 } from "@pagopa/io-react-native-jwt";
|
3
|
-
import { AuthRequestDecodeError } from "
|
3
|
+
import { AuthRequestDecodeError } from "./errors";
|
4
4
|
const QRCodePayload = z.object({
|
5
5
|
protocol: z.string(),
|
6
6
|
resource: z.string(),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["z","decodeBase64","AuthRequestDecodeError","QRCodePayload","object","protocol","string","resource","clientId","requestURI","startFlowFromQR","qrcode","decoded","decodedUrl","URL","hostname","searchParams","get","result","safeParse","success","data","error","message"],"sourceRoot":"../../../../src","sources":["credential/presentation/01-start-flow.ts"],"mappings":"AAAA,OAAO,KAAKA,CAAC,MAAM,KAAK;AACxB,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,sBAAsB,QAAQ,
|
1
|
+
{"version":3,"names":["z","decodeBase64","AuthRequestDecodeError","QRCodePayload","object","protocol","string","resource","clientId","requestURI","startFlowFromQR","qrcode","decoded","decodedUrl","URL","hostname","searchParams","get","result","safeParse","success","data","error","message"],"sourceRoot":"../../../../src","sources":["credential/presentation/01-start-flow.ts"],"mappings":"AAAA,OAAO,KAAKA,CAAC,MAAM,KAAK;AACxB,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,sBAAsB,QAAQ,UAAU;AAEjD,MAAMC,aAAa,GAAGH,CAAC,CAACI,MAAM,CAAC;EAC7BC,QAAQ,EAAEL,CAAC,CAACM,MAAM,CAAC,CAAC;EACpBC,QAAQ,EAAEP,CAAC,CAACM,MAAM,CAAC,CAAC;EAAE;EACtBE,QAAQ,EAAER,CAAC,CAACM,MAAM,CAAC,CAAC;EACpBG,UAAU,EAAET,CAAC,CAACM,MAAM,CAAC;AACvB,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,eAAoC,GAAIC,MAAM,IAAK;EAC9D,MAAMC,OAAO,GAAGX,YAAY,CAACU,MAAM,CAAC;EACpC,MAAME,UAAU,GAAG,IAAIC,GAAG,CAACF,OAAO,CAAC;EACnC,MAAMP,QAAQ,GAAGQ,UAAU,CAACR,QAAQ;EACpC,MAAME,QAAQ,GAAGM,UAAU,CAACE,QAAQ;EACpC,MAAMN,UAAU,GAAGI,UAAU,CAACG,YAAY,CAACC,GAAG,CAAC,aAAa,CAAC;EAC7D,MAAMT,QAAQ,GAAGK,UAAU,CAACG,YAAY,CAACC,GAAG,CAAC,WAAW,CAAC;EAEzD,MAAMC,MAAM,GAAGf,aAAa,CAACgB,SAAS,CAAC;IACrCd,QAAQ;IACRE,QAAQ;IACRE,UAAU;IACVD;EACF,CAAC,CAAC;EAEF,IAAIU,MAAM,CAACE,OAAO,EAAE;IAClB,OAAOF,MAAM,CAACG,IAAI;EACpB,CAAC,MAAM;IACL,MAAM,IAAInB,sBAAsB,CAACgB,MAAM,CAACI,KAAK,CAACC,OAAO,EAAG,GAAEV,UAAW,EAAC,CAAC;EACzE;AACF,CAAC"}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import uuid from "react-native-uuid";
|
2
2
|
import { decode as decodeJwt, sha256ToBase64, verify } from "@pagopa/io-react-native-jwt";
|
3
3
|
import { createDPopToken } from "../../utils/dpop";
|
4
|
-
import { NoSuitableKeysFoundInEntityConfiguration } from "
|
5
|
-
import {
|
4
|
+
import { NoSuitableKeysFoundInEntityConfiguration } from "./errors";
|
5
|
+
import { hasStatusOrThrow } from "../../utils/misc";
|
6
6
|
import { RequestObject } from "./types";
|
7
7
|
/**
|
8
8
|
* Obtain the Request Object for RP authentication
|
@@ -33,7 +33,7 @@ export const getRequestObject = async (requestUri, rpConf, _ref) => {
|
|
33
33
|
Authorization: `DPoP ${walletInstanceAttestation}`,
|
34
34
|
DPoP: signedWalletInstanceDPoP
|
35
35
|
}
|
36
|
-
}).then(
|
36
|
+
}).then(hasStatusOrThrow(200)).then(res => res.json()).then(responseJson => responseJson.response);
|
37
37
|
const responseJwt = decodeJwt(responseEncodedJwt);
|
38
38
|
|
39
39
|
// verify token signature according to RP's entity configuration
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["uuid","decode","decodeJwt","sha256ToBase64","verify","createDPopToken","NoSuitableKeysFoundInEntityConfiguration","
|
1
|
+
{"version":3,"names":["uuid","decode","decodeJwt","sha256ToBase64","verify","createDPopToken","NoSuitableKeysFoundInEntityConfiguration","hasStatusOrThrow","RequestObject","getRequestObject","requestUri","rpConf","_ref","wiaCryptoContext","appFetch","fetch","walletInstanceAttestation","signedWalletInstanceDPoP","jti","v4","htm","htu","ath","responseEncodedJwt","method","headers","Authorization","DPoP","then","res","json","responseJson","response","responseJwt","pubKey","wallet_relying_party","jwks","keys","find","_ref2","kid","protectedHeader","requestObject","parse","payload"],"sourceRoot":"../../../../src","sources":["credential/presentation/03-get-request-object.ts"],"mappings":"AAAA,OAAOA,IAAI,MAAM,mBAAmB;AACpC,SACEC,MAAM,IAAIC,SAAS,EACnBC,cAAc,EACdC,MAAM,QAED,6BAA6B;AAEpC,SAASC,eAAe,QAAQ,kBAAkB;AAClD,SAASC,wCAAwC,QAAQ,UAAU;AAEnE,SAASC,gBAAgB,QAAkB,kBAAkB;AAE7D,SAASC,aAAa,QAAQ,SAAS;AAYvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAkC,GAAG,MAAAA,CAChDC,UAAU,EACVC,MAAM,EAAAC,IAAA,KAEH;EAAA,IADH;IAAEC,gBAAgB;IAAEC,QAAQ,GAAGC,KAAK;IAAEC;EAA0B,CAAC,GAAAJ,IAAA;EAEjE,MAAMK,wBAAwB,GAAG,MAAMZ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id";
|
3
3
|
import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
|
4
|
-
import { NoSuitableKeysFoundInEntityConfiguration } from "
|
5
|
-
import {
|
4
|
+
import { NoSuitableKeysFoundInEntityConfiguration } from "./errors";
|
5
|
+
import { hasStatusOrThrow } from "../../utils/misc";
|
6
6
|
import { disclose } from "../../sd-jwt";
|
7
7
|
import * as z from "zod";
|
8
8
|
export const AuthorizationResponse = z.object({
|
@@ -123,6 +123,6 @@ export const sendAuthorizationResponse = async (requestObject, rpConf, presentat
|
|
123
123
|
"Content-Type": "application/x-www-form-urlencoded"
|
124
124
|
},
|
125
125
|
body
|
126
|
-
}).then(
|
126
|
+
}).then(hasStatusOrThrow(200)).then(res => res.json()).then(AuthorizationResponse.parse);
|
127
127
|
};
|
128
128
|
//# sourceMappingURL=04-send-authorization-response.js.map
|