@pagopa/io-react-native-wallet 1.7.1 → 2.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -1
- package/lib/commonjs/client/generated/wallet-provider.js +49 -20
- package/lib/commonjs/client/generated/wallet-provider.js.map +1 -1
- package/lib/commonjs/credential/index.js +5 -1
- package/lib/commonjs/credential/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js +27 -0
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js +25 -16
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +30 -18
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/05-authorize-access.js +17 -12
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +36 -29
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +27 -207
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/README.md +23 -20
- package/lib/commonjs/credential/issuance/const.js +1 -1
- package/lib/commonjs/credential/issuance/const.js.map +1 -1
- package/lib/commonjs/credential/issuance/index.js +3 -3
- package/lib/commonjs/credential/issuance/index.js.map +1 -1
- package/lib/commonjs/credential/presentation/01-start-flow.js +14 -15
- package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js +6 -4
- package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
- package/lib/commonjs/credential/presentation/03-get-request-object.js +34 -7
- package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js +4 -126
- package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
- package/lib/commonjs/credential/presentation/05-verify-request-object.js +80 -25
- package/lib/commonjs/credential/presentation/05-verify-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js +6 -30
- package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +97 -117
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +86 -191
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js +112 -176
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/commonjs/credential/presentation/README.md +74 -79
- package/lib/commonjs/credential/presentation/errors.js +42 -21
- package/lib/commonjs/credential/presentation/errors.js.map +1 -1
- package/lib/commonjs/credential/presentation/index.js +13 -13
- package/lib/commonjs/credential/presentation/index.js.map +1 -1
- package/lib/commonjs/credential/presentation/types.js +53 -29
- package/lib/commonjs/credential/presentation/types.js.map +1 -1
- package/lib/commonjs/credential/status/01-start-flow.js +2 -0
- package/lib/commonjs/credential/status/01-start-flow.js.map +1 -0
- package/lib/commonjs/credential/status/02-status-attestation.js +73 -0
- package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -0
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +55 -0
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
- package/lib/commonjs/credential/status/README.md +67 -0
- package/lib/commonjs/credential/status/index.js +27 -0
- package/lib/commonjs/credential/status/index.js.map +1 -0
- package/lib/commonjs/credential/status/types.js +48 -0
- package/lib/commonjs/credential/status/types.js.map +1 -0
- package/lib/commonjs/credential/trustmark/README.md +62 -0
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js +86 -0
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js.map +1 -0
- package/lib/commonjs/credential/trustmark/index.js +13 -0
- package/lib/commonjs/credential/trustmark/index.js.map +1 -0
- package/lib/commonjs/index.js +5 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/pid/sd-jwt/types.js +18 -2
- package/lib/commonjs/pid/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/index.test.js +22 -34
- package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/types.test.js +11 -23
- package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/index.js +1 -7
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/commonjs/sd-jwt/types.js +5 -21
- package/lib/commonjs/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/trust/README.md +147 -0
- package/lib/commonjs/trust/chain.js +153 -0
- package/lib/commonjs/trust/chain.js.map +1 -0
- package/lib/commonjs/trust/errors.js +133 -0
- package/lib/commonjs/trust/errors.js.map +1 -0
- package/lib/commonjs/trust/index.js +288 -0
- package/lib/commonjs/trust/index.js.map +1 -0
- package/lib/commonjs/{entity/trust → trust}/types.js +27 -47
- package/lib/commonjs/trust/types.js.map +1 -0
- package/lib/commonjs/trust/utils.js +70 -0
- package/lib/commonjs/trust/utils.js.map +1 -0
- package/lib/commonjs/utils/crypto.js +5 -112
- package/lib/commonjs/utils/crypto.js.map +1 -1
- package/lib/commonjs/utils/decoder.js +2 -0
- package/lib/commonjs/utils/decoder.js.map +1 -1
- package/lib/commonjs/utils/error-codes.js +22 -2
- package/lib/commonjs/utils/error-codes.js.map +1 -1
- package/lib/commonjs/utils/errors.js +72 -4
- package/lib/commonjs/utils/errors.js.map +1 -1
- package/lib/commonjs/utils/logging.js +68 -0
- package/lib/commonjs/utils/logging.js.map +1 -0
- package/lib/commonjs/utils/misc.js +2 -0
- package/lib/commonjs/utils/misc.js.map +1 -1
- package/lib/commonjs/utils/par.js +17 -10
- package/lib/commonjs/utils/par.js.map +1 -1
- package/lib/commonjs/utils/string.js +1 -12
- package/lib/commonjs/utils/string.js.map +1 -1
- package/lib/commonjs/wallet-instance/index.js +14 -0
- package/lib/commonjs/wallet-instance/index.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/README.md +8 -3
- package/lib/commonjs/wallet-instance-attestation/issuing.js +15 -8
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/types.js +16 -20
- package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
- package/lib/module/client/generated/wallet-provider.js +40 -15
- package/lib/module/client/generated/wallet-provider.js.map +1 -1
- package/lib/module/credential/index.js +3 -1
- package/lib/module/credential/index.js.map +1 -1
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +20 -0
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
- package/lib/module/credential/issuance/03-start-user-authorization.js +25 -16
- package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js +30 -18
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/05-authorize-access.js +17 -11
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +36 -28
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +27 -205
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/issuance/README.md +23 -20
- package/lib/module/credential/issuance/const.js +1 -1
- package/lib/module/credential/issuance/const.js.map +1 -1
- package/lib/module/credential/issuance/index.js +2 -2
- package/lib/module/credential/issuance/index.js.map +1 -1
- package/lib/module/credential/presentation/01-start-flow.js +14 -15
- package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/module/credential/presentation/02-evaluate-rp-trust.js +5 -3
- package/lib/module/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
- package/lib/module/credential/presentation/03-get-request-object.js +34 -7
- package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/module/credential/presentation/04-retrieve-rp-jwks.js +2 -124
- package/lib/module/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
- package/lib/module/credential/presentation/05-verify-request-object.js +78 -23
- package/lib/module/credential/presentation/05-verify-request-object.js.map +1 -1
- package/lib/module/credential/presentation/06-fetch-presentation-definition.js +6 -30
- package/lib/module/credential/presentation/06-fetch-presentation-definition.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js +97 -118
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +83 -186
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/module/credential/presentation/08-send-authorization-response.js +107 -170
- package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/module/credential/presentation/README.md +74 -79
- package/lib/module/credential/presentation/errors.js +30 -17
- package/lib/module/credential/presentation/errors.js.map +1 -1
- package/lib/module/credential/presentation/index.js +6 -6
- package/lib/module/credential/presentation/index.js.map +1 -1
- package/lib/module/credential/presentation/types.js +49 -27
- package/lib/module/credential/presentation/types.js.map +1 -1
- package/lib/module/credential/status/01-start-flow.js +2 -0
- package/lib/module/credential/status/01-start-flow.js.map +1 -0
- package/lib/module/credential/status/02-status-attestation.js +66 -0
- package/lib/module/credential/status/02-status-attestation.js.map +1 -0
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +49 -0
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
- package/lib/module/credential/status/README.md +67 -0
- package/lib/module/credential/status/index.js +5 -0
- package/lib/module/credential/status/index.js.map +1 -0
- package/lib/module/credential/status/types.js +40 -0
- package/lib/module/credential/status/types.js.map +1 -0
- package/lib/module/credential/trustmark/README.md +62 -0
- package/lib/module/credential/trustmark/get-credential-trustmark.js +77 -0
- package/lib/module/credential/trustmark/get-credential-trustmark.js.map +1 -0
- package/lib/module/credential/trustmark/index.js +3 -0
- package/lib/module/credential/trustmark/index.js.map +1 -0
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/pid/sd-jwt/types.js +16 -1
- package/lib/module/pid/sd-jwt/types.js.map +1 -1
- package/lib/module/sd-jwt/__test__/index.test.js +22 -34
- package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/module/sd-jwt/__test__/types.test.js +11 -23
- package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/module/sd-jwt/index.js +1 -7
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/module/sd-jwt/types.js +4 -19
- package/lib/module/sd-jwt/types.js.map +1 -1
- package/lib/module/trust/README.md +147 -0
- package/lib/module/trust/chain.js +145 -0
- package/lib/module/trust/chain.js.map +1 -0
- package/lib/module/trust/errors.js +115 -0
- package/lib/module/trust/errors.js.map +1 -0
- package/lib/module/trust/index.js +269 -0
- package/lib/module/trust/index.js.map +1 -0
- package/lib/module/{entity/trust → trust}/types.js +25 -46
- package/lib/module/trust/types.js.map +1 -0
- package/lib/module/trust/utils.js +60 -0
- package/lib/module/trust/utils.js.map +1 -0
- package/lib/module/utils/crypto.js +4 -107
- package/lib/module/utils/crypto.js.map +1 -1
- package/lib/module/utils/decoder.js +3 -0
- package/lib/module/utils/decoder.js.map +1 -1
- package/lib/module/utils/error-codes.js +20 -1
- package/lib/module/utils/error-codes.js.map +1 -1
- package/lib/module/utils/errors.js +61 -4
- package/lib/module/utils/errors.js.map +1 -1
- package/lib/module/utils/logging.js +62 -0
- package/lib/module/utils/logging.js.map +1 -0
- package/lib/module/utils/misc.js +2 -0
- package/lib/module/utils/misc.js.map +1 -1
- package/lib/module/utils/par.js +17 -9
- package/lib/module/utils/par.js.map +1 -1
- package/lib/module/utils/string.js +0 -10
- package/lib/module/utils/string.js.map +1 -1
- package/lib/module/wallet-instance/index.js +13 -0
- package/lib/module/wallet-instance/index.js.map +1 -1
- package/lib/module/wallet-instance-attestation/README.md +8 -3
- package/lib/module/wallet-instance-attestation/index.js +2 -2
- package/lib/module/wallet-instance-attestation/index.js.map +1 -1
- package/lib/module/wallet-instance-attestation/issuing.js +16 -9
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/wallet-instance-attestation/types.js +14 -18
- package/lib/module/wallet-instance-attestation/types.js.map +1 -1
- package/lib/typescript/client/generated/wallet-provider.d.ts +206 -51
- package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
- package/lib/typescript/credential/index.d.ts +3 -1
- package/lib/typescript/credential/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -1
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts +19 -0
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +3 -3
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +9 -9
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts +3 -3
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +4 -4
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +3 -15
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/const.d.ts +1 -1
- package/lib/typescript/credential/issuance/const.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/index.d.ts +3 -3
- package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/types.d.ts +8 -3
- package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/01-start-flow.d.ts +28 -9
- package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts +2 -1
- package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts +7 -5
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts +4 -30
- package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts +17 -4
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts +4 -9
- package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +13 -12
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +40 -42
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +30 -43
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/errors.d.ts +25 -10
- package/lib/typescript/credential/presentation/errors.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/index.d.ts +7 -8
- package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/types.d.ts +137 -307
- package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
- package/lib/typescript/credential/status/01-start-flow.d.ts +10 -0
- package/lib/typescript/credential/status/01-start-flow.d.ts.map +1 -0
- package/lib/typescript/credential/status/02-status-attestation.d.ts +19 -0
- package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -0
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts +24 -0
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +1 -0
- package/lib/typescript/credential/status/index.d.ts +7 -0
- package/lib/typescript/credential/status/index.d.ts.map +1 -0
- package/lib/typescript/credential/status/types.d.ts +305 -0
- package/lib/typescript/credential/status/types.d.ts.map +1 -0
- package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts +52 -0
- package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts.map +1 -0
- package/lib/typescript/credential/trustmark/index.d.ts +4 -0
- package/lib/typescript/credential/trustmark/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +3 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/pid/sd-jwt/types.d.ts +103 -25
- package/lib/typescript/pid/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/index.d.ts +20 -72
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/types.d.ts +24 -129
- package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/trust/chain.d.ts +23 -0
- package/lib/typescript/trust/chain.d.ts.map +1 -0
- package/lib/typescript/trust/errors.d.ts +102 -0
- package/lib/typescript/trust/errors.d.ts.map +1 -0
- package/lib/typescript/{entity/trust → trust}/index.d.ts +308 -281
- package/lib/typescript/trust/index.d.ts.map +1 -0
- package/lib/typescript/{entity/trust → trust}/types.d.ts +1714 -1301
- package/lib/typescript/{entity/trust → trust}/types.d.ts.map +1 -1
- package/lib/typescript/trust/utils.d.ts +22 -0
- package/lib/typescript/trust/utils.d.ts.map +1 -0
- package/lib/typescript/utils/crypto.d.ts +0 -32
- package/lib/typescript/utils/crypto.d.ts.map +1 -1
- package/lib/typescript/utils/decoder.d.ts.map +1 -1
- package/lib/typescript/utils/error-codes.d.ts +20 -0
- package/lib/typescript/utils/error-codes.d.ts.map +1 -1
- package/lib/typescript/utils/errors.d.ts +55 -10
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/logging.d.ts +35 -0
- package/lib/typescript/utils/logging.d.ts.map +1 -0
- package/lib/typescript/utils/misc.d.ts.map +1 -1
- package/lib/typescript/utils/par.d.ts +8 -1
- package/lib/typescript/utils/par.d.ts.map +1 -1
- package/lib/typescript/utils/string.d.ts +0 -7
- package/lib/typescript/utils/string.d.ts.map +1 -1
- package/lib/typescript/wallet-instance/index.d.ts +8 -0
- package/lib/typescript/wallet-instance/index.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/index.d.ts +1 -2
- package/lib/typescript/wallet-instance-attestation/index.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts +4 -2
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/types.d.ts +60 -102
- package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
- package/package.json +9 -10
- package/src/client/generated/wallet-provider.ts +52 -17
- package/src/credential/index.ts +4 -1
- package/src/credential/issuance/01-start-flow.ts +1 -1
- package/src/credential/issuance/02-evaluate-issuer-trust.ts +32 -0
- package/src/credential/issuance/03-start-user-authorization.ts +48 -22
- package/src/credential/issuance/04-complete-user-authorization.ts +74 -18
- package/src/credential/issuance/05-authorize-access.ts +29 -11
- package/src/credential/issuance/06-obtain-credential.ts +61 -36
- package/src/credential/issuance/07-verify-and-parse-credential.ts +37 -264
- package/src/credential/issuance/README.md +23 -20
- package/src/credential/issuance/const.ts +1 -1
- package/src/credential/issuance/index.ts +6 -3
- package/src/credential/presentation/01-start-flow.ts +19 -22
- package/src/credential/presentation/02-evaluate-rp-trust.ts +5 -4
- package/src/credential/presentation/03-get-request-object.ts +36 -8
- package/src/credential/presentation/04-retrieve-rp-jwks.ts +6 -148
- package/src/credential/presentation/05-verify-request-object.ts +115 -30
- package/src/credential/presentation/06-fetch-presentation-definition.ts +5 -35
- package/src/credential/presentation/07-evaluate-dcql-query.ts +132 -161
- package/src/credential/presentation/07-evaluate-input-descriptor.ts +136 -254
- package/src/credential/presentation/08-send-authorization-response.ts +178 -260
- package/src/credential/presentation/README.md +74 -79
- package/src/credential/presentation/errors.ts +38 -15
- package/src/credential/presentation/index.ts +18 -19
- package/src/credential/presentation/types.ts +67 -64
- package/src/credential/status/01-start-flow.ts +9 -0
- package/src/credential/status/02-status-attestation.ts +105 -0
- package/src/credential/status/03-verify-and-parse-status-attestation.ts +70 -0
- package/src/credential/status/README.md +67 -0
- package/src/credential/status/index.ts +22 -0
- package/src/credential/status/types.ts +43 -0
- package/src/credential/trustmark/README.md +62 -0
- package/src/credential/trustmark/get-credential-trustmark.ts +139 -0
- package/src/credential/trustmark/index.ts +8 -0
- package/src/index.ts +4 -0
- package/src/pid/sd-jwt/types.ts +18 -1
- package/src/sd-jwt/__test__/index.test.ts +36 -55
- package/src/sd-jwt/__test__/types.test.ts +16 -29
- package/src/sd-jwt/index.ts +1 -5
- package/src/sd-jwt/types.ts +2 -19
- package/src/trust/README.md +147 -0
- package/src/trust/chain.ts +227 -0
- package/src/trust/errors.ts +136 -0
- package/src/{entity/trust → trust}/index.ts +207 -25
- package/src/{entity/trust → trust}/types.ts +24 -37
- package/src/trust/utils.ts +70 -0
- package/src/utils/crypto.ts +4 -106
- package/src/utils/decoder.ts +6 -1
- package/src/utils/error-codes.ts +23 -0
- package/src/utils/errors.ts +119 -15
- package/src/utils/logging.ts +68 -0
- package/src/utils/misc.ts +5 -0
- package/src/utils/par.ts +19 -6
- package/src/utils/string.ts +0 -10
- package/src/wallet-instance/index.ts +30 -1
- package/src/wallet-instance-attestation/README.md +8 -3
- package/src/wallet-instance-attestation/index.ts +2 -2
- package/src/wallet-instance-attestation/issuing.ts +33 -12
- package/src/wallet-instance-attestation/types.ts +18 -22
- package/lib/commonjs/credential/issuance/02-get-issuer-config.js +0 -48
- package/lib/commonjs/credential/issuance/02-get-issuer-config.js.map +0 -1
- package/lib/commonjs/entity/openid-connect/issuer/index.js +0 -25
- package/lib/commonjs/entity/openid-connect/issuer/index.js.map +0 -1
- package/lib/commonjs/entity/openid-connect/issuer/types.js +0 -64
- package/lib/commonjs/entity/openid-connect/issuer/types.js.map +0 -1
- package/lib/commonjs/entity/trust/chain.js +0 -122
- package/lib/commonjs/entity/trust/chain.js.map +0 -1
- package/lib/commonjs/entity/trust/index.js +0 -148
- package/lib/commonjs/entity/trust/index.js.map +0 -1
- package/lib/commonjs/entity/trust/types.js.map +0 -1
- package/lib/commonjs/mdoc/converters.js +0 -26
- package/lib/commonjs/mdoc/converters.js.map +0 -1
- package/lib/commonjs/mdoc/index.js +0 -68
- package/lib/commonjs/mdoc/index.js.map +0 -1
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -469
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -90
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
- package/lib/module/credential/issuance/02-get-issuer-config.js +0 -42
- package/lib/module/credential/issuance/02-get-issuer-config.js.map +0 -1
- package/lib/module/entity/openid-connect/issuer/index.js +0 -20
- package/lib/module/entity/openid-connect/issuer/index.js.map +0 -1
- package/lib/module/entity/openid-connect/issuer/types.js +0 -48
- package/lib/module/entity/openid-connect/issuer/types.js.map +0 -1
- package/lib/module/entity/trust/chain.js +0 -113
- package/lib/module/entity/trust/chain.js.map +0 -1
- package/lib/module/entity/trust/index.js +0 -131
- package/lib/module/entity/trust/index.js.map +0 -1
- package/lib/module/entity/trust/types.js.map +0 -1
- package/lib/module/mdoc/converters.js +0 -20
- package/lib/module/mdoc/converters.js.map +0 -1
- package/lib/module/mdoc/index.js +0 -60
- package/lib/module/mdoc/index.js.map +0 -1
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -462
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -83
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
- package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts +0 -32
- package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts.map +0 -1
- package/lib/typescript/entity/openid-connect/issuer/index.d.ts +0 -12
- package/lib/typescript/entity/openid-connect/issuer/index.d.ts.map +0 -1
- package/lib/typescript/entity/openid-connect/issuer/types.d.ts +0 -777
- package/lib/typescript/entity/openid-connect/issuer/types.d.ts.map +0 -1
- package/lib/typescript/entity/trust/chain.d.ts +0 -26
- package/lib/typescript/entity/trust/chain.d.ts.map +0 -1
- package/lib/typescript/entity/trust/index.d.ts.map +0 -1
- package/lib/typescript/mdoc/converters.d.ts +0 -8
- package/lib/typescript/mdoc/converters.d.ts.map +0 -1
- package/lib/typescript/mdoc/index.d.ts +0 -10
- package/lib/typescript/mdoc/index.d.ts.map +0 -1
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts +0 -3
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts.map +0 -1
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts +0 -42
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts.map +0 -1
- package/src/credential/issuance/02-get-issuer-config.ts +0 -67
- package/src/entity/openid-connect/issuer/index.ts +0 -27
- package/src/entity/openid-connect/issuer/types.ts +0 -76
- package/src/entity/trust/chain.ts +0 -154
- package/src/mdoc/converters.ts +0 -26
- package/src/mdoc/index.ts +0 -95
- package/src/utils/credential/issuance/07-verify-and-parse-credentials-inputs.ts +0 -615
- package/src/utils/credential/issuance/07-verify-and-parse-credentials-utils.ts +0 -171
@@ -0,0 +1,70 @@
|
|
1
|
+
import type { Out } from "../../utils/misc";
|
2
|
+
import { IoWalletError } from "../../utils/errors";
|
3
|
+
import { verify, type CryptoContext } from "@pagopa/io-react-native-jwt";
|
4
|
+
import type { EvaluateIssuerTrust, StatusAttestation } from "../status";
|
5
|
+
import { ParsedStatusAttestation } from "./types";
|
6
|
+
import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
|
7
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
8
|
+
|
9
|
+
export type VerifyAndParseStatusAttestation = (
|
10
|
+
issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
|
11
|
+
statusAttestation: Out<StatusAttestation>,
|
12
|
+
context: {
|
13
|
+
credentialCryptoContext: CryptoContext;
|
14
|
+
}
|
15
|
+
) => Promise<{ parsedStatusAttestation: ParsedStatusAttestation }>;
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Given a status attestation, verifies that:
|
19
|
+
* - It's in the supported format;
|
20
|
+
* - The attestation is correctly signed;
|
21
|
+
* - It's bound to the given key.
|
22
|
+
* @param issuerConf The Issuer configuration returned by {@link evaluateIssuerTrust}
|
23
|
+
* @param statusAttestation The encoded status attestation returned by {@link statusAttestation}
|
24
|
+
* @param context.credentialCryptoContext The crypto context used to obtain the credential in {@link obtainCredential}
|
25
|
+
* @returns A parsed status attestation
|
26
|
+
* @throws {IoWalletError} If the credential signature is not verified with the Issuer key set
|
27
|
+
* @throws {IoWalletError} If the credential is not bound to the provided user key
|
28
|
+
* @throws {IoWalletError} If the credential data fail to parse
|
29
|
+
*/
|
30
|
+
export const verifyAndParseStatusAttestation: VerifyAndParseStatusAttestation =
|
31
|
+
async (issuerConf, rawStatusAttestation, context) => {
|
32
|
+
try {
|
33
|
+
const { statusAttestation } = rawStatusAttestation;
|
34
|
+
const { credentialCryptoContext } = context;
|
35
|
+
|
36
|
+
await verify(
|
37
|
+
statusAttestation,
|
38
|
+
issuerConf.openid_credential_issuer.jwks.keys
|
39
|
+
);
|
40
|
+
|
41
|
+
const decodedJwt = decodeJwt(statusAttestation);
|
42
|
+
const parsedStatusAttestation = ParsedStatusAttestation.parse({
|
43
|
+
header: decodedJwt.protectedHeader,
|
44
|
+
payload: decodedJwt.payload,
|
45
|
+
});
|
46
|
+
|
47
|
+
Logger.log(
|
48
|
+
LogLevel.DEBUG,
|
49
|
+
`Parsed status attestation: ${JSON.stringify(parsedStatusAttestation)}`
|
50
|
+
);
|
51
|
+
|
52
|
+
const holderBindingKey = await credentialCryptoContext.getPublicKey();
|
53
|
+
const { cnf } = parsedStatusAttestation.payload;
|
54
|
+
if (!cnf.jwk.kid || cnf.jwk.kid !== holderBindingKey.kid) {
|
55
|
+
Logger.log(
|
56
|
+
LogLevel.ERROR,
|
57
|
+
`Failed to verify holder binding for status attestation, expected kid: ${holderBindingKey.kid}, got: ${parsedStatusAttestation.payload.cnf.jwk.kid}`
|
58
|
+
);
|
59
|
+
throw new IoWalletError(
|
60
|
+
`Failed to verify holder binding for status attestation, expected kid: ${holderBindingKey.kid}, got: ${parsedStatusAttestation.payload.cnf.jwk.kid}`
|
61
|
+
);
|
62
|
+
}
|
63
|
+
|
64
|
+
return { parsedStatusAttestation };
|
65
|
+
} catch (e) {
|
66
|
+
throw new IoWalletError(
|
67
|
+
`Failed to verify status attestation: ${JSON.stringify(e)}`
|
68
|
+
);
|
69
|
+
}
|
70
|
+
};
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# Credential Status Attestation
|
2
|
+
|
3
|
+
This flow is used to obtain a credential status attestation from its credential issuer. Each step in the flow is imported from the related file which is named with a sequential number.
|
4
|
+
The credential status attestation is a JWT which contains the credential status which indicates if the credential is valid or not.
|
5
|
+
The status attestation is supposed to be stored securely along with the credential. It has a limited lifetime and should be refreshed periodically according to the `exp` field in the JWT payload.
|
6
|
+
|
7
|
+
## Sequence Diagram
|
8
|
+
|
9
|
+
```mermaid
|
10
|
+
graph TD;
|
11
|
+
0[startFlow]
|
12
|
+
1[statusAttestation]
|
13
|
+
2[verifyAndParseStatusAttestation]
|
14
|
+
|
15
|
+
0 --> 1
|
16
|
+
1 --> 2
|
17
|
+
```
|
18
|
+
|
19
|
+
|
20
|
+
## Mapped results
|
21
|
+
|
22
|
+
The following errors are mapped to a `IssuerResponseError` with specific codes.
|
23
|
+
|
24
|
+
|HTTP Status|Error Code|Description|
|
25
|
+
|-----------|----------|-----------|
|
26
|
+
|`404 Not Found`|`ERR_CREDENTIAL_INVALID_STATUS`|This response is returned by the credential issuer when the status attestation is invalid. It might contain more details in the `reason` property.|
|
27
|
+
|
28
|
+
## Example
|
29
|
+
|
30
|
+
<details>
|
31
|
+
<summary>Credential status attestation flow</summary>
|
32
|
+
|
33
|
+
```ts
|
34
|
+
// Start the issuance flow
|
35
|
+
const credentialIssuerUrl = "https://issuer.example.com";
|
36
|
+
const startFlow: Credential.Status.StartFlow = () => ({
|
37
|
+
issuerUrl: credentialIssuerUrl, // Let's assum
|
38
|
+
});
|
39
|
+
|
40
|
+
const { issuerUrl } = startFlow();
|
41
|
+
|
42
|
+
// Evaluate issuer trust
|
43
|
+
const { issuerConf } = await Credential.Status.evaluateIssuerTrust(issuerUrl);
|
44
|
+
|
45
|
+
// Get the credential attestation
|
46
|
+
const res = await Credential.Status.statusAttestation(
|
47
|
+
issuerConf,
|
48
|
+
credential,
|
49
|
+
credentialCryptoContext
|
50
|
+
);
|
51
|
+
|
52
|
+
// Verify and parse the status attestation
|
53
|
+
const { parsedStatusAttestation } =
|
54
|
+
await Credential.Status.verifyAndParseStatusAttestation(
|
55
|
+
issuerConf,
|
56
|
+
res.statusAttestation,
|
57
|
+
{ credentialCryptoContext }
|
58
|
+
);
|
59
|
+
|
60
|
+
return {
|
61
|
+
statusAttestation: res.statusAttestation,
|
62
|
+
parsedStatusAttestation,
|
63
|
+
credentialType,
|
64
|
+
};
|
65
|
+
```
|
66
|
+
|
67
|
+
</details>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { type StartFlow } from "./01-start-flow";
|
2
|
+
import {
|
3
|
+
statusAttestation,
|
4
|
+
type StatusAttestation,
|
5
|
+
} from "./02-status-attestation";
|
6
|
+
import { evaluateIssuerTrust, type EvaluateIssuerTrust } from "../issuance";
|
7
|
+
import {
|
8
|
+
verifyAndParseStatusAttestation,
|
9
|
+
type VerifyAndParseStatusAttestation,
|
10
|
+
} from "./03-verify-and-parse-status-attestation";
|
11
|
+
|
12
|
+
export {
|
13
|
+
evaluateIssuerTrust,
|
14
|
+
statusAttestation,
|
15
|
+
verifyAndParseStatusAttestation,
|
16
|
+
};
|
17
|
+
export type {
|
18
|
+
StartFlow,
|
19
|
+
EvaluateIssuerTrust,
|
20
|
+
StatusAttestation,
|
21
|
+
VerifyAndParseStatusAttestation,
|
22
|
+
};
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { UnixTime } from "../../sd-jwt/types";
|
2
|
+
import { JWK } from "../../utils/jwk";
|
3
|
+
import * as z from "zod";
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Shape from parsing a status attestation response in case of 201.
|
7
|
+
*/
|
8
|
+
export const StatusAttestationResponse = z.object({
|
9
|
+
status_attestation: z.string(),
|
10
|
+
});
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Type from parsing a status attestation response in case of 201.
|
14
|
+
* Inferred from {@link StatusAttestationResponse}.
|
15
|
+
*/
|
16
|
+
export type StatusAttestationResponse = z.infer<
|
17
|
+
typeof StatusAttestationResponse
|
18
|
+
>;
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Type for a parsed status attestation.
|
22
|
+
*/
|
23
|
+
export type ParsedStatusAttestation = z.infer<typeof ParsedStatusAttestation>;
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Shape for parsing a status attestation in a JWT.
|
27
|
+
*/
|
28
|
+
export const ParsedStatusAttestation = z.object({
|
29
|
+
header: z.object({
|
30
|
+
typ: z.literal("status-attestation+jwt"),
|
31
|
+
alg: z.string(),
|
32
|
+
kid: z.string().optional(),
|
33
|
+
}),
|
34
|
+
payload: z.object({
|
35
|
+
credential_hash_alg: z.string(),
|
36
|
+
credential_hash: z.string(),
|
37
|
+
cnf: z.object({
|
38
|
+
jwk: JWK,
|
39
|
+
}),
|
40
|
+
exp: UnixTime,
|
41
|
+
iat: UnixTime,
|
42
|
+
}),
|
43
|
+
});
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# Credential Trustmark
|
2
|
+
|
3
|
+
A credential TrustMark is a signed JWT that verifies the authenticity of a credential issued by a trusted source. It serves as proof that a credential is valid and linked to a specific wallet instance.
|
4
|
+
The TrustMark is often presented as a QR code, containing cryptographic data to ensure it hasn't been tampered with. It includes fields like issuer, issuance and expiration timestamps, and credential-specific details. TrustMarks have a short validity period and are used to enhance security and prevent misuse, such as QR code swapping.
|
5
|
+
|
6
|
+
### getCredentialTrustmark
|
7
|
+
|
8
|
+
A function that generates a signed JWT Trustmark to verify the authenticity of a digital credential. The Trustmark serves as a cryptographic proof linking a credential to a specific wallet instance, ensuring the credential's validity and preventing unauthorized modifications or misuse.
|
9
|
+
|
10
|
+
#### Signature
|
11
|
+
|
12
|
+
```typescript
|
13
|
+
function getCredentialTrustmark({
|
14
|
+
walletInstanceAttestation: string,
|
15
|
+
wiaCryptoContext: CryptoContext,
|
16
|
+
credentialType: string,
|
17
|
+
docNumber?: string,
|
18
|
+
expirationTime?: number | string
|
19
|
+
}): Promise<{
|
20
|
+
jwt: string,
|
21
|
+
expirationTime: number
|
22
|
+
}>
|
23
|
+
```
|
24
|
+
|
25
|
+
#### Parameters
|
26
|
+
| Parameter | Type | Required | Description |
|
27
|
+
|-----------|------|----------|-------------|
|
28
|
+
| walletInstanceAttestation | string | Yes | A base64-encoded string containing the Wallet Instance Attestation (WIA). This attestation proves the authenticity of the wallet instance. |
|
29
|
+
| wiaCryptoContext | CryptoContext | Yes | The cryptographic context associated with the wallet instance. Must contain the same key pair used to generate the WIA. |
|
30
|
+
| credentialType | string | Yes | Identifier for the type of credential (e.g., "MDL" for Mobile Driver's License). |
|
31
|
+
| docNumber | string | No | The document number of the credential. If provided, it will be obfuscated in the Trustmark for privacy. |
|
32
|
+
| expirationTime | number \| string | No | Specifies when the Trustmark expires. Can be either:<br>- A timestamp in seconds<br>- A time span string (e.g., "2m" for 2 minutes)<br>Default: "2m" |
|
33
|
+
|
34
|
+
#### Return Value
|
35
|
+
|
36
|
+
Returns a Promise that resolves to an object containing:
|
37
|
+
| Property | Type | Description |
|
38
|
+
|----------|------|-------------|
|
39
|
+
| jwt | string | The signed trustmark JWT string |
|
40
|
+
| expirationTime | number | The expiration timestamp of the JWT in seconds |
|
41
|
+
|
42
|
+
## Example
|
43
|
+
|
44
|
+
```typescript
|
45
|
+
// Required inputs
|
46
|
+
const walletInstanceAttestation = "base64AttestationString";
|
47
|
+
const credentialType = "MDL"; // Credential type (e.g., Mobile Driver's License)
|
48
|
+
const documentNumber = "AB123456"; // Optional document number
|
49
|
+
const cryptoContext = createCryptoContextFor("wiaKeyTag"); // Sample crypto context
|
50
|
+
|
51
|
+
// Generate the TrustMark JWT
|
52
|
+
const { jwt, expirationTime } = await getCredentialTrustmark({
|
53
|
+
walletInstanceAttestation: "eyJ0eXAi...", // WIA JWT
|
54
|
+
wiaCryptoContext: cryptoContext,
|
55
|
+
credentialType: "IdentityCard",
|
56
|
+
docNumber: "AB123456",
|
57
|
+
expirationTime: "5m", // 5 minutes
|
58
|
+
});
|
59
|
+
|
60
|
+
console.log("Generated TrustMark JWT:", jwt);
|
61
|
+
console.log("Expires at:", new Date(expirationTime * 1000));
|
62
|
+
```
|
@@ -0,0 +1,139 @@
|
|
1
|
+
import {
|
2
|
+
SignJWT,
|
3
|
+
thumbprint,
|
4
|
+
type CryptoContext,
|
5
|
+
decode as decodeJwt,
|
6
|
+
} from "@pagopa/io-react-native-jwt";
|
7
|
+
import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
|
8
|
+
import { IoWalletError } from "../../utils/errors";
|
9
|
+
import { obfuscateString } from "../../utils/string";
|
10
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
11
|
+
|
12
|
+
export type GetCredentialTrustmarkJwt = (params: {
|
13
|
+
/**
|
14
|
+
* The Wallet Instance's attestation
|
15
|
+
*/
|
16
|
+
walletInstanceAttestation: string;
|
17
|
+
/**
|
18
|
+
* The Wallet Instance's crypto context associated with the walletInstanceAttestation parameter
|
19
|
+
*/
|
20
|
+
wiaCryptoContext: CryptoContext;
|
21
|
+
/**
|
22
|
+
* The type of credential for which the trustmark is generated
|
23
|
+
*/
|
24
|
+
credentialType: string;
|
25
|
+
/**
|
26
|
+
* (Optional) Document number contained in the credential, if applicable
|
27
|
+
*/
|
28
|
+
docNumber?: string;
|
29
|
+
/**
|
30
|
+
* (Optional) Expiration time for the trustmark, default is 2 minutes.
|
31
|
+
* If a number is provided, it is interpreted as a timestamp in seconds.
|
32
|
+
* If a string is provided, it is interpreted as a time span and added to the current timestamp.
|
33
|
+
*/
|
34
|
+
expirationTime?: number | string;
|
35
|
+
}) => Promise<{
|
36
|
+
/**
|
37
|
+
* The signed JWT
|
38
|
+
*/
|
39
|
+
jwt: string;
|
40
|
+
/**
|
41
|
+
* The expiration time of the JWT in seconds
|
42
|
+
*/
|
43
|
+
expirationTime: number;
|
44
|
+
}>;
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Generates a trustmark signed JWT, which is used to verify the authenticity of a credential.
|
48
|
+
* The public key used to sign the trustmark must the same used for the Wallet Instance Attestation.
|
49
|
+
*
|
50
|
+
* @param walletInstanceAttestation the Wallet Instance's attestation
|
51
|
+
* @param wiaCryptoContext The Wallet Instance's crypto context associated with the walletInstanceAttestation parameter
|
52
|
+
* @param credentialType The type of credential for which the trustmark is generated
|
53
|
+
* @param docNumber (Optional) Document number contained in the credential, if applicable
|
54
|
+
* @param expirationTime (Optional) Expiration time for the trustmark, default is 2 minutes.
|
55
|
+
* If a number is provided, it is interpreted as a timestamp in seconds.
|
56
|
+
* If a string is provided, it is interpreted as a time span and added to the current timestamp.
|
57
|
+
* @throws {IoWalletError} If the WIA is expired
|
58
|
+
* @throws {IoWalletError} If the public key associated to the WIA is not the same for the CryptoContext
|
59
|
+
* @throws {JWSSignatureVerificationFailed} If the WIA signature is not valid
|
60
|
+
* @returns A promise containing the signed JWT and its expiration time in seconds
|
61
|
+
*/
|
62
|
+
export const getCredentialTrustmark: GetCredentialTrustmarkJwt = async ({
|
63
|
+
walletInstanceAttestation,
|
64
|
+
wiaCryptoContext,
|
65
|
+
credentialType,
|
66
|
+
docNumber,
|
67
|
+
expirationTime = "2m",
|
68
|
+
}) => {
|
69
|
+
/**
|
70
|
+
* Check that the public key used to sign the trustmark is the one used for the WIA
|
71
|
+
*/
|
72
|
+
const holderBindingKey = await wiaCryptoContext.getPublicKey();
|
73
|
+
const decodedWia = WalletInstanceAttestation.decode(
|
74
|
+
walletInstanceAttestation
|
75
|
+
);
|
76
|
+
|
77
|
+
Logger.log(
|
78
|
+
LogLevel.DEBUG,
|
79
|
+
`Decoded wia ${JSON.stringify(decodedWia.payload)} with holder binding key ${JSON.stringify(holderBindingKey)}`
|
80
|
+
);
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Check that the WIA is not expired
|
84
|
+
*/
|
85
|
+
if (decodedWia.payload.exp * 1000 < Date.now()) {
|
86
|
+
Logger.log(
|
87
|
+
LogLevel.ERROR,
|
88
|
+
`Wallet Instance Attestation expired with exp: ${decodedWia.payload.exp}`
|
89
|
+
);
|
90
|
+
throw new IoWalletError("Wallet Instance Attestation expired");
|
91
|
+
}
|
92
|
+
|
93
|
+
/**
|
94
|
+
* Verify holder binding by comparing thumbprints of the WIA and the CryptoContext key
|
95
|
+
*/
|
96
|
+
const wiaThumbprint = await thumbprint(decodedWia.payload.cnf.jwk);
|
97
|
+
const cryptoContextThumbprint = await thumbprint(holderBindingKey);
|
98
|
+
|
99
|
+
if (wiaThumbprint !== cryptoContextThumbprint) {
|
100
|
+
Logger.log(
|
101
|
+
LogLevel.ERROR,
|
102
|
+
`Failed to verify holder binding for status attestation, expected thumbprint: ${cryptoContextThumbprint}, got: ${wiaThumbprint}`
|
103
|
+
);
|
104
|
+
throw new IoWalletError(
|
105
|
+
`Failed to verify holder binding for status attestation, expected thumbprint: ${cryptoContextThumbprint}, got: ${wiaThumbprint}`
|
106
|
+
);
|
107
|
+
}
|
108
|
+
|
109
|
+
Logger.log(
|
110
|
+
LogLevel.DEBUG,
|
111
|
+
`Wia thumbprint: ${wiaThumbprint} CryptoContext thumbprint: ${cryptoContextThumbprint}`
|
112
|
+
);
|
113
|
+
|
114
|
+
/**
|
115
|
+
* Generate Trustmark signed JWT
|
116
|
+
*/
|
117
|
+
const signedTrustmarkJwt = await new SignJWT(wiaCryptoContext)
|
118
|
+
.setProtectedHeader({
|
119
|
+
alg: "ES256",
|
120
|
+
})
|
121
|
+
.setPayload({
|
122
|
+
iss: walletInstanceAttestation,
|
123
|
+
/**
|
124
|
+
* If present, the document number is obfuscated before adding it to the payload
|
125
|
+
*/
|
126
|
+
...(docNumber ? { sub: obfuscateString(docNumber) } : {}),
|
127
|
+
subtyp: credentialType,
|
128
|
+
})
|
129
|
+
.setIssuedAt()
|
130
|
+
.setExpirationTime(expirationTime)
|
131
|
+
.sign();
|
132
|
+
|
133
|
+
const decodedTrustmark = decodeJwt(signedTrustmarkJwt);
|
134
|
+
|
135
|
+
return {
|
136
|
+
jwt: signedTrustmarkJwt,
|
137
|
+
expirationTime: decodedTrustmark.payload.exp ?? 0,
|
138
|
+
};
|
139
|
+
};
|
package/src/index.ts
CHANGED
@@ -9,7 +9,9 @@ import * as PID from "./pid";
|
|
9
9
|
import * as SdJwt from "./sd-jwt";
|
10
10
|
import * as Errors from "./utils/errors";
|
11
11
|
import * as WalletInstanceAttestation from "./wallet-instance-attestation";
|
12
|
+
import * as Trust from "./trust";
|
12
13
|
import * as WalletInstance from "./wallet-instance";
|
14
|
+
import * as Logging from "./utils/logging";
|
13
15
|
import { AuthorizationDetail, AuthorizationDetails } from "./utils/par";
|
14
16
|
import { createCryptoContextFor } from "./utils/crypto";
|
15
17
|
import type { IntegrityContext } from "./utils/integrity";
|
@@ -21,10 +23,12 @@ export {
|
|
21
23
|
WalletInstanceAttestation,
|
22
24
|
WalletInstance,
|
23
25
|
Errors,
|
26
|
+
Trust,
|
24
27
|
createCryptoContextFor,
|
25
28
|
AuthorizationDetail,
|
26
29
|
AuthorizationDetails,
|
27
30
|
fixBase64EncodingOnKey,
|
31
|
+
Logging,
|
28
32
|
};
|
29
33
|
|
30
34
|
export type { IntegrityContext, AuthorizationContext };
|
package/src/pid/sd-jwt/types.ts
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
import { z } from "zod";
|
2
|
-
|
2
|
+
|
3
|
+
const VerificationEvidence = z.object({
|
4
|
+
type: z.string(),
|
5
|
+
record: z.object({
|
6
|
+
type: z.string(),
|
7
|
+
source: z.object({
|
8
|
+
organization_name: z.string(),
|
9
|
+
organization_id: z.string(),
|
10
|
+
country_code: z.string(),
|
11
|
+
}),
|
12
|
+
}),
|
13
|
+
});
|
14
|
+
type Verification = z.infer<typeof Verification>;
|
15
|
+
const Verification = z.object({
|
16
|
+
trustFramework: z.literal("eidas"),
|
17
|
+
assuranceLevel: z.string(),
|
18
|
+
evidence: z.array(VerificationEvidence),
|
19
|
+
});
|
3
20
|
|
4
21
|
/**
|
5
22
|
* Data structure for the PID.
|
@@ -13,73 +13,56 @@ import { SdJwt4VC } from "../types";
|
|
13
13
|
// - "address" is used as verification._sd
|
14
14
|
// - all others disclosures are in claims._sd
|
15
15
|
const token =
|
16
|
-
"
|
16
|
+
"eyJraWQiOiItRl82VWdhOG4zVmVnalkyVTdZVUhLMXpMb2FELU5QVGM2M1JNSVNuTGF3IiwidHlwIjoidmMrc2Qtand0IiwiYWxnIjoiRVMyNTYifQ.eyJfc2QiOlsiMHExRDVKbWF2NnBRYUVoX0pfRmN2X3VOTk1RSWdDeWhRT3hxbFk0bDNxVSIsIktDSi1BVk52ODhkLXhqNnNVSUFPSnhGbmJVaDNySFhES2tJSDFsRnFiUnMiLCJNOWxvOVl4RE5JWHJBcTJxV2VpQ0E0MHpwSl96WWZGZFJfNEFFQUxjUnRVIiwiY3pnalVrMG5xUkNzd1NoQ2hDamRTNkExLXY0N2RfcVRDU0ZJdklIaE1vSSIsIm5HblFyN2NsbTN0ZlRwOHlqTF91SHJEU090elIyUFZiOFM3R2VMZEFxQlEiLCJ4TklWd2xwU3NhWjhDSlNmMGd6NXhfNzVWUldXYzZWMW1scGVqZENycVVzIl0sInN1YiI6IjIxNmY4OTQ2LTllY2ItNDgxOS05MzA5LWMwNzZmMzRhN2UxMSIsIl9zZF9hbGciOiJzaGEtMjU2IiwidmN0IjoiUGVyc29uSWRlbnRpZmljYXRpb25EYXRhIiwiaXNzIjoiaHR0cHM6Ly9wcmUuZWlkLndhbGxldC5pcHpzLml0IiwiY25mIjp7Imp3ayI6eyJrdHkiOiJFQyIsImNydiI6IlAtMjU2Iiwia2lkIjoiUnYzVy1FaUtwdkJUeWs1eVp4dnJldi03TURCNlNselVDQm9fQ1FqamRkVSIsIngiOiIwV294N1F0eVBxQnlnMzVNSF9YeUNjbmQ1TGUtSm0wQVhIbFVnREJBMDNZIiwieSI6ImVFaFZ2ZzFKUHFOZDNEVFNhNG1HREdCbHdZNk5QLUVaYkxiTkZYU1h3SWcifX0sImV4cCI6MTc1MTU0NjU3Niwic3RhdHVzIjp7InN0YXR1c19hdHRlc3RhdGlvbiI6eyJjcmVkZW50aWFsX2hhc2hfYWxnIjoic2hhLTI1NiJ9fX0.qXHA2oqr8trX4fGxpxpUft2GX380TM3pzfo1MYAsDjUC8HsODA-4rdRWAvDe2zYP57x4tJU7eiABkd1Kmln9yQ~WyJrSkRFUDhFYU5URU1CRE9aelp6VDR3IiwidW5pcXVlX2lkIiwiVElOSVQtTFZMREFBODVUNTBHNzAyQiJd~WyJ6SUF5VUZ2UGZJcEUxekJxeEk1aGFRIiwiYmlydGhfZGF0ZSIsIjE5ODUtMTItMTAiXQ~WyJHcjNSM3MyOTBPa1FVbS1ORlR1OTZBIiwidGF4X2lkX2NvZGUiLCJUSU5JVC1MVkxEQUE4NVQ1MEc3MDJCIl0~WyJHeE9SYWxNQWVsZlowZWRGSmpqWVV3IiwiZ2l2ZW5fbmFtZSIsIkFkYSJd~WyJfdlY1UklrbDBJT0VYS290czlrdDF3IiwiZmFtaWx5X25hbWUiLCJMb3ZlbGFjZSJd~WyJDajV0Y2NSNzJKd3J6ZTJUVzRhLXdnIiwiaWF0IiwxNzIwMDEwNTc1XQ";
|
17
17
|
|
18
18
|
const unsigned =
|
19
|
-
"
|
19
|
+
"eyJraWQiOiItRl82VWdhOG4zVmVnalkyVTdZVUhLMXpMb2FELU5QVGM2M1JNSVNuTGF3IiwidHlwIjoidmMrc2Qtand0IiwiYWxnIjoiRVMyNTYifQ.eyJfc2QiOlsiMHExRDVKbWF2NnBRYUVoX0pfRmN2X3VOTk1RSWdDeWhRT3hxbFk0bDNxVSIsIktDSi1BVk52ODhkLXhqNnNVSUFPSnhGbmJVaDNySFhES2tJSDFsRnFiUnMiLCJNOWxvOVl4RE5JWHJBcTJxV2VpQ0E0MHpwSl96WWZGZFJfNEFFQUxjUnRVIiwiY3pnalVrMG5xUkNzd1NoQ2hDamRTNkExLXY0N2RfcVRDU0ZJdklIaE1vSSIsIm5HblFyN2NsbTN0ZlRwOHlqTF91SHJEU090elIyUFZiOFM3R2VMZEFxQlEiLCJ4TklWd2xwU3NhWjhDSlNmMGd6NXhfNzVWUldXYzZWMW1scGVqZENycVVzIl0sInN1YiI6IjIxNmY4OTQ2LTllY2ItNDgxOS05MzA5LWMwNzZmMzRhN2UxMSIsIl9zZF9hbGciOiJzaGEtMjU2IiwidmN0IjoiUGVyc29uSWRlbnRpZmljYXRpb25EYXRhIiwiaXNzIjoiaHR0cHM6Ly9wcmUuZWlkLndhbGxldC5pcHpzLml0IiwiY25mIjp7Imp3ayI6eyJrdHkiOiJFQyIsImNydiI6IlAtMjU2Iiwia2lkIjoiUnYzVy1FaUtwdkJUeWs1eVp4dnJldi03TURCNlNselVDQm9fQ1FqamRkVSIsIngiOiIwV294N1F0eVBxQnlnMzVNSF9YeUNjbmQ1TGUtSm0wQVhIbFVnREJBMDNZIiwieSI6ImVFaFZ2ZzFKUHFOZDNEVFNhNG1HREdCbHdZNk5QLUVaYkxiTkZYU1h3SWcifX0sImV4cCI6MTc1MTU0NjU3Niwic3RhdHVzIjp7InN0YXR1c19hdHRlc3RhdGlvbiI6eyJjcmVkZW50aWFsX2hhc2hfYWxnIjoic2hhLTI1NiJ9fX0";
|
20
20
|
|
21
21
|
const signature =
|
22
|
-
"
|
22
|
+
"qXHA2oqr8trX4fGxpxpUft2GX380TM3pzfo1MYAsDjUC8HsODA-4rdRWAvDe2zYP57x4tJU7eiABkd1Kmln9yQ";
|
23
23
|
|
24
24
|
const signed = `${unsigned}.${signature}`;
|
25
25
|
|
26
26
|
const tokenizedDisclosures = [
|
27
|
-
"
|
28
|
-
"
|
29
|
-
"
|
30
|
-
"
|
31
|
-
"
|
32
|
-
"
|
33
|
-
"WyJrazlUVW9DQm9OZFd0VElpUWJValNBIiwidGF4X2lkX2NvZGUiLCJUSU5JVC1TUENNUkE5NUE1OEg1MDFUIl0",
|
34
|
-
"WyJjclNLNDlpaWpiZTdSbFFLSXlvcmlRIiwiaWF0IiwxNzQ3NzQ3MTI1XQ",
|
27
|
+
"WyJrSkRFUDhFYU5URU1CRE9aelp6VDR3IiwidW5pcXVlX2lkIiwiVElOSVQtTFZMREFBODVUNTBHNzAyQiJd",
|
28
|
+
"WyJ6SUF5VUZ2UGZJcEUxekJxeEk1aGFRIiwiYmlydGhfZGF0ZSIsIjE5ODUtMTItMTAiXQ",
|
29
|
+
"WyJHcjNSM3MyOTBPa1FVbS1ORlR1OTZBIiwidGF4X2lkX2NvZGUiLCJUSU5JVC1MVkxEQUE4NVQ1MEc3MDJCIl0",
|
30
|
+
"WyJHeE9SYWxNQWVsZlowZWRGSmpqWVV3IiwiZ2l2ZW5fbmFtZSIsIkFkYSJd",
|
31
|
+
"WyJfdlY1UklrbDBJT0VYS290czlrdDF3IiwiZmFtaWx5X25hbWUiLCJMb3ZlbGFjZSJd",
|
32
|
+
"WyJDajV0Y2NSNzJKd3J6ZTJUVzRhLXdnIiwiaWF0IiwxNzIwMDEwNTc1XQ",
|
35
33
|
];
|
36
34
|
|
37
35
|
const sdJwt = {
|
38
36
|
header: {
|
39
|
-
kid: "
|
37
|
+
kid: "-F_6Uga8n3VegjY2U7YUHK1zLoaD-NPTc63RMISnLaw",
|
40
38
|
typ: "vc+sd-jwt",
|
41
39
|
alg: "ES256",
|
42
40
|
},
|
43
41
|
payload: {
|
44
|
-
sub: "ZLbdJnwBmqBK6iRjfefusjr0Y1I5HMu1IeqryMbFz4g",
|
45
|
-
vct: "urn:eu.europa.ec.eudi:pid:1",
|
46
|
-
expiry_date: "2026-05-20",
|
47
|
-
iss: "https://api.potential-wallet-it-pid-provider.it",
|
48
42
|
_sd: [
|
49
|
-
"
|
50
|
-
"
|
51
|
-
"
|
52
|
-
"
|
53
|
-
"
|
54
|
-
"
|
55
|
-
"wQTDzXpVi6iUkMrQol4WiZJpfHlKahf-K-lXf18FYuc",
|
56
|
-
"xjg5MlJWp5jTimvXsivQRhLVqe8cSzadMZ60Hkk53js",
|
43
|
+
"0q1D5Jmav6pQaEh_J_Fcv_uNNMQIgCyhQOxqlY4l3qU",
|
44
|
+
"KCJ-AVNv88d-xj6sUIAOJxFnbUh3rHXDKkIH1lFqbRs",
|
45
|
+
"M9lo9YxDNIXrAq2qWeiCA40zpJ_zYfFdR_4AEALcRtU",
|
46
|
+
"czgjUk0nqRCswShChCjdS6A1-v47d_qTCSFIvIHhMoI",
|
47
|
+
"nGnQr7clm3tfTp8yjL_uHrDSOtzR2PVb8S7GeLdAqBQ",
|
48
|
+
"xNIVwlpSsaZ8CJSf0gz5x_75VRWWc6V1mlpejdCrqUs",
|
57
49
|
],
|
58
|
-
"
|
59
|
-
"242302d97d38da2714a257f2a253bf2fa30aae5c109fe9581bfcda3b1d797c97",
|
60
|
-
issuing_country: "IT",
|
50
|
+
sub: "216f8946-9ecb-4819-9309-c076f34a7e11",
|
61
51
|
_sd_alg: "sha-256",
|
62
|
-
|
52
|
+
vct: "PersonIdentificationData",
|
53
|
+
iss: "https://pre.eid.wallet.ipzs.it",
|
63
54
|
cnf: {
|
64
55
|
jwk: {
|
65
56
|
kty: "EC",
|
66
57
|
crv: "P-256",
|
67
|
-
kid: "
|
68
|
-
x: "
|
69
|
-
y: "
|
58
|
+
kid: "Rv3W-EiKpvBTyk5yZxvrev-7MDB6SlzUCBo_CQjjddU",
|
59
|
+
x: "0Wox7QtyPqByg35MH_XyCcnd5Le-Jm0AXHlUgDBA03Y",
|
60
|
+
y: "eEhVvg1JPqNd3DTSa4mGDGBlwY6NP-EZbLbNFXSXwIg",
|
70
61
|
},
|
71
62
|
},
|
72
|
-
exp:
|
73
|
-
iat: 1747747125,
|
74
|
-
verification: {
|
75
|
-
evidence: {
|
76
|
-
method: "cie",
|
77
|
-
},
|
78
|
-
trust_framework: "eidas",
|
79
|
-
assurance_level: "high",
|
80
|
-
},
|
63
|
+
exp: 1751546576,
|
81
64
|
status: {
|
82
|
-
|
65
|
+
status_attestation: {
|
83
66
|
credential_hash_alg: "sha-256",
|
84
67
|
},
|
85
68
|
},
|
@@ -88,14 +71,12 @@ const sdJwt = {
|
|
88
71
|
|
89
72
|
// In the very same order than tokenizedDisclosures
|
90
73
|
const disclosures = [
|
91
|
-
["
|
92
|
-
["
|
93
|
-
["
|
94
|
-
["
|
95
|
-
["
|
96
|
-
["
|
97
|
-
["kk9TUoCBoNdWtTIiQbUjSA", "tax_id_code", "TINIT-SPCMRA95A58H501T"],
|
98
|
-
["crSK49iijbe7RlQKIyoriQ", "iat", 1747747125],
|
74
|
+
["kJDEP8EaNTEMBDOZzZzT4w", "unique_id", "TINIT-LVLDAA85T50G702B"],
|
75
|
+
["zIAyUFvPfIpE1zBqxI5haQ", "birth_date", "1985-12-10"],
|
76
|
+
["Gr3R3s290OkQUm-NFTu96A", "tax_id_code", "TINIT-LVLDAA85T50G702B"],
|
77
|
+
["GxORalMAelfZ0edFJjjYUw", "given_name", "Ada"],
|
78
|
+
["_vV5RIkl0IOEXKots9kt1w", "family_name", "Lovelace"],
|
79
|
+
["Cj5tccR72Jwrze2TW4a-wg", "iat", 1720010575],
|
99
80
|
];
|
100
81
|
it("Ensures example data correctness", () => {
|
101
82
|
expect(
|
@@ -149,10 +130,10 @@ describe("decode", () => {
|
|
149
130
|
|
150
131
|
describe("disclose", () => {
|
151
132
|
it("should encode a valid sdjwt (one claim)", async () => {
|
152
|
-
const result = await disclose(token, ["
|
133
|
+
const result = await disclose(token, ["given_name"]);
|
153
134
|
const expected = {
|
154
|
-
token: `${signed}~
|
155
|
-
paths: [{ claim: "
|
135
|
+
token: `${signed}~WyJHeE9SYWxNQWVsZlowZWRGSmpqWVV3IiwiZ2l2ZW5fbmFtZSIsIkFkYSJd`,
|
136
|
+
paths: [{ claim: "given_name", path: "verified_claims.claims._sd[3]" }],
|
156
137
|
};
|
157
138
|
|
158
139
|
expect(result).toEqual(expected);
|
@@ -168,15 +149,15 @@ describe("disclose", () => {
|
|
168
149
|
it("should encode a valid sdjwt (multiple claims)", async () => {
|
169
150
|
const result = await disclose(token, ["iat", "family_name"]);
|
170
151
|
const expected = {
|
171
|
-
token: `${signed}~
|
152
|
+
token: `${signed}~WyJfdlY1UklrbDBJT0VYS290czlrdDF3IiwiZmFtaWx5X25hbWUiLCJMb3ZlbGFjZSJd~WyJDajV0Y2NSNzJKd3J6ZTJUVzRhLXdnIiwiaWF0IiwxNzIwMDEwNTc1XQ`,
|
172
153
|
paths: [
|
173
154
|
{
|
174
155
|
claim: "iat",
|
175
|
-
path: "verified_claims.claims._sd[
|
156
|
+
path: "verified_claims.claims._sd[4]",
|
176
157
|
},
|
177
158
|
{
|
178
159
|
claim: "family_name",
|
179
|
-
path: "verified_claims.claims._sd[
|
160
|
+
path: "verified_claims.claims._sd[0]",
|
180
161
|
},
|
181
162
|
],
|
182
163
|
};
|