How to handle sensitive information in js?

problem description

what"s wrong with the appid secretKey that calls Wechat"s token exposed in js?

the environmental background of the problems and what methods you have tried

Compression without encryption will cause online js code to run with an error

related codes

getOpenId: function getOpenId(code) {
        return _jquery2["default"].get("https://api.weixin.qq.com/sns/oauth2/access_token", {
          appid: "xxxxxx", //
          secret: "yyyyy", //and 
          code: code,
          grant_type: "authorization_code"
        });
      },

what result do you expect? What is the error message actually seen?

expect not to get appid secret directly from js, or others will go to http://work.weixin.qq.com/api.
call

.
May.12,2021

  1. the information in js cannot be completely masked. You can deal with it in some ways, but it just makes it more difficult for others to get (basically equivalent to putting a newspaper on a bundle of banknotes)
  2. when Wechat designed it, the, app id was public, but the secret key was confidential, so you need a backend to help you deal with situations where you need secret key.

this is not your request. You pass the code to the backend and then request


secret certainly can't be put at the front desk. This thing is originally put in the background for use in the background.

and even if you put it on the front end, you can't solve the cross-domain problem of interface calls.


tonken is used by the backend to obtain the TONKEN calculation key of JSDK and return it to the frontend research JSDK API. The frontend only needs to call appId, and backing to return a random string and timestamp, and the secret key is fine.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3260e-2be14.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3260e-2be14.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?