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