@jwn-js/common 1.3.24 → 1.3.25

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 (46) hide show
  1. package/{Jwt-f1da5291.js → Jwt-e49753f6.js} +2 -2
  2. package/Jwt.js +1 -1
  3. package/{Server-77093d28.js → Server-dadc1f87.js} +5 -5
  4. package/Server.js +1 -1
  5. package/docs/.nojekyll +1 -0
  6. package/docs/assets/highlight.css +36 -0
  7. package/docs/assets/icons.css +1043 -0
  8. package/docs/assets/{images/icons.png → icons.png} +0 -0
  9. package/docs/assets/{images/icons@2x.png → icons@2x.png} +0 -0
  10. package/docs/assets/main.js +52 -0
  11. package/docs/assets/search.js +1 -0
  12. package/docs/assets/style.css +1388 -0
  13. package/docs/assets/{images/widgets.png → widgets.png} +0 -0
  14. package/docs/assets/{images/widgets@2x.png → widgets@2x.png} +0 -0
  15. package/docs/classes/ApiError.html +18 -560
  16. package/docs/classes/AsyncJwt.html +17 -312
  17. package/docs/classes/Controller.html +27 -1005
  18. package/docs/classes/Jwt.html +17 -312
  19. package/docs/classes/Memcached.html +20 -384
  20. package/docs/classes/Model.html +7 -664
  21. package/docs/classes/Server.html +25 -461
  22. package/docs/classes/Ssr.html +11 -307
  23. package/docs/classes/Web.html +11 -437
  24. package/docs/index.html +18 -258
  25. package/docs/interfaces/ApiErrorMessage.html +1 -219
  26. package/docs/interfaces/ContextSsr.html +23 -324
  27. package/docs/interfaces/ContextWeb.html +1 -288
  28. package/docs/interfaces/OptionsSsr.html +1 -181
  29. package/docs/interfaces/OptionsWeb.html +1 -209
  30. package/docs/interfaces/Route.html +1 -191
  31. package/docs/interfaces/Schema.html +1 -177
  32. package/docs/interfaces/ServerHandler.html +1 -218
  33. package/docs/interfaces/ServerOptions.html +1 -233
  34. package/docs/interfaces/ServerWebsocket.html +1 -191
  35. package/docs/modules.html +70 -2005
  36. package/index.d.ts +4 -0
  37. package/index.js +20 -12
  38. package/multipartBody.js +1 -1
  39. package/package.json +3 -3
  40. package/readConfig.js +1 -1
  41. package/readConfigSync.js +2 -2
  42. package/staticBody.js +1 -1
  43. package/urlencodedBody.js +1 -1
  44. package/docs/assets/css/main.css +0 -2660
  45. package/docs/assets/js/main.js +0 -248
  46. package/docs/assets/js/search.js +0 -1
package/index.d.ts CHANGED
@@ -718,6 +718,10 @@ declare const helpers: {
718
718
  staticBody: typeof staticBody;
719
719
  extensions: string[];
720
720
  getExt: (path: string) => string;
721
+ jwtDecode: (jwt: string) => {
722
+ head: any;
723
+ body: any;
724
+ };
721
725
  };
722
726
 
723
727
  export { AsyncJwt, ContextWeb$1 as ContextWeb, Controller, Model, OptionsSsr, OptionsWeb, Route$1 as Route, Schema, Ssr, Web, action, body, config, connection, context, controller, cookies, db, headers, helpers, home, hostname, http, init, json, logerror, method, mixin, mountWithContext as mount, pool, protocol, request, stream, subaction, url, xml };
package/index.js CHANGED
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var ApiError = require('./ApiError.js');
6
- var Server = require('./Server-77093d28.js');
7
- var Jwt = require('./Jwt-f1da5291.js');
6
+ var Server = require('./Server-dadc1f87.js');
7
+ var Jwt = require('./Jwt-e49753f6.js');
8
8
  var crypto = require('crypto');
9
9
  var util = require('util');
10
10
  var Memcached = require('./Memcached.js');
@@ -78,6 +78,13 @@ class AsyncJwt {
78
78
  }
79
79
  }
80
80
 
81
+ const jwtDecode = (jwt) => {
82
+ const parts = (jwt || "").split(".");
83
+ const head = Jwt.fromBase64url(parts[0]);
84
+ const body = Jwt.fromBase64url(parts[1]);
85
+ return { head, body };
86
+ };
87
+
81
88
  const rawBody$1 = (res, req) => new Promise((resolve, reject) => {
82
89
  readRaw$1(res, (obj) => {
83
90
  resolve(obj);
@@ -295,7 +302,7 @@ async function staticBody(res, req, base) {
295
302
  }));
296
303
  let url = req.getUrl().replace(/\.\.\//ig, "").replace(/^\.\/?/, "");
297
304
  url = `./${url}`;
298
- const file = path__default['default'].resolve(base, url);
305
+ const file = path__default["default"].resolve(base, url);
299
306
  const content = await fs.promises.readFile(file);
300
307
  res.writeStatus("200 OK").writeHeader("content-type", getContentType(getExt(url))).end(content);
301
308
  } catch (e) {
@@ -632,7 +639,7 @@ const multipartBody = (res, req, options = { multiples: true }) => new Promise(a
632
639
  stream.end();
633
640
  }
634
641
  });
635
- const form = formidable__default['default'](options);
642
+ const form = formidable__default["default"](options);
636
643
  form.parse(stream, (err2, fields, files) => {
637
644
  if (err2) {
638
645
  reject(err2);
@@ -658,7 +665,7 @@ function readBody(res, cb, err) {
658
665
  buffer = Buffer.concat([buffer, Buffer.from(ab)]);
659
666
  if (isLast) {
660
667
  try {
661
- cb(querystring__default['default'].parse(buffer.toString()));
668
+ cb(querystring__default["default"].parse(buffer.toString()));
662
669
  } catch (e) {
663
670
  cb(null);
664
671
  return;
@@ -733,7 +740,7 @@ class Web {
733
740
  };
734
741
  this.req.forEach((key, value) => this.contextWeb.headers[key] = value);
735
742
  const type = this.contextWeb.headers["content-type"] || "application/json";
736
- request = Object.assign({}, this.defaultRequest, request, querystring__default['default'].parse(this.req.getQuery()));
743
+ request = Object.assign({}, this.defaultRequest, request, querystring__default["default"].parse(this.req.getQuery()));
737
744
  if (type.indexOf("application/json") !== -1 || type.indexOf("text/json") !== -1) {
738
745
  Object.assign(request, await jsonBody(this.res, this.req));
739
746
  } else if (!["get", "head"].includes(this.contextWeb.method) && type.indexOf("multipart/form-data") !== -1) {
@@ -742,7 +749,7 @@ class Web {
742
749
  Object.assign(request, await urlencodedBody(this.res, this.req));
743
750
  } else if (!["get", "head"].includes(this.contextWeb.method) && (type.indexOf("application/xml") !== -1 || type.indexOf("text/xml") !== -1)) {
744
751
  const raw = (await rawBody(this.res, this.req)).toString();
745
- const records = xmljs__default['default'].xml2js(raw, { compact: true, cdataKey: "_value", textKey: "_value" });
752
+ const records = xmljs__default["default"].xml2js(raw, { compact: true, cdataKey: "_value", textKey: "_value" });
746
753
  Object.assign(request, records || {});
747
754
  } else if (!["get", "head"].includes(this.contextWeb.method) && type.indexOf("application/octet-stream") !== -1) {
748
755
  Object.defineProperty(this.contextWeb, "$stream", {
@@ -854,8 +861,8 @@ class Web {
854
861
  }
855
862
 
856
863
  const readConfigSync = (jsonfile) => {
857
- const file = path__default['default'].resolve(jsonfile);
858
- return JSON.parse(fs__default['default'].readFileSync(file, "utf-8"));
864
+ const file = path__default["default"].resolve(jsonfile);
865
+ return JSON.parse(fs__default["default"].readFileSync(file, "utf-8"));
859
866
  };
860
867
 
861
868
  const config$1 = readConfigSync("./connect.json");
@@ -976,7 +983,7 @@ class Controller {
976
983
  const response = this.success(data, options);
977
984
  return {
978
985
  headers: Object.assign({ "content-type": "application/xml" }, this.responseHeaders, options?.headers || {}),
979
- body: xmljs__default['default'].js2xml(Object.assign(defaultXml, { body: { ...response.body } }), xmlOptions),
986
+ body: xmljs__default["default"].js2xml(Object.assign(defaultXml, { body: { ...response.body } }), xmlOptions),
980
987
  memcache: response.memcache
981
988
  };
982
989
  }
@@ -994,7 +1001,7 @@ class Controller {
994
1001
  const headers = Object.assign({ "content-type": "application/json" }, e.headers);
995
1002
  return {
996
1003
  headers,
997
- body: xmljs__default['default'].js2xml(Object.assign(defaultXml, { body: { ...response.body } }), xmlOptions),
1004
+ body: xmljs__default["default"].js2xml(Object.assign(defaultXml, { body: { ...response.body } }), xmlOptions),
998
1005
  statusCode: response.statusCode
999
1006
  };
1000
1007
  }
@@ -1378,7 +1385,8 @@ const helpers = {
1378
1385
  readConfigSync: readConfigSync$1.readConfigSync,
1379
1386
  staticBody,
1380
1387
  extensions,
1381
- getExt
1388
+ getExt,
1389
+ jwtDecode
1382
1390
  };
1383
1391
 
1384
1392
  exports.ApiError = ApiError.ApiError;
package/multipartBody.js CHANGED
@@ -24,7 +24,7 @@ const multipartBody = (res, req, options = { multiples: true }) => new Promise(a
24
24
  stream$1.end();
25
25
  }
26
26
  });
27
- const form = formidable__default['default'](options);
27
+ const form = formidable__default["default"](options);
28
28
  form.parse(stream$1, (err2, fields, files) => {
29
29
  if (err2) {
30
30
  reject(err2);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jwn-js/common",
3
3
  "private": false,
4
- "version": "1.3.24",
4
+ "version": "1.3.25",
5
5
  "description": "@jwn-js/common package",
6
6
  "main": "./index.js",
7
7
  "types": "./index.d.ts",
@@ -33,12 +33,12 @@
33
33
  "jest": "^27.4.3",
34
34
  "rollup": "^2.53.2",
35
35
  "rollup-plugin-dts": "^3.0.2",
36
- "rollup-plugin-esbuild": "^4.5.0",
36
+ "rollup-plugin-esbuild": "4.1",
37
37
  "supertest": "^6.1.6",
38
38
  "superwstest": "^1.8.0",
39
39
  "ts-jest": "^27.1.0",
40
40
  "ts-node": "^10.4.0",
41
- "typedoc": "^0.21.4",
41
+ "typedoc": "^0.22.10",
42
42
  "typescript": "^4.3.2",
43
43
  "zlib": "^1.0.5"
44
44
  },
package/readConfig.js CHANGED
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
  var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
11
11
 
12
12
  const readConfig = async (jsonfile) => {
13
- const file = path__default['default'].resolve(jsonfile);
13
+ const file = path__default["default"].resolve(jsonfile);
14
14
  return JSON.parse(await fs.promises.readFile(file, "utf-8"));
15
15
  };
16
16
 
package/readConfigSync.js CHANGED
@@ -11,8 +11,8 @@ var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
11
11
  var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
12
12
 
13
13
  const readConfigSync = (jsonfile) => {
14
- const file = path__default['default'].resolve(jsonfile);
15
- return JSON.parse(fs__default['default'].readFileSync(file, "utf-8"));
14
+ const file = path__default["default"].resolve(jsonfile);
15
+ return JSON.parse(fs__default["default"].readFileSync(file, "utf-8"));
16
16
  };
17
17
 
18
18
  exports.readConfigSync = readConfigSync;
package/staticBody.js CHANGED
@@ -193,7 +193,7 @@ async function staticBody(res, req, base) {
193
193
  }));
194
194
  let url = req.getUrl().replace(/\.\.\//ig, "").replace(/^\.\/?/, "");
195
195
  url = `./${url}`;
196
- const file = path__default['default'].resolve(base, url);
196
+ const file = path__default["default"].resolve(base, url);
197
197
  const content = await fs.promises.readFile(file);
198
198
  res.writeStatus("200 OK").writeHeader("content-type", getContentType(getExt(url))).end(content);
199
199
  } catch (e) {
package/urlencodedBody.js CHANGED
@@ -22,7 +22,7 @@ function readBody(res, cb, err) {
22
22
  buffer = Buffer.concat([buffer, Buffer.from(ab)]);
23
23
  if (isLast) {
24
24
  try {
25
- cb(querystring__default['default'].parse(buffer.toString()));
25
+ cb(querystring__default["default"].parse(buffer.toString()));
26
26
  } catch (e) {
27
27
  cb(null);
28
28
  return;