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.2.6 to 0.2.7

7

dist/Authentication.d.ts

@@ -44,2 +44,6 @@ import * as React from "react";

loading?: React.ReactElement;
/**
* Interval to check the session.
*/
sessionInterval: number;
}

@@ -79,2 +83,4 @@ interface State {

static defaultProps: {
login: JSX.Element;
signup: JSX.Element;
loading: JSX.Element;

@@ -84,2 +90,3 @@ debug: boolean;

adapter: string;
sessionInterval: number;
};

@@ -86,0 +93,0 @@ state: State;

33

dist/Authentication.js

@@ -14,2 +14,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import "isomorphic-fetch";
import { Login, LoginView, SignUp, SignUpView } from "./components";
const ROUTE_LOGIN = "login";

@@ -100,3 +101,3 @@ const ROUTE_SIGNUP = "signup";

this.setState({ authenticated: true, user });
this.setupDb();
this.setupDb(username, password);
}

@@ -160,3 +161,9 @@ catch (err) {

try {
const session = yield this.fetch(this.props.url + "_session");
// If we have a remoteDb, we'll use it. This works better in Safari which does
// not support storing cross-origin cookies across multiple requests.
const session = this.remoteDb
? // This is not exposed via the TypeScript definition for PouchDB.Database
// but it is added by the HTTP adapter, and we've accounted for it on the property
yield this.remoteDb.fetch("../_session").then((d) => d.json())
: yield this.fetch(this.props.url + "_session");
this.log("User session", session);

@@ -171,2 +178,3 @@ const isLoggedIn = !!session.userCtx.name;

if (isLoggedIn && !this.remoteDb) {
this.log("User is already logged in, setting up db.");
this.setupDb();

@@ -181,14 +189,18 @@ }

}
setupDb() {
setupDb(username, password) {
this.localDb = new PouchDB("user", {
adapter: this.props.adapter,
});
const opts = {
skip_setup: true,
fetch: (url, opts) => {
const opts = Object.assign({ skip_setup: true, fetch: (url, opts) => {
// In PouchDB 7.0 they dropped this and it breaks cookie authentication, so we set this explicitly
opts.credentials = "include";
return PouchDB.fetch(url, opts);
},
};
} }, (username && password
? {
auth: {
username,
password,
},
}
: {}));
const userDbUrl = this.getUserDbUrl(this.state.user.name);

@@ -219,3 +231,3 @@ this.remoteDb = new PouchDB(userDbUrl, opts);

this.checkSession();
}, 15000);
}, this.props.sessionInterval);
}

@@ -295,2 +307,4 @@ componentWillUnmount() {

Authentication.defaultProps = {
login: React.createElement(Login, { component: LoginView }),
signup: React.createElement(SignUp, { component: SignUpView }),
loading: React.createElement(React.Fragment, null, "Loading..."),

@@ -300,3 +314,4 @@ debug: false,

adapter: "idb",
sessionInterval: 15000,
};
//# sourceMappingURL=Authentication.js.map
{
"name": "@stanlemon/react-couchdb-authentication",
"version": "0.2.6",
"version": "0.2.7",
"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

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