New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@squarecloud/api

Package Overview
Dependencies
Maintainers
2
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@squarecloud/api - npm Package Compare versions

Comparing version
1.1.6
to
1.1.7
+2
-3
lib/APIManager.d.ts
import { APIResponse, RawUserData } from './typings';
import { AxiosRequestConfig } from 'axios';
export declare class SquareCloudAPIError extends Error {

@@ -11,4 +10,4 @@ constructor(code: string, message?: string);

private fetch;
user(id?: string, options?: AxiosRequestConfig): Promise<RawUserData>;
application(path: string, id: string, options?: AxiosRequestConfig | boolean): Promise<APIResponse>;
user(id?: string, options?: RequestInit): Promise<RawUserData>;
application(path: string, id: string, options?: RequestInit | boolean): Promise<APIResponse>;
}
+2
-5
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.APIManager = exports.SquareCloudAPIError = void 0;
const axios_1 = __importDefault(require("axios"));
class SquareCloudAPIError extends Error {

@@ -41,3 +37,4 @@ constructor(code, message) {

options.method = options.method || 'GET';
const { data } = await (0, axios_1.default)('https://api.squarecloud.app/v1/public/' + path, options).catch((r) => r.response);
const data = await fetch('https://api.squarecloud.app/v1/public/' + path, options)
.then((r) => r.json());
if (data.status === 'error') {

@@ -44,0 +41,0 @@ throw new SquareCloudAPIError(data.code);

@@ -14,3 +14,3 @@ /// <reference types="node" />

export declare class Application {
private apiManager;
#private;
/** The application id */

@@ -71,6 +71,7 @@ id: string;

*
* @param file - The absolute file path or a ReadStream
* @param file - The absolute file path, a Buffer or a ReadStream
* @param fileName - If a Buffer is provided you must provide the file name and extension too
*/
commit(file: string | ReadStream): Promise<boolean>;
commit(file: Buffer, fileName: string, fileExtension: `.${string}`): Promise<boolean>;
commit(file: Buffer, fileName: string): Promise<boolean>;
}

@@ -18,3 +18,2 @@ "use strict";

class Application {
apiManager;
/** The application id */

@@ -43,4 +42,4 @@ id;

isWebsite;
#apiManager;
constructor(apiManager, data) {
this.apiManager = apiManager;
this.id = data.id;

@@ -54,6 +53,7 @@ this.tag = data.tag;

this.isWebsite = data.isWebsite;
this.#apiManager = apiManager;
}
/** Gets the application's current information */
async getStatus() {
const { network, cpu, ram, storage, requests, running, status, uptime, time, } = (await this.apiManager.application('status', this.id)).response;
const { network, cpu, ram, storage, requests, running, status, uptime, time, } = (await this.#apiManager.application('status', this.id)).response;
return {

@@ -79,7 +79,7 @@ status,

(0, Assertions_1.validateBoolean)(full, '[LOGS_FULL]');
return (await this.apiManager.application(`${full ? 'full-' : ''}logs`, this.id)).response.logs;
return (await this.#apiManager.application(`${full ? 'full-' : ''}logs`, this.id)).response.logs;
}
/** Generates the backup download URL */
async backup() {
return (await this.apiManager.application('backup', this.id)).response
return (await this.#apiManager.application('backup', this.id)).response
.downloadURL;

@@ -89,3 +89,3 @@ }

async start() {
const { code } = await this.apiManager.application('start', this.id, true);
const { code } = await this.#apiManager.application('start', this.id, true);
return code === 'ACTION_SENT';

@@ -95,3 +95,3 @@ }

async stop() {
const { code } = await this.apiManager.application('stop', this.id, true);
const { code } = await this.#apiManager.application('stop', this.id, true);
return code === 'ACTION_SENT';

@@ -101,3 +101,3 @@ }

async restart() {
const { code } = await this.apiManager.application('restart', this.id, true);
const { code } = await this.#apiManager.application('restart', this.id, true);
return code === 'ACTION_SENT';

@@ -111,6 +111,6 @@ }

async delete() {
const { code } = await this.apiManager.application('delete', this.id, true);
const { code } = await this.#apiManager.application('delete', this.id, true);
return code === 'APP_DELETED';
}
async commit(file, fileName, fileExtension) {
async commit(file, fileName) {
(0, Assertions_1.validateCommitLike)(file, 'COMMIT_DATA');

@@ -120,4 +120,3 @@ const formData = new form_data_1.default();

(0, Assertions_1.validateString)(fileName, 'FILE_NAME');
(0, Assertions_1.validateString)(fileExtension, 'FILE_EXTENSION');
formData.append('file', file, { filename: fileName + fileExtension });
formData.append('file', file, { filename: fileName });
}

@@ -127,6 +126,6 @@ else {

}
const { code } = await this.apiManager.application('commit', this.id, {
const { code } = await this.#apiManager.application('commit', this.id, {
method: 'POST',
data: formData,
headers: { ...formData.getHeaders() },
body: formData.getBuffer(),
headers: formData.getHeaders(),
});

@@ -133,0 +132,0 @@ return code === 'SUCCESS';

@@ -13,3 +13,3 @@ import { AccountPlan, RawUserData } from '../typings';

export declare class User {
private apiManager;
#private;
/** The user's id */

@@ -16,0 +16,0 @@ id: string;

@@ -14,3 +14,2 @@ "use strict";

class User {
apiManager;
/** The user's id */

@@ -24,4 +23,4 @@ id;

hasAccess;
#apiManager;
constructor(apiManager, data) {
this.apiManager = apiManager;
this.id = data.user.id;

@@ -37,8 +36,9 @@ this.tag = data.user.tag;

this.hasAccess = () => data.user.email !== 'Access denied';
this.#apiManager = apiManager;
}
/** Fetches the user data again and returns a new User */
fetch() {
return this.apiManager
return this.#apiManager
.user(this.id)
.then((data) => new (this.hasAccess() ? FullUser : User)(this.apiManager, data));
.then((data) => new (this.hasAccess() ? FullUser : User)(this.#apiManager, data));
}

@@ -45,0 +45,0 @@ }

{
"name": "@squarecloud/api",
"version": "1.1.6",
"version": "1.1.7",
"description": "A JavaScript Wrapper for SquareCloud API",

@@ -5,0 +5,0 @@ "main": "lib/index.js",