@yuneta/gobj-js 7.27.0 → 7.28.1

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,6 +1,35 @@
1
1
  var gobjJs = (function(exports) {
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  //#region src/sprintf.js
4
+ /*!
5
+ Adapted from https://github.com/alexei/sprintf.js/blob/master/src/sprintf.js
6
+ under its BSD-3-Clause License:
7
+
8
+ Copyright (c) 2007-present, Alexandru Mărășteanu <hello@alexei.ro>
9
+ All rights reserved.
10
+
11
+ Redistribution and use in source and binary forms, with or without
12
+ modification, are permitted provided that the following conditions are met:
13
+ * Redistributions of source code must retain the above copyright
14
+ notice, this list of conditions and the following disclaimer.
15
+ * Redistributions in binary form must reproduce the above copyright
16
+ notice, this list of conditions and the following disclaimer in the
17
+ documentation and/or other materials provided with the distribution.
18
+ * Neither the name of this software nor the names of its contributors may be
19
+ used to endorse or promote products derived from this software without
20
+ specific prior written permission.
21
+
22
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
26
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+ */
4
33
  var re = {
5
34
  not_string: /[^s]/,
6
35
  not_bool: /[^t]/,
@@ -399,7 +428,7 @@ var gobjJs = (function(exports) {
399
428
  }
400
429
  };
401
430
  function tab() {
402
- return " ".repeat(Math.max(1, __inside__ * 2));
431
+ return " ".repeat(Math.max(1, __inside__ * 4));
403
432
  }
404
433
  var __trace_machine_format__ = 1;
405
434
  function gobj_set_trace_machine_format(format) {
@@ -6939,59 +6968,6 @@ var gobjJs = (function(exports) {
6939
6968
  json_object_update_existing(record, value);
6940
6969
  return record;
6941
6970
  }
6942
- /************************************************************
6943
- * https://stackoverflow.com/questions/38552003/how-to-decode-jwt-token-in-javascript-without-using-a-library
6944
- ************************************************************/
6945
- function jwtDecode(jwt) {
6946
- function b64DecodeUnicode(str) {
6947
- return decodeURIComponent(atob(str).replace(/(.)/g, function(m, p) {
6948
- let code = p.charCodeAt(0).toString(16).toUpperCase();
6949
- if (code.length < 2) code = "0" + code;
6950
- return "%" + code;
6951
- }));
6952
- }
6953
- function decode(str) {
6954
- let output = str.replace(/-/g, "+").replace(/_/g, "/");
6955
- switch (output.length % 4) {
6956
- case 0: break;
6957
- case 2:
6958
- output += "==";
6959
- break;
6960
- case 3:
6961
- output += "=";
6962
- break;
6963
- default: throw "Illegal base64url string!";
6964
- }
6965
- try {
6966
- return b64DecodeUnicode(output);
6967
- } catch (err) {
6968
- return atob(output);
6969
- }
6970
- }
6971
- let jwtArray = jwt.split(".");
6972
- return {
6973
- header: decode(jwtArray[0]),
6974
- payload: decode(jwtArray[1]),
6975
- signature: decode(jwtArray[2])
6976
- };
6977
- }
6978
- /************************************************************
6979
- * Decoded jwt and return in json
6980
- * 'what' can be "header", "payload" or "signature"
6981
- * default is "payload"
6982
- ************************************************************/
6983
- function jwt2json(jwt, what) {
6984
- try {
6985
- let jwt_decoded = jwtDecode(jwt);
6986
- switch (what) {
6987
- case "header": return JSON.parse(jwt_decoded.header);
6988
- case "signature": return JSON.parse(jwt_decoded.signature);
6989
- default: return JSON.parse(jwt_decoded.payload);
6990
- }
6991
- } catch (e) {
6992
- return null;
6993
- }
6994
- }
6995
6971
  /***************************************************************************
6996
6972
  * Escape a value for safe insertion into an HTML context.
6997
6973
  * Use this whenever user- or server-supplied strings are interpolated
@@ -9901,8 +9877,6 @@ var gobjJs = (function(exports) {
9901
9877
  exports.json_object_update_missing = json_object_update_missing;
9902
9878
  exports.json_size = json_size;
9903
9879
  exports.json_text_of = json_text_of;
9904
- exports.jwt2json = jwt2json;
9905
- exports.jwtDecode = jwtDecode;
9906
9880
  exports.kw_clone_by_keys = kw_clone_by_keys;
9907
9881
  exports.kw_clone_by_not_keys = kw_clone_by_not_keys;
9908
9882
  exports.kw_collect = kw_collect;