@udibo/oauth2 0.4.0 → 0.5.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/README.md +3 -3
- package/SECURITY.md +0 -4
- package/esm/adapters/hono/_common.d.ts +10 -13
- package/esm/adapters/hono/_common.js +11 -20
- package/esm/adapters/hono/authorization-server.d.ts +16 -10
- package/esm/adapters/hono/authorization-server.js +13 -8
- package/esm/adapters/hono/bff/auth-request-store.d.ts +4 -0
- package/esm/adapters/hono/bff/auth-request-store.js +4 -0
- package/esm/adapters/hono/bff/bff.d.ts +29 -18
- package/esm/adapters/hono/bff/bff.js +15 -11
- package/esm/adapters/hono/bff/proxy.js +7 -55
- package/esm/adapters/hono/bff/session-store.d.ts +9 -9
- package/esm/adapters/hono/bff/session-store.js +3 -2
- package/esm/adapters/hono/bff/testing.d.ts +14 -3
- package/esm/adapters/hono/bff/testing.js +14 -3
- package/esm/adapters/hono/identity.d.ts +5 -3
- package/esm/adapters/hono/identity.js +1 -17
- package/esm/adapters/hono/resource-server.d.ts +3 -2
- package/esm/adapters/hono/resource-server.js +3 -2
- package/esm/client/_http.d.ts +4 -7
- package/esm/client/_http.js +4 -37
- package/esm/client/base.d.ts +3 -6
- package/esm/client/bff-client.d.ts +7 -6
- package/esm/client/bff-client.js +7 -6
- package/esm/client/browser-storage.d.ts +33 -34
- package/esm/client/browser-storage.js +47 -32
- package/esm/client/check.d.ts +10 -3
- package/esm/client/check.js +28 -8
- package/esm/client/direct-client.d.ts +49 -29
- package/esm/client/direct-client.js +59 -59
- package/esm/client/discovery-cache.d.ts +12 -5
- package/esm/client/discovery-cache.js +11 -4
- package/esm/client/events.d.ts +11 -3
- package/esm/client/events.js +1 -1
- package/esm/client/mod.d.ts +6 -4
- package/esm/client/mod.js +5 -3
- package/esm/client/storage.d.ts +53 -23
- package/esm/client/storage.js +43 -15
- package/esm/errors.d.ts +15 -12
- package/esm/errors.js +12 -8
- package/esm/identity/delivery.d.ts +7 -7
- package/esm/identity/delivery.js +1 -2
- package/esm/identity/errors.d.ts +10 -4
- package/esm/identity/errors.js +4 -1
- package/esm/identity/events.d.ts +21 -5
- package/esm/identity/events.js +4 -2
- package/esm/identity/external/_shared.d.ts +5 -7
- package/esm/identity/external/_shared.js +5 -7
- package/esm/identity/external/_token-exchange.d.ts +3 -6
- package/esm/identity/external/_token-exchange.js +2 -5
- package/esm/identity/external/apple-client-secret.d.ts +13 -8
- package/esm/identity/external/apple-client-secret.js +9 -6
- package/esm/identity/external/apple.d.ts +17 -10
- package/esm/identity/external/apple.js +12 -9
- package/esm/identity/external/discord.d.ts +5 -1
- package/esm/identity/external/errors.d.ts +6 -2
- package/esm/identity/external/errors.js +6 -2
- package/esm/identity/external/flow.d.ts +9 -6
- package/esm/identity/external/flow.js +6 -5
- package/esm/identity/external/github.d.ts +7 -3
- package/esm/identity/external/github.js +2 -2
- package/esm/identity/external/google.d.ts +5 -1
- package/esm/identity/external/oauth2.d.ts +13 -2
- package/esm/identity/external/oauth2.js +3 -3
- package/esm/identity/external/oidc.d.ts +21 -10
- package/esm/identity/external/oidc.js +11 -6
- package/esm/identity/external/provider.d.ts +4 -2
- package/esm/identity/identifier.d.ts +6 -5
- package/esm/identity/identifier.js +6 -5
- package/esm/identity/lockout.d.ts +4 -3
- package/esm/identity/lockout.js +4 -3
- package/esm/identity/mfa/mod.d.ts +2 -1
- package/esm/identity/mfa/mod.js +2 -1
- package/esm/identity/mfa/recovery-codes.d.ts +2 -1
- package/esm/identity/mfa/service.d.ts +29 -11
- package/esm/identity/mfa/service.js +35 -11
- package/esm/identity/mfa/totp.d.ts +4 -2
- package/esm/identity/mfa/totp.js +4 -2
- package/esm/identity/migration.d.ts +8 -7
- package/esm/identity/migration.js +9 -12
- package/esm/identity/mod.d.ts +2 -2
- package/esm/identity/mod.js +2 -2
- package/esm/identity/otp.d.ts +23 -16
- package/esm/identity/otp.js +13 -12
- package/esm/identity/password-policy.d.ts +3 -3
- package/esm/identity/password-policy.js +3 -3
- package/esm/identity/password.d.ts +23 -20
- package/esm/identity/password.js +15 -16
- package/esm/identity/rate-limit.d.ts +1 -7
- package/esm/identity/rate-limit.js +1 -2
- package/esm/identity/service.d.ts +76 -44
- package/esm/identity/service.js +86 -60
- package/esm/identity/session.d.ts +5 -4
- package/esm/identity/session.js +5 -4
- package/esm/identity/token-flow.d.ts +8 -8
- package/esm/identity/token-flow.js +5 -6
- package/esm/models/client.d.ts +7 -4
- package/esm/models/token.d.ts +2 -3
- package/esm/react/callback.d.ts +3 -3
- package/esm/react/callback.js +3 -3
- package/esm/react/components/class-names.d.ts +3 -6
- package/esm/react/components/class-names.js +3 -6
- package/esm/react/components/internal.d.ts +7 -17
- package/esm/react/components/internal.js +7 -17
- package/esm/react/components/mod.d.ts +7 -5
- package/esm/react/components/mod.js +7 -5
- package/esm/react/components/types.d.ts +8 -6
- package/esm/react/context.d.ts +3 -3
- package/esm/react/provider.d.ts +3 -2
- package/esm/react/provider.js +0 -13
- package/esm/react/require-auth.d.ts +0 -3
- package/esm/react/require-auth.js +0 -3
- package/esm/react/testing.d.ts +3 -2
- package/esm/react/testing.js +3 -3
- package/esm/react/use-oauth2.d.ts +1 -1
- package/esm/server/authorization-server.d.ts +81 -54
- package/esm/server/authorization-server.js +76 -100
- package/esm/server/grants/authorization-code.d.ts +7 -3
- package/esm/server/grants/authorization-code.js +6 -2
- package/esm/server/grants/device-authorization.d.ts +1 -1
- package/esm/server/grants/grant.d.ts +15 -8
- package/esm/server/grants/grant.js +26 -18
- package/esm/server/grants/password.d.ts +1 -1
- package/esm/server/grants/refresh-token.d.ts +6 -3
- package/esm/server/grants/refresh-token.js +4 -3
- package/esm/server/introspection-token-reader.d.ts +16 -7
- package/esm/server/introspection-token-reader.js +9 -3
- package/esm/server/jwks-token-reader.d.ts +3 -3
- package/esm/server/jwks-token-reader.js +3 -3
- package/esm/server/public-suffix/rules.d.ts +4 -4
- package/esm/server/public-suffix/rules.js +4 -4
- package/esm/server/redirect-uri.d.ts +6 -9
- package/esm/server/redirect-uri.js +7 -34
- package/esm/server/resource-server.d.ts +5 -3
- package/esm/server/resource-server.js +5 -3
- package/esm/server/services/client.d.ts +5 -1
- package/esm/server/services/device-authorization.d.ts +6 -6
- package/esm/server/services/token.d.ts +15 -8
- package/esm/server/services/token.js +1 -1
- package/esm/server/signing-keys.d.ts +24 -9
- package/esm/server/signing-keys.js +20 -9
- package/esm/testing/contract/mod.d.ts +3 -3
- package/esm/testing/contract/mod.js +3 -3
- package/esm/testing/mod.d.ts +4 -2
- package/esm/testing/mod.js +4 -2
- package/esm/testing/services.d.ts +1 -1
- package/esm/testing/services.js +1 -1
- package/esm/testing/tenant.d.ts +13 -4
- package/esm/utils/_buffer.d.ts +3 -2
- package/esm/utils/_buffer.js +3 -2
- package/esm/utils/_timing-safe.d.ts +8 -6
- package/esm/utils/_timing-safe.js +8 -6
- package/esm/utils/basic-auth.d.ts +5 -12
- package/esm/utils/basic-auth.js +5 -12
- package/esm/utils/crypto.d.ts +2 -1
- package/esm/utils/crypto.js +2 -1
- package/esm/utils/text.d.ts +2 -9
- package/esm/utils/text.js +2 -9
- package/esm/utils/url.d.ts +2 -2
- package/esm/utils/url.js +0 -2
- package/package.json +1 -1
|
@@ -40,8 +40,9 @@ export class RefreshTokenGrant extends AbstractGrant {
|
|
|
40
40
|
* authorization.
|
|
41
41
|
*
|
|
42
42
|
* @throws {InvalidRequestError} If `refresh_token` is missing.
|
|
43
|
-
* @throws {InvalidGrantError} If the refresh token is unknown or expired,
|
|
44
|
-
*
|
|
43
|
+
* @throws {InvalidGrantError} If the refresh token is unknown or expired, its
|
|
44
|
+
* family has outlived the absolute cap, or a concurrent exchange already
|
|
45
|
+
* claimed it.
|
|
45
46
|
* @throws {InvalidClientError} If the token was issued to another client.
|
|
46
47
|
* @throws {InvalidScopeError} If the requested scope exceeds the original grant.
|
|
47
48
|
*/
|
|
@@ -98,7 +99,7 @@ export class RefreshTokenGrant extends AbstractGrant {
|
|
|
98
99
|
if (familyExpiresAt && familyExpiresAt.getTime() <= Date.now()) {
|
|
99
100
|
throw new InvalidGrantError("refresh_token family expired");
|
|
100
101
|
}
|
|
101
|
-
const nextToken = await this.generateToken(client, user, nextScope, tokenService, currentToken.authenticationContext);
|
|
102
|
+
const nextToken = await this.generateToken(client, user, nextScope, tokenService, currentToken.authenticationContext, familyExpiresAt);
|
|
102
103
|
const nextRefreshToken = "refreshToken" in nextToken
|
|
103
104
|
? nextToken
|
|
104
105
|
: {
|
|
@@ -46,10 +46,13 @@ export interface IntrospectionTokenReaderOptions<Client extends ClientInterface,
|
|
|
46
46
|
* `undefined` when the token doesn't represent a user. Omit entirely if
|
|
47
47
|
* your app never reads user info off the token.
|
|
48
48
|
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
49
|
+
* This package's authorization server sets `sub` from its `subjectOf`
|
|
50
|
+
* option (the user's `id` by default — the same value its id_token and
|
|
51
|
+
* UserInfo carry) and omits it for a token with no user, whatever its
|
|
52
|
+
* `introspectionClaims` hook returns, so `data.sub` is present only when
|
|
53
|
+
* there is a resource owner and `data.sub ? {…} : undefined` is the whole
|
|
54
|
+
* discriminator. Another authorization server may set `sub` to the client
|
|
55
|
+
* id for a machine token; check how yours answers.
|
|
53
56
|
*
|
|
54
57
|
* May be async — return a promise to enrich from a DB lookup or the
|
|
55
58
|
* authorization server's OIDC UserInfo endpoint, using `data.sub` as
|
|
@@ -81,6 +84,11 @@ export interface IntrospectionTokenReaderOptions<Client extends ClientInterface,
|
|
|
81
84
|
* types via the {@linkcode IntrospectionTokenReaderOptions.getClient} and
|
|
82
85
|
* {@linkcode IntrospectionTokenReaderOptions.getUser} mappers.
|
|
83
86
|
*
|
|
87
|
+
* The reader does not check `aud` or `iss`: any token the endpoint reports
|
|
88
|
+
* active with a bearer `token_type` is accepted. When one authorization server
|
|
89
|
+
* issues tokens for several APIs, check the audience yourself (it is on
|
|
90
|
+
* {@linkcode Token.claims}) or have the endpoint scope its answers.
|
|
91
|
+
*
|
|
84
92
|
* @example
|
|
85
93
|
* ```ts
|
|
86
94
|
* import {
|
|
@@ -137,9 +145,10 @@ export declare class IntrospectionTokenReader<Client extends ClientInterface, Us
|
|
|
137
145
|
* returns a 5xx — a down authorization server must be distinguishable from
|
|
138
146
|
* a genuinely invalid token (which is `undefined` → `invalid_token`), not
|
|
139
147
|
* collapsed into it.
|
|
140
|
-
* @throws {ServerError} If the endpoint returns
|
|
141
|
-
* introspection credentials are rejected)
|
|
142
|
-
* verdict on the caller's
|
|
148
|
+
* @throws {ServerError} If the endpoint returns any other non-2xx status
|
|
149
|
+
* (e.g. the reader's own introspection credentials are rejected) or a body
|
|
150
|
+
* that is not JSON — a misconfiguration, not a verdict on the caller's
|
|
151
|
+
* token.
|
|
143
152
|
*
|
|
144
153
|
* An active response is only accepted when its `token_type` names a bearer
|
|
145
154
|
* token. RFC 7662 answers for refresh tokens too, and a refresh token's
|
|
@@ -22,6 +22,11 @@ import { encodeBasicAuth } from "../utils/basic-auth.js";
|
|
|
22
22
|
* types via the {@linkcode IntrospectionTokenReaderOptions.getClient} and
|
|
23
23
|
* {@linkcode IntrospectionTokenReaderOptions.getUser} mappers.
|
|
24
24
|
*
|
|
25
|
+
* The reader does not check `aud` or `iss`: any token the endpoint reports
|
|
26
|
+
* active with a bearer `token_type` is accepted. When one authorization server
|
|
27
|
+
* issues tokens for several APIs, check the audience yourself (it is on
|
|
28
|
+
* {@linkcode Token.claims}) or have the endpoint scope its answers.
|
|
29
|
+
*
|
|
25
30
|
* @example
|
|
26
31
|
* ```ts
|
|
27
32
|
* import {
|
|
@@ -87,9 +92,10 @@ export class IntrospectionTokenReader {
|
|
|
87
92
|
* returns a 5xx — a down authorization server must be distinguishable from
|
|
88
93
|
* a genuinely invalid token (which is `undefined` → `invalid_token`), not
|
|
89
94
|
* collapsed into it.
|
|
90
|
-
* @throws {ServerError} If the endpoint returns
|
|
91
|
-
* introspection credentials are rejected)
|
|
92
|
-
* verdict on the caller's
|
|
95
|
+
* @throws {ServerError} If the endpoint returns any other non-2xx status
|
|
96
|
+
* (e.g. the reader's own introspection credentials are rejected) or a body
|
|
97
|
+
* that is not JSON — a misconfiguration, not a verdict on the caller's
|
|
98
|
+
* token.
|
|
93
99
|
*
|
|
94
100
|
* An active response is only accepted when its `token_type` names a bearer
|
|
95
101
|
* token. RFC 7662 answers for refresh tokens too, and a refresh token's
|
|
@@ -255,9 +255,9 @@ export declare class JwksTokenReader<Client extends ClientInterface, User, S ext
|
|
|
255
255
|
* available — a down issuer must be distinguishable from a genuinely
|
|
256
256
|
* invalid token, not collapsed into it. Once keys are cached, a failed
|
|
257
257
|
* refresh is absorbed and the cached keys keep serving.
|
|
258
|
-
* @throws {ServerError} If the JWKS endpoint returns
|
|
259
|
-
* is not a JWKS, or discovery reports no `jwks_uri`
|
|
260
|
-
* misconfiguration, not a verdict on the caller's token.
|
|
258
|
+
* @throws {ServerError} If, with no keys cached, the JWKS endpoint returns
|
|
259
|
+
* a 4xx or a body that is not a JWKS, or discovery reports no `jwks_uri`
|
|
260
|
+
* — a misconfiguration, not a verdict on the caller's token.
|
|
261
261
|
*/
|
|
262
262
|
getToken(accessToken: string): Promise<Token<Client, User, S> | undefined>;
|
|
263
263
|
}
|
|
@@ -276,9 +276,9 @@ export class JwksTokenReader {
|
|
|
276
276
|
* available — a down issuer must be distinguishable from a genuinely
|
|
277
277
|
* invalid token, not collapsed into it. Once keys are cached, a failed
|
|
278
278
|
* refresh is absorbed and the cached keys keep serving.
|
|
279
|
-
* @throws {ServerError} If the JWKS endpoint returns
|
|
280
|
-
* is not a JWKS, or discovery reports no `jwks_uri`
|
|
281
|
-
* misconfiguration, not a verdict on the caller's token.
|
|
279
|
+
* @throws {ServerError} If, with no keys cached, the JWKS endpoint returns
|
|
280
|
+
* a 4xx or a body that is not a JWKS, or discovery reports no `jwks_uri`
|
|
281
|
+
* — a misconfiguration, not a verdict on the caller's token.
|
|
282
282
|
*/
|
|
283
283
|
async getToken(accessToken) {
|
|
284
284
|
const parsed = parseJws(accessToken);
|