Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bearer/js

Package Overview
Dependencies
Maintainers
4
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bearer/js

A JavaScript library for working with Bearer integrations

  • 0.100.1-canary.34
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17
decreased by-86.51%
Maintainers
4
Weekly downloads
 
Created
Source

@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

<script src="https://cdn.jsdelivr.net/npm/@bearer/js@beta5/lib/bearer.production.min.js"></script>
<script>
  // you have now access to a global `bearer` function, initialize your code by passing the `clientId` as parameter
  bearer('clientId')
</script>

With a build system

yarn add @bearer/js
# or
npm install @bearer/js

In your app

import bearer from '@bearer/js'

class MyApp {
  componentDidMount() {
    bearer('clientId')
  }
}

Usage

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

bearer.i18n.locale = 'es'

bearer.i18n.load

Lets you load custom translation for integrations

// with a simple dictionnary
const dictionnary = { titles: { welcome: 'Ola!' } }
bearer.i18n.load('integration-uuid', dictionnary)

// with a promise returning a dictionnary
const promiseReturningADictionnary = Promise.new((resolve, reject) => {
  // async stuff
  resolve({ titles: { welcome: 'Ola!' } })
})
bearer.i18n.load('integration-uuid', promiseReturningADictionnary)

// for a given locale
const dictionnary = { titles: { welcome: 'Guten Morgen' } }
bearer.i18n.load('integration-uuid', dictionnary, { locale: 'de' })

// for multiple integrations on a single page
const dictionnary = {
  ['integration-one-uuid']: { title: { welcome: 'Hello my friend' } },
  ['integration-two-uuid']: { message: { goodbye: 'Bye Bye' } }
}
bearer.i18n.load(null, dictionnary)

Secure

If you want to add a level of security, you can switch to the secure mode:

window.bearer.secured = true
// at the initialisation time
window.bearer('clientId', { secured: true })

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
import Cipher from '@bearer/security'

const cipher = new Cipher(ENCRYPTION_KEY)
cipher.encrypt(MESSAGE)

init options

Soon

FAQs

Package last updated on 14 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc