const nodersa = require('node-rsa')
const axios = require('axios')
const express = require('express')
const server = express()
const PRIVATE_KEY = "-----BEGIN PRIVATE KEY-----YOUR KEY HERE-----END PRIVATE KEY-----"
const key = new nodersa(PRIVATE_KEY, 'pkcs8-private-pem', { encryptionScheme: 'pkcs1' })
const AppKey = 'AppKey'
const MasterSecret = 'MasterSecret'
const Authorization = new Buffer(`${AppKey}:${MasterSecret}`).toString('base64')
server.post('/api/loginWithToken', async function (req, res) {
const { loginWithToken } = req.body
const { data } = await axios.post(
'https://api.verification.jpush.cn/v1/web/loginTokenVerify',
{ loginToken },
{ headers: { Authorization }, auth: { username: AppKey, password: MasterSecret } }
)
const phone = key.decrypt(data.phone, 'utf-8')
})
server.listen(3000, console.log)
Last active
December 31, 2019 07:31
-
-
Save crapthings/2f5387b7189fa2d17589a9bcba3d388a to your computer and use it in GitHub Desktop.
import nodersa from 'node-rsa'
import axios from 'axios'
const PRIVATE_KEY = "-----BEGIN PRIVATE KEY-----YOUR KEY HERE-----END PRIVATE KEY-----"
const key = new nodersa(PRIVATE_KEY, 'pkcs8-private-pem', { encryptionScheme: 'pkcs1' })
const AppKey = 'AppKey'
const MasterSecret = 'MasterSecret'
const Authorization = new Buffer(`${AppKey}:${MasterSecret}`).toString('base64')
Meteor.methods({
async loginWithToken(loginToken) {
const { data } = await axios.post(
'https://api.verification.jpush.cn/v1/web/loginTokenVerify',
{ loginToken },
{ headers: { Authorization }, auth: { username: AppKey, password: MasterSecret } }
)
const phone = key.decrypt(data.phone, 'utf-8')
}
})
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment