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¶
options
-BusinessCenterProfileOptions
: options for BusinessCenterProfile constructor.bcAddress
-string
: ENS address (domain name) of the business center, the module instance is scoped tocryptoProvider
-CryptoProvider
:CryptoProvider
instancedefaultCryptoAlgo
-string
: crypto algorith name fromCryptoProvider
ipld
-Ipld
:Ipld
instancenameResolver
-NameResolver
:NameResolver
instanceipldData
-any
(optional): preloaded profile datalog
-Function
(optional): function to use for logging:(message, level) => {...}
logLevel
-LogLevel
(optional): messages with this level will be logged withlog
logLog
-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
getContactCard¶
businessCenterProfile.getContactCard();
Get contact card from.
Parameters¶
(none)
Returns¶
Promise
returns any
: contact card
storeForBusinessCenter¶
businessCenterProfile.storeForBusinessCenter(businessCenterDomain, account);
Stores profile to business centers profile store.
Parameters¶
businessCenerDomain
-string
: ENS domain name of a business centeraccount
-string
: Ethereum account id
Returns¶
Promise
returns void
: resolved when done
Example¶
await businessCenterProfile.setContactCard(contactCard);
await businessCenterProfile.storeForBusinessCenter(businessCenterDomain, accounts[0]);
loadForBusinessCenter¶
businessCenterProfile.loadForBusinessCenter(businessCenterDomain, account);
Function description
Parameters¶
businessCenerDomain
-string
: ENS domain name of a business centeraccount
-string
: Ethereum account id
Returns¶
Promise
returns void
: resolved when done
Example¶
await newProfilebusinessCenterProfile.loadForBusinessCenter(businessCenterDomain, accounts[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
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);