UNPKG

@accounts/database-manager

Version:

Accounts Database Manager, allow the use of separate databases for session and user

232 lines 9.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DatabaseManager = void 0; var DatabaseManager = /** @class */ (function () { function DatabaseManager(configuration) { this.validateConfiguration(configuration); this.userStorage = configuration.userStorage; this.sessionStorage = configuration.sessionStorage; } DatabaseManager.prototype.validateConfiguration = function (configuration) { if (!configuration) { throw new Error('[ Accounts - DatabaseManager ] configuration : A configuration object is required on DatabaseManager'); } if (!configuration.userStorage) { throw new Error('[ Accounts - DatabaseManager ] configuration : A userStorage DatabaseInterface is required'); } if (!configuration.sessionStorage) { throw new Error('[ Accounts - DatabaseManager ] configuration : A sessionStorage DatabaseInterface is required'); } }; Object.defineProperty(DatabaseManager.prototype, "createUser", { // Return the createUser function from the userStorage get: function () { return this.userStorage.createUser.bind(this.userStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "findUserById", { // Return the findUserById function from the userStorage get: function () { return this.userStorage.findUserById.bind(this.userStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "findUserByEmail", { // Return the findUserByEmail function from the userStorage get: function () { return this.userStorage.findUserByEmail.bind(this.userStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "findUserByUsername", { // Return the findUserByUsername function from the userStorage get: function () { return this.userStorage.findUserByUsername.bind(this.userStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "findPasswordHash", { // Return the findPasswordHash function from the userStorage get: function () { return this.userStorage.findPasswordHash.bind(this.userStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "findUserByEmailVerificationToken", { // Return the findUserByEmailVerificationToken function from the userStorage get: function () { return this.userStorage.findUserByEmailVerificationToken.bind(this.userStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "findUserByResetPasswordToken", { // Return the findUserByResetPasswordToken function from the userStorage get: function () { return this.userStorage.findUserByResetPasswordToken.bind(this.userStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "findUserByServiceId", { // Return the findUserByServiceId function from the userStorage get: function () { return this.userStorage.findUserByServiceId.bind(this.userStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "addEmail", { // Return the addEmail function from the userStorage get: function () { return this.userStorage.addEmail.bind(this.userStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "removeEmail", { // Return the removeEmail function from the userStorage get: function () { return this.userStorage.removeEmail.bind(this.userStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "verifyEmail", { // Return the verifyEmail function from the userStorage get: function () { return this.userStorage.verifyEmail.bind(this.userStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "setUsername", { // Return the setUsername function from the userStorage get: function () { return this.userStorage.setUsername.bind(this.userStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "setPassword", { // Return the setPassword function from the userStorage get: function () { return this.userStorage.setPassword.bind(this.userStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "setService", { // Return the setService function from the userStorage get: function () { return this.userStorage.setService.bind(this.userStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "unsetService", { // Return the unsetService function from the userStorage get: function () { return this.userStorage.unsetService.bind(this.userStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "createSession", { // Return the createSession function from the sessionStorage get: function () { return this.sessionStorage.createSession.bind(this.sessionStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "updateSession", { // Return the updateSession function from the sessionStorage get: function () { return this.sessionStorage.updateSession.bind(this.sessionStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "invalidateSession", { // Return the invalidateSession function from the sessionStorage get: function () { return this.sessionStorage.invalidateSession.bind(this.sessionStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "invalidateAllSessions", { // Return the invalidateAllSessions function from the sessionStorage get: function () { return this.sessionStorage.invalidateAllSessions.bind(this.sessionStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "removeAllResetPasswordTokens", { // Return the removeAllResetPasswordTokens function from the sessionStorage get: function () { return this.userStorage.removeAllResetPasswordTokens.bind(this.userStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "findSessionByToken", { // Return the findSessionByToken function from the sessionStorage get: function () { return this.sessionStorage.findSessionByToken.bind(this.sessionStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "findSessionById", { // Return the findSessionById function from the sessionStorage get: function () { return this.sessionStorage.findSessionById.bind(this.sessionStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "addEmailVerificationToken", { // Return the addEmailVerificationToken function from the userStorage get: function () { return this.userStorage.addEmailVerificationToken.bind(this.userStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "addResetPasswordToken", { // Return the addResetPasswordToken function from the userStorage get: function () { return this.userStorage.addResetPasswordToken.bind(this.userStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "setResetPassword", { // Return the setResetPassword function from the userStorage get: function () { return this.userStorage.setResetPassword.bind(this.userStorage); }, enumerable: false, configurable: true }); Object.defineProperty(DatabaseManager.prototype, "setUserDeactivated", { // Return the setResetPassword function from the userStorage get: function () { return this.userStorage.setUserDeactivated.bind(this.userStorage); }, enumerable: false, configurable: true }); return DatabaseManager; }()); exports.DatabaseManager = DatabaseManager; //# sourceMappingURL=database-manager.js.map