@perfood/couch-auth
Version:
Easy and secure authentication for CouchDB/Cloudant. Based on SuperLogin, updated and rewritten in Typescript.
27 lines (26 loc) • 846 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Session = void 0;
const hashing_session_1 = require("./hashing-session");
class Session {
constructor() { }
/**
* Confirms that the password matches with the provided token and returns the
* token, if successful, but removes the information that should not be sent
* to the client.
*/
async confirmToken(token, password) {
try {
await (0, hashing_session_1.verifyCouchPassword)(token, password);
delete token.salt;
delete token.derived_key;
delete token.iterations;
return token;
}
catch (error) {
throw Session.invalidErr;
}
}
}
exports.Session = Session;
Session.invalidErr = { status: 401, message: 'invalid token' };