@os1-platform/aaa-mobile
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

React native AAA mobile SDK

Introduction

Built on top of react-native, react-native-app-auth, typescript. This sdk can be used on mobile for authentication, to fetch access token and logout feature.

Installation

npm install @os1-platform/aaa-mobile

Install Peer dependencies

npm install react-native-app-auth@6.4.3
npm install @react-native-async-storage/async-storage@^1.15.14
npm install axios@^0.26.1

Peer dependencies:

{
  "@react-native-async-storage/async-storage": "^1.15.14",
  "react": ">=17.0.2",
  "react-native": ">=0.67.3",
  "react-native-app-auth": "^6.4.3",
  "axios": ">=0.26.1"
}

Add Manifest Placeholder in build.gradle (app level)

manifestPlaceholders = [appAuthRedirectScheme: "${applicationId}"]

Usage

Init AAA SDK

// Obtain domainId and clientId from  Auth0/ Keycloak dashboard
import { LoginHelper } from '@os1-platform/aaa-mobile';
await LoginHelper.initAuth0(
  'domain', //example.dev.io
  'clientId' //some-rn-app
);

//Note : domainId should start with https://

Initiate Login

import { LoginHelper } from '@os1-platform/aaa-mobile';

// Pass keys name for storing access Token and id Token
await LoginHelper.initLogin('Token', 'idToken').then((res: any) => {
  console.log('Result ', res);
});

// Result Type
export interface AuthorizeResult {
  accessToken: string;
  accessTokenExpirationDate: string;
  authorizeAdditionalParameters?: { [name: string]: string };
  tokenAdditionalParameters?: { [name: string]: string };
  idToken: string;
  refreshToken: string;
  tokenType: string;
  scopes: string[];
  authorizationCode: string;
  codeVerifier?: string;
}

Logout

import { LoginHelper } from '@os1-platform/aaa-mobile';

await LoginHelper.logoutUser('Token');

Fetch access Token

import { LoginHelper } from '@os1-platform/aaa-mobile';
const accessToken = await LoginHelper.fetchAccessToken();

//This will fetch the latest access token from the storage and if the token is expired then it calls refresh token internally and returns the new access token

Refresh Token

import { LoginHelper } from '@os1-platform/aaa-mobile';

await LoginHelper.refreshToken();

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.61latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.61
1.0.51
1.0.42
1.0.31
1.0.01

Package Sidebar

Install

npm i @os1-platform/aaa-mobile

Weekly Downloads

6

Version

1.0.6

License

MIT

Unpacked Size

450 kB

Total Files

47

Last publish

Collaborators

  • fxtrt-automation
  • ashishranjan-delhivery
  • kshitijsharmadelhivery
  • bhatupanshu
  • u-anand
  • garima-delhivery
  • pavanbhat