File manager - Edit - /home/opticamezl/www/newok/metadata-service.tar
Back
src/VerificationMethodANDCombinations.php 0000644 00000001712 15173524301 0014522 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; use Assert\Assertion; class VerificationMethodANDCombinations { /** * @var VerificationMethodDescriptor[] */ private $verificationMethods = []; /** * @return VerificationMethodDescriptor[] */ public function getVerificationMethods(): array { return $this->verificationMethods; } public static function createFromArray(array $data): self { $object = new self(); foreach ($data as $datum) { Assertion::isArray($datum, 'Invalid verificationMethod and combinations'); $object->verificationMethods[] = VerificationMethodDescriptor::createFromArray($datum); } return $object; } } src/AuthenticatorStatus.php 0000644 00000002360 15173524301 0012064 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; abstract class AuthenticatorStatus { public const NOT_FIDO_CERTIFIED = 'NOT_FIDO_CERTIFIED'; public const FIDO_CERTIFIED = 'FIDO_CERTIFIED'; public const USER_VERIFICATION_BYPASS = 'USER_VERIFICATION_BYPASS'; public const ATTESTATION_KEY_COMPROMISE = 'ATTESTATION_KEY_COMPROMISE'; public const USER_KEY_REMOTE_COMPROMISE = 'USER_KEY_REMOTE_COMPROMISE'; public const USER_KEY_PHYSICAL_COMPROMISE = 'USER_KEY_PHYSICAL_COMPROMISE'; public const UPDATE_AVAILABLE = 'UPDATE_AVAILABLE'; public const REVOKED = 'REVOKED'; public const SELF_ASSERTION_SUBMITTED = 'SELF_ASSERTION_SUBMITTED'; public const FIDO_CERTIFIED_L1 = 'FIDO_CERTIFIED_L1'; public const FIDO_CERTIFIED_L1plus = 'FIDO_CERTIFIED_L1plus'; public const FIDO_CERTIFIED_L2 = 'FIDO_CERTIFIED_L2'; public const FIDO_CERTIFIED_L2plus = 'FIDO_CERTIFIED_L2plus'; public const FIDO_CERTIFIED_L3 = 'FIDO_CERTIFIED_L3'; public const FIDO_CERTIFIED_L3plus = 'FIDO_CERTIFIED_L3plus'; } src/SingleMetadata.php 0000644 00000002364 15173524301 0010734 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; use Assert\Assertion; class SingleMetadata { /** * @var MetadataStatement */ private $statement; /** * @var string */ private $data; /** * @var bool */ private $isBare64Encoded; public function __construct(string $data, bool $isBare64Encoded) { $this->data = $data; $this->isBare64Encoded = $isBare64Encoded; } public function getMetadataStatement(): MetadataStatement { if (null === $this->statement) { $json = $this->data; if ($this->isBare64Encoded) { $json = base64_decode($this->data, true); Assertion::string($json, 'Unable to decode the data'); } $statement = json_decode($json, true); Assertion::eq(JSON_ERROR_NONE, json_last_error(), 'Unable to decode the data'); $this->statement = MetadataStatement::createFromArray($statement); } return $this->statement; } } src/BiometricStatusReport.php 0000644 00000004251 15173524301 0012364 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; class BiometricStatusReport { /** * @var int */ private $certLevel; /** * @var int */ private $modality; /** * @var string|null */ private $effectiveDate; /** * @var string|null */ private $certificationDescriptor; /** * @var string|null */ private $certificateNumber; /** * @var string|null */ private $certificationPolicyVersion; /** * @var string|null */ private $certificationRequirementsVersion; public function getCertLevel(): int { return $this->certLevel; } public function getModality(): int { return $this->modality; } public function getEffectiveDate(): ?string { return $this->effectiveDate; } public function getCertificationDescriptor(): ?string { return $this->certificationDescriptor; } public function getCertificateNumber(): ?string { return $this->certificateNumber; } public function getCertificationPolicyVersion(): ?string { return $this->certificationPolicyVersion; } public function getCertificationRequirementsVersion(): ?string { return $this->certificationRequirementsVersion; } public static function createFromArray(array $data): self { $object = new self(); $object->certLevel = $data['certLevel'] ?? null; $object->modality = $data['modality'] ?? null; $object->effectiveDate = $data['effectiveDate'] ?? null; $object->certificationDescriptor = $data['certificationDescriptor'] ?? null; $object->certificateNumber = $data['certificateNumber'] ?? null; $object->certificationPolicyVersion = $data['certificationPolicyVersion'] ?? null; $object->certificationRequirementsVersion = $data['certificationRequirementsVersion'] ?? null; return $object; } } src/MetadataService.php 0000644 00000004365 15173524301 0011116 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; use function League\Uri\build; use function League\Uri\build_query; use function League\Uri\parse; use function League\Uri\parse_query; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestFactoryInterface; class MetadataService { /** * @var ClientInterface */ private $httpClient; /** * @var RequestFactoryInterface */ private $requestFactory; /** * @var array */ private $additionalQueryStringValues; /** * @var array */ private $additionalHeaders; /** * @var string */ private $serviceUri; public function __construct(string $serviceUri, ClientInterface $httpClient, RequestFactoryInterface $requestFactory, array $additionalQueryStringValues = [], array $additionalHeaders = []) { $this->serviceUri = $serviceUri; $this->httpClient = $httpClient; $this->requestFactory = $requestFactory; $this->additionalQueryStringValues = $additionalQueryStringValues; $this->additionalHeaders = $additionalHeaders; } public function getMetadataStatementFor(MetadataTOCPayloadEntry $entry): MetadataStatement { $uri = $this->buildUri($entry->getUrl()); return MetadataStatementFetcher::fetchMetadataStatement($uri, true, $this->httpClient, $this->requestFactory, $this->additionalHeaders); } public function getMetadataTOCPayload(): MetadataTOCPayload { $uri = $this->buildUri($this->serviceUri); return MetadataStatementFetcher::fetchTableOfContent($uri, $this->httpClient, $this->requestFactory, $this->additionalHeaders); } private function buildUri(string $uri): string { $parsedUri = parse($uri); $queryString = $parsedUri['query']; $query = parse_query($queryString ?? ''); foreach ($this->additionalQueryStringValues as $k => $v) { $query[$k] = $v; } $parsedUri['query'] = build_query($query); return build($parsedUri); } } src/VerificationMethodDescriptor.php 0000644 00000004146 15173524301 0013674 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; class VerificationMethodDescriptor { public const USER_VERIFY_PRESENCE = 0x00000001; public const USER_VERIFY_FINGERPRINT = 0x00000002; public const USER_VERIFY_PASSCODE = 0x00000004; public const USER_VERIFY_VOICEPRINT = 0x00000008; public const USER_VERIFY_FACEPRINT = 0x00000010; public const USER_VERIFY_LOCATION = 0x00000020; public const USER_VERIFY_EYEPRINT = 0x00000040; public const USER_VERIFY_PATTERN = 0x00000080; public const USER_VERIFY_HANDPRINT = 0x00000100; public const USER_VERIFY_NONE = 0x00000200; public const USER_VERIFY_ALL = 0x00000400; /** * @var int */ private $userVerification; /** * @var CodeAccuracyDescriptor|null */ private $caDesc; /** * @var BiometricAccuracyDescriptor|null */ private $baDesc; /** * @var PatternAccuracyDescriptor|null */ private $paDesc; public function getUserVerification(): int { return $this->userVerification; } public function getCaDesc(): ?CodeAccuracyDescriptor { return $this->caDesc; } public function getBaDesc(): ?BiometricAccuracyDescriptor { return $this->baDesc; } public function getPaDesc(): ?PatternAccuracyDescriptor { return $this->paDesc; } public static function createFromArray(array $data): self { $object = new self(); $object->userVerification = $data['userVerification'] ?? null; $object->caDesc = isset($data['caDesc']) ? CodeAccuracyDescriptor::createFromArray($data['caDesc']) : null; $object->baDesc = isset($data['baDesc']) ? BiometricAccuracyDescriptor::createFromArray($data['baDesc']) : null; $object->paDesc = isset($data['paDesc']) ? PatternAccuracyDescriptor::createFromArray($data['paDesc']) : null; return $object; } } src/BiometricAccuracyDescriptor.php 0000644 00000003336 15173524301 0013501 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; class BiometricAccuracyDescriptor { /** * @var int|null */ private $selfAttestedFRR; /** * @var int|null */ private $selfAttestedFAR; /** * @var int|null */ private $maxTemplates; /** * @var int|null */ private $maxRetries; /** * @var int|null */ private $blockSlowdown; /** * @return int */ public function getSelfAttestedFRR(): ?int { return $this->selfAttestedFRR; } /** * @return int */ public function getSelfAttestedFAR(): ?int { return $this->selfAttestedFAR; } /** * @return int|null */ public function getMaxTemplates(): ?int { return $this->maxTemplates; } /** * @return int|null */ public function getMaxRetries(): ?int { return $this->maxRetries; } /** * @return int|null */ public function getBlockSlowdown(): ?int { return $this->blockSlowdown; } public static function createFromArray(array $data): self { $object = new self(); $object->selfAttestedFRR = $data['selfAttestedFRR'] ?? null; $object->selfAttestedFAR = $data['selfAttestedFAR'] ?? null; $object->maxTemplates = $data['maxTemplates'] ?? null; $object->maxRetries = $data['maxRetries'] ?? null; $object->blockSlowdown = $data['blockSlowdown'] ?? null; return $object; } } src/DisplayPNGCharacteristicsDescriptor.php 0000644 00000004467 15173524301 0015125 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; use Assert\Assertion; class DisplayPNGCharacteristicsDescriptor { /** * @var int */ private $width; /** * @var int */ private $height; /** * @var int */ private $bitDepth; /** * @var int */ private $colorType; /** * @var int */ private $compression; /** * @var int */ private $filter; /** * @var int */ private $interlace; /** * @var RgbPaletteEntry[] */ private $plte = []; public function getWidth(): int { return $this->width; } public function getHeight(): int { return $this->height; } public function getBitDepth(): int { return $this->bitDepth; } public function getColorType(): int { return $this->colorType; } public function getCompression(): int { return $this->compression; } public function getFilter(): int { return $this->filter; } public function getInterlace(): int { return $this->interlace; } /** * @return RgbPaletteEntry[] */ public function getPlte(): array { return $this->plte; } public static function createFromArray(array $data): self { $object = new self(); $object->width = $data['width'] ?? null; $object->compression = $data['compression'] ?? null; $object->height = $data['height'] ?? null; $object->bitDepth = $data['bitDepth'] ?? null; $object->colorType = $data['colorType'] ?? null; $object->compression = $data['compression'] ?? null; $object->filter = $data['filter'] ?? null; $object->interlace = $data['interlace'] ?? null; if (isset($data['plte'])) { $plte = $data['plte']; Assertion::isArray($plte, 'Invalid "plte" parameter'); foreach ($plte as $item) { $object->plte[] = RgbPaletteEntry::createFromArray($item); } } return $object; } } src/CodeAccuracyDescriptor.php 0000644 00000002335 15173524301 0012434 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; class CodeAccuracyDescriptor { /** * @var int */ private $base; /** * @var int */ private $minLength; /** * @var int|null */ private $maxRetries; /** * @var int|null */ private $blockSlowdown; public function getBase(): int { return $this->base; } public function getMinLength(): int { return $this->minLength; } public function getMaxRetries(): ?int { return $this->maxRetries; } public function getBlockSlowdown(): ?int { return $this->blockSlowdown; } public static function createFromArray(array $data): self { $object = new self(); $object->base = $data['base'] ?? null; $object->minLength = $data['minLength'] ?? null; $object->maxRetries = $data['maxRetries'] ?? null; $object->blockSlowdown = $data['blockSlowdown'] ?? null; return $object; } } src/MetadataStatement.php 0000644 00000032025 15173524301 0011454 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; use Assert\Assertion; use InvalidArgumentException; class MetadataStatement { public const KEY_PROTECTION_SOFTWARE = 0x0001; public const KEY_PROTECTION_HARDWARE = 0x0002; public const KEY_PROTECTION_TEE = 0x0004; public const KEY_PROTECTION_SECURE_ELEMENT = 0x0008; public const KEY_PROTECTION_REMOTE_HANDLE = 0x0010; public const MATCHER_PROTECTION_SOFTWARE = 0x0001; public const MATCHER_PROTECTION_TEE = 0x0002; public const MATCHER_PROTECTION_ON_CHIP = 0x0004; public const ATTACHMENT_HINT_INTERNAL = 0x0001; public const ATTACHMENT_HINT_EXTERNAL = 0x0002; public const ATTACHMENT_HINT_WIRED = 0x0004; public const ATTACHMENT_HINT_WIRELESS = 0x0008; public const ATTACHMENT_HINT_NFC = 0x0010; public const ATTACHMENT_HINT_BLUETOOTH = 0x0020; public const ATTACHMENT_HINT_NETWORK = 0x0040; public const ATTACHMENT_HINT_READY = 0x0080; public const ATTACHMENT_HINT_WIFI_DIRECT = 0x0100; public const TRANSACTION_CONFIRMATION_DISPLAY_ANY = 0x0001; public const TRANSACTION_CONFIRMATION_DISPLAY_PRIVILEGED_SOFTWARE = 0x0002; public const TRANSACTION_CONFIRMATION_DISPLAY_TEE = 0x0004; public const TRANSACTION_CONFIRMATION_DISPLAY_HARDWARE = 0x0008; public const TRANSACTION_CONFIRMATION_DISPLAY_REMOTE = 0x0010; public const ALG_SIGN_SECP256R1_ECDSA_SHA256_RAW = 0x0001; public const ALG_SIGN_SECP256R1_ECDSA_SHA256_DER = 0x0002; public const ALG_SIGN_RSASSA_PSS_SHA256_RAW = 0x0003; public const ALG_SIGN_RSASSA_PSS_SHA256_DER = 0x0004; public const ALG_SIGN_SECP256K1_ECDSA_SHA256_RAW = 0x0005; public const ALG_SIGN_SECP256K1_ECDSA_SHA256_DER = 0x0006; public const ALG_SIGN_SM2_SM3_RAW = 0x0007; public const ALG_SIGN_RSA_EMSA_PKCS1_SHA256_RAW = 0x0008; public const ALG_SIGN_RSA_EMSA_PKCS1_SHA256_DER = 0x0009; public const ALG_SIGN_RSASSA_PSS_SHA384_RAW = 0x000A; public const ALG_SIGN_RSASSA_PSS_SHA512_RAW = 0x000B; public const ALG_SIGN_RSASSA_PKCSV15_SHA256_RAW = 0x000C; public const ALG_SIGN_RSASSA_PKCSV15_SHA384_RAW = 0x000D; public const ALG_SIGN_RSASSA_PKCSV15_SHA512_RAW = 0x000E; public const ALG_SIGN_RSASSA_PKCSV15_SHA1_RAW = 0x000F; public const ALG_SIGN_SECP384R1_ECDSA_SHA384_RAW = 0x0010; public const ALG_SIGN_SECP521R1_ECDSA_SHA512_RAW = 0x0011; public const ALG_SIGN_ED25519_EDDSA_SHA256_RAW = 0x0012; public const ALG_KEY_ECC_X962_RAW = 0x0100; public const ALG_KEY_ECC_X962_DER = 0x0101; public const ALG_KEY_RSA_2048_RAW = 0x0102; public const ALG_KEY_RSA_2048_DER = 0x0103; public const ALG_KEY_COSE = 0x0104; public const ATTESTATION_BASIC_FULL = 0x3E07; public const ATTESTATION_BASIC_SURROGATE = 0x3E08; public const ATTESTATION_ECDAA = 0x3E09; public const ATTESTATION_ATTCA = 0x3E0A; /** * @var string|null */ private $legalHeader; /** * @var string|null */ private $aaid; /** * @var string|null */ private $aaguid; /** * @var string[] */ private $attestationCertificateKeyIdentifiers = []; /** * @var string */ private $description; /** * @var string[] */ private $alternativeDescriptions = []; /** * @var int */ private $authenticatorVersion; /** * @var string */ private $protocolFamily; /** * @var Version[] */ private $upv = []; /** * @var string|null */ private $assertionScheme; /** * @var int|null */ private $authenticationAlgorithm; /** * @var int[] */ private $authenticationAlgorithms = []; /** * @var int|null */ private $publicKeyAlgAndEncoding; /** * @var int[] */ private $publicKeyAlgAndEncodings = []; /** * @var int[] */ private $attestationTypes = []; /** * @var VerificationMethodANDCombinations[] */ private $userVerificationDetails = []; /** * @var int */ private $keyProtection; /** * @var bool|null */ private $isKeyRestricted; /** * @var bool|null */ private $isFreshUserVerificationRequired; /** * @var int */ private $matcherProtection; /** * @var int|null */ private $cryptoStrength; /** * @var string|null */ private $operatingEnv; /** * @var int */ private $attachmentHint = 0; /** * @var bool|null */ private $isSecondFactorOnly; /** * @var int */ private $tcDisplay; /** * @var string|null */ private $tcDisplayContentType; /** * @var DisplayPNGCharacteristicsDescriptor[] */ private $tcDisplayPNGCharacteristics = []; /** * @var string[] */ private $attestationRootCertificates = []; /** * @var EcdaaTrustAnchor[] */ private $ecdaaTrustAnchors = []; /** * @var string|null */ private $icon; /** * @var ExtensionDescriptor[] */ private $supportedExtensions = []; public function getLegalHeader(): ?string { return $this->legalHeader; } public function getAaid(): ?string { return $this->aaid; } public function getAaguid(): ?string { return $this->aaguid; } /** * @return string[] */ public function getAttestationCertificateKeyIdentifiers(): array { return $this->attestationCertificateKeyIdentifiers; } public function getDescription(): string { return $this->description; } /** * @return string[] */ public function getAlternativeDescriptions(): array { return $this->alternativeDescriptions; } public function getAuthenticatorVersion(): int { return $this->authenticatorVersion; } public function getProtocolFamily(): string { return $this->protocolFamily; } /** * @return Version[] */ public function getUpv(): array { return $this->upv; } public function getAssertionScheme(): ?string { return $this->assertionScheme; } public function getAuthenticationAlgorithm(): ?int { return $this->authenticationAlgorithm; } /** * @return int[] */ public function getAuthenticationAlgorithms(): array { return $this->authenticationAlgorithms; } public function getPublicKeyAlgAndEncoding(): ?int { return $this->publicKeyAlgAndEncoding; } /** * @return int[] */ public function getPublicKeyAlgAndEncodings(): array { return $this->publicKeyAlgAndEncodings; } /** * @return int[] */ public function getAttestationTypes(): array { return $this->attestationTypes; } /** * @return VerificationMethodANDCombinations[] */ public function getUserVerificationDetails(): array { return $this->userVerificationDetails; } public function getKeyProtection(): int { return $this->keyProtection; } public function isKeyRestricted(): ?bool { return (bool) $this->isKeyRestricted; } public function isFreshUserVerificationRequired(): ?bool { return (bool) $this->isFreshUserVerificationRequired; } public function getMatcherProtection(): int { return $this->matcherProtection; } public function getCryptoStrength(): ?int { return $this->cryptoStrength; } public function getOperatingEnv(): ?string { return $this->operatingEnv; } public function getAttachmentHint(): int { return $this->attachmentHint; } public function isSecondFactorOnly(): ?bool { return (bool) $this->isSecondFactorOnly; } public function getTcDisplay(): int { return $this->tcDisplay; } public function getTcDisplayContentType(): ?string { return $this->tcDisplayContentType; } /** * @return DisplayPNGCharacteristicsDescriptor[] */ public function getTcDisplayPNGCharacteristics(): array { return $this->tcDisplayPNGCharacteristics; } /** * @return string[] */ public function getAttestationRootCertificates(): array { return $this->attestationRootCertificates; } /** * @return EcdaaTrustAnchor[] */ public function getEcdaaTrustAnchors(): array { return $this->ecdaaTrustAnchors; } public function getIcon(): ?string { return $this->icon; } /** * @return ExtensionDescriptor[] */ public function getSupportedExtensions(): array { return $this->supportedExtensions; } public static function createFromArray(array $data): self { $object = new self(); foreach (['description', 'protocolFamily'] as $key) { if (!isset($data[$key])) { throw new InvalidArgumentException(sprintf('The parameter "%s" is missing', $key)); } } $object->legalHeader = $data['legalHeader'] ?? null; $object->aaid = $data['aaid'] ?? null; $object->aaguid = $data['aaguid'] ?? null; $object->attestationCertificateKeyIdentifiers = $data['attestationCertificateKeyIdentifiers'] ?? []; $object->description = $data['description']; $object->alternativeDescriptions = $data['alternativeDescriptions'] ?? []; $object->authenticatorVersion = $data['authenticatorVersion'] ?? 0; $object->protocolFamily = $data['protocolFamily']; if (isset($data['upv'])) { $upv = $data['upv']; Assertion::isArray($upv, 'Invalid Metadata Statement'); foreach ($upv as $value) { Assertion::isArray($value, 'Invalid Metadata Statement'); $object->upv[] = Version::createFromArray($value); } } $object->assertionScheme = $data['assertionScheme'] ?? null; $object->authenticationAlgorithm = $data['authenticationAlgorithm'] ?? null; $object->authenticationAlgorithms = $data['authenticationAlgorithms'] ?? []; $object->publicKeyAlgAndEncoding = $data['publicKeyAlgAndEncoding'] ?? null; $object->publicKeyAlgAndEncodings = $data['publicKeyAlgAndEncodings'] ?? []; $object->attestationTypes = $data['attestationTypes'] ?? []; if (isset($data['userVerificationDetails'])) { $userVerificationDetails = $data['userVerificationDetails']; Assertion::isArray($userVerificationDetails, 'Invalid Metadata Statement'); foreach ($userVerificationDetails as $value) { Assertion::isArray($value, 'Invalid Metadata Statement'); $object->userVerificationDetails[] = VerificationMethodANDCombinations::createFromArray($value); } } $object->keyProtection = $data['keyProtection'] ?? 0; $object->isKeyRestricted = $data['isKeyRestricted'] ?? null; $object->isFreshUserVerificationRequired = $data['isFreshUserVerificationRequired'] ?? null; $object->matcherProtection = $data['matcherProtection'] ?? 0; $object->cryptoStrength = $data['cryptoStrength'] ?? null; $object->operatingEnv = $data['operatingEnv'] ?? null; $object->attachmentHint = $data['attachmentHint'] ?? 0; $object->isSecondFactorOnly = $data['isSecondFactorOnly'] ?? null; $object->tcDisplay = $data['tcDisplay'] ?? 0; $object->tcDisplayContentType = $data['tcDisplayContentType'] ?? null; if (isset($data['tcDisplayPNGCharacteristics'])) { $tcDisplayPNGCharacteristics = $data['tcDisplayPNGCharacteristics']; Assertion::isArray($tcDisplayPNGCharacteristics, 'Invalid Metadata Statement'); foreach ($tcDisplayPNGCharacteristics as $tcDisplayPNGCharacteristic) { Assertion::isArray($tcDisplayPNGCharacteristic, 'Invalid Metadata Statement'); $object->tcDisplayPNGCharacteristics[] = DisplayPNGCharacteristicsDescriptor::createFromArray($tcDisplayPNGCharacteristic); } } $object->attestationRootCertificates = $data['attestationRootCertificates'] ?? []; $object->ecdaaTrustAnchors = $data['ecdaaTrustAnchors'] ?? []; $object->icon = $data['icon'] ?? null; if (isset($data['supportedExtensions'])) { $supportedExtensions = $data['supportedExtensions']; Assertion::isArray($supportedExtensions, 'Invalid Metadata Statement'); foreach ($supportedExtensions as $supportedExtension) { Assertion::isArray($supportedExtension, 'Invalid Metadata Statement'); $object->supportedExtensions[] = ExtensionDescriptor::createFromArray($supportedExtension); } } return $object; } } src/EcdaaTrustAnchor.php 0000644 00000002667 15173524301 0011252 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; class EcdaaTrustAnchor { /** * @var string */ private $X; /** * @var string */ private $Y; /** * @var string */ private $c; /** * @var string */ private $sx; /** * @var string */ private $sy; /** * @var string */ private $G1Curve; public function getX(): string { return $this->X; } public function getY(): string { return $this->Y; } public function getC(): string { return $this->c; } public function getSx(): string { return $this->sx; } public function getSy(): string { return $this->sy; } public function getG1Curve(): string { return $this->G1Curve; } public static function createFromArray(array $data): self { $object = new self(); $object->X = $data['X'] ?? null; $object->Y = $data['Y'] ?? null; $object->c = $c['data'] ?? null; $object->sx = $data['sx'] ?? null; $object->sy = $data['sy'] ?? null; $object->G1Curve = $data['G1Curve'] ?? null; return $object; } } src/MetadataTOCPayloadEntry.php 0000644 00000006216 15173524301 0012474 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; use Assert\Assertion; class MetadataTOCPayloadEntry { /** * @var string|null */ private $aaid; /** * @var string|null */ private $aaguid; /** * @var string[] */ private $attestationCertificateKeyIdentifiers = []; /** * @var string|null */ private $hash; /** * @var string|null */ private $url; /** * @var BiometricStatusReport[] */ private $biometricStatusReports = []; /** * @var StatusReport[] */ private $statusReports = []; /** * @var string */ private $timeOfLastStatusChange; /** * @var string */ private $rogueListURL; /** * @var string */ private $rogueListHash; public function getAaid(): ?string { return $this->aaid; } public function getAaguid(): ?string { return $this->aaguid; } public function getAttestationCertificateKeyIdentifiers(): array { return $this->attestationCertificateKeyIdentifiers; } public function getHash(): ?string { return $this->hash; } public function getUrl(): ?string { return $this->url; } public function getBiometricStatusReports(): array { return $this->biometricStatusReports; } /** * @return StatusReport[] */ public function getStatusReports(): array { return $this->statusReports; } public function getTimeOfLastStatusChange(): string { return $this->timeOfLastStatusChange; } public function getRogueListURL(): string { return $this->rogueListURL; } public function getRogueListHash(): string { return $this->rogueListHash; } public static function createFromArray(array $data): self { $object = new self(); $object->aaid = $data['aaid'] ?? null; $object->aaguid = $data['aaguid'] ?? null; $object->attestationCertificateKeyIdentifiers = $data['attestationCertificateKeyIdentifiers'] ?? null; $object->hash = $data['hash'] ?? null; $object->url = $data['url'] ?? null; $object->biometricStatusReports = isset($data['biometricStatusReports']) ? BiometricStatusReport::createFromArray($data['biometricStatusReports']) : null; $object->statusReports = []; if (isset($data['statusReports'])) { Assertion::isArray($data['statusReports'], 'Invalid status report'); foreach ($data['statusReports'] as $k => $statusReport) { $object->statusReports[$k] = StatusReport::createFromArray($statusReport); } } $object->timeOfLastStatusChange = $data['timeOfLastStatusChange'] ?? null; $object->rogueListURL = $data['rogueListURL'] ?? null; $object->rogueListHash = $data['rogueListHash'] ?? null; return $object; } } src/MetadataTOCPayload.php 0000644 00000002722 15173524301 0011450 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; class MetadataTOCPayload { /** * @var string|null */ private $legalHeader; /** * @var int */ private $no; /** * @var string */ private $nextUpdate; /** * @var MetadataTOCPayloadEntry[] */ private $entries = []; public function getLegalHeader(): ?string { return $this->legalHeader; } public function getNo(): int { return $this->no; } public function getNextUpdate(): string { return $this->nextUpdate; } /** * @return MetadataTOCPayloadEntry[] */ public function getEntries(): array { return $this->entries; } public static function createFromArray(array $data): self { $object = new self(); $object->legalHeader = $data['legalHeader'] ?? null; $object->nextUpdate = $data['nextUpdate'] ?? null; $object->no = $data['no'] ?? null; $object->entries = []; if (isset($data['entries'])) { foreach ($data['entries'] as $k => $entry) { $object->entries[$k] = MetadataTOCPayloadEntry::createFromArray($entry); } } return $object; } } src/MetadataStatementRepository.php 0000644 00000000602 15173524301 0013550 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; interface MetadataStatementRepository { public function findOneByAAGUID(string $aaguid): ?MetadataStatement; } src/DistantSingleMetadataFactory.php 0000644 00000002070 15173524301 0013605 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestFactoryInterface; class DistantSingleMetadataFactory { /** * @var ClientInterface */ private $httpClient; /** * @var RequestFactoryInterface */ private $requestFactory; public function __construct(ClientInterface $httpClient, RequestFactoryInterface $requestFactory) { $this->httpClient = $httpClient; $this->requestFactory = $requestFactory; } public function create(string $uri, bool $isBare64Encoded, array $additionalHeaders = [], ?ClientInterface $client = null): DistantSingleMetadata { $client = $client ?? $this->httpClient; return new DistantSingleMetadata($uri, $isBare64Encoded, $client, $this->requestFactory, $additionalHeaders); } } src/Version.php 0000644 00000001412 15173524301 0007470 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; class Version { /** * @var int */ private $major; /** * @var int */ private $minor; public function getMajor(): int { return $this->major; } public function getMinor(): int { return $this->minor; } public static function createFromArray(array $data): self { $object = new self(); $object->major = $data['major'] ?? null; $object->minor = $data['minor'] ?? null; return $object; } } src/ExtensionDescriptor.php 0000644 00000002251 15173524301 0012060 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; class ExtensionDescriptor { /** * @var string */ private $id; /** * @var int|null */ private $tag; /** * @var string|null */ private $data; /** * @var bool */ private $fail_if_unknown; public function getId(): string { return $this->id; } public function getTag(): ?int { return $this->tag; } public function getData(): ?string { return $this->data; } public function isFailIfUnknown(): bool { return $this->fail_if_unknown; } public static function createFromArray(array $data): self { $object = new self(); $object->id = $data['id'] ?? null; $object->tag = $data['tag'] ?? null; $object->data = $data['data'] ?? null; $object->fail_if_unknown = $data['fail_if_unknown'] ?? null; return $object; } } src/MetadataServiceFactory.php 0000644 00000002122 15173524301 0012433 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestFactoryInterface; class MetadataServiceFactory { /** * @var ClientInterface */ private $httpClient; /** * @var RequestFactoryInterface */ private $requestFactory; public function __construct(ClientInterface $httpClient, RequestFactoryInterface $requestFactory) { $this->httpClient = $httpClient; $this->requestFactory = $requestFactory; } public function create(string $serviceUri, array $additionalQueryStringValues = [], array $additionalHeaders = [], ?ClientInterface $client = null): MetadataService { $client = $client ?? $this->httpClient; return new MetadataService($serviceUri, $client, $this->requestFactory, $additionalQueryStringValues, $additionalHeaders); } } src/DistantSingleMetadata.php 0000644 00000002662 15173524301 0012264 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestFactoryInterface; class DistantSingleMetadata extends SingleMetadata { /** * @var ClientInterface */ private $httpClient; /** * @var RequestFactoryInterface */ private $requestFactory; /** * @var array */ private $additionalHeaders; /** * @var string */ private $uri; /** * @var bool */ private $isBare64Encoded; public function __construct(string $uri, bool $isBare64Encoded, ClientInterface $httpClient, RequestFactoryInterface $requestFactory, array $additionalHeaders = []) { parent::__construct($uri, $isBare64Encoded); //Useless $this->uri = $uri; $this->isBare64Encoded = $isBare64Encoded; $this->httpClient = $httpClient; $this->requestFactory = $requestFactory; $this->additionalHeaders = $additionalHeaders; } public function getMetadataStatement(): MetadataStatement { return MetadataStatementFetcher::fetchMetadataStatement($this->uri, $this->isBare64Encoded, $this->httpClient, $this->requestFactory, $this->additionalHeaders); } } src/RgbPaletteEntry.php 0000644 00000001612 15173524301 0011120 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; class RgbPaletteEntry { /** * @var int */ private $r; /** * @var int */ private $g; /** * @var int */ private $b; public function getR(): int { return $this->r; } public function getG(): int { return $this->g; } public function getB(): int { return $this->b; } public static function createFromArray(array $data): self { $object = new self(); $object->r = $data['r'] ?? null; $object->g = $data['g'] ?? null; $object->b = $data['b'] ?? null; return $object; } } src/MetadataStatementFetcher.php 0000644 00000007114 15173524301 0012756 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; use Assert\Assertion; use Base64Url\Base64Url; use Jose\Component\KeyManagement\JWKFactory; use Jose\Component\Signature\Algorithm\ES256; use Jose\Component\Signature\Serializer\CompactSerializer; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestFactoryInterface; class MetadataStatementFetcher { public static function fetchTableOfContent(string $uri, ClientInterface $client, RequestFactoryInterface $requestFactory, array $additionalHeaders = []): MetadataTOCPayload { $content = self::fetch($uri, $client, $requestFactory, $additionalHeaders); $payload = self::getJwsPayload($content); $data = json_decode($payload, true); Assertion::eq(JSON_ERROR_NONE, json_last_error(), 'Unable to decode the data'); return MetadataTOCPayload::createFromArray($data); } public static function fetchMetadataStatement(string $uri, bool $isBase64UrlEncoded, ClientInterface $client, RequestFactoryInterface $requestFactory, array $additionalHeaders = []): MetadataStatement { $payload = self::fetch($uri, $client, $requestFactory, $additionalHeaders); $json = $isBase64UrlEncoded ? Base64Url::decode($payload) : $payload; $data = json_decode($json, true); Assertion::eq(JSON_ERROR_NONE, json_last_error(), 'Unable to decode the data'); return MetadataStatement::createFromArray($data); } private static function fetch(string $uri, ClientInterface $client, RequestFactoryInterface $requestFactory, array $additionalHeaders = []): string { $request = $requestFactory->createRequest('GET', $uri); foreach ($additionalHeaders as $k => $v) { $request = $request->withHeader($k, $v); } $response = $client->sendRequest($request); Assertion::eq(200, $response->getStatusCode(), sprintf('Unable to contact the server. Response code is %d', $response->getStatusCode())); $content = $response->getBody()->getContents(); Assertion::notEmpty($content, 'Unable to contact the server. The response has no content'); return $content; } private static function getJwsPayload(string $token): string { $jws = (new CompactSerializer())->unserialize($token); Assertion::eq(1, $jws->countSignatures(), 'Invalid response from the metadata service. Only one signature shall be present.'); $signature = $jws->getSignature(0); $payload = $jws->getPayload(); Assertion::notEmpty($payload, 'Invalid response from the metadata service. The token payload is empty.'); $header = $signature->getProtectedHeader(); Assertion::keyExists($header, 'alg', 'The "alg" parameter is missing.'); Assertion::eq($header['alg'], 'ES256', 'The expected "alg" parameter value should be "ES256".'); Assertion::keyExists($header, 'x5c', 'The "x5c" parameter is missing.'); Assertion::isArray($header['x5c'], 'The "x5c" parameter should be an array.'); $key = JWKFactory::createFromX5C($header['x5c']); $algorithm = new ES256(); $isValid = $algorithm->verify($key, $signature->getEncodedProtectedHeader().'.'.$jws->getEncodedPayload(), $signature->getSignature()); Assertion::true($isValid, 'Invalid response from the metadata service. The token signature is invalid.'); return $jws->getPayload(); } } src/StatusReport.php 0000644 00000004617 15173524301 0010534 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; class StatusReport { /** * @var string * * @see AuthenticatorStatus */ private $status; /** * @var string|null */ private $effectiveDate; /** * @var string|null */ private $certificate; /** * @var string|null */ private $url; /** * @var string|null */ private $certificationDescriptor; /** * @var string|null */ private $certificateNumber; /** * @var string|null */ private $certificationPolicyVersion; /** * @var string|null */ private $certificationRequirementsVersion; public function getStatus(): string { return $this->status; } public function getEffectiveDate(): ?string { return $this->effectiveDate; } public function getCertificate(): ?string { return $this->certificate; } public function getUrl(): ?string { return $this->url; } public function getCertificationDescriptor(): ?string { return $this->certificationDescriptor; } public function getCertificateNumber(): ?string { return $this->certificateNumber; } public function getCertificationPolicyVersion(): ?string { return $this->certificationPolicyVersion; } public function getCertificationRequirementsVersion(): ?string { return $this->certificationRequirementsVersion; } public static function createFromArray(array $data): self { $object = new self(); $object->status = $data['status'] ?? null; $object->effectiveDate = $data['effectiveDate'] ?? null; $object->certificate = $data['certificate'] ?? null; $object->url = $data['url'] ?? null; $object->certificationDescriptor = $data['certificationDescriptor'] ?? null; $object->certificateNumber = $data['certificateNumber'] ?? null; $object->certificationPolicyVersion = $data['certificationPolicyVersion'] ?? null; $object->certificationRequirementsVersion = $data['certificationRequirementsVersion'] ?? null; return $object; } } src/PatternAccuracyDescriptor.php 0000644 00000002105 15173524301 0013172 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; class PatternAccuracyDescriptor { /** * @var int */ private $minComplexity; /** * @var int|null */ private $maxRetries; /** * @var int|null */ private $blockSlowdown; public function getMinComplexity(): int { return $this->minComplexity; } public function getMaxRetries(): ?int { return $this->maxRetries; } public function getBlockSlowdown(): ?int { return $this->blockSlowdown; } public static function createFromArray(array $data): self { $object = new self(); $object->minComplexity = $data['minComplexity'] ?? null; $object->maxRetries = $data['maxRetries'] ?? null; $object->blockSlowdown = $data['blockSlowdown'] ?? null; return $object; } } src/SimpleMetadataStatementRepository.php 0000644 00000011143 15173524301 0014724 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; use DateTimeImmutable; use Psr\Cache\CacheItemPoolInterface; use Throwable; class SimpleMetadataStatementRepository implements MetadataStatementRepository { /** * @var CacheItemPoolInterface */ private $cacheItemPool; /** * @var MetadataService[] */ private $services = []; /** * @var SingleMetadata[] */ private $singleStatements = []; public function __construct(CacheItemPoolInterface $cacheItemPool) { $this->cacheItemPool = $cacheItemPool; } public function addService(string $name, MetadataService $service): void { $this->services[$name] = $service; } public function addSingleStatement(string $name, SingleMetadata $singleStatements): void { $this->singleStatements[$name] = $singleStatements; } public function findOneByAAGUID(string $aaguid): ?MetadataStatement { $metadataStatement = $this->findOneByAAGUIDFromServices($aaguid); if (null !== $metadataStatement) { return $metadataStatement; } return $this->findOneByAAGUIDFromSingleStatements($aaguid); } private function findOneByAAGUIDFromSingleStatements(string $aaguid): ?MetadataStatement { foreach ($this->singleStatements as $name => $singleStatement) { try { $singleCacheItem = $this->cacheItemPool->getItem(sprintf('MDS-%s', $name)); if (!$singleCacheItem->isHit()) { $metadataStatement = $singleStatement->getMetadataStatement(); $singleCacheItem->set($metadataStatement); $this->cacheItemPool->save($singleCacheItem); } else { $metadataStatement = $singleCacheItem->get(); } if ($metadataStatement->getAaguid() === $aaguid) { return $metadataStatement; } } catch (Throwable $throwable) { continue; } } return null; } private function findOneByAAGUIDFromServices(string $aaguid): ?MetadataStatement { foreach ($this->services as $name => $service) { try { $tocCacheItem = $this->cacheItemPool->getItem(sprintf('TOC-%s', $name)); if (!$tocCacheItem->isHit()) { $tableOfContent = $service->getMetadataTOCPayload(); $tocCacheItem->set($tableOfContent); $this->cacheItemPool->save($tocCacheItem); $needCacheUpdate = true; } else { $tableOfContent = $tocCacheItem->get(); $nextUpdate = DateTimeImmutable::createFromFormat('Y-m-d', $tableOfContent->getNextUpdate()); if (false === $nextUpdate) { $needCacheUpdate = true; } else { $needCacheUpdate = $nextUpdate->getTimestamp() < time(); if ($needCacheUpdate) { $tableOfContent = $service->getMetadataTOCPayload(); $tocCacheItem->set($tableOfContent); $this->cacheItemPool->save($tocCacheItem); } } } } catch (Throwable $throwable) { continue; } foreach ($tableOfContent->getEntries() as $entry) { $url = $entry->getUrl(); if (null === $url) { continue; } try { $mdsCacheItem = $this->cacheItemPool->getItem(sprintf('MDS-%s', urlencode($url))); if ($mdsCacheItem->isHit() && !$needCacheUpdate) { $metadataStatement = $mdsCacheItem->get(); } else { $metadataStatement = $service->getMetadataStatementFor($entry); $mdsCacheItem->set($metadataStatement); $this->cacheItemPool->save($mdsCacheItem); } if ($metadataStatement->getAaguid() === $aaguid) { return $metadataStatement; } } catch (Throwable $throwable) { continue; } } } return null; } } src/RogueListEntry.php 0000644 00000001410 15173524301 0011000 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2019 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ namespace Webauthn\MetadataService; class RogueListEntry { /** * @var string */ private $sk; /** * @var string */ private $date; public function getSk(): string { return $this->sk; } public function getDate(): string { return $this->date; } public static function createFromArray(array $data): self { $object = new self(); $object->sk = $data['sk'] ?? null; $object->date = $data['date'] ?? null; return $object; } } LICENSE 0000644 00000002054 15173524301 0005553 0 ustar 00 MIT License Copyright (c) 2018 Spomky-Labs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
| ver. 1.4 |
Github
|
.
| PHP 8.3.23 | Generation time: 0 |
proxy
|
phpinfo
|
Settings