@nitida/asset-client 0.18.1 → 0.19.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/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
 
@@ -101,5 +117,7 @@ was never renamed.
101
117
 
102
118
  ⚠️ `@aquienpz/asset-client` still exists on npm but is **frozen at 0.14.2 (2026-07-18)**. It
103
119
  predates `oext`, the `variants` array, and a `hasPreset` that does not claim an `original` the
104
- asset does not have. Install `@nitida/asset-client`. The `@aquienpz/tenant-config` and
105
- `@aquienpz/asset-uploader-*` packages are internal and are not on npm at all.
120
+ asset does not have. Install `@nitida/asset-client`. `@nitida/asset-uploader-web` and
121
+ `@nitida/asset-uploader-expo` ARE on npm since 2026-08-23 reach for one only
122
+ when you need an upload to survive a reload or a backgrounded app.
123
+ `@aquienpz/tenant-config` is still internal.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Espacio Futuro LTD
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -128,3 +128,13 @@ shape. `presets` is populated everywhere, on every version — so read existence
128
128
 
129
129
  Deeper guidance — including uploads, tenant onboarding and the CORS boundary — lives in
130
130
  `@nitida/sdk`'s `skills/nitida-sdk/SKILL.md`, which ships inside that package.
131
+
132
+ ## License
133
+
134
+ MIT — see [LICENSE](./LICENSE).
135
+
136
+ ⚠️ **The licence covers this client code, not the service.** MIT lets you use,
137
+ modify and redistribute the SDK; it does not grant access to nitida. The
138
+ service is governed by its own terms and plan tiers, and every call still needs
139
+ credentials issued to your project. Same shape as every other API client you
140
+ already depend on.
package/SECURITY.md ADDED
@@ -0,0 +1,56 @@
1
+ # Security
2
+
3
+ ## Reporting a vulnerability
4
+
5
+ Email **security@espaciofuturo.io**. Please do not open a public issue — a
6
+ public report is a disclosure, and it reaches attackers at the same moment it
7
+ reaches us.
8
+
9
+ Include what you have: the affected package and version, what you did, and what
10
+ happened. A URL that reproduces it is worth more than a paragraph describing
11
+ one. We will confirm receipt and tell you what we found.
12
+
13
+ ## What is in scope
14
+
15
+ The published client packages and the service they talk to:
16
+
17
+ - `@nitida/sdk`, `@nitida/asset-client`
18
+ - `@nitida/asset-compressor-web`, `@nitida/asset-compressor-native`
19
+ - `@nitida/asset-uploader-web`, `@nitida/asset-uploader-expo`
20
+ - the delivery edge (`8ok.uk`) and the API (`api.nitida.gofuture.space`)
21
+
22
+ ## Two behaviours that look like bugs and are not
23
+
24
+ Reported often enough to state up front, so a real report is not lost among
25
+ them:
26
+
27
+ **A 404 on a private asset is the feature.** An asset with
28
+ `visibility: "private"` answers 404 on every public URL — the raw path, every
29
+ stored variant, every `/t/` transform and every HLS segment. It is not a
30
+ missing file. Signed access lives at `/a/{tenant}/…?exp&sig`, minted on your
31
+ backend. See the SDK's `getPrivateAssetUrl`.
32
+
33
+ **A presigned upload URL is a bearer credential, on purpose.** The browser
34
+ uploader persists presigned R2 PUT URLs in IndexedDB, because that is what
35
+ resuming after a reload means. They are write-only, scoped to the parts of one
36
+ upload the holder started, expire in 60 minutes, and are deleted on complete
37
+ and on abort.
38
+
39
+ ## Credentials, and the one mistake that matters
40
+
41
+ An API key (`amk_rt_*`, `amk_ad_*`, `amk_ci_*`) is a **server-side** credential.
42
+ It must never reach a browser bundle, an `NEXT_PUBLIC_*` variable, or a mobile
43
+ app binary.
44
+
45
+ The same goes for a tenant's **URL signing key**: it mints signed URLs for
46
+ every private asset that tenant owns. Sign on your backend, or pre-sign at
47
+ build time.
48
+
49
+ The client packages are built so this is hard to get wrong — the web entrypoint
50
+ `@nitida/sdk/web` does not accept `apiKey` or `signingKey` at all; the types
51
+ reject them. If you find a path that leaks either one, that is exactly the
52
+ report we want.
53
+
54
+ If you believe a key has been exposed, email the address above and we will
55
+ rotate it. Rotating a signing key invalidates every URL already signed with it,
56
+ so tell us whether you have signed URLs in circulation.
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