UNPKG

madeline-ton

Version:

Pure JS client-side implementation of the Telegram TON blockchain protocol

102 lines (87 loc) 2.78 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _tempAuthKey = _interopRequireDefault(require("./tempAuthKey")); var AuthInfo = /*#__PURE__*/ function () { function AuthInfo() { (0, _classCallCheck2["default"])(this, AuthInfo); } (0, _createClass2["default"])(AuthInfo, [{ key: "setAuthKey", /** * Set auth key * @param {AuthKey} key AuthKey * @param {boolean} temp Whether to set temporary or pemanent auth key */ value: function setAuthKey(key) { var temp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; if (temp) { this.tempAuthKey = key; } else { this.permAuthKey = key; } } /** * Get auth key * @param {boolean} temp Whether to get temporary or permanent auth key */ }, { key: "getAuthKey", value: function getAuthKey() { var temp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; return temp ? this.tempAuthKey : this.permAuthKey; } /** * Check whether temporary or permanent auth key exists * @param {boolean} temp */ }, { key: "hasAuthKey", value: function hasAuthKey() { var temp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; return typeof (temp ? this.tempAuthKey : this.permAuthKey) !== 'undefined'; } /** * Bind temporary and permanent auth keys * @param {boolean} pfs Whether to bind using PFS */ }, { key: "bindPfs", value: function bindPfs() { var pfs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; if (!pfs && !this.tempAuthKey) { this.tempAuthKey = new _tempAuthKey["default"](); } this.tempAuthKey.bindPerm(this.permAuthKey, pfs); } }, { key: "isBound", value: function isBound() { return this.tempAuthKey ? this.tempAuthKey.isBound() : false; } }, { key: "isAuthorized", value: function isAuthorized() { return this.tempAuthKey ? this.tempAuthKey.isAuthorized() : false; } }, { key: "authorized", value: function authorized(_authorized) { if (_authorized) { this.tempAuthKey.authorized(_authorized); } else if (this.tempAuthKey) { this.tempAuthKey.authorized(_authorized); } } }]); return AuthInfo; }(); var _default = AuthInfo; exports["default"] = _default;