@jwn-js/common 2.2.1 → 2.2.3

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 (82) hide show
  1. package/ApiError.js +37 -1
  2. package/ApiError.mjs +35 -1
  3. package/Jwt-B4QZ2Ypb.js +80 -0
  4. package/Jwt-Be4GWrIO.js +75 -0
  5. package/Jwt.js +8 -1
  6. package/Jwt.mjs +2 -1
  7. package/Memcached.js +166 -9
  8. package/Memcached.mjs +164 -9
  9. package/Server.js +316 -1
  10. package/Server.mjs +313 -1
  11. package/cookieParse.js +25 -1
  12. package/cookieParse.mjs +23 -1
  13. package/cookieString.js +22 -1
  14. package/cookieString.mjs +20 -1
  15. package/docs/classes/ApiError.html +2 -2
  16. package/docs/classes/AsyncJwt.html +2 -2
  17. package/docs/classes/Controller.html +2 -2
  18. package/docs/classes/Jwt.html +2 -2
  19. package/docs/classes/Memcached.html +2 -2
  20. package/docs/classes/Model.html +2 -2
  21. package/docs/classes/Server.html +2 -2
  22. package/docs/classes/Ssr.html +2 -2
  23. package/docs/classes/Web.html +2 -2
  24. package/docs/functions/action.html +2 -2
  25. package/docs/functions/body.html +2 -2
  26. package/docs/functions/codeToStatus.html +2 -2
  27. package/docs/functions/config.html +2 -2
  28. package/docs/functions/connection.html +2 -2
  29. package/docs/functions/context.html +2 -2
  30. package/docs/functions/controller-1.html +2 -2
  31. package/docs/functions/cookies.html +2 -2
  32. package/docs/functions/db.html +2 -2
  33. package/docs/functions/headers.html +2 -2
  34. package/docs/functions/home.html +2 -2
  35. package/docs/functions/hostname.html +2 -2
  36. package/docs/functions/http.html +2 -2
  37. package/docs/functions/init.html +2 -2
  38. package/docs/functions/json.html +2 -2
  39. package/docs/functions/logerror.html +2 -2
  40. package/docs/functions/method.html +2 -2
  41. package/docs/functions/mixin.html +2 -2
  42. package/docs/functions/mount.html +2 -2
  43. package/docs/functions/pool.html +2 -2
  44. package/docs/functions/protocol.html +2 -2
  45. package/docs/functions/request.html +2 -2
  46. package/docs/functions/selectControllersSchema.html +1 -1
  47. package/docs/functions/stream.html +2 -2
  48. package/docs/functions/subaction.html +2 -2
  49. package/docs/functions/url.html +2 -2
  50. package/docs/functions/xml.html +2 -2
  51. package/docs/index.html +2 -2
  52. package/docs/interfaces/ApiErrorMessage.html +2 -2
  53. package/docs/interfaces/ContextSsr.html +2 -2
  54. package/docs/interfaces/ContextWeb.html +2 -2
  55. package/docs/interfaces/OptionsSsr.html +2 -2
  56. package/docs/interfaces/OptionsWeb.html +2 -2
  57. package/docs/interfaces/ResponseOptions.html +2 -2
  58. package/docs/interfaces/Route.html +2 -2
  59. package/docs/interfaces/Schema.html +2 -2
  60. package/docs/interfaces/ServerHandler.html +2 -2
  61. package/docs/interfaces/ServerOptions.html +2 -2
  62. package/docs/interfaces/ServerWebsocket.html +2 -2
  63. package/docs/modules.html +2 -2
  64. package/docs/types/ServerRoutes.html +1 -1
  65. package/docs/variables/helpers.html +2 -2
  66. package/index.js +1473 -4
  67. package/index.mjs +1417 -4
  68. package/jsonBody.js +25 -1
  69. package/jsonBody.mjs +23 -1
  70. package/multipartBody.js +42 -1
  71. package/multipartBody.mjs +40 -1
  72. package/package.json +1 -1
  73. package/readConfig.js +11 -1
  74. package/readConfig.mjs +9 -1
  75. package/readConfigSync.js +11 -1
  76. package/readConfigSync.mjs +9 -1
  77. package/staticBody.js +205 -1
  78. package/staticBody.mjs +200 -1
  79. package/urlencodedBody.js +26 -1
  80. package/urlencodedBody.mjs +24 -1
  81. package/Jwt-7tQL-rwa.js +0 -1
  82. package/Jwt-CDdbxwvH.js +0 -1
package/urlencodedBody.js CHANGED
@@ -1 +1,26 @@
1
- "use strict";var c=require("./ApiError.js"),d=require("querystring");const f=e=>new Promise((o,t)=>{s(e,r=>o(r),()=>{t(new c.ApiError({message:"Can`t parse body",code:1,statusCode:404}))})});function s(e,o,t){let r=Buffer.from([]);e.onData((a,n)=>{if(r=Buffer.concat([r,Buffer.from(a)]),n)try{o(d.parse(r.toString()))}catch{o({})}}),e.onAborted(t)}exports.urlencodedBody=f;
1
+ 'use strict';
2
+
3
+ var ApiError = require('./ApiError.js');
4
+ var querystring = require('querystring');
5
+
6
+ const urlencodedBody = (res) => new Promise((resolve, reject) => {
7
+ readBody(res, (obj) => resolve(obj), () => {
8
+ reject(new ApiError.ApiError({ message: "Can`t parse body", code: 1, statusCode: 404 }));
9
+ });
10
+ });
11
+ function readBody(res, cb, err) {
12
+ let buffer = Buffer.from([]);
13
+ res.onData((ab, isLast) => {
14
+ buffer = Buffer.concat([buffer, Buffer.from(ab)]);
15
+ if (isLast) {
16
+ try {
17
+ cb(querystring.parse(buffer.toString()));
18
+ } catch (e) {
19
+ cb({});
20
+ }
21
+ }
22
+ });
23
+ res.onAborted(err);
24
+ }
25
+
26
+ exports.urlencodedBody = urlencodedBody;
@@ -1 +1,24 @@
1
- import{ApiError as a}from"./ApiError.mjs";import c from"querystring";const m=r=>new Promise((e,t)=>{s(r,o=>e(o),()=>{t(new a({message:"Can`t parse body",code:1,statusCode:404}))})});function s(r,e,t){let o=Buffer.from([]);r.onData((f,n)=>{if(o=Buffer.concat([o,Buffer.from(f)]),n)try{e(c.parse(o.toString()))}catch{e({})}}),r.onAborted(t)}export{m as urlencodedBody};
1
+ import { ApiError } from './ApiError.mjs';
2
+ import querystring from 'querystring';
3
+
4
+ const urlencodedBody = (res) => new Promise((resolve, reject) => {
5
+ readBody(res, (obj) => resolve(obj), () => {
6
+ reject(new ApiError({ message: "Can`t parse body", code: 1, statusCode: 404 }));
7
+ });
8
+ });
9
+ function readBody(res, cb, err) {
10
+ let buffer = Buffer.from([]);
11
+ res.onData((ab, isLast) => {
12
+ buffer = Buffer.concat([buffer, Buffer.from(ab)]);
13
+ if (isLast) {
14
+ try {
15
+ cb(querystring.parse(buffer.toString()));
16
+ } catch (e) {
17
+ cb({});
18
+ }
19
+ }
20
+ });
21
+ res.onAborted(err);
22
+ }
23
+
24
+ export { urlencodedBody };
package/Jwt-7tQL-rwa.js DELETED
@@ -1 +0,0 @@
1
- import l from"crypto";const i=e=>e.replace(/\+/ig,"-").replace(/\//ig,"_").replace(/=+$/,""),h=e=>e.replace(/-/ig,"+").replace(/_/ig,"/"),o=e=>i(Buffer.from(JSON.stringify(e)).toString("base64")),c=e=>JSON.parse(Buffer.from(h(e),"base64").toString());class g{constructor(r,t){this.algorithm="SHA256",this.secret=r,this.algorithm=t?.algorithm||this.algorithm,this.algorithm=this.algorithm.replace("-","")}verify(r){if(!r)return!1;const t=r.split(".");return i(l.createHmac(this.algorithm,this.secret).update(`${t[0]}.${t[1]}`).digest("base64"))===t[2]}sign(r){const t=o({alg:this.algorithm.replace("SHA","HS"),typ:"JWT"}),s=o(r),a=i(l.createHmac(this.algorithm,this.secret).update(`${t}.${s}`).digest("base64"));return`${t}.${s}.${a}`}decode(r){const t=(r||"").split("."),s=c(t[0]),a=c(t[1]);return{head:s,body:a}}}export{g as J,c as f,o as t,i as u};
package/Jwt-CDdbxwvH.js DELETED
@@ -1 +0,0 @@
1
- "use strict";var c=require("crypto");const i=t=>t.replace(/\+/ig,"-").replace(/\//ig,"_").replace(/=+$/,""),h=t=>t.replace(/-/ig,"+").replace(/_/ig,"/"),o=t=>i(Buffer.from(JSON.stringify(t)).toString("base64")),l=t=>JSON.parse(Buffer.from(h(t),"base64").toString());class g{constructor(r,e){this.algorithm="SHA256",this.secret=r,this.algorithm=e?.algorithm||this.algorithm,this.algorithm=this.algorithm.replace("-","")}verify(r){if(!r)return!1;const e=r.split(".");return i(c.createHmac(this.algorithm,this.secret).update(`${e[0]}.${e[1]}`).digest("base64"))===e[2]}sign(r){const e=o({alg:this.algorithm.replace("SHA","HS"),typ:"JWT"}),s=o(r),a=i(c.createHmac(this.algorithm,this.secret).update(`${e}.${s}`).digest("base64"));return`${e}.${s}.${a}`}decode(r){const e=(r||"").split("."),s=l(e[0]),a=l(e[1]);return{head:s,body:a}}}exports.Jwt=g,exports.fromBase64url=l,exports.toBase64url=o,exports.urlEncode=i;