UNPKG

@arc-publishing/sdk-identity

Version:
34 lines 1.45 kB
import { __assign, __rest } from "tslib"; import JSONResponseHandler from '../serviceHelpers/JSONResponseHandler'; import { isSignUpResponse } from './userProfile'; import Identity from './identity'; import { headers } from './constants'; import enforceRecaptcha, { RecaptchaMethod } from '../utils/enforceRecaptcha'; export default function signUp(identity, profile, _, rememberMe, recaptchaToken) { return enforceRecaptcha(RecaptchaMethod.SIGN_UP, recaptchaToken) .then(function () { return fetch("".concat(Identity.apiOrigin, "/identity/public/v1/signup"), { method: 'POST', headers: headers, body: JSON.stringify({ identity: identity, profile: profile, recaptchaToken: recaptchaToken }) }); }) .then(JSONResponseHandler) .then(function (json) { if (isSignUpResponse(json)) { Identity._isSession = !rememberMe; var identities = json.identities, profile_1 = json.profile, uuid = json.uuid, userIdentity = __rest(json, ["identities", "profile", "uuid"]); Identity.userProfile = __assign(__assign({}, profile_1), { identities: identities, uuid: uuid }); Identity.userIdentity = __assign({ uuid: uuid }, userIdentity); return json; } else { throw json; } }); } //# sourceMappingURL=signUp.js.map