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

@vercel/blob

Package Overview
Dependencies
Maintainers
218
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.4.0 to 0.5.0

2

dist/index.d.ts

@@ -45,3 +45,3 @@ import { Readable } from 'node:stream';

declare function put(pathname: string, body: string | Readable | Blob | ArrayBuffer | FormData | ReadableStream, options: PutCommandOptions): Promise<PutBlobResult>;
declare function del(url: string, options?: BlobCommandOptions): Promise<void>;
declare function del(url: string | string[], options?: BlobCommandOptions): Promise<void>;
declare function head(url: string, options?: BlobCommandOptions): Promise<HeadBlobResult>;

@@ -48,0 +48,0 @@ declare function list(options?: ListCommandOptions): Promise<ListBlobResult>;

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

import{fetch as l}from"undici";var i=class extends Error{constructor(t){super(`Vercel Blob: ${t}`)}},o=class extends Error{constructor(){super("Vercel Blob: Access denied, please provide a valid token")}},n=class extends Error{constructor(){super("Vercel Blob: Unknown error, please contact support@vercel.com")}};async function m(e,t,r){if(!e)throw new i("pathname is required");if(!t)throw new i("body is required");if(!r||r.access!=="public")throw new i('access must be "public"');let s=await l(`${c()}/${e}`,{method:"PUT",body:t,headers:{authorization:`Bearer ${u(r)}`},duplex:"half"});if(s.status!==200)throw s.status===403?new o:new n;return s.json()}async function b(e,t){let r=new URL(c());r.searchParams.set("url",e);let s=await l(r,{method:"DELETE",headers:{authorization:`Bearer ${u(t)}`}});if(s.status!==200)throw s.status===403?new o:new n}async function p(e,t){let r=new URL(c());r.searchParams.set("url",e);let s=await l(r,{method:"GET",headers:{authorization:`Bearer ${u(t)}`}});if(s.status!==200)throw s.status===403?new o:new n;let a=await s.json();return{...a,uploadedAt:new Date(a.uploadedAt)}}async function f(e){let t=new URL(c());e!=null&&e.limit&&t.searchParams.set("limit",e.limit.toString()),e!=null&&e.prefix&&t.searchParams.set("prefix",e.prefix),e!=null&&e.cursor&&t.searchParams.set("cursor",e.cursor);let r=await l(t,{method:"GET",headers:{authorization:`Bearer ${u(e)}`}});if(r.status!==200)throw r.status===403?new o:new n;let s=await r.json();return{...s,blobs:s.blobs.map(a=>({...a,uploadedAt:new Date(a.uploadedAt)}))}}function c(){return process.env.VERCEL_BLOB_API_URL||"https://blob.vercel-storage.com"}function u(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,n 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(t){super(`Vercel Blob: ${t}`)}},o=class extends Error{constructor(){super("Vercel Blob: Access denied, please provide a valid token")}},n=class extends Error{constructor(){super("Vercel Blob: Unknown error, please contact support@vercel.com")}};async function m(e,t,r){if(!e)throw new i("pathname is required");if(!t)throw new i("body is required");if(!r||r.access!=="public")throw new i('access must be "public"');let s=await l(`${c()}/${e}`,{method:"PUT",body:t,headers:{authorization:`Bearer ${u(r)}`},duplex:"half"});if(s.status!==200)throw s.status===403?new o:new n;return s.json()}async function b(e,t){let r=await l(`${c()}/delete`,{method:"POST",headers:{authorization:`Bearer ${u(t)}`,"content-type":"application/json"},body:JSON.stringify({urls:Array.isArray(e)?e:[e]})});if(r.status!==200)throw r.status===403?new o:new n}async function p(e,t){let r=new URL(c());r.searchParams.set("url",e);let s=await l(r,{method:"GET",headers:{authorization:`Bearer ${u(t)}`}});if(s.status!==200)throw s.status===403?new o:new n;let a=await s.json();return{...a,uploadedAt:new Date(a.uploadedAt)}}async function f(e){let t=new URL(c());e!=null&&e.limit&&t.searchParams.set("limit",e.limit.toString()),e!=null&&e.prefix&&t.searchParams.set("prefix",e.prefix),e!=null&&e.cursor&&t.searchParams.set("cursor",e.cursor);let r=await l(t,{method:"GET",headers:{authorization:`Bearer ${u(e)}`}});if(r.status!==200)throw r.status===403?new o:new n;let s=await r.json();return{...s,blobs:s.blobs.map(a=>({...a,uploadedAt:new Date(a.uploadedAt)}))}}function c(){return process.env.VERCEL_BLOB_API_URL||"https://blob.vercel-storage.com"}function u(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,n as BlobUnknownError,b as del,p as head,f as list,m as put};
{
"name": "@vercel/blob",
"version": "0.4.0",
"version": "0.5.0",
"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