diff --git a/package-lock.json b/package-lock.json index 5b0c024..e6664f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,16 +8,13 @@ "name": "remix-auth-form", "version": "1.2.0", "license": "MIT", - "dependencies": { - "remix-auth": "^3.3.0" - }, "devDependencies": { "@babel/core": "^7.14.2", "@babel/preset-env": "^7.14.1", "@babel/preset-react": "^7.13.13", "@babel/preset-typescript": "^7.13.0", - "@remix-run/node": "^1.0.3", - "@remix-run/react": "^1.1.1", + "@remix-run/node": "^1.0.0", + "@remix-run/react": "^1.0.0", "@remix-run/server-runtime": "^1.0.0", "@types/jest": "^26.0.23", "@typescript-eslint/eslint-plugin": "^4.23.0", @@ -32,12 +29,15 @@ "jest": "^26.6.3", "jest-fetch-mock": "^3.0.3", "prettier": "^2.3.2", - "react": "^17.0.2", + "react": "^17.0.0", + "react-dom": "^17.0.0", + "remix-auth": "^3.4.0", "ts-node": "^9.1.1", "typescript": "^4.3.5" }, "peerDependencies": { - "@remix-run/server-runtime": "^1.0.0" + "@remix-run/server-runtime": "^1.0.0", + "remix-auth": "^3.4.0" } }, "node_modules/@babel/code-frame": { @@ -1712,6 +1712,7 @@ "version": "7.16.5", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.16.5.tgz", "integrity": "sha512-TXWihFIS3Pyv5hzR7j6ihmeLkZfrXGxAr5UfSl8CHf+6q/wpiYDkUau0czckpYG8QmnCIuPpdLtuA9VmuGGyMA==", + "dev": true, "dependencies": { "regenerator-runtime": "^0.13.4" }, @@ -2626,6 +2627,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/@remix-run/react/-/react-1.1.1.tgz", "integrity": "sha512-vz7my0sqjuL3BpgvSb+pUFjebof54okDLm2wHI09NnlbPS1ILrrp61zeNmDyrA11tFcxS/JrgKS/q1Frk030mg==", + "dev": true, "dependencies": { "react-router-dom": "^6.2.1" }, @@ -2638,6 +2640,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/@remix-run/server-runtime/-/server-runtime-1.1.1.tgz", "integrity": "sha512-uTTGSjCn2WTXUShruvTuErpbdbGoLu2dZ/zQ0ZHA0MMgP4VDA8xyuBeRcv/By3xqGcu2zSxcEGv7tRPgzU1AtA==", + "dev": true, "dependencies": { "@types/cookie": "^0.4.0", "cookie": "^0.4.1", @@ -2655,6 +2658,7 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz", "integrity": "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==", + "dev": true, "bin": { "jsesc": "bin/jsesc" }, @@ -2666,6 +2670,7 @@ "version": "0.7.3", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", + "dev": true, "engines": { "node": ">= 8" } @@ -2845,7 +2850,8 @@ "node_modules/@types/cookie": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", - "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==" + "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==", + "dev": true }, "node_modules/@types/graceful-fs": { "version": "4.1.5", @@ -4125,6 +4131,7 @@ "version": "0.4.1", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz", "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==", + "dev": true, "engines": { "node": ">= 0.6" } @@ -5945,6 +5952,7 @@ "version": "5.2.0", "resolved": "https://registry.npmjs.org/history/-/history-5.2.0.tgz", "integrity": "sha512-uPSF6lAJb3nSePJ43hN3eKj1dTWpN9gMod0ZssbFTIsen+WehTmEadgL+kg78xLJFdRfrrC//SavDzmRVdE+Ig==", + "dev": true, "dependencies": { "@babel/runtime": "^7.7.6" } @@ -8245,7 +8253,8 @@ "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true }, "node_modules/js-yaml": { "version": "3.14.1", @@ -8498,6 +8507,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, "dependencies": { "js-tokens": "^3.0.0 || ^4.0.0" }, @@ -8827,6 +8837,7 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -9376,6 +9387,7 @@ "version": "17.0.2", "resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz", "integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==", + "dev": true, "dependencies": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1" @@ -9388,7 +9400,7 @@ "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz", "integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==", - "peer": true, + "dev": true, "dependencies": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1", @@ -9408,6 +9420,7 @@ "version": "6.2.1", "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.2.1.tgz", "integrity": "sha512-2fG0udBtxou9lXtK97eJeET2ki5//UWfQSl1rlJ7quwe6jrktK9FCCc8dQb5QY6jAv3jua8bBQRhhDOM/kVRsg==", + "dev": true, "dependencies": { "history": "^5.2.0" }, @@ -9419,6 +9432,7 @@ "version": "6.2.1", "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.2.1.tgz", "integrity": "sha512-I6Zax+/TH/cZMDpj3/4Fl2eaNdcvoxxHoH1tYOREsQ22OKDYofGebrNm6CTPUcvLvZm63NL/vzCYdjf9CUhqmA==", + "dev": true, "dependencies": { "history": "^5.2.0", "react-router": "6.2.1" @@ -9499,7 +9513,8 @@ "node_modules/regenerator-runtime": { "version": "0.13.9", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", - "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==" + "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", + "dev": true }, "node_modules/regenerator-transform": { "version": "0.14.5", @@ -9598,9 +9613,10 @@ } }, "node_modules/remix-auth": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/remix-auth/-/remix-auth-3.3.0.tgz", - "integrity": "sha512-sLY5s6DQF4OJp03HM/dIEw3tLfSOIowerS2QDTuvEVXoEA3IHVmk7QkvOKosWdVPbcnlRfwF6PbeBLKgo6vqsg==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/remix-auth/-/remix-auth-3.4.0.tgz", + "integrity": "sha512-VRliJo9VRAS4sSYgMjYbi7rYRixPWU2Tb8PFZb06OIj0nONK/1KRzHf2+Y6VGZeIacepLVgan6g2IUJjayE2rQ==", + "dev": true, "dependencies": { "uuid": "^8.3.2" }, @@ -10110,7 +10126,7 @@ "version": "0.20.2", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz", "integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==", - "peer": true, + "dev": true, "dependencies": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1" @@ -10134,7 +10150,8 @@ "node_modules/set-cookie-parser": { "version": "2.4.8", "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.4.8.tgz", - "integrity": "sha512-edRH8mBKEWNVIVMKejNnuJxleqYE/ZSdcT8/Nem9/mmosx12pctd80s2Oy00KNZzrogMZS5mauK2/ymL1bvlvg==" + "integrity": "sha512-edRH8mBKEWNVIVMKejNnuJxleqYE/ZSdcT8/Nem9/mmosx12pctd80s2Oy00KNZzrogMZS5mauK2/ymL1bvlvg==", + "dev": true }, "node_modules/set-value": { "version": "2.0.1", @@ -11308,6 +11325,7 @@ "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, "bin": { "uuid": "dist/bin/uuid" } @@ -12804,6 +12822,7 @@ "version": "7.16.5", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.16.5.tgz", "integrity": "sha512-TXWihFIS3Pyv5hzR7j6ihmeLkZfrXGxAr5UfSl8CHf+6q/wpiYDkUau0czckpYG8QmnCIuPpdLtuA9VmuGGyMA==", + "dev": true, "requires": { "regenerator-runtime": "^0.13.4" } @@ -13511,6 +13530,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/@remix-run/react/-/react-1.1.1.tgz", "integrity": "sha512-vz7my0sqjuL3BpgvSb+pUFjebof54okDLm2wHI09NnlbPS1ILrrp61zeNmDyrA11tFcxS/JrgKS/q1Frk030mg==", + "dev": true, "requires": { "react-router-dom": "^6.2.1" } @@ -13519,6 +13539,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/@remix-run/server-runtime/-/server-runtime-1.1.1.tgz", "integrity": "sha512-uTTGSjCn2WTXUShruvTuErpbdbGoLu2dZ/zQ0ZHA0MMgP4VDA8xyuBeRcv/By3xqGcu2zSxcEGv7tRPgzU1AtA==", + "dev": true, "requires": { "@types/cookie": "^0.4.0", "cookie": "^0.4.1", @@ -13531,12 +13552,14 @@ "jsesc": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz", - "integrity": "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==" + "integrity": "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==", + "dev": true }, "source-map": { "version": "0.7.3", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==" + "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", + "dev": true } } }, @@ -13690,7 +13713,8 @@ "@types/cookie": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", - "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==" + "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==", + "dev": true }, "@types/graceful-fs": { "version": "4.1.5", @@ -14673,7 +14697,8 @@ "cookie": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz", - "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==" + "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==", + "dev": true }, "cookie-signature": { "version": "1.1.0", @@ -16040,6 +16065,7 @@ "version": "5.2.0", "resolved": "https://registry.npmjs.org/history/-/history-5.2.0.tgz", "integrity": "sha512-uPSF6lAJb3nSePJ43hN3eKj1dTWpN9gMod0ZssbFTIsen+WehTmEadgL+kg78xLJFdRfrrC//SavDzmRVdE+Ig==", + "dev": true, "requires": { "@babel/runtime": "^7.7.6" } @@ -17746,7 +17772,8 @@ "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true }, "js-yaml": { "version": "3.14.1", @@ -17942,6 +17969,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, "requires": { "js-tokens": "^3.0.0 || ^4.0.0" } @@ -18203,7 +18231,8 @@ "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true }, "object-copy": { "version": "0.1.0", @@ -18598,6 +18627,7 @@ "version": "17.0.2", "resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz", "integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==", + "dev": true, "requires": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1" @@ -18607,7 +18637,7 @@ "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz", "integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==", - "peer": true, + "dev": true, "requires": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1", @@ -18624,6 +18654,7 @@ "version": "6.2.1", "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.2.1.tgz", "integrity": "sha512-2fG0udBtxou9lXtK97eJeET2ki5//UWfQSl1rlJ7quwe6jrktK9FCCc8dQb5QY6jAv3jua8bBQRhhDOM/kVRsg==", + "dev": true, "requires": { "history": "^5.2.0" } @@ -18632,6 +18663,7 @@ "version": "6.2.1", "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.2.1.tgz", "integrity": "sha512-I6Zax+/TH/cZMDpj3/4Fl2eaNdcvoxxHoH1tYOREsQ22OKDYofGebrNm6CTPUcvLvZm63NL/vzCYdjf9CUhqmA==", + "dev": true, "requires": { "history": "^5.2.0", "react-router": "6.2.1" @@ -18694,7 +18726,8 @@ "regenerator-runtime": { "version": "0.13.9", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", - "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==" + "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", + "dev": true }, "regenerator-transform": { "version": "0.14.5", @@ -18776,9 +18809,10 @@ } }, "remix-auth": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/remix-auth/-/remix-auth-3.3.0.tgz", - "integrity": "sha512-sLY5s6DQF4OJp03HM/dIEw3tLfSOIowerS2QDTuvEVXoEA3IHVmk7QkvOKosWdVPbcnlRfwF6PbeBLKgo6vqsg==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/remix-auth/-/remix-auth-3.4.0.tgz", + "integrity": "sha512-VRliJo9VRAS4sSYgMjYbi7rYRixPWU2Tb8PFZb06OIj0nONK/1KRzHf2+Y6VGZeIacepLVgan6g2IUJjayE2rQ==", + "dev": true, "requires": { "uuid": "^8.3.2" } @@ -19167,7 +19201,7 @@ "version": "0.20.2", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz", "integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==", - "peer": true, + "dev": true, "requires": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1" @@ -19188,7 +19222,8 @@ "set-cookie-parser": { "version": "2.4.8", "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.4.8.tgz", - "integrity": "sha512-edRH8mBKEWNVIVMKejNnuJxleqYE/ZSdcT8/Nem9/mmosx12pctd80s2Oy00KNZzrogMZS5mauK2/ymL1bvlvg==" + "integrity": "sha512-edRH8mBKEWNVIVMKejNnuJxleqYE/ZSdcT8/Nem9/mmosx12pctd80s2Oy00KNZzrogMZS5mauK2/ymL1bvlvg==", + "dev": true }, "set-value": { "version": "2.0.1", @@ -20126,7 +20161,8 @@ "uuid": { "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true }, "v8-compile-cache": { "version": "2.3.0", diff --git a/package.json b/package.json index 9533056..108211c 100644 --- a/package.json +++ b/package.json @@ -24,15 +24,16 @@ "README.md" ], "peerDependencies": { - "@remix-run/server-runtime": "^1.0.0" + "@remix-run/server-runtime": "^1.0.0", + "remix-auth": "^3.4.0" }, "devDependencies": { "@babel/core": "^7.14.2", "@babel/preset-env": "^7.14.1", "@babel/preset-react": "^7.13.13", "@babel/preset-typescript": "^7.13.0", - "@remix-run/node": "^1.0.3", - "@remix-run/react": "^1.1.1", + "@remix-run/node": "^1.0.0", + "@remix-run/react": "^1.0.0", "@remix-run/server-runtime": "^1.0.0", "@types/jest": "^26.0.23", "@typescript-eslint/eslint-plugin": "^4.23.0", @@ -47,11 +48,10 @@ "jest": "^26.6.3", "jest-fetch-mock": "^3.0.3", "prettier": "^2.3.2", - "react": "^17.0.2", + "react": "^17.0.0", + "react-dom": "^17.0.0", + "remix-auth": "^3.4.0", "ts-node": "^9.1.1", "typescript": "^4.3.5" - }, - "dependencies": { - "remix-auth": "^3.3.0" } } diff --git a/src/index.ts b/src/index.ts index 31de33c..2796bef 100644 --- a/src/index.ts +++ b/src/index.ts @@ -29,15 +29,38 @@ export class FormStrategy extends Strategy< ): Promise { let form = await this.readFormData(request, options); - let user: User; try { - user = await this.verify({ form, context: options.context }); + let user = await this.verify({ form, context: options.context }); + return this.success(user, request, sessionStorage, options); } catch (error) { - let message = (error as Error).message; - return await this.failure(message, request, sessionStorage, options); - } + if (error instanceof Error) { + return await this.failure( + error.message, + request, + sessionStorage, + options, + error + ); + } + + if (typeof error === "string") { + return await this.failure( + error, + request, + sessionStorage, + options, + new Error(error) + ); + } - return this.success(user, request, sessionStorage, options); + return await this.failure( + "Unknown error", + request, + sessionStorage, + options, + new Error(JSON.stringify(error, null, 2)) + ); + } } private async readFormData(request: Request, options: AuthenticateOptions) { diff --git a/test/index.test.ts b/test/index.test.ts index afe58a5..f43da7c 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -1,6 +1,14 @@ import { createCookieSessionStorage } from "@remix-run/server-runtime"; +import { AuthenticateOptions, AuthorizationError } from "remix-auth"; import { FormStrategy, FormStrategyVerifyParams } from "../src"; +const BASE_OPTIONS: AuthenticateOptions = { + name: "form", + sessionKey: "user", + sessionErrorKey: "error", + sessionStrategyKey: "strategy", +}; + describe(FormStrategy, () => { let verify = jest.fn(); // You will probably need a sessionStorage to test the strategy. @@ -25,9 +33,7 @@ describe(FormStrategy, () => { let strategy = new FormStrategy(verify); - await strategy.authenticate(request, sessionStorage, { - sessionKey: "user", - }); + await strategy.authenticate(request, sessionStorage, BASE_OPTIONS); expect(verify).toBeCalledWith({ form: body }); }); @@ -46,9 +52,11 @@ describe(FormStrategy, () => { let strategy = new FormStrategy(verify); - let user = await strategy.authenticate(request, sessionStorage, { - sessionKey: "user", - }); + let user = await strategy.authenticate( + request, + sessionStorage, + BASE_OPTIONS + ); expect(user).toBe("test@example.com"); }); @@ -64,7 +72,7 @@ describe(FormStrategy, () => { let strategy = new FormStrategy(verify); await strategy.authenticate(request, sessionStorage, { - sessionKey: "user", + ...BASE_OPTIONS, context, }); @@ -85,7 +93,7 @@ describe(FormStrategy, () => { expect( strategy.authenticate(request, sessionStorage, { - sessionKey: "user", + ...BASE_OPTIONS, context, }) ).resolves.toBe("test@example.com"); @@ -105,9 +113,84 @@ describe(FormStrategy, () => { expect( strategy.authenticate(request, sessionStorage, { - sessionKey: "user", + ...BASE_OPTIONS, context, }) ).resolves.toBe("test@example.com"); }); + + test("should pass error as cause on failure", async () => { + verify.mockImplementationOnce(() => { + throw new TypeError("Invalid email address"); + }); + + let body = new FormData(); + body.set("email", "test@example.com"); + + let request = new Request("", { body, method: "POST" }); + + let strategy = new FormStrategy(verify); + + let result = await strategy + .authenticate(request, sessionStorage, { + ...BASE_OPTIONS, + throwOnError: true, + }) + .catch((error) => error); + + expect(result).toEqual(new AuthorizationError("Invalid email address")); + expect((result as AuthorizationError).cause).toEqual( + new TypeError("Invalid email address") + ); + }); + + test("should pass generate error from string on failure", async () => { + verify.mockImplementationOnce(() => { + throw "Invalid email address"; + }); + + let body = new FormData(); + body.set("email", "test@example.com"); + + let request = new Request("", { body, method: "POST" }); + + let strategy = new FormStrategy(verify); + + let result = await strategy + .authenticate(request, sessionStorage, { + ...BASE_OPTIONS, + throwOnError: true, + }) + .catch((error) => error); + + expect(result).toEqual(new AuthorizationError("Invalid email address")); + expect((result as AuthorizationError).cause).toEqual( + new TypeError("Invalid email address") + ); + }); + + test("should create Unknown error if thrown value is not Error or string", async () => { + verify.mockImplementationOnce(() => { + throw { message: "Invalid email address" }; + }); + + let body = new FormData(); + body.set("email", "test@example.com"); + + let request = new Request("", { body, method: "POST" }); + + let strategy = new FormStrategy(verify); + + let result = await strategy + .authenticate(request, sessionStorage, { + ...BASE_OPTIONS, + throwOnError: true, + }) + .catch((error) => error); + + expect(result).toEqual(new AuthorizationError("Unknown error")); + expect((result as AuthorizationError).cause).toEqual( + new Error(JSON.stringify({ message: "Invalid email address" }, null, 2)) + ); + }); });