@better-auth/sso 1.4.7 → 1.4.8-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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @better-auth/sso@1.4.7 build /home/runner/work/better-auth/better-auth/packages/sso
2
+ > @better-auth/sso@1.4.8-beta.1 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 83.77 kB │ gzip: 15.84 kB
10
+ ℹ dist/index.mjs 92.44 kB │ gzip: 18.07 kB
11
11
  ℹ dist/client.mjs  0.15 kB │ gzip: 0.14 kB
12
- ℹ dist/index.d.mts  1.44 kB │ gzip: 0.52 kB
12
+ ℹ dist/index.d.mts  1.48 kB │ gzip: 0.51 kB
13
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
14
+ ℹ dist/index-DNWhGQW-.d.mts 42.86 kB │ gzip: 8.79 kB
15
+ ℹ 5 files, total: 137.41 kB
16
+ ✔ Build complete in 12113ms
package/dist/client.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as SSOPlugin } from "./index-B9WMxRdD.mjs";
1
+ import { t as SSOPlugin } from "./index-DNWhGQW-.mjs";
2
2
 
3
3
  //#region src/client.d.ts
4
4
  interface SSOClientOptions {
@@ -1,43 +1,47 @@
1
1
  import { APIError } from "better-auth/api";
2
- import * as z from "zod/v4";
3
- import { OAuth2Tokens, User } from "better-auth";
4
- import * as better_call7 from "better-call";
2
+ import * as z$1 from "zod/v4";
3
+ import z from "zod/v4";
4
+ import { Awaitable, OAuth2Tokens, User } from "better-auth";
5
+ import * as better_call0 from "better-call";
5
6
 
6
- //#region src/authn-request-store.d.ts
7
-
8
- /**
9
- * AuthnRequest Store
10
- *
11
- * Tracks SAML AuthnRequest IDs to enable InResponseTo validation.
12
- * This prevents:
13
- * - Unsolicited SAML responses
14
- * - Cross-provider response injection
15
- * - Replay attacks
16
- * - Expired login completions
17
- */
18
- interface AuthnRequestRecord {
19
- id: string;
20
- providerId: string;
21
- createdAt: number;
22
- expiresAt: number;
23
- }
24
- interface AuthnRequestStore {
25
- save(record: AuthnRequestRecord): Promise<void>;
26
- get(id: string): Promise<AuthnRequestRecord | null>;
27
- delete(id: string): Promise<void>;
7
+ //#region src/saml/algorithms.d.ts
8
+ declare const SignatureAlgorithm: {
9
+ readonly RSA_SHA1: "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
10
+ readonly RSA_SHA256: "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256";
11
+ readonly RSA_SHA384: "http://www.w3.org/2001/04/xmldsig-more#rsa-sha384";
12
+ readonly RSA_SHA512: "http://www.w3.org/2001/04/xmldsig-more#rsa-sha512";
13
+ readonly ECDSA_SHA256: "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256";
14
+ readonly ECDSA_SHA384: "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384";
15
+ readonly ECDSA_SHA512: "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512";
16
+ };
17
+ declare const DigestAlgorithm: {
18
+ readonly SHA1: "http://www.w3.org/2000/09/xmldsig#sha1";
19
+ readonly SHA256: "http://www.w3.org/2001/04/xmlenc#sha256";
20
+ readonly SHA384: "http://www.w3.org/2001/04/xmldsig-more#sha384";
21
+ readonly SHA512: "http://www.w3.org/2001/04/xmlenc#sha512";
22
+ };
23
+ declare const KeyEncryptionAlgorithm: {
24
+ readonly RSA_1_5: "http://www.w3.org/2001/04/xmlenc#rsa-1_5";
25
+ readonly RSA_OAEP: "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p";
26
+ readonly RSA_OAEP_SHA256: "http://www.w3.org/2009/xmlenc11#rsa-oaep";
27
+ };
28
+ declare const DataEncryptionAlgorithm: {
29
+ readonly TRIPLEDES_CBC: "http://www.w3.org/2001/04/xmlenc#tripledes-cbc";
30
+ readonly AES_128_CBC: "http://www.w3.org/2001/04/xmlenc#aes128-cbc";
31
+ readonly AES_192_CBC: "http://www.w3.org/2001/04/xmlenc#aes192-cbc";
32
+ readonly AES_256_CBC: "http://www.w3.org/2001/04/xmlenc#aes256-cbc";
33
+ readonly AES_128_GCM: "http://www.w3.org/2009/xmlenc11#aes128-gcm";
34
+ readonly AES_192_GCM: "http://www.w3.org/2009/xmlenc11#aes192-gcm";
35
+ readonly AES_256_GCM: "http://www.w3.org/2009/xmlenc11#aes256-gcm";
36
+ };
37
+ type DeprecatedAlgorithmBehavior = "reject" | "warn" | "allow";
38
+ interface AlgorithmValidationOptions {
39
+ onDeprecated?: DeprecatedAlgorithmBehavior;
40
+ allowedSignatureAlgorithms?: string[];
41
+ allowedDigestAlgorithms?: string[];
42
+ allowedKeyEncryptionAlgorithms?: string[];
43
+ allowedDataEncryptionAlgorithms?: string[];
28
44
  }
29
- /**
30
- * Default TTL for AuthnRequest records (5 minutes).
31
- * This should be sufficient for most IdPs while protecting against stale requests.
32
- */
33
- declare const DEFAULT_AUTHN_REQUEST_TTL_MS: number;
34
- /**
35
- * In-memory implementation of AuthnRequestStore.
36
- * ⚠️ Only suitable for testing or single-instance non-serverless deployments.
37
- * For production, rely on the default behavior (uses verification table)
38
- * or provide a custom Redis-backed store.
39
- */
40
- declare function createInMemoryAuthnRequestStore(): AuthnRequestStore;
41
45
  //#endregion
42
46
  //#region src/types.d.ts
43
47
  interface OIDCMapping {
@@ -148,7 +152,7 @@ interface SSOOptions {
148
152
  * The SSO provider
149
153
  */
150
154
  provider: SSOProvider<SSOOptions>;
151
- }) => Promise<void>) | undefined;
155
+ }) => Awaitable<void>) | undefined;
152
156
  /**
153
157
  * Organization provisioning options
154
158
  */
@@ -244,7 +248,7 @@ interface SSOOptions {
244
248
  * ```
245
249
  * @default 10
246
250
  */
247
- providersLimit?: (number | ((user: User) => Promise<number> | number)) | undefined;
251
+ providersLimit?: (number | ((user: User) => Awaitable<number>)) | undefined;
248
252
  /**
249
253
  * Trust the email verified flag from the provider.
250
254
  *
@@ -253,7 +257,13 @@ interface SSOOptions {
253
257
  *
254
258
  * If you want to allow account linking for specific trusted providers, enable the `accountLinking` option in your auth config and specify those
255
259
  * providers in the `trustedProviders` list.
260
+ *
256
261
  * @default false
262
+ *
263
+ * @deprecated This option is discouraged for new projects. Relying on provider-level `email_verified` is a weaker
264
+ * trust signal compared to using `trustedProviders` in `accountLinking` or enabling `domainVerification` for SSO.
265
+ * Existing configurations will continue to work, but new integrations should use explicit trust mechanisms.
266
+ * This option may be removed in a future major version.
257
267
  */
258
268
  trustEmailVerified?: boolean | undefined;
259
269
  /**
@@ -311,16 +321,6 @@ interface SSOOptions {
311
321
  * @default 300000 (5 minutes)
312
322
  */
313
323
  requestTTL?: number;
314
- /**
315
- * Custom AuthnRequest store implementation.
316
- * Use this to provide a custom storage backend (e.g., Redis-backed store).
317
- *
318
- * Providing a custom store automatically enables InResponseTo validation.
319
- *
320
- * Note: When not provided, the default storage (secondaryStorage with
321
- * verification table fallback) is used automatically.
322
- */
323
- authnRequestStore?: AuthnRequestStore;
324
324
  /**
325
325
  * Clock skew tolerance for SAML assertion timestamp validation in milliseconds.
326
326
  * Allows for minor time differences between IdP and SP servers.
@@ -353,15 +353,29 @@ interface SSOOptions {
353
353
  * @default false
354
354
  */
355
355
  requireTimestamps?: boolean;
356
+ /**
357
+ * Algorithm validation options for SAML responses.
358
+ *
359
+ * Controls behavior when deprecated algorithms (SHA-1, RSA1_5, 3DES)
360
+ * are detected in SAML responses.
361
+ *
362
+ * @example
363
+ * ```ts
364
+ * algorithms: {
365
+ * onDeprecated: "reject" // Reject deprecated algorithms
366
+ * }
367
+ * ```
368
+ */
369
+ algorithms?: AlgorithmValidationOptions;
356
370
  };
357
371
  }
358
372
  //#endregion
359
373
  //#region src/routes/domain-verification.d.ts
360
- declare const requestDomainVerification: (options: SSOOptions) => better_call7.StrictEndpoint<"/sso/request-domain-verification", {
374
+ declare const requestDomainVerification: (options: SSOOptions) => better_call0.StrictEndpoint<"/sso/request-domain-verification", {
361
375
  method: "POST";
362
- body: z.ZodObject<{
363
- providerId: z.ZodString;
364
- }, z.core.$strip>;
376
+ body: z$1.ZodObject<{
377
+ providerId: z$1.ZodString;
378
+ }, z$1.core.$strip>;
365
379
  metadata: {
366
380
  openapi: {
367
381
  summary: string;
@@ -379,7 +393,7 @@ declare const requestDomainVerification: (options: SSOOptions) => better_call7.S
379
393
  };
380
394
  };
381
395
  };
382
- use: ((inputContext: better_call7.MiddlewareInputContext<better_call7.MiddlewareOptions>) => Promise<{
396
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
383
397
  session: {
384
398
  session: Record<string, any> & {
385
399
  id: string;
@@ -405,11 +419,11 @@ declare const requestDomainVerification: (options: SSOOptions) => better_call7.S
405
419
  }, {
406
420
  domainVerificationToken: string;
407
421
  }>;
408
- declare const verifyDomain: (options: SSOOptions) => better_call7.StrictEndpoint<"/sso/verify-domain", {
422
+ declare const verifyDomain: (options: SSOOptions) => better_call0.StrictEndpoint<"/sso/verify-domain", {
409
423
  method: "POST";
410
- body: z.ZodObject<{
411
- providerId: z.ZodString;
412
- }, z.core.$strip>;
424
+ body: z$1.ZodObject<{
425
+ providerId: z$1.ZodString;
426
+ }, z$1.core.$strip>;
413
427
  metadata: {
414
428
  openapi: {
415
429
  summary: string;
@@ -430,7 +444,7 @@ declare const verifyDomain: (options: SSOOptions) => better_call7.StrictEndpoint
430
444
  };
431
445
  };
432
446
  };
433
- use: ((inputContext: better_call7.MiddlewareInputContext<better_call7.MiddlewareOptions>) => Promise<{
447
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
434
448
  session: {
435
449
  session: Record<string, any> & {
436
450
  id: string;
@@ -456,8 +470,6 @@ declare const verifyDomain: (options: SSOOptions) => better_call7.StrictEndpoint
456
470
  }, void>;
457
471
  //#endregion
458
472
  //#region src/routes/sso.d.ts
459
- /** Default clock skew tolerance: 5 minutes */
460
- declare const DEFAULT_CLOCK_SKEW_MS: number;
461
473
  interface TimestampValidationOptions {
462
474
  clockSkew?: number;
463
475
  requireTimestamps?: boolean;
@@ -476,7 +488,7 @@ interface SAMLConditions {
476
488
  * @throws {APIError} If timestamps are invalid, expired, or not yet valid
477
489
  */
478
490
  declare function validateSAMLTimestamp(conditions: SAMLConditions | undefined, options?: TimestampValidationOptions): void;
479
- declare const spMetadata: () => better_call7.StrictEndpoint<"/sso/saml2/sp/metadata", {
491
+ declare const spMetadata: () => better_call0.StrictEndpoint<"/sso/saml2/sp/metadata", {
480
492
  method: "GET";
481
493
  query: z.ZodObject<{
482
494
  providerId: z.ZodString;
@@ -498,7 +510,7 @@ declare const spMetadata: () => better_call7.StrictEndpoint<"/sso/saml2/sp/metad
498
510
  };
499
511
  };
500
512
  }, Response>;
501
- declare const registerSSOProvider: <O extends SSOOptions>(options: O) => better_call7.StrictEndpoint<"/sso/register", {
513
+ declare const registerSSOProvider: <O extends SSOOptions>(options: O) => better_call0.StrictEndpoint<"/sso/register", {
502
514
  method: "POST";
503
515
  body: z.ZodObject<{
504
516
  providerId: z.ZodString;
@@ -577,7 +589,7 @@ declare const registerSSOProvider: <O extends SSOOptions>(options: O) => better_
577
589
  organizationId: z.ZodOptional<z.ZodString>;
578
590
  overrideUserInfo: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
579
591
  }, z.core.$strip>;
580
- use: ((inputContext: better_call7.MiddlewareInputContext<better_call7.MiddlewareOptions>) => Promise<{
592
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
581
593
  session: {
582
594
  session: Record<string, any> & {
583
595
  id: string;
@@ -767,7 +779,7 @@ declare const registerSSOProvider: <O extends SSOOptions>(options: O) => better_
767
779
  domainVerified: boolean;
768
780
  domainVerificationToken: string;
769
781
  } & SSOProvider<O> : SSOProvider<O>>;
770
- declare const signInSSO: (options?: SSOOptions) => better_call7.StrictEndpoint<"/sign-in/sso", {
782
+ declare const signInSSO: (options?: SSOOptions) => better_call0.StrictEndpoint<"/sign-in/sso", {
771
783
  method: "POST";
772
784
  body: z.ZodObject<{
773
785
  email: z.ZodOptional<z.ZodString>;
@@ -861,7 +873,7 @@ declare const signInSSO: (options?: SSOOptions) => better_call7.StrictEndpoint<"
861
873
  url: string;
862
874
  redirect: boolean;
863
875
  }>;
864
- declare const callbackSSO: (options?: SSOOptions) => better_call7.StrictEndpoint<"/sso/callback/:providerId", {
876
+ declare const callbackSSO: (options?: SSOOptions) => better_call0.StrictEndpoint<"/sso/callback/:providerId", {
865
877
  method: "GET";
866
878
  query: z.ZodObject<{
867
879
  code: z.ZodOptional<z.ZodString>;
@@ -884,7 +896,7 @@ declare const callbackSSO: (options?: SSOOptions) => better_call7.StrictEndpoint
884
896
  scope: "server";
885
897
  };
886
898
  }, never>;
887
- declare const callbackSSOSAML: (options?: SSOOptions) => better_call7.StrictEndpoint<"/sso/saml2/callback/:providerId", {
899
+ declare const callbackSSOSAML: (options?: SSOOptions) => better_call0.StrictEndpoint<"/sso/saml2/callback/:providerId", {
888
900
  method: "POST";
889
901
  body: z.ZodObject<{
890
902
  SAMLResponse: z.ZodString;
@@ -911,7 +923,7 @@ declare const callbackSSOSAML: (options?: SSOOptions) => better_call7.StrictEndp
911
923
  scope: "server";
912
924
  };
913
925
  }, never>;
914
- declare const acsEndpoint: (options?: SSOOptions) => better_call7.StrictEndpoint<"/sso/saml2/sp/acs/:providerId", {
926
+ declare const acsEndpoint: (options?: SSOOptions) => better_call0.StrictEndpoint<"/sso/saml2/sp/acs/:providerId", {
915
927
  method: "POST";
916
928
  params: z.ZodObject<{
917
929
  providerId: z.ZodOptional<z.ZodString>;
@@ -1230,4 +1242,4 @@ declare function sso<O extends SSOOptions>(options?: O | undefined): {
1230
1242
  endpoints: SSOEndpoints<O>;
1231
1243
  };
1232
1244
  //#endregion
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 };
1245
+ export { KeyEncryptionAlgorithm as A, SAMLConfig as C, DataEncryptionAlgorithm as D, AlgorithmValidationOptions as E, DeprecatedAlgorithmBehavior as O, OIDCConfig as S, SSOProvider as T, REQUIRED_DISCOVERY_FIELDS as _, fetchDiscoveryDocument as a, TimestampValidationOptions as b, normalizeUrl as c, validateDiscoveryUrl as d, DiscoverOIDCConfigParams as f, OIDCDiscoveryDocument as g, HydratedOIDCConfig as h, discoverOIDCConfig as i, SignatureAlgorithm as j, DigestAlgorithm 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, SSOOptions as w, validateSAMLTimestamp as x, SAMLConditions as y };
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
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 };
1
+ import { A as KeyEncryptionAlgorithm, C as SAMLConfig, D as DataEncryptionAlgorithm, E as AlgorithmValidationOptions, O as DeprecatedAlgorithmBehavior, S as OIDCConfig, T as SSOProvider, _ as REQUIRED_DISCOVERY_FIELDS, a as fetchDiscoveryDocument, b as TimestampValidationOptions, c as normalizeUrl, d as validateDiscoveryUrl, f as DiscoverOIDCConfigParams, g as OIDCDiscoveryDocument, h as HydratedOIDCConfig, i as discoverOIDCConfig, j as SignatureAlgorithm, k as DigestAlgorithm, 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 SSOOptions, x as validateSAMLTimestamp, y as SAMLConditions } from "./index-DNWhGQW-.mjs";
2
+ export { AlgorithmValidationOptions, DataEncryptionAlgorithm, DeprecatedAlgorithmBehavior, DigestAlgorithm, DiscoverOIDCConfigParams, DiscoveryError, DiscoveryErrorCode, HydratedOIDCConfig, KeyEncryptionAlgorithm, OIDCConfig, OIDCDiscoveryDocument, REQUIRED_DISCOVERY_FIELDS, RequiredDiscoveryField, SAMLConditions, SAMLConfig, SSOOptions, SSOPlugin, SSOProvider, SignatureAlgorithm, TimestampValidationOptions, computeDiscoveryUrl, discoverOIDCConfig, fetchDiscoveryDocument, needsRuntimeDiscovery, normalizeDiscoveryUrls, normalizeUrl, selectTokenEndpointAuthMethod, sso, validateDiscoveryDocument, validateDiscoveryUrl, validateSAMLTimestamp };