affinidi generate app --provider=affinidi --framework=usecase --library=eventi --path=affinidi-refcodes
affinidi token create-token -n WorkshopPAT --auto-generate-key --passphrase "MySecretPassphraseForPAT" --with-permissions --no-input
affinidi login create-config --name "Eventi" --redirect-uris "http://localhost:3000/api/auth/callback/affinidi"
This is a event reference app to demonstrate Zero party data exchange, interoperability of data across business boundaries and consent based data management for applications using Affinidi Login, Affinidi Iota framework, Credential Issuance and Affinidi Vault
-
Install the dependencies:
npm install
-
Create a
.env
file:cp .env.example .env
-
Click here to Set up your environment variables for Affinidi Login configuration
-
Click here to Set up your environment variables for Affinidi Iota configuration
-
Click here to Set up your Personnel Access Token to interact with Affinidi services
-
Launch the app:
npm run dev
App will be available locally on http://localhost:3000.
-
Follow this guide to set up your login configuration with callback URL as
http://localhost:3000/api/auth/callback/affinidi
-
Copy your Client ID, Client Secret and Issuer from your login configuration and paste them into your
.env
file:
PROVIDER_CLIENT_ID="<CLIENT_ID>"
PROVIDER_CLIENT_SECRET="<CLIENT_SECRET>"
PROVIDER_ISSUER="<ISSUER>"
-
Follow this guide to set up your iota configuration for queries
-
Copy your Configuration ID and Query ID for relevant iota queries and paste them into your
.env
file:
NEXT_PUBLIC_IOTA_CONFIG_ID=""
NEXT_PUBLIC_IOTA_ADDRESS_QUERY=""
NEXT_PUBLIC_IOTA_MUSIC_RECOMMEND_QUERY=""
NEXT_PUBLIC_IOTA_EVENT_TICKET_QUERY=""
Follow this guide to set up your Personnel Access Token
Create Issuance Configuration through Affinidi Portal with following details
- Name for the configuration
- Description
- Issuing Wallet : You may select the same wallet created during iota configurations
- Lifetime of Credential Offer
- Supported Schema: Create following entry for supported Schema
CredentialTypeId : EventTicketVC
JSON Schema URL : https://schema.affinidi.io/TEventTicketVCV1R0.json
JSON-LD Context URL : https://schema.affinidi.io/TEventTicketVCV1R0.jsonld
Custom hook useIotaQuery
, accepts Iota configuration id and returns the query response
Sample Snippet
const {
isInitializing,
statusMessage,
handleInitiate,
isRequestPrepared,
isWaitingForResponse,
errorMessage,
dataRequest,
data: iotaRequestData,
} = useIotaQuery({
configurationId,
});
useEffect(() => {
if (!iotaRequestData) return;
//data for email query
const addressData = iotaRequestData[emailQueryId]
if (addressData) {
console.log('Your email', emailData.email)
}
}, [iotaRequestData]);
...
...
return (
<>
{isInitializing && (
<div>
<p>{statusMessage || "Loading"}...</p>
</div>
)}
<button onClick={() => handleInitiate(emailQueryId)} >
Request Email
</button>
{iotaRequestData && iotaRequestData[emailQueryId] && (
<pre>
{JSON.stringify(emailData, null, 1)}
</pre>
)}
</>
)
- isInitializing : This is Boolean type, return true when user starts the request and false when completes the response
- statusMessage : This is string type, which gives message on the status of each event like creating Iota session, preparing request etc...
- handleInitiate : This is method, which can be called on click of a button to trigger the request
- isRequestPrepared : This is Boolean type, which returns true when prepare request is started
- isWaitingForResponse : This is Boolean type, which returns true when we prepared the request and waiting for the response, will be false when we got the response
- dataRequest : This is object type, contains request and response of the Iota request
- data : This is object type, which contains the credentialSubject group by each query Id of all the VCs e.g.
data[emailQueryId]