@odla-ai/brand 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -4043,7 +4043,8 @@ async function handleDesignPreview(ctx, req, bookId, assetId) {
4043
4043
  const asset = await linkedAsset(ctx, book, assetId);
4044
4044
  if (asset.kind !== DESIGN_ASSET_KIND) throw new BrandNotFoundError(`design ${assetId}`);
4045
4045
  const signed = await ctx.db.storage.sign(asset.path, SIGNED_READ_TTL_SECONDS);
4046
- const fetched = await ctx.fetchPrivateAsset(signed, {
4046
+ const fetchPrivateAsset = ctx.fetchPrivateAsset;
4047
+ const fetched = await fetchPrivateAsset(signed, {
4047
4048
  headers: { accept: "text/html" },
4048
4049
  redirect: "manual",
4049
4050
  signal: req.signal
@@ -4928,7 +4929,8 @@ async function handleBrandDiscussionAsset(ctx, req, target) {
4928
4929
  await ctx.db.storage.sign(before.path, SIGN_TTL_SECONDS)
4929
4930
  );
4930
4931
  if (!signed) throw new BrandInputError("private asset signing failed");
4931
- const response = await ctx.fetchPrivateAsset(signed, {
4932
+ const fetchPrivateAsset = ctx.fetchPrivateAsset;
4933
+ const response = await fetchPrivateAsset(signed, {
4932
4934
  headers: { accept: contentType },
4933
4935
  redirect: "manual",
4934
4936
  signal: req.signal
@@ -5165,7 +5167,10 @@ function createBrandRoutes(options) {
5165
5167
  newId: options.newId ?? (() => crypto.randomUUID()),
5166
5168
  maxUploadBytes: options.maxUploadBytes ?? 8 * 1024 * 1024,
5167
5169
  discussionBasePath: options.discussionBasePath ?? "/",
5168
- fetchPrivateAsset: options.fetchPrivateAsset ?? fetch,
5170
+ // Bound: this is stored on the context and invoked from route handlers,
5171
+ // where a property call would set the receiver to that context and
5172
+ // Cloudflare's fetch refuses a foreign receiver ("Illegal invocation").
5173
+ fetchPrivateAsset: options.fetchPrivateAsset ?? globalThis.fetch.bind(globalThis),
5169
5174
  previewFrameAncestors: options.previewFrameAncestors ?? ["'self'"]
5170
5175
  };
5171
5176
  return async (req) => {