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

0.5.2 • Public • Published

Bloomberg SSO js utilities

NPM Version Build Status Code Climate Test Coverage

Install

yarn add bsso

! Usage with react native !

First setup react-native-get-random-values and react-native-webview-crypto and react-native-url-polyfill.

Simple Usage

import { BSSO } from 'bsso';

const bsso = new BSSO({
  clientId: 'se-mobile-app',
  redirectUri: 'http://localhost:8080/'
});

const tokenFromRedirectUrl = new URLSearchParams(window.location.hash).get('#token');
	
if (tokenFromRedirectUrl) {
  // if we have #token, we are ready for redirect
  console.log('redirect');
  window.location.replace(await bsso.getRedirectURL(tokenFromRedirectUrl));
} else {
  const code = new URLSearchParams(window.location.search).get("code");

  if (code) {
    // if we have the code, we are ready to continue getting token for authorization
    const activeToken = await bsso.getToken(code);
    console.log('activeToken', activeToken);
  }
}

BSSO API

Method Arguments Return
getToken code?: string string
isExpired boolean
getRedirectURL token: string, scope?: string string
toJSON object

Package Sidebar

Install

npm i bsso

Weekly Downloads

14

Version

0.5.2

License

ISC

Unpacked Size

13.2 kB

Total Files

7

Last publish

Collaborators

  • jcgertig