2.6.6 • Published 6 years ago

@crediful/core v2.6.6

Weekly downloads
2
License
GPL-3.0
Repository
github
Last release
6 years ago

Crediful

This repository is part of the source code of Crediful. You can find more information at crediful.io or by contacting opensource@crediful.io.

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/core@0.0.30

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: 'name@email.com',
  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: 'name@email.com',
  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);
});