Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@allsquare/react-apple-signin-auth
Advanced tools
Readme
Apple signin for React using the official Apple JS SDK
Checkout the demo for a quick start!
Deatiled confuguration instructions can be found at blog post and Apple docs and official apple docs for webpage signin.
npm i react-apple-signin-auth
OR
yarn add react-apple-signin-auth
Checkout the demo for a quick start!
import AppleSignin from 'react-apple-signin-auth';
/** Apple Signin button */
const MyAppleSigninButton = () => (
<AppleSignin
/** Auth options passed to AppleID.auth.init() */
authOptions={{
/** Client ID - eg: 'com.example.com' */
clientId: 'com.example.web',
/** Requested scopes, seperated by spaces - eg: 'email name' */
scope: 'email name',
/** Apple's redirectURI - must be one of the URIs you added to the serviceID - the undocumented trick in apple docs is that you should call auth from a page that is listed as a redirectURI, localhost fails */
redirectURI: 'https://example.com',
/** State string that is returned with the apple response */
state: 'state',
/** Nonce */
nonce: 'nonce',
/** Uses popup auth instead of redirection */
usePopup: ${authOptions.usePopup},
}} // REQUIRED
/** General props */
uiType="dark"
/** Extra controlling props */
/** Called upon signin success in case authOptions.usePopup = true -- which means auth is handled client side */
onSuccess={(response) => console.log(response)} // default = undefined
/** Called upon signin error */
onError={(error) => console.error(error)} // default = undefined
/** Skips loading the apple script if true */
skipScript={false} // default = undefined
/** Apple image props */
iconProp={{ style: { marginTop: '10px' } }} // default = undefined
/** render function - called with all props - can be used to fully customize the UI by rendering your own component */
render={(props) => <button {...props}>My Custom Button</button>}
/>
);
export default MyAppleSigninButton;
a module called appleAuthHelpers
is also exported to allow you to use the functionality without using the UI or relying on React. This works with any kind of frontend JS, eg: react, vue, etc...
import { appleAuthHelpers } from 'react-apple-signin-auth';
// OR
// import appleAuthHelpers from 'react-apple-signin-auth/dist/appleAuthHelpers'; // @unstable - might change with upgrades
/**
* perform apple signIn operation
*/
appleAuthHelpers.signIn({
authOptions: {
// same as above
},
onSuccess: (response) => console.log(response),
onError: (error) => console.error(error),
});
// OR
/** promisified version - promise resolves with response on success or undefined on error -- note that this only work with usePopup: true */
const response = await appleAuthHelpers.signIn({
authOptions: {
// same as above
},
onError: (error) => console.error(error),
});
if (response) {
console.log(response);
} else {
console.error('Error performing apple signin.');
}
Another library exists for server/backend support for Apple signin apple-signin-auth
yarn add apple-signin-auth
OR npm i apple-signin-auth
const appleSignin = require("apple-signin-auth");
const { authorization, user } = req.body;
try {
const { sub: userAppleId } = await appleSignin.verifyIdToken(
authorization.id_token, // We need to pass the token that we wish to decode.
{
audience: "com.example.web", // client id - The same one we used on the frontend, this is the secret key used for encoding and decoding the token.
nonce: 'nonce' // nonce - The same one we used on the frontend - OPTIONAL
}
);
} catch (err) {
// Token is not verified
console.error(err);
}
Pull requests are highly appreciated! For major changes, please open an issue first to discuss what you would like to change.
git clone https://github.com/a-tokyo/react-apple-signin-auth
yarn
yarn start
yarn test -u
FAQs
Apple signin for React using the official Apple JS SDK
The npm package @allsquare/react-apple-signin-auth receives a total of 37 weekly downloads. As such, @allsquare/react-apple-signin-auth popularity was classified as not popular.
We found that @allsquare/react-apple-signin-auth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.