@ctx-core/jwt 10.2.8 → 10.3.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/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ctx-core/jwt",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.3.0",
|
|
4
4
|
"description": "ctx-core jwt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ctx-core",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@swc/core": "^1.3.35"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"c8": "^7.
|
|
34
|
+
"c8": "^7.13.0",
|
|
35
35
|
"check-dts": "^0.7.0",
|
|
36
36
|
"tsx": "^3.12.3",
|
|
37
37
|
"typescript": "next",
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function jwt__expiration__is_valid_(jwt_token:string):boolean
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jwt_token_exp_ } from '../jwt_token_exp_/index.js'
|
|
2
|
+
/**
|
|
3
|
+
* @param jwt_token{string}
|
|
4
|
+
* @returns {boolean}
|
|
5
|
+
*/
|
|
6
|
+
export function jwt__expiration__is_valid_(jwt_token) {
|
|
7
|
+
const jwt_token_exp = jwt_token_exp_(jwt_token)
|
|
8
|
+
if (jwt_token_exp === null) return true
|
|
9
|
+
const jwt_token_exp_millis = jwt_token_exp * 1000
|
|
10
|
+
return Date.now() <= jwt_token_exp_millis
|
|
11
|
+
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { bad_credentials__throw } from '@ctx-core/error'
|
|
2
|
-
import {
|
|
2
|
+
import { jwt__expiration__is_valid_ } from '../jwt__expiration__is_valid_/index.js'
|
|
3
3
|
/**
|
|
4
4
|
* @param {string}jwt_token
|
|
5
5
|
*/
|
|
6
6
|
export function jwt__expiration__validate(jwt_token) {
|
|
7
|
-
|
|
8
|
-
if (jwt_token_exp === null) return
|
|
9
|
-
const jwt_token_exp_millis = jwt_token_exp * 1000
|
|
10
|
-
if (Date.now() > jwt_token_exp_millis) {
|
|
7
|
+
if (!jwt__expiration__is_valid_(jwt_token)) {
|
|
11
8
|
bad_credentials__throw({
|
|
12
|
-
jwt_token,
|
|
9
|
+
data: { jwt_token },
|
|
13
10
|
error_message: 'Session Expired'
|
|
14
11
|
})
|
|
15
12
|
}
|