@arc-publishing/sdk-identity
Version:
JS Identity SDK for working with Identity API
42 lines • 1.76 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getConfig = exports.isConfigOptions = void 0;
var tslib_1 = require("tslib");
var constants_1 = require("./constants");
var identity_1 = tslib_1.__importDefault(require("./identity"));
var JSONResponseHandler_1 = tslib_1.__importDefault(require("../serviceHelpers/JSONResponseHandler"));
var APIErrorResponse_1 = require("../serviceHelpers/APIErrorResponse");
function isConfigOptions(object) {
return object.signinRecaptcha !== undefined;
}
exports.isConfigOptions = isConfigOptions;
function getConfig() {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
if (!identity_1.default._configOptions) {
return [2, fetch("".concat(identity_1.default.apiOrigin, "/identity/public/v1/config"), {
method: 'GET',
cache: 'no-cache',
headers: tslib_1.__assign({}, constants_1.headers)
})
.then(JSONResponseHandler_1.default)
.then(function (json) {
if ((0, APIErrorResponse_1.isAPIErrorResponse)(json)) {
throw json;
}
else {
identity_1.default._configOptions = json;
return json;
}
})];
}
else {
return [2, identity_1.default._configOptions];
}
return [2];
});
});
}
exports.getConfig = getConfig;
exports.default = getConfig;
//# sourceMappingURL=getConfig.js.map