@pagopa/io-react-native-wallet 1.0.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/credential/index.js +1 -5
- package/lib/commonjs/credential/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/02-get-issuer-config.js +48 -0
- package/lib/commonjs/credential/issuance/02-get-issuer-config.js.map +1 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js +16 -20
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +8 -8
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/05-authorize-access.js +8 -9
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +18 -21
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +3 -3
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/README.md +18 -21
- package/lib/commonjs/credential/issuance/index.js +3 -3
- package/lib/commonjs/credential/issuance/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/types.js +1 -1
- package/lib/commonjs/credential/issuance/types.js.map +1 -1
- package/lib/commonjs/credential/presentation/01-start-flow.js +7 -2
- package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js +2 -2
- package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
- package/lib/commonjs/credential/presentation/03-retrieve-jwks.js +68 -0
- package/lib/commonjs/credential/presentation/03-retrieve-jwks.js.map +1 -0
- package/lib/commonjs/credential/presentation/{03-get-request-object.js → 04-get-request-object.js} +27 -13
- package/lib/commonjs/credential/presentation/04-get-request-object.js.map +1 -0
- package/lib/commonjs/credential/presentation/{04-send-authorization-response.js → 05-send-authorization-response.js} +1 -1
- package/lib/commonjs/credential/presentation/{04-send-authorization-response.js.map → 05-send-authorization-response.js.map} +1 -1
- package/lib/commonjs/credential/presentation/README.md +74 -2
- package/lib/commonjs/credential/presentation/index.js +15 -2
- package/lib/commonjs/credential/presentation/index.js.map +1 -1
- package/lib/commonjs/credential/presentation/types.js +5 -3
- package/lib/commonjs/credential/presentation/types.js.map +1 -1
- package/lib/commonjs/entity/openid-connect/issuer/index.js +25 -0
- package/lib/commonjs/entity/openid-connect/issuer/index.js.map +1 -0
- package/lib/commonjs/entity/openid-connect/issuer/types.js +61 -0
- package/lib/commonjs/entity/openid-connect/issuer/types.js.map +1 -0
- package/lib/commonjs/{trust → entity/trust}/chain.js +1 -1
- package/lib/commonjs/entity/trust/chain.js.map +1 -0
- package/lib/commonjs/{trust → entity/trust}/index.js +1 -1
- package/lib/commonjs/entity/trust/index.js.map +1 -0
- package/lib/commonjs/{trust → entity/trust}/types.js +2 -2
- package/lib/commonjs/entity/trust/types.js.map +1 -0
- package/lib/commonjs/index.js +1 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/pid/sd-jwt/types.js +2 -18
- package/lib/commonjs/pid/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/index.test.js +32 -23
- package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/types.test.js +20 -11
- package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/types.js +18 -5
- package/lib/commonjs/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/utils/error-codes.js +1 -13
- package/lib/commonjs/utils/error-codes.js.map +1 -1
- package/lib/commonjs/utils/errors.js +2 -53
- package/lib/commonjs/utils/errors.js.map +1 -1
- package/lib/commonjs/utils/jwk.js +5 -1
- package/lib/commonjs/utils/jwk.js.map +1 -1
- package/lib/commonjs/utils/par.js +6 -12
- package/lib/commonjs/utils/par.js.map +1 -1
- package/lib/module/credential/index.js +1 -3
- package/lib/module/credential/index.js.map +1 -1
- package/lib/module/credential/issuance/02-get-issuer-config.js +42 -0
- package/lib/module/credential/issuance/02-get-issuer-config.js.map +1 -0
- package/lib/module/credential/issuance/03-start-user-authorization.js +16 -20
- package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js +8 -8
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/05-authorize-access.js +8 -9
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +18 -21
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +3 -3
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/issuance/README.md +18 -21
- package/lib/module/credential/issuance/index.js +2 -2
- package/lib/module/credential/issuance/index.js.map +1 -1
- package/lib/module/credential/issuance/types.js +1 -1
- package/lib/module/credential/issuance/types.js.map +1 -1
- package/lib/module/credential/presentation/01-start-flow.js +7 -2
- package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/module/credential/presentation/02-evaluate-rp-trust.js +1 -1
- package/lib/module/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
- package/lib/module/credential/presentation/03-retrieve-jwks.js +61 -0
- package/lib/module/credential/presentation/03-retrieve-jwks.js.map +1 -0
- package/lib/module/credential/presentation/{03-get-request-object.js → 04-get-request-object.js} +26 -12
- package/lib/module/credential/presentation/04-get-request-object.js.map +1 -0
- package/lib/module/credential/presentation/{04-send-authorization-response.js → 05-send-authorization-response.js} +1 -1
- package/lib/module/credential/presentation/{04-send-authorization-response.js.map → 05-send-authorization-response.js.map} +1 -1
- package/lib/module/credential/presentation/README.md +74 -2
- 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 +5 -3
- package/lib/module/credential/presentation/types.js.map +1 -1
- package/lib/module/entity/openid-connect/issuer/index.js +20 -0
- package/lib/module/entity/openid-connect/issuer/index.js.map +1 -0
- package/lib/module/entity/openid-connect/issuer/types.js +47 -0
- package/lib/module/entity/openid-connect/issuer/types.js.map +1 -0
- package/lib/module/{trust → entity/trust}/chain.js +1 -1
- package/lib/module/entity/trust/chain.js.map +1 -0
- package/lib/module/{trust → entity/trust}/index.js +1 -1
- package/lib/module/entity/trust/index.js.map +1 -0
- package/lib/module/{trust → entity/trust}/types.js +2 -2
- package/lib/module/entity/trust/types.js.map +1 -0
- package/lib/module/index.js +1 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/pid/sd-jwt/types.js +1 -16
- package/lib/module/pid/sd-jwt/types.js.map +1 -1
- package/lib/module/sd-jwt/__test__/index.test.js +32 -23
- package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/module/sd-jwt/__test__/types.test.js +20 -11
- package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/module/sd-jwt/types.js +16 -4
- package/lib/module/sd-jwt/types.js.map +1 -1
- package/lib/module/utils/error-codes.js +1 -13
- package/lib/module/utils/error-codes.js.map +1 -1
- package/lib/module/utils/errors.js +0 -48
- package/lib/module/utils/errors.js.map +1 -1
- package/lib/module/utils/jwk.js +3 -0
- package/lib/module/utils/jwk.js.map +1 -1
- package/lib/module/utils/par.js +6 -12
- package/lib/module/utils/par.js.map +1 -1
- package/lib/typescript/credential/index.d.ts +1 -3
- package/lib/typescript/credential/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -1
- package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts +32 -0
- package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +3 -3
- 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 +8 -8
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts +3 -3
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +3 -3
- 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 +3 -3
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/index.d.ts +3 -3
- package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/types.d.ts +4 -9
- package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
- 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 -1
- package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/03-retrieve-jwks.d.ts +41 -0
- package/lib/typescript/credential/presentation/03-retrieve-jwks.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/{03-get-request-object.d.ts → 04-get-request-object.d.ts} +4 -4
- package/lib/typescript/credential/presentation/04-get-request-object.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/{04-send-authorization-response.d.ts → 05-send-authorization-response.d.ts} +2 -2
- package/lib/typescript/credential/presentation/{04-send-authorization-response.d.ts.map → 05-send-authorization-response.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 +15 -15
- package/lib/typescript/entity/openid-connect/issuer/index.d.ts +12 -0
- package/lib/typescript/entity/openid-connect/issuer/index.d.ts.map +1 -0
- package/lib/typescript/entity/openid-connect/issuer/types.d.ts +641 -0
- package/lib/typescript/entity/openid-connect/issuer/types.d.ts.map +1 -0
- package/lib/typescript/entity/trust/chain.d.ts.map +1 -0
- package/lib/typescript/{trust → entity/trust}/index.d.ts +97 -97
- package/lib/typescript/entity/trust/index.d.ts.map +1 -0
- package/lib/typescript/{trust → entity/trust}/types.d.ts +597 -597
- package/lib/typescript/{trust → entity/trust}/types.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/pid/sd-jwt/types.d.ts +25 -103
- package/lib/typescript/pid/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/index.d.ts +60 -20
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/types.d.ts +114 -24
- package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/utils/error-codes.d.ts +0 -12
- package/lib/typescript/utils/error-codes.d.ts.map +1 -1
- package/lib/typescript/utils/errors.d.ts +6 -37
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/jwk.d.ts +135 -0
- package/lib/typescript/utils/jwk.d.ts.map +1 -1
- package/lib/typescript/utils/par.d.ts +1 -8
- package/lib/typescript/utils/par.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/types.d.ts +12 -12
- package/package.json +1 -1
- package/src/credential/index.ts +1 -4
- package/src/credential/issuance/01-start-flow.ts +1 -1
- package/src/credential/issuance/02-get-issuer-config.ts +67 -0
- package/src/credential/issuance/03-start-user-authorization.ts +22 -30
- package/src/credential/issuance/04-complete-user-authorization.ts +11 -13
- package/src/credential/issuance/05-authorize-access.ts +8 -10
- package/src/credential/issuance/06-obtain-credential.ts +30 -31
- package/src/credential/issuance/07-verify-and-parse-credential.ts +6 -6
- package/src/credential/issuance/README.md +18 -21
- package/src/credential/issuance/index.ts +3 -6
- package/src/credential/issuance/types.ts +1 -1
- package/src/credential/presentation/01-start-flow.ts +8 -2
- package/src/credential/presentation/02-evaluate-rp-trust.ts +2 -2
- package/src/credential/presentation/03-retrieve-jwks.ts +73 -0
- package/src/credential/presentation/{03-get-request-object.ts → 04-get-request-object.ts} +33 -15
- package/src/credential/presentation/{04-send-authorization-response.ts → 05-send-authorization-response.ts} +1 -1
- package/src/credential/presentation/README.md +74 -2
- package/src/credential/presentation/index.ts +10 -2
- package/src/credential/presentation/types.ts +3 -3
- package/src/entity/openid-connect/issuer/index.ts +27 -0
- package/src/entity/openid-connect/issuer/types.ts +68 -0
- package/src/{trust → entity/trust}/chain.ts +2 -2
- package/src/{trust → entity/trust}/index.ts +1 -1
- package/src/{trust → entity/trust}/types.ts +2 -2
- package/src/index.ts +0 -2
- package/src/pid/sd-jwt/types.ts +1 -18
- package/src/sd-jwt/__test__/index.test.ts +47 -37
- package/src/sd-jwt/__test__/types.test.ts +26 -16
- package/src/sd-jwt/types.ts +16 -2
- package/src/utils/error-codes.ts +0 -12
- package/src/utils/errors.ts +12 -86
- package/src/utils/jwk.ts +5 -0
- package/src/utils/par.ts +3 -10
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js +0 -27
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js.map +0 -1
- package/lib/commonjs/credential/presentation/03-get-request-object.js.map +0 -1
- package/lib/commonjs/credential/status/01-start-flow.js +0 -2
- package/lib/commonjs/credential/status/01-start-flow.js.map +0 -1
- package/lib/commonjs/credential/status/02-status-attestation.js +0 -72
- package/lib/commonjs/credential/status/02-status-attestation.js.map +0 -1
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +0 -52
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +0 -1
- package/lib/commonjs/credential/status/README.md +0 -67
- package/lib/commonjs/credential/status/index.js +0 -27
- package/lib/commonjs/credential/status/index.js.map +0 -1
- package/lib/commonjs/credential/status/types.js +0 -48
- package/lib/commonjs/credential/status/types.js.map +0 -1
- package/lib/commonjs/credential/trustmark/README.md +0 -62
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js +0 -81
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js.map +0 -1
- package/lib/commonjs/credential/trustmark/index.js +0 -13
- package/lib/commonjs/credential/trustmark/index.js.map +0 -1
- package/lib/commonjs/trust/chain.js.map +0 -1
- package/lib/commonjs/trust/index.js.map +0 -1
- package/lib/commonjs/trust/types.js.map +0 -1
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +0 -20
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +0 -1
- package/lib/module/credential/presentation/03-get-request-object.js.map +0 -1
- package/lib/module/credential/status/01-start-flow.js +0 -2
- package/lib/module/credential/status/01-start-flow.js.map +0 -1
- package/lib/module/credential/status/02-status-attestation.js +0 -64
- package/lib/module/credential/status/02-status-attestation.js.map +0 -1
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +0 -46
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +0 -1
- package/lib/module/credential/status/README.md +0 -67
- package/lib/module/credential/status/index.js +0 -5
- package/lib/module/credential/status/index.js.map +0 -1
- package/lib/module/credential/status/types.js +0 -40
- package/lib/module/credential/status/types.js.map +0 -1
- package/lib/module/credential/trustmark/README.md +0 -62
- package/lib/module/credential/trustmark/get-credential-trustmark.js +0 -72
- package/lib/module/credential/trustmark/get-credential-trustmark.js.map +0 -1
- package/lib/module/credential/trustmark/index.js +0 -3
- package/lib/module/credential/trustmark/index.js.map +0 -1
- package/lib/module/trust/chain.js.map +0 -1
- package/lib/module/trust/index.js.map +0 -1
- package/lib/module/trust/types.js.map +0 -1
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts +0 -19
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +0 -1
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +0 -1
- package/lib/typescript/credential/status/01-start-flow.d.ts +0 -10
- package/lib/typescript/credential/status/01-start-flow.d.ts.map +0 -1
- package/lib/typescript/credential/status/02-status-attestation.d.ts +0 -19
- package/lib/typescript/credential/status/02-status-attestation.d.ts.map +0 -1
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts +0 -24
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +0 -1
- package/lib/typescript/credential/status/index.d.ts +0 -7
- package/lib/typescript/credential/status/index.d.ts.map +0 -1
- package/lib/typescript/credential/status/types.d.ts +0 -305
- package/lib/typescript/credential/status/types.d.ts.map +0 -1
- package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts +0 -52
- package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts.map +0 -1
- package/lib/typescript/credential/trustmark/index.d.ts +0 -4
- package/lib/typescript/credential/trustmark/index.d.ts.map +0 -1
- package/lib/typescript/trust/chain.d.ts.map +0 -1
- package/lib/typescript/trust/index.d.ts.map +0 -1
- package/src/credential/issuance/02-evaluate-issuer-trust.ts +0 -32
- package/src/credential/status/01-start-flow.ts +0 -9
- package/src/credential/status/02-status-attestation.ts +0 -102
- package/src/credential/status/03-verify-and-parse-status-attestation.ts +0 -60
- package/src/credential/status/README.md +0 -67
- package/src/credential/status/index.ts +0 -22
- package/src/credential/status/types.ts +0 -43
- package/src/credential/trustmark/README.md +0 -62
- package/src/credential/trustmark/get-credential-trustmark.ts +0 -120
- package/src/credential/trustmark/index.ts +0 -8
- /package/lib/typescript/{trust → entity/trust}/chain.d.ts +0 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
import type { StartFlow } from "./01-start-flow";
|
2
|
+
import type { Out } from "../../utils/misc";
|
3
|
+
import type { JWK } from "src/utils/jwk";
|
4
|
+
import { getCredentialIssuerMetadata } from "../../entity/openid-connect/issuer";
|
5
|
+
import type { CredentialConfigurationSupported } from "../../entity/openid-connect/issuer/types";
|
6
|
+
|
7
|
+
export type GetIssuerConfig = (
|
8
|
+
issuerUrl: Out<StartFlow>["issuerUrl"],
|
9
|
+
context?: {
|
10
|
+
appFetch?: GlobalFetch["fetch"];
|
11
|
+
}
|
12
|
+
) => Promise<{ issuerConf: IssuerConfig }>;
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Common configuration for the issuer.
|
16
|
+
* This is needed to have a common configuration for the issuer to be used in our flows.
|
17
|
+
* It allows to support multiple issuers with different configurations, defining a common interface to interact with them.
|
18
|
+
*/
|
19
|
+
export type IssuerConfig = {
|
20
|
+
credential_configurations_supported: CredentialConfigurationSupported;
|
21
|
+
pushed_authorization_request_endpoint: string;
|
22
|
+
authorization_endpoint: string;
|
23
|
+
token_endpoint: string;
|
24
|
+
credential_endpoint: string;
|
25
|
+
keys: Array<JWK>;
|
26
|
+
};
|
27
|
+
|
28
|
+
/**
|
29
|
+
* WARNING: This function must be called after {@link startFlow}. The next function to be called is {@link startUserAuthorization}.
|
30
|
+
* Get the Issuer's configuration from the Issuer's metadata.
|
31
|
+
* Currently it only supports a mixed configuration based on OpenID Connect partial implementation.
|
32
|
+
* @param issuerUrl The base url of the Issuer returned by {@link startFlow}
|
33
|
+
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
34
|
+
* @returns The Issuer's configuration
|
35
|
+
*/
|
36
|
+
export const getIssuerConfig: GetIssuerConfig = async (
|
37
|
+
issuerUrl,
|
38
|
+
context = {}
|
39
|
+
): ReturnType<GetIssuerConfig> => {
|
40
|
+
const res = await getCredentialIssuerMetadata(issuerUrl, {
|
41
|
+
appFetch: context.appFetch,
|
42
|
+
});
|
43
|
+
|
44
|
+
return credentialIssuerRationalization(res);
|
45
|
+
};
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Rationalize the issuer's metadata to the issuer's configuration which is then used in our flows to interact with the issuer.
|
49
|
+
* @param issuerMetadata - The issuer's metadata
|
50
|
+
* @returns the isssuer configuration to be used later in our flows
|
51
|
+
*/
|
52
|
+
const credentialIssuerRationalization = (
|
53
|
+
issuerMetadata: Awaited<ReturnType<typeof getCredentialIssuerMetadata>>
|
54
|
+
): Awaited<ReturnType<GetIssuerConfig>> => {
|
55
|
+
return {
|
56
|
+
issuerConf: {
|
57
|
+
credential_configurations_supported:
|
58
|
+
issuerMetadata.credential_configurations_supported,
|
59
|
+
pushed_authorization_request_endpoint:
|
60
|
+
issuerMetadata.pushed_authorization_request_endpoint,
|
61
|
+
authorization_endpoint: issuerMetadata.authorization_endpoint,
|
62
|
+
token_endpoint: issuerMetadata.token_endpoint,
|
63
|
+
credential_endpoint: issuerMetadata.credential_endpoint,
|
64
|
+
keys: issuerMetadata.jwks.keys,
|
65
|
+
},
|
66
|
+
};
|
67
|
+
};
|
@@ -1,13 +1,12 @@
|
|
1
1
|
import type { CryptoContext } from "@pagopa/io-react-native-jwt";
|
2
2
|
import type { ResponseMode } from "./types";
|
3
3
|
import { generateRandomAlphaNumericString, type Out } from "../../utils/misc";
|
4
|
-
import type { EvaluateIssuerTrust } from "./02-evaluate-issuer-trust";
|
5
4
|
import type { StartFlow } from "./01-start-flow";
|
6
5
|
import { AuthorizationDetail, makeParRequest } from "../../utils/par";
|
7
|
-
import {
|
6
|
+
import type { GetIssuerConfig } from "./02-get-issuer-config";
|
8
7
|
|
9
8
|
export type StartUserAuthorization = (
|
10
|
-
issuerConf: Out<
|
9
|
+
issuerConf: Out<GetIssuerConfig>["issuerConf"],
|
11
10
|
credentialType: Out<StartFlow>["credentialType"],
|
12
11
|
context: {
|
13
12
|
wiaCryptoContext: CryptoContext;
|
@@ -25,7 +24,7 @@ export type StartUserAuthorization = (
|
|
25
24
|
/**
|
26
25
|
* Ensures that the credential type requested is supported by the issuer and contained in the
|
27
26
|
* issuer configuration.
|
28
|
-
* @param issuerConf The issuer configuration returned by {@link
|
27
|
+
* @param issuerConf The issuer configuration returned by {@link getIssuerConfig}
|
29
28
|
* @param credentialType The type of the credential to be requested returned by {@link startFlow}
|
30
29
|
* @param context.wiaCryptoContext The Wallet Instance's crypto context
|
31
30
|
* @param context.walletInstanceAttestation The Wallet Instance's attestation
|
@@ -34,23 +33,24 @@ export type StartUserAuthorization = (
|
|
34
33
|
* @returns The credential definition to be used in the request which includes the format and the type and its type
|
35
34
|
*/
|
36
35
|
const selectCredentialDefinition = (
|
37
|
-
issuerConf: Out<
|
36
|
+
issuerConf: Out<GetIssuerConfig>["issuerConf"],
|
38
37
|
credentialType: Out<StartFlow>["credentialType"]
|
39
38
|
): AuthorizationDetail => {
|
40
39
|
const credential_configurations_supported =
|
41
|
-
issuerConf.
|
40
|
+
issuerConf.credential_configurations_supported;
|
42
41
|
|
43
|
-
const
|
44
|
-
.filter((e) => e.includes(credentialType))
|
45
|
-
.map((e) => ({
|
46
|
-
credential_configuration_id: credentialType,
|
47
|
-
format: credential_configurations_supported[e]!.format,
|
48
|
-
type: "openid_credential" as const,
|
49
|
-
}));
|
42
|
+
const credential = credential_configurations_supported[credentialType];
|
50
43
|
|
51
|
-
if (!
|
44
|
+
if (!credential) {
|
52
45
|
throw new Error(`No credential support the type '${credentialType}'`);
|
53
46
|
}
|
47
|
+
|
48
|
+
const result = {
|
49
|
+
credential_configuration_id: credentialType,
|
50
|
+
format: credential.format,
|
51
|
+
type: "openid_credential" as const,
|
52
|
+
};
|
53
|
+
|
54
54
|
return result;
|
55
55
|
};
|
56
56
|
|
@@ -58,27 +58,21 @@ const selectCredentialDefinition = (
|
|
58
58
|
* Ensures that the response mode requested is supported by the issuer and contained in the issuer configuration.
|
59
59
|
* @param issuerConf The issuer configuration
|
60
60
|
* @param credentialType The type of the credential to be requested
|
61
|
-
* @returns The response mode to be used in the request, "query" for
|
61
|
+
* @returns The response mode to be used in the request, "query" for urn:eu.europa.ec.eudi:pid:1 and "form_post.jwt" for all other types.
|
62
62
|
*/
|
63
63
|
const selectResponseMode = (
|
64
|
-
issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
|
65
64
|
credentialType: Out<StartFlow>["credentialType"]
|
66
65
|
): ResponseMode => {
|
67
|
-
const responseModeSupported =
|
68
|
-
issuerConf.oauth_authorization_server.response_modes_supported;
|
69
|
-
|
70
66
|
const responseMode =
|
71
|
-
credentialType === "
|
72
|
-
|
73
|
-
|
74
|
-
throw new Error(`No response mode support the type '${credentialType}'`);
|
75
|
-
}
|
67
|
+
credentialType === "urn:eu.europa.ec.eudi:pid:1"
|
68
|
+
? "query"
|
69
|
+
: "form_post.jwt";
|
76
70
|
|
77
71
|
return responseMode;
|
78
72
|
};
|
79
73
|
|
80
74
|
/**
|
81
|
-
* WARNING: This function must be called after {@link
|
75
|
+
* WARNING: This function must be called after {@link getIssuerConfig} and {@link startFlow}. The next steam is {@link compeUserAuthorizationWithQueryMode} or {@link compeUserAuthorizationWithFormPostJwtMode}
|
82
76
|
* Creates and sends a PAR request to the /as/par endpoint of the authorization server.
|
83
77
|
* This starts the authentication flow to obtain an access token.
|
84
78
|
* This token enables the Wallet Instance to request a digital credential from the Credential Endpoint of the Credential Issuer.
|
@@ -109,13 +103,12 @@ export const startUserAuthorization: StartUserAuthorization = async (
|
|
109
103
|
|
110
104
|
const clientId = await wiaCryptoContext.getPublicKey().then((_) => _.kid);
|
111
105
|
const codeVerifier = generateRandomAlphaNumericString(64);
|
112
|
-
const parEndpoint =
|
113
|
-
issuerConf.oauth_authorization_server.pushed_authorization_request_endpoint;
|
106
|
+
const parEndpoint = issuerConf.pushed_authorization_request_endpoint;
|
114
107
|
const credentialDefinition = selectCredentialDefinition(
|
115
108
|
issuerConf,
|
116
109
|
credentialType
|
117
110
|
);
|
118
|
-
const responseMode = selectResponseMode(
|
111
|
+
const responseMode = selectResponseMode(credentialType);
|
119
112
|
|
120
113
|
const getPar = makeParRequest({ wiaCryptoContext, appFetch });
|
121
114
|
const issuerRequestUri = await getPar(
|
@@ -125,8 +118,7 @@ export const startUserAuthorization: StartUserAuthorization = async (
|
|
125
118
|
responseMode,
|
126
119
|
parEndpoint,
|
127
120
|
walletInstanceAttestation,
|
128
|
-
[credentialDefinition]
|
129
|
-
ASSERTION_TYPE
|
121
|
+
[credentialDefinition]
|
130
122
|
);
|
131
123
|
|
132
124
|
return { issuerRequestUri, clientId, codeVerifier, credentialDefinition };
|
@@ -7,7 +7,7 @@ import { hasStatusOrThrow, type Out } from "../../utils/misc";
|
|
7
7
|
import type { StartUserAuthorization } from "./03-start-user-authorization";
|
8
8
|
import parseUrl from "parse-url";
|
9
9
|
import { IssuerResponseError, ValidationFailed } from "../../utils/errors";
|
10
|
-
import type {
|
10
|
+
import type { GetIssuerConfig } from "./02-get-issuer-config";
|
11
11
|
import {
|
12
12
|
decode,
|
13
13
|
encodeBase64,
|
@@ -21,7 +21,7 @@ import { getJwtFromFormPost } from "../../utils/decoder";
|
|
21
21
|
import { AuthorizationError, AuthorizationIdpError } from "./errors";
|
22
22
|
|
23
23
|
/**
|
24
|
-
* The interface of the phase to complete User authorization via strong identification when the response mode is "query" and the request credential is a
|
24
|
+
* The interface of the phase to complete User authorization via strong identification when the response mode is "query" and the request credential is a urn:eu.europa.ec.eudi:pid:1.
|
25
25
|
*/
|
26
26
|
export type CompleteUserAuthorizationWithQueryMode = (
|
27
27
|
authRedirectUrl: string
|
@@ -41,14 +41,14 @@ export type CompleteUserAuthorizationWithFormPostJwtMode = (
|
|
41
41
|
export type GetRequestedCredentialToBePresented = (
|
42
42
|
issuerRequestUri: Out<StartUserAuthorization>["issuerRequestUri"],
|
43
43
|
clientId: Out<StartUserAuthorization>["clientId"],
|
44
|
-
issuerConf: Out<
|
44
|
+
issuerConf: Out<GetIssuerConfig>["issuerConf"],
|
45
45
|
appFetch?: GlobalFetch["fetch"]
|
46
46
|
) => Promise<RequestObject>;
|
47
47
|
|
48
48
|
export type BuildAuthorizationUrl = (
|
49
49
|
issuerRequestUri: Out<StartUserAuthorization>["issuerRequestUri"],
|
50
50
|
clientId: Out<StartUserAuthorization>["clientId"],
|
51
|
-
issuerConf: Out<
|
51
|
+
issuerConf: Out<GetIssuerConfig>["issuerConf"],
|
52
52
|
idpHint: string
|
53
53
|
) => Promise<{
|
54
54
|
authUrl: string;
|
@@ -59,7 +59,7 @@ export type BuildAuthorizationUrl = (
|
|
59
59
|
* Builds the authorization URL to which the end user should be redirected to continue the authentication flow.
|
60
60
|
* @param issuerRequestUri the URI of the issuer where the request is sent
|
61
61
|
* @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
|
62
|
-
* @param issuerConf The issuer configuration returned by {@link
|
62
|
+
* @param issuerConf The issuer configuration returned by {@link getIssuerConfig}
|
63
63
|
* @param idpHint Unique identifier of the IDP selected by the user
|
64
64
|
* @returns An object containing the authorization URL
|
65
65
|
*/
|
@@ -69,8 +69,7 @@ export const buildAuthorizationUrl: BuildAuthorizationUrl = async (
|
|
69
69
|
issuerConf,
|
70
70
|
idpHint
|
71
71
|
) => {
|
72
|
-
const authzRequestEndpoint =
|
73
|
-
issuerConf.oauth_authorization_server.authorization_endpoint;
|
72
|
+
const authzRequestEndpoint = issuerConf.authorization_endpoint;
|
74
73
|
|
75
74
|
const params = new URLSearchParams({
|
76
75
|
client_id: clientId,
|
@@ -85,7 +84,7 @@ export const buildAuthorizationUrl: BuildAuthorizationUrl = async (
|
|
85
84
|
|
86
85
|
/**
|
87
86
|
* WARNING: This function must be called after obtaining the authorization redirect URL from the webviews (SPID and CIE L3) or browser for CIEID.
|
88
|
-
* Complete User authorization via strong identification when the response mode is "query" and the request credential is a
|
87
|
+
* Complete User authorization via strong identification when the response mode is "query" and the request credential is a urn:eu.europa.ec.eudi:pid:1.
|
89
88
|
* This function parses the authorization redirect URL to extract the authorization response.
|
90
89
|
* @param authRedirectUrl The URL to which the end user should be redirected to start the authentication flow
|
91
90
|
* @returns the authorization response which contains code, state and iss
|
@@ -104,15 +103,14 @@ export const completeUserAuthorizationWithQueryMode: CompleteUserAuthorizationWi
|
|
104
103
|
* The information is obtained by performing a GET request to the authorization endpoint with request_uri and client_id parameters.
|
105
104
|
* @param issuerRequestUri the URI of the issuer where the request is sent
|
106
105
|
* @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
|
107
|
-
* @param issuerConf The issuer configuration returned by {@link
|
106
|
+
* @param issuerConf The issuer configuration returned by {@link getIssuerConfig}
|
108
107
|
* @param appFetch (optional) fetch api implementation. Default: built-in fetch
|
109
108
|
* @throws {ValidationFailed} if an error while validating the response
|
110
109
|
* @returns the request object which contains the credential to be presented in order to obtain the requested credential
|
111
110
|
*/
|
112
111
|
export const getRequestedCredentialToBePresented: GetRequestedCredentialToBePresented =
|
113
112
|
async (issuerRequestUri, clientId, issuerConf, appFetch = fetch) => {
|
114
|
-
const authzRequestEndpoint =
|
115
|
-
issuerConf.oauth_authorization_server.authorization_endpoint;
|
113
|
+
const authzRequestEndpoint = issuerConf.authorization_endpoint;
|
116
114
|
const params = new URLSearchParams({
|
117
115
|
client_id: clientId,
|
118
116
|
request_uri: issuerRequestUri,
|
@@ -143,7 +141,7 @@ export const getRequestedCredentialToBePresented: GetRequestedCredentialToBePres
|
|
143
141
|
* The information is obtained by performing a GET request to the authorization endpoint with request_uri and client_id parameters.
|
144
142
|
* @param issuerRequestUri the URI of the issuer where the request is sent
|
145
143
|
* @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
|
146
|
-
* @param issuerConf The issuer configuration returned by {@link
|
144
|
+
* @param issuerConf The issuer configuration returned by {@link getIssuerConfig}
|
147
145
|
* @param context.walletInstanceAccestation the Wallet Instance's attestation to be presented
|
148
146
|
* @param context.pid the PID to be presented
|
149
147
|
* @param context.wiaCryptoContext The Wallet Instance's crypto context associated with the walletInstanceAttestation parameter
|
@@ -200,7 +198,7 @@ export const completeUserAuthorizationWithFormPostJwtMode: CompleteUserAuthoriza
|
|
200
198
|
id: `${uuid.v4()}`,
|
201
199
|
descriptor_map: [
|
202
200
|
{
|
203
|
-
id: "
|
201
|
+
id: "urn:eu.europa.ec.eudi:pid:1",
|
204
202
|
path: "$.vp_token[0].vp",
|
205
203
|
format: "vc+sd-jwt",
|
206
204
|
},
|
@@ -1,18 +1,17 @@
|
|
1
1
|
import { hasStatusOrThrow, type Out } from "../../utils/misc";
|
2
|
-
import type {
|
2
|
+
import type { GetIssuerConfig } from "./02-get-issuer-config";
|
3
3
|
import type { StartUserAuthorization } from "./03-start-user-authorization";
|
4
4
|
import { createDPopToken } from "../../utils/dpop";
|
5
5
|
import uuid from "react-native-uuid";
|
6
6
|
import { createPopToken } from "../../utils/pop";
|
7
7
|
import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
|
8
8
|
import type { CryptoContext } from "@pagopa/io-react-native-jwt";
|
9
|
-
import { ASSERTION_TYPE } from "./const";
|
10
9
|
import { TokenResponse } from "./types";
|
11
10
|
import { IssuerResponseError, ValidationFailed } from "../../utils/errors";
|
12
11
|
import type { CompleteUserAuthorizationWithQueryMode } from "./04-complete-user-authorization";
|
13
12
|
|
14
13
|
export type AuthorizeAccess = (
|
15
|
-
issuerConf: Out<
|
14
|
+
issuerConf: Out<GetIssuerConfig>["issuerConf"],
|
16
15
|
code: Out<CompleteUserAuthorizationWithQueryMode>["code"],
|
17
16
|
redirectUri: string,
|
18
17
|
clientId: Out<StartUserAuthorization>["clientId"],
|
@@ -30,7 +29,7 @@ export type AuthorizeAccess = (
|
|
30
29
|
* for requesting the issuance of an access token bound to the public key of the Wallet Instance contained within the DPoP.
|
31
30
|
* This enables the Wallet Instance to request a digital credential.
|
32
31
|
* The DPoP Proof JWT is generated according to the section 4.3 of the DPoP RFC 9449 specification.
|
33
|
-
* @param issuerConf The issuer configuration returned by {@link
|
32
|
+
* @param issuerConf The issuer configuration returned by {@link getIssuerConfig}
|
34
33
|
* @param code The authorization code returned by {@link completeUserAuthorizationWithQueryMode} or {@link completeUserAuthorizationWithFormPost}
|
35
34
|
* @param redirectUri The redirect URI which is the custom URL scheme that the Wallet Instance is registered to handle
|
36
35
|
* @param clientId The client id returned by {@link startUserAuthorization}
|
@@ -58,14 +57,13 @@ export const authorizeAccess: AuthorizeAccess = async (
|
|
58
57
|
dPopCryptoContext,
|
59
58
|
} = context;
|
60
59
|
|
61
|
-
const parEndpoint =
|
62
|
-
issuerConf.oauth_authorization_server.pushed_authorization_request_endpoint;
|
60
|
+
const parEndpoint = issuerConf.pushed_authorization_request_endpoint;
|
63
61
|
const parUrl = new URL(parEndpoint);
|
64
62
|
const aud = `${parUrl.protocol}//${parUrl.hostname}`;
|
65
63
|
const iss = WalletInstanceAttestation.decode(walletInstanceAttestation)
|
66
64
|
.payload.cnf.jwk.kid;
|
67
65
|
|
68
|
-
const tokenUrl = issuerConf.
|
66
|
+
const tokenUrl = issuerConf.token_endpoint;
|
69
67
|
|
70
68
|
const tokenRequestSignedDPop = await createDPopToken(
|
71
69
|
{
|
@@ -86,13 +84,11 @@ export const authorizeAccess: AuthorizeAccess = async (
|
|
86
84
|
);
|
87
85
|
|
88
86
|
const requestBody = {
|
89
|
-
grant_type: "authorization_code",
|
90
87
|
client_id: clientId,
|
88
|
+
grant_type: "authorization_code",
|
91
89
|
code,
|
92
90
|
redirect_uri: redirectUri,
|
93
91
|
code_verifier: codeVerifier,
|
94
|
-
client_assertion_type: ASSERTION_TYPE,
|
95
|
-
client_assertion: walletInstanceAttestation + "~" + signedWiaPoP,
|
96
92
|
};
|
97
93
|
|
98
94
|
const authorizationRequestFormBody = new URLSearchParams(requestBody);
|
@@ -101,6 +97,8 @@ export const authorizeAccess: AuthorizeAccess = async (
|
|
101
97
|
headers: {
|
102
98
|
"Content-Type": "application/x-www-form-urlencoded",
|
103
99
|
DPoP: tokenRequestSignedDPop,
|
100
|
+
"OAuth-Client-Attestation": walletInstanceAttestation,
|
101
|
+
"OAuth-Client-Attestation-PoP": signedWiaPoP,
|
104
102
|
},
|
105
103
|
body: authorizationRequestFormBody.toString(),
|
106
104
|
})
|
@@ -4,7 +4,7 @@ import {
|
|
4
4
|
SignJWT,
|
5
5
|
} from "@pagopa/io-react-native-jwt";
|
6
6
|
import type { AuthorizeAccess } from "./05-authorize-access";
|
7
|
-
import type {
|
7
|
+
import type { GetIssuerConfig } from "./02-get-issuer-config";
|
8
8
|
import { hasStatusOrThrow, type Out } from "../../utils/misc";
|
9
9
|
import type { StartUserAuthorization } from "./03-start-user-authorization";
|
10
10
|
import {
|
@@ -19,7 +19,7 @@ import { createDPopToken } from "../../utils/dpop";
|
|
19
19
|
import uuid from "react-native-uuid";
|
20
20
|
|
21
21
|
export type ObtainCredential = (
|
22
|
-
issuerConf: Out<
|
22
|
+
issuerConf: Out<GetIssuerConfig>["issuerConf"],
|
23
23
|
accessToken: Out<AuthorizeAccess>["accessToken"],
|
24
24
|
clientId: Out<StartUserAuthorization>["clientId"],
|
25
25
|
credentialDefinition: Out<StartUserAuthorization>["credentialDefinition"],
|
@@ -58,7 +58,7 @@ export const createNonceProof = async (
|
|
58
58
|
* of the Credential Issuer to request the issuance of a credential linked to the public key contained in the JWT proof.
|
59
59
|
* The Openid4vci proof JWT incapsulates the nonce extracted from the token response from the {@link authorizeAccess} step.
|
60
60
|
* The credential request is sent to the Credential Endpoint of the Credential Issuer via HTTP POST with the type of the credential, its format, the access token and the JWT proof.
|
61
|
-
* @param issuerConf The issuer configuration returned by {@link
|
61
|
+
* @param issuerConf The issuer configuration returned by {@link getIssuerConfig}
|
62
62
|
* @param accessToken The access token response returned by {@link authorizeAccess}
|
63
63
|
* @param clientId The client id returned by {@link startUserAuthorization}
|
64
64
|
* @param credentialDefinition The credential definition of the credential to be obtained returned by {@link startUserAuthorization}
|
@@ -81,7 +81,7 @@ export const obtainCredential: ObtainCredential = async (
|
|
81
81
|
dPopCryptoContext,
|
82
82
|
} = context;
|
83
83
|
|
84
|
-
const credentialUrl = issuerConf.
|
84
|
+
const credentialUrl = issuerConf.credential_endpoint;
|
85
85
|
|
86
86
|
/**
|
87
87
|
* JWT proof token to bind the request nonce to the key that will bind the holder User with the Credential
|
@@ -95,14 +95,10 @@ export const obtainCredential: ObtainCredential = async (
|
|
95
95
|
credentialCryptoContext
|
96
96
|
);
|
97
97
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
credentialDefinition.credential_configuration_id &&
|
103
|
-
c.format === credentialDefinition.format &&
|
104
|
-
c.type === credentialDefinition.type
|
105
|
-
);
|
98
|
+
const containsCredentialDefinition =
|
99
|
+
accessToken.authorization_details.credential_configuration_id ===
|
100
|
+
credentialDefinition.credential_configuration_id &&
|
101
|
+
accessToken.authorization_details.type === credentialDefinition.type;
|
106
102
|
|
107
103
|
if (!containsCredentialDefinition) {
|
108
104
|
throw new ValidationFailed({
|
@@ -111,12 +107,30 @@ export const obtainCredential: ObtainCredential = async (
|
|
111
107
|
});
|
112
108
|
}
|
113
109
|
|
110
|
+
const credential =
|
111
|
+
issuerConf.credential_configurations_supported[
|
112
|
+
credentialDefinition.credential_configuration_id
|
113
|
+
];
|
114
|
+
|
115
|
+
if (!credential) {
|
116
|
+
throw new ValidationFailed({
|
117
|
+
message: "The credential configuration is not supported by the issuer",
|
118
|
+
});
|
119
|
+
}
|
120
|
+
|
121
|
+
const format = credential.format;
|
122
|
+
|
123
|
+
if (!format) {
|
124
|
+
throw new ValidationFailed({
|
125
|
+
message:
|
126
|
+
"The credential doesn't contain the format required by the issuer",
|
127
|
+
});
|
128
|
+
}
|
129
|
+
|
114
130
|
/** The credential request body */
|
115
131
|
const credentialRequestFormBody = {
|
116
|
-
|
117
|
-
|
118
|
-
},
|
119
|
-
format: credentialDefinition.format,
|
132
|
+
vct: credentialDefinition.credential_configuration_id,
|
133
|
+
format,
|
120
134
|
proof: {
|
121
135
|
jwt: signedNonceProof,
|
122
136
|
proof_type: "jwt",
|
@@ -168,21 +182,6 @@ const handleObtainCredentialError = (e: unknown) => {
|
|
168
182
|
}
|
169
183
|
|
170
184
|
throw new ResponseErrorBuilder(IssuerResponseError)
|
171
|
-
.handle(201, {
|
172
|
-
// Although it is technically not an error, we handle it as such to avoid
|
173
|
-
// changing the return type of `obtainCredential` and introduce a breaking change.
|
174
|
-
code: IssuerResponseErrorCodes.CredentialIssuingNotSynchronous,
|
175
|
-
message:
|
176
|
-
"This credential cannot be issued synchronously. It will be available at a later time.",
|
177
|
-
})
|
178
|
-
.handle(403, {
|
179
|
-
code: IssuerResponseErrorCodes.CredentialInvalidStatus,
|
180
|
-
message: "Invalid status found for the given credential",
|
181
|
-
})
|
182
|
-
.handle(404, {
|
183
|
-
code: IssuerResponseErrorCodes.CredentialInvalidStatus,
|
184
|
-
message: "Invalid status found for the given credential",
|
185
|
-
})
|
186
185
|
.handle("*", {
|
187
186
|
code: IssuerResponseErrorCodes.CredentialRequestFailed,
|
188
187
|
message: "Unable to obtain the requested credential",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { CryptoContext } from "@pagopa/io-react-native-jwt";
|
2
2
|
import type { Out } from "../../utils/misc";
|
3
|
-
import type {
|
3
|
+
import type { GetIssuerConfig } from "./02-get-issuer-config";
|
4
4
|
import { IoWalletError } from "../../utils/errors";
|
5
5
|
import { SdJwt4VC } from "../../sd-jwt/types";
|
6
6
|
import { verify as verifySdJwt } from "../../sd-jwt";
|
@@ -9,7 +9,7 @@ import type { JWK } from "../../utils/jwk";
|
|
9
9
|
import type { ObtainCredential } from "./06-obtain-credential";
|
10
10
|
|
11
11
|
export type VerifyAndParseCredential = (
|
12
|
-
issuerConf: Out<
|
12
|
+
issuerConf: Out<GetIssuerConfig>["issuerConf"],
|
13
13
|
credential: Out<ObtainCredential>["credential"],
|
14
14
|
format: Out<ObtainCredential>["format"],
|
15
15
|
context: {
|
@@ -54,7 +54,7 @@ type DecodedSdJwtCredential = Out<typeof verifySdJwt> & {
|
|
54
54
|
|
55
55
|
const parseCredentialSdJwt = (
|
56
56
|
// the list of supported credentials, as defined in the issuer configuration
|
57
|
-
credentials_supported: Out<
|
57
|
+
credentials_supported: Out<GetIssuerConfig>["issuerConf"]["credential_configurations_supported"],
|
58
58
|
{ sdJwt, disclosures }: DecodedSdJwtCredential,
|
59
59
|
ignoreMissingAttributes: boolean = false,
|
60
60
|
includeUndefinedAttributes: boolean = false
|
@@ -200,12 +200,12 @@ const verifyAndParseCredentialSdJwt: WithFormat<"vc+sd-jwt"> = async (
|
|
200
200
|
) => {
|
201
201
|
const decoded = await verifyCredentialSdJwt(
|
202
202
|
credential,
|
203
|
-
issuerConf.
|
203
|
+
issuerConf.keys,
|
204
204
|
credentialCryptoContext
|
205
205
|
);
|
206
206
|
|
207
207
|
const parsedCredential = parseCredentialSdJwt(
|
208
|
-
issuerConf.
|
208
|
+
issuerConf.credential_configurations_supported,
|
209
209
|
decoded,
|
210
210
|
ignoreMissingAttributes,
|
211
211
|
includeUndefinedAttributes
|
@@ -225,7 +225,7 @@ const verifyAndParseCredentialSdJwt: WithFormat<"vc+sd-jwt"> = async (
|
|
225
225
|
|
226
226
|
/**
|
227
227
|
* Verify and parse an encoded credential.
|
228
|
-
* @param issuerConf The Issuer configuration returned by {@link
|
228
|
+
* @param issuerConf The Issuer configuration returned by {@link getIssuerConfig}
|
229
229
|
* @param credential The encoded credential returned by {@link obtainCredential}
|
230
230
|
* @param format The format of the credentual returned by {@link obtainCredential}
|
231
231
|
* @param context.credentialCryptoContext The crypto context used to obtain the credential in {@link obtainCredential}
|
@@ -6,7 +6,7 @@ There's a fork in the flow which is based on the type of the credential that is
|
|
6
6
|
This is due to the fact that eID credentials require a different authorization flow than other credentials, which is accomplished by a strong authentication method like SPID or CIE.
|
7
7
|
Credentials instead require a simpler authorization flow and they require other credentials to be presented in order to be issued.
|
8
8
|
|
9
|
-
The supported credentials are defined in the entity configuration of the issuer which is evaluted and parsed in the `
|
9
|
+
The supported credentials are defined in the entity configuration of the issuer which is evaluted and parsed in the `getIssuerConfig` step.
|
10
10
|
|
11
11
|
## Sequence Diagram
|
12
12
|
|
@@ -14,7 +14,7 @@ The supported credentials are defined in the entity configuration of the issuer
|
|
14
14
|
graph TD;
|
15
15
|
0[WalletInstanceAttestation.getAttestation]
|
16
16
|
1[startFlow]
|
17
|
-
2[
|
17
|
+
2[getIssuerConfig]
|
18
18
|
3[startUserAuthorization]
|
19
19
|
C4[getRequestedCredentialToBePresented]
|
20
20
|
C4.1[completeUserAuthorizationWithFormPostJwtMode]
|
@@ -41,12 +41,9 @@ graph TD;
|
|
41
41
|
|
42
42
|
The following errors are mapped to a `IssuerResponseError` with specific codes.
|
43
43
|
|
44
|
-
|HTTP Status|Error Code|Description|
|
45
|
-
|
46
|
-
|
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.|
|
44
|
+
| HTTP Status | Error Code | Description |
|
45
|
+
| ----------- | -------------------------- | ----------------------------------------------------------------------------------------------------- |
|
46
|
+
| `*` | `ERR_ISSUER_GENERIC_ERROR` | This is a generic error code to map unexpected errors that occurred when interacting with the Issuer. |
|
50
47
|
|
51
48
|
## Strong authentication for eID issuance (Query Mode)
|
52
49
|
|
@@ -121,7 +118,7 @@ const startFlow: Credential.Issuance.StartFlow = () => ({
|
|
121
118
|
const { issuerUrl } = startFlow();
|
122
119
|
|
123
120
|
// Evaluate issuer trust
|
124
|
-
const { issuerConf } = await Credential.Issuance.
|
121
|
+
const { issuerConf } = await Credential.Issuance.getIssuerConfig(issuerUrl);
|
125
122
|
|
126
123
|
// Start user authorization
|
127
124
|
const { issuerRequestUri, clientId, codeVerifier, credentialDefinition } =
|
@@ -251,17 +248,16 @@ const credentialCryptoContext = createCryptoContextFor(credentialKeyTag);
|
|
251
248
|
// Start the issuance flow
|
252
249
|
const startFlow: Credential.Issuance.StartFlow = () => ({
|
253
250
|
issuerUrl: WALLET_EID_PROVIDER_BASE_URL,
|
254
|
-
credentialType: "
|
251
|
+
credentialType: "urn:eu.europa.ec.eudi:pid:1",
|
255
252
|
appFetch,
|
256
253
|
});
|
257
254
|
|
258
255
|
const { issuerUrl } = startFlow();
|
259
256
|
|
260
257
|
// Evaluate issuer trust
|
261
|
-
const { issuerConf } = await Credential.Issuance.
|
262
|
-
|
263
|
-
|
264
|
-
);
|
258
|
+
const { issuerConf } = await Credential.Issuance.getIssuerConfig(issuerUrl, {
|
259
|
+
appFetch,
|
260
|
+
});
|
265
261
|
|
266
262
|
// Start user authorization
|
267
263
|
const { issuerRequestUri, clientId, codeVerifier, credentialDefinition } =
|
@@ -315,12 +311,13 @@ const { credential, format } = await Credential.Issuance.obtainCredential(
|
|
315
311
|
);
|
316
312
|
|
317
313
|
// Parse and verify the eID credential
|
318
|
-
const { parsedCredential, issuedAt, expiration } =
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
314
|
+
const { parsedCredential, issuedAt, expiration } =
|
315
|
+
await Credential.Issuance.verifyAndParseCredential(
|
316
|
+
issuerConf,
|
317
|
+
credential,
|
318
|
+
format,
|
319
|
+
{ credentialCryptoContext }
|
320
|
+
);
|
324
321
|
|
325
322
|
return {
|
326
323
|
parsedCredential,
|
@@ -328,7 +325,7 @@ return {
|
|
328
325
|
keyTag: credentialKeyTag,
|
329
326
|
credentialType,
|
330
327
|
issuedAt,
|
331
|
-
expiration
|
328
|
+
expiration,
|
332
329
|
};
|
333
330
|
```
|
334
331
|
|
@@ -1,8 +1,5 @@
|
|
1
1
|
import { type StartFlow } from "./01-start-flow";
|
2
|
-
import {
|
3
|
-
evaluateIssuerTrust,
|
4
|
-
type EvaluateIssuerTrust,
|
5
|
-
} from "./02-evaluate-issuer-trust";
|
2
|
+
import { getIssuerConfig, type GetIssuerConfig } from "./02-get-issuer-config";
|
6
3
|
import {
|
7
4
|
startUserAuthorization,
|
8
5
|
type StartUserAuthorization,
|
@@ -30,7 +27,7 @@ import {
|
|
30
27
|
import * as Errors from "./errors";
|
31
28
|
|
32
29
|
export {
|
33
|
-
|
30
|
+
getIssuerConfig,
|
34
31
|
startUserAuthorization,
|
35
32
|
buildAuthorizationUrl,
|
36
33
|
completeUserAuthorizationWithQueryMode,
|
@@ -44,7 +41,7 @@ export {
|
|
44
41
|
};
|
45
42
|
export type {
|
46
43
|
StartFlow,
|
47
|
-
|
44
|
+
GetIssuerConfig,
|
48
45
|
StartUserAuthorization,
|
49
46
|
BuildAuthorizationUrl,
|
50
47
|
CompleteUserAuthorizationWithQueryMode,
|
@@ -6,7 +6,7 @@ export type TokenResponse = z.infer<typeof TokenResponse>;
|
|
6
6
|
|
7
7
|
export const TokenResponse = z.object({
|
8
8
|
access_token: z.string(),
|
9
|
-
authorization_details:
|
9
|
+
authorization_details: AuthorizationDetail,
|
10
10
|
c_nonce: z.string(),
|
11
11
|
c_nonce_expires_in: z.number(),
|
12
12
|
expires_in: z.number(),
|
@@ -29,8 +29,14 @@ export type StartFlow<T extends Array<unknown> = []> = (...args: T) => {
|
|
29
29
|
* @throws If the provided qr code fails to be decoded
|
30
30
|
*/
|
31
31
|
export const startFlowFromQR: StartFlow<[string]> = (qrcode) => {
|
32
|
-
|
33
|
-
|
32
|
+
let decodedUrl: URL;
|
33
|
+
try {
|
34
|
+
const decoded = decodeBase64(qrcode);
|
35
|
+
decodedUrl = new URL(decoded);
|
36
|
+
} catch (error) {
|
37
|
+
throw new AuthRequestDecodeError("Failed to decode QR code: ", qrcode);
|
38
|
+
}
|
39
|
+
|
34
40
|
const protocol = decodedUrl.protocol;
|
35
41
|
const resource = decodedUrl.hostname;
|
36
42
|
const requestURI = decodedUrl.searchParams.get("request_uri");
|