@dws-std/jwt 1.0.0 → 1.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/dist/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- export { JWT_ERROR_KEYS } from './constant/jwt-error-keys';
2
- export { signJWT, verifyJWT, type VerifyOptions } from './jwt';
1
+ export { JWT_ERROR_KEYS, signJWT, verifyJWT, type VerifyOptions } from './jwt';
package/dist/index.js CHANGED
@@ -1,16 +1,15 @@
1
1
  // @bun
2
- // src/constant/jwt-error-keys.ts
3
- var JWT_ERROR_KEYS = {
4
- JWT_SECRET_TOO_WEAK: "jwt.secret_too_weak",
5
- JWT_EXPIRATION_PASSED: "jwt.expiration_passed",
6
- JWT_SIGN_ERROR: "jwt.sign_error",
7
- JWT_EXPIRED: "jwt.token_expired",
8
- JWT_UNAUTHORIZED: "jwt.unauthorized"
9
- };
10
2
  // src/jwt.ts
11
3
  import { parseHumanTimeToSeconds } from "@dws-std/common";
12
4
  import { Exception } from "@dws-std/error";
13
5
  import { SignJWT, errors, jwtVerify } from "jose";
6
+ var JWT_ERROR_KEYS = {
7
+ JWT_SECRET_TOO_WEAK: "jwt.secret-too-weak",
8
+ JWT_EXPIRATION_PASSED: "jwt.expiration-passed",
9
+ JWT_SIGN_ERROR: "jwt.sign-error",
10
+ JWT_EXPIRED: "jwt.token-expired",
11
+ JWT_UNAUTHORIZED: "jwt.unauthorized"
12
+ };
14
13
  var _textEncoder = new TextEncoder;
15
14
  var signJWT = (secret, payload, expiration = 60 * 15) => {
16
15
  if (secret.length < 32)
package/dist/jwt.d.ts CHANGED
@@ -1,4 +1,11 @@
1
1
  import { type JWTPayload, type JWTVerifyResult } from 'jose';
2
+ export declare const JWT_ERROR_KEYS: {
3
+ readonly JWT_SECRET_TOO_WEAK: "jwt.secret-too-weak";
4
+ readonly JWT_EXPIRATION_PASSED: "jwt.expiration-passed";
5
+ readonly JWT_SIGN_ERROR: "jwt.sign-error";
6
+ readonly JWT_EXPIRED: "jwt.token-expired";
7
+ readonly JWT_UNAUTHORIZED: "jwt.unauthorized";
8
+ };
2
9
  export interface VerifyOptions {
3
10
  issuer?: string;
4
11
  audience?: string | string[];
@@ -10,7 +17,7 @@ export interface VerifyOptions {
10
17
  * @param payload - The JWT payload claims
11
18
  * @param expiration - Token expiration as seconds offset, Date, or human-readable string (default: 15 minutes)
12
19
  *
13
- * @throws ({@link Exception}) If secret is too short, expiration is in the past, or signing fails
20
+ * @throws ({@link Exception}) - If secret is too short, expiration is in the past, or signing fails
14
21
  *
15
22
  * @returns A Promise resolving to the signed JWT string
16
23
  */
@@ -22,7 +29,7 @@ export declare const signJWT: (secret: string, payload: JWTPayload, expiration?:
22
29
  * @param secret - The secret key used for HS256 verification
23
30
  * @param options - Optional verification options for issuer/audience validation
24
31
  *
25
- * @throws ({@link Exception}) 401 if token is expired, invalid signature, malformed, or claim validation fails
32
+ * @throws ({@link Exception}) - 401 if token is expired, invalid signature, malformed, or claim validation fails
26
33
  *
27
34
  * @returns The verification result with payload and protected header
28
35
  */
package/package.json CHANGED
@@ -1,55 +1,59 @@
1
1
  {
2
- "name": "@dws-std/jwt",
3
- "version": "1.0.0",
4
- "description": "JWT utilities for Dominus Web Services (DWS) projects.",
5
- "keywords": [
6
- "bun",
7
- "dws",
8
- "jwt",
9
- "types",
10
- "utilities"
11
- ],
12
- "license": "MIT",
13
- "author": "Dominus Web Services (DWS)",
14
- "repository": {
15
- "type": "git",
16
- "url": "https://github.com/Dominus-Web-Service/std",
17
- "directory": "packages/common"
18
- },
19
- "files": [
20
- "dist"
21
- ],
22
- "type": "module",
23
- "exports": {
24
- ".": {
25
- "types": "./dist/index.d.ts",
26
- "default": "./dist/index.js"
27
- }
28
- },
29
- "scripts": {
30
- "build": "bun builder.ts",
31
- "docs": "bunx typedoc --tsconfig tsconfig.build.json",
32
- "fmt:check": "oxfmt --check",
33
- "fmt": "oxfmt",
34
- "lint:fix": "oxlint --type-aware --type-check --fix ./src",
35
- "lint:github": "oxlint --type-aware --type-check --format=github ./src",
36
- "lint": "oxlint --type-aware --type-check ./src",
37
- "test": "bun test --pass-with-no-tests --coverage"
38
- },
39
- "dependencies": {
40
- "@dws-std/common": "^1.0.0",
41
- "@dws-std/error": "^2.1.0",
42
- "jose": "^6.2.2"
43
- },
44
- "devDependencies": {
45
- "@types/bun": "^1.3.11",
46
- "oxfmt": "0.41.0",
47
- "oxlint": "1.56.0",
48
- "oxlint-tsgolint": "0.17.0",
49
- "typescript": "^5.9.3"
50
- },
51
- "peerDependencies": {
52
- "@dws-std/common": "^1.0.0",
53
- "@dws-std/error": "^2.1.0"
54
- }
2
+ "name": "@dws-std/jwt",
3
+ "version": "1.1.0",
4
+ "description": "JWT utilities and helpers for secure token management.",
5
+ "keywords": [
6
+ "bun",
7
+ "dws",
8
+ "helpers",
9
+ "jwt",
10
+ "open-source",
11
+ "token",
12
+ "types",
13
+ "typescript",
14
+ "utilities"
15
+ ],
16
+ "license": "MIT",
17
+ "author": "Dominus Web Services (DWS)",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/Dominus-Web-Service/std",
21
+ "directory": "packages/common"
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "type": "module",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "default": "./dist/index.js"
31
+ }
32
+ },
33
+ "scripts": {
34
+ "build": "bun builder.ts",
35
+ "docs": "bunx typedoc --tsconfig tsconfig.build.json",
36
+ "fmt:check": "oxfmt --check",
37
+ "fmt": "oxfmt",
38
+ "lint:fix": "oxlint --type-aware --type-check --fix ./src",
39
+ "lint:github": "oxlint --type-aware --type-check --format=github ./src",
40
+ "lint": "oxlint --type-aware --type-check ./src",
41
+ "test": "bun test --pass-with-no-tests --coverage"
42
+ },
43
+ "dependencies": {
44
+ "@dws-std/common": "^1.1.0",
45
+ "@dws-std/error": "^2.2.0",
46
+ "jose": "^6.2.2"
47
+ },
48
+ "devDependencies": {
49
+ "@types/bun": "^1.3.11",
50
+ "oxfmt": "0.44.0",
51
+ "oxlint": "1.59.0",
52
+ "oxlint-tsgolint": "0.20.0",
53
+ "typescript": "^6.0.2"
54
+ },
55
+ "peerDependencies": {
56
+ "@dws-std/common": "^1.1.0",
57
+ "@dws-std/error": "^2.2.0"
58
+ }
55
59
  }
@@ -1,7 +0,0 @@
1
- export declare const JWT_ERROR_KEYS: {
2
- readonly JWT_SECRET_TOO_WEAK: "jwt.secret_too_weak";
3
- readonly JWT_EXPIRATION_PASSED: "jwt.expiration_passed";
4
- readonly JWT_SIGN_ERROR: "jwt.sign_error";
5
- readonly JWT_EXPIRED: "jwt.token_expired";
6
- readonly JWT_UNAUTHORIZED: "jwt.unauthorized";
7
- };