@better-auth/oauth-provider 1.7.0-beta.3 → 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.
- package/dist/{client-assertion-BYtMWGCE.mjs → client-assertion-DLMKVgoj.mjs} +4 -4
- package/dist/client-resource.d.mts +13 -6
- package/dist/client-resource.mjs +2 -2
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +1 -1
- package/dist/index.d.mts +7 -6
- package/dist/index.mjs +329 -145
- package/dist/{oauth-BxP4Iupj.d.mts → oauth-Vt3lTNHX.d.mts} +67 -20
- package/dist/{oauth-Ds-ejTJY.d.mts → oauth-q7dn10NU.d.mts} +36 -7
- package/dist/{utils-_Jr_enAe.mjs → utils-DKBWQ8fe.mjs} +55 -16
- package/dist/{version-CG1YnCiF.mjs → version-nFnRm-a3.mjs} +1 -1
- package/package.json +6 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as getClient } from "./utils-DKBWQ8fe.mjs";
|
|
2
2
|
import { APIError } from "better-call";
|
|
3
|
-
import {
|
|
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 = [...
|
|
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 || !
|
|
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 { s as ResourceServerMetadata } from "./oauth-
|
|
1
|
+
import { s as ResourceServerMetadata } from "./oauth-q7dn10NU.mjs";
|
|
2
2
|
import { JWTPayload, JWTVerifyOptions } from "jose";
|
|
3
|
-
import {
|
|
3
|
+
import { BetterAuthOptions } from "better-auth/types";
|
|
4
4
|
|
|
5
5
|
//#region src/client-resource.d.ts
|
|
6
|
-
|
|
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
|
|
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
|
|
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
|
|
79
|
+
}) => Promise<ResourceServerMetadata> : (overrides?: Partial<ResourceServerMetadata>, opts?: {
|
|
73
80
|
silenceWarnings?: {
|
|
74
81
|
oidcScopes?: boolean;
|
|
75
82
|
};
|
package/dist/client-resource.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as handleMcpErrors } from "./mcp-CYnz-MXn.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { t as PACKAGE_VERSION } from "./version-
|
|
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
package/dist/client.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
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-
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
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;
|