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

react-native-ms-adal

v0.4.2

Published

React Native Bindings for the Microsoft ADAL library

Downloads

82

Readme

react-native-ms-adal

This is a port of the Active Directory Authentication Library (ADAL) plugin for Apache Cordova apps to work with React Native.

It provides all the basic authentication functions and keychain stuff as per the original cordova library.

See the Microsoft Azure Active Directory Authentication Library (ADAL) for iOS and OSX for full instructions on how to configure the keychain etc in xcode.

See the Microsoft Azure Active Directory Authentication Library (ADAL) for Android for full instructions on how to configure necessary permissions in Android.

Hopefully Microsoft will release an official version soon.

Prerequisites

  1. A working react native project. Tested on react-native 0.41 and above
  2. A working CocoaPods installation CocoaPods - Getting Started

Installation iOS

  1. Install from npm npm install --save react-native-ms-adal
  2. Add the ADAL ios library to your ios/Podfile file pod 'ADAL', '~> 2.3'. Create Podfile with pod init if required.
  3. Run pod install to pull the ios ADAL library down.
  4. In you react-native project root folder run react-native link react-native-ms-adal

Installation Android

  1. Install from npm npm install --save react-native-ms-adal
  2. In you react-native project root folder run react-native link react-native-ms-adal

Installation Windows UWP (Experimental)

  1. Install from npm npm install --save react-native-ms-adal
  2. Open windows/{projectname}.sln
  3. Add '../node_modules/react-native-ms-adal/uwp/ReactNativeMSAdal.csproj' to the solution
  4. Add new ReactNativeMSAdal.ReactNativeMSAdalPackage() to the packages list in MainPage.cs

Notes: the UWP implementation is a wrapper for WebAuthenticationCoreManager instead of ADAL and has therefore not implenented direct access to the tokenCache since that is not accessible from that API. MSAdalLogin() and MSAdalLogout() will therefor not work, use the msadal/AuthenticationContext.js directly instead: import AuthenticationContext from 'react-native-ms-adal/msadal/AuthenticationContext'

Installation Windows WPF (Experimental)

  1. Install from npm npm install --save react-native-ms-adal
  2. Open windows/{projectname}.sln
  3. Add '../node_modules/react-native-ms-adal/wpf/ReactNativeMSAdal.Net46.csproj' to the solution
  4. Add '''new ReactNativeMSAdal.ReactNativeMSAdalPackage()''' to the packages list in MainPage.cs

Usage Example

See Active Directory Authentication Library (ADAL) plugin for Apache Cordova apps for details on how to use the AuthenticationContext. This library renames this to MSAdalAuthenticationContext, which can be imported as follows

import {MSAdalAuthenticationContext} from "react-native-ms-adal";

There are also couple of promised based utility functions to provide login and logout functionality. The login method will first try using the acquireTokenSilentAsync function to login using the details stored in the keychain.

import {MSAdalLogin, MSAdalLogout} from "react-native-ms-adal";

const authority = "https://login.windows.net/common";
const resourceUri = "https://graph.windows.net";

const clientId = <your-client-id>;
const redirectUri = <your-redirect-uri>;

const msAdalPromise = MSAdalLogin(authority, clientId, redirectUri, resourceUri)
  .then(authDetails => {
    // Get the data from the server, using the Authorisation Header
    fetch("<your-url>", {
      headers: {
        "Cache-Control": "no-cache",
        Authorization: "Bearer " + authDetails.accessToken
      }
    })
      .then(response => {
        if (response.status === 200) {
          return response.json();
        } else {
          throw new Error(
            "Server returned status: " +
              response.status +
              ": " +
              response.statusText
          );
        }
      })
      .then(json => {
        // etc
      });
  })
  .catch(err => {
    if (err.code === "403") {
      // User has cancelled
      // We need to make sure the login button is displayed
    }
    console.log("Failed to authenticate: " + err);
  });