🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

luraph

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

luraph - npm Package Compare versions

Comparing version

to
2.0.0

.github/dependabot.yml

139

index.ts

@@ -1,19 +0,12 @@

import axios, { AxiosError, AxiosInstance, AxiosResponse } from "axios";
const CONTENT_REGEX = /filename[^;=\n]*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/i;
export interface LuraphOptionSpec {
export interface LuraphOptionInfo {
readonly name: string;
readonly description: string;
readonly tier: string;
readonly type: string;
readonly choices: readonly string[];
}
export interface LuraphOptionSpecList {
readonly [optionName: string]: LuraphOptionSpec;
}
readonly tier: "CUSTOMER_ONLY" | "PREMIUM_ONLY" | "ADMIN_ONLY";
readonly type: "CHECKBOX" | "DROPDOWN" | "TEXT";
export interface LuraphOptionList {
[optionName: string]: [boolean, string];
//empty `[]` if `type !== DROPDOWN`
readonly choices: readonly string[];
}

@@ -23,28 +16,11 @@

readonly cpuUsage: number;
readonly options: LuraphOptionSpecList;
readonly options: {
readonly [key: string]: LuraphOptionInfo;
};
}
export interface LuraphNodeList {
readonly [nodeId: string]: LuraphNode;
export interface LuraphOptionList {
[key: string]: [boolean, string];
}
export interface LuraphNodesResponse {
readonly recommendedId: string;
readonly nodes: LuraphNodeList;
}
export interface LuraphNewJobResponse {
readonly jobId: string;
}
export interface LuraphJobStatusResponse {
readonly success: boolean;
readonly error?: string;
}
export interface LuraphDownloadResponse {
readonly fileName: string;
readonly data: string;
}
export interface LuraphError {

@@ -63,3 +39,3 @@ readonly param?: string;

super(`Luraph API Error: ${errorMsg}`);
super(`${errorMsg}`);
this.name = this.constructor.name;

@@ -70,65 +46,84 @@

}
export default class Luraph {
private readonly apiKey: string;
export class LuraphAPI {
private readonly api: AxiosInstance;
constructor(apiKey: string) {
this.apiKey = apiKey;
}
constructor(apiKey: string) {
this.api = axios.create({
baseURL: "https://api.lura.ph/v1/",
headers: {
"Luraph-API-Key": apiKey
private async doRequest(url: string, isPost = false, body: object | undefined = undefined, rawResponse = false) {
const req = await fetch(
new URL(url, "https://api.lura.ph/v1/"),
{
method: isPost ? "POST" : "GET",
headers: {
"Luraph-API-Key": this.apiKey,
"Content-Type": "application/json"
},
body: JSON.stringify(body)
}
});
);
//raw responses
if(rawResponse && req.ok)
return req;
this.api.interceptors.response.use(this.onResponseFufilled, this.onResponseRejected);
}
const rawResp = await req.text();
const resp = rawResp.length ? JSON.parse(rawResp) : {};
private onResponseFufilled(resp: AxiosResponse) {
if(!resp.data)
resp.data = {};
return Promise.resolve(resp);
}
if(resp.warnings){
for(const warning of resp.warnings){
console.warn(`Luraph API warning: ${warning}`);
}
}
private onResponseRejected(err: AxiosError) {
if(err.isAxiosError && err.response && err.response.data && err.response.data.errors){
return Promise.reject(new LuraphException(err.response.data.errors));
if(req.ok){
return resp;
}else{
let errors = (resp as any)?.errors;
if(!errors)
errors = [{
message: "An unknown error occurred",
rawBody: resp
}];
throw new LuraphException(errors);
}
return Promise.reject(err);
}
}
async getNodes() {
return (await this.api.get("/obfuscate/nodes")).data as LuraphNodesResponse;
getNodes() {
return this.doRequest("obfuscate/nodes") as Promise<{ nodes: {[nodeId: string]: LuraphNode}; recommendedId: string | null }>;
}
async createNewJob(node: string, script: string, fileName: string, options: LuraphOptionList) {
createNewJob(node: string, script: string, fileName: string, options: LuraphOptionList, useTokens = false, enforceSettings = false) {
script = Buffer.from(script).toString("base64");
return (await this.api.post("/obfuscate/new", {
return this.doRequest("obfuscate/new", true, {
node,
script,
fileName,
options
})).data as LuraphNewJobResponse;
options,
useTokens,
enforceSettings
}) as Promise<{jobId: string}>;
}
async getJobStatus(jobId: string) {
const {data} = await this.api.get(`/obfuscate/status/${jobId}`);
const data = await this.doRequest(`obfuscate/status/${jobId}`) as { error: string | null };
return {
success: !data.error,
error: data.error
} as LuraphJobStatusResponse;
error: data.error as string | null
};
}
async downloadResult(jobId: string) {
const {data, headers} = await this.api.get(`/obfuscate/download/${jobId}`);
const fileName = (CONTENT_REGEX.exec(headers['content-disposition'] || '') || [])[2]
const req = await this.doRequest(`obfuscate/download/${jobId}`, false, undefined, true);
const fileName = CONTENT_REGEX.exec(req.headers.get("content-disposition"))?.[2] || "script-obfuscated.lua";
const data = await req.text();
return {
data,
fileName
} as LuraphDownloadResponse;
};
}
};
export default LuraphAPI;
export const Luraph = LuraphAPI;
export const API = LuraphAPI;
};
{
"name": "luraph",
"version": "1.0.2",
"version": "2.0.0",
"description": "Luraph API binding for Node.JS",
"main": "build/index.js",
"scripts": {
"start": "tsc && node build/index.js",
"build": "tsc"
},
"main": "dist/index.js",
"keywords": [

@@ -23,7 +19,9 @@ "luraph",

"devDependencies": {
"@types/node": "^15.0.2",
"typescript": "^4.2.4"
"@tsconfig/node-lts": "^18.12.5",
"@types/node": "^20.10.0",
"typescript": "^5.3.2"
},
"dependencies": {
"axios": "^0.21.4"
"axios": "^1.6.2",
"undici": "^5.28.0"
},

@@ -37,3 +35,7 @@ "repository": {

},
"homepage": "https://github.com/Luraph/luraph-node#readme"
}
"homepage": "https://github.com/Luraph/luraph-node#readme",
"scripts": {
"start": "tsc && node dist/index.js",
"build": "tsc"
}
}

@@ -1,2 +0,2 @@

const Luraph = require("./build/index").Luraph;
const Luraph = require("./dist/index").default;
const api = new Luraph(process.env.LPH_API_KEY);

@@ -6,36 +6,17 @@

const nodes = await api.getNodes();
console.log("Recommended Node", nodes.recommendedId);
console.log("Recommended Node:", nodes.recommendedId);
const node = nodes.nodes[nodes.recommendedId];
console.log("- CPU Usage: ", node.cpuUsage);
console.log("- CPU Usage:", node.cpuUsage);
console.log("- Options: ");
for(const [optionId, optionInfo] of Object.entries(node.options)){
console.log("*", optionId, "-", optionInfo.name + ":");
console.log(" Description:", optionInfo.description);
console.log(" Type:", optionInfo.type);
console.log(" Tier:", optionInfo.tier);
console.log(" Choices:", `[${optionInfo.choices.join(", ")}]`);
console.log(" *", optionId, "-", optionInfo.name + ":");
console.log(" |- Description:", optionInfo.description);
console.log(" |- Type:", optionInfo.type);
console.log(" |- Tier:", optionInfo.tier);
console.log(" |- Choices:", `[${optionInfo.choices.join(", ")}]`);
console.log("");
}
const options = {};
const optionChoices = node.options;
for(const [option, info] of Object.entries(optionChoices)){
let value;
switch(info.type){
case "CHECKBOX":
value = false;
break;
case "DROPDOWN":
value = info.choices[0];
break;
case "TEXT":
value = "";
break;
default:
break;
}
options[option] = value;
}
const {jobId} = await api.createNewJob(nodes.recommendedId, `print'Hello World!'`, "hello-world.txt", options);
const {jobId} = await api.createNewJob(nodes.recommendedId, `print'Hello World!'`, "hello-world.txt", {});
console.log("Job ID", jobId);

@@ -42,0 +23,0 @@

{
"extends": "@tsconfig/node-lts/tsconfig.json",
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "build/", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
"outDir": "dist/",
"types": ["@types/node"]
}
}

Sorry, the diff of this file is not supported yet