Affinidi Iota Framework

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

Install Dependency

Package: @affinidi-tdk/iota-client

npm install @affinidi-tdk/iota-client --save

Check the latest version on the npm registry or view the source on GitHub.

Classes and Methods

Configurations API

Manages Affinidi Iota Framework configurations to integrate your application with Affinidi Vault data requests.

createIotaConfiguration

Creates an Affinidi Iota Framework configuration.

Parameters

Configuration details including name, wallet ARI, and webhook URL.

Example

import { ConfigurationsApi, Configuration, CreateIotaConfigurationInput } from '@affinidi-tdk/iota-client'

const api = new ConfigurationsApi(
  new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)

const request: CreateIotaConfigurationInput = {
  name: 'Sample App',
  walletAri: '<WALLET_ARI>',
  iotaResponseWebhookURL: 'http://localhost',
}

const { data } = await api.createIotaConfiguration(request)

deleteIotaConfigurationById

Deletes an existing Affinidi Iota Framework configuration by ID.

Parameters

configurationId string Required
ID of the Affinidi Iota configuration to delete.

Example

import { ConfigurationsApi, Configuration } from '@affinidi-tdk/iota-client'

const api = new ConfigurationsApi(
  new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)

await api.deleteIotaConfigurationById('<CONFIG_ID>')

getIotaConfigurationById

Retrieves an existing Affinidi Iota Framework configuration by ID.

Parameters

configurationId string Required
ID of the Affinidi Iota configuration to retrieve.

Example

import { ConfigurationsApi, Configuration } from '@affinidi-tdk/iota-client'

const api = new ConfigurationsApi(
  new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)

const { data } = await api.getIotaConfigurationById('<CONFIG_ID>')

getIotaConfigurationMetaData

Retrieves the metadata of an existing Affinidi Iota Framework configuration.

Parameters

projectId string Required
ID of the project where the Affinidi Iota Framework was created.
configurationId string Required
ID of the Affinidi Iota configuration.

Example

import { ConfigurationsApi, Configuration } from '@affinidi-tdk/iota-client'

const api = new ConfigurationsApi(
  new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)

const { data } = await api.getIotaConfigurationMetaData('<PROJECT_ID>', '<CONFIG_ID>')

listIotaConfigurations

Lists all Affinidi Iota Framework configurations.

No parameters required.

Example

import { ConfigurationsApi, Configuration } from '@affinidi-tdk/iota-client'

const api = new ConfigurationsApi(
  new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)

const { data } = await api.listIotaConfigurations()

updateIotaConfigurationById

Updates an existing Affinidi Iota Framework configuration by ID.

Parameters

configurationId string Required
ID of the Affinidi Iota configuration to update.
Updated configuration details.

Example

import { ConfigurationsApi, Configuration, UpdateConfigurationByIdInput } from '@affinidi-tdk/iota-client'

const api = new ConfigurationsApi(
  new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)

const request: UpdateConfigurationByIdInput = {
  name: 'Sample App',
  walletAri: '<WALLET_ARI>',
  iotaResponseWebhookURL: 'http://localhost',
}

const { data } = await api.updateIotaConfigurationById('<CONFIG_ID>', request)

Iota API

Generates access tokens required to access the Affinidi Iota Framework.

awsExchangeCredentials

Exchanges a limited token for a Cognito token.

Parameters

request AwsExchangeCredentials Required
JWT assertion to exchange.

Example

import { IotaApi, Configuration, AwsExchangeCredentials } from '@affinidi-tdk/iota-client'

const api = new IotaApi(
  new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)

const request: AwsExchangeCredentials = {
  assertion: '<PROOF_JWT>',
}

const { data } = await api.AwsExchangeCredentials(request)

initiateDataSharingRequest

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

Parameters

Details required to initiate the data-sharing request, including configuration ID, mode, query ID, correlation ID, nonce, and redirect URI.

Example

import { IotaApi, Configuration, InitiateDataSharingRequestInput, IotaConfigurationDtoModeEnum } from '@affinidi-tdk/iota-client'

const api = new IotaApi(
  new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)

const request: InitiateDataSharingRequestInput = {
  configurationId: '<IOTA_CONFIGURATION_ID>',
  mode: 'redirect',
  queryId: '<IOTA_CONFIGURATION_QUERY_ID>',
  correlationId: '<UUID4_STRING>',
  nonce: '<NONCE_FROM_FRONTEND>',
  redirectUri: '<IOTA_CONFIGURATION_REDIRECT_URL>',
}

const { data: dataSharingRequestResponse } = await api.initiateDataSharingRequest(request)

fetchIotaVpResponse

Fetches the callback response from Affinidi Vault.

Parameters

request FetchIOTAVPResponseInput Required
Details required to retrieve the callback response, including configuration ID, correlation ID, transaction ID, and response code.

Example

import { IotaApi, Configuration, FetchIOTAVPResponseInput, FetchIOTAVPResponseOK } from '@affinidi-tdk/iota-client'

const api = new IotaApi(
  new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)

const request: FetchIOTAVPResponseInput = {
  configurationId: '<IOTA_CONFIGURATION_ID>',
  correlationId: '<CORRELATION_ID_FROM_LOCAL_STORAGE>',
  transactionId: '<TRANSACTION_ID_FROM_LOCAL_STORAGE>',
  responseCode: '<RESPONSE_CODE_FROM_REDIRECT>',
}

const iotaVpResponse: FetchIOTAVPResponseOK = await api.fetchIotaVpResponse(request)

Default API

Manages logged consents from Affinidi Iota Framework.

listLoggedConsents

Returns the list of logged consents for the project.

Parameters

configurationId string Optional
Returns logged consents for the specified configuration.
userId string Optional
Returns logged consents for the specified user.
limit number Optional
Maximum number of records to return.
exclusiveStartKey string Optional
Base64url-encoded key of the first item that this operation will evaluate (it is not returned). Use the value returned in the previous operation to paginate.

Example

import { DefaultApi, Configuration } from '@affinidi-tdk/iota-client'

const api = new DefaultApi(
  new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)

const { data } = await api.listLoggedConsents()

Callback API

Handles OID4VP callbacks from Affinidi Iota Framework.

iotOIDC4VPCallback

Handles a callback from a client with OID4VP transaction data including states, presentation submission, and verification tokens.

Parameters

request CallbackInput Required
Callback data from the client including state, presentation submission, and VP token.

Example

import { CallbackApi, CallbackInput } from '@affinidi-tdk/iota-client'

const api = new CallbackApi()

const request: CallbackInput = {
  state: '<RANDOM_STRING>',
  presentation_submission: {},
  vp_token: {},
}

const { data } = await api.iotOIDC4VPCallback(request)

PexQueryAPI

Manages Presentation Exchange (PEX) query definitions in Iota configurations.

createPexQuery

Creates a Presentation Definition in an Iota configuration.

Parameters

configurationId string Required
ID of the Affinidi Iota configuration.
request CreatePexQueryInput Required
PEX query details including name and presentation definition.

Example

import { PexQueryApi, Configuration, CreatePexQueryInput } from '@affinidi-tdk/iota-client'

const api = new PexQueryApi(
  new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)

const request: CreatePexQueryInput = {
  name: 'Request Data',
  vpDefinition: '<PRESENTATION_DEFINITION_JSON_STRING>',
}

const { data } = await api.createPexQuery('<CONFIG_ID>', request)

deletePexQueryById

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

Parameters

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

Example

import { PexQueryApi, Configuration } from '@affinidi-tdk/iota-client'

const api = new PexQueryApi(
  new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)

await api.deletePexQueryById('<CONFIG_ID>', '<QUERY_ID>')

getPexQueryById

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

Parameters

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

Example

import { PexQueryApi, Configuration } from '@affinidi-tdk/iota-client'

const api = new PexQueryApi(
  new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)

const { data } = await api.getPexQueryById('<CONFIG_ID>', '<QUERY_ID>')

listPexQueries

Retrieves all Presentation Definitions in an Iota configuration.

Parameters

configurationId string Required
ID of the Affinidi Iota configuration.

Example

import { PexQueryApi, Configuration } from '@affinidi-tdk/iota-client'

const api = new PexQueryApi(
  new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)

const { data } = await api.listPexQueries('<CONFIG_ID>')

updatePexQueryById

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

Parameters

configurationId string Required
ID of the Affinidi Iota configuration.
queryId string Required
ID of the Presentation Definition to update.
request UpdatePexQueryInput Required
Updated PEX query details.

Example

import { PexQueryApi, Configuration, UpdatePexQueryInput } from '@affinidi-tdk/iota-client'

const api = new PexQueryApi(
  new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)

const request: UpdatePexQueryInput = {
  vpDefinition: '<PRESENTATION_DEFINITION_JSON_STRING>',
}

const { data } = await api.updatePexQueryById('<CONFIG_ID>', '<QUERY_ID>', request)