0.1.7 • Published 5 years ago

@manifoldco/shadowcat v0.1.7

Weekly downloads
-
License
BSD
Repository
github
Last release
5 years ago

shadowcat

Simple JS OAuth solutions for Manifold UI

Usage

React

In a terminal, install @manifoldco/shadowcat for your app:

npm i @manifoldco/shadowcat

Then register the web component (we recommend as high up the DOM tree as possible, so it’ll load sooner).

import React, { useEffect, useRef } from "react";

import("@manifoldco/shadowcat/dist/loader").then(({ defineCustomElements }) =>
  defineCustomElements(window)
);

const App = () => {
  const authRef = useRef(null);

  useEffect(() => {
    // Fires whenever a token is received
    const tokenReceived = detail => {
      console.log(detail);
      // {
      //   duration: 1450,
      //   error: null,
      //   expiry: 1566565841,
      //   token: "Hi I'm a super duper secret token!"
      // }
    };

    if (authRef.current) {
      authRef.addEventListener("receiveManifoldToken", tokenReceived);
    }
  }, []);

  return (
    <>
      <Routes />
      <manifold-oauth ref={authRef} /> {/* this can be placed anywhere, really, but the sooner it loads the better  */}
    </>
  );
};

HTML / JS

<body>
  <manifold-auth></manifold-auth>
  <script src="https://unpkg.com/@manifoldco/shadowcat/dist/manifold.js"></script>
  <script>
    document
      .querySelector("manifold-oauth")
      .addEventListener("receiveManifoldToken", e => {
        console.log(e.detail);
        // {
        //   duration: 1450,
        //   error: null,
        //   expiry: 1566565841,
        //   token: "Hi I'm a super duper secret token!"
        // }
      });
  </script>
</body>

CDN

In any setup, you can use a CDN for Shadowcat

https://js.cdn.manifold.co/@manifoldco/shadowcat/       # latest (beware of breaking changes!)
https://js.cdn.manifold.co/@manifoldco/shadowcat@0.2.0/ # specific version

Options

OAuth URL

You can change the OAuth URL from Manifold’s default by specifying oauth-url on the custom element:

<manifold-oauth oauth-url="[your-oauth-url]"></manifold-oauth>

Links

Code of Conduct | Contribution Guidelines

GitHub release

Travis

version (scoped)

License

0.1.7

5 years ago

0.1.7-rc.1

5 years ago

0.1.7-rc.0

5 years ago

0.1.6

5 years ago

1.6.0

5 years ago

0.1.6-rc.0

5 years ago

0.1.3-rc.0

5 years ago

0.1.2-test.0

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago