Onboarding¶
Class Name | Onboarding |
---|---|
Extends | Logger |
Source | onboarding.ts |
Examples | onboarding.spec.ts |
The onboarding process is used to enable users to invite other users, where no blockchain account id is known. It allows to send an email to such contacts, that contains a link. This link points to a evan.network ÐApp, that allows accept the invitation by either creating a new account or by accepting it with an existing account.
It uses the Key Exchange module described in the last section for its underlying key exchange process but moves the process of creating a new communication key to the invited user.
To get in contact with a user via email, a smart agent is used. This smart agent has to be added as a contact and a regular key exchange with the smart agent is performed. The agent accepts the invitation automatically and the inviting user sends a bmail (blockchain mail) with the contact details of the user, that should be invited, and an amount of welcome EVEs to the smart agent.
The onboarding smart creates a session on his end and sends an email to the invited user, that includes the session token, with which the invited user can claim the welcome EVEs.
The invited user now creates or confirms an account and start the key exchange process on his or her end. The rest of the flow is as described in Key Exchange.
To start the process at from the inviting users side, make sure that this user has exchanged keys with the onboarding smart agent.
constructor¶
new Onboarding(options);
Creates a new Onboarding instance.
Parameters¶
options
-OnboardingOptions
: options for Onboarding constructorexecutor
-Executor
:Executor
instancemailbox
-Mailbox
:Mailbox
instancesmartAgentId
-string
: account id of onboarding smart agentlog
-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¶
Onboarding
instance
Example¶
const onboarding = new Onboarding({
mailbox,
smartAgentId: config.smartAgents.onboarding.accountId,
executor,
});
sendInvitation¶
onboarding.sendInvitation(invitation, weiToSend);
Send invitation to another user via smart agent that sends a mail.
Parameters¶
invitation
-invitation
: mail that will be sent to invited personweiToSend
-string
: amount of ETC to transfert to new member, can be created with web3.utils.toWei(10, ‘ether’) [web3 >=1.0] / web.toWei(10, ‘ether’) [web3 < 1.0]
Returns¶
Promise
returns void
: resolved when done
Example¶
await onboarding.sendInvitation({
fromAlias: 'example inviter',
to: 'example invitee <example.invitee@evan.network>',
lang: 'en',
subject: 'evan.network Onboarding Invitation',
body: 'I\'d like to welcome you on board.',
}, web3.utils.toWei('1'));
createMnemonic¶
Onboarding.createMnemonic();
(static class function)
Generates a new random Mnemonic
Returns¶
string
Example¶
To show the difference, without purging:
const mnemnonic = Onboarding.createMnemnonic();
console.log(mnemnoic);
// prints out a random 12 word mnemnonic
createNewProfile¶
Onboarding.createNewProfile(mnemnonic, password, profileProperties);
(static class function)
Creates a new full blown profile on a given evan network (testcore/core) and returns the mnemonic, password and a configuration for the runtime initalization
Parameters¶
mnemnonic
-string
: 12 word mnemnonic as stringpassword
-string
: password of the new created profileprofileProperties
-any
: Properties for the profile to be created
Returns¶
Promise
returns any
: object with the mnemonic, password and the config object for the runtime
Example¶
const originRuntime = await TestUtils.getRuntime(accounts[0]);
const mnemonic = Onboarding.createMnemonic();
await Onboarding.createNewProfile(originRuntime, mnemonicNew, 'Test1234', {
accountDetails: {
profileType: 'company',
accountName: 'test account'
}});
createOfflineProfile¶
Onboarding.createNewProfile(mnemnonic, password, profileProperties);
(static class function)
Creates a new empty profile offline and emits it to a given smart agent. The profile is created in two steps. First, an empty profile is created then the empty profile is filled and returned. In the case of a company profile two empty profiles are created and then both are filled and each are given access to both profiles.
Parameters¶
runtime
-any
: initialized runtimeprofileData
-any
: object that included profile data (accountDetails, registration, contact, …)accountId
-string
: accountId of the private keypKey
-string
: private keypassword
-string
: password of the new created profilerecaptchaToken
-string
: recaptcha tokennetwork
-string
: selected network (testcore/core) - defaults to testcore
Returns¶
Promise
returns void
: resolved when done
Example¶
// For creating a user profile offline
const tempRuntime = await TestUtils.getRuntime(accounts[2], null, { useIdentity });
Onboarding.createOfflineProfile(
tempRuntime,
{
accountDetails: {
accountName: 'Test',
},
},
accounts[2],
pKey,
'',
'')
// For creating a company profile offline
const tempRuntime = await TestUtils.getRuntime(accounts[2], null, { useIdentity });
Onboarding.createOfflineProfile(
tempRuntime,
{
accountDetails: {
accountName: 'Test',
profileType: 'company',
companyAlias: 'Evan',
},
registration: 'Germany',
contact: 'anyone',
},
accounts[2],
pKey,
'',
'')