@ms-atlas/datastudio 0.1.20
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.
Potentially problematic release.
This version of @ms-atlas/datastudio might be problematic. Click here for more details.
- package/ExternalLibraries/Monaco/vs/loader.js +2166 -0
- package/ExternalLibraries/URI.min.js +1901 -0
- package/ExternalLibraries/crossroads.min.js +453 -0
- package/ExternalLibraries/css.js +165 -0
- package/ExternalLibraries/d3.min.js +10857 -0
- package/ExternalLibraries/es6-promise.min.js +363 -0
- package/ExternalLibraries/hammer.js +2224 -0
- package/ExternalLibraries/hull.js +444 -0
- package/ExternalLibraries/i18n.min.js +115 -0
- package/ExternalLibraries/jquery-ui-timepicker-addon.min.css +76 -0
- package/ExternalLibraries/jquery-ui-timepicker-addon.min.js +1918 -0
- package/ExternalLibraries/jquery-ui.js +17201 -0
- package/ExternalLibraries/jquery-ui.min.css +1454 -0
- package/ExternalLibraries/jquery.history.js +2173 -0
- package/ExternalLibraries/jquery.min.js +5168 -0
- package/ExternalLibraries/jquery.mockjax.min.js +445 -0
- package/ExternalLibraries/jquery.modal.js +173 -0
- package/ExternalLibraries/jstree.js +10086 -0
- package/ExternalLibraries/jstree.style.css +1048 -0
- package/ExternalLibraries/jwt-decode.min.js +142 -0
- package/ExternalLibraries/knockout-latest.debug.js +7375 -0
- package/ExternalLibraries/knockout.mapping.min.js +534 -0
- package/ExternalLibraries/moment.js +3389 -0
- package/ExternalLibraries/q.js +1974 -0
- package/ExternalLibraries/require.js +2230 -0
- package/ExternalLibraries/signals.min.js +179 -0
- package/ExternalLibraries/text.js +445 -0
- package/ExternalLibraries/uuid.js +274 -0
- package/app-main.js +1 -0
- package/datastudio.application.mainpage.js +1502 -0
- package/datastudio.application.shared.js +626 -0
- package/datastudio.bootstrapper.js +517 -0
- package/fonts.css +14 -0
- package/nls/resx.js +1 -0
- package/nls/root/resx.js +22 -0
- package/package.json +22 -0
- package/scripts/application/sourceMapper.js +15 -0
- package/scripts/libs/adal/adal.js +720 -0
- package/stylesheets/main.css +8879 -0
|
@@ -0,0 +1,720 @@
|
|
|
1
|
+
var AuthenticationContext;
|
|
2
|
+
if ("undefined" != typeof module && module.exports) {
|
|
3
|
+
var window, localStorage, angular, document, sessionStorage;
|
|
4
|
+
module.exports.inject = function (t, e, i, s, n, o) {
|
|
5
|
+
return (
|
|
6
|
+
(window = t),
|
|
7
|
+
(localStorage = e),
|
|
8
|
+
(sessionStorage = e),
|
|
9
|
+
(document = i),
|
|
10
|
+
(Math = s),
|
|
11
|
+
(angular = n),
|
|
12
|
+
new AuthenticationContext(o)
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
(AuthenticationContext = function (t) {
|
|
17
|
+
if (
|
|
18
|
+
((this.REQUEST_TYPE = {
|
|
19
|
+
LOGIN: "LOGIN",
|
|
20
|
+
RENEW_TOKEN: "RENEW_TOKEN",
|
|
21
|
+
ID_TOKEN: "ID_TOKEN",
|
|
22
|
+
UNKNOWN: "UNKNOWN",
|
|
23
|
+
}),
|
|
24
|
+
(this.CONSTANTS = {
|
|
25
|
+
ACCESS_TOKEN: "access_token",
|
|
26
|
+
EXPIRES_IN: "expires_in",
|
|
27
|
+
ID_TOKEN: "id_token",
|
|
28
|
+
ERROR_DESCRIPTION: "error_description",
|
|
29
|
+
SESSION_STATE: "session_state",
|
|
30
|
+
STORAGE: {
|
|
31
|
+
TOKEN_KEYS: "adal.token.keys",
|
|
32
|
+
ACCESS_TOKEN_KEY: "adal.access.token.key",
|
|
33
|
+
EXPIRATION_KEY: "adal.expiration.key",
|
|
34
|
+
START_PAGE: "adal.start.page",
|
|
35
|
+
FAILED_RENEW: "adal.failed.renew",
|
|
36
|
+
STATE_LOGIN: "adal.state.login",
|
|
37
|
+
STATE_RENEW: "adal.state.renew",
|
|
38
|
+
STATE_RENEW_RESOURCE: "adal.state.renew.resource",
|
|
39
|
+
STATE_IDTOKEN: "adal.state.idtoken",
|
|
40
|
+
NONCE_IDTOKEN: "adal.nonce.idtoken",
|
|
41
|
+
SESSION_STATE: "adal.session.state",
|
|
42
|
+
USERNAME: "adal.username",
|
|
43
|
+
IDTOKEN: "adal.idtoken",
|
|
44
|
+
ERROR: "adal.error",
|
|
45
|
+
ERROR_DESCRIPTION: "adal.error.description",
|
|
46
|
+
LOGIN_REQUEST: "adal.login.request",
|
|
47
|
+
LOGIN_ERROR: "adal.login.error",
|
|
48
|
+
},
|
|
49
|
+
RESOURCE_DELIMETER: "|",
|
|
50
|
+
ERR_MESSAGES: { NO_TOKEN: "User is not authorized" },
|
|
51
|
+
}),
|
|
52
|
+
AuthenticationContext.prototype._singletonInstance)
|
|
53
|
+
)
|
|
54
|
+
return AuthenticationContext.prototype._singletonInstance;
|
|
55
|
+
if (
|
|
56
|
+
((AuthenticationContext.prototype._singletonInstance = this),
|
|
57
|
+
(this.instance = "https://login.microsoftonline.com/"),
|
|
58
|
+
(this.config = {}),
|
|
59
|
+
(this.callback = null),
|
|
60
|
+
(this.popUp = !1),
|
|
61
|
+
(this._user = null),
|
|
62
|
+
(this._renewActive = !1),
|
|
63
|
+
(this._loginInProgress = !1),
|
|
64
|
+
(this._renewStates = []),
|
|
65
|
+
t.displayCall && "function" != typeof t.displayCall)
|
|
66
|
+
)
|
|
67
|
+
throw new Error("displayCall is not a function");
|
|
68
|
+
if (!t.clientId) throw new Error("clientId is required");
|
|
69
|
+
(this.config = this._cloneConfig(t)),
|
|
70
|
+
this.config.loginResource ||
|
|
71
|
+
(this.config.loginResource = this.config.clientId),
|
|
72
|
+
this.config.redirectUri || (this.config.redirectUri = window.location.href),
|
|
73
|
+
(this.config.resource = this.config.loginResource || "");
|
|
74
|
+
}),
|
|
75
|
+
(AuthenticationContext.prototype.login = function () {
|
|
76
|
+
var t = this._guid();
|
|
77
|
+
(this.config.state = t),
|
|
78
|
+
(this._idTokenNonce = this._guid()),
|
|
79
|
+
this._logstatus("Expected state: " + t + " startPage:" + window.location),
|
|
80
|
+
this._saveItem(this.CONSTANTS.STORAGE.LOGIN_REQUEST, window.location),
|
|
81
|
+
this._saveItem(this.CONSTANTS.STORAGE.LOGIN_ERROR, ""),
|
|
82
|
+
this._saveItem(this.CONSTANTS.STORAGE.STATE_LOGIN, t),
|
|
83
|
+
this._saveItem(this.CONSTANTS.STORAGE.NONCE_IDTOKEN, this._idTokenNonce),
|
|
84
|
+
this._saveItem(this.CONSTANTS.STORAGE.FAILED_RENEW, ""),
|
|
85
|
+
this._saveItem(this.CONSTANTS.STORAGE.ERROR, ""),
|
|
86
|
+
this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION, "");
|
|
87
|
+
var e =
|
|
88
|
+
this._getNavigateUrl(
|
|
89
|
+
"code+id_token",
|
|
90
|
+
"https://management.core.windows.net"
|
|
91
|
+
) +
|
|
92
|
+
"&nonce=" +
|
|
93
|
+
encodeURIComponent(this._idTokenNonce);
|
|
94
|
+
(this.frameCallInProgress = !1),
|
|
95
|
+
(this._loginInProgress = !0),
|
|
96
|
+
this.config.displayCall ? this.config.displayCall(e) : this.promptUser(e);
|
|
97
|
+
}),
|
|
98
|
+
(AuthenticationContext.prototype.loginInProgress = function () {
|
|
99
|
+
return this._loginInProgress;
|
|
100
|
+
}),
|
|
101
|
+
(AuthenticationContext.prototype._hasResource = function (t) {
|
|
102
|
+
var e = this._getItem(this.CONSTANTS.STORAGE.TOKEN_KEYS);
|
|
103
|
+
return (
|
|
104
|
+
e &&
|
|
105
|
+
!this._isEmpty(e) &&
|
|
106
|
+
e.indexOf(t + this.CONSTANTS.RESOURCE_DELIMETER) > -1
|
|
107
|
+
);
|
|
108
|
+
}),
|
|
109
|
+
(AuthenticationContext.prototype.getCachedToken = function (t) {
|
|
110
|
+
if (!this._hasResource(t)) return null;
|
|
111
|
+
var e = this._getItem(this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY + t),
|
|
112
|
+
i = this._getItem(this.CONSTANTS.STORAGE.EXPIRATION_KEY + t),
|
|
113
|
+
s = this.config.expireOffsetSeconds || 120;
|
|
114
|
+
return i && i > this._now() + s
|
|
115
|
+
? e
|
|
116
|
+
: (this._saveItem(this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY + t, ""),
|
|
117
|
+
this._saveItem(this.CONSTANTS.STORAGE.EXPIRATION_KEY + t, 0),
|
|
118
|
+
null);
|
|
119
|
+
}),
|
|
120
|
+
(AuthenticationContext.prototype.getCachedUser = function () {
|
|
121
|
+
if (this._user) return this._user;
|
|
122
|
+
var t = this._getItem(this.CONSTANTS.STORAGE.IDTOKEN);
|
|
123
|
+
return (this._user = this._createUser(t)), this._user;
|
|
124
|
+
}),
|
|
125
|
+
(AuthenticationContext.prototype._renewToken = function (t, e) {
|
|
126
|
+
if (
|
|
127
|
+
(this._logstatus("renewToken is called for resource:" + t),
|
|
128
|
+
!this._hasResource(t))
|
|
129
|
+
) {
|
|
130
|
+
var i = this._getItem(this.CONSTANTS.STORAGE.TOKEN_KEYS) || "";
|
|
131
|
+
this._saveItem(
|
|
132
|
+
this.CONSTANTS.STORAGE.TOKEN_KEYS,
|
|
133
|
+
i + t + this.CONSTANTS.RESOURCE_DELIMETER
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
var s = this._addAdalFrame("adalRenewFrame"),
|
|
137
|
+
n = this._guid() + "|" + t;
|
|
138
|
+
(this._idTokenNonce = this._guid()),
|
|
139
|
+
(this.config.state = n),
|
|
140
|
+
this._renewStates.push(n),
|
|
141
|
+
this._saveItem(this.CONSTANTS.STORAGE.FAILED_RENEW, ""),
|
|
142
|
+
this._logstatus("Renew token Expected state: " + n);
|
|
143
|
+
var o =
|
|
144
|
+
this._getNavigateUrl("token", t) +
|
|
145
|
+
"&prompt=none&login_hint=" +
|
|
146
|
+
encodeURIComponent(this._user.userName);
|
|
147
|
+
(o += "&domain_hint=" + encodeURIComponent(this._getDomainHint())),
|
|
148
|
+
(o += "&nonce=" + encodeURIComponent(this._idTokenNonce)),
|
|
149
|
+
(this.callback = e),
|
|
150
|
+
(this.idTokenNonce = null),
|
|
151
|
+
this._logstatus("Navigate to:" + o),
|
|
152
|
+
this._saveItem(this.CONSTANTS.STORAGE.LOGIN_REQUEST, ""),
|
|
153
|
+
(s.src = "about:blank"),
|
|
154
|
+
this._loadFrame(o, "adalRenewFrame");
|
|
155
|
+
}),
|
|
156
|
+
(AuthenticationContext.prototype._renewIdToken = function (t) {
|
|
157
|
+
if (
|
|
158
|
+
(this._logstatus("renewIdToken is called"),
|
|
159
|
+
!this._hasResource(this.config.clientId))
|
|
160
|
+
) {
|
|
161
|
+
var e = this._getItem(this.CONSTANTS.STORAGE.TOKEN_KEYS) || "";
|
|
162
|
+
this._saveItem(
|
|
163
|
+
this.CONSTANTS.STORAGE.TOKEN_KEYS,
|
|
164
|
+
e + this.config.clientId + this.CONSTANTS.RESOURCE_DELIMETER
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
var i = this._addAdalFrame("adalIdTokenFrame"),
|
|
168
|
+
s = this._guid() + "|" + this.config.clientId;
|
|
169
|
+
(this._idTokenNonce = this._guid()),
|
|
170
|
+
this._saveItem(this.CONSTANTS.STORAGE.NONCE_IDTOKEN, this._idTokenNonce),
|
|
171
|
+
(this.config.state = s),
|
|
172
|
+
this._renewStates.push(s),
|
|
173
|
+
this._saveItem(this.CONSTANTS.STORAGE.STATE_RENEW, s),
|
|
174
|
+
this._saveItem(this.CONSTANTS.STORAGE.FAILED_RENEW, ""),
|
|
175
|
+
this._logstatus("Renew token Expected state: " + s);
|
|
176
|
+
var n =
|
|
177
|
+
this._getNavigateUrl("id_token", null) +
|
|
178
|
+
"&prompt=none&login_hint=" +
|
|
179
|
+
encodeURIComponent(this._user.userName);
|
|
180
|
+
(n += "&domain_hint=" + encodeURIComponent(this._getDomainHint())),
|
|
181
|
+
(n += "&nonce=" + encodeURIComponent(this._idTokenNonce)),
|
|
182
|
+
(this.callback = t),
|
|
183
|
+
(this.idTokenNonce = null),
|
|
184
|
+
this._logstatus("Navigate to:" + n),
|
|
185
|
+
this._saveItem(this.CONSTANTS.STORAGE.LOGIN_REQUEST, ""),
|
|
186
|
+
(i.src = "about:blank"),
|
|
187
|
+
this._loadFrame(n, "adalIdTokenFrame");
|
|
188
|
+
}),
|
|
189
|
+
(AuthenticationContext.prototype._loadFrame = function (t, e) {
|
|
190
|
+
var i = this;
|
|
191
|
+
i._logstatus("LoadFrame: " + e);
|
|
192
|
+
var s = e;
|
|
193
|
+
setTimeout(function () {
|
|
194
|
+
var e = i._addAdalFrame(s);
|
|
195
|
+
("" === e.src || "about:blank" === e.src) &&
|
|
196
|
+
((e.src = t), i._loadFrame(t, s));
|
|
197
|
+
}, 500);
|
|
198
|
+
}),
|
|
199
|
+
(AuthenticationContext.prototype.acquireToken = function (t, e) {
|
|
200
|
+
if (this._isEmpty(t)) return void e("resource is required", null);
|
|
201
|
+
var i = this.getCachedToken(t);
|
|
202
|
+
return i
|
|
203
|
+
? (this._logstatus("Token in cache"), void e(null, i))
|
|
204
|
+
: this._getItem(this.CONSTANTS.STORAGE.FAILED_RENEW)
|
|
205
|
+
? (this._logstatus(
|
|
206
|
+
"renewToken is failed:" +
|
|
207
|
+
this._getItem(this.CONSTANTS.STORAGE.FAILED_RENEW)
|
|
208
|
+
),
|
|
209
|
+
void e(this._getItem(this.CONSTANTS.STORAGE.FAILED_RENEW), null))
|
|
210
|
+
: this._user
|
|
211
|
+
? ((this._renewActive = !0),
|
|
212
|
+
void (t === this.config.clientId
|
|
213
|
+
? (this._logstatus("renewing idtoken"), this._renewIdToken(e))
|
|
214
|
+
: this._renewToken(t, e)))
|
|
215
|
+
: void e("User login is required", null);
|
|
216
|
+
}),
|
|
217
|
+
(AuthenticationContext.prototype.promptUser = function (t) {
|
|
218
|
+
t
|
|
219
|
+
? (this._logstatus("Navigate to:" + t), window.location.replace(t))
|
|
220
|
+
: this._logstatus("Navigate url is empty");
|
|
221
|
+
}),
|
|
222
|
+
(AuthenticationContext.prototype.clearCache = function () {
|
|
223
|
+
this._saveItem(this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY, ""),
|
|
224
|
+
this._saveItem(this.CONSTANTS.STORAGE.EXPIRATION_KEY, 0),
|
|
225
|
+
this._saveItem(this.CONSTANTS.STORAGE.FAILED_RENEW, ""),
|
|
226
|
+
this._saveItem(this.CONSTANTS.STORAGE.SESSION_STATE, ""),
|
|
227
|
+
this._saveItem(this.CONSTANTS.STORAGE.STATE_LOGIN, ""),
|
|
228
|
+
(this._renewStates = []),
|
|
229
|
+
this._saveItem(this.CONSTANTS.STORAGE.STATE_IDTOKEN, ""),
|
|
230
|
+
this._saveItem(this.CONSTANTS.STORAGE.START_PAGE, ""),
|
|
231
|
+
this._saveItem(this.CONSTANTS.STORAGE.USERNAME, ""),
|
|
232
|
+
this._saveItem(this.CONSTANTS.STORAGE.IDTOKEN, ""),
|
|
233
|
+
this._saveItem(this.CONSTANTS.STORAGE.ERROR, ""),
|
|
234
|
+
this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION, "");
|
|
235
|
+
var t = this._getItem(this.CONSTANTS.STORAGE.TOKEN_KEYS);
|
|
236
|
+
if (!this._isEmpty(t)) {
|
|
237
|
+
t = t.split(this.CONSTANTS.RESOURCE_DELIMETER);
|
|
238
|
+
for (var e = 0; e < t.length; e++)
|
|
239
|
+
this._saveItem(this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY + t[e], ""),
|
|
240
|
+
this._saveItem(this.CONSTANTS.STORAGE.EXPIRATION_KEY + t[e], 0);
|
|
241
|
+
}
|
|
242
|
+
this._saveItem(this.CONSTANTS.STORAGE.TOKEN_KEYS, "");
|
|
243
|
+
}),
|
|
244
|
+
(AuthenticationContext.prototype.clearCacheForResource = function (t) {
|
|
245
|
+
this._saveItem(this.CONSTANTS.STORAGE.FAILED_RENEW, ""),
|
|
246
|
+
this._saveItem(this.CONSTANTS.STORAGE.STATE_RENEW, ""),
|
|
247
|
+
this._saveItem(this.CONSTANTS.STORAGE.STATE_IDTOKEN, ""),
|
|
248
|
+
this._saveItem(this.CONSTANTS.STORAGE.ERROR, ""),
|
|
249
|
+
this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION, ""),
|
|
250
|
+
this._hasResource(t) &&
|
|
251
|
+
(this._saveItem(this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY + t, ""),
|
|
252
|
+
this._saveItem(this.CONSTANTS.STORAGE.EXPIRATION_KEY + t, 0));
|
|
253
|
+
}),
|
|
254
|
+
(AuthenticationContext.prototype.logOut = function () {
|
|
255
|
+
this.clearCache();
|
|
256
|
+
var t = "common",
|
|
257
|
+
e = "";
|
|
258
|
+
(this._user = null),
|
|
259
|
+
this.config.tenant && (t = this.config.tenant),
|
|
260
|
+
this.config.instance && (this.instance = this.config.instance),
|
|
261
|
+
this.config.postLogoutRedirectUri &&
|
|
262
|
+
(e =
|
|
263
|
+
"post_logout_redirect_uri=" +
|
|
264
|
+
encodeURIComponent(this.config.postLogoutRedirectUri));
|
|
265
|
+
var i = this.instance + t + "/oauth2/logout?" + e;
|
|
266
|
+
this._logstatus("Logout navigate to: " + i), this.promptUser(i);
|
|
267
|
+
}),
|
|
268
|
+
(AuthenticationContext.prototype._isEmpty = function (t) {
|
|
269
|
+
return "undefined" == typeof t || !t || 0 === t.length;
|
|
270
|
+
}),
|
|
271
|
+
(AuthenticationContext.prototype.getUser = function (t) {
|
|
272
|
+
if ("function" != typeof t) throw new Error("callback is not a function");
|
|
273
|
+
if (((this.callback = t), this._user))
|
|
274
|
+
return void this.callback(null, this._user);
|
|
275
|
+
var e = this._getItem(this.CONSTANTS.STORAGE.IDTOKEN);
|
|
276
|
+
this._isEmpty(e)
|
|
277
|
+
? this.callback("User information is not available")
|
|
278
|
+
: (this._logstatus("User exists in cache: "),
|
|
279
|
+
(this._user = this._createUser(e)),
|
|
280
|
+
this.callback(null, this._user));
|
|
281
|
+
}),
|
|
282
|
+
(AuthenticationContext.prototype._getDomainHint = function () {
|
|
283
|
+
if (
|
|
284
|
+
this._user &&
|
|
285
|
+
this._user.userName &&
|
|
286
|
+
this._user.userName.indexOf("@") > -1
|
|
287
|
+
) {
|
|
288
|
+
var t = this._user.userName.split("@");
|
|
289
|
+
return t[t.length - 1];
|
|
290
|
+
}
|
|
291
|
+
return "";
|
|
292
|
+
}),
|
|
293
|
+
(AuthenticationContext.prototype._createUser = function (t) {
|
|
294
|
+
var e = null,
|
|
295
|
+
i = this._extractIdToken(t);
|
|
296
|
+
return (
|
|
297
|
+
i &&
|
|
298
|
+
i.hasOwnProperty("aud") &&
|
|
299
|
+
(i.aud.toLowerCase() === this.config.clientId.toLowerCase()
|
|
300
|
+
? ((e = { userName: "", profile: i }),
|
|
301
|
+
i.hasOwnProperty("upn")
|
|
302
|
+
? (e.userName = i.upn)
|
|
303
|
+
: i.hasOwnProperty("email") && (e.userName = i.email))
|
|
304
|
+
: this._logstatus("IdToken has invalid aud field")),
|
|
305
|
+
e
|
|
306
|
+
);
|
|
307
|
+
}),
|
|
308
|
+
(AuthenticationContext.prototype._getHash = function (t) {
|
|
309
|
+
return (
|
|
310
|
+
t.indexOf("#/") > -1
|
|
311
|
+
? (t = t.substring(t.indexOf("#/") + 2))
|
|
312
|
+
: t.indexOf("#") > -1 && (t = t.substring(1)),
|
|
313
|
+
t
|
|
314
|
+
);
|
|
315
|
+
}),
|
|
316
|
+
(AuthenticationContext.prototype.isCallback = function (t) {
|
|
317
|
+
t = this._getHash(t);
|
|
318
|
+
var e = this._deserialize(t);
|
|
319
|
+
return (
|
|
320
|
+
e.hasOwnProperty(this.CONSTANTS.ERROR_DESCRIPTION) ||
|
|
321
|
+
e.hasOwnProperty(this.CONSTANTS.ACCESS_TOKEN) ||
|
|
322
|
+
e.hasOwnProperty(this.CONSTANTS.ID_TOKEN)
|
|
323
|
+
);
|
|
324
|
+
}),
|
|
325
|
+
(AuthenticationContext.prototype.getLoginError = function () {
|
|
326
|
+
return this._getItem(this.CONSTANTS.STORAGE.LOGIN_ERROR);
|
|
327
|
+
}),
|
|
328
|
+
(AuthenticationContext.prototype.getRequestInfo = function (t) {
|
|
329
|
+
t = this._getHash(t);
|
|
330
|
+
var e = this._deserialize(t),
|
|
331
|
+
i = {
|
|
332
|
+
valid: !1,
|
|
333
|
+
parameters: {},
|
|
334
|
+
stateMatch: !1,
|
|
335
|
+
stateResponse: "",
|
|
336
|
+
requestType: this.REQUEST_TYPE.UNKNOWN,
|
|
337
|
+
};
|
|
338
|
+
if (
|
|
339
|
+
e &&
|
|
340
|
+
((i.parameters = e),
|
|
341
|
+
e.hasOwnProperty(this.CONSTANTS.ERROR_DESCRIPTION) ||
|
|
342
|
+
e.hasOwnProperty(this.CONSTANTS.ACCESS_TOKEN) ||
|
|
343
|
+
e.hasOwnProperty(this.CONSTANTS.ID_TOKEN))
|
|
344
|
+
) {
|
|
345
|
+
i.valid = !0;
|
|
346
|
+
var s = "";
|
|
347
|
+
switch (
|
|
348
|
+
(e.hasOwnProperty("state")
|
|
349
|
+
? (this._logstatus("State: " + e.state), (s = e.state))
|
|
350
|
+
: this._logstatus("No state returned"),
|
|
351
|
+
(i.stateResponse = s),
|
|
352
|
+
s)
|
|
353
|
+
) {
|
|
354
|
+
case this._getItem(this.CONSTANTS.STORAGE.STATE_LOGIN):
|
|
355
|
+
(i.requestType = this.REQUEST_TYPE.LOGIN), (i.stateMatch = !0);
|
|
356
|
+
break;
|
|
357
|
+
case this._getItem(this.CONSTANTS.STORAGE.STATE_IDTOKEN):
|
|
358
|
+
(i.requestType = this.REQUEST_TYPE.ID_TOKEN),
|
|
359
|
+
this._saveItem(this.CONSTANTS.STORAGE.STATE_IDTOKEN, ""),
|
|
360
|
+
(i.stateMatch = !0);
|
|
361
|
+
}
|
|
362
|
+
if (
|
|
363
|
+
!i.stateMatch &&
|
|
364
|
+
window.parent &&
|
|
365
|
+
window.parent.AuthenticationContext()
|
|
366
|
+
)
|
|
367
|
+
for (
|
|
368
|
+
var n = window.parent.AuthenticationContext()._renewStates, o = 0;
|
|
369
|
+
o < n.length;
|
|
370
|
+
o++
|
|
371
|
+
)
|
|
372
|
+
if (n[o] === i.stateResponse) {
|
|
373
|
+
(i.requestType = this.REQUEST_TYPE.RENEW_TOKEN),
|
|
374
|
+
(i.stateMatch = !0);
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
return i;
|
|
379
|
+
}),
|
|
380
|
+
(AuthenticationContext.prototype._getResourceFromState = function (t) {
|
|
381
|
+
if (t) {
|
|
382
|
+
var e = t.indexOf("|");
|
|
383
|
+
if (e > -1 && e + 1 < t.length) return t.substring(e + 1);
|
|
384
|
+
}
|
|
385
|
+
return "";
|
|
386
|
+
}),
|
|
387
|
+
(AuthenticationContext.prototype.saveTokenFromHash = function (t) {
|
|
388
|
+
if (
|
|
389
|
+
(this._logstatus("State status:" + t.stateMatch),
|
|
390
|
+
this._saveItem(this.CONSTANTS.STORAGE.ERROR, ""),
|
|
391
|
+
this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION, ""),
|
|
392
|
+
t.parameters.hasOwnProperty(this.CONSTANTS.ERROR_DESCRIPTION))
|
|
393
|
+
)
|
|
394
|
+
this._logstatus("Error :" + t.parameters.error),
|
|
395
|
+
this._logstatus(
|
|
396
|
+
"Error description:" + t.parameters[this.CONSTANTS.ERROR_DESCRIPTION]
|
|
397
|
+
),
|
|
398
|
+
this._saveItem(
|
|
399
|
+
this.CONSTANTS.STORAGE.FAILED_RENEW,
|
|
400
|
+
t.parameters[this.CONSTANTS.ERROR_DESCRIPTION]
|
|
401
|
+
),
|
|
402
|
+
this._saveItem(this.CONSTANTS.STORAGE.ERROR, t.parameters.error),
|
|
403
|
+
this._saveItem(
|
|
404
|
+
this.CONSTANTS.STORAGE.ERROR_DESCRIPTION,
|
|
405
|
+
t.parameters[this.CONSTANTS.ERROR_DESCRIPTION]
|
|
406
|
+
),
|
|
407
|
+
t.requestType === this.REQUEST_TYPE.LOGIN
|
|
408
|
+
? ((this._loginInProgress = !1),
|
|
409
|
+
this._saveItem(
|
|
410
|
+
this.CONSTANTS.STORAGE.LOGIN_ERROR,
|
|
411
|
+
t.parameters.errorDescription
|
|
412
|
+
))
|
|
413
|
+
: (this._renewActive = !1);
|
|
414
|
+
else if (t.stateMatch) {
|
|
415
|
+
this._logstatus("State is right"),
|
|
416
|
+
t.parameters.hasOwnProperty(this.CONSTANTS.SESSION_STATE) &&
|
|
417
|
+
this._saveItem(
|
|
418
|
+
this.CONSTANTS.STORAGE.SESSION_STATE,
|
|
419
|
+
t.parameters[this.CONSTANTS.SESSION_STATE]
|
|
420
|
+
);
|
|
421
|
+
var e, i;
|
|
422
|
+
t.parameters.hasOwnProperty(this.CONSTANTS.ACCESS_TOKEN) &&
|
|
423
|
+
(this._logstatus("Fragment has access token"),
|
|
424
|
+
(this._renewActive = !1),
|
|
425
|
+
(i = this.config.loginResource),
|
|
426
|
+
this._hasResource(i) ||
|
|
427
|
+
((e = this._getItem(this.CONSTANTS.STORAGE.TOKEN_KEYS) || ""),
|
|
428
|
+
this._saveItem(
|
|
429
|
+
this.CONSTANTS.STORAGE.TOKEN_KEYS,
|
|
430
|
+
e + i + this.CONSTANTS.RESOURCE_DELIMETER
|
|
431
|
+
)),
|
|
432
|
+
t.requestType === this.REQUEST_TYPE.RENEW_TOKEN &&
|
|
433
|
+
(i = this._getResourceFromState(t.stateResponse)),
|
|
434
|
+
this._saveItem(
|
|
435
|
+
this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY + i,
|
|
436
|
+
t.parameters[this.CONSTANTS.ACCESS_TOKEN]
|
|
437
|
+
),
|
|
438
|
+
this._saveItem(
|
|
439
|
+
this.CONSTANTS.STORAGE.EXPIRATION_KEY + i,
|
|
440
|
+
this._expiresIn(t.parameters[this.CONSTANTS.EXPIRES_IN])
|
|
441
|
+
)),
|
|
442
|
+
t.parameters.hasOwnProperty(this.CONSTANTS.ID_TOKEN) &&
|
|
443
|
+
((this._loginInProgress = !1),
|
|
444
|
+
(this._user = this._createUser(
|
|
445
|
+
t.parameters[this.CONSTANTS.ID_TOKEN]
|
|
446
|
+
)),
|
|
447
|
+
this._user &&
|
|
448
|
+
this._user.profile &&
|
|
449
|
+
(this._user.profile.nonce !==
|
|
450
|
+
this._getItem(this.CONSTANTS.STORAGE.NONCE_IDTOKEN)
|
|
451
|
+
? ((this._user = null),
|
|
452
|
+
this._saveItem(
|
|
453
|
+
this.CONSTANTS.STORAGE.LOGIN_ERROR,
|
|
454
|
+
"Nonce is not same as " + this._idTokenNonce
|
|
455
|
+
))
|
|
456
|
+
: (this._saveItem(
|
|
457
|
+
this.CONSTANTS.STORAGE.IDTOKEN,
|
|
458
|
+
t.parameters[this.CONSTANTS.ID_TOKEN]
|
|
459
|
+
),
|
|
460
|
+
(i = this.config.clientId),
|
|
461
|
+
this._hasResource(i) ||
|
|
462
|
+
((e = this._getItem(this.CONSTANTS.STORAGE.TOKEN_KEYS) || ""),
|
|
463
|
+
this._saveItem(
|
|
464
|
+
this.CONSTANTS.STORAGE.TOKEN_KEYS,
|
|
465
|
+
e + i + this.CONSTANTS.RESOURCE_DELIMETER
|
|
466
|
+
)),
|
|
467
|
+
this._saveItem(
|
|
468
|
+
this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY + i,
|
|
469
|
+
t.parameters[this.CONSTANTS.ID_TOKEN]
|
|
470
|
+
),
|
|
471
|
+
this._saveItem(
|
|
472
|
+
this.CONSTANTS.STORAGE.EXPIRATION_KEY + i,
|
|
473
|
+
this._user.profile.exp
|
|
474
|
+
))));
|
|
475
|
+
} else
|
|
476
|
+
this._saveItem(this.CONSTANTS.STORAGE.ERROR, "Invalid_state"),
|
|
477
|
+
this._saveItem(
|
|
478
|
+
this.CONSTANTS.STORAGE.ERROR_DESCRIPTION,
|
|
479
|
+
"Invalid_state"
|
|
480
|
+
),
|
|
481
|
+
t.requestType === this.REQUEST_TYPE.LOGIN &&
|
|
482
|
+
this._saveItem(
|
|
483
|
+
this.CONSTANTS.STORAGE.LOGIN_ERROR,
|
|
484
|
+
"State is not same as " + t.stateResponse
|
|
485
|
+
);
|
|
486
|
+
}),
|
|
487
|
+
(AuthenticationContext.prototype.getResourceForEndpoint = function (t) {
|
|
488
|
+
if (this.config && this.config.endpoints)
|
|
489
|
+
for (var e in this.config.endpoints)
|
|
490
|
+
if (t.indexOf(e) > -1) return this.config.endpoints[e];
|
|
491
|
+
return this.config.loginResource;
|
|
492
|
+
}),
|
|
493
|
+
(AuthenticationContext.prototype.handleWindowCallback = function () {
|
|
494
|
+
var t = window.location.hash;
|
|
495
|
+
if (this.isCallback(t)) {
|
|
496
|
+
var e = this.getRequestInfo(t);
|
|
497
|
+
this.saveTokenFromHash(e);
|
|
498
|
+
var i = null;
|
|
499
|
+
if (
|
|
500
|
+
((e.requestType !== this.REQUEST_TYPE.RENEW_TOKEN &&
|
|
501
|
+
e.requestType !== this.REQUEST_TYPE.ID_TOKEN) ||
|
|
502
|
+
!window.parent
|
|
503
|
+
? window &&
|
|
504
|
+
window.oauth2Callback &&
|
|
505
|
+
(this._logstatus("Window is redirecting"), (i = this.callback))
|
|
506
|
+
: (this._logstatus("Window is in iframe"),
|
|
507
|
+
(i = window.parent.AuthenticationContext().callback),
|
|
508
|
+
(window.src = "")),
|
|
509
|
+
(window.location.hash = ""),
|
|
510
|
+
(window.location = this._getItem(this.CONSTANTS.STORAGE.LOGIN_REQUEST)),
|
|
511
|
+
e.requestType === this.REQUEST_TYPE.RENEW_TOKEN)
|
|
512
|
+
)
|
|
513
|
+
return void i(
|
|
514
|
+
this._getItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION),
|
|
515
|
+
e.parameters[this.CONSTANTS.ACCESS_TOKEN] ||
|
|
516
|
+
e.parameters[this.CONSTANTS.ID_TOKEN]
|
|
517
|
+
);
|
|
518
|
+
if (e.requestType === this.REQUEST_TYPE.ID_TOKEN)
|
|
519
|
+
return void i(
|
|
520
|
+
this._getItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION),
|
|
521
|
+
this._createUser(this._getItem(this.CONSTANTS.STORAGE.IDTOKEN))
|
|
522
|
+
);
|
|
523
|
+
}
|
|
524
|
+
}),
|
|
525
|
+
(AuthenticationContext.prototype._getNavigateUrl = function (t, e) {
|
|
526
|
+
var i = "common";
|
|
527
|
+
this.config.tenant && (i = this.config.tenant),
|
|
528
|
+
this.config.instance && (this.instance = this.config.instance);
|
|
529
|
+
var s =
|
|
530
|
+
this.instance +
|
|
531
|
+
i +
|
|
532
|
+
"/oauth2/authorize" +
|
|
533
|
+
this._serialize(t, this.config, e) +
|
|
534
|
+
this._addClientId();
|
|
535
|
+
return this._logstatus("Navigate url:" + s), s;
|
|
536
|
+
}),
|
|
537
|
+
(AuthenticationContext.prototype._extractIdToken = function (t) {
|
|
538
|
+
var e = this._decodeJwt(t);
|
|
539
|
+
if (!e) return null;
|
|
540
|
+
try {
|
|
541
|
+
var i = e.JWSPayload,
|
|
542
|
+
s = this._base64DecodeStringUrlSafe(i);
|
|
543
|
+
return s
|
|
544
|
+
? JSON.parse(s)
|
|
545
|
+
: (this._logstatus(
|
|
546
|
+
"The returned id_token could not be base64 url safe decoded."
|
|
547
|
+
),
|
|
548
|
+
null);
|
|
549
|
+
} catch (n) {
|
|
550
|
+
this._logstatus("The returned id_token could not be decoded: " + n.stack);
|
|
551
|
+
}
|
|
552
|
+
return null;
|
|
553
|
+
}),
|
|
554
|
+
(AuthenticationContext.prototype._extractUserName = function (t) {
|
|
555
|
+
try {
|
|
556
|
+
var e = this._extractIdToken(t);
|
|
557
|
+
if (e) {
|
|
558
|
+
if (e.hasOwnProperty("upn")) return e.upn;
|
|
559
|
+
if (e.hasOwnProperty("email")) return e.email;
|
|
560
|
+
}
|
|
561
|
+
} catch (i) {
|
|
562
|
+
this._logstatus("The returned id_token could not be decoded: " + i.stack);
|
|
563
|
+
}
|
|
564
|
+
return null;
|
|
565
|
+
}),
|
|
566
|
+
(AuthenticationContext.prototype._base64DecodeStringUrlSafe = function (t) {
|
|
567
|
+
return (
|
|
568
|
+
(t = t.replace(/-/g, "+").replace(/_/g, "/")),
|
|
569
|
+
window.atob
|
|
570
|
+
? decodeURIComponent(escape(window.atob(t)))
|
|
571
|
+
: (this._logstatus("Browser is not supported"), null)
|
|
572
|
+
);
|
|
573
|
+
}),
|
|
574
|
+
(AuthenticationContext.prototype._decodeJwt = function (t) {
|
|
575
|
+
var e = /^([^\.\s]*)\.([^\.\s]+)\.([^\.\s]*)$/,
|
|
576
|
+
i = e.exec(t);
|
|
577
|
+
if (!i || i.length < 4)
|
|
578
|
+
return this._logstatus("The returned id_token is not parseable."), null;
|
|
579
|
+
var s = { header: i[1], JWSPayload: i[2], JWSSig: i[3] };
|
|
580
|
+
return s;
|
|
581
|
+
}),
|
|
582
|
+
(AuthenticationContext.prototype._convertUrlSafeToRegularBase64EncodedString =
|
|
583
|
+
function (t) {
|
|
584
|
+
return t.replace("-", "+").replace("_", "/");
|
|
585
|
+
}),
|
|
586
|
+
(AuthenticationContext.prototype._serialize = function (t, e, i) {
|
|
587
|
+
var s = [];
|
|
588
|
+
return (
|
|
589
|
+
null !== e &&
|
|
590
|
+
(s.push("?response_type=" + t),
|
|
591
|
+
s.push("client_id=" + encodeURIComponent(e.clientId)),
|
|
592
|
+
i && s.push("resource=" + encodeURIComponent(i)),
|
|
593
|
+
s.push("redirect_uri=" + encodeURIComponent(e.redirectUri)),
|
|
594
|
+
s.push("state=" + encodeURIComponent(e.state)),
|
|
595
|
+
e.hasOwnProperty("slice") &&
|
|
596
|
+
s.push("slice=" + encodeURIComponent(e.slice)),
|
|
597
|
+
e.hasOwnProperty("extraQueryParameter") &&
|
|
598
|
+
s.push(e.extraQueryParameter)),
|
|
599
|
+
s.join("&")
|
|
600
|
+
);
|
|
601
|
+
}),
|
|
602
|
+
(AuthenticationContext.prototype._deserialize = function (t) {
|
|
603
|
+
var e,
|
|
604
|
+
i = /\+/g,
|
|
605
|
+
s = /([^&=]+)=?([^&]*)/g,
|
|
606
|
+
n = function (t) {
|
|
607
|
+
return decodeURIComponent(t.replace(i, " "));
|
|
608
|
+
},
|
|
609
|
+
o = {};
|
|
610
|
+
for (e = s.exec(t); e; ) (o[n(e[1])] = n(e[2])), (e = s.exec(t));
|
|
611
|
+
return o;
|
|
612
|
+
}),
|
|
613
|
+
(AuthenticationContext.prototype._guid = function () {
|
|
614
|
+
for (
|
|
615
|
+
var t = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
616
|
+
e = "0123456789abcdef",
|
|
617
|
+
i = 0,
|
|
618
|
+
s = "",
|
|
619
|
+
n = 0;
|
|
620
|
+
36 > n;
|
|
621
|
+
n++
|
|
622
|
+
)
|
|
623
|
+
"-" !== t[n] && "4" !== t[n] && (i = (16 * Math.random()) | 0),
|
|
624
|
+
"x" === t[n]
|
|
625
|
+
? (s += e[i])
|
|
626
|
+
: "y" === t[n]
|
|
627
|
+
? ((i &= 3), (i |= 8), (s += e[i]))
|
|
628
|
+
: (s += t[n]);
|
|
629
|
+
return s;
|
|
630
|
+
}),
|
|
631
|
+
(AuthenticationContext.prototype._expiresIn = function (t) {
|
|
632
|
+
return this._now() + parseInt(t, 10);
|
|
633
|
+
}),
|
|
634
|
+
(AuthenticationContext.prototype._now = function () {
|
|
635
|
+
return Math.round(new Date().getTime() / 1e3);
|
|
636
|
+
}),
|
|
637
|
+
(AuthenticationContext.prototype._addAdalFrame = function (t) {
|
|
638
|
+
if ("undefined" != typeof t) {
|
|
639
|
+
this._logstatus("Add adal frame to document:" + t);
|
|
640
|
+
var e = document.getElementById(t);
|
|
641
|
+
if (!e) {
|
|
642
|
+
if (
|
|
643
|
+
document.createElement &&
|
|
644
|
+
document.documentElement &&
|
|
645
|
+
(window.opera ||
|
|
646
|
+
-1 === window.navigator.userAgent.indexOf("MSIE 5.0"))
|
|
647
|
+
) {
|
|
648
|
+
var i = document.createElement("iframe");
|
|
649
|
+
i.setAttribute("id", t),
|
|
650
|
+
(i.style.visibility = "hidden"),
|
|
651
|
+
(i.style.position = "absolute"),
|
|
652
|
+
(i.style.width = i.style.height = i.borderWidth = "0px"),
|
|
653
|
+
(e = document.getElementsByTagName("body")[0].appendChild(i));
|
|
654
|
+
} else
|
|
655
|
+
document.body &&
|
|
656
|
+
document.body.insertAdjacentHTML &&
|
|
657
|
+
document.body.insertAdjacentHTML(
|
|
658
|
+
"beforeEnd",
|
|
659
|
+
'<iframe name="' +
|
|
660
|
+
t +
|
|
661
|
+
'" id="' +
|
|
662
|
+
t +
|
|
663
|
+
'" style="display:none"></iframe>'
|
|
664
|
+
);
|
|
665
|
+
window.frames && window.frames[t] && (e = window.frames[t]);
|
|
666
|
+
}
|
|
667
|
+
return e;
|
|
668
|
+
}
|
|
669
|
+
}),
|
|
670
|
+
(AuthenticationContext.prototype._logstatus = function (t) {
|
|
671
|
+
console && console.log(t);
|
|
672
|
+
}),
|
|
673
|
+
(AuthenticationContext.prototype._saveItem = function (t, e) {
|
|
674
|
+
return this.config &&
|
|
675
|
+
this.config.cacheLocation &&
|
|
676
|
+
"localStorage" === this.config.cacheLocation
|
|
677
|
+
? this._supportsLocalStorage()
|
|
678
|
+
? (localStorage.setItem(t, e), !0)
|
|
679
|
+
: (this._logStatus("Local storage is not supported"), !1)
|
|
680
|
+
: this._supportsSessionStorage()
|
|
681
|
+
? (sessionStorage.setItem(t, e), !0)
|
|
682
|
+
: (this._logstatus("Session storage is not supported"), !1);
|
|
683
|
+
}),
|
|
684
|
+
(AuthenticationContext.prototype._getItem = function (t) {
|
|
685
|
+
return this.config &&
|
|
686
|
+
this.config.cacheLocation &&
|
|
687
|
+
"localStorage" === this.config.cacheLocation
|
|
688
|
+
? this._supportsLocalStorage()
|
|
689
|
+
? localStorage.getItem(t)
|
|
690
|
+
: (this._logstatus("Local storage is not supported"), null)
|
|
691
|
+
: this._supportsSessionStorage()
|
|
692
|
+
? sessionStorage.getItem(t)
|
|
693
|
+
: (this._logstatus("Session storage is not supported"), null);
|
|
694
|
+
}),
|
|
695
|
+
(AuthenticationContext.prototype._supportsLocalStorage = function () {
|
|
696
|
+
try {
|
|
697
|
+
return "localStorage" in window && window.localStorage;
|
|
698
|
+
} catch (t) {
|
|
699
|
+
return !1;
|
|
700
|
+
}
|
|
701
|
+
}),
|
|
702
|
+
(AuthenticationContext.prototype._supportsSessionStorage = function () {
|
|
703
|
+
try {
|
|
704
|
+
return "sessionStorage" in window && window.sessionStorage;
|
|
705
|
+
} catch (t) {
|
|
706
|
+
return !1;
|
|
707
|
+
}
|
|
708
|
+
}),
|
|
709
|
+
(AuthenticationContext.prototype._cloneConfig = function (t) {
|
|
710
|
+
if (null === t || "object" != typeof t) return t;
|
|
711
|
+
var e = {};
|
|
712
|
+
for (var i in t) t.hasOwnProperty(i) && (e[i] = t[i]);
|
|
713
|
+
return e;
|
|
714
|
+
}),
|
|
715
|
+
(AuthenticationContext.prototype._libVersion = function () {
|
|
716
|
+
return "1.0.0";
|
|
717
|
+
}),
|
|
718
|
+
(AuthenticationContext.prototype._addClientId = function () {
|
|
719
|
+
return "&x-client-SKU=Js&x-client-Ver=" + this._libVersion();
|
|
720
|
+
});
|