b2m-utils 0.0.1
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/build/functions/getCookies.d.ts +1 -0
- package/build/functions/getDataFromToken.d.ts +1 -0
- package/build/functions/index.d.ts +2 -0
- package/build/index.d.ts +1 -0
- package/build/index.esm.js +25 -0
- package/build/index.esm.js.gz +0 -0
- package/build/index.esm.js.map +1 -0
- package/build/index.js +30 -0
- package/build/index.js.gz +0 -0
- package/build/index.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getCookies: (cookies: string | undefined) => any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getDataFromToken(token: string): any;
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './functions';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var getCookies = function (cookies) {
|
|
2
|
+
if (cookies) {
|
|
3
|
+
var data_1 = {};
|
|
4
|
+
cookies
|
|
5
|
+
.split(';')
|
|
6
|
+
.map(function (item) { return item.trim().split('='); })
|
|
7
|
+
.forEach(function (item) { return (data_1[item[0]] = item[1]); });
|
|
8
|
+
return data_1;
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
return {};
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function getDataFromToken(token) {
|
|
16
|
+
var jwtDataBase64 = token.split('.')[1];
|
|
17
|
+
var data = JSON.parse(Buffer.from(jwtDataBase64, 'base64').toString());
|
|
18
|
+
if (data.exp * 1000 < Date.now()) {
|
|
19
|
+
throw new Error('Token expirado.');
|
|
20
|
+
}
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { getCookies, getDataFromToken };
|
|
25
|
+
//# sourceMappingURL=index.esm.js.map
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/functions/getCookies.ts","../src/functions/getDataFromToken.ts"],"sourcesContent":["export const getCookies = (cookies: string | undefined) => {\r\n\r\n if (cookies) {\r\n\r\n const data = {} as any;\r\n\r\n cookies\r\n .split(';')\r\n .map((item) => item.trim().split('='))\r\n .forEach((item) => (data[item[0]] = item[1]));\r\n \r\n return data;\r\n\r\n } else {\r\n return {};\r\n }\r\n\r\n}","export function getDataFromToken(token: string) {\r\n const jwtDataBase64 = token.split('.')[1];\r\n\r\n const data = JSON.parse(Buffer.from(jwtDataBase64, 'base64').toString());\r\n\r\n if (data.exp * 1000 < Date.now()) {\r\n throw new Error('Token expirado.');\r\n }\r\n\r\n return data;\r\n}\r\n"],"names":[],"mappings":"AAAO,IAAM,UAAU,GAAG,UAAC,OAA2B,EAAA;AAElD,IAAA,IAAI,OAAO,EAAE;QAET,IAAM,MAAI,GAAG,EAAS,CAAC;QAEvB,OAAO;aACF,KAAK,CAAC,GAAG,CAAC;AACV,aAAA,GAAG,CAAC,UAAC,IAAI,EAAK,EAAA,OAAA,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA,EAAA,CAAC;aACrC,OAAO,CAAC,UAAC,IAAI,EAAA,EAAK,QAAC,MAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,EAAC,EAAA,CAAC,CAAC;AAElD,QAAA,OAAO,MAAI,CAAC;AAEf,KAAA;AAAM,SAAA;AACH,QAAA,OAAO,EAAE,CAAC;AACb,KAAA;AAEL;;ACjBM,SAAU,gBAAgB,CAAC,KAAa,EAAA;IAC5C,IAAM,aAAa,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAE1C,IAAA,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEzE,IAAI,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE;AAChC,QAAA,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;AACpC,KAAA;AAED,IAAA,OAAO,IAAI,CAAC;AACd;;;;"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var getCookies = function (cookies) {
|
|
6
|
+
if (cookies) {
|
|
7
|
+
var data_1 = {};
|
|
8
|
+
cookies
|
|
9
|
+
.split(';')
|
|
10
|
+
.map(function (item) { return item.trim().split('='); })
|
|
11
|
+
.forEach(function (item) { return (data_1[item[0]] = item[1]); });
|
|
12
|
+
return data_1;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function getDataFromToken(token) {
|
|
20
|
+
var jwtDataBase64 = token.split('.')[1];
|
|
21
|
+
var data = JSON.parse(Buffer.from(jwtDataBase64, 'base64').toString());
|
|
22
|
+
if (data.exp * 1000 < Date.now()) {
|
|
23
|
+
throw new Error('Token expirado.');
|
|
24
|
+
}
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.getCookies = getCookies;
|
|
29
|
+
exports.getDataFromToken = getDataFromToken;
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/functions/getCookies.ts","../src/functions/getDataFromToken.ts"],"sourcesContent":["export const getCookies = (cookies: string | undefined) => {\r\n\r\n if (cookies) {\r\n\r\n const data = {} as any;\r\n\r\n cookies\r\n .split(';')\r\n .map((item) => item.trim().split('='))\r\n .forEach((item) => (data[item[0]] = item[1]));\r\n \r\n return data;\r\n\r\n } else {\r\n return {};\r\n }\r\n\r\n}","export function getDataFromToken(token: string) {\r\n const jwtDataBase64 = token.split('.')[1];\r\n\r\n const data = JSON.parse(Buffer.from(jwtDataBase64, 'base64').toString());\r\n\r\n if (data.exp * 1000 < Date.now()) {\r\n throw new Error('Token expirado.');\r\n }\r\n\r\n return data;\r\n}\r\n"],"names":[],"mappings":";;;;AAAO,IAAM,UAAU,GAAG,UAAC,OAA2B,EAAA;AAElD,IAAA,IAAI,OAAO,EAAE;QAET,IAAM,MAAI,GAAG,EAAS,CAAC;QAEvB,OAAO;aACF,KAAK,CAAC,GAAG,CAAC;AACV,aAAA,GAAG,CAAC,UAAC,IAAI,EAAK,EAAA,OAAA,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA,EAAA,CAAC;aACrC,OAAO,CAAC,UAAC,IAAI,EAAA,EAAK,QAAC,MAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,EAAC,EAAA,CAAC,CAAC;AAElD,QAAA,OAAO,MAAI,CAAC;AAEf,KAAA;AAAM,SAAA;AACH,QAAA,OAAO,EAAE,CAAC;AACb,KAAA;AAEL;;ACjBM,SAAU,gBAAgB,CAAC,KAAa,EAAA;IAC5C,IAAM,aAAa,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAE1C,IAAA,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEzE,IAAI,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE;AAChC,QAAA,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;AACpC,KAAA;AAED,IAAA,OAAO,IAAI,CAAC;AACd;;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "b2m-utils",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "B2M Utils",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"module": "build/index.esm.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"build"
|
|
9
|
+
],
|
|
10
|
+
"types": "build/index.d.ts",
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=16"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"prebuild": "rimraf build",
|
|
16
|
+
"build": "rollup -c",
|
|
17
|
+
"123postbuild": "npm run new:version",
|
|
18
|
+
"preprod": "npm run lint && npm run build",
|
|
19
|
+
"prod": "npm publish",
|
|
20
|
+
"lint": "npx eslint src/**"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/B2M-Audit-Payment-Solutions/b2m-utils.git"
|
|
25
|
+
},
|
|
26
|
+
"author": "B2M Developer (https://b2mplatform.com.br)",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/B2M-Audit-Payment-Solutions/b2m-utils/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/B2M-Audit-Payment-Solutions/b2m-utils#readme",
|
|
32
|
+
"keywords": [
|
|
33
|
+
"functions",
|
|
34
|
+
"types",
|
|
35
|
+
"interfaces"
|
|
36
|
+
],
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@rollup/plugin-commonjs": "^19.0.1",
|
|
39
|
+
"@rollup/plugin-node-resolve": "^13.0.4",
|
|
40
|
+
"@types/node": "^20.8.7",
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "^5.59.5",
|
|
42
|
+
"@typescript-eslint/parser": "^5.2.0",
|
|
43
|
+
"eslint": "7",
|
|
44
|
+
"eslint-config-next": "^12.0.1",
|
|
45
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
46
|
+
"rollup": "^2.54.0",
|
|
47
|
+
"rollup-plugin-babel": "^4.4.0",
|
|
48
|
+
"rollup-plugin-copy": "^3.3.0",
|
|
49
|
+
"rollup-plugin-gzip": "^2.5.0",
|
|
50
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
51
|
+
"rollup-plugin-postcss": "^4.0.0",
|
|
52
|
+
"rollup-plugin-typescript2": "^0.34.1",
|
|
53
|
+
"typescript": "5.1"
|
|
54
|
+
}
|
|
55
|
+
}
|