@arc-publishing/sdk-identity
Version:
JS Identity SDK for working with Identity API
236 lines • 10.1 kB
JavaScript
import { IDENTITY_STORAGE_KEY, PROFILE_STORAGE_KEY, USER_SETTINGS_STORAGE_KEY, AMP_ID_STORAGE_KEY, USER_SEGMENTS_STORAGE_KEY } from './constants';
import { initStorage, shouldStorageChange } from '../utils/storage';
import login, { isLoggedIn } from './login';
import logout from './logout';
import requestMagicLink from './requestMagicLink';
import redeemMagicLink from './redeemMagicLink';
import { extendSession, heartbeat } from './extendSession';
import clearSession from './clearSession';
import options from './options';
import requestOTALink from './requestOTALink';
import redeemOTALink from './redeemOTALink';
import getUserProfile from './getUserProfile';
import getUserSegments from './getUserSegments';
import updateUserProfile from './updateUserProfile';
import { uploadAvatar, deleteAvatar } from './avatar';
import signUp from './signUp';
import updatePassword from './updatePassword';
import requestResetPassword from './requestResetPassword';
import resetPassword from './resetPassword';
import requestVerifyEmail from './requestVerifyEmail';
import verifyEmail from './verifyEmail';
import { getConfig } from './getConfig';
import requestDeleteAccount, { approveDeleteAccount, declineDeleteAccount } from './requestDeleteAccount';
import { getUserSettings } from './getUserSettings';
import getThirdPartyTokens from './getThirdPartyTokens';
import listGdprReports from './listGdprReports';
import getGdprReport from './getGdprReport';
import initFacebookLogin from './initFacebookLogin';
import initGoogleLogin, { initGoogleAuthSDK, initGoogleAuth } from './initGoogleLogin';
import initAppleSignOn from './initAppleSignOn';
import initiateOIDC from './initiateOIDC';
import signInWithOIDC from './signInWithOIDC';
import signInWithOIDCPKCE from './signInWithOIDCPKCE';
import loginWithArcIdentityAsOIDCProvider from './loginWithArcIdentityAsOIDCProvider';
import unlinkOIDC from './unlinkOIDC';
import facebookSignOn from './facebookSignOn';
import googleSignOn, { signOnSwgUser } from './googleSignOn';
import signInWithGoogle from './signInWithGoogle';
import appleSignOn from './appleSignOn';
import unlinkSocialIdentity from './unlinkSocialIdentity';
import getSwgAccessToken from './getSwgAccessToken';
import checkSwgLogin from './checkSwgLogin';
import relinkGoogleAccount from './relinkGoogleAccount';
import CookieStorage from '../utils/cookieStorage';
var Identity = (function () {
function Identity() {
}
Object.defineProperty(Identity, "userIdentity", {
get: function () {
if (!this._userIdentity && this._userIdentityStorage) {
this._userIdentity = JSON.parse(this._userIdentityStorage.getItem(IDENTITY_STORAGE_KEY) || '{}');
}
return this._userIdentity;
},
set: function (v) {
if (shouldStorageChange(this._userIdentityStorage, this._isSession, IDENTITY_STORAGE_KEY)) {
if (this._userIdentityStorage instanceof CookieStorage) {
this._userIdentityStorage.removeItem(IDENTITY_STORAGE_KEY);
}
this._userIdentityStorage = initStorage(this._baseDomain, this._isSession);
}
if (!v.uuid && !v.accessToken && !v.refreshToken && !v.impersonator) {
this._userIdentityStorage.removeItem(IDENTITY_STORAGE_KEY);
}
this._userIdentityStorage.setItem(IDENTITY_STORAGE_KEY, JSON.stringify(v));
this._userIdentity = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Identity, "userProfile", {
get: function () {
if (!this._userProfile) {
this._userProfile = JSON.parse(this._selectedStorage.getItem(PROFILE_STORAGE_KEY) || null);
}
return this._userProfile;
},
set: function (u) {
var _a, _b;
if (u === null) {
this._selectedStorage.removeItem(PROFILE_STORAGE_KEY);
}
if (shouldStorageChange(this._selectedStorage, this._isSession, PROFILE_STORAGE_KEY)) {
if (this._selectedStorage instanceof CookieStorage) {
this._selectedStorage.removeItem(PROFILE_STORAGE_KEY);
}
this._selectedStorage = initStorage(this._baseDomain, this._isSession, (_a = this._profileStorageOpt) === null || _a === void 0 ? void 0 : _a.storageExp);
}
if ((_b = this._profileStorageOpt) === null || _b === void 0 ? void 0 : _b.ignoreProfile) {
this._selectedStorage.removeItem(PROFILE_STORAGE_KEY);
}
else {
this._selectedStorage.setItem(PROFILE_STORAGE_KEY, JSON.stringify(u));
}
this._userProfile = u;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Identity, "userSegments", {
get: function () {
if (!this._userSegments) {
this._userSegments = JSON.parse(this._selectedStorage.getItem(USER_SEGMENTS_STORAGE_KEY) || null);
}
return this._userSegments;
},
set: function (us) {
this._selectedStorage.setItem(USER_SEGMENTS_STORAGE_KEY, JSON.stringify(us));
this._userSegments = us;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Identity, "configOptions", {
get: function () {
return this._configOptions;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Identity, "userSettings", {
get: function () {
if (!this._userSettings && !this._userSettings) {
this._userSettings = JSON.parse(this._selectedStorage.getItem(USER_SETTINGS_STORAGE_KEY) || null);
}
return this._userSettings;
},
set: function (u) {
if (u === null) {
this._selectedStorage.removeItem(USER_SETTINGS_STORAGE_KEY);
}
this._selectedStorage.setItem(USER_SETTINGS_STORAGE_KEY, JSON.stringify(u));
},
enumerable: false,
configurable: true
});
Object.defineProperty(Identity, "baseDomain", {
set: function (v) {
this._userIdentityStorage = initStorage(v);
this._baseDomain = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Identity, "ampReaderId", {
get: function () {
if (!this._ampReaderId) {
this._ampReaderId = JSON.parse(this._selectedStorage.getItem(AMP_ID_STORAGE_KEY) || null);
}
return this._ampReaderId;
},
set: function (u) {
if (u === null || u === undefined) {
this._selectedStorage.removeItem(AMP_ID_STORAGE_KEY);
}
else if (!!u) {
this._selectedStorage.setItem(AMP_ID_STORAGE_KEY, JSON.stringify(u));
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(Identity, "profileStorageOpt", {
get: function () {
return this._profileStorageOpt;
},
set: function (u) {
if (!!u) {
this._profileStorageOpt = u;
}
},
enumerable: false,
configurable: true
});
Identity._version = require('../../package.json').version;
Identity._userIdentityStorage = initStorage();
Identity._selectedStorage = initStorage();
Identity.apiOrigin = '';
Identity._baseDomain = '';
Identity._google = {
useCustomButton: false
};
Identity._useCustomFBButton = false;
Identity.options = options;
Identity.login = login;
Identity.isLoggedIn = isLoggedIn;
Identity.extendSession = extendSession;
Identity.clearSession = clearSession;
Identity.heartbeat = heartbeat;
Identity.logout = logout;
Identity.getUserSettings = getUserSettings;
Identity.getUserProfile = getUserProfile;
Identity.getUserSegments = getUserSegments;
Identity.updateUserProfile = updateUserProfile;
Identity.uploadAvatar = uploadAvatar;
Identity.deleteAvatar = deleteAvatar;
Identity.signUp = signUp;
Identity.updatePassword = updatePassword;
Identity.requestResetPassword = requestResetPassword;
Identity.resetPassword = resetPassword;
Identity.requestDeleteAccount = requestDeleteAccount;
Identity.approveDeleteAccount = approveDeleteAccount;
Identity.declineDeleteAccount = declineDeleteAccount;
Identity.getConfig = getConfig;
Identity.initFacebookLogin = initFacebookLogin;
Identity.facebookSignOn = facebookSignOn;
Identity.initGoogleLogin = initGoogleLogin;
Identity.initGoogleAuthSDK = initGoogleAuthSDK;
Identity.initGoogleAuth = initGoogleAuth;
Identity.initiateOIDC = initiateOIDC;
Identity.signInWithOIDC = signInWithOIDC;
Identity.signInWithOIDCPKCE = signInWithOIDCPKCE;
Identity.loginWithArcIdentityAsOIDCProvider = loginWithArcIdentityAsOIDCProvider;
Identity.unlinkOIDC = unlinkOIDC;
Identity.googleSignOn = googleSignOn;
Identity.signInWithGoogle = signInWithGoogle;
Identity.initAppleSignOn = initAppleSignOn;
Identity.appleSignOn = appleSignOn;
Identity.requestMagicLink = requestMagicLink;
Identity.redeemMagicLink = redeemMagicLink;
Identity.requestVerifyEmail = requestVerifyEmail;
Identity.verifyEmail = verifyEmail;
Identity.listGdprReports = listGdprReports;
Identity.getGdprReport = getGdprReport;
Identity.getThirdPartyTokens = getThirdPartyTokens;
Identity.unlinkSocialIdentity = unlinkSocialIdentity;
Identity.requestOTALink = requestOTALink;
Identity.redeemOTALink = redeemOTALink;
Identity.getSwgAccessToken = getSwgAccessToken;
Identity.checkSwgLogin = checkSwgLogin;
Identity.relinkGoogleAccount = relinkGoogleAccount;
Identity.signOnSwgUser = signOnSwgUser;
return Identity;
}());
export default Identity;
//# sourceMappingURL=identity.js.map