Issuer guide
Required reading
SDK feature overview
The primary features provided by the Issuer SDK are:
checking if your user has an idOS profile, and create one otherwise;
transforming IDV results into idOS credentials;
implementing a Passporting-compliant onboarding flow.
Getting started: what you'll need
Compliance guidance
See idOS Regulatory approach for more context, and discuss with your compliance officer:
whether you’re going to be using Passporting.
Signature and encryption keys
🛑 DANGER 🛑
Make sure you don't lose access to either secret keys. Otherwise, you won't be able to authenticate or decrypt credential contents. The idOS team won't be able to help you.
You'll need:
encryptionSecretKey: base64-encodednacl.BoxKeyPairsecret key. It'll be used to encrypt the credentials you issue to your userssee Encryption for more information
signingKeyPair: this can be a NEARKeyPair, anacl.SignKeyPair, or anethers.Wallet. This will be used to sign RPC calls to the idOS nodes.see Signatures for more information
You'll also need a multibaseSigningKeyPair, which will be used to sign the W3C VCs you issue. If you're unfamiliar with how to generate one, you can use the following example:
A frontend
Your frontend (web or native app), as your user’s touch point, is where you’ll:
confirm that the user is in idOS;
find whether the user already has your credential;
otherwise, request write grant and take user through IDV.
A backend
Your backend (private server) is where you’ll:
create user profiles in idOS;
write credentials to idOS;
revoking previously issued credentials.
Our Issuer SDK
Get our NPM packages
https://www.npmjs.com/package/@idos-network/client
https://www.npmjs.com/package/@idos-network/issuer
and their dependencies with pnpm (or your package manager of choice)
Usage
[ frontend ] Importing and initializing
[ backend ] Importing and initializing
[ frontend ] Connecting your user's wallet
Connect your user's wallet however you do it today, for example:
[ frontend + backend ] Ensuring your user has an idOS profile
Get your user's address from the signer above and confirm they have an idOS profile. If not, redirect them to your onboarding journey.
Creating a profile
If they don't have a profile, you must create one for them. This procedure can only be done by a Permissioned Issuer. Get in touch with us at [email protected] if you're interested in being one.
To create a user profile in idOS, you need:
A wallet address associated with the user.
A public encryption key derived from either a password chosen by the user in the idOS enclave app.
Step 1: Deciding on a user id
Deciding on a user id for a user is an issuer decision. You can use whichever you want, as long as it's an UUID.
Step 2: Getting the user's signing and encryption public keys
Use the idOSClient.discoverUserEncryptionPublicKey function to derive a public key for the user. This key will be used to encrypt and decrypt user's credential content.
Step 3: Creating a User Profile
Once the public key is derived, you can create the user profile in idOS by passing it to the createUser function alongside with user id and the wallet the user's going to use to drive their idOS profile.
[ frontend ] Setting signer
Pass your user’s signer to the SDK, so it knows where to send signature requests to.
[ frontend ] Checking for issued credential
If the user doesn’t already have your credential, you can proceed to requesting a write grant so you can issue and write it.
[ frontend ] Requesting write grant
In order to write a credential to idOS, the issuer needs to obtain permission from the user. This can be done using a Delegated Write Grant (DWG).
A Delegated Write Grant (DWG) is a permission given by the user that allows a specific issuer to create a credential and it's copy for the issuer itself on the user's behalf. This is particularly relevant to not require the user to come back to your website if you want to add data to their profile. A DWG is a ERC-191 message that the user signs. The message contains fields:
To do this, you must first to ask a user to sign DWG message:
Be sure you have the DWG message parameters and its signature kept. You need to use them on server side later.
[ backend ] Issuing and writing credentials
To issue a credential, you can use our W3C Verifiable Credentials helpers:
To write the credential you issued, you'll make use of the write grant acquired above.
This will create a credential for the user in the idOS and a copy for you.
[ backend ] Revoking and editing credentials
The editCredential function allows issuers to update the public notes associated with a credential in the idOS. This is useful for actions like marking credentials as revoked or updating metadata.
In order for editCredential to work, the credential's public_notes field needs to be a valid JSON object with an id field, and the public_notes_id argument needs to have that value.
⚠️ Warning
If the new
public_notesvalue doesn't have anidfield, you'll stop being able to edit that credential.
Last updated