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

morphcloud

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

morphcloud - npm Package Compare versions

Comparing version
0.0.17
to
0.0.18
+55
-4
dist/index.cjs

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

constructor(data, client) {
var _a, _b, _c, _d, _e;
this.id = data.id;

@@ -726,2 +727,11 @@ this.object = data.object;

};
this.ttl = {
ttlSeconds: (_a = data.ttl) == null ? void 0 : _a.ttl_seconds,
ttlExpireAt: (_b = data.ttl) == null ? void 0 : _b.ttl_expire_at,
ttlAction: (_c = data.ttl) == null ? void 0 : _c.ttl_action
};
this.wakeOn = {
wakeOnSsh: (_d = data.wake_on) == null ? void 0 : _d.wake_on_ssh,
wakeOnHttp: (_e = data.wake_on) == null ? void 0 : _e.wake_on_http
};
this.metadata = data.metadata;

@@ -741,2 +751,6 @@ this.client = client;

}
async reboot() {
await this.client.POST(`/instance/${this.id}/reboot`);
await this.refresh();
}
async setMetadata(metadata) {

@@ -746,2 +760,10 @@ await this.client.POST(`/instance/${this.id}/metadata`, {}, metadata);

}
async setWakeOn(wakeOnSsh, wakeOnHttp) {
const payload = {};
if (wakeOnSsh !== void 0) payload.wake_on_ssh = wakeOnSsh;
if (wakeOnHttp !== void 0) payload.wake_on_http = wakeOnHttp;
if (Object.keys(payload).length === 0) return;
await this.client.POST(`/instance/${this.id}/wake-on`, {}, payload);
await this.refresh();
}
async snapshot(options = {}) {

@@ -808,3 +830,5 @@ const digest = options.digest || void 0;

if (this._isTimeoutError(error)) {
throw new Error(`Command execution timed out after ${timeout ? timeout / 1e3 : "24 hours"} ${timeout ? timeout / 1e3 === 1 ? "second" : "seconds" : ""}`);
throw new Error(
`Command execution timed out after ${timeout ? timeout : "24 hours"} ${timeout ? timeout === 1 ? "second" : "seconds" : ""}`
);
}

@@ -890,3 +914,5 @@ throw error;

if (this._isTimeoutError(error)) {
throw new Error(`Command execution timed out after ${timeout ? timeout / 1e3 : "24 hours"} ${timeout ? timeout / 1e3 === 1 ? "second" : "seconds" : ""}`);
throw new Error(
`Command execution timed out after ${timeout ? timeout : "24 hours"} ${timeout ? timeout === 1 ? "second" : "seconds" : ""}`
);
}

@@ -901,4 +927,6 @@ throw error;

const startTime = Date.now();
const hasTimeout = timeout !== void 0;
const limitMs = hasTimeout ? timeout * 1e3 : void 0;
while (this.status !== "ready" /* READY */) {
if (timeout && Date.now() - startTime > timeout * 1e3) {
if (hasTimeout && Date.now() - startTime > limitMs) {
throw new Error("Instance did not become ready before timeout");

@@ -1424,3 +1452,3 @@ }

start: async (options) => {
const { snapshotId, metadata, ttlSeconds, ttlAction } = options;
const { snapshotId, metadata, ttlSeconds, ttlAction, timeout } = options;
const queryParams = {

@@ -1440,2 +1468,25 @@ snapshot_id: snapshotId

const response = await this.POST("/instance", queryParams, body);
const instance = new Instance(response, this);
try {
await instance.waitUntilReady(timeout);
} catch (e) {
try {
await instance.stop();
} catch (cleanupError) {
console.error(`Failed to cleanup instance ${instance.id}:`, cleanupError);
}
throw e;
}
return instance;
},
boot: async (options) => {
const { snapshotId, vcpus, memory, diskSize, metadata, ttlSeconds, ttlAction } = options;
const body = {};
if (vcpus !== void 0) body.vcpus = vcpus;
if (memory !== void 0) body.memory = memory;
if (diskSize !== void 0) body.disk_size = diskSize;
if (metadata !== void 0) body.metadata = metadata;
if (ttlSeconds !== void 0) body.ttl_seconds = ttlSeconds;
if (ttlAction !== void 0) body.ttl_action = ttlAction;
const response = await this.POST(`/snapshot/${snapshotId}/boot`, {}, body);
return new Instance(response, this);

@@ -1442,0 +1493,0 @@ },

@@ -44,2 +44,11 @@ import { NodeSSH } from 'node-ssh';

}
interface InstanceTTL {
ttlSeconds?: number;
ttlExpireAt?: number;
ttlAction?: "stop" | "pause";
}
interface InstanceWakeOn {
wakeOnSsh?: boolean;
wakeOnHttp?: boolean;
}
interface ExecOptions {

@@ -90,2 +99,3 @@ timeout?: number;

ttlAction?: "stop" | "pause";
timeout?: number;
}

@@ -102,2 +112,11 @@ interface InstanceSnapshotOptions {

}
interface InstanceBootOptions {
snapshotId: string;
vcpus?: number;
memory?: number;
diskSize?: number;
metadata?: Record<string, string>;
ttlSeconds?: number;
ttlAction?: "stop" | "pause";
}
interface SyncOptions {

@@ -187,2 +206,4 @@ delete?: boolean;

networking: InstanceNetworking;
ttl: InstanceTTL;
wakeOn: InstanceWakeOn;
readonly metadata?: Record<string, string>;

@@ -194,3 +215,5 @@ private client;

resume(): Promise<void>;
reboot(): Promise<void>;
setMetadata(metadata: Record<string, string>): Promise<void>;
setWakeOn(wakeOnSsh?: boolean, wakeOnHttp?: boolean): Promise<void>;
snapshot(options?: InstanceSnapshotOptions): Promise<Snapshot>;

@@ -256,2 +279,3 @@ branch(count: number): Promise<{

start: (options: InstanceStartOptions) => Promise<Instance>;
boot: (options: InstanceBootOptions) => Promise<Instance>;
get: (options: InstanceGetOptions) => Promise<Instance>;

@@ -262,2 +286,2 @@ stop: (options: InstanceStopOptions) => Promise<void>;

export { type ExecOptions, Image, type ImageListOptions, Instance, type InstanceExecResponse, type InstanceGetOptions, type InstanceHttpService, type InstanceListOptions, type InstanceNetworking, type InstanceRefs, type InstanceSnapshotOptions, type InstanceSshKey, type InstanceStartOptions, InstanceStatus, type InstanceStopOptions, MorphCloudClient, type MorphCloudClientOptions, type ResourceSpec, Snapshot, type SnapshotCreateOptions, type SnapshotGetOptions, type SnapshotListOptions, type SnapshotRefs, SnapshotStatus, type SyncOptions };
export { type ExecOptions, Image, type ImageListOptions, Instance, type InstanceBootOptions, type InstanceExecResponse, type InstanceGetOptions, type InstanceHttpService, type InstanceListOptions, type InstanceNetworking, type InstanceRefs, type InstanceSnapshotOptions, type InstanceSshKey, type InstanceStartOptions, InstanceStatus, type InstanceStopOptions, type InstanceTTL, type InstanceWakeOn, MorphCloudClient, type MorphCloudClientOptions, type ResourceSpec, Snapshot, type SnapshotCreateOptions, type SnapshotGetOptions, type SnapshotListOptions, type SnapshotRefs, SnapshotStatus, type SyncOptions };

@@ -44,2 +44,11 @@ import { NodeSSH } from 'node-ssh';

}
interface InstanceTTL {
ttlSeconds?: number;
ttlExpireAt?: number;
ttlAction?: "stop" | "pause";
}
interface InstanceWakeOn {
wakeOnSsh?: boolean;
wakeOnHttp?: boolean;
}
interface ExecOptions {

@@ -90,2 +99,3 @@ timeout?: number;

ttlAction?: "stop" | "pause";
timeout?: number;
}

@@ -102,2 +112,11 @@ interface InstanceSnapshotOptions {

}
interface InstanceBootOptions {
snapshotId: string;
vcpus?: number;
memory?: number;
diskSize?: number;
metadata?: Record<string, string>;
ttlSeconds?: number;
ttlAction?: "stop" | "pause";
}
interface SyncOptions {

@@ -187,2 +206,4 @@ delete?: boolean;

networking: InstanceNetworking;
ttl: InstanceTTL;
wakeOn: InstanceWakeOn;
readonly metadata?: Record<string, string>;

@@ -194,3 +215,5 @@ private client;

resume(): Promise<void>;
reboot(): Promise<void>;
setMetadata(metadata: Record<string, string>): Promise<void>;
setWakeOn(wakeOnSsh?: boolean, wakeOnHttp?: boolean): Promise<void>;
snapshot(options?: InstanceSnapshotOptions): Promise<Snapshot>;

@@ -256,2 +279,3 @@ branch(count: number): Promise<{

start: (options: InstanceStartOptions) => Promise<Instance>;
boot: (options: InstanceBootOptions) => Promise<Instance>;
get: (options: InstanceGetOptions) => Promise<Instance>;

@@ -262,2 +286,2 @@ stop: (options: InstanceStopOptions) => Promise<void>;

export { type ExecOptions, Image, type ImageListOptions, Instance, type InstanceExecResponse, type InstanceGetOptions, type InstanceHttpService, type InstanceListOptions, type InstanceNetworking, type InstanceRefs, type InstanceSnapshotOptions, type InstanceSshKey, type InstanceStartOptions, InstanceStatus, type InstanceStopOptions, MorphCloudClient, type MorphCloudClientOptions, type ResourceSpec, Snapshot, type SnapshotCreateOptions, type SnapshotGetOptions, type SnapshotListOptions, type SnapshotRefs, SnapshotStatus, type SyncOptions };
export { type ExecOptions, Image, type ImageListOptions, Instance, type InstanceBootOptions, type InstanceExecResponse, type InstanceGetOptions, type InstanceHttpService, type InstanceListOptions, type InstanceNetworking, type InstanceRefs, type InstanceSnapshotOptions, type InstanceSshKey, type InstanceStartOptions, InstanceStatus, type InstanceStopOptions, type InstanceTTL, type InstanceWakeOn, MorphCloudClient, type MorphCloudClientOptions, type ResourceSpec, Snapshot, type SnapshotCreateOptions, type SnapshotGetOptions, type SnapshotListOptions, type SnapshotRefs, SnapshotStatus, type SyncOptions };

@@ -669,2 +669,3 @@ var __getOwnPropNames = Object.getOwnPropertyNames;

constructor(data, client) {
var _a, _b, _c, _d, _e;
this.id = data.id;

@@ -687,2 +688,11 @@ this.object = data.object;

};
this.ttl = {
ttlSeconds: (_a = data.ttl) == null ? void 0 : _a.ttl_seconds,
ttlExpireAt: (_b = data.ttl) == null ? void 0 : _b.ttl_expire_at,
ttlAction: (_c = data.ttl) == null ? void 0 : _c.ttl_action
};
this.wakeOn = {
wakeOnSsh: (_d = data.wake_on) == null ? void 0 : _d.wake_on_ssh,
wakeOnHttp: (_e = data.wake_on) == null ? void 0 : _e.wake_on_http
};
this.metadata = data.metadata;

@@ -702,2 +712,6 @@ this.client = client;

}
async reboot() {
await this.client.POST(`/instance/${this.id}/reboot`);
await this.refresh();
}
async setMetadata(metadata) {

@@ -707,2 +721,10 @@ await this.client.POST(`/instance/${this.id}/metadata`, {}, metadata);

}
async setWakeOn(wakeOnSsh, wakeOnHttp) {
const payload = {};
if (wakeOnSsh !== void 0) payload.wake_on_ssh = wakeOnSsh;
if (wakeOnHttp !== void 0) payload.wake_on_http = wakeOnHttp;
if (Object.keys(payload).length === 0) return;
await this.client.POST(`/instance/${this.id}/wake-on`, {}, payload);
await this.refresh();
}
async snapshot(options = {}) {

@@ -769,3 +791,5 @@ const digest = options.digest || void 0;

if (this._isTimeoutError(error)) {
throw new Error(`Command execution timed out after ${timeout ? timeout / 1e3 : "24 hours"} ${timeout ? timeout / 1e3 === 1 ? "second" : "seconds" : ""}`);
throw new Error(
`Command execution timed out after ${timeout ? timeout : "24 hours"} ${timeout ? timeout === 1 ? "second" : "seconds" : ""}`
);
}

@@ -851,3 +875,5 @@ throw error;

if (this._isTimeoutError(error)) {
throw new Error(`Command execution timed out after ${timeout ? timeout / 1e3 : "24 hours"} ${timeout ? timeout / 1e3 === 1 ? "second" : "seconds" : ""}`);
throw new Error(
`Command execution timed out after ${timeout ? timeout : "24 hours"} ${timeout ? timeout === 1 ? "second" : "seconds" : ""}`
);
}

@@ -862,4 +888,6 @@ throw error;

const startTime = Date.now();
const hasTimeout = timeout !== void 0;
const limitMs = hasTimeout ? timeout * 1e3 : void 0;
while (this.status !== "ready" /* READY */) {
if (timeout && Date.now() - startTime > timeout * 1e3) {
if (hasTimeout && Date.now() - startTime > limitMs) {
throw new Error("Instance did not become ready before timeout");

@@ -1385,3 +1413,3 @@ }

start: async (options) => {
const { snapshotId, metadata, ttlSeconds, ttlAction } = options;
const { snapshotId, metadata, ttlSeconds, ttlAction, timeout } = options;
const queryParams = {

@@ -1401,2 +1429,25 @@ snapshot_id: snapshotId

const response = await this.POST("/instance", queryParams, body);
const instance = new Instance(response, this);
try {
await instance.waitUntilReady(timeout);
} catch (e) {
try {
await instance.stop();
} catch (cleanupError) {
console.error(`Failed to cleanup instance ${instance.id}:`, cleanupError);
}
throw e;
}
return instance;
},
boot: async (options) => {
const { snapshotId, vcpus, memory, diskSize, metadata, ttlSeconds, ttlAction } = options;
const body = {};
if (vcpus !== void 0) body.vcpus = vcpus;
if (memory !== void 0) body.memory = memory;
if (diskSize !== void 0) body.disk_size = diskSize;
if (metadata !== void 0) body.metadata = metadata;
if (ttlSeconds !== void 0) body.ttl_seconds = ttlSeconds;
if (ttlAction !== void 0) body.ttl_action = ttlAction;
const response = await this.POST(`/snapshot/${snapshotId}/boot`, {}, body);
return new Instance(response, this);

@@ -1403,0 +1454,0 @@ },

+1
-1
{
"name": "morphcloud",
"version": "0.0.17",
"version": "0.0.18",
"description": "A Typescript SDK for creating, managing, and interacting with Morph Cloud VMs.",

@@ -5,0 +5,0 @@ "main": "./dist/index.cjs",

@@ -82,2 +82,13 @@ import * as crypto from "crypto";

interface InstanceTTL {
ttlSeconds?: number;
ttlExpireAt?: number;
ttlAction?: "stop" | "pause";
}
interface InstanceWakeOn {
wakeOnSsh?: boolean;
wakeOnHttp?: boolean;
}
interface ExecOptions {

@@ -135,2 +146,3 @@ timeout?: number;

ttlAction?: "stop" | "pause";
timeout?: number; // seconds to wait for readiness
}

@@ -151,2 +163,12 @@

interface InstanceBootOptions {
snapshotId: string;
vcpus?: number;
memory?: number;
diskSize?: number;
metadata?: Record<string, string>;
ttlSeconds?: number;
ttlAction?: "stop" | "pause";
}
interface SyncOptions {

@@ -386,2 +408,4 @@ delete?: boolean;

networking: InstanceNetworking;
ttl: InstanceTTL;
wakeOn: InstanceWakeOn;
readonly metadata?: Record<string, string>;

@@ -408,2 +432,11 @@ private client: MorphCloudClient;

};
this.ttl = {
ttlSeconds: data.ttl?.ttl_seconds,
ttlExpireAt: data.ttl?.ttl_expire_at,
ttlAction: data.ttl?.ttl_action,
};
this.wakeOn = {
wakeOnSsh: data.wake_on?.wake_on_ssh,
wakeOnHttp: data.wake_on?.wake_on_http,
};
this.metadata = data.metadata;

@@ -427,2 +460,7 @@ this.client = client;

async reboot(): Promise<void> {
await this.client.POST(`/instance/${this.id}/reboot`);
await this.refresh();
}
async setMetadata(metadata: Record<string, string>): Promise<void> {

@@ -433,2 +471,14 @@ await this.client.POST(`/instance/${this.id}/metadata`, {}, metadata);

async setWakeOn(
wakeOnSsh?: boolean,
wakeOnHttp?: boolean
): Promise<void> {
const payload: any = {};
if (wakeOnSsh !== undefined) payload.wake_on_ssh = wakeOnSsh;
if (wakeOnHttp !== undefined) payload.wake_on_http = wakeOnHttp;
if (Object.keys(payload).length === 0) return;
await this.client.POST(`/instance/${this.id}/wake-on`, {}, payload);
await this.refresh();
}
async snapshot(options: InstanceSnapshotOptions = {}): Promise<Snapshot> {

@@ -519,5 +569,7 @@ const digest = options.digest || undefined;

} catch (error: any) {
// Convert timeout errors to more user-friendly TimeoutError
// Convert timeout errors to more user-friendly message (timeout is in seconds)
if (this._isTimeoutError(error)) {
throw new Error(`Command execution timed out after ${timeout ? (timeout / 1000) : '24 hours'} ${timeout ? (timeout / 1000 === 1 ? 'second' : 'seconds') : ''}`);
throw new Error(
`Command execution timed out after ${timeout ? timeout : '24 hours'} ${timeout ? (timeout === 1 ? 'second' : 'seconds') : ''}`
);
}

@@ -630,5 +682,7 @@ throw error;

} catch (error: any) {
// Convert timeout errors to more user-friendly TimeoutError
// Convert timeout errors to more user-friendly message (timeout is in seconds)
if (this._isTimeoutError(error)) {
throw new Error(`Command execution timed out after ${timeout ? (timeout / 1000) : '24 hours'} ${timeout ? (timeout / 1000 === 1 ? 'second' : 'seconds') : ''}`);
throw new Error(
`Command execution timed out after ${timeout ? timeout : '24 hours'} ${timeout ? (timeout === 1 ? 'second' : 'seconds') : ''}`
);
}

@@ -648,4 +702,6 @@ throw error;

const startTime = Date.now();
const hasTimeout = timeout !== undefined;
const limitMs = hasTimeout ? timeout! * 1000 : undefined;
while (this.status !== InstanceStatus.READY) {
if (timeout && Date.now() - startTime > timeout * 1000) {
if (hasTimeout && Date.now() - startTime > (limitMs as number)) {
throw new Error("Instance did not become ready before timeout");

@@ -1452,3 +1508,3 @@ }

start: async (options: InstanceStartOptions): Promise<Instance> => {
const { snapshotId, metadata, ttlSeconds, ttlAction } = options;
const { snapshotId, metadata, ttlSeconds, ttlAction, timeout } = options;

@@ -1473,2 +1529,31 @@ // Build query parameters

const response = await this.POST("/instance", queryParams, body);
const instance = new Instance(response, this);
try {
// Wait for instance to become READY. Undefined => wait indefinitely, 0 => immediate timeout
await instance.waitUntilReady(timeout);
} catch (e) {
// Attempt cleanup on failure
try {
await instance.stop();
} catch (cleanupError) {
// Log cleanup error and rethrow original
console.error(`Failed to cleanup instance ${instance.id}:`, cleanupError);
}
throw e;
}
return instance;
},
boot: async (options: InstanceBootOptions): Promise<Instance> => {
const { snapshotId, vcpus, memory, diskSize, metadata, ttlSeconds, ttlAction } = options;
const body: any = {};
if (vcpus !== undefined) body.vcpus = vcpus;
if (memory !== undefined) body.memory = memory;
if (diskSize !== undefined) body.disk_size = diskSize;
if (metadata !== undefined) body.metadata = metadata;
if (ttlSeconds !== undefined) body.ttl_seconds = ttlSeconds;
if (ttlAction !== undefined) body.ttl_action = ttlAction;
const response = await this.POST(`/snapshot/${snapshotId}/boot`, {}, body);
return new Instance(response, this);

@@ -1507,5 +1592,8 @@ },

InstanceStartOptions,
InstanceBootOptions,
InstanceSnapshotOptions,
InstanceGetOptions,
InstanceStopOptions,
InstanceTTL,
InstanceWakeOn,
};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display