@better-auth/oauth-provider 1.7.9 → 1.8.0-beta.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/dist/{authorize-D8r6mvZx.mjs → authorize-92EtLsBi.mjs} +735 -502
- package/dist/client-resource.d.mts +1 -1
- package/dist/client-resource.mjs +2 -2
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +1 -1
- package/dist/index-sGnh4IfY.d.mts +275 -0
- package/dist/index.d.mts +4 -203
- package/dist/index.mjs +198 -41
- package/dist/internal.d.mts +108 -40
- package/dist/internal.mjs +4 -2
- package/dist/{introspect-7WCMPe5Z.mjs → introspect-CEo9Q06v.mjs} +318 -237
- package/dist/{oauth-DAMtT2vg.d.mts → oauth-BlEuA8oD.d.mts} +380 -20
- package/dist/{oauth-BWgg8X-A.d.mts → oauth-mdkaIwmm.d.mts} +191 -86
- package/dist/{utils-DKU5wblX.mjs → utils-BMNe8Sg2.mjs} +343 -5
- package/dist/{version-DVUrz-nv.mjs → version-DeABnmP9.mjs} +1 -1
- package/package.json +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as ResourceServerMetadata } from "./oauth-
|
|
1
|
+
import { c as ResourceServerMetadata } from "./oauth-BlEuA8oD.mjs";
|
|
2
2
|
import { ResourceRequestInput, VerifyAccessTokenRequestOptions } from "better-auth/oauth2";
|
|
3
3
|
import { JWTPayload, JWTVerifyOptions } from "jose";
|
|
4
4
|
import { BetterAuthOptions } from "better-auth/types";
|
package/dist/client-resource.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as PACKAGE_VERSION } from "./version-
|
|
1
|
+
import { f as getJwtPlugin, p as getOAuthProviderPlugin } from "./utils-BMNe8Sg2.mjs";
|
|
2
|
+
import { t as PACKAGE_VERSION } from "./version-DeABnmP9.mjs";
|
|
3
3
|
import { t as createResourceServerChallenge } from "./resource-challenge-Damwi0Or.mjs";
|
|
4
4
|
import { APIError } from "better-call";
|
|
5
5
|
import { BetterAuthError } from "@better-auth/core/error";
|
package/dist/client.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as oauthDeviceAuthorization, r as oauthProvider } from "./oauth-mdkaIwmm.mjs";
|
|
2
2
|
import * as _$_better_fetch_fetch0 from "@better-fetch/fetch";
|
|
3
3
|
|
|
4
4
|
//#region src/client.d.ts
|
package/dist/client.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as buildSignedOAuthQuery } from "./signed-query-Df1MNiSH.mjs";
|
|
2
|
-
import { t as PACKAGE_VERSION } from "./version-
|
|
2
|
+
import { t as PACKAGE_VERSION } from "./version-DeABnmP9.mjs";
|
|
3
3
|
import { safeJSONParse } from "@better-auth/core/utils/json";
|
|
4
4
|
import { deviceAuthorizationClient } from "better-auth/client/plugins";
|
|
5
5
|
//#region src/client.ts
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { J as Scope, K as Prompt, L as OAuthOptions, R as OAuthProviderApi, a as GrantType, l as TokenEndpointAuthMethod, n as AuthServerMetadata, q as SchemaClient, rt as Awaitable, z as OAuthProviderExtension } from "./oauth-BlEuA8oD.mjs";
|
|
2
|
+
import { APIError } from "better-call";
|
|
3
|
+
import { JWSAlgorithms, JwtOptions } from "better-auth/plugins";
|
|
4
|
+
import { JWTPayload } from "jose";
|
|
5
|
+
import { User } from "better-auth/types";
|
|
6
|
+
import { AuthContext, GenericEndpointContext } from "@better-auth/core";
|
|
7
|
+
import * as _$better_auth0 from "better-auth";
|
|
8
|
+
//#region src/extensions.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Registers an {@link OAuthProviderExtension} with the OAuth Provider plugin
|
|
11
|
+
* from a companion plugin's `init()` hook. An extension can add token grants,
|
|
12
|
+
* assertion-based client authentication methods, additive discovery metadata,
|
|
13
|
+
* access-token / ID-token / UserInfo claims, and client-id discovery, without
|
|
14
|
+
* forking provider core.
|
|
15
|
+
*
|
|
16
|
+
* Call this once, at `init()` time. It is idempotent in the same `extension`
|
|
17
|
+
* object, so re-running a plugin's `init()` (for example when one plugin factory
|
|
18
|
+
* result is shared across two `betterAuth()` instances) does not register it
|
|
19
|
+
* twice. It throws if the oauth-provider plugin is not installed, if a grant
|
|
20
|
+
* type or assertion type is not an absolute URI, if a client authentication
|
|
21
|
+
* method reuses a built-in name, or if the extension registers a grant type,
|
|
22
|
+
* auth method, assertion type, or client discovery identifier that another
|
|
23
|
+
* extension already registered (contributions must be disjoint).
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* init(ctx) {
|
|
28
|
+
* extendOAuthProvider(ctx, {
|
|
29
|
+
* grants: { "urn:example:grant": async ({ provider }) => provider.issueTokens(...) },
|
|
30
|
+
* });
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
declare function extendOAuthProvider(ctx: AuthContext, extension: OAuthProviderExtension): void;
|
|
35
|
+
/** Registration fields that extensions define, stored in the client's `metadata`. */
|
|
36
|
+
declare function getExtensionClientMetadataFields(opts: OAuthOptions<Scope[]>): Set<string>;
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/metadata.d.ts
|
|
39
|
+
declare function authServerMetadata(ctx: GenericEndpointContext, opts?: JwtOptions, overrides?: {
|
|
40
|
+
scopes_supported?: AuthServerMetadata["scopes_supported"];
|
|
41
|
+
dynamic_client_registration_supported?: boolean;
|
|
42
|
+
public_client_supported?: boolean;
|
|
43
|
+
grant_types_supported?: GrantType[];
|
|
44
|
+
token_endpoint_auth_methods_supported?: TokenEndpointAuthMethod[];
|
|
45
|
+
endpoint_auth_methods_supported?: TokenEndpointAuthMethod[];
|
|
46
|
+
jwt_disabled?: boolean;
|
|
47
|
+
dpop_signing_alg_values_supported?: JWSAlgorithms[];
|
|
48
|
+
}): AuthServerMetadata;
|
|
49
|
+
declare function oauthAuthorizationServerMetadata(ctx: GenericEndpointContext, opts: OAuthOptions<Scope[]>): AuthServerMetadata;
|
|
50
|
+
declare function oidcServerMetadata(ctx: GenericEndpointContext, opts: OAuthOptions<Scope[]> & {
|
|
51
|
+
claims?: string[];
|
|
52
|
+
}): {
|
|
53
|
+
jwks_uri?: string | undefined;
|
|
54
|
+
userinfo_endpoint: string;
|
|
55
|
+
acr_values_supported?: string[] | undefined;
|
|
56
|
+
subject_types_supported: ("public" | "pairwise")[];
|
|
57
|
+
claims_supported: string[];
|
|
58
|
+
claims_parameter_supported?: boolean | undefined;
|
|
59
|
+
end_session_endpoint: string;
|
|
60
|
+
request_parameter_supported?: boolean | undefined;
|
|
61
|
+
request_uri_parameter_supported?: boolean | undefined;
|
|
62
|
+
prompt_values_supported: Prompt[];
|
|
63
|
+
issuer: string;
|
|
64
|
+
authorization_endpoint: string;
|
|
65
|
+
token_endpoint: string;
|
|
66
|
+
registration_endpoint?: string | undefined;
|
|
67
|
+
scopes_supported?: string[] | undefined;
|
|
68
|
+
response_types_supported: "code"[];
|
|
69
|
+
response_modes_supported: "query"[];
|
|
70
|
+
grant_types_supported: GrantType[];
|
|
71
|
+
token_endpoint_auth_methods_supported?: TokenEndpointAuthMethod[] | undefined;
|
|
72
|
+
token_endpoint_auth_signing_alg_values_supported?: _$better_auth0.PrivateKeyJwtSigningAlgorithm[] | undefined;
|
|
73
|
+
service_documentation?: string | undefined;
|
|
74
|
+
ui_locales_supported?: string[] | undefined;
|
|
75
|
+
op_policy_uri?: string | undefined;
|
|
76
|
+
op_tos_uri?: string | undefined;
|
|
77
|
+
revocation_endpoint?: string | undefined;
|
|
78
|
+
revocation_endpoint_auth_methods_supported?: TokenEndpointAuthMethod[] | undefined;
|
|
79
|
+
revocation_endpoint_auth_signing_alg_values_supported?: _$better_auth0.PrivateKeyJwtSigningAlgorithm[] | undefined;
|
|
80
|
+
introspection_endpoint?: string | undefined;
|
|
81
|
+
introspection_endpoint_auth_methods_supported?: TokenEndpointAuthMethod[] | undefined;
|
|
82
|
+
introspection_endpoint_auth_signing_alg_values_supported?: _$better_auth0.PrivateKeyJwtSigningAlgorithm[] | undefined;
|
|
83
|
+
code_challenge_methods_supported: "S256"[];
|
|
84
|
+
authorization_response_iss_parameter_supported?: boolean | undefined;
|
|
85
|
+
client_id_metadata_document_supported?: boolean | undefined;
|
|
86
|
+
backchannel_logout_supported?: boolean | undefined;
|
|
87
|
+
backchannel_logout_session_supported?: boolean | undefined;
|
|
88
|
+
dpop_signing_alg_values_supported?: JWSAlgorithms[] | undefined;
|
|
89
|
+
frontchannel_logout_supported?: boolean | undefined;
|
|
90
|
+
frontchannel_logout_session_supported?: boolean | undefined;
|
|
91
|
+
id_token_signing_alg_values_supported: JWSAlgorithms[] | ["HS256"];
|
|
92
|
+
};
|
|
93
|
+
declare function metadataResponse(body: unknown, extraHeaders?: HeadersInit): Response;
|
|
94
|
+
/**
|
|
95
|
+
* Provides an exportable `/.well-known/oauth-authorization-server`.
|
|
96
|
+
*
|
|
97
|
+
* Useful when basePath prevents the endpoint from being located at the root
|
|
98
|
+
* and must be provided manually.
|
|
99
|
+
*
|
|
100
|
+
* @external
|
|
101
|
+
*/
|
|
102
|
+
declare const oauthProviderAuthServerMetadata: <Auth extends {
|
|
103
|
+
api: {
|
|
104
|
+
getOAuthServerConfig: (...args: any) => any;
|
|
105
|
+
};
|
|
106
|
+
}>(auth: Auth, opts?: {
|
|
107
|
+
headers?: HeadersInit;
|
|
108
|
+
}) => (request: Request) => Promise<Response>;
|
|
109
|
+
/**
|
|
110
|
+
* Provides an exportable `/.well-known/openid-configuration`.
|
|
111
|
+
*
|
|
112
|
+
* Useful when basePath prevents the endpoint from being located at the root
|
|
113
|
+
* and must be provided manually.
|
|
114
|
+
*
|
|
115
|
+
* @external
|
|
116
|
+
*/
|
|
117
|
+
declare const oauthProviderOpenIdConfigMetadata: <Auth extends {
|
|
118
|
+
api: {
|
|
119
|
+
getOpenIdConfig: (...args: any) => any;
|
|
120
|
+
};
|
|
121
|
+
}>(auth: Auth, opts?: {
|
|
122
|
+
headers?: HeadersInit;
|
|
123
|
+
}) => (request: Request) => Promise<Response>;
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/resource-challenge.d.ts
|
|
126
|
+
/**
|
|
127
|
+
* Create an OAuth resource-server challenge for a failed access-token request.
|
|
128
|
+
*
|
|
129
|
+
* Missing/invalid bearer credentials are reported with RFC 6750 plus the RFC
|
|
130
|
+
* 9728 `resource_metadata` pointer. Insufficient-scope failures (built with
|
|
131
|
+
* `createInsufficientScopeError`) are reported with RFC 6750 §3.1's
|
|
132
|
+
* `insufficient_scope` challenge on a 403 naming the scopes the token lacks, so
|
|
133
|
+
* clients can step up their authorization. DPoP-bound-token failures are
|
|
134
|
+
* reported with RFC 9449's `DPoP` challenge so clients know which proof
|
|
135
|
+
* algorithms to use. Non-URL resources (for example a `urn:` or a client id)
|
|
136
|
+
* resolve their metadata URL through `resourceMetadataMappings`.
|
|
137
|
+
*
|
|
138
|
+
* Every other error returns `undefined`, including a plain `FORBIDDEN`: a
|
|
139
|
+
* permission denial that re-authorizing cannot fix must not be answered with a
|
|
140
|
+
* challenge that sends the user through consent for scopes they already hold.
|
|
141
|
+
*
|
|
142
|
+
* @external
|
|
143
|
+
*/
|
|
144
|
+
declare function createResourceServerChallenge(error: unknown, resource: string | string[], opts?: {
|
|
145
|
+
/** Maps non-URL (urn, client) resources to their resource_metadata URL. */resourceMetadataMappings?: Record<string, string>; /** DPoP JWS algorithms to advertise in RFC 9449 challenges. */
|
|
146
|
+
dpopSigningAlgorithms?: readonly string[];
|
|
147
|
+
/**
|
|
148
|
+
* Scopes to advertise in RFC 6750 bearer challenges,
|
|
149
|
+
* hinting what an unauthenticated client should request. An
|
|
150
|
+
* insufficient-scope failure advertises the scopes it names instead.
|
|
151
|
+
*/
|
|
152
|
+
challengeScopes?: readonly string[];
|
|
153
|
+
}): APIError | undefined;
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/token.d.ts
|
|
156
|
+
/**
|
|
157
|
+
* Returns the OAuth Provider's server-side capability surface bound to `ctx`.
|
|
158
|
+
* The token endpoint passes one (pre-bound to the dispatched grant) to each
|
|
159
|
+
* extension grant handler; a companion plugin's own endpoint calls this directly
|
|
160
|
+
* with its grant type. `grantType` is bound here, not per issuance, so a handler
|
|
161
|
+
* cannot mislabel the grant; omit it for capabilities that do not issue tokens
|
|
162
|
+
* (`getClient`, `validateAccessToken`, `requireActiveAccessToken`), and
|
|
163
|
+
* `issueTokens` then throws.
|
|
164
|
+
*/
|
|
165
|
+
declare function getOAuthProviderApi(ctx: GenericEndpointContext, opts: OAuthOptions<Scope[]>, grantType?: GrantType): OAuthProviderApi;
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/token-exchange.d.ts
|
|
168
|
+
/** RFC 8693 §2.1 token exchange grant type. */
|
|
169
|
+
declare const TOKEN_EXCHANGE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:token-exchange";
|
|
170
|
+
/** RFC 8693 §3 token type identifier for an OAuth 2.0 access token. */
|
|
171
|
+
declare const ACCESS_TOKEN_TYPE = "urn:ietf:params:oauth:token-type:access_token";
|
|
172
|
+
interface OAuthTokenExchangeRequest {
|
|
173
|
+
/** The authenticated client requesting the exchange. */
|
|
174
|
+
client: SchemaClient<Scope[]>;
|
|
175
|
+
/** The user the subject token represents, and the issued token's `sub`. */
|
|
176
|
+
user: User;
|
|
177
|
+
/** The validated subject token, in RFC 7662 introspection form. */
|
|
178
|
+
subjectToken: JWTPayload;
|
|
179
|
+
/** Resource identifiers the issued token is requested for. */
|
|
180
|
+
resources: string[];
|
|
181
|
+
/** Scopes the issued token is requested with. */
|
|
182
|
+
scopes: string[];
|
|
183
|
+
/**
|
|
184
|
+
* Consent reference (`postLogin.consentReferenceId`) the subject token was
|
|
185
|
+
* issued under, such as an organization. The issued token keeps it.
|
|
186
|
+
*/
|
|
187
|
+
referenceId?: string;
|
|
188
|
+
}
|
|
189
|
+
interface OAuthTokenExchangeOptions {
|
|
190
|
+
/**
|
|
191
|
+
* Final policy check, run after every built-in check passes. Return `false`
|
|
192
|
+
* to deny the exchange with `invalid_request`, or throw an `APIError` for a
|
|
193
|
+
* different OAuth error.
|
|
194
|
+
*/
|
|
195
|
+
allowExchange?: (request: OAuthTokenExchangeRequest) => Awaitable<boolean>;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* RFC 8693 token exchange for the OAuth Provider. A confidential client
|
|
199
|
+
* registered for the token-exchange grant trades a user's access token, issued
|
|
200
|
+
* by this server to it or for a resource it serves, for an access token to
|
|
201
|
+
* another registered resource. The issued token represents the same user
|
|
202
|
+
* (impersonation), carries the requesting client as `client_id`, and expires
|
|
203
|
+
* no later than the subject token.
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```ts
|
|
207
|
+
* const auth = betterAuth({
|
|
208
|
+
* plugins: [jwt(), oauthProvider({ ... }), oauthTokenExchange()],
|
|
209
|
+
* });
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
declare function oauthTokenExchange(options?: OAuthTokenExchangeOptions): {
|
|
213
|
+
id: string;
|
|
214
|
+
init(ctx: AuthContext): void;
|
|
215
|
+
};
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region src/utils/index.d.ts
|
|
218
|
+
/**
|
|
219
|
+
* Normalizes OAuth resource values into a non-empty string array.
|
|
220
|
+
*/
|
|
221
|
+
declare function toResourceList(value: string | string[] | undefined): string[] | undefined;
|
|
222
|
+
/**
|
|
223
|
+
* Verify the signature and expiration of an OAuth query issued by this provider.
|
|
224
|
+
* Use the provider's current auth secret on the server before displaying a
|
|
225
|
+
* consent page. A valid signature does not replace client or session checks.
|
|
226
|
+
*/
|
|
227
|
+
declare function verifyOAuthQueryParams(oauth_query: string, secret: string): Promise<boolean>;
|
|
228
|
+
/**
|
|
229
|
+
* Validates requested scopes against a registered client's allowed scopes.
|
|
230
|
+
*
|
|
231
|
+
* @internal
|
|
232
|
+
*/
|
|
233
|
+
declare function validateClientScopes(client: Pick<SchemaClient<Scope[]>, "scopes">, scopes?: string[]): void;
|
|
234
|
+
/**
|
|
235
|
+
* Parse client metadata that may be stored as JSON string or already parsed object.
|
|
236
|
+
* Handles database adapters that auto-parse JSON columns.
|
|
237
|
+
*
|
|
238
|
+
* @internal
|
|
239
|
+
*/
|
|
240
|
+
declare function parseClientMetadata(metadata: string | object | undefined): Record<string, unknown> | undefined;
|
|
241
|
+
//#endregion
|
|
242
|
+
//#region src/utils/client-assertion.d.ts
|
|
243
|
+
/**
|
|
244
|
+
* Enforces the assertion-hygiene claims every client-assertion authentication
|
|
245
|
+
* method must check, independent of how the signature is verified or where the
|
|
246
|
+
* verification keys come from:
|
|
247
|
+
* - `aud` MUST include `expectedAudience` (RFC 7523 §3 rule 3),
|
|
248
|
+
* - `exp` MUST be present, unexpired, and at most `assertionMaxLifetime`
|
|
249
|
+
* seconds away (RFC 7523 §3 rule 4),
|
|
250
|
+
* - `iat`, when present, MUST be within `assertionMaxLifetime`,
|
|
251
|
+
* - `jti` MUST be present and single-use; this consumes a replay tombstone keyed
|
|
252
|
+
* by `` `${namespace}:${jti}` ``, inserted under the adapter's primary key so a
|
|
253
|
+
* replay across workers fails atomically.
|
|
254
|
+
*
|
|
255
|
+
* A custom {@link OAuthClientAuthenticationStrategy} should call this after
|
|
256
|
+
* verifying the assertion signature, so an extension method inherits the same
|
|
257
|
+
* replay, lifetime, and audience guarantees as the built-in `private_key_jwt`
|
|
258
|
+
* path, which calls it too.
|
|
259
|
+
*
|
|
260
|
+
* @param params.namespace Scopes the replay tombstone to the method and client,
|
|
261
|
+
* e.g. `` `${method}:${clientId}` ``, so the same `jti` can recur across
|
|
262
|
+
* distinct methods or clients but never within one.
|
|
263
|
+
*/
|
|
264
|
+
declare function consumeClientAssertion(ctx: GenericEndpointContext, opts: OAuthOptions<Scope[]>, params: {
|
|
265
|
+
namespace: string;
|
|
266
|
+
payload: {
|
|
267
|
+
aud?: unknown;
|
|
268
|
+
exp?: unknown;
|
|
269
|
+
iat?: unknown;
|
|
270
|
+
jti?: unknown;
|
|
271
|
+
};
|
|
272
|
+
expectedAudience: string;
|
|
273
|
+
}): Promise<void>;
|
|
274
|
+
//#endregion
|
|
275
|
+
export { oauthProviderOpenIdConfigMetadata as _, verifyOAuthQueryParams as a, getExtensionClientMetadataFields as b, OAuthTokenExchangeRequest as c, getOAuthProviderApi as d, createResourceServerChallenge as f, oauthProviderAuthServerMetadata as g, oauthAuthorizationServerMetadata as h, validateClientScopes as i, TOKEN_EXCHANGE_GRANT_TYPE as l, metadataResponse as m, parseClientMetadata as n, ACCESS_TOKEN_TYPE as o, authServerMetadata as p, toResourceList as r, OAuthTokenExchangeOptions as s, consumeClientAssertion as t, oauthTokenExchange as u, oidcServerMetadata as v, extendOAuthProvider as y };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,203 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { AuthContext, GenericEndpointContext } from "@better-auth/core";
|
|
6
|
-
import * as _$better_auth0 from "better-auth";
|
|
7
|
-
//#region src/extensions.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* Registers an {@link OAuthProviderExtension} with the OAuth Provider plugin
|
|
10
|
-
* from a companion plugin's `init()` hook. An extension can add token grants,
|
|
11
|
-
* assertion-based client authentication methods, additive discovery metadata,
|
|
12
|
-
* access-token / ID-token / UserInfo claims, and client-id discovery, without
|
|
13
|
-
* forking provider core.
|
|
14
|
-
*
|
|
15
|
-
* Call this once, at `init()` time. It is idempotent in the same `extension`
|
|
16
|
-
* object, so re-running a plugin's `init()` (for example when one plugin factory
|
|
17
|
-
* result is shared across two `betterAuth()` instances) does not register it
|
|
18
|
-
* twice. It throws if the oauth-provider plugin is not installed, if a grant
|
|
19
|
-
* type or assertion type is not an absolute URI, if a client authentication
|
|
20
|
-
* method reuses a built-in name, or if the extension registers a grant type,
|
|
21
|
-
* auth method, assertion type, or client discovery identifier that another
|
|
22
|
-
* extension already registered (contributions must be disjoint).
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* init(ctx) {
|
|
27
|
-
* extendOAuthProvider(ctx, {
|
|
28
|
-
* grants: { "urn:example:grant": async ({ provider }) => provider.issueTokens(...) },
|
|
29
|
-
* });
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
declare function extendOAuthProvider(ctx: AuthContext, extension: OAuthProviderExtension): void;
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/metadata.d.ts
|
|
36
|
-
declare function authServerMetadata(ctx: GenericEndpointContext, opts?: JwtOptions, overrides?: {
|
|
37
|
-
scopes_supported?: AuthServerMetadata["scopes_supported"];
|
|
38
|
-
dynamic_client_registration_supported?: boolean;
|
|
39
|
-
public_client_supported?: boolean;
|
|
40
|
-
grant_types_supported?: GrantType[];
|
|
41
|
-
token_endpoint_auth_methods_supported?: TokenEndpointAuthMethod[];
|
|
42
|
-
endpoint_auth_methods_supported?: TokenEndpointAuthMethod[];
|
|
43
|
-
jwt_disabled?: boolean;
|
|
44
|
-
dpop_signing_alg_values_supported?: JWSAlgorithms[];
|
|
45
|
-
}): AuthServerMetadata;
|
|
46
|
-
declare function oauthAuthorizationServerMetadata(ctx: GenericEndpointContext, opts: OAuthOptions<Scope[]>): AuthServerMetadata;
|
|
47
|
-
declare function oidcServerMetadata(ctx: GenericEndpointContext, opts: OAuthOptions<Scope[]> & {
|
|
48
|
-
claims?: string[];
|
|
49
|
-
}): {
|
|
50
|
-
jwks_uri?: string | undefined;
|
|
51
|
-
userinfo_endpoint: string;
|
|
52
|
-
acr_values_supported?: string[] | undefined;
|
|
53
|
-
subject_types_supported: ("public" | "pairwise")[];
|
|
54
|
-
claims_supported: string[];
|
|
55
|
-
claims_parameter_supported?: boolean | undefined;
|
|
56
|
-
end_session_endpoint: string;
|
|
57
|
-
request_parameter_supported?: boolean | undefined;
|
|
58
|
-
request_uri_parameter_supported?: boolean | undefined;
|
|
59
|
-
prompt_values_supported: Prompt[];
|
|
60
|
-
issuer: string;
|
|
61
|
-
authorization_endpoint: string;
|
|
62
|
-
token_endpoint: string;
|
|
63
|
-
registration_endpoint?: string | undefined;
|
|
64
|
-
scopes_supported?: string[] | undefined;
|
|
65
|
-
response_types_supported: "code"[];
|
|
66
|
-
response_modes_supported: "query"[];
|
|
67
|
-
grant_types_supported: GrantType[];
|
|
68
|
-
token_endpoint_auth_methods_supported?: TokenEndpointAuthMethod[] | undefined;
|
|
69
|
-
token_endpoint_auth_signing_alg_values_supported?: _$better_auth0.PrivateKeyJwtSigningAlgorithm[] | undefined;
|
|
70
|
-
service_documentation?: string | undefined;
|
|
71
|
-
ui_locales_supported?: string[] | undefined;
|
|
72
|
-
op_policy_uri?: string | undefined;
|
|
73
|
-
op_tos_uri?: string | undefined;
|
|
74
|
-
revocation_endpoint?: string | undefined;
|
|
75
|
-
revocation_endpoint_auth_methods_supported?: TokenEndpointAuthMethod[] | undefined;
|
|
76
|
-
revocation_endpoint_auth_signing_alg_values_supported?: _$better_auth0.PrivateKeyJwtSigningAlgorithm[] | undefined;
|
|
77
|
-
introspection_endpoint?: string | undefined;
|
|
78
|
-
introspection_endpoint_auth_methods_supported?: TokenEndpointAuthMethod[] | undefined;
|
|
79
|
-
introspection_endpoint_auth_signing_alg_values_supported?: _$better_auth0.PrivateKeyJwtSigningAlgorithm[] | undefined;
|
|
80
|
-
code_challenge_methods_supported: "S256"[];
|
|
81
|
-
authorization_response_iss_parameter_supported?: boolean | undefined;
|
|
82
|
-
client_id_metadata_document_supported?: boolean | undefined;
|
|
83
|
-
backchannel_logout_supported?: boolean | undefined;
|
|
84
|
-
backchannel_logout_session_supported?: boolean | undefined;
|
|
85
|
-
dpop_signing_alg_values_supported?: JWSAlgorithms[] | undefined;
|
|
86
|
-
id_token_signing_alg_values_supported: JWSAlgorithms[] | ["HS256"];
|
|
87
|
-
};
|
|
88
|
-
declare function metadataResponse(body: unknown, extraHeaders?: HeadersInit): Response;
|
|
89
|
-
/**
|
|
90
|
-
* Provides an exportable `/.well-known/oauth-authorization-server`.
|
|
91
|
-
*
|
|
92
|
-
* Useful when basePath prevents the endpoint from being located at the root
|
|
93
|
-
* and must be provided manually.
|
|
94
|
-
*
|
|
95
|
-
* @external
|
|
96
|
-
*/
|
|
97
|
-
declare const oauthProviderAuthServerMetadata: <Auth extends {
|
|
98
|
-
api: {
|
|
99
|
-
getOAuthServerConfig: (...args: any) => any;
|
|
100
|
-
};
|
|
101
|
-
}>(auth: Auth, opts?: {
|
|
102
|
-
headers?: HeadersInit;
|
|
103
|
-
}) => (request: Request) => Promise<Response>;
|
|
104
|
-
/**
|
|
105
|
-
* Provides an exportable `/.well-known/openid-configuration`.
|
|
106
|
-
*
|
|
107
|
-
* Useful when basePath prevents the endpoint from being located at the root
|
|
108
|
-
* and must be provided manually.
|
|
109
|
-
*
|
|
110
|
-
* @external
|
|
111
|
-
*/
|
|
112
|
-
declare const oauthProviderOpenIdConfigMetadata: <Auth extends {
|
|
113
|
-
api: {
|
|
114
|
-
getOpenIdConfig: (...args: any) => any;
|
|
115
|
-
};
|
|
116
|
-
}>(auth: Auth, opts?: {
|
|
117
|
-
headers?: HeadersInit;
|
|
118
|
-
}) => (request: Request) => Promise<Response>;
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region src/resource-challenge.d.ts
|
|
121
|
-
/**
|
|
122
|
-
* Create an OAuth resource-server challenge for a failed access-token request.
|
|
123
|
-
*
|
|
124
|
-
* Missing/invalid bearer credentials are reported with RFC 6750 plus the RFC
|
|
125
|
-
* 9728 `resource_metadata` pointer. Insufficient-scope failures (built with
|
|
126
|
-
* `createInsufficientScopeError`) are reported with RFC 6750 §3.1's
|
|
127
|
-
* `insufficient_scope` challenge on a 403 naming the scopes the token lacks, so
|
|
128
|
-
* clients can step up their authorization. DPoP-bound-token failures are
|
|
129
|
-
* reported with RFC 9449's `DPoP` challenge so clients know which proof
|
|
130
|
-
* algorithms to use. Non-URL resources (for example a `urn:` or a client id)
|
|
131
|
-
* resolve their metadata URL through `resourceMetadataMappings`.
|
|
132
|
-
*
|
|
133
|
-
* Every other error returns `undefined`, including a plain `FORBIDDEN`: a
|
|
134
|
-
* permission denial that re-authorizing cannot fix must not be answered with a
|
|
135
|
-
* challenge that sends the user through consent for scopes they already hold.
|
|
136
|
-
*
|
|
137
|
-
* @external
|
|
138
|
-
*/
|
|
139
|
-
declare function createResourceServerChallenge(error: unknown, resource: string | string[], opts?: {
|
|
140
|
-
/** Maps non-URL (urn, client) resources to their resource_metadata URL. */resourceMetadataMappings?: Record<string, string>; /** DPoP JWS algorithms to advertise in RFC 9449 challenges. */
|
|
141
|
-
dpopSigningAlgorithms?: readonly string[];
|
|
142
|
-
/**
|
|
143
|
-
* Scopes to advertise in RFC 6750 bearer challenges,
|
|
144
|
-
* hinting what an unauthenticated client should request. An
|
|
145
|
-
* insufficient-scope failure advertises the scopes it names instead.
|
|
146
|
-
*/
|
|
147
|
-
challengeScopes?: readonly string[];
|
|
148
|
-
}): APIError | undefined;
|
|
149
|
-
//#endregion
|
|
150
|
-
//#region src/token.d.ts
|
|
151
|
-
/**
|
|
152
|
-
* Returns the OAuth Provider's server-side capability surface bound to `ctx`.
|
|
153
|
-
* The token endpoint passes one (pre-bound to the dispatched grant) to each
|
|
154
|
-
* extension grant handler; a companion plugin's own endpoint calls this directly
|
|
155
|
-
* with its grant type. `grantType` is bound here, not per issuance, so a handler
|
|
156
|
-
* cannot mislabel the grant; omit it for capabilities that do not issue tokens
|
|
157
|
-
* (`getClient`, `validateAccessToken`, `requireActiveAccessToken`), and
|
|
158
|
-
* `issueTokens` then throws.
|
|
159
|
-
*/
|
|
160
|
-
declare function getOAuthProviderApi(ctx: GenericEndpointContext, opts: OAuthOptions<Scope[]>, grantType?: GrantType): OAuthProviderApi;
|
|
161
|
-
//#endregion
|
|
162
|
-
//#region src/utils/index.d.ts
|
|
163
|
-
/**
|
|
164
|
-
* Verify the signature and expiration of an OAuth query issued by this provider.
|
|
165
|
-
* Use the provider's current auth secret on the server before displaying a
|
|
166
|
-
* consent page. A valid signature does not replace client or session checks.
|
|
167
|
-
*/
|
|
168
|
-
declare function verifyOAuthQueryParams(oauth_query: string, secret: string): Promise<boolean>;
|
|
169
|
-
//#endregion
|
|
170
|
-
//#region src/utils/client-assertion.d.ts
|
|
171
|
-
/**
|
|
172
|
-
* Enforces the assertion-hygiene claims every client-assertion authentication
|
|
173
|
-
* method must check, independent of how the signature is verified or where the
|
|
174
|
-
* verification keys come from:
|
|
175
|
-
* - `aud` MUST include `expectedAudience` (RFC 7523 §3 rule 3),
|
|
176
|
-
* - `exp` MUST be present, unexpired, and at most `assertionMaxLifetime`
|
|
177
|
-
* seconds away (RFC 7523 §3 rule 4),
|
|
178
|
-
* - `iat`, when present, MUST be within `assertionMaxLifetime`,
|
|
179
|
-
* - `jti` MUST be present and single-use; this consumes a replay tombstone keyed
|
|
180
|
-
* by `` `${namespace}:${jti}` ``, inserted under the adapter's primary key so a
|
|
181
|
-
* replay across workers fails atomically.
|
|
182
|
-
*
|
|
183
|
-
* A custom {@link OAuthClientAuthenticationStrategy} should call this after
|
|
184
|
-
* verifying the assertion signature, so an extension method inherits the same
|
|
185
|
-
* replay, lifetime, and audience guarantees as the built-in `private_key_jwt`
|
|
186
|
-
* path, which calls it too.
|
|
187
|
-
*
|
|
188
|
-
* @param params.namespace Scopes the replay tombstone to the method and client,
|
|
189
|
-
* e.g. `` `${method}:${clientId}` ``, so the same `jti` can recur across
|
|
190
|
-
* distinct methods or clients but never within one.
|
|
191
|
-
*/
|
|
192
|
-
declare function consumeClientAssertion(ctx: GenericEndpointContext, opts: OAuthOptions<Scope[]>, params: {
|
|
193
|
-
namespace: string;
|
|
194
|
-
payload: {
|
|
195
|
-
aud?: unknown;
|
|
196
|
-
exp?: unknown;
|
|
197
|
-
iat?: unknown;
|
|
198
|
-
jti?: unknown;
|
|
199
|
-
};
|
|
200
|
-
expectedAudience: string;
|
|
201
|
-
}): Promise<void>;
|
|
202
|
-
//#endregion
|
|
203
|
-
export { ActiveAccessTokenPayload, AuthMethod, AuthServerMetadata, AuthorizePrompt, BearerMethodsSupported, ClientDiscovery, ClientMetadataResourceFetch, ClientRegistrationRequest, Confirmation, DEFAULT_OAUTH_SCOPES, DEVICE_CODE_GRANT_TYPE, GrantType, InitialAccessTokenAuthorization, OAuthAuthenticatedClient, OAuthAuthorizationQuery, OAuthClaimExtensionInput, type OAuthClient, OAuthClientAdministrativeResponse, OAuthClientAuthenticationInput, OAuthClientAuthenticationRequest, OAuthClientAuthenticationResult, OAuthClientAuthenticationStrategy, type OAuthClientMetadata, OAuthClientRegistrationResponse, OAuthClientResource, OAuthConsent, type OAuthDeviceAuthorizationOptions, type OAuthEndpointErrorResult, type OAuthEndpointRedirectContext, type OAuthErrorCode, OAuthExtensionGrantHandler, OAuthExtensionGrantHandlerInput, type OAuthFieldErrorCode, type OAuthFieldErrorCodeMap, OAuthMetadataExtensionInput, OAuthOpaqueAccessToken, OAuthOptions, OAuthProviderApi, OAuthProviderExtension, type OAuthRedirectOnError, OAuthRefreshToken, OAuthResource, OAuthResourceInput, OAuthTokenIssueParams, OAuthTokenResponse, OAuthUserInfoExtensionInput, OIDCMetadata, Prompt, type ResourceServerMetadata, ResourceUriSchema, SchemaClient, Scope, StoreTokenType, StoredAuthorizationQuery, TokenEndpointAuthMethod, TokenType, VerificationValue, authServerMetadata, consumeClientAssertion, createResourceServerChallenge, extendOAuthProvider, getIssuer, getOAuthProviderApi, getOAuthProviderState, metadataResponse, oauthAuthorizationServerMetadata, oauthClientMetadataSchema, oauthDeviceAuthorization, oauthProvider, oauthProviderAuthServerMetadata, oauthProviderOpenIdConfigMetadata, oidcServerMetadata, verifyOAuthQueryParams };
|
|
1
|
+
import { $ as OAuthClientMetadata, A as OAuthExtensionGrantHandler, B as OAuthRefreshToken, C as OAuthClientAuthenticationRequest, D as OAuthClientRegistrationResponse, E as OAuthClientMetadataExtensionInput, F as OAuthMetadataExtensionInput, G as OAuthUserInfoExtensionInput, H as OAuthResourceInput, I as OAuthOpaqueAccessToken, J as Scope, K as Prompt, L as OAuthOptions, M as OAuthInteractionQuery, N as OAuthInteractionRequest, O as OAuthClientResource, P as OAuthInteractionRequestHandler, Q as ClientRegistrationRequest, R as OAuthProviderApi, S as OAuthClientAuthenticationInput, T as OAuthClientAuthenticationStrategy, U as OAuthTokenIssueParams, V as OAuthResource, W as OAuthTokenResponse, X as StoredAuthorizationQuery, Y as StoreTokenType, Z as VerificationValue, _ as OAuthAuthenticationContext, a as GrantType, b as OAuthClaimExtensionInput, c as ResourceServerMetadata, d as ActiveAccessTokenPayload, et as ResourceUriSchema, f as AuthorizePrompt, g as OAuthAuthenticatedClient, h as InitialAccessTokenAuthorization, i as Confirmation, it as OAuthClientRegistrationMetadata, j as OAuthExtensionGrantHandlerInput, k as OAuthConsent, l as TokenEndpointAuthMethod, m as ClientMetadataResourceFetch, n as AuthServerMetadata, nt as oauthClientMetadataSchema, o as OAuthClient, p as ClientDiscovery, q as SchemaClient, r as BearerMethodsSupported, s as OIDCMetadata, t as AuthMethod, u as TokenType, v as OAuthAuthenticationContextOptions, w as OAuthClientAuthenticationResult, x as OAuthClientAdministrativeResponse, y as OAuthAuthorizationQuery, z as OAuthProviderExtension } from "./oauth-BlEuA8oD.mjs";
|
|
2
|
+
import { c as OAuthEndpointRedirectContext, d as OAuthFieldErrorCodeMap, f as OAuthRedirectOnError, g as oauthDeviceAuthorization, h as OAuthDeviceAuthorizationOptions, l as OAuthErrorCode, m as DEVICE_CODE_GRANT_TYPE, n as getOAuthProviderState, o as getIssuer, r as oauthProvider, s as OAuthEndpointErrorResult, t as DEFAULT_OAUTH_SCOPES, u as OAuthFieldErrorCode } from "./oauth-mdkaIwmm.mjs";
|
|
3
|
+
import { _ as oauthProviderOpenIdConfigMetadata, a as verifyOAuthQueryParams, c as OAuthTokenExchangeRequest, d as getOAuthProviderApi, f as createResourceServerChallenge, g as oauthProviderAuthServerMetadata, h as oauthAuthorizationServerMetadata, l as TOKEN_EXCHANGE_GRANT_TYPE, m as metadataResponse, o as ACCESS_TOKEN_TYPE, p as authServerMetadata, s as OAuthTokenExchangeOptions, t as consumeClientAssertion, u as oauthTokenExchange, v as oidcServerMetadata, y as extendOAuthProvider } from "./index-sGnh4IfY.mjs";
|
|
4
|
+
export { ACCESS_TOKEN_TYPE, ActiveAccessTokenPayload, AuthMethod, AuthServerMetadata, AuthorizePrompt, BearerMethodsSupported, ClientDiscovery, ClientMetadataResourceFetch, ClientRegistrationRequest, Confirmation, DEFAULT_OAUTH_SCOPES, DEVICE_CODE_GRANT_TYPE, GrantType, InitialAccessTokenAuthorization, OAuthAuthenticatedClient, OAuthAuthenticationContext, OAuthAuthenticationContextOptions, OAuthAuthorizationQuery, OAuthClaimExtensionInput, OAuthClient, OAuthClientAdministrativeResponse, OAuthClientAuthenticationInput, OAuthClientAuthenticationRequest, OAuthClientAuthenticationResult, OAuthClientAuthenticationStrategy, OAuthClientMetadata, OAuthClientMetadataExtensionInput, OAuthClientRegistrationMetadata, OAuthClientRegistrationResponse, OAuthClientResource, OAuthConsent, OAuthDeviceAuthorizationOptions, OAuthEndpointErrorResult, OAuthEndpointRedirectContext, OAuthErrorCode, OAuthExtensionGrantHandler, OAuthExtensionGrantHandlerInput, OAuthFieldErrorCode, OAuthFieldErrorCodeMap, OAuthInteractionQuery, OAuthInteractionRequest, OAuthInteractionRequestHandler, OAuthMetadataExtensionInput, OAuthOpaqueAccessToken, OAuthOptions, OAuthProviderApi, OAuthProviderExtension, OAuthRedirectOnError, OAuthRefreshToken, OAuthResource, OAuthResourceInput, OAuthTokenExchangeOptions, OAuthTokenExchangeRequest, OAuthTokenIssueParams, OAuthTokenResponse, OAuthUserInfoExtensionInput, OIDCMetadata, Prompt, ResourceServerMetadata, ResourceUriSchema, SchemaClient, Scope, StoreTokenType, StoredAuthorizationQuery, TOKEN_EXCHANGE_GRANT_TYPE, TokenEndpointAuthMethod, TokenType, VerificationValue, authServerMetadata, consumeClientAssertion, createResourceServerChallenge, extendOAuthProvider, getIssuer, getOAuthProviderApi, getOAuthProviderState, metadataResponse, oauthAuthorizationServerMetadata, oauthClientMetadataSchema, oauthDeviceAuthorization, oauthProvider, oauthProviderAuthServerMetadata, oauthProviderOpenIdConfigMetadata, oauthTokenExchange, oidcServerMetadata, verifyOAuthQueryParams };
|