@burdenoff/be-sdk 2026.528.1 → 2026.529.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.
@@ -1,127 +0,0 @@
1
- import { logger } from './chunk-CBZNP6RF.js';
2
- import { __name } from './chunk-XE4OXN2W.js';
3
-
4
- // src/server/workspace-guard.ts
5
- var WorkspaceRequiredError = class WorkspaceRequiredError2 extends Error {
6
- static {
7
- __name(this, "WorkspaceRequiredError");
8
- }
9
- extensions;
10
- constructor(message) {
11
- super(message);
12
- this.name = "WorkspaceRequiredError";
13
- this.extensions = {
14
- code: "WORKSPACE_REQUIRED",
15
- http: {
16
- status: 403
17
- }
18
- };
19
- }
20
- };
21
- function isFieldPublic(field) {
22
- const directives = field?.astNode?.directives;
23
- if (!directives || directives.length === 0) return false;
24
- for (const dir of directives) {
25
- const name = dir.name?.value;
26
- if (name === "public") return true;
27
- if (name === "rbac") {
28
- const args = dir.arguments ?? [];
29
- for (const arg of args) {
30
- if (arg.name?.value === "public" && arg.value?.kind === "BooleanValue" && arg.value.value === true) {
31
- return true;
32
- }
33
- }
34
- }
35
- }
36
- return false;
37
- }
38
- __name(isFieldPublic, "isFieldPublic");
39
- function resolveOperationType(document, operationName) {
40
- const defs = document?.definitions ?? [];
41
- for (const def of defs) {
42
- if (def.kind !== "OperationDefinition") ;
43
- if (def.operation && (!operationName || def.name?.value === operationName)) {
44
- return def.operation;
45
- }
46
- }
47
- return "query";
48
- }
49
- __name(resolveOperationType, "resolveOperationType");
50
- function allRootFieldsPublic(schema, document, operationName) {
51
- if (!schema || !document) return false;
52
- const opType = resolveOperationType(document, operationName);
53
- let rootType;
54
- if (opType === "mutation") {
55
- rootType = schema.getMutationType?.();
56
- } else if (opType === "subscription") {
57
- rootType = schema.getSubscriptionType?.();
58
- } else {
59
- rootType = schema.getQueryType?.();
60
- }
61
- if (!rootType) return false;
62
- const fields = rootType.getFields();
63
- const defs = document.definitions ?? [];
64
- const opDef = defs.find((d) => d.operation && (!operationName || d.name?.value === operationName));
65
- const selections = opDef?.selectionSet?.selections ?? [];
66
- if (selections.length === 0) return false;
67
- for (const sel of selections) {
68
- if (sel.kind && sel.kind !== "Field") return false;
69
- const fieldName = sel.name?.value;
70
- if (!fieldName) return false;
71
- if (fieldName.startsWith("__")) continue;
72
- const fieldDef = fields[fieldName];
73
- if (!isFieldPublic(fieldDef)) return false;
74
- }
75
- return true;
76
- }
77
- __name(allRootFieldsPublic, "allRootFieldsPublic");
78
- function createWorkspaceGuardPlugin(config) {
79
- const enabled = config?.enabled ?? true;
80
- const whitelistedOperations = new Set(config?.whitelistedOperations ?? []);
81
- const allowPublicDirective = config?.allowPublicDirective ?? true;
82
- const errorMessage = config?.errorMessage ?? "Workspace context required. Ensure the request includes a valid workspace context (x-workspace-id header).";
83
- if (!enabled) {
84
- logger.info("[WorkspaceGuard] Workspace guard disabled");
85
- return {};
86
- }
87
- logger.info("[WorkspaceGuard] Workspace guard enabled", {
88
- whitelistedOperations: [
89
- ...whitelistedOperations
90
- ],
91
- allowPublicDirective
92
- });
93
- return {
94
- onExecute({ args }) {
95
- let operationName = args.operationName;
96
- if (!operationName && args.document?.definitions) {
97
- for (const def of args.document.definitions) {
98
- if (def.operation && def.name?.value) {
99
- operationName = def.name.value;
100
- break;
101
- }
102
- }
103
- }
104
- if (operationName && whitelistedOperations.has(operationName)) {
105
- return void 0;
106
- }
107
- if (allowPublicDirective && allRootFieldsPublic(args.schema, args.document, operationName)) {
108
- return void 0;
109
- }
110
- const context = args.contextValue;
111
- const workspaceId = context?.workspace?.id;
112
- const headerWorkspaceId = context?.request?.headers?.get?.("x-workspace-id");
113
- if (!workspaceId && !headerWorkspaceId) {
114
- logger.warn("[WorkspaceGuard] Blocked operation without workspace context", {
115
- operationName: operationName ?? "<anonymous>"
116
- });
117
- throw new WorkspaceRequiredError(errorMessage);
118
- }
119
- return void 0;
120
- }
121
- };
122
- }
123
- __name(createWorkspaceGuardPlugin, "createWorkspaceGuardPlugin");
124
-
125
- export { createWorkspaceGuardPlugin };
126
- //# sourceMappingURL=chunk-BTQREMD4.js.map
127
- //# sourceMappingURL=chunk-BTQREMD4.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/server/workspace-guard.ts"],"names":["WorkspaceRequiredError","Error","extensions","message","name","code","http","status","isFieldPublic","field","directives","astNode","length","dir","value","args","arguments","arg","kind","resolveOperationType","document","operationName","defs","definitions","def","operation","allRootFieldsPublic","schema","opType","rootType","getMutationType","getSubscriptionType","getQueryType","fields","getFields","opDef","find","d","selections","selectionSet","sel","fieldName","startsWith","fieldDef","createWorkspaceGuardPlugin","config","enabled","whitelistedOperations","Set","allowPublicDirective","errorMessage","logger","info","onExecute","has","undefined","context","contextValue","workspaceId","workspace","id","headerWorkspaceId","request","headers","get","warn"],"mappings":";;;;AA4EA,IAAMA,sBAAAA,GAAN,MAAMA,uBAAAA,SAA+BC,KAAAA,CAAAA;EA5ErC;;;AA6EkBC,EAAAA,UAAAA;AAEhB,EAAA,WAAA,CAAYC,OAAAA,EAAiB;AAC3B,IAAA,KAAA,CAAMA,OAAAA,CAAAA;AACN,IAAA,IAAA,CAAKC,IAAAA,GAAO,wBAAA;AACZ,IAAA,IAAA,CAAKF,UAAAA,GAAa;MAChBG,IAAAA,EAAM,oBAAA;MACNC,IAAAA,EAAM;QAAEC,MAAAA,EAAQ;AAAI;AACtB,KAAA;AACF,EAAA;AACF,CAAA;AAkCA,SAASC,cAAcC,KAAAA,EAA+B;AACpD,EAAA,MAAMC,UAAAA,GAAaD,OAAOE,OAAAA,EAASD,UAAAA;AACnC,EAAA,IAAI,CAACA,UAAAA,IAAcA,UAAAA,CAAWE,MAAAA,KAAW,GAAG,OAAO,KAAA;AAEnD,EAAA,KAAA,MAAWC,OAAOH,UAAAA,EAAY;AAC5B,IAAA,MAAMN,IAAAA,GAAOS,IAAIT,IAAAA,EAAMU,KAAAA;AACvB,IAAA,IAAIV,IAAAA,KAAS,UAAU,OAAO,IAAA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A;AAGA,MAAA,IAAIN,wBAAwBvB,mBAAAA,CAAoBX,IAAAA,CAAKY,QAAQZ,IAAAA,CAAKK,QAAAA,EAAUC,aAAAA,CAAAA,EAAgB;AAC1F,QAAA,OAAOkC,MAAAA;AACT,MAAA;AAGA,MAAA,MAAMC,UAAUzC,IAAAA,CAAK0C,YAAAA;AACrB,MAAA,MAAMC,WAAAA,GAAcF,SAASG,SAAAA,EAAWC,EAAAA;AAGxC,MAAA,MAAMC,iBAAAA,GAAoBL,OAAAA,EAASM,OAAAA,EAASC,OAAAA,EAASC,MAAM,gBAAA,CAAA;AAE3D,MAAA,IAAI,CAACN,WAAAA,IAAe,CAACG,iBAAAA,EAAmB;AACtCV,QAAAA,MAAAA,CAAOc,KAAK,8DAAA,EAAgE;AAC1E5C,UAAAA,aAAAA,EAAeA,aAAAA,IAAiB;SAClC,CAAA;AACA,QAAA,MAAM,IAAIrB,uBAAuBkD,YAAAA,CAAAA;AACnC,MAAA;AAEA,MAAA,OAAOK,MAAAA;AACT,IAAA;AACF,GAAA;AACF;AApEgBX,MAAAA,CAAAA,0BAAAA,EAAAA,4BAAAA,CAAAA","file":"chunk-BTQREMD4.js","sourcesContent":["/**\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';\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 * @default []\n *\n * @example\n * ```typescript\n * whitelistedOperations: ['createWorkspace', 'validateTokens']\n * ```\n */\n whitelistedOperations?: string[];\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// GraphQL Error\n// ============================================================================\n\n/**\n * Workspace required error with proper GraphQL error extensions\n */\nclass WorkspaceRequiredError extends Error {\n public readonly extensions: { code: string; http: { status: number } };\n\n constructor(message: string) {\n super(message);\n this.name = 'WorkspaceRequiredError';\n this.extensions = {\n code: 'WORKSPACE_REQUIRED',\n http: { status: 403 },\n };\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 * Returns true iff every root field in the document selection set is marked\n * public on the schema. Empty selection sets return false (fail-closed).\n */\nfunction allRootFieldsPublic(\n schema: SchemaLike | undefined,\n document: DocumentLike | undefined,\n operationName: string | null | undefined\n): boolean {\n if (!schema || !document) 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 const defs = document.definitions ?? [];\n\n // Find the operation definition matching operationName (or first one).\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 false;\n\n for (const sel of selections) {\n // Only consider plain Field selections (skip fragments — fragments at the root\n // shouldn't drive a public bypass; fail-closed there).\n if (sel.kind && sel.kind !== 'Field') return false;\n const fieldName = sel.name?.value;\n if (!fieldName) return false;\n // __schema / __type introspection is always allowed without workspace context;\n // treat them as public.\n if (fieldName.startsWith('__')) continue;\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 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 allowPublicDirective,\n });\n\n return {\n onExecute({\n args,\n }: {\n args: {\n schema?: SchemaLike;\n document?: DocumentLike;\n operationName?: string | null;\n contextValue?: { workspace?: { id?: string }; request?: Request };\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\n if (operationName && whitelistedOperations.has(operationName)) {\n return undefined;\n }\n\n // Check schema-directive-based public bypass (Option C)\n if (allowPublicDirective && allRootFieldsPublic(args.schema, args.document, operationName)) {\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 return undefined;\n },\n };\n}\n"]}
@@ -1,5 +0,0 @@
1
- export { createWorkspaceGuardPlugin } from './chunk-BTQREMD4.js';
2
- import './chunk-CBZNP6RF.js';
3
- import './chunk-XE4OXN2W.js';
4
- //# sourceMappingURL=workspace-guard-524GBJQ6.js.map
5
- //# sourceMappingURL=workspace-guard-524GBJQ6.js.map