@studyportals/sp-hs-misc
Version:
Miscellaneous code used in HouseStark's projects
76 lines • 2.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SignedSuperAgentRequestFactory = void 0;
const base_super_agent_request_factory_class_1 = require("../requests/base-super-agent-request-factory.class");
/**
* A basic implementation of the ISignedSuperAgentRequestFactory interface.
*
* @deprecated Use the SessionTokenRequestSigner instead.
*/
class SignedSuperAgentRequestFactory extends base_super_agent_request_factory_class_1.BaseSuperAgentRequestFactory {
/**
* Initializes a new SignedSuperAgentRequestFactory instance.
*
* @param userSessionOperationsProvider The IUserSessionOperationsProvider object used by the new instance.
*/
constructor(userSessionOperationsProvider) {
super();
this._userSessionOperationsProvider = userSessionOperationsProvider;
}
/**
* Gets the IUserSessionOperationsProvider object used by the current instance.
*/
get userSessionOperationsProvider() {
return this._userSessionOperationsProvider;
}
/**
* 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.
*/
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.
*/
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.
*/
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.
*/
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.
*/
signRequest(request) {
request.set('Authorization', this.userSessionOperationsProvider.getAuthorization());
return request;
}
}
exports.SignedSuperAgentRequestFactory = SignedSuperAgentRequestFactory;
//# sourceMappingURL=signed-super-agent-request-factory.class.js.map