@nitida/sdk 0.29.0 → 0.30.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/web.js CHANGED
@@ -772,7 +772,15 @@ var NitidaClient = class {
772
772
  assetId: existing.id,
773
773
  sha256: sha,
774
774
  sha: sha.slice(0, 16),
775
- cdnUrl: this.urlFor(existing, this.bestPresetForAsset(existing, mime))
775
+ mime: existing.mime ?? mime,
776
+ oext: existing.oext ?? null,
777
+ // Same shape as the presign branch below, for the same reason. This
778
+ // DTO does carry `sha` today — but relying on that is how the other
779
+ // branch broke, and the value we hashed ourselves is authoritative.
780
+ cdnUrl: this.urlFor(
781
+ { ...existing, sha: sha.slice(0, 16) },
782
+ this.bestPresetForAsset(existing, mime)
783
+ )
776
784
  };
777
785
  }
778
786
  const presign = await this.assets.presignUploadUrl({
@@ -785,11 +793,38 @@ var NitidaClient = class {
785
793
  ...opts.video != null && { video: opts.video }
786
794
  });
787
795
  if (presign.deduped) {
796
+ const short = sha.slice(0, 16);
788
797
  return {
789
798
  assetId: presign.asset.id,
790
799
  sha256: sha,
791
- sha: sha.slice(0, 16),
792
- cdnUrl: this.urlFor(presign.asset, this.defaultPresetForMime(mime))
800
+ sha: short,
801
+ mime: presign.asset.mime ?? mime,
802
+ oext: presign.asset.oext ?? null,
803
+ // ⭐ `{ ...asset, sha: short }`, never `asset` alone.
804
+ //
805
+ // The presign route answers a dedup hit with `sha256` and NO `sha` —
806
+ // literally the shape `assertSha`'s message names. Handing it straight
807
+ // to a URL builder threw:
808
+ //
809
+ // getAssetUrl: no usable `sha` … has `sha256` but not `sha` —
810
+ // that is the shape `upload()` returns.
811
+ //
812
+ // …with `upload()` as BOTH the accuser and the caller. Found
813
+ // 2026-08-24 by neo's hourly canary, ~16 alerts deep. Before
814
+ // asset-client 0.18.1 the same line produced a `cdnUrl` with the word
815
+ // `undefined` inside it, silently; the guard did its job and made a
816
+ // latent defect loud.
817
+ //
818
+ // This branch is only reached when the asset EXISTS but is not
819
+ // `ready` — the `byHash` branch above returns first otherwise — so
820
+ // ordinary uploads never touched it and no test did either.
821
+ //
822
+ // The sha is not the DTO's to supply: we hashed the bytes ourselves at
823
+ // the top of this method. Build from what we KNOW.
824
+ cdnUrl: this.urlFor(
825
+ { ...presign.asset, sha: short },
826
+ this.defaultPresetForMime(mime)
827
+ )
793
828
  };
794
829
  }
795
830
  const putR = await fetch(presign.upload.url, {
@@ -832,6 +867,8 @@ var NitidaClient = class {
832
867
  assetId,
833
868
  sha256: sha,
834
869
  sha: sha.slice(0, 16),
870
+ mime: final.mime ?? mime,
871
+ oext: final.oext ?? null,
835
872
  cdnUrl: this.urlFor(final, this.bestPresetForAsset(final, mime))
836
873
  };
837
874
  }