pinata 2.5.1 → 2.5.2

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.mjs CHANGED
@@ -2555,11 +2555,21 @@ var uploadFile = async (config, file, network, options) => {
2555
2555
  if (options?.car) {
2556
2556
  metadata += `,car ${btoa("true")}`;
2557
2557
  }
2558
+ if (options?.cid_version !== void 0) {
2559
+ metadata += `,cid_version ${btoa(options.cid_version)}`;
2560
+ }
2558
2561
  let updatedEndpoint = `${endpoint}/files`;
2559
2562
  if (options?.url) {
2560
2563
  updatedEndpoint = options.url;
2561
2564
  }
2562
- const urlReq = await fetch(updatedEndpoint, {
2565
+ const requestUrl = new URL(updatedEndpoint);
2566
+ if (options?.cid_version !== void 0) {
2567
+ requestUrl.searchParams.set(
2568
+ "X-Upload-Option-Cid-Version",
2569
+ options.cid_version.toString()
2570
+ );
2571
+ }
2572
+ const urlReq = await fetch(requestUrl.toString(), {
2563
2573
  method: "POST",
2564
2574
  headers: {
2565
2575
  "Upload-Length": `${file.size}`,
@@ -2721,9 +2731,13 @@ var uploadFile = async (config, file, network, options) => {
2721
2731
  if (options?.car) {
2722
2732
  data.append("car", "true");
2723
2733
  }
2734
+ if (options?.cid_version !== void 0) {
2735
+ data.append("cid_version", options.cid_version.toString());
2736
+ }
2724
2737
  if (options?.url) {
2725
2738
  try {
2726
- const request = await fetch(options.url, {
2739
+ const url = new URL(options.url);
2740
+ const request = await fetch(url.toString(), {
2727
2741
  method: "POST",
2728
2742
  headers,
2729
2743
  body: data
@@ -4243,10 +4257,10 @@ var UploadBuilder = class {
4243
4257
  this.uploadUrl = url;
4244
4258
  return this;
4245
4259
  }
4246
- // cidVersion(v: 0 | 1): UploadBuilder<T> {
4247
- // this.version = v;
4248
- // return this;
4249
- // }
4260
+ cidVersion(v) {
4261
+ this._cidVersion = v;
4262
+ return this;
4263
+ }
4250
4264
  group(groupId) {
4251
4265
  this.groupId = groupId;
4252
4266
  return this;
@@ -4289,6 +4303,9 @@ var UploadBuilder = class {
4289
4303
  if (this.carFormat) {
4290
4304
  options.car = this.carFormat;
4291
4305
  }
4306
+ if (this._cidVersion !== void 0) {
4307
+ options.cid_version = this._cidVersion;
4308
+ }
4292
4309
  this.args[this.args.length - 1] = options;
4293
4310
  return this.uploadFunction(this.config, ...this.args).then(
4294
4311
  onfulfilled,