Business Center Profile
Class Name |
BusinessCenterProfile |
|---|---|
Extends |
|
Source |
|
Examples |
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
options-BusinessCenterProfileOptions: options for BusinessCenterProfile constructor.bcAddress-string: ENS address (domain name) of the business center, the module instance is scoped tocryptoProvider-CryptoProvider:CryptoProviderinstancedefaultCryptoAlgo-string: crypto algorith name fromCryptoProvidernameResolver-NameResolver:NameResolverinstanceipldData-any(optional): preloaded profile datalog-Function(optional): function to use for logging:(message, level) => {...}logLevel-LogLevel(optional): messages with this level will be logged withloglogLog-LogLogInterface(optional): container for collecting log messageslogLogLevel-LogLevel(optional): messages with this level will be pushed tologLog
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
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
businessCenerDomain-string: ENS domain name of a business centerexecutorAddress-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
businessCenerDomain-string: ENS domain name of a business centerexecutorAddress-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
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
businessCenterDomain-string: The business center domaincontractType-string: The contract typesubject-string: Subject to get the contracts for
Returns
Promise returns any: Array with all registered bc contracts
Example
businessCenterProfile.loadFromIpld(ipldIpfsHash);