@crediful/core
v2.6.6
Published
Crediful for Web's communication core.
Downloads
2
Readme
Crediful
This repository is part of the source code of Crediful. You can find more information at crediful.io or by contacting [email protected].
You can find the published source code at github.com/crediful.
For licensing information, see the attached LICENSE file and the list of third-party licenses at crediful.io/legal/licenses/.
Core
Crediful for Web's communication core.
Example
yarn add @crediful/[email protected]
JavaScript (Node.js)
const {Account} = require('@crediful/core');
const account = new Account();
account.on(Account.INCOMING.TEXT_MESSAGE, ({conversation, content}) => {
account.service.conversation.sendTextMessage(conversation, `Echo: ${content}`);
});
account.listen({
email: '[email protected]',
password: 'secret',
persist: false,
});
TypeScript
import {Account} from '@crediful/core';
import {PayloadBundle} from '@crediful/core/dist/commonjs/cryptography/';
import {LoginData} from '@crediful/api-client/dist/commonjs/auth/';
const account: Account = new Account();
const login: LoginData = {
email: '[email protected]',
password: 'secret',
persist: false,
};
account.on(Account.INCOMING.TEXT_MESSAGE, (data: PayloadBundle) => {
account.service.conversation.sendTextMessage(data.conversation, data.content);
});
account.listen(login).catch(error => {
console.error(error.stack);
return process.exit(1);
});