@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.
- package/ApiError.js +37 -1
- package/ApiError.mjs +35 -1
- package/Jwt-B4QZ2Ypb.js +80 -0
- package/Jwt-Be4GWrIO.js +75 -0
- package/Jwt.js +8 -1
- package/Jwt.mjs +2 -1
- package/Memcached.js +166 -9
- package/Memcached.mjs +164 -9
- package/Server.js +316 -1
- package/Server.mjs +313 -1
- package/cookieParse.js +25 -1
- package/cookieParse.mjs +23 -1
- package/cookieString.js +22 -1
- package/cookieString.mjs +20 -1
- package/docs/classes/ApiError.html +2 -2
- package/docs/classes/AsyncJwt.html +2 -2
- package/docs/classes/Controller.html +2 -2
- package/docs/classes/Jwt.html +2 -2
- package/docs/classes/Memcached.html +2 -2
- package/docs/classes/Model.html +2 -2
- package/docs/classes/Server.html +2 -2
- package/docs/classes/Ssr.html +2 -2
- package/docs/classes/Web.html +2 -2
- package/docs/functions/action.html +2 -2
- package/docs/functions/body.html +2 -2
- package/docs/functions/codeToStatus.html +2 -2
- package/docs/functions/config.html +2 -2
- package/docs/functions/connection.html +2 -2
- package/docs/functions/context.html +2 -2
- package/docs/functions/controller-1.html +2 -2
- package/docs/functions/cookies.html +2 -2
- package/docs/functions/db.html +2 -2
- package/docs/functions/headers.html +2 -2
- package/docs/functions/home.html +2 -2
- package/docs/functions/hostname.html +2 -2
- package/docs/functions/http.html +2 -2
- package/docs/functions/init.html +2 -2
- package/docs/functions/json.html +2 -2
- package/docs/functions/logerror.html +2 -2
- package/docs/functions/method.html +2 -2
- package/docs/functions/mixin.html +2 -2
- package/docs/functions/mount.html +2 -2
- package/docs/functions/pool.html +2 -2
- package/docs/functions/protocol.html +2 -2
- package/docs/functions/request.html +2 -2
- package/docs/functions/selectControllersSchema.html +1 -1
- package/docs/functions/stream.html +2 -2
- package/docs/functions/subaction.html +2 -2
- package/docs/functions/url.html +2 -2
- package/docs/functions/xml.html +2 -2
- package/docs/index.html +2 -2
- package/docs/interfaces/ApiErrorMessage.html +2 -2
- package/docs/interfaces/ContextSsr.html +2 -2
- package/docs/interfaces/ContextWeb.html +2 -2
- package/docs/interfaces/OptionsSsr.html +2 -2
- package/docs/interfaces/OptionsWeb.html +2 -2
- package/docs/interfaces/ResponseOptions.html +2 -2
- package/docs/interfaces/Route.html +2 -2
- package/docs/interfaces/Schema.html +2 -2
- package/docs/interfaces/ServerHandler.html +2 -2
- package/docs/interfaces/ServerOptions.html +2 -2
- package/docs/interfaces/ServerWebsocket.html +2 -2
- package/docs/modules.html +2 -2
- package/docs/types/ServerRoutes.html +1 -1
- package/docs/variables/helpers.html +2 -2
- package/index.js +1473 -4
- package/index.mjs +1417 -4
- package/jsonBody.js +25 -1
- package/jsonBody.mjs +23 -1
- package/multipartBody.js +42 -1
- package/multipartBody.mjs +40 -1
- package/package.json +1 -1
- package/readConfig.js +11 -1
- package/readConfig.mjs +9 -1
- package/readConfigSync.js +11 -1
- package/readConfigSync.mjs +9 -1
- package/staticBody.js +205 -1
- package/staticBody.mjs +200 -1
- package/urlencodedBody.js +26 -1
- package/urlencodedBody.mjs +24 -1
- package/Jwt-7tQL-rwa.js +0 -1
- package/Jwt-CDdbxwvH.js +0 -1
package/urlencodedBody.js
CHANGED
|
@@ -1 +1,26 @@
|
|
|
1
|
-
|
|
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;
|
package/urlencodedBody.mjs
CHANGED
|
@@ -1 +1,24 @@
|
|
|
1
|
-
import{ApiError
|
|
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;
|