@ctx-core/jwt 10.3.61 → 10.4.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
@@ -1,5 +1,17 @@
1
1
  # @ctx-core/jwt
2
2
 
3
+ ## 10.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - - jwt**expiration**error\_
8
+
9
+ ## 10.3.62
10
+
11
+ ### Patch Changes
12
+
13
+ - @ctx-core/atob: ^10.1.52 -> ^10.1.53
14
+
3
15
  ## 10.3.61
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctx-core/jwt",
3
- "version": "10.3.61",
3
+ "version": "10.4.0",
4
4
  "description": "ctx-core jwt",
5
5
  "keywords": [
6
6
  "ctx-core",
@@ -24,7 +24,7 @@
24
24
  "./package.json": "./package.json"
25
25
  },
26
26
  "dependencies": {
27
- "@ctx-core/atob": "^10.1.52",
27
+ "@ctx-core/atob": "^10.1.53",
28
28
  "@ctx-core/error": "^11.6.20",
29
29
  "@ctx-core/function": "^21.12.1"
30
30
  },
package/src/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './_types'
2
2
  export * from './authorization__header__jwt_token_'
3
3
  export * from './jwt_token_exp_'
4
+ export * from './jwt__expiration__error_'
4
5
  export * from './jwt__expiration__is_valid_'
5
6
  export * from './jwt__expiration__validate'
package/src/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './authorization__header__jwt_token_/index.js'
2
2
  export * from './jwt_token_exp_/index.js'
3
+ export * from './jwt__expiration__error_/index.js'
3
4
  export * from './jwt__expiration__is_valid_/index.js'
4
5
  export * from './jwt__expiration__validate/index.js'
@@ -0,0 +1,2 @@
1
+ import type { BadCredentialsError } from '@ctx-core/error'
2
+ export declare function jwt__expiration__error_(jwt_token:string):BadCredentialsError|null
@@ -0,0 +1,16 @@
1
+ import { bad_credentials_error_ } from '@ctx-core/error'
2
+ import { jwt__expiration__is_valid_ } from '../jwt__expiration__is_valid_/index.js'
3
+ /**
4
+ * @param {string}jwt_token
5
+ * @returns {import('@ctx-core/error').BadCredentialsError}
6
+ */
7
+ export function jwt__expiration__error_(jwt_token) {
8
+ return (
9
+ jwt__expiration__is_valid_(jwt_token)
10
+ ? null
11
+ : bad_credentials_error_({
12
+ data: { jwt_token },
13
+ error_message: 'Session Expired'
14
+ })
15
+ )
16
+ }
@@ -1,15 +1,10 @@
1
- import { bad_credentials__throw } from '@ctx-core/error'
2
- import { jwt__expiration__is_valid_ } from '../jwt__expiration__is_valid_/index.js'
1
+ import { jwt__expiration__error_ } from '../jwt__expiration__error_/index.js'
3
2
  /**
4
3
  * @param {string}jwt_token
5
4
  */
6
5
  export function jwt__expiration__validate(jwt_token) {
7
- if (!jwt__expiration__is_valid_(jwt_token)) {
8
- bad_credentials__throw({
9
- data: { jwt_token },
10
- error_message: 'Session Expired'
11
- })
12
- }
6
+ const jwt__expiration__error = jwt__expiration__error_(jwt_token)
7
+ if (jwt__expiration__error) throw jwt__expiration__error
13
8
  }
14
9
  export {
15
10
  jwt__expiration__validate as validate_current_jwt,