forked from Crypho/cordova-plugin-secure-storage
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RMET-3408 KeyStore Plugin - Prepare release of version
2.6.8-OS19
(#29
) * RMET-3408 KeyStore Plugin - Set auth prompt text (title, subtitle, and negative button) (#28) * feat: get biometric prompt info from strings.xml and pass them to library References: https://outsystemsrd.atlassian.net/browse/RMET-3408 * feat: copy biometric prompt info to strings.xml in hook References: * feat: check of biometric prompt info is not empty References: https://outsystemsrd.atlassian.net/browse/RMET-3408 * fix: properly use getPreference method, passing in the platform (android) References: https://outsystemsrd.atlassian.net/browse/RMET-3408 * refactor: use const instead of var References: https://outsystemsrd.atlassian.net/browse/RMET-3408 * chore: update dependency to OSKeystoreLib-Android References: https://outsystemsrd.atlassian.net/browse/RMET-3408 * fix: add dependency to xmldom References: https://outsystemsrd.atlassian.net/browse/RMET-3408 * fix: create DOMParser() instance References: https://outsystemsrd.atlassian.net/browse/RMET-3408 * fix: get android preferences properly References: https://outsystemsrd.atlassian.net/browse/RMET-3408 * refactor: remove unused code References: https://outsystemsrd.atlassian.net/browse/RMET-3408 * chore: update changelog References: https://outsystemsrd.atlassian.net/browse/RMET-3408 * revert: revert change in previous commit References: https://outsystemsrd.atlassian.net/browse/RMET-3408 * chore: raise to version 2.6.8-OS19 References: https://outsystemsrd.atlassian.net/browse/RMET-3408 * chore: update dependency to OSKeystoreLib-Android References: https://outsystemsrd.atlassian.net/browse/RMET-3408 * fix: properly check if field is empty string References: https://outsystemsrd.atlassian.net/browse/RMET-3408 * misc: set version to an existing one References: https://outsystemsrd.atlassian.net/browse/RMET-3408 * chore: update dependency to OSKeystoreAndroid-Lib References: https://outsystemsrd.atlassian.net/browse/RMET-3408
- Loading branch information
1 parent
b22c283
commit f3b03e0
Showing
6 changed files
with
77 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,58 @@ | ||
const et = require('elementtree'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const { ConfigParser } = require('cordova-common'); | ||
const { DOMParser, XMLSerializer } = require('xmldom'); | ||
|
||
module.exports = function (context) { | ||
var projectRoot = context.opts.cordova.project ? context.opts.cordova.project.root : context.opts.projectRoot; | ||
var configXML = path.join(projectRoot, 'config.xml'); | ||
var configParser = new ConfigParser(configXML); | ||
var authenticate = configParser.getGlobalPreference("MigratedKeysAuthentication"); | ||
const projectRoot = context.opts.cordova.project ? context.opts.cordova.project.root : context.opts.projectRoot; | ||
const configXML = path.join(projectRoot, 'config.xml'); | ||
const configParser = new ConfigParser(configXML); | ||
const parser = new DOMParser(); | ||
|
||
const authenticate = configParser.getGlobalPreference('MigratedKeysAuthentication'); | ||
const auth_prompt_title = configParser.getPreference('AuthPromptTitle', 'android') | ||
const auth_prompt_subtitle = configParser.getPreference('AuthPromptSubtitle', 'android') | ||
const auth_prompt_negative_button = configParser.getPreference('AuthPromptCancelButton', 'android') | ||
|
||
const stringsXmlPath = path.join(projectRoot, 'platforms/android/app/src/main/res/values/strings.xml'); | ||
const stringsXmlString = fs.readFileSync(stringsXmlPath, 'utf-8'); | ||
const stringsXmlDoc = parser.parseFromString(stringsXmlString, 'text/xml') | ||
|
||
if(authenticate == "true"){ | ||
var stringsXmlPath = path.join(projectRoot, 'platforms/android/app/src/main/res/values/strings.xml'); | ||
var stringsXmlContents = fs.readFileSync(stringsXmlPath).toString(); | ||
var etreeStrings = et.parse(stringsXmlContents); | ||
// insert bool value in strings.xml | ||
const booleanElements = stringsXmlDoc.getElementsByTagName('bool'); | ||
|
||
var migrationAuthTags = etreeStrings.findall('./bool[@name="migration_auth"]'); | ||
for (var i = 0; i < migrationAuthTags.length; i++) { | ||
migrationAuthTags[i].text = authenticate; | ||
// set text for each <bool> element | ||
for (let i = 0; i < booleanElements.length; i++) { | ||
const name = booleanElements[i].getAttribute('name'); | ||
if (name == "migration_auth") { | ||
booleanElements[i].textContent = authenticate; | ||
} | ||
} | ||
} | ||
|
||
var resultXmlStrings = etreeStrings.write(); | ||
fs.writeFileSync(stringsXmlPath, resultXmlStrings); | ||
// insert string values in strings.xml | ||
const stringElements = stringsXmlDoc.getElementsByTagName('string'); | ||
|
||
// set text for each <string> element | ||
for (let i = 0; i < stringElements.length; i++) { | ||
const name = stringElements[i].getAttribute('name'); | ||
if (name == "biometric_prompt_title" && auth_prompt_title != "") { | ||
stringElements[i].textContent = auth_prompt_title; | ||
} | ||
else if (name == "biometric_prompt_subtitle" && auth_prompt_subtitle != "") { | ||
stringElements[i].textContent = auth_prompt_subtitle; | ||
} | ||
else if (name == "biometric_prompt_negative_button" && auth_prompt_negative_button != "") { | ||
stringElements[i].textContent = auth_prompt_negative_button; | ||
} | ||
} | ||
|
||
// serialize the updated XML document back to string | ||
const serializer = new XMLSerializer(); | ||
const updatedXmlString = serializer.serializeToString(stringsXmlDoc); | ||
|
||
// write the updated XML string back to the same file | ||
fs.writeFileSync(stringsXmlPath, updatedXmlString, 'utf-8'); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "cordova-plugin-secure-storage", | ||
"version": "2.6.8-OS18", | ||
"version": "2.6.8-OS19", | ||
"description": "Secure storage plugin for iOS & Android", | ||
"author": "Yiorgis Gozadinos <[email protected]>", | ||
"contributors": [ | ||
|
@@ -50,5 +50,8 @@ | |
"bugs": { | ||
"url": "https://github.com/crypho/cordova-plugin-secure-storage/issues" | ||
}, | ||
"homepage": "https://github.com/crypho/cordova-plugin-secure-storage#readme" | ||
"homepage": "https://github.com/crypho/cordova-plugin-secure-storage#readme", | ||
"dependencies": { | ||
"xmldom": "^0.6.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters