Affinidi Iota Framework
Install Dependency
Package: @affinidi-tdk/iota-client
npm install @affinidi-tdk/iota-client --save
You can check the latest version of this module on the NPM 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
import { ConfigurationsApi, Configuration, CreateIotaConfigurationInput } from '@affinidi-tdk/iota-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new ConfigurationsApi(authConfiguration)
const request: CreateIotaConfigurationInput = {
name: "Sample App",
walletAri: "<WALLET_ARI>",
iotaResponseWebhookURL: "http://localhost"
}
const { data } = await api.createIotaConfiguration(request)
deleteIotaConfigurationById
Delete existing Affinidi Iota Framework configuration by ID.
Parameters
configurationId [String]
ID of the Affinidi Iota Configuration to delete.
Example
import { ConfigurationsApi, Configuration } from '@affinidi-tdk/iota-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new ConfigurationsApi(authConfiguration)
const configurationId = "<Config_ID>"
const { data } = await api.deleteIotaConfigurationById(configurationId)
getIotaConfigurationById
Retrieves existing Affinidi Iota Framework by ID.
Parameters
configurationId [String]
ID of the Affinidi Iota Configuration to delete.
Example
import { ConfigurationsApi, Configuration } from '@affinidi-tdk/iota-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new ConfigurationsApi(authConfiguration)
const configurationId = "<Config_ID>"
const result = await api.getIotaConfigurationById(configurationId)
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
import { ConfigurationsApi, Configuration } from '@affinidi-tdk/iota-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new ConfigurationsApi(authConfiguration)
const projectId = "<Project_ID>"
const configurationId = "<Config_ID>"
const { data } = await api.getIotaConfigurationMetaData(projectId, configurationId)
listIotaConfigurations
List all the Affinidi Iota Framework configurations.
Parameters
No Parameters Required
Example
import { ConfigurationsApi, Configuration } from '@affinidi-tdk/iota-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new ConfigurationsApi(authConfiguration)
const { data } = await api.listIotaConfigurations()
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
import { ConfigurationsApi, Configuration, UpdateConfigurationByIdInput } from '@affinidi-tdk/iota-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new ConfigurationsApi(authConfiguration)
const configurationId = "<Config_ID>"
const request: UpdateConfigurationByIdInput = {
name: "Sample App",
walletAri: "<WALLET_ARI>",
iotaResponseWebhookURL: "http://localhost"
}
const { data } = await api.updateIotaConfigurationById(configurationId, request)
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
import { IotaApi, Configuration, AwsExchangeCredentials } from '@affinidi-tdk/iota-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new IotaApi(authConfiguration)
const request: AwsExchangeCredentials = {
assertion: "JWT_STRING"
}
const { data } = await api.AwsExchangeCredentials(request)
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
import { IotaApi, Configuration, InitiateDataSharingRequestInput, IotaConfigurationDtoModeEnum } from '@affinidi-tdk/iota-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new IotaApi(authConfiguration)
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
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
import { IotaApi, Configuration, FetchIOTAVPResponseInput, FetchIOTAVPResponseOK } from '@affinidi-tdk/iota-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new IotaApi(authConfiguration)
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
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
import { DefaultApi, Configuration } from '@affinidi-tdk/iota-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new DefaultApi(authConfiguration)
const { data } = await api.listLoggedConsents()
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
import { CallbackApi } from '@affinidi-tdk/iota-client'
const api = new CallbackApi()
const request: CallbackInput = {
state: "<RANDOM_STRING>",
presentation_submission: <PRESENTATIN_SUBMISSION_OBJECT>,
vp_token: <VERIFIABLE_PRESENTATION_OBJECT>,
}
const { data } = await api.iotOIDC4VPCallback(request)
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
import { PexQueryApi, Configuration, CreatePexQueryInput } from '@affinidi-tdk/iota-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new PexQueryApi(authConfiguration)
const configurationId = "<Config_ID>"
const request: CreatePexQueryInput = {
name: "Request Data",
vpDefinition: "{PRESENTATION_DEFINITION_JSON_STRING}"
}
const { data } = await api.createPexQuery(configurationId, request)
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
import { PexQueryApi, Configuration } from '@affinidi-tdk/iota-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new PexQueryApi(authConfiguration)
const configurationId = "<Config_ID>"
const queryId = "<Query_ID>"
const result = await api.deletePexQueryById(configurationId, queryId)
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
import { PexQueryApi, Configuration } from '@affinidi-tdk/iota-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new PexQueryApi(authConfiguration)
const configurationId = "<Config_ID>"
const queryId = "<Query_ID>"
const result = await api.getPexQueryById(configurationId, queryId)
listPexQueries
Retrieves all Presentation Definition in the Iota Configuration.
Parameters
configurationId [String]
ID of the existing Affinidi Iota Framework Configuration.
Example
import { PexQueryApi, Configuration } from '@affinidi-tdk/iota-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new PexQueryApi(authConfiguration)
const configurationId = "<Config_ID>"
const result = await api.listPexQueries(configurationId)
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
import { PexQueryApi, Configuration, UpdatePexQueryInput } from '@affinidi-tdk/iota-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new PexQueryApi(authConfiguration)
const configurationId = "<Config_ID>"
const queryId = "<Query_ID>"
const request: UpdatePexQueryInput = {
vpDefinition: "{PRESENTATION_DEFINITION_JSON_STRING}"
}
const result = await api.updatePexQueryById(configurationId, queryId, 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.