Business Center Profile

Class Name BusinessCenterProfile
Extends Logger
Source business-center-profile.ts
Examples business-center-profile.spec.ts

The BusinessCenterProfile module allows to create profiles in a business center.

These profiles are like business cards for specific contexts and can be used to share data like contact data or certificates under this business centers context.


Basic Usage

// update/set contact card locally
await profile.setContactCard(JSON.parse(JSON.stringify(sampleProfile)));

// store to business center
await profile.storeForBusinessCenter(businessCenterDomain, accounts[0]);

// load from business center
await profile.loadForBusinessCenter(businessCenterDomain, accounts[0]);
const loadedProfile = await profile.getContactCard();

constructor

new BusinessCenterProfile(options);

Creates a new BusinessCenterProfile instance.

Parameters

  1. options - BusinessCenterProfileOptions: options for BusinessCenterProfile constructor.
    • bcAddress - string: ENS address (domain name) of the business center, the module instance is scoped to
    • cryptoProvider - CryptoProvider: CryptoProvider instance
    • defaultCryptoAlgo - string: crypto algorith name from CryptoProvider
    • ipld - Ipld: Ipld instance
    • nameResolver - NameResolver: NameResolver instance
    • ipldData - any (optional): preloaded profile data
    • log - Function (optional): function to use for logging: (message, level) => {...}
    • logLevel - LogLevel (optional): messages with this level will be logged with log
    • logLog - LogLogInterface (optional): container for collecting log messages
    • logLogLevel - LogLevel (optional): messages with this level will be pushed to logLog

Returns

BusinessCenterProfile instance

Example

const businessCenterProfile = new BusinessCenterProfile({
  ipld,
  nameResolver,
  defaultCryptoAlgo: 'aes',
  bcAddress: businessCenterDomain,
  cryptoProvider,
});;

setContactCard

businessCenterProfile.setContactCard();

Set contact card on current profile.

Parameters

  1. contactCard - any: contact card to store

Returns

Promise returns any: updated tree

Example

const updated = await businessCenterProfile.setContactCard(contactCard);

getContactCard

businessCenterProfile.getContactCard();

Get contact card from.

Parameters

(none)

Returns

Promise returns any: contact card

Example

const loadedProfile = await businessCenterProfile.getContactCard();

storeForBusinessCenter

businessCenterProfile.storeForBusinessCenter(businessCenterDomain, identity);

Stores profile to business centers profile store.

Parameters

  1. businessCenerDomain - string: ENS domain name of a business center
  2. executorAddress - string: Identity or account making the transaction

Returns

Promise returns void: resolved when done

Example

await businessCenterProfile.setContactCard(contactCard);
await businessCenterProfile.storeForBusinessCenter(businessCenterDomain, identities[0]);

loadForBusinessCenter

businessCenterProfile.loadForBusinessCenter(businessCenterDomain, identity);

Function description

Parameters

  1. businessCenerDomain - string: ENS domain name of a business center
  2. executorAddress - string: identity or account making the transaction

Returns

Promise returns void: resolved when done

Example

await newProfilebusinessCenterProfile.loadForBusinessCenter(businessCenterDomain, identities[0]);
const contactCard = await businessCenterProfile.getContactCard();

storeToIpld

businessCenterProfile.storeToIpld();

Store profile in ipfs as an ipfs file that points to a ipld dag.

Parameters

(none)

Returns

Promise returns string: hash of the ipfs file

Example

await businessCenterProfile.storeToIpld();

loadFromIpld

businessCenterProfile.loadFromIpld(tree, ipldIpfsHash);

Load profile from ipfs via ipld dag via ipfs file hash.

Parameters

  1. ipldIpfsHash - string: ipfs file hash that points to a file with ipld a hash

Returns

Promise returns BusinessCenterProfile: this profile

Example

businessCenterProfile.loadFromIpld(ipldIpfsHash);

getMyBusinessCenterContracts

businessCenterProfile.getMyBusinessCenterContracts(domain, contractType, subject);

Gets all registered contracts for a specific contract type on a businesscenter

Parameters

  1. businessCenterDomain - string: The business center domain
  2. contractType - string: The contract type
  3. subject - string: Subject to get the contracts for

Returns

Promise returns any: Array with all registered bc contracts

Example

businessCenterProfile.loadFromIpld(ipldIpfsHash);