@sdxc/jwt 2026.9.11 → 2026.9.28

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/jwk.d.ts CHANGED
@@ -24,11 +24,11 @@ export declare namespace JWK {
24
24
  * providers; EdDSA derives its nonce from the key and message, keeping the
25
25
  * ECDSA nonce-reuse leak that exposes a private key out of reach.
26
26
  */
27
- const Algorithm: typeof SignatureAlgorithm;
27
+ export const Algorithm: typeof SignatureAlgorithm;
28
28
  /** One of the supported signature algorithms. */
29
- type Algorithm = (typeof SignatureAlgorithm)[keyof typeof SignatureAlgorithm];
29
+ export type Algorithm = (typeof SignatureAlgorithm)[keyof typeof SignatureAlgorithm];
30
30
  /** A key pair imported into a usable form, with the public half in JWK format. */
31
- interface KeyPair {
31
+ export interface KeyPair {
32
32
  /** Identifier published as the `kid`, and written into every token header. */
33
33
  id: string;
34
34
  /** Algorithm the pair was generated for. */
@@ -50,7 +50,7 @@ export declare namespace JWK {
50
50
  * PEM strings and a millisecond timestamp, so the whole pair survives
51
51
  * `JSON.stringify` into a bucket or a text column with nothing lost.
52
52
  */
53
- interface SerializedKeyPair {
53
+ export interface SerializedKeyPair {
54
54
  /** Identifier that becomes the `kid`. */
55
55
  id: `${string}-${string}-${string}-${string}-${string}`;
56
56
  /** Algorithm the pair was generated for. */
@@ -70,7 +70,7 @@ export declare namespace JWK {
70
70
  * A structural subset of `KeyPair`, so a full pair is accepted wherever this is
71
71
  * expected, and a caller holding only a private key already has enough to sign.
72
72
  */
73
- interface SigningKey {
73
+ export interface SigningKey {
74
74
  /** Identifier written into the token header as `kid`. */
75
75
  id: string;
76
76
  /** Algorithm the key was generated for, matched against the requested one. */
@@ -84,7 +84,7 @@ export declare namespace JWK {
84
84
  * A single `jwk` field carries both the key material and the `kid` a token's
85
85
  * header is matched against — everything selecting a key from a set takes.
86
86
  */
87
- interface VerificationKey {
87
+ export interface VerificationKey {
88
88
  jwk: jose.JWK;
89
89
  }
90
90
  /**
@@ -93,11 +93,11 @@ export declare namespace JWK {
93
93
  * What `importLocal` and `importRemote` hand back: the key set is only consulted
94
94
  * once there is a token to consult it about.
95
95
  */
96
- type KeyResolver = jose.JWTVerifyGetKey;
96
+ export type KeyResolver = jose.JWTVerifyGetKey;
97
97
  /** Where `JWT.verify` can find a token's key: the keys themselves, or a resolver. */
98
- type VerificationKeys = KeyResolver | VerificationKey[];
98
+ export type VerificationKeys = KeyResolver | VerificationKey[];
99
99
  /** Request headers, timeouts, and cache windows a remote key set can be given. */
100
- type RemoteOptions = jose.RemoteJWKSetOptions;
100
+ export type RemoteOptions = jose.RemoteJWKSetOptions;
101
101
  /**
102
102
  * Generates a new key pair in serialized form.
103
103
  *
@@ -110,7 +110,7 @@ export declare namespace JWK {
110
110
  * let serialized = await JWK.generateKeyPair(JWK.Algorithm.ES256);
111
111
  * await db.create(table, { id: serialized.id, private_key: serialized.privateKey });
112
112
  */
113
- function generateKeyPair(alg: Algorithm): Promise<SerializedKeyPair>;
113
+ export function generateKeyPair(alg: Algorithm): Promise<SerializedKeyPair>;
114
114
  /**
115
115
  * Imports a stored key pair back into usable `CryptoKey` objects.
116
116
  *
@@ -122,7 +122,7 @@ export declare namespace JWK {
122
122
  * @example
123
123
  * let keyPair = await JWK.importKeyPair({ id, alg, publicKey, privateKey, created });
124
124
  */
125
- function importKeyPair(value: SerializedKeyPair): Promise<KeyPair>;
125
+ export function importKeyPair(value: SerializedKeyPair): Promise<KeyPair>;
126
126
  /**
127
127
  * Loads the signing keys out of storage, generating one on first use.
128
128
  *
@@ -135,7 +135,7 @@ export declare namespace JWK {
135
135
  * let keys = await JWK.signingKeys(storage);
136
136
  * let jwks = JWK.toJSON(keys);
137
137
  */
138
- function signingKeys(storage: KeyStorage): Promise<KeyPair[]>;
138
+ export function signingKeys(storage: KeyStorage): Promise<KeyPair[]>;
139
139
  /**
140
140
  * Resolves a token's key by matching its header's `kid`, key type, curve,
141
141
  * algorithm, and use against the set; anything but exactly one match is an
@@ -147,7 +147,7 @@ export declare namespace JWK {
147
147
  * let keys = await JWK.importLocal(jwks);
148
148
  * let token = await IdToken.verify(raw, keys, { issuer, audience, algorithms });
149
149
  */
150
- function importLocal(jwks: jose.JSONWebKeySet): Promise<KeyResolver>;
150
+ export function importLocal(jwks: jose.JSONWebKeySet): Promise<KeyResolver>;
151
151
  /**
152
152
  * Points a resolver at a JWKS endpoint, fetched on first use and re-fetched
153
153
  * at most once per cooldown window when a token names an unseen `kid` —
@@ -159,7 +159,7 @@ export declare namespace JWK {
159
159
  * @example
160
160
  * let keys = JWK.importRemote(new URL(jwksUrl));
161
161
  */
162
- function importRemote(url: URL, options?: RemoteOptions): Promise<KeyResolver>;
162
+ export function importRemote(url: URL, options?: RemoteOptions): Promise<KeyResolver>;
163
163
  /**
164
164
  * Renders key pairs as the JSON a `/.well-known/jwks.json` endpoint serves.
165
165
  *
@@ -167,10 +167,21 @@ export declare namespace JWK {
167
167
  * plus `kid` and `alg`, keeping unvetted private material out of the set.
168
168
  *
169
169
  * @param keys - The key pairs to publish.
170
- * @returns The JWKS document.
170
+ * @returns The JWKS document, every entry carrying the `kty` RFC 7517 requires.
171
171
  * @throws When a pair's key type has no published shape on record.
172
172
  * @example
173
173
  * return Response.json(JWK.toJSON(await JWK.signingKeys(storage)));
174
174
  */
175
- function toJSON(keys: KeyPair[]): jose.JSONWebKeySet;
175
+ export function toJSON(keys: KeyPair[]): PublishedKeySet;
176
+ /** The members jose allows on a key inside a JWKS document. */
177
+ type PublishedKeyMembers = jose.JSONWebKeySet["keys"][number];
178
+ /** A published key: RFC 7517 makes `kty` the one member every JWK carries. */
179
+ export interface PublishedKey extends PublishedKeyMembers {
180
+ kty: string;
181
+ }
182
+ /** The JWKS document {@link toJSON} writes, accepted anywhere a JWKS is read. */
183
+ export interface PublishedKeySet {
184
+ keys: PublishedKey[];
185
+ }
186
+ export {};
176
187
  }
package/dist/jwk.js CHANGED
@@ -164,7 +164,7 @@ export var JWK;
164
164
  * plus `kid` and `alg`, keeping unvetted private material out of the set.
165
165
  *
166
166
  * @param keys - The key pairs to publish.
167
- * @returns The JWKS document.
167
+ * @returns The JWKS document, every entry carrying the `kty` RFC 7517 requires.
168
168
  * @throws When a pair's key type has no published shape on record.
169
169
  * @example
170
170
  * return Response.json(JWK.toJSON(await JWK.signingKeys(storage)));
@@ -172,10 +172,11 @@ export var JWK;
172
172
  function toJSON(keys) {
173
173
  return {
174
174
  keys: keys.map(({ alg, id, jwk }) => {
175
- let publish = jwk.kty ? PUBLISHED_JWK_FIELDS[jwk.kty] : undefined;
176
- if (!publish)
177
- throw new Error(`Cannot publish a key of type ${String(jwk.kty)}`);
178
- return { ...publish(jwk), kty: jwk.kty, kid: id, alg };
175
+ let kty = jwk.kty;
176
+ let publish = kty ? PUBLISHED_JWK_FIELDS[kty] : undefined;
177
+ if (!kty || !publish)
178
+ throw new Error(`Cannot publish a key of type ${String(kty)}`);
179
+ return { ...publish(jwk), kty, kid: id, alg };
179
180
  }),
180
181
  };
181
182
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdxc/jwt",
3
- "version": "2026.9.11",
3
+ "version": "2026.9.28",
4
4
  "description": "JWT payload classes and the keys that sign them",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -9,10 +9,10 @@
9
9
  "./algorithm": "./dist/algorithm.js"
10
10
  },
11
11
  "dependencies": {
12
- "@sdxc/duration": "2026.9.11",
12
+ "@sdxc/duration": "2026.9.15",
13
13
  "jose": "^6.2.10"
14
14
  },
15
- "gitHead": "3aedbf2a8ed2251cecac480501941ee4c4614ec3",
15
+ "gitHead": "00c01e349b11f65b9f47902c5345a817e8afd2b1",
16
16
  "publishConfig": {
17
17
  "access": "public"
18
18
  },