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

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.
@@ -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.12",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "license": "MIT",
@@ -55,14 +55,14 @@
55
55
  "devDependencies": {
56
56
  "@types/body-parser": "^1.19.6",
57
57
  "@types/express": "^5.0.3",
58
- "better-call": "1.0.19",
58
+ "better-call": "1.0.24",
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.12"
63
63
  },
64
64
  "peerDependencies": {
65
- "better-auth": "1.4.0-beta.10"
65
+ "better-auth": "1.4.0-beta.12"
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");