@bigso/auth-sdk 0.4.4 → 0.4.6

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.
@@ -17,12 +17,12 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
20
+ // src/browser/index.ts
21
+ var browser_exports = {};
22
+ __export(browser_exports, {
23
23
  BigsoAuth: () => BigsoAuth
24
24
  });
25
- module.exports = __toCommonJS(index_exports);
25
+ module.exports = __toCommonJS(browser_exports);
26
26
 
27
27
  // src/utils/crypto.ts
28
28
  async function sha256Base64Url(input) {
@@ -71,7 +71,7 @@ async function verifySignedPayload(token, jwksUrl, expectedAudience) {
71
71
  return payload;
72
72
  }
73
73
 
74
- // src/core/auth.ts
74
+ // src/browser/auth.ts
75
75
  var BigsoAuth = class extends EventEmitter {
76
76
  constructor(options) {
77
77
  super();
@@ -355,12 +355,13 @@ var BigsoAuth = class extends EventEmitter {
355
355
  }
356
356
  // ─── Helpers ──────────────────────────────────────────────────────
357
357
  buildFallbackUrl() {
358
- const url = new URL(`${this.options.ssoOrigin}/authorize`);
359
- url.searchParams.set("client_id", this.options.clientId);
360
- url.searchParams.set("response_type", "code");
358
+ const url = new URL(this.options.ssoOrigin);
359
+ url.searchParams.set("app_id", this.options.clientId);
361
360
  url.searchParams.set("redirect_uri", this.options.redirectUri || window.location.origin);
361
+ url.searchParams.set("response_type", "code");
362
362
  url.searchParams.set("state", generateRandomId());
363
363
  url.searchParams.set("code_challenge_method", "S256");
364
+ url.searchParams.set("client_id", this.options.clientId);
364
365
  return url.toString();
365
366
  }
366
367
  debug(...args) {
@@ -1,3 +1,5 @@
1
+ import { B as BigsoAuthOptions } from '../types-CoXgtTry.cjs';
2
+
1
3
  declare class EventEmitter {
2
4
  private events;
3
5
  on(event: string, handler: Function): void;
@@ -5,25 +7,6 @@ declare class EventEmitter {
5
7
  emit(event: string, data?: any): void;
6
8
  }
7
9
 
8
- interface BigsoAuthOptions {
9
- /** Client ID registrado en el SSO */
10
- clientId: string;
11
- /** Origen del SSO (ej: https://sso.bigso.co) */
12
- ssoOrigin: string;
13
- /** URL del JWKS para verificar firmas (ej: https://sso.bigso.co/.well-known/jwks.json) */
14
- jwksUrl: string;
15
- /** Timeout en milisegundos (por defecto 5000) */
16
- timeout?: number;
17
- /** Activar logs de depuración */
18
- debug?: boolean;
19
- /** URI de redirección registrada (opcional, si se requiere validación exacta) */
20
- redirectUri?: string;
21
- /** Sugerencia de tenant (opcional) */
22
- tenantHint?: string;
23
- /** Tema visual del iframe ('light' | 'dark', por defecto 'light') */
24
- theme?: 'light' | 'dark';
25
- }
26
-
27
10
  declare class BigsoAuth extends EventEmitter {
28
11
  private options;
29
12
  private iframe?;
@@ -63,4 +46,4 @@ declare class BigsoAuth extends EventEmitter {
63
46
  private debug;
64
47
  }
65
48
 
66
- export { BigsoAuth, type BigsoAuthOptions };
49
+ export { BigsoAuth, BigsoAuthOptions };
@@ -1,3 +1,5 @@
1
+ import { B as BigsoAuthOptions } from '../types-CoXgtTry.js';
2
+
1
3
  declare class EventEmitter {
2
4
  private events;
3
5
  on(event: string, handler: Function): void;
@@ -5,25 +7,6 @@ declare class EventEmitter {
5
7
  emit(event: string, data?: any): void;
6
8
  }
7
9
 
8
- interface BigsoAuthOptions {
9
- /** Client ID registrado en el SSO */
10
- clientId: string;
11
- /** Origen del SSO (ej: https://sso.bigso.co) */
12
- ssoOrigin: string;
13
- /** URL del JWKS para verificar firmas (ej: https://sso.bigso.co/.well-known/jwks.json) */
14
- jwksUrl: string;
15
- /** Timeout en milisegundos (por defecto 5000) */
16
- timeout?: number;
17
- /** Activar logs de depuración */
18
- debug?: boolean;
19
- /** URI de redirección registrada (opcional, si se requiere validación exacta) */
20
- redirectUri?: string;
21
- /** Sugerencia de tenant (opcional) */
22
- tenantHint?: string;
23
- /** Tema visual del iframe ('light' | 'dark', por defecto 'light') */
24
- theme?: 'light' | 'dark';
25
- }
26
-
27
10
  declare class BigsoAuth extends EventEmitter {
28
11
  private options;
29
12
  private iframe?;
@@ -63,4 +46,4 @@ declare class BigsoAuth extends EventEmitter {
63
46
  private debug;
64
47
  }
65
48
 
66
- export { BigsoAuth, type BigsoAuthOptions };
49
+ export { BigsoAuth, BigsoAuthOptions };
@@ -1,3 +1,7 @@
1
+ import {
2
+ verifySignedPayload
3
+ } from "../chunk-LDDK6SJD.js";
4
+
1
5
  // src/utils/crypto.ts
2
6
  async function sha256Base64Url(input) {
3
7
  const encoder = new TextEncoder();
@@ -35,17 +39,7 @@ var EventEmitter = class {
35
39
  }
36
40
  };
37
41
 
38
- // src/utils/jws.ts
39
- import { jwtVerify, createRemoteJWKSet } from "jose";
40
- async function verifySignedPayload(token, jwksUrl, expectedAudience) {
41
- const JWKS = createRemoteJWKSet(new URL(jwksUrl));
42
- const { payload } = await jwtVerify(token, JWKS, {
43
- audience: expectedAudience
44
- });
45
- return payload;
46
- }
47
-
48
- // src/core/auth.ts
42
+ // src/browser/auth.ts
49
43
  var BigsoAuth = class extends EventEmitter {
50
44
  constructor(options) {
51
45
  super();
@@ -329,12 +323,13 @@ var BigsoAuth = class extends EventEmitter {
329
323
  }
330
324
  // ─── Helpers ──────────────────────────────────────────────────────
331
325
  buildFallbackUrl() {
332
- const url = new URL(`${this.options.ssoOrigin}/authorize`);
333
- url.searchParams.set("client_id", this.options.clientId);
334
- url.searchParams.set("response_type", "code");
326
+ const url = new URL(this.options.ssoOrigin);
327
+ url.searchParams.set("app_id", this.options.clientId);
335
328
  url.searchParams.set("redirect_uri", this.options.redirectUri || window.location.origin);
329
+ url.searchParams.set("response_type", "code");
336
330
  url.searchParams.set("state", generateRandomId());
337
331
  url.searchParams.set("code_challenge_method", "S256");
332
+ url.searchParams.set("client_id", this.options.clientId);
338
333
  return url.toString();
339
334
  }
340
335
  debug(...args) {
@@ -0,0 +1,13 @@
1
+ // src/utils/jws.ts
2
+ import { jwtVerify, createRemoteJWKSet } from "jose";
3
+ async function verifySignedPayload(token, jwksUrl, expectedAudience) {
4
+ const JWKS = createRemoteJWKSet(new URL(jwksUrl));
5
+ const { payload } = await jwtVerify(token, JWKS, {
6
+ audience: expectedAudience
7
+ });
8
+ return payload;
9
+ }
10
+
11
+ export {
12
+ verifySignedPayload
13
+ };
@@ -0,0 +1,287 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/express/index.ts
21
+ var express_exports = {};
22
+ __export(express_exports, {
23
+ createSsoAuthRouter: () => createSsoAuthRouter,
24
+ createSsoSyncRouter: () => createSsoSyncRouter,
25
+ ssoAuthMiddleware: () => ssoAuthMiddleware,
26
+ ssoSyncGuardMiddleware: () => ssoSyncGuardMiddleware
27
+ });
28
+ module.exports = __toCommonJS(express_exports);
29
+
30
+ // src/express/middlewares/ssoAuth.ts
31
+ function ssoAuthMiddleware(options) {
32
+ const cookieName = options.cookieName || "sso_session";
33
+ const isProduction = options.isProduction ?? process.env.NODE_ENV === "production";
34
+ return async (req, res, next) => {
35
+ try {
36
+ let sessionToken = req.cookies?.[cookieName];
37
+ let session = null;
38
+ if (sessionToken) {
39
+ session = await options.ssoClient.validateSessionToken(sessionToken);
40
+ }
41
+ if (!session) {
42
+ const refreshToken = req.cookies?.[`${cookieName}_refresh`];
43
+ if (refreshToken) {
44
+ const newSessionData = await options.ssoClient.refreshAppSession(refreshToken);
45
+ if (newSessionData) {
46
+ const sessionMaxAge = new Date(newSessionData.expiresAt).getTime() - Date.now();
47
+ const refreshMaxAge = newSessionData.refreshExpiresAt ? new Date(newSessionData.refreshExpiresAt).getTime() - Date.now() : 7 * 24 * 60 * 60 * 1e3;
48
+ const sessionCookieOptions = {
49
+ httpOnly: true,
50
+ secure: isProduction,
51
+ sameSite: "lax",
52
+ path: "/",
53
+ maxAge: sessionMaxAge > 0 ? sessionMaxAge : 0,
54
+ ...isProduction && options.cookieDomain ? { domain: options.cookieDomain } : {}
55
+ };
56
+ const refreshCookieOptions = {
57
+ ...sessionCookieOptions,
58
+ maxAge: refreshMaxAge > 0 ? refreshMaxAge : 0
59
+ };
60
+ res.cookie(cookieName, newSessionData.sessionToken, sessionCookieOptions);
61
+ res.cookie(`${cookieName}_refresh`, newSessionData.refreshToken, refreshCookieOptions);
62
+ session = await options.ssoClient.validateSessionToken(newSessionData.sessionToken);
63
+ }
64
+ }
65
+ if (!session) {
66
+ res.clearCookie(cookieName);
67
+ res.clearCookie(`${cookieName}_refresh`);
68
+ res.status(401).json({ error: "Session expired or invalid" });
69
+ return;
70
+ }
71
+ }
72
+ if (options.onSessionValidated) {
73
+ await options.onSessionValidated(session, req);
74
+ }
75
+ req.user = session.user;
76
+ req.tenant = session.tenant;
77
+ req.ssoSession = session;
78
+ next();
79
+ } catch (error) {
80
+ console.error("\u274C [BigsoAuthSDK] Authentication Middleware Error:", error instanceof Error ? error.message : error);
81
+ res.status(500).json({ error: "Internal authentication error" });
82
+ }
83
+ };
84
+ }
85
+
86
+ // src/express/middlewares/ssoSyncGuard.ts
87
+ var import_dns = require("dns");
88
+ function ssoSyncGuardMiddleware(options) {
89
+ const isProduction = options.isProduction ?? process.env.NODE_ENV === "production";
90
+ return async (req, res, next) => {
91
+ try {
92
+ const isSecure = req.secure || req.headers["x-forwarded-proto"] === "https";
93
+ if (!isSecure && isProduction) {
94
+ console.warn("\u26A0\uFE0F [BigsoAuthSDK] Blocked non-HTTPS sync request");
95
+ res.status(403).json({ error: "HTTPS required" });
96
+ return;
97
+ }
98
+ const clientIp = req.ip || req.socket.remoteAddress || "";
99
+ const isLoopback = clientIp === "::1" || clientIp === "127.0.0.1" || clientIp === "::ffff:127.0.0.1";
100
+ if (!isProduction && isLoopback) {
101
+ return next();
102
+ }
103
+ const ssoUrl = new URL(options.ssoBackendUrl);
104
+ const ssoHostname = ssoUrl.hostname;
105
+ const ssoIps = await import_dns.promises.resolve4(ssoHostname).catch(() => []);
106
+ const cleanClientIp = clientIp.replace(/^.*:/, "");
107
+ const isPrivateIp = cleanClientIp.startsWith("10.") || cleanClientIp.startsWith("192.168.") || cleanClientIp.startsWith("172.") && parseInt(cleanClientIp.split(".")[1], 10) >= 16 && parseInt(cleanClientIp.split(".")[1], 10) <= 31;
108
+ if (!ssoIps.includes(cleanClientIp) && !isPrivateIp) {
109
+ console.warn(`\u26D4\uFE0F [BigsoAuthSDK] Blocked sync request from unauthorized IP: ${clientIp}`);
110
+ res.status(403).json({ error: "Unauthorized origin" });
111
+ return;
112
+ }
113
+ next();
114
+ } catch (error) {
115
+ console.error("\u274C [BigsoAuthSDK] Sync Guard Validation Error:", error instanceof Error ? error.message : error);
116
+ res.status(500).json({ error: "Security validation failed" });
117
+ }
118
+ };
119
+ }
120
+
121
+ // src/express/routes/createSsoAuthRouter.ts
122
+ var import_express = require("express");
123
+ function createSsoAuthRouter(options) {
124
+ const router = (0, import_express.Router)();
125
+ const cookieName = options.cookieName || "sso_session";
126
+ const isProduction = options.isProduction ?? process.env.NODE_ENV === "production";
127
+ const getCookieOptions = (customOptions = {}) => {
128
+ const base = {
129
+ httpOnly: true,
130
+ secure: isProduction,
131
+ sameSite: "lax",
132
+ path: "/",
133
+ ...customOptions
134
+ };
135
+ if (isProduction && options.cookieDomain) {
136
+ base.domain = options.cookieDomain;
137
+ }
138
+ return base;
139
+ };
140
+ router.post("/exchange", async (req, res) => {
141
+ try {
142
+ const { code } = req.body;
143
+ if (!code) {
144
+ res.status(400).json({ error: "Authorization code is required" });
145
+ return;
146
+ }
147
+ const ssoResponse = await options.ssoClient.exchangeCodeForToken(code);
148
+ if (!ssoResponse.success) {
149
+ res.status(401).json({ error: "Invalid authorization code" });
150
+ return;
151
+ }
152
+ const sessionMaxAge = new Date(ssoResponse.expiresAt).getTime() - Date.now();
153
+ const refreshMaxAge = ssoResponse.refreshExpiresAt ? new Date(ssoResponse.refreshExpiresAt).getTime() - Date.now() : 7 * 24 * 60 * 60 * 1e3;
154
+ const sessionCookieOptions = getCookieOptions({
155
+ maxAge: sessionMaxAge > 0 ? sessionMaxAge : 0
156
+ });
157
+ const refreshCookieOptions = getCookieOptions({
158
+ maxAge: refreshMaxAge > 0 ? refreshMaxAge : 0
159
+ });
160
+ res.cookie(cookieName, ssoResponse.sessionToken, sessionCookieOptions);
161
+ if (ssoResponse.refreshToken) {
162
+ res.cookie(`${cookieName}_refresh`, ssoResponse.refreshToken, refreshCookieOptions);
163
+ }
164
+ if (options.onLoginSuccess) {
165
+ await options.onLoginSuccess(ssoResponse);
166
+ }
167
+ res.json({
168
+ success: true,
169
+ user: ssoResponse.user,
170
+ tenant: ssoResponse.tenant,
171
+ expiresAt: ssoResponse.expiresAt
172
+ });
173
+ } catch (error) {
174
+ console.error("\u274C [BigsoAuthSDK] Error exchanging code:", error.message);
175
+ res.status(500).json({
176
+ error: error.message || "Failed to exchange authorization code"
177
+ });
178
+ }
179
+ });
180
+ router.post("/exchange-v2", async (req, res) => {
181
+ try {
182
+ const { payload } = req.body;
183
+ if (!payload) {
184
+ res.status(400).json({ error: "Signed payload is required" });
185
+ return;
186
+ }
187
+ const verified = await options.ssoClient.verifySignedPayload(payload, options.frontendUrl);
188
+ if (!verified.code) {
189
+ res.status(400).json({ error: "No authorization code found in payload" });
190
+ return;
191
+ }
192
+ const ssoResponse = await options.ssoClient.exchangeCodeForToken(verified.code);
193
+ if (!ssoResponse.success) {
194
+ res.status(401).json({ error: "Invalid authorization code" });
195
+ return;
196
+ }
197
+ const sessionMaxAge = new Date(ssoResponse.expiresAt).getTime() - Date.now();
198
+ const refreshMaxAge = ssoResponse.refreshExpiresAt ? new Date(ssoResponse.refreshExpiresAt).getTime() - Date.now() : 7 * 24 * 60 * 60 * 1e3;
199
+ const sessionCookieOptions = getCookieOptions({
200
+ maxAge: sessionMaxAge > 0 ? sessionMaxAge : 0
201
+ });
202
+ const refreshCookieOptions = getCookieOptions({
203
+ maxAge: refreshMaxAge > 0 ? refreshMaxAge : 0
204
+ });
205
+ res.cookie(cookieName, ssoResponse.sessionToken, sessionCookieOptions);
206
+ if (ssoResponse.refreshToken) {
207
+ res.cookie(`${cookieName}_refresh`, ssoResponse.refreshToken, refreshCookieOptions);
208
+ }
209
+ if (options.onLoginSuccess) {
210
+ await options.onLoginSuccess(ssoResponse);
211
+ }
212
+ res.json({
213
+ success: true,
214
+ user: ssoResponse.user,
215
+ tenant: ssoResponse.tenant,
216
+ expiresAt: ssoResponse.expiresAt
217
+ });
218
+ } catch (error) {
219
+ console.error("\u274C [BigsoAuthSDK] Error exchanging v2 payload:", error.message);
220
+ res.status(401).json({
221
+ error: error.message || "Failed to verify signed payload"
222
+ });
223
+ }
224
+ });
225
+ router.get("/session", ssoAuthMiddleware(options), (req, res) => {
226
+ res.set("Cache-Control", "no-store, no-cache, must-revalidate, private");
227
+ res.set("Pragma", "no-cache");
228
+ res.set("Expires", "0");
229
+ res.json({
230
+ success: true,
231
+ user: req.user,
232
+ tenant: req.tenant,
233
+ expiresAt: req.ssoSession?.expiresAt
234
+ });
235
+ });
236
+ router.post("/logout", async (req, res) => {
237
+ const sessionToken = req.cookies?.[cookieName];
238
+ if (sessionToken) {
239
+ try {
240
+ await options.ssoClient.revokeSession(sessionToken);
241
+ } catch (error) {
242
+ console.warn("\u26A0\uFE0F [BigsoAuthSDK] Failed to revoke session in SSO Backend. Clearing local anyway.", error.message);
243
+ }
244
+ }
245
+ const cookieOptions = getCookieOptions({ maxAge: 0 });
246
+ res.clearCookie(cookieName, cookieOptions);
247
+ res.clearCookie(`${cookieName}_refresh`, cookieOptions);
248
+ if (options.onLogout && sessionToken) {
249
+ await options.onLogout(sessionToken);
250
+ }
251
+ res.json({ success: true, message: "Logged out" });
252
+ });
253
+ return router;
254
+ }
255
+
256
+ // src/express/routes/createSsoSyncRouter.ts
257
+ var import_express2 = require("express");
258
+ function createSsoSyncRouter(options) {
259
+ const router = (0, import_express2.Router)();
260
+ router.get("/resources", ssoSyncGuardMiddleware({
261
+ ssoBackendUrl: options.ssoBackendUrl,
262
+ isProduction: options.isProduction
263
+ }), (req, res) => {
264
+ try {
265
+ res.json({
266
+ success: true,
267
+ resources: options.resources,
268
+ meta: {
269
+ appId: options.appId,
270
+ count: options.resources.length,
271
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
272
+ }
273
+ });
274
+ } catch (error) {
275
+ console.error("\u274C [BigsoAuthSDK] Error in sync endpoint:", error.message);
276
+ res.status(500).json({ error: error.message });
277
+ }
278
+ });
279
+ return router;
280
+ }
281
+ // Annotate the CommonJS export names for ESM import in node:
282
+ 0 && (module.exports = {
283
+ createSsoAuthRouter,
284
+ createSsoSyncRouter,
285
+ ssoAuthMiddleware,
286
+ ssoSyncGuardMiddleware
287
+ });
@@ -0,0 +1,48 @@
1
+ import { Request, Response, NextFunction, Router } from 'express';
2
+ import { BigsoSsoClient } from '../node/index.cjs';
3
+ import { S as SsoSessionData } from '../types-CoXgtTry.cjs';
4
+
5
+ interface SsoAuthMiddlewareOptions {
6
+ ssoClient: BigsoSsoClient;
7
+ cookieName?: string;
8
+ cookieDomain?: string;
9
+ isProduction?: boolean;
10
+ onSessionValidated?: (session: SsoSessionData, req: Request) => Promise<void> | void;
11
+ }
12
+ declare global {
13
+ namespace Express {
14
+ interface Request {
15
+ user?: SsoSessionData['user'];
16
+ tenant?: SsoSessionData['tenant'];
17
+ ssoSession?: SsoSessionData;
18
+ }
19
+ }
20
+ }
21
+ declare function ssoAuthMiddleware(options: SsoAuthMiddlewareOptions): (req: Request, res: Response, next: NextFunction) => Promise<void>;
22
+
23
+ interface SsoSyncGuardOptions {
24
+ ssoBackendUrl: string;
25
+ isProduction?: boolean;
26
+ }
27
+ declare function ssoSyncGuardMiddleware(options: SsoSyncGuardOptions): (req: Request, res: Response, next: NextFunction) => Promise<void>;
28
+
29
+ interface CreateSsoAuthRouterOptions {
30
+ ssoClient: BigsoSsoClient;
31
+ frontendUrl: string;
32
+ cookieName?: string;
33
+ cookieDomain?: string;
34
+ isProduction?: boolean;
35
+ onLoginSuccess?: (session: SsoSessionData) => void | Promise<void>;
36
+ onLogout?: (sessionToken: string) => void | Promise<void>;
37
+ }
38
+ declare function createSsoAuthRouter(options: CreateSsoAuthRouterOptions): Router;
39
+
40
+ interface SsoSyncRouterOptions {
41
+ resources: any[];
42
+ appId: string;
43
+ ssoBackendUrl: string;
44
+ isProduction?: boolean;
45
+ }
46
+ declare function createSsoSyncRouter(options: SsoSyncRouterOptions): Router;
47
+
48
+ export { type CreateSsoAuthRouterOptions, type SsoAuthMiddlewareOptions, type SsoSyncGuardOptions, type SsoSyncRouterOptions, createSsoAuthRouter, createSsoSyncRouter, ssoAuthMiddleware, ssoSyncGuardMiddleware };
@@ -0,0 +1,48 @@
1
+ import { Request, Response, NextFunction, Router } from 'express';
2
+ import { BigsoSsoClient } from '../node/index.js';
3
+ import { S as SsoSessionData } from '../types-CoXgtTry.js';
4
+
5
+ interface SsoAuthMiddlewareOptions {
6
+ ssoClient: BigsoSsoClient;
7
+ cookieName?: string;
8
+ cookieDomain?: string;
9
+ isProduction?: boolean;
10
+ onSessionValidated?: (session: SsoSessionData, req: Request) => Promise<void> | void;
11
+ }
12
+ declare global {
13
+ namespace Express {
14
+ interface Request {
15
+ user?: SsoSessionData['user'];
16
+ tenant?: SsoSessionData['tenant'];
17
+ ssoSession?: SsoSessionData;
18
+ }
19
+ }
20
+ }
21
+ declare function ssoAuthMiddleware(options: SsoAuthMiddlewareOptions): (req: Request, res: Response, next: NextFunction) => Promise<void>;
22
+
23
+ interface SsoSyncGuardOptions {
24
+ ssoBackendUrl: string;
25
+ isProduction?: boolean;
26
+ }
27
+ declare function ssoSyncGuardMiddleware(options: SsoSyncGuardOptions): (req: Request, res: Response, next: NextFunction) => Promise<void>;
28
+
29
+ interface CreateSsoAuthRouterOptions {
30
+ ssoClient: BigsoSsoClient;
31
+ frontendUrl: string;
32
+ cookieName?: string;
33
+ cookieDomain?: string;
34
+ isProduction?: boolean;
35
+ onLoginSuccess?: (session: SsoSessionData) => void | Promise<void>;
36
+ onLogout?: (sessionToken: string) => void | Promise<void>;
37
+ }
38
+ declare function createSsoAuthRouter(options: CreateSsoAuthRouterOptions): Router;
39
+
40
+ interface SsoSyncRouterOptions {
41
+ resources: any[];
42
+ appId: string;
43
+ ssoBackendUrl: string;
44
+ isProduction?: boolean;
45
+ }
46
+ declare function createSsoSyncRouter(options: SsoSyncRouterOptions): Router;
47
+
48
+ export { type CreateSsoAuthRouterOptions, type SsoAuthMiddlewareOptions, type SsoSyncGuardOptions, type SsoSyncRouterOptions, createSsoAuthRouter, createSsoSyncRouter, ssoAuthMiddleware, ssoSyncGuardMiddleware };