0.0.1 • Published 7 months ago

nstbrowser-node-sdk v0.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

NST BROWSER NODE SDK

Nst browser node sdk

Installing

Using npm:

$ npm install nstbrowser-sdk-node

Using pnpm:

$ pnpm install nstbrowser-sdk-node

Using yarn:

$ yarn add nstbrowser-sdk-node

How To Use

javascript:

import { NstBrowser } from 'nstbrowser-sdk-node';

const nst = new NstBrowser(your api key, option);
const { getLatestVersion } = nst.agentManager();
getLatestVersion();

typescript:

import { NstBrowser, NstBrowserTypes } from 'nstbrowser-sdk-node';

const nst: NstBrowserTypes = new NstBrowser(your api key, option);
const { getLatestVersion } = nst.agentManager();
getLatestVersion();

option:

{
  timeout: number
}

NstBrowser Node Sdk Response Schema:

{
  // `data` is the response
  data: {},
    
  // `code` is the HTTP status code
  code: 200,
  
  // `err` is the request's status
  err: false,
  
  msg: 'success'
}

AgentManager

getLatestVersion

get latest version info

const { getLatestVersion } = nst.agentManager();
getLatestVersion();

Response Data:

{
  notes: string,
  pub_date: string,
  upgradeMode: number,
  platforms: {},
  version: string
}

skipVersion

set agent skip version

const { skipVersion } = nst.agentManager();
skipVersion(version: string);

BrowserManager

start

start the browser by profileId

const { start } = nst.browserManager();
start(profileId: string);

startSome

batch start browser by profileIds

const { startSome } = nst.browserManager();
startSome(profileIds: string[]);

restart

restart the browser by profileId

const { restart } = nst.browserManager();
restart(profileId: string);

restartSome

batch restart browser by profileIds

const { restartSome } = nst.browserManager();
restartSome(profileIds: string[]);

restartAll

restart all running browser

const { restartAll } = nst.browserManager();
restartAll();

stop

stop the browser by profileId

const { stop } = nst.browserManager();
stop(profileId: string);

stopSome

batch stop browser by profileIds

const { stopSome } = nst.browserManager();
stopSome(profileIds: string[]);

stopAll

stop all running browser

const { stopAll } = nst.browserManager();
stopAll();

getRunningBrowserAll

get all running browser's info

const { getRunningBrowserAll } = nst.browserManager();
getRunningBrowserAll();

response data:

[
  {
    profileId: string,
    name: string,
    version: string,
    kernelType: string, // nstchrome | nstfirefox
    running: boolean,
    userDirPath: string
  }
]

getRemoteWebSocketDebuggingURLService

get browser remote web socket debugging url

const { getRunningBrowserAll } = nst.browserManager();
getRemoteWebSocketDebuggingURL(profileId: string);

ExtensionManager

getDownLoadExtensions

get downloaded extensions

const { getDownLoadExtensions } = nst.extensionManager();
getDownLoadExtensions();

response data:

[
  {
    extensionId: string,
    version: string
  }
]

getExtensionsFromProfileId

get extensions from profileId

const { getExtensionsFromProfileId } = nst.extensionManager();
getExtensionsFromProfileId(profileId: string);

response data:

[
  {
    id: string,
    extensionId: string,
    uploaderId: string,
    teamId: string,
    uploadType?: number,
    storeUrl?: string,
    downloadUrl?: string,
    name: {}, // classify by language, default: en
    desc: {}, // classify by language, default: en
    version: string,
    iconFullPath: string,
    pkgFullPath: string,
    isDisplay: boolean,
    createdAt: string,
    updatedAt: string,
    iconUrl: string,
    ossUrl: string,
    provider: string
  }
]

downloadExtensionsFromProfileId

download extensions from profileId

const { downloadExtensionsFromProfileId } = nst.extensionManager();
downloadExtensionsFromProfileId(profileId: string);

parseExtensionInfoFromZip

parse extension info from zip file

const fs = require('node:fs');
const FormData = require('form-data');

fs.readFile('yourExtension.zip', (err, data) => {
  if (err) return;

  const formData = new FormData();
  formData.append('file', data, {
    filename: 'yourExtension.zip',
    contentType: 'application/octet-stream'
  });

  const { parseExtensionInfoFromZip } = nst.extensionManager();
  parseExtensionInfoFromZip(formData: FormData);
})

response data:

{
  desc: {}, // classify by language, default: en
  iconExt: string,
  iconUrl: string,
  name: {}, // classify by language, default: en
  version: string
}

uploadExtensionCustom

custom upload extension

const fs = require('node:fs');
const FormData = require('form-data');

fs.readFile('yourExtension.zip', (err, data) => {
  if (err) return;

  const formData = new FormData();
  formData.append('file', data, {
    filename: 'yourExtension.zip',
    contentType: 'application/octet-stream'
  });

  const { uploadExtensionCustom } = nst.extensionManager();
  uploadExtensionCustom(formData: FormData);
})

upgradeExtensionCustom

custom upgrade extension

const fs = require('node:fs');
const FormData = require('form-data');

fs.readFile('yourExtension.zip', (err, data) => {
  if (err) return;

  const formData = new FormData();
  formData.append('file', data, {
    filename: 'yourExtension.zip',
    contentType: 'application/octet-stream'
  });
  formData.append('extensionId', extensionId: string); // required!

  const { upgradeExtensionCustom } = nst.extensionManager();
  upgradeExtensionCustom(formData: FormData);
})

KernelManager

availableList

get all local available kernel list

const { availableList } = nst.kernelManager();
availableList();

response data:

[
  {
    name: string,
    kernelType: number, // 0: nstchrome | 1: nstfirefox
    kernelMilestone: string,
    customVersion: string, // nst version
    path: string,
    size: number,
    formatSize: string
  }
]

download

download kernel

const { download } = nst.kernelManager();
download({
  kernelType: number, // 0: nstchrome | 1: nstfirefox
  kernelMilestone: string
})

downloadedList

get local all downloaded kernels

const { downloadedList } = nst.kernelManager();
downloadedList();

response data:

[
  {
    name: string,
    kernelType: number, // 0: nstchrome | 1: nstfirefox
    kernelMilestone: string,
    customVersion: string,
    path: string,
    size: number,
    formatSize: string
  }
]

getLatestVersion

get latest kernel versions

const { getLatestVersion } = nst.kernelManager();
getLatestVersion();

response data:

[
  {
    _id: string,
    kernelMilestone: string,
    customVersion: string,
    kernelType: number, // 0: nstchrome | 1: nstfirefox
    platform: number, // 0: win | 1: mac | 2: linux | 3: android | 4: ios
    platformVersion: string[],
    arch: string,
    upgradeMode: number,
    status: number,
    published: boolean,
    changelog: string,
    fullPath: string,
    filename: string,
    originalname: string,
    downloadURL: string,
    createdAt: string,
    updatedAt: string
  }
]

skipVersion

set kernel skip version

const { skipVersion } = nst.kernelManager();
skipVersion({
  kernelType: number, // 0: nstchrome | 1: nstfirefox
  milestoneVersion: string,
  customVersion: string
});

update

update kernel: replace old kernel with new kernel

const { update } = nst.kernelManager();
update({
  kernelMilestone: string,
  kernelType: number // 0: nstchrome | 1: nstfirefox
});

ProfileManager

getProfileFingerPrint

get Profile info and fingerprint data

const { getProfileFingerPrint } = nst.profileManager();
getProfileFingerPrint(profileId: string);

response data:

{
  setting: {
    profileId: string,
    name: string,
    groupId: string,
    hash: string,
    version: string,
    cookies: object[],
    startupUrls: string[],
    bookmarks: string[],
    port: string,
    proxy: string,
    kernel: number,
    kernelVersion: string,
    platform: number, // 0: win | 1: mac | 2: linux | 3: android | 4: ios
    agentUrl: string,
    extensionsIds: string[]
  },
  profile: {
    ui: {},
    global: {},
    flags: {},
    encrypted: boolean,
    fingerprint: {},
    metadata: {},
    unstable: {}
  }
}

proxyInfo

check proxy info

const { proxyInfo } = nst.profileManager();
proxyInfo(proxyStr: string);

response data:

{
  ip: string,
  proxy: {
    schema: string,
    host: string,
    port: number,
    username: string,
    password: string,
    need_auth: boolean
  },
  location: {
    countryShort: string,
    countryLong: string,
    latitude: string,
    longitude: string,
    timezone: string,
    localTime: string,
    money: string
  }
}