@pagopa/io-react-native-wallet 1.7.1 → 2.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -1
- package/lib/commonjs/client/generated/wallet-provider.js +49 -20
- package/lib/commonjs/client/generated/wallet-provider.js.map +1 -1
- package/lib/commonjs/credential/index.js +5 -1
- package/lib/commonjs/credential/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js +27 -0
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js +25 -16
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +30 -18
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/05-authorize-access.js +17 -12
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +36 -29
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +27 -207
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/README.md +23 -20
- package/lib/commonjs/credential/issuance/const.js +1 -1
- package/lib/commonjs/credential/issuance/const.js.map +1 -1
- package/lib/commonjs/credential/issuance/index.js +3 -3
- package/lib/commonjs/credential/issuance/index.js.map +1 -1
- package/lib/commonjs/credential/presentation/01-start-flow.js +14 -15
- package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js +6 -4
- package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
- package/lib/commonjs/credential/presentation/03-get-request-object.js +34 -7
- package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js +4 -126
- package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
- package/lib/commonjs/credential/presentation/05-verify-request-object.js +80 -25
- package/lib/commonjs/credential/presentation/05-verify-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js +6 -30
- package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +97 -117
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +86 -191
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js +112 -176
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/commonjs/credential/presentation/README.md +74 -79
- package/lib/commonjs/credential/presentation/errors.js +42 -21
- package/lib/commonjs/credential/presentation/errors.js.map +1 -1
- package/lib/commonjs/credential/presentation/index.js +13 -13
- package/lib/commonjs/credential/presentation/index.js.map +1 -1
- package/lib/commonjs/credential/presentation/types.js +53 -29
- package/lib/commonjs/credential/presentation/types.js.map +1 -1
- package/lib/commonjs/credential/status/01-start-flow.js +2 -0
- package/lib/commonjs/credential/status/01-start-flow.js.map +1 -0
- package/lib/commonjs/credential/status/02-status-attestation.js +73 -0
- package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -0
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +55 -0
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
- package/lib/commonjs/credential/status/README.md +67 -0
- package/lib/commonjs/credential/status/index.js +27 -0
- package/lib/commonjs/credential/status/index.js.map +1 -0
- package/lib/commonjs/credential/status/types.js +48 -0
- package/lib/commonjs/credential/status/types.js.map +1 -0
- package/lib/commonjs/credential/trustmark/README.md +62 -0
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js +86 -0
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js.map +1 -0
- package/lib/commonjs/credential/trustmark/index.js +13 -0
- package/lib/commonjs/credential/trustmark/index.js.map +1 -0
- package/lib/commonjs/index.js +5 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/pid/sd-jwt/types.js +18 -2
- package/lib/commonjs/pid/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/index.test.js +22 -34
- package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/types.test.js +11 -23
- package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/index.js +1 -7
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/commonjs/sd-jwt/types.js +5 -21
- package/lib/commonjs/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/{entity/trust → trust}/chain.js +49 -55
- package/lib/commonjs/trust/chain.js.map +1 -0
- package/lib/commonjs/trust/errors.js +110 -0
- package/lib/commonjs/trust/errors.js.map +1 -0
- package/lib/commonjs/trust/index.js +282 -0
- package/lib/commonjs/trust/index.js.map +1 -0
- package/lib/commonjs/{entity/trust → trust}/types.js +27 -47
- package/lib/commonjs/trust/types.js.map +1 -0
- package/lib/commonjs/trust/utils.js +41 -0
- package/lib/commonjs/trust/utils.js.map +1 -0
- package/lib/commonjs/utils/crypto.js +5 -112
- package/lib/commonjs/utils/crypto.js.map +1 -1
- package/lib/commonjs/utils/decoder.js +2 -0
- package/lib/commonjs/utils/decoder.js.map +1 -1
- package/lib/commonjs/utils/error-codes.js +22 -2
- package/lib/commonjs/utils/error-codes.js.map +1 -1
- package/lib/commonjs/utils/errors.js +72 -4
- package/lib/commonjs/utils/errors.js.map +1 -1
- package/lib/commonjs/utils/logging.js +68 -0
- package/lib/commonjs/utils/logging.js.map +1 -0
- package/lib/commonjs/utils/misc.js +2 -0
- package/lib/commonjs/utils/misc.js.map +1 -1
- package/lib/commonjs/utils/par.js +17 -10
- package/lib/commonjs/utils/par.js.map +1 -1
- package/lib/commonjs/utils/string.js +1 -12
- package/lib/commonjs/utils/string.js.map +1 -1
- package/lib/commonjs/wallet-instance/index.js +14 -0
- package/lib/commonjs/wallet-instance/index.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/README.md +8 -3
- package/lib/commonjs/wallet-instance-attestation/issuing.js +15 -8
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/types.js +16 -20
- package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
- package/lib/module/client/generated/wallet-provider.js +40 -15
- package/lib/module/client/generated/wallet-provider.js.map +1 -1
- package/lib/module/credential/index.js +3 -1
- package/lib/module/credential/index.js.map +1 -1
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +20 -0
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
- package/lib/module/credential/issuance/03-start-user-authorization.js +25 -16
- package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js +30 -18
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/05-authorize-access.js +17 -11
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +36 -28
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +27 -205
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/issuance/README.md +23 -20
- package/lib/module/credential/issuance/const.js +1 -1
- package/lib/module/credential/issuance/const.js.map +1 -1
- package/lib/module/credential/issuance/index.js +2 -2
- package/lib/module/credential/issuance/index.js.map +1 -1
- package/lib/module/credential/presentation/01-start-flow.js +14 -15
- package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/module/credential/presentation/02-evaluate-rp-trust.js +5 -3
- package/lib/module/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
- package/lib/module/credential/presentation/03-get-request-object.js +34 -7
- package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/module/credential/presentation/04-retrieve-rp-jwks.js +2 -124
- package/lib/module/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
- package/lib/module/credential/presentation/05-verify-request-object.js +78 -23
- package/lib/module/credential/presentation/05-verify-request-object.js.map +1 -1
- package/lib/module/credential/presentation/06-fetch-presentation-definition.js +6 -30
- package/lib/module/credential/presentation/06-fetch-presentation-definition.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js +97 -118
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +83 -186
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/module/credential/presentation/08-send-authorization-response.js +107 -170
- package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/module/credential/presentation/README.md +74 -79
- package/lib/module/credential/presentation/errors.js +30 -17
- package/lib/module/credential/presentation/errors.js.map +1 -1
- package/lib/module/credential/presentation/index.js +6 -6
- package/lib/module/credential/presentation/index.js.map +1 -1
- package/lib/module/credential/presentation/types.js +49 -27
- package/lib/module/credential/presentation/types.js.map +1 -1
- package/lib/module/credential/status/01-start-flow.js +2 -0
- package/lib/module/credential/status/01-start-flow.js.map +1 -0
- package/lib/module/credential/status/02-status-attestation.js +66 -0
- package/lib/module/credential/status/02-status-attestation.js.map +1 -0
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +49 -0
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
- package/lib/module/credential/status/README.md +67 -0
- package/lib/module/credential/status/index.js +5 -0
- package/lib/module/credential/status/index.js.map +1 -0
- package/lib/module/credential/status/types.js +40 -0
- package/lib/module/credential/status/types.js.map +1 -0
- package/lib/module/credential/trustmark/README.md +62 -0
- package/lib/module/credential/trustmark/get-credential-trustmark.js +77 -0
- package/lib/module/credential/trustmark/get-credential-trustmark.js.map +1 -0
- package/lib/module/credential/trustmark/index.js +3 -0
- package/lib/module/credential/trustmark/index.js.map +1 -0
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/pid/sd-jwt/types.js +16 -1
- package/lib/module/pid/sd-jwt/types.js.map +1 -1
- package/lib/module/sd-jwt/__test__/index.test.js +22 -34
- package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/module/sd-jwt/__test__/types.test.js +11 -23
- package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/module/sd-jwt/index.js +1 -7
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/module/sd-jwt/types.js +4 -19
- package/lib/module/sd-jwt/types.js.map +1 -1
- package/lib/module/trust/chain.js +108 -0
- package/lib/module/trust/chain.js.map +1 -0
- package/lib/module/trust/errors.js +94 -0
- package/lib/module/trust/errors.js.map +1 -0
- package/lib/module/trust/index.js +263 -0
- package/lib/module/trust/index.js.map +1 -0
- package/lib/module/{entity/trust → trust}/types.js +25 -46
- package/lib/module/trust/types.js.map +1 -0
- package/lib/module/trust/utils.js +33 -0
- package/lib/module/trust/utils.js.map +1 -0
- package/lib/module/utils/crypto.js +4 -107
- package/lib/module/utils/crypto.js.map +1 -1
- package/lib/module/utils/decoder.js +3 -0
- package/lib/module/utils/decoder.js.map +1 -1
- package/lib/module/utils/error-codes.js +20 -1
- package/lib/module/utils/error-codes.js.map +1 -1
- package/lib/module/utils/errors.js +61 -4
- package/lib/module/utils/errors.js.map +1 -1
- package/lib/module/utils/logging.js +62 -0
- package/lib/module/utils/logging.js.map +1 -0
- package/lib/module/utils/misc.js +2 -0
- package/lib/module/utils/misc.js.map +1 -1
- package/lib/module/utils/par.js +17 -9
- package/lib/module/utils/par.js.map +1 -1
- package/lib/module/utils/string.js +0 -10
- package/lib/module/utils/string.js.map +1 -1
- package/lib/module/wallet-instance/index.js +13 -0
- package/lib/module/wallet-instance/index.js.map +1 -1
- package/lib/module/wallet-instance-attestation/README.md +8 -3
- package/lib/module/wallet-instance-attestation/index.js +2 -2
- package/lib/module/wallet-instance-attestation/index.js.map +1 -1
- package/lib/module/wallet-instance-attestation/issuing.js +16 -9
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/wallet-instance-attestation/types.js +14 -18
- package/lib/module/wallet-instance-attestation/types.js.map +1 -1
- package/lib/typescript/client/generated/wallet-provider.d.ts +206 -51
- package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
- package/lib/typescript/credential/index.d.ts +3 -1
- package/lib/typescript/credential/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -1
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts +19 -0
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +3 -3
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +9 -9
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts +3 -3
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +4 -4
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +3 -15
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/const.d.ts +1 -1
- package/lib/typescript/credential/issuance/const.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/index.d.ts +3 -3
- package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/types.d.ts +8 -3
- package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/01-start-flow.d.ts +28 -9
- package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts +2 -1
- package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts +7 -5
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts +4 -30
- package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts +17 -4
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts +4 -9
- package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +13 -12
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +40 -42
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +30 -43
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/errors.d.ts +25 -10
- package/lib/typescript/credential/presentation/errors.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/index.d.ts +7 -8
- package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/types.d.ts +137 -307
- package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
- package/lib/typescript/credential/status/01-start-flow.d.ts +10 -0
- package/lib/typescript/credential/status/01-start-flow.d.ts.map +1 -0
- package/lib/typescript/credential/status/02-status-attestation.d.ts +19 -0
- package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -0
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts +24 -0
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +1 -0
- package/lib/typescript/credential/status/index.d.ts +7 -0
- package/lib/typescript/credential/status/index.d.ts.map +1 -0
- package/lib/typescript/credential/status/types.d.ts +305 -0
- package/lib/typescript/credential/status/types.d.ts.map +1 -0
- package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts +52 -0
- package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts.map +1 -0
- package/lib/typescript/credential/trustmark/index.d.ts +4 -0
- package/lib/typescript/credential/trustmark/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +3 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/pid/sd-jwt/types.d.ts +103 -25
- package/lib/typescript/pid/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/index.d.ts +30 -82
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/types.d.ts +29 -134
- package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/{entity/trust → trust}/chain.d.ts +5 -10
- package/lib/typescript/trust/chain.d.ts.map +1 -0
- package/lib/typescript/trust/errors.d.ts +80 -0
- package/lib/typescript/trust/errors.d.ts.map +1 -0
- package/lib/typescript/{entity/trust → trust}/index.d.ts +211 -186
- package/lib/typescript/trust/index.d.ts.map +1 -0
- package/lib/typescript/{entity/trust → trust}/types.d.ts +1533 -1120
- package/lib/typescript/{entity/trust → trust}/types.d.ts.map +1 -1
- package/lib/typescript/trust/utils.d.ts +12 -0
- package/lib/typescript/trust/utils.d.ts.map +1 -0
- package/lib/typescript/utils/crypto.d.ts +0 -32
- package/lib/typescript/utils/crypto.d.ts.map +1 -1
- package/lib/typescript/utils/decoder.d.ts.map +1 -1
- package/lib/typescript/utils/error-codes.d.ts +20 -0
- package/lib/typescript/utils/error-codes.d.ts.map +1 -1
- package/lib/typescript/utils/errors.d.ts +55 -10
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/logging.d.ts +35 -0
- package/lib/typescript/utils/logging.d.ts.map +1 -0
- package/lib/typescript/utils/misc.d.ts.map +1 -1
- package/lib/typescript/utils/par.d.ts +8 -1
- package/lib/typescript/utils/par.d.ts.map +1 -1
- package/lib/typescript/utils/string.d.ts +0 -7
- package/lib/typescript/utils/string.d.ts.map +1 -1
- package/lib/typescript/wallet-instance/index.d.ts +8 -0
- package/lib/typescript/wallet-instance/index.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/index.d.ts +1 -2
- package/lib/typescript/wallet-instance-attestation/index.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts +4 -2
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/types.d.ts +78 -120
- package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
- package/package.json +8 -9
- package/src/client/generated/wallet-provider.ts +52 -17
- package/src/credential/index.ts +4 -1
- package/src/credential/issuance/01-start-flow.ts +1 -1
- package/src/credential/issuance/02-evaluate-issuer-trust.ts +32 -0
- package/src/credential/issuance/03-start-user-authorization.ts +48 -22
- package/src/credential/issuance/04-complete-user-authorization.ts +74 -18
- package/src/credential/issuance/05-authorize-access.ts +29 -11
- package/src/credential/issuance/06-obtain-credential.ts +61 -36
- package/src/credential/issuance/07-verify-and-parse-credential.ts +37 -264
- package/src/credential/issuance/README.md +23 -20
- package/src/credential/issuance/const.ts +1 -1
- package/src/credential/issuance/index.ts +6 -3
- package/src/credential/presentation/01-start-flow.ts +19 -22
- package/src/credential/presentation/02-evaluate-rp-trust.ts +5 -4
- package/src/credential/presentation/03-get-request-object.ts +36 -8
- package/src/credential/presentation/04-retrieve-rp-jwks.ts +6 -148
- package/src/credential/presentation/05-verify-request-object.ts +115 -30
- package/src/credential/presentation/06-fetch-presentation-definition.ts +5 -35
- package/src/credential/presentation/07-evaluate-dcql-query.ts +132 -161
- package/src/credential/presentation/07-evaluate-input-descriptor.ts +136 -254
- package/src/credential/presentation/08-send-authorization-response.ts +178 -260
- package/src/credential/presentation/README.md +74 -79
- package/src/credential/presentation/errors.ts +38 -15
- package/src/credential/presentation/index.ts +18 -19
- package/src/credential/presentation/types.ts +67 -64
- package/src/credential/status/01-start-flow.ts +9 -0
- package/src/credential/status/02-status-attestation.ts +105 -0
- package/src/credential/status/03-verify-and-parse-status-attestation.ts +70 -0
- package/src/credential/status/README.md +67 -0
- package/src/credential/status/index.ts +22 -0
- package/src/credential/status/types.ts +43 -0
- package/src/credential/trustmark/README.md +62 -0
- package/src/credential/trustmark/get-credential-trustmark.ts +139 -0
- package/src/credential/trustmark/index.ts +8 -0
- package/src/index.ts +4 -0
- package/src/pid/sd-jwt/types.ts +18 -1
- package/src/sd-jwt/__test__/index.test.ts +36 -55
- package/src/sd-jwt/__test__/types.test.ts +16 -29
- package/src/sd-jwt/index.ts +1 -5
- package/src/sd-jwt/types.ts +2 -19
- package/src/trust/chain.ts +151 -0
- package/src/trust/errors.ts +105 -0
- package/src/{entity/trust → trust}/index.ts +198 -23
- package/src/{entity/trust → trust}/types.ts +24 -37
- package/src/trust/utils.ts +35 -0
- package/src/utils/crypto.ts +4 -106
- package/src/utils/decoder.ts +6 -1
- package/src/utils/error-codes.ts +23 -0
- package/src/utils/errors.ts +119 -15
- package/src/utils/logging.ts +68 -0
- package/src/utils/misc.ts +5 -0
- package/src/utils/par.ts +19 -6
- package/src/utils/string.ts +0 -10
- package/src/wallet-instance/index.ts +30 -1
- package/src/wallet-instance-attestation/README.md +8 -3
- package/src/wallet-instance-attestation/index.ts +2 -2
- package/src/wallet-instance-attestation/issuing.ts +33 -12
- package/src/wallet-instance-attestation/types.ts +18 -22
- package/lib/commonjs/credential/issuance/02-get-issuer-config.js +0 -48
- package/lib/commonjs/credential/issuance/02-get-issuer-config.js.map +0 -1
- package/lib/commonjs/entity/openid-connect/issuer/index.js +0 -25
- package/lib/commonjs/entity/openid-connect/issuer/index.js.map +0 -1
- package/lib/commonjs/entity/openid-connect/issuer/types.js +0 -64
- package/lib/commonjs/entity/openid-connect/issuer/types.js.map +0 -1
- package/lib/commonjs/entity/trust/chain.js.map +0 -1
- package/lib/commonjs/entity/trust/index.js +0 -148
- package/lib/commonjs/entity/trust/index.js.map +0 -1
- package/lib/commonjs/entity/trust/types.js.map +0 -1
- package/lib/commonjs/mdoc/converters.js +0 -26
- package/lib/commonjs/mdoc/converters.js.map +0 -1
- package/lib/commonjs/mdoc/index.js +0 -68
- package/lib/commonjs/mdoc/index.js.map +0 -1
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -469
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -90
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
- package/lib/module/credential/issuance/02-get-issuer-config.js +0 -42
- package/lib/module/credential/issuance/02-get-issuer-config.js.map +0 -1
- package/lib/module/entity/openid-connect/issuer/index.js +0 -20
- package/lib/module/entity/openid-connect/issuer/index.js.map +0 -1
- package/lib/module/entity/openid-connect/issuer/types.js +0 -48
- package/lib/module/entity/openid-connect/issuer/types.js.map +0 -1
- package/lib/module/entity/trust/chain.js +0 -113
- package/lib/module/entity/trust/chain.js.map +0 -1
- package/lib/module/entity/trust/index.js +0 -131
- package/lib/module/entity/trust/index.js.map +0 -1
- package/lib/module/entity/trust/types.js.map +0 -1
- package/lib/module/mdoc/converters.js +0 -20
- package/lib/module/mdoc/converters.js.map +0 -1
- package/lib/module/mdoc/index.js +0 -60
- package/lib/module/mdoc/index.js.map +0 -1
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -462
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -83
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
- package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts +0 -32
- package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts.map +0 -1
- package/lib/typescript/entity/openid-connect/issuer/index.d.ts +0 -12
- package/lib/typescript/entity/openid-connect/issuer/index.d.ts.map +0 -1
- package/lib/typescript/entity/openid-connect/issuer/types.d.ts +0 -777
- package/lib/typescript/entity/openid-connect/issuer/types.d.ts.map +0 -1
- package/lib/typescript/entity/trust/chain.d.ts.map +0 -1
- package/lib/typescript/entity/trust/index.d.ts.map +0 -1
- package/lib/typescript/mdoc/converters.d.ts +0 -8
- package/lib/typescript/mdoc/converters.d.ts.map +0 -1
- package/lib/typescript/mdoc/index.d.ts +0 -10
- package/lib/typescript/mdoc/index.d.ts.map +0 -1
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts +0 -3
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts.map +0 -1
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts +0 -42
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts.map +0 -1
- package/src/credential/issuance/02-get-issuer-config.ts +0 -67
- package/src/entity/openid-connect/issuer/index.ts +0 -27
- package/src/entity/openid-connect/issuer/types.ts +0 -76
- package/src/entity/trust/chain.ts +0 -154
- package/src/mdoc/converters.ts +0 -26
- package/src/mdoc/index.ts +0 -95
- package/src/utils/credential/issuance/07-verify-and-parse-credentials-inputs.ts +0 -615
- package/src/utils/credential/issuance/07-verify-and-parse-credentials-utils.ts +0 -171
@@ -4,13 +4,14 @@ import parseUrl from "parse-url";
|
|
4
4
|
import { IssuerResponseError, ValidationFailed } from "../../utils/errors";
|
5
5
|
import { decode, encodeBase64, SignJWT } from "@pagopa/io-react-native-jwt";
|
6
6
|
import { RequestObject } from "../presentation/types";
|
7
|
-
import
|
7
|
+
import { v4 as uuidv4 } from "uuid";
|
8
8
|
import { ResponseUriResultShape } from "./types";
|
9
9
|
import { getJwtFromFormPost } from "../../utils/decoder";
|
10
10
|
import { AuthorizationError, AuthorizationIdpError } from "./errors";
|
11
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
11
12
|
|
12
13
|
/**
|
13
|
-
* The interface of the phase to complete User authorization via strong identification when the response mode is "query" and the request credential is a
|
14
|
+
* The interface of the phase to complete User authorization via strong identification when the response mode is "query" and the request credential is a PersonIdentificationData.
|
14
15
|
*/
|
15
16
|
|
16
17
|
/**
|
@@ -18,19 +19,19 @@ import { AuthorizationError, AuthorizationIdpError } from "./errors";
|
|
18
19
|
* Builds the authorization URL to which the end user should be redirected to continue the authentication flow.
|
19
20
|
* @param issuerRequestUri the URI of the issuer where the request is sent
|
20
21
|
* @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
|
21
|
-
* @param issuerConf The issuer configuration returned by {@link
|
22
|
-
* @param idpHint Unique identifier of the IDP selected by the user
|
22
|
+
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
23
|
+
* @param idpHint Unique identifier of the IDP selected by the user (optional)
|
23
24
|
* @returns An object containing the authorization URL
|
24
25
|
*/
|
25
26
|
export const buildAuthorizationUrl = async (issuerRequestUri, clientId, issuerConf, idpHint) => {
|
26
|
-
const authzRequestEndpoint = issuerConf.authorization_endpoint;
|
27
|
+
const authzRequestEndpoint = issuerConf.oauth_authorization_server.authorization_endpoint;
|
27
28
|
const params = new URLSearchParams({
|
28
29
|
client_id: clientId,
|
29
|
-
request_uri: issuerRequestUri
|
30
|
-
...(idpHint && {
|
31
|
-
idphint: idpHint
|
32
|
-
})
|
30
|
+
request_uri: issuerRequestUri
|
33
31
|
});
|
32
|
+
if (idpHint) {
|
33
|
+
params.append("idphint", idpHint);
|
34
|
+
}
|
34
35
|
const authUrl = `${authzRequestEndpoint}?${params}`;
|
35
36
|
return {
|
36
37
|
authUrl
|
@@ -39,12 +40,13 @@ export const buildAuthorizationUrl = async (issuerRequestUri, clientId, issuerCo
|
|
39
40
|
|
40
41
|
/**
|
41
42
|
* WARNING: This function must be called after obtaining the authorization redirect URL from the webviews (SPID and CIE L3) or browser for CIEID.
|
42
|
-
* Complete User authorization via strong identification when the response mode is "query" and the request credential is a
|
43
|
+
* Complete User authorization via strong identification when the response mode is "query" and the request credential is a PersonIdentificationData.
|
43
44
|
* This function parses the authorization redirect URL to extract the authorization response.
|
44
45
|
* @param authRedirectUrl The URL to which the end user should be redirected to start the authentication flow
|
45
46
|
* @returns the authorization response which contains code, state and iss
|
46
47
|
*/
|
47
48
|
export const completeUserAuthorizationWithQueryMode = async authRedirectUrl => {
|
49
|
+
Logger.log(LogLevel.DEBUG, `The requeste credential is a PersonIdentificationData, completing the user authorization with query mode`);
|
48
50
|
const query = parseUrl(authRedirectUrl).query;
|
49
51
|
return parseAuthorizationResponse(query);
|
50
52
|
};
|
@@ -56,22 +58,25 @@ export const completeUserAuthorizationWithQueryMode = async authRedirectUrl => {
|
|
56
58
|
* The information is obtained by performing a GET request to the authorization endpoint with request_uri and client_id parameters.
|
57
59
|
* @param issuerRequestUri the URI of the issuer where the request is sent
|
58
60
|
* @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
|
59
|
-
* @param issuerConf The issuer configuration returned by {@link
|
61
|
+
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
60
62
|
* @param appFetch (optional) fetch api implementation. Default: built-in fetch
|
61
63
|
* @throws {ValidationFailed} if an error while validating the response
|
62
64
|
* @returns the request object which contains the credential to be presented in order to obtain the requested credential
|
63
65
|
*/
|
64
66
|
export const getRequestedCredentialToBePresented = async function (issuerRequestUri, clientId, issuerConf) {
|
65
67
|
let appFetch = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : fetch;
|
66
|
-
|
68
|
+
Logger.log(LogLevel.DEBUG, `The requeste credential is not a PersonIdentificationData, requesting the credential to be presented`);
|
69
|
+
const authzRequestEndpoint = issuerConf.oauth_authorization_server.authorization_endpoint;
|
67
70
|
const params = new URLSearchParams({
|
68
71
|
client_id: clientId,
|
69
72
|
request_uri: issuerRequestUri
|
70
73
|
});
|
74
|
+
Logger.log(LogLevel.DEBUG, `Requesting the request object to ${authzRequestEndpoint}?${params.toString()}`);
|
71
75
|
const requestObject = await appFetch(`${authzRequestEndpoint}?${params.toString()}`, {
|
72
76
|
method: "GET"
|
73
77
|
}).then(hasStatusOrThrow(200, IssuerResponseError)).then(res => res.text()).then(jws => decode(jws)).then(reqObj => RequestObject.safeParse(reqObj.payload));
|
74
78
|
if (!requestObject.success) {
|
79
|
+
Logger.log(LogLevel.ERROR, `Error while validating the response object: ${requestObject.error.message}`);
|
75
80
|
throw new ValidationFailed({
|
76
81
|
message: "Request Object validation failed",
|
77
82
|
reason: requestObject.error.message
|
@@ -87,7 +92,7 @@ export const getRequestedCredentialToBePresented = async function (issuerRequest
|
|
87
92
|
* The information is obtained by performing a GET request to the authorization endpoint with request_uri and client_id parameters.
|
88
93
|
* @param issuerRequestUri the URI of the issuer where the request is sent
|
89
94
|
* @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
|
90
|
-
* @param issuerConf The issuer configuration returned by {@link
|
95
|
+
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
91
96
|
* @param context.walletInstanceAccestation the Wallet Instance's attestation to be presented
|
92
97
|
* @param context.pid the PID to be presented
|
93
98
|
* @param context.wiaCryptoContext The Wallet Instance's crypto context associated with the walletInstanceAttestation parameter
|
@@ -97,6 +102,7 @@ export const getRequestedCredentialToBePresented = async function (issuerRequest
|
|
97
102
|
* @returns the authorization response which contains code, state and iss
|
98
103
|
*/
|
99
104
|
export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject, ctx) => {
|
105
|
+
Logger.log(LogLevel.DEBUG, `The requeste credential is not a PersonIdentificationData, completing the user authorization with form_post.jwt mode`);
|
100
106
|
const {
|
101
107
|
wiaCryptoContext,
|
102
108
|
pidCryptoContext,
|
@@ -109,7 +115,7 @@ export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject
|
|
109
115
|
typ: "JWT"
|
110
116
|
}).setPayload({
|
111
117
|
vp: walletInstanceAttestation,
|
112
|
-
jti:
|
118
|
+
jti: uuidv4().toString(),
|
113
119
|
nonce: requestObject.nonce
|
114
120
|
}).setIssuedAt().setExpirationTime("5m").setAudience(requestObject.response_uri).sign();
|
115
121
|
const pidWpToken = await new SignJWT(pidCryptoContext).setProtectedHeader({
|
@@ -117,18 +123,19 @@ export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject
|
|
117
123
|
typ: "JWT"
|
118
124
|
}).setPayload({
|
119
125
|
vp: pid,
|
120
|
-
jti:
|
126
|
+
jti: uuidv4().toString(),
|
121
127
|
nonce: requestObject.nonce
|
122
128
|
}).setIssuedAt().setExpirationTime("5m").setAudience(requestObject.response_uri).sign();
|
129
|
+
Logger.log(LogLevel.DEBUG, `Wallet instance attestation JWT token: ${wiaWpToken}`);
|
123
130
|
|
124
131
|
/* The path parameter refers to the vp_token variable of the authzResponsePayload and must point to the plain credential which
|
125
132
|
* is cointaned in the `vp` property of the signed jwt token payload
|
126
133
|
*/
|
127
134
|
const presentationSubmission = {
|
128
|
-
definition_id: `${
|
129
|
-
id: `${
|
135
|
+
definition_id: `${uuidv4()}`,
|
136
|
+
id: `${uuidv4()}`,
|
130
137
|
descriptor_map: [{
|
131
|
-
id: "
|
138
|
+
id: "PersonIdentificationData",
|
132
139
|
path: "$.vp_token[0].vp",
|
133
140
|
format: "vc+sd-jwt"
|
134
141
|
}, {
|
@@ -137,11 +144,13 @@ export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject
|
|
137
144
|
format: "jwt"
|
138
145
|
}]
|
139
146
|
};
|
147
|
+
Logger.log(LogLevel.DEBUG, `Presentation submission: ${JSON.stringify(presentationSubmission)}`);
|
140
148
|
const authzResponsePayload = encodeBase64(JSON.stringify({
|
141
149
|
state: requestObject.state,
|
142
150
|
presentation_submission: presentationSubmission,
|
143
151
|
vp_token: [pidWpToken, wiaWpToken]
|
144
152
|
}));
|
153
|
+
Logger.log(LogLevel.DEBUG, `Authz response payload: ${authzResponsePayload}`);
|
145
154
|
|
146
155
|
// Note: according to the spec, the response should be encrypted with the public key of the RP however this is not implemented yet
|
147
156
|
// https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#name-signed-and-encrypted-response
|
@@ -164,6 +173,7 @@ export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject
|
|
164
173
|
}).then(hasStatusOrThrow(200, IssuerResponseError)).then(reqUri => reqUri.json());
|
165
174
|
const responseUri = ResponseUriResultShape.safeParse(resUriRes);
|
166
175
|
if (!responseUri.success) {
|
176
|
+
Logger.log(LogLevel.ERROR, `Error while validating the response uri: ${responseUri.error.message}`);
|
167
177
|
throw new ValidationFailed({
|
168
178
|
message: "Response Uri validation failed",
|
169
179
|
reason: responseUri.error.message
|
@@ -184,9 +194,11 @@ export const parseAuthorizationResponse = authRes => {
|
|
184
194
|
if (!authResParsed.success) {
|
185
195
|
const authErr = AuthorizationErrorShape.safeParse(authRes);
|
186
196
|
if (!authErr.success) {
|
197
|
+
Logger.log(LogLevel.ERROR, `Error while parsing the authorization response: ${authResParsed.error.message}`);
|
187
198
|
throw new AuthorizationError(authResParsed.error.message); // an error occured while parsing the result and the error
|
188
199
|
}
|
189
200
|
|
201
|
+
Logger.log(LogLevel.ERROR, `Error while authorizating with the idp: ${JSON.stringify(authErr)}`);
|
190
202
|
throw new AuthorizationIdpError(authErr.data.error, authErr.data.error_description);
|
191
203
|
}
|
192
204
|
return authResParsed.data;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","hasStatusOrThrow","parseUrl","IssuerResponseError","ValidationFailed","decode","encodeBase64","SignJWT","RequestObject","
|
1
|
+
{"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","hasStatusOrThrow","parseUrl","IssuerResponseError","ValidationFailed","decode","encodeBase64","SignJWT","RequestObject","v4","uuidv4","ResponseUriResultShape","getJwtFromFormPost","AuthorizationError","AuthorizationIdpError","LogLevel","Logger","buildAuthorizationUrl","issuerRequestUri","clientId","issuerConf","idpHint","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","append","authUrl","completeUserAuthorizationWithQueryMode","authRedirectUrl","log","DEBUG","query","parseAuthorizationResponse","getRequestedCredentialToBePresented","appFetch","arguments","length","undefined","fetch","toString","requestObject","method","then","res","text","jws","reqObj","safeParse","payload","success","ERROR","error","message","reason","data","completeUserAuthorizationWithFormPostJwtMode","ctx","wiaCryptoContext","pidCryptoContext","pid","walletInstanceAttestation","wiaWpToken","setProtectedHeader","alg","typ","setPayload","vp","jti","nonce","setIssuedAt","setExpirationTime","setAudience","response_uri","sign","pidWpToken","presentationSubmission","definition_id","id","descriptor_map","path","format","JSON","stringify","authzResponsePayload","state","presentation_submission","vp_token","body","response","resUriRes","headers","reqUri","json","responseUri","redirect_uri","cbRes","decodedJwt","authRes","authResParsed","authErr","error_description"],"sourceRoot":"../../../../src","sources":["credential/issuance/04-complete-user-authorization.ts"],"mappings":"AAAA,SACEA,uBAAuB,EACvBC,wBAAwB,QAEnB,kBAAkB;AACzB,SAASC,gBAAgB,QAAkB,kBAAkB;AAE7D,OAAOC,QAAQ,MAAM,WAAW;AAChC,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,oBAAoB;AAE1E,SACEC,MAAM,EACNC,YAAY,EACZC,OAAO,QAEF,6BAA6B;AACpC,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,sBAAsB,QAAQ,SAAS;AAChD,SAASC,kBAAkB,QAAQ,qBAAqB;AACxD,SAASC,kBAAkB,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ACRlB,QAAQ,CAACuC,KAAK,EACb,2CAA0C+B,IAAI,CAACC,SAAS,CAACiB,OAAO,CAAE,EACrE,CAAC;IACD,MAAM,IAAIzF,qBAAqB,CAC7ByF,OAAO,CAAC7C,IAAI,CAACH,KAAK,EAClBgD,OAAO,CAAC7C,IAAI,CAAC8C,iBACf,CAAC;EACH;EACA,OAAOF,aAAa,CAAC5C,IAAI;AAC3B,CAAC"}
|
@@ -1,16 +1,18 @@
|
|
1
1
|
import { hasStatusOrThrow } from "../../utils/misc";
|
2
2
|
import { createDPopToken } from "../../utils/dpop";
|
3
|
-
import
|
3
|
+
import { v4 as uuidv4 } from "uuid";
|
4
4
|
import { createPopToken } from "../../utils/pop";
|
5
5
|
import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
|
6
|
+
import { ASSERTION_TYPE } from "./const";
|
6
7
|
import { TokenResponse } from "./types";
|
7
8
|
import { IssuerResponseError, ValidationFailed } from "../../utils/errors";
|
9
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
8
10
|
/**
|
9
11
|
* Creates and sends the DPoP Proof JWT to be presented with the authorization code to the /token endpoint of the authorization server
|
10
12
|
* for requesting the issuance of an access token bound to the public key of the Wallet Instance contained within the DPoP.
|
11
13
|
* This enables the Wallet Instance to request a digital credential.
|
12
14
|
* The DPoP Proof JWT is generated according to the section 4.3 of the DPoP RFC 9449 specification.
|
13
|
-
* @param issuerConf The issuer configuration returned by {@link
|
15
|
+
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
14
16
|
* @param code The authorization code returned by {@link completeUserAuthorizationWithQueryMode} or {@link completeUserAuthorizationWithFormPost}
|
15
17
|
* @param redirectUri The redirect URI which is the custom URL scheme that the Wallet Instance is registered to handle
|
16
18
|
* @param clientId The client id returned by {@link startUserAuthorization}
|
@@ -30,40 +32,44 @@ export const authorizeAccess = async (issuerConf, code, clientId, redirectUri, c
|
|
30
32
|
wiaCryptoContext,
|
31
33
|
dPopCryptoContext
|
32
34
|
} = context;
|
33
|
-
const parEndpoint = issuerConf.pushed_authorization_request_endpoint;
|
35
|
+
const parEndpoint = issuerConf.oauth_authorization_server.pushed_authorization_request_endpoint;
|
34
36
|
const parUrl = new URL(parEndpoint);
|
35
37
|
const aud = `${parUrl.protocol}//${parUrl.hostname}`;
|
36
38
|
const iss = WalletInstanceAttestation.decode(walletInstanceAttestation).payload.cnf.jwk.kid;
|
37
|
-
const tokenUrl = issuerConf.token_endpoint;
|
39
|
+
const tokenUrl = issuerConf.oauth_authorization_server.token_endpoint;
|
38
40
|
const tokenRequestSignedDPop = await createDPopToken({
|
39
41
|
htm: "POST",
|
40
42
|
htu: tokenUrl,
|
41
|
-
jti: `${
|
43
|
+
jti: `${uuidv4()}`
|
42
44
|
}, dPopCryptoContext);
|
45
|
+
Logger.log(LogLevel.DEBUG, `Token request DPoP: ${tokenRequestSignedDPop}`);
|
43
46
|
const signedWiaPoP = await createPopToken({
|
44
|
-
jti: `${
|
47
|
+
jti: `${uuidv4()}`,
|
45
48
|
aud,
|
46
49
|
iss
|
47
50
|
}, wiaCryptoContext);
|
51
|
+
Logger.log(LogLevel.DEBUG, `WIA DPoP token: ${signedWiaPoP}`);
|
48
52
|
const requestBody = {
|
49
|
-
client_id: clientId,
|
50
53
|
grant_type: "authorization_code",
|
54
|
+
client_id: clientId,
|
51
55
|
code,
|
52
56
|
redirect_uri: redirectUri,
|
53
|
-
code_verifier: codeVerifier
|
57
|
+
code_verifier: codeVerifier,
|
58
|
+
client_assertion_type: ASSERTION_TYPE,
|
59
|
+
client_assertion: walletInstanceAttestation + "~" + signedWiaPoP
|
54
60
|
};
|
55
61
|
const authorizationRequestFormBody = new URLSearchParams(requestBody);
|
62
|
+
Logger.log(LogLevel.DEBUG, `Auth form request body: ${authorizationRequestFormBody}`);
|
56
63
|
const tokenRes = await appFetch(tokenUrl, {
|
57
64
|
method: "POST",
|
58
65
|
headers: {
|
59
66
|
"Content-Type": "application/x-www-form-urlencoded",
|
60
|
-
DPoP: tokenRequestSignedDPop
|
61
|
-
"OAuth-Client-Attestation": walletInstanceAttestation,
|
62
|
-
"OAuth-Client-Attestation-PoP": signedWiaPoP
|
67
|
+
DPoP: tokenRequestSignedDPop
|
63
68
|
},
|
64
69
|
body: authorizationRequestFormBody.toString()
|
65
70
|
}).then(hasStatusOrThrow(200, IssuerResponseError)).then(res => res.json()).then(body => TokenResponse.safeParse(body));
|
66
71
|
if (!tokenRes.success) {
|
72
|
+
Logger.log(LogLevel.ERROR, `Token Response validation failed: ${tokenRes.error.message}`);
|
67
73
|
throw new ValidationFailed({
|
68
74
|
message: "Token Response validation failed",
|
69
75
|
reason: tokenRes.error.message
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["hasStatusOrThrow","createDPopToken","
|
1
|
+
{"version":3,"names":["hasStatusOrThrow","createDPopToken","v4","uuidv4","createPopToken","WalletInstanceAttestation","ASSERTION_TYPE","TokenResponse","IssuerResponseError","ValidationFailed","LogLevel","Logger","authorizeAccess","issuerConf","code","clientId","redirectUri","codeVerifier","context","appFetch","fetch","walletInstanceAttestation","wiaCryptoContext","dPopCryptoContext","parEndpoint","oauth_authorization_server","pushed_authorization_request_endpoint","parUrl","URL","aud","protocol","hostname","iss","decode","payload","cnf","jwk","kid","tokenUrl","token_endpoint","tokenRequestSignedDPop","htm","htu","jti","log","DEBUG","signedWiaPoP","requestBody","grant_type","client_id","redirect_uri","code_verifier","client_assertion_type","client_assertion","authorizationRequestFormBody","URLSearchParams","tokenRes","method","headers","DPoP","body","toString","then","res","json","safeParse","success","ERROR","error","message","reason","accessToken","data"],"sourceRoot":"../../../../src","sources":["credential/issuance/05-authorize-access.ts"],"mappings":"AAAA,SAASA,gBAAgB,QAAkB,kBAAkB;AAG7D,SAASC,eAAe,QAAQ,kBAAkB;AAClD,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,cAAc,QAAQ,iBAAiB;AAChD,OAAO,KAAKC,yBAAyB,MAAM,mCAAmC;AAE9E,SA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,CAACC;IACzB,CAAC,CAAC;EACJ;EAEA,OAAO;IAAEE,WAAW,EAAEf,QAAQ,CAACgB;EAAK,CAAC;AACvC,CAAC"}
|
@@ -3,7 +3,8 @@ import { hasStatusOrThrow } from "../../utils/misc";
|
|
3
3
|
import { IssuerResponseError, IssuerResponseErrorCodes, ResponseErrorBuilder, UnexpectedStatusCodeError, ValidationFailed } from "../../utils/errors";
|
4
4
|
import { CredentialResponse } from "./types";
|
5
5
|
import { createDPopToken } from "../../utils/dpop";
|
6
|
-
import
|
6
|
+
import { v4 as uuidv4 } from "uuid";
|
7
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
7
8
|
export const createNonceProof = async (nonce, issuer, audience, ctx) => {
|
8
9
|
const jwk = await ctx.getPublicKey();
|
9
10
|
return new SignJWT(ctx).setPayload({
|
@@ -20,7 +21,7 @@ export const createNonceProof = async (nonce, issuer, audience, ctx) => {
|
|
20
21
|
* of the Credential Issuer to request the issuance of a credential linked to the public key contained in the JWT proof.
|
21
22
|
* The Openid4vci proof JWT incapsulates the nonce extracted from the token response from the {@link authorizeAccess} step.
|
22
23
|
* The credential request is sent to the Credential Endpoint of the Credential Issuer via HTTP POST with the type of the credential, its format, the access token and the JWT proof.
|
23
|
-
* @param issuerConf The issuer configuration returned by {@link
|
24
|
+
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
24
25
|
* @param accessToken The access token response returned by {@link authorizeAccess}
|
25
26
|
* @param clientId The client id returned by {@link startUserAuthorization}
|
26
27
|
* @param credentialDefinition The credential definition of the credential to be obtained returned by {@link startUserAuthorization}
|
@@ -30,13 +31,13 @@ export const createNonceProof = async (nonce, issuer, audience, ctx) => {
|
|
30
31
|
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
31
32
|
* @returns The credential response containing the credential
|
32
33
|
*/
|
33
|
-
export const obtainCredential = async (issuerConf, accessToken, clientId, credentialDefinition, context) => {
|
34
|
+
export const obtainCredential = async (issuerConf, accessToken, clientId, credentialDefinition, context, operationType) => {
|
34
35
|
const {
|
35
36
|
credentialCryptoContext,
|
36
37
|
appFetch = fetch,
|
37
38
|
dPopCryptoContext
|
38
39
|
} = context;
|
39
|
-
const credentialUrl = issuerConf.credential_endpoint;
|
40
|
+
const credentialUrl = issuerConf.openid_credential_issuer.credential_endpoint;
|
40
41
|
|
41
42
|
/**
|
42
43
|
* JWT proof token to bind the request nonce to the key that will bind the holder User with the Credential
|
@@ -44,61 +45,56 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
|
|
44
45
|
* @see https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-proof-types
|
45
46
|
*/
|
46
47
|
const signedNonceProof = await createNonceProof(accessToken.c_nonce, clientId, credentialUrl, credentialCryptoContext);
|
47
|
-
|
48
|
+
Logger.log(LogLevel.DEBUG, `Signed nonce proof: ${signedNonceProof}`);
|
49
|
+
|
50
|
+
// Validation of accessTokenResponse.authorization_details if contain credentialDefinition
|
51
|
+
const containsCredentialDefinition = accessToken.authorization_details.some(c => c.credential_configuration_id === credentialDefinition.credential_configuration_id && c.format === credentialDefinition.format && c.type === credentialDefinition.type);
|
48
52
|
if (!containsCredentialDefinition) {
|
53
|
+
Logger.log(LogLevel.ERROR, `Credential definition not found in the access token response ${accessToken.authorization_details}`);
|
49
54
|
throw new ValidationFailed({
|
50
55
|
message: "The access token response does not contain the requested credential"
|
51
56
|
});
|
52
57
|
}
|
53
|
-
const credential = issuerConf.credential_configurations_supported[credentialDefinition.credential_configuration_id];
|
54
|
-
if (!credential) {
|
55
|
-
throw new ValidationFailed({
|
56
|
-
message: "The credential configuration is not supported by the issuer"
|
57
|
-
});
|
58
|
-
}
|
59
|
-
const format = credential.format;
|
60
|
-
if (!format) {
|
61
|
-
throw new ValidationFailed({
|
62
|
-
message: "The credential doesn't contain the format required by the issuer"
|
63
|
-
});
|
64
|
-
}
|
65
58
|
|
66
59
|
/** The credential request body */
|
67
60
|
const credentialRequestFormBody = {
|
68
|
-
|
69
|
-
|
70
|
-
}
|
71
|
-
|
72
|
-
}),
|
73
|
-
format,
|
61
|
+
credential_definition: {
|
62
|
+
type: [credentialDefinition.credential_configuration_id]
|
63
|
+
},
|
64
|
+
format: credentialDefinition.format,
|
74
65
|
proof: {
|
75
66
|
jwt: signedNonceProof,
|
76
67
|
proof_type: "jwt"
|
77
68
|
}
|
78
69
|
};
|
70
|
+
Logger.log(LogLevel.DEBUG, `Credential request body: ${JSON.stringify(credentialRequestFormBody)}`);
|
79
71
|
const tokenRequestSignedDPop = await createDPopToken({
|
80
72
|
htm: "POST",
|
81
73
|
htu: credentialUrl,
|
82
|
-
jti: `${
|
74
|
+
jti: `${uuidv4()}`,
|
83
75
|
ath: await sha256ToBase64(accessToken.access_token)
|
84
76
|
}, dPopCryptoContext);
|
77
|
+
Logger.log(LogLevel.DEBUG, `Token request DPoP: ${tokenRequestSignedDPop}`);
|
85
78
|
const credentialRes = await appFetch(credentialUrl, {
|
86
79
|
method: "POST",
|
87
80
|
headers: {
|
88
81
|
"Content-Type": "application/json",
|
89
82
|
DPoP: tokenRequestSignedDPop,
|
90
|
-
Authorization: `${accessToken.token_type} ${accessToken.access_token}
|
83
|
+
Authorization: `${accessToken.token_type} ${accessToken.access_token}`,
|
84
|
+
...(operationType === "reissuing" && {
|
85
|
+
operationType
|
86
|
+
})
|
91
87
|
},
|
92
88
|
body: JSON.stringify(credentialRequestFormBody)
|
93
89
|
}).then(hasStatusOrThrow(200)).then(res => res.json()).then(body => CredentialResponse.safeParse(body)).catch(handleObtainCredentialError);
|
94
90
|
if (!credentialRes.success) {
|
91
|
+
Logger.log(LogLevel.ERROR, `Credential Response validation failed: ${credentialRes.error.message}`);
|
95
92
|
throw new ValidationFailed({
|
96
93
|
message: "Credential Response validation failed",
|
97
94
|
reason: credentialRes.error.message
|
98
95
|
});
|
99
96
|
}
|
100
|
-
|
101
|
-
/* temporary base64 parsing for the "mso_mdoc" format until the credential submission with this format is fixed. */
|
97
|
+
Logger.log(LogLevel.DEBUG, `Credential Response: ${JSON.stringify(credentialRes.data)}`);
|
102
98
|
return credentialRes.data;
|
103
99
|
};
|
104
100
|
|
@@ -109,10 +105,22 @@ export const obtainCredential = async (issuerConf, accessToken, clientId, creden
|
|
109
105
|
* @throws {IssuerResponseError} with a specific code for more context
|
110
106
|
*/
|
111
107
|
const handleObtainCredentialError = e => {
|
108
|
+
Logger.log(LogLevel.ERROR, `Error occurred while obtaining credential: ${e}`);
|
112
109
|
if (!(e instanceof UnexpectedStatusCodeError)) {
|
113
110
|
throw e;
|
114
111
|
}
|
115
|
-
throw new ResponseErrorBuilder(IssuerResponseError).handle(
|
112
|
+
throw new ResponseErrorBuilder(IssuerResponseError).handle(201, {
|
113
|
+
// Although it is technically not an error, we handle it as such to avoid
|
114
|
+
// changing the return type of `obtainCredential` and introduce a breaking change.
|
115
|
+
code: IssuerResponseErrorCodes.CredentialIssuingNotSynchronous,
|
116
|
+
message: "This credential cannot be issued synchronously. It will be available at a later time."
|
117
|
+
}).handle(403, {
|
118
|
+
code: IssuerResponseErrorCodes.CredentialInvalidStatus,
|
119
|
+
message: "Invalid status found for the given credential"
|
120
|
+
}).handle(404, {
|
121
|
+
code: IssuerResponseErrorCodes.CredentialInvalidStatus,
|
122
|
+
message: "Invalid status found for the given credential"
|
123
|
+
}).handle("*", {
|
116
124
|
code: IssuerResponseErrorCodes.CredentialRequestFailed,
|
117
125
|
message: "Unable to obtain the requested credential"
|
118
126
|
}).buildFrom(e);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["sha256ToBase64","SignJWT","hasStatusOrThrow","IssuerResponseError","IssuerResponseErrorCodes","ResponseErrorBuilder","UnexpectedStatusCodeError","ValidationFailed","CredentialResponse","createDPopToken","
|
1
|
+
{"version":3,"names":["sha256ToBase64","SignJWT","hasStatusOrThrow","IssuerResponseError","IssuerResponseErrorCodes","ResponseErrorBuilder","UnexpectedStatusCodeError","ValidationFailed","CredentialResponse","createDPopToken","v4","uuidv4","LogLevel","Logger","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","obtainCredential","issuerConf","accessToken","clientId","credentialDefinition","context","operationType","credentialCryptoContext","appFetch","fetch","dPopCryptoContext","credentialUrl","openid_credential_issuer","credential_endpoint","signedNonceProof","c_nonce","log","DEBUG","containsCredentialDefinition","authorization_details","some","c","credential_configuration_id","format","type","ERROR","message","credentialRequestFormBody","credential_definition","proof","jwt","proof_type","JSON","stringify","tokenRequestSignedDPop","htm","htu","jti","ath","access_token","credentialRes","method","headers","DPoP","Authorization","token_type","body","then","res","json","safeParse","catch","handleObtainCredentialError","success","error","reason","data","e","handle","code","CredentialIssuingNotSynchronous","CredentialInvalidStatus","CredentialRequestFailed","buildFrom"],"sourceRoot":"../../../../src","sources":["credential/issuance/06-obtain-credential.ts"],"mappings":"AAAA,SAEEA,cAAc,EACdC,OAAO,QACF,6BAA6B;AAGpC,SAASC,gBAAgB,QAAkB,kBAAkB;AAE7D,SACEC,mBAAmB,EACnBC,wBAAwB,EACxBC,oBAAoB,EACpBC,yBAAyB,EACzBC,gBAAgB,QACX,oBAAoB;AAC3B,SAASC,kBAAkB,QAAQ,SAAS;AAC5C,SAASC,eAAe,QAAQ,kBAAkB;AAClD,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,QAAQ,EAAEC,MAAM,QAAQ,qBAAqB;AAetD,OAAO,MAAMC,gBAAgB,GAAG,MAAAA,CAC9BC,KAAa,EACbC,MAAc,EACdC,QAAgB,EAChBC,GAAkB,KACE;EACpB,MAAMC,GAAG,GAAG,MAAMD,GAAG,CAACE,YAAY,CAAC,CAAC;EACpC,OAAO,IAAInB,OAAO,CAACiB,GAAG,CAAC,CACpBG,UAAU,CAAC;IACVN;EACF,CAAC,CAAC,CACDO,kBAAkB,CAAC;IAClBC,GAAG,EAAE,sBAAsB;IAC3BJ;EACF,CAAC,CAAC,CACDK,WAAW,CAAC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