pinata 0.1.9 → 0.1.10

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
@@ -301,7 +301,7 @@ declare class Gateways {
301
301
  config: PinataConfig | undefined;
302
302
  constructor(config?: PinataConfig);
303
303
  get(cid: string): Promise<GetCIDResponse>;
304
- convert(url: string): string;
304
+ convert(url: string): Promise<string>;
305
305
  }
306
306
  declare class FilterPinJobs {
307
307
  private config;
package/dist/index.d.ts CHANGED
@@ -301,7 +301,7 @@ declare class Gateways {
301
301
  config: PinataConfig | undefined;
302
302
  constructor(config?: PinataConfig);
303
303
  get(cid: string): Promise<GetCIDResponse>;
304
- convert(url: string): string;
304
+ convert(url: string): Promise<string>;
305
305
  }
306
306
  declare class FilterPinJobs {
307
307
  private config;
package/dist/index.js CHANGED
@@ -464,7 +464,7 @@ var uploadJson = async (config, jsonData, options) => {
464
464
  };
465
465
 
466
466
  // src/core/pinning/cid.ts
467
- var uploadCid = async (config, cid2, options) => {
467
+ var uploadCid = async (config, cid, options) => {
468
468
  if (!config || !config.pinataJwt) {
469
469
  throw new ValidationError("Pinata configuration or JWT is missing");
470
470
  }
@@ -478,9 +478,9 @@ var uploadCid = async (config, cid2, options) => {
478
478
  }
479
479
  headers["Source"] = headers["Source"] || "sdk/cid";
480
480
  const data = JSON.stringify({
481
- hashToPin: cid2,
481
+ hashToPin: cid,
482
482
  pinataMetadata: {
483
- name: options?.metadata ? options?.metadata?.name : cid2,
483
+ name: options?.metadata ? options?.metadata?.name : cid,
484
484
  keyvalues: options?.metadata?.keyValues
485
485
  },
486
486
  pinataOptions: {
@@ -599,7 +599,7 @@ var listFiles = async (config, options) => {
599
599
  });
600
600
  if (options) {
601
601
  const {
602
- cid: cid2,
602
+ cid,
603
603
  pinStart,
604
604
  pinEnd,
605
605
  pinSizeMin,
@@ -612,8 +612,8 @@ var listFiles = async (config, options) => {
612
612
  operator,
613
613
  groupId
614
614
  } = options;
615
- if (cid2)
616
- params.append("cid", cid2);
615
+ if (cid)
616
+ params.append("cid", cid);
617
617
  if (pinStart)
618
618
  params.append("pinStart", pinStart);
619
619
  if (pinEnd)
@@ -736,11 +736,18 @@ var updateMetadata = async (config, options) => {
736
736
  };
737
737
 
738
738
  // src/utils/gateway-tools.ts
739
- var isIPFS = __toESM(require("is-ipfs"));
740
- function containsCID(input) {
739
+ var isIPFSModule;
740
+ async function getIsIPFS() {
741
+ if (!isIPFSModule) {
742
+ isIPFSModule = await import("is-ipfs");
743
+ }
744
+ return isIPFSModule;
745
+ }
746
+ async function containsCID(input) {
741
747
  if (typeof input !== "string") {
742
748
  throw new Error("Input is not a string");
743
749
  }
750
+ const isIPFS = await getIsIPFS();
744
751
  const startsWithCID = (str) => {
745
752
  const parts = str.split("/");
746
753
  return isIPFS.cid(parts[0]) ? parts[0] : null;
@@ -758,11 +765,11 @@ function containsCID(input) {
758
765
  } catch (error) {
759
766
  const parts = input.split(/\/|\?/);
760
767
  for (const part of parts) {
761
- const cid2 = startsWithCID(part);
762
- if (cid2) {
768
+ const cid = startsWithCID(part);
769
+ if (cid) {
763
770
  return {
764
771
  containsCid: true,
765
- cid: cid2
772
+ cid
766
773
  };
767
774
  }
768
775
  }
@@ -782,11 +789,11 @@ function containsCID(input) {
782
789
  }
783
790
  const pathParts = url.pathname.split("/");
784
791
  for (const part of pathParts) {
785
- const cid2 = startsWithCID(part);
786
- if (cid2) {
792
+ const cid = startsWithCID(part);
793
+ if (cid) {
787
794
  return {
788
795
  containsCid: true,
789
- cid: cid2
796
+ cid
790
797
  };
791
798
  }
792
799
  }
@@ -795,8 +802,8 @@ function containsCID(input) {
795
802
  cid: null
796
803
  };
797
804
  }
798
- function convertToDesiredGateway(sourceUrl, desiredGatewayPrefix) {
799
- const results = containsCID(sourceUrl);
805
+ async function convertToDesiredGateway(sourceUrl, desiredGatewayPrefix) {
806
+ const results = await containsCID(sourceUrl);
800
807
  if (results.containsCid !== true) {
801
808
  throw new Error("url does not contain CID");
802
809
  }
@@ -823,13 +830,13 @@ function convertToDesiredGateway(sourceUrl, desiredGatewayPrefix) {
823
830
  }
824
831
 
825
832
  // src/core/gateway/getCid.ts
826
- var getCid = async (config, cid2) => {
833
+ var getCid = async (config, cid) => {
827
834
  if (!config || !config.pinataJwt) {
828
835
  throw new ValidationError("Pinata configuration or JWT is missing");
829
836
  }
830
837
  let data;
831
838
  let newUrl;
832
- newUrl = convertToDesiredGateway(cid2, config?.pinataGateway);
839
+ newUrl = await convertToDesiredGateway(cid, config?.pinataGateway);
833
840
  if (config?.pinataGatewayKey) {
834
841
  newUrl = `${newUrl}?pinataGatewayToken=${config?.pinataGatewayKey}`;
835
842
  }
@@ -882,9 +889,9 @@ var getCid = async (config, cid2) => {
882
889
  };
883
890
 
884
891
  // src/core/gateway/convertIPFSUrl.ts
885
- var convertIPFSUrl = (config, url) => {
892
+ var convertIPFSUrl = async (config, url) => {
886
893
  let newUrl;
887
- newUrl = convertToDesiredGateway(url, config?.pinataGateway);
894
+ newUrl = await convertToDesiredGateway(url, config?.pinataGateway);
888
895
  if (config?.pinataGatewayKey) {
889
896
  `${newUrl}?pinataGatewayToken=${config?.pinataGatewayKey}`;
890
897
  }
@@ -900,9 +907,9 @@ var pinJobs = async (config, options) => {
900
907
  includesCount: "false"
901
908
  });
902
909
  if (options) {
903
- const { ipfs_pin_hash: cid2, status, sort, limit, offset } = options;
904
- if (cid2)
905
- params.append("ipfs_pin_hash", cid2.toString());
910
+ const { ipfs_pin_hash: cid, status, sort, limit, offset } = options;
911
+ if (cid)
912
+ params.append("ipfs_pin_hash", cid.toString());
906
913
  if (status)
907
914
  params.append("status", status.toString());
908
915
  if (sort)
@@ -1662,7 +1669,7 @@ var addSignature = async (config, options) => {
1662
1669
  };
1663
1670
 
1664
1671
  // src/core/signatures/getSignature.ts
1665
- var getSignature = async (config, cid2) => {
1672
+ var getSignature = async (config, cid) => {
1666
1673
  if (!config || !config.pinataJwt) {
1667
1674
  throw new ValidationError("Pinata configuration or JWT is missing");
1668
1675
  }
@@ -1676,7 +1683,7 @@ var getSignature = async (config, cid2) => {
1676
1683
  headers["Source"] = headers["Source"] || "sdk/getSignature";
1677
1684
  try {
1678
1685
  const request = await fetch(
1679
- `https://api.pinata.cloud/v3/ipfs/signature/${cid2}`,
1686
+ `https://api.pinata.cloud/v3/ipfs/signature/${cid}`,
1680
1687
  {
1681
1688
  method: "GET",
1682
1689
  headers
@@ -1713,7 +1720,7 @@ var getSignature = async (config, cid2) => {
1713
1720
  };
1714
1721
 
1715
1722
  // src/core/signatures/removeSignature.ts
1716
- var removeSignature = async (config, cid2) => {
1723
+ var removeSignature = async (config, cid) => {
1717
1724
  if (!config || !config.pinataJwt) {
1718
1725
  throw new ValidationError("Pinata configuration or JWT is missing");
1719
1726
  }
@@ -1727,7 +1734,7 @@ var removeSignature = async (config, cid2) => {
1727
1734
  headers["Source"] = headers["Source"] || "sdk/removeSignature";
1728
1735
  try {
1729
1736
  const request = await fetch(
1730
- `https://api.pinata.cloud/v3/ipfs/signature/${cid2}`,
1737
+ `https://api.pinata.cloud/v3/ipfs/signature/${cid}`,
1731
1738
  {
1732
1739
  method: "DELETE",
1733
1740
  headers
@@ -1869,8 +1876,8 @@ var Upload = class {
1869
1876
  json(data, options) {
1870
1877
  return new UploadBuilder(this.config, uploadJson, data, options);
1871
1878
  }
1872
- cid(cid2, options) {
1873
- return new UploadBuilder(this.config, uploadCid, cid2, options);
1879
+ cid(cid, options) {
1880
+ return new UploadBuilder(this.config, uploadCid, cid, options);
1874
1881
  }
1875
1882
  };
1876
1883
  var FilterFiles = class {
@@ -1883,8 +1890,8 @@ var FilterFiles = class {
1883
1890
  this.MINUTE_IN_MS = 6e4;
1884
1891
  this.config = config;
1885
1892
  }
1886
- cid(cid2) {
1887
- this.query.cid = cid2;
1893
+ cid(cid) {
1894
+ this.query.cid = cid;
1888
1895
  return this;
1889
1896
  }
1890
1897
  pinStart(date) {
@@ -1975,8 +1982,8 @@ var Gateways = class {
1975
1982
  constructor(config) {
1976
1983
  this.config = formatConfig(config);
1977
1984
  }
1978
- get(cid2) {
1979
- return getCid(this.config, cid2);
1985
+ get(cid) {
1986
+ return getCid(this.config, cid);
1980
1987
  }
1981
1988
  convert(url) {
1982
1989
  return convertIPFSUrl(this.config, url);
@@ -1992,8 +1999,8 @@ var FilterPinJobs = class {
1992
1999
  this.MINUTE_IN_MS = 6e4;
1993
2000
  this.config = config;
1994
2001
  }
1995
- cid(cid2) {
1996
- this.query.ipfs_pin_hash = cid2;
2002
+ cid(cid) {
2003
+ this.query.ipfs_pin_hash = cid;
1997
2004
  return this;
1998
2005
  }
1999
2006
  status(status) {
@@ -2250,11 +2257,11 @@ var Signatures = class {
2250
2257
  add(options) {
2251
2258
  return addSignature(this.config, options);
2252
2259
  }
2253
- get(cid2) {
2254
- return getSignature(this.config, cid2);
2260
+ get(cid) {
2261
+ return getSignature(this.config, cid);
2255
2262
  }
2256
- delete(cid2) {
2257
- return removeSignature(this.config, cid2);
2263
+ delete(cid) {
2264
+ return removeSignature(this.config, cid);
2258
2265
  }
2259
2266
  };
2260
2267
  // Annotate the CommonJS export names for ESM import in node: