Affinidi Iota Framework

Manage Affinidi Iota Framework configuration to request data from Affinidi Vault.

Install Dependency

Package: affinidi-tdk/affinidi-tdk-php

composer require affinidi-tdk/affinidi-tdk-php

You can check the latest version of this module on the Packagist repository or view the source code at the GitHub repository.

Classes and Methods

Configurations API

Manage Affinidi Iota Framework configurations to integrate your application to request data from Affinidi Vault.

createIotaConfiguration

Create an Affinidi Iota Framework configuration.

Parameters

CreateIotaConfigurationInput [Object]

JSON object to provide the configuration details. See more here.

Example
require_once 'vendor/autoload.php';

use AffinidiTdk\Clients\IotaClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];

// Configure API key authorization: ProjectTokenAuth
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);

$apiInstance = new IotaClient\Api\ConfigurationsApi(
    new GuzzleHttp\Client(),
    $config
);

try {

    $request = array(
      name => "Sample App",
      walletAri => "<WALLET_ARI>",
      iotaResponseWebhookURL => "http://localhost"
    );

    $result = $apiInstance->createIotaConfiguration($request);

    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}

deleteIotaConfigurationById

Delete existing Affinidi Iota Framework configuration by ID.

Parameters

configurationId [String]

ID of the Affinidi Iota Configuration to delete.

Example
require_once 'vendor/autoload.php';

use AffinidiTdk\Clients\IotaClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];

// Configure API key authorization: ProjectTokenAuth
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);

$apiInstance = new IotaClient\Api\ConfigurationsApi(
    new GuzzleHttp\Client(),
    $config
);

try {

    $configurationId = "<Config_ID>";

    $result = $apiInstance->deleteIotaConfigurationById($configurationId);

    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}

getIotaConfigurationById

Retrieves existing Affinidi Iota Framework by ID.

Parameters

configurationId [String]

ID of the Affinidi Iota Configuration to delete.

Example
require_once 'vendor/autoload.php';

use AffinidiTdk\Clients\IotaClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];

// Configure API key authorization: ProjectTokenAuth
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);

$apiInstance = new IotaClient\Api\ConfigurationsApi(
    new GuzzleHttp\Client(),
    $config
);

try {

    $configurationId = "<Config_ID>";

    $result = $apiInstance->getIotaConfigurationById($configurationId);

    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}

getIotaConfigurationMetaData

Retrieves the Metadata of the existing Affinidi Iota Framework.

Parameters

projectId [String]

Project ID where the Affinidi Iota Framework was created.

configurationId [String]

ID of the existing Affinidi Iota Framework Configuration.

Example
require_once 'vendor/autoload.php';

use AffinidiTdk\Clients\IotaClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];

// Configure API key authorization: ProjectTokenAuth
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);

$apiInstance = new IotaClient\Api\ConfigurationsApi(
    new GuzzleHttp\Client(),
    $config
);

try {

    $projectId = "<Project_ID>";
    $configurationId = "<Config_ID>";

    $result = $apiInstance->getIotaConfigurationMetaData($projectId, $configurationId);

    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}

listIotaConfigurations

List all the Affinidi Iota Framework configurations.

Parameters

No Parameters Required

Example
require_once 'vendor/autoload.php';

use AffinidiTdk\Clients\IotaClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];

// Configure API key authorization: ProjectTokenAuth
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);

$apiInstance = new IotaClient\Api\ConfigurationsApi(
    new GuzzleHttp\Client(),
    $config
);

try {

    $result = $apiInstance->listIotaConfigurations();

    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}

updateIotaConfigurationById

Update an existing Affinidi Iota Framework by ID.

Parameters

configurationId [String]

ID of the existing Affinidi Iota Framework Configuration.

UpdateConfigurationByIdInput [Object]

JSON object to provide the configuration details. See more here.

Example
require_once 'vendor/autoload.php';

use AffinidiTdk\Clients\IotaClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];

// Configure API key authorization: ProjectTokenAuth
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);

$apiInstance = new IotaClient\Api\ConfigurationsApi(
    new GuzzleHttp\Client(),
    $config
);

try {

    $configurationId = "<Config_ID>";
    $request = array(
      name => "Sample App",
      walletAri => "<WALLET_ARI>",
      iotaResponseWebhookURL => "http://localhost"
    );

    $result = $apiInstance->updateIotaConfigurationById($configurationId, $request);

    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}

Iota API

Generate access token required to access the Affinidi Iota Framework.

awsExchangeCredentials

Exchanges limited token into a Cognito token.

Parameters

AwsExchangeCredentials [String]

JWT string. See more here.

Example
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];

// Configure API key authorization: ProjectTokenAuth
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);

$apiInstance = new IotaClient\Api\IotaApi(
    new GuzzleHttp\Client(),
    $config
);

try {

    $request = array(
      "assertion" => "JWT_STRING"
    );

    $result = $apiInstance->AwsExchangeCredentials($request);

    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}

initiateDataSharingRequest

Initiate data-sharing request for Affinidi Iota Framework and returns the signed request token.

Parameters

InitiateDataSharingRequestInput [Object]

JSON object to provide the required details to initiate data sharing request. See more here.

Example
require_once 'vendor/autoload.php';

use AffinidiTdk\Clients\IotaClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];

// Configure API key authorization: ProjectTokenAuth
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);

$apiInstance = new IotaClient\Api\IotaApi(
    new GuzzleHttp\Client(),
    $config
);

try {

    $request = array(
      "configurationId" => "<IOTA_CONFIGURATION_ID>",
      "mode" => "redirect",
      "queryId" => "<IOTA_CONFIGURATION_QUERY_ID>",
      "correlationId" => "<uuid4_string>",
      "nonce" => "<NONCE_FROM_FRONTEND>",
      "redirectUri" => "<IOTA_CONFIGURATION_REDIRECT_URL>",
    );

    $result = $apiInstance->initiateDataSharingRequest($request);

    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}

fetchIotaVpResponse

Fetch the callback response from Affinidi Vault.

Parameters

FetchIOTAVPResponseInput [Object]

JSON object to provide the required details to the callback response. See more here.

Example
require_once 'vendor/autoload.php';

use AffinidiTdk\Clients\IotaClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];

// Configure API key authorization: ProjectTokenAuth
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);

$apiInstance = new IotaClient\Api\IotaApi(
    new GuzzleHttp\Client(),
    $config
);

try {

    $request = array(
      "configurationId" => "<IOTA_CONFIGURATION_ID>",
      "correlationId" => "<CORRELATION_ID_FROM_LOCAL_STORAGE>",
      "transactionId" => "<TRANSACTION_ID_FROM_LOCAL_STORAGE>",
      "responseCode" => "<RESPONSE_CODE_FROM_REDIRECT>",
    );

    $result = $apiInstance->fetchIotaVpResponse($request);

    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}

Default API

Manage logged consent from Affinidi Iota Framework.

listLoggedConsents

Returns the list of logged consents for the project.

Parameters

configurationId [String]

Returns logged consent for the particular configuration.

userId [String]

Returns logged consent for the particular user.

limit [Integer]

Maximum number of records to fetch in a list.

exclusiveStartKey [String]

The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation.

Example
require_once 'vendor/autoload.php';

use AffinidiTdk\Clients\IotaClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];

// Configure API key authorization: ProjectTokenAuth
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);

$apiInstance = new IotaClient\Api\DefaultApi(
    new GuzzleHttp\Client(),
    $config
);

try {

    $result = $apiInstance->listLoggedConsents();

    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}

Callback API

Manage logged consent from Affinidi Iota Framework.

iotOIDC4VPCallback

Handles callback from clients with data from the OID4VP transactions, including states, presentation submission, and verification tokens.

Parameters

CallbackInput [Object]

JSON object to provide the Callback data from the client. See more here.

Example
require_once 'vendor/autoload.php';

use AffinidiTdk\Clients\IotaClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];

// Configure API key authorization: ProjectTokenAuth
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);

$apiInstance = new IotaClient\Api\CallbackApi(
    new GuzzleHttp\Client(),
    $config
);

try {

    $request = array(
      "state" => "<RANDOM_STRING>",
      "presentation_submission" => <PRESENTATIN_SUBMISSION_OBJECT>,
      "vp_token" => <VERIFIABLE_PRESENTATION_OBJECT>,
    );

    $result = $apiInstance->iotOIDC4VPCallback($request);

    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}

PexQueryAPI

createPexQuery

Creates a Presentation Definition in the Iota Configuration.

Parameters

configurationId [String]

ID of the existing Affinidi Iota Framework Configuration.

CreatePexQueryInput [Object]

JSON object to provide the PEX query details. See more here.

Example
require_once 'vendor/autoload.php';

use AffinidiTdk\Clients\IotaClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];

// Configure API key authorization: ProjectTokenAuth
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);

$apiInstance = new IotaClient\Api\PexQueryApi(
    new GuzzleHttp\Client(),
    $config
);

try {

    $configurationId = "<Config_ID>";
    $request = array(
      "name" => "Request Data",
      "vpDefinition" => "{PRESENTATION_DEFINITION_JSON_STRING}"
    );

    $result = $apiInstance->createPexQuery($configurationId, $request);

    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}

deletePexQueryById

Deletes a Presentation Definition based on the queryId from the Iota Configuration.

Parameters

configurationId [String]

ID of the existing Affinidi Iota Framework Configuration.

queryId [String]

ID of the existing Presentation Definition of the Affinidi Iota Configuration.

Example
require_once 'vendor/autoload.php';

use AffinidiTdk\Clients\IotaClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];

// Configure API key authorization: ProjectTokenAuth
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);

$apiInstance = new IotaClient\Api\PexQueryApi(
    new GuzzleHttp\Client(),
    $config
);

try {

    $configurationId = "<Config_ID>";
    $queryId = "<Query_ID>";

    $result = $apiInstance->deletePexQueryById($configurationId, $queryId);

    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}

getPexQueryById

Retrieves a Presentation Definition based on the queryId from the Iota Configuration.

Parameters

configurationId [String]

ID of the existing Affinidi Iota Framework Configuration.

queryId [String]

ID of the existing Presentation Definition of the Affinidi Iota Configuration.

Example
require_once 'vendor/autoload.php';

use AffinidiTdk\Clients\IotaClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];

// Configure API key authorization: ProjectTokenAuth
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);

$apiInstance = new IotaClient\Api\PexQueryApi(
    new GuzzleHttp\Client(),
    $config
);

try {

    $configurationId = "<Config_ID>";
    $queryId = "<Query_ID>";

    $result = $apiInstance->getPexQueryById($configurationId, $queryId);

    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}

listPexQueries

Retrieves all Presentation Definition in the Iota Configuration.

Parameters

configurationId [String]

ID of the existing Affinidi Iota Framework Configuration.

Example
require_once 'vendor/autoload.php';

use AffinidiTdk\Clients\IotaClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];

// Configure API key authorization: ProjectTokenAuth
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);

$apiInstance = new IotaClient\Api\PexQueryApi(
    new GuzzleHttp\Client(),
    $config
);

try {

    $configurationId = "<Config_ID>";

    $result = $apiInstance->listPexQueries($configurationId);

    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}

updatePexQueryById

Updates a Presentation Definition based on the queryId from the Iota Configuration.

Parameters

configurationId [String]

ID of the existing Affinidi Iota Framework Configuration.

queryId [String]

ID of the existing Presentation Definition of the Affinidi Iota Configuration.

UpdatePexQueryInput [Object]

JSON object to provide the PEX query details. See more here.

Example
require_once 'vendor/autoload.php';

use AffinidiTdk\Clients\IotaClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);

$apiInstance = new IotaClient\Api\PexQueryApi(
    new GuzzleHttp\Client(),
    $config
);

try {

    $configurationId = "<Config_ID>";
    $queryId = "<Query_ID>";

    $request = array(
        "vpDefinition" => "{PRESENTATION_DEFINITION_JSON_STRING}"
    );

    $result = $apiInstance->updatePexQueryById($configurationId, $queryId, $request);

    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}