This repository contains a sample app using the DIF Identity Hub JavaScript SDK.
For more details about the APIs used, see the Hub SDK API Reference.
To run the sample app, clone this repository locally and then run:
npm install
npm run build
npm run start
The sample app stores objects representing to-do items in your Hub:
-
When you add a new to-do, the app authors a
create
commit to instantiate a new object and issues aHubWriteRequest
to commit the operation to your Hub. -
When you change the
done
state of a to-do, the app authors anupdate
commit. This commit references theobject_id
of the to-do and contains the updated to-do state. The app then issues aHubWriteRequest
to commit the update operation to your Hub. -
When you delete a to-do, the app authors a
delete
commit referencing theobject_id
of the to-do and issues aHubWriteRequest
to commit the delete operation to your Hub. -
When you close and re-open the app, the app fetches any existing to-dos from your Hub. The app issues a
HubObjectQueryRequest
to identify theobject_id
s of all objects having the to-do schema. The app then issues aHubCommitQueryRequest
to retrieve the constituent commits of all of the identified objects. Once all commits are retrieved, the app uses theCommitStrategyBasic
strategy to compile the commits into the final state of each to-do.
The code interacting with the Hub JS SDK is mostly found in the src/HubStore.ts
file.