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

proxyauth

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proxyauth

模拟登陆过程,用于前后端分离开发时,作为中间服务将前端接口代理到测试或线上环境,并添加cookies,以及方便的进行代理方案切换,避免重启编译的耗时。 使用puppeteer进行模拟登陆,会根据set-cookie保存cookie, 在代理中携带。

latest
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

proxyauth

模拟登陆过程,用于前后端分离开发时,作为中间服务将前端接口代理到测试或线上环境,并添加cookies,以及方便的进行代理方案切换,避免重启编译的耗时。 使用puppeteer进行模拟登陆,会根据set-cookie保存cookie, 在代理中携带。

Install

npm i -g proxyauth

Usage

proxyauth

根据提示输入对应内容
配置项目的代理指向当前服务及端口.
例:通过vue-cli创建的项目中,修改vue.config.js

module.exports = {
  devServer: {
    proxy: {
      '/api': {
        target: 'http://localhost:5000',
        ws: true,
        changeOrigin: true
      }
    }
  }
}

指令

  • proxyauth clear 清除本地保存的开发者信息
  • proxyauth -p <port> 指定端口
  • proxyauth -t <url> 更新代理URL
  • proxyauth -d 清除本地保存的配置
  • proxyauth -c <config file path> 指定配置文件地址,默认读取 .proxyauth.cfg.json.
  • proxyauth -h 查看帮助
  • proxyauth <any> 等同于执行proxyauth && npm run <any>

Config file (Optional)

创建文件 .proxyauth.cfg.json.

{
  "proxyUrl": "https://example.com",
  "port": 5000,
  "submitSelector": "form [type=submit]",
  "checkNeedLogin": "response => response.statusCode === 302",
  "input": [
    {
      "selector": "form [name=username]",
      "value": "username"
    },
    {
      "selector": "form [name=password]",
      "value": "password"
    }
  ]
}
字段说明必填
proxyUrl代理地址,访问后必须自动跳转到登陆界面必填
port服务端口, 可以将前端项目proxy指向此服务,默认5000必填
checkNeedLogin接口代理时已此为依据判断是否需要重新进行登陆过程,例:response => response.statusCode === 401,接口返回状态码为401时,会进行登陆过程。 r默认:response => false
submitSelector提交按钮的选择器(等同于querySelector),按钮存在时进行输入,输入完成会点击提交。默认:form [type=submit]必填
input用于输入用户名密码等输入项。类型为数组。
[input].selector输入项选择器必填
[input].value输入值

运行过程中主动切换和刷新登陆

  • 输入 c 根据提示更新代理地址后重新进行登陆过程
  • 输入 r 重新进行登陆过程

FAQs

Package last updated on 17 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts