crdtes

crdtes

Creative Developer Tools (CRDT) is a growing suite of tools aimed at script developers and plug-in developers for the Adobe Creative Cloud eco-system.

Currently, it is at an alpha stage: the feature set is not frozen, and new features are added regularly.

There are two different versions of CRDT: one for UXP/UXPScript and another for ExtendScript.

The software is functional and useful, but without a doubt, there will be bugs and dragons…

Features include:

- Provides a unique machine GUID for each end-user computer
- Provides a unique account GUID for each end user
- Add licensing and activation features to your script
- Protect sensitive source code and make it hard to reverse engineer
- AES-256 encryption/decryption functions
- Base64 encode and decode functions

More to come! You can contact us on dev@rorohiko.com with feature request

For downloading and installation info, visit

https://CreativeDeveloperTools.com
Source:

Members

(static) UNIT_NAME_CICERO

crdtes.UNIT_NAME_CICERO for ciceros
Source:

(static) UNIT_NAME_CM

crdtes.UNIT_NAME_CM for centimeters
Source:

(static) UNIT_NAME_INCH

crdtes.UNIT_NAME_INCH for inches.
Source:

(static) UNIT_NAME_MM

crdtes.UNIT_NAME_MM for millimeters
Source:

(static) UNIT_NAME_NONE

crdtes.UNIT_NAME_NONE represents unit-less values.
Source:

(static) UNIT_NAME_PICA

crdtes.UNIT_NAME_PICA for picas
Source:

(static) UNIT_NAME_PIXEL

crdtes.UNIT_NAME_PIXEL for pixels
Source:

(static) UNIT_NAME_POINT

crdtes.UNIT_NAME_POINT for points
Source:

Methods

(static) base64decode(base64Str) → {string}

Decode a string that was encoded using base64.
Source:
Parameters:
Name Type Description
base64Str string base64 encoded string
Returns:
Type:
string
decoded string

(static) base64encode(str_or_ByteArr) → {string}

Encode a string or an array of bytes using Base 64 encoding.
Source:
Parameters:
Name Type Description
str_or_ByteArr string either a string or an array containing bytes (0-255).
Returns:
Type:
string
encoded string

(static) binaryToStr(in_byteArray) → {string}

Convert an array of bytes into string format. This string is UTF-16 internally, and
we map one byte to one UTF-16 character. The resulting string might contain character values
(charCodeAt()) that would be invalid in UTF8.
Source:
Parameters:
Name Type Description
in_byteArray array an array containing UTF-16 values in the range 0-255
Returns:
Type:
string
a string

(static) binaryUTF8ToStr(in_byteArray) → {string}

Decode an array of bytes that contains a UTF-8 encoded string.
Source:
Parameters:
Name Type Description
in_byteArray array an array containing bytes (0-255) for a string that was encoded using UTF-8 encoding.
Returns:
Type:
string
a string, or undefined if some invalid UTF-8 is encountered

(static) configLogger(logInfo) → {boolean}

Configure the logger
Source:
Parameters:
Name Type Description
logInfo object object with logger setup info{
logLevel: 0-4
logEntryExit: boolean
logToESTKConsole: boolean
logToCRDT: boolean
logToFilePath: undefined or a file path for logging
}
Returns:
Type:
boolean
success/failure

(static) dQ(str_or_ByteArr) → {string}

Wrap a string or a byte array into double quotes, encoding any binary data as a string.
Knows how to handle Unicode characters or binary zeroes.

When the input is a string, high Unicode characters are encoded as `\uHHHH`.

When the input is a byte array, all bytes are encoded as characters or as `\xHH` escape sequences.
Source:
Parameters:
Name Type Description
str_or_ByteArr string a Unicode string or an array of bytes
Returns:
Type:
string
a string enclosed in double quotes. This string is pure 7-bit
ASCII and can be inserted into generated script code
Example:
var script = "a=b(" + crdtes.dQ(somedata) + ");";

(static) deQuote(quotedString) → {array}

Reverse the operation of crdtes.dQ() or crdtes.sQ().
Source:
Parameters:
Name Type Description
quotedString string a quoted string
Returns:
Type:
array
a byte array. If the quoted string contains any \uHHHH codes, these are first re-encoded
using UTF-8 before storing them into the byte array.

(static) decrypt(str_or_ByteArr, aesKey) → {array}

Reverse the operation of the crdtes.encrypt() function. Only available to paid developer accounts
Source:
Parameters:
Name Type Description
str_or_ByteArr string a string or an array of bytes
aesKey string a string or an array of bytes
Returns:
Type:
array
an array of bytes

(static) dirCreate(filePath) → {array}

Create a directory.

Not restricted by the UXP security sandbox. Not needed for pure ExtendScript -
provided to offer some compatibility with the UXP version of CRDT
Source:
Parameters:
Name Type Description
filePath string
Returns:
Type:
array
list if items in directory

(static) dirDelete(filePath, recurse) → {boolean}

Delete a directory.

Not restricted by the UXP security sandbox. Not needed for pure ExtendScript -
provided to offer some compatibility with the UXP version of CRDT
Source:
Parameters:
Name Type Description
filePath string
recurse boolean
Returns:
Type:
boolean
success or failure

(static) dirExists(dirPath) → {boolean}

Verify whether a directory exists. Will return false if the path points to a file (instead of a directory).

Also see crdtes.fileExists().

Not restricted by the UXP security sandbox. Not needed for pure ExtendScript -
provided to offer some compatibility with the UXP version of CRDT
Source:
Parameters:
Name Type Description
dirPath string a path to a directory
Returns:
Type:
boolean
true or false

(static) dirScan(filePath) → {array}

Scan a directory.

Not restricted by the UXP security sandbox. Not needed for pure ExtendScript -
provided to offer some compatibility with the UXP version of CRDT
Source:
Parameters:
Name Type Description
filePath string
Returns:
Type:
array
list if items in directory

(static) encrypt(str_or_ByteArr, aesKey) → {string}

Encrypt a string or array of bytes using a key. A random salt is added into the mix,
so even when passing in the same parameter values, the result will be different every time.

Only available to paid developer accounts
Source:
Parameters:
Name Type Description
str_or_ByteArr string a string or an array of bytes
aesKey string a string or an array of bytes
Returns:
Type:
string
a base-64 encoded encrypted string.

(static) evalScript(scriptName, parentScriptFile) → {any}

Evaluate a script file. If the unencrypted script file is not available (`.jsx` or `.js`),
use crdtesDLL to try and run an `.ejsx` or `.ejs` file.
Source:
Parameters:
Name Type Description
scriptName string the name of the script to run, without file name extension or parent directory
parentScriptFile string the name of the script from which we're calling this (pass in $.fileName).
If this is missing, evaluate the path relative to the parent of CreativeDeveloperTools_ES
Returns:
Type:
any
the returned value

(static) evalTQL(tqlScript, tqlScopeName) → {any}

Send a TQL script to the DLL
Source:
Parameters:
Name Type Description
tqlScript string a script to run
tqlScopeName string a scope name to use. Such scope can be used to pass data between different processes
Returns:
Type:
any
the returned value

(static) fileClose(fileHandle) → {boolean}

Close a currently open file.

Not restricted by the UXP security sandbox. Not needed for pure ExtendScript -
provided to offer some compatibility with the UXP version of CRDT
Source:
Parameters:
Name Type Description
fileHandle number a file handle as returned by crdtes.fileOpen().
Returns:
Type:
boolean
success or failure

(static) fileDelete(filePath) → {boolean}

Delete a file

Not restricted by the UXP security sandbox. Not needed for pure ExtendScript -
provided to offer some compatibility with the UXP version of CRDT
Source:
Parameters:
Name Type Description
filePath string
Returns:
Type:
boolean
success or failure

(static) fileExists(filePath) → {boolean}

Check if a file exists. Will return false if the file path points to a directory.

Also see crdtes.dirExists().

Not restricted by the UXP security sandbox. Not needed for pure ExtendScript -
provided to offer some compatibility with the UXP version of CRDT
Source:
Parameters:
Name Type Description
filePath string
Returns:
Type:
boolean
existence of file

(static) fileOpen(fileName, mode) → {number}

Open a binary file and return a handle.

Not restricted by the UXP security sandbox. Not needed for pure ExtendScript -
provided to offer some compatibility with the UXP version of CRDT
Source:
Parameters:
Name Type Description
fileName string a native full file path to the file
mode string one of 'a', 'r', 'w' (append, read, write)
Returns:
Type:
number
file handle

(static) fileRead(fileHandle, isBinary) → {any}

Read a file into memory

Not restricted by the UXP security sandbox. Not needed for pure ExtendScript -
provided to offer some compatibility with the UXP version of CRDT
Source:
Parameters:
Name Type Description
fileHandle number a file handle as returned by crdtes.fileOpen().
isBinary boolean whether the file is considered a binary file (as opposed to a UTF-8 text file)
Returns:
Type:
any
either a byte array or a string

(static) fileWrite(fileHandle, str_or_ByteArr) → {boolean}

Binary write to a file. Strings are written as UTF-8

Not restricted by the UXP security sandbox. Not needed for pure ExtendScript -
provided to offer some compatibility with the UXP version of CRDT
Source:
Parameters:
Name Type Description
fileHandle number a file handle as returned by crdtes.fileOpen().
str_or_ByteArr string data to write to the file
Returns:
Type:
boolean
success or failure

(static) functionNameFromArguments(functionArguments) → {string}

Extract the function name from its arguments
Source:
Parameters:
Name Type Description
functionArguments object pass in the current arguments to the function.
This is used to determine the function's name
Returns:
Type:
string
function name

(static) getBooleanFromINI(in_value) → {boolean}

Interpret a value extracted from some INI data as a boolean. Things like y, n, yes, no, true, false, t, f, 0, 1
Source:
Parameters:
Name Type Description
in_value string ini value
Returns:
Type:
boolean
value

(static) getCapability(issuer, capabilityCode, encryptionKey) → {string}

Determine whether, or which, features of some software or module are currently activated or not
Source:
Parameters:
Name Type Description
issuer string a GUID identifier for the developer account as seen in the PluginInstaller
capabilityCode string a code for the software features to be activated (as determined by
the developer who owns the account).
capabilityCode is not the same as orderProductCode - there can be multiple orderProductCode associated with a single capabilityCode (e.g. capabilityCode: 'XYZ', orderProductCode: 'XYZ_1YEAR', 'XYZ_2YEAR'...).
encryptionKey string the secret encryption key (created by the developer) needed to decode
the capability data. As a developer you want to make sure this encryptionKey is obfuscated and only contained
within encrypted script code.
Returns:
Type:
string
either "NOT_ACTIVATED" or a JSON structure with capability data (customer GUID, decrypted developer-provided data from the activation file).

(static) getCreativeDeveloperToolsLevel() → {number}

Determine the license level for CRDT: 0 = not, 1 = basic, 2 = full

Some functions, marked with "Only available to paid developer accounts"
will only work with level 2. Licensing function only work with level 1
Source:
Returns:
Type:
number
0, 1 or 2

(static) getDir(dirTag) → {string}

Get the path of a system directory

Not restricted by the UXP security sandbox. Not needed for pure ExtendScript -
provided to offer some compatibility with the UXP version of CRDT
Source:
Parameters:
Name Type Description
dirTag string a tag representing the dir:

crdtes.DESKTOP_DIR
crdtes.DOCUMENTS_DIR
crdtes.HOME_DIR
crdtes.LOG_DIR
crdtes.SYSTEMDATA_DIR
crdtes.TMP_DIR
crdtes.USERDATA_DIR
Returns:
Type:
string
file path of dir or undefined. Directory paths include a trailing slash or backslash

(static) getEnvironment(envVarName) → {string}

Access the environment

Not restricted by the UXP security sandbox. Not needed for pure ExtendScript -
provided to offer some compatibility with the UXP version of CRDT
Source:
Parameters:
Name Type Description
envVarName string name of environment variable
Returns:
Type:
string
environment variable value

(static) getFloatValuesFromINI(in_valueStr) → {array}

Interpret a string extracted from some INI data as an array with float values (e.g. "[ 255, 128.2, 1.7]" )
Source:
Parameters:
Name Type Description
in_valueStr string ini value
Returns:
Type:
array
array of numbers or undefined

(static) getFloatWithUnitFromINI(in_valueStr, in_convertToUnit) → {number}

Interpret a string extracted from some INI data as a floating point value, followed by an optional unit
If there is no unit, then no conversion is performed.
Source:
Parameters:
Name Type Description
in_valueStr string ini value
in_convertToUnit string unit to convert to
Returns:
Type:
number
value

(static) getIntValuesFromINI(in_valueStr) → {array}

Interpret a string extracted from some INI data as an array with int values (e.g. "[ 255, 128, 1]" )
Source:
Parameters:
Name Type Description
in_valueStr string ini value
Returns:
Type:
array
array of ints or undefined

(static) getPersistData(issuer, attribute, password) → {string}

Fetch some persistent data Only available to paid developer accounts
Source:
Parameters:
Name Type Description
issuer string a GUID identifier for the developer account as seen in the PluginInstaller
attribute string an attribute name for the data
password string the password (created by the developer) needed to decode the persistent data
Returns:
Type:
string
whatever persistent data is stored for the given attribute

(static) getPluginInstallerPath() → {string}

Get file path to PluginInstaller if it is installed
Source:
Returns:
Type:
string
file path

(static) getUnitFromINI(in_value, in_defaultUnit) → {string}

Interpret a string extracted from some INI data as a unit name
Source:
Parameters:
Name Type Description
in_value string ini value
in_defaultUnit string default to use if no match is found
Returns:
Type:
string
value

(static) intPow(i, intPower) → {number}

Calculate an integer power of an int value. Avoids using floating point, so
should not have any floating-point round-off errors. `Math.pow()` will probably
give the exact same result, but I am doubtful that some implementations might internally use `log` and `exp`
to handle `Math.pow()`
Source:
Parameters:
Name Type Description
i number Integer base
intPower number integer power
Returns:
Type:
number
i ^ intPower

(static) leftPad(s, padChar, len) → {string}

Extend or shorten a string to an exact length, adding padChar as needed
Source:
Parameters:
Name Type Description
s string string to be extended or shortened
padChar string string to append repeatedly if length needs to extended
len number desired result length
Returns:
Type:
string
padded or shortened string

(static) logEntry(reportingFunctionArguments)

Make a log entry of the call of a function. Pass in the arguments keyword as a parameter.
Source:
Parameters:
Name Type Description
reportingFunctionArguments array pass in the current arguments to the function.
This is used to determine the function's name for the log

(static) logError(reportingFunctionArguments, message)

Make a log entry of an error message. Pass in the arguments keyword as the first parameter.
If the error level is below crdtes.LOG_LEVEL_ERROR nothing happens
Source:
Parameters:
Name Type Description
reportingFunctionArguments array pass in the current arguments to the function.
This is used to determine the function's name for the log
message string error message

(static) logExit(reportingFunctionArguments)

Make a log entry of the exit of a function. Pass in the arguments keyword as a parameter.
Source:
Parameters:
Name Type Description
reportingFunctionArguments array pass in the current arguments to the function.
This is used to determine the function's name for the log

(static) logMessage(reportingFunctionArguments, logLevel, message)

Output a log message. Pass in the arguments keyword as the first parameter.
Source:
Parameters:
Name Type Description
reportingFunctionArguments array pass in the current arguments to the function.
This is used to determine the function's name for the log
logLevel number log level
message string the note to output

(static) logNote(reportingFunctionArguments, message)

Make a log entry of a note. Pass in the arguments keyword as the first parameter.
If the error level is below crdtes.LOG_LEVEL_NOTE nothing happens
Source:
Parameters:
Name Type Description
reportingFunctionArguments array pass in the current arguments to the function.
This is used to determine the function's name for the log
message string the note to output

(static) logTrace(reportingFunctionArguments, message)

Emit a trace messsage into the log. Pass in the arguments keyword as the first parameter.
If the error level is below crdtes.LOG_LEVEL_TRACE nothing happens
Source:
Parameters:
Name Type Description
reportingFunctionArguments array pass in the current arguments to the function.
This is used to determine the function's name for the log
message string the trace message to output

(static) logWarning(arguments, message)

Emit a warning messsage into the log. Pass in the arguments keyword as the first parameter.
If the error level is below crdtes.LOG_LEVEL_WARNING nothing happens
Source:
Parameters:
Name Type Description
arguments array pass in the current arguments to the function.
This is used to determine the function's name for the log
message string the warning message to output

(static) machineGUID() → {string}

The unique GUID of this computer

Only available to paid developer accounts
Source:
Returns:
Type:
string
a GUID string

(static) pluginInstaller() → {boolean}

Attempt to launch the PluginInstaller if it is installed
Source:
Returns:
Type:
boolean
success or failure

(static) popLogLevel() → {number}

Restore the log level to what it was when pushLogLevel was called
Source:
Returns:
Type:
number
log level that was popped off the stack

(static) pushLogLevel(newLogLevel) → {number}

Save the previous log level and set a new log level
Source:
Parameters:
Name Type Description
newLogLevel number new log level to set
Returns:
Type:
number
previous log level

(static) readINI(in_text) → {object}

Read a bunch of text and try to extract structured information in .INI format

This function is lenient and is able to extract slightly mangled INI data from the text frame
content of an InDesign text frame.

This function knows how to handle curly quotes should they be present.

The following flexibilities have been built-in:

- Attribute names are case-insensitive and anything not a-z 0-9 is ignored.
Entries like this or that = ... or thisOrThat = ... or this'orThat = ... are
all equivalent. Only letters and digits are retained, and converted to lowercase.

- Attribute values can be quoted with either single, double, curly quotes.
This often occurs because InDesign can be configured to convert normal quotes into
curly quotes automatically.
Attribute values without quotes are trimmed (e.g. bla = x is the same as bla=x)
Spaces are retained in quoted attribute values.

- Any text will be ignore if not properly formatted as either a section name or an attribute-value
pair with an equal sign

- Hard and soft returns are equivalent

The return value is an object with the section names at the top level, and attribute names
below that. The following .INI

[My data]
this is = " abc "
that = abc

returns


{
"mydata": {
"__rawSectionName": "My data",
"thisis": " abc ",
"that": "abc"
}
}

Duplicated sections and entries are automatically suffixed with a counter suffix - e.g.
[main] a=1 a=2 a=3

is equivalent with
[main] a=1 a_2=2 a_3=3

and
[a] a=1 [a] a=2

is equivalent with
[a] a=1 [a_2] a=2

Source:
Parameters:
Name Type Description
in_text string raw text, which might or might not contain some INI-formatted data mixed with normal text
Returns:
Type:
object
either the ini data or undefined.

(static) rightPad(s, padChar, len) → {string}

Extend or shorten a string to an exact length, adding padChar as needed
Source:
Parameters:
Name Type Description
s string string to be extended or shortened
padChar string string to append repeatedly if length needs to extended
len number desired result length
Returns:
Type:
string
padded or shortened string

(static) sQ(str_or_ByteArr) → {string}

Wrap a string or a byte array into single quotes, encoding any binary data as a string.
Knows how to handle Unicode characters or binary zeroes.

When the input is a string, high Unicode characters are encoded as \uHHHH

When the input is a byte array, all bytes are encoded as \xHH escape sequences.
Source:
Parameters:
Name Type Description
str_or_ByteArr string a Unicode string or an array of bytes
Returns:
Type:
string
a string enclosed in double quotes. This string is pure 7-bit
ASCII and can be used into generated script code
Example:
var script = "a=b(" + crdtes.sQ(somedata) + ");";

(static) setIssuer(issuerGUID, issuerEmail)

Send in activation data to determine whether some software is currently activated or not.

Needs to be followed by a crdtes.sublicense() call
Source:
Parameters:
Name Type Description
issuerGUID string a GUID identifier for the developer account as seen in the PluginInstaller
issuerEmail string the email for the developer account as seen in the PluginInstaller

(static) setPersistData(issuer, attribute, password, data) → {boolean}

Store some persistent data (e.g. a time stamp to determine a demo version lapsing)

Only available to paid developer accounts
Source:
Parameters:
Name Type Description
issuer string a GUID identifier for the developer account as seen in the PluginInstaller
attribute string an attribute name for the data
password string the password (created by the developer) needed to decode the persistent data
data string any data to persist
Returns:
Type:
boolean
success or failure

(static) strToBinary(in_s) → {array}

Encode a string into an byte array using the 8 lowest bits of each UTF-16 character
Source:
Parameters:
Name Type Description
in_s string a string
Returns:
Type:
array
a byte array

(static) strToUTF8(in_s) → {array}

Encode a string into an byte array using UTF-8
Source:
Parameters:
Name Type Description
in_s string a string
Returns:
Type:
array
a byte array

(static) sublicense(key, activation) → {boolean}

Send in sublicense info generated in the PluginInstaller so we can determine whether some software is currently activated or not.

Needs to be preceded by a crdtes.setIssuer() call.
Source:
Parameters:
Name Type Description
key string key needed to decode activation data
activation string encrypted activation data
Returns:
Type:
boolean
success or failure

(static) toHex(i, numDigits) → {string}

Convert an integer into a hex representation with a fixed number of digits.
Negative numbers are converted using 2-s complement (so -15 results in 0x01)
Source:
Parameters:
Name Type Description
i number integer to convert to hex
numDigits number How many digits. Defaults to 4 if omitted.
Returns:
Type:
string
hex-encoded integer

(static) unitToInchFactor(in_unit) → {number}

Conversion factor from a length unit into inches
Source:
Parameters:
Name Type Description
in_unit string unit name (crdtes.UNIT_NAME...)
Returns:
Type:
number
conversion factor or 1.0 if unknown/not applicable