@azure/msal-node 1.0.0-alpha.8 → 1.0.0-beta.2
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.json +269 -0
- package/LICENSE +21 -21
- package/README.md +153 -153
- package/changelog.md +170 -79
- package/dist/cache/Storage.d.ts +77 -5
- package/dist/cache/TokenCache.d.ts +15 -11
- package/dist/client/ClientApplication.d.ts +20 -7
- package/dist/client/ClientAssertion.d.ts +7 -1
- package/dist/client/ConfidentialClientApplication.d.ts +5 -3
- package/dist/client/PublicClientApplication.d.ts +15 -2
- package/dist/config/Configuration.d.ts +4 -2
- package/dist/crypto/CryptoProvider.d.ts +2 -0
- package/dist/index.d.ts +10 -2
- package/dist/msal-node.cjs.development.js +1871 -400
- package/dist/msal-node.cjs.development.js.map +1 -1
- package/dist/msal-node.cjs.production.min.js +1 -1
- package/dist/msal-node.cjs.production.min.js.map +1 -1
- package/dist/msal-node.esm.js +1819 -404
- package/dist/msal-node.esm.js.map +1 -1
- package/dist/request/AuthorizationCodeRequest.d.ts +17 -0
- package/dist/request/AuthorizationUrlRequest.d.ts +30 -0
- package/dist/request/ClientCredentialRequest.d.ts +11 -0
- package/dist/request/DeviceCodeRequest.d.ts +13 -0
- package/dist/request/OnBehalfOfRequest.d.ts +12 -0
- package/dist/request/RefreshTokenRequest.d.ts +13 -0
- package/dist/request/SilentFlowRequest.d.ts +14 -0
- package/dist/request/UsernamePasswordRequest.d.ts +17 -0
- package/dist/utils/Constants.d.ts +5 -3
- package/package.json +78 -79
- package/dist/cache/ICachePlugin.d.ts +0 -4
package/dist/msal-node.esm.js
CHANGED
|
@@ -1,11 +1,46 @@
|
|
|
1
|
-
import { LogLevel, StringUtils, AccountEntity, CacheManager, IdTokenEntity, AccessTokenEntity, RefreshTokenEntity, AppMetadataEntity,
|
|
2
|
-
export { AuthError, AuthErrorMessage, LogLevel, PromptValue, ResponseMode } from '@azure/msal-common';
|
|
1
|
+
import { Constants as Constants$1, ProtocolMode, LogLevel, StringUtils, AccountEntity, CacheManager, IdTokenEntity, AccessTokenEntity, RefreshTokenEntity, AppMetadataEntity, ServerTelemetryEntity, ThrottlingEntity, TokenCacheContext, ServerTelemetryManager, Logger, TrustedAuthority, AuthorityFactory, AuthorizationCodeClient, ResponseMode, AuthenticationScheme, RefreshTokenClient, SilentFlowClient, ClientAuthError, DeviceCodeClient, UsernamePasswordClient, TimeUtils, ClientCredentialClient, OnBehalfOfClient } from '@azure/msal-common';
|
|
2
|
+
export { AuthError, AuthErrorMessage, ClientAuthError, ClientAuthErrorMessage, ClientConfigurationError, ClientConfigurationErrorMessage, InteractionRequiredAuthError, LogLevel, Logger, PromptValue, ProtocolMode, ResponseMode, ServerError, TokenCacheContext } from '@azure/msal-common';
|
|
3
3
|
import axios from 'axios';
|
|
4
|
-
import debug from 'debug';
|
|
5
4
|
import { v4 } from 'uuid';
|
|
6
5
|
import crypto from 'crypto';
|
|
7
6
|
import { sign } from 'jsonwebtoken';
|
|
8
7
|
|
|
8
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
9
|
+
try {
|
|
10
|
+
var info = gen[key](arg);
|
|
11
|
+
var value = info.value;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
reject(error);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (info.done) {
|
|
18
|
+
resolve(value);
|
|
19
|
+
} else {
|
|
20
|
+
Promise.resolve(value).then(_next, _throw);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function _asyncToGenerator(fn) {
|
|
25
|
+
return function () {
|
|
26
|
+
var self = this,
|
|
27
|
+
args = arguments;
|
|
28
|
+
return new Promise(function (resolve, reject) {
|
|
29
|
+
var gen = fn.apply(self, args);
|
|
30
|
+
|
|
31
|
+
function _next(value) {
|
|
32
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function _throw(err) {
|
|
36
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
_next(undefined);
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
9
44
|
function _defineProperties(target, props) {
|
|
10
45
|
for (var i = 0; i < props.length; i++) {
|
|
11
46
|
var descriptor = props[i];
|
|
@@ -46,24 +81,759 @@ function _inheritsLoose(subClass, superClass) {
|
|
|
46
81
|
subClass.__proto__ = superClass;
|
|
47
82
|
}
|
|
48
83
|
|
|
49
|
-
|
|
84
|
+
function createCommonjsModule(fn, module) {
|
|
85
|
+
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
var runtime_1 = createCommonjsModule(function (module) {
|
|
89
|
+
/**
|
|
90
|
+
* Copyright (c) 2014-present, Facebook, Inc.
|
|
91
|
+
*
|
|
92
|
+
* This source code is licensed under the MIT license found in the
|
|
93
|
+
* LICENSE file in the root directory of this source tree.
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
var runtime = (function (exports) {
|
|
97
|
+
|
|
98
|
+
var Op = Object.prototype;
|
|
99
|
+
var hasOwn = Op.hasOwnProperty;
|
|
100
|
+
var undefined$1; // More compressible than void 0.
|
|
101
|
+
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
102
|
+
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
103
|
+
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
104
|
+
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
105
|
+
|
|
106
|
+
function define(obj, key, value) {
|
|
107
|
+
Object.defineProperty(obj, key, {
|
|
108
|
+
value: value,
|
|
109
|
+
enumerable: true,
|
|
110
|
+
configurable: true,
|
|
111
|
+
writable: true
|
|
112
|
+
});
|
|
113
|
+
return obj[key];
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
117
|
+
define({}, "");
|
|
118
|
+
} catch (err) {
|
|
119
|
+
define = function(obj, key, value) {
|
|
120
|
+
return obj[key] = value;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
125
|
+
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
126
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
127
|
+
var generator = Object.create(protoGenerator.prototype);
|
|
128
|
+
var context = new Context(tryLocsList || []);
|
|
129
|
+
|
|
130
|
+
// The ._invoke method unifies the implementations of the .next,
|
|
131
|
+
// .throw, and .return methods.
|
|
132
|
+
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
133
|
+
|
|
134
|
+
return generator;
|
|
135
|
+
}
|
|
136
|
+
exports.wrap = wrap;
|
|
137
|
+
|
|
138
|
+
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
139
|
+
// record like context.tryEntries[i].completion. This interface could
|
|
140
|
+
// have been (and was previously) designed to take a closure to be
|
|
141
|
+
// invoked without arguments, but in all the cases we care about we
|
|
142
|
+
// already have an existing method we want to call, so there's no need
|
|
143
|
+
// to create a new function object. We can even get away with assuming
|
|
144
|
+
// the method takes exactly one argument, since that happens to be true
|
|
145
|
+
// in every case, so we don't have to touch the arguments object. The
|
|
146
|
+
// only additional allocation required is the completion record, which
|
|
147
|
+
// has a stable shape and so hopefully should be cheap to allocate.
|
|
148
|
+
function tryCatch(fn, obj, arg) {
|
|
149
|
+
try {
|
|
150
|
+
return { type: "normal", arg: fn.call(obj, arg) };
|
|
151
|
+
} catch (err) {
|
|
152
|
+
return { type: "throw", arg: err };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
var GenStateSuspendedStart = "suspendedStart";
|
|
157
|
+
var GenStateSuspendedYield = "suspendedYield";
|
|
158
|
+
var GenStateExecuting = "executing";
|
|
159
|
+
var GenStateCompleted = "completed";
|
|
160
|
+
|
|
161
|
+
// Returning this object from the innerFn has the same effect as
|
|
162
|
+
// breaking out of the dispatch switch statement.
|
|
163
|
+
var ContinueSentinel = {};
|
|
164
|
+
|
|
165
|
+
// Dummy constructor functions that we use as the .constructor and
|
|
166
|
+
// .constructor.prototype properties for functions that return Generator
|
|
167
|
+
// objects. For full spec compliance, you may wish to configure your
|
|
168
|
+
// minifier not to mangle the names of these two functions.
|
|
169
|
+
function Generator() {}
|
|
170
|
+
function GeneratorFunction() {}
|
|
171
|
+
function GeneratorFunctionPrototype() {}
|
|
172
|
+
|
|
173
|
+
// This is a polyfill for %IteratorPrototype% for environments that
|
|
174
|
+
// don't natively support it.
|
|
175
|
+
var IteratorPrototype = {};
|
|
176
|
+
IteratorPrototype[iteratorSymbol] = function () {
|
|
177
|
+
return this;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
var getProto = Object.getPrototypeOf;
|
|
181
|
+
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
182
|
+
if (NativeIteratorPrototype &&
|
|
183
|
+
NativeIteratorPrototype !== Op &&
|
|
184
|
+
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
185
|
+
// This environment has a native %IteratorPrototype%; use it instead
|
|
186
|
+
// of the polyfill.
|
|
187
|
+
IteratorPrototype = NativeIteratorPrototype;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
var Gp = GeneratorFunctionPrototype.prototype =
|
|
191
|
+
Generator.prototype = Object.create(IteratorPrototype);
|
|
192
|
+
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
|
193
|
+
GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
|
194
|
+
GeneratorFunction.displayName = define(
|
|
195
|
+
GeneratorFunctionPrototype,
|
|
196
|
+
toStringTagSymbol,
|
|
197
|
+
"GeneratorFunction"
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
// Helper for defining the .next, .throw, and .return methods of the
|
|
201
|
+
// Iterator interface in terms of a single ._invoke method.
|
|
202
|
+
function defineIteratorMethods(prototype) {
|
|
203
|
+
["next", "throw", "return"].forEach(function(method) {
|
|
204
|
+
define(prototype, method, function(arg) {
|
|
205
|
+
return this._invoke(method, arg);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
exports.isGeneratorFunction = function(genFun) {
|
|
211
|
+
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
212
|
+
return ctor
|
|
213
|
+
? ctor === GeneratorFunction ||
|
|
214
|
+
// For the native GeneratorFunction constructor, the best we can
|
|
215
|
+
// do is to check its .name property.
|
|
216
|
+
(ctor.displayName || ctor.name) === "GeneratorFunction"
|
|
217
|
+
: false;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
exports.mark = function(genFun) {
|
|
221
|
+
if (Object.setPrototypeOf) {
|
|
222
|
+
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
223
|
+
} else {
|
|
224
|
+
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
225
|
+
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
226
|
+
}
|
|
227
|
+
genFun.prototype = Object.create(Gp);
|
|
228
|
+
return genFun;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// Within the body of any async function, `await x` is transformed to
|
|
232
|
+
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
233
|
+
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
234
|
+
// meant to be awaited.
|
|
235
|
+
exports.awrap = function(arg) {
|
|
236
|
+
return { __await: arg };
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
240
|
+
function invoke(method, arg, resolve, reject) {
|
|
241
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
242
|
+
if (record.type === "throw") {
|
|
243
|
+
reject(record.arg);
|
|
244
|
+
} else {
|
|
245
|
+
var result = record.arg;
|
|
246
|
+
var value = result.value;
|
|
247
|
+
if (value &&
|
|
248
|
+
typeof value === "object" &&
|
|
249
|
+
hasOwn.call(value, "__await")) {
|
|
250
|
+
return PromiseImpl.resolve(value.__await).then(function(value) {
|
|
251
|
+
invoke("next", value, resolve, reject);
|
|
252
|
+
}, function(err) {
|
|
253
|
+
invoke("throw", err, resolve, reject);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return PromiseImpl.resolve(value).then(function(unwrapped) {
|
|
258
|
+
// When a yielded Promise is resolved, its final value becomes
|
|
259
|
+
// the .value of the Promise<{value,done}> result for the
|
|
260
|
+
// current iteration.
|
|
261
|
+
result.value = unwrapped;
|
|
262
|
+
resolve(result);
|
|
263
|
+
}, function(error) {
|
|
264
|
+
// If a rejected Promise was yielded, throw the rejection back
|
|
265
|
+
// into the async generator function so it can be handled there.
|
|
266
|
+
return invoke("throw", error, resolve, reject);
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
var previousPromise;
|
|
272
|
+
|
|
273
|
+
function enqueue(method, arg) {
|
|
274
|
+
function callInvokeWithMethodAndArg() {
|
|
275
|
+
return new PromiseImpl(function(resolve, reject) {
|
|
276
|
+
invoke(method, arg, resolve, reject);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return previousPromise =
|
|
281
|
+
// If enqueue has been called before, then we want to wait until
|
|
282
|
+
// all previous Promises have been resolved before calling invoke,
|
|
283
|
+
// so that results are always delivered in the correct order. If
|
|
284
|
+
// enqueue has not been called before, then it is important to
|
|
285
|
+
// call invoke immediately, without waiting on a callback to fire,
|
|
286
|
+
// so that the async generator function has the opportunity to do
|
|
287
|
+
// any necessary setup in a predictable way. This predictability
|
|
288
|
+
// is why the Promise constructor synchronously invokes its
|
|
289
|
+
// executor callback, and why async functions synchronously
|
|
290
|
+
// execute code before the first await. Since we implement simple
|
|
291
|
+
// async functions in terms of async generators, it is especially
|
|
292
|
+
// important to get this right, even though it requires care.
|
|
293
|
+
previousPromise ? previousPromise.then(
|
|
294
|
+
callInvokeWithMethodAndArg,
|
|
295
|
+
// Avoid propagating failures to Promises returned by later
|
|
296
|
+
// invocations of the iterator.
|
|
297
|
+
callInvokeWithMethodAndArg
|
|
298
|
+
) : callInvokeWithMethodAndArg();
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// Define the unified helper method that is used to implement .next,
|
|
302
|
+
// .throw, and .return (see defineIteratorMethods).
|
|
303
|
+
this._invoke = enqueue;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
defineIteratorMethods(AsyncIterator.prototype);
|
|
307
|
+
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
|
308
|
+
return this;
|
|
309
|
+
};
|
|
310
|
+
exports.AsyncIterator = AsyncIterator;
|
|
311
|
+
|
|
312
|
+
// Note that simple async functions are implemented on top of
|
|
313
|
+
// AsyncIterator objects; they just return a Promise for the value of
|
|
314
|
+
// the final result produced by the iterator.
|
|
315
|
+
exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
316
|
+
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
317
|
+
|
|
318
|
+
var iter = new AsyncIterator(
|
|
319
|
+
wrap(innerFn, outerFn, self, tryLocsList),
|
|
320
|
+
PromiseImpl
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
return exports.isGeneratorFunction(outerFn)
|
|
324
|
+
? iter // If outerFn is a generator, return the full iterator.
|
|
325
|
+
: iter.next().then(function(result) {
|
|
326
|
+
return result.done ? result.value : iter.next();
|
|
327
|
+
});
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
function makeInvokeMethod(innerFn, self, context) {
|
|
331
|
+
var state = GenStateSuspendedStart;
|
|
332
|
+
|
|
333
|
+
return function invoke(method, arg) {
|
|
334
|
+
if (state === GenStateExecuting) {
|
|
335
|
+
throw new Error("Generator is already running");
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (state === GenStateCompleted) {
|
|
339
|
+
if (method === "throw") {
|
|
340
|
+
throw arg;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
344
|
+
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
345
|
+
return doneResult();
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
context.method = method;
|
|
349
|
+
context.arg = arg;
|
|
350
|
+
|
|
351
|
+
while (true) {
|
|
352
|
+
var delegate = context.delegate;
|
|
353
|
+
if (delegate) {
|
|
354
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
355
|
+
if (delegateResult) {
|
|
356
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
357
|
+
return delegateResult;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (context.method === "next") {
|
|
362
|
+
// Setting context._sent for legacy support of Babel's
|
|
363
|
+
// function.sent implementation.
|
|
364
|
+
context.sent = context._sent = context.arg;
|
|
365
|
+
|
|
366
|
+
} else if (context.method === "throw") {
|
|
367
|
+
if (state === GenStateSuspendedStart) {
|
|
368
|
+
state = GenStateCompleted;
|
|
369
|
+
throw context.arg;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
context.dispatchException(context.arg);
|
|
373
|
+
|
|
374
|
+
} else if (context.method === "return") {
|
|
375
|
+
context.abrupt("return", context.arg);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
state = GenStateExecuting;
|
|
379
|
+
|
|
380
|
+
var record = tryCatch(innerFn, self, context);
|
|
381
|
+
if (record.type === "normal") {
|
|
382
|
+
// If an exception is thrown from innerFn, we leave state ===
|
|
383
|
+
// GenStateExecuting and loop back for another invocation.
|
|
384
|
+
state = context.done
|
|
385
|
+
? GenStateCompleted
|
|
386
|
+
: GenStateSuspendedYield;
|
|
387
|
+
|
|
388
|
+
if (record.arg === ContinueSentinel) {
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
return {
|
|
393
|
+
value: record.arg,
|
|
394
|
+
done: context.done
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
} else if (record.type === "throw") {
|
|
398
|
+
state = GenStateCompleted;
|
|
399
|
+
// Dispatch the exception by looping back around to the
|
|
400
|
+
// context.dispatchException(context.arg) call above.
|
|
401
|
+
context.method = "throw";
|
|
402
|
+
context.arg = record.arg;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
409
|
+
// result, either by returning a { value, done } result from the
|
|
410
|
+
// delegate iterator, or by modifying context.method and context.arg,
|
|
411
|
+
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
412
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
413
|
+
var method = delegate.iterator[context.method];
|
|
414
|
+
if (method === undefined$1) {
|
|
415
|
+
// A .throw or .return when the delegate iterator has no .throw
|
|
416
|
+
// method always terminates the yield* loop.
|
|
417
|
+
context.delegate = null;
|
|
418
|
+
|
|
419
|
+
if (context.method === "throw") {
|
|
420
|
+
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
421
|
+
if (delegate.iterator["return"]) {
|
|
422
|
+
// If the delegate iterator has a return method, give it a
|
|
423
|
+
// chance to clean up.
|
|
424
|
+
context.method = "return";
|
|
425
|
+
context.arg = undefined$1;
|
|
426
|
+
maybeInvokeDelegate(delegate, context);
|
|
427
|
+
|
|
428
|
+
if (context.method === "throw") {
|
|
429
|
+
// If maybeInvokeDelegate(context) changed context.method from
|
|
430
|
+
// "return" to "throw", let that override the TypeError below.
|
|
431
|
+
return ContinueSentinel;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
context.method = "throw";
|
|
436
|
+
context.arg = new TypeError(
|
|
437
|
+
"The iterator does not provide a 'throw' method");
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
return ContinueSentinel;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
444
|
+
|
|
445
|
+
if (record.type === "throw") {
|
|
446
|
+
context.method = "throw";
|
|
447
|
+
context.arg = record.arg;
|
|
448
|
+
context.delegate = null;
|
|
449
|
+
return ContinueSentinel;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
var info = record.arg;
|
|
453
|
+
|
|
454
|
+
if (! info) {
|
|
455
|
+
context.method = "throw";
|
|
456
|
+
context.arg = new TypeError("iterator result is not an object");
|
|
457
|
+
context.delegate = null;
|
|
458
|
+
return ContinueSentinel;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
if (info.done) {
|
|
462
|
+
// Assign the result of the finished delegate to the temporary
|
|
463
|
+
// variable specified by delegate.resultName (see delegateYield).
|
|
464
|
+
context[delegate.resultName] = info.value;
|
|
465
|
+
|
|
466
|
+
// Resume execution at the desired location (see delegateYield).
|
|
467
|
+
context.next = delegate.nextLoc;
|
|
468
|
+
|
|
469
|
+
// If context.method was "throw" but the delegate handled the
|
|
470
|
+
// exception, let the outer generator proceed normally. If
|
|
471
|
+
// context.method was "next", forget context.arg since it has been
|
|
472
|
+
// "consumed" by the delegate iterator. If context.method was
|
|
473
|
+
// "return", allow the original .return call to continue in the
|
|
474
|
+
// outer generator.
|
|
475
|
+
if (context.method !== "return") {
|
|
476
|
+
context.method = "next";
|
|
477
|
+
context.arg = undefined$1;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
} else {
|
|
481
|
+
// Re-yield the result returned by the delegate method.
|
|
482
|
+
return info;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// The delegate iterator is finished, so forget it and continue with
|
|
486
|
+
// the outer generator.
|
|
487
|
+
context.delegate = null;
|
|
488
|
+
return ContinueSentinel;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
492
|
+
// unified ._invoke helper method.
|
|
493
|
+
defineIteratorMethods(Gp);
|
|
494
|
+
|
|
495
|
+
define(Gp, toStringTagSymbol, "Generator");
|
|
496
|
+
|
|
497
|
+
// A Generator should always return itself as the iterator object when the
|
|
498
|
+
// @@iterator function is called on it. Some browsers' implementations of the
|
|
499
|
+
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
500
|
+
// object to not be returned from this call. This ensures that doesn't happen.
|
|
501
|
+
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
502
|
+
Gp[iteratorSymbol] = function() {
|
|
503
|
+
return this;
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
Gp.toString = function() {
|
|
507
|
+
return "[object Generator]";
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
function pushTryEntry(locs) {
|
|
511
|
+
var entry = { tryLoc: locs[0] };
|
|
512
|
+
|
|
513
|
+
if (1 in locs) {
|
|
514
|
+
entry.catchLoc = locs[1];
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if (2 in locs) {
|
|
518
|
+
entry.finallyLoc = locs[2];
|
|
519
|
+
entry.afterLoc = locs[3];
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
this.tryEntries.push(entry);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
function resetTryEntry(entry) {
|
|
526
|
+
var record = entry.completion || {};
|
|
527
|
+
record.type = "normal";
|
|
528
|
+
delete record.arg;
|
|
529
|
+
entry.completion = record;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
function Context(tryLocsList) {
|
|
533
|
+
// The root entry object (effectively a try statement without a catch
|
|
534
|
+
// or a finally block) gives us a place to store values thrown from
|
|
535
|
+
// locations where there is no enclosing try statement.
|
|
536
|
+
this.tryEntries = [{ tryLoc: "root" }];
|
|
537
|
+
tryLocsList.forEach(pushTryEntry, this);
|
|
538
|
+
this.reset(true);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
exports.keys = function(object) {
|
|
542
|
+
var keys = [];
|
|
543
|
+
for (var key in object) {
|
|
544
|
+
keys.push(key);
|
|
545
|
+
}
|
|
546
|
+
keys.reverse();
|
|
547
|
+
|
|
548
|
+
// Rather than returning an object with a next method, we keep
|
|
549
|
+
// things simple and return the next function itself.
|
|
550
|
+
return function next() {
|
|
551
|
+
while (keys.length) {
|
|
552
|
+
var key = keys.pop();
|
|
553
|
+
if (key in object) {
|
|
554
|
+
next.value = key;
|
|
555
|
+
next.done = false;
|
|
556
|
+
return next;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// To avoid creating an additional object, we just hang the .value
|
|
561
|
+
// and .done properties off the next function object itself. This
|
|
562
|
+
// also ensures that the minifier will not anonymize the function.
|
|
563
|
+
next.done = true;
|
|
564
|
+
return next;
|
|
565
|
+
};
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
function values(iterable) {
|
|
569
|
+
if (iterable) {
|
|
570
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
571
|
+
if (iteratorMethod) {
|
|
572
|
+
return iteratorMethod.call(iterable);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
if (typeof iterable.next === "function") {
|
|
576
|
+
return iterable;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
if (!isNaN(iterable.length)) {
|
|
580
|
+
var i = -1, next = function next() {
|
|
581
|
+
while (++i < iterable.length) {
|
|
582
|
+
if (hasOwn.call(iterable, i)) {
|
|
583
|
+
next.value = iterable[i];
|
|
584
|
+
next.done = false;
|
|
585
|
+
return next;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
next.value = undefined$1;
|
|
590
|
+
next.done = true;
|
|
591
|
+
|
|
592
|
+
return next;
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
return next.next = next;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// Return an iterator with no values.
|
|
600
|
+
return { next: doneResult };
|
|
601
|
+
}
|
|
602
|
+
exports.values = values;
|
|
603
|
+
|
|
604
|
+
function doneResult() {
|
|
605
|
+
return { value: undefined$1, done: true };
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
Context.prototype = {
|
|
609
|
+
constructor: Context,
|
|
610
|
+
|
|
611
|
+
reset: function(skipTempReset) {
|
|
612
|
+
this.prev = 0;
|
|
613
|
+
this.next = 0;
|
|
614
|
+
// Resetting context._sent for legacy support of Babel's
|
|
615
|
+
// function.sent implementation.
|
|
616
|
+
this.sent = this._sent = undefined$1;
|
|
617
|
+
this.done = false;
|
|
618
|
+
this.delegate = null;
|
|
619
|
+
|
|
620
|
+
this.method = "next";
|
|
621
|
+
this.arg = undefined$1;
|
|
622
|
+
|
|
623
|
+
this.tryEntries.forEach(resetTryEntry);
|
|
624
|
+
|
|
625
|
+
if (!skipTempReset) {
|
|
626
|
+
for (var name in this) {
|
|
627
|
+
// Not sure about the optimal order of these conditions:
|
|
628
|
+
if (name.charAt(0) === "t" &&
|
|
629
|
+
hasOwn.call(this, name) &&
|
|
630
|
+
!isNaN(+name.slice(1))) {
|
|
631
|
+
this[name] = undefined$1;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
},
|
|
636
|
+
|
|
637
|
+
stop: function() {
|
|
638
|
+
this.done = true;
|
|
639
|
+
|
|
640
|
+
var rootEntry = this.tryEntries[0];
|
|
641
|
+
var rootRecord = rootEntry.completion;
|
|
642
|
+
if (rootRecord.type === "throw") {
|
|
643
|
+
throw rootRecord.arg;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
return this.rval;
|
|
647
|
+
},
|
|
648
|
+
|
|
649
|
+
dispatchException: function(exception) {
|
|
650
|
+
if (this.done) {
|
|
651
|
+
throw exception;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
var context = this;
|
|
655
|
+
function handle(loc, caught) {
|
|
656
|
+
record.type = "throw";
|
|
657
|
+
record.arg = exception;
|
|
658
|
+
context.next = loc;
|
|
659
|
+
|
|
660
|
+
if (caught) {
|
|
661
|
+
// If the dispatched exception was caught by a catch block,
|
|
662
|
+
// then let that catch block handle the exception normally.
|
|
663
|
+
context.method = "next";
|
|
664
|
+
context.arg = undefined$1;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
return !! caught;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
671
|
+
var entry = this.tryEntries[i];
|
|
672
|
+
var record = entry.completion;
|
|
673
|
+
|
|
674
|
+
if (entry.tryLoc === "root") {
|
|
675
|
+
// Exception thrown outside of any try block that could handle
|
|
676
|
+
// it, so set the completion value of the entire function to
|
|
677
|
+
// throw the exception.
|
|
678
|
+
return handle("end");
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
if (entry.tryLoc <= this.prev) {
|
|
682
|
+
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
683
|
+
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
684
|
+
|
|
685
|
+
if (hasCatch && hasFinally) {
|
|
686
|
+
if (this.prev < entry.catchLoc) {
|
|
687
|
+
return handle(entry.catchLoc, true);
|
|
688
|
+
} else if (this.prev < entry.finallyLoc) {
|
|
689
|
+
return handle(entry.finallyLoc);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
} else if (hasCatch) {
|
|
693
|
+
if (this.prev < entry.catchLoc) {
|
|
694
|
+
return handle(entry.catchLoc, true);
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
} else if (hasFinally) {
|
|
698
|
+
if (this.prev < entry.finallyLoc) {
|
|
699
|
+
return handle(entry.finallyLoc);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
} else {
|
|
703
|
+
throw new Error("try statement without catch or finally");
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
},
|
|
708
|
+
|
|
709
|
+
abrupt: function(type, arg) {
|
|
710
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
711
|
+
var entry = this.tryEntries[i];
|
|
712
|
+
if (entry.tryLoc <= this.prev &&
|
|
713
|
+
hasOwn.call(entry, "finallyLoc") &&
|
|
714
|
+
this.prev < entry.finallyLoc) {
|
|
715
|
+
var finallyEntry = entry;
|
|
716
|
+
break;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
if (finallyEntry &&
|
|
721
|
+
(type === "break" ||
|
|
722
|
+
type === "continue") &&
|
|
723
|
+
finallyEntry.tryLoc <= arg &&
|
|
724
|
+
arg <= finallyEntry.finallyLoc) {
|
|
725
|
+
// Ignore the finally entry if control is not jumping to a
|
|
726
|
+
// location outside the try/catch block.
|
|
727
|
+
finallyEntry = null;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
731
|
+
record.type = type;
|
|
732
|
+
record.arg = arg;
|
|
733
|
+
|
|
734
|
+
if (finallyEntry) {
|
|
735
|
+
this.method = "next";
|
|
736
|
+
this.next = finallyEntry.finallyLoc;
|
|
737
|
+
return ContinueSentinel;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
return this.complete(record);
|
|
741
|
+
},
|
|
742
|
+
|
|
743
|
+
complete: function(record, afterLoc) {
|
|
744
|
+
if (record.type === "throw") {
|
|
745
|
+
throw record.arg;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
if (record.type === "break" ||
|
|
749
|
+
record.type === "continue") {
|
|
750
|
+
this.next = record.arg;
|
|
751
|
+
} else if (record.type === "return") {
|
|
752
|
+
this.rval = this.arg = record.arg;
|
|
753
|
+
this.method = "return";
|
|
754
|
+
this.next = "end";
|
|
755
|
+
} else if (record.type === "normal" && afterLoc) {
|
|
756
|
+
this.next = afterLoc;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
return ContinueSentinel;
|
|
760
|
+
},
|
|
761
|
+
|
|
762
|
+
finish: function(finallyLoc) {
|
|
763
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
764
|
+
var entry = this.tryEntries[i];
|
|
765
|
+
if (entry.finallyLoc === finallyLoc) {
|
|
766
|
+
this.complete(entry.completion, entry.afterLoc);
|
|
767
|
+
resetTryEntry(entry);
|
|
768
|
+
return ContinueSentinel;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
},
|
|
772
|
+
|
|
773
|
+
"catch": function(tryLoc) {
|
|
774
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
775
|
+
var entry = this.tryEntries[i];
|
|
776
|
+
if (entry.tryLoc === tryLoc) {
|
|
777
|
+
var record = entry.completion;
|
|
778
|
+
if (record.type === "throw") {
|
|
779
|
+
var thrown = record.arg;
|
|
780
|
+
resetTryEntry(entry);
|
|
781
|
+
}
|
|
782
|
+
return thrown;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
// The context.catch method must only be called with a location
|
|
787
|
+
// argument that corresponds to a known catch block.
|
|
788
|
+
throw new Error("illegal catch attempt");
|
|
789
|
+
},
|
|
790
|
+
|
|
791
|
+
delegateYield: function(iterable, resultName, nextLoc) {
|
|
792
|
+
this.delegate = {
|
|
793
|
+
iterator: values(iterable),
|
|
794
|
+
resultName: resultName,
|
|
795
|
+
nextLoc: nextLoc
|
|
796
|
+
};
|
|
50
797
|
|
|
51
|
-
|
|
798
|
+
if (this.method === "next") {
|
|
799
|
+
// Deliberately forget the last sent value so that we don't
|
|
800
|
+
// accidentally pass it on to the delegate.
|
|
801
|
+
this.arg = undefined$1;
|
|
802
|
+
}
|
|
52
803
|
|
|
53
|
-
|
|
804
|
+
return ContinueSentinel;
|
|
805
|
+
}
|
|
806
|
+
};
|
|
54
807
|
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
808
|
+
// Regardless of whether this script is executing as a CommonJS module
|
|
809
|
+
// or not, return the runtime object so that we can declare the variable
|
|
810
|
+
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
811
|
+
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
812
|
+
return exports;
|
|
813
|
+
|
|
814
|
+
}(
|
|
815
|
+
// If this script is executing as a CommonJS module, use module.exports
|
|
816
|
+
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
817
|
+
// object. Either way, the resulting object will be used to initialize
|
|
818
|
+
// the regeneratorRuntime variable at the top of this file.
|
|
819
|
+
module.exports
|
|
820
|
+
));
|
|
821
|
+
|
|
822
|
+
try {
|
|
823
|
+
regeneratorRuntime = runtime;
|
|
824
|
+
} catch (accidentalStrictMode) {
|
|
825
|
+
// This module should not be running in strict mode, so the above
|
|
826
|
+
// assignment should always work unless something is misconfigured. Just
|
|
827
|
+
// in case runtime.js accidentally runs in strict mode, we can escape
|
|
828
|
+
// strict mode using a global Function call. This could conceivably fail
|
|
829
|
+
// if a Content Security Policy forbids using Function, but in that case
|
|
830
|
+
// the proper solution is to fix the accidental strict mode problem. If
|
|
831
|
+
// you've misconfigured your bundler to force strict mode and applied a
|
|
832
|
+
// CSP to forbid Function, and you're not willing to fix either of those
|
|
833
|
+
// problems, please detail your unique predicament in a GitHub issue.
|
|
834
|
+
Function("r", "regeneratorRuntime = r")(runtime);
|
|
66
835
|
}
|
|
836
|
+
});
|
|
67
837
|
|
|
68
838
|
/*
|
|
69
839
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -119,10 +889,11 @@ var ApiId;
|
|
|
119
889
|
|
|
120
890
|
(function (ApiId) {
|
|
121
891
|
ApiId[ApiId["acquireTokenSilent"] = 62] = "acquireTokenSilent";
|
|
122
|
-
ApiId[ApiId["
|
|
123
|
-
ApiId[ApiId["acquireTokenByRefreshToken"] = 872] = "acquireTokenByRefreshToken";
|
|
892
|
+
ApiId[ApiId["acquireTokenByUsernamePassword"] = 371] = "acquireTokenByUsernamePassword";
|
|
124
893
|
ApiId[ApiId["acquireTokenByDeviceCode"] = 671] = "acquireTokenByDeviceCode";
|
|
125
894
|
ApiId[ApiId["acquireTokenByClientCredential"] = 771] = "acquireTokenByClientCredential";
|
|
895
|
+
ApiId[ApiId["acquireTokenByCode"] = 871] = "acquireTokenByCode";
|
|
896
|
+
ApiId[ApiId["acquireTokenByRefreshToken"] = 872] = "acquireTokenByRefreshToken";
|
|
126
897
|
})(ApiId || (ApiId = {}));
|
|
127
898
|
/**
|
|
128
899
|
* JWT constants
|
|
@@ -133,6 +904,7 @@ var JwtConstants = {
|
|
|
133
904
|
ALGORITHM: "alg",
|
|
134
905
|
RSA_256: "RS256",
|
|
135
906
|
X5T: "x5t",
|
|
907
|
+
X5C: "x5c",
|
|
136
908
|
AUDIENCE: "aud",
|
|
137
909
|
EXPIRATION_TIME: "exp",
|
|
138
910
|
ISSUER: "iss",
|
|
@@ -141,10 +913,6 @@ var JwtConstants = {
|
|
|
141
913
|
JWT_ID: "jti"
|
|
142
914
|
};
|
|
143
915
|
|
|
144
|
-
/*
|
|
145
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
146
|
-
* Licensed under the MIT License.
|
|
147
|
-
*/
|
|
148
916
|
/**
|
|
149
917
|
* This class implements the API for network requests.
|
|
150
918
|
*/
|
|
@@ -164,24 +932,45 @@ var HttpClient = /*#__PURE__*/function () {
|
|
|
164
932
|
|
|
165
933
|
var _proto = HttpClient.prototype;
|
|
166
934
|
|
|
167
|
-
_proto.sendGetRequestAsync =
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
935
|
+
_proto.sendGetRequestAsync =
|
|
936
|
+
/*#__PURE__*/
|
|
937
|
+
function () {
|
|
938
|
+
var _sendGetRequestAsync = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(url, options) {
|
|
939
|
+
var request, response;
|
|
940
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
941
|
+
while (1) {
|
|
942
|
+
switch (_context.prev = _context.next) {
|
|
943
|
+
case 0:
|
|
944
|
+
request = {
|
|
945
|
+
method: HttpMethod.GET,
|
|
946
|
+
url: url,
|
|
947
|
+
headers: options && options.headers
|
|
948
|
+
};
|
|
949
|
+
_context.next = 3;
|
|
950
|
+
return axios(request);
|
|
951
|
+
|
|
952
|
+
case 3:
|
|
953
|
+
response = _context.sent;
|
|
954
|
+
return _context.abrupt("return", {
|
|
955
|
+
headers: response.headers,
|
|
956
|
+
body: response.data,
|
|
957
|
+
status: response.status
|
|
958
|
+
});
|
|
959
|
+
|
|
960
|
+
case 5:
|
|
961
|
+
case "end":
|
|
962
|
+
return _context.stop();
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
}, _callee);
|
|
966
|
+
}));
|
|
967
|
+
|
|
968
|
+
function sendGetRequestAsync(_x, _x2) {
|
|
969
|
+
return _sendGetRequestAsync.apply(this, arguments);
|
|
183
970
|
}
|
|
184
|
-
|
|
971
|
+
|
|
972
|
+
return sendGetRequestAsync;
|
|
973
|
+
}()
|
|
185
974
|
/**
|
|
186
975
|
* Http Post request
|
|
187
976
|
* @param url
|
|
@@ -189,25 +978,46 @@ var HttpClient = /*#__PURE__*/function () {
|
|
|
189
978
|
*/
|
|
190
979
|
;
|
|
191
980
|
|
|
192
|
-
_proto.sendPostRequestAsync =
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
981
|
+
_proto.sendPostRequestAsync =
|
|
982
|
+
/*#__PURE__*/
|
|
983
|
+
function () {
|
|
984
|
+
var _sendPostRequestAsync = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(url, options) {
|
|
985
|
+
var request, response;
|
|
986
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
987
|
+
while (1) {
|
|
988
|
+
switch (_context2.prev = _context2.next) {
|
|
989
|
+
case 0:
|
|
990
|
+
request = {
|
|
991
|
+
method: HttpMethod.POST,
|
|
992
|
+
url: url,
|
|
993
|
+
data: options && options.body || "",
|
|
994
|
+
headers: options && options.headers
|
|
995
|
+
};
|
|
996
|
+
_context2.next = 3;
|
|
997
|
+
return axios(request);
|
|
998
|
+
|
|
999
|
+
case 3:
|
|
1000
|
+
response = _context2.sent;
|
|
1001
|
+
return _context2.abrupt("return", {
|
|
1002
|
+
headers: response.headers,
|
|
1003
|
+
body: response.data,
|
|
1004
|
+
status: response.status
|
|
1005
|
+
});
|
|
1006
|
+
|
|
1007
|
+
case 5:
|
|
1008
|
+
case "end":
|
|
1009
|
+
return _context2.stop();
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
}, _callee2);
|
|
1013
|
+
}));
|
|
1014
|
+
|
|
1015
|
+
function sendPostRequestAsync(_x3, _x4) {
|
|
1016
|
+
return _sendPostRequestAsync.apply(this, arguments);
|
|
209
1017
|
}
|
|
210
|
-
|
|
1018
|
+
|
|
1019
|
+
return sendPostRequestAsync;
|
|
1020
|
+
}();
|
|
211
1021
|
|
|
212
1022
|
return HttpClient;
|
|
213
1023
|
}();
|
|
@@ -231,21 +1041,22 @@ var NetworkUtils = /*#__PURE__*/function () {
|
|
|
231
1041
|
|
|
232
1042
|
var DEFAULT_AUTH_OPTIONS = {
|
|
233
1043
|
clientId: "",
|
|
234
|
-
authority:
|
|
1044
|
+
authority: Constants$1.DEFAULT_AUTHORITY,
|
|
235
1045
|
clientSecret: "",
|
|
236
1046
|
clientAssertion: "",
|
|
237
1047
|
clientCertificate: {
|
|
238
1048
|
thumbprint: "",
|
|
239
|
-
privateKey: ""
|
|
1049
|
+
privateKey: "",
|
|
1050
|
+
x5c: ""
|
|
240
1051
|
},
|
|
241
1052
|
knownAuthorities: [],
|
|
242
1053
|
cloudDiscoveryMetadata: "",
|
|
243
|
-
clientCapabilities: []
|
|
1054
|
+
clientCapabilities: [],
|
|
1055
|
+
protocolMode: ProtocolMode.AAD
|
|
244
1056
|
};
|
|
245
1057
|
var DEFAULT_CACHE_OPTIONS = {};
|
|
246
1058
|
var DEFAULT_LOGGER_OPTIONS = {
|
|
247
|
-
loggerCallback: function loggerCallback(
|
|
248
|
-
debug("msal:" + LogLevel[level] + (containsPii ? "-Pii" : ""))(message);
|
|
1059
|
+
loggerCallback: function loggerCallback() {// allow users to not set logger call back
|
|
249
1060
|
},
|
|
250
1061
|
piiLoggingEnabled: false,
|
|
251
1062
|
logLevel: LogLevel.Info
|
|
@@ -269,9 +1080,9 @@ function buildAppConfiguration(_ref) {
|
|
|
269
1080
|
cache = _ref.cache,
|
|
270
1081
|
system = _ref.system;
|
|
271
1082
|
return {
|
|
272
|
-
auth: _extends({}, DEFAULT_AUTH_OPTIONS,
|
|
273
|
-
cache: _extends({}, DEFAULT_CACHE_OPTIONS,
|
|
274
|
-
system: _extends({}, DEFAULT_SYSTEM_OPTIONS,
|
|
1083
|
+
auth: _extends({}, DEFAULT_AUTH_OPTIONS, auth),
|
|
1084
|
+
cache: _extends({}, DEFAULT_CACHE_OPTIONS, cache),
|
|
1085
|
+
system: _extends({}, DEFAULT_SYSTEM_OPTIONS, system)
|
|
275
1086
|
};
|
|
276
1087
|
}
|
|
277
1088
|
|
|
@@ -358,10 +1169,6 @@ var EncodingUtils = /*#__PURE__*/function () {
|
|
|
358
1169
|
return EncodingUtils;
|
|
359
1170
|
}();
|
|
360
1171
|
|
|
361
|
-
/*
|
|
362
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
363
|
-
* Licensed under the MIT License.
|
|
364
|
-
*/
|
|
365
1172
|
/**
|
|
366
1173
|
* https://tools.ietf.org/html/rfc7636#page-8
|
|
367
1174
|
*/
|
|
@@ -375,22 +1182,36 @@ var PkceGenerator = /*#__PURE__*/function () {
|
|
|
375
1182
|
* generates the codeVerfier and the challenge from the codeVerfier
|
|
376
1183
|
* reference: https://tools.ietf.org/html/rfc7636#section-4.1 and https://tools.ietf.org/html/rfc7636#section-4.2
|
|
377
1184
|
*/
|
|
378
|
-
_proto.generatePkceCodes =
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
var verifier
|
|
383
|
-
|
|
384
|
-
|
|
1185
|
+
_proto.generatePkceCodes =
|
|
1186
|
+
/*#__PURE__*/
|
|
1187
|
+
function () {
|
|
1188
|
+
var _generatePkceCodes = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
1189
|
+
var verifier, challenge;
|
|
1190
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1191
|
+
while (1) {
|
|
1192
|
+
switch (_context.prev = _context.next) {
|
|
1193
|
+
case 0:
|
|
1194
|
+
verifier = this.generateCodeVerifier();
|
|
1195
|
+
challenge = this.generateCodeChallengeFromVerifier(verifier);
|
|
1196
|
+
return _context.abrupt("return", {
|
|
1197
|
+
verifier: verifier,
|
|
1198
|
+
challenge: challenge
|
|
1199
|
+
});
|
|
1200
|
+
|
|
1201
|
+
case 3:
|
|
1202
|
+
case "end":
|
|
1203
|
+
return _context.stop();
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
}, _callee, this);
|
|
1207
|
+
}));
|
|
385
1208
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
challenge: challenge
|
|
389
|
-
});
|
|
390
|
-
} catch (e) {
|
|
391
|
-
return Promise.reject(e);
|
|
1209
|
+
function generatePkceCodes() {
|
|
1210
|
+
return _generatePkceCodes.apply(this, arguments);
|
|
392
1211
|
}
|
|
393
|
-
|
|
1212
|
+
|
|
1213
|
+
return generatePkceCodes;
|
|
1214
|
+
}()
|
|
394
1215
|
/**
|
|
395
1216
|
* generates the codeVerfier; reference: https://tools.ietf.org/html/rfc7636#section-4.1
|
|
396
1217
|
*/
|
|
@@ -491,6 +1312,14 @@ var CryptoProvider = /*#__PURE__*/function () {
|
|
|
491
1312
|
return this.pkceGenerator.generatePkceCodes();
|
|
492
1313
|
};
|
|
493
1314
|
|
|
1315
|
+
_proto.getPublicKeyThumbprint = function getPublicKeyThumbprint() {
|
|
1316
|
+
throw new Error("Method not implemented.");
|
|
1317
|
+
};
|
|
1318
|
+
|
|
1319
|
+
_proto.signJwt = function signJwt() {
|
|
1320
|
+
throw new Error("Method not implemented.");
|
|
1321
|
+
};
|
|
1322
|
+
|
|
494
1323
|
return CryptoProvider;
|
|
495
1324
|
}();
|
|
496
1325
|
|
|
@@ -837,10 +1666,10 @@ var Serializer = /*#__PURE__*/function () {
|
|
|
837
1666
|
var Storage = /*#__PURE__*/function (_CacheManager) {
|
|
838
1667
|
_inheritsLoose(Storage, _CacheManager);
|
|
839
1668
|
|
|
840
|
-
function Storage(logger) {
|
|
1669
|
+
function Storage(logger, clientId, cryptoImpl) {
|
|
841
1670
|
var _this;
|
|
842
1671
|
|
|
843
|
-
_this = _CacheManager.call(this) || this;
|
|
1672
|
+
_this = _CacheManager.call(this, clientId, cryptoImpl) || this;
|
|
844
1673
|
_this.cache = {};
|
|
845
1674
|
_this.changeEmitters = [];
|
|
846
1675
|
_this.logger = logger;
|
|
@@ -900,7 +1729,7 @@ var Storage = /*#__PURE__*/function (_CacheManager) {
|
|
|
900
1729
|
_proto.inMemoryCacheToCache = function inMemoryCacheToCache(inMemoryCache) {
|
|
901
1730
|
// convert in memory cache to a flat Key-Value map
|
|
902
1731
|
var cache = this.getCache();
|
|
903
|
-
cache = _extends({}, inMemoryCache.accounts,
|
|
1732
|
+
cache = _extends({}, inMemoryCache.accounts, inMemoryCache.idTokens, inMemoryCache.accessTokens, inMemoryCache.refreshTokens, inMemoryCache.appMetadata);
|
|
904
1733
|
return cache;
|
|
905
1734
|
}
|
|
906
1735
|
/**
|
|
@@ -949,31 +1778,206 @@ var Storage = /*#__PURE__*/function (_CacheManager) {
|
|
|
949
1778
|
this.emitChange();
|
|
950
1779
|
}
|
|
951
1780
|
/**
|
|
952
|
-
* Gets cache item with given
|
|
1781
|
+
* Gets cache item with given key.
|
|
953
1782
|
* @param key
|
|
954
|
-
* @param value
|
|
955
1783
|
*/
|
|
956
1784
|
;
|
|
957
1785
|
|
|
958
|
-
_proto.
|
|
1786
|
+
_proto.getItem = function getItem(key) {
|
|
959
1787
|
this.logger.verbosePii("Item key: " + key); // read cache
|
|
960
1788
|
|
|
961
1789
|
var cache = this.getCache();
|
|
962
|
-
cache[key]
|
|
963
|
-
|
|
964
|
-
this.setCache(cache);
|
|
1790
|
+
return cache[key];
|
|
965
1791
|
}
|
|
966
1792
|
/**
|
|
967
|
-
* Gets cache item with given key
|
|
1793
|
+
* Gets cache item with given <key, value>
|
|
968
1794
|
* @param key
|
|
1795
|
+
* @param value
|
|
969
1796
|
*/
|
|
970
1797
|
;
|
|
971
1798
|
|
|
972
|
-
_proto.
|
|
1799
|
+
_proto.setItem = function setItem(key, value) {
|
|
973
1800
|
this.logger.verbosePii("Item key: " + key); // read cache
|
|
974
1801
|
|
|
975
1802
|
var cache = this.getCache();
|
|
976
|
-
|
|
1803
|
+
cache[key] = value; // write to cache
|
|
1804
|
+
|
|
1805
|
+
this.setCache(cache);
|
|
1806
|
+
}
|
|
1807
|
+
/**
|
|
1808
|
+
* fetch the account entity
|
|
1809
|
+
* @param accountKey
|
|
1810
|
+
*/
|
|
1811
|
+
;
|
|
1812
|
+
|
|
1813
|
+
_proto.getAccount = function getAccount(accountKey) {
|
|
1814
|
+
var account = this.getItem(accountKey);
|
|
1815
|
+
|
|
1816
|
+
if (AccountEntity.isAccountEntity(account)) {
|
|
1817
|
+
return account;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
return null;
|
|
1821
|
+
}
|
|
1822
|
+
/**
|
|
1823
|
+
* set account entity
|
|
1824
|
+
* @param account
|
|
1825
|
+
*/
|
|
1826
|
+
;
|
|
1827
|
+
|
|
1828
|
+
_proto.setAccount = function setAccount(account) {
|
|
1829
|
+
var accountKey = account.generateAccountKey();
|
|
1830
|
+
this.setItem(accountKey, account);
|
|
1831
|
+
}
|
|
1832
|
+
/**
|
|
1833
|
+
* fetch the idToken credential
|
|
1834
|
+
* @param idTokenKey
|
|
1835
|
+
*/
|
|
1836
|
+
;
|
|
1837
|
+
|
|
1838
|
+
_proto.getIdTokenCredential = function getIdTokenCredential(idTokenKey) {
|
|
1839
|
+
var idToken = this.getItem(idTokenKey);
|
|
1840
|
+
|
|
1841
|
+
if (IdTokenEntity.isIdTokenEntity(idToken)) {
|
|
1842
|
+
return idToken;
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1845
|
+
return null;
|
|
1846
|
+
}
|
|
1847
|
+
/**
|
|
1848
|
+
* set idToken credential
|
|
1849
|
+
* @param idToken
|
|
1850
|
+
*/
|
|
1851
|
+
;
|
|
1852
|
+
|
|
1853
|
+
_proto.setIdTokenCredential = function setIdTokenCredential(idToken) {
|
|
1854
|
+
var idTokenKey = idToken.generateCredentialKey();
|
|
1855
|
+
this.setItem(idTokenKey, idToken);
|
|
1856
|
+
}
|
|
1857
|
+
/**
|
|
1858
|
+
* fetch the accessToken credential
|
|
1859
|
+
* @param accessTokenKey
|
|
1860
|
+
*/
|
|
1861
|
+
;
|
|
1862
|
+
|
|
1863
|
+
_proto.getAccessTokenCredential = function getAccessTokenCredential(accessTokenKey) {
|
|
1864
|
+
var accessToken = this.getItem(accessTokenKey);
|
|
1865
|
+
|
|
1866
|
+
if (AccessTokenEntity.isAccessTokenEntity(accessToken)) {
|
|
1867
|
+
return accessToken;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
return null;
|
|
1871
|
+
}
|
|
1872
|
+
/**
|
|
1873
|
+
* set accessToken credential
|
|
1874
|
+
* @param accessToken
|
|
1875
|
+
*/
|
|
1876
|
+
;
|
|
1877
|
+
|
|
1878
|
+
_proto.setAccessTokenCredential = function setAccessTokenCredential(accessToken) {
|
|
1879
|
+
var accessTokenKey = accessToken.generateCredentialKey();
|
|
1880
|
+
this.setItem(accessTokenKey, accessToken);
|
|
1881
|
+
}
|
|
1882
|
+
/**
|
|
1883
|
+
* fetch the refreshToken credential
|
|
1884
|
+
* @param refreshTokenKey
|
|
1885
|
+
*/
|
|
1886
|
+
;
|
|
1887
|
+
|
|
1888
|
+
_proto.getRefreshTokenCredential = function getRefreshTokenCredential(refreshTokenKey) {
|
|
1889
|
+
var refreshToken = this.getItem(refreshTokenKey);
|
|
1890
|
+
|
|
1891
|
+
if (RefreshTokenEntity.isRefreshTokenEntity(refreshToken)) {
|
|
1892
|
+
return refreshToken;
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
return null;
|
|
1896
|
+
}
|
|
1897
|
+
/**
|
|
1898
|
+
* set refreshToken credential
|
|
1899
|
+
* @param refreshToken
|
|
1900
|
+
*/
|
|
1901
|
+
;
|
|
1902
|
+
|
|
1903
|
+
_proto.setRefreshTokenCredential = function setRefreshTokenCredential(refreshToken) {
|
|
1904
|
+
var refreshTokenKey = refreshToken.generateCredentialKey();
|
|
1905
|
+
this.setItem(refreshTokenKey, refreshToken);
|
|
1906
|
+
}
|
|
1907
|
+
/**
|
|
1908
|
+
* fetch appMetadata entity from the platform cache
|
|
1909
|
+
* @param appMetadataKey
|
|
1910
|
+
*/
|
|
1911
|
+
;
|
|
1912
|
+
|
|
1913
|
+
_proto.getAppMetadata = function getAppMetadata(appMetadataKey) {
|
|
1914
|
+
var appMetadata = this.getItem(appMetadataKey);
|
|
1915
|
+
|
|
1916
|
+
if (AppMetadataEntity.isAppMetadataEntity(appMetadataKey, appMetadata)) {
|
|
1917
|
+
return appMetadata;
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
return null;
|
|
1921
|
+
}
|
|
1922
|
+
/**
|
|
1923
|
+
* set appMetadata entity to the platform cache
|
|
1924
|
+
* @param appMetadata
|
|
1925
|
+
*/
|
|
1926
|
+
;
|
|
1927
|
+
|
|
1928
|
+
_proto.setAppMetadata = function setAppMetadata(appMetadata) {
|
|
1929
|
+
var appMetadataKey = appMetadata.generateAppMetadataKey();
|
|
1930
|
+
this.setItem(appMetadataKey, appMetadata);
|
|
1931
|
+
}
|
|
1932
|
+
/**
|
|
1933
|
+
* fetch server telemetry entity from the platform cache
|
|
1934
|
+
* @param serverTelemetrykey
|
|
1935
|
+
*/
|
|
1936
|
+
;
|
|
1937
|
+
|
|
1938
|
+
_proto.getServerTelemetry = function getServerTelemetry(serverTelemetrykey) {
|
|
1939
|
+
var serverTelemetryEntity = this.getItem(serverTelemetrykey);
|
|
1940
|
+
|
|
1941
|
+
if (serverTelemetryEntity && ServerTelemetryEntity.isServerTelemetryEntity(serverTelemetrykey, serverTelemetryEntity)) {
|
|
1942
|
+
return serverTelemetryEntity;
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
return null;
|
|
1946
|
+
}
|
|
1947
|
+
/**
|
|
1948
|
+
* set server telemetry entity to the platform cache
|
|
1949
|
+
* @param serverTelemetryKey
|
|
1950
|
+
* @param serverTelemetry
|
|
1951
|
+
*/
|
|
1952
|
+
;
|
|
1953
|
+
|
|
1954
|
+
_proto.setServerTelemetry = function setServerTelemetry(serverTelemetryKey, serverTelemetry) {
|
|
1955
|
+
this.setItem(serverTelemetryKey, serverTelemetry);
|
|
1956
|
+
}
|
|
1957
|
+
/**
|
|
1958
|
+
* fetch throttling entity from the platform cache
|
|
1959
|
+
* @param throttlingCacheKey
|
|
1960
|
+
*/
|
|
1961
|
+
;
|
|
1962
|
+
|
|
1963
|
+
_proto.getThrottlingCache = function getThrottlingCache(throttlingCacheKey) {
|
|
1964
|
+
var throttlingCache = this.getItem(throttlingCacheKey);
|
|
1965
|
+
|
|
1966
|
+
if (throttlingCache && ThrottlingEntity.isThrottlingEntity(throttlingCacheKey, throttlingCache)) {
|
|
1967
|
+
return throttlingCache;
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
return null;
|
|
1971
|
+
}
|
|
1972
|
+
/**
|
|
1973
|
+
* set throttling entity to the platform cache
|
|
1974
|
+
* @param throttlingCacheKey
|
|
1975
|
+
* @param throttlingCache
|
|
1976
|
+
*/
|
|
1977
|
+
;
|
|
1978
|
+
|
|
1979
|
+
_proto.setThrottlingCache = function setThrottlingCache(throttlingCacheKey, throttlingCache) {
|
|
1980
|
+
this.setItem(throttlingCacheKey, throttlingCache);
|
|
977
1981
|
}
|
|
978
1982
|
/**
|
|
979
1983
|
* Removes the cache item from memory with the given key.
|
|
@@ -996,6 +2000,7 @@ var Storage = /*#__PURE__*/function (_CacheManager) {
|
|
|
996
2000
|
|
|
997
2001
|
if (result) {
|
|
998
2002
|
this.setCache(cache);
|
|
2003
|
+
this.emitChange();
|
|
999
2004
|
}
|
|
1000
2005
|
|
|
1001
2006
|
return result;
|
|
@@ -1130,104 +2135,218 @@ var TokenCache = /*#__PURE__*/function () {
|
|
|
1130
2135
|
}
|
|
1131
2136
|
}
|
|
1132
2137
|
/**
|
|
1133
|
-
*
|
|
2138
|
+
* API that retrieves all accounts currently in cache to the user
|
|
1134
2139
|
*/
|
|
1135
2140
|
;
|
|
1136
2141
|
|
|
1137
|
-
_proto.
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
2142
|
+
_proto.getAllAccounts =
|
|
2143
|
+
/*#__PURE__*/
|
|
2144
|
+
function () {
|
|
2145
|
+
var _getAllAccounts = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
2146
|
+
var cacheContext;
|
|
2147
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
2148
|
+
while (1) {
|
|
2149
|
+
switch (_context.prev = _context.next) {
|
|
2150
|
+
case 0:
|
|
2151
|
+
this.logger.verbose("getAllAccounts called");
|
|
2152
|
+
_context.prev = 1;
|
|
2153
|
+
|
|
2154
|
+
if (!this.persistence) {
|
|
2155
|
+
_context.next = 6;
|
|
2156
|
+
break;
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
cacheContext = new TokenCacheContext(this, false);
|
|
2160
|
+
_context.next = 6;
|
|
2161
|
+
return this.persistence.beforeCacheAccess(cacheContext);
|
|
2162
|
+
|
|
2163
|
+
case 6:
|
|
2164
|
+
return _context.abrupt("return", this.storage.getAllAccounts());
|
|
2165
|
+
|
|
2166
|
+
case 7:
|
|
2167
|
+
_context.prev = 7;
|
|
2168
|
+
|
|
2169
|
+
if (!(this.persistence && cacheContext)) {
|
|
2170
|
+
_context.next = 11;
|
|
2171
|
+
break;
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
_context.next = 11;
|
|
2175
|
+
return this.persistence.afterCacheAccess(cacheContext);
|
|
2176
|
+
|
|
2177
|
+
case 11:
|
|
2178
|
+
return _context.finish(7);
|
|
2179
|
+
|
|
2180
|
+
case 12:
|
|
2181
|
+
case "end":
|
|
2182
|
+
return _context.stop();
|
|
2183
|
+
}
|
|
1167
2184
|
}
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
|
|
2185
|
+
}, _callee, this, [[1,, 7, 12]]);
|
|
2186
|
+
}));
|
|
2187
|
+
|
|
2188
|
+
function getAllAccounts() {
|
|
2189
|
+
return _getAllAccounts.apply(this, arguments);
|
|
1171
2190
|
}
|
|
1172
|
-
|
|
2191
|
+
|
|
2192
|
+
return getAllAccounts;
|
|
2193
|
+
}()
|
|
1173
2194
|
/**
|
|
1174
|
-
*
|
|
1175
|
-
*
|
|
2195
|
+
* Returns the signed in account matching homeAccountId.
|
|
2196
|
+
* (the account object is created at the time of successful login)
|
|
2197
|
+
* or null when no matching account is found
|
|
2198
|
+
* @returns {@link AccountInfo} - the account object stored in MSAL
|
|
1176
2199
|
*/
|
|
1177
2200
|
;
|
|
1178
2201
|
|
|
1179
|
-
_proto.
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
2202
|
+
_proto.getAccountByHomeId =
|
|
2203
|
+
/*#__PURE__*/
|
|
2204
|
+
function () {
|
|
2205
|
+
var _getAccountByHomeId = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(homeAccountId) {
|
|
2206
|
+
var allAccounts;
|
|
2207
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2208
|
+
while (1) {
|
|
2209
|
+
switch (_context2.prev = _context2.next) {
|
|
2210
|
+
case 0:
|
|
2211
|
+
_context2.next = 2;
|
|
2212
|
+
return this.getAllAccounts();
|
|
2213
|
+
|
|
2214
|
+
case 2:
|
|
2215
|
+
allAccounts = _context2.sent;
|
|
2216
|
+
|
|
2217
|
+
if (!(!StringUtils.isEmpty(homeAccountId) && allAccounts && allAccounts.length)) {
|
|
2218
|
+
_context2.next = 7;
|
|
2219
|
+
break;
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
return _context2.abrupt("return", allAccounts.filter(function (accountObj) {
|
|
2223
|
+
return accountObj.homeAccountId === homeAccountId;
|
|
2224
|
+
})[0] || null);
|
|
2225
|
+
|
|
2226
|
+
case 7:
|
|
2227
|
+
return _context2.abrupt("return", null);
|
|
2228
|
+
|
|
2229
|
+
case 8:
|
|
2230
|
+
case "end":
|
|
2231
|
+
return _context2.stop();
|
|
2232
|
+
}
|
|
1206
2233
|
}
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
|
|
2234
|
+
}, _callee2, this);
|
|
2235
|
+
}));
|
|
2236
|
+
|
|
2237
|
+
function getAccountByHomeId(_x) {
|
|
2238
|
+
return _getAccountByHomeId.apply(this, arguments);
|
|
1210
2239
|
}
|
|
1211
|
-
|
|
2240
|
+
|
|
2241
|
+
return getAccountByHomeId;
|
|
2242
|
+
}()
|
|
1212
2243
|
/**
|
|
1213
|
-
*
|
|
2244
|
+
* Returns the signed in account matching localAccountId.
|
|
2245
|
+
* (the account object is created at the time of successful login)
|
|
2246
|
+
* or null when no matching account is found
|
|
2247
|
+
* @returns {@link AccountInfo} - the account object stored in MSAL
|
|
1214
2248
|
*/
|
|
1215
2249
|
;
|
|
1216
2250
|
|
|
1217
|
-
_proto.
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
2251
|
+
_proto.getAccountByLocalId =
|
|
2252
|
+
/*#__PURE__*/
|
|
2253
|
+
function () {
|
|
2254
|
+
var _getAccountByLocalId = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(localAccountId) {
|
|
2255
|
+
var allAccounts;
|
|
2256
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2257
|
+
while (1) {
|
|
2258
|
+
switch (_context3.prev = _context3.next) {
|
|
2259
|
+
case 0:
|
|
2260
|
+
_context3.next = 2;
|
|
2261
|
+
return this.getAllAccounts();
|
|
2262
|
+
|
|
2263
|
+
case 2:
|
|
2264
|
+
allAccounts = _context3.sent;
|
|
2265
|
+
|
|
2266
|
+
if (!(!StringUtils.isEmpty(localAccountId) && allAccounts && allAccounts.length)) {
|
|
2267
|
+
_context3.next = 7;
|
|
2268
|
+
break;
|
|
2269
|
+
}
|
|
2270
|
+
|
|
2271
|
+
return _context3.abrupt("return", allAccounts.filter(function (accountObj) {
|
|
2272
|
+
return accountObj.localAccountId === localAccountId;
|
|
2273
|
+
})[0] || null);
|
|
2274
|
+
|
|
2275
|
+
case 7:
|
|
2276
|
+
return _context3.abrupt("return", null);
|
|
2277
|
+
|
|
2278
|
+
case 8:
|
|
2279
|
+
case "end":
|
|
2280
|
+
return _context3.stop();
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
}, _callee3, this);
|
|
2284
|
+
}));
|
|
2285
|
+
|
|
2286
|
+
function getAccountByLocalId(_x2) {
|
|
2287
|
+
return _getAccountByLocalId.apply(this, arguments);
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2290
|
+
return getAccountByLocalId;
|
|
2291
|
+
}()
|
|
1221
2292
|
/**
|
|
1222
2293
|
* API to remove a specific account and the relevant data from cache
|
|
1223
2294
|
* @param account
|
|
1224
2295
|
*/
|
|
1225
2296
|
;
|
|
1226
2297
|
|
|
1227
|
-
_proto.removeAccount =
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
2298
|
+
_proto.removeAccount =
|
|
2299
|
+
/*#__PURE__*/
|
|
2300
|
+
function () {
|
|
2301
|
+
var _removeAccount = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(account) {
|
|
2302
|
+
var cacheContext;
|
|
2303
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2304
|
+
while (1) {
|
|
2305
|
+
switch (_context4.prev = _context4.next) {
|
|
2306
|
+
case 0:
|
|
2307
|
+
this.logger.verbose("removeAccount called");
|
|
2308
|
+
_context4.prev = 1;
|
|
2309
|
+
|
|
2310
|
+
if (!this.persistence) {
|
|
2311
|
+
_context4.next = 6;
|
|
2312
|
+
break;
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2315
|
+
cacheContext = new TokenCacheContext(this, true);
|
|
2316
|
+
_context4.next = 6;
|
|
2317
|
+
return this.persistence.beforeCacheAccess(cacheContext);
|
|
2318
|
+
|
|
2319
|
+
case 6:
|
|
2320
|
+
this.storage.removeAccount(AccountEntity.generateAccountCacheKey(account));
|
|
2321
|
+
|
|
2322
|
+
case 7:
|
|
2323
|
+
_context4.prev = 7;
|
|
2324
|
+
|
|
2325
|
+
if (!(this.persistence && cacheContext)) {
|
|
2326
|
+
_context4.next = 11;
|
|
2327
|
+
break;
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
_context4.next = 11;
|
|
2331
|
+
return this.persistence.afterCacheAccess(cacheContext);
|
|
2332
|
+
|
|
2333
|
+
case 11:
|
|
2334
|
+
return _context4.finish(7);
|
|
2335
|
+
|
|
2336
|
+
case 12:
|
|
2337
|
+
case "end":
|
|
2338
|
+
return _context4.stop();
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
}, _callee4, this, [[1,, 7, 12]]);
|
|
2342
|
+
}));
|
|
2343
|
+
|
|
2344
|
+
function removeAccount(_x3) {
|
|
2345
|
+
return _removeAccount.apply(this, arguments);
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
return removeAccount;
|
|
2349
|
+
}()
|
|
1231
2350
|
/**
|
|
1232
2351
|
* Called when the cache has changed state.
|
|
1233
2352
|
*/
|
|
@@ -1256,7 +2375,7 @@ var TokenCache = /*#__PURE__*/function () {
|
|
|
1256
2375
|
;
|
|
1257
2376
|
|
|
1258
2377
|
_proto.mergeUpdates = function mergeUpdates(oldState, newState) {
|
|
1259
|
-
var
|
|
2378
|
+
var _this = this;
|
|
1260
2379
|
|
|
1261
2380
|
Object.keys(newState).forEach(function (newKey) {
|
|
1262
2381
|
var newValue = newState[newKey]; // if oldState does not contain value but newValue does, add it
|
|
@@ -1273,7 +2392,7 @@ var TokenCache = /*#__PURE__*/function () {
|
|
|
1273
2392
|
var oldStateNotUndefinedOrNull = typeof oldState[newKey] !== "undefined" && oldState[newKey] !== null;
|
|
1274
2393
|
|
|
1275
2394
|
if (newValueNotNull && newValueIsObject && newValueIsNotArray && oldStateNotUndefinedOrNull) {
|
|
1276
|
-
|
|
2395
|
+
_this.mergeUpdates(oldState[newKey], newValue);
|
|
1277
2396
|
} else {
|
|
1278
2397
|
oldState[newKey] = newValue;
|
|
1279
2398
|
}
|
|
@@ -1291,11 +2410,11 @@ var TokenCache = /*#__PURE__*/function () {
|
|
|
1291
2410
|
|
|
1292
2411
|
_proto.mergeRemovals = function mergeRemovals(oldState, newState) {
|
|
1293
2412
|
this.logger.verbose("Remove updated entries in cache");
|
|
1294
|
-
var accounts = oldState.Account
|
|
1295
|
-
var accessTokens = oldState.AccessToken
|
|
1296
|
-
var refreshTokens = oldState.RefreshToken
|
|
1297
|
-
var idTokens = oldState.IdToken
|
|
1298
|
-
var appMetadata = oldState.AppMetadata
|
|
2413
|
+
var accounts = oldState.Account ? this.mergeRemovalsDict(oldState.Account, newState.Account) : oldState.Account;
|
|
2414
|
+
var accessTokens = oldState.AccessToken ? this.mergeRemovalsDict(oldState.AccessToken, newState.AccessToken) : oldState.AccessToken;
|
|
2415
|
+
var refreshTokens = oldState.RefreshToken ? this.mergeRemovalsDict(oldState.RefreshToken, newState.RefreshToken) : oldState.RefreshToken;
|
|
2416
|
+
var idTokens = oldState.IdToken ? this.mergeRemovalsDict(oldState.IdToken, newState.IdToken) : oldState.IdToken;
|
|
2417
|
+
var appMetadata = oldState.AppMetadata ? this.mergeRemovalsDict(oldState.AppMetadata, newState.AppMetadata) : oldState.AppMetadata;
|
|
1299
2418
|
return _extends({}, oldState, {
|
|
1300
2419
|
Account: accounts,
|
|
1301
2420
|
AccessToken: accessTokens,
|
|
@@ -1319,18 +2438,19 @@ var TokenCache = /*#__PURE__*/function () {
|
|
|
1319
2438
|
_proto.overlayDefaults = function overlayDefaults(passedInCache) {
|
|
1320
2439
|
this.logger.verbose("Overlaying input cache with the default cache");
|
|
1321
2440
|
return {
|
|
1322
|
-
Account: _extends({}, defaultSerializedCache.Account,
|
|
1323
|
-
IdToken: _extends({}, defaultSerializedCache.IdToken,
|
|
1324
|
-
AccessToken: _extends({}, defaultSerializedCache.AccessToken,
|
|
1325
|
-
RefreshToken: _extends({}, defaultSerializedCache.RefreshToken,
|
|
1326
|
-
AppMetadata: _extends({}, defaultSerializedCache.AppMetadata,
|
|
2441
|
+
Account: _extends({}, defaultSerializedCache.Account, passedInCache.Account),
|
|
2442
|
+
IdToken: _extends({}, defaultSerializedCache.IdToken, passedInCache.IdToken),
|
|
2443
|
+
AccessToken: _extends({}, defaultSerializedCache.AccessToken, passedInCache.AccessToken),
|
|
2444
|
+
RefreshToken: _extends({}, defaultSerializedCache.RefreshToken, passedInCache.RefreshToken),
|
|
2445
|
+
AppMetadata: _extends({}, defaultSerializedCache.AppMetadata, passedInCache.AppMetadata)
|
|
1327
2446
|
};
|
|
1328
2447
|
};
|
|
1329
2448
|
|
|
1330
2449
|
return TokenCache;
|
|
1331
2450
|
}();
|
|
1332
2451
|
|
|
1333
|
-
var
|
|
2452
|
+
var name = "@azure/msal-node";
|
|
2453
|
+
var version = "1.0.0-beta.2";
|
|
1334
2454
|
|
|
1335
2455
|
var ClientApplication = /*#__PURE__*/function () {
|
|
1336
2456
|
/**
|
|
@@ -1338,10 +2458,10 @@ var ClientApplication = /*#__PURE__*/function () {
|
|
|
1338
2458
|
*/
|
|
1339
2459
|
function ClientApplication(configuration) {
|
|
1340
2460
|
this.config = buildAppConfiguration(configuration);
|
|
1341
|
-
this.logger = new Logger(this.config.system.loggerOptions);
|
|
1342
|
-
this.storage = new Storage(this.logger);
|
|
1343
|
-
this.tokenCache = new TokenCache(this.storage, this.logger, this.config.cache.cachePlugin);
|
|
1344
2461
|
this.cryptoProvider = new CryptoProvider();
|
|
2462
|
+
this.logger = new Logger(this.config.system.loggerOptions, name, version);
|
|
2463
|
+
this.storage = new Storage(this.logger, this.config.auth.clientId, this.cryptoProvider);
|
|
2464
|
+
this.tokenCache = new TokenCache(this.storage, this.logger, this.config.cache.cachePlugin);
|
|
1345
2465
|
TrustedAuthority.setTrustedAuthoritiesFromConfig(this.config.auth.knownAuthorities, this.config.auth.cloudDiscoveryMetadata);
|
|
1346
2466
|
}
|
|
1347
2467
|
/**
|
|
@@ -1357,22 +2477,43 @@ var ClientApplication = /*#__PURE__*/function () {
|
|
|
1357
2477
|
|
|
1358
2478
|
var _proto = ClientApplication.prototype;
|
|
1359
2479
|
|
|
1360
|
-
_proto.getAuthCodeUrl =
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
2480
|
+
_proto.getAuthCodeUrl =
|
|
2481
|
+
/*#__PURE__*/
|
|
2482
|
+
function () {
|
|
2483
|
+
var _getAuthCodeUrl = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(request) {
|
|
2484
|
+
var validRequest, authClientConfig, authorizationCodeClient;
|
|
2485
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
2486
|
+
while (1) {
|
|
2487
|
+
switch (_context.prev = _context.next) {
|
|
2488
|
+
case 0:
|
|
2489
|
+
this.logger.info("getAuthCodeUrl called");
|
|
2490
|
+
validRequest = _extends({}, request, this.initializeBaseRequest(request), {
|
|
2491
|
+
responseMode: request.responseMode || ResponseMode.QUERY,
|
|
2492
|
+
authenticationScheme: AuthenticationScheme.BEARER
|
|
2493
|
+
});
|
|
2494
|
+
_context.next = 4;
|
|
2495
|
+
return this.buildOauthClientConfiguration(validRequest.authority);
|
|
2496
|
+
|
|
2497
|
+
case 4:
|
|
2498
|
+
authClientConfig = _context.sent;
|
|
2499
|
+
this.logger.verbose("Auth client config generated");
|
|
2500
|
+
authorizationCodeClient = new AuthorizationCodeClient(authClientConfig);
|
|
2501
|
+
return _context.abrupt("return", authorizationCodeClient.getAuthCodeUrl(validRequest));
|
|
2502
|
+
|
|
2503
|
+
case 8:
|
|
2504
|
+
case "end":
|
|
2505
|
+
return _context.stop();
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2508
|
+
}, _callee, this);
|
|
2509
|
+
}));
|
|
1368
2510
|
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
});
|
|
1372
|
-
} catch (e) {
|
|
1373
|
-
return Promise.reject(e);
|
|
2511
|
+
function getAuthCodeUrl(_x) {
|
|
2512
|
+
return _getAuthCodeUrl.apply(this, arguments);
|
|
1374
2513
|
}
|
|
1375
|
-
|
|
2514
|
+
|
|
2515
|
+
return getAuthCodeUrl;
|
|
2516
|
+
}()
|
|
1376
2517
|
/**
|
|
1377
2518
|
* Acquires a token by exchanging the Authorization Code received from the first step of OAuth2.0
|
|
1378
2519
|
* Authorization Code flow.
|
|
@@ -1383,31 +2524,50 @@ var ClientApplication = /*#__PURE__*/function () {
|
|
|
1383
2524
|
*/
|
|
1384
2525
|
;
|
|
1385
2526
|
|
|
1386
|
-
_proto.acquireTokenByCode =
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
2527
|
+
_proto.acquireTokenByCode =
|
|
2528
|
+
/*#__PURE__*/
|
|
2529
|
+
function () {
|
|
2530
|
+
var _acquireTokenByCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(request) {
|
|
2531
|
+
var validRequest, serverTelemetryManager, authClientConfig, authorizationCodeClient;
|
|
2532
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2533
|
+
while (1) {
|
|
2534
|
+
switch (_context2.prev = _context2.next) {
|
|
2535
|
+
case 0:
|
|
2536
|
+
this.logger.info("acquireTokenByCode called");
|
|
2537
|
+
validRequest = _extends({}, request, this.initializeBaseRequest(request), {
|
|
2538
|
+
authenticationScheme: AuthenticationScheme.BEARER
|
|
2539
|
+
});
|
|
2540
|
+
serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByCode, validRequest.correlationId);
|
|
2541
|
+
_context2.prev = 3;
|
|
2542
|
+
_context2.next = 6;
|
|
2543
|
+
return this.buildOauthClientConfiguration(validRequest.authority, serverTelemetryManager);
|
|
2544
|
+
|
|
2545
|
+
case 6:
|
|
2546
|
+
authClientConfig = _context2.sent;
|
|
2547
|
+
this.logger.verbose("Auth client config generated");
|
|
2548
|
+
authorizationCodeClient = new AuthorizationCodeClient(authClientConfig);
|
|
2549
|
+
return _context2.abrupt("return", authorizationCodeClient.acquireToken(validRequest));
|
|
2550
|
+
|
|
2551
|
+
case 12:
|
|
2552
|
+
_context2.prev = 12;
|
|
2553
|
+
_context2.t0 = _context2["catch"](3);
|
|
2554
|
+
serverTelemetryManager.cacheFailedRequest(_context2.t0);
|
|
2555
|
+
throw _context2.t0;
|
|
2556
|
+
|
|
2557
|
+
case 16:
|
|
2558
|
+
case "end":
|
|
2559
|
+
return _context2.stop();
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
}, _callee2, this, [[3, 12]]);
|
|
2563
|
+
}));
|
|
1399
2564
|
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
});
|
|
1403
|
-
}, function (e) {
|
|
1404
|
-
serverTelemetryManager.cacheFailedRequest(e);
|
|
1405
|
-
throw e;
|
|
1406
|
-
}));
|
|
1407
|
-
} catch (e) {
|
|
1408
|
-
return Promise.reject(e);
|
|
2565
|
+
function acquireTokenByCode(_x2) {
|
|
2566
|
+
return _acquireTokenByCode.apply(this, arguments);
|
|
1409
2567
|
}
|
|
1410
|
-
|
|
2568
|
+
|
|
2569
|
+
return acquireTokenByCode;
|
|
2570
|
+
}()
|
|
1411
2571
|
/**
|
|
1412
2572
|
* Acquires a token by exchanging the refresh token provided for a new set of tokens.
|
|
1413
2573
|
*
|
|
@@ -1417,31 +2577,50 @@ var ClientApplication = /*#__PURE__*/function () {
|
|
|
1417
2577
|
*/
|
|
1418
2578
|
;
|
|
1419
2579
|
|
|
1420
|
-
_proto.acquireTokenByRefreshToken =
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
2580
|
+
_proto.acquireTokenByRefreshToken =
|
|
2581
|
+
/*#__PURE__*/
|
|
2582
|
+
function () {
|
|
2583
|
+
var _acquireTokenByRefreshToken = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(request) {
|
|
2584
|
+
var validRequest, serverTelemetryManager, refreshTokenClientConfig, refreshTokenClient;
|
|
2585
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2586
|
+
while (1) {
|
|
2587
|
+
switch (_context3.prev = _context3.next) {
|
|
2588
|
+
case 0:
|
|
2589
|
+
this.logger.info("acquireTokenByRefreshToken called");
|
|
2590
|
+
validRequest = _extends({}, request, this.initializeBaseRequest(request), {
|
|
2591
|
+
authenticationScheme: AuthenticationScheme.BEARER
|
|
2592
|
+
});
|
|
2593
|
+
serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByRefreshToken, validRequest.correlationId);
|
|
2594
|
+
_context3.prev = 3;
|
|
2595
|
+
_context3.next = 6;
|
|
2596
|
+
return this.buildOauthClientConfiguration(validRequest.authority, serverTelemetryManager);
|
|
2597
|
+
|
|
2598
|
+
case 6:
|
|
2599
|
+
refreshTokenClientConfig = _context3.sent;
|
|
2600
|
+
this.logger.verbose("Auth client config generated");
|
|
2601
|
+
refreshTokenClient = new RefreshTokenClient(refreshTokenClientConfig);
|
|
2602
|
+
return _context3.abrupt("return", refreshTokenClient.acquireToken(validRequest));
|
|
2603
|
+
|
|
2604
|
+
case 12:
|
|
2605
|
+
_context3.prev = 12;
|
|
2606
|
+
_context3.t0 = _context3["catch"](3);
|
|
2607
|
+
serverTelemetryManager.cacheFailedRequest(_context3.t0);
|
|
2608
|
+
throw _context3.t0;
|
|
2609
|
+
|
|
2610
|
+
case 16:
|
|
2611
|
+
case "end":
|
|
2612
|
+
return _context3.stop();
|
|
2613
|
+
}
|
|
2614
|
+
}
|
|
2615
|
+
}, _callee3, this, [[3, 12]]);
|
|
2616
|
+
}));
|
|
1433
2617
|
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
});
|
|
1437
|
-
}, function (e) {
|
|
1438
|
-
serverTelemetryManager.cacheFailedRequest(e);
|
|
1439
|
-
throw e;
|
|
1440
|
-
}));
|
|
1441
|
-
} catch (e) {
|
|
1442
|
-
return Promise.reject(e);
|
|
2618
|
+
function acquireTokenByRefreshToken(_x3) {
|
|
2619
|
+
return _acquireTokenByRefreshToken.apply(this, arguments);
|
|
1443
2620
|
}
|
|
1444
|
-
|
|
2621
|
+
|
|
2622
|
+
return acquireTokenByRefreshToken;
|
|
2623
|
+
}()
|
|
1445
2624
|
/**
|
|
1446
2625
|
* Acquires a token silently when a user specifies the account the token is requested for.
|
|
1447
2626
|
*
|
|
@@ -1452,27 +2631,48 @@ var ClientApplication = /*#__PURE__*/function () {
|
|
|
1452
2631
|
*/
|
|
1453
2632
|
;
|
|
1454
2633
|
|
|
1455
|
-
_proto.acquireTokenSilent =
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
var validRequest
|
|
1460
|
-
|
|
1461
|
-
|
|
2634
|
+
_proto.acquireTokenSilent =
|
|
2635
|
+
/*#__PURE__*/
|
|
2636
|
+
function () {
|
|
2637
|
+
var _acquireTokenSilent = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(request) {
|
|
2638
|
+
var validRequest, serverTelemetryManager, silentFlowClientConfig, silentFlowClient;
|
|
2639
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2640
|
+
while (1) {
|
|
2641
|
+
switch (_context4.prev = _context4.next) {
|
|
2642
|
+
case 0:
|
|
2643
|
+
validRequest = _extends({}, request, this.initializeBaseRequest(request), {
|
|
2644
|
+
forceRefresh: request.forceRefresh || false
|
|
2645
|
+
});
|
|
2646
|
+
serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent, validRequest.correlationId, validRequest.forceRefresh);
|
|
2647
|
+
_context4.prev = 2;
|
|
2648
|
+
_context4.next = 5;
|
|
2649
|
+
return this.buildOauthClientConfiguration(validRequest.authority, serverTelemetryManager);
|
|
2650
|
+
|
|
2651
|
+
case 5:
|
|
2652
|
+
silentFlowClientConfig = _context4.sent;
|
|
2653
|
+
silentFlowClient = new SilentFlowClient(silentFlowClientConfig);
|
|
2654
|
+
return _context4.abrupt("return", silentFlowClient.acquireToken(validRequest));
|
|
2655
|
+
|
|
2656
|
+
case 10:
|
|
2657
|
+
_context4.prev = 10;
|
|
2658
|
+
_context4.t0 = _context4["catch"](2);
|
|
2659
|
+
serverTelemetryManager.cacheFailedRequest(_context4.t0);
|
|
2660
|
+
throw _context4.t0;
|
|
2661
|
+
|
|
2662
|
+
case 14:
|
|
2663
|
+
case "end":
|
|
2664
|
+
return _context4.stop();
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
}, _callee4, this, [[2, 10]]);
|
|
2668
|
+
}));
|
|
1462
2669
|
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
var silentFlowClient = new SilentFlowClient(silentFlowClientConfig);
|
|
1466
|
-
return silentFlowClient.acquireToken(validRequest);
|
|
1467
|
-
});
|
|
1468
|
-
}, function (e) {
|
|
1469
|
-
serverTelemetryManager.cacheFailedRequest(e);
|
|
1470
|
-
throw e;
|
|
1471
|
-
}));
|
|
1472
|
-
} catch (e) {
|
|
1473
|
-
return Promise.reject(e);
|
|
2670
|
+
function acquireTokenSilent(_x4) {
|
|
2671
|
+
return _acquireTokenSilent.apply(this, arguments);
|
|
1474
2672
|
}
|
|
1475
|
-
|
|
2673
|
+
|
|
2674
|
+
return acquireTokenSilent;
|
|
2675
|
+
}()
|
|
1476
2676
|
/**
|
|
1477
2677
|
* Gets the token cache for the application.
|
|
1478
2678
|
*/
|
|
@@ -1481,49 +2681,98 @@ var ClientApplication = /*#__PURE__*/function () {
|
|
|
1481
2681
|
_proto.getTokenCache = function getTokenCache() {
|
|
1482
2682
|
this.logger.info("getTokenCache called");
|
|
1483
2683
|
return this.tokenCache;
|
|
2684
|
+
}
|
|
2685
|
+
/**
|
|
2686
|
+
* Returns the logger instance
|
|
2687
|
+
*/
|
|
2688
|
+
;
|
|
2689
|
+
|
|
2690
|
+
_proto.getLogger = function getLogger() {
|
|
2691
|
+
return this.logger;
|
|
2692
|
+
}
|
|
2693
|
+
/**
|
|
2694
|
+
* Replaces the default logger set in configurations with new Logger with new configurations
|
|
2695
|
+
* @param logger Logger instance
|
|
2696
|
+
*/
|
|
2697
|
+
;
|
|
2698
|
+
|
|
2699
|
+
_proto.setLogger = function setLogger(logger) {
|
|
2700
|
+
this.logger = logger;
|
|
1484
2701
|
};
|
|
1485
2702
|
|
|
1486
|
-
_proto.buildOauthClientConfiguration = function
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
2703
|
+
_proto.buildOauthClientConfiguration = /*#__PURE__*/function () {
|
|
2704
|
+
var _buildOauthClientConfiguration = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(authority, serverTelemetryManager) {
|
|
2705
|
+
return runtime_1.wrap(function _callee5$(_context5) {
|
|
2706
|
+
while (1) {
|
|
2707
|
+
switch (_context5.prev = _context5.next) {
|
|
2708
|
+
case 0:
|
|
2709
|
+
this.logger.verbose("buildOauthClientConfiguration called"); // using null assertion operator as we ensure that all config values have default values in buildConfiguration()
|
|
2710
|
+
|
|
2711
|
+
_context5.t0 = this.config.auth.clientId;
|
|
2712
|
+
_context5.next = 4;
|
|
2713
|
+
return this.createAuthority(authority);
|
|
2714
|
+
|
|
2715
|
+
case 4:
|
|
2716
|
+
_context5.t1 = _context5.sent;
|
|
2717
|
+
_context5.t2 = this.config.auth.knownAuthorities;
|
|
2718
|
+
_context5.t3 = this.config.auth.cloudDiscoveryMetadata;
|
|
2719
|
+
_context5.t4 = this.config.auth.clientCapabilities;
|
|
2720
|
+
_context5.t5 = this.config.auth.protocolMode;
|
|
2721
|
+
_context5.t6 = {
|
|
2722
|
+
clientId: _context5.t0,
|
|
2723
|
+
authority: _context5.t1,
|
|
2724
|
+
knownAuthorities: _context5.t2,
|
|
2725
|
+
cloudDiscoveryMetadata: _context5.t3,
|
|
2726
|
+
clientCapabilities: _context5.t4,
|
|
2727
|
+
protocolMode: _context5.t5
|
|
2728
|
+
};
|
|
2729
|
+
_context5.t7 = {
|
|
2730
|
+
loggerCallback: this.config.system.loggerOptions.loggerCallback,
|
|
2731
|
+
piiLoggingEnabled: this.config.system.loggerOptions.piiLoggingEnabled
|
|
2732
|
+
};
|
|
2733
|
+
_context5.t8 = this.cryptoProvider;
|
|
2734
|
+
_context5.t9 = this.config.system.networkClient;
|
|
2735
|
+
_context5.t10 = this.storage;
|
|
2736
|
+
_context5.t11 = serverTelemetryManager;
|
|
2737
|
+
_context5.t12 = {
|
|
2738
|
+
clientSecret: this.clientSecret,
|
|
2739
|
+
clientAssertion: this.clientAssertion ? this.getClientAssertion() : undefined
|
|
2740
|
+
};
|
|
2741
|
+
_context5.t13 = {
|
|
2742
|
+
sku: Constants.MSAL_SKU,
|
|
2743
|
+
version: version,
|
|
2744
|
+
cpu: process.arch || "",
|
|
2745
|
+
os: process.platform || ""
|
|
2746
|
+
};
|
|
2747
|
+
_context5.t14 = this.config.cache.cachePlugin;
|
|
2748
|
+
_context5.t15 = this.tokenCache;
|
|
2749
|
+
return _context5.abrupt("return", {
|
|
2750
|
+
authOptions: _context5.t6,
|
|
2751
|
+
loggerOptions: _context5.t7,
|
|
2752
|
+
cryptoInterface: _context5.t8,
|
|
2753
|
+
networkInterface: _context5.t9,
|
|
2754
|
+
storageInterface: _context5.t10,
|
|
2755
|
+
serverTelemetryManager: _context5.t11,
|
|
2756
|
+
clientCredentials: _context5.t12,
|
|
2757
|
+
libraryInfo: _context5.t13,
|
|
2758
|
+
persistencePlugin: _context5.t14,
|
|
2759
|
+
serializableCache: _context5.t15
|
|
2760
|
+
});
|
|
2761
|
+
|
|
2762
|
+
case 20:
|
|
2763
|
+
case "end":
|
|
2764
|
+
return _context5.stop();
|
|
1520
2765
|
}
|
|
1521
|
-
}
|
|
1522
|
-
});
|
|
1523
|
-
}
|
|
1524
|
-
|
|
2766
|
+
}
|
|
2767
|
+
}, _callee5, this);
|
|
2768
|
+
}));
|
|
2769
|
+
|
|
2770
|
+
function buildOauthClientConfiguration(_x5, _x6) {
|
|
2771
|
+
return _buildOauthClientConfiguration.apply(this, arguments);
|
|
1525
2772
|
}
|
|
1526
|
-
|
|
2773
|
+
|
|
2774
|
+
return buildOauthClientConfiguration;
|
|
2775
|
+
}();
|
|
1527
2776
|
|
|
1528
2777
|
_proto.getClientAssertion = function getClientAssertion() {
|
|
1529
2778
|
return {
|
|
@@ -1537,11 +2786,12 @@ var ClientApplication = /*#__PURE__*/function () {
|
|
|
1537
2786
|
*/
|
|
1538
2787
|
;
|
|
1539
2788
|
|
|
1540
|
-
_proto.
|
|
2789
|
+
_proto.initializeBaseRequest = function initializeBaseRequest(authRequest) {
|
|
1541
2790
|
this.logger.verbose("initializeRequestScopes called");
|
|
1542
2791
|
return _extends({}, authRequest, {
|
|
1543
2792
|
scopes: [].concat(authRequest && authRequest.scopes || [], [Constants$1.OPENID_SCOPE, Constants$1.PROFILE_SCOPE, Constants$1.OFFLINE_ACCESS_SCOPE]),
|
|
1544
|
-
correlationId: authRequest && authRequest.correlationId || this.cryptoProvider.createNewGuid()
|
|
2793
|
+
correlationId: authRequest && authRequest.correlationId || this.cryptoProvider.createNewGuid(),
|
|
2794
|
+
authority: authRequest.authority || this.config.auth.authority
|
|
1545
2795
|
});
|
|
1546
2796
|
};
|
|
1547
2797
|
|
|
@@ -1561,39 +2811,59 @@ var ClientApplication = /*#__PURE__*/function () {
|
|
|
1561
2811
|
*/
|
|
1562
2812
|
;
|
|
1563
2813
|
|
|
1564
|
-
_proto.createAuthority =
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
_this12.logger.verbose("createAuthority called");
|
|
1569
|
-
|
|
2814
|
+
_proto.createAuthority =
|
|
2815
|
+
/*#__PURE__*/
|
|
2816
|
+
function () {
|
|
2817
|
+
var _createAuthority = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(authorityString) {
|
|
1570
2818
|
var authority;
|
|
2819
|
+
return runtime_1.wrap(function _callee6$(_context6) {
|
|
2820
|
+
while (1) {
|
|
2821
|
+
switch (_context6.prev = _context6.next) {
|
|
2822
|
+
case 0:
|
|
2823
|
+
this.logger.verbose("createAuthority called");
|
|
2824
|
+
|
|
2825
|
+
if (this.authority.canonicalAuthority !== authorityString) {
|
|
2826
|
+
this.logger.verbose("Authority passed in, creating authority instance");
|
|
2827
|
+
authority = AuthorityFactory.createInstance(authorityString, this.config.system.networkClient, this.config.auth.protocolMode);
|
|
2828
|
+
} else {
|
|
2829
|
+
this.logger.verbose("Authority on request is the same as on application object, defaulting to authority set on application object");
|
|
2830
|
+
authority = this.authority;
|
|
2831
|
+
}
|
|
2832
|
+
|
|
2833
|
+
if (!authority.discoveryComplete()) {
|
|
2834
|
+
_context6.next = 4;
|
|
2835
|
+
break;
|
|
2836
|
+
}
|
|
2837
|
+
|
|
2838
|
+
return _context6.abrupt("return", authority);
|
|
2839
|
+
|
|
2840
|
+
case 4:
|
|
2841
|
+
_context6.prev = 4;
|
|
2842
|
+
_context6.next = 7;
|
|
2843
|
+
return authority.resolveEndpointsAsync();
|
|
2844
|
+
|
|
2845
|
+
case 7:
|
|
2846
|
+
return _context6.abrupt("return", authority);
|
|
2847
|
+
|
|
2848
|
+
case 10:
|
|
2849
|
+
_context6.prev = 10;
|
|
2850
|
+
_context6.t0 = _context6["catch"](4);
|
|
2851
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError(_context6.t0);
|
|
2852
|
+
|
|
2853
|
+
case 13:
|
|
2854
|
+
case "end":
|
|
2855
|
+
return _context6.stop();
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2858
|
+
}, _callee6, this, [[4, 10]]);
|
|
2859
|
+
}));
|
|
1571
2860
|
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
authority = AuthorityFactory.createInstance(authorityString, _this12.config.system.networkClient);
|
|
1576
|
-
} else {
|
|
1577
|
-
_this12.logger.verbose("No authority passed in request, defaulting to authority set on application object");
|
|
1578
|
-
|
|
1579
|
-
authority = _this12.authority;
|
|
1580
|
-
}
|
|
1581
|
-
|
|
1582
|
-
if (authority.discoveryComplete()) {
|
|
1583
|
-
return Promise.resolve(authority);
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
|
-
return Promise.resolve(_catch(function () {
|
|
1587
|
-
return Promise.resolve(authority.resolveEndpointsAsync()).then(function () {
|
|
1588
|
-
return authority;
|
|
1589
|
-
});
|
|
1590
|
-
}, function (error) {
|
|
1591
|
-
throw ClientAuthError.createEndpointDiscoveryIncompleteError(error);
|
|
1592
|
-
}));
|
|
1593
|
-
} catch (e) {
|
|
1594
|
-
return Promise.reject(e);
|
|
2861
|
+
function createAuthority(_x7) {
|
|
2862
|
+
return _createAuthority.apply(this, arguments);
|
|
1595
2863
|
}
|
|
1596
|
-
|
|
2864
|
+
|
|
2865
|
+
return createAuthority;
|
|
2866
|
+
}();
|
|
1597
2867
|
|
|
1598
2868
|
_createClass(ClientApplication, [{
|
|
1599
2869
|
key: "authority",
|
|
@@ -1602,7 +2872,7 @@ var ClientApplication = /*#__PURE__*/function () {
|
|
|
1602
2872
|
return this._authority;
|
|
1603
2873
|
}
|
|
1604
2874
|
|
|
1605
|
-
this._authority = AuthorityFactory.createInstance(this.config.auth.authority
|
|
2875
|
+
this._authority = AuthorityFactory.createInstance(this.config.auth.authority, this.config.system.networkClient, this.config.auth.protocolMode);
|
|
1606
2876
|
return this._authority;
|
|
1607
2877
|
}
|
|
1608
2878
|
}]);
|
|
@@ -1651,31 +2921,102 @@ var PublicClientApplication = /*#__PURE__*/function (_ClientApplication) {
|
|
|
1651
2921
|
|
|
1652
2922
|
var _proto = PublicClientApplication.prototype;
|
|
1653
2923
|
|
|
1654
|
-
_proto.acquireTokenByDeviceCode =
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
2924
|
+
_proto.acquireTokenByDeviceCode =
|
|
2925
|
+
/*#__PURE__*/
|
|
2926
|
+
function () {
|
|
2927
|
+
var _acquireTokenByDeviceCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(request) {
|
|
2928
|
+
var validRequest, serverTelemetryManager, deviceCodeConfig, deviceCodeClient;
|
|
2929
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
2930
|
+
while (1) {
|
|
2931
|
+
switch (_context.prev = _context.next) {
|
|
2932
|
+
case 0:
|
|
2933
|
+
this.logger.info("acquireTokenByDeviceCode called");
|
|
2934
|
+
validRequest = _extends({}, request, this.initializeBaseRequest(request));
|
|
2935
|
+
serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByDeviceCode, validRequest.correlationId);
|
|
2936
|
+
_context.prev = 3;
|
|
2937
|
+
_context.next = 6;
|
|
2938
|
+
return this.buildOauthClientConfiguration(validRequest.authority, serverTelemetryManager);
|
|
2939
|
+
|
|
2940
|
+
case 6:
|
|
2941
|
+
deviceCodeConfig = _context.sent;
|
|
2942
|
+
this.logger.verbose("Auth client config generated");
|
|
2943
|
+
deviceCodeClient = new DeviceCodeClient(deviceCodeConfig);
|
|
2944
|
+
return _context.abrupt("return", deviceCodeClient.acquireToken(validRequest));
|
|
2945
|
+
|
|
2946
|
+
case 12:
|
|
2947
|
+
_context.prev = 12;
|
|
2948
|
+
_context.t0 = _context["catch"](3);
|
|
2949
|
+
serverTelemetryManager.cacheFailedRequest(_context.t0);
|
|
2950
|
+
throw _context.t0;
|
|
2951
|
+
|
|
2952
|
+
case 16:
|
|
2953
|
+
case "end":
|
|
2954
|
+
return _context.stop();
|
|
2955
|
+
}
|
|
2956
|
+
}
|
|
2957
|
+
}, _callee, this, [[3, 12]]);
|
|
2958
|
+
}));
|
|
1659
2959
|
|
|
1660
|
-
|
|
2960
|
+
function acquireTokenByDeviceCode(_x) {
|
|
2961
|
+
return _acquireTokenByDeviceCode.apply(this, arguments);
|
|
2962
|
+
}
|
|
1661
2963
|
|
|
1662
|
-
|
|
2964
|
+
return acquireTokenByDeviceCode;
|
|
2965
|
+
}()
|
|
2966
|
+
/**
|
|
2967
|
+
* Acquires tokens with password grant by exchanging client applications username and password for credentials
|
|
2968
|
+
*
|
|
2969
|
+
* The latest OAuth 2.0 Security Best Current Practice disallows the password grant entirely.
|
|
2970
|
+
* More details on this recommendation at https://tools.ietf.org/html/draft-ietf-oauth-security-topics-13#section-3.4
|
|
2971
|
+
* Microsoft's documentation and recommendations are at:
|
|
2972
|
+
* https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows#usernamepassword
|
|
2973
|
+
*
|
|
2974
|
+
* @param request
|
|
2975
|
+
*/
|
|
2976
|
+
;
|
|
1663
2977
|
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
2978
|
+
_proto.acquireTokenByUsernamePassword =
|
|
2979
|
+
/*#__PURE__*/
|
|
2980
|
+
function () {
|
|
2981
|
+
var _acquireTokenByUsernamePassword = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(request) {
|
|
2982
|
+
var validRequest, serverTelemetryManager, usernamePasswordClientConfig, usernamePasswordClient;
|
|
2983
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2984
|
+
while (1) {
|
|
2985
|
+
switch (_context2.prev = _context2.next) {
|
|
2986
|
+
case 0:
|
|
2987
|
+
this.logger.info("acquireTokenByUsernamePassword called");
|
|
2988
|
+
validRequest = _extends({}, request, this.initializeBaseRequest(request));
|
|
2989
|
+
serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByUsernamePassword, validRequest.correlationId);
|
|
2990
|
+
_context2.prev = 3;
|
|
2991
|
+
_context2.next = 6;
|
|
2992
|
+
return this.buildOauthClientConfiguration(validRequest.authority, serverTelemetryManager);
|
|
2993
|
+
|
|
2994
|
+
case 6:
|
|
2995
|
+
usernamePasswordClientConfig = _context2.sent;
|
|
2996
|
+
this.logger.verbose("Auth client config generated");
|
|
2997
|
+
usernamePasswordClient = new UsernamePasswordClient(usernamePasswordClientConfig);
|
|
2998
|
+
return _context2.abrupt("return", usernamePasswordClient.acquireToken(validRequest));
|
|
2999
|
+
|
|
3000
|
+
case 12:
|
|
3001
|
+
_context2.prev = 12;
|
|
3002
|
+
_context2.t0 = _context2["catch"](3);
|
|
3003
|
+
serverTelemetryManager.cacheFailedRequest(_context2.t0);
|
|
3004
|
+
throw _context2.t0;
|
|
3005
|
+
|
|
3006
|
+
case 16:
|
|
3007
|
+
case "end":
|
|
3008
|
+
return _context2.stop();
|
|
3009
|
+
}
|
|
3010
|
+
}
|
|
3011
|
+
}, _callee2, this, [[3, 12]]);
|
|
3012
|
+
}));
|
|
1667
3013
|
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
});
|
|
1671
|
-
}, function (e) {
|
|
1672
|
-
serverTelemetryManager.cacheFailedRequest(e);
|
|
1673
|
-
throw e;
|
|
1674
|
-
}));
|
|
1675
|
-
} catch (e) {
|
|
1676
|
-
return Promise.reject(e);
|
|
3014
|
+
function acquireTokenByUsernamePassword(_x2) {
|
|
3015
|
+
return _acquireTokenByUsernamePassword.apply(this, arguments);
|
|
1677
3016
|
}
|
|
1678
|
-
|
|
3017
|
+
|
|
3018
|
+
return acquireTokenByUsernamePassword;
|
|
3019
|
+
}();
|
|
1679
3020
|
|
|
1680
3021
|
return PublicClientApplication;
|
|
1681
3022
|
}(ClientApplication);
|
|
@@ -1697,10 +3038,15 @@ var ClientAssertion = /*#__PURE__*/function () {
|
|
|
1697
3038
|
return clientAssertion;
|
|
1698
3039
|
};
|
|
1699
3040
|
|
|
1700
|
-
ClientAssertion.fromCertificate = function fromCertificate(thumbprint, privateKey) {
|
|
3041
|
+
ClientAssertion.fromCertificate = function fromCertificate(thumbprint, privateKey, publicCertificate) {
|
|
1701
3042
|
var clientAssertion = new ClientAssertion();
|
|
1702
3043
|
clientAssertion.privateKey = privateKey;
|
|
1703
3044
|
clientAssertion.thumbprint = thumbprint;
|
|
3045
|
+
|
|
3046
|
+
if (publicCertificate) {
|
|
3047
|
+
clientAssertion.publicCertificate = this.parseCertificate(publicCertificate);
|
|
3048
|
+
}
|
|
3049
|
+
|
|
1704
3050
|
return clientAssertion;
|
|
1705
3051
|
};
|
|
1706
3052
|
|
|
@@ -1708,8 +3054,8 @@ var ClientAssertion = /*#__PURE__*/function () {
|
|
|
1708
3054
|
|
|
1709
3055
|
_proto.getJwt = function getJwt(cryptoProvider, issuer, jwtAudience) {
|
|
1710
3056
|
// if assertion was created from certificate, check if jwt is expired and create new one.
|
|
1711
|
-
if (this.privateKey
|
|
1712
|
-
if (this.jwt
|
|
3057
|
+
if (this.privateKey && this.thumbprint) {
|
|
3058
|
+
if (this.jwt && !this.isExpired() && issuer === this.issuer && jwtAudience === this.jwtAudience) {
|
|
1713
3059
|
return this.jwt;
|
|
1714
3060
|
}
|
|
1715
3061
|
|
|
@@ -1721,7 +3067,7 @@ var ClientAssertion = /*#__PURE__*/function () {
|
|
|
1721
3067
|
*/
|
|
1722
3068
|
|
|
1723
3069
|
|
|
1724
|
-
if (this.jwt
|
|
3070
|
+
if (this.jwt) {
|
|
1725
3071
|
return this.jwt;
|
|
1726
3072
|
}
|
|
1727
3073
|
|
|
@@ -1737,6 +3083,13 @@ var ClientAssertion = /*#__PURE__*/function () {
|
|
|
1737
3083
|
var issuedAt = TimeUtils.nowSeconds();
|
|
1738
3084
|
this.expirationTime = issuedAt + 600;
|
|
1739
3085
|
var header = (_header = {}, _header[JwtConstants.ALGORITHM] = JwtConstants.RSA_256, _header[JwtConstants.X5T] = EncodingUtils.base64EncodeUrl(this.thumbprint, "hex"), _header);
|
|
3086
|
+
|
|
3087
|
+
if (this.publicCertificate) {
|
|
3088
|
+
var _Object$assign;
|
|
3089
|
+
|
|
3090
|
+
Object.assign(header, (_Object$assign = {}, _Object$assign[JwtConstants.X5C] = this.publicCertificate, _Object$assign));
|
|
3091
|
+
}
|
|
3092
|
+
|
|
1740
3093
|
var payload = (_payload = {}, _payload[JwtConstants.AUDIENCE] = this.jwtAudience, _payload[JwtConstants.EXPIRATION_TIME] = this.expirationTime, _payload[JwtConstants.ISSUER] = this.issuer, _payload[JwtConstants.SUBJECT] = this.issuer, _payload[JwtConstants.NOT_BEFORE] = issuedAt, _payload[JwtConstants.JWT_ID] = cryptoProvider.createNewGuid(), _payload);
|
|
1741
3094
|
this.jwt = sign(payload, this.privateKey, {
|
|
1742
3095
|
header: header
|
|
@@ -1746,6 +3099,31 @@ var ClientAssertion = /*#__PURE__*/function () {
|
|
|
1746
3099
|
|
|
1747
3100
|
_proto.isExpired = function isExpired() {
|
|
1748
3101
|
return this.expirationTime < TimeUtils.nowSeconds();
|
|
3102
|
+
}
|
|
3103
|
+
/**
|
|
3104
|
+
* Extracts the raw certs from a given certificate string and returns them in an array.
|
|
3105
|
+
* @param publicCertificate
|
|
3106
|
+
*/
|
|
3107
|
+
;
|
|
3108
|
+
|
|
3109
|
+
ClientAssertion.parseCertificate = function parseCertificate(publicCertificate) {
|
|
3110
|
+
/**
|
|
3111
|
+
* This is regex to identify the certs in a given certificate string.
|
|
3112
|
+
* We want to look for the contents between the BEGIN and END certificate strings, without the associated newlines.
|
|
3113
|
+
* The information in parens "(.+?)" is the capture group to represent the cert we want isolated.
|
|
3114
|
+
* "." means any string character, "+" means match 1 or more times, and "?" means the shortest match.
|
|
3115
|
+
* The "g" at the end of the regex means search the string globally, and the "m" means search across multiple lines.
|
|
3116
|
+
*/
|
|
3117
|
+
var regexToFindCerts = /-----BEGIN CERTIFICATE-----\n(.+?)\n-----END CERTIFICATE-----/gm;
|
|
3118
|
+
var certs = [];
|
|
3119
|
+
var matches;
|
|
3120
|
+
|
|
3121
|
+
while ((matches = regexToFindCerts.exec(publicCertificate)) !== null) {
|
|
3122
|
+
// matches[1] represents the first parens capture group in the regex.
|
|
3123
|
+
certs.push(matches[1]);
|
|
3124
|
+
}
|
|
3125
|
+
|
|
3126
|
+
return certs;
|
|
1749
3127
|
};
|
|
1750
3128
|
|
|
1751
3129
|
return ClientAssertion;
|
|
@@ -1790,31 +3168,48 @@ var ConfidentialClientApplication = /*#__PURE__*/function (_ClientApplication) {
|
|
|
1790
3168
|
|
|
1791
3169
|
var _proto = ConfidentialClientApplication.prototype;
|
|
1792
3170
|
|
|
1793
|
-
_proto.acquireTokenByClientCredential =
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
3171
|
+
_proto.acquireTokenByClientCredential =
|
|
3172
|
+
/*#__PURE__*/
|
|
3173
|
+
function () {
|
|
3174
|
+
var _acquireTokenByClientCredential = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(request) {
|
|
3175
|
+
var validRequest, serverTelemetryManager, clientCredentialConfig, clientCredentialClient;
|
|
3176
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
3177
|
+
while (1) {
|
|
3178
|
+
switch (_context.prev = _context.next) {
|
|
3179
|
+
case 0:
|
|
3180
|
+
this.logger.info("acquireTokenByClientCredential called");
|
|
3181
|
+
validRequest = _extends({}, request, this.initializeBaseRequest(request));
|
|
3182
|
+
serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByClientCredential, validRequest.correlationId, validRequest.skipCache);
|
|
3183
|
+
_context.prev = 3;
|
|
3184
|
+
_context.next = 6;
|
|
3185
|
+
return this.buildOauthClientConfiguration(validRequest.authority, serverTelemetryManager);
|
|
3186
|
+
|
|
3187
|
+
case 6:
|
|
3188
|
+
clientCredentialConfig = _context.sent;
|
|
3189
|
+
this.logger.verbose("Auth client config generated");
|
|
3190
|
+
clientCredentialClient = new ClientCredentialClient(clientCredentialConfig);
|
|
3191
|
+
return _context.abrupt("return", clientCredentialClient.acquireToken(validRequest));
|
|
3192
|
+
|
|
3193
|
+
case 12:
|
|
3194
|
+
_context.prev = 12;
|
|
3195
|
+
_context.t0 = _context["catch"](3);
|
|
3196
|
+
serverTelemetryManager.cacheFailedRequest(_context.t0);
|
|
3197
|
+
throw _context.t0;
|
|
3198
|
+
|
|
3199
|
+
case 16:
|
|
3200
|
+
case "end":
|
|
3201
|
+
return _context.stop();
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
}, _callee, this, [[3, 12]]);
|
|
3205
|
+
}));
|
|
1806
3206
|
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
});
|
|
1810
|
-
}, function (e) {
|
|
1811
|
-
serverTelemetryManager.cacheFailedRequest(e);
|
|
1812
|
-
throw e;
|
|
1813
|
-
}));
|
|
1814
|
-
} catch (e) {
|
|
1815
|
-
return Promise.reject(e);
|
|
3207
|
+
function acquireTokenByClientCredential(_x) {
|
|
3208
|
+
return _acquireTokenByClientCredential.apply(this, arguments);
|
|
1816
3209
|
}
|
|
1817
|
-
|
|
3210
|
+
|
|
3211
|
+
return acquireTokenByClientCredential;
|
|
3212
|
+
}()
|
|
1818
3213
|
/**
|
|
1819
3214
|
* Acquires tokens from the authority for the application.
|
|
1820
3215
|
*
|
|
@@ -1828,28 +3223,46 @@ var ConfidentialClientApplication = /*#__PURE__*/function (_ClientApplication) {
|
|
|
1828
3223
|
*/
|
|
1829
3224
|
;
|
|
1830
3225
|
|
|
1831
|
-
_proto.acquireTokenOnBehalfOf =
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
3226
|
+
_proto.acquireTokenOnBehalfOf =
|
|
3227
|
+
/*#__PURE__*/
|
|
3228
|
+
function () {
|
|
3229
|
+
var _acquireTokenOnBehalfOf = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(request) {
|
|
3230
|
+
var validRequest, clientCredentialConfig, oboClient;
|
|
3231
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
3232
|
+
while (1) {
|
|
3233
|
+
switch (_context2.prev = _context2.next) {
|
|
3234
|
+
case 0:
|
|
3235
|
+
this.logger.info("acquireTokenOnBehalfOf called");
|
|
3236
|
+
validRequest = _extends({}, request, this.initializeBaseRequest(request));
|
|
3237
|
+
_context2.next = 4;
|
|
3238
|
+
return this.buildOauthClientConfiguration(validRequest.authority);
|
|
3239
|
+
|
|
3240
|
+
case 4:
|
|
3241
|
+
clientCredentialConfig = _context2.sent;
|
|
3242
|
+
this.logger.verbose("Auth client config generated");
|
|
3243
|
+
oboClient = new OnBehalfOfClient(clientCredentialConfig);
|
|
3244
|
+
return _context2.abrupt("return", oboClient.acquireToken(validRequest));
|
|
3245
|
+
|
|
3246
|
+
case 8:
|
|
3247
|
+
case "end":
|
|
3248
|
+
return _context2.stop();
|
|
3249
|
+
}
|
|
3250
|
+
}
|
|
3251
|
+
}, _callee2, this);
|
|
3252
|
+
}));
|
|
1839
3253
|
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
});
|
|
1843
|
-
} catch (e) {
|
|
1844
|
-
return Promise.reject(e);
|
|
3254
|
+
function acquireTokenOnBehalfOf(_x2) {
|
|
3255
|
+
return _acquireTokenOnBehalfOf.apply(this, arguments);
|
|
1845
3256
|
}
|
|
1846
|
-
|
|
3257
|
+
|
|
3258
|
+
return acquireTokenOnBehalfOf;
|
|
3259
|
+
}();
|
|
1847
3260
|
|
|
1848
3261
|
_proto.setClientCredential = function setClientCredential(configuration) {
|
|
1849
3262
|
var clientSecretNotEmpty = !StringUtils.isEmpty(configuration.auth.clientSecret);
|
|
1850
3263
|
var clientAssertionNotEmpty = !StringUtils.isEmpty(configuration.auth.clientAssertion);
|
|
1851
3264
|
var certificate = configuration.auth.clientCertificate;
|
|
1852
|
-
var certificateNotEmpty = !StringUtils.isEmpty(certificate.thumbprint) || !StringUtils.isEmpty(certificate.privateKey); // Check that at most one credential is set on the application
|
|
3265
|
+
var certificateNotEmpty = !StringUtils.isEmpty(certificate.thumbprint) || !StringUtils.isEmpty(certificate.privateKey); // Check that at most one credential is set on the application
|
|
1853
3266
|
|
|
1854
3267
|
if (clientSecretNotEmpty && clientAssertionNotEmpty || clientAssertionNotEmpty && certificateNotEmpty || clientSecretNotEmpty && certificateNotEmpty) {
|
|
1855
3268
|
throw ClientAuthError.createInvalidCredentialError();
|
|
@@ -1868,12 +3281,14 @@ var ConfidentialClientApplication = /*#__PURE__*/function (_ClientApplication) {
|
|
|
1868
3281
|
if (!certificateNotEmpty) {
|
|
1869
3282
|
throw ClientAuthError.createInvalidCredentialError();
|
|
1870
3283
|
} else {
|
|
1871
|
-
|
|
3284
|
+
var _configuration$auth$c;
|
|
3285
|
+
|
|
3286
|
+
this.clientAssertion = ClientAssertion.fromCertificate(certificate.thumbprint, certificate.privateKey, (_configuration$auth$c = configuration.auth.clientCertificate) == null ? void 0 : _configuration$auth$c.x5c);
|
|
1872
3287
|
}
|
|
1873
3288
|
};
|
|
1874
3289
|
|
|
1875
3290
|
return ConfidentialClientApplication;
|
|
1876
3291
|
}(ClientApplication);
|
|
1877
3292
|
|
|
1878
|
-
export { ConfidentialClientApplication, CryptoProvider, PublicClientApplication, Storage, TokenCache, buildAppConfiguration };
|
|
3293
|
+
export { ConfidentialClientApplication, CryptoProvider, Deserializer, PublicClientApplication, Serializer, Storage, TokenCache, buildAppConfiguration };
|
|
1879
3294
|
//# sourceMappingURL=msal-node.esm.js.map
|