@sourceregistry/node-jwt 1.5.6 → 1.5.7

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,150 @@
1
+ import { BinaryLike, KeyLike, KeyObject } from 'crypto';
2
+ export declare const base64Url: {
3
+ encode: (input: string | Buffer) => string;
4
+ decode: (input: string) => string;
5
+ };
6
+ export interface JWTPayload {
7
+ /**
8
+ * Issuer
9
+ */
10
+ iss?: string;
11
+ /**
12
+ * Subject
13
+ */
14
+ sub?: string;
15
+ /**
16
+ * Audience
17
+ */
18
+ aud?: string | string[];
19
+ /**
20
+ * Expiration Time (as UNIX timestamp)
21
+ */
22
+ exp?: number;
23
+ /**
24
+ * Not Before (as UNIX timestamp)
25
+ */
26
+ nbf?: number;
27
+ /**
28
+ * Issued At (as UNIX timestamp)
29
+ */
30
+ iat?: number;
31
+ /**
32
+ * JWT ID
33
+ */
34
+ jti?: string;
35
+ /**
36
+ * Session ID
37
+ */
38
+ sid?: string;
39
+ /**
40
+ * Custom claims
41
+ */
42
+ [key: string]: unknown;
43
+ }
44
+ export interface JWTHeader {
45
+ alg: string;
46
+ typ?: string;
47
+ kid?: string;
48
+ }
49
+ export interface JWT {
50
+ header: JWTHeader;
51
+ payload: JWTPayload;
52
+ signature: string;
53
+ }
54
+ type SignatureAlgorithmImplementation = {
55
+ sign: (data: BinaryLike, secret: KeyLike) => string;
56
+ verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
57
+ };
58
+ type SignatureAlgorithmsMap = {
59
+ HS256: SignatureAlgorithmImplementation;
60
+ HS384: SignatureAlgorithmImplementation;
61
+ HS512: SignatureAlgorithmImplementation;
62
+ RS256: SignatureAlgorithmImplementation;
63
+ RS384: SignatureAlgorithmImplementation;
64
+ RS512: SignatureAlgorithmImplementation;
65
+ ES256: SignatureAlgorithmImplementation;
66
+ ES384: SignatureAlgorithmImplementation;
67
+ ES512: SignatureAlgorithmImplementation;
68
+ ES256K: SignatureAlgorithmImplementation;
69
+ PS256: SignatureAlgorithmImplementation;
70
+ PS384: SignatureAlgorithmImplementation;
71
+ PS512: SignatureAlgorithmImplementation;
72
+ EdDSA: SignatureAlgorithmImplementation;
73
+ };
74
+ export declare const SignatureAlgorithm: SignatureAlgorithmsMap;
75
+ export type SupportedAlgorithm = keyof typeof SignatureAlgorithm;
76
+ export declare const SupportedAlgorithms: Array<SupportedAlgorithm>;
77
+ /**
78
+ * Autodetection of algorithm for KeyObjects
79
+ * @param key
80
+ * @constructor
81
+ */
82
+ export declare function AutodetectAlgorithm(key: KeyObject): SupportedAlgorithm;
83
+ /**
84
+ * Decode a JWT string into its parts (without verification)
85
+ * @param token
86
+ */
87
+ export declare const decode: (token: string) => JWT;
88
+ export type SignOptions = {
89
+ alg?: SupportedAlgorithm;
90
+ kid?: string;
91
+ typ?: string;
92
+ /**
93
+ * default 'der'
94
+ */
95
+ signatureFormat?: 'der' | 'jose';
96
+ };
97
+ /**
98
+ * Sign a JWT
99
+ * @param payload
100
+ * @param secret
101
+ * @param options
102
+ */
103
+ export declare const sign: (payload: JWTPayload, secret: KeyLike, options?: SignOptions) => string;
104
+ export type VerifyOptions = {
105
+ algorithms?: SupportedAlgorithm[];
106
+ issuer?: string;
107
+ subject?: string;
108
+ audience?: string | string[];
109
+ jwtId?: string;
110
+ ignoreExpiration?: boolean;
111
+ clockSkew?: number;
112
+ maxTokenAge?: number;
113
+ signatureFormat?: 'der' | 'jose';
114
+ };
115
+ /**
116
+ * Verify and validate a JWT
117
+ * @param token
118
+ * @param secret
119
+ * @param options
120
+ */
121
+ export declare const verify: (token: string, secret: KeyLike, options?: VerifyOptions) => {
122
+ valid: true;
123
+ header: JWTHeader;
124
+ payload: JWTPayload;
125
+ signature: string;
126
+ } | {
127
+ valid: false;
128
+ error: {
129
+ reason: string;
130
+ code: string;
131
+ };
132
+ };
133
+ export declare const JWT: {
134
+ readonly sign: (payload: JWTPayload, secret: KeyLike, options?: SignOptions) => string;
135
+ readonly verify: (token: string, secret: KeyLike, options?: VerifyOptions) => {
136
+ valid: true;
137
+ header: JWTHeader;
138
+ payload: JWTPayload;
139
+ signature: string;
140
+ } | {
141
+ valid: false;
142
+ error: {
143
+ reason: string;
144
+ code: string;
145
+ };
146
+ };
147
+ readonly decode: (token: string) => JWT;
148
+ readonly algorithms: SignatureAlgorithmsMap;
149
+ };
150
+ export {};
@@ -0,0 +1,89 @@
1
+ import { JWT as JSONWebToken, sign as signSync, verify as verifySync, JWTPayload, JWTHeader } from '../';
2
+ export { type SupportedAlgorithm, SupportedAlgorithms, SignatureAlgorithm, type JWTHeader, type JWTPayload } from '../index';
3
+ /**
4
+ * Decode a JWT string into its parts (without verification)
5
+ * @param token
6
+ */
7
+ export declare const decode: (token: string) => Promise<JSONWebToken>;
8
+ /**
9
+ * Sign a JWT
10
+ * @see(synchronous parameters)
11
+ */
12
+ export declare const sign: (...args: Parameters<typeof signSync>) => Promise<string>;
13
+ /**
14
+ * Verify and validate a JWT
15
+ * @throws { { reason: string; code: string } } if invalid
16
+ */
17
+ export declare const verify: (...args: Parameters<typeof verifySync>) => Promise<{
18
+ header: JWTHeader;
19
+ payload: JWTPayload;
20
+ signature: string;
21
+ }>;
22
+ export type JWT = JSONWebToken;
23
+ export declare const JWT: {
24
+ sign: (payload: JWTPayload, secret: import('node:crypto').KeyLike, options?: import('.').SignOptions | undefined) => Promise<string>;
25
+ verify: (token: string, secret: import('node:crypto').KeyLike, options?: import('.').VerifyOptions | undefined) => Promise<{
26
+ header: JWTHeader;
27
+ payload: JWTPayload;
28
+ signature: string;
29
+ }>;
30
+ decode: (token: string) => Promise<JSONWebToken>;
31
+ algorithms: {
32
+ HS256: {
33
+ sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
34
+ verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
35
+ };
36
+ HS384: {
37
+ sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
38
+ verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
39
+ };
40
+ HS512: {
41
+ sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
42
+ verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
43
+ };
44
+ RS256: {
45
+ sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
46
+ verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
47
+ };
48
+ RS384: {
49
+ sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
50
+ verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
51
+ };
52
+ RS512: {
53
+ sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
54
+ verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
55
+ };
56
+ ES256: {
57
+ sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
58
+ verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
59
+ };
60
+ ES384: {
61
+ sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
62
+ verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
63
+ };
64
+ ES512: {
65
+ sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
66
+ verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
67
+ };
68
+ ES256K: {
69
+ sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
70
+ verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
71
+ };
72
+ PS256: {
73
+ sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
74
+ verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
75
+ };
76
+ PS384: {
77
+ sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
78
+ verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
79
+ };
80
+ PS512: {
81
+ sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
82
+ verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
83
+ };
84
+ EdDSA: {
85
+ sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
86
+ verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
87
+ };
88
+ };
89
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-D70ysYoo.cjs");require("crypto");const r=e=>Promise.resolve().then(()=>o.decode(e)),i=(...e)=>Promise.resolve().then(()=>o.sign(...e)),s=(...e)=>Promise.resolve().then(()=>{const t=o.verify(...e);if(!t.valid)throw t.error;const{header:J,payload:p,signature:g}=t;return{header:J,payload:p,signature:g}}),b={sign:i,verify:s,decode:r,algorithms:o.SignatureAlgorithm},n=e=>Promise.resolve().then(()=>o.exportJWK(e)),m=e=>Promise.resolve().then(()=>o.importJWK(e)),c=e=>Promise.resolve().then(()=>o.toPublicJWK(e)),l=(e,t="sha256")=>Promise.resolve().then(()=>o.getJWKThumbprint(e,t)),W=(e,t)=>Promise.resolve().then(()=>o.JWKSToKeyObject(e,t)),K=e=>Promise.resolve().then(()=>o.normalizeJWKS(e)),h=e=>Promise.resolve().then(()=>o.computeX5T(e)),u=(...e)=>Promise.resolve().then(()=>o.fromWeb(...e)),a={export:n,import:m,toPublic:c,thumbprint:l,computeX5T:h},v={toKeyObject:W,normalize:K,fromWeb:u};exports.SignatureAlgorithm=o.SignatureAlgorithm;exports.SupportedAlgorithms=o.SupportedAlgorithms;exports.JWK=a;exports.JWKS=v;exports.JWKSToKeyObject=W;exports.JWT=b;exports.computeX5T=h;exports.decode=r;exports.exportJWK=n;exports.fromWeb=u;exports.getJWKThumbprint=l;exports.importJWK=m;exports.normalizeJWKS=K;exports.sign=i;exports.toPublicJWK=c;exports.verify=s;
2
+ //# sourceMappingURL=promises.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promises.cjs.js","sources":["../src/jwt/promises.ts","../src/jwks/promises.ts"],"sourcesContent":["import {\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 '../';\n\nexport {\n type SupportedAlgorithm, SupportedAlgorithms, SignatureAlgorithm, type JWTHeader, type JWTPayload\n} from '../index';\n\n/**\n * Decode a JWT string into its parts (without verification)\n * @param token\n */\nexport const decode = (token: string): Promise<JSONWebToken> =>\n Promise.resolve().then(() => decodeSync(token));\n\n/**\n * Sign a JWT\n * @see(synchronous parameters)\n */\nexport const sign = (...args: Parameters<typeof signSync>): Promise<string> =>\n Promise.resolve().then(() => signSync(...args));\n\n/**\n * Verify and validate a JWT\n * @throws { { reason: string; code: string } } if invalid\n */\nexport const verify = (...args: Parameters<typeof verifySync>): Promise<{\n header: JWTHeader;\n payload: JWTPayload;\n signature: string\n}> =>\n Promise.resolve().then(() => {\n const result = verifySync(...args);\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\n//namespace export\nexport const JWT = {\n sign,\n verify,\n decode,\n algorithms: SignatureAlgorithm\n};\n","import type {KeyObject} from 'crypto';\n\nimport {\n type JWK as JWKType,\n type JWKSResolver,\n type JWKS as JSONWebKeySet,\n exportJWK as exportJWKSYNC,\n importJWK as importJWKSYNC,\n toPublicJWK as toPublicJWKSYNC,\n getJWKThumbprint as getJWKThumbprintSYNC,\n JWKSToKeyObject as JWKSToKeyObjectSYNC,\n normalizeJWKS as normalizeJWKSSYNC,\n computeX5T as computeX5TSYNC,\n fromWeb as fromWebSYNC\n} from './';\n\n/**\n * Export a KeyObject to JWK\n * @param key\n */\nexport const exportJWK = (key: KeyObject): Promise<JWKType> =>\n Promise.resolve().then(() => exportJWKSYNC(key));\n\n/**\n * Import a JWK to KeyObject\n * @param jwk\n */\nexport const importJWK = (jwk: JWKType): Promise<KeyObject> =>\n Promise.resolve().then(() => importJWKSYNC(jwk));\n\n/**\n * Export public-only JWK\n * @param key\n */\nexport const toPublicJWK = (key: KeyObject): Promise<JWKType> =>\n Promise.resolve().then(() => toPublicJWKSYNC(key));\n\n/**\n * RFC 7638 JWK thumbprint\n * @param jwk\n * @param hashAlg\n */\nexport const getJWKThumbprint = (\n jwk: JWKType,\n hashAlg: 'sha256' = 'sha256'\n): Promise<string> =>\n Promise.resolve().then(() => getJWKThumbprintSYNC(jwk, hashAlg));\n\n/**\n * Resolve a KeyObject from a JWKS (kid-based)\n * @param jwks\n * @param kid\n * @constructor\n */\nexport const JWKSToKeyObject = (\n jwks: JSONWebKeySet,\n kid?: string\n): Promise<KeyObject> =>\n Promise.resolve().then(() => JWKSToKeyObjectSYNC(jwks, kid));\n\n/**\n * Normalize JWKS (auto-generate missing kid values)\n * @param jwks\n */\nexport const normalizeJWKS = (\n jwks: JSONWebKeySet\n): Promise<JSONWebKeySet> =>\n Promise.resolve().then(() => normalizeJWKSSYNC(jwks));\n\n/**\n * Compute x5t (SHA-1) from first cert in x5c if not set\n * @param jwk\n */\nexport const computeX5T = (jwk: JWKType): Promise<string | undefined> =>\n Promise.resolve().then(() => computeX5TSYNC(jwk));\n\n/**\n * Load and resolve JWKS from a remote endpoint\n * @param args\n */\nexport const fromWeb = (\n ...args: Parameters<typeof fromWebSYNC>\n): Promise<JWKSResolver> =>\n Promise.resolve().then(() => fromWebSYNC(...args));\n\n//namespaced exports\nexport const JWK = {\n export: exportJWK,\n import: importJWK,\n toPublic: toPublicJWK,\n thumbprint: getJWKThumbprint,\n computeX5T: computeX5T,\n};\n\n//namespaced exports\nexport const JWKS = {\n toKeyObject: JWKSToKeyObject,\n normalize: normalizeJWKS,\n fromWeb,\n};\n"],"names":["decode","token","decodeSync","sign","args","signSync","verify","result","verifySync","header","payload","signature","JWT","SignatureAlgorithm","exportJWK","key","exportJWKSYNC","importJWK","jwk","importJWKSYNC","toPublicJWK","toPublicJWKSYNC","getJWKThumbprint","hashAlg","getJWKThumbprintSYNC","JWKSToKeyObject","jwks","kid","JWKSToKeyObjectSYNC","normalizeJWKS","normalizeJWKSSYNC","computeX5T","computeX5TSYNC","fromWeb","fromWebSYNC","JWK","JWKS"],"mappings":"0IAmBO,MAAMA,EAAUC,GACnB,QAAQ,QAAA,EAAU,KAAK,IAAMC,EAAAA,OAAWD,CAAK,CAAC,EAMrCE,EAAO,IAAIC,IACpB,QAAQ,QAAA,EAAU,KAAK,IAAMC,OAAS,GAAGD,CAAI,CAAC,EAMrCE,EAAS,IAAIF,IAKtB,QAAQ,QAAA,EAAU,KAAK,IAAM,CACzB,MAAMG,EAASC,SAAW,GAAGJ,CAAI,EACjC,GAAI,CAACG,EAAO,MACR,MAAMA,EAAO,MAEjB,KAAM,CAAC,OAAAE,EAAQ,QAAAC,EAAS,UAAAC,CAAA,EAAaJ,EACrC,MAAO,CAAC,OAAAE,EAAQ,QAAAC,EAAS,UAAAC,CAAA,CAC7B,CAAC,EAKQC,EAAM,CACf,KAAAT,EACA,OAAAG,EACA,OAAAN,EACA,WAAYa,EAAAA,kBAChB,ECnCaC,EAAaC,GACtB,QAAQ,QAAA,EAAU,KAAK,IAAMC,EAAAA,UAAcD,CAAG,CAAC,EAMtCE,EAAaC,GACtB,QAAQ,QAAA,EAAU,KAAK,IAAMC,EAAAA,UAAcD,CAAG,CAAC,EAMtCE,EAAeL,GACxB,QAAQ,QAAA,EAAU,KAAK,IAAMM,EAAAA,YAAgBN,CAAG,CAAC,EAOxCO,EAAmB,CAC5BJ,EACAK,EAAoB,WAEpB,QAAQ,QAAA,EAAU,KAAK,IAAMC,mBAAqBN,EAAKK,CAAO,CAAC,EAQtDE,EAAkB,CAC3BC,EACAC,IAEA,QAAQ,UAAU,KAAK,IAAMC,EAAAA,gBAAoBF,EAAMC,CAAG,CAAC,EAMlDE,EACTH,GAEA,QAAQ,QAAA,EAAU,KAAK,IAAMI,EAAAA,cAAkBJ,CAAI,CAAC,EAM3CK,EAAcb,GACvB,QAAQ,QAAA,EAAU,KAAK,IAAMc,EAAAA,WAAed,CAAG,CAAC,EAMvCe,EAAU,IAChB7B,IAEH,QAAQ,QAAA,EAAU,KAAK,IAAM8B,UAAY,GAAG9B,CAAI,CAAC,EAGxC+B,EAAM,CACf,OAAQrB,EACR,OAAQG,EACR,SAAUG,EACV,WAAYE,EACZ,WAAAS,CACJ,EAGaK,EAAO,CAChB,YAAaX,EACb,UAAWI,EACX,QAAAI,CACJ"}
@@ -0,0 +1,2 @@
1
+ export * from './jwt/promises';
2
+ export * from './jwks/promises';
@@ -0,0 +1,44 @@
1
+ import { S as n, g as i, v as m, s as c, f as a, j as l, t as h, k as p, h as K, i as W, l as v, b as J } from "./index-CRVBqFI5.js";
2
+ import { d as q } from "./index-CRVBqFI5.js";
3
+ import "crypto";
4
+ const P = (e) => Promise.resolve().then(() => i(e)), u = (...e) => Promise.resolve().then(() => c(...e)), b = (...e) => Promise.resolve().then(() => {
5
+ const o = m(...e);
6
+ if (!o.valid)
7
+ throw o.error;
8
+ const { header: t, payload: s, signature: r } = o;
9
+ return { header: t, payload: s, signature: r };
10
+ }), O = {
11
+ sign: u,
12
+ verify: b,
13
+ decode: P,
14
+ algorithms: n
15
+ }, $ = (e) => Promise.resolve().then(() => K(e)), g = (e) => Promise.resolve().then(() => p(e)), d = (e) => Promise.resolve().then(() => h(e)), f = (e, o = "sha256") => Promise.resolve().then(() => l(e, o)), S = (e, o) => Promise.resolve().then(() => J(e, o)), T = (e) => Promise.resolve().then(() => v(e)), y = (e) => Promise.resolve().then(() => a(e)), x = (...e) => Promise.resolve().then(() => W(...e)), A = {
16
+ export: $,
17
+ import: g,
18
+ toPublic: d,
19
+ thumbprint: f,
20
+ computeX5T: y
21
+ }, X = {
22
+ toKeyObject: S,
23
+ normalize: T,
24
+ fromWeb: x
25
+ };
26
+ export {
27
+ A as JWK,
28
+ X as JWKS,
29
+ S as JWKSToKeyObject,
30
+ O as JWT,
31
+ n as SignatureAlgorithm,
32
+ q as SupportedAlgorithms,
33
+ y as computeX5T,
34
+ P as decode,
35
+ $ as exportJWK,
36
+ x as fromWeb,
37
+ f as getJWKThumbprint,
38
+ g as importJWK,
39
+ T as normalizeJWKS,
40
+ u as sign,
41
+ d as toPublicJWK,
42
+ b as verify
43
+ };
44
+ //# sourceMappingURL=promises.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promises.es.js","sources":["../src/jwt/promises.ts","../src/jwks/promises.ts"],"sourcesContent":["import {\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 '../';\n\nexport {\n type SupportedAlgorithm, SupportedAlgorithms, SignatureAlgorithm, type JWTHeader, type JWTPayload\n} from '../index';\n\n/**\n * Decode a JWT string into its parts (without verification)\n * @param token\n */\nexport const decode = (token: string): Promise<JSONWebToken> =>\n Promise.resolve().then(() => decodeSync(token));\n\n/**\n * Sign a JWT\n * @see(synchronous parameters)\n */\nexport const sign = (...args: Parameters<typeof signSync>): Promise<string> =>\n Promise.resolve().then(() => signSync(...args));\n\n/**\n * Verify and validate a JWT\n * @throws { { reason: string; code: string } } if invalid\n */\nexport const verify = (...args: Parameters<typeof verifySync>): Promise<{\n header: JWTHeader;\n payload: JWTPayload;\n signature: string\n}> =>\n Promise.resolve().then(() => {\n const result = verifySync(...args);\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\n//namespace export\nexport const JWT = {\n sign,\n verify,\n decode,\n algorithms: SignatureAlgorithm\n};\n","import type {KeyObject} from 'crypto';\n\nimport {\n type JWK as JWKType,\n type JWKSResolver,\n type JWKS as JSONWebKeySet,\n exportJWK as exportJWKSYNC,\n importJWK as importJWKSYNC,\n toPublicJWK as toPublicJWKSYNC,\n getJWKThumbprint as getJWKThumbprintSYNC,\n JWKSToKeyObject as JWKSToKeyObjectSYNC,\n normalizeJWKS as normalizeJWKSSYNC,\n computeX5T as computeX5TSYNC,\n fromWeb as fromWebSYNC\n} from './';\n\n/**\n * Export a KeyObject to JWK\n * @param key\n */\nexport const exportJWK = (key: KeyObject): Promise<JWKType> =>\n Promise.resolve().then(() => exportJWKSYNC(key));\n\n/**\n * Import a JWK to KeyObject\n * @param jwk\n */\nexport const importJWK = (jwk: JWKType): Promise<KeyObject> =>\n Promise.resolve().then(() => importJWKSYNC(jwk));\n\n/**\n * Export public-only JWK\n * @param key\n */\nexport const toPublicJWK = (key: KeyObject): Promise<JWKType> =>\n Promise.resolve().then(() => toPublicJWKSYNC(key));\n\n/**\n * RFC 7638 JWK thumbprint\n * @param jwk\n * @param hashAlg\n */\nexport const getJWKThumbprint = (\n jwk: JWKType,\n hashAlg: 'sha256' = 'sha256'\n): Promise<string> =>\n Promise.resolve().then(() => getJWKThumbprintSYNC(jwk, hashAlg));\n\n/**\n * Resolve a KeyObject from a JWKS (kid-based)\n * @param jwks\n * @param kid\n * @constructor\n */\nexport const JWKSToKeyObject = (\n jwks: JSONWebKeySet,\n kid?: string\n): Promise<KeyObject> =>\n Promise.resolve().then(() => JWKSToKeyObjectSYNC(jwks, kid));\n\n/**\n * Normalize JWKS (auto-generate missing kid values)\n * @param jwks\n */\nexport const normalizeJWKS = (\n jwks: JSONWebKeySet\n): Promise<JSONWebKeySet> =>\n Promise.resolve().then(() => normalizeJWKSSYNC(jwks));\n\n/**\n * Compute x5t (SHA-1) from first cert in x5c if not set\n * @param jwk\n */\nexport const computeX5T = (jwk: JWKType): Promise<string | undefined> =>\n Promise.resolve().then(() => computeX5TSYNC(jwk));\n\n/**\n * Load and resolve JWKS from a remote endpoint\n * @param args\n */\nexport const fromWeb = (\n ...args: Parameters<typeof fromWebSYNC>\n): Promise<JWKSResolver> =>\n Promise.resolve().then(() => fromWebSYNC(...args));\n\n//namespaced exports\nexport const JWK = {\n export: exportJWK,\n import: importJWK,\n toPublic: toPublicJWK,\n thumbprint: getJWKThumbprint,\n computeX5T: computeX5T,\n};\n\n//namespaced exports\nexport const JWKS = {\n toKeyObject: JWKSToKeyObject,\n normalize: normalizeJWKS,\n fromWeb,\n};\n"],"names":["decode","token","decodeSync","sign","args","signSync","verify","result","verifySync","header","payload","signature","JWT","SignatureAlgorithm","exportJWK","key","exportJWKSYNC","importJWK","jwk","importJWKSYNC","toPublicJWK","toPublicJWKSYNC","getJWKThumbprint","hashAlg","getJWKThumbprintSYNC","JWKSToKeyObject","jwks","kid","JWKSToKeyObjectSYNC","normalizeJWKS","normalizeJWKSSYNC","computeX5T","computeX5TSYNC","fromWeb","fromWebSYNC","JWK","JWKS"],"mappings":";;;AAmBO,MAAMA,IAAS,CAACC,MACnB,QAAQ,QAAA,EAAU,KAAK,MAAMC,EAAWD,CAAK,CAAC,GAMrCE,IAAO,IAAIC,MACpB,QAAQ,QAAA,EAAU,KAAK,MAAMC,EAAS,GAAGD,CAAI,CAAC,GAMrCE,IAAS,IAAIF,MAKtB,QAAQ,QAAA,EAAU,KAAK,MAAM;AACzB,QAAMG,IAASC,EAAW,GAAGJ,CAAI;AACjC,MAAI,CAACG,EAAO;AACR,UAAMA,EAAO;AAEjB,QAAM,EAAC,QAAAE,GAAQ,SAAAC,GAAS,WAAAC,EAAA,IAAaJ;AACrC,SAAO,EAAC,QAAAE,GAAQ,SAAAC,GAAS,WAAAC,EAAA;AAC7B,CAAC,GAKQC,IAAM;AAAA,EACf,MAAAT;AAAA,EACA,QAAAG;AAAA,EACA,QAAAN;AAAA,EACA,YAAYa;AAChB,GCnCaC,IAAY,CAACC,MACtB,QAAQ,QAAA,EAAU,KAAK,MAAMC,EAAcD,CAAG,CAAC,GAMtCE,IAAY,CAACC,MACtB,QAAQ,QAAA,EAAU,KAAK,MAAMC,EAAcD,CAAG,CAAC,GAMtCE,IAAc,CAACL,MACxB,QAAQ,QAAA,EAAU,KAAK,MAAMM,EAAgBN,CAAG,CAAC,GAOxCO,IAAmB,CAC5BJ,GACAK,IAAoB,aAEpB,QAAQ,QAAA,EAAU,KAAK,MAAMC,EAAqBN,GAAKK,CAAO,CAAC,GAQtDE,IAAkB,CAC3BC,GACAC,MAEA,QAAQ,UAAU,KAAK,MAAMC,EAAoBF,GAAMC,CAAG,CAAC,GAMlDE,IAAgB,CACzBH,MAEA,QAAQ,QAAA,EAAU,KAAK,MAAMI,EAAkBJ,CAAI,CAAC,GAM3CK,IAAa,CAACb,MACvB,QAAQ,QAAA,EAAU,KAAK,MAAMc,EAAed,CAAG,CAAC,GAMvCe,IAAU,IAChB7B,MAEH,QAAQ,QAAA,EAAU,KAAK,MAAM8B,EAAY,GAAG9B,CAAI,CAAC,GAGxC+B,IAAM;AAAA,EACf,QAAQrB;AAAA,EACR,QAAQG;AAAA,EACR,UAAUG;AAAA,EACV,YAAYE;AAAA,EACZ,YAAAS;AACJ,GAGaK,IAAO;AAAA,EAChB,aAAaX;AAAA,EACb,WAAWI;AAAA,EACX,SAAAI;AACJ;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sourceregistry/node-jwt",
3
- "version": "1.5.6",
3
+ "version": "1.5.7",
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",
@@ -82,12 +82,8 @@
82
82
  "@semantic-release/commit-analyzer",
83
83
  "@semantic-release/release-notes-generator",
84
84
  "@semantic-release/changelog",
85
- [
86
- "@semantic-release/npm"
87
- ],
88
- [
89
- "@sourceregistry/semantic-release-jsr"
90
- ],
85
+ "@semantic-release/npm",
86
+ "@sourceregistry/semantic-release-jsr",
91
87
  [
92
88
  "@semantic-release/git",
93
89
  {