wwenj / sign-in-with-apple-for-node Goto Github PK
View Code? Open in Web Editor NEWApple三方登录demo,node编写
Apple三方登录demo,node编写
https://forums.developer.apple.com/thread/129047
const getAppleIDPublicKey = async (kid) => {
const url = new URL(ENDPOINT_URL);
url.pathname = '/auth/keys';
const data = await request({ url: url.toString(), method: 'GET' });
const keys = JSON.parse(data).keys;
const key = keys.find(k => k.kid === kid);
const pubKey = new NodeRSA();
pubKey.importKey({ n: Buffer.from(key.n, 'base64'), e: Buffer.from(key.e, 'base64') }, 'components-public');
return pubKey.exportKey(['public']);
};
const verifyIdToken = async (idToken, clientID) => {
const decodedToken = jwt.decode(idToken, { complete: true });
const applePublicKey = await getAppleIDPublicKey(decodedToken.header.kid);
const jwtClaims = jwt.verify(idToken, applePublicKey, { algorithms: 'RS256' });
if (jwtClaims.iss !== TOKEN_ISSUER) throw new Error('id token not issued by correct OpenID provider - expected: ' + TOKEN_ISSUER + ' | from: ' + jwtClaims.iss);
if (clientID !== undefined && jwtClaims.aud !== clientID) throw new Error('aud parameter does not include this client - is: ' + jwtClaims.aud + '| expected: ' + clientID);
if (jwtClaims.exp < (Date.now() / 1000)) throw new Error('id token has expired');
return jwtClaims;
};
请问有或者APP用户信息的方法吗
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.