Commit 40c56362 authored by Christophe Maudoux's avatar Christophe Maudoux 🐛

Append dependencies & Fix JS error (#1430)

parent 723ea519
......@@ -149,6 +149,8 @@ print "<style>\n";
print "$css\n";
print "</style>\n";
print
"<script type=\"text/javascript\" src=\"$portal_url/static/bwr/crypto-js/core.js\"></script>\n";
print
"<script type=\"text/javascript\" src=\"$portal_url/static/bwr/crypto-js/sha256.js\"></script>\n";
print
"<script type=\"text/javascript\" src=\"$portal_url/static/bwr/crypto-js/enc-base64.js\"></script>\n";
......
......@@ -186,6 +186,8 @@ site/htdocs/static/bwr/bootstrap/dist/js/bootstrap.js
site/htdocs/static/bwr/bootstrap/dist/js/bootstrap.js.map
site/htdocs/static/bwr/bootstrap/dist/js/bootstrap.min.js
site/htdocs/static/bwr/bootstrap/dist/js/bootstrap.min.js.map
site/htdocs/static/bwr/crypto-js/core.js
site/htdocs/static/bwr/crypto-js/core.min.js
site/htdocs/static/bwr/crypto-js/enc-base64.js
site/htdocs/static/bwr/crypto-js/enc-base64.min.js
site/htdocs/static/bwr/crypto-js/sha256.js
......
......@@ -7,7 +7,7 @@ $(document).ready ->
tmp = JSON.parse $(this).text()
for k of tmp
values[k] = tmp[k]
console.log 'values=', values[k]
#console.log 'values=', values[k]
catch e
console.log 'Parsing error', e
# Initialize JS communication channel
......@@ -15,14 +15,16 @@ $(document).ready ->
message = e.data
console.log 'message=', message
client_id = decodeURIComponent message.split(' ')[0]
console.log 'client_id=', client_id
#console.log 'client_id=', client_id
session_state = decodeURIComponent message.split(' ')[1]
console.log 'session_state=', session_state
#console.log 'session_state=', session_state
salt = decodeURIComponent session_state.split('.')[1]
console.log 'salt=', salt
#console.log 'salt=', salt
# hash ??????
#ss = hash.toString(CryptoJS.enc.Base64) + '.' + salt
ss = btoa(client_id + ' ' + e.origin + ' ' + salt) + '.' + salt
#ss = btoa(client_id + ' ' + e.origin + ' ' + salt) + '.' + salt
word = CryptoJS.enc.Utf8.parse(client_id + ' ' + e.origin + ' ' + salt)
ss = CryptoJS.enc.Base64.stringify(word) + '.' + salt
if session_state == ss
stat = 'unchanged'
else
......
This diff is collapsed.
!function(t,n){"object"==typeof exports?module.exports=exports=n():"function"==typeof define&&define.amd?define([],n):t.CryptoJS=n()}(this,function(){var t=t||function(t,n){var i=Object.create||function(){function t(){}return function(n){var i;return t.prototype=n,i=new t,t.prototype=null,i}}(),e={},r=e.lib={},o=r.Base=function(){return{extend:function(t){var n=i(this);return t&&n.mixIn(t),n.hasOwnProperty("init")&&this.init!==n.init||(n.init=function(){n.$super.init.apply(this,arguments)}),n.init.prototype=n,n.$super=this,n},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var n in t)t.hasOwnProperty(n)&&(this[n]=t[n]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),s=r.WordArray=o.extend({init:function(t,i){t=this.words=t||[],i!=n?this.sigBytes=i:this.sigBytes=4*t.length},toString:function(t){return(t||c).stringify(this)},concat:function(t){var n=this.words,i=t.words,e=this.sigBytes,r=t.sigBytes;if(this.clamp(),e%4)for(var o=0;o<r;o++){var s=i[o>>>2]>>>24-o%4*8&255;n[e+o>>>2]|=s<<24-(e+o)%4*8}else for(var o=0;o<r;o+=4)n[e+o>>>2]=i[o>>>2];return this.sigBytes+=r,this},clamp:function(){var n=this.words,i=this.sigBytes;n[i>>>2]&=4294967295<<32-i%4*8,n.length=t.ceil(i/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(n){for(var i,e=[],r=function(n){var n=n,i=987654321,e=4294967295;return function(){i=36969*(65535&i)+(i>>16)&e,n=18e3*(65535&n)+(n>>16)&e;var r=(i<<16)+n&e;return r/=4294967296,r+=.5,r*(t.random()>.5?1:-1)}},o=0;o<n;o+=4){var a=r(4294967296*(i||t.random()));i=987654071*a(),e.push(4294967296*a()|0)}return new s.init(e,n)}}),a=e.enc={},c=a.Hex={stringify:function(t){for(var n=t.words,i=t.sigBytes,e=[],r=0;r<i;r++){var o=n[r>>>2]>>>24-r%4*8&255;e.push((o>>>4).toString(16)),e.push((15&o).toString(16))}return e.join("")},parse:function(t){for(var n=t.length,i=[],e=0;e<n;e+=2)i[e>>>3]|=parseInt(t.substr(e,2),16)<<24-e%8*4;return new s.init(i,n/2)}},u=a.Latin1={stringify:function(t){for(var n=t.words,i=t.sigBytes,e=[],r=0;r<i;r++){var o=n[r>>>2]>>>24-r%4*8&255;e.push(String.fromCharCode(o))}return e.join("")},parse:function(t){for(var n=t.length,i=[],e=0;e<n;e++)i[e>>>2]|=(255&t.charCodeAt(e))<<24-e%4*8;return new s.init(i,n)}},f=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return u.parse(unescape(encodeURIComponent(t)))}},h=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(n){var i=this._data,e=i.words,r=i.sigBytes,o=this.blockSize,a=4*o,c=r/a;c=n?t.ceil(c):t.max((0|c)-this._minBufferSize,0);var u=c*o,f=t.min(4*u,r);if(u){for(var h=0;h<u;h+=o)this._doProcessBlock(e,h);var p=e.splice(0,u);i.sigBytes-=f}return new s.init(p,f)},clone:function(){var t=o.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),p=(r.Hasher=h.extend({cfg:o.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){t&&this._append(t);var n=this._doFinalize();return n},blockSize:16,_createHelper:function(t){return function(n,i){return new t.init(i).finalize(n)}},_createHmacHelper:function(t){return function(n,i){return new p.HMAC.init(t,i).finalize(n)}}}),e.algo={});return e}(Math);return t});
//# sourceMappingURL=core.min.js.map
\ No newline at end of file
......@@ -21,7 +21,7 @@
}
});
return window.addEventListener("message", function(e) {
var client_id, message, salt, session_state, ss, stat;
var client_id, message, salt, session_state, ss, stat, word;
message = e.data;
console.log('message=', message);
client_id = decodeURIComponent(message.split(' ')[0]);
......@@ -30,7 +30,8 @@
console.log('session_state=', session_state);
salt = decodeURIComponent(session_state.split('.')[1]);
console.log('salt=', salt);
ss = btoa(client_id + ' ' + e.origin + ' ' + salt) + '.' + salt;
word = CryptoJS.enc.Utf8.parse(client_id + ' ' + e.origin + ' ' + salt);
ss = CryptoJS.enc.Base64.stringify(word) + '.' + salt;
if (session_state === ss) {
stat = 'unchanged';
} else {
......
(function(){var values;values={};$(document).ready(function(){$("script[type='application/init']").each(function(){var e,k,results,tmp;try{tmp=JSON.parse($(this).text());results=[];for(k in tmp){values[k]=tmp[k];results.push(console.log("values=",values[k]))}return results}catch(error){e=error;return console.log("Parsing error",e)}});return window.addEventListener("message",function(e){var client_id,message,salt,session_state,ss,stat;message=e.data;console.log("message=",message);client_id=decodeURIComponent(message.split(" ")[0]);console.log("client_id=",client_id);session_state=decodeURIComponent(message.split(" ")[1]);console.log("session_state=",session_state);salt=decodeURIComponent(session_state.split(".")[1]);console.log("salt=",salt);ss=btoa(client_id+" "+e.origin+" "+salt)+"."+salt;if(session_state===ss){stat="unchanged"}else{stat="changed"}return e.source.postMessage(stat,e.origin)},false)})}).call(this);
(function(){var values;values={};$(document).ready(function(){$("script[type='application/init']").each(function(){var e,k,results,tmp;try{tmp=JSON.parse($(this).text());results=[];for(k in tmp){values[k]=tmp[k];results.push(console.log("values=",values[k]))}return results}catch(error){e=error;return console.log("Parsing error",e)}});return window.addEventListener("message",function(e){var client_id,message,salt,session_state,ss,stat,word;message=e.data;console.log("message=",message);client_id=decodeURIComponent(message.split(" ")[0]);console.log("client_id=",client_id);session_state=decodeURIComponent(message.split(" ")[1]);console.log("session_state=",session_state);salt=decodeURIComponent(session_state.split(".")[1]);console.log("salt=",salt);word=CryptoJS.enc.Utf8.parse(client_id+" "+e.origin+" "+salt);ss=CryptoJS.enc.Base64.stringify(word)+"."+salt;if(session_state===ss){stat="unchanged"}else{stat="changed"}return e.source.postMessage(stat,e.origin)},false)})}).call(this);
......@@ -5,16 +5,19 @@
{"cookiename":"<TMPL_VAR NAME="COOKIENAME">"}
</script>
<!-- //if:usedebianlibs
<script type="text/javascript" src="/javascript/cryptojs/components/core-min.js"></script>
<script type="text/javascript" src="/javascript/cryptojs/components/sha256-min.js"></script>
<script type="text/javascript" src="/javascript/cryptojs/components/enc-base64-min.js"></script>
<script type="text/javascript" src="/javascript/jquery/jquery.min.js"></script>
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">common/js/oidcchecksession.min.js"></script>
//elsif:jsminified
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">bwr/crypto-js/core.min.js"></script>
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">bwr/crypto-js/sha256.min.js"></script>
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">bwr/crypto-js/enc-base64.min.js"></script>
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">bwr/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">common/js/oidcchecksession.min.js"></script>
//else -->
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">bwr/crypto-js/core.js"></script>
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">bwr/crypto-js/sha256.js"></script>
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">bwr/crypto-js/enc-base64.js"></script>
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">bwr/jquery/dist/jquery.js"></script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment