New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sf-extension-utils

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sf-extension-utils - npm Package Compare versions

Comparing version

to
5.5.1

doc/getCombinedStyle.md

1

doc/fingerprint.md

@@ -57,2 +57,3 @@ <a name="module_fingerprint"></a>

| options.passwordTextBox | <code>UI.TextBox</code> | | to use textbox as password field (Required) |
| [options.force] | <code>boolean</code> | <code>false</code> | to force the fingerprint utility to be recreated. Recommended to use when textboxes are created from the code. |
| options.callback | <code>fingerprint:loginWithFingerprintCallback</code> | | is called when fingerprint login is called (Required) This callback is used to obtain password. When the login challege is successful it is important to call the success method of the fingerprintResult argument for the callback |

@@ -59,0 +60,0 @@ | [options.autoLogin] | <code>boolean</code> | <code>false</code> | to attempt fingerprint login after init. Takes effect after user gives permission and enables the setting |

46

doc/service-call.md

@@ -164,14 +164,15 @@ <a name="module_service-call"></a>

| Param | Type | Description |
| --- | --- | --- |
| endpointPath | <code>string</code> | Added to the end of the base url to form the url |
| options | <code>object</code> | Request specific options |
| method | <code>string</code> | HTTP method of this request |
| [options.body] | <code>object</code> | Request payload body. This object will be automatically stringified |
| [options.q] | <code>object</code> | Query string string object. Combines with the url |
| [options.query] | <code>object</code> | Alias for options.q |
| [options.headers] | <code>object</code> | Request specific headers. In conflict with configuration, those values are used |
| [options.logEnabled] | <code>boolean</code> | Request specific log option |
| [options.user] | <code>string</code> | Basic authentication user. Must be used with options.password |
| [options.password] | <code>string</code> | Basic authentication password. Must be used with options.user |
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| endpointPath | <code>string</code> | | Added to the end of the base url to form the url |
| options | <code>object</code> | | Request specific options |
| method | <code>string</code> | | HTTP method of this request |
| [options.body] | <code>object</code> | | Request payload body. This object will be automatically stringified |
| [options.q] | <code>object</code> | | Query string string object. Combines with the url |
| [options.query] | <code>object</code> | | Alias for options.q |
| [options.headers] | <code>object</code> | | Request specific headers. In conflict with configuration, those values are used |
| [options.logEnabled] | <code>boolean</code> | | Request specific log option |
| [options.user] | <code>string</code> | | Basic authentication user. Must be used with options.password |
| [options.password] | <code>string</code> | | Basic authentication password. Must be used with options.user |
| [options.fullResponse] | <code>boolean</code> | <code>false</code> | Resolved promise contains full response including `headers`, `body` and `status` |

@@ -253,12 +254,13 @@ **Example**

| Param | Type | Description |
| --- | --- | --- |
| options | <code>object</code> | Request specific options |
| options.method | <code>string</code> | HTTP method of this request |
| options.url | <code>string</code> | Full Http url |
| [options.body] | <code>object</code> | Request payload body. This object will be automatically stringified |
| [options.headers] | <code>object</code> | Full request headers |
| [options.logEnabled] | <code>boolean</code> | Request specific log option |
| [options.user] | <code>string</code> | Basic authentication user. Must be used with options.password |
| [options.password] | <code>string</code> | Basic authentication password. Must be used with options.user |
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| options | <code>object</code> | | Request specific options |
| options.method | <code>string</code> | | HTTP method of this request |
| options.url | <code>string</code> | | Full Http url |
| [options.body] | <code>object</code> | | Request payload body. This object will be automatically stringified |
| [options.headers] | <code>object</code> | | Full request headers |
| [options.logEnabled] | <code>boolean</code> | | Request specific log option |
| [options.user] | <code>string</code> | | Basic authentication user. Must be used with options.password |
| [options.password] | <code>string</code> | | Basic authentication password. Must be used with options.user |
| [options.fullResponse] | <code>boolean</code> | <code>false</code> | Resolved promise contains full response including `headers`, `body` and `status` |

@@ -265,0 +267,0 @@ **Example**

@@ -11,3 +11,3 @@ <a name="module_WebViewBridge"></a>

* [~WebViewBridge](#module_WebViewBridge..WebViewBridge) ⇐ <code>EventEmitter</code>
* [new WebViewBridge(options, [parseResponses], [bounceEnabled])](#new_module_WebViewBridge..WebViewBridge_new)
* [new WebViewBridge(options)](#new_module_WebViewBridge..WebViewBridge_new)
* [~webView](#module_WebViewBridge..webView)

@@ -33,3 +33,3 @@ * [~loadedScriptNames](#module_WebViewBridge..loadedScriptNames)

#### new WebViewBridge(options, [parseResponses], [bounceEnabled])
#### new WebViewBridge(options)
WebViewBridge is used for bi-directional communication with WebView. Events from WebView are captured with [EventEmiter](https://www.npmjs.com/package/wolfy87-eventemitter)<br />

@@ -54,4 +54,7 @@ This bridge creates window.**boubleEvent** function inside WebPage of the WebView<br />

| [options.source] | <code>string</code> \| <code>IO.File</code> | | source to inject bridge code |
| [parseResponses] | <code>boolean</code> | <code>false</code> | when false, the WebView.evaluateJS runs faster without parsing the executed JS code response |
| [bounceEnabled] | <code>boolean</code> | <code>false</code> | when false bounce effect of the WebView is disabled |
| [options.parseResponses] | <code>boolean</code> | <code>false</code> | when false, the WebView.evaluateJS runs faster without parsing the executed JS code response |
| [options.bounceEnabled] | <code>boolean</code> | <code>false</code> | when false bounce effect of the WebView is disabled |
| [options.skipLoadEvents] | <code>boolean</code> | <code>false</code> | skips onLoad auto-bouble events. Might be useful to set true when there are redirections on page |
| [options.skipBoubleEvent] | <code>boolean</code> | <code>false</code> | skips injection of boubleEvent on each page. Might be useful when there are redirections on page |
| [options.delay] | <code>number</code> | <code>0</code> | sets delay between injection of boubleEvent and page show |

@@ -58,0 +61,0 @@ **Example**

@@ -36,4 +36,5 @@ /**

const newEvent = args.shift();
oldEvent && oldEvent.apply(target, args);
return newEvent.apply(target, args);
const oldReturnValue = oldEvent && oldEvent.apply(target, args);
const newReturnValue = newEvent.apply(target, args);
return typeof newReturnValue === "undefined"? oldReturnValue: newReturnValue;
}

@@ -71,2 +71,3 @@ /**

* @param {UI.TextBox} options.passwordTextBox to use textbox as password field (Required)
* @param {boolean} [options.force = false] to force the fingerprint utility to be recreated. Recommended to use when textboxes are created from the code.
* @param {fingerprint:loginWithFingerprintCallback} options.callback is called when fingerprint login is called (Required) This callback is used to obtain password. When the login challege is successful it is important to call the success method of the fingerprintResult argument for the callback

@@ -134,3 +135,3 @@ * @param {boolean} [options.autoLogin = false] to attempt fingerprint login after init. Takes effect after user gives permission and enables the setting

function init(options) {
if (isConfigured)
if (isConfigured && !options.force)
return;

@@ -137,0 +138,0 @@ // expect(options).to.be.an("object");

@@ -85,12 +85,11 @@ /**

const showNavigationMenuForAndroid = function({ page, transportType = "d", location }) {
const showNavigationMenuForAndroid = function({ transportType = "d", location }) {
return new Promise((resolve, reject) => {
Application.call(
`geo:${location.latitude},${location.longitude}?q=${location.latitude},${location.longitude}&mode=${transportType}`,
null,
() => resolve("App selector opened"),
() => reject("Couldn't launch the selector"),
let { latitude, longitude } = location;
Application.call(`geo:${latitude},${longitude}?q=${latitude},${longitude}&mode=${transportType}`,
"",
(e) => resolve(e),
(e) => reject(e),
true,
global.lang.chooseNavigationApp || "Choose Navigation App" // Chooser title
);
global.lang.chooseNavigationApp || "Choose Navigation App");
});

@@ -97,0 +96,0 @@ };

@@ -27,2 +27,4 @@ /**

const getHttp = createAsyncGetter(() => new Http());
const reParseBodyAsText = /(?:application\/(?:x-csh|json|javascript|rtf|xml)|text\/.*|.*\/.*(:?\+xml|xml\+).*)/i;
const reJSON = /^application\/json/i;

@@ -187,2 +189,3 @@ /**

* @param {string} [options.password] - Basic authentication password. Must be used with options.user
* @param {boolean} [options.fullResponse=false] - Resolved promise contains full response including `headers`, `body` and `status`
* @returns {object} http request object

@@ -265,2 +268,3 @@ * @example

* @param {string} [options.password] - Basic authentication password. Must be used with options.user
* @param {boolean} [options.fullResponse=false] - Resolved promise contains full response including `headers`, `body` and `status`
* @returns {Promise}

@@ -285,2 +289,4 @@ * @example

static request(options) {
options = Object.assign({}, options);
let { fullResponse = false } = options;
let query = options.q || options.query;

@@ -302,5 +308,5 @@ options.url = String(options.url);

if (response.body.success === false)
reject(response.body);
reject(fullResponse ? response : response.body);
else
resolve(response.body);
resolve(fullResponse ? response : response.body);
}

@@ -357,18 +363,20 @@ catch (ex) {

const contentType = (response.headers && getContentType(response.headers)) || "";
switch (true) {
case !contentType.startsWith("image"):
response.body = response.body.toString();
reJSON.lastIndex = reParseBodyAsText.lastIndex = 0;
if (reParseBodyAsText.test(contentType))
response.body = response.body.toString();
case contentType === "application/json":
try {
response.body = JSON.parse(response.body);
response.logEnabled && console.log("Response body", response.body);
}
catch (ex) {
response.logEnabled && console.log("Response is not a JSON\nResponse Body", response.body);
}
break;
if (reJSON.test(contentType)) {
try {
response.body = JSON.parse(response.body);
response.logEnabled && console.log("Response body ", response.body);
}
catch (ex) {
response.logEnabled && console.log("Response is not a JSON\nResponse Body ", response.body);
}
}
if (response.logEnabled && typeof response.body === "string")
console.log("Response body (non-json) ", response.body);
}
const getContentType = (headers = {}) => {

@@ -375,0 +383,0 @@ let contentType = headers["Content-Type"];

@@ -38,4 +38,7 @@ /*globals SF, requireClass */

* @param {string|IO.File} [options.source] - source to inject bridge code
* @param {boolean} [parseResponses = false] - when false, the WebView.evaluateJS runs faster without parsing the executed JS code response
* @param {boolean} [bounceEnabled = false] - when false bounce effect of the WebView is disabled
* @param {boolean} [options.parseResponses = false] - when false, the WebView.evaluateJS runs faster without parsing the executed JS code response
* @param {boolean} [options.bounceEnabled = false] - when false bounce effect of the WebView is disabled
* @param {boolean} [options.skipLoadEvents = false] - skips onLoad auto-bouble events. Might be useful to set true when there are redirections on page
* @param {boolean} [options.skipBoubleEvent = false] - skips injection of boubleEvent on each page. Might be useful when there are redirections on page
* @param {number} [options.delay = 0] - sets delay between injection of boubleEvent and page show
* @example

@@ -201,2 +204,4 @@ * //Bridge Creation with AM-Charts

webView.bounceEnabled = !!options.bounceEnabled;
var skipLoadEvents = options.skipLoadEvents || false;
var skipBoubleEvent = options.skipBoubleEvent || false;

@@ -387,3 +392,3 @@

return;
insertScript.call(me, me.scheme, code);
!skipBoubleEvent && insertScript.call(me, me.scheme, code, !!skipLoadEvents);
me.emit("show", event);

@@ -456,2 +461,14 @@ }.bind(global, lastURL), delay);

javascript = `(function(){\n${javascript}\n})();null;`;
if (onReceive) {
let originalReceiveFunction = onReceive;
onReceive = result => {
if (System.OS === "Android" && result && this.parseResponses) {
try {
result = JSON.parse(result);
}
catch (ex) {}
}
originalReceiveFunction(result);
};
}
return this.webView.evaluateJS(javascript, onReceive);

@@ -485,4 +502,4 @@ }

const me = this;
const script = `(function (scheme, code) {
if(window.boubleEvent) {
const script = `(function (scheme, code, skipLoadEvents) {
if(window.boubleEvent && !skipLoadEvents) {
window.boubleEvent("bridge.duplicateLoad", {code: code});

@@ -549,6 +566,6 @@ return;

window.onload = function() {
window.boubleEvent("window.onload", { code: code });
!skipLoadEvents && window.boubleEvent("window.onload", { code: code });
};
} else
window.boubleEvent("window.onload", { code: code });
!skipLoadEvents && window.boubleEvent("window.onload", { code: code });
})("${scheme}", ${code})`;

@@ -555,0 +572,0 @@

{
"name": "sf-extension-utils",
"version": "5.2.0",
"version": "5.5.1",
"description": "Utils Extension for Smartface Native Framework",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -20,2 +20,6 @@ # Utility Extension from Smartface

- TextBox (max text length)
- Copy (creates a shallow copy of an object)
- Router (with buildExtender, page management made easy)
- Guid (creates uuid-v4 text)
- getCombinedStyle (gets style object from theme class)

@@ -22,0 +26,0 @@ ## Installation