mongodb-stitch
Version:
[](https://gitter.im/mongodb/stitch?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
60 lines • 2.59 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { StitchRequest } from "./StitchRequest";
var StitchAuthRequest = (function (_super) {
__extends(StitchAuthRequest, _super);
function StitchAuthRequest(request, useRefreshToken, shouldRefreshOnFailure) {
if (useRefreshToken === void 0) { useRefreshToken = false; }
if (shouldRefreshOnFailure === void 0) { shouldRefreshOnFailure = true; }
var _this = _super.call(this, request.method, request.path, request.headers, request.startedAt, request.body) || this;
_this.useRefreshToken = useRefreshToken;
_this.shouldRefreshOnFailure = shouldRefreshOnFailure;
return _this;
}
Object.defineProperty(StitchAuthRequest.prototype, "builder", {
get: function () {
return new StitchAuthRequest.Builder(this);
},
enumerable: true,
configurable: true
});
return StitchAuthRequest;
}(StitchRequest));
export { StitchAuthRequest };
(function (StitchAuthRequest) {
var Builder = (function (_super) {
__extends(Builder, _super);
function Builder(request) {
return _super.call(this, request) || this;
}
Builder.prototype.withAccessToken = function () {
this.useRefreshToken = false;
return this;
};
Builder.prototype.withRefreshToken = function () {
this.useRefreshToken = true;
return this;
};
Builder.prototype.withShouldRefreshOnFailure = function (shouldRefreshOnFailure) {
this.shouldRefreshOnFailure = shouldRefreshOnFailure;
return this;
};
Builder.prototype.build = function () {
if (this.useRefreshToken) {
this.shouldRefreshOnFailure = false;
}
return new StitchAuthRequest(_super.prototype.build.call(this), this.useRefreshToken, this.shouldRefreshOnFailure);
};
return Builder;
}(StitchRequest.Builder));
StitchAuthRequest.Builder = Builder;
})(StitchAuthRequest || (StitchAuthRequest = {}));
//# sourceMappingURL=StitchAuthRequest.js.map