utils

Methods

(static) areOwnPropertiesEqual(a, b) → {null|boolean}

Source:

Compares two objects by shallow properties.

Parameters:
Name Type Description
a object

First object to be compared

b object

Second object to be compared

Returns:

Whether objects are equal (null for invalid arguments)

Type
null | boolean

(static) cleanUrl(url) → {string}

Source:

Cleans a Server URL so it becomes useful as a db key It strips the protocol, removes a trailing slash, removes www, and converts to lowercase

Parameters:
Name Type Description
url string

Url to be cleaned up

Returns:

Cleaned up url

Type
string

(static) getOpenRosaKey(survey, prefixopt) → {string|null}

Source:

Returns a unique, predictable openRosaKey from a survey oject

Parameters:
Name Type Attributes Description
survey module:survey-model~SurveyObject

survey object

prefix string <optional>

prefix

Returns:

openRosaKey

Type
string | null

(static) getXformsManifestHash(manifest, type) → {string}

Source:

Returns a XForm manifest hash.

Parameters:
Name Type Description
manifest Array

hash of XForm manifest

type string

Webform type

Returns:

Hash

Type
string

(static) insecureAes192Decrypt(encrypted, pw) → {string}

Source:

Decrypts encrypted text.

Parameters:
Name Type Description
encrypted object

The text to be decrypted

pw object

The password to use for decryption

Returns:

The decrypted result

Type
string

(static) insecureAes192Encrypt(text, pw) → {string}

Source:

This is not secure encryption as it doesn't use a random cipher. Therefore the result is always the same for each text & pw (which is desirable in this case). This means the password is vulnerable to be cracked, and we should use a dedicated low-importance password for this.

Parameters:
Name Type Description
text string

The text to be encrypted

pw string

The password to use for encryption

Returns:

The encrypted result

Type
string

(static) isValidUrl(url) → {boolean}

Source:

The name of this function is deceiving. It checks for a valid server URL and therefore doesn't approve of:

  • fragment identifiers
  • query strings
Parameters:
Name Type Description
url string

Url to be validated

Returns:

Whether the url is valid

Type
boolean

(static) md5(message) → {string}

Source:

Returns md5 hash of given message

Parameters:
Name Type Description
message string

Message to be hashed

Returns:

Hash string

Type
string

(static) pickRandomItemFromArray(array) → {*|null}

Source:

Returns random item from array.

Parameters:
Name Type Description
array Array

Target array

Returns:

Random array item

Type
* | null

(static) randomString(howManyopt, charsopt) → {string}

Source:

Returns random howMany-lengthed string from provided characters.

Parameters:
Name Type Attributes Default Description
howMany number <optional>
8

Desired length of string

chars string <optional>
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789

Characters to use

Returns:

Random string

Type
string

(inner) _getKeyIv(pw)

Source:

Not secure, but used for backward compatibility with deprecated crypto.createCipher It's okay to use for this purpose.

Parameters:
Name Type Description
pw string

password