UNPKG

graphdb

Version:

Javascript client library supporting GraphDB and RDF4J REST API.

88 lines (81 loc) 3.1 kB
"use strict"; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /** * Logged in user credentials and settings. * * @class * @author Mihail Radkov * @author Svilen Velikov */ var User = /*#__PURE__*/function () { /** * Instantiates the user. * @param {string} token is the authentication token obtained with the login. * @param {string} password of the user * @param {Object} data is the logged in user data which contains the username * the role and settings. */ function User(token, password, data) { _classCallCheck(this, User); this.token = token; this.password = password; this.data = data; } /** * @return {string} the authentication token. */ return _createClass(User, [{ key: "getToken", value: function getToken() { return this.token; } /** * Removes the token which effectively make the user unauthenticated. */ }, { key: "clearToken", value: function clearToken() { this.token = undefined; } /** * @return {string} the logged in username. */ }, { key: "getUsername", value: function getUsername() { return this.getProperty('username'); } /** * @return {string} the user's password. */ }, { key: "getPassword", value: function getPassword() { return this.password; } /** * @return {Array<string>} an array of user roles. */ }, { key: "getAuthorities", value: function getAuthorities() { return this.getProperty('authorities'); } /** * @private * @param {string} name is the property name * @return {*} the property value or undefined if data or property is missing. */ }, { key: "getProperty", value: function getProperty(name) { return this.data ? this.data[name] : undefined; } }]); }(); module.exports = User;