Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Commit

Permalink
feat(CryptoJS, ExifRestorer): Move 3rd-party deps to qq namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
rnicholus committed May 6, 2016
1 parent 0739458 commit 3b12d0b
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion client/js/image-support/scaler.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ qq.extend(qq.Scaler.prototype, {

reader.onload = function() {
originalImageDataUri = reader.result;
insertionEffort.success(ExifRestorer.restore(originalImageDataUri, scaledImageDataUri));
insertionEffort.success(qq.ExifRestorer.restore(originalImageDataUri, scaledImageDataUri));
};

reader.onerror = function() {
Expand Down
48 changes: 24 additions & 24 deletions client/js/s3/request-signer.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,19 @@ qq.s3.RequestSigner = function(o) {
},

signApiRequest: function(signatureConstructor, headersStr, signatureEffort) {
var headersWordArray = CryptoJS.enc.Utf8.parse(headersStr),
headersHmacSha1 = CryptoJS.HmacSHA1(headersWordArray, credentialsProvider.get().secretKey),
headersHmacSha1Base64 = CryptoJS.enc.Base64.stringify(headersHmacSha1);
var headersWordArray = qq.CryptoJS.enc.Utf8.parse(headersStr),
headersHmacSha1 = qq.CryptoJS.HmacSHA1(headersWordArray, credentialsProvider.get().secretKey),
headersHmacSha1Base64 = qq.CryptoJS.enc.Base64.stringify(headersHmacSha1);

generateHeaders(signatureConstructor, headersHmacSha1Base64, signatureEffort);
},

signPolicy: function(policy, signatureEffort, updatedAccessKey, updatedSessionToken) {
var policyStr = JSON.stringify(policy),
policyWordArray = CryptoJS.enc.Utf8.parse(policyStr),
base64Policy = CryptoJS.enc.Base64.stringify(policyWordArray),
policyHmacSha1 = CryptoJS.HmacSHA1(base64Policy, credentialsProvider.get().secretKey),
policyHmacSha1Base64 = CryptoJS.enc.Base64.stringify(policyHmacSha1);
policyWordArray = qq.CryptoJS.enc.Utf8.parse(policyStr),
base64Policy = qq.CryptoJS.enc.Base64.stringify(policyWordArray),
policyHmacSha1 = qq.CryptoJS.HmacSHA1(base64Policy, credentialsProvider.get().secretKey),
policyHmacSha1Base64 = qq.CryptoJS.enc.Base64.stringify(policyHmacSha1);

signatureEffort.success({
policy: base64Policy,
Expand Down Expand Up @@ -164,16 +164,16 @@ qq.s3.RequestSigner = function(o) {
promise.failure(e.target.error);
}
else {
var wordArray = CryptoJS.lib.WordArray.create(e.target.result);
promise.success(CryptoJS.SHA256(wordArray).toString());
var wordArray = qq.CryptoJS.lib.WordArray.create(e.target.result);
promise.success(qq.CryptoJS.SHA256(wordArray).toString());
}
}
};
reader.readAsArrayBuffer(body);
}
else {
body = body || "";
promise.success(CryptoJS.SHA256(body).toString());
promise.success(qq.CryptoJS.SHA256(body).toString());
}

return promise;
Expand All @@ -187,7 +187,7 @@ qq.s3.RequestSigner = function(o) {
getStringToSign: function(signatureSpec) {
var canonicalRequest = v4.getCanonicalRequest(signatureSpec),
date = qq.s3.util.getV4PolicyDate(signatureSpec.date, signatureSpec.drift),
hashedRequest = CryptoJS.SHA256(canonicalRequest).toString(),
hashedRequest = qq.CryptoJS.SHA256(canonicalRequest).toString(),
scope = v4.getScope(signatureSpec.date, options.signatureSpec.region),
stringToSignTemplate = "AWS4-HMAC-SHA256\n{}\n{}\n{}";

Expand Down Expand Up @@ -217,18 +217,18 @@ qq.s3.RequestSigner = function(o) {
matches = headersPattern.exec(headersStr),
dateKey, dateRegionKey, dateRegionServiceKey, signingKey;

dateKey = CryptoJS.HmacSHA256(matches[1], "AWS4" + secretKey);
dateRegionKey = CryptoJS.HmacSHA256(matches[2], dateKey);
dateRegionServiceKey = CryptoJS.HmacSHA256("s3", dateRegionKey);
signingKey = CryptoJS.HmacSHA256("aws4_request", dateRegionServiceKey);
dateKey = qq.CryptoJS.HmacSHA256(matches[1], "AWS4" + secretKey);
dateRegionKey = qq.CryptoJS.HmacSHA256(matches[2], dateKey);
dateRegionServiceKey = qq.CryptoJS.HmacSHA256("s3", dateRegionKey);
signingKey = qq.CryptoJS.HmacSHA256("aws4_request", dateRegionServiceKey);

generateHeaders(signatureConstructor, CryptoJS.HmacSHA256(headersStr, signingKey), signatureEffort);
generateHeaders(signatureConstructor, qq.CryptoJS.HmacSHA256(headersStr, signingKey), signatureEffort);
},

signPolicy: function(policy, signatureEffort, updatedAccessKey, updatedSessionToken) {
var policyStr = JSON.stringify(policy),
policyWordArray = CryptoJS.enc.Utf8.parse(policyStr),
base64Policy = CryptoJS.enc.Base64.stringify(policyWordArray),
policyWordArray = qq.CryptoJS.enc.Utf8.parse(policyStr),
base64Policy = qq.CryptoJS.enc.Base64.stringify(policyWordArray),
secretKey = credentialsProvider.get().secretKey,
credentialPattern = /.+\/(.+)\/(.+)\/s3\/aws4_request/,
credentialCondition = (function() {
Expand All @@ -245,14 +245,14 @@ qq.s3.RequestSigner = function(o) {
matches, dateKey, dateRegionKey, dateRegionServiceKey, signingKey;

matches = credentialPattern.exec(credentialCondition);
dateKey = CryptoJS.HmacSHA256(matches[1], "AWS4" + secretKey);
dateRegionKey = CryptoJS.HmacSHA256(matches[2], dateKey);
dateRegionServiceKey = CryptoJS.HmacSHA256("s3", dateRegionKey);
signingKey = CryptoJS.HmacSHA256("aws4_request", dateRegionServiceKey);
dateKey = qq.CryptoJS.HmacSHA256(matches[1], "AWS4" + secretKey);
dateRegionKey = qq.CryptoJS.HmacSHA256(matches[2], dateKey);
dateRegionServiceKey = qq.CryptoJS.HmacSHA256("s3", dateRegionKey);
signingKey = qq.CryptoJS.HmacSHA256("aws4_request", dateRegionServiceKey);

signatureEffort.success({
policy: base64Policy,
signature: CryptoJS.HmacSHA256(base64Policy, signingKey).toString()
signature: qq.CryptoJS.HmacSHA256(base64Policy, signingKey).toString()
}, updatedAccessKey, updatedSessionToken);
}
};
Expand Down Expand Up @@ -487,7 +487,7 @@ qq.s3.RequestSigner = function(o) {
queryParams = {v4: true};
}

if (credentialsProvider.get().secretKey && window.CryptoJS) {
if (credentialsProvider.get().secretKey && qq.CryptoJS) {
if (credentialsProvider.get().expiration.getTime() > Date.now()) {
determineSignatureClientSide(id, toBeSigned, signatureEffort);
}
Expand Down
2 changes: 1 addition & 1 deletion client/js/third-party/ExifRestorer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//Based on MinifyJpeg
//http://elicon.blog57.fc2.com/blog-entry-206.html

var ExifRestorer = (function()
qq.ExifRestorer = (function()
{

var ExifRestorer = {};
Expand Down
2 changes: 1 addition & 1 deletion client/js/third-party/crypto-js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ code.google.com/p/crypto-js/wiki/License
/**
* CryptoJS core components.
*/
var CryptoJS = CryptoJS || (function (Math, undefined) {
qq.CryptoJS = (function (Math, undefined) {
/**
* CryptoJS namespace.
*/
Expand Down
2 changes: 1 addition & 1 deletion client/js/third-party/crypto-js/enc-base64.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ code.google.com/p/crypto-js/wiki/License
*/
(function () {
// Shortcuts
var C = CryptoJS;
var C = qq.CryptoJS;
var C_lib = C.lib;
var WordArray = C_lib.WordArray;
var C_enc = C.enc;
Expand Down
2 changes: 1 addition & 1 deletion client/js/third-party/crypto-js/hmac.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ code.google.com/p/crypto-js/wiki/License
*/
(function () {
// Shortcuts
var C = CryptoJS;
var C = qq.CryptoJS;
var C_lib = C.lib;
var Base = C_lib.Base;
var C_enc = C.enc;
Expand Down
14 changes: 7 additions & 7 deletions client/js/third-party/crypto-js/lib-typedarrays.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
(function () {
// Check if typed arrays are supported
if (typeof ArrayBuffer != 'function') {
return;
}

// Shortcuts
var C = CryptoJS;
var C = qq.CryptoJS;
var C_lib = C.lib;
var WordArray = C_lib.WordArray;

Expand Down
2 changes: 1 addition & 1 deletion client/js/third-party/crypto-js/sha1.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ code.google.com/p/crypto-js/wiki/License
*/
(function () {
// Shortcuts
var C = CryptoJS;
var C = qq.CryptoJS;
var C_lib = C.lib;
var WordArray = C_lib.WordArray;
var Hasher = C_lib.Hasher;
Expand Down
14 changes: 7 additions & 7 deletions client/js/third-party/crypto-js/sha256.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
(function (Math) {
// Shortcuts
var C = CryptoJS;
var C = qq.CryptoJS;
var C_lib = C.lib;
var WordArray = C_lib.WordArray;
var Hasher = C_lib.Hasher;
Expand Down
2 changes: 1 addition & 1 deletion lib/grunt/configs/concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = function(paths) {
" define(function() {\n" +
" return qq;\n" +
" });\n" +
"}\n" +
"}\n" +
"else if (typeof module !== 'undefined' && module.exports) {\n" +
" module.exports = qq;\n" +
"}\n" +
Expand Down

0 comments on commit 3b12d0b

Please sign in to comment.