@or-sdk/auth 0.24.9-beta.994.0 → 0.24.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/cjs/Auth.js +616 -0
- package/dist/cjs/Auth.js.map +1 -1
- package/dist/cjs/index.js +3 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/Auth.js +449 -1
- package/dist/esm/Auth.js.map +1 -1
- package/dist/esm/index.js +1 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/types/Auth.d.ts +56 -0
- package/dist/types/Auth.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -5
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +2 -18
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/Auth.ts +763 -763
- package/src/index.ts +1 -6
- package/src/types.ts +4 -20
- package/dist/cjs/AuthBase.js +0 -97
- package/dist/cjs/AuthBase.js.map +0 -1
- package/dist/cjs/AuthCookieStorage.js +0 -217
- package/dist/cjs/AuthCookieStorage.js.map +0 -1
- package/dist/cjs/AuthForBackend.js +0 -28
- package/dist/cjs/AuthForBackend.js.map +0 -1
- package/dist/cjs/AuthForClient.js +0 -402
- package/dist/cjs/AuthForClient.js.map +0 -1
- package/dist/esm/AuthBase.js +0 -42
- package/dist/esm/AuthBase.js.map +0 -1
- package/dist/esm/AuthCookieStorage.js +0 -145
- package/dist/esm/AuthCookieStorage.js.map +0 -1
- package/dist/esm/AuthForBackend.js +0 -7
- package/dist/esm/AuthForBackend.js.map +0 -1
- package/dist/esm/AuthForClient.js +0 -257
- package/dist/esm/AuthForClient.js.map +0 -1
- package/dist/types/AuthBase.d.ts +0 -14
- package/dist/types/AuthBase.d.ts.map +0 -1
- package/dist/types/AuthCookieStorage.d.ts +0 -40
- package/dist/types/AuthCookieStorage.d.ts.map +0 -1
- package/dist/types/AuthForBackend.d.ts +0 -6
- package/dist/types/AuthForBackend.d.ts.map +0 -1
- package/dist/types/AuthForClient.d.ts +0 -30
- package/dist/types/AuthForClient.d.ts.map +0 -1
- package/src/AuthBase.ts +0 -44
- package/src/AuthCookieStorage.ts +0 -307
- package/src/AuthForBackend.ts +0 -8
- package/src/AuthForClient.ts +0 -426
package/src/index.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export { AuthBase } from './AuthBase';
|
|
3
|
-
export { AuthForBackend } from './AuthForBackend';
|
|
4
|
-
export { AuthForClient } from './AuthForClient';
|
|
5
|
-
export { AuthCookieStorage } from './AuthCookieStorage';
|
|
1
|
+
export { Auth } from './Auth';
|
|
6
2
|
export * from './types';
|
|
7
3
|
export * from './constants';
|
|
8
|
-
export * from './utils';
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type AuthConfig = {
|
|
2
2
|
/**
|
|
3
3
|
* Url of OneReach service discovery api
|
|
4
4
|
*/
|
|
@@ -8,11 +8,11 @@ export interface AuthBaseConfig {
|
|
|
8
8
|
* Url of OneReach SDK api
|
|
9
9
|
*/
|
|
10
10
|
sdkUrl?: string;
|
|
11
|
-
}
|
|
12
11
|
|
|
13
|
-
export interface AuthDataStorageConfig extends AuthBaseConfig {
|
|
14
12
|
cookieDomain?: string;
|
|
13
|
+
|
|
15
14
|
userCookieName?: string;
|
|
15
|
+
|
|
16
16
|
allowGuestLogin?: boolean;
|
|
17
17
|
userExpireCookieName?: string;
|
|
18
18
|
cookiePrefix?: string;
|
|
@@ -21,7 +21,7 @@ export interface AuthDataStorageConfig extends AuthBaseConfig {
|
|
|
21
21
|
expireInShort?: number;
|
|
22
22
|
expireInLong?: number;
|
|
23
23
|
allowIframe?: boolean;
|
|
24
|
-
}
|
|
24
|
+
};
|
|
25
25
|
|
|
26
26
|
export type Domain = {
|
|
27
27
|
domain?: string;
|
|
@@ -102,19 +102,3 @@ export type MultiUserUpdateTwoFactorArgs = {
|
|
|
102
102
|
codes: any;
|
|
103
103
|
verificationCode: string;
|
|
104
104
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
export interface AuthDataStorage {
|
|
108
|
-
updateExpiration(): void;
|
|
109
|
-
getExpire(...args: unknown[]): number;
|
|
110
|
-
monitor(...args: unknown[]): void;
|
|
111
|
-
stopMonitor(): void;
|
|
112
|
-
removeItem(...args: unknown[]): void;
|
|
113
|
-
multiUserData: User;
|
|
114
|
-
user: User | null;
|
|
115
|
-
setItem(user: User, expiration: number): void;
|
|
116
|
-
saveMultiUser(user: User, long: boolean): void;
|
|
117
|
-
saveMultiUser(user: User, expiration: number): void;
|
|
118
|
-
checkDeprecatedData(): void;
|
|
119
|
-
saveUser(args: SaveUserArgs): Promise<void> |void;
|
|
120
|
-
}
|
package/dist/cjs/AuthBase.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
-
};
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.AuthBase = void 0;
|
|
54
|
-
var lodash_1 = __importDefault(require("lodash"));
|
|
55
|
-
var utils_1 = require("./utils");
|
|
56
|
-
var sdk_api_1 = require("@or-sdk/sdk-api");
|
|
57
|
-
var AuthBase = (function () {
|
|
58
|
-
function AuthBase(params) {
|
|
59
|
-
var sdkUrl = params.sdkUrl, discoveryUrl = params.discoveryUrl;
|
|
60
|
-
this.sdkApi = new sdk_api_1.SdkApi({
|
|
61
|
-
token: '',
|
|
62
|
-
sdkUrl: sdkUrl,
|
|
63
|
-
discoveryUrl: discoveryUrl,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
AuthBase.prototype.validateGuest = function (role, allowGuestLoginOverride) {
|
|
67
|
-
if (allowGuestLoginOverride === void 0) { allowGuestLoginOverride = false; }
|
|
68
|
-
if (!allowGuestLoginOverride && lodash_1.default.toLower(role) === 'guest') {
|
|
69
|
-
throw new utils_1.NoRightsError('Authorization for guests is not allowed');
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
AuthBase.prototype.validateToken = function (token, allowGuestLogin) {
|
|
73
|
-
if (allowGuestLogin === void 0) { allowGuestLogin = false; }
|
|
74
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
-
var user;
|
|
76
|
-
return __generator(this, function (_a) {
|
|
77
|
-
switch (_a.label) {
|
|
78
|
-
case 0: return [4, this.sdkApi.makeRequest({
|
|
79
|
-
method: 'GET',
|
|
80
|
-
route: '/auth/token',
|
|
81
|
-
customHeaders: __assign({}, this.addTokenToHeaders(token)),
|
|
82
|
-
})];
|
|
83
|
-
case 1:
|
|
84
|
-
user = _a.sent();
|
|
85
|
-
this.validateGuest(user.role, allowGuestLogin);
|
|
86
|
-
return [2, user];
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
AuthBase.prototype.addTokenToHeaders = function (token) {
|
|
92
|
-
return { Authorization: token };
|
|
93
|
-
};
|
|
94
|
-
return AuthBase;
|
|
95
|
-
}());
|
|
96
|
-
exports.AuthBase = AuthBase;
|
|
97
|
-
//# sourceMappingURL=AuthBase.js.map
|
package/dist/cjs/AuthBase.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AuthBase.js","sourceRoot":"","sources":["../../src/AuthBase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kDAAuB;AACvB,iCAAwC;AACxC,2CAAyC;AAEzC;IAKE,kBAAsB,MAAsB;QAClC,IAAA,MAAM,GAAmB,MAAM,OAAzB,EAAE,YAAY,GAAK,MAAM,aAAX,CAAY;QACxC,IAAI,CAAC,MAAM,GAAG,IAAI,gBAAM,CAAC;YAEvB,KAAK,EAAE,EAAE;YACT,MAAM,QAAA;YACN,YAAY,cAAA;SACb,CAAC,CAAC;IACL,CAAC;IAED,gCAAa,GAAb,UAAc,IAAY,EAAE,uBAA+B;QAA/B,wCAAA,EAAA,+BAA+B;QACzD,IAAI,CAAC,uBAAuB,IAAI,gBAAC,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,EAAE;YAC3D,MAAM,IAAI,qBAAa,CAAC,yCAAyC,CAAC,CAAC;SACpE;IACH,CAAC;IAEK,gCAAa,GAAnB,UAAoB,KAAa,EAAE,eAAuB;QAAvB,gCAAA,EAAA,uBAAuB;;;;;4BAC3C,WAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAO;4BAC/C,MAAM,EAAE,KAAK;4BACb,KAAK,EAAE,aAAa;4BACpB,aAAa,eACR,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CACjC;yBACF,CAAC,EAAA;;wBANI,IAAI,GAAG,SAMX;wBAEF,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;wBAC/C,WAAO,IAAI,EAAC;;;;KACb;IAED,oCAAiB,GAAjB,UAAkB,KAAa;QAC7B,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;IAClC,CAAC;IAEH,eAAC;AAAD,CAAC,AAtCD,IAsCC;AAtCqB,4BAAQ"}
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
-
};
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.AuthCookieStorage = void 0;
|
|
54
|
-
var lodash_1 = __importDefault(require("lodash"));
|
|
55
|
-
var universal_cookie_1 = __importDefault(require("universal-cookie"));
|
|
56
|
-
var settings_1 = require("@or-sdk/settings");
|
|
57
|
-
var AuthCookieStorage = (function () {
|
|
58
|
-
function AuthCookieStorage(params) {
|
|
59
|
-
this.defaultCookiePollingInterval = 500;
|
|
60
|
-
this.defaultExpireInShort = 3600000;
|
|
61
|
-
this.defaultExpireInLong = 30758400000;
|
|
62
|
-
this.loggedIn = false;
|
|
63
|
-
var discoveryUrl = params.discoveryUrl, sdkUrl = params.sdkUrl, cookieDomain = params.cookieDomain, allowGuestLogin = params.allowGuestLogin, userCookieName = params.userCookieName, userExpireCookieName = params.userExpireCookieName, cookiePrefix = params.cookiePrefix, multiUserCookieName = params.multiUserCookieName, cookiePollingInterval = params.cookiePollingInterval, expireInShort = params.expireInShort, expireInLong = params.expireInLong, allowIframe = params.allowIframe;
|
|
64
|
-
this.discoveryUrl = discoveryUrl;
|
|
65
|
-
this.sdkUrl = sdkUrl;
|
|
66
|
-
this.cookie = new universal_cookie_1.default();
|
|
67
|
-
this.cookieDomain = cookieDomain;
|
|
68
|
-
this.allowGuestLogin = Boolean(allowGuestLogin);
|
|
69
|
-
this.allowIframe = allowIframe;
|
|
70
|
-
this.deprecatedCookieName = userCookieName || 'user';
|
|
71
|
-
this.deprecatedUserExpireCookieName = userExpireCookieName || 'user_expire';
|
|
72
|
-
this.deprecatedDomain = { domain: '.onereach.ai' };
|
|
73
|
-
this.userCookieName = cookiePrefix ? cookiePrefix : "".concat(userCookieName, "_new");
|
|
74
|
-
this.multiUserCookieName = multiUserCookieName;
|
|
75
|
-
this.userExpireCookieName = "".concat(this.userCookieName, "_expire");
|
|
76
|
-
this.cookiePollingInterval = cookiePollingInterval || this.defaultCookiePollingInterval;
|
|
77
|
-
this.expireInShort = expireInShort ? +expireInShort : this.defaultExpireInShort;
|
|
78
|
-
this.expireInLong = expireInLong ? +expireInLong : this.defaultExpireInLong;
|
|
79
|
-
}
|
|
80
|
-
Object.defineProperty(AuthCookieStorage.prototype, "domain", {
|
|
81
|
-
get: function () {
|
|
82
|
-
return this.cookieDomain ? { domain: this.cookieDomain } : {};
|
|
83
|
-
},
|
|
84
|
-
enumerable: false,
|
|
85
|
-
configurable: true
|
|
86
|
-
});
|
|
87
|
-
Object.defineProperty(AuthCookieStorage.prototype, "user", {
|
|
88
|
-
get: function () {
|
|
89
|
-
return this.cookie.get(this.userCookieName) || null;
|
|
90
|
-
},
|
|
91
|
-
enumerable: false,
|
|
92
|
-
configurable: true
|
|
93
|
-
});
|
|
94
|
-
AuthCookieStorage.prototype.getExpire = function (cookieName) {
|
|
95
|
-
var expireCookie = this.cookie.get(cookieName || this.userExpireCookieName);
|
|
96
|
-
return expireCookie ? parseInt(expireCookie, 10) : this.expireInShort;
|
|
97
|
-
};
|
|
98
|
-
AuthCookieStorage.prototype._getNextExpiration = function (expireIn) {
|
|
99
|
-
return new Date(Date.now() + expireIn);
|
|
100
|
-
};
|
|
101
|
-
Object.defineProperty(AuthCookieStorage.prototype, "multiUserData", {
|
|
102
|
-
get: function () {
|
|
103
|
-
return this.cookie.get(this.multiUserCookieName) || {};
|
|
104
|
-
},
|
|
105
|
-
enumerable: false,
|
|
106
|
-
configurable: true
|
|
107
|
-
});
|
|
108
|
-
AuthCookieStorage.prototype.monitor = function (logoutCallback, loginCallback) {
|
|
109
|
-
var _this = this;
|
|
110
|
-
this.stopMonitor();
|
|
111
|
-
this.monitorCookieTimeout = setTimeout(function () {
|
|
112
|
-
var user = _this.user;
|
|
113
|
-
if (user) {
|
|
114
|
-
if (!_this.loggedIn) {
|
|
115
|
-
_this.loggedIn = true;
|
|
116
|
-
}
|
|
117
|
-
if (lodash_1.default.isFunction(loginCallback)) {
|
|
118
|
-
loginCallback(user);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
else if (_this.loggedIn) {
|
|
122
|
-
_this.loggedIn = false;
|
|
123
|
-
if (lodash_1.default.isFunction(logoutCallback)) {
|
|
124
|
-
logoutCallback();
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
_this.monitor(logoutCallback, loginCallback);
|
|
128
|
-
}, this.cookiePollingInterval);
|
|
129
|
-
};
|
|
130
|
-
AuthCookieStorage.prototype.stopMonitor = function () {
|
|
131
|
-
if (window) {
|
|
132
|
-
clearTimeout(Number(this.monitorCookieTimeout));
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
AuthCookieStorage.prototype.setItem = function (user, expireIn) {
|
|
136
|
-
var nextExpiration = this._getNextExpiration(expireIn);
|
|
137
|
-
this.cookie.set(this.userCookieName, user, __assign({ path: '/', expires: nextExpiration, secure: true, sameSite: this.allowIframe ? 'none' : 'lax' }, this.domain));
|
|
138
|
-
this.cookie.set(this.userExpireCookieName, expireIn, __assign({ path: '/', expires: nextExpiration, secure: true, sameSite: this.allowIframe ? 'none' : 'lax' }, this.domain));
|
|
139
|
-
this.cookie.set(this.deprecatedCookieName, user, __assign({ path: '/', expires: nextExpiration }, this.domain));
|
|
140
|
-
this.cookie.set(this.deprecatedUserExpireCookieName, expireIn, __assign({ path: '/', expires: nextExpiration }, this.domain));
|
|
141
|
-
};
|
|
142
|
-
AuthCookieStorage.prototype.saveMultiUser = function (user, expirationOrLong) {
|
|
143
|
-
if (typeof expirationOrLong === 'boolean') {
|
|
144
|
-
expirationOrLong = expirationOrLong ? this.expireInLong : this.expireInShort;
|
|
145
|
-
}
|
|
146
|
-
this.cookie.set(this.multiUserCookieName, user, __assign({ path: '/', expires: this._getNextExpiration(expirationOrLong), secure: true }, this.domain));
|
|
147
|
-
};
|
|
148
|
-
AuthCookieStorage.prototype.updateExpiration = function () {
|
|
149
|
-
var user = this.user;
|
|
150
|
-
var expire = this.getExpire();
|
|
151
|
-
if (user) {
|
|
152
|
-
this.setItem(user, expire);
|
|
153
|
-
}
|
|
154
|
-
var multiUser = this.cookie.get(this.multiUserCookieName);
|
|
155
|
-
if (multiUser) {
|
|
156
|
-
this.saveMultiUser(multiUser, expire);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
AuthCookieStorage.prototype.saveUser = function (_a) {
|
|
160
|
-
var long = _a.long, user = _a.user;
|
|
161
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
162
|
-
var key, settingsApi, cookieExpirationDuration, error_1;
|
|
163
|
-
return __generator(this, function (_b) {
|
|
164
|
-
switch (_b.label) {
|
|
165
|
-
case 0:
|
|
166
|
-
key = long ? 'cookieExpirationLong' : 'cookieExpirationShort';
|
|
167
|
-
settingsApi = new settings_1.Settings({
|
|
168
|
-
token: user.token || '',
|
|
169
|
-
discoveryUrl: this.discoveryUrl,
|
|
170
|
-
sdkUrl: this.sdkUrl,
|
|
171
|
-
});
|
|
172
|
-
_b.label = 1;
|
|
173
|
-
case 1:
|
|
174
|
-
_b.trys.push([1, 3, , 4]);
|
|
175
|
-
return [4, settingsApi.getMergedSettings({ key: key })];
|
|
176
|
-
case 2:
|
|
177
|
-
cookieExpirationDuration = _b.sent();
|
|
178
|
-
return [3, 4];
|
|
179
|
-
case 3:
|
|
180
|
-
error_1 = _b.sent();
|
|
181
|
-
console.log('Unable to fetch settingCookiesExpire from user Settings: ', error_1);
|
|
182
|
-
return [3, 4];
|
|
183
|
-
case 4:
|
|
184
|
-
if (!cookieExpirationDuration) {
|
|
185
|
-
cookieExpirationDuration = long ? this.expireInLong : this.expireInShort;
|
|
186
|
-
}
|
|
187
|
-
this.setItem(user, cookieExpirationDuration);
|
|
188
|
-
return [2];
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
};
|
|
193
|
-
AuthCookieStorage.prototype.checkDeprecatedData = function () {
|
|
194
|
-
var user = this.cookie.get(this.deprecatedCookieName);
|
|
195
|
-
if (user) {
|
|
196
|
-
var deprecatedUserExpireValue = this.getExpire(this.deprecatedUserExpireCookieName);
|
|
197
|
-
var nextExpiration = this._getNextExpiration(deprecatedUserExpireValue);
|
|
198
|
-
this.cookie.set(this.userCookieName, user, __assign({ path: '/', expires: nextExpiration, secure: true }, this.domain));
|
|
199
|
-
this.cookie.set(this.userExpireCookieName, deprecatedUserExpireValue, __assign({ path: '/', expires: nextExpiration, secure: true }, this.domain));
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
AuthCookieStorage.prototype.removeItem = function () {
|
|
203
|
-
this.cookie.remove(this.userExpireCookieName, __assign({ path: '/' }, this.domain));
|
|
204
|
-
this.cookie.remove(this.userCookieName, __assign({ path: '/' }, this.domain));
|
|
205
|
-
this.cookie.remove(this.multiUserCookieName, __assign({ path: '/' }, this.domain));
|
|
206
|
-
this.cookie.remove(this.deprecatedCookieName, __assign({ path: '/' }, this.domain));
|
|
207
|
-
this.cookie.remove(this.deprecatedUserExpireCookieName, __assign({ path: '/' }, this.domain));
|
|
208
|
-
this.cookie.remove(this.deprecatedCookieName, __assign({ path: '/' }, this.domain));
|
|
209
|
-
this.cookie.remove(this.deprecatedUserExpireCookieName, __assign({ path: '/' }, this.domain));
|
|
210
|
-
};
|
|
211
|
-
AuthCookieStorage.prototype.hasUserParams = function () {
|
|
212
|
-
return Boolean(this.user);
|
|
213
|
-
};
|
|
214
|
-
return AuthCookieStorage;
|
|
215
|
-
}());
|
|
216
|
-
exports.AuthCookieStorage = AuthCookieStorage;
|
|
217
|
-
//# sourceMappingURL=AuthCookieStorage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AuthCookieStorage.js","sourceRoot":"","sources":["../../src/AuthCookieStorage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kDAAuB;AACvB,sEAAsC;AACtC,6CAA4C;AAE5C;IAyBE,2BAAY,MAA6B;QAxBxB,iCAA4B,GAAG,GAAG,CAAC;QACnC,yBAAoB,GAAG,OAAO,CAAC;QAC/B,wBAAmB,GAAG,WAAW,CAAC;QAe3C,aAAQ,GAAG,KAAK,CAAC;QASrB,IAAA,YAAY,GAYV,MAAM,aAZI,E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AO,EAAE,cAAc,EACvB,MAAM,EAAE,IAAI,IACT,IAAI,CAAC,MAAM,EACd,CAAC;SACJ;IACH,CAAC;IAQD,sCAAU,GAAV;QACE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,aAC1C,IAAI,EAAE,GAAG,IACN,IAAI,CAAC,MAAM,EACd,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,aACpC,IAAI,EAAE,GAAG,IACN,IAAI,CAAC,MAAM,EACd,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,mBAA6B,aACnD,IAAI,EAAE,GAAG,IACN,IAAI,CAAC,MAAM,EACd,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,aAC1C,IAAI,EAAE,GAAG,IACN,IAAI,CAAC,MAAM,EACd,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,aACpD,IAAI,EAAE,GAAG,IACN,IAAI,CAAC,MAAM,EACd,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,aAC1C,IAAI,EAAE,GAAG,IACN,IAAI,CAAC,MAAM,EACd,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,aACpD,IAAI,EAAE,GAAG,IACN,IAAI,CAAC,MAAM,EACd,CAAC;IACL,CAAC;IAQD,yCAAa,GAAb;QACE,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IACH,wBAAC;AAAD,CAAC,AA7SD,IA6SC;AA7SY,8CAAiB"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.AuthForBackend = void 0;
|
|
19
|
-
var AuthBase_1 = require("./AuthBase");
|
|
20
|
-
var AuthForBackend = (function (_super) {
|
|
21
|
-
__extends(AuthForBackend, _super);
|
|
22
|
-
function AuthForBackend(params) {
|
|
23
|
-
return _super.call(this, params) || this;
|
|
24
|
-
}
|
|
25
|
-
return AuthForBackend;
|
|
26
|
-
}(AuthBase_1.AuthBase));
|
|
27
|
-
exports.AuthForBackend = AuthForBackend;
|
|
28
|
-
//# sourceMappingURL=AuthForBackend.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AuthForBackend.js","sourceRoot":"","sources":["../../src/AuthForBackend.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,uCAAsC;AAGtC;IAAoC,kCAAQ;IAC1C,wBAAY,MAAsB;eAChC,kBAAM,MAAM,CAAC;IACf,CAAC;IACH,qBAAC;AAAD,CAAC,AAJD,CAAoC,mBAAQ,GAI3C;AAJY,wCAAc"}
|