Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@crossid/crossid-spa-js

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@crossid/crossid-spa-js

Crossid is an OAuth2 / OIDC client for single page application (SPA) with support for PKCE extension.

  • 0.4.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-81.82%
Maintainers
2
Weekly downloads
 
Created
Source

@crossid/crossid-spa-js npm version Test PRs Welcome GitHub license

OAuth2 and OIDC SDK for a single page application (SPA), using the authorization code flow with PKCE extension.

Get Started

Install by:

npm:

npm install @crossid/crossid-spa-js

yarn:

yarn add @crossid/crossid-spa-js

Init a client:

import { newCrossidClient, Client } from '@crossid/crossid-spa-js'
const crossid = newCrossidClient({
  // your crossid tenant
  tenant_id: 'indexia',
  client_id: 'my-client-id',
  audience: ['example.com'],
  scope: 'openid profile',
  redirect_uri: 'http://localhost:3009',
  // use session_storage or local_storage for a persistent cache.
  cache_type: 'memory',
})

note: the example above shows how to connect to a crossid tenant but this library can work with any OIDC authorization server that supports the PKCE extension. See newCrossidClientByDiscovery and newCrossidClientCustom.

To sign user in, call crossid.loginWithRedirect({}) to redirect browser to the authprization server login page. This function is typically bound to a button.

Once signing the user in completes successfully, the user will be redirected to the location specified in redirect_uri.

At this point, the signing in process must be completed by running the crossid.handleRedirectCallback() function which will take care of completing the flow and caching the tokens.

To get an access token, which can be used to access your API:

const token = await client.getAccessToken()

To get the authenticated user:

const user = await client.getUser()

For a working example, see example repo.

Documentation

Bugs and feature requests

Have a bug, feature request or feedback? Please first search for existing and closed issues. If your problem or idea is not addressed yet, please open a new issue.

Contributing

The main purpose of this repository is to continue evolving crossid-spa-js, making it more secure and easier to use. Development of this library happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving crossid-spa-js.

Reporting a Vulnerability

The Crossid team takes security issues very seriously. We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions.

To report a security issue, email security@crossid.io.

We'll endeavor to respond quickly, and will keep you updated throughout the process.

What is Crossid?

Crossid can:

  • Sign users in using various passwordless authentication factors (e.g., otp, fingerprint, etc...)
  • Sign users in via social providers (e,g. Facebook) or enterprise providers (e.g., Azure)
  • Multi factor authentication.
  • Issue signed OAuth2 and Openid-Connect access tokens to protect API calls.
  • Manage user profiles and access.

License

This project is licensed under the MIT license.

Keywords

FAQs

Package last updated on 22 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc