@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,25 +1,18 @@
|
|
1
1
|
import type { CryptoContext } from "@pagopa/io-react-native-jwt";
|
2
|
-
import { CBOR } from "@pagopa/io-react-native-cbor";
|
3
2
|
import type { Out } from "../../utils/misc";
|
4
|
-
import type {
|
3
|
+
import type { EvaluateIssuerTrust } from "./02-evaluate-issuer-trust";
|
5
4
|
import { IoWalletError } from "../../utils/errors";
|
6
5
|
import { SdJwt4VC } from "../../sd-jwt/types";
|
7
6
|
import { verify as verifySdJwt } from "../../sd-jwt";
|
8
|
-
import { verify as verifyMdoc } from "../../mdoc";
|
9
7
|
import { getValueFromDisclosures } from "../../sd-jwt/converters";
|
10
8
|
import type { JWK } from "../../utils/jwk";
|
11
9
|
import type { ObtainCredential } from "./06-obtain-credential";
|
12
|
-
import {
|
13
|
-
CredentialSdJwtClaims,
|
14
|
-
CredentialClaim,
|
15
|
-
} from "../../entity/openid-connect/issuer/types";
|
16
|
-
import { extractElementValueAsDate } from "../../mdoc/converters";
|
10
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
17
11
|
|
18
12
|
export type VerifyAndParseCredential = (
|
19
|
-
issuerConf: Out<
|
13
|
+
issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
|
20
14
|
credential: Out<ObtainCredential>["credential"],
|
21
15
|
format: Out<ObtainCredential>["format"],
|
22
|
-
credentialType: string,
|
23
16
|
context: {
|
24
17
|
credentialCryptoContext: CryptoContext;
|
25
18
|
/**
|
@@ -60,14 +53,9 @@ type DecodedSdJwtCredential = Out<typeof verifySdJwt> & {
|
|
60
53
|
sdJwt: SdJwt4VC;
|
61
54
|
};
|
62
55
|
|
63
|
-
|
64
|
-
issuerSigned: CBOR.IssuerSigned;
|
65
|
-
};
|
66
|
-
|
67
|
-
//Exported for testing purposes
|
68
|
-
export const parseCredentialSdJwt = (
|
56
|
+
const parseCredentialSdJwt = (
|
69
57
|
// the list of supported credentials, as defined in the issuer configuration
|
70
|
-
credentials_supported: Out<
|
58
|
+
credentials_supported: Out<EvaluateIssuerTrust>["issuerConf"]["openid_credential_issuer"]["credential_configurations_supported"],
|
71
59
|
{ sdJwt, disclosures }: DecodedSdJwtCredential,
|
72
60
|
ignoreMissingAttributes: boolean = false,
|
73
61
|
includeUndefinedAttributes: boolean = false
|
@@ -75,10 +63,18 @@ export const parseCredentialSdJwt = (
|
|
75
63
|
const credentialSubject = credentials_supported[sdJwt.payload.vct];
|
76
64
|
|
77
65
|
if (!credentialSubject) {
|
66
|
+
Logger.log(
|
67
|
+
LogLevel.ERROR,
|
68
|
+
`Credential type not supported by the issuer: ${sdJwt.payload.vct}`
|
69
|
+
);
|
78
70
|
throw new IoWalletError("Credential type not supported by the issuer");
|
79
71
|
}
|
80
72
|
|
81
73
|
if (credentialSubject.format !== sdJwt.header.typ) {
|
74
|
+
Logger.log(
|
75
|
+
LogLevel.ERROR,
|
76
|
+
`Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}'`
|
77
|
+
);
|
82
78
|
throw new IoWalletError(
|
83
79
|
`Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}', `
|
84
80
|
);
|
@@ -86,20 +82,23 @@ export const parseCredentialSdJwt = (
|
|
86
82
|
|
87
83
|
// transfrom a record { key: value } in an iterable of pairs [key, value]
|
88
84
|
if (!credentialSubject.claims) {
|
85
|
+
Logger.log(LogLevel.ERROR, "Missing claims in the credential subject");
|
89
86
|
throw new IoWalletError("Missing claims in the credential subject"); // TODO [SIW-1268]: should not be optional
|
90
87
|
}
|
91
|
-
const
|
92
|
-
const attrDefinitions = Object.entries(claims);
|
88
|
+
const attrDefinitions = Object.entries(credentialSubject.claims);
|
93
89
|
|
94
90
|
// the key of the attribute defintion must match the disclosure's name
|
95
91
|
const attrsNotInDisclosures = attrDefinitions.filter(
|
96
|
-
([attrKey,
|
97
|
-
!disclosures.some(([, name]) => name === attrKey) && definition.mandatory
|
92
|
+
([attrKey]) => !disclosures.some(([, name]) => name === attrKey)
|
98
93
|
);
|
99
94
|
if (attrsNotInDisclosures.length > 0) {
|
100
95
|
const missing = attrsNotInDisclosures.map((_) => _[0 /* key */]).join(", ");
|
101
96
|
const received = disclosures.map((_) => _[1 /* name */]).join(", ");
|
102
97
|
if (!ignoreMissingAttributes) {
|
98
|
+
Logger.log(
|
99
|
+
LogLevel.ERROR,
|
100
|
+
`Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`
|
101
|
+
);
|
103
102
|
throw new IoWalletError(
|
104
103
|
`Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`
|
105
104
|
);
|
@@ -123,8 +122,6 @@ export const parseCredentialSdJwt = (
|
|
123
122
|
},
|
124
123
|
] as const
|
125
124
|
)
|
126
|
-
//filter the not found elements
|
127
|
-
.filter(([_, definition]) => definition.value !== undefined)
|
128
125
|
// add a human readable attribute name, with i18n, in the form { locale: name }
|
129
126
|
// example: { "it-IT": "Nome", "en-EN": "Name", "es-ES": "Nombre" }
|
130
127
|
.map(
|
@@ -159,136 +156,6 @@ export const parseCredentialSdJwt = (
|
|
159
156
|
return definedValues;
|
160
157
|
};
|
161
158
|
|
162
|
-
//Exported for testing purposes
|
163
|
-
export const parseCredentialMDoc = (
|
164
|
-
// the list of supported credentials, as defined in the issuer configuration
|
165
|
-
credentials_supported: Out<GetIssuerConfig>["issuerConf"]["credential_configurations_supported"],
|
166
|
-
credential_type: string,
|
167
|
-
{ issuerSigned }: DecodedMDocCredential,
|
168
|
-
ignoreMissingAttributes: boolean = false,
|
169
|
-
includeUndefinedAttributes: boolean = false
|
170
|
-
): ParsedCredential => {
|
171
|
-
const credentialSubject = credentials_supported[credential_type];
|
172
|
-
|
173
|
-
if (!credentialSubject) {
|
174
|
-
throw new IoWalletError("Credential type not supported by the issuer");
|
175
|
-
}
|
176
|
-
|
177
|
-
// transfrom a record { key: value } in an iterable of pairs [key, value]
|
178
|
-
if (!credentialSubject.claims) {
|
179
|
-
throw new IoWalletError("Missing claims in the credential subject"); // TODO [SIW-1268]: should not be optional
|
180
|
-
}
|
181
|
-
|
182
|
-
const claims = credentialSubject.claims as Record<
|
183
|
-
string,
|
184
|
-
CredentialSdJwtClaims
|
185
|
-
>;
|
186
|
-
|
187
|
-
const attrDefinitions: [string, string, CredentialClaim][] = Object.entries(
|
188
|
-
claims
|
189
|
-
).flatMap(([namespace, claimName]) =>
|
190
|
-
Object.entries(claimName).map(
|
191
|
-
([claimNameKey, definition]) =>
|
192
|
-
[namespace, claimNameKey, definition] as [
|
193
|
-
string,
|
194
|
-
string,
|
195
|
-
CredentialClaim,
|
196
|
-
]
|
197
|
-
)
|
198
|
-
);
|
199
|
-
|
200
|
-
if (!issuerSigned.nameSpaces) {
|
201
|
-
throw new IoWalletError("Missing claims in the credential");
|
202
|
-
}
|
203
|
-
|
204
|
-
const flatNamespaces: [string, string, string][] = Object.entries(
|
205
|
-
issuerSigned.nameSpaces
|
206
|
-
).flatMap(([namespace, values]) =>
|
207
|
-
values.map(
|
208
|
-
(v) =>
|
209
|
-
[namespace, v.elementIdentifier, v.elementValue] as [
|
210
|
-
string,
|
211
|
-
string,
|
212
|
-
string,
|
213
|
-
]
|
214
|
-
)
|
215
|
-
);
|
216
|
-
|
217
|
-
// Check that all mandatory attributes defined in the issuer configuration are present in the disclosure set
|
218
|
-
// and filter the non present ones
|
219
|
-
const attrsNotInDisclosures = attrDefinitions.filter(
|
220
|
-
([attrDefNamespace, attrKey, definition]) => {
|
221
|
-
const isClaimPresent = flatNamespaces.find(
|
222
|
-
([namespace, name]) =>
|
223
|
-
attrDefNamespace === namespace && name === attrKey
|
224
|
-
);
|
225
|
-
return isClaimPresent === undefined && definition.mandatory;
|
226
|
-
}
|
227
|
-
);
|
228
|
-
if (attrsNotInDisclosures.length > 0) {
|
229
|
-
const missing = attrsNotInDisclosures
|
230
|
-
.map((_) => _[1 /* claim key */])
|
231
|
-
.join(", ");
|
232
|
-
const received = flatNamespaces.map((_) => _[1 /*name*/]);
|
233
|
-
if (!ignoreMissingAttributes) {
|
234
|
-
throw new IoWalletError(
|
235
|
-
`Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`
|
236
|
-
);
|
237
|
-
}
|
238
|
-
}
|
239
|
-
|
240
|
-
// Attributes defined in the issuer configuration and present in the disclosure set
|
241
|
-
const definedValues = Object.fromEntries(
|
242
|
-
attrDefinitions
|
243
|
-
// Retrieve the value from the corresponding disclosure
|
244
|
-
.map(
|
245
|
-
([attrDefNamespace, attrKey, definition]) =>
|
246
|
-
[
|
247
|
-
attrKey,
|
248
|
-
{
|
249
|
-
...definition,
|
250
|
-
value: flatNamespaces.find(
|
251
|
-
([namespace, name]) =>
|
252
|
-
attrDefNamespace === namespace && name === attrKey
|
253
|
-
)?.[2],
|
254
|
-
},
|
255
|
-
] as const
|
256
|
-
)
|
257
|
-
//filter the not found elements
|
258
|
-
.filter(([_, definition]) => definition.value !== undefined)
|
259
|
-
// Add a human-readable attribute name, with i18n, in the form { locale: name }
|
260
|
-
// Example: { "it-IT": "Nome", "en-EN": "Name", "es-ES": "Nombre" }
|
261
|
-
.map(
|
262
|
-
([attrKey, { display, ...definition }]) =>
|
263
|
-
[
|
264
|
-
attrKey,
|
265
|
-
{
|
266
|
-
...definition,
|
267
|
-
name: display.reduce(
|
268
|
-
(names, { locale, name }) => ({ ...names, [locale]: name }),
|
269
|
-
{} as Record<string, string>
|
270
|
-
),
|
271
|
-
},
|
272
|
-
] as const
|
273
|
-
)
|
274
|
-
);
|
275
|
-
|
276
|
-
if (includeUndefinedAttributes) {
|
277
|
-
// Attributes that are present in the disclosure set but not defined in the issuer configuration
|
278
|
-
const undefinedValues = Object.fromEntries(
|
279
|
-
flatNamespaces
|
280
|
-
.filter(([, key]) => !Object.keys(definedValues).includes(key))
|
281
|
-
.map(([, key, value]) => [key, { value, name: key }])
|
282
|
-
);
|
283
|
-
return {
|
284
|
-
...definedValues,
|
285
|
-
...undefinedValues,
|
286
|
-
};
|
287
|
-
}
|
288
|
-
|
289
|
-
return definedValues;
|
290
|
-
};
|
291
|
-
|
292
159
|
/**
|
293
160
|
* Given a credential, verify it's in the supported format
|
294
161
|
* and the credential is correctly signed
|
@@ -319,6 +186,10 @@ async function verifyCredentialSdJwt(
|
|
319
186
|
const { cnf } = decodedCredential.sdJwt.payload;
|
320
187
|
|
321
188
|
if (!cnf.jwk.kid || cnf.jwk.kid !== holderBindingKey.kid) {
|
189
|
+
Logger.log(
|
190
|
+
LogLevel.ERROR,
|
191
|
+
`Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`
|
192
|
+
);
|
322
193
|
throw new IoWalletError(
|
323
194
|
`Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`
|
324
195
|
);
|
@@ -327,72 +198,18 @@ async function verifyCredentialSdJwt(
|
|
327
198
|
return decodedCredential;
|
328
199
|
}
|
329
200
|
|
330
|
-
/**
|
331
|
-
* Given a credential, verify it's in the supported format
|
332
|
-
* and the credential is correctly signed
|
333
|
-
* and it's bound to the given key
|
334
|
-
*
|
335
|
-
* @param rawCredential The received credential
|
336
|
-
* @param issuerKeys The set of public keys of the issuer,
|
337
|
-
* which will be used to verify the signature
|
338
|
-
* @param holderBindingContext The access to the holder's key
|
339
|
-
*
|
340
|
-
* @throws If the signature verification fails
|
341
|
-
* @throws If the credential is not in the SdJwt4VC format
|
342
|
-
* @throws If the holder binding is not properly configured
|
343
|
-
*
|
344
|
-
*/
|
345
|
-
async function verifyCredentialMDoc(
|
346
|
-
rawCredential: string,
|
347
|
-
issuerKeys: JWK[],
|
348
|
-
holderBindingContext: CryptoContext
|
349
|
-
): Promise<DecodedMDocCredential> {
|
350
|
-
/**
|
351
|
-
* For the moment, being that issues in the crypto key generation
|
352
|
-
* have been found on Android, the check for the deviceKey inside
|
353
|
-
* of the mDoc is skipped, so we are not interested in the holderBindingKey
|
354
|
-
*/
|
355
|
-
const [decodedCredential, _] =
|
356
|
-
// parallel for optimization
|
357
|
-
await Promise.all([
|
358
|
-
verifyMdoc(rawCredential, issuerKeys),
|
359
|
-
holderBindingContext.getPublicKey(),
|
360
|
-
]);
|
361
|
-
|
362
|
-
if (!decodedCredential) {
|
363
|
-
throw new IoWalletError("No MDOC credentials found!");
|
364
|
-
}
|
365
|
-
|
366
|
-
/**
|
367
|
-
* For the moment, being that issues in the crypto key generation
|
368
|
-
* have been found on Android, the check for the deviceKey inside
|
369
|
-
* of the mDoc is skipped.
|
370
|
-
*/
|
371
|
-
//const key = decodedCredential.mDoc.issuerSigned.issuerAuth.payload.deviceKeyInfo.deviceKey;
|
372
|
-
//
|
373
|
-
//if (!compareKeysByThumbprint(key, holderBindingKey as PublicKey)) {
|
374
|
-
// throw new IoWalletError(
|
375
|
-
// `Failed to verify holder binding, holder binding key and mDoc deviceKey don't match`
|
376
|
-
// );
|
377
|
-
//}
|
378
|
-
|
379
|
-
return decodedCredential;
|
380
|
-
}
|
381
|
-
|
382
201
|
// utility type that specialize VerifyAndParseCredential for given format
|
383
202
|
type WithFormat<Format extends Parameters<VerifyAndParseCredential>[2]> = (
|
384
203
|
_0: Parameters<VerifyAndParseCredential>[0],
|
385
204
|
_1: Parameters<VerifyAndParseCredential>[1],
|
386
205
|
_2: Format,
|
387
|
-
_3: Parameters<VerifyAndParseCredential>[3]
|
388
|
-
_4: Parameters<VerifyAndParseCredential>[4]
|
206
|
+
_3: Parameters<VerifyAndParseCredential>[3]
|
389
207
|
) => ReturnType<VerifyAndParseCredential>;
|
390
208
|
|
391
209
|
const verifyAndParseCredentialSdJwt: WithFormat<"vc+sd-jwt"> = async (
|
392
210
|
issuerConf,
|
393
211
|
credential,
|
394
212
|
_,
|
395
|
-
__,
|
396
213
|
{
|
397
214
|
credentialCryptoContext,
|
398
215
|
ignoreMissingAttributes,
|
@@ -401,19 +218,25 @@ const verifyAndParseCredentialSdJwt: WithFormat<"vc+sd-jwt"> = async (
|
|
401
218
|
) => {
|
402
219
|
const decoded = await verifyCredentialSdJwt(
|
403
220
|
credential,
|
404
|
-
issuerConf.keys,
|
221
|
+
issuerConf.openid_credential_issuer.jwks.keys,
|
405
222
|
credentialCryptoContext
|
406
223
|
);
|
407
224
|
|
225
|
+
Logger.log(LogLevel.DEBUG, `Decoded credential: ${JSON.stringify(decoded)}`);
|
226
|
+
|
408
227
|
const parsedCredential = parseCredentialSdJwt(
|
409
|
-
issuerConf.credential_configurations_supported,
|
228
|
+
issuerConf.openid_credential_issuer.credential_configurations_supported,
|
410
229
|
decoded,
|
411
230
|
ignoreMissingAttributes,
|
412
231
|
includeUndefinedAttributes
|
413
232
|
);
|
414
|
-
|
415
233
|
const maybeIssuedAt = getValueFromDisclosures(decoded.disclosures, "iat");
|
416
234
|
|
235
|
+
Logger.log(
|
236
|
+
LogLevel.DEBUG,
|
237
|
+
`Parsed credential: ${JSON.stringify(parsedCredential)}\nIssued at: ${maybeIssuedAt}`
|
238
|
+
);
|
239
|
+
|
417
240
|
return {
|
418
241
|
parsedCredential,
|
419
242
|
expiration: new Date(decoded.sdJwt.payload.exp * 1000),
|
@@ -424,50 +247,9 @@ const verifyAndParseCredentialSdJwt: WithFormat<"vc+sd-jwt"> = async (
|
|
424
247
|
};
|
425
248
|
};
|
426
249
|
|
427
|
-
const verifyAndParseCredentialMDoc: WithFormat<"mso_mdoc"> = async (
|
428
|
-
issuerConf,
|
429
|
-
credential,
|
430
|
-
_,
|
431
|
-
credentialType,
|
432
|
-
{ credentialCryptoContext, ignoreMissingAttributes }
|
433
|
-
) => {
|
434
|
-
const decoded = await verifyCredentialMDoc(
|
435
|
-
credential,
|
436
|
-
issuerConf.keys,
|
437
|
-
credentialCryptoContext
|
438
|
-
);
|
439
|
-
|
440
|
-
const parsedCredential = parseCredentialMDoc(
|
441
|
-
issuerConf.credential_configurations_supported,
|
442
|
-
credentialType,
|
443
|
-
decoded,
|
444
|
-
undefined,
|
445
|
-
ignoreMissingAttributes
|
446
|
-
);
|
447
|
-
|
448
|
-
const expirationDate = extractElementValueAsDate(
|
449
|
-
parsedCredential?.expiry_date?.value as string
|
450
|
-
);
|
451
|
-
if (!expirationDate) {
|
452
|
-
throw new IoWalletError(`expirationDate must be present!!`);
|
453
|
-
}
|
454
|
-
expirationDate?.setDate(expirationDate.getDate() + 1);
|
455
|
-
|
456
|
-
const maybeIssuedAt = extractElementValueAsDate(
|
457
|
-
parsedCredential?.issue_date?.value as string
|
458
|
-
);
|
459
|
-
maybeIssuedAt?.setDate(maybeIssuedAt.getDate() + 1);
|
460
|
-
|
461
|
-
return {
|
462
|
-
parsedCredential,
|
463
|
-
expiration: expirationDate ?? new Date(),
|
464
|
-
issuedAt: maybeIssuedAt ?? undefined,
|
465
|
-
};
|
466
|
-
};
|
467
|
-
|
468
250
|
/**
|
469
251
|
* Verify and parse an encoded credential.
|
470
|
-
* @param issuerConf The Issuer configuration returned by {@link
|
252
|
+
* @param issuerConf The Issuer configuration returned by {@link evaluateIssuerTrust}
|
471
253
|
* @param credential The encoded credential returned by {@link obtainCredential}
|
472
254
|
* @param format The format of the credentual returned by {@link obtainCredential}
|
473
255
|
* @param context.credentialCryptoContext The crypto context used to obtain the credential in {@link obtainCredential}
|
@@ -482,27 +264,18 @@ export const verifyAndParseCredential: VerifyAndParseCredential = async (
|
|
482
264
|
issuerConf,
|
483
265
|
credential,
|
484
266
|
format,
|
485
|
-
credentialType,
|
486
267
|
context
|
487
268
|
) => {
|
488
269
|
if (format === "vc+sd-jwt") {
|
270
|
+
Logger.log(LogLevel.DEBUG, "Parsing credential in vc+sd-jwt format");
|
489
271
|
return verifyAndParseCredentialSdJwt(
|
490
272
|
issuerConf,
|
491
273
|
credential,
|
492
274
|
format,
|
493
|
-
credentialType,
|
494
|
-
context
|
495
|
-
);
|
496
|
-
}
|
497
|
-
if (format === "mso_mdoc") {
|
498
|
-
return verifyAndParseCredentialMDoc(
|
499
|
-
issuerConf,
|
500
|
-
credential,
|
501
|
-
format,
|
502
|
-
credentialType,
|
503
275
|
context
|
504
276
|
);
|
505
277
|
}
|
506
278
|
|
279
|
+
Logger.log(LogLevel.ERROR, `Unsupported credential format: ${format}`);
|
507
280
|
throw new IoWalletError(`Unsupported credential format: ${format}`);
|
508
281
|
};
|
@@ -6,7 +6,7 @@ There's a fork in the flow which is based on the type of the credential that is
|
|
6
6
|
This is due to the fact that eID credentials require a different authorization flow than other credentials, which is accomplished by a strong authentication method like SPID or CIE.
|
7
7
|
Credentials instead require a simpler authorization flow and they require other credentials to be presented in order to be issued.
|
8
8
|
|
9
|
-
The supported credentials are defined in the entity configuration of the issuer which is evaluted and parsed in the `
|
9
|
+
The supported credentials are defined in the entity configuration of the issuer which is evaluted and parsed in the `evaluateIssuerTrust` step.
|
10
10
|
|
11
11
|
## Sequence Diagram
|
12
12
|
|
@@ -14,7 +14,7 @@ The supported credentials are defined in the entity configuration of the issuer
|
|
14
14
|
graph TD;
|
15
15
|
0[WalletInstanceAttestation.getAttestation]
|
16
16
|
1[startFlow]
|
17
|
-
2[
|
17
|
+
2[evaluateIssuerTrust]
|
18
18
|
3[startUserAuthorization]
|
19
19
|
C4[getRequestedCredentialToBePresented]
|
20
20
|
C4.1[completeUserAuthorizationWithFormPostJwtMode]
|
@@ -41,9 +41,12 @@ graph TD;
|
|
41
41
|
|
42
42
|
The following errors are mapped to a `IssuerResponseError` with specific codes.
|
43
43
|
|
44
|
-
|
|
45
|
-
|
46
|
-
|
44
|
+
|HTTP Status|Error Code|Description|
|
45
|
+
|-----------|----------|-----------|
|
46
|
+
|`201 Created`|`ERR_CREDENTIAL_ISSUING_NOT_SYNCHRONOUS`| This response is returned by the credential issuer when the request has been queued because the credential cannot be issued synchronously. The consumer should try to obtain the credential at a later time. Although `201 Created` is not considered an error, it is mapped as an error in this context in order to handle the case where the credential issuance is not synchronous. This allows keeping the flow consistent and handle the case where the credential is not immediately available.|
|
47
|
+
|`403 Forbidden`|`ERR_CREDENTIAL_INVALID_STATUS`|This response is returned by the credential issuer when the requested credential has an invalid status. It might contain more details in the `reason` property.|
|
48
|
+
|`404 Not Found`|`ERR_CREDENTIAL_INVALID_STATUS`| This response is returned by the credential issuer when the authenticated user is not entitled to receive the requested credential. It might contain more details in the `reason` property.|
|
49
|
+
|`*`|`ERR_ISSUER_GENERIC_ERROR`|This is a generic error code to map unexpected errors that occurred when interacting with the Issuer.|
|
47
50
|
|
48
51
|
## Strong authentication for eID issuance (Query Mode)
|
49
52
|
|
@@ -105,7 +108,7 @@ const eid = {
|
|
105
108
|
const eidCryptoContext = createCryptoContextFor(eid.keyTag);
|
106
109
|
|
107
110
|
// Create credential crypto context
|
108
|
-
const credentialKeyTag =
|
111
|
+
const credentialKeyTag = uuidv4().toString();
|
109
112
|
await generate(credentialKeyTag); // Let's assume this function generates a new hardware-backed key pair
|
110
113
|
const credentialCryptoContext = createCryptoContextFor(credentialKeyTag);
|
111
114
|
|
@@ -118,7 +121,7 @@ const startFlow: Credential.Issuance.StartFlow = () => ({
|
|
118
121
|
const { issuerUrl } = startFlow();
|
119
122
|
|
120
123
|
// Evaluate issuer trust
|
121
|
-
const { issuerConf } = await Credential.Issuance.
|
124
|
+
const { issuerConf } = await Credential.Issuance.evaluateIssuerTrust(issuerUrl);
|
122
125
|
|
123
126
|
// Start user authorization
|
124
127
|
const { issuerRequestUri, clientId, codeVerifier, credentialDefinition } =
|
@@ -241,23 +244,24 @@ const authorizationContext = idpHint.includes("servizicie")
|
|
241
244
|
* Create credential crypto context for the PID
|
242
245
|
* WARNING: The eID keytag must be persisted and later used when requesting a credential which requires a eID presentation
|
243
246
|
*/
|
244
|
-
const credentialKeyTag =
|
247
|
+
const credentialKeyTag = uuidv4().toString();
|
245
248
|
await generate(credentialKeyTag);
|
246
249
|
const credentialCryptoContext = createCryptoContextFor(credentialKeyTag);
|
247
250
|
|
248
251
|
// Start the issuance flow
|
249
252
|
const startFlow: Credential.Issuance.StartFlow = () => ({
|
250
253
|
issuerUrl: WALLET_EID_PROVIDER_BASE_URL,
|
251
|
-
credentialType: "
|
254
|
+
credentialType: "PersonIdentificationData",
|
252
255
|
appFetch,
|
253
256
|
});
|
254
257
|
|
255
258
|
const { issuerUrl } = startFlow();
|
256
259
|
|
257
260
|
// Evaluate issuer trust
|
258
|
-
const { issuerConf } = await Credential.Issuance.
|
259
|
-
|
260
|
-
}
|
261
|
+
const { issuerConf } = await Credential.Issuance.evaluateIssuerTrust(
|
262
|
+
issuerUrl,
|
263
|
+
{ appFetch }
|
264
|
+
);
|
261
265
|
|
262
266
|
// Start user authorization
|
263
267
|
const { issuerRequestUri, clientId, codeVerifier, credentialDefinition } =
|
@@ -311,13 +315,12 @@ const { credential, format } = await Credential.Issuance.obtainCredential(
|
|
311
315
|
);
|
312
316
|
|
313
317
|
// Parse and verify the eID credential
|
314
|
-
const { parsedCredential, issuedAt, expiration } =
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
);
|
318
|
+
const { parsedCredential, issuedAt, expiration } = await Credential.Issuance.verifyAndParseCredential(
|
319
|
+
issuerConf,
|
320
|
+
credential,
|
321
|
+
format,
|
322
|
+
{ credentialCryptoContext }
|
323
|
+
);
|
321
324
|
|
322
325
|
return {
|
323
326
|
parsedCredential,
|
@@ -325,7 +328,7 @@ return {
|
|
325
328
|
keyTag: credentialKeyTag,
|
326
329
|
credentialType,
|
327
330
|
issuedAt,
|
328
|
-
expiration
|
331
|
+
expiration
|
329
332
|
};
|
330
333
|
```
|
331
334
|
|
@@ -1,5 +1,8 @@
|
|
1
1
|
import { type StartFlow } from "./01-start-flow";
|
2
|
-
import {
|
2
|
+
import {
|
3
|
+
evaluateIssuerTrust,
|
4
|
+
type EvaluateIssuerTrust,
|
5
|
+
} from "./02-evaluate-issuer-trust";
|
3
6
|
import {
|
4
7
|
startUserAuthorization,
|
5
8
|
type StartUserAuthorization,
|
@@ -27,7 +30,7 @@ import {
|
|
27
30
|
import * as Errors from "./errors";
|
28
31
|
|
29
32
|
export {
|
30
|
-
|
33
|
+
evaluateIssuerTrust,
|
31
34
|
startUserAuthorization,
|
32
35
|
buildAuthorizationUrl,
|
33
36
|
completeUserAuthorizationWithQueryMode,
|
@@ -41,7 +44,7 @@ export {
|
|
41
44
|
};
|
42
45
|
export type {
|
43
46
|
StartFlow,
|
44
|
-
|
47
|
+
EvaluateIssuerTrust,
|
45
48
|
StartUserAuthorization,
|
46
49
|
BuildAuthorizationUrl,
|
47
50
|
CompleteUserAuthorizationWithQueryMode,
|
@@ -1,45 +1,42 @@
|
|
1
1
|
import * as z from "zod";
|
2
|
-
import {
|
2
|
+
import { InvalidQRCodeError } from "./errors";
|
3
3
|
|
4
4
|
const PresentationParams = z.object({
|
5
|
-
|
6
|
-
|
5
|
+
client_id: z.string().nonempty(),
|
6
|
+
request_uri: z.string().url(),
|
7
|
+
request_uri_method: z.enum(["get", "post"]),
|
8
|
+
state: z.string().optional(),
|
7
9
|
});
|
10
|
+
export type PresentationParams = z.infer<typeof PresentationParams>;
|
8
11
|
|
9
12
|
/**
|
10
13
|
* The beginning of the presentation flow.
|
11
14
|
* To be implemented accordind to the user touchpoint
|
12
15
|
*
|
13
|
-
* @param
|
16
|
+
* @param params Presentation parameters, depending on the starting touchpoint
|
14
17
|
* @returns The url for the Relying Party to connect with
|
15
18
|
*/
|
16
|
-
export type StartFlow
|
17
|
-
|
18
|
-
|
19
|
-
};
|
19
|
+
export type StartFlow = (params: {
|
20
|
+
[K in keyof PresentationParams]?: PresentationParams[K] | null;
|
21
|
+
}) => PresentationParams;
|
20
22
|
|
21
23
|
/**
|
22
|
-
* Start a presentation flow by
|
24
|
+
* Start a presentation flow by validating the required parameters.
|
25
|
+
* Parameters are extracted from a url encoded in a QR code or in a deep link.
|
23
26
|
*
|
24
|
-
* @param
|
27
|
+
* @param params The parameters to be validated
|
25
28
|
* @returns The url for the Relying Party to connect with
|
26
|
-
* @throws If the provided
|
29
|
+
* @throws If the provided parameters are not valid
|
27
30
|
*/
|
28
|
-
export const startFlowFromQR: StartFlow
|
29
|
-
requestUri: string,
|
30
|
-
clientId: string
|
31
|
-
) => {
|
31
|
+
export const startFlowFromQR: StartFlow = (params) => {
|
32
32
|
const result = PresentationParams.safeParse({
|
33
|
-
|
34
|
-
|
33
|
+
...params,
|
34
|
+
request_uri_method: params.request_uri_method ?? "get",
|
35
35
|
});
|
36
36
|
|
37
37
|
if (result.success) {
|
38
38
|
return result.data;
|
39
|
-
} else {
|
40
|
-
throw new ValidationFailed({
|
41
|
-
message: "Invalid parameters provided",
|
42
|
-
reason: result.error.message,
|
43
|
-
});
|
44
39
|
}
|
40
|
+
|
41
|
+
throw new InvalidQRCodeError(result.error.message);
|
45
42
|
};
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { getRelyingPartyEntityConfiguration } from "../../
|
2
|
-
import { RelyingPartyEntityConfiguration } from "../../
|
1
|
+
import { getRelyingPartyEntityConfiguration } from "../../trust";
|
2
|
+
import { RelyingPartyEntityConfiguration } from "../../trust/types";
|
3
3
|
import type { StartFlow } from "../issuance/01-start-flow";
|
4
4
|
import type { Out } from "../../utils/misc";
|
5
5
|
|
@@ -10,6 +10,7 @@ export type EvaluateRelyingPartyTrust = (
|
|
10
10
|
}
|
11
11
|
) => Promise<{
|
12
12
|
rpConf: RelyingPartyEntityConfiguration["payload"]["metadata"];
|
13
|
+
subject: string;
|
13
14
|
}>;
|
14
15
|
|
15
16
|
/**
|
@@ -25,9 +26,9 @@ export const evaluateRelyingPartyTrust: EvaluateRelyingPartyTrust = async (
|
|
25
26
|
{ appFetch = fetch } = {}
|
26
27
|
) => {
|
27
28
|
const {
|
28
|
-
payload: { metadata: rpConf },
|
29
|
+
payload: { metadata: rpConf, sub },
|
29
30
|
} = await getRelyingPartyEntityConfiguration(rpUrl, {
|
30
31
|
appFetch,
|
31
32
|
});
|
32
|
-
return { rpConf };
|
33
|
+
return { rpConf, subject: sub };
|
33
34
|
};
|