Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tiv-kampala/compass-cordova-android-utils-plugin
Cordova plugin for use in encrypting and decrypting BridgeRA request & response payloads
https://github.com/tiv-kampala/compass-cordova-android-utils-plugin
aes android bridgera cordova rsa
Last synced: 19 days ago
JSON representation
Cordova plugin for use in encrypting and decrypting BridgeRA request & response payloads
- Host: GitHub
- URL: https://github.com/tiv-kampala/compass-cordova-android-utils-plugin
- Owner: TIV-kampala
- Created: 2024-10-17T15:43:14.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-10-21T07:15:32.000Z (2 months ago)
- Last Synced: 2024-10-21T10:17:24.321Z (2 months ago)
- Topics: aes, android, bridgera, cordova, rsa
- Language: Kotlin
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
---
title: AndroidUtils
description: Generate RSA keys, save data to android SharedPreferences, encrypt & decrypt bridge RA request and response
---# compass-cordova-android-utils-plugin
This plugin defines a global `AndroidUtils` object, which exposes native methods.
Although the object is in the global scope, it is not available until after the `deviceready` event.```js
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(AndroidUtils.generateRsaKeyPair());
}
```## Installation - Cordova
npx cordova plugin add https://github.com/TIV-kampala/compass-cordova-android-utils-plugin
## Installation - Capacitor
Reference: https://capacitorjs.com/docs/plugins/cordovanpm install https://github.com/TIV-kampala/compass-cordova-android-utils-plugin
npx cap sync
## Supported Platforms
- Android (cordova >=10.0.0, cordova android version >=9.0.0)
- These plugin has been tested with below configurations
- MIN_SDK_VERSION (24)
- SDK_VERSION (34)
- MIN_BUILD_TOOLS_VERSION (34)
- GRADLE_VERSION (8.7)
- JAVA_TARGET_COMPATIBILITY (8)
- JAVA_SOURCE_COMPATIBILITY (8)
- KOTLIN_VERSION (1.9.24)## Methods
- AndroidUtils.generateRsaKeyPair()
- AndroidUtils.generateAesKey()
- AndroidUtils.saveStringData()
- AndroidUtils.saveBoolData()
- AndroidUtils.getStringData()
- AndroidUtils.getBoolData()
- AndroidUtils.clearData()
- AndroidUtils.prepareRequestPayload()
- AndroidUtils.parseResponsePayload()## AndroidUtils.generateRsaKeyPair()
Generates a pair of RSA keys: a private key stored securely in the Android KeyStore and a public key returned as a base64 string.
Returns a promise which resolves to an object containing the public key in base64 format.## AndroidUtils.generateAesKey()
Generates an AES key for encryption, which is securely stored in the Android KeyStore.
Returns a promise which resolves to an object containing the aes key in base64 format.## AndroidUtils.saveStringData(key: string, value: string)
Saves a string value to the device's SharedPreferences.
Returns a promise which resolves to an object containing a `success` boolean value i.e `{success: true}`.## AndroidUtils.saveBoolData(key: string, value: boolean)
Saves a boolean value to the device's SharedPreferences.
Returns a promise which resolves to an object containing a `success` boolean value i.e `{success: true}`.## AndroidUtils.getStringData(key: string)
Retrieves a string value from the device's SharedPreferences.
Returns a promise which resolves to an object containing the data.## AndroidUtils.getBoolData(key: string)
Retrieves a boolean value from the device's SharedPreferences.
Returns a promise which resolves to an object containing the data.## AndroidUtils.clearData(key: string)
Clears a value from the device's SharedPreferences.
Returns a promise which resolves to an object containing a `success` boolean value i.e `{success: true}`## AndroidUtils.prepareRequestPayload(cmtJson: string, bridgeRAEncPublicKey: string)
Handles encryption of the CMT request payload using the bridgeRAEncPublicKey.
Returns a promise which resolves with a base64 encrypted request payload string.## AndroidUtils.parseResponsePayload(encryptedResponsePayload: string)
Handles decryption of the base64 encrypted CMT response payload string.
Returns a promise which resolves with a decrypted response payload json string.