Commands this handler can execute

interface Exec {
    addLog: ((log, alert?) => void);
    base64ToInteger: ((value, offset?, maxByteLength?) => number);
    base64ToString: ((args) => string);
    base64ToUInt8Array: ((value) => Uint8Array);
    cborDecode: ((input, encoding?) => any);
    cborEncode: ((...objs) => Uint8Array);
    decrypt: ((args) => Uint8Array);
    encrypt: ((args) => {
        authTag: Uint8Array;
        encodedPayload: Uint8Array;
        initializationVector: Uint8Array;
    });
    getDeviceFields: ((objectType, hashId) => null | FieldsFromServer);
    getFile: ((file) => Uint8Array);
    integerToBase64: ((value, maxByteLength?) => string);
    scheduleCommand: ((args) => Command);
    sendRequest: ((args) => null | WebResponse);
    setDeviceFields: ((fields, object?, logInAuditLog?) => void);
    stringToBase64: ((args) => string);
    stringToUint8Array: ((str, inputEncoding) => Uint8Array);
    uInt8ArrayToBase64: ((value) => string);
    uint8ArrayToString: ((uint8Array, outputEncoding) => string);
    getCredentials(hashId): string;
    updateGeometry(longitude, latitude): void;
}

Properties

addLog: ((log, alert?) => void)

Add a text to the log file of this activity

Type declaration

    • (log, alert?): void
    • Parameters

      • log: string

        Text to log.

      • Optional alert: boolean

        True to mark this activity as failed, triggering an email alert to subscribers. False by default

      Returns void

base64ToInteger: ((value, offset?, maxByteLength?) => number)

Decode a base64 string to an integer number

Type declaration

    • (value, offset?, maxByteLength?): number
    • Parameters

      • value: string

        The base64 encoded string

      • Optional offset: number

        Number of bytes to skip before starting to read. Defaults to 0.

      • Optional maxByteLength: number

        Number of bytes to read. Must satisfy 0 < byteLength <= 6. Defaults to 6.

      Returns number

Returns

A big endian signed integer

base64ToString: ((args) => string)

Decode a base64 string to a UTF-8 string

Type declaration

    • (args): string
    • Parameters

      • args: string

        The base64 encoded string

      Returns string

Returns

A UTF-8 string

Deprecated

use stringToUint8Array and uint8ArrayToString instead

base64ToUInt8Array: ((value) => Uint8Array)

Decode a a base64 string to a Uint8Array

Type declaration

    • (value): Uint8Array
    • Parameters

      • value: string

        The base64 encoded string

      Returns Uint8Array

Returns

Uint8Array

Deprecated

use stringToUint8Array instead

cborDecode: ((input, encoding?) => any)

Decode the first CBOR item in the input into a JavaScript object

Type declaration

    • (input, encoding?): any
    • Parameters

      • input: string | Uint8Array

        The input

      • Optional encoding: string

      Returns any

Returns

The decoded javascript object

cborEncode: ((...objs) => Uint8Array)

Encode one or more JavaScript objects into a buffer containing the CBOR bytes

Type declaration

    • (...objs): Uint8Array
    • Parameters

      • Rest ...objs: any[]

        any[]

      Returns Uint8Array

Returns

Uint8Array

decrypt: ((args) => Uint8Array)

Decrypt data

Type declaration

    • (args): Uint8Array
    • Parameters

      • args: DecryptArgs

        information about the data to decrypt and the encryption cipher

      Returns Uint8Array

Returns

decrypted data

encrypt: ((args) => {
    authTag: Uint8Array;
    encodedPayload: Uint8Array;
    initializationVector: Uint8Array;
})

Encrypt data

Type declaration

    • (args): {
          authTag: Uint8Array;
          encodedPayload: Uint8Array;
          initializationVector: Uint8Array;
      }
    • Parameters

      • args: EncryptArgs

        information about the data to encrypt and the encryption cipher

      Returns {
          authTag: Uint8Array;
          encodedPayload: Uint8Array;
          initializationVector: Uint8Array;
      }

      • authTag: Uint8Array
      • encodedPayload: Uint8Array
      • initializationVector: Uint8Array

Returns

object with the encrypted payload, IV and authtag

getDeviceFields: ((objectType, hashId) => null | FieldsFromServer)

Get the form fields of a location or port

Type declaration

getFile: ((file) => Uint8Array)

Get report file

Type declaration

    • (file): Uint8Array
    • Parameters

      • file: string

        File hash id to get

      Returns Uint8Array

integerToBase64: ((value, maxByteLength?) => string)

Encode an integer number into a base64 string

Type declaration

    • (value, maxByteLength?): string
    • Parameters

      • value: number

        The big endian signed integer

      • Optional maxByteLength: number

        Number of bytes to write. Must satisfy 0 < byteLength <= 6. Defaults to 6.

      Returns string

Returns

A base64 encoded value

scheduleCommand: ((args) => Command)

Schedule a new command for this device

Type declaration

sendRequest: ((args) => null | WebResponse)

Perform an HTTP request

Type declaration

setDeviceFields: ((fields, object?, logInAuditLog?) => void)

Update the form fields of the device, its linked location or port

Type declaration

    • (fields, object?, logInAuditLog?): void
    • Parameters

      • fields: FieldsToServerUpdate

        data to store

      • Optional object: DeviceFieldsObject

        where to store it (device by default)

      • Optional logInAuditLog: boolean

        if true, the changes will be logged in the audit log

      Returns void

stringToBase64: ((args) => string)

Encode a UTF-8 string into a base64 string

Type declaration

    • (args): string
    • Parameters

      • args: string

        A UTF-8 string

      Returns string

Returns

The base64 encoded value

Deprecated

use stringToUint8Array and uint8ArrayToString instead

stringToUint8Array: ((str, inputEncoding) => Uint8Array)

Convert a string to a Uint8Array

Type declaration

    • (str, inputEncoding): Uint8Array
    • Parameters

      • str: string

        string to convert

      • inputEncoding: BufferEncoding

        encoding of the input string

      Returns Uint8Array

Returns

Uint8Array

uInt8ArrayToBase64: ((value) => string)

Encode a Uint8Array into a base64 string

Type declaration

    • (value): string
    • Parameters

      • value: Uint8Array

        Uint8Array

      Returns string

Returns

A base64 encoded value

Deprecated

use uint8ArrayToString instead

uint8ArrayToString: ((uint8Array, outputEncoding) => string)

Convert a Uint8Array to a string

Type declaration

    • (uint8Array, outputEncoding): string
    • Parameters

      • uint8Array: Uint8Array

        uint8Array to convert

      • outputEncoding: BufferEncoding

        encoding of the output string

      Returns string

Returns

string

Methods

  • Get the credentials used for an authenticated request

    Parameters

    • hashId: string

      hashId of the credentials

    Returns string

  • Update the geometry of the location

    Parameters

    • longitude: number

      new longitude of the location

    • latitude: number

      new latitude of the location

    Returns void