@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.
package/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2014-2024 Niyamaka
4
+ Copyright (c) 2024-2026, ArtGins
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
23
+
24
+ src/sprintf.js is under its own license (BSD-3-Clause): see THIRD-PARTY-NOTICES.
package/README.md CHANGED
@@ -761,8 +761,6 @@ empty_string(s) // true if null/undefined/""
761
761
  str_in_list(list, str, ci) // case-insensitive optional
762
762
  index_in_list(list, value)
763
763
  delete_from_list(list, value)
764
- jwtDecode(token) // → header/payload/signature
765
- jwt2json(token, what) // → payload JSON (what: optional part)
766
764
  debounce(fn, wait, immediate)
767
765
  timeTracker()
768
766
 
@@ -0,0 +1,37 @@
1
+ THIRD-PARTY NOTICES
2
+ ===================
3
+
4
+ @yuneta/gobj-js is under the MIT License of LICENSE. It carries the code of
5
+ others below, under its own license.
6
+
7
+ ------------------------------------------------------------------------------
8
+ sprintf.js
9
+ ------------------------------------------------------------------------------
10
+ src/sprintf.js, from https://github.com/alexei/sprintf.js (src/sprintf.js),
11
+ adapted; built into dist/.
12
+ License: BSD-3-Clause
13
+
14
+ Copyright (c) 2007-present, Alexandru Mărășteanu <hello@alexei.ro>
15
+ All rights reserved.
16
+
17
+ Redistribution and use in source and binary forms, with or without
18
+ modification, are permitted provided that the following conditions are met:
19
+ * Redistributions of source code must retain the above copyright
20
+ notice, this list of conditions and the following disclaimer.
21
+ * Redistributions in binary form must reproduce the above copyright
22
+ notice, this list of conditions and the following disclaimer in the
23
+ documentation and/or other materials provided with the distribution.
24
+ * Neither the name of this software nor the names of its contributors may be
25
+ used to endorse or promote products derived from this software without
26
+ specific prior written permission.
27
+
28
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
29
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
30
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
32
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
33
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
35
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,5 +1,34 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/sprintf.js
3
+ /*!
4
+ Adapted from https://github.com/alexei/sprintf.js/blob/master/src/sprintf.js
5
+ under its BSD-3-Clause License:
6
+
7
+ Copyright (c) 2007-present, Alexandru Mărășteanu <hello@alexei.ro>
8
+ All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+ * Redistributions of source code must retain the above copyright
13
+ notice, this list of conditions and the following disclaimer.
14
+ * Redistributions in binary form must reproduce the above copyright
15
+ notice, this list of conditions and the following disclaimer in the
16
+ documentation and/or other materials provided with the distribution.
17
+ * Neither the name of this software nor the names of its contributors may be
18
+ used to endorse or promote products derived from this software without
19
+ specific prior written permission.
20
+
21
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
25
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ */
3
32
  var re = {
4
33
  not_string: /[^s]/,
5
34
  not_bool: /[^t]/,
@@ -6938,59 +6967,6 @@ function create_json_record(json_desc, value) {
6938
6967
  json_object_update_existing(record, value);
6939
6968
  return record;
6940
6969
  }
6941
- /************************************************************
6942
- * https://stackoverflow.com/questions/38552003/how-to-decode-jwt-token-in-javascript-without-using-a-library
6943
- ************************************************************/
6944
- function jwtDecode(jwt) {
6945
- function b64DecodeUnicode(str) {
6946
- return decodeURIComponent(atob(str).replace(/(.)/g, function(m, p) {
6947
- let code = p.charCodeAt(0).toString(16).toUpperCase();
6948
- if (code.length < 2) code = "0" + code;
6949
- return "%" + code;
6950
- }));
6951
- }
6952
- function decode(str) {
6953
- let output = str.replace(/-/g, "+").replace(/_/g, "/");
6954
- switch (output.length % 4) {
6955
- case 0: break;
6956
- case 2:
6957
- output += "==";
6958
- break;
6959
- case 3:
6960
- output += "=";
6961
- break;
6962
- default: throw "Illegal base64url string!";
6963
- }
6964
- try {
6965
- return b64DecodeUnicode(output);
6966
- } catch (err) {
6967
- return atob(output);
6968
- }
6969
- }
6970
- let jwtArray = jwt.split(".");
6971
- return {
6972
- header: decode(jwtArray[0]),
6973
- payload: decode(jwtArray[1]),
6974
- signature: decode(jwtArray[2])
6975
- };
6976
- }
6977
- /************************************************************
6978
- * Decoded jwt and return in json
6979
- * 'what' can be "header", "payload" or "signature"
6980
- * default is "payload"
6981
- ************************************************************/
6982
- function jwt2json(jwt, what) {
6983
- try {
6984
- let jwt_decoded = jwtDecode(jwt);
6985
- switch (what) {
6986
- case "header": return JSON.parse(jwt_decoded.header);
6987
- case "signature": return JSON.parse(jwt_decoded.signature);
6988
- default: return JSON.parse(jwt_decoded.payload);
6989
- }
6990
- } catch (e) {
6991
- return null;
6992
- }
6993
- }
6994
6970
  /***************************************************************************
6995
6971
  * Escape a value for safe insertion into an HTML context.
6996
6972
  * Use this whenever user- or server-supplied strings are interpolated
@@ -9900,8 +9876,6 @@ exports.json_object_update_existing = json_object_update_existing;
9900
9876
  exports.json_object_update_missing = json_object_update_missing;
9901
9877
  exports.json_size = json_size;
9902
9878
  exports.json_text_of = json_text_of;
9903
- exports.jwt2json = jwt2json;
9904
- exports.jwtDecode = jwtDecode;
9905
9879
  exports.kw_clone_by_keys = kw_clone_by_keys;
9906
9880
  exports.kw_clone_by_not_keys = kw_clone_by_not_keys;
9907
9881
  exports.kw_collect = kw_collect;