npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fe-enigma-kynareth

v0.2.10

Published

前端非对称签名

Readme

Kynareth集成方式

npm install fe-enigma-kynareth

构造函数

new Kynareth()

使用方法

在main.js中:

import axios from 'axios'

import Kynareth from '@longfor/kynareth'

const kynareth = new Kynareth()

kynareth.setAdapter(axios) // 0.0.19 版本之前

kynareth.setAdapter(axios, onSubmitMaskedData, onMaskedResponseDetected) // 0.0.20以上

// 当Kynareth检测到可能正在提交脱敏数据会回调这个方法

const onSubmitMaskedData = (axiosRequestConfig) => {

   // do anything you like

   // even raise an error to stop this request

}

const onMaskedResponseDetected = (axiosResponse) => {

   // do anything you like

   // for example: mara.probe({some info useful for debug})

}

// 由于Kynareth 需要使用axios,对其进行拦截器的设置,因此需要把axios工厂实例传入Kynareth

请注意,以下说明需server端配合,如需体验,请跳转去这里安装并启用demo server

以上代码的作用是:

  • 后端统一拦截器会对字符串类型进行匹配

  • 手机号

  • 银行卡号

  • 身份证号

  • 后端拦截器对字段值进行脱敏,形式如下:

  • 179 {{????}} 4215

  • 610 {{??? ???? ????}} 1012

  • Kynareth在axios拦截器层面对字段值进行重写,将上面的脱敏值修改为

  • 610 *** **** **** 1012

  • vue render之后Kynareth会对渲染了脱敏值的dom进行修饰,在其右边添加小眼睛组件

  • 点击小眼睛组件,会发起携带非对称签名的真实数据的请求

  • 返回值仅为当前字段的未脱敏值

  • Kynareth 会利用vue的响应式原理修改组件中的data值,并响应式的渲染到dom上

关于编辑页需要的全量真实数据场景

如需response中包含全量未脱敏数据时,比如编辑页上显示的数据应该均为真实数据。

在此场景下,前端调用接口时需要自行添加标记,以便后端知道需要返回全量真实数据。

具体方法如下:

const { cnonce, signature, timestamp } = await window.kynareth.sign()
  const headers = {
    'x-enigma-cnonce': cnonce,
    'x-enigma-signature': signature,
    'x-enigma-timestamp': timestamp // 适用于 0.0.16 版本以上
  }
  axios.get('http://localhost:3000', { headers })
    .then(res => {
      console.log(res)
      state.name = res.data.name
      state.idnumber = res.data.idnumber
      state.phone = res.data.phone
    })

携带:

  • x-enigma-enonce

  • x-enigma-signature

  • x-enigma-timestamp

三个请求头时,后端会在通过签名校验后,返回不脱敏的全部字段数据