Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
couch-persona
Advanced tools
Readme
A Node.js server that integrated Mozilla Persona logins with Apache CouchDB, once a user has successfully authenticated with persona we create a user and a database for their use only, on a successful login this script will return the url to a couchdb database and a token used to authenticate against that instance.
couch-persona requires a CouchDB host running, preferably with CORS support enabled.
Install and start your server
$ npm install -g couch-persona
$ couch-persona --host=http://127.0.0.1:5984 --username=john --password=doe
Follow the Quick Setup instructions on the MDN wiki to install the persona client on your site, ensure you use the correct urls to sign in and out (/persona/sign-in
+ /persona/sign-out
). Here is some example working code:
// Host that the couch-persona server is running on
var authHost = 'http://127.0.0.1:3000';
var loggedIn = function(result) {
console.log('logged in:', result);
// result.dbUrl is the location of your CouchDB Instance
// result.authToken is the token you need to be able to write to it,
// use xhr.setRequestHeader("Cookie", result.authToken);
};
var loggedOut = function() {
console.log('logged out!');
};
function simpleXhrSentinel(xhr) {
return function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var result = {};
try {
result = JSON.parse(xhr.responseText);
} catch(e) {}
loggedIn(result);
} else {
loggedOut();
navigator.id.logout();
}
}
};
}
function verifyAssertion(assertion) {
var xhr = new XMLHttpRequest();
var param = 'assert=' + assertion;
xhr.open('POST', authHost + '/persona/sign-in', true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Content-length", param.length);
xhr.setRequestHeader("Connection", "close");
xhr.send(param);
xhr.onreadystatechange = simpleXhrSentinel(xhr);
}
function signoutUser() {
var xhr = new XMLHttpRequest();
xhr.open("POST", authHost + '/persona/sign-out', true);
xhr.send(null);
xhr.onreadystatechange = simpleXhrSentinel(xhr);
}
navigator.id.watch({
onlogin: verifyAssertion,
onlogout: signoutUser
});
var signinLink = document.getElementById('signin');
var signoutLink = document.getElementById('signout');
signinLink.onclick = function() { navigator.id.request(); };
signoutLink.onclick = function() { navigator.id.logout(); };
FAQs
A server that integrates persona with CouchDB
The npm package couch-persona receives a total of 6 weekly downloads. As such, couch-persona popularity was classified as not popular.
We found that couch-persona demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.