@better-auth/sso 1.4.6-beta.6 → 1.4.7-beta.2

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,16 +1,16 @@
1
1
 
2
- > @better-auth/sso@1.4.6-beta.6 build /home/runner/work/better-auth/better-auth/packages/sso
2
+ > @better-auth/sso@1.4.7-beta.2 build /home/runner/work/better-auth/better-auth/packages/sso
3
3
  > tsdown
4
4
 
5
- ℹ tsdown v0.17.0 powered by rolldown v1.0.0-beta.53
5
+ ℹ tsdown v0.17.2 powered by rolldown v1.0.0-beta.53
6
6
  ℹ config file: /home/runner/work/better-auth/better-auth/packages/sso/tsdown.config.ts
7
7
  ℹ entry: src/index.ts, src/client.ts
8
8
  ℹ tsconfig: tsconfig.json
9
9
  ℹ Build start
10
- ℹ dist/index.mjs 59.70 kB │ gzip: 10.49 kB
10
+ ℹ dist/index.mjs 59.70 kB │ gzip: 10.48 kB
11
11
  ℹ dist/client.mjs  0.15 kB │ gzip: 0.14 kB
12
- ℹ dist/client.d.mts  0.49 kB │ gzip: 0.29 kB
12
+ ℹ dist/client.d.mts  0.49 kB │ gzip: 0.30 kB
13
13
  ℹ dist/index.d.mts  0.21 kB │ gzip: 0.15 kB
14
- ℹ dist/index-CYgzSZS4.d.mts 25.84 kB │ gzip: 4.13 kB
14
+ ℹ dist/index-BWvN4yrs.d.mts 25.84 kB │ gzip: 4.13 kB
15
15
  ℹ 5 files, total: 86.39 kB
16
- ✔ Build complete in 11274ms
16
+ ✔ Build complete in 12102ms
package/dist/client.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as SSOPlugin } from "./index-CYgzSZS4.mjs";
1
+ import { t as SSOPlugin } from "./index-BWvN4yrs.mjs";
2
2
 
3
3
  //#region src/client.d.ts
4
4
  interface SSOClientOptions {
@@ -1,6 +1,6 @@
1
1
  import * as z from "zod/v4";
2
2
  import { OAuth2Tokens, User } from "better-auth";
3
- import * as better_call0 from "better-call";
3
+ import * as better_call7 from "better-call";
4
4
 
5
5
  //#region src/types.d.ts
6
6
  interface OIDCMapping {
@@ -246,7 +246,7 @@ interface SSOOptions {
246
246
  }
247
247
  //#endregion
248
248
  //#region src/routes/domain-verification.d.ts
249
- declare const requestDomainVerification: (options: SSOOptions) => better_call0.StrictEndpoint<"/sso/request-domain-verification", {
249
+ declare const requestDomainVerification: (options: SSOOptions) => better_call7.StrictEndpoint<"/sso/request-domain-verification", {
250
250
  method: "POST";
251
251
  body: z.ZodObject<{
252
252
  providerId: z.ZodString;
@@ -268,7 +268,7 @@ declare const requestDomainVerification: (options: SSOOptions) => better_call0.S
268
268
  };
269
269
  };
270
270
  };
271
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
271
+ use: ((inputContext: better_call7.MiddlewareInputContext<better_call7.MiddlewareOptions>) => Promise<{
272
272
  session: {
273
273
  session: Record<string, any> & {
274
274
  id: string;
@@ -296,7 +296,7 @@ declare const requestDomainVerification: (options: SSOOptions) => better_call0.S
296
296
  }, {
297
297
  domainVerificationToken: string;
298
298
  }>;
299
- declare const verifyDomain: (options: SSOOptions) => better_call0.StrictEndpoint<"/sso/verify-domain", {
299
+ declare const verifyDomain: (options: SSOOptions) => better_call7.StrictEndpoint<"/sso/verify-domain", {
300
300
  method: "POST";
301
301
  body: z.ZodObject<{
302
302
  providerId: z.ZodString;
@@ -321,7 +321,7 @@ declare const verifyDomain: (options: SSOOptions) => better_call0.StrictEndpoint
321
321
  };
322
322
  };
323
323
  };
324
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
324
+ use: ((inputContext: better_call7.MiddlewareInputContext<better_call7.MiddlewareOptions>) => Promise<{
325
325
  session: {
326
326
  session: Record<string, any> & {
327
327
  id: string;
@@ -349,7 +349,7 @@ declare const verifyDomain: (options: SSOOptions) => better_call0.StrictEndpoint
349
349
  }, void>;
350
350
  //#endregion
351
351
  //#region src/routes/sso.d.ts
352
- declare const spMetadata: () => better_call0.StrictEndpoint<"/sso/saml2/sp/metadata", {
352
+ declare const spMetadata: () => better_call7.StrictEndpoint<"/sso/saml2/sp/metadata", {
353
353
  method: "GET";
354
354
  query: z.ZodObject<{
355
355
  providerId: z.ZodString;
@@ -373,7 +373,7 @@ declare const spMetadata: () => better_call0.StrictEndpoint<"/sso/saml2/sp/metad
373
373
  } & {
374
374
  use: any[];
375
375
  }, Response>;
376
- declare const registerSSOProvider: <O extends SSOOptions>(options: O) => better_call0.StrictEndpoint<"/sso/register", {
376
+ declare const registerSSOProvider: <O extends SSOOptions>(options: O) => better_call7.StrictEndpoint<"/sso/register", {
377
377
  method: "POST";
378
378
  body: z.ZodObject<{
379
379
  providerId: z.ZodString;
@@ -451,7 +451,7 @@ declare const registerSSOProvider: <O extends SSOOptions>(options: O) => better_
451
451
  organizationId: z.ZodOptional<z.ZodString>;
452
452
  overrideUserInfo: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
453
453
  }, z.core.$strip>;
454
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
454
+ use: ((inputContext: better_call7.MiddlewareInputContext<better_call7.MiddlewareOptions>) => Promise<{
455
455
  session: {
456
456
  session: Record<string, any> & {
457
457
  id: string;
@@ -643,7 +643,7 @@ declare const registerSSOProvider: <O extends SSOOptions>(options: O) => better_
643
643
  domainVerified: boolean;
644
644
  domainVerificationToken: string;
645
645
  } & SSOProvider<O> : SSOProvider<O>>;
646
- declare const signInSSO: (options?: SSOOptions) => better_call0.StrictEndpoint<"/sign-in/sso", {
646
+ declare const signInSSO: (options?: SSOOptions) => better_call7.StrictEndpoint<"/sign-in/sso", {
647
647
  method: "POST";
648
648
  body: z.ZodObject<{
649
649
  email: z.ZodOptional<z.ZodString>;
@@ -739,7 +739,7 @@ declare const signInSSO: (options?: SSOOptions) => better_call0.StrictEndpoint<"
739
739
  url: string;
740
740
  redirect: boolean;
741
741
  }>;
742
- declare const callbackSSO: (options?: SSOOptions) => better_call0.StrictEndpoint<"/sso/callback/:providerId", {
742
+ declare const callbackSSO: (options?: SSOOptions) => better_call7.StrictEndpoint<"/sso/callback/:providerId", {
743
743
  method: "GET";
744
744
  query: z.ZodObject<{
745
745
  code: z.ZodOptional<z.ZodString>;
@@ -764,7 +764,7 @@ declare const callbackSSO: (options?: SSOOptions) => better_call0.StrictEndpoint
764
764
  } & {
765
765
  use: any[];
766
766
  }, never>;
767
- declare const callbackSSOSAML: (options?: SSOOptions) => better_call0.StrictEndpoint<"/sso/saml2/callback/:providerId", {
767
+ declare const callbackSSOSAML: (options?: SSOOptions) => better_call7.StrictEndpoint<"/sso/saml2/callback/:providerId", {
768
768
  method: "POST";
769
769
  body: z.ZodObject<{
770
770
  SAMLResponse: z.ZodString;
@@ -793,7 +793,7 @@ declare const callbackSSOSAML: (options?: SSOOptions) => better_call0.StrictEndp
793
793
  } & {
794
794
  use: any[];
795
795
  }, never>;
796
- declare const acsEndpoint: (options?: SSOOptions) => better_call0.StrictEndpoint<"/sso/saml2/sp/acs/:providerId", {
796
+ declare const acsEndpoint: (options?: SSOOptions) => better_call7.StrictEndpoint<"/sso/saml2/sp/acs/:providerId", {
797
797
  method: "POST";
798
798
  params: z.ZodObject<{
799
799
  providerId: z.ZodOptional<z.ZodString>;
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as SSOOptions, i as SAMLConfig, n as sso, o as SSOProvider, r as OIDCConfig, t as SSOPlugin } from "./index-CYgzSZS4.mjs";
1
+ import { a as SSOOptions, i as SAMLConfig, n as sso, o as SSOProvider, r as OIDCConfig, t as SSOPlugin } from "./index-BWvN4yrs.mjs";
2
2
  export { OIDCConfig, SAMLConfig, SSOOptions, SSOPlugin, SSOProvider, sso };
package/dist/index.mjs CHANGED
@@ -810,7 +810,7 @@ const callbackSSO = (options) => {
810
810
  }
811
811
  }
812
812
  }, async (ctx) => {
813
- const { code, state, error, error_description } = ctx.query;
813
+ const { code, error, error_description } = ctx.query;
814
814
  const stateData = await parseState(ctx);
815
815
  if (!stateData) {
816
816
  const errorURL$1 = ctx.context.options.onAPIError?.errorURL || `${ctx.context.baseURL}/error`;
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.6-beta.6",
4
+ "version": "1.4.7-beta.2",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",
7
7
  "types": "dist/index.d.mts",
@@ -65,16 +65,17 @@
65
65
  "body-parser": "^2.2.1",
66
66
  "express": "^5.1.0",
67
67
  "oauth2-mock-server": "^8.2.0",
68
- "tsdown": "^0.17.0",
69
- "better-auth": "1.4.6-beta.6"
68
+ "tsdown": "^0.17.2",
69
+ "better-auth": "1.4.7-beta.2"
70
70
  },
71
71
  "peerDependencies": {
72
- "better-auth": "1.4.6-beta.6"
72
+ "better-auth": "1.4.7-beta.2"
73
73
  },
74
74
  "scripts": {
75
75
  "test": "vitest",
76
76
  "coverage": "vitest run --coverage",
77
77
  "lint:package": "publint run --strict",
78
+ "lint:types": "attw --profile esm-only --pack .",
78
79
  "build": "tsdown",
79
80
  "dev": "tsdown --watch",
80
81
  "typecheck": "tsc --project tsconfig.json"
package/src/routes/sso.ts CHANGED
@@ -1107,7 +1107,7 @@ export const callbackSSO = (options?: SSOOptions) => {
1107
1107
  },
1108
1108
  },
1109
1109
  async (ctx) => {
1110
- const { code, state, error, error_description } = ctx.query;
1110
+ const { code, error, error_description } = ctx.query;
1111
1111
  const stateData = await parseState(ctx);
1112
1112
  if (!stateData) {
1113
1113
  const errorURL =
package/src/saml.test.ts CHANGED
@@ -448,13 +448,9 @@ const createMockSAMLIdP = (port: number) => {
448
448
  async (req: ExpressRequest, res: ExpressResponse) => {
449
449
  const { SAMLResponse, RelayState } = req.body;
450
450
  try {
451
- const parseResult = await sp.parseLoginResponse(
452
- idp,
453
- saml.Constants.wording.binding.post,
454
- { body: { SAMLResponse } },
455
- );
456
-
457
- const { attributes, nameID } = parseResult.extract;
451
+ await sp.parseLoginResponse(idp, saml.Constants.wording.binding.post, {
452
+ body: { SAMLResponse },
453
+ });
458
454
 
459
455
  res.redirect(302, RelayState || "http://localhost:3000/dashboard");
460
456
  } catch (error) {
@@ -550,18 +546,6 @@ describe("SAML SSO with defaultSSO array", async () => {
550
546
  plugins: [sso(ssoOptions)],
551
547
  });
552
548
 
553
- const ctx = await auth.$context;
554
-
555
- const authClient = createAuthClient({
556
- baseURL: "http://localhost:3000",
557
- plugins: [bearer(), ssoClient()],
558
- fetchOptions: {
559
- customFetchImpl: async (url, init) => {
560
- return auth.handler(new Request(url, init));
561
- },
562
- },
563
- });
564
-
565
549
  beforeAll(async () => {
566
550
  await mockIdP.start();
567
551
  });
@@ -619,8 +603,6 @@ describe("SAML SSO", async () => {
619
603
  plugins: [sso(ssoOptions)],
620
604
  });
621
605
 
622
- const ctx = await auth.$context;
623
-
624
606
  const authClient = createAuthClient({
625
607
  baseURL: "http://localhost:3000",
626
608
  plugins: [bearer(), ssoClient()],
@@ -639,7 +621,7 @@ describe("SAML SSO", async () => {
639
621
 
640
622
  beforeAll(async () => {
641
623
  await mockIdP.start();
642
- const res = await authClient.signUp.email({
624
+ await authClient.signUp.email({
643
625
  email: testUser.email,
644
626
  password: testUser.password,
645
627
  name: testUser.name,
@@ -667,7 +649,7 @@ describe("SAML SSO", async () => {
667
649
  password: testUser.password,
668
650
  name: testUser.name,
669
651
  });
670
- const res = await authClient.signIn.email(testUser, {
652
+ await authClient.signIn.email(testUser, {
671
653
  throw: true,
672
654
  onSuccess: setCookieToHeader(headers),
673
655
  });
@@ -676,7 +658,7 @@ describe("SAML SSO", async () => {
676
658
 
677
659
  it("should register a new SAML provider", async () => {
678
660
  const headers = await getAuthHeaders();
679
- const res = await authClient.signIn.email(testUser, {
661
+ await authClient.signIn.email(testUser, {
680
662
  throw: true,
681
663
  onSuccess: setCookieToHeader(headers),
682
664
  });
@@ -847,11 +829,11 @@ describe("SAML SSO", async () => {
847
829
  });
848
830
  it("should initiate SAML login and handle response", async () => {
849
831
  const headers = await getAuthHeaders();
850
- const res = await authClient.signIn.email(testUser, {
832
+ await authClient.signIn.email(testUser, {
851
833
  throw: true,
852
834
  onSuccess: setCookieToHeader(headers),
853
835
  });
854
- const provider = await auth.api.registerSSOProvider({
836
+ await auth.api.registerSSOProvider({
855
837
  body: {
856
838
  providerId: "saml-provider-1",
857
839
  issuer: "http://localhost:8081",
@@ -1184,11 +1166,7 @@ describe("SAML SSO", async () => {
1184
1166
  });
1185
1167
 
1186
1168
  it("should deny account linking when provider is not trusted and domain is not verified", async () => {
1187
- const {
1188
- auth: authUntrusted,
1189
- signInWithTestUser,
1190
- client,
1191
- } = await getTestInstance({
1169
+ const { auth: authUntrusted, signInWithTestUser } = await getTestInstance({
1192
1170
  account: {
1193
1171
  accountLinking: {
1194
1172
  enabled: true,
@@ -1401,7 +1379,7 @@ describe("SAML SSO with custom fields", () => {
1401
1379
 
1402
1380
  beforeAll(async () => {
1403
1381
  await mockIdP.start();
1404
- const res = await authClient.signUp.email({
1382
+ await authClient.signUp.email({
1405
1383
  email: testUser.email,
1406
1384
  password: testUser.password,
1407
1385
  name: testUser.name,
package/bump.config.ts DELETED
@@ -1,5 +0,0 @@
1
- import { defineConfig } from "bumpp";
2
-
3
- export default defineConfig({
4
- files: ["package.json"],
5
- });