import { F as File, L as LocalMetaStorageOptions, i as BaseStorageOptions, M as MetaStorage, d as FileInit, O as OperationOptions, e as FilePart, f as FileQuery, g as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C9EdfTf1.js"; import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CYWYyCUo.js"; import { BoxClient } from 'box-typescript-sdk-gen'; import 'node:stream'; import 'node:timers'; import 'node:crypto'; import 'node:http'; import 'lru-cache'; declare class BoxFile extends File { boxFileId?: string; eTag?: string; publicUrl?: string; } declare class BoxMetaStorage extends LocalMetaStorage { constructor(config?: LocalMetaStorageOptions); } interface BoxOAuthOptions { /** * Box application client ID. */ clientId: string; /** * Box application client secret. */ clientSecret: string; /** * Long-lived refresh token previously obtained via Box's authorization * code flow. The adapter seeds the SDK's in-memory token storage with * this value; the SDK exchanges it for a fresh access token on first * use and re-refreshes when the access token expires. */ refreshToken: string; } interface BoxCcgOptions { /** * Box application client ID. */ clientId: string; /** * Box application client secret. */ clientSecret: string; /** * Pass `enterpriseId` to authenticate as the service account, or `userId` * to authenticate as a managed/app user. At least one is required. */ enterpriseId?: string; /** * Pass `userId` to authenticate as a managed/app user. */ userId?: string; } type BoxJwtOptions = { configFilePath: string; } | { configJsonString: string; }; interface BoxStorageOptions extends BaseStorageOptions { /** * Server-side Client Credentials Grant. Mutually exclusive with * `developerToken`, `oauth`, and `jwt`. */ ccg?: BoxCcgOptions; /** * Pre-built `BoxClient`. Escape hatch for callers that already wire * auth themselves (e.g. with a custom `NetworkSession`, proxy config, * or downscoped tokens). */ client?: BoxClient; /** * Default expiry, in seconds, advertised to callers of `getReadUrl()`. * Box does not document a hard maximum for download URLs (they are * short-lived by API design); this value is forwarded as documentation * only — the actual lifetime is decided by Box. Defaults to 3600. */ defaultUrlExpiresIn?: number; /** * Static developer token from the Box developer console. Useful for * scripts and trying the adapter; production apps should use OAuth, * CCG, or JWT instead. Mutually exclusive with `oauth`, `ccg`, `jwt`. */ developerToken?: string; /** * JWT Server Authentication, configured via the JSON blob from Box's * developer console. Mutually exclusive with the other auth modes. */ jwt?: BoxJwtOptions; /** * Configure metafiles storage. Defaults to local tmp directory. */ metaStorageConfig?: LocalMetaStorageOptions; /** * OAuth2 user-app flow seeded with a refresh token. Mutually exclusive * with `developerToken`, `ccg`, and `jwt`. */ oauth?: BoxOAuthOptions; /** * When `true`, `getReadUrl` creates (or reuses) an `open`-access shared * link instead of a short-lived signed download URL. Public shared links * may be restricted on Box Business or Enterprise plans; the adapter * surfaces Box's `access_denied_insufficient_permissions` error * unmodified in that case. */ publicByDefault?: boolean; /** * Logical "bucket root" — virtual keys live under this Box folder ID. * Use `"0"` (the default) to anchor at the user's root folder. The * folder must already exist; intermediate subfolders are auto-created * on upload. */ rootFolderId?: string; } /** * Box storage backend. * * Routes virtual keys onto Box folder/file IDs under `rootFolderId`. Uploads * use `uploads.uploadFile` / `uploads.uploadFileVersion` up to 50 MB and * switch to the chunked-upload session API above that threshold. Subfolders * along a key's path are auto-created on first write. * * **Auth precedence**: * 1. `client` (pre-built `BoxClient`) * 2. `developerToken` (static, from Box developer console) * 3. `oauth` (refresh-token seeded — `clientId` + `clientSecret` + `refreshToken`) * 4. `ccg` (Client Credentials Grant — `clientId` + `clientSecret` + `enterpriseId` or `userId`) * 5. `jwt` (JWT Server Auth — `configJsonString` or `configFilePath`) * 6. Env fallback: `BOX_DEVELOPER_TOKEN` * * **Limitations**: * - `metadata` is not supported on the unified API — Box exposes file metadata * via classifications and metadata templates. Use `storage.raw.fileMetadata.*` * directly if you need them. * - `cacheControl` is not supported (Box does not expose HTTP cache headers * on file content). * - `getUploadUrl` is not supported — Box uploads require a multipart `POST` * with both an `attributes` JSON part and the file bytes part, which doesn't * fit the PUT-with-raw-body presigned-URL contract. * - `responseContentDisposition` is not supported on signed download URLs. * - `write()` buffers the full part body in memory before choosing between * the simple-upload and chunked-upload paths. Each request handler runs * independently, so concurrent multi-GB writes are bounded by the host's * available memory. * - ⚠️ Per-operation `signal`/`timeout` are best-effort: the underlying SDK does not support request cancellation, so an in-flight call may complete server-side even after abort. `retries` is honored. */ declare class BoxStorage extends BaseStorage { static override readonly name: string; override checksumTypes: string[]; protected meta: MetaStorage; private readonly authHandle; private readonly client; private readonly fileIdCache; private readonly folderIdCache; private readonly publicByDefault; private readonly rootFolderId; constructor(config: BoxStorageOptions); override get raw(): BoxClient; create(config: FileInit, _options?: OperationOptions): Promise; write(part: FilePart | FileQuery | BoxFile, options?: OperationOptions): Promise; delete({ id }: FileQuery, options?: OperationOptions): Promise; get({ id }: FileQuery, options?: OperationOptions): Promise; copy(name: string, destination: string, options?: OperationOptions & { storageClass?: string; }): Promise; move(name: string, destination: string, options?: OperationOptions): Promise; override list(limit?: number, options?: OperationOptions): Promise; override getReadUrl(key: string, options?: { expiresIn?: number; responseContentDisposition?: string; responseContentType?: string; }): Promise; override getUploadUrl(_key: string, _options?: { contentLength?: number; contentType?: string; expiresIn?: number; }): Promise; private findChildByName; private folderCacheKey; private resolveFolderId; private resolveFileId; private resolveExistingFileForUpload; private performUpload; private ensureSharedLink; private fetchSharedLinkUrl; private internalOnComplete; } export { type BoxCcgOptions, BoxFile, type BoxJwtOptions, BoxMetaStorage, type BoxOAuthOptions, BoxStorage, type BoxStorageOptions };