Implementing Control Planes
✈
Last updated
Was this helpful?
✈
Last updated
Was this helpful?
In order to promote convergence across Plugin APIs to support common functionality over complex workflows, plugins may choose to implement . Because each plane is slightly different, how they are actually implemented will also be slightly different. For the most part, there are some standard conventions that plugins must follow when implementing methods for a plane.
To demonstrate this, let's build a plugin that implements the and planes using .
Let's start with the types! We will use to define a Plugin that implements the Read and Store planes like so:
Before actually implementing the localStorage functionality, let's build out the skeleton of what our implementation will look like:
Because we specified that this plugin is implementing the read
and store
planes, we must include those keys in the returned Plugin
object. The Read Plane requires we implement a get
method, and the Store Plane requires we implement at least an upload
method, so these methods have been stubbed out.
Where id
is the identifier used as a key in localStorage
.
With our URI scheme defined and ID generation in place, let's implement our Store Plane!
With this code in place, the Store Plane has successfully been implemented! Verifiable Credentials can now be stored by a LearnCard using this plugin with the following code:
Now the we can store credentials in localStorage, let's implement getting them out!
To implement the Read Plane, we simply need to verify that the incoming URI
is one that matches our scheme, and if so, read the value stored in localStorage! This can be done with the following code:
With this in place, the Read and Store planes have been implemented and LearnCards may use our plugin to store and retrieve credentials from localStorage with the following code:
Let's start by implementing the Store Plane! The mention that the upload
method should return a , so we will now devise a URI scheme. It looks like this:
To easily create unique identifiers, we will use the npm package. Creating an ID using that package looks like this:
Wondering what that unused _learnCard
variable is about? It's ! Check out what it is and how to use it !