@fluxfiles/node 0.1.4 → 0.1.5

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.d.mts CHANGED
@@ -60,6 +60,12 @@ interface BaseTokenOptions {
60
60
  maxPreviewMb?: number;
61
61
  /** TTL (seconds) for per-file gated-local stream tokens. `0`/omitted = inherit (3600). */
62
62
  streamTokenTtl?: number;
63
+ /** Expose the on-demand WebP endpoint (`/api/fm/img`) for images. Omit to inherit the default (true). */
64
+ webpEnabled?: boolean;
65
+ /** Max resize width (px) a transform request may ask for. `0`/omitted = inherit (2000). */
66
+ webpMaxWidth?: number;
67
+ /** Default WebP quality when a request omits it. `0`/omitted = inherit (80). */
68
+ webpDefaultQuality?: number;
63
69
  }
64
70
  interface CreateTokenOptions extends BaseTokenOptions {
65
71
  /** Disk names the token may access. */
package/dist/index.d.ts CHANGED
@@ -60,6 +60,12 @@ interface BaseTokenOptions {
60
60
  maxPreviewMb?: number;
61
61
  /** TTL (seconds) for per-file gated-local stream tokens. `0`/omitted = inherit (3600). */
62
62
  streamTokenTtl?: number;
63
+ /** Expose the on-demand WebP endpoint (`/api/fm/img`) for images. Omit to inherit the default (true). */
64
+ webpEnabled?: boolean;
65
+ /** Max resize width (px) a transform request may ask for. `0`/omitted = inherit (2000). */
66
+ webpMaxWidth?: number;
67
+ /** Default WebP quality when a request omits it. `0`/omitted = inherit (80). */
68
+ webpDefaultQuality?: number;
63
69
  }
64
70
  interface CreateTokenOptions extends BaseTokenOptions {
65
71
  /** Disk names the token may access. */
package/dist/index.js CHANGED
@@ -154,6 +154,9 @@ function applyTenantOverrides(payload, opts) {
154
154
  if (opts.previewUrlTtl && opts.previewUrlTtl > 0) payload.preview_url_ttl = Math.trunc(opts.previewUrlTtl);
155
155
  if (opts.maxPreviewMb && opts.maxPreviewMb > 0) payload.max_preview_mb = Math.trunc(opts.maxPreviewMb);
156
156
  if (opts.streamTokenTtl && opts.streamTokenTtl > 0) payload.stream_token_ttl = Math.trunc(opts.streamTokenTtl);
157
+ if (opts.webpEnabled !== void 0) payload.webp_enabled = !!opts.webpEnabled;
158
+ if (opts.webpMaxWidth && opts.webpMaxWidth > 0) payload.webp_max_width = Math.trunc(opts.webpMaxWidth);
159
+ if (opts.webpDefaultQuality && opts.webpDefaultQuality > 0) payload.webp_default_quality = Math.trunc(opts.webpDefaultQuality);
157
160
  }
158
161
  function validateByobDisk(name, config) {
159
162
  if (!config || config.driver !== "s3") {
package/dist/index.mjs CHANGED
@@ -132,6 +132,9 @@ function applyTenantOverrides(payload, opts) {
132
132
  if (opts.previewUrlTtl && opts.previewUrlTtl > 0) payload.preview_url_ttl = Math.trunc(opts.previewUrlTtl);
133
133
  if (opts.maxPreviewMb && opts.maxPreviewMb > 0) payload.max_preview_mb = Math.trunc(opts.maxPreviewMb);
134
134
  if (opts.streamTokenTtl && opts.streamTokenTtl > 0) payload.stream_token_ttl = Math.trunc(opts.streamTokenTtl);
135
+ if (opts.webpEnabled !== void 0) payload.webp_enabled = !!opts.webpEnabled;
136
+ if (opts.webpMaxWidth && opts.webpMaxWidth > 0) payload.webp_max_width = Math.trunc(opts.webpMaxWidth);
137
+ if (opts.webpDefaultQuality && opts.webpDefaultQuality > 0) payload.webp_default_quality = Math.trunc(opts.webpDefaultQuality);
135
138
  }
136
139
  function validateByobDisk(name, config) {
137
140
  if (!config || config.driver !== "s3") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluxfiles/node",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Server-side Node/TypeScript SDK for minting FluxFiles JWTs (plain + BYOB), byte-compatible with the PHP core",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
package/src/token.ts CHANGED
@@ -120,6 +120,11 @@ function applyTenantOverrides(payload: Record<string, unknown>, opts: BaseTokenO
120
120
  if (opts.previewUrlTtl && opts.previewUrlTtl > 0) payload.preview_url_ttl = Math.trunc(opts.previewUrlTtl);
121
121
  if (opts.maxPreviewMb && opts.maxPreviewMb > 0) payload.max_preview_mb = Math.trunc(opts.maxPreviewMb);
122
122
  if (opts.streamTokenTtl && opts.streamTokenTtl > 0) payload.stream_token_ttl = Math.trunc(opts.streamTokenTtl);
123
+
124
+ // On-demand WebP claims.
125
+ if (opts.webpEnabled !== undefined) payload.webp_enabled = !!opts.webpEnabled;
126
+ if (opts.webpMaxWidth && opts.webpMaxWidth > 0) payload.webp_max_width = Math.trunc(opts.webpMaxWidth);
127
+ if (opts.webpDefaultQuality && opts.webpDefaultQuality > 0) payload.webp_default_quality = Math.trunc(opts.webpDefaultQuality);
123
128
  }
124
129
 
125
130
  /**
package/src/types.ts CHANGED
@@ -62,6 +62,12 @@ export interface BaseTokenOptions {
62
62
  maxPreviewMb?: number;
63
63
  /** TTL (seconds) for per-file gated-local stream tokens. `0`/omitted = inherit (3600). */
64
64
  streamTokenTtl?: number;
65
+ /** Expose the on-demand WebP endpoint (`/api/fm/img`) for images. Omit to inherit the default (true). */
66
+ webpEnabled?: boolean;
67
+ /** Max resize width (px) a transform request may ask for. `0`/omitted = inherit (2000). */
68
+ webpMaxWidth?: number;
69
+ /** Default WebP quality when a request omits it. `0`/omitted = inherit (80). */
70
+ webpDefaultQuality?: number;
65
71
  }
66
72
 
67
73
  export interface CreateTokenOptions extends BaseTokenOptions {