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

edge-csrf

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

edge-csrf - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

5

package.json
{
"name": "edge-csrf",
"description": "Primary logic behind CSRF tokens for Next.js Edge runtime",
"version": "0.1.0",
"version": "0.1.1",
"author": "Andres Morey",

@@ -23,3 +23,6 @@ "license": "MIT",

"@edge-runtime/jest-environment": "^1.1.0-beta.7",
"@edge-runtime/primitives": "^1.1.0-beta.10",
"babel-jest": "^28.1.1",
"beautify-benchmark": "^0.2.4",
"benchmark": "^2.1.4",
"eslint": "^8.18.0",

@@ -26,0 +29,0 @@ "jest": "^28.1.1",

2

README.md

@@ -5,3 +5,3 @@ # Edge-CSRF

This library uses the cookie strategy from [`expressjs/csurf`](https://github.com/expressjs/csurf) and the crypto logic from ['pillarjs/csrf'](https://github.com/pillarjs/csrf) except it only uses Next.js edge runtime dependencies so it can be used in [Next.js middleware](https://nextjs.org/docs/advanced-features/middleware).
This library uses the cookie strategy from [expressjs/csurf](https://github.com/expressjs/csurf) and the crypto logic from [pillarjs/csrf](https://github.com/pillarjs/csrf) except it only uses Next.js edge runtime dependencies so it can be used in [Next.js middleware](https://nextjs.org/docs/advanced-features/middleware).

@@ -8,0 +8,0 @@ # Features

@@ -15,6 +15,7 @@ /**

export function utoa(input) {
let i = input.byteLength;
let output = new Array(i);
while (i--) output[i] = String.fromCharCode(input[i]);
return btoa(output.join(''));
let output = '';
for (let i = 0; i < input.byteLength; i++) {
output += String.fromCharCode(input[i]);
}
return btoa(output);
}

@@ -27,5 +28,4 @@

input = atob(input);
let i = input.length;
let output = new Uint8Array(i);
while (i--) output[i] = input.charCodeAt(i);
let output = new Uint8Array(input.length);
for (let i = 0; i < input.length; i++) output[i] = input.charCodeAt(i);
return output;

@@ -104,9 +104,7 @@ }

let i = hash.byteLength;
// check hash length
if (i !== hashCheck.byteLength) return false;
if (hash.byteLength !== hashCheck.byteLength) return false;
// check hash values
while (i--) {
for (let i = 0; i < hash.byteLength; i++) {
if (hash[i] !== hashCheck[i]) return false;

@@ -124,4 +122,5 @@ }

const salt = new Uint8Array(byteLength);
let i = byteLength;
while (i--) salt[i] = Math.floor(Math.random() * 255);
for (let i = 0; i < byteLength; i++) {
salt[i] = Math.floor(Math.random() * 255);
}
return salt;

@@ -128,0 +127,0 @@ }

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