@better-auth/oauth-provider 1.7.10 → 1.8.0-beta.1
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/{authorize-dkOG8GqZ.mjs → authorize-Dg976Ug0.mjs} +583 -433
- package/dist/client-resource.d.mts +2 -2
- package/dist/client-resource.mjs +2 -2
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +1 -1
- package/dist/index-DVydGHlT.d.mts +275 -0
- package/dist/index.d.mts +4 -203
- package/dist/index.mjs +196 -40
- package/dist/internal.d.mts +109 -22
- package/dist/internal.mjs +4 -2
- package/dist/{introspect-BVm_zFQC.mjs → introspect-DdmCPEHN.mjs} +294 -227
- package/dist/{oauth-DXiqbRzK.d.mts → oauth-CzT1PvAY.d.mts} +359 -13
- package/dist/{oauth-Cse_eZ6i.d.mts → oauth-DfH-ghKj.d.mts} +163 -87
- package/dist/{utils-DfMNRh3J.mjs → utils-D-CUrvd1.mjs} +287 -20
- package/dist/{version-aKfgWHzo.mjs → version-BwHks7Wg.mjs} +1 -1
- package/package.json +6 -6
- package/dist/client-jwks-DY2QBrsl.d.mts +0 -25
|
@@ -1,10 +1,49 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
2
|
import { PrivateKeyJwtSigningAlgorithm } from "@better-auth/core/oauth2";
|
|
3
|
-
import { JWTPayload } from "jose";
|
|
4
3
|
import { JWSAlgorithms } from "better-auth/plugins";
|
|
4
|
+
import { JWTPayload } from "jose";
|
|
5
5
|
import { InferOptionSchema, Session, User } from "better-auth/types";
|
|
6
6
|
import { GenericEndpointContext, LiteralString } from "@better-auth/core";
|
|
7
7
|
|
|
8
|
+
//#region src/register.d.ts
|
|
9
|
+
type OAuthClientRegistrationMetadata = Omit<OAuthClient, "client_id" | "redirect_uris" | "client_secret_expires_at"> & {
|
|
10
|
+
client_id?: string;
|
|
11
|
+
redirect_uris?: string[];
|
|
12
|
+
client_secret_expires_at?: number | string;
|
|
13
|
+
metadata?: Record<string, unknown>;
|
|
14
|
+
resources?: string[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Rejects a URI the server will POST to unless it is an absolute https URL
|
|
18
|
+
* with no fragment or credentials on a publicly routable host. Back-channel
|
|
19
|
+
* endpoints use it as an SSRF guard, since the server, not the browser, calls
|
|
20
|
+
* them.
|
|
21
|
+
*/
|
|
22
|
+
declare function assertPublicRoutableHttpsUri(field: string, uri: string): void;
|
|
23
|
+
interface OAuthClientRegistrationResult {
|
|
24
|
+
client: SchemaClient<Scope[]>;
|
|
25
|
+
clientSecret?: string;
|
|
26
|
+
resources: string[];
|
|
27
|
+
created: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface RegisterClientMetadataDocumentInput {
|
|
30
|
+
metadata: OAuthClient;
|
|
31
|
+
clientId: string;
|
|
32
|
+
clientDiscoveryId: string;
|
|
33
|
+
existingClient?: SchemaClient<Scope[]>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* First-party persistence seam for a validated Client ID Metadata Document.
|
|
37
|
+
*
|
|
38
|
+
* This operation owns both initial creation and atomic replacement. It never
|
|
39
|
+
* generates a client secret, preserves operator-controlled flags on
|
|
40
|
+
* replacement, and ensures server-default resource links in the same
|
|
41
|
+
* transaction.
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
declare function registerClientMetadataDocument(ctx: GenericEndpointContext, opts: OAuthOptions<Scope[]>, input: RegisterClientMetadataDocumentInput): Promise<OAuthClientRegistrationResult>;
|
|
46
|
+
//#endregion
|
|
8
47
|
//#region src/schema.d.ts
|
|
9
48
|
declare const schema: {
|
|
10
49
|
oauthClient: {
|
|
@@ -40,6 +79,10 @@ declare const schema: {
|
|
|
40
79
|
type: "string";
|
|
41
80
|
required: false;
|
|
42
81
|
};
|
|
82
|
+
sectorIdentifier: {
|
|
83
|
+
type: "string";
|
|
84
|
+
required: false;
|
|
85
|
+
};
|
|
43
86
|
scopes: {
|
|
44
87
|
type: "string[]";
|
|
45
88
|
required: false;
|
|
@@ -118,6 +161,14 @@ declare const schema: {
|
|
|
118
161
|
type: "boolean";
|
|
119
162
|
required: false;
|
|
120
163
|
};
|
|
164
|
+
frontchannelLogoutUri: {
|
|
165
|
+
type: "string";
|
|
166
|
+
required: false;
|
|
167
|
+
};
|
|
168
|
+
frontchannelLogoutSessionRequired: {
|
|
169
|
+
type: "boolean";
|
|
170
|
+
required: false;
|
|
171
|
+
};
|
|
121
172
|
tokenEndpointAuthMethod: {
|
|
122
173
|
type: "string";
|
|
123
174
|
required: false;
|
|
@@ -371,6 +422,14 @@ declare const schema: {
|
|
|
371
422
|
type: "date";
|
|
372
423
|
required: false;
|
|
373
424
|
};
|
|
425
|
+
acr: {
|
|
426
|
+
type: "string";
|
|
427
|
+
required: false;
|
|
428
|
+
};
|
|
429
|
+
amr: {
|
|
430
|
+
type: "string[]";
|
|
431
|
+
required: false;
|
|
432
|
+
};
|
|
374
433
|
confirmation: {
|
|
375
434
|
type: "json";
|
|
376
435
|
required: false;
|
|
@@ -582,6 +641,8 @@ declare const clientRegistrationRequestSchema: z.ZodObject<{
|
|
|
582
641
|
post_logout_redirect_uris: z.ZodOptional<z.ZodArray<z.ZodURL>>;
|
|
583
642
|
backchannel_logout_uri: z.ZodOptional<z.ZodURL>;
|
|
584
643
|
backchannel_logout_session_required: z.ZodOptional<z.ZodBoolean>;
|
|
644
|
+
frontchannel_logout_uri: z.ZodOptional<z.ZodURL>;
|
|
645
|
+
frontchannel_logout_session_required: z.ZodOptional<z.ZodBoolean>;
|
|
585
646
|
token_endpoint_auth_method: z.ZodOptional<z.ZodString>;
|
|
586
647
|
jwks: z.ZodOptional<z.ZodObject<{
|
|
587
648
|
keys: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
@@ -614,26 +675,27 @@ declare const clientRegistrationRequestSchema: z.ZodObject<{
|
|
|
614
675
|
* unknown extension without unsafe casts or ad-hoc allowlists.
|
|
615
676
|
*/
|
|
616
677
|
declare const oauthClientMetadataSchema: z.ZodObject<{
|
|
617
|
-
contacts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
618
678
|
jwks: z.ZodOptional<z.ZodObject<{
|
|
619
679
|
keys: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
620
680
|
}, z.core.$strip>>;
|
|
621
|
-
|
|
681
|
+
contacts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
622
682
|
scope: z.ZodOptional<z.ZodString>;
|
|
623
|
-
redirect_uris: z.ZodOptional<z.ZodArray<z.ZodURL>>;
|
|
624
683
|
client_name: z.ZodOptional<z.ZodString>;
|
|
625
684
|
client_uri: z.ZodOptional<z.ZodString>;
|
|
626
685
|
logo_uri: z.ZodOptional<z.ZodString>;
|
|
627
686
|
tos_uri: z.ZodOptional<z.ZodString>;
|
|
628
687
|
policy_uri: z.ZodOptional<z.ZodString>;
|
|
688
|
+
jwks_uri: z.ZodOptional<z.ZodString>;
|
|
629
689
|
software_id: z.ZodOptional<z.ZodString>;
|
|
630
690
|
software_version: z.ZodOptional<z.ZodString>;
|
|
631
691
|
software_statement: z.ZodOptional<z.ZodString>;
|
|
692
|
+
redirect_uris: z.ZodOptional<z.ZodArray<z.ZodURL>>;
|
|
632
693
|
post_logout_redirect_uris: z.ZodOptional<z.ZodArray<z.ZodURL>>;
|
|
633
694
|
backchannel_logout_uri: z.ZodOptional<z.ZodURL>;
|
|
634
695
|
backchannel_logout_session_required: z.ZodOptional<z.ZodBoolean>;
|
|
696
|
+
frontchannel_logout_uri: z.ZodOptional<z.ZodURL>;
|
|
697
|
+
frontchannel_logout_session_required: z.ZodOptional<z.ZodBoolean>;
|
|
635
698
|
token_endpoint_auth_method: z.ZodOptional<z.ZodString>;
|
|
636
|
-
jwks_uri: z.ZodOptional<z.ZodString>;
|
|
637
699
|
grant_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
638
700
|
response_types: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
639
701
|
code: "code";
|
|
@@ -642,11 +704,12 @@ declare const oauthClientMetadataSchema: z.ZodObject<{
|
|
|
642
704
|
web: "web";
|
|
643
705
|
native: "native";
|
|
644
706
|
}>>;
|
|
707
|
+
dpop_bound_access_tokens: z.ZodOptional<z.ZodBoolean>;
|
|
645
708
|
subject_type: z.ZodOptional<z.ZodEnum<{
|
|
646
709
|
public: "public";
|
|
647
710
|
pairwise: "pairwise";
|
|
648
711
|
}>>;
|
|
649
|
-
|
|
712
|
+
resources: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
650
713
|
client_id: z.ZodString;
|
|
651
714
|
client_secret: z.ZodOptional<z.ZodString>;
|
|
652
715
|
client_secret_expires_at: z.ZodOptional<z.ZodNumber>;
|
|
@@ -666,6 +729,55 @@ type ClientRegistrationRequest = z.infer<typeof clientRegistrationRequestSchema>
|
|
|
666
729
|
//#endregion
|
|
667
730
|
//#region src/types/index.d.ts
|
|
668
731
|
type StoreTokenType = "access_token" | "refresh_token" | "authorization_code" | (string & {});
|
|
732
|
+
/**
|
|
733
|
+
* The authentication context the provider asserts in ID tokens
|
|
734
|
+
* (OIDC Core 1.0 §2).
|
|
735
|
+
*/
|
|
736
|
+
interface OAuthAuthenticationContext {
|
|
737
|
+
/**
|
|
738
|
+
* Authentication Context Class Reference the session satisfies. Must be one
|
|
739
|
+
* of `acrValuesSupported`. Defaults to `"0"`.
|
|
740
|
+
*/
|
|
741
|
+
acr?: string;
|
|
742
|
+
/**
|
|
743
|
+
* Authentication Methods References used for the session, such as
|
|
744
|
+
* `["pwd", "otp"]` (RFC 8176).
|
|
745
|
+
*/
|
|
746
|
+
amr?: string[];
|
|
747
|
+
}
|
|
748
|
+
interface OAuthAuthenticationContextOptions<Scopes extends readonly Scope[] = InternallySupportedScopes[]> {
|
|
749
|
+
/**
|
|
750
|
+
* ACR values this provider can assert, advertised as
|
|
751
|
+
* `acr_values_supported` in discovery. Include `"0"` when `resolve` can
|
|
752
|
+
* return no `acr`.
|
|
753
|
+
*/
|
|
754
|
+
acrValuesSupported: string[];
|
|
755
|
+
/**
|
|
756
|
+
* Returns the `acr` and `amr` the current session establishes. Called when
|
|
757
|
+
* the user approves an authorization request or a device code. Return only
|
|
758
|
+
* what the session actually proved; do not raise `acr` to match
|
|
759
|
+
* `requestedAcrValues`.
|
|
760
|
+
*
|
|
761
|
+
* An essential `acr` request (`claims.id_token.acr.essential`) that the
|
|
762
|
+
* returned `acr` does not satisfy fails with `access_denied`. A voluntary
|
|
763
|
+
* request (`acr_values` or a non-essential `acr` claim) never fails.
|
|
764
|
+
*
|
|
765
|
+
* Not called for requests without the `openid` scope, which issue no ID
|
|
766
|
+
* token.
|
|
767
|
+
*/
|
|
768
|
+
resolve: (info: {
|
|
769
|
+
user: User & Record<string, unknown>;
|
|
770
|
+
session: Session & Record<string, unknown>;
|
|
771
|
+
client: SchemaClient<Scopes>; /** Scopes being approved */
|
|
772
|
+
scopes: string[]; /** Headers of the request approving the authorization */
|
|
773
|
+
headers: Headers;
|
|
774
|
+
/**
|
|
775
|
+
* ACR values the client requested, from `claims.id_token.acr` and
|
|
776
|
+
* `acr_values`, in order of preference.
|
|
777
|
+
*/
|
|
778
|
+
requestedAcrValues: string[];
|
|
779
|
+
}) => Awaitable<OAuthAuthenticationContext | undefined>;
|
|
780
|
+
}
|
|
669
781
|
type InternallySupportedScopes = "openid" | "profile" | "email" | "offline_access";
|
|
670
782
|
type Scope = LiteralString | InternallySupportedScopes;
|
|
671
783
|
/**
|
|
@@ -779,6 +891,10 @@ interface OAuthTokenIssueParams {
|
|
|
779
891
|
id: string;
|
|
780
892
|
};
|
|
781
893
|
authTime?: Date;
|
|
894
|
+
/** The `acr` ID token claim. Defaults to `"0"`. */
|
|
895
|
+
acr?: string;
|
|
896
|
+
/** The `amr` ID token claim. */
|
|
897
|
+
amr?: string[];
|
|
782
898
|
verificationValue?: VerificationValue;
|
|
783
899
|
resources?: string[];
|
|
784
900
|
/** Full original authorized resources for the grant, used to seed refresh tokens. */
|
|
@@ -820,6 +936,14 @@ interface OAuthTokenIssueParams {
|
|
|
820
936
|
* is stamped after, and cannot be overridden by, contributed claims.
|
|
821
937
|
*/
|
|
822
938
|
confirmation?: Confirmation;
|
|
939
|
+
/**
|
|
940
|
+
* Latest time the access token may expire. The authorization server issues
|
|
941
|
+
* the earlier of this and its configured lifetime, so a grant derived from
|
|
942
|
+
* another token (for example RFC 8693 token exchange) cannot outlive it.
|
|
943
|
+
* If it is not in the future, issuance fails with `invalid_request`. Refresh
|
|
944
|
+
* and ID tokens are not capped, so such a grant should not issue them.
|
|
945
|
+
*/
|
|
946
|
+
maxExpiresAt?: Date;
|
|
823
947
|
}
|
|
824
948
|
interface OAuthTokenResponse {
|
|
825
949
|
access_token: string;
|
|
@@ -852,7 +976,10 @@ interface OAuthProviderApi {
|
|
|
852
976
|
* or none). For assertion-based methods, the RFC 7523 audience is bound to the
|
|
853
977
|
* endpoint serving the request, so an assertion cannot be replayed across
|
|
854
978
|
* endpoints. Returns the authenticated client, plus any `confirmation` an
|
|
855
|
-
* assertion strategy proved.
|
|
979
|
+
* assertion strategy proved. A companion endpoint that accepts
|
|
980
|
+
* `application/x-www-form-urlencoded` must set `cloneRequest: true` in its
|
|
981
|
+
* endpoint options because client authentication re-reads the raw form body
|
|
982
|
+
* to enforce credential cardinality and reject mixed authentication methods.
|
|
856
983
|
*/
|
|
857
984
|
authenticateClient: (request?: OAuthClientAuthenticationRequest) => Awaitable<OAuthAuthenticatedClient>;
|
|
858
985
|
/**
|
|
@@ -869,6 +996,21 @@ interface OAuthProviderApi {
|
|
|
869
996
|
* calling it.
|
|
870
997
|
*/
|
|
871
998
|
issueTokens: (params: OAuthTokenIssueParams) => Awaitable<OAuthTokenResponse>;
|
|
999
|
+
/**
|
|
1000
|
+
* Resolves the sender-constraint the tokens for this request will carry: the
|
|
1001
|
+
* `confirmation` the client proved at authentication, or else the DPoP proof
|
|
1002
|
+
* on this request, verified and required by the same rules `issueTokens`
|
|
1003
|
+
* applies. A grant that consumes a one-time credential (a device code, a CIBA
|
|
1004
|
+
* request) calls this before the claim and passes the result to
|
|
1005
|
+
* `issueTokens` as `confirmation`, so a rejected proof leaves the credential
|
|
1006
|
+
* for a retry with a valid one.
|
|
1007
|
+
*/
|
|
1008
|
+
resolveConfirmation: (params: {
|
|
1009
|
+
client: SchemaClient<Scope[]>;
|
|
1010
|
+
scopes: string[];
|
|
1011
|
+
resources?: string[];
|
|
1012
|
+
confirmation?: Confirmation;
|
|
1013
|
+
}) => Promise<Confirmation | undefined>;
|
|
872
1014
|
/**
|
|
873
1015
|
* Computes the stored lookup key for a token value (the same hash the
|
|
874
1016
|
* provider persists), so a caller can find or revoke a previously issued
|
|
@@ -998,7 +1140,7 @@ interface OAuthUserInfoExtensionInput {
|
|
|
998
1140
|
* `extendOAuthProvider(ctx, extension)` (or the `oauthProvider({ extensions })`
|
|
999
1141
|
* option).
|
|
1000
1142
|
*
|
|
1001
|
-
* All
|
|
1143
|
+
* All seven kinds live on one object so a single protocol plugin (for example
|
|
1002
1144
|
* RFC 8693 token exchange, which adds a grant, advertises metadata, and emits
|
|
1003
1145
|
* claims) registers atomically and the host validates the combined surface in
|
|
1004
1146
|
* one place. Every field is independently optional, so a single-concern plugin
|
|
@@ -1006,10 +1148,11 @@ interface OAuthUserInfoExtensionInput {
|
|
|
1006
1148
|
* just the one it needs. This is the shape every future OAuth RFC plugin copies.
|
|
1007
1149
|
*
|
|
1008
1150
|
* Two contribution disciplines:
|
|
1009
|
-
* - Dispatched kinds (`grants`, `clientAuthentication`)
|
|
1010
|
-
* extensions: registering a grant type, auth method,
|
|
1011
|
-
*
|
|
1012
|
-
* would otherwise be
|
|
1151
|
+
* - Dispatched kinds (`grants`, `clientAuthentication`, `interactionRequests`)
|
|
1152
|
+
* must be disjoint across extensions: registering a grant type, auth method,
|
|
1153
|
+
* assertion type, or interaction parameter that another extension already
|
|
1154
|
+
* registered is rejected at setup, since the second would otherwise be
|
|
1155
|
+
* silently unreachable.
|
|
1013
1156
|
* - Additive kinds (`metadata`, `claims`) never override authorization-server
|
|
1014
1157
|
* core; a key already owned by the provider is kept, and a key two extensions
|
|
1015
1158
|
* both contribute resolves to the first-registered extension.
|
|
@@ -1059,6 +1202,117 @@ interface OAuthProviderExtension {
|
|
|
1059
1202
|
* registry, an attestation header) contributes it here.
|
|
1060
1203
|
*/
|
|
1061
1204
|
clientDiscovery?: ClientDiscovery | ClientDiscovery[];
|
|
1205
|
+
/**
|
|
1206
|
+
* Client registration metadata the extension defines, such as CIBA's
|
|
1207
|
+
* `backchannel_token_delivery_mode`. Extension fields live in the client's
|
|
1208
|
+
* `metadata`.
|
|
1209
|
+
*/
|
|
1210
|
+
clientMetadata?: {
|
|
1211
|
+
/**
|
|
1212
|
+
* Top-level registration fields the extension defines. Dynamic client
|
|
1213
|
+
* registration (RFC 7591 §2) and client metadata documents (CIMD) both
|
|
1214
|
+
* ignore unrecognized fields; they keep these and store them in the
|
|
1215
|
+
* client's `metadata`, where admin-created clients put them too. Core
|
|
1216
|
+
* and server-owned client fields cannot be claimed.
|
|
1217
|
+
*/
|
|
1218
|
+
fields?: string[];
|
|
1219
|
+
/**
|
|
1220
|
+
* Validates the extension's fields when a client is registered through
|
|
1221
|
+
* dynamic registration or a client metadata document, or created or
|
|
1222
|
+
* updated by an admin. Throw an `APIError` with `invalid_client_metadata`
|
|
1223
|
+
* to reject the client.
|
|
1224
|
+
*/
|
|
1225
|
+
validate?: (input: OAuthClientMetadataExtensionInput) => Awaitable<void>;
|
|
1226
|
+
};
|
|
1227
|
+
/**
|
|
1228
|
+
* Requests other than an authorization request that users approve through
|
|
1229
|
+
* the `/oauth2/authorize` sign-in, account selection, post-login, and
|
|
1230
|
+
* consent pages, keyed by the query parameter that identifies one, such as
|
|
1231
|
+
* `user_code`. Every interaction page resumes them through
|
|
1232
|
+
* `/oauth2/authorize`.
|
|
1233
|
+
*/
|
|
1234
|
+
interactionRequests?: Record<string, OAuthInteractionRequestHandler>;
|
|
1235
|
+
}
|
|
1236
|
+
/**
|
|
1237
|
+
* Parameters signed into each interaction page. An authorization request
|
|
1238
|
+
* carries its `redirect_uri`; other interaction requests have none and add
|
|
1239
|
+
* their own identifying parameter, such as `user_code`.
|
|
1240
|
+
*/
|
|
1241
|
+
type OAuthInteractionQuery = Omit<OAuthAuthorizationQuery, "redirect_uri"> & {
|
|
1242
|
+
redirect_uri?: string | undefined;
|
|
1243
|
+
};
|
|
1244
|
+
/**
|
|
1245
|
+
* A request the user reviews through the `/oauth2/authorize` sign-in,
|
|
1246
|
+
* account selection, signup, post-login, and consent pages.
|
|
1247
|
+
*/
|
|
1248
|
+
interface OAuthInteractionRequest {
|
|
1249
|
+
/** Signed into each interaction page; carries `prompt` and `max_age`. */
|
|
1250
|
+
query: OAuthInteractionQuery;
|
|
1251
|
+
/** The provider sends the user to the error page when this client is disabled. */
|
|
1252
|
+
client: SchemaClient<Scope[]>;
|
|
1253
|
+
/**
|
|
1254
|
+
* Show the consent page even when consent is stored or the client skips
|
|
1255
|
+
* it, and approve only in the request where the user accepts on that page.
|
|
1256
|
+
*/
|
|
1257
|
+
requireConsent?: boolean | undefined;
|
|
1258
|
+
/**
|
|
1259
|
+
* Records the approval once every interaction is complete and returns the
|
|
1260
|
+
* URL to send the user to.
|
|
1261
|
+
*/
|
|
1262
|
+
approve: (approval: {
|
|
1263
|
+
query: OAuthInteractionQuery;
|
|
1264
|
+
userId: string;
|
|
1265
|
+
sessionId: string;
|
|
1266
|
+
authTime: number;
|
|
1267
|
+
acr?: string;
|
|
1268
|
+
amr?: string[];
|
|
1269
|
+
referenceId?: string;
|
|
1270
|
+
}) => Promise<string>;
|
|
1271
|
+
}
|
|
1272
|
+
/** Loads and denies one kind of {@link OAuthInteractionRequest}. */
|
|
1273
|
+
interface OAuthInteractionRequestHandler {
|
|
1274
|
+
/**
|
|
1275
|
+
* Loads the request identified by `value`. On a direct `/oauth2/authorize`
|
|
1276
|
+
* request only `value` comes from the caller; when resuming after an
|
|
1277
|
+
* interaction page, `signedQuery` is the query this server signed into it.
|
|
1278
|
+
* Throw an `APIError` when the request can no longer be approved.
|
|
1279
|
+
*/
|
|
1280
|
+
load: (input: {
|
|
1281
|
+
ctx: GenericEndpointContext;
|
|
1282
|
+
opts: OAuthOptions<Scope[]>;
|
|
1283
|
+
value: string;
|
|
1284
|
+
signedQuery?: OAuthInteractionQuery | undefined;
|
|
1285
|
+
}) => Promise<OAuthInteractionRequest>;
|
|
1286
|
+
/**
|
|
1287
|
+
* Records a denial from the consent page and returns the URL to send the
|
|
1288
|
+
* user to.
|
|
1289
|
+
*/
|
|
1290
|
+
deny: (input: {
|
|
1291
|
+
ctx: GenericEndpointContext;
|
|
1292
|
+
value: string;
|
|
1293
|
+
userId: string;
|
|
1294
|
+
}) => Promise<string>;
|
|
1295
|
+
/**
|
|
1296
|
+
* Where to send the user when the request cannot be loaded, approved, or
|
|
1297
|
+
* denied, such as a page where they can correct it. The provider appends
|
|
1298
|
+
* `error` and `error_description`. Defaults to the provider error page.
|
|
1299
|
+
*/
|
|
1300
|
+
errorPage?: (input: {
|
|
1301
|
+
ctx: GenericEndpointContext;
|
|
1302
|
+
value: string;
|
|
1303
|
+
}) => string;
|
|
1304
|
+
}
|
|
1305
|
+
interface OAuthClientMetadataExtensionInput {
|
|
1306
|
+
/**
|
|
1307
|
+
* The client's core registration metadata after provider defaults. Read
|
|
1308
|
+
* extension fields from `metadata`, not from here.
|
|
1309
|
+
*/
|
|
1310
|
+
client: Omit<OAuthClientRegistrationMetadata, "metadata">;
|
|
1311
|
+
/**
|
|
1312
|
+
* The client's `metadata` as it will be stored, with reserved client field
|
|
1313
|
+
* names removed. Extension fields are read from here.
|
|
1314
|
+
*/
|
|
1315
|
+
metadata: Record<string, unknown>;
|
|
1062
1316
|
}
|
|
1063
1317
|
/**
|
|
1064
1318
|
* Result of authorizing an RFC 7591 initial access token, returned by
|
|
@@ -1073,6 +1327,19 @@ interface InitialAccessTokenAuthorization {
|
|
|
1073
1327
|
* client is stored with neither a `user_id` nor a `reference_id`).
|
|
1074
1328
|
*/
|
|
1075
1329
|
referenceId?: string;
|
|
1330
|
+
/**
|
|
1331
|
+
* Scope ceiling for the `client_credentials` grant, such as the machine
|
|
1332
|
+
* scopes an administrator approved when the token was issued. Return only
|
|
1333
|
+
* scopes that approval covered: the token is the only proof of it.
|
|
1334
|
+
*
|
|
1335
|
+
* The client must register the `client_credentials` grant with a
|
|
1336
|
+
* confidential authentication method, and every scope must be one the
|
|
1337
|
+
* provider offers and not a user-delegated scope such as `openid`.
|
|
1338
|
+
* Otherwise registration fails.
|
|
1339
|
+
*
|
|
1340
|
+
* @default []
|
|
1341
|
+
*/
|
|
1342
|
+
clientCredentialsScopes?: string[];
|
|
1076
1343
|
}
|
|
1077
1344
|
interface OAuthOptions<Scopes extends readonly Scope[] = InternallySupportedScopes[]> {
|
|
1078
1345
|
/**
|
|
@@ -1770,6 +2037,14 @@ interface OAuthOptions<Scopes extends readonly Scope[] = InternallySupportedScop
|
|
|
1770
2037
|
*/
|
|
1771
2038
|
requestedClaims: string[];
|
|
1772
2039
|
}) => Awaitable<Record<string, any>>;
|
|
2040
|
+
/**
|
|
2041
|
+
* Asserts the `acr` and `amr` ID token claims for each approved
|
|
2042
|
+
* authorization request.
|
|
2043
|
+
*
|
|
2044
|
+
* Without this option, ID tokens carry `acr: "0"` (OIDC level 0) and no
|
|
2045
|
+
* `amr`.
|
|
2046
|
+
*/
|
|
2047
|
+
authenticationContext?: OAuthAuthenticationContextOptions<Scopes>;
|
|
1773
2048
|
/**
|
|
1774
2049
|
* Custom claims attached to OIDC id tokens.
|
|
1775
2050
|
*
|
|
@@ -2309,6 +2584,8 @@ interface VerificationValue {
|
|
|
2309
2584
|
resource?: string[];
|
|
2310
2585
|
referenceId?: string;
|
|
2311
2586
|
authTime?: number;
|
|
2587
|
+
acr?: string;
|
|
2588
|
+
amr?: string[];
|
|
2312
2589
|
}
|
|
2313
2590
|
/**
|
|
2314
2591
|
* Client registered values as used within the plugin
|
|
@@ -2405,6 +2682,25 @@ interface SchemaClient<Scopes extends readonly Scope[] = InternallySupportedScop
|
|
|
2405
2682
|
* @default false
|
|
2406
2683
|
*/
|
|
2407
2684
|
backchannelLogoutSessionRequired?: boolean;
|
|
2685
|
+
/**
|
|
2686
|
+
* RP URL rendered in a hidden iframe on the OP's logout page when the
|
|
2687
|
+
* end-user's session ends at `/oauth2/end-session`. Registering it is the
|
|
2688
|
+
* per-client opt-in for front-channel logout. Must be absolute, without a
|
|
2689
|
+
* fragment, and share the scheme, host, and port of a registered redirect
|
|
2690
|
+
* URI.
|
|
2691
|
+
*
|
|
2692
|
+
* @see https://openid.net/specs/openid-connect-frontchannel-1_0.html#RPLogout
|
|
2693
|
+
*/
|
|
2694
|
+
frontchannelLogoutUri?: string;
|
|
2695
|
+
/**
|
|
2696
|
+
* When true, the RP requires `iss` and `sid` query parameters on its
|
|
2697
|
+
* front-channel logout URI. The OP includes both whenever it notifies a
|
|
2698
|
+
* front-channel client, so this flag is stored but does not change
|
|
2699
|
+
* delivery.
|
|
2700
|
+
*
|
|
2701
|
+
* @default false
|
|
2702
|
+
*/
|
|
2703
|
+
frontchannelLogoutSessionRequired?: boolean;
|
|
2408
2704
|
tokenEndpointAuthMethod?: TokenEndpointAuthMethod;
|
|
2409
2705
|
grantTypes?: GrantType[];
|
|
2410
2706
|
responseTypes?: "code"[];
|
|
@@ -2437,6 +2733,12 @@ interface SchemaClient<Scopes extends readonly Scope[] = InternallySupportedScop
|
|
|
2437
2733
|
enableEndSession?: boolean;
|
|
2438
2734
|
/** Subject identifier type: "public" (default) or "pairwise" */
|
|
2439
2735
|
subjectType?: "public" | "pairwise";
|
|
2736
|
+
/**
|
|
2737
|
+
* Pairwise sector, set by the server when the client is created. `null`
|
|
2738
|
+
* for clients created before sectors were stored; those keep the sector
|
|
2739
|
+
* derived from their first redirect URI host.
|
|
2740
|
+
*/
|
|
2741
|
+
sectorIdentifier?: string | null;
|
|
2440
2742
|
/** Reference to the owner of this client. Eg. Organization, Team, Profile */
|
|
2441
2743
|
referenceId?: string;
|
|
2442
2744
|
/**
|
|
@@ -2553,6 +2855,10 @@ interface OAuthRefreshToken<Scopes extends readonly Scope[] = InternallySupporte
|
|
|
2553
2855
|
* Persisted so refreshed ID tokens can include a correct `auth_time` claim.
|
|
2554
2856
|
*/
|
|
2555
2857
|
authTime?: Date;
|
|
2858
|
+
/** The `acr` asserted at authorization, carried forward on rotation. */
|
|
2859
|
+
acr?: string;
|
|
2860
|
+
/** The `amr` asserted at authorization, carried forward on rotation. */
|
|
2861
|
+
amr?: string[];
|
|
2556
2862
|
/**
|
|
2557
2863
|
* Scopes granted for this refresh token.
|
|
2558
2864
|
*
|
|
@@ -2818,6 +3124,27 @@ interface AuthServerMetadata {
|
|
|
2818
3124
|
* @see https://datatracker.ietf.org/doc/html/rfc9449
|
|
2819
3125
|
*/
|
|
2820
3126
|
dpop_signing_alg_values_supported?: JWSAlgorithms[];
|
|
3127
|
+
/**
|
|
3128
|
+
* Boolean value specifying whether the OP supports HTTP-based (front-channel)
|
|
3129
|
+
* logout, with true indicating support.
|
|
3130
|
+
*
|
|
3131
|
+
* Registered in the "OAuth Authorization Server Metadata" IANA registry
|
|
3132
|
+
* under OpenID Connect Front-Channel Logout 1.0, so this may appear at both
|
|
3133
|
+
* `.well-known/oauth-authorization-server` and `.well-known/openid-configuration`.
|
|
3134
|
+
*
|
|
3135
|
+
* @default false
|
|
3136
|
+
* @see https://openid.net/specs/openid-connect-frontchannel-1_0.html#OPLogout
|
|
3137
|
+
*/
|
|
3138
|
+
frontchannel_logout_supported?: boolean;
|
|
3139
|
+
/**
|
|
3140
|
+
* Boolean value specifying whether the OP can pass `iss` (issuer) and `sid`
|
|
3141
|
+
* (session ID) query parameters to identify the RP session with the OP when
|
|
3142
|
+
* the `frontchannel_logout_uri` is used.
|
|
3143
|
+
*
|
|
3144
|
+
* @default false
|
|
3145
|
+
* @see https://openid.net/specs/openid-connect-frontchannel-1_0.html#OPLogout
|
|
3146
|
+
*/
|
|
3147
|
+
frontchannel_logout_session_supported?: boolean;
|
|
2821
3148
|
}
|
|
2822
3149
|
/**
|
|
2823
3150
|
* Metadata returned by the openid-configuration endpoint:
|
|
@@ -2957,6 +3284,25 @@ interface OAuthClient {
|
|
|
2957
3284
|
* @see https://openid.net/specs/openid-connect-backchannel-1_0.html#RPMetadata
|
|
2958
3285
|
*/
|
|
2959
3286
|
backchannel_logout_session_required?: boolean;
|
|
3287
|
+
/**
|
|
3288
|
+
* RP URL that the OP renders in a hidden iframe on its logout page so the
|
|
3289
|
+
* RP can log itself out when the end-user's OP session ends at
|
|
3290
|
+
* `/oauth2/end-session`. Must share the scheme, host, and port of one of
|
|
3291
|
+
* the client's `redirect_uris`.
|
|
3292
|
+
*
|
|
3293
|
+
* @see https://openid.net/specs/openid-connect-frontchannel-1_0.html#RPLogout
|
|
3294
|
+
*/
|
|
3295
|
+
frontchannel_logout_uri?: string;
|
|
3296
|
+
/**
|
|
3297
|
+
* When true, the RP requires `iss` and `sid` query parameters on its
|
|
3298
|
+
* `frontchannel_logout_uri`. The OP includes both whenever it notifies a
|
|
3299
|
+
* front-channel client, so this flag is stored but does not change
|
|
3300
|
+
* delivery.
|
|
3301
|
+
*
|
|
3302
|
+
* @default false
|
|
3303
|
+
* @see https://openid.net/specs/openid-connect-frontchannel-1_0.html#RPLogout
|
|
3304
|
+
*/
|
|
3305
|
+
frontchannel_logout_session_required?: boolean;
|
|
2960
3306
|
token_endpoint_auth_method?: TokenEndpointAuthMethod;
|
|
2961
3307
|
grant_types?: GrantType[];
|
|
2962
3308
|
response_types?: "code"[];
|
|
@@ -3034,4 +3380,4 @@ interface ResourceServerMetadata {
|
|
|
3034
3380
|
dpop_bound_access_tokens_required?: boolean;
|
|
3035
3381
|
}
|
|
3036
3382
|
//#endregion
|
|
3037
|
-
export {
|
|
3383
|
+
export { OAuthClientMetadata as $, OAuthExtensionGrantHandler as A, OAuthRefreshToken as B, OAuthClientAuthenticationRequest as C, OAuthClientRegistrationResponse as D, OAuthClientMetadataExtensionInput as E, OAuthMetadataExtensionInput as F, OAuthUserInfoExtensionInput as G, OAuthResourceInput as H, OAuthOpaqueAccessToken as I, Scope as J, Prompt as K, OAuthOptions as L, OAuthInteractionQuery as M, OAuthInteractionRequest as N, OAuthClientResource as O, OAuthInteractionRequestHandler as P, ClientRegistrationRequest as Q, OAuthProviderApi as R, OAuthClientAuthenticationInput as S, OAuthClientAuthenticationStrategy as T, OAuthTokenIssueParams as U, OAuthResource as V, OAuthTokenResponse as W, StoredAuthorizationQuery as X, StoreTokenType as Y, VerificationValue as Z, OAuthAuthenticationContext as _, GrantType as a, OAuthClientRegistrationResult as at, OAuthClaimExtensionInput as b, ResourceServerMetadata as c, registerClientMetadataDocument as ct, ActiveAccessTokenPayload as d, ResourceUriSchema as et, AuthorizePrompt as f, OAuthAuthenticatedClient as g, InitialAccessTokenAuthorization as h, Confirmation as i, OAuthClientRegistrationMetadata as it, OAuthExtensionGrantHandlerInput as j, OAuthConsent as k, TokenEndpointAuthMethod as l, ClientMetadataResourceFetch as m, AuthServerMetadata as n, oauthClientMetadataSchema as nt, OAuthClient as o, RegisterClientMetadataDocumentInput as ot, ClientDiscovery as p, SchemaClient as q, BearerMethodsSupported as r, Awaitable as rt, OIDCMetadata as s, assertPublicRoutableHttpsUri as st, AuthMethod as t, clientRegistrationRequestSchema as tt, TokenType as u, OAuthAuthenticationContextOptions as v, OAuthClientAuthenticationResult as w, OAuthClientAdministrativeResponse as x, OAuthAuthorizationQuery as y, OAuthProviderExtension as z };
|