New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@stanlemon/react-couchdb-authentication

Package Overview
Dependencies
Maintainers
1
Versions
202
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stanlemon/react-couchdb-authentication - npm Package Compare versions

Comparing version 0.7.0 to 0.7.1

12

dist/components/Authenticated.js

@@ -1,6 +0,10 @@

import { jsx as _jsx } from "react/jsx-runtime";
import { Context } from "./Authentication";
export function Authenticated({ children, }) {
return (_jsx(Context.Consumer, { children: ({ authenticated }) => (authenticated ? children : null) }, void 0));
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Authenticated = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const Authentication_1 = require("./Authentication");
function Authenticated({ children, }) {
return ((0, jsx_runtime_1.jsx)(Authentication_1.Context.Consumer, { children: ({ authenticated }) => (authenticated ? children : null) }, void 0));
}
exports.Authenticated = Authenticated;
//# sourceMappingURL=Authenticated.js.map

@@ -1,13 +0,38 @@

import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import * as React from "react";
import PouchDB from "pouchdb";
import retry from "async-retry";
import { Login } from "./Login";
import { LoginView } from "./LoginView";
import { SignUp } from "./SignUp";
import { SignUpView } from "./SignUpView";
import { Buffer } from "buffer";
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Authentication = exports.Context = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const React = __importStar(require("react"));
const pouchdb_1 = __importDefault(require("pouchdb"));
const async_retry_1 = __importDefault(require("async-retry"));
const Login_1 = require("./Login");
const LoginView_1 = require("./LoginView");
const SignUp_1 = require("./SignUp");
const SignUpView_1 = require("./SignUpView");
const buffer_1 = require("buffer");
const ROUTE_LOGIN = "login";
const ROUTE_SIGNUP = "signup";
export const Context = React.createContext({
exports.Context = React.createContext({
db: undefined,

@@ -37,7 +62,7 @@ remoteDb: undefined,

*/
export class Authentication extends React.Component {
class Authentication extends React.Component {
static defaultProps = {
login: _jsx(Login, { component: LoginView }, void 0),
signup: _jsx(SignUp, { component: SignUpView }, void 0),
loading: _jsx(_Fragment, { children: "Loading..." }, void 0),
login: (0, jsx_runtime_1.jsx)(Login_1.Login, { component: LoginView_1.LoginView }, void 0),
signup: (0, jsx_runtime_1.jsx)(SignUp_1.SignUp, { component: SignUpView_1.SignUpView }, void 0),
loading: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: "Loading..." }, void 0),
debug: false,

@@ -68,3 +93,3 @@ sync: true,

super(props);
this.#localDb = new PouchDB(this.props.localDbName, {
this.#localDb = new pouchdb_1.default(this.props.localDbName, {
adapter: this.props.adapter,

@@ -91,3 +116,3 @@ });

}
const buffer = Buffer.from(username);
const buffer = buffer_1.Buffer.from(username);
const hexUsername = buffer.toString("hex");

@@ -138,3 +163,3 @@ return "userdb-" + hexUsername;

async checkForDb(username) {
await retry(async () => {
await (0, async_retry_1.default)(async () => {
const info = await this.fetch(this.getUserDbUrl(username));

@@ -252,3 +277,3 @@ const isFound = info.error === "not_found" ||

opts.credentials = "include";
return PouchDB.fetch(url, opts);
return pouchdb_1.default.fetch(url, opts);
},

@@ -269,3 +294,3 @@ // Safari does some weird stuff if we don't do this, Chrome and Firefox work fine

const userDbUrl = this.getUserDbUrl(this.state.user.name);
this.#remoteDb = new PouchDB(userDbUrl, opts);
this.#remoteDb = new pouchdb_1.default(userDbUrl, opts);
// This is because we're setting important properties that aren't in state

@@ -277,3 +302,3 @@ this.forceUpdate();

}
this.#syncHandler = PouchDB.sync(this.#localDb, this.#remoteDb, {
this.#syncHandler = pouchdb_1.default.sync(this.#localDb, this.#remoteDb, {
live: true,

@@ -335,3 +360,3 @@ retry: true,

};
return (_jsx(Context.Provider, { value: value, children: this.renderChildren() }, void 0));
return ((0, jsx_runtime_1.jsx)(exports.Context.Provider, { value: value, children: this.renderChildren() }, void 0));
}

@@ -350,2 +375,3 @@ renderChildren() {

}
exports.Authentication = Authentication;
//# sourceMappingURL=Authentication.js.map

@@ -1,8 +0,30 @@

import { jsx as _jsx } from "react/jsx-runtime";
import * as React from "react";
import { Context } from "./Authentication";
import { LoginView } from "./LoginView";
export class Login extends React.Component {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Login = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const React = __importStar(require("react"));
const Authentication_1 = require("./Authentication");
const LoginView_1 = require("./LoginView");
class Login extends React.Component {
static defaultProps = {
component: LoginView,
component: LoginView_1.LoginView,
};

@@ -16,3 +38,3 @@ state = {

render() {
return (_jsx(Context.Consumer, { children: ({ error, login, navigateToSignUp }) => {
return ((0, jsx_runtime_1.jsx)(Authentication_1.Context.Consumer, { children: ({ error, login, navigateToSignUp }) => {
const props = {

@@ -33,2 +55,3 @@ error,

}
exports.Login = Login;
//# sourceMappingURL=Login.js.map

@@ -1,3 +0,6 @@

import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export function LoginView(props) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LoginView = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
function LoginView(props) {
const clickToSignUp = (e) => {

@@ -13,4 +16,5 @@ e.preventDefault();

};
return (_jsxs("div", { children: [props.error && _jsx("p", { className: "error", children: props.error }, void 0), _jsxs("p", { children: [_jsx("label", { htmlFor: "username", children: "Username" }, void 0), _jsx("input", { id: "username", type: "text", value: props.username, onChange: props.setUsername, onKeyPress: hitEnter }, void 0)] }, void 0), _jsxs("p", { children: [_jsx("label", { htmlFor: "password", children: "Password" }, void 0), _jsx("input", { id: "password", type: "password", value: props.password, onChange: props.setPassword, onKeyPress: hitEnter }, void 0)] }, void 0), _jsx("button", { id: "login-button", onClick: props.login, children: "Login" }, void 0), _jsx("p", { children: _jsx("a", { href: "#", "data-testid": "navigate-to-sign-up", onClick: clickToSignUp, children: "Or sign up for a new account." }, void 0) }, void 0)] }, void 0));
return ((0, jsx_runtime_1.jsxs)("div", { children: [props.error && (0, jsx_runtime_1.jsx)("p", { className: "error", children: props.error }, void 0), (0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: "username", children: "Username" }, void 0), (0, jsx_runtime_1.jsx)("input", { id: "username", type: "text", value: props.username, onChange: props.setUsername, onKeyPress: hitEnter }, void 0)] }, void 0), (0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: "password", children: "Password" }, void 0), (0, jsx_runtime_1.jsx)("input", { id: "password", type: "password", value: props.password, onChange: props.setPassword, onKeyPress: hitEnter }, void 0)] }, void 0), (0, jsx_runtime_1.jsx)("button", { id: "login-button", onClick: props.login, children: "Login" }, void 0), (0, jsx_runtime_1.jsx)("p", { children: (0, jsx_runtime_1.jsx)("a", { href: "#", "data-testid": "navigate-to-sign-up", onClick: clickToSignUp, children: "Or sign up for a new account." }, void 0) }, void 0)] }, void 0));
}
exports.LoginView = LoginView;
//# sourceMappingURL=LoginView.js.map

@@ -1,8 +0,30 @@

import { jsx as _jsx } from "react/jsx-runtime";
import * as React from "react";
import { Context } from "./Authentication";
import { SignUpView } from "./SignUpView";
export class SignUp extends React.Component {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SignUp = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const React = __importStar(require("react"));
const Authentication_1 = require("./Authentication");
const SignUpView_1 = require("./SignUpView");
class SignUp extends React.Component {
static defaultProps = {
component: SignUpView,
component: SignUpView_1.SignUpView,
};

@@ -20,3 +42,3 @@ state = {

render() {
return (_jsx(Context.Consumer, { children: ({ error, signUp, navigateToLogin, }) => {
return ((0, jsx_runtime_1.jsx)(Authentication_1.Context.Consumer, { children: ({ error, signUp, navigateToLogin, }) => {
const props = {

@@ -39,2 +61,3 @@ error,

}
exports.SignUp = SignUp;
//# sourceMappingURL=SignUp.js.map

@@ -1,3 +0,6 @@

import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export function SignUpView(props) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SignUpView = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
function SignUpView(props) {
const clickToLogin = (e) => {

@@ -7,4 +10,5 @@ e.preventDefault();

};
return (_jsxs("div", { children: [props.error && _jsx("div", { className: "error", children: props.error }, void 0), _jsxs("p", { children: [_jsx("label", { htmlFor: "username", children: "Username" }, void 0), _jsx("input", { id: "username", type: "text", value: props.username, onChange: props.setUsername }, void 0)] }, void 0), _jsxs("p", { children: [_jsx("label", { htmlFor: "email", children: "Email" }, void 0), _jsx("input", { id: "email", type: "text", value: props.email, onChange: props.setEmail }, void 0)] }, void 0), _jsxs("p", { children: [_jsx("label", { htmlFor: "password", children: "Password" }, void 0), _jsx("input", { id: "password", type: "password", value: props.password, onChange: props.setPassword }, void 0)] }, void 0), _jsx("button", { id: "sign-up-button", onClick: props.signUp, children: "Sign Up" }, void 0), _jsx("p", { children: _jsx("a", { href: "#", id: "navigate-to-login", onClick: clickToLogin, children: "Return to login." }, void 0) }, void 0)] }, void 0));
return ((0, jsx_runtime_1.jsxs)("div", { children: [props.error && (0, jsx_runtime_1.jsx)("div", { className: "error", children: props.error }, void 0), (0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: "username", children: "Username" }, void 0), (0, jsx_runtime_1.jsx)("input", { id: "username", type: "text", value: props.username, onChange: props.setUsername }, void 0)] }, void 0), (0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: "email", children: "Email" }, void 0), (0, jsx_runtime_1.jsx)("input", { id: "email", type: "text", value: props.email, onChange: props.setEmail }, void 0)] }, void 0), (0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: "password", children: "Password" }, void 0), (0, jsx_runtime_1.jsx)("input", { id: "password", type: "password", value: props.password, onChange: props.setPassword }, void 0)] }, void 0), (0, jsx_runtime_1.jsx)("button", { id: "sign-up-button", onClick: props.signUp, children: "Sign Up" }, void 0), (0, jsx_runtime_1.jsx)("p", { children: (0, jsx_runtime_1.jsx)("a", { href: "#", id: "navigate-to-login", onClick: clickToLogin, children: "Return to login." }, void 0) }, void 0)] }, void 0));
}
exports.SignUpView = SignUpView;
//# sourceMappingURL=SignUpView.js.map

@@ -1,6 +0,10 @@

import { jsx as _jsx } from "react/jsx-runtime";
import { Context } from "./Authentication";
export function Unauthenticated({ children, }) {
return (_jsx(Context.Consumer, { children: ({ authenticated }) => authenticated ? null : children }, void 0));
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Unauthenticated = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const Authentication_1 = require("./Authentication");
function Unauthenticated({ children, }) {
return ((0, jsx_runtime_1.jsx)(Authentication_1.Context.Consumer, { children: ({ authenticated }) => authenticated ? null : children }, void 0));
}
exports.Unauthenticated = Unauthenticated;
//# sourceMappingURL=Unauthenticated.js.map

@@ -0,12 +1,24 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
// Supporting components
export * from "./components/Authenticated";
export * from "./components/Login";
export * from "./components/LoginView";
export * from "./components/SignUp";
export * from "./components/SignUpView";
export * from "./components/Unauthenticated";
__exportStar(require("./components/Authenticated"), exports);
__exportStar(require("./components/Login"), exports);
__exportStar(require("./components/LoginView"), exports);
__exportStar(require("./components/SignUp"), exports);
__exportStar(require("./components/SignUpView"), exports);
__exportStar(require("./components/Unauthenticated"), exports);
// Main component for use in applications
export * from "./components/Authentication";
__exportStar(require("./components/Authentication"), exports);
// Utilities for composing apps
export * from "./utils/withAuthentication";
__exportStar(require("./utils/withAuthentication"), exports);
//# sourceMappingURL=index.js.map

@@ -1,8 +0,31 @@

import { jsx as _jsx } from "react/jsx-runtime";
import * as React from "react";
import { Context } from "../";
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withAuthentication = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const React = __importStar(require("react"));
const __1 = require("../");
//): React.FunctionComponent<Omit<P, "putDocument"> & PassThruDocumentProps> {
export function withAuthentication(component) {
return () => (_jsx(Context.Consumer, { children: ({ db, remoteDb, logout, user }) => React.createElement(component, { db, remoteDb, logout, user }) }, void 0));
function withAuthentication(component) {
return () => ((0, jsx_runtime_1.jsx)(__1.Context.Consumer, { children: ({ db, remoteDb, logout, user }) => React.createElement(component, { db, remoteDb, logout, user }) }, void 0));
}
exports.withAuthentication = withAuthentication;
//# sourceMappingURL=withAuthentication.js.map
{
"name": "@stanlemon/react-couchdb-authentication",
"version": "0.7.0",
"version": "0.7.1",
"description": "React component for authenticating against a CouchDB user db and syncing it locally with PouchDB.",

@@ -5,0 +5,0 @@ "keywords": [

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc