Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 29 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| WebAuthnSerializerFactory | |
0.00% |
0 / 29 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| create | |
0.00% |
0 / 28 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * cf https://github.com/web-auth/webauthn-lib/blob/5.2.3/src/Denormalizer/WebauthnSerializerFactory.php |
| 5 | * |
| 6 | * Changes: |
| 7 | * * Re-namespaced and capitalisation of class name changed |
| 8 | * * Updated to MW code style |
| 9 | * * class_exists() check removed; composer makes sure classes exist |
| 10 | * * Mapping of class => package removed, along with related constants |
| 11 | * * PhpDocExtractor removed from ObjectNormalizer/PropertyInfoExtractor |
| 12 | * |
| 13 | * @license MIT |
| 14 | */ |
| 15 | |
| 16 | declare( strict_types = 1 ); |
| 17 | |
| 18 | namespace MediaWiki\Extension\OATHAuth; |
| 19 | |
| 20 | use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; |
| 21 | use Symfony\Component\PropertyInfo\PropertyInfoExtractor; |
| 22 | use Symfony\Component\Serializer\Encoder\JsonEncoder; |
| 23 | use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer; |
| 24 | use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; |
| 25 | use Symfony\Component\Serializer\Normalizer\UidNormalizer; |
| 26 | use Symfony\Component\Serializer\Serializer; |
| 27 | use Symfony\Component\Serializer\SerializerInterface; |
| 28 | use Webauthn\AttestationStatement\AttestationStatementSupportManager; |
| 29 | use Webauthn\Denormalizer\AttestationObjectDenormalizer; |
| 30 | use Webauthn\Denormalizer\AttestationStatementDenormalizer; |
| 31 | use Webauthn\Denormalizer\AttestedCredentialDataNormalizer; |
| 32 | use Webauthn\Denormalizer\AuthenticationExtensionNormalizer; |
| 33 | use Webauthn\Denormalizer\AuthenticationExtensionsDenormalizer; |
| 34 | use Webauthn\Denormalizer\AuthenticatorAssertionResponseDenormalizer; |
| 35 | use Webauthn\Denormalizer\AuthenticatorAttestationResponseDenormalizer; |
| 36 | use Webauthn\Denormalizer\AuthenticatorDataDenormalizer; |
| 37 | use Webauthn\Denormalizer\AuthenticatorResponseDenormalizer; |
| 38 | use Webauthn\Denormalizer\CollectedClientDataDenormalizer; |
| 39 | use Webauthn\Denormalizer\ExtensionDescriptorDenormalizer; |
| 40 | use Webauthn\Denormalizer\PublicKeyCredentialDenormalizer; |
| 41 | use Webauthn\Denormalizer\PublicKeyCredentialDescriptorNormalizer; |
| 42 | use Webauthn\Denormalizer\PublicKeyCredentialOptionsDenormalizer; |
| 43 | use Webauthn\Denormalizer\PublicKeyCredentialSourceDenormalizer; |
| 44 | use Webauthn\Denormalizer\PublicKeyCredentialUserEntityDenormalizer; |
| 45 | use Webauthn\Denormalizer\TrustPathDenormalizer; |
| 46 | use Webauthn\Denormalizer\VerificationMethodANDCombinationsDenormalizer; |
| 47 | |
| 48 | final readonly class WebAuthnSerializerFactory { |
| 49 | public function __construct( |
| 50 | private AttestationStatementSupportManager $attestationStatementSupportManager |
| 51 | ) { |
| 52 | } |
| 53 | |
| 54 | public function create(): SerializerInterface { |
| 55 | $denormalizers = [ |
| 56 | new ExtensionDescriptorDenormalizer(), |
| 57 | new VerificationMethodANDCombinationsDenormalizer(), |
| 58 | new AuthenticationExtensionNormalizer(), |
| 59 | new PublicKeyCredentialDescriptorNormalizer(), |
| 60 | new AttestedCredentialDataNormalizer(), |
| 61 | new AttestationObjectDenormalizer(), |
| 62 | new AttestationStatementDenormalizer( $this->attestationStatementSupportManager ), |
| 63 | new AuthenticationExtensionsDenormalizer(), |
| 64 | new AuthenticatorAssertionResponseDenormalizer(), |
| 65 | new AuthenticatorAttestationResponseDenormalizer(), |
| 66 | new AuthenticatorDataDenormalizer(), |
| 67 | new AuthenticatorResponseDenormalizer(), |
| 68 | new CollectedClientDataDenormalizer(), |
| 69 | new PublicKeyCredentialDenormalizer(), |
| 70 | new PublicKeyCredentialOptionsDenormalizer(), |
| 71 | new PublicKeyCredentialSourceDenormalizer(), |
| 72 | new PublicKeyCredentialUserEntityDenormalizer(), |
| 73 | new TrustPathDenormalizer(), |
| 74 | new UidNormalizer(), |
| 75 | new ArrayDenormalizer(), |
| 76 | new ObjectNormalizer( |
| 77 | propertyTypeExtractor: new PropertyInfoExtractor( typeExtractors: [ |
| 78 | new ReflectionExtractor(), |
| 79 | ] ) |
| 80 | ), |
| 81 | ]; |
| 82 | |
| 83 | return new Serializer( $denormalizers, [ new JsonEncoder() ] ); |
| 84 | } |
| 85 | } |