Skip to content

packagist/private-packagist-api-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Private Packagist API Client

Table of Contents

Requirements

Install

Via Composer:

$ composer require private-packagist/api-client guzzlehttp/guzzle

Why do you need to require guzzlehttp/guzzle? We are decoupled from any HTTP messaging client with help by HTTPlug, so you can pick an HTTP client of your choice, guzzle is merely a recommendation.

Basic usage of private-packagist/api-client client

<?php

// This file is generated by Composer
require_once __DIR__ . '/vendor/autoload.php';

$client = new \PrivatePackagist\ApiClient\Client();
$client->authenticate('api-key', 'api-secret');
$packages = $client->packages()->all();

From $client object, you can access the full Private Packagist API.

Documentation

Full documentation can be found in the Private Packagist documentation.

Organization

Trigger a full synchronization

$jobs = $client->organization()->sync();

Returns an array of created jobs. One for every synchronization.

Team

The permissions available for a team are:

  • canEditTeamPackages: members of the team can edit and remove packages, assign package permissions (only applies to packages assigned to team).
  • canAddPackages: members of the team can add packages to organization; add, edit and remove credentials and mirrored third-party repositories.
  • canCreateSuborganizations: members of the team can create suborganizations.
  • canViewVendorCustomers: members of the team can view customers, their Composer information, their packages, and their install statistics.
  • canManageVendorCustomers: members of the team can create and delete customers, add and remove packages, update their settings, view Composer information and install statistics.
use PrivatePackagist\ApiClient\TeamPermissions;

$permissions = new TeamPermissions;
// Grant all permissions.
$permissions->canEditTeamPackages = true;
$permissions->canAddPackages = true;
$permissions->canCreateSuborganizations = true;
$permissions->canManageVendorCustomers = true;
$permissions->canManageVendorCustomers = true;

The permissions model can also be constructed via flags:

use PrivatePackagist\ApiClient\TeamPermissions;

$permissions = TeamPermissions::fromFlags(
    TeamPermissions::PERMISSION_CAN_EDIT_TEAM_PACKAGES | TeamPermissions::PERMISSION_CAN_ADD_PACKAGES,
);

Or from the permissions of an existing team:

use PrivatePackagist\ApiClient\TeamPermissions;

$team = $client->teams()->all()[0];
$permissions = TeamPermissions::fromTeamResponse($team);

List an organization's teams

$teams = $client->teams()->all();

Returns an array of teams.

Create a New Team

use PrivatePackagist\ApiClient\TeamPermissions;

$permissions = new TeamPermissions;
$team = $client->teams()->create('New Team Name', $permissions);

Creates a team and sets permissions applied to team members. Returns the newly-created team.

Show a Team

$team = $client->teams()->show($teamId);

Returns the team including all its members.

Edit a Team

use PrivatePackagist\ApiClient\TeamPermissions;

$permissions = new TeamPermissions;
$team = $client->teams()->edit($teamId, 'Altered Team Name', $permissions);

Edits a team's name and permissions to be applied to team members. Returns the updated team.

Grant All Package Access

$team = $client->teams()->grantAccessToAllPackages($teamId);

Granting a team access to all packages will give this team access to all current and future organization packages which do not have their permissions synchronized.

Revoke All Package Access

$team = $client->teams()->revokeAccessToAllPackages($teamId);

Revoking a team's access to all packages will not remove access to packages the team can currently access, but will prevent access to new packages and allow revoking individual package access.

Delete a Team

$client->teams()->remove($teamId);

Add Member to Team (by User ID)

$team = $client->teams()->addMember($teamId, $userId);

Returns the team the user was added to.

Remove Member from Team

$client->teams()->removeMember($teamId, $userId);

List all private packages a team has access to

$teamId = 1;
$packages = $client->teams()->packages($teamId);

Returns an array of packages.

Grant a team access to a list of private packages

You pass an array of packages to give access to. The values of the array can be either package ID or package name.

$teamId = 1;
$packages = $client->teams()->addPackages($teamId, ['acme-website/package', 1]);

Returns an array of packages.

Remove access for a package from a team

You can use the package ID or package name as a reference.

$teamId = 1;
$packages = $client->teams()->removePackage($teamId, 'acme-website/package');

Authentication Tokens

List an organization's team authentication tokens

$tokens = $client->tokens()->all();

Returns an array of team tokens.

Create a new team authentication token

// Create a new token with access to all packages
$token = $client->tokens()->create([
    'description' => 'New Team Token',
    'access' => 'read',
    'accessToAllPackages' => true,
]);

// Create a new token with access to packages a team has access to
$token = $client->tokens()->create([
    'description' => 'New Team Token',
    'access' => 'read',
    'teamId' => 1, // Get teamId from the list of teams to determine to which packages the token has access to
]);

Returns the created token.

Delete a team authentication token

$client->tokens()->remove($tokenId));

Regenerate a team authentication token

$customerId = 42;
$confirmation = [
    'IConfirmOldTokenWillStopWorkingImmediately' => true,
];
$token = $client->tokens()->regenerateToken($tokenId, $confirmation);

Returns the regenerated token.

Customer

List an organization's customers

$customers = $client->customers()->all();

Returns an array of customers.

Show a customer

$customerId = 42;
$customer = $client->customers()->show($customerId);
// or
$customerUrlName = 'customer-url-name';
$customer = $client->customers()->show($customerUrlName);

Returns a single customer.

Create a customer

$customer = $client->customers()->create('New customer name');
// or
$customer = $client->customers()->create('New customer name', false, 'customer-url-name', 'beta', true);

Returns the customer.

Edit a customer

$customerId = 42;
$customerData = [
    'name' => $name,
    'urlName' => 'customer',
    'accessToVersionControlSource' => false,
    'minimumAccessibleStability' => 'beta',
    'assignAllPackages' => true,
];
$customer = $client->customers()->edit($customerId, $customerData);

Returns the customer.

Delete a customer

$customerId = 42;
$client->customers()->remove($customerId);

Enable a customer

$customerId = 42;
$customer = $client->customers()->enable($customerId);

Disable a customer

$customerId = 42;
$customer = $client->customers()->disable($customerId);

List a customer's packages

$customerId = 42;
$packages = $client->customers()->listPackages($customerId);

Returns an array of customer packages.

Show a customer's package

$customerId = 42;
$package = $client->customers()->showPackage($customerId, $packageName);
$accessibleVersions = $package['versions'];

Returns a customer's package, including the versions that the customer has been granted access to.

Grant a customer access to a package or edit the limitations

$customerId = 42;
$packages = [
    [
        'name' => 'acme-website/package',
        'versionConstraint' => '^1.0 | ^2.0', // optional version constraint to limit updates the customer receives
        'expirationDate' => (new \DateTime())->add(new \DateInterval('P1Y'))->format('c'), // optional expiration date to limit updates the customer receives
        'minimumAccessibleStability' => 'beta', // optional stability to restrict customers to specific package version stabilities like alpha, beta, or RC
    ],
];
$packages = $client->customers()->addOrEditPackages($customerId, $packages);

Returns an array of all added or edited customer packages.

Revoke access to a package from a customer

You can reference the package by its ID or name.

$customerId = 42;
$packageName = 'acme-website/package';
$client->customers()->removePackage($customerId, $packageName);

Regenerate a customer's Composer repository token

$customerId = 42;
$confirmation = [
    'IConfirmOldTokenWillStopWorkingImmediately' => true,
];
$composerRepository = $client->customers()->regenerateToken($customerId, $confirmation);

Returns the edited Composer repository.

List a customer's vendor bundles

$customerId = 42;
$packages = $client->customers()->vendorBundles()->listVendorBundles($customerId);

Returns an array of customer vendor bundles.

Grant a customer access to a vendor bundle or edit the limitations

$customerId = 42;
$vendorBundleId = 12;
$expirationDate = (new \DateTime())->add(new \DateInterval('P1Y'))->format('c'), // optional expiration date to limit updates the customer receives
$packages = $client->customers()->vendorBundles()->addOrEditVendorBundle($customerId, $vendorBundleId, $expirationDate);

Returns the added or edited customer vendor bundle.

Revoke access to a vendor bundle from a customer

$customerId = 42;
$vendorBundleId = 12;
$client->customers()->vendorBundles()->removeVendorBundle($customerId, $vendorBundleId);

Vendor Bundle

List an organization's vendor bundles

$vendorBundles = $client->vendorBundles()->all();

Returns an array of vendor bundles.

Show a vendor bundle

$vendorBundleId = 42;
$vendorBundle = $client->vendorBundles()->show($vendorBundleId);

Returns a single vendor bundle.

Create a vendor bundle

$vendorBundle = $client->vendorBundles()->create('New bundle name');
// or
$vendorBundle = $client->vendorBundles()->create('New bundle name', 'dev', '^1.0', true, [123]);

Returns the vendor bundle.

Edit a customer

$vendorBundleId = 42;
$vendorBundleData = [
    'name' => 'Bundle name',
    'minimumAccessibleStability' => 'dev',
    'versionConstraint' => '^1.0',
    'assignAllPackages' => true,
    'synchronizationIds' => [123], // A list of synchronization ids for which new packages should automatically be added to the bundle.
];
$vendorBundle = $client->vendorBundles()->edit($vendorBundleId, $vendorBundleData);

Returns the vendor bundle.

Delete a vendor bundle

$vendorBundleId = 42;
$client->vendorBundles()->remove($vendorBundleId);

List packages in a vendor bundle

$vendorBundleId = 42;
$packages = $client->vendorBundles()->packages()->listPackages($vendorBundleId);

Returns an array of vendor bundle packages.

Add one or more packages to a vendor bundle or edit their limitations

$vendorBundleId = 42;
$packages = [
    [
        'name' => 'acme-website/package',
        'versionConstraint' => '^1.0 | ^2.0', // optional version constraint to limit updates the customer receives
        'minimumAccessibleStability' => 'beta', // optional stability to restrict customers to specific package version stabilities like alpha, beta, or RC
    ],
];
$packages = $client->vendorBundles()->packages()->addOrEditPackages($vendorBundleId, $packages);

Returns an array of all added or edited customer packages.

Remove a package from a vendor bundle

You can reference the package by its ID or name.

$vendorBundleId = 42;
$packageName = 'acme-website/package';
$client->vendorBundles()->packages()->removePackage($vendorBundleId, $packageName);

Suborganization

List an organization's suborganizations

$suborganizations = $client->suborganizations()->all();

Returns an array of suborganizations.

Show a suborganization

$suborganizationName = 'suborganization';
$suborganization = $client->suborganizations()->show($suborganizationName);

Returns a single suborganization.

Create a suborganization

$suborganization = $client->suborganizations()->create('New suborganization name');

Returns the suborganization.

Delete a suborganization

$suborganizationName = 'suborganization';
$client->suborganizations()->remove($suborganizationName);

List a suborganization's teams

$suborganizationName = 'suborganization';
$teams = $client->suborganizations()->listTeams($suborganizationName);

Returns an array of suborganizations teams.

Add a team to a suborganization or edit the permission

$suborganizationName = 'suborganization';
$teams = [
    [
        'id' => 12,
        'permission' => 'owner',
    ],
];
$teams = $client->suborganizations()->addOrEditTeams($suborganizationName, $teams);

Returns an array of added suborganization teams.

Remove a team from a suborganization

$suborganizationName = 'suborganization';
$teamId = 12;
$client->suborganizations()->removeTeam($suborganizationName, $teamId);

List a suborganization's packages

$suborganizationName = 'suborganization';
$packages = $client->suborganizations()->packages()->all($suborganizationName);

Returns an array of suborganizations packages.

Show a suborganization package

You can reference a package by its name or ID.

$suborganizationName = 'suborganization';
// Either use package name:
$package = $client->suborganizations()->packages()->show($suborganizationName, 'acme-website/package');
// Or the package ID: 
$package = $client->suborganizations()->packages()->show($suborganizationName, 123);

Returns the package.

Create a vcs package in a suborganization

$suborganizationName = 'suborganization';
$job = $client->suborganizations()->packages()->createVcsPackage($suborganizationName, 'https://github.com/acme-website/package');

Returns a new job.

Create a vcs package with credentials in a suborganization

$suborganizationName = 'suborganization';
$credentialId = 42;
$job = $client->suborganizations()->packages()->createVcsPackage($suborganizationName,'https://github.com/acme-website/package', $credentialId);

Returns a new job.

Create a custom package in a suborganization

$suborganizationName = 'suborganization';
$packageDefinition = '{...}';
$job = $client->suborganizations()->packages()->createCustomPackage($suborganizationName, $packageDefinition);

Returns a new job.

Create a custom package with credentials in a suborganization

$suborganizationName = 'suborganization';
$packageDefinition = '{...}';
$credentialId = 42;
$job = $client->suborganizations()->packages()->createCustomPackage($suborganizationName, $packageDefinition, $credentialId);

Returns a new job.

Edit a vcs package in a suborganization in a suborganization

$suborganizationName = 'suborganization';
$job = $client->suborganizations()->packages()->editVcsPackage($suborganizationName, 'acme-website/package', 'https://github.com/acme-website/package');

Returns a new job.

Edit a custom package in a suborganization

$suborganizationName = 'suborganization';
$packageDefinition = '{...}';
$job = $client->suborganizations()->packages()->editCustomPackage($suborganizationName, 'acme-website/package', $packageDefinition);

Returns a new job.

Delete a package from a suborganization

$suborganizationName = 'suborganization';
$client->suborganizations()->packages()->remove($suborganizationName, 'acme-website/package');

List all dependents of a suborganization package

$suborganizationName = 'suborganization';
$client->suborganizations()->packages()->listDependents($suborganizationName, 'acme-website/package');

Returns a list of packages.

List a suborganization's authentication tokens

$suborganizationName = 'suborganization';
$tokens = $client->suborganizations()->listTokens($suborganizationName);

Returns an array of authentication tokens.

Create a suborganization authentication token

$suborganizationName = 'suborganization';
$data = [
  'description' => 'Suborganization Token',
  'access' => 'read',
];
$token = $client->suborganizations()->createToken($suborganizationName, $data);

Returns the authentication token.

Delete a suborganization authentication token

$suborganizationName = 'suborganization';
$tokenId = 33;
$client->suborganizations()->removeToken($suborganizationName, $tokenId);

Regenerate a suborganization authentication token

$suborganizationName = 'suborganization';
$tokenId = 33;
$confirmation = [
    'IConfirmOldTokenWillStopWorkingImmediately' => true,
];
$token = $client->suborganizations()->regenerateToken($suborganizationName, $confirmation);

Returns the authentication token.

List a suborganization's mirrored repositories

$suborganizationName = 'suborganization';
$mirroredRepositories = $client->suborganizations()->mirroredRepositories()->all($suborganizationName);

Returns an array of mirrored repositories.

Show a mirrored repository

$suborganizationName = 'suborganization';
$mirroredRepositoryId = 42;
$mirroredRepository = $client->suborganizations()->mirroredRepositories()->show($suborganizationName, $mirroredRepositoryId);

Returns the mirrored repository.

Add mirrored repositories to a suborganization

$suborganizationName = 'suborganization';
$mirroredRepositoriesToAdd = [
    ['id' => 12, 'mirroringBehavior' => 'add_on_use'],
];
$mirroredRepository = $client->suborganizations()->mirroredRepositories()->add($suborganizationName, $mirroredRepositoriesToAdd);

Returns a list of added mirrored repositories.

Edit the mirroring behaviour of mirrored repository in a suborganization

$suborganizationName = 'suborganization';
$mirroredRepositoryId = 42;
$mirroredRepository = $client->suborganizations()->mirroredRepositories()->create($suborganizationName, $mirroredRepositoryId, 'add_on_use');

Returns the edited mirrored repository.

Delete a mirrored repository from a suborganization

$suborganizationName = 'suborganization';
$mirroredRepositoryId = 42;
$client->suborganizations()->mirroredRepositories()->remove($suborganizationName, $mirroredRepositoryId);

List all mirrored packages from a mirrored repository in a suborganization

$suborganizationName = 'suborganization';
$mirroredRepositoryId = 42;
$packages = $client->suborganizations()->mirroredRepositories()->listPackages($suborganizationName, $mirroredRepositoryId);

Returns an array of packages.

Add mirrored packages from one mirrored repository to a suborganization

$suborganizationName = 'suborganization';
$mirroredRepositoryId = 42;
$packages = [
    'acme/cool-lib
];
$jobs = $client->suborganizations()->mirroredRepositories()->addPackages($suborganizationName, $mirroredRepositoryId, $packages);

Returns an array of jobs.

Remove all mirrored packages from one mirrored repository in a suborganization

$suborganizationName = 'suborganization';
$mirroredRepositoryId = 42;
$client->suborganizations()->mirroredRepositories()->removePackages($suborganizationName, $mirroredRepositoryId);

Package

You can reference a package by its name or ID.

List an organization's packages

$filters = [
    'origin' => \PrivatePackagist\ApiClient\Api\Packages::ORIGIN_PRIVATE, // optional filter to only receive packages that can be added to customers,
    'security-issue-state' => \PrivatePackagist\ApiClient\Api\SecurityIssues::STATE_OPEN, // optional filter to filter packages with open security issues,
];
$packages = $client->packages()->all($filters);

Returns an array of packages.

Show a package

// Either use package name:
$package = $client->packages()->show('acme-website/package');
// Or the package ID: 
$package = $client->packages()->show(123);

Returns the package.

Create a vcs package

$job = $client->packages()->createVcsPackage('https://github.com/acme-website/package');

Returns a new job.

Create a vcs package with credentials

$credentialId = 42;
$job = $client->packages()->createVcsPackage('https://github.com/acme-website/package', $credentialId);

Returns a new job.

Create a vcs package with a specific type

$job = $client->packages()->createVcsPackage('https://github.com/acme-website/package', null, 'git');

Returns a new job.

Create a custom package

$packageDefinition = '{...}';
$job = $client->packages()->createCustomPackage($packageDefinition);

Returns a new job.

Create a custom package with credentials

$packageDefinition = '{...}';
$credentialId = 42;
$job = $client->packages()->createCustomPackage($packageDefinition, $credentialId);

Returns a new job.

Edit a vcs package

$job = $client->packages()->editVcsPackage('acme-website/package', 'https://github.com/acme-website/package');

Returns a new job.

Edit a custom package

$packageDefinition = '{...}';
$job = $client->packages()->editCustomPackage('acme-website/package', $packageDefinition);

Returns a new job.

Delete a package

$client->packages()->remove('acme-website/package');

List all dependents of a package

$client->packages()->listDependents('acme-website/package');

Returns a list of packages.

List all customers with access to a package

Pass either package ID or package name as argument.

$client->packages()->listCustomers('acme-website/package');

Returns a list of customers with access to the package.

List all security issues of a package

$filters = [
    'security-issue-state' => \PrivatePackagist\ApiClient\Api\SecurityIssues::STATE_OPEN,
];
$client->packages()->listSecurityIssues('acme-website/package', $filters);

Returns a list of security issues.

Show the security monitoring config of a package

$client->packages()->showSecurityMonitoringConfig('acme-website/package');

Returns the security monitoring config of the package.

Edit the security monitoring config of a package

$config = [
    "monitorAllBranches" => false, // If set to true then monitoredBranches will be ignored and can be omitted 
    "monitoredBranches" => [
        "dev-main"
    ],
];
$client->packages()->editSecurityMonitoringConfig('acme-website/package', $config);

Returns the edited security monitoring config of the package.

Create an artifact package file

$fileName = 'package1.zip'; // your package archive artifact containing a valid composer.json in root directory
$file = file_get_contents($fileName);
$client->packages()->artifacts()->create($file, 'application/zip', $fileName);

Create an artifact package

$fileName = 'package1.zip';
$file = file_get_contents($fileName);
$response = $client->packages()->artifacts()->create($file, 'application/zip', $fileName);
$artifactId = $response['id'];
$client->packages()->createArtifactPackage([$artifactId]);

Add an artifact file to an existing package

$packageName = 'acme/artifact';
$fileName = 'package1.zip';
$file = file_get_contents($fileName);
$client->packages()->artifacts()->add($packageName, $file, 'application/zip', $fileName);

Update or replace artifact files of a package

// in case you want to replace the artifact file with a newly uploaded one
// 1. get current artifact ids
$result = $client->packages()->artifacts()->showPackageArtifacts('acme-website/package');
$artifactIds = array_column($result, 'id'); // [41, 42]

// 2. upload the new artifact file
$fileName = 'package1.zip';
$file = file_get_contents($fileName);
$response = $client->packages()->artifacts()->create($file, 'application/zip', $fileName);
$newArtifactId = $response['id'];

// 3. let's say we don't want to have the artifact file id = 41 and use the newly uploaded file instead
$artifactIds = array_shift($artifactIds);
$artifactIds[] = $newArtifactId;
$client->packages()->editArtifactPackage('acme-website/package', $artifactIds);

Credential

List an organization's credentials

$credentials = $client->credentials()->all();

Returns an array of credentials.

Show a credential

$credentialId = 42;
$credential = $client->credentials()->show($credentialId);

Returns the credential.

Create a credential

$type = \PrivatePackagist\ApiClient\Api\Credentials::TYPE_HTTP_BASIC;
$credential = $client->credentials()->create('ACME http auth', $type, 'acme-website.com', 'username', 'password');

Returns the new credential.

Edit a credential

$credentialId = 42;
$type = \PrivatePackagist\ApiClient\Api\Credentials::TYPE_HTTP_BASIC;
$credential = $client->credentials()->edit($credentialId, $type, 'username', 'password');

Returns the edited credential.

Delete a credential

$credentialId = 42;
$client->credentials()->remove($credentialId);

Mirrored Repository

List an organization's mirrored repositories

$mirroredRepositories = $client->mirroredRepositories()->all();

Returns an array of mirrored repositories.

Show a mirrored repository

$mirroredRepositoryId = 42;
$mirroredRepository = $client->mirroredRepositories()->show($mirroredRepositoryId);

Returns the mirrored repository.

Create a mirrored repository

$mirroredRepository = $client->mirroredRepositories()->create('Mirrored Repository', 'https://composer.example.com', 'add_on_use', 543);

Returns the new mirrored repository.

Edit a mirrored repository

$mirroredRepositoryId = 42;
$mirroredRepository = $client->mirroredRepositories()->create($mirroredRepositoryId, 'Mirrored Repository', 'https://composer.example.com', 'add_on_use', 543);

Returns the edited mirrored repository.

Delete a mirrored repository

$mirroredRepositoryId = 42;
$client->mirroredRepositories()->remove($mirroredRepositoryId);

List all mirrored packages from one repository

$mirroredRepositoryId = 42;
$packages = $client->mirroredRepositories()->listPackages($mirroredRepositoryId);

Returns an array of packages.

Add mirrored packages from one repository

$mirroredRepositoryId = 42;
$packages = [
    'acme/cool-lib
];
$jobs = $client->mirroredRepositories()->addPackages($mirroredRepositoryId, $packages);

Returns an array of jobs.

Remove all mirrored packages from one repository

$mirroredRepositoryId = 42;
$client->mirroredRepositories()->removePackages($mirroredRepositoryId);

Job

Show a job

$job = $client->jobs()->show($jobId);

Returns the job.

Wait for a job to finish

This will periodically poll the job status until the job either finished or the maximum wait time was reached

$numberOfSecondsToWait = 180;
$jobHelper = new \PrivatePackagist\ApiClient\JobHelper($client);
try {
    $job = $jobHelper->waitForJob($jobId, $numberOfSecondsToWait);
} catch (\PrivatePackagist\ApiClient\Exception\JobTimeoutException $e) {
    // Job didn't finish within the specified time
} catch (\PrivatePackagist\ApiClient\Exception\JobErrorException $e) {
    // Job finished with an error. See the message for more information
    echo $e->getMessage();
}

Returns the job.

Security Issue

List an organization's security issues

$filters = [
    'security-issue-state' => \PrivatePackagist\ApiClient\Api\SecurityIssues::STATE_OPEN, // optional filter to filter packages with open security issues,
];
$packages = $client->securityIssues()->all($filters);

Returns an array of security issues.

Magento legacy keys

List all legacy keys for a customer

$customerId = 42;
$legacyKeys = $client->customers()->magentoLegacyKeys()->all($customerId);

Returns a list of Magento legacy keys.

Create a new legacy keys for a customer

$legacyKey = $client->customers()->magentoLegacyKeys()->create($customerId, $publicKey, $privateKey);

Returns the new Magento legacy key.

Delete a legacy keys from a customer

$client->customers()->magentoLegacyKeys()->remove($customerId, $publicKey);

Validate incoming webhook payloads

When you create or update a webhook in Private Packagist an optional secret can be set. This secret gets used to create a signature which is sent with each request in the headers as Packagist-Signature. The secret and signature can then be used on your server to validate that the request was made by Private Packagist. If no secret is set then no signature is sent.

$request = /** any Psr7 request */;
$secret = 'webhook-secret';
$webhookSignature = new \PrivatePackagist\ApiClient\WebhookSignature($secret);
$requestSignature = $request->hasHeader('Packagist-Signature') ? $request->getHeader('Packagist-Signature')[0] : null;
$webhookSignature->validate($requestSignature, (string) $request->getBody());

License

private-packagist/api-client is licensed under the MIT License