@pagopa/io-react-native-wallet 1.7.1 → 2.0.0-next.1
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/trust/README.md +147 -0
- package/lib/commonjs/trust/chain.js +153 -0
- package/lib/commonjs/trust/chain.js.map +1 -0
- package/lib/commonjs/trust/errors.js +133 -0
- package/lib/commonjs/trust/errors.js.map +1 -0
- package/lib/commonjs/trust/index.js +288 -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 +70 -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/README.md +147 -0
- package/lib/module/trust/chain.js +145 -0
- package/lib/module/trust/chain.js.map +1 -0
- package/lib/module/trust/errors.js +115 -0
- package/lib/module/trust/errors.js.map +1 -0
- package/lib/module/trust/index.js +269 -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 +60 -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 +20 -72
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/types.d.ts +24 -129
- package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/trust/chain.d.ts +23 -0
- package/lib/typescript/trust/chain.d.ts.map +1 -0
- package/lib/typescript/trust/errors.d.ts +102 -0
- package/lib/typescript/trust/errors.d.ts.map +1 -0
- package/lib/typescript/{entity/trust → trust}/index.d.ts +308 -281
- package/lib/typescript/trust/index.d.ts.map +1 -0
- package/lib/typescript/{entity/trust → trust}/types.d.ts +1714 -1301
- package/lib/typescript/{entity/trust → trust}/types.d.ts.map +1 -1
- package/lib/typescript/trust/utils.d.ts +22 -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 +60 -102
- package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
- package/package.json +9 -10
- 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/README.md +147 -0
- package/src/trust/chain.ts +227 -0
- package/src/trust/errors.ts +136 -0
- package/src/{entity/trust → trust}/index.ts +207 -25
- package/src/{entity/trust → trust}/types.ts +24 -37
- package/src/trust/utils.ts +70 -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 +0 -122
- 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 +0 -26
- 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,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>
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { IoWalletError, serializeAttrs } from "../../utils/errors";
|
2
|
+
export { DcqlError } from "dcql";
|
2
3
|
|
3
4
|
/**
|
4
5
|
* An error subclass thrown when auth request decode fail
|
@@ -41,18 +42,33 @@ export class NoSuitableKeysFoundInEntityConfiguration extends IoWalletError {
|
|
41
42
|
}
|
42
43
|
|
43
44
|
/**
|
44
|
-
* When
|
45
|
+
* When a QR code is not valid.
|
45
46
|
*
|
46
47
|
*/
|
47
|
-
export class
|
48
|
-
code = "
|
48
|
+
export class InvalidQRCodeError extends IoWalletError {
|
49
|
+
code = "ERR_INVALID_QR_CODE";
|
50
|
+
|
51
|
+
/** Detailed reason for the QR code validation failure. */
|
52
|
+
reason: string;
|
49
53
|
|
50
|
-
/**
|
51
|
-
* @param reason A description of why the entity cannot be verified.
|
52
|
-
*/
|
53
54
|
constructor(reason: string) {
|
54
|
-
|
55
|
+
super("Invalid QR code");
|
56
|
+
this.reason = reason;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
/**
|
61
|
+
* When the Request Object sent by the Relying Party is not valid
|
62
|
+
*/
|
63
|
+
export class InvalidRequestObjectError extends IoWalletError {
|
64
|
+
code = "ERR_INVALID_REQUEST_OBJECT";
|
65
|
+
|
66
|
+
/** Detailed reason for the Request Object validation failure. */
|
67
|
+
reason: string;
|
68
|
+
|
69
|
+
constructor(message: string, reason = "unspecified") {
|
55
70
|
super(message);
|
71
|
+
this.reason = reason;
|
56
72
|
}
|
57
73
|
}
|
58
74
|
|
@@ -72,18 +88,25 @@ export class MissingDataError extends IoWalletError {
|
|
72
88
|
}
|
73
89
|
}
|
74
90
|
|
91
|
+
export type NotFoundDetail = {
|
92
|
+
id: string;
|
93
|
+
reason?: string;
|
94
|
+
vctValues?: string[];
|
95
|
+
};
|
96
|
+
|
75
97
|
/**
|
76
|
-
*
|
77
|
-
*
|
98
|
+
* Error thrown when one or more credentials cannot be found in the wallet
|
99
|
+
* and the presentation request cannot be satisfied.
|
78
100
|
*/
|
79
|
-
export class
|
80
|
-
code = "
|
101
|
+
export class CredentialsNotFoundError extends IoWalletError {
|
102
|
+
code = "ERR_CREDENTIALS_NOT_FOUND";
|
103
|
+
details: NotFoundDetail[];
|
81
104
|
|
82
105
|
/**
|
83
|
-
* @param
|
106
|
+
* @param details The details of the credentials that could not be found.
|
84
107
|
*/
|
85
|
-
constructor(
|
86
|
-
|
87
|
-
|
108
|
+
constructor(details: NotFoundDetail[]) {
|
109
|
+
super("One or more credentials cannot be found in the wallet");
|
110
|
+
this.details = details;
|
88
111
|
}
|
89
112
|
}
|
@@ -7,14 +7,10 @@ import {
|
|
7
7
|
getRequestObject,
|
8
8
|
type GetRequestObject,
|
9
9
|
} from "./03-get-request-object";
|
10
|
+
import { getJwksFromConfig, type FetchJwks } from "./04-retrieve-rp-jwks";
|
10
11
|
import {
|
11
|
-
|
12
|
-
|
13
|
-
type FetchJwks,
|
14
|
-
} from "./04-retrieve-rp-jwks";
|
15
|
-
import {
|
16
|
-
verifyRequestObjectSignature,
|
17
|
-
type VerifyRequestObjectSignature,
|
12
|
+
verifyRequestObject,
|
13
|
+
type VerifyRequestObject,
|
18
14
|
} from "./05-verify-request-object";
|
19
15
|
import {
|
20
16
|
fetchPresentDefinition,
|
@@ -22,38 +18,40 @@ import {
|
|
22
18
|
} from "./06-fetch-presentation-definition";
|
23
19
|
import {
|
24
20
|
evaluateInputDescriptors,
|
21
|
+
prepareLegacyRemotePresentations,
|
25
22
|
type EvaluateInputDescriptors,
|
23
|
+
type PrepareLegacyRemotePresentations,
|
26
24
|
} from "./07-evaluate-input-descriptor";
|
27
25
|
import {
|
28
26
|
evaluateDcqlQuery,
|
27
|
+
prepareRemotePresentations,
|
29
28
|
type EvaluateDcqlQuery,
|
29
|
+
type PrepareRemotePresentations,
|
30
30
|
} from "./07-evaluate-dcql-query";
|
31
31
|
import {
|
32
|
-
prepareRemotePresentations,
|
33
32
|
sendAuthorizationResponse,
|
34
33
|
type SendAuthorizationResponse,
|
34
|
+
sendLegacyAuthorizationResponse,
|
35
|
+
type SendLegacyAuthorizationResponse,
|
35
36
|
sendAuthorizationErrorResponse,
|
36
37
|
type SendAuthorizationErrorResponse,
|
37
|
-
sendAuthorizationResponseDcql,
|
38
|
-
type SendAuthorizationResponseDcql,
|
39
38
|
} from "./08-send-authorization-response";
|
40
39
|
import * as Errors from "./errors";
|
41
|
-
import type { PrepareRemotePresentations } from "./types";
|
42
40
|
|
43
41
|
export {
|
44
42
|
startFlowFromQR,
|
45
43
|
evaluateRelyingPartyTrust,
|
46
44
|
getRequestObject,
|
47
|
-
|
48
|
-
|
49
|
-
verifyRequestObjectSignature,
|
45
|
+
getJwksFromConfig,
|
46
|
+
verifyRequestObject,
|
50
47
|
fetchPresentDefinition,
|
51
48
|
evaluateInputDescriptors,
|
52
49
|
evaluateDcqlQuery,
|
50
|
+
prepareLegacyRemotePresentations,
|
51
|
+
prepareRemotePresentations,
|
53
52
|
sendAuthorizationResponse,
|
53
|
+
sendLegacyAuthorizationResponse,
|
54
54
|
sendAuthorizationErrorResponse,
|
55
|
-
sendAuthorizationResponseDcql,
|
56
|
-
prepareRemotePresentations,
|
57
55
|
Errors,
|
58
56
|
};
|
59
57
|
export type {
|
@@ -61,12 +59,13 @@ export type {
|
|
61
59
|
EvaluateRelyingPartyTrust,
|
62
60
|
GetRequestObject,
|
63
61
|
FetchJwks,
|
64
|
-
|
62
|
+
VerifyRequestObject,
|
65
63
|
FetchPresentationDefinition,
|
66
64
|
EvaluateInputDescriptors,
|
65
|
+
EvaluateDcqlQuery,
|
66
|
+
PrepareLegacyRemotePresentations,
|
67
67
|
PrepareRemotePresentations,
|
68
68
|
SendAuthorizationResponse,
|
69
|
-
|
69
|
+
SendLegacyAuthorizationResponse,
|
70
70
|
SendAuthorizationErrorResponse,
|
71
|
-
EvaluateDcqlQuery,
|
72
71
|
};
|
@@ -1,58 +1,38 @@
|
|
1
1
|
import type { CryptoContext } from "@pagopa/io-react-native-jwt";
|
2
2
|
import { UnixTime } from "../../sd-jwt/types";
|
3
3
|
import * as z from "zod";
|
4
|
-
import { JWKS } from "../../utils/jwk";
|
5
|
-
|
6
|
-
export type EvaluatedDisclosure = {
|
7
|
-
namespace?: string;
|
8
|
-
name: string;
|
9
|
-
value: unknown;
|
10
|
-
};
|
11
|
-
|
12
|
-
export type CredentialFormat =
|
13
|
-
| {
|
14
|
-
format: "vc+sd-jwt";
|
15
|
-
}
|
16
|
-
| {
|
17
|
-
format: "mso_mdoc";
|
18
|
-
doctype: string;
|
19
|
-
};
|
20
4
|
|
21
5
|
/**
|
22
6
|
* A pair that associate a tokenized Verified Credential with the claims presented or requested to present.
|
23
7
|
*/
|
24
8
|
export type Presentation = [
|
25
9
|
/* verified credential token */ string,
|
26
|
-
/* claims */
|
10
|
+
/* claims */ string[],
|
27
11
|
/* the context for the key associated to the credential */ CryptoContext,
|
28
12
|
];
|
29
13
|
|
30
14
|
/**
|
31
15
|
* A object that associate the information needed to multiple remote presentation
|
16
|
+
* Used with `presentation_definition`
|
17
|
+
* @deprecated Use `RemotePresentation`
|
32
18
|
*/
|
33
|
-
export type
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
vpToken: string;
|
39
|
-
}[];
|
40
|
-
generatedNonce?: string /* nonce generated by app, used in mdoc presentation */;
|
19
|
+
export type LegacyRemotePresentation = {
|
20
|
+
requestedClaims: string[];
|
21
|
+
inputDescriptor: InputDescriptor;
|
22
|
+
format: string;
|
23
|
+
vpToken: string;
|
41
24
|
};
|
42
25
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
responseUri: string;
|
54
|
-
}
|
55
|
-
) => Promise<RemotePresentation>;
|
26
|
+
/**
|
27
|
+
* A object that associate the information needed to multiple remote presentation
|
28
|
+
* Used with DCQL queries
|
29
|
+
*/
|
30
|
+
export type RemotePresentation = {
|
31
|
+
requestedClaims: string[];
|
32
|
+
credentialId: string;
|
33
|
+
format: string;
|
34
|
+
vpToken: string;
|
35
|
+
};
|
56
36
|
|
57
37
|
const Fields = z.object({
|
58
38
|
path: z.array(z.string().min(1)), // Array of JSONPath string expressions
|
@@ -111,57 +91,80 @@ export const PresentationDefinition = z.object({
|
|
111
91
|
|
112
92
|
export type RequestObject = z.infer<typeof RequestObject>;
|
113
93
|
export const RequestObject = z.object({
|
114
|
-
iss: z.string()
|
115
|
-
iat: UnixTime
|
116
|
-
exp: UnixTime
|
94
|
+
iss: z.string(),
|
95
|
+
iat: UnixTime,
|
96
|
+
exp: UnixTime,
|
117
97
|
state: z.string().optional(),
|
118
98
|
nonce: z.string(),
|
119
99
|
response_uri: z.string(),
|
100
|
+
response_uri_method: z.string().optional(),
|
120
101
|
response_type: z.literal("vp_token"),
|
121
|
-
response_mode: z.
|
102
|
+
response_mode: z.literal("direct_post.jwt"),
|
122
103
|
client_id: z.string(),
|
123
|
-
client_id_scheme: z.string().optional(), // previous z.literal("entity_id"),
|
124
|
-
client_metadata: z
|
125
|
-
.object({
|
126
|
-
authorization_encrypted_response_alg: z.string().optional(),
|
127
|
-
authorization_encrypted_response_enc: z.string().optional(),
|
128
|
-
jwks_uri: z.string().optional(),
|
129
|
-
jwks: JWKS.optional(),
|
130
|
-
})
|
131
|
-
.optional(), // previous z.literal("entity_id"),
|
132
104
|
dcql_query: z.record(z.string(), z.any()).optional(), // Validation happens within the `dcql` library, no need to duplicate it here
|
133
105
|
scope: z.string().optional(),
|
134
106
|
presentation_definition: PresentationDefinition.optional(),
|
135
107
|
});
|
136
108
|
|
109
|
+
export type WalletMetadata = z.infer<typeof WalletMetadata>;
|
110
|
+
export const WalletMetadata = z.object({
|
111
|
+
presentation_definition_uri_supported: z.boolean().optional(),
|
112
|
+
client_id_schemes_supported: z.array(z.string()).optional(),
|
113
|
+
request_object_signing_alg_values_supported: z.array(z.string()).optional(),
|
114
|
+
vp_formats_supported: z.record(
|
115
|
+
z.string(), // TODO [SIW-2110]: use explicit credential format?
|
116
|
+
z.object({
|
117
|
+
"sd-jwt_alg_values": z.array(z.string()).optional(), // alg_values_supported?
|
118
|
+
})
|
119
|
+
),
|
120
|
+
// TODO [SIW-2110]: include other metadata?
|
121
|
+
});
|
122
|
+
|
123
|
+
/**
|
124
|
+
* Wallet capabilities that must be submitted to get the Request Object
|
125
|
+
* via POST request when the `request_uri_method` is `post`.
|
126
|
+
*/
|
127
|
+
export type RequestObjectWalletCapabilities = z.infer<
|
128
|
+
typeof RequestObjectWalletCapabilities
|
129
|
+
>;
|
130
|
+
export const RequestObjectWalletCapabilities = z.object({
|
131
|
+
wallet_metadata: WalletMetadata,
|
132
|
+
wallet_nonce: z.string().optional(),
|
133
|
+
});
|
134
|
+
|
137
135
|
/**
|
138
136
|
* This type models the possible error responses the OpenID4VP protocol allows for a presentation of a credential.
|
139
|
-
*
|
137
|
+
* When the Wallet encounters one of these errors, it will notify the Relying Party through the `response_uri` endpoint.
|
138
|
+
* See https://italia.github.io/eid-wallet-it-docs/versione-corrente/en/pid-eaa-presentation.html#authorization-response-errors for more information.
|
140
139
|
*/
|
141
140
|
export type ErrorResponse = z.infer<typeof ErrorResponse>;
|
142
141
|
export const ErrorResponse = z.enum([
|
143
|
-
"
|
142
|
+
"invalid_request_object",
|
143
|
+
"invalid_request_uri",
|
144
|
+
"vp_formats_not_supported",
|
144
145
|
"invalid_request",
|
145
|
-
"invalid_client",
|
146
146
|
"access_denied",
|
147
|
+
"invalid_client",
|
147
148
|
]);
|
148
149
|
|
149
150
|
/**
|
150
|
-
*
|
151
|
+
* @deprecated Use `DirectAuthorizationBodyPayload`
|
152
|
+
*/
|
153
|
+
const LegacyDirectAuthorizationBodyPayload = z.object({
|
154
|
+
vp_token: z.union([z.string(), z.array(z.string())]).optional(),
|
155
|
+
presentation_submission: z.record(z.string(), z.unknown()),
|
156
|
+
});
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Authorization Response payload sent to the Relying Party.
|
151
160
|
*/
|
152
161
|
export type DirectAuthorizationBodyPayload = z.infer<
|
153
162
|
typeof DirectAuthorizationBodyPayload
|
154
163
|
>;
|
155
164
|
export const DirectAuthorizationBodyPayload = z.union([
|
156
165
|
z.object({
|
157
|
-
vp_token: z
|
158
|
-
.union([
|
159
|
-
z.string(), // Presentation Definition with one credential
|
160
|
-
z.array(z.string()), // Presentation Definition with more credential
|
161
|
-
z.record(z.string(), z.string()), // DCQL query
|
162
|
-
])
|
163
|
-
.optional(),
|
164
|
-
presentation_submission: z.record(z.string(), z.unknown()).optional(),
|
166
|
+
vp_token: z.record(z.string(), z.string()),
|
165
167
|
}),
|
166
|
-
z.object({ error: ErrorResponse }),
|
168
|
+
z.object({ error: ErrorResponse, error_description: z.string() }),
|
169
|
+
LegacyDirectAuthorizationBodyPayload,
|
167
170
|
]);
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* WARNING: This is the first function to be called in the status attestation flow. The next function to be called is {@link statusAttestation}.
|
3
|
+
* The beginning of the status attestation flow.
|
4
|
+
*
|
5
|
+
* @returns The url of the credential issuer to be used in the next function.
|
6
|
+
*/
|
7
|
+
export type StartFlow = () => {
|
8
|
+
issuerUrl: string;
|
9
|
+
};
|
@@ -0,0 +1,105 @@
|
|
1
|
+
import {
|
2
|
+
getCredentialHashWithouDiscloures,
|
3
|
+
hasStatusOrThrow,
|
4
|
+
type Out,
|
5
|
+
} from "../../utils/misc";
|
6
|
+
import type { EvaluateIssuerTrust, ObtainCredential } from "../issuance";
|
7
|
+
import { type CryptoContext, SignJWT } from "@pagopa/io-react-native-jwt";
|
8
|
+
import { v4 as uuidv4 } from "uuid";
|
9
|
+
import { StatusAttestationResponse } from "./types";
|
10
|
+
import {
|
11
|
+
IssuerResponseError,
|
12
|
+
IssuerResponseErrorCodes,
|
13
|
+
ResponseErrorBuilder,
|
14
|
+
UnexpectedStatusCodeError,
|
15
|
+
} from "../../utils/errors";
|
16
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
17
|
+
|
18
|
+
export type StatusAttestation = (
|
19
|
+
issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
|
20
|
+
credential: Out<ObtainCredential>["credential"],
|
21
|
+
credentialCryptoContext: CryptoContext,
|
22
|
+
appFetch?: GlobalFetch["fetch"]
|
23
|
+
) => Promise<{
|
24
|
+
statusAttestation: StatusAttestationResponse["status_attestation"];
|
25
|
+
}>;
|
26
|
+
|
27
|
+
/**
|
28
|
+
* WARNING: This function must be called after {@link startFlow}.
|
29
|
+
* Verify the status of the credential attestation.
|
30
|
+
* @param issuerConf - The issuer's configuration
|
31
|
+
* @param credential - The credential to be verified
|
32
|
+
* @param credentialCryptoContext - The credential's crypto context
|
33
|
+
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
34
|
+
* @throws {IssuerResponseError} with a specific code for more context
|
35
|
+
* @returns The credential status attestation
|
36
|
+
*/
|
37
|
+
export const statusAttestation: StatusAttestation = async (
|
38
|
+
issuerConf,
|
39
|
+
credential,
|
40
|
+
credentialCryptoContext,
|
41
|
+
appFetch: GlobalFetch["fetch"] = fetch
|
42
|
+
) => {
|
43
|
+
const jwk = await credentialCryptoContext.getPublicKey();
|
44
|
+
const credentialHash = await getCredentialHashWithouDiscloures(credential);
|
45
|
+
const statusAttUrl =
|
46
|
+
issuerConf.openid_credential_issuer.status_attestation_endpoint;
|
47
|
+
const credentialPop = await new SignJWT(credentialCryptoContext)
|
48
|
+
.setPayload({
|
49
|
+
aud: statusAttUrl,
|
50
|
+
jti: uuidv4().toString(),
|
51
|
+
credential_hash: credentialHash,
|
52
|
+
credential_hash_alg: "S256",
|
53
|
+
})
|
54
|
+
.setProtectedHeader({
|
55
|
+
alg: "ES256",
|
56
|
+
typ: "status-attestation-request+jwt",
|
57
|
+
kid: jwk.kid,
|
58
|
+
})
|
59
|
+
.setIssuedAt()
|
60
|
+
.setExpirationTime("5m")
|
61
|
+
.sign();
|
62
|
+
|
63
|
+
const body = {
|
64
|
+
credential_pop: credentialPop,
|
65
|
+
};
|
66
|
+
|
67
|
+
Logger.log(LogLevel.DEBUG, `Credential pop: ${credentialPop}`);
|
68
|
+
|
69
|
+
const result = await appFetch(statusAttUrl, {
|
70
|
+
method: "POST",
|
71
|
+
headers: {
|
72
|
+
"Content-Type": "application/json",
|
73
|
+
},
|
74
|
+
body: JSON.stringify(body),
|
75
|
+
})
|
76
|
+
.then(hasStatusOrThrow(201))
|
77
|
+
.then((raw) => raw.json())
|
78
|
+
.then((json) => StatusAttestationResponse.parse(json))
|
79
|
+
.catch(handleStatusAttestationError);
|
80
|
+
|
81
|
+
return { statusAttestation: result.status_attestation };
|
82
|
+
};
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Handle the status attestation error by mapping it to a custom exception.
|
86
|
+
* If the error is not an instance of {@link UnexpectedStatusCodeError}, it is thrown as is.
|
87
|
+
* @param e - The error to be handled
|
88
|
+
* @throws {IssuerResponseError} with a specific code for more context
|
89
|
+
*/
|
90
|
+
const handleStatusAttestationError = (e: unknown) => {
|
91
|
+
if (!(e instanceof UnexpectedStatusCodeError)) {
|
92
|
+
throw e;
|
93
|
+
}
|
94
|
+
|
95
|
+
throw new ResponseErrorBuilder(IssuerResponseError)
|
96
|
+
.handle(404, {
|
97
|
+
code: IssuerResponseErrorCodes.CredentialInvalidStatus,
|
98
|
+
message: "Invalid status found for the given credential",
|
99
|
+
})
|
100
|
+
.handle("*", {
|
101
|
+
code: IssuerResponseErrorCodes.StatusAttestationRequestFailed,
|
102
|
+
message: `Unable to obtain the status attestation for the given credential`,
|
103
|
+
})
|
104
|
+
.buildFrom(e);
|
105
|
+
};
|