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

cordova-plugin-root-safety

v0.0.3

Published

A plugin to check if the Android device is rooted or not using Google SafetyNet API. It provides both offline and online verification methods.

Downloads

9

Readme

Cordova RootSafety plugin for root detection and certificate verification using Google SafetyNet API

It's a cordova plugin to assess android device using SafetyNet APIs. It won't work for iOS devices as SafetyNet APIs are not available for iOS devices. You can read more about SafetyNet here

Android developers can also use code snippets from this plugin in their project.

Features

  • Google Play Service availability check
  • Attestation
  • Offline verification of the SafetyNet attestation response
  • Online verification of the SafetyNet attestation response
  • Decryption of payload from attestation signature
  • List harmful apps
  • Check/enable app verification service state

Getting Started

For using this plugin you need an API key for SafetyNet attestation. You can use these steps to generate the API key.

Install

cordova plugin add cordova-plugin-root-safety --save

Check the Google Play services

Google Play services is required for SafetyNet APIs to work.

declare var rootSafety: any;
rootSafety.checkGooglePlayServicesAvailability((state)=>{
	if(state == "success"){
		// other stuff
	}
}, (error)=>{
})

Attestation

You need a nonce and an API key while calling the SafetyNet Attestation API. The resulting attestation contains this nonce, allowing you to determine that the attestation belongs to your API call and isn't replayed by an attacker. Attest API returns JWS token which is just a 3 base64 encoded parts concatenated by a . (dot) character.

rootSafety.attest(nonce, apikey,successCallback,errorCallback)

Offline Verification

You can use this service to verify if SafetyNet attestation response actually came from the SafetyNet service and includes data matching your request. It verifies hostname of the attestation response.

rootSafety.offlineVerification(jwsResponse,successCallback,errorCallback)

This service returns a JSON with status parameter with value success if it successfully verifies the attestation signature certificate.

Online Verification

You can verify attestation signature by sending the entire JWS response to your own server, using a secure connection, for verification. It's not recommend that you perform the verification directly in your app.

This plugin also includes a service for verification of the JWS response which sends JWS token through a POST request to the following API, https://www.googleapis.com/androidcheck/v1/attestations/verify?key=ATTESTATION_API_KEY

rootSafety.onlineVerification(apiKey,jwsResponse,successCallback,errorCallback)

The above API return a JSON with isValidSignature parameter with value true if it successfully validates the signature.

Decryption of payload from attestation signature

It extracts the payload JSON string from the attestation signature.

rootSafety.extractPayload(jwsResponse,successCallback,errorCallback)

The payload response JSON contains following parameter:

{  
	"timestampMs": 9860437986543,  
	"nonce": "R2Rra24fVm5xa2Mg",  
	"apkPackageName": "com.package.name.of.requesting.app", 
	"apkCertificateDigestSha256": ["base64 encoded, SHA-256 hash of the certificate used to sign requesting app"],  
	"ctsProfileMatch": true,  
	"basicIntegrity": true,
}

nonce - nonce sent as part of the request. timestampMs - timestamp of the request. apkPackageName - package name of the APK that submitted this request. apkCertificateDigestSha256 - base-64 encoded representation of the SHA-256 hash of the calling app's signing certificate. ctsProfileMatch - if the value of ctsProfileMatch is true, then the profile of the device running your app matches the profile of a device that has passed android compatibility testing. basicIntegrity - true if the device has passed a basic integrity test, but the CTS profile could not be verified. A more lenient verdict of device integrity. If only the value of basicIntegrity is true, then the device running your app likely wasn't tampered with. advice - advice parameter provides information to help explain why the SafetyNet Attestation API set either ctsProfileMatch or basicIntegrity to false in a particular result.