@bigso/auth-sdk 0.5.1 → 0.5.3

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.
@@ -0,0 +1,46 @@
1
+ import { Request, Response, NextFunction, Router } from 'express';
2
+ import { BigsoSsoClient } from '../node/index.js';
3
+ import { S as SsoJwtTenant, b as SsoTokenPayload, V as V2ExchangeResponse } from '../types-K3V5MV8v.js';
4
+
5
+ interface SsoAuthMiddlewareOptions {
6
+ ssoClient: BigsoSsoClient;
7
+ }
8
+ declare global {
9
+ namespace Express {
10
+ interface Request {
11
+ user?: {
12
+ userId: string;
13
+ email: string;
14
+ firstName: string;
15
+ lastName: string;
16
+ };
17
+ tenant?: SsoJwtTenant;
18
+ tokenPayload?: SsoTokenPayload;
19
+ }
20
+ }
21
+ }
22
+ declare function ssoAuthMiddleware(options: SsoAuthMiddlewareOptions): (req: Request, res: Response, next: NextFunction) => Promise<void>;
23
+
24
+ interface SsoSyncGuardOptions {
25
+ ssoBackendUrl: string;
26
+ isProduction?: boolean;
27
+ }
28
+ declare function ssoSyncGuardMiddleware(options: SsoSyncGuardOptions): (req: Request, res: Response, next: NextFunction) => Promise<void>;
29
+
30
+ interface CreateSsoAuthRouterOptions {
31
+ ssoClient: BigsoSsoClient;
32
+ frontendUrl: string;
33
+ onLoginSuccess?: (session: V2ExchangeResponse) => void | Promise<void>;
34
+ onLogout?: (accessToken: string) => void | Promise<void>;
35
+ }
36
+ declare function createSsoAuthRouter(options: CreateSsoAuthRouterOptions): Router;
37
+
38
+ interface SsoSyncRouterOptions {
39
+ resources: any[];
40
+ appId: string;
41
+ ssoBackendUrl: string;
42
+ isProduction?: boolean;
43
+ }
44
+ declare function createSsoSyncRouter(options: SsoSyncRouterOptions): Router;
45
+
46
+ export { type CreateSsoAuthRouterOptions, type SsoAuthMiddlewareOptions, type SsoSyncGuardOptions, type SsoSyncRouterOptions, createSsoAuthRouter, createSsoSyncRouter, ssoAuthMiddleware, ssoSyncGuardMiddleware };
@@ -0,0 +1,196 @@
1
+ // src/express/middlewares/ssoAuth.ts
2
+ function ssoAuthMiddleware(options) {
3
+ return async (req, res, next) => {
4
+ try {
5
+ const authHeader = req.headers.authorization;
6
+ if (!authHeader || !authHeader.startsWith("Bearer ")) {
7
+ res.status(401).json({ error: "Missing access token" });
8
+ return;
9
+ }
10
+ const accessToken = authHeader.substring(7);
11
+ const payload = await options.ssoClient.validateAccessToken(accessToken);
12
+ if (!payload) {
13
+ res.status(401).json({ error: "Invalid or expired access token" });
14
+ return;
15
+ }
16
+ const primaryTenant = payload.tenants?.[0];
17
+ req.user = {
18
+ userId: payload.sub,
19
+ email: "",
20
+ firstName: "",
21
+ lastName: ""
22
+ };
23
+ req.tenant = primaryTenant || void 0;
24
+ req.tokenPayload = payload;
25
+ next();
26
+ } catch (error) {
27
+ console.error("[BigsoAuthSDK] Authentication Middleware Error:", error instanceof Error ? error.message : error);
28
+ res.status(401).json({ error: "Authentication failed" });
29
+ }
30
+ };
31
+ }
32
+
33
+ // src/express/middlewares/ssoSyncGuard.ts
34
+ import { promises as dns } from "dns";
35
+ function ssoSyncGuardMiddleware(options) {
36
+ const isProduction = options.isProduction ?? process.env.NODE_ENV === "production";
37
+ return async (req, res, next) => {
38
+ try {
39
+ const isSecure = req.secure || req.headers["x-forwarded-proto"] === "https";
40
+ if (!isSecure && isProduction) {
41
+ console.warn("\u26A0\uFE0F [BigsoAuthSDK] Blocked non-HTTPS sync request");
42
+ res.status(403).json({ error: "HTTPS required" });
43
+ return;
44
+ }
45
+ const clientIp = req.ip || req.socket.remoteAddress || "";
46
+ const isLoopback = clientIp === "::1" || clientIp === "127.0.0.1" || clientIp === "::ffff:127.0.0.1";
47
+ if (!isProduction && isLoopback) {
48
+ return next();
49
+ }
50
+ const ssoUrl = new URL(options.ssoBackendUrl);
51
+ const ssoHostname = ssoUrl.hostname;
52
+ const ssoIps = await dns.resolve4(ssoHostname).catch(() => []);
53
+ const cleanClientIp = clientIp.replace(/^.*:/, "");
54
+ const isPrivateIp = cleanClientIp.startsWith("10.") || cleanClientIp.startsWith("192.168.") || cleanClientIp.startsWith("172.") && parseInt(cleanClientIp.split(".")[1], 10) >= 16 && parseInt(cleanClientIp.split(".")[1], 10) <= 31;
55
+ if (!ssoIps.includes(cleanClientIp) && !isPrivateIp) {
56
+ console.warn(`\u26D4\uFE0F [BigsoAuthSDK] Blocked sync request from unauthorized IP: ${clientIp}`);
57
+ res.status(403).json({ error: "Unauthorized origin" });
58
+ return;
59
+ }
60
+ next();
61
+ } catch (error) {
62
+ console.error("\u274C [BigsoAuthSDK] Sync Guard Validation Error:", error instanceof Error ? error.message : error);
63
+ res.status(500).json({ error: "Security validation failed" });
64
+ }
65
+ };
66
+ }
67
+
68
+ // src/express/routes/createSsoAuthRouter.ts
69
+ import { Router } from "express";
70
+ function createSsoAuthRouter(options) {
71
+ const router = Router();
72
+ router.post("/exchange", async (req, res) => {
73
+ try {
74
+ const { code, codeVerifier } = req.body;
75
+ if (!code || !codeVerifier) {
76
+ res.status(400).json({ error: "code and codeVerifier are required" });
77
+ return;
78
+ }
79
+ const ssoResponse = await options.ssoClient.exchangeCode(code, codeVerifier);
80
+ if (options.onLoginSuccess) {
81
+ await options.onLoginSuccess(ssoResponse);
82
+ }
83
+ res.json({
84
+ success: true,
85
+ tokens: ssoResponse.tokens,
86
+ user: ssoResponse.user,
87
+ tenant: ssoResponse.tenant
88
+ });
89
+ } catch (error) {
90
+ console.error("[BigsoAuthSDK] Error exchanging code:", error.message);
91
+ res.status(401).json({ error: error.message || "Failed to exchange authorization code" });
92
+ }
93
+ });
94
+ router.post("/exchange-v2", async (req, res) => {
95
+ try {
96
+ const { payload } = req.body;
97
+ if (!payload) {
98
+ res.status(400).json({ error: "Signed payload is required" });
99
+ return;
100
+ }
101
+ const verified = await options.ssoClient.verifySignedPayload(payload, options.frontendUrl);
102
+ if (!verified.code) {
103
+ res.status(400).json({ error: "No authorization code found in payload" });
104
+ return;
105
+ }
106
+ const codeVerifier = verified.code_verifier;
107
+ if (!codeVerifier) {
108
+ res.status(400).json({ error: "code_verifier is required for PKCE exchange" });
109
+ return;
110
+ }
111
+ const ssoResponse = await options.ssoClient.exchangeCode(verified.code, codeVerifier);
112
+ if (options.onLoginSuccess) {
113
+ await options.onLoginSuccess(ssoResponse);
114
+ }
115
+ res.json({
116
+ success: true,
117
+ tokens: ssoResponse.tokens,
118
+ user: ssoResponse.user,
119
+ tenant: ssoResponse.tenant
120
+ });
121
+ } catch (error) {
122
+ console.error("[BigsoAuthSDK] Error exchanging v2 payload:", error.message);
123
+ res.status(401).json({ error: error.message || "Failed to verify signed payload" });
124
+ }
125
+ });
126
+ router.get("/session", ssoAuthMiddleware({ ssoClient: options.ssoClient }), (req, res) => {
127
+ res.set("Cache-Control", "no-store, no-cache, must-revalidate, private");
128
+ res.set("Pragma", "no-cache");
129
+ res.set("Expires", "0");
130
+ res.json({
131
+ success: true,
132
+ user: req.user,
133
+ tenant: req.tenant,
134
+ tokenPayload: req.tokenPayload
135
+ });
136
+ });
137
+ router.post("/refresh", async (req, res) => {
138
+ try {
139
+ const ssoResponse = await options.ssoClient.refreshTokens();
140
+ res.json({
141
+ success: true,
142
+ tokens: ssoResponse.tokens
143
+ });
144
+ } catch (error) {
145
+ console.error("[BigsoAuthSDK] Error refreshing tokens:", error.message);
146
+ res.status(401).json({ error: error.message || "Failed to refresh tokens" });
147
+ }
148
+ });
149
+ router.post("/logout", ssoAuthMiddleware({ ssoClient: options.ssoClient }), async (req, res) => {
150
+ try {
151
+ const accessToken = req.headers.authorization?.substring(7) || "";
152
+ const { revokeAll = false } = req.body || {};
153
+ await options.ssoClient.logout(accessToken, revokeAll);
154
+ if (options.onLogout) {
155
+ await options.onLogout(accessToken);
156
+ }
157
+ res.json({ success: true, message: "Logged out" });
158
+ } catch (error) {
159
+ console.warn("[BigsoAuthSDK] Failed to logout in SSO Backend.", error.message);
160
+ res.json({ success: true, message: "Logged out (backend revocation failed)" });
161
+ }
162
+ });
163
+ return router;
164
+ }
165
+
166
+ // src/express/routes/createSsoSyncRouter.ts
167
+ import { Router as Router2 } from "express";
168
+ function createSsoSyncRouter(options) {
169
+ const router = Router2();
170
+ router.get("/resources", ssoSyncGuardMiddleware({
171
+ ssoBackendUrl: options.ssoBackendUrl,
172
+ isProduction: options.isProduction
173
+ }), (req, res) => {
174
+ try {
175
+ res.json({
176
+ success: true,
177
+ resources: options.resources,
178
+ meta: {
179
+ appId: options.appId,
180
+ count: options.resources.length,
181
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
182
+ }
183
+ });
184
+ } catch (error) {
185
+ console.error("\u274C [BigsoAuthSDK] Error in sync endpoint:", error.message);
186
+ res.status(500).json({ error: error.message });
187
+ }
188
+ });
189
+ return router;
190
+ }
191
+ export {
192
+ createSsoAuthRouter,
193
+ createSsoSyncRouter,
194
+ ssoAuthMiddleware,
195
+ ssoSyncGuardMiddleware
196
+ };
@@ -0,0 +1,142 @@
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/node/index.ts
21
+ var node_exports = {};
22
+ __export(node_exports, {
23
+ BigsoSsoClient: () => BigsoSsoClient
24
+ });
25
+ module.exports = __toCommonJS(node_exports);
26
+
27
+ // src/utils/jws.ts
28
+ var import_jose = require("jose");
29
+ async function verifySignedPayload(token, jwksUrl, expectedAudience) {
30
+ const JWKS = (0, import_jose.createRemoteJWKSet)(new URL(jwksUrl));
31
+ const { payload } = await (0, import_jose.jwtVerify)(token, JWKS, {
32
+ audience: expectedAudience
33
+ });
34
+ return payload;
35
+ }
36
+ async function verifyAccessToken(accessToken, jwksUrl) {
37
+ const JWKS = (0, import_jose.createRemoteJWKSet)(new URL(jwksUrl));
38
+ const { payload } = await (0, import_jose.jwtVerify)(accessToken, JWKS);
39
+ if (!payload.sub || !payload.jti) {
40
+ throw new Error("Invalid token structure: missing sub or jti");
41
+ }
42
+ return {
43
+ sub: payload.sub,
44
+ jti: payload.jti,
45
+ iss: payload.iss,
46
+ aud: payload.aud || "",
47
+ exp: payload.exp,
48
+ iat: payload.iat,
49
+ tenants: payload.tenants || [],
50
+ systemRole: payload.systemRole || "user",
51
+ scope: payload.scope,
52
+ deviceFingerprint: payload.deviceFingerprint
53
+ };
54
+ }
55
+
56
+ // src/node/SsoClient.ts
57
+ var BigsoSsoClient = class {
58
+ constructor(options) {
59
+ this.ssoBackendUrl = options.ssoBackendUrl;
60
+ this.appId = options.appId;
61
+ this.ssoJwksUrl = options.ssoJwksUrl;
62
+ }
63
+ async verifySignedPayload(token, expectedAudience) {
64
+ if (!this.ssoJwksUrl) {
65
+ throw new Error("ssoJwksUrl is required for verifySignedPayload");
66
+ }
67
+ return await verifySignedPayload(token, this.ssoJwksUrl, expectedAudience);
68
+ }
69
+ async validateAccessToken(accessToken) {
70
+ if (!this.ssoJwksUrl) {
71
+ throw new Error("ssoJwksUrl is required for validateAccessToken");
72
+ }
73
+ try {
74
+ return await verifyAccessToken(accessToken, this.ssoJwksUrl);
75
+ } catch {
76
+ return null;
77
+ }
78
+ }
79
+ async login(emailOrNuid, password) {
80
+ const isEmail = emailOrNuid.includes("@");
81
+ const payload = isEmail ? { email: emailOrNuid, password } : { nuid: emailOrNuid, password };
82
+ const response = await fetch(`${this.ssoBackendUrl}/api/v2/auth/login`, {
83
+ method: "POST",
84
+ headers: { "Content-Type": "application/json" },
85
+ body: JSON.stringify(payload),
86
+ credentials: "include"
87
+ });
88
+ if (!response.ok) {
89
+ const err = await response.json().catch(() => ({}));
90
+ throw new Error(err.message || "Login failed");
91
+ }
92
+ return await response.json();
93
+ }
94
+ async exchangeCode(code, codeVerifier) {
95
+ const response = await fetch(`${this.ssoBackendUrl}/api/v2/auth/exchange`, {
96
+ method: "POST",
97
+ headers: { "Content-Type": "application/json" },
98
+ body: JSON.stringify({
99
+ code,
100
+ appId: this.appId,
101
+ codeVerifier
102
+ }),
103
+ credentials: "include"
104
+ });
105
+ if (!response.ok) {
106
+ const err = await response.json().catch(() => ({}));
107
+ throw new Error(err.message || "Token exchange failed");
108
+ }
109
+ return await response.json();
110
+ }
111
+ async refreshTokens() {
112
+ const response = await fetch(`${this.ssoBackendUrl}/api/v2/auth/refresh`, {
113
+ method: "POST",
114
+ headers: { "Content-Type": "application/json" },
115
+ credentials: "include"
116
+ });
117
+ if (!response.ok) {
118
+ const err = await response.json().catch(() => ({}));
119
+ throw new Error(err.message || "Token refresh failed");
120
+ }
121
+ return await response.json();
122
+ }
123
+ async logout(accessToken, revokeAll = false) {
124
+ const response = await fetch(`${this.ssoBackendUrl}/api/v2/auth/logout`, {
125
+ method: "POST",
126
+ headers: {
127
+ "Content-Type": "application/json",
128
+ "Authorization": `Bearer ${accessToken}`
129
+ },
130
+ body: JSON.stringify({ revokeAll }),
131
+ credentials: "include"
132
+ });
133
+ if (!response.ok) {
134
+ const err = await response.json().catch(() => ({}));
135
+ throw new Error(err.message || "Logout failed");
136
+ }
137
+ }
138
+ };
139
+ // Annotate the CommonJS export names for ESM import in node:
140
+ 0 && (module.exports = {
141
+ BigsoSsoClient
142
+ });
@@ -0,0 +1,21 @@
1
+ import { b as SsoTokenPayload, c as V2LoginResponse, V as V2ExchangeResponse, d as V2RefreshResponse } from '../types-K3V5MV8v.cjs';
2
+
3
+ interface SsoClientOptions {
4
+ ssoBackendUrl: string;
5
+ ssoJwksUrl?: string;
6
+ appId: string;
7
+ }
8
+ declare class BigsoSsoClient {
9
+ private ssoBackendUrl;
10
+ private appId;
11
+ private ssoJwksUrl?;
12
+ constructor(options: SsoClientOptions);
13
+ verifySignedPayload(token: string, expectedAudience: string): Promise<any>;
14
+ validateAccessToken(accessToken: string): Promise<SsoTokenPayload | null>;
15
+ login(emailOrNuid: string, password: string): Promise<V2LoginResponse>;
16
+ exchangeCode(code: string, codeVerifier: string): Promise<V2ExchangeResponse>;
17
+ refreshTokens(): Promise<V2RefreshResponse>;
18
+ logout(accessToken: string, revokeAll?: boolean): Promise<void>;
19
+ }
20
+
21
+ export { BigsoSsoClient, type SsoClientOptions };
@@ -0,0 +1,21 @@
1
+ import { b as SsoTokenPayload, c as V2LoginResponse, V as V2ExchangeResponse, d as V2RefreshResponse } from '../types-K3V5MV8v.js';
2
+
3
+ interface SsoClientOptions {
4
+ ssoBackendUrl: string;
5
+ ssoJwksUrl?: string;
6
+ appId: string;
7
+ }
8
+ declare class BigsoSsoClient {
9
+ private ssoBackendUrl;
10
+ private appId;
11
+ private ssoJwksUrl?;
12
+ constructor(options: SsoClientOptions);
13
+ verifySignedPayload(token: string, expectedAudience: string): Promise<any>;
14
+ validateAccessToken(accessToken: string): Promise<SsoTokenPayload | null>;
15
+ login(emailOrNuid: string, password: string): Promise<V2LoginResponse>;
16
+ exchangeCode(code: string, codeVerifier: string): Promise<V2ExchangeResponse>;
17
+ refreshTokens(): Promise<V2RefreshResponse>;
18
+ logout(accessToken: string, revokeAll?: boolean): Promise<void>;
19
+ }
20
+
21
+ export { BigsoSsoClient, type SsoClientOptions };
@@ -0,0 +1,91 @@
1
+ import {
2
+ verifyAccessToken,
3
+ verifySignedPayload
4
+ } from "../chunk-PB3GVAEJ.js";
5
+
6
+ // src/node/SsoClient.ts
7
+ var BigsoSsoClient = class {
8
+ constructor(options) {
9
+ this.ssoBackendUrl = options.ssoBackendUrl;
10
+ this.appId = options.appId;
11
+ this.ssoJwksUrl = options.ssoJwksUrl;
12
+ }
13
+ async verifySignedPayload(token, expectedAudience) {
14
+ if (!this.ssoJwksUrl) {
15
+ throw new Error("ssoJwksUrl is required for verifySignedPayload");
16
+ }
17
+ return await verifySignedPayload(token, this.ssoJwksUrl, expectedAudience);
18
+ }
19
+ async validateAccessToken(accessToken) {
20
+ if (!this.ssoJwksUrl) {
21
+ throw new Error("ssoJwksUrl is required for validateAccessToken");
22
+ }
23
+ try {
24
+ return await verifyAccessToken(accessToken, this.ssoJwksUrl);
25
+ } catch {
26
+ return null;
27
+ }
28
+ }
29
+ async login(emailOrNuid, password) {
30
+ const isEmail = emailOrNuid.includes("@");
31
+ const payload = isEmail ? { email: emailOrNuid, password } : { nuid: emailOrNuid, password };
32
+ const response = await fetch(`${this.ssoBackendUrl}/api/v2/auth/login`, {
33
+ method: "POST",
34
+ headers: { "Content-Type": "application/json" },
35
+ body: JSON.stringify(payload),
36
+ credentials: "include"
37
+ });
38
+ if (!response.ok) {
39
+ const err = await response.json().catch(() => ({}));
40
+ throw new Error(err.message || "Login failed");
41
+ }
42
+ return await response.json();
43
+ }
44
+ async exchangeCode(code, codeVerifier) {
45
+ const response = await fetch(`${this.ssoBackendUrl}/api/v2/auth/exchange`, {
46
+ method: "POST",
47
+ headers: { "Content-Type": "application/json" },
48
+ body: JSON.stringify({
49
+ code,
50
+ appId: this.appId,
51
+ codeVerifier
52
+ }),
53
+ credentials: "include"
54
+ });
55
+ if (!response.ok) {
56
+ const err = await response.json().catch(() => ({}));
57
+ throw new Error(err.message || "Token exchange failed");
58
+ }
59
+ return await response.json();
60
+ }
61
+ async refreshTokens() {
62
+ const response = await fetch(`${this.ssoBackendUrl}/api/v2/auth/refresh`, {
63
+ method: "POST",
64
+ headers: { "Content-Type": "application/json" },
65
+ credentials: "include"
66
+ });
67
+ if (!response.ok) {
68
+ const err = await response.json().catch(() => ({}));
69
+ throw new Error(err.message || "Token refresh failed");
70
+ }
71
+ return await response.json();
72
+ }
73
+ async logout(accessToken, revokeAll = false) {
74
+ const response = await fetch(`${this.ssoBackendUrl}/api/v2/auth/logout`, {
75
+ method: "POST",
76
+ headers: {
77
+ "Content-Type": "application/json",
78
+ "Authorization": `Bearer ${accessToken}`
79
+ },
80
+ body: JSON.stringify({ revokeAll }),
81
+ credentials: "include"
82
+ });
83
+ if (!response.ok) {
84
+ const err = await response.json().catch(() => ({}));
85
+ throw new Error(err.message || "Logout failed");
86
+ }
87
+ }
88
+ };
89
+ export {
90
+ BigsoSsoClient
91
+ };
@@ -0,0 +1,80 @@
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
+ tenantId: string;
19
+ name: string;
20
+ slug: string;
21
+ role: string;
22
+ }
23
+ interface SsoJwtTenant {
24
+ id: string;
25
+ name: string;
26
+ slug: string;
27
+ role: string;
28
+ apps: string[];
29
+ }
30
+ interface SsoTokenPayload {
31
+ sub: string;
32
+ jti: string;
33
+ iss: string;
34
+ aud: string;
35
+ exp: number;
36
+ iat: number;
37
+ tenants: SsoJwtTenant[];
38
+ systemRole: string;
39
+ deviceFingerprint?: string;
40
+ }
41
+ interface V2LoginResponse {
42
+ success: boolean;
43
+ tokens: {
44
+ accessToken: string;
45
+ expiresIn: number;
46
+ };
47
+ user: SsoUser;
48
+ }
49
+ interface V2ExchangeResponse {
50
+ success: boolean;
51
+ tokens: {
52
+ accessToken: string;
53
+ refreshToken: string;
54
+ expiresIn: number;
55
+ };
56
+ user: SsoUser;
57
+ tenant: SsoTenant;
58
+ }
59
+ interface V2RefreshResponse {
60
+ success: boolean;
61
+ tokens: {
62
+ accessToken: string;
63
+ expiresIn: number;
64
+ };
65
+ }
66
+ interface BigsoAuthResult {
67
+ code: string;
68
+ state: string;
69
+ nonce: string;
70
+ codeVerifier: string;
71
+ signed_payload: string;
72
+ tenant?: SsoTenant;
73
+ jti?: string;
74
+ iss?: string;
75
+ aud?: string;
76
+ exp?: number;
77
+ iat?: number;
78
+ }
79
+
80
+ 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,80 @@
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
+ tenantId: string;
19
+ name: string;
20
+ slug: string;
21
+ role: string;
22
+ }
23
+ interface SsoJwtTenant {
24
+ id: string;
25
+ name: string;
26
+ slug: string;
27
+ role: string;
28
+ apps: string[];
29
+ }
30
+ interface SsoTokenPayload {
31
+ sub: string;
32
+ jti: string;
33
+ iss: string;
34
+ aud: string;
35
+ exp: number;
36
+ iat: number;
37
+ tenants: SsoJwtTenant[];
38
+ systemRole: string;
39
+ deviceFingerprint?: string;
40
+ }
41
+ interface V2LoginResponse {
42
+ success: boolean;
43
+ tokens: {
44
+ accessToken: string;
45
+ expiresIn: number;
46
+ };
47
+ user: SsoUser;
48
+ }
49
+ interface V2ExchangeResponse {
50
+ success: boolean;
51
+ tokens: {
52
+ accessToken: string;
53
+ refreshToken: string;
54
+ expiresIn: number;
55
+ };
56
+ user: SsoUser;
57
+ tenant: SsoTenant;
58
+ }
59
+ interface V2RefreshResponse {
60
+ success: boolean;
61
+ tokens: {
62
+ accessToken: string;
63
+ expiresIn: number;
64
+ };
65
+ }
66
+ interface BigsoAuthResult {
67
+ code: string;
68
+ state: string;
69
+ nonce: string;
70
+ codeVerifier: string;
71
+ signed_payload: string;
72
+ tenant?: SsoTenant;
73
+ jti?: string;
74
+ iss?: string;
75
+ aud?: string;
76
+ exp?: number;
77
+ iat?: number;
78
+ }
79
+
80
+ export type { BigsoAuthOptions as B, SsoJwtTenant as S, V2ExchangeResponse as V, BigsoAuthResult as a, SsoTokenPayload as b, V2LoginResponse as c, V2RefreshResponse as d };