@awhere/api
Version:
The awesome aWhere API for JavaScript.
138 lines • 4.5 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var randomstring_1 = __importDefault(require("randomstring"));
var PrototypeBase_1 = __importDefault(require("../PrototypeBase"));
var User_1 = __importDefault(require("../User"));
var APIKey = /** @class */ (function (_super) {
__extends(APIKey, _super);
function APIKey(props) {
if (props === void 0) { props = {}; }
var _this = _super.call(this, props) || this;
_this._id = props._id || APIKey.generateId();
if (props.key !== undefined) {
_this.key = props.key;
}
else {
_this.key = APIKey.generateKey();
}
if (props.name !== undefined) {
_this.name = props.name;
}
if (props.description !== undefined) {
_this.description = props.description;
}
if (props.restrictionType !== undefined) {
_this.restrictionType = props.restrictionType;
}
if (typeof props.owner === 'object') {
_this.user = new User_1.default(props.owner);
}
else {
_this.user = props.owner;
}
if (props.scope !== undefined) {
_this.scope = props.scope;
}
if (props.expiresAt !== undefined) {
_this.expiresAt = props.expiresAt;
}
return _this;
}
APIKey.generateId = function () {
return _super.generateId.call(this, 'awhere.core.api-key');
};
APIKey.generateKey = function () {
return randomstring_1.default.generate(64);
};
Object.defineProperty(APIKey.prototype, "name", {
get: function () {
return this._name;
},
set: function (value) {
this._name = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(APIKey.prototype, "description", {
get: function () {
return this._description;
},
set: function (value) {
this._description = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(APIKey.prototype, "key", {
get: function () {
return this._key;
},
set: function (value) {
this._key = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(APIKey.prototype, "user", {
get: function () {
return this._user;
},
set: function (value) {
this._user = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(APIKey.prototype, "scope", {
get: function () {
return this._scope;
},
set: function (value) {
this._scope = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(APIKey.prototype, "restrictionType", {
get: function () {
return this._restrictionType;
},
set: function (value) {
this._restrictionType = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(APIKey.prototype, "expiresAt", {
get: function () {
return this._expiresAt;
},
set: function (value) {
this._expiresAt = value;
},
enumerable: false,
configurable: true
});
return APIKey;
}(PrototypeBase_1.default));
exports.default = APIKey;
//# sourceMappingURL=APIKey.js.map