@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
@@ -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,35 @@
|
|
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
|
+
|
8
|
+
export type ParsedToken = {
|
9
|
+
header: JWTDecodeResult["protectedHeader"];
|
10
|
+
payload: JWTDecodeResult["payload"];
|
11
|
+
};
|
12
|
+
|
13
|
+
// Verify a token signature
|
14
|
+
// The kid is extracted from the token header
|
15
|
+
export const verify = async (
|
16
|
+
token: string,
|
17
|
+
kid: string,
|
18
|
+
jwks: JWK[]
|
19
|
+
): Promise<ParsedToken> => {
|
20
|
+
const jwk = jwks.find((k) => k.kid === kid);
|
21
|
+
if (!jwk) {
|
22
|
+
throw new Error(`Invalid kid: ${kid}, token: ${token}`);
|
23
|
+
}
|
24
|
+
const { protectedHeader: header, payload } = await verifyJwt(token, jwk);
|
25
|
+
return { header, payload };
|
26
|
+
};
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Return type for this function is necessary to avoid an issue during the bob build process.
|
30
|
+
* It seems like typescript can't correctly infer the return type of the function.
|
31
|
+
*/
|
32
|
+
export const decode = (token: string): ParsedToken => {
|
33
|
+
const { protectedHeader: header, payload } = decodeJwt(token);
|
34
|
+
return { header, payload };
|
35
|
+
};
|
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
|
});
|
package/src/utils/error-codes.ts
CHANGED
@@ -1,9 +1,21 @@
|
|
1
1
|
export const IssuerResponseErrorCodes = {
|
2
2
|
IssuerGenericError: "ERR_ISSUER_GENERIC_ERROR",
|
3
|
+
/**
|
4
|
+
* Error code thrown when a credential cannot be issued immediately because it follows the async flow.
|
5
|
+
*/
|
6
|
+
CredentialIssuingNotSynchronous: "ERR_CREDENTIAL_ISSUING_NOT_SYNCHRONOUS",
|
3
7
|
/**
|
4
8
|
* Error code thrown when an error occurs while requesting a credential.
|
5
9
|
*/
|
6
10
|
CredentialRequestFailed: "ERR_CREDENTIAL_REQUEST_FAILED",
|
11
|
+
/**
|
12
|
+
* Error code thrown when a credential status is invalid, either during issuance or when requesting a status attestation.
|
13
|
+
*/
|
14
|
+
CredentialInvalidStatus: "ERR_CREDENTIAL_INVALID_STATUS",
|
15
|
+
/**
|
16
|
+
* Error code thrown when an error occurs while obtaining a status attestation for a credential.
|
17
|
+
*/
|
18
|
+
StatusAttestationRequestFailed: "ERR_STATUS_ATTESTATION_REQUEST_FAILED",
|
7
19
|
} as const;
|
8
20
|
|
9
21
|
export const WalletProviderResponseErrorCodes = {
|
@@ -31,8 +43,19 @@ export const WalletProviderResponseErrorCodes = {
|
|
31
43
|
WalletInstanceNotFound: "ERR_IO_WALLET_INSTANCE_NOT_FOUND",
|
32
44
|
} as const;
|
33
45
|
|
46
|
+
export const RelyingPartyResponseErrorCodes = {
|
47
|
+
RelyingPartyGenericError: "ERR_RP_GENERIC_ERROR",
|
48
|
+
/**
|
49
|
+
* An error code thrown then the Relying Party rejects the Wallet's Authorization Response.
|
50
|
+
*/
|
51
|
+
InvalidAuthorizationResponse: "ERR_RP_INVALID_AUTHORIZATION_RESPONSE",
|
52
|
+
} as const;
|
53
|
+
|
34
54
|
export type IssuerResponseErrorCode =
|
35
55
|
(typeof IssuerResponseErrorCodes)[keyof typeof IssuerResponseErrorCodes];
|
36
56
|
|
37
57
|
export type WalletProviderResponseErrorCode =
|
38
58
|
(typeof WalletProviderResponseErrorCodes)[keyof typeof WalletProviderResponseErrorCodes];
|
59
|
+
|
60
|
+
export type RelyingPartyResponseErrorCode =
|
61
|
+
(typeof RelyingPartyResponseErrorCodes)[keyof typeof RelyingPartyResponseErrorCodes];
|
package/src/utils/errors.ts
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
import type { ProblemDetail } from "../client/generated/wallet-provider";
|
2
|
+
import type { CredentialIssuerEntityConfiguration } from "../trust";
|
2
3
|
import {
|
3
4
|
IssuerResponseErrorCodes,
|
4
5
|
WalletProviderResponseErrorCodes,
|
6
|
+
RelyingPartyResponseErrorCodes,
|
5
7
|
type IssuerResponseErrorCode,
|
6
8
|
type WalletProviderResponseErrorCode,
|
9
|
+
type RelyingPartyResponseErrorCode,
|
7
10
|
} from "./error-codes";
|
8
11
|
|
9
|
-
export {
|
12
|
+
export {
|
13
|
+
IssuerResponseErrorCodes,
|
14
|
+
WalletProviderResponseErrorCodes,
|
15
|
+
RelyingPartyResponseErrorCodes,
|
16
|
+
};
|
10
17
|
|
11
18
|
// An error reason that supports both a string and a generic JSON object
|
12
19
|
type GenericErrorReason = string | Record<string, unknown>;
|
@@ -109,8 +116,6 @@ export class UnexpectedStatusCodeError extends IoWalletError {
|
|
109
116
|
/**
|
110
117
|
* An error subclass thrown when an Issuer HTTP request fails.
|
111
118
|
* The specific error can be found in the `code` property.
|
112
|
-
*
|
113
|
-
* The class is generic over the error code to narrow down the reason.
|
114
119
|
*/
|
115
120
|
export class IssuerResponseError extends UnexpectedStatusCodeError {
|
116
121
|
code: IssuerResponseErrorCode;
|
@@ -148,6 +153,117 @@ export class WalletProviderResponseError extends UnexpectedStatusCodeError {
|
|
148
153
|
}
|
149
154
|
}
|
150
155
|
|
156
|
+
/**
|
157
|
+
* An error subclass thrown when a Relying Party HTTP request fails.
|
158
|
+
* The specific error can be found in the `code` property.
|
159
|
+
*/
|
160
|
+
export class RelyingPartyResponseError extends UnexpectedStatusCodeError {
|
161
|
+
code: RelyingPartyResponseErrorCode;
|
162
|
+
|
163
|
+
constructor(params: {
|
164
|
+
code?: RelyingPartyResponseErrorCode;
|
165
|
+
message: string;
|
166
|
+
reason: GenericErrorReason;
|
167
|
+
statusCode: number;
|
168
|
+
}) {
|
169
|
+
super(params);
|
170
|
+
this.code =
|
171
|
+
params.code ?? RelyingPartyResponseErrorCodes.RelyingPartyGenericError;
|
172
|
+
}
|
173
|
+
}
|
174
|
+
|
175
|
+
type LocalizedIssuanceError = {
|
176
|
+
[locale: string]: {
|
177
|
+
title: string;
|
178
|
+
description: string;
|
179
|
+
};
|
180
|
+
};
|
181
|
+
|
182
|
+
/**
|
183
|
+
* Function to extract the error message from the Entity Configuration's supported error codes.
|
184
|
+
* @param errorCode The error code to map to a meaningful message
|
185
|
+
* @param issuerConf The entity configuration for credentials
|
186
|
+
* @param credentialType The type of credential the error belongs to
|
187
|
+
* @returns A localized error {@link LocalizedIssuanceError} or undefined
|
188
|
+
* @throws {IoWalletError} When no credential config is found
|
189
|
+
*/
|
190
|
+
export function extractErrorMessageFromIssuerConf(
|
191
|
+
errorCode: string,
|
192
|
+
{
|
193
|
+
issuerConf,
|
194
|
+
credentialType,
|
195
|
+
}: {
|
196
|
+
issuerConf: CredentialIssuerEntityConfiguration["payload"]["metadata"];
|
197
|
+
credentialType: string;
|
198
|
+
}
|
199
|
+
): LocalizedIssuanceError | undefined {
|
200
|
+
const credentialConfiguration =
|
201
|
+
issuerConf.openid_credential_issuer.credential_configurations_supported[
|
202
|
+
credentialType
|
203
|
+
];
|
204
|
+
|
205
|
+
if (!credentialConfiguration) {
|
206
|
+
throw new IoWalletError(
|
207
|
+
`No configuration found for ${credentialType} in the provided EC`
|
208
|
+
);
|
209
|
+
}
|
210
|
+
|
211
|
+
const { issuance_errors_supported } = credentialConfiguration;
|
212
|
+
|
213
|
+
if (!issuance_errors_supported?.[errorCode]) {
|
214
|
+
return undefined;
|
215
|
+
}
|
216
|
+
|
217
|
+
const localesList = issuance_errors_supported[errorCode]!.display;
|
218
|
+
|
219
|
+
return localesList.reduce(
|
220
|
+
(acc, { locale, ...rest }) => ({ ...acc, [locale]: rest }),
|
221
|
+
{} as LocalizedIssuanceError
|
222
|
+
);
|
223
|
+
}
|
224
|
+
|
225
|
+
/**
|
226
|
+
* Factory function to create a type guard for specific error classes.
|
227
|
+
*
|
228
|
+
* @param errorClass The error class to create the type guard for
|
229
|
+
* @returns A type guard that checks if the error is an instance of the given class and has the expected code
|
230
|
+
*/
|
231
|
+
const makeErrorTypeGuard =
|
232
|
+
<T extends typeof UnexpectedStatusCodeError>(ErrorClass: T) =>
|
233
|
+
(error: unknown, code?: ExtractErrorCode<T>): error is InstanceType<T> =>
|
234
|
+
error instanceof ErrorClass && error.code === (code ?? error.code);
|
235
|
+
|
236
|
+
export const isIssuerResponseError = makeErrorTypeGuard(IssuerResponseError);
|
237
|
+
export const isWalletProviderResponseError = makeErrorTypeGuard(
|
238
|
+
WalletProviderResponseError
|
239
|
+
);
|
240
|
+
export const isRelyingPartyResponseError = makeErrorTypeGuard(
|
241
|
+
RelyingPartyResponseError
|
242
|
+
);
|
243
|
+
|
244
|
+
// Mapping type between error classes and their allowed codes
|
245
|
+
type ErrorCodeMap =
|
246
|
+
| {
|
247
|
+
type: typeof IssuerResponseError;
|
248
|
+
code: IssuerResponseErrorCode;
|
249
|
+
}
|
250
|
+
| {
|
251
|
+
type: typeof WalletProviderResponseError;
|
252
|
+
code: WalletProviderResponseErrorCode;
|
253
|
+
}
|
254
|
+
| {
|
255
|
+
type: typeof RelyingPartyResponseError;
|
256
|
+
code: RelyingPartyResponseErrorCode;
|
257
|
+
};
|
258
|
+
|
259
|
+
type ExtractErrorCode<T> = Extract<ErrorCodeMap, { type: T }>["code"];
|
260
|
+
|
261
|
+
type ErrorCase<T> = {
|
262
|
+
code: ExtractErrorCode<T>;
|
263
|
+
message: string;
|
264
|
+
reason?: GenericErrorReason;
|
265
|
+
};
|
266
|
+
|
151
267
|
/**
|
152
268
|
* Builder class used to create specialized errors from type {@link UnexpectedStatusCodeError} that handles multiple status codes.
|
153
269
|
*
|
@@ -185,15 +301,3 @@ export class ResponseErrorBuilder<T extends typeof UnexpectedStatusCodeError> {
|
|
185
301
|
return originalError;
|
186
302
|
}
|
187
303
|
}
|
188
|
-
|
189
|
-
type ErrorCodeMap<T> = T extends typeof IssuerResponseError
|
190
|
-
? IssuerResponseErrorCode
|
191
|
-
: T extends typeof WalletProviderResponseError
|
192
|
-
? WalletProviderResponseErrorCode
|
193
|
-
: never;
|
194
|
-
|
195
|
-
type ErrorCase<T> = {
|
196
|
-
code: ErrorCodeMap<T>;
|
197
|
-
message: string;
|
198
|
-
reason?: GenericErrorReason;
|
199
|
-
};
|
@@ -0,0 +1,68 @@
|
|
1
|
+
/**
|
2
|
+
* Logger interface which can be provided to the Logger class as a custom implementation.
|
3
|
+
*/
|
4
|
+
export interface LoggingContext {
|
5
|
+
logDebug: (msg: string) => void;
|
6
|
+
logInfo: (msg: string) => void;
|
7
|
+
logWarn: (msg: string) => void;
|
8
|
+
logError: (msg: string) => void;
|
9
|
+
}
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Supported debug levels.
|
13
|
+
*/
|
14
|
+
export enum LogLevel {
|
15
|
+
DEBUG,
|
16
|
+
INFO,
|
17
|
+
WARN,
|
18
|
+
ERROR,
|
19
|
+
}
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Logger singleton class which provides a simple logging interface with an init function to set the logging context and
|
23
|
+
* a static log function to log messages based on the debug level.
|
24
|
+
* This can be used as follows:
|
25
|
+
* const logger = Logger.getInstance();
|
26
|
+
* logger.initLogging(yourLoggingContext);
|
27
|
+
* logger.log(LogLevel.DEBUG, "Debug message");
|
28
|
+
*/
|
29
|
+
export class Logger {
|
30
|
+
private static instance: Logger | null = null;
|
31
|
+
private static loggingContext?: LoggingContext;
|
32
|
+
|
33
|
+
// Private constructor to prevent direct instantiation
|
34
|
+
private constructor() {}
|
35
|
+
|
36
|
+
// Public static method to get the Logger instance
|
37
|
+
public static getInstance(): Logger {
|
38
|
+
if (Logger.instance === null) {
|
39
|
+
Logger.instance = new Logger();
|
40
|
+
}
|
41
|
+
return Logger.instance;
|
42
|
+
}
|
43
|
+
|
44
|
+
// Method to initialize the logging context
|
45
|
+
public initLogging(loggingCtx: LoggingContext): void {
|
46
|
+
Logger.loggingContext = loggingCtx;
|
47
|
+
}
|
48
|
+
|
49
|
+
// Method to log based on the level which wraps the null check for the logging context
|
50
|
+
public static log(level: LogLevel, msg: string): void {
|
51
|
+
if (Logger.loggingContext) {
|
52
|
+
switch (level) {
|
53
|
+
case LogLevel.DEBUG:
|
54
|
+
Logger.loggingContext.logDebug(msg);
|
55
|
+
break;
|
56
|
+
case LogLevel.INFO:
|
57
|
+
Logger.loggingContext.logInfo(msg);
|
58
|
+
break;
|
59
|
+
case LogLevel.WARN:
|
60
|
+
Logger.loggingContext.logWarn(msg);
|
61
|
+
break;
|
62
|
+
case LogLevel.ERROR:
|
63
|
+
Logger.loggingContext.logError(msg);
|
64
|
+
break;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
package/src/utils/misc.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { IoWalletError, UnexpectedStatusCodeError } from "./errors";
|
2
2
|
import { sha256 } from "js-sha256";
|
3
|
+
import { LogLevel, Logger } from "./logging";
|
3
4
|
|
4
5
|
/**
|
5
6
|
* Check if a response is in the expected status, otherwise throw an error
|
@@ -13,6 +14,10 @@ export const hasStatusOrThrow =
|
|
13
14
|
async (res: Response): Promise<Response> => {
|
14
15
|
if (res.status !== status) {
|
15
16
|
const ErrorClass = customError ?? UnexpectedStatusCodeError;
|
17
|
+
Logger.log(
|
18
|
+
LogLevel.ERROR,
|
19
|
+
`Http request failed. Expected ${status}, got ${res.status}, url: ${res.url}`
|
20
|
+
);
|
16
21
|
throw new ErrorClass({
|
17
22
|
message: `Http request failed. Expected ${status}, got ${res.status}, url: ${res.url}`,
|
18
23
|
statusCode: res.status,
|