Skip to main content

Managing Scripts

This is the main and core part of using SecLoad. This page goes over how you can use the NodeJS SDK to view and modify scripts. There is some miscellaneous info you can use, such as generating keys and using Node's Native API for SecLoad's API.

Promises

This API is Promise Based, meaning you will have to use await or .then(function)

info

In these examples, you will have to log into the client first, not doing this will throw an error.

Modifying scripts.

Creating a script

src/index.js
const {SecloadClient} = require('secload')
const client = new SecloadClient()
client.createScript("scriptname", "content")

Overwriting a script.

You can update your own scripts with this.

src/index.js
const {SecloadClient} = require('secload')
const client = new SecloadClient()
client.overwriteScript("scriptname", "content")

Removing a script

src/index.js
const {SecloadClient} = require('secload')
const client = new SecloadClient()
client.removeScript("scriptname")

Viewing Scripts

Listing Scripts

This function returns a promise (obviously) as an array with strings.

src/index.js
const {SecloadClient} = require('secload')
const client = new SecloadClient()
client.listScripts()

Viewing a script's source

You can get the script source if you want.

src/index.js
const {SecloadClient} = require('secload')
const client = new SecloadClient()
client.getScriptSource("scriptname")

Miscellaneous

Generating Script Keys

src/index.js
const {SecloadClient} = require('secload')
const client = new SecloadClient()
client.generateKey("scriptname", 5, "doqe_wow") // (scriptname, time [minutes], username)

Using FileSystem/Buffers with SecLoad

SecLoad automatically supports buffers if you use them. This example, we will use the fs package, a well known official node package used for file modification/reading.

danger

If you are using TypeScript, make sure @types/node is installed.

src/index.js
const fs = require('fs')
const {SecloadClient} = require('secload')
const client = new SecloadClient()
client.createScript("scriptname", fs.readFileSync('script.lua'))