isite 2024.8.5 → 2024.8.7

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.
Files changed (129) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +1384 -1387
  3. package/apps/charts/site_files/html/PieChart.html +35 -35
  4. package/apps/charts/site_files/html/PieChart2.html +35 -35
  5. package/apps/charts/site_files/html/XYChart.html +42 -42
  6. package/apps/charts/site_files/html/column.html +60 -60
  7. package/apps/charts/site_files/html/gauge.html +44 -44
  8. package/apps/charts/site_files/html/index.html +92 -92
  9. package/apps/charts/site_files/html/line-graph.html +42 -42
  10. package/apps/charts/site_files/html/pie-chart-rounded-corners.html +38 -38
  11. package/apps/charts/site_files/html/simple-3D-pie-chart.html +43 -43
  12. package/apps/charts/site_files/js/chart-animated.js +2 -2
  13. package/apps/charts/site_files/json/PieChart.json +41 -41
  14. package/apps/charts/site_files/json/PieChart2.json +23 -23
  15. package/apps/charts/site_files/json/XYChart.json +74 -74
  16. package/apps/charts/site_files/json/bar-chart.json +99 -99
  17. package/apps/charts/site_files/json/column-chart.json +80 -80
  18. package/apps/charts/site_files/json/gauge.json +36 -36
  19. package/apps/charts/site_files/json/line-graph.json +1867 -1867
  20. package/apps/charts/site_files/json/pie-chart-rounded-corners.json +42 -42
  21. package/apps/charts/site_files/json/simple-3D-pie-chart.json +50 -50
  22. package/apps/client-side/package-lock.json +5 -5
  23. package/apps/client-side/package.json +21 -21
  24. package/apps/client-side/site_files/css/bootstrap3.css +5 -5
  25. package/apps/client-side/site_files/css/bootstrap4.css +6 -6
  26. package/apps/client-side/site_files/css/bootstrap5.css +6 -6
  27. package/apps/client-side/site_files/css/checkbox.css +125 -125
  28. package/apps/client-side/site_files/css/font-awesome.css +4616 -4616
  29. package/apps/client-side/site_files/css/font-awesome.min.css +4 -4
  30. package/apps/client-side/site_files/css/fonts.css +85 -85
  31. package/apps/client-side/site_files/css/help.css +51 -51
  32. package/apps/client-side/site_files/css/main-menu.css +66 -66
  33. package/apps/client-side/site_files/css/print.css +144 -144
  34. package/apps/client-side/site_files/css/prism.css +139 -139
  35. package/apps/client-side/site_files/css/progress.css +7 -7
  36. package/apps/client-side/site_files/css/radio.css +103 -103
  37. package/apps/client-side/site_files/css/scrollbar.css +13 -13
  38. package/apps/client-side/site_files/css/semantic.css +363 -363
  39. package/apps/client-side/site_files/css/table.css +87 -87
  40. package/apps/client-side/site_files/css/treeview.css +84 -84
  41. package/apps/client-side/site_files/css/ui.css +28 -28
  42. package/apps/client-side/site_files/css/video-js.min.css +1 -0
  43. package/apps/client-side/site_files/fonts/fontawesome-webfont.svg +2671 -2671
  44. package/apps/client-side/site_files/fonts/glyphicons-halflings-regular.svg +287 -287
  45. package/apps/client-side/site_files/fonts/icons.svg +684 -684
  46. package/apps/client-side/site_files/js/Youtube.min.js +1 -0
  47. package/apps/client-side/site_files/js/angular-animate.js +4179 -4179
  48. package/apps/client-side/site_files/js/angular.js +36599 -36599
  49. package/apps/client-side/site_files/js/angular.min.js +351 -351
  50. package/apps/client-side/site_files/js/angular.min.js.map +8 -8
  51. package/apps/client-side/site_files/js/barcode.js +1 -1
  52. package/apps/client-side/site_files/js/base64.js +319 -319
  53. package/apps/client-side/site_files/js/bootstrap-5-directive.js +1456 -1456
  54. package/apps/client-side/site_files/js/bootstrap3.js +6 -6
  55. package/apps/client-side/site_files/js/bootstrap4.js +6 -6
  56. package/apps/client-side/site_files/js/bootstrap5.js +6 -6
  57. package/apps/client-side/site_files/js/custom.js +149 -149
  58. package/apps/client-side/site_files/js/directive.min.js +1 -1
  59. package/apps/client-side/site_files/js/hijri.js +965 -965
  60. package/apps/client-side/site_files/js/jquery.js +2 -2
  61. package/apps/client-side/site_files/js/moment.js +4511 -4511
  62. package/apps/client-side/site_files/js/prism.js +6 -6
  63. package/apps/client-side/site_files/js/qrcode.js +1398 -1398
  64. package/apps/client-side/site_files/js/semantic.js +10 -10
  65. package/apps/client-side/site_files/js/video.min.js +53 -0
  66. package/apps/client-side/site_files/js/xlsx.js +23 -23
  67. package/apps/client-side/site_files/semantic-themes/default/assets/fonts/brand-icons.svg +1008 -1008
  68. package/apps/client-side/site_files/semantic-themes/default/assets/fonts/icons.svg +1518 -1518
  69. package/apps/client-side/site_files/semantic-themes/default/assets/fonts/outline-icons.svg +366 -366
  70. package/apps/client-side/site_files/webfonts/fa-brands-400.svg +3717 -3717
  71. package/apps/client-side/site_files/webfonts/fa-regular-400.svg +801 -801
  72. package/apps/client-side/site_files/webfonts/fa-solid-900.svg +5034 -5034
  73. package/apps/security/README.md +12 -12
  74. package/apps/security/app.js +288 -288
  75. package/apps/security/libs/notifications.js +89 -89
  76. package/apps/security/site_files/html/add_modal.html +36 -36
  77. package/apps/security/site_files/html/content.html +36 -36
  78. package/apps/security/site_files/html/delete_modal.html +31 -31
  79. package/apps/security/site_files/html/head.html +7 -7
  80. package/apps/security/site_files/html/index.html +80 -80
  81. package/apps/security/site_files/html/login_modal.html +24 -24
  82. package/apps/security/site_files/html/logout_modal.html +21 -21
  83. package/apps/security/site_files/html/navbar.html +8 -8
  84. package/apps/security/site_files/html/register_modal.html +32 -32
  85. package/apps/security/site_files/html/update_modal.html +28 -28
  86. package/apps/security/site_files/html/view.html +74 -74
  87. package/apps/security/site_files/html/view_modal.html +32 -32
  88. package/apps/security/site_files/js/app.js +1 -1
  89. package/apps/security/site_files/js/index.js +278 -278
  90. package/apps/security/site_files/js/login.js +35 -35
  91. package/apps/security/site_files/js/logout.js +22 -22
  92. package/apps/security/site_files/js/navbar.js +26 -26
  93. package/apps/security/site_files/js/register.js +30 -30
  94. package/apps/security/site_files/json/permissions.json +7 -7
  95. package/apps/security/site_files/json/roles.json +33 -33
  96. package/apps/security/site_files/json/words.json +28 -28
  97. package/gulpfile.js +17 -17
  98. package/isite.postman_collection.json +7 -7
  99. package/isite_files/css/bootstrap.css +5 -5
  100. package/isite_files/css/font-awesome.css +4 -4
  101. package/isite_files/css/prism.css +139 -139
  102. package/isite_files/fonts/fontawesome-webfont.svg +2671 -2671
  103. package/isite_files/fonts/glyphicons-halflings-regular.svg +287 -287
  104. package/isite_files/html/files.html +9 -9
  105. package/isite_files/html/head.html +12 -12
  106. package/isite_files/html/index.html +30 -30
  107. package/isite_files/html/installing.html +27 -27
  108. package/isite_files/html/navbar.html +51 -51
  109. package/isite_files/html/routes.html +13 -13
  110. package/isite_files/html/sessions.html +13 -13
  111. package/isite_files/html/vars.html +9 -9
  112. package/isite_files/js/angular.js +334 -334
  113. package/isite_files/js/bootstrap.js +6 -6
  114. package/isite_files/js/custom.js +149 -149
  115. package/isite_files/js/jquery.js +4 -4
  116. package/isite_files/js/prism.js +6 -6
  117. package/lib/README.md +1 -1
  118. package/lib/collection.js +92 -41
  119. package/lib/collectionFile.js +21 -18
  120. package/lib/cookie.js +81 -81
  121. package/lib/dashboard.js +189 -189
  122. package/lib/mongodb.js +819 -756
  123. package/lib/parser.js +910 -910
  124. package/lib/security.js +48 -57
  125. package/lib/session.js +153 -153
  126. package/object-options/index.js +3 -3
  127. package/object-options/lib/isite.code-workspace +10 -10
  128. package/package.json +58 -58
  129. package/ssl/create_ssl.sh +3 -3
@@ -1,319 +1,319 @@
1
- //
2
- // THIS FILE IS AUTOMATICALLY GENERATED! DO NOT EDIT BY HAND!
3
- //
4
- ;
5
- (function (global, factory) {
6
- typeof exports === 'object' && typeof module !== 'undefined'
7
- ? module.exports = factory()
8
- : typeof define === 'function' && define.amd
9
- ? define(factory) :
10
- // cf. https://github.com/dankogai/js-base64/issues/119
11
- (function () {
12
- // existing version for noConflict()
13
- var _Base64 = global.Base64;
14
- var gBase64 = factory();
15
- gBase64.noConflict = function () {
16
- global.Base64 = _Base64;
17
- return gBase64;
18
- };
19
- if (global.Meteor) { // Meteor.js
20
- Base64 = gBase64;
21
- }
22
- global.Base64 = gBase64;
23
- })();
24
- }((typeof self !== 'undefined' ? self
25
- : typeof window !== 'undefined' ? window
26
- : typeof global !== 'undefined' ? global
27
- : this), function () {
28
- 'use strict';
29
- /**
30
- * base64.ts
31
- *
32
- * Licensed under the BSD 3-Clause License.
33
- * http://opensource.org/licenses/BSD-3-Clause
34
- *
35
- * References:
36
- * http://en.wikipedia.org/wiki/Base64
37
- *
38
- * @author Dan Kogai (https://github.com/dankogai)
39
- */
40
- var version = '3.7.2';
41
- /**
42
- * @deprecated use lowercase `version`.
43
- */
44
- var VERSION = version;
45
- var _hasatob = typeof atob === 'function';
46
- var _hasbtoa = typeof btoa === 'function';
47
- var _hasBuffer = typeof Buffer === 'function';
48
- var _TD = typeof TextDecoder === 'function' ? new TextDecoder() : undefined;
49
- var _TE = typeof TextEncoder === 'function' ? new TextEncoder() : undefined;
50
- var b64ch = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
51
- var b64chs = Array.prototype.slice.call(b64ch);
52
- var b64tab = (function (a) {
53
- var tab = {};
54
- a.forEach(function (c, i) { return tab[c] = i; });
55
- return tab;
56
- })(b64chs);
57
- var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
58
- var _fromCC = String.fromCharCode.bind(String);
59
- var _U8Afrom = typeof Uint8Array.from === 'function'
60
- ? Uint8Array.from.bind(Uint8Array)
61
- : function (it, fn) {
62
- if (fn === void 0) { fn = function (x) { return x; }; }
63
- return new Uint8Array(Array.prototype.slice.call(it, 0).map(fn));
64
- };
65
- var _mkUriSafe = function (src) { return src
66
- .replace(/=/g, '').replace(/[+\/]/g, function (m0) { return m0 == '+' ? '-' : '_'; }); };
67
- var _tidyB64 = function (s) { return s.replace(/[^A-Za-z0-9\+\/]/g, ''); };
68
- /**
69
- * polyfill version of `btoa`
70
- */
71
- var btoaPolyfill = function (bin) {
72
- // console.log('polyfilled');
73
- var u32, c0, c1, c2, asc = '';
74
- var pad = bin.length % 3;
75
- for (var i = 0; i < bin.length;) {
76
- if ((c0 = bin.charCodeAt(i++)) > 255 ||
77
- (c1 = bin.charCodeAt(i++)) > 255 ||
78
- (c2 = bin.charCodeAt(i++)) > 255)
79
- throw new TypeError('invalid character found');
80
- u32 = (c0 << 16) | (c1 << 8) | c2;
81
- asc += b64chs[u32 >> 18 & 63]
82
- + b64chs[u32 >> 12 & 63]
83
- + b64chs[u32 >> 6 & 63]
84
- + b64chs[u32 & 63];
85
- }
86
- return pad ? asc.slice(0, pad - 3) + "===".substring(pad) : asc;
87
- };
88
- /**
89
- * does what `window.btoa` of web browsers do.
90
- * @param {String} bin binary string
91
- * @returns {string} Base64-encoded string
92
- */
93
- var _btoa = _hasbtoa ? function (bin) { return btoa(bin); }
94
- : _hasBuffer ? function (bin) { return Buffer.from(bin, 'binary').toString('base64'); }
95
- : btoaPolyfill;
96
- var _fromUint8Array = _hasBuffer
97
- ? function (u8a) { return Buffer.from(u8a).toString('base64'); }
98
- : function (u8a) {
99
- // cf. https://stackoverflow.com/questions/12710001/how-to-convert-uint8-array-to-base64-encoded-string/12713326#12713326
100
- var maxargs = 0x1000;
101
- var strs = [];
102
- for (var i = 0, l = u8a.length; i < l; i += maxargs) {
103
- strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs)));
104
- }
105
- return _btoa(strs.join(''));
106
- };
107
- /**
108
- * converts a Uint8Array to a Base64 string.
109
- * @param {boolean} [urlsafe] URL-and-filename-safe a la RFC4648 §5
110
- * @returns {string} Base64 string
111
- */
112
- var fromUint8Array = function (u8a, urlsafe) {
113
- if (urlsafe === void 0) { urlsafe = false; }
114
- return urlsafe ? _mkUriSafe(_fromUint8Array(u8a)) : _fromUint8Array(u8a);
115
- };
116
- // This trick is found broken https://github.com/dankogai/js-base64/issues/130
117
- // const utob = (src: string) => unescape(encodeURIComponent(src));
118
- // reverting good old fationed regexp
119
- var cb_utob = function (c) {
120
- if (c.length < 2) {
121
- var cc = c.charCodeAt(0);
122
- return cc < 0x80 ? c
123
- : cc < 0x800 ? (_fromCC(0xc0 | (cc >>> 6))
124
- + _fromCC(0x80 | (cc & 0x3f)))
125
- : (_fromCC(0xe0 | ((cc >>> 12) & 0x0f))
126
- + _fromCC(0x80 | ((cc >>> 6) & 0x3f))
127
- + _fromCC(0x80 | (cc & 0x3f)));
128
- }
129
- else {
130
- var cc = 0x10000
131
- + (c.charCodeAt(0) - 0xD800) * 0x400
132
- + (c.charCodeAt(1) - 0xDC00);
133
- return (_fromCC(0xf0 | ((cc >>> 18) & 0x07))
134
- + _fromCC(0x80 | ((cc >>> 12) & 0x3f))
135
- + _fromCC(0x80 | ((cc >>> 6) & 0x3f))
136
- + _fromCC(0x80 | (cc & 0x3f)));
137
- }
138
- };
139
- var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
140
- /**
141
- * @deprecated should have been internal use only.
142
- * @param {string} src UTF-8 string
143
- * @returns {string} UTF-16 string
144
- */
145
- var utob = function (u) { return u.replace(re_utob, cb_utob); };
146
- //
147
- var _encode = _hasBuffer
148
- ? function (s) { return Buffer.from(s, 'utf8').toString('base64'); }
149
- : _TE
150
- ? function (s) { return _fromUint8Array(_TE.encode(s)); }
151
- : function (s) { return _btoa(utob(s)); };
152
- /**
153
- * converts a UTF-8-encoded string to a Base64 string.
154
- * @param {boolean} [urlsafe] if `true` make the result URL-safe
155
- * @returns {string} Base64 string
156
- */
157
- var encode = function (src, urlsafe) {
158
- if (urlsafe === void 0) { urlsafe = false; }
159
- return urlsafe
160
- ? _mkUriSafe(_encode(src))
161
- : _encode(src);
162
- };
163
- /**
164
- * converts a UTF-8-encoded string to URL-safe Base64 RFC4648 §5.
165
- * @returns {string} Base64 string
166
- */
167
- var encodeURI = function (src) { return encode(src, true); };
168
- // This trick is found broken https://github.com/dankogai/js-base64/issues/130
169
- // const btou = (src: string) => decodeURIComponent(escape(src));
170
- // reverting good old fationed regexp
171
- var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
172
- var cb_btou = function (cccc) {
173
- switch (cccc.length) {
174
- case 4:
175
- var cp = ((0x07 & cccc.charCodeAt(0)) << 18)
176
- | ((0x3f & cccc.charCodeAt(1)) << 12)
177
- | ((0x3f & cccc.charCodeAt(2)) << 6)
178
- | (0x3f & cccc.charCodeAt(3)), offset = cp - 0x10000;
179
- return (_fromCC((offset >>> 10) + 0xD800)
180
- + _fromCC((offset & 0x3FF) + 0xDC00));
181
- case 3:
182
- return _fromCC(((0x0f & cccc.charCodeAt(0)) << 12)
183
- | ((0x3f & cccc.charCodeAt(1)) << 6)
184
- | (0x3f & cccc.charCodeAt(2)));
185
- default:
186
- return _fromCC(((0x1f & cccc.charCodeAt(0)) << 6)
187
- | (0x3f & cccc.charCodeAt(1)));
188
- }
189
- };
190
- /**
191
- * @deprecated should have been internal use only.
192
- * @param {string} src UTF-16 string
193
- * @returns {string} UTF-8 string
194
- */
195
- var btou = function (b) { return b.replace(re_btou, cb_btou); };
196
- /**
197
- * polyfill version of `atob`
198
- */
199
- var atobPolyfill = function (asc) {
200
- // console.log('polyfilled');
201
- asc = asc.replace(/\s+/g, '');
202
- if (!b64re.test(asc))
203
- throw new TypeError('malformed base64.');
204
- asc += '=='.slice(2 - (asc.length & 3));
205
- var u24, bin = '', r1, r2;
206
- for (var i = 0; i < asc.length;) {
207
- u24 = b64tab[asc.charAt(i++)] << 18
208
- | b64tab[asc.charAt(i++)] << 12
209
- | (r1 = b64tab[asc.charAt(i++)]) << 6
210
- | (r2 = b64tab[asc.charAt(i++)]);
211
- bin += r1 === 64 ? _fromCC(u24 >> 16 & 255)
212
- : r2 === 64 ? _fromCC(u24 >> 16 & 255, u24 >> 8 & 255)
213
- : _fromCC(u24 >> 16 & 255, u24 >> 8 & 255, u24 & 255);
214
- }
215
- return bin;
216
- };
217
- /**
218
- * does what `window.atob` of web browsers do.
219
- * @param {String} asc Base64-encoded string
220
- * @returns {string} binary string
221
- */
222
- var _atob = _hasatob ? function (asc) { return atob(_tidyB64(asc)); }
223
- : _hasBuffer ? function (asc) { return Buffer.from(asc, 'base64').toString('binary'); }
224
- : atobPolyfill;
225
- //
226
- var _toUint8Array = _hasBuffer
227
- ? function (a) { return _U8Afrom(Buffer.from(a, 'base64')); }
228
- : function (a) { return _U8Afrom(_atob(a), function (c) { return c.charCodeAt(0); }); };
229
- /**
230
- * converts a Base64 string to a Uint8Array.
231
- */
232
- var toUint8Array = function (a) { return _toUint8Array(_unURI(a)); };
233
- //
234
- var _decode = _hasBuffer
235
- ? function (a) { return Buffer.from(a, 'base64').toString('utf8'); }
236
- : _TD
237
- ? function (a) { return _TD.decode(_toUint8Array(a)); }
238
- : function (a) { return btou(_atob(a)); };
239
- var _unURI = function (a) { return _tidyB64(a.replace(/[-_]/g, function (m0) { return m0 == '-' ? '+' : '/'; })); };
240
- /**
241
- * converts a Base64 string to a UTF-8 string.
242
- * @param {String} src Base64 string. Both normal and URL-safe are supported
243
- * @returns {string} UTF-8 string
244
- */
245
- var decode = function (src) { return _decode(_unURI(src)); };
246
- /**
247
- * check if a value is a valid Base64 string
248
- * @param {String} src a value to check
249
- */
250
- var isValid = function (src) {
251
- if (typeof src !== 'string')
252
- return false;
253
- var s = src.replace(/\s+/g, '').replace(/={0,2}$/, '');
254
- return !/[^\s0-9a-zA-Z\+/]/.test(s) || !/[^\s0-9a-zA-Z\-_]/.test(s);
255
- };
256
- //
257
- var _noEnum = function (v) {
258
- return {
259
- value: v, enumerable: false, writable: true, configurable: true
260
- };
261
- };
262
- /**
263
- * extend String.prototype with relevant methods
264
- */
265
- var extendString = function () {
266
- var _add = function (name, body) { return Object.defineProperty(String.prototype, name, _noEnum(body)); };
267
- _add('fromBase64', function () { return decode(this); });
268
- _add('toBase64', function (urlsafe) { return encode(this, urlsafe); });
269
- _add('toBase64URI', function () { return encode(this, true); });
270
- _add('toBase64URL', function () { return encode(this, true); });
271
- _add('toUint8Array', function () { return toUint8Array(this); });
272
- };
273
- /**
274
- * extend Uint8Array.prototype with relevant methods
275
- */
276
- var extendUint8Array = function () {
277
- var _add = function (name, body) { return Object.defineProperty(Uint8Array.prototype, name, _noEnum(body)); };
278
- _add('toBase64', function (urlsafe) { return fromUint8Array(this, urlsafe); });
279
- _add('toBase64URI', function () { return fromUint8Array(this, true); });
280
- _add('toBase64URL', function () { return fromUint8Array(this, true); });
281
- };
282
- /**
283
- * extend Builtin prototypes with relevant methods
284
- */
285
- var extendBuiltins = function () {
286
- extendString();
287
- extendUint8Array();
288
- };
289
- var gBase64 = {
290
- version: version,
291
- VERSION: VERSION,
292
- atob: _atob,
293
- atobPolyfill: atobPolyfill,
294
- btoa: _btoa,
295
- btoaPolyfill: btoaPolyfill,
296
- fromBase64: decode,
297
- toBase64: encode,
298
- encode: encode,
299
- encodeURI: encodeURI,
300
- encodeURL: encodeURI,
301
- utob: utob,
302
- btou: btou,
303
- decode: decode,
304
- isValid: isValid,
305
- fromUint8Array: fromUint8Array,
306
- toUint8Array: toUint8Array,
307
- extendString: extendString,
308
- extendUint8Array: extendUint8Array,
309
- extendBuiltins: extendBuiltins
310
- };
311
- //
312
- // export Base64 to the namespace
313
- //
314
- // ES5 is yet to have Object.assign() that may make transpilers unhappy.
315
- // gBase64.Base64 = Object.assign({}, gBase64);
316
- gBase64.Base64 = {};
317
- Object.keys(gBase64).forEach(function (k) { return gBase64.Base64[k] = gBase64[k]; });
318
- return gBase64;
319
- }));
1
+ //
2
+ // THIS FILE IS AUTOMATICALLY GENERATED! DO NOT EDIT BY HAND!
3
+ //
4
+ ;
5
+ (function (global, factory) {
6
+ typeof exports === 'object' && typeof module !== 'undefined'
7
+ ? module.exports = factory()
8
+ : typeof define === 'function' && define.amd
9
+ ? define(factory) :
10
+ // cf. https://github.com/dankogai/js-base64/issues/119
11
+ (function () {
12
+ // existing version for noConflict()
13
+ var _Base64 = global.Base64;
14
+ var gBase64 = factory();
15
+ gBase64.noConflict = function () {
16
+ global.Base64 = _Base64;
17
+ return gBase64;
18
+ };
19
+ if (global.Meteor) { // Meteor.js
20
+ Base64 = gBase64;
21
+ }
22
+ global.Base64 = gBase64;
23
+ })();
24
+ }((typeof self !== 'undefined' ? self
25
+ : typeof window !== 'undefined' ? window
26
+ : typeof global !== 'undefined' ? global
27
+ : this), function () {
28
+ 'use strict';
29
+ /**
30
+ * base64.ts
31
+ *
32
+ * Licensed under the BSD 3-Clause License.
33
+ * http://opensource.org/licenses/BSD-3-Clause
34
+ *
35
+ * References:
36
+ * http://en.wikipedia.org/wiki/Base64
37
+ *
38
+ * @author Dan Kogai (https://github.com/dankogai)
39
+ */
40
+ var version = '3.7.2';
41
+ /**
42
+ * @deprecated use lowercase `version`.
43
+ */
44
+ var VERSION = version;
45
+ var _hasatob = typeof atob === 'function';
46
+ var _hasbtoa = typeof btoa === 'function';
47
+ var _hasBuffer = typeof Buffer === 'function';
48
+ var _TD = typeof TextDecoder === 'function' ? new TextDecoder() : undefined;
49
+ var _TE = typeof TextEncoder === 'function' ? new TextEncoder() : undefined;
50
+ var b64ch = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
51
+ var b64chs = Array.prototype.slice.call(b64ch);
52
+ var b64tab = (function (a) {
53
+ var tab = {};
54
+ a.forEach(function (c, i) { return tab[c] = i; });
55
+ return tab;
56
+ })(b64chs);
57
+ var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
58
+ var _fromCC = String.fromCharCode.bind(String);
59
+ var _U8Afrom = typeof Uint8Array.from === 'function'
60
+ ? Uint8Array.from.bind(Uint8Array)
61
+ : function (it, fn) {
62
+ if (fn === void 0) { fn = function (x) { return x; }; }
63
+ return new Uint8Array(Array.prototype.slice.call(it, 0).map(fn));
64
+ };
65
+ var _mkUriSafe = function (src) { return src
66
+ .replace(/=/g, '').replace(/[+\/]/g, function (m0) { return m0 == '+' ? '-' : '_'; }); };
67
+ var _tidyB64 = function (s) { return s.replace(/[^A-Za-z0-9\+\/]/g, ''); };
68
+ /**
69
+ * polyfill version of `btoa`
70
+ */
71
+ var btoaPolyfill = function (bin) {
72
+ // console.log('polyfilled');
73
+ var u32, c0, c1, c2, asc = '';
74
+ var pad = bin.length % 3;
75
+ for (var i = 0; i < bin.length;) {
76
+ if ((c0 = bin.charCodeAt(i++)) > 255 ||
77
+ (c1 = bin.charCodeAt(i++)) > 255 ||
78
+ (c2 = bin.charCodeAt(i++)) > 255)
79
+ throw new TypeError('invalid character found');
80
+ u32 = (c0 << 16) | (c1 << 8) | c2;
81
+ asc += b64chs[u32 >> 18 & 63]
82
+ + b64chs[u32 >> 12 & 63]
83
+ + b64chs[u32 >> 6 & 63]
84
+ + b64chs[u32 & 63];
85
+ }
86
+ return pad ? asc.slice(0, pad - 3) + "===".substring(pad) : asc;
87
+ };
88
+ /**
89
+ * does what `window.btoa` of web browsers do.
90
+ * @param {String} bin binary string
91
+ * @returns {string} Base64-encoded string
92
+ */
93
+ var _btoa = _hasbtoa ? function (bin) { return btoa(bin); }
94
+ : _hasBuffer ? function (bin) { return Buffer.from(bin, 'binary').toString('base64'); }
95
+ : btoaPolyfill;
96
+ var _fromUint8Array = _hasBuffer
97
+ ? function (u8a) { return Buffer.from(u8a).toString('base64'); }
98
+ : function (u8a) {
99
+ // cf. https://stackoverflow.com/questions/12710001/how-to-convert-uint8-array-to-base64-encoded-string/12713326#12713326
100
+ var maxargs = 0x1000;
101
+ var strs = [];
102
+ for (var i = 0, l = u8a.length; i < l; i += maxargs) {
103
+ strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs)));
104
+ }
105
+ return _btoa(strs.join(''));
106
+ };
107
+ /**
108
+ * converts a Uint8Array to a Base64 string.
109
+ * @param {boolean} [urlsafe] URL-and-filename-safe a la RFC4648 §5
110
+ * @returns {string} Base64 string
111
+ */
112
+ var fromUint8Array = function (u8a, urlsafe) {
113
+ if (urlsafe === void 0) { urlsafe = false; }
114
+ return urlsafe ? _mkUriSafe(_fromUint8Array(u8a)) : _fromUint8Array(u8a);
115
+ };
116
+ // This trick is found broken https://github.com/dankogai/js-base64/issues/130
117
+ // const utob = (src: string) => unescape(encodeURIComponent(src));
118
+ // reverting good old fationed regexp
119
+ var cb_utob = function (c) {
120
+ if (c.length < 2) {
121
+ var cc = c.charCodeAt(0);
122
+ return cc < 0x80 ? c
123
+ : cc < 0x800 ? (_fromCC(0xc0 | (cc >>> 6))
124
+ + _fromCC(0x80 | (cc & 0x3f)))
125
+ : (_fromCC(0xe0 | ((cc >>> 12) & 0x0f))
126
+ + _fromCC(0x80 | ((cc >>> 6) & 0x3f))
127
+ + _fromCC(0x80 | (cc & 0x3f)));
128
+ }
129
+ else {
130
+ var cc = 0x10000
131
+ + (c.charCodeAt(0) - 0xD800) * 0x400
132
+ + (c.charCodeAt(1) - 0xDC00);
133
+ return (_fromCC(0xf0 | ((cc >>> 18) & 0x07))
134
+ + _fromCC(0x80 | ((cc >>> 12) & 0x3f))
135
+ + _fromCC(0x80 | ((cc >>> 6) & 0x3f))
136
+ + _fromCC(0x80 | (cc & 0x3f)));
137
+ }
138
+ };
139
+ var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
140
+ /**
141
+ * @deprecated should have been internal use only.
142
+ * @param {string} src UTF-8 string
143
+ * @returns {string} UTF-16 string
144
+ */
145
+ var utob = function (u) { return u.replace(re_utob, cb_utob); };
146
+ //
147
+ var _encode = _hasBuffer
148
+ ? function (s) { return Buffer.from(s, 'utf8').toString('base64'); }
149
+ : _TE
150
+ ? function (s) { return _fromUint8Array(_TE.encode(s)); }
151
+ : function (s) { return _btoa(utob(s)); };
152
+ /**
153
+ * converts a UTF-8-encoded string to a Base64 string.
154
+ * @param {boolean} [urlsafe] if `true` make the result URL-safe
155
+ * @returns {string} Base64 string
156
+ */
157
+ var encode = function (src, urlsafe) {
158
+ if (urlsafe === void 0) { urlsafe = false; }
159
+ return urlsafe
160
+ ? _mkUriSafe(_encode(src))
161
+ : _encode(src);
162
+ };
163
+ /**
164
+ * converts a UTF-8-encoded string to URL-safe Base64 RFC4648 §5.
165
+ * @returns {string} Base64 string
166
+ */
167
+ var encodeURI = function (src) { return encode(src, true); };
168
+ // This trick is found broken https://github.com/dankogai/js-base64/issues/130
169
+ // const btou = (src: string) => decodeURIComponent(escape(src));
170
+ // reverting good old fationed regexp
171
+ var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
172
+ var cb_btou = function (cccc) {
173
+ switch (cccc.length) {
174
+ case 4:
175
+ var cp = ((0x07 & cccc.charCodeAt(0)) << 18)
176
+ | ((0x3f & cccc.charCodeAt(1)) << 12)
177
+ | ((0x3f & cccc.charCodeAt(2)) << 6)
178
+ | (0x3f & cccc.charCodeAt(3)), offset = cp - 0x10000;
179
+ return (_fromCC((offset >>> 10) + 0xD800)
180
+ + _fromCC((offset & 0x3FF) + 0xDC00));
181
+ case 3:
182
+ return _fromCC(((0x0f & cccc.charCodeAt(0)) << 12)
183
+ | ((0x3f & cccc.charCodeAt(1)) << 6)
184
+ | (0x3f & cccc.charCodeAt(2)));
185
+ default:
186
+ return _fromCC(((0x1f & cccc.charCodeAt(0)) << 6)
187
+ | (0x3f & cccc.charCodeAt(1)));
188
+ }
189
+ };
190
+ /**
191
+ * @deprecated should have been internal use only.
192
+ * @param {string} src UTF-16 string
193
+ * @returns {string} UTF-8 string
194
+ */
195
+ var btou = function (b) { return b.replace(re_btou, cb_btou); };
196
+ /**
197
+ * polyfill version of `atob`
198
+ */
199
+ var atobPolyfill = function (asc) {
200
+ // console.log('polyfilled');
201
+ asc = asc.replace(/\s+/g, '');
202
+ if (!b64re.test(asc))
203
+ throw new TypeError('malformed base64.');
204
+ asc += '=='.slice(2 - (asc.length & 3));
205
+ var u24, bin = '', r1, r2;
206
+ for (var i = 0; i < asc.length;) {
207
+ u24 = b64tab[asc.charAt(i++)] << 18
208
+ | b64tab[asc.charAt(i++)] << 12
209
+ | (r1 = b64tab[asc.charAt(i++)]) << 6
210
+ | (r2 = b64tab[asc.charAt(i++)]);
211
+ bin += r1 === 64 ? _fromCC(u24 >> 16 & 255)
212
+ : r2 === 64 ? _fromCC(u24 >> 16 & 255, u24 >> 8 & 255)
213
+ : _fromCC(u24 >> 16 & 255, u24 >> 8 & 255, u24 & 255);
214
+ }
215
+ return bin;
216
+ };
217
+ /**
218
+ * does what `window.atob` of web browsers do.
219
+ * @param {String} asc Base64-encoded string
220
+ * @returns {string} binary string
221
+ */
222
+ var _atob = _hasatob ? function (asc) { return atob(_tidyB64(asc)); }
223
+ : _hasBuffer ? function (asc) { return Buffer.from(asc, 'base64').toString('binary'); }
224
+ : atobPolyfill;
225
+ //
226
+ var _toUint8Array = _hasBuffer
227
+ ? function (a) { return _U8Afrom(Buffer.from(a, 'base64')); }
228
+ : function (a) { return _U8Afrom(_atob(a), function (c) { return c.charCodeAt(0); }); };
229
+ /**
230
+ * converts a Base64 string to a Uint8Array.
231
+ */
232
+ var toUint8Array = function (a) { return _toUint8Array(_unURI(a)); };
233
+ //
234
+ var _decode = _hasBuffer
235
+ ? function (a) { return Buffer.from(a, 'base64').toString('utf8'); }
236
+ : _TD
237
+ ? function (a) { return _TD.decode(_toUint8Array(a)); }
238
+ : function (a) { return btou(_atob(a)); };
239
+ var _unURI = function (a) { return _tidyB64(a.replace(/[-_]/g, function (m0) { return m0 == '-' ? '+' : '/'; })); };
240
+ /**
241
+ * converts a Base64 string to a UTF-8 string.
242
+ * @param {String} src Base64 string. Both normal and URL-safe are supported
243
+ * @returns {string} UTF-8 string
244
+ */
245
+ var decode = function (src) { return _decode(_unURI(src)); };
246
+ /**
247
+ * check if a value is a valid Base64 string
248
+ * @param {String} src a value to check
249
+ */
250
+ var isValid = function (src) {
251
+ if (typeof src !== 'string')
252
+ return false;
253
+ var s = src.replace(/\s+/g, '').replace(/={0,2}$/, '');
254
+ return !/[^\s0-9a-zA-Z\+/]/.test(s) || !/[^\s0-9a-zA-Z\-_]/.test(s);
255
+ };
256
+ //
257
+ var _noEnum = function (v) {
258
+ return {
259
+ value: v, enumerable: false, writable: true, configurable: true
260
+ };
261
+ };
262
+ /**
263
+ * extend String.prototype with relevant methods
264
+ */
265
+ var extendString = function () {
266
+ var _add = function (name, body) { return Object.defineProperty(String.prototype, name, _noEnum(body)); };
267
+ _add('fromBase64', function () { return decode(this); });
268
+ _add('toBase64', function (urlsafe) { return encode(this, urlsafe); });
269
+ _add('toBase64URI', function () { return encode(this, true); });
270
+ _add('toBase64URL', function () { return encode(this, true); });
271
+ _add('toUint8Array', function () { return toUint8Array(this); });
272
+ };
273
+ /**
274
+ * extend Uint8Array.prototype with relevant methods
275
+ */
276
+ var extendUint8Array = function () {
277
+ var _add = function (name, body) { return Object.defineProperty(Uint8Array.prototype, name, _noEnum(body)); };
278
+ _add('toBase64', function (urlsafe) { return fromUint8Array(this, urlsafe); });
279
+ _add('toBase64URI', function () { return fromUint8Array(this, true); });
280
+ _add('toBase64URL', function () { return fromUint8Array(this, true); });
281
+ };
282
+ /**
283
+ * extend Builtin prototypes with relevant methods
284
+ */
285
+ var extendBuiltins = function () {
286
+ extendString();
287
+ extendUint8Array();
288
+ };
289
+ var gBase64 = {
290
+ version: version,
291
+ VERSION: VERSION,
292
+ atob: _atob,
293
+ atobPolyfill: atobPolyfill,
294
+ btoa: _btoa,
295
+ btoaPolyfill: btoaPolyfill,
296
+ fromBase64: decode,
297
+ toBase64: encode,
298
+ encode: encode,
299
+ encodeURI: encodeURI,
300
+ encodeURL: encodeURI,
301
+ utob: utob,
302
+ btou: btou,
303
+ decode: decode,
304
+ isValid: isValid,
305
+ fromUint8Array: fromUint8Array,
306
+ toUint8Array: toUint8Array,
307
+ extendString: extendString,
308
+ extendUint8Array: extendUint8Array,
309
+ extendBuiltins: extendBuiltins
310
+ };
311
+ //
312
+ // export Base64 to the namespace
313
+ //
314
+ // ES5 is yet to have Object.assign() that may make transpilers unhappy.
315
+ // gBase64.Base64 = Object.assign({}, gBase64);
316
+ gBase64.Base64 = {};
317
+ Object.keys(gBase64).forEach(function (k) { return gBase64.Base64[k] = gBase64[k]; });
318
+ return gBase64;
319
+ }));