@burdenoff/be-sdk 2026.529.2 → 2026.530.1
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.
- package/dist/auth/index.d.ts +18 -10
- package/dist/auth/index.js +1 -1
- package/dist/{chunk-7NUQXGA7.js → chunk-KKCC3Z4I.js} +108 -30
- package/dist/chunk-KKCC3Z4I.js.map +1 -0
- package/dist/i18n/index.d.ts +3 -2
- package/dist/i18n-DrdPTann.d.ts +33 -0
- package/dist/{index-BV3G48cH.d.ts → index-D4l1u8VR.d.ts} +2 -1
- package/dist/index.d.ts +9 -7
- package/dist/index.js +3 -3
- package/dist/server/index.d.ts +8 -226
- package/dist/{i18n-DA6IPnYy.d.ts → types-C8TbSdEj.d.ts} +1 -31
- package/dist/types-sKXodL2N.d.ts +227 -0
- package/package.json +1 -1
- package/dist/chunk-7NUQXGA7.js.map +0 -1
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { B as BurdenoffGraphQLClient } from '../graphql-DH3L5Hj7.js';
|
|
2
2
|
import { S as SDKContext } from '../index-Caqvetqq.js';
|
|
3
|
+
import { G as GraphQLContext } from '../types-sKXodL2N.js';
|
|
3
4
|
import 'graphql-request';
|
|
5
|
+
import 'graphql';
|
|
6
|
+
import 'graphql-yoga';
|
|
7
|
+
import '../client-CSjIrYKS.js';
|
|
8
|
+
import '@prisma/adapter-pg';
|
|
9
|
+
import 'pg';
|
|
10
|
+
import '../types-C8TbSdEj.js';
|
|
4
11
|
|
|
5
12
|
interface CookieOptions {
|
|
6
13
|
name: string;
|
|
@@ -12,20 +19,21 @@ interface CookieOptions {
|
|
|
12
19
|
secure?: boolean;
|
|
13
20
|
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
14
21
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
declare const AuthCookieHelper: {
|
|
21
|
-
setAuthCookies(context: CookieContext, tokens: {
|
|
22
|
+
declare class AuthCookieHelper {
|
|
23
|
+
private static readonly ACCESS_TOKEN_COOKIE;
|
|
24
|
+
private static readonly REFRESH_TOKEN_COOKIE;
|
|
25
|
+
private static readonly PROFILE_ID_COOKIE;
|
|
26
|
+
static setAuthCookies(context: GraphQLContext, tokens: {
|
|
22
27
|
accessToken: string;
|
|
23
|
-
refreshToken
|
|
28
|
+
refreshToken?: string;
|
|
24
29
|
}, options?: {
|
|
30
|
+
profileId?: string;
|
|
25
31
|
rememberMe?: boolean;
|
|
26
32
|
}): void;
|
|
27
|
-
clearAuthCookies(context:
|
|
28
|
-
|
|
33
|
+
static clearAuthCookies(context: GraphQLContext): void;
|
|
34
|
+
private static setCookie;
|
|
35
|
+
}
|
|
36
|
+
|
|
29
37
|
interface TokenPayload {
|
|
30
38
|
jti: string;
|
|
31
39
|
sub: string;
|
package/dist/auth/index.js
CHANGED
|
@@ -3,36 +3,114 @@ import { AuthenticationError } from './chunk-O6RHB2YP.js';
|
|
|
3
3
|
import { logger } from './chunk-CBZNP6RF.js';
|
|
4
4
|
import { __name } from './chunk-XE4OXN2W.js';
|
|
5
5
|
|
|
6
|
-
// src/auth/
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
6
|
+
// src/auth/cookie-helper.ts
|
|
7
|
+
var AuthCookieHelper = class {
|
|
8
|
+
static {
|
|
9
|
+
__name(this, "AuthCookieHelper");
|
|
10
|
+
}
|
|
11
|
+
static ACCESS_TOKEN_COOKIE = "bf_at";
|
|
12
|
+
static REFRESH_TOKEN_COOKIE = "bf_rt";
|
|
13
|
+
static PROFILE_ID_COOKIE = "bf_pid";
|
|
14
|
+
/**
|
|
15
|
+
* Set authentication cookies in the context response headers
|
|
16
|
+
*/
|
|
17
|
+
static setAuthCookies(context, tokens, options = {}) {
|
|
18
|
+
const isProd = process.env["NODE_ENV"] === "production";
|
|
19
|
+
const domain = process.env["COOKIE_DOMAIN"];
|
|
20
|
+
this.setCookie(context, {
|
|
21
|
+
name: this.ACCESS_TOKEN_COOKIE,
|
|
22
|
+
value: tokens.accessToken,
|
|
23
|
+
maxAge: 15 * 60,
|
|
24
|
+
httpOnly: true,
|
|
25
|
+
secure: isProd,
|
|
26
|
+
sameSite: "Lax",
|
|
27
|
+
domain,
|
|
28
|
+
path: "/"
|
|
29
|
+
});
|
|
30
|
+
if (tokens.refreshToken) {
|
|
31
|
+
this.setCookie(context, {
|
|
32
|
+
name: this.REFRESH_TOKEN_COOKIE,
|
|
33
|
+
value: tokens.refreshToken,
|
|
34
|
+
maxAge: options.rememberMe ? 30 * 24 * 60 * 60 : 7 * 24 * 60 * 60,
|
|
35
|
+
httpOnly: true,
|
|
36
|
+
secure: isProd,
|
|
37
|
+
sameSite: "Lax",
|
|
38
|
+
domain,
|
|
39
|
+
path: "/global/graphql"
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (options.profileId) {
|
|
43
|
+
this.setCookie(context, {
|
|
44
|
+
name: this.PROFILE_ID_COOKIE,
|
|
45
|
+
value: options.profileId,
|
|
46
|
+
maxAge: 30 * 24 * 60 * 60,
|
|
47
|
+
httpOnly: false,
|
|
48
|
+
secure: isProd,
|
|
49
|
+
sameSite: "Lax",
|
|
50
|
+
domain,
|
|
51
|
+
path: "/"
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Clear authentication cookies
|
|
57
|
+
*/
|
|
58
|
+
static clearAuthCookies(context) {
|
|
59
|
+
const domain = process.env["COOKIE_DOMAIN"];
|
|
60
|
+
const isProd = process.env["NODE_ENV"] === "production";
|
|
61
|
+
const clearOptions = {
|
|
62
|
+
value: "",
|
|
63
|
+
maxAge: 0,
|
|
64
|
+
domain,
|
|
65
|
+
path: "/",
|
|
66
|
+
secure: isProd,
|
|
67
|
+
sameSite: "Lax"
|
|
68
|
+
};
|
|
69
|
+
this.setCookie(context, {
|
|
70
|
+
...clearOptions,
|
|
71
|
+
name: this.ACCESS_TOKEN_COOKIE,
|
|
72
|
+
httpOnly: true
|
|
73
|
+
});
|
|
74
|
+
this.setCookie(context, {
|
|
75
|
+
...clearOptions,
|
|
76
|
+
name: this.REFRESH_TOKEN_COOKIE,
|
|
77
|
+
httpOnly: true,
|
|
78
|
+
path: "/global/graphql"
|
|
79
|
+
});
|
|
80
|
+
this.setCookie(context, {
|
|
81
|
+
...clearOptions,
|
|
82
|
+
name: this.PROFILE_ID_COOKIE,
|
|
83
|
+
httpOnly: false
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Internal helper to set a cookie header
|
|
88
|
+
*/
|
|
89
|
+
static setCookie(context, options) {
|
|
90
|
+
let cookie = `${options.name}=${options.value}`;
|
|
91
|
+
if (options.maxAge !== void 0) {
|
|
92
|
+
cookie += `; Max-Age=${options.maxAge}`;
|
|
93
|
+
}
|
|
94
|
+
if (options.domain) {
|
|
95
|
+
cookie += `; Domain=${options.domain}`;
|
|
96
|
+
}
|
|
97
|
+
if (options.path) {
|
|
98
|
+
cookie += `; Path=${options.path}`;
|
|
99
|
+
}
|
|
100
|
+
if (options.httpOnly) {
|
|
101
|
+
cookie += "; HttpOnly";
|
|
102
|
+
}
|
|
103
|
+
if (options.secure) {
|
|
104
|
+
cookie += "; Secure";
|
|
105
|
+
}
|
|
106
|
+
if (options.sameSite) {
|
|
107
|
+
cookie += `; SameSite=${options.sameSite}`;
|
|
108
|
+
}
|
|
109
|
+
context.responseHeaders.append("Set-Cookie", cookie);
|
|
34
110
|
}
|
|
35
111
|
};
|
|
112
|
+
|
|
113
|
+
// src/auth/index.ts
|
|
36
114
|
var AuthModule = class {
|
|
37
115
|
static {
|
|
38
116
|
__name(this, "AuthModule");
|
|
@@ -194,5 +272,5 @@ var AuthModule = class {
|
|
|
194
272
|
};
|
|
195
273
|
|
|
196
274
|
export { AuthCookieHelper, AuthModule };
|
|
197
|
-
//# sourceMappingURL=chunk-
|
|
198
|
-
//# sourceMappingURL=chunk-
|
|
275
|
+
//# sourceMappingURL=chunk-KKCC3Z4I.js.map
|
|
276
|
+
//# sourceMappingURL=chunk-KKCC3Z4I.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/auth/cookie-helper.ts","../src/auth/index.ts"],"names":["AuthCookieHelper","ACCESS_TOKEN_COOKIE","REFRESH_TOKEN_COOKIE","PROFILE_ID_COOKIE","setAuthCookies","context","tokens","options","isProd","process","env","domain","setCookie","name","value","accessToken","maxAge","httpOnly","secure","sameSite","path","refreshToken","rememberMe","profileId","clearAuthCookies","clearOptions","cookie","undefined","responseHeaders","append","AuthModule","client","verifyToken","token","logger","debug","isTokenExpired","valid","error","query","response","Error","message","decodeToken","payload","parseJWT","mutation","info","AuthenticationError","validatePermission","userId","permission","resourceId","allowed","isTokenValid","getUserIdFromToken","user_id","getWorkspaceIdFromToken","workspace_id","getTokenClaims","willExpireSoon","withinSeconds","exp","now","Math","floor","Date"],"mappings":";;;;;;AAoBO,IAAMA,mBAAN,MAAMA;EApBb;;;AAqBE,EAAA,OAAwBC,mBAAAA,GAAsB,OAAA;AAC9C,EAAA,OAAwBC,oBAAAA,GAAuB,OAAA;AAC/C,EAAA,OAAwBC,iBAAAA,GAAoB,QAAA;;;;AAK5C,EAAA,OAAcC,cAAAA,CACZC,OAAAA,EACAC,MAAAA,EACAC,OAAAA,GAAwD,EAAC,EACnD;AACN,IAAA,MAAMC,MAAAA,GAASC,OAAAA,CAAQC,GAAAA,CAAI,UAAA,CAAA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D,WAAAA,CAAYV,KAAAA,CAAAA;AACjC,IAAA,OAAOW,SAASc,YAAAA,IAAgB,IAAA;AAClC,EAAA;;;;AAKOC,EAAAA,cAAAA,CAAe1B,KAAAA,EAA+C;AACnE,IAAA,MAAMW,OAAAA,GAAUC,SAASZ,KAAAA,CAAAA;AACzB,IAAA,OAAOW,OAAAA;AACT,EAAA;;;;EAKOgB,cAAAA,CAAe3B,KAAAA,EAAe4B,gBAAwB,GAAA,EAAc;AACzE,IAAA,MAAMjB,OAAAA,GAAU,IAAA,CAAKD,WAAAA,CAAYV,KAAAA,CAAAA;AACjC,IAAA,IAAI,CAACW,OAAAA,IAAW,OAAOA,OAAAA,CAAQkB,QAAQ,QAAA,EAAU;AAC/C,MAAA,OAAO,IAAA;AACT,IAAA;AAEA,IAAA,MAAMC,MAAMC,IAAAA,CAAKC,KAAAA,CAAMC,IAAAA,CAAKH,GAAAA,KAAQ,GAAA,CAAA;AACpC,IAAA,OAAOnB,OAAAA,CAAQkB,MAAMC,GAAAA,GAAMF,aAAAA;AAC7B,EAAA;AACF","file":"chunk-KKCC3Z4I.js","sourcesContent":["/**\n * Auth Cookie Helper\n *\n * Utilities for setting secure, HttpOnly cookies for authentication.\n * Used by auth services to transition from localStorage to secure cookies.\n */\n\nimport type { GraphQLContext } from '../server/types.js';\n\nexport interface CookieOptions {\n name: string;\n value: string;\n maxAge?: number;\n domain?: string;\n path?: string;\n httpOnly?: boolean;\n secure?: boolean;\n sameSite?: 'Strict' | 'Lax' | 'None';\n}\n\nexport class AuthCookieHelper {\n private static readonly ACCESS_TOKEN_COOKIE = 'bf_at';\n private static readonly REFRESH_TOKEN_COOKIE = 'bf_rt';\n private static readonly PROFILE_ID_COOKIE = 'bf_pid';\n\n /**\n * Set authentication cookies in the context response headers\n */\n public static setAuthCookies(\n context: GraphQLContext,\n tokens: { accessToken: string; refreshToken?: string },\n options: { profileId?: string; rememberMe?: boolean } = {}\n ): void {\n const isProd = process.env['NODE_ENV'] === 'production';\n const domain = process.env['COOKIE_DOMAIN'];\n\n // Access token cookie (short-lived, 15m)\n this.setCookie(context, {\n name: this.ACCESS_TOKEN_COOKIE,\n value: tokens.accessToken,\n maxAge: 15 * 60,\n httpOnly: true,\n secure: isProd,\n sameSite: 'Lax',\n domain,\n path: '/',\n });\n\n // Refresh token cookie (long-lived, 7d or 30d)\n if (tokens.refreshToken) {\n this.setCookie(context, {\n name: this.REFRESH_TOKEN_COOKIE,\n value: tokens.refreshToken,\n maxAge: options.rememberMe ? 30 * 24 * 60 * 60 : 7 * 24 * 60 * 60,\n httpOnly: true,\n secure: isProd,\n sameSite: 'Lax',\n domain,\n path: '/global/graphql', // Only send to global gateway for refresh\n });\n }\n\n // Profile ID cookie (not HttpOnly, needed for UI profile resolution)\n if (options.profileId) {\n this.setCookie(context, {\n name: this.PROFILE_ID_COOKIE,\n value: options.profileId,\n maxAge: 30 * 24 * 60 * 60,\n httpOnly: false,\n secure: isProd,\n sameSite: 'Lax',\n domain,\n path: '/',\n });\n }\n }\n\n /**\n * Clear authentication cookies\n */\n public static clearAuthCookies(context: GraphQLContext): void {\n const domain = process.env['COOKIE_DOMAIN'];\n const isProd = process.env['NODE_ENV'] === 'production';\n\n const clearOptions = {\n value: '',\n maxAge: 0,\n domain,\n path: '/',\n secure: isProd,\n sameSite: 'Lax' as const,\n };\n\n this.setCookie(context, { ...clearOptions, name: this.ACCESS_TOKEN_COOKIE, httpOnly: true });\n this.setCookie(context, {\n ...clearOptions,\n name: this.REFRESH_TOKEN_COOKIE,\n httpOnly: true,\n path: '/global/graphql',\n });\n this.setCookie(context, { ...clearOptions, name: this.PROFILE_ID_COOKIE, httpOnly: false });\n }\n\n /**\n * Internal helper to set a cookie header\n */\n private static setCookie(context: GraphQLContext, options: CookieOptions): void {\n let cookie = `${options.name}=${options.value}`;\n\n if (options.maxAge !== undefined) {\n cookie += `; Max-Age=${options.maxAge}`;\n }\n\n if (options.domain) {\n cookie += `; Domain=${options.domain}`;\n }\n\n if (options.path) {\n cookie += `; Path=${options.path}`;\n }\n\n if (options.httpOnly) {\n cookie += '; HttpOnly';\n }\n\n if (options.secure) {\n cookie += '; Secure';\n }\n\n if (options.sameSite) {\n cookie += `; SameSite=${options.sameSite}`;\n }\n\n context.responseHeaders.append('Set-Cookie', cookie);\n }\n}\n","/**\n * Authentication Module\n * JWT verification, token management, and user authentication\n */\n\nimport type { BurdenoffGraphQLClient } from '../client/graphql.js';\nimport type { SDKContext } from '../types/index.js';\nimport { AuthenticationError } from '../types/index.js';\nimport { logger } from '../logger/index.js';\nimport { parseJWT, isTokenExpired } from '../utils/index.js';\n\nexport { AuthCookieHelper } from './cookie-helper.js';\n\nexport interface TokenPayload {\n jti: string;\n sub: string;\n user_id: string;\n workspace_id?: string;\n org_id?: string;\n tenant_endpoint?: string;\n iat: number;\n exp: number;\n scope?: string;\n}\n\nexport interface VerifyTokenResult {\n valid: boolean;\n payload?: TokenPayload;\n error?: string;\n}\n\nexport interface RefreshTokenResult {\n accessToken: string;\n refreshToken: string;\n expiresIn: number;\n}\n\nexport * from './cookie-helper.js';\n\n/**\n * Authentication Module\n */\nexport class AuthModule {\n constructor(\n private client: BurdenoffGraphQLClient,\n private context: SDKContext\n ) {}\n\n /**\n * Verify JWT token\n */\n public async verifyToken(token: string): Promise<VerifyTokenResult> {\n logger.debug('[Auth] Verifying token');\n\n // First check if token is expired locally\n if (isTokenExpired(token)) {\n return {\n valid: false,\n error: 'Token expired',\n };\n }\n\n const query = `\n query VerifyToken($token: String!) {\n verifyToken(token: $token) {\n valid\n payload\n error\n }\n }\n `;\n\n try {\n const response = await this.client.query<{ verifyToken: VerifyTokenResult }>(query, { token }, this.context);\n\n logger.debug('[Auth] Token verification result', { valid: response.verifyToken.valid });\n\n return response.verifyToken;\n } catch (error) {\n logger.error('[Auth] Token verification failed', { error });\n return {\n valid: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n };\n }\n }\n\n /**\n * Decode token without verification\n */\n public decodeToken(token: string): TokenPayload | null {\n const payload = parseJWT(token);\n if (!payload) {\n return null;\n }\n return payload as unknown as TokenPayload;\n }\n\n /**\n * Refresh access token using refresh token\n */\n public async refreshToken(refreshToken: string): Promise<RefreshTokenResult> {\n logger.debug('[Auth] Refreshing token');\n\n const mutation = `\n mutation RefreshToken($refreshToken: String!) {\n refreshToken(refreshToken: $refreshToken) {\n accessToken\n refreshToken\n expiresIn\n }\n }\n `;\n\n try {\n const response = await this.client.query<{ refreshToken: RefreshTokenResult }>(\n mutation,\n { refreshToken },\n this.context\n );\n\n logger.info('[Auth] Token refreshed successfully');\n\n return response.refreshToken;\n } catch (error) {\n logger.error('[Auth] Token refresh failed', { error });\n throw new AuthenticationError('Failed to refresh token', {\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n }\n }\n\n /**\n * Validate user has specific permission\n */\n public async validatePermission(userId: string, permission: string, resourceId?: string): Promise<boolean> {\n logger.debug('[Auth] Validating permission', { userId, permission, resourceId });\n\n const query = `\n query ValidatePermission($userId: ID!, $permission: String!, $resourceId: ID) {\n validatePermission(userId: $userId, permission: $permission, resourceId: $resourceId) {\n allowed\n }\n }\n `;\n\n try {\n const response = await this.client.query<{\n validatePermission: { allowed: boolean };\n }>(query, { userId, permission, resourceId }, this.context);\n\n logger.debug('[Auth] Permission validation result', {\n allowed: response.validatePermission.allowed,\n });\n\n return response.validatePermission.allowed;\n } catch (error) {\n logger.error('[Auth] Permission validation failed', { error });\n return false;\n }\n }\n\n /**\n * Check if token is valid and not expired\n */\n public isTokenValid(token: string): boolean {\n return !isTokenExpired(token);\n }\n\n /**\n * Get user ID from token\n */\n public getUserIdFromToken(token: string): string | null {\n const payload = this.decodeToken(token);\n return payload?.user_id || null;\n }\n\n /**\n * Get workspace ID from token\n */\n public getWorkspaceIdFromToken(token: string): string | null {\n const payload = this.decodeToken(token);\n return payload?.workspace_id || null;\n }\n\n /**\n * Extract all claims from token\n */\n public getTokenClaims(token: string): Record<string, unknown> | null {\n const payload = parseJWT(token);\n return payload;\n }\n\n /**\n * Check if token will expire soon (within given seconds)\n */\n public willExpireSoon(token: string, withinSeconds: number = 300): boolean {\n const payload = this.decodeToken(token);\n if (!payload || typeof payload.exp !== 'number') {\n return true;\n }\n\n const now = Math.floor(Date.now() / 1000);\n return payload.exp - now < withinSeconds;\n }\n}\n"]}
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { D as DEFAULT_I18N_CONFIG, I as I18nCapableContext, L as Locales, T as Translator, b as clearTranslationCache, c as createTranslator, d as discoverLocales, e as extractLocaleFromRequest, f as findBestMatch, j as flattenDictionary, k as getCachedTranslations, g as getLanguage, l as getLanguageFromLocale, a as getLocale, m as getRegionFromLocale, h as hasI18n, n as loadTranslationFile, o as loadTranslationsForLocale, p as normalizeLocale, q as parseAcceptLanguage, r as parseLocaleString, s as preloadAllTranslations, u as setCachedTranslations, t } from '../index-
|
|
1
|
+
export { I as I18n, c as createI18n, g as getI18n, i as initializeI18n } from '../i18n-DrdPTann.js';
|
|
2
|
+
export { D as DEFAULT_I18N_CONFIG, I as I18nCapableContext, L as Locales, T as Translator, b as clearTranslationCache, c as createTranslator, d as discoverLocales, e as extractLocaleFromRequest, f as findBestMatch, j as flattenDictionary, k as getCachedTranslations, g as getLanguage, l as getLanguageFromLocale, a as getLocale, m as getRegionFromLocale, h as hasI18n, n as loadTranslationFile, o as loadTranslationsForLocale, p as normalizeLocale, q as parseAcceptLanguage, r as parseLocaleString, s as preloadAllTranslations, u as setCachedTranslations, t } from '../index-D4l1u8VR.js';
|
|
3
|
+
export { F as FlatTranslationMap, b as I18nConfig, I as I18nContext, a as II18n, c as LanguageCode, g as LanguageInfo, L as LocaleCode, e as ParsedLocale, h as PluralForms, P as PluralTranslateFunction, R as RTL_LANGUAGES, i as TextDirection, T as TranslateFunction, f as TranslationDictionary, d as TranslationVariables, j as getTextDirection } from '../types-C8TbSdEj.js';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { a as II18n, b as I18nConfig, L as LocaleCode, F as FlatTranslationMap, T as TranslateFunction, P as PluralTranslateFunction, I as I18nContext, c as LanguageCode } from './types-C8TbSdEj.js';
|
|
2
|
+
|
|
3
|
+
declare class I18n implements II18n {
|
|
4
|
+
private config;
|
|
5
|
+
private currentLocale;
|
|
6
|
+
private supportedLocales;
|
|
7
|
+
private initialized;
|
|
8
|
+
constructor(config: I18nConfig);
|
|
9
|
+
initialize(): Promise<void>;
|
|
10
|
+
getLocale(): LocaleCode;
|
|
11
|
+
setLocale(locale: LocaleCode): void;
|
|
12
|
+
getSupportedLocales(): LocaleCode[];
|
|
13
|
+
isSupported(locale: LocaleCode): boolean;
|
|
14
|
+
loadLocale(locale: LocaleCode): Promise<void>;
|
|
15
|
+
getTranslations(locale: LocaleCode): FlatTranslationMap | undefined;
|
|
16
|
+
t: TranslateFunction;
|
|
17
|
+
tp: PluralTranslateFunction;
|
|
18
|
+
private translate;
|
|
19
|
+
private translatePlural;
|
|
20
|
+
createContext(locale: LocaleCode): I18nContext;
|
|
21
|
+
createContextFromRequest(request: Request): I18nContext;
|
|
22
|
+
getLanguageInfo(locale: LocaleCode): {
|
|
23
|
+
code: LanguageCode;
|
|
24
|
+
direction: 'ltr' | 'rtl';
|
|
25
|
+
locale: LocaleCode;
|
|
26
|
+
region?: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
declare function initializeI18n(config: I18nConfig): Promise<I18n>;
|
|
30
|
+
declare function getI18n(): I18n | null;
|
|
31
|
+
declare function createI18n(config: I18nConfig): I18n;
|
|
32
|
+
|
|
33
|
+
export { I18n as I, createI18n as c, getI18n as g, initializeI18n as i };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { I as
|
|
1
|
+
import { I as I18n, c as createI18n, g as getI18n, i as initializeI18n } from './i18n-DrdPTann.js';
|
|
2
|
+
import { I as I18nContext, d as TranslationVariables, L as LocaleCode, e as ParsedLocale, c as LanguageCode, f as TranslationDictionary, F as FlatTranslationMap, b as I18nConfig, a as II18n, g as LanguageInfo, h as PluralForms, P as PluralTranslateFunction, R as RTL_LANGUAGES, i as TextDirection, T as TranslateFunction, j as getTextDirection } from './types-C8TbSdEj.js';
|
|
2
3
|
|
|
3
4
|
interface I18nCapableContext {
|
|
4
5
|
i18n?: I18nContext;
|
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export { i as Observability } from './index-4gKQKZ2B.js';
|
|
|
24
24
|
export { i as GraphQL } from './index-joONjwLt.js';
|
|
25
25
|
export { i as Prisma } from './index-Dtf6FBaD.js';
|
|
26
26
|
export { i as Utils } from './index-PaojfSdd.js';
|
|
27
|
-
export { i as I18n, I as I18nCapableContext, T as Translator, c as createTranslator, g as getLanguage, a as getLocale, h as hasI18n, t } from './index-
|
|
27
|
+
export { i as I18n, I as I18nCapableContext, T as Translator, c as createTranslator, g as getLanguage, a as getLocale, h as hasI18n, t } from './index-D4l1u8VR.js';
|
|
28
28
|
export { i as Export } from './index-Dg4kH1VJ.js';
|
|
29
29
|
export { i as Init } from './index-BqSh1K8I.js';
|
|
30
30
|
export { i as DataLoader } from './index-DW9q22GH.js';
|
|
@@ -36,23 +36,25 @@ export { i as FeatureFlags } from './index-jOuh_TKn.js';
|
|
|
36
36
|
export { i as Captcha, R as RecaptchaVerifyOptions, a as RecaptchaVerifyResult, b as isCaptchaEnabled, v as verifyCaptcha, c as verifyCaptchaIfEnabled } from './index-B70b5mYS.js';
|
|
37
37
|
export { i as Platform } from './index-BQ1yJn1K.js';
|
|
38
38
|
export { C as CircuitBreakerConfig, h as DEFAULT_CIRCUIT_BREAKER_CONFIG, i as DEFAULT_GATEWAY_RETRY_CONFIG, D as DEFAULT_GATEWAY_ROUTING, b as DEFAULT_LAYER_RESOURCES, c as DEFAULT_LAYER_STREAMS, f as GatewayRequestHeaders, g as GatewayRetryConfig, G as GatewayRoutingConfig, L as LayerConfig, a as LayerFullConfig, d as LayerGatewayConfig, e as LayerResourceUrls, S as ServiceLayer } from './layer-CUu_cZ7d.js';
|
|
39
|
+
import './types-sKXodL2N.js';
|
|
40
|
+
import 'graphql';
|
|
41
|
+
import 'graphql-yoga';
|
|
42
|
+
import './client-CSjIrYKS.js';
|
|
43
|
+
import '@prisma/adapter-pg';
|
|
44
|
+
import 'pg';
|
|
45
|
+
import './types-C8TbSdEj.js';
|
|
39
46
|
import 'graphql-request';
|
|
40
47
|
import '@envelop/core';
|
|
41
48
|
import '@clickhouse/client';
|
|
42
49
|
import './graph-emitter-r5TylDBm.js';
|
|
43
|
-
import './client-CSjIrYKS.js';
|
|
44
|
-
import '@prisma/adapter-pg';
|
|
45
|
-
import 'pg';
|
|
46
50
|
import './prisma-extension-krXnYnrN.js';
|
|
47
51
|
import '@temporalio/client';
|
|
48
52
|
import '@temporalio/common';
|
|
49
|
-
import 'graphql';
|
|
50
53
|
import 'elysia';
|
|
51
54
|
import './types-Bo2wkjSP.js';
|
|
52
55
|
import './graphql/services/index.js';
|
|
53
|
-
import './i18n-
|
|
56
|
+
import './i18n-DrdPTann.js';
|
|
54
57
|
import './index-UhkH2eaB.js';
|
|
55
|
-
import 'graphql-yoga';
|
|
56
58
|
|
|
57
59
|
declare class ContextManager {
|
|
58
60
|
static getContext(): SDKContext | undefined;
|
package/dist/index.js
CHANGED
|
@@ -11,8 +11,8 @@ import './chunk-REF7PANB.js';
|
|
|
11
11
|
export { middleware_exports as Middleware } from './chunk-2HANKZZM.js';
|
|
12
12
|
import { TenantNotificationsModule, NotificationsModule } from './chunk-RMDKB5O7.js';
|
|
13
13
|
export { tenant_notifications_exports as Notifications, NotificationsModule } from './chunk-RMDKB5O7.js';
|
|
14
|
-
export { platform_exports as Platform } from './chunk-PHKK7725.js';
|
|
15
14
|
export { observability_exports as Observability } from './chunk-5LXDPGDH.js';
|
|
15
|
+
export { platform_exports as Platform } from './chunk-PHKK7725.js';
|
|
16
16
|
export { export_exports as Export } from './chunk-SVONGBQR.js';
|
|
17
17
|
export { feature_flags_exports as FeatureFlags } from './chunk-VWCN5PMD.js';
|
|
18
18
|
import { GraphModule } from './chunk-TGTJ653K.js';
|
|
@@ -30,8 +30,8 @@ export { init_exports as Init } from './chunk-2BG75H2K.js';
|
|
|
30
30
|
export { gateway_exports as Gateway } from './chunk-DMPS4Y53.js';
|
|
31
31
|
import './chunk-LD7ETTWG.js';
|
|
32
32
|
export { layer_exports as Layer } from './chunk-GSEPF2B6.js';
|
|
33
|
-
import { AuthModule } from './chunk-
|
|
34
|
-
export { AuthModule } from './chunk-
|
|
33
|
+
import { AuthModule } from './chunk-KKCC3Z4I.js';
|
|
34
|
+
export { AuthModule } from './chunk-KKCC3Z4I.js';
|
|
35
35
|
export { utils_exports as Utils } from './chunk-B7I4TABG.js';
|
|
36
36
|
export { cache_exports as Cache } from './chunk-PDSV3TFO.js';
|
|
37
37
|
export { captcha_exports as Captcha, isCaptchaEnabled, verifyCaptcha, verifyCaptchaIfEnabled } from './chunk-YMZEUTD2.js';
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,233 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { P as PrismaClientBase, a as PrismaClientConstructorOptions } from '../client-CSjIrYKS.js';
|
|
4
|
-
import { I as I18nContext, L as LocaleCode, d as I18n } from '../i18n-DA6IPnYy.js';
|
|
1
|
+
import { W as WorkspaceSecret, I as IActor, J as JWTPayload, S as ServerDefinition, a as ServerInstance, b as ITenant, G as GraphQLContext, Y as YogaPlugin } from '../types-sKXodL2N.js';
|
|
2
|
+
export { C as ConsentContext, E as ElysiaApp, c as IContextFilterInput, d as IOperationContext, e as IOrganization, f as IProduct, g as IProject, h as ITracking, i as IWorkspace, M as ModuleGraphConfig, P as PrismaClientConstructor, R as RESTEndpoint, j as ServerConfig, k as ServerI18nConfig, l as ServerInfo, m as WspaceGraphQLContext } from '../types-sKXodL2N.js';
|
|
5
3
|
import * as jose from 'jose';
|
|
6
4
|
import { VerifyOptions } from 'jsonwebtoken';
|
|
5
|
+
import { I as I18n } from '../i18n-DrdPTann.js';
|
|
6
|
+
import { GraphQLError } from 'graphql';
|
|
7
|
+
export { I as I18nContext, L as LocaleCode } from '../types-C8TbSdEj.js';
|
|
8
|
+
export { P as PrismaClientBase } from '../client-CSjIrYKS.js';
|
|
9
|
+
import 'graphql-yoga';
|
|
7
10
|
import '@prisma/adapter-pg';
|
|
8
11
|
import 'pg';
|
|
9
12
|
|
|
10
|
-
interface IActor {
|
|
11
|
-
id: string;
|
|
12
|
-
type: string;
|
|
13
|
-
workspace_id?: string;
|
|
14
|
-
tenant_id?: string;
|
|
15
|
-
org_id?: string;
|
|
16
|
-
isAdmin?: boolean;
|
|
17
|
-
}
|
|
18
|
-
interface ITenant {
|
|
19
|
-
id: string;
|
|
20
|
-
endpoint: string;
|
|
21
|
-
}
|
|
22
|
-
interface IOrganization {
|
|
23
|
-
id: string;
|
|
24
|
-
}
|
|
25
|
-
interface IWorkspace {
|
|
26
|
-
id: string;
|
|
27
|
-
}
|
|
28
|
-
interface IProject {
|
|
29
|
-
id: string;
|
|
30
|
-
}
|
|
31
|
-
interface IProduct {
|
|
32
|
-
id: string;
|
|
33
|
-
}
|
|
34
|
-
interface ITracking {
|
|
35
|
-
ip?: string;
|
|
36
|
-
userAgent?: string;
|
|
37
|
-
}
|
|
38
|
-
interface ConsentContext {
|
|
39
|
-
grantedBy: string;
|
|
40
|
-
scopes?: string[];
|
|
41
|
-
grantedAt?: Date;
|
|
42
|
-
expiresAt?: Date;
|
|
43
|
-
}
|
|
44
|
-
interface GraphQLContext {
|
|
45
|
-
request: Request;
|
|
46
|
-
actor: IActor | null;
|
|
47
|
-
tenant: ITenant | null;
|
|
48
|
-
organization: IOrganization | null;
|
|
49
|
-
workspace: IWorkspace | null;
|
|
50
|
-
project: IProject | null;
|
|
51
|
-
product: IProduct | null;
|
|
52
|
-
tracking: ITracking;
|
|
53
|
-
consentContext?: ConsentContext;
|
|
54
|
-
onBehalfOf: string;
|
|
55
|
-
db: unknown;
|
|
56
|
-
pubsub?: PubSub<Record<string, [unknown]>>;
|
|
57
|
-
i18n?: I18nContext;
|
|
58
|
-
responseHeaders: Headers;
|
|
59
|
-
}
|
|
60
|
-
interface WspaceGraphQLContext extends Omit<GraphQLContext, 'workspace' | 'actor'> {
|
|
61
|
-
actor: IActor;
|
|
62
|
-
workspace: IWorkspace;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
interface IOperationContext {
|
|
66
|
-
workspaceId?: string | null;
|
|
67
|
-
actorId?: string | null;
|
|
68
|
-
projectId?: string | null;
|
|
69
|
-
appId?: string | null;
|
|
70
|
-
custom?: Record<string, unknown> | null;
|
|
71
|
-
}
|
|
72
|
-
interface IContextFilterInput {
|
|
73
|
-
workspaceId?: string | null;
|
|
74
|
-
actorId?: string | null;
|
|
75
|
-
projectId?: string | null;
|
|
76
|
-
appId?: string | null;
|
|
77
|
-
}
|
|
78
|
-
interface ServerI18nConfig {
|
|
79
|
-
enabled?: boolean;
|
|
80
|
-
defaultLocale?: LocaleCode;
|
|
81
|
-
fallbackLocale?: LocaleCode;
|
|
82
|
-
localesPath?: string;
|
|
83
|
-
supportedLocales?: LocaleCode[];
|
|
84
|
-
namespace?: string;
|
|
85
|
-
lazyLoad?: boolean;
|
|
86
|
-
logMissing?: boolean;
|
|
87
|
-
}
|
|
88
|
-
interface ServerConfig {
|
|
89
|
-
serviceName: string;
|
|
90
|
-
serviceVersion?: string;
|
|
91
|
-
port: number;
|
|
92
|
-
host?: string;
|
|
93
|
-
environment?: 'development' | 'staging' | 'production';
|
|
94
|
-
boundary?: 'wspace' | 'global';
|
|
95
|
-
graphqlEndpoint?: string;
|
|
96
|
-
corsOrigins?: string | string[];
|
|
97
|
-
sessionSecret?: string;
|
|
98
|
-
enablePlayground?: boolean;
|
|
99
|
-
enableIntrospection?: boolean;
|
|
100
|
-
csrfSkipRoutes?: string[];
|
|
101
|
-
loginEndpoints?: string[];
|
|
102
|
-
enableCSRF?: boolean;
|
|
103
|
-
enableSessionSecurity?: boolean;
|
|
104
|
-
i18n?: ServerI18nConfig;
|
|
105
|
-
workspaceGuard?: {
|
|
106
|
-
enabled?: boolean;
|
|
107
|
-
whitelistedOperations?: string[];
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
interface ModuleGraphConfig {
|
|
111
|
-
getSchema: () => unknown;
|
|
112
|
-
exportAll: (orgId?: string, workspaceId?: string) => Promise<unknown>;
|
|
113
|
-
exportEntities: (orgId?: string, workspaceId?: string, types?: string[]) => Promise<unknown>;
|
|
114
|
-
exportRelationships: (orgId?: string, workspaceId?: string) => Promise<unknown>;
|
|
115
|
-
initialize: () => Promise<void>;
|
|
116
|
-
shutdown: () => Promise<void>;
|
|
117
|
-
}
|
|
118
|
-
interface RESTEndpoint {
|
|
119
|
-
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
120
|
-
path: string;
|
|
121
|
-
handler: (request: Request, context: GraphQLContext, rawBody?: string) => Promise<unknown>;
|
|
122
|
-
rawBody?: boolean;
|
|
123
|
-
}
|
|
124
|
-
type PrismaClientConstructor<T extends PrismaClientBase = PrismaClientBase> = new (options: PrismaClientConstructorOptions) => T;
|
|
125
|
-
interface YogaPlugin {
|
|
126
|
-
onExecute?: (args: {
|
|
127
|
-
args: {
|
|
128
|
-
document?: unknown;
|
|
129
|
-
operationName?: string | null;
|
|
130
|
-
variableValues?: Record<string, unknown>;
|
|
131
|
-
contextValue?: unknown;
|
|
132
|
-
};
|
|
133
|
-
}) => {
|
|
134
|
-
onExecuteDone: (args: {
|
|
135
|
-
result: unknown;
|
|
136
|
-
}) => void;
|
|
137
|
-
} | undefined | void;
|
|
138
|
-
onSubscribe?: (args: {
|
|
139
|
-
args: unknown;
|
|
140
|
-
}) => void;
|
|
141
|
-
[key: string]: unknown;
|
|
142
|
-
}
|
|
143
|
-
interface ServerDefinition {
|
|
144
|
-
config: ServerConfig;
|
|
145
|
-
prismaClient: PrismaClientConstructor;
|
|
146
|
-
schema: GraphQLSchema;
|
|
147
|
-
moduleGraph?: ModuleGraphConfig;
|
|
148
|
-
restEndpoints?: RESTEndpoint[];
|
|
149
|
-
yogaPlugins?: YogaPlugin[];
|
|
150
|
-
buildContext?: (defaultContext: GraphQLContext) => Promise<GraphQLContext> | GraphQLContext;
|
|
151
|
-
workspaceExtensionConfig?: {
|
|
152
|
-
strictMode?: boolean;
|
|
153
|
-
excludeModels?: string[];
|
|
154
|
-
excludeModelsFromReadIsolation?: string[];
|
|
155
|
-
allowedUnguardedOperations?: string[];
|
|
156
|
-
enableReadIsolation?: boolean;
|
|
157
|
-
enableDeleteIsolation?: boolean;
|
|
158
|
-
enableUpdateWhereIsolation?: boolean;
|
|
159
|
-
debug?: boolean;
|
|
160
|
-
};
|
|
161
|
-
disableWorkspaceExtension?: boolean;
|
|
162
|
-
onShutdown?: () => Promise<void>;
|
|
163
|
-
}
|
|
164
|
-
interface BunServerHandle {
|
|
165
|
-
stop(): void;
|
|
166
|
-
port: number;
|
|
167
|
-
hostname: string;
|
|
168
|
-
}
|
|
169
|
-
interface ElysiaLikeServer {
|
|
170
|
-
server: BunServerHandle | null;
|
|
171
|
-
listen(options: {
|
|
172
|
-
port: number;
|
|
173
|
-
hostname?: string;
|
|
174
|
-
}): ElysiaLikeServer;
|
|
175
|
-
use(plugin: unknown): ElysiaLikeServer;
|
|
176
|
-
all(path: string, handler: (ctx: {
|
|
177
|
-
request: Request;
|
|
178
|
-
}) => unknown): ElysiaLikeServer;
|
|
179
|
-
get(path: string, handler: (ctx: {
|
|
180
|
-
request: Request;
|
|
181
|
-
query: Record<string, string | undefined>;
|
|
182
|
-
}) => unknown): ElysiaLikeServer;
|
|
183
|
-
post(path: string, handler: (ctx: {
|
|
184
|
-
request: Request;
|
|
185
|
-
}) => unknown): ElysiaLikeServer;
|
|
186
|
-
put(path: string, handler: (ctx: {
|
|
187
|
-
request: Request;
|
|
188
|
-
}) => unknown): ElysiaLikeServer;
|
|
189
|
-
patch(path: string, handler: (ctx: {
|
|
190
|
-
request: Request;
|
|
191
|
-
}) => unknown): ElysiaLikeServer;
|
|
192
|
-
delete(path: string, handler: (ctx: {
|
|
193
|
-
request: Request;
|
|
194
|
-
}) => unknown): ElysiaLikeServer;
|
|
195
|
-
}
|
|
196
|
-
type ElysiaApp = ElysiaLikeServer;
|
|
197
|
-
interface ServerInstance {
|
|
198
|
-
app: ElysiaApp;
|
|
199
|
-
server: BunServerHandle | null;
|
|
200
|
-
start: () => Promise<void>;
|
|
201
|
-
stop: () => Promise<void>;
|
|
202
|
-
getInfo: () => ServerInfo;
|
|
203
|
-
}
|
|
204
|
-
interface ServerInfo {
|
|
205
|
-
serviceName: string;
|
|
206
|
-
serviceVersion: string;
|
|
207
|
-
environment: string;
|
|
208
|
-
port: number;
|
|
209
|
-
host: string;
|
|
210
|
-
graphqlEndpoint: string;
|
|
211
|
-
startedAt: string;
|
|
212
|
-
uptime: number;
|
|
213
|
-
}
|
|
214
|
-
interface JWTPayload {
|
|
215
|
-
sub: string;
|
|
216
|
-
actor_type?: string;
|
|
217
|
-
workspace_id?: string;
|
|
218
|
-
org_id?: string;
|
|
219
|
-
tenant_id?: string;
|
|
220
|
-
iat?: number;
|
|
221
|
-
exp?: number;
|
|
222
|
-
[key: string]: unknown;
|
|
223
|
-
}
|
|
224
|
-
interface WorkspaceSecret {
|
|
225
|
-
kty: string;
|
|
226
|
-
k: string;
|
|
227
|
-
alg?: string;
|
|
228
|
-
[key: string]: unknown;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
13
|
type FetchWorkspaceSecretFn = (workspaceId: string) => Promise<WorkspaceSecret | null>;
|
|
232
14
|
interface AuthConfig {
|
|
233
15
|
fetchWorkspaceSecret: FetchWorkspaceSecretFn;
|
|
@@ -399,4 +181,4 @@ declare function createHumanReadableErrorPlugin(options?: ErrorNormalizationOpti
|
|
|
399
181
|
declare function formatHttpError(error: unknown, options?: ErrorNormalizationOptions): HttpErrorResult;
|
|
400
182
|
declare function createHttpErrorResponse(error: unknown, options?: ErrorNormalizationOptions): Response;
|
|
401
183
|
|
|
402
|
-
export { type AuthConfig, type
|
|
184
|
+
export { type AuthConfig, type ContextBuilderOptions, type ErrorNormalizationOptions, type FetchWorkspaceSecretFn, GraphQLContext, type HttpErrorPayload, type HttpErrorResult, IActor, ITenant, JWTPayload, type NormalizedErrorState, ServerDefinition, ServerInstance, type UserFacingErrorOptions, UserFacingGraphQLError, type WorkspaceGuardConfig, WorkspaceSecret, YogaPlugin, authCheck, buildContext, configureAuth, configureContext, configureDefaultAuth, configureServerAuth, createHttpErrorResponse, createHumanReadableErrorPlugin, createServer, createWorkspaceGuardPlugin, decodeJWT, fetchWorkspaceSecret, formatHttpError, generateSymmetricSecret, getContextOptions, normalizeError, normalizeExecutionResultErrors, normalizeGraphQLResponse, normalizeGraphQLResponsePayload, orgCheck, requireWorkspace, tenantCheck, toUserFacingGraphQLError, verifyJWT, workspaceCheck };
|
|
@@ -68,34 +68,4 @@ interface LanguageInfo {
|
|
|
68
68
|
declare const RTL_LANGUAGES: LanguageCode[];
|
|
69
69
|
declare function getTextDirection(language: LanguageCode): TextDirection;
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
private config;
|
|
73
|
-
private currentLocale;
|
|
74
|
-
private supportedLocales;
|
|
75
|
-
private initialized;
|
|
76
|
-
constructor(config: I18nConfig);
|
|
77
|
-
initialize(): Promise<void>;
|
|
78
|
-
getLocale(): LocaleCode;
|
|
79
|
-
setLocale(locale: LocaleCode): void;
|
|
80
|
-
getSupportedLocales(): LocaleCode[];
|
|
81
|
-
isSupported(locale: LocaleCode): boolean;
|
|
82
|
-
loadLocale(locale: LocaleCode): Promise<void>;
|
|
83
|
-
getTranslations(locale: LocaleCode): FlatTranslationMap | undefined;
|
|
84
|
-
t: TranslateFunction;
|
|
85
|
-
tp: PluralTranslateFunction;
|
|
86
|
-
private translate;
|
|
87
|
-
private translatePlural;
|
|
88
|
-
createContext(locale: LocaleCode): I18nContext;
|
|
89
|
-
createContextFromRequest(request: Request): I18nContext;
|
|
90
|
-
getLanguageInfo(locale: LocaleCode): {
|
|
91
|
-
code: LanguageCode;
|
|
92
|
-
direction: 'ltr' | 'rtl';
|
|
93
|
-
locale: LocaleCode;
|
|
94
|
-
region?: string;
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
declare function initializeI18n(config: I18nConfig): Promise<I18n>;
|
|
98
|
-
declare function getI18n(): I18n | null;
|
|
99
|
-
declare function createI18n(config: I18nConfig): I18n;
|
|
100
|
-
|
|
101
|
-
export { type FlatTranslationMap as F, type I18nContext as I, type LocaleCode as L, type ParsedLocale as P, RTL_LANGUAGES as R, type TranslationVariables as T, type LanguageCode as a, type TranslationDictionary as b, type I18nConfig as c, I18n as d, type II18n as e, type LanguageInfo as f, type PluralForms as g, type PluralTranslateFunction as h, type TextDirection as i, type TranslateFunction as j, createI18n as k, getI18n as l, getTextDirection as m, initializeI18n as n };
|
|
71
|
+
export { type FlatTranslationMap as F, type I18nContext as I, type LocaleCode as L, type PluralTranslateFunction as P, RTL_LANGUAGES as R, type TranslateFunction as T, type II18n as a, type I18nConfig as b, type LanguageCode as c, type TranslationVariables as d, type ParsedLocale as e, type TranslationDictionary as f, type LanguageInfo as g, type PluralForms as h, type TextDirection as i, getTextDirection as j };
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { GraphQLSchema } from 'graphql';
|
|
2
|
+
import { PubSub } from 'graphql-yoga';
|
|
3
|
+
import { P as PrismaClientBase, a as PrismaClientConstructorOptions } from './client-CSjIrYKS.js';
|
|
4
|
+
import { I as I18nContext, L as LocaleCode } from './types-C8TbSdEj.js';
|
|
5
|
+
|
|
6
|
+
interface IActor {
|
|
7
|
+
id: string;
|
|
8
|
+
type: string;
|
|
9
|
+
workspace_id?: string;
|
|
10
|
+
tenant_id?: string;
|
|
11
|
+
org_id?: string;
|
|
12
|
+
isAdmin?: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface ITenant {
|
|
15
|
+
id: string;
|
|
16
|
+
endpoint: string;
|
|
17
|
+
}
|
|
18
|
+
interface IOrganization {
|
|
19
|
+
id: string;
|
|
20
|
+
}
|
|
21
|
+
interface IWorkspace {
|
|
22
|
+
id: string;
|
|
23
|
+
}
|
|
24
|
+
interface IProject {
|
|
25
|
+
id: string;
|
|
26
|
+
}
|
|
27
|
+
interface IProduct {
|
|
28
|
+
id: string;
|
|
29
|
+
}
|
|
30
|
+
interface ITracking {
|
|
31
|
+
ip?: string;
|
|
32
|
+
userAgent?: string;
|
|
33
|
+
}
|
|
34
|
+
interface ConsentContext {
|
|
35
|
+
grantedBy: string;
|
|
36
|
+
scopes?: string[];
|
|
37
|
+
grantedAt?: Date;
|
|
38
|
+
expiresAt?: Date;
|
|
39
|
+
}
|
|
40
|
+
interface GraphQLContext {
|
|
41
|
+
request: Request;
|
|
42
|
+
actor: IActor | null;
|
|
43
|
+
tenant: ITenant | null;
|
|
44
|
+
organization: IOrganization | null;
|
|
45
|
+
workspace: IWorkspace | null;
|
|
46
|
+
project: IProject | null;
|
|
47
|
+
product: IProduct | null;
|
|
48
|
+
tracking: ITracking;
|
|
49
|
+
consentContext?: ConsentContext;
|
|
50
|
+
onBehalfOf: string;
|
|
51
|
+
db: unknown;
|
|
52
|
+
pubsub?: PubSub<Record<string, [unknown]>>;
|
|
53
|
+
i18n?: I18nContext;
|
|
54
|
+
responseHeaders: Headers;
|
|
55
|
+
}
|
|
56
|
+
interface WspaceGraphQLContext extends Omit<GraphQLContext, 'workspace' | 'actor'> {
|
|
57
|
+
actor: IActor;
|
|
58
|
+
workspace: IWorkspace;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface IOperationContext {
|
|
62
|
+
workspaceId?: string | null;
|
|
63
|
+
actorId?: string | null;
|
|
64
|
+
projectId?: string | null;
|
|
65
|
+
appId?: string | null;
|
|
66
|
+
custom?: Record<string, unknown> | null;
|
|
67
|
+
}
|
|
68
|
+
interface IContextFilterInput {
|
|
69
|
+
workspaceId?: string | null;
|
|
70
|
+
actorId?: string | null;
|
|
71
|
+
projectId?: string | null;
|
|
72
|
+
appId?: string | null;
|
|
73
|
+
}
|
|
74
|
+
interface ServerI18nConfig {
|
|
75
|
+
enabled?: boolean;
|
|
76
|
+
defaultLocale?: LocaleCode;
|
|
77
|
+
fallbackLocale?: LocaleCode;
|
|
78
|
+
localesPath?: string;
|
|
79
|
+
supportedLocales?: LocaleCode[];
|
|
80
|
+
namespace?: string;
|
|
81
|
+
lazyLoad?: boolean;
|
|
82
|
+
logMissing?: boolean;
|
|
83
|
+
}
|
|
84
|
+
interface ServerConfig {
|
|
85
|
+
serviceName: string;
|
|
86
|
+
serviceVersion?: string;
|
|
87
|
+
port: number;
|
|
88
|
+
host?: string;
|
|
89
|
+
environment?: 'development' | 'staging' | 'production';
|
|
90
|
+
boundary?: 'wspace' | 'global';
|
|
91
|
+
graphqlEndpoint?: string;
|
|
92
|
+
corsOrigins?: string | string[];
|
|
93
|
+
sessionSecret?: string;
|
|
94
|
+
enablePlayground?: boolean;
|
|
95
|
+
enableIntrospection?: boolean;
|
|
96
|
+
csrfSkipRoutes?: string[];
|
|
97
|
+
loginEndpoints?: string[];
|
|
98
|
+
enableCSRF?: boolean;
|
|
99
|
+
enableSessionSecurity?: boolean;
|
|
100
|
+
i18n?: ServerI18nConfig;
|
|
101
|
+
workspaceGuard?: {
|
|
102
|
+
enabled?: boolean;
|
|
103
|
+
whitelistedOperations?: string[];
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
interface ModuleGraphConfig {
|
|
107
|
+
getSchema: () => unknown;
|
|
108
|
+
exportAll: (orgId?: string, workspaceId?: string) => Promise<unknown>;
|
|
109
|
+
exportEntities: (orgId?: string, workspaceId?: string, types?: string[]) => Promise<unknown>;
|
|
110
|
+
exportRelationships: (orgId?: string, workspaceId?: string) => Promise<unknown>;
|
|
111
|
+
initialize: () => Promise<void>;
|
|
112
|
+
shutdown: () => Promise<void>;
|
|
113
|
+
}
|
|
114
|
+
interface RESTEndpoint {
|
|
115
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
116
|
+
path: string;
|
|
117
|
+
handler: (request: Request, context: GraphQLContext, rawBody?: string) => Promise<unknown>;
|
|
118
|
+
rawBody?: boolean;
|
|
119
|
+
}
|
|
120
|
+
type PrismaClientConstructor<T extends PrismaClientBase = PrismaClientBase> = new (options: PrismaClientConstructorOptions) => T;
|
|
121
|
+
interface YogaPlugin {
|
|
122
|
+
onExecute?: (args: {
|
|
123
|
+
args: {
|
|
124
|
+
document?: unknown;
|
|
125
|
+
operationName?: string | null;
|
|
126
|
+
variableValues?: Record<string, unknown>;
|
|
127
|
+
contextValue?: unknown;
|
|
128
|
+
};
|
|
129
|
+
}) => {
|
|
130
|
+
onExecuteDone: (args: {
|
|
131
|
+
result: unknown;
|
|
132
|
+
}) => void;
|
|
133
|
+
} | undefined | void;
|
|
134
|
+
onSubscribe?: (args: {
|
|
135
|
+
args: unknown;
|
|
136
|
+
}) => void;
|
|
137
|
+
[key: string]: unknown;
|
|
138
|
+
}
|
|
139
|
+
interface ServerDefinition {
|
|
140
|
+
config: ServerConfig;
|
|
141
|
+
prismaClient: PrismaClientConstructor;
|
|
142
|
+
schema: GraphQLSchema;
|
|
143
|
+
moduleGraph?: ModuleGraphConfig;
|
|
144
|
+
restEndpoints?: RESTEndpoint[];
|
|
145
|
+
yogaPlugins?: YogaPlugin[];
|
|
146
|
+
buildContext?: (defaultContext: GraphQLContext) => Promise<GraphQLContext> | GraphQLContext;
|
|
147
|
+
workspaceExtensionConfig?: {
|
|
148
|
+
strictMode?: boolean;
|
|
149
|
+
excludeModels?: string[];
|
|
150
|
+
excludeModelsFromReadIsolation?: string[];
|
|
151
|
+
allowedUnguardedOperations?: string[];
|
|
152
|
+
enableReadIsolation?: boolean;
|
|
153
|
+
enableDeleteIsolation?: boolean;
|
|
154
|
+
enableUpdateWhereIsolation?: boolean;
|
|
155
|
+
debug?: boolean;
|
|
156
|
+
};
|
|
157
|
+
disableWorkspaceExtension?: boolean;
|
|
158
|
+
onShutdown?: () => Promise<void>;
|
|
159
|
+
}
|
|
160
|
+
interface BunServerHandle {
|
|
161
|
+
stop(): void;
|
|
162
|
+
port: number;
|
|
163
|
+
hostname: string;
|
|
164
|
+
}
|
|
165
|
+
interface ElysiaLikeServer {
|
|
166
|
+
server: BunServerHandle | null;
|
|
167
|
+
listen(options: {
|
|
168
|
+
port: number;
|
|
169
|
+
hostname?: string;
|
|
170
|
+
}): ElysiaLikeServer;
|
|
171
|
+
use(plugin: unknown): ElysiaLikeServer;
|
|
172
|
+
all(path: string, handler: (ctx: {
|
|
173
|
+
request: Request;
|
|
174
|
+
}) => unknown): ElysiaLikeServer;
|
|
175
|
+
get(path: string, handler: (ctx: {
|
|
176
|
+
request: Request;
|
|
177
|
+
query: Record<string, string | undefined>;
|
|
178
|
+
}) => unknown): ElysiaLikeServer;
|
|
179
|
+
post(path: string, handler: (ctx: {
|
|
180
|
+
request: Request;
|
|
181
|
+
}) => unknown): ElysiaLikeServer;
|
|
182
|
+
put(path: string, handler: (ctx: {
|
|
183
|
+
request: Request;
|
|
184
|
+
}) => unknown): ElysiaLikeServer;
|
|
185
|
+
patch(path: string, handler: (ctx: {
|
|
186
|
+
request: Request;
|
|
187
|
+
}) => unknown): ElysiaLikeServer;
|
|
188
|
+
delete(path: string, handler: (ctx: {
|
|
189
|
+
request: Request;
|
|
190
|
+
}) => unknown): ElysiaLikeServer;
|
|
191
|
+
}
|
|
192
|
+
type ElysiaApp = ElysiaLikeServer;
|
|
193
|
+
interface ServerInstance {
|
|
194
|
+
app: ElysiaApp;
|
|
195
|
+
server: BunServerHandle | null;
|
|
196
|
+
start: () => Promise<void>;
|
|
197
|
+
stop: () => Promise<void>;
|
|
198
|
+
getInfo: () => ServerInfo;
|
|
199
|
+
}
|
|
200
|
+
interface ServerInfo {
|
|
201
|
+
serviceName: string;
|
|
202
|
+
serviceVersion: string;
|
|
203
|
+
environment: string;
|
|
204
|
+
port: number;
|
|
205
|
+
host: string;
|
|
206
|
+
graphqlEndpoint: string;
|
|
207
|
+
startedAt: string;
|
|
208
|
+
uptime: number;
|
|
209
|
+
}
|
|
210
|
+
interface JWTPayload {
|
|
211
|
+
sub: string;
|
|
212
|
+
actor_type?: string;
|
|
213
|
+
workspace_id?: string;
|
|
214
|
+
org_id?: string;
|
|
215
|
+
tenant_id?: string;
|
|
216
|
+
iat?: number;
|
|
217
|
+
exp?: number;
|
|
218
|
+
[key: string]: unknown;
|
|
219
|
+
}
|
|
220
|
+
interface WorkspaceSecret {
|
|
221
|
+
kty: string;
|
|
222
|
+
k: string;
|
|
223
|
+
alg?: string;
|
|
224
|
+
[key: string]: unknown;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export type { ConsentContext as C, ElysiaApp as E, GraphQLContext as G, IActor as I, JWTPayload as J, ModuleGraphConfig as M, PrismaClientConstructor as P, RESTEndpoint as R, ServerDefinition as S, WorkspaceSecret as W, YogaPlugin as Y, ServerInstance as a, ITenant as b, IContextFilterInput as c, IOperationContext as d, IOrganization as e, IProduct as f, IProject as g, ITracking as h, IWorkspace as i, ServerConfig as j, ServerI18nConfig as k, ServerInfo as l, WspaceGraphQLContext as m };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@burdenoff/be-sdk",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.530.1",
|
|
4
4
|
"description": "Backend SDK for Burdenoff products providing unified access to notifications, RBAC, activity tracking, usage monitoring, and more",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/auth/index.ts"],"names":["ACCESS_TOKEN_COOKIE","REFRESH_TOKEN_COOKIE","ACCESS_TOKEN_MAX_AGE","REFRESH_TOKEN_MAX_AGE","REFRESH_TOKEN_REMEMBER_MAX_AGE","buildCookieString","name","value","maxAge","buildClearCookieString","AuthCookieHelper","setAuthCookies","context","tokens","options","headers","responseHeaders","rememberMe","refreshMaxAge","append","accessToken","refreshToken","clearAuthCookies","AuthModule","client","verifyToken","token","logger","debug","isTokenExpired","valid","error","query","response","Error","message","decodeToken","payload","parseJWT","mutation","info","AuthenticationError","validatePermission","userId","permission","resourceId","allowed","isTokenValid","getUserIdFromToken","user_id","getWorkspaceIdFromToken","workspace_id","getTokenClaims","willExpireSoon","withinSeconds","exp","now","Math","floor","Date"],"mappings":";;;;;;AAgBA,IAAMA,mBAAAA,GAAsB,iBAAA;AAC5B,IAAMC,oBAAAA,GAAuB,kBAAA;AAC7B,IAAMC,uBAAuB,EAAA,GAAK,EAAA;AAClC,IAAMC,qBAAAA,GAAwB,EAAA,GAAK,EAAA,GAAK,EAAA,GAAK,EAAA;AAC7C,IAAMC,8BAAAA,GAAiC,EAAA,GAAK,EAAA,GAAK,EAAA,GAAK,EAAA;AAEtD,SAASC,iBAAAA,CAAkBC,IAAAA,EAAcC,KAAAA,EAAeC,MAAAA,EAAc;AACpE,EAAA,OAAO,CAAA,EAAGF,IAAAA,CAAAA,CAAAA,EAAQC,KAAAA,aAAkBC,MAAAA,CAAAA,mCAAAA,CAAAA;AACtC;AAFSH,MAAAA,CAAAA,iBAAAA,EAAAA,mBAAAA,CAAAA;AAIT,SAASI,uBAAuBH,IAAAA,EAAY;AAC1C,EAAA,OAAO,GAAGA,IAAAA,CAAAA,+CAAAA,CAAAA;AACZ;AAFSG,MAAAA,CAAAA,sBAAAA,EAAAA,wBAAAA,CAAAA;AAIF,IAAMC,gBAAAA,GAAmB;EAC9BC,cAAAA,CACEC,OAAAA,EACAC,QACAC,OAAAA,EAAkC;AAElC,IAAA,MAAMC,UAAUH,OAAAA,CAAQI,eAAAA;AACxB,IAAA,IAAI,CAACD,OAAAA,EAAS;AAEd,IAAA,MAAME,UAAAA,GAAaH,SAASG,UAAAA,IAAc,KAAA;AAC1C,IAAA,MAAMC,aAAAA,GAAgBD,aAAab,8BAAAA,GAAiCD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AACjC,IAAA,OAAOW,SAASc,YAAAA,IAAgB,IAAA;AAClC,EAAA;;;;AAKOC,EAAAA,cAAAA,CAAe1B,KAAAA,EAA+C;AACnE,IAAA,MAAMW,OAAAA,GAAUC,SAASZ,KAAAA,CAAAA;AACzB,IAAA,OAAOW,OAAAA;AACT,EAAA;;;;EAKOgB,cAAAA,CAAe3B,KAAAA,EAAe4B,gBAAwB,GAAA,EAAc;AACzE,IAAA,MAAMjB,OAAAA,GAAU,IAAA,CAAKD,WAAAA,CAAYV,KAAAA,CAAAA;AACjC,IAAA,IAAI,CAACW,OAAAA,IAAW,OAAOA,OAAAA,CAAQkB,QAAQ,QAAA,EAAU;AAC/C,MAAA,OAAO,IAAA;AACT,IAAA;AAEA,IAAA,MAAMC,MAAMC,IAAAA,CAAKC,KAAAA,CAAMC,IAAAA,CAAKH,GAAAA,KAAQ,GAAA,CAAA;AACpC,IAAA,OAAOnB,OAAAA,CAAQkB,MAAMC,GAAAA,GAAMF,aAAAA;AAC7B,EAAA;AACF","file":"chunk-7NUQXGA7.js","sourcesContent":["/**\n * Authentication Module\n * JWT verification, token management, and user authentication\n */\n\nimport type { BurdenoffGraphQLClient } from '../client/graphql.js';\nimport type { SDKContext } from '../types/index.js';\nimport { AuthenticationError } from '../types/index.js';\nimport { logger } from '../logger/index.js';\nimport { parseJWT, isTokenExpired } from '../utils/index.js';\n\ninterface CookieContext {\n responseHeaders?: Headers;\n [key: string]: unknown;\n}\n\nconst ACCESS_TOKEN_COOKIE = 'bf_access_token';\nconst REFRESH_TOKEN_COOKIE = 'bf_refresh_token';\nconst ACCESS_TOKEN_MAX_AGE = 15 * 60; // 15 minutes\nconst REFRESH_TOKEN_MAX_AGE = 30 * 24 * 60 * 60; // 30 days\nconst REFRESH_TOKEN_REMEMBER_MAX_AGE = 30 * 24 * 60 * 60; // 30 days (same, controlled by backend)\n\nfunction buildCookieString(name: string, value: string, maxAge: number): string {\n return `${name}=${value}; Max-Age=${maxAge}; Path=/; HttpOnly; SameSite=Strict`;\n}\n\nfunction buildClearCookieString(name: string): string {\n return `${name}=; Max-Age=0; Path=/; HttpOnly; SameSite=Strict`;\n}\n\nexport const AuthCookieHelper = {\n setAuthCookies(\n context: CookieContext,\n tokens: { accessToken: string; refreshToken: string },\n options?: { rememberMe?: boolean }\n ): void {\n const headers = context.responseHeaders;\n if (!headers) return;\n\n const rememberMe = options?.rememberMe ?? false;\n const refreshMaxAge = rememberMe ? REFRESH_TOKEN_REMEMBER_MAX_AGE : REFRESH_TOKEN_MAX_AGE;\n\n headers.append('Set-Cookie', buildCookieString(ACCESS_TOKEN_COOKIE, tokens.accessToken, ACCESS_TOKEN_MAX_AGE));\n headers.append('Set-Cookie', buildCookieString(REFRESH_TOKEN_COOKIE, tokens.refreshToken, refreshMaxAge));\n },\n\n clearAuthCookies(context: CookieContext): void {\n const headers = context.responseHeaders;\n if (!headers) return;\n\n headers.append('Set-Cookie', buildClearCookieString(ACCESS_TOKEN_COOKIE));\n headers.append('Set-Cookie', buildClearCookieString(REFRESH_TOKEN_COOKIE));\n },\n};\n\nexport interface TokenPayload {\n jti: string;\n sub: string;\n user_id: string;\n workspace_id?: string;\n org_id?: string;\n tenant_endpoint?: string;\n iat: number;\n exp: number;\n scope?: string;\n}\n\nexport interface VerifyTokenResult {\n valid: boolean;\n payload?: TokenPayload;\n error?: string;\n}\n\nexport interface RefreshTokenResult {\n accessToken: string;\n refreshToken: string;\n expiresIn: number;\n}\n\nexport * from './cookie-helper.js';\n\n/**\n * Authentication Module\n */\nexport class AuthModule {\n constructor(\n private client: BurdenoffGraphQLClient,\n private context: SDKContext\n ) {}\n\n /**\n * Verify JWT token\n */\n public async verifyToken(token: string): Promise<VerifyTokenResult> {\n logger.debug('[Auth] Verifying token');\n\n // First check if token is expired locally\n if (isTokenExpired(token)) {\n return {\n valid: false,\n error: 'Token expired',\n };\n }\n\n const query = `\n query VerifyToken($token: String!) {\n verifyToken(token: $token) {\n valid\n payload\n error\n }\n }\n `;\n\n try {\n const response = await this.client.query<{ verifyToken: VerifyTokenResult }>(query, { token }, this.context);\n\n logger.debug('[Auth] Token verification result', { valid: response.verifyToken.valid });\n\n return response.verifyToken;\n } catch (error) {\n logger.error('[Auth] Token verification failed', { error });\n return {\n valid: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n };\n }\n }\n\n /**\n * Decode token without verification\n */\n public decodeToken(token: string): TokenPayload | null {\n const payload = parseJWT(token);\n if (!payload) {\n return null;\n }\n return payload as unknown as TokenPayload;\n }\n\n /**\n * Refresh access token using refresh token\n */\n public async refreshToken(refreshToken: string): Promise<RefreshTokenResult> {\n logger.debug('[Auth] Refreshing token');\n\n const mutation = `\n mutation RefreshToken($refreshToken: String!) {\n refreshToken(refreshToken: $refreshToken) {\n accessToken\n refreshToken\n expiresIn\n }\n }\n `;\n\n try {\n const response = await this.client.query<{ refreshToken: RefreshTokenResult }>(\n mutation,\n { refreshToken },\n this.context\n );\n\n logger.info('[Auth] Token refreshed successfully');\n\n return response.refreshToken;\n } catch (error) {\n logger.error('[Auth] Token refresh failed', { error });\n throw new AuthenticationError('Failed to refresh token', {\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n }\n }\n\n /**\n * Validate user has specific permission\n */\n public async validatePermission(userId: string, permission: string, resourceId?: string): Promise<boolean> {\n logger.debug('[Auth] Validating permission', { userId, permission, resourceId });\n\n const query = `\n query ValidatePermission($userId: ID!, $permission: String!, $resourceId: ID) {\n validatePermission(userId: $userId, permission: $permission, resourceId: $resourceId) {\n allowed\n }\n }\n `;\n\n try {\n const response = await this.client.query<{\n validatePermission: { allowed: boolean };\n }>(query, { userId, permission, resourceId }, this.context);\n\n logger.debug('[Auth] Permission validation result', {\n allowed: response.validatePermission.allowed,\n });\n\n return response.validatePermission.allowed;\n } catch (error) {\n logger.error('[Auth] Permission validation failed', { error });\n return false;\n }\n }\n\n /**\n * Check if token is valid and not expired\n */\n public isTokenValid(token: string): boolean {\n return !isTokenExpired(token);\n }\n\n /**\n * Get user ID from token\n */\n public getUserIdFromToken(token: string): string | null {\n const payload = this.decodeToken(token);\n return payload?.user_id || null;\n }\n\n /**\n * Get workspace ID from token\n */\n public getWorkspaceIdFromToken(token: string): string | null {\n const payload = this.decodeToken(token);\n return payload?.workspace_id || null;\n }\n\n /**\n * Extract all claims from token\n */\n public getTokenClaims(token: string): Record<string, unknown> | null {\n const payload = parseJWT(token);\n return payload;\n }\n\n /**\n * Check if token will expire soon (within given seconds)\n */\n public willExpireSoon(token: string, withinSeconds: number = 300): boolean {\n const payload = this.decodeToken(token);\n if (!payload || typeof payload.exp !== 'number') {\n return true;\n }\n\n const now = Math.floor(Date.now() / 1000);\n return payload.exp - now < withinSeconds;\n }\n}\n"]}
|