@better-auth/oauth-provider 1.7.0-rc.5 → 1.7.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.
@@ -1,7 +1,8 @@
1
- import { c as ResourceServerMetadata } from "./oauth-CjcHkAmR.mjs";
1
+ import { c as ResourceServerMetadata } from "./oauth-1Ud-hvZY.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";
5
+
5
6
  //#region src/client-resource.d.ts
6
7
  type ResourceClientAuth = {
7
8
  options: BetterAuthOptions;
@@ -75,8 +76,7 @@ type VerifyAccessTokenAuthOpts = {
75
76
  requiredScopes?: readonly string[];
76
77
  isScopeSatisfied?: VerifyAccessTokenRequestOptions["isScopeSatisfied"];
77
78
  jwksUrl?: string;
78
- remoteVerify?: VerifyAccessTokenRemote;
79
- /** Maps non-url (ie urn, client) resources to resource_metadata */
79
+ remoteVerify?: VerifyAccessTokenRemote; /** Maps non-url (ie urn, client) resources to resource_metadata */
80
80
  resourceMetadataMappings?: Record<string, string>;
81
81
  };
82
82
  type VerifyAccessTokenRequestAuthOpts = VerifyAccessTokenAuthOpts & {
@@ -87,16 +87,14 @@ type VerifyAccessTokenNoAuthOpts = {
87
87
  requiredScopes?: readonly string[];
88
88
  isScopeSatisfied?: VerifyAccessTokenRequestOptions["isScopeSatisfied"];
89
89
  jwksUrl: string;
90
- remoteVerify?: VerifyAccessTokenRemote;
91
- /** Maps non-url (ie urn, client) resources to resource_metadata */
90
+ remoteVerify?: VerifyAccessTokenRemote; /** Maps non-url (ie urn, client) resources to resource_metadata */
92
91
  resourceMetadataMappings?: Record<string, string>;
93
92
  } | {
94
93
  verifyOptions: JWTVerifyOptions & Required<Pick<JWTVerifyOptions, "audience" | "issuer">>;
95
94
  requiredScopes?: readonly string[];
96
95
  isScopeSatisfied?: VerifyAccessTokenRequestOptions["isScopeSatisfied"];
97
96
  jwksUrl?: string;
98
- remoteVerify: VerifyAccessTokenRemote;
99
- /** Maps non-url (ie urn, client) resources to resource_metadata */
97
+ remoteVerify: VerifyAccessTokenRemote; /** Maps non-url (ie urn, client) resources to resource_metadata */
100
98
  resourceMetadataMappings?: Record<string, string>;
101
99
  };
102
100
  type VerifyAccessTokenRequestNoAuthOpts = VerifyAccessTokenNoAuthOpts & {
@@ -1,6 +1,6 @@
1
- import { o as getJwtPlugin, s as getOAuthProviderPlugin } from "./utils-jZEA4KQb.mjs";
2
- import { t as PACKAGE_VERSION } from "./version-CwxXc1Y6.mjs";
3
- import { t as createResourceServerChallenge } from "./resource-challenge-CiJTlsEh.mjs";
1
+ import { o as getJwtPlugin, s as getOAuthProviderPlugin } from "./utils-CCi1maVd.mjs";
2
+ import { t as PACKAGE_VERSION } from "./version-C0TE7qRr.mjs";
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";
6
6
  import { DPOP_SIGNING_ALGORITHMS, requestToResourceInput, verifyAccessTokenRequest, verifyBearerToken } from "better-auth/oauth2";
@@ -106,7 +106,7 @@ const oauthProviderResourceClient = (auth) => {
106
106
  if (!resource) throw Error("missing required resource");
107
107
  if (oauthProviderOptions?.scopes && opts?.externalScopes && (overrides?.authorization_servers?.length ?? 0) <= 1) throw new BetterAuthError("external scopes should not be provided with one authorization server");
108
108
  if (overrides?.scopes_supported) {
109
- const allValidScopes = /* @__PURE__ */ new Set([...oauthProviderOptions?.scopes ?? [], ...opts?.externalScopes ?? []]);
109
+ const allValidScopes = new Set([...oauthProviderOptions?.scopes ?? [], ...opts?.externalScopes ?? []]);
110
110
  for (const sc of overrides.scopes_supported) {
111
111
  if (sc === "openid") throw new BetterAuthError("Only the Auth Server should utilize the openid scope");
112
112
  if (!allValidScopes.has(sc)) throw new BetterAuthError(`Unsupported scope ${sc}. If external, please add to "externalScopes"`);
package/dist/client.d.mts CHANGED
@@ -1,4 +1,6 @@
1
- import { p as oauthDeviceAuthorization, r as oauthProvider } from "./oauth-4LGMyr3C.mjs";
1
+ import { p as oauthDeviceAuthorization, r as oauthProvider } from "./oauth-D8xpKR0_.mjs";
2
+ import * as _$_better_fetch_fetch0 from "@better-fetch/fetch";
3
+
2
4
  //#region src/client.d.ts
3
5
  declare const oauthProviderClient: () => {
4
6
  id: "oauth-provider-client";
@@ -8,7 +10,7 @@ declare const oauthProviderClient: () => {
8
10
  name: string;
9
11
  description: string;
10
12
  hooks: {
11
- onRequest<T extends Record<string, any>>(ctx: import("@better-fetch/fetch").RequestContext<T>): Promise<void>;
13
+ onRequest<T extends Record<string, any>>(ctx: _$_better_fetch_fetch0.RequestContext<T>): Promise<void>;
12
14
  };
13
15
  }[];
14
16
  $InferServerPlugin: ReturnType<typeof oauthProvider>;
package/dist/client.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { t as buildSignedOAuthQuery } from "./signed-query-BQAwsV_w.mjs";
2
- import { t as PACKAGE_VERSION } from "./version-CwxXc1Y6.mjs";
1
+ import { t as buildSignedOAuthQuery } from "./signed-query-Df1MNiSH.mjs";
2
+ import { t as PACKAGE_VERSION } from "./version-C0TE7qRr.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
package/dist/index.d.mts CHANGED
@@ -1,8 +1,10 @@
1
- import { A as OAuthOpaqueAccessToken, B as Prompt, C as OAuthClientAuthenticationStrategy, D as OAuthExtensionGrantHandler, E as OAuthConsent, F as OAuthResource, G as VerificationValue, H as Scope, I as OAuthResourceInput, J as ResourceUriSchema, K as ClientRegistrationRequest, L as OAuthTokenIssueParams, M as OAuthProviderApi, N as OAuthProviderExtension, O as OAuthExtensionGrantHandlerInput, P as OAuthRefreshToken, R as OAuthTokenResponse, S as OAuthClientAuthenticationResult, T as OAuthClientResource, U as StoreTokenType, V as SchemaClient, W as StoredAuthorizationQuery, Y as oauthClientMetadataSchema, _ as OAuthAuthorizationQuery, a as GrantType, b as OAuthClientAuthenticationInput, c as ResourceServerMetadata, d as ActiveAccessTokenPayload, f as AuthorizePrompt, g as OAuthAuthenticatedClient, h as InitialAccessTokenAuthorization, i as Confirmation, j as OAuthOptions, k as OAuthMetadataExtensionInput, l as TokenEndpointAuthMethod, m as ClientMetadataResourceFetch, n as AuthServerMetadata, o as OAuthClient, p as ClientDiscovery, q as OAuthClientMetadata, r as BearerMethodsSupported, s as OIDCMetadata, t as AuthMethod, u as TokenType, v as OAuthClaimExtensionInput, w as OAuthClientRegistrationResponse, x as OAuthClientAuthenticationRequest, y as OAuthClientAdministrativeResponse, z as OAuthUserInfoExtensionInput } from "./oauth-CjcHkAmR.mjs";
2
- import { a as OAuthEndpointErrorResult, c as OAuthFieldErrorCode, d as DEVICE_CODE_GRANT_TYPE, f as OAuthDeviceAuthorizationOptions, i as getIssuer, l as OAuthFieldErrorCodeMap, n as getOAuthProviderState, o as OAuthEndpointRedirectContext, p as oauthDeviceAuthorization, r as oauthProvider, s as OAuthErrorCode, t as DEFAULT_OAUTH_SCOPES, u as OAuthRedirectOnError } from "./oauth-4LGMyr3C.mjs";
1
+ import { A as OAuthOpaqueAccessToken, B as Prompt, C as OAuthClientAuthenticationStrategy, D as OAuthExtensionGrantHandler, E as OAuthConsent, F as OAuthResource, G as VerificationValue, H as Scope, I as OAuthResourceInput, J as ResourceUriSchema, K as ClientRegistrationRequest, L as OAuthTokenIssueParams, M as OAuthProviderApi, N as OAuthProviderExtension, O as OAuthExtensionGrantHandlerInput, P as OAuthRefreshToken, R as OAuthTokenResponse, S as OAuthClientAuthenticationResult, T as OAuthClientResource, U as StoreTokenType, V as SchemaClient, W as StoredAuthorizationQuery, Y as oauthClientMetadataSchema, _ as OAuthAuthorizationQuery, a as GrantType, b as OAuthClientAuthenticationInput, c as ResourceServerMetadata, d as ActiveAccessTokenPayload, f as AuthorizePrompt, g as OAuthAuthenticatedClient, h as InitialAccessTokenAuthorization, i as Confirmation, j as OAuthOptions, k as OAuthMetadataExtensionInput, l as TokenEndpointAuthMethod, m as ClientMetadataResourceFetch, n as AuthServerMetadata, o as OAuthClient, p as ClientDiscovery, q as OAuthClientMetadata, r as BearerMethodsSupported, s as OIDCMetadata, t as AuthMethod, u as TokenType, v as OAuthClaimExtensionInput, w as OAuthClientRegistrationResponse, x as OAuthClientAuthenticationRequest, y as OAuthClientAdministrativeResponse, z as OAuthUserInfoExtensionInput } from "./oauth-1Ud-hvZY.mjs";
2
+ import { a as OAuthEndpointErrorResult, c as OAuthFieldErrorCode, d as DEVICE_CODE_GRANT_TYPE, f as OAuthDeviceAuthorizationOptions, i as getIssuer, l as OAuthFieldErrorCodeMap, n as getOAuthProviderState, o as OAuthEndpointRedirectContext, p as oauthDeviceAuthorization, r as oauthProvider, s as OAuthErrorCode, t as DEFAULT_OAUTH_SCOPES, u as OAuthRedirectOnError } from "./oauth-D8xpKR0_.mjs";
3
3
  import { APIError } from "better-call";
4
4
  import { JWSAlgorithms, JwtOptions } from "better-auth/plugins";
5
5
  import { AuthContext, GenericEndpointContext } from "@better-auth/core";
6
+ import * as _$better_auth0 from "better-auth";
7
+
6
8
  //#region src/extensions.d.ts
7
9
  /**
8
10
  * Registers an {@link OAuthProviderExtension} with the OAuth Provider plugin
@@ -65,17 +67,17 @@ declare function oidcServerMetadata(ctx: GenericEndpointContext, opts: OAuthOpti
65
67
  response_modes_supported: "query"[];
66
68
  grant_types_supported: GrantType[];
67
69
  token_endpoint_auth_methods_supported?: TokenEndpointAuthMethod[] | undefined;
68
- token_endpoint_auth_signing_alg_values_supported?: import("better-auth").PrivateKeyJwtSigningAlgorithm[] | undefined;
70
+ token_endpoint_auth_signing_alg_values_supported?: _$better_auth0.PrivateKeyJwtSigningAlgorithm[] | undefined;
69
71
  service_documentation?: string | undefined;
70
72
  ui_locales_supported?: string[] | undefined;
71
73
  op_policy_uri?: string | undefined;
72
74
  op_tos_uri?: string | undefined;
73
75
  revocation_endpoint?: string | undefined;
74
76
  revocation_endpoint_auth_methods_supported?: TokenEndpointAuthMethod[] | undefined;
75
- revocation_endpoint_auth_signing_alg_values_supported?: import("better-auth").PrivateKeyJwtSigningAlgorithm[] | undefined;
77
+ revocation_endpoint_auth_signing_alg_values_supported?: _$better_auth0.PrivateKeyJwtSigningAlgorithm[] | undefined;
76
78
  introspection_endpoint?: string | undefined;
77
79
  introspection_endpoint_auth_methods_supported?: TokenEndpointAuthMethod[] | undefined;
78
- introspection_endpoint_auth_signing_alg_values_supported?: import("better-auth").PrivateKeyJwtSigningAlgorithm[] | undefined;
80
+ introspection_endpoint_auth_signing_alg_values_supported?: _$better_auth0.PrivateKeyJwtSigningAlgorithm[] | undefined;
79
81
  code_challenge_methods_supported: "S256"[];
80
82
  authorization_response_iss_parameter_supported?: boolean | undefined;
81
83
  client_id_metadata_document_supported?: boolean | undefined;
@@ -136,9 +138,7 @@ declare const oauthProviderOpenIdConfigMetadata: <Auth extends {
136
138
  * @external
137
139
  */
138
140
  declare function createResourceServerChallenge(error: unknown, resource: string | string[], opts?: {
139
- /** Maps non-URL (urn, client) resources to their resource_metadata URL. */
140
- resourceMetadataMappings?: Record<string, string>;
141
- /** DPoP JWS algorithms to advertise in RFC 9449 challenges. */
141
+ /** Maps non-URL (urn, client) resources to their resource_metadata URL. */resourceMetadataMappings?: Record<string, string>; /** DPoP JWS algorithms to advertise in RFC 9449 challenges. */
142
142
  dpopSigningAlgorithms?: readonly string[];
143
143
  /**
144
144
  * Scopes to advertise in RFC 6750 bearer challenges,
@@ -193,4 +193,4 @@ declare function consumeClientAssertion(ctx: GenericEndpointContext, opts: OAuth
193
193
  expectedAudience: string;
194
194
  }): Promise<void>;
195
195
  //#endregion
196
- export { type ActiveAccessTokenPayload, type AuthMethod, type AuthServerMetadata, type AuthorizePrompt, type BearerMethodsSupported, type ClientDiscovery, type ClientMetadataResourceFetch, type ClientRegistrationRequest, type Confirmation, DEFAULT_OAUTH_SCOPES, DEVICE_CODE_GRANT_TYPE, type GrantType, type InitialAccessTokenAuthorization, type OAuthAuthenticatedClient, type OAuthAuthorizationQuery, type OAuthClaimExtensionInput, type OAuthClient, type OAuthClientAdministrativeResponse, type OAuthClientAuthenticationInput, type OAuthClientAuthenticationRequest, type OAuthClientAuthenticationResult, type OAuthClientAuthenticationStrategy, type OAuthClientMetadata, type OAuthClientRegistrationResponse, type OAuthClientResource, type OAuthConsent, type OAuthDeviceAuthorizationOptions, type OAuthEndpointErrorResult, type OAuthEndpointRedirectContext, type OAuthErrorCode, type OAuthExtensionGrantHandler, type OAuthExtensionGrantHandlerInput, type OAuthFieldErrorCode, type OAuthFieldErrorCodeMap, type OAuthMetadataExtensionInput, type OAuthOpaqueAccessToken, type OAuthOptions, type OAuthProviderApi, type OAuthProviderExtension, type OAuthRedirectOnError, type OAuthRefreshToken, type OAuthResource, type OAuthResourceInput, type OAuthTokenIssueParams, type OAuthTokenResponse, type OAuthUserInfoExtensionInput, type OIDCMetadata, type Prompt, type ResourceServerMetadata, ResourceUriSchema, type SchemaClient, type Scope, type StoreTokenType, type StoredAuthorizationQuery, type TokenEndpointAuthMethod, type TokenType, type VerificationValue, authServerMetadata, consumeClientAssertion, createResourceServerChallenge, extendOAuthProvider, getIssuer, getOAuthProviderApi, getOAuthProviderState, metadataResponse, oauthAuthorizationServerMetadata, oauthClientMetadataSchema, oauthDeviceAuthorization, oauthProvider, oauthProviderAuthServerMetadata, oauthProviderOpenIdConfigMetadata, oidcServerMetadata };
196
+ 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 };