Affinidi Iota Framework
Install Dependency
Package: @affinidi-tdk/iota-client
npm install @affinidi-tdk/iota-client --saveCheck 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
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
RequiredExample
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
RequiredExample
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
RequiredconfigurationId
string
RequiredExample
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
RequiredExample
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
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
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
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
OptionaluserId
string
Optionallimit
number
OptionalexclusiveStartKey
string
OptionalExample
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
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
RequiredExample
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
RequiredqueryId
string
RequiredExample
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
RequiredqueryId
string
RequiredExample
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
RequiredExample
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
RequiredqueryId
string
RequiredExample
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)Glad to hear it! Please tell us how we can improve more.
Sorry to hear that. Please tell us how we can improve.
Thank you for sharing your feedback so we can improve your experience.