npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@databiz/login

v2.0.2

Published

Web Component to simplify authentication using Google oAuth for Databiz group domains.

Downloads

19

Readme

@databiz/login

Build Status

Web Component to simplify authentication using Google oAuth for Databiz group domains, it wraps the Google Sign-in for Websites SDK and expose custom events for its functionalities.

How to use

Install the package from NPM registry

$ npm install @databiz/login
--- or ---
$ yarn add @databiz/login

If you want to include the compiled version (no build-step needed), just load the script tag:

<script src="./node_modules/@databiz/login/component.js" async defer></script>

Or if you are working with Webpack and ES modules:

import '@databiz/login';

then in your markup add

<databiz-login
  client-id="YOUR-CLIENT-ID"
></databiz-login>

the client-id is a required parameter and you can obtain it from the Google Developer console.

This will render the Google login button, once clicked a popup will be prompted to user to choose an account and confirm.

To react to the login attempt the component fires two custom events: signin-success and signin-error.

A quick example:

const $login = document.querySelector('databiz-login');

$login.addEventListener('signin-success', 
  evt => console.log(evt.detail));

$login.addEventListener('signin-error', 
  evt => console.log(evt.detail));

The signin-success event will return an object inside the detail with the following data:

  • token: the token_id returned from Google authentication
  • profile: the data exposed by the googleUser.getBasicProfile() in the SDK.

To trigger the logout from the current session you must import the signOut method from the main package:

import { signOut } from '@databiz/login';

// ...some code later...

signOut().then(() => {
  // code to execute after the logout is completed
});

Browser compatibility

The component is built following the Custom Elements v1 and EcmaScript 2015 specifications.

| | Chrome | Firefox | Safari | Opera | Edge | IE11 | |--|--|--|--|--|--|--| | as-is | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |:x:|:x:| | CE polyfill | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: |

Available NPM tasks

Start the demo page in development mode (live reload)

$ yarn start

Create a static build of the main component in the root folder

$ yarn build

Create a static build of the demo page in the ./dist folder

$ yarn demo

Run the demo action and deploy to GitHub pages

$ yarn deploy

Local development

In order to have a local development environment, you must create a .env file in the project root and add your Google application's client id:

CLIENT_ID=123fake123client123id

License

Developed by Bitrock UI Engineering team, released under the MIT license.