@nitida/asset-client 0.18.1 → 0.19.0

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/AGENTS.md CHANGED
@@ -91,6 +91,22 @@ await getPrivateTransformUrl(asset, { width: 1280 }, signingKey, { expiresInSeco
91
91
  - **`exp` is mandatory**; revocation is *"within a minute"* (60 s TTL at the edge).
92
92
  - **The signing key is a backend secret** — it mints URLs for every private
93
93
  asset the tenant owns.
94
+ - **⭐ Where the signing key comes from: the response that CREATED your
95
+ project, once.** `POST /admin/projects` returns `signingKey` next to the
96
+ three API keys, and the console shows it in the same panel. Nothing else
97
+ hands it out — `GET /admin/projects/:code` does **not** include it. If it is
98
+ lost, the only endpoint that returns a key is
99
+ `POST /admin/projects/:code/rotate-signing-key`, which **invalidates every
100
+ URL already signed** and needs the system-scope key the platform operator
101
+ holds. A tenant with nothing signed yet can rotate for free; a live one
102
+ cannot, which is why you save it at creation.
103
+ - **⭐ Already have a project and never saw a signing key?** Then you never got
104
+ one — projects created before 2026-08-23 were not handed it, and no endpoint
105
+ shows you the current one. **If you have not signed any URLs yet, ask us to
106
+ rotate: with nothing in flight, rotation invalidates nothing and is free.**
107
+ If you already have signed URLs circulating, ask us for the current key
108
+ instead. This is the wall the T5 agent hit, and the sentence that was
109
+ missing.
94
110
 
95
111
  ## The endpoint
96
112
 
package/dist/index.cjs CHANGED
@@ -24,6 +24,7 @@ __export(index_exports, {
24
24
  PRESET_LONG: () => PRESET_LONG,
25
25
  PRESET_MAX_DIM: () => PRESET_MAX_DIM,
26
26
  PRESET_SHORT: () => PRESET_SHORT,
27
+ REQUESTABLE_PRESETS: () => REQUESTABLE_PRESETS,
27
28
  TRANSFORM_WIDTHS: () => TRANSFORM_WIDTHS,
28
29
  accessMessage: () => accessMessage,
29
30
  assertPublic: () => assertPublic,
@@ -54,6 +55,7 @@ __export(index_exports, {
54
55
  hasPreset: () => hasPreset,
55
56
  hlsLadderAlignment: () => hlsLadderAlignment,
56
57
  invalidateSlotCache: () => invalidateSlotCache,
58
+ isRequestablePreset: () => isRequestablePreset,
57
59
  iteratePaletteSwatches: () => iteratePaletteSwatches,
58
60
  pickAmbientBackground: () => pickAmbientBackground,
59
61
  relativeLuminance: () => relativeLuminance,
@@ -63,7 +65,8 @@ __export(index_exports, {
63
65
  setCdnBase: () => setCdnBase,
64
66
  setTenantId: () => setTenantId,
65
67
  signAccessUrl: () => signAccessUrl,
66
- signTransformUrl: () => signTransformUrl
68
+ signTransformUrl: () => signTransformUrl,
69
+ toRequestablePresets: () => toRequestablePresets
67
70
  });
68
71
  module.exports = __toCommonJS(index_exports);
69
72
 
@@ -130,10 +133,10 @@ async function signAccessUrl(publicUrl, signingKey, opts) {
130
133
  u.searchParams.set("sig", sig);
131
134
  return u.toString();
132
135
  }
133
- function assertPublic(asset, fn, escape) {
136
+ function assertPublic(asset, fn, escapeHatch) {
134
137
  if (asset.visibility !== "private") return;
135
138
  throw new Error(
136
- `${fn}: this asset is private, so a public CDN URL for it will answer 404 \u2014 that is the feature, not a missing file. Mint a signed URL on your BACKEND instead: await ${escape}. Never ship the signing key to a browser.`
139
+ `${fn}: this asset is private, so a public CDN URL for it will answer 404 \u2014 that is the feature, not a missing file. Mint a signed URL on your BACKEND instead: await ${escapeHatch}. Never ship the signing key to a browser.`
137
140
  );
138
141
  }
139
142
  function assertSha(asset, fn) {
@@ -503,6 +506,28 @@ function materializeResolution(dto, overridePreset) {
503
506
  }
504
507
 
505
508
  // src/index.ts
509
+ var REQUESTABLE_PRESETS = [
510
+ "thumb",
511
+ "sm",
512
+ "md",
513
+ "lg",
514
+ "xl",
515
+ "original",
516
+ "poster",
517
+ "video",
518
+ "aiproxy",
519
+ "probe"
520
+ ];
521
+ var isRequestablePreset = (v) => REQUESTABLE_PRESETS.includes(v);
522
+ var toRequestablePresets = (input) => {
523
+ const bad = input.filter((p) => !isRequestablePreset(p));
524
+ if (bad.length > 0) {
525
+ throw new Error(
526
+ `Cannot request ${bad.map((b) => `"${b}"`).join(", ")}. \`hls\` and \`mp3\` are things a variant can BE, not things you may ask for \u2014 the server derives them itself (hls when a video is transcoded, mp3 alongside any audio original). Requestable: ${REQUESTABLE_PRESETS.join(", ")}.`
527
+ );
528
+ }
529
+ return input;
530
+ };
506
531
  var PRESET_SHORT = {
507
532
  thumb: "q",
508
533
  sm: "s",
@@ -719,6 +744,7 @@ function getAssetDimensions(asset) {
719
744
  PRESET_LONG,
720
745
  PRESET_MAX_DIM,
721
746
  PRESET_SHORT,
747
+ REQUESTABLE_PRESETS,
722
748
  TRANSFORM_WIDTHS,
723
749
  accessMessage,
724
750
  assertPublic,
@@ -749,6 +775,7 @@ function getAssetDimensions(asset) {
749
775
  hasPreset,
750
776
  hlsLadderAlignment,
751
777
  invalidateSlotCache,
778
+ isRequestablePreset,
752
779
  iteratePaletteSwatches,
753
780
  pickAmbientBackground,
754
781
  relativeLuminance,
@@ -758,6 +785,7 @@ function getAssetDimensions(asset) {
758
785
  setCdnBase,
759
786
  setTenantId,
760
787
  signAccessUrl,
761
- signTransformUrl
788
+ signTransformUrl,
789
+ toRequestablePresets
762
790
  });
763
791
  //# sourceMappingURL=index.cjs.map