@bigso/auth-sdk 0.5.6 → 0.5.8

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,4 +1,4 @@
1
- import { B as BigsoAuthOptions, a as BigsoAuthResult } from '../types-B51l8wWh.cjs';
1
+ import { B as BigsoAuthOptions, a as BigsoAuthResult } from '../types-sI7dMCGy.cjs';
2
2
 
3
3
  declare class EventEmitter {
4
4
  private events;
@@ -1,4 +1,4 @@
1
- import { B as BigsoAuthOptions, a as BigsoAuthResult } from '../types-B51l8wWh.js';
1
+ import { B as BigsoAuthOptions, a as BigsoAuthResult } from '../types-sI7dMCGy.js';
2
2
 
3
3
  declare class EventEmitter {
4
4
  private events;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  verifySignedPayload
3
- } from "../chunk-PB3GVAEJ.js";
3
+ } from "../chunk-BXRGCGYR.js";
4
4
 
5
5
  // src/utils/crypto.ts
6
6
  async function sha256Base64Url(input) {
@@ -0,0 +1,34 @@
1
+ // src/utils/jws.ts
2
+ import { createRemoteJWKSet, jwtVerify } 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
+ async function verifyAccessToken(accessToken, jwksUrl) {
11
+ const JWKS = createRemoteJWKSet(new URL(jwksUrl));
12
+ const { payload } = await jwtVerify(accessToken, JWKS);
13
+ if (!payload.sub || !payload.jti) {
14
+ throw new Error("Invalid token structure: missing sub or jti");
15
+ }
16
+ return {
17
+ sub: payload.sub,
18
+ jti: payload.jti,
19
+ iss: payload.iss,
20
+ aud: payload.aud || "",
21
+ exp: payload.exp,
22
+ iat: payload.iat,
23
+ tenants: payload.tenants || [],
24
+ tenantId: payload.tenantId || "",
25
+ systemRole: payload.systemRole || "user",
26
+ scope: payload.scope,
27
+ deviceFingerprint: payload.deviceFingerprint
28
+ };
29
+ }
30
+
31
+ export {
32
+ verifySignedPayload,
33
+ verifyAccessToken
34
+ };
@@ -42,15 +42,6 @@ function ssoAuthMiddleware(options) {
42
42
  res.status(401).json({ error: "Invalid or expired access token" });
43
43
  return;
44
44
  }
45
- const selectedTenantId = payload.tenantId;
46
- const tenantInfo = payload.tenants.find((t) => t.id === selectedTenantId);
47
- req.user = {
48
- userId: payload.sub,
49
- email: "",
50
- firstName: "",
51
- lastName: ""
52
- };
53
- req.tenant = tenantInfo;
54
45
  req.tokenPayload = payload;
55
46
  next();
56
47
  } catch (error) {
@@ -97,30 +88,38 @@ function ssoSyncGuardMiddleware(options) {
97
88
 
98
89
  // src/express/routes/createSsoAuthRouter.ts
99
90
  var import_express = require("express");
91
+ function validateRequiredEnvs() {
92
+ const requiredEnvs = ["COOKIE_DOMAIN", "COOKIE_SAMESITE"];
93
+ const missingEnvs = requiredEnvs.filter((env) => !process.env[env]);
94
+ if (missingEnvs.length > 0) {
95
+ throw new Error(`Missing required environment variables: ${missingEnvs.join(", ")}`);
96
+ }
97
+ }
98
+ function extractCookieValueFromMap(cookieMapStr, key) {
99
+ if (!cookieMapStr) return null;
100
+ try {
101
+ const cookieMap = JSON.parse(cookieMapStr);
102
+ const entry = cookieMap.find((item) => item.startsWith(`${key}:`));
103
+ return entry ? entry.split(":")[1] : null;
104
+ } catch (error) {
105
+ console.warn("[BigsoAuthSDK] Failed to parse cookie name map:", error);
106
+ return null;
107
+ }
108
+ }
109
+ function extractCookieNameFromMap(cookieMapStr, key) {
110
+ if (!cookieMapStr) return null;
111
+ try {
112
+ const cookieMap = JSON.parse(cookieMapStr);
113
+ const entry = cookieMap.find((item) => item.startsWith(`${key}:`));
114
+ return entry ? entry.split(":")[0] : null;
115
+ } catch (error) {
116
+ console.warn("[BigsoAuthSDK] Failed to parse cookie name map:", error);
117
+ return null;
118
+ }
119
+ }
100
120
  function createSsoAuthRouter(options) {
121
+ validateRequiredEnvs();
101
122
  const router = (0, import_express.Router)();
102
- router.post("/exchange", async (req, res) => {
103
- try {
104
- const { code, codeVerifier } = req.body;
105
- if (!code || !codeVerifier) {
106
- res.status(400).json({ error: "code and codeVerifier are required" });
107
- return;
108
- }
109
- const ssoResponse = await options.ssoClient.exchangeCode(code, codeVerifier);
110
- if (options.onLoginSuccess) {
111
- await options.onLoginSuccess(ssoResponse);
112
- }
113
- res.json({
114
- success: true,
115
- tokens: ssoResponse.tokens,
116
- user: ssoResponse.user,
117
- tenant: ssoResponse.tenant
118
- });
119
- } catch (error) {
120
- console.error("[BigsoAuthSDK] Error exchanging code:", error.message);
121
- res.status(401).json({ error: error.message || "Failed to exchange authorization code" });
122
- }
123
- });
124
123
  router.post("/exchange-v2", async (req, res) => {
125
124
  try {
126
125
  const { payload, codeVerifier: codeVerifierFromBody } = req.body;
@@ -146,33 +145,55 @@ function createSsoAuthRouter(options) {
146
145
  success: true,
147
146
  tokens: ssoResponse.tokens,
148
147
  user: ssoResponse.user,
149
- tenant: ssoResponse.tenant
148
+ currentTenant: ssoResponse.currentTenant,
149
+ relatedTenants: ssoResponse.relatedTenants
150
150
  });
151
151
  } catch (error) {
152
152
  console.error("[BigsoAuthSDK] Error exchanging v2 payload:", error.message);
153
153
  res.status(401).json({ error: error.message || "Failed to verify signed payload" });
154
154
  }
155
155
  });
156
- router.get("/session", ssoAuthMiddleware({ ssoClient: options.ssoClient }), (req, res) => {
156
+ router.post("/session", ssoAuthMiddleware({ ssoClient: options.ssoClient }), async (req, res) => {
157
157
  res.set("Cache-Control", "no-store, no-cache, must-revalidate, private");
158
158
  res.set("Pragma", "no-cache");
159
159
  res.set("Expires", "0");
160
+ const sessionId = extractCookieValueFromMap(req.cookies?.["bs_cookie_name_map"], "sessionId");
161
+ const ssoSession = await options.ssoClient.session(req.headers.authorization?.substring(7), sessionId, req.tokenPayload?.appId);
160
162
  res.json({
161
163
  success: true,
162
- user: req.user,
163
- tenant: req.tenant,
164
+ ...ssoSession,
164
165
  tokenPayload: req.tokenPayload
165
166
  });
166
167
  });
167
168
  router.post("/refresh", async (req, res) => {
169
+ const refreshTokenCookieName = extractCookieNameFromMap(req.cookies?.["bs_cookie_name_map"], "refreshToken");
168
170
  try {
169
- const ssoResponse = await options.ssoClient.refreshTokens();
171
+ const refreshToken = extractCookieValueFromMap(req.cookies?.["bs_cookie_name_map"], "refreshToken");
172
+ const ssoResponse = await options.ssoClient.refreshTokens(refreshToken);
173
+ if (ssoResponse.tokens?.refreshToken) {
174
+ res.cookie(refreshTokenCookieName, ssoResponse.tokens.refreshToken, {
175
+ httpOnly: true,
176
+ secure: process.env.NODE_ENV === "production",
177
+ sameSite: process.env.COOKIE_SAMESITE,
178
+ path: "/api/auth/refresh",
179
+ maxAge: 7 * 24 * 60 * 60 * 1e3,
180
+ domain: process.env.COOKIE_DOMAIN
181
+ });
182
+ } else {
183
+ console.warn("[BigsoAuthSDK] No refresh token received in refresh response, not setting cookie");
184
+ }
170
185
  res.json({
171
186
  success: true,
172
187
  tokens: ssoResponse.tokens
173
188
  });
174
189
  } catch (error) {
175
190
  console.error("[BigsoAuthSDK] Error refreshing tokens:", error.message);
191
+ if (error.message?.includes("revoked") || error.message?.includes("expired") || error.message?.includes("Invalid")) {
192
+ res.clearCookie(refreshTokenCookieName, {
193
+ path: "/api/auth/refresh",
194
+ domain: process.env.COOKIE_DOMAIN
195
+ });
196
+ }
176
197
  res.status(401).json({ error: error.message || "Failed to refresh tokens" });
177
198
  }
178
199
  });
@@ -184,9 +205,17 @@ function createSsoAuthRouter(options) {
184
205
  if (options.onLogout) {
185
206
  await options.onLogout(accessToken);
186
207
  }
208
+ res.clearCookie(process.env.REFRESH_COOKIE_NAME, {
209
+ path: "/api/auth/refresh",
210
+ domain: process.env.COOKIE_DOMAIN
211
+ });
187
212
  res.json({ success: true, message: "Logged out" });
188
213
  } catch (error) {
189
214
  console.warn("[BigsoAuthSDK] Failed to logout in SSO Backend.", error.message);
215
+ res.clearCookie(process.env.REFRESH_COOKIE_NAME, {
216
+ path: "/api/auth/refresh",
217
+ domain: process.env.COOKIE_DOMAIN
218
+ });
190
219
  res.json({ success: true, message: "Logged out (backend revocation failed)" });
191
220
  }
192
221
  });
@@ -1,6 +1,6 @@
1
1
  import { Request, Response, NextFunction, Router } from 'express';
2
2
  import { BigsoSsoClient } from '../node/index.cjs';
3
- import { S as SsoJwtTenant, b as SsoTokenPayload, V as V2ExchangeResponse } from '../types-B51l8wWh.cjs';
3
+ import { S as SsoJwtTenant, b as SsoTokenPayload, V as V2ExchangeResponse } from '../types-sI7dMCGy.cjs';
4
4
 
5
5
  interface SsoAuthMiddlewareOptions {
6
6
  ssoClient: BigsoSsoClient;
@@ -1,6 +1,6 @@
1
1
  import { Request, Response, NextFunction, Router } from 'express';
2
2
  import { BigsoSsoClient } from '../node/index.js';
3
- import { S as SsoJwtTenant, b as SsoTokenPayload, V as V2ExchangeResponse } from '../types-B51l8wWh.js';
3
+ import { S as SsoJwtTenant, b as SsoTokenPayload, V as V2ExchangeResponse } from '../types-sI7dMCGy.js';
4
4
 
5
5
  interface SsoAuthMiddlewareOptions {
6
6
  ssoClient: BigsoSsoClient;
@@ -13,15 +13,6 @@ function ssoAuthMiddleware(options) {
13
13
  res.status(401).json({ error: "Invalid or expired access token" });
14
14
  return;
15
15
  }
16
- const selectedTenantId = payload.tenantId;
17
- const tenantInfo = payload.tenants.find((t) => t.id === selectedTenantId);
18
- req.user = {
19
- userId: payload.sub,
20
- email: "",
21
- firstName: "",
22
- lastName: ""
23
- };
24
- req.tenant = tenantInfo;
25
16
  req.tokenPayload = payload;
26
17
  next();
27
18
  } catch (error) {
@@ -68,30 +59,38 @@ function ssoSyncGuardMiddleware(options) {
68
59
 
69
60
  // src/express/routes/createSsoAuthRouter.ts
70
61
  import { Router } from "express";
62
+ function validateRequiredEnvs() {
63
+ const requiredEnvs = ["COOKIE_DOMAIN", "COOKIE_SAMESITE"];
64
+ const missingEnvs = requiredEnvs.filter((env) => !process.env[env]);
65
+ if (missingEnvs.length > 0) {
66
+ throw new Error(`Missing required environment variables: ${missingEnvs.join(", ")}`);
67
+ }
68
+ }
69
+ function extractCookieValueFromMap(cookieMapStr, key) {
70
+ if (!cookieMapStr) return null;
71
+ try {
72
+ const cookieMap = JSON.parse(cookieMapStr);
73
+ const entry = cookieMap.find((item) => item.startsWith(`${key}:`));
74
+ return entry ? entry.split(":")[1] : null;
75
+ } catch (error) {
76
+ console.warn("[BigsoAuthSDK] Failed to parse cookie name map:", error);
77
+ return null;
78
+ }
79
+ }
80
+ function extractCookieNameFromMap(cookieMapStr, key) {
81
+ if (!cookieMapStr) return null;
82
+ try {
83
+ const cookieMap = JSON.parse(cookieMapStr);
84
+ const entry = cookieMap.find((item) => item.startsWith(`${key}:`));
85
+ return entry ? entry.split(":")[0] : null;
86
+ } catch (error) {
87
+ console.warn("[BigsoAuthSDK] Failed to parse cookie name map:", error);
88
+ return null;
89
+ }
90
+ }
71
91
  function createSsoAuthRouter(options) {
92
+ validateRequiredEnvs();
72
93
  const router = Router();
73
- router.post("/exchange", async (req, res) => {
74
- try {
75
- const { code, codeVerifier } = req.body;
76
- if (!code || !codeVerifier) {
77
- res.status(400).json({ error: "code and codeVerifier are required" });
78
- return;
79
- }
80
- const ssoResponse = await options.ssoClient.exchangeCode(code, codeVerifier);
81
- if (options.onLoginSuccess) {
82
- await options.onLoginSuccess(ssoResponse);
83
- }
84
- res.json({
85
- success: true,
86
- tokens: ssoResponse.tokens,
87
- user: ssoResponse.user,
88
- tenant: ssoResponse.tenant
89
- });
90
- } catch (error) {
91
- console.error("[BigsoAuthSDK] Error exchanging code:", error.message);
92
- res.status(401).json({ error: error.message || "Failed to exchange authorization code" });
93
- }
94
- });
95
94
  router.post("/exchange-v2", async (req, res) => {
96
95
  try {
97
96
  const { payload, codeVerifier: codeVerifierFromBody } = req.body;
@@ -117,33 +116,55 @@ function createSsoAuthRouter(options) {
117
116
  success: true,
118
117
  tokens: ssoResponse.tokens,
119
118
  user: ssoResponse.user,
120
- tenant: ssoResponse.tenant
119
+ currentTenant: ssoResponse.currentTenant,
120
+ relatedTenants: ssoResponse.relatedTenants
121
121
  });
122
122
  } catch (error) {
123
123
  console.error("[BigsoAuthSDK] Error exchanging v2 payload:", error.message);
124
124
  res.status(401).json({ error: error.message || "Failed to verify signed payload" });
125
125
  }
126
126
  });
127
- router.get("/session", ssoAuthMiddleware({ ssoClient: options.ssoClient }), (req, res) => {
127
+ router.post("/session", ssoAuthMiddleware({ ssoClient: options.ssoClient }), async (req, res) => {
128
128
  res.set("Cache-Control", "no-store, no-cache, must-revalidate, private");
129
129
  res.set("Pragma", "no-cache");
130
130
  res.set("Expires", "0");
131
+ const sessionId = extractCookieValueFromMap(req.cookies?.["bs_cookie_name_map"], "sessionId");
132
+ const ssoSession = await options.ssoClient.session(req.headers.authorization?.substring(7), sessionId, req.tokenPayload?.appId);
131
133
  res.json({
132
134
  success: true,
133
- user: req.user,
134
- tenant: req.tenant,
135
+ ...ssoSession,
135
136
  tokenPayload: req.tokenPayload
136
137
  });
137
138
  });
138
139
  router.post("/refresh", async (req, res) => {
140
+ const refreshTokenCookieName = extractCookieNameFromMap(req.cookies?.["bs_cookie_name_map"], "refreshToken");
139
141
  try {
140
- const ssoResponse = await options.ssoClient.refreshTokens();
142
+ const refreshToken = extractCookieValueFromMap(req.cookies?.["bs_cookie_name_map"], "refreshToken");
143
+ const ssoResponse = await options.ssoClient.refreshTokens(refreshToken);
144
+ if (ssoResponse.tokens?.refreshToken) {
145
+ res.cookie(refreshTokenCookieName, ssoResponse.tokens.refreshToken, {
146
+ httpOnly: true,
147
+ secure: process.env.NODE_ENV === "production",
148
+ sameSite: process.env.COOKIE_SAMESITE,
149
+ path: "/api/auth/refresh",
150
+ maxAge: 7 * 24 * 60 * 60 * 1e3,
151
+ domain: process.env.COOKIE_DOMAIN
152
+ });
153
+ } else {
154
+ console.warn("[BigsoAuthSDK] No refresh token received in refresh response, not setting cookie");
155
+ }
141
156
  res.json({
142
157
  success: true,
143
158
  tokens: ssoResponse.tokens
144
159
  });
145
160
  } catch (error) {
146
161
  console.error("[BigsoAuthSDK] Error refreshing tokens:", error.message);
162
+ if (error.message?.includes("revoked") || error.message?.includes("expired") || error.message?.includes("Invalid")) {
163
+ res.clearCookie(refreshTokenCookieName, {
164
+ path: "/api/auth/refresh",
165
+ domain: process.env.COOKIE_DOMAIN
166
+ });
167
+ }
147
168
  res.status(401).json({ error: error.message || "Failed to refresh tokens" });
148
169
  }
149
170
  });
@@ -155,9 +176,17 @@ function createSsoAuthRouter(options) {
155
176
  if (options.onLogout) {
156
177
  await options.onLogout(accessToken);
157
178
  }
179
+ res.clearCookie(process.env.REFRESH_COOKIE_NAME, {
180
+ path: "/api/auth/refresh",
181
+ domain: process.env.COOKIE_DOMAIN
182
+ });
158
183
  res.json({ success: true, message: "Logged out" });
159
184
  } catch (error) {
160
185
  console.warn("[BigsoAuthSDK] Failed to logout in SSO Backend.", error.message);
186
+ res.clearCookie(process.env.REFRESH_COOKIE_NAME, {
187
+ path: "/api/auth/refresh",
188
+ domain: process.env.COOKIE_DOMAIN
189
+ });
161
190
  res.json({ success: true, message: "Logged out (backend revocation failed)" });
162
191
  }
163
192
  });
@@ -47,6 +47,7 @@ async function verifyAccessToken(accessToken, jwksUrl) {
47
47
  exp: payload.exp,
48
48
  iat: payload.iat,
49
49
  tenants: payload.tenants || [],
50
+ tenantId: payload.tenantId || "",
50
51
  systemRole: payload.systemRole || "user",
51
52
  scope: payload.scope,
52
53
  deviceFingerprint: payload.deviceFingerprint
@@ -138,6 +139,21 @@ var BigsoSsoClient = class {
138
139
  throw new Error(err.message || "Logout failed");
139
140
  }
140
141
  }
142
+ async session(accessToken, sessionId, appId) {
143
+ const response = await fetch(`${this.ssoBackendUrl}/api/v2/auth/session`, {
144
+ method: "POST",
145
+ headers: {
146
+ "Content-Type": "application/json",
147
+ "Authorization": `Bearer ${accessToken}`
148
+ },
149
+ body: JSON.stringify({ sessionId, appId }),
150
+ credentials: "include"
151
+ });
152
+ if (!response.ok) {
153
+ const err = await response.json().catch(() => ({}));
154
+ throw new Error(err.message || "Session validate failed");
155
+ }
156
+ }
141
157
  };
142
158
  // Annotate the CommonJS export names for ESM import in node:
143
159
  0 && (module.exports = {
@@ -1,4 +1,4 @@
1
- import { b as SsoTokenPayload, c as V2LoginResponse, V as V2ExchangeResponse, d as V2RefreshResponse } from '../types-B51l8wWh.cjs';
1
+ import { b as SsoTokenPayload, c as V2LoginResponse, V as V2ExchangeResponse, d as V2RefreshResponse } from '../types-sI7dMCGy.cjs';
2
2
 
3
3
  interface SsoClientOptions {
4
4
  ssoBackendUrl: string;
@@ -16,6 +16,7 @@ declare class BigsoSsoClient {
16
16
  exchangeCode(code: string, codeVerifier: string): Promise<V2ExchangeResponse>;
17
17
  refreshTokens(refreshToken?: string): Promise<V2RefreshResponse>;
18
18
  logout(accessToken: string, revokeAll?: boolean): Promise<void>;
19
+ session(accessToken: string, sessionId: string, appId: string): Promise<any>;
19
20
  }
20
21
 
21
22
  export { BigsoSsoClient, type SsoClientOptions };
@@ -1,4 +1,4 @@
1
- import { b as SsoTokenPayload, c as V2LoginResponse, V as V2ExchangeResponse, d as V2RefreshResponse } from '../types-B51l8wWh.js';
1
+ import { b as SsoTokenPayload, c as V2LoginResponse, V as V2ExchangeResponse, d as V2RefreshResponse } from '../types-sI7dMCGy.js';
2
2
 
3
3
  interface SsoClientOptions {
4
4
  ssoBackendUrl: string;
@@ -16,6 +16,7 @@ declare class BigsoSsoClient {
16
16
  exchangeCode(code: string, codeVerifier: string): Promise<V2ExchangeResponse>;
17
17
  refreshTokens(refreshToken?: string): Promise<V2RefreshResponse>;
18
18
  logout(accessToken: string, revokeAll?: boolean): Promise<void>;
19
+ session(accessToken: string, sessionId: string, appId: string): Promise<any>;
19
20
  }
20
21
 
21
22
  export { BigsoSsoClient, type SsoClientOptions };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  verifyAccessToken,
3
3
  verifySignedPayload
4
- } from "../chunk-PB3GVAEJ.js";
4
+ } from "../chunk-BXRGCGYR.js";
5
5
 
6
6
  // src/node/SsoClient.ts
7
7
  var BigsoSsoClient = class {
@@ -88,6 +88,21 @@ var BigsoSsoClient = class {
88
88
  throw new Error(err.message || "Logout failed");
89
89
  }
90
90
  }
91
+ async session(accessToken, sessionId, appId) {
92
+ const response = await fetch(`${this.ssoBackendUrl}/api/v2/auth/session`, {
93
+ method: "POST",
94
+ headers: {
95
+ "Content-Type": "application/json",
96
+ "Authorization": `Bearer ${accessToken}`
97
+ },
98
+ body: JSON.stringify({ sessionId, appId }),
99
+ credentials: "include"
100
+ });
101
+ if (!response.ok) {
102
+ const err = await response.json().catch(() => ({}));
103
+ throw new Error(err.message || "Session validate failed");
104
+ }
105
+ }
91
106
  };
92
107
  export {
93
108
  BigsoSsoClient
@@ -0,0 +1,87 @@
1
+ interface BigsoAuthOptions {
2
+ clientId: string;
3
+ ssoOrigin: string;
4
+ jwksUrl: string;
5
+ timeout?: number;
6
+ debug?: boolean;
7
+ redirectUri?: string;
8
+ tenantHint?: string;
9
+ theme?: 'light' | 'dark';
10
+ }
11
+ interface SsoUser {
12
+ userId: string;
13
+ email: string;
14
+ firstName: string;
15
+ lastName: string;
16
+ }
17
+ interface SsoTenant {
18
+ id: string;
19
+ name: string;
20
+ slug: string;
21
+ role: string;
22
+ permissions: Array<{
23
+ resource: string;
24
+ action: string;
25
+ }>;
26
+ }
27
+ interface SsoJwtTenant {
28
+ id: string;
29
+ name: string;
30
+ slug: string;
31
+ role: string;
32
+ apps: string[];
33
+ }
34
+ interface SsoTokenPayload {
35
+ sub: string;
36
+ jti: string;
37
+ iss: string;
38
+ aud: string;
39
+ exp: number;
40
+ iat: number;
41
+ tenantId: string;
42
+ AppId: string;
43
+ systemRole: string;
44
+ scope: string[];
45
+ }
46
+ interface V2LoginResponse {
47
+ success: boolean;
48
+ tokens: {
49
+ accessToken: string;
50
+ expiresIn: number;
51
+ };
52
+ user: SsoUser;
53
+ }
54
+ interface V2ExchangeResponse {
55
+ success: boolean;
56
+ tokens: {
57
+ accessToken: string;
58
+ refreshToken: string;
59
+ expiresIn: number;
60
+ };
61
+ user: SsoUser;
62
+ currentTenant: SsoTenant;
63
+ relatedTenants: SsoTenant[];
64
+ }
65
+ interface V2RefreshResponse {
66
+ success: boolean;
67
+ tokens: {
68
+ accessToken: string;
69
+ expiresIn: number;
70
+ refreshToken?: string;
71
+ };
72
+ }
73
+ interface BigsoAuthResult {
74
+ code: string;
75
+ state: string;
76
+ nonce: string;
77
+ codeVerifier: string;
78
+ signed_payload: string;
79
+ tenant?: SsoTenant;
80
+ jti?: string;
81
+ iss?: string;
82
+ aud?: string;
83
+ exp?: number;
84
+ iat?: number;
85
+ }
86
+
87
+ export type { BigsoAuthOptions as B, SsoJwtTenant as S, V2ExchangeResponse as V, BigsoAuthResult as a, SsoTokenPayload as b, V2LoginResponse as c, V2RefreshResponse as d };
@@ -0,0 +1,87 @@
1
+ interface BigsoAuthOptions {
2
+ clientId: string;
3
+ ssoOrigin: string;
4
+ jwksUrl: string;
5
+ timeout?: number;
6
+ debug?: boolean;
7
+ redirectUri?: string;
8
+ tenantHint?: string;
9
+ theme?: 'light' | 'dark';
10
+ }
11
+ interface SsoUser {
12
+ userId: string;
13
+ email: string;
14
+ firstName: string;
15
+ lastName: string;
16
+ }
17
+ interface SsoTenant {
18
+ id: string;
19
+ name: string;
20
+ slug: string;
21
+ role: string;
22
+ permissions: Array<{
23
+ resource: string;
24
+ action: string;
25
+ }>;
26
+ }
27
+ interface SsoJwtTenant {
28
+ id: string;
29
+ name: string;
30
+ slug: string;
31
+ role: string;
32
+ apps: string[];
33
+ }
34
+ interface SsoTokenPayload {
35
+ sub: string;
36
+ jti: string;
37
+ iss: string;
38
+ aud: string;
39
+ exp: number;
40
+ iat: number;
41
+ tenantId: string;
42
+ AppId: string;
43
+ systemRole: string;
44
+ scope: string[];
45
+ }
46
+ interface V2LoginResponse {
47
+ success: boolean;
48
+ tokens: {
49
+ accessToken: string;
50
+ expiresIn: number;
51
+ };
52
+ user: SsoUser;
53
+ }
54
+ interface V2ExchangeResponse {
55
+ success: boolean;
56
+ tokens: {
57
+ accessToken: string;
58
+ refreshToken: string;
59
+ expiresIn: number;
60
+ };
61
+ user: SsoUser;
62
+ currentTenant: SsoTenant;
63
+ relatedTenants: SsoTenant[];
64
+ }
65
+ interface V2RefreshResponse {
66
+ success: boolean;
67
+ tokens: {
68
+ accessToken: string;
69
+ expiresIn: number;
70
+ refreshToken?: string;
71
+ };
72
+ }
73
+ interface BigsoAuthResult {
74
+ code: string;
75
+ state: string;
76
+ nonce: string;
77
+ codeVerifier: string;
78
+ signed_payload: string;
79
+ tenant?: SsoTenant;
80
+ jti?: string;
81
+ iss?: string;
82
+ aud?: string;
83
+ exp?: number;
84
+ iat?: number;
85
+ }
86
+
87
+ export type { BigsoAuthOptions as B, SsoJwtTenant as S, V2ExchangeResponse as V, BigsoAuthResult as a, SsoTokenPayload as b, V2LoginResponse as c, V2RefreshResponse as d };
@@ -0,0 +1,87 @@
1
+ interface BigsoAuthOptions {
2
+ clientId: string;
3
+ ssoOrigin: string;
4
+ jwksUrl: string;
5
+ timeout?: number;
6
+ debug?: boolean;
7
+ redirectUri?: string;
8
+ tenantHint?: string;
9
+ theme?: 'light' | 'dark';
10
+ }
11
+ interface SsoUser {
12
+ userId: string;
13
+ email: string;
14
+ firstName: string;
15
+ lastName: string;
16
+ }
17
+ interface SsoTenant {
18
+ id: string;
19
+ name: string;
20
+ slug: string;
21
+ role: string;
22
+ permissions: Array<{
23
+ resource: string;
24
+ action: string;
25
+ }>;
26
+ }
27
+ interface SsoJwtTenant {
28
+ id: string;
29
+ name: string;
30
+ slug: string;
31
+ role: string;
32
+ apps: string[];
33
+ }
34
+ interface SsoTokenPayload {
35
+ sub: string;
36
+ jti: string;
37
+ iss: string;
38
+ aud: string;
39
+ exp: number;
40
+ iat: number;
41
+ tenantId: string;
42
+ appId: string;
43
+ systemRole: string;
44
+ scope: string[];
45
+ }
46
+ interface V2LoginResponse {
47
+ success: boolean;
48
+ tokens: {
49
+ accessToken: string;
50
+ expiresIn: number;
51
+ };
52
+ user: SsoUser;
53
+ }
54
+ interface V2ExchangeResponse {
55
+ success: boolean;
56
+ tokens: {
57
+ accessToken: string;
58
+ refreshToken: string;
59
+ expiresIn: number;
60
+ };
61
+ user: SsoUser;
62
+ currentTenant: SsoTenant;
63
+ relatedTenants: SsoTenant[];
64
+ }
65
+ interface V2RefreshResponse {
66
+ success: boolean;
67
+ tokens: {
68
+ accessToken: string;
69
+ expiresIn: number;
70
+ refreshToken?: string;
71
+ };
72
+ }
73
+ interface BigsoAuthResult {
74
+ code: string;
75
+ state: string;
76
+ nonce: string;
77
+ codeVerifier: string;
78
+ signed_payload: string;
79
+ tenant?: SsoTenant;
80
+ jti?: string;
81
+ iss?: string;
82
+ aud?: string;
83
+ exp?: number;
84
+ iat?: number;
85
+ }
86
+
87
+ export type { BigsoAuthOptions as B, SsoJwtTenant as S, V2ExchangeResponse as V, BigsoAuthResult as a, SsoTokenPayload as b, V2LoginResponse as c, V2RefreshResponse as d };
@@ -0,0 +1,87 @@
1
+ interface BigsoAuthOptions {
2
+ clientId: string;
3
+ ssoOrigin: string;
4
+ jwksUrl: string;
5
+ timeout?: number;
6
+ debug?: boolean;
7
+ redirectUri?: string;
8
+ tenantHint?: string;
9
+ theme?: 'light' | 'dark';
10
+ }
11
+ interface SsoUser {
12
+ userId: string;
13
+ email: string;
14
+ firstName: string;
15
+ lastName: string;
16
+ }
17
+ interface SsoTenant {
18
+ id: string;
19
+ name: string;
20
+ slug: string;
21
+ role: string;
22
+ permissions: Array<{
23
+ resource: string;
24
+ action: string;
25
+ }>;
26
+ }
27
+ interface SsoJwtTenant {
28
+ id: string;
29
+ name: string;
30
+ slug: string;
31
+ role: string;
32
+ apps: string[];
33
+ }
34
+ interface SsoTokenPayload {
35
+ sub: string;
36
+ jti: string;
37
+ iss: string;
38
+ aud: string;
39
+ exp: number;
40
+ iat: number;
41
+ tenantId: string;
42
+ appId: string;
43
+ systemRole: string;
44
+ scope: string[];
45
+ }
46
+ interface V2LoginResponse {
47
+ success: boolean;
48
+ tokens: {
49
+ accessToken: string;
50
+ expiresIn: number;
51
+ };
52
+ user: SsoUser;
53
+ }
54
+ interface V2ExchangeResponse {
55
+ success: boolean;
56
+ tokens: {
57
+ accessToken: string;
58
+ refreshToken: string;
59
+ expiresIn: number;
60
+ };
61
+ user: SsoUser;
62
+ currentTenant: SsoTenant;
63
+ relatedTenants: SsoTenant[];
64
+ }
65
+ interface V2RefreshResponse {
66
+ success: boolean;
67
+ tokens: {
68
+ accessToken: string;
69
+ expiresIn: number;
70
+ refreshToken?: string;
71
+ };
72
+ }
73
+ interface BigsoAuthResult {
74
+ code: string;
75
+ state: string;
76
+ nonce: string;
77
+ codeVerifier: string;
78
+ signed_payload: string;
79
+ tenant?: SsoTenant;
80
+ jti?: string;
81
+ iss?: string;
82
+ aud?: string;
83
+ exp?: number;
84
+ iat?: number;
85
+ }
86
+
87
+ export type { BigsoAuthOptions as B, SsoJwtTenant as S, V2ExchangeResponse as V, BigsoAuthResult as a, SsoTokenPayload as b, V2LoginResponse as c, V2RefreshResponse as d };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigso/auth-sdk",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "description": "SDK de autenticación para SSO v2 - JWT Bearer + PKCE",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",