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
createcommit to instantiate a new object and issues aHubWriteRequestto commit the operation to your Hub. -
When you change the
donestate of a to-do, the app authors anupdatecommit. This commit references theobject_idof the to-do and contains the updated to-do state. The app then issues aHubWriteRequestto commit the update operation to your Hub. -
When you delete a to-do, the app authors a
deletecommit referencing theobject_idof the to-do and issues aHubWriteRequestto 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
HubObjectQueryRequestto identify theobject_ids of all objects having the to-do schema. The app then issues aHubCommitQueryRequestto retrieve the constituent commits of all of the identified objects. Once all commits are retrieved, the app uses theCommitStrategyBasicstrategy 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.
