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

@vercel/edge

Package Overview
Dependencies
Maintainers
164
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vercel/edge - npm Package Compare versions

Comparing version 0.0.1-canary.0 to 0.0.1

src/edge-headers.ts

67

dist/index.d.ts

@@ -17,2 +17,67 @@ declare type ExtraResponseInit = Omit<ResponseInit, 'headers'> & {

export { ExtraResponseInit, next, rewrite };
/**
* City of the original client IP calculated by Vercel Proxy.
*/
declare const CITY_HEADER_NAME = "x-vercel-ip-city";
/**
* Country of the original client IP calculated by Vercel Proxy.
*/
declare const COUNTRY_HEADER_NAME = "x-vercel-ip-country";
/**
* Ip from Vercel Proxy. Do not confuse it with the client Ip.
*/
declare const IP_HEADER_NAME = "x-real-ip";
/**
* Latitude of the original client IP calculated by Vercel Proxy.
*/
declare const LATITUDE_HEADER_NAME = "x-vercel-ip-latitude";
/**
* Longitude of the original client IP calculated by Vercel Proxy.
*/
declare const LONGITUDE_HEADER_NAME = "x-vercel-ip-longitude";
/**
* Region of the original client IP calculated by Vercel Proxy.
*/
declare const REGION_HEADER_NAME = "x-vercel-ip-country-region";
/**
* We define a new type so this function can be reused with
* the global `Request`, `node-fetch` and other types.
*/
interface Request {
headers: {
get(name: string): string | null;
};
}
/**
* The location information of a given request
*/
interface Geo {
/** The city that the request originated from */
city?: string;
/** The country that the request originated from */
country?: string;
/** The Vercel Edge Network region that received the request */
region?: string;
/** The latitude of the client */
latitude?: string;
/** The longitude of the client */
longitude?: string;
}
/**
* Returns the IP address of the request from the headers.
*
* @see {@link IP_HEADER_NAME}
*/
declare function ipAddress(request: Request): string | undefined;
/**
* Returns the location information from for the incoming request
*
* @see {@link CITY_HEADER_NAME}
* @see {@link COUNTRY_HEADER_NAME}
* @see {@link REGION_HEADER_NAME}
* @see {@link LATITUDE_HEADER_NAME}
* @see {@link LONGITUDE_HEADER_NAME}
*/
declare function geolocation(request: Request): Geo;
export { CITY_HEADER_NAME, COUNTRY_HEADER_NAME, ExtraResponseInit, Geo, IP_HEADER_NAME, LATITUDE_HEADER_NAME, LONGITUDE_HEADER_NAME, REGION_HEADER_NAME, geolocation, ipAddress, next, rewrite };

@@ -23,2 +23,10 @@ "use strict";

__export(src_exports, {
CITY_HEADER_NAME: () => CITY_HEADER_NAME,
COUNTRY_HEADER_NAME: () => COUNTRY_HEADER_NAME,
IP_HEADER_NAME: () => IP_HEADER_NAME,
LATITUDE_HEADER_NAME: () => LATITUDE_HEADER_NAME,
LONGITUDE_HEADER_NAME: () => LONGITUDE_HEADER_NAME,
REGION_HEADER_NAME: () => REGION_HEADER_NAME,
geolocation: () => geolocation,
ipAddress: () => ipAddress,
next: () => next,

@@ -46,6 +54,37 @@ rewrite: () => rewrite

}
// src/edge-headers.ts
var CITY_HEADER_NAME = "x-vercel-ip-city";
var COUNTRY_HEADER_NAME = "x-vercel-ip-country";
var IP_HEADER_NAME = "x-real-ip";
var LATITUDE_HEADER_NAME = "x-vercel-ip-latitude";
var LONGITUDE_HEADER_NAME = "x-vercel-ip-longitude";
var REGION_HEADER_NAME = "x-vercel-ip-country-region";
function getHeader(request, key) {
return request.headers.get(key) ?? void 0;
}
function ipAddress(request) {
return getHeader(request, IP_HEADER_NAME);
}
function geolocation(request) {
return {
city: getHeader(request, CITY_HEADER_NAME),
country: getHeader(request, COUNTRY_HEADER_NAME),
region: getHeader(request, REGION_HEADER_NAME),
latitude: getHeader(request, LATITUDE_HEADER_NAME),
longitude: getHeader(request, LONGITUDE_HEADER_NAME)
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
CITY_HEADER_NAME,
COUNTRY_HEADER_NAME,
IP_HEADER_NAME,
LATITUDE_HEADER_NAME,
LONGITUDE_HEADER_NAME,
REGION_HEADER_NAME,
geolocation,
ipAddress,
next,
rewrite
});

4

package.json
{
"name": "@vercel/edge",
"version": "0.0.1-canary.0",
"version": "0.0.1",
"license": "MIT",

@@ -30,3 +30,3 @@ "main": "dist/index.js",

},
"gitHead": "570fd24e29f5e8abb9e01e0ddb2a6c751dd4adfe"
"gitHead": "eed39913e1394477b224c38efe29429b17eeada6"
}
export type { ExtraResponseInit } from './middleware-helpers';
export { next, rewrite } from './middleware-helpers';
export * from './middleware-helpers';
export type { Geo } from './edge-headers';
export * from './edge-headers';

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