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

@silentauth/silentauth-sdk-react-native

v1.0.13

Published

React Native SDK for SilentAuth

Downloads

23

Readme

SilentAuth SDK for React Native

License

The only purpose of the SDK is to force the data cellular connectivity prior to call a public URL, and will return the following JSON response

  • Success When the data connectivity has been achieved and a response has been received from the url endpoint
{
"http_status": string, // HTTP status related to the url
"response_body" : { // optional depending on the HTTP status
           ... // the response body of the opened url 
           ... // see API doc for /device_ip and /redirect
                },
"debug" : {
    "device_info": string, 
    "url_trace" : string
          }
}
  • Error When data connectivity is not available and/or an internal SDK error occurred
{
"error" : string,
"error_description": string,
"debug": {
    "device_info": string, 
    "url_trace" : string
          }
}

Potential error codes: sdk_no_data_connectivity, sdk_connection_error, sdk_redirect_error, sdk_error.

Installation

npm install @silentauth/silentauth-sdk-react-native

For Android, add the following to your application's build.gradle:

maven {
    url "https://gitlab.com/api/v4/projects/40053021/packages/maven"
}

Compatibility

Usage

  • Is the device elgibile for silent authentication?
import SilentAuthSdkReactNative, {
  ReachabilityResponse,
  CheckResponse,
  CheckErrorBody,
  CheckSuccessBody,
  ApiError,
  ReachabilityBody,
  ReachabilityResponseBody,
} from '@silentauth/silentauth-sdk-react-native';

// ...
// retrieve access token with coverage scope from back-end
const token = ...
// open the device_ip public API endpoint
    if (token) {
      const res = await SilentAuthSdkReactNative.openWithDataCellularAndAccessToken<ReachabilityResponse>(
        'https://eu.api.silentauth.com/coverage/v0.1/device_ip',
        true,
        token
        );
    if ('error' in res) {
      // error ${err.error_description}
    } else if ('http_status' in res) {
      const httpStatus = success.http_status;
      if (httpStatus === 200 && res.response_body !== undefined) {
        const body = res.response_body as ReachabilityBody
        // device is eligible on MNO  ${body.network_name}
      } else if (httpStatus === 400 && res.response_body !== undefined) {
        const body = res.response_body as ApiError;
        // MNO not supported ${body.detail}
      } else if (httpStatus === 412 && res.response_body !== undefined) {
        const body = res.response_body as ApiError;
        // Not a mobile IP ${body.detail}
      } else if (res.response_body !== undefined) {
        const body = res.response_body as ApiError;
        // other error see ${body.detail}
      }
    }
    }

 
  • How to open a check URL return?
import SilentAuthSdkReactNative, {
  ReachabilityResponse,
  CheckResponse,
  CheckErrorBody,
  CheckSuccessBody,
  ApiError,
  ReachabilityBody,
  ReachabilityResponseBody,
} from '@silentauth/silentauth-sdk-react-native';

// ...

const res = await SilentAuthSdkReactNative.openWithDataCellular<CheckResponse>(checkUrl);
      if ('error' in res) {
        // error see ${err.error_description}
      } else if ('http_status' in res) {
        const httpStatus = res.http_status;
        if (httpStatus === 200 && res.response_body !== undefined) {
            if ('error' in res.response_body) {
              const body = res.response_body as CheckErrorBody;
                // error see ${body.error_description}
            } else {
              const body = res.response_body as CheckSuccessBody;
                // send ${body.code}, ${body.check_id} and ${body.reference_id} to back-end 
                // to trigger a PATCH /checks/{check_id}
            }
        } else if (httpStatus == 400 && res.response_body !== undefined) {
          const body = res.response_body as ApiError;
          // MNO not supported see ${body.detail}
        } else if (httpStatus === 412 && res.response_body !== undefined) {
          const body = res.response_body as ApiError;
          // Not a mobile IP see ${body.detail}
        } else if (res.response_body !== undefined) {
          const body = res.response_body as ApiError;
          // other error see ${body.detail}
        }
      }

Example Demo

There's an embedded example demo is located in the example directory, see README

Releasing

Update CHANGELOG.md and finesse.

$ yarn run changelog

Commit the changes:

$ git commit -m 'chore(release): v{version}'

Tag:

$ git tag v{version}

Publish a new canary build to test.

$ yarn run publish:canary

Publish a full version:

$ yarn run publish:latest

Meta

Distributed under the MIT license. See LICENSE for more information.

https://github.com/silentauth