@yuneta/gobj-js 7.27.0 → 7.28.0

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