0.0.16 • Published 2 years ago

@crowdform/flex-connect-sdk v0.0.16

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

FlexConnect SDK

Installation

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