@studyportals/sp-hs-misc
Version:
Miscellaneous code used in HouseStark's projects
108 lines (92 loc) • 4.49 kB
JavaScript
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**
* A basic implementation of the ISignedSuperAgentRequestFactory interface.
*
* @deprecated Use the SessionTokenRequestSigner instead.
*/
//# sourceMappingURL=signed-super-agent-request-factory.class.js.map
var SignedSuperAgentRequestFactory = function (_BaseSuperAgentReques) {
_inherits(SignedSuperAgentRequestFactory, _BaseSuperAgentReques);
/**
* Initializes a new SignedSuperAgentRequestFactory instance.
*
* @param userSessionOperationsProvider The IUserSessionOperationsProvider object used by the new instance.
*/
function SignedSuperAgentRequestFactory(userSessionOperationsProvider) {
_classCallCheck(this, SignedSuperAgentRequestFactory);
var _this = _possibleConstructorReturn(this, (SignedSuperAgentRequestFactory.__proto__ || Object.getPrototypeOf(SignedSuperAgentRequestFactory)).call(this));
_this._userSessionOperationsProvider = userSessionOperationsProvider;
return _this;
}
/**
* Gets the IUserSessionOperationsProvider object used by the current instance.
*/
_createClass(SignedSuperAgentRequestFactory, [{
key: "getSigned",
/**
* Creates a GET request to the specified path.
*
* Configures the request in such a way that the receiving party
* will be able to recognise the user's identity.
*/
value: function getSigned(path) {
return this.signRequest(this.get(path));
}
/**
* Creates a POST request to the specified path.
*
* Configures the request in such a way that the receiving party
* will be able to recognise the user's identity.
*/
}, {
key: "postSigned",
value: function postSigned(path) {
return this.signRequest(this.post(path));
}
/**
* Creates a PUT request to the specified path.
*
* Configures the request in such a way that the receiving party
* will be able to recognise the user's identity.
*/
}, {
key: "putSigned",
value: function putSigned(path) {
return this.signRequest(this.put(path));
}
/**
* Creates a DELETE request to the specified path.
*
* Configures the request in such a way that the receiving party
* will be able to recognise the user's identity.
*/
}, {
key: "deleteSigned",
value: function deleteSigned(path) {
return this.signRequest(this.delete(path));
}
/**
* Configures the request in such a way that the receiving party
* will be able to recognise the user's identity.
*
* Returns the configured request.
*
* @param request The request that is to be signed.
*/
}, {
key: "signRequest",
value: function signRequest(request) {
request.set('Authorization', this.userSessionOperationsProvider.getAuthorization());
return request;
}
}, {
key: "userSessionOperationsProvider",
get: function get() {
return this._userSessionOperationsProvider;
}
}]);
return SignedSuperAgentRequestFactory;
}(BaseSuperAgentRequestFactory);