jwt-auths 1.0.0
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/README.md +1 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +49 -0
- package/dist/index.mjs +28 -0
- package/package.json +41 -0
- package/src/cors/createToken.ts +8 -0
- package/src/cors/decodeToken.ts +0 -0
- package/src/cors/refreshToken.ts +8 -0
- package/src/cors/verifyToken.ts +0 -0
- package/src/index.ts +2 -0
- package/tsconfig.json +17 -0
- package/tsup.config.ts +10 -0
package/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
#jwt-auth
|
package/dist/index.d.mts
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
declare const createAccessToken: (jwtsecret: String, expiredDate: String | undefined, payload: any, algorithm?: String) => String;
|
2
|
+
|
3
|
+
declare const createRefreshToken: (jwtsecret: String, expiredDate: String | undefined, payload: any, algorithm?: String) => String;
|
4
|
+
|
5
|
+
export { createAccessToken, createRefreshToken };
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
declare const createAccessToken: (jwtsecret: String, expiredDate: String | undefined, payload: any, algorithm?: String) => String;
|
2
|
+
|
3
|
+
declare const createRefreshToken: (jwtsecret: String, expiredDate: String | undefined, payload: any, algorithm?: String) => String;
|
4
|
+
|
5
|
+
export { createAccessToken, createRefreshToken };
|
package/dist/index.js
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
|
20
|
+
// src/index.ts
|
21
|
+
var index_exports = {};
|
22
|
+
__export(index_exports, {
|
23
|
+
createAccessToken: () => createAccessToken,
|
24
|
+
createRefreshToken: () => createRefreshToken
|
25
|
+
});
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
27
|
+
|
28
|
+
// src/cors/createToken.ts
|
29
|
+
var jwt = require("jsonwebtoken");
|
30
|
+
var createAccessToken = (jwtsecret, expiredDate = "15m", payload, algorithm = "HS256") => {
|
31
|
+
return jwt.sign(payload, jwtsecret, {
|
32
|
+
algorithm,
|
33
|
+
expiresIn: expiredDate
|
34
|
+
});
|
35
|
+
};
|
36
|
+
|
37
|
+
// src/cors/refreshToken.ts
|
38
|
+
var jwt2 = require("jsonwebtoken");
|
39
|
+
var createRefreshToken = (jwtsecret, expiredDate = "7d", payload, algorithm = "HS256") => {
|
40
|
+
return jwt2.sign(payload, jwtsecret, {
|
41
|
+
algorithm,
|
42
|
+
expiresIn: expiredDate
|
43
|
+
});
|
44
|
+
};
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
46
|
+
0 && (module.exports = {
|
47
|
+
createAccessToken,
|
48
|
+
createRefreshToken
|
49
|
+
});
|
package/dist/index.mjs
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
3
|
+
}) : x)(function(x) {
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
6
|
+
});
|
7
|
+
|
8
|
+
// src/cors/createToken.ts
|
9
|
+
var jwt = __require("jsonwebtoken");
|
10
|
+
var createAccessToken = (jwtsecret, expiredDate = "15m", payload, algorithm = "HS256") => {
|
11
|
+
return jwt.sign(payload, jwtsecret, {
|
12
|
+
algorithm,
|
13
|
+
expiresIn: expiredDate
|
14
|
+
});
|
15
|
+
};
|
16
|
+
|
17
|
+
// src/cors/refreshToken.ts
|
18
|
+
var jwt2 = __require("jsonwebtoken");
|
19
|
+
var createRefreshToken = (jwtsecret, expiredDate = "7d", payload, algorithm = "HS256") => {
|
20
|
+
return jwt2.sign(payload, jwtsecret, {
|
21
|
+
algorithm,
|
22
|
+
expiresIn: expiredDate
|
23
|
+
});
|
24
|
+
};
|
25
|
+
export {
|
26
|
+
createAccessToken,
|
27
|
+
createRefreshToken
|
28
|
+
};
|
package/package.json
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
{
|
2
|
+
"name": "jwt-auths",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "A fully functional JWT authentication library for securely generating, verifying, and managing JSON Web Tokens.",
|
5
|
+
"main": "./dist/index.js",
|
6
|
+
"module": "./dist/index.mjs",
|
7
|
+
"types": "./dist/index.d.ts",
|
8
|
+
"scripts": {
|
9
|
+
"build": "tsup"
|
10
|
+
},
|
11
|
+
"repository": {
|
12
|
+
"type": "git",
|
13
|
+
"url": "https://github.com/BrangB/jwt-auth.git"
|
14
|
+
},
|
15
|
+
"keywords": [
|
16
|
+
"jwt",
|
17
|
+
"authentication",
|
18
|
+
"authorization",
|
19
|
+
"jsonwebtoken",
|
20
|
+
"security",
|
21
|
+
"access-token",
|
22
|
+
"nodejs",
|
23
|
+
"typescript"
|
24
|
+
],
|
25
|
+
"author": "brangtsawmaung",
|
26
|
+
"license": "MIT",
|
27
|
+
"bugs": {
|
28
|
+
"url": "https://github.com/BrangB/jwt-auth/issues"
|
29
|
+
},
|
30
|
+
"homepage": "https://github.com/BrangB/jwt-auth#readme",
|
31
|
+
"devDependencies": {
|
32
|
+
"tsup": "^8.3.6",
|
33
|
+
"typescript": "^5.7.3"
|
34
|
+
},
|
35
|
+
"publishConfig": {
|
36
|
+
"access": "public"
|
37
|
+
},
|
38
|
+
"dependencies": {
|
39
|
+
"@types/jsonwebtoken": "^9.0.8"
|
40
|
+
}
|
41
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
const jwt = require('jsonwebtoken');
|
2
|
+
|
3
|
+
export const createAccessToken = (jwtsecret: String, expiredDate: String = '15m', payload: any, algorithm:String = 'HS256'):String => {
|
4
|
+
return jwt.sign(payload, jwtsecret, {
|
5
|
+
algorithm: algorithm,
|
6
|
+
expiresIn: expiredDate,
|
7
|
+
});
|
8
|
+
}
|
File without changes
|
@@ -0,0 +1,8 @@
|
|
1
|
+
const jwt = require('jsonwebtoken');
|
2
|
+
|
3
|
+
export const createRefreshToken = (jwtsecret: String, expiredDate: String = '7d', payload: any, algorithm:String = 'HS256'):String => {
|
4
|
+
return jwt.sign(payload, jwtsecret, {
|
5
|
+
algorithm: algorithm,
|
6
|
+
expiresIn: expiredDate,
|
7
|
+
});
|
8
|
+
}
|
File without changes
|
package/src/index.ts
ADDED
package/tsconfig.json
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"strict": true,
|
4
|
+
"noImplicitAny": true,
|
5
|
+
"esModuleInterop": true,
|
6
|
+
"strictNullChecks": true,
|
7
|
+
"target": "ES2022",
|
8
|
+
"moduleResolution": "Node10",
|
9
|
+
"module": "CommonJS",
|
10
|
+
"declaration": true,
|
11
|
+
"isolatedModules": true,
|
12
|
+
"noEmit": true,
|
13
|
+
"outDir": "dist"
|
14
|
+
},
|
15
|
+
"include": ["src"],
|
16
|
+
"exclude": ["node_modules"]
|
17
|
+
}
|