Skip to content

Commit

Permalink
Improved docs (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
kober32 authored Sep 12, 2024
1 parent 0bc73ac commit 9f3bb70
Show file tree
Hide file tree
Showing 18 changed files with 96 additions and 72 deletions.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
# PowerAuth SDK for React Native Mobile Apps
# PowerAuth Mobile JS SDK

[![npm](https://img.shields.io/npm/v/react-native-powerauth-mobile-sdk)](https://www.npmjs.com/package/react-native-powerauth-mobile-sdk) ![license](https://img.shields.io/github/license/wultra/react-native-powerauth-mobile-sdk) ![released](https://img.shields.io/github/release-date/wultra/react-native-powerauth-mobile-sdk)

In order to connect to the [PowerAuth](https://www.wultra.com/mobile-security-suite) service, mobile applications need to perform the required network and cryptographic processes, as described in the PowerAuth documentation. To simplify the implementation of these processes, developers can use React Native library (for Android and iOS) from this repository.
In order to connect to the [PowerAuth](https://www.wultra.com/mobile-security-suite) service, mobile applications need to perform the required network and cryptographic processes, as described in the PowerAuth documentation. To simplify the implementation of these processes, developers can use This PowerAuth JS SDK library (for Android and iOS) from this repository.

> [!NOTE]
> We currently support __REACT NATIVE__ and __APACHE CORDOVA__ development platforms.
## Documentation

The documentation is available at the [Wultra Developer Portal](https://developers.wultra.com/components/react-native-powerauth-mobile-sdk/) or inside the [docs](docs) folder.

## Support and compatibility

| Version | React-Native<sup>1</sup> | Native SDK | Server version | Support Status |
|---------|-----------------|--------------|----------------|-------------------|
| `2.5.x` | `0.73+` | `1.7.x` | `0.24+` | Fully supported |
| `2.4.x` | `0.71+` | `1.7.x` | `0.24+` | Security bugfixes |
| `2.3.x` | `0.64` - `0.70` | `1.7.x` | `0.24+` | Security bugfixes |
| `2.2.x` | | `1.6.x` | `0.24+` | Not supported |
| Version | React-Native<sup>1</sup> | Cordova | Native SDK | Server version | Support Status |
|---------|--------------------------|-----------|--------------|----------------|-------------------|
| `2.5.x` | `0.73+` | `12.0.0+` | `1.7.x` | `0.24+` | Fully supported |
| `2.4.x` | `0.71+` | - | `1.7.x` | `0.24+` | Security bugfixes |
| `2.3.x` | `0.64` - `0.70` | - | `1.7.x` | `0.24+` | Security bugfixes |
| `2.2.x` | | - | `1.6.x` | `0.24+` | Not supported |

<!-- begin box info -->
> Note 1: The library may also work with other React-Native versions but we don't guarantee compatibility. The specified version is the version that we use for the development and for the tests.
Expand Down
12 changes: 2 additions & 10 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ You will need the following parameters to prepare and configure a PowerAuth inst
To configure PowerAuth instance simply import it from the module and use the following snippet.

```javascript
import { PowerAuth } from 'react-native-powerauth-mobile-sdk';
import { Component } from 'react';

export default class AppMyApplication extends Component {
class AppMyApplication {

private powerAuth = new PowerAuth("your-app-instance-id");

Expand Down Expand Up @@ -87,12 +84,7 @@ In case that you need an advanced configuration, then you can import and use the
The following code snipped shows usage of the advanced configuration:

```javascript
import {
PowerAuth,
PowerAuthConfiguration } from 'react-native-powerauth-mobile-sdk';
import { Component } from 'react';

export default class AppMyApplication extends Component {
class AppMyApplication {

private powerAuth = new PowerAuth("your-app-instance-id");

Expand Down
2 changes: 1 addition & 1 deletion docs/Device-Activation-Removal.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ httpClient.post(null, "/custom/activation/remove", async (error) => {

## Removal via Signed Request

PowerAuth Standard RESTful API has a default endpoint `/pa/v3/activation/remove` for an activation removal. This endpoint uses a signature verification for looking up the activation to be removed. The benefit of this method is that it is already present in both PowerAuth React Native SDK and PowerAuth Standard RESTful API - nothing has to be programmed. Also, the user does not have to be logged in to use it. However, the user has to authenticate using 2FA with either password or biometry.
PowerAuth Standard RESTful API has a default endpoint `/pa/v3/activation/remove` for an activation removal. This endpoint uses a signature verification for looking up the activation to be removed. The benefit of this method is that it is already present in both PowerAuth JS SDK and PowerAuth Standard RESTful API - nothing has to be programmed. Also, the user does not have to be logged in to use it. However, the user has to authenticate using 2FA with either password or biometry.

Use the following code for an activation removal using signed request:

Expand Down
18 changes: 0 additions & 18 deletions docs/Device-Activation.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ The original activation method uses a one-time activation code generated in Powe
Use the following code to create an activation once you have an activation code:

```javascript
import { PowerAuthActivation } from 'react-native-powerauth-mobile-sdk';

const deviceName = "Petr's iPhone 7"; // users phone name
const activationCode = "VVVVV-VVVVV-VVVVV-VTFVA"; // let user type or QR-scan this value

Expand All @@ -33,8 +31,6 @@ If the received activation result also contains recovery data, then you should d
If an [additional activation OTP](https://github.com/wultra/powerauth-crypto/blob/develop/docs/Additional-Activation-OTP.md) is required to complete the activation, then use the following code to configure the `PowerAuthActivation` object:

```javascript
import { PowerAuthActivation } from 'react-native-powerauth-mobile-sdk';

const deviceName = "Petr's iPhone 7"; // users phone name
const activationCode = "VVVVV-VVVVV-VVVVV-VTFVA"; // let user type or QR-scan this value
const activationOtp = "12345";
Expand All @@ -56,8 +52,6 @@ You may also create an activation using any custom login data - it can be anythi
Use the following code to create an activation using custom credentials:

```javascript
import { PowerAuthActivation } from 'react-native-powerauth-mobile-sdk';

// Create a new activation with a given device name and custom login credentials
const deviceName = "Petr's iPhone 7"; // users phone name
const credentials = {
Expand Down Expand Up @@ -89,8 +83,6 @@ If PowerAuth Server is configured to support [Recovery Codes](https://github.com
Use the following code to create an activation using recovery code:

```javascript
import { PowerAuthActivation } from 'react-native-powerauth-mobile-sdk';

const deviceName = "John Tramonta"; // users phone name
const recoveryCode = "55555-55555-55555-55YMA"; // User's input
const puk = "0123456789"; // User's input. You should validate RC & PUK with using PowerAuthOtpUtil
Expand All @@ -114,8 +106,6 @@ try {
You can set an additional properties to `PowerAuthActivation` object, before any type of activation is created. For example:

```javascript
import { PowerAuthActivation } from 'react-native-powerauth-mobile-sdk';

// Custom attributes that can be processed before the activation is created on PowerAuth Server.
// The dictionary may contain only values that can be serialized to JSON.
const customAttributes = {
Expand Down Expand Up @@ -147,8 +137,6 @@ try {
After you create an activation using one of the methods mentioned above, you need to commit the activation - to use provided user credentials to store the activation data on the device.

```javascript
import { PowerAuthAuthentication } from 'react-native-powerauth-mobile-sdk';

const auth = PowerAuthAuthentication.commitWithPasswordAndBiometry("1234", {
// The `PowerAuthBiometricPrompt` object is required on Android platform in case that
// `biometryConfiguration.authenticateOnBiometricKeySetup` is true.
Expand Down Expand Up @@ -178,8 +166,6 @@ The mobile SDK is providing a couple of functions in `PowerAuthActivationCodeUti
To validate an activation code scanned from QR code, you can use `PowerAuthActivationCodeUtil.parseActivationCode(code)` function. You have to provide the code with or without the signature part. For example:

```javascript
import { PowerAuthActivationCodeUtil } from 'react-native-powerauth-mobile-sdk';

const scannedCode = "VVVVV-VVVVV-VVVVV-VTFVA#aGVsbG8......gd29ybGQ=";
try {
const otp = await PowerAuthActivationCodeUtil.parseActivationCode(scannedCode);
Expand All @@ -195,8 +181,6 @@ try {
Note that the signature is only formally validated in the function above. The actual signature verification is performed in the activation process, or you can do it on your own:

```javascript
import { PowerAuthActivationCodeUtil } from 'react-native-powerauth-mobile-sdk';

const scannedCode = "VVVVV-VVVVV-VVVVV-VTFVA#aGVsbG8......gd29ybGQ=";
try {
const otp = await PowerAuthActivationCodeUtil.parseActivationCode(scannedCode);
Expand Down Expand Up @@ -247,8 +231,6 @@ Here's an example how to iterate over the string and validate it character by ch


```javascript
import { PowerAuthActivationCodeUtil } from 'react-native-powerauth-mobile-sdk';

/// Returns corrected code
validateAndCorrectCharacters(code) {
let result = "";
Expand Down
46 changes: 40 additions & 6 deletions docs/Installation.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
# Installation

React Native PowerAuth Mobile SDK is distributed as a public [npm package](https://www.npmjs.com/package/react-native-powerauth-mobile-sdk).
- [Installation for React-Native](#react-native-installation)
- [Installation for Cordova](#cordova-installation)

## Supported Platforms
## React-Native Installation

### Supported Platforms

The library is available for the following __React Native (0.64.1+)__ platforms:

- __Android 5.0 (API 21)__ and newer
- __iOS 13.4__ and newer

## How To Install
### How To Install

### 1. Install the package via npm
#### 1. Install the package via npm
```sh
npm i react-native-powerauth-mobile-sdk --save
```

### 2. Install pods for iOS
#### 2. Install pods for iOS

To make integration working with iOS, don't forget to install Pods:

Expand All @@ -25,12 +28,43 @@ cd ios
pod install
```

### 3. Import PowerAuth in your js/ts files
#### 3. Import PowerAuth in your js/ts files

```typescript
import { PowerAuth, PowerAuthAuthentication, PowerAuthError } from 'react-native-powerauth-mobile-sdk';
```

## Cordova Installation

### Supported Platforms

The library is available for the following __Apache Cordova (>=12.0.0)__ platforms:

- __Android 7.0 (API 24)__ and newer (cordova-android version >=12.0.0)
- __iOS 11.0__ and newer (cordova-ios version >=7.0.0)

### How To Install

#### 1. Install the plugin via the cordova plugin installer
```sh
cordova plugin add cordova-powerauth-mobile-sdk
```

#### 2. Install pods for iOS (if needed)

To make integration working with iOS, you might need to install Pods:

```sh
cd platforms/ios
pod install
```

#### 3. Start using PowerAuth classes

```typescript
const powerAuth = new PowerAuth("my-test-instance");
```

## Read Next

- [Configuration](./Configuration.md)
2 changes: 1 addition & 1 deletion docs/Migration-Instructions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Migration Instructions

This page contains React Native PowerAuth mobile SDK migration instructions.
This page contains PowerAuth Mobile JS SDK migration instructions.

<!-- begin box warning -->
When updating across multiple versions, you need to perform all migration steps additively.
Expand Down
22 changes: 13 additions & 9 deletions docs/Readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# React Native PowerAuth Mobile SDK
# PowerAuth Mobile JS SDK

In order to connect to the [PowerAuth](https://www.wultra.com/product/powerauth-mobile-security-suite) service, mobile applications need to perform the required network and cryptographic processes, as described in the PowerAuth documentation. To simplify the implementation of these processes, developers can use React Native library from this repository.
In order to connect to the [PowerAuth](https://www.wultra.com/mobile-security-suite) service, mobile applications need to perform the required network and cryptographic processes, as described in the PowerAuth documentation. To simplify the implementation of these processes, developers can use This PowerAuth Mobile JS SDK library (for Android and iOS) from this repository.

<!-- begin box info -->
> We currently support __REACT NATIVE__ and __APACHE CORDOVA__ development platforms.
<!-- end -->
<!-- begin remove -->
## Integration Tutorials
Expand Down Expand Up @@ -28,15 +32,15 @@ In order to connect to the [PowerAuth](https://www.wultra.com/product/powerauth-

## Support and compatibility

| Version | React-Native<sup>1</sup> | Native SDK | Server version | Support Status |
|---------|-----------------|--------------|----------------|-------------------|
| `2.5.x` | `0.73+` | `1.7.x` | `0.24+` | Fully supported |
| `2.4.x` | `0.71+` | `1.7.x` | `0.24+` | Security bugfixes |
| `2.3.x` | `0.64` - `0.70` | `1.7.x` | `0.24+` | Security bugfixes |
| `2.2.x` | | `1.6.x` | `0.24+` | Not supported |
| Version | React-Native<sup>1</sup> | Cordova | Native SDK | Server version | Support Status |
|---------|--------------------------|-----------|--------------|----------------|-------------------|
| `2.5.x` | `0.73+` | `12.0.0+` | `1.7.x` | `0.24+` | Fully supported |
| `2.4.x` | `0.71+` | - | `1.7.x` | `0.24+` | Security bugfixes |
| `2.3.x` | `0.64` - `0.70` | - | `1.7.x` | `0.24+` | Security bugfixes |
| `2.2.x` | | - | `1.6.x` | `0.24+` | Not supported |

<!-- begin box info -->
Note 1: The library may work also with other React-Native versions but we don't guarantee the compatibility. The specified version is version that we use for the development and for the tests.
> Note 1: The library may also work with other React-Native versions but we don't guarantee compatibility. The specified version is the version that we use for the development and for the tests.
<!-- end -->
## License
Expand Down
4 changes: 2 additions & 2 deletions docs/Sample-Integration.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Sample Integration

To better understand the APIs of the PowerAuth React Native SDK, we prepared a sample test application.
To better understand the APIs of the PowerAuth Mobile JS SDK, we prepared a sample test application.

## Test Application

The test application with the PowerAuth React Native SDK integration can be found inside the `testapp` folder of the [GitHub repository](https://github.com/wultra/react-native-powerauth-mobile-sdk#docucheck-keep-link). Visit [_tests](https://github.com/wultra/react-native-powerauth-mobile-sdk/blob/develop/testapp/_tests#docucheck-keep-link) folder for example usage of the SDK. The [PowerAuth_Example.ts](https://github.com/wultra/react-native-powerauth-mobile-sdk/blob/develop/testapp/_tests/PowerAuth_Example.ts#docucheck-keep-link) file is perhaps the best start point, because contains a well commented example of the activation flow.
The test application with the PowerAuth Mobile JS SDK integration can be found inside the `testapp` folder of the [GitHub repository](https://github.com/wultra/react-native-powerauth-mobile-sdk#docucheck-keep-link). Visit [_tests](https://github.com/wultra/react-native-powerauth-mobile-sdk/blob/develop/testapp/_tests#docucheck-keep-link) folder for example usage of the SDK. The [PowerAuth_Example.ts](https://github.com/wultra/react-native-powerauth-mobile-sdk/blob/develop/testapp/_tests/PowerAuth_Example.ts#docucheck-keep-link) file is perhaps the best start point, because contains a well commented example of the activation flow.

<!-- begin box warning -->
The test application is using our [`powerauth-js-test-client`](https://github.com/wultra/powerauth-js-test-client) library to manage activations on the server automatically. You suppose to don't do such thing in the real application.
Expand Down
2 changes: 1 addition & 1 deletion docs/Secure-Password.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ In both ways you can alter the following parameters:

## Using password

React Native PowerAuth Mobile SDK allows you to use both strings and special password objects at input, so it’s up to you which way fits best for your purposes. For simplicity, this documentation is using strings for the passwords, but all code examples can be changed to utilize `PowerAuthPassword` object as well. For example, this is the modified code for [Password Change](Password-Change.md#change-with-an-automatic-validation):
PowerAuth Mobile JS SDK allows you to use both strings and special password objects at input, so it’s up to you which way fits best for your purposes. For simplicity, this documentation is using strings for the passwords, but all code examples can be changed to utilize `PowerAuthPassword` object as well. For example, this is the modified code for [Password Change](Password-Change.md#change-with-an-automatic-validation):

```javascript
// Change password from "0123" to "3210".
Expand Down
4 changes: 2 additions & 2 deletions docs/Troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ PowerAuthDebug.traceNativeCodeCalls(true, true);
```

<!-- begin box warning -->
The `PowerAuthDebug` class is effective only if global `__DEV__` constant is `true`. We don't want to log the sensitive information to the console in the production application.
The `PowerAuthDebug` class is effective only when `isEnabled` is `true`. We don't want to log the sensitive information to the console in the production application.
<!-- end -->

## Dumping native objects

If `__DEV__` mode is turned on, then you can dump information about all native objects allocated and used by React Native PowerAuth Mobile SDK:
If `PowerAuthDebug.isEnabled` is turned on, then you can dump information about all native objects allocated and used by PowerAuth Mobile JS SDK:

```javascript
// Dump all objects
Expand Down
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ const tmpDir = ".build";
const copyCDVSourceFiles = () =>
gulp
.src("src/**/**.ts", { base: ".", allowEmpty: true })
.pipe(replace("__DEV__", "false")) // replace reaact-native __DEV__ with false by default
.pipe(gulp.dest(CDV_tempDir));

const copyCDVPatchSourceFiles = () =>
Expand Down
4 changes: 2 additions & 2 deletions other-platforms-support/cordova/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "cordova-powerauth-mobile-sdk",
"title": "PowerAuth SDK for Cordova Mobile Apps",
"title": "PowerAuth Mobile JS SDK for Cordova Mobile Apps",
"version": "0.1.0",
"description": "Wultra PowerAuth Mobile SDK Cordova component for iOS and Android",
"description": "Wultra PowerAuth Mobile JS SDK for Cordova (iOS and Android)",
"types": "typings.d.ts",
"files": [
"README.md",
Expand Down
4 changes: 2 additions & 2 deletions other-platforms-support/cordova/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-powerauth-mobile-sdk" version="0.1.0">
<name>PowerAuth SDK</name>
<description>PowerAuth Mobile SDK for adds capability for authentication and transaction signing into the mobile apps</description>
<name>PowerAuth Mobile JS SDK</name>
<description>PowerAuth Mobile JS SDK for adds capability for authentication and transaction signing into the mobile apps</description>
<license>Apache 2.0</license>
<keywords>cordova,powerauth</keywords>
<!-- Modules are generated by the build script -->
Expand Down
1 change: 0 additions & 1 deletion other-platforms-support/cordova/src/internal/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

export class Utils {

static isDev = false // TODO: set real value
static platformOs = this.detectPlatform()

// TODO: we should probably make this more robust
Expand Down
Loading

0 comments on commit 9f3bb70

Please sign in to comment.