@better-auth/oauth-provider 1.7.0-beta.2 → 1.7.0-beta.4

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.
@@ -1,6 +1,6 @@
1
- import { a as getClient } from "./utils-Cx_XnD9i.mjs";
1
+ import { a as getClient } from "./utils-DKBWQ8fe.mjs";
2
2
  import { APIError } from "better-call";
3
- import { ASSERTION_SIGNING_ALGORITHMS, CLIENT_ASSERTION_TYPE } from "@better-auth/core/oauth2";
3
+ import { CLIENT_ASSERTION_TYPE, PRIVATE_KEY_JWT_SIGNING_ALGORITHMS } from "@better-auth/core/oauth2";
4
4
  import { createLocalJWKSet, decodeJwt, decodeProtectedHeader, jwtVerify } from "jose";
5
5
  //#region \0rolldown/runtime.js
6
6
  var __defProp = Object.defineProperty;
@@ -33,7 +33,7 @@ function setJwksCache(uri, jwks, fetchedAt) {
33
33
  if (oldest !== void 0) jwksCache.delete(oldest);
34
34
  }
35
35
  }
36
- const ALGORITHMS_LIST = [...ASSERTION_SIGNING_ALGORITHMS];
36
+ const ALGORITHMS_LIST = [...PRIVATE_KEY_JWT_SIGNING_ALGORITHMS];
37
37
  const pendingAssertionIds = /* @__PURE__ */ new Set();
38
38
  /**
39
39
  * Block SSRF: reject jwks_uri pointing at private/reserved IP ranges.
@@ -160,7 +160,7 @@ async function verifyClientAssertion(ctx, opts, clientAssertion, clientAssertion
160
160
  error: "invalid_client"
161
161
  });
162
162
  }
163
- if (!header.alg || !ASSERTION_SIGNING_ALGORITHMS.includes(header.alg)) throw new APIError("BAD_REQUEST", {
163
+ if (!header.alg || !ALGORITHMS_LIST.includes(header.alg)) throw new APIError("BAD_REQUEST", {
164
164
  error_description: `unsupported assertion signing algorithm: ${header.alg}`,
165
165
  error: "invalid_client"
166
166
  });
@@ -1,9 +1,16 @@
1
- import { o as ResourceServerMetadata } from "./oauth-CU79t-eG.mjs";
1
+ import { s as ResourceServerMetadata } from "./oauth-q7dn10NU.mjs";
2
2
  import { JWTPayload, JWTVerifyOptions } from "jose";
3
- import { Auth } from "better-auth/types";
3
+ import { BetterAuthOptions } from "better-auth/types";
4
4
 
5
5
  //#region src/client-resource.d.ts
6
- declare const oauthProviderResourceClient: <T extends Auth | undefined>(auth?: T) => {
6
+ type ResourceClientAuth = {
7
+ options: {
8
+ baseURL?: BetterAuthOptions["baseURL"];
9
+ basePath?: BetterAuthOptions["basePath"];
10
+ };
11
+ $context: Promise<unknown>;
12
+ };
13
+ declare const oauthProviderResourceClient: <T extends ResourceClientAuth | undefined = undefined>(auth?: T) => {
7
14
  id: "oauth-provider-resource-client";
8
15
  version: string;
9
16
  getActions(): {
@@ -43,7 +50,7 @@ interface VerifyAccessTokenRemote {
43
50
  */
44
51
  force?: boolean;
45
52
  }
46
- type VerifyAccessTokenOutput<T> = T extends Auth ? (token: string | undefined, opts?: VerifyAccessTokenAuthOpts) => Promise<JWTPayload> : (token: string | undefined, opts: VerifyAccessTokenNoAuthOpts) => Promise<JWTPayload>;
53
+ type VerifyAccessTokenOutput<T> = T extends undefined ? (token: string | undefined, opts: VerifyAccessTokenNoAuthOpts) => Promise<JWTPayload> : (token: string | undefined, opts?: VerifyAccessTokenAuthOpts) => Promise<JWTPayload>;
47
54
  type VerifyAccessTokenAuthOpts = {
48
55
  verifyOptions?: JWTVerifyOptions & Required<Pick<JWTVerifyOptions, "audience">>;
49
56
  scopes?: string[];
@@ -64,12 +71,12 @@ type VerifyAccessTokenNoAuthOpts = {
64
71
  remoteVerify: VerifyAccessTokenRemote; /** Maps non-url (ie urn, client) resources to resource_metadata */
65
72
  resourceMetadataMappings?: Record<string, string>;
66
73
  };
67
- type ProtectedResourceMetadataOutput<T> = T extends Auth ? (overrides?: Partial<ResourceServerMetadata>, opts?: {
74
+ type ProtectedResourceMetadataOutput<T> = T extends undefined ? (overrides: ResourceServerMetadata, opts?: {
68
75
  silenceWarnings?: {
69
76
  oidcScopes?: boolean;
70
77
  };
71
78
  externalScopes?: string[];
72
- }) => Promise<ResourceServerMetadata> : (overrides: ResourceServerMetadata, opts?: {
79
+ }) => Promise<ResourceServerMetadata> : (overrides?: Partial<ResourceServerMetadata>, opts?: {
73
80
  silenceWarnings?: {
74
81
  oidcScopes?: boolean;
75
82
  };
@@ -1,6 +1,6 @@
1
1
  import { t as handleMcpErrors } from "./mcp-CYnz-MXn.mjs";
2
- import { o as getJwtPlugin, s as getOAuthProviderPlugin } from "./utils-Cx_XnD9i.mjs";
3
- import { t as PACKAGE_VERSION } from "./version-CZxZ64qJ.mjs";
2
+ import { o as getJwtPlugin, s as getOAuthProviderPlugin } from "./utils-DKBWQ8fe.mjs";
3
+ import { t as PACKAGE_VERSION } from "./version-nFnRm-a3.mjs";
4
4
  import { verifyAccessToken } from "better-auth/oauth2";
5
5
  import { APIError } from "better-call";
6
6
  import { logger } from "@better-auth/core/env";
package/dist/client.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as oauthProvider } from "./oauth-DJcZ8MMZ.mjs";
1
+ import { n as oauthProvider } from "./oauth-Vt3lTNHX.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,4 +1,4 @@
1
- import { t as PACKAGE_VERSION } from "./version-CZxZ64qJ.mjs";
1
+ import { t as PACKAGE_VERSION } from "./version-nFnRm-a3.mjs";
2
2
  import { safeJSONParse } from "@better-auth/core/utils/json";
3
3
  //#region src/client.ts
4
4
  function parseSignedQuery(search) {
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { _ as Scope, a as OIDCMetadata, b as Awaitable, c as AuthorizePrompt, d as OAuthConsent, f as OAuthOpaqueAccessToken, g as SchemaClient, h as Prompt, i as OAuthClient, l as ClientDiscovery, m as OAuthRefreshToken, n as AuthServerMetadata, o as ResourceServerMetadata, p as OAuthOptions, r as GrantType, s as TokenEndpointAuthMethod, t as AuthMethod, u as OAuthAuthorizationQuery, v as StoreTokenType, y as VerificationValue } from "./oauth-CU79t-eG.mjs";
2
- import { a as OAuthErrorCode, c as OAuthRedirectOnError, i as OAuthEndpointRedirectContext, n as oauthProvider, o as OAuthFieldErrorCode, r as OAuthEndpointErrorResult, s as OAuthFieldErrorCodeMap, t as getOAuthProviderState } from "./oauth-DJcZ8MMZ.mjs";
1
+ import { _ as SchemaClient, a as OAuthClient, b as VerificationValue, c as TokenEndpointAuthMethod, d as OAuthAuthorizationQuery, f as OAuthConsent, g as Prompt, h as OAuthRefreshToken, i as GrantType, l as AuthorizePrompt, m as OAuthOptions, n as AuthServerMetadata, o as OIDCMetadata, p as OAuthOpaqueAccessToken, r as BearerMethodsSupported, s as ResourceServerMetadata, t as AuthMethod, u as ClientDiscovery, v as Scope, x as Awaitable, y as StoreTokenType } from "./oauth-q7dn10NU.mjs";
2
+ import { a as OAuthErrorCode, c as OAuthRedirectOnError, i as OAuthEndpointRedirectContext, n as oauthProvider, o as OAuthFieldErrorCode, r as OAuthEndpointErrorResult, s as OAuthFieldErrorCodeMap, t as getOAuthProviderState } from "./oauth-Vt3lTNHX.mjs";
3
3
  import { verifyAccessToken } from "better-auth/oauth2";
4
4
  import { JWSAlgorithms, JwtOptions } from "better-auth/plugins";
5
5
  import { JWTPayload } from "jose";
@@ -22,6 +22,7 @@ verifyOptions: Parameters<typeof verifyAccessToken>[1], handler: (req: Request,
22
22
  //#region src/metadata.d.ts
23
23
  declare function authServerMetadata(ctx: GenericEndpointContext, opts?: JwtOptions, overrides?: {
24
24
  scopes_supported?: AuthServerMetadata["scopes_supported"];
25
+ dynamic_client_registration_supported?: boolean;
25
26
  public_client_supported?: boolean;
26
27
  grant_types_supported?: GrantType[];
27
28
  jwt_disabled?: boolean;
@@ -39,23 +40,23 @@ declare function oidcServerMetadata(ctx: GenericEndpointContext, opts: OAuthOpti
39
40
  issuer: string;
40
41
  authorization_endpoint: string;
41
42
  token_endpoint: string;
42
- registration_endpoint: string;
43
+ registration_endpoint?: string | undefined;
43
44
  scopes_supported?: string[] | undefined;
44
45
  response_types_supported: "code"[];
45
46
  response_modes_supported: "query"[];
46
47
  grant_types_supported: GrantType[];
47
48
  token_endpoint_auth_methods_supported?: TokenEndpointAuthMethod[] | undefined;
48
- token_endpoint_auth_signing_alg_values_supported?: better_auth0.AssertionSigningAlgorithm[] | undefined;
49
+ token_endpoint_auth_signing_alg_values_supported?: better_auth0.PrivateKeyJwtSigningAlgorithm[] | undefined;
49
50
  service_documentation?: string | undefined;
50
51
  ui_locales_supported?: string[] | undefined;
51
52
  op_policy_uri?: string | undefined;
52
53
  op_tos_uri?: string | undefined;
53
54
  revocation_endpoint?: string | undefined;
54
55
  revocation_endpoint_auth_methods_supported?: AuthMethod[] | undefined;
55
- revocation_endpoint_auth_signing_alg_values_supported?: better_auth0.AssertionSigningAlgorithm[] | undefined;
56
+ revocation_endpoint_auth_signing_alg_values_supported?: better_auth0.PrivateKeyJwtSigningAlgorithm[] | undefined;
56
57
  introspection_endpoint?: string | undefined;
57
58
  introspection_endpoint_auth_methods_supported?: AuthMethod[] | undefined;
58
- introspection_endpoint_auth_signing_alg_values_supported?: better_auth0.AssertionSigningAlgorithm[] | undefined;
59
+ introspection_endpoint_auth_signing_alg_values_supported?: better_auth0.PrivateKeyJwtSigningAlgorithm[] | undefined;
59
60
  code_challenge_methods_supported: "S256"[];
60
61
  authorization_response_iss_parameter_supported?: boolean | undefined;
61
62
  client_id_metadata_document_supported?: boolean | undefined;
@@ -105,4 +106,4 @@ declare function checkOAuthClient(client: OAuthClient, opts: OAuthOptions<Scope[
105
106
  */
106
107
  declare function oauthToSchema(input: OAuthClient): SchemaClient<Scope[]>;
107
108
  //#endregion
108
- export { AuthServerMetadata, AuthorizePrompt, ClientDiscovery, OAuthAuthorizationQuery, OAuthClient, OAuthConsent, type OAuthEndpointErrorResult, type OAuthEndpointRedirectContext, type OAuthErrorCode, type OAuthFieldErrorCode, type OAuthFieldErrorCodeMap, OAuthOpaqueAccessToken, OAuthOptions, type OAuthRedirectOnError, OAuthRefreshToken, OIDCMetadata, Prompt, ResourceServerMetadata, SchemaClient, Scope, StoreTokenType, VerificationValue, authServerMetadata, checkOAuthClient, getOAuthProviderState, mcpHandler, oauthProvider, oauthProviderAuthServerMetadata, oauthProviderOpenIdConfigMetadata, oauthToSchema, oidcServerMetadata };
109
+ export { AuthMethod, AuthServerMetadata, AuthorizePrompt, BearerMethodsSupported, ClientDiscovery, GrantType, OAuthAuthorizationQuery, OAuthClient, OAuthConsent, type OAuthEndpointErrorResult, type OAuthEndpointRedirectContext, type OAuthErrorCode, type OAuthFieldErrorCode, type OAuthFieldErrorCodeMap, OAuthOpaqueAccessToken, OAuthOptions, type OAuthRedirectOnError, OAuthRefreshToken, OIDCMetadata, Prompt, ResourceServerMetadata, SchemaClient, Scope, StoreTokenType, TokenEndpointAuthMethod, VerificationValue, authServerMetadata, checkOAuthClient, getOAuthProviderState, mcpHandler, oauthProvider, oauthProviderAuthServerMetadata, oauthProviderOpenIdConfigMetadata, oauthToSchema, oidcServerMetadata };