@nitida/sdk 0.32.3 → 0.35.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/dist/server.js CHANGED
@@ -32,6 +32,7 @@ import {
32
32
  configureSlotResolver as configureSlotResolver2,
33
33
  contrastRatio,
34
34
  deriveAccessKey,
35
+ deriveTransformKid,
35
36
  extractAssetSha,
36
37
  getAmbientGradient,
37
38
  getAssetDimensions,
@@ -55,6 +56,9 @@ import {
55
56
  invalidateSlotCache as invalidateSlotCache2,
56
57
  isRequestablePreset as isRequestablePreset2,
57
58
  iteratePaletteSwatches,
59
+ MAX_SIGNED_TRANSFORM_TTL_SECONDS,
60
+ MAX_SIGNED_URL_TTL_SECONDS,
61
+ MIN_SIGNED_TRANSFORM_TTL_SECONDS,
58
62
  PRESET_EXT,
59
63
  PRESET_LONG,
60
64
  PRESET_MAX_DIM,
@@ -70,7 +74,8 @@ import {
70
74
  signAccessUrl,
71
75
  signTransformUrl,
72
76
  TRANSFORM_WIDTHS,
73
- toRequestablePresets as toRequestablePresets2
77
+ toRequestablePresets as toRequestablePresets2,
78
+ transformMessage
74
79
  } from "@nitida/asset-client";
75
80
  function endpointUrl(opts, path, searchParams) {
76
81
  const endpoint = opts.endpoint.replace(/\/+$/, "");
@@ -508,6 +513,13 @@ function mimeFromFileName(fileName) {
508
513
  return ext ? MIME_BY_EXT[ext] ?? null : null;
509
514
  }
510
515
  var DEFAULT_UPLOAD_PRESETS = ["original"];
516
+ function kindForMime(mime) {
517
+ const m = (mime ?? "").toLowerCase();
518
+ if (m.startsWith("video/")) return "video";
519
+ if (m.startsWith("audio/")) return "audio";
520
+ if (m.startsWith("image/")) return "image";
521
+ return "other";
522
+ }
511
523
  async function computeSha256(bytes) {
512
524
  const buf = bytes instanceof Blob ? await bytes.arrayBuffer() : bytes instanceof Uint8Array ? bytes.buffer : bytes;
513
525
  const digest = await crypto.subtle.digest("SHA-256", buf);
@@ -593,7 +605,11 @@ var NitidaClient = class {
593
605
  "aq.transform({ sign: true }) requires `signingKey` in NitidaClientOptions. No signingKey on this client. It is returned ONCE, in the response that creates your project (POST /admin/projects \u2192 `signingKey`, next to the three API keys; the console shows it in the same panel). If you never saw one \u2014 projects created before 2026-08-23 were not handed it \u2014 ask the platform operator to rotate: with no signed URLs in flight that invalidates nothing and is free. If you DO have signed URLs circulating, ask for the current key instead, because rotating would kill them. Then pass it to the SDK constructor on a SERVER-side instance only."
594
606
  );
595
607
  }
596
- return getSignedTransformUrl(asset, opts, this.opts.signingKey) ?? Promise.resolve(this.urlFor(asset, "lg"));
608
+ return getSignedTransformUrl(asset, opts, this.opts.signingKey, {
609
+ expiresInSeconds: signOpts.expiresInSeconds,
610
+ tenantId: signOpts.tenantId ?? this.opts.tenantId,
611
+ nowSeconds: signOpts.nowSeconds
612
+ }) ?? Promise.resolve(this.urlFor(asset, "lg"));
597
613
  }
598
614
  transformSrcSet(asset, widths, extraOpts = {}, signOpts) {
599
615
  if (!signOpts?.sign) return getTransformSrcSet(asset, widths, extraOpts);
@@ -603,12 +619,18 @@ var NitidaClient = class {
603
619
  );
604
620
  }
605
621
  const key = this.opts.signingKey;
622
+ const sign = {
623
+ expiresInSeconds: signOpts.expiresInSeconds,
624
+ tenantId: signOpts.tenantId ?? this.opts.tenantId,
625
+ nowSeconds: signOpts.nowSeconds
626
+ };
606
627
  return Promise.all(
607
628
  widths.map(async (w) => {
608
629
  const signed = await getSignedTransformUrl(
609
630
  asset,
610
631
  { ...extraOpts, width: w },
611
- key
632
+ key,
633
+ sign
612
634
  );
613
635
  return signed ? `${signed} ${w}w` : null;
614
636
  })
@@ -777,6 +799,7 @@ var NitidaClient = class {
777
799
  // Same shape as the presign branch below, for the same reason. This
778
800
  // DTO does carry `sha` today — but relying on that is how the other
779
801
  // branch broke, and the value we hashed ourselves is authoritative.
802
+ kind: existing.kind ?? kindForMime(mime),
780
803
  visibility: existing.visibility ?? "public",
781
804
  presets: existing.presets ?? "",
782
805
  variants: existing.variants ?? [],
@@ -837,6 +860,7 @@ var NitidaClient = class {
837
860
  // ACTUALLY has, now that we waited for it — not from
838
861
  // `defaultPresetForMime`, which is a guess made before anything exists.
839
862
  // Guessing was safe only while this branch never ran.
863
+ kind: settled.kind ?? kindForMime(mime),
840
864
  visibility: settled.visibility ?? "public",
841
865
  presets: settled.presets ?? "",
842
866
  variants: settled.variants ?? [],
@@ -888,6 +912,7 @@ var NitidaClient = class {
888
912
  sha: sha.slice(0, 16),
889
913
  mime: final.mime ?? mime,
890
914
  oext: final.oext ?? null,
915
+ kind: final.kind ?? kindForMime(final.mime ?? mime),
891
916
  visibility: final.visibility ?? "public",
892
917
  presets: final.presets ?? "",
893
918
  variants: final.variants ?? [],
@@ -949,6 +974,9 @@ var NitidaClient2 = class extends NitidaClient {
949
974
  }
950
975
  };
951
976
  export {
977
+ MAX_SIGNED_TRANSFORM_TTL_SECONDS,
978
+ MAX_SIGNED_URL_TTL_SECONDS,
979
+ MIN_SIGNED_TRANSFORM_TTL_SECONDS,
952
980
  NitidaClient2 as NitidaClient,
953
981
  PRESET_EXT,
954
982
  PRESET_LONG,
@@ -964,6 +992,7 @@ export {
964
992
  configureSlotResolver2 as configureSlotResolver,
965
993
  contrastRatio,
966
994
  deriveAccessKey,
995
+ deriveTransformKid,
967
996
  extractAssetSha,
968
997
  getAmbientGradient,
969
998
  getAssetDimensions,
@@ -998,6 +1027,7 @@ export {
998
1027
  setTenantId2 as setTenantId,
999
1028
  signAccessUrl,
1000
1029
  signTransformUrl,
1001
- toRequestablePresets2 as toRequestablePresets
1030
+ toRequestablePresets2 as toRequestablePresets,
1031
+ transformMessage
1002
1032
  };
1003
1033
  //# sourceMappingURL=server.js.map