@better-auth/sso 1.4.0-beta.10 → 1.4.0-beta.11

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.0-beta.10 build /home/runner/work/better-auth/better-auth/packages/sso
2
+ > @better-auth/sso@1.4.0-beta.11 build /home/runner/work/better-auth/better-auth/packages/sso
3
3
  > tsdown
4
4
 
5
5
  ℹ tsdown v0.15.6 powered by rolldown v1.0.0-beta.43
@@ -9,17 +9,17 @@
9
9
  ℹ Build start
10
10
  ℹ [CJS] dist/client.cjs  0.19 kB │ gzip: 0.17 kB
11
11
  ℹ [CJS] dist/index.cjs  0.08 kB │ gzip: 0.08 kB
12
- ℹ [CJS] dist/src-DLLHZrD9.cjs 51.93 kB │ gzip: 9.06 kB
13
- ℹ [CJS] 3 files, total: 52.20 kB
12
+ ℹ [CJS] dist/src-BYOa9Nr6.cjs 52.34 kB │ gzip: 9.21 kB
13
+ ℹ [CJS] 3 files, total: 52.61 kB
14
14
  ℹ [ESM] dist/client.js  0.18 kB │ gzip: 0.16 kB
15
15
  ℹ [ESM] dist/index.js  0.06 kB │ gzip: 0.07 kB
16
- ℹ [ESM] dist/src-DrA9mJEu.js 49.17 kB │ gzip: 8.42 kB
16
+ ℹ [ESM] dist/src-Z1RpfPZt.js 49.58 kB │ gzip: 8.54 kB
17
17
  ℹ [ESM] dist/index.d.ts  0.21 kB │ gzip: 0.12 kB
18
18
  ℹ [ESM] dist/client.d.ts  0.21 kB │ gzip: 0.18 kB
19
- ℹ [ESM] dist/index-Drgwy6ZL.d.ts 30.79 kB │ gzip: 3.70 kB
20
- ℹ [ESM] 6 files, total: 80.61 kB
19
+ ℹ [ESM] dist/index-Dtx0Mkqc.d.ts 31.02 kB │ gzip: 3.72 kB
20
+ ℹ [ESM] 6 files, total: 81.25 kB
21
21
  ℹ [CJS] dist/index.d.cts  0.21 kB │ gzip: 0.12 kB
22
22
  ℹ [CJS] dist/client.d.cts  0.21 kB │ gzip: 0.18 kB
23
- ℹ [CJS] dist/index-D0i1jHBp.d.cts 30.79 kB │ gzip: 3.70 kB
24
- ℹ [CJS] 3 files, total: 31.20 kB
25
- ✔ Build complete in 5583ms
23
+ ℹ [CJS] dist/index-Cl11-WdU.d.cts 31.02 kB │ gzip: 3.72 kB
24
+ ℹ [CJS] 3 files, total: 31.44 kB
25
+ ✔ Build complete in 5245ms
package/dist/client.cjs CHANGED
@@ -1,4 +1,4 @@
1
- require('./src-DLLHZrD9.cjs');
1
+ require('./src-BYOa9Nr6.cjs');
2
2
 
3
3
  //#region src/client.ts
4
4
  const ssoClient = () => {
package/dist/client.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { sso } from "./index-D0i1jHBp.cjs";
1
+ import { sso } from "./index-Cl11-WdU.cjs";
2
2
 
3
3
  //#region src/client.d.ts
4
4
  declare const ssoClient: () => {
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { sso } from "./index-Drgwy6ZL.js";
1
+ import { sso } from "./index-Dtx0Mkqc.js";
2
2
 
3
3
  //#region src/client.d.ts
4
4
  declare const ssoClient: () => {
package/dist/client.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./src-DrA9mJEu.js";
1
+ import "./src-Z1RpfPZt.js";
2
2
 
3
3
  //#region src/client.ts
4
4
  const ssoClient = () => {
@@ -623,6 +623,7 @@ declare const sso: (options?: SSOOptions) => {
623
623
  errorCallbackURL?: string | undefined;
624
624
  newUserCallbackURL?: string | undefined;
625
625
  scopes?: string[] | undefined;
626
+ loginHint?: string | undefined;
626
627
  requestSignUp?: boolean | undefined;
627
628
  providerType?: "oidc" | "saml" | undefined;
628
629
  };
@@ -665,6 +666,7 @@ declare const sso: (options?: SSOOptions) => {
665
666
  errorCallbackURL: z.ZodOptional<z.ZodString>;
666
667
  newUserCallbackURL: z.ZodOptional<z.ZodString>;
667
668
  scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
669
+ loginHint: z.ZodOptional<z.ZodString>;
668
670
  requestSignUp: z.ZodOptional<z.ZodBoolean>;
669
671
  providerType: z.ZodOptional<z.ZodEnum<{
670
672
  oidc: "oidc";
@@ -705,6 +707,10 @@ declare const sso: (options?: SSOOptions) => {
705
707
  type: string;
706
708
  description: string;
707
709
  };
710
+ loginHint: {
711
+ type: string;
712
+ description: string;
713
+ };
708
714
  };
709
715
  required: string[];
710
716
  };
@@ -623,6 +623,7 @@ declare const sso: (options?: SSOOptions) => {
623
623
  errorCallbackURL?: string | undefined;
624
624
  newUserCallbackURL?: string | undefined;
625
625
  scopes?: string[] | undefined;
626
+ loginHint?: string | undefined;
626
627
  requestSignUp?: boolean | undefined;
627
628
  providerType?: "oidc" | "saml" | undefined;
628
629
  };
@@ -665,6 +666,7 @@ declare const sso: (options?: SSOOptions) => {
665
666
  errorCallbackURL: z.ZodOptional<z.ZodString>;
666
667
  newUserCallbackURL: z.ZodOptional<z.ZodString>;
667
668
  scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
669
+ loginHint: z.ZodOptional<z.ZodString>;
668
670
  requestSignUp: z.ZodOptional<z.ZodBoolean>;
669
671
  providerType: z.ZodOptional<z.ZodEnum<{
670
672
  oidc: "oidc";
@@ -705,6 +707,10 @@ declare const sso: (options?: SSOOptions) => {
705
707
  type: string;
706
708
  description: string;
707
709
  };
710
+ loginHint: {
711
+ type: string;
712
+ description: string;
713
+ };
708
714
  };
709
715
  required: string[];
710
716
  };
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- const require_src = require('./src-DLLHZrD9.cjs');
1
+ const require_src = require('./src-BYOa9Nr6.cjs');
2
2
 
3
3
  exports.sso = require_src.sso;
package/dist/index.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { OIDCConfig, OIDCMapping, SAMLConfig, SAMLMapping, SSOOptions, SSOProvider, sso } from "./index-D0i1jHBp.cjs";
1
+ import { OIDCConfig, OIDCMapping, SAMLConfig, SAMLMapping, SSOOptions, SSOProvider, sso } from "./index-Cl11-WdU.cjs";
2
2
  export { OIDCConfig, OIDCMapping, SAMLConfig, SAMLMapping, SSOOptions, SSOProvider, sso };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { OIDCConfig, OIDCMapping, SAMLConfig, SAMLMapping, SSOOptions, SSOProvider, sso } from "./index-Drgwy6ZL.js";
1
+ import { OIDCConfig, OIDCMapping, SAMLConfig, SAMLMapping, SSOOptions, SSOProvider, sso } from "./index-Dtx0Mkqc.js";
2
2
  export { OIDCConfig, OIDCMapping, SAMLConfig, SAMLMapping, SSOOptions, SSOProvider, sso };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { sso } from "./src-DrA9mJEu.js";
1
+ import { sso } from "./src-Z1RpfPZt.js";
2
2
 
3
3
  export { sso };
@@ -428,6 +428,7 @@ const sso = (options) => {
428
428
  errorCallbackURL: zod_v4.string({}).meta({ description: "The URL to redirect to after login" }).optional(),
429
429
  newUserCallbackURL: zod_v4.string({}).meta({ description: "The URL to redirect to after login if the user is new" }).optional(),
430
430
  scopes: zod_v4.array(zod_v4.string(), {}).meta({ description: "Scopes to request from the provider." }).optional(),
431
+ loginHint: zod_v4.string({}).meta({ description: "Login hint to send to the identity provider (e.g., email or identifier). If supported, will be sent as 'login_hint'." }).optional(),
431
432
  requestSignUp: zod_v4.boolean({}).meta({ description: "Explicitly request sign-up. Useful when disableImplicitSignUp is true for this provider" }).optional(),
432
433
  providerType: zod_v4.enum(["oidc", "saml"]).optional()
433
434
  }),
@@ -460,6 +461,10 @@ const sso = (options) => {
460
461
  newUserCallbackURL: {
461
462
  type: "string",
462
463
  description: "The URL to redirect to after login if the user is new"
464
+ },
465
+ loginHint: {
466
+ type: "string",
467
+ description: "Login hint to send to the identity provider (e.g., email or identifier). If supported, sent as 'login_hint'."
463
468
  }
464
469
  },
465
470
  required: ["callbackURL"]
@@ -549,6 +554,7 @@ const sso = (options) => {
549
554
  "profile",
550
555
  "offline_access"
551
556
  ],
557
+ loginHint: ctx.body.loginHint || email,
552
558
  authorizationEndpoint: provider.oidcConfig.authorizationEndpoint
553
559
  });
554
560
  return ctx.json({
@@ -972,7 +978,7 @@ const sso = (options) => {
972
978
  }
973
979
  }
974
980
  await (0, better_auth_cookies.setSessionCookie)(ctx, {
975
- session: await ctx.context.internalAdapter.createSession(user.id, ctx),
981
+ session: await ctx.context.internalAdapter.createSession(user.id),
976
982
  user
977
983
  });
978
984
  const callbackUrl = RelayState || parsedSamlConfig.callbackUrl || ctx.context.baseURL;
@@ -1197,7 +1203,7 @@ const sso = (options) => {
1197
1203
  }
1198
1204
  }
1199
1205
  await (0, better_auth_cookies.setSessionCookie)(ctx, {
1200
- session: await ctx.context.internalAdapter.createSession(user.id, ctx),
1206
+ session: await ctx.context.internalAdapter.createSession(user.id),
1201
1207
  user
1202
1208
  });
1203
1209
  const callbackUrl = RelayState || parsedSamlConfig.callbackUrl || ctx.context.baseURL;
@@ -395,6 +395,7 @@ const sso = (options) => {
395
395
  errorCallbackURL: z.string({}).meta({ description: "The URL to redirect to after login" }).optional(),
396
396
  newUserCallbackURL: z.string({}).meta({ description: "The URL to redirect to after login if the user is new" }).optional(),
397
397
  scopes: z.array(z.string(), {}).meta({ description: "Scopes to request from the provider." }).optional(),
398
+ loginHint: z.string({}).meta({ description: "Login hint to send to the identity provider (e.g., email or identifier). If supported, will be sent as 'login_hint'." }).optional(),
398
399
  requestSignUp: z.boolean({}).meta({ description: "Explicitly request sign-up. Useful when disableImplicitSignUp is true for this provider" }).optional(),
399
400
  providerType: z.enum(["oidc", "saml"]).optional()
400
401
  }),
@@ -427,6 +428,10 @@ const sso = (options) => {
427
428
  newUserCallbackURL: {
428
429
  type: "string",
429
430
  description: "The URL to redirect to after login if the user is new"
431
+ },
432
+ loginHint: {
433
+ type: "string",
434
+ description: "Login hint to send to the identity provider (e.g., email or identifier). If supported, sent as 'login_hint'."
430
435
  }
431
436
  },
432
437
  required: ["callbackURL"]
@@ -516,6 +521,7 @@ const sso = (options) => {
516
521
  "profile",
517
522
  "offline_access"
518
523
  ],
524
+ loginHint: ctx.body.loginHint || email,
519
525
  authorizationEndpoint: provider.oidcConfig.authorizationEndpoint
520
526
  });
521
527
  return ctx.json({
@@ -939,7 +945,7 @@ const sso = (options) => {
939
945
  }
940
946
  }
941
947
  await setSessionCookie(ctx, {
942
- session: await ctx.context.internalAdapter.createSession(user.id, ctx),
948
+ session: await ctx.context.internalAdapter.createSession(user.id),
943
949
  user
944
950
  });
945
951
  const callbackUrl = RelayState || parsedSamlConfig.callbackUrl || ctx.context.baseURL;
@@ -1164,7 +1170,7 @@ const sso = (options) => {
1164
1170
  }
1165
1171
  }
1166
1172
  await setSessionCookie(ctx, {
1167
- session: await ctx.context.internalAdapter.createSession(user.id, ctx),
1173
+ session: await ctx.context.internalAdapter.createSession(user.id),
1168
1174
  user
1169
1175
  });
1170
1176
  const callbackUrl = RelayState || parsedSamlConfig.callbackUrl || ctx.context.baseURL;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@better-auth/sso",
3
3
  "author": "Bereket Engida",
4
- "version": "1.4.0-beta.10",
4
+ "version": "1.4.0-beta.11",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "license": "MIT",
@@ -59,10 +59,10 @@
59
59
  "body-parser": "^2.2.0",
60
60
  "express": "^5.1.0",
61
61
  "tsdown": "^0.15.6",
62
- "better-auth": "^1.4.0-beta.10"
62
+ "better-auth": "^1.4.0-beta.11"
63
63
  },
64
64
  "peerDependencies": {
65
- "better-auth": "1.4.0-beta.10"
65
+ "better-auth": "1.4.0-beta.11"
66
66
  },
67
67
  "scripts": {
68
68
  "test": "vitest",
package/src/index.ts CHANGED
@@ -922,6 +922,13 @@ export const sso = (options?: SSOOptions) => {
922
922
  description: "Scopes to request from the provider.",
923
923
  })
924
924
  .optional(),
925
+ loginHint: z
926
+ .string({})
927
+ .meta({
928
+ description:
929
+ "Login hint to send to the identity provider (e.g., email or identifier). If supported, will be sent as 'login_hint'.",
930
+ })
931
+ .optional(),
925
932
  requestSignUp: z
926
933
  .boolean({})
927
934
  .meta({
@@ -970,6 +977,11 @@ export const sso = (options?: SSOOptions) => {
970
977
  description:
971
978
  "The URL to redirect to after login if the user is new",
972
979
  },
980
+ loginHint: {
981
+ type: "string",
982
+ description:
983
+ "Login hint to send to the identity provider (e.g., email or identifier). If supported, sent as 'login_hint'.",
984
+ },
973
985
  },
974
986
  required: ["callbackURL"],
975
987
  },
@@ -1146,6 +1158,7 @@ export const sso = (options?: SSOOptions) => {
1146
1158
  "profile",
1147
1159
  "offline_access",
1148
1160
  ],
1161
+ loginHint: ctx.body.loginHint || email,
1149
1162
  authorizationEndpoint: provider.oidcConfig.authorizationEndpoint!,
1150
1163
  });
1151
1164
  return ctx.json({
@@ -1865,7 +1878,7 @@ export const sso = (options?: SSOOptions) => {
1865
1878
 
1866
1879
  // Create session and set cookie
1867
1880
  let session: Session =
1868
- await ctx.context.internalAdapter.createSession(user.id, ctx);
1881
+ await ctx.context.internalAdapter.createSession(user.id);
1869
1882
  await setSessionCookie(ctx, { session, user });
1870
1883
 
1871
1884
  // Redirect to callback URL
@@ -2224,7 +2237,7 @@ export const sso = (options?: SSOOptions) => {
2224
2237
  }
2225
2238
 
2226
2239
  let session: Session =
2227
- await ctx.context.internalAdapter.createSession(user.id, ctx);
2240
+ await ctx.context.internalAdapter.createSession(user.id);
2228
2241
  await setSessionCookie(ctx, { session, user });
2229
2242
 
2230
2243
  const callbackUrl =
package/src/oidc.test.ts CHANGED
@@ -208,6 +208,7 @@ describe("SSO", async () => {
208
208
  expect(res.url).toContain(
209
209
  "redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fapi%2Fauth%2Fsso%2Fcallback%2Ftest",
210
210
  );
211
+ expect(res.url).toContain("login_hint=my-email%40localhost.com");
211
212
  const { callbackURL } = await simulateOAuthFlow(res.url, headers);
212
213
  expect(callbackURL).toContain("/dashboard");
213
214
  });
@@ -235,6 +236,7 @@ describe("SSO", async () => {
235
236
  const headers = new Headers();
236
237
  const res = await authClient.signIn.sso({
237
238
  providerId: "test",
239
+ loginHint: "user@example.com",
238
240
  callbackURL: "/dashboard",
239
241
  fetchOptions: {
240
242
  throw: true,
@@ -245,6 +247,7 @@ describe("SSO", async () => {
245
247
  expect(res.url).toContain(
246
248
  "redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fapi%2Fauth%2Fsso%2Fcallback%2Ftest",
247
249
  );
250
+ expect(res.url).toContain("login_hint=user%40example.com");
248
251
 
249
252
  const { callbackURL } = await simulateOAuthFlow(res.url, headers);
250
253
  expect(callbackURL).toContain("/dashboard");