UNPKG

@arc-publishing/sdk-identity

Version:
37 lines 1.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var JSONResponseHandler_1 = tslib_1.__importDefault(require("../serviceHelpers/JSONResponseHandler")); var userProfile_1 = require("./userProfile"); var identity_1 = tslib_1.__importDefault(require("./identity")); var constants_1 = require("./constants"); var enforceRecaptcha_1 = tslib_1.__importStar(require("../utils/enforceRecaptcha")); function signUp(identity, profile, _, rememberMe, recaptchaToken) { return (0, enforceRecaptcha_1.default)(enforceRecaptcha_1.RecaptchaMethod.SIGN_UP, recaptchaToken) .then(function () { return fetch("".concat(identity_1.default.apiOrigin, "/identity/public/v1/signup"), { method: 'POST', headers: constants_1.headers, body: JSON.stringify({ identity: identity, profile: profile, recaptchaToken: recaptchaToken }) }); }) .then(JSONResponseHandler_1.default) .then(function (json) { if ((0, userProfile_1.isSignUpResponse)(json)) { identity_1.default._isSession = !rememberMe; var identities = json.identities, profile_1 = json.profile, uuid = json.uuid, userIdentity = tslib_1.__rest(json, ["identities", "profile", "uuid"]); identity_1.default.userProfile = tslib_1.__assign(tslib_1.__assign({}, profile_1), { identities: identities, uuid: uuid }); identity_1.default.userIdentity = tslib_1.__assign({ uuid: uuid }, userIdentity); return json; } else { throw json; } }); } exports.default = signUp; //# sourceMappingURL=signUp.js.map