@pagopa/io-react-native-wallet 1.7.0 → 2.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -1
- package/lib/commonjs/client/generated/wallet-provider.js +49 -20
- package/lib/commonjs/client/generated/wallet-provider.js.map +1 -1
- package/lib/commonjs/credential/index.js +5 -1
- package/lib/commonjs/credential/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js +27 -0
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js +25 -16
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +30 -18
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/05-authorize-access.js +17 -12
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +36 -29
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +27 -207
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/README.md +23 -20
- package/lib/commonjs/credential/issuance/const.js +1 -1
- package/lib/commonjs/credential/issuance/const.js.map +1 -1
- package/lib/commonjs/credential/issuance/index.js +3 -3
- package/lib/commonjs/credential/issuance/index.js.map +1 -1
- package/lib/commonjs/credential/presentation/01-start-flow.js +14 -15
- package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js +6 -4
- package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
- package/lib/commonjs/credential/presentation/03-get-request-object.js +34 -7
- package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js +4 -126
- package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
- package/lib/commonjs/credential/presentation/05-verify-request-object.js +80 -25
- package/lib/commonjs/credential/presentation/05-verify-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js +6 -30
- package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +97 -117
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +86 -191
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js +112 -176
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/commonjs/credential/presentation/README.md +74 -79
- package/lib/commonjs/credential/presentation/errors.js +42 -21
- package/lib/commonjs/credential/presentation/errors.js.map +1 -1
- package/lib/commonjs/credential/presentation/index.js +13 -13
- package/lib/commonjs/credential/presentation/index.js.map +1 -1
- package/lib/commonjs/credential/presentation/types.js +53 -29
- package/lib/commonjs/credential/presentation/types.js.map +1 -1
- package/lib/commonjs/credential/status/01-start-flow.js +2 -0
- package/lib/commonjs/credential/status/01-start-flow.js.map +1 -0
- package/lib/commonjs/credential/status/02-status-attestation.js +73 -0
- package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -0
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +55 -0
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
- package/lib/commonjs/credential/status/README.md +67 -0
- package/lib/commonjs/credential/status/index.js +27 -0
- package/lib/commonjs/credential/status/index.js.map +1 -0
- package/lib/commonjs/credential/status/types.js +48 -0
- package/lib/commonjs/credential/status/types.js.map +1 -0
- package/lib/commonjs/credential/trustmark/README.md +62 -0
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js +86 -0
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js.map +1 -0
- package/lib/commonjs/credential/trustmark/index.js +13 -0
- package/lib/commonjs/credential/trustmark/index.js.map +1 -0
- package/lib/commonjs/index.js +5 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/pid/sd-jwt/types.js +18 -2
- package/lib/commonjs/pid/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/index.test.js +22 -34
- package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/types.test.js +11 -23
- package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/index.js +1 -7
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/commonjs/sd-jwt/types.js +5 -21
- package/lib/commonjs/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/{entity/trust → trust}/chain.js +49 -55
- package/lib/commonjs/trust/chain.js.map +1 -0
- package/lib/commonjs/trust/errors.js +110 -0
- package/lib/commonjs/trust/errors.js.map +1 -0
- package/lib/commonjs/trust/index.js +282 -0
- package/lib/commonjs/trust/index.js.map +1 -0
- package/lib/commonjs/{entity/trust → trust}/types.js +27 -47
- package/lib/commonjs/trust/types.js.map +1 -0
- package/lib/commonjs/trust/utils.js +41 -0
- package/lib/commonjs/trust/utils.js.map +1 -0
- package/lib/commonjs/utils/crypto.js +5 -112
- package/lib/commonjs/utils/crypto.js.map +1 -1
- package/lib/commonjs/utils/decoder.js +2 -0
- package/lib/commonjs/utils/decoder.js.map +1 -1
- package/lib/commonjs/utils/error-codes.js +22 -2
- package/lib/commonjs/utils/error-codes.js.map +1 -1
- package/lib/commonjs/utils/errors.js +72 -4
- package/lib/commonjs/utils/errors.js.map +1 -1
- package/lib/commonjs/utils/logging.js +68 -0
- package/lib/commonjs/utils/logging.js.map +1 -0
- package/lib/commonjs/utils/misc.js +2 -0
- package/lib/commonjs/utils/misc.js.map +1 -1
- package/lib/commonjs/utils/par.js +17 -10
- package/lib/commonjs/utils/par.js.map +1 -1
- package/lib/commonjs/utils/string.js +1 -12
- package/lib/commonjs/utils/string.js.map +1 -1
- package/lib/commonjs/wallet-instance/index.js +14 -0
- package/lib/commonjs/wallet-instance/index.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/README.md +8 -3
- package/lib/commonjs/wallet-instance-attestation/issuing.js +15 -8
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/types.js +16 -20
- package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
- package/lib/module/client/generated/wallet-provider.js +40 -15
- package/lib/module/client/generated/wallet-provider.js.map +1 -1
- package/lib/module/credential/index.js +3 -1
- package/lib/module/credential/index.js.map +1 -1
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +20 -0
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
- package/lib/module/credential/issuance/03-start-user-authorization.js +25 -16
- package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js +30 -18
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/05-authorize-access.js +17 -11
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +36 -28
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +27 -205
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/issuance/README.md +23 -20
- package/lib/module/credential/issuance/const.js +1 -1
- package/lib/module/credential/issuance/const.js.map +1 -1
- package/lib/module/credential/issuance/index.js +2 -2
- package/lib/module/credential/issuance/index.js.map +1 -1
- package/lib/module/credential/presentation/01-start-flow.js +14 -15
- package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/module/credential/presentation/02-evaluate-rp-trust.js +5 -3
- package/lib/module/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
- package/lib/module/credential/presentation/03-get-request-object.js +34 -7
- package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/module/credential/presentation/04-retrieve-rp-jwks.js +2 -124
- package/lib/module/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
- package/lib/module/credential/presentation/05-verify-request-object.js +78 -23
- package/lib/module/credential/presentation/05-verify-request-object.js.map +1 -1
- package/lib/module/credential/presentation/06-fetch-presentation-definition.js +6 -30
- package/lib/module/credential/presentation/06-fetch-presentation-definition.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js +97 -118
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +83 -186
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/module/credential/presentation/08-send-authorization-response.js +107 -170
- package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/module/credential/presentation/README.md +74 -79
- package/lib/module/credential/presentation/errors.js +30 -17
- package/lib/module/credential/presentation/errors.js.map +1 -1
- package/lib/module/credential/presentation/index.js +6 -6
- package/lib/module/credential/presentation/index.js.map +1 -1
- package/lib/module/credential/presentation/types.js +49 -27
- package/lib/module/credential/presentation/types.js.map +1 -1
- package/lib/module/credential/status/01-start-flow.js +2 -0
- package/lib/module/credential/status/01-start-flow.js.map +1 -0
- package/lib/module/credential/status/02-status-attestation.js +66 -0
- package/lib/module/credential/status/02-status-attestation.js.map +1 -0
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +49 -0
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
- package/lib/module/credential/status/README.md +67 -0
- package/lib/module/credential/status/index.js +5 -0
- package/lib/module/credential/status/index.js.map +1 -0
- package/lib/module/credential/status/types.js +40 -0
- package/lib/module/credential/status/types.js.map +1 -0
- package/lib/module/credential/trustmark/README.md +62 -0
- package/lib/module/credential/trustmark/get-credential-trustmark.js +77 -0
- package/lib/module/credential/trustmark/get-credential-trustmark.js.map +1 -0
- package/lib/module/credential/trustmark/index.js +3 -0
- package/lib/module/credential/trustmark/index.js.map +1 -0
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/pid/sd-jwt/types.js +16 -1
- package/lib/module/pid/sd-jwt/types.js.map +1 -1
- package/lib/module/sd-jwt/__test__/index.test.js +22 -34
- package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/module/sd-jwt/__test__/types.test.js +11 -23
- package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/module/sd-jwt/index.js +1 -7
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/module/sd-jwt/types.js +4 -19
- package/lib/module/sd-jwt/types.js.map +1 -1
- package/lib/module/trust/chain.js +108 -0
- package/lib/module/trust/chain.js.map +1 -0
- package/lib/module/trust/errors.js +94 -0
- package/lib/module/trust/errors.js.map +1 -0
- package/lib/module/trust/index.js +263 -0
- package/lib/module/trust/index.js.map +1 -0
- package/lib/module/{entity/trust → trust}/types.js +25 -46
- package/lib/module/trust/types.js.map +1 -0
- package/lib/module/trust/utils.js +33 -0
- package/lib/module/trust/utils.js.map +1 -0
- package/lib/module/utils/crypto.js +4 -107
- package/lib/module/utils/crypto.js.map +1 -1
- package/lib/module/utils/decoder.js +3 -0
- package/lib/module/utils/decoder.js.map +1 -1
- package/lib/module/utils/error-codes.js +20 -1
- package/lib/module/utils/error-codes.js.map +1 -1
- package/lib/module/utils/errors.js +61 -4
- package/lib/module/utils/errors.js.map +1 -1
- package/lib/module/utils/logging.js +62 -0
- package/lib/module/utils/logging.js.map +1 -0
- package/lib/module/utils/misc.js +2 -0
- package/lib/module/utils/misc.js.map +1 -1
- package/lib/module/utils/par.js +17 -9
- package/lib/module/utils/par.js.map +1 -1
- package/lib/module/utils/string.js +0 -10
- package/lib/module/utils/string.js.map +1 -1
- package/lib/module/wallet-instance/index.js +13 -0
- package/lib/module/wallet-instance/index.js.map +1 -1
- package/lib/module/wallet-instance-attestation/README.md +8 -3
- package/lib/module/wallet-instance-attestation/index.js +2 -2
- package/lib/module/wallet-instance-attestation/index.js.map +1 -1
- package/lib/module/wallet-instance-attestation/issuing.js +16 -9
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/wallet-instance-attestation/types.js +14 -18
- package/lib/module/wallet-instance-attestation/types.js.map +1 -1
- package/lib/typescript/client/generated/wallet-provider.d.ts +206 -51
- package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
- package/lib/typescript/credential/index.d.ts +3 -1
- 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-evaluate-issuer-trust.d.ts +19 -0
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.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 +9 -9
- 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 +4 -4
- 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 -15
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/const.d.ts +1 -1
- package/lib/typescript/credential/issuance/const.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 +8 -3
- package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/01-start-flow.d.ts +28 -9
- package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts +2 -1
- package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts +7 -5
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts +4 -30
- package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts +17 -4
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts +4 -9
- package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +13 -12
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +40 -42
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +30 -43
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/errors.d.ts +25 -10
- package/lib/typescript/credential/presentation/errors.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/index.d.ts +7 -8
- package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/types.d.ts +137 -307
- package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
- package/lib/typescript/credential/status/01-start-flow.d.ts +10 -0
- package/lib/typescript/credential/status/01-start-flow.d.ts.map +1 -0
- package/lib/typescript/credential/status/02-status-attestation.d.ts +19 -0
- package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -0
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts +24 -0
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +1 -0
- package/lib/typescript/credential/status/index.d.ts +7 -0
- package/lib/typescript/credential/status/index.d.ts.map +1 -0
- package/lib/typescript/credential/status/types.d.ts +305 -0
- package/lib/typescript/credential/status/types.d.ts.map +1 -0
- package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts +52 -0
- package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts.map +1 -0
- package/lib/typescript/credential/trustmark/index.d.ts +4 -0
- package/lib/typescript/credential/trustmark/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +3 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/pid/sd-jwt/types.d.ts +103 -25
- package/lib/typescript/pid/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/index.d.ts +30 -82
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/types.d.ts +29 -134
- package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/{entity/trust → trust}/chain.d.ts +5 -10
- package/lib/typescript/trust/chain.d.ts.map +1 -0
- package/lib/typescript/trust/errors.d.ts +80 -0
- package/lib/typescript/trust/errors.d.ts.map +1 -0
- package/lib/typescript/{entity/trust → trust}/index.d.ts +211 -186
- package/lib/typescript/trust/index.d.ts.map +1 -0
- package/lib/typescript/{entity/trust → trust}/types.d.ts +1533 -1120
- package/lib/typescript/{entity/trust → trust}/types.d.ts.map +1 -1
- package/lib/typescript/trust/utils.d.ts +12 -0
- package/lib/typescript/trust/utils.d.ts.map +1 -0
- package/lib/typescript/utils/crypto.d.ts +0 -32
- package/lib/typescript/utils/crypto.d.ts.map +1 -1
- package/lib/typescript/utils/decoder.d.ts.map +1 -1
- package/lib/typescript/utils/error-codes.d.ts +20 -0
- package/lib/typescript/utils/error-codes.d.ts.map +1 -1
- package/lib/typescript/utils/errors.d.ts +55 -10
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/logging.d.ts +35 -0
- package/lib/typescript/utils/logging.d.ts.map +1 -0
- package/lib/typescript/utils/misc.d.ts.map +1 -1
- package/lib/typescript/utils/par.d.ts +8 -1
- package/lib/typescript/utils/par.d.ts.map +1 -1
- package/lib/typescript/utils/string.d.ts +0 -7
- package/lib/typescript/utils/string.d.ts.map +1 -1
- package/lib/typescript/wallet-instance/index.d.ts +8 -0
- package/lib/typescript/wallet-instance/index.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/index.d.ts +1 -2
- package/lib/typescript/wallet-instance-attestation/index.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts +4 -2
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/types.d.ts +78 -120
- package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
- package/package.json +8 -9
- package/src/client/generated/wallet-provider.ts +52 -17
- package/src/credential/index.ts +4 -1
- package/src/credential/issuance/01-start-flow.ts +1 -1
- package/src/credential/issuance/02-evaluate-issuer-trust.ts +32 -0
- package/src/credential/issuance/03-start-user-authorization.ts +48 -22
- package/src/credential/issuance/04-complete-user-authorization.ts +74 -18
- package/src/credential/issuance/05-authorize-access.ts +29 -11
- package/src/credential/issuance/06-obtain-credential.ts +61 -36
- package/src/credential/issuance/07-verify-and-parse-credential.ts +37 -264
- package/src/credential/issuance/README.md +23 -20
- package/src/credential/issuance/const.ts +1 -1
- package/src/credential/issuance/index.ts +6 -3
- package/src/credential/presentation/01-start-flow.ts +19 -22
- package/src/credential/presentation/02-evaluate-rp-trust.ts +5 -4
- package/src/credential/presentation/03-get-request-object.ts +36 -8
- package/src/credential/presentation/04-retrieve-rp-jwks.ts +6 -148
- package/src/credential/presentation/05-verify-request-object.ts +115 -30
- package/src/credential/presentation/06-fetch-presentation-definition.ts +5 -35
- package/src/credential/presentation/07-evaluate-dcql-query.ts +132 -161
- package/src/credential/presentation/07-evaluate-input-descriptor.ts +136 -254
- package/src/credential/presentation/08-send-authorization-response.ts +178 -260
- package/src/credential/presentation/README.md +74 -79
- package/src/credential/presentation/errors.ts +38 -15
- package/src/credential/presentation/index.ts +18 -19
- package/src/credential/presentation/types.ts +67 -64
- package/src/credential/status/01-start-flow.ts +9 -0
- package/src/credential/status/02-status-attestation.ts +105 -0
- package/src/credential/status/03-verify-and-parse-status-attestation.ts +70 -0
- package/src/credential/status/README.md +67 -0
- package/src/credential/status/index.ts +22 -0
- package/src/credential/status/types.ts +43 -0
- package/src/credential/trustmark/README.md +62 -0
- package/src/credential/trustmark/get-credential-trustmark.ts +139 -0
- package/src/credential/trustmark/index.ts +8 -0
- package/src/index.ts +4 -0
- package/src/pid/sd-jwt/types.ts +18 -1
- package/src/sd-jwt/__test__/index.test.ts +36 -55
- package/src/sd-jwt/__test__/types.test.ts +16 -29
- package/src/sd-jwt/index.ts +1 -5
- package/src/sd-jwt/types.ts +2 -19
- package/src/trust/chain.ts +151 -0
- package/src/trust/errors.ts +105 -0
- package/src/{entity/trust → trust}/index.ts +198 -23
- package/src/{entity/trust → trust}/types.ts +24 -37
- package/src/trust/utils.ts +35 -0
- package/src/utils/crypto.ts +4 -106
- package/src/utils/decoder.ts +6 -1
- package/src/utils/error-codes.ts +23 -0
- package/src/utils/errors.ts +119 -15
- package/src/utils/logging.ts +68 -0
- package/src/utils/misc.ts +5 -0
- package/src/utils/par.ts +19 -6
- package/src/utils/string.ts +0 -10
- package/src/wallet-instance/index.ts +30 -1
- package/src/wallet-instance-attestation/README.md +8 -3
- package/src/wallet-instance-attestation/index.ts +2 -2
- package/src/wallet-instance-attestation/issuing.ts +33 -12
- package/src/wallet-instance-attestation/types.ts +18 -22
- package/lib/commonjs/credential/issuance/02-get-issuer-config.js +0 -48
- package/lib/commonjs/credential/issuance/02-get-issuer-config.js.map +0 -1
- package/lib/commonjs/entity/openid-connect/issuer/index.js +0 -25
- package/lib/commonjs/entity/openid-connect/issuer/index.js.map +0 -1
- package/lib/commonjs/entity/openid-connect/issuer/types.js +0 -64
- package/lib/commonjs/entity/openid-connect/issuer/types.js.map +0 -1
- package/lib/commonjs/entity/trust/chain.js.map +0 -1
- package/lib/commonjs/entity/trust/index.js +0 -148
- package/lib/commonjs/entity/trust/index.js.map +0 -1
- package/lib/commonjs/entity/trust/types.js.map +0 -1
- package/lib/commonjs/mdoc/converters.js +0 -26
- package/lib/commonjs/mdoc/converters.js.map +0 -1
- package/lib/commonjs/mdoc/index.js +0 -68
- package/lib/commonjs/mdoc/index.js.map +0 -1
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -469
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -90
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
- package/lib/module/credential/issuance/02-get-issuer-config.js +0 -42
- package/lib/module/credential/issuance/02-get-issuer-config.js.map +0 -1
- package/lib/module/entity/openid-connect/issuer/index.js +0 -20
- package/lib/module/entity/openid-connect/issuer/index.js.map +0 -1
- package/lib/module/entity/openid-connect/issuer/types.js +0 -48
- package/lib/module/entity/openid-connect/issuer/types.js.map +0 -1
- package/lib/module/entity/trust/chain.js +0 -113
- package/lib/module/entity/trust/chain.js.map +0 -1
- package/lib/module/entity/trust/index.js +0 -131
- package/lib/module/entity/trust/index.js.map +0 -1
- package/lib/module/entity/trust/types.js.map +0 -1
- package/lib/module/mdoc/converters.js +0 -20
- package/lib/module/mdoc/converters.js.map +0 -1
- package/lib/module/mdoc/index.js +0 -60
- package/lib/module/mdoc/index.js.map +0 -1
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -462
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -83
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
- package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts +0 -32
- package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts.map +0 -1
- package/lib/typescript/entity/openid-connect/issuer/index.d.ts +0 -12
- package/lib/typescript/entity/openid-connect/issuer/index.d.ts.map +0 -1
- package/lib/typescript/entity/openid-connect/issuer/types.d.ts +0 -777
- package/lib/typescript/entity/openid-connect/issuer/types.d.ts.map +0 -1
- package/lib/typescript/entity/trust/chain.d.ts.map +0 -1
- package/lib/typescript/entity/trust/index.d.ts.map +0 -1
- package/lib/typescript/mdoc/converters.d.ts +0 -8
- package/lib/typescript/mdoc/converters.d.ts.map +0 -1
- package/lib/typescript/mdoc/index.d.ts +0 -10
- package/lib/typescript/mdoc/index.d.ts.map +0 -1
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts +0 -3
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts.map +0 -1
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts +0 -42
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts.map +0 -1
- package/src/credential/issuance/02-get-issuer-config.ts +0 -67
- package/src/entity/openid-connect/issuer/index.ts +0 -27
- package/src/entity/openid-connect/issuer/types.ts +0 -76
- package/src/entity/trust/chain.ts +0 -154
- package/src/mdoc/converters.ts +0 -26
- package/src/mdoc/index.ts +0 -95
- package/src/utils/credential/issuance/07-verify-and-parse-credentials-inputs.ts +0 -615
- package/src/utils/credential/issuance/07-verify-and-parse-credentials-utils.ts +0 -171
@@ -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 { EvaluateIssuerTrust } from "./02-evaluate-issuer-trust";
|
11
11
|
import {
|
12
12
|
decode,
|
13
13
|
encodeBase64,
|
@@ -15,13 +15,14 @@ import {
|
|
15
15
|
type CryptoContext,
|
16
16
|
} from "@pagopa/io-react-native-jwt";
|
17
17
|
import { RequestObject } from "../presentation/types";
|
18
|
-
import
|
18
|
+
import { v4 as uuidv4 } from "uuid";
|
19
19
|
import { ResponseUriResultShape } from "./types";
|
20
20
|
import { getJwtFromFormPost } from "../../utils/decoder";
|
21
21
|
import { AuthorizationError, AuthorizationIdpError } from "./errors";
|
22
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
22
23
|
|
23
24
|
/**
|
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
|
25
|
+
* 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.
|
25
26
|
*/
|
26
27
|
export type CompleteUserAuthorizationWithQueryMode = (
|
27
28
|
authRedirectUrl: string
|
@@ -41,14 +42,14 @@ export type CompleteUserAuthorizationWithFormPostJwtMode = (
|
|
41
42
|
export type GetRequestedCredentialToBePresented = (
|
42
43
|
issuerRequestUri: Out<StartUserAuthorization>["issuerRequestUri"],
|
43
44
|
clientId: Out<StartUserAuthorization>["clientId"],
|
44
|
-
issuerConf: Out<
|
45
|
+
issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
|
45
46
|
appFetch?: GlobalFetch["fetch"]
|
46
47
|
) => Promise<RequestObject>;
|
47
48
|
|
48
49
|
export type BuildAuthorizationUrl = (
|
49
50
|
issuerRequestUri: Out<StartUserAuthorization>["issuerRequestUri"],
|
50
51
|
clientId: Out<StartUserAuthorization>["clientId"],
|
51
|
-
issuerConf: Out<
|
52
|
+
issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
|
52
53
|
idpHint?: string
|
53
54
|
) => Promise<{
|
54
55
|
authUrl: string;
|
@@ -59,8 +60,8 @@ export type BuildAuthorizationUrl = (
|
|
59
60
|
* Builds the authorization URL to which the end user should be redirected to continue the authentication flow.
|
60
61
|
* @param issuerRequestUri the URI of the issuer where the request is sent
|
61
62
|
* @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
|
63
|
-
* @param idpHint Unique identifier of the IDP selected by the user
|
63
|
+
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
64
|
+
* @param idpHint Unique identifier of the IDP selected by the user (optional)
|
64
65
|
* @returns An object containing the authorization URL
|
65
66
|
*/
|
66
67
|
export const buildAuthorizationUrl: BuildAuthorizationUrl = async (
|
@@ -69,14 +70,18 @@ export const buildAuthorizationUrl: BuildAuthorizationUrl = async (
|
|
69
70
|
issuerConf,
|
70
71
|
idpHint
|
71
72
|
) => {
|
72
|
-
const authzRequestEndpoint =
|
73
|
+
const authzRequestEndpoint =
|
74
|
+
issuerConf.oauth_authorization_server.authorization_endpoint;
|
73
75
|
|
74
76
|
const params = new URLSearchParams({
|
75
77
|
client_id: clientId,
|
76
78
|
request_uri: issuerRequestUri,
|
77
|
-
...(idpHint && { idphint: idpHint }),
|
78
79
|
});
|
79
80
|
|
81
|
+
if (idpHint) {
|
82
|
+
params.append("idphint", idpHint);
|
83
|
+
}
|
84
|
+
|
80
85
|
const authUrl = `${authzRequestEndpoint}?${params}`;
|
81
86
|
|
82
87
|
return { authUrl };
|
@@ -84,13 +89,17 @@ export const buildAuthorizationUrl: BuildAuthorizationUrl = async (
|
|
84
89
|
|
85
90
|
/**
|
86
91
|
* WARNING: This function must be called after obtaining the authorization redirect URL from the webviews (SPID and CIE L3) or browser for CIEID.
|
87
|
-
* Complete User authorization via strong identification when the response mode is "query" and the request credential is a
|
92
|
+
* Complete User authorization via strong identification when the response mode is "query" and the request credential is a PersonIdentificationData.
|
88
93
|
* This function parses the authorization redirect URL to extract the authorization response.
|
89
94
|
* @param authRedirectUrl The URL to which the end user should be redirected to start the authentication flow
|
90
95
|
* @returns the authorization response which contains code, state and iss
|
91
96
|
*/
|
92
97
|
export const completeUserAuthorizationWithQueryMode: CompleteUserAuthorizationWithQueryMode =
|
93
98
|
async (authRedirectUrl) => {
|
99
|
+
Logger.log(
|
100
|
+
LogLevel.DEBUG,
|
101
|
+
`The requeste credential is a PersonIdentificationData, completing the user authorization with query mode`
|
102
|
+
);
|
94
103
|
const query = parseUrl(authRedirectUrl).query;
|
95
104
|
|
96
105
|
return parseAuthorizationResponse(query);
|
@@ -103,19 +112,29 @@ export const completeUserAuthorizationWithQueryMode: CompleteUserAuthorizationWi
|
|
103
112
|
* The information is obtained by performing a GET request to the authorization endpoint with request_uri and client_id parameters.
|
104
113
|
* @param issuerRequestUri the URI of the issuer where the request is sent
|
105
114
|
* @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
|
106
|
-
* @param issuerConf The issuer configuration returned by {@link
|
115
|
+
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
107
116
|
* @param appFetch (optional) fetch api implementation. Default: built-in fetch
|
108
117
|
* @throws {ValidationFailed} if an error while validating the response
|
109
118
|
* @returns the request object which contains the credential to be presented in order to obtain the requested credential
|
110
119
|
*/
|
111
120
|
export const getRequestedCredentialToBePresented: GetRequestedCredentialToBePresented =
|
112
121
|
async (issuerRequestUri, clientId, issuerConf, appFetch = fetch) => {
|
113
|
-
|
122
|
+
Logger.log(
|
123
|
+
LogLevel.DEBUG,
|
124
|
+
`The requeste credential is not a PersonIdentificationData, requesting the credential to be presented`
|
125
|
+
);
|
126
|
+
const authzRequestEndpoint =
|
127
|
+
issuerConf.oauth_authorization_server.authorization_endpoint;
|
114
128
|
const params = new URLSearchParams({
|
115
129
|
client_id: clientId,
|
116
130
|
request_uri: issuerRequestUri,
|
117
131
|
});
|
118
132
|
|
133
|
+
Logger.log(
|
134
|
+
LogLevel.DEBUG,
|
135
|
+
`Requesting the request object to ${authzRequestEndpoint}?${params.toString()}`
|
136
|
+
);
|
137
|
+
|
119
138
|
const requestObject = await appFetch(
|
120
139
|
`${authzRequestEndpoint}?${params.toString()}`,
|
121
140
|
{ method: "GET" }
|
@@ -126,6 +145,10 @@ export const getRequestedCredentialToBePresented: GetRequestedCredentialToBePres
|
|
126
145
|
.then((reqObj) => RequestObject.safeParse(reqObj.payload));
|
127
146
|
|
128
147
|
if (!requestObject.success) {
|
148
|
+
Logger.log(
|
149
|
+
LogLevel.ERROR,
|
150
|
+
`Error while validating the response object: ${requestObject.error.message}`
|
151
|
+
);
|
129
152
|
throw new ValidationFailed({
|
130
153
|
message: "Request Object validation failed",
|
131
154
|
reason: requestObject.error.message,
|
@@ -141,7 +164,7 @@ export const getRequestedCredentialToBePresented: GetRequestedCredentialToBePres
|
|
141
164
|
* The information is obtained by performing a GET request to the authorization endpoint with request_uri and client_id parameters.
|
142
165
|
* @param issuerRequestUri the URI of the issuer where the request is sent
|
143
166
|
* @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
|
144
|
-
* @param issuerConf The issuer configuration returned by {@link
|
167
|
+
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
145
168
|
* @param context.walletInstanceAccestation the Wallet Instance's attestation to be presented
|
146
169
|
* @param context.pid the PID to be presented
|
147
170
|
* @param context.wiaCryptoContext The Wallet Instance's crypto context associated with the walletInstanceAttestation parameter
|
@@ -152,6 +175,11 @@ export const getRequestedCredentialToBePresented: GetRequestedCredentialToBePres
|
|
152
175
|
*/
|
153
176
|
export const completeUserAuthorizationWithFormPostJwtMode: CompleteUserAuthorizationWithFormPostJwtMode =
|
154
177
|
async (requestObject, ctx) => {
|
178
|
+
Logger.log(
|
179
|
+
LogLevel.DEBUG,
|
180
|
+
`The requeste credential is not a PersonIdentificationData, completing the user authorization with form_post.jwt mode`
|
181
|
+
);
|
182
|
+
|
155
183
|
const {
|
156
184
|
wiaCryptoContext,
|
157
185
|
pidCryptoContext,
|
@@ -167,7 +195,7 @@ export const completeUserAuthorizationWithFormPostJwtMode: CompleteUserAuthoriza
|
|
167
195
|
})
|
168
196
|
.setPayload({
|
169
197
|
vp: walletInstanceAttestation,
|
170
|
-
jti:
|
198
|
+
jti: uuidv4().toString(),
|
171
199
|
nonce: requestObject.nonce,
|
172
200
|
})
|
173
201
|
.setIssuedAt()
|
@@ -182,7 +210,7 @@ export const completeUserAuthorizationWithFormPostJwtMode: CompleteUserAuthoriza
|
|
182
210
|
})
|
183
211
|
.setPayload({
|
184
212
|
vp: pid,
|
185
|
-
jti:
|
213
|
+
jti: uuidv4().toString(),
|
186
214
|
nonce: requestObject.nonce,
|
187
215
|
})
|
188
216
|
.setIssuedAt()
|
@@ -190,15 +218,20 @@ export const completeUserAuthorizationWithFormPostJwtMode: CompleteUserAuthoriza
|
|
190
218
|
.setAudience(requestObject.response_uri)
|
191
219
|
.sign();
|
192
220
|
|
221
|
+
Logger.log(
|
222
|
+
LogLevel.DEBUG,
|
223
|
+
`Wallet instance attestation JWT token: ${wiaWpToken}`
|
224
|
+
);
|
225
|
+
|
193
226
|
/* The path parameter refers to the vp_token variable of the authzResponsePayload and must point to the plain credential which
|
194
227
|
* is cointaned in the `vp` property of the signed jwt token payload
|
195
228
|
*/
|
196
229
|
const presentationSubmission = {
|
197
|
-
definition_id: `${
|
198
|
-
id: `${
|
230
|
+
definition_id: `${uuidv4()}`,
|
231
|
+
id: `${uuidv4()}`,
|
199
232
|
descriptor_map: [
|
200
233
|
{
|
201
|
-
id: "
|
234
|
+
id: "PersonIdentificationData",
|
202
235
|
path: "$.vp_token[0].vp",
|
203
236
|
format: "vc+sd-jwt",
|
204
237
|
},
|
@@ -210,6 +243,11 @@ export const completeUserAuthorizationWithFormPostJwtMode: CompleteUserAuthoriza
|
|
210
243
|
],
|
211
244
|
};
|
212
245
|
|
246
|
+
Logger.log(
|
247
|
+
LogLevel.DEBUG,
|
248
|
+
`Presentation submission: ${JSON.stringify(presentationSubmission)}`
|
249
|
+
);
|
250
|
+
|
213
251
|
const authzResponsePayload = encodeBase64(
|
214
252
|
JSON.stringify({
|
215
253
|
state: requestObject.state,
|
@@ -218,6 +256,11 @@ export const completeUserAuthorizationWithFormPostJwtMode: CompleteUserAuthoriza
|
|
218
256
|
})
|
219
257
|
);
|
220
258
|
|
259
|
+
Logger.log(
|
260
|
+
LogLevel.DEBUG,
|
261
|
+
`Authz response payload: ${authzResponsePayload}`
|
262
|
+
);
|
263
|
+
|
221
264
|
// Note: according to the spec, the response should be encrypted with the public key of the RP however this is not implemented yet
|
222
265
|
// https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#name-signed-and-encrypted-response
|
223
266
|
// const rsaPublicJwk = chooseRSAPublicKeyToEncrypt(rpConf);
|
@@ -230,6 +273,7 @@ export const completeUserAuthorizationWithFormPostJwtMode: CompleteUserAuthoriza
|
|
230
273
|
const body = new URLSearchParams({
|
231
274
|
response: authzResponsePayload,
|
232
275
|
}).toString();
|
276
|
+
|
233
277
|
const resUriRes = await appFetch(requestObject.response_uri, {
|
234
278
|
method: "POST",
|
235
279
|
headers: {
|
@@ -242,6 +286,10 @@ export const completeUserAuthorizationWithFormPostJwtMode: CompleteUserAuthoriza
|
|
242
286
|
|
243
287
|
const responseUri = ResponseUriResultShape.safeParse(resUriRes);
|
244
288
|
if (!responseUri.success) {
|
289
|
+
Logger.log(
|
290
|
+
LogLevel.ERROR,
|
291
|
+
`Error while validating the response uri: ${responseUri.error.message}`
|
292
|
+
);
|
245
293
|
throw new ValidationFailed({
|
246
294
|
message: "Response Uri validation failed",
|
247
295
|
reason: responseUri.error.message,
|
@@ -269,8 +317,16 @@ export const parseAuthorizationResponse = (
|
|
269
317
|
if (!authResParsed.success) {
|
270
318
|
const authErr = AuthorizationErrorShape.safeParse(authRes);
|
271
319
|
if (!authErr.success) {
|
320
|
+
Logger.log(
|
321
|
+
LogLevel.ERROR,
|
322
|
+
`Error while parsing the authorization response: ${authResParsed.error.message}`
|
323
|
+
);
|
272
324
|
throw new AuthorizationError(authResParsed.error.message); // an error occured while parsing the result and the error
|
273
325
|
}
|
326
|
+
Logger.log(
|
327
|
+
LogLevel.ERROR,
|
328
|
+
`Error while authorizating with the idp: ${JSON.stringify(authErr)}`
|
329
|
+
);
|
274
330
|
throw new AuthorizationIdpError(
|
275
331
|
authErr.data.error,
|
276
332
|
authErr.data.error_description
|
@@ -1,17 +1,19 @@
|
|
1
1
|
import { hasStatusOrThrow, type Out } from "../../utils/misc";
|
2
|
-
import type {
|
2
|
+
import type { EvaluateIssuerTrust } from "./02-evaluate-issuer-trust";
|
3
3
|
import type { StartUserAuthorization } from "./03-start-user-authorization";
|
4
4
|
import { createDPopToken } from "../../utils/dpop";
|
5
|
-
import
|
5
|
+
import { v4 as uuidv4 } from "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";
|
9
10
|
import { TokenResponse } from "./types";
|
10
11
|
import { IssuerResponseError, ValidationFailed } from "../../utils/errors";
|
11
12
|
import type { CompleteUserAuthorizationWithQueryMode } from "./04-complete-user-authorization";
|
13
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
12
14
|
|
13
15
|
export type AuthorizeAccess = (
|
14
|
-
issuerConf: Out<
|
16
|
+
issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
|
15
17
|
code: Out<CompleteUserAuthorizationWithQueryMode>["code"],
|
16
18
|
redirectUri: string,
|
17
19
|
clientId: Out<StartUserAuthorization>["clientId"],
|
@@ -29,7 +31,7 @@ export type AuthorizeAccess = (
|
|
29
31
|
* for requesting the issuance of an access token bound to the public key of the Wallet Instance contained within the DPoP.
|
30
32
|
* This enables the Wallet Instance to request a digital credential.
|
31
33
|
* The DPoP Proof JWT is generated according to the section 4.3 of the DPoP RFC 9449 specification.
|
32
|
-
* @param issuerConf The issuer configuration returned by {@link
|
34
|
+
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
33
35
|
* @param code The authorization code returned by {@link completeUserAuthorizationWithQueryMode} or {@link completeUserAuthorizationWithFormPost}
|
34
36
|
* @param redirectUri The redirect URI which is the custom URL scheme that the Wallet Instance is registered to handle
|
35
37
|
* @param clientId The client id returned by {@link startUserAuthorization}
|
@@ -57,48 +59,59 @@ export const authorizeAccess: AuthorizeAccess = async (
|
|
57
59
|
dPopCryptoContext,
|
58
60
|
} = context;
|
59
61
|
|
60
|
-
const parEndpoint =
|
62
|
+
const parEndpoint =
|
63
|
+
issuerConf.oauth_authorization_server.pushed_authorization_request_endpoint;
|
61
64
|
const parUrl = new URL(parEndpoint);
|
62
65
|
const aud = `${parUrl.protocol}//${parUrl.hostname}`;
|
63
66
|
const iss = WalletInstanceAttestation.decode(walletInstanceAttestation)
|
64
67
|
.payload.cnf.jwk.kid;
|
65
68
|
|
66
|
-
const tokenUrl = issuerConf.token_endpoint;
|
69
|
+
const tokenUrl = issuerConf.oauth_authorization_server.token_endpoint;
|
67
70
|
|
68
71
|
const tokenRequestSignedDPop = await createDPopToken(
|
69
72
|
{
|
70
73
|
htm: "POST",
|
71
74
|
htu: tokenUrl,
|
72
|
-
jti: `${
|
75
|
+
jti: `${uuidv4()}`,
|
73
76
|
},
|
74
77
|
dPopCryptoContext
|
75
78
|
);
|
76
79
|
|
80
|
+
Logger.log(LogLevel.DEBUG, `Token request DPoP: ${tokenRequestSignedDPop}`);
|
81
|
+
|
77
82
|
const signedWiaPoP = await createPopToken(
|
78
83
|
{
|
79
|
-
jti: `${
|
84
|
+
jti: `${uuidv4()}`,
|
80
85
|
aud,
|
81
86
|
iss,
|
82
87
|
},
|
83
88
|
wiaCryptoContext
|
84
89
|
);
|
85
90
|
|
91
|
+
Logger.log(LogLevel.DEBUG, `WIA DPoP token: ${signedWiaPoP}`);
|
92
|
+
|
86
93
|
const requestBody = {
|
87
|
-
client_id: clientId,
|
88
94
|
grant_type: "authorization_code",
|
95
|
+
client_id: clientId,
|
89
96
|
code,
|
90
97
|
redirect_uri: redirectUri,
|
91
98
|
code_verifier: codeVerifier,
|
99
|
+
client_assertion_type: ASSERTION_TYPE,
|
100
|
+
client_assertion: walletInstanceAttestation + "~" + signedWiaPoP,
|
92
101
|
};
|
93
102
|
|
94
103
|
const authorizationRequestFormBody = new URLSearchParams(requestBody);
|
104
|
+
|
105
|
+
Logger.log(
|
106
|
+
LogLevel.DEBUG,
|
107
|
+
`Auth form request body: ${authorizationRequestFormBody}`
|
108
|
+
);
|
109
|
+
|
95
110
|
const tokenRes = await appFetch(tokenUrl, {
|
96
111
|
method: "POST",
|
97
112
|
headers: {
|
98
113
|
"Content-Type": "application/x-www-form-urlencoded",
|
99
114
|
DPoP: tokenRequestSignedDPop,
|
100
|
-
"OAuth-Client-Attestation": walletInstanceAttestation,
|
101
|
-
"OAuth-Client-Attestation-PoP": signedWiaPoP,
|
102
115
|
},
|
103
116
|
body: authorizationRequestFormBody.toString(),
|
104
117
|
})
|
@@ -107,6 +120,11 @@ export const authorizeAccess: AuthorizeAccess = async (
|
|
107
120
|
.then((body) => TokenResponse.safeParse(body));
|
108
121
|
|
109
122
|
if (!tokenRes.success) {
|
123
|
+
Logger.log(
|
124
|
+
LogLevel.ERROR,
|
125
|
+
`Token Response validation failed: ${tokenRes.error.message}`
|
126
|
+
);
|
127
|
+
|
110
128
|
throw new ValidationFailed({
|
111
129
|
message: "Token Response validation failed",
|
112
130
|
reason: tokenRes.error.message,
|
@@ -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 { EvaluateIssuerTrust } from "./02-evaluate-issuer-trust";
|
8
8
|
import { hasStatusOrThrow, type Out } from "../../utils/misc";
|
9
9
|
import type { StartUserAuthorization } from "./03-start-user-authorization";
|
10
10
|
import {
|
@@ -16,10 +16,11 @@ import {
|
|
16
16
|
} from "../../utils/errors";
|
17
17
|
import { CredentialResponse } from "./types";
|
18
18
|
import { createDPopToken } from "../../utils/dpop";
|
19
|
-
import
|
19
|
+
import { v4 as uuidv4 } from "uuid";
|
20
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
20
21
|
|
21
22
|
export type ObtainCredential = (
|
22
|
-
issuerConf: Out<
|
23
|
+
issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
|
23
24
|
accessToken: Out<AuthorizeAccess>["accessToken"],
|
24
25
|
clientId: Out<StartUserAuthorization>["clientId"],
|
25
26
|
credentialDefinition: Out<StartUserAuthorization>["credentialDefinition"],
|
@@ -27,7 +28,8 @@ export type ObtainCredential = (
|
|
27
28
|
dPopCryptoContext: CryptoContext;
|
28
29
|
credentialCryptoContext: CryptoContext;
|
29
30
|
appFetch?: GlobalFetch["fetch"];
|
30
|
-
}
|
31
|
+
},
|
32
|
+
operationType?: "reissuing"
|
31
33
|
) => Promise<CredentialResponse>;
|
32
34
|
|
33
35
|
export const createNonceProof = async (
|
@@ -58,7 +60,7 @@ export const createNonceProof = async (
|
|
58
60
|
* of the Credential Issuer to request the issuance of a credential linked to the public key contained in the JWT proof.
|
59
61
|
* The Openid4vci proof JWT incapsulates the nonce extracted from the token response from the {@link authorizeAccess} step.
|
60
62
|
* 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
|
63
|
+
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
62
64
|
* @param accessToken The access token response returned by {@link authorizeAccess}
|
63
65
|
* @param clientId The client id returned by {@link startUserAuthorization}
|
64
66
|
* @param credentialDefinition The credential definition of the credential to be obtained returned by {@link startUserAuthorization}
|
@@ -73,7 +75,8 @@ export const obtainCredential: ObtainCredential = async (
|
|
73
75
|
accessToken,
|
74
76
|
clientId,
|
75
77
|
credentialDefinition,
|
76
|
-
context
|
78
|
+
context,
|
79
|
+
operationType
|
77
80
|
) => {
|
78
81
|
const {
|
79
82
|
credentialCryptoContext,
|
@@ -81,7 +84,7 @@ export const obtainCredential: ObtainCredential = async (
|
|
81
84
|
dPopCryptoContext,
|
82
85
|
} = context;
|
83
86
|
|
84
|
-
const credentialUrl = issuerConf.credential_endpoint;
|
87
|
+
const credentialUrl = issuerConf.openid_credential_issuer.credential_endpoint;
|
85
88
|
|
86
89
|
/**
|
87
90
|
* JWT proof token to bind the request nonce to the key that will bind the holder User with the Credential
|
@@ -95,67 +98,64 @@ export const obtainCredential: ObtainCredential = async (
|
|
95
98
|
credentialCryptoContext
|
96
99
|
);
|
97
100
|
|
101
|
+
Logger.log(LogLevel.DEBUG, `Signed nonce proof: ${signedNonceProof}`);
|
102
|
+
|
103
|
+
// Validation of accessTokenResponse.authorization_details if contain credentialDefinition
|
98
104
|
const containsCredentialDefinition = accessToken.authorization_details.some(
|
99
|
-
(
|
100
|
-
|
105
|
+
(c) =>
|
106
|
+
c.credential_configuration_id ===
|
101
107
|
credentialDefinition.credential_configuration_id &&
|
102
|
-
|
108
|
+
c.format === credentialDefinition.format &&
|
109
|
+
c.type === credentialDefinition.type
|
103
110
|
);
|
104
111
|
|
105
112
|
if (!containsCredentialDefinition) {
|
113
|
+
Logger.log(
|
114
|
+
LogLevel.ERROR,
|
115
|
+
`Credential definition not found in the access token response ${accessToken.authorization_details}`
|
116
|
+
);
|
106
117
|
throw new ValidationFailed({
|
107
118
|
message:
|
108
119
|
"The access token response does not contain the requested credential",
|
109
120
|
});
|
110
121
|
}
|
111
122
|
|
112
|
-
const credential =
|
113
|
-
issuerConf.credential_configurations_supported[
|
114
|
-
credentialDefinition.credential_configuration_id
|
115
|
-
];
|
116
|
-
|
117
|
-
if (!credential) {
|
118
|
-
throw new ValidationFailed({
|
119
|
-
message: "The credential configuration is not supported by the issuer",
|
120
|
-
});
|
121
|
-
}
|
122
|
-
|
123
|
-
const format = credential.format;
|
124
|
-
|
125
|
-
if (!format) {
|
126
|
-
throw new ValidationFailed({
|
127
|
-
message:
|
128
|
-
"The credential doesn't contain the format required by the issuer",
|
129
|
-
});
|
130
|
-
}
|
131
|
-
|
132
123
|
/** The credential request body */
|
133
124
|
const credentialRequestFormBody = {
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
format,
|
125
|
+
credential_definition: {
|
126
|
+
type: [credentialDefinition.credential_configuration_id],
|
127
|
+
},
|
128
|
+
format: credentialDefinition.format,
|
138
129
|
proof: {
|
139
130
|
jwt: signedNonceProof,
|
140
131
|
proof_type: "jwt",
|
141
132
|
},
|
142
133
|
};
|
143
134
|
|
135
|
+
Logger.log(
|
136
|
+
LogLevel.DEBUG,
|
137
|
+
`Credential request body: ${JSON.stringify(credentialRequestFormBody)}`
|
138
|
+
);
|
139
|
+
|
144
140
|
const tokenRequestSignedDPop = await createDPopToken(
|
145
141
|
{
|
146
142
|
htm: "POST",
|
147
143
|
htu: credentialUrl,
|
148
|
-
jti: `${
|
144
|
+
jti: `${uuidv4()}`,
|
149
145
|
ath: await sha256ToBase64(accessToken.access_token),
|
150
146
|
},
|
151
147
|
dPopCryptoContext
|
152
148
|
);
|
149
|
+
|
150
|
+
Logger.log(LogLevel.DEBUG, `Token request DPoP: ${tokenRequestSignedDPop}`);
|
151
|
+
|
153
152
|
const credentialRes = await appFetch(credentialUrl, {
|
154
153
|
method: "POST",
|
155
154
|
headers: {
|
156
155
|
"Content-Type": "application/json",
|
157
156
|
DPoP: tokenRequestSignedDPop,
|
158
157
|
Authorization: `${accessToken.token_type} ${accessToken.access_token}`,
|
158
|
+
...(operationType === "reissuing" && { operationType }),
|
159
159
|
},
|
160
160
|
body: JSON.stringify(credentialRequestFormBody),
|
161
161
|
})
|
@@ -165,13 +165,21 @@ export const obtainCredential: ObtainCredential = async (
|
|
165
165
|
.catch(handleObtainCredentialError);
|
166
166
|
|
167
167
|
if (!credentialRes.success) {
|
168
|
+
Logger.log(
|
169
|
+
LogLevel.ERROR,
|
170
|
+
`Credential Response validation failed: ${credentialRes.error.message}`
|
171
|
+
);
|
168
172
|
throw new ValidationFailed({
|
169
173
|
message: "Credential Response validation failed",
|
170
174
|
reason: credentialRes.error.message,
|
171
175
|
});
|
172
176
|
}
|
173
177
|
|
174
|
-
|
178
|
+
Logger.log(
|
179
|
+
LogLevel.DEBUG,
|
180
|
+
`Credential Response: ${JSON.stringify(credentialRes.data)}`
|
181
|
+
);
|
182
|
+
|
175
183
|
return credentialRes.data;
|
176
184
|
};
|
177
185
|
|
@@ -182,11 +190,28 @@ export const obtainCredential: ObtainCredential = async (
|
|
182
190
|
* @throws {IssuerResponseError} with a specific code for more context
|
183
191
|
*/
|
184
192
|
const handleObtainCredentialError = (e: unknown) => {
|
193
|
+
Logger.log(LogLevel.ERROR, `Error occurred while obtaining credential: ${e}`);
|
194
|
+
|
185
195
|
if (!(e instanceof UnexpectedStatusCodeError)) {
|
186
196
|
throw e;
|
187
197
|
}
|
188
198
|
|
189
199
|
throw new ResponseErrorBuilder(IssuerResponseError)
|
200
|
+
.handle(201, {
|
201
|
+
// Although it is technically not an error, we handle it as such to avoid
|
202
|
+
// changing the return type of `obtainCredential` and introduce a breaking change.
|
203
|
+
code: IssuerResponseErrorCodes.CredentialIssuingNotSynchronous,
|
204
|
+
message:
|
205
|
+
"This credential cannot be issued synchronously. It will be available at a later time.",
|
206
|
+
})
|
207
|
+
.handle(403, {
|
208
|
+
code: IssuerResponseErrorCodes.CredentialInvalidStatus,
|
209
|
+
message: "Invalid status found for the given credential",
|
210
|
+
})
|
211
|
+
.handle(404, {
|
212
|
+
code: IssuerResponseErrorCodes.CredentialInvalidStatus,
|
213
|
+
message: "Invalid status found for the given credential",
|
214
|
+
})
|
190
215
|
.handle("*", {
|
191
216
|
code: IssuerResponseErrorCodes.CredentialRequestFailed,
|
192
217
|
message: "Unable to obtain the requested credential",
|