New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

macattack-express

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

macattack-express - npm Package Compare versions

Comparing version 0.0.14 to 0.0.15

6

index.js
var macattack = require("macattack"),
macaroons = require("node-macaroons"),
// MacaroonsBuilder = macaroons.MacaroonsBuilder,
// MacaroonsVerifier = macaroons.MacaroonsVerifier,
cert_encoder = require("cert_encoder")

@@ -42,7 +40,7 @@ pem = require("pem"),

var caveatKey = crypto.createHash('md5').digest('hex');
console.log("cert = %j", optionsObj.cert);
// console.log("cert = %j", optionsObj.cert);
var caveatMacaroon = publicKeyMacaroons.addPublicKey3rdPartyCaveat(serializedMacaroon, "Macattack", caveatKey, "cert = " + condenseCertificate(optionsObj.cert), data.publicKey);
console.log("client_macaroon=" + JSON.stringify(caveatMacaroon));
// console.log("client_macaroon=" + macaroons.serialize(caveatMacaroon));

@@ -49,0 +47,0 @@ // Return Express server instance vial callback

{
"name": "macattack-express",
"version": "0.0.14",
"version": "0.0.15",
"description": "macattack for express",

@@ -23,3 +23,3 @@ "main": "index.js",

"pem": "^1.8.1",
"public-key-macaroons": "0.0.6"
"public-key-macaroons": "0.0.7"
},

@@ -26,0 +26,0 @@ "devDependencies": {

@@ -60,2 +60,4 @@ 'use strict';

describe('running with invalid macaroon', function (){
var err = null;

@@ -65,5 +67,7 @@

var req = getBlankRequest(certificate);
var client_macaroon = middlewareFn.client_macaroon;
req.headers.authorization = "Bearer " + client_macaroon.macaroon;
//macaroon is an object
var serializedMacaroon = macaroons.serialize(middlewareFn.client_macaroon);
req.headers.authorization = "Bearer " + serializedMacaroon;
middlewareFn(req, res, function (errObj) {

@@ -85,32 +89,21 @@ err = errObj;

var client_macaroon = middlewareFn.client_macaroon;
var serializedMacaroon = macaroons.serialize(middlewareFn.client_macaroon);
var req = getBlankRequest(certificate);
var m = macaroons.deserialize(client_macaroon.macaroon);
function getDischarge(loc, thirdPartyLoc, cond, onOK, onErr) {
var key = new NodeRSA();
key.importKey(privKey);
var decryptedIdentifier = key.decrypt(client_macaroon.discharge).toString('utf8');
// console.log("client_macaroon.discharge = %j", client_macaroon.discharge);
// console.log("decryptedIdentifier = %j", decryptedIdentifier);
var splitIdentifier = decryptedIdentifier.split("\n");
// console.log("splitIdentifier = %j", splitIdentifier);
var dischargeSerialized = cond.split(" = ")[1];
var decryptedIdentifier = key.decrypt(dischargeSerialized).toString('utf8');
var splitIdentifier = decryptedIdentifier.split("\n").filter(function (n) { return n;});
var splitCaveatKey = splitIdentifier[0].split(" ");
var caveatKey = splitCaveatKey[splitCaveatKey.length - 1];
// console.log("caveatKey = %j", caveatKey);
var dischargeMac = macaroons.newMacaroon(caveatKey, "enc = " + client_macaroon.discharge, "Macattack");
var dischargeMac = macaroons.newMacaroon(caveatKey, cond, thirdPartyLoc);
onOK(dischargeMac);
}
macaroons.discharge(m, getDischarge, function(discharges) {
macaroons.discharge(client_macaroon, getDischarge, function(discharges) {
var serializedDischarge = macaroons.serialize(discharges[1]);
// console.log("serializedDischarge = %j", serializedDischarge);
req.headers.authorization = "Bearer " + client_macaroon.macaroon + "," + serializedDischarge;
req.headers.authorization = "Bearer " + serializedMacaroon + "," + serializedDischarge;

@@ -117,0 +110,0 @@ middlewareFn(req, res, function (errObj) {

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