@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,14 +1,25 @@
|
|
1
|
+
import { decode, verify } from "./utils";
|
1
2
|
import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
|
2
3
|
import {
|
3
|
-
WalletProviderEntityConfiguration,
|
4
|
-
TrustAnchorEntityConfiguration,
|
5
4
|
CredentialIssuerEntityConfiguration,
|
6
|
-
RelyingPartyEntityConfiguration,
|
7
5
|
EntityConfiguration,
|
8
6
|
EntityStatement,
|
7
|
+
FederationListResponse,
|
8
|
+
RelyingPartyEntityConfiguration,
|
9
|
+
TrustAnchorEntityConfiguration,
|
10
|
+
WalletProviderEntityConfiguration,
|
9
11
|
} from "./types";
|
10
|
-
import {
|
11
|
-
import { hasStatusOrThrow } from "
|
12
|
+
import { renewTrustChain, validateTrustChain } from "./chain";
|
13
|
+
import { hasStatusOrThrow } from "../utils/misc";
|
14
|
+
import type { JWK } from "../utils/jwk";
|
15
|
+
import {
|
16
|
+
BuildTrustChainError,
|
17
|
+
FederationListParseError,
|
18
|
+
MissingFederationFetchEndpointError,
|
19
|
+
RelyingPartyNotAuthorizedError,
|
20
|
+
TrustAnchorKidMissingError,
|
21
|
+
} from "./errors";
|
22
|
+
import type { X509CertificateOptions } from "@pagopa/io-react-native-crypto";
|
12
23
|
|
13
24
|
export type {
|
14
25
|
WalletProviderEntityConfiguration,
|
@@ -24,26 +35,32 @@ export type {
|
|
24
35
|
* It can handle fast chain renewal, which means we try to fetch a fresh version of each statement.
|
25
36
|
*
|
26
37
|
* @param trustAnchorEntity The entity configuration of the known trust anchor
|
27
|
-
* @param chain The chain of statements to be
|
28
|
-
* @param
|
29
|
-
* @param
|
38
|
+
* @param chain The chain of statements to be validated
|
39
|
+
* @param x509Options Options for the verification process
|
40
|
+
* @param appFetch (optional) fetch api implementation
|
41
|
+
* @param renewOnFail Whether to attempt to renew the trust chain if the initial validation fails
|
30
42
|
* @returns The result of the chain validation
|
31
|
-
* @throws {
|
43
|
+
* @throws {FederationError} If the chain is not valid
|
32
44
|
*/
|
33
45
|
export async function verifyTrustChain(
|
34
46
|
trustAnchorEntity: TrustAnchorEntityConfiguration,
|
35
47
|
chain: string[],
|
48
|
+
x509Options: X509CertificateOptions = {
|
49
|
+
connectTimeout: 10000,
|
50
|
+
readTimeout: 10000,
|
51
|
+
requireCrl: true,
|
52
|
+
},
|
36
53
|
{
|
37
54
|
appFetch = fetch,
|
38
55
|
renewOnFail = true,
|
39
56
|
}: { appFetch?: GlobalFetch["fetch"]; renewOnFail?: boolean } = {}
|
40
57
|
): Promise<ReturnType<typeof validateTrustChain>> {
|
41
58
|
try {
|
42
|
-
return validateTrustChain(trustAnchorEntity, chain);
|
59
|
+
return validateTrustChain(trustAnchorEntity, chain, x509Options);
|
43
60
|
} catch (error) {
|
44
61
|
if (renewOnFail) {
|
45
62
|
const renewedChain = await renewTrustChain(chain, appFetch);
|
46
|
-
return validateTrustChain(trustAnchorEntity, renewedChain);
|
63
|
+
return validateTrustChain(trustAnchorEntity, renewedChain, x509Options);
|
47
64
|
} else {
|
48
65
|
throw error;
|
49
66
|
}
|
@@ -54,7 +71,7 @@ export async function verifyTrustChain(
|
|
54
71
|
* Fetch the signed entity configuration token for an entity
|
55
72
|
*
|
56
73
|
* @param entityBaseUrl The url of the entity to fetch
|
57
|
-
* @param
|
74
|
+
* @param appFetch (optional) fetch api implementation
|
58
75
|
* @returns The signed Entity Configuration token
|
59
76
|
*/
|
60
77
|
export async function getSignedEntityConfiguration(
|
@@ -86,6 +103,7 @@ export async function getSignedEntityConfiguration(
|
|
86
103
|
*
|
87
104
|
* @param entityBaseUrl The base url of the entity.
|
88
105
|
* @param schema The expected schema of the entity configuration, according to the kind of entity we are fetching from.
|
106
|
+
* @param options An optional object with additional options.
|
89
107
|
* @param options.appFetch An optional instance of the http client to be used.
|
90
108
|
* @returns The parsed entity configuration object
|
91
109
|
* @throws {IoWalletError} If the http request fails
|
@@ -200,12 +218,11 @@ export const getEntityConfiguration = (
|
|
200
218
|
/**
|
201
219
|
* Fetch and parse the entity statement document for a given federation entity.
|
202
220
|
*
|
203
|
-
* @param accreditationBodyBaseUrl The base url of the
|
221
|
+
* @param accreditationBodyBaseUrl The base url of the accreditation body which holds and signs the required entity statement
|
204
222
|
* @param subordinatedEntityBaseUrl The url that identifies the subordinate entity
|
205
|
-
* @param
|
223
|
+
* @param appFetch An optional instance of the http client to be used.
|
206
224
|
* @returns The parsed entity configuration object
|
207
225
|
* @throws {IoWalletError} If the http request fails
|
208
|
-
* @throws Parse error if the document is not in the expected shape.
|
209
226
|
*/
|
210
227
|
export async function getEntityStatement(
|
211
228
|
accreditationBodyBaseUrl: string,
|
@@ -234,14 +251,14 @@ export async function getEntityStatement(
|
|
234
251
|
/**
|
235
252
|
* Fetch the entity statement document for a given federation entity.
|
236
253
|
*
|
237
|
-
* @param
|
238
|
-
* @param subordinatedEntityBaseUrl The url that identifies the subordinate entity
|
239
|
-
* @param
|
240
|
-
* @returns The signed entity statement token
|
241
|
-
* @throws {IoWalletError} If the http request fails
|
254
|
+
* @param federationFetchEndpoint The exact endpoint provided by the parent EC's metadata.
|
255
|
+
* @param subordinatedEntityBaseUrl The url that identifies the subordinate entity.
|
256
|
+
* @param appFetch An optional instance of the http client to be used.
|
257
|
+
* @returns The signed entity statement token.
|
258
|
+
* @throws {IoWalletError} If the http request fails.
|
242
259
|
*/
|
243
260
|
export async function getSignedEntityStatement(
|
244
|
-
|
261
|
+
federationFetchEndpoint: string,
|
245
262
|
subordinatedEntityBaseUrl: string,
|
246
263
|
{
|
247
264
|
appFetch = fetch,
|
@@ -249,13 +266,178 @@ export async function getSignedEntityStatement(
|
|
249
266
|
appFetch?: GlobalFetch["fetch"];
|
250
267
|
} = {}
|
251
268
|
) {
|
252
|
-
const url =
|
253
|
-
|
254
|
-
})}`;
|
269
|
+
const url = new URL(federationFetchEndpoint);
|
270
|
+
url.searchParams.set("sub", subordinatedEntityBaseUrl);
|
255
271
|
|
256
|
-
return await appFetch(url, {
|
272
|
+
return await appFetch(url.toString(), {
|
257
273
|
method: "GET",
|
258
274
|
})
|
259
275
|
.then(hasStatusOrThrow(200))
|
260
276
|
.then((res) => res.text());
|
261
277
|
}
|
278
|
+
|
279
|
+
/**
|
280
|
+
* Fetch the federation list document from a given endpoint.
|
281
|
+
*
|
282
|
+
* @param federationListEndpoint The URL of the federation list endpoint.
|
283
|
+
* @param appFetch An optional instance of the http client to be used.
|
284
|
+
* @returns The federation list as an array of strings.
|
285
|
+
* @throws {IoWalletError} If the HTTP request fails.
|
286
|
+
* @throws {FederationError} If the result is not in the expected format.
|
287
|
+
*/
|
288
|
+
export async function getFederationList(
|
289
|
+
federationListEndpoint: string,
|
290
|
+
{
|
291
|
+
appFetch = fetch,
|
292
|
+
}: {
|
293
|
+
appFetch?: GlobalFetch["fetch"];
|
294
|
+
} = {}
|
295
|
+
): Promise<string[]> {
|
296
|
+
return await appFetch(federationListEndpoint, {
|
297
|
+
method: "GET",
|
298
|
+
})
|
299
|
+
.then(hasStatusOrThrow(200))
|
300
|
+
.then((res) => res.json())
|
301
|
+
.then((json) => {
|
302
|
+
const result = FederationListResponse.safeParse(json);
|
303
|
+
if (!result.success) {
|
304
|
+
throw new FederationListParseError(
|
305
|
+
`Invalid federation list format received from ${federationListEndpoint}. Error: ${result.error.message}`,
|
306
|
+
{ url: federationListEndpoint, parseError: result.error.toString() }
|
307
|
+
);
|
308
|
+
}
|
309
|
+
return result.data;
|
310
|
+
});
|
311
|
+
}
|
312
|
+
|
313
|
+
/**
|
314
|
+
* Build a not-verified trust chain for a given Relying Party (RP) entity.
|
315
|
+
*
|
316
|
+
* @param relyingPartyEntityBaseUrl The base URL of the RP entity
|
317
|
+
* @param trustAnchorKey The public key of the Trust Anchor (TA) entity
|
318
|
+
* @param appFetch An optional instance of the http client to be used.
|
319
|
+
* @returns A list of signed tokens that represent the trust chain, in the order of the chain (from the RP to the Trust Anchor)
|
320
|
+
* @throws {FederationError} When an element of the chain fails to parse or other build steps fail.
|
321
|
+
*/
|
322
|
+
export async function buildTrustChain(
|
323
|
+
relyingPartyEntityBaseUrl: string,
|
324
|
+
trustAnchorKey: JWK,
|
325
|
+
appFetch: GlobalFetch["fetch"] = fetch
|
326
|
+
): Promise<string[]> {
|
327
|
+
// 1: Recursively gather the trust chain from the RP up to the Trust Anchor
|
328
|
+
const trustChain = await gatherTrustChain(
|
329
|
+
relyingPartyEntityBaseUrl,
|
330
|
+
appFetch
|
331
|
+
);
|
332
|
+
|
333
|
+
// 2: Trust Anchor signature verification
|
334
|
+
const trustAnchorJwt = trustChain[trustChain.length - 1];
|
335
|
+
if (!trustAnchorJwt) {
|
336
|
+
throw new BuildTrustChainError(
|
337
|
+
"Cannot verify trust anchor: missing entity configuration in gathered chain.",
|
338
|
+
{ relyingPartyUrl: relyingPartyEntityBaseUrl }
|
339
|
+
);
|
340
|
+
}
|
341
|
+
|
342
|
+
if (!trustAnchorKey.kid) {
|
343
|
+
throw new TrustAnchorKidMissingError();
|
344
|
+
}
|
345
|
+
|
346
|
+
await verify(trustAnchorJwt, trustAnchorKey.kid, [trustAnchorKey]);
|
347
|
+
|
348
|
+
// 3: Check the federation list
|
349
|
+
const trustAnchorConfig = EntityConfiguration.parse(decode(trustAnchorJwt));
|
350
|
+
const federationListEndpoint =
|
351
|
+
trustAnchorConfig.payload.metadata.federation_entity
|
352
|
+
.federation_list_endpoint;
|
353
|
+
|
354
|
+
if (federationListEndpoint) {
|
355
|
+
const federationList = await getFederationList(federationListEndpoint, {
|
356
|
+
appFetch,
|
357
|
+
});
|
358
|
+
|
359
|
+
if (!federationList.includes(relyingPartyEntityBaseUrl)) {
|
360
|
+
throw new RelyingPartyNotAuthorizedError(
|
361
|
+
"Relying Party entity base URL is not authorized by the Trust Anchor's federation list.",
|
362
|
+
{ relyingPartyUrl: relyingPartyEntityBaseUrl, federationListEndpoint }
|
363
|
+
);
|
364
|
+
}
|
365
|
+
}
|
366
|
+
|
367
|
+
return trustChain;
|
368
|
+
}
|
369
|
+
|
370
|
+
/**
|
371
|
+
* Recursively gather the trust chain for an entity and all its superiors.
|
372
|
+
* @param entityBaseUrl The base URL of the entity for which to gather the chain.
|
373
|
+
* @param appFetch An optional instance of the http client to be used.
|
374
|
+
* @param isLeaf Whether the current entity is the leaf of the chain.
|
375
|
+
* @returns A full ordered list of JWTs (ECs and ESs) forming the trust chain.
|
376
|
+
* @throws {FederationError} If any of the fetched documents fail to parse or other errors occur during the gathering process.
|
377
|
+
*/
|
378
|
+
async function gatherTrustChain(
|
379
|
+
entityBaseUrl: string,
|
380
|
+
appFetch: GlobalFetch["fetch"],
|
381
|
+
isLeaf: boolean = true
|
382
|
+
): Promise<string[]> {
|
383
|
+
const chain: string[] = [];
|
384
|
+
|
385
|
+
// Fetch self-signed EC (only needed for the leaf)
|
386
|
+
const entityECJwt = await getSignedEntityConfiguration(entityBaseUrl, {
|
387
|
+
appFetch,
|
388
|
+
});
|
389
|
+
const entityEC = EntityConfiguration.parse(decode(entityECJwt));
|
390
|
+
|
391
|
+
if (isLeaf) {
|
392
|
+
// Only push EC for the leaf
|
393
|
+
chain.push(entityECJwt);
|
394
|
+
}
|
395
|
+
|
396
|
+
// Find authority_hints (parent, if any)
|
397
|
+
const authorityHints = entityEC.payload.authority_hints ?? [];
|
398
|
+
if (authorityHints.length === 0) {
|
399
|
+
// This is the Trust Anchor (no parent)
|
400
|
+
if (!isLeaf) {
|
401
|
+
chain.push(entityECJwt);
|
402
|
+
}
|
403
|
+
return chain;
|
404
|
+
}
|
405
|
+
|
406
|
+
const parentEntityBaseUrl = authorityHints[0]!;
|
407
|
+
|
408
|
+
// Fetch parent EC
|
409
|
+
const parentECJwt = await getSignedEntityConfiguration(parentEntityBaseUrl, {
|
410
|
+
appFetch,
|
411
|
+
});
|
412
|
+
const parentEC = EntityConfiguration.parse(decode(parentECJwt));
|
413
|
+
|
414
|
+
// Fetch ES
|
415
|
+
const federationFetchEndpoint =
|
416
|
+
parentEC.payload.metadata.federation_entity.federation_fetch_endpoint;
|
417
|
+
if (!federationFetchEndpoint) {
|
418
|
+
throw new MissingFederationFetchEndpointError(
|
419
|
+
`Missing federation_fetch_endpoint in parent's (${parentEntityBaseUrl}) configuration when gathering chain for ${entityBaseUrl}.`,
|
420
|
+
{ entityBaseUrl, missingInEntityUrl: parentEntityBaseUrl }
|
421
|
+
);
|
422
|
+
}
|
423
|
+
|
424
|
+
const entityStatementJwt = await getSignedEntityStatement(
|
425
|
+
federationFetchEndpoint,
|
426
|
+
entityBaseUrl,
|
427
|
+
{ appFetch }
|
428
|
+
);
|
429
|
+
// Validate the ES
|
430
|
+
EntityStatement.parse(decode(entityStatementJwt));
|
431
|
+
|
432
|
+
// Push this ES into the chain
|
433
|
+
chain.push(entityStatementJwt);
|
434
|
+
|
435
|
+
// Recurse into the parent
|
436
|
+
const parentChain = await gatherTrustChain(
|
437
|
+
parentEntityBaseUrl,
|
438
|
+
appFetch,
|
439
|
+
false
|
440
|
+
);
|
441
|
+
|
442
|
+
return chain.concat(parentChain);
|
443
|
+
}
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { UnixTime } from "
|
2
|
-
import { JWK } from "
|
1
|
+
import { UnixTime } from "../sd-jwt/types";
|
2
|
+
import { JWK } from "../utils/jwk";
|
3
3
|
import * as z from "zod";
|
4
|
-
import { PresentationDefinition } from "
|
4
|
+
import { PresentationDefinition } from "../credential/presentation/types";
|
5
5
|
|
6
6
|
export const TrustMark = z.object({ id: z.string(), trust_mark: z.string() });
|
7
7
|
export type TrustMark = z.infer<typeof TrustMark>;
|
@@ -13,9 +13,11 @@ const RelyingPartyMetadata = z.object({
|
|
13
13
|
jwks: z.object({ keys: z.array(JWK) }),
|
14
14
|
contacts: z.array(z.string()).optional(),
|
15
15
|
presentation_definition: PresentationDefinition.optional(),
|
16
|
-
|
16
|
+
request_uris: z.array(z.string()).optional(),
|
17
|
+
authorization_signed_response_alg: z.string().optional(),
|
18
|
+
authorization_encrypted_response_alg: z.string().optional(),
|
19
|
+
authorization_encrypted_response_enc: z.string().optional(),
|
17
20
|
});
|
18
|
-
//.passthrough();
|
19
21
|
|
20
22
|
// Display metadata for a credential, used by the issuer to
|
21
23
|
// instruct the Wallet Solution on how to render the credential correctly
|
@@ -23,14 +25,6 @@ type CredentialDisplayMetadata = z.infer<typeof CredentialDisplayMetadata>;
|
|
23
25
|
const CredentialDisplayMetadata = z.object({
|
24
26
|
name: z.string(),
|
25
27
|
locale: z.string(),
|
26
|
-
logo: z
|
27
|
-
.object({
|
28
|
-
url: z.string(),
|
29
|
-
alt_text: z.string(),
|
30
|
-
})
|
31
|
-
.optional(), // TODO [SIW-1268]: should not be optional
|
32
|
-
background_color: z.string().optional(), // TODO [SIW-1268]: should not be optional
|
33
|
-
text_color: z.string().optional(), // TODO [SIW-1268]: should not be optional
|
34
28
|
});
|
35
29
|
|
36
30
|
// Metadata for displaying issuer information
|
@@ -40,12 +34,6 @@ type CredentialIssuerDisplayMetadata = z.infer<
|
|
40
34
|
const CredentialIssuerDisplayMetadata = z.object({
|
41
35
|
name: z.string(),
|
42
36
|
locale: z.string(),
|
43
|
-
logo: z
|
44
|
-
.object({
|
45
|
-
url: z.string(),
|
46
|
-
alt_text: z.string(),
|
47
|
-
})
|
48
|
-
.optional(), // TODO [SIW-1268]: should not be optional
|
49
37
|
});
|
50
38
|
|
51
39
|
type ClaimsMetadata = z.infer<typeof ClaimsMetadata>;
|
@@ -67,13 +55,13 @@ const IssuanceErrorSupported = z.object({
|
|
67
55
|
),
|
68
56
|
});
|
69
57
|
|
70
|
-
// Metadata for a
|
58
|
+
// Metadata for a credential which is supported by an Issuer
|
71
59
|
type SupportedCredentialMetadata = z.infer<typeof SupportedCredentialMetadata>;
|
72
60
|
const SupportedCredentialMetadata = z.object({
|
73
|
-
format: z.union([z.literal("vc+sd-jwt"), z.literal("
|
61
|
+
format: z.union([z.literal("vc+sd-jwt"), z.literal("vc+mdoc-cbor")]),
|
74
62
|
scope: z.string(),
|
75
63
|
display: z.array(CredentialDisplayMetadata),
|
76
|
-
claims: ClaimsMetadata
|
64
|
+
claims: ClaimsMetadata,
|
77
65
|
cryptographic_binding_methods_supported: z.array(z.string()),
|
78
66
|
credential_signing_alg_values_supported: z.array(z.string()),
|
79
67
|
authentic_source: z.string().optional(),
|
@@ -91,7 +79,7 @@ export const EntityStatement = z.object({
|
|
91
79
|
iss: z.string(),
|
92
80
|
sub: z.string(),
|
93
81
|
jwks: z.object({ keys: z.array(JWK) }),
|
94
|
-
trust_marks: z.array(TrustMark),
|
82
|
+
trust_marks: z.array(TrustMark).optional(),
|
95
83
|
iat: z.number(),
|
96
84
|
exp: z.number(),
|
97
85
|
}),
|
@@ -107,7 +95,7 @@ export const EntityConfigurationHeader = z.object({
|
|
107
95
|
});
|
108
96
|
|
109
97
|
/**
|
110
|
-
* @see https://openid.net/specs/openid-
|
98
|
+
* @see https://openid.net/specs/openid-federation-1_0-41.html
|
111
99
|
*/
|
112
100
|
const FederationEntityMetadata = z
|
113
101
|
.object({
|
@@ -116,6 +104,9 @@ const FederationEntityMetadata = z
|
|
116
104
|
federation_resolve_endpoint: z.string().optional(),
|
117
105
|
federation_trust_mark_status_endpoint: z.string().optional(),
|
118
106
|
federation_trust_mark_list_endpoint: z.string().optional(),
|
107
|
+
federation_trust_mark_endpoint: z.string().optional(),
|
108
|
+
federation_historical_keys_endpoint: z.string().optional(),
|
109
|
+
endpoint_auth_signing_alg_values_supported: z.string().optional(),
|
119
110
|
organization_name: z.string().optional(),
|
120
111
|
homepage_uri: z.string().optional(),
|
121
112
|
policy_uri: z.string().optional(),
|
@@ -124,7 +115,7 @@ const FederationEntityMetadata = z
|
|
124
115
|
})
|
125
116
|
.passthrough();
|
126
117
|
|
127
|
-
//
|
118
|
+
// Structure common to every Entity Configuration document
|
128
119
|
const BaseEntityConfiguration = z.object({
|
129
120
|
header: EntityConfigurationHeader,
|
130
121
|
payload: z
|
@@ -175,30 +166,24 @@ export const CredentialIssuerEntityConfiguration = BaseEntityConfiguration.and(
|
|
175
166
|
oauth_authorization_server: z.object({
|
176
167
|
authorization_endpoint: z.string(),
|
177
168
|
pushed_authorization_request_endpoint: z.string(),
|
178
|
-
dpop_signing_alg_values_supported: z.array(z.string()).optional(), // TODO [SIW-1268]: should not be optional
|
179
169
|
token_endpoint: z.string(),
|
180
|
-
introspection_endpoint: z.string().optional(), // TODO [SIW-1268]: should not be optional
|
181
170
|
client_registration_types_supported: z.array(z.string()),
|
182
171
|
code_challenge_methods_supported: z.array(z.string()),
|
183
|
-
authorization_details_types_supported: z.array(z.string()).optional(), // TODO [SIW-1268]: should not be optional,
|
184
172
|
acr_values_supported: z.array(z.string()),
|
185
173
|
grant_types_supported: z.array(z.string()),
|
186
174
|
issuer: z.string(),
|
187
175
|
jwks: z.object({ keys: z.array(JWK) }),
|
188
176
|
scopes_supported: z.array(z.string()),
|
189
|
-
request_parameter_supported: z.boolean().optional(), // TODO [SIW-1268]: should not be optional
|
190
|
-
request_uri_parameter_supported: z.boolean().optional(), // TODO [SIW-1268]: should not be optional
|
191
|
-
response_types_supported: z.array(z.string()).optional(), // TODO [SIW-1268]: should not be optional
|
192
177
|
response_modes_supported: z.array(z.string()),
|
193
|
-
subject_types_supported: z.array(z.string()).optional(), // TODO [SIW-1268]: should not be optional
|
194
178
|
token_endpoint_auth_methods_supported: z.array(z.string()),
|
195
179
|
token_endpoint_auth_signing_alg_values_supported: z.array(z.string()),
|
196
180
|
request_object_signing_alg_values_supported: z.array(z.string()),
|
197
181
|
}),
|
198
|
-
/**
|
199
|
-
|
200
|
-
|
201
|
-
|
182
|
+
/**
|
183
|
+
* Credential Issuers act as Relying Party when they require the presentation of other credentials.
|
184
|
+
* This does not apply for PID issuance, which requires CIE authz.
|
185
|
+
*/
|
186
|
+
openid_credential_verifier: RelyingPartyMetadata.optional(),
|
202
187
|
}),
|
203
188
|
}),
|
204
189
|
})
|
@@ -212,7 +197,7 @@ export const RelyingPartyEntityConfiguration = BaseEntityConfiguration.and(
|
|
212
197
|
z.object({
|
213
198
|
payload: z.object({
|
214
199
|
metadata: z.object({
|
215
|
-
|
200
|
+
openid_credential_verifier: RelyingPartyMetadata,
|
216
201
|
}),
|
217
202
|
}),
|
218
203
|
})
|
@@ -256,3 +241,5 @@ export const EntityConfiguration = z.union(
|
|
256
241
|
description: "Any kind of Entity Configuration allowed in the ecosystem",
|
257
242
|
}
|
258
243
|
);
|
244
|
+
|
245
|
+
export const FederationListResponse = z.array(z.string());
|
@@ -0,0 +1,70 @@
|
|
1
|
+
import {
|
2
|
+
decode as decodeJwt,
|
3
|
+
verify as verifyJwt,
|
4
|
+
} from "@pagopa/io-react-native-jwt";
|
5
|
+
|
6
|
+
import type { JWK, JWTDecodeResult } from "../utils/jwk";
|
7
|
+
import { FederationError } from "./errors";
|
8
|
+
import type { TrustAnchorEntityConfiguration } from "./types";
|
9
|
+
|
10
|
+
export type ParsedToken = {
|
11
|
+
header: JWTDecodeResult["protectedHeader"];
|
12
|
+
payload: JWTDecodeResult["payload"];
|
13
|
+
};
|
14
|
+
|
15
|
+
// Verify a token signature
|
16
|
+
// The kid is extracted from the token header
|
17
|
+
export const verify = async (
|
18
|
+
token: string,
|
19
|
+
kid: string,
|
20
|
+
jwks: JWK[]
|
21
|
+
): Promise<ParsedToken> => {
|
22
|
+
const jwk = jwks.find((k) => k.kid === kid);
|
23
|
+
if (!jwk) {
|
24
|
+
throw new Error(`Invalid kid: ${kid}, token: ${token}`);
|
25
|
+
}
|
26
|
+
const { protectedHeader: header, payload } = await verifyJwt(token, jwk);
|
27
|
+
return { header, payload };
|
28
|
+
};
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Return type for this function is necessary to avoid an issue during the bob build process.
|
32
|
+
* It seems like typescript can't correctly infer the return type of the function.
|
33
|
+
*/
|
34
|
+
export const decode = (token: string): ParsedToken => {
|
35
|
+
const { protectedHeader: header, payload } = decodeJwt(token);
|
36
|
+
return { header, payload };
|
37
|
+
};
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Extracts the X.509 Trust Anchor certificate (Base64 encoded) from the
|
41
|
+
* Trust Anchor's Entity Configuration.
|
42
|
+
*
|
43
|
+
* @param trustAnchorEntity The entity configuration of the known trust anchor.
|
44
|
+
* @returns The Base64 encoded X.509 certificate string.
|
45
|
+
* @throws {FederationError} If the certificate cannot be derived.
|
46
|
+
*/
|
47
|
+
export function getTrustAnchorX509Certificate(
|
48
|
+
trustAnchorEntity: TrustAnchorEntityConfiguration
|
49
|
+
): string {
|
50
|
+
const taHeaderKid = trustAnchorEntity.header.kid;
|
51
|
+
const taSigningJwk = trustAnchorEntity.payload.jwks.keys.find(
|
52
|
+
(key) => key.kid === taHeaderKid
|
53
|
+
);
|
54
|
+
|
55
|
+
if (!taSigningJwk) {
|
56
|
+
throw new FederationError(
|
57
|
+
`Cannot derive X.509 Trust Anchor certificate: JWK with kid '${taHeaderKid}' not found in Trust Anchor's JWKS.`,
|
58
|
+
{ trustAnchorKid: taHeaderKid, reason: "JWK not found for header kid" }
|
59
|
+
);
|
60
|
+
}
|
61
|
+
|
62
|
+
if (taSigningJwk.x5c && taSigningJwk.x5c.length > 0 && taSigningJwk.x5c[0]) {
|
63
|
+
return taSigningJwk.x5c[0];
|
64
|
+
}
|
65
|
+
|
66
|
+
throw new FederationError(
|
67
|
+
`Cannot derive X.509 Trust Anchor certificate: JWK with kid '${taHeaderKid}' does not contain a valid 'x5c' certificate array.`,
|
68
|
+
{ trustAnchorKid: taHeaderKid, reason: "Missing or empty x5c in JWK" }
|
69
|
+
);
|
70
|
+
}
|
package/src/utils/crypto.ts
CHANGED
@@ -3,14 +3,10 @@ import {
|
|
3
3
|
sign,
|
4
4
|
generate,
|
5
5
|
deleteKey,
|
6
|
-
type PublicKey,
|
7
6
|
} from "@pagopa/io-react-native-crypto";
|
8
|
-
import
|
7
|
+
import { v4 as uuidv4 } from "uuid";
|
9
8
|
import { thumbprint, type CryptoContext } from "@pagopa/io-react-native-jwt";
|
10
|
-
import {
|
11
|
-
import { JWK } from "./jwk";
|
12
|
-
import { removePadding } from "@pagopa/io-react-native-jwt";
|
13
|
-
import { Buffer } from "buffer";
|
9
|
+
import { fixBase64EncodingOnKey } from "./jwk";
|
14
10
|
|
15
11
|
/**
|
16
12
|
* Create a CryptoContext bound to a key pair.
|
@@ -28,7 +24,7 @@ export const createCryptoContextFor = (keytag: string): CryptoContext => {
|
|
28
24
|
*/
|
29
25
|
async getPublicKey() {
|
30
26
|
return getPublicKey(keytag)
|
31
|
-
.then(
|
27
|
+
.then(fixBase64EncodingOnKey)
|
32
28
|
.then(async (jwk) => ({
|
33
29
|
...jwk,
|
34
30
|
// Keys in the TEE are not stored with their KID, which is supposed to be assigned when they are included in JWK sets.
|
@@ -50,45 +46,6 @@ export const createCryptoContextFor = (keytag: string): CryptoContext => {
|
|
50
46
|
};
|
51
47
|
};
|
52
48
|
|
53
|
-
/**
|
54
|
-
* This function takes a JSON Web Key (JWK) and returns a new JWK with its base64-url properties (x, y, e, n) processed.
|
55
|
-
* Each property is passed through the `removeLeadingZeroAndParseb64u` function if it exists, which fixes any unwanted leading zeros.
|
56
|
-
*
|
57
|
-
* @param key - The input JSON Web Key that may contain properties with potential leading zero issues.
|
58
|
-
* @returns A new JSON Web Key with the processed properties.
|
59
|
-
*/
|
60
|
-
const fixBase64WithLeadingZero = (key: JWK): JWK => {
|
61
|
-
const { x, y, e, n, ...pk } = key;
|
62
|
-
|
63
|
-
return {
|
64
|
-
...pk,
|
65
|
-
...(x ? { x: removeLeadingZeroAndParseb64u(x) } : {}),
|
66
|
-
...(y ? { y: removeLeadingZeroAndParseb64u(y) } : {}),
|
67
|
-
...(e ? { e: removeLeadingZeroAndParseb64u(e) } : {}),
|
68
|
-
...(n ? { n: removeLeadingZeroAndParseb64u(n) } : {}),
|
69
|
-
};
|
70
|
-
};
|
71
|
-
|
72
|
-
/**
|
73
|
-
* This function processes a base64-encoded string to remove any unwanted leading zeros.
|
74
|
-
* It converts the input base64 string into a buffer, then to a hex string, checks for a leading "00",
|
75
|
-
* and removes it if present. The result is then converted back to a base64-url.
|
76
|
-
*
|
77
|
-
* @param input - The base64 encoded string to process.
|
78
|
-
* @returns A new base64-url encoded string with any leading zero removed.
|
79
|
-
*/
|
80
|
-
const removeLeadingZeroAndParseb64u = (input: string): string => {
|
81
|
-
// Decode base64 input into a Buffer
|
82
|
-
const buffer = Buffer.from(input, "base64");
|
83
|
-
const hex = buffer.toString("hex");
|
84
|
-
// If the hex string starts with "00", remove the first two characters
|
85
|
-
const fixedHex = hex.startsWith("00") ? hex.slice(2) : hex;
|
86
|
-
const newBuffer = Buffer.from(fixedHex, "hex");
|
87
|
-
|
88
|
-
// removePadding convert base64 string to base64-url
|
89
|
-
return removePadding(newBuffer.toString("base64"));
|
90
|
-
};
|
91
|
-
|
92
49
|
/**
|
93
50
|
* Executes the input function injecting an ephemeral crypto context.
|
94
51
|
* An ephemeral crypto context is a context which is bound to a key
|
@@ -101,67 +58,8 @@ export const withEphemeralKey = async <R>(
|
|
101
58
|
fn: (ephemeralContext: CryptoContext) => Promise<R>
|
102
59
|
): Promise<R> => {
|
103
60
|
// Use an ephemeral key to be destroyed after use
|
104
|
-
const keytag = `ephemeral-${
|
61
|
+
const keytag = `ephemeral-${uuidv4()}`;
|
105
62
|
await generate(keytag);
|
106
63
|
const ephemeralContext = createCryptoContextFor(keytag);
|
107
64
|
return fn(ephemeralContext).finally(() => deleteKey(keytag));
|
108
65
|
};
|
109
|
-
|
110
|
-
/**
|
111
|
-
* Converts a certificate string to PEM format.
|
112
|
-
*
|
113
|
-
* @param certificate - The certificate string.
|
114
|
-
* @returns The PEM-formatted certificate.
|
115
|
-
*/
|
116
|
-
export const convertCertToPem = (certificate: string): string =>
|
117
|
-
`-----BEGIN CERTIFICATE-----\n${certificate}\n-----END CERTIFICATE-----`;
|
118
|
-
|
119
|
-
/**
|
120
|
-
* Parses the public key from a PEM-formatted certificate.
|
121
|
-
*
|
122
|
-
* @param pemCert - The PEM-formatted certificate.
|
123
|
-
* @returns The public key object.
|
124
|
-
* @throws Will throw an error if the public key is unsupported.
|
125
|
-
*/
|
126
|
-
export const parsePublicKey = (
|
127
|
-
pemCert: string
|
128
|
-
): RSAKey | KJUR.crypto.ECDSA | undefined => {
|
129
|
-
const x509 = new X509();
|
130
|
-
x509.readCertPEM(pemCert);
|
131
|
-
const publicKey = x509.getPublicKey();
|
132
|
-
|
133
|
-
if (publicKey instanceof RSAKey || publicKey instanceof KJUR.crypto.ECDSA) {
|
134
|
-
return publicKey;
|
135
|
-
}
|
136
|
-
|
137
|
-
return undefined;
|
138
|
-
};
|
139
|
-
|
140
|
-
/**
|
141
|
-
* Retrieves the signing JWK from the public key.
|
142
|
-
*
|
143
|
-
* @param publicKey - The public key object.
|
144
|
-
* @returns The signing JWK.
|
145
|
-
*/
|
146
|
-
export const getSigningJwk = (publicKey: RSAKey | KJUR.crypto.ECDSA): JWK => ({
|
147
|
-
...JWK.parse(KEYUTIL.getJWKFromKey(publicKey)),
|
148
|
-
use: "sig",
|
149
|
-
});
|
150
|
-
|
151
|
-
/**
|
152
|
-
* This function takes two {@link PublicKey} and evaluates and compares their thumbprints
|
153
|
-
* @param key1 The first key
|
154
|
-
* @param key2 The second key
|
155
|
-
* @returns true if the keys' thumbprints are equal, false otherwise
|
156
|
-
*/
|
157
|
-
export const compareKeysByThumbprint = async (
|
158
|
-
key1: PublicKey,
|
159
|
-
key2: PublicKey
|
160
|
-
) => {
|
161
|
-
//Parallel for optimization
|
162
|
-
const [thumbprint1, thumbprint2] = await Promise.all([
|
163
|
-
thumbprint(key1),
|
164
|
-
thumbprint(key2),
|
165
|
-
]);
|
166
|
-
return thumbprint1 === thumbprint2;
|
167
|
-
};
|
package/src/utils/decoder.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
|
2
|
-
import { ValidationFailed } from "./errors";
|
3
2
|
import type { JWTDecodeResult } from "./jwk";
|
3
|
+
import { ValidationFailed } from "./errors";
|
4
|
+
import { LogLevel, Logger } from "./logging";
|
4
5
|
|
5
6
|
/*
|
6
7
|
* Decode a form_post.jwt and return the final JWT.
|
@@ -47,6 +48,10 @@ export const getJwtFromFormPost = async (
|
|
47
48
|
}
|
48
49
|
}
|
49
50
|
|
51
|
+
Logger.log(
|
52
|
+
LogLevel.ERROR,
|
53
|
+
`Unable to obtain JWT from form_post.jwt. Form data: ${formData}`
|
54
|
+
);
|
50
55
|
throw new ValidationFailed({
|
51
56
|
message: `Unable to obtain JWT from form_post.jwt. Form data: ${formData}`,
|
52
57
|
});
|