@stanlemon/react-couchdb-authentication
Advanced tools
Comparing version 0.8.30 to 0.8.31
@@ -7,13 +7,7 @@ "use strict"; | ||
exports.Authenticated = Authenticated; | ||
var React = _interopRequireWildcard(require("react")); | ||
var _Authentication = require("./Authentication"); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function Authenticated({ | ||
@@ -20,0 +14,0 @@ children |
"use strict"; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _pouchdb = _interopRequireDefault(require("pouchdb")); | ||
var _react2 = require("@testing-library/react"); | ||
require("@testing-library/jest-dom"); | ||
var _ = require("../"); | ||
var _isomorphicFetch = _interopRequireDefault(require("isomorphic-fetch")); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/* eslint-disable max-lines-per-function */ | ||
/* eslint-disable max-lines-per-function */ | ||
if (!window.setImmediate) { | ||
// This is as gross as it looks. It's a workaround for using PouchDB in tests. | ||
window.setImmediate = window.setTimeout; | ||
} // eslint-disable-next-line @typescript-eslint/no-var-requires | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
_pouchdb.default.plugin(require("pouchdb-adapter-memory")); | ||
const couchDbUrl = process.env.COUCHDB_URL || "http://localhost:5984/"; | ||
const checkCouchDb = async () => { | ||
@@ -38,3 +29,2 @@ try { | ||
}; | ||
describe("<Authentication /> with CouchDB instance", () => { | ||
@@ -44,3 +34,2 @@ // This is a full end to end test | ||
const isCouchDbUp = await checkCouchDb(); | ||
if (!isCouchDbUp) { | ||
@@ -51,3 +40,2 @@ /* eslint-disable no-console */ | ||
} | ||
const username = "test" + Date.now().toString(); | ||
@@ -77,19 +65,18 @@ const password = "password"; | ||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(App, {}) | ||
})); // This element is present before connecting to CouchDB and then should be removed. | ||
})); | ||
// This element is present before connecting to CouchDB and then should be removed. | ||
await (0, _react2.waitFor)(() => { | ||
const loading = _react2.screen.queryByText("Loading..."); | ||
expect(loading).not.toBeInTheDocument(); // it doesn't exist | ||
}); // On login screen, navigate to signup | ||
}); | ||
_react2.fireEvent.click(_react2.screen.getByTestId("navigate-to-sign-up")); // Check that our signup form is on the page | ||
// On login screen, navigate to signup | ||
_react2.fireEvent.click(_react2.screen.getByTestId("navigate-to-sign-up")); | ||
// Check that our signup form is on the page | ||
const signUpButton = _react2.screen.getByRole("button", { | ||
name: "Sign Up" | ||
}); | ||
expect(signUpButton).toBeInTheDocument(); | ||
_react2.fireEvent.change(_react2.screen.getByLabelText("Username"), { | ||
@@ -99,5 +86,5 @@ target: { | ||
} | ||
}); // Fill in email | ||
}); | ||
// Fill in email | ||
_react2.fireEvent.change(_react2.screen.getByLabelText("Email"), { | ||
@@ -107,5 +94,5 @@ target: { | ||
} | ||
}); // Fill in password | ||
}); | ||
// Fill in password | ||
_react2.fireEvent.change(_react2.screen.getByLabelText("Password"), { | ||
@@ -115,7 +102,6 @@ target: { | ||
} | ||
}); // Submit the form | ||
}); | ||
// Submit the form | ||
_react2.fireEvent.click(signUpButton); | ||
await (0, _react2.waitFor)(() => { | ||
@@ -125,5 +111,3 @@ expect(_react2.screen.getByText("Authenticated")).toBeInTheDocument(); | ||
expect(_react2.screen.getByText("Hello " + username)).toBeInTheDocument(); | ||
_react2.fireEvent.click(_react2.screen.getByTestId("logout")); | ||
await (0, _react2.waitFor)(() => { | ||
@@ -134,3 +118,2 @@ expect(_react2.screen.getByRole("button", { | ||
}); | ||
_react2.fireEvent.change(_react2.screen.getByLabelText("Username"), { | ||
@@ -140,5 +123,5 @@ target: { | ||
} | ||
}); // Fill in password | ||
}); | ||
// Fill in password | ||
_react2.fireEvent.change(_react2.screen.getByLabelText("Password"), { | ||
@@ -149,11 +132,10 @@ target: { | ||
}); | ||
_react2.fireEvent.click(_react2.screen.getByRole("button", { | ||
name: "Login" | ||
})); | ||
await (0, _react2.waitFor)(() => { | ||
expect(_react2.screen.getByText("Authenticated")).toBeInTheDocument(); | ||
}); // Now we need to cleanup the user that we created | ||
}); | ||
// Now we need to cleanup the user that we created | ||
const userUrl = couchDbUrl.substring(0, 7) + username + ":" + password + "@" + couchDbUrl.substring(7) + "_users/org.couchdb.user:" + username; | ||
@@ -165,4 +147,5 @@ const userResponse = await (0, _isomorphicFetch.default)(userUrl); | ||
}); | ||
const userDelete = await userDeleteResponse.json(); // We successfully delete the user that we created | ||
const userDelete = await userDeleteResponse.json(); | ||
// We successfully delete the user that we created | ||
expect(userDelete.ok).toBe(true); | ||
@@ -169,0 +152,0 @@ }); |
@@ -7,27 +7,14 @@ "use strict"; | ||
exports.Context = exports.Authentication = void 0; | ||
var React = _interopRequireWildcard(require("react")); | ||
var _pouchdb = _interopRequireDefault(require("pouchdb")); | ||
var _asyncRetry = _interopRequireDefault(require("async-retry")); | ||
var _Login = require("./Login"); | ||
var _LoginView = require("./LoginView"); | ||
var _SignUp = require("./SignUp"); | ||
var _SignUpView = require("./SignUpView"); | ||
var _buffer = require("buffer"); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
const ROUTE_LOGIN = "login"; | ||
@@ -41,5 +28,7 @@ const ROUTE_SIGNUP = "signup"; | ||
error: "", | ||
login: (username, password) => {// Empty | ||
login: (username, password) => { | ||
// Empty | ||
}, | ||
logout: () => {// Empty | ||
logout: () => { | ||
// Empty | ||
}, | ||
@@ -49,13 +38,14 @@ signUp: (username, password, email) => { | ||
}, | ||
navigateToLogin: () => {// Empty | ||
navigateToLogin: () => { | ||
// Empty | ||
}, | ||
navigateToSignUp: () => {// Empty | ||
navigateToSignUp: () => { | ||
// Empty | ||
} | ||
}); | ||
/** | ||
* Wrap components behind CouchDB authentication and sync the user's database locally. | ||
*/ | ||
exports.Context = Context; | ||
class Authentication extends React.Component { | ||
@@ -95,16 +85,13 @@ static defaultProps = { | ||
#checkSessionInterval; | ||
constructor(props) { | ||
super(props); | ||
if (!this.props.url) { | ||
throw new Error("A url to a couchdb instance is required"); | ||
} | ||
this.#localDb = new _pouchdb.default(this.props.localDbName, { | ||
adapter: this.props.adapter | ||
}); | ||
} // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
log(...args) { | ||
@@ -115,5 +102,5 @@ if (this.props.debug) { | ||
} | ||
} // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
error(...args) { | ||
@@ -125,3 +112,2 @@ if (this.props.debug) { | ||
} | ||
getUserDb(username) { | ||
@@ -131,13 +117,9 @@ if (!username) { | ||
} | ||
const buffer = _buffer.Buffer.from(username); | ||
const hexUsername = buffer.toString("hex"); | ||
return "userdb-" + hexUsername; | ||
} | ||
getUserDbUrl(username) { | ||
return this.props.url.substring(0, this.props.url.lastIndexOf("/") + 1) + (this.getUserDb(username) || ""); | ||
} | ||
signUp = async (username, password, email) => { | ||
@@ -150,3 +132,2 @@ if (!username || !password || !email) { | ||
} | ||
const userId = "org.couchdb.user:" + username; | ||
@@ -164,3 +145,2 @@ const user = { | ||
}; | ||
try { | ||
@@ -171,3 +151,2 @@ const response = await this.fetch(this.props.url + "_users/" + userId, { | ||
}); | ||
if (response.error) { | ||
@@ -180,3 +159,2 @@ //{error: "conflict", reason: "Document update conflict."} | ||
} | ||
if (!response.ok) { | ||
@@ -187,3 +165,2 @@ this.setState({ | ||
} | ||
await this.checkForDb(username); | ||
@@ -195,3 +172,2 @@ await this.login(username, password); | ||
}; | ||
async checkForDb(username) { | ||
@@ -201,7 +177,5 @@ await (0, _asyncRetry.default)(async () => { | ||
const isFound = info.error === "not_found" || info.error === "forbidden" && info.reason && (info.reason === "You are not allowed to access this db." || info.reason === "_reader access is required for this request"); | ||
if (!isFound) { | ||
throw Error("Cannot find database " + username); | ||
} | ||
return info; | ||
@@ -212,5 +186,5 @@ }, { | ||
} | ||
fetch(url, options = {}) { | ||
return fetch(url, { ...options, | ||
return fetch(url, { | ||
...options, | ||
...{ | ||
@@ -225,3 +199,2 @@ cache: "no-cache", | ||
} | ||
async grabSession() { | ||
@@ -238,3 +211,2 @@ // If we have a remoteDb, we'll use it. This works better in Safari which does | ||
} | ||
async checkSession() { | ||
@@ -249,8 +221,9 @@ try { | ||
user | ||
}); // If we are logged in and have not yet setup our remote db connection, set it up | ||
}); | ||
// If we are logged in and have not yet setup our remote db connection, set it up | ||
if (isLoggedIn && !this.#remoteDb) { | ||
this.log("User is already logged in, setting up db."); | ||
this.setupDb(); // Immediately check the session again so we fully load the user | ||
this.setupDb(); | ||
// Immediately check the session again so we fully load the user | ||
await this.checkSession(); | ||
@@ -267,3 +240,2 @@ } | ||
} | ||
logout = () => { | ||
@@ -274,4 +246,5 @@ void (async () => { | ||
method: "DELETE" | ||
}); // Clear the user and redirect them to our login screen | ||
}); | ||
// Clear the user and redirect them to our login screen | ||
this.setState({ | ||
@@ -294,3 +267,2 @@ user: undefined, | ||
} | ||
try { | ||
@@ -304,4 +276,5 @@ const response = await this.fetch(this.props.url + "_session", { | ||
}); | ||
const userError = response; // If the login fails, set the reason as error and make sure we show as unauthenticated | ||
const userError = response; | ||
// If the login fails, set the reason as error and make sure we show as unauthenticated | ||
if (!userError || userError.error) { | ||
@@ -314,3 +287,2 @@ this.setState({ | ||
} | ||
const user = response; | ||
@@ -330,3 +302,2 @@ this.setState({ | ||
}; | ||
setupDb(username, password) { | ||
@@ -348,12 +319,10 @@ const opts = { | ||
}; | ||
if (!this.state.user || !this.state.user.name) { | ||
return; | ||
} | ||
const userDbUrl = this.getUserDbUrl(this.state.user.name); | ||
this.#remoteDb = new _pouchdb.default(userDbUrl, opts); // This is because we're setting important properties that aren't in state | ||
this.#remoteDb = new _pouchdb.default(userDbUrl, opts); | ||
// This is because we're setting important properties that aren't in state | ||
this.forceUpdate(); | ||
if (!this.props.sync) { | ||
@@ -363,3 +332,2 @@ this.log("Sync is disabled"); | ||
} | ||
this.#syncHandler = _pouchdb.default.sync(this.#localDb, this.#remoteDb, { | ||
@@ -371,3 +339,2 @@ live: true, | ||
} | ||
async componentDidMount() { | ||
@@ -380,13 +347,11 @@ await this.checkSession(); | ||
} | ||
async componentWillUnmount() { | ||
if (this.#checkSessionInterval) { | ||
window.clearInterval(this.#checkSessionInterval); | ||
} // Will not be set if sync has been disabled | ||
} | ||
// Will not be set if sync has been disabled | ||
if (this.#syncHandler) { | ||
this.#syncHandler.cancel(); | ||
} | ||
if (this.#remoteDb) { | ||
@@ -396,3 +361,2 @@ await this.#remoteDb.close(); | ||
} | ||
render() { | ||
@@ -403,11 +367,11 @@ // If we haven't completed our initial load yet, show a loader | ||
return this.props.loading; | ||
} // Switches to the login screen and clears out any errors | ||
} | ||
// Switches to the login screen and clears out any errors | ||
const navigateToLogin = () => this.setState({ | ||
error: undefined, | ||
internalRoute: ROUTE_LOGIN | ||
}); // Switches to the sign up screen and clears out any errors | ||
}); | ||
// Switches to the sign up screen and clears out any errors | ||
const navigateToSignUp = () => this.setState({ | ||
@@ -417,3 +381,2 @@ error: undefined, | ||
}); | ||
const value = { | ||
@@ -436,3 +399,2 @@ db: this.#localDb, | ||
} | ||
renderChildren() { | ||
@@ -443,14 +405,10 @@ // We have loaded our remote database but we are not authenticated | ||
return /*#__PURE__*/React.cloneElement(this.props.signup); | ||
} // If we aren't on the signup screen we should return the login screen | ||
} | ||
// If we aren't on the signup screen we should return the login screen | ||
return /*#__PURE__*/React.cloneElement(this.props.login); | ||
} | ||
return this.props.children; | ||
} | ||
} | ||
exports.Authentication = Authentication; | ||
//# sourceMappingURL=Authentication.js.map |
"use strict"; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _pouchdb = _interopRequireDefault(require("pouchdb")); | ||
var _react2 = require("@testing-library/react"); | ||
require("@testing-library/jest-dom"); | ||
var _ = require("../"); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
/* eslint-disable max-lines-per-function */ | ||
/* eslint-disable max-lines-per-function */ | ||
if (!window.setImmediate) { | ||
// This is as gross as it looks. It's a workaround for using PouchDB in tests. | ||
window.setImmediate = window.setTimeout; | ||
} // eslint-disable-next-line @typescript-eslint/no-var-requires | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
_pouchdb.default.plugin(require("pouchdb-adapter-memory")); | ||
const couchDbUrl = process.env.COUCHDB_URL || "http://localhost:5984/"; | ||
@@ -35,3 +27,4 @@ describe("<Authentication />", () => { | ||
(0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Authentication, { | ||
adapter: "memory" // An empty URL should yield an error | ||
adapter: "memory" | ||
// An empty URL should yield an error | ||
, | ||
@@ -43,3 +36,2 @@ url: "", | ||
}; | ||
expect(t).toThrow("A url to a couchdb instance is required"); | ||
@@ -53,6 +45,8 @@ }); | ||
signup: /*#__PURE__*/(0, _jsxRuntime.jsx)(_.SignUp, {}) | ||
})); // Initially the component shows a loading, it has to make a credentials call next | ||
})); | ||
expect(_react2.screen.getByText("Loading...")).toBeInTheDocument(); // After the page is loaded it should disappear. | ||
// Initially the component shows a loading, it has to make a credentials call next | ||
expect(_react2.screen.getByText("Loading...")).toBeInTheDocument(); | ||
// After the page is loaded it should disappear. | ||
await (0, _react2.waitForElementToBeRemoved)(() => _react2.screen.queryByText("Loading...")); | ||
@@ -66,10 +60,11 @@ }); | ||
signup: /*#__PURE__*/(0, _jsxRuntime.jsx)(_.SignUp, {}) | ||
})); // This element is present before connecting to CouchDB and then should be removed. | ||
})); | ||
// This element is present before connecting to CouchDB and then should be removed. | ||
await (0, _react2.waitFor)(() => { | ||
const loading = _react2.screen.queryByText("Loading..."); | ||
expect(loading).not.toBeInTheDocument(); // it doesn't exist | ||
}); // Check that our login form is on the page | ||
}); | ||
// Check that our login form is on the page | ||
expect(_react2.screen.getByLabelText("Username")).toBeInTheDocument(); | ||
@@ -87,13 +82,14 @@ expect(_react2.screen.getByLabelText("Password")).toBeInTheDocument(); | ||
signup: /*#__PURE__*/(0, _jsxRuntime.jsx)(_.SignUp, {}) | ||
})); // This element is present before connecting to CouchDB and then should be removed. | ||
})); | ||
// This element is present before connecting to CouchDB and then should be removed. | ||
await (0, _react2.waitFor)(() => { | ||
const loading = _react2.screen.queryByText("Loading..."); | ||
expect(loading).not.toBeInTheDocument(); // it doesn't exist | ||
}); // On login screen, navigate to signup | ||
}); | ||
_react2.fireEvent.click(_react2.screen.getByTestId("navigate-to-sign-up")); // Check that our signup form is on the page | ||
// On login screen, navigate to signup | ||
_react2.fireEvent.click(_react2.screen.getByTestId("navigate-to-sign-up")); | ||
// Check that our signup form is on the page | ||
expect(_react2.screen.getByLabelText("Username")).toBeInTheDocument(); | ||
@@ -112,21 +108,21 @@ expect(_react2.screen.getByLabelText("Email")).toBeInTheDocument(); | ||
signup: /*#__PURE__*/(0, _jsxRuntime.jsx)(_.SignUp, {}) | ||
})); // This element is present before connecting to CouchDB and then should be removed. | ||
})); | ||
// This element is present before connecting to CouchDB and then should be removed. | ||
await (0, _react2.waitFor)(() => { | ||
const loading = _react2.screen.queryByText("Loading..."); | ||
expect(loading).not.toBeInTheDocument(); // it doesn't exist | ||
}); // On login screen, navigate to signup | ||
}); | ||
_react2.fireEvent.click(_react2.screen.getByTestId("navigate-to-sign-up")); // Check that our signup form is on the page | ||
// On login screen, navigate to signup | ||
_react2.fireEvent.click(_react2.screen.getByTestId("navigate-to-sign-up")); | ||
// Check that our signup form is on the page | ||
const signUpButton = _react2.screen.getByRole("button", { | ||
name: "Sign Up" | ||
}); | ||
expect(signUpButton).toBeInTheDocument(); | ||
expect(signUpButton).toBeInTheDocument(); // Form is empty, submitting it should yield errors | ||
// Form is empty, submitting it should yield errors | ||
_react2.fireEvent.click(signUpButton); | ||
expect(_react2.screen.getByText("Username, password and email are required fields.")).toBeInTheDocument(); | ||
@@ -133,0 +129,0 @@ }); |
@@ -7,15 +7,8 @@ "use strict"; | ||
exports.Login = void 0; | ||
var React = _interopRequireWildcard(require("react")); | ||
var _Authentication = require("./Authentication"); | ||
var _LoginView = require("./LoginView"); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
class Login extends React.Component { | ||
@@ -35,3 +28,2 @@ static defaultProps = { | ||
}); | ||
render() { | ||
@@ -57,6 +49,4 @@ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Authentication.Context.Consumer, { | ||
} | ||
} | ||
exports.Login = Login; | ||
//# sourceMappingURL=Login.js.map |
@@ -7,11 +7,6 @@ "use strict"; | ||
exports.LoginView = LoginView; | ||
var React = _interopRequireWildcard(require("react")); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function LoginView(props) { | ||
@@ -22,3 +17,2 @@ const clickToSignUp = e => { | ||
}; | ||
const hitEnter = e => { | ||
@@ -30,3 +24,2 @@ // Submit the form if they hit enter | ||
}; | ||
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", { | ||
@@ -33,0 +26,0 @@ children: [props.error && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", { |
@@ -7,15 +7,8 @@ "use strict"; | ||
exports.SignUp = void 0; | ||
var React = _interopRequireWildcard(require("react")); | ||
var _Authentication = require("./Authentication"); | ||
var _SignUpView = require("./SignUpView"); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
class SignUp extends React.Component { | ||
@@ -41,3 +34,2 @@ static defaultProps = { | ||
}); | ||
render() { | ||
@@ -67,6 +59,4 @@ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Authentication.Context.Consumer, { | ||
} | ||
} | ||
exports.SignUp = SignUp; | ||
//# sourceMappingURL=SignUp.js.map |
@@ -7,11 +7,6 @@ "use strict"; | ||
exports.SignUpView = SignUpView; | ||
var React = _interopRequireWildcard(require("react")); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function SignUpView(props) { | ||
@@ -22,3 +17,2 @@ const clickToLogin = e => { | ||
}; | ||
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", { | ||
@@ -25,0 +19,0 @@ children: [props.error && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { |
@@ -7,13 +7,7 @@ "use strict"; | ||
exports.Unauthenticated = Unauthenticated; | ||
var React = _interopRequireWildcard(require("react")); | ||
var _Authentication = require("./Authentication"); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function Unauthenticated({ | ||
@@ -20,0 +14,0 @@ children |
@@ -6,5 +6,3 @@ "use strict"; | ||
}); | ||
var _Authenticated = require("./components/Authenticated"); | ||
Object.keys(_Authenticated).forEach(function (key) { | ||
@@ -20,5 +18,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _Login = require("./components/Login"); | ||
Object.keys(_Login).forEach(function (key) { | ||
@@ -34,5 +30,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _LoginView = require("./components/LoginView"); | ||
Object.keys(_LoginView).forEach(function (key) { | ||
@@ -48,5 +42,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _SignUp = require("./components/SignUp"); | ||
Object.keys(_SignUp).forEach(function (key) { | ||
@@ -62,5 +54,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _SignUpView = require("./components/SignUpView"); | ||
Object.keys(_SignUpView).forEach(function (key) { | ||
@@ -76,5 +66,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _Unauthenticated = require("./components/Unauthenticated"); | ||
Object.keys(_Unauthenticated).forEach(function (key) { | ||
@@ -90,5 +78,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _Authentication = require("./components/Authentication"); | ||
Object.keys(_Authentication).forEach(function (key) { | ||
@@ -104,5 +90,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _withAuthentication = require("./utils/withAuthentication"); | ||
Object.keys(_withAuthentication).forEach(function (key) { | ||
@@ -109,0 +93,0 @@ if (key === "default" || key === "__esModule") return; |
@@ -7,14 +7,9 @@ "use strict"; | ||
exports.withAuthentication = withAuthentication; | ||
var React = _interopRequireWildcard(require("react")); | ||
var _ = require("../"); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
//): React.FunctionComponent<Omit<P, "putDocument"> & PassThruDocumentProps> { | ||
//): React.FunctionComponent<Omit<P, "putDocument"> & PassThruDocumentProps> { | ||
function withAuthentication(component) { | ||
@@ -21,0 +16,0 @@ return () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Context.Consumer, { |
{ | ||
"name": "@stanlemon/react-couchdb-authentication", | ||
"version": "0.8.30", | ||
"version": "0.8.31", | ||
"description": "React component for authenticating against a CouchDB user db and syncing it locally with PouchDB.", | ||
@@ -43,3 +43,3 @@ "keywords": [ | ||
"@types/isomorphic-fetch": "^0.0.36", | ||
"@types/jest": "^29.1.2", | ||
"@types/jest": "^29.2.0", | ||
"@types/node": "^15.14.9", | ||
@@ -46,0 +46,0 @@ "@types/pouchdb": "^6.4.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
117371
1232