@mgcloud/lib-base
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

🚀 @mgcloud/lib-base

提供了一些基础功能和工具的封装。

  • request: 简化的网络请求功能
  • security: 前端安全 (防止 XSS 攻击)

使用示例

import { ref } from 'vue'
import { request, xssFilter } from '@mgcloud/lib-base'

interface LoginByCodesTypes {
  code: string
  mobile: string
}

interface LoginByCodesResultTypes {
  token: string
}

export function loginByCodesApi(data: LoginByCodesTypes) {
  return request<LoginByCodesResultTypes>({
    baseURL: '/api',
    url: `/user/loginByCodes`,
    method: 'post',
    data,
  })
}

const xssHtml = ref(
`
<h1 id="title">XSS Demo</h1>

<p class="text-center">
Sanitize untrusted HTML (to prevent XSS) with a configuration specified by a Whitelist.
</p>

<form>
  <input type="text" name="q" value="test">
  <button id="submit">Submit</button>
</form>

<pre>hello</pre>

<p>
  <a href="http://jsxss.com">http</a>
  <a href="https://jsxss.com">https</a>
  <a href="ftp://jsxss.com">ftp</a>
  <a href="other1">other1</a>
  <a href="/other2">other2</a>
  <a href="#">other3</a>
</p>

<h3 style="color: #fff;">Features:</h3>
<ul>
  <li>Specifies HTML tags and their attributes allowed with whitelist</li>
  <li>Handle any tags or attributes using custom function</li>
</ul>

<script type="text/javascript">
alert(/xss/);
<\/script>
`,
)

console.log(xssFilter(xssHtml.value))

Readme

Keywords

Package Sidebar

Install

npm i @mgcloud/lib-base

Weekly Downloads

54

Version

1.1.0

License

MIT

Unpacked Size

252 kB

Total Files

8

Last publish

Collaborators

  • wuchendi