@better-auth/oauth-provider 1.7.10 → 1.7.12

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,8 +1,8 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-wcPFST8Q.mjs";
2
- import { A as canSatisfyEssentialAcrRequest, C as authorizationQuerySchema, D as STANDARD_CLAIMS, M as filterClaimsRequestUserInfoClaims, N as getRequestedUserInfoClaims, O as STANDARD_CLAIM_NAMES, P as isValidOidcClaimsRequest, S as SafeUrlSchema, T as clientRegistrationRequestSchema, _ as logEnforcePerClientResourcesResolution, a as invalidateRefreshFamily, b as seedResourcesOnce, c as normalizeClientCredentialsScopes, d as JWS_ALGORITHMS, f as assertIdentifierValid, g as isAudienceClaimAllowed, h as invalidateResourceCache, j as claimsRequestParameterSchema, k as getSupportedClaims, l as validateClientCredentialsScopes, m as getResource, o as tokenEndpoint, p as extractRepeatedResourceFromForm, r as decodeRefreshToken, s as userInfoEndpoint, t as introspectEndpoint, u as getEndpointUrl, v as logStartupSeedFailure, w as clientJwksSchema, x as ResourceUriSchema, y as resolveResourcePolicy } from "./introspect-BVm_zFQC.mjs";
3
- import { A as validateClientCredentials, B as getSupportedAuthMethods, D as storeToken, E as storeClientSecret, M as verifyOAuthQueryParams, N as applyOAuthProviderMetadataExtensions, R as getClientDiscoveries, S as removePromptFromQuery, T as searchParamsToQuery, U as isExtensionTokenEndpointAuthMethod, V as getSupportedGrantTypes, W as validateOAuthProviderExtensions, a as extractClientCredentials, b as parsePrompt, c as getConsentReferenceId, d as getStoredToken, f as isInvalidJwtError, h as mergeDiscoveryMetadata, i as destructureCredentials, k as toResourceList, l as getJwtPlugin, m as isSessionFreshForSignedQuery, n as clientAllowsGrant, o as findConsent, p as isPKCERequired, r as decryptStoredClientSecret, s as getClient, t as assertNotTrustedClient, v as parseBearerToken, w as resolveSubjectIdentifier, x as removeMaxAgeFromQuery, y as parseClientMetadata } from "./utils-DfMNRh3J.mjs";
2
+ import { A as canSatisfyEssentialAcrRequest, C as authorizationQuerySchema, D as STANDARD_CLAIMS, M as filterClaimsRequestUserInfoClaims, N as getRequestedUserInfoClaims, O as STANDARD_CLAIM_NAMES, P as isValidOidcClaimsRequest, S as SafeUrlSchema, T as clientRegistrationRequestSchema, _ as logEnforcePerClientResourcesResolution, a as invalidateRefreshFamily, b as seedResourcesOnce, c as normalizeClientCredentialsScopes, d as JWS_ALGORITHMS, f as assertIdentifierValid, g as isAudienceClaimAllowed, h as invalidateResourceCache, j as claimsRequestParameterSchema, k as getSupportedClaims, l as validateClientCredentialsScopes, m as getResource, o as tokenEndpoint, p as extractRepeatedResourceFromForm, r as decodeRefreshToken, s as userInfoEndpoint, t as introspectEndpoint, u as getEndpointUrl, v as logStartupSeedFailure, w as clientJwksSchema, x as ResourceUriSchema, y as resolveResourcePolicy } from "./introspect-DeWu79D4.mjs";
3
+ import { A as validateClientCredentials, B as getSupportedAuthMethods, D as storeToken, E as storeClientSecret, M as verifyOAuthQueryParams, N as applyOAuthProviderMetadataExtensions, R as getClientDiscoveries, S as removePromptFromQuery, T as searchParamsToQuery, U as isExtensionTokenEndpointAuthMethod, V as getSupportedGrantTypes, W as validateOAuthProviderExtensions, a as extractClientCredentials, b as parsePrompt, c as getConsentReferenceId, d as getStoredToken, f as isInvalidJwtError, h as mergeDiscoveryMetadata, i as destructureCredentials, k as toResourceList, l as getJwtPlugin, m as isSessionFreshForSignedQuery, n as clientAllowsGrant, o as findConsent, p as isPKCERequired, r as decryptStoredClientSecret, s as getClient, t as assertNotTrustedClient, v as parseBearerToken, w as resolveSubjectIdentifier, x as removeMaxAgeFromQuery, y as parseClientMetadata } from "./utils-BfpTo7XY.mjs";
4
4
  import { a as setSignedOAuthQueryParameterNames, i as postLoginClearedParam, n as canonicalizeOAuthQueryParams, o as signedQueryIssuedAtParam, r as getSignedQueryIssuedAt } from "./signed-query-Df1MNiSH.mjs";
5
- import { t as PACKAGE_VERSION } from "./version-aKfgWHzo.mjs";
5
+ import { t as PACKAGE_VERSION } from "./version-anFUgA6q.mjs";
6
6
  import { isBrowserFetchRequest } from "@better-auth/core/utils/fetch-metadata";
7
7
  import { isLoopbackHost, isLoopbackIP, isPublicRoutableHost } from "@better-auth/core/utils/host";
8
8
  import { appendQueryParams } from "@better-auth/core/utils/url";
@@ -2033,7 +2033,7 @@ async function persistOAuthClientRegistration(ctx, opts, input) {
2033
2033
  user_id: owner?.referenceId ? void 0 : owner?.userId,
2034
2034
  reference_id: owner?.referenceId
2035
2035
  });
2036
- schema.clientCredentialsScopes = input.registrationSource === "clientMetadataDocument" ? input.existingClient?.clientCredentialsScopes ?? [] : input.registrationSource === "managed" ? input.clientCredentialsScopes ?? [] : [];
2036
+ schema.clientCredentialsScopes = input.registrationSource === "managed" ? input.clientCredentialsScopes ?? [] : [];
2037
2037
  schema.clientDiscoveryId = input.registrationSource === "clientMetadataDocument" ? input.clientDiscoveryId : null;
2038
2038
  if (input.registrationSource === "clientMetadataDocument" && body.application_type === void 0) schema.applicationType = null;
2039
2039
  const requestedResources = input.registrationSource === "clientMetadataDocument" ? [] : input.requestedResources ?? [];
@@ -2048,6 +2048,7 @@ async function persistOAuthClientRegistration(ctx, opts, input) {
2048
2048
  let storedClient;
2049
2049
  let created = false;
2050
2050
  if (existingClient) {
2051
+ const { clientCredentialsScopes: _ceiling, disabled: _disabled, skipConsent: _skipConsent, enableEndSession: _enableEndSession, ...refreshed } = schema;
2051
2052
  const updatedClient = await adapter.update({
2052
2053
  model: clientModel,
2053
2054
  where: [{
@@ -2058,10 +2059,7 @@ async function persistOAuthClientRegistration(ctx, opts, input) {
2058
2059
  value: clientDiscoveryId
2059
2060
  }],
2060
2061
  update: {
2061
- ...schema,
2062
- disabled: existingClient.disabled,
2063
- skipConsent: existingClient.skipConsent,
2064
- enableEndSession: existingClient.enableEndSession,
2062
+ ...refreshed,
2065
2063
  createdAt: existingClient.createdAt,
2066
2064
  updatedAt: /* @__PURE__ */ new Date(iat * 1e3)
2067
2065
  }
@@ -4675,12 +4673,19 @@ const oauthProvider = (options) => {
4675
4673
  description: "Consent processed successfully",
4676
4674
  content: { "application/json": { schema: {
4677
4675
  type: "object",
4678
- properties: { redirect_uri: {
4679
- type: "string",
4680
- format: "uri",
4681
- description: "The URI to redirect to, either with an authorization code or an error"
4682
- } },
4683
- required: ["redirect_uri"]
4676
+ properties: {
4677
+ redirect: {
4678
+ type: "boolean",
4679
+ description: "Always true. Indicates the caller should redirect to `url`.",
4680
+ enum: [true]
4681
+ },
4682
+ url: {
4683
+ type: "string",
4684
+ format: "uri-reference",
4685
+ description: "The absolute or relative URI to redirect to next."
4686
+ }
4687
+ },
4688
+ required: ["redirect", "url"]
4684
4689
  } } }
4685
4690
  } }
4686
4691
  } }
@@ -4699,15 +4704,22 @@ const oauthProvider = (options) => {
4699
4704
  metadata: { openapi: {
4700
4705
  description: "Continues OAuth2 authorization flow",
4701
4706
  responses: { "200": {
4702
- description: "Consent processed successfully",
4707
+ description: "Authorization flow continued successfully",
4703
4708
  content: { "application/json": { schema: {
4704
4709
  type: "object",
4705
- properties: { redirect_uri: {
4706
- type: "string",
4707
- format: "uri",
4708
- description: "The URI to redirect to, either with an authorization code or an error"
4709
- } },
4710
- required: ["redirect_uri"]
4710
+ properties: {
4711
+ redirect: {
4712
+ type: "boolean",
4713
+ description: "Always true. Indicates the caller should redirect to `url`.",
4714
+ enum: [true]
4715
+ },
4716
+ url: {
4717
+ type: "string",
4718
+ format: "uri-reference",
4719
+ description: "The absolute or relative URI to redirect to next."
4720
+ }
4721
+ },
4722
+ required: ["redirect", "url"]
4711
4723
  } } }
4712
4724
  } }
4713
4725
  } }
@@ -1,5 +1,5 @@
1
- import { l as getJwtPlugin, u as getOAuthProviderPlugin } from "./utils-DfMNRh3J.mjs";
2
- import { t as PACKAGE_VERSION } from "./version-aKfgWHzo.mjs";
1
+ import { l as getJwtPlugin, u as getOAuthProviderPlugin } from "./utils-BfpTo7XY.mjs";
2
+ import { t as PACKAGE_VERSION } from "./version-anFUgA6q.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 { p as oauthDeviceAuthorization, r as oauthProvider } from "./oauth-Cse_eZ6i.mjs";
1
+ import { p as oauthDeviceAuthorization, r as oauthProvider } from "./oauth-ChlxgY8l.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-aKfgWHzo.mjs";
2
+ import { t as PACKAGE_VERSION } from "./version-anFUgA6q.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,5 +1,5 @@
1
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-DXiqbRzK.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-Cse_eZ6i.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-ChlxgY8l.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";
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { E as oauthClientMetadataSchema, i as getOAuthProviderApi, p as extractRepeatedResourceFromForm, x as ResourceUriSchema, y as resolveResourcePolicy } from "./introspect-BVm_zFQC.mjs";
2
- import { L as extendOAuthProvider, M as verifyOAuthQueryParams, O as toAudienceClaim, g as normalizeClientAuthenticationParameters, j as validateClientScopes, k as toResourceList, s as getClient, u as getOAuthProviderPlugin } from "./utils-DfMNRh3J.mjs";
3
- import { d as metadataResponse, f as oauthAuthorizationServerMetadata, h as oidcServerMetadata, i as oauthProvider, m as oauthProviderOpenIdConfigMetadata, n as DEFAULT_OAUTH_SCOPES, p as oauthProviderAuthServerMetadata, r as getOAuthProviderState, s as consumeClientAssertion, t as getIssuer, u as authServerMetadata } from "./authorize-dkOG8GqZ.mjs";
1
+ import { E as oauthClientMetadataSchema, i as getOAuthProviderApi, p as extractRepeatedResourceFromForm, x as ResourceUriSchema, y as resolveResourcePolicy } from "./introspect-DeWu79D4.mjs";
2
+ import { L as extendOAuthProvider, M as verifyOAuthQueryParams, O as toAudienceClaim, g as normalizeClientAuthenticationParameters, j as validateClientScopes, k as toResourceList, s as getClient, u as getOAuthProviderPlugin } from "./utils-BfpTo7XY.mjs";
3
+ import { d as metadataResponse, f as oauthAuthorizationServerMetadata, h as oidcServerMetadata, i as oauthProvider, m as oauthProviderOpenIdConfigMetadata, n as DEFAULT_OAUTH_SCOPES, p as oauthProviderAuthServerMetadata, r as getOAuthProviderState, s as consumeClientAssertion, t as getIssuer, u as authServerMetadata } from "./authorize-D_jy3s-1.mjs";
4
4
  import { t as createResourceServerChallenge } from "./resource-challenge-Damwi0Or.mjs";
5
5
  import { APIError } from "better-auth/api";
6
6
  import * as z from "zod";
package/dist/internal.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as registerClientMetadataDocument, c as isForbiddenCimdClientMetadataField, l as validatePublicClientJwks } from "./authorize-dkOG8GqZ.mjs";
1
+ import { a as registerClientMetadataDocument, c as isForbiddenCimdClientMetadataField, l as validatePublicClientJwks } from "./authorize-D_jy3s-1.mjs";
2
2
  export { isForbiddenCimdClientMetadataField, registerClientMetadataDocument, validatePublicClientJwks };
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-wcPFST8Q.mjs";
2
- import { A as validateClientCredentials, C as resolveSessionAuthTime, D as storeToken, F as collectExtensionIdTokenClaims, H as hasUserInfoClaimExtension, I as collectExtensionUserInfoClaims, O as toAudienceClaim, P as collectExtensionAccessTokenClaims, V as getSupportedGrantTypes, _ as normalizeTimestampValue, a as extractClientCredentials, d as getStoredToken, f as isInvalidJwtError, i as destructureCredentials, j as validateClientScopes, k as toResourceList, l as getJwtPlugin, n as clientAllowsGrant, p as isPKCERequired, r as decryptStoredClientSecret, s as getClient, w as resolveSubjectIdentifier, y as parseClientMetadata, z as getExtensionGrantHandler } from "./utils-DfMNRh3J.mjs";
2
+ import { A as validateClientCredentials, C as resolveSessionAuthTime, D as storeToken, F as collectExtensionIdTokenClaims, H as hasUserInfoClaimExtension, I as collectExtensionUserInfoClaims, O as toAudienceClaim, P as collectExtensionAccessTokenClaims, V as getSupportedGrantTypes, _ as normalizeTimestampValue, a as extractClientCredentials, d as getStoredToken, f as isInvalidJwtError, i as destructureCredentials, j as validateClientScopes, k as toResourceList, l as getJwtPlugin, n as clientAllowsGrant, p as isPKCERequired, r as decryptStoredClientSecret, s as getClient, w as resolveSubjectIdentifier, y as parseClientMetadata, z as getExtensionGrantHandler } from "./utils-BfpTo7XY.mjs";
3
3
  import { APIError } from "better-auth/api";
4
4
  import { generateRandomString, symmetricDecrypt, symmetricEncrypt } from "better-auth/crypto";
5
5
  import { APIError as APIError$1 } from "better-call";
@@ -920,7 +920,12 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
920
920
  schema: {
921
921
  type: "object";
922
922
  properties: {
923
- redirect_uri: {
923
+ redirect: {
924
+ type: string;
925
+ description: string;
926
+ enum: boolean[];
927
+ };
928
+ url: {
924
929
  type: string;
925
930
  format: string;
926
931
  description: string;
@@ -980,7 +985,12 @@ declare const oauthProvider: <O extends OAuthOptions<Scope[]>>(options: O) => {
980
985
  schema: {
981
986
  type: "object";
982
987
  properties: {
983
- redirect_uri: {
988
+ redirect: {
989
+ type: string;
990
+ description: string;
991
+ enum: boolean[];
992
+ };
993
+ url: {
984
994
  type: string;
985
995
  format: string;
986
996
  description: string;
@@ -738,7 +738,7 @@ async function extractClientCredentials(ctx, opts, expectedAudience) {
738
738
  confirmation: result.confirmation
739
739
  };
740
740
  }
741
- const { verifyClientAssertion: verify } = await import("./authorize-dkOG8GqZ.mjs").then((n) => n.o);
741
+ const { verifyClientAssertion: verify } = await import("./authorize-D_jy3s-1.mjs").then((n) => n.o);
742
742
  return {
743
743
  kind: "pre_verified",
744
744
  method: "private_key_jwt",
@@ -1,5 +1,5 @@
1
1
  //#endregion
2
2
  //#region src/version.ts
3
- const PACKAGE_VERSION = "1.7.10";
3
+ const PACKAGE_VERSION = "1.7.12";
4
4
  //#endregion
5
5
  export { PACKAGE_VERSION as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/oauth-provider",
3
- "version": "1.7.10",
3
+ "version": "1.7.12",
4
4
  "description": "An oauth provider plugin for Better Auth",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -71,16 +71,16 @@
71
71
  "devDependencies": {
72
72
  "listhen": "^1.9.0",
73
73
  "tsdown": "0.21.10",
74
- "@better-auth/core": "1.7.10",
75
- "@better-auth/memory-adapter": "1.7.10",
76
- "better-auth": "1.7.10"
74
+ "@better-auth/core": "1.7.12",
75
+ "@better-auth/memory-adapter": "1.7.12",
76
+ "better-auth": "1.7.12"
77
77
  },
78
78
  "peerDependencies": {
79
79
  "@better-auth/utils": "^0.4.2 || ^0.5.0",
80
80
  "@better-fetch/fetch": "1.3.2",
81
- "better-call": "1.4.2",
82
- "@better-auth/core": "^1.7.10",
83
- "better-auth": "^1.7.10"
81
+ "better-call": "1.4.4",
82
+ "@better-auth/core": "^1.7.12",
83
+ "better-auth": "^1.7.12"
84
84
  },
85
85
  "scripts": {
86
86
  "build": "tsdown",