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

etc2tc

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

etc2tc - npm Package Compare versions

Comparing version 0.0.1 to 0.0.3

40

dist/etc2tc.js

@@ -8,3 +8,3 @@ 'use strict';

function createObj(obj, name) {
if (!obj[name]) {
if (obj[name] === undefined) {
obj[name] = {};

@@ -15,2 +15,8 @@ }

function pushValue(src, key, dst) {
if (src[key] !== undefined) {
dst[key] = src[key];
}
}
function etc2tc(srcFile, dstFile) {

@@ -25,17 +31,33 @@ if (!srcFile || !dstFile) {

_.each(srcJson, function(c) {
createObj(createObj(createObj(dstJson, c.domain), c.path), c.name);
dstJson[c.domain][c.path][c.name] = {
'key': c.name,
'value': c.value,
var dst = {
'domain': c.domain,
'path': c.path,
'hostOnly': c.hostOnly,
'key': c.name,
// 'value': c.value,
// 'maxAge': c.maxAge,
// 'secure': c.secure,
// 'httpOnly': c.httpOnly,
// 'extensions': c.extensions,
'creation': Moment(),
// 'creationIndex': c.creationIndex,
// 'hostOnly': c.hostOnly,
// 'pathIsDefault': c.pathIsDefault,
'lastAccessed': Moment()
};
if (c.expirationDate) {
dstJson[c.domain][c.path][c.name]['expires'] = Moment(parseInt(c.expirationDate * 1000));
pushValue(c, 'value', dst);
pushValue(c, 'maxAge', dst);
pushValue(c, 'secure', dst);
pushValue(c, 'httpOnly', dst);
pushValue(c, 'extensions', dst);
pushValue(c, 'creationIndex', dst);
pushValue(c, 'hostOnly', dst);
pushValue(c, 'pathIsDefault', dst);
if (c.expirationDate !== undefined) {
dst['expires'] = Moment(parseInt(c.expirationDate * 1000));
}
createObj(createObj(createObj(dstJson, c.domain), c.path), c.name);
dstJson[c.domain][c.path][c.name] = dst;
});

@@ -42,0 +64,0 @@

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

"use strict";function createObj(e,t){return e[t]||(e[t]={}),e[t]}function etc2tc(e,t){if(!e||!t)return null;var n=JSON.parse(Fs.readFileSync(e,"utf8")),a={};return _.each(n,function(e){createObj(createObj(createObj(a,e.domain),e.path),e.name),a[e.domain][e.path][e.name]={key:e.name,value:e.value,domain:e.domain,path:e.path,hostOnly:e.hostOnly,creation:Moment(),lastAccessed:Moment()},e.expirationDate&&(a[e.domain][e.path][e.name].expires=Moment(parseInt(1e3*e.expirationDate)))}),Fs.writeFileSync(t,JSON.stringify(a),"utf8"),t}const Fs=require("fs"),_=require("lodash"),Moment=require("moment");module.exports=etc2tc;
"use strict";function createObj(e,t){return void 0===e[t]&&(e[t]={}),e[t]}function pushValue(e,t,a){void 0!==e[t]&&(a[t]=e[t])}function etc2tc(e,t){if(!e||!t)return null;var a=JSON.parse(Fs.readFileSync(e,"utf8")),n={};return _.each(a,function(e){var t={domain:e.domain,path:e.path,key:e.name,creation:Moment(),lastAccessed:Moment()};pushValue(e,"value",t),pushValue(e,"maxAge",t),pushValue(e,"secure",t),pushValue(e,"httpOnly",t),pushValue(e,"extensions",t),pushValue(e,"creationIndex",t),pushValue(e,"hostOnly",t),pushValue(e,"pathIsDefault",t),void 0!==e.expirationDate&&(t.expires=Moment(parseInt(1e3*e.expirationDate))),createObj(createObj(createObj(n,e.domain),e.path),e.name),n[e.domain][e.path][e.name]=t}),Fs.writeFileSync(t,JSON.stringify(n),"utf8"),t}const Fs=require("fs"),_=require("lodash"),Moment=require("moment");module.exports=etc2tc;

@@ -5,3 +5,3 @@ {

"description": "Convert EditThisCookie json format to ToughCookie json file",
"version": "0.0.1",
"version": "0.0.3",
"main": "dist/etc2tc.js",

@@ -8,0 +8,0 @@ "files": [

@@ -8,3 +8,3 @@ 'use strict';

function createObj(obj, name) {
if (!obj[name]) {
if (obj[name] === undefined) {
obj[name] = {};

@@ -15,2 +15,8 @@ }

function pushValue(src, key, dst) {
if (src[key] !== undefined) {
dst[key] = src[key];
}
}
function etc2tc(srcFile, dstFile) {

@@ -25,17 +31,33 @@ if (!srcFile || !dstFile) {

_.each(srcJson, function(c) {
createObj(createObj(createObj(dstJson, c.domain), c.path), c.name);
dstJson[c.domain][c.path][c.name] = {
'key': c.name,
'value': c.value,
var dst = {
'domain': c.domain,
'path': c.path,
'hostOnly': c.hostOnly,
'key': c.name,
// 'value': c.value,
// 'maxAge': c.maxAge,
// 'secure': c.secure,
// 'httpOnly': c.httpOnly,
// 'extensions': c.extensions,
'creation': Moment(),
// 'creationIndex': c.creationIndex,
// 'hostOnly': c.hostOnly,
// 'pathIsDefault': c.pathIsDefault,
'lastAccessed': Moment()
};
if (c.expirationDate) {
dstJson[c.domain][c.path][c.name]['expires'] = Moment(parseInt(c.expirationDate * 1000));
pushValue(c, 'value', dst);
pushValue(c, 'maxAge', dst);
pushValue(c, 'secure', dst);
pushValue(c, 'httpOnly', dst);
pushValue(c, 'extensions', dst);
pushValue(c, 'creationIndex', dst);
pushValue(c, 'hostOnly', dst);
pushValue(c, 'pathIsDefault', dst);
if (c.expirationDate !== undefined) {
dst['expires'] = Moment(parseInt(c.expirationDate * 1000));
}
createObj(createObj(createObj(dstJson, c.domain), c.path), c.name);
dstJson[c.domain][c.path][c.name] = dst;
});

@@ -42,0 +64,0 @@

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