@burdenoff/be-sdk 2026.1130.3 → 2026.1201.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/dist/context/index.js +7 -2
- package/dist/context/index.js.map +1 -1
- package/dist/files/index.d.ts +2 -2
- package/dist/files/index.js +2 -2
- package/dist/{files-h5U-D2AF.js → files-BISdM0fh.js} +188 -28
- package/dist/files-BISdM0fh.js.map +1 -0
- package/dist/{bun-runtime-metrics-CPy5D6NT.js → incoming-request-span-DCou42Il.js} +56 -2
- package/dist/incoming-request-span-DCou42Il.js.map +1 -0
- package/dist/{index-8pUSoT85.d.ts → index-ieSQpD9r.d.ts} +26 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/prisma/index.js +2 -2
- package/dist/{prisma-Bo-C0XUv.js → prisma-D0f-THMv.js} +2 -2
- package/dist/{prisma-Bo-C0XUv.js.map → prisma-D0f-THMv.js.map} +1 -1
- package/dist/{sdk-7TBR987n.js → sdk-Oooulm2n.js} +22 -6
- package/dist/sdk-Oooulm2n.js.map +1 -0
- package/dist/server/index.js +5 -5
- package/dist/server/index.js.map +1 -1
- package/dist/{stub-DNkzpQvR.js → stub-CmVOE6ql.js} +2 -2
- package/dist/{stub-DNkzpQvR.js.map → stub-CmVOE6ql.js.map} +1 -1
- package/dist/telemetry/index.d.ts +40 -2
- package/dist/telemetry/index.js +3 -3
- package/dist/telemetry/index.js.map +1 -1
- package/dist/tracker/index.js +2 -2
- package/dist/{tracker-CDVYIoCb.js → tracker-CNF8TRpk.js} +2 -2
- package/dist/{tracker-CDVYIoCb.js.map → tracker-CNF8TRpk.js.map} +1 -1
- package/dist/{workspace-extension-BcMPoGWr.js → workspace-extension-feJYFO9e.js} +41 -8
- package/dist/workspace-extension-feJYFO9e.js.map +1 -0
- package/package.json +1 -1
- package/dist/bun-runtime-metrics-CPy5D6NT.js.map +0 -1
- package/dist/files-h5U-D2AF.js.map +0 -1
- package/dist/sdk-7TBR987n.js.map +0 -1
- package/dist/workspace-extension-BcMPoGWr.js.map +0 -1
package/README.md
CHANGED
|
@@ -274,7 +274,12 @@ service must still authorize the action itself (its own `@rbac` plus a scoped ro
|
|
|
274
274
|
- Only scalar `File` fields are read through the ROOT `getFile` field: files-svc's `File`
|
|
275
275
|
entity has no `__resolveReference`, so never select federated `file { name }` elsewhere.
|
|
276
276
|
- Errors are `FilesClientError` with a stable `code` (`NOT_FOUND`, `QUOTA_EXCEEDED`,
|
|
277
|
-
`TOO_LARGE`, `STORAGE_ERROR`, …) and `graphqlCode`.
|
|
277
|
+
`TOO_LARGE`, `STORAGE_ERROR`, …) and `graphqlCode`. `summary` is one sanitised line for
|
|
278
|
+
logs and run errors, such as
|
|
279
|
+
`UPSTREAM_ERROR (INTERNAL_SERVER_ERROR, files.errors.fileExtensionCannotBeNull): wspace-files-svc getFile.extension failed: …`.
|
|
280
|
+
It is built only from the upstream code, i18n key, failing field, trace id, HTTP status and a
|
|
281
|
+
capped message with URLs and tokens removed. `upstreamErrors` holds the same fields per error.
|
|
282
|
+
Request variables and headers are never copied into the error.
|
|
278
283
|
|
|
279
284
|
```typescript
|
|
280
285
|
import { FilesClient, toFileReference } from '@burdenoff/be-sdk/files';
|
package/dist/context/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as getScopedWorkspaceContext } from "../workspace-extension-
|
|
1
|
+
import { c as getScopedWorkspaceContext } from "../workspace-extension-feJYFO9e.js";
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
3
|
|
|
4
4
|
// src/context/index.ts
|
|
@@ -114,9 +114,14 @@ var ContextManager = class {
|
|
|
114
114
|
/**
|
|
115
115
|
* Run function with specific context
|
|
116
116
|
* Context is isolated to this execution and its children
|
|
117
|
+
*
|
|
118
|
+
* Whatever `fn` returns is awaited inside the scope, so a lazy thenable (such as a Prisma
|
|
119
|
+
* query) returned un-awaited still starts while the context is bound (BOFF-17566).
|
|
117
120
|
*/
|
|
118
121
|
static async withContext(context, fn) {
|
|
119
|
-
return asyncLocalStorage.run(context,
|
|
122
|
+
return asyncLocalStorage.run(context, async () => {
|
|
123
|
+
return await fn();
|
|
124
|
+
});
|
|
120
125
|
}
|
|
121
126
|
/**
|
|
122
127
|
* Run synchronous function with specific context
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/context/index.ts"],"sourcesContent":["/**\n * Context Module\n * Manages request-scoped context using AsyncLocalStorage\n * Thread-safe context propagation for async operations\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport { getScopedWorkspaceContext } from '../prisma/workspace-extension.js';\nimport type { CfAccessCredentials, SDKContext } from '../types/index.js';\n\nconst asyncLocalStorage = new AsyncLocalStorage<SDKContext>();\n\n/**\n * A Cloudflare Access service token the service configured for itself, from its own\n * configuration (for example `CF_ACCESS_CLIENT_ID` / `CF_ACCESS_CLIENT_SECRET` in its\n * environment), via {@link ContextManager.configureCfAccessServiceToken}.\n *\n * This is the only process-wide Cloudflare Access state. It is never written from request\n * data: credentials an inbound request presented live only in that request's bound async\n * scope (see {@link ContextManager.getCfAccessHeaders}).\n */\nlet configuredServiceToken: { clientId: string; clientSecret: string } | undefined;\n\nfunction nonEmpty(value: string | undefined): string | undefined {\n return typeof value === 'string' && value.length > 0 ? value : undefined;\n}\n\n/**\n * The Cloudflare Access credentials bound to the current async scope: the ContextManager\n * store first, then the request scope the SDK server binds for GraphQL execution and REST\n * handlers. Reads only bound stores, never the deprecated warn-mode workspace fallback.\n */\nfunction scopedCfAccess(): CfAccessCredentials | undefined {\n const context = asyncLocalStorage.getStore();\n const fromContext: CfAccessCredentials = {\n clientId: nonEmpty(context?.cfAccessClientId),\n clientSecret: nonEmpty(context?.cfAccessClientSecret),\n authorization: nonEmpty(context?.cfAuthorization),\n };\n const fromRequestScope = getScopedWorkspaceContext()?.cfAccess;\n const contextHasPair = Boolean(fromContext.clientId && fromContext.clientSecret);\n const scopeHasPair = Boolean(fromRequestScope?.clientId && fromRequestScope.clientSecret);\n // The service-token pair is taken from one source as a unit, never mixed across stores.\n const pair = contextHasPair ? fromContext : scopeHasPair ? fromRequestScope : undefined;\n const authorization = fromContext.authorization ?? nonEmpty(fromRequestScope?.authorization);\n if (!pair && !authorization) return undefined;\n return {\n ...(pair ? { clientId: pair.clientId, clientSecret: pair.clientSecret } : {}),\n ...(authorization ? { authorization } : {}),\n };\n}\n\n/** The service-token pair for the current scope, else the token the service configured. */\nfunction serviceTokenPair(\n scoped: CfAccessCredentials | undefined = scopedCfAccess()\n): { clientId: string; clientSecret: string } | undefined {\n if (scoped?.clientId && scoped.clientSecret) {\n return { clientId: scoped.clientId, clientSecret: scoped.clientSecret };\n }\n return configuredServiceToken;\n}\n\n/**\n * Context Manager for handling request-scoped context\n */\nexport class ContextManager {\n /**\n * Get current context from async local storage\n */\n public static getContext(): SDKContext | undefined {\n return asyncLocalStorage.getStore();\n }\n\n /**\n * Set context for current async scope\n * Merges with existing context if present\n */\n public static setContext(context: SDKContext): void {\n const currentContext = this.getContext() || {};\n asyncLocalStorage.enterWith({ ...currentContext, ...context });\n }\n\n /**\n * Configure a Cloudflare Access service token the service holds for itself, read from its own\n * configuration (never from a request). Cross-layer calls attach it when the current request\n * scope carries no service-token pair of its own, which lets background work (stream\n * consumers, schedulers, CLIs) pass a Cloudflare-Access-gated peer gateway.\n *\n * Pass both values to set the token, or call it with no arguments to remove it. A lone half\n * is ignored, since it can never pass Access.\n *\n * @example\n * ```typescript\n * ContextManager.configureCfAccessServiceToken(process.env.CF_ACCESS_CLIENT_ID, process.env.CF_ACCESS_CLIENT_SECRET);\n * ```\n */\n public static configureCfAccessServiceToken(clientId?: string, clientSecret?: string): void {\n const id = nonEmpty(clientId);\n const secret = nonEmpty(clientSecret);\n if (id && secret) {\n configuredServiceToken = { clientId: id, clientSecret: secret };\n } else if (id === undefined && secret === undefined) {\n configuredServiceToken = undefined;\n }\n }\n\n /**\n * @deprecated Use {@link ContextManager.configureCfAccessServiceToken} with the service's own\n * token. Credentials a request presents no longer need recording: the SDK server binds them\n * to that request's scope.\n *\n * Kept for services that seed their own token from configuration. It sets the service token\n * when both values are present and otherwise does nothing. The `CF_Authorization` cookie is a\n * per-user credential, so it is never stored process-wide and the third argument is ignored.\n */\n public static setCfAccessContext(clientId?: string, clientSecret?: string, _cfAuthorization?: string): void {\n if (nonEmpty(clientId) && nonEmpty(clientSecret)) {\n this.configureCfAccessServiceToken(clientId, clientSecret);\n }\n }\n\n /**\n * Run function with specific context\n * Context is isolated to this execution and its children\n */\n public static async withContext<T>(context: SDKContext, fn: () => Promise<T>): Promise<T> {\n return asyncLocalStorage.run(context, fn);\n }\n\n /**\n * Run synchronous function with specific context\n */\n public static withContextSync<T>(context: SDKContext, fn: () => T): T {\n return asyncLocalStorage.run(context, fn);\n }\n\n /**\n * Clear current context, including any configured Cloudflare Access service token.\n */\n public static clearContext(): void {\n asyncLocalStorage.disable();\n configuredServiceToken = undefined;\n }\n\n /**\n * Get actor ID from context\n */\n public static getActorId(): string | undefined {\n return this.getContext()?.actorId;\n }\n\n /**\n * Get legacy user ID from context.\n */\n public static getUser(): string | undefined {\n const context = this.getContext();\n const userId = context?.['userId'];\n return typeof userId === 'string' ? userId : context?.actorId;\n }\n\n /**\n * Get workspace ID from context\n */\n public static getWorkspace(): string | undefined {\n return this.getContext()?.workspaceId;\n }\n\n /**\n * Get tenant ID from context\n */\n public static getTenant(): string | undefined {\n return this.getContext()?.tenantId;\n }\n\n /**\n * Get legacy organization ID from context.\n */\n public static getOrganization(): string | undefined {\n const organizationId = this.getContext()?.['organizationId'];\n return typeof organizationId === 'string' ? organizationId : undefined;\n }\n\n /**\n * Get project ID from context\n */\n public static getProject(): string | undefined {\n return this.getContext()?.projectId;\n }\n\n /**\n * Get app ID from context\n */\n public static getApp(): string | undefined {\n return this.getContext()?.appId;\n }\n\n /**\n * Get JWT token from context\n */\n public static getToken(): string | undefined {\n return this.getContext()?.token;\n }\n\n /**\n * Get product ID from context\n */\n public static getProduct(): string | undefined {\n return this.getContext()?.productId;\n }\n\n /**\n * The Cloudflare Access service-token client id for the current request scope, else the\n * service's configured token. Undefined outside a bound scope unless a token is configured.\n */\n public static getCfAccessClientId(): string | undefined {\n return serviceTokenPair()?.clientId;\n }\n\n /**\n * The Cloudflare Access service-token client secret, resolved together with\n * {@link ContextManager.getCfAccessClientId}.\n */\n public static getCfAccessClientSecret(): string | undefined {\n return serviceTokenPair()?.clientSecret;\n }\n\n /**\n * The `CF_Authorization` cookie value the current request presented. Read only from the bound\n * request scope: it is a per-user credential and is never shared across requests.\n */\n public static getCfAuthorization(): string | undefined {\n return scopedCfAccess()?.authorization;\n }\n\n /**\n * Build the Cloudflare Access credentials to re-present on a cross-layer outbound call.\n *\n * Sources, in order:\n * 1. The credentials the current request presented, read only from its bound async scope\n * (the ContextManager store, or the request scope the SDK server binds for GraphQL\n * execution and REST handlers).\n * 2. For the service-token pair only, a token the service configured for itself with\n * {@link ContextManager.configureCfAccessServiceToken}.\n *\n * Fails closed: outside a bound request scope, and with no configured token, it returns `{}`.\n * Credentials one request presented are never attached to another request or to background\n * work. It is also `{}` wherever no Cloudflare Access fronts the gateways (local dev and\n * production).\n */\n public static getCfAccessHeaders(): Record<string, string> {\n const headers: Record<string, string> = {};\n const scoped = scopedCfAccess();\n\n const pair = serviceTokenPair(scoped);\n if (pair) {\n headers['cf-access-client-id'] = pair.clientId;\n headers['cf-access-client-secret'] = pair.clientSecret;\n }\n\n // A real user request on alpha carries the CF_Authorization cookie rather than a service\n // token; re-present it as the cookie for this request only. See BOFF-2929.\n const cfAuthorization = scoped?.authorization;\n if (cfAuthorization) {\n headers['cookie'] = `CF_Authorization=${cfAuthorization}`;\n }\n\n return headers;\n }\n\n /**\n * Update specific context fields\n */\n public static updateContext(updates: Partial<SDKContext>): void {\n const current = this.getContext();\n if (current) {\n this.setContext({ ...current, ...updates });\n } else {\n this.setContext(updates);\n }\n }\n\n /**\n * Check if context exists\n */\n public static hasContext(): boolean {\n return this.getContext() !== undefined;\n }\n\n /**\n * Get custom field from context\n */\n public static getCustomField(key: string): unknown {\n return this.getContext()?.[key];\n }\n\n /**\n * Set custom field in context\n */\n public static setCustomField(key: string, value: unknown): void {\n const current = this.getContext() || {};\n this.setContext({ ...current, [key]: value });\n }\n}\n\n/**\n * Default export for convenience\n */\nexport const contextManager = ContextManager;\n\n/**\n * Helper function to extract context from HTTP request\n */\nexport function extractContextFromRequest(req: {\n headers: Record<string, string | string[] | undefined>;\n user?: { user_id?: string; workspace_id?: string; tenant_endpoint?: string };\n}): SDKContext {\n const context: SDKContext = {};\n\n // Extract from user object (if JWT already verified)\n if (req.user) {\n context.actorId = req.user.user_id;\n context.workspaceId = req.user.workspace_id;\n context.tenantId = req.user.tenant_endpoint;\n }\n\n // Extract from headers\n const getHeader = (key: string): string | undefined => {\n const value = req.headers[key.toLowerCase()];\n return Array.isArray(value) ? value[0] : value;\n };\n\n const authHeader = getHeader('authorization');\n if (authHeader) {\n context.token = authHeader.replace('Bearer ', '');\n }\n\n const workspaceId = getHeader('x-workspace-id');\n if (workspaceId && !context.workspaceId) {\n context.workspaceId = workspaceId;\n }\n\n const productId = getHeader('x-product-id');\n if (productId) {\n context.productId = productId;\n }\n\n const projectId = getHeader('x-project-id');\n if (projectId) {\n context.projectId = projectId;\n }\n\n const appId = getHeader('x-app-id');\n if (appId) {\n context.appId = appId;\n }\n\n // Cloudflare Access service token. Forwarded to subgraphs by the public\n // gateways only when the request actually transited CF (cf-ray present), so\n // we can capture whatever arrives here. Re-presented on cross-layer outbound\n // calls — see ContextManager.getCfAccessHeaders.\n const cfAccessClientId = getHeader('cf-access-client-id');\n if (cfAccessClientId) {\n context.cfAccessClientId = cfAccessClientId;\n }\n\n const cfAccessClientSecret = getHeader('cf-access-client-secret');\n if (cfAccessClientSecret) {\n context.cfAccessClientSecret = cfAccessClientSecret;\n }\n\n // CF Access user-SSO cookie, forwarded by the public gateway as\n // x-cf-authorization. Re-presented as the CF_Authorization cookie on\n // cross-layer calls (see getCfAccessHeaders). See BOFF-2929.\n const cfAuthorization = getHeader('x-cf-authorization');\n if (cfAuthorization) {\n context.cfAuthorization = cfAuthorization;\n }\n\n return context;\n}\n"],"mappings":";;;;;;;;;AAUA,MAAM,oBAAoB,IAAI,kBAA8B;;;;;;;;;;AAW5D,IAAI;AAEJ,SAAS,SAAS,OAA+C;CAC/D,OAAO,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ;AACjE;;;;;;AAOA,SAAS,iBAAkD;CACzD,MAAM,UAAU,kBAAkB,SAAS;CAC3C,MAAM,cAAmC;EACvC,UAAU,SAAS,SAAS,gBAAgB;EAC5C,cAAc,SAAS,SAAS,oBAAoB;EACpD,eAAe,SAAS,SAAS,eAAe;CAClD;CACA,MAAM,mBAAmB,0BAA0B,CAAC,EAAE;CACtD,MAAM,iBAAiB,QAAQ,YAAY,YAAY,YAAY,YAAY;CAC/E,MAAM,eAAe,QAAQ,kBAAkB,YAAY,iBAAiB,YAAY;CAExF,MAAM,OAAO,iBAAiB,cAAc,eAAe,mBAAmB;CAC9E,MAAM,gBAAgB,YAAY,iBAAiB,SAAS,kBAAkB,aAAa;CAC3F,IAAI,CAAC,QAAQ,CAAC,eAAe,OAAO;CACpC,OAAO;EACL,GAAI,OAAO;GAAE,UAAU,KAAK;GAAU,cAAc,KAAK;EAAa,IAAI,CAAC;EAC3E,GAAI,gBAAgB,EAAE,cAAc,IAAI,CAAC;CAC3C;AACF;;AAGA,SAAS,iBACP,SAA0C,eAAe,GACD;CACxD,IAAI,QAAQ,YAAY,OAAO,cAC7B,OAAO;EAAE,UAAU,OAAO;EAAU,cAAc,OAAO;CAAa;CAExE,OAAO;AACT;;;;AAKA,IAAa,iBAAb,MAA4B;;;;CAI1B,OAAc,aAAqC;EACjD,OAAO,kBAAkB,SAAS;CACpC;;;;;CAMA,OAAc,WAAW,SAA2B;EAClD,MAAM,iBAAiB,KAAK,W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B,QAAQ,cAAc,IAAI,KAAK;EAC/B,QAAQ,WAAW,IAAI,KAAK;CAC9B;CAGA,MAAM,aAAa,QAAoC;EACrD,MAAM,QAAQ,IAAI,QAAQ,IAAI,YAAY;EAC1C,OAAO,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK;CAC3C;CAEA,MAAM,aAAa,UAAU,eAAe;CAC5C,IAAI,YACF,QAAQ,QAAQ,WAAW,QAAQ,WAAW,EAAE;CAGlD,MAAM,cAAc,UAAU,gBAAgB;CAC9C,IAAI,eAAe,CAAC,QAAQ,aAC1B,QAAQ,cAAc;CAGxB,MAAM,YAAY,UAAU,cAAc;CAC1C,IAAI,WACF,QAAQ,YAAY;CAGtB,MAAM,YAAY,UAAU,cAAc;CAC1C,IAAI,WACF,QAAQ,YAAY;CAGtB,MAAM,QAAQ,UAAU,UAAU;CAClC,IAAI,OACF,QAAQ,QAAQ;CAOlB,MAAM,mBAAmB,UAAU,qBAAqB;CACxD,IAAI,kBACF,QAAQ,mBAAmB;CAG7B,MAAM,uBAAuB,UAAU,yBAAyB;CAChE,IAAI,sBACF,QAAQ,uBAAuB;CAMjC,MAAM,kBAAkB,UAAU,oBAAoB;CACtD,IAAI,iBACF,QAAQ,kBAAkB;CAG5B,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/context/index.ts"],"sourcesContent":["/**\n * Context Module\n * Manages request-scoped context using AsyncLocalStorage\n * Thread-safe context propagation for async operations\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport { getScopedWorkspaceContext } from '../prisma/workspace-extension.js';\nimport type { CfAccessCredentials, SDKContext } from '../types/index.js';\n\nconst asyncLocalStorage = new AsyncLocalStorage<SDKContext>();\n\n/**\n * A Cloudflare Access service token the service configured for itself, from its own\n * configuration (for example `CF_ACCESS_CLIENT_ID` / `CF_ACCESS_CLIENT_SECRET` in its\n * environment), via {@link ContextManager.configureCfAccessServiceToken}.\n *\n * This is the only process-wide Cloudflare Access state. It is never written from request\n * data: credentials an inbound request presented live only in that request's bound async\n * scope (see {@link ContextManager.getCfAccessHeaders}).\n */\nlet configuredServiceToken: { clientId: string; clientSecret: string } | undefined;\n\nfunction nonEmpty(value: string | undefined): string | undefined {\n return typeof value === 'string' && value.length > 0 ? value : undefined;\n}\n\n/**\n * The Cloudflare Access credentials bound to the current async scope: the ContextManager\n * store first, then the request scope the SDK server binds for GraphQL execution and REST\n * handlers. Reads only bound stores, never the deprecated warn-mode workspace fallback.\n */\nfunction scopedCfAccess(): CfAccessCredentials | undefined {\n const context = asyncLocalStorage.getStore();\n const fromContext: CfAccessCredentials = {\n clientId: nonEmpty(context?.cfAccessClientId),\n clientSecret: nonEmpty(context?.cfAccessClientSecret),\n authorization: nonEmpty(context?.cfAuthorization),\n };\n const fromRequestScope = getScopedWorkspaceContext()?.cfAccess;\n const contextHasPair = Boolean(fromContext.clientId && fromContext.clientSecret);\n const scopeHasPair = Boolean(fromRequestScope?.clientId && fromRequestScope.clientSecret);\n // The service-token pair is taken from one source as a unit, never mixed across stores.\n const pair = contextHasPair ? fromContext : scopeHasPair ? fromRequestScope : undefined;\n const authorization = fromContext.authorization ?? nonEmpty(fromRequestScope?.authorization);\n if (!pair && !authorization) return undefined;\n return {\n ...(pair ? { clientId: pair.clientId, clientSecret: pair.clientSecret } : {}),\n ...(authorization ? { authorization } : {}),\n };\n}\n\n/** The service-token pair for the current scope, else the token the service configured. */\nfunction serviceTokenPair(\n scoped: CfAccessCredentials | undefined = scopedCfAccess()\n): { clientId: string; clientSecret: string } | undefined {\n if (scoped?.clientId && scoped.clientSecret) {\n return { clientId: scoped.clientId, clientSecret: scoped.clientSecret };\n }\n return configuredServiceToken;\n}\n\n/**\n * Context Manager for handling request-scoped context\n */\nexport class ContextManager {\n /**\n * Get current context from async local storage\n */\n public static getContext(): SDKContext | undefined {\n return asyncLocalStorage.getStore();\n }\n\n /**\n * Set context for current async scope\n * Merges with existing context if present\n */\n public static setContext(context: SDKContext): void {\n const currentContext = this.getContext() || {};\n asyncLocalStorage.enterWith({ ...currentContext, ...context });\n }\n\n /**\n * Configure a Cloudflare Access service token the service holds for itself, read from its own\n * configuration (never from a request). Cross-layer calls attach it when the current request\n * scope carries no service-token pair of its own, which lets background work (stream\n * consumers, schedulers, CLIs) pass a Cloudflare-Access-gated peer gateway.\n *\n * Pass both values to set the token, or call it with no arguments to remove it. A lone half\n * is ignored, since it can never pass Access.\n *\n * @example\n * ```typescript\n * ContextManager.configureCfAccessServiceToken(process.env.CF_ACCESS_CLIENT_ID, process.env.CF_ACCESS_CLIENT_SECRET);\n * ```\n */\n public static configureCfAccessServiceToken(clientId?: string, clientSecret?: string): void {\n const id = nonEmpty(clientId);\n const secret = nonEmpty(clientSecret);\n if (id && secret) {\n configuredServiceToken = { clientId: id, clientSecret: secret };\n } else if (id === undefined && secret === undefined) {\n configuredServiceToken = undefined;\n }\n }\n\n /**\n * @deprecated Use {@link ContextManager.configureCfAccessServiceToken} with the service's own\n * token. Credentials a request presents no longer need recording: the SDK server binds them\n * to that request's scope.\n *\n * Kept for services that seed their own token from configuration. It sets the service token\n * when both values are present and otherwise does nothing. The `CF_Authorization` cookie is a\n * per-user credential, so it is never stored process-wide and the third argument is ignored.\n */\n public static setCfAccessContext(clientId?: string, clientSecret?: string, _cfAuthorization?: string): void {\n if (nonEmpty(clientId) && nonEmpty(clientSecret)) {\n this.configureCfAccessServiceToken(clientId, clientSecret);\n }\n }\n\n /**\n * Run function with specific context\n * Context is isolated to this execution and its children\n *\n * Whatever `fn` returns is awaited inside the scope, so a lazy thenable (such as a Prisma\n * query) returned un-awaited still starts while the context is bound (BOFF-17566).\n */\n public static async withContext<T>(context: SDKContext, fn: () => Promise<T>): Promise<T> {\n return asyncLocalStorage.run(context, async () => {\n const result = await fn();\n return result;\n });\n }\n\n /**\n * Run synchronous function with specific context\n */\n public static withContextSync<T>(context: SDKContext, fn: () => T): T {\n return asyncLocalStorage.run(context, fn);\n }\n\n /**\n * Clear current context, including any configured Cloudflare Access service token.\n */\n public static clearContext(): void {\n asyncLocalStorage.disable();\n configuredServiceToken = undefined;\n }\n\n /**\n * Get actor ID from context\n */\n public static getActorId(): string | undefined {\n return this.getContext()?.actorId;\n }\n\n /**\n * Get legacy user ID from context.\n */\n public static getUser(): string | undefined {\n const context = this.getContext();\n const userId = context?.['userId'];\n return typeof userId === 'string' ? userId : context?.actorId;\n }\n\n /**\n * Get workspace ID from context\n */\n public static getWorkspace(): string | undefined {\n return this.getContext()?.workspaceId;\n }\n\n /**\n * Get tenant ID from context\n */\n public static getTenant(): string | undefined {\n return this.getContext()?.tenantId;\n }\n\n /**\n * Get legacy organization ID from context.\n */\n public static getOrganization(): string | undefined {\n const organizationId = this.getContext()?.['organizationId'];\n return typeof organizationId === 'string' ? organizationId : undefined;\n }\n\n /**\n * Get project ID from context\n */\n public static getProject(): string | undefined {\n return this.getContext()?.projectId;\n }\n\n /**\n * Get app ID from context\n */\n public static getApp(): string | undefined {\n return this.getContext()?.appId;\n }\n\n /**\n * Get JWT token from context\n */\n public static getToken(): string | undefined {\n return this.getContext()?.token;\n }\n\n /**\n * Get product ID from context\n */\n public static getProduct(): string | undefined {\n return this.getContext()?.productId;\n }\n\n /**\n * The Cloudflare Access service-token client id for the current request scope, else the\n * service's configured token. Undefined outside a bound scope unless a token is configured.\n */\n public static getCfAccessClientId(): string | undefined {\n return serviceTokenPair()?.clientId;\n }\n\n /**\n * The Cloudflare Access service-token client secret, resolved together with\n * {@link ContextManager.getCfAccessClientId}.\n */\n public static getCfAccessClientSecret(): string | undefined {\n return serviceTokenPair()?.clientSecret;\n }\n\n /**\n * The `CF_Authorization` cookie value the current request presented. Read only from the bound\n * request scope: it is a per-user credential and is never shared across requests.\n */\n public static getCfAuthorization(): string | undefined {\n return scopedCfAccess()?.authorization;\n }\n\n /**\n * Build the Cloudflare Access credentials to re-present on a cross-layer outbound call.\n *\n * Sources, in order:\n * 1. The credentials the current request presented, read only from its bound async scope\n * (the ContextManager store, or the request scope the SDK server binds for GraphQL\n * execution and REST handlers).\n * 2. For the service-token pair only, a token the service configured for itself with\n * {@link ContextManager.configureCfAccessServiceToken}.\n *\n * Fails closed: outside a bound request scope, and with no configured token, it returns `{}`.\n * Credentials one request presented are never attached to another request or to background\n * work. It is also `{}` wherever no Cloudflare Access fronts the gateways (local dev and\n * production).\n */\n public static getCfAccessHeaders(): Record<string, string> {\n const headers: Record<string, string> = {};\n const scoped = scopedCfAccess();\n\n const pair = serviceTokenPair(scoped);\n if (pair) {\n headers['cf-access-client-id'] = pair.clientId;\n headers['cf-access-client-secret'] = pair.clientSecret;\n }\n\n // A real user request on alpha carries the CF_Authorization cookie rather than a service\n // token; re-present it as the cookie for this request only. See BOFF-2929.\n const cfAuthorization = scoped?.authorization;\n if (cfAuthorization) {\n headers['cookie'] = `CF_Authorization=${cfAuthorization}`;\n }\n\n return headers;\n }\n\n /**\n * Update specific context fields\n */\n public static updateContext(updates: Partial<SDKContext>): void {\n const current = this.getContext();\n if (current) {\n this.setContext({ ...current, ...updates });\n } else {\n this.setContext(updates);\n }\n }\n\n /**\n * Check if context exists\n */\n public static hasContext(): boolean {\n return this.getContext() !== undefined;\n }\n\n /**\n * Get custom field from context\n */\n public static getCustomField(key: string): unknown {\n return this.getContext()?.[key];\n }\n\n /**\n * Set custom field in context\n */\n public static setCustomField(key: string, value: unknown): void {\n const current = this.getContext() || {};\n this.setContext({ ...current, [key]: value });\n }\n}\n\n/**\n * Default export for convenience\n */\nexport const contextManager = ContextManager;\n\n/**\n * Helper function to extract context from HTTP request\n */\nexport function extractContextFromRequest(req: {\n headers: Record<string, string | string[] | undefined>;\n user?: { user_id?: string; workspace_id?: string; tenant_endpoint?: string };\n}): SDKContext {\n const context: SDKContext = {};\n\n // Extract from user object (if JWT already verified)\n if (req.user) {\n context.actorId = req.user.user_id;\n context.workspaceId = req.user.workspace_id;\n context.tenantId = req.user.tenant_endpoint;\n }\n\n // Extract from headers\n const getHeader = (key: string): string | undefined => {\n const value = req.headers[key.toLowerCase()];\n return Array.isArray(value) ? value[0] : value;\n };\n\n const authHeader = getHeader('authorization');\n if (authHeader) {\n context.token = authHeader.replace('Bearer ', '');\n }\n\n const workspaceId = getHeader('x-workspace-id');\n if (workspaceId && !context.workspaceId) {\n context.workspaceId = workspaceId;\n }\n\n const productId = getHeader('x-product-id');\n if (productId) {\n context.productId = productId;\n }\n\n const projectId = getHeader('x-project-id');\n if (projectId) {\n context.projectId = projectId;\n }\n\n const appId = getHeader('x-app-id');\n if (appId) {\n context.appId = appId;\n }\n\n // Cloudflare Access service token. Forwarded to subgraphs by the public\n // gateways only when the request actually transited CF (cf-ray present), so\n // we can capture whatever arrives here. Re-presented on cross-layer outbound\n // calls — see ContextManager.getCfAccessHeaders.\n const cfAccessClientId = getHeader('cf-access-client-id');\n if (cfAccessClientId) {\n context.cfAccessClientId = cfAccessClientId;\n }\n\n const cfAccessClientSecret = getHeader('cf-access-client-secret');\n if (cfAccessClientSecret) {\n context.cfAccessClientSecret = cfAccessClientSecret;\n }\n\n // CF Access user-SSO cookie, forwarded by the public gateway as\n // x-cf-authorization. Re-presented as the CF_Authorization cookie on\n // cross-layer calls (see getCfAccessHeaders). See BOFF-2929.\n const cfAuthorization = getHeader('x-cf-authorization');\n if (cfAuthorization) {\n context.cfAuthorization = cfAuthorization;\n }\n\n return context;\n}\n"],"mappings":";;;;;;;;;AAUA,MAAM,oBAAoB,IAAI,kBAA8B;;;;;;;;;;AAW5D,IAAI;AAEJ,SAAS,SAAS,OAA+C;CAC/D,OAAO,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ;AACjE;;;;;;AAOA,SAAS,iBAAkD;CACzD,MAAM,UAAU,kBAAkB,SAAS;CAC3C,MAAM,cAAmC;EACvC,UAAU,SAAS,SAAS,gBAAgB;EAC5C,cAAc,SAAS,SAAS,oBAAoB;EACpD,eAAe,SAAS,SAAS,eAAe;CAClD;CACA,MAAM,mBAAmB,0BAA0B,CAAC,EAAE;CACtD,MAAM,iBA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ClC,IAAI,OACF,QAAQ,QAAQ;CAOlB,MAAM,mBAAmB,UAAU,qBAAqB;CACxD,IAAI,kBACF,QAAQ,mBAAmB;CAG7B,MAAM,uBAAuB,UAAU,yBAAyB;CAChE,IAAI,sBACF,QAAQ,uBAAuB;CAMjC,MAAM,kBAAkB,UAAU,oBAAoB;CACtD,IAAI,iBACF,QAAQ,kBAAkB;CAG5B,OAAO;AACT"}
|
package/dist/files/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { type CompleteUploadSessionInput, type CreateUploadSessionInput, type DeleteFileOptions, type DownloadFileOptions, type DownloadUrlOptions, type DownloadedFile, FILES_CLIENT_GRAPHQL_CODES, FILE_ACTOR_TYPES, FILE_REFERENCE_KIND, FILE_VISIBILITIES, type FileActor, type FileActorType, type FileBytes, type FileMetadata, type FileReference, type FileStatus, type FileUploadType, type FileVisibility, FilesClient, FilesClientError, type FilesClientErrorCode, type FilesClientOptions, type FilesFetch, type FilesTransport, MAX_DOWNLOAD_URL_TTL_SECONDS, MIN_DOWNLOAD_URL_TTL_SECONDS, type RawFileMetadata, type RequireFileOptions, type StoredFile, type UploadFileInput, type UploadSessionPart, type UploadSessionTicket, type UploadedPart, clampDownloadUrlTtl, classifyFilesErrors, fileExtensionOf, isFileReference, isFilesClientError, mapFileMetadata, toFileReference, toFilesClientError };
|
|
1
|
+
import { A as DownloadFileOptions, B as FileUploadType, C as sanitizeUpstreamError, D as CompleteUploadSessionInput, E as toFilesClientError, F as FileActor, G as RequireFileOptions, H as FilesFetch, I as FileActorType, J as UploadSessionPart, K as StoredFile, L as FileBytes, M as DownloadedFile, N as FILE_ACTOR_TYPES, O as CreateUploadSessionInput, P as FILE_VISIBILITIES, R as FileMetadata, S as isFilesClientError, T as summarizeFilesClientError, U as FilesTransport, V as FileVisibility, W as RawFileMetadata, X as UploadedPart, Y as UploadSessionTicket, _ as FilesUpstreamError, a as toFileReference, b as classifyFilesErrors, c as MAX_DOWNLOAD_URL_TTL_SECONDS, d as fileExtensionOf, f as mapFileMetadata, g as FilesClientErrorUpstream, h as FilesClientErrorCode, i as isFileReference, j as DownloadUrlOptions, k as DeleteFileOptions, l as MIN_DOWNLOAD_URL_TTL_SECONDS, m as FilesClientError, n as FILE_REFERENCE_KIND, o as FilesClient, p as FILES_CLIENT_GRAPHQL_CODES, q as UploadFileInput, r as FileReference, s as FilesClientOptions, u as clampDownloadUrlTtl, v as MAX_FILES_ERROR_SUMMARY_LENGTH, w as sanitizeUpstreamText, x as filesGraphQLError, y as MAX_UPSTREAM_MESSAGE_LENGTH, z as FileStatus } from "../index-ieSQpD9r.js";
|
|
2
|
+
export { type CompleteUploadSessionInput, type CreateUploadSessionInput, type DeleteFileOptions, type DownloadFileOptions, type DownloadUrlOptions, type DownloadedFile, FILES_CLIENT_GRAPHQL_CODES, FILE_ACTOR_TYPES, FILE_REFERENCE_KIND, FILE_VISIBILITIES, type FileActor, type FileActorType, type FileBytes, type FileMetadata, type FileReference, type FileStatus, type FileUploadType, type FileVisibility, FilesClient, FilesClientError, type FilesClientErrorCode, type FilesClientErrorUpstream, type FilesClientOptions, type FilesFetch, type FilesTransport, type FilesUpstreamError, MAX_DOWNLOAD_URL_TTL_SECONDS, MAX_FILES_ERROR_SUMMARY_LENGTH, MAX_UPSTREAM_MESSAGE_LENGTH, MIN_DOWNLOAD_URL_TTL_SECONDS, type RawFileMetadata, type RequireFileOptions, type StoredFile, type UploadFileInput, type UploadSessionPart, type UploadSessionTicket, type UploadedPart, clampDownloadUrlTtl, classifyFilesErrors, fileExtensionOf, filesGraphQLError, isFileReference, isFilesClientError, mapFileMetadata, sanitizeUpstreamError, sanitizeUpstreamText, summarizeFilesClientError, toFileReference, toFilesClientError };
|
package/dist/files/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as FILE_VISIBILITIES, S as FILE_ACTOR_TYPES, _ as isFilesClientError, a as FilesClient, b as summarizeFilesClientError, c as clampDownloadUrlTtl, d as FILES_CLIENT_GRAPHQL_CODES, f as FilesClientError, g as filesGraphQLError, h as classifyFilesErrors, i as toFileReference, l as fileExtensionOf, m as MAX_UPSTREAM_MESSAGE_LENGTH, n as FILE_REFERENCE_KIND, o as MAX_DOWNLOAD_URL_TTL_SECONDS, p as MAX_FILES_ERROR_SUMMARY_LENGTH, r as isFileReference, s as MIN_DOWNLOAD_URL_TTL_SECONDS, u as mapFileMetadata, v as sanitizeUpstreamError, x as toFilesClientError, y as sanitizeUpstreamText } from "../files-BISdM0fh.js";
|
|
2
2
|
|
|
3
|
-
export { FILES_CLIENT_GRAPHQL_CODES, FILE_ACTOR_TYPES, FILE_REFERENCE_KIND, FILE_VISIBILITIES, FilesClient, FilesClientError, MAX_DOWNLOAD_URL_TTL_SECONDS, MIN_DOWNLOAD_URL_TTL_SECONDS, clampDownloadUrlTtl, classifyFilesErrors, fileExtensionOf, isFileReference, isFilesClientError, mapFileMetadata, toFileReference, toFilesClientError };
|
|
3
|
+
export { FILES_CLIENT_GRAPHQL_CODES, FILE_ACTOR_TYPES, FILE_REFERENCE_KIND, FILE_VISIBILITIES, FilesClient, FilesClientError, MAX_DOWNLOAD_URL_TTL_SECONDS, MAX_FILES_ERROR_SUMMARY_LENGTH, MAX_UPSTREAM_MESSAGE_LENGTH, MIN_DOWNLOAD_URL_TTL_SECONDS, clampDownloadUrlTtl, classifyFilesErrors, fileExtensionOf, filesGraphQLError, isFileReference, isFilesClientError, mapFileMetadata, sanitizeUpstreamError, sanitizeUpstreamText, summarizeFilesClientError, toFileReference, toFilesClientError };
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -26,6 +26,11 @@ const FILE_VISIBILITIES = [
|
|
|
26
26
|
* `code` is stable so that mapping never parses messages. Upstream detail
|
|
27
27
|
* (files-svc messages, storage status codes) lives in `details` for logging and
|
|
28
28
|
* must not be returned to clients verbatim.
|
|
29
|
+
*
|
|
30
|
+
* The upstream GraphQL errors are kept as {@link FilesUpstreamError}s: a
|
|
31
|
+
* whitelist of fields (code, i18n key, failing field, trace id and a sanitised,
|
|
32
|
+
* capped message). Request variables, headers and URLs are never copied, so
|
|
33
|
+
* {@link FilesClientError.summary} is safe to log and to show in a run error.
|
|
29
34
|
*/
|
|
30
35
|
/** GraphQL `extensions.code` each {@link FilesClientErrorCode} should surface as. */
|
|
31
36
|
const FILES_CLIENT_GRAPHQL_CODES = {
|
|
@@ -38,41 +43,189 @@ const FILES_CLIENT_GRAPHQL_CODES = {
|
|
|
38
43
|
UPSTREAM_ERROR: "INTERNAL_SERVER_ERROR",
|
|
39
44
|
CONFIGURATION_ERROR: "INTERNAL_SERVER_ERROR"
|
|
40
45
|
};
|
|
46
|
+
/** Longest upstream message kept, in characters. */
|
|
47
|
+
const MAX_UPSTREAM_MESSAGE_LENGTH = 200;
|
|
48
|
+
/** Longest {@link FilesClientError.summary}, in characters. */
|
|
49
|
+
const MAX_FILES_ERROR_SUMMARY_LENGTH = 400;
|
|
41
50
|
var FilesClientError = class extends Error {
|
|
42
51
|
code;
|
|
43
52
|
details;
|
|
44
|
-
|
|
53
|
+
/** The FilesClient operation that failed, when the error came from a files-svc call. */
|
|
54
|
+
operation;
|
|
55
|
+
/** The sanitised upstream GraphQL errors (empty when there were none). */
|
|
56
|
+
upstreamErrors;
|
|
57
|
+
/** The HTTP status of the failed response, when known. */
|
|
58
|
+
status;
|
|
59
|
+
constructor(code, message, details = {}, upstream = {}) {
|
|
45
60
|
super(message);
|
|
46
61
|
this.name = "FilesClientError";
|
|
47
62
|
this.code = code;
|
|
48
63
|
this.details = details;
|
|
64
|
+
this.operation = upstream.operation;
|
|
65
|
+
this.upstreamErrors = upstream.errors ?? [];
|
|
66
|
+
this.status = upstream.status;
|
|
49
67
|
}
|
|
50
68
|
/** The GraphQL `extensions.code` this error maps to. */
|
|
51
69
|
get graphqlCode() {
|
|
52
70
|
return FILES_CLIENT_GRAPHQL_CODES[this.code];
|
|
53
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* One line for logs and run errors: the class, the upstream reason and the
|
|
74
|
+
* failing call, e.g.
|
|
75
|
+
* `UPSTREAM_ERROR (INTERNAL_SERVER_ERROR, files.errors.fileExtensionCannotBeNull): wspace-files-svc getFile failed: File extension cannot be null`.
|
|
76
|
+
* Built only from whitelisted, sanitised fields; never contains request
|
|
77
|
+
* variables, headers or URLs.
|
|
78
|
+
*/
|
|
79
|
+
get summary() {
|
|
80
|
+
return summarizeFilesClientError(this);
|
|
81
|
+
}
|
|
54
82
|
};
|
|
55
83
|
function isFilesClientError(error) {
|
|
56
84
|
return error instanceof FilesClientError;
|
|
57
85
|
}
|
|
58
|
-
const NOT_FOUND_UPSTREAM_CODES = /* @__PURE__ */ new Set([
|
|
86
|
+
const NOT_FOUND_UPSTREAM_CODES = /* @__PURE__ */ new Set([
|
|
87
|
+
"NOT_FOUND",
|
|
88
|
+
"FORBIDDEN",
|
|
89
|
+
"FILE_NOT_FOUND",
|
|
90
|
+
"ACCESS_DENIED",
|
|
91
|
+
"UNAUTHORIZED"
|
|
92
|
+
]);
|
|
59
93
|
const QUOTA_UPSTREAM_CODES = /* @__PURE__ */ new Set([
|
|
60
94
|
"QUOTA_EXCEEDED",
|
|
61
95
|
"QUOTA_EXHAUSTED",
|
|
62
96
|
"USAGE_LIMIT_EXCEEDED"
|
|
63
97
|
]);
|
|
64
|
-
const INVALID_UPSTREAM_CODES = /* @__PURE__ */ new Set([
|
|
98
|
+
const INVALID_UPSTREAM_CODES = /* @__PURE__ */ new Set([
|
|
99
|
+
"BAD_USER_INPUT",
|
|
100
|
+
"EXPIRED",
|
|
101
|
+
"VALIDATION_ERROR",
|
|
102
|
+
"INVALID_INPUT"
|
|
103
|
+
]);
|
|
65
104
|
function upstreamCode(error) {
|
|
66
105
|
const code = error.extensions?.["code"];
|
|
67
106
|
return typeof code === "string" ? code : null;
|
|
68
107
|
}
|
|
108
|
+
/** The class a single upstream code maps to. */
|
|
109
|
+
function classOfUpstreamCode(code) {
|
|
110
|
+
if (QUOTA_UPSTREAM_CODES.has(code)) return "QUOTA_EXCEEDED";
|
|
111
|
+
if (NOT_FOUND_UPSTREAM_CODES.has(code)) return "NOT_FOUND";
|
|
112
|
+
if (INVALID_UPSTREAM_CODES.has(code)) return "INVALID_INPUT";
|
|
113
|
+
return "UPSTREAM_ERROR";
|
|
114
|
+
}
|
|
115
|
+
/** Precedence when several upstream errors disagree: the first class listed wins. */
|
|
116
|
+
const CLASS_PRECEDENCE = [
|
|
117
|
+
"QUOTA_EXCEEDED",
|
|
118
|
+
"NOT_FOUND",
|
|
119
|
+
"INVALID_INPUT"
|
|
120
|
+
];
|
|
69
121
|
/** Classify files-svc GraphQL errors into a {@link FilesClientErrorCode}. */
|
|
70
122
|
function classifyFilesErrors(errors) {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
123
|
+
const classes = new Set(errors.map(upstreamCode).filter((code) => code !== null).map(classOfUpstreamCode));
|
|
124
|
+
return CLASS_PRECEDENCE.find((candidate) => classes.has(candidate)) ?? "UPSTREAM_ERROR";
|
|
125
|
+
}
|
|
126
|
+
const UPSTREAM_CODE_PATTERN = /^[A-Z][A-Z0-9_]{0,63}$/;
|
|
127
|
+
const I18N_KEY_SEGMENT_PATTERN = /^[\w-]+$/;
|
|
128
|
+
const MAX_I18N_KEY_LENGTH = 128;
|
|
129
|
+
const MAX_I18N_KEY_SEGMENTS = 8;
|
|
130
|
+
const FIELD_SEGMENT_PATTERN = /^[A-Za-z_]\w{0,63}$/;
|
|
131
|
+
const MAX_FIELD_SEGMENTS = 6;
|
|
132
|
+
const TRACE_ID_PATTERN = /^[0-9a-f]{16,32}$/i;
|
|
133
|
+
const URL_PATTERN = /\b[a-z][a-z0-9+.-]*:\/\/[^\s"'<>`]+/gi;
|
|
134
|
+
const JWT_PATTERN = /\beyJ[\w-]{4,}\.[\w-]{4,}\.[\w-]*/g;
|
|
135
|
+
const AUTH_SCHEME_PATTERN = /\b(bearer|basic)\s+[\w.~+/=-]+/gi;
|
|
136
|
+
const ASSIGNMENT_PATTERN = /(?<![\w-])([\w-]+)(["']?\s?[:=]\s?["']?)([^\s"',;&}]+)/g;
|
|
137
|
+
/** Text longer than this is cut before the patterns run, so a huge upstream message costs nothing. */
|
|
138
|
+
const MAX_SCANNED_TEXT_LENGTH = 4096;
|
|
139
|
+
const SECRET_NAME_PATTERN = /token|secret|passw|signature|credential|api[_-]?key|authorization|cookie/i;
|
|
140
|
+
const VARIABLE_VALUE_PATTERN = /(Variable "\$\w+" got invalid value)[\s\S]*/g;
|
|
141
|
+
/** Replace C0/C1 control characters and DEL with spaces (log-line injection). */
|
|
142
|
+
function withoutControlCharacters(value) {
|
|
143
|
+
let result = "";
|
|
144
|
+
for (const character of value) {
|
|
145
|
+
const code = character.charCodeAt(0);
|
|
146
|
+
result += code < 32 || code >= 127 && code <= 159 ? " " : character;
|
|
147
|
+
}
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Reduce free text from an upstream error to something safe to log: control
|
|
152
|
+
* characters, URLs (presigned ones carry signatures), bearer/JWT tokens,
|
|
153
|
+
* `secret=…`-style assignments and echoed variable values are removed, and the
|
|
154
|
+
* result is capped at `maxLength` characters.
|
|
155
|
+
*/
|
|
156
|
+
function sanitizeUpstreamText(value, maxLength = 200) {
|
|
157
|
+
if (typeof value !== "string") return "";
|
|
158
|
+
const cleaned = withoutControlCharacters(value.slice(0, MAX_SCANNED_TEXT_LENGTH)).replace(VARIABLE_VALUE_PATTERN, "$1 (value omitted)").replace(URL_PATTERN, "[url]").replace(JWT_PATTERN, "[redacted]").replace(AUTH_SCHEME_PATTERN, "$1 [redacted]").replace(ASSIGNMENT_PATTERN, (assignment, name, separator) => SECRET_NAME_PATTERN.test(name) ? `${name}${separator}[redacted]` : assignment).replace(/\s+/g, " ").trim();
|
|
159
|
+
return cleaned.length > maxLength ? `${cleaned.slice(0, Math.max(0, maxLength - 1))}…` : cleaned;
|
|
160
|
+
}
|
|
161
|
+
function sanitizeField(path) {
|
|
162
|
+
if (!Array.isArray(path) || path.length === 0) return void 0;
|
|
163
|
+
const segments = [];
|
|
164
|
+
for (const segment of path.slice(0, MAX_FIELD_SEGMENTS)) if (typeof segment === "number" && Number.isSafeInteger(segment) && segment >= 0) segments.push(String(segment));
|
|
165
|
+
else if (typeof segment === "string" && FIELD_SEGMENT_PATTERN.test(segment)) segments.push(segment);
|
|
166
|
+
else break;
|
|
167
|
+
return segments.length > 0 ? segments.join(".") : void 0;
|
|
168
|
+
}
|
|
169
|
+
function isI18nKey(value) {
|
|
170
|
+
if (typeof value !== "string" || value.length > MAX_I18N_KEY_LENGTH) return false;
|
|
171
|
+
const segments = value.split(".");
|
|
172
|
+
return segments.length >= 2 && segments.length <= MAX_I18N_KEY_SEGMENTS && /^[A-Za-z]/.test(value) && segments.every((segment) => I18N_KEY_SEGMENT_PATTERN.test(segment));
|
|
173
|
+
}
|
|
174
|
+
function matching(value, pattern, maxLength) {
|
|
175
|
+
return typeof value === "string" && value.length <= maxLength && pattern.test(value) ? value : void 0;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Keep only the whitelisted fields of an upstream GraphQL error. Everything
|
|
179
|
+
* else on it (other extensions, `locations`, the original error) is dropped.
|
|
180
|
+
*/
|
|
181
|
+
function sanitizeUpstreamError(error) {
|
|
182
|
+
const extensions = error.extensions ?? {};
|
|
183
|
+
const result = {
|
|
184
|
+
code: matching(extensions["code"], UPSTREAM_CODE_PATTERN, 64) ?? null,
|
|
185
|
+
message: sanitizeUpstreamText(error.message)
|
|
186
|
+
};
|
|
187
|
+
const i18nKey = extensions["i18nKey"];
|
|
188
|
+
if (isI18nKey(i18nKey)) result.i18nKey = i18nKey;
|
|
189
|
+
const field = sanitizeField(error.path);
|
|
190
|
+
if (field) result.field = field;
|
|
191
|
+
const traceId = matching(extensions["traceId"], TRACE_ID_PATTERN, 32);
|
|
192
|
+
if (traceId) result.traceId = traceId;
|
|
193
|
+
return result;
|
|
194
|
+
}
|
|
195
|
+
function validStatus(value) {
|
|
196
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 100 && value <= 599 ? value : void 0;
|
|
197
|
+
}
|
|
198
|
+
function primaryUpstreamError(errors, code) {
|
|
199
|
+
return (code === "UPSTREAM_ERROR" ? void 0 : errors.find((error) => error.code !== null && classOfUpstreamCode(error.code) === code)) ?? errors.find((error) => error.i18nKey !== void 0) ?? errors.find((error) => error.code !== null) ?? errors[0];
|
|
200
|
+
}
|
|
201
|
+
function capSummary(value) {
|
|
202
|
+
return value.length > 400 ? `${value.slice(0, 399)}…` : value;
|
|
203
|
+
}
|
|
204
|
+
/** See {@link FilesClientError.summary}. */
|
|
205
|
+
function summarizeFilesClientError(error) {
|
|
206
|
+
const primary = primaryUpstreamError(error.upstreamErrors, error.code);
|
|
207
|
+
const tags = [];
|
|
208
|
+
if (primary?.code && primary.code !== error.code) tags.push(primary.code);
|
|
209
|
+
if (primary?.i18nKey) tags.push(primary.i18nKey);
|
|
210
|
+
if (error.status !== void 0) tags.push(`HTTP ${error.status}`);
|
|
211
|
+
if (primary?.traceId) tags.push(`trace ${primary.traceId}`);
|
|
212
|
+
const tag = tags.length > 0 ? ` (${tags.join(", ")})` : "";
|
|
213
|
+
const target = primary?.field ?? error.operation;
|
|
214
|
+
if (!primary || !target) return capSummary(`${error.code}${tag}: ${sanitizeUpstreamText(error.message, 400)}`);
|
|
215
|
+
const reason = primary.message ? `: ${primary.message}` : "";
|
|
216
|
+
const more = error.upstreamErrors.length > 1 ? ` (+${error.upstreamErrors.length - 1} more)` : "";
|
|
217
|
+
return capSummary(`${error.code}${tag}: wspace-files-svc ${target} failed${reason}${more}`);
|
|
218
|
+
}
|
|
219
|
+
/** A {@link FilesClientError} for a files-svc response that carried GraphQL errors. */
|
|
220
|
+
function filesGraphQLError(errors, operation) {
|
|
221
|
+
const upstream = errors.map(sanitizeUpstreamError);
|
|
222
|
+
return new FilesClientError(classifyFilesErrors(errors), `wspace-files-svc ${operation} failed`, {
|
|
223
|
+
operation,
|
|
224
|
+
errors: upstream
|
|
225
|
+
}, {
|
|
226
|
+
operation,
|
|
227
|
+
errors: upstream
|
|
228
|
+
});
|
|
76
229
|
}
|
|
77
230
|
/**
|
|
78
231
|
* Normalise anything a files-svc call threw (a `GatewayError` carrying GraphQL
|
|
@@ -83,18 +236,21 @@ function toFilesClientError(error, operation) {
|
|
|
83
236
|
if (error instanceof GatewayError) {
|
|
84
237
|
const graphqlErrors = error.graphqlErrors ?? [];
|
|
85
238
|
const code = graphqlErrors.length > 0 ? classifyFilesErrors(graphqlErrors) : "UPSTREAM_ERROR";
|
|
86
|
-
|
|
239
|
+
const upstream = graphqlErrors.map(sanitizeUpstreamError);
|
|
240
|
+
const status = validStatus(error.statusCode);
|
|
241
|
+
return new FilesClientError(code, `wspace-files-svc ${operation} failed: ${sanitizeUpstreamText(error.message)}`, {
|
|
87
242
|
operation,
|
|
88
243
|
gatewayErrorType: error.type,
|
|
89
244
|
statusCode: error.statusCode,
|
|
90
|
-
errors:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
245
|
+
errors: upstream
|
|
246
|
+
}, {
|
|
247
|
+
operation,
|
|
248
|
+
errors: upstream,
|
|
249
|
+
...status !== void 0 ? { status } : {}
|
|
94
250
|
});
|
|
95
251
|
}
|
|
96
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
97
|
-
return new FilesClientError("UPSTREAM_ERROR", `wspace-files-svc ${operation} failed: ${message}`, { operation });
|
|
252
|
+
const message = sanitizeUpstreamText(error instanceof Error ? error.message : String(error));
|
|
253
|
+
return new FilesClientError("UPSTREAM_ERROR", `wspace-files-svc ${operation} failed: ${message}`, { operation }, { operation });
|
|
98
254
|
}
|
|
99
255
|
|
|
100
256
|
// src/files/client.ts
|
|
@@ -469,10 +625,8 @@ var FilesClient = class {
|
|
|
469
625
|
}
|
|
470
626
|
/** File metadata, or `null` when it does not exist or the actor cannot see it. */
|
|
471
627
|
async getFile(fileId, actor) {
|
|
472
|
-
const id = requireNonEmpty(fileId, "fileId");
|
|
473
628
|
try {
|
|
474
|
-
|
|
475
|
-
return data.getFile ? mapFileMetadata(data.getFile) : null;
|
|
629
|
+
return await this.fetchFile(fileId, actor);
|
|
476
630
|
} catch (error) {
|
|
477
631
|
if (error instanceof FilesClientError && error.code === "NOT_FOUND") return null;
|
|
478
632
|
throw error;
|
|
@@ -485,10 +639,16 @@ var FilesClient = class {
|
|
|
485
639
|
*/
|
|
486
640
|
async requireFile(fileId, actor, options = {}) {
|
|
487
641
|
const context = this.requireActor(actor);
|
|
488
|
-
const file = await this.
|
|
642
|
+
const file = await this.fetchFile(fileId, context);
|
|
489
643
|
this.assertUsable(file, fileId, context, options);
|
|
490
644
|
return file;
|
|
491
645
|
}
|
|
646
|
+
/** `getFile` without turning an upstream NOT_FOUND into `null`. */
|
|
647
|
+
async fetchFile(fileId, actor) {
|
|
648
|
+
const id = requireNonEmpty(fileId, "fileId");
|
|
649
|
+
const data = await this.request("getFile", GET_FILE, { id }, actor);
|
|
650
|
+
return data.getFile ? mapFileMetadata(data.getFile) : null;
|
|
651
|
+
}
|
|
492
652
|
/**
|
|
493
653
|
* A presigned download URL for the file, minted for the actor. Mint it when the
|
|
494
654
|
* user opens the file; never persist it. The lifetime is clamped to
|
|
@@ -769,13 +929,7 @@ var FilesClient = class {
|
|
|
769
929
|
} catch (error) {
|
|
770
930
|
throw toFilesClientError(error, operation);
|
|
771
931
|
}
|
|
772
|
-
if (response.errors?.length) throw
|
|
773
|
-
operation,
|
|
774
|
-
errors: response.errors.map((error) => ({
|
|
775
|
-
message: error.message,
|
|
776
|
-
code: error.extensions?.["code"] ?? null
|
|
777
|
-
}))
|
|
778
|
-
});
|
|
932
|
+
if (response.errors?.length) throw filesGraphQLError(response.errors, operation);
|
|
779
933
|
if (!response.data) throw new FilesClientError("UPSTREAM_ERROR", `wspace-files-svc ${operation} returned no data`, { operation });
|
|
780
934
|
return response.data;
|
|
781
935
|
}
|
|
@@ -815,16 +969,22 @@ var files_exports = /* @__PURE__ */ __exportAll({
|
|
|
815
969
|
FilesClient: () => FilesClient,
|
|
816
970
|
FilesClientError: () => FilesClientError,
|
|
817
971
|
MAX_DOWNLOAD_URL_TTL_SECONDS: () => MAX_DOWNLOAD_URL_TTL_SECONDS,
|
|
972
|
+
MAX_FILES_ERROR_SUMMARY_LENGTH: () => 400,
|
|
973
|
+
MAX_UPSTREAM_MESSAGE_LENGTH: () => 200,
|
|
818
974
|
MIN_DOWNLOAD_URL_TTL_SECONDS: () => 60,
|
|
819
975
|
clampDownloadUrlTtl: () => clampDownloadUrlTtl,
|
|
820
976
|
classifyFilesErrors: () => classifyFilesErrors,
|
|
821
977
|
fileExtensionOf: () => fileExtensionOf,
|
|
978
|
+
filesGraphQLError: () => filesGraphQLError,
|
|
822
979
|
isFileReference: () => isFileReference,
|
|
823
980
|
isFilesClientError: () => isFilesClientError,
|
|
824
981
|
mapFileMetadata: () => mapFileMetadata,
|
|
982
|
+
sanitizeUpstreamError: () => sanitizeUpstreamError,
|
|
983
|
+
sanitizeUpstreamText: () => sanitizeUpstreamText,
|
|
984
|
+
summarizeFilesClientError: () => summarizeFilesClientError,
|
|
825
985
|
toFileReference: () => toFileReference,
|
|
826
986
|
toFilesClientError: () => toFilesClientError
|
|
827
987
|
});
|
|
828
988
|
|
|
829
|
-
export { FILE_VISIBILITIES as _, FilesClient as a, clampDownloadUrlTtl as c, FILES_CLIENT_GRAPHQL_CODES as d, FilesClientError as f,
|
|
830
|
-
//# sourceMappingURL=files-
|
|
989
|
+
export { FILE_VISIBILITIES as C, FILE_ACTOR_TYPES as S, isFilesClientError as _, FilesClient as a, summarizeFilesClientError as b, clampDownloadUrlTtl as c, FILES_CLIENT_GRAPHQL_CODES as d, FilesClientError as f, filesGraphQLError as g, classifyFilesErrors as h, toFileReference as i, fileExtensionOf as l, MAX_UPSTREAM_MESSAGE_LENGTH as m, FILE_REFERENCE_KIND as n, MAX_DOWNLOAD_URL_TTL_SECONDS as o, MAX_FILES_ERROR_SUMMARY_LENGTH as p, isFileReference as r, MIN_DOWNLOAD_URL_TTL_SECONDS as s, files_exports as t, mapFileMetadata as u, sanitizeUpstreamError as v, toFilesClientError as x, sanitizeUpstreamText as y };
|
|
990
|
+
//# sourceMappingURL=files-BISdM0fh.js.map
|