<commit_before>// --------------------------------------------------------------------------------------------------------------------
//
// s3.js - class for AWS Simple Storage Service
//
// Copyright (c) 2011 AppsAttic Ltd - http://www.appsattic.com/
// Written by <NAME> <<EMAIL>>
//
// License: http://opensource.org/licenses/MIT
//
// --------------------------------------------------------------------------------------------------------------------

// --------------------------------------------------------------------------------------------------------------------
// requires

// built-ins
var util = require('util');
var crypto = require('crypto');

// dependencies
var _ = require('underscore');
var xml2js = require('xml2js');
var dateFormat = require('dateformat');
var XML = require('xml');
var data2xml = require('data2xml');

// our own
var awssum = require('../awssum');
var amazon = require('./amazon');
var operations = require('./s3-config');
var esc = require('../esc');

// --------------------------------------------------------------------------------------------------------------------
// package variables

var MARK = 's3: ';

// From: http://docs.amazonwebservices.com/general/latest/gr/rande.html
var endPoint = {};
endPoint[amazon.US_EAST_1]      = "s3.amazonaws.com";
endPoint[amazon.US_WEST_1]      = "s3-us-west-1.amazonaws.com";
endPoint[amazon.US_WEST_2]      = "s3-us-west-2.amazonaws.com";
endPoint[amazon.EU_WEST_1]      = "s3-eu-west-1.amazonaws.com";
endPoint[amazon.AP_SOUTHEAST_1] = "s3-ap-southeast-1.amazonaws.com";
endPoint[amazon.AP_NORTHEAST_1] = "s3-ap-northeast-1.amazonaws.com";
endPoint[amazon.US_GOV_WEST_1]  = "s3-us-gov-west-1.amazonaws.com";
endPoint[amazon.SA_EAST_1]      = "s3-sa-east-1.amazonaws.com";

// From: http://docs.amazonwebservices.com/general/latest/gr/rande.html#s3_region
var locationConstraint = {};
locationConstraint[amazon.US_EAST_1]      = "";
locationConstraint[amazon.US_WEST_1]      = "us-west-1";
locationConstraint[amazon.EU_WEST_1]      = "EU";
locationConstraint[amazon.AP_SOUTHEAST_1] = "ap-southeast-1";
locationConstraint[amazon.AP_NORTHEAST_1] = "ap-northeast-1";
// US_GOV_WEST_1 not defined for public consumption
locationConstraint[amazon.SA_EAST_1]      = "sa-east-1";

var version = '2011-10-04';

// List from: http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/RESTAuthentication.html
var validSubresource = {
    acl            : true,
    'delete'       : true,
    lifecycle      : true,
    location       : true,
    logging        : true,
    notification   : true,
    partNumber     : true,
    policy         : true,
    requestPayment : true,
    torrent        : true,
    uploadId       : true,
    uploads        : true,
    versionId      : true,
    versioning     : true,
    versions       : true,
    website        : true,
};

// create our XML parser
var parser = new xml2js.Parser({ normalize : false, trim : false, explicitRoot : true });

// --------------------------------------------------------------------------------------------------------------------
// constructor

var S3 = function(opts) {
    var self = this;

    // call the superclass for initialisation
    S3.super_.call(this, opts);

    // check the region is valid
    if ( ! endPoint[opts.region] ) {
        throw MARK + "invalid region '" + opts.region + "'";
    }

    return self;
};

// inherit from Amazon
util.inherits(S3, amazon.Amazon);

// --------------------------------------------------------------------------------------------------------------------
// methods we need to implement from awssum.js/amazon.js<commit_msg>Fixes 23, Fixes 25 : Make sure we sign some of the params given<commit_after>// --------------------------------------------------------------------------------------------------------------------
//
// s3.js - class for AWS Simple Storage Service
//
// Copyright (c) 2011 AppsAttic Ltd - http://www.appsattic.com/
// Written by <NAME> <<EMAIL>>
//
// License: http://opensource.org/licenses/MIT
//
// --------------------------------------------------------------------------------------------------------------------

// --------------------------------------------------------------------------------------------------------------------
// requires

// built-ins
var util = require('util');
var crypto = require('crypto');

// dependencies
var _ = require('underscore');
var xml2js = require('xml2js');
var dateFormat = require('dateformat');
var XML = require('xml');
var data2xml = require('data2xml');

// our own
var awssum = require('../awssum');
var amazon = require('./amazon');
var operations = require('./s3-config');
var esc = require('../esc');

// --------------------------------------------------------------------------------------------------------------------
// package variables

var MARK = 's3: ';

// From: http://docs.amazonwebservices.com/general/latest/gr/rande.html
var endPoint = {};
endPoint[amazon.US_EAST_1]      = "s3.amazonaws.com";
endPoint[amazon.US_WEST_1]      = "s3-us-west-1.amazonaws.com";
endPoint[amazon.US_WEST_2]      = "s3-us-west-2.amazonaws.com";
endPoint[amazon.EU_WEST_1]      = "s3-eu-west-1.amazonaws.com";
endPoint[amazon.AP_SOUTHEAST_1] = "s3-ap-southeast-1.amazonaws.com";
endPoint[amazon.AP_NORTHEAST_1] = "s3-ap-northeast-1.amazonaws.com";
endPoint[amazon.US_GOV_WEST_1]  = "s3-us-gov-west-1.amazonaws.com";
endPoint[amazon.SA_EAST_1]      = "s3-sa-east-1.amazonaws.com";

// From: http://docs.amazonwebservices.com/general/latest/gr/rande.html#s3_region
var locationConstraint = {};
locationConstraint[amazon.US_EAST_1]      = "";
locationConstraint[amazon.US_WEST_1]      = "us-west-1";
locationConstraint[amazon.EU_WEST_1]      = "EU";
locationConstraint[amazon.AP_SOUTHEAST_1] = "ap-southeast-1";
locationConstraint[amazon.AP_NORTHEAST_1] = "ap-northeast-1";
// US_GOV_WEST_1 not defined for public consumption
locationConstraint[amazon.SA_EAST_1]      = "sa-east-1";

var version = '2011-10-04';

// List from: http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/RESTAuthentication.html
var validSubresource = {
    acl            : true,
    'delete'       : true,
    lifecycle      : true,
    location       : true,
    logging        : true,
    notification   : true,
    partNumber     : true,
    policy         : true,
    requestPayment : true,
    torrent        : true,
    uploadId       : true,
    uploads        : true,
    versionId      : true,
    versioning     : true,
    versions       : true,
    website        : true,
    // For http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectGET.html
    'response-content-type'        : true,
    'response-content-language'    : true,
    'response-expires'             : true,
    'response-cache-control'       : true,
    'response-content-disposition' : true,
    'response-content-encoding'    : true,
};

// create our XML parser
var parser = new xml2js.Parser({ normalize : false, trim : false, explicitRoot : true });

// --------------------------------------------------------------------------------------------------------------------
// constructor

var S3 = function(opts) {
    var self = this;

    // call the superclass for initialisation
    S3.super_.call(this, opts);

    // check the region is valid
    if ( ! endPoint[opts.region] ) {
        throw MARK + "invalid region '" + opts.region + "'";
    }

    return self;
};

// inherit from Amazon
util.inherits(S3, amazon.Amazon);

// --------------------------------------------------------------------------------------------------------------------
// methods we need to implement from awssum.js/amazon.js
{'fraction_non_alphanumeric': 0.30659885237350026, 'fraction_numerical': 0.018127282211789254, 'mean_word_length': 1.5614562458249832, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 12}, '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': '1726975', 'n_tokens_mistral': 2229, 'n_tokens_neox': 2180, 'n_words': 419}