Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 3.145.88.20
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/node_modules/npm/node_modules/libnpmaccess/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /lib/node_modules/npm/node_modules/libnpmaccess/lib/index.js
'use strict'

const npa = require('npm-package-arg')
const npmFetch = require('npm-registry-fetch')

const npar = (spec) => {
  spec = npa(spec)
  if (!spec.registry) {
    throw new Error('must use package name only')
  }
  return spec
}

const parseTeam = (scopeTeam) => {
  let slice = 0
  if (scopeTeam.startsWith('@')) {
    slice = 1
  }
  const [scope, team] = scopeTeam.slice(slice).split(':').map(encodeURIComponent)
  return { scope, team }
}

const getPackages = async (scopeTeam, opts) => {
  const { scope, team } = parseTeam(scopeTeam)

  let uri
  if (team) {
    uri = `/-/team/${scope}/${team}/package`
  } else {
    uri = `/-/org/${scope}/package`
  }
  try {
    return await npmFetch.json(uri, opts)
  } catch (err) {
    if (err.code === 'E404') {
      uri = `/-/user/${scope}/package`
      return npmFetch.json(uri, opts)
    }
    throw err
  }
}

const getCollaborators = async (pkg, opts) => {
  const spec = npar(pkg)
  const uri = `/-/package/${spec.escapedName}/collaborators`
  return npmFetch.json(uri, opts)
}

const getVisibility = async (pkg, opts) => {
  const spec = npar(pkg)
  const uri = `/-/package/${spec.escapedName}/visibility`
  return npmFetch.json(uri, opts)
}

const setAccess = async (pkg, access, opts) => {
  const spec = npar(pkg)
  const uri = `/-/package/${spec.escapedName}/access`
  await npmFetch(uri, {
    ...opts,
    method: 'POST',
    body: { access },
    spec,
    ignoreBody: true,
  })
  return true
}

const setMfa = async (pkg, level, opts) => {
  const spec = npar(pkg)
  const body = {}
  switch (level) {
    case 'none':
      body.publish_requires_tfa = false
      break
    case 'publish':
      // tfa is required, automation tokens can not override tfa
      body.publish_requires_tfa = true
      body.automation_token_overrides_tfa = false
      break
    case 'automation':
      // tfa is required, automation tokens can override tfa
      body.publish_requires_tfa = true
      body.automation_token_overrides_tfa = true
      break
    default:
      throw new Error(`Invalid mfa setting ${level}`)
  }
  const uri = `/-/package/${spec.escapedName}/access`
  await npmFetch(uri, {
    ...opts,
    method: 'POST',
    body,
    spec,
    ignoreBody: true,
  })
  return true
}

const setPermissions = async (scopeTeam, pkg, permissions, opts) => {
  const spec = npar(pkg)
  const { scope, team } = parseTeam(scopeTeam)
  if (!scope || !team) {
    throw new Error('team must be in format `scope:team`')
  }
  const uri = `/-/team/${scope}/${team}/package`
  await npmFetch(uri, {
    ...opts,
    method: 'PUT',
    body: { package: spec.name, permissions },
    scope,
    spec,
    ignoreBody: true,
  })
  return true
}

const removePermissions = async (scopeTeam, pkg, opts) => {
  const spec = npar(pkg)
  const { scope, team } = parseTeam(scopeTeam)
  const uri = `/-/team/${scope}/${team}/package`
  await npmFetch(uri, {
    ...opts,
    method: 'DELETE',
    body: { package: spec.name },
    scope,
    spec,
    ignoreBody: true,
  })
  return true
}

module.exports = {
  getCollaborators,
  getPackages,
  getVisibility,
  removePermissions,
  setAccess,
  setMfa,
  setPermissions,
}

Anon7 - 2022
AnonSec Team