<commit_before>'use strict';

const
  fs            = require( 'fs'            ),
  path          = require( 'path'          ),
  child_process = require( 'child_process' ),
  crypto        = require( 'crypto'        ),

  storage_path = path.join(
    process.env.HOME_SESSION_PATH || process.env.HOME || process.env.USERPROFILE || process.env.HOMEPATH,
    '.sharepoint-file-$session'
  ),
  cookie_file_path = path.join( storage_path, 'cookie_data.json' ),
  algorithm        = 'aes-256-ctr';

let request, getmac;
try {
  request = require( 'request' );
  getmac  = require( 'getmac' );
}
catch ( err ) {}

module.exports = class Storage {
  static restore (key) {
    return restore(key);
  }

  static save ( url, payload) {
    return save( url, payload );
  }

  static clear (key) {
    return clear(key);
  }
}

function restore (key='defaultSessionKey') {
  let path = cookie_file_path.replace('$session',key);
  console.log('storage_path',path);
  return new Promise( resolve =>
    fs.readFile( path, 'utf8', ( err, data ) => {
      if ( err ) {
        return resolve();
      }
      decrypt( data ).then(
        data => resolve( {data} )<commit_msg>Update storage.js<commit_after>'use strict';

const
  fs            = require( 'fs'            ),
  path          = require( 'path'          ),
  child_process = require( 'child_process' ),
  crypto        = require( 'crypto'        ),

  storage_path = path.join(
    process.env.HOME_SESSION_PATH || process.env.HOME || process.env.USERPROFILE || process.env.HOMEPATH,
    '.sharepoint-file-$session'
  ),
  cookie_file_path = path.join( storage_path, 'cookie_data.json' ),
  algorithm        = 'aes-256-ctr';

let request, getmac;
try {
  request = require( 'request' );
  getmac  = require( 'getmac' );
}
catch ( err ) {}

module.exports = class Storage {
  static restore (key) {
    return restore(key);
  }

  static save ( url, payload) {
    return save( url, payload );
  }

  static clear (key) {
    return clear(key);
  }
}

function restore (key='defaultSessionKey') {
  let path = cookie_file_path.replace('$session',key);
  //console.log('storage_path',path);
  return new Promise( resolve =>
    fs.readFile( path, 'utf8', ( err, data ) => {
      if ( err ) {
        return resolve();
      }
      decrypt( data ).then(
        data => resolve( {data} )
{'fraction_non_alphanumeric': 0.1482905982905983, 'fraction_numerical': 0.003418803418803419, 'mean_word_length': 2.618238021638331, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2929115', 'n_tokens_mistral': 759, 'n_tokens_neox': 752, 'n_words': 175}