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

rystem.authentication.social.react

v0.2.1

Published

It can simplify the integration with social identities and .Net.

Downloads

12

Readme

What is Rystem?

Social logins

Services setup

You need to install the configuration in the startup file.

import { SocialLoginWrapper, setupSocialLogin } from 'rystem.authentication.social.react';

setupSocialLogin(x => {
    x.apiUri = "https://localhost:7017";
    x.google.clientId = "23769141170-lfs24avv5qrj00m4cbmrm202c0fc6gcg.apps.googleusercontent.com";
    x.microsoft.clientId = "0b90db07-be9f-4b29-b673-9e8ee9265927";
    x.facebook.clientId = "345885718092912";
    x.github.clientId = "97154d062f2bb5d28620"
    x.amazon.clientId = "amzn1.application-oa2-client.dffbc466d62c44e49d71ad32f4aecb62"
    x.onLoginFailure = (data) => alert(data.message); //set the callback for error during request.
    x.automaticRefresh = true; //this one help to autorefresh the token if expired during getting it.
});

function App() {
    return (
        <>
            <SocialLoginWrapper>
                <Wrapper></Wrapper>
            </SocialLoginWrapper>
        </>
    )
}

export default App

onLoginFailure callback

On error you can receive:

  • code: 3, for error during clicking the social login button
  • code: 15, for error during retrieve of the token
  • code: 10, for error during retrieve of the user

Furthermore, you will receive a message and the social provider. When you see DotNet or 0, it means it's the integration with .Net api.

Usage for token

Get current token to use for example in http request to your api services. Check before the request if the token is expired.

const token = useSocialToken();
const isExpired = token.isExpired;

Usage for user

Get current user to retrieve information about him.

const user = useSocialUser();

Force refresh

Get the refresh action to use as you wish to refresh the token with a brand new one.

const forceRefresh = useContext(SocialLoginContextRefresh);

Force logout

Get the logout action to set, for instance, as an event of a clicked button.

const logout = useContext(SocialLoginContextLogout);

Example

For example the Wrapper component could be so, in this example you may find the way to change the login buttons order too.

import { SocialLoginButtons, SocialLoginContextLogout, SocialLoginContextRefresh, SocialLogoutButton, useSocialToken, useSocialUser } from "rystem.authentication.social.react";
import { AmazonButton, GoogleButton, MicrosoftButton, FacebookButton, GitHubButton, LinkedinButton, XButton, TikTokButton, PinterestButton, InstagramButton } from "rystem.authentication.social.react";

const newOrderButtons = [
    MicrosoftButton,
    GoogleButton,
    LinkedinButton,
    FacebookButton,
    AmazonButton,
    GitHubButton,
    XButton,
    TikTokButton,
    InstagramButton,
    PinterestButton
];

export const Wrapper = () => {
    const token = useSocialToken();
    const [count, setCount] = useState(0);
    const user = useSocialUser();
    const forceRefresh = useContext(SocialLoginContextRefresh);
    const logout = useContext(SocialLoginContextLogout);
    return (
        <>
            {token.isExpired && <SocialLoginButtons buttons={newOrderButtons}></SocialLoginButtons>}
            {!token.isExpired && <div>{token.accessToken}</div>}
            {user.isAuthenticated && <div>{user.username}</div>}
            <button onClick={() => forceRefresh()}>force refresh</button>
            <button onClick={() => logout()}>logout</button>
            <SocialLogoutButton>
                logout
            </SocialLogoutButton>
        </>
    );
}