client-passport
TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

client-passport

Universal authentication for client-side apps, supported providers:

  • Google Sign-in for Websites
  • Facebook SDK

Usage

Create authenticator instance.

import {passport} from 'client-passport';
import {loader as facebookLoader} from 'client-passport/lib/providers/facebook';
 
const authenticator = passport({
  providers: {
    google: async () => ({
      loader: (await import('client-passport/lib/providers/google')).loader,
      options: {
        client_id: 'xxxxxxxxxx-yyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.apps.googleusercontent.com',
      },
    }),
    facebook: () => ({
      loader: facebookLoader,
      options: {
        appId: '00000000000000',
        autoLogAppEvents: true,
        xfbml: true,
        version: 'v3.2',
      }
    }),
  }
});

Subscribe to user changes. Every time user logs in this callback is called. When user logs out, user is set to null.

authenticator.onchange = (user) => {
   //
};

Sign-in with selected provider.

user = await authenticator.signIn('google');
user = await authenticator.signIn('facebook');

Sign-out.

await authenticator.signOut();

License

Unlicense — public domain.

Readme

Keywords

none

Package Sidebar

Install

npm i client-passport

Weekly Downloads

8

Version

2.1.0

License

Unlicense

Unpacked Size

1.12 MB

Total Files

85

Last publish

Collaborators

  • streamich