Git Product home page Git Product logo

breadbutter-js's Introduction

Bread & Butter JS

Client Side JavaScript toolkit for the Bread & Butter API

Download

https://cdn.breadbutter.io/dist/breadbutter.7.2.0.979.min.js

Configuration


Integrate with BreadButter with one simple front end script tag

Example Website

<!DOCTYPE html>
<html>
  <head>
    <title>Bread & Butter Sample</title>
    <script>
        window.initBreadButter = function() {
            BreadButter.configure({ app_id: APP_ID });
            BreadButter.widgets.continueWith();
        };
    </script>
    <script id="breadbutter-js" src="https://cdn.breadbutter.io/dist/breadbutter.7.2.0.979.min.js"></script>
  </head>
 <body></body>
</html>

Continue with script tag

Inject this on your home page to get started using with Bread & Butter with the Continue With widget.

<script>
    window.initBreadButter = function() {
    	BreadButter.configure({ app_id: APP_ID });
    	BreadButter.widgets.continueWith();
    };
    (function(d, s, id){ var js,fjs=d.getElementsByTagName(s)[0]; if(d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = 'https://cdn.breadbutter.io/dist/breadbutter.7.2.0.979.min.js'; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'breadbutter-js'));
</script>

Configure the global BreadButter client

BreadButter.configure({
    app_id,
    api_path,
    destination_url,
    callback_url,    
    client_data,
    force_reauthentication, //default false
    app_name,
    page_view_tracking, //default true
    button_theme,
    continue_with_position: {
        top/bottom,
        left/right
    },
    expand_email_address, //default true
    show_login_focus, //default true
    allow_sub_domain, //default true
    remember_close, //default true
    success_event_code
});

Configuration Details

Property Description
app_id [STRING] Unique identifier for your application. Find your app_id here: https://app.breadbutter.io/app/#/app-settings.
callback_url [STRING] The Callback URL is the URL that the user will be redirected to after they have authenticated with the provider. Please add your Callback URL by going to "Settings" in the left menu of your Bread & Butter app, and expand "Advanced Settings". Note that "Enable Callback URL" will need to be set to ON.
destination_url [STRING] The Destination URL is the final destination for the user to be redirected. This is only required if your client side needs to tell your backend where to redirect the user.
app_name [STRING] Application name that you want displayed in the JSL widgets.
client_data [OBJECT] Client data is used to allow you to pass parameters from the client side to your backend which processes the authentication.
force_reauthentication [STRING] [off/attempt/force] Force reauthentication for the provider when your user logs in (ie, disregard the user's current session if the providers supports it).
page_view_tracking [BOOLEAN] [DEFAULT: true] By default, the JSL will create events for all your user's page views. This parameter allows you to disable this feature.
button_theme [STRING] [VALUES: round-icons/square-icons/tiles] [DEFAULT: 'tiles'] This parameter allows you to change the theme the provider buttons are displayed in your widgets.
expand_email_address [BOOLEAN] [DEFAULT: true] This parameter is used to expand the email address field on advanced discovery.
show_login_focus [BOOLEAN] [DEFAULT: false] Show the background blur for the continue with login on the advanced discovery.
continue_with_position [OBJECT] [Example: {'top': '10px', 'right': '10px'}] Used for positioning the continue with widget. Will accept only 1 parameter for top/bottom and 1 parameter for left/right. Accepts 10, '10px', and '10%' for positioning.
allow_sub_domain [BOOLEAN] [DEFAULT: false]
remember_close [BOOLEAN] [DEFAULT: false]
success_event_code [STRING] When authentication is a success, an event will be created with this custom event code.

Widgets

Continue With Widget

ContinueWith

Global Overrides

Accepted global options (defined above) when using the Continue With widget:

app_name
destination_url
callback_url
client_data
force_reauthentication
button_theme
continue_with_position
expand_email_address
show_login_focus
remember_close
success_event_code

Parameters

Property Description
mode [STRING] Used to start the widget in a specific part of the workflow.
email_address [STRING] Used to prefill the email address for the user if you already have it (ie, querystring parameter from an email)
pin [STRING] This parameter takes a pin sent to the user in a one of the following workflows: Email confirmation, Invitation, Reset Password.
onFormClose [FUNCTION] Function called when the Continue With widget is closed.

Basic Usage

BreadButter.widgets.continueWith();

BreadButter.widgets.continueWith({
    email_address: USER_EMAIL
});

BreadButter.widgets.continueWith({
    mode: BreadButter.mode.RESET_PASSWORD,
    email_address: USER_EMAIL,
    pin: EMAIL_PIN
});

BreadButter.widgets.continueWith({
    mode: BreadButter.mode.CONFIRM_EMAIL,
    email_address: USER_EMAIL,
    pin: EMAIL_PIN
});

BreadButter.widgets.continueWith({
    mode: BreadButter.mode.INVITATION,
    email_address: USER_EMAIL,
    pin: EMAIL_PIN //if invitation pin is available
});

Close Event

BreadButter.widgets.continueWith();

BreadButter.widgets.continueWith({
    onFormClose: function() {
        console.log("Continue With widget dismissed");
    }
});

Sign in Widget

Signin

Global Overrides

Accepted global options (defined above) when using the Continue With Widget:

app_name
destination_url
callback_url
client_data
force_reauthentication
button_theme
expand_email_address
success_event_code

Parameters

Property Description
mode [STRING] Used to start the widget in a specific part of the workflow.
email_address [STRING] Used to prefill the email address for the user if you already have it (ie, querystring parameter from an email)
pin [STRING] This parameter takes a pin sent to the user in a one of the following workflows: Email confirmation, Invitation, Reset Password.

Basic Usage

BreadButter.widgets.signIn(TARGET_DOM_ID);

BreadButter.widgets.signIn(TARGET_DOM_ID, {
    email_address: USER_EMAIL
});

BreadButter.widgets.signIn(TARGET_DOM_ID, {
    mode: BreadButter.mode.RESET_PASSWORD,
    email_address: USER_EMAIL,
    pin: EMAIL_PIN
});

BreadButter.widgets.signIn(TARGET_DOM_ID, {
    mode: BreadButter.mode.CONFIRM_EMAIL,
    email_address: USER_EMAIL,
    pin: EMAIL_PIN
});

BreadButter.widgets.signIn(TARGET_DOM_ID, {
    mode: BreadButter.mode.INVITATION,
    email_address: USER_EMAIL,
    pin: EMAIL_PIN //if invitation pin is available
});

Buttons Widget

Buttons

LL icon

BreadButter.widgets.buttons(TARGET_DOM_ID);

Icons

LL icon

BreadButter.widgets.buttons(TARGET_DOM_ID, {
    button_theme: ‘round-icons’
});

De-identification

BreadButter.widgets.deIdentification();

Methods

Custom API Events

CustomAPI

Use this method to track specific events performed by your users.

BreadButter.events.custom(CUSTOM_API_EVENT_NAME, function() {
    console.log(‘EVENT CALL COMPLETE’);
});

Get Profile API

Use this method to retrieve user profile information about your users.

BreadButter.getProfile(function(user_profile, suggested_provider, device_verified) {
    console.log(‘GET PROFILE CALL COMPLETE’);
});

Response

Property Description
user_profile [OBJECT] Contains information identifying the users including: email_address, first_name, last_name, profile_image_url.
suggested_provider [STRING] Type of account the user had logged in with (eg, Google, Linkedin, Microsoft, etc.)
device_verified [BOOL] Whether the user is verified or not.

breadbutter-js's People

Contributors

ango-breadbutter avatar isiah-bb avatar isiah-logon-labs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

breadbutter-js's Issues

missing cdn file breadbutter.6.1.0.3081.min.js

This URL returns 404
https://cdn.breadbutter.io/dist/breadbutter.6.1.0.3081.min.js

wget https://cdn.breadbutter.io/dist/breadbutter.6.1.0.3081.min.js
--2022-10-19 09:36:10--  https://cdn.breadbutter.io/dist/breadbutter.6.1.0.3081.min.js
Resolving cdn.breadbutter.io (cdn.breadbutter.io)... 152.199.39.108, 2606:2800:247:1cb7:261b:1f9c:2074:3c
Connecting to cdn.breadbutter.io (cdn.breadbutter.io)|152.199.39.108|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2022-10-19 09:36:11 ERROR 404: Not Found.

sign in to breadbutter.io

Hello! Sign In to yours site does not work properly.
after success login with GitHUB/Google account, next redirect return html as text/plain? and last versions of Google Chrome, Opera, Firefox, Safary show source code of it.
https://breadbutter.io/wp-json/breadbutter-connect/v1/authorize?app_id=2b7889dab8a54c78b0e7242a53ce864b&authentication_token=605ad9a98e0305b4aea1c671
https://breadbutter.io/wp-json/breadbutter-connect/v1/authorize?app_id=2b7889dab8a54c78b0e7242a53ce864b&authentication_token=605ada037b2edef1528bb77e
Sorry for post here, but i cant login to view another contacts
bread1
bread2

Typo in code sample

BreadButter.widgets.deidentification();

Hi guys

The de-identification code example in the README.md does not work because of a typo. It should be BreadButter.widgets.deIdentification() (with a capital i).

Cheers,
Hazzeldorn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.