{"_id":"@bonnier-publications/vue-auth-cognito","_rev":"6-05f67a84b566380fe3d286cb393c19dd","name":"@bonnier-publications/vue-auth-cognito","dist-tags":{"latest":"0.1.6"},"versions":{"0.1.6":{"name":"@bonnier-publications/vue-auth-cognito","version":"0.1.6","description":"A Vue.js Vuex module for authentication using Amazon AWS Cognito","main":"lib/index.js","scripts":{"test":"tap -Rspec --coverage --coverage-report=html test/unit/index.js","test:watch":"tape-watch test/unit/index.js -p tap-spec","compile":"babel -d lib/ src/","prepublish":"npm run compile","coverage":"tap --cov --coverage-report=html --strict test/unit/index.js"},"repository":{"type":"git","url":"git+https://github.com/kopterio/vue-auth-cognito.git"},"author":{"name":"Evgeny Zislis","email":"evgeny.zislis@gmail.com"},"contributors":[{"name":"Anton Sekatski","email":"antonsekatski@gmail.com"}],"license":"MIT","dependencies":{"amazon-cognito-identity-js":"^1.19.0","vuex":"^3.0.0"},"devDependencies":{"babel-cli":"^6.24.1","babel-eslint":"^8.0.0","babel-preset-es2015":"^6.24.1","babel-preset-stage-0":"^6.24.1","bower":"^1.8.0","codeclimate-test-reporter":"^0.5.0","cov":"^0.1.3","coveralls":"^3.0.0","eslint":"^5.0.0","eslint-config-airbnb-base":"^12.0.0","eslint-plugin-import":"^2.7.0","proxyquire":"^1.8.0","sinon":"^6.0.0","tap":"^11.0.0","tap-spec":"^5.0.0","tape":"^4.7.0","tape-watch":"^2.3.0","vue":"^2.4.1"},"release-script":{"defaultDryRun":"true","bowerRepo":"git@github.com:kopterio/vue-auth-cognito-bower.git"},"gitHead":"7db54dea9883ff63e2ad2b21ae9ef274b2e3368e","bugs":{"url":"https://github.com/kopterio/vue-auth-cognito/issues"},"homepage":"https://github.com/kopterio/vue-auth-cognito#readme","_id":"@bonnier-publications/vue-auth-cognito@0.1.6","_nodeVersion":"8.11.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-+qyD8sEpy2JfOtj35iMg+dOqam9FNBzo5U6BZvH3uPHIZzl/XXjjDUBlBN3S0NR8b6RuTjkPV1/oayi0UPTxjA==","shasum":"274c3a49e00f9c9a1d0e9deb441623a91e652dee","tarball":"https://registry.npmjs.org/@bonnier-publications/vue-auth-cognito/-/vue-auth-cognito-0.1.6.tgz","fileCount":34,"unpackedSize":173832,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdnvzqCRA9TVsSAnZWagAA8GAQAJFlmUT4siz7uPDmbrk+\nxQnKzqkiQtUxWDUttdOOH6h8p1GfEFDFXjUBPRsr9hOD4p5BcudTvuQk3Wv/\nyrkRP3GoLv4mAifoazdm0acSbosJcVXEt/B4bEJsqtk8PuyFZJu+g9sovE9e\nj5ahGZDMwCuct0/SMTrLRJgu3NWp3YrP8xLfzlksCisbhW22UtWyD4i0D0UO\nMay44BaJXUHTsqGJRwW2DfCr71YV7AxkSYVe2GNIKjqSkvyWRlFCqReOOqt+\n4MsZJunUENYdBRfqA8DXVCIZW8UcbCsN1DKTaabz49PrPhM1bTWv7x/O/l8d\nTzsWvB5J5A9eqhOn7oo+WCir+npMnY8VSS3YwP7RJnu7E4CVdFmAuKbLngLW\n99KvlDeViso+pa9zMJZ/HcCD9QkxTSc/7QqfVG5whJ+3bSKHw2UfsFa3xCGd\nVAVGIRP3fOFLNY4plbrmTj/zFJF1clGJqT3g3l0Ty3vJud/Tq3lhn3OliTl8\n7adzhUFn+o+tLf1VvrHBPjZQqt+cbv2YAhT4oRZgk37m7LCO8QaRn1d0BsfD\npAJNx9IioZnmuNBwRXw8teRVDWKyZkZYlzOA4V463pmPxCecRHSX/9HivDHN\nOCkoMGs74acZBOd6z4i43PJAfS60ubQZM61vX5qDuCLACt7+fU5XSm7btXSV\nsqTd\r\n=N77D\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDyua8mOdPUd2xOUw22yTHaRpDVPlMmovO5eWP6VwfSugIgfnYYgHVSO82zZZ6DD6W5xah+t9FmZPZpX6k2yyg/AFM="}]},"maintainers":[{"name":"jonastanz","email":"jonask@jonask.dk"},{"name":"mflor","email":"magnus@m-flor.dk"},{"name":"alfhen","email":"alfhenderson@gmail.com"}],"_npmUser":{"name":"alfhen","email":"alfhenderson@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vue-auth-cognito_0.1.6_1570700521635_0.5954218705280236"},"_hasShrinkwrap":false}},"time":{"created":"2019-10-10T09:42:01.400Z","0.1.6":"2019-10-10T09:42:01.795Z","modified":"2022-04-04T20:06:39.709Z"},"maintainers":[{"email":"martin.henriksen@bonnier.dk","name":"mrhn_bonnier"},{"email":"jonask@jonask.dk","name":"jonastanz"},{"email":"soren.thorup@bonnier.dk","name":"sorenthorup"},{"email":"martin.shi@bonnier.dk","name":"186-dk"}],"description":"A Vue.js Vuex module for authentication using Amazon AWS Cognito","homepage":"https://github.com/kopterio/vue-auth-cognito#readme","repository":{"type":"git","url":"git+https://github.com/kopterio/vue-auth-cognito.git"},"contributors":[{"name":"Anton Sekatski","email":"antonsekatski@gmail.com"}],"author":{"name":"Evgeny Zislis","email":"evgeny.zislis@gmail.com"},"bugs":{"url":"https://github.com/kopterio/vue-auth-cognito/issues"},"license":"MIT","readme":"# vue-auth-cognito\n\n[![npm](https://img.shields.io/npm/v/vue-auth-cognito.svg)](https://www.npmjs.com/package/vue-auth-cognito)\n[![Build Status](https://travis-ci.org/kopterio/vue-auth-cognito.svg?branch=master)](https://travis-ci.org/kopterio/vue-auth-cognito)\n[![Code Climate](https://codeclimate.com/github/kopterio/vue-auth-cognito/badges/gpa.svg)](https://codeclimate.com/github/kopterio/vue-auth-cognito)\n[![Coverage Status](https://coveralls.io/repos/github/kopterio/vue-auth-cognito/badge.svg?branch=master)](https://coveralls.io/github/kopterio/vue-auth-cognito?branch=master)\n[![Greenkeeper Badge](https://badges.greenkeeper.io/kopterio/vue-auth-cognito.svg)](https://greenkeeper.io/)\n\nThis small library serves as a wrapper of Amazon Cognito for Vuex.\n\n> As pointed out in #65 the [aws-amplify/amplify-js](https://github.com/aws-amplify/amplify-js) project officially supported by AWS has Vue.js integration. The example project is at [aws-samples/aws-amplify-vue](https://github.com/aws-samples/aws-amplify-vue).\n\n# Actions for dispatch method\n\nAll actions return a promise to be able to easily control execution flow.\n\n## getCurrentUser\n\nRetrieve current user and save user schema to store.\n\nReturned promise rejects with an error if there is no previously authenticated user:\n\n```\n{\n  message: \"Can't retrieve current user\",\n}\n```\n\n## authenticateUser\n\nAuthenticates a user with username and password.\n\nUsage:\n\n```\nthis.$store.dispatch('authenticateUser', {\n  username: \"bruce@wayne.com\",\n  password: \"testbatmanpass\"\n});\n```\n\nReturned promise resolves with an object with `userConfirmationNecessary` flag:\n\n```\nthis.$store.dispatch('signUp', { ... }).then(({ userConfirmationNecessary }) => { ... })\n```\n\nReturned promise rejects with the following error object:\n\n```\n{\n  code: \"NotAuthorizedException\", // Amazon Cognito error code\n  message: \"...\" // Error message returned from Amazon Cognito servers\n}\n```\n\n## signUp\n\nCreates user with the following payload:\n\n```\n{\n  username: 'test',\n  password: 'Qwerty123!',\n  attributes: {\n    email: 'test@test.com',\n    name: 'MegaTest',\n    phone_number: '+15553334444',\n  }\n}\n```\n\nYou can change `username` to be any value, for example, an email address or UUID. It's important to know that Amazon Cognito doesn't allow changing username after signing up.\n\nUsage:\n\n```\nthis.$store.dispatch('signUp', { ... });\n```\n\nReturned promise resolves with an object with `userConfirmationNecessary` flag:\n\n```\nthis.$store.dispatch('signUp', { ... }).then(({ userConfirmationNecessary }) => { ... })\n```\n\nReturned promise rejects with the following error object:\n\n```\n{\n  code: \"NotAuthorizedException\", // Amazon Cognito error code\n  message: \"...\" // Error message returned from Amazon Cognito servers\n}\n```\n\n## confirmRegistration\n\nConfirms user registration with username and code:\n\nUsage:\n\n```\nthis.$store.dispatch('confirmRegistration', {\n  username: 'testusername',\n  code: '123456'\n});\n```\n\nReturned promise rejects with the following error object:\n\n```\n{\n  code: \"NotAuthorizedException\", // Amazon Cognito error code\n  message: \"...\" // Error message returned from Amazon Cognito servers\n}\n```\n\n## resendConfirmationCode\n\nResends user confirmation code:\n\nUsage:\n\n```\nthis.$store.dispatch('resendConfirmationCode', {\n  username: 'testusername'\n});\n```\n\nReturned promise rejects with the following error object:\n\n```\n{\n  code: \"NotAuthorizedException\", // Amazon Cognito error code\n  message: \"...\" // Error message returned from Amazon Cognito servers\n}\n```\n\n## forgotPassword\n\nStarts forgot password flow:\n\nUsage:\n\n```\nthis.$store.dispatch('forgotPassword', {\n  username: 'testusername'\n});\n```\n\nReturned promise rejects with the following error object:\n\n```\n{\n  code: \"NotAuthorizedException\", // Amazon Cognito error code\n  message: \"...\" // Error message returned from Amazon Cognito servers\n}\n```\n\n## confirmPassword\n\nSets a new password with the code received after calling forgotPassword action:\n\nUsage:\n\n```\nthis.$store.dispatch('confirmPassword', {\n  username: 'testusername',\n  code: '123456',\n  newPassword: 'qwerty123'\n});\n```\n\nReturned promise rejects with the following error object:\n\n```\n{\n  code: \"NotAuthorizedException\", // Amazon Cognito error code\n  message: \"...\" // Error message returned from Amazon Cognito servers\n}\n```\n\n## changePassword\n\n> Only for authenticated users\n\nChanges user password:\n\nUsage:\n\n```\nthis.$store.dispatch('changePassword', {\n  oldPassword: '123qwerty',\n  newPassword: 'qwerty123'\n});\n```\n\nReturned promise rejects with the following error object:\n\n```\n{\n  code: \"NotAuthorizedException\", // Amazon Cognito error code\n  message: \"...\" // Error message returned from Amazon Cognito servers\n}\n```\n\n## updateAttributes\n\n> Only for authenticated users\n\nUpdates user attributes. Payload is an object where key is an attribute name:\n\n```\n{\n  email: 'value',\n  phone_number: 'bruce@wayne.com',\n  username: 'batman' // see documentation on Cognito attributes\n}\n```\n\nUsage:\n\n```\nthis.$store.dispatch('updateAttributes', {\n  email: 'bruce@wayne.com',\n  name: 'Bruce',\n  phone_number: '+15551234567',\n});\n```\n\nReturned promise rejects with the following error object:\n\n```\n{\n  code: \"NotAuthorizedException\", // Amazon Cognito error code\n  message: \"...\" // Error message returned from Amazon Cognito servers\n}\n```\n\n## signOut\n\nRemoves user from the store (for example, `$store.cognito.user`) and Cognito session from Local Storage.\n\nReturned promise rejects with an error if there is no previously authenticated user:\n\n```\n{\n  message: \"User is unauthenticated\",\n}\n```\n\n# Examples\n\nBefore checking examples, please copy `examples/.env.example` to `examples/.env` and add the correct AWS crendentials to it.\n\n`npm start` command uses [node-foreman](https://github.com/strongloop/node-foreman) package to run both API and Vue.js front-end servers. \n\n``` bash\ncd examples\n\n# install dependencies\nnpm install\n\n# serve API server and examples with hot reload at localhost\nnpm start\n```\n\n### UUID\n\nCognito's username could be anything: email, a randomly generated integer, UUID, etc. It cannot be changed later so it's wise to use something unique like UUID and use attributes to keep email addresses, phone numbers and other information.\n\nFor now, Cognito doesn't support some features like resending confirmation code using email attribute. It requires a username for that operation and it could be a problem if it's a generated UUID. We can potentially keep username in localStorage or a cookie but it can easily be lost if a user switches computers or browsers.\n\nThat's why we need a little API endpoint to convert an email address stored in `email` attribute to a username by using Cognito API. You can find an example server in `examples/servers/index.js`.\n\n# Tests\n\n``` bash\n# run all tests\nnpm test\n```\n\n# Credits\n\n- [Evgeny Zislis](https://github.com/kesor)\n- [Anton Sekatski](https://github.com/antonsekatski)\n","readmeFilename":"README.md"}