@ctx-core/jwt 10.0.48 → 10.1.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 +36 -0
- package/package.json +17 -14
- package/src/_types/JwtToken.d.ts +11 -0
- package/src/_types/index.ts +2 -0
- package/src/{jwt_error_ctx_I.ts → _types/jwt_error_ctx_I.d.ts} +0 -0
- package/src/header_authorization_jwt_token_.d.ts +6 -0
- package/src/{header_authorization_jwt_token_.ts → header_authorization_jwt_token_.js} +6 -3
- package/src/index.d.ts +4 -0
- package/src/{index.ts → index.js} +0 -2
- package/src/jwt_token_exp_.d.ts +3 -0
- package/src/jwt_token_exp_.js +12 -0
- package/src/validate_current_jwt.d.ts +3 -0
- package/src/{validate_current_jwt.ts → validate_current_jwt.js} +7 -7
- package/.swcrc +0 -10
- package/lib/JwtToken.d.ts +0 -9
- package/lib/JwtToken.js +0 -3
- package/lib/JwtToken.js.map +0 -1
- package/lib/header_authorization_jwt_token_.d.ts +0 -3
- package/lib/header_authorization_jwt_token_.js +0 -7
- package/lib/header_authorization_jwt_token_.js.map +0 -1
- package/lib/index.d.ts +0 -5
- package/lib/index.js +0 -7
- package/lib/index.js.map +0 -1
- package/lib/jwt_error_ctx_I.d.ts +0 -4
- package/lib/jwt_error_ctx_I.js +0 -3
- package/lib/jwt_error_ctx_I.js.map +0 -1
- package/lib/jwt_token_exp_.d.ts +0 -3
- package/lib/jwt_token_exp_.js +0 -9
- package/lib/jwt_token_exp_.js.map +0 -1
- package/lib/validate_current_jwt.d.ts +0 -3
- package/lib/validate_current_jwt.js +0 -15
- package/lib/validate_current_jwt.js.map +0 -1
- package/src/JwtToken.ts +0 -9
- package/src/jwt_token_exp_.ts +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @ctx-core/jwt
|
|
2
2
|
|
|
3
|
+
## 10.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- JwtToken: + expires_in: number
|
|
8
|
+
- JwtToken: aliased by Token
|
|
9
|
+
|
|
10
|
+
## 10.0.51
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- update dependencies
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
- @ctx-core/atob@10.0.47
|
|
17
|
+
- @ctx-core/error@11.3.1
|
|
18
|
+
|
|
19
|
+
## 10.0.50
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- sideEffects = false
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
- @ctx-core/atob@10.0.46
|
|
26
|
+
- @ctx-core/error@11.1.23
|
|
27
|
+
- @ctx-core/function@20.2.25
|
|
28
|
+
|
|
29
|
+
## 10.0.49
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- @swc/core: ^1.2.125 -> ^1.2.127
|
|
34
|
+
- Updated dependencies
|
|
35
|
+
- @ctx-core/atob@10.0.45
|
|
36
|
+
- @ctx-core/error@11.1.22
|
|
37
|
+
- @ctx-core/function@20.2.24
|
|
38
|
+
|
|
3
39
|
## 10.0.48
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ctx-core/jwt",
|
|
3
|
-
"version": "10.0
|
|
3
|
+
"version": "10.1.0",
|
|
4
4
|
"description": "ctx-core jwt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ctx-core",
|
|
@@ -25,28 +25,31 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@ctx-core/atob": "^10.0.
|
|
29
|
-
"@ctx-core/error": "^11.1
|
|
30
|
-
"@ctx-core/function": "
|
|
28
|
+
"@ctx-core/atob": "^10.0.47",
|
|
29
|
+
"@ctx-core/error": "^11.3.1",
|
|
30
|
+
"@ctx-core/function": "20.4.0",
|
|
31
31
|
"@swc/cli": "^0.1.55",
|
|
32
|
-
"@swc/core": "^1.2.
|
|
32
|
+
"@swc/core": "^1.2.138"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
35
|
+
"c8": "^7.11.0",
|
|
36
|
+
"check-dts": "^0.6.6",
|
|
37
|
+
"tsm": "^2.2.1",
|
|
38
|
+
"typescript": "next",
|
|
39
|
+
"uvu": "^0.5.3"
|
|
37
40
|
},
|
|
38
41
|
"publishConfig": {
|
|
39
42
|
"access": "public",
|
|
40
43
|
"cache": "~/.npm"
|
|
41
44
|
},
|
|
42
45
|
"svelte": "./lib/index.js",
|
|
46
|
+
"sideEffects": false,
|
|
43
47
|
"scripts": {
|
|
44
|
-
"build": "
|
|
45
|
-
"clean": "
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"exec": "$@"
|
|
48
|
+
"build": ":",
|
|
49
|
+
"clean": ":",
|
|
50
|
+
"exec": "$@",
|
|
51
|
+
"test": "pnpm test-unit && check-dts",
|
|
52
|
+
"test-unit": "tsm node_modules/uvu/bin.js . '\\.test\\.(ts|js)$'",
|
|
53
|
+
"test-unit-coverage": "c8 pnpm test-unit"
|
|
51
54
|
}
|
|
52
55
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { error_ctx_I } from '@ctx-core/error'
|
|
2
|
+
import type { nullish } from '@ctx-core/function'
|
|
3
|
+
export interface JwtToken {
|
|
4
|
+
access_token:string
|
|
5
|
+
token_type:string
|
|
6
|
+
id_token?:string
|
|
7
|
+
email?:string
|
|
8
|
+
error?:error_ctx_I|nullish
|
|
9
|
+
expires_in?:number
|
|
10
|
+
}
|
|
11
|
+
export type Token = JwtToken
|
|
File without changes
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { nullish } from '@ctx-core/function'
|
|
2
|
+
export declare function header_authorization_jwt_token_(authorization:string|nullish):string|null
|
|
3
|
+
export {
|
|
4
|
+
header_authorization_jwt_token_ as _header_authorization_jwt_token,
|
|
5
|
+
header_authorization_jwt_token_ as _jwt_token__authorization__header,
|
|
6
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @param {string|nullish}authorization
|
|
3
|
+
* @return {string|null}
|
|
4
|
+
*/
|
|
5
|
+
export function header_authorization_jwt_token_(authorization) {
|
|
3
6
|
const authorization_a = authorization?.split(/^Bearer */)
|
|
4
|
-
return authorization_a ? authorization_a[1] :
|
|
7
|
+
return authorization_a ? authorization_a[1] : null
|
|
5
8
|
}
|
|
6
9
|
export {
|
|
7
10
|
header_authorization_jwt_token_ as _header_authorization_jwt_token,
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { atob_ } from '@ctx-core/atob'
|
|
2
|
+
/**
|
|
3
|
+
* @param {string|nullish}jwt_token
|
|
4
|
+
* @return {number|null}
|
|
5
|
+
*/
|
|
6
|
+
export function jwt_token_exp_(jwt_token) {
|
|
7
|
+
const atob = atob_()
|
|
8
|
+
if (!jwt_token) return null
|
|
9
|
+
const jwt_data = JSON.parse(atob(jwt_token.split('.')[1]))
|
|
10
|
+
return jwt_data?.exp
|
|
11
|
+
}
|
|
12
|
+
export { jwt_token_exp_ as _jwt_token_exp, jwt_token_exp_ as _exp__jwt_token, }
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { throw_bad_credentials } from '@ctx-core/error'
|
|
2
|
-
import type { nullish } from '@ctx-core/function'
|
|
3
|
-
import type { jwt_error_ctx_I } from './jwt_error_ctx_I.js'
|
|
4
2
|
import { jwt_token_exp_ } from './jwt_token_exp_.js'
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @param {string|nullish}jwt_token
|
|
5
|
+
*/
|
|
6
|
+
export function validate_current_jwt(jwt_token) {
|
|
6
7
|
const jwt_token_exp = jwt_token_exp_(jwt_token)
|
|
8
|
+
if (jwt_token_exp === null) return
|
|
7
9
|
const jwt_token_exp_millis = jwt_token_exp * 1000
|
|
8
10
|
if (Date.now() > jwt_token_exp_millis) {
|
|
9
11
|
throw_bad_credentials({
|
|
10
12
|
jwt_token,
|
|
11
13
|
error_message: 'Session Expired'
|
|
12
|
-
}
|
|
14
|
+
})
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
|
-
export {
|
|
16
|
-
validate_current_jwt as validate__current__jwt
|
|
17
|
-
}
|
|
17
|
+
export { validate_current_jwt as validate__current__jwt }
|
package/.swcrc
DELETED
package/lib/JwtToken.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { error_ctx_I } from '@ctx-core/error';
|
|
2
|
-
import type { maybe, nullish } from '@ctx-core/function';
|
|
3
|
-
export interface Token {
|
|
4
|
-
access_token: string;
|
|
5
|
-
token_type: string;
|
|
6
|
-
id_token?: string;
|
|
7
|
-
email?: string;
|
|
8
|
-
error?: maybe<error_ctx_I, nullish>;
|
|
9
|
-
}
|
package/lib/JwtToken.js
DELETED
package/lib/JwtToken.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/JwtToken.ts"],"sourcesContent":["import type { error_ctx_I } from '@ctx-core/error'\nimport type { maybe, nullish } from '@ctx-core/function'\nexport interface Token {\n\taccess_token: string\n\ttoken_type: string\n\tid_token?:string\n\temail?:string\n\terror?:maybe<error_ctx_I, nullish>\n}\n"],"names":[],"mappings":"AAAA,MAAM"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { nullish } from '@ctx-core/function';
|
|
2
|
-
export declare function header_authorization_jwt_token_(authorization: string | nullish): string | undefined;
|
|
3
|
-
export { header_authorization_jwt_token_ as _header_authorization_jwt_token, header_authorization_jwt_token_ as _jwt_token__authorization__header, };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export function header_authorization_jwt_token_(authorization) {
|
|
2
|
-
const authorization_a = authorization === null || authorization === void 0 ? void 0 : authorization.split(/^Bearer */);
|
|
3
|
-
return authorization_a ? authorization_a[1] : undefined;
|
|
4
|
-
}
|
|
5
|
-
export { header_authorization_jwt_token_ as _header_authorization_jwt_token, header_authorization_jwt_token_ as _jwt_token__authorization__header, };
|
|
6
|
-
|
|
7
|
-
//# sourceMappingURL=header_authorization_jwt_token_.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/header_authorization_jwt_token_.ts"],"sourcesContent":["import type { nullish } from '@ctx-core/function'\nexport function header_authorization_jwt_token_(authorization:string|nullish):string|undefined {\n\tconst authorization_a = authorization?.split(/^Bearer */)\n\treturn authorization_a ? authorization_a[1] : undefined\n}\nexport {\n\theader_authorization_jwt_token_ as _header_authorization_jwt_token,\n\theader_authorization_jwt_token_ as _jwt_token__authorization__header,\n}\n"],"names":["header_authorization_jwt_token_","authorization","authorization_a","split","undefined","_header_authorization_jwt_token","_jwt_token__authorization__header"],"mappings":"AACA,MAAM,UAAUA,+BAA+B,CAACC,aAA4B,EAAmB,CAAC;IAC/F,KAAK,CAACC,eAAe,GAAGD,aAAa,aAAbA,aAAa,KAAbA,IAAI,CAAJA,CAAoB,GAApBA,IAAI,CAAJA,CAAoB,GAApBA,aAAa,CAAEE,KAAK;IAC5C,MAAM,CAACD,eAAe,GAAGA,eAAe,CAAC,CAAC,IAAIE,SAAS;AACxD,CAAC;AACD,MAAM,GACLJ,+BAA+B,IAAIK,+BAA+B,EAClEL,+BAA+B,IAAIM,iCAAiC"}
|
package/lib/index.d.ts
DELETED
package/lib/index.js
DELETED
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './header_authorization_jwt_token_.js'\nexport * from './jwt_error_ctx_I.js'\nexport * from './jwt_token_exp_.js'\nexport * from './JwtToken.js'\nexport * from './validate_current_jwt.js'\n"],"names":[],"mappings":"cAAc,CAAsC;cACtC,CAAsB;cACtB,CAAqB;cACrB,CAAe;cACf,CAA2B"}
|
package/lib/jwt_error_ctx_I.d.ts
DELETED
package/lib/jwt_error_ctx_I.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/jwt_error_ctx_I.ts"],"sourcesContent":["import type { error_ctx_I } from '@ctx-core/error'\nexport interface jwt_error_ctx_I extends error_ctx_I {\n\tjwt_token:string\n}\n"],"names":[],"mappings":"AAAA,MAAM"}
|
package/lib/jwt_token_exp_.d.ts
DELETED
package/lib/jwt_token_exp_.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { atob_ } from '@ctx-core/atob';
|
|
2
|
-
export function jwt_token_exp_(jwt_token) {
|
|
3
|
-
const atob = atob_();
|
|
4
|
-
const jwt_data = jwt_token && JSON.parse(atob(jwt_token.split('.')[1]));
|
|
5
|
-
return jwt_data === null || jwt_data === void 0 ? void 0 : jwt_data.exp;
|
|
6
|
-
}
|
|
7
|
-
export { jwt_token_exp_ as _jwt_token_exp, jwt_token_exp_ as _exp__jwt_token, };
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=jwt_token_exp_.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/jwt_token_exp_.ts"],"sourcesContent":["import { atob_ } from '@ctx-core/atob'\nimport type { nullish } from '@ctx-core/function'\nexport function jwt_token_exp_(jwt_token:string|nullish):number {\n\tconst atob = atob_()\n\tconst jwt_data = jwt_token && JSON.parse(atob(jwt_token.split('.')[1]))\n\treturn jwt_data?.exp\n}\nexport {\n\tjwt_token_exp_ as _jwt_token_exp,\n\tjwt_token_exp_ as _exp__jwt_token,\n}\n"],"names":["atob_","jwt_token_exp_","jwt_token","atob","jwt_data","JSON","parse","split","exp","_jwt_token_exp","_exp__jwt_token"],"mappings":"AAAA,MAAM,GAAGA,KAAK,QAAQ,CAAgB;AAEtC,MAAM,UAAUC,cAAc,CAACC,SAAwB,EAAS,CAAC;IAChE,KAAK,CAACC,IAAI,GAAGH,KAAK;IAClB,KAAK,CAACI,QAAQ,GAAGF,SAAS,IAAIG,IAAI,CAACC,KAAK,CAACH,IAAI,CAACD,SAAS,CAACK,KAAK,CAAC,CAAG,IAAE,CAAC;IACpE,MAAM,CAACH,QAAQ,aAARA,QAAQ,KAARA,IAAI,CAAJA,CAAa,GAAbA,IAAI,CAAJA,CAAa,GAAbA,QAAQ,CAAEI,GAAG;AACrB,CAAC;AACD,MAAM,GACLP,cAAc,IAAIQ,cAAc,EAChCR,cAAc,IAAIS,eAAe"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { throw_bad_credentials } from '@ctx-core/error';
|
|
2
|
-
import { jwt_token_exp_ } from './jwt_token_exp_.js';
|
|
3
|
-
export function validate_current_jwt(jwt_token) {
|
|
4
|
-
const jwt_token_exp = jwt_token_exp_(jwt_token);
|
|
5
|
-
const jwt_token_exp_millis = jwt_token_exp * 1000;
|
|
6
|
-
if (Date.now() > jwt_token_exp_millis) {
|
|
7
|
-
throw_bad_credentials({
|
|
8
|
-
jwt_token,
|
|
9
|
-
error_message: 'Session Expired'
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export { validate_current_jwt as validate__current__jwt };
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=validate_current_jwt.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/validate_current_jwt.ts"],"sourcesContent":["import { throw_bad_credentials } from '@ctx-core/error'\nimport type { nullish } from '@ctx-core/function'\nimport type { jwt_error_ctx_I } from './jwt_error_ctx_I.js'\nimport { jwt_token_exp_ } from './jwt_token_exp_.js'\nexport function validate_current_jwt(jwt_token:string|nullish):void {\n\tconst jwt_token_exp = jwt_token_exp_(jwt_token)\n\tconst jwt_token_exp_millis = jwt_token_exp * 1000\n\tif (Date.now() > jwt_token_exp_millis) {\n\t\tthrow_bad_credentials({\n\t\t\tjwt_token,\n\t\t\terror_message: 'Session Expired'\n\t\t} as jwt_error_ctx_I)\n\t}\n}\nexport {\n\tvalidate_current_jwt as validate__current__jwt\n}\n"],"names":["throw_bad_credentials","jwt_token_exp_","validate_current_jwt","jwt_token","jwt_token_exp","jwt_token_exp_millis","Date","now","error_message","validate__current__jwt"],"mappings":"AAAA,MAAM,GAAGA,qBAAqB,QAAQ,CAAiB;AAGvD,MAAM,GAAGC,cAAc,QAAQ,CAAqB;AACpD,MAAM,UAAUC,oBAAoB,CAACC,SAAwB,EAAO,CAAC;IACpE,KAAK,CAACC,aAAa,GAAGH,cAAc,CAACE,SAAS;IAC9C,KAAK,CAACE,oBAAoB,GAAGD,aAAa,GAAG,IAAI;IACjD,EAAE,EAAEE,IAAI,CAACC,GAAG,KAAKF,oBAAoB,EAAE,CAAC;QACvCL,qBAAqB,CAAC,CAAC;YACtBG,SAAS;YACTK,aAAa,EAAE,CAAiB;QACjC,CAAC;IACF,CAAC;AACF,CAAC;AACD,MAAM,GACLN,oBAAoB,IAAIO,sBAAsB"}
|
package/src/JwtToken.ts
DELETED
package/src/jwt_token_exp_.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { atob_ } from '@ctx-core/atob'
|
|
2
|
-
import type { nullish } from '@ctx-core/function'
|
|
3
|
-
export function jwt_token_exp_(jwt_token:string|nullish):number {
|
|
4
|
-
const atob = atob_()
|
|
5
|
-
const jwt_data = jwt_token && JSON.parse(atob(jwt_token.split('.')[1]))
|
|
6
|
-
return jwt_data?.exp
|
|
7
|
-
}
|
|
8
|
-
export {
|
|
9
|
-
jwt_token_exp_ as _jwt_token_exp,
|
|
10
|
-
jwt_token_exp_ as _exp__jwt_token,
|
|
11
|
-
}
|