noblox-private

    4.2.6 • Public • Published

    noblox.js

    A Node.js wrapper for interacting with the Roblox API. Forked from roblox-js.

    JavaScript Style Guide Roblox API Discord NPM package Travis Build Status

    AboutPrerequisitesInstallationDocsExamplesCreditsLicense

    About

    Noblox.js is a node module that was forked from sentanos's roblox-js module. This project was created because the roblox-js repository was no longer maintained by sentanos. This private version is an upload of a fix for the cookie persistancy problem that happens with heroku.

    Noblox.js allows you to do things you would normally do on the Roblox website through a Node.js interface. You can use noblox.js along with Roblox's HttpService feature to create scripts that interact with the website. If you're looking for more information on how to create something like this, check out this repository by sentanos. Keep in mind that this does not use the latest version of this module and it is highly encouraged that you learn to use the library directly.

    Prerequisites

    Installation

    With node.js installed simply run:

    # Run this to install noblox.js locally to your repository.  
    $ npm install noblox.js --save
     
    # Run this instead to install noblox.js globally so you can use it anywhere. 
    $ npm install noblox.js -g

    That's it!

    Documentation

    You can find the current noblox.js wiki with all API documentation here. A majority of the new features that can be found in noblox.js are not in roblox-js. There will be new documentation coming in with v5.0.0.

    Making use of new login workaround

    Initial setup

    1. Remove any usages of the login method.
    2. Run cookieLogin when your app starts. You only need to run it on app start. Supply it with a cookie, guide on obtaining that below.
    3. This cookie will be automatically refreshed. You never need to supply it again, but supplying it is unlikely to cause problems

    Getting your cookie (Chrome):

    1. Open any Roblox page and login
    2. Press Control + Shift + i on your keyboard
    3. Click Application
    4. Find .ROBLOSECURITY. Copy it's contents, which will start with _|WARNING:-DO
    5. Put this full token, including the warning into cookieLogin: rbx.cookieLogin( tokenHere )

    Example

    This example makes use of the new async-await syntax.

    const rbx = require("noblox.js")
    async function startApp () {
        await rbx.cookieLogin("_|WARNING:-DO-NOT-SHARE-THIS.--Sharing-this-will-allow-someone-to-log-in-as-you-and-to-steal-your-ROBUX-and-items.|_F9F1EA531adk")
        // Do everything else, calling functions and the like.
        let currentUser = await rbx.getCurrentUser()
    }

    Drawbacks

    • Only one application can be logged in at once.
    • If the application is offline for like a week to a month you may need to get the cookie again
    • Your cookie is stored within a file in the lib by default (see: Using a custom cookie loader)
    • Roblox-js-server is not currently compatible. Use noblox.js-server instead.
    • The application will not work on Heroku. This is because we store the cookie internally in a file, and files do not persist in Heroku.

    Using a custom cookie loader

    The cookie can be stored using a cookie loader. A cookie loader is a set of functions passed to cookieLogin to load and save cookies. In this case, the initial cookie should be a paramater in the object argument.

    cookieLoad should return (if available) an object with the cookie string and optionally a time number (which represents the amount of time since the unix epoch; e.g. Date.Now()). cookieSave is given a cookie to save and should return once completed. Both cookieLoad and cookieSave may run asynchronously in which case they must return a Promise.

    const rbx = require("noblox.js")
    const { promisify } = require("util")
    const redis = require("redis").createClient()
    const redisGet = promisify(redis.get)
    const redisSet = promisify(redis.set)
    async function startApp () {
        await rbx.cookieLogin({
            cookie: "_|WARNING:-DO-NOT-SHARE-THIS.--Sharing-this-will-allow-someone-to-log-in-as-you-and-to-steal-your-ROBUX-and-items.|_F9F1EA531adk",
            loadCookie: function () {
                return redisGet('cookie')
            },
            saveCookie: function (cookie) {
                await redisSet('cookie', {cookie: cookie, time: Date.now()})
            }
        })
        // Do everything else, calling functions and the like.
        let currentUser = await rbx.getCurrentUser()
    }

    Additionally, sample loaders have been provided for MySql, PostgreSQL, and Microsoft SQL databases.

    1. A connection pool is created for the database,
    2. an rbx_cookie table is created (if it does not exist),
    3. and the loader functions are returned.
    const rbx = require("noblox.js")
    async function startApp () {
        let loader = rbx.cookieLoaders('mysql', {
            host: 'example.org',
            user: 'bob',
            password: 'secret',
            connectionLimit: 20
        })
        await rbx.cookieLogin({
            cookie: "_|WARNING:-DO-NOT-SHARE-THIS.--Sharing-this-will-allow-someone-to-log-in-as-you-and-to-steal-your-ROBUX-and-items.|_F9F1EA531adk",
            loadCookie: loader.loadCookie,
            saveCookie: loader.saveCookie 
        })
        // Do everything else, calling functions and the like.
        let currentUser = await rbx.getCurrentUser()
    }

    Each sample loader has it's own identifier and driver that needs to be installed:

    • mysql - Requires mysql (npm install --save mysql).
    • postgres - Requires pg (npm install --save pg).
    • mssql - Requires mssql (npm install --save mssql).

    Credits

    • sentanos - We wouldn't exist without him. 😀

    License

    MIT

    Install

    npm i noblox-private

    DownloadsWeekly Downloads

    9

    Version

    4.2.6

    License

    MIT

    Unpacked Size

    202 kB

    Total Files

    150

    Last publish

    Collaborators

    • grandomgamer