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

Check the latest version on the Packagist repository or view the source on GitHub.

Classes and Methods

Configurations API

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

createIotaConfiguration

Creates an Affinidi Iota Framework configuration.

Parameters

createIotaConfigurationInput CreateIotaConfigurationInput Required
Configuration name, wallet ARI, and webhook URL.

Example

require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$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: ', $e->getMessage(), PHP_EOL;
}

deleteIotaConfigurationById

Deletes an existing Affinidi Iota Framework configuration by ID.

Parameters

configurationId string Required
ID of the configuration to delete.

Example

require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\ConfigurationsApi(new GuzzleHttp\Client(), $config);

try {
    $result = $apiInstance->deleteIotaConfigurationById('<CONFIG_ID>');
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}

getIotaConfigurationById

Retrieves an existing Affinidi Iota Framework configuration by ID.

Parameters

configurationId string Required
ID of the configuration to retrieve.

Example

require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\ConfigurationsApi(new GuzzleHttp\Client(), $config);

try {
    $result = $apiInstance->getIotaConfigurationById('<CONFIG_ID>');
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}

getIotaConfigurationMetaData

Retrieves the metadata of an existing Affinidi Iota Framework configuration.

Parameters

projectId string Required
Project ID where the configuration was created.
configurationId string Required
ID of the configuration.

Example

require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\ConfigurationsApi(new GuzzleHttp\Client(), $config);

try {
    $result = $apiInstance->getIotaConfigurationMetaData('<PROJECT_ID>', '<CONFIG_ID>');
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}

listIotaConfigurations

Returns all Affinidi Iota Framework configurations.

No parameters required.

Example

require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$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: ', $e->getMessage(), PHP_EOL;
}

updateIotaConfigurationById

Updates an existing Affinidi Iota Framework configuration by ID.

Parameters

configurationId string Required
ID of the configuration to update.
updateConfigurationByIdInput UpdateConfigurationByIdInput Required
Updated configuration name, wallet ARI, and webhook URL.

Example

require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$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->updateIotaConfigurationById('<CONFIG_ID>', $request);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}

Iota API

Generate access token required to access the Affinidi Iota Framework.

awsExchangeCredentials

Exchanges a limited token into a Cognito token.

Parameters

awsExchangeCredentials AwsExchangeCredentials Required
JWT assertion string.

Example

require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$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: ', $e->getMessage(), PHP_EOL;
}

initiateDataSharingRequest

Initiates a data-sharing request and returns the signed request token.

Parameters

initiateDataSharingRequestInput InitiateDataSharingRequestInput Required
Configuration ID, mode, query ID, correlation ID, nonce, and redirect URI.

Example

require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$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: ', $e->getMessage(), PHP_EOL;
}

fetchIotaVpResponse

Fetches the callback response from Affinidi Vault.

Parameters

fetchIOTAVPResponseInput FetchIOTAVPResponseInput Required
Configuration ID, correlation ID, transaction ID, and response code.

Example

require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$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: ', $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 Optional
Filter by configuration ID.
userId string Optional
Filter by user ID.
limit integer Optional
Maximum number of records to return.
exclusiveStartKey string Optional
Base64url-encoded pagination key.

Example

require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$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: ', $e->getMessage(), PHP_EOL;
}

Callback API

Manage logged consent from Affinidi Iota Framework.

iotOIDC4VPCallback

Handles the callback from clients with data from OID4VP transactions.

Parameters

callbackInput CallbackInput Required
State, presentation submission, and VP token.

Example

require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\CallbackApi(new GuzzleHttp\Client(), $config);

try {
    $request = array(
        'state' => '<RANDOM_STRING>',
        'presentation_submission' => '<PRESENTATION_SUBMISSION>',
        'vp_token' => '<VP_TOKEN>',
    );
    $result = $apiInstance->iotOIDC4VPCallback($request);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}

PexQuery API

Manage Presentation Exchange query definitions in an Affinidi Iota Framework configuration.

createPexQuery

Creates a Presentation Definition in the Iota configuration.

Parameters

configurationId string Required
ID of the Iota configuration.
createPexQueryInput CreatePexQueryInput Required
PEX query name and VP definition.

Example

require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\PexQueryApi(new GuzzleHttp\Client(), $config);

try {
    $request = array(
        'name' => 'Request Data',
        'vpDefinition' => '<PRESENTATION_DEFINITION_JSON_STRING>',
    );
    $result = $apiInstance->createPexQuery('<CONFIG_ID>', $request);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}

deletePexQueryById

Deletes a Presentation Definition by query ID from the Iota configuration.

Parameters

configurationId string Required
ID of the Iota configuration.
queryId string Required
ID of the Presentation Definition to delete.

Example

require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\PexQueryApi(new GuzzleHttp\Client(), $config);

try {
    $result = $apiInstance->deletePexQueryById('<CONFIG_ID>', '<QUERY_ID>');
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}

getPexQueryById

Retrieves a Presentation Definition by query ID from the Iota configuration.

Parameters

configurationId string Required
ID of the Iota configuration.
queryId string Required
ID of the Presentation Definition to retrieve.

Example

require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\PexQueryApi(new GuzzleHttp\Client(), $config);

try {
    $result = $apiInstance->getPexQueryById('<CONFIG_ID>', '<QUERY_ID>');
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}

listPexQueries

Retrieves all Presentation Definitions in the Iota configuration.

Parameters

configurationId string Required
ID of the Iota configuration.

Example

require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\PexQueryApi(new GuzzleHttp\Client(), $config);

try {
    $result = $apiInstance->listPexQueries('<CONFIG_ID>');
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}

updatePexQueryById

Updates a Presentation Definition by query ID in the Iota configuration.

Parameters

configurationId string Required
ID of the Iota configuration.
queryId string Required
ID of the Presentation Definition to update.
updatePexQueryInput UpdatePexQueryInput Required
Updated VP definition.

Example

require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\IotaClient;

$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
$config = IotaClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new IotaClient\Api\PexQueryApi(new GuzzleHttp\Client(), $config);

try {
    $request = array(
        'vpDefinition' => '<PRESENTATION_DEFINITION_JSON_STRING>',
    );
    $result = $apiInstance->updatePexQueryById('<CONFIG_ID>', '<QUERY_ID>', $request);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}