@sourceregistry/node-jwt 1.0.0 → 1.2.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.
@@ -0,0 +1,115 @@
1
+ import { KeyLike } from 'crypto';
2
+ import { JWT as JSONWebToken, JWTPayload, SupportedAlgorithm, JWTHeader } from './index.js';
3
+ export { type SupportedAlgorithm, SupportedAlgorithms, SignatureAlgorithm, type JWTHeader, type JWTPayload } from './index.js';
4
+ /**
5
+ * Decode a JWT string into its parts (without verification)
6
+ */
7
+ export declare const decode: (token: string) => Promise<JSONWebToken>;
8
+ /**
9
+ * Sign a JWT
10
+ */
11
+ export declare const sign: (payload: JWTPayload, secret: KeyLike, options?: {
12
+ alg?: SupportedAlgorithm;
13
+ kid?: string;
14
+ typ?: string;
15
+ }) => Promise<string>;
16
+ /**
17
+ * Verify and validate a JWT
18
+ *
19
+ * @throws { { reason: string; code: string } } if invalid
20
+ */
21
+ export declare const verify: (token: string, secret: KeyLike, options?: {
22
+ algorithms?: SupportedAlgorithm[];
23
+ issuer?: string;
24
+ subject?: string;
25
+ audience?: string | string[];
26
+ jwtId?: string;
27
+ ignoreExpiration?: boolean;
28
+ clockSkew?: number;
29
+ maxTokenAge?: number;
30
+ }) => Promise<{
31
+ header: JWTHeader;
32
+ payload: JWTPayload;
33
+ signature: string;
34
+ }>;
35
+ export type JWT = JSONWebToken;
36
+ export declare const JWT: {
37
+ sign: (payload: JWTPayload, secret: KeyLike, options?: {
38
+ alg?: SupportedAlgorithm;
39
+ kid?: string;
40
+ typ?: string;
41
+ }) => Promise<string>;
42
+ verify: (token: string, secret: KeyLike, options?: {
43
+ algorithms?: SupportedAlgorithm[];
44
+ issuer?: string;
45
+ subject?: string;
46
+ audience?: string | string[];
47
+ jwtId?: string;
48
+ ignoreExpiration?: boolean;
49
+ clockSkew?: number;
50
+ maxTokenAge?: number;
51
+ }) => Promise<{
52
+ header: JWTHeader;
53
+ payload: JWTPayload;
54
+ signature: string;
55
+ }>;
56
+ decode: (token: string) => Promise<JSONWebToken>;
57
+ algorithms: {
58
+ readonly HS256: {
59
+ readonly sign: (data: import('crypto').BinaryLike, secret: KeyLike) => string;
60
+ readonly verify: (data: import('crypto').BinaryLike, secret: KeyLike, signature: string) => boolean;
61
+ };
62
+ readonly HS384: {
63
+ readonly sign: (data: import('crypto').BinaryLike, secret: KeyLike) => string;
64
+ readonly verify: (data: import('crypto').BinaryLike, secret: KeyLike, signature: string) => boolean;
65
+ };
66
+ readonly HS512: {
67
+ readonly sign: (data: import('crypto').BinaryLike, secret: KeyLike) => string;
68
+ readonly verify: (data: import('crypto').BinaryLike, secret: KeyLike, signature: string) => boolean;
69
+ };
70
+ readonly RS256: {
71
+ readonly sign: (data: import('crypto').BinaryLike, secret: KeyLike) => string;
72
+ readonly verify: (data: import('crypto').BinaryLike, secret: KeyLike, signature: string) => boolean;
73
+ };
74
+ readonly RS384: {
75
+ readonly sign: (data: import('crypto').BinaryLike, secret: KeyLike) => string;
76
+ readonly verify: (data: import('crypto').BinaryLike, secret: KeyLike, signature: string) => boolean;
77
+ };
78
+ readonly RS512: {
79
+ readonly sign: (data: import('crypto').BinaryLike, secret: KeyLike) => string;
80
+ readonly verify: (data: import('crypto').BinaryLike, secret: KeyLike, signature: string) => boolean;
81
+ };
82
+ readonly ES256: {
83
+ readonly sign: (data: import('crypto').BinaryLike, secret: KeyLike) => string;
84
+ readonly verify: (data: import('crypto').BinaryLike, secret: KeyLike, signature: string) => boolean;
85
+ };
86
+ readonly ES384: {
87
+ readonly sign: (data: import('crypto').BinaryLike, secret: KeyLike) => string;
88
+ readonly verify: (data: import('crypto').BinaryLike, secret: KeyLike, signature: string) => boolean;
89
+ };
90
+ readonly ES512: {
91
+ readonly sign: (data: import('crypto').BinaryLike, secret: KeyLike) => string;
92
+ readonly verify: (data: import('crypto').BinaryLike, secret: KeyLike, signature: string) => boolean;
93
+ };
94
+ readonly ES256K: {
95
+ readonly sign: (data: import('crypto').BinaryLike, secret: KeyLike) => string;
96
+ readonly verify: (data: import('crypto').BinaryLike, secret: KeyLike, signature: string) => boolean;
97
+ };
98
+ readonly PS256: {
99
+ readonly sign: (data: import('crypto').BinaryLike, secret: KeyLike) => string;
100
+ readonly verify: (data: import('crypto').BinaryLike, secret: KeyLike, signature: string) => boolean;
101
+ };
102
+ readonly PS384: {
103
+ readonly sign: (data: import('crypto').BinaryLike, secret: KeyLike) => string;
104
+ readonly verify: (data: import('crypto').BinaryLike, secret: KeyLike, signature: string) => boolean;
105
+ };
106
+ readonly PS512: {
107
+ readonly sign: (data: import('crypto').BinaryLike, secret: KeyLike) => string;
108
+ readonly verify: (data: import('crypto').BinaryLike, secret: KeyLike, signature: string) => boolean;
109
+ };
110
+ readonly EdDSA: {
111
+ readonly sign: (data: import('crypto').BinaryLike, secret: KeyLike) => string;
112
+ readonly verify: (data: import('crypto').BinaryLike, secret: KeyLike, signature: string) => boolean;
113
+ };
114
+ };
115
+ };
@@ -0,0 +1,23 @@
1
+ import { SignatureAlgorithm as a, decode as d, sign as c, verify as l } from "./index.es.js";
2
+ import { SupportedAlgorithms as y } from "./index.es.js";
3
+ const m = (e) => Promise.resolve().then(() => d(e)), g = (e, r, o = {}) => Promise.resolve().then(() => c(e, r, o)), h = (e, r, o = {}) => Promise.resolve().then(() => {
4
+ const s = l(e, r, o);
5
+ if (!s.valid)
6
+ throw s.error;
7
+ const { header: t, payload: i, signature: n } = s;
8
+ return { header: t, payload: i, signature: n };
9
+ }), f = {
10
+ sign: g,
11
+ verify: h,
12
+ decode: m,
13
+ algorithms: a
14
+ };
15
+ export {
16
+ f as JWT,
17
+ a as SignatureAlgorithm,
18
+ y as SupportedAlgorithms,
19
+ m as decode,
20
+ g as sign,
21
+ h as verify
22
+ };
23
+ //# sourceMappingURL=promises.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promises.es.js","sources":["../src/promises.ts"],"sourcesContent":["import type { KeyLike } from 'crypto';\nimport {\n type JWT as JSONWebToken,\n decode as decodeSync,\n sign as signSync,\n verify as verifySync,\n JWTPayload,\n type SupportedAlgorithm,\n JWTHeader,\n SignatureAlgorithm\n} from './index.js';\n\nexport { type SupportedAlgorithm, SupportedAlgorithms, SignatureAlgorithm, type JWTHeader, type JWTPayload } from './index.js';\n\n/**\n * Decode a JWT string into its parts (without verification)\n */\nexport const decode = (token: string): Promise<JSONWebToken> =>\n Promise.resolve().then(() => decodeSync(token));\n\n/**\n * Sign a JWT\n */\nexport const sign = (\n payload: JWTPayload,\n secret: KeyLike,\n options: {\n alg?: SupportedAlgorithm;\n kid?: string;\n typ?: string;\n } = {}\n): Promise<string> =>\n Promise.resolve().then(() => signSync(payload, secret, options));\n\n/**\n * Verify and validate a JWT\n *\n * @throws { { reason: string; code: string } } if invalid\n */\nexport const verify = (\n token: string,\n secret: KeyLike,\n options: {\n algorithms?: SupportedAlgorithm[]; // Whitelist of allowed algorithms\n issuer?: string;\n subject?: string;\n audience?: string | string[];\n jwtId?: string;\n ignoreExpiration?: boolean;\n clockSkew?: number; // in seconds, default 0\n maxTokenAge?: number; // Maximum age in seconds\n } = {}\n): Promise<{ header: JWTHeader; payload: JWTPayload; signature: string }> =>\n Promise.resolve().then(() => {\n const result = verifySync(token, secret, options);\n if (!result.valid) {\n throw result.error;\n }\n const { header, payload, signature } = result;\n return { header, payload, signature };\n });\n\nexport type JWT = JSONWebToken;\n\nexport const JWT = {\n sign,\n verify,\n decode,\n algorithms: SignatureAlgorithm\n};\n"],"names":["decode","token","decodeSync","sign","payload","secret","options","signSync","verify","result","verifySync","header","signature","JWT","SignatureAlgorithm"],"mappings":";;AAiBO,MAAMA,IAAS,CAACC,MACnB,QAAQ,QAAA,EAAU,KAAK,MAAMC,EAAWD,CAAK,CAAC,GAKrCE,IAAO,CAChBC,GACAC,GACAC,IAII,CAAA,MAEJ,QAAQ,QAAA,EAAU,KAAK,MAAMC,EAASH,GAASC,GAAQC,CAAO,CAAC,GAOtDE,IAAS,CAClBP,GACAI,GACAC,IASI,CAAA,MAEJ,QAAQ,UAAU,KAAK,MAAM;AACzB,QAAMG,IAASC,EAAWT,GAAOI,GAAQC,CAAO;AAChD,MAAI,CAACG,EAAO;AACR,UAAMA,EAAO;AAEjB,QAAM,EAAE,QAAAE,GAAQ,SAAAP,GAAS,WAAAQ,EAAA,IAAcH;AACvC,SAAO,EAAE,QAAAE,GAAQ,SAAAP,GAAS,WAAAQ,EAAA;AAC9B,CAAC,GAIQC,IAAM;AAAA,EACf,MAAAV;AAAA,EACA,QAAAK;AAAA,EACA,QAAAR;AAAA,EACA,YAAYc;AAChB;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sourceregistry/node-jwt",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "A lightweight, zero-dependency TypeScript library for creating, verifying and decoding JSON Web Tokens (JWT).",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.es.js",
@@ -10,6 +10,11 @@
10
10
  "types": "./dist/index.d.ts",
11
11
  "import": "./dist/index.es.js",
12
12
  "require": "./dist/index.cjs.js"
13
+ },
14
+ "./promises": {
15
+ "types": "./dist/promises.d.ts",
16
+ "import": "./dist/promises.es.js",
17
+ "require": "./dist/promises.cjs.js"
13
18
  }
14
19
  },
15
20
  "files": [
@@ -20,7 +25,8 @@
20
25
  "test": "vitest",
21
26
  "test:ui": "vitest --ui",
22
27
  "test:coverage": "vitest run --coverage",
23
- "lint": "tsc --noEmit"
28
+ "lint": "tsc --noEmit",
29
+ "docs:build": "typedoc src/index.ts --out docs --name \"node-jwt\" --theme default --excludePrivate --excludeProtected"
24
30
  },
25
31
  "repository": {
26
32
  "type": "git",
@@ -48,18 +54,19 @@
48
54
  "node": ">=16.0.0"
49
55
  },
50
56
  "devDependencies": {
57
+ "@semantic-release/changelog": "^6.0.3",
58
+ "@semantic-release/commit-analyzer": "^13.0.1",
59
+ "@semantic-release/git": "^10.0.1",
60
+ "@semantic-release/npm": "^12.0.2",
61
+ "@semantic-release/release-notes-generator": "^14.0.3",
51
62
  "@types/node": "^24.3.0",
52
63
  "@vitest/coverage-v8": "^3.2.4",
53
64
  "@vitest/ui": "^3.2.4",
65
+ "typedoc": "^0.28.14",
54
66
  "typescript": "^5.9.3",
55
- "vite": "^7.1.3",
67
+ "vite": "^7.1.12",
56
68
  "vite-plugin-dts": "^4.5.4",
57
- "vitest": "^3.2.4",
58
- "@semantic-release/commit-analyzer": "^13.0.1",
59
- "@semantic-release/release-notes-generator": "^14.0.3",
60
- "@semantic-release/changelog": "^6.0.3",
61
- "@semantic-release/npm": "^12.0.2",
62
- "@semantic-release/git": "^10.0.1"
69
+ "vitest": "^3.2.4"
63
70
  },
64
71
  "release": {
65
72
  "branches": [