@pagopa/io-react-native-wallet 1.7.1 → 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
@@ -5,48 +5,35 @@ describe("SdJwt4VC", () => {
|
|
5
5
|
// example provided at https://italia.github.io/eidas-it-wallet-docs/en/pid-data-model.html
|
6
6
|
const token = {
|
7
7
|
header: {
|
8
|
-
kid: "eNN-g5i6CnLKcltQBp6abbioGMbzM6muW3vuxw6uh88",
|
9
8
|
typ: "vc+sd-jwt",
|
10
|
-
alg: "
|
9
|
+
alg: "RS512",
|
10
|
+
kid: "dB67gL7ck3TFiIAf7N6_7SHvqk0MDYMEQcoGGlkUAAw",
|
11
11
|
},
|
12
12
|
payload: {
|
13
|
-
sub: "sj1OpYiiLTVYANnBGNwSK2krMwqpWaz2iHmN1t0_Esg",
|
14
13
|
_sd: [
|
15
|
-
"
|
16
|
-
"
|
17
|
-
"
|
18
|
-
"
|
19
|
-
"
|
20
|
-
"
|
14
|
+
"0q1D5Jmav6pQaEh_J_Fcv_uNNMQIgCyhQOxqlY4l3qU",
|
15
|
+
"KCJ-AVNv88d-xj6sUIAOJxFnbUh3rHXDKkIH1lFqbRs",
|
16
|
+
"M9lo9YxDNIXrAq2qWeiCA40zpJ_zYfFdR_4AEALcRtU",
|
17
|
+
"czgjUk0nqRCswShChCjdS6A1-v47d_qTCSFIvIHhMoI",
|
18
|
+
"nGnQr7clm3tfTp8yjL_uHrDSOtzR2PVb8S7GeLdAqBQ",
|
19
|
+
"xNIVwlpSsaZ8CJSf0gz5x_75VRWWc6V1mlpejdCrqUs",
|
21
20
|
],
|
22
|
-
"
|
23
|
-
"242302d97d38da2714a257f2a253bf2fa30aae5c109fe9581bfcda3b1d797c97",
|
21
|
+
sub: "216f8946-9ecb-4819-9309-c076f34a7e11",
|
24
22
|
_sd_alg: "sha-256",
|
25
|
-
vct: "
|
26
|
-
iss: "https://
|
23
|
+
vct: "PersonIdentificationData",
|
24
|
+
iss: "https://pidprovider.example.com",
|
27
25
|
cnf: {
|
28
26
|
jwk: {
|
29
27
|
kty: "EC",
|
30
28
|
crv: "P-256",
|
31
|
-
kid: "
|
32
|
-
x: "
|
33
|
-
y: "
|
29
|
+
kid: "zEv_qGSL5r0_F67j2dwEgUJmBgbMNSEJ5K_iH1PYc7A",
|
30
|
+
x: "0Pj7v_afNp9ETJx11JbYgkI7yQpd0rtiYuo5feuAN2o",
|
31
|
+
y: "XB62Um02vHqedkOzSfJ5hdtjPz-zmV9jmWh4sKgdD9o",
|
34
32
|
},
|
35
33
|
},
|
36
|
-
exp:
|
37
|
-
iat: 1736954196,
|
38
|
-
expiry_date: "2026-12-05",
|
39
|
-
issuing_country: "IT",
|
40
|
-
issuing_authority: "Istituto Poligrafico e Zecca dello Stato",
|
41
|
-
verification: {
|
42
|
-
evidence: {
|
43
|
-
method: "cie",
|
44
|
-
},
|
45
|
-
trust_framework: "eidas",
|
46
|
-
assurance_level: "high",
|
47
|
-
},
|
34
|
+
exp: 1751107255,
|
48
35
|
status: {
|
49
|
-
|
36
|
+
status_attestation: {
|
50
37
|
credential_hash_alg: "sha-256",
|
51
38
|
},
|
52
39
|
},
|
package/src/sd-jwt/index.ts
CHANGED
@@ -187,11 +187,7 @@ export const prepareVpToken = async (
|
|
187
187
|
vp_token: string;
|
188
188
|
}> => {
|
189
189
|
// Produce a VP token with only requested claims from the verifiable credential
|
190
|
-
const
|
191
|
-
const { token: vp } = await disclose(
|
192
|
-
verifiableCredential,
|
193
|
-
requestedClaimsString
|
194
|
-
);
|
190
|
+
const { token: vp } = await disclose(verifiableCredential, requestedClaims);
|
195
191
|
|
196
192
|
// <Issuer-signed JWT>~<Disclosure 1>~<Disclosure N>~
|
197
193
|
const sd_hash = await sha256ToBase64(`${vp}~`);
|
package/src/sd-jwt/types.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { CredentialFormat } from "../entity/openid-connect/issuer/types";
|
2
1
|
import { JWK } from "../utils/jwk";
|
3
2
|
import { z } from "zod";
|
4
3
|
|
@@ -34,23 +33,12 @@ export type DisclosureWithEncoded = {
|
|
34
33
|
encoded: string;
|
35
34
|
};
|
36
35
|
|
37
|
-
export type Verification = z.infer<typeof Verification>;
|
38
|
-
export const Verification = z.object({
|
39
|
-
trust_framework: z.literal("eidas"),
|
40
|
-
assurance_level: z.string(),
|
41
|
-
evidence: z.object({
|
42
|
-
method: z.string(),
|
43
|
-
}),
|
44
|
-
});
|
45
|
-
|
46
36
|
export type SdJwt4VC = z.infer<typeof SdJwt4VC>;
|
47
37
|
export const SdJwt4VC = z.object({
|
48
38
|
header: z.object({
|
49
|
-
typ:
|
39
|
+
typ: z.literal("vc+sd-jwt"),
|
50
40
|
alg: z.string(),
|
51
41
|
kid: z.string().optional(),
|
52
|
-
x5c: z.string().optional(),
|
53
|
-
vctm: z.array(z.string()).optional(),
|
54
42
|
}),
|
55
43
|
payload: z.intersection(
|
56
44
|
z.object({
|
@@ -60,7 +48,7 @@ export const SdJwt4VC = z.object({
|
|
60
48
|
exp: UnixTime,
|
61
49
|
_sd_alg: z.literal("sha-256"),
|
62
50
|
status: z.object({
|
63
|
-
|
51
|
+
status_attestation: z.object({
|
64
52
|
credential_hash_alg: z.literal("sha-256"),
|
65
53
|
}),
|
66
54
|
}),
|
@@ -68,11 +56,6 @@ export const SdJwt4VC = z.object({
|
|
68
56
|
jwk: JWK,
|
69
57
|
}),
|
70
58
|
vct: z.string(),
|
71
|
-
"vct#integrity": z.string().optional(),
|
72
|
-
verification: Verification.optional(),
|
73
|
-
expiry_date: z.string().refine((str) => !isNaN(new Date(str).getTime())),
|
74
|
-
issuing_authority: z.string(),
|
75
|
-
issuing_country: z.string(),
|
76
59
|
}),
|
77
60
|
ObfuscatedDisclosures
|
78
61
|
),
|
@@ -0,0 +1,151 @@
|
|
1
|
+
import {
|
2
|
+
EntityConfiguration,
|
3
|
+
EntityStatement,
|
4
|
+
TrustAnchorEntityConfiguration,
|
5
|
+
} from "./types";
|
6
|
+
import { JWK } from "../utils/jwk";
|
7
|
+
import * as z from "zod";
|
8
|
+
import { getSignedEntityConfiguration, getSignedEntityStatement } from ".";
|
9
|
+
import { decode, type ParsedToken, verify } from "./utils";
|
10
|
+
import {
|
11
|
+
MissingFederationFetchEndpointError,
|
12
|
+
TrustChainEmptyError,
|
13
|
+
TrustChainRenewalError,
|
14
|
+
TrustChainTokenMissingError,
|
15
|
+
} from "./errors";
|
16
|
+
|
17
|
+
// The first element of the chain is supposed to be the Entity Configuration for the document issuer
|
18
|
+
const FirstElementShape = EntityConfiguration;
|
19
|
+
// Each element but the first is supposed to be an Entity Statement
|
20
|
+
const MiddleElementShape = EntityStatement;
|
21
|
+
// The last element of the chain can either be an Entity Statement
|
22
|
+
// or the Entity Configuration for the known Trust Anchor
|
23
|
+
const LastElementShape = z.union([
|
24
|
+
EntityStatement,
|
25
|
+
TrustAnchorEntityConfiguration,
|
26
|
+
]);
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Validates a provided trust chain against a known trust
|
30
|
+
*
|
31
|
+
* @param trustAnchorEntity The entity configuration of the known trust anchor
|
32
|
+
* @param chain The chain of statements to be validated
|
33
|
+
* @returns The list of parsed token representing the chain
|
34
|
+
* @throws {FederationError} If the chain is not valid
|
35
|
+
*/
|
36
|
+
export async function validateTrustChain(
|
37
|
+
trustAnchorEntity: TrustAnchorEntityConfiguration,
|
38
|
+
chain: string[]
|
39
|
+
): Promise<ParsedToken[]> {
|
40
|
+
// If the chain is empty, fail
|
41
|
+
if (chain.length === 0) {
|
42
|
+
throw new TrustChainEmptyError("Cannot verify empty trust chain.");
|
43
|
+
}
|
44
|
+
|
45
|
+
// Select the expected token shape
|
46
|
+
const selectTokenShape = (elementIndex: number) =>
|
47
|
+
elementIndex === 0
|
48
|
+
? FirstElementShape
|
49
|
+
: elementIndex === chain.length - 1
|
50
|
+
? LastElementShape
|
51
|
+
: MiddleElementShape;
|
52
|
+
|
53
|
+
// select the kid from the current index
|
54
|
+
const selectKid = (currentIndex: number): string => {
|
55
|
+
const token = chain[currentIndex];
|
56
|
+
if (!token) {
|
57
|
+
throw new TrustChainTokenMissingError(
|
58
|
+
`Token missing at index ${currentIndex} in trust chain.`,
|
59
|
+
{ index: currentIndex }
|
60
|
+
);
|
61
|
+
}
|
62
|
+
const shape = selectTokenShape(currentIndex);
|
63
|
+
return shape.parse(decode(token)).header.kid;
|
64
|
+
};
|
65
|
+
|
66
|
+
// select keys from the next token
|
67
|
+
// if the current token is the last, keys from trust anchor will be used
|
68
|
+
const selectKeys = (currentIndex: number): JWK[] => {
|
69
|
+
if (currentIndex === chain.length - 1) {
|
70
|
+
return trustAnchorEntity.payload.jwks.keys;
|
71
|
+
}
|
72
|
+
|
73
|
+
const nextIndex = currentIndex + 1;
|
74
|
+
const nextToken = chain[nextIndex];
|
75
|
+
if (!nextToken) {
|
76
|
+
throw new TrustChainTokenMissingError(
|
77
|
+
`Next token missing at index ${nextIndex} (needed for keys for token at ${currentIndex}).`,
|
78
|
+
{ index: nextIndex }
|
79
|
+
);
|
80
|
+
}
|
81
|
+
const shape = selectTokenShape(nextIndex);
|
82
|
+
return shape.parse(decode(nextToken)).payload.jwks.keys;
|
83
|
+
};
|
84
|
+
|
85
|
+
// Iterate the chain and validate each element's signature against the public keys of its next
|
86
|
+
// If there is no next, hence it's the end of the chain, and it must be verified by the Trust Anchor
|
87
|
+
return Promise.all(
|
88
|
+
chain
|
89
|
+
.map((token, i) => [token, selectKid(i), selectKeys(i)] as const)
|
90
|
+
.map((args) => verify(...args))
|
91
|
+
);
|
92
|
+
}
|
93
|
+
|
94
|
+
/**
|
95
|
+
* Given a trust chain, obtain a new trust chain by fetching each element's fresh version
|
96
|
+
*
|
97
|
+
* @param chain The original chain
|
98
|
+
* @param appFetch (optional) fetch api implementation
|
99
|
+
* @returns A list of signed token that represent the trust chain, in the same order of the provided chain
|
100
|
+
* @throws {FederationError} If the chain is not valid
|
101
|
+
*/
|
102
|
+
export async function renewTrustChain(
|
103
|
+
chain: string[],
|
104
|
+
appFetch: GlobalFetch["fetch"] = fetch
|
105
|
+
): Promise<string[]> {
|
106
|
+
return Promise.all(
|
107
|
+
chain.map(async (token, index) => {
|
108
|
+
const decoded = decode(token);
|
109
|
+
|
110
|
+
const entityStatementResult = EntityStatement.safeParse(decoded);
|
111
|
+
const entityConfigurationResult = EntityConfiguration.safeParse(decoded);
|
112
|
+
|
113
|
+
if (entityConfigurationResult.success) {
|
114
|
+
return getSignedEntityConfiguration(
|
115
|
+
entityConfigurationResult.data.payload.iss,
|
116
|
+
{ appFetch }
|
117
|
+
);
|
118
|
+
}
|
119
|
+
if (entityStatementResult.success) {
|
120
|
+
const entityStatement = entityStatementResult.data;
|
121
|
+
|
122
|
+
const parentBaseUrl = entityStatement.payload.iss;
|
123
|
+
const parentECJwt = await getSignedEntityConfiguration(parentBaseUrl, {
|
124
|
+
appFetch,
|
125
|
+
});
|
126
|
+
const parentEC = EntityConfiguration.parse(decode(parentECJwt));
|
127
|
+
|
128
|
+
const federationFetchEndpoint =
|
129
|
+
parentEC.payload.metadata.federation_entity.federation_fetch_endpoint;
|
130
|
+
if (!federationFetchEndpoint) {
|
131
|
+
throw new MissingFederationFetchEndpointError(
|
132
|
+
`Parent EC at ${parentBaseUrl} is missing federation_fetch_endpoint, cannot renew ES for ${entityStatement.payload.sub}.`,
|
133
|
+
{
|
134
|
+
entityBaseUrl: entityStatement.payload.sub,
|
135
|
+
missingInEntityUrl: parentBaseUrl,
|
136
|
+
}
|
137
|
+
);
|
138
|
+
}
|
139
|
+
return getSignedEntityStatement(
|
140
|
+
federationFetchEndpoint,
|
141
|
+
entityStatement.payload.sub,
|
142
|
+
{ appFetch }
|
143
|
+
);
|
144
|
+
}
|
145
|
+
throw new TrustChainRenewalError(
|
146
|
+
`Failed to renew trust chain. Reason: element #${index} failed to parse.`,
|
147
|
+
{ originalChain: chain }
|
148
|
+
);
|
149
|
+
})
|
150
|
+
);
|
151
|
+
}
|
@@ -0,0 +1,105 @@
|
|
1
|
+
import { IoWalletError, serializeAttrs } from "../utils/errors"; // Ensure this path is correct
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Base class for all federation-specific errors.
|
5
|
+
*/
|
6
|
+
export class FederationError extends IoWalletError {
|
7
|
+
constructor(message: string, details?: Record<string, unknown>) {
|
8
|
+
super(details ? serializeAttrs({ message, ...details }) : message);
|
9
|
+
this.name = this.constructor.name;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Error thrown when a trust chain is unexpectedly empty.
|
15
|
+
*/
|
16
|
+
export class TrustChainEmptyError extends FederationError {
|
17
|
+
code = "ERR_FED_TRUST_CHAIN_EMPTY";
|
18
|
+
constructor(message = "Trust chain cannot be empty.") {
|
19
|
+
super(message, undefined);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Error thrown when a token is unexpectedly missing from a trust chain during processing.
|
25
|
+
*/
|
26
|
+
export class TrustChainTokenMissingError extends FederationError {
|
27
|
+
code = "ERR_FED_TRUST_CHAIN_TOKEN_MISSING";
|
28
|
+
constructor(message: string, details?: { index?: number }) {
|
29
|
+
super(message, details);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Error thrown when renewing a trust chain fails.
|
35
|
+
* This class itself might be used or could be considered a more general renewal error.
|
36
|
+
*/
|
37
|
+
export class TrustChainRenewalError extends FederationError {
|
38
|
+
code = "ERR_FED_TRUST_CHAIN_RENEWAL_FAILED";
|
39
|
+
constructor(
|
40
|
+
message: string,
|
41
|
+
details?: { originalChain?: string[]; [key: string]: unknown }
|
42
|
+
) {
|
43
|
+
super(message, details);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
export class FederationListParseError extends FederationError {
|
48
|
+
code = "ERR_FED_FEDERATION_LIST_PARSE_FAILED";
|
49
|
+
constructor(message: string, details: { url: string; parseError?: string }) {
|
50
|
+
super(message, details);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
/**
|
55
|
+
* General error thrown during the trust chain building process.
|
56
|
+
*/
|
57
|
+
export class BuildTrustChainError extends FederationError {
|
58
|
+
code = "ERR_FED_BUILD_TRUST_CHAIN_FAILED";
|
59
|
+
constructor(
|
60
|
+
message: string,
|
61
|
+
details?: {
|
62
|
+
relyingPartyUrl?: string;
|
63
|
+
trustAnchorKid?: string;
|
64
|
+
[key: string]: unknown;
|
65
|
+
}
|
66
|
+
) {
|
67
|
+
super(message, details);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Error thrown when the Trust Anchor's key is missing a 'kid'.
|
73
|
+
*/
|
74
|
+
export class TrustAnchorKidMissingError extends FederationError {
|
75
|
+
code = "ERR_FED_TRUST_ANCHOR_KID_MISSING";
|
76
|
+
constructor(message = "Missing 'kid' in provided Trust Anchor key.") {
|
77
|
+
super(message, undefined);
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Error thrown if the Relying Party is not found in the Trust Anchor's federation list.
|
83
|
+
*/
|
84
|
+
export class RelyingPartyNotAuthorizedError extends FederationError {
|
85
|
+
code = "ERR_FED_RELYING_PARTY_NOT_AUTHORIZED";
|
86
|
+
constructor(
|
87
|
+
message: string,
|
88
|
+
details: { relyingPartyUrl: string; federationListEndpoint?: string }
|
89
|
+
) {
|
90
|
+
super(message, details);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
/**
|
95
|
+
* Error thrown when a 'federation_fetch_endpoint' is missing in an entity's configuration.
|
96
|
+
*/
|
97
|
+
export class MissingFederationFetchEndpointError extends FederationError {
|
98
|
+
code = "ERR_FED_MISSING_FEDERATION_FETCH_ENDPOINT";
|
99
|
+
constructor(
|
100
|
+
message: string,
|
101
|
+
details: { entityBaseUrl: string; missingInEntityUrl: string }
|
102
|
+
) {
|
103
|
+
super(message, details);
|
104
|
+
}
|
105
|
+
}
|
@@ -1,14 +1,24 @@
|
|
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";
|
12
22
|
|
13
23
|
export type {
|
14
24
|
WalletProviderEntityConfiguration,
|
@@ -24,11 +34,11 @@ export type {
|
|
24
34
|
* It can handle fast chain renewal, which means we try to fetch a fresh version of each statement.
|
25
35
|
*
|
26
36
|
* @param trustAnchorEntity The entity configuration of the known trust anchor
|
27
|
-
* @param chain The chain of statements to be
|
28
|
-
* @param
|
29
|
-
* @param
|
37
|
+
* @param chain The chain of statements to be validated
|
38
|
+
* @param renewOnFail Whether to renew the provided chain if the validation fails at first. Default: true
|
39
|
+
* @param appFetch Fetch api implementation. Default: the built-in implementation
|
30
40
|
* @returns The result of the chain validation
|
31
|
-
* @throws {
|
41
|
+
* @throws {FederationError} If the chain is not valid
|
32
42
|
*/
|
33
43
|
export async function verifyTrustChain(
|
34
44
|
trustAnchorEntity: TrustAnchorEntityConfiguration,
|
@@ -54,7 +64,7 @@ export async function verifyTrustChain(
|
|
54
64
|
* Fetch the signed entity configuration token for an entity
|
55
65
|
*
|
56
66
|
* @param entityBaseUrl The url of the entity to fetch
|
57
|
-
* @param
|
67
|
+
* @param appFetch (optional) fetch api implementation
|
58
68
|
* @returns The signed Entity Configuration token
|
59
69
|
*/
|
60
70
|
export async function getSignedEntityConfiguration(
|
@@ -86,6 +96,7 @@ export async function getSignedEntityConfiguration(
|
|
86
96
|
*
|
87
97
|
* @param entityBaseUrl The base url of the entity.
|
88
98
|
* @param schema The expected schema of the entity configuration, according to the kind of entity we are fetching from.
|
99
|
+
* @param options An optional object with additional options.
|
89
100
|
* @param options.appFetch An optional instance of the http client to be used.
|
90
101
|
* @returns The parsed entity configuration object
|
91
102
|
* @throws {IoWalletError} If the http request fails
|
@@ -200,12 +211,11 @@ export const getEntityConfiguration = (
|
|
200
211
|
/**
|
201
212
|
* Fetch and parse the entity statement document for a given federation entity.
|
202
213
|
*
|
203
|
-
* @param accreditationBodyBaseUrl The base url of the
|
214
|
+
* @param accreditationBodyBaseUrl The base url of the accreditation body which holds and signs the required entity statement
|
204
215
|
* @param subordinatedEntityBaseUrl The url that identifies the subordinate entity
|
205
|
-
* @param
|
216
|
+
* @param appFetch An optional instance of the http client to be used.
|
206
217
|
* @returns The parsed entity configuration object
|
207
218
|
* @throws {IoWalletError} If the http request fails
|
208
|
-
* @throws Parse error if the document is not in the expected shape.
|
209
219
|
*/
|
210
220
|
export async function getEntityStatement(
|
211
221
|
accreditationBodyBaseUrl: string,
|
@@ -234,14 +244,14 @@ export async function getEntityStatement(
|
|
234
244
|
/**
|
235
245
|
* Fetch the entity statement document for a given federation entity.
|
236
246
|
*
|
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
|
247
|
+
* @param federationFetchEndpoint The exact endpoint provided by the parent EC's metadata.
|
248
|
+
* @param subordinatedEntityBaseUrl The url that identifies the subordinate entity.
|
249
|
+
* @param appFetch An optional instance of the http client to be used.
|
250
|
+
* @returns The signed entity statement token.
|
251
|
+
* @throws {IoWalletError} If the http request fails.
|
242
252
|
*/
|
243
253
|
export async function getSignedEntityStatement(
|
244
|
-
|
254
|
+
federationFetchEndpoint: string,
|
245
255
|
subordinatedEntityBaseUrl: string,
|
246
256
|
{
|
247
257
|
appFetch = fetch,
|
@@ -249,13 +259,178 @@ export async function getSignedEntityStatement(
|
|
249
259
|
appFetch?: GlobalFetch["fetch"];
|
250
260
|
} = {}
|
251
261
|
) {
|
252
|
-
const url =
|
253
|
-
|
254
|
-
})}`;
|
262
|
+
const url = new URL(federationFetchEndpoint);
|
263
|
+
url.searchParams.set("sub", subordinatedEntityBaseUrl);
|
255
264
|
|
256
|
-
return await appFetch(url, {
|
265
|
+
return await appFetch(url.toString(), {
|
257
266
|
method: "GET",
|
258
267
|
})
|
259
268
|
.then(hasStatusOrThrow(200))
|
260
269
|
.then((res) => res.text());
|
261
270
|
}
|
271
|
+
|
272
|
+
/**
|
273
|
+
* Fetch the federation list document from a given endpoint.
|
274
|
+
*
|
275
|
+
* @param federationListEndpoint The URL of the federation list endpoint.
|
276
|
+
* @param appFetch An optional instance of the http client to be used.
|
277
|
+
* @returns The federation list as an array of strings.
|
278
|
+
* @throws {IoWalletError} If the HTTP request fails.
|
279
|
+
* @throws {FederationError} If the result is not in the expected format.
|
280
|
+
*/
|
281
|
+
export async function getFederationList(
|
282
|
+
federationListEndpoint: string,
|
283
|
+
{
|
284
|
+
appFetch = fetch,
|
285
|
+
}: {
|
286
|
+
appFetch?: GlobalFetch["fetch"];
|
287
|
+
} = {}
|
288
|
+
): Promise<string[]> {
|
289
|
+
return await appFetch(federationListEndpoint, {
|
290
|
+
method: "GET",
|
291
|
+
})
|
292
|
+
.then(hasStatusOrThrow(200))
|
293
|
+
.then((res) => res.json())
|
294
|
+
.then((json) => {
|
295
|
+
const result = FederationListResponse.safeParse(json);
|
296
|
+
if (!result.success) {
|
297
|
+
throw new FederationListParseError(
|
298
|
+
`Invalid federation list format received from ${federationListEndpoint}. Error: ${result.error.message}`,
|
299
|
+
{ url: federationListEndpoint, parseError: result.error.toString() }
|
300
|
+
);
|
301
|
+
}
|
302
|
+
return result.data;
|
303
|
+
});
|
304
|
+
}
|
305
|
+
|
306
|
+
/**
|
307
|
+
* Build a not-verified trust chain for a given Relying Party (RP) entity.
|
308
|
+
*
|
309
|
+
* @param relyingPartyEntityBaseUrl The base URL of the RP entity
|
310
|
+
* @param trustAnchorKey The public key of the Trust Anchor (TA) entity
|
311
|
+
* @param appFetch An optional instance of the http client to be used.
|
312
|
+
* @returns A list of signed tokens that represent the trust chain, in the order of the chain (from the RP to the Trust Anchor)
|
313
|
+
* @throws {FederationError} When an element of the chain fails to parse or other build steps fail.
|
314
|
+
*/
|
315
|
+
export async function buildTrustChain(
|
316
|
+
relyingPartyEntityBaseUrl: string,
|
317
|
+
trustAnchorKey: JWK,
|
318
|
+
appFetch: GlobalFetch["fetch"] = fetch
|
319
|
+
): Promise<string[]> {
|
320
|
+
// 1: Recursively gather the trust chain from the RP up to the Trust Anchor
|
321
|
+
const trustChain = await gatherTrustChain(
|
322
|
+
relyingPartyEntityBaseUrl,
|
323
|
+
appFetch
|
324
|
+
);
|
325
|
+
|
326
|
+
// 2: Trust Anchor signature verification
|
327
|
+
const trustAnchorJwt = trustChain[trustChain.length - 1];
|
328
|
+
if (!trustAnchorJwt) {
|
329
|
+
throw new BuildTrustChainError(
|
330
|
+
"Cannot verify trust anchor: missing entity configuration in gathered chain.",
|
331
|
+
{ relyingPartyUrl: relyingPartyEntityBaseUrl }
|
332
|
+
);
|
333
|
+
}
|
334
|
+
|
335
|
+
if (!trustAnchorKey.kid) {
|
336
|
+
throw new TrustAnchorKidMissingError();
|
337
|
+
}
|
338
|
+
|
339
|
+
await verify(trustAnchorJwt, trustAnchorKey.kid, [trustAnchorKey]);
|
340
|
+
|
341
|
+
// 3: Check the federation list
|
342
|
+
const trustAnchorConfig = EntityConfiguration.parse(decode(trustAnchorJwt));
|
343
|
+
const federationListEndpoint =
|
344
|
+
trustAnchorConfig.payload.metadata.federation_entity
|
345
|
+
.federation_list_endpoint;
|
346
|
+
|
347
|
+
if (federationListEndpoint) {
|
348
|
+
const federationList = await getFederationList(federationListEndpoint, {
|
349
|
+
appFetch,
|
350
|
+
});
|
351
|
+
|
352
|
+
if (!federationList.includes(relyingPartyEntityBaseUrl)) {
|
353
|
+
throw new RelyingPartyNotAuthorizedError(
|
354
|
+
"Relying Party entity base URL is not authorized by the Trust Anchor's federation list.",
|
355
|
+
{ relyingPartyUrl: relyingPartyEntityBaseUrl, federationListEndpoint }
|
356
|
+
);
|
357
|
+
}
|
358
|
+
}
|
359
|
+
|
360
|
+
return trustChain;
|
361
|
+
}
|
362
|
+
|
363
|
+
/**
|
364
|
+
* Recursively gather the trust chain for an entity and all its superiors.
|
365
|
+
* @param entityBaseUrl The base URL of the entity for which to gather the chain.
|
366
|
+
* @param appFetch An optional instance of the http client to be used.
|
367
|
+
* @param isLeaf Whether the current entity is the leaf of the chain.
|
368
|
+
* @returns A full ordered list of JWTs (ECs and ESs) forming the trust chain.
|
369
|
+
* @throws {FederationError} If any of the fetched documents fail to parse or other errors occur during the gathering process.
|
370
|
+
*/
|
371
|
+
async function gatherTrustChain(
|
372
|
+
entityBaseUrl: string,
|
373
|
+
appFetch: GlobalFetch["fetch"],
|
374
|
+
isLeaf: boolean = true
|
375
|
+
): Promise<string[]> {
|
376
|
+
const chain: string[] = [];
|
377
|
+
|
378
|
+
// Fetch self-signed EC (only needed for the leaf)
|
379
|
+
const entityECJwt = await getSignedEntityConfiguration(entityBaseUrl, {
|
380
|
+
appFetch,
|
381
|
+
});
|
382
|
+
const entityEC = EntityConfiguration.parse(decode(entityECJwt));
|
383
|
+
|
384
|
+
if (isLeaf) {
|
385
|
+
// Only push EC for the leaf
|
386
|
+
chain.push(entityECJwt);
|
387
|
+
}
|
388
|
+
|
389
|
+
// Find authority_hints (parent, if any)
|
390
|
+
const authorityHints = entityEC.payload.authority_hints ?? [];
|
391
|
+
if (authorityHints.length === 0) {
|
392
|
+
// This is the Trust Anchor (no parent)
|
393
|
+
if (!isLeaf) {
|
394
|
+
chain.push(entityECJwt);
|
395
|
+
}
|
396
|
+
return chain;
|
397
|
+
}
|
398
|
+
|
399
|
+
const parentEntityBaseUrl = authorityHints[0]!;
|
400
|
+
|
401
|
+
// Fetch parent EC
|
402
|
+
const parentECJwt = await getSignedEntityConfiguration(parentEntityBaseUrl, {
|
403
|
+
appFetch,
|
404
|
+
});
|
405
|
+
const parentEC = EntityConfiguration.parse(decode(parentECJwt));
|
406
|
+
|
407
|
+
// Fetch ES
|
408
|
+
const federationFetchEndpoint =
|
409
|
+
parentEC.payload.metadata.federation_entity.federation_fetch_endpoint;
|
410
|
+
if (!federationFetchEndpoint) {
|
411
|
+
throw new MissingFederationFetchEndpointError(
|
412
|
+
`Missing federation_fetch_endpoint in parent's (${parentEntityBaseUrl}) configuration when gathering chain for ${entityBaseUrl}.`,
|
413
|
+
{ entityBaseUrl, missingInEntityUrl: parentEntityBaseUrl }
|
414
|
+
);
|
415
|
+
}
|
416
|
+
|
417
|
+
const entityStatementJwt = await getSignedEntityStatement(
|
418
|
+
federationFetchEndpoint,
|
419
|
+
entityBaseUrl,
|
420
|
+
{ appFetch }
|
421
|
+
);
|
422
|
+
// Validate the ES
|
423
|
+
EntityStatement.parse(decode(entityStatementJwt));
|
424
|
+
|
425
|
+
// Push this ES into the chain
|
426
|
+
chain.push(entityStatementJwt);
|
427
|
+
|
428
|
+
// Recurse into the parent
|
429
|
+
const parentChain = await gatherTrustChain(
|
430
|
+
parentEntityBaseUrl,
|
431
|
+
appFetch,
|
432
|
+
false
|
433
|
+
);
|
434
|
+
|
435
|
+
return chain.concat(parentChain);
|
436
|
+
}
|