@burdenoff/be-sdk 2026.1030.1 → 2026.1031.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.d.ts +2 -2
- package/dist/{chunk-6GL4SLU7.js → chunk-5CJBZZLS.js} +82 -15
- package/dist/chunk-5CJBZZLS.js.map +1 -0
- package/dist/feature-flags/index.d.ts +3 -3
- package/dist/i18n/index.d.ts +3 -3
- package/dist/{i18n-DrdPTann.d.ts → i18n-Qm2AkPC-.d.ts} +1 -1
- package/dist/{index-B2YkcG0J.d.ts → index--yvpa6ay.d.ts} +1 -1
- package/dist/{index-D4l1u8VR.d.ts → index-lFffh5-G.d.ts} +2 -2
- package/dist/index.d.ts +5 -5
- package/dist/{sdk-YS2M6RF5.js → sdk-L75WWUP3.js} +5 -2
- package/dist/sdk-L75WWUP3.js.map +1 -0
- package/dist/server/index.d.ts +5 -75
- package/dist/server/index.js +6 -4
- package/dist/server/index.js.map +1 -1
- package/dist/telemetry/index.d.ts +8 -1
- package/dist/telemetry/index.js +22 -4
- package/dist/telemetry/index.js.map +1 -1
- package/dist/{types-C8TbSdEj.d.ts → types-DVpvrAhd.d.ts} +1 -1
- package/dist/{types-DLFCJD3D.d.ts → types-USOv09qy.d.ts} +86 -2
- package/dist/workspace-guard-ADPSEN6E.js +5 -0
- package/dist/{workspace-guard-7PEZT3ZJ.js.map → workspace-guard-ADPSEN6E.js.map} +1 -1
- package/package.json +2 -2
- package/dist/chunk-6GL4SLU7.js.map +0 -1
- package/dist/sdk-YS2M6RF5.js.map +0 -1
- package/dist/workspace-guard-7PEZT3ZJ.js +0 -5
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { B as BurdenoffGraphQLClient } from '../graphql-BUbw43Zx.js';
|
|
2
2
|
import { a as SDKContext } from '../index-CV3r9Taj.js';
|
|
3
|
-
import { G as GraphQLContext } from '../types-
|
|
3
|
+
import { G as GraphQLContext } from '../types-USOv09qy.js';
|
|
4
4
|
import 'graphql-request';
|
|
5
5
|
import '../layer-Cv9vSwBx.js';
|
|
6
6
|
import 'graphql';
|
|
@@ -10,7 +10,7 @@ import '@prisma/adapter-pg';
|
|
|
10
10
|
import 'pg';
|
|
11
11
|
import '../workspace-extension-BGwTOV_r.js';
|
|
12
12
|
import '../assistant-session-CJZhF4D6.js';
|
|
13
|
-
import '../types-
|
|
13
|
+
import '../types-DVpvrAhd.js';
|
|
14
14
|
|
|
15
15
|
interface CookieOptions {
|
|
16
16
|
name: string;
|
|
@@ -398,6 +398,20 @@ var WorkspaceRequiredError = class WorkspaceRequiredError2 extends UserFacingGra
|
|
|
398
398
|
this.name = "WorkspaceRequiredError";
|
|
399
399
|
}
|
|
400
400
|
};
|
|
401
|
+
var WorkspaceMembershipError = class WorkspaceMembershipError2 extends UserFacingGraphQLError {
|
|
402
|
+
static {
|
|
403
|
+
__name(this, "WorkspaceMembershipError");
|
|
404
|
+
}
|
|
405
|
+
constructor(workspaceId) {
|
|
406
|
+
super({
|
|
407
|
+
code: "NOT_FOUND",
|
|
408
|
+
userMessage: "We could not find the requested item.",
|
|
409
|
+
technicalMessage: `Workspace ${workspaceId} was not found for the current actor.`,
|
|
410
|
+
httpStatus: 404
|
|
411
|
+
});
|
|
412
|
+
this.name = "WorkspaceMembershipError";
|
|
413
|
+
}
|
|
414
|
+
};
|
|
401
415
|
function isFieldPublic(field) {
|
|
402
416
|
const directives = field?.astNode?.directives;
|
|
403
417
|
if (!directives || directives.length === 0) return false;
|
|
@@ -427,8 +441,31 @@ function resolveOperationType(document, operationName) {
|
|
|
427
441
|
return "query";
|
|
428
442
|
}
|
|
429
443
|
__name(resolveOperationType, "resolveOperationType");
|
|
430
|
-
function
|
|
431
|
-
|
|
444
|
+
function resolveRootFieldNames(document, operationName) {
|
|
445
|
+
const defs = document?.definitions ?? [];
|
|
446
|
+
const opDef = defs.find((d) => d.operation && (!operationName || d.name?.value === operationName));
|
|
447
|
+
const selections = opDef?.selectionSet?.selections ?? [];
|
|
448
|
+
if (selections.length === 0) return null;
|
|
449
|
+
const fieldNames = [];
|
|
450
|
+
for (const sel of selections) {
|
|
451
|
+
if (sel.kind && sel.kind !== "Field") return null;
|
|
452
|
+
const fieldName = sel.name?.value;
|
|
453
|
+
if (!fieldName) return null;
|
|
454
|
+
if (fieldName.startsWith("__")) continue;
|
|
455
|
+
fieldNames.push(fieldName);
|
|
456
|
+
}
|
|
457
|
+
return fieldNames;
|
|
458
|
+
}
|
|
459
|
+
__name(resolveRootFieldNames, "resolveRootFieldNames");
|
|
460
|
+
function allRootFieldsWhitelisted(rootFieldNames, whitelistedFields) {
|
|
461
|
+
return rootFieldNames.length > 0 && rootFieldNames.every((name) => whitelistedFields.has(name));
|
|
462
|
+
}
|
|
463
|
+
__name(allRootFieldsWhitelisted, "allRootFieldsWhitelisted");
|
|
464
|
+
function allRootFieldsPublic(schema, document, operationName, rootFieldNames) {
|
|
465
|
+
if (!document) return false;
|
|
466
|
+
if (rootFieldNames === null) return false;
|
|
467
|
+
if (rootFieldNames.length === 0) return true;
|
|
468
|
+
if (!schema) return false;
|
|
432
469
|
const opType = resolveOperationType(document, operationName);
|
|
433
470
|
let rootType;
|
|
434
471
|
if (opType === "mutation") {
|
|
@@ -440,15 +477,7 @@ function allRootFieldsPublic(schema, document, operationName) {
|
|
|
440
477
|
}
|
|
441
478
|
if (!rootType) return false;
|
|
442
479
|
const fields = rootType.getFields();
|
|
443
|
-
const
|
|
444
|
-
const opDef = defs.find((d) => d.operation && (!operationName || d.name?.value === operationName));
|
|
445
|
-
const selections = opDef?.selectionSet?.selections ?? [];
|
|
446
|
-
if (selections.length === 0) return false;
|
|
447
|
-
for (const sel of selections) {
|
|
448
|
-
if (sel.kind && sel.kind !== "Field") return false;
|
|
449
|
-
const fieldName = sel.name?.value;
|
|
450
|
-
if (!fieldName) return false;
|
|
451
|
-
if (fieldName.startsWith("__")) continue;
|
|
480
|
+
for (const fieldName of rootFieldNames) {
|
|
452
481
|
const fieldDef = fields[fieldName];
|
|
453
482
|
if (!isFieldPublic(fieldDef)) return false;
|
|
454
483
|
}
|
|
@@ -458,6 +487,8 @@ __name(allRootFieldsPublic, "allRootFieldsPublic");
|
|
|
458
487
|
function createWorkspaceGuardPlugin(config) {
|
|
459
488
|
const enabled = config?.enabled ?? true;
|
|
460
489
|
const whitelistedOperations = new Set(config?.whitelistedOperations ?? []);
|
|
490
|
+
const whitelistedFields = new Set(config?.whitelistedFields ?? []);
|
|
491
|
+
const validateWorkspaceMembership = config?.validateWorkspaceMembership;
|
|
461
492
|
const allowPublicDirective = config?.allowPublicDirective ?? true;
|
|
462
493
|
const errorMessage = config?.errorMessage ?? "Workspace context required. Ensure the request includes a valid workspace context (x-workspace-id header).";
|
|
463
494
|
if (!enabled) {
|
|
@@ -468,10 +499,14 @@ function createWorkspaceGuardPlugin(config) {
|
|
|
468
499
|
whitelistedOperations: [
|
|
469
500
|
...whitelistedOperations
|
|
470
501
|
],
|
|
502
|
+
whitelistedFields: [
|
|
503
|
+
...whitelistedFields
|
|
504
|
+
],
|
|
505
|
+
membershipValidation: validateWorkspaceMembership ? "enabled" : "disabled",
|
|
471
506
|
allowPublicDirective
|
|
472
507
|
});
|
|
473
508
|
return {
|
|
474
|
-
onExecute({ args }) {
|
|
509
|
+
async onExecute({ args }) {
|
|
475
510
|
let operationName = args.operationName;
|
|
476
511
|
if (!operationName && args.document?.definitions) {
|
|
477
512
|
for (const def of args.document.definitions) {
|
|
@@ -484,7 +519,11 @@ function createWorkspaceGuardPlugin(config) {
|
|
|
484
519
|
if (operationName && whitelistedOperations.has(operationName)) {
|
|
485
520
|
return void 0;
|
|
486
521
|
}
|
|
487
|
-
|
|
522
|
+
const rootFieldNames = resolveRootFieldNames(args.document, operationName);
|
|
523
|
+
if (whitelistedFields.size > 0 && rootFieldNames && allRootFieldsWhitelisted(rootFieldNames, whitelistedFields)) {
|
|
524
|
+
return void 0;
|
|
525
|
+
}
|
|
526
|
+
if (allowPublicDirective && allRootFieldsPublic(args.schema, args.document, operationName, rootFieldNames)) {
|
|
488
527
|
return void 0;
|
|
489
528
|
}
|
|
490
529
|
const context = args.contextValue;
|
|
@@ -496,6 +535,34 @@ function createWorkspaceGuardPlugin(config) {
|
|
|
496
535
|
});
|
|
497
536
|
throw new WorkspaceRequiredError(errorMessage);
|
|
498
537
|
}
|
|
538
|
+
if (validateWorkspaceMembership) {
|
|
539
|
+
const resolvedWorkspaceId = workspaceId ? workspaceId : headerWorkspaceId ?? "";
|
|
540
|
+
const actor = context?.actor ?? null;
|
|
541
|
+
let isMember = false;
|
|
542
|
+
try {
|
|
543
|
+
isMember = await validateWorkspaceMembership({
|
|
544
|
+
actorId: actor?.id ?? null,
|
|
545
|
+
actorType: actor?.type ?? null,
|
|
546
|
+
workspaceId: resolvedWorkspaceId,
|
|
547
|
+
contextValue: context
|
|
548
|
+
});
|
|
549
|
+
} catch (error) {
|
|
550
|
+
logger.error("[WorkspaceGuard] Workspace membership validation failed", {
|
|
551
|
+
operationName: operationName ?? "<anonymous>",
|
|
552
|
+
workspaceId: resolvedWorkspaceId,
|
|
553
|
+
error
|
|
554
|
+
});
|
|
555
|
+
throw new WorkspaceMembershipError(resolvedWorkspaceId);
|
|
556
|
+
}
|
|
557
|
+
if (!isMember) {
|
|
558
|
+
logger.warn("[WorkspaceGuard] Rejected non-member workspace context", {
|
|
559
|
+
operationName: operationName ?? "<anonymous>",
|
|
560
|
+
workspaceId: resolvedWorkspaceId,
|
|
561
|
+
actorId: actor?.id ?? null
|
|
562
|
+
});
|
|
563
|
+
throw new WorkspaceMembershipError(resolvedWorkspaceId);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
499
566
|
return void 0;
|
|
500
567
|
}
|
|
501
568
|
};
|
|
@@ -503,5 +570,5 @@ function createWorkspaceGuardPlugin(config) {
|
|
|
503
570
|
__name(createWorkspaceGuardPlugin, "createWorkspaceGuardPlugin");
|
|
504
571
|
|
|
505
572
|
export { UserFacingGraphQLError, createHttpErrorResponse, createHumanReadableErrorPlugin, createWorkspaceGuardPlugin, formatHttpError, normalizeError, normalizeExecutionResultErrors, normalizeGraphQLResponse, normalizeGraphQLResponsePayload, toUserFacingGraphQLError };
|
|
506
|
-
//# sourceMappingURL=chunk-
|
|
507
|
-
//# sourceMappingURL=chunk-
|
|
573
|
+
//# sourceMappingURL=chunk-5CJBZZLS.js.map
|
|
574
|
+
//# sourceMappingURL=chunk-5CJBZZLS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/errors.ts","../src/server/workspace-guard.ts"],"names":["DEFAULT_ERROR_CODE","DEFAULT_HTTP_STATUS","INVALID_CREDENTIALS_USER_MESSAGE","DEFAULT_USER_MESSAGES","BAD_REQUEST","BAD_USER_INPUT","CAPTCHA_FAILED","CAPTCHA_REQUIRED","COMPLEXITY_TOO_HIGH","CONFLICT","FORBIDDEN","INTERNAL_SERVER_ERROR","INVALID_PASSWORD","NOT_FOUND","PERMISSION_DENIED","QUOTA_EXCEEDED","QUOTA_EXHAUSTED","RATE_LIMITED","RESOURCE_CAP_EXCEEDED","STORAGE_QUOTA_EXCEEDED","TIMEOUT","UNAUTHENTICATED","VALIDATION_ERROR","WORKSPACE_REQUIRED","DEFAULT_STATUS_BY_CODE","SENSITIVE_EXTENSION_KEYS","Set","TECHNICAL_MESSAGE_PATTERNS","GRAPHQL_VALIDATION_MESSAGE_PATTERNS","isRecord","value","Array","isArray","readString","record","key","trim","length","readExtensions","error","extensions","readOriginalError","GraphQLError","originalError","Error","undefined","sanitizeExtensions","sanitized","Object","entries","has","normalizeCode","code","replace","toUpperCase","inferCodeFromMessage","message","lower","toLowerCase","some","pattern","test","includes","inferCode","extensionCode","originalCode","directCode","readErrorMessage","isLikelyTechnicalMessage","readExplicitUserMessage","resolveUserMessage","explicit","fallback","resolveTechnicalMessage","options","environment","serviceName","readHttpStatus","http","normalizeError","originalExtensions","directExtensions","mergedExtensions","userMessage","technicalMessage","status","UserFacingGraphQLError","details","httpStatus","cause","name","toUserFacingGraphQLError","normalized","nodes","source","positions","path","normalizeExecutionResultErrors","result","forEach","entry","errors","map","normalizeGraphQLResponsePayload","payload","normalizeGraphQLResponse","response","contentType","headers","get","text","Response","statusText","JSON","parse","stringify","createHumanReadableErrorPlugin","onExecute","onExecuteDone","formatHttpError","body","createHttpErrorResponse","formatted","WorkspaceRequiredError","WorkspaceMembershipError","workspaceId","isFieldPublic","field","directives","astNode","dir","args","arguments","arg","kind","resolveOperationType","document","operationName","defs","definitions","def","operation","resolveRootFieldNames","opDef","find","d","selections","selectionSet","fieldNames","sel","fieldName","startsWith","push","allRootFieldsWhitelisted","rootFieldNames","whitelistedFields","every","allRootFieldsPublic","schema","opType","rootType","getMutationType","getSubscriptionType","getQueryType","fields","getFields","fieldDef","createWorkspaceGuardPlugin","config","enabled","whitelistedOperations","validateWorkspaceMembership","allowPublicDirective","errorMessage","logger","info","membershipValidation","size","context","contextValue","workspace","id","headerWorkspaceId","request","warn","resolvedWorkspaceId","actor","isMember","actorId","actorType","type"],"mappings":";;;;AAwCA,IAAMA,kBAAAA,GAAqB,uBAAA;AAC3B,IAAMC,mBAAAA,GAAsB,GAAA;AAK5B,IAAMC,gCAAAA,GAAmC,wCAAA;AAEzC,IAAMC,qBAAAA,GAAgD;EACpDC,WAAAA,EAAa,yCAAA;EACbC,cAAAA,EAAgB,6CAAA;EAChBC,cAAAA,EAAgB,4CAAA;EAChBC,gBAAAA,EAAkB,+CAAA;EAClBC,mBAAAA,EAAqB,yEAAA;EACrBC,QAAAA,EAAU,yEAAA;EACVC,SAAAA,EAAW,wCAAA;EACXC,qBAAAA,EAAuB,yCAAA;EACvBC,gBAAAA,EAAkBV,gCAAAA;EAClBW,SAAAA,EAAW,uCAAA;EACXC,iBAAAA,EAAmB,wCAAA;EACnBC,cAAAA,EAAgB,kCAAA;EAChBC,eAAAA,EAAiB,kCAAA;EACjBC,YAAAA,EAAc,wDAAA;EACdC,qBAAAA,E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,IAAAA,IAAQ,IAAA;YAC1BjE,WAAAA,EAAa4D,mBAAAA;YACbN,YAAAA,EAAcD;WAChB,CAAA;AACF,QAAA,CAAA,CAAA,OAAS3I,KAAAA,EAAO;AAEduI,UAAAA,MAAAA,CAAOvI,MAAM,yDAAA,EAA2D;AACtEkG,YAAAA,aAAAA,EAAeA,aAAAA,IAAiB,aAAA;YAChCZ,WAAAA,EAAa4D,mBAAAA;AACblJ,YAAAA;WACF,CAAA;AACA,UAAA,MAAM,IAAIqF,yBAAyB6D,mBAAAA,CAAAA;AACrC,QAAA;AACA,QAAA,IAAI,CAACE,QAAAA,EAAU;AACbb,UAAAA,MAAAA,CAAOU,KAAK,wDAAA,EAA0D;AACpE/C,YAAAA,aAAAA,EAAeA,aAAAA,IAAiB,aAAA;YAChCZ,WAAAA,EAAa4D,mBAAAA;AACbG,YAAAA,OAAAA,EAASF,OAAOL,EAAAA,IAAM;WACxB,CAAA;AACA,UAAA,MAAM,IAAIzD,yBAAyB6D,mBAAAA,CAAAA;AACrC,QAAA;AACF,MAAA;AAEA,MAAA,OAAO5I,MAAAA;AACT,IAAA;AACF,GAAA;AACF;AA5HgB0H,MAAAA,CAAAA,0BAAAA,EAAAA,4BAAAA,CAAAA","file":"chunk-5CJBZZLS.js","sourcesContent":["import { GraphQLError } from 'graphql';\n\nimport type { YogaPlugin } from './types.js';\n\nexport interface UserFacingErrorOptions {\n code: string;\n userMessage: string;\n technicalMessage?: string;\n details?: Record<string, unknown>;\n httpStatus?: number;\n cause?: Error;\n}\n\nexport interface ErrorNormalizationOptions {\n serviceName?: string;\n environment?: string;\n}\n\nexport interface NormalizedErrorState {\n code: string;\n userMessage: string;\n technicalMessage: string;\n extensions: Record<string, unknown>;\n status: number;\n}\n\nexport interface HttpErrorPayload {\n error: string;\n message: string;\n userMessage: string;\n technicalMessage: string;\n code: string;\n extensions: Record<string, unknown>;\n}\n\nexport interface HttpErrorResult {\n status: number;\n body: HttpErrorPayload;\n}\n\nconst DEFAULT_ERROR_CODE = 'INTERNAL_SERVER_ERROR';\nconst DEFAULT_HTTP_STATUS = 500;\n\n// Held in a separately-named const so the literal isn't assigned directly to\n// the `INVALID_PASSWORD` key — that pattern trips sonarjs/no-hardcoded-passwords\n// (a false positive: this is a user-facing message, not a credential).\nconst INVALID_CREDENTIALS_USER_MESSAGE = 'The password you entered is incorrect.';\n\nconst DEFAULT_USER_MESSAGES: Record<string, string> = {\n BAD_REQUEST: 'Please check the request and try again.',\n BAD_USER_INPUT: 'Please check the information and try again.',\n CAPTCHA_FAILED: 'The verification failed. Please try again.',\n CAPTCHA_REQUIRED: 'Please complete the verification to continue.',\n COMPLEXITY_TOO_HIGH: 'This request is too large to process. Please simplify it and try again.',\n CONFLICT: 'This change conflicts with existing data. Please refresh and try again.',\n FORBIDDEN: 'You do not have permission to do that.',\n INTERNAL_SERVER_ERROR: 'Something went wrong. Please try again.',\n INVALID_PASSWORD: INVALID_CREDENTIALS_USER_MESSAGE,\n NOT_FOUND: 'We could not find the requested item.',\n PERMISSION_DENIED: 'You do not have permission to do that.',\n QUOTA_EXCEEDED: \"You've reached your usage limit.\",\n QUOTA_EXHAUSTED: \"You've reached your usage limit.\",\n RATE_LIMITED: 'Too many requests. Please wait a moment and try again.',\n RESOURCE_CAP_EXCEEDED: \"You've reached your plan limit. Upgrade your plan to continue.\",\n STORAGE_QUOTA_EXCEEDED: \"You've reached your storage limit. Upgrade your plan to continue.\",\n TIMEOUT: 'The request took too long. Please try again.',\n UNAUTHENTICATED: 'Please sign in to continue.',\n VALIDATION_ERROR: 'Please check the information and try again.',\n WORKSPACE_REQUIRED: 'Please choose a workspace and try again.',\n};\n\nconst DEFAULT_STATUS_BY_CODE: Record<string, number> = {\n BAD_REQUEST: 400,\n BAD_USER_INPUT: 400,\n CAPTCHA_FAILED: 400,\n CAPTCHA_REQUIRED: 400,\n COMPLEXITY_TOO_HIGH: 400,\n CONFLICT: 409,\n FORBIDDEN: 403,\n INVALID_PASSWORD: 400,\n NOT_FOUND: 404,\n PERMISSION_DENIED: 403,\n QUOTA_EXCEEDED: 429,\n QUOTA_EXHAUSTED: 429,\n RATE_LIMITED: 429,\n RESOURCE_CAP_EXCEEDED: 429,\n STORAGE_QUOTA_EXCEEDED: 429,\n TIMEOUT: 504,\n UNAUTHENTICATED: 401,\n VALIDATION_ERROR: 400,\n WORKSPACE_REQUIRED: 403,\n};\n\nconst SENSITIVE_EXTENSION_KEYS = new Set(['exception', 'originalError', 'stack', 'stacktrace']);\n\nconst TECHNICAL_MESSAGE_PATTERNS = [\n /\\bprisma\\b/i,\n /\\bsql\\b/i,\n /\\bconstraint\\b/i,\n /\\bstack\\b/i,\n /\\bundefined\\b/i,\n /\\bnull\\b/i,\n /\\bECONN[A-Z_]*\\b/,\n /\\bETIMEDOUT\\b/,\n /\\bENOTFOUND\\b/,\n /\\bP\\d{4}\\b/,\n /Cannot (read|set|find|access)/i,\n /Build failed \\(exit \\d+\\)/i,\n /JSON\\.stringify/i,\n];\n\nconst GRAPHQL_VALIDATION_MESSAGE_PATTERNS = [\n /^Syntax Error:/i,\n /^Cannot query field\\b/i,\n /^Cannot return null for non-nullable field\\b/i,\n /^Unknown (argument|directive|type)\\b/i,\n /^Variable \"\\$[^\"]+\" got invalid value/i,\n /^Field \"[^\"]+\" of required type/i,\n /^Field \"[^\"]+\" must not have a selection/i,\n /^Field \"[^\"]+\" must have a selection/i,\n /^Fragment \"[^\"]+\" cannot be spread here/i,\n /^There can be only one/i,\n /Did you mean /i,\n];\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction readString(record: Record<string, unknown>, key: string): string | null {\n const value = record[key];\n return typeof value === 'string' && value.trim().length > 0 ? value : null;\n}\n\nfunction readExtensions(error: unknown): Record<string, unknown> {\n if (!isRecord(error)) return {};\n const extensions = error['extensions'];\n return isRecord(extensions) ? extensions : {};\n}\n\nfunction readOriginalError(error: unknown): Error | undefined {\n if (error instanceof GraphQLError && error.originalError instanceof Error) {\n return error.originalError;\n }\n return undefined;\n}\n\nfunction sanitizeExtensions(extensions: Record<string, unknown>): Record<string, unknown> {\n const sanitized: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(extensions)) {\n if (!SENSITIVE_EXTENSION_KEYS.has(key)) {\n sanitized[key] = value;\n }\n }\n return sanitized;\n}\n\nfunction normalizeCode(code: string | null): string {\n if (!code) return DEFAULT_ERROR_CODE;\n return code\n .trim()\n .replace(/[\\s-]+/g, '_')\n .toUpperCase();\n}\n\nfunction inferCodeFromMessage(message: string): string {\n const lower = message.toLowerCase();\n\n if (GRAPHQL_VALIDATION_MESSAGE_PATTERNS.some((pattern) => pattern.test(message))) {\n return 'BAD_USER_INPUT';\n }\n\n if (\n lower.includes('unauthenticated') ||\n lower.includes('not authenticated') ||\n lower.includes('authentication required') ||\n lower.includes('unauthorized') ||\n lower.includes('please sign in') ||\n lower.includes('sign in to')\n ) {\n return 'UNAUTHENTICATED';\n }\n\n if (lower.includes('workspace context') || lower.includes('switch to a workspace')) {\n return 'WORKSPACE_REQUIRED';\n }\n\n if (\n lower.includes('forbidden') ||\n lower.includes('access denied') ||\n lower.includes('permission denied') ||\n lower.includes('not authorized')\n ) {\n return 'FORBIDDEN';\n }\n\n if (lower.includes('not found') || lower.includes('disappeared')) {\n return 'NOT_FOUND';\n }\n\n if (lower.includes('already exists') || lower.includes('already taken') || lower.includes('conflict')) {\n return 'CONFLICT';\n }\n\n if (lower.includes('quota') || lower.includes('cap exceeded') || lower.includes('limit reached')) {\n return 'QUOTA_EXCEEDED';\n }\n\n if (lower.includes('timeout') || lower.includes('timed out')) {\n return 'TIMEOUT';\n }\n\n if (\n lower.includes('required') ||\n lower.includes('invalid') ||\n lower.includes('missing') ||\n lower.includes('unsupported')\n ) {\n return 'BAD_USER_INPUT';\n }\n\n return DEFAULT_ERROR_CODE;\n}\n\nfunction inferCode(error: unknown, extensions: Record<string, unknown>, originalError: Error | undefined): string {\n const extensionCode = typeof extensions['code'] === 'string' ? extensions['code'] : null;\n if (extensionCode) return normalizeCode(extensionCode);\n\n if (isRecord(originalError)) {\n const originalCode = readString(originalError, 'code');\n if (originalCode) return normalizeCode(originalCode);\n }\n\n if (isRecord(error)) {\n const directCode = readString(error, 'code');\n if (directCode) return normalizeCode(directCode);\n }\n\n const message = readErrorMessage(error);\n return inferCodeFromMessage(message);\n}\n\nfunction readErrorMessage(error: unknown): string {\n if (error instanceof Error && error.message.trim().length > 0) {\n return error.message;\n }\n if (isRecord(error)) {\n const message = readString(error, 'message');\n if (message) return message;\n }\n return DEFAULT_USER_MESSAGES[DEFAULT_ERROR_CODE] ?? 'Something went wrong. Please try again.';\n}\n\nfunction isLikelyTechnicalMessage(message: string): boolean {\n if (message.length > 220) return true;\n if (message.includes('\\n')) return true;\n if (message.includes('{') && message.includes('}')) return true;\n if (GRAPHQL_VALIDATION_MESSAGE_PATTERNS.some((pattern) => pattern.test(message))) return true;\n return TECHNICAL_MESSAGE_PATTERNS.some((pattern) => pattern.test(message));\n}\n\nfunction readExplicitUserMessage(extensions: Record<string, unknown>): string | null {\n return (\n readString(extensions, 'userMessage') ??\n readString(extensions, 'humanMessage') ??\n readString(extensions, 'displayMessage')\n );\n}\n\nfunction resolveUserMessage(code: string, message: string, extensions: Record<string, unknown>): string {\n const explicit = readExplicitUserMessage(extensions);\n if (explicit) return explicit;\n\n const fallback =\n DEFAULT_USER_MESSAGES[code] ??\n DEFAULT_USER_MESSAGES[DEFAULT_ERROR_CODE] ??\n 'Something went wrong. Please try again.';\n if (code === DEFAULT_ERROR_CODE) {\n return fallback;\n }\n\n if (!isLikelyTechnicalMessage(message)) {\n return message;\n }\n\n return fallback;\n}\n\nfunction resolveTechnicalMessage(\n code: string,\n message: string,\n extensions: Record<string, unknown>,\n options: ErrorNormalizationOptions\n): string {\n const explicit = readString(extensions, 'technicalMessage');\n if (explicit) return explicit;\n\n if (options.environment === 'production' && code === DEFAULT_ERROR_CODE) {\n return options.serviceName ? `${options.serviceName} returned ${DEFAULT_ERROR_CODE}` : DEFAULT_ERROR_CODE;\n }\n\n return message;\n}\n\nfunction readHttpStatus(extensions: Record<string, unknown>, code: string): number {\n const http = extensions['http'];\n if (isRecord(http) && typeof http['status'] === 'number') {\n return http['status'];\n }\n return DEFAULT_STATUS_BY_CODE[code] ?? DEFAULT_HTTP_STATUS;\n}\n\nexport function normalizeError(error: unknown, options: ErrorNormalizationOptions = {}): NormalizedErrorState {\n const originalError = readOriginalError(error);\n const originalExtensions = readExtensions(originalError);\n const directExtensions = readExtensions(error);\n const mergedExtensions = sanitizeExtensions({ ...originalExtensions, ...directExtensions });\n const message = readErrorMessage(error);\n const code = inferCode(error, mergedExtensions, originalError);\n const userMessage = resolveUserMessage(code, message, mergedExtensions);\n const technicalMessage = resolveTechnicalMessage(code, message, mergedExtensions, options);\n const status = readHttpStatus(mergedExtensions, code);\n\n const extensions: Record<string, unknown> = {\n ...mergedExtensions,\n code,\n userMessage,\n technicalMessage,\n };\n\n if (options.serviceName) {\n extensions['serviceName'] = options.serviceName;\n }\n\n if (!isRecord(extensions['http'])) {\n extensions['http'] = { status };\n }\n\n return {\n code,\n userMessage,\n technicalMessage,\n extensions,\n status,\n };\n}\n\nexport class UserFacingGraphQLError extends GraphQLError {\n constructor(options: UserFacingErrorOptions) {\n const extensions: Record<string, unknown> = {\n code: normalizeCode(options.code),\n userMessage: options.userMessage,\n technicalMessage: options.technicalMessage ?? options.userMessage,\n };\n\n if (options.details) {\n extensions['details'] = options.details;\n }\n\n if (options.httpStatus) {\n extensions['http'] = { status: options.httpStatus };\n }\n\n super(options.userMessage, {\n originalError: options.cause,\n extensions,\n });\n this.name = 'UserFacingGraphQLError';\n }\n}\n\nexport function toUserFacingGraphQLError(error: unknown, options: ErrorNormalizationOptions = {}): GraphQLError {\n const normalized = normalizeError(error, options);\n\n if (error instanceof GraphQLError) {\n return new GraphQLError(normalized.userMessage, {\n nodes: error.nodes,\n source: error.source,\n positions: error.positions,\n path: error.path,\n originalError: error.originalError,\n extensions: normalized.extensions,\n });\n }\n\n return new GraphQLError(normalized.userMessage, {\n originalError: error instanceof Error ? error : undefined,\n extensions: normalized.extensions,\n });\n}\n\nexport function normalizeExecutionResultErrors(result: unknown, options: ErrorNormalizationOptions = {}): void {\n if (Array.isArray(result)) {\n result.forEach((entry) => normalizeExecutionResultErrors(entry, options));\n return;\n }\n\n if (!isRecord(result)) return;\n const errors = result['errors'];\n if (!Array.isArray(errors) || errors.length === 0) return;\n\n result['errors'] = errors.map((error) => toUserFacingGraphQLError(error, options));\n}\n\nexport function normalizeGraphQLResponsePayload(payload: unknown, options: ErrorNormalizationOptions = {}): unknown {\n normalizeExecutionResultErrors(payload, options);\n return payload;\n}\n\nexport async function normalizeGraphQLResponse(\n response: Response,\n options: ErrorNormalizationOptions = {}\n): Promise<Response> {\n const contentType = response.headers.get('content-type') ?? '';\n if (!contentType.toLowerCase().includes('json')) {\n return response;\n }\n\n const text = await response.text();\n if (!text) {\n return new Response(text, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n }\n\n let payload: unknown;\n try {\n payload = JSON.parse(text) as unknown;\n } catch {\n return new Response(text, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n }\n\n normalizeGraphQLResponsePayload(payload, options);\n\n return new Response(JSON.stringify(payload), {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n}\n\nexport function createHumanReadableErrorPlugin(options: ErrorNormalizationOptions = {}): YogaPlugin {\n return {\n onExecute() {\n return {\n onExecuteDone({ result }: { result: unknown }) {\n normalizeExecutionResultErrors(result, options);\n },\n };\n },\n };\n}\n\nexport function formatHttpError(error: unknown, options: ErrorNormalizationOptions = {}): HttpErrorResult {\n const normalized = normalizeError(error, options);\n return {\n status: normalized.status,\n body: {\n error: normalized.userMessage,\n message: normalized.userMessage,\n userMessage: normalized.userMessage,\n technicalMessage: normalized.technicalMessage,\n code: normalized.code,\n extensions: normalized.extensions,\n },\n };\n}\n\nexport function createHttpErrorResponse(error: unknown, options: ErrorNormalizationOptions = {}): Response {\n const formatted = formatHttpError(error, options);\n return new Response(JSON.stringify(formatted.body), {\n status: formatted.status,\n headers: { 'Content-Type': 'application/json' },\n });\n}\n","/**\n * Workspace Guard Plugin for GraphQL Yoga\n *\n * Blocks GraphQL operations that lack a valid workspace context (x-workspace-id header).\n * This provides defense-in-depth at the GraphQL layer — even if the gateway allows a request\n * through, the service itself will reject it if workspace context is missing.\n *\n * **Whitelisted operations** (e.g., workspace creation) can bypass the guard.\n *\n * **Public schema fields** marked with `@public` or `@rbac(public: true)` are auto-bypassed\n * when `allowPublicDirective` is enabled (default true). This lets anonymous public-link\n * resolvers (e.g. `accessShare`) be reached through the federation gateway without an\n * `x-workspace-id` header.\n *\n * @module server/workspace-guard\n * @category Security\n */\n\nimport { logger } from '../logger/index.js';\nimport { UserFacingGraphQLError } from './errors.js';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Configuration for the workspace guard plugin\n */\nexport interface WorkspaceGuardConfig {\n /**\n * Enable the workspace guard.\n * @default true\n */\n enabled?: boolean;\n\n /**\n * GraphQL operation names that can run without workspace context.\n * These are typically operations like `createWorkspace` that execute\n * before a workspace exists.\n *\n * Matching is case-sensitive against the operation name in the GraphQL document.\n *\n * @deprecated Prefer `whitelistedFields`: operation names are client-supplied\n * strings, so any client that names its operation differently (or sends an\n * anonymous operation) is rejected even when every root field it requests is\n * genuinely context-free. `whitelistedFields` matches on the root field names\n * resolved from the parsed document, which is a property of the schema, not\n * of the client's request.\n *\n * @default []\n *\n * @example\n * ```typescript\n * whitelistedOperations: ['createWorkspace', 'validateTokens']\n * ```\n */\n whitelistedOperations?: string[];\n\n /**\n * Root field names (Query/Mutation/Subscription fields) that can run without\n * workspace context — e.g. `myWorkspaces`, which bootstraps workspace\n * discovery before any workspace has been chosen.\n *\n * Matching is done against the root field names resolved from the parsed\n * GraphQL document for the executed operation, completely independent of the\n * client-supplied `operationName`: anonymous operations, persisted queries\n * and arbitrarily named operations all behave identically.\n *\n * An operation is exempt only when EVERY root field it selects is listed\n * here (or is public per the schema directives). A document that mixes an\n * exempt field with a guarded field is NOT exempt. Fragment spreads at the\n * root fail closed (not exempt).\n *\n * @default []\n *\n * @example\n * ```typescript\n * whitelistedFields: ['myWorkspaces', 'createWorkspace']\n * ```\n */\n whitelistedFields?: string[];\n\n /**\n * Optional membership validation for requests that DO carry a workspace\n * context (`x-workspace-id`). Without this, the guard only checks that a\n * workspace id is present — any well-formed UUID passes, which looks like\n * authorization but performs none.\n *\n * When provided, the callback is invoked with the resolved actor and\n * workspace id for every guarded request; returning `false` rejects the\n * request with `NOT_FOUND` (per the platform RBAC guide: never leak resource\n * existence to non-members). Returning `true` (or omitting this callback)\n * preserves the legacy accept-any-present-workspace-id behaviour.\n *\n * The callback is NOT invoked for operations exempted via\n * `whitelistedOperations`, `whitelistedFields` or the public-directive\n * bypass — context-free bootstrap fields stay reachable regardless.\n *\n * The service that owns the `Workspace`/`WorkspaceMember` entities wires\n * this; the SDK never derives membership itself.\n *\n * @default undefined\n */\n validateWorkspaceMembership?: (validation: WorkspaceMembershipValidation) => boolean | Promise<boolean>;\n\n /**\n * Custom error message when workspace context is missing.\n * @default 'Workspace context required. Provide a valid X-Workspace-Authorization header.'\n */\n errorMessage?: string;\n\n /**\n * If true, fields whose schema definition carries the `@public` directive or\n * `@rbac(public: true)` are bypassed by the guard automatically — no need to\n * list them in `whitelistedOperations`. The check uses the GraphQL schema\n * passed to the executor at request time.\n *\n * Set to false to fall back to the legacy operation-name allowlist only.\n *\n * @default true\n */\n allowPublicDirective?: boolean;\n}\n\n/**\n * Input for the `validateWorkspaceMembership` callback.\n */\nexport interface WorkspaceMembershipValidation {\n /** Actor id from the gateway-injected identity (`x-actor-id`). */\n actorId: string | null;\n /** Actor type from the gateway-injected identity (`x-actor-type`). */\n actorType: string | null;\n /** The workspace id claimed by `x-workspace-id` (or the actor's workspace). */\n workspaceId: string;\n /** The full GraphQL context value for the request. */\n contextValue: unknown;\n}\n\n// ============================================================================\n// GraphQL Error\n// ============================================================================\n\n/**\n * Workspace required error with proper GraphQL error extensions\n */\nclass WorkspaceRequiredError extends UserFacingGraphQLError {\n constructor(message: string) {\n super({\n code: 'WORKSPACE_REQUIRED',\n userMessage: 'Please choose a workspace and try again.',\n technicalMessage: message,\n httpStatus: 403,\n });\n this.name = 'WorkspaceRequiredError';\n }\n}\n\n/**\n * Rejection for a workspace id the calling actor is not a member of.\n * Per the platform RBAC guide (Type B convention), non-members get\n * NOT_FOUND so resource existence is never leaked.\n */\nclass WorkspaceMembershipError extends UserFacingGraphQLError {\n constructor(workspaceId: string) {\n super({\n code: 'NOT_FOUND',\n userMessage: 'We could not find the requested item.',\n technicalMessage: `Workspace ${workspaceId} was not found for the current actor.`,\n httpStatus: 404,\n });\n this.name = 'WorkspaceMembershipError';\n }\n}\n\n// ============================================================================\n// Schema directive helpers\n// ============================================================================\n\n/**\n * Minimal structural typings for the bits of the GraphQL schema we look at.\n * We avoid importing the GraphQL types directly so the SDK keeps `graphql`\n * as a peer dep without a runtime hard dependency.\n */\ninterface FieldLikeDef {\n astNode?: {\n directives?: ReadonlyArray<{\n name: { value: string };\n arguments?: ReadonlyArray<{\n name: { value: string };\n value: { kind: string; value?: unknown };\n }>;\n }>;\n };\n}\n\ninterface SchemaLike {\n getQueryType?: () => { getFields: () => Record<string, FieldLikeDef> } | null | undefined;\n getMutationType?: () => { getFields: () => Record<string, FieldLikeDef> } | null | undefined;\n getSubscriptionType?: () => { getFields: () => Record<string, FieldLikeDef> } | null | undefined;\n}\n\n/**\n * Returns true iff the field carries either:\n * - `@public` directive, OR\n * - `@rbac(public: true)` directive (any arg-order)\n */\nfunction isFieldPublic(field: FieldLikeDef | undefined): boolean {\n const directives = field?.astNode?.directives;\n if (!directives || directives.length === 0) return false;\n\n for (const dir of directives) {\n const name = dir.name?.value;\n if (name === 'public') return true;\n if (name === 'rbac') {\n const args = dir.arguments ?? [];\n for (const arg of args) {\n if (arg.name?.value === 'public' && arg.value?.kind === 'BooleanValue' && arg.value.value === true) {\n return true;\n }\n }\n }\n }\n return false;\n}\n\ninterface DocumentLike {\n definitions?: ReadonlyArray<{\n kind?: string;\n operation?: string;\n name?: { value?: string };\n selectionSet?: {\n selections?: ReadonlyArray<{\n kind?: string;\n name?: { value?: string };\n }>;\n };\n }>;\n}\n\n/**\n * Resolve the operation type ('query' | 'mutation' | 'subscription') for the\n * primary operation in the document. Falls back to 'query'.\n */\nfunction resolveOperationType(\n document: DocumentLike | undefined,\n operationName: string | null | undefined\n): 'query' | 'mutation' | 'subscription' {\n const defs = document?.definitions ?? [];\n for (const def of defs) {\n if (def.kind !== 'OperationDefinition') {\n // Older parsers may not set kind; fall through to the operation property check below.\n }\n if (def.operation && (!operationName || def.name?.value === operationName)) {\n return def.operation as 'query' | 'mutation' | 'subscription';\n }\n }\n return 'query';\n}\n\n/**\n * Resolve the root field names selected by the operation that will execute\n * (`operationName` identifies it when the document carries multiple\n * operations). Returns null when no operation definition matches, the\n * selection set is empty, or a non-Field selection appears at the root\n * (fragment spreads / inline fragments fail closed — see the public-bypass\n * rationale above). Introspection fields (`__schema`, `__type`) are omitted;\n * an introspection-only operation yields an EMPTY array (not null) so callers\n * can distinguish \"only introspection selected\" from \"fail closed\".\n */\nfunction resolveRootFieldNames(\n document: DocumentLike | undefined,\n operationName: string | null | undefined\n): string[] | null {\n const defs = document?.definitions ?? [];\n const opDef = defs.find((d) => d.operation && (!operationName || d.name?.value === operationName));\n const selections = opDef?.selectionSet?.selections ?? [];\n if (selections.length === 0) return null;\n\n const fieldNames: string[] = [];\n for (const sel of selections) {\n if (sel.kind && sel.kind !== 'Field') return null;\n const fieldName = sel.name?.value;\n if (!fieldName) return null;\n if (fieldName.startsWith('__')) continue;\n fieldNames.push(fieldName);\n }\n return fieldNames;\n}\n\n/**\n * Returns true iff every root field selected by the operation is present in\n * the whitelist set. An empty list (introspection-only operation) is NOT\n * exempt — the whitelist covers named schema fields only. A document mixing\n * an exempt field with a guarded field is NOT exempt either, so an exempt\n * bootstrap field cannot smuggle a guarded one.\n */\nfunction allRootFieldsWhitelisted(rootFieldNames: string[], whitelistedFields: Set<string>): boolean {\n return rootFieldNames.length > 0 && rootFieldNames.every((name) => whitelistedFields.has(name));\n}\n\n/**\n * Returns true iff every root field in the document selection set is marked\n * public on the schema. An empty field list (introspection-only operation) is\n * public — schema discovery never requires workspace context. Null (fail\n * closed: no matching operation, empty selection set, or fragment at the\n * root) is not public.\n */\nfunction allRootFieldsPublic(\n schema: SchemaLike | undefined,\n document: DocumentLike | undefined,\n operationName: string | null | undefined,\n rootFieldNames: string[] | null\n): boolean {\n if (!document) return false;\n if (rootFieldNames === null) return false;\n // Introspection-only operations are always public — schema discovery never\n // requires workspace context, and no schema lookup is needed for it.\n if (rootFieldNames.length === 0) return true;\n if (!schema) return false;\n\n const opType = resolveOperationType(document, operationName);\n let rootType: ReturnType<NonNullable<SchemaLike['getQueryType']>> | undefined;\n if (opType === 'mutation') {\n rootType = schema.getMutationType?.();\n } else if (opType === 'subscription') {\n rootType = schema.getSubscriptionType?.();\n } else {\n rootType = schema.getQueryType?.();\n }\n\n if (!rootType) return false;\n\n const fields = rootType.getFields();\n for (const fieldName of rootFieldNames) {\n const fieldDef = fields[fieldName];\n if (!isFieldPublic(fieldDef)) return false;\n }\n return true;\n}\n\n// ============================================================================\n// Plugin\n// ============================================================================\n\n/**\n * Create a GraphQL Yoga plugin that guards operations requiring workspace context.\n *\n * The plugin inspects the GraphQL context for workspace information (set by the SDK's\n * buildContext from the x-workspace-id header). If missing and the operation is not\n * whitelisted (and not all-public per directive), it throws a WORKSPACE_REQUIRED error.\n *\n * @param config - Guard configuration\n * @returns A Yoga-compatible plugin\n *\n * @example\n * ```typescript\n * import { createWorkspaceGuardPlugin } from '@burdenoff/be-sdk/server';\n *\n * const guardPlugin = createWorkspaceGuardPlugin({\n * whitelistedOperations: ['createWorkspace'],\n * allowPublicDirective: true, // default\n * });\n * ```\n */\nexport function createWorkspaceGuardPlugin(config?: WorkspaceGuardConfig) {\n const enabled = config?.enabled ?? true;\n const whitelistedOperations = new Set(config?.whitelistedOperations ?? []);\n const whitelistedFields = new Set(config?.whitelistedFields ?? []);\n const validateWorkspaceMembership = config?.validateWorkspaceMembership;\n const allowPublicDirective = config?.allowPublicDirective ?? true;\n const errorMessage =\n config?.errorMessage ??\n 'Workspace context required. Ensure the request includes a valid workspace context (x-workspace-id header).';\n\n if (!enabled) {\n logger.info('[WorkspaceGuard] Workspace guard disabled');\n return {};\n }\n\n logger.info('[WorkspaceGuard] Workspace guard enabled', {\n whitelistedOperations: [...whitelistedOperations],\n whitelistedFields: [...whitelistedFields],\n membershipValidation: validateWorkspaceMembership ? 'enabled' : 'disabled',\n allowPublicDirective,\n });\n\n return {\n async onExecute({\n args,\n }: {\n args: {\n schema?: SchemaLike;\n document?: DocumentLike;\n operationName?: string | null;\n contextValue?: {\n actor?: { id?: string; type?: string } | null;\n workspace?: { id?: string };\n request?: Request;\n };\n };\n }) {\n // Extract operation name from args or document\n let operationName = args.operationName;\n\n if (!operationName && args.document?.definitions) {\n for (const def of args.document.definitions) {\n if (def.operation && def.name?.value) {\n operationName = def.name.value;\n break;\n }\n }\n }\n\n // Check if operation is whitelisted by name (legacy, client-supplied name)\n if (operationName && whitelistedOperations.has(operationName)) {\n return undefined;\n }\n\n // Resolve the executed operation's root fields once. Null means fail\n // closed (no matching operation, empty selection set, or fragment at\n // the root); an empty array means an introspection-only operation.\n const rootFieldNames = resolveRootFieldNames(args.document, operationName);\n\n // Check if every root field of the executed operation is whitelisted by\n // FIELD name, resolved from the parsed document — independent of the\n // client-supplied operation name.\n if (whitelistedFields.size > 0 && rootFieldNames && allRootFieldsWhitelisted(rootFieldNames, whitelistedFields)) {\n return undefined;\n }\n\n // Check schema-directive-based public bypass (Option C)\n if (allowPublicDirective && allRootFieldsPublic(args.schema, args.document, operationName, rootFieldNames)) {\n return undefined;\n }\n\n // Check for workspace context\n const context = args.contextValue;\n const workspaceId = context?.workspace?.id;\n\n // Also check the raw header as a fallback\n const headerWorkspaceId = context?.request?.headers?.get?.('x-workspace-id');\n\n if (!workspaceId && !headerWorkspaceId) {\n logger.warn('[WorkspaceGuard] Blocked operation without workspace context', {\n operationName: operationName ?? '<anonymous>',\n });\n throw new WorkspaceRequiredError(errorMessage);\n }\n\n // A workspace id is present. When the service wired a membership\n // validator, the id must denote a workspace the actor actually belongs\n // to — a well-formed but unrelated UUID is rejected with NOT_FOUND so\n // workspace existence is never leaked to non-members. The context id\n // wins only when non-empty; an empty context id falls back to the\n // header (matching the truthiness gate above).\n if (validateWorkspaceMembership) {\n const resolvedWorkspaceId = workspaceId ? workspaceId : (headerWorkspaceId ?? '');\n const actor = context?.actor ?? null;\n let isMember = false;\n try {\n isMember = await validateWorkspaceMembership({\n actorId: actor?.id ?? null,\n actorType: actor?.type ?? null,\n workspaceId: resolvedWorkspaceId,\n contextValue: context,\n });\n } catch (error) {\n // Fail closed: a membership-lookup failure must not admit the request.\n logger.error('[WorkspaceGuard] Workspace membership validation failed', {\n operationName: operationName ?? '<anonymous>',\n workspaceId: resolvedWorkspaceId,\n error,\n });\n throw new WorkspaceMembershipError(resolvedWorkspaceId);\n }\n if (!isMember) {\n logger.warn('[WorkspaceGuard] Rejected non-member workspace context', {\n operationName: operationName ?? '<anonymous>',\n workspaceId: resolvedWorkspaceId,\n actorId: actor?.id ?? null,\n });\n throw new WorkspaceMembershipError(resolvedWorkspaceId);\n }\n }\n\n return undefined;\n },\n };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { E as EvaluationContext, F as FeatureFlagProvider, a as FeatureFlagProviderConfig, b as FlagEvaluation, c as FlagType, G as GatedOperationType, O as OperationsFlagGatePluginOptions, R as ResolutionDetails, d as createOperationsFlagGatePlugin } from '../index
|
|
2
|
-
import '../types-
|
|
1
|
+
export { E as EvaluationContext, F as FeatureFlagProvider, a as FeatureFlagProviderConfig, b as FlagEvaluation, c as FlagType, G as GatedOperationType, O as OperationsFlagGatePluginOptions, R as ResolutionDetails, d as createOperationsFlagGatePlugin } from '../index--yvpa6ay.js';
|
|
2
|
+
import '../types-USOv09qy.js';
|
|
3
3
|
import 'graphql';
|
|
4
4
|
import 'graphql-yoga';
|
|
5
5
|
import '../client-CCXpAZ2r.js';
|
|
@@ -7,4 +7,4 @@ import '@prisma/adapter-pg';
|
|
|
7
7
|
import 'pg';
|
|
8
8
|
import '../workspace-extension-BGwTOV_r.js';
|
|
9
9
|
import '../assistant-session-CJZhF4D6.js';
|
|
10
|
-
import '../types-
|
|
10
|
+
import '../types-DVpvrAhd.js';
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { I as I18n, c as createI18n, g as getI18n, i as initializeI18n } from '../i18n-
|
|
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-
|
|
3
|
-
export { F as FlatTranslationMap,
|
|
1
|
+
export { I as I18n, c as createI18n, g as getI18n, i as initializeI18n } from '../i18n-Qm2AkPC-.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-lFffh5-G.js';
|
|
3
|
+
export { F as FlatTranslationMap, a as I18nConfig, b as I18nContext, I 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-DVpvrAhd.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { I as II18n, a as I18nConfig, L as LocaleCode, F as FlatTranslationMap, T as TranslateFunction, P as PluralTranslateFunction, b as I18nContext, c as LanguageCode } from './types-DVpvrAhd.js';
|
|
2
2
|
|
|
3
3
|
declare class I18n implements II18n {
|
|
4
4
|
private config;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as I18n, c as createI18n, g as getI18n, i as initializeI18n } from './i18n-
|
|
2
|
-
import {
|
|
1
|
+
import { I as I18n, c as createI18n, g as getI18n, i as initializeI18n } from './i18n-Qm2AkPC-.js';
|
|
2
|
+
import { b as I18nContext, d as TranslationVariables, L as LocaleCode, e as ParsedLocale, c as LanguageCode, f as TranslationDictionary, F as FlatTranslationMap, a as I18nConfig, I 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-DVpvrAhd.js';
|
|
3
3
|
|
|
4
4
|
interface I18nCapableContext {
|
|
5
5
|
i18n?: I18nContext;
|
package/dist/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export { i as Observability } from './index-4gKQKZ2B.js';
|
|
|
29
29
|
export { i as GraphQL } from './index-joONjwLt.js';
|
|
30
30
|
export { i as Prisma } from './index-BTMt4OjA.js';
|
|
31
31
|
export { i as Utils } from './index-PaojfSdd.js';
|
|
32
|
-
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-
|
|
32
|
+
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-lFffh5-G.js';
|
|
33
33
|
export { i as Export } from './index-CWmH_-RZ.js';
|
|
34
34
|
export { i as Init } from './index-5x0XMKXN.js';
|
|
35
35
|
export { i as DataLoader } from './index-DW9q22GH.js';
|
|
@@ -37,14 +37,14 @@ export { i as Instrumentation } from './index-Coua7_P7.js';
|
|
|
37
37
|
export { i as Layer } from './index-ffmipXSA.js';
|
|
38
38
|
export { i as Crypto } from './index-e_18DzAg.js';
|
|
39
39
|
export { i as Gateway } from './index-szTxGaO6.js';
|
|
40
|
-
export { i as FeatureFlags } from './index
|
|
40
|
+
export { i as FeatureFlags } from './index--yvpa6ay.js';
|
|
41
41
|
export { i as Captcha, R as RecaptchaVerifyOptions, a as RecaptchaVerifyResult, b as isCaptchaEnabled, v as verifyCaptcha, c as verifyCaptchaIfEnabled } from './index-B70b5mYS.js';
|
|
42
42
|
export { i as Platform } from './index-D8HGwglK.js';
|
|
43
43
|
export { N as NAME_MAX_LENGTH, a as NAME_MIN_LENGTH, b as NameErrorCode, c as NameValidationResult, R as RbacCoverageError, d as RbacCoverageOptions, e as RbacCoverageReport, f as RbacCoverageSource, U as USERNAME_MAX_LENGTH, g as USERNAME_MIN_LENGTH, h as UserFieldError, i as UserFieldKey, j as UserFieldsValidationResult, k as UsernameErrorCode, l as UsernameValidationResult, V as ValidatedUserFields, m as Validation, n as analyzeRbacCoverage, o as assertRbacCoverage, p as lengthInCodePoints, v as validateName, q as validateUserFields, r as validateUsername } from './index-qwG_TaUg.js';
|
|
44
44
|
export { E as EmitGeneration, P as PRODUCT_RENAMES, a as PRODUCT_RENAME_EMIT, b as PRODUCT_SLUG_ALIASES, i as ProductAlias, c as ProductRename, R as RENAME_CONCERNS, d as RenameConcern, e as billingIdVariants, f as emitBillingId, g as emitName, h as emitProductSlug, j as emitQuotaKey, k as emitRbacResource, l as emitTemplateKey, m as isLegacyName, n as isSameBillingId, o as isSameGraphQLName, p as isSameName, q as isSameProductSlug, r as isSameQuotaKey, s as isSameRbacResource, t as isSameTemplateKey, u as nameVariants, v as normalizeBillingId, w as normalizeGraphQLName, x as normalizeProductSlug, y as normalizeQuotaKey, z as normalizeRbacResource, A as normalizeTemplateKey, B as productSlugVariants, C as quotaKeyVariants, D as rbacResourceVariants, F as readRenamedEnv, G as templateKeyVariants, H as toCurrentName, I as toLegacyName } from './index-BuAj5nXg.js';
|
|
45
45
|
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-Cv9vSwBx.js';
|
|
46
46
|
export { S as ShutdownDisposable, d as disposeAll, g as getRegisteredDisposableCount, r as registerDisposable, u as unregisterDisposable } from './shutdown-registry-CW9LryO8.js';
|
|
47
|
-
import './types-
|
|
47
|
+
import './types-USOv09qy.js';
|
|
48
48
|
import 'graphql';
|
|
49
49
|
import 'graphql-yoga';
|
|
50
50
|
import './client-CCXpAZ2r.js';
|
|
@@ -52,7 +52,7 @@ import '@prisma/adapter-pg';
|
|
|
52
52
|
import 'pg';
|
|
53
53
|
import './workspace-extension-BGwTOV_r.js';
|
|
54
54
|
import './assistant-session-CJZhF4D6.js';
|
|
55
|
-
import './types-
|
|
55
|
+
import './types-DVpvrAhd.js';
|
|
56
56
|
import 'graphql-request';
|
|
57
57
|
import '@envelop/core';
|
|
58
58
|
import './explicit-activity-scope-CCoxVwAr.js';
|
|
@@ -65,7 +65,7 @@ import './types-DgJ4lDYA.js';
|
|
|
65
65
|
import 'elysia';
|
|
66
66
|
import './types-Bo2wkjSP.js';
|
|
67
67
|
import './graphql/services/index.js';
|
|
68
|
-
import './i18n-
|
|
68
|
+
import './i18n-Qm2AkPC-.js';
|
|
69
69
|
import './index-D3d2TAS-.js';
|
|
70
70
|
|
|
71
71
|
declare class ContextManager {
|
|
@@ -122,6 +122,9 @@ async function createOtelSdk(cfg) {
|
|
|
122
122
|
...sampler ? {
|
|
123
123
|
sampler
|
|
124
124
|
} : {},
|
|
125
|
+
...cfg.idGenerator ? {
|
|
126
|
+
idGenerator: cfg.idGenerator
|
|
127
|
+
} : {},
|
|
125
128
|
...autoInstrumentations ? {
|
|
126
129
|
instrumentations: autoInstrumentations
|
|
127
130
|
} : {}
|
|
@@ -149,5 +152,5 @@ async function createOtelSdk(cfg) {
|
|
|
149
152
|
__name(createOtelSdk, "createOtelSdk");
|
|
150
153
|
|
|
151
154
|
export { createOtelSdk };
|
|
152
|
-
//# sourceMappingURL=sdk-
|
|
153
|
-
//# sourceMappingURL=sdk-
|
|
155
|
+
//# sourceMappingURL=sdk-L75WWUP3.js.map
|
|
156
|
+
//# sourceMappingURL=sdk-L75WWUP3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/telemetry/sdk.ts"],"names":["isThenable","value","then","asyncDisposeMetricReader","metricReaderCandidate","shutdown","result","call","createOtelSdk","cfg","console","log","sdkNodeMod","sdkMod","resourcesMod","resources","semMod","sem","traceExpMod","traceExp","metricsExp","metricsExpMod","undefined","metricReader","metricsEnabled","metricsDropReason","OTLPMetricExporter","metricsSdkMod","metricsSdk","candidate","PeriodicExportingMetricReader","exporter","url","otlpEndpoint","replace","setProducer","setMetricProducer","sampler","traceBaseMod","traceBase","ParentBasedSampler","root","TraceIdRatioBasedSampler","Math","min","max","sampleRatio","autoInstrumentations","autoMod","auto","getNodeAutoInstrumentations","enabled","serviceNamespaceByBoundary","wspace","global","gateway","resourceAttributes","serviceName","serviceVersion","boundary","env","module","serviceInstanceId","process","clusterName","resource","resourceFromAttributes","traceExporter","OTLPTraceExporter","nodeSdk","NodeSDK","idGen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AA;AACAC,IAAAA;AACF,GAAA;AACF;AAtLsBjB,MAAAA,CAAAA,aAAAA,EAAAA,eAAAA,CAAAA","file":"sdk-L75WWUP3.js","sourcesContent":["/**\n * Thin wrapper that initializes `@opentelemetry/sdk-node` with the\n * OTLPTrace + OTLPMetric exporters and standard auto-instrumentations.\n *\n * All imports are dynamic so services that haven't installed sdk-node\n * still compile and run. The function resolves `undefined` when the SDK\n * isn't available, letting `bootstrapTelemetry` fall back gracefully.\n */\nimport type { TelemetryIdGenerator } from './id-generator.js';\nimport type { Boundary, Env } from './index.js';\n\nexport interface OtelSdkConfig {\n serviceName: string;\n serviceVersion: string;\n boundary: Boundary;\n module?: string;\n env: Env;\n otlpEndpoint: string;\n sampleRatio: number;\n /**\n * Optional trace/span id generator handed to NodeSDK's tracer provider.\n * Omitted means the SDK's default random generator.\n */\n idGenerator?: TelemetryIdGenerator;\n}\n\nexport interface OtelSdkHandle {\n shutdown: () => Promise<void>;\n metricsEnabled: boolean;\n metricsDropReason?: string;\n}\n\ntype Thenable = {\n then: (onfulfilled?: (value: void) => void, onrejected?: (reason: unknown) => void) => unknown;\n};\n\nconst isThenable = (value: unknown): value is Thenable => {\n return typeof value === 'object' && value !== null && typeof (value as { then?: unknown }).then === 'function';\n};\n\nconst asyncDisposeMetricReader = async (metricReaderCandidate: unknown): Promise<void> => {\n const shutdown = (metricReaderCandidate as { shutdown?: () => void | Promise<void> }).shutdown;\n if (typeof shutdown === 'function') {\n const result = shutdown.call(metricReaderCandidate) as unknown;\n if (isThenable(result)) await result;\n }\n};\n\nexport async function createOtelSdk(cfg: OtelSdkConfig): Promise<OtelSdkHandle> {\n // Use local string variables so TypeScript skips static module resolution for\n // optional peer dependencies that may not be installed.\n console.log('[sdk] importing @opentelemetry/sdk-node...');\n const sdkNodeMod = '@opentelemetry/sdk-node';\n const sdkMod = (await import(sdkNodeMod)) as unknown as {\n NodeSDK: new (init: Record<string, unknown>) => {\n start: () => void;\n shutdown: () => Promise<void>;\n };\n };\n\n console.log('[sdk] importing @opentelemetry/resources...');\n const resourcesMod = '@opentelemetry/resources';\n const resources = (await import(resourcesMod)) as unknown as {\n resourceFromAttributes: (attrs: Record<string, string | number>) => unknown;\n };\n\n console.log('[sdk] importing @opentelemetry/semantic-conventions...');\n const semMod = '@opentelemetry/semantic-conventions';\n const sem = (await import(semMod)) as unknown as Record<string, string>;\n\n console.log('[sdk] importing @opentelemetry/exporter-trace-otlp-http...');\n const traceExpMod = '@opentelemetry/exporter-trace-otlp-http';\n const traceExp = (await import(traceExpMod)) as unknown as {\n OTLPTraceExporter: new (init: Record<string, string>) => unknown;\n };\n\n console.log('[sdk] importing @opentelemetry/exporter-metrics-otlp-http...');\n let metricsExp: { OTLPMetricExporter?: new (init: Record<string, string>) => unknown } | undefined;\n try {\n const metricsExpMod = '@opentelemetry/exporter-metrics-otlp-http';\n metricsExp = await import(metricsExpMod);\n } catch {\n metricsExp = undefined;\n console.log('[sdk] metrics exporter not available (non-fatal)');\n }\n\n let metricReader: unknown;\n let metricsEnabled = false;\n let metricsDropReason: string | undefined;\n if (metricsExp?.OTLPMetricExporter) {\n try {\n const metricsSdkMod = '@opentelemetry/sdk-metrics';\n const metricsSdk = (await import(metricsSdkMod)) as unknown as {\n PeriodicExportingMetricReader: new (init: Record<string, unknown>) => unknown;\n };\n const candidate = new metricsSdk.PeriodicExportingMetricReader({\n exporter: new metricsExp.OTLPMetricExporter({\n url: `${cfg.otlpEndpoint.replace(/\\/$/, '')}/v1/metrics`,\n }),\n });\n // Pre-flight API compatibility check. Some OTel package version\n // combinations construct `PeriodicExportingMetricReader` successfully\n // but lack `setMetricProducer` on the prototype chain (mixed\n // sdk-metrics versions, or runtime-specific class-inheritance\n // quirks — Bun has surfaced this in the past). Without the check,\n // `NodeSDK.start()` may register the global tracer provider BEFORE\n // it tries to call `setMetricProducer` and throws — leaving the\n // global tracer pointing at a half-initialized provider whose\n // span pipeline never drains. Skipping the metric reader when the\n // API isn't there avoids that whole failure mode in one pass.\n const setProducer = (candidate as { setMetricProducer?: unknown }).setMetricProducer;\n if (typeof setProducer === 'function') {\n metricReader = candidate;\n metricsEnabled = true;\n } else {\n metricsDropReason =\n 'setMetricProducer is not a function on PeriodicExportingMetricReader; skipping metrics path';\n await asyncDisposeMetricReader(candidate);\n metricReader = undefined;\n }\n } catch {\n if (metricsDropReason === undefined) {\n metricsDropReason = 'metric reader construction or compatibility check failed';\n }\n metricReader = undefined;\n }\n }\n\n console.log('[sdk] importing @opentelemetry/sdk-trace-base for sampler...');\n let sampler: unknown;\n try {\n const traceBaseMod = '@opentelemetry/sdk-trace-base';\n const traceBase = (await import(traceBaseMod)) as unknown as {\n ParentBasedSampler: new (init: Record<string, unknown>) => unknown;\n TraceIdRatioBasedSampler: new (ratio: number) => unknown;\n };\n sampler = new traceBase.ParentBasedSampler({\n root: new traceBase.TraceIdRatioBasedSampler(Math.min(1, Math.max(0, cfg.sampleRatio))),\n });\n } catch {\n sampler = undefined;\n console.log('[sdk] sampler not available (non-fatal)');\n }\n\n // Some services have auto-instrumentations installed; optional.\n console.log('[sdk] importing @opentelemetry/auto-instrumentations-node...');\n let autoInstrumentations: unknown[] | undefined;\n try {\n const autoMod = '@opentelemetry/auto-instrumentations-node';\n const auto = (await import(autoMod)) as unknown as {\n getNodeAutoInstrumentations: (cfg?: Record<string, unknown>) => unknown[];\n };\n autoInstrumentations = auto.getNodeAutoInstrumentations({\n '@opentelemetry/instrumentation-fs': { enabled: false },\n });\n console.log('[sdk] auto-instrumentations loaded');\n } catch {\n autoInstrumentations = undefined;\n console.log('[sdk] auto-instrumentations not available (non-fatal)');\n }\n\n const serviceNamespaceByBoundary: Record<Boundary, string> = {\n wspace: 'workspaces',\n global: 'tenant',\n gateway: 'gateways',\n };\n const resourceAttributes: Record<string, string> = {\n [sem['SEMRESATTRS_SERVICE_NAME'] ?? 'service.name']: cfg.serviceName,\n [sem['SEMRESATTRS_SERVICE_VERSION'] ?? 'service.version']: cfg.serviceVersion,\n [sem['SEMRESATTRS_SERVICE_NAMESPACE'] ?? 'service.namespace']: serviceNamespaceByBoundary[cfg.boundary],\n [sem['SEMRESATTRS_DEPLOYMENT_ENVIRONMENT'] ?? 'deployment.environment']: cfg.env,\n 'burdenoff.boundary': cfg.boundary,\n };\n if (cfg.module) resourceAttributes['burdenoff.module'] = cfg.module;\n const serviceInstanceId = process.env['POD_NAME'] ?? process.env['HOSTNAME'];\n if (serviceInstanceId) resourceAttributes['service.instance.id'] = serviceInstanceId;\n const clusterName = process.env['CLUSTER_NAME'];\n if (clusterName) {\n resourceAttributes['cluster'] = clusterName;\n resourceAttributes['k8s.cluster.name'] = clusterName;\n }\n\n const resource = resources.resourceFromAttributes(resourceAttributes);\n\n const traceExporter = new traceExp.OTLPTraceExporter({\n url: `${cfg.otlpEndpoint.replace(/\\/$/, '')}/v1/traces`,\n });\n\n // Single NodeSDK, single start. The pre-flight `setMetricProducer`\n // check above means we never pass an incompatible metric reader into\n // NodeSDK construction — so we no longer need the prior catch+rebuild\n // fallback dance, which had its own side-effect: the failed first\n // NodeSDK could leave the global tracer provider partially registered,\n // and the second NodeSDK's `setGlobalTracerProvider` becomes a no-op\n // — meaning spans flow into the FIRST (broken) provider and never\n // reach the exporter. Eliminating the fallback eliminates that hazard.\n console.log('[sdk] constructing NodeSDK...');\n const nodeSdk = new sdkMod.NodeSDK({\n resource,\n traceExporter,\n ...(metricReader ? { metricReader } : {}),\n ...(sampler ? { sampler } : {}),\n ...(cfg.idGenerator ? { idGenerator: cfg.idGenerator } : {}),\n ...(autoInstrumentations ? { instrumentations: autoInstrumentations } : {}),\n });\n console.log('[sdk] NodeSDK constructed, calling start()...');\n // NodeSDK.start() returns void in modern versions and Promise<void> in older\n // ones. Cast to a permissive thenable shape so awaiting works either way\n // without tripping `@typescript-eslint/await-thenable`.\n const startResult = nodeSdk.start() as unknown;\n if (isThenable(startResult)) {\n await startResult;\n }\n console.log('[sdk] NodeSDK started');\n\n // Stash the @opentelemetry/api reference for pino-logger's mixin.\n try {\n const otelApiMod = '@opentelemetry/api';\n (globalThis as unknown as { __otelApi?: unknown }).__otelApi = await import(otelApiMod);\n console.log('[sdk] @opentelemetry/api stashed for pino mixin');\n } catch {\n console.log('[sdk] @opentelemetry/api stash failed (non-fatal)');\n }\n\n console.log('[sdk] OTel SDK initialization complete');\n return {\n shutdown: async (): Promise<void> => nodeSdk.shutdown(),\n metricsEnabled,\n metricsDropReason,\n };\n}\n"]}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { W as WorkspaceSecret, I as IActor, J as JWTPayload, S as ServerDefinition, a as ServerInstance, R as RESTEndpoint, b as ITenant, G as GraphQLContext, V as VerifiedDelegationContext, Y as YogaPlugin } from '../types-
|
|
2
|
-
export { A as ActorProvenance, 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, j as ServerConfig, k as ServerI18nConfig, l as ServerInfo, m as WspaceGraphQLContext } from '../types-
|
|
1
|
+
import { W as WorkspaceSecret, I as IActor, J as JWTPayload, S as ServerDefinition, a as ServerInstance, R as RESTEndpoint, b as ITenant, G as GraphQLContext, V as VerifiedDelegationContext, Y as YogaPlugin } from '../types-USOv09qy.js';
|
|
2
|
+
export { A as ActorProvenance, 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, j as ServerConfig, k as ServerI18nConfig, l as ServerInfo, m as WorkspaceGuardConfig, n as WorkspaceMembershipValidation, o as WspaceGraphQLContext, p as createWorkspaceGuardPlugin } from '../types-USOv09qy.js';
|
|
3
3
|
import * as jose from 'jose';
|
|
4
4
|
import { VerifyOptions } from 'jsonwebtoken';
|
|
5
|
-
import { I as I18n } from '../i18n-
|
|
5
|
+
import { I as I18n } from '../i18n-Qm2AkPC-.js';
|
|
6
6
|
export { c as ACTOR_ORIGIN_HEADER, a as AI_ASSISTANT_ACTOR_ORIGIN, d as ASSISTANT_CORRELATION_ID_HEADER, e as ASSISTANT_SESSION_ID_HEADER, b as ActorOrigin, A as AssistantSessionAttribution, p as parseAssistantSessionHeaders, r as readAssistantSessionAttribution, t as toAssistantSessionAttribution } from '../assistant-session-CJZhF4D6.js';
|
|
7
7
|
import { DocumentNode, GraphQLError } from 'graphql';
|
|
8
8
|
import { Plugin } from 'graphql-yoga';
|
|
9
9
|
export { s as suppressMutationAudit } from '../explicit-activity-scope-CCoxVwAr.js';
|
|
10
|
-
export {
|
|
10
|
+
export { b as I18nContext, L as LocaleCode } from '../types-DVpvrAhd.js';
|
|
11
11
|
export { P as PrismaClientBase } from '../client-CCXpAZ2r.js';
|
|
12
12
|
import '../workspace-extension-BGwTOV_r.js';
|
|
13
13
|
import '@prisma/adapter-pg';
|
|
@@ -107,76 +107,6 @@ declare function getDelegatedPrincipal(context: {
|
|
|
107
107
|
verifiedDelegation?: VerifiedDelegationContext;
|
|
108
108
|
}): DelegatedPrincipal | null;
|
|
109
109
|
|
|
110
|
-
interface WorkspaceGuardConfig {
|
|
111
|
-
enabled?: boolean;
|
|
112
|
-
whitelistedOperations?: string[];
|
|
113
|
-
errorMessage?: string;
|
|
114
|
-
allowPublicDirective?: boolean;
|
|
115
|
-
}
|
|
116
|
-
interface FieldLikeDef {
|
|
117
|
-
astNode?: {
|
|
118
|
-
directives?: ReadonlyArray<{
|
|
119
|
-
name: {
|
|
120
|
-
value: string;
|
|
121
|
-
};
|
|
122
|
-
arguments?: ReadonlyArray<{
|
|
123
|
-
name: {
|
|
124
|
-
value: string;
|
|
125
|
-
};
|
|
126
|
-
value: {
|
|
127
|
-
kind: string;
|
|
128
|
-
value?: unknown;
|
|
129
|
-
};
|
|
130
|
-
}>;
|
|
131
|
-
}>;
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
interface SchemaLike {
|
|
135
|
-
getQueryType?: () => {
|
|
136
|
-
getFields: () => Record<string, FieldLikeDef>;
|
|
137
|
-
} | null | undefined;
|
|
138
|
-
getMutationType?: () => {
|
|
139
|
-
getFields: () => Record<string, FieldLikeDef>;
|
|
140
|
-
} | null | undefined;
|
|
141
|
-
getSubscriptionType?: () => {
|
|
142
|
-
getFields: () => Record<string, FieldLikeDef>;
|
|
143
|
-
} | null | undefined;
|
|
144
|
-
}
|
|
145
|
-
interface DocumentLike {
|
|
146
|
-
definitions?: ReadonlyArray<{
|
|
147
|
-
kind?: string;
|
|
148
|
-
operation?: string;
|
|
149
|
-
name?: {
|
|
150
|
-
value?: string;
|
|
151
|
-
};
|
|
152
|
-
selectionSet?: {
|
|
153
|
-
selections?: ReadonlyArray<{
|
|
154
|
-
kind?: string;
|
|
155
|
-
name?: {
|
|
156
|
-
value?: string;
|
|
157
|
-
};
|
|
158
|
-
}>;
|
|
159
|
-
};
|
|
160
|
-
}>;
|
|
161
|
-
}
|
|
162
|
-
declare function createWorkspaceGuardPlugin(config?: WorkspaceGuardConfig): {
|
|
163
|
-
onExecute?: undefined;
|
|
164
|
-
} | {
|
|
165
|
-
onExecute({ args, }: {
|
|
166
|
-
args: {
|
|
167
|
-
schema?: SchemaLike;
|
|
168
|
-
document?: DocumentLike;
|
|
169
|
-
operationName?: string | null;
|
|
170
|
-
contextValue?: {
|
|
171
|
-
workspace?: {
|
|
172
|
-
id?: string;
|
|
173
|
-
};
|
|
174
|
-
request?: Request;
|
|
175
|
-
};
|
|
176
|
-
};
|
|
177
|
-
}): undefined;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
110
|
declare const MUTATION_AUDIT_ACTIVITY_TYPE = "graphql.mutation";
|
|
181
111
|
declare const MUTATION_AUDIT_RESOURCE_TYPE = "graphql_mutation";
|
|
182
112
|
interface MutationAuditPluginOptions {
|
|
@@ -231,4 +161,4 @@ declare function createHumanReadableErrorPlugin(options?: ErrorNormalizationOpti
|
|
|
231
161
|
declare function formatHttpError(error: unknown, options?: ErrorNormalizationOptions): HttpErrorResult;
|
|
232
162
|
declare function createHttpErrorResponse(error: unknown, options?: ErrorNormalizationOptions): Response;
|
|
233
163
|
|
|
234
|
-
export { type AuthConfig, type ContextBuilderOptions, type DelegatedPrincipal, type ErrorNormalizationOptions, type FetchWorkspaceSecretFn, GraphQLContext, type HttpErrorPayload, type HttpErrorResult, IActor, ITenant, JWTPayload, MAX_IDLE_TIMEOUT_SECONDS, MUTATION_AUDIT_ACTIVITY_TYPE, MUTATION_AUDIT_RESOURCE_TYPE, type MutationAuditPluginOptions, type NormalizedErrorState, type OrdinaryRoute, RESTEndpoint, type RawBodyResolution, type RawBodyRouter, ServerDefinition, ServerInstance, type UserFacingErrorOptions, UserFacingGraphQLError, VerifiedDelegationContext,
|
|
164
|
+
export { type AuthConfig, type ContextBuilderOptions, type DelegatedPrincipal, type ErrorNormalizationOptions, type FetchWorkspaceSecretFn, GraphQLContext, type HttpErrorPayload, type HttpErrorResult, IActor, ITenant, JWTPayload, MAX_IDLE_TIMEOUT_SECONDS, MUTATION_AUDIT_ACTIVITY_TYPE, MUTATION_AUDIT_RESOURCE_TYPE, type MutationAuditPluginOptions, type NormalizedErrorState, type OrdinaryRoute, RESTEndpoint, type RawBodyResolution, type RawBodyRouter, ServerDefinition, ServerInstance, type UserFacingErrorOptions, UserFacingGraphQLError, VerifiedDelegationContext, WorkspaceSecret, YogaPlugin, authCheck, buildContext, configureAuth, configureContext, configureDefaultAuth, configureServerAuth, createHttpErrorResponse, createHumanReadableErrorPlugin, createMutationAuditPlugin, createRawBodyRouter, createServer, decodeJWT, extendRequestIdleTimeout, fetchWorkspaceSecret, formatHttpError, generateSymmetricSecret, getContextOptions, getDelegatedPrincipal, getMutationFieldNames, normalizeError, normalizeExecutionResultErrors, normalizeGraphQLResponse, normalizeGraphQLResponsePayload, orgCheck, requireWorkspace, resolveOnBehalfOf, sanitizeAuditValue, tenantCheck, toUserFacingGraphQLError, verifyJWT, workspaceCheck };
|
package/dist/server/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createHumanReadableErrorPlugin, formatHttpError, normalizeGraphQLResponse, createHttpErrorResponse } from '../chunk-
|
|
2
|
-
export { UserFacingGraphQLError, createHttpErrorResponse, createHumanReadableErrorPlugin, createWorkspaceGuardPlugin, formatHttpError, normalizeError, normalizeExecutionResultErrors, normalizeGraphQLResponse, normalizeGraphQLResponsePayload, toUserFacingGraphQLError } from '../chunk-
|
|
1
|
+
import { createHumanReadableErrorPlugin, formatHttpError, normalizeGraphQLResponse, createHttpErrorResponse } from '../chunk-5CJBZZLS.js';
|
|
2
|
+
export { UserFacingGraphQLError, createHttpErrorResponse, createHumanReadableErrorPlugin, createWorkspaceGuardPlugin, formatHttpError, normalizeError, normalizeExecutionResultErrors, normalizeGraphQLResponse, normalizeGraphQLResponsePayload, toUserFacingGraphQLError } from '../chunk-5CJBZZLS.js';
|
|
3
3
|
import { getWorkspaceQuotaRegistry } from '../chunk-WTEHAVBX.js';
|
|
4
4
|
import { parseAssistantSessionHeaders, readAssistantSessionAttribution, trackOperation, createExplicitActivityScope, runInExplicitActivityScope } from '../chunk-TANAOLAV.js';
|
|
5
5
|
export { ACTOR_ORIGIN_HEADER, AI_ASSISTANT_ACTOR_ORIGIN, ASSISTANT_CORRELATION_ID_HEADER, ASSISTANT_SESSION_ID_HEADER, parseAssistantSessionHeaders, readAssistantSessionAttribution, suppressMutationAudit, toAssistantSessionAttribution } from '../chunk-TANAOLAV.js';
|
|
@@ -942,7 +942,7 @@ async function createServer(definition) {
|
|
|
942
942
|
const { initializeDatabase, getDb: getDb2, getDatabaseManager } = await import('../prisma/index.js');
|
|
943
943
|
const { createSecurityPlugin } = await import('../middleware/index.js');
|
|
944
944
|
const { createMetricsPlugin } = await import('../observability/index.js');
|
|
945
|
-
const { createWorkspaceGuardPlugin: createWorkspaceGuardPlugin2 } = await import('../workspace-guard-
|
|
945
|
+
const { createWorkspaceGuardPlugin: createWorkspaceGuardPlugin2 } = await import('../workspace-guard-ADPSEN6E.js');
|
|
946
946
|
logger.info(`[Server] Initializing ${config.serviceName}...`);
|
|
947
947
|
const boundary = config.boundary ?? (config.serviceName.startsWith("wspace-") ? "wspace" : config.serviceName.startsWith("global-") ? "global" : "wspace");
|
|
948
948
|
const shouldEnableWorkspaceExtension = disableWorkspaceExtension === true ? false : disableWorkspaceExtension === false ? true : boundary === "wspace";
|
|
@@ -992,7 +992,9 @@ async function createServer(definition) {
|
|
|
992
992
|
const workspaceGuardPlugins = workspaceGuardEnabled ? [
|
|
993
993
|
createWorkspaceGuardPlugin2({
|
|
994
994
|
enabled: true,
|
|
995
|
-
whitelistedOperations: config.workspaceGuard?.whitelistedOperations
|
|
995
|
+
whitelistedOperations: config.workspaceGuard?.whitelistedOperations,
|
|
996
|
+
whitelistedFields: config.workspaceGuard?.whitelistedFields,
|
|
997
|
+
validateWorkspaceMembership: config.workspaceGuard?.validateWorkspaceMembership
|
|
996
998
|
})
|
|
997
999
|
] : [];
|
|
998
1000
|
const graphqlEndpoint = config.graphqlEndpoint || "/graphql";
|