@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
@@ -6,20 +6,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.authorizeAccess = void 0;
|
7
7
|
var _misc = require("../../utils/misc");
|
8
8
|
var _dpop = require("../../utils/dpop");
|
9
|
-
var
|
9
|
+
var _uuid = require("uuid");
|
10
10
|
var _pop = require("../../utils/pop");
|
11
11
|
var WalletInstanceAttestation = _interopRequireWildcard(require("../../wallet-instance-attestation"));
|
12
|
+
var _const = require("./const");
|
12
13
|
var _types = require("./types");
|
13
14
|
var _errors = require("../../utils/errors");
|
15
|
+
var _logging = require("../../utils/logging");
|
14
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
15
17
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
18
|
/**
|
18
19
|
* Creates and sends the DPoP Proof JWT to be presented with the authorization code to the /token endpoint of the authorization server
|
19
20
|
* for requesting the issuance of an access token bound to the public key of the Wallet Instance contained within the DPoP.
|
20
21
|
* This enables the Wallet Instance to request a digital credential.
|
21
22
|
* The DPoP Proof JWT is generated according to the section 4.3 of the DPoP RFC 9449 specification.
|
22
|
-
* @param issuerConf The issuer configuration returned by {@link
|
23
|
+
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
23
24
|
* @param code The authorization code returned by {@link completeUserAuthorizationWithQueryMode} or {@link completeUserAuthorizationWithFormPost}
|
24
25
|
* @param redirectUri The redirect URI which is the custom URL scheme that the Wallet Instance is registered to handle
|
25
26
|
* @param clientId The client id returned by {@link startUserAuthorization}
|
@@ -39,40 +40,44 @@ const authorizeAccess = async (issuerConf, code, clientId, redirectUri, codeVeri
|
|
39
40
|
wiaCryptoContext,
|
40
41
|
dPopCryptoContext
|
41
42
|
} = context;
|
42
|
-
const parEndpoint = issuerConf.pushed_authorization_request_endpoint;
|
43
|
+
const parEndpoint = issuerConf.oauth_authorization_server.pushed_authorization_request_endpoint;
|
43
44
|
const parUrl = new URL(parEndpoint);
|
44
45
|
const aud = `${parUrl.protocol}//${parUrl.hostname}`;
|
45
46
|
const iss = WalletInstanceAttestation.decode(walletInstanceAttestation).payload.cnf.jwk.kid;
|
46
|
-
const tokenUrl = issuerConf.token_endpoint;
|
47
|
+
const tokenUrl = issuerConf.oauth_authorization_server.token_endpoint;
|
47
48
|
const tokenRequestSignedDPop = await (0, _dpop.createDPopToken)({
|
48
49
|
htm: "POST",
|
49
50
|
htu: tokenUrl,
|
50
|
-
jti: `${
|
51
|
+
jti: `${(0, _uuid.v4)()}`
|
51
52
|
}, dPopCryptoContext);
|
53
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Token request DPoP: ${tokenRequestSignedDPop}`);
|
52
54
|
const signedWiaPoP = await (0, _pop.createPopToken)({
|
53
|
-
jti: `${
|
55
|
+
jti: `${(0, _uuid.v4)()}`,
|
54
56
|
aud,
|
55
57
|
iss
|
56
58
|
}, wiaCryptoContext);
|
59
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `WIA DPoP token: ${signedWiaPoP}`);
|
57
60
|
const requestBody = {
|
58
|
-
client_id: clientId,
|
59
61
|
grant_type: "authorization_code",
|
62
|
+
client_id: clientId,
|
60
63
|
code,
|
61
64
|
redirect_uri: redirectUri,
|
62
|
-
code_verifier: codeVerifier
|
65
|
+
code_verifier: codeVerifier,
|
66
|
+
client_assertion_type: _const.ASSERTION_TYPE,
|
67
|
+
client_assertion: walletInstanceAttestation + "~" + signedWiaPoP
|
63
68
|
};
|
64
69
|
const authorizationRequestFormBody = new URLSearchParams(requestBody);
|
70
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Auth form request body: ${authorizationRequestFormBody}`);
|
65
71
|
const tokenRes = await appFetch(tokenUrl, {
|
66
72
|
method: "POST",
|
67
73
|
headers: {
|
68
74
|
"Content-Type": "application/x-www-form-urlencoded",
|
69
|
-
DPoP: tokenRequestSignedDPop
|
70
|
-
"OAuth-Client-Attestation": walletInstanceAttestation,
|
71
|
-
"OAuth-Client-Attestation-PoP": signedWiaPoP
|
75
|
+
DPoP: tokenRequestSignedDPop
|
72
76
|
},
|
73
77
|
body: authorizationRequestFormBody.toString()
|
74
78
|
}).then((0, _misc.hasStatusOrThrow)(200, _errors.IssuerResponseError)).then(res => res.json()).then(body => _types.TokenResponse.safeParse(body));
|
75
79
|
if (!tokenRes.success) {
|
80
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Token Response validation failed: ${tokenRes.error.message}`);
|
76
81
|
throw new _errors.ValidationFailed({
|
77
82
|
message: "Token Response validation failed",
|
78
83
|
reason: tokenRes.error.message
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_misc","require","_dpop","
|
1
|
+
{"version":3,"names":["_misc","require","_dpop","_uuid","_pop","WalletInstanceAttestation","_interopRequireWildcard","_const","_types","_errors","_logging","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","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","createDPopToken","htm","htu","jti","uuidv4","Logger","log","LogLevel","DEBUG","signedWiaPoP","createPopToken","requestBody","grant_type","client_id","redirect_uri","code_verifier","client_assertion_type","ASSERTION_TYPE","client_assertion","authorizationRequestFormBody","URLSearchParams","tokenRes","method","headers","DPoP","body","toString","then","hasStatusOrThrow","IssuerResponseError","res","json","TokenResponse","safeParse","success","ERROR","error","message","ValidationFailed","reason","accessToken","data","exports"],"sourceRoot":"../../../../src","sources":["credential/issuance/05-authorize-access.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAGA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,yBAAA,GAAAC,uBAAA,CAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AAEA,IAAAS,QAAA,GAAAT,OAAA;AAAuD,SAAAU,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAN,wBAAAU,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,q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AC,CAAC,CAChDF,IAAI,CAAEG,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBJ,IAAI,CAAEF,IAAI,IAAKO,oBAAa,CAACC,SAAS,CAACR,IAAI,CAAC,CAAC;EAEhD,IAAI,CAACJ,QAAQ,CAACa,OAAO,EAAE;IACrB7B,eAAM,CAACC,GAAG,CACRC,iBAAQ,CAAC4B,KAAK,EACb,qCAAoCd,QAAQ,CAACe,KAAK,CAACC,OAAQ,EAC9D,CAAC;IAED,MAAM,IAAIC,wBAAgB,CAAC;MACzBD,OAAO,EAAE,kCAAkC;MAC3CE,MAAM,EAAElB,QAAQ,CAACe,KAAK,CAACC;IACzB,CAAC,CAAC;EACJ;EAEA,OAAO;IAAEG,WAAW,EAAEnB,QAAQ,CAACoB;EAAK,CAAC;AACvC,CAAC;AAACC,OAAA,CAAAvE,eAAA,GAAAA,eAAA"}
|
@@ -9,8 +9,8 @@ var _misc = require("../../utils/misc");
|
|
9
9
|
var _errors = require("../../utils/errors");
|
10
10
|
var _types = require("./types");
|
11
11
|
var _dpop = require("../../utils/dpop");
|
12
|
-
var
|
13
|
-
|
12
|
+
var _uuid = require("uuid");
|
13
|
+
var _logging = require("../../utils/logging");
|
14
14
|
const createNonceProof = async (nonce, issuer, audience, ctx) => {
|
15
15
|
const jwk = await ctx.getPublicKey();
|
16
16
|
return new _ioReactNativeJwt.SignJWT(ctx).setPayload({
|
@@ -27,7 +27,7 @@ const createNonceProof = async (nonce, issuer, audience, ctx) => {
|
|
27
27
|
* of the Credential Issuer to request the issuance of a credential linked to the public key contained in the JWT proof.
|
28
28
|
* The Openid4vci proof JWT incapsulates the nonce extracted from the token response from the {@link authorizeAccess} step.
|
29
29
|
* 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.
|
30
|
-
* @param issuerConf The issuer configuration returned by {@link
|
30
|
+
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
31
31
|
* @param accessToken The access token response returned by {@link authorizeAccess}
|
32
32
|
* @param clientId The client id returned by {@link startUserAuthorization}
|
33
33
|
* @param credentialDefinition The credential definition of the credential to be obtained returned by {@link startUserAuthorization}
|
@@ -38,13 +38,13 @@ const createNonceProof = async (nonce, issuer, audience, ctx) => {
|
|
38
38
|
* @returns The credential response containing the credential
|
39
39
|
*/
|
40
40
|
exports.createNonceProof = createNonceProof;
|
41
|
-
const obtainCredential = async (issuerConf, accessToken, clientId, credentialDefinition, context) => {
|
41
|
+
const obtainCredential = async (issuerConf, accessToken, clientId, credentialDefinition, context, operationType) => {
|
42
42
|
const {
|
43
43
|
credentialCryptoContext,
|
44
44
|
appFetch = fetch,
|
45
45
|
dPopCryptoContext
|
46
46
|
} = context;
|
47
|
-
const credentialUrl = issuerConf.credential_endpoint;
|
47
|
+
const credentialUrl = issuerConf.openid_credential_issuer.credential_endpoint;
|
48
48
|
|
49
49
|
/**
|
50
50
|
* JWT proof token to bind the request nonce to the key that will bind the holder User with the Credential
|
@@ -52,61 +52,56 @@ const obtainCredential = async (issuerConf, accessToken, clientId, credentialDef
|
|
52
52
|
* @see https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-proof-types
|
53
53
|
*/
|
54
54
|
const signedNonceProof = await createNonceProof(accessToken.c_nonce, clientId, credentialUrl, credentialCryptoContext);
|
55
|
-
|
55
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Signed nonce proof: ${signedNonceProof}`);
|
56
|
+
|
57
|
+
// Validation of accessTokenResponse.authorization_details if contain credentialDefinition
|
58
|
+
const containsCredentialDefinition = accessToken.authorization_details.some(c => c.credential_configuration_id === credentialDefinition.credential_configuration_id && c.format === credentialDefinition.format && c.type === credentialDefinition.type);
|
56
59
|
if (!containsCredentialDefinition) {
|
60
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Credential definition not found in the access token response ${accessToken.authorization_details}`);
|
57
61
|
throw new _errors.ValidationFailed({
|
58
62
|
message: "The access token response does not contain the requested credential"
|
59
63
|
});
|
60
64
|
}
|
61
|
-
const credential = issuerConf.credential_configurations_supported[credentialDefinition.credential_configuration_id];
|
62
|
-
if (!credential) {
|
63
|
-
throw new _errors.ValidationFailed({
|
64
|
-
message: "The credential configuration is not supported by the issuer"
|
65
|
-
});
|
66
|
-
}
|
67
|
-
const format = credential.format;
|
68
|
-
if (!format) {
|
69
|
-
throw new _errors.ValidationFailed({
|
70
|
-
message: "The credential doesn't contain the format required by the issuer"
|
71
|
-
});
|
72
|
-
}
|
73
65
|
|
74
66
|
/** The credential request body */
|
75
67
|
const credentialRequestFormBody = {
|
76
|
-
|
77
|
-
|
78
|
-
}
|
79
|
-
|
80
|
-
}),
|
81
|
-
format,
|
68
|
+
credential_definition: {
|
69
|
+
type: [credentialDefinition.credential_configuration_id]
|
70
|
+
},
|
71
|
+
format: credentialDefinition.format,
|
82
72
|
proof: {
|
83
73
|
jwt: signedNonceProof,
|
84
74
|
proof_type: "jwt"
|
85
75
|
}
|
86
76
|
};
|
77
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Credential request body: ${JSON.stringify(credentialRequestFormBody)}`);
|
87
78
|
const tokenRequestSignedDPop = await (0, _dpop.createDPopToken)({
|
88
79
|
htm: "POST",
|
89
80
|
htu: credentialUrl,
|
90
|
-
jti: `${
|
81
|
+
jti: `${(0, _uuid.v4)()}`,
|
91
82
|
ath: await (0, _ioReactNativeJwt.sha256ToBase64)(accessToken.access_token)
|
92
83
|
}, dPopCryptoContext);
|
84
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Token request DPoP: ${tokenRequestSignedDPop}`);
|
93
85
|
const credentialRes = await appFetch(credentialUrl, {
|
94
86
|
method: "POST",
|
95
87
|
headers: {
|
96
88
|
"Content-Type": "application/json",
|
97
89
|
DPoP: tokenRequestSignedDPop,
|
98
|
-
Authorization: `${accessToken.token_type} ${accessToken.access_token}
|
90
|
+
Authorization: `${accessToken.token_type} ${accessToken.access_token}`,
|
91
|
+
...(operationType === "reissuing" && {
|
92
|
+
operationType
|
93
|
+
})
|
99
94
|
},
|
100
95
|
body: JSON.stringify(credentialRequestFormBody)
|
101
96
|
}).then((0, _misc.hasStatusOrThrow)(200)).then(res => res.json()).then(body => _types.CredentialResponse.safeParse(body)).catch(handleObtainCredentialError);
|
102
97
|
if (!credentialRes.success) {
|
98
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Credential Response validation failed: ${credentialRes.error.message}`);
|
103
99
|
throw new _errors.ValidationFailed({
|
104
100
|
message: "Credential Response validation failed",
|
105
101
|
reason: credentialRes.error.message
|
106
102
|
});
|
107
103
|
}
|
108
|
-
|
109
|
-
/* temporary base64 parsing for the "mso_mdoc" format until the credential submission with this format is fixed. */
|
104
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Credential Response: ${JSON.stringify(credentialRes.data)}`);
|
110
105
|
return credentialRes.data;
|
111
106
|
};
|
112
107
|
|
@@ -118,10 +113,22 @@ const obtainCredential = async (issuerConf, accessToken, clientId, credentialDef
|
|
118
113
|
*/
|
119
114
|
exports.obtainCredential = obtainCredential;
|
120
115
|
const handleObtainCredentialError = e => {
|
116
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Error occurred while obtaining credential: ${e}`);
|
121
117
|
if (!(e instanceof _errors.UnexpectedStatusCodeError)) {
|
122
118
|
throw e;
|
123
119
|
}
|
124
|
-
throw new _errors.ResponseErrorBuilder(_errors.IssuerResponseError).handle(
|
120
|
+
throw new _errors.ResponseErrorBuilder(_errors.IssuerResponseError).handle(201, {
|
121
|
+
// Although it is technically not an error, we handle it as such to avoid
|
122
|
+
// changing the return type of `obtainCredential` and introduce a breaking change.
|
123
|
+
code: _errors.IssuerResponseErrorCodes.CredentialIssuingNotSynchronous,
|
124
|
+
message: "This credential cannot be issued synchronously. It will be available at a later time."
|
125
|
+
}).handle(403, {
|
126
|
+
code: _errors.IssuerResponseErrorCodes.CredentialInvalidStatus,
|
127
|
+
message: "Invalid status found for the given credential"
|
128
|
+
}).handle(404, {
|
129
|
+
code: _errors.IssuerResponseErrorCodes.CredentialInvalidStatus,
|
130
|
+
message: "Invalid status found for the given credential"
|
131
|
+
}).handle("*", {
|
125
132
|
code: _errors.IssuerResponseErrorCodes.CredentialRequestFailed,
|
126
133
|
message: "Unable to obtain the requested credential"
|
127
134
|
}).buildFrom(e);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_ioReactNativeJwt","require","_misc","_errors","_types","_dpop","
|
1
|
+
{"version":3,"names":["_ioReactNativeJwt","require","_misc","_errors","_types","_dpop","_uuid","_logging","createNonceProof","nonce","issuer","audience","ctx","jwk","getPublicKey","SignJWT","setPayload","setProtectedHeader","typ","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","exports","obtainCredential","issuerConf","accessToken","clientId","credentialDefinition","context","operationType","credentialCryptoContext","appFetch","fetch","dPopCryptoContext","credentialUrl","openid_credential_issuer","credential_endpoint","signedNonceProof","c_nonce","Logger","log","LogLevel","DEBUG","containsCredentialDefinition","authorization_details","some","c","credential_configuration_id","format","type","ERROR","ValidationFailed","message","credentialRequestFormBody","credential_definition","proof","jwt","proof_type","JSON","stringify","tokenRequestSignedDPop","createDPopToken","htm","htu","jti","uuidv4","ath","sha256ToBase64","access_token","credentialRes","method","headers","DPoP","Authorization","token_type","body","then","hasStatusOrThrow","res","json","CredentialResponse","safeParse","catch","handleObtainCredentialError","success","error","reason","data","e","UnexpectedStatusCodeError","ResponseErrorBuilder","IssuerResponseError","handle","code","IssuerResponseErrorCodes","CredentialIssuingNotSynchronous","CredentialInvalidStatus","CredentialRequestFailed","buildFrom"],"sourceRoot":"../../../../src","sources":["credential/issuance/06-obtain-credential.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAOA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAOA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAA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AAC;EACT;EAEA,MAAM,IAAIE,4BAAoB,CAACC,2BAAmB,CAAC,CAChDC,MAAM,CAAC,GAAG,EAAE;IACX;IACA;IACAC,IAAI,EAAEC,gCAAwB,CAACC,+BAA+B;IAC9D3C,OAAO,EACL;EACJ,CAAC,CAAC,CACDwC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,gCAAwB,CAACE,uBAAuB;IACtD5C,OAAO,EAAE;EACX,CAAC,CAAC,CACDwC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,gCAAwB,CAACE,uBAAuB;IACtD5C,OAAO,EAAE;EACX,CAAC,CAAC,CACDwC,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,gCAAwB,CAACG,uBAAuB;IACtD7C,OAAO,EAAE;EACX,CAAC,CAAC,CACD8C,SAAS,CAACV,CAAC,CAAC;AACjB,CAAC"}
|
@@ -3,18 +3,16 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.verifyAndParseCredential =
|
6
|
+
exports.verifyAndParseCredential = void 0;
|
7
7
|
var _errors = require("../../utils/errors");
|
8
8
|
var _types = require("../../sd-jwt/types");
|
9
9
|
var _sdJwt = require("../../sd-jwt");
|
10
|
-
var _mdoc = require("../../mdoc");
|
11
10
|
var _converters = require("../../sd-jwt/converters");
|
12
|
-
var
|
11
|
+
var _logging = require("../../utils/logging");
|
13
12
|
// The credential as a collection of attributes in plain value
|
14
13
|
|
15
14
|
// handy alias
|
16
15
|
|
17
|
-
//Exported for testing purposes
|
18
16
|
const parseCredentialSdJwt = function (credentials_supported, _ref) {
|
19
17
|
let {
|
20
18
|
sdJwt,
|
@@ -24,32 +22,35 @@ const parseCredentialSdJwt = function (credentials_supported, _ref) {
|
|
24
22
|
let includeUndefinedAttributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
25
23
|
const credentialSubject = credentials_supported[sdJwt.payload.vct];
|
26
24
|
if (!credentialSubject) {
|
25
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Credential type not supported by the issuer: ${sdJwt.payload.vct}`);
|
27
26
|
throw new _errors.IoWalletError("Credential type not supported by the issuer");
|
28
27
|
}
|
29
28
|
if (credentialSubject.format !== sdJwt.header.typ) {
|
29
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}'`);
|
30
30
|
throw new _errors.IoWalletError(`Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}', `);
|
31
31
|
}
|
32
32
|
|
33
33
|
// transfrom a record { key: value } in an iterable of pairs [key, value]
|
34
34
|
if (!credentialSubject.claims) {
|
35
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, "Missing claims in the credential subject");
|
35
36
|
throw new _errors.IoWalletError("Missing claims in the credential subject"); // TODO [SIW-1268]: should not be optional
|
36
37
|
}
|
37
38
|
|
38
|
-
const
|
39
|
-
const attrDefinitions = Object.entries(claims);
|
39
|
+
const attrDefinitions = Object.entries(credentialSubject.claims);
|
40
40
|
|
41
41
|
// the key of the attribute defintion must match the disclosure's name
|
42
42
|
const attrsNotInDisclosures = attrDefinitions.filter(_ref2 => {
|
43
|
-
let [attrKey
|
43
|
+
let [attrKey] = _ref2;
|
44
44
|
return !disclosures.some(_ref3 => {
|
45
45
|
let [, name] = _ref3;
|
46
46
|
return name === attrKey;
|
47
|
-
})
|
47
|
+
});
|
48
48
|
});
|
49
49
|
if (attrsNotInDisclosures.length > 0) {
|
50
50
|
const missing = attrsNotInDisclosures.map(_ => _[0 /* key */]).join(", ");
|
51
51
|
const received = disclosures.map(_ => _[1 /* name */]).join(", ");
|
52
52
|
if (!ignoreMissingAttributes) {
|
53
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`);
|
53
54
|
throw new _errors.IoWalletError(`Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`);
|
54
55
|
}
|
55
56
|
}
|
@@ -66,25 +67,20 @@ const parseCredentialSdJwt = function (credentials_supported, _ref) {
|
|
66
67
|
value: (_disclosures$find = disclosures.find(_ => _[1 /* name */] === attrKey)) === null || _disclosures$find === void 0 ? void 0 : _disclosures$find[2 /* value */]
|
67
68
|
}];
|
68
69
|
})
|
69
|
-
//filter the not found elements
|
70
|
-
.filter(_ref5 => {
|
71
|
-
let [_, definition] = _ref5;
|
72
|
-
return definition.value !== undefined;
|
73
|
-
})
|
74
70
|
// add a human readable attribute name, with i18n, in the form { locale: name }
|
75
71
|
// example: { "it-IT": "Nome", "en-EN": "Name", "es-ES": "Nombre" }
|
76
|
-
.map(
|
72
|
+
.map(_ref5 => {
|
77
73
|
let [attrKey, {
|
78
74
|
display,
|
79
75
|
...definition
|
80
|
-
}] =
|
76
|
+
}] = _ref5;
|
81
77
|
return [attrKey, {
|
82
78
|
...definition,
|
83
|
-
name: display.reduce((names,
|
79
|
+
name: display.reduce((names, _ref6) => {
|
84
80
|
let {
|
85
81
|
locale,
|
86
82
|
name
|
87
|
-
} =
|
83
|
+
} = _ref6;
|
88
84
|
return {
|
89
85
|
...names,
|
90
86
|
[locale]: name
|
@@ -95,120 +91,8 @@ const parseCredentialSdJwt = function (credentials_supported, _ref) {
|
|
95
91
|
if (includeUndefinedAttributes) {
|
96
92
|
// attributes that are in the disclosure set
|
97
93
|
// but are not defined in the issuer configuration
|
98
|
-
const undefinedValues = Object.fromEntries(disclosures.filter(_ => !Object.keys(definedValues).includes(_[1])).map(
|
99
|
-
let [, key, value] =
|
100
|
-
return [key, {
|
101
|
-
value,
|
102
|
-
name: key
|
103
|
-
}];
|
104
|
-
}));
|
105
|
-
return {
|
106
|
-
...definedValues,
|
107
|
-
...undefinedValues
|
108
|
-
};
|
109
|
-
}
|
110
|
-
return definedValues;
|
111
|
-
};
|
112
|
-
|
113
|
-
//Exported for testing purposes
|
114
|
-
exports.parseCredentialSdJwt = parseCredentialSdJwt;
|
115
|
-
const parseCredentialMDoc = function (credentials_supported, credential_type, _ref9) {
|
116
|
-
let {
|
117
|
-
issuerSigned
|
118
|
-
} = _ref9;
|
119
|
-
let ignoreMissingAttributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
120
|
-
let includeUndefinedAttributes = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
121
|
-
const credentialSubject = credentials_supported[credential_type];
|
122
|
-
if (!credentialSubject) {
|
123
|
-
throw new _errors.IoWalletError("Credential type not supported by the issuer");
|
124
|
-
}
|
125
|
-
|
126
|
-
// transfrom a record { key: value } in an iterable of pairs [key, value]
|
127
|
-
if (!credentialSubject.claims) {
|
128
|
-
throw new _errors.IoWalletError("Missing claims in the credential subject"); // TODO [SIW-1268]: should not be optional
|
129
|
-
}
|
130
|
-
|
131
|
-
const claims = credentialSubject.claims;
|
132
|
-
const attrDefinitions = Object.entries(claims).flatMap(_ref10 => {
|
133
|
-
let [namespace, claimName] = _ref10;
|
134
|
-
return Object.entries(claimName).map(_ref11 => {
|
135
|
-
let [claimNameKey, definition] = _ref11;
|
136
|
-
return [namespace, claimNameKey, definition];
|
137
|
-
});
|
138
|
-
});
|
139
|
-
if (!issuerSigned.nameSpaces) {
|
140
|
-
throw new _errors.IoWalletError("Missing claims in the credential");
|
141
|
-
}
|
142
|
-
const flatNamespaces = Object.entries(issuerSigned.nameSpaces).flatMap(_ref12 => {
|
143
|
-
let [namespace, values] = _ref12;
|
144
|
-
return values.map(v => [namespace, v.elementIdentifier, v.elementValue]);
|
145
|
-
});
|
146
|
-
|
147
|
-
// Check that all mandatory attributes defined in the issuer configuration are present in the disclosure set
|
148
|
-
// and filter the non present ones
|
149
|
-
const attrsNotInDisclosures = attrDefinitions.filter(_ref13 => {
|
150
|
-
let [attrDefNamespace, attrKey, definition] = _ref13;
|
151
|
-
const isClaimPresent = flatNamespaces.find(_ref14 => {
|
152
|
-
let [namespace, name] = _ref14;
|
153
|
-
return attrDefNamespace === namespace && name === attrKey;
|
154
|
-
});
|
155
|
-
return isClaimPresent === undefined && definition.mandatory;
|
156
|
-
});
|
157
|
-
if (attrsNotInDisclosures.length > 0) {
|
158
|
-
const missing = attrsNotInDisclosures.map(_ => _[1 /* claim key */]).join(", ");
|
159
|
-
const received = flatNamespaces.map(_ => _[1 /*name*/]);
|
160
|
-
if (!ignoreMissingAttributes) {
|
161
|
-
throw new _errors.IoWalletError(`Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`);
|
162
|
-
}
|
163
|
-
}
|
164
|
-
|
165
|
-
// Attributes defined in the issuer configuration and present in the disclosure set
|
166
|
-
const definedValues = Object.fromEntries(attrDefinitions
|
167
|
-
// Retrieve the value from the corresponding disclosure
|
168
|
-
.map(_ref15 => {
|
169
|
-
var _flatNamespaces$find;
|
170
|
-
let [attrDefNamespace, attrKey, definition] = _ref15;
|
171
|
-
return [attrKey, {
|
172
|
-
...definition,
|
173
|
-
value: (_flatNamespaces$find = flatNamespaces.find(_ref16 => {
|
174
|
-
let [namespace, name] = _ref16;
|
175
|
-
return attrDefNamespace === namespace && name === attrKey;
|
176
|
-
})) === null || _flatNamespaces$find === void 0 ? void 0 : _flatNamespaces$find[2]
|
177
|
-
}];
|
178
|
-
})
|
179
|
-
//filter the not found elements
|
180
|
-
.filter(_ref17 => {
|
181
|
-
let [_, definition] = _ref17;
|
182
|
-
return definition.value !== undefined;
|
183
|
-
})
|
184
|
-
// Add a human-readable attribute name, with i18n, in the form { locale: name }
|
185
|
-
// Example: { "it-IT": "Nome", "en-EN": "Name", "es-ES": "Nombre" }
|
186
|
-
.map(_ref18 => {
|
187
|
-
let [attrKey, {
|
188
|
-
display,
|
189
|
-
...definition
|
190
|
-
}] = _ref18;
|
191
|
-
return [attrKey, {
|
192
|
-
...definition,
|
193
|
-
name: display.reduce((names, _ref19) => {
|
194
|
-
let {
|
195
|
-
locale,
|
196
|
-
name
|
197
|
-
} = _ref19;
|
198
|
-
return {
|
199
|
-
...names,
|
200
|
-
[locale]: name
|
201
|
-
};
|
202
|
-
}, {})
|
203
|
-
}];
|
204
|
-
}));
|
205
|
-
if (includeUndefinedAttributes) {
|
206
|
-
// Attributes that are present in the disclosure set but not defined in the issuer configuration
|
207
|
-
const undefinedValues = Object.fromEntries(flatNamespaces.filter(_ref20 => {
|
208
|
-
let [, key] = _ref20;
|
209
|
-
return !Object.keys(definedValues).includes(key);
|
210
|
-
}).map(_ref21 => {
|
211
|
-
let [, key, value] = _ref21;
|
94
|
+
const undefinedValues = Object.fromEntries(disclosures.filter(_ => !Object.keys(definedValues).includes(_[1])).map(_ref7 => {
|
95
|
+
let [, key, value] = _ref7;
|
212
96
|
return [key, {
|
213
97
|
value,
|
214
98
|
name: key
|
@@ -237,7 +121,6 @@ const parseCredentialMDoc = function (credentials_supported, credential_type, _r
|
|
237
121
|
* @throws If the holder binding is not properly configured
|
238
122
|
*
|
239
123
|
*/
|
240
|
-
exports.parseCredentialMDoc = parseCredentialMDoc;
|
241
124
|
async function verifyCredentialSdJwt(rawCredential, issuerKeys, holderBindingContext) {
|
242
125
|
const [decodedCredential, holderBindingKey] =
|
243
126
|
// parallel for optimization
|
@@ -246,97 +129,35 @@ async function verifyCredentialSdJwt(rawCredential, issuerKeys, holderBindingCon
|
|
246
129
|
cnf
|
247
130
|
} = decodedCredential.sdJwt.payload;
|
248
131
|
if (!cnf.jwk.kid || cnf.jwk.kid !== holderBindingKey.kid) {
|
132
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`);
|
249
133
|
throw new _errors.IoWalletError(`Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`);
|
250
134
|
}
|
251
135
|
return decodedCredential;
|
252
136
|
}
|
253
137
|
|
254
|
-
/**
|
255
|
-
* Given a credential, verify it's in the supported format
|
256
|
-
* and the credential is correctly signed
|
257
|
-
* and it's bound to the given key
|
258
|
-
*
|
259
|
-
* @param rawCredential The received credential
|
260
|
-
* @param issuerKeys The set of public keys of the issuer,
|
261
|
-
* which will be used to verify the signature
|
262
|
-
* @param holderBindingContext The access to the holder's key
|
263
|
-
*
|
264
|
-
* @throws If the signature verification fails
|
265
|
-
* @throws If the credential is not in the SdJwt4VC format
|
266
|
-
* @throws If the holder binding is not properly configured
|
267
|
-
*
|
268
|
-
*/
|
269
|
-
async function verifyCredentialMDoc(rawCredential, issuerKeys, holderBindingContext) {
|
270
|
-
/**
|
271
|
-
* For the moment, being that issues in the crypto key generation
|
272
|
-
* have been found on Android, the check for the deviceKey inside
|
273
|
-
* of the mDoc is skipped, so we are not interested in the holderBindingKey
|
274
|
-
*/
|
275
|
-
const [decodedCredential, _] =
|
276
|
-
// parallel for optimization
|
277
|
-
await Promise.all([(0, _mdoc.verify)(rawCredential, issuerKeys), holderBindingContext.getPublicKey()]);
|
278
|
-
if (!decodedCredential) {
|
279
|
-
throw new _errors.IoWalletError("No MDOC credentials found!");
|
280
|
-
}
|
281
|
-
|
282
|
-
/**
|
283
|
-
* For the moment, being that issues in the crypto key generation
|
284
|
-
* have been found on Android, the check for the deviceKey inside
|
285
|
-
* of the mDoc is skipped.
|
286
|
-
*/
|
287
|
-
//const key = decodedCredential.mDoc.issuerSigned.issuerAuth.payload.deviceKeyInfo.deviceKey;
|
288
|
-
//
|
289
|
-
//if (!compareKeysByThumbprint(key, holderBindingKey as PublicKey)) {
|
290
|
-
// throw new IoWalletError(
|
291
|
-
// `Failed to verify holder binding, holder binding key and mDoc deviceKey don't match`
|
292
|
-
// );
|
293
|
-
//}
|
294
|
-
|
295
|
-
return decodedCredential;
|
296
|
-
}
|
297
|
-
|
298
138
|
// utility type that specialize VerifyAndParseCredential for given format
|
299
139
|
|
300
|
-
const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _,
|
140
|
+
const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) => {
|
301
141
|
let {
|
302
142
|
credentialCryptoContext,
|
303
143
|
ignoreMissingAttributes,
|
304
144
|
includeUndefinedAttributes
|
305
|
-
} =
|
306
|
-
const decoded = await verifyCredentialSdJwt(credential, issuerConf.keys, credentialCryptoContext);
|
307
|
-
|
145
|
+
} = _ref8;
|
146
|
+
const decoded = await verifyCredentialSdJwt(credential, issuerConf.openid_credential_issuer.jwks.keys, credentialCryptoContext);
|
147
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Decoded credential: ${JSON.stringify(decoded)}`);
|
148
|
+
const parsedCredential = parseCredentialSdJwt(issuerConf.openid_credential_issuer.credential_configurations_supported, decoded, ignoreMissingAttributes, includeUndefinedAttributes);
|
308
149
|
const maybeIssuedAt = (0, _converters.getValueFromDisclosures)(decoded.disclosures, "iat");
|
150
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Parsed credential: ${JSON.stringify(parsedCredential)}\nIssued at: ${maybeIssuedAt}`);
|
309
151
|
return {
|
310
152
|
parsedCredential,
|
311
153
|
expiration: new Date(decoded.sdJwt.payload.exp * 1000),
|
312
154
|
issuedAt: typeof maybeIssuedAt === "number" ? new Date(maybeIssuedAt * 1000) : undefined
|
313
155
|
};
|
314
156
|
};
|
315
|
-
const verifyAndParseCredentialMDoc = async (issuerConf, credential, _, credentialType, _ref23) => {
|
316
|
-
var _parsedCredential$exp, _parsedCredential$iss;
|
317
|
-
let {
|
318
|
-
credentialCryptoContext,
|
319
|
-
ignoreMissingAttributes
|
320
|
-
} = _ref23;
|
321
|
-
const decoded = await verifyCredentialMDoc(credential, issuerConf.keys, credentialCryptoContext);
|
322
|
-
const parsedCredential = parseCredentialMDoc(issuerConf.credential_configurations_supported, credentialType, decoded, undefined, ignoreMissingAttributes);
|
323
|
-
const expirationDate = (0, _converters2.extractElementValueAsDate)(parsedCredential === null || parsedCredential === void 0 || (_parsedCredential$exp = parsedCredential.expiry_date) === null || _parsedCredential$exp === void 0 ? void 0 : _parsedCredential$exp.value);
|
324
|
-
if (!expirationDate) {
|
325
|
-
throw new _errors.IoWalletError(`expirationDate must be present!!`);
|
326
|
-
}
|
327
|
-
expirationDate === null || expirationDate === void 0 ? void 0 : expirationDate.setDate(expirationDate.getDate() + 1);
|
328
|
-
const maybeIssuedAt = (0, _converters2.extractElementValueAsDate)(parsedCredential === null || parsedCredential === void 0 || (_parsedCredential$iss = parsedCredential.issue_date) === null || _parsedCredential$iss === void 0 ? void 0 : _parsedCredential$iss.value);
|
329
|
-
maybeIssuedAt === null || maybeIssuedAt === void 0 ? void 0 : maybeIssuedAt.setDate(maybeIssuedAt.getDate() + 1);
|
330
|
-
return {
|
331
|
-
parsedCredential,
|
332
|
-
expiration: expirationDate ?? new Date(),
|
333
|
-
issuedAt: maybeIssuedAt ?? undefined
|
334
|
-
};
|
335
|
-
};
|
336
157
|
|
337
158
|
/**
|
338
159
|
* Verify and parse an encoded credential.
|
339
|
-
* @param issuerConf The Issuer configuration returned by {@link
|
160
|
+
* @param issuerConf The Issuer configuration returned by {@link evaluateIssuerTrust}
|
340
161
|
* @param credential The encoded credential returned by {@link obtainCredential}
|
341
162
|
* @param format The format of the credentual returned by {@link obtainCredential}
|
342
163
|
* @param context.credentialCryptoContext The crypto context used to obtain the credential in {@link obtainCredential}
|
@@ -347,13 +168,12 @@ const verifyAndParseCredentialMDoc = async (issuerConf, credential, _, credentia
|
|
347
168
|
* @throws {IoWalletError} If the credential is not bound to the provided user key
|
348
169
|
* @throws {IoWalletError} If the credential data fail to parse
|
349
170
|
*/
|
350
|
-
const verifyAndParseCredential = async (issuerConf, credential, format,
|
171
|
+
const verifyAndParseCredential = async (issuerConf, credential, format, context) => {
|
351
172
|
if (format === "vc+sd-jwt") {
|
352
|
-
|
353
|
-
|
354
|
-
if (format === "mso_mdoc") {
|
355
|
-
return verifyAndParseCredentialMDoc(issuerConf, credential, format, credentialType, context);
|
173
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, "Parsing credential in vc+sd-jwt format");
|
174
|
+
return verifyAndParseCredentialSdJwt(issuerConf, credential, format, context);
|
356
175
|
}
|
176
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Unsupported credential format: ${format}`);
|
357
177
|
throw new _errors.IoWalletError(`Unsupported credential format: ${format}`);
|
358
178
|
};
|
359
179
|
exports.verifyAndParseCredential = verifyAndParseCredential;
|