@bearer/js
The hassle-free way to use bearer's integrations into any web application
Getting started
Bearer lib can be used instantly in your page or with a package system.
Directly in your page
With a build system
yarn add @bearer/js# or npm install @bearer/js
In your app
import bearer from '@bearer/js' { }
Usage
Calling any APIs
Out of the box, Bearer provides an added value proxy for any API. You can call any API (aka integration) endpoint as follow
const bearerClient = // initialize an API client to target a specific service (ex: slack, github, etc...)const slack = bearerClient // re-use previously created API clientslack // see #connect section for more information // all REST verbs are available here: .post, .put, .delete etc... // passing extra argumentsslack
Invoke js
The Bearer SDK for JavaScript lets you invoke integration's function (if their execution is not restricted to server side usage).
const bearerClient = const myIntegration = bearerClientmyIntegration // is equivalent tobearerClient
Passing params to your function works as follow:
bearerClient
i18n
@bearer/js
comes with an i18n module that let you deal with internationalization of Bearer's integrations
bearer.i18n.locale
Lets you change the locale
beareri18nlocale = 'es'
bearer.i18n.load
Lets you load custom translation for integrations
// with a simple dictionnaryconst dictionnary = titles: welcome: 'Ola!' beareri18n // with a promise returning a dictionnaryconst promiseReturningADictionnary = Promisebeareri18n // for a given localeconst dictionnary = titles: welcome: 'Guten Morgen' beareri18n // for multiple integrations on a single pageconst dictionnary = 'integration-one-uuid': title: welcome: 'Hello my friend' 'integration-two-uuid': message: goodbye: 'Bye Bye' beareri18n
Secure
If you want to add a level of security, you can switch to the secure mode:
windowbearersecured = true// at the initialisation timewindow
Once this mode is turned on, all your values passed in the properties need to be encrypted using your ENCRYPTION_KEY
.
CLI
Within the CLI, you can use bearer encrypt
to get the
bearer encrypt ENCRYPTION_KEY MESSAGE
NodeJS
cipher.encryptMESSAGE
connect
connect
lets you easily retrieve the auth-id
for an integration using OAuth authentication. Before using it, you'll need to generate a setup-id
with the setup component of your integration
bearerClient
you can pass your own auth-id
within options parameters as follows
bearerClient
init options
Soon