@crowdform/flex-connect-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.0.16 • Public • Published

FlexConnect SDK

Installation

<script src="https://flex-connect-staging.web.app/main.connect.js"></script>

Example

Using jQuery + Parcel Demo Example

$(function() {
  // <script src="https://flex-connect-staging.web.app/main.connect.js"></script>
  // clientId = flex-xyz

  const sdk = new window.FlexConnect("flex-xyz", {
    env: "development"
  });

  // must init the package
  sdk.init();

  // create button with class .login
  $(".login").on("click", async () => {
    try {
      const url = await sdk.auth.login();
    } catch (e) {
      console.error(e);
    }
  });

  // create button with class .logout
  $(".logout").on("click", async () => {
    try {
      const url = await sdk.auth.logout();
    } catch (e) {
      console.error(e);
    }
  });

  // add a <div class="profile"></div>
  document.addEventListener("onAuthSuccess", event => {
    console.log("user is logged in", event.detail.user);
    // do something with user data
    const profile = JSON.stringify(event.detail.user, null, 2);
    $(".profile").text(profile);
    $(".login").hide();
  });
});

Publish Script

Deploy through github CI/CD on main branch. Hosted on Firebase.

<script src="https://flex-connect-staging.web.app/connect.js"></script>

Publish NPM Package

  1. Login to NPM under Crowdform organisation
  2. Increase package.json version number
  3. run yarn build
  4. run npm publish

Readme

Keywords

none

Package Sidebar

Install

npm i @crowdform/flex-connect-sdk

Weekly Downloads

1

Version

0.0.16

License

MIT

Unpacked Size

3.06 MB

Total Files

88

Last publish

Collaborators

  • niltonsf
  • joaomario
  • leocrowdform
  • jdarosaj