Skip to content

Commit

Permalink
Merge pull request #304 from getyoti/release/4.1.0
Browse files Browse the repository at this point in the history
- Was added support for a static liveness check
- Was added support for allowing the Relying Business to enable/disable the use of expired documents
(new OrthogonalRestrictionsFilterBuilder())
            -> withAllowExpiredDocuments()  // enable
            ->withDenyExpiredDocuments() // disable
            ->build();
- Was added support for a face comparison check
- Was fixed bug with 'uploadFaceCaptureImage' function
- Support only for php7.4.* + php 8.0.* + php8.1.* version
- Was updated guzzle http/guzzle to ^7.0 version
- Was updated guzzle http/psr7 to ^2.4 version
- Was removed php7.1 support
  • Loading branch information
LuborRod authored Nov 1, 2022
2 parents a5c4379 + 4b1cea9 commit aa8cd8e
Show file tree
Hide file tree
Showing 34 changed files with 873 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/sonar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fetch-depth: 0
- uses: shivammathur/[email protected]
with:
php-version: 8.0
php-version: 8.1

- run: composer install
- run: composer coverage-clover
Expand Down
40 changes: 33 additions & 7 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Unit Tests
on: [ push, pull_request_target ]

jobs:
php8compat:
name: Unit Tests PHP8 Compatibility (php ${{ matrix.php-version }})
php8-1:
name: Unit Tests php8.1 (php ${{ matrix.php-version }})
runs-on: ubuntu-latest
# always run on push events
# only run on pull_request_target event when pull request pulls from fork repository
Expand All @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: [ 8.0 ]
php-version: [ 8.1 ]

steps:
- uses: actions/checkout@v2
Expand All @@ -31,14 +31,14 @@ jobs:

- run: composer test

php7:
name: Unit Tests (php ${{ matrix.php-version }})
php7-4:
name: Unit Tests php7.4 (php ${{ matrix.php-version }})
runs-on: ubuntu-latest
# always run on push events
# only run on pull_request_target event when pull request pulls from fork repository
if: >
github.event_name == 'push' ||
github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository
github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository
strategy:
fail-fast: false
matrix:
Expand All @@ -57,6 +57,32 @@ jobs:

- run: composer test

php8-0:
name: Unit Tests php8.0 (php ${{ matrix.php-version }})
runs-on: ubuntu-latest
# always run on push events
# only run on pull_request_target event when pull request pulls from fork repository
if: >
github.event_name == 'push' ||
github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository
strategy:
fail-fast: false
matrix:
php-version: [ 8.0 ]

steps:
- uses: actions/checkout@v2

- uses: shivammathur/[email protected]
with:
php-version: ${{ matrix.php-version }}

- run: composer self-update

- run: composer install --no-interaction --prefer-source --dev

- run: composer test

protobuf:
name: Unit Tests With Protobuf C Extension 3.13 (php ${{ matrix.php-version }})
runs-on: ubuntu-latest
Expand All @@ -68,7 +94,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: [ 7.4 ]
php-version: [ 8.1 ]

steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 5 additions & 1 deletion .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
->in(__DIR__ . '/tests')
;

return PhpCsFixer\Config::create()
$config = new PhpCsFixer\Config();
$config
->setRiskyAllowed(true)
->setRules([
'array_syntax' => ['syntax' => 'short'],
'no_unused_imports' => true,
Expand All @@ -22,3 +24,5 @@
])
->setFinder($finder)
;

return $config;
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ composer coverage-clover
We follow the [PSR-12 Style Guide](https://www.php-fig.org/psr/psr-12/), which
is configured in [.phpcs.xml.dist](.phpcs.xml.dist).

Additional checks are configured in [.php_cs.dist](.php_cs.dist) - See
Additional checks are configured in [.php-cs-fixer.dist.php](.php-cs-fixer.dist.php) - See
<https://cs.symfony.com/> for further information.

Coding style can be verified by running:
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"name": "yoti/yoti-php-sdk",
"description": "Yoti SDK for quickly integrating your PHP backend with Yoti",
"version": "4.0.0",
"version": "4.1.0",
"keywords": [
"yoti",
"sdk"
],
"homepage": "https://yoti.com",
"license": "MIT",
"require": {
"php": "^7.1 || ^8.0",
"php": "^7.4 || ^8.0 || ^8.1",
"ext-json": "*",
"google/protobuf": "^3.10",
"phpseclib/phpseclib": "^3.0",
"guzzlehttp/guzzle": "^6.4 || ^7.0",
"guzzlehttp/guzzle": "^7.0",
"psr/http-client": "^1.0",
"psr/http-message": "^1.0",
"guzzlehttp/psr7": "^2.0",
"guzzlehttp/psr7": "^2.4",
"ext-openssl": "*"
},
"autoload": {
Expand All @@ -27,7 +27,7 @@
"require-dev": {
"phpunit/phpunit": "^9.5.13",
"squizlabs/php_codesniffer": "^3.4",
"friendsofphp/php-cs-fixer": "^2.15",
"friendsofphp/php-cs-fixer": "^3.4",
"brainmaestro/composer-git-hooks": "^2.8",
"phpstan/phpstan-strict-rules": "^0.12.1",
"phpstan/extension-installer": "^1.0",
Expand All @@ -45,12 +45,12 @@
"coverage-clover": "phpunit --coverage-clover ./coverage/coverage.xml",
"coverage-html": "phpunit --coverage-html ./coverage/report",
"fix": [
"php-cs-fixer fix --config=.php_cs.dist -v --using-cache=no --diff-format=udiff --ansi",
"php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no",
"phpcbf"
],
"lint": [
"phpcs",
"php-cs-fixer fix --config=.php_cs.dist -v --dry-run --using-cache=no --diff-format=udiff --ansi",
"php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --dry-run --using-cache=no",
"phpstan analyse"
],
"post-install-cmd": "cghooks add --ignore-lock",
Expand Down
2 changes: 1 addition & 1 deletion src/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Constants
public const SDK_IDENTIFIER = 'PHP';

/** Default SDK version */
public const SDK_VERSION = '4.0.0';
public const SDK_VERSION = '4.1.0';

/** Base url for connect page (user will be redirected to this page eg. baseurl/app-id) */
public const CONNECT_BASE_URL = 'https://www.yoti.com/connect';
Expand Down
1 change: 1 addition & 0 deletions src/DocScan/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Constants
public const LIVENESS = 'LIVENESS';
public const WATCHLIST_SCREENING = 'WATCHLIST_SCREENING';
public const WATCHLIST_ADVANCED_CA = 'WATCHLIST_ADVANCED_CA';
public const FACE_COMPARISON = 'FACE_COMPARISON';

public const WITH_YOTI_ACCOUNT = 'WITH_YOTI_ACCOUNT';
public const WITH_CUSTOM_ACCOUNT = 'WITH_CUSTOM_ACCOUNT';
Expand Down
28 changes: 28 additions & 0 deletions src/DocScan/Session/Create/Check/RequestedFaceComparisonCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Yoti\DocScan\Session\Create\Check;

use Yoti\DocScan\Constants;

class RequestedFaceComparisonCheck extends RequestedCheck
{
/**
* @var RequestedFaceComparisonCheckConfig
*/
private $config;

public function __construct(RequestedFaceComparisonCheckConfig $config)
{
$this->config = $config;
}

protected function getType(): string
{
return Constants::FACE_COMPARISON;
}

protected function getConfig(): ?RequestedCheckConfigInterface
{
return $this->config;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Yoti\DocScan\Session\Create\Check;

use Yoti\DocScan\Session\Create\Traits\Builder\ManualCheckTrait;
use Yoti\Util\Validation;

class RequestedFaceComparisonCheckBuilder
{
use ManualCheckTrait;

public function build(): RequestedFaceComparisonCheck
{
Validation::notEmptyString($this->manualCheck, 'manualCheck');

$config = new RequestedFaceComparisonCheckConfig($this->manualCheck);
return new RequestedFaceComparisonCheck($config);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Yoti\DocScan\Session\Create\Check;

use stdClass;

class RequestedFaceComparisonCheckConfig implements RequestedCheckConfigInterface
{
/**
* @var string
*/
private $manualCheck;

public function __construct(string $manualCheck)
{
$this->manualCheck = $manualCheck;
}

/**
* @return stdClass
*/
public function jsonSerialize(): stdClass
{
return (object) [
'manual_check' => $this->getManualCheck(),
];
}

/**
* @return string
*/
public function getManualCheck(): string
{
return $this->manualCheck;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

namespace Yoti\DocScan\Session\Create\Check;

use Yoti\DocScan\Constants;
use Yoti\Util\Validation;

class RequestedLivenessCheckBuilder
{
private const ZOOM = 'ZOOM';
private const STATIC = 'STATIC';

/**
* @var string
Expand All @@ -20,11 +22,21 @@ class RequestedLivenessCheckBuilder
*/
private $maxRetries = 1;

/**
* @var string|null
*/
private $manualCheck = null;

public function forZoomLiveness(): self
{
return $this->forLivenessType(self::ZOOM);
}

public function forStaticLiveness(): self
{
return $this->forLivenessType(self::STATIC);
}

public function forLivenessType(string $livenessType): self
{
$this->livenessType = $livenessType;
Expand All @@ -37,12 +49,23 @@ public function withMaxRetries(int $maxRetries): self
return $this;
}

public function withoutManualCheck(): self
{
return $this->withManualCheck(Constants::NEVER);
}

private function withManualCheck(string $manualCheck): self
{
$this->manualCheck = $manualCheck;
return $this;
}

public function build(): RequestedLivenessCheck
{
Validation::notEmptyString($this->livenessType, 'livenessType');
Validation::notNull($this->maxRetries, 'maxRetries');

$config = new RequestedLivenessConfig($this->livenessType, $this->maxRetries);
$config = new RequestedLivenessConfig($this->livenessType, $this->maxRetries, $this->manualCheck);
return new RequestedLivenessCheck($config);
}
}
24 changes: 22 additions & 2 deletions src/DocScan/Session/Create/Check/RequestedLivenessConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,33 @@ class RequestedLivenessConfig implements RequestedCheckConfigInterface
*/
private $maxRetries;

public function __construct(string $livenessType, int $maxRetries)
/**
* @var string|null
*/
private $manualCheck;

public function __construct(string $livenessType, int $maxRetries, string $manualCheck = null)
{
$this->livenessType = $livenessType;
$this->maxRetries = $maxRetries;
$this->manualCheck = $manualCheck;
}

/**
* @return stdClass
*/
public function jsonSerialize(): stdClass
{
return (object) [
$data = [
'liveness_type' => $this->getLivenessType(),
'max_retries' => $this->getMaxRetries(),
];

if (null !== $this->manualCheck) {
$data['manual_check'] = $this->getManualCheck();
}

return (object)$data;
}

/**
Expand All @@ -50,4 +62,12 @@ public function getMaxRetries(): int
{
return $this->maxRetries;
}

/**
* @return string|null
*/
public function getManualCheck(): ?string
{
return $this->manualCheck;
}
}
Loading

0 comments on commit aa8cd8e

Please sign in to comment.