@pagopa/io-react-native-wallet 1.7.1 → 2.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -1
- package/lib/commonjs/client/generated/wallet-provider.js +49 -20
- package/lib/commonjs/client/generated/wallet-provider.js.map +1 -1
- package/lib/commonjs/credential/index.js +5 -1
- package/lib/commonjs/credential/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js +27 -0
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js +25 -16
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +30 -18
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/05-authorize-access.js +17 -12
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +36 -29
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +27 -207
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/README.md +23 -20
- package/lib/commonjs/credential/issuance/const.js +1 -1
- package/lib/commonjs/credential/issuance/const.js.map +1 -1
- package/lib/commonjs/credential/issuance/index.js +3 -3
- package/lib/commonjs/credential/issuance/index.js.map +1 -1
- package/lib/commonjs/credential/presentation/01-start-flow.js +14 -15
- package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js +6 -4
- package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
- package/lib/commonjs/credential/presentation/03-get-request-object.js +34 -7
- package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js +4 -126
- package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
- package/lib/commonjs/credential/presentation/05-verify-request-object.js +80 -25
- package/lib/commonjs/credential/presentation/05-verify-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js +6 -30
- package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +97 -117
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +86 -191
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js +112 -176
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/commonjs/credential/presentation/README.md +74 -79
- package/lib/commonjs/credential/presentation/errors.js +42 -21
- package/lib/commonjs/credential/presentation/errors.js.map +1 -1
- package/lib/commonjs/credential/presentation/index.js +13 -13
- package/lib/commonjs/credential/presentation/index.js.map +1 -1
- package/lib/commonjs/credential/presentation/types.js +53 -29
- package/lib/commonjs/credential/presentation/types.js.map +1 -1
- package/lib/commonjs/credential/status/01-start-flow.js +2 -0
- package/lib/commonjs/credential/status/01-start-flow.js.map +1 -0
- package/lib/commonjs/credential/status/02-status-attestation.js +73 -0
- package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -0
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +55 -0
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
- package/lib/commonjs/credential/status/README.md +67 -0
- package/lib/commonjs/credential/status/index.js +27 -0
- package/lib/commonjs/credential/status/index.js.map +1 -0
- package/lib/commonjs/credential/status/types.js +48 -0
- package/lib/commonjs/credential/status/types.js.map +1 -0
- package/lib/commonjs/credential/trustmark/README.md +62 -0
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js +86 -0
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js.map +1 -0
- package/lib/commonjs/credential/trustmark/index.js +13 -0
- package/lib/commonjs/credential/trustmark/index.js.map +1 -0
- package/lib/commonjs/index.js +5 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/pid/sd-jwt/types.js +18 -2
- package/lib/commonjs/pid/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/index.test.js +22 -34
- package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/types.test.js +11 -23
- package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/index.js +1 -7
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/commonjs/sd-jwt/types.js +5 -21
- package/lib/commonjs/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/trust/README.md +147 -0
- package/lib/commonjs/trust/chain.js +153 -0
- package/lib/commonjs/trust/chain.js.map +1 -0
- package/lib/commonjs/trust/errors.js +133 -0
- package/lib/commonjs/trust/errors.js.map +1 -0
- package/lib/commonjs/trust/index.js +288 -0
- package/lib/commonjs/trust/index.js.map +1 -0
- package/lib/commonjs/{entity/trust → trust}/types.js +27 -47
- package/lib/commonjs/trust/types.js.map +1 -0
- package/lib/commonjs/trust/utils.js +70 -0
- package/lib/commonjs/trust/utils.js.map +1 -0
- package/lib/commonjs/utils/crypto.js +5 -112
- package/lib/commonjs/utils/crypto.js.map +1 -1
- package/lib/commonjs/utils/decoder.js +2 -0
- package/lib/commonjs/utils/decoder.js.map +1 -1
- package/lib/commonjs/utils/error-codes.js +22 -2
- package/lib/commonjs/utils/error-codes.js.map +1 -1
- package/lib/commonjs/utils/errors.js +72 -4
- package/lib/commonjs/utils/errors.js.map +1 -1
- package/lib/commonjs/utils/logging.js +68 -0
- package/lib/commonjs/utils/logging.js.map +1 -0
- package/lib/commonjs/utils/misc.js +2 -0
- package/lib/commonjs/utils/misc.js.map +1 -1
- package/lib/commonjs/utils/par.js +17 -10
- package/lib/commonjs/utils/par.js.map +1 -1
- package/lib/commonjs/utils/string.js +1 -12
- package/lib/commonjs/utils/string.js.map +1 -1
- package/lib/commonjs/wallet-instance/index.js +14 -0
- package/lib/commonjs/wallet-instance/index.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/README.md +8 -3
- package/lib/commonjs/wallet-instance-attestation/issuing.js +15 -8
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/types.js +16 -20
- package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
- package/lib/module/client/generated/wallet-provider.js +40 -15
- package/lib/module/client/generated/wallet-provider.js.map +1 -1
- package/lib/module/credential/index.js +3 -1
- package/lib/module/credential/index.js.map +1 -1
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +20 -0
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
- package/lib/module/credential/issuance/03-start-user-authorization.js +25 -16
- package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js +30 -18
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/05-authorize-access.js +17 -11
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +36 -28
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +27 -205
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/issuance/README.md +23 -20
- package/lib/module/credential/issuance/const.js +1 -1
- package/lib/module/credential/issuance/const.js.map +1 -1
- package/lib/module/credential/issuance/index.js +2 -2
- package/lib/module/credential/issuance/index.js.map +1 -1
- package/lib/module/credential/presentation/01-start-flow.js +14 -15
- package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/module/credential/presentation/02-evaluate-rp-trust.js +5 -3
- package/lib/module/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
- package/lib/module/credential/presentation/03-get-request-object.js +34 -7
- package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/module/credential/presentation/04-retrieve-rp-jwks.js +2 -124
- package/lib/module/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
- package/lib/module/credential/presentation/05-verify-request-object.js +78 -23
- package/lib/module/credential/presentation/05-verify-request-object.js.map +1 -1
- package/lib/module/credential/presentation/06-fetch-presentation-definition.js +6 -30
- package/lib/module/credential/presentation/06-fetch-presentation-definition.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js +97 -118
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +83 -186
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/module/credential/presentation/08-send-authorization-response.js +107 -170
- package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/module/credential/presentation/README.md +74 -79
- package/lib/module/credential/presentation/errors.js +30 -17
- package/lib/module/credential/presentation/errors.js.map +1 -1
- package/lib/module/credential/presentation/index.js +6 -6
- package/lib/module/credential/presentation/index.js.map +1 -1
- package/lib/module/credential/presentation/types.js +49 -27
- package/lib/module/credential/presentation/types.js.map +1 -1
- package/lib/module/credential/status/01-start-flow.js +2 -0
- package/lib/module/credential/status/01-start-flow.js.map +1 -0
- package/lib/module/credential/status/02-status-attestation.js +66 -0
- package/lib/module/credential/status/02-status-attestation.js.map +1 -0
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +49 -0
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
- package/lib/module/credential/status/README.md +67 -0
- package/lib/module/credential/status/index.js +5 -0
- package/lib/module/credential/status/index.js.map +1 -0
- package/lib/module/credential/status/types.js +40 -0
- package/lib/module/credential/status/types.js.map +1 -0
- package/lib/module/credential/trustmark/README.md +62 -0
- package/lib/module/credential/trustmark/get-credential-trustmark.js +77 -0
- package/lib/module/credential/trustmark/get-credential-trustmark.js.map +1 -0
- package/lib/module/credential/trustmark/index.js +3 -0
- package/lib/module/credential/trustmark/index.js.map +1 -0
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/pid/sd-jwt/types.js +16 -1
- package/lib/module/pid/sd-jwt/types.js.map +1 -1
- package/lib/module/sd-jwt/__test__/index.test.js +22 -34
- package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/module/sd-jwt/__test__/types.test.js +11 -23
- package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/module/sd-jwt/index.js +1 -7
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/module/sd-jwt/types.js +4 -19
- package/lib/module/sd-jwt/types.js.map +1 -1
- package/lib/module/trust/README.md +147 -0
- package/lib/module/trust/chain.js +145 -0
- package/lib/module/trust/chain.js.map +1 -0
- package/lib/module/trust/errors.js +115 -0
- package/lib/module/trust/errors.js.map +1 -0
- package/lib/module/trust/index.js +269 -0
- package/lib/module/trust/index.js.map +1 -0
- package/lib/module/{entity/trust → trust}/types.js +25 -46
- package/lib/module/trust/types.js.map +1 -0
- package/lib/module/trust/utils.js +60 -0
- package/lib/module/trust/utils.js.map +1 -0
- package/lib/module/utils/crypto.js +4 -107
- package/lib/module/utils/crypto.js.map +1 -1
- package/lib/module/utils/decoder.js +3 -0
- package/lib/module/utils/decoder.js.map +1 -1
- package/lib/module/utils/error-codes.js +20 -1
- package/lib/module/utils/error-codes.js.map +1 -1
- package/lib/module/utils/errors.js +61 -4
- package/lib/module/utils/errors.js.map +1 -1
- package/lib/module/utils/logging.js +62 -0
- package/lib/module/utils/logging.js.map +1 -0
- package/lib/module/utils/misc.js +2 -0
- package/lib/module/utils/misc.js.map +1 -1
- package/lib/module/utils/par.js +17 -9
- package/lib/module/utils/par.js.map +1 -1
- package/lib/module/utils/string.js +0 -10
- package/lib/module/utils/string.js.map +1 -1
- package/lib/module/wallet-instance/index.js +13 -0
- package/lib/module/wallet-instance/index.js.map +1 -1
- package/lib/module/wallet-instance-attestation/README.md +8 -3
- package/lib/module/wallet-instance-attestation/index.js +2 -2
- package/lib/module/wallet-instance-attestation/index.js.map +1 -1
- package/lib/module/wallet-instance-attestation/issuing.js +16 -9
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/wallet-instance-attestation/types.js +14 -18
- package/lib/module/wallet-instance-attestation/types.js.map +1 -1
- package/lib/typescript/client/generated/wallet-provider.d.ts +206 -51
- package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
- package/lib/typescript/credential/index.d.ts +3 -1
- package/lib/typescript/credential/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -1
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts +19 -0
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +3 -3
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +9 -9
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts +3 -3
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +4 -4
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +3 -15
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/const.d.ts +1 -1
- package/lib/typescript/credential/issuance/const.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/index.d.ts +3 -3
- package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/types.d.ts +8 -3
- package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/01-start-flow.d.ts +28 -9
- package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts +2 -1
- package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts +7 -5
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts +4 -30
- package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts +17 -4
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts +4 -9
- package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +13 -12
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +40 -42
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +30 -43
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/errors.d.ts +25 -10
- package/lib/typescript/credential/presentation/errors.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/index.d.ts +7 -8
- package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/types.d.ts +137 -307
- package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
- package/lib/typescript/credential/status/01-start-flow.d.ts +10 -0
- package/lib/typescript/credential/status/01-start-flow.d.ts.map +1 -0
- package/lib/typescript/credential/status/02-status-attestation.d.ts +19 -0
- package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -0
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts +24 -0
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +1 -0
- package/lib/typescript/credential/status/index.d.ts +7 -0
- package/lib/typescript/credential/status/index.d.ts.map +1 -0
- package/lib/typescript/credential/status/types.d.ts +305 -0
- package/lib/typescript/credential/status/types.d.ts.map +1 -0
- package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts +52 -0
- package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts.map +1 -0
- package/lib/typescript/credential/trustmark/index.d.ts +4 -0
- package/lib/typescript/credential/trustmark/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +3 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/pid/sd-jwt/types.d.ts +103 -25
- package/lib/typescript/pid/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/index.d.ts +20 -72
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/types.d.ts +24 -129
- package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/trust/chain.d.ts +23 -0
- package/lib/typescript/trust/chain.d.ts.map +1 -0
- package/lib/typescript/trust/errors.d.ts +102 -0
- package/lib/typescript/trust/errors.d.ts.map +1 -0
- package/lib/typescript/{entity/trust → trust}/index.d.ts +308 -281
- package/lib/typescript/trust/index.d.ts.map +1 -0
- package/lib/typescript/{entity/trust → trust}/types.d.ts +1714 -1301
- package/lib/typescript/{entity/trust → trust}/types.d.ts.map +1 -1
- package/lib/typescript/trust/utils.d.ts +22 -0
- package/lib/typescript/trust/utils.d.ts.map +1 -0
- package/lib/typescript/utils/crypto.d.ts +0 -32
- package/lib/typescript/utils/crypto.d.ts.map +1 -1
- package/lib/typescript/utils/decoder.d.ts.map +1 -1
- package/lib/typescript/utils/error-codes.d.ts +20 -0
- package/lib/typescript/utils/error-codes.d.ts.map +1 -1
- package/lib/typescript/utils/errors.d.ts +55 -10
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/logging.d.ts +35 -0
- package/lib/typescript/utils/logging.d.ts.map +1 -0
- package/lib/typescript/utils/misc.d.ts.map +1 -1
- package/lib/typescript/utils/par.d.ts +8 -1
- package/lib/typescript/utils/par.d.ts.map +1 -1
- package/lib/typescript/utils/string.d.ts +0 -7
- package/lib/typescript/utils/string.d.ts.map +1 -1
- package/lib/typescript/wallet-instance/index.d.ts +8 -0
- package/lib/typescript/wallet-instance/index.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/index.d.ts +1 -2
- package/lib/typescript/wallet-instance-attestation/index.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts +4 -2
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/types.d.ts +60 -102
- package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
- package/package.json +9 -10
- package/src/client/generated/wallet-provider.ts +52 -17
- package/src/credential/index.ts +4 -1
- package/src/credential/issuance/01-start-flow.ts +1 -1
- package/src/credential/issuance/02-evaluate-issuer-trust.ts +32 -0
- package/src/credential/issuance/03-start-user-authorization.ts +48 -22
- package/src/credential/issuance/04-complete-user-authorization.ts +74 -18
- package/src/credential/issuance/05-authorize-access.ts +29 -11
- package/src/credential/issuance/06-obtain-credential.ts +61 -36
- package/src/credential/issuance/07-verify-and-parse-credential.ts +37 -264
- package/src/credential/issuance/README.md +23 -20
- package/src/credential/issuance/const.ts +1 -1
- package/src/credential/issuance/index.ts +6 -3
- package/src/credential/presentation/01-start-flow.ts +19 -22
- package/src/credential/presentation/02-evaluate-rp-trust.ts +5 -4
- package/src/credential/presentation/03-get-request-object.ts +36 -8
- package/src/credential/presentation/04-retrieve-rp-jwks.ts +6 -148
- package/src/credential/presentation/05-verify-request-object.ts +115 -30
- package/src/credential/presentation/06-fetch-presentation-definition.ts +5 -35
- package/src/credential/presentation/07-evaluate-dcql-query.ts +132 -161
- package/src/credential/presentation/07-evaluate-input-descriptor.ts +136 -254
- package/src/credential/presentation/08-send-authorization-response.ts +178 -260
- package/src/credential/presentation/README.md +74 -79
- package/src/credential/presentation/errors.ts +38 -15
- package/src/credential/presentation/index.ts +18 -19
- package/src/credential/presentation/types.ts +67 -64
- package/src/credential/status/01-start-flow.ts +9 -0
- package/src/credential/status/02-status-attestation.ts +105 -0
- package/src/credential/status/03-verify-and-parse-status-attestation.ts +70 -0
- package/src/credential/status/README.md +67 -0
- package/src/credential/status/index.ts +22 -0
- package/src/credential/status/types.ts +43 -0
- package/src/credential/trustmark/README.md +62 -0
- package/src/credential/trustmark/get-credential-trustmark.ts +139 -0
- package/src/credential/trustmark/index.ts +8 -0
- package/src/index.ts +4 -0
- package/src/pid/sd-jwt/types.ts +18 -1
- package/src/sd-jwt/__test__/index.test.ts +36 -55
- package/src/sd-jwt/__test__/types.test.ts +16 -29
- package/src/sd-jwt/index.ts +1 -5
- package/src/sd-jwt/types.ts +2 -19
- package/src/trust/README.md +147 -0
- package/src/trust/chain.ts +227 -0
- package/src/trust/errors.ts +136 -0
- package/src/{entity/trust → trust}/index.ts +207 -25
- package/src/{entity/trust → trust}/types.ts +24 -37
- package/src/trust/utils.ts +70 -0
- package/src/utils/crypto.ts +4 -106
- package/src/utils/decoder.ts +6 -1
- package/src/utils/error-codes.ts +23 -0
- package/src/utils/errors.ts +119 -15
- package/src/utils/logging.ts +68 -0
- package/src/utils/misc.ts +5 -0
- package/src/utils/par.ts +19 -6
- package/src/utils/string.ts +0 -10
- package/src/wallet-instance/index.ts +30 -1
- package/src/wallet-instance-attestation/README.md +8 -3
- package/src/wallet-instance-attestation/index.ts +2 -2
- package/src/wallet-instance-attestation/issuing.ts +33 -12
- package/src/wallet-instance-attestation/types.ts +18 -22
- package/lib/commonjs/credential/issuance/02-get-issuer-config.js +0 -48
- package/lib/commonjs/credential/issuance/02-get-issuer-config.js.map +0 -1
- package/lib/commonjs/entity/openid-connect/issuer/index.js +0 -25
- package/lib/commonjs/entity/openid-connect/issuer/index.js.map +0 -1
- package/lib/commonjs/entity/openid-connect/issuer/types.js +0 -64
- package/lib/commonjs/entity/openid-connect/issuer/types.js.map +0 -1
- package/lib/commonjs/entity/trust/chain.js +0 -122
- package/lib/commonjs/entity/trust/chain.js.map +0 -1
- package/lib/commonjs/entity/trust/index.js +0 -148
- package/lib/commonjs/entity/trust/index.js.map +0 -1
- package/lib/commonjs/entity/trust/types.js.map +0 -1
- package/lib/commonjs/mdoc/converters.js +0 -26
- package/lib/commonjs/mdoc/converters.js.map +0 -1
- package/lib/commonjs/mdoc/index.js +0 -68
- package/lib/commonjs/mdoc/index.js.map +0 -1
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -469
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -90
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
- package/lib/module/credential/issuance/02-get-issuer-config.js +0 -42
- package/lib/module/credential/issuance/02-get-issuer-config.js.map +0 -1
- package/lib/module/entity/openid-connect/issuer/index.js +0 -20
- package/lib/module/entity/openid-connect/issuer/index.js.map +0 -1
- package/lib/module/entity/openid-connect/issuer/types.js +0 -48
- package/lib/module/entity/openid-connect/issuer/types.js.map +0 -1
- package/lib/module/entity/trust/chain.js +0 -113
- package/lib/module/entity/trust/chain.js.map +0 -1
- package/lib/module/entity/trust/index.js +0 -131
- package/lib/module/entity/trust/index.js.map +0 -1
- package/lib/module/entity/trust/types.js.map +0 -1
- package/lib/module/mdoc/converters.js +0 -20
- package/lib/module/mdoc/converters.js.map +0 -1
- package/lib/module/mdoc/index.js +0 -60
- package/lib/module/mdoc/index.js.map +0 -1
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -462
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -83
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
- package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts +0 -32
- package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts.map +0 -1
- package/lib/typescript/entity/openid-connect/issuer/index.d.ts +0 -12
- package/lib/typescript/entity/openid-connect/issuer/index.d.ts.map +0 -1
- package/lib/typescript/entity/openid-connect/issuer/types.d.ts +0 -777
- package/lib/typescript/entity/openid-connect/issuer/types.d.ts.map +0 -1
- package/lib/typescript/entity/trust/chain.d.ts +0 -26
- package/lib/typescript/entity/trust/chain.d.ts.map +0 -1
- package/lib/typescript/entity/trust/index.d.ts.map +0 -1
- package/lib/typescript/mdoc/converters.d.ts +0 -8
- package/lib/typescript/mdoc/converters.d.ts.map +0 -1
- package/lib/typescript/mdoc/index.d.ts +0 -10
- package/lib/typescript/mdoc/index.d.ts.map +0 -1
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts +0 -3
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts.map +0 -1
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts +0 -42
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts.map +0 -1
- package/src/credential/issuance/02-get-issuer-config.ts +0 -67
- package/src/entity/openid-connect/issuer/index.ts +0 -27
- package/src/entity/openid-connect/issuer/types.ts +0 -76
- package/src/entity/trust/chain.ts +0 -154
- package/src/mdoc/converters.ts +0 -26
- package/src/mdoc/index.ts +0 -95
- package/src/utils/credential/issuance/07-verify-and-parse-credentials-inputs.ts +0 -615
- package/src/utils/credential/issuance/07-verify-and-parse-credentials-utils.ts +0 -171
@@ -1,26 +1,24 @@
|
|
1
1
|
import { EncryptJwe } from "@pagopa/io-react-native-jwt";
|
2
2
|
import uuid from "react-native-uuid";
|
3
|
-
import type
|
4
|
-
import type {
|
5
|
-
import {
|
6
|
-
NoSuitableKeysFoundInEntityConfiguration,
|
7
|
-
CredentialNotFoundError,
|
8
|
-
} from "./errors";
|
3
|
+
import { getJwksFromConfig, type FetchJwks } from "./04-retrieve-rp-jwks";
|
4
|
+
import type { VerifyRequestObject } from "./05-verify-request-object";
|
5
|
+
import { NoSuitableKeysFoundInEntityConfiguration } from "./errors";
|
9
6
|
import { hasStatusOrThrow, type Out } from "../../utils/misc";
|
10
7
|
import {
|
8
|
+
type RemotePresentation,
|
11
9
|
DirectAuthorizationBodyPayload,
|
12
10
|
ErrorResponse,
|
13
|
-
type
|
14
|
-
type PrepareRemotePresentations,
|
11
|
+
type LegacyRemotePresentation,
|
15
12
|
} from "./types";
|
16
13
|
import * as z from "zod";
|
17
14
|
import type { JWK } from "../../utils/jwk";
|
18
|
-
import {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
15
|
+
import type { RelyingPartyEntityConfiguration } from "../../trust";
|
16
|
+
import {
|
17
|
+
RelyingPartyResponseError,
|
18
|
+
ResponseErrorBuilder,
|
19
|
+
UnexpectedStatusCodeError,
|
20
|
+
RelyingPartyResponseErrorCodes,
|
21
|
+
} from "../../utils/errors";
|
24
22
|
|
25
23
|
export type AuthorizationResponse = z.infer<typeof AuthorizationResponse>;
|
26
24
|
export const AuthorizationResponse = z.object({
|
@@ -39,9 +37,6 @@ export const AuthorizationResponse = z.object({
|
|
39
37
|
* Selects a public key (with `use = enc`) from the set of JWK keys
|
40
38
|
* offered by the Relying Party (RP) for encryption.
|
41
39
|
*
|
42
|
-
* Preference is given to EC keys (P-256 or P-384), followed by RSA keys,
|
43
|
-
* based on compatibility and common usage for encryption.
|
44
|
-
*
|
45
40
|
* @param rpJwkKeys - The array of JWKs retrieved from the RP entity configuration.
|
46
41
|
* @returns The first suitable public key found in the list.
|
47
42
|
* @throws {NoSuitableKeysFoundInEntityConfiguration} If no suitable encryption key is found.
|
@@ -49,18 +44,7 @@ export const AuthorizationResponse = z.object({
|
|
49
44
|
export const choosePublicKeyToEncrypt = (
|
50
45
|
rpJwkKeys: Out<FetchJwks>["keys"]
|
51
46
|
): JWK => {
|
52
|
-
|
53
|
-
const encKeys = rpJwkKeys.filter((jwk) => jwk.use === "enc");
|
54
|
-
|
55
|
-
// Prioritize EC keys first, then fall back to RSA keys if needed
|
56
|
-
// io-react-native-jwt support only EC keys with P-256 or P-384 curves
|
57
|
-
const ecEncKeys = encKeys.filter(
|
58
|
-
(jwk) => jwk.kty === "EC" && (jwk.crv === "P-256" || jwk.crv === "P-384")
|
59
|
-
);
|
60
|
-
const rsaEncKeys = encKeys.filter((jwk) => jwk.kty === "RSA");
|
61
|
-
|
62
|
-
// Select the first available key based on priority
|
63
|
-
const encKey = ecEncKeys[0] || rsaEncKeys[0] || encKeys[0];
|
47
|
+
const encKey = rpJwkKeys.find((jwk) => jwk.use === "enc");
|
64
48
|
|
65
49
|
if (encKey) {
|
66
50
|
return encKey;
|
@@ -72,72 +56,44 @@ export const choosePublicKeyToEncrypt = (
|
|
72
56
|
);
|
73
57
|
};
|
74
58
|
|
75
|
-
/**
|
76
|
-
* Builds a URL-encoded form body for a direct POST response without encryption.
|
77
|
-
*
|
78
|
-
* @param requestObject - Contains state, nonce, and other relevant info.
|
79
|
-
* @param payload - Object that contains either the VP token to encrypt and the stringified mapping of the credential disclosures or the error code
|
80
|
-
* @returns A URL-encoded string suitable for an `application/x-www-form-urlencoded` POST body.
|
81
|
-
*/
|
82
|
-
export const buildDirectPostBody = async (
|
83
|
-
requestObject: Out<VerifyRequestObjectSignature>["requestObject"],
|
84
|
-
payload: DirectAuthorizationBodyPayload
|
85
|
-
): Promise<string> => {
|
86
|
-
const formUrlEncodedBody = new URLSearchParams({
|
87
|
-
...(requestObject.state ? { state: requestObject.state } : {}),
|
88
|
-
...Object.fromEntries(
|
89
|
-
Object.entries(payload).map(([key, value]) => {
|
90
|
-
return [
|
91
|
-
key,
|
92
|
-
Array.isArray(value) || typeof value === "object"
|
93
|
-
? JSON.stringify(value)
|
94
|
-
: value,
|
95
|
-
];
|
96
|
-
})
|
97
|
-
),
|
98
|
-
});
|
99
|
-
|
100
|
-
return formUrlEncodedBody.toString();
|
101
|
-
};
|
102
|
-
|
103
59
|
/**
|
104
60
|
* Builds a URL-encoded form body for a direct POST response using JWT encryption.
|
105
61
|
*
|
106
62
|
* @param jwkKeys - Array of JWKs from the Relying Party for encryption.
|
107
63
|
* @param requestObject - Contains state, nonce, and other relevant info.
|
108
|
-
* @param payload - Object that contains
|
109
|
-
* @
|
110
|
-
* @returns A URL-encoded string for an `application/x-www-form-urlencoded` POST body,
|
111
|
-
* where `response` contains the encrypted JWE.
|
64
|
+
* @param payload - Object that contains the VP token to encrypt and the mapping of the credential disclosures
|
65
|
+
* @returns A URL-encoded string for an `application/x-www-form-urlencoded` POST body, where `response` contains the encrypted JWE.
|
112
66
|
*/
|
113
67
|
export const buildDirectPostJwtBody = async (
|
114
|
-
|
115
|
-
|
116
|
-
payload: DirectAuthorizationBodyPayload
|
117
|
-
generatedNonce?: string
|
68
|
+
requestObject: Out<VerifyRequestObject>["requestObject"],
|
69
|
+
rpConf: RelyingPartyEntityConfiguration["payload"]["metadata"],
|
70
|
+
payload: DirectAuthorizationBodyPayload
|
118
71
|
): Promise<string> => {
|
72
|
+
type Jwe = ConstructorParameters<typeof EncryptJwe>[1];
|
73
|
+
|
119
74
|
// Prepare the authorization response payload to be encrypted
|
120
75
|
const authzResponsePayload = JSON.stringify({
|
121
76
|
state: requestObject.state,
|
122
77
|
...payload,
|
123
78
|
});
|
79
|
+
// Choose a suitable public key for encryption
|
80
|
+
const { keys } = getJwksFromConfig(rpConf);
|
81
|
+
const encPublicJwk = choosePublicKeyToEncrypt(keys);
|
124
82
|
|
125
|
-
const encPublicJwk = choosePublicKeyToEncrypt(jwkKeys);
|
126
83
|
// Encrypt the authorization payload
|
127
|
-
const {
|
84
|
+
const {
|
85
|
+
authorization_encrypted_response_alg,
|
86
|
+
authorization_encrypted_response_enc,
|
87
|
+
} = rpConf.openid_credential_verifier;
|
88
|
+
|
89
|
+
const defaultAlg: Jwe["alg"] =
|
90
|
+
encPublicJwk.kty === "EC" ? "ECDH-ES" : "RSA-OAEP-256";
|
91
|
+
|
128
92
|
const encryptedResponse = await new EncryptJwe(authzResponsePayload, {
|
129
|
-
alg:
|
130
|
-
(client_metadata?.authorization_encrypted_response_alg as
|
131
|
-
| "RSA-OAEP-256"
|
132
|
-
| "RSA-OAEP") || "RSA-OAEP-256",
|
93
|
+
alg: (authorization_encrypted_response_alg as Jwe["alg"]) || defaultAlg,
|
133
94
|
enc:
|
134
|
-
(
|
135
|
-
| "A256CBC-HS512"
|
136
|
-
| "A128CBC-HS256") || "A256CBC-HS512",
|
95
|
+
(authorization_encrypted_response_enc as Jwe["enc"]) || "A256CBC-HS512",
|
137
96
|
kid: encPublicJwk.kid,
|
138
|
-
/* ISO 18013-7 */
|
139
|
-
apv: Base64.encodeURI(requestObject.nonce),
|
140
|
-
...(generatedNonce ? { apu: Base64.encodeURI(generatedNonce) } : {}),
|
141
97
|
}).encrypt(encPublicJwk);
|
142
98
|
|
143
99
|
// Build the x-www-form-urlencoded form body
|
@@ -149,27 +105,44 @@ export const buildDirectPostJwtBody = async (
|
|
149
105
|
};
|
150
106
|
|
151
107
|
/**
|
152
|
-
*
|
153
|
-
*
|
108
|
+
* Builds a URL-encoded form body for a direct POST response without encryption.
|
109
|
+
*
|
110
|
+
* @param requestObject - Contains state, nonce, and other relevant info.
|
111
|
+
* @param payload - Object that contains either the VP token to encrypt and the stringified mapping of the credential disclosures or the error code
|
112
|
+
* @returns A URL-encoded string suitable for an `application/x-www-form-urlencoded` POST body.
|
154
113
|
*/
|
155
|
-
export
|
156
|
-
requestObject: Out<
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
114
|
+
export const buildDirectPostBody = async (
|
115
|
+
requestObject: Out<VerifyRequestObject>["requestObject"],
|
116
|
+
payload: DirectAuthorizationBodyPayload
|
117
|
+
): Promise<string> => {
|
118
|
+
const formUrlEncodedBody = new URLSearchParams({
|
119
|
+
...(requestObject.state && { state: requestObject.state }),
|
120
|
+
...Object.entries(payload).reduce(
|
121
|
+
(acc, [key, value]) => ({
|
122
|
+
...acc,
|
123
|
+
[key]:
|
124
|
+
Array.isArray(value) || typeof value === "object"
|
125
|
+
? JSON.stringify(value)
|
126
|
+
: value,
|
127
|
+
}),
|
128
|
+
{} as Record<string, string>
|
129
|
+
),
|
130
|
+
});
|
131
|
+
|
132
|
+
return formUrlEncodedBody.toString();
|
133
|
+
};
|
164
134
|
|
165
135
|
/**
|
166
136
|
* Type definition for the function that sends the authorization response
|
167
137
|
* to the Relying Party, completing the presentation flow.
|
138
|
+
* Use with `presentation_definition`.
|
139
|
+
* @deprecated Use `sendAuthorizationResponse`
|
168
140
|
*/
|
169
|
-
export type
|
170
|
-
requestObject: Out<
|
171
|
-
|
172
|
-
|
141
|
+
export type SendLegacyAuthorizationResponse = (
|
142
|
+
requestObject: Out<VerifyRequestObject>["requestObject"],
|
143
|
+
presentationDefinitionId: string,
|
144
|
+
remotePresentations: LegacyRemotePresentation[],
|
145
|
+
rpConf: RelyingPartyEntityConfiguration["payload"]["metadata"],
|
173
146
|
context?: {
|
174
147
|
appFetch?: GlobalFetch["fetch"];
|
175
148
|
}
|
@@ -186,55 +159,91 @@ export type SendAuthorizationResponseDcql = (
|
|
186
159
|
* @param context - Contains optional custom fetch implementation.
|
187
160
|
* @returns Parsed and validated authorization response from the Relying Party.
|
188
161
|
*/
|
189
|
-
export const
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
162
|
+
export const sendLegacyAuthorizationResponse: SendLegacyAuthorizationResponse =
|
163
|
+
async (
|
164
|
+
requestObject,
|
165
|
+
presentationDefinitionId,
|
166
|
+
remotePresentations,
|
167
|
+
rpConf,
|
168
|
+
{ appFetch = fetch } = {}
|
169
|
+
): Promise<AuthorizationResponse> => {
|
170
|
+
/**
|
171
|
+
* 1. Prepare the VP token and presentation submission
|
172
|
+
* If there is only one credential, `vpToken` is a single string.
|
173
|
+
* If there are multiple credential, `vpToken` is an array of string.
|
174
|
+
**/
|
175
|
+
const vp_token =
|
176
|
+
remotePresentations?.length === 1
|
177
|
+
? remotePresentations[0]?.vpToken
|
178
|
+
: remotePresentations.map(
|
179
|
+
(remotePresentation) => remotePresentation.vpToken
|
180
|
+
);
|
181
|
+
|
182
|
+
const descriptor_map = remotePresentations.map(
|
183
|
+
(remotePresentation, index) => ({
|
184
|
+
id: remotePresentation.inputDescriptor.id,
|
185
|
+
path: remotePresentations.length === 1 ? `$` : `$[${index}]`,
|
186
|
+
format: remotePresentation.format,
|
187
|
+
})
|
188
|
+
);
|
206
189
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
190
|
+
const presentation_submission = {
|
191
|
+
id: uuid.v4(),
|
192
|
+
definition_id: presentationDefinitionId,
|
193
|
+
descriptor_map,
|
194
|
+
};
|
212
195
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
196
|
+
const requestBody = await buildDirectPostJwtBody(requestObject, rpConf, {
|
197
|
+
vp_token,
|
198
|
+
presentation_submission,
|
199
|
+
});
|
200
|
+
|
201
|
+
// 3. Send the authorization response via HTTP POST and validate the response
|
202
|
+
return await appFetch(requestObject.response_uri, {
|
203
|
+
method: "POST",
|
204
|
+
headers: {
|
205
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
206
|
+
},
|
207
|
+
body: requestBody,
|
208
|
+
})
|
209
|
+
.then(hasStatusOrThrow(200))
|
210
|
+
.then((res) => res.json())
|
211
|
+
.then(AuthorizationResponse.parse);
|
217
212
|
};
|
218
213
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
vp_token,
|
233
|
-
presentation_submission: presentation_submission,
|
234
|
-
});
|
214
|
+
/**
|
215
|
+
* Type definition for the function that sends the authorization response
|
216
|
+
* to the Relying Party, completing the presentation flow.
|
217
|
+
* Use with DCQL queries.
|
218
|
+
*/
|
219
|
+
export type SendAuthorizationResponse = (
|
220
|
+
requestObject: Out<VerifyRequestObject>["requestObject"],
|
221
|
+
remotePresentations: RemotePresentation[],
|
222
|
+
rpConf: RelyingPartyEntityConfiguration["payload"]["metadata"],
|
223
|
+
context?: {
|
224
|
+
appFetch?: GlobalFetch["fetch"];
|
225
|
+
}
|
226
|
+
) => Promise<AuthorizationResponse>;
|
235
227
|
|
236
|
-
|
237
|
-
|
228
|
+
export const sendAuthorizationResponse: SendAuthorizationResponse = async (
|
229
|
+
requestObject,
|
230
|
+
remotePresentations,
|
231
|
+
rpConf,
|
232
|
+
{ appFetch = fetch } = {}
|
233
|
+
): Promise<AuthorizationResponse> => {
|
234
|
+
// 1. Prepare the VP token as a JSON object with keys corresponding to the DCQL query credential IDs
|
235
|
+
const requestBody = await buildDirectPostJwtBody(requestObject, rpConf, {
|
236
|
+
vp_token: remotePresentations.reduce(
|
237
|
+
(acc, presentation) => ({
|
238
|
+
...acc,
|
239
|
+
[presentation.credentialId]: presentation.vpToken,
|
240
|
+
}),
|
241
|
+
{} as Record<string, string>
|
242
|
+
),
|
243
|
+
});
|
244
|
+
|
245
|
+
// 2. Send the authorization response via HTTP POST and validate the response
|
246
|
+
return await appFetch(requestObject.response_uri, {
|
238
247
|
method: "POST",
|
239
248
|
headers: {
|
240
249
|
"Content-Type": "application/x-www-form-urlencoded",
|
@@ -243,10 +252,8 @@ export const sendAuthorizationResponse: SendAuthorizationResponse = async (
|
|
243
252
|
})
|
244
253
|
.then(hasStatusOrThrow(200))
|
245
254
|
.then((res) => res.json())
|
246
|
-
.then(AuthorizationResponse.
|
247
|
-
|
248
|
-
// Some Relying Parties may return an empty body.
|
249
|
-
return authResponse.success ? authResponse.data : {};
|
255
|
+
.then(AuthorizationResponse.parse)
|
256
|
+
.catch(handleAuthorizationResponseError);
|
250
257
|
};
|
251
258
|
|
252
259
|
/**
|
@@ -254,9 +261,8 @@ export const sendAuthorizationResponse: SendAuthorizationResponse = async (
|
|
254
261
|
* to the Relying Party, completing the presentation flow.
|
255
262
|
*/
|
256
263
|
export type SendAuthorizationErrorResponse = (
|
257
|
-
requestObject: Out<
|
258
|
-
error: ErrorResponse,
|
259
|
-
jwkKeys: Out<FetchJwks>["keys"],
|
264
|
+
requestObject: Out<VerifyRequestObject>["requestObject"],
|
265
|
+
error: { error: ErrorResponse; errorDescription: string },
|
260
266
|
context?: {
|
261
267
|
appFetch?: GlobalFetch["fetch"];
|
262
268
|
}
|
@@ -267,61 +273,21 @@ export type SendAuthorizationErrorResponse = (
|
|
267
273
|
* This function completes the presentation flow in an OpenID 4 Verifiable Presentations scenario.
|
268
274
|
*
|
269
275
|
* @param requestObject - The request details, including presentation requirements.
|
270
|
-
* @param error - The response error value
|
271
|
-
* @param jwkKeys - Array of JWKs from the Relying Party for optional encryption.
|
276
|
+
* @param error - The response error value, with description
|
272
277
|
* @param context - Contains optional custom fetch implementation.
|
273
278
|
* @returns Parsed and validated authorization response from the Relying Party.
|
274
279
|
*/
|
275
280
|
export const sendAuthorizationErrorResponse: SendAuthorizationErrorResponse =
|
276
281
|
async (
|
277
282
|
requestObject,
|
278
|
-
error,
|
279
|
-
jwkKeys,
|
283
|
+
{ error, errorDescription },
|
280
284
|
{ appFetch = fetch } = {}
|
281
285
|
): Promise<AuthorizationResponse> => {
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
: await buildDirectPostBody(requestObject, { error });
|
287
|
-
// 3. Send the authorization error response via HTTP POST and validate the response
|
288
|
-
return await appFetch(requestObject.response_uri, {
|
289
|
-
method: "POST",
|
290
|
-
headers: {
|
291
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
292
|
-
},
|
293
|
-
body: requestBody,
|
294
|
-
})
|
295
|
-
.then(hasStatusOrThrow(200))
|
296
|
-
.then((res) => res.json())
|
297
|
-
.then(AuthorizationResponse.parse);
|
298
|
-
};
|
286
|
+
const requestBody = await buildDirectPostBody(requestObject, {
|
287
|
+
error,
|
288
|
+
error_description: errorDescription,
|
289
|
+
});
|
299
290
|
|
300
|
-
export const sendAuthorizationResponseDcql: SendAuthorizationResponseDcql =
|
301
|
-
async (
|
302
|
-
requestObject,
|
303
|
-
jwkKeys,
|
304
|
-
remotePresentation,
|
305
|
-
{ appFetch = fetch } = {}
|
306
|
-
): Promise<AuthorizationResponse> => {
|
307
|
-
const { generatedNonce, presentations } = remotePresentation;
|
308
|
-
// 1. Prepare the VP token as a JSON object with keys corresponding to the DCQL query credential IDs
|
309
|
-
const requestBody = await buildDirectPostJwtBody(
|
310
|
-
jwkKeys,
|
311
|
-
requestObject,
|
312
|
-
{
|
313
|
-
vp_token: presentations.reduce(
|
314
|
-
(acc, presentation) => ({
|
315
|
-
...acc,
|
316
|
-
[presentation.credentialId]: presentation.vpToken,
|
317
|
-
}),
|
318
|
-
{} as Record<string, string>
|
319
|
-
),
|
320
|
-
},
|
321
|
-
generatedNonce
|
322
|
-
);
|
323
|
-
|
324
|
-
// 2. Send the authorization response via HTTP POST and validate the response
|
325
291
|
return await appFetch(requestObject.response_uri, {
|
326
292
|
method: "POST",
|
327
293
|
headers: {
|
@@ -329,83 +295,35 @@ export const sendAuthorizationResponseDcql: SendAuthorizationResponseDcql =
|
|
329
295
|
},
|
330
296
|
body: requestBody,
|
331
297
|
})
|
332
|
-
.then(hasStatusOrThrow(200))
|
298
|
+
.then(hasStatusOrThrow(200, RelyingPartyResponseError))
|
333
299
|
.then((res) => res.json())
|
334
300
|
.then(AuthorizationResponse.parse);
|
335
301
|
};
|
336
302
|
|
337
303
|
/**
|
338
|
-
*
|
339
|
-
*
|
340
|
-
*
|
341
|
-
*
|
342
|
-
* - Generates a verifiable presentation token (vpToken) using the appropriate method.
|
343
|
-
* - For ISO 18013-7, generates a special nonce with minimum entropy of 16.
|
344
|
-
*
|
345
|
-
* @param credentials - An array of credential items containing format, credential data, requested claims, and key information.
|
346
|
-
* @param authRequestObject - The authentication request object containing nonce, clientId, and responseUri.
|
347
|
-
* @returns A promise that resolves to an object containing an array of presentations and the generated nonce.
|
348
|
-
* @throws {CredentialNotFoundError} When the credential format is unsupported.
|
304
|
+
* Handle the the presentation error by mapping it to a custom exception.
|
305
|
+
* If the error is not an instance of {@link UnexpectedStatusCodeError}, it is thrown as is.
|
306
|
+
* @param e - The error to be handled
|
307
|
+
* @throws {RelyingPartyResponseError} with a specific code for more context
|
349
308
|
*/
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
/* In case of ISO 18013-7 we need a nonce, it shall have a minimum entropy of 16 */
|
355
|
-
const generatedNonce = generateRandomAlphaNumericString(16);
|
356
|
-
|
357
|
-
const presentations = await Promise.all(
|
358
|
-
credentials.map(async (item) => {
|
359
|
-
const { credentialInputId, format } = item;
|
360
|
-
|
361
|
-
if (format === "mso_mdoc") {
|
362
|
-
const { vp_token } = await prepareVpTokenMdoc(
|
363
|
-
authRequestObject.nonce,
|
364
|
-
generatedNonce,
|
365
|
-
authRequestObject.clientId,
|
366
|
-
authRequestObject.responseUri,
|
367
|
-
item.doctype,
|
368
|
-
item.keyTag,
|
369
|
-
[
|
370
|
-
item.credential,
|
371
|
-
item.requestedClaims,
|
372
|
-
createCryptoContextFor(item.keyTag),
|
373
|
-
]
|
374
|
-
);
|
375
|
-
|
376
|
-
return {
|
377
|
-
requestedClaims: [...item.requestedClaims.map(({ name }) => name)],
|
378
|
-
credentialId: credentialInputId,
|
379
|
-
vpToken: vp_token,
|
380
|
-
format: "mso_mdoc",
|
381
|
-
};
|
382
|
-
}
|
383
|
-
|
384
|
-
if (format === "vc+sd-jwt") {
|
385
|
-
const { vp_token } = await prepareVpToken(
|
386
|
-
authRequestObject.nonce,
|
387
|
-
authRequestObject.clientId,
|
388
|
-
[
|
389
|
-
item.credential,
|
390
|
-
item.requestedClaims,
|
391
|
-
createCryptoContextFor(item.keyTag),
|
392
|
-
]
|
393
|
-
);
|
394
|
-
|
395
|
-
return {
|
396
|
-
requestedClaims: [...item.requestedClaims.map(({ name }) => name)],
|
397
|
-
credentialId: credentialInputId,
|
398
|
-
vpToken: vp_token,
|
399
|
-
format: "vc+sd-jwt",
|
400
|
-
};
|
401
|
-
}
|
309
|
+
const handleAuthorizationResponseError = (e: unknown) => {
|
310
|
+
if (!(e instanceof UnexpectedStatusCodeError)) {
|
311
|
+
throw e;
|
312
|
+
}
|
402
313
|
|
403
|
-
|
314
|
+
throw new ResponseErrorBuilder(RelyingPartyResponseError)
|
315
|
+
.handle(400, {
|
316
|
+
code: RelyingPartyResponseErrorCodes.InvalidAuthorizationResponse,
|
317
|
+
message:
|
318
|
+
"The Authorization Response contains invalid parameters or it is malformed",
|
404
319
|
})
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
320
|
+
.handle(403, {
|
321
|
+
code: RelyingPartyResponseErrorCodes.InvalidAuthorizationResponse,
|
322
|
+
message: "The Authorization Response was forbidden",
|
323
|
+
})
|
324
|
+
.handle("*", {
|
325
|
+
code: RelyingPartyResponseErrorCodes.RelyingPartyGenericError,
|
326
|
+
message: "Unable to successfully send the Authorization Response",
|
327
|
+
})
|
328
|
+
.buildFrom(e);
|
411
329
|
};
|