@better-auth/sso 1.4.0-beta.15 → 1.4.0-beta.17

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,25 +1,17 @@
1
1
 
2
- > @better-auth/sso@1.4.0-beta.15 build /home/runner/work/better-auth/better-auth/packages/sso
2
+ > @better-auth/sso@1.4.0-beta.17 build /home/runner/work/better-auth/better-auth/packages/sso
3
3
  > tsdown
4
4
 
5
- ℹ tsdown v0.15.11 powered by rolldown v1.0.0-beta.45
5
+ ℹ tsdown v0.16.0 powered by rolldown v1.0.0-beta.46
6
6
  ℹ Using tsdown config: /home/runner/work/better-auth/better-auth/packages/sso/tsdown.config.ts
7
7
  ℹ entry: src/client.ts, src/index.ts
8
8
  ℹ tsconfig: tsconfig.json
9
9
  ℹ Build start
10
- ℹ [CJS] dist/client.cjs  0.19 kB │ gzip: 0.16 kB
11
- ℹ [CJS] dist/index.cjs  0.08 kB │ gzip: 0.08 kB
12
- ℹ [CJS] dist/src-BsLnNXTo.cjs 52.34 kB │ gzip: 9.21 kB
13
- ℹ [CJS] 3 files, total: 52.61 kB
14
- ℹ [ESM] dist/client.js  0.18 kB │ gzip: 0.16 kB
15
- ℹ [ESM] dist/index.js  0.06 kB │ gzip: 0.07 kB
16
- ℹ [ESM] dist/src-BEPbgggK.js 49.59 kB │ gzip: 8.54 kB
17
- ℹ [ESM] dist/index.d.ts  0.24 kB │ gzip: 0.16 kB
18
- ℹ [ESM] dist/client.d.ts  0.21 kB │ gzip: 0.18 kB
19
- ℹ [ESM] dist/index-CdeDxbNh.d.ts 22.04 kB │ gzip: 3.15 kB
20
- ℹ [ESM] 6 files, total: 72.32 kB
21
- ℹ [CJS] dist/index.d.cts  0.24 kB │ gzip: 0.16 kB
22
- ℹ [CJS] dist/client.d.cts  0.21 kB │ gzip: 0.18 kB
23
- ℹ [CJS] dist/index-DJAIa5j3.d.cts 22.04 kB │ gzip: 3.16 kB
24
- ℹ [CJS] 3 files, total: 22.50 kB
25
- ✔ Build complete in 9377ms
10
+ ℹ dist/client.mjs  0.18 kB │ gzip: 0.16 kB
11
+ ℹ dist/index.mjs  0.06 kB │ gzip: 0.07 kB
12
+ ℹ dist/src-D0TWWO55.mjs 49.60 kB │ gzip: 8.54 kB
13
+ ℹ dist/index.d.mts  0.24 kB │ gzip: 0.16 kB
14
+ ℹ dist/client.d.mts  0.21 kB │ gzip: 0.18 kB
15
+ ℹ dist/index-D8XmWYZn.d.mts 22.51 kB │ gzip: 3.39 kB
16
+ ℹ 6 files, total: 72.81 kB
17
+ ✔ Build complete in 11481ms
@@ -1,4 +1,4 @@
1
- import { s as sso } from "./index-DJAIa5j3.cjs";
1
+ import { s as sso } from "./index-D8XmWYZn.mjs";
2
2
 
3
3
  //#region src/client.d.ts
4
4
  declare const ssoClient: () => {
@@ -1,4 +1,4 @@
1
- import "./src-BEPbgggK.js";
1
+ import "./src-D0TWWO55.mjs";
2
2
 
3
3
  //#region src/client.ts
4
4
  const ssoClient = () => {
@@ -181,6 +181,12 @@ interface SSOOptions {
181
181
  providersLimit?: (number | ((user: User) => Promise<number> | number)) | undefined;
182
182
  /**
183
183
  * Trust the email verified flag from the provider.
184
+ *
185
+ * ⚠️ Use this with caution — it can lead to account takeover if misused. Only enable it if users **cannot freely register new providers**. You can
186
+ * prevent that by using `disabledPaths` or other safeguards to block provider registration from the client.
187
+ *
188
+ * If you want to allow account linking for specific trusted providers, enable the `accountLinking` option in your auth config and specify those
189
+ * providers in the `trustedProviders` list.
184
190
  * @default false
185
191
  */
186
192
  trustEmailVerified?: boolean | undefined;
@@ -193,8 +199,8 @@ declare const sso: (options?: SSOOptions | undefined) => {
193
199
  query: z.ZodObject<{
194
200
  providerId: z.ZodString;
195
201
  format: z.ZodDefault<z.ZodEnum<{
196
- json: "json";
197
202
  xml: "xml";
203
+ json: "json";
198
204
  }>>;
199
205
  }, z.core.$strip>;
200
206
  metadata: {
@@ -1,2 +1,2 @@
1
- import { a as SSOOptions, i as SAMLMapping, n as OIDCMapping, o as SSOProvider, r as SAMLConfig, s as sso, t as OIDCConfig } from "./index-DJAIa5j3.cjs";
1
+ import { a as SSOOptions, i as SAMLMapping, n as OIDCMapping, o as SSOProvider, r as SAMLConfig, s as sso, t as OIDCConfig } from "./index-D8XmWYZn.mjs";
2
2
  export { OIDCConfig, OIDCMapping, SAMLConfig, SAMLMapping, SSOOptions, SSOProvider, sso };
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { t as sso } from "./src-D0TWWO55.mjs";
2
+
3
+ export { sso };
@@ -504,7 +504,7 @@ const sso = (options) => {
504
504
  if (body.providerType === "saml" && !provider.samlConfig) throw new APIError("BAD_REQUEST", { message: "SAML provider is not configured" });
505
505
  }
506
506
  if (provider.oidcConfig && body.providerType !== "saml") {
507
- const state = await generateState(ctx);
507
+ const state = await generateState(ctx, void 0, false);
508
508
  const redirectURI = `${ctx.context.baseURL}/sso/callback/${provider.providerId}`;
509
509
  const authorizationURL = await createAuthorizationURL({
510
510
  id: provider.issuer,
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@better-auth/sso",
3
3
  "author": "Bereket Engida",
4
- "version": "1.4.0-beta.15",
4
+ "version": "1.4.0-beta.17",
5
5
  "type": "module",
6
- "main": "dist/index.js",
6
+ "main": "dist/index.mjs",
7
7
  "homepage": "https://www.better-auth.com/docs/plugins/sso",
8
8
  "repository": {
9
9
  "type": "git",
@@ -26,29 +26,27 @@
26
26
  "publishConfig": {
27
27
  "access": "public"
28
28
  },
29
- "module": "dist/index.js",
29
+ "module": "dist/index.mjs",
30
30
  "description": "SSO plugin for Better Auth",
31
31
  "exports": {
32
32
  ".": {
33
33
  "better-auth-dev-source": "./src/index.ts",
34
- "types": "./dist/index.d.ts",
35
- "import": "./dist/index.js",
36
- "require": "./dist/index.cjs"
34
+ "types": "./dist/index.d.mts",
35
+ "default": "./dist/index.mjs"
37
36
  },
38
37
  "./client": {
39
38
  "better-auth-dev-source": "./src/client.ts",
40
- "types": "./dist/client.d.ts",
41
- "import": "./dist/client.js",
42
- "require": "./dist/client.cjs"
39
+ "types": "./dist/client.d.mts",
40
+ "default": "./dist/client.mjs"
43
41
  }
44
42
  },
45
43
  "typesVersions": {
46
44
  "*": {
47
45
  "*": [
48
- "./dist/index.d.ts"
46
+ "./dist/index.d.mts"
49
47
  ],
50
48
  "client": [
51
- "./dist/client.d.ts"
49
+ "./dist/client.d.mts"
52
50
  ]
53
51
  }
54
52
  },
@@ -56,21 +54,21 @@
56
54
  "@better-fetch/fetch": "1.1.18",
57
55
  "fast-xml-parser": "^5.2.5",
58
56
  "jose": "^6.1.0",
59
- "oauth2-mock-server": "^7.2.1",
60
57
  "samlify": "^2.10.1",
61
58
  "zod": "^4.1.5"
62
59
  },
63
60
  "devDependencies": {
64
61
  "@types/body-parser": "^1.19.6",
65
62
  "@types/express": "^5.0.5",
66
- "better-call": "1.0.24",
63
+ "better-call": "1.0.26",
67
64
  "body-parser": "^2.2.0",
68
65
  "express": "^5.1.0",
69
- "tsdown": "^0.15.11",
70
- "better-auth": "^1.4.0-beta.15"
66
+ "oauth2-mock-server": "^7.2.1",
67
+ "tsdown": "^0.16.0",
68
+ "better-auth": "^1.4.0-beta.17"
71
69
  },
72
70
  "peerDependencies": {
73
- "better-auth": "1.4.0-beta.15"
71
+ "better-auth": "1.4.0-beta.17"
74
72
  },
75
73
  "scripts": {
76
74
  "test": "vitest",
package/src/index.ts CHANGED
@@ -260,6 +260,12 @@ export interface SSOOptions {
260
260
  | undefined;
261
261
  /**
262
262
  * Trust the email verified flag from the provider.
263
+ *
264
+ * ⚠️ Use this with caution — it can lead to account takeover if misused. Only enable it if users **cannot freely register new providers**. You can
265
+ * prevent that by using `disabledPaths` or other safeguards to block provider registration from the client.
266
+ *
267
+ * If you want to allow account linking for specific trusted providers, enable the `accountLinking` option in your auth config and specify those
268
+ * providers in the `trustedProviders` list.
263
269
  * @default false
264
270
  */
265
271
  trustEmailVerified?: boolean | undefined;
@@ -1149,7 +1155,7 @@ export const sso = (options?: SSOOptions | undefined) => {
1149
1155
  }
1150
1156
  }
1151
1157
  if (provider.oidcConfig && body.providerType !== "saml") {
1152
- const state = await generateState(ctx);
1158
+ const state = await generateState(ctx, undefined, false);
1153
1159
  const redirectURI = `${ctx.context.baseURL}/sso/callback/${provider.providerId}`;
1154
1160
  const authorizationURL = await createAuthorizationURL({
1155
1161
  id: provider.issuer,
package/src/oidc.test.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { betterFetch } from "@better-fetch/fetch";
2
2
  import { createAuthClient } from "better-auth/client";
3
3
  import { organization } from "better-auth/plugins";
4
- import { getTestInstanceMemory as getTestInstance } from "better-auth/test";
4
+ import { getTestInstance } from "better-auth/test";
5
5
  import { OAuth2Server } from "oauth2-mock-server";
6
6
  import { afterAll, beforeAll, describe, expect, it } from "vitest";
7
7
  import { sso } from ".";
package/src/saml.test.ts CHANGED
@@ -4,7 +4,7 @@ import { memoryAdapter } from "better-auth/adapters/memory";
4
4
  import { createAuthClient } from "better-auth/client";
5
5
  import { setCookieToHeader } from "better-auth/cookies";
6
6
  import { bearer } from "better-auth/plugins";
7
- import { getTestInstanceMemory } from "better-auth/test";
7
+ import { getTestInstance } from "better-auth/test";
8
8
  import bodyParser from "body-parser";
9
9
  import { randomUUID } from "crypto";
10
10
  import type {
@@ -926,7 +926,7 @@ describe("SAML SSO", async () => {
926
926
  });
927
927
 
928
928
  it("should not allow creating a provider if limit is set to 0", async () => {
929
- const { auth, signInWithTestUser } = await getTestInstanceMemory({
929
+ const { auth, signInWithTestUser } = await getTestInstance({
930
930
  plugins: [sso({ providersLimit: 0 })],
931
931
  });
932
932
  const { headers } = await signInWithTestUser();
@@ -957,7 +957,7 @@ describe("SAML SSO", async () => {
957
957
  });
958
958
 
959
959
  it("should not allow creating a provider if limit is reached", async () => {
960
- const { auth, signInWithTestUser } = await getTestInstanceMemory({
960
+ const { auth, signInWithTestUser } = await getTestInstance({
961
961
  plugins: [sso({ providersLimit: 1 })],
962
962
  });
963
963
  const { headers } = await signInWithTestUser();
@@ -1011,7 +1011,7 @@ describe("SAML SSO", async () => {
1011
1011
  });
1012
1012
 
1013
1013
  it("should not allow creating a provider if limit from function is reached", async () => {
1014
- const { auth, signInWithTestUser } = await getTestInstanceMemory({
1014
+ const { auth, signInWithTestUser } = await getTestInstance({
1015
1015
  plugins: [
1016
1016
  sso({
1017
1017
  providersLimit: async (user) => {
package/tsdown.config.ts CHANGED
@@ -2,7 +2,7 @@ import { defineConfig } from "tsdown";
2
2
 
3
3
  export default defineConfig({
4
4
  dts: { build: true, incremental: true },
5
- format: ["esm", "cjs"],
5
+ format: ["esm"],
6
6
  entry: ["./src/index.ts", "./src/client.ts"],
7
7
  external: ["better-auth", "better-call", "@better-fetch/fetch", "stripe"],
8
8
  });
package/dist/client.cjs DELETED
@@ -1,12 +0,0 @@
1
- require('./src-BsLnNXTo.cjs');
2
-
3
- //#region src/client.ts
4
- const ssoClient = () => {
5
- return {
6
- id: "sso-client",
7
- $InferServerPlugin: {}
8
- };
9
- };
10
-
11
- //#endregion
12
- exports.ssoClient = ssoClient;
package/dist/client.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import { s as sso } from "./index-CdeDxbNh.js";
2
-
3
- //#region src/client.d.ts
4
- declare const ssoClient: () => {
5
- id: "sso-client";
6
- $InferServerPlugin: ReturnType<typeof sso>;
7
- };
8
- //#endregion
9
- export { ssoClient };