@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
@@ -1,33 +1,29 @@
|
|
1
|
-
import { InputDescriptor, type
|
2
|
-
import { decode } from "../../sd-jwt";
|
1
|
+
import { InputDescriptor, type LegacyRemotePresentation } from "./types";
|
3
2
|
import { SdJwt4VC, type DisclosureWithEncoded } from "../../sd-jwt/types";
|
3
|
+
import { decode, prepareVpToken } from "../../sd-jwt";
|
4
|
+
import { createCryptoContextFor } from "../../utils/crypto";
|
4
5
|
import { JSONPath } from "jsonpath-plus";
|
5
|
-
import {
|
6
|
+
import { CredentialsNotFoundError, MissingDataError } from "./errors";
|
6
7
|
import Ajv from "ajv";
|
7
|
-
import { CBOR } from "@pagopa/io-react-native-cbor";
|
8
8
|
|
9
9
|
const ajv = new Ajv({ allErrors: true });
|
10
|
+
const INDEX_CLAIM_NAME = 1;
|
10
11
|
|
11
|
-
type EvaluatedDisclosures = {
|
12
|
-
requiredDisclosures:
|
13
|
-
optionalDisclosures:
|
12
|
+
export type EvaluatedDisclosures = {
|
13
|
+
requiredDisclosures: DisclosureWithEncoded[];
|
14
|
+
optionalDisclosures: DisclosureWithEncoded[];
|
15
|
+
unrequestedDisclosures: DisclosureWithEncoded[];
|
14
16
|
};
|
15
17
|
|
16
|
-
type EvaluateInputDescriptorSdJwt4VC = (
|
18
|
+
export type EvaluateInputDescriptorSdJwt4VC = (
|
17
19
|
inputDescriptor: InputDescriptor,
|
18
20
|
payloadCredential: SdJwt4VC["payload"],
|
19
21
|
disclosures: DisclosureWithEncoded[]
|
20
22
|
) => EvaluatedDisclosures;
|
21
23
|
|
22
|
-
type EvaluateInputDescriptorMdoc = (
|
23
|
-
inputDescriptor: InputDescriptor,
|
24
|
-
issuerSigned: CBOR.IssuerSigned
|
25
|
-
) => EvaluatedDisclosures;
|
26
|
-
|
27
24
|
export type EvaluateInputDescriptors = (
|
28
25
|
descriptors: InputDescriptor[],
|
29
|
-
credentialsSdJwt: [string
|
30
|
-
credentialsMdoc: [string, string /* keyTag */, string /* credential */][]
|
26
|
+
credentialsSdJwt: [string /* keyTag */, string /* credential */][]
|
31
27
|
) => Promise<
|
32
28
|
{
|
33
29
|
evaluatedDisclosure: EvaluatedDisclosures;
|
@@ -37,28 +33,19 @@ export type EvaluateInputDescriptors = (
|
|
37
33
|
}[]
|
38
34
|
>;
|
39
35
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
issuerSigned: CBOR.IssuerSigned;
|
54
|
-
};
|
55
|
-
|
56
|
-
type DecodedCredentialSdJwt = {
|
57
|
-
keyTag: string;
|
58
|
-
credential: string;
|
59
|
-
sdJwt: SdJwt4VC;
|
60
|
-
disclosures: DisclosureWithEncoded[];
|
61
|
-
};
|
36
|
+
/**
|
37
|
+
* @deprecated Use `prepareRemotePresentations` from DCQL
|
38
|
+
*/
|
39
|
+
export type PrepareLegacyRemotePresentations = (
|
40
|
+
credentialAndDescriptors: {
|
41
|
+
requestedClaims: string[];
|
42
|
+
inputDescriptor: InputDescriptor;
|
43
|
+
credential: string;
|
44
|
+
keyTag: string;
|
45
|
+
}[],
|
46
|
+
nonce: string,
|
47
|
+
client_id: string
|
48
|
+
) => Promise<LegacyRemotePresentation[]>;
|
62
49
|
|
63
50
|
/**
|
64
51
|
* Transforms an array of DisclosureWithEncoded objects into a key-value map.
|
@@ -78,31 +65,6 @@ const mapDisclosuresToObject = (
|
|
78
65
|
);
|
79
66
|
};
|
80
67
|
|
81
|
-
/**
|
82
|
-
* Transforms the issuer's namespaces from a CBOR structure into a plain JavaScript object.
|
83
|
-
*
|
84
|
-
* @param namespaces - The CBOR-based namespaces object where each key corresponds to a namespace,
|
85
|
-
* and each value is an array of elements containing identifiers and values.
|
86
|
-
* @returns A record (plain object) where each key is a namespace, and its value is another object
|
87
|
-
* mapping element identifiers to their corresponding element values.
|
88
|
-
*/
|
89
|
-
const mapNamespacesToObject = (
|
90
|
-
namespaces: CBOR.IssuerSigned["nameSpaces"]
|
91
|
-
): Record<string, unknown> => {
|
92
|
-
return Object.entries(namespaces).reduce(
|
93
|
-
(obj, [namespace, elements]) => {
|
94
|
-
obj[namespace] = Object.fromEntries(
|
95
|
-
elements.map((element) => [
|
96
|
-
element.elementIdentifier,
|
97
|
-
element.elementValue,
|
98
|
-
])
|
99
|
-
);
|
100
|
-
return obj;
|
101
|
-
},
|
102
|
-
{} as Record<string, unknown>
|
103
|
-
);
|
104
|
-
};
|
105
|
-
|
106
68
|
/**
|
107
69
|
* Finds a claim within the payload based on provided JSONPath expressions.
|
108
70
|
* @param paths - An array of JSONPath expressions to search for in the payload.
|
@@ -155,109 +117,12 @@ const extractClaimName = (path: string): string | undefined => {
|
|
155
117
|
return match[1] || match[2];
|
156
118
|
}
|
157
119
|
|
158
|
-
|
159
|
-
`Invalid input format: "${path}". Expected formats are "$.propertyName", "$['propertyName']", or '$["propertyName"]'.`
|
160
|
-
);
|
161
|
-
};
|
162
|
-
|
163
|
-
/**
|
164
|
-
* Extracts the namespace and claim name from a path in the following format:
|
165
|
-
* $['nameSpace']['propertyName']
|
166
|
-
*
|
167
|
-
* @param path - The path string containing the claim reference.
|
168
|
-
* @returns An object with the extracted namespace and claim name.
|
169
|
-
* @throws An error if the input format is invalid.
|
170
|
-
*/
|
171
|
-
const extractNamespaceAndClaimName = (
|
172
|
-
path: string
|
173
|
-
): { nameSpace?: string; propertyName?: string } => {
|
174
|
-
const regex = /^\$\[(?:'|")([^'"\]]+)(?:'|")\]\[(?:'|")([^'"\]]+)(?:'|")\]$/;
|
175
|
-
const match = path.match(regex);
|
176
|
-
if (match) {
|
177
|
-
return { nameSpace: match[1], propertyName: match[2] };
|
178
|
-
}
|
120
|
+
// If the input doesn't match any of the expected formats, return null
|
179
121
|
|
180
122
|
throw new Error(
|
181
|
-
`Invalid input format: "${path}". Expected
|
123
|
+
`Invalid input format: "${path}". Expected formats are "$.propertyName", "$['propertyName']", or '$["propertyName"]'.`
|
182
124
|
);
|
183
125
|
};
|
184
|
-
/**
|
185
|
-
* Evaluates the input descriptor for an mDoc by verifying that the issuerSigned claims meet
|
186
|
-
* the constraints defined in the input descriptor. It categorizes disclosures as either required
|
187
|
-
* or optional based on the field definitions.
|
188
|
-
*
|
189
|
-
* @param inputDescriptor - Contains constraints and field definitions specifying required/optional claims.
|
190
|
-
* @param issuerSigned - Contains the issuerSigned with namespaces and their associated claims.
|
191
|
-
* @returns An object with two arrays: one for required disclosures and one for optional disclosures.
|
192
|
-
* @throws MissingDataError - If a required field is missing or if a claim fails JSON Schema validation.
|
193
|
-
*/
|
194
|
-
export const evaluateInputDescriptorForMdoc: EvaluateInputDescriptorMdoc = (
|
195
|
-
inputDescriptor,
|
196
|
-
issuerSigned
|
197
|
-
) => {
|
198
|
-
if (!inputDescriptor?.constraints?.fields) {
|
199
|
-
// No validation, no field are required
|
200
|
-
return {
|
201
|
-
requiredDisclosures: [],
|
202
|
-
optionalDisclosures: [],
|
203
|
-
};
|
204
|
-
}
|
205
|
-
|
206
|
-
const requiredDisclosures: EvaluatedDisclosure[] = [];
|
207
|
-
const optionalDisclosures: EvaluatedDisclosure[] = [];
|
208
|
-
|
209
|
-
// Convert issuer's namespaces into an object for easier lookup of claim values.
|
210
|
-
const namespacesAsPayload = mapNamespacesToObject(issuerSigned.nameSpaces);
|
211
|
-
|
212
|
-
const allFieldsValid = inputDescriptor.constraints.fields.every((field) => {
|
213
|
-
const [matchedPath, matchedValue] = findMatchedClaim(
|
214
|
-
field.path,
|
215
|
-
namespacesAsPayload
|
216
|
-
);
|
217
|
-
|
218
|
-
// If no matching claim is found, the field is valid only if it's marked as optional.
|
219
|
-
if (matchedValue === undefined || !matchedPath) {
|
220
|
-
return field?.optional;
|
221
|
-
} else {
|
222
|
-
// Extract the namespace and property name from the matched path.
|
223
|
-
const { nameSpace, propertyName } =
|
224
|
-
extractNamespaceAndClaimName(matchedPath);
|
225
|
-
if (nameSpace && propertyName) {
|
226
|
-
(field?.optional ? optionalDisclosures : requiredDisclosures).push({
|
227
|
-
namespace: nameSpace,
|
228
|
-
name: propertyName,
|
229
|
-
value: matchedValue,
|
230
|
-
});
|
231
|
-
}
|
232
|
-
}
|
233
|
-
|
234
|
-
if (field.filter) {
|
235
|
-
try {
|
236
|
-
const validateSchema = ajv.compile(field.filter);
|
237
|
-
if (!validateSchema(matchedValue)) {
|
238
|
-
throw new MissingDataError(
|
239
|
-
`Claim value "${matchedValue}" for path "${matchedPath}" does not match the provided JSON Schema.`
|
240
|
-
);
|
241
|
-
}
|
242
|
-
} catch (error) {
|
243
|
-
return false;
|
244
|
-
}
|
245
|
-
}
|
246
|
-
|
247
|
-
return true;
|
248
|
-
});
|
249
|
-
|
250
|
-
if (!allFieldsValid) {
|
251
|
-
throw new MissingDataError(
|
252
|
-
"Credential validation failed: Required fields are missing or do not match the input descriptor."
|
253
|
-
);
|
254
|
-
}
|
255
|
-
|
256
|
-
return {
|
257
|
-
requiredDisclosures,
|
258
|
-
optionalDisclosures,
|
259
|
-
};
|
260
|
-
};
|
261
126
|
|
262
127
|
/**
|
263
128
|
* Evaluates an InputDescriptor for an SD-JWT-based verifiable credential.
|
@@ -267,12 +132,14 @@ export const evaluateInputDescriptorForMdoc: EvaluateInputDescriptorMdoc = (
|
|
267
132
|
* - Validates whether required fields are present (unless marked optional)
|
268
133
|
* and match any specified JSONPath.
|
269
134
|
* - If a field includes a JSON Schema filter, validates the claim value against that schema.
|
135
|
+
* - Enforces `limit_disclosure` rules by returning only disclosures, required and optional, matching the specified fields
|
136
|
+
* if set to "required". Otherwise also return the array unrequestedDisclosures with disclosures which can be passed for a particular use case.
|
270
137
|
* - Throws an error if a required field is invalid or missing.
|
271
138
|
*
|
272
139
|
* @param inputDescriptor - Describes constraints (fields, filters, etc.) that must be satisfied.
|
273
140
|
* @param payloadCredential - The credential payload to check against.
|
274
141
|
* @param disclosures - An array of DisclosureWithEncoded objects representing selective disclosures.
|
275
|
-
* @returns
|
142
|
+
* @returns A filtered list of disclosures satisfying the descriptor constraints, or throws an error if not.
|
276
143
|
* @throws Will throw an error if any required constraint fails or if JSONPath lookups are invalid.
|
277
144
|
*/
|
278
145
|
export const evaluateInputDescriptorForSdJwt4VC: EvaluateInputDescriptorSdJwt4VC =
|
@@ -282,12 +149,13 @@ export const evaluateInputDescriptorForSdJwt4VC: EvaluateInputDescriptorSdJwt4VC
|
|
282
149
|
return {
|
283
150
|
requiredDisclosures: [],
|
284
151
|
optionalDisclosures: [],
|
152
|
+
unrequestedDisclosures: disclosures,
|
285
153
|
};
|
286
154
|
}
|
287
|
-
const
|
288
|
-
const
|
155
|
+
const requiredClaimNames: string[] = [];
|
156
|
+
const optionalClaimNames: string[] = [];
|
289
157
|
|
290
|
-
// Transform disclosures
|
158
|
+
// Transform disclosures to find claim using JSONPath
|
291
159
|
const disclosuresAsPayload = mapDisclosuresToObject(disclosures);
|
292
160
|
|
293
161
|
// For each field, we need at least one matching path
|
@@ -315,10 +183,9 @@ export const evaluateInputDescriptorForSdJwt4VC: EvaluateInputDescriptorSdJwt4VC
|
|
315
183
|
// if match a disclouse we save which is required or optional
|
316
184
|
const claimName = extractClaimName(matchedPath);
|
317
185
|
if (claimName) {
|
318
|
-
(field?.optional ?
|
319
|
-
|
320
|
-
|
321
|
-
});
|
186
|
+
(field?.optional ? optionalClaimNames : requiredClaimNames).push(
|
187
|
+
claimName
|
188
|
+
);
|
322
189
|
}
|
323
190
|
}
|
324
191
|
|
@@ -348,12 +215,44 @@ export const evaluateInputDescriptorForSdJwt4VC: EvaluateInputDescriptorSdJwt4VC
|
|
348
215
|
);
|
349
216
|
}
|
350
217
|
|
218
|
+
// Categorizes disclosures into required and optional based on claim names and disclosure constraints.
|
219
|
+
|
220
|
+
const requiredDisclosures = disclosures.filter((disclosure) =>
|
221
|
+
requiredClaimNames.includes(disclosure.decoded[INDEX_CLAIM_NAME])
|
222
|
+
);
|
223
|
+
|
224
|
+
const optionalDisclosures = disclosures.filter((disclosure) =>
|
225
|
+
optionalClaimNames.includes(disclosure.decoded[INDEX_CLAIM_NAME])
|
226
|
+
);
|
227
|
+
|
228
|
+
const isNotLimitDisclosure = !(
|
229
|
+
inputDescriptor.constraints.limit_disclosure === "required"
|
230
|
+
);
|
231
|
+
|
232
|
+
const unrequestedDisclosures = isNotLimitDisclosure
|
233
|
+
? disclosures.filter(
|
234
|
+
(disclosure) =>
|
235
|
+
!optionalClaimNames.includes(
|
236
|
+
disclosure.decoded[INDEX_CLAIM_NAME]
|
237
|
+
) &&
|
238
|
+
!requiredClaimNames.includes(disclosure.decoded[INDEX_CLAIM_NAME])
|
239
|
+
)
|
240
|
+
: [];
|
241
|
+
|
351
242
|
return {
|
352
243
|
requiredDisclosures,
|
353
244
|
optionalDisclosures,
|
245
|
+
unrequestedDisclosures,
|
354
246
|
};
|
355
247
|
};
|
356
248
|
|
249
|
+
type DecodedCredentialSdJwt = {
|
250
|
+
keyTag: string;
|
251
|
+
credential: string;
|
252
|
+
sdJwt: SdJwt4VC;
|
253
|
+
disclosures: DisclosureWithEncoded[];
|
254
|
+
};
|
255
|
+
|
357
256
|
/**
|
358
257
|
* Finds the first credential that satisfies the input descriptor constraints.
|
359
258
|
* @param inputDescriptor The input descriptor to evaluate.
|
@@ -392,46 +291,12 @@ export const findCredentialSdJwt = (
|
|
392
291
|
}
|
393
292
|
}
|
394
293
|
|
395
|
-
throw new
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
* Finds the first credential that satisfies the input descriptor constraints.
|
402
|
-
* @param inputDescriptor The input descriptor to evaluate.
|
403
|
-
* @param decodedMdocCredentials An array of decoded MDOC credentials.
|
404
|
-
* @returns An object containing the matched evaluation, keyTag, and credential.
|
405
|
-
*/
|
406
|
-
export const findCredentialMDoc = (
|
407
|
-
inputDescriptor: InputDescriptor,
|
408
|
-
decodedMDocCredentials: DecodedCredentialMdoc[]
|
409
|
-
): {
|
410
|
-
matchedEvaluation: EvaluatedDisclosures;
|
411
|
-
matchedKeyTag: string;
|
412
|
-
matchedCredential: string;
|
413
|
-
} => {
|
414
|
-
for (const { keyTag, credential, issuerSigned } of decodedMDocCredentials) {
|
415
|
-
try {
|
416
|
-
const evaluatedDisclosure = evaluateInputDescriptorForMdoc(
|
417
|
-
inputDescriptor,
|
418
|
-
issuerSigned
|
419
|
-
);
|
420
|
-
|
421
|
-
return {
|
422
|
-
matchedEvaluation: evaluatedDisclosure,
|
423
|
-
matchedKeyTag: keyTag,
|
424
|
-
matchedCredential: credential,
|
425
|
-
};
|
426
|
-
} catch {
|
427
|
-
// skip to next credential
|
428
|
-
continue;
|
429
|
-
}
|
430
|
-
}
|
431
|
-
|
432
|
-
throw new CredentialNotFoundError(
|
433
|
-
"None of the mso_mdoc credentials satisfy the requirements."
|
434
|
-
);
|
294
|
+
throw new CredentialsNotFoundError([
|
295
|
+
{
|
296
|
+
id: "",
|
297
|
+
reason: "None of the vc+sd-jwt credentials satisfy the requirements.",
|
298
|
+
},
|
299
|
+
]);
|
435
300
|
};
|
436
301
|
|
437
302
|
/**
|
@@ -444,62 +309,31 @@ export const findCredentialMDoc = (
|
|
444
309
|
*
|
445
310
|
* @param inputDescriptors - An array of input descriptors.
|
446
311
|
* @param credentialsSdJwt - An array of tuples containing keyTag and SD-JWT credential.
|
447
|
-
* @param credentialsMdoc - An array of tuples containing keyTag and MDOC credential.
|
448
312
|
* @returns An array of objects, each containing the evaluated disclosures,
|
449
313
|
* the input descriptor, the credential, and the keyTag.
|
450
314
|
* @throws {CredentialNotFoundError} When the credential format is unsupported.
|
451
315
|
*/
|
452
316
|
export const evaluateInputDescriptors: EvaluateInputDescriptors = async (
|
453
317
|
inputDescriptors,
|
454
|
-
credentialsSdJwt
|
455
|
-
credentialsMdoc
|
318
|
+
credentialsSdJwt
|
456
319
|
) => {
|
457
320
|
// We need decode SD-JWT credentials for evaluation
|
458
321
|
const decodedSdJwtCredentials =
|
459
|
-
credentialsSdJwt?.map(([
|
322
|
+
credentialsSdJwt?.map(([keyTag, credential]) => {
|
460
323
|
const { sdJwt, disclosures } = decode(credential);
|
461
324
|
return { keyTag, credential, sdJwt, disclosures };
|
462
325
|
}) || [];
|
463
326
|
|
464
|
-
|
465
|
-
const decodedMdocCredentials =
|
466
|
-
(await Promise.all(
|
467
|
-
credentialsMdoc?.map(async ([, keyTag, credential]) => {
|
468
|
-
const issuerSigned = await CBOR.decodeIssuerSigned(credential);
|
469
|
-
if (!issuerSigned) {
|
470
|
-
throw new CredentialNotFoundError(
|
471
|
-
"mso_mdoc credential is not present."
|
472
|
-
);
|
473
|
-
}
|
474
|
-
return { keyTag, credential, issuerSigned };
|
475
|
-
})
|
476
|
-
)) || [];
|
477
|
-
|
478
|
-
const results = Promise.all(
|
327
|
+
return Promise.all(
|
479
328
|
inputDescriptors.map(async (descriptor) => {
|
480
|
-
if (descriptor.format?.mso_mdoc) {
|
481
|
-
if (!credentialsMdoc.length) {
|
482
|
-
throw new CredentialNotFoundError(
|
483
|
-
"mso_mdoc credential is not supported."
|
484
|
-
);
|
485
|
-
}
|
486
|
-
|
487
|
-
const { matchedEvaluation, matchedKeyTag, matchedCredential } =
|
488
|
-
findCredentialMDoc(descriptor, decodedMdocCredentials);
|
489
|
-
|
490
|
-
return {
|
491
|
-
evaluatedDisclosure: matchedEvaluation,
|
492
|
-
inputDescriptor: descriptor,
|
493
|
-
credential: matchedCredential,
|
494
|
-
keyTag: matchedKeyTag,
|
495
|
-
};
|
496
|
-
}
|
497
|
-
|
498
329
|
if (descriptor.format?.["vc+sd-jwt"]) {
|
499
330
|
if (!decodedSdJwtCredentials.length) {
|
500
|
-
throw new
|
501
|
-
|
502
|
-
|
331
|
+
throw new CredentialsNotFoundError([
|
332
|
+
{
|
333
|
+
id: descriptor.id,
|
334
|
+
reason: "vc+sd-jwt credential is not supported.",
|
335
|
+
},
|
336
|
+
]);
|
503
337
|
}
|
504
338
|
|
505
339
|
const { matchedEvaluation, matchedKeyTag, matchedCredential } =
|
@@ -513,11 +347,59 @@ export const evaluateInputDescriptors: EvaluateInputDescriptors = async (
|
|
513
347
|
};
|
514
348
|
}
|
515
349
|
|
516
|
-
throw new
|
517
|
-
|
518
|
-
|
350
|
+
throw new CredentialsNotFoundError([
|
351
|
+
{
|
352
|
+
id: descriptor.id,
|
353
|
+
reason: `${descriptor.format} format is not supported.`,
|
354
|
+
},
|
355
|
+
]);
|
519
356
|
})
|
520
357
|
);
|
521
|
-
|
522
|
-
return results;
|
523
358
|
};
|
359
|
+
|
360
|
+
/**
|
361
|
+
* Prepares remote presentations for a set of credentials based on input descriptors.
|
362
|
+
*
|
363
|
+
* For each credential and its corresponding input descriptor, this function:
|
364
|
+
* - Validates the credential format.
|
365
|
+
* - Generates a verifiable presentation token (vpToken) using the provided nonce and client identifier.
|
366
|
+
*
|
367
|
+
* @deprecated Use `prepareRemotePresentations` from DCQL
|
368
|
+
*
|
369
|
+
* @param credentialAndDescriptors - An array containing objects with requested claims,
|
370
|
+
* input descriptor, credential, and keyTag.
|
371
|
+
* @param nonce - A unique nonce for the verifiable presentation token.
|
372
|
+
* @param client_id - The client identifier.
|
373
|
+
* @returns A promise that resolves to an array of RemotePresentation objects.
|
374
|
+
* @throws {CredentialNotFoundError} When the credential format is unsupported.
|
375
|
+
*/
|
376
|
+
export const prepareLegacyRemotePresentations: PrepareLegacyRemotePresentations =
|
377
|
+
async (credentialAndDescriptors, nonce, client_id) => {
|
378
|
+
return Promise.all(
|
379
|
+
credentialAndDescriptors.map(async (item) => {
|
380
|
+
const descriptor = item.inputDescriptor;
|
381
|
+
|
382
|
+
if (descriptor.format?.["vc+sd-jwt"]) {
|
383
|
+
const { vp_token } = await prepareVpToken(nonce, client_id, [
|
384
|
+
item.credential,
|
385
|
+
item.requestedClaims,
|
386
|
+
createCryptoContextFor(item.keyTag),
|
387
|
+
]);
|
388
|
+
|
389
|
+
return {
|
390
|
+
requestedClaims: item.requestedClaims,
|
391
|
+
inputDescriptor: descriptor,
|
392
|
+
vpToken: vp_token,
|
393
|
+
format: "vc+sd-jwt",
|
394
|
+
};
|
395
|
+
}
|
396
|
+
|
397
|
+
throw new CredentialsNotFoundError([
|
398
|
+
{
|
399
|
+
id: descriptor.id,
|
400
|
+
reason: `${descriptor.format} format is not supported.`,
|
401
|
+
},
|
402
|
+
]);
|
403
|
+
})
|
404
|
+
);
|
405
|
+
};
|