@livechat/accounts-sdk 2.0.7 → 2.0.9
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/dist/accounts-sdk.js +1862 -1020
- package/dist/accounts-sdk.js.map +1 -1
- package/dist/accounts-sdk.min.js +4 -6
- package/dist/accounts-sdk.min.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/accounts-sdk.js
CHANGED
|
@@ -1,110 +1,25 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.AccountsSDK = factory());
|
|
5
|
-
}(this, (function () { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('util')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['util'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.AccountsSDK = factory(global.require$$0));
|
|
5
|
+
}(this, (function (require$$0) { 'use strict';
|
|
6
6
|
|
|
7
|
-
function
|
|
8
|
-
"@babel/helpers - typeof";
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
_typeof = function (obj) {
|
|
12
|
-
return typeof obj;
|
|
13
|
-
};
|
|
14
|
-
} else {
|
|
15
|
-
_typeof = function (obj) {
|
|
16
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return _typeof(obj);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function _classCallCheck(instance, Constructor) {
|
|
24
|
-
if (!(instance instanceof Constructor)) {
|
|
25
|
-
throw new TypeError("Cannot call a class as a function");
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function _defineProperties(target, props) {
|
|
30
|
-
for (var i = 0; i < props.length; i++) {
|
|
31
|
-
var descriptor = props[i];
|
|
32
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
33
|
-
descriptor.configurable = true;
|
|
34
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
35
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
40
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
41
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
42
|
-
return Constructor;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function _defineProperty(obj, key, value) {
|
|
46
|
-
if (key in obj) {
|
|
47
|
-
Object.defineProperty(obj, key, {
|
|
48
|
-
value: value,
|
|
49
|
-
enumerable: true,
|
|
50
|
-
configurable: true,
|
|
51
|
-
writable: true
|
|
52
|
-
});
|
|
53
|
-
} else {
|
|
54
|
-
obj[key] = value;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return obj;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function ownKeys(object, enumerableOnly) {
|
|
61
|
-
var keys = Object.keys(object);
|
|
62
|
-
|
|
63
|
-
if (Object.getOwnPropertySymbols) {
|
|
64
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
65
|
-
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
66
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
67
|
-
});
|
|
68
|
-
keys.push.apply(keys, symbols);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return keys;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function _objectSpread2(target) {
|
|
75
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
76
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
77
|
-
|
|
78
|
-
if (i % 2) {
|
|
79
|
-
ownKeys(Object(source), true).forEach(function (key) {
|
|
80
|
-
_defineProperty(target, key, source[key]);
|
|
81
|
-
});
|
|
82
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
83
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
84
|
-
} else {
|
|
85
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
86
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return target;
|
|
92
|
-
}
|
|
9
|
+
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
93
10
|
|
|
94
11
|
var errors = {
|
|
95
|
-
extend: function
|
|
12
|
+
extend: function (error) {
|
|
96
13
|
if (error.oauth_exception && this.oauth_exception[error.oauth_exception]) {
|
|
97
14
|
return Object.assign(error, {
|
|
98
15
|
description: this.oauth_exception[error.oauth_exception]
|
|
99
16
|
});
|
|
100
17
|
}
|
|
101
|
-
|
|
102
18
|
if (error.identity_exception && this.identity_exception[error.identity_exception]) {
|
|
103
19
|
return Object.assign(error, {
|
|
104
20
|
description: this.identity_exception[error.identity_exception]
|
|
105
21
|
});
|
|
106
22
|
}
|
|
107
|
-
|
|
108
23
|
return error;
|
|
109
24
|
},
|
|
110
25
|
oauth_exception: {
|
|
@@ -118,215 +33,1483 @@
|
|
|
118
33
|
}
|
|
119
34
|
};
|
|
120
35
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
_classCallCheck(this, Listener);
|
|
126
|
-
|
|
36
|
+
/* eslint-disable require-jsdoc */
|
|
37
|
+
class Listener {
|
|
38
|
+
constructor(options = {}) {
|
|
127
39
|
this.options = options;
|
|
128
40
|
this.listening = false;
|
|
129
41
|
this.receiveMessage = this.receiveMessage.bind(this);
|
|
130
42
|
}
|
|
43
|
+
start(timeout, callback) {
|
|
44
|
+
if (this._listenerInited) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
this.listening = true;
|
|
48
|
+
this.callback = callback;
|
|
49
|
+
if (timeout) {
|
|
50
|
+
this.tid = setTimeout(() => {
|
|
51
|
+
this.stop();
|
|
52
|
+
callback('timeout', null);
|
|
53
|
+
}, timeout);
|
|
54
|
+
}
|
|
55
|
+
window.addEventListener('message', this.receiveMessage);
|
|
56
|
+
}
|
|
57
|
+
stop() {
|
|
58
|
+
this.listening = false;
|
|
59
|
+
clearTimeout(this.tid);
|
|
60
|
+
window.removeEventListener('message', this.receiveMessage, false);
|
|
61
|
+
}
|
|
62
|
+
receiveMessage(event) {
|
|
63
|
+
if (event.origin !== this.options.server_url && event.origin !== this.options.server_url.replace(/livechat\.com$/, 'livechatinc.com')) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (!event.data.data && !event.data.error) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
this.stop();
|
|
70
|
+
if (event.data.error) {
|
|
71
|
+
this.callback(errors.extend(event.data.error), null);
|
|
72
|
+
} else {
|
|
73
|
+
if (event.data.data.scopes) {
|
|
74
|
+
event.data.data.scope = event.data.data.scopes;
|
|
75
|
+
delete event.data.data.scopes;
|
|
76
|
+
}
|
|
77
|
+
if (event.data.data.expires_in) {
|
|
78
|
+
event.data.data.expires_in = parseInt(event.data.data.expires_in) || 0;
|
|
79
|
+
}
|
|
80
|
+
this.callback(null, event.data.data);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
131
84
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Class for authentication using popup.
|
|
87
|
+
*/
|
|
88
|
+
class Popup {
|
|
89
|
+
// eslint-disable-next-line require-jsdoc
|
|
90
|
+
constructor(sdk, options) {
|
|
91
|
+
this.options = options;
|
|
92
|
+
this.sdk = sdk;
|
|
93
|
+
}
|
|
136
94
|
|
|
137
|
-
|
|
138
|
-
|
|
95
|
+
/**
|
|
96
|
+
* run popup authorization flow, should be called in a click handler to avoid beeing blocked
|
|
97
|
+
* @return {Promise} promise that resolves to authorize data or error
|
|
98
|
+
*/
|
|
99
|
+
authorize() {
|
|
100
|
+
return new Promise((resolve, reject) => {
|
|
101
|
+
const url = this.sdk.authorizeURL(this.options, 'button');
|
|
102
|
+
const w = 500;
|
|
103
|
+
const h = 650;
|
|
104
|
+
const left = window.screen.width / 2 - w / 2;
|
|
105
|
+
const top = window.screen.height / 2 - h / 2;
|
|
106
|
+
const listener = new Listener(this.options);
|
|
107
|
+
listener.start(null, (err, authorizeData) => {
|
|
108
|
+
if (err) {
|
|
109
|
+
return reject(err);
|
|
110
|
+
}
|
|
111
|
+
resolve(authorizeData);
|
|
112
|
+
});
|
|
113
|
+
var open = function () {
|
|
114
|
+
window.open(url, 'livechat-login-popup', "resizable,scrollbars,width=".concat(w, ",height=").concat(h, ",left=").concat(left, ",top=").concat(top));
|
|
115
|
+
};
|
|
116
|
+
if (document.requestStorageAccess) {
|
|
117
|
+
var promise = document.requestStorageAccess();
|
|
118
|
+
promise.then(open, open);
|
|
119
|
+
} else {
|
|
120
|
+
open();
|
|
139
121
|
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
140
125
|
|
|
141
|
-
|
|
142
|
-
|
|
126
|
+
/* eslint complexity: [2, 18], max-statements: [2, 33] */
|
|
127
|
+
var shams = function hasSymbols() {
|
|
128
|
+
if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
if (typeof Symbol.iterator === 'symbol') {
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
var obj = {};
|
|
135
|
+
var sym = Symbol('test');
|
|
136
|
+
var symObj = Object(sym);
|
|
137
|
+
if (typeof sym === 'string') {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
if (Object.prototype.toString.call(sym) !== '[object Symbol]') {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
if (Object.prototype.toString.call(symObj) !== '[object Symbol]') {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
143
146
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
// temp disabled per https://github.com/ljharb/object.assign/issues/17
|
|
148
|
+
// if (sym instanceof Symbol) { return false; }
|
|
149
|
+
// temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
|
|
150
|
+
// if (!(symObj instanceof Symbol)) { return false; }
|
|
147
151
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
152
|
+
// if (typeof Symbol.prototype.toString !== 'function') { return false; }
|
|
153
|
+
// if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
|
|
151
154
|
|
|
152
|
-
|
|
155
|
+
var symVal = 42;
|
|
156
|
+
obj[sym] = symVal;
|
|
157
|
+
for (sym in obj) {
|
|
158
|
+
return false;
|
|
159
|
+
} // eslint-disable-line no-restricted-syntax, no-unreachable-loop
|
|
160
|
+
if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
var syms = Object.getOwnPropertySymbols(obj);
|
|
167
|
+
if (syms.length !== 1 || syms[0] !== sym) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
if (typeof Object.getOwnPropertyDescriptor === 'function') {
|
|
174
|
+
var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
|
|
175
|
+
if (descriptor.value !== symVal || descriptor.enumerable !== true) {
|
|
176
|
+
return false;
|
|
153
177
|
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
178
|
+
}
|
|
179
|
+
return true;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
var origSymbol = typeof Symbol !== 'undefined' && Symbol;
|
|
183
|
+
var hasSymbols = function hasNativeSymbols() {
|
|
184
|
+
if (typeof origSymbol !== 'function') {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
if (typeof Symbol !== 'function') {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
if (typeof origSymbol('foo') !== 'symbol') {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
if (typeof Symbol('bar') !== 'symbol') {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
return shams();
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
var test = {
|
|
200
|
+
foo: {}
|
|
201
|
+
};
|
|
202
|
+
var $Object = Object;
|
|
203
|
+
var hasProto = function hasProto() {
|
|
204
|
+
return {
|
|
205
|
+
__proto__: test
|
|
206
|
+
}.foo === test.foo && !({
|
|
207
|
+
__proto__: null
|
|
208
|
+
} instanceof $Object);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
/* eslint no-invalid-this: 1 */
|
|
212
|
+
var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
|
|
213
|
+
var toStr = Object.prototype.toString;
|
|
214
|
+
var max = Math.max;
|
|
215
|
+
var funcType = '[object Function]';
|
|
216
|
+
var concatty = function concatty(a, b) {
|
|
217
|
+
var arr = [];
|
|
218
|
+
for (var i = 0; i < a.length; i += 1) {
|
|
219
|
+
arr[i] = a[i];
|
|
220
|
+
}
|
|
221
|
+
for (var j = 0; j < b.length; j += 1) {
|
|
222
|
+
arr[j + a.length] = b[j];
|
|
223
|
+
}
|
|
224
|
+
return arr;
|
|
225
|
+
};
|
|
226
|
+
var slicy = function slicy(arrLike, offset) {
|
|
227
|
+
var arr = [];
|
|
228
|
+
for (var i = offset || 0, j = 0; i < arrLike.length; i += 1, j += 1) {
|
|
229
|
+
arr[j] = arrLike[i];
|
|
230
|
+
}
|
|
231
|
+
return arr;
|
|
232
|
+
};
|
|
233
|
+
var joiny = function (arr, joiner) {
|
|
234
|
+
var str = '';
|
|
235
|
+
for (var i = 0; i < arr.length; i += 1) {
|
|
236
|
+
str += arr[i];
|
|
237
|
+
if (i + 1 < arr.length) {
|
|
238
|
+
str += joiner;
|
|
160
239
|
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
240
|
+
}
|
|
241
|
+
return str;
|
|
242
|
+
};
|
|
243
|
+
var implementation = function bind(that) {
|
|
244
|
+
var target = this;
|
|
245
|
+
if (typeof target !== 'function' || toStr.apply(target) !== funcType) {
|
|
246
|
+
throw new TypeError(ERROR_MESSAGE + target);
|
|
247
|
+
}
|
|
248
|
+
var args = slicy(arguments, 1);
|
|
249
|
+
var bound;
|
|
250
|
+
var binder = function () {
|
|
251
|
+
if (this instanceof bound) {
|
|
252
|
+
var result = target.apply(this, concatty(args, arguments));
|
|
253
|
+
if (Object(result) === result) {
|
|
254
|
+
return result;
|
|
166
255
|
}
|
|
256
|
+
return this;
|
|
257
|
+
}
|
|
258
|
+
return target.apply(that, concatty(args, arguments));
|
|
259
|
+
};
|
|
260
|
+
var boundLength = max(0, target.length - args.length);
|
|
261
|
+
var boundArgs = [];
|
|
262
|
+
for (var i = 0; i < boundLength; i++) {
|
|
263
|
+
boundArgs[i] = '$' + i;
|
|
264
|
+
}
|
|
265
|
+
bound = Function('binder', 'return function (' + joiny(boundArgs, ',') + '){ return binder.apply(this,arguments); }')(binder);
|
|
266
|
+
if (target.prototype) {
|
|
267
|
+
var Empty = function Empty() {};
|
|
268
|
+
Empty.prototype = target.prototype;
|
|
269
|
+
bound.prototype = new Empty();
|
|
270
|
+
Empty.prototype = null;
|
|
271
|
+
}
|
|
272
|
+
return bound;
|
|
273
|
+
};
|
|
167
274
|
|
|
168
|
-
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
275
|
+
var functionBind = Function.prototype.bind || implementation;
|
|
171
276
|
|
|
172
|
-
|
|
277
|
+
var call = Function.prototype.call;
|
|
278
|
+
var $hasOwn = Object.prototype.hasOwnProperty;
|
|
173
279
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
} else {
|
|
177
|
-
if (event.data.data.scopes) {
|
|
178
|
-
event.data.data.scope = event.data.data.scopes;
|
|
179
|
-
delete event.data.data.scopes;
|
|
180
|
-
}
|
|
280
|
+
/** @type {(o: {}, p: PropertyKey) => p is keyof o} */
|
|
281
|
+
var hasown = functionBind.call(call, $hasOwn);
|
|
181
282
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
283
|
+
var undefined$1;
|
|
284
|
+
var $SyntaxError = SyntaxError;
|
|
285
|
+
var $Function = Function;
|
|
286
|
+
var $TypeError = TypeError;
|
|
185
287
|
|
|
186
|
-
|
|
288
|
+
// eslint-disable-next-line consistent-return
|
|
289
|
+
var getEvalledConstructor = function (expressionSyntax) {
|
|
290
|
+
try {
|
|
291
|
+
return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
|
|
292
|
+
} catch (e) {}
|
|
293
|
+
};
|
|
294
|
+
var $gOPD = Object.getOwnPropertyDescriptor;
|
|
295
|
+
if ($gOPD) {
|
|
296
|
+
try {
|
|
297
|
+
$gOPD({}, '');
|
|
298
|
+
} catch (e) {
|
|
299
|
+
$gOPD = null; // this is IE 8, which has a broken gOPD
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
var throwTypeError = function () {
|
|
303
|
+
throw new $TypeError();
|
|
304
|
+
};
|
|
305
|
+
var ThrowTypeError = $gOPD ? function () {
|
|
306
|
+
try {
|
|
307
|
+
// eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
|
|
308
|
+
arguments.callee; // IE 8 does not throw here
|
|
309
|
+
return throwTypeError;
|
|
310
|
+
} catch (calleeThrows) {
|
|
311
|
+
try {
|
|
312
|
+
// IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
|
|
313
|
+
return $gOPD(arguments, 'callee').get;
|
|
314
|
+
} catch (gOPDthrows) {
|
|
315
|
+
return throwTypeError;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}() : throwTypeError;
|
|
319
|
+
var hasSymbols$1 = hasSymbols();
|
|
320
|
+
var hasProto$1 = hasProto();
|
|
321
|
+
var getProto = Object.getPrototypeOf || (hasProto$1 ? function (x) {
|
|
322
|
+
return x.__proto__;
|
|
323
|
+
} // eslint-disable-line no-proto
|
|
324
|
+
: null);
|
|
325
|
+
var needsEval = {};
|
|
326
|
+
var TypedArray = typeof Uint8Array === 'undefined' || !getProto ? undefined$1 : getProto(Uint8Array);
|
|
327
|
+
var INTRINSICS = {
|
|
328
|
+
'%AggregateError%': typeof AggregateError === 'undefined' ? undefined$1 : AggregateError,
|
|
329
|
+
'%Array%': Array,
|
|
330
|
+
'%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined$1 : ArrayBuffer,
|
|
331
|
+
'%ArrayIteratorPrototype%': hasSymbols$1 && getProto ? getProto([][Symbol.iterator]()) : undefined$1,
|
|
332
|
+
'%AsyncFromSyncIteratorPrototype%': undefined$1,
|
|
333
|
+
'%AsyncFunction%': needsEval,
|
|
334
|
+
'%AsyncGenerator%': needsEval,
|
|
335
|
+
'%AsyncGeneratorFunction%': needsEval,
|
|
336
|
+
'%AsyncIteratorPrototype%': needsEval,
|
|
337
|
+
'%Atomics%': typeof Atomics === 'undefined' ? undefined$1 : Atomics,
|
|
338
|
+
'%BigInt%': typeof BigInt === 'undefined' ? undefined$1 : BigInt,
|
|
339
|
+
'%BigInt64Array%': typeof BigInt64Array === 'undefined' ? undefined$1 : BigInt64Array,
|
|
340
|
+
'%BigUint64Array%': typeof BigUint64Array === 'undefined' ? undefined$1 : BigUint64Array,
|
|
341
|
+
'%Boolean%': Boolean,
|
|
342
|
+
'%DataView%': typeof DataView === 'undefined' ? undefined$1 : DataView,
|
|
343
|
+
'%Date%': Date,
|
|
344
|
+
'%decodeURI%': decodeURI,
|
|
345
|
+
'%decodeURIComponent%': decodeURIComponent,
|
|
346
|
+
'%encodeURI%': encodeURI,
|
|
347
|
+
'%encodeURIComponent%': encodeURIComponent,
|
|
348
|
+
'%Error%': Error,
|
|
349
|
+
'%eval%': eval,
|
|
350
|
+
// eslint-disable-line no-eval
|
|
351
|
+
'%EvalError%': EvalError,
|
|
352
|
+
'%Float32Array%': typeof Float32Array === 'undefined' ? undefined$1 : Float32Array,
|
|
353
|
+
'%Float64Array%': typeof Float64Array === 'undefined' ? undefined$1 : Float64Array,
|
|
354
|
+
'%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined$1 : FinalizationRegistry,
|
|
355
|
+
'%Function%': $Function,
|
|
356
|
+
'%GeneratorFunction%': needsEval,
|
|
357
|
+
'%Int8Array%': typeof Int8Array === 'undefined' ? undefined$1 : Int8Array,
|
|
358
|
+
'%Int16Array%': typeof Int16Array === 'undefined' ? undefined$1 : Int16Array,
|
|
359
|
+
'%Int32Array%': typeof Int32Array === 'undefined' ? undefined$1 : Int32Array,
|
|
360
|
+
'%isFinite%': isFinite,
|
|
361
|
+
'%isNaN%': isNaN,
|
|
362
|
+
'%IteratorPrototype%': hasSymbols$1 && getProto ? getProto(getProto([][Symbol.iterator]())) : undefined$1,
|
|
363
|
+
'%JSON%': typeof JSON === 'object' ? JSON : undefined$1,
|
|
364
|
+
'%Map%': typeof Map === 'undefined' ? undefined$1 : Map,
|
|
365
|
+
'%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols$1 || !getProto ? undefined$1 : getProto(new Map()[Symbol.iterator]()),
|
|
366
|
+
'%Math%': Math,
|
|
367
|
+
'%Number%': Number,
|
|
368
|
+
'%Object%': Object,
|
|
369
|
+
'%parseFloat%': parseFloat,
|
|
370
|
+
'%parseInt%': parseInt,
|
|
371
|
+
'%Promise%': typeof Promise === 'undefined' ? undefined$1 : Promise,
|
|
372
|
+
'%Proxy%': typeof Proxy === 'undefined' ? undefined$1 : Proxy,
|
|
373
|
+
'%RangeError%': RangeError,
|
|
374
|
+
'%ReferenceError%': ReferenceError,
|
|
375
|
+
'%Reflect%': typeof Reflect === 'undefined' ? undefined$1 : Reflect,
|
|
376
|
+
'%RegExp%': RegExp,
|
|
377
|
+
'%Set%': typeof Set === 'undefined' ? undefined$1 : Set,
|
|
378
|
+
'%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols$1 || !getProto ? undefined$1 : getProto(new Set()[Symbol.iterator]()),
|
|
379
|
+
'%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined$1 : SharedArrayBuffer,
|
|
380
|
+
'%String%': String,
|
|
381
|
+
'%StringIteratorPrototype%': hasSymbols$1 && getProto ? getProto(''[Symbol.iterator]()) : undefined$1,
|
|
382
|
+
'%Symbol%': hasSymbols$1 ? Symbol : undefined$1,
|
|
383
|
+
'%SyntaxError%': $SyntaxError,
|
|
384
|
+
'%ThrowTypeError%': ThrowTypeError,
|
|
385
|
+
'%TypedArray%': TypedArray,
|
|
386
|
+
'%TypeError%': $TypeError,
|
|
387
|
+
'%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined$1 : Uint8Array,
|
|
388
|
+
'%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined$1 : Uint8ClampedArray,
|
|
389
|
+
'%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined$1 : Uint16Array,
|
|
390
|
+
'%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined$1 : Uint32Array,
|
|
391
|
+
'%URIError%': URIError,
|
|
392
|
+
'%WeakMap%': typeof WeakMap === 'undefined' ? undefined$1 : WeakMap,
|
|
393
|
+
'%WeakRef%': typeof WeakRef === 'undefined' ? undefined$1 : WeakRef,
|
|
394
|
+
'%WeakSet%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet
|
|
395
|
+
};
|
|
396
|
+
if (getProto) {
|
|
397
|
+
try {
|
|
398
|
+
null.error; // eslint-disable-line no-unused-expressions
|
|
399
|
+
} catch (e) {
|
|
400
|
+
// https://github.com/tc39/proposal-shadowrealm/pull/384#issuecomment-1364264229
|
|
401
|
+
var errorProto = getProto(getProto(e));
|
|
402
|
+
INTRINSICS['%Error.prototype%'] = errorProto;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
var doEval = function doEval(name) {
|
|
406
|
+
var value;
|
|
407
|
+
if (name === '%AsyncFunction%') {
|
|
408
|
+
value = getEvalledConstructor('async function () {}');
|
|
409
|
+
} else if (name === '%GeneratorFunction%') {
|
|
410
|
+
value = getEvalledConstructor('function* () {}');
|
|
411
|
+
} else if (name === '%AsyncGeneratorFunction%') {
|
|
412
|
+
value = getEvalledConstructor('async function* () {}');
|
|
413
|
+
} else if (name === '%AsyncGenerator%') {
|
|
414
|
+
var fn = doEval('%AsyncGeneratorFunction%');
|
|
415
|
+
if (fn) {
|
|
416
|
+
value = fn.prototype;
|
|
417
|
+
}
|
|
418
|
+
} else if (name === '%AsyncIteratorPrototype%') {
|
|
419
|
+
var gen = doEval('%AsyncGenerator%');
|
|
420
|
+
if (gen && getProto) {
|
|
421
|
+
value = getProto(gen.prototype);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
INTRINSICS[name] = value;
|
|
425
|
+
return value;
|
|
426
|
+
};
|
|
427
|
+
var LEGACY_ALIASES = {
|
|
428
|
+
'%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],
|
|
429
|
+
'%ArrayPrototype%': ['Array', 'prototype'],
|
|
430
|
+
'%ArrayProto_entries%': ['Array', 'prototype', 'entries'],
|
|
431
|
+
'%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'],
|
|
432
|
+
'%ArrayProto_keys%': ['Array', 'prototype', 'keys'],
|
|
433
|
+
'%ArrayProto_values%': ['Array', 'prototype', 'values'],
|
|
434
|
+
'%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'],
|
|
435
|
+
'%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'],
|
|
436
|
+
'%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'],
|
|
437
|
+
'%BooleanPrototype%': ['Boolean', 'prototype'],
|
|
438
|
+
'%DataViewPrototype%': ['DataView', 'prototype'],
|
|
439
|
+
'%DatePrototype%': ['Date', 'prototype'],
|
|
440
|
+
'%ErrorPrototype%': ['Error', 'prototype'],
|
|
441
|
+
'%EvalErrorPrototype%': ['EvalError', 'prototype'],
|
|
442
|
+
'%Float32ArrayPrototype%': ['Float32Array', 'prototype'],
|
|
443
|
+
'%Float64ArrayPrototype%': ['Float64Array', 'prototype'],
|
|
444
|
+
'%FunctionPrototype%': ['Function', 'prototype'],
|
|
445
|
+
'%Generator%': ['GeneratorFunction', 'prototype'],
|
|
446
|
+
'%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'],
|
|
447
|
+
'%Int8ArrayPrototype%': ['Int8Array', 'prototype'],
|
|
448
|
+
'%Int16ArrayPrototype%': ['Int16Array', 'prototype'],
|
|
449
|
+
'%Int32ArrayPrototype%': ['Int32Array', 'prototype'],
|
|
450
|
+
'%JSONParse%': ['JSON', 'parse'],
|
|
451
|
+
'%JSONStringify%': ['JSON', 'stringify'],
|
|
452
|
+
'%MapPrototype%': ['Map', 'prototype'],
|
|
453
|
+
'%NumberPrototype%': ['Number', 'prototype'],
|
|
454
|
+
'%ObjectPrototype%': ['Object', 'prototype'],
|
|
455
|
+
'%ObjProto_toString%': ['Object', 'prototype', 'toString'],
|
|
456
|
+
'%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'],
|
|
457
|
+
'%PromisePrototype%': ['Promise', 'prototype'],
|
|
458
|
+
'%PromiseProto_then%': ['Promise', 'prototype', 'then'],
|
|
459
|
+
'%Promise_all%': ['Promise', 'all'],
|
|
460
|
+
'%Promise_reject%': ['Promise', 'reject'],
|
|
461
|
+
'%Promise_resolve%': ['Promise', 'resolve'],
|
|
462
|
+
'%RangeErrorPrototype%': ['RangeError', 'prototype'],
|
|
463
|
+
'%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'],
|
|
464
|
+
'%RegExpPrototype%': ['RegExp', 'prototype'],
|
|
465
|
+
'%SetPrototype%': ['Set', 'prototype'],
|
|
466
|
+
'%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'],
|
|
467
|
+
'%StringPrototype%': ['String', 'prototype'],
|
|
468
|
+
'%SymbolPrototype%': ['Symbol', 'prototype'],
|
|
469
|
+
'%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'],
|
|
470
|
+
'%TypedArrayPrototype%': ['TypedArray', 'prototype'],
|
|
471
|
+
'%TypeErrorPrototype%': ['TypeError', 'prototype'],
|
|
472
|
+
'%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'],
|
|
473
|
+
'%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'],
|
|
474
|
+
'%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'],
|
|
475
|
+
'%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'],
|
|
476
|
+
'%URIErrorPrototype%': ['URIError', 'prototype'],
|
|
477
|
+
'%WeakMapPrototype%': ['WeakMap', 'prototype'],
|
|
478
|
+
'%WeakSetPrototype%': ['WeakSet', 'prototype']
|
|
479
|
+
};
|
|
480
|
+
var $concat = functionBind.call(Function.call, Array.prototype.concat);
|
|
481
|
+
var $spliceApply = functionBind.call(Function.apply, Array.prototype.splice);
|
|
482
|
+
var $replace = functionBind.call(Function.call, String.prototype.replace);
|
|
483
|
+
var $strSlice = functionBind.call(Function.call, String.prototype.slice);
|
|
484
|
+
var $exec = functionBind.call(Function.call, RegExp.prototype.exec);
|
|
485
|
+
|
|
486
|
+
/* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
|
|
487
|
+
var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
|
|
488
|
+
var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */
|
|
489
|
+
var stringToPath = function stringToPath(string) {
|
|
490
|
+
var first = $strSlice(string, 0, 1);
|
|
491
|
+
var last = $strSlice(string, -1);
|
|
492
|
+
if (first === '%' && last !== '%') {
|
|
493
|
+
throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
|
|
494
|
+
} else if (last === '%' && first !== '%') {
|
|
495
|
+
throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
|
|
496
|
+
}
|
|
497
|
+
var result = [];
|
|
498
|
+
$replace(string, rePropName, function (match, number, quote, subString) {
|
|
499
|
+
result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match;
|
|
500
|
+
});
|
|
501
|
+
return result;
|
|
502
|
+
};
|
|
503
|
+
/* end adaptation */
|
|
504
|
+
|
|
505
|
+
var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
|
|
506
|
+
var intrinsicName = name;
|
|
507
|
+
var alias;
|
|
508
|
+
if (hasown(LEGACY_ALIASES, intrinsicName)) {
|
|
509
|
+
alias = LEGACY_ALIASES[intrinsicName];
|
|
510
|
+
intrinsicName = '%' + alias[0] + '%';
|
|
511
|
+
}
|
|
512
|
+
if (hasown(INTRINSICS, intrinsicName)) {
|
|
513
|
+
var value = INTRINSICS[intrinsicName];
|
|
514
|
+
if (value === needsEval) {
|
|
515
|
+
value = doEval(intrinsicName);
|
|
516
|
+
}
|
|
517
|
+
if (typeof value === 'undefined' && !allowMissing) {
|
|
518
|
+
throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
|
|
519
|
+
}
|
|
520
|
+
return {
|
|
521
|
+
alias: alias,
|
|
522
|
+
name: intrinsicName,
|
|
523
|
+
value: value
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
throw new $SyntaxError('intrinsic ' + name + ' does not exist!');
|
|
527
|
+
};
|
|
528
|
+
var getIntrinsic = function GetIntrinsic(name, allowMissing) {
|
|
529
|
+
if (typeof name !== 'string' || name.length === 0) {
|
|
530
|
+
throw new $TypeError('intrinsic name must be a non-empty string');
|
|
531
|
+
}
|
|
532
|
+
if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
|
|
533
|
+
throw new $TypeError('"allowMissing" argument must be a boolean');
|
|
534
|
+
}
|
|
535
|
+
if ($exec(/^%?[^%]*%?$/, name) === null) {
|
|
536
|
+
throw new $SyntaxError('`%` may not be present anywhere but at the beginning and end of the intrinsic name');
|
|
537
|
+
}
|
|
538
|
+
var parts = stringToPath(name);
|
|
539
|
+
var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
|
|
540
|
+
var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
|
|
541
|
+
var intrinsicRealName = intrinsic.name;
|
|
542
|
+
var value = intrinsic.value;
|
|
543
|
+
var skipFurtherCaching = false;
|
|
544
|
+
var alias = intrinsic.alias;
|
|
545
|
+
if (alias) {
|
|
546
|
+
intrinsicBaseName = alias[0];
|
|
547
|
+
$spliceApply(parts, $concat([0, 1], alias));
|
|
548
|
+
}
|
|
549
|
+
for (var i = 1, isOwn = true; i < parts.length; i += 1) {
|
|
550
|
+
var part = parts[i];
|
|
551
|
+
var first = $strSlice(part, 0, 1);
|
|
552
|
+
var last = $strSlice(part, -1);
|
|
553
|
+
if ((first === '"' || first === "'" || first === '`' || last === '"' || last === "'" || last === '`') && first !== last) {
|
|
554
|
+
throw new $SyntaxError('property names with quotes must have matching quotes');
|
|
555
|
+
}
|
|
556
|
+
if (part === 'constructor' || !isOwn) {
|
|
557
|
+
skipFurtherCaching = true;
|
|
558
|
+
}
|
|
559
|
+
intrinsicBaseName += '.' + part;
|
|
560
|
+
intrinsicRealName = '%' + intrinsicBaseName + '%';
|
|
561
|
+
if (hasown(INTRINSICS, intrinsicRealName)) {
|
|
562
|
+
value = INTRINSICS[intrinsicRealName];
|
|
563
|
+
} else if (value != null) {
|
|
564
|
+
if (!(part in value)) {
|
|
565
|
+
if (!allowMissing) {
|
|
566
|
+
throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
|
|
567
|
+
}
|
|
568
|
+
return void undefined$1;
|
|
569
|
+
}
|
|
570
|
+
if ($gOPD && i + 1 >= parts.length) {
|
|
571
|
+
var desc = $gOPD(value, part);
|
|
572
|
+
isOwn = !!desc;
|
|
573
|
+
|
|
574
|
+
// By convention, when a data property is converted to an accessor
|
|
575
|
+
// property to emulate a data property that does not suffer from
|
|
576
|
+
// the override mistake, that accessor's getter is marked with
|
|
577
|
+
// an `originalValue` property. Here, when we detect this, we
|
|
578
|
+
// uphold the illusion by pretending to see that original data
|
|
579
|
+
// property, i.e., returning the value rather than the getter
|
|
580
|
+
// itself.
|
|
581
|
+
if (isOwn && 'get' in desc && !('originalValue' in desc.get)) {
|
|
582
|
+
value = desc.get;
|
|
583
|
+
} else {
|
|
584
|
+
value = value[part];
|
|
585
|
+
}
|
|
586
|
+
} else {
|
|
587
|
+
isOwn = hasown(value, part);
|
|
588
|
+
value = value[part];
|
|
589
|
+
}
|
|
590
|
+
if (isOwn && !skipFurtherCaching) {
|
|
591
|
+
INTRINSICS[intrinsicRealName] = value;
|
|
187
592
|
}
|
|
188
593
|
}
|
|
189
|
-
}
|
|
594
|
+
}
|
|
595
|
+
return value;
|
|
596
|
+
};
|
|
190
597
|
|
|
191
|
-
|
|
192
|
-
}();
|
|
598
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
193
599
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
600
|
+
function createCommonjsModule(fn, basedir, module) {
|
|
601
|
+
return module = {
|
|
602
|
+
path: basedir,
|
|
603
|
+
exports: {},
|
|
604
|
+
require: function (path, base) {
|
|
605
|
+
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
|
|
606
|
+
}
|
|
607
|
+
}, fn(module, module.exports), module.exports;
|
|
608
|
+
}
|
|
197
609
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
_classCallCheck(this, Popup);
|
|
610
|
+
function commonjsRequire () {
|
|
611
|
+
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
|
|
612
|
+
}
|
|
202
613
|
|
|
203
|
-
|
|
204
|
-
|
|
614
|
+
var $defineProperty = getIntrinsic('%Object.defineProperty%', true);
|
|
615
|
+
var hasPropertyDescriptors = function hasPropertyDescriptors() {
|
|
616
|
+
if ($defineProperty) {
|
|
617
|
+
try {
|
|
618
|
+
$defineProperty({}, 'a', {
|
|
619
|
+
value: 1
|
|
620
|
+
});
|
|
621
|
+
return true;
|
|
622
|
+
} catch (e) {
|
|
623
|
+
// IE 8 has a broken defineProperty
|
|
624
|
+
return false;
|
|
625
|
+
}
|
|
205
626
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
627
|
+
return false;
|
|
628
|
+
};
|
|
629
|
+
hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBug() {
|
|
630
|
+
// node v0.6 has a bug where array lengths can be Set but not Defined
|
|
631
|
+
if (!hasPropertyDescriptors()) {
|
|
632
|
+
return null;
|
|
633
|
+
}
|
|
634
|
+
try {
|
|
635
|
+
return $defineProperty([], 'length', {
|
|
636
|
+
value: 1
|
|
637
|
+
}).length !== 1;
|
|
638
|
+
} catch (e) {
|
|
639
|
+
// In Firefox 4-22, defining length on an array throws an exception.
|
|
640
|
+
return true;
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
var hasPropertyDescriptors_1 = hasPropertyDescriptors;
|
|
210
644
|
|
|
645
|
+
var $gOPD$1 = getIntrinsic('%Object.getOwnPropertyDescriptor%', true);
|
|
646
|
+
if ($gOPD$1) {
|
|
647
|
+
try {
|
|
648
|
+
$gOPD$1([], 'length');
|
|
649
|
+
} catch (e) {
|
|
650
|
+
// IE 8 has a broken gOPD
|
|
651
|
+
$gOPD$1 = null;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
var gopd = $gOPD$1;
|
|
211
655
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
656
|
+
var hasPropertyDescriptors$1 = hasPropertyDescriptors_1();
|
|
657
|
+
var $defineProperty$1 = hasPropertyDescriptors$1 && getIntrinsic('%Object.defineProperty%', true);
|
|
658
|
+
if ($defineProperty$1) {
|
|
659
|
+
try {
|
|
660
|
+
$defineProperty$1({}, 'a', {
|
|
661
|
+
value: 1
|
|
662
|
+
});
|
|
663
|
+
} catch (e) {
|
|
664
|
+
// IE 8 has a broken defineProperty
|
|
665
|
+
$defineProperty$1 = false;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
var $SyntaxError$1 = getIntrinsic('%SyntaxError%');
|
|
669
|
+
var $TypeError$1 = getIntrinsic('%TypeError%');
|
|
216
670
|
|
|
217
|
-
|
|
218
|
-
|
|
671
|
+
/** @type {(obj: Record<PropertyKey, unknown>, property: PropertyKey, value: unknown, nonEnumerable?: boolean | null, nonWritable?: boolean | null, nonConfigurable?: boolean | null, loose?: boolean) => void} */
|
|
672
|
+
var defineDataProperty = function defineDataProperty(obj, property, value) {
|
|
673
|
+
if (!obj || typeof obj !== 'object' && typeof obj !== 'function') {
|
|
674
|
+
throw new $TypeError$1('`obj` must be an object or a function`');
|
|
675
|
+
}
|
|
676
|
+
if (typeof property !== 'string' && typeof property !== 'symbol') {
|
|
677
|
+
throw new $TypeError$1('`property` must be a string or a symbol`');
|
|
678
|
+
}
|
|
679
|
+
if (arguments.length > 3 && typeof arguments[3] !== 'boolean' && arguments[3] !== null) {
|
|
680
|
+
throw new $TypeError$1('`nonEnumerable`, if provided, must be a boolean or null');
|
|
681
|
+
}
|
|
682
|
+
if (arguments.length > 4 && typeof arguments[4] !== 'boolean' && arguments[4] !== null) {
|
|
683
|
+
throw new $TypeError$1('`nonWritable`, if provided, must be a boolean or null');
|
|
684
|
+
}
|
|
685
|
+
if (arguments.length > 5 && typeof arguments[5] !== 'boolean' && arguments[5] !== null) {
|
|
686
|
+
throw new $TypeError$1('`nonConfigurable`, if provided, must be a boolean or null');
|
|
687
|
+
}
|
|
688
|
+
if (arguments.length > 6 && typeof arguments[6] !== 'boolean') {
|
|
689
|
+
throw new $TypeError$1('`loose`, if provided, must be a boolean');
|
|
690
|
+
}
|
|
691
|
+
var nonEnumerable = arguments.length > 3 ? arguments[3] : null;
|
|
692
|
+
var nonWritable = arguments.length > 4 ? arguments[4] : null;
|
|
693
|
+
var nonConfigurable = arguments.length > 5 ? arguments[5] : null;
|
|
694
|
+
var loose = arguments.length > 6 ? arguments[6] : false;
|
|
219
695
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
696
|
+
/* @type {false | TypedPropertyDescriptor<unknown>} */
|
|
697
|
+
var desc = !!gopd && gopd(obj, property);
|
|
698
|
+
if ($defineProperty$1) {
|
|
699
|
+
$defineProperty$1(obj, property, {
|
|
700
|
+
configurable: nonConfigurable === null && desc ? desc.configurable : !nonConfigurable,
|
|
701
|
+
enumerable: nonEnumerable === null && desc ? desc.enumerable : !nonEnumerable,
|
|
702
|
+
value: value,
|
|
703
|
+
writable: nonWritable === null && desc ? desc.writable : !nonWritable
|
|
704
|
+
});
|
|
705
|
+
} else if (loose || !nonEnumerable && !nonWritable && !nonConfigurable) {
|
|
706
|
+
// must fall back to [[Set]], and was not explicitly asked to make non-enumerable, non-writable, or non-configurable
|
|
707
|
+
obj[property] = value; // eslint-disable-line no-param-reassign
|
|
708
|
+
} else {
|
|
709
|
+
throw new $SyntaxError$1('This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.');
|
|
710
|
+
}
|
|
711
|
+
};
|
|
229
712
|
|
|
230
|
-
|
|
231
|
-
|
|
713
|
+
var hasDescriptors = hasPropertyDescriptors_1();
|
|
714
|
+
var $TypeError$2 = getIntrinsic('%TypeError%');
|
|
715
|
+
var $floor = getIntrinsic('%Math.floor%');
|
|
716
|
+
var setFunctionLength = function setFunctionLength(fn, length) {
|
|
717
|
+
if (typeof fn !== 'function') {
|
|
718
|
+
throw new $TypeError$2('`fn` is not a function');
|
|
719
|
+
}
|
|
720
|
+
if (typeof length !== 'number' || length < 0 || length > 0xFFFFFFFF || $floor(length) !== length) {
|
|
721
|
+
throw new $TypeError$2('`length` must be a positive 32-bit integer');
|
|
722
|
+
}
|
|
723
|
+
var loose = arguments.length > 2 && !!arguments[2];
|
|
724
|
+
var functionLengthIsConfigurable = true;
|
|
725
|
+
var functionLengthIsWritable = true;
|
|
726
|
+
if ('length' in fn && gopd) {
|
|
727
|
+
var desc = gopd(fn, 'length');
|
|
728
|
+
if (desc && !desc.configurable) {
|
|
729
|
+
functionLengthIsConfigurable = false;
|
|
730
|
+
}
|
|
731
|
+
if (desc && !desc.writable) {
|
|
732
|
+
functionLengthIsWritable = false;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
if (functionLengthIsConfigurable || functionLengthIsWritable || !loose) {
|
|
736
|
+
if (hasDescriptors) {
|
|
737
|
+
defineDataProperty(fn, 'length', length, true, true);
|
|
738
|
+
} else {
|
|
739
|
+
defineDataProperty(fn, 'length', length);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
return fn;
|
|
743
|
+
};
|
|
232
744
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
745
|
+
var callBind = createCommonjsModule(function (module) {
|
|
746
|
+
|
|
747
|
+
var $TypeError = getIntrinsic('%TypeError%');
|
|
748
|
+
var $apply = getIntrinsic('%Function.prototype.apply%');
|
|
749
|
+
var $call = getIntrinsic('%Function.prototype.call%');
|
|
750
|
+
var $reflectApply = getIntrinsic('%Reflect.apply%', true) || functionBind.call($call, $apply);
|
|
751
|
+
var $defineProperty = getIntrinsic('%Object.defineProperty%', true);
|
|
752
|
+
var $max = getIntrinsic('%Math.max%');
|
|
753
|
+
if ($defineProperty) {
|
|
754
|
+
try {
|
|
755
|
+
$defineProperty({}, 'a', {
|
|
756
|
+
value: 1
|
|
757
|
+
});
|
|
758
|
+
} catch (e) {
|
|
759
|
+
// IE 8 has a broken defineProperty
|
|
760
|
+
$defineProperty = null;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
module.exports = function callBind(originalFunction) {
|
|
764
|
+
if (typeof originalFunction !== 'function') {
|
|
765
|
+
throw new $TypeError('a function is required');
|
|
766
|
+
}
|
|
767
|
+
var func = $reflectApply(functionBind, $call, arguments);
|
|
768
|
+
return setFunctionLength(func, 1 + $max(0, originalFunction.length - (arguments.length - 1)), true);
|
|
769
|
+
};
|
|
770
|
+
var applyBind = function applyBind() {
|
|
771
|
+
return $reflectApply(functionBind, $apply, arguments);
|
|
772
|
+
};
|
|
773
|
+
if ($defineProperty) {
|
|
774
|
+
$defineProperty(module.exports, 'apply', {
|
|
775
|
+
value: applyBind
|
|
776
|
+
});
|
|
777
|
+
} else {
|
|
778
|
+
module.exports.apply = applyBind;
|
|
779
|
+
}
|
|
780
|
+
});
|
|
236
781
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
782
|
+
var $indexOf = callBind(getIntrinsic('String.prototype.indexOf'));
|
|
783
|
+
var callBound = function callBoundIntrinsic(name, allowMissing) {
|
|
784
|
+
var intrinsic = getIntrinsic(name, !!allowMissing);
|
|
785
|
+
if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
|
|
786
|
+
return callBind(intrinsic);
|
|
787
|
+
}
|
|
788
|
+
return intrinsic;
|
|
789
|
+
};
|
|
790
|
+
|
|
791
|
+
var util_inspect = require$$0__default['default'].inspect;
|
|
792
|
+
|
|
793
|
+
var hasMap = typeof Map === 'function' && Map.prototype;
|
|
794
|
+
var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
|
|
795
|
+
var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;
|
|
796
|
+
var mapForEach = hasMap && Map.prototype.forEach;
|
|
797
|
+
var hasSet = typeof Set === 'function' && Set.prototype;
|
|
798
|
+
var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null;
|
|
799
|
+
var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null;
|
|
800
|
+
var setForEach = hasSet && Set.prototype.forEach;
|
|
801
|
+
var hasWeakMap = typeof WeakMap === 'function' && WeakMap.prototype;
|
|
802
|
+
var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null;
|
|
803
|
+
var hasWeakSet = typeof WeakSet === 'function' && WeakSet.prototype;
|
|
804
|
+
var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null;
|
|
805
|
+
var hasWeakRef = typeof WeakRef === 'function' && WeakRef.prototype;
|
|
806
|
+
var weakRefDeref = hasWeakRef ? WeakRef.prototype.deref : null;
|
|
807
|
+
var booleanValueOf = Boolean.prototype.valueOf;
|
|
808
|
+
var objectToString = Object.prototype.toString;
|
|
809
|
+
var functionToString = Function.prototype.toString;
|
|
810
|
+
var $match = String.prototype.match;
|
|
811
|
+
var $slice = String.prototype.slice;
|
|
812
|
+
var $replace$1 = String.prototype.replace;
|
|
813
|
+
var $toUpperCase = String.prototype.toUpperCase;
|
|
814
|
+
var $toLowerCase = String.prototype.toLowerCase;
|
|
815
|
+
var $test = RegExp.prototype.test;
|
|
816
|
+
var $concat$1 = Array.prototype.concat;
|
|
817
|
+
var $join = Array.prototype.join;
|
|
818
|
+
var $arrSlice = Array.prototype.slice;
|
|
819
|
+
var $floor$1 = Math.floor;
|
|
820
|
+
var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
|
|
821
|
+
var gOPS = Object.getOwnPropertySymbols;
|
|
822
|
+
var symToString = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? Symbol.prototype.toString : null;
|
|
823
|
+
var hasShammedSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'object';
|
|
824
|
+
// ie, `has-tostringtag/shams
|
|
825
|
+
var toStringTag = typeof Symbol === 'function' && Symbol.toStringTag && (typeof Symbol.toStringTag === hasShammedSymbols ? 'object' : 'symbol') ? Symbol.toStringTag : null;
|
|
826
|
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
|
827
|
+
var gPO = (typeof Reflect === 'function' ? Reflect.getPrototypeOf : Object.getPrototypeOf) || ([].__proto__ === Array.prototype // eslint-disable-line no-proto
|
|
828
|
+
? function (O) {
|
|
829
|
+
return O.__proto__; // eslint-disable-line no-proto
|
|
830
|
+
} : null);
|
|
831
|
+
function addNumericSeparator(num, str) {
|
|
832
|
+
if (num === Infinity || num === -Infinity || num !== num || num && num > -1000 && num < 1000 || $test.call(/e/, str)) {
|
|
833
|
+
return str;
|
|
834
|
+
}
|
|
835
|
+
var sepRegex = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;
|
|
836
|
+
if (typeof num === 'number') {
|
|
837
|
+
var int = num < 0 ? -$floor$1(-num) : $floor$1(num); // trunc(num)
|
|
838
|
+
if (int !== num) {
|
|
839
|
+
var intStr = String(int);
|
|
840
|
+
var dec = $slice.call(str, intStr.length + 1);
|
|
841
|
+
return $replace$1.call(intStr, sepRegex, '$&_') + '.' + $replace$1.call($replace$1.call(dec, /([0-9]{3})/g, '$&_'), /_$/, '');
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
return $replace$1.call(str, sepRegex, '$&_');
|
|
845
|
+
}
|
|
846
|
+
var inspectCustom = util_inspect.custom;
|
|
847
|
+
var inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null;
|
|
848
|
+
var objectInspect = function inspect_(obj, options, depth, seen) {
|
|
849
|
+
var opts = options || {};
|
|
850
|
+
if (has(opts, 'quoteStyle') && opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double') {
|
|
851
|
+
throw new TypeError('option "quoteStyle" must be "single" or "double"');
|
|
852
|
+
}
|
|
853
|
+
if (has(opts, 'maxStringLength') && (typeof opts.maxStringLength === 'number' ? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity : opts.maxStringLength !== null)) {
|
|
854
|
+
throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');
|
|
855
|
+
}
|
|
856
|
+
var customInspect = has(opts, 'customInspect') ? opts.customInspect : true;
|
|
857
|
+
if (typeof customInspect !== 'boolean' && customInspect !== 'symbol') {
|
|
858
|
+
throw new TypeError('option "customInspect", if provided, must be `true`, `false`, or `\'symbol\'`');
|
|
859
|
+
}
|
|
860
|
+
if (has(opts, 'indent') && opts.indent !== null && opts.indent !== '\t' && !(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0)) {
|
|
861
|
+
throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');
|
|
862
|
+
}
|
|
863
|
+
if (has(opts, 'numericSeparator') && typeof opts.numericSeparator !== 'boolean') {
|
|
864
|
+
throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');
|
|
865
|
+
}
|
|
866
|
+
var numericSeparator = opts.numericSeparator;
|
|
867
|
+
if (typeof obj === 'undefined') {
|
|
868
|
+
return 'undefined';
|
|
869
|
+
}
|
|
870
|
+
if (obj === null) {
|
|
871
|
+
return 'null';
|
|
872
|
+
}
|
|
873
|
+
if (typeof obj === 'boolean') {
|
|
874
|
+
return obj ? 'true' : 'false';
|
|
875
|
+
}
|
|
876
|
+
if (typeof obj === 'string') {
|
|
877
|
+
return inspectString(obj, opts);
|
|
878
|
+
}
|
|
879
|
+
if (typeof obj === 'number') {
|
|
880
|
+
if (obj === 0) {
|
|
881
|
+
return Infinity / obj > 0 ? '0' : '-0';
|
|
882
|
+
}
|
|
883
|
+
var str = String(obj);
|
|
884
|
+
return numericSeparator ? addNumericSeparator(obj, str) : str;
|
|
885
|
+
}
|
|
886
|
+
if (typeof obj === 'bigint') {
|
|
887
|
+
var bigIntStr = String(obj) + 'n';
|
|
888
|
+
return numericSeparator ? addNumericSeparator(obj, bigIntStr) : bigIntStr;
|
|
889
|
+
}
|
|
890
|
+
var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
|
|
891
|
+
if (typeof depth === 'undefined') {
|
|
892
|
+
depth = 0;
|
|
893
|
+
}
|
|
894
|
+
if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {
|
|
895
|
+
return isArray(obj) ? '[Array]' : '[Object]';
|
|
896
|
+
}
|
|
897
|
+
var indent = getIndent(opts, depth);
|
|
898
|
+
if (typeof seen === 'undefined') {
|
|
899
|
+
seen = [];
|
|
900
|
+
} else if (indexOf(seen, obj) >= 0) {
|
|
901
|
+
return '[Circular]';
|
|
902
|
+
}
|
|
903
|
+
function inspect(value, from, noIndent) {
|
|
904
|
+
if (from) {
|
|
905
|
+
seen = $arrSlice.call(seen);
|
|
906
|
+
seen.push(from);
|
|
907
|
+
}
|
|
908
|
+
if (noIndent) {
|
|
909
|
+
var newOpts = {
|
|
910
|
+
depth: opts.depth
|
|
911
|
+
};
|
|
912
|
+
if (has(opts, 'quoteStyle')) {
|
|
913
|
+
newOpts.quoteStyle = opts.quoteStyle;
|
|
914
|
+
}
|
|
915
|
+
return inspect_(value, newOpts, depth + 1, seen);
|
|
916
|
+
}
|
|
917
|
+
return inspect_(value, opts, depth + 1, seen);
|
|
918
|
+
}
|
|
919
|
+
if (typeof obj === 'function' && !isRegExp(obj)) {
|
|
920
|
+
// in older engines, regexes are callable
|
|
921
|
+
var name = nameOf(obj);
|
|
922
|
+
var keys = arrObjKeys(obj, inspect);
|
|
923
|
+
return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']' + (keys.length > 0 ? ' { ' + $join.call(keys, ', ') + ' }' : '');
|
|
924
|
+
}
|
|
925
|
+
if (isSymbol(obj)) {
|
|
926
|
+
var symString = hasShammedSymbols ? $replace$1.call(String(obj), /^(Symbol\(.*\))_[^)]*$/, '$1') : symToString.call(obj);
|
|
927
|
+
return typeof obj === 'object' && !hasShammedSymbols ? markBoxed(symString) : symString;
|
|
928
|
+
}
|
|
929
|
+
if (isElement(obj)) {
|
|
930
|
+
var s = '<' + $toLowerCase.call(String(obj.nodeName));
|
|
931
|
+
var attrs = obj.attributes || [];
|
|
932
|
+
for (var i = 0; i < attrs.length; i++) {
|
|
933
|
+
s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts);
|
|
934
|
+
}
|
|
935
|
+
s += '>';
|
|
936
|
+
if (obj.childNodes && obj.childNodes.length) {
|
|
937
|
+
s += '...';
|
|
938
|
+
}
|
|
939
|
+
s += '</' + $toLowerCase.call(String(obj.nodeName)) + '>';
|
|
940
|
+
return s;
|
|
941
|
+
}
|
|
942
|
+
if (isArray(obj)) {
|
|
943
|
+
if (obj.length === 0) {
|
|
944
|
+
return '[]';
|
|
945
|
+
}
|
|
946
|
+
var xs = arrObjKeys(obj, inspect);
|
|
947
|
+
if (indent && !singleLineValues(xs)) {
|
|
948
|
+
return '[' + indentedJoin(xs, indent) + ']';
|
|
949
|
+
}
|
|
950
|
+
return '[ ' + $join.call(xs, ', ') + ' ]';
|
|
951
|
+
}
|
|
952
|
+
if (isError(obj)) {
|
|
953
|
+
var parts = arrObjKeys(obj, inspect);
|
|
954
|
+
if (!('cause' in Error.prototype) && 'cause' in obj && !isEnumerable.call(obj, 'cause')) {
|
|
955
|
+
return '{ [' + String(obj) + '] ' + $join.call($concat$1.call('[cause]: ' + inspect(obj.cause), parts), ', ') + ' }';
|
|
956
|
+
}
|
|
957
|
+
if (parts.length === 0) {
|
|
958
|
+
return '[' + String(obj) + ']';
|
|
959
|
+
}
|
|
960
|
+
return '{ [' + String(obj) + '] ' + $join.call(parts, ', ') + ' }';
|
|
961
|
+
}
|
|
962
|
+
if (typeof obj === 'object' && customInspect) {
|
|
963
|
+
if (inspectSymbol && typeof obj[inspectSymbol] === 'function' && util_inspect) {
|
|
964
|
+
return util_inspect(obj, {
|
|
965
|
+
depth: maxDepth - depth
|
|
243
966
|
});
|
|
967
|
+
} else if (customInspect !== 'symbol' && typeof obj.inspect === 'function') {
|
|
968
|
+
return obj.inspect();
|
|
244
969
|
}
|
|
245
|
-
}
|
|
970
|
+
}
|
|
971
|
+
if (isMap(obj)) {
|
|
972
|
+
var mapParts = [];
|
|
973
|
+
if (mapForEach) {
|
|
974
|
+
mapForEach.call(obj, function (value, key) {
|
|
975
|
+
mapParts.push(inspect(key, obj, true) + ' => ' + inspect(value, obj));
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
return collectionOf('Map', mapSize.call(obj), mapParts, indent);
|
|
979
|
+
}
|
|
980
|
+
if (isSet(obj)) {
|
|
981
|
+
var setParts = [];
|
|
982
|
+
if (setForEach) {
|
|
983
|
+
setForEach.call(obj, function (value) {
|
|
984
|
+
setParts.push(inspect(value, obj));
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
return collectionOf('Set', setSize.call(obj), setParts, indent);
|
|
988
|
+
}
|
|
989
|
+
if (isWeakMap(obj)) {
|
|
990
|
+
return weakCollectionOf('WeakMap');
|
|
991
|
+
}
|
|
992
|
+
if (isWeakSet(obj)) {
|
|
993
|
+
return weakCollectionOf('WeakSet');
|
|
994
|
+
}
|
|
995
|
+
if (isWeakRef(obj)) {
|
|
996
|
+
return weakCollectionOf('WeakRef');
|
|
997
|
+
}
|
|
998
|
+
if (isNumber(obj)) {
|
|
999
|
+
return markBoxed(inspect(Number(obj)));
|
|
1000
|
+
}
|
|
1001
|
+
if (isBigInt(obj)) {
|
|
1002
|
+
return markBoxed(inspect(bigIntValueOf.call(obj)));
|
|
1003
|
+
}
|
|
1004
|
+
if (isBoolean(obj)) {
|
|
1005
|
+
return markBoxed(booleanValueOf.call(obj));
|
|
1006
|
+
}
|
|
1007
|
+
if (isString(obj)) {
|
|
1008
|
+
return markBoxed(inspect(String(obj)));
|
|
1009
|
+
}
|
|
1010
|
+
// note: in IE 8, sometimes `global !== window` but both are the prototypes of each other
|
|
1011
|
+
/* eslint-env browser */
|
|
1012
|
+
if (typeof window !== 'undefined' && obj === window) {
|
|
1013
|
+
return '{ [object Window] }';
|
|
1014
|
+
}
|
|
1015
|
+
if (obj === commonjsGlobal) {
|
|
1016
|
+
return '{ [object globalThis] }';
|
|
1017
|
+
}
|
|
1018
|
+
if (!isDate(obj) && !isRegExp(obj)) {
|
|
1019
|
+
var ys = arrObjKeys(obj, inspect);
|
|
1020
|
+
var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
|
|
1021
|
+
var protoTag = obj instanceof Object ? '' : 'null prototype';
|
|
1022
|
+
var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr$1(obj), 8, -1) : protoTag ? 'Object' : '';
|
|
1023
|
+
var constructorTag = isPlainObject || typeof obj.constructor !== 'function' ? '' : obj.constructor.name ? obj.constructor.name + ' ' : '';
|
|
1024
|
+
var tag = constructorTag + (stringTag || protoTag ? '[' + $join.call($concat$1.call([], stringTag || [], protoTag || []), ': ') + '] ' : '');
|
|
1025
|
+
if (ys.length === 0) {
|
|
1026
|
+
return tag + '{}';
|
|
1027
|
+
}
|
|
1028
|
+
if (indent) {
|
|
1029
|
+
return tag + '{' + indentedJoin(ys, indent) + '}';
|
|
1030
|
+
}
|
|
1031
|
+
return tag + '{ ' + $join.call(ys, ', ') + ' }';
|
|
1032
|
+
}
|
|
1033
|
+
return String(obj);
|
|
1034
|
+
};
|
|
1035
|
+
function wrapQuotes(s, defaultStyle, opts) {
|
|
1036
|
+
var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'";
|
|
1037
|
+
return quoteChar + s + quoteChar;
|
|
1038
|
+
}
|
|
1039
|
+
function quote(s) {
|
|
1040
|
+
return $replace$1.call(String(s), /"/g, '"');
|
|
1041
|
+
}
|
|
1042
|
+
function isArray(obj) {
|
|
1043
|
+
return toStr$1(obj) === '[object Array]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1044
|
+
}
|
|
1045
|
+
function isDate(obj) {
|
|
1046
|
+
return toStr$1(obj) === '[object Date]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1047
|
+
}
|
|
1048
|
+
function isRegExp(obj) {
|
|
1049
|
+
return toStr$1(obj) === '[object RegExp]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1050
|
+
}
|
|
1051
|
+
function isError(obj) {
|
|
1052
|
+
return toStr$1(obj) === '[object Error]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1053
|
+
}
|
|
1054
|
+
function isString(obj) {
|
|
1055
|
+
return toStr$1(obj) === '[object String]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1056
|
+
}
|
|
1057
|
+
function isNumber(obj) {
|
|
1058
|
+
return toStr$1(obj) === '[object Number]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1059
|
+
}
|
|
1060
|
+
function isBoolean(obj) {
|
|
1061
|
+
return toStr$1(obj) === '[object Boolean]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1062
|
+
}
|
|
246
1063
|
|
|
247
|
-
|
|
248
|
-
|
|
1064
|
+
// Symbol and BigInt do have Symbol.toStringTag by spec, so that can't be used to eliminate false positives
|
|
1065
|
+
function isSymbol(obj) {
|
|
1066
|
+
if (hasShammedSymbols) {
|
|
1067
|
+
return obj && typeof obj === 'object' && obj instanceof Symbol;
|
|
1068
|
+
}
|
|
1069
|
+
if (typeof obj === 'symbol') {
|
|
1070
|
+
return true;
|
|
1071
|
+
}
|
|
1072
|
+
if (!obj || typeof obj !== 'object' || !symToString) {
|
|
1073
|
+
return false;
|
|
1074
|
+
}
|
|
1075
|
+
try {
|
|
1076
|
+
symToString.call(obj);
|
|
1077
|
+
return true;
|
|
1078
|
+
} catch (e) {}
|
|
1079
|
+
return false;
|
|
1080
|
+
}
|
|
1081
|
+
function isBigInt(obj) {
|
|
1082
|
+
if (!obj || typeof obj !== 'object' || !bigIntValueOf) {
|
|
1083
|
+
return false;
|
|
1084
|
+
}
|
|
1085
|
+
try {
|
|
1086
|
+
bigIntValueOf.call(obj);
|
|
1087
|
+
return true;
|
|
1088
|
+
} catch (e) {}
|
|
1089
|
+
return false;
|
|
1090
|
+
}
|
|
1091
|
+
var hasOwn = Object.prototype.hasOwnProperty || function (key) {
|
|
1092
|
+
return key in this;
|
|
1093
|
+
};
|
|
1094
|
+
function has(obj, key) {
|
|
1095
|
+
return hasOwn.call(obj, key);
|
|
1096
|
+
}
|
|
1097
|
+
function toStr$1(obj) {
|
|
1098
|
+
return objectToString.call(obj);
|
|
1099
|
+
}
|
|
1100
|
+
function nameOf(f) {
|
|
1101
|
+
if (f.name) {
|
|
1102
|
+
return f.name;
|
|
1103
|
+
}
|
|
1104
|
+
var m = $match.call(functionToString.call(f), /^function\s*([\w$]+)/);
|
|
1105
|
+
if (m) {
|
|
1106
|
+
return m[1];
|
|
1107
|
+
}
|
|
1108
|
+
return null;
|
|
1109
|
+
}
|
|
1110
|
+
function indexOf(xs, x) {
|
|
1111
|
+
if (xs.indexOf) {
|
|
1112
|
+
return xs.indexOf(x);
|
|
1113
|
+
}
|
|
1114
|
+
for (var i = 0, l = xs.length; i < l; i++) {
|
|
1115
|
+
if (xs[i] === x) {
|
|
1116
|
+
return i;
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
return -1;
|
|
1120
|
+
}
|
|
1121
|
+
function isMap(x) {
|
|
1122
|
+
if (!mapSize || !x || typeof x !== 'object') {
|
|
1123
|
+
return false;
|
|
1124
|
+
}
|
|
1125
|
+
try {
|
|
1126
|
+
mapSize.call(x);
|
|
1127
|
+
try {
|
|
1128
|
+
setSize.call(x);
|
|
1129
|
+
} catch (s) {
|
|
1130
|
+
return true;
|
|
1131
|
+
}
|
|
1132
|
+
return x instanceof Map; // core-js workaround, pre-v2.5.0
|
|
1133
|
+
} catch (e) {}
|
|
1134
|
+
return false;
|
|
1135
|
+
}
|
|
1136
|
+
function isWeakMap(x) {
|
|
1137
|
+
if (!weakMapHas || !x || typeof x !== 'object') {
|
|
1138
|
+
return false;
|
|
1139
|
+
}
|
|
1140
|
+
try {
|
|
1141
|
+
weakMapHas.call(x, weakMapHas);
|
|
1142
|
+
try {
|
|
1143
|
+
weakSetHas.call(x, weakSetHas);
|
|
1144
|
+
} catch (s) {
|
|
1145
|
+
return true;
|
|
1146
|
+
}
|
|
1147
|
+
return x instanceof WeakMap; // core-js workaround, pre-v2.5.0
|
|
1148
|
+
} catch (e) {}
|
|
1149
|
+
return false;
|
|
1150
|
+
}
|
|
1151
|
+
function isWeakRef(x) {
|
|
1152
|
+
if (!weakRefDeref || !x || typeof x !== 'object') {
|
|
1153
|
+
return false;
|
|
1154
|
+
}
|
|
1155
|
+
try {
|
|
1156
|
+
weakRefDeref.call(x);
|
|
1157
|
+
return true;
|
|
1158
|
+
} catch (e) {}
|
|
1159
|
+
return false;
|
|
1160
|
+
}
|
|
1161
|
+
function isSet(x) {
|
|
1162
|
+
if (!setSize || !x || typeof x !== 'object') {
|
|
1163
|
+
return false;
|
|
1164
|
+
}
|
|
1165
|
+
try {
|
|
1166
|
+
setSize.call(x);
|
|
1167
|
+
try {
|
|
1168
|
+
mapSize.call(x);
|
|
1169
|
+
} catch (m) {
|
|
1170
|
+
return true;
|
|
1171
|
+
}
|
|
1172
|
+
return x instanceof Set; // core-js workaround, pre-v2.5.0
|
|
1173
|
+
} catch (e) {}
|
|
1174
|
+
return false;
|
|
1175
|
+
}
|
|
1176
|
+
function isWeakSet(x) {
|
|
1177
|
+
if (!weakSetHas || !x || typeof x !== 'object') {
|
|
1178
|
+
return false;
|
|
1179
|
+
}
|
|
1180
|
+
try {
|
|
1181
|
+
weakSetHas.call(x, weakSetHas);
|
|
1182
|
+
try {
|
|
1183
|
+
weakMapHas.call(x, weakMapHas);
|
|
1184
|
+
} catch (s) {
|
|
1185
|
+
return true;
|
|
1186
|
+
}
|
|
1187
|
+
return x instanceof WeakSet; // core-js workaround, pre-v2.5.0
|
|
1188
|
+
} catch (e) {}
|
|
1189
|
+
return false;
|
|
1190
|
+
}
|
|
1191
|
+
function isElement(x) {
|
|
1192
|
+
if (!x || typeof x !== 'object') {
|
|
1193
|
+
return false;
|
|
1194
|
+
}
|
|
1195
|
+
if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) {
|
|
1196
|
+
return true;
|
|
1197
|
+
}
|
|
1198
|
+
return typeof x.nodeName === 'string' && typeof x.getAttribute === 'function';
|
|
1199
|
+
}
|
|
1200
|
+
function inspectString(str, opts) {
|
|
1201
|
+
if (str.length > opts.maxStringLength) {
|
|
1202
|
+
var remaining = str.length - opts.maxStringLength;
|
|
1203
|
+
var trailer = '... ' + remaining + ' more character' + (remaining > 1 ? 's' : '');
|
|
1204
|
+
return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer;
|
|
1205
|
+
}
|
|
1206
|
+
// eslint-disable-next-line no-control-regex
|
|
1207
|
+
var s = $replace$1.call($replace$1.call(str, /(['\\])/g, '\\$1'), /[\x00-\x1f]/g, lowbyte);
|
|
1208
|
+
return wrapQuotes(s, 'single', opts);
|
|
1209
|
+
}
|
|
1210
|
+
function lowbyte(c) {
|
|
1211
|
+
var n = c.charCodeAt(0);
|
|
1212
|
+
var x = {
|
|
1213
|
+
8: 'b',
|
|
1214
|
+
9: 't',
|
|
1215
|
+
10: 'n',
|
|
1216
|
+
12: 'f',
|
|
1217
|
+
13: 'r'
|
|
1218
|
+
}[n];
|
|
1219
|
+
if (x) {
|
|
1220
|
+
return '\\' + x;
|
|
1221
|
+
}
|
|
1222
|
+
return '\\x' + (n < 0x10 ? '0' : '') + $toUpperCase.call(n.toString(16));
|
|
1223
|
+
}
|
|
1224
|
+
function markBoxed(str) {
|
|
1225
|
+
return 'Object(' + str + ')';
|
|
1226
|
+
}
|
|
1227
|
+
function weakCollectionOf(type) {
|
|
1228
|
+
return type + ' { ? }';
|
|
1229
|
+
}
|
|
1230
|
+
function collectionOf(type, size, entries, indent) {
|
|
1231
|
+
var joinedEntries = indent ? indentedJoin(entries, indent) : $join.call(entries, ', ');
|
|
1232
|
+
return type + ' (' + size + ') {' + joinedEntries + '}';
|
|
1233
|
+
}
|
|
1234
|
+
function singleLineValues(xs) {
|
|
1235
|
+
for (var i = 0; i < xs.length; i++) {
|
|
1236
|
+
if (indexOf(xs[i], '\n') >= 0) {
|
|
1237
|
+
return false;
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
return true;
|
|
1241
|
+
}
|
|
1242
|
+
function getIndent(opts, depth) {
|
|
1243
|
+
var baseIndent;
|
|
1244
|
+
if (opts.indent === '\t') {
|
|
1245
|
+
baseIndent = '\t';
|
|
1246
|
+
} else if (typeof opts.indent === 'number' && opts.indent > 0) {
|
|
1247
|
+
baseIndent = $join.call(Array(opts.indent + 1), ' ');
|
|
1248
|
+
} else {
|
|
1249
|
+
return null;
|
|
1250
|
+
}
|
|
1251
|
+
return {
|
|
1252
|
+
base: baseIndent,
|
|
1253
|
+
prev: $join.call(Array(depth + 1), baseIndent)
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
function indentedJoin(xs, indent) {
|
|
1257
|
+
if (xs.length === 0) {
|
|
1258
|
+
return '';
|
|
1259
|
+
}
|
|
1260
|
+
var lineJoiner = '\n' + indent.prev + indent.base;
|
|
1261
|
+
return lineJoiner + $join.call(xs, ',' + lineJoiner) + '\n' + indent.prev;
|
|
1262
|
+
}
|
|
1263
|
+
function arrObjKeys(obj, inspect) {
|
|
1264
|
+
var isArr = isArray(obj);
|
|
1265
|
+
var xs = [];
|
|
1266
|
+
if (isArr) {
|
|
1267
|
+
xs.length = obj.length;
|
|
1268
|
+
for (var i = 0; i < obj.length; i++) {
|
|
1269
|
+
xs[i] = has(obj, i) ? inspect(obj[i], obj) : '';
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
var syms = typeof gOPS === 'function' ? gOPS(obj) : [];
|
|
1273
|
+
var symMap;
|
|
1274
|
+
if (hasShammedSymbols) {
|
|
1275
|
+
symMap = {};
|
|
1276
|
+
for (var k = 0; k < syms.length; k++) {
|
|
1277
|
+
symMap['$' + syms[k]] = syms[k];
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
for (var key in obj) {
|
|
1281
|
+
// eslint-disable-line no-restricted-syntax
|
|
1282
|
+
if (!has(obj, key)) {
|
|
1283
|
+
continue;
|
|
1284
|
+
} // eslint-disable-line no-restricted-syntax, no-continue
|
|
1285
|
+
if (isArr && String(Number(key)) === key && key < obj.length) {
|
|
1286
|
+
continue;
|
|
1287
|
+
} // eslint-disable-line no-restricted-syntax, no-continue
|
|
1288
|
+
if (hasShammedSymbols && symMap['$' + key] instanceof Symbol) {
|
|
1289
|
+
// this is to prevent shammed Symbols, which are stored as strings, from being included in the string key section
|
|
1290
|
+
continue; // eslint-disable-line no-restricted-syntax, no-continue
|
|
1291
|
+
} else if ($test.call(/[^\w$]/, key)) {
|
|
1292
|
+
xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj));
|
|
1293
|
+
} else {
|
|
1294
|
+
xs.push(key + ': ' + inspect(obj[key], obj));
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
if (typeof gOPS === 'function') {
|
|
1298
|
+
for (var j = 0; j < syms.length; j++) {
|
|
1299
|
+
if (isEnumerable.call(obj, syms[j])) {
|
|
1300
|
+
xs.push('[' + inspect(syms[j]) + ']: ' + inspect(obj[syms[j]], obj));
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
return xs;
|
|
1305
|
+
}
|
|
249
1306
|
|
|
250
|
-
var
|
|
251
|
-
var
|
|
1307
|
+
var $TypeError$3 = getIntrinsic('%TypeError%');
|
|
1308
|
+
var $WeakMap = getIntrinsic('%WeakMap%', true);
|
|
1309
|
+
var $Map = getIntrinsic('%Map%', true);
|
|
1310
|
+
var $weakMapGet = callBound('WeakMap.prototype.get', true);
|
|
1311
|
+
var $weakMapSet = callBound('WeakMap.prototype.set', true);
|
|
1312
|
+
var $weakMapHas = callBound('WeakMap.prototype.has', true);
|
|
1313
|
+
var $mapGet = callBound('Map.prototype.get', true);
|
|
1314
|
+
var $mapSet = callBound('Map.prototype.set', true);
|
|
1315
|
+
var $mapHas = callBound('Map.prototype.has', true);
|
|
1316
|
+
|
|
1317
|
+
/*
|
|
1318
|
+
* This function traverses the list returning the node corresponding to the
|
|
1319
|
+
* given key.
|
|
1320
|
+
*
|
|
1321
|
+
* That node is also moved to the head of the list, so that if it's accessed
|
|
1322
|
+
* again we don't need to traverse the whole list. By doing so, all the recently
|
|
1323
|
+
* used nodes can be accessed relatively quickly.
|
|
1324
|
+
*/
|
|
1325
|
+
var listGetNode = function (list, key) {
|
|
1326
|
+
// eslint-disable-line consistent-return
|
|
1327
|
+
for (var prev = list, curr; (curr = prev.next) !== null; prev = curr) {
|
|
1328
|
+
if (curr.key === key) {
|
|
1329
|
+
prev.next = curr.next;
|
|
1330
|
+
curr.next = list.next;
|
|
1331
|
+
list.next = curr; // eslint-disable-line no-param-reassign
|
|
1332
|
+
return curr;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
};
|
|
1336
|
+
var listGet = function (objects, key) {
|
|
1337
|
+
var node = listGetNode(objects, key);
|
|
1338
|
+
return node && node.value;
|
|
1339
|
+
};
|
|
1340
|
+
var listSet = function (objects, key, value) {
|
|
1341
|
+
var node = listGetNode(objects, key);
|
|
1342
|
+
if (node) {
|
|
1343
|
+
node.value = value;
|
|
1344
|
+
} else {
|
|
1345
|
+
// Prepend the new node to the beginning of the list
|
|
1346
|
+
objects.next = {
|
|
1347
|
+
// eslint-disable-line no-param-reassign
|
|
1348
|
+
key: key,
|
|
1349
|
+
next: objects.next,
|
|
1350
|
+
value: value
|
|
1351
|
+
};
|
|
1352
|
+
}
|
|
1353
|
+
};
|
|
1354
|
+
var listHas = function (objects, key) {
|
|
1355
|
+
return !!listGetNode(objects, key);
|
|
1356
|
+
};
|
|
1357
|
+
var sideChannel = function getSideChannel() {
|
|
1358
|
+
var $wm;
|
|
1359
|
+
var $m;
|
|
1360
|
+
var $o;
|
|
1361
|
+
var channel = {
|
|
1362
|
+
assert: function (key) {
|
|
1363
|
+
if (!channel.has(key)) {
|
|
1364
|
+
throw new $TypeError$3('Side channel does not contain ' + objectInspect(key));
|
|
1365
|
+
}
|
|
1366
|
+
},
|
|
1367
|
+
get: function (key) {
|
|
1368
|
+
// eslint-disable-line consistent-return
|
|
1369
|
+
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
|
1370
|
+
if ($wm) {
|
|
1371
|
+
return $weakMapGet($wm, key);
|
|
1372
|
+
}
|
|
1373
|
+
} else if ($Map) {
|
|
1374
|
+
if ($m) {
|
|
1375
|
+
return $mapGet($m, key);
|
|
1376
|
+
}
|
|
1377
|
+
} else {
|
|
1378
|
+
if ($o) {
|
|
1379
|
+
// eslint-disable-line no-lonely-if
|
|
1380
|
+
return listGet($o, key);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
},
|
|
1384
|
+
has: function (key) {
|
|
1385
|
+
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
|
1386
|
+
if ($wm) {
|
|
1387
|
+
return $weakMapHas($wm, key);
|
|
1388
|
+
}
|
|
1389
|
+
} else if ($Map) {
|
|
1390
|
+
if ($m) {
|
|
1391
|
+
return $mapHas($m, key);
|
|
1392
|
+
}
|
|
1393
|
+
} else {
|
|
1394
|
+
if ($o) {
|
|
1395
|
+
// eslint-disable-line no-lonely-if
|
|
1396
|
+
return listHas($o, key);
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
return false;
|
|
1400
|
+
},
|
|
1401
|
+
set: function (key, value) {
|
|
1402
|
+
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
|
1403
|
+
if (!$wm) {
|
|
1404
|
+
$wm = new $WeakMap();
|
|
1405
|
+
}
|
|
1406
|
+
$weakMapSet($wm, key, value);
|
|
1407
|
+
} else if ($Map) {
|
|
1408
|
+
if (!$m) {
|
|
1409
|
+
$m = new $Map();
|
|
1410
|
+
}
|
|
1411
|
+
$mapSet($m, key, value);
|
|
1412
|
+
} else {
|
|
1413
|
+
if (!$o) {
|
|
1414
|
+
/*
|
|
1415
|
+
* Initialize the linked list as an empty node, so that we don't have
|
|
1416
|
+
* to special-case handling of the first node: we can always refer to
|
|
1417
|
+
* it as (previous node).next, instead of something like (list).head
|
|
1418
|
+
*/
|
|
1419
|
+
$o = {
|
|
1420
|
+
key: {},
|
|
1421
|
+
next: null
|
|
1422
|
+
};
|
|
1423
|
+
}
|
|
1424
|
+
listSet($o, key, value);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
};
|
|
1428
|
+
return channel;
|
|
1429
|
+
};
|
|
1430
|
+
|
|
1431
|
+
var replace = String.prototype.replace;
|
|
1432
|
+
var percentTwenties = /%20/g;
|
|
1433
|
+
var Format = {
|
|
1434
|
+
RFC1738: 'RFC1738',
|
|
1435
|
+
RFC3986: 'RFC3986'
|
|
1436
|
+
};
|
|
1437
|
+
var formats = {
|
|
1438
|
+
'default': Format.RFC3986,
|
|
1439
|
+
formatters: {
|
|
1440
|
+
RFC1738: function (value) {
|
|
1441
|
+
return replace.call(value, percentTwenties, '+');
|
|
1442
|
+
},
|
|
1443
|
+
RFC3986: function (value) {
|
|
1444
|
+
return String(value);
|
|
1445
|
+
}
|
|
1446
|
+
},
|
|
1447
|
+
RFC1738: Format.RFC1738,
|
|
1448
|
+
RFC3986: Format.RFC3986
|
|
1449
|
+
};
|
|
252
1450
|
|
|
1451
|
+
var has$1 = Object.prototype.hasOwnProperty;
|
|
1452
|
+
var isArray$1 = Array.isArray;
|
|
253
1453
|
var hexTable = function () {
|
|
254
1454
|
var array = [];
|
|
255
|
-
|
|
256
1455
|
for (var i = 0; i < 256; ++i) {
|
|
257
1456
|
array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
|
|
258
1457
|
}
|
|
259
|
-
|
|
260
1458
|
return array;
|
|
261
1459
|
}();
|
|
262
|
-
|
|
263
1460
|
var compactQueue = function compactQueue(queue) {
|
|
264
1461
|
while (queue.length > 1) {
|
|
265
1462
|
var item = queue.pop();
|
|
266
1463
|
var obj = item.obj[item.prop];
|
|
267
|
-
|
|
268
|
-
if (isArray(obj)) {
|
|
1464
|
+
if (isArray$1(obj)) {
|
|
269
1465
|
var compacted = [];
|
|
270
|
-
|
|
271
1466
|
for (var j = 0; j < obj.length; ++j) {
|
|
272
1467
|
if (typeof obj[j] !== 'undefined') {
|
|
273
1468
|
compacted.push(obj[j]);
|
|
274
1469
|
}
|
|
275
1470
|
}
|
|
276
|
-
|
|
277
1471
|
item.obj[item.prop] = compacted;
|
|
278
1472
|
}
|
|
279
1473
|
}
|
|
280
1474
|
};
|
|
281
|
-
|
|
282
1475
|
var arrayToObject = function arrayToObject(source, options) {
|
|
283
1476
|
var obj = options && options.plainObjects ? Object.create(null) : {};
|
|
284
|
-
|
|
285
1477
|
for (var i = 0; i < source.length; ++i) {
|
|
286
1478
|
if (typeof source[i] !== 'undefined') {
|
|
287
1479
|
obj[i] = source[i];
|
|
288
1480
|
}
|
|
289
1481
|
}
|
|
290
|
-
|
|
291
1482
|
return obj;
|
|
292
1483
|
};
|
|
293
|
-
|
|
294
1484
|
var merge = function merge(target, source, options) {
|
|
295
1485
|
/* eslint no-param-reassign: 0 */
|
|
296
1486
|
if (!source) {
|
|
297
1487
|
return target;
|
|
298
1488
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
if (isArray(target)) {
|
|
1489
|
+
if (typeof source !== 'object') {
|
|
1490
|
+
if (isArray$1(target)) {
|
|
302
1491
|
target.push(source);
|
|
303
|
-
} else if (target &&
|
|
304
|
-
if (options && (options.plainObjects || options.allowPrototypes) || !has.call(Object.prototype, source)) {
|
|
1492
|
+
} else if (target && typeof target === 'object') {
|
|
1493
|
+
if (options && (options.plainObjects || options.allowPrototypes) || !has$1.call(Object.prototype, source)) {
|
|
305
1494
|
target[source] = true;
|
|
306
1495
|
}
|
|
307
1496
|
} else {
|
|
308
1497
|
return [target, source];
|
|
309
1498
|
}
|
|
310
|
-
|
|
311
1499
|
return target;
|
|
312
1500
|
}
|
|
313
|
-
|
|
314
|
-
if (!target || _typeof(target) !== 'object') {
|
|
1501
|
+
if (!target || typeof target !== 'object') {
|
|
315
1502
|
return [target].concat(source);
|
|
316
1503
|
}
|
|
317
|
-
|
|
318
1504
|
var mergeTarget = target;
|
|
319
|
-
|
|
320
|
-
if (isArray(target) && !isArray(source)) {
|
|
1505
|
+
if (isArray$1(target) && !isArray$1(source)) {
|
|
321
1506
|
mergeTarget = arrayToObject(target, options);
|
|
322
1507
|
}
|
|
323
|
-
|
|
324
|
-
if (isArray(target) && isArray(source)) {
|
|
1508
|
+
if (isArray$1(target) && isArray$1(source)) {
|
|
325
1509
|
source.forEach(function (item, i) {
|
|
326
|
-
if (has.call(target, i)) {
|
|
1510
|
+
if (has$1.call(target, i)) {
|
|
327
1511
|
var targetItem = target[i];
|
|
328
|
-
|
|
329
|
-
if (targetItem && _typeof(targetItem) === 'object' && item && _typeof(item) === 'object') {
|
|
1512
|
+
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
|
330
1513
|
target[i] = merge(targetItem, item, options);
|
|
331
1514
|
} else {
|
|
332
1515
|
target.push(item);
|
|
@@ -337,69 +1520,55 @@
|
|
|
337
1520
|
});
|
|
338
1521
|
return target;
|
|
339
1522
|
}
|
|
340
|
-
|
|
341
1523
|
return Object.keys(source).reduce(function (acc, key) {
|
|
342
1524
|
var value = source[key];
|
|
343
|
-
|
|
344
|
-
if (has.call(acc, key)) {
|
|
1525
|
+
if (has$1.call(acc, key)) {
|
|
345
1526
|
acc[key] = merge(acc[key], value, options);
|
|
346
1527
|
} else {
|
|
347
1528
|
acc[key] = value;
|
|
348
1529
|
}
|
|
349
|
-
|
|
350
1530
|
return acc;
|
|
351
1531
|
}, mergeTarget);
|
|
352
1532
|
};
|
|
353
|
-
|
|
354
1533
|
var assign = function assignSingleSource(target, source) {
|
|
355
1534
|
return Object.keys(source).reduce(function (acc, key) {
|
|
356
1535
|
acc[key] = source[key];
|
|
357
1536
|
return acc;
|
|
358
1537
|
}, target);
|
|
359
1538
|
};
|
|
360
|
-
|
|
361
|
-
var decode = function decode(str, decoder, charset) {
|
|
1539
|
+
var decode = function (str, decoder, charset) {
|
|
362
1540
|
var strWithoutPlus = str.replace(/\+/g, ' ');
|
|
363
|
-
|
|
364
1541
|
if (charset === 'iso-8859-1') {
|
|
365
1542
|
// unescape never throws, no try...catch needed:
|
|
366
1543
|
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
|
|
1544
|
+
}
|
|
1545
|
+
// utf-8
|
|
370
1546
|
try {
|
|
371
1547
|
return decodeURIComponent(strWithoutPlus);
|
|
372
1548
|
} catch (e) {
|
|
373
1549
|
return strWithoutPlus;
|
|
374
1550
|
}
|
|
375
1551
|
};
|
|
376
|
-
|
|
377
|
-
var encode = function encode(str, defaultEncoder, charset) {
|
|
1552
|
+
var encode = function encode(str, defaultEncoder, charset, kind, format) {
|
|
378
1553
|
// This code was originally written by Brian White (mscdex) for the io.js core querystring library.
|
|
379
1554
|
// It has been adapted here for stricter adherence to RFC 3986
|
|
380
1555
|
if (str.length === 0) {
|
|
381
1556
|
return str;
|
|
382
1557
|
}
|
|
383
|
-
|
|
384
1558
|
var string = str;
|
|
385
|
-
|
|
386
|
-
if (_typeof(str) === 'symbol') {
|
|
1559
|
+
if (typeof str === 'symbol') {
|
|
387
1560
|
string = Symbol.prototype.toString.call(str);
|
|
388
1561
|
} else if (typeof str !== 'string') {
|
|
389
1562
|
string = String(str);
|
|
390
1563
|
}
|
|
391
|
-
|
|
392
1564
|
if (charset === 'iso-8859-1') {
|
|
393
1565
|
return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
|
|
394
1566
|
return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
|
|
395
1567
|
});
|
|
396
1568
|
}
|
|
397
|
-
|
|
398
1569
|
var out = '';
|
|
399
|
-
|
|
400
1570
|
for (var i = 0; i < string.length; ++i) {
|
|
401
1571
|
var c = string.charCodeAt(i);
|
|
402
|
-
|
|
403
1572
|
if (c === 0x2D // -
|
|
404
1573
|
|| c === 0x2E // .
|
|
405
1574
|
|| c === 0x5F // _
|
|
@@ -407,34 +1576,30 @@
|
|
|
407
1576
|
|| c >= 0x30 && c <= 0x39 // 0-9
|
|
408
1577
|
|| c >= 0x41 && c <= 0x5A // a-z
|
|
409
1578
|
|| c >= 0x61 && c <= 0x7A // A-Z
|
|
1579
|
+
|| format === formats.RFC1738 && (c === 0x28 || c === 0x29) // ( )
|
|
410
1580
|
) {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
1581
|
+
out += string.charAt(i);
|
|
1582
|
+
continue;
|
|
1583
|
+
}
|
|
415
1584
|
if (c < 0x80) {
|
|
416
1585
|
out = out + hexTable[c];
|
|
417
1586
|
continue;
|
|
418
1587
|
}
|
|
419
|
-
|
|
420
1588
|
if (c < 0x800) {
|
|
421
1589
|
out = out + (hexTable[0xC0 | c >> 6] + hexTable[0x80 | c & 0x3F]);
|
|
422
1590
|
continue;
|
|
423
1591
|
}
|
|
424
|
-
|
|
425
1592
|
if (c < 0xD800 || c >= 0xE000) {
|
|
426
1593
|
out = out + (hexTable[0xE0 | c >> 12] + hexTable[0x80 | c >> 6 & 0x3F] + hexTable[0x80 | c & 0x3F]);
|
|
427
1594
|
continue;
|
|
428
1595
|
}
|
|
429
|
-
|
|
430
1596
|
i += 1;
|
|
431
1597
|
c = 0x10000 + ((c & 0x3FF) << 10 | string.charCodeAt(i) & 0x3FF);
|
|
1598
|
+
/* eslint operator-linebreak: [2, "before"] */
|
|
432
1599
|
out += hexTable[0xF0 | c >> 18] + hexTable[0x80 | c >> 12 & 0x3F] + hexTable[0x80 | c >> 6 & 0x3F] + hexTable[0x80 | c & 0x3F];
|
|
433
1600
|
}
|
|
434
|
-
|
|
435
1601
|
return out;
|
|
436
1602
|
};
|
|
437
|
-
|
|
438
1603
|
var compact = function compact(value) {
|
|
439
1604
|
var queue = [{
|
|
440
1605
|
obj: {
|
|
@@ -443,17 +1608,14 @@
|
|
|
443
1608
|
prop: 'o'
|
|
444
1609
|
}];
|
|
445
1610
|
var refs = [];
|
|
446
|
-
|
|
447
1611
|
for (var i = 0; i < queue.length; ++i) {
|
|
448
1612
|
var item = queue[i];
|
|
449
1613
|
var obj = item.obj[item.prop];
|
|
450
1614
|
var keys = Object.keys(obj);
|
|
451
|
-
|
|
452
1615
|
for (var j = 0; j < keys.length; ++j) {
|
|
453
1616
|
var key = keys[j];
|
|
454
1617
|
var val = obj[key];
|
|
455
|
-
|
|
456
|
-
if (_typeof(val) === 'object' && val !== null && refs.indexOf(val) === -1) {
|
|
1618
|
+
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
|
|
457
1619
|
queue.push({
|
|
458
1620
|
obj: obj,
|
|
459
1621
|
prop: key
|
|
@@ -462,41 +1624,31 @@
|
|
|
462
1624
|
}
|
|
463
1625
|
}
|
|
464
1626
|
}
|
|
465
|
-
|
|
466
1627
|
compactQueue(queue);
|
|
467
1628
|
return value;
|
|
468
1629
|
};
|
|
469
|
-
|
|
470
|
-
var isRegExp = function isRegExp(obj) {
|
|
1630
|
+
var isRegExp$1 = function isRegExp(obj) {
|
|
471
1631
|
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
|
472
1632
|
};
|
|
473
|
-
|
|
474
1633
|
var isBuffer = function isBuffer(obj) {
|
|
475
|
-
if (!obj ||
|
|
1634
|
+
if (!obj || typeof obj !== 'object') {
|
|
476
1635
|
return false;
|
|
477
1636
|
}
|
|
478
|
-
|
|
479
1637
|
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
|
480
1638
|
};
|
|
481
|
-
|
|
482
1639
|
var combine = function combine(a, b) {
|
|
483
1640
|
return [].concat(a, b);
|
|
484
1641
|
};
|
|
485
|
-
|
|
486
1642
|
var maybeMap = function maybeMap(val, fn) {
|
|
487
|
-
if (isArray(val)) {
|
|
1643
|
+
if (isArray$1(val)) {
|
|
488
1644
|
var mapped = [];
|
|
489
|
-
|
|
490
1645
|
for (var i = 0; i < val.length; i += 1) {
|
|
491
1646
|
mapped.push(fn(val[i]));
|
|
492
1647
|
}
|
|
493
|
-
|
|
494
1648
|
return mapped;
|
|
495
1649
|
}
|
|
496
|
-
|
|
497
1650
|
return fn(val);
|
|
498
1651
|
};
|
|
499
|
-
|
|
500
1652
|
var utils = {
|
|
501
1653
|
arrayToObject: arrayToObject,
|
|
502
1654
|
assign: assign,
|
|
@@ -505,30 +1657,12 @@
|
|
|
505
1657
|
decode: decode,
|
|
506
1658
|
encode: encode,
|
|
507
1659
|
isBuffer: isBuffer,
|
|
508
|
-
isRegExp: isRegExp,
|
|
1660
|
+
isRegExp: isRegExp$1,
|
|
509
1661
|
maybeMap: maybeMap,
|
|
510
1662
|
merge: merge
|
|
511
1663
|
};
|
|
512
1664
|
|
|
513
|
-
var
|
|
514
|
-
var percentTwenties = /%20/g;
|
|
515
|
-
var Format = {
|
|
516
|
-
RFC1738: 'RFC1738',
|
|
517
|
-
RFC3986: 'RFC3986'
|
|
518
|
-
};
|
|
519
|
-
var formats = utils.assign({
|
|
520
|
-
'default': Format.RFC3986,
|
|
521
|
-
formatters: {
|
|
522
|
-
RFC1738: function RFC1738(value) {
|
|
523
|
-
return replace.call(value, percentTwenties, '+');
|
|
524
|
-
},
|
|
525
|
-
RFC3986: function RFC3986(value) {
|
|
526
|
-
return String(value);
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
}, Format);
|
|
530
|
-
|
|
531
|
-
var has$1 = Object.prototype.hasOwnProperty;
|
|
1665
|
+
var has$2 = Object.prototype.hasOwnProperty;
|
|
532
1666
|
var arrayPrefixGenerators = {
|
|
533
1667
|
brackets: function brackets(prefix) {
|
|
534
1668
|
return prefix + '[]';
|
|
@@ -541,13 +1675,11 @@
|
|
|
541
1675
|
return prefix;
|
|
542
1676
|
}
|
|
543
1677
|
};
|
|
544
|
-
var isArray$
|
|
1678
|
+
var isArray$2 = Array.isArray;
|
|
545
1679
|
var push = Array.prototype.push;
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
push.apply(arr, isArray$1(valueOrArray) ? valueOrArray : [valueOrArray]);
|
|
1680
|
+
var pushToArray = function (arr, valueOrArray) {
|
|
1681
|
+
push.apply(arr, isArray$2(valueOrArray) ? valueOrArray : [valueOrArray]);
|
|
549
1682
|
};
|
|
550
|
-
|
|
551
1683
|
var toISO = Date.prototype.toISOString;
|
|
552
1684
|
var defaultFormat = formats['default'];
|
|
553
1685
|
var defaults = {
|
|
@@ -569,107 +1701,112 @@
|
|
|
569
1701
|
skipNulls: false,
|
|
570
1702
|
strictNullHandling: false
|
|
571
1703
|
};
|
|
572
|
-
|
|
573
1704
|
var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
|
|
574
|
-
return typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' ||
|
|
1705
|
+
return typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || typeof v === 'symbol' || typeof v === 'bigint';
|
|
575
1706
|
};
|
|
576
|
-
|
|
577
|
-
var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate, formatter, encodeValuesOnly, charset) {
|
|
1707
|
+
var sentinel = {};
|
|
1708
|
+
var stringify = function stringify(object, prefix, generateArrayPrefix, commaRoundTrip, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, sideChannel$1) {
|
|
578
1709
|
var obj = object;
|
|
579
|
-
|
|
1710
|
+
var tmpSc = sideChannel$1;
|
|
1711
|
+
var step = 0;
|
|
1712
|
+
var findFlag = false;
|
|
1713
|
+
while ((tmpSc = tmpSc.get(sentinel)) !== void undefined && !findFlag) {
|
|
1714
|
+
// Where object last appeared in the ref tree
|
|
1715
|
+
var pos = tmpSc.get(object);
|
|
1716
|
+
step += 1;
|
|
1717
|
+
if (typeof pos !== 'undefined') {
|
|
1718
|
+
if (pos === step) {
|
|
1719
|
+
throw new RangeError('Cyclic object value');
|
|
1720
|
+
} else {
|
|
1721
|
+
findFlag = true; // Break while
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
if (typeof tmpSc.get(sentinel) === 'undefined') {
|
|
1725
|
+
step = 0;
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
580
1728
|
if (typeof filter === 'function') {
|
|
581
1729
|
obj = filter(prefix, obj);
|
|
582
1730
|
} else if (obj instanceof Date) {
|
|
583
1731
|
obj = serializeDate(obj);
|
|
584
|
-
} else if (generateArrayPrefix === 'comma' && isArray$
|
|
1732
|
+
} else if (generateArrayPrefix === 'comma' && isArray$2(obj)) {
|
|
585
1733
|
obj = utils.maybeMap(obj, function (value) {
|
|
586
1734
|
if (value instanceof Date) {
|
|
587
1735
|
return serializeDate(value);
|
|
588
1736
|
}
|
|
589
|
-
|
|
590
1737
|
return value;
|
|
591
|
-
})
|
|
1738
|
+
});
|
|
592
1739
|
}
|
|
593
|
-
|
|
594
1740
|
if (obj === null) {
|
|
595
1741
|
if (strictNullHandling) {
|
|
596
|
-
return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key') : prefix;
|
|
1742
|
+
return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key', format) : prefix;
|
|
597
1743
|
}
|
|
598
|
-
|
|
599
1744
|
obj = '';
|
|
600
1745
|
}
|
|
601
|
-
|
|
602
1746
|
if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) {
|
|
603
1747
|
if (encoder) {
|
|
604
|
-
var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, 'key');
|
|
605
|
-
return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value'))];
|
|
1748
|
+
var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, 'key', format);
|
|
1749
|
+
return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value', format))];
|
|
606
1750
|
}
|
|
607
|
-
|
|
608
1751
|
return [formatter(prefix) + '=' + formatter(String(obj))];
|
|
609
1752
|
}
|
|
610
|
-
|
|
611
1753
|
var values = [];
|
|
612
|
-
|
|
613
1754
|
if (typeof obj === 'undefined') {
|
|
614
1755
|
return values;
|
|
615
1756
|
}
|
|
616
|
-
|
|
617
1757
|
var objKeys;
|
|
618
|
-
|
|
619
|
-
|
|
1758
|
+
if (generateArrayPrefix === 'comma' && isArray$2(obj)) {
|
|
1759
|
+
// we need to join elements in
|
|
1760
|
+
if (encodeValuesOnly && encoder) {
|
|
1761
|
+
obj = utils.maybeMap(obj, encoder);
|
|
1762
|
+
}
|
|
1763
|
+
objKeys = [{
|
|
1764
|
+
value: obj.length > 0 ? obj.join(',') || null : void undefined
|
|
1765
|
+
}];
|
|
1766
|
+
} else if (isArray$2(filter)) {
|
|
620
1767
|
objKeys = filter;
|
|
621
1768
|
} else {
|
|
622
1769
|
var keys = Object.keys(obj);
|
|
623
1770
|
objKeys = sort ? keys.sort(sort) : keys;
|
|
624
1771
|
}
|
|
625
|
-
|
|
626
|
-
for (var
|
|
627
|
-
var key = objKeys[
|
|
628
|
-
var value = obj[key];
|
|
629
|
-
|
|
1772
|
+
var adjustedPrefix = commaRoundTrip && isArray$2(obj) && obj.length === 1 ? prefix + '[]' : prefix;
|
|
1773
|
+
for (var j = 0; j < objKeys.length; ++j) {
|
|
1774
|
+
var key = objKeys[j];
|
|
1775
|
+
var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];
|
|
630
1776
|
if (skipNulls && value === null) {
|
|
631
1777
|
continue;
|
|
632
1778
|
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
1779
|
+
var keyPrefix = isArray$2(obj) ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, key) : adjustedPrefix : adjustedPrefix + (allowDots ? '.' + key : '[' + key + ']');
|
|
1780
|
+
sideChannel$1.set(object, step);
|
|
1781
|
+
var valueSideChannel = sideChannel();
|
|
1782
|
+
valueSideChannel.set(sentinel, sideChannel$1);
|
|
1783
|
+
pushToArray(values, stringify(value, keyPrefix, generateArrayPrefix, commaRoundTrip, strictNullHandling, skipNulls, generateArrayPrefix === 'comma' && encodeValuesOnly && isArray$2(obj) ? null : encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, valueSideChannel));
|
|
636
1784
|
}
|
|
637
|
-
|
|
638
1785
|
return values;
|
|
639
1786
|
};
|
|
640
|
-
|
|
641
1787
|
var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
|
|
642
1788
|
if (!opts) {
|
|
643
1789
|
return defaults;
|
|
644
1790
|
}
|
|
645
|
-
|
|
646
|
-
if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') {
|
|
1791
|
+
if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') {
|
|
647
1792
|
throw new TypeError('Encoder has to be a function.');
|
|
648
1793
|
}
|
|
649
|
-
|
|
650
1794
|
var charset = opts.charset || defaults.charset;
|
|
651
|
-
|
|
652
1795
|
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
|
|
653
1796
|
throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
|
|
654
1797
|
}
|
|
655
|
-
|
|
656
1798
|
var format = formats['default'];
|
|
657
|
-
|
|
658
1799
|
if (typeof opts.format !== 'undefined') {
|
|
659
|
-
if (!has$
|
|
1800
|
+
if (!has$2.call(formats.formatters, opts.format)) {
|
|
660
1801
|
throw new TypeError('Unknown format option provided.');
|
|
661
1802
|
}
|
|
662
|
-
|
|
663
1803
|
format = opts.format;
|
|
664
1804
|
}
|
|
665
|
-
|
|
666
1805
|
var formatter = formats.formatters[format];
|
|
667
1806
|
var filter = defaults.filter;
|
|
668
|
-
|
|
669
|
-
if (typeof opts.filter === 'function' || isArray$1(opts.filter)) {
|
|
1807
|
+
if (typeof opts.filter === 'function' || isArray$2(opts.filter)) {
|
|
670
1808
|
filter = opts.filter;
|
|
671
1809
|
}
|
|
672
|
-
|
|
673
1810
|
return {
|
|
674
1811
|
addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix,
|
|
675
1812
|
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
|
|
@@ -680,6 +1817,7 @@
|
|
|
680
1817
|
encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder,
|
|
681
1818
|
encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly,
|
|
682
1819
|
filter: filter,
|
|
1820
|
+
format: format,
|
|
683
1821
|
formatter: formatter,
|
|
684
1822
|
serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate,
|
|
685
1823
|
skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls,
|
|
@@ -687,29 +1825,23 @@
|
|
|
687
1825
|
strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
|
|
688
1826
|
};
|
|
689
1827
|
};
|
|
690
|
-
|
|
691
|
-
var stringify_1 = function stringify_1(object, opts) {
|
|
1828
|
+
var stringify_1 = function (object, opts) {
|
|
692
1829
|
var obj = object;
|
|
693
1830
|
var options = normalizeStringifyOptions(opts);
|
|
694
1831
|
var objKeys;
|
|
695
1832
|
var filter;
|
|
696
|
-
|
|
697
1833
|
if (typeof options.filter === 'function') {
|
|
698
1834
|
filter = options.filter;
|
|
699
1835
|
obj = filter('', obj);
|
|
700
|
-
} else if (isArray$
|
|
1836
|
+
} else if (isArray$2(options.filter)) {
|
|
701
1837
|
filter = options.filter;
|
|
702
1838
|
objKeys = filter;
|
|
703
1839
|
}
|
|
704
|
-
|
|
705
1840
|
var keys = [];
|
|
706
|
-
|
|
707
|
-
if (_typeof(obj) !== 'object' || obj === null) {
|
|
1841
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
708
1842
|
return '';
|
|
709
1843
|
}
|
|
710
|
-
|
|
711
1844
|
var arrayFormat;
|
|
712
|
-
|
|
713
1845
|
if (opts && opts.arrayFormat in arrayPrefixGenerators) {
|
|
714
1846
|
arrayFormat = opts.arrayFormat;
|
|
715
1847
|
} else if (opts && 'indices' in opts) {
|
|
@@ -717,30 +1849,27 @@
|
|
|
717
1849
|
} else {
|
|
718
1850
|
arrayFormat = 'indices';
|
|
719
1851
|
}
|
|
720
|
-
|
|
721
1852
|
var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
|
|
722
|
-
|
|
1853
|
+
if (opts && 'commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') {
|
|
1854
|
+
throw new TypeError('`commaRoundTrip` must be a boolean, or absent');
|
|
1855
|
+
}
|
|
1856
|
+
var commaRoundTrip = generateArrayPrefix === 'comma' && opts && opts.commaRoundTrip;
|
|
723
1857
|
if (!objKeys) {
|
|
724
1858
|
objKeys = Object.keys(obj);
|
|
725
1859
|
}
|
|
726
|
-
|
|
727
1860
|
if (options.sort) {
|
|
728
1861
|
objKeys.sort(options.sort);
|
|
729
1862
|
}
|
|
730
|
-
|
|
1863
|
+
var sideChannel$1 = sideChannel();
|
|
731
1864
|
for (var i = 0; i < objKeys.length; ++i) {
|
|
732
1865
|
var key = objKeys[i];
|
|
733
|
-
|
|
734
1866
|
if (options.skipNulls && obj[key] === null) {
|
|
735
1867
|
continue;
|
|
736
1868
|
}
|
|
737
|
-
|
|
738
|
-
pushToArray(keys, stringify(obj[key], key, generateArrayPrefix, options.strictNullHandling, options.skipNulls, options.encode ? options.encoder : null, options.filter, options.sort, options.allowDots, options.serializeDate, options.formatter, options.encodeValuesOnly, options.charset));
|
|
1869
|
+
pushToArray(keys, stringify(obj[key], key, generateArrayPrefix, commaRoundTrip, options.strictNullHandling, options.skipNulls, options.encode ? options.encoder : null, options.filter, options.sort, options.allowDots, options.serializeDate, options.format, options.formatter, options.encodeValuesOnly, options.charset, sideChannel$1));
|
|
739
1870
|
}
|
|
740
|
-
|
|
741
1871
|
var joined = keys.join(options.delimiter);
|
|
742
1872
|
var prefix = options.addQueryPrefix === true ? '?' : '';
|
|
743
|
-
|
|
744
1873
|
if (options.charsetSentinel) {
|
|
745
1874
|
if (options.charset === 'iso-8859-1') {
|
|
746
1875
|
// encodeURIComponent('✓'), the "numeric entity" representation of a checkmark
|
|
@@ -750,15 +1879,15 @@
|
|
|
750
1879
|
prefix += 'utf8=%E2%9C%93&';
|
|
751
1880
|
}
|
|
752
1881
|
}
|
|
753
|
-
|
|
754
1882
|
return joined.length > 0 ? prefix + joined : '';
|
|
755
1883
|
};
|
|
756
1884
|
|
|
757
|
-
var has$
|
|
758
|
-
var isArray$
|
|
1885
|
+
var has$3 = Object.prototype.hasOwnProperty;
|
|
1886
|
+
var isArray$3 = Array.isArray;
|
|
759
1887
|
var defaults$1 = {
|
|
760
1888
|
allowDots: false,
|
|
761
1889
|
allowPrototypes: false,
|
|
1890
|
+
allowSparse: false,
|
|
762
1891
|
arrayLimit: 20,
|
|
763
1892
|
charset: 'utf-8',
|
|
764
1893
|
charsetSentinel: false,
|
|
@@ -773,41 +1902,38 @@
|
|
|
773
1902
|
plainObjects: false,
|
|
774
1903
|
strictNullHandling: false
|
|
775
1904
|
};
|
|
776
|
-
|
|
777
|
-
var interpretNumericEntities = function interpretNumericEntities(str) {
|
|
1905
|
+
var interpretNumericEntities = function (str) {
|
|
778
1906
|
return str.replace(/&#(\d+);/g, function ($0, numberStr) {
|
|
779
1907
|
return String.fromCharCode(parseInt(numberStr, 10));
|
|
780
1908
|
});
|
|
781
1909
|
};
|
|
782
|
-
|
|
783
|
-
var parseArrayValue = function parseArrayValue(val, options) {
|
|
1910
|
+
var parseArrayValue = function (val, options) {
|
|
784
1911
|
if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
|
|
785
1912
|
return val.split(',');
|
|
786
1913
|
}
|
|
787
|
-
|
|
788
1914
|
return val;
|
|
789
|
-
};
|
|
1915
|
+
};
|
|
1916
|
+
|
|
1917
|
+
// This is what browsers will submit when the ✓ character occurs in an
|
|
790
1918
|
// application/x-www-form-urlencoded body and the encoding of the page containing
|
|
791
1919
|
// the form is iso-8859-1, or when the submitted form has an accept-charset
|
|
792
1920
|
// attribute of iso-8859-1. Presumably also with other charsets that do not contain
|
|
793
1921
|
// the ✓ character, such as us-ascii.
|
|
794
|
-
|
|
795
|
-
|
|
796
1922
|
var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('✓')
|
|
797
|
-
// These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.
|
|
798
1923
|
|
|
1924
|
+
// These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.
|
|
799
1925
|
var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓')
|
|
800
1926
|
|
|
801
1927
|
var parseValues = function parseQueryStringValues(str, options) {
|
|
802
|
-
var obj = {
|
|
1928
|
+
var obj = {
|
|
1929
|
+
__proto__: null
|
|
1930
|
+
};
|
|
803
1931
|
var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
|
|
804
1932
|
var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
|
|
805
1933
|
var parts = cleanStr.split(options.delimiter, limit);
|
|
806
1934
|
var skipIndex = -1; // Keep track of where the utf8 sentinel was found
|
|
807
|
-
|
|
808
1935
|
var i;
|
|
809
1936
|
var charset = options.charset;
|
|
810
|
-
|
|
811
1937
|
if (options.charsetSentinel) {
|
|
812
1938
|
for (i = 0; i < parts.length; ++i) {
|
|
813
1939
|
if (parts[i].indexOf('utf8=') === 0) {
|
|
@@ -816,23 +1942,19 @@
|
|
|
816
1942
|
} else if (parts[i] === isoSentinel) {
|
|
817
1943
|
charset = 'iso-8859-1';
|
|
818
1944
|
}
|
|
819
|
-
|
|
820
1945
|
skipIndex = i;
|
|
821
1946
|
i = parts.length; // The eslint settings do not allow break;
|
|
822
1947
|
}
|
|
823
1948
|
}
|
|
824
1949
|
}
|
|
825
|
-
|
|
826
1950
|
for (i = 0; i < parts.length; ++i) {
|
|
827
1951
|
if (i === skipIndex) {
|
|
828
1952
|
continue;
|
|
829
1953
|
}
|
|
830
|
-
|
|
831
1954
|
var part = parts[i];
|
|
832
1955
|
var bracketEqualsPos = part.indexOf(']=');
|
|
833
1956
|
var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
|
|
834
1957
|
var key, val;
|
|
835
|
-
|
|
836
1958
|
if (pos === -1) {
|
|
837
1959
|
key = options.decoder(part, defaults$1.decoder, charset, 'key');
|
|
838
1960
|
val = options.strictNullHandling ? null : '';
|
|
@@ -842,39 +1964,31 @@
|
|
|
842
1964
|
return options.decoder(encodedVal, defaults$1.decoder, charset, 'value');
|
|
843
1965
|
});
|
|
844
1966
|
}
|
|
845
|
-
|
|
846
1967
|
if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
|
|
847
1968
|
val = interpretNumericEntities(val);
|
|
848
1969
|
}
|
|
849
|
-
|
|
850
1970
|
if (part.indexOf('[]=') > -1) {
|
|
851
|
-
val = isArray$
|
|
1971
|
+
val = isArray$3(val) ? [val] : val;
|
|
852
1972
|
}
|
|
853
|
-
|
|
854
|
-
if (has$2.call(obj, key)) {
|
|
1973
|
+
if (has$3.call(obj, key)) {
|
|
855
1974
|
obj[key] = utils.combine(obj[key], val);
|
|
856
1975
|
} else {
|
|
857
1976
|
obj[key] = val;
|
|
858
1977
|
}
|
|
859
1978
|
}
|
|
860
|
-
|
|
861
1979
|
return obj;
|
|
862
1980
|
};
|
|
863
|
-
|
|
864
|
-
var parseObject = function parseObject(chain, val, options, valuesParsed) {
|
|
1981
|
+
var parseObject = function (chain, val, options, valuesParsed) {
|
|
865
1982
|
var leaf = valuesParsed ? val : parseArrayValue(val, options);
|
|
866
|
-
|
|
867
1983
|
for (var i = chain.length - 1; i >= 0; --i) {
|
|
868
1984
|
var obj;
|
|
869
1985
|
var root = chain[i];
|
|
870
|
-
|
|
871
1986
|
if (root === '[]' && options.parseArrays) {
|
|
872
1987
|
obj = [].concat(leaf);
|
|
873
1988
|
} else {
|
|
874
1989
|
obj = options.plainObjects ? Object.create(null) : {};
|
|
875
1990
|
var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
|
|
876
1991
|
var index = parseInt(cleanRoot, 10);
|
|
877
|
-
|
|
878
1992
|
if (!options.parseArrays && cleanRoot === '') {
|
|
879
1993
|
obj = {
|
|
880
1994
|
0: leaf
|
|
@@ -882,84 +1996,80 @@
|
|
|
882
1996
|
} else if (!isNaN(index) && root !== cleanRoot && String(index) === cleanRoot && index >= 0 && options.parseArrays && index <= options.arrayLimit) {
|
|
883
1997
|
obj = [];
|
|
884
1998
|
obj[index] = leaf;
|
|
885
|
-
} else {
|
|
1999
|
+
} else if (cleanRoot !== '__proto__') {
|
|
886
2000
|
obj[cleanRoot] = leaf;
|
|
887
2001
|
}
|
|
888
2002
|
}
|
|
889
|
-
|
|
890
|
-
leaf = obj; // eslint-disable-line no-param-reassign
|
|
2003
|
+
leaf = obj;
|
|
891
2004
|
}
|
|
892
|
-
|
|
893
2005
|
return leaf;
|
|
894
2006
|
};
|
|
895
|
-
|
|
896
2007
|
var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
|
|
897
2008
|
if (!givenKey) {
|
|
898
2009
|
return;
|
|
899
|
-
}
|
|
2010
|
+
}
|
|
900
2011
|
|
|
2012
|
+
// Transform dot notation to bracket notation
|
|
2013
|
+
var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
|
|
901
2014
|
|
|
902
|
-
|
|
2015
|
+
// The regex chunks
|
|
903
2016
|
|
|
904
2017
|
var brackets = /(\[[^[\]]*])/;
|
|
905
|
-
var child = /(\[[^[\]]*])/g;
|
|
2018
|
+
var child = /(\[[^[\]]*])/g;
|
|
2019
|
+
|
|
2020
|
+
// Get the parent
|
|
906
2021
|
|
|
907
2022
|
var segment = options.depth > 0 && brackets.exec(key);
|
|
908
|
-
var parent = segment ? key.slice(0, segment.index) : key;
|
|
2023
|
+
var parent = segment ? key.slice(0, segment.index) : key;
|
|
909
2024
|
|
|
910
|
-
|
|
2025
|
+
// Stash the parent if it exists
|
|
911
2026
|
|
|
2027
|
+
var keys = [];
|
|
912
2028
|
if (parent) {
|
|
913
2029
|
// If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
|
|
914
|
-
if (!options.plainObjects && has$
|
|
2030
|
+
if (!options.plainObjects && has$3.call(Object.prototype, parent)) {
|
|
915
2031
|
if (!options.allowPrototypes) {
|
|
916
2032
|
return;
|
|
917
2033
|
}
|
|
918
2034
|
}
|
|
919
|
-
|
|
920
2035
|
keys.push(parent);
|
|
921
|
-
}
|
|
2036
|
+
}
|
|
922
2037
|
|
|
2038
|
+
// Loop through children appending to the array until we hit depth
|
|
923
2039
|
|
|
924
2040
|
var i = 0;
|
|
925
|
-
|
|
926
2041
|
while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) {
|
|
927
2042
|
i += 1;
|
|
928
|
-
|
|
929
|
-
if (!options.plainObjects && has$2.call(Object.prototype, segment[1].slice(1, -1))) {
|
|
2043
|
+
if (!options.plainObjects && has$3.call(Object.prototype, segment[1].slice(1, -1))) {
|
|
930
2044
|
if (!options.allowPrototypes) {
|
|
931
2045
|
return;
|
|
932
2046
|
}
|
|
933
2047
|
}
|
|
934
|
-
|
|
935
2048
|
keys.push(segment[1]);
|
|
936
|
-
}
|
|
2049
|
+
}
|
|
937
2050
|
|
|
2051
|
+
// If there's a remainder, just add whatever is left
|
|
938
2052
|
|
|
939
2053
|
if (segment) {
|
|
940
2054
|
keys.push('[' + key.slice(segment.index) + ']');
|
|
941
2055
|
}
|
|
942
|
-
|
|
943
2056
|
return parseObject(keys, val, options, valuesParsed);
|
|
944
2057
|
};
|
|
945
|
-
|
|
946
2058
|
var normalizeParseOptions = function normalizeParseOptions(opts) {
|
|
947
2059
|
if (!opts) {
|
|
948
2060
|
return defaults$1;
|
|
949
2061
|
}
|
|
950
|
-
|
|
951
2062
|
if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') {
|
|
952
2063
|
throw new TypeError('Decoder has to be a function.');
|
|
953
2064
|
}
|
|
954
|
-
|
|
955
2065
|
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
|
|
956
2066
|
throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
|
|
957
2067
|
}
|
|
958
|
-
|
|
959
2068
|
var charset = typeof opts.charset === 'undefined' ? defaults$1.charset : opts.charset;
|
|
960
2069
|
return {
|
|
961
2070
|
allowDots: typeof opts.allowDots === 'undefined' ? defaults$1.allowDots : !!opts.allowDots,
|
|
962
2071
|
allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults$1.allowPrototypes,
|
|
2072
|
+
allowSparse: typeof opts.allowSparse === 'boolean' ? opts.allowSparse : defaults$1.allowSparse,
|
|
963
2073
|
arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults$1.arrayLimit,
|
|
964
2074
|
charset: charset,
|
|
965
2075
|
charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults$1.charsetSentinel,
|
|
@@ -976,25 +2086,25 @@
|
|
|
976
2086
|
strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults$1.strictNullHandling
|
|
977
2087
|
};
|
|
978
2088
|
};
|
|
979
|
-
|
|
980
|
-
var parse = function parse(str, opts) {
|
|
2089
|
+
var parse = function (str, opts) {
|
|
981
2090
|
var options = normalizeParseOptions(opts);
|
|
982
|
-
|
|
983
2091
|
if (str === '' || str === null || typeof str === 'undefined') {
|
|
984
2092
|
return options.plainObjects ? Object.create(null) : {};
|
|
985
2093
|
}
|
|
986
|
-
|
|
987
2094
|
var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
|
|
988
|
-
var obj = options.plainObjects ? Object.create(null) : {};
|
|
2095
|
+
var obj = options.plainObjects ? Object.create(null) : {};
|
|
989
2096
|
|
|
990
|
-
|
|
2097
|
+
// Iterate over the keys and setup the new object
|
|
991
2098
|
|
|
2099
|
+
var keys = Object.keys(tempObj);
|
|
992
2100
|
for (var i = 0; i < keys.length; ++i) {
|
|
993
2101
|
var key = keys[i];
|
|
994
2102
|
var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string');
|
|
995
2103
|
obj = utils.merge(obj, newObj, options);
|
|
996
2104
|
}
|
|
997
|
-
|
|
2105
|
+
if (options.allowSparse === true) {
|
|
2106
|
+
return obj;
|
|
2107
|
+
}
|
|
998
2108
|
return utils.compact(obj);
|
|
999
2109
|
};
|
|
1000
2110
|
|
|
@@ -1010,167 +2120,125 @@
|
|
|
1010
2120
|
* @author Auth0 https://github.com/auth0/auth0.js
|
|
1011
2121
|
* @license MIT
|
|
1012
2122
|
*/
|
|
2123
|
+
|
|
1013
2124
|
function pick(object, keys) {
|
|
1014
|
-
return keys.reduce(
|
|
2125
|
+
return keys.reduce((prev, key) => {
|
|
1015
2126
|
if (object[key]) {
|
|
1016
2127
|
prev[key] = object[key];
|
|
1017
2128
|
}
|
|
1018
|
-
|
|
1019
2129
|
return prev;
|
|
1020
2130
|
}, {});
|
|
1021
2131
|
}
|
|
1022
2132
|
|
|
1023
|
-
|
|
2133
|
+
// eslint-disable-next-line require-jsdoc
|
|
2134
|
+
class Redirect {
|
|
1024
2135
|
// eslint-disable-next-line require-jsdoc
|
|
1025
|
-
|
|
1026
|
-
_classCallCheck(this, Redirect);
|
|
1027
|
-
|
|
2136
|
+
constructor(sdk, options) {
|
|
1028
2137
|
this.options = options;
|
|
1029
2138
|
this.sdk = sdk;
|
|
1030
2139
|
}
|
|
2140
|
+
|
|
1031
2141
|
/**
|
|
1032
2142
|
* run default authorization flow
|
|
1033
2143
|
*/
|
|
2144
|
+
authorize() {
|
|
2145
|
+
const url = this.sdk.authorizeURL(this.options);
|
|
2146
|
+
window.location = url;
|
|
2147
|
+
}
|
|
1034
2148
|
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
case 'code':
|
|
1075
|
-
requiredFields = ['code'];
|
|
1076
|
-
authorizeData = lib.parse(window.location.search, {
|
|
1077
|
-
ignoreQueryPrefix: true
|
|
1078
|
-
});
|
|
1079
|
-
authorizeData = pick(authorizeData, ['state', 'code']);
|
|
1080
|
-
|
|
1081
|
-
if (!requiredFields.every(function (field) {
|
|
1082
|
-
return authorizeData.hasOwnProperty(field);
|
|
1083
|
-
})) {
|
|
1084
|
-
reject(errors.extend({
|
|
1085
|
-
identity_exception: 'unauthorized'
|
|
1086
|
-
}));
|
|
1087
|
-
return;
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
_this.sdk.redirectUriParamsPersister.retrieve(authorizeData.state);
|
|
1093
|
-
|
|
1094
|
-
resolve(authorizeData);
|
|
1095
|
-
});
|
|
1096
|
-
}
|
|
1097
|
-
}]);
|
|
1098
|
-
|
|
1099
|
-
return Redirect;
|
|
1100
|
-
}();
|
|
2149
|
+
/**
|
|
2150
|
+
* this function checks if the current origin was redirected to with authorize data
|
|
2151
|
+
* @return {Promise} promise that resolves to authorize data or error
|
|
2152
|
+
*/
|
|
2153
|
+
authorizeData() {
|
|
2154
|
+
return new Promise((resolve, reject) => {
|
|
2155
|
+
let authorizeData = {};
|
|
2156
|
+
let requiredFields = [];
|
|
2157
|
+
switch (this.options.response_type) {
|
|
2158
|
+
case 'token':
|
|
2159
|
+
requiredFields = ['access_token', 'expires_in', 'token_type'];
|
|
2160
|
+
authorizeData = lib.parse(window.location.hash.substring(1));
|
|
2161
|
+
authorizeData = pick(authorizeData, ['access_token', 'expires_in', 'state', 'scope', 'token_type']);
|
|
2162
|
+
if (!requiredFields.every(field => authorizeData.hasOwnProperty(field))) {
|
|
2163
|
+
reject(errors.extend({
|
|
2164
|
+
identity_exception: 'unauthorized'
|
|
2165
|
+
}));
|
|
2166
|
+
return;
|
|
2167
|
+
}
|
|
2168
|
+
authorizeData.expires_in = parseInt(authorizeData.expires_in);
|
|
2169
|
+
break;
|
|
2170
|
+
case 'code':
|
|
2171
|
+
requiredFields = ['code'];
|
|
2172
|
+
authorizeData = lib.parse(window.location.search, {
|
|
2173
|
+
ignoreQueryPrefix: true
|
|
2174
|
+
});
|
|
2175
|
+
authorizeData = pick(authorizeData, ['state', 'code']);
|
|
2176
|
+
if (!requiredFields.every(field => authorizeData.hasOwnProperty(field))) {
|
|
2177
|
+
reject(errors.extend({
|
|
2178
|
+
identity_exception: 'unauthorized'
|
|
2179
|
+
}));
|
|
2180
|
+
return;
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
this.sdk.redirectUriParamsPersister.retrieve(authorizeData.state);
|
|
2184
|
+
resolve(authorizeData);
|
|
2185
|
+
});
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
1101
2188
|
|
|
1102
2189
|
/**
|
|
1103
2190
|
* Class for authentication using Iframe
|
|
1104
2191
|
*/
|
|
1105
|
-
|
|
1106
|
-
var Iframe = /*#__PURE__*/function () {
|
|
2192
|
+
class Iframe {
|
|
1107
2193
|
// eslint-disable-next-line require-jsdoc
|
|
1108
|
-
|
|
1109
|
-
_classCallCheck(this, Iframe);
|
|
1110
|
-
|
|
2194
|
+
constructor(sdk, options) {
|
|
1111
2195
|
this.options = options;
|
|
1112
2196
|
this.sdk = sdk;
|
|
1113
2197
|
}
|
|
2198
|
+
|
|
1114
2199
|
/**
|
|
1115
2200
|
* run iframe authorization flow, not recommended because of ITP 2.0
|
|
1116
2201
|
* @return {Promise} promise that resolves to authorize data or error
|
|
1117
2202
|
*/
|
|
2203
|
+
authorize() {
|
|
2204
|
+
return new Promise((resolve, reject) => {
|
|
2205
|
+
const url = this.sdk.authorizeURL(this.options, 'button');
|
|
2206
|
+
const listener = new Listener(this.options);
|
|
2207
|
+
const cb = (err, authorizeData) => {
|
|
2208
|
+
this.removeIframe();
|
|
2209
|
+
if (err) {
|
|
2210
|
+
return reject(err);
|
|
2211
|
+
}
|
|
2212
|
+
resolve(authorizeData);
|
|
2213
|
+
};
|
|
2214
|
+
listener.start(5000, cb);
|
|
2215
|
+
const iframe = document.createElement('iframe');
|
|
2216
|
+
iframe.setAttribute('src', url);
|
|
2217
|
+
iframe.setAttribute('id', this.iframeID());
|
|
2218
|
+
iframe.style.width = '1px';
|
|
2219
|
+
iframe.style.height = '1px';
|
|
2220
|
+
iframe.style.position = 'fixed';
|
|
2221
|
+
iframe.style.top = '0';
|
|
2222
|
+
iframe.style.right = '0';
|
|
2223
|
+
iframe.style.opacity = '0';
|
|
2224
|
+
iframe.style.visibility = 'none';
|
|
2225
|
+
document.body.appendChild(iframe);
|
|
2226
|
+
});
|
|
2227
|
+
}
|
|
1118
2228
|
|
|
2229
|
+
// eslint-disable-next-line require-jsdoc
|
|
2230
|
+
iframeID() {
|
|
2231
|
+
return this.options.client_id + this.options.response_type;
|
|
2232
|
+
}
|
|
1119
2233
|
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
return new Promise(function (resolve, reject) {
|
|
1126
|
-
var url = _this.sdk.authorizeURL(_this.options, 'button');
|
|
1127
|
-
|
|
1128
|
-
var listener = new Listener(_this.options);
|
|
1129
|
-
|
|
1130
|
-
var cb = function cb(err, authorizeData) {
|
|
1131
|
-
_this.removeIframe();
|
|
1132
|
-
|
|
1133
|
-
if (err) {
|
|
1134
|
-
return reject(err);
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
resolve(authorizeData);
|
|
1138
|
-
};
|
|
1139
|
-
|
|
1140
|
-
listener.start(5000, cb);
|
|
1141
|
-
var iframe = document.createElement('iframe');
|
|
1142
|
-
iframe.setAttribute('src', url);
|
|
1143
|
-
iframe.setAttribute('id', _this.iframeID());
|
|
1144
|
-
iframe.style.width = '1px';
|
|
1145
|
-
iframe.style.height = '1px';
|
|
1146
|
-
iframe.style.position = 'fixed';
|
|
1147
|
-
iframe.style.top = '0';
|
|
1148
|
-
iframe.style.right = '0';
|
|
1149
|
-
iframe.style.opacity = '0';
|
|
1150
|
-
iframe.style.visibility = 'none';
|
|
1151
|
-
document.body.appendChild(iframe);
|
|
1152
|
-
});
|
|
1153
|
-
} // eslint-disable-next-line require-jsdoc
|
|
1154
|
-
|
|
1155
|
-
}, {
|
|
1156
|
-
key: "iframeID",
|
|
1157
|
-
value: function iframeID() {
|
|
1158
|
-
return this.options.client_id + this.options.response_type;
|
|
1159
|
-
} // eslint-disable-next-line require-jsdoc
|
|
1160
|
-
|
|
1161
|
-
}, {
|
|
1162
|
-
key: "removeIframe",
|
|
1163
|
-
value: function removeIframe() {
|
|
1164
|
-
var ref = document.getElementById(this.iframeID());
|
|
1165
|
-
|
|
1166
|
-
if (ref && ref.parentNode) {
|
|
1167
|
-
ref.parentNode.removeChild(ref);
|
|
1168
|
-
}
|
|
2234
|
+
// eslint-disable-next-line require-jsdoc
|
|
2235
|
+
removeIframe() {
|
|
2236
|
+
const ref = document.getElementById(this.iframeID());
|
|
2237
|
+
if (ref && ref.parentNode) {
|
|
2238
|
+
ref.parentNode.removeChild(ref);
|
|
1169
2239
|
}
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
return Iframe;
|
|
1173
|
-
}();
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
1174
2242
|
|
|
1175
2243
|
/* eslint-disable require-jsdoc */
|
|
1176
2244
|
|
|
@@ -1178,44 +2246,24 @@
|
|
|
1178
2246
|
* @author Auth0 https://github.com/auth0/auth0.js
|
|
1179
2247
|
* @license MIT
|
|
1180
2248
|
*/
|
|
1181
|
-
function DummyStorage() {}
|
|
1182
2249
|
|
|
2250
|
+
function DummyStorage() {}
|
|
1183
2251
|
DummyStorage.prototype.getItem = function () {
|
|
1184
2252
|
return null;
|
|
1185
2253
|
};
|
|
1186
|
-
|
|
1187
2254
|
DummyStorage.prototype.removeItem = function () {};
|
|
1188
|
-
|
|
1189
2255
|
DummyStorage.prototype.setItem = function () {};
|
|
1190
2256
|
|
|
1191
|
-
function createCommonjsModule(fn, basedir, module) {
|
|
1192
|
-
return module = {
|
|
1193
|
-
path: basedir,
|
|
1194
|
-
exports: {},
|
|
1195
|
-
require: function (path, base) {
|
|
1196
|
-
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
|
|
1197
|
-
}
|
|
1198
|
-
}, fn(module, module.exports), module.exports;
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
function commonjsRequire () {
|
|
1202
|
-
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
2257
|
var js_cookie = createCommonjsModule(function (module, exports) {
|
|
1206
|
-
|
|
1207
2258
|
(function (factory) {
|
|
1208
2259
|
var registeredInModuleLoader;
|
|
1209
|
-
|
|
1210
2260
|
{
|
|
1211
2261
|
module.exports = factory();
|
|
1212
2262
|
registeredInModuleLoader = true;
|
|
1213
2263
|
}
|
|
1214
|
-
|
|
1215
2264
|
if (!registeredInModuleLoader) {
|
|
1216
2265
|
var OldCookies = window.Cookies;
|
|
1217
2266
|
var api = window.Cookies = factory();
|
|
1218
|
-
|
|
1219
2267
|
api.noConflict = function () {
|
|
1220
2268
|
window.Cookies = OldCookies;
|
|
1221
2269
|
return api;
|
|
@@ -1225,162 +2273,125 @@
|
|
|
1225
2273
|
function extend() {
|
|
1226
2274
|
var i = 0;
|
|
1227
2275
|
var result = {};
|
|
1228
|
-
|
|
1229
2276
|
for (; i < arguments.length; i++) {
|
|
1230
2277
|
var attributes = arguments[i];
|
|
1231
|
-
|
|
1232
2278
|
for (var key in attributes) {
|
|
1233
2279
|
result[key] = attributes[key];
|
|
1234
2280
|
}
|
|
1235
2281
|
}
|
|
1236
|
-
|
|
1237
2282
|
return result;
|
|
1238
2283
|
}
|
|
1239
|
-
|
|
1240
2284
|
function decode(s) {
|
|
1241
2285
|
return s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent);
|
|
1242
2286
|
}
|
|
1243
|
-
|
|
1244
2287
|
function init(converter) {
|
|
1245
2288
|
function api() {}
|
|
1246
|
-
|
|
1247
2289
|
function set(key, value, attributes) {
|
|
1248
2290
|
if (typeof document === 'undefined') {
|
|
1249
2291
|
return;
|
|
1250
2292
|
}
|
|
1251
|
-
|
|
1252
2293
|
attributes = extend({
|
|
1253
2294
|
path: '/'
|
|
1254
2295
|
}, api.defaults, attributes);
|
|
1255
|
-
|
|
1256
2296
|
if (typeof attributes.expires === 'number') {
|
|
1257
2297
|
attributes.expires = new Date(new Date() * 1 + attributes.expires * 864e+5);
|
|
1258
|
-
}
|
|
1259
|
-
|
|
2298
|
+
}
|
|
1260
2299
|
|
|
2300
|
+
// We're using "expires" because "max-age" is not supported by IE
|
|
1261
2301
|
attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
|
|
1262
|
-
|
|
1263
2302
|
try {
|
|
1264
2303
|
var result = JSON.stringify(value);
|
|
1265
|
-
|
|
1266
2304
|
if (/^[\{\[]/.test(result)) {
|
|
1267
2305
|
value = result;
|
|
1268
2306
|
}
|
|
1269
2307
|
} catch (e) {}
|
|
1270
|
-
|
|
1271
2308
|
value = converter.write ? converter.write(value, key) : encodeURIComponent(String(value)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
|
|
1272
2309
|
key = encodeURIComponent(String(key)).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/[\(\)]/g, escape);
|
|
1273
2310
|
var stringifiedAttributes = '';
|
|
1274
|
-
|
|
1275
2311
|
for (var attributeName in attributes) {
|
|
1276
2312
|
if (!attributes[attributeName]) {
|
|
1277
2313
|
continue;
|
|
1278
2314
|
}
|
|
1279
|
-
|
|
1280
2315
|
stringifiedAttributes += '; ' + attributeName;
|
|
1281
|
-
|
|
1282
2316
|
if (attributes[attributeName] === true) {
|
|
1283
2317
|
continue;
|
|
1284
|
-
}
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
// Considers RFC 6265 section 5.2:
|
|
1285
2321
|
// ...
|
|
1286
2322
|
// 3. If the remaining unparsed-attributes contains a %x3B (";")
|
|
1287
2323
|
// character:
|
|
1288
2324
|
// Consume the characters of the unparsed-attributes up to,
|
|
1289
2325
|
// not including, the first %x3B (";") character.
|
|
1290
2326
|
// ...
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
2327
|
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
|
|
1294
2328
|
}
|
|
1295
|
-
|
|
1296
2329
|
return document.cookie = key + '=' + value + stringifiedAttributes;
|
|
1297
2330
|
}
|
|
1298
|
-
|
|
1299
2331
|
function get(key, json) {
|
|
1300
2332
|
if (typeof document === 'undefined') {
|
|
1301
2333
|
return;
|
|
1302
2334
|
}
|
|
1303
|
-
|
|
1304
|
-
|
|
2335
|
+
var jar = {};
|
|
2336
|
+
// To prevent the for loop in the first place assign an empty array
|
|
1305
2337
|
// in case there are no cookies at all.
|
|
1306
|
-
|
|
1307
2338
|
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
|
1308
2339
|
var i = 0;
|
|
1309
|
-
|
|
1310
2340
|
for (; i < cookies.length; i++) {
|
|
1311
2341
|
var parts = cookies[i].split('=');
|
|
1312
2342
|
var cookie = parts.slice(1).join('=');
|
|
1313
|
-
|
|
1314
2343
|
if (!json && cookie.charAt(0) === '"') {
|
|
1315
2344
|
cookie = cookie.slice(1, -1);
|
|
1316
2345
|
}
|
|
1317
|
-
|
|
1318
2346
|
try {
|
|
1319
2347
|
var name = decode(parts[0]);
|
|
1320
2348
|
cookie = (converter.read || converter)(cookie, name) || decode(cookie);
|
|
1321
|
-
|
|
1322
2349
|
if (json) {
|
|
1323
2350
|
try {
|
|
1324
2351
|
cookie = JSON.parse(cookie);
|
|
1325
2352
|
} catch (e) {}
|
|
1326
2353
|
}
|
|
1327
|
-
|
|
1328
2354
|
jar[name] = cookie;
|
|
1329
|
-
|
|
1330
2355
|
if (key === name) {
|
|
1331
2356
|
break;
|
|
1332
2357
|
}
|
|
1333
2358
|
} catch (e) {}
|
|
1334
2359
|
}
|
|
1335
|
-
|
|
1336
2360
|
return key ? jar[key] : jar;
|
|
1337
2361
|
}
|
|
1338
|
-
|
|
1339
2362
|
api.set = set;
|
|
1340
|
-
|
|
1341
2363
|
api.get = function (key) {
|
|
1342
|
-
return get(key, false
|
|
1343
|
-
/* read as raw */
|
|
1344
|
-
);
|
|
2364
|
+
return get(key, false /* read as raw */);
|
|
1345
2365
|
};
|
|
1346
|
-
|
|
1347
2366
|
api.getJSON = function (key) {
|
|
1348
|
-
return get(key, true
|
|
1349
|
-
/* read as json */
|
|
1350
|
-
);
|
|
2367
|
+
return get(key, true /* read as json */);
|
|
1351
2368
|
};
|
|
1352
|
-
|
|
1353
2369
|
api.remove = function (key, attributes) {
|
|
1354
2370
|
set(key, '', extend(attributes, {
|
|
1355
2371
|
expires: -1
|
|
1356
2372
|
}));
|
|
1357
2373
|
};
|
|
1358
|
-
|
|
1359
2374
|
api.defaults = {};
|
|
1360
2375
|
api.withConverter = init;
|
|
1361
2376
|
return api;
|
|
1362
2377
|
}
|
|
1363
|
-
|
|
1364
2378
|
return init(function () {});
|
|
1365
2379
|
});
|
|
1366
2380
|
});
|
|
1367
2381
|
|
|
1368
2382
|
/* eslint-disable require-jsdoc */
|
|
1369
|
-
|
|
1370
2383
|
function CookieStorage() {}
|
|
1371
|
-
|
|
1372
2384
|
CookieStorage.prototype.getItem = function (key) {
|
|
1373
2385
|
return js_cookie.get(key);
|
|
1374
2386
|
};
|
|
1375
|
-
|
|
1376
2387
|
CookieStorage.prototype.removeItem = function (key) {
|
|
1377
2388
|
js_cookie.remove(key);
|
|
1378
2389
|
};
|
|
1379
|
-
|
|
1380
2390
|
CookieStorage.prototype.setItem = function (key, value, options) {
|
|
1381
|
-
|
|
2391
|
+
const params = Object.assign({
|
|
1382
2392
|
expires: 1,
|
|
1383
2393
|
// 1 day
|
|
2394
|
+
|
|
1384
2395
|
// After august 2020 chrome changed iframe cookie policy and without
|
|
1385
2396
|
// those parameters cookies wont we stored properly if document is inside iframe.
|
|
1386
2397
|
SameSite: 'none',
|
|
@@ -1390,19 +2401,15 @@
|
|
|
1390
2401
|
};
|
|
1391
2402
|
|
|
1392
2403
|
/* eslint-disable require-jsdoc */
|
|
1393
|
-
|
|
1394
2404
|
function StorageHandler(options) {
|
|
1395
2405
|
this.storage = new CookieStorage();
|
|
1396
|
-
|
|
1397
2406
|
if (options.force_local_storage !== true) {
|
|
1398
2407
|
return;
|
|
1399
2408
|
}
|
|
1400
|
-
|
|
1401
2409
|
try {
|
|
1402
2410
|
// some browsers throw an error when trying to access localStorage
|
|
1403
2411
|
// when localStorage is disabled.
|
|
1404
|
-
|
|
1405
|
-
|
|
2412
|
+
const localStorage = window.localStorage;
|
|
1406
2413
|
if (localStorage) {
|
|
1407
2414
|
this.storage = localStorage;
|
|
1408
2415
|
}
|
|
@@ -1411,7 +2418,6 @@
|
|
|
1411
2418
|
console.warn('Cant use localStorage. Using CookieStorage instead.');
|
|
1412
2419
|
}
|
|
1413
2420
|
}
|
|
1414
|
-
|
|
1415
2421
|
StorageHandler.prototype.failover = function () {
|
|
1416
2422
|
if (this.storage instanceof DummyStorage) {
|
|
1417
2423
|
console.warn('DummyStorage: ignore failover');
|
|
@@ -1424,7 +2430,6 @@
|
|
|
1424
2430
|
this.storage = new CookieStorage();
|
|
1425
2431
|
}
|
|
1426
2432
|
};
|
|
1427
|
-
|
|
1428
2433
|
StorageHandler.prototype.getItem = function (key) {
|
|
1429
2434
|
try {
|
|
1430
2435
|
return this.storage.getItem(key);
|
|
@@ -1434,7 +2439,6 @@
|
|
|
1434
2439
|
return this.getItem(key);
|
|
1435
2440
|
}
|
|
1436
2441
|
};
|
|
1437
|
-
|
|
1438
2442
|
StorageHandler.prototype.removeItem = function (key) {
|
|
1439
2443
|
try {
|
|
1440
2444
|
return this.storage.removeItem(key);
|
|
@@ -1444,7 +2448,6 @@
|
|
|
1444
2448
|
return this.removeItem(key);
|
|
1445
2449
|
}
|
|
1446
2450
|
};
|
|
1447
|
-
|
|
1448
2451
|
StorageHandler.prototype.setItem = function (key, value, options) {
|
|
1449
2452
|
try {
|
|
1450
2453
|
return this.storage.setItem(key, value, options);
|
|
@@ -1456,65 +2459,49 @@
|
|
|
1456
2459
|
};
|
|
1457
2460
|
|
|
1458
2461
|
/* eslint-disable require-jsdoc */
|
|
1459
|
-
|
|
1460
2462
|
function Storage(options) {
|
|
1461
2463
|
this.handler = new StorageHandler(options);
|
|
1462
2464
|
}
|
|
1463
|
-
|
|
1464
2465
|
Storage.prototype.getItem = function (key) {
|
|
1465
|
-
|
|
1466
|
-
|
|
2466
|
+
const value = this.handler.getItem(key);
|
|
1467
2467
|
try {
|
|
1468
2468
|
return JSON.parse(value);
|
|
1469
2469
|
} catch (_) {
|
|
1470
2470
|
return value;
|
|
1471
2471
|
}
|
|
1472
2472
|
};
|
|
1473
|
-
|
|
1474
2473
|
Storage.prototype.removeItem = function (key) {
|
|
1475
2474
|
return this.handler.removeItem(key);
|
|
1476
2475
|
};
|
|
1477
|
-
|
|
1478
2476
|
Storage.prototype.setItem = function (key, value, options) {
|
|
1479
|
-
|
|
2477
|
+
const json = JSON.stringify(value);
|
|
1480
2478
|
return this.handler.setItem(key, json, options);
|
|
1481
2479
|
};
|
|
1482
2480
|
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
2481
|
+
/* eslint-disable require-jsdoc */
|
|
2482
|
+
class Transaction {
|
|
2483
|
+
constructor(options) {
|
|
1487
2484
|
this.options = options.transaction;
|
|
1488
2485
|
this.storage = new Storage(this.options);
|
|
1489
2486
|
}
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
}
|
|
1509
|
-
}, {
|
|
1510
|
-
key: "clear",
|
|
1511
|
-
value: function clear(state) {
|
|
1512
|
-
this.storage.removeItem(this.options.namespace + state);
|
|
1513
|
-
}
|
|
1514
|
-
}]);
|
|
1515
|
-
|
|
1516
|
-
return Transaction;
|
|
1517
|
-
}();
|
|
2487
|
+
generate(params) {
|
|
2488
|
+
// 30 minutes
|
|
2489
|
+
this.storage.setItem(this.options.namespace + params.state, {
|
|
2490
|
+
state: params.state,
|
|
2491
|
+
code_verifier: params.code_verifier
|
|
2492
|
+
}, {
|
|
2493
|
+
expires: 1 / 48
|
|
2494
|
+
});
|
|
2495
|
+
}
|
|
2496
|
+
get(state) {
|
|
2497
|
+
const transactionData = this.storage.getItem(this.options.namespace + state);
|
|
2498
|
+
this.clear(state);
|
|
2499
|
+
return transactionData || {};
|
|
2500
|
+
}
|
|
2501
|
+
clear(state) {
|
|
2502
|
+
this.storage.removeItem(this.options.namespace + state);
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
1518
2505
|
|
|
1519
2506
|
/** @fileOverview Javascript cryptography implementation.
|
|
1520
2507
|
*
|
|
@@ -1525,46 +2512,40 @@
|
|
|
1525
2512
|
* @author Mike Hamburg
|
|
1526
2513
|
* @author Dan Boneh
|
|
1527
2514
|
*/
|
|
1528
|
-
/*jslint indent: 2, bitwise: false, nomen: false, plusplus: false, white: false, regexp: false */
|
|
1529
2515
|
|
|
2516
|
+
/*jslint indent: 2, bitwise: false, nomen: false, plusplus: false, white: false, regexp: false */
|
|
1530
2517
|
/*global document, window, escape, unescape, module, require, Uint32Array */
|
|
1531
2518
|
|
|
1532
2519
|
/**
|
|
1533
2520
|
* The Stanford Javascript Crypto Library, top-level namespace.
|
|
1534
2521
|
* @namespace
|
|
1535
2522
|
*/
|
|
1536
|
-
|
|
1537
2523
|
var sjcl = {
|
|
1538
2524
|
/**
|
|
1539
2525
|
* Symmetric ciphers.
|
|
1540
2526
|
* @namespace
|
|
1541
2527
|
*/
|
|
1542
2528
|
cipher: {},
|
|
1543
|
-
|
|
1544
2529
|
/**
|
|
1545
2530
|
* Hash functions. Right now only SHA256 is implemented.
|
|
1546
2531
|
* @namespace
|
|
1547
2532
|
*/
|
|
1548
2533
|
hash: {},
|
|
1549
|
-
|
|
1550
2534
|
/**
|
|
1551
2535
|
* Key exchange functions. Right now only SRP is implemented.
|
|
1552
2536
|
* @namespace
|
|
1553
2537
|
*/
|
|
1554
2538
|
keyexchange: {},
|
|
1555
|
-
|
|
1556
2539
|
/**
|
|
1557
2540
|
* Cipher modes of operation.
|
|
1558
2541
|
* @namespace
|
|
1559
2542
|
*/
|
|
1560
2543
|
mode: {},
|
|
1561
|
-
|
|
1562
2544
|
/**
|
|
1563
2545
|
* Miscellaneous. HMAC and PBKDF2.
|
|
1564
2546
|
* @namespace
|
|
1565
2547
|
*/
|
|
1566
2548
|
misc: {},
|
|
1567
|
-
|
|
1568
2549
|
/**
|
|
1569
2550
|
* Bit array encoders and decoders.
|
|
1570
2551
|
* @namespace
|
|
@@ -1576,7 +2557,6 @@
|
|
|
1576
2557
|
* the method names are "fromBits" and "toBits".
|
|
1577
2558
|
*/
|
|
1578
2559
|
codec: {},
|
|
1579
|
-
|
|
1580
2560
|
/**
|
|
1581
2561
|
* Exceptions.
|
|
1582
2562
|
* @namespace
|
|
@@ -1586,47 +2566,40 @@
|
|
|
1586
2566
|
* Ciphertext is corrupt.
|
|
1587
2567
|
* @constructor
|
|
1588
2568
|
*/
|
|
1589
|
-
corrupt: function
|
|
2569
|
+
corrupt: function (message) {
|
|
1590
2570
|
this.toString = function () {
|
|
1591
2571
|
return 'CORRUPT: ' + this.message;
|
|
1592
2572
|
};
|
|
1593
|
-
|
|
1594
2573
|
this.message = message;
|
|
1595
2574
|
},
|
|
1596
|
-
|
|
1597
2575
|
/**
|
|
1598
2576
|
* Invalid parameter.
|
|
1599
2577
|
* @constructor
|
|
1600
2578
|
*/
|
|
1601
|
-
invalid: function
|
|
2579
|
+
invalid: function (message) {
|
|
1602
2580
|
this.toString = function () {
|
|
1603
2581
|
return 'INVALID: ' + this.message;
|
|
1604
2582
|
};
|
|
1605
|
-
|
|
1606
2583
|
this.message = message;
|
|
1607
2584
|
},
|
|
1608
|
-
|
|
1609
2585
|
/**
|
|
1610
2586
|
* Bug or missing feature in SJCL.
|
|
1611
2587
|
* @constructor
|
|
1612
2588
|
*/
|
|
1613
|
-
bug: function
|
|
2589
|
+
bug: function (message) {
|
|
1614
2590
|
this.toString = function () {
|
|
1615
2591
|
return 'BUG: ' + this.message;
|
|
1616
2592
|
};
|
|
1617
|
-
|
|
1618
2593
|
this.message = message;
|
|
1619
2594
|
},
|
|
1620
|
-
|
|
1621
2595
|
/**
|
|
1622
2596
|
* Something isn't ready.
|
|
1623
2597
|
* @constructor
|
|
1624
2598
|
*/
|
|
1625
|
-
notReady: function
|
|
2599
|
+
notReady: function (message) {
|
|
1626
2600
|
this.toString = function () {
|
|
1627
2601
|
return 'NOT READY: ' + this.message;
|
|
1628
2602
|
};
|
|
1629
|
-
|
|
1630
2603
|
this.message = message;
|
|
1631
2604
|
}
|
|
1632
2605
|
}
|
|
@@ -1662,7 +2635,6 @@
|
|
|
1662
2635
|
* to ciphers like AES which want arrays of words.
|
|
1663
2636
|
* </p>
|
|
1664
2637
|
*/
|
|
1665
|
-
|
|
1666
2638
|
sjcl.bitArray = {
|
|
1667
2639
|
/**
|
|
1668
2640
|
* Array slices in units of bits.
|
|
@@ -1672,11 +2644,10 @@
|
|
|
1672
2644
|
* slice until the end of the array.
|
|
1673
2645
|
* @return {bitArray} The requested slice.
|
|
1674
2646
|
*/
|
|
1675
|
-
bitSlice: function
|
|
2647
|
+
bitSlice: function (a, bstart, bend) {
|
|
1676
2648
|
a = sjcl.bitArray._shiftRight(a.slice(bstart / 32), 32 - (bstart & 31)).slice(1);
|
|
1677
2649
|
return bend === undefined ? a : sjcl.bitArray.clamp(a, bend - bstart);
|
|
1678
2650
|
},
|
|
1679
|
-
|
|
1680
2651
|
/**
|
|
1681
2652
|
* Extract a number packed into a bit array.
|
|
1682
2653
|
* @param {bitArray} a The array to slice.
|
|
@@ -1684,12 +2655,11 @@
|
|
|
1684
2655
|
* @param {Number} blength The length of the number to extract.
|
|
1685
2656
|
* @return {Number} The requested slice.
|
|
1686
2657
|
*/
|
|
1687
|
-
extract: function
|
|
2658
|
+
extract: function (a, bstart, blength) {
|
|
1688
2659
|
// FIXME: this Math.floor is not necessary at all, but for some reason
|
|
1689
2660
|
// seems to suppress a bug in the Chromium JIT.
|
|
1690
2661
|
var x,
|
|
1691
|
-
|
|
1692
|
-
|
|
2662
|
+
sh = Math.floor(-bstart - blength & 31);
|
|
1693
2663
|
if ((bstart + blength - 1 ^ bstart) & -32) {
|
|
1694
2664
|
// it crosses a boundary
|
|
1695
2665
|
x = a[bstart / 32 | 0] << 32 - sh ^ a[bstart / 32 + 1 | 0] >>> sh;
|
|
@@ -1697,70 +2667,58 @@
|
|
|
1697
2667
|
// within a single word
|
|
1698
2668
|
x = a[bstart / 32 | 0] >>> sh;
|
|
1699
2669
|
}
|
|
1700
|
-
|
|
1701
2670
|
return x & (1 << blength) - 1;
|
|
1702
2671
|
},
|
|
1703
|
-
|
|
1704
2672
|
/**
|
|
1705
2673
|
* Concatenate two bit arrays.
|
|
1706
2674
|
* @param {bitArray} a1 The first array.
|
|
1707
2675
|
* @param {bitArray} a2 The second array.
|
|
1708
2676
|
* @return {bitArray} The concatenation of a1 and a2.
|
|
1709
2677
|
*/
|
|
1710
|
-
concat: function
|
|
2678
|
+
concat: function (a1, a2) {
|
|
1711
2679
|
if (a1.length === 0 || a2.length === 0) {
|
|
1712
2680
|
return a1.concat(a2);
|
|
1713
2681
|
}
|
|
1714
|
-
|
|
1715
2682
|
var last = a1[a1.length - 1],
|
|
1716
|
-
|
|
1717
|
-
|
|
2683
|
+
shift = sjcl.bitArray.getPartial(last);
|
|
1718
2684
|
if (shift === 32) {
|
|
1719
2685
|
return a1.concat(a2);
|
|
1720
2686
|
} else {
|
|
1721
2687
|
return sjcl.bitArray._shiftRight(a2, shift, last | 0, a1.slice(0, a1.length - 1));
|
|
1722
2688
|
}
|
|
1723
2689
|
},
|
|
1724
|
-
|
|
1725
2690
|
/**
|
|
1726
2691
|
* Find the length of an array of bits.
|
|
1727
2692
|
* @param {bitArray} a The array.
|
|
1728
2693
|
* @return {Number} The length of a, in bits.
|
|
1729
2694
|
*/
|
|
1730
|
-
bitLength: function
|
|
2695
|
+
bitLength: function (a) {
|
|
1731
2696
|
var l = a.length,
|
|
1732
|
-
|
|
1733
|
-
|
|
2697
|
+
x;
|
|
1734
2698
|
if (l === 0) {
|
|
1735
2699
|
return 0;
|
|
1736
2700
|
}
|
|
1737
|
-
|
|
1738
2701
|
x = a[l - 1];
|
|
1739
2702
|
return (l - 1) * 32 + sjcl.bitArray.getPartial(x);
|
|
1740
2703
|
},
|
|
1741
|
-
|
|
1742
2704
|
/**
|
|
1743
2705
|
* Truncate an array.
|
|
1744
2706
|
* @param {bitArray} a The array.
|
|
1745
2707
|
* @param {Number} len The length to truncate to, in bits.
|
|
1746
2708
|
* @return {bitArray} A new array, truncated to len bits.
|
|
1747
2709
|
*/
|
|
1748
|
-
clamp: function
|
|
2710
|
+
clamp: function (a, len) {
|
|
1749
2711
|
if (a.length * 32 < len) {
|
|
1750
2712
|
return a;
|
|
1751
2713
|
}
|
|
1752
|
-
|
|
1753
2714
|
a = a.slice(0, Math.ceil(len / 32));
|
|
1754
2715
|
var l = a.length;
|
|
1755
2716
|
len = len & 31;
|
|
1756
|
-
|
|
1757
2717
|
if (l > 0 && len) {
|
|
1758
2718
|
a[l - 1] = sjcl.bitArray.partial(len, a[l - 1] & 0x80000000 >> len - 1, 1);
|
|
1759
2719
|
}
|
|
1760
|
-
|
|
1761
2720
|
return a;
|
|
1762
2721
|
},
|
|
1763
|
-
|
|
1764
2722
|
/**
|
|
1765
2723
|
* Make a partial word for a bit array.
|
|
1766
2724
|
* @param {Number} len The number of bits in the word.
|
|
@@ -1768,44 +2726,37 @@
|
|
|
1768
2726
|
* @param {Number} [_end=0] Pass 1 if x has already been shifted to the high side.
|
|
1769
2727
|
* @return {Number} The partial word.
|
|
1770
2728
|
*/
|
|
1771
|
-
partial: function
|
|
2729
|
+
partial: function (len, x, _end) {
|
|
1772
2730
|
if (len === 32) {
|
|
1773
2731
|
return x;
|
|
1774
2732
|
}
|
|
1775
|
-
|
|
1776
2733
|
return (_end ? x | 0 : x << 32 - len) + len * 0x10000000000;
|
|
1777
2734
|
},
|
|
1778
|
-
|
|
1779
2735
|
/**
|
|
1780
2736
|
* Get the number of bits used by a partial word.
|
|
1781
2737
|
* @param {Number} x The partial word.
|
|
1782
2738
|
* @return {Number} The number of bits used by the partial word.
|
|
1783
2739
|
*/
|
|
1784
|
-
getPartial: function
|
|
2740
|
+
getPartial: function (x) {
|
|
1785
2741
|
return Math.round(x / 0x10000000000) || 32;
|
|
1786
2742
|
},
|
|
1787
|
-
|
|
1788
2743
|
/**
|
|
1789
2744
|
* Compare two arrays for equality in a predictable amount of time.
|
|
1790
2745
|
* @param {bitArray} a The first array.
|
|
1791
2746
|
* @param {bitArray} b The second array.
|
|
1792
2747
|
* @return {boolean} true if a == b; false otherwise.
|
|
1793
2748
|
*/
|
|
1794
|
-
equal: function
|
|
2749
|
+
equal: function (a, b) {
|
|
1795
2750
|
if (sjcl.bitArray.bitLength(a) !== sjcl.bitArray.bitLength(b)) {
|
|
1796
2751
|
return false;
|
|
1797
2752
|
}
|
|
1798
|
-
|
|
1799
2753
|
var x = 0,
|
|
1800
|
-
|
|
1801
|
-
|
|
2754
|
+
i;
|
|
1802
2755
|
for (i = 0; i < a.length; i++) {
|
|
1803
2756
|
x |= a[i] ^ b[i];
|
|
1804
2757
|
}
|
|
1805
|
-
|
|
1806
2758
|
return x === 0;
|
|
1807
2759
|
},
|
|
1808
|
-
|
|
1809
2760
|
/** Shift an array right.
|
|
1810
2761
|
* @param {bitArray} a The array to shift.
|
|
1811
2762
|
* @param {Number} shift The number of bits to shift.
|
|
@@ -1813,57 +2764,48 @@
|
|
|
1813
2764
|
* @param {bitArray} [out=[]] An array to prepend to the output.
|
|
1814
2765
|
* @private
|
|
1815
2766
|
*/
|
|
1816
|
-
_shiftRight: function
|
|
2767
|
+
_shiftRight: function (a, shift, carry, out) {
|
|
1817
2768
|
var i,
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
2769
|
+
last2 = 0,
|
|
2770
|
+
shift2;
|
|
1821
2771
|
if (out === undefined) {
|
|
1822
2772
|
out = [];
|
|
1823
2773
|
}
|
|
1824
|
-
|
|
1825
2774
|
for (; shift >= 32; shift -= 32) {
|
|
1826
2775
|
out.push(carry);
|
|
1827
2776
|
carry = 0;
|
|
1828
2777
|
}
|
|
1829
|
-
|
|
1830
2778
|
if (shift === 0) {
|
|
1831
2779
|
return out.concat(a);
|
|
1832
2780
|
}
|
|
1833
|
-
|
|
1834
2781
|
for (i = 0; i < a.length; i++) {
|
|
1835
2782
|
out.push(carry | a[i] >>> shift);
|
|
1836
2783
|
carry = a[i] << 32 - shift;
|
|
1837
2784
|
}
|
|
1838
|
-
|
|
1839
2785
|
last2 = a.length ? a[a.length - 1] : 0;
|
|
1840
2786
|
shift2 = sjcl.bitArray.getPartial(last2);
|
|
1841
2787
|
out.push(sjcl.bitArray.partial(shift + shift2 & 31, shift + shift2 > 32 ? carry : out.pop(), 1));
|
|
1842
2788
|
return out;
|
|
1843
2789
|
},
|
|
1844
|
-
|
|
1845
2790
|
/** xor a block of 4 words together.
|
|
1846
2791
|
* @private
|
|
1847
2792
|
*/
|
|
1848
|
-
_xor4: function
|
|
2793
|
+
_xor4: function (x, y) {
|
|
1849
2794
|
return [x[0] ^ y[0], x[1] ^ y[1], x[2] ^ y[2], x[3] ^ y[3]];
|
|
1850
2795
|
},
|
|
1851
|
-
|
|
1852
2796
|
/** byteswap a word array inplace.
|
|
1853
2797
|
* (does not handle partial words)
|
|
1854
2798
|
* @param {sjcl.bitArray} a word array
|
|
1855
2799
|
* @return {sjcl.bitArray} byteswapped array
|
|
1856
2800
|
*/
|
|
1857
|
-
byteswapM: function
|
|
2801
|
+
byteswapM: function (a) {
|
|
1858
2802
|
var i,
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
2803
|
+
v,
|
|
2804
|
+
m = 0xff00;
|
|
1862
2805
|
for (i = 0; i < a.length; ++i) {
|
|
1863
2806
|
v = a[i];
|
|
1864
2807
|
a[i] = v >>> 24 | v >>> 8 & m | (v & m) << 8 | v << 24;
|
|
1865
2808
|
}
|
|
1866
|
-
|
|
1867
2809
|
return a;
|
|
1868
2810
|
}
|
|
1869
2811
|
};
|
|
@@ -1878,47 +2820,38 @@
|
|
|
1878
2820
|
* UTF-8 strings
|
|
1879
2821
|
* @namespace
|
|
1880
2822
|
*/
|
|
1881
|
-
|
|
1882
2823
|
sjcl.codec.utf8String = {
|
|
1883
2824
|
/** Convert from a bitArray to a UTF-8 string. */
|
|
1884
|
-
fromBits: function
|
|
2825
|
+
fromBits: function (arr) {
|
|
1885
2826
|
var out = '',
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
2827
|
+
bl = sjcl.bitArray.bitLength(arr),
|
|
2828
|
+
i,
|
|
2829
|
+
tmp;
|
|
1890
2830
|
for (i = 0; i < bl / 8; i++) {
|
|
1891
2831
|
if ((i & 3) === 0) {
|
|
1892
2832
|
tmp = arr[i / 4];
|
|
1893
2833
|
}
|
|
1894
|
-
|
|
1895
2834
|
out += String.fromCharCode(tmp >>> 8 >>> 8 >>> 8);
|
|
1896
2835
|
tmp <<= 8;
|
|
1897
2836
|
}
|
|
1898
|
-
|
|
1899
2837
|
return decodeURIComponent(escape(out));
|
|
1900
2838
|
},
|
|
1901
|
-
|
|
1902
2839
|
/** Convert from a UTF-8 string to a bitArray. */
|
|
1903
|
-
toBits: function
|
|
2840
|
+
toBits: function (str) {
|
|
1904
2841
|
str = unescape(encodeURIComponent(str));
|
|
1905
2842
|
var out = [],
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
2843
|
+
i,
|
|
2844
|
+
tmp = 0;
|
|
1909
2845
|
for (i = 0; i < str.length; i++) {
|
|
1910
2846
|
tmp = tmp << 8 | str.charCodeAt(i);
|
|
1911
|
-
|
|
1912
2847
|
if ((i & 3) === 3) {
|
|
1913
2848
|
out.push(tmp);
|
|
1914
2849
|
tmp = 0;
|
|
1915
2850
|
}
|
|
1916
2851
|
}
|
|
1917
|
-
|
|
1918
2852
|
if (i & 3) {
|
|
1919
2853
|
out.push(sjcl.bitArray.partial(8 * (i & 3), tmp));
|
|
1920
2854
|
}
|
|
1921
|
-
|
|
1922
2855
|
return out;
|
|
1923
2856
|
}
|
|
1924
2857
|
};
|
|
@@ -1941,12 +2874,10 @@
|
|
|
1941
2874
|
* Context for a SHA-256 operation in progress.
|
|
1942
2875
|
* @constructor
|
|
1943
2876
|
*/
|
|
1944
|
-
|
|
1945
2877
|
sjcl.hash.sha256 = function (hash) {
|
|
1946
2878
|
if (!this._key[0]) {
|
|
1947
2879
|
this._precompute();
|
|
1948
2880
|
}
|
|
1949
|
-
|
|
1950
2881
|
if (hash) {
|
|
1951
2882
|
this._h = hash._h.slice(0);
|
|
1952
2883
|
this._buffer = hash._buffer.slice(0);
|
|
@@ -1955,108 +2886,94 @@
|
|
|
1955
2886
|
this.reset();
|
|
1956
2887
|
}
|
|
1957
2888
|
};
|
|
2889
|
+
|
|
1958
2890
|
/**
|
|
1959
2891
|
* Hash a string or an array of words.
|
|
1960
2892
|
* @static
|
|
1961
2893
|
* @param {bitArray|String} data the data to hash.
|
|
1962
2894
|
* @return {bitArray} The hash value, an array of 16 big-endian words.
|
|
1963
2895
|
*/
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
2896
|
sjcl.hash.sha256.hash = function (data) {
|
|
1967
2897
|
return new sjcl.hash.sha256().update(data).finalize();
|
|
1968
2898
|
};
|
|
1969
|
-
|
|
1970
2899
|
sjcl.hash.sha256.prototype = {
|
|
1971
2900
|
/**
|
|
1972
2901
|
* The hash's block size, in bits.
|
|
1973
2902
|
* @constant
|
|
1974
2903
|
*/
|
|
1975
2904
|
blockSize: 512,
|
|
1976
|
-
|
|
1977
2905
|
/**
|
|
1978
2906
|
* Reset the hash state.
|
|
1979
2907
|
* @return this
|
|
1980
2908
|
*/
|
|
1981
|
-
reset: function
|
|
2909
|
+
reset: function () {
|
|
1982
2910
|
this._h = this._init.slice(0);
|
|
1983
2911
|
this._buffer = [];
|
|
1984
2912
|
this._length = 0;
|
|
1985
2913
|
return this;
|
|
1986
2914
|
},
|
|
1987
|
-
|
|
1988
2915
|
/**
|
|
1989
2916
|
* Input several words to the hash.
|
|
1990
2917
|
* @param {bitArray|String} data the data to hash.
|
|
1991
2918
|
* @return this
|
|
1992
2919
|
*/
|
|
1993
|
-
update: function
|
|
2920
|
+
update: function (data) {
|
|
1994
2921
|
if (typeof data === 'string') {
|
|
1995
2922
|
data = sjcl.codec.utf8String.toBits(data);
|
|
1996
2923
|
}
|
|
1997
|
-
|
|
1998
2924
|
var i,
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2925
|
+
b = this._buffer = sjcl.bitArray.concat(this._buffer, data),
|
|
2926
|
+
ol = this._length,
|
|
2927
|
+
nl = this._length = ol + sjcl.bitArray.bitLength(data);
|
|
2003
2928
|
if (nl > 9007199254740991) {
|
|
2004
2929
|
throw new sjcl.exception.invalid('Cannot hash more than 2^53 - 1 bits');
|
|
2005
2930
|
}
|
|
2006
|
-
|
|
2007
2931
|
if (typeof Uint32Array !== 'undefined') {
|
|
2008
2932
|
var c = new Uint32Array(b);
|
|
2009
2933
|
var j = 0;
|
|
2010
|
-
|
|
2011
2934
|
for (i = 512 + ol - (512 + ol & 511); i <= nl; i += 512) {
|
|
2012
2935
|
this._block(c.subarray(16 * j, 16 * (j + 1)));
|
|
2013
|
-
|
|
2014
2936
|
j += 1;
|
|
2015
2937
|
}
|
|
2016
|
-
|
|
2017
2938
|
b.splice(0, 16 * j);
|
|
2018
2939
|
} else {
|
|
2019
2940
|
for (i = 512 + ol - (512 + ol & 511); i <= nl; i += 512) {
|
|
2020
2941
|
this._block(b.splice(0, 16));
|
|
2021
2942
|
}
|
|
2022
2943
|
}
|
|
2023
|
-
|
|
2024
2944
|
return this;
|
|
2025
2945
|
},
|
|
2026
|
-
|
|
2027
2946
|
/**
|
|
2028
2947
|
* Complete hashing and output the hash value.
|
|
2029
2948
|
* @return {bitArray} The hash value, an array of 8 big-endian words.
|
|
2030
2949
|
*/
|
|
2031
|
-
finalize: function
|
|
2950
|
+
finalize: function () {
|
|
2032
2951
|
var i,
|
|
2033
|
-
|
|
2034
|
-
|
|
2952
|
+
b = this._buffer,
|
|
2953
|
+
h = this._h;
|
|
2035
2954
|
|
|
2036
|
-
|
|
2955
|
+
// Round out and push the buffer
|
|
2956
|
+
b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(1, 1)]);
|
|
2037
2957
|
|
|
2958
|
+
// Round out the buffer to a multiple of 16 words, less the 2 length words.
|
|
2038
2959
|
for (i = b.length + 2; i & 15; i++) {
|
|
2039
2960
|
b.push(0);
|
|
2040
|
-
}
|
|
2041
|
-
|
|
2961
|
+
}
|
|
2042
2962
|
|
|
2963
|
+
// append the length
|
|
2043
2964
|
b.push(Math.floor(this._length / 0x100000000));
|
|
2044
2965
|
b.push(this._length | 0);
|
|
2045
|
-
|
|
2046
2966
|
while (b.length) {
|
|
2047
2967
|
this._block(b.splice(0, 16));
|
|
2048
2968
|
}
|
|
2049
|
-
|
|
2050
2969
|
this.reset();
|
|
2051
2970
|
return h;
|
|
2052
2971
|
},
|
|
2053
|
-
|
|
2054
2972
|
/**
|
|
2055
2973
|
* The SHA-256 initialization vector, to be precomputed.
|
|
2056
2974
|
* @private
|
|
2057
2975
|
*/
|
|
2058
2976
|
_init: [],
|
|
2059
|
-
|
|
2060
2977
|
/*
|
|
2061
2978
|
_init:[0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19],
|
|
2062
2979
|
*/
|
|
@@ -2066,7 +2983,6 @@
|
|
|
2066
2983
|
* @private
|
|
2067
2984
|
*/
|
|
2068
2985
|
_key: [],
|
|
2069
|
-
|
|
2070
2986
|
/*
|
|
2071
2987
|
_key:
|
|
2072
2988
|
[0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
@@ -2083,57 +2999,52 @@
|
|
|
2083
2999
|
* Function to precompute _init and _key.
|
|
2084
3000
|
* @private
|
|
2085
3001
|
*/
|
|
2086
|
-
_precompute: function
|
|
3002
|
+
_precompute: function () {
|
|
2087
3003
|
var i = 0,
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
3004
|
+
prime = 2,
|
|
3005
|
+
factor,
|
|
3006
|
+
isPrime;
|
|
2092
3007
|
function frac(x) {
|
|
2093
3008
|
return (x - Math.floor(x)) * 0x100000000 | 0;
|
|
2094
3009
|
}
|
|
2095
|
-
|
|
2096
3010
|
for (; i < 64; prime++) {
|
|
2097
3011
|
isPrime = true;
|
|
2098
|
-
|
|
2099
3012
|
for (factor = 2; factor * factor <= prime; factor++) {
|
|
2100
3013
|
if (prime % factor === 0) {
|
|
2101
3014
|
isPrime = false;
|
|
2102
3015
|
break;
|
|
2103
3016
|
}
|
|
2104
3017
|
}
|
|
2105
|
-
|
|
2106
3018
|
if (isPrime) {
|
|
2107
3019
|
if (i < 8) {
|
|
2108
3020
|
this._init[i] = frac(Math.pow(prime, 1 / 2));
|
|
2109
3021
|
}
|
|
2110
|
-
|
|
2111
3022
|
this._key[i] = frac(Math.pow(prime, 1 / 3));
|
|
2112
3023
|
i++;
|
|
2113
3024
|
}
|
|
2114
3025
|
}
|
|
2115
3026
|
},
|
|
2116
|
-
|
|
2117
3027
|
/**
|
|
2118
3028
|
* Perform one cycle of SHA-256.
|
|
2119
3029
|
* @param {Uint32Array|bitArray} w one block of words.
|
|
2120
3030
|
* @private
|
|
2121
3031
|
*/
|
|
2122
|
-
_block: function
|
|
3032
|
+
_block: function (w) {
|
|
2123
3033
|
var i,
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
3034
|
+
tmp,
|
|
3035
|
+
a,
|
|
3036
|
+
b,
|
|
3037
|
+
h = this._h,
|
|
3038
|
+
k = this._key,
|
|
3039
|
+
h0 = h[0],
|
|
3040
|
+
h1 = h[1],
|
|
3041
|
+
h2 = h[2],
|
|
3042
|
+
h3 = h[3],
|
|
3043
|
+
h4 = h[4],
|
|
3044
|
+
h5 = h[5],
|
|
3045
|
+
h6 = h[6],
|
|
3046
|
+
h7 = h[7];
|
|
3047
|
+
|
|
2137
3048
|
/* Rationale for placement of |0 :
|
|
2138
3049
|
* If a value can overflow is original 32 bits by a factor of more than a few
|
|
2139
3050
|
* million (2^23 ish), there is a possibility that it might overflow the
|
|
@@ -2147,7 +3058,6 @@
|
|
|
2147
3058
|
* The clamps on h[] are necessary for the output to be correct even in the
|
|
2148
3059
|
* common case and for short inputs.
|
|
2149
3060
|
*/
|
|
2150
|
-
|
|
2151
3061
|
for (i = 0; i < 64; i++) {
|
|
2152
3062
|
// load up the input word for this round
|
|
2153
3063
|
if (i < 16) {
|
|
@@ -2157,10 +3067,9 @@
|
|
|
2157
3067
|
b = w[i + 14 & 15];
|
|
2158
3068
|
tmp = w[i & 15] = (a >>> 7 ^ a >>> 18 ^ a >>> 3 ^ a << 25 ^ a << 14) + (b >>> 17 ^ b >>> 19 ^ b >>> 10 ^ b << 15 ^ b << 13) + w[i & 15] + w[i + 9 & 15] | 0;
|
|
2159
3069
|
}
|
|
2160
|
-
|
|
2161
3070
|
tmp = tmp + h7 + (h4 >>> 6 ^ h4 >>> 11 ^ h4 >>> 25 ^ h4 << 26 ^ h4 << 21 ^ h4 << 7) + (h6 ^ h4 & (h5 ^ h6)) + k[i]; // | 0;
|
|
2162
|
-
// shift register
|
|
2163
3071
|
|
|
3072
|
+
// shift register
|
|
2164
3073
|
h7 = h6;
|
|
2165
3074
|
h6 = h5;
|
|
2166
3075
|
h5 = h4;
|
|
@@ -2170,7 +3079,6 @@
|
|
|
2170
3079
|
h1 = h0;
|
|
2171
3080
|
h0 = tmp + (h1 & h2 ^ h3 & (h1 ^ h2)) + (h1 >>> 2 ^ h1 >>> 13 ^ h1 >>> 22 ^ h1 << 30 ^ h1 << 19 ^ h1 << 10) | 0;
|
|
2172
3081
|
}
|
|
2173
|
-
|
|
2174
3082
|
h[0] = h[0] + h0 | 0;
|
|
2175
3083
|
h[1] = h[1] + h1 | 0;
|
|
2176
3084
|
h[2] = h[2] + h2 | 0;
|
|
@@ -2186,106 +3094,83 @@
|
|
|
2186
3094
|
function base64URLEncode(str) {
|
|
2187
3095
|
return btoa(str).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
2188
3096
|
}
|
|
2189
|
-
|
|
2190
3097
|
var encoding = {
|
|
2191
3098
|
base64URLEncode: base64URLEncode
|
|
2192
3099
|
};
|
|
2193
3100
|
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
3101
|
+
/* eslint-disable require-jsdoc */
|
|
3102
|
+
class Persister {
|
|
3103
|
+
constructor(options, type) {
|
|
2198
3104
|
this.options = {
|
|
2199
3105
|
namespace: options.transaction.namespace + type
|
|
2200
3106
|
};
|
|
2201
3107
|
this.storage = new Storage(this.options);
|
|
2202
3108
|
}
|
|
3109
|
+
set(state, data) {
|
|
3110
|
+
this.storage.setItem(this.options.namespace + state, data, {
|
|
3111
|
+
expires: 1 / 48
|
|
3112
|
+
});
|
|
3113
|
+
}
|
|
3114
|
+
get(state) {
|
|
3115
|
+
const data = this.storage.getItem(this.options.namespace + state);
|
|
3116
|
+
this.clear(state);
|
|
3117
|
+
return data || {};
|
|
3118
|
+
}
|
|
3119
|
+
clear(state) {
|
|
3120
|
+
this.storage.removeItem(this.options.namespace + state);
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
2203
3123
|
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
this.storage.setItem(this.options.namespace + state, data, {
|
|
2208
|
-
expires: 1 / 48
|
|
2209
|
-
});
|
|
2210
|
-
}
|
|
2211
|
-
}, {
|
|
2212
|
-
key: "get",
|
|
2213
|
-
value: function get(state) {
|
|
2214
|
-
var data = this.storage.getItem(this.options.namespace + state);
|
|
2215
|
-
this.clear(state);
|
|
2216
|
-
return data || {};
|
|
2217
|
-
}
|
|
2218
|
-
}, {
|
|
2219
|
-
key: "clear",
|
|
2220
|
-
value: function clear(state) {
|
|
2221
|
-
this.storage.removeItem(this.options.namespace + state);
|
|
2222
|
-
}
|
|
2223
|
-
}]);
|
|
2224
|
-
|
|
2225
|
-
return Persister;
|
|
2226
|
-
}();
|
|
2227
|
-
|
|
2228
|
-
var RedirectUriParamsPersister = /*#__PURE__*/function () {
|
|
2229
|
-
function RedirectUriParamsPersister(options) {
|
|
2230
|
-
_classCallCheck(this, RedirectUriParamsPersister);
|
|
2231
|
-
|
|
3124
|
+
/* eslint-disable require-jsdoc */
|
|
3125
|
+
class RedirectUriParamsPersister {
|
|
3126
|
+
constructor(options) {
|
|
2232
3127
|
this.persister = new Persister(options, 'redirect_uri_params');
|
|
2233
3128
|
}
|
|
3129
|
+
|
|
2234
3130
|
/**
|
|
2235
3131
|
* Clears query and hash params from redirect_uri and persists them in storage
|
|
2236
3132
|
* @param {Object} params
|
|
2237
3133
|
*/
|
|
3134
|
+
persist(params) {
|
|
3135
|
+
const redirectUrl = new URL(params.redirect_uri);
|
|
3136
|
+
const queryParams = lib.parse(redirectUrl.search.substring(1));
|
|
3137
|
+
const hashParams = lib.parse(redirectUrl.hash.substring(1));
|
|
3138
|
+
this.persister.set(params.state, {
|
|
3139
|
+
query_params: queryParams,
|
|
3140
|
+
hash_params: hashParams
|
|
3141
|
+
});
|
|
3142
|
+
params.redirect_uri = redirectUrl.origin + redirectUrl.pathname;
|
|
3143
|
+
}
|
|
2238
3144
|
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
3145
|
+
/**
|
|
3146
|
+
* Retrieves persisted query and hash params from storage and updates current location accordingly.
|
|
3147
|
+
* Params returned by global accounts overrides persisted params in case of duplications.
|
|
3148
|
+
* @param {Object} state
|
|
3149
|
+
*/
|
|
3150
|
+
retrieve(state) {
|
|
3151
|
+
var _redirectUriParams$qu, _redirectUriParams$ha;
|
|
3152
|
+
const redirectUriParams = this.persister.get(state, false);
|
|
3153
|
+
if (!redirectUriParams) {
|
|
3154
|
+
return;
|
|
3155
|
+
}
|
|
3156
|
+
const queryParams = {
|
|
3157
|
+
...((_redirectUriParams$qu = redirectUriParams.query_params) !== null && _redirectUriParams$qu !== void 0 ? _redirectUriParams$qu : {}),
|
|
3158
|
+
...lib.parse(window.location.search.substring(1))
|
|
3159
|
+
};
|
|
3160
|
+
const hashParams = {
|
|
3161
|
+
...((_redirectUriParams$ha = redirectUriParams.hash_params) !== null && _redirectUriParams$ha !== void 0 ? _redirectUriParams$ha : {}),
|
|
3162
|
+
...lib.parse(window.location.hash.substring(1))
|
|
3163
|
+
};
|
|
3164
|
+
let uri = window.location.origin + window.location.pathname;
|
|
3165
|
+
if (queryParams) {
|
|
3166
|
+
uri += '?' + lib.stringify(queryParams);
|
|
2251
3167
|
}
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
* Params returned by global accounts overrides persisted params in case of duplications.
|
|
2255
|
-
* @param {Object} state
|
|
2256
|
-
*/
|
|
2257
|
-
|
|
2258
|
-
}, {
|
|
2259
|
-
key: "retrieve",
|
|
2260
|
-
value: function retrieve(state) {
|
|
2261
|
-
var _redirectUriParams$qu, _redirectUriParams$ha;
|
|
2262
|
-
|
|
2263
|
-
var redirectUriParams = this.persister.get(state, false);
|
|
2264
|
-
|
|
2265
|
-
if (!redirectUriParams) {
|
|
2266
|
-
return;
|
|
2267
|
-
}
|
|
2268
|
-
|
|
2269
|
-
var queryParams = _objectSpread2(_objectSpread2({}, (_redirectUriParams$qu = redirectUriParams.query_params) !== null && _redirectUriParams$qu !== void 0 ? _redirectUriParams$qu : {}), lib.parse(window.location.search.substring(1)));
|
|
2270
|
-
|
|
2271
|
-
var hashParams = _objectSpread2(_objectSpread2({}, (_redirectUriParams$ha = redirectUriParams.hash_params) !== null && _redirectUriParams$ha !== void 0 ? _redirectUriParams$ha : {}), lib.parse(window.location.hash.substring(1)));
|
|
2272
|
-
|
|
2273
|
-
var uri = window.location.origin + window.location.pathname;
|
|
2274
|
-
|
|
2275
|
-
if (queryParams) {
|
|
2276
|
-
uri += '?' + lib.stringify(queryParams);
|
|
2277
|
-
}
|
|
2278
|
-
|
|
2279
|
-
if (hashParams) {
|
|
2280
|
-
uri += '#' + lib.stringify(hashParams);
|
|
2281
|
-
}
|
|
2282
|
-
|
|
2283
|
-
window.history.replaceState({}, document.title, uri);
|
|
3168
|
+
if (hashParams) {
|
|
3169
|
+
uri += '#' + lib.stringify(hashParams);
|
|
2284
3170
|
}
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
}();
|
|
3171
|
+
window.history.replaceState({}, document.title, uri);
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
2289
3174
|
|
|
2290
3175
|
/* eslint-disable require-jsdoc */
|
|
2291
3176
|
|
|
@@ -2293,28 +3178,25 @@
|
|
|
2293
3178
|
* @author Auth0 https://github.com/auth0/auth0.js
|
|
2294
3179
|
* @license MIT
|
|
2295
3180
|
*/
|
|
2296
|
-
function string(length) {
|
|
2297
|
-
var bytes = new Uint8Array(length);
|
|
2298
|
-
var result = [];
|
|
2299
|
-
var charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._~';
|
|
2300
|
-
var cryptoObj = window.crypto || window.msCrypto;
|
|
2301
|
-
var random = '';
|
|
2302
3181
|
|
|
3182
|
+
function string(length) {
|
|
3183
|
+
const bytes = new Uint8Array(length);
|
|
3184
|
+
const result = [];
|
|
3185
|
+
const charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._~';
|
|
3186
|
+
const cryptoObj = window.crypto || window.msCrypto;
|
|
3187
|
+
let random = '';
|
|
2303
3188
|
if (!cryptoObj) {
|
|
2304
|
-
for (
|
|
3189
|
+
for (let i = 0; i < length; i++) {
|
|
2305
3190
|
random += charset.charAt(Math.floor(Math.random() * charset.length));
|
|
2306
3191
|
}
|
|
2307
3192
|
} else {
|
|
2308
3193
|
random = cryptoObj.getRandomValues(bytes);
|
|
2309
3194
|
}
|
|
2310
|
-
|
|
2311
|
-
for (var a = 0; a < random.length; a++) {
|
|
3195
|
+
for (let a = 0; a < random.length; a++) {
|
|
2312
3196
|
result.push(charset[random[a] % charset.length]);
|
|
2313
3197
|
}
|
|
2314
|
-
|
|
2315
3198
|
return result.join('');
|
|
2316
3199
|
}
|
|
2317
|
-
|
|
2318
3200
|
var random = {
|
|
2319
3201
|
string: string
|
|
2320
3202
|
};
|
|
@@ -2322,8 +3204,7 @@
|
|
|
2322
3204
|
/**
|
|
2323
3205
|
* Accounts SDK main class
|
|
2324
3206
|
*/
|
|
2325
|
-
|
|
2326
|
-
var AccountsSDK = /*#__PURE__*/function () {
|
|
3207
|
+
class AccountsSDK {
|
|
2327
3208
|
/**
|
|
2328
3209
|
* Accounts SDK constructor
|
|
2329
3210
|
*
|
|
@@ -2351,16 +3232,11 @@
|
|
|
2351
3232
|
* @param {Number} [options.pkce.code_verifier_length=128] code verifier length, between 43 and 128 characters https://tools.ietf.org/html/rfc7636#section-4.1
|
|
2352
3233
|
* @param {String} [options.pkce.code_challange_method='S256'] code challange method, use `S256` or `plain`
|
|
2353
3234
|
*/
|
|
2354
|
-
|
|
2355
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2356
|
-
|
|
2357
|
-
_classCallCheck(this, AccountsSDK);
|
|
2358
|
-
|
|
3235
|
+
constructor(options = {}) {
|
|
2359
3236
|
if (options.client_id == null) {
|
|
2360
3237
|
throw new Error('client id not provided');
|
|
2361
3238
|
}
|
|
2362
|
-
|
|
2363
|
-
var defaultOptions = {
|
|
3239
|
+
const defaultOptions = {
|
|
2364
3240
|
prompt: '',
|
|
2365
3241
|
response_type: 'token',
|
|
2366
3242
|
popup_flow: 'auto',
|
|
@@ -2390,143 +3266,109 @@
|
|
|
2390
3266
|
this.transaction = new Transaction(this.options);
|
|
2391
3267
|
this.redirectUriParamsPersister = new RedirectUriParamsPersister(this.options);
|
|
2392
3268
|
}
|
|
3269
|
+
|
|
2393
3270
|
/**
|
|
2394
3271
|
* use iframe for authorization
|
|
2395
3272
|
* @param {Object} options for overriding defaults
|
|
2396
3273
|
* @return {Object} instance of an iframe flow
|
|
2397
3274
|
*/
|
|
3275
|
+
iframe(options = {}) {
|
|
3276
|
+
const localOptions = Object.assign({}, this.options, options);
|
|
3277
|
+
return new Iframe(this, localOptions);
|
|
3278
|
+
}
|
|
2398
3279
|
|
|
3280
|
+
/**
|
|
3281
|
+
* use popup for authorization
|
|
3282
|
+
* @param {Object} options for overriding defaults
|
|
3283
|
+
* @return {Object} instance of a popup flow
|
|
3284
|
+
*/
|
|
3285
|
+
popup(options = {}) {
|
|
3286
|
+
const localOptions = Object.assign({}, this.options, options);
|
|
3287
|
+
return new Popup(this, localOptions);
|
|
3288
|
+
}
|
|
2399
3289
|
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
}
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
* @param {Object} options for overriding defaults
|
|
2410
|
-
* @return {Object} instance of a popup flow
|
|
2411
|
-
*/
|
|
2412
|
-
|
|
2413
|
-
}, {
|
|
2414
|
-
key: "popup",
|
|
2415
|
-
value: function popup() {
|
|
2416
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2417
|
-
var localOptions = Object.assign({}, this.options, options);
|
|
2418
|
-
return new Popup(this, localOptions);
|
|
2419
|
-
}
|
|
2420
|
-
/**
|
|
2421
|
-
* use redirect for authorization
|
|
2422
|
-
* @param {Object} options for overriding defaults
|
|
2423
|
-
* @return {Object} instance of a redirect flow
|
|
2424
|
-
*/
|
|
2425
|
-
|
|
2426
|
-
}, {
|
|
2427
|
-
key: "redirect",
|
|
2428
|
-
value: function redirect() {
|
|
2429
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2430
|
-
var localOptions = Object.assign({}, this.options, options);
|
|
2431
|
-
return new Redirect(this, localOptions);
|
|
2432
|
-
}
|
|
2433
|
-
/**
|
|
2434
|
-
* create authorization url
|
|
2435
|
-
* @param {Object} options for overriding defaults
|
|
2436
|
-
* @param {String} flow set 'button' for popup and iframe
|
|
2437
|
-
* @return {string} generated url
|
|
2438
|
-
*/
|
|
2439
|
-
|
|
2440
|
-
}, {
|
|
2441
|
-
key: "authorizeURL",
|
|
2442
|
-
value: function authorizeURL() {
|
|
2443
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2444
|
-
var flow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
2445
|
-
var localOptions = Object.assign({}, this.options, options);
|
|
2446
|
-
|
|
2447
|
-
if (!params.state) {
|
|
2448
|
-
localOptions.state = random.string(localOptions.key_length);
|
|
2449
|
-
}
|
|
2450
|
-
|
|
2451
|
-
if (!localOptions.redirect_uri) {
|
|
2452
|
-
localOptions.redirect_uri = window.location.href;
|
|
2453
|
-
}
|
|
2454
|
-
|
|
2455
|
-
var params = pick(localOptions, ['client_id', 'redirect_uri', 'state', 'response_type', 'scope', 'prompt']);
|
|
2456
|
-
Object.assign(params, localOptions.tracking);
|
|
2457
|
-
|
|
2458
|
-
if (params.scope === null) {
|
|
2459
|
-
delete params.scope;
|
|
2460
|
-
}
|
|
2461
|
-
|
|
2462
|
-
if (flow != null) {
|
|
2463
|
-
params.flow = flow;
|
|
2464
|
-
}
|
|
2465
|
-
|
|
2466
|
-
if (localOptions.email_hint) {
|
|
2467
|
-
params.email = localOptions.email_hint;
|
|
2468
|
-
}
|
|
2469
|
-
|
|
2470
|
-
var url = localOptions.server_url;
|
|
2471
|
-
|
|
2472
|
-
if (localOptions.popup_flow === 'manual') {
|
|
2473
|
-
url += '/signin';
|
|
2474
|
-
}
|
|
2475
|
-
|
|
2476
|
-
if (localOptions.path) {
|
|
2477
|
-
url += localOptions.path;
|
|
2478
|
-
}
|
|
3290
|
+
/**
|
|
3291
|
+
* use redirect for authorization
|
|
3292
|
+
* @param {Object} options for overriding defaults
|
|
3293
|
+
* @return {Object} instance of a redirect flow
|
|
3294
|
+
*/
|
|
3295
|
+
redirect(options = {}) {
|
|
3296
|
+
const localOptions = Object.assign({}, this.options, options);
|
|
3297
|
+
return new Redirect(this, localOptions);
|
|
3298
|
+
}
|
|
2479
3299
|
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
3300
|
+
/**
|
|
3301
|
+
* create authorization url
|
|
3302
|
+
* @param {Object} options for overriding defaults
|
|
3303
|
+
* @param {String} flow set 'button' for popup and iframe
|
|
3304
|
+
* @return {string} generated url
|
|
3305
|
+
*/
|
|
3306
|
+
authorizeURL(options = {}, flow = '') {
|
|
3307
|
+
const localOptions = Object.assign({}, this.options, options);
|
|
3308
|
+
if (!localOptions.state) {
|
|
3309
|
+
localOptions.state = random.string(localOptions.key_length);
|
|
3310
|
+
}
|
|
3311
|
+
if (!localOptions.redirect_uri) {
|
|
3312
|
+
localOptions.redirect_uri = window.location.href;
|
|
3313
|
+
}
|
|
3314
|
+
const params = pick(localOptions, ['client_id', 'redirect_uri', 'state', 'response_type', 'scope', 'prompt']);
|
|
3315
|
+
Object.assign(params, localOptions.tracking);
|
|
3316
|
+
if (params.scope === null) {
|
|
3317
|
+
delete params.scope;
|
|
3318
|
+
}
|
|
3319
|
+
if (flow != null) {
|
|
3320
|
+
params.flow = flow;
|
|
3321
|
+
}
|
|
3322
|
+
if (localOptions.email_hint) {
|
|
3323
|
+
params.email = localOptions.email_hint;
|
|
3324
|
+
}
|
|
3325
|
+
let url = localOptions.server_url;
|
|
3326
|
+
if (localOptions.popup_flow === 'manual') {
|
|
3327
|
+
url += '/signin';
|
|
3328
|
+
}
|
|
3329
|
+
if (localOptions.path) {
|
|
3330
|
+
url += localOptions.path;
|
|
3331
|
+
}
|
|
3332
|
+
if (localOptions.response_type === 'code' && localOptions.pkce.enabled) {
|
|
3333
|
+
const codeVerifier = localOptions.pkce.code_verifier || random.string(localOptions.pkce.code_verifier_length);
|
|
3334
|
+
switch (localOptions.pkce.code_challange_method) {
|
|
3335
|
+
case 'S256':
|
|
3336
|
+
const codeChallenge = sjcl.hash.sha256.hash(codeVerifier);
|
|
3337
|
+
Object.assign(params, {
|
|
3338
|
+
code_verifier: codeVerifier,
|
|
3339
|
+
code_challenge: encoding.base64URLEncode(codeChallenge),
|
|
3340
|
+
code_challenge_method: localOptions.pkce.code_challange_method
|
|
3341
|
+
});
|
|
3342
|
+
break;
|
|
3343
|
+
default:
|
|
3344
|
+
Object.assign(params, {
|
|
3345
|
+
code_verifier: codeVerifier,
|
|
3346
|
+
code_challenge: codeVerifier,
|
|
3347
|
+
code_challenge_method: localOptions.pkce.code_challange_method
|
|
3348
|
+
});
|
|
2500
3349
|
}
|
|
2501
|
-
|
|
2502
|
-
this.transaction.generate(params);
|
|
2503
|
-
this.redirectUriParamsPersister.persist(params);
|
|
2504
|
-
delete params.code_verifier;
|
|
2505
|
-
return url + '?' + lib.stringify(params);
|
|
2506
3350
|
}
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
}, {
|
|
2514
|
-
key: "verify",
|
|
2515
|
-
value: function verify(authorizeData) {
|
|
2516
|
-
var transactionData = this.transaction.get(authorizeData.state);
|
|
3351
|
+
this.transaction.generate(params);
|
|
3352
|
+
this.redirectUriParamsPersister.persist(params);
|
|
3353
|
+
delete params.code_verifier;
|
|
3354
|
+
return url + '?' + lib.stringify(params);
|
|
3355
|
+
}
|
|
2517
3356
|
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
3357
|
+
/**
|
|
3358
|
+
* This function verifies if redirect transaction params are valid.
|
|
3359
|
+
* @param {Object} authorizeData authorize data to validate and return transaction state - redirect state, pkce code verifier
|
|
3360
|
+
* @return {Object} transaction state if valid, null otherwise
|
|
3361
|
+
*/
|
|
3362
|
+
verify(authorizeData) {
|
|
3363
|
+
const transactionData = this.transaction.get(authorizeData.state);
|
|
3364
|
+
if (authorizeData.state && this.options.verify_state) {
|
|
3365
|
+
if (transactionData.state != authorizeData.state) {
|
|
3366
|
+
return null;
|
|
2522
3367
|
}
|
|
2523
|
-
|
|
2524
|
-
return transactionData;
|
|
2525
3368
|
}
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
}();
|
|
3369
|
+
return transactionData;
|
|
3370
|
+
}
|
|
3371
|
+
}
|
|
2530
3372
|
|
|
2531
3373
|
return AccountsSDK;
|
|
2532
3374
|
|