@hearth-auth/sdk 2.0.4 → 3.0.1
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/README.md +295 -101
- package/dist/admin.d.ts +82 -47
- package/dist/admin.js +179 -132
- package/dist/admin.js.map +1 -1
- package/dist/claims.d.ts +10 -0
- package/dist/claims.js +16 -0
- package/dist/claims.js.map +1 -1
- package/dist/errors.d.ts +18 -6
- package/dist/errors.js +70 -7
- package/dist/errors.js.map +1 -1
- package/dist/generated/admin/schema.d.ts +3650 -0
- package/dist/generated/admin/schema.js +6 -0
- package/dist/generated/admin/schema.js.map +1 -0
- package/dist/hearth-client.d.ts +129 -10
- package/dist/hearth-client.js +278 -83
- package/dist/hearth-client.js.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/introspection-client.d.ts +9 -3
- package/dist/introspection-client.js +35 -14
- package/dist/introspection-client.js.map +1 -1
- package/dist/jwks-client.d.ts +8 -2
- package/dist/jwks-client.js +20 -10
- package/dist/jwks-client.js.map +1 -1
- package/dist/middleware.d.ts +117 -0
- package/dist/middleware.js +171 -1
- package/dist/middleware.js.map +1 -1
- package/dist/nextjs/edge.d.ts +26 -0
- package/dist/nextjs/edge.js +31 -0
- package/dist/nextjs/edge.js.map +1 -0
- package/dist/nextjs/index.d.ts +50 -0
- package/dist/nextjs/index.js +55 -0
- package/dist/nextjs/index.js.map +1 -0
- package/dist/session-version-cache.js.map +1 -1
- package/dist/types.d.ts +62 -4
- package/package.json +20 -3
package/dist/hearth-client.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AuthorizationModeMismatchError, ConfigurationError, DiscoveryError, OAuthFlowError, TokenExpiredError, } from "./errors.js";
|
|
2
2
|
import { JwksClient } from "./jwks-client.js";
|
|
3
3
|
import { IntrospectionClient } from "./introspection-client.js";
|
|
4
|
+
import { buildAuthorizationUrl, generateCodeChallenge, generateCodeVerifier } from "./pkce.js";
|
|
4
5
|
/**
|
|
5
|
-
* Primary entry point for the Hearth
|
|
6
|
+
* Primary entry point for the Hearth SDK.
|
|
6
7
|
*
|
|
7
8
|
* Accepts a single configuration object, auto-discovers all endpoint URLs
|
|
8
9
|
* from `{issuerUrl}/.well-known/openid-configuration` on first use, and
|
|
@@ -25,6 +26,7 @@ export class HearthClient {
|
|
|
25
26
|
/** Expected authorization mode; validated on `introspect()` when present. */
|
|
26
27
|
expectedMode;
|
|
27
28
|
_discovery = null;
|
|
29
|
+
_discoveryInFlight = null;
|
|
28
30
|
_jwksClient = null;
|
|
29
31
|
_introspectionClient = null;
|
|
30
32
|
constructor(config) {
|
|
@@ -50,12 +52,34 @@ export class HearthClient {
|
|
|
50
52
|
* Fetches and caches the OIDC discovery document from
|
|
51
53
|
* `{issuerUrl}/.well-known/openid-configuration`.
|
|
52
54
|
*
|
|
55
|
+
* Concurrent callers share one request. A failed fetch is not cached.
|
|
56
|
+
*
|
|
53
57
|
* Throws {@link DiscoveryError} when the endpoint is unreachable,
|
|
54
58
|
* returns a non-2xx status, or returns invalid JSON.
|
|
55
59
|
*/
|
|
56
60
|
async discover() {
|
|
57
61
|
if (this._discovery)
|
|
58
62
|
return this._discovery;
|
|
63
|
+
if (!this._discoveryInFlight) {
|
|
64
|
+
this._discoveryInFlight = this.fetchDiscovery().finally(() => {
|
|
65
|
+
this._discoveryInFlight = null;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return this._discoveryInFlight;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Drop the cached discovery document, JWKS key set and introspection client.
|
|
72
|
+
* The next call fetches them again. Call it after the issuer rotates keys or
|
|
73
|
+
* changes endpoints, or after a resource server answers 401 for a token you
|
|
74
|
+
* believe is valid.
|
|
75
|
+
*/
|
|
76
|
+
invalidateCache() {
|
|
77
|
+
this._discovery = null;
|
|
78
|
+
this._discoveryInFlight = null;
|
|
79
|
+
this._jwksClient = null;
|
|
80
|
+
this._introspectionClient = null;
|
|
81
|
+
}
|
|
82
|
+
async fetchDiscovery() {
|
|
59
83
|
const url = `${this.issuerUrl}/.well-known/openid-configuration`;
|
|
60
84
|
let resp;
|
|
61
85
|
try {
|
|
@@ -178,12 +202,14 @@ export class HearthClient {
|
|
|
178
202
|
* deployments where the resource server and the issuing client disagree on
|
|
179
203
|
* the permission delivery strategy.
|
|
180
204
|
*
|
|
205
|
+
* @param tokenTypeHint - Optional RFC 7662 `token_type_hint`.
|
|
181
206
|
* @throws {@link ConfigurationError} when `clientId`/`clientSecret` are absent.
|
|
207
|
+
* @throws {@link IntrospectionError} when the introspection request fails.
|
|
182
208
|
* @throws {@link AuthorizationModeMismatchError} on mode echo mismatch.
|
|
183
209
|
*/
|
|
184
|
-
async introspect(token) {
|
|
210
|
+
async introspect(token, tokenTypeHint) {
|
|
185
211
|
const ic = await this.introspectionClient();
|
|
186
|
-
const result = await ic.introspect(token);
|
|
212
|
+
const result = await ic.introspect(token, tokenTypeHint);
|
|
187
213
|
if (this.expectedMode !== undefined &&
|
|
188
214
|
result.mode !== undefined &&
|
|
189
215
|
result.mode !== this.expectedMode) {
|
|
@@ -205,7 +231,8 @@ export class HearthClient {
|
|
|
205
231
|
* 3. `nbf` claim (rejects post-dated tokens).
|
|
206
232
|
* 4. `iss` claim (must match configured `issuerUrl`).
|
|
207
233
|
* 5. `aud` claim (validated when `clientId` is set in config).
|
|
208
|
-
*
|
|
234
|
+
*
|
|
235
|
+
* `exp` and `nbf` allow a 5-second clock skew.
|
|
209
236
|
*
|
|
210
237
|
* @throws {@link TokenExpiredError} — token is expired.
|
|
211
238
|
* @throws {@link TokenInvalidError} — signature invalid or JWT malformed.
|
|
@@ -221,6 +248,89 @@ export class HearthClient {
|
|
|
221
248
|
});
|
|
222
249
|
}
|
|
223
250
|
// ── §4.5 — OAuth Flows ───────────────────────────────────────────────────
|
|
251
|
+
/**
|
|
252
|
+
* Begin an authorization-code login with PKCE.
|
|
253
|
+
*
|
|
254
|
+
* Generates a code verifier and a `state` value and builds the URL of the
|
|
255
|
+
* discovered `authorization_endpoint`. Store `state` and `codeVerifier` in the
|
|
256
|
+
* server-side session, redirect the browser to `authorizationUrl`, then call
|
|
257
|
+
* {@link completeLogin} on the callback route.
|
|
258
|
+
*
|
|
259
|
+
* @param redirectUri - Callback URL registered for this client.
|
|
260
|
+
* @param scope - Space-delimited scopes. Default: `"openid"`.
|
|
261
|
+
* @throws {@link ConfigurationError} when `clientId` is absent or discovery has
|
|
262
|
+
* no `authorization_endpoint`.
|
|
263
|
+
*/
|
|
264
|
+
async beginLogin(redirectUri, scope = "openid") {
|
|
265
|
+
const clientId = this.requireClientId("beginLogin");
|
|
266
|
+
const authorizationEndpoint = await this.endpoint("authorization_endpoint");
|
|
267
|
+
const codeVerifier = generateCodeVerifier();
|
|
268
|
+
const { url, state } = buildAuthorizationUrl({
|
|
269
|
+
authorizationEndpoint,
|
|
270
|
+
clientId,
|
|
271
|
+
redirectUri,
|
|
272
|
+
codeChallenge: await generateCodeChallenge(codeVerifier),
|
|
273
|
+
scope,
|
|
274
|
+
});
|
|
275
|
+
return { authorizationUrl: url, state, codeVerifier };
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Complete an authorization-code login: exchange the callback `code` for
|
|
279
|
+
* tokens. Check the callback's `state` against the stored one first.
|
|
280
|
+
*
|
|
281
|
+
* @param code - The `code` query parameter from the callback URL.
|
|
282
|
+
* @param codeVerifier - The verifier returned by {@link beginLogin}.
|
|
283
|
+
* @param redirectUri - The same redirect URI passed to {@link beginLogin}.
|
|
284
|
+
* @throws {@link OAuthFlowError} on a non-2xx response or a network failure.
|
|
285
|
+
*/
|
|
286
|
+
async completeLogin(code, codeVerifier, redirectUri) {
|
|
287
|
+
return this.exchangeCode(code, redirectUri, { codeVerifier });
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Exchange an authorization code for tokens (RFC 6749 §4.1.3).
|
|
291
|
+
*
|
|
292
|
+
* Posts to the discovered `token_endpoint` as
|
|
293
|
+
* `application/x-www-form-urlencoded`. `client_secret` is sent only when
|
|
294
|
+
* configured, so public clients use PKCE alone.
|
|
295
|
+
*
|
|
296
|
+
* @param code - Authorization code from the callback URL.
|
|
297
|
+
* @param redirectUri - The redirect URI used in the authorization request.
|
|
298
|
+
* @param opts - `codeVerifier` for PKCE-protected flows.
|
|
299
|
+
* @throws {@link ConfigurationError} when `clientId` is absent.
|
|
300
|
+
* @throws {@link OAuthFlowError} on a non-2xx response or a network failure.
|
|
301
|
+
*/
|
|
302
|
+
async exchangeCode(code, redirectUri, opts) {
|
|
303
|
+
const params = {
|
|
304
|
+
grant_type: "authorization_code",
|
|
305
|
+
code,
|
|
306
|
+
redirect_uri: redirectUri,
|
|
307
|
+
...this.clientAuthParams("exchangeCode"),
|
|
308
|
+
};
|
|
309
|
+
if (opts?.codeVerifier)
|
|
310
|
+
params.code_verifier = opts.codeVerifier;
|
|
311
|
+
return this.postForm(await this.endpoint("token_endpoint"), params);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Exchange a refresh token for new tokens (RFC 6749 §6).
|
|
315
|
+
*
|
|
316
|
+
* The response may carry a rotated `refresh_token`; store it in place of the
|
|
317
|
+
* old one when present.
|
|
318
|
+
*
|
|
319
|
+
* @param refreshToken - Refresh token previously issued to this client.
|
|
320
|
+
* @param scope - Optional space-delimited scopes (must not widen the grant).
|
|
321
|
+
* @throws {@link ConfigurationError} when `clientId` is absent.
|
|
322
|
+
* @throws {@link OAuthFlowError} on a non-2xx response or a network failure.
|
|
323
|
+
*/
|
|
324
|
+
async refreshTokens(refreshToken, scope) {
|
|
325
|
+
const params = {
|
|
326
|
+
grant_type: "refresh_token",
|
|
327
|
+
refresh_token: refreshToken,
|
|
328
|
+
...this.clientAuthParams("refreshTokens"),
|
|
329
|
+
};
|
|
330
|
+
if (scope !== undefined)
|
|
331
|
+
params.scope = scope;
|
|
332
|
+
return this.postForm(await this.endpoint("token_endpoint"), params);
|
|
333
|
+
}
|
|
224
334
|
/**
|
|
225
335
|
* Obtain a token via the Client Credentials grant (RFC 6749 §4.4).
|
|
226
336
|
*
|
|
@@ -228,14 +338,9 @@ export class HearthClient {
|
|
|
228
338
|
* body fields — NEVER as URL query parameters. The token endpoint is discovered
|
|
229
339
|
* from the OIDC discovery document.
|
|
230
340
|
*
|
|
231
|
-
* @throws {@link OAuthFlowError} on
|
|
341
|
+
* @throws {@link OAuthFlowError} on a non-2xx response or a network failure.
|
|
232
342
|
*/
|
|
233
343
|
async clientCredentials(scope) {
|
|
234
|
-
const doc = await this.discover();
|
|
235
|
-
const tokenEndpoint = doc["token_endpoint"];
|
|
236
|
-
if (!tokenEndpoint) {
|
|
237
|
-
throw new ConfigurationError("token_endpoint not found in OIDC discovery document");
|
|
238
|
-
}
|
|
239
344
|
const params = {
|
|
240
345
|
grant_type: "client_credentials",
|
|
241
346
|
client_id: this.clientId ?? "",
|
|
@@ -243,7 +348,7 @@ export class HearthClient {
|
|
|
243
348
|
};
|
|
244
349
|
if (scope !== undefined)
|
|
245
350
|
params.scope = scope;
|
|
246
|
-
return this.postForm(
|
|
351
|
+
return this.postForm(await this.endpoint("token_endpoint"), params);
|
|
247
352
|
}
|
|
248
353
|
/**
|
|
249
354
|
* Begin a Device Authorization Flow (RFC 8628 §3.1).
|
|
@@ -252,18 +357,13 @@ export class HearthClient {
|
|
|
252
357
|
* Pass the returned `device_code` and `interval` to `pollDeviceToken()` to await approval.
|
|
253
358
|
*
|
|
254
359
|
* @throws {@link ConfigurationError} when `device_authorization_endpoint` is absent.
|
|
255
|
-
* @throws {@link OAuthFlowError} on
|
|
360
|
+
* @throws {@link OAuthFlowError} on a non-2xx response or a network failure.
|
|
256
361
|
*/
|
|
257
362
|
async startDeviceFlow(scope) {
|
|
258
|
-
const doc = await this.discover();
|
|
259
|
-
const deviceEndpoint = doc["device_authorization_endpoint"];
|
|
260
|
-
if (!deviceEndpoint) {
|
|
261
|
-
throw new ConfigurationError("device_authorization_endpoint not found in OIDC discovery document");
|
|
262
|
-
}
|
|
263
363
|
const params = { client_id: this.clientId ?? "" };
|
|
264
364
|
if (scope !== undefined)
|
|
265
365
|
params.scope = scope;
|
|
266
|
-
return this.postForm(
|
|
366
|
+
return this.postForm(await this.endpoint("device_authorization_endpoint"), params);
|
|
267
367
|
}
|
|
268
368
|
/**
|
|
269
369
|
* Poll the token endpoint until the device flow completes (RFC 8628 §3.5).
|
|
@@ -275,51 +375,33 @@ export class HearthClient {
|
|
|
275
375
|
* @param deviceCode - The `device_code` from `startDeviceFlow()`.
|
|
276
376
|
* @param intervalSeconds - Initial polling interval (from `startDeviceFlow().interval`).
|
|
277
377
|
* @throws {@link TokenExpiredError} — device code has expired.
|
|
278
|
-
* @throws {@link OAuthFlowError} — non-recoverable error from the server.
|
|
378
|
+
* @throws {@link OAuthFlowError} — non-recoverable error from the server, or a network failure.
|
|
279
379
|
*/
|
|
280
380
|
async pollDeviceToken(deviceCode, intervalSeconds) {
|
|
281
|
-
const
|
|
282
|
-
const tokenEndpoint = doc["token_endpoint"];
|
|
283
|
-
if (!tokenEndpoint) {
|
|
284
|
-
throw new ConfigurationError("token_endpoint not found in OIDC discovery document");
|
|
285
|
-
}
|
|
381
|
+
const tokenEndpoint = await this.endpoint("token_endpoint");
|
|
286
382
|
let currentIntervalMs = intervalSeconds * 1000;
|
|
287
383
|
// Use while(true) + await-setTimeout so Vitest fake timers can control polling in tests.
|
|
288
384
|
while (true) {
|
|
289
385
|
await new Promise((res) => setTimeout(res, currentIntervalMs));
|
|
290
|
-
const body = new URLSearchParams({
|
|
291
|
-
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
292
|
-
device_code: deviceCode,
|
|
293
|
-
client_id: this.clientId ?? "",
|
|
294
|
-
}).toString();
|
|
295
|
-
const resp = await fetch(tokenEndpoint, {
|
|
296
|
-
method: "POST",
|
|
297
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
298
|
-
body,
|
|
299
|
-
});
|
|
300
|
-
if (resp.ok) {
|
|
301
|
-
return resp.json();
|
|
302
|
-
}
|
|
303
|
-
let errorCode = "unknown";
|
|
304
386
|
try {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
if (errorCode === "authorization_pending") {
|
|
312
|
-
continue;
|
|
313
|
-
}
|
|
314
|
-
else if (errorCode === "slow_down") {
|
|
315
|
-
currentIntervalMs += 5000;
|
|
316
|
-
continue;
|
|
317
|
-
}
|
|
318
|
-
else if (errorCode === "expired_token") {
|
|
319
|
-
throw new TokenExpiredError(new Date());
|
|
387
|
+
return await this.postForm(tokenEndpoint, {
|
|
388
|
+
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
389
|
+
device_code: deviceCode,
|
|
390
|
+
client_id: this.clientId ?? "",
|
|
391
|
+
});
|
|
320
392
|
}
|
|
321
|
-
|
|
322
|
-
|
|
393
|
+
catch (err) {
|
|
394
|
+
if (!(err instanceof OAuthFlowError))
|
|
395
|
+
throw err;
|
|
396
|
+
if (err.errorCode === "authorization_pending")
|
|
397
|
+
continue;
|
|
398
|
+
if (err.errorCode === "slow_down") {
|
|
399
|
+
currentIntervalMs += 5000;
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
if (err.errorCode === "expired_token")
|
|
403
|
+
throw new TokenExpiredError(new Date());
|
|
404
|
+
throw err;
|
|
323
405
|
}
|
|
324
406
|
}
|
|
325
407
|
}
|
|
@@ -333,24 +415,19 @@ export class HearthClient {
|
|
|
333
415
|
* Requires `realmId` in `HearthClientConfig`.
|
|
334
416
|
*
|
|
335
417
|
* @throws {@link ConfigurationError} when `realmId` is absent.
|
|
336
|
-
* @throws {@link OAuthFlowError} on non-2xx response.
|
|
418
|
+
* @throws {@link OAuthFlowError} on a non-2xx response or a network failure.
|
|
337
419
|
*/
|
|
338
420
|
async requestMagicLink(email) {
|
|
339
421
|
if (!this.realmId) {
|
|
340
422
|
throw new ConfigurationError("realmId is required for requestMagicLink");
|
|
341
423
|
}
|
|
342
|
-
const
|
|
343
|
-
const resp = await fetch(url, {
|
|
424
|
+
const resp = await this.send(`${this.issuerUrl}/v1/${this.realmId}/auth/magic-link`, {
|
|
344
425
|
method: "POST",
|
|
345
426
|
headers: { "Content-Type": "application/json" },
|
|
346
427
|
body: JSON.stringify({ email }),
|
|
347
|
-
signal: AbortSignal.timeout(this.httpTimeout),
|
|
348
428
|
});
|
|
349
|
-
if (resp.
|
|
350
|
-
|
|
351
|
-
if (!resp.ok) {
|
|
352
|
-
throw new OAuthFlowError(resp.status, `HTTP ${resp.status}`);
|
|
353
|
-
}
|
|
429
|
+
if (!resp.ok)
|
|
430
|
+
throw await oauthFlowError(resp);
|
|
354
431
|
}
|
|
355
432
|
/**
|
|
356
433
|
* Exchange a magic-link token for tokens (spec §4.5.3 / §7.2 C-12).
|
|
@@ -364,40 +441,158 @@ export class HearthClient {
|
|
|
364
441
|
* @throws {@link OAuthFlowError} on any non-2xx response (e.g. expired/used token).
|
|
365
442
|
*/
|
|
366
443
|
async exchangeMagicLink(token) {
|
|
367
|
-
const doc = await this.discover();
|
|
368
|
-
const tokenEndpoint = doc["token_endpoint"];
|
|
369
|
-
if (!tokenEndpoint) {
|
|
370
|
-
throw new ConfigurationError("token_endpoint not found in OIDC discovery document");
|
|
371
|
-
}
|
|
372
444
|
const params = {
|
|
373
445
|
grant_type: "urn:hearth:grant-type:magic-link",
|
|
374
446
|
token,
|
|
375
447
|
};
|
|
376
448
|
if (this.clientId)
|
|
377
449
|
params.client_id = this.clientId;
|
|
378
|
-
return this.postForm(
|
|
450
|
+
return this.postForm(await this.endpoint("token_endpoint"), params);
|
|
451
|
+
}
|
|
452
|
+
// ── UserInfo, live permissions and the session-version feed ─────────────
|
|
453
|
+
/**
|
|
454
|
+
* Fetch the OIDC userinfo claims for an access token from the discovered
|
|
455
|
+
* `userinfo_endpoint`. Sends `X-Realm-ID` when `realmId` is configured.
|
|
456
|
+
*
|
|
457
|
+
* @throws {@link ConfigurationError} when discovery has no `userinfo_endpoint`.
|
|
458
|
+
* @throws {@link OAuthFlowError} on a non-2xx response or a network failure.
|
|
459
|
+
*/
|
|
460
|
+
async userinfo(accessToken) {
|
|
461
|
+
const endpoint = await this.endpoint("userinfo_endpoint");
|
|
462
|
+
return this.getRequired(endpoint, accessToken);
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Fetch the user's current roles, groups and permissions from
|
|
466
|
+
* `GET /v1/me/permissions`. Unlike the claims in the JWT, which are fixed
|
|
467
|
+
* when the token is issued, this reflects assignments made since.
|
|
468
|
+
*
|
|
469
|
+
* @throws {@link ConfigurationError} when `realmId` is absent.
|
|
470
|
+
* @throws {@link OAuthFlowError} on a non-2xx response or a network failure.
|
|
471
|
+
*/
|
|
472
|
+
async mePermissions(accessToken) {
|
|
473
|
+
this.requireRealmId("mePermissions");
|
|
474
|
+
const url = `${this.issuerUrl}/v1/me/permissions`;
|
|
475
|
+
return this.getRequired(url, accessToken);
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Fetch the full session-version snapshot (RFC HEA-930): every
|
|
479
|
+
* `{sessionId → minSv}` pair in the realm. Use it to seed a cache, then
|
|
480
|
+
* follow {@link svDelta} from `current_seq`. {@link SessionVersionCache} does
|
|
481
|
+
* both for you.
|
|
482
|
+
*
|
|
483
|
+
* @param serviceToken - Token with the `hearth.sv_feed` scope.
|
|
484
|
+
* @throws {@link ConfigurationError} when `realmId` is absent.
|
|
485
|
+
* @throws {@link OAuthFlowError} on a non-2xx response or a network failure.
|
|
486
|
+
*/
|
|
487
|
+
async svSnapshot(serviceToken) {
|
|
488
|
+
this.requireRealmId("svSnapshot");
|
|
489
|
+
const url = `${this.issuerUrl}/oauth/session-versions/snapshot`;
|
|
490
|
+
return this.getRequired(url, serviceToken);
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Fetch session-version changes with `seq > since` (RFC HEA-930).
|
|
494
|
+
*
|
|
495
|
+
* @param serviceToken - Token with the `hearth.sv_feed` scope.
|
|
496
|
+
* @param since - Return only events after this sequence number.
|
|
497
|
+
* @param limit - Maximum number of entries (server default when omitted).
|
|
498
|
+
* @returns The deltas, or `null` when there are none (HTTP 204).
|
|
499
|
+
* @throws {@link ConfigurationError} when `realmId` is absent.
|
|
500
|
+
* @throws {@link OAuthFlowError} on a non-2xx response or a network failure.
|
|
501
|
+
*/
|
|
502
|
+
async svDelta(serviceToken, since, limit) {
|
|
503
|
+
this.requireRealmId("svDelta");
|
|
504
|
+
const url = new URL(`${this.issuerUrl}/oauth/session-versions`);
|
|
505
|
+
url.searchParams.set("since", String(since));
|
|
506
|
+
if (limit !== undefined)
|
|
507
|
+
url.searchParams.set("limit", String(limit));
|
|
508
|
+
return this.getWithBearer(url.toString(), serviceToken);
|
|
379
509
|
}
|
|
380
510
|
// ── Private helpers ──────────────────────────────────────────────────────
|
|
511
|
+
requireClientId(method) {
|
|
512
|
+
if (!this.clientId)
|
|
513
|
+
throw new ConfigurationError(`clientId is required for ${method}()`);
|
|
514
|
+
return this.clientId;
|
|
515
|
+
}
|
|
516
|
+
requireRealmId(method) {
|
|
517
|
+
if (!this.realmId)
|
|
518
|
+
throw new ConfigurationError(`realmId is required for ${method}()`);
|
|
519
|
+
return this.realmId;
|
|
520
|
+
}
|
|
521
|
+
/** `client_id`, plus `client_secret` when this is a confidential client. */
|
|
522
|
+
clientAuthParams(method) {
|
|
523
|
+
const params = { client_id: this.requireClientId(method) };
|
|
524
|
+
if (this.clientSecret)
|
|
525
|
+
params.client_secret = this.clientSecret;
|
|
526
|
+
return params;
|
|
527
|
+
}
|
|
528
|
+
/** Read an endpoint URL from the discovery document. */
|
|
529
|
+
async endpoint(field) {
|
|
530
|
+
const value = (await this.discover())[field];
|
|
531
|
+
if (typeof value !== "string" || value === "") {
|
|
532
|
+
throw new ConfigurationError(`${field} not found in OIDC discovery document`);
|
|
533
|
+
}
|
|
534
|
+
return value;
|
|
535
|
+
}
|
|
536
|
+
/** `fetch` with the configured timeout; a network failure becomes `OAuthFlowError(0)`. */
|
|
537
|
+
async send(url, init) {
|
|
538
|
+
try {
|
|
539
|
+
return await fetch(url, { ...init, signal: AbortSignal.timeout(this.httpTimeout) });
|
|
540
|
+
}
|
|
541
|
+
catch (err) {
|
|
542
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
543
|
+
throw new OAuthFlowError(0, "request_failed", `Request to ${url} failed: ${detail}`);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
381
546
|
async postForm(endpoint, params) {
|
|
382
|
-
const resp = await
|
|
547
|
+
const resp = await this.send(endpoint, {
|
|
383
548
|
method: "POST",
|
|
384
549
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
385
550
|
body: new URLSearchParams(params).toString(),
|
|
386
|
-
signal: AbortSignal.timeout(this.httpTimeout),
|
|
387
551
|
});
|
|
388
|
-
if (!resp.ok)
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
}
|
|
398
|
-
throw new OAuthFlowError(resp.status, errorCode);
|
|
552
|
+
if (!resp.ok)
|
|
553
|
+
throw await oauthFlowError(resp);
|
|
554
|
+
return resp.json();
|
|
555
|
+
}
|
|
556
|
+
/** GET with a bearer token, for endpoints that must return a body. */
|
|
557
|
+
async getRequired(url, token) {
|
|
558
|
+
const result = await this.getWithBearer(url, token);
|
|
559
|
+
if (result === null) {
|
|
560
|
+
throw new OAuthFlowError(204, "no_content", `${url} answered 204 No Content`);
|
|
399
561
|
}
|
|
562
|
+
return result;
|
|
563
|
+
}
|
|
564
|
+
/** GET with a bearer token; `null` on 204 No Content. */
|
|
565
|
+
async getWithBearer(url, token) {
|
|
566
|
+
const headers = { Authorization: `Bearer ${token}` };
|
|
567
|
+
if (this.realmId)
|
|
568
|
+
headers["X-Realm-ID"] = this.realmId;
|
|
569
|
+
const resp = await this.send(url, { headers });
|
|
570
|
+
if (resp.status === 204)
|
|
571
|
+
return null;
|
|
572
|
+
if (!resp.ok)
|
|
573
|
+
throw await oauthFlowError(resp);
|
|
400
574
|
return resp.json();
|
|
401
575
|
}
|
|
402
576
|
}
|
|
577
|
+
/**
|
|
578
|
+
* Build an {@link OAuthFlowError} from a non-2xx response, taking `error` and
|
|
579
|
+
* `error_description` from an RFC 6749 §5.2 JSON body when there is one.
|
|
580
|
+
*/
|
|
581
|
+
async function oauthFlowError(resp) {
|
|
582
|
+
let errorCode = `HTTP ${resp.status}`;
|
|
583
|
+
let description;
|
|
584
|
+
try {
|
|
585
|
+
const parsed = (await resp.json());
|
|
586
|
+
if (typeof parsed["error"] === "string")
|
|
587
|
+
errorCode = parsed["error"];
|
|
588
|
+
if (typeof parsed["error_description"] === "string") {
|
|
589
|
+
description = parsed["error_description"];
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
catch {
|
|
593
|
+
/* body is not JSON */
|
|
594
|
+
}
|
|
595
|
+
const message = `OAuth flow error ${resp.status}: ${errorCode}${description ? ` (${description})` : ""}`;
|
|
596
|
+
return new OAuthFlowError(resp.status, errorCode, message);
|
|
597
|
+
}
|
|
403
598
|
//# sourceMappingURL=hearth-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hearth-client.js","sourceRoot":"","sources":["../src/hearth-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAA4B,MAAM,2BAA2B,CAAC;AAkE1F;;;;;;;;;GASG;AACH,MAAM,OAAO,YAAY;IACvB,0CAA0C;IACjC,SAAS,CAAS;IAClB,QAAQ,CAAqB;IAC7B,YAAY,CAAqB;IACjC,OAAO,CAAqB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AAc,CAAC,IAAI,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,IAAI,EAAgB,CAAC;IACnC,CAAC;CACF;AAED;;;GAGG;AACH,KAAK,UAAU,cAAc,CAAC,IAAc;IAC1C,IAAI,SAAS,GAAG,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;IACtC,IAAI,WAA+B,CAAC;IACpC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAA4B,CAAC;QAC9D,IAAI,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,QAAQ;YAAE,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;QACrE,IAAI,OAAO,MAAM,CAAC,mBAAmB,CAAC,KAAK,QAAQ,EAAE,CAAC;YACpD,WAAW,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,sBAAsB;IACxB,CAAC;IACD,MAAM,OAAO,GAAG,oBAAoB,IAAI,CAAC,MAAM,KAAK,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,WAAW,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACzG,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAC7D,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
export { HearthClient } from "./hearth-client.js";
|
|
2
2
|
export { generateCodeVerifier, generateCodeChallenge, buildAuthorizationUrl, startLogin, } from "./pkce.js";
|
|
3
3
|
export type { BuildAuthorizationUrlOptions, AuthorizationUrlResult, StartLoginOptions, StartLoginResult, } from "./pkce.js";
|
|
4
|
-
export type { HearthClientConfig } from "./hearth-client.js";
|
|
4
|
+
export type { HearthClientConfig, OidcConfiguration } from "./hearth-client.js";
|
|
5
5
|
export { JwksClient } from "./jwks-client.js";
|
|
6
6
|
export type { JwksClientConfig, VerifyOptions } from "./jwks-client.js";
|
|
7
7
|
export { IntrospectionClient } from "./introspection-client.js";
|
|
8
8
|
export type { IntrospectionClientConfig, IntrospectionResult } from "./introspection-client.js";
|
|
9
|
-
export { AuthorizationModeMismatchError, ConfigurationError, DiscoveryError, HearthSdkError, IntrospectionError, JWKSFetchError, OAuthFlowError, RequiredActionError, SessionVersionCacheStaleError, SessionVersionRevokedError, TokenAudienceError, TokenExpiredError, TokenInvalidError, TokenIssuerError, TokenNotYetValidError, } from "./errors.js";
|
|
10
|
-
export { requirePermission } from "./middleware.js";
|
|
11
|
-
export type { PermissionChecker, RequirePermissionOptions } from "./middleware.js";
|
|
9
|
+
export { AuthorizationModeMismatchError, ConfigurationError, DiscoveryError, HearthSdkError, IntrospectionError, JWKSFetchError, OAuthFlowError, RequiredActionError, SessionVersionCacheStaleError, SessionVersionRevokedError, TokenAudienceError, TokenExpiredError, TokenInvalidError, TokenIssuerError, TokenNotYetValidError, TokenVerificationError, } from "./errors.js";
|
|
10
|
+
export { assertMiddlewareOptions, authenticateRequest, hearthFastifyHook, hearthMiddleware, requirePermission, } from "./middleware.js";
|
|
11
|
+
export type { FastifyReplyLike, FastifyRequestLike, HearthAuthErrorBody, HearthAuthResult, HearthMiddlewareOptions, MiddlewareRequest, MiddlewareResponse, PermissionChecker, RequirePermissionOptions, } from "./middleware.js";
|
|
12
12
|
export { Claims } from "./claims.js";
|
|
13
13
|
export { HearthApiClient, HearthError } from "./client.js";
|
|
14
14
|
export type { HearthApiClientConfig, HandleCallbackParams } from "./client.js";
|
|
15
15
|
export { AdminClient } from "./admin.js";
|
|
16
|
+
export type { AdminApplication, AdminGroup, AdminRole, CreateApplicationParams, CreateGroupParams, CreateOrganizationParams, CreateRoleParams, Organization, UpdateApplicationParams, UpdateGroupParams, UpdateOrganizationParams, UpdateRoleParams, } from "./admin.js";
|
|
16
17
|
export { createHearth } from "./hearth.js";
|
|
17
18
|
export type { HearthFacade, HearthHttpClient, HearthOptions } from "./hearth.js";
|
|
18
19
|
export { HearthContext, HearthProvider, useHasPermission, useHasRole, useInGroup, useInOrg, } from "./react.js";
|
|
19
20
|
export type { HearthProviderProps } from "./react.js";
|
|
20
|
-
export type { AccessTokenAuthorizationMode, AuthorizeParams, AuthorizePermissionOptions, AuthorizeResponse, BootstrapResponse, CreateUserParams, JwksDocument, JsonWebKey, MePermissionsResponse, OAuthClient, PageResponse, RegisterClientParams, Realm, SessionVersionConfig, StepUpAssertion, StepUpProof, TokenExchangeParams, DeviceAuthorizationResponse, TokenResponse, UpdateRealmParams, UpdateUserParams, User, UserInfoResponse, WebAuthnAllowCredential, WebAuthnRegistrationBeginResponse, WebAuthnRegistrationCompleteRequest, WebAuthnRegistrationCompleteResponse, WebAuthnAuthenticationBeginResponse, WebAuthnAuthenticationCompleteRequest, } from "./types.js";
|
|
21
|
+
export type { AccessTokenAuthorizationMode, AuthorizeParams, AuthorizePermissionOptions, AuthorizeResponse, BootstrapResponse, CreateUserParams, ExchangeCodeOptions, JwksDocument, JsonWebKey, LoginBeginResult, MePermissionsResponse, OAuthClient, PageOptions, PageResponse, RegisterClientParams, Realm, SessionVersionConfig, StepUpAssertion, StepUpProof, SvDeltaEntry, SvDeltaResponse, SvSnapshotResponse, TokenExchangeParams, DeviceAuthorizationResponse, TokenResponse, UpdateRealmParams, UpdateUserParams, UserStatus, User, UserInfoResponse, WebAuthnAllowCredential, WebAuthnRegistrationBeginResponse, WebAuthnRegistrationCompleteRequest, WebAuthnRegistrationCompleteResponse, WebAuthnAuthenticationBeginResponse, WebAuthnAuthenticationCompleteRequest, } from "./types.js";
|
|
21
22
|
export { SessionVersionCache } from "./session-version-cache.js";
|
|
22
23
|
export { getAccessToken, getRefreshToken, getIdToken, isAuthenticated, clearTokens, createHearthAuth, } from "./browser-auth.js";
|
|
23
24
|
export type { AuthConfig, HearthBrowserAuth } from "./browser-auth.js";
|
package/dist/index.js
CHANGED
|
@@ -6,9 +6,10 @@ export { generateCodeVerifier, generateCodeChallenge, buildAuthorizationUrl, sta
|
|
|
6
6
|
export { JwksClient } from "./jwks-client.js";
|
|
7
7
|
export { IntrospectionClient } from "./introspection-client.js";
|
|
8
8
|
// Error types (spec §5).
|
|
9
|
-
export { AuthorizationModeMismatchError, ConfigurationError, DiscoveryError, HearthSdkError, IntrospectionError, JWKSFetchError, OAuthFlowError, RequiredActionError, SessionVersionCacheStaleError, SessionVersionRevokedError, TokenAudienceError, TokenExpiredError, TokenInvalidError, TokenIssuerError, TokenNotYetValidError, } from "./errors.js";
|
|
10
|
-
// Mode-aware middleware (HEA-923).
|
|
11
|
-
|
|
9
|
+
export { AuthorizationModeMismatchError, ConfigurationError, DiscoveryError, HearthSdkError, IntrospectionError, JWKSFetchError, OAuthFlowError, RequiredActionError, SessionVersionCacheStaleError, SessionVersionRevokedError, TokenAudienceError, TokenExpiredError, TokenInvalidError, TokenIssuerError, TokenNotYetValidError, TokenVerificationError, } from "./errors.js";
|
|
10
|
+
// Mode-aware permission checks and request middleware (HEA-923).
|
|
11
|
+
// Next.js helpers live at `@hearth-auth/sdk/nextjs` and `@hearth-auth/sdk/nextjs/edge`.
|
|
12
|
+
export { assertMiddlewareOptions, authenticateRequest, hearthFastifyHook, hearthMiddleware, requirePermission, } from "./middleware.js";
|
|
12
13
|
// Claims API (spec §4).
|
|
13
14
|
export { Claims } from "./claims.js";
|
|
14
15
|
// Lower-level API client (kept for backwards-compatibility).
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,qCAAqC;AACrC,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,UAAU,GACX,MAAM,WAAW,CAAC;AASnB,mDAAmD;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;A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Y,CAAC;AAezC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EACL,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,QAAQ,GACT,MAAM,YAAY,CAAC;AAwCpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,0DAA0D;AAC1D,OAAO,EACL,cAAc,EACd,eAAe,EACf,UAAU,EACV,eAAe,EACf,WAAW,EACX,gBAAgB,GACjB,MAAM,mBAAmB,CAAC"}
|
|
@@ -46,7 +46,7 @@ export interface IntrospectionClientConfig {
|
|
|
46
46
|
* Low-level RFC 7662 token introspection client.
|
|
47
47
|
*
|
|
48
48
|
* Results are never cached — per RFC 7662 §2.1, token state can change
|
|
49
|
-
* at any time.
|
|
49
|
+
* at any time.
|
|
50
50
|
*/
|
|
51
51
|
export declare class IntrospectionClient {
|
|
52
52
|
private readonly endpoint;
|
|
@@ -54,6 +54,12 @@ export declare class IntrospectionClient {
|
|
|
54
54
|
private readonly clientSecret;
|
|
55
55
|
readonly httpTimeout: number;
|
|
56
56
|
constructor(config: IntrospectionClientConfig);
|
|
57
|
-
/**
|
|
58
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Introspect a token. Never cached per RFC 7662 §2.1.
|
|
59
|
+
*
|
|
60
|
+
* @param tokenTypeHint - Optional RFC 7662 `token_type_hint`.
|
|
61
|
+
* @throws {@link IntrospectionError} when the request fails, the endpoint
|
|
62
|
+
* answers non-2xx, or the response is not JSON.
|
|
63
|
+
*/
|
|
64
|
+
introspect(token: string, tokenTypeHint?: "access_token" | "refresh_token"): Promise<IntrospectionResult>;
|
|
59
65
|
}
|