Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vercel/blob

Package Overview
Dependencies
Maintainers
219
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vercel/blob - npm Package Compare versions

Comparing version 0.8.0 to 0.8.1

1

dist/index.d.ts
import { Readable } from 'node:stream';
interface BlobResult {
url: string;
size: string;

@@ -5,0 +6,0 @@ uploadedAt: Date;

2

dist/index.js

@@ -1,1 +0,1 @@

import{fetch as l}from"undici";var i=class extends Error{constructor(r){super(`Vercel Blob: ${r}`)}},n=class extends Error{constructor(){super("Vercel Blob: Access denied, please provide a valid token for this resource")}},a=class extends Error{constructor(){super("Vercel Blob: Unknown error, please contact support@vercel.com")}};async function m(e,r,t){if(!e)throw new i("pathname is required");if(!r)throw new i("body is required");if(!t||t.access!=="public")throw new i('access must be "public"');let s={authorization:`Bearer ${c(t)}`};t.contentType&&(s["x-content-type"]=t.contentType);let o=await l(`${u()}/${e}`,{method:"PUT",body:r,headers:s,duplex:"half"});if(o.status!==200)throw o.status===403?new n:new a;return o.json()}async function b(e,r){let t=await l(`${u()}/delete`,{method:"POST",headers:{authorization:`Bearer ${c(r)}`,"content-type":"application/json"},body:JSON.stringify({urls:Array.isArray(e)?e:[e]})});if(t.status!==200)throw t.status===403?new n:new a;let s=await t.json();return Array.isArray(e)?s:s[0]}async function p(e,r){let t=new URL(u());t.searchParams.set("url",e);let s=await l(t,{method:"GET",headers:{authorization:`Bearer ${c(r)}`}});if(s.status===404)return null;if(s.status!==200)throw s.status===403?new n:new a;let o=await s.json();return{...o,uploadedAt:new Date(o.uploadedAt)}}async function f(e){let r=new URL(u());e!=null&&e.limit&&r.searchParams.set("limit",e.limit.toString()),e!=null&&e.prefix&&r.searchParams.set("prefix",e.prefix),e!=null&&e.cursor&&r.searchParams.set("cursor",e.cursor);let t=await l(r,{method:"GET",headers:{authorization:`Bearer ${c(e)}`}});if(t.status!==200)throw t.status===403?new n:new a;let s=await t.json();return{...s,blobs:s.blobs.map(o=>({...o,uploadedAt:new Date(o.uploadedAt)}))}}function u(){return process.env.VERCEL_BLOB_API_URL||"https://blob.vercel-storage.com"}function c(e){if(e!=null&&e.token)return e.token;if(!process.env.BLOB_READ_WRITE_TOKEN)throw new Error("BLOB_READ_WRITE_TOKEN environment variable is not set. Please set it to your write token.");return process.env.BLOB_READ_WRITE_TOKEN}export{n as BlobAccessError,i as BlobError,a as BlobUnknownError,b as del,p as head,f as list,m as put};
import{fetch as l}from"undici";var i=class extends Error{constructor(r){super(`Vercel Blob: ${r}`)}},o=class extends Error{constructor(){super("Vercel Blob: Access denied, please provide a valid token for this resource")}},a=class extends Error{constructor(){super("Vercel Blob: Unknown error, please contact support@vercel.com")}};async function m(e,r,t){if(!e)throw new i("pathname is required");if(!r)throw new i("body is required");if(!t||t.access!=="public")throw new i('access must be "public"');let s={authorization:`Bearer ${c(t)}`};t.contentType&&(s["x-content-type"]=t.contentType);let n=await l(`${u()}/${e}`,{method:"PUT",body:r,headers:s,duplex:"half"});if(n.status!==200)throw n.status===403?new o:new a;return n.json()}async function b(e,r){let t=await l(`${u()}/delete`,{method:"POST",headers:{authorization:`Bearer ${c(r)}`,"content-type":"application/json"},body:JSON.stringify({urls:Array.isArray(e)?e:[e]})});if(t.status!==200)throw t.status===403?new o:new a;let s=await t.json();return Array.isArray(e)?s:s[0]}async function p(e,r){let t=new URL(u());t.searchParams.set("url",e);let s=await l(t,{method:"GET",headers:{authorization:`Bearer ${c(r)}`}});if(s.status===404)return null;if(s.status!==200)throw s.status===403?new o:new a;let n=await s.json();return{...n,uploadedAt:new Date(n.uploadedAt)}}async function f(e){let r=new URL(u());e!=null&&e.limit&&r.searchParams.set("limit",e.limit.toString()),e!=null&&e.prefix&&r.searchParams.set("prefix",e.prefix),e!=null&&e.cursor&&r.searchParams.set("cursor",e.cursor);let t=await l(r,{method:"GET",headers:{authorization:`Bearer ${c(e)}`}});if(t.status!==200)throw t.status===403?new o:new a;let s=await t.json();return{...s,blobs:s.blobs.map(n=>({...n,uploadedAt:new Date(n.uploadedAt)}))}}function u(){return process.env.VERCEL_BLOB_API_URL||"https://blob.vercel-storage.com"}function c(e){if(e!=null&&e.token)return e.token;if(!process.env.BLOB_READ_WRITE_TOKEN)throw new Error("BLOB_READ_WRITE_TOKEN environment variable is not set. Please set it to your write token.");return process.env.BLOB_READ_WRITE_TOKEN}export{o as BlobAccessError,i as BlobError,a as BlobUnknownError,b as del,p as head,f as list,m as put};
{
"name": "@vercel/blob",
"version": "0.8.0",
"version": "0.8.1",
"description": "The Vercel Blob JavaScript API client",

@@ -5,0 +5,0 @@ "homepage": "https://vercel.com/blob",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc