jssign 0.3.12 → 0.3.14
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/dist/index.cjs +8 -19
- package/dist/index.mjs +1 -7
- package/dist/types.mjs +1 -1
- package/package.json +5 -4
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region \0rolldown/runtime.js
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -7,16 +7,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
20
16
|
}
|
|
21
17
|
return to;
|
|
22
18
|
};
|
|
@@ -24,15 +20,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
20
|
value: mod,
|
|
25
21
|
enumerable: true
|
|
26
22
|
}) : target, mod));
|
|
27
|
-
|
|
28
23
|
//#endregion
|
|
29
24
|
let sjcl = require("sjcl");
|
|
30
25
|
sjcl = __toESM(sjcl);
|
|
31
|
-
|
|
32
26
|
//#region src/constants.ts
|
|
33
27
|
const characters = "abcdefghijklmnopqrstuvwxyz`1234567890-=[];,./~!@#$%^&*()_+{}:<>?";
|
|
34
28
|
const pairRegex = /(.{1,2})/g;
|
|
35
|
-
|
|
36
29
|
//#endregion
|
|
37
30
|
//#region src/lib/utils.ts
|
|
38
31
|
const byteHex = (n) => ("0" + Number(n).toString(16)).slice(-2);
|
|
@@ -45,7 +38,6 @@ function genSalt(length) {
|
|
|
45
38
|
}
|
|
46
39
|
const stringFromCode = (code) => String.fromCharCode(code);
|
|
47
40
|
const textToChars = (text) => text.split("").map((c) => c.charCodeAt(0));
|
|
48
|
-
|
|
49
41
|
//#endregion
|
|
50
42
|
//#region src/lib/cipher.ts
|
|
51
43
|
const encoder = new TextEncoder();
|
|
@@ -78,7 +70,6 @@ function decode(token, secret, mode) {
|
|
|
78
70
|
for (let i = 0; i < tokenLength; i++) decodedBytes[i] = tokenBytes[i] ^ secretBytes[i % secretLength];
|
|
79
71
|
return decoder.decode(decodedBytes);
|
|
80
72
|
}
|
|
81
|
-
|
|
82
73
|
//#endregion
|
|
83
74
|
//#region src/lib/token.ts
|
|
84
75
|
function validateData(token, secret, getData) {
|
|
@@ -90,7 +81,6 @@ function validateData(token, secret, getData) {
|
|
|
90
81
|
throw new Error("Invalid token or secret!");
|
|
91
82
|
}
|
|
92
83
|
}
|
|
93
|
-
|
|
94
84
|
//#endregion
|
|
95
85
|
//#region src/index.ts
|
|
96
86
|
function sign(data, secret, { expiresIn = 0, sl = 32 } = {}) {
|
|
@@ -125,9 +115,8 @@ function decrypt(token, secret) {
|
|
|
125
115
|
return sjcl.default.decrypt(secret, JSON.stringify(encryptedObj));
|
|
126
116
|
});
|
|
127
117
|
}
|
|
128
|
-
|
|
129
118
|
//#endregion
|
|
130
119
|
exports.decrypt = decrypt;
|
|
131
120
|
exports.encrypt = encrypt;
|
|
132
121
|
exports.sign = sign;
|
|
133
|
-
exports.verify = verify;
|
|
122
|
+
exports.verify = verify;
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import sjcl from "sjcl";
|
|
2
|
-
|
|
3
2
|
//#region src/constants.ts
|
|
4
3
|
const characters = "abcdefghijklmnopqrstuvwxyz`1234567890-=[];,./~!@#$%^&*()_+{}:<>?";
|
|
5
4
|
const pairRegex = /(.{1,2})/g;
|
|
6
|
-
|
|
7
5
|
//#endregion
|
|
8
6
|
//#region src/lib/utils.ts
|
|
9
7
|
const byteHex = (n) => ("0" + Number(n).toString(16)).slice(-2);
|
|
@@ -16,7 +14,6 @@ function genSalt(length) {
|
|
|
16
14
|
}
|
|
17
15
|
const stringFromCode = (code) => String.fromCharCode(code);
|
|
18
16
|
const textToChars = (text) => text.split("").map((c) => c.charCodeAt(0));
|
|
19
|
-
|
|
20
17
|
//#endregion
|
|
21
18
|
//#region src/lib/cipher.ts
|
|
22
19
|
const encoder = new TextEncoder();
|
|
@@ -49,7 +46,6 @@ function decode(token, secret, mode) {
|
|
|
49
46
|
for (let i = 0; i < tokenLength; i++) decodedBytes[i] = tokenBytes[i] ^ secretBytes[i % secretLength];
|
|
50
47
|
return decoder.decode(decodedBytes);
|
|
51
48
|
}
|
|
52
|
-
|
|
53
49
|
//#endregion
|
|
54
50
|
//#region src/lib/token.ts
|
|
55
51
|
function validateData(token, secret, getData) {
|
|
@@ -61,7 +57,6 @@ function validateData(token, secret, getData) {
|
|
|
61
57
|
throw new Error("Invalid token or secret!");
|
|
62
58
|
}
|
|
63
59
|
}
|
|
64
|
-
|
|
65
60
|
//#endregion
|
|
66
61
|
//#region src/index.ts
|
|
67
62
|
function sign(data, secret, { expiresIn = 0, sl = 32 } = {}) {
|
|
@@ -96,6 +91,5 @@ function decrypt(token, secret) {
|
|
|
96
91
|
return sjcl.decrypt(secret, JSON.stringify(encryptedObj));
|
|
97
92
|
});
|
|
98
93
|
}
|
|
99
|
-
|
|
100
94
|
//#endregion
|
|
101
|
-
export { decrypt, encrypt, sign, verify };
|
|
95
|
+
export { decrypt, encrypt, sign, verify };
|
package/dist/types.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jssign",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.14",
|
|
4
4
|
"description": "A token generator library to encode and decode data using a secret key",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sahil Aggarwal <aggarwalsahil2004@gmail.com>",
|
|
@@ -29,15 +29,16 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"sideEffects": false,
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"sjcl": "^1.0.
|
|
34
|
+
"sjcl": "^1.0.9"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@release-it/conventional-changelog": "^10.0.
|
|
37
|
+
"@release-it/conventional-changelog": "^10.0.6",
|
|
37
38
|
"@types/sjcl": "^1.0.34",
|
|
38
39
|
"prettier-package-json": "^2.8.0",
|
|
39
40
|
"release-it": "^19.2.4",
|
|
40
|
-
"tsdown": "^0.
|
|
41
|
+
"tsdown": "^0.21.4",
|
|
41
42
|
"typescript": "^5.9.3"
|
|
42
43
|
},
|
|
43
44
|
"keywords": [
|