@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
@@ -1,13 +1,10 @@
|
|
1
1
|
import { EncryptJwe } from "@pagopa/io-react-native-jwt";
|
2
2
|
import uuid from "react-native-uuid";
|
3
|
-
import {
|
3
|
+
import { getJwksFromConfig } from "./04-retrieve-rp-jwks";
|
4
|
+
import { NoSuitableKeysFoundInEntityConfiguration } from "./errors";
|
4
5
|
import { hasStatusOrThrow } from "../../utils/misc";
|
5
6
|
import * as z from "zod";
|
6
|
-
import {
|
7
|
-
import { prepareVpTokenMdoc } from "../../mdoc";
|
8
|
-
import { generateRandomAlphaNumericString } from "../../utils/misc";
|
9
|
-
import { createCryptoContextFor } from "../../utils/crypto";
|
10
|
-
import { prepareVpToken } from "../../sd-jwt";
|
7
|
+
import { RelyingPartyResponseError, ResponseErrorBuilder, UnexpectedStatusCodeError, RelyingPartyResponseErrorCodes } from "../../utils/errors";
|
11
8
|
export const AuthorizationResponse = z.object({
|
12
9
|
status: z.string().optional(),
|
13
10
|
response_code: z.string() /**
|
@@ -22,24 +19,12 @@ export const AuthorizationResponse = z.object({
|
|
22
19
|
* Selects a public key (with `use = enc`) from the set of JWK keys
|
23
20
|
* offered by the Relying Party (RP) for encryption.
|
24
21
|
*
|
25
|
-
* Preference is given to EC keys (P-256 or P-384), followed by RSA keys,
|
26
|
-
* based on compatibility and common usage for encryption.
|
27
|
-
*
|
28
22
|
* @param rpJwkKeys - The array of JWKs retrieved from the RP entity configuration.
|
29
23
|
* @returns The first suitable public key found in the list.
|
30
24
|
* @throws {NoSuitableKeysFoundInEntityConfiguration} If no suitable encryption key is found.
|
31
25
|
*/
|
32
26
|
export const choosePublicKeyToEncrypt = rpJwkKeys => {
|
33
|
-
|
34
|
-
const encKeys = rpJwkKeys.filter(jwk => jwk.use === "enc");
|
35
|
-
|
36
|
-
// Prioritize EC keys first, then fall back to RSA keys if needed
|
37
|
-
// io-react-native-jwt support only EC keys with P-256 or P-384 curves
|
38
|
-
const ecEncKeys = encKeys.filter(jwk => jwk.kty === "EC" && (jwk.crv === "P-256" || jwk.crv === "P-384"));
|
39
|
-
const rsaEncKeys = encKeys.filter(jwk => jwk.kty === "RSA");
|
40
|
-
|
41
|
-
// Select the first available key based on priority
|
42
|
-
const encKey = ecEncKeys[0] || rsaEncKeys[0] || encKeys[0];
|
27
|
+
const encKey = rpJwkKeys.find(jwk => jwk.use === "enc");
|
43
28
|
if (encKey) {
|
44
29
|
return encKey;
|
45
30
|
}
|
@@ -48,56 +33,36 @@ export const choosePublicKeyToEncrypt = rpJwkKeys => {
|
|
48
33
|
throw new NoSuitableKeysFoundInEntityConfiguration("No suitable public key found for encryption.");
|
49
34
|
};
|
50
35
|
|
51
|
-
/**
|
52
|
-
* Builds a URL-encoded form body for a direct POST response without encryption.
|
53
|
-
*
|
54
|
-
* @param requestObject - Contains state, nonce, and other relevant info.
|
55
|
-
* @param payload - Object that contains either the VP token to encrypt and the stringified mapping of the credential disclosures or the error code
|
56
|
-
* @returns A URL-encoded string suitable for an `application/x-www-form-urlencoded` POST body.
|
57
|
-
*/
|
58
|
-
export const buildDirectPostBody = async (requestObject, payload) => {
|
59
|
-
const formUrlEncodedBody = new URLSearchParams({
|
60
|
-
...(requestObject.state ? {
|
61
|
-
state: requestObject.state
|
62
|
-
} : {}),
|
63
|
-
...Object.fromEntries(Object.entries(payload).map(_ref => {
|
64
|
-
let [key, value] = _ref;
|
65
|
-
return [key, Array.isArray(value) || typeof value === "object" ? JSON.stringify(value) : value];
|
66
|
-
}))
|
67
|
-
});
|
68
|
-
return formUrlEncodedBody.toString();
|
69
|
-
};
|
70
|
-
|
71
36
|
/**
|
72
37
|
* Builds a URL-encoded form body for a direct POST response using JWT encryption.
|
73
38
|
*
|
74
39
|
* @param jwkKeys - Array of JWKs from the Relying Party for encryption.
|
75
40
|
* @param requestObject - Contains state, nonce, and other relevant info.
|
76
|
-
* @param payload - Object that contains
|
77
|
-
* @
|
78
|
-
* @returns A URL-encoded string for an `application/x-www-form-urlencoded` POST body,
|
79
|
-
* where `response` contains the encrypted JWE.
|
41
|
+
* @param payload - Object that contains the VP token to encrypt and the mapping of the credential disclosures
|
42
|
+
* @returns A URL-encoded string for an `application/x-www-form-urlencoded` POST body, where `response` contains the encrypted JWE.
|
80
43
|
*/
|
81
|
-
export const buildDirectPostJwtBody = async (
|
44
|
+
export const buildDirectPostJwtBody = async (requestObject, rpConf, payload) => {
|
82
45
|
// Prepare the authorization response payload to be encrypted
|
83
46
|
const authzResponsePayload = JSON.stringify({
|
84
47
|
state: requestObject.state,
|
85
48
|
...payload
|
86
49
|
});
|
87
|
-
|
50
|
+
// Choose a suitable public key for encryption
|
51
|
+
const {
|
52
|
+
keys
|
53
|
+
} = getJwksFromConfig(rpConf);
|
54
|
+
const encPublicJwk = choosePublicKeyToEncrypt(keys);
|
55
|
+
|
88
56
|
// Encrypt the authorization payload
|
89
57
|
const {
|
90
|
-
|
91
|
-
|
58
|
+
authorization_encrypted_response_alg,
|
59
|
+
authorization_encrypted_response_enc
|
60
|
+
} = rpConf.openid_credential_verifier;
|
61
|
+
const defaultAlg = encPublicJwk.kty === "EC" ? "ECDH-ES" : "RSA-OAEP-256";
|
92
62
|
const encryptedResponse = await new EncryptJwe(authzResponsePayload, {
|
93
|
-
alg:
|
94
|
-
enc:
|
95
|
-
kid: encPublicJwk.kid
|
96
|
-
/* ISO 18013-7 */
|
97
|
-
apv: Base64.encodeURI(requestObject.nonce),
|
98
|
-
...(generatedNonce ? {
|
99
|
-
apu: Base64.encodeURI(generatedNonce)
|
100
|
-
} : {})
|
63
|
+
alg: authorization_encrypted_response_alg || defaultAlg,
|
64
|
+
enc: authorization_encrypted_response_enc || "A256CBC-HS512",
|
65
|
+
kid: encPublicJwk.kid
|
101
66
|
}).encrypt(encPublicJwk);
|
102
67
|
|
103
68
|
// Build the x-www-form-urlencoded form body
|
@@ -111,13 +76,33 @@ export const buildDirectPostJwtBody = async (jwkKeys, requestObject, payload, ge
|
|
111
76
|
};
|
112
77
|
|
113
78
|
/**
|
114
|
-
*
|
115
|
-
*
|
79
|
+
* Builds a URL-encoded form body for a direct POST response without encryption.
|
80
|
+
*
|
81
|
+
* @param requestObject - Contains state, nonce, and other relevant info.
|
82
|
+
* @param payload - Object that contains either the VP token to encrypt and the stringified mapping of the credential disclosures or the error code
|
83
|
+
* @returns A URL-encoded string suitable for an `application/x-www-form-urlencoded` POST body.
|
116
84
|
*/
|
85
|
+
export const buildDirectPostBody = async (requestObject, payload) => {
|
86
|
+
const formUrlEncodedBody = new URLSearchParams({
|
87
|
+
...(requestObject.state && {
|
88
|
+
state: requestObject.state
|
89
|
+
}),
|
90
|
+
...Object.entries(payload).reduce((acc, _ref) => {
|
91
|
+
let [key, value] = _ref;
|
92
|
+
return {
|
93
|
+
...acc,
|
94
|
+
[key]: Array.isArray(value) || typeof value === "object" ? JSON.stringify(value) : value
|
95
|
+
};
|
96
|
+
}, {})
|
97
|
+
});
|
98
|
+
return formUrlEncodedBody.toString();
|
99
|
+
};
|
117
100
|
|
118
101
|
/**
|
119
102
|
* Type definition for the function that sends the authorization response
|
120
103
|
* to the Relying Party, completing the presentation flow.
|
104
|
+
* Use with `presentation_definition`.
|
105
|
+
* @deprecated Use `sendAuthorizationResponse`
|
121
106
|
*/
|
122
107
|
|
123
108
|
/**
|
@@ -131,172 +116,124 @@ export const buildDirectPostJwtBody = async (jwkKeys, requestObject, payload, ge
|
|
131
116
|
* @param context - Contains optional custom fetch implementation.
|
132
117
|
* @returns Parsed and validated authorization response from the Relying Party.
|
133
118
|
*/
|
134
|
-
export const
|
135
|
-
var
|
119
|
+
export const sendLegacyAuthorizationResponse = async function (requestObject, presentationDefinitionId, remotePresentations, rpConf) {
|
120
|
+
var _remotePresentations$;
|
136
121
|
let {
|
137
122
|
appFetch = fetch
|
138
123
|
} = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
139
|
-
const {
|
140
|
-
generatedNonce,
|
141
|
-
presentations
|
142
|
-
} = remotePresentation;
|
143
124
|
/**
|
144
125
|
* 1. Prepare the VP token and presentation submission
|
145
126
|
* If there is only one credential, `vpToken` is a single string.
|
146
127
|
* If there are multiple credential, `vpToken` is an array of string.
|
147
128
|
**/
|
148
|
-
const vp_token = (
|
149
|
-
const descriptor_map =
|
150
|
-
id:
|
151
|
-
path:
|
152
|
-
format:
|
129
|
+
const vp_token = (remotePresentations === null || remotePresentations === void 0 ? void 0 : remotePresentations.length) === 1 ? (_remotePresentations$ = remotePresentations[0]) === null || _remotePresentations$ === void 0 ? void 0 : _remotePresentations$.vpToken : remotePresentations.map(remotePresentation => remotePresentation.vpToken);
|
130
|
+
const descriptor_map = remotePresentations.map((remotePresentation, index) => ({
|
131
|
+
id: remotePresentation.inputDescriptor.id,
|
132
|
+
path: remotePresentations.length === 1 ? `$` : `$[${index}]`,
|
133
|
+
format: remotePresentation.format
|
153
134
|
}));
|
154
135
|
const presentation_submission = {
|
155
136
|
id: uuid.v4(),
|
156
137
|
definition_id: presentationDefinitionId,
|
157
138
|
descriptor_map
|
158
139
|
};
|
159
|
-
|
160
|
-
// 2. Choose the appropriate request body builder based on response mode
|
161
|
-
const requestBody = requestObject.response_mode === "direct_post.jwt" ? await buildDirectPostJwtBody(jwkKeys, requestObject, {
|
140
|
+
const requestBody = await buildDirectPostJwtBody(requestObject, rpConf, {
|
162
141
|
vp_token,
|
163
142
|
presentation_submission
|
164
|
-
}, generatedNonce) : await buildDirectPostBody(requestObject, {
|
165
|
-
vp_token,
|
166
|
-
presentation_submission: presentation_submission
|
167
143
|
});
|
168
144
|
|
169
145
|
// 3. Send the authorization response via HTTP POST and validate the response
|
170
|
-
|
146
|
+
return await appFetch(requestObject.response_uri, {
|
171
147
|
method: "POST",
|
172
148
|
headers: {
|
173
149
|
"Content-Type": "application/x-www-form-urlencoded"
|
174
150
|
},
|
175
151
|
body: requestBody
|
176
|
-
}).then(hasStatusOrThrow(200)).then(res => res.json()).then(AuthorizationResponse.
|
177
|
-
|
178
|
-
// Some Relying Parties may return an empty body.
|
179
|
-
return authResponse.success ? authResponse.data : {};
|
152
|
+
}).then(hasStatusOrThrow(200)).then(res => res.json()).then(AuthorizationResponse.parse);
|
180
153
|
};
|
181
154
|
|
182
155
|
/**
|
183
156
|
* Type definition for the function that sends the authorization response
|
184
157
|
* to the Relying Party, completing the presentation flow.
|
158
|
+
* Use with DCQL queries.
|
185
159
|
*/
|
186
160
|
|
187
|
-
|
188
|
-
* Sends the authorization error response to the Relying Party (RP) using the specified `response_mode`.
|
189
|
-
* This function completes the presentation flow in an OpenID 4 Verifiable Presentations scenario.
|
190
|
-
*
|
191
|
-
* @param requestObject - The request details, including presentation requirements.
|
192
|
-
* @param error - The response error value
|
193
|
-
* @param jwkKeys - Array of JWKs from the Relying Party for optional encryption.
|
194
|
-
* @param context - Contains optional custom fetch implementation.
|
195
|
-
* @returns Parsed and validated authorization response from the Relying Party.
|
196
|
-
*/
|
197
|
-
export const sendAuthorizationErrorResponse = async function (requestObject, error, jwkKeys) {
|
161
|
+
export const sendAuthorizationResponse = async function (requestObject, remotePresentations, rpConf) {
|
198
162
|
let {
|
199
163
|
appFetch = fetch
|
200
164
|
} = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
201
|
-
//
|
202
|
-
const requestBody =
|
203
|
-
|
204
|
-
|
205
|
-
|
165
|
+
// 1. Prepare the VP token as a JSON object with keys corresponding to the DCQL query credential IDs
|
166
|
+
const requestBody = await buildDirectPostJwtBody(requestObject, rpConf, {
|
167
|
+
vp_token: remotePresentations.reduce((acc, presentation) => ({
|
168
|
+
...acc,
|
169
|
+
[presentation.credentialId]: presentation.vpToken
|
170
|
+
}), {})
|
206
171
|
});
|
207
|
-
|
172
|
+
|
173
|
+
// 2. Send the authorization response via HTTP POST and validate the response
|
208
174
|
return await appFetch(requestObject.response_uri, {
|
209
175
|
method: "POST",
|
210
176
|
headers: {
|
211
177
|
"Content-Type": "application/x-www-form-urlencoded"
|
212
178
|
},
|
213
179
|
body: requestBody
|
214
|
-
}).then(hasStatusOrThrow(200)).then(res => res.json()).then(AuthorizationResponse.parse);
|
180
|
+
}).then(hasStatusOrThrow(200)).then(res => res.json()).then(AuthorizationResponse.parse).catch(handleAuthorizationResponseError);
|
215
181
|
};
|
216
|
-
|
182
|
+
|
183
|
+
/**
|
184
|
+
* Type definition for the function that sends the authorization response
|
185
|
+
* to the Relying Party, completing the presentation flow.
|
186
|
+
*/
|
187
|
+
|
188
|
+
/**
|
189
|
+
* Sends the authorization error response to the Relying Party (RP) using the specified `response_mode`.
|
190
|
+
* This function completes the presentation flow in an OpenID 4 Verifiable Presentations scenario.
|
191
|
+
*
|
192
|
+
* @param requestObject - The request details, including presentation requirements.
|
193
|
+
* @param error - The response error value, with description
|
194
|
+
* @param context - Contains optional custom fetch implementation.
|
195
|
+
* @returns Parsed and validated authorization response from the Relying Party.
|
196
|
+
*/
|
197
|
+
export const sendAuthorizationErrorResponse = async function (requestObject, _ref2) {
|
198
|
+
let {
|
199
|
+
error,
|
200
|
+
errorDescription
|
201
|
+
} = _ref2;
|
217
202
|
let {
|
218
203
|
appFetch = fetch
|
219
|
-
} = arguments.length >
|
220
|
-
const {
|
221
|
-
|
222
|
-
|
223
|
-
}
|
224
|
-
// 1. Prepare the VP token as a JSON object with keys corresponding to the DCQL query credential IDs
|
225
|
-
const requestBody = await buildDirectPostJwtBody(jwkKeys, requestObject, {
|
226
|
-
vp_token: presentations.reduce((acc, presentation) => ({
|
227
|
-
...acc,
|
228
|
-
[presentation.credentialId]: presentation.vpToken
|
229
|
-
}), {})
|
230
|
-
}, generatedNonce);
|
231
|
-
|
232
|
-
// 2. Send the authorization response via HTTP POST and validate the response
|
204
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
205
|
+
const requestBody = await buildDirectPostBody(requestObject, {
|
206
|
+
error,
|
207
|
+
error_description: errorDescription
|
208
|
+
});
|
233
209
|
return await appFetch(requestObject.response_uri, {
|
234
210
|
method: "POST",
|
235
211
|
headers: {
|
236
212
|
"Content-Type": "application/x-www-form-urlencoded"
|
237
213
|
},
|
238
214
|
body: requestBody
|
239
|
-
}).then(hasStatusOrThrow(200)).then(res => res.json()).then(AuthorizationResponse.parse);
|
215
|
+
}).then(hasStatusOrThrow(200, RelyingPartyResponseError)).then(res => res.json()).then(AuthorizationResponse.parse);
|
240
216
|
};
|
241
217
|
|
242
218
|
/**
|
243
|
-
*
|
244
|
-
*
|
245
|
-
*
|
246
|
-
*
|
247
|
-
* - Generates a verifiable presentation token (vpToken) using the appropriate method.
|
248
|
-
* - For ISO 18013-7, generates a special nonce with minimum entropy of 16.
|
249
|
-
*
|
250
|
-
* @param credentials - An array of credential items containing format, credential data, requested claims, and key information.
|
251
|
-
* @param authRequestObject - The authentication request object containing nonce, clientId, and responseUri.
|
252
|
-
* @returns A promise that resolves to an object containing an array of presentations and the generated nonce.
|
253
|
-
* @throws {CredentialNotFoundError} When the credential format is unsupported.
|
219
|
+
* Handle the the presentation error by mapping it to a custom exception.
|
220
|
+
* If the error is not an instance of {@link UnexpectedStatusCodeError}, it is thrown as is.
|
221
|
+
* @param e - The error to be handled
|
222
|
+
* @throws {RelyingPartyResponseError} with a specific code for more context
|
254
223
|
*/
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
let {
|
270
|
-
name
|
271
|
-
} = _ref2;
|
272
|
-
return name;
|
273
|
-
})],
|
274
|
-
credentialId: credentialInputId,
|
275
|
-
vpToken: vp_token,
|
276
|
-
format: "mso_mdoc"
|
277
|
-
};
|
278
|
-
}
|
279
|
-
if (format === "vc+sd-jwt") {
|
280
|
-
const {
|
281
|
-
vp_token
|
282
|
-
} = await prepareVpToken(authRequestObject.nonce, authRequestObject.clientId, [item.credential, item.requestedClaims, createCryptoContextFor(item.keyTag)]);
|
283
|
-
return {
|
284
|
-
requestedClaims: [...item.requestedClaims.map(_ref3 => {
|
285
|
-
let {
|
286
|
-
name
|
287
|
-
} = _ref3;
|
288
|
-
return name;
|
289
|
-
})],
|
290
|
-
credentialId: credentialInputId,
|
291
|
-
vpToken: vp_token,
|
292
|
-
format: "vc+sd-jwt"
|
293
|
-
};
|
294
|
-
}
|
295
|
-
throw new CredentialNotFoundError(`${format} format is not supported.`);
|
296
|
-
}));
|
297
|
-
return {
|
298
|
-
presentations,
|
299
|
-
generatedNonce
|
300
|
-
};
|
224
|
+
const handleAuthorizationResponseError = e => {
|
225
|
+
if (!(e instanceof UnexpectedStatusCodeError)) {
|
226
|
+
throw e;
|
227
|
+
}
|
228
|
+
throw new ResponseErrorBuilder(RelyingPartyResponseError).handle(400, {
|
229
|
+
code: RelyingPartyResponseErrorCodes.InvalidAuthorizationResponse,
|
230
|
+
message: "The Authorization Response contains invalid parameters or it is malformed"
|
231
|
+
}).handle(403, {
|
232
|
+
code: RelyingPartyResponseErrorCodes.InvalidAuthorizationResponse,
|
233
|
+
message: "The Authorization Response was forbidden"
|
234
|
+
}).handle("*", {
|
235
|
+
code: RelyingPartyResponseErrorCodes.RelyingPartyGenericError,
|
236
|
+
message: "Unable to successfully send the Authorization Response"
|
237
|
+
}).buildFrom(e);
|
301
238
|
};
|
302
239
|
//# sourceMappingURL=08-send-authorization-response.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["EncryptJwe","uuid","
|
1
|
+
{"version":3,"names":["EncryptJwe","uuid","getJwksFromConfig","NoSuitableKeysFoundInEntityConfiguration","hasStatusOrThrow","z","RelyingPartyResponseError","ResponseErrorBuilder","UnexpectedStatusCodeError","RelyingPartyResponseErrorCodes","AuthorizationResponse","object","status","string","optional","response_code","redirect_uri","choosePublicKeyToEncrypt","rpJwkKeys","encKey","find","jwk","use","buildDirectPostJwtBody","requestObject","rpConf","payload","authzResponsePayload","JSON","stringify","state","keys","encPublicJwk","authorization_encrypted_response_alg","authorization_encrypted_response_enc","openid_credential_verifier","defaultAlg","kty","encryptedResponse","alg","enc","kid","encrypt","formBody","URLSearchParams","response","toString","buildDirectPostBody","formUrlEncodedBody","Object","entries","reduce","acc","_ref","key","value","Array","isArray","sendLegacyAuthorizationResponse","presentationDefinitionId","remotePresentations","_remotePresentations$","appFetch","fetch","arguments","length","undefined","vp_token","vpToken","map","remotePresentation","descriptor_map","index","id","inputDescriptor","path","format","presentation_submission","v4","definition_id","requestBody","response_uri","method","headers","body","then","res","json","parse","sendAuthorizationResponse","presentation","credentialId","catch","handleAuthorizationResponseError","sendAuthorizationErrorResponse","_ref2","error","errorDescription","error_description","e","handle","code","InvalidAuthorizationResponse","message","RelyingPartyGenericError","buildFrom"],"sourceRoot":"../../../../src","sources":["credential/presentation/08-send-authorization-response.ts"],"mappings":"AAAA,SAASA,UAAU,QAAQ,6BAA6B;AACxD,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,iBAAiB,QAAwB,uBAAuB;AAEzE,SAASC,wCAAwC,QAAQ,UAAU;AACnE,SAASC,gBAAgB,QAAkB,kBAAkB;AAO7D,OAAO,KAAKC,CAAC,MAAM,KAAK;AAGxB,SACEC,yBAAyB,EACzBC,oBAAoB,EACpBC,yBAAyB,EACzBC,8BAA8B,QACzB,oBAAoB;AAG3B,OAAO,MAAMC,qBAAqB,GAAGL,CAAC,CAACM,MAAM,CAAC;EAC5CC,MAAM,EAAEP,CAAC,CAACQ,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC7BC,aAAa,EAAEV,CAAC,CACbQ,MAAM,CAAC,CAAC,CAAC;AACd;AACA;AACA;AACA,8BAJc,CAKTC,QAAQ,CAAC,CAAC;EACbE,YAAY,EAAEX,CAAC,CAACQ,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC;AACpC,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,wBAAwB,GACnCC,SAAiC,IACzB;EACR,MAAMC,MAAM,GAAGD,SAAS,CAACE,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,GAAG,KAAK,KAAK,CAAC;EAEzD,IAAIH,MAAM,EAAE;IACV,OAAOA,MAAM;EACf;;EAEA;EACA,MAAM,IAAIhB,wCAAwC,CAChD,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E,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBF,IAAI,CAAC3E,qBAAqB,CAAC8E,KAAK,CAAC;AACtC,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,gCAAgC,GAAIM,CAAU,IAAK;EACvD,IAAI,EAAEA,CAAC,YAAY3F,yBAAyB,CAAC,EAAE;IAC7C,MAAM2F,CAAC;EACT;EAEA,MAAM,IAAI5F,oBAAoB,CAACD,yBAAyB,CAAC,CACtD8F,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAE5F,8BAA8B,CAAC6F,4BAA4B;IACjEC,OAAO,EACL;EACJ,CAAC,CAAC,CACDH,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAE5F,8BAA8B,CAAC6F,4BAA4B;IACjEC,OAAO,EAAE;EACX,CAAC,CAAC,CACDH,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAE5F,8BAA8B,CAAC+F,wBAAwB;IAC7DD,OAAO,EAAE;EACX,CAAC,CAAC,CACDE,SAAS,CAACN,CAAC,CAAC;AACjB,CAAC"}
|
@@ -1,112 +1,107 @@
|
|
1
1
|
# Credential Presentation
|
2
2
|
|
3
|
+
This flow is used for remote presentation, allowing a user with a valid Wallet Instance to remotely present credentials to a Relying Party (Verifier). The presentation flow adheres to the [IT Wallet 0.9.x specification](https://italia.github.io/eid-wallet-it-docs/v0.9.3/en/relying-party-solution.html).
|
4
|
+
|
5
|
+
The Relying Party provides the Wallet with a Request Object that contains the requested credentials and claims. The Wallet validates the Request Object and asks the user for consent. Then the Wallet creates an encrypted Authorization Response that contains the Verifiable Presentation with the requested data (`vp_token`) and sends it to the Relying Party.
|
6
|
+
|
3
7
|
## Sequence Diagram
|
4
8
|
|
5
9
|
```mermaid
|
6
10
|
sequenceDiagram
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
O->>+A: GET: /.well-known/jwt-vc-issuer/jwk
|
20
|
-
A->>+O: Respond with the public key
|
21
|
-
O->>+I: Redirect: Authorisation response
|
11
|
+
autonumber
|
12
|
+
participant I as User (Wallet Instance)
|
13
|
+
participant O as Relying Party (Verifier)
|
14
|
+
|
15
|
+
O->>+I: QR-CODE: Authorization Request (`request_uri`)
|
16
|
+
I->>+O: GET: Verifier's Entity Configuration
|
17
|
+
O->>+I: Respond with metadata (including public keys)
|
18
|
+
I->>+O: GET: Request Object, resolved from `request_uri`
|
19
|
+
O->>+I: Respond with the Request Object
|
20
|
+
I->>+I: Validate Request Object and give consent
|
21
|
+
I->>+O: POST: Authorization Response with encrypted VP token
|
22
|
+
O->>+I: Respond with optional `redirect_uri`
|
22
23
|
```
|
23
24
|
|
24
25
|
## Mapped results
|
25
26
|
|
27
|
+
| Error | Description|
|
28
|
+
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
29
|
+
| `InvalidRequestObject` | The Request Object is not valid, for instance it is malformed or its signature cannot be verified. |
|
30
|
+
| `DcqlError` | The DCQL query cannot be evaluated because it contains errors. |
|
31
|
+
| `CredentialsNotFoundError` | The presentation cannot be completed because the Wallet does not contain all requested credentials. The missing credentials can be found in `details`. |
|
32
|
+
| `RelyingPartyResponseError` | Error in the Relying Party's response. See the next table for more details. |
|
33
|
+
|
34
|
+
#### RelyingPartyResponseError
|
35
|
+
The following HTTP errors are mapped to a `RelyingPartyResponseError` with specific codes.
|
36
|
+
|
37
|
+
| HTTP Status | Error Code | Description |
|
38
|
+
| ------------ | --------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
|
39
|
+
| `400`, `403` | `ERR_RP_INVALID_AUTHORIZATION_RESPONSE` | The Relying Party rejected the Authorization Response sent by the Wallet because it was deemed invalid. |
|
40
|
+
| `*` | `ERR_RP_GENERIC_ERROR` | This is a generic error code to map unexpected errors that occurred when interacting with the Relying Party. |
|
41
|
+
|
42
|
+
|
26
43
|
## Examples
|
27
44
|
|
28
45
|
<details>
|
29
46
|
<summary>Remote Presentation flow</summary>
|
30
47
|
|
48
|
+
**Note:** To successfully complete a remote presentation, the Wallet Instance must be in a valid state with a valid Wallet Instance Attestation.
|
49
|
+
|
31
50
|
```ts
|
32
|
-
//
|
33
|
-
const
|
34
|
-
|
35
|
-
// Retrieve the integrity key tag from the store and create its context
|
36
|
-
const integrityKeyTag = "example"; // Let's assume this is the key tag used to create the wallet instance
|
37
|
-
const integrityContext = getIntegrityContext(integrityKeyTag);
|
38
|
-
|
39
|
-
// Let's assume the key esists befor starting the presentation process
|
40
|
-
const wiaCryptoContext = createCryptoContextFor(WIA_KEYTAG);
|
41
|
-
|
42
|
-
const { WALLET_PROVIDER_BASE_URL, WALLET_EAA_PROVIDER_BASE_URL, REDIRECT_URI } =
|
43
|
-
env; // Let's assume these are the environment variables
|
44
|
-
|
45
|
-
/**
|
46
|
-
* Obtains a new Wallet Instance Attestation.
|
47
|
-
* WARNING: The integrity context must be the same used when creating the Wallet Instance with the same keytag.
|
48
|
-
*/
|
49
|
-
const walletInstanceAttestation =
|
50
|
-
await WalletInstanceAttestation.getAttestation({
|
51
|
-
wiaCryptoContext,
|
52
|
-
integrityContext,
|
53
|
-
walletProviderBaseUrl: WALLET_PROVIDER_BASE_URL,
|
54
|
-
appFetch,
|
55
|
-
});
|
51
|
+
// Retrieve and scan the qr-code, decode it and get its parameters
|
52
|
+
const qrCodeParams = decodeQrCode(qrCode)
|
56
53
|
|
57
54
|
// Start the issuance flow
|
58
|
-
const {
|
55
|
+
const {
|
56
|
+
request_uri,
|
57
|
+
client_id,
|
58
|
+
request_uri_method,
|
59
|
+
state
|
60
|
+
} = Credential.Presentation.startFlowFromQR(qrCodeParams);
|
59
61
|
|
60
|
-
//
|
61
|
-
const { rpConf } = await Credential.Presentation.evaluateRelyingPartyTrust(
|
62
|
+
// Get the Relying Party's Entity Configuration and evaluate trust
|
63
|
+
const { rpConf } = await Credential.Presentation.evaluateRelyingPartyTrust(client_id);
|
62
64
|
|
65
|
+
// Get the Request Object from the RP
|
63
66
|
const { requestObjectEncodedJwt } =
|
64
|
-
|
65
|
-
appFetch: appFetch
|
66
|
-
});
|
67
|
-
|
68
|
-
// Retrieve RP JWK
|
69
|
-
// If use trust federation: Fetch Jwks from rpConf
|
70
|
-
const jwks = await Credential.Presentation.fetchJwksFromConfig(rpConf);
|
67
|
+
await Credential.Presentation.getRequestObject(request_uri);
|
71
68
|
|
72
|
-
//
|
73
|
-
const
|
69
|
+
// Validate the Request Object
|
70
|
+
const { requestObject } = await Credential.Presentation.verifyRequestObject(
|
74
71
|
requestObjectEncodedJwt,
|
75
|
-
{
|
72
|
+
{ clientId: client_id, rpConf }
|
76
73
|
);
|
77
74
|
|
78
|
-
//
|
79
|
-
const
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
);
|
75
|
+
// All the credentials that might be requested by the Relying Party
|
76
|
+
const credentialsSdJwt = [
|
77
|
+
["credential1_keytag", "eyJraWQiOiItRl82VWdhOG4zVmVnalkyVTdZVUhLMXpMb2FELU5QVGM2M1JNSVNuTGF3IiwidHlwIjoidmMrc2Qtand0IiwiYWxnIjoiRVMyNTYifQ.eyJfc2"],
|
78
|
+
["credential2_keytag", "eyJ0eXAiOiJ2YytzZC1qd3QiLCJhbGciOiJFUzI1NiIsImtpZCI6Ii1GXzZVZ2E4bjNWZWdqWTJVN1lVSEsxekxvYUQtTlBUYzYzUk1JU25MYXcifQ.ew0KIC"]
|
79
|
+
];
|
84
80
|
|
85
|
-
|
86
|
-
|
87
|
-
requestObject
|
88
|
-
{
|
89
|
-
appFetch: appFetch,
|
90
|
-
},
|
91
|
-
rpConf // If trust federation is used
|
81
|
+
const result = Credential.Presentation.evaluateDcqlQuery(
|
82
|
+
credentialsSdJwt,
|
83
|
+
requestObject.dcql_query as DcqlQuery
|
92
84
|
);
|
93
85
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
86
|
+
const credentialsToPresent = result.map(
|
87
|
+
({ requiredDisclosures, ...rest }) => ({
|
88
|
+
...rest,
|
89
|
+
requestedClaims: requiredDisclosures.map(([, claimName]) => claimName),
|
90
|
+
})
|
91
|
+
);
|
100
92
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
[credential, disclosuresRequested, { appFetch: appFetch }]
|
93
|
+
const remotePresentations =
|
94
|
+
await Credential.Presentation.prepareRemotePresentations(
|
95
|
+
credentialsToPresent,
|
96
|
+
requestObject.nonce,
|
97
|
+
requestObject.client_id
|
107
98
|
);
|
108
99
|
|
109
|
-
|
100
|
+
const authResponse = await Credential.Presentation.sendAuthorizationResponse(
|
101
|
+
requestObject,
|
102
|
+
remotePresentations,
|
103
|
+
rpConf
|
104
|
+
);
|
110
105
|
```
|
111
106
|
|
112
|
-
</details>
|
107
|
+
</details>
|