# @os1-platform/aaa-mobile

> AAA mobile SDK

Latest version **1.0.6** (published 2022-09-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @os1-platform/aaa-mobile
pnpm add @os1-platform/aaa-mobile
yarn add @os1-platform/aaa-mobile
bun add @os1-platform/aaa-mobile
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2022-09-20 |
| First published | 2022-09-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 439.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | FoxtrotPlatform |
| Maintainers | bhatupanshu, u-anand, anuj-delhivery, garima-delhivery, pavanbhat |
| Keywords | react-native, android |

## Links

- npm: https://www.npmjs.com/package/@os1-platform/aaa-mobile
- npm.io page: https://npm.io/package/@os1-platform/aaa-mobile

## Dependencies (1)

- [jwt-decode](https://npm.io/package/jwt-decode.md) ^3.1.2

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2022-09-20
- 1.0.5 — 2022-09-19
- 1.0.4 — 2022-09-16
- 1.0.3 — 2022-09-16
- 1.0.0 — 2022-09-15

## README

`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

```shell
npm install @os1-platform/aaa-mobile
```

## Install Peer dependencies

```shell
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:

```js
{
  "@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)

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

```

## Usage

### `Init AAA SDK`

```ts
// 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`

```ts
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`

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

await LoginHelper.logoutUser('Token');
```

### `Fetch access Token`

```ts
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`

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

await LoginHelper.refreshToken();
```

---
_Source: https://npm.io/package/@os1-platform/aaa-mobile · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
