@pagopa/io-react-native-wallet 1.7.0 → 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
@@ -3,38 +3,93 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
7
|
-
var _errors = require("./errors");
|
6
|
+
exports.verifyRequestObject = void 0;
|
8
7
|
var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
|
8
|
+
var _errors = require("./errors");
|
9
9
|
var _types = require("./types");
|
10
|
-
|
10
|
+
var _retrieveRpJwks = require("./04-retrieve-rp-jwks");
|
11
|
+
/**
|
12
|
+
* Function to verify the Request Object's validity, from the signature to the required properties.
|
13
|
+
* @param requestObjectEncodedJwt The Request Object in JWT format
|
14
|
+
* @param context.clientId The client ID to verify
|
15
|
+
* @param context.rpConf The Entity Configuration of the Relying Party
|
16
|
+
* @param context.state Optional state
|
17
|
+
* @returns The verified Request Object
|
18
|
+
* @throws {InvalidRequestObjectError} if the Request Object cannot be validated
|
19
|
+
*/
|
20
|
+
const verifyRequestObject = async (requestObjectEncodedJwt, _ref) => {
|
21
|
+
let {
|
22
|
+
clientId,
|
23
|
+
rpConf,
|
24
|
+
rpSubject,
|
25
|
+
state
|
26
|
+
} = _ref;
|
11
27
|
const requestObjectJwt = (0, _ioReactNativeJwt.decode)(requestObjectEncodedJwt);
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
}
|
18
|
-
|
19
|
-
|
20
|
-
let {
|
21
|
-
use
|
22
|
-
} = _ref2;
|
23
|
-
return use === "sig";
|
24
|
-
}));
|
25
|
-
if (!pubKey) {
|
26
|
-
throw new _errors.UnverifiedEntityError("Request Object signature verification!");
|
28
|
+
const pubKey = getSigPublicKey(rpConf, requestObjectJwt.protectedHeader.kid);
|
29
|
+
try {
|
30
|
+
// Standard claims are verified within `verify`
|
31
|
+
await (0, _ioReactNativeJwt.verify)(requestObjectEncodedJwt, pubKey, {
|
32
|
+
issuer: clientId
|
33
|
+
});
|
34
|
+
} catch (_) {
|
35
|
+
throw new _errors.InvalidRequestObjectError("The Request Object signature verification failed");
|
27
36
|
}
|
28
|
-
|
29
|
-
const
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
37
|
+
const requestObject = validateRequestObjectShape(requestObjectJwt.payload);
|
38
|
+
const isClientIdMatch = clientId === requestObject.client_id && clientId === rpSubject;
|
39
|
+
if (!isClientIdMatch) {
|
40
|
+
throw new _errors.InvalidRequestObjectError("Client ID does not match Request Object or Entity Configuration");
|
41
|
+
}
|
42
|
+
const isStateMatch = state && requestObject.state ? state === requestObject.state : true;
|
43
|
+
if (!isStateMatch) {
|
44
|
+
throw new _errors.InvalidRequestObjectError("The provided state does not match the Request Object's");
|
34
45
|
}
|
35
46
|
return {
|
36
47
|
requestObject
|
37
48
|
};
|
38
49
|
};
|
39
|
-
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Validate the shape of the Request Object to ensure all required properties are present and are of the expected type.
|
53
|
+
*
|
54
|
+
* @param payload The Request Object to validate
|
55
|
+
* @returns A valid Request Object
|
56
|
+
* @throws {InvalidRequestObjectError} when the Request Object cannot be parsed
|
57
|
+
*/
|
58
|
+
exports.verifyRequestObject = verifyRequestObject;
|
59
|
+
const validateRequestObjectShape = payload => {
|
60
|
+
const requestObjectParse = _types.RequestObject.safeParse(payload);
|
61
|
+
if (requestObjectParse.success) {
|
62
|
+
return requestObjectParse.data;
|
63
|
+
}
|
64
|
+
throw new _errors.InvalidRequestObjectError("The Request Object cannot be parsed successfully", formatFlattenedZodErrors(requestObjectParse.error.flatten()));
|
65
|
+
};
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Get the public key to verify the Request Object's signature from the Relying Party's EC.
|
69
|
+
*
|
70
|
+
* @param rpConf The Relying Party's EC
|
71
|
+
* @param kid The identifier of the key to find
|
72
|
+
* @returns The corresponding public key to verify the signature
|
73
|
+
* @throws {InvalidRequestObjectError} when the key cannot be found
|
74
|
+
*/
|
75
|
+
const getSigPublicKey = (rpConf, kid) => {
|
76
|
+
try {
|
77
|
+
const {
|
78
|
+
keys
|
79
|
+
} = (0, _retrieveRpJwks.getJwksFromConfig)(rpConf);
|
80
|
+
const pubKey = keys.find(k => k.kid === kid);
|
81
|
+
if (!pubKey) throw new Error();
|
82
|
+
return pubKey;
|
83
|
+
} catch (_) {
|
84
|
+
throw new _errors.InvalidRequestObjectError(`The public key for signature verification (${kid}) cannot be found in the Entity Configuration`);
|
85
|
+
}
|
86
|
+
};
|
87
|
+
|
88
|
+
/**
|
89
|
+
* Utility to format flattened Zod errors into a simplified string `key1: key1_error, key2: key2_error`
|
90
|
+
*/
|
91
|
+
const formatFlattenedZodErrors = errors => Object.entries(errors.fieldErrors).map(_ref2 => {
|
92
|
+
let [key, error] = _ref2;
|
93
|
+
return `${key}: ${error[0]}`;
|
94
|
+
}).join(", ");
|
40
95
|
//# sourceMappingURL=05-verify-request-object.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["_ioReactNativeJwt","require","_errors","_types","_retrieveRpJwks","verifyRequestObject","requestObjectEncodedJwt","_ref","clientId","rpConf","rpSubject","state","requestObjectJwt","decodeJwt","pubKey","getSigPublicKey","protectedHeader","kid","verify","issuer","_","InvalidRequestObjectError","requestObject","validateRequestObjectShape","payload","isClientIdMatch","client_id","isStateMatch","exports","requestObjectParse","RequestObject","safeParse","success","data","formatFlattenedZodErrors","error","flatten","keys","getJwksFromConfig","find","k","Error","errors","Object","entries","fieldErrors","map","_ref2","key","join"],"sourceRoot":"../../../../src","sources":["credential/presentation/05-verify-request-object.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMI,mBAAwC,GAAG,MAAAA,CACtDC,uBAAuB,EAAAC,IAAA,KAEpB;EAAA,IADH;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,SAAS;IAAEC;EAAM,CAAC,GAAAJ,IAAA;EAEtC,MAAMK,gBAAgB,GAAG,IAAAC,wBAAS,E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ACA;AACA,MAAMrB,eAAe,GAAGA,CACtBN,MAA8D,EAC9DQ,GAAuB,KACpB;EACH,IAAI;IACF,MAAM;MAAEoB;IAAK,CAAC,GAAG,IAAAC,iCAAiB,EAAC7B,MAAM,CAAC;IAE1C,MAAMK,MAAM,GAAGuB,IAAI,CAACE,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACvB,GAAG,KAAKA,GAAG,CAAC;IAE9C,IAAI,CAACH,MAAM,EAAE,MAAM,IAAI2B,KAAK,CAAC,CAAC;IAE9B,OAAO3B,MAAM;EACf,CAAC,CAAC,OAAOM,CAAC,EAAE;IACV,MAAM,IAAIC,iCAAyB,CAChC,8CAA6CJ,GAAI,+CACpD,CAAC;EACH;AACF,CAAC;;AAED;AACA;AACA;AACA,MAAMiB,wBAAwB,GAC5BQ,MAA+C,IAE/CC,MAAM,CAACC,OAAO,CAACF,MAAM,CAACG,WAAW,CAAC,CAC/BC,GAAG,CAACC,KAAA;EAAA,IAAC,CAACC,GAAG,EAAEb,KAAK,CAAC,GAAAY,KAAA;EAAA,OAAM,GAAEC,GAAI,KAAIb,KAAK,CAAC,CAAC,CAAE,EAAC;AAAA,EAAC,CAC5Cc,IAAI,CAAC,IAAI,CAAC"}
|
@@ -4,31 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.fetchPresentDefinition = void 0;
|
7
|
-
var _types = require("./types");
|
8
|
-
var _misc = require("../../utils/misc");
|
9
7
|
/**
|
10
8
|
* Retrieves a PresentationDefinition based on the given parameters.
|
11
9
|
*
|
12
10
|
* The method attempts the following strategies in order:
|
13
11
|
* 1. Checks if `presentation_definition` is directly available in the request object.
|
14
|
-
* 2.
|
15
|
-
* 3. Uses a pre-configured `presentation_definition` from the relying party configuration if the `scope` is present in the request object.
|
12
|
+
* 2. Uses a pre-configured `presentation_definition` from the relying party configuration if the `scope` is present in the request object.
|
16
13
|
*
|
17
|
-
* If none of the above conditions are met, the function throws an error indicating the definition could not be found.
|
14
|
+
* If none of the above conditions are met, the function throws an error indicating the definition could not be found. Note that `presentation_definition_uri` is not supported in 0.9.x.
|
18
15
|
*
|
19
16
|
* @param {RequestObject} requestObject - The request object containing the presentation definition or references to it.
|
20
17
|
* @param {RelyingPartyEntityConfiguration["payload"]["metadata"]} [rpConf] - Optional relying party configuration.
|
21
|
-
* @param {Object} [context] - Optional context for providing a custom fetch implementation.
|
22
|
-
* @param {GlobalFetch["fetch"]} [context.appFetch] - Custom fetch function, defaults to global `fetch`.
|
23
18
|
* @returns {Promise<{ presentationDefinition: PresentationDefinition }>} - Resolves with the presentation definition.
|
24
19
|
* @throws {Error} - Throws if the presentation definition cannot be found or fetched.
|
25
20
|
*/
|
26
|
-
const fetchPresentDefinition = async
|
27
|
-
var _rpConf$
|
28
|
-
let {
|
29
|
-
appFetch = fetch
|
30
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
31
|
-
let rpConf = arguments.length > 2 ? arguments[2] : undefined;
|
21
|
+
const fetchPresentDefinition = async (requestObject, rpConf) => {
|
22
|
+
var _rpConf$openid_creden;
|
32
23
|
// Check if `presentation_definition` is directly available in the request object
|
33
24
|
if (requestObject.presentation_definition) {
|
34
25
|
return {
|
@@ -36,25 +27,10 @@ const fetchPresentDefinition = async function (requestObject) {
|
|
36
27
|
};
|
37
28
|
}
|
38
29
|
|
39
|
-
// Check if `presentation_definition_uri` is provided in the relying party configuration
|
40
|
-
if (rpConf !== null && rpConf !== void 0 && (_rpConf$wallet_relyin = rpConf.wallet_relying_party) !== null && _rpConf$wallet_relyin !== void 0 && _rpConf$wallet_relyin.presentation_definition_uri) {
|
41
|
-
try {
|
42
|
-
// Fetch the presentation definition from the provided URI
|
43
|
-
const presentationDefinition = await appFetch(rpConf === null || rpConf === void 0 ? void 0 : rpConf.wallet_relying_party.presentation_definition_uri, {
|
44
|
-
method: "GET"
|
45
|
-
}).then((0, _misc.hasStatusOrThrow)(200)).then(raw => raw.json()).then(json => _types.PresentationDefinition.parse(json));
|
46
|
-
return {
|
47
|
-
presentationDefinition
|
48
|
-
};
|
49
|
-
} catch (error) {
|
50
|
-
throw new Error(`Failed to fetch presentation definition: ${error}`);
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
54
30
|
// Check if `scope` is present in the request object and a pre-configured presentation definition exists
|
55
|
-
if (requestObject.scope && rpConf !== null && rpConf !== void 0 && (_rpConf$
|
31
|
+
if (requestObject.scope && rpConf !== null && rpConf !== void 0 && (_rpConf$openid_creden = rpConf.openid_credential_verifier) !== null && _rpConf$openid_creden !== void 0 && _rpConf$openid_creden.presentation_definition) {
|
56
32
|
return {
|
57
|
-
presentationDefinition: rpConf.
|
33
|
+
presentationDefinition: rpConf.openid_credential_verifier.presentation_definition
|
58
34
|
};
|
59
35
|
}
|
60
36
|
throw new Error("Presentation definition not found");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["fetchPresentDefinition","requestObject","rpConf","_rpConf$openid_creden","presentation_definition","presentationDefinition","scope","openid_credential_verifier","Error","exports"],"sourceRoot":"../../../../src","sources":["credential/presentation/06-fetch-presentation-definition.ts"],"mappings":";;;;;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,sBAAmD,GAAG,MAAAA,CACjEC,aAAa,EACbC,MAAM,KACH;EAAA,IAAAC,qBAAA;EACH;EACA,IAAIF,aAAa,CAACG,uBAAuB,EAAE;IACzC,OAAO;MACLC,sBAAsB,EAAEJ,aAAa,CAACG;IACxC,CAAC;EACH;;EAEA;EACA,IACEH,aAAa,CAACK,KAAK,IACnBJ,MAAM,aAANA,MAAM,gBAAAC,qBAAA,GAAND,MAAM,CAAEK,0BAA0B,cAAAJ,qBAAA,eAAlCA,qBAAA,CAAoCC,uBAAuB,EAC3D;IACA,OAAO;MACLC,sBAAsB,EACpBH,MAAM,CAACK,0BAA0B,CAACH;IACtC,CAAC;EACH;EAEA,MAAM,IAAII,KAAK,CAAC,mCAAmC,CAAC;AACtD,CAAC;AAACC,OAAA,CAAAT,sBAAA,GAAAA,sBAAA"}
|
@@ -3,28 +3,31 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.evaluateDcqlQuery = void 0;
|
6
|
+
exports.prepareRemotePresentations = exports.evaluateDcqlQuery = void 0;
|
7
7
|
var _dcql = require("dcql");
|
8
8
|
var _valibot = require("valibot");
|
9
9
|
var _sdJwt = require("../../sd-jwt");
|
10
|
-
var
|
11
|
-
var
|
12
|
-
var _ioReactNativeCbor = require("@pagopa/io-react-native-cbor");
|
10
|
+
var _crypto = require("../../utils/crypto");
|
11
|
+
var _errors = require("./errors");
|
13
12
|
/**
|
14
13
|
* The purpose for the credential request by the RP.
|
15
14
|
*/
|
16
15
|
|
17
16
|
/**
|
18
|
-
* Convert a credential in
|
17
|
+
* Convert a credential in JWT format to an object with claims
|
19
18
|
* for correct parsing by the `dcql` library.
|
20
19
|
*/
|
21
|
-
const
|
22
|
-
let [,, jwt] = _ref;
|
20
|
+
const mapCredentialToObject = jwt => {
|
23
21
|
const {
|
24
22
|
sdJwt,
|
25
23
|
disclosures
|
26
24
|
} = (0, _sdJwt.decode)(jwt);
|
27
25
|
const credentialFormat = sdJwt.header.typ;
|
26
|
+
|
27
|
+
// TODO [SIW-2082]: support MDOC credentials
|
28
|
+
if (credentialFormat !== "vc+sd-jwt") {
|
29
|
+
throw new Error(`Unsupported credential format: ${credentialFormat}`);
|
30
|
+
}
|
28
31
|
return {
|
29
32
|
vct: sdJwt.payload.vct,
|
30
33
|
credential_format: credentialFormat,
|
@@ -33,63 +36,74 @@ const mapCredentialSdJwtToObj = credentials => credentials.map(_ref => {
|
|
33
36
|
[disclosure.decoded[1]]: disclosure.decoded
|
34
37
|
}), {})
|
35
38
|
};
|
39
|
+
};
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Extract only successful matches from the DCQL query result.
|
43
|
+
*/
|
44
|
+
const getDcqlQueryMatches = result => Object.entries(result.credential_matches).filter(_ref => {
|
45
|
+
let [, match] = _ref;
|
46
|
+
return match.success === true;
|
36
47
|
});
|
37
48
|
|
38
49
|
/**
|
39
|
-
*
|
40
|
-
|
50
|
+
* Extract only failed matches from the DCQL query result.
|
51
|
+
*/
|
52
|
+
const getDcqlQueryFailedMatches = result => Object.entries(result.credential_matches).filter(_ref2 => {
|
53
|
+
let [, match] = _ref2;
|
54
|
+
return match.success === false;
|
55
|
+
});
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Extract missing credentials from the DCQL query result.
|
59
|
+
* Note: here we are assuming a failed match is a missing credential,
|
60
|
+
* but there might be other reasons for its failure.
|
41
61
|
*/
|
42
|
-
const
|
43
|
-
return
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
62
|
+
const extractMissingCredentials = (queryResult, originalQuery) => {
|
63
|
+
return getDcqlQueryFailedMatches(queryResult).map(_ref3 => {
|
64
|
+
var _credential$meta;
|
65
|
+
let [id] = _ref3;
|
66
|
+
const credential = originalQuery.credentials.find(c => c.id === id);
|
67
|
+
if ((credential === null || credential === void 0 ? void 0 : credential.format) !== "vc+sd-jwt") {
|
68
|
+
throw new Error("Unsupported format"); // TODO [SIW-2082]: support MDOC credentials
|
48
69
|
}
|
49
|
-
|
50
|
-
let [ns, nsClaims] = _ref3;
|
51
|
-
const flattenNsClaims = Object.entries(nsClaims).reduce((ac, _ref4) => {
|
52
|
-
let [, el] = _ref4;
|
53
|
-
return {
|
54
|
-
...ac,
|
55
|
-
[el.elementIdentifier]: el.elementValue
|
56
|
-
};
|
57
|
-
}, {});
|
58
|
-
return {
|
59
|
-
...acc,
|
60
|
-
[ns]: flattenNsClaims
|
61
|
-
};
|
62
|
-
}, {});
|
70
|
+
|
63
71
|
return {
|
64
|
-
|
65
|
-
|
66
|
-
namespaces
|
72
|
+
id,
|
73
|
+
vctValues: (_credential$meta = credential.meta) === null || _credential$meta === void 0 ? void 0 : _credential$meta.vct_values
|
67
74
|
};
|
68
|
-
})
|
75
|
+
});
|
69
76
|
};
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
let [, match] = _ref5;
|
76
|
-
return match.success === true;
|
77
|
-
});
|
78
|
-
const evaluateDcqlQuery = async (query, credentialsSdJwt, credentialsMdoc) => {
|
79
|
-
const credentials = [];
|
80
|
-
credentials.push(...mapCredentialSdJwtToObj(credentialsSdJwt));
|
81
|
-
credentials.push(...(await mapCredentialsMdocToObj(credentialsMdoc)));
|
77
|
+
const evaluateDcqlQuery = (credentialsSdJwt, query) => {
|
78
|
+
const credentials = credentialsSdJwt.map(_ref4 => {
|
79
|
+
let [, credential] = _ref4;
|
80
|
+
return mapCredentialToObject(credential);
|
81
|
+
});
|
82
82
|
try {
|
83
83
|
// Validate the query
|
84
84
|
const parsedQuery = _dcql.DcqlQuery.parse(query);
|
85
85
|
_dcql.DcqlQuery.validate(parsedQuery);
|
86
86
|
const queryResult = _dcql.DcqlQuery.query(parsedQuery, credentials);
|
87
87
|
if (!queryResult.canBeSatisfied) {
|
88
|
-
throw new
|
88
|
+
throw new _errors.CredentialsNotFoundError(extractMissingCredentials(queryResult, parsedQuery));
|
89
89
|
}
|
90
|
-
|
90
|
+
|
91
|
+
// Build an object vct:credentialJwt to map matched credentials to their JWT
|
92
|
+
const credentialsSdJwtByVct = credentials.reduce((acc, c, i) => ({
|
93
|
+
...acc,
|
94
|
+
[c.vct]: credentialsSdJwt[i]
|
95
|
+
}), {});
|
96
|
+
return getDcqlQueryMatches(queryResult).map(_ref5 => {
|
91
97
|
var _queryResult$credenti;
|
92
|
-
let [id, match] =
|
98
|
+
let [id, match] = _ref5;
|
99
|
+
if (match.output.credential_format !== "vc+sd-jwt") {
|
100
|
+
throw new Error("Unsupported format"); // TODO [SIW-2082]: support MDOC credentials
|
101
|
+
}
|
102
|
+
|
103
|
+
const {
|
104
|
+
vct,
|
105
|
+
claims
|
106
|
+
} = match.output;
|
93
107
|
const purposes = (_queryResult$credenti = queryResult.credential_sets) === null || _queryResult$credenti === void 0 || (_queryResult$credenti = _queryResult$credenti.filter(set => {
|
94
108
|
var _set$matching_options;
|
95
109
|
return (_set$matching_options = set.matching_options) === null || _set$matching_options === void 0 ? void 0 : _set$matching_options.flat().includes(id);
|
@@ -100,82 +114,48 @@ const evaluateDcqlQuery = async (query, credentialsSdJwt, credentialsMdoc) => {
|
|
100
114
|
required: Boolean(credentialSet.required)
|
101
115
|
};
|
102
116
|
});
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
format: match.output.credential_format,
|
118
|
-
credential,
|
119
|
-
requiredDisclosures,
|
120
|
-
// When it is a match but no credential_sets are found, the credential is required by default
|
121
|
-
// See https://openid.net/specs/openid-4-verifiable-presentations-1_0-24.html#section-6.3.1.2-2.1
|
122
|
-
purposes: purposes ?? [{
|
123
|
-
required: true
|
124
|
-
}]
|
125
|
-
};
|
126
|
-
}
|
127
|
-
if (match.output.credential_format === "mso_mdoc") {
|
128
|
-
const {
|
129
|
-
doctype,
|
130
|
-
namespaces
|
131
|
-
} = match.output;
|
132
|
-
const [, keyTag, credential] = credentialsMdoc.find(_ref8 => {
|
133
|
-
let [type] = _ref8;
|
134
|
-
return type === doctype;
|
135
|
-
});
|
136
|
-
const requiredDisclosures = Object.entries(namespaces).reduce((acc, _ref9) => {
|
137
|
-
let [ns, nsClaims] = _ref9;
|
138
|
-
return [...acc, ...Object.entries(nsClaims).map(_ref10 => {
|
139
|
-
let [claimName] = _ref10;
|
140
|
-
return {
|
141
|
-
namespace: ns,
|
142
|
-
name: claimName,
|
143
|
-
value: nsClaims[claimName]
|
144
|
-
};
|
145
|
-
})];
|
146
|
-
}, []);
|
147
|
-
return {
|
148
|
-
id,
|
149
|
-
keyTag,
|
150
|
-
format: match.output.credential_format,
|
151
|
-
credential,
|
152
|
-
requiredDisclosures,
|
153
|
-
// When it is a match but no credential_sets are found, the credential is required by default
|
154
|
-
// See https://openid.net/specs/openid-4-verifiable-presentations-1_0-24.html#section-6.3.1.2-2.1
|
155
|
-
purposes: purposes ?? [{
|
156
|
-
required: true
|
157
|
-
}],
|
158
|
-
doctype
|
159
|
-
};
|
160
|
-
}
|
161
|
-
throw new Error(`Unsupported credential format: ${match.output.credential_format}`);
|
117
|
+
const [keyTag, credential] = credentialsSdJwtByVct[vct];
|
118
|
+
const requiredDisclosures = Object.values(claims);
|
119
|
+
return {
|
120
|
+
id,
|
121
|
+
vct,
|
122
|
+
keyTag,
|
123
|
+
credential,
|
124
|
+
requiredDisclosures,
|
125
|
+
// When it is a match but no credential_sets are found, the credential is required by default
|
126
|
+
// See https://openid.net/specs/openid-4-verifiable-presentations-1_0-24.html#section-6.3.1.2-2.1
|
127
|
+
purposes: purposes ?? [{
|
128
|
+
required: true
|
129
|
+
}]
|
130
|
+
};
|
162
131
|
});
|
163
132
|
} catch (error) {
|
164
|
-
// Invalid DCQL query structure
|
133
|
+
// Invalid DCQL query structure. Remap to `DcqlError` for consistency.
|
165
134
|
if ((0, _valibot.isValiError)(error)) {
|
166
|
-
throw new
|
167
|
-
message: "
|
168
|
-
|
135
|
+
throw new _dcql.DcqlError({
|
136
|
+
message: "Failed to parse the provided DCQL query",
|
137
|
+
code: "PARSE_ERROR",
|
138
|
+
cause: error.issues
|
169
139
|
});
|
170
140
|
}
|
171
|
-
|
172
|
-
|
173
|
-
}
|
174
|
-
if (error instanceof _dcql.DcqlCredentialSetError) {
|
175
|
-
// TODO [SIW-2110]: handle missing credentials or let the error propagate
|
176
|
-
}
|
141
|
+
|
142
|
+
// Let other errors propagate so they can be caught with `err instanceof DcqlError`
|
177
143
|
throw error;
|
178
144
|
}
|
179
145
|
};
|
180
146
|
exports.evaluateDcqlQuery = evaluateDcqlQuery;
|
147
|
+
const prepareRemotePresentations = async (credentials, nonce, clientId) => {
|
148
|
+
return Promise.all(credentials.map(async item => {
|
149
|
+
const {
|
150
|
+
vp_token
|
151
|
+
} = await (0, _sdJwt.prepareVpToken)(nonce, clientId, [item.credential, item.requestedClaims, (0, _crypto.createCryptoContextFor)(item.keyTag)]);
|
152
|
+
return {
|
153
|
+
credentialId: item.id,
|
154
|
+
requestedClaims: item.requestedClaims,
|
155
|
+
vpToken: vp_token,
|
156
|
+
format: "vc+sd-jwt"
|
157
|
+
};
|
158
|
+
}));
|
159
|
+
};
|
160
|
+
exports.prepareRemotePresentations = prepareRemotePresentations;
|
181
161
|
//# sourceMappingURL=07-evaluate-dcql-query.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_dcql","require","_valibot","_sdJwt","
|
1
|
+
{"version":3,"names":["_dcql","require","_valibot","_sdJwt","_crypto","_errors","mapCredentialToObject","jwt","sdJwt","disclosures","decode","credentialFormat","header","typ","Error","vct","payload","credential_format","claims","reduce","acc","disclosure","decoded","getDcqlQueryMatches","result","Object","entries","credential_matches","filter","_ref","match","success","getDcqlQueryFailedMatches","_ref2","extractMissingCredentials","queryResult","originalQuery","map","_ref3","_credential$meta","id","credential","credentials","find","c","format","vctValues","meta","vct_values","evaluateDcqlQuery","credentialsSdJwt","query","_ref4","parsedQuery","DcqlQuery","parse","validate","canBeSatisfied","CredentialsNotFoundError","credentialsSdJwtByVct","i","_ref5","_queryResult$credenti","output","purposes","credential_sets","set","_set$matching_options","matching_options","flat","includes","credentialSet","_credentialSet$purpos","description","purpose","toString","required","Boolean","keyTag","requiredDisclosures","values","error","isValiError","DcqlError","message","code","cause","issues","exports","prepareRemotePresentations","nonce","clientId","Promise","all","item","vp_token","prepareVpToken","requestedClaims","createCryptoContextFor","credentialId","vpToken"],"sourceRoot":"../../../../src","sources":["credential/presentation/07-evaluate-dcql-query.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAA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