| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- const OperatorID = '730998640' // Requester ID
- const payload = {
- OperatorID: OperatorID,
- Data: undefined,
- TimeStamp: getUTCFormatTime(),
- Seq: '0001',
- Sig: undefined,
- }
- const data = {
- OperatorID: OperatorID,
- OperatorSecret: secret.operatorSecret, // Servicer Secret
- }
- const aesCipher = new AESCipher()
- const hmacCipher = new HmacCipher()
- const encryptData = aesCipher.encrypt(
- JSON.stringify(data),
- secret.dataSecret,
- secret.dataSecretIV
- )
- payload.Data = encryptData
- const constructHashText =
- payload.OperatorID + payload.Data + payload.TimeStamp + payload.Seq
- const sign = hmacCipher.hmacMD5Sign(constructHashText, secret.sigSecret)
- payload.Sig = sign
- console.log('Payload:', payload)
- const targetUrl = 'https://evtry.qihui.net/evnet/evcs/equipment/v1/query_token'
- fetch(targetUrl, {
- body: JSON.stringify(payload),
- headers: {
- 'Content-Type': 'application/json;charset=UTF-8',
- Accept: 'application/json, text/plain',
- },
- method: 'POST',
- mode: 'no-cors'
- }).then(async (resp) => {
- console.log(await resp.text())
- })
|