@better-auth/sso 1.4.7-beta.3 → 1.4.7

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,5 +1,5 @@
1
1
 
2
- > @better-auth/sso@1.4.7-beta.3 build /home/runner/work/better-auth/better-auth/packages/sso
2
+ > @better-auth/sso@1.4.7 build /home/runner/work/better-auth/better-auth/packages/sso
3
3
  > tsdown
4
4
 
5
5
  ℹ tsdown v0.17.2 powered by rolldown v1.0.0-beta.53
@@ -7,10 +7,10 @@
7
7
  ℹ entry: src/index.ts, src/client.ts
8
8
  ℹ tsconfig: tsconfig.json
9
9
  ℹ Build start
10
- ℹ dist/index.mjs 65.14 kB │ gzip: 11.40 kB
10
+ ℹ dist/index.mjs 83.77 kB │ gzip: 15.84 kB
11
11
  ℹ dist/client.mjs  0.15 kB │ gzip: 0.14 kB
12
- ℹ dist/client.d.mts  0.49 kB │ gzip: 0.29 kB
13
- ℹ dist/index.d.mts  0.43 kB │ gzip: 0.23 kB
14
- ℹ dist/index-m7FISidt.d.mts 28.63 kB │ gzip: 5.07 kB
15
- ℹ 5 files, total: 94.85 kB
16
- ✔ Build complete in 11484ms
12
+ ℹ dist/index.d.mts  1.44 kB │ gzip: 0.52 kB
13
+ ℹ dist/client.d.mts  0.49 kB │ gzip: 0.30 kB
14
+ ℹ dist/index-B9WMxRdD.d.mts 41.59 kB │ gzip: 8.59 kB
15
+ ℹ 5 files, total: 127.44 kB
16
+ ✔ Build complete in 12101ms
package/dist/client.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as SSOPlugin } from "./index-m7FISidt.mjs";
1
+ import { t as SSOPlugin } from "./index-B9WMxRdD.mjs";
2
2
 
3
3
  //#region src/client.d.ts
4
4
  interface SSOClientOptions {
@@ -1,6 +1,7 @@
1
+ import { APIError } from "better-auth/api";
1
2
  import * as z from "zod/v4";
2
3
  import { OAuth2Tokens, User } from "better-auth";
3
- import * as better_call0 from "better-call";
4
+ import * as better_call7 from "better-call";
4
5
 
5
6
  //#region src/authn-request-store.d.ts
6
7
 
@@ -252,13 +253,7 @@ interface SSOOptions {
252
253
  *
253
254
  * If you want to allow account linking for specific trusted providers, enable the `accountLinking` option in your auth config and specify those
254
255
  * providers in the `trustedProviders` list.
255
- *
256
256
  * @default false
257
- *
258
- * @deprecated This option is discouraged for new projects. Relying on provider-level `email_verified` is a weaker
259
- * trust signal compared to using `trustedProviders` in `accountLinking` or enabling `domainVerification` for SSO.
260
- * Existing configurations will continue to work, but new integrations should use explicit trust mechanisms.
261
- * This option may be removed in a future major version.
262
257
  */
263
258
  trustEmailVerified?: boolean | undefined;
264
259
  /**
@@ -326,11 +321,43 @@ interface SSOOptions {
326
321
  * verification table fallback) is used automatically.
327
322
  */
328
323
  authnRequestStore?: AuthnRequestStore;
324
+ /**
325
+ * Clock skew tolerance for SAML assertion timestamp validation in milliseconds.
326
+ * Allows for minor time differences between IdP and SP servers.
327
+ *
328
+ * Defaults to 300000 (5 minutes) to accommodate:
329
+ * - Network latency and processing time
330
+ * - Clock synchronization differences (NTP drift)
331
+ * - Distributed systems across timezones
332
+ *
333
+ * For stricter security, reduce to 1-2 minutes (60000-120000).
334
+ * For highly distributed systems, increase up to 10 minutes (600000).
335
+ *
336
+ * @default 300000 (5 minutes)
337
+ */
338
+ clockSkew?: number;
339
+ /**
340
+ * Require timestamp conditions (NotBefore/NotOnOrAfter) in SAML assertions.
341
+ * When enabled, assertions without timestamp conditions will be rejected.
342
+ *
343
+ * When disabled (default), assertions without timestamps are accepted
344
+ * but a warning is logged.
345
+ *
346
+ * **SAML Spec Notes:**
347
+ * - SAML 2.0 Core: Timestamps are OPTIONAL
348
+ * - SAML2Int (enterprise profile): Timestamps are REQUIRED
349
+ *
350
+ * **Recommendation:** Enable for enterprise/production deployments
351
+ * where your IdP follows SAML2Int (Okta, Azure AD, OneLogin, etc.)
352
+ *
353
+ * @default false
354
+ */
355
+ requireTimestamps?: boolean;
329
356
  };
330
357
  }
331
358
  //#endregion
332
359
  //#region src/routes/domain-verification.d.ts
333
- declare const requestDomainVerification: (options: SSOOptions) => better_call0.StrictEndpoint<"/sso/request-domain-verification", {
360
+ declare const requestDomainVerification: (options: SSOOptions) => better_call7.StrictEndpoint<"/sso/request-domain-verification", {
334
361
  method: "POST";
335
362
  body: z.ZodObject<{
336
363
  providerId: z.ZodString;
@@ -352,7 +379,7 @@ declare const requestDomainVerification: (options: SSOOptions) => better_call0.S
352
379
  };
353
380
  };
354
381
  };
355
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
382
+ use: ((inputContext: better_call7.MiddlewareInputContext<better_call7.MiddlewareOptions>) => Promise<{
356
383
  session: {
357
384
  session: Record<string, any> & {
358
385
  id: string;
@@ -378,7 +405,7 @@ declare const requestDomainVerification: (options: SSOOptions) => better_call0.S
378
405
  }, {
379
406
  domainVerificationToken: string;
380
407
  }>;
381
- declare const verifyDomain: (options: SSOOptions) => better_call0.StrictEndpoint<"/sso/verify-domain", {
408
+ declare const verifyDomain: (options: SSOOptions) => better_call7.StrictEndpoint<"/sso/verify-domain", {
382
409
  method: "POST";
383
410
  body: z.ZodObject<{
384
411
  providerId: z.ZodString;
@@ -403,7 +430,7 @@ declare const verifyDomain: (options: SSOOptions) => better_call0.StrictEndpoint
403
430
  };
404
431
  };
405
432
  };
406
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
433
+ use: ((inputContext: better_call7.MiddlewareInputContext<better_call7.MiddlewareOptions>) => Promise<{
407
434
  session: {
408
435
  session: Record<string, any> & {
409
436
  id: string;
@@ -429,7 +456,27 @@ declare const verifyDomain: (options: SSOOptions) => better_call0.StrictEndpoint
429
456
  }, void>;
430
457
  //#endregion
431
458
  //#region src/routes/sso.d.ts
432
- declare const spMetadata: () => better_call0.StrictEndpoint<"/sso/saml2/sp/metadata", {
459
+ /** Default clock skew tolerance: 5 minutes */
460
+ declare const DEFAULT_CLOCK_SKEW_MS: number;
461
+ interface TimestampValidationOptions {
462
+ clockSkew?: number;
463
+ requireTimestamps?: boolean;
464
+ logger?: {
465
+ warn: (message: string, data?: Record<string, unknown>) => void;
466
+ };
467
+ }
468
+ /** Conditions extracted from SAML assertion */
469
+ interface SAMLConditions {
470
+ notBefore?: string;
471
+ notOnOrAfter?: string;
472
+ }
473
+ /**
474
+ * Validates SAML assertion timestamp conditions (NotBefore/NotOnOrAfter).
475
+ * Prevents acceptance of expired or future-dated assertions.
476
+ * @throws {APIError} If timestamps are invalid, expired, or not yet valid
477
+ */
478
+ declare function validateSAMLTimestamp(conditions: SAMLConditions | undefined, options?: TimestampValidationOptions): void;
479
+ declare const spMetadata: () => better_call7.StrictEndpoint<"/sso/saml2/sp/metadata", {
433
480
  method: "GET";
434
481
  query: z.ZodObject<{
435
482
  providerId: z.ZodString;
@@ -451,7 +498,7 @@ declare const spMetadata: () => better_call0.StrictEndpoint<"/sso/saml2/sp/metad
451
498
  };
452
499
  };
453
500
  }, Response>;
454
- declare const registerSSOProvider: <O extends SSOOptions>(options: O) => better_call0.StrictEndpoint<"/sso/register", {
501
+ declare const registerSSOProvider: <O extends SSOOptions>(options: O) => better_call7.StrictEndpoint<"/sso/register", {
455
502
  method: "POST";
456
503
  body: z.ZodObject<{
457
504
  providerId: z.ZodString;
@@ -469,6 +516,7 @@ declare const registerSSOProvider: <O extends SSOOptions>(options: O) => better_
469
516
  }>>;
470
517
  jwksEndpoint: z.ZodOptional<z.ZodString>;
471
518
  discoveryEndpoint: z.ZodOptional<z.ZodString>;
519
+ skipDiscovery: z.ZodOptional<z.ZodBoolean>;
472
520
  scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
473
521
  pkce: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
474
522
  mapping: z.ZodOptional<z.ZodObject<{
@@ -529,7 +577,7 @@ declare const registerSSOProvider: <O extends SSOOptions>(options: O) => better_
529
577
  organizationId: z.ZodOptional<z.ZodString>;
530
578
  overrideUserInfo: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
531
579
  }, z.core.$strip>;
532
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
580
+ use: ((inputContext: better_call7.MiddlewareInputContext<better_call7.MiddlewareOptions>) => Promise<{
533
581
  session: {
534
582
  session: Record<string, any> & {
535
583
  id: string;
@@ -719,7 +767,7 @@ declare const registerSSOProvider: <O extends SSOOptions>(options: O) => better_
719
767
  domainVerified: boolean;
720
768
  domainVerificationToken: string;
721
769
  } & SSOProvider<O> : SSOProvider<O>>;
722
- declare const signInSSO: (options?: SSOOptions) => better_call0.StrictEndpoint<"/sign-in/sso", {
770
+ declare const signInSSO: (options?: SSOOptions) => better_call7.StrictEndpoint<"/sign-in/sso", {
723
771
  method: "POST";
724
772
  body: z.ZodObject<{
725
773
  email: z.ZodOptional<z.ZodString>;
@@ -813,7 +861,7 @@ declare const signInSSO: (options?: SSOOptions) => better_call0.StrictEndpoint<"
813
861
  url: string;
814
862
  redirect: boolean;
815
863
  }>;
816
- declare const callbackSSO: (options?: SSOOptions) => better_call0.StrictEndpoint<"/sso/callback/:providerId", {
864
+ declare const callbackSSO: (options?: SSOOptions) => better_call7.StrictEndpoint<"/sso/callback/:providerId", {
817
865
  method: "GET";
818
866
  query: z.ZodObject<{
819
867
  code: z.ZodOptional<z.ZodString>;
@@ -836,7 +884,7 @@ declare const callbackSSO: (options?: SSOOptions) => better_call0.StrictEndpoint
836
884
  scope: "server";
837
885
  };
838
886
  }, never>;
839
- declare const callbackSSOSAML: (options?: SSOOptions) => better_call0.StrictEndpoint<"/sso/saml2/callback/:providerId", {
887
+ declare const callbackSSOSAML: (options?: SSOOptions) => better_call7.StrictEndpoint<"/sso/saml2/callback/:providerId", {
840
888
  method: "POST";
841
889
  body: z.ZodObject<{
842
890
  SAMLResponse: z.ZodString;
@@ -863,7 +911,7 @@ declare const callbackSSOSAML: (options?: SSOOptions) => better_call0.StrictEndp
863
911
  scope: "server";
864
912
  };
865
913
  }, never>;
866
- declare const acsEndpoint: (options?: SSOOptions) => better_call0.StrictEndpoint<"/sso/saml2/sp/acs/:providerId", {
914
+ declare const acsEndpoint: (options?: SSOOptions) => better_call7.StrictEndpoint<"/sso/saml2/sp/acs/:providerId", {
867
915
  method: "POST";
868
916
  params: z.ZodObject<{
869
917
  providerId: z.ZodOptional<z.ZodString>;
@@ -888,6 +936,264 @@ declare const acsEndpoint: (options?: SSOOptions) => better_call0.StrictEndpoint
888
936
  };
889
937
  }, never>;
890
938
  //#endregion
939
+ //#region src/oidc/types.d.ts
940
+ /**
941
+ * OIDC Discovery Types
942
+ *
943
+ * Types for the OIDC discovery document and hydrated configuration.
944
+ * Based on OpenID Connect Discovery 1.0 specification.
945
+ *
946
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html
947
+ */
948
+ /**
949
+ * Raw OIDC Discovery Document as returned by the IdP's
950
+ * .well-known/openid-configuration endpoint.
951
+ *
952
+ * Required fields for Better Auth's OIDC support:
953
+ * - issuer
954
+ * - authorization_endpoint
955
+ * - token_endpoint
956
+ * - jwks_uri (required for ID token validation)
957
+ *
958
+ */
959
+ interface OIDCDiscoveryDocument {
960
+ /** REQUIRED. URL using the https scheme that the OP asserts as its Issuer Identifier. */
961
+ issuer: string;
962
+ /** REQUIRED. URL of the OP's OAuth 2.0 Authorization Endpoint. */
963
+ authorization_endpoint: string;
964
+ /**
965
+ * REQUIRED (spec says "unless only implicit flow is used").
966
+ * URL of the OP's OAuth 2.0 Token Endpoint.
967
+ * We only support authorization code flow.
968
+ */
969
+ token_endpoint: string;
970
+ /** REQUIRED. URL of the OP's JSON Web Key Set document for ID token validation. */
971
+ jwks_uri: string;
972
+ /** RECOMMENDED. URL of the OP's UserInfo Endpoint. */
973
+ userinfo_endpoint?: string;
974
+ /**
975
+ * OPTIONAL. JSON array containing a list of Client Authentication methods
976
+ * supported by this Token Endpoint.
977
+ * Default: ["client_secret_basic"]
978
+ */
979
+ token_endpoint_auth_methods_supported?: string[];
980
+ /** OPTIONAL. JSON array containing a list of the OAuth 2.0 scope values that this server supports. */
981
+ scopes_supported?: string[];
982
+ /** OPTIONAL. JSON array containing a list of the OAuth 2.0 response_type values that this OP supports. */
983
+ response_types_supported?: string[];
984
+ /** OPTIONAL. JSON array containing a list of the Subject Identifier types that this OP supports. */
985
+ subject_types_supported?: string[];
986
+ /** OPTIONAL. JSON array containing a list of the JWS signing algorithms supported by the OP. */
987
+ id_token_signing_alg_values_supported?: string[];
988
+ /** OPTIONAL. JSON array containing a list of the claim names that the OP may supply values for. */
989
+ claims_supported?: string[];
990
+ /** OPTIONAL. URL of a page containing human-readable information about the OP. */
991
+ service_documentation?: string;
992
+ /** OPTIONAL. Boolean value specifying whether the OP supports use of the claims parameter. */
993
+ claims_parameter_supported?: boolean;
994
+ /** OPTIONAL. Boolean value specifying whether the OP supports use of the request parameter. */
995
+ request_parameter_supported?: boolean;
996
+ /** OPTIONAL. Boolean value specifying whether the OP supports use of the request_uri parameter. */
997
+ request_uri_parameter_supported?: boolean;
998
+ /** OPTIONAL. Boolean value specifying whether the OP requires any request_uri values to be pre-registered. */
999
+ require_request_uri_registration?: boolean;
1000
+ /** OPTIONAL. URL of the OP's end session endpoint. */
1001
+ end_session_endpoint?: string;
1002
+ /** OPTIONAL. URL of the OP's revocation endpoint. */
1003
+ revocation_endpoint?: string;
1004
+ /** OPTIONAL. URL of the OP's introspection endpoint. */
1005
+ introspection_endpoint?: string;
1006
+ /** OPTIONAL. JSON array of PKCE code challenge methods supported (e.g., "S256", "plain"). */
1007
+ code_challenge_methods_supported?: string[];
1008
+ /** Allow additional fields from the discovery document */
1009
+ [key: string]: unknown;
1010
+ }
1011
+ /**
1012
+ * Error codes for OIDC discovery operations.
1013
+ */
1014
+ type DiscoveryErrorCode = /** Request to discovery endpoint timed out */
1015
+ "discovery_timeout"
1016
+ /** Discovery endpoint returned 404 or similar */ | "discovery_not_found"
1017
+ /** Discovery endpoint returned invalid JSON */ | "discovery_invalid_json"
1018
+ /** Discovery URL is invalid or malformed */ | "discovery_invalid_url"
1019
+ /** Discovery URL is not trusted by the trusted origins configuration */ | "discovery_untrusted_origin"
1020
+ /** Discovery document issuer doesn't match configured issuer */ | "issuer_mismatch"
1021
+ /** Discovery document is missing required fields */ | "discovery_incomplete"
1022
+ /** IdP only advertises token auth methods that Better Auth doesn't currently support */ | "unsupported_token_auth_method"
1023
+ /** Catch-all for unexpected errors */ | "discovery_unexpected_error";
1024
+ /**
1025
+ * Custom error class for OIDC discovery failures.
1026
+ * Can be caught and mapped to APIError at the edge.
1027
+ */
1028
+ declare class DiscoveryError extends Error {
1029
+ readonly code: DiscoveryErrorCode;
1030
+ readonly details?: Record<string, unknown>;
1031
+ constructor(code: DiscoveryErrorCode, message: string, details?: Record<string, unknown>, options?: {
1032
+ cause?: unknown;
1033
+ });
1034
+ }
1035
+ /**
1036
+ * Hydrated OIDC configuration after discovery.
1037
+ * This is the normalized shape that gets persisted to the database
1038
+ * or merged into provider config at runtime.
1039
+ *
1040
+ * Field names are camelCase to match Better Auth conventions.
1041
+ */
1042
+ interface HydratedOIDCConfig {
1043
+ /** The issuer URL (validated to match configured issuer) */
1044
+ issuer: string;
1045
+ /** The discovery endpoint URL */
1046
+ discoveryEndpoint: string;
1047
+ /** URL of the authorization endpoint */
1048
+ authorizationEndpoint: string;
1049
+ /** URL of the token endpoint */
1050
+ tokenEndpoint: string;
1051
+ /** URL of the JWKS endpoint */
1052
+ jwksEndpoint: string;
1053
+ /** URL of the userinfo endpoint (optional) */
1054
+ userInfoEndpoint?: string;
1055
+ /** Token endpoint authentication method */
1056
+ tokenEndpointAuthentication?: "client_secret_basic" | "client_secret_post";
1057
+ /** Scopes supported by the IdP */
1058
+ scopesSupported?: string[];
1059
+ }
1060
+ /**
1061
+ * Parameters for the discoverOIDCConfig function.
1062
+ */
1063
+ interface DiscoverOIDCConfigParams {
1064
+ /** The issuer URL to discover configuration from */
1065
+ issuer: string;
1066
+ /**
1067
+ * Optional existing configuration.
1068
+ * Values provided here will override discovered values.
1069
+ */
1070
+ existingConfig?: Partial<HydratedOIDCConfig>;
1071
+ /**
1072
+ * Optional custom discovery endpoint URL.
1073
+ * If not provided, defaults to <issuer>/.well-known/openid-configuration
1074
+ */
1075
+ discoveryEndpoint?: string;
1076
+ /**
1077
+ * Optional timeout in milliseconds for the discovery request.
1078
+ * @default 10000 (10 seconds)
1079
+ */
1080
+ timeout?: number;
1081
+ /**
1082
+ * Trusted origin predicate. See "trustedOrigins" option
1083
+ * @param url the url to test
1084
+ * @returns {boolean} return true for urls that belong to a trusted origin and false otherwise
1085
+ */
1086
+ isTrustedOrigin: (url: string) => boolean;
1087
+ }
1088
+ /**
1089
+ * Required fields that must be present in a valid discovery document.
1090
+ */
1091
+ declare const REQUIRED_DISCOVERY_FIELDS: readonly ["issuer", "authorization_endpoint", "token_endpoint", "jwks_uri"];
1092
+ type RequiredDiscoveryField = (typeof REQUIRED_DISCOVERY_FIELDS)[number];
1093
+ //#endregion
1094
+ //#region src/oidc/discovery.d.ts
1095
+ /**
1096
+ * Main entry point: Discover and hydrate OIDC configuration from an issuer.
1097
+ *
1098
+ * This function:
1099
+ * 1. Computes the discovery URL from the issuer
1100
+ * 2. Validates the discovery URL
1101
+ * 3. Fetches the discovery document
1102
+ * 4. Validates the discovery document (issuer match + required fields)
1103
+ * 5. Normalizes URLs
1104
+ * 6. Selects token endpoint auth method
1105
+ * 7. Merges with existing config (existing values take precedence)
1106
+ *
1107
+ * @param params - Discovery parameters
1108
+ * @param isTrustedOrigin - Origin verification tester function
1109
+ * @returns Hydrated OIDC configuration ready for persistence
1110
+ * @throws DiscoveryError on any failure
1111
+ */
1112
+ declare function discoverOIDCConfig(params: DiscoverOIDCConfigParams): Promise<HydratedOIDCConfig>;
1113
+ /**
1114
+ * Compute the discovery URL from an issuer URL.
1115
+ *
1116
+ * Per OIDC Discovery spec, the discovery document is located at:
1117
+ * <issuer>/.well-known/openid-configuration
1118
+ *
1119
+ * Handles trailing slashes correctly.
1120
+ */
1121
+ declare function computeDiscoveryUrl(issuer: string): string;
1122
+ /**
1123
+ * Validate a discovery URL before fetching.
1124
+ *
1125
+ * @param url - The discovery URL to validate
1126
+ * @param isTrustedOrigin - Origin verification tester function
1127
+ * @throws DiscoveryError if URL is invalid
1128
+ */
1129
+ declare function validateDiscoveryUrl(url: string, isTrustedOrigin: DiscoverOIDCConfigParams["isTrustedOrigin"]): void;
1130
+ /**
1131
+ * Fetch the OIDC discovery document from the IdP.
1132
+ *
1133
+ * @param url - The discovery endpoint URL
1134
+ * @param timeout - Request timeout in milliseconds
1135
+ * @returns The parsed discovery document
1136
+ * @throws DiscoveryError on network errors, timeouts, or invalid responses
1137
+ */
1138
+ declare function fetchDiscoveryDocument(url: string, timeout?: number): Promise<OIDCDiscoveryDocument>;
1139
+ /**
1140
+ * Validate a discovery document.
1141
+ *
1142
+ * Checks:
1143
+ * 1. All required fields are present
1144
+ * 2. Issuer matches the configured issuer (case-sensitive, exact match)
1145
+ *
1146
+ * Invariant: If this function returns without throwing, the document is safe
1147
+ * to use for hydrating OIDC config (required fields present, issuer matches
1148
+ * configured value, basic structural sanity verified).
1149
+ *
1150
+ * @param doc - The discovery document to validate
1151
+ * @param configuredIssuer - The expected issuer value
1152
+ * @throws DiscoveryError if validation fails
1153
+ */
1154
+ declare function validateDiscoveryDocument(doc: OIDCDiscoveryDocument, configuredIssuer: string): void;
1155
+ /**
1156
+ * Normalize URLs in the discovery document.
1157
+ *
1158
+ * @param document - The discovery document
1159
+ * @param issuer - The base issuer URL
1160
+ * @param isTrustedOrigin - Origin verification tester function
1161
+ * @returns The normalized discovery document
1162
+ */
1163
+ declare function normalizeDiscoveryUrls(document: OIDCDiscoveryDocument, issuer: string, isTrustedOrigin: DiscoverOIDCConfigParams["isTrustedOrigin"]): OIDCDiscoveryDocument;
1164
+ /**
1165
+ * Normalize a single URL endpoint.
1166
+ *
1167
+ * @param name - The endpoint name (e.g token_endpoint)
1168
+ * @param endpoint - The endpoint URL to normalize
1169
+ * @param issuer - The base issuer URL
1170
+ * @returns The normalized endpoint URL
1171
+ */
1172
+ declare function normalizeUrl(name: string, endpoint: string, issuer: string): string;
1173
+ /**
1174
+ * Select the token endpoint authentication method.
1175
+ *
1176
+ * @param doc - The discovery document
1177
+ * @param existing - Existing authentication method from config
1178
+ * @returns The selected authentication method
1179
+ */
1180
+ declare function selectTokenEndpointAuthMethod(doc: OIDCDiscoveryDocument, existing?: "client_secret_basic" | "client_secret_post"): "client_secret_basic" | "client_secret_post";
1181
+ /**
1182
+ * Check if a provider configuration needs runtime discovery.
1183
+ *
1184
+ * Returns true if we need discovery at runtime to complete the token exchange
1185
+ * and validation. Specifically checks for:
1186
+ * - `tokenEndpoint` - required for exchanging authorization code for tokens
1187
+ * - `jwksEndpoint` - required for validating ID token signatures
1188
+ *
1189
+ * Note: `authorizationEndpoint` is handled separately in the sign-in flow,
1190
+ * so it's not checked here.
1191
+ *
1192
+ * @param config - Partial OIDC config from the provider
1193
+ * @returns true if runtime discovery should be performed
1194
+ */
1195
+ declare function needsRuntimeDiscovery(config: Partial<HydratedOIDCConfig> | undefined): boolean;
1196
+ //#endregion
891
1197
  //#region src/index.d.ts
892
1198
  type DomainVerificationEndpoints = {
893
1199
  requestDomainVerification: ReturnType<typeof requestDomainVerification>;
@@ -924,4 +1230,4 @@ declare function sso<O extends SSOOptions>(options?: O | undefined): {
924
1230
  endpoints: SSOEndpoints<O>;
925
1231
  };
926
1232
  //#endregion
927
- export { SSOOptions as a, AuthnRequestStore as c, SAMLConfig as i, DEFAULT_AUTHN_REQUEST_TTL_MS as l, sso as n, SSOProvider as o, OIDCConfig as r, AuthnRequestRecord as s, SSOPlugin as t, createInMemoryAuthnRequestStore as u };
1233
+ export { createInMemoryAuthnRequestStore as A, OIDCConfig as C, AuthnRequestRecord as D, SSOProvider as E, AuthnRequestStore as O, validateSAMLTimestamp as S, SSOOptions as T, REQUIRED_DISCOVERY_FIELDS as _, fetchDiscoveryDocument as a, SAMLConditions as b, normalizeUrl as c, validateDiscoveryUrl as d, DiscoverOIDCConfigParams as f, OIDCDiscoveryDocument as g, HydratedOIDCConfig as h, discoverOIDCConfig as i, DEFAULT_AUTHN_REQUEST_TTL_MS as k, selectTokenEndpointAuthMethod as l, DiscoveryErrorCode as m, sso as n, needsRuntimeDiscovery as o, DiscoveryError as p, computeDiscoveryUrl as r, normalizeDiscoveryUrls as s, SSOPlugin as t, validateDiscoveryDocument as u, RequiredDiscoveryField as v, SAMLConfig as w, TimestampValidationOptions as x, DEFAULT_CLOCK_SKEW_MS as y };
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as SSOOptions, c as AuthnRequestStore, i as SAMLConfig, l as DEFAULT_AUTHN_REQUEST_TTL_MS, n as sso, o as SSOProvider, r as OIDCConfig, s as AuthnRequestRecord, t as SSOPlugin, u as createInMemoryAuthnRequestStore } from "./index-m7FISidt.mjs";
2
- export { AuthnRequestRecord, AuthnRequestStore, DEFAULT_AUTHN_REQUEST_TTL_MS, OIDCConfig, SAMLConfig, SSOOptions, SSOPlugin, SSOProvider, createInMemoryAuthnRequestStore, sso };
1
+ import { A as createInMemoryAuthnRequestStore, C as OIDCConfig, D as AuthnRequestRecord, E as SSOProvider, O as AuthnRequestStore, S as validateSAMLTimestamp, T as SSOOptions, _ as REQUIRED_DISCOVERY_FIELDS, a as fetchDiscoveryDocument, b as SAMLConditions, c as normalizeUrl, d as validateDiscoveryUrl, f as DiscoverOIDCConfigParams, g as OIDCDiscoveryDocument, h as HydratedOIDCConfig, i as discoverOIDCConfig, k as DEFAULT_AUTHN_REQUEST_TTL_MS, l as selectTokenEndpointAuthMethod, m as DiscoveryErrorCode, n as sso, o as needsRuntimeDiscovery, p as DiscoveryError, r as computeDiscoveryUrl, s as normalizeDiscoveryUrls, t as SSOPlugin, u as validateDiscoveryDocument, v as RequiredDiscoveryField, w as SAMLConfig, x as TimestampValidationOptions, y as DEFAULT_CLOCK_SKEW_MS } from "./index-B9WMxRdD.mjs";
2
+ export { AuthnRequestRecord, AuthnRequestStore, DEFAULT_AUTHN_REQUEST_TTL_MS, DEFAULT_CLOCK_SKEW_MS, DiscoverOIDCConfigParams, DiscoveryError, DiscoveryErrorCode, HydratedOIDCConfig, OIDCConfig, OIDCDiscoveryDocument, REQUIRED_DISCOVERY_FIELDS, RequiredDiscoveryField, SAMLConditions, SAMLConfig, SSOOptions, SSOPlugin, SSOProvider, TimestampValidationOptions, computeDiscoveryUrl, createInMemoryAuthnRequestStore, discoverOIDCConfig, fetchDiscoveryDocument, needsRuntimeDiscovery, normalizeDiscoveryUrls, normalizeUrl, selectTokenEndpointAuthMethod, sso, validateDiscoveryDocument, validateDiscoveryUrl, validateSAMLTimestamp };