{"_id":"@allsquare/react-apple-signin-auth","_rev":"2-d5b4af643a8fb95cbecde1ce6e75f2b5","name":"@allsquare/react-apple-signin-auth","dist-tags":{"latest":"0.0.6-b"},"versions":{"0.0.6-a":{"name":"@allsquare/react-apple-signin-auth","version":"0.0.6-a","description":" Apple signin for React using the official Apple JS SDK","author":{"name":"Ahmed Tarek","email":"ahmed.tokyo1@gmail.com","url":"https://github.com/A-Tokyo"},"repository":{"type":"git","url":"https://github.com/allsquare/react-apple-signin-auth"},"main":"dist/index.js","homepage":"https://github.com/a-tokyo/react-apple-signin-auth#readme","bugs":{"url":"https://github.com/a-tokyo/react-apple-signin-auth/issues"},"scripts":{"start":"webpack-dev-server --mode development","transpile":"babel src -d dist --copy-files","prepublishOnly":"npm run transpile","build":"webpack --mode production","deploy":"gh-pages -d demo/dist","publish-demo":"npm run build && npm run deploy","test":"jest"},"peerDependencies":{"react":">= 16.8.0","react-dom":">= 16.8.0"},"devDependencies":{"@babel/cli":"^7.11.6","@babel/core":"^7.11.6","@babel/preset-env":"^7.11.5","@babel/preset-flow":"^7.10.4","@babel/preset-react":"^7.10.4","@testing-library/jest-dom":"^5.11.4","@testing-library/react-hooks":"^3.4.2","babel-loader":"^8.1.0","css-loader":"^4.3.0","enzyme":"^3.11.0","enzyme-adapter-react-16":"^1.15.5","enzyme-to-json":"^3.6.1","eslint":"^7.10.0","eslint-config-airbnb":"^18.2.0","eslint-config-prettier":"^6.12.0","eslint-plugin-flowtype":"^3.13.0","eslint-plugin-import":"^2.14.0","eslint-plugin-jsx-a11y":"^6.1.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react":"^7.11.0","flow-bin":"^0.135.0","gh-pages":"^3.1.0","html-webpack-plugin":"^4.5.0","husky":"^4.3.0","jest":"^26.4.2","jest-cli":"^26.4.2","jest-enzyme":"^7.1.2","lint-staged":"^10.4.0","plato":"^1.7.0","prettier":"^2.1.2","react":"^16.13.1","react-dom":"^16.13.1","react-syntax-highlighter":"^13.5.3","regenerator-runtime":"^0.13.7","style-loader":"^1.2.1","webpack":"^4.44.2","webpack-cli":"^3.3.12","webpack-dev-server":"^3.11.0"},"husky":{"hooks":{"pre-commit":"lint-staged && eslint . --fix"}},"lint-staged":{"*.js":["prettier --write","git add"]},"license":"MIT","keywords":["apple","signin","login","auth","authentication","react","react-component","react-apple","apple-js","apple-sdk","apple-id","appleID","apple-signin","demo","popup","modal","no-redirect","jwt","es6","vue","vue-apple","flow","types"],"contributors":[{"name":"Ahmed Tarek","email":"ahmed.tokyo1@gmail.com","url":"https://github.com/A-Tokyo"},{"name":"Jordan Becker","url":"https://github.com/habovh"}],"licenseText":"MIT License\n\nCopyright (c) 2020 Ahmed Tarek\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","_id":"@allsquare/react-apple-signin-auth@0.0.6-a","dist":{"shasum":"86eb26a840101df136373c2771457cf4c5779a7e","integrity":"sha512-Qc1XPqMlmReXmXJ67vA8e7okTWXpxh/Vr0xFEfxAQ8nZBSBdLX/i4DX0PDtt9OpjHQ4Gwhbtv5K5Ba9knLiDVA==","tarball":"https://registry.npmjs.org/@allsquare/react-apple-signin-auth/-/react-apple-signin-auth-0.0.6-a.tgz","fileCount":22,"unpackedSize":38961,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfnDndCRA9TVsSAnZWagAA410P/19yi6rnq/pU46Yj2aLZ\nYyWN+/m2n45Ncjad0VddG9KaF8J8OUtBpnO8qGkvb+D6W2xtNgkGAm0Up9L+\nyVZNKmMj1RJK3npXxg02VPK94UUbTqK71+ys6Wy4VgG24dPECruHadQ9SkF5\nnx1FdUv5yd1cUi8rBnFE1XqAN3Rn/LIxXQbQy1v/mil2X9Vhcrnv056vM7RS\n2Xqculr7ukgT7y5x579A9shRKW15hdenm4N3nfzxRcpk/76pYv9xPHU4Gu3N\nvo1UJKd/fARAqRRHMumpLWjt1CiCWpJFTfd6IJncdyw4BHoix24NF9W2GrGs\nMac7zqbeMmIynYahFTtNfZvHAq4j0BHlud9H+5IQevJk1J1VzfWplJgVEXMd\nuc/HHeO89xgfsrG3hOSX37hokAzhF7lXI65Di3DH/LoRmjGkbwFbb3PlF0M0\nmcXu/J5wB+UlvxeL43F2rBhxyuh+Gh0i1OUZiYDUm54uHCA36Re68NTthQqR\nYVjml5OKlBDnhjM9VT0e+q0HHsSgTtz7bATeXxSQsw2IUkjkxzHZV6aMfOAF\nzuxIR75/rNEYXTq0H++CYZ2+wU3/++72ITFY3XWbx0+ytM4/Qs3l0aXLk9Iz\nXD2PuUmz3e+XETsTHWFqVlRap3mUG549+Pgws8opYvghDWCWjkFkOQ/j4j4j\n7PSl\r\n=2IXt\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCPf80/4zXSjzDs+GrINwXyvFr3d5a6wjYaAXmcexDcjAIhAIp0jeSwVKQab938ONWggB6QTjMxj3gkeYL9b0FBJR+Z"}]},"maintainers":[{"name":"habovh","email":"jordanbeckerfr@gmail.com"}],"_npmUser":{"name":"habovh","email":"jordanbeckerfr@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-apple-signin-auth_0.0.6-a_1604073948462_0.8702859605290838"},"_hasShrinkwrap":false},"0.0.6-b":{"name":"@allsquare/react-apple-signin-auth","version":"0.0.6-b","description":" Apple signin for React using the official Apple JS SDK","author":{"name":"Ahmed Tarek","email":"ahmed.tokyo1@gmail.com","url":"https://github.com/A-Tokyo"},"repository":{"type":"git","url":"https://github.com/allsquare/react-apple-signin-auth"},"main":"dist/index.js","homepage":"https://github.com/allsquare/react-apple-signin-auth#readme","bugs":{"url":"https://github.com/allsquare/react-apple-signin-auth/issues"},"scripts":{"start":"webpack-dev-server --mode development","transpile":"babel src -d dist --copy-files","prepublishOnly":"npm run transpile","build":"webpack --mode production","deploy":"gh-pages -d demo/dist","publish-demo":"npm run build && npm run deploy","test":"jest"},"peerDependencies":{"react":">= 16.8.0","react-dom":">= 16.8.0"},"devDependencies":{"@babel/cli":"^7.11.6","@babel/core":"^7.11.6","@babel/preset-env":"^7.11.5","@babel/preset-flow":"^7.10.4","@babel/preset-react":"^7.10.4","@testing-library/jest-dom":"^5.11.4","@testing-library/react-hooks":"^3.4.2","babel-loader":"^8.1.0","css-loader":"^4.3.0","enzyme":"^3.11.0","enzyme-adapter-react-16":"^1.15.5","enzyme-to-json":"^3.6.1","eslint":"^7.10.0","eslint-config-airbnb":"^18.2.0","eslint-config-prettier":"^6.12.0","eslint-plugin-flowtype":"^3.13.0","eslint-plugin-import":"^2.14.0","eslint-plugin-jsx-a11y":"^6.1.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react":"^7.11.0","flow-bin":"^0.135.0","gh-pages":"^3.1.0","html-webpack-plugin":"^4.5.0","husky":"^4.3.0","jest":"^26.4.2","jest-cli":"^26.4.2","jest-enzyme":"^7.1.2","lint-staged":"^10.4.0","plato":"^1.7.0","prettier":"^2.1.2","react":"^16.13.1","react-dom":"^16.13.1","react-syntax-highlighter":"^13.5.3","regenerator-runtime":"^0.13.7","style-loader":"^1.2.1","webpack":"^4.44.2","webpack-cli":"^3.3.12","webpack-dev-server":"^3.11.0"},"husky":{"hooks":{"pre-commit":"lint-staged && eslint . --fix"}},"lint-staged":{"*.js":["prettier --write","git add"]},"license":"MIT","keywords":["apple","signin","login","auth","authentication","react","react-component","react-apple","apple-js","apple-sdk","apple-id","appleID","apple-signin","demo","popup","modal","no-redirect","jwt","es6","vue","vue-apple","flow","types"],"contributors":[{"name":"Ahmed Tarek","email":"ahmed.tokyo1@gmail.com","url":"https://github.com/A-Tokyo"},{"name":"Jordan Becker","url":"https://github.com/habovh"}],"licenseText":"MIT License\n\nCopyright (c) 2020 Ahmed Tarek\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","_id":"@allsquare/react-apple-signin-auth@0.0.6-b","dist":{"shasum":"4df76b07567fd67ef58170272ca566a57413c3bb","integrity":"sha512-6sNGxlJ1nxJf1rGwEPTlKzy9e7/MRJNpUEIXhHmCadaR9JNqisystmjPcwddmiJuaFTGVCrljAoelOxrp+OGlA==","tarball":"https://registry.npmjs.org/@allsquare/react-apple-signin-auth/-/react-apple-signin-auth-0.0.6-b.tgz","fileCount":22,"unpackedSize":35641,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfnE4lCRA9TVsSAnZWagAA7JUP/3I55aPLrX6xAJpbHxmv\ndCdOZqW8qb92dk7HA37Yd7HZRojRh14606YzcvzznaMNgKg32s2fYbOsAN7e\n+0oinc//PyTTkShp86X2QSYE0JXlz16tx5Mr6HlepkgjqNVhMmvIbadvZSSd\nyT8dS8obGh/FdgUY4e9MzvOcLW2Aga21HdGNqud66RtmeA70FXRaD44RmQN4\nuYqZZhLUKyLkZNDzHsVx2SjSEyNU02lQK6ae6kswFvghoN9M3mFbGp6k16VG\nHIZH8Vp6dOS1VAwf7ch3xONKb/aUDplw29rOX4j/0ltS1SVE1kwUESI1IULU\nn1rQyjXrNGmbpKa9hM/DpLeu3RfXJTb7ri0wgJxYTSMReiVsnlo+2DczLf5W\ntmTyN4tgPfsaH3EK9pwQc61JWxoR9rfK/7jxBWtQplpIo6I/Nv3xcaUHs4c7\nnoraRfvG0JAwnqiHDNtzAdXT6YHFo5QU4nMEEShUqLOnNm4lbh3LrATjfaXm\ndROqwvYf8FePK6GuJkYafm4jfxH9azbwN/WJ+AUz8xaWSZf0hh1BCpuzp0Bw\nv+tyJIMbfpu7HdFf5O9Xdki12Vqat8Rl6O31nGEqBD7IvvMdkJTEJ38r5m0e\nV2ssL68hW9dc5tpG4VfJ07d2+ArXy8foMxaezNkYvWkTJe2P3V+qQJ23MM7u\nUJsm\r\n=QXG/\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDJc2hTmr97/Z/yPMHo4xEAi3oGeiAH39LtiO9q2tA4FAIgLuFx8IrCCgduL4DThtjDH7m1iCCcw6BHMOvZia26Fu4="}]},"maintainers":[{"name":"habovh","email":"jordanbeckerfr@gmail.com"}],"_npmUser":{"name":"habovh","email":"jordanbeckerfr@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-apple-signin-auth_0.0.6-b_1604079141372_0.00655847281030475"},"_hasShrinkwrap":false}},"time":{"created":"2020-10-30T16:05:48.220Z","0.0.6-a":"2020-10-30T16:05:48.622Z","modified":"2022-04-04T13:34:43.973Z","0.0.6-b":"2020-10-30T17:32:21.544Z"},"maintainers":[{"name":"habovh","email":"jordanbeckerfr@gmail.com"}],"description":" Apple signin for React using the official Apple JS SDK","homepage":"https://github.com/allsquare/react-apple-signin-auth#readme","keywords":["apple","signin","login","auth","authentication","react","react-component","react-apple","apple-js","apple-sdk","apple-id","appleID","apple-signin","demo","popup","modal","no-redirect","jwt","es6","vue","vue-apple","flow","types"],"repository":{"type":"git","url":"https://github.com/allsquare/react-apple-signin-auth"},"contributors":[{"name":"Ahmed Tarek","email":"ahmed.tokyo1@gmail.com","url":"https://github.com/A-Tokyo"},{"name":"Jordan Becker","url":"https://github.com/habovh"}],"author":{"name":"Ahmed Tarek","email":"ahmed.tokyo1@gmail.com","url":"https://github.com/A-Tokyo"},"bugs":{"url":"https://github.com/allsquare/react-apple-signin-auth/issues"},"license":"MIT","readme":"# react-apple-signin-auth\n\n Apple signin for React using the official Apple JS SDK\n\n<a href=\"https://npmjs.com/package/react-apple-signin-auth\">\n  <img src=\"https://img.shields.io/npm/v/react-apple-signin-auth.svg\"></img>\n  <img src=\"https://img.shields.io/npm/dt/react-apple-signin-auth.svg\"></img>\n</a>\n<a href=\"https://codecov.io/gh/A-Tokyo/react-apple-signin-auth\">\n  <img src=\"https://img.shields.io/codecov/c/github/a-tokyo/react-apple-signin-auth.svg\"></img>\n</a>\n<a href=\"https://twitter.com/intent/follow?screen_name=ahmad_tokyo\"><img src=\"https://img.shields.io/twitter/follow/ahmad_tokyo.svg?label=Follow%20@ahmad_tokyo\" alt=\"Follow @ahmad_tokyo\"></img></a>\n\n[Checkout the demo for a quick start!](https://a-tokyo.github.io/react-apple-signin-auth)\n\n## Prerequisites\n1. You should be enrolled in [Apple Developer Program](https://developer.apple.com/programs/).\n2. Please have a look at [Apple documentation](\nhttps://developer.apple.com/sign-in-with-apple/get-started/) related to \"Sign in with Apple\" feature.\n3. You should create App ID and Service ID in your Apple Developer Account.\n4. You should generate private key for your Service ID in your Apple Developer Account.\n\n## Apple Signin Setup\nDeatiled confuguration instructions can be found at [blog post](https://medium.com/@artyomefremov/add-sign-in-with-apple-button-to-your-website-today-part-1-12ed1444623a?postPublishedType=initial) and [Apple docs](https://help.apple.com/developer-account/#/dev1c0e25352) and [official apple docs for webpage signin](https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_js/configuring_your_webpage_for_sign_in_with_apple).\n\n## Installation\n\n```bash\nnpm i react-apple-signin-auth\n```\nOR\n```bash\nyarn add react-apple-signin-auth\n```\n\n## Usage\n[Checkout the demo for a quick start!](https://a-tokyo.github.io/react-apple-signin-auth)\n```js\nimport AppleSignin from 'react-apple-signin-auth';\n\n/** Apple Signin button */\nconst MyAppleSigninButton = () => (\n  <AppleSignin\n    /** Auth options passed to AppleID.auth.init() */\n    authOptions={{\n      /** Client ID - eg: 'com.example.com' */\n      clientId: 'com.example.web',\n      /** Requested scopes, seperated by spaces - eg: 'email name' */\n      scope: 'email name',\n      /** 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 */\n      redirectURI: 'https://example.com',\n      /** State string that is returned with the apple response */\n      state: 'state',\n      /** Nonce */\n      nonce: 'nonce',\n      /** Uses popup auth instead of redirection */\n      usePopup: ${authOptions.usePopup},\n    }} // REQUIRED\n    /** General props */\n    uiType=\"dark\"\n    /** Extra controlling props */\n    /** Called upon signin success in case authOptions.usePopup = true -- which means auth is handled client side */\n    onSuccess={(response) => console.log(response)} // default = undefined\n    /** Called upon signin error */\n    onError={(error) => console.error(error)} // default = undefined\n    /** Skips loading the apple script if true */\n    skipScript={false} // default = undefined\n    /** Apple image props */\n    iconProp={{ style: { marginTop: '10px' } }} // default = undefined\n    /** render function - called with all props - can be used to fully customize the UI by rendering your own component  */\n    render={(props) => <button {...props}>My Custom Button</button>}\n  />\n);\n\nexport default MyAppleSigninButton;\n```\n\n### Raw JS functionality\na 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...\n```js\nimport { appleAuthHelpers } from 'react-apple-signin-auth';\n// OR\n// import appleAuthHelpers from 'react-apple-signin-auth/dist/appleAuthHelpers'; // @unstable - might change with upgrades\n\n/**\n * perform apple signIn operation\n */\nappleAuthHelpers.signIn({\n  authOptions: {\n    // same as above\n  },\n  onSuccess: (response) => console.log(response),\n  onError: (error) => console.error(error),\n});\n\n// OR\n\n/** promisified version - promise resolves with response on success or undefined on error -- note that this only work with usePopup: true */\nconst response = await appleAuthHelpers.signIn({\n  authOptions: {\n    // same as above\n  },\n  onError: (error) => console.error(error),\n});\n\nif (response) {\n  console.log(response);\n} else {\n  console.error('Error performing apple signin.');\n}\n\n```\n\n## Server-side authentication (nodeJS backend)\nAnother library exists for server/backend support for Apple signin [apple-signin-auth](https://github.com/A-Tokyo/apple-signin-auth)\n\n### Usage\n- Install the library `yarn add apple-signin-auth` OR `npm i apple-signin-auth`\n- Implement JWT verification logic\n  ```js\n  const appleSignin = require(\"apple-signin-auth\");\n\n\n  const { authorization, user } = req.body;\n\n  try {\n    const { sub: userAppleId } = await appleSignin.verifyIdToken(\n      authorization.id_token, // We need to pass the token that we wish to decode.\n      {\n        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.\n        nonce: 'nonce' // nonce - The same one we used on the frontend - OPTIONAL\n      }\n    );\n  } catch (err) {\n    // Token is not verified\n    console.error(err);\n  }\n  ```\n#### Further resources:\n- https://dev.to/onygami/how-to-add-signin-with-apple-on-your-website-43m9\n\n### Related Projects\n- [Apple Signin for Node JS](https://github.com/A-Tokyo/apple-signin-auth)\n- [Apple Signin for React Native](https://github.com/invertase/react-native-apple-authentication)\n\n## Contributing\nPull requests are highly appreciated! For major changes, please open an issue first to discuss what you would like to change.\n\n### Getting Started\n- Clone the repo: `git clone https://github.com/a-tokyo/react-apple-signin-auth`\n- Install deps: `yarn`\n- Start webpack development server on [localhost:3001](http://localhost:3001): `yarn start`\n- To run/update the tests locally, run: `yarn test -u`\n\n## Roadmap / Todos\n- Better UI for the demo. eg: tailwind\n- Typescript support\n","readmeFilename":"README.md"}