4. Public Profile

A public profile can be attached to an identity to make it easy for any identity with which you interact to easily resolve your identity. This is especially relevant for interactions with online services, as a public profile can be used to advertise interaction conditions, as well as various attestations.

Before you start, be sure to initialize the IdentityWallet class as outlined in the Getting Started section.

4.1. Adding a public profile

We currently model public profiles as simple SignedCredential instances, each containing the following claims: about, url, image, and name.

Before we can publish the credential, we need to first create it:

import { claimsMetadata } from 'jolocom-lib'

const myPublicProfile = {
  name: 'Jolocom',
  about: 'We enable a global identity system'
}

const credential = await identityWallet.create.signedCredential({
  metadata: claimsMetadata.publicProfile,
  claim: myPublicProfile,
  subject: identityWallet.did
}, password)

Add the newly created public profile to your identity:

/**
* Typescript accessors are used to get
* and set values on the identityWallet instance
* @see https://www.typescriptlang.org/docs/handbook/classes.html
*/

identityWallet.publicProfile = publicProfileCred

Note

Typescript accessors are used to get and set values on the identityWallet instance

So far you have been making changes to your identity only locally. Now, you can commit the changes to IPFS and Ethereum.

await registry.commit({
  identityWallet,
  vaultedKeyProvider,
  keyMetadata: {
    encryptionPass: secret,
    derivationPath: JolocomLib.KeyTypes.jolocomIdentityKey
  }
})

In order to update your public profile, simply create a new credential, add it to your identityWallet, and commit the changes.

4.2. Removing your public profile

identityWallet.identity.publicProfile = undefined

await registry.commit({
  identityWallet,
  vaultedKeyProvider,
  keyMetadata: {
    encryptionPass: secret,
    derivationPath: JolocomLib.KeyTypes.jolocomIdentityKey
  }
})

Please note that due to the way that IPFS handles the concept of deletion, this delete method simply unpins your public profile from its corresponding pin set, and allows the unpinned data to be removed by the “garbage collection” process. Accordingly, if the data has been pinned by another IPFS gateway, complete removal of stored information on the IPFS network cannot be ensured.

4.3. View the public profile

Viewing the public profile associated with an identity is easy:

console.log(identityWallet.identity.publicProfile)

An instance of the SignedCredential class is returned.