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