@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
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,
|
package/src/utils/par.ts
CHANGED
@@ -3,16 +3,18 @@ import {
|
|
3
3
|
type CryptoContext,
|
4
4
|
SignJWT,
|
5
5
|
} from "@pagopa/io-react-native-jwt";
|
6
|
-
import
|
6
|
+
import { v4 as uuidv4 } from "uuid";
|
7
7
|
import * as z from "zod";
|
8
8
|
import * as WalletInstanceAttestation from "../wallet-instance-attestation";
|
9
9
|
import { generateRandomAlphaNumericString, hasStatusOrThrow } from "./misc";
|
10
10
|
import { createPopToken } from "./pop";
|
11
11
|
import { IssuerResponseError } from "./errors";
|
12
|
+
import { LogLevel, Logger } from "./logging";
|
12
13
|
|
13
14
|
export type AuthorizationDetail = z.infer<typeof AuthorizationDetail>;
|
14
15
|
export const AuthorizationDetail = z.object({
|
15
16
|
credential_configuration_id: z.string(),
|
17
|
+
format: z.union([z.literal("vc+sd-jwt"), z.literal("vc+mdoc-cbor")]),
|
16
18
|
type: z.literal("openid_credential"),
|
17
19
|
});
|
18
20
|
|
@@ -37,7 +39,8 @@ export const makeParRequest =
|
|
37
39
|
responseMode: string,
|
38
40
|
parEndpoint: string,
|
39
41
|
walletInstanceAttestation: string,
|
40
|
-
authorizationDetails: AuthorizationDetails
|
42
|
+
authorizationDetails: AuthorizationDetails,
|
43
|
+
assertionType: string
|
41
44
|
): Promise<string> => {
|
42
45
|
const wiaPublicKey = await wiaCryptoContext.getPublicKey();
|
43
46
|
|
@@ -49,7 +52,7 @@ export const makeParRequest =
|
|
49
52
|
|
50
53
|
const signedWiaPoP = await createPopToken(
|
51
54
|
{
|
52
|
-
jti: `${
|
55
|
+
jti: `${uuidv4()}`,
|
53
56
|
aud,
|
54
57
|
iss,
|
55
58
|
},
|
@@ -72,7 +75,7 @@ export const makeParRequest =
|
|
72
75
|
kid: wiaPublicKey.kid,
|
73
76
|
})
|
74
77
|
.setPayload({
|
75
|
-
jti: `${
|
78
|
+
jti: `${uuidv4()}`,
|
76
79
|
aud,
|
77
80
|
response_type: "code",
|
78
81
|
response_mode: responseMode,
|
@@ -83,6 +86,8 @@ export const makeParRequest =
|
|
83
86
|
code_challenge_method: codeChallengeMethod,
|
84
87
|
authorization_details: authorizationDetails,
|
85
88
|
redirect_uri: redirectUri,
|
89
|
+
client_assertion_type: assertionType,
|
90
|
+
client_assertion: walletInstanceAttestation + "~" + signedWiaPoP,
|
86
91
|
})
|
87
92
|
.setIssuedAt() //iat is set to now
|
88
93
|
.setExpirationTime("5min")
|
@@ -90,16 +95,24 @@ export const makeParRequest =
|
|
90
95
|
|
91
96
|
/** The request body for the Pushed Authorization Request */
|
92
97
|
var formBody = new URLSearchParams({
|
98
|
+
response_type: "code",
|
93
99
|
client_id: clientId,
|
100
|
+
code_challenge: codeChallenge,
|
101
|
+
code_challenge_method: "S256",
|
94
102
|
request: signedJwtForPar,
|
103
|
+
client_assertion_type: assertionType,
|
104
|
+
client_assertion: walletInstanceAttestation + "~" + signedWiaPoP,
|
95
105
|
});
|
96
106
|
|
107
|
+
Logger.log(
|
108
|
+
LogLevel.DEBUG,
|
109
|
+
`Sending to PAR endpoint ${parEndpoint}: ${formBody}`
|
110
|
+
);
|
111
|
+
|
97
112
|
return await appFetch(parEndpoint, {
|
98
113
|
method: "POST",
|
99
114
|
headers: {
|
100
115
|
"Content-Type": "application/x-www-form-urlencoded",
|
101
|
-
"OAuth-Client-Attestation": walletInstanceAttestation,
|
102
|
-
"OAuth-Client-Attestation-PoP": signedWiaPoP,
|
103
116
|
},
|
104
117
|
body: formBody.toString(),
|
105
118
|
})
|
package/src/utils/string.ts
CHANGED
@@ -43,13 +43,3 @@ export const obfuscateString = (
|
|
43
43
|
|
44
44
|
return chars.join("");
|
45
45
|
};
|
46
|
-
|
47
|
-
/**
|
48
|
-
* Converts a base64 string to a Base64 URL-encoded string.
|
49
|
-
*
|
50
|
-
* @param byteString - The input string in base64 format.
|
51
|
-
* @returns The Base64 URL-encoded string.
|
52
|
-
*/
|
53
|
-
export const base64ToBase64Url = (base64: string): string => {
|
54
|
-
return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/[=]+$/, "");
|
55
|
-
};
|
@@ -6,6 +6,7 @@ import {
|
|
6
6
|
} from "../utils/errors";
|
7
7
|
import type { WalletInstanceData } from "../client/generated/wallet-provider";
|
8
8
|
import type { IntegrityContext } from "..";
|
9
|
+
import { LogLevel, Logger } from "../utils/logging";
|
9
10
|
|
10
11
|
export async function createWalletInstance(context: {
|
11
12
|
integrityContext: IntegrityContext;
|
@@ -13,15 +14,25 @@ export async function createWalletInstance(context: {
|
|
13
14
|
appFetch?: GlobalFetch["fetch"];
|
14
15
|
}) {
|
15
16
|
const { integrityContext } = context;
|
16
|
-
|
17
17
|
const api = getWalletProviderClient(context);
|
18
18
|
|
19
19
|
//1. Obtain nonce
|
20
20
|
const challenge = await api.get("/nonce").then((response) => response.nonce);
|
21
21
|
|
22
|
+
Logger.log(
|
23
|
+
LogLevel.DEBUG,
|
24
|
+
`Challenge obtained from ${context.walletProviderBaseUrl}: ${challenge}`
|
25
|
+
);
|
26
|
+
|
22
27
|
const keyAttestation = await integrityContext.getAttestation(challenge);
|
28
|
+
|
23
29
|
const hardwareKeyTag = integrityContext.getHardwareKeyTag();
|
24
30
|
|
31
|
+
Logger.log(
|
32
|
+
LogLevel.DEBUG,
|
33
|
+
`Key attestation: ${keyAttestation}\nAssociated hardware key tag: ${hardwareKeyTag}`
|
34
|
+
);
|
35
|
+
|
25
36
|
//2. Create Wallet Instance
|
26
37
|
await api
|
27
38
|
.post("/wallet-instances", {
|
@@ -37,6 +48,11 @@ export async function createWalletInstance(context: {
|
|
37
48
|
}
|
38
49
|
|
39
50
|
const handleCreateWalletInstanceError = (e: unknown) => {
|
51
|
+
Logger.log(
|
52
|
+
LogLevel.ERROR,
|
53
|
+
`An error occurred while calling /wallet-instances endpoint: ${e}`
|
54
|
+
);
|
55
|
+
|
40
56
|
if (!(e instanceof WalletProviderResponseError)) {
|
41
57
|
throw e;
|
42
58
|
}
|
@@ -87,3 +103,16 @@ export async function getWalletInstanceStatus(context: {
|
|
87
103
|
path: { id: context.id },
|
88
104
|
});
|
89
105
|
}
|
106
|
+
|
107
|
+
/**
|
108
|
+
* Get the status of the current Wallet Instance.
|
109
|
+
* @returns Details on the status of the current Wallet Instance
|
110
|
+
*/
|
111
|
+
export async function getCurrentWalletInstanceStatus(context: {
|
112
|
+
walletProviderBaseUrl: string;
|
113
|
+
appFetch?: GlobalFetch["fetch"];
|
114
|
+
}): Promise<WalletInstanceData> {
|
115
|
+
const api = getWalletProviderClient(context);
|
116
|
+
|
117
|
+
return api.get("/wallet-instances/current/status");
|
118
|
+
}
|
@@ -1,7 +1,11 @@
|
|
1
1
|
# Wallet Instance Attestation
|
2
2
|
|
3
|
-
This flow consists of a single step and is used to obtain a Wallet Instance Attestation. The
|
4
|
-
|
3
|
+
This flow consists of a single step and is used to obtain a Wallet Instance Attestation. The attestation is issued in multiple formats:
|
4
|
+
- `jwt`
|
5
|
+
- `dc+sd-jwt`
|
6
|
+
- `mso_mdoc`
|
7
|
+
|
8
|
+
The wallet provider must implement its endpoints based on the OpenAPI specification provided in the [wallet-instance.yaml](../../openapi/wallet-provider.yaml) file. In order to require a status attestation the consumer application must provide:
|
5
9
|
|
6
10
|
- `wiaCryptoContext` object that is used to sign the attestation request. The key must be generated before creating the crypto context;
|
7
11
|
- `integrityContext` object that is used to verify the integrity of the device where the app is running. The key tag must be the same used when creating the Wallet Instance;
|
@@ -29,10 +33,11 @@ const issuedAttestation = await WalletInstanceAttestation.getAttestation({
|
|
29
33
|
walletProviderBaseUrl: WALLET_PROVIDER_BASE_URL,
|
30
34
|
appFetch,
|
31
35
|
});
|
36
|
+
// [{ "format": "jwt", "wallet_attestation": "ey..." }, { "format": "dc+sd-jwt", "wallet_attestation": "ey..." }]
|
32
37
|
return issuedAttestation;
|
33
38
|
```
|
34
39
|
|
35
|
-
The returned `issuedAttestation` is supposed to be stored and used for any future operation that requires a Wallet Instance Attestation. The wallet attestation has a limited validity and must be regenerated when it expires.
|
40
|
+
The returned `issuedAttestation` is supposed to be stored and used for any future operation that requires a Wallet Instance Attestation in one of the available formats. The wallet attestation has a limited validity and must be regenerated when it expires.
|
36
41
|
|
37
42
|
## Mapped results
|
38
43
|
|
@@ -2,8 +2,8 @@ import { WalletInstanceAttestationJwt } from "./types";
|
|
2
2
|
import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
|
3
3
|
import { verify as verifyJwt } from "@pagopa/io-react-native-jwt";
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
export { getAttestation } from "./issuing";
|
6
|
+
|
7
7
|
/**
|
8
8
|
* Decode a given JWT to get the parsed Wallet Instance Attestation object they define.
|
9
9
|
* It ensures provided data is in a valid shape.
|
@@ -5,13 +5,14 @@ import {
|
|
5
5
|
} from "@pagopa/io-react-native-jwt";
|
6
6
|
import { fixBase64EncodingOnKey, JWK } from "../utils/jwk";
|
7
7
|
import { getWalletProviderClient } from "../client";
|
8
|
-
import type { IntegrityContext } from "
|
8
|
+
import type { IntegrityContext } from "../utils/integrity";
|
9
|
+
import { LogLevel, Logger } from "../utils/logging";
|
9
10
|
import {
|
10
11
|
ResponseErrorBuilder,
|
11
12
|
WalletProviderResponseError,
|
12
13
|
WalletProviderResponseErrorCodes,
|
13
14
|
} from "../utils/errors";
|
14
|
-
import {
|
15
|
+
import { WalletAttestationResponse } from "./types";
|
15
16
|
|
16
17
|
/**
|
17
18
|
* Getter for an attestation request. The attestation request is a JWT that will be sent to the Wallet Provider to request a Wallet Instance Attestation.
|
@@ -47,8 +48,8 @@ export async function getAttestationRequest(
|
|
47
48
|
return new SignJWT(wiaCryptoContext)
|
48
49
|
.setPayload({
|
49
50
|
iss: keyThumbprint,
|
50
|
-
|
51
|
-
challenge,
|
51
|
+
aud: walletProviderBaseUrl,
|
52
|
+
nonce: challenge,
|
52
53
|
hardware_signature: signature,
|
53
54
|
integrity_assertion: authenticatorData,
|
54
55
|
hardware_key_tag: hardwareKeyTag,
|
@@ -58,7 +59,7 @@ export async function getAttestationRequest(
|
|
58
59
|
})
|
59
60
|
.setProtectedHeader({
|
60
61
|
kid: publicKey.kid,
|
61
|
-
typ: "war+jwt",
|
62
|
+
typ: "wp-war+jwt",
|
62
63
|
})
|
63
64
|
.setIssuedAt()
|
64
65
|
.setExpirationTime("1h")
|
@@ -67,6 +68,7 @@ export async function getAttestationRequest(
|
|
67
68
|
|
68
69
|
/**
|
69
70
|
* Request a Wallet Instance Attestation (WIA) to the Wallet provider
|
71
|
+
* @version 1.0.0
|
70
72
|
*
|
71
73
|
* @param params.wiaCryptoContext The key pair associated with the WIA. Will be use to prove the ownership of the attestation.
|
72
74
|
* @param params.appFetch (optional) Http client
|
@@ -84,7 +86,7 @@ export const getAttestation = async ({
|
|
84
86
|
integrityContext: IntegrityContext;
|
85
87
|
walletProviderBaseUrl: string;
|
86
88
|
appFetch?: GlobalFetch["fetch"];
|
87
|
-
}): Promise<
|
89
|
+
}): Promise<WalletAttestationResponse["wallet_attestations"]> => {
|
88
90
|
const api = getWalletProviderClient({
|
89
91
|
walletProviderBaseUrl,
|
90
92
|
appFetch,
|
@@ -92,6 +94,10 @@ export const getAttestation = async ({
|
|
92
94
|
|
93
95
|
// 1. Get nonce from backend
|
94
96
|
const challenge = await api.get("/nonce").then((response) => response.nonce);
|
97
|
+
Logger.log(
|
98
|
+
LogLevel.DEBUG,
|
99
|
+
`Challenge obtained from ${walletProviderBaseUrl}: ${challenge} `
|
100
|
+
);
|
95
101
|
|
96
102
|
// 2. Get a signed attestation request
|
97
103
|
const signedAttestationRequest = await getAttestationRequest(
|
@@ -100,22 +106,37 @@ export const getAttestation = async ({
|
|
100
106
|
integrityContext,
|
101
107
|
walletProviderBaseUrl
|
102
108
|
);
|
109
|
+
Logger.log(
|
110
|
+
LogLevel.DEBUG,
|
111
|
+
`Signed attestation request: ${signedAttestationRequest}`
|
112
|
+
);
|
103
113
|
|
104
|
-
// 3. Request WIA
|
105
|
-
const
|
106
|
-
.post("/
|
114
|
+
// 3. Request WIA in multiple formats
|
115
|
+
const response = await api
|
116
|
+
.post("/wallet-attestations", {
|
107
117
|
body: {
|
108
|
-
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
|
109
118
|
assertion: signedAttestationRequest,
|
110
119
|
},
|
111
120
|
})
|
112
|
-
.then(
|
121
|
+
.then(WalletAttestationResponse.parse)
|
113
122
|
.catch(handleAttestationCreationError);
|
114
123
|
|
115
|
-
|
124
|
+
for (const attestation of response.wallet_attestations) {
|
125
|
+
Logger.log(
|
126
|
+
LogLevel.DEBUG,
|
127
|
+
`Obtained wallet attestation in ${attestation.format} format: ${attestation.wallet_attestation}`
|
128
|
+
);
|
129
|
+
}
|
130
|
+
|
131
|
+
return response.wallet_attestations;
|
116
132
|
};
|
117
133
|
|
118
134
|
const handleAttestationCreationError = (e: unknown) => {
|
135
|
+
Logger.log(
|
136
|
+
LogLevel.ERROR,
|
137
|
+
`An error occurred while calling /wallet-attestation endpoint: ${e}`
|
138
|
+
);
|
139
|
+
|
119
140
|
if (!(e instanceof WalletProviderResponseError)) {
|
120
141
|
throw e;
|
121
142
|
}
|
@@ -33,15 +33,17 @@ export const WalletInstanceAttestationRequestJwt = z.object({
|
|
33
33
|
header: z.intersection(
|
34
34
|
Jwt.shape.header,
|
35
35
|
z.object({
|
36
|
-
typ: z.literal("war+jwt"),
|
36
|
+
typ: z.literal("wp-war+jwt"),
|
37
37
|
})
|
38
38
|
),
|
39
39
|
payload: z.intersection(
|
40
40
|
Jwt.shape.payload,
|
41
41
|
z.object({
|
42
42
|
aud: z.string(),
|
43
|
-
jti: z.string(),
|
44
43
|
nonce: z.string(),
|
44
|
+
hardware_signature: z.string(),
|
45
|
+
integrity_assertion: z.string(),
|
46
|
+
hardware_key_tag: z.string(),
|
45
47
|
})
|
46
48
|
),
|
47
49
|
});
|
@@ -53,7 +55,8 @@ export const WalletInstanceAttestationJwt = z.object({
|
|
53
55
|
header: z.intersection(
|
54
56
|
Jwt.shape.header,
|
55
57
|
z.object({
|
56
|
-
typ: z.literal("
|
58
|
+
typ: z.literal("oauth-client-attestation+jwt"),
|
59
|
+
trust_chain: z.array(z.string()),
|
57
60
|
})
|
58
61
|
),
|
59
62
|
payload: z.intersection(
|
@@ -61,27 +64,20 @@ export const WalletInstanceAttestationJwt = z.object({
|
|
61
64
|
z.object({
|
62
65
|
sub: z.string(),
|
63
66
|
aal: z.string(),
|
64
|
-
|
65
|
-
|
66
|
-
vp_formats_supported: z.object({
|
67
|
-
"vc+sd-jwt": z
|
68
|
-
.object({
|
69
|
-
"sd-jwt_alg_values": z.array(z.string()),
|
70
|
-
})
|
71
|
-
.optional(),
|
72
|
-
"vp+sd-jwt": z
|
73
|
-
.object({
|
74
|
-
"sd-jwt_alg_values": z.array(z.string()),
|
75
|
-
})
|
76
|
-
.optional(),
|
77
|
-
}),
|
78
|
-
request_object_signing_alg_values_supported: z.array(z.string()),
|
79
|
-
presentation_definition_uri_supported: z.boolean(),
|
67
|
+
wallet_link: z.string().optional(),
|
68
|
+
wallet_name: z.string().optional(),
|
80
69
|
})
|
81
70
|
),
|
82
71
|
});
|
83
72
|
|
84
|
-
export type
|
85
|
-
|
86
|
-
|
73
|
+
export type WalletAttestationResponse = z.infer<
|
74
|
+
typeof WalletAttestationResponse
|
75
|
+
>;
|
76
|
+
export const WalletAttestationResponse = z.object({
|
77
|
+
wallet_attestations: z.array(
|
78
|
+
z.object({
|
79
|
+
wallet_attestation: z.string(),
|
80
|
+
format: z.enum(["jwt", "dc+sd-jwt", "mso_mdoc"]),
|
81
|
+
})
|
82
|
+
),
|
87
83
|
});
|