@govuk-pay/pay-js-commons 3.7.0 → 3.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,537 @@
1
1
  (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2
+ (function (process){(function (){
3
+ // 'path' module extracted from Node.js v8.11.1 (only the posix part)
4
+ // transplited with Babel
5
+
6
+ // Copyright Joyent, Inc. and other Node contributors.
7
+ //
8
+ // Permission is hereby granted, free of charge, to any person obtaining a
9
+ // copy of this software and associated documentation files (the
10
+ // "Software"), to deal in the Software without restriction, including
11
+ // without limitation the rights to use, copy, modify, merge, publish,
12
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
13
+ // persons to whom the Software is furnished to do so, subject to the
14
+ // following conditions:
15
+ //
16
+ // The above copyright notice and this permission notice shall be included
17
+ // in all copies or substantial portions of the Software.
18
+ //
19
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
22
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
23
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+
27
+ 'use strict';
28
+
29
+ function assertPath(path) {
30
+ if (typeof path !== 'string') {
31
+ throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));
32
+ }
33
+ }
34
+
35
+ // Resolves . and .. elements in a path with directory names
36
+ function normalizeStringPosix(path, allowAboveRoot) {
37
+ var res = '';
38
+ var lastSegmentLength = 0;
39
+ var lastSlash = -1;
40
+ var dots = 0;
41
+ var code;
42
+ for (var i = 0; i <= path.length; ++i) {
43
+ if (i < path.length)
44
+ code = path.charCodeAt(i);
45
+ else if (code === 47 /*/*/)
46
+ break;
47
+ else
48
+ code = 47 /*/*/;
49
+ if (code === 47 /*/*/) {
50
+ if (lastSlash === i - 1 || dots === 1) {
51
+ // NOOP
52
+ } else if (lastSlash !== i - 1 && dots === 2) {
53
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {
54
+ if (res.length > 2) {
55
+ var lastSlashIndex = res.lastIndexOf('/');
56
+ if (lastSlashIndex !== res.length - 1) {
57
+ if (lastSlashIndex === -1) {
58
+ res = '';
59
+ lastSegmentLength = 0;
60
+ } else {
61
+ res = res.slice(0, lastSlashIndex);
62
+ lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
63
+ }
64
+ lastSlash = i;
65
+ dots = 0;
66
+ continue;
67
+ }
68
+ } else if (res.length === 2 || res.length === 1) {
69
+ res = '';
70
+ lastSegmentLength = 0;
71
+ lastSlash = i;
72
+ dots = 0;
73
+ continue;
74
+ }
75
+ }
76
+ if (allowAboveRoot) {
77
+ if (res.length > 0)
78
+ res += '/..';
79
+ else
80
+ res = '..';
81
+ lastSegmentLength = 2;
82
+ }
83
+ } else {
84
+ if (res.length > 0)
85
+ res += '/' + path.slice(lastSlash + 1, i);
86
+ else
87
+ res = path.slice(lastSlash + 1, i);
88
+ lastSegmentLength = i - lastSlash - 1;
89
+ }
90
+ lastSlash = i;
91
+ dots = 0;
92
+ } else if (code === 46 /*.*/ && dots !== -1) {
93
+ ++dots;
94
+ } else {
95
+ dots = -1;
96
+ }
97
+ }
98
+ return res;
99
+ }
100
+
101
+ function _format(sep, pathObject) {
102
+ var dir = pathObject.dir || pathObject.root;
103
+ var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');
104
+ if (!dir) {
105
+ return base;
106
+ }
107
+ if (dir === pathObject.root) {
108
+ return dir + base;
109
+ }
110
+ return dir + sep + base;
111
+ }
112
+
113
+ var posix = {
114
+ // path.resolve([from ...], to)
115
+ resolve: function resolve() {
116
+ var resolvedPath = '';
117
+ var resolvedAbsolute = false;
118
+ var cwd;
119
+
120
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
121
+ var path;
122
+ if (i >= 0)
123
+ path = arguments[i];
124
+ else {
125
+ if (cwd === undefined)
126
+ cwd = process.cwd();
127
+ path = cwd;
128
+ }
129
+
130
+ assertPath(path);
131
+
132
+ // Skip empty entries
133
+ if (path.length === 0) {
134
+ continue;
135
+ }
136
+
137
+ resolvedPath = path + '/' + resolvedPath;
138
+ resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;
139
+ }
140
+
141
+ // At this point the path should be resolved to a full absolute path, but
142
+ // handle relative paths to be safe (might happen when process.cwd() fails)
143
+
144
+ // Normalize the path
145
+ resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
146
+
147
+ if (resolvedAbsolute) {
148
+ if (resolvedPath.length > 0)
149
+ return '/' + resolvedPath;
150
+ else
151
+ return '/';
152
+ } else if (resolvedPath.length > 0) {
153
+ return resolvedPath;
154
+ } else {
155
+ return '.';
156
+ }
157
+ },
158
+
159
+ normalize: function normalize(path) {
160
+ assertPath(path);
161
+
162
+ if (path.length === 0) return '.';
163
+
164
+ var isAbsolute = path.charCodeAt(0) === 47 /*/*/;
165
+ var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;
166
+
167
+ // Normalize the path
168
+ path = normalizeStringPosix(path, !isAbsolute);
169
+
170
+ if (path.length === 0 && !isAbsolute) path = '.';
171
+ if (path.length > 0 && trailingSeparator) path += '/';
172
+
173
+ if (isAbsolute) return '/' + path;
174
+ return path;
175
+ },
176
+
177
+ isAbsolute: function isAbsolute(path) {
178
+ assertPath(path);
179
+ return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;
180
+ },
181
+
182
+ join: function join() {
183
+ if (arguments.length === 0)
184
+ return '.';
185
+ var joined;
186
+ for (var i = 0; i < arguments.length; ++i) {
187
+ var arg = arguments[i];
188
+ assertPath(arg);
189
+ if (arg.length > 0) {
190
+ if (joined === undefined)
191
+ joined = arg;
192
+ else
193
+ joined += '/' + arg;
194
+ }
195
+ }
196
+ if (joined === undefined)
197
+ return '.';
198
+ return posix.normalize(joined);
199
+ },
200
+
201
+ relative: function relative(from, to) {
202
+ assertPath(from);
203
+ assertPath(to);
204
+
205
+ if (from === to) return '';
206
+
207
+ from = posix.resolve(from);
208
+ to = posix.resolve(to);
209
+
210
+ if (from === to) return '';
211
+
212
+ // Trim any leading backslashes
213
+ var fromStart = 1;
214
+ for (; fromStart < from.length; ++fromStart) {
215
+ if (from.charCodeAt(fromStart) !== 47 /*/*/)
216
+ break;
217
+ }
218
+ var fromEnd = from.length;
219
+ var fromLen = fromEnd - fromStart;
220
+
221
+ // Trim any leading backslashes
222
+ var toStart = 1;
223
+ for (; toStart < to.length; ++toStart) {
224
+ if (to.charCodeAt(toStart) !== 47 /*/*/)
225
+ break;
226
+ }
227
+ var toEnd = to.length;
228
+ var toLen = toEnd - toStart;
229
+
230
+ // Compare paths to find the longest common path from root
231
+ var length = fromLen < toLen ? fromLen : toLen;
232
+ var lastCommonSep = -1;
233
+ var i = 0;
234
+ for (; i <= length; ++i) {
235
+ if (i === length) {
236
+ if (toLen > length) {
237
+ if (to.charCodeAt(toStart + i) === 47 /*/*/) {
238
+ // We get here if `from` is the exact base path for `to`.
239
+ // For example: from='/foo/bar'; to='/foo/bar/baz'
240
+ return to.slice(toStart + i + 1);
241
+ } else if (i === 0) {
242
+ // We get here if `from` is the root
243
+ // For example: from='/'; to='/foo'
244
+ return to.slice(toStart + i);
245
+ }
246
+ } else if (fromLen > length) {
247
+ if (from.charCodeAt(fromStart + i) === 47 /*/*/) {
248
+ // We get here if `to` is the exact base path for `from`.
249
+ // For example: from='/foo/bar/baz'; to='/foo/bar'
250
+ lastCommonSep = i;
251
+ } else if (i === 0) {
252
+ // We get here if `to` is the root.
253
+ // For example: from='/foo'; to='/'
254
+ lastCommonSep = 0;
255
+ }
256
+ }
257
+ break;
258
+ }
259
+ var fromCode = from.charCodeAt(fromStart + i);
260
+ var toCode = to.charCodeAt(toStart + i);
261
+ if (fromCode !== toCode)
262
+ break;
263
+ else if (fromCode === 47 /*/*/)
264
+ lastCommonSep = i;
265
+ }
266
+
267
+ var out = '';
268
+ // Generate the relative path based on the path difference between `to`
269
+ // and `from`
270
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
271
+ if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {
272
+ if (out.length === 0)
273
+ out += '..';
274
+ else
275
+ out += '/..';
276
+ }
277
+ }
278
+
279
+ // Lastly, append the rest of the destination (`to`) path that comes after
280
+ // the common path parts
281
+ if (out.length > 0)
282
+ return out + to.slice(toStart + lastCommonSep);
283
+ else {
284
+ toStart += lastCommonSep;
285
+ if (to.charCodeAt(toStart) === 47 /*/*/)
286
+ ++toStart;
287
+ return to.slice(toStart);
288
+ }
289
+ },
290
+
291
+ _makeLong: function _makeLong(path) {
292
+ return path;
293
+ },
294
+
295
+ dirname: function dirname(path) {
296
+ assertPath(path);
297
+ if (path.length === 0) return '.';
298
+ var code = path.charCodeAt(0);
299
+ var hasRoot = code === 47 /*/*/;
300
+ var end = -1;
301
+ var matchedSlash = true;
302
+ for (var i = path.length - 1; i >= 1; --i) {
303
+ code = path.charCodeAt(i);
304
+ if (code === 47 /*/*/) {
305
+ if (!matchedSlash) {
306
+ end = i;
307
+ break;
308
+ }
309
+ } else {
310
+ // We saw the first non-path separator
311
+ matchedSlash = false;
312
+ }
313
+ }
314
+
315
+ if (end === -1) return hasRoot ? '/' : '.';
316
+ if (hasRoot && end === 1) return '//';
317
+ return path.slice(0, end);
318
+ },
319
+
320
+ basename: function basename(path, ext) {
321
+ if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string');
322
+ assertPath(path);
323
+
324
+ var start = 0;
325
+ var end = -1;
326
+ var matchedSlash = true;
327
+ var i;
328
+
329
+ if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
330
+ if (ext.length === path.length && ext === path) return '';
331
+ var extIdx = ext.length - 1;
332
+ var firstNonSlashEnd = -1;
333
+ for (i = path.length - 1; i >= 0; --i) {
334
+ var code = path.charCodeAt(i);
335
+ if (code === 47 /*/*/) {
336
+ // If we reached a path separator that was not part of a set of path
337
+ // separators at the end of the string, stop now
338
+ if (!matchedSlash) {
339
+ start = i + 1;
340
+ break;
341
+ }
342
+ } else {
343
+ if (firstNonSlashEnd === -1) {
344
+ // We saw the first non-path separator, remember this index in case
345
+ // we need it if the extension ends up not matching
346
+ matchedSlash = false;
347
+ firstNonSlashEnd = i + 1;
348
+ }
349
+ if (extIdx >= 0) {
350
+ // Try to match the explicit extension
351
+ if (code === ext.charCodeAt(extIdx)) {
352
+ if (--extIdx === -1) {
353
+ // We matched the extension, so mark this as the end of our path
354
+ // component
355
+ end = i;
356
+ }
357
+ } else {
358
+ // Extension does not match, so our result is the entire path
359
+ // component
360
+ extIdx = -1;
361
+ end = firstNonSlashEnd;
362
+ }
363
+ }
364
+ }
365
+ }
366
+
367
+ if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;
368
+ return path.slice(start, end);
369
+ } else {
370
+ for (i = path.length - 1; i >= 0; --i) {
371
+ if (path.charCodeAt(i) === 47 /*/*/) {
372
+ // If we reached a path separator that was not part of a set of path
373
+ // separators at the end of the string, stop now
374
+ if (!matchedSlash) {
375
+ start = i + 1;
376
+ break;
377
+ }
378
+ } else if (end === -1) {
379
+ // We saw the first non-path separator, mark this as the end of our
380
+ // path component
381
+ matchedSlash = false;
382
+ end = i + 1;
383
+ }
384
+ }
385
+
386
+ if (end === -1) return '';
387
+ return path.slice(start, end);
388
+ }
389
+ },
390
+
391
+ extname: function extname(path) {
392
+ assertPath(path);
393
+ var startDot = -1;
394
+ var startPart = 0;
395
+ var end = -1;
396
+ var matchedSlash = true;
397
+ // Track the state of characters (if any) we see before our first dot and
398
+ // after any path separator we find
399
+ var preDotState = 0;
400
+ for (var i = path.length - 1; i >= 0; --i) {
401
+ var code = path.charCodeAt(i);
402
+ if (code === 47 /*/*/) {
403
+ // If we reached a path separator that was not part of a set of path
404
+ // separators at the end of the string, stop now
405
+ if (!matchedSlash) {
406
+ startPart = i + 1;
407
+ break;
408
+ }
409
+ continue;
410
+ }
411
+ if (end === -1) {
412
+ // We saw the first non-path separator, mark this as the end of our
413
+ // extension
414
+ matchedSlash = false;
415
+ end = i + 1;
416
+ }
417
+ if (code === 46 /*.*/) {
418
+ // If this is our first dot, mark it as the start of our extension
419
+ if (startDot === -1)
420
+ startDot = i;
421
+ else if (preDotState !== 1)
422
+ preDotState = 1;
423
+ } else if (startDot !== -1) {
424
+ // We saw a non-dot and non-path separator before our dot, so we should
425
+ // have a good chance at having a non-empty extension
426
+ preDotState = -1;
427
+ }
428
+ }
429
+
430
+ if (startDot === -1 || end === -1 ||
431
+ // We saw a non-dot character immediately before the dot
432
+ preDotState === 0 ||
433
+ // The (right-most) trimmed path component is exactly '..'
434
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
435
+ return '';
436
+ }
437
+ return path.slice(startDot, end);
438
+ },
439
+
440
+ format: function format(pathObject) {
441
+ if (pathObject === null || typeof pathObject !== 'object') {
442
+ throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
443
+ }
444
+ return _format('/', pathObject);
445
+ },
446
+
447
+ parse: function parse(path) {
448
+ assertPath(path);
449
+
450
+ var ret = { root: '', dir: '', base: '', ext: '', name: '' };
451
+ if (path.length === 0) return ret;
452
+ var code = path.charCodeAt(0);
453
+ var isAbsolute = code === 47 /*/*/;
454
+ var start;
455
+ if (isAbsolute) {
456
+ ret.root = '/';
457
+ start = 1;
458
+ } else {
459
+ start = 0;
460
+ }
461
+ var startDot = -1;
462
+ var startPart = 0;
463
+ var end = -1;
464
+ var matchedSlash = true;
465
+ var i = path.length - 1;
466
+
467
+ // Track the state of characters (if any) we see before our first dot and
468
+ // after any path separator we find
469
+ var preDotState = 0;
470
+
471
+ // Get non-dir info
472
+ for (; i >= start; --i) {
473
+ code = path.charCodeAt(i);
474
+ if (code === 47 /*/*/) {
475
+ // If we reached a path separator that was not part of a set of path
476
+ // separators at the end of the string, stop now
477
+ if (!matchedSlash) {
478
+ startPart = i + 1;
479
+ break;
480
+ }
481
+ continue;
482
+ }
483
+ if (end === -1) {
484
+ // We saw the first non-path separator, mark this as the end of our
485
+ // extension
486
+ matchedSlash = false;
487
+ end = i + 1;
488
+ }
489
+ if (code === 46 /*.*/) {
490
+ // If this is our first dot, mark it as the start of our extension
491
+ if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;
492
+ } else if (startDot !== -1) {
493
+ // We saw a non-dot and non-path separator before our dot, so we should
494
+ // have a good chance at having a non-empty extension
495
+ preDotState = -1;
496
+ }
497
+ }
498
+
499
+ if (startDot === -1 || end === -1 ||
500
+ // We saw a non-dot character immediately before the dot
501
+ preDotState === 0 ||
502
+ // The (right-most) trimmed path component is exactly '..'
503
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
504
+ if (end !== -1) {
505
+ if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);
506
+ }
507
+ } else {
508
+ if (startPart === 0 && isAbsolute) {
509
+ ret.name = path.slice(1, startDot);
510
+ ret.base = path.slice(1, end);
511
+ } else {
512
+ ret.name = path.slice(startPart, startDot);
513
+ ret.base = path.slice(startPart, end);
514
+ }
515
+ ret.ext = path.slice(startDot, end);
516
+ }
517
+
518
+ if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';
519
+
520
+ return ret;
521
+ },
522
+
523
+ sep: '/',
524
+ delimiter: ':',
525
+ win32: null,
526
+ posix: null
527
+ };
528
+
529
+ posix.posix = posix;
530
+
531
+ module.exports = posix;
532
+
533
+ }).call(this)}).call(this,require('_process'))
534
+ },{"_process":3}],2:[function(require,module,exports){
2
535
  /*! js-cookie v3.0.1 | MIT */
3
536
  ;
4
537
  (function (global, factory) {
@@ -147,32 +680,212 @@
147
680
 
148
681
  })));
149
682
 
150
- },{}],2:[function(require,module,exports){
151
- "use strict";
683
+ },{}],3:[function(require,module,exports){
684
+ // shim for using process in browser
685
+ var process = module.exports = {};
686
+
687
+ // cached from whatever global is present so that test runners that stub it
688
+ // don't break things. But we need to wrap it in a try catch in case it is
689
+ // wrapped in strict mode code which doesn't define any globals. It's inside a
690
+ // function because try/catches deoptimize in certain engines.
691
+
692
+ var cachedSetTimeout;
693
+ var cachedClearTimeout;
694
+
695
+ function defaultSetTimout() {
696
+ throw new Error('setTimeout has not been defined');
697
+ }
698
+ function defaultClearTimeout () {
699
+ throw new Error('clearTimeout has not been defined');
700
+ }
701
+ (function () {
702
+ try {
703
+ if (typeof setTimeout === 'function') {
704
+ cachedSetTimeout = setTimeout;
705
+ } else {
706
+ cachedSetTimeout = defaultSetTimout;
707
+ }
708
+ } catch (e) {
709
+ cachedSetTimeout = defaultSetTimout;
710
+ }
711
+ try {
712
+ if (typeof clearTimeout === 'function') {
713
+ cachedClearTimeout = clearTimeout;
714
+ } else {
715
+ cachedClearTimeout = defaultClearTimeout;
716
+ }
717
+ } catch (e) {
718
+ cachedClearTimeout = defaultClearTimeout;
719
+ }
720
+ } ())
721
+ function runTimeout(fun) {
722
+ if (cachedSetTimeout === setTimeout) {
723
+ //normal enviroments in sane situations
724
+ return setTimeout(fun, 0);
725
+ }
726
+ // if setTimeout wasn't available but was latter defined
727
+ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
728
+ cachedSetTimeout = setTimeout;
729
+ return setTimeout(fun, 0);
730
+ }
731
+ try {
732
+ // when when somebody has screwed with setTimeout but no I.E. maddness
733
+ return cachedSetTimeout(fun, 0);
734
+ } catch(e){
735
+ try {
736
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
737
+ return cachedSetTimeout.call(null, fun, 0);
738
+ } catch(e){
739
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
740
+ return cachedSetTimeout.call(this, fun, 0);
741
+ }
742
+ }
743
+
744
+
745
+ }
746
+ function runClearTimeout(marker) {
747
+ if (cachedClearTimeout === clearTimeout) {
748
+ //normal enviroments in sane situations
749
+ return clearTimeout(marker);
750
+ }
751
+ // if clearTimeout wasn't available but was latter defined
752
+ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
753
+ cachedClearTimeout = clearTimeout;
754
+ return clearTimeout(marker);
755
+ }
756
+ try {
757
+ // when when somebody has screwed with setTimeout but no I.E. maddness
758
+ return cachedClearTimeout(marker);
759
+ } catch (e){
760
+ try {
761
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
762
+ return cachedClearTimeout.call(null, marker);
763
+ } catch (e){
764
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
765
+ // Some versions of I.E. have different rules for clearTimeout vs setTimeout
766
+ return cachedClearTimeout.call(this, marker);
767
+ }
768
+ }
152
769
 
153
- var Cookies = require('js-cookie'); // eslint-disable-next-line node/no-path-concat
154
770
 
155
771
 
772
+ }
773
+ var queue = [];
774
+ var draining = false;
775
+ var currentQueue;
776
+ var queueIndex = -1;
777
+
778
+ function cleanUpNextTick() {
779
+ if (!draining || !currentQueue) {
780
+ return;
781
+ }
782
+ draining = false;
783
+ if (currentQueue.length) {
784
+ queue = currentQueue.concat(queue);
785
+ } else {
786
+ queueIndex = -1;
787
+ }
788
+ if (queue.length) {
789
+ drainQueue();
790
+ }
791
+ }
792
+
793
+ function drainQueue() {
794
+ if (draining) {
795
+ return;
796
+ }
797
+ var timeout = runTimeout(cleanUpNextTick);
798
+ draining = true;
799
+
800
+ var len = queue.length;
801
+ while(len) {
802
+ currentQueue = queue;
803
+ queue = [];
804
+ while (++queueIndex < len) {
805
+ if (currentQueue) {
806
+ currentQueue[queueIndex].run();
807
+ }
808
+ }
809
+ queueIndex = -1;
810
+ len = queue.length;
811
+ }
812
+ currentQueue = null;
813
+ draining = false;
814
+ runClearTimeout(timeout);
815
+ }
816
+
817
+ process.nextTick = function (fun) {
818
+ var args = new Array(arguments.length - 1);
819
+ if (arguments.length > 1) {
820
+ for (var i = 1; i < arguments.length; i++) {
821
+ args[i - 1] = arguments[i];
822
+ }
823
+ }
824
+ queue.push(new Item(fun, args));
825
+ if (queue.length === 1 && !draining) {
826
+ runTimeout(drainQueue);
827
+ }
828
+ };
829
+
830
+ // v8 likes predictible objects
831
+ function Item(fun, array) {
832
+ this.fun = fun;
833
+ this.array = array;
834
+ }
835
+ Item.prototype.run = function () {
836
+ this.fun.apply(null, this.array);
837
+ };
838
+ process.title = 'browser';
839
+ process.browser = true;
840
+ process.env = {};
841
+ process.argv = [];
842
+ process.version = ''; // empty string to avoid regexp issues
843
+ process.versions = {};
844
+
845
+ function noop() {}
846
+
847
+ process.on = noop;
848
+ process.addListener = noop;
849
+ process.once = noop;
850
+ process.off = noop;
851
+ process.removeListener = noop;
852
+ process.removeAllListeners = noop;
853
+ process.emit = noop;
854
+ process.prependListener = noop;
855
+ process.prependOnceListener = noop;
856
+
857
+ process.listeners = function (name) { return [] }
858
+
859
+ process.binding = function (name) {
860
+ throw new Error('process.binding is not supported');
861
+ };
862
+
863
+ process.cwd = function () { return '/' };
864
+ process.chdir = function (dir) {
865
+ throw new Error('process.chdir is not supported');
866
+ };
867
+ process.umask = function() { return 0; };
868
+
869
+ },{}],4:[function(require,module,exports){
870
+ "use strict";
871
+
872
+ var Cookies = require('js-cookie');
873
+ var path = require('path');
156
874
  var template = "<style>\n\t/* component should only be shown if JS is available, by the cookieMessage JS, so hide by default */\n\t.pay-cookie-banner {\n\t\tdisplay: block;\n\t}\n\n\t.pay-cookie-banner__wrapper {\n\t\tpadding-top: 15px;\n \tpadding-bottom: 15px;\n\t}\n\n\t.pay-cookie-banner__buttons {\n\t\tdisplay: flex;\n\t\tflex-wrap: wrap;\n\t}\n\n\t@media (min-width: 40.0625em){\n\t\t.pay-cookie-banner__buttons {\n\t\t\tflex-wrap: nowrap;\n\t\t}\n\t}\n\n\n\t.pay-cookie-banner__button,\n\t.pay-cookie-banner__link {\n\t\tvertical-align: baseline;\n\t}\n\n\t.pay-cookie-banner__button {\n\t\tdisplay: inline-block;\n\t\tflex: 1 0;\n\t\tpadding-left: 60px;\n\t\tpadding-right: 60px;\n\t\tmargin-bottom: 10px;\n\t\tmargin-right: 20px;\n\t}\n\n\t@media (min-width: 40.0625em){\n\t\t.pay-cookie-banner__button {\n\t\t\tflex: 0 0 150px;\n\t\t\tpadding-left: 10px;\n\t\t\tpadding-right: 10px;\n\t\t\tmargin-bottom: 5px;\n\t\t}\n\t}\n\t\n\t.pay-cookie-banner__link {\n\t\tfont-family: \"GDS Transport\", Arial, sans-serif;\n\t\tfont-weight: 400;\n\t\tfont-size: 16px;\n\t\tfont-size: 1rem;\n\t\tline-height: 1.25;\n\t\tline-height: 1;\n\t\tdisplay: block;\n\t\twidth: 100%;\n\t padding: 9px 0px 6px;\n\t}\n\t\n\t@media (min-width: 40.0625em){\n\t\t.pay-cookie-banner__link {\n\t\t\tdisplay: inline;\n\t\t\twidth: auto;\n\t\t\tmargin-left: 30px;\n\t\t}\n\t}\n\n\n\t.pay-cookie-banner__confirmation {\n\t\tdisplay: none;\n\t\tposition: relative;\n\t\tpadding: 20px 0;\n\n\t\t\n\t}\n\n\t/* This element is focused using JavaScript so that it's being read out by screen readers\n\tor this reason we don't want to show the default outline or emphasise it visually using `govuk-focused-text`*/\n\t.pay-cookie-banner__confirmation:focus {\n\t outline: none;\n\t}\n\n\n\t.pay-cookie-banner__confirmation-message,\n\t.pay-cookie-banner__hide-button {\n\t\tdisplay: block;\n\t}\n\n\n\t@media (min-width: 48.0625em){\n\t\t.pay-cookie-banner__confirmation-message, \n\t\t.pay-cookie-banner__hide-button {\n\t\t display: inline-block;\n\t\t}\n\t}\n\n\t.pay-cookie-banner__confirmation-message {\n\t\tmargin-right: 20px;\n\t}\n\n\t@media (min-width: 48.0625em){\n\t\t.pay-cookie-banner__confirmation-message {\n\t\t\tmax-width: 90%;\n\t\t}\n\t}\n\n\t.pay-cookie-banner__hide-button {\n\t\tfont-family: \"GDS Transport\", Arial, sans-serif;\n\t\tfont-weight: 400;\n\t\tfont-size: 16px;\n\t\tfont-size: 1rem;\n\t\tline-height: 1.25;\n\t\tcolor: #1d70b8;\n\t\toutline: 0;\n\t\tborder: 0;\n\t\tbackground: none;\n\t\ttext-decoration: underline;\n\t\tpadding: 0;\n\t\tmargin-top: 10px;\n\t\tright: 15px;\n\t\tcursor: pointer;\n\t}\n\n\t@media (min-width: 40.0625em){\n\t\t.pay-cookie-banner__hide-button {\n\t\t\tfont-size: 19px;\n\t\t\tfont-size: 1.1875rem;\n\t\t\tline-height: 1.3157894737;\n\t\t}\n\t}\n</style>\n<div id=\"pay-cookie-banner\" class=\"pay-cookie-banner govuk-width-container\" data-module=\"pay-cookie-banner\" role=\"region\" aria-label=\"cookie banner\">\n\t<div class=\"pay-cookie-banner__wrapper\">\n\t\t<h2 class=\"pay-cookie-banner__heading govuk-heading-m\" id=\"pay-cookie-banner__heading\">\n\t\t\tCan we store analytics cookies on your device?\n\t\t</h2>\n\t\t<p class=\"govuk-body\">\n\t\t\tAnalytics cookies help us understand how our website is being used.\n\t\t</p>\n\t\t<div class=\"pay-cookie-banner__buttons\">\n\t\t\t<button class=\"govuk-button pay-cookie-banner__button pay-cookie-banner__button--accept\" type=\"submit\" data-accept-cookies=\"true\" aria-describedby=\"pay-cookie-banner__heading\">\n\t\t\t\tYes<span class=\"govuk-visually-hidden\">, GOV.UK Pay can store analytics cookies on your device</span>\n\t\t\t</button>\n\t\t\t<button class=\"govuk-button pay-cookie-banner__button pay-cookie-banner__button--reject\" type=\"submit\" data-accept-cookies=\"false\" aria-describedby=\"pay-cookie-banner__heading\">\n\t\t\t\tNo<span class=\"govuk-visually-hidden\">, GOV.UK Pay cannot store analytics cookies on your device</span>\n\t\t\t</button>\n\t\t\t<a class=\"govuk-link pay-cookie-banner__link\" href=\"https://www.payments.service.gov.uk/cookies\">How GOV.UK Pay uses cookies</a>\n\t\t</div>\n\t</div>\n\n\t<div class=\"pay-cookie-banner__confirmation\" tabindex=\"-1\">\n\t\t<p class=\"pay-cookie-banner__confirmation-message govuk-body\">\n\t\t\tYou can <a class=\"govuk-link\" href=\"https://www.payments.service.gov.uk/cookies/\">change your cookie settings</a> at any time.\n\t\t</p>\n\t\t<button class=\"pay-cookie-banner__hide-button govuk-link\" data-hide-cookie-banner=\"true\" role=\"link\">Hide</button>\n\t</div>\n</div>\n";
157
875
  var GOVUK_PAY_ANALYTICS_CONSENT_COOKIE_NAME = 'govuk_pay_cookie_policy';
158
876
  var ANALYTICS_CONSENT_BANNER_ID = 'pay-cookie-banner';
159
-
160
877
  function hasAnalyticsConsent() {
161
878
  var cookie = Cookies.get(GOVUK_PAY_ANALYTICS_CONSENT_COOKIE_NAME);
162
879
  var parsed = cookie && JSON.parse(cookie);
163
880
  return Boolean(parsed) && parsed.analytics === true;
164
881
  }
165
-
166
882
  function getCookieDomain() {
167
883
  var PROD_HOSTNAME = 'payments.service.gov.uk';
168
-
169
884
  if (window.location.hostname.includes(PROD_HOSTNAME)) {
170
885
  return PROD_HOSTNAME;
171
886
  }
172
-
173
887
  return undefined;
174
888
  }
175
-
176
889
  function setAnalyticsCookie() {
177
890
  var userConsentedToAnalytics = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
178
891
  var cookieValue = JSON.stringify({
@@ -185,19 +898,15 @@ function setAnalyticsCookie() {
185
898
  };
186
899
  Cookies.set(GOVUK_PAY_ANALYTICS_CONSENT_COOKIE_NAME, cookieValue, cookieAttributes);
187
900
  }
188
-
189
901
  function hideBannerIfExists(event) {
190
902
  var banner = document.querySelector("#".concat(ANALYTICS_CONSENT_BANNER_ID));
191
-
192
903
  if (banner) {
193
904
  banner.style.display = 'none';
194
905
  }
195
-
196
906
  if (event.target) {
197
907
  event.preventDefault();
198
908
  }
199
909
  }
200
-
201
910
  function showConfirmationMessage(analyticsConsent) {
202
911
  var messagePrefix = analyticsConsent ? 'You’ve accepted analytics cookies.' : 'You told us not to use analytics cookies.';
203
912
  var $cookieBannerMainContent = document.querySelector('.pay-cookie-banner__wrapper');
@@ -207,17 +916,14 @@ function showConfirmationMessage(analyticsConsent) {
207
916
  var $cookieBannerConfirmationWrapper = document.querySelector('.pay-cookie-banner__confirmation');
208
917
  $cookieBannerConfirmationWrapper.style.display = 'block';
209
918
  }
210
-
211
919
  function acceptAnalyticsCookies() {
212
920
  setAnalyticsCookie(true);
213
921
  showConfirmationMessage(true);
214
922
  }
215
-
216
923
  function rejectAnalyticsCookies() {
217
924
  setAnalyticsCookie(false);
218
925
  showConfirmationMessage(false);
219
926
  }
220
-
221
927
  function createBannerHTMLElement() {
222
928
  var consentProvidedCallback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {};
223
929
  var banner = document.createElement('div');
@@ -225,51 +931,42 @@ function createBannerHTMLElement() {
225
931
  banner.innerHTML = template.trim();
226
932
  var acceptButton = banner.querySelector('button[data-accept-cookies=true]');
227
933
  var rejectButton = banner.querySelector('button[data-accept-cookies=false]');
228
-
229
934
  if (acceptButton && rejectButton) {
230
935
  acceptButton.addEventListener('click', acceptAnalyticsCookies);
231
936
  acceptButton.addEventListener('click', consentProvidedCallback);
232
937
  rejectButton.addEventListener('click', rejectAnalyticsCookies);
233
938
  }
234
-
235
939
  var hideCookieBannerLink = banner.querySelector('button[data-hide-cookie-banner]');
236
-
237
940
  if (hideCookieBannerLink) {
238
941
  hideCookieBannerLink.addEventListener('click', hideBannerIfExists);
239
942
  }
240
-
241
943
  return banner;
242
944
  }
945
+
243
946
  /**
244
947
  * ConsentProvidedCallback: function - generic callback that will be called
245
948
  * if and only if the user provides consent
246
949
  */
247
-
248
-
249
950
  function showBannerIfConsentNotSet() {
250
951
  var consentProvidedCallback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {};
251
952
  var consentCookieNotSet = !Cookies.get(GOVUK_PAY_ANALYTICS_CONSENT_COOKIE_NAME);
252
953
  var banner = document.querySelector("#".concat(ANALYTICS_CONSENT_BANNER_ID));
253
-
254
954
  if (consentCookieNotSet && !banner) {
255
955
  var _banner = createBannerHTMLElement(consentProvidedCallback);
256
-
257
956
  document.body.prepend(_banner);
258
957
  }
259
958
  }
260
-
261
959
  module.exports = {
262
960
  hasAnalyticsConsent: hasAnalyticsConsent,
263
961
  showBannerIfConsentNotSet: showBannerIfConsentNotSet
264
962
  };
265
963
 
266
- },{"js-cookie":1}],3:[function(require,module,exports){
964
+ },{"js-cookie":2,"path":1}],5:[function(require,module,exports){
267
965
  "use strict";
268
966
 
269
967
  var cookies = require('./cookies/validate');
270
-
271
968
  window.GovUkPay = {
272
969
  cookies: cookies
273
970
  };
274
971
 
275
- },{"./cookies/validate":2}]},{},[3]);
972
+ },{"./cookies/validate":4}]},{},[5]);