New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@aserto/aserto-react

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aserto/aserto-react

Aserto React SDK

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19
increased by137.5%
Maintainers
1
Weekly downloads
 
Created
Source

Aserto React SDK

Loosely modeled after the Auth0 React SDK.

This SDK uses the Aserto javascript SPA SDK.

Installation

Using npm:

npm install @aserto/aserto-react

Using yarn:

yarn add @aserto/aserto-react

Getting Started

Configure the SDK by wrapping your application in AsertoProvider. If using in conjunction with the Auth0Provider, AsertoProvider should be nested inside of it.

// src/index.js
import React from 'react'
import ReactDOM from 'react-dom'
import { AsertoProvider } from '@aserto/aserto-react'
import App from './App'

// this example initializes the Aserto Provider with a getToken 
// function supplied by the Auth0 React SDK
import { Auth0Provider, useAuth0 } from '@auth0/auth0-react'
const { getAccessTokenSilently } = useAuth0();

ReactDOM.render(
  <Auth0Provider
    domain="YOUR_AUTH0_DOMAIN"
    clientId="YOUR_AUTH0_CLIENT_ID"
    redirectUri={window.location.origin}
  >
    <AsertoProvider
      getToken={getAccessTokenSilently}
    >
      <App />
    </AsertoProvider>
  </Auth0Provider>,
  document.getElementById('app')
);

Use the useAserto hook in your components to access authorization map state (loading, authzMap) or to force it to load (loadAuthzMap):

// src/App.js
import React from 'react'
import { useAserto } from '@aserto/aserto-react'

function App() {
  const {
    loading,
    authzMap,
    loadAuthzMap
  } = useAserto();

  if (loading) {
    return <div>Loading...</div>;
  }

  if (!authzMap) {
    loadAuthzMap();
    return <div>Loading...</div>;
  } else {
    return (
      <div>
        { authzMap }
      </div>
    );
  } 
}

export default App

Keywords

FAQs

Package last updated on 21 Dec 2020

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