@better-auth/oauth-provider 1.7.0-rc.3 → 1.7.0-rc.5
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/{client-assertion-CsbEATZc.mjs → client-assertion-Cy8ZcH7P.mjs} +1 -1
- package/dist/client-resource.d.mts +1 -7
- package/dist/client-resource.mjs +2 -11
- package/dist/client.d.mts +15 -2
- package/dist/client.mjs +10 -2
- package/dist/index.d.mts +3 -40
- package/dist/index.mjs +184 -192
- package/dist/internal.d.mts +1 -1
- package/dist/internal.mjs +2 -2
- package/dist/{oauth-CgWbnA8o.d.mts → oauth-4LGMyr3C.d.mts} +602 -31
- package/dist/{oauth-Bi2PA_d1.d.mts → oauth-CjcHkAmR.d.mts} +0 -21
- package/dist/{register-BotzQoS8.mjs → register-BjyzmoSI.mjs} +3 -3
- package/dist/{utils-GbnW6qPl.mjs → utils-jZEA4KQb.mjs} +92 -36
- package/dist/{version-xoFrTW0m.mjs → version-CwxXc1Y6.mjs} +1 -1
- package/package.json +7 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { P as getClientDiscoveries, a as getClient } from "./utils-jZEA4KQb.mjs";
|
|
2
2
|
import { isPublicRoutableHost } from "@better-auth/core/utils/host";
|
|
3
3
|
import { APIError } from "better-call";
|
|
4
4
|
import { CLIENT_ASSERTION_TYPE, PRIVATE_KEY_JWT_SIGNING_ALGORITHMS } from "@better-auth/core/oauth2";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as ResourceServerMetadata } from "./oauth-
|
|
1
|
+
import { c as ResourceServerMetadata } from "./oauth-CjcHkAmR.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";
|
|
@@ -103,14 +103,8 @@ type VerifyAccessTokenRequestNoAuthOpts = VerifyAccessTokenNoAuthOpts & {
|
|
|
103
103
|
dpop?: VerifyAccessTokenRequestOptions["dpop"];
|
|
104
104
|
};
|
|
105
105
|
type ProtectedResourceMetadataOutput<T> = T extends undefined ? (overrides: ResourceServerMetadata, opts?: {
|
|
106
|
-
silenceWarnings?: {
|
|
107
|
-
oidcScopes?: boolean;
|
|
108
|
-
};
|
|
109
106
|
externalScopes?: string[];
|
|
110
107
|
}) => Promise<ResourceServerMetadata> : (overrides?: Partial<ResourceServerMetadata>, opts?: {
|
|
111
|
-
silenceWarnings?: {
|
|
112
|
-
oidcScopes?: boolean;
|
|
113
|
-
};
|
|
114
108
|
externalScopes?: string[];
|
|
115
109
|
}) => Promise<ResourceServerMetadata>;
|
|
116
110
|
//#endregion
|
package/dist/client-resource.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { o as getJwtPlugin, s as getOAuthProviderPlugin } from "./utils-
|
|
2
|
-
import { t as PACKAGE_VERSION } from "./version-
|
|
1
|
+
import { o as getJwtPlugin, s as getOAuthProviderPlugin } from "./utils-jZEA4KQb.mjs";
|
|
2
|
+
import { t as PACKAGE_VERSION } from "./version-CwxXc1Y6.mjs";
|
|
3
3
|
import { t as createResourceServerChallenge } from "./resource-challenge-CiJTlsEh.mjs";
|
|
4
4
|
import { APIError } from "better-call";
|
|
5
|
-
import { logger } from "@better-auth/core/env";
|
|
6
5
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
7
6
|
import { DPOP_SIGNING_ALGORITHMS, requestToResourceInput, verifyAccessTokenRequest, verifyBearerToken } from "better-auth/oauth2";
|
|
8
7
|
//#region src/client-resource.ts
|
|
@@ -110,14 +109,6 @@ const oauthProviderResourceClient = (auth) => {
|
|
|
110
109
|
const allValidScopes = /* @__PURE__ */ new Set([...oauthProviderOptions?.scopes ?? [], ...opts?.externalScopes ?? []]);
|
|
111
110
|
for (const sc of overrides.scopes_supported) {
|
|
112
111
|
if (sc === "openid") throw new BetterAuthError("Only the Auth Server should utilize the openid scope");
|
|
113
|
-
if ([
|
|
114
|
-
"profile",
|
|
115
|
-
"email",
|
|
116
|
-
"phone",
|
|
117
|
-
"address"
|
|
118
|
-
].includes(sc)) {
|
|
119
|
-
if (!opts?.silenceWarnings?.oidcScopes) logger.warn(`"${sc}" is typically restricted for the authorization server, a resource server typically shouldn't handle this scope`);
|
|
120
|
-
}
|
|
121
112
|
if (!allValidScopes.has(sc)) throw new BetterAuthError(`Unsupported scope ${sc}. If external, please add to "externalScopes"`);
|
|
122
113
|
}
|
|
123
114
|
}
|
package/dist/client.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as oauthProvider } from "./oauth-
|
|
1
|
+
import { p as oauthDeviceAuthorization, r as oauthProvider } from "./oauth-4LGMyr3C.mjs";
|
|
2
2
|
//#region src/client.d.ts
|
|
3
3
|
declare const oauthProviderClient: () => {
|
|
4
4
|
id: "oauth-provider-client";
|
|
@@ -13,5 +13,18 @@ declare const oauthProviderClient: () => {
|
|
|
13
13
|
}[];
|
|
14
14
|
$InferServerPlugin: ReturnType<typeof oauthProvider>;
|
|
15
15
|
};
|
|
16
|
+
/** Client plugin for {@link oauthDeviceAuthorization}. */
|
|
17
|
+
declare const oauthDeviceAuthorizationClient: () => {
|
|
18
|
+
$InferServerPlugin: ReturnType<typeof oauthDeviceAuthorization>;
|
|
19
|
+
id: "device-authorization";
|
|
20
|
+
version: string;
|
|
21
|
+
pathMethods: {
|
|
22
|
+
"/device/code": "POST";
|
|
23
|
+
"/device/token": "POST";
|
|
24
|
+
"/device": "GET";
|
|
25
|
+
"/device/approve": "POST";
|
|
26
|
+
"/device/deny": "POST";
|
|
27
|
+
};
|
|
28
|
+
};
|
|
16
29
|
//#endregion
|
|
17
|
-
export { oauthProviderClient };
|
|
30
|
+
export { oauthDeviceAuthorizationClient, oauthProviderClient };
|
package/dist/client.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { t as buildSignedOAuthQuery } from "./signed-query-BQAwsV_w.mjs";
|
|
2
|
-
import { t as PACKAGE_VERSION } from "./version-
|
|
2
|
+
import { t as PACKAGE_VERSION } from "./version-CwxXc1Y6.mjs";
|
|
3
3
|
import { safeJSONParse } from "@better-auth/core/utils/json";
|
|
4
|
+
import { deviceAuthorizationClient } from "better-auth/client/plugins";
|
|
4
5
|
//#region src/client.ts
|
|
5
6
|
const oauthProviderClient = () => {
|
|
6
7
|
return {
|
|
@@ -23,5 +24,12 @@ const oauthProviderClient = () => {
|
|
|
23
24
|
$InferServerPlugin: {}
|
|
24
25
|
};
|
|
25
26
|
};
|
|
27
|
+
/** Client plugin for {@link oauthDeviceAuthorization}. */
|
|
28
|
+
const oauthDeviceAuthorizationClient = () => {
|
|
29
|
+
return {
|
|
30
|
+
...deviceAuthorizationClient(),
|
|
31
|
+
$InferServerPlugin: {}
|
|
32
|
+
};
|
|
33
|
+
};
|
|
26
34
|
//#endregion
|
|
27
|
-
export { oauthProviderClient };
|
|
35
|
+
export { oauthDeviceAuthorizationClient, oauthProviderClient };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,45 +1,8 @@
|
|
|
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-
|
|
2
|
-
import { a as OAuthEndpointErrorResult, c as OAuthFieldErrorCode, i as getIssuer, l as OAuthFieldErrorCodeMap, n as getOAuthProviderState, o as OAuthEndpointRedirectContext, r as oauthProvider, s as OAuthErrorCode, t as DEFAULT_OAUTH_SCOPES, u as OAuthRedirectOnError } from "./oauth-
|
|
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";
|
|
3
3
|
import { APIError } from "better-call";
|
|
4
4
|
import { JWSAlgorithms, JwtOptions } from "better-auth/plugins";
|
|
5
|
-
import { BetterAuthPlugin } from "better-auth/types";
|
|
6
5
|
import { AuthContext, GenericEndpointContext } from "@better-auth/core";
|
|
7
|
-
//#region src/device-code.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* RFC 8628 device authorization grant type. A registered OAuth client polls the
|
|
10
|
-
* token endpoint with this `grant_type` to exchange an approved device code for
|
|
11
|
-
* a first-class OAuth token set.
|
|
12
|
-
*/
|
|
13
|
-
declare const DEVICE_CODE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
|
|
14
|
-
/**
|
|
15
|
-
* Bridges the {@link https://datatracker.ietf.org/doc/html/rfc8628 RFC 8628}
|
|
16
|
-
* device authorization grant into the OAuth Provider. Pair it with the
|
|
17
|
-
* `device-authorization` plugin (which owns the `/device/code` request endpoint,
|
|
18
|
-
* the user verification flow, and the `deviceCode` table) and the
|
|
19
|
-
* `oauthProvider` plugin: this registers a `device_code` token grant on
|
|
20
|
-
* `/oauth2/token` that issues real OAuth tokens for a registered OAuth client,
|
|
21
|
-
* and advertises `device_authorization_endpoint` in discovery metadata.
|
|
22
|
-
*
|
|
23
|
-
* First-party device login (the device-authorization plugin's own
|
|
24
|
-
* `/device/token`, which mints a Better Auth session token) keeps working
|
|
25
|
-
* unchanged. To stop a registered OAuth client's device code from being redeemed
|
|
26
|
-
* there for a session token, a `before` hook rejects `/device/token` requests
|
|
27
|
-
* whose `client_id` resolves to a registered OAuth client, directing them to
|
|
28
|
-
* `/oauth2/token`.
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* const auth = betterAuth({
|
|
33
|
-
* plugins: [
|
|
34
|
-
* deviceAuthorization(),
|
|
35
|
-
* oauthProvider({ ... }),
|
|
36
|
-
* deviceCodeGrant(),
|
|
37
|
-
* ],
|
|
38
|
-
* });
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
declare function deviceCodeGrant(): BetterAuthPlugin;
|
|
42
|
-
//#endregion
|
|
43
6
|
//#region src/extensions.d.ts
|
|
44
7
|
/**
|
|
45
8
|
* Registers an {@link OAuthProviderExtension} with the OAuth Provider plugin
|
|
@@ -230,4 +193,4 @@ declare function consumeClientAssertion(ctx: GenericEndpointContext, opts: OAuth
|
|
|
230
193
|
expectedAudience: string;
|
|
231
194
|
}): Promise<void>;
|
|
232
195
|
//#endregion
|
|
233
|
-
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 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,
|
|
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 };
|