@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.
- package/.turbo/turbo-build.log +9 -9
- package/dist/client.cjs +1 -1
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/{index-D0i1jHBp.d.cts → index-Cl11-WdU.d.cts} +6 -0
- package/dist/{index-Drgwy6ZL.d.ts → index-Dtx0Mkqc.d.ts} +6 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{src-DLLHZrD9.cjs → src-BYOa9Nr6.cjs} +8 -2
- package/dist/{src-DrA9mJEu.js → src-Z1RpfPZt.js} +8 -2
- package/package.json +3 -3
- package/src/index.ts +15 -2
- package/src/oidc.test.ts +3 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @better-auth/sso@1.4.0-beta.
|
|
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
|
[34mℹ[39m tsdown [2mv0.15.6[22m powered by rolldown [2mv1.0.0-beta.43[22m
|
|
@@ -9,17 +9,17 @@
|
|
|
9
9
|
[34mℹ[39m Build start
|
|
10
10
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[1mclient.cjs[22m [2m 0.19 kB[22m [2m│ gzip: 0.17 kB[22m
|
|
11
11
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[1mindex.cjs[22m [2m 0.08 kB[22m [2m│ gzip: 0.08 kB[22m
|
|
12
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22msrc-
|
|
13
|
-
[34mℹ[39m [33m[CJS][39m 3 files, total: 52.
|
|
12
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22msrc-BYOa9Nr6.cjs [2m52.34 kB[22m [2m│ gzip: 9.21 kB[22m
|
|
13
|
+
[34mℹ[39m [33m[CJS][39m 3 files, total: 52.61 kB
|
|
14
14
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[1mclient.js[22m [2m 0.18 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
15
15
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[1mindex.js[22m [2m 0.06 kB[22m [2m│ gzip: 0.07 kB[22m
|
|
16
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22msrc-
|
|
16
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22msrc-Z1RpfPZt.js [2m49.58 kB[22m [2m│ gzip: 8.54 kB[22m
|
|
17
17
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32m[1mindex.d.ts[22m[39m [2m 0.21 kB[22m [2m│ gzip: 0.12 kB[22m
|
|
18
18
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32m[1mclient.d.ts[22m[39m [2m 0.21 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
19
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mindex-
|
|
20
|
-
[34mℹ[39m [34m[ESM][39m 6 files, total:
|
|
19
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mindex-Dtx0Mkqc.d.ts[39m [2m31.02 kB[22m [2m│ gzip: 3.72 kB[22m
|
|
20
|
+
[34mℹ[39m [34m[ESM][39m 6 files, total: 81.25 kB
|
|
21
21
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32m[1mindex.d.cts[22m[39m [2m 0.21 kB[22m [2m│ gzip: 0.12 kB[22m
|
|
22
22
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32m[1mclient.d.cts[22m[39m [2m 0.21 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
23
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mindex-
|
|
24
|
-
[34mℹ[39m [33m[CJS][39m 3 files, total: 31.
|
|
25
|
-
[32m✔[39m Build complete in [
|
|
23
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mindex-Cl11-WdU.d.cts[39m [2m31.02 kB[22m [2m│ gzip: 3.72 kB[22m
|
|
24
|
+
[34mℹ[39m [33m[CJS][39m 3 files, total: 31.44 kB
|
|
25
|
+
[32m✔[39m Build complete in [32m5245ms[39m
|
package/dist/client.cjs
CHANGED
package/dist/client.d.cts
CHANGED
package/dist/client.d.ts
CHANGED
package/dist/client.js
CHANGED
|
@@ -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
package/dist/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { OIDCConfig, OIDCMapping, SAMLConfig, SAMLMapping, SSOOptions, SSOProvider, sso } from "./index-
|
|
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-
|
|
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
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
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.
|
|
62
|
+
"better-auth": "^1.4.0-beta.11"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"better-auth": "1.4.0-beta.
|
|
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
|
|
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
|
|
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");
|