@pagopa/io-react-native-wallet 1.7.1 → 2.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -1
- package/lib/commonjs/client/generated/wallet-provider.js +49 -20
- package/lib/commonjs/client/generated/wallet-provider.js.map +1 -1
- package/lib/commonjs/credential/index.js +5 -1
- package/lib/commonjs/credential/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js +27 -0
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js +25 -16
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +30 -18
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/05-authorize-access.js +17 -12
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +36 -29
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +27 -207
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/README.md +23 -20
- package/lib/commonjs/credential/issuance/const.js +1 -1
- package/lib/commonjs/credential/issuance/const.js.map +1 -1
- package/lib/commonjs/credential/issuance/index.js +3 -3
- package/lib/commonjs/credential/issuance/index.js.map +1 -1
- package/lib/commonjs/credential/presentation/01-start-flow.js +14 -15
- package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js +6 -4
- package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
- package/lib/commonjs/credential/presentation/03-get-request-object.js +34 -7
- package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js +4 -126
- package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
- package/lib/commonjs/credential/presentation/05-verify-request-object.js +80 -25
- package/lib/commonjs/credential/presentation/05-verify-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js +6 -30
- package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +97 -117
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +86 -191
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js +112 -176
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/commonjs/credential/presentation/README.md +74 -79
- package/lib/commonjs/credential/presentation/errors.js +42 -21
- package/lib/commonjs/credential/presentation/errors.js.map +1 -1
- package/lib/commonjs/credential/presentation/index.js +13 -13
- package/lib/commonjs/credential/presentation/index.js.map +1 -1
- package/lib/commonjs/credential/presentation/types.js +53 -29
- package/lib/commonjs/credential/presentation/types.js.map +1 -1
- package/lib/commonjs/credential/status/01-start-flow.js +2 -0
- package/lib/commonjs/credential/status/01-start-flow.js.map +1 -0
- package/lib/commonjs/credential/status/02-status-attestation.js +73 -0
- package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -0
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +55 -0
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
- package/lib/commonjs/credential/status/README.md +67 -0
- package/lib/commonjs/credential/status/index.js +27 -0
- package/lib/commonjs/credential/status/index.js.map +1 -0
- package/lib/commonjs/credential/status/types.js +48 -0
- package/lib/commonjs/credential/status/types.js.map +1 -0
- package/lib/commonjs/credential/trustmark/README.md +62 -0
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js +86 -0
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js.map +1 -0
- package/lib/commonjs/credential/trustmark/index.js +13 -0
- package/lib/commonjs/credential/trustmark/index.js.map +1 -0
- package/lib/commonjs/index.js +5 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/pid/sd-jwt/types.js +18 -2
- package/lib/commonjs/pid/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/index.test.js +22 -34
- package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/types.test.js +11 -23
- package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/index.js +1 -7
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/commonjs/sd-jwt/types.js +5 -21
- package/lib/commonjs/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/trust/README.md +147 -0
- package/lib/commonjs/trust/chain.js +153 -0
- package/lib/commonjs/trust/chain.js.map +1 -0
- package/lib/commonjs/trust/errors.js +133 -0
- package/lib/commonjs/trust/errors.js.map +1 -0
- package/lib/commonjs/trust/index.js +288 -0
- package/lib/commonjs/trust/index.js.map +1 -0
- package/lib/commonjs/{entity/trust → trust}/types.js +27 -47
- package/lib/commonjs/trust/types.js.map +1 -0
- package/lib/commonjs/trust/utils.js +70 -0
- package/lib/commonjs/trust/utils.js.map +1 -0
- package/lib/commonjs/utils/crypto.js +5 -112
- package/lib/commonjs/utils/crypto.js.map +1 -1
- package/lib/commonjs/utils/decoder.js +2 -0
- package/lib/commonjs/utils/decoder.js.map +1 -1
- package/lib/commonjs/utils/error-codes.js +22 -2
- package/lib/commonjs/utils/error-codes.js.map +1 -1
- package/lib/commonjs/utils/errors.js +72 -4
- package/lib/commonjs/utils/errors.js.map +1 -1
- package/lib/commonjs/utils/logging.js +68 -0
- package/lib/commonjs/utils/logging.js.map +1 -0
- package/lib/commonjs/utils/misc.js +2 -0
- package/lib/commonjs/utils/misc.js.map +1 -1
- package/lib/commonjs/utils/par.js +17 -10
- package/lib/commonjs/utils/par.js.map +1 -1
- package/lib/commonjs/utils/string.js +1 -12
- package/lib/commonjs/utils/string.js.map +1 -1
- package/lib/commonjs/wallet-instance/index.js +14 -0
- package/lib/commonjs/wallet-instance/index.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/README.md +8 -3
- package/lib/commonjs/wallet-instance-attestation/issuing.js +15 -8
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/types.js +16 -20
- package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
- package/lib/module/client/generated/wallet-provider.js +40 -15
- package/lib/module/client/generated/wallet-provider.js.map +1 -1
- package/lib/module/credential/index.js +3 -1
- package/lib/module/credential/index.js.map +1 -1
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +20 -0
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +1 -0
- package/lib/module/credential/issuance/03-start-user-authorization.js +25 -16
- package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js +30 -18
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/05-authorize-access.js +17 -11
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +36 -28
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +27 -205
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/issuance/README.md +23 -20
- package/lib/module/credential/issuance/const.js +1 -1
- package/lib/module/credential/issuance/const.js.map +1 -1
- package/lib/module/credential/issuance/index.js +2 -2
- package/lib/module/credential/issuance/index.js.map +1 -1
- package/lib/module/credential/presentation/01-start-flow.js +14 -15
- package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/module/credential/presentation/02-evaluate-rp-trust.js +5 -3
- package/lib/module/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
- package/lib/module/credential/presentation/03-get-request-object.js +34 -7
- package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/module/credential/presentation/04-retrieve-rp-jwks.js +2 -124
- package/lib/module/credential/presentation/04-retrieve-rp-jwks.js.map +1 -1
- package/lib/module/credential/presentation/05-verify-request-object.js +78 -23
- package/lib/module/credential/presentation/05-verify-request-object.js.map +1 -1
- package/lib/module/credential/presentation/06-fetch-presentation-definition.js +6 -30
- package/lib/module/credential/presentation/06-fetch-presentation-definition.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js +97 -118
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +83 -186
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/module/credential/presentation/08-send-authorization-response.js +107 -170
- package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/module/credential/presentation/README.md +74 -79
- package/lib/module/credential/presentation/errors.js +30 -17
- package/lib/module/credential/presentation/errors.js.map +1 -1
- package/lib/module/credential/presentation/index.js +6 -6
- package/lib/module/credential/presentation/index.js.map +1 -1
- package/lib/module/credential/presentation/types.js +49 -27
- package/lib/module/credential/presentation/types.js.map +1 -1
- package/lib/module/credential/status/01-start-flow.js +2 -0
- package/lib/module/credential/status/01-start-flow.js.map +1 -0
- package/lib/module/credential/status/02-status-attestation.js +66 -0
- package/lib/module/credential/status/02-status-attestation.js.map +1 -0
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +49 -0
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +1 -0
- package/lib/module/credential/status/README.md +67 -0
- package/lib/module/credential/status/index.js +5 -0
- package/lib/module/credential/status/index.js.map +1 -0
- package/lib/module/credential/status/types.js +40 -0
- package/lib/module/credential/status/types.js.map +1 -0
- package/lib/module/credential/trustmark/README.md +62 -0
- package/lib/module/credential/trustmark/get-credential-trustmark.js +77 -0
- package/lib/module/credential/trustmark/get-credential-trustmark.js.map +1 -0
- package/lib/module/credential/trustmark/index.js +3 -0
- package/lib/module/credential/trustmark/index.js.map +1 -0
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/pid/sd-jwt/types.js +16 -1
- package/lib/module/pid/sd-jwt/types.js.map +1 -1
- package/lib/module/sd-jwt/__test__/index.test.js +22 -34
- package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/module/sd-jwt/__test__/types.test.js +11 -23
- package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/module/sd-jwt/index.js +1 -7
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/module/sd-jwt/types.js +4 -19
- package/lib/module/sd-jwt/types.js.map +1 -1
- package/lib/module/trust/README.md +147 -0
- package/lib/module/trust/chain.js +145 -0
- package/lib/module/trust/chain.js.map +1 -0
- package/lib/module/trust/errors.js +115 -0
- package/lib/module/trust/errors.js.map +1 -0
- package/lib/module/trust/index.js +269 -0
- package/lib/module/trust/index.js.map +1 -0
- package/lib/module/{entity/trust → trust}/types.js +25 -46
- package/lib/module/trust/types.js.map +1 -0
- package/lib/module/trust/utils.js +60 -0
- package/lib/module/trust/utils.js.map +1 -0
- package/lib/module/utils/crypto.js +4 -107
- package/lib/module/utils/crypto.js.map +1 -1
- package/lib/module/utils/decoder.js +3 -0
- package/lib/module/utils/decoder.js.map +1 -1
- package/lib/module/utils/error-codes.js +20 -1
- package/lib/module/utils/error-codes.js.map +1 -1
- package/lib/module/utils/errors.js +61 -4
- package/lib/module/utils/errors.js.map +1 -1
- package/lib/module/utils/logging.js +62 -0
- package/lib/module/utils/logging.js.map +1 -0
- package/lib/module/utils/misc.js +2 -0
- package/lib/module/utils/misc.js.map +1 -1
- package/lib/module/utils/par.js +17 -9
- package/lib/module/utils/par.js.map +1 -1
- package/lib/module/utils/string.js +0 -10
- package/lib/module/utils/string.js.map +1 -1
- package/lib/module/wallet-instance/index.js +13 -0
- package/lib/module/wallet-instance/index.js.map +1 -1
- package/lib/module/wallet-instance-attestation/README.md +8 -3
- package/lib/module/wallet-instance-attestation/index.js +2 -2
- package/lib/module/wallet-instance-attestation/index.js.map +1 -1
- package/lib/module/wallet-instance-attestation/issuing.js +16 -9
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/wallet-instance-attestation/types.js +14 -18
- package/lib/module/wallet-instance-attestation/types.js.map +1 -1
- package/lib/typescript/client/generated/wallet-provider.d.ts +206 -51
- package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
- package/lib/typescript/credential/index.d.ts +3 -1
- package/lib/typescript/credential/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -1
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts +19 -0
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +3 -3
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +9 -9
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts +3 -3
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +4 -4
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +3 -15
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/const.d.ts +1 -1
- package/lib/typescript/credential/issuance/const.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/index.d.ts +3 -3
- package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/types.d.ts +8 -3
- package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/01-start-flow.d.ts +28 -9
- package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts +2 -1
- package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts +7 -5
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts +4 -30
- package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts +17 -4
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts +4 -9
- package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +13 -12
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +40 -42
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +30 -43
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/errors.d.ts +25 -10
- package/lib/typescript/credential/presentation/errors.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/index.d.ts +7 -8
- package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/types.d.ts +137 -307
- package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
- package/lib/typescript/credential/status/01-start-flow.d.ts +10 -0
- package/lib/typescript/credential/status/01-start-flow.d.ts.map +1 -0
- package/lib/typescript/credential/status/02-status-attestation.d.ts +19 -0
- package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -0
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts +24 -0
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +1 -0
- package/lib/typescript/credential/status/index.d.ts +7 -0
- package/lib/typescript/credential/status/index.d.ts.map +1 -0
- package/lib/typescript/credential/status/types.d.ts +305 -0
- package/lib/typescript/credential/status/types.d.ts.map +1 -0
- package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts +52 -0
- package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts.map +1 -0
- package/lib/typescript/credential/trustmark/index.d.ts +4 -0
- package/lib/typescript/credential/trustmark/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +3 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/pid/sd-jwt/types.d.ts +103 -25
- package/lib/typescript/pid/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/index.d.ts +20 -72
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/types.d.ts +24 -129
- package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/trust/chain.d.ts +23 -0
- package/lib/typescript/trust/chain.d.ts.map +1 -0
- package/lib/typescript/trust/errors.d.ts +102 -0
- package/lib/typescript/trust/errors.d.ts.map +1 -0
- package/lib/typescript/{entity/trust → trust}/index.d.ts +308 -281
- package/lib/typescript/trust/index.d.ts.map +1 -0
- package/lib/typescript/{entity/trust → trust}/types.d.ts +1714 -1301
- package/lib/typescript/{entity/trust → trust}/types.d.ts.map +1 -1
- package/lib/typescript/trust/utils.d.ts +22 -0
- package/lib/typescript/trust/utils.d.ts.map +1 -0
- package/lib/typescript/utils/crypto.d.ts +0 -32
- package/lib/typescript/utils/crypto.d.ts.map +1 -1
- package/lib/typescript/utils/decoder.d.ts.map +1 -1
- package/lib/typescript/utils/error-codes.d.ts +20 -0
- package/lib/typescript/utils/error-codes.d.ts.map +1 -1
- package/lib/typescript/utils/errors.d.ts +55 -10
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/logging.d.ts +35 -0
- package/lib/typescript/utils/logging.d.ts.map +1 -0
- package/lib/typescript/utils/misc.d.ts.map +1 -1
- package/lib/typescript/utils/par.d.ts +8 -1
- package/lib/typescript/utils/par.d.ts.map +1 -1
- package/lib/typescript/utils/string.d.ts +0 -7
- package/lib/typescript/utils/string.d.ts.map +1 -1
- package/lib/typescript/wallet-instance/index.d.ts +8 -0
- package/lib/typescript/wallet-instance/index.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/index.d.ts +1 -2
- package/lib/typescript/wallet-instance-attestation/index.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts +4 -2
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/types.d.ts +60 -102
- package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
- package/package.json +9 -10
- package/src/client/generated/wallet-provider.ts +52 -17
- package/src/credential/index.ts +4 -1
- package/src/credential/issuance/01-start-flow.ts +1 -1
- package/src/credential/issuance/02-evaluate-issuer-trust.ts +32 -0
- package/src/credential/issuance/03-start-user-authorization.ts +48 -22
- package/src/credential/issuance/04-complete-user-authorization.ts +74 -18
- package/src/credential/issuance/05-authorize-access.ts +29 -11
- package/src/credential/issuance/06-obtain-credential.ts +61 -36
- package/src/credential/issuance/07-verify-and-parse-credential.ts +37 -264
- package/src/credential/issuance/README.md +23 -20
- package/src/credential/issuance/const.ts +1 -1
- package/src/credential/issuance/index.ts +6 -3
- package/src/credential/presentation/01-start-flow.ts +19 -22
- package/src/credential/presentation/02-evaluate-rp-trust.ts +5 -4
- package/src/credential/presentation/03-get-request-object.ts +36 -8
- package/src/credential/presentation/04-retrieve-rp-jwks.ts +6 -148
- package/src/credential/presentation/05-verify-request-object.ts +115 -30
- package/src/credential/presentation/06-fetch-presentation-definition.ts +5 -35
- package/src/credential/presentation/07-evaluate-dcql-query.ts +132 -161
- package/src/credential/presentation/07-evaluate-input-descriptor.ts +136 -254
- package/src/credential/presentation/08-send-authorization-response.ts +178 -260
- package/src/credential/presentation/README.md +74 -79
- package/src/credential/presentation/errors.ts +38 -15
- package/src/credential/presentation/index.ts +18 -19
- package/src/credential/presentation/types.ts +67 -64
- package/src/credential/status/01-start-flow.ts +9 -0
- package/src/credential/status/02-status-attestation.ts +105 -0
- package/src/credential/status/03-verify-and-parse-status-attestation.ts +70 -0
- package/src/credential/status/README.md +67 -0
- package/src/credential/status/index.ts +22 -0
- package/src/credential/status/types.ts +43 -0
- package/src/credential/trustmark/README.md +62 -0
- package/src/credential/trustmark/get-credential-trustmark.ts +139 -0
- package/src/credential/trustmark/index.ts +8 -0
- package/src/index.ts +4 -0
- package/src/pid/sd-jwt/types.ts +18 -1
- package/src/sd-jwt/__test__/index.test.ts +36 -55
- package/src/sd-jwt/__test__/types.test.ts +16 -29
- package/src/sd-jwt/index.ts +1 -5
- package/src/sd-jwt/types.ts +2 -19
- package/src/trust/README.md +147 -0
- package/src/trust/chain.ts +227 -0
- package/src/trust/errors.ts +136 -0
- package/src/{entity/trust → trust}/index.ts +207 -25
- package/src/{entity/trust → trust}/types.ts +24 -37
- package/src/trust/utils.ts +70 -0
- package/src/utils/crypto.ts +4 -106
- package/src/utils/decoder.ts +6 -1
- package/src/utils/error-codes.ts +23 -0
- package/src/utils/errors.ts +119 -15
- package/src/utils/logging.ts +68 -0
- package/src/utils/misc.ts +5 -0
- package/src/utils/par.ts +19 -6
- package/src/utils/string.ts +0 -10
- package/src/wallet-instance/index.ts +30 -1
- package/src/wallet-instance-attestation/README.md +8 -3
- package/src/wallet-instance-attestation/index.ts +2 -2
- package/src/wallet-instance-attestation/issuing.ts +33 -12
- package/src/wallet-instance-attestation/types.ts +18 -22
- package/lib/commonjs/credential/issuance/02-get-issuer-config.js +0 -48
- package/lib/commonjs/credential/issuance/02-get-issuer-config.js.map +0 -1
- package/lib/commonjs/entity/openid-connect/issuer/index.js +0 -25
- package/lib/commonjs/entity/openid-connect/issuer/index.js.map +0 -1
- package/lib/commonjs/entity/openid-connect/issuer/types.js +0 -64
- package/lib/commonjs/entity/openid-connect/issuer/types.js.map +0 -1
- package/lib/commonjs/entity/trust/chain.js +0 -122
- package/lib/commonjs/entity/trust/chain.js.map +0 -1
- package/lib/commonjs/entity/trust/index.js +0 -148
- package/lib/commonjs/entity/trust/index.js.map +0 -1
- package/lib/commonjs/entity/trust/types.js.map +0 -1
- package/lib/commonjs/mdoc/converters.js +0 -26
- package/lib/commonjs/mdoc/converters.js.map +0 -1
- package/lib/commonjs/mdoc/index.js +0 -68
- package/lib/commonjs/mdoc/index.js.map +0 -1
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -469
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -90
- package/lib/commonjs/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
- package/lib/module/credential/issuance/02-get-issuer-config.js +0 -42
- package/lib/module/credential/issuance/02-get-issuer-config.js.map +0 -1
- package/lib/module/entity/openid-connect/issuer/index.js +0 -20
- package/lib/module/entity/openid-connect/issuer/index.js.map +0 -1
- package/lib/module/entity/openid-connect/issuer/types.js +0 -48
- package/lib/module/entity/openid-connect/issuer/types.js.map +0 -1
- package/lib/module/entity/trust/chain.js +0 -113
- package/lib/module/entity/trust/chain.js.map +0 -1
- package/lib/module/entity/trust/index.js +0 -131
- package/lib/module/entity/trust/index.js.map +0 -1
- package/lib/module/entity/trust/types.js.map +0 -1
- package/lib/module/mdoc/converters.js +0 -20
- package/lib/module/mdoc/converters.js.map +0 -1
- package/lib/module/mdoc/index.js +0 -60
- package/lib/module/mdoc/index.js.map +0 -1
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js +0 -462
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-inputs.js.map +0 -1
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js +0 -83
- package/lib/module/utils/credential/issuance/07-verify-and-parse-credentials-utils.js.map +0 -1
- package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts +0 -32
- package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts.map +0 -1
- package/lib/typescript/entity/openid-connect/issuer/index.d.ts +0 -12
- package/lib/typescript/entity/openid-connect/issuer/index.d.ts.map +0 -1
- package/lib/typescript/entity/openid-connect/issuer/types.d.ts +0 -777
- package/lib/typescript/entity/openid-connect/issuer/types.d.ts.map +0 -1
- package/lib/typescript/entity/trust/chain.d.ts +0 -26
- package/lib/typescript/entity/trust/chain.d.ts.map +0 -1
- package/lib/typescript/entity/trust/index.d.ts.map +0 -1
- package/lib/typescript/mdoc/converters.d.ts +0 -8
- package/lib/typescript/mdoc/converters.d.ts.map +0 -1
- package/lib/typescript/mdoc/index.d.ts +0 -10
- package/lib/typescript/mdoc/index.d.ts.map +0 -1
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts +0 -3
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-inputs.d.ts.map +0 -1
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts +0 -42
- package/lib/typescript/utils/credential/issuance/07-verify-and-parse-credentials-utils.d.ts.map +0 -1
- package/src/credential/issuance/02-get-issuer-config.ts +0 -67
- package/src/entity/openid-connect/issuer/index.ts +0 -27
- package/src/entity/openid-connect/issuer/types.ts +0 -76
- package/src/entity/trust/chain.ts +0 -154
- package/src/mdoc/converters.ts +0 -26
- package/src/mdoc/index.ts +0 -95
- package/src/utils/credential/issuance/07-verify-and-parse-credentials-inputs.ts +0 -615
- package/src/utils/credential/issuance/07-verify-and-parse-credentials-utils.ts +0 -171
@@ -0,0 +1,70 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.decode = void 0;
|
7
|
+
exports.getTrustAnchorX509Certificate = getTrustAnchorX509Certificate;
|
8
|
+
exports.verify = void 0;
|
9
|
+
var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
|
10
|
+
var _errors = require("./errors");
|
11
|
+
// Verify a token signature
|
12
|
+
// The kid is extracted from the token header
|
13
|
+
const verify = async (token, kid, jwks) => {
|
14
|
+
const jwk = jwks.find(k => k.kid === kid);
|
15
|
+
if (!jwk) {
|
16
|
+
throw new Error(`Invalid kid: ${kid}, token: ${token}`);
|
17
|
+
}
|
18
|
+
const {
|
19
|
+
protectedHeader: header,
|
20
|
+
payload
|
21
|
+
} = await (0, _ioReactNativeJwt.verify)(token, jwk);
|
22
|
+
return {
|
23
|
+
header,
|
24
|
+
payload
|
25
|
+
};
|
26
|
+
};
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Return type for this function is necessary to avoid an issue during the bob build process.
|
30
|
+
* It seems like typescript can't correctly infer the return type of the function.
|
31
|
+
*/
|
32
|
+
exports.verify = verify;
|
33
|
+
const decode = token => {
|
34
|
+
const {
|
35
|
+
protectedHeader: header,
|
36
|
+
payload
|
37
|
+
} = (0, _ioReactNativeJwt.decode)(token);
|
38
|
+
return {
|
39
|
+
header,
|
40
|
+
payload
|
41
|
+
};
|
42
|
+
};
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Extracts the X.509 Trust Anchor certificate (Base64 encoded) from the
|
46
|
+
* Trust Anchor's Entity Configuration.
|
47
|
+
*
|
48
|
+
* @param trustAnchorEntity The entity configuration of the known trust anchor.
|
49
|
+
* @returns The Base64 encoded X.509 certificate string.
|
50
|
+
* @throws {FederationError} If the certificate cannot be derived.
|
51
|
+
*/
|
52
|
+
exports.decode = decode;
|
53
|
+
function getTrustAnchorX509Certificate(trustAnchorEntity) {
|
54
|
+
const taHeaderKid = trustAnchorEntity.header.kid;
|
55
|
+
const taSigningJwk = trustAnchorEntity.payload.jwks.keys.find(key => key.kid === taHeaderKid);
|
56
|
+
if (!taSigningJwk) {
|
57
|
+
throw new _errors.FederationError(`Cannot derive X.509 Trust Anchor certificate: JWK with kid '${taHeaderKid}' not found in Trust Anchor's JWKS.`, {
|
58
|
+
trustAnchorKid: taHeaderKid,
|
59
|
+
reason: "JWK not found for header kid"
|
60
|
+
});
|
61
|
+
}
|
62
|
+
if (taSigningJwk.x5c && taSigningJwk.x5c.length > 0 && taSigningJwk.x5c[0]) {
|
63
|
+
return taSigningJwk.x5c[0];
|
64
|
+
}
|
65
|
+
throw new _errors.FederationError(`Cannot derive X.509 Trust Anchor certificate: JWK with kid '${taHeaderKid}' does not contain a valid 'x5c' certificate array.`, {
|
66
|
+
trustAnchorKid: taHeaderKid,
|
67
|
+
reason: "Missing or empty x5c in JWK"
|
68
|
+
});
|
69
|
+
}
|
70
|
+
//# sourceMappingURL=utils.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_ioReactNativeJwt","require","_errors","verify","token","kid","jwks","jwk","find","k","Error","protectedHeader","header","payload","verifyJwt","exports","decode","decodeJwt","getTrustAnchorX509Certificate","trustAnchorEntity","taHeaderKid","taSigningJwk","keys","key","FederationError","trustAnchorKid","reason","x5c","length"],"sourceRoot":"../../../src","sources":["trust/utils.ts"],"mappings":";;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAD,OAAA;AAQA;AACA;AACO,MAAME,MAAM,GAAG,MAAAA,CACpBC,KAAa,EACbC,GAAW,EACXC,IAAW,KACc;EACzB,MAAMC,GAAG,GAAGD,IAAI,CAACE,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACJ,GAAG,KAAKA,GAAG,CAAC;EAC3C,IAAI,CAACE,GAAG,EAAE;IACR,MAAM,IAAIG,KAAK,CA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,cAAc,EAAEL,WAAW;IAAEM,MAAM,EAAE;EAA8B,CACvE,CAAC;AACH"}
|
@@ -3,14 +3,11 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.withEphemeralKey = exports.
|
6
|
+
exports.withEphemeralKey = exports.createCryptoContextFor = void 0;
|
7
7
|
var _ioReactNativeCrypto = require("@pagopa/io-react-native-crypto");
|
8
|
-
var
|
8
|
+
var _uuid = require("uuid");
|
9
9
|
var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
|
10
|
-
var _jsrsasign = require("jsrsasign");
|
11
10
|
var _jwk = require("./jwk");
|
12
|
-
var _buffer = require("buffer");
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
11
|
/**
|
15
12
|
* Create a CryptoContext bound to a key pair.
|
16
13
|
* Key pair is supposed to exist already in the device's keychain.
|
@@ -26,7 +23,7 @@ const createCryptoContextFor = keytag => {
|
|
26
23
|
* @returns The public key.
|
27
24
|
*/
|
28
25
|
async getPublicKey() {
|
29
|
-
return (0, _ioReactNativeCrypto.getPublicKey)(keytag).then(
|
26
|
+
return (0, _ioReactNativeCrypto.getPublicKey)(keytag).then(_jwk.fixBase64EncodingOnKey).then(async jwk => ({
|
30
27
|
...jwk,
|
31
28
|
// Keys in the TEE are not stored with their KID, which is supposed to be assigned when they are included in JWK sets.
|
32
29
|
// (that is, KID is not a propoerty of the key itself, but it's property used to identify a key in a set).
|
@@ -47,59 +44,6 @@ const createCryptoContextFor = keytag => {
|
|
47
44
|
};
|
48
45
|
};
|
49
46
|
|
50
|
-
/**
|
51
|
-
* This function takes a JSON Web Key (JWK) and returns a new JWK with its base64-url properties (x, y, e, n) processed.
|
52
|
-
* Each property is passed through the `removeLeadingZeroAndParseb64u` function if it exists, which fixes any unwanted leading zeros.
|
53
|
-
*
|
54
|
-
* @param key - The input JSON Web Key that may contain properties with potential leading zero issues.
|
55
|
-
* @returns A new JSON Web Key with the processed properties.
|
56
|
-
*/
|
57
|
-
exports.createCryptoContextFor = createCryptoContextFor;
|
58
|
-
const fixBase64WithLeadingZero = key => {
|
59
|
-
const {
|
60
|
-
x,
|
61
|
-
y,
|
62
|
-
e,
|
63
|
-
n,
|
64
|
-
...pk
|
65
|
-
} = key;
|
66
|
-
return {
|
67
|
-
...pk,
|
68
|
-
...(x ? {
|
69
|
-
x: removeLeadingZeroAndParseb64u(x)
|
70
|
-
} : {}),
|
71
|
-
...(y ? {
|
72
|
-
y: removeLeadingZeroAndParseb64u(y)
|
73
|
-
} : {}),
|
74
|
-
...(e ? {
|
75
|
-
e: removeLeadingZeroAndParseb64u(e)
|
76
|
-
} : {}),
|
77
|
-
...(n ? {
|
78
|
-
n: removeLeadingZeroAndParseb64u(n)
|
79
|
-
} : {})
|
80
|
-
};
|
81
|
-
};
|
82
|
-
|
83
|
-
/**
|
84
|
-
* This function processes a base64-encoded string to remove any unwanted leading zeros.
|
85
|
-
* It converts the input base64 string into a buffer, then to a hex string, checks for a leading "00",
|
86
|
-
* and removes it if present. The result is then converted back to a base64-url.
|
87
|
-
*
|
88
|
-
* @param input - The base64 encoded string to process.
|
89
|
-
* @returns A new base64-url encoded string with any leading zero removed.
|
90
|
-
*/
|
91
|
-
const removeLeadingZeroAndParseb64u = input => {
|
92
|
-
// Decode base64 input into a Buffer
|
93
|
-
const buffer = _buffer.Buffer.from(input, "base64");
|
94
|
-
const hex = buffer.toString("hex");
|
95
|
-
// If the hex string starts with "00", remove the first two characters
|
96
|
-
const fixedHex = hex.startsWith("00") ? hex.slice(2) : hex;
|
97
|
-
const newBuffer = _buffer.Buffer.from(fixedHex, "hex");
|
98
|
-
|
99
|
-
// removePadding convert base64 string to base64-url
|
100
|
-
return (0, _ioReactNativeJwt.removePadding)(newBuffer.toString("base64"));
|
101
|
-
};
|
102
|
-
|
103
47
|
/**
|
104
48
|
* Executes the input function injecting an ephemeral crypto context.
|
105
49
|
* An ephemeral crypto context is a context which is bound to a key
|
@@ -108,64 +52,13 @@ const removeLeadingZeroAndParseb64u = input => {
|
|
108
52
|
* @param fn The procedure to be executed
|
109
53
|
* @returns The returned value of the input procedure.
|
110
54
|
*/
|
55
|
+
exports.createCryptoContextFor = createCryptoContextFor;
|
111
56
|
const withEphemeralKey = async fn => {
|
112
57
|
// Use an ephemeral key to be destroyed after use
|
113
|
-
const keytag = `ephemeral-${
|
58
|
+
const keytag = `ephemeral-${(0, _uuid.v4)()}`;
|
114
59
|
await (0, _ioReactNativeCrypto.generate)(keytag);
|
115
60
|
const ephemeralContext = createCryptoContextFor(keytag);
|
116
61
|
return fn(ephemeralContext).finally(() => (0, _ioReactNativeCrypto.deleteKey)(keytag));
|
117
62
|
};
|
118
|
-
|
119
|
-
/**
|
120
|
-
* Converts a certificate string to PEM format.
|
121
|
-
*
|
122
|
-
* @param certificate - The certificate string.
|
123
|
-
* @returns The PEM-formatted certificate.
|
124
|
-
*/
|
125
63
|
exports.withEphemeralKey = withEphemeralKey;
|
126
|
-
const convertCertToPem = certificate => `-----BEGIN CERTIFICATE-----\n${certificate}\n-----END CERTIFICATE-----`;
|
127
|
-
|
128
|
-
/**
|
129
|
-
* Parses the public key from a PEM-formatted certificate.
|
130
|
-
*
|
131
|
-
* @param pemCert - The PEM-formatted certificate.
|
132
|
-
* @returns The public key object.
|
133
|
-
* @throws Will throw an error if the public key is unsupported.
|
134
|
-
*/
|
135
|
-
exports.convertCertToPem = convertCertToPem;
|
136
|
-
const parsePublicKey = pemCert => {
|
137
|
-
const x509 = new _jsrsasign.X509();
|
138
|
-
x509.readCertPEM(pemCert);
|
139
|
-
const publicKey = x509.getPublicKey();
|
140
|
-
if (publicKey instanceof _jsrsasign.RSAKey || publicKey instanceof _jsrsasign.KJUR.crypto.ECDSA) {
|
141
|
-
return publicKey;
|
142
|
-
}
|
143
|
-
return undefined;
|
144
|
-
};
|
145
|
-
|
146
|
-
/**
|
147
|
-
* Retrieves the signing JWK from the public key.
|
148
|
-
*
|
149
|
-
* @param publicKey - The public key object.
|
150
|
-
* @returns The signing JWK.
|
151
|
-
*/
|
152
|
-
exports.parsePublicKey = parsePublicKey;
|
153
|
-
const getSigningJwk = publicKey => ({
|
154
|
-
..._jwk.JWK.parse(_jsrsasign.KEYUTIL.getJWKFromKey(publicKey)),
|
155
|
-
use: "sig"
|
156
|
-
});
|
157
|
-
|
158
|
-
/**
|
159
|
-
* This function takes two {@link PublicKey} and evaluates and compares their thumbprints
|
160
|
-
* @param key1 The first key
|
161
|
-
* @param key2 The second key
|
162
|
-
* @returns true if the keys' thumbprints are equal, false otherwise
|
163
|
-
*/
|
164
|
-
exports.getSigningJwk = getSigningJwk;
|
165
|
-
const compareKeysByThumbprint = async (key1, key2) => {
|
166
|
-
//Parallel for optimization
|
167
|
-
const [thumbprint1, thumbprint2] = await Promise.all([(0, _ioReactNativeJwt.thumbprint)(key1), (0, _ioReactNativeJwt.thumbprint)(key2)]);
|
168
|
-
return thumbprint1 === thumbprint2;
|
169
|
-
};
|
170
|
-
exports.compareKeysByThumbprint = compareKeysByThumbprint;
|
171
64
|
//# sourceMappingURL=crypto.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_ioReactNativeCrypto","require","
|
1
|
+
{"version":3,"names":["_ioReactNativeCrypto","require","_uuid","_ioReactNativeJwt","_jwk","createCryptoContextFor","keytag","getPublicKey","then","fixBase64EncodingOnKey","jwk","kid","thumbprint","getSignature","value","sign","exports","withEphemeralKey","fn","uuidv4","generate","ephemeralContext","finally","deleteKey"],"sourceRoot":"../../../src","sources":["utils/crypto.ts"],"mappings":";;;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AAMA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMI,sBAAsB,GAAIC,MAAc,IAAoB;EACvE,OAAO;IACL;AACJ;AACA;AACA;AACA;IACI,MAAMC,YAAYA,CAAA,EAAG;MACnB,OAAO,IAAAA,iCAAY,EAACD,MAAM,CAAC,CACxBE,IAAI,CAACC,2BAAsB,CAAC,CAC5BD,IAAI,CAAC,MAAOE,GAAG,KAAM;QACpB,GAAGA,GAAG;QACN;QACA;QACA;QACA;QACAC,GAAG,EAAE,MAAM,IAAAC,4BAAU,EAACF,GAAG;MAC3B,CAAC,CAAC,CAAC;IACP,CAAC;IACD;AACJ;AACA;AACA;AACA;AACA;IACI,MAAMG,YAAYA,CAACC,KAAa,EAAE;MAChC,OAAO,IAAAC,yBAAI,EAACD,KAAK,EAAER,MAAM,CAAC;IAC5B;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAU,OAAA,CAAAX,sBAAA,GAAAA,sBAAA;AAQO,MAAMY,gBAAgB,GAAG,MAC9BC,EAAmD,IACpC;EACf;EACA,MAAMZ,MAAM,GAAI,aAAY,IAAAa,QAAM,EAAC,CAAE,EAAC;EACtC,MAAM,IAAAC,6BAAQ,EAACd,MAAM,CAAC;EACtB,MAAMe,gBAAgB,GAAGhB,sBAAsB,CAACC,MAAM,CAAC;EACvD,OAAOY,EAAE,CAACG,gBAAgB,CAAC,CAACC,OAAO,CAAC,MAAM,IAAAC,8BAAS,EAACjB,MAAM,CAAC,CAAC;AAC9D,CAAC;AAACU,OAAA,CAAAC,gBAAA,GAAAA,gBAAA"}
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.getJwtFromFormPost = void 0;
|
7
7
|
var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
|
8
8
|
var _errors = require("./errors");
|
9
|
+
var _logging = require("./logging");
|
9
10
|
/*
|
10
11
|
* Decode a form_post.jwt and return the final JWT.
|
11
12
|
* The formData here is in form_post.jwt format as defined in
|
@@ -49,6 +50,7 @@ const getJwtFromFormPost = async formData => {
|
|
49
50
|
};
|
50
51
|
}
|
51
52
|
}
|
53
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Unable to obtain JWT from form_post.jwt. Form data: ${formData}`);
|
52
54
|
throw new _errors.ValidationFailed({
|
53
55
|
message: `Unable to obtain JWT from form_post.jwt. Form data: ${formData}`
|
54
56
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_ioReactNativeJwt","require","_errors","getJwtFromFormPost","formData","formPostRegex","lineExpressionRegex","match","exec","responseJwt","jwt","replace","decodedJwt","decodeJwt","ValidationFailed","message","exports"],"sourceRoot":"../../../src","sources":["utils/decoder.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;
|
1
|
+
{"version":3,"names":["_ioReactNativeJwt","require","_errors","_logging","getJwtFromFormPost","formData","formPostRegex","lineExpressionRegex","match","exec","responseJwt","jwt","replace","decodedJwt","decodeJwt","Logger","log","LogLevel","ERROR","ValidationFailed","message","exports"],"sourceRoot":"../../../src","sources":["utils/decoder.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,kBAAkB,GAAG,MAChCC,QAAgB,IAC0C;EAC1D,MAAMC,aAAa,GAAG,iDAAiD;EACvE,MAAMC,mBAAmB,GAAG,sBAAsB;EAElD,MAAMC,KAAK,GAAGF,aAAa,CAACG,IAAI,CAACJ,QAAQ,CAAC;EAC1C,IAAIG,KAAK,IAAIA,KAAK,CAAC,CAAC,CAAC,EAAE;IACrB,MAAME,WAAW,GAAGF,KAAK,CAAC,CAAC,CAAC;IAE5B,IAAIE,WAAW,EAAE;MACf,MAAMC,GAAG,GAAGD,WAAW,CAACE,OAAO,CAACL,mBAAmB,EAAE,EAAE,CAAC;MACxD,MAAMM,UAAU,GAAG,IAAAC,wBAAS,EAACH,GAAG,CAAC;MACjC,OAAO;QAAEA,GAAG;QAAEE;MAAW,CAAC;IAC5B;EACF;EAEAE,eAAM,CAACC,GAAG,CACRC,iBAAQ,CAACC,KAAK,EACb,uDAAsDb,QAAS,EAClE,CAAC;EACD,MAAM,IAAIc,wBAAgB,CAAC;IACzBC,OAAO,EAAG,uDAAsDf,QAAS;EAC3E,CAAC,CAAC;AACJ,CAAC;AAACgB,OAAA,CAAAjB,kBAAA,GAAAA,kBAAA"}
|
@@ -3,13 +3,25 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.WalletProviderResponseErrorCodes = exports.IssuerResponseErrorCodes = void 0;
|
6
|
+
exports.WalletProviderResponseErrorCodes = exports.RelyingPartyResponseErrorCodes = exports.IssuerResponseErrorCodes = void 0;
|
7
7
|
const IssuerResponseErrorCodes = {
|
8
8
|
IssuerGenericError: "ERR_ISSUER_GENERIC_ERROR",
|
9
|
+
/**
|
10
|
+
* Error code thrown when a credential cannot be issued immediately because it follows the async flow.
|
11
|
+
*/
|
12
|
+
CredentialIssuingNotSynchronous: "ERR_CREDENTIAL_ISSUING_NOT_SYNCHRONOUS",
|
9
13
|
/**
|
10
14
|
* Error code thrown when an error occurs while requesting a credential.
|
11
15
|
*/
|
12
|
-
CredentialRequestFailed: "ERR_CREDENTIAL_REQUEST_FAILED"
|
16
|
+
CredentialRequestFailed: "ERR_CREDENTIAL_REQUEST_FAILED",
|
17
|
+
/**
|
18
|
+
* Error code thrown when a credential status is invalid, either during issuance or when requesting a status attestation.
|
19
|
+
*/
|
20
|
+
CredentialInvalidStatus: "ERR_CREDENTIAL_INVALID_STATUS",
|
21
|
+
/**
|
22
|
+
* Error code thrown when an error occurs while obtaining a status attestation for a credential.
|
23
|
+
*/
|
24
|
+
StatusAttestationRequestFailed: "ERR_STATUS_ATTESTATION_REQUEST_FAILED"
|
13
25
|
};
|
14
26
|
exports.IssuerResponseErrorCodes = IssuerResponseErrorCodes;
|
15
27
|
const WalletProviderResponseErrorCodes = {
|
@@ -36,4 +48,12 @@ const WalletProviderResponseErrorCodes = {
|
|
36
48
|
WalletInstanceNotFound: "ERR_IO_WALLET_INSTANCE_NOT_FOUND"
|
37
49
|
};
|
38
50
|
exports.WalletProviderResponseErrorCodes = WalletProviderResponseErrorCodes;
|
51
|
+
const RelyingPartyResponseErrorCodes = {
|
52
|
+
RelyingPartyGenericError: "ERR_RP_GENERIC_ERROR",
|
53
|
+
/**
|
54
|
+
* An error code thrown then the Relying Party rejects the Wallet's Authorization Response.
|
55
|
+
*/
|
56
|
+
InvalidAuthorizationResponse: "ERR_RP_INVALID_AUTHORIZATION_RESPONSE"
|
57
|
+
};
|
58
|
+
exports.RelyingPartyResponseErrorCodes = RelyingPartyResponseErrorCodes;
|
39
59
|
//# sourceMappingURL=error-codes.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["IssuerResponseErrorCodes","IssuerGenericError","CredentialRequestFailed","exports","WalletProviderResponseErrorCodes","WalletProviderGenericError","WalletInstanceCreationFailed","WalletInstanceAttestationIssuingFailed","WalletInstanceIntegrityFailed","WalletInstanceRevoked","WalletInstanceNotFound"],"sourceRoot":"../../../src","sources":["utils/error-codes.ts"],"mappings":";;;;;;AAAO,MAAMA,wBAAwB,GAAG;EACtCC,kBAAkB,EAAE,0BAA0B;EAC9C;AACF;AACA;EACEC,uBAAuB,EAAE;
|
1
|
+
{"version":3,"names":["IssuerResponseErrorCodes","IssuerGenericError","CredentialIssuingNotSynchronous","CredentialRequestFailed","CredentialInvalidStatus","StatusAttestationRequestFailed","exports","WalletProviderResponseErrorCodes","WalletProviderGenericError","WalletInstanceCreationFailed","WalletInstanceAttestationIssuingFailed","WalletInstanceIntegrityFailed","WalletInstanceRevoked","WalletInstanceNotFound","RelyingPartyResponseErrorCodes","RelyingPartyGenericError","InvalidAuthorizationResponse"],"sourceRoot":"../../../src","sources":["utils/error-codes.ts"],"mappings":";;;;;;AAAO,MAAMA,wBAAwB,GAAG;EACtCC,kBAAkB,EAAE,0BAA0B;EAC9C;AACF;AACA;EACEC,+BAA+B,EAAE,wCAAwC;EACzE;AACF;AACA;EACEC,uBAAuB,EAAE,+BAA+B;EACxD;AACF;AACA;EACEC,uBAAuB,EAAE,+BAA+B;EACxD;AACF;AACA;EACEC,8BAA8B,EAAE;AAClC,CAAU;AAACC,OAAA,CAAAN,wBAAA,GAAAA,wBAAA;AAEJ,MAAMO,gCAAgC,GAAG;EAC9CC,0BAA0B,EAAE,sCAAsC;EAClE;AACF;AACA;EACEC,4BAA4B,EAAE,wCAAwC;EACtE;AACF;AACA;EACEC,sCAAsC,EACpC,mDAAmD;EACrD;AACF;AACA;EACEC,6BAA6B,EAAE,yCAAyC;EACxE;AACF;AACA;EACEC,qBAAqB,EAAE,gCAAgC;EACvD;AACF;AACA;EACEC,sBAAsB,EAAE;AAC1B,CAAU;AAACP,OAAA,CAAAC,gCAAA,GAAAA,gCAAA;AAEJ,MAAMO,8BAA8B,GAAG;EAC5CC,wBAAwB,EAAE,sBAAsB;EAChD;AACF;AACA;EACEC,4BAA4B,EAAE;AAChC,CAAU;AAACV,OAAA,CAAAQ,8BAAA,GAAAA,8BAAA"}
|
@@ -10,6 +10,13 @@ Object.defineProperty(exports, "IssuerResponseErrorCodes", {
|
|
10
10
|
return _errorCodes.IssuerResponseErrorCodes;
|
11
11
|
}
|
12
12
|
});
|
13
|
+
exports.RelyingPartyResponseError = void 0;
|
14
|
+
Object.defineProperty(exports, "RelyingPartyResponseErrorCodes", {
|
15
|
+
enumerable: true,
|
16
|
+
get: function () {
|
17
|
+
return _errorCodes.RelyingPartyResponseErrorCodes;
|
18
|
+
}
|
19
|
+
});
|
13
20
|
exports.WalletProviderResponseError = exports.ValidationFailed = exports.UnexpectedStatusCodeError = exports.ResponseErrorBuilder = void 0;
|
14
21
|
Object.defineProperty(exports, "WalletProviderResponseErrorCodes", {
|
15
22
|
enumerable: true,
|
@@ -17,7 +24,8 @@ Object.defineProperty(exports, "WalletProviderResponseErrorCodes", {
|
|
17
24
|
return _errorCodes.WalletProviderResponseErrorCodes;
|
18
25
|
}
|
19
26
|
});
|
20
|
-
exports.
|
27
|
+
exports.extractErrorMessageFromIssuerConf = extractErrorMessageFromIssuerConf;
|
28
|
+
exports.serializeAttrs = exports.isWalletProviderResponseError = exports.isRelyingPartyResponseError = exports.isIssuerResponseError = void 0;
|
21
29
|
var _errorCodes = require("./error-codes");
|
22
30
|
// An error reason that supports both a string and a generic JSON object
|
23
31
|
|
@@ -115,8 +123,6 @@ class UnexpectedStatusCodeError extends IoWalletError {
|
|
115
123
|
/**
|
116
124
|
* An error subclass thrown when an Issuer HTTP request fails.
|
117
125
|
* The specific error can be found in the `code` property.
|
118
|
-
*
|
119
|
-
* The class is generic over the error code to narrow down the reason.
|
120
126
|
*/
|
121
127
|
exports.UnexpectedStatusCodeError = UnexpectedStatusCodeError;
|
122
128
|
class IssuerResponseError extends UnexpectedStatusCodeError {
|
@@ -139,6 +145,69 @@ class WalletProviderResponseError extends UnexpectedStatusCodeError {
|
|
139
145
|
}
|
140
146
|
}
|
141
147
|
|
148
|
+
/**
|
149
|
+
* An error subclass thrown when a Relying Party HTTP request fails.
|
150
|
+
* The specific error can be found in the `code` property.
|
151
|
+
*/
|
152
|
+
exports.WalletProviderResponseError = WalletProviderResponseError;
|
153
|
+
class RelyingPartyResponseError extends UnexpectedStatusCodeError {
|
154
|
+
constructor(params) {
|
155
|
+
super(params);
|
156
|
+
this.code = params.code ?? _errorCodes.RelyingPartyResponseErrorCodes.RelyingPartyGenericError;
|
157
|
+
}
|
158
|
+
}
|
159
|
+
exports.RelyingPartyResponseError = RelyingPartyResponseError;
|
160
|
+
/**
|
161
|
+
* Function to extract the error message from the Entity Configuration's supported error codes.
|
162
|
+
* @param errorCode The error code to map to a meaningful message
|
163
|
+
* @param issuerConf The entity configuration for credentials
|
164
|
+
* @param credentialType The type of credential the error belongs to
|
165
|
+
* @returns A localized error {@link LocalizedIssuanceError} or undefined
|
166
|
+
* @throws {IoWalletError} When no credential config is found
|
167
|
+
*/
|
168
|
+
function extractErrorMessageFromIssuerConf(errorCode, _ref5) {
|
169
|
+
let {
|
170
|
+
issuerConf,
|
171
|
+
credentialType
|
172
|
+
} = _ref5;
|
173
|
+
const credentialConfiguration = issuerConf.openid_credential_issuer.credential_configurations_supported[credentialType];
|
174
|
+
if (!credentialConfiguration) {
|
175
|
+
throw new IoWalletError(`No configuration found for ${credentialType} in the provided EC`);
|
176
|
+
}
|
177
|
+
const {
|
178
|
+
issuance_errors_supported
|
179
|
+
} = credentialConfiguration;
|
180
|
+
if (!(issuance_errors_supported !== null && issuance_errors_supported !== void 0 && issuance_errors_supported[errorCode])) {
|
181
|
+
return undefined;
|
182
|
+
}
|
183
|
+
const localesList = issuance_errors_supported[errorCode].display;
|
184
|
+
return localesList.reduce((acc, _ref6) => {
|
185
|
+
let {
|
186
|
+
locale,
|
187
|
+
...rest
|
188
|
+
} = _ref6;
|
189
|
+
return {
|
190
|
+
...acc,
|
191
|
+
[locale]: rest
|
192
|
+
};
|
193
|
+
}, {});
|
194
|
+
}
|
195
|
+
|
196
|
+
/**
|
197
|
+
* Factory function to create a type guard for specific error classes.
|
198
|
+
*
|
199
|
+
* @param errorClass The error class to create the type guard for
|
200
|
+
* @returns A type guard that checks if the error is an instance of the given class and has the expected code
|
201
|
+
*/
|
202
|
+
const makeErrorTypeGuard = ErrorClass => (error, code) => error instanceof ErrorClass && error.code === (code ?? error.code);
|
203
|
+
const isIssuerResponseError = makeErrorTypeGuard(IssuerResponseError);
|
204
|
+
exports.isIssuerResponseError = isIssuerResponseError;
|
205
|
+
const isWalletProviderResponseError = makeErrorTypeGuard(WalletProviderResponseError);
|
206
|
+
exports.isWalletProviderResponseError = isWalletProviderResponseError;
|
207
|
+
const isRelyingPartyResponseError = makeErrorTypeGuard(RelyingPartyResponseError);
|
208
|
+
|
209
|
+
// Mapping type between error classes and their allowed codes
|
210
|
+
exports.isRelyingPartyResponseError = isRelyingPartyResponseError;
|
142
211
|
/**
|
143
212
|
* Builder class used to create specialized errors from type {@link UnexpectedStatusCodeError} that handles multiple status codes.
|
144
213
|
*
|
@@ -153,7 +222,6 @@ class WalletProviderResponseError extends UnexpectedStatusCodeError {
|
|
153
222
|
* .buildFrom(baseError)
|
154
223
|
* ```
|
155
224
|
*/
|
156
|
-
exports.WalletProviderResponseError = WalletProviderResponseError;
|
157
225
|
class ResponseErrorBuilder {
|
158
226
|
errorCases = {};
|
159
227
|
constructor(ErrorClass) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_errorCodes","require","serializeAttrs","attrs","Object","entries","filter","_ref","v","undefined","map","_ref2","k","Array","isArray","join","JSON","stringify","_","exports","IoWalletError","Error","code","constructor","message","name","ValidationFailed","_ref3","claim","reason","UnexpectedStatusCodeError","_ref4","statusCode","IssuerResponseError","params","IssuerResponseErrorCodes","IssuerGenericError","WalletProviderResponseError","WalletProviderResponseErrorCodes","WalletProviderGenericError","
|
1
|
+
{"version":3,"names":["_errorCodes","require","serializeAttrs","attrs","Object","entries","filter","_ref","v","undefined","map","_ref2","k","Array","isArray","join","JSON","stringify","_","exports","IoWalletError","Error","code","constructor","message","name","ValidationFailed","_ref3","claim","reason","UnexpectedStatusCodeError","_ref4","statusCode","IssuerResponseError","params","IssuerResponseErrorCodes","IssuerGenericError","WalletProviderResponseError","WalletProviderResponseErrorCodes","WalletProviderGenericError","RelyingPartyResponseError","RelyingPartyResponseErrorCodes","RelyingPartyGenericError","extractErrorMessageFromIssuerConf","errorCode","_ref5","issuerConf","credentialType","credentialConfiguration","openid_credential_issuer","credential_configurations_supported","issuance_errors_supported","localesList","display","reduce","acc","_ref6","locale","rest","makeErrorTypeGuard","ErrorClass","error","isIssuerResponseError","isWalletProviderResponseError","isRelyingPartyResponseError","ResponseErrorBuilder","errorCases","handle","status","buildFrom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
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Logger = exports.LogLevel = void 0;
|
7
|
+
/**
|
8
|
+
* Logger interface which can be provided to the Logger class as a custom implementation.
|
9
|
+
*/
|
10
|
+
/**
|
11
|
+
* Supported debug levels.
|
12
|
+
*/
|
13
|
+
let LogLevel = /*#__PURE__*/function (LogLevel) {
|
14
|
+
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
15
|
+
LogLevel[LogLevel["INFO"] = 1] = "INFO";
|
16
|
+
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
17
|
+
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
|
18
|
+
return LogLevel;
|
19
|
+
}({});
|
20
|
+
/**
|
21
|
+
* Logger singleton class which provides a simple logging interface with an init function to set the logging context and
|
22
|
+
* a static log function to log messages based on the debug level.
|
23
|
+
* This can be used as follows:
|
24
|
+
* const logger = Logger.getInstance();
|
25
|
+
* logger.initLogging(yourLoggingContext);
|
26
|
+
* logger.log(LogLevel.DEBUG, "Debug message");
|
27
|
+
*/
|
28
|
+
exports.LogLevel = LogLevel;
|
29
|
+
class Logger {
|
30
|
+
static instance = null;
|
31
|
+
// Private constructor to prevent direct instantiation
|
32
|
+
constructor() {}
|
33
|
+
|
34
|
+
// Public static method to get the Logger instance
|
35
|
+
static getInstance() {
|
36
|
+
if (Logger.instance === null) {
|
37
|
+
Logger.instance = new Logger();
|
38
|
+
}
|
39
|
+
return Logger.instance;
|
40
|
+
}
|
41
|
+
|
42
|
+
// Method to initialize the logging context
|
43
|
+
initLogging(loggingCtx) {
|
44
|
+
Logger.loggingContext = loggingCtx;
|
45
|
+
}
|
46
|
+
|
47
|
+
// Method to log based on the level which wraps the null check for the logging context
|
48
|
+
static log(level, msg) {
|
49
|
+
if (Logger.loggingContext) {
|
50
|
+
switch (level) {
|
51
|
+
case LogLevel.DEBUG:
|
52
|
+
Logger.loggingContext.logDebug(msg);
|
53
|
+
break;
|
54
|
+
case LogLevel.INFO:
|
55
|
+
Logger.loggingContext.logInfo(msg);
|
56
|
+
break;
|
57
|
+
case LogLevel.WARN:
|
58
|
+
Logger.loggingContext.logWarn(msg);
|
59
|
+
break;
|
60
|
+
case LogLevel.ERROR:
|
61
|
+
Logger.loggingContext.logError(msg);
|
62
|
+
break;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
exports.Logger = Logger;
|
68
|
+
//# sourceMappingURL=logging.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["LogLevel","exports","Logger","instance","constructor","getInstance","initLogging","loggingCtx","loggingContext","log","level","msg","DEBUG","logDebug","INFO","logInfo","WARN","logWarn","ERROR","logError"],"sourceRoot":"../../../src","sources":["utils/logging.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AAQA;AACA;AACA;AAFA,IAGYA,QAAQ,0BAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;AAOpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAC,OAAA,CAAAD,QAAA,GAAAA,QAAA;AAQO,MAAME,MAAM,CAAC;EAClB,OAAeC,QAAQ,GAAkB,IAAI;EAG7C;EACQC,WAAWA,CAAA,EAAG,CAAC;;EAEvB;EACA,OAAcC,WAAWA,CAAA,EAAW;IAClC,IAAIH,MAAM,CAACC,QAAQ,KAAK,IAAI,EAAE;MAC5BD,MAAM,CAACC,QAAQ,GAAG,IAAID,MAAM,CAAC,CAAC;IAChC;IACA,OAAOA,MAAM,CAACC,QAAQ;EACxB;;EAEA;EACOG,WAAWA,CAACC,UAA0B,EAAQ;IACnDL,MAAM,CAACM,cAAc,GAAGD,UAAU;EACpC;;EAEA;EACA,OAAcE,GAAGA,CAACC,KAAe,EAAEC,GAAW,EAAQ;IACpD,IAAIT,MAAM,CAACM,cAAc,EAAE;MACzB,QAAQE,KAAK;QACX,KAAKV,QAAQ,CAACY,KAAK;UACjBV,MAAM,CAACM,cAAc,CAACK,QAAQ,CAACF,GAAG,CAAC;UACnC;QACF,KAAKX,QAAQ,CAACc,IAAI;UAChBZ,MAAM,CAACM,cAAc,CAACO,OAAO,CAACJ,GAAG,CAAC;UAClC;QACF,KAAKX,QAAQ,CAACgB,IAAI;UAChBd,MAAM,CAACM,cAAc,CAACS,OAAO,CAACN,GAAG,CAAC;UAClC;QACF,KAAKX,QAAQ,CAACkB,KAAK;UACjBhB,MAAM,CAACM,cAAc,CAACW,QAAQ,CAACR,GAAG,CAAC;UACnC;MACJ;IACF;EACF;AACF;AAACV,OAAA,CAAAC,MAAA,GAAAA,MAAA"}
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.safeJsonParse = exports.parseRawHttpResponse = exports.hasStatusOrThrow = exports.getCredentialHashWithouDiscloures = exports.generateRandomAlphaNumericString = void 0;
|
7
7
|
var _errors = require("./errors");
|
8
8
|
var _jsSha = require("js-sha256");
|
9
|
+
var _logging = require("./logging");
|
9
10
|
/**
|
10
11
|
* Check if a response is in the expected status, otherwise throw an error
|
11
12
|
* @param status - The expected status
|
@@ -16,6 +17,7 @@ var _jsSha = require("js-sha256");
|
|
16
17
|
const hasStatusOrThrow = (status, customError) => async res => {
|
17
18
|
if (res.status !== status) {
|
18
19
|
const ErrorClass = customError ?? _errors.UnexpectedStatusCodeError;
|
20
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Http request failed. Expected ${status}, got ${res.status}, url: ${res.url}`);
|
19
21
|
throw new ErrorClass({
|
20
22
|
message: `Http request failed. Expected ${status}, got ${res.status}, url: ${res.url}`,
|
21
23
|
statusCode: res.status,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_errors","require","_jsSha","hasStatusOrThrow","status","customError","res","ErrorClass","UnexpectedStatusCodeError","
|
1
|
+
{"version":3,"names":["_errors","require","_jsSha","_logging","hasStatusOrThrow","status","customError","res","ErrorClass","UnexpectedStatusCodeError","Logger","log","LogLevel","ERROR","url","message","statusCode","reason","parseRawHttpResponse","exports","response","_response$headers$get","headers","get","includes","json","text","generateRandomAlphaNumericString","size","Array","from","Math","floor","random","toString","join","getCredentialHashWithouDiscloures","credential","tildeIndex","indexOf","IoWalletError","sha256","slice","safeJsonParse","withDefault","JSON","parse","_"],"sourceRoot":"../../../src","sources":["utils/misc.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,gBAAgB,GAC3BA,CAACC,MAAc,EAAEC,WAA8C,KAC/D,MAAOC,GAAa,IAAwB;EAC1C,IAAIA,GAAG,CAACF,MAAM,KAAKA,MAAM,EAAE;IACzB,MAAMG,UAAU,GAAGF,WAAW,IAAIG,iCAAyB;IAC3DC,eAAM,CAACC,GAAG,CACRC,iBAAQ,CAACC,KAAK,EACb,iCAAgCR,MAAO,SAAQE,GAAG,CAACF,MAAO,UAASE,GAAG,CAACO,GAAI,EAC9E,CAAC;IACD,MAAM,IAAIN,UAAU,CAAC;MACnBO,OAAO,EAAG,iCAAgCV,MAAO,SAAQE,GAAG,CAACF,MAAO,UAASE,GAAG,CAACO,GAAI,EAAC;MACtFE,UAAU,EAAET,GAAG,CAACF,MAAM;MACtBY,MAAM,EAAE,MAAMC,oBAAoB,CAACX,GAAG,CAAC,CAAE;IAC3C,CAAC,CAAC;EACJ;;EACA,OAAOA,GAAG;AACZ,CAAC;;AAEH;AACA;AACA;AAFAY,OAAA,CAAAf,gBAAA,GAAAA,gBAAA;AAGO,MAAMc,oBAAoB,GAC/BE,QAAkB;EAAA,IAAAC,qBAAA;EAAA,OAElB,CAAAA,qBAAA,GAAAD,QAA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exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.makeParRequest = exports.AuthorizationDetails = exports.AuthorizationDetail = void 0;
|
7
7
|
var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
|
8
|
-
var
|
8
|
+
var _uuid = require("uuid");
|
9
9
|
var z = _interopRequireWildcard(require("zod"));
|
10
10
|
var WalletInstanceAttestation = _interopRequireWildcard(require("../wallet-instance-attestation"));
|
11
11
|
var _misc = require("./misc");
|
12
12
|
var _pop = require("./pop");
|
13
13
|
var _errors = require("./errors");
|
14
|
+
var _logging = require("./logging");
|
14
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
15
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
17
|
const AuthorizationDetail = z.object({
|
18
18
|
credential_configuration_id: z.string(),
|
19
|
+
format: z.union([z.literal("vc+sd-jwt"), z.literal("vc+mdoc-cbor")]),
|
19
20
|
type: z.literal("openid_credential")
|
20
21
|
});
|
21
22
|
exports.AuthorizationDetail = AuthorizationDetail;
|
@@ -30,13 +31,13 @@ const makeParRequest = _ref => {
|
|
30
31
|
wiaCryptoContext,
|
31
32
|
appFetch
|
32
33
|
} = _ref;
|
33
|
-
return async (clientId, codeVerifier, redirectUri, responseMode, parEndpoint, walletInstanceAttestation, authorizationDetails) => {
|
34
|
+
return async (clientId, codeVerifier, redirectUri, responseMode, parEndpoint, walletInstanceAttestation, authorizationDetails, assertionType) => {
|
34
35
|
const wiaPublicKey = await wiaCryptoContext.getPublicKey();
|
35
36
|
const parUrl = new URL(parEndpoint);
|
36
37
|
const aud = `${parUrl.protocol}//${parUrl.hostname}`;
|
37
38
|
const iss = WalletInstanceAttestation.decode(walletInstanceAttestation).payload.cnf.jwk.kid;
|
38
39
|
const signedWiaPoP = await (0, _pop.createPopToken)({
|
39
|
-
jti: `${
|
40
|
+
jti: `${(0, _uuid.v4)()}`,
|
40
41
|
aud,
|
41
42
|
iss
|
42
43
|
}, wiaCryptoContext);
|
@@ -55,7 +56,7 @@ const makeParRequest = _ref => {
|
|
55
56
|
typ: "jwk",
|
56
57
|
kid: wiaPublicKey.kid
|
57
58
|
}).setPayload({
|
58
|
-
jti: `${
|
59
|
+
jti: `${(0, _uuid.v4)()}`,
|
59
60
|
aud,
|
60
61
|
response_type: "code",
|
61
62
|
response_mode: responseMode,
|
@@ -65,21 +66,27 @@ const makeParRequest = _ref => {
|
|
65
66
|
code_challenge: codeChallenge,
|
66
67
|
code_challenge_method: codeChallengeMethod,
|
67
68
|
authorization_details: authorizationDetails,
|
68
|
-
redirect_uri: redirectUri
|
69
|
+
redirect_uri: redirectUri,
|
70
|
+
client_assertion_type: assertionType,
|
71
|
+
client_assertion: walletInstanceAttestation + "~" + signedWiaPoP
|
69
72
|
}).setIssuedAt() //iat is set to now
|
70
73
|
.setExpirationTime("5min").sign();
|
71
74
|
|
72
75
|
/** The request body for the Pushed Authorization Request */
|
73
76
|
var formBody = new URLSearchParams({
|
77
|
+
response_type: "code",
|
74
78
|
client_id: clientId,
|
75
|
-
|
79
|
+
code_challenge: codeChallenge,
|
80
|
+
code_challenge_method: "S256",
|
81
|
+
request: signedJwtForPar,
|
82
|
+
client_assertion_type: assertionType,
|
83
|
+
client_assertion: walletInstanceAttestation + "~" + signedWiaPoP
|
76
84
|
});
|
85
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, `Sending to PAR endpoint ${parEndpoint}: ${formBody}`);
|
77
86
|
return await appFetch(parEndpoint, {
|
78
87
|
method: "POST",
|
79
88
|
headers: {
|
80
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
81
|
-
"OAuth-Client-Attestation": walletInstanceAttestation,
|
82
|
-
"OAuth-Client-Attestation-PoP": signedWiaPoP
|
89
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
83
90
|
},
|
84
91
|
body: formBody.toString()
|
85
92
|
}).then((0, _misc.hasStatusOrThrow)(201, _errors.IssuerResponseError)).then(res => res.json()).then(result => result.request_uri);
|