@scrypted/nvr 0.10.121 → 0.10.123

Sign up to get free protection for your applications and to get access to all the features.
package/dist/724 ADDED
@@ -0,0 +1,1734 @@
1
+ "use strict";
2
+ exports.id = 724;
3
+ exports.ids = [724];
4
+ exports.modules = {
5
+
6
+ /***/ 7529:
7
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
8
+
9
+
10
+ // EXPORTS
11
+ __webpack_require__.d(__webpack_exports__, {
12
+ BASIC: () => (/* reexport */ basic)
13
+ });
14
+
15
+ // UNUSED EXPORTS: BEARER, DIGEST, buildAuthorizationHeader, buildWWWAuthenticateHeader, mechanisms, parseAuthorizationHeader, parseWWWAuthenticateHeader
16
+
17
+ // EXTERNAL MODULE: ../../scrypted/common/node_modules/yerror/dist/index.js
18
+ var dist = __webpack_require__(9126);
19
+ // EXTERNAL MODULE: ../../scrypted/common/node_modules/http-auth-utils/dist/utils.js
20
+ var utils = __webpack_require__(1845);
21
+ ;// ../../scrypted/common/node_modules/http-auth-utils/dist/mechanisms/basic.js
22
+ /**
23
+ * @module http-auth-utils/mechanisms/basic
24
+ */
25
+
26
+
27
+ const REQUIRED_WWW_AUTHENTICATE_KEYS = ['realm'];
28
+ const AUTHORIZED_WWW_AUTHENTICATE_KEYS = REQUIRED_WWW_AUTHENTICATE_KEYS;
29
+ /* Architecture Note #1.2: Basic mechanism
30
+
31
+ See the following [RFC](https://tools.ietf.org/html/rfc7617).
32
+
33
+ */
34
+ /**
35
+ * Basic authentication mechanism.
36
+ * @type {Object}
37
+ * @see http://tools.ietf.org/html/rfc2617#section-2
38
+ */
39
+ const BASIC = {
40
+ /**
41
+ * The Basic auth mechanism prefix.
42
+ * @type {String}
43
+ */
44
+ type: 'Basic',
45
+ /**
46
+ * Parse the WWW Authenticate header rest.
47
+ * @param {String} rest The header rest (string after the authentication mechanism prefix).
48
+ * @return {Object} Object representing the result of the parse operation.
49
+ * @example
50
+ * assert.deepEqual(
51
+ * BASIC.parseWWWAuthenticateRest('realm="perlinpinpin"'), {
52
+ * realm: 'perlinpinpin'
53
+ * }
54
+ * );
55
+ * @api public
56
+ */
57
+ parseWWWAuthenticateRest: function parseWWWAuthenticateRest(rest) {
58
+ return (0,utils.parseHTTPHeadersQuotedKeyValueSet)(rest, AUTHORIZED_WWW_AUTHENTICATE_KEYS, REQUIRED_WWW_AUTHENTICATE_KEYS);
59
+ },
60
+ /**
61
+ * Build the WWW Authenticate header rest.
62
+ * @param {Object} data The content from wich to build the rest.
63
+ * @return {String} The built rest.
64
+ * @example
65
+ * assert.equal(
66
+ * BASIC.buildWWWAuthenticateRest({
67
+ * realm: 'perlinpinpin'
68
+ * }),
69
+ * 'realm="perlinpinpin"'
70
+ * );
71
+ * @api public
72
+ */
73
+ buildWWWAuthenticateRest: function buildWWWAuthenticateRest(data) {
74
+ return (0,utils/* buildHTTPHeadersQuotedKeyValueSet */.$)(data, AUTHORIZED_WWW_AUTHENTICATE_KEYS, REQUIRED_WWW_AUTHENTICATE_KEYS);
75
+ },
76
+ /**
77
+ * Parse the Authorization header rest.
78
+ * @param {String} rest The header rest (string after the authentication mechanism prefix).)
79
+ * @return {Object} Object representing the result of the parse operation {hash}.
80
+ * @example
81
+ * assert.deepEqual(
82
+ * BASIC.parseAuthorizationRest('QWxpIEJhYmE6b3BlbiBzZXNhbWU='), {
83
+ * hash: 'QWxpIEJhYmE6b3BlbiBzZXNhbWU=',
84
+ * username: 'Ali Baba',
85
+ * password: 'open sesame'
86
+ * }
87
+ * );
88
+ * @api public
89
+ */
90
+ parseAuthorizationRest: function parseAuthorizationRest(rest) {
91
+ if (!rest) {
92
+ throw new dist/* YError */.w('E_EMPTY_AUTH');
93
+ }
94
+ const { username, password } = BASIC.decodeHash(rest);
95
+ return {
96
+ hash: rest,
97
+ username,
98
+ password,
99
+ };
100
+ },
101
+ /**
102
+ * Build the Authorization header rest.
103
+ * @param {Object} content The content from wich to build the rest.
104
+ * @return {String} The rest built.
105
+ * @example
106
+ * assert.equal(
107
+ * BASIC.buildAuthorizationRest({
108
+ * hash: 'QWxpIEJhYmE6b3BlbiBzZXNhbWU='
109
+ * }),
110
+ * 'QWxpIEJhYmE6b3BlbiBzZXNhbWU='
111
+ * );
112
+ * @api public
113
+ */
114
+ buildAuthorizationRest: function buildAuthorizationRest({ hash, username, password, }) {
115
+ if (username && password) {
116
+ return BASIC.computeHash({
117
+ username,
118
+ password,
119
+ });
120
+ }
121
+ if (!hash) {
122
+ throw new dist/* YError */.w('E_NO_HASH');
123
+ }
124
+ return hash;
125
+ },
126
+ /**
127
+ * Compute the Basic authentication hash from the given credentials.
128
+ * @param {Object} credentials The credentials to encode {username, password}.
129
+ * @return {String} The hash representing the credentials.
130
+ * @example
131
+ * assert.equal(
132
+ * BASIC.computeHash({
133
+ * username: 'Ali Baba',
134
+ * password: 'open sesame'
135
+ * }),
136
+ * 'QWxpIEJhYmE6b3BlbiBzZXNhbWU='
137
+ * );
138
+ * @api public
139
+ */
140
+ computeHash: function computeHash({ username, password, }) {
141
+ return Buffer.from(username + ':' + password).toString('base64');
142
+ },
143
+ /**
144
+ * Decode the Basic hash and return the corresponding credentials.
145
+ * @param {String} hash The hash.
146
+ * @return {Object} Object representing the credentials {username, password}.
147
+ * @example
148
+ * assert.deepEqual(
149
+ * BASIC.decodeHash('QWxpIEJhYmE6b3BlbiBzZXNhbWU='), {
150
+ * username: 'Ali Baba',
151
+ * password: 'open sesame'
152
+ * }
153
+ * );
154
+ * @api public
155
+ */
156
+ decodeHash: function decodeHash(hash) {
157
+ const [username, ...passwordParts] = Buffer.from(hash, 'base64')
158
+ .toString()
159
+ .split(':');
160
+ return {
161
+ username,
162
+ password: passwordParts.join(':'),
163
+ };
164
+ },
165
+ };
166
+ /* harmony default export */ const basic = (BASIC);
167
+ //# sourceMappingURL=basic.js.map
168
+ // EXTERNAL MODULE: external "crypto"
169
+ var external_crypto_ = __webpack_require__(6982);
170
+ ;// ../../scrypted/common/node_modules/http-auth-utils/dist/mechanisms/digest.js
171
+ /**
172
+ * @module http-auth-utils/mechanisms/digest
173
+ */
174
+
175
+
176
+ const digest_REQUIRED_WWW_AUTHENTICATE_KEYS = ['realm', 'nonce'];
177
+ const digest_AUTHORIZED_WWW_AUTHENTICATE_KEYS = [
178
+ ...digest_REQUIRED_WWW_AUTHENTICATE_KEYS,
179
+ 'domain',
180
+ 'opaque',
181
+ 'stale',
182
+ 'algorithm',
183
+ 'qop',
184
+ ];
185
+ const CASE_INSENSITIVE_WWW_AUTHENTICATE_VALUES = ['stale'];
186
+ const REQUIRED_AUTHORIZATION_KEYS = [
187
+ 'username',
188
+ 'realm',
189
+ 'nonce',
190
+ 'uri',
191
+ 'response',
192
+ ];
193
+ const AUTHORIZED_AUTHORIZATION_KEYS = [
194
+ ...REQUIRED_AUTHORIZATION_KEYS,
195
+ 'algorithm',
196
+ 'cnonce',
197
+ 'opaque',
198
+ 'qop',
199
+ 'nc',
200
+ ];
201
+ /* Architecture Note #1.3: Digest mechanism
202
+
203
+ See the following [RFC](https://tools.ietf.org/html/rfc2617).
204
+
205
+ */
206
+ /**
207
+ * Digest authentication mechanism.
208
+ * @type {Object}
209
+ * @see http://tools.ietf.org/html/rfc2617#section-3
210
+ * @see http://tools.ietf.org/html/rfc2069#section-2
211
+ */
212
+ const DIGEST = {
213
+ /**
214
+ * The Digest auth mechanism prefix.
215
+ * @type {String}
216
+ */
217
+ type: 'Digest',
218
+ /**
219
+ * Parse the WWW Authenticate header rest.
220
+ * @param {String} rest The header rest (string after the authentication mechanism prefix).
221
+ * @return {Object} Object representing the result of the parse operation.
222
+ * @example
223
+ * assert.deepEqual(
224
+ * DIGEST.parseWWWAuthenticateRest(
225
+ * 'realm="testrealm@host.com", ' +
226
+ * 'qop="auth, auth-int", ' +
227
+ * 'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' +
228
+ * 'opaque="5ccc069c403ebaf9f0171e9517f40e41"'
229
+ * ), {
230
+ * realm: 'testrealm@host.com',
231
+ * qop: 'auth, auth-int',
232
+ * nonce: 'dcd98b7102dd2f0e8b11d0f600bfb0c093',
233
+ * opaque: '5ccc069c403ebaf9f0171e9517f40e41'
234
+ * }
235
+ * );
236
+ * @api public
237
+ */
238
+ parseWWWAuthenticateRest: function parseWWWAuthenticateRest(rest) {
239
+ return (0,utils.parseHTTPHeadersQuotedKeyValueSet)(rest, digest_AUTHORIZED_WWW_AUTHENTICATE_KEYS, digest_REQUIRED_WWW_AUTHENTICATE_KEYS, CASE_INSENSITIVE_WWW_AUTHENTICATE_VALUES);
240
+ },
241
+ /**
242
+ * Build the WWW Authenticate header rest.
243
+ * @param {Object} data The content from which to build the rest.
244
+ * @return {String} The built rest.
245
+ * @example
246
+ * assert.equal(
247
+ * DIGEST.buildWWWAuthenticateRest({
248
+ * realm: 'testrealm@host.com',
249
+ * qop: 'auth, auth-int',
250
+ * nonce: 'dcd98b7102dd2f0e8b11d0f600bfb0c093',
251
+ * opaque: '5ccc069c403ebaf9f0171e9517f40e41'
252
+ * }),
253
+ * 'realm="testrealm@host.com", ' +
254
+ * 'qop="auth, auth-int", ' +
255
+ * 'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' +
256
+ * 'opaque="5ccc069c403ebaf9f0171e9517f40e41"'
257
+ * );
258
+ * @api public
259
+ */
260
+ buildWWWAuthenticateRest: function buildWWWAuthenticateRest(data) {
261
+ return (0,utils/* buildHTTPHeadersQuotedKeyValueSet */.$)(data, digest_AUTHORIZED_WWW_AUTHENTICATE_KEYS, digest_REQUIRED_WWW_AUTHENTICATE_KEYS);
262
+ },
263
+ /**
264
+ * Parse the Authorization header rest.
265
+ * @param {String} rest The header rest (string after the authentication mechanism prefix).)
266
+ * @return {Object} Object representing the result of the parse operation {hash}.
267
+ * @example
268
+ * assert.deepEqual(
269
+ * DIGEST.parseAuthorizationRest(
270
+ * 'username="Mufasa",' +
271
+ * 'realm="testrealm@host.com",' +
272
+ * 'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",' +
273
+ * 'uri="/dir/index.html",' +
274
+ * 'qop="auth",' +
275
+ * 'nc="00000001",' +
276
+ * 'cnonce="0a4f113b",' +
277
+ * 'response="6629fae49393a05397450978507c4ef1",' +
278
+ * 'opaque="5ccc069c403ebaf9f0171e9517f40e41"'
279
+ * ), {
280
+ * username: "Mufasa",
281
+ * realm: 'testrealm@host.com',
282
+ * nonce: "dcd98b7102dd2f0e8b11d0f600bfb0c093",
283
+ * uri: "/dir/index.html",
284
+ * qop: 'auth',
285
+ * nc: '00000001',
286
+ * cnonce: "0a4f113b",
287
+ * response: "6629fae49393a05397450978507c4ef1",
288
+ * opaque: "5ccc069c403ebaf9f0171e9517f40e41"
289
+ * }
290
+ * );
291
+ * @api public
292
+ */
293
+ parseAuthorizationRest: function parseAuthorizationRest(rest) {
294
+ return (0,utils.parseHTTPHeadersQuotedKeyValueSet)(rest, AUTHORIZED_AUTHORIZATION_KEYS, REQUIRED_AUTHORIZATION_KEYS);
295
+ },
296
+ /**
297
+ * Build the Authorization header rest.
298
+ * @param {Object} data The content from which to build the rest.
299
+ * @return {String} The rest built.
300
+ * @example
301
+ * assert.equal(
302
+ * DIGEST.buildAuthorizationRest({
303
+ * username: "Mufasa",
304
+ * realm: 'testrealm@host.com',
305
+ * nonce: "dcd98b7102dd2f0e8b11d0f600bfb0c093",
306
+ * uri: "/dir/index.html",
307
+ * qop: 'auth',
308
+ * nc: '00000001',
309
+ * cnonce: "0a4f113b",
310
+ * response: "6629fae49393a05397450978507c4ef1",
311
+ * opaque: "5ccc069c403ebaf9f0171e9517f40e41"
312
+ * }),
313
+ * 'username="Mufasa", ' +
314
+ * 'realm="testrealm@host.com", ' +
315
+ * 'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' +
316
+ * 'uri="/dir/index.html", ' +
317
+ * 'response="6629fae49393a05397450978507c4ef1", ' +
318
+ * 'cnonce="0a4f113b", ' +
319
+ * 'opaque="5ccc069c403ebaf9f0171e9517f40e41", ' +
320
+ * 'qop="auth", ' +
321
+ * 'nc="00000001"'
322
+ * );
323
+ * @api public
324
+ */
325
+ buildAuthorizationRest: function buildAuthorizationRest(data) {
326
+ return (0,utils/* buildHTTPHeadersQuotedKeyValueSet */.$)(data, AUTHORIZED_AUTHORIZATION_KEYS, REQUIRED_AUTHORIZATION_KEYS);
327
+ },
328
+ /**
329
+ * Compute the Digest authentication hash from the given credentials.
330
+ * @param {Object} data The credentials to encode and other encoding details.
331
+ * @return {String} The hash representing the credentials.
332
+ * @example
333
+ * assert.equal(
334
+ * DIGEST.computeHash({
335
+ * username: 'Mufasa',
336
+ * realm: 'testrealm@host.com',
337
+ * password: 'Circle Of Life',
338
+ * method: 'GET',
339
+ * uri: '/dir/index.html',
340
+ * nonce: 'dcd98b7102dd2f0e8b11d0f600bfb0c093',
341
+ * nc: '00000001',
342
+ * cnonce: '0a4f113b',
343
+ * qop: 'auth',
344
+ * algorithm: 'md5'
345
+ * }),
346
+ * '6629fae49393a05397450978507c4ef1'
347
+ * );
348
+ * @api public
349
+ */
350
+ computeHash: function computeHash(data) {
351
+ const ha1 = data.ha1 ||
352
+ _computeHash(data.algorithm, [data.username, data.realm, data.password].join(':'));
353
+ const ha2 = _computeHash(data.algorithm, [data.method, data.uri].join(':'));
354
+ return _computeHash(data.algorithm, [ha1, data.nonce, data.nc, data.cnonce, data.qop, ha2].join(':'));
355
+ },
356
+ };
357
+ function _computeHash(algorithm, str) {
358
+ const hashsum = external_crypto_.createHash(algorithm);
359
+ hashsum.update(str);
360
+ return hashsum.digest('hex');
361
+ }
362
+ /* harmony default export */ const digest = (DIGEST);
363
+ //# sourceMappingURL=digest.js.map
364
+ ;// ../../scrypted/common/node_modules/http-auth-utils/dist/mechanisms/bearer.js
365
+ /**
366
+ * @module http-auth-utils/mechanisms/bearer
367
+ */
368
+
369
+
370
+ const AUTHORIZED_ERROR_CODES = [
371
+ 'invalid_request',
372
+ 'invalid_token',
373
+ 'insufficient_scope',
374
+ ];
375
+ const bearer_REQUIRED_WWW_AUTHENTICATE_KEYS = ['realm'];
376
+ const bearer_AUTHORIZED_WWW_AUTHENTICATE_KEYS = [
377
+ ...bearer_REQUIRED_WWW_AUTHENTICATE_KEYS,
378
+ 'scope',
379
+ 'error',
380
+ 'error_description',
381
+ ];
382
+ /* Architecture Note #1.1: Bearer mechanism
383
+
384
+ See the following [RFC](https://tools.ietf.org/html/rfc6750).
385
+
386
+ */
387
+ /**
388
+ * Bearer authentication mechanism.
389
+ * @type {Object}
390
+ * @see https://tools.ietf.org/html/rfc6750#section-3
391
+ */
392
+ const BEARER = {
393
+ /**
394
+ * The Bearer auth mechanism prefix.
395
+ * @type {String}
396
+ */
397
+ type: 'Bearer',
398
+ /**
399
+ * Parse the WWW Authenticate header rest.
400
+ * @param {String} rest The header rest (string after the authentication mechanism prefix).
401
+ * @return {Object} Object representing the result of the parse operation.
402
+ * @example
403
+ * assert.deepEqual(
404
+ * BEARER.parseWWWAuthenticateRest(
405
+ * 'realm="testrealm@host.com", ' +
406
+ * 'scope="openid profile email"'
407
+ * ), {
408
+ * realm: 'testrealm@host.com',
409
+ * scope: 'openid profile email',
410
+ * }
411
+ * );
412
+ * @api public
413
+ */
414
+ parseWWWAuthenticateRest: function parseWWWAuthenticateRest(rest) {
415
+ return (0,utils.parseHTTPHeadersQuotedKeyValueSet)(rest, bearer_AUTHORIZED_WWW_AUTHENTICATE_KEYS, []);
416
+ },
417
+ /**
418
+ * Build the WWW Authenticate header rest.
419
+ * @param {Object} data The content from wich to build the rest.
420
+ * @return {String} The built rest.
421
+ * @example
422
+ * assert.equal(
423
+ * BEARER.buildWWWAuthenticateRest({
424
+ * realm: 'testrealm@host.com',
425
+ * error: 'invalid_request',
426
+ * error_description: 'The access token expired',
427
+ * }),
428
+ * 'realm="testrealm@host.com", ' +
429
+ * 'error="invalid_request", ' +
430
+ * 'error_description="The access token expired"'
431
+ * );
432
+ * @api public
433
+ */
434
+ buildWWWAuthenticateRest: function buildWWWAuthenticateRest(data) {
435
+ if (data.error &&
436
+ -1 ===
437
+ AUTHORIZED_ERROR_CODES.indexOf(data.error)) {
438
+ throw new dist/* YError */.w('E_INVALID_ERROR', data.error, AUTHORIZED_ERROR_CODES);
439
+ }
440
+ return (0,utils/* buildHTTPHeadersQuotedKeyValueSet */.$)(data, bearer_AUTHORIZED_WWW_AUTHENTICATE_KEYS, []);
441
+ },
442
+ /**
443
+ * Parse the Authorization header rest.
444
+ * @param {String} rest The header rest (string after the authentication mechanism prefix).)
445
+ * @return {Object} Object representing the result of the parse operation {hash}.
446
+ * @example
447
+ * assert.deepEqual(
448
+ * BEARER.parseAuthorizationRest('mF_9.B5f-4.1JqM'), {
449
+ * hash: 'mF_9.B5f-4.1JqM',
450
+ * }
451
+ * );
452
+ * @api public
453
+ */
454
+ parseAuthorizationRest: function parseAuthorizationRest(rest) {
455
+ if (!rest) {
456
+ throw new dist/* YError */.w('E_EMPTY_AUTH');
457
+ }
458
+ return {
459
+ hash: rest,
460
+ };
461
+ },
462
+ /**
463
+ * Build the Authorization header rest.
464
+ * @param {Object} content The content from wich to build the rest.
465
+ * @return {String} The rest built.
466
+ * @example
467
+ * assert.equal(
468
+ * BEARER.buildAuthorizationRest({
469
+ * hash: 'mF_9.B5f-4.1JqM'
470
+ * }),
471
+ * 'mF_9.B5f-4.1JqM=='
472
+ * );
473
+ * @api public
474
+ */
475
+ buildAuthorizationRest: function buildAuthorizationRest({ hash, }) {
476
+ if (!hash) {
477
+ throw new dist/* YError */.w('E_NO_HASH');
478
+ }
479
+ return hash;
480
+ },
481
+ };
482
+ /* harmony default export */ const bearer = (BEARER);
483
+ //# sourceMappingURL=bearer.js.map
484
+ ;// ../../scrypted/common/node_modules/http-auth-utils/dist/index.js
485
+
486
+
487
+
488
+
489
+ /**
490
+ * @module http-auth-utils
491
+ */
492
+ /**
493
+ * Natively supported authentication mechanisms.
494
+ * @type {Array}
495
+ */
496
+ const mechanisms = [basic, digest, bearer];
497
+ /**
498
+ * Basic authentication mechanism.
499
+ * @type {Object}
500
+ * @see {@link module:http-auth-utils/mechanisms/basic}
501
+ */
502
+ basic;
503
+ /**
504
+ * Digest authentication mechanism.
505
+ * @type {Object}
506
+ * @see {@link module:http-auth-utils/mechanisms/digest}
507
+ */
508
+ digest;
509
+ /**
510
+ * Bearer authentication mechanism.
511
+ * @type {Object}
512
+ * @see {@link module:http-auth-utils/mechanisms/digest}
513
+ */
514
+ bearer;
515
+
516
+ /**
517
+ * Parse HTTP WWW-Authenticate header contents.
518
+ * @type {Function}
519
+ * @param {string} header
520
+ * The WWW-Authenticate header contents
521
+ * @param {Array} [authMechanisms=[BASIC, DIGEST, BEARER]]
522
+ * Allow providing custom authentication mechanisms.
523
+ * @param {Object} [options]
524
+ * Parsing options
525
+ * @param {boolean} [options.strict=true]
526
+ * Strictly detect the mechanism type (case sensitive)
527
+ * @return {Object} Result of the contents parse.
528
+ * @api public
529
+ * @example
530
+ * assert.deepEqual(
531
+ * parseWWWAuthenticateHeader('Basic realm="test"'), {
532
+ * type: 'Basic',
533
+ * data: {
534
+ * realm: 'test'
535
+ * }
536
+ * }
537
+ * );
538
+ */
539
+ function parseWWWAuthenticateHeader(header, authMechanisms = mechanisms, { strict = true } = { strict: true }) {
540
+ let result = null;
541
+ authMechanisms.some((authMechanism) => {
542
+ if (0 === header.indexOf(authMechanism.type + ' ') ||
543
+ (!strict && 0 === header.indexOf(authMechanism.type.toLowerCase() + ' '))) {
544
+ result = {
545
+ type: authMechanism.type,
546
+ data: authMechanism.parseWWWAuthenticateRest(header.substr(authMechanism.type.length + 1)),
547
+ };
548
+ return true;
549
+ }
550
+ return false;
551
+ });
552
+ if (!result) {
553
+ throw new YError('E_UNKNOWN_AUTH_MECHANISM', header);
554
+ }
555
+ return result;
556
+ }
557
+ /**
558
+ * Parse HTTP Authorization header contents.
559
+ * @type {Function}
560
+ * @param {string} header The Authorization header contents
561
+ * @param {Array} [authMechanisms=[BASIC, DIGEST, BEARER]]
562
+ * Allow custom authentication mechanisms.
563
+ * @param {Object} [options]
564
+ * Parsing options
565
+ * @param {boolean} [options.strict=true]
566
+ * Strictly detect the mechanism type (case sensitive)
567
+ * @return {Object} Result of the contents parse.
568
+ * @api public
569
+ * @example
570
+ * assert.deepEqual(
571
+ * parseAuthorizationHeader('Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='), {
572
+ * type: 'Basic',
573
+ * data: {
574
+ * hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
575
+ * }
576
+ * }
577
+ * );
578
+ */
579
+ function parseAuthorizationHeader(header, authMechanisms = mechanisms, { strict = true } = { strict: true }) {
580
+ let result = null;
581
+ authMechanisms.some(function (authMechanism) {
582
+ if (0 === header.indexOf(authMechanism.type + ' ') ||
583
+ (!strict && 0 === header.indexOf(authMechanism.type.toLowerCase() + ' '))) {
584
+ result = {
585
+ type: authMechanism.type,
586
+ data: authMechanism.parseAuthorizationRest(header.substr(authMechanism.type.length + 1)),
587
+ };
588
+ return true;
589
+ }
590
+ return false;
591
+ });
592
+ if (result) {
593
+ return result;
594
+ }
595
+ throw new YError('E_UNKNOWN_AUTH_MECHANISM', header);
596
+ }
597
+ /**
598
+ * Build HTTP WWW-Authenticate header value.
599
+ * @type {Function}
600
+ * @param {Object} authMechanism The mechanism to use
601
+ * @param {Object}
602
+ * The WWW-Authenticate header contents to base the value on.
603
+ * @return {string} The header value.
604
+ * @api public
605
+ * @example
606
+ * assert.deepEqual(
607
+ * buildWWWAuthenticateHeader(BASIC, {
608
+ * realm: 'test'
609
+ * }),
610
+ * 'Basic realm="test"'
611
+ * );
612
+ */
613
+ function buildWWWAuthenticateHeader(authMechanism, data) {
614
+ return `${authMechanism.type} ${authMechanism.buildWWWAuthenticateRest(data)}`;
615
+ }
616
+ /**
617
+ * Build HTTP Authorization header value.
618
+ * @type {Function}
619
+ * @param {Object} authMechanism The mechanism to use
620
+ * @param {Object}
621
+ * The Authorization header contents to base the value on.
622
+ * @return {string} The header value.
623
+ * @api public
624
+ * @example
625
+ * assert.deepEqual(
626
+ * buildAuthorizationHeader(BASIC, {
627
+ * realm: 'test'
628
+ * }),
629
+ * 'Basic realm="test"'
630
+ * );
631
+ */
632
+ function buildAuthorizationHeader(authMechanism, data) {
633
+ return `${authMechanism.type} ${authMechanism.buildAuthorizationRest(data)}`;
634
+ }
635
+ //# sourceMappingURL=index.js.map
636
+
637
+ /***/ }),
638
+
639
+ /***/ 1845:
640
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
641
+
642
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
643
+ /* harmony export */ $: () => (/* binding */ buildHTTPHeadersQuotedKeyValueSet),
644
+ /* harmony export */ parseHTTPHeadersQuotedKeyValueSet: () => (/* binding */ parseHTTPHeadersQuotedKeyValueSet)
645
+ /* harmony export */ });
646
+ /* harmony import */ var yerror__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9126);
647
+
648
+ const QUOTE = '"';
649
+ const EQUAL = '=';
650
+ const SEPARATOR = ', ';
651
+ /*
652
+ * Regular expression for matching the key-value pairs
653
+ * \w+ = The key
654
+ * = = The equal sign
655
+ * ".*?" = Value option 1: A double-quoted value (using the non-greedy *? to stop at the first doublequote)
656
+ * [^",]+ = Value option 2: A string without commas or double-quotes
657
+ * (?=,|$) = Zero-width (as in not captured) positive lookahead assertion.
658
+ * The previous match will only be valid if it's followed by a " literal
659
+ * or the end of the string
660
+ */
661
+ const KEYVALUE_REGEXP = /\w+=(".*?"|[^",]+)(?=,|$)/g;
662
+ // FIXME: Create a real parser
663
+ function parseHTTPHeadersQuotedKeyValueSet(contents, authorizedKeys, requiredKeys = [], valuesToNormalize = []) {
664
+ const matches = contents.trim().match(KEYVALUE_REGEXP);
665
+ if (!matches)
666
+ throw new yerror__WEBPACK_IMPORTED_MODULE_0__/* .YError */ .w('E_MALFORMED_QUOTEDKEYVALUE', contents);
667
+ const data = matches
668
+ .map((part, partPosition) => {
669
+ const [key, ...rest] = part.split(EQUAL);
670
+ const value = rest.join(EQUAL);
671
+ if (0 === rest.length) {
672
+ throw new yerror__WEBPACK_IMPORTED_MODULE_0__/* .YError */ .w('E_MALFORMED_QUOTEDKEYVALUE', partPosition, part);
673
+ }
674
+ return [key, value];
675
+ })
676
+ .reduce(function (parsedValues, [name, value], valuePosition) {
677
+ const normalizedName = name.toLowerCase();
678
+ if (-1 === authorizedKeys.indexOf(normalizedName)) {
679
+ throw new yerror__WEBPACK_IMPORTED_MODULE_0__/* .YError */ .w('E_UNAUTHORIZED_KEY', valuePosition, normalizedName);
680
+ }
681
+ /*
682
+ * Regular expression for stripping paired starting and ending double quotes off the value:
683
+ * ^ = The beginning of the string
684
+ * " = The first double quote
685
+ * .+ = One or more characters of any kind
686
+ * (?="$) = Zero-width (as in not captured) positive lookahead assertion.
687
+ * The previous match will only be valid if it's followed by a " literal
688
+ * or the end of the string
689
+ * " = The ending double quote
690
+ * $ = The end of the string
691
+ */
692
+ const strippedValue = value.replace(/^"(.+(?="$))"$/, '$1');
693
+ parsedValues[normalizedName] = valuesToNormalize.includes(normalizedName)
694
+ ? strippedValue.toLowerCase()
695
+ : strippedValue;
696
+ return parsedValues;
697
+ }, {});
698
+ _checkRequiredKeys(requiredKeys, data);
699
+ return data;
700
+ }
701
+ function buildHTTPHeadersQuotedKeyValueSet(data, authorizedKeys, requiredKeys = []) {
702
+ _checkRequiredKeys(requiredKeys, data);
703
+ return authorizedKeys.reduce(function (contents, key) {
704
+ if (data[key]) {
705
+ return (contents +
706
+ (contents ? SEPARATOR : '') +
707
+ key +
708
+ EQUAL +
709
+ QUOTE +
710
+ data[key] +
711
+ QUOTE);
712
+ }
713
+ return contents;
714
+ }, '');
715
+ }
716
+ function _checkRequiredKeys(requiredKeys, data) {
717
+ requiredKeys.forEach((name) => {
718
+ if ('undefined' === typeof data[name]) {
719
+ throw new yerror__WEBPACK_IMPORTED_MODULE_0__/* .YError */ .w('E_REQUIRED_KEY', name);
720
+ }
721
+ });
722
+ }
723
+ //# sourceMappingURL=utils.js.map
724
+
725
+ /***/ }),
726
+
727
+ /***/ 9126:
728
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
729
+
730
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
731
+ /* harmony export */ w: () => (/* binding */ YError)
732
+ /* harmony export */ });
733
+ /* unused harmony export printStackTrace */
734
+ /* harmony import */ var os__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(857);
735
+
736
+ /**
737
+ * A YError class able to contain some params and
738
+ * print better stack traces
739
+ * @extends Error
740
+ */
741
+ class YError extends Error {
742
+ code;
743
+ params;
744
+ wrappedErrors;
745
+ constructor(wrappedErrors, errorCode, ...params) {
746
+ // Detecting if wrappedErrors are passed
747
+ if (!(wrappedErrors instanceof Array)) {
748
+ params = ('undefined' === typeof errorCode ? [] : [errorCode]).concat(params);
749
+ errorCode = wrappedErrors;
750
+ wrappedErrors = [];
751
+ }
752
+ // Call the parent constructor
753
+ super(errorCode);
754
+ // Filling error
755
+ this.code = errorCode || 'E_UNEXPECTED';
756
+ this.params = params;
757
+ this.wrappedErrors = wrappedErrors;
758
+ this.name = this.toString();
759
+ if (Error.captureStackTrace) {
760
+ Error.captureStackTrace(this, this.constructor);
761
+ }
762
+ }
763
+ /**
764
+ * Wraps any error and output a YError with an error
765
+ * code and some params as debug values.
766
+ * @param {Error} err
767
+ * The error to wrap
768
+ * @param {string} [errorCode = 'E_UNEXPECTED']
769
+ * The error code corresponding to the actual error
770
+ * @param {...YErrorParams} [params]
771
+ * Some additional debugging values
772
+ * @return {YError}
773
+ * The wrapped error
774
+ */
775
+ static wrap(err, errorCode, ...params) {
776
+ const wrappedErrorIsACode = _looksLikeAYErrorCode(err.message);
777
+ const wrappedErrors = ('wrappedErrors' in err ? err.wrappedErrors : []).concat(err);
778
+ if (!errorCode) {
779
+ if (wrappedErrorIsACode) {
780
+ errorCode = err.message;
781
+ }
782
+ else {
783
+ errorCode = 'E_UNEXPECTED';
784
+ }
785
+ }
786
+ if (err.message && !wrappedErrorIsACode) {
787
+ params.push(err.message);
788
+ }
789
+ return new YError(wrappedErrors, errorCode, ...params);
790
+ }
791
+ /**
792
+ * Return a YError as is or wraps any other error and output
793
+ * a YError with a code and some params as debug values.
794
+ * @param {Error} err
795
+ * The error to cast
796
+ * @param {string} [errorCode = 'E_UNEXPECTED']
797
+ * The error code corresponding to the actual error
798
+ * @param {...YErrorParams} [params]
799
+ * Some additional debugging values
800
+ * @return {YError}
801
+ * The wrapped error
802
+ */
803
+ static cast(err, errorCode, ...params) {
804
+ if (_looksLikeAYError(err)) {
805
+ return err;
806
+ }
807
+ return YError.wrap(err, errorCode, ...params);
808
+ }
809
+ /**
810
+ * Same than `YError.wrap()` but preserves the code
811
+ * and the debug values of the error if it is
812
+ * already an instance of the YError constructor.
813
+ * @param {Error} err
814
+ * The error to bump
815
+ * @param {string} [errorCode = 'E_UNEXPECTED']
816
+ * The error code corresponding to the actual error
817
+ * @param {...YErrorParams} [params]
818
+ * Some additional debugging values
819
+ * @return {YError}
820
+ * The wrapped error
821
+ */
822
+ static bump(err, errorCode, ...params) {
823
+ if (_looksLikeAYError(err)) {
824
+ return YError.wrap(err, err.code, ...err.params);
825
+ }
826
+ return YError.wrap(err, errorCode, ...params);
827
+ }
828
+ toString() {
829
+ return ((this.wrappedErrors.length
830
+ ? // eslint-disable-next-line
831
+ this.wrappedErrors[this.wrappedErrors.length - 1].stack + os__WEBPACK_IMPORTED_MODULE_0__.EOL
832
+ : '') +
833
+ this.constructor.name +
834
+ ': ' +
835
+ this.code +
836
+ ' (' +
837
+ this.params.join(', ') +
838
+ ')');
839
+ }
840
+ }
841
+ /**
842
+ * Allow to print a stack from anything (especially catched
843
+ * errors that may or may not contain errors 🤷).
844
+ * @param {Error} err
845
+ * The error to print
846
+ * @return {string}
847
+ * The stack trace if any
848
+ */
849
+ function printStackTrace(err) {
850
+ return typeof err === 'object' && typeof err.stack === 'string'
851
+ ? err.stack
852
+ : `[no_stack_trace]: error is ${err != null && typeof err.toString === 'function'
853
+ ? err.toString()
854
+ : typeof err}`;
855
+ }
856
+ // In order to keep compatibility through major versions
857
+ // we have to make kind of an cross major version instanceof
858
+ function _looksLikeAYError(err) {
859
+ return (!!(err instanceof YError) ||
860
+ !!(err.constructor &&
861
+ err.constructor.name &&
862
+ err.constructor.name.endsWith('Error') &&
863
+ 'code' in err &&
864
+ 'string' === typeof err.code &&
865
+ _looksLikeAYErrorCode(err.code) &&
866
+ 'params' in err &&
867
+ err.params &&
868
+ err.params instanceof Array));
869
+ }
870
+ function _looksLikeAYErrorCode(str) {
871
+ return /^([A-Z0-9_]+)$/.test(str);
872
+ }
873
+
874
+ //# sourceMappingURL=index.js.map
875
+
876
+ /***/ }),
877
+
878
+ /***/ 8188:
879
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
880
+
881
+
882
+ // EXPORTS
883
+ __webpack_require__.d(__webpack_exports__, {
884
+ BASIC: () => (/* reexport */ basic),
885
+ DIGEST: () => (/* reexport */ digest),
886
+ buildAuthorizationHeader: () => (/* binding */ buildAuthorizationHeader),
887
+ parseWWWAuthenticateHeader: () => (/* binding */ parseWWWAuthenticateHeader)
888
+ });
889
+
890
+ // UNUSED EXPORTS: BEARER, buildWWWAuthenticateHeader, mechanisms, parseAuthorizationHeader
891
+
892
+ // EXTERNAL MODULE: external "os"
893
+ var external_os_ = __webpack_require__(857);
894
+ ;// ../../scrypted/packages/auth-fetch/node_modules/yerror/dist/index.js
895
+
896
+ /**
897
+ * A YError class able to contain some params and
898
+ * print better stack traces
899
+ * @extends Error
900
+ */
901
+ class dist_YError extends Error {
902
+ code;
903
+ params;
904
+ wrappedErrors;
905
+ constructor(wrappedErrors, errorCode, ...params) {
906
+ // Detecting if wrappedErrors are passed
907
+ if (!(wrappedErrors instanceof Array)) {
908
+ params = ('undefined' === typeof errorCode ? [] : [errorCode]).concat(params);
909
+ errorCode = wrappedErrors;
910
+ wrappedErrors = [];
911
+ }
912
+ // Call the parent constructor
913
+ super(errorCode);
914
+ // Filling error
915
+ this.code = errorCode || 'E_UNEXPECTED';
916
+ this.params = params;
917
+ this.wrappedErrors = wrappedErrors;
918
+ this.name = this.toString();
919
+ if (Error.captureStackTrace) {
920
+ Error.captureStackTrace(this, this.constructor);
921
+ }
922
+ }
923
+ /**
924
+ * Wraps any error and output a YError with an error
925
+ * code and some params as debug values.
926
+ * @param {Error} err
927
+ * The error to wrap
928
+ * @param {string} [errorCode = 'E_UNEXPECTED']
929
+ * The error code corresponding to the actual error
930
+ * @param {...YErrorParams} [params]
931
+ * Some additional debugging values
932
+ * @return {YError}
933
+ * The wrapped error
934
+ */
935
+ static wrap(err, errorCode, ...params) {
936
+ const wrappedErrorIsACode = _looksLikeAYErrorCode(err.message);
937
+ const wrappedErrors = ('wrappedErrors' in err ? err.wrappedErrors : []).concat(err);
938
+ if (!errorCode) {
939
+ if (wrappedErrorIsACode) {
940
+ errorCode = err.message;
941
+ }
942
+ else {
943
+ errorCode = 'E_UNEXPECTED';
944
+ }
945
+ }
946
+ if (err.message && !wrappedErrorIsACode) {
947
+ params.push(err.message);
948
+ }
949
+ return new dist_YError(wrappedErrors, errorCode, ...params);
950
+ }
951
+ /**
952
+ * Return a YError as is or wraps any other error and output
953
+ * a YError with a code and some params as debug values.
954
+ * @param {Error} err
955
+ * The error to cast
956
+ * @param {string} [errorCode = 'E_UNEXPECTED']
957
+ * The error code corresponding to the actual error
958
+ * @param {...YErrorParams} [params]
959
+ * Some additional debugging values
960
+ * @return {YError}
961
+ * The wrapped error
962
+ */
963
+ static cast(err, errorCode, ...params) {
964
+ if (_looksLikeAYError(err)) {
965
+ return err;
966
+ }
967
+ return dist_YError.wrap(err, errorCode, ...params);
968
+ }
969
+ /**
970
+ * Same than `YError.wrap()` but preserves the code
971
+ * and the debug values of the error if it is
972
+ * already an instance of the YError constructor.
973
+ * @param {Error} err
974
+ * The error to bump
975
+ * @param {string} [errorCode = 'E_UNEXPECTED']
976
+ * The error code corresponding to the actual error
977
+ * @param {...YErrorParams} [params]
978
+ * Some additional debugging values
979
+ * @return {YError}
980
+ * The wrapped error
981
+ */
982
+ static bump(err, errorCode, ...params) {
983
+ if (_looksLikeAYError(err)) {
984
+ return dist_YError.wrap(err, err.code, ...err.params);
985
+ }
986
+ return dist_YError.wrap(err, errorCode, ...params);
987
+ }
988
+ toString() {
989
+ return ((this.wrappedErrors.length
990
+ ? // eslint-disable-next-line
991
+ this.wrappedErrors[this.wrappedErrors.length - 1].stack + external_os_.EOL
992
+ : '') +
993
+ this.constructor.name +
994
+ ': ' +
995
+ this.code +
996
+ ' (' +
997
+ this.params.join(', ') +
998
+ ')');
999
+ }
1000
+ }
1001
+ /**
1002
+ * Allow to print a stack from anything (especially catched
1003
+ * errors that may or may not contain errors 🤷).
1004
+ * @param {Error} err
1005
+ * The error to print
1006
+ * @return {string}
1007
+ * The stack trace if any
1008
+ */
1009
+ function printStackTrace(err) {
1010
+ return typeof err === 'object' && typeof err.stack === 'string'
1011
+ ? err.stack
1012
+ : `[no_stack_trace]: error is ${err != null && typeof err.toString === 'function'
1013
+ ? err.toString()
1014
+ : typeof err}`;
1015
+ }
1016
+ // In order to keep compatibility through major versions
1017
+ // we have to make kind of an cross major version instanceof
1018
+ function _looksLikeAYError(err) {
1019
+ return (!!(err instanceof dist_YError) ||
1020
+ !!(err.constructor &&
1021
+ err.constructor.name &&
1022
+ err.constructor.name.endsWith('Error') &&
1023
+ 'code' in err &&
1024
+ 'string' === typeof err.code &&
1025
+ _looksLikeAYErrorCode(err.code) &&
1026
+ 'params' in err &&
1027
+ err.params &&
1028
+ err.params instanceof Array));
1029
+ }
1030
+ function _looksLikeAYErrorCode(str) {
1031
+ return /^([A-Z0-9_]+)$/.test(str);
1032
+ }
1033
+
1034
+ //# sourceMappingURL=index.js.map
1035
+ ;// ../../scrypted/packages/auth-fetch/node_modules/http-auth-utils/dist/utils.js
1036
+
1037
+ const QUOTE = '"';
1038
+ const EQUAL = '=';
1039
+ const SEPARATOR = ', ';
1040
+ /*
1041
+ * Regular expression for matching the key-value pairs
1042
+ * \w+ = The key
1043
+ * = = The equal sign
1044
+ * ".*?" = Value option 1: A double-quoted value (using the non-greedy *? to stop at the first doublequote)
1045
+ * [^",]+ = Value option 2: A string without commas or double-quotes
1046
+ * (?=,|$) = Zero-width (as in not captured) positive lookahead assertion.
1047
+ * The previous match will only be valid if it's followed by a " literal
1048
+ * or the end of the string
1049
+ */
1050
+ const KEYVALUE_REGEXP = /\w+=(".*?"|[^",]+)(?=,|$)/g;
1051
+ // FIXME: Create a real parser
1052
+ function parseHTTPHeadersQuotedKeyValueSet(contents, authorizedKeys, requiredKeys = [], valuesToNormalize = []) {
1053
+ const matches = contents.trim().match(KEYVALUE_REGEXP);
1054
+ if (!matches)
1055
+ throw new dist_YError('E_MALFORMED_QUOTEDKEYVALUE', contents);
1056
+ const data = matches
1057
+ .map((part, partPosition) => {
1058
+ const [key, ...rest] = part.split(EQUAL);
1059
+ const value = rest.join(EQUAL);
1060
+ if (0 === rest.length) {
1061
+ throw new dist_YError('E_MALFORMED_QUOTEDKEYVALUE', partPosition, part);
1062
+ }
1063
+ return [key, value];
1064
+ })
1065
+ .reduce(function (parsedValues, [name, value], valuePosition) {
1066
+ const normalizedName = name.toLowerCase();
1067
+ if (-1 === authorizedKeys.indexOf(normalizedName)) {
1068
+ throw new dist_YError('E_UNAUTHORIZED_KEY', valuePosition, normalizedName);
1069
+ }
1070
+ /*
1071
+ * Regular expression for stripping paired starting and ending double quotes off the value:
1072
+ * ^ = The beginning of the string
1073
+ * " = The first double quote
1074
+ * .+ = One or more characters of any kind
1075
+ * (?="$) = Zero-width (as in not captured) positive lookahead assertion.
1076
+ * The previous match will only be valid if it's followed by a " literal
1077
+ * or the end of the string
1078
+ * " = The ending double quote
1079
+ * $ = The end of the string
1080
+ */
1081
+ const strippedValue = value.replace(/^"(.+(?="$))"$/, '$1');
1082
+ parsedValues[normalizedName] = valuesToNormalize.includes(normalizedName)
1083
+ ? strippedValue.toLowerCase()
1084
+ : strippedValue;
1085
+ return parsedValues;
1086
+ }, {});
1087
+ _checkRequiredKeys(requiredKeys, data);
1088
+ return data;
1089
+ }
1090
+ function buildHTTPHeadersQuotedKeyValueSet(data, authorizedKeys, requiredKeys = []) {
1091
+ _checkRequiredKeys(requiredKeys, data);
1092
+ return authorizedKeys.reduce(function (contents, key) {
1093
+ if (data[key]) {
1094
+ return (contents +
1095
+ (contents ? SEPARATOR : '') +
1096
+ key +
1097
+ EQUAL +
1098
+ QUOTE +
1099
+ data[key] +
1100
+ QUOTE);
1101
+ }
1102
+ return contents;
1103
+ }, '');
1104
+ }
1105
+ function _checkRequiredKeys(requiredKeys, data) {
1106
+ requiredKeys.forEach((name) => {
1107
+ if ('undefined' === typeof data[name]) {
1108
+ throw new dist_YError('E_REQUIRED_KEY', name);
1109
+ }
1110
+ });
1111
+ }
1112
+ //# sourceMappingURL=utils.js.map
1113
+ ;// ../../scrypted/packages/auth-fetch/node_modules/http-auth-utils/dist/mechanisms/basic.js
1114
+ /**
1115
+ * @module http-auth-utils/mechanisms/basic
1116
+ */
1117
+
1118
+
1119
+ const REQUIRED_WWW_AUTHENTICATE_KEYS = ['realm'];
1120
+ const AUTHORIZED_WWW_AUTHENTICATE_KEYS = REQUIRED_WWW_AUTHENTICATE_KEYS;
1121
+ /* Architecture Note #1.2: Basic mechanism
1122
+
1123
+ See the following [RFC](https://tools.ietf.org/html/rfc7617).
1124
+
1125
+ */
1126
+ /**
1127
+ * Basic authentication mechanism.
1128
+ * @type {Object}
1129
+ * @see http://tools.ietf.org/html/rfc2617#section-2
1130
+ */
1131
+ const BASIC = {
1132
+ /**
1133
+ * The Basic auth mechanism prefix.
1134
+ * @type {String}
1135
+ */
1136
+ type: 'Basic',
1137
+ /**
1138
+ * Parse the WWW Authenticate header rest.
1139
+ * @param {String} rest The header rest (string after the authentication mechanism prefix).
1140
+ * @return {Object} Object representing the result of the parse operation.
1141
+ * @example
1142
+ * assert.deepEqual(
1143
+ * BASIC.parseWWWAuthenticateRest('realm="perlinpinpin"'), {
1144
+ * realm: 'perlinpinpin'
1145
+ * }
1146
+ * );
1147
+ * @api public
1148
+ */
1149
+ parseWWWAuthenticateRest: function parseWWWAuthenticateRest(rest) {
1150
+ return parseHTTPHeadersQuotedKeyValueSet(rest, AUTHORIZED_WWW_AUTHENTICATE_KEYS, REQUIRED_WWW_AUTHENTICATE_KEYS);
1151
+ },
1152
+ /**
1153
+ * Build the WWW Authenticate header rest.
1154
+ * @param {Object} data The content from wich to build the rest.
1155
+ * @return {String} The built rest.
1156
+ * @example
1157
+ * assert.equal(
1158
+ * BASIC.buildWWWAuthenticateRest({
1159
+ * realm: 'perlinpinpin'
1160
+ * }),
1161
+ * 'realm="perlinpinpin"'
1162
+ * );
1163
+ * @api public
1164
+ */
1165
+ buildWWWAuthenticateRest: function buildWWWAuthenticateRest(data) {
1166
+ return buildHTTPHeadersQuotedKeyValueSet(data, AUTHORIZED_WWW_AUTHENTICATE_KEYS, REQUIRED_WWW_AUTHENTICATE_KEYS);
1167
+ },
1168
+ /**
1169
+ * Parse the Authorization header rest.
1170
+ * @param {String} rest The header rest (string after the authentication mechanism prefix).)
1171
+ * @return {Object} Object representing the result of the parse operation {hash}.
1172
+ * @example
1173
+ * assert.deepEqual(
1174
+ * BASIC.parseAuthorizationRest('QWxpIEJhYmE6b3BlbiBzZXNhbWU='), {
1175
+ * hash: 'QWxpIEJhYmE6b3BlbiBzZXNhbWU=',
1176
+ * username: 'Ali Baba',
1177
+ * password: 'open sesame'
1178
+ * }
1179
+ * );
1180
+ * @api public
1181
+ */
1182
+ parseAuthorizationRest: function parseAuthorizationRest(rest) {
1183
+ if (!rest) {
1184
+ throw new dist_YError('E_EMPTY_AUTH');
1185
+ }
1186
+ const { username, password } = BASIC.decodeHash(rest);
1187
+ return {
1188
+ hash: rest,
1189
+ username,
1190
+ password,
1191
+ };
1192
+ },
1193
+ /**
1194
+ * Build the Authorization header rest.
1195
+ * @param {Object} content The content from wich to build the rest.
1196
+ * @return {String} The rest built.
1197
+ * @example
1198
+ * assert.equal(
1199
+ * BASIC.buildAuthorizationRest({
1200
+ * hash: 'QWxpIEJhYmE6b3BlbiBzZXNhbWU='
1201
+ * }),
1202
+ * 'QWxpIEJhYmE6b3BlbiBzZXNhbWU='
1203
+ * );
1204
+ * @api public
1205
+ */
1206
+ buildAuthorizationRest: function buildAuthorizationRest({ hash, username, password, }) {
1207
+ if (username && password) {
1208
+ return BASIC.computeHash({
1209
+ username,
1210
+ password,
1211
+ });
1212
+ }
1213
+ if (!hash) {
1214
+ throw new dist_YError('E_NO_HASH');
1215
+ }
1216
+ return hash;
1217
+ },
1218
+ /**
1219
+ * Compute the Basic authentication hash from the given credentials.
1220
+ * @param {Object} credentials The credentials to encode {username, password}.
1221
+ * @return {String} The hash representing the credentials.
1222
+ * @example
1223
+ * assert.equal(
1224
+ * BASIC.computeHash({
1225
+ * username: 'Ali Baba',
1226
+ * password: 'open sesame'
1227
+ * }),
1228
+ * 'QWxpIEJhYmE6b3BlbiBzZXNhbWU='
1229
+ * );
1230
+ * @api public
1231
+ */
1232
+ computeHash: function computeHash({ username, password, }) {
1233
+ return Buffer.from(username + ':' + password).toString('base64');
1234
+ },
1235
+ /**
1236
+ * Decode the Basic hash and return the corresponding credentials.
1237
+ * @param {String} hash The hash.
1238
+ * @return {Object} Object representing the credentials {username, password}.
1239
+ * @example
1240
+ * assert.deepEqual(
1241
+ * BASIC.decodeHash('QWxpIEJhYmE6b3BlbiBzZXNhbWU='), {
1242
+ * username: 'Ali Baba',
1243
+ * password: 'open sesame'
1244
+ * }
1245
+ * );
1246
+ * @api public
1247
+ */
1248
+ decodeHash: function decodeHash(hash) {
1249
+ const [username, ...passwordParts] = Buffer.from(hash, 'base64')
1250
+ .toString()
1251
+ .split(':');
1252
+ return {
1253
+ username,
1254
+ password: passwordParts.join(':'),
1255
+ };
1256
+ },
1257
+ };
1258
+ /* harmony default export */ const basic = (BASIC);
1259
+ //# sourceMappingURL=basic.js.map
1260
+ // EXTERNAL MODULE: external "crypto"
1261
+ var external_crypto_ = __webpack_require__(6982);
1262
+ ;// ../../scrypted/packages/auth-fetch/node_modules/http-auth-utils/dist/mechanisms/digest.js
1263
+ /**
1264
+ * @module http-auth-utils/mechanisms/digest
1265
+ */
1266
+
1267
+
1268
+ const digest_REQUIRED_WWW_AUTHENTICATE_KEYS = ['realm', 'nonce'];
1269
+ const digest_AUTHORIZED_WWW_AUTHENTICATE_KEYS = [
1270
+ ...digest_REQUIRED_WWW_AUTHENTICATE_KEYS,
1271
+ 'domain',
1272
+ 'opaque',
1273
+ 'stale',
1274
+ 'algorithm',
1275
+ 'qop',
1276
+ ];
1277
+ const CASE_INSENSITIVE_WWW_AUTHENTICATE_VALUES = ['stale'];
1278
+ const REQUIRED_AUTHORIZATION_KEYS = [
1279
+ 'username',
1280
+ 'realm',
1281
+ 'nonce',
1282
+ 'uri',
1283
+ 'response',
1284
+ ];
1285
+ const AUTHORIZED_AUTHORIZATION_KEYS = [
1286
+ ...REQUIRED_AUTHORIZATION_KEYS,
1287
+ 'algorithm',
1288
+ 'cnonce',
1289
+ 'opaque',
1290
+ 'qop',
1291
+ 'nc',
1292
+ ];
1293
+ /* Architecture Note #1.3: Digest mechanism
1294
+
1295
+ See the following [RFC](https://tools.ietf.org/html/rfc2617).
1296
+
1297
+ */
1298
+ /**
1299
+ * Digest authentication mechanism.
1300
+ * @type {Object}
1301
+ * @see http://tools.ietf.org/html/rfc2617#section-3
1302
+ * @see http://tools.ietf.org/html/rfc2069#section-2
1303
+ */
1304
+ const DIGEST = {
1305
+ /**
1306
+ * The Digest auth mechanism prefix.
1307
+ * @type {String}
1308
+ */
1309
+ type: 'Digest',
1310
+ /**
1311
+ * Parse the WWW Authenticate header rest.
1312
+ * @param {String} rest The header rest (string after the authentication mechanism prefix).
1313
+ * @return {Object} Object representing the result of the parse operation.
1314
+ * @example
1315
+ * assert.deepEqual(
1316
+ * DIGEST.parseWWWAuthenticateRest(
1317
+ * 'realm="testrealm@host.com", ' +
1318
+ * 'qop="auth, auth-int", ' +
1319
+ * 'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' +
1320
+ * 'opaque="5ccc069c403ebaf9f0171e9517f40e41"'
1321
+ * ), {
1322
+ * realm: 'testrealm@host.com',
1323
+ * qop: 'auth, auth-int',
1324
+ * nonce: 'dcd98b7102dd2f0e8b11d0f600bfb0c093',
1325
+ * opaque: '5ccc069c403ebaf9f0171e9517f40e41'
1326
+ * }
1327
+ * );
1328
+ * @api public
1329
+ */
1330
+ parseWWWAuthenticateRest: function parseWWWAuthenticateRest(rest) {
1331
+ return parseHTTPHeadersQuotedKeyValueSet(rest, digest_AUTHORIZED_WWW_AUTHENTICATE_KEYS, digest_REQUIRED_WWW_AUTHENTICATE_KEYS, CASE_INSENSITIVE_WWW_AUTHENTICATE_VALUES);
1332
+ },
1333
+ /**
1334
+ * Build the WWW Authenticate header rest.
1335
+ * @param {Object} data The content from which to build the rest.
1336
+ * @return {String} The built rest.
1337
+ * @example
1338
+ * assert.equal(
1339
+ * DIGEST.buildWWWAuthenticateRest({
1340
+ * realm: 'testrealm@host.com',
1341
+ * qop: 'auth, auth-int',
1342
+ * nonce: 'dcd98b7102dd2f0e8b11d0f600bfb0c093',
1343
+ * opaque: '5ccc069c403ebaf9f0171e9517f40e41'
1344
+ * }),
1345
+ * 'realm="testrealm@host.com", ' +
1346
+ * 'qop="auth, auth-int", ' +
1347
+ * 'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' +
1348
+ * 'opaque="5ccc069c403ebaf9f0171e9517f40e41"'
1349
+ * );
1350
+ * @api public
1351
+ */
1352
+ buildWWWAuthenticateRest: function buildWWWAuthenticateRest(data) {
1353
+ return buildHTTPHeadersQuotedKeyValueSet(data, digest_AUTHORIZED_WWW_AUTHENTICATE_KEYS, digest_REQUIRED_WWW_AUTHENTICATE_KEYS);
1354
+ },
1355
+ /**
1356
+ * Parse the Authorization header rest.
1357
+ * @param {String} rest The header rest (string after the authentication mechanism prefix).)
1358
+ * @return {Object} Object representing the result of the parse operation {hash}.
1359
+ * @example
1360
+ * assert.deepEqual(
1361
+ * DIGEST.parseAuthorizationRest(
1362
+ * 'username="Mufasa",' +
1363
+ * 'realm="testrealm@host.com",' +
1364
+ * 'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",' +
1365
+ * 'uri="/dir/index.html",' +
1366
+ * 'qop="auth",' +
1367
+ * 'nc="00000001",' +
1368
+ * 'cnonce="0a4f113b",' +
1369
+ * 'response="6629fae49393a05397450978507c4ef1",' +
1370
+ * 'opaque="5ccc069c403ebaf9f0171e9517f40e41"'
1371
+ * ), {
1372
+ * username: "Mufasa",
1373
+ * realm: 'testrealm@host.com',
1374
+ * nonce: "dcd98b7102dd2f0e8b11d0f600bfb0c093",
1375
+ * uri: "/dir/index.html",
1376
+ * qop: 'auth',
1377
+ * nc: '00000001',
1378
+ * cnonce: "0a4f113b",
1379
+ * response: "6629fae49393a05397450978507c4ef1",
1380
+ * opaque: "5ccc069c403ebaf9f0171e9517f40e41"
1381
+ * }
1382
+ * );
1383
+ * @api public
1384
+ */
1385
+ parseAuthorizationRest: function parseAuthorizationRest(rest) {
1386
+ return parseHTTPHeadersQuotedKeyValueSet(rest, AUTHORIZED_AUTHORIZATION_KEYS, REQUIRED_AUTHORIZATION_KEYS);
1387
+ },
1388
+ /**
1389
+ * Build the Authorization header rest.
1390
+ * @param {Object} data The content from which to build the rest.
1391
+ * @return {String} The rest built.
1392
+ * @example
1393
+ * assert.equal(
1394
+ * DIGEST.buildAuthorizationRest({
1395
+ * username: "Mufasa",
1396
+ * realm: 'testrealm@host.com',
1397
+ * nonce: "dcd98b7102dd2f0e8b11d0f600bfb0c093",
1398
+ * uri: "/dir/index.html",
1399
+ * qop: 'auth',
1400
+ * nc: '00000001',
1401
+ * cnonce: "0a4f113b",
1402
+ * response: "6629fae49393a05397450978507c4ef1",
1403
+ * opaque: "5ccc069c403ebaf9f0171e9517f40e41"
1404
+ * }),
1405
+ * 'username="Mufasa", ' +
1406
+ * 'realm="testrealm@host.com", ' +
1407
+ * 'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' +
1408
+ * 'uri="/dir/index.html", ' +
1409
+ * 'response="6629fae49393a05397450978507c4ef1", ' +
1410
+ * 'cnonce="0a4f113b", ' +
1411
+ * 'opaque="5ccc069c403ebaf9f0171e9517f40e41", ' +
1412
+ * 'qop="auth", ' +
1413
+ * 'nc="00000001"'
1414
+ * );
1415
+ * @api public
1416
+ */
1417
+ buildAuthorizationRest: function buildAuthorizationRest(data) {
1418
+ return buildHTTPHeadersQuotedKeyValueSet(data, AUTHORIZED_AUTHORIZATION_KEYS, REQUIRED_AUTHORIZATION_KEYS);
1419
+ },
1420
+ /**
1421
+ * Compute the Digest authentication hash from the given credentials.
1422
+ * @param {Object} data The credentials to encode and other encoding details.
1423
+ * @return {String} The hash representing the credentials.
1424
+ * @example
1425
+ * assert.equal(
1426
+ * DIGEST.computeHash({
1427
+ * username: 'Mufasa',
1428
+ * realm: 'testrealm@host.com',
1429
+ * password: 'Circle Of Life',
1430
+ * method: 'GET',
1431
+ * uri: '/dir/index.html',
1432
+ * nonce: 'dcd98b7102dd2f0e8b11d0f600bfb0c093',
1433
+ * nc: '00000001',
1434
+ * cnonce: '0a4f113b',
1435
+ * qop: 'auth',
1436
+ * algorithm: 'md5'
1437
+ * }),
1438
+ * '6629fae49393a05397450978507c4ef1'
1439
+ * );
1440
+ * @api public
1441
+ */
1442
+ computeHash: function computeHash(data) {
1443
+ const ha1 = data.ha1 ||
1444
+ _computeHash(data.algorithm, [data.username, data.realm, data.password].join(':'));
1445
+ const ha2 = _computeHash(data.algorithm, [data.method, data.uri].join(':'));
1446
+ return _computeHash(data.algorithm, [ha1, data.nonce, data.nc, data.cnonce, data.qop, ha2].join(':'));
1447
+ },
1448
+ };
1449
+ function _computeHash(algorithm, str) {
1450
+ const hashsum = external_crypto_.createHash(algorithm);
1451
+ hashsum.update(str);
1452
+ return hashsum.digest('hex');
1453
+ }
1454
+ /* harmony default export */ const digest = (DIGEST);
1455
+ //# sourceMappingURL=digest.js.map
1456
+ ;// ../../scrypted/packages/auth-fetch/node_modules/http-auth-utils/dist/mechanisms/bearer.js
1457
+ /**
1458
+ * @module http-auth-utils/mechanisms/bearer
1459
+ */
1460
+
1461
+
1462
+ const AUTHORIZED_ERROR_CODES = [
1463
+ 'invalid_request',
1464
+ 'invalid_token',
1465
+ 'insufficient_scope',
1466
+ ];
1467
+ const bearer_REQUIRED_WWW_AUTHENTICATE_KEYS = ['realm'];
1468
+ const bearer_AUTHORIZED_WWW_AUTHENTICATE_KEYS = [
1469
+ ...bearer_REQUIRED_WWW_AUTHENTICATE_KEYS,
1470
+ 'scope',
1471
+ 'error',
1472
+ 'error_description',
1473
+ ];
1474
+ /* Architecture Note #1.1: Bearer mechanism
1475
+
1476
+ See the following [RFC](https://tools.ietf.org/html/rfc6750).
1477
+
1478
+ */
1479
+ /**
1480
+ * Bearer authentication mechanism.
1481
+ * @type {Object}
1482
+ * @see https://tools.ietf.org/html/rfc6750#section-3
1483
+ */
1484
+ const BEARER = {
1485
+ /**
1486
+ * The Bearer auth mechanism prefix.
1487
+ * @type {String}
1488
+ */
1489
+ type: 'Bearer',
1490
+ /**
1491
+ * Parse the WWW Authenticate header rest.
1492
+ * @param {String} rest The header rest (string after the authentication mechanism prefix).
1493
+ * @return {Object} Object representing the result of the parse operation.
1494
+ * @example
1495
+ * assert.deepEqual(
1496
+ * BEARER.parseWWWAuthenticateRest(
1497
+ * 'realm="testrealm@host.com", ' +
1498
+ * 'scope="openid profile email"'
1499
+ * ), {
1500
+ * realm: 'testrealm@host.com',
1501
+ * scope: 'openid profile email',
1502
+ * }
1503
+ * );
1504
+ * @api public
1505
+ */
1506
+ parseWWWAuthenticateRest: function parseWWWAuthenticateRest(rest) {
1507
+ return parseHTTPHeadersQuotedKeyValueSet(rest, bearer_AUTHORIZED_WWW_AUTHENTICATE_KEYS, []);
1508
+ },
1509
+ /**
1510
+ * Build the WWW Authenticate header rest.
1511
+ * @param {Object} data The content from wich to build the rest.
1512
+ * @return {String} The built rest.
1513
+ * @example
1514
+ * assert.equal(
1515
+ * BEARER.buildWWWAuthenticateRest({
1516
+ * realm: 'testrealm@host.com',
1517
+ * error: 'invalid_request',
1518
+ * error_description: 'The access token expired',
1519
+ * }),
1520
+ * 'realm="testrealm@host.com", ' +
1521
+ * 'error="invalid_request", ' +
1522
+ * 'error_description="The access token expired"'
1523
+ * );
1524
+ * @api public
1525
+ */
1526
+ buildWWWAuthenticateRest: function buildWWWAuthenticateRest(data) {
1527
+ if (data.error &&
1528
+ -1 ===
1529
+ AUTHORIZED_ERROR_CODES.indexOf(data.error)) {
1530
+ throw new dist_YError('E_INVALID_ERROR', data.error, AUTHORIZED_ERROR_CODES);
1531
+ }
1532
+ return buildHTTPHeadersQuotedKeyValueSet(data, bearer_AUTHORIZED_WWW_AUTHENTICATE_KEYS, []);
1533
+ },
1534
+ /**
1535
+ * Parse the Authorization header rest.
1536
+ * @param {String} rest The header rest (string after the authentication mechanism prefix).)
1537
+ * @return {Object} Object representing the result of the parse operation {hash}.
1538
+ * @example
1539
+ * assert.deepEqual(
1540
+ * BEARER.parseAuthorizationRest('mF_9.B5f-4.1JqM'), {
1541
+ * hash: 'mF_9.B5f-4.1JqM',
1542
+ * }
1543
+ * );
1544
+ * @api public
1545
+ */
1546
+ parseAuthorizationRest: function parseAuthorizationRest(rest) {
1547
+ if (!rest) {
1548
+ throw new dist_YError('E_EMPTY_AUTH');
1549
+ }
1550
+ return {
1551
+ hash: rest,
1552
+ };
1553
+ },
1554
+ /**
1555
+ * Build the Authorization header rest.
1556
+ * @param {Object} content The content from wich to build the rest.
1557
+ * @return {String} The rest built.
1558
+ * @example
1559
+ * assert.equal(
1560
+ * BEARER.buildAuthorizationRest({
1561
+ * hash: 'mF_9.B5f-4.1JqM'
1562
+ * }),
1563
+ * 'mF_9.B5f-4.1JqM=='
1564
+ * );
1565
+ * @api public
1566
+ */
1567
+ buildAuthorizationRest: function buildAuthorizationRest({ hash, }) {
1568
+ if (!hash) {
1569
+ throw new dist_YError('E_NO_HASH');
1570
+ }
1571
+ return hash;
1572
+ },
1573
+ };
1574
+ /* harmony default export */ const bearer = (BEARER);
1575
+ //# sourceMappingURL=bearer.js.map
1576
+ ;// ../../scrypted/packages/auth-fetch/node_modules/http-auth-utils/dist/index.js
1577
+
1578
+
1579
+
1580
+
1581
+ /**
1582
+ * @module http-auth-utils
1583
+ */
1584
+ /**
1585
+ * Natively supported authentication mechanisms.
1586
+ * @type {Array}
1587
+ */
1588
+ const mechanisms = [basic, digest, bearer];
1589
+ /**
1590
+ * Basic authentication mechanism.
1591
+ * @type {Object}
1592
+ * @see {@link module:http-auth-utils/mechanisms/basic}
1593
+ */
1594
+ basic;
1595
+ /**
1596
+ * Digest authentication mechanism.
1597
+ * @type {Object}
1598
+ * @see {@link module:http-auth-utils/mechanisms/digest}
1599
+ */
1600
+ digest;
1601
+ /**
1602
+ * Bearer authentication mechanism.
1603
+ * @type {Object}
1604
+ * @see {@link module:http-auth-utils/mechanisms/digest}
1605
+ */
1606
+ bearer;
1607
+
1608
+ /**
1609
+ * Parse HTTP WWW-Authenticate header contents.
1610
+ * @type {Function}
1611
+ * @param {string} header
1612
+ * The WWW-Authenticate header contents
1613
+ * @param {Array} [authMechanisms=[BASIC, DIGEST, BEARER]]
1614
+ * Allow providing custom authentication mechanisms.
1615
+ * @param {Object} [options]
1616
+ * Parsing options
1617
+ * @param {boolean} [options.strict=true]
1618
+ * Strictly detect the mechanism type (case sensitive)
1619
+ * @return {Object} Result of the contents parse.
1620
+ * @api public
1621
+ * @example
1622
+ * assert.deepEqual(
1623
+ * parseWWWAuthenticateHeader('Basic realm="test"'), {
1624
+ * type: 'Basic',
1625
+ * data: {
1626
+ * realm: 'test'
1627
+ * }
1628
+ * }
1629
+ * );
1630
+ */
1631
+ function parseWWWAuthenticateHeader(header, authMechanisms = mechanisms, { strict = true } = { strict: true }) {
1632
+ let result = null;
1633
+ authMechanisms.some((authMechanism) => {
1634
+ if (0 === header.indexOf(authMechanism.type + ' ') ||
1635
+ (!strict && 0 === header.indexOf(authMechanism.type.toLowerCase() + ' '))) {
1636
+ result = {
1637
+ type: authMechanism.type,
1638
+ data: authMechanism.parseWWWAuthenticateRest(header.substr(authMechanism.type.length + 1)),
1639
+ };
1640
+ return true;
1641
+ }
1642
+ return false;
1643
+ });
1644
+ if (!result) {
1645
+ throw new dist_YError('E_UNKNOWN_AUTH_MECHANISM', header);
1646
+ }
1647
+ return result;
1648
+ }
1649
+ /**
1650
+ * Parse HTTP Authorization header contents.
1651
+ * @type {Function}
1652
+ * @param {string} header The Authorization header contents
1653
+ * @param {Array} [authMechanisms=[BASIC, DIGEST, BEARER]]
1654
+ * Allow custom authentication mechanisms.
1655
+ * @param {Object} [options]
1656
+ * Parsing options
1657
+ * @param {boolean} [options.strict=true]
1658
+ * Strictly detect the mechanism type (case sensitive)
1659
+ * @return {Object} Result of the contents parse.
1660
+ * @api public
1661
+ * @example
1662
+ * assert.deepEqual(
1663
+ * parseAuthorizationHeader('Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='), {
1664
+ * type: 'Basic',
1665
+ * data: {
1666
+ * hash: 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
1667
+ * }
1668
+ * }
1669
+ * );
1670
+ */
1671
+ function parseAuthorizationHeader(header, authMechanisms = mechanisms, { strict = true } = { strict: true }) {
1672
+ let result = null;
1673
+ authMechanisms.some(function (authMechanism) {
1674
+ if (0 === header.indexOf(authMechanism.type + ' ') ||
1675
+ (!strict && 0 === header.indexOf(authMechanism.type.toLowerCase() + ' '))) {
1676
+ result = {
1677
+ type: authMechanism.type,
1678
+ data: authMechanism.parseAuthorizationRest(header.substr(authMechanism.type.length + 1)),
1679
+ };
1680
+ return true;
1681
+ }
1682
+ return false;
1683
+ });
1684
+ if (result) {
1685
+ return result;
1686
+ }
1687
+ throw new YError('E_UNKNOWN_AUTH_MECHANISM', header);
1688
+ }
1689
+ /**
1690
+ * Build HTTP WWW-Authenticate header value.
1691
+ * @type {Function}
1692
+ * @param {Object} authMechanism The mechanism to use
1693
+ * @param {Object}
1694
+ * The WWW-Authenticate header contents to base the value on.
1695
+ * @return {string} The header value.
1696
+ * @api public
1697
+ * @example
1698
+ * assert.deepEqual(
1699
+ * buildWWWAuthenticateHeader(BASIC, {
1700
+ * realm: 'test'
1701
+ * }),
1702
+ * 'Basic realm="test"'
1703
+ * );
1704
+ */
1705
+ function buildWWWAuthenticateHeader(authMechanism, data) {
1706
+ return `${authMechanism.type} ${authMechanism.buildWWWAuthenticateRest(data)}`;
1707
+ }
1708
+ /**
1709
+ * Build HTTP Authorization header value.
1710
+ * @type {Function}
1711
+ * @param {Object} authMechanism The mechanism to use
1712
+ * @param {Object}
1713
+ * The Authorization header contents to base the value on.
1714
+ * @return {string} The header value.
1715
+ * @api public
1716
+ * @example
1717
+ * assert.deepEqual(
1718
+ * buildAuthorizationHeader(BASIC, {
1719
+ * realm: 'test'
1720
+ * }),
1721
+ * 'Basic realm="test"'
1722
+ * );
1723
+ */
1724
+ function buildAuthorizationHeader(authMechanism, data) {
1725
+ return `${authMechanism.type} ${authMechanism.buildAuthorizationRest(data)}`;
1726
+ }
1727
+ //# sourceMappingURL=index.js.map
1728
+
1729
+ /***/ })
1730
+
1731
+ };
1732
+ ;
1733
+
1734
+ //# sourceURL=/plugin/724