diff --git a/bower.json b/bower.json index 5f2c6f6..97d8501 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "tincan", - "version": "0.41.1", + "version": "0.50.0", "homepage": "http://rusticisoftware.github.com/TinCanJS/", "authors": [ "Brian J. Miller " diff --git a/build/tincan-min.js b/build/tincan-min.js index 333182e..db59569 100644 --- a/build/tincan-min.js +++ b/build/tincan-min.js @@ -1,4 +1,5 @@ -"0.41.1";var CryptoJS=CryptoJS||function(a,b){var c={},d=c.lib={},e=d.Base=function(){function a(){}return{extend:function(b){a.prototype=this;var c=new a;return b&&c.mixIn(b),c.$super=this,c},create:function(){var a=this.extend();return a.init.apply(a,arguments),a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.$super.extend(this)}}}(),f=d.WordArray=e.extend({init:function(a,c){a=this.words=a||[],this.sigBytes=c!=b?c:4*a.length},toString:function(a){return(a||h).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes,a=a.sigBytes;if(this.clamp(),d%4)for(var e=0;a>e;e++)b[d+e>>>2]|=(c[e>>>2]>>>24-8*(e%4)&255)<<24-8*((d+e)%4);else if(65535e;e+=4)b[d+e>>>2]=c[e>>>2];else b.push.apply(b,c);return this.sigBytes+=a,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-8*(c%4),b.length=a.ceil(c/4)},clone:function(){var a=e.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;b>d;d+=4)c.push(4294967296*a.random()|0);return f.create(c,b)}}),g=c.enc={},h=g.Hex={stringify:function(a){for(var b=a.words,a=a.sigBytes,c=[],d=0;a>d;d++){var e=b[d>>>2]>>>24-8*(d%4)&255;c.push((e>>>4).toString(16)),c.push((15&e).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d+=2)c[d>>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return f.create(c,b/2)}},i=g.Latin1={stringify:function(a){for(var b=a.words,a=a.sigBytes,c=[],d=0;a>d;d++)c.push(String.fromCharCode(b[d>>>2]>>>24-8*(d%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d++)c[d>>>2]|=(255&a.charCodeAt(d))<<24-8*(d%4);return f.create(c,b)}},j=g.Utf8={stringify:function(a){try{return decodeURIComponent(escape(i.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data")}},parse:function(a){return i.parse(unescape(encodeURIComponent(a)))}},k=d.BufferedBlockAlgorithm=e.extend({reset:function(){this._data=f.create(),this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,g=this.blockSize,h=e/(4*g),h=b?a.ceil(h):a.max((0|h)-this._minBufferSize,0),b=h*g,e=a.min(4*b,e);if(b){for(var i=0;b>i;i+=g)this._doProcessBlock(d,i);i=d.splice(0,b),c.sigBytes-=e}return f.create(i,e)},clone:function(){var a=e.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0});d.Hasher=k.extend({init:function(){this.reset()},reset:function(){k.reset.call(this),this._doReset()},update:function(a){return this._append(a),this._process(),this},finalize:function(a){return a&&this._append(a),this._doFinalize(),this._hash},clone:function(){var a=k.clone.call(this);return a._hash=this._hash.clone(),a},blockSize:16,_createHelper:function(a){return function(b,c){return a.create(c).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return l.HMAC.create(a,c).finalize(b)}}});var l=c.algo={};return c}(Math);!function(){var a=CryptoJS,b=a.lib,c=b.WordArray,b=b.Hasher,d=[],e=a.algo.SHA1=b.extend({_doReset:function(){this._hash=c.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,b){for(var c=this._hash.words,e=c[0],f=c[1],g=c[2],h=c[3],i=c[4],j=0;80>j;j++){if(16>j)d[j]=0|a[b+j];else{var k=d[j-3]^d[j-8]^d[j-14]^d[j-16];d[j]=k<<1|k>>>31}k=(e<<5|e>>>27)+i+d[j],k=20>j?k+((f&g|~f&h)+1518500249):40>j?k+((f^g^h)+1859775393):60>j?k+((f&g|f&h|g&h)-1894007588):k+((f^g^h)-899497514),i=h,h=g,g=f<<30|f>>>2,f=e,e=k}c[0]=c[0]+e|0,c[1]=c[1]+f|0,c[2]=c[2]+g|0,c[3]=c[3]+h|0,c[4]=c[4]+i|0},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;b[d>>>5]|=128<<24-d%32,b[(d+64>>>9<<4)+15]=c,a.sigBytes=4*b.length,this._process()}});a.SHA1=b._createHelper(e),a.HmacSHA1=b._createHmacHelper(e)}(),function(){{var a=CryptoJS,b=a.lib,c=b.WordArray,d=a.enc;d.Base64={stringify:function(a){var b=a.words,c=a.sigBytes,d=this._map;a.clamp();for(var e=[],f=0;c>f;f+=3)for(var g=b[f>>>2]>>>24-f%4*8&255,h=b[f+1>>>2]>>>24-(f+1)%4*8&255,i=b[f+2>>>2]>>>24-(f+2)%4*8&255,j=g<<16|h<<8|i,k=0;4>k&&c>f+.75*k;k++)e.push(d.charAt(j>>>6*(3-k)&63));var l=d.charAt(64);if(l)for(;e.length%4;)e.push(l);return e.join("")},parse:function(a){a=a.replace(/\s/g,"");var b=a.length,d=this._map,e=d.charAt(64);if(e){var f=a.indexOf(e);-1!=f&&(b=f)}for(var g=[],h=0,i=0;b>i;i++)if(i%4){var j=d.indexOf(a.charAt(i-1))<>>6-i%4*2;g[h>>>2]|=(j|k)<<24-h%4*8,h++}return c.create(g,h)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}}();var TinCan;!function(){"use strict";var a={statementId:!0,voidedStatementId:!0,verb:!0,object:!0,registration:!0,context:!0,actor:!0,since:!0,until:!0,limit:!0,authoritative:!0,sparse:!0,instructor:!0,ascending:!0,continueToken:!0,agent:!0,activityId:!0,stateId:!0,profileId:!0,activity_platform:!0,grouping:!0,"Accept-Language":!0};TinCan=function(a){this.log("constructor"),this.recordStores=[],this.actor=null,this.activity=null,this.registration=null,this.context=null,this.init(a)},TinCan.prototype={LOG_SRC:"TinCan",log:function(a,b){TinCan.DEBUG&&"undefined"!=typeof console&&console.log&&(b=b||this.LOG_SRC||"TinCan",console.log("TinCan."+b+": "+a))},init:function(a){this.log("init");var b;if(a=a||{},a.hasOwnProperty("url")&&""!==a.url&&this._initFromQueryString(a.url),a.hasOwnProperty("recordStores")&&void 0!==a.recordStores)for(b=0;b0)for("function"==typeof b&&(e=function(a,c){var d;f.log("sendStatement - callbackWrapper: "+h),h>1?(h-=1,j.push({err:a,xhr:c})):1===h?(j.push({err:a,xhr:c}),d=[j,g],b.apply(this,d)):f.log("sendStatement - unexpected record store count: "+h)}),d=0;h>d;d+=1)c=this.recordStores[d],i.push(c.saveStatement(g,{callback:e}));else this.log("[warning] sendStatement: No LRSs added yet (statement not sent)"),"function"==typeof b&&b.apply(this,[null,g]);return{statement:g,results:i}},getStatement:function(a,b){this.log("getStatement");var c;return this.recordStores.length>0?(c=this.recordStores[0],c.retrieveStatement(a,{callback:b})):void this.log("[warning] getStatement: No LRSs added yet (statement not retrieved)")},voidStatement:function(a,b,c){this.log("voidStatement");var d,e,f,g,h,i=this,j=this.recordStores.length,k=[],l=[];if(a instanceof TinCan.Statement&&(a=a.id),"undefined"!=typeof c.actor?e=c.actor:null!==this.actor&&(e=this.actor),f=new TinCan.Statement({actor:e,verb:{id:"http://adlnet.gov/expapi/verbs/voided"},target:{objectType:"StatementRef",id:a}}),j>0)for("function"==typeof b&&(h=function(a,c){var d;i.log("voidStatement - callbackWrapper: "+j),j>1?(j-=1,l.push({err:a,xhr:c})):1===j?(l.push({err:a,xhr:c}),d=[l,f],b.apply(this,d)):i.log("voidStatement - unexpected record store count: "+j)}),g=0;j>g;g+=1)d=this.recordStores[g],k.push(d.saveStatement(f,{callback:h}));else this.log("[warning] voidStatement: No LRSs added yet (statement not sent)"),"function"==typeof b&&b.apply(this,[null,f]);return{statement:f,results:k}},getVoidedStatement:function(a,b){this.log("getVoidedStatement");var c;return this.recordStores.length>0?(c=this.recordStores[0],c.retrieveVoidedStatement(a,{callback:b})):void this.log("[warning] getVoidedStatement: No LRSs added yet (statement not retrieved)")},sendStatements:function(a,b){this.log("sendStatements");var c,d,e,f=this,g=[],h=this.recordStores.length,i=[],j=[];if(0===a.length)"function"==typeof b&&b.apply(this,[null,g]);else{for(d=0;d0)for("function"==typeof b&&(e=function(a,c){var d;f.log("sendStatements - callbackWrapper: "+h),h>1?(h-=1,j.push({err:a,xhr:c})):1===h?(j.push({err:a,xhr:c}),d=[j,g],b.apply(this,d)):f.log("sendStatements - unexpected record store count: "+h)}),d=0;h>d;d+=1)c=this.recordStores[d],i.push(c.saveStatements(g,{callback:e}));else this.log("[warning] sendStatements: No LRSs added yet (statements not sent)"),"function"==typeof b&&b.apply(this,[null,g])}return{statements:g,results:i}},getStatements:function(a){this.log("getStatements");var b,c,d={};return this.recordStores.length>0?(b=this.recordStores[0],a=a||{},c=a.params||{},a.sendActor&&null!==this.actor&&("0.9"===b.version||"0.95"===b.version?c.actor=this.actor:c.agent=this.actor),a.sendActivity&&null!==this.activity&&("0.9"===b.version||"0.95"===b.version?c.target=this.activity:c.activity=this.activity),"undefined"==typeof c.registration&&null!==this.registration&&(c.registration=this.registration),d={params:c},"undefined"!=typeof a.callback&&(d.callback=a.callback),b.queryStatements(d)):void this.log("[warning] getStatements: No LRSs added yet (statements not read)")},getState:function(a,b){this.log("getState");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor,activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.registration?c.registration=b.registration:null!==this.registration&&(c.registration=this.registration),"undefined"!=typeof b.callback&&(c.callback=b.callback),d.retrieveState(a,c)):void this.log("[warning] getState: No LRSs added yet (state not retrieved)")},setState:function(a,b,c){this.log("setState");var d,e;return this.recordStores.length>0?(e=this.recordStores[0],c=c||{},d={agent:"undefined"!=typeof c.agent?c.agent:this.actor,activity:"undefined"!=typeof c.activity?c.activity:this.activity},"undefined"!=typeof c.registration?d.registration=c.registration:null!==this.registration&&(d.registration=this.registration),"undefined"!=typeof c.lastSHA1&&(d.lastSHA1=c.lastSHA1),"undefined"!=typeof c.contentType&&(d.contentType=c.contentType,"undefined"!=typeof c.overwriteJSON&&!c.overwriteJSON&&TinCan.Utils.isApplicationJSON(c.contentType)&&(d.method="POST")),"undefined"!=typeof c.callback&&(d.callback=c.callback),e.saveState(a,b,d)):void this.log("[warning] setState: No LRSs added yet (state not saved)")},deleteState:function(a,b){this.log("deleteState");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor,activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.registration?c.registration=b.registration:null!==this.registration&&(c.registration=this.registration),"undefined"!=typeof b.callback&&(c.callback=b.callback),d.dropState(a,c)):void this.log("[warning] deleteState: No LRSs added yet (state not deleted)")},getActivityProfile:function(a,b){this.log("getActivityProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.retrieveActivityProfile(a,c)):void this.log("[warning] getActivityProfile: No LRSs added yet (activity profile not retrieved)")},setActivityProfile:function(a,b,c){this.log("setActivityProfile");var d,e;return this.recordStores.length>0?(e=this.recordStores[0],c=c||{},d={activity:"undefined"!=typeof c.activity?c.activity:this.activity},"undefined"!=typeof c.callback&&(d.callback=c.callback),"undefined"!=typeof c.lastSHA1&&(d.lastSHA1=c.lastSHA1),"undefined"!=typeof c.contentType&&(d.contentType=c.contentType,"undefined"!=typeof c.overwriteJSON&&!c.overwriteJSON&&TinCan.Utils.isApplicationJSON(c.contentType)&&(d.method="POST")),e.saveActivityProfile(a,b,d)):void this.log("[warning] setActivityProfile: No LRSs added yet (activity profile not saved)")},deleteActivityProfile:function(a,b){this.log("deleteActivityProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.dropActivityProfile(a,c)):void this.log("[warning] deleteActivityProfile: No LRSs added yet (activity profile not deleted)")},getAgentProfile:function(a,b){this.log("getAgentProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.retrieveAgentProfile(a,c)):void this.log("[warning] getAgentProfile: No LRSs added yet (agent profile not retrieved)")},setAgentProfile:function(a,b,c){this.log("setAgentProfile");var d,e;return this.recordStores.length>0?(e=this.recordStores[0],c=c||{},d={agent:"undefined"!=typeof c.agent?c.agent:this.actor},"undefined"!=typeof c.callback&&(d.callback=c.callback),"undefined"!=typeof c.lastSHA1&&(d.lastSHA1=c.lastSHA1),"undefined"!=typeof c.contentType&&(d.contentType=c.contentType,"undefined"!=typeof c.overwriteJSON&&!c.overwriteJSON&&TinCan.Utils.isApplicationJSON(c.contentType)&&(d.method="POST")),e.saveAgentProfile(a,b,d)):void this.log("[warning] setAgentProfile: No LRSs added yet (agent profile not saved)")},deleteAgentProfile:function(a,b){this.log("deleteAgentProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.dropAgentProfile(a,c)):void this.log("[warning] deleteAgentProfile: No LRSs added yet (agent profile not deleted)")}},TinCan.DEBUG=!1,TinCan.enableDebug=function(){TinCan.DEBUG=!0},TinCan.disableDebug=function(){TinCan.DEBUG=!1},TinCan.versions=function(){return["1.0.2","1.0.1","1.0.0","0.95","0.9"]},"object"==typeof module&&(module.exports=TinCan)}(),function(){"use strict";TinCan.Utils={getUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})},getISODateString:function(a){function b(a,b){var c,d;for(("undefined"==typeof a||null===a)&&(a=0),("undefined"==typeof b||null===b)&&(b=2),c=Math.pow(10,b-1),d=a.toString();c>a&&c>1;)d="0"+d,c/=10;return d}return a.getUTCFullYear()+"-"+b(a.getUTCMonth()+1)+"-"+b(a.getUTCDate())+"T"+b(a.getUTCHours())+":"+b(a.getUTCMinutes())+":"+b(a.getUTCSeconds())+"."+b(a.getUTCMilliseconds(),3)+"Z"},convertISO8601DurationToMilliseconds:function(a){var b,c,d,e,f=a.indexOf("-")>=0,g=a.indexOf("T"),h=a.indexOf("H"),i=a.indexOf("M"),j=a.indexOf("S");if(-1===g||-1!==i&&g>i||-1!==a.indexOf("D")||-1!==a.indexOf("Y"))throw new Error("ISO 8601 timestamps including years, months and/or days are not currently supported");return-1===h?(h=g,b=0):b=parseInt(a.slice(g+1,h),10),-1===i?(i=g,c=0):c=parseInt(a.slice(h+1,i),10),d=parseFloat(a.slice(i+1,j)),e=parseInt(1e3*(60*(60*b+c)+d),10),isNaN(e)&&(e=0),f&&(e=-1*e),e},convertMillisecondsToISO8601Duration:function(a){var b,c,d,e,f=parseInt(a,10),g="",h="";return e=Math.round(f/10),0>e&&(g="-",e=-1*e),b=parseInt(e/36e4,10),c=parseInt(e%36e4/6e3,10),d=e%36e4%6e3/100,h=g+"PT",b>0&&(h+=b+"H"),c>0&&(h+=c+"M"),h+=d+"S"},getSHA1String:function(a){return CryptoJS.SHA1(a).toString(CryptoJS.enc.Hex)},getBase64String:function(a){return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Latin1.parse(a))},getLangDictionaryValue:function(a,b){var c,d=this[a];if("undefined"!=typeof b&&"undefined"!=typeof d[b])return d[b];if("undefined"!=typeof d.und)return d.und;if("undefined"!=typeof d["en-US"])return d["en-US"];for(c in d)if(d.hasOwnProperty(c))return d[c];return""},parseURL:function(a,b){var c,d,e,f,g="/"===a.charAt(0),h=["(/[^?#]*)","(\\?[^#]*|)","(#.*|)$"],i=/\+/g,j=/([^&=]+)=?([^&]*)/g,k=function(a){return decodeURIComponent(a.replace(i," "))};if(b=b||{},g){if("undefined"==typeof b.allowRelative||!b.allowRelative)throw new Error("Refusing to parse relative URL without 'allowRelative' option")}else h.unshift("^(https?:)//","(([^:/?#]*)(?::([0-9]+))?)"),-1===a.indexOf("/",8)&&(a+="/");if(c=new RegExp(h.join("")),d=a.match(c),null===d)throw new Error("Unable to parse URL regular expression did not match: '"+a+"'");if(g?(e={protocol:null,host:null,hostname:null,port:null,path:null,pathname:d[1],search:d[2],hash:d[3],params:{}},e.path=e.pathname):(e={protocol:d[1],host:d[2],hostname:d[3],port:d[4],pathname:d[5],search:d[6],hash:d[7],params:{}},e.path=e.protocol+"//"+e.host+e.pathname),""!==e.search)for(;f=j.exec(e.search.substring(1));)e.params[k(f[1])]=k(f[2]);return e},getServerRoot:function(a){var b=a.split("/");return b[0]+"//"+b[2]},getContentTypeFromHeader:function(a){return String(a).split(";")[0]},isApplicationJSON:function(a){return 0===TinCan.Utils.getContentTypeFromHeader(a).toLowerCase().indexOf("application/json")}}}(),function(){"use strict";var a=TinCan.LRS=function(a){this.log("constructor"),this.endpoint=null,this.version=null,this.auth=null,this.allowFail=!0,this.extended=null,this.init(a)};a.prototype={LOG_SRC:"LRS",log:TinCan.prototype.log,init:function(a){this.log("init");var b,c=TinCan.versions(),d=!1;if(a=a||{},a.hasOwnProperty("alertOnRequestFailure")&&this.log("'alertOnRequestFailure' is deprecated (alerts have been removed) no need to set it now"),!a.hasOwnProperty("endpoint")||null===a.endpoint||""===a.endpoint)throw this.log("[error] LRS invalid: no endpoint"),{code:3,mesg:"LRS invalid: no endpoint"};if(this.endpoint=String(a.endpoint),"/"!==this.endpoint.slice(-1)&&(this.log("adding trailing slash to endpoint"),this.endpoint+="/"),a.hasOwnProperty("allowFail")&&(this.allowFail=a.allowFail),a.hasOwnProperty("auth")?this.auth=a.auth:a.hasOwnProperty("username")&&a.hasOwnProperty("password")&&(this.auth="Basic "+TinCan.Utils.getBase64String(a.username+":"+a.password)),a.hasOwnProperty("extended")&&(this.extended=a.extended),this._initByEnvironment(a),"undefined"!=typeof a.version){for(this.log("version: "+a.version),b=0;b0&&(a.name=a.firstName[0],a.firstName.length>1&&(this.degraded=!0)),""!==a.name&&(a.name+=" "),"undefined"!=typeof a.lastName&&a.lastName.length>0&&(a.name+=a.lastName[0],a.lastName.length>1&&(this.degraded=!0))):("undefined"!=typeof a.familyName||"undefined"!=typeof a.givenName)&&(a.name="","undefined"!=typeof a.givenName&&a.givenName.length>0&&(a.name=a.givenName[0],a.givenName.length>1&&(this.degraded=!0)),""!==a.name&&(a.name+=" "),"undefined"!=typeof a.familyName&&a.familyName.length>0&&(a.name+=a.familyName[0],a.familyName.length>1&&(this.degraded=!0))),"object"==typeof a.name&&null!==a.name&&(a.name.length>1&&(this.degraded=!0),a.name=a.name[0]),"object"==typeof a.mbox&&null!==a.mbox&&(a.mbox.length>1&&(this.degraded=!0),a.mbox=a.mbox[0]),"object"==typeof a.mbox_sha1sum&&null!==a.mbox_sha1sum&&(a.mbox_sha1sum.length>1&&(this.degraded=!0),a.mbox_sha1sum=a.mbox_sha1sum[0]),"object"==typeof a.openid&&null!==a.openid&&(a.openid.length>1&&(this.degraded=!0),a.openid=a.openid[0]),"object"==typeof a.account&&null!==a.account&&"undefined"==typeof a.account.homePage&&"undefined"==typeof a.account.name&&(0===a.account.length?delete a.account:(a.account.length>1&&(this.degraded=!0),a.account=a.account[0])),a.hasOwnProperty("account")&&(this.account=a.account instanceof TinCan.AgentAccount?a.account:new TinCan.AgentAccount(a.account)),b=0;b0)for(b.member=[],c=0;c0))for(c=0;c0)if("0.9"===a||"0.95"===a)this[e[b]].length>1&&this.log("[warning] version does not support multiple values in: "+e[b]),d[e[b]]=this[e[b]][0].asVersion(a);else for(d[e[b]]=[],c=0;c0){if("0.9"===a||"0.95"===a)throw this.log("[error] version does not support the 'category' property: "+a),new Error(a+" does not support the 'category' property");for(d.category=[],b=0;b=200&&400>f||e?b.callback?void b.callback(null,a):d={err:null,xhr:a}:(d={err:f,xhr:a},0===f?log("[warning] There was a problem communicating with the Learning Record Store. Aborted, offline, or invalid CORS endpoint ("+f+")",LOG_SRC):log("[warning] There was a problem communicating with the Learning Record Store. ("+f+" | "+a.responseText+")",LOG_SRC),b.callback&&b.callback(f,a),d))},__IEModeConversion=function(a,b,c,d){var e;for(e in b)b.hasOwnProperty(e)&&c.push(e+"="+encodeURIComponent(b[e]));return"undefined"!=typeof d.data&&c.push("content="+encodeURIComponent(d.data)),b["Content-Type"]="application/x-www-form-urlencoded",a+="?method="+d.method,d.method="POST",d.params={},c.length>0&&(d.data=c.join("&")),a},nativeRequest=function(a,b,c){log("sendRequest using XMLHttpRequest",LOG_SRC);var d,e,f,g,h=this,i=[],j={finished:!1,fakeStatus:null},k="undefined"!=typeof c.callback,l=a,m=2048;log("sendRequest using XMLHttpRequest - async: "+k,LOG_SRC);for(e in c.params)c.params.hasOwnProperty(e)&&i.push(e+"="+encodeURIComponent(c.params[e]));if(i.length>0&&(l+="?"+i.join("&")),l.length>=m){if("undefined"!=typeof b["Content-Type"]&&"application/json"!==b["Content-Type"])return g=new Error("Unsupported content type for IE Mode request"),"undefined"!=typeof c.callback&&c.callback(g,null),{err:g,xhr:null};if("undefined"==typeof c.method)return g=new Error("method must not be undefined for an IE Mode Request conversion"),"undefined"!=typeof c.callback&&c.callback(g,null),{err:g,xhr:null};a=__IEModeConversion(a,b,i,c)}else a=l;d="undefined"!=typeof XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"),d.open(c.method,a,k);for(e in b)b.hasOwnProperty(e)&&d.setRequestHeader(e,b[e]);"undefined"!=typeof c.data&&(c.data+=""),f=c.data,k&&(d.onreadystatechange=function(){log("xhr.onreadystatechange - xhr.readyState: "+d.readyState,LOG_SRC),4===d.readyState&&requestComplete.call(h,d,c,j)});try{d.send(f)}catch(n){log("sendRequest caught send exception: "+n,LOG_SRC)}return k?d:requestComplete.call(this,d,c,j)},xdrRequest=function(a,b,c){log("sendRequest using XDomainRequest",LOG_SRC);var d,e,f,g,h,i=this,j=[],k={finished:!1,fakeStatus:null};if("undefined"!=typeof b["Content-Type"]&&"application/json"!==b["Content-Type"])return h=new Error("Unsupported content type for IE Mode request"),c.callback?(c.callback(h,null),null):{err:h,xhr:null};a+="?method="+c.method;for(f in c.params)c.params.hasOwnProperty(f)&&j.push(f+"="+encodeURIComponent(c.params[f]));for(f in b)b.hasOwnProperty(f)&&j.push(f+"="+encodeURIComponent(b[f]));"undefined"!=typeof c.data&&j.push("content="+encodeURIComponent(c.data)),e=j.join("&"),d=new XDomainRequest,d.open("POST",a),c.callback?(d.onload=function(){k.fakeStatus=200,requestComplete.call(i,d,c,k)},d.onerror=function(){k.fakeStatus=400,requestComplete.call(i,d,c,k)},d.ontimeout=function(){k.fakeStatus=0,requestComplete.call(i,d,c,k)}):(d.onload=function(){k.fakeStatus=200},d.onerror=function(){k.fakeStatus=400},d.ontimeout=function(){k.fakeStatus=0}),d.onprogress=function(){},d.timeout=0;try{d.send(e)}catch(l){log("sendRequest caught send exception: "+l,LOG_SRC)}if(!c.callback){for(g=1e4+Date.now(),log("sendRequest - until: "+g+", finished: "+k.finished,LOG_SRC);Date.now()>>2]|=(c[e>>>2]>>>24-8*(e%4)&255)<<24-8*((d+e)%4);else if(65535>>2]=c[e>>>2];else b.push.apply(b,c);return this.sigBytes+=a,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-8*(c%4),b.length=a.ceil(c/4)},clone:function(){var a=f.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;d>>2]>>>24-8*(d%4)&255;c.push((e>>>4).toString(16)),c.push((15&e).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return new g.init(c,b/2)}},j=h.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var c=[],d=0;d>>2]>>>24-8*(d%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>2]|=(255&a.charCodeAt(d))<<24-8*(d%4);return new g.init(c,b)}},k=h.Utf8={stringify:function(a){try{return decodeURIComponent(escape(j.stringify(a)))}catch(a){throw Error("Malformed UTF-8 data")}},parse:function(a){return j.parse(unescape(encodeURIComponent(a)))}},l=d.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=k.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,f=this.blockSize,h=e/(4*f),h=b?a.ceil(h):a.max((0|h)-this._minBufferSize,0);if(b=h*f,e=a.min(4*b,e),b){for(var i=0;ij;j++){if(16>j)e[j]=0|a[b+j];else{var k=e[j-3]^e[j-8]^e[j-14]^e[j-16];e[j]=k<<1|k>>>31}k=(d<<5|d>>>27)+i+e[j],k=20>j?k+((f&g|~f&h)+1518500249):40>j?k+((f^g^h)+1859775393):60>j?k+((f&g|f&h|g&h)-1894007588):k+((f^g^h)-899497514),i=h,h=g,g=f<<30|f>>>2,f=d,d=k}c[0]=c[0]+d|0,c[1]=c[1]+f|0,c[2]=c[2]+g|0,c[3]=c[3]+h|0,c[4]=c[4]+i|0},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;return b[d>>>5]|=128<<24-d%32,b[(d+64>>>9<<4)+14]=Math.floor(c/4294967296),b[(d+64>>>9<<4)+15]=c,a.sigBytes=4*b.length,this._process(),this._hash},clone:function(){var a=d.clone.call(this);return a._hash=this._hash.clone(),a}});a.SHA1=d._createHelper(b),a.HmacSHA1=d._createHmacHelper(b)}();var CryptoJS=CryptoJS||function(a,b){var c={},d=c.lib={},e=function(){},f=d.Base={extend:function(a){e.prototype=this;var b=new e;return a&&b.mixIn(a),b.hasOwnProperty("init")||(b.init=function(){b.$super.init.apply(this,arguments)}),b.init.prototype=b,b.$super=this,b},create:function(){var a=this.extend();return a.init.apply(a,arguments),a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},g=d.WordArray=f.extend({init:function(a,c){a=this.words=a||[],this.sigBytes=c!=b?c:4*a.length},toString:function(a){return(a||i).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes;if(a=a.sigBytes,this.clamp(),d%4)for(var e=0;e>>2]|=(c[e>>>2]>>>24-8*(e%4)&255)<<24-8*((d+e)%4);else if(65535>>2]=c[e>>>2];else b.push.apply(b,c);return this.sigBytes+=a,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-8*(c%4),b.length=a.ceil(c/4)},clone:function(){var a=f.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;d>>2]>>>24-8*(d%4)&255;c.push((e>>>4).toString(16)),c.push((15&e).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return new g.init(c,b/2)}},j=h.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var c=[],d=0;d>>2]>>>24-8*(d%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>2]|=(255&a.charCodeAt(d))<<24-8*(d%4);return new g.init(c,b)}},k=h.Utf8={stringify:function(a){try{return decodeURIComponent(escape(j.stringify(a)))}catch(a){throw Error("Malformed UTF-8 data")}},parse:function(a){return j.parse(unescape(encodeURIComponent(a)))}},l=d.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=k.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,f=this.blockSize,h=e/(4*f),h=b?a.ceil(h):a.max((0|h)-this._minBufferSize,0);if(b=h*f,e=a.min(4*b,e),b){for(var i=0;ij;){var k;a:{k=i;for(var l=a.sqrt(k),m=2;m<=l;m++)if(!(k%m)){k=!1;break a}k=!0}k&&(8>j&&(f[j]=h(a.pow(i,.5))),g[j]=h(a.pow(i,1/3)),j++),i++}var n=[],c=c.SHA256=e.extend({_doReset:function(){this._hash=new d.init(f.slice(0))},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],h=c[3],i=c[4],j=c[5],k=c[6],l=c[7],m=0;64>m;m++){if(16>m)n[m]=0|a[b+m];else{var o=n[m-15],p=n[m-2];n[m]=((o<<25|o>>>7)^(o<<14|o>>>18)^o>>>3)+n[m-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[m-16]}o=l+((i<<26|i>>>6)^(i<<21|i>>>11)^(i<<7|i>>>25))+(i&j^~i&k)+g[m]+n[m],p=((d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22))+(d&e^d&f^e&f),l=k,k=j,j=i,i=h+o|0,h=f,f=e,e=d,d=o+p|0}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+h|0,c[4]=c[4]+i|0,c[5]=c[5]+j|0,c[6]=c[6]+k|0,c[7]=c[7]+l|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;return c[e>>>5]|=128<<24-e%32,c[(e+64>>>9<<4)+14]=a.floor(d/4294967296),c[(e+64>>>9<<4)+15]=d,b.sigBytes=4*c.length,this._process(),this._hash},clone:function(){var a=e.clone.call(this);return a._hash=this._hash.clone(),a}});b.SHA256=e._createHelper(c),b.HmacSHA256=e._createHmacHelper(c)}(Math),function(){var a=CryptoJS,b=a.lib,c=b.WordArray,d=a.enc;d.Base64={stringify:function(a){var b=a.words,c=a.sigBytes,d=this._map;a.clamp();for(var e=[],f=0;f>>2]>>>24-f%4*8&255,h=b[f+1>>>2]>>>24-(f+1)%4*8&255,i=b[f+2>>>2]>>>24-(f+2)%4*8&255,j=g<<16|h<<8|i,k=0;k<4&&f+.75*k>>6*(3-k)&63));var l=d.charAt(64);if(l)for(;e.length%4;)e.push(l);return e.join("")},parse:function(a){var b=a.length,d=this._map,e=d.charAt(64);if(e){var f=a.indexOf(e);f!=-1&&(b=f)}for(var g=[],h=0,i=0;i>>6-i%4*2;g[h>>>2]|=(j|k)<<24-h%4*8,h++}return c.create(g,h)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(){if("function"==typeof ArrayBuffer){var a=CryptoJS,b=a.lib,c=b.WordArray,d=c.init,e=c.init=function(a){if(a instanceof ArrayBuffer&&(a=new Uint8Array(a)),(a instanceof Int8Array||a instanceof Uint8ClampedArray||a instanceof Int16Array||a instanceof Uint16Array||a instanceof Int32Array||a instanceof Uint32Array||a instanceof Float32Array||a instanceof Float64Array)&&(a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength)),a instanceof Uint8Array){for(var b=a.byteLength,c=[],e=0;e>>2]|=a[e]<<24-e%4*8;d.call(this,c,b)}else d.apply(this,arguments)};e.prototype=c}}();var TinCan;!function(){"use strict";var a={statementId:!0,voidedStatementId:!0,verb:!0,object:!0,registration:!0,context:!0,actor:!0,since:!0,until:!0,limit:!0,authoritative:!0,sparse:!0,instructor:!0,ascending:!0,continueToken:!0,agent:!0,activityId:!0,stateId:!0,profileId:!0,activity_platform:!0,grouping:!0,"Accept-Language":!0};TinCan=function(a){this.log("constructor"),this.recordStores=[],this.actor=null,this.activity=null,this.registration=null,this.context=null,this.init(a)},TinCan.prototype={LOG_SRC:"TinCan",log:function(a,b){TinCan.DEBUG&&"undefined"!=typeof console&&console.log&&(b=b||this.LOG_SRC||"TinCan",console.log("TinCan."+b+": "+a))},init:function(a){this.log("init");var b;if(a=a||{},a.hasOwnProperty("url")&&""!==a.url&&this._initFromQueryString(a.url),a.hasOwnProperty("recordStores")&&void 0!==a.recordStores)for(b=0;b0)for("function"==typeof b&&(e=function(a,c){var d;f.log("sendStatement - callbackWrapper: "+h),h>1?(h-=1,j.push({err:a,xhr:c})):1===h?(j.push({err:a,xhr:c}),d=[j,g],b.apply(this,d)):f.log("sendStatement - unexpected record store count: "+h)}),d=0;d0?(d=this.recordStores[0],d.retrieveStatement(a,{callback:b,params:c.params})):void this.log("[warning] getStatement: No LRSs added yet (statement not retrieved)")},voidStatement:function(a,b,c){this.log("voidStatement");var d,e,f,g,h,i=this,j=this.recordStores.length,k=[],l=[];if(a instanceof TinCan.Statement&&(a=a.id),"undefined"!=typeof c.actor?e=c.actor:null!==this.actor&&(e=this.actor),f=new TinCan.Statement({actor:e,verb:{id:"http://adlnet.gov/expapi/verbs/voided"},target:{objectType:"StatementRef",id:a}}),j>0)for("function"==typeof b&&(h=function(a,c){var d;i.log("voidStatement - callbackWrapper: "+j),j>1?(j-=1,l.push({err:a,xhr:c})):1===j?(l.push({err:a,xhr:c}),d=[l,f],b.apply(this,d)):i.log("voidStatement - unexpected record store count: "+j)}),g=0;g0?(c=this.recordStores[0],c.retrieveVoidedStatement(a,{callback:b})):void this.log("[warning] getVoidedStatement: No LRSs added yet (statement not retrieved)")},sendStatements:function(a,b){this.log("sendStatements");var c,d,e,f=this,g=[],h=this.recordStores.length,i=[],j=[];if(0===a.length)"function"==typeof b&&b.apply(this,[null,g]);else{for(d=0;d0)for("function"==typeof b&&(e=function(a,c){var d;f.log("sendStatements - callbackWrapper: "+h),h>1?(h-=1,j.push({err:a,xhr:c})):1===h?(j.push({err:a,xhr:c}),d=[j,g],b.apply(this,d)):f.log("sendStatements - unexpected record store count: "+h)}),d=0;d0?(b=this.recordStores[0],a=a||{},c=a.params||{},a.sendActor&&null!==this.actor&&("0.9"===b.version||"0.95"===b.version?c.actor=this.actor:c.agent=this.actor),a.sendActivity&&null!==this.activity&&("0.9"===b.version||"0.95"===b.version?c.target=this.activity:c.activity=this.activity),"undefined"==typeof c.registration&&null!==this.registration&&(c.registration=this.registration),d={params:c},"undefined"!=typeof a.callback&&(d.callback=a.callback),b.queryStatements(d)):void this.log("[warning] getStatements: No LRSs added yet (statements not read)")},getState:function(a,b){this.log("getState");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor,activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.registration?c.registration=b.registration:null!==this.registration&&(c.registration=this.registration),"undefined"!=typeof b.callback&&(c.callback=b.callback),d.retrieveState(a,c)):void this.log("[warning] getState: No LRSs added yet (state not retrieved)")},setState:function(a,b,c){this.log("setState");var d,e;return this.recordStores.length>0?(e=this.recordStores[0],c=c||{},d={agent:"undefined"!=typeof c.agent?c.agent:this.actor,activity:"undefined"!=typeof c.activity?c.activity:this.activity},"undefined"!=typeof c.registration?d.registration=c.registration:null!==this.registration&&(d.registration=this.registration),"undefined"!=typeof c.lastSHA1&&(d.lastSHA1=c.lastSHA1),"undefined"!=typeof c.contentType&&(d.contentType=c.contentType,"undefined"!=typeof c.overwriteJSON&&!c.overwriteJSON&&TinCan.Utils.isApplicationJSON(c.contentType)&&(d.method="POST")),"undefined"!=typeof c.callback&&(d.callback=c.callback),e.saveState(a,b,d)):void this.log("[warning] setState: No LRSs added yet (state not saved)")},deleteState:function(a,b){this.log("deleteState");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor,activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.registration?c.registration=b.registration:null!==this.registration&&(c.registration=this.registration),"undefined"!=typeof b.callback&&(c.callback=b.callback),d.dropState(a,c)):void this.log("[warning] deleteState: No LRSs added yet (state not deleted)")},getActivityProfile:function(a,b){this.log("getActivityProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.retrieveActivityProfile(a,c)):void this.log("[warning] getActivityProfile: No LRSs added yet (activity profile not retrieved)")},setActivityProfile:function(a,b,c){this.log("setActivityProfile");var d,e;return this.recordStores.length>0?(e=this.recordStores[0],c=c||{},d={activity:"undefined"!=typeof c.activity?c.activity:this.activity},"undefined"!=typeof c.callback&&(d.callback=c.callback),"undefined"!=typeof c.lastSHA1&&(d.lastSHA1=c.lastSHA1),"undefined"!=typeof c.contentType&&(d.contentType=c.contentType,"undefined"!=typeof c.overwriteJSON&&!c.overwriteJSON&&TinCan.Utils.isApplicationJSON(c.contentType)&&(d.method="POST")),e.saveActivityProfile(a,b,d)):void this.log("[warning] setActivityProfile: No LRSs added yet (activity profile not saved)")},deleteActivityProfile:function(a,b){this.log("deleteActivityProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.dropActivityProfile(a,c)):void this.log("[warning] deleteActivityProfile: No LRSs added yet (activity profile not deleted)")},getAgentProfile:function(a,b){this.log("getAgentProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.retrieveAgentProfile(a,c)):void this.log("[warning] getAgentProfile: No LRSs added yet (agent profile not retrieved)")},setAgentProfile:function(a,b,c){this.log("setAgentProfile");var d,e;return this.recordStores.length>0?(e=this.recordStores[0],c=c||{},d={agent:"undefined"!=typeof c.agent?c.agent:this.actor},"undefined"!=typeof c.callback&&(d.callback=c.callback),"undefined"!=typeof c.lastSHA1&&(d.lastSHA1=c.lastSHA1),"undefined"!=typeof c.contentType&&(d.contentType=c.contentType,"undefined"!=typeof c.overwriteJSON&&!c.overwriteJSON&&TinCan.Utils.isApplicationJSON(c.contentType)&&(d.method="POST")),e.saveAgentProfile(a,b,d)):void this.log("[warning] setAgentProfile: No LRSs added yet (agent profile not saved)")},deleteAgentProfile:function(a,b){this.log("deleteAgentProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.dropAgentProfile(a,c)):void this.log("[warning] deleteAgentProfile: No LRSs added yet (agent profile not deleted)")}},TinCan.DEBUG=!1,TinCan.enableDebug=function(){TinCan.DEBUG=!0},TinCan.disableDebug=function(){TinCan.DEBUG=!1},TinCan.versions=function(){return["1.0.2","1.0.1","1.0.0","0.95","0.9"]},"object"==typeof module&&(module.exports=TinCan)}(),function(){"use strict";TinCan.Utils={defaultEncoding:"utf8",getUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})},getISODateString:function(a){function b(a,b){var c,d;for("undefined"!=typeof a&&null!==a||(a=0),"undefined"!=typeof b&&null!==b||(b=2),c=Math.pow(10,b-1),d=a.toString();a1;)d="0"+d,c/=10;return d}return a.getUTCFullYear()+"-"+b(a.getUTCMonth()+1)+"-"+b(a.getUTCDate())+"T"+b(a.getUTCHours())+":"+b(a.getUTCMinutes())+":"+b(a.getUTCSeconds())+"."+b(a.getUTCMilliseconds(),3)+"Z"},convertISO8601DurationToMilliseconds:function(a){var b,c,d,e,f=a.indexOf("-")>=0,g=a.indexOf("T"),h=a.indexOf("H"),i=a.indexOf("M"),j=a.indexOf("S");if(g===-1||i!==-1&&i0&&(h+=b+"H"),c>0&&(h+=c+"M"),h+=d+"S"},getSHA1String:function(a){return CryptoJS.SHA1(a).toString(CryptoJS.enc.Hex)},getSHA256String:function(a){return"[object ArrayBuffer]"===Object.prototype.toString.call(a)&&(a=CryptoJS.lib.WordArray.create(a)),CryptoJS.SHA256(a).toString(CryptoJS.enc.Hex)},getBase64String:function(a){return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Latin1.parse(a))},getLangDictionaryValue:function(a,b){var c,d=this[a];if("undefined"!=typeof b&&"undefined"!=typeof d[b])return d[b];if("undefined"!=typeof d.und)return d.und;if("undefined"!=typeof d["en-US"])return d["en-US"];for(c in d)if(d.hasOwnProperty(c))return d[c];return""},parseURL:function(a,b){var c,d,e,f,g="/"===a.charAt(0),h=["(/[^?#]*)","(\\?[^#]*|)","(#.*|)$"],i=/\+/g,j=/([^&=]+)=?([^&]*)/g,k=function(a){return decodeURIComponent(a.replace(i," "))};if(b=b||{},g){if("undefined"==typeof b.allowRelative||!b.allowRelative)throw new Error("Refusing to parse relative URL without 'allowRelative' option")}else h.unshift("^(https?:)//","(([^:/?#]*)(?::([0-9]+))?)"),a.indexOf("/",8)===-1&&(a+="/");if(c=new RegExp(h.join("")),d=a.match(c),null===d)throw new Error("Unable to parse URL regular expression did not match: '"+a+"'");if(g?(e={protocol:null,host:null,hostname:null,port:null,path:null,pathname:d[1],search:d[2],hash:d[3],params:{}},e.path=e.pathname):(e={protocol:d[1],host:d[2],hostname:d[3],port:d[4],pathname:d[5],search:d[6],hash:d[7],params:{}},e.path=e.protocol+"//"+e.host+e.pathname),""!==e.search)for(;f=j.exec(e.search.substring(1));)e.params[k(f[1])]=k(f[2]);return e},getServerRoot:function(a){var b=a.split("/");return b[0]+"//"+b[2]},getContentTypeFromHeader:function(a){return String(a).split(";")[0]},isApplicationJSON:function(a){return 0===TinCan.Utils.getContentTypeFromHeader(a).toLowerCase().indexOf("application/json")},stringToArrayBuffer:function(){TinCan.prototype.log("stringToArrayBuffer not overloaded - no environment loaded?")},stringFromArrayBuffer:function(){TinCan.prototype.log("stringFromArrayBuffer not overloaded - no environment loaded?")}}}(),function(){"use strict";var a=TinCan.LRS=function(a){this.log("constructor"),this.endpoint=null,this.version=null,this.auth=null,this.allowFail=!0,this.extended=null,this.init(a)};a.prototype={LOG_SRC:"LRS",log:TinCan.prototype.log,init:function(a){this.log("init");var b,c=TinCan.versions(),d=!1;if(a=a||{},a.hasOwnProperty("alertOnRequestFailure")&&this.log("'alertOnRequestFailure' is deprecated (alerts have been removed) no need to set it now"),!a.hasOwnProperty("endpoint")||null===a.endpoint||""===a.endpoint)throw this.log("[error] LRS invalid: no endpoint"),{code:3,mesg:"LRS invalid: no endpoint"};if(this.endpoint=String(a.endpoint),"/"!==this.endpoint.slice(-1)&&(this.log("adding trailing slash to endpoint"),this.endpoint+="/"),a.hasOwnProperty("allowFail")&&(this.allowFail=a.allowFail),a.hasOwnProperty("auth")?this.auth=a.auth:a.hasOwnProperty("username")&&a.hasOwnProperty("password")&&(this.auth="Basic "+TinCan.Utils.getBase64String(a.username+":"+a.password)),a.hasOwnProperty("extended")&&(this.extended=a.extended),this._initByEnvironment(a),"undefined"!=typeof a.version){for(this.log("version: "+a.version),b=0;b0&&(a.name=a.firstName[0],a.firstName.length>1&&(this.degraded=!0)),""!==a.name&&(a.name+=" "),"undefined"!=typeof a.lastName&&a.lastName.length>0&&(a.name+=a.lastName[0],a.lastName.length>1&&(this.degraded=!0))):"undefined"==typeof a.familyName&&"undefined"==typeof a.givenName||(a.name="","undefined"!=typeof a.givenName&&a.givenName.length>0&&(a.name=a.givenName[0],a.givenName.length>1&&(this.degraded=!0)),""!==a.name&&(a.name+=" "),"undefined"!=typeof a.familyName&&a.familyName.length>0&&(a.name+=a.familyName[0],a.familyName.length>1&&(this.degraded=!0))),"object"==typeof a.name&&null!==a.name&&(a.name.length>1&&(this.degraded=!0),a.name=a.name[0]),"object"==typeof a.mbox&&null!==a.mbox&&(a.mbox.length>1&&(this.degraded=!0),a.mbox=a.mbox[0]),"object"==typeof a.mbox_sha1sum&&null!==a.mbox_sha1sum&&(a.mbox_sha1sum.length>1&&(this.degraded=!0),a.mbox_sha1sum=a.mbox_sha1sum[0]),"object"==typeof a.openid&&null!==a.openid&&(a.openid.length>1&&(this.degraded=!0),a.openid=a.openid[0]),"object"==typeof a.account&&null!==a.account&&"undefined"==typeof a.account.homePage&&"undefined"==typeof a.account.name&&(0===a.account.length?delete a.account:(a.account.length>1&&(this.degraded=!0),a.account=a.account[0])),a.hasOwnProperty("account")&&(a.account instanceof TinCan.AgentAccount?this.account=a.account:this.account=new TinCan.AgentAccount(a.account)),b=0;b0)for(b.member=[],c=0;c0))for(c=0;c0)if("0.9"===a||"0.95"===a)this[e[b]].length>1&&this.log("[warning] version does not support multiple values in: "+e[b]),d[e[b]]=this[e[b]][0].asVersion(a);else for(d[e[b]]=[],c=0;c0){if("0.9"===a||"0.95"===a)throw this.log("[error] version does not support the 'category' property: "+a),new Error(a+" does not support the 'category' property"); +for(d.category=[],b=0;b>>0;if("function"!=typeof a)throw new TypeError;var d,e=arguments[1];for(d=0;d=200&&f<400||e?b.callback?void b.callback(null,a):d={err:null,xhr:a}:(d={err:f,xhr:a},0===f?log("[warning] There was a problem communicating with the Learning Record Store. Aborted, offline, or invalid CORS endpoint ("+f+")",LOG_SRC):log("[warning] There was a problem communicating with the Learning Record Store. ("+f+" | "+a.responseText+")",LOG_SRC),b.callback&&b.callback(f,a),d))},__IEModeConversion=function(a,b,c,d){var e;for(e in b)b.hasOwnProperty(e)&&c.push(e+"="+encodeURIComponent(b[e]));return"undefined"!=typeof d.data&&c.push("content="+encodeURIComponent(d.data)),b["Content-Type"]="application/x-www-form-urlencoded",a+="?method="+d.method,d.method="POST",d.params={},c.length>0&&(d.data=c.join("&")),a},nativeRequest=function(a,b,c){log("sendRequest using XMLHttpRequest",LOG_SRC);var d,e,f,g,h=this,i=[],j={finished:!1,fakeStatus:null},k="undefined"!=typeof c.callback,l=a,m=2048;log("sendRequest using XMLHttpRequest - async: "+k,LOG_SRC);for(e in c.params)c.params.hasOwnProperty(e)&&i.push(e+"="+encodeURIComponent(c.params[e]));if(i.length>0&&(l+="?"+i.join("&")),l.length>=m){if("undefined"==typeof c.method)return g=new Error("method must not be undefined for an IE Mode Request conversion"),"undefined"!=typeof c.callback&&c.callback(g,null),{err:g,xhr:null};a=__IEModeConversion(a,b,i,c)}else a=l;if("undefined"!=typeof XMLHttpRequest)d=new XMLHttpRequest;else if(d=new ActiveXObject("Microsoft.XMLHTTP"),c.expectMultipart)return g=new Error("Attachment support not available"),"undefined"!=typeof c.callback&&c.callback(g,null),{err:g,xhr:null};d.open(c.method,a,k),c.expectMultipart&&(d.responseType="arraybuffer");for(e in b)b.hasOwnProperty(e)&&d.setRequestHeader(e,b[e]);f=c.data,k&&(d.onreadystatechange=function(){log("xhr.onreadystatechange - xhr.readyState: "+d.readyState,LOG_SRC),4===d.readyState&&requestComplete.call(h,d,c,j)});try{d.send(f)}catch(a){log("sendRequest caught send exception: "+a,LOG_SRC)}return k?d:requestComplete.call(this,d,c,j)},xdrRequest=function(a,b,c){log("sendRequest using XDomainRequest",LOG_SRC);var d,e,f,g,h,i=this,j=[],k={finished:!1,fakeStatus:null};if(c.expectMultipart)return h=new Error("Attachment support not available"),"undefined"!=typeof c.callback&&c.callback(h,null),{err:h,xhr:null};a+="?method="+c.method;for(f in c.params)c.params.hasOwnProperty(f)&&j.push(f+"="+encodeURIComponent(c.params[f]));for(f in b)b.hasOwnProperty(f)&&j.push(f+"="+encodeURIComponent(b[f]));"undefined"!=typeof c.data&&j.push("content="+encodeURIComponent(c.data)),e=j.join("&"),d=new XDomainRequest,d.open("POST",a),c.callback?(d.onload=function(){k.fakeStatus=200,requestComplete.call(i,d,c,k)},d.onerror=function(){k.fakeStatus=400,requestComplete.call(i,d,c,k)},d.ontimeout=function(){k.fakeStatus=0,requestComplete.call(i,d,c,k)}):(d.onload=function(){k.fakeStatus=200},d.onerror=function(){k.fakeStatus=400},d.ontimeout=function(){k.fakeStatus=0}),d.onprogress=function(){},d.timeout=0;try{d.send(e)}catch(a){log("sendRequest caught send exception: "+a,LOG_SRC)}if(!c.callback){for(g=1e4+Date.now(),log("sendRequest - until: "+g+", finished: "+k.finished,LOG_SRC);Date.now()>0}function g(a){return a>>>0}function h(b){function c(a){Object.defineProperty(b,a,{get:function(){return b._getter(a)},set:function(c){b._setter(a,c)},enumerable:!0,configurable:!1})}if(!("TYPED_ARRAY_POLYFILL_NO_ARRAY_ACCESSORS"in a)){if(b.length>E)throw RangeError("Array too large for polyfill");var d;for(d=0;d>c}function j(a,b){var c=32-b;return a<>>c}function k(a){return[255&a]}function l(a){return i(a[0],8)}function m(a){return[255&a]}function n(a){return j(a[0],8)}function o(a){return a=M(Number(a)),[a<0?0:a>255?255:255&a]}function p(a){return[255&a,a>>8&255]}function q(a){return i(a[1]<<8|a[0],16)}function r(a){return[255&a,a>>8&255]}function s(a){return j(a[1]<<8|a[0],16)}function t(a){return[255&a,a>>8&255,a>>16&255,a>>24&255]}function u(a){return i(a[3]<<24|a[2]<<16|a[1]<<8|a[0],32)}function v(a){return[255&a,a>>8&255,a>>16&255,a>>24&255]}function w(a){return j(a[3]<<24|a[2]<<16|a[1]<<8|a[0],32)}function x(a,b,c){function d(a){var b=H(a),c=a-b;return c<.5?b:c>.5?b+1:b%2?b+1:b}var e,f,g,h=(1<=L(2,1-h)){f=K(H(I(a)/F),1023);var i=a/L(2,f);i<1&&(f-=1,i*=2),i>=2&&(f+=1,i/=2);var j=L(2,c);g=d(i*j)-j,f+=h,g/j>=1&&(f+=1,g=0),f>2*h&&(f=(1<>=1;return l.reverse(),g=l.join(""),h=(1<0?i*L(2,j-h)*(1+k/L(2,c)):0!==k?i*L(2,-(h-1))*(k/L(2,c)):i<0?-0:0}function z(a){return y(a,11,52)}function A(a){return x(a,11,52)}function B(a){return y(a,8,23)}function C(a){return x(a,8,23)}var D=void 0,E=1e5,F=Math.LN2,G=Math.abs,H=Math.floor,I=Math.log,J=Math.max,K=Math.min,L=Math.pow,M=Math.round;!function(){var a=Object.defineProperty,b=!function(){try{return Object.defineProperty({},"x",{})}catch(a){return!1}}();a&&!b||(Object.defineProperty=function(b,c,d){if(a)try{return a(b,c,d)}catch(a){}if(b!==Object(b))throw TypeError("Object.defineProperty called on non-object");return Object.prototype.__defineGetter__&&"get"in d&&Object.prototype.__defineGetter__.call(b,c,d.get),Object.prototype.__defineSetter__&&"set"in d&&Object.prototype.__defineSetter__.call(b,c,d.set),"value"in d&&(b[c]=d.value),b})}(),function(){function i(a){if(a=f(a),a<0)throw RangeError("ArrayBuffer size is not a small enough positive integer.");Object.defineProperty(this,"byteLength",{value:a}),Object.defineProperty(this,"_bytes",{value:Array(a)});for(var b=0;b=1&&"object"===b(arguments[0])&&arguments[0]instanceof j)return function(a){if(this.constructor!==a.constructor)throw TypeError();var b=a.length*this.BYTES_PER_ELEMENT;Object.defineProperty(this,"buffer",{value:new i(b)}),Object.defineProperty(this,"byteLength",{value:b}),Object.defineProperty(this,"byteOffset",{value:0}),Object.defineProperty(this,"length",{value:a.length});for(var c=0;c=1&&"object"===b(arguments[0])&&!(arguments[0]instanceof j)&&!(arguments[0]instanceof i||"ArrayBuffer"===c(arguments[0])))return function(a){var b=a.length*this.BYTES_PER_ELEMENT;Object.defineProperty(this,"buffer",{value:new i(b)}),Object.defineProperty(this,"byteLength",{value:b}),Object.defineProperty(this,"byteOffset",{value:0}),Object.defineProperty(this,"length",{value:a.length});for(var c=0;c=1&&"object"===b(arguments[0])&&(arguments[0]instanceof i||"ArrayBuffer"===c(arguments[0])))return function(a,b,c){if(b=g(b),b>a.byteLength)throw RangeError("byteOffset out of range");if(b%this.BYTES_PER_ELEMENT)throw RangeError("buffer length minus the byteOffset is not a multiple of the element size.");if(c===D){var d=a.byteLength-b;if(d%this.BYTES_PER_ELEMENT)throw RangeError("length of buffer minus byteOffset not a multiple of the element size");c=d/this.BYTES_PER_ELEMENT}else c=g(c),d=c*this.BYTES_PER_ELEMENT;if(b+d>a.byteLength)throw RangeError("byteOffset and length reference an area beyond the end of the buffer");Object.defineProperty(this,"buffer",{value:a}),Object.defineProperty(this,"byteLength",{value:d}),Object.defineProperty(this,"byteOffset",{value:b}),Object.defineProperty(this,"length",{value:c})}.apply(this,arguments);throw TypeError()}function x(a,b,c){var d=function(){Object.defineProperty(this,"constructor",{value:d}),j.apply(this,arguments),h(this)};"__proto__"in d?d.__proto__=j:(d.from=j.from,d.of=j.of),d.BYTES_PER_ELEMENT=a;var e=function(){};return e.prototype=y,d.prototype=new e,Object.defineProperty(d.prototype,"BYTES_PER_ELEMENT",{value:a}),Object.defineProperty(d.prototype,"_pack",{value:b}),Object.defineProperty(d.prototype,"_unpack",{value:c}),d}a.ArrayBuffer=a.ArrayBuffer||i,Object.defineProperty(j,"from",{value:function(a){return new this(a)}}),Object.defineProperty(j,"of",{value:function(){return new this(arguments)}});var y={};j.prototype=y,Object.defineProperty(j.prototype,"_getter",{value:function(a){if(arguments.length<1)throw SyntaxError("Not enough arguments");if(a=g(a),a>=this.length)return D;var b,c,d=[];for(b=0,c=this.byteOffset+a*this.BYTES_PER_ELEMENT;b=this.length)){var c,d,e=this._pack(b);for(c=0,d=this.byteOffset+a*this.BYTES_PER_ELEMENT;c0;)d._setter(j,d._getter(l)),l+=p,j+=p,q-=1;return d}}),Object.defineProperty(j.prototype,"every",{value:function(a){if(this===D||null===this)throw TypeError();var b=Object(this),c=g(b.length);if(!d(a))throw TypeError();for(var e=arguments[1],f=0;f1?arguments[1]:D,i=0;i1?arguments[1]:D,i=0;i0&&(d=Number(arguments[1]),d!==d?d=0:0!==d&&d!==1/0&&d!==-(1/0)&&(d=(d>0||-1)*H(G(d)))),d>=c)return-1;for(var e=d>=0?d:J(c-G(d),0);e1&&(d=Number(arguments[1]),d!==d?d=0:0!==d&&d!==1/0&&d!==-(1/0)&&(d=(d>0||-1)*H(G(d))));for(var e=d>=0?K(d,c-1):c-G(d);e>=0;e--)if(b._getter(e)===a)return e; +return-1}}),Object.defineProperty(j.prototype,"map",{value:function(a){if(this===D||null===this)throw TypeError();var b=Object(this),c=g(b.length);if(!d(a))throw TypeError();var e=[];e.length=c;for(var f=arguments[1],h=0;h=2?arguments[1]:b._getter(f++);f=2?arguments[1]:b._getter(f--);f>=0;)e=a.call(D,e,b._getter(f),f,b),f--;return e}}),Object.defineProperty(j.prototype,"reverse",{value:function(){if(this===D||null===this)throw TypeError();for(var a=Object(this),b=g(a.length),c=H(b/2),d=0,e=b-1;dthis.length)throw RangeError("Offset plus length of array is out of range");if(k=this.byteOffset+e*this.BYTES_PER_ELEMENT,l=c.length*this.BYTES_PER_ELEMENT,c.buffer===this.buffer){for(m=[],h=0,i=c.byteOffset;hthis.length)throw RangeError("Offset plus length of array is out of range");for(h=0;hc?c:a}a=f(a),b=f(b),arguments.length<1&&(a=0),arguments.length<2&&(b=this.length),a<0&&(a=this.length+a),b<0&&(b=this.length+b),a=c(a,0,this.length),b=c(b,0,this.length);var d=b-a;return d<0&&(d=0),new this.constructor(this.buffer,this.byteOffset+a*this.BYTES_PER_ELEMENT,d)}});var E=x(1,k,l),F=x(1,m,n),I=x(1,o,n),L=x(2,p,q),M=x(2,r,s),N=x(4,t,u),O=x(4,v,w),P=x(4,C,B),Q=x(8,A,z);a.Int8Array=a.Int8Array||E,a.Uint8Array=a.Uint8Array||F,a.Uint8ClampedArray=a.Uint8ClampedArray||I,a.Int16Array=a.Int16Array||L,a.Uint16Array=a.Uint16Array||M,a.Int32Array=a.Int32Array||N,a.Uint32Array=a.Uint32Array||O,a.Float32Array=a.Float32Array||P,a.Float64Array=a.Float64Array||Q}(),function(){function b(a,b){return d(a.get)?a.get(b):a[b]}function e(a,b,d){if(!(a instanceof ArrayBuffer||"ArrayBuffer"===c(a)))throw TypeError();if(b=g(b),b>a.byteLength)throw RangeError("byteOffset out of range");if(d=d===D?a.byteLength-b:g(d),b+d>a.byteLength)throw RangeError("byteOffset and length reference an area beyond the end of the buffer");Object.defineProperty(this,"buffer",{value:a}),Object.defineProperty(this,"byteLength",{value:d}),Object.defineProperty(this,"byteOffset",{value:b})}function f(a){return function(c,d){if(c=g(c),c+a.BYTES_PER_ELEMENT>this.byteLength)throw RangeError("Array index out of range");c+=this.byteOffset;for(var e=new Uint8Array(this.buffer,c,a.BYTES_PER_ELEMENT),f=[],h=0;hthis.byteLength)throw RangeError("Array index out of range");var f,h,j=new a([d]),k=new Uint8Array(j.buffer),l=[];for(f=0;fg)return new ArrayBuffer(0);var h=g-f,i=new ArrayBuffer(h),j=new Uint8Array(i),k=new Uint8Array(this,f,h);return j.set(k),i})}(),"undefined"!=typeof module&&module.exports&&(this["encoding-indexes"]=require("./encoding-indexes.js")["encoding-indexes"]),function(a){"use strict";function b(a,b,c){return b<=a&&a<=c}function c(a,b){return a.indexOf(b)!==-1}function d(a){if(void 0===a)return{};if(a===Object(a))return a;throw TypeError("Could not convert argument to dictionary")}function e(a){for(var b=String(a),c=b.length,d=0,e=[];d57343)e.push(f);else if(56320<=f&&f<=57343)e.push(65533);else if(55296<=f&&f<=56319)if(d===c-1)e.push(65533);else{var g=a.charCodeAt(d+1);if(56320<=g&&g<=57343){var h=1023&f,i=1023&g;e.push(65536+(h<<10)+i),d+=1}else e.push(65533)}d+=1}return e}function f(a){for(var b="",c=0;c>10)+55296,(1023&d)+56320))}return b}function g(a){return 0<=a&&a<=127}function h(a){this.tokens=[].slice.call(a),this.tokens.reverse()}function i(a,b){if(a)throw TypeError("Decoder error");return b||65533}function j(a){throw TypeError("The code point "+a+" could not be encoded.")}function k(){}function l(){}function m(a){return a=String(a).trim().toLowerCase(),Object.prototype.hasOwnProperty.call(W,a)?W[a]:null}function n(a,b){return b?b[a]||null:null}function o(a,b){var c=b.indexOf(a);return c===-1?null:c}function p(b){if(!("encoding-indexes"in a))throw Error("Indexes missing. Did you forget to include encoding-indexes.js?");return a["encoding-indexes"][b]}function q(a){if(a>39419&&a<189e3||a>1237575)return null;if(7457===a)return 59335;var b,c=0,d=0,e=p("gb18030");for(b=0;b>6*d)+e];d>0;){var g=c>>6*(d-1);f.push(128|63&g),d-=1}return f}}function y(a,b){var c=b.fatal;this.handler=function(b,d){if(d===T)return U;if(g(d))return d;var e=a[d-128];return null===e?i(c):e}}function z(a,b){b.fatal;this.handler=function(b,c){if(c===T)return U;if(S(c))return c;var d=o(c,a);return null===d&&j(c),d+128}}function A(a){var c=a.fatal,d=0,e=0,f=0;this.handler=function(a,h){if(h===T&&0===d&&0===e&&0===f)return U;h!==T||0===d&&0===e&&0===f||(d=0,e=0,f=0,i(c));var j;if(0!==f){j=null,b(h,48,57)&&(j=q(10*(126*(10*(d-129)+(e-48))+(f-129))+h-48));var k=[e,f,h];return d=0,e=0,f=0,null===j?(a.prepend(k),i(c)):j}if(0!==e)return b(h,129,254)?(f=h,null):(a.prepend([e,h]),d=0,e=0,i(c));if(0!==d){if(b(h,48,57))return e=h,null;var l=d,m=null;d=0;var o=h<127?64:65;return(b(h,64,126)||b(h,128,254))&&(m=190*(l-129)+(h-o)),j=null===m?null:n(m,p("gb18030")),null===j&&g(h)&&a.prepend(h),null===j?i(c):j}return g(h)?h:128===h?8364:b(h,129,254)?(d=h,null):i(c)}}function B(a,b){a.fatal;this.handler=function(a,c){if(c===T)return U;if(S(c))return c;if(58853===c)return j(c);if(b&&8364===c)return 128;var d=o(c,p("gb18030"));if(null!==d){var e=R(d/190)+129,f=d%190,g=f<63?64:65;return[e,f+g]}if(b)return j(c);d=r(c);var h=R(d/10/126/10);d-=10*h*126*10;var i=R(d/10/126);d-=10*i*126;var k=R(d/10),l=d-10*k;return[h+129,i+48,k+129,l+48]}}function C(a){var c=a.fatal,d=0;this.handler=function(a,e){if(e===T&&0!==d)return d=0,i(c);if(e===T&&0===d)return U;if(0!==d){var f=d,h=null;d=0;var j=e<127?64:98;switch((b(e,64,126)||b(e,161,254))&&(h=157*(f-129)+(e-j)),h){case 1133:return[202,772];case 1135:return[202,780];case 1164:return[234,772];case 1166:return[234,780]}var k=null===h?null:n(h,p("big5"));return null===k&&g(e)&&a.prepend(e),null===k?i(c):k}return g(e)?e:b(e,129,254)?(d=e,null):i(c)}}function D(a){a.fatal;this.handler=function(a,b){if(b===T)return U;if(S(b))return b;var c=t(b);if(null===c)return j(b);var d=R(c/157)+129;if(d<161)return j(b);var e=c%157,f=e<63?64:98;return[d,e+f]}}function E(a){var c=a.fatal,d=!1,e=0;this.handler=function(a,f){if(f===T&&0!==e)return e=0,i(c);if(f===T&&0===e)return U;if(142===e&&b(f,161,223))return e=0,65377+f-161;if(143===e&&b(f,161,254))return d=!0,e=f,null;if(0!==e){var h=e;e=0;var j=null;return b(h,161,254)&&b(f,161,254)&&(j=n(94*(h-161)+(f-161),p(d?"jis0212":"jis0208"))),d=!1,b(f,161,254)||a.prepend(f),null===j?i(c):j}return g(f)?f:142===f||143===f||b(f,161,254)?(e=f,null):i(c)}}function F(a){a.fatal;this.handler=function(a,c){if(c===T)return U;if(S(c))return c;if(165===c)return 92;if(8254===c)return 126;if(b(c,65377,65439))return[142,c-65377+161];8722===c&&(c=65293);var d=o(c,p("jis0208"));if(null===d)return j(c);var e=R(d/94)+161,f=d%94+161;return[e,f]}}function G(a){var c=a.fatal,d={ASCII:0,Roman:1,Katakana:2,LeadByte:3,TrailByte:4,EscapeStart:5,Escape:6},e=d.ASCII,f=d.ASCII,g=0,h=!1;this.handler=function(a,j){switch(e){default:case d.ASCII:return 27===j?(e=d.EscapeStart,null):b(j,0,127)&&14!==j&&15!==j&&27!==j?(h=!1,j):j===T?U:(h=!1,i(c));case d.Roman:return 27===j?(e=d.EscapeStart,null):92===j?(h=!1,165):126===j?(h=!1,8254):b(j,0,127)&&14!==j&&15!==j&&27!==j&&92!==j&&126!==j?(h=!1,j):j===T?U:(h=!1,i(c));case d.Katakana:return 27===j?(e=d.EscapeStart,null):b(j,33,95)?(h=!1,65377+j-33):j===T?U:(h=!1,i(c));case d.LeadByte:return 27===j?(e=d.EscapeStart,null):b(j,33,126)?(h=!1,g=j,e=d.TrailByte,null):j===T?U:(h=!1,i(c));case d.TrailByte:if(27===j)return e=d.EscapeStart,i(c);if(b(j,33,126)){e=d.LeadByte;var k=94*(g-33)+j-33,l=n(k,p("jis0208"));return null===l?i(c):l}return j===T?(e=d.LeadByte,a.prepend(j),i(c)):(e=d.LeadByte,i(c));case d.EscapeStart:return 36===j||40===j?(g=j,e=d.Escape,null):(a.prepend(j),h=!1,e=f,i(c));case d.Escape:var m=g;g=0;var o=null;if(40===m&&66===j&&(o=d.ASCII),40===m&&74===j&&(o=d.Roman),40===m&&73===j&&(o=d.Katakana),36!==m||64!==j&&66!==j||(o=d.LeadByte),null!==o){e=e=o;var q=h;return h=!0,q?i(c):null}return a.prepend([m,j]),h=!1,e=f,i(c)}}}function H(a){var b=(a.fatal,{ASCII:0,Roman:1,jis0208:2}),c=b.ASCII;this.handler=function(a,d){if(d===T&&c!==b.ASCII)return a.prepend(d),c=b.ASCII,[27,40,66];if(d===T&&c===b.ASCII)return U;if(!(c!==b.ASCII&&c!==b.Roman||14!==d&&15!==d&&27!==d))return j(65533);if(c===b.ASCII&&S(d))return d;if(c===b.Roman&&(S(d)&&92!==d&&126!==d||165==d||8254==d)){if(S(d))return d;if(165===d)return 92;if(8254===d)return 126}if(S(d)&&c!==b.ASCII)return a.prepend(d),c=b.ASCII,[27,40,66];if((165===d||8254===d)&&c!==b.Roman)return a.prepend(d),c=b.Roman,[27,40,74];8722===d&&(d=65293);var e=o(d,p("jis0208"));if(null===e)return j(d);if(c!==b.jis0208)return a.prepend(d),c=b.jis0208,[27,36,66];var f=R(e/94)+33,g=e%94+33;return[f,g]}}function I(a){var c=a.fatal,d=0;this.handler=function(a,e){if(e===T&&0!==d)return d=0,i(c);if(e===T&&0===d)return U;if(0!==d){var f=d,h=null;d=0;var j=e<127?64:65,k=f<160?129:193;(b(e,64,126)||b(e,128,252))&&(h=188*(f-k)+e-j);var l=null===h?null:n(h,p("jis0208"));return null===l&&null!==h&&b(h,8836,10528)?57344+h-8836:(null===l&&g(e)&&a.prepend(e),null===l?i(c):l)}return g(e)||128===e?e:b(e,161,223)?65377+e-161:b(e,129,159)||b(e,224,252)?(d=e,null):i(c)}}function J(a){a.fatal;this.handler=function(a,c){if(c===T)return U;if(S(c)||128===c)return c;if(165===c)return 92;if(8254===c)return 126;if(b(c,65377,65439))return c-65377+161;8722===c&&(c=65293);var d=s(c);if(null===d)return j(c);var e=R(d/188),f=e<31?129:193,g=d%188,h=g<63?64:65;return[e+f,g+h]}}function K(a){var c=a.fatal,d=0;this.handler=function(a,e){if(e===T&&0!==d)return d=0,i(c);if(e===T&&0===d)return U;if(0!==d){var f=d,h=null;d=0,b(e,65,254)&&(h=190*(f-129)+(e-65));var j=null===h?null:n(h,p("euc-kr"));return null===h&&g(e)&&a.prepend(e),null===j?i(c):j}return g(e)?e:b(e,129,254)?(d=e,null):i(c)}}function L(a){a.fatal;this.handler=function(a,b){if(b===T)return U;if(S(b))return b;var c=o(b,p("euc-kr"));if(null===c)return j(b);var d=R(c/190)+129,e=c%190+65;return[d,e]}}function M(a,b){var c=a>>8,d=255&a;return b?[c,d]:[d,c]}function N(a,c){var d=c.fatal,e=null,f=null;this.handler=function(c,g){if(g===T&&(null!==e||null!==f))return i(d);if(g===T&&null===e&&null===f)return U;if(null===e)return e=g,null;var h;if(h=a?(e<<8)+g:(g<<8)+e,e=null,null!==f){var j=f;return f=null,b(h,56320,57343)?65536+1024*(j-55296)+(h-56320):(c.prepend(M(h,a)),i(d))}return b(h,55296,56319)?(f=h,null):b(h,56320,57343)?i(d):h}}function O(a,c){c.fatal;this.handler=function(c,d){if(d===T)return U;if(b(d,0,65535))return M(d,a);var e=M((d-65536>>10)+55296,a),f=M((d-65536&1023)+56320,a);return e.concat(f)}}function P(a){a.fatal;this.handler=function(a,b){return b===T?U:g(b)?b:63360+b-128}}function Q(a){a.fatal;this.handler=function(a,c){return c===T?U:S(c)?c:b(c,63360,63487)?c-63360+128:j(c)}}var R=Math.floor,S=g,T=-1;h.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.pop():T},prepend:function(a){if(Array.isArray(a))for(var b=a;b.length;)this.tokens.push(b.pop());else this.tokens.push(a)},push:function(a){if(Array.isArray(a))for(var b=a;b.length;)this.tokens.unshift(b.shift());else this.tokens.unshift(a)}};var U=-1;k.prototype={handler:function(a,b){}},l.prototype={handler:function(a,b){}};var V=[{encodings:[{labels:["unicode-1-1-utf-8","utf-8","utf8"],name:"UTF-8"}],heading:"The Encoding"},{encodings:[{labels:["866","cp866","csibm866","ibm866"],name:"IBM866"},{labels:["csisolatin2","iso-8859-2","iso-ir-101","iso8859-2","iso88592","iso_8859-2","iso_8859-2:1987","l2","latin2"],name:"ISO-8859-2"},{labels:["csisolatin3","iso-8859-3","iso-ir-109","iso8859-3","iso88593","iso_8859-3","iso_8859-3:1988","l3","latin3"],name:"ISO-8859-3"},{labels:["csisolatin4","iso-8859-4","iso-ir-110","iso8859-4","iso88594","iso_8859-4","iso_8859-4:1988","l4","latin4"],name:"ISO-8859-4"},{labels:["csisolatincyrillic","cyrillic","iso-8859-5","iso-ir-144","iso8859-5","iso88595","iso_8859-5","iso_8859-5:1988"],name:"ISO-8859-5"},{labels:["arabic","asmo-708","csiso88596e","csiso88596i","csisolatinarabic","ecma-114","iso-8859-6","iso-8859-6-e","iso-8859-6-i","iso-ir-127","iso8859-6","iso88596","iso_8859-6","iso_8859-6:1987"],name:"ISO-8859-6"},{labels:["csisolatingreek","ecma-118","elot_928","greek","greek8","iso-8859-7","iso-ir-126","iso8859-7","iso88597","iso_8859-7","iso_8859-7:1987","sun_eu_greek"],name:"ISO-8859-7"},{labels:["csiso88598e","csisolatinhebrew","hebrew","iso-8859-8","iso-8859-8-e","iso-ir-138","iso8859-8","iso88598","iso_8859-8","iso_8859-8:1988","visual"],name:"ISO-8859-8"},{labels:["csiso88598i","iso-8859-8-i","logical"],name:"ISO-8859-8-I"},{labels:["csisolatin6","iso-8859-10","iso-ir-157","iso8859-10","iso885910","l6","latin6"],name:"ISO-8859-10"},{labels:["iso-8859-13","iso8859-13","iso885913"],name:"ISO-8859-13"},{labels:["iso-8859-14","iso8859-14","iso885914"],name:"ISO-8859-14"},{labels:["csisolatin9","iso-8859-15","iso8859-15","iso885915","iso_8859-15","l9"],name:"ISO-8859-15"},{labels:["iso-8859-16"],name:"ISO-8859-16"},{labels:["cskoi8r","koi","koi8","koi8-r","koi8_r"],name:"KOI8-R"},{labels:["koi8-ru","koi8-u"],name:"KOI8-U"},{labels:["csmacintosh","mac","macintosh","x-mac-roman"],name:"macintosh"},{labels:["dos-874","iso-8859-11","iso8859-11","iso885911","tis-620","windows-874"],name:"windows-874"},{labels:["cp1250","windows-1250","x-cp1250"],name:"windows-1250"},{labels:["cp1251","windows-1251","x-cp1251"],name:"windows-1251"},{labels:["ansi_x3.4-1968","ascii","cp1252","cp819","csisolatin1","ibm819","iso-8859-1","iso-ir-100","iso8859-1","iso88591","iso_8859-1","iso_8859-1:1987","l1","latin1","us-ascii","windows-1252","x-cp1252"],name:"windows-1252"},{labels:["cp1253","windows-1253","x-cp1253"],name:"windows-1253"},{labels:["cp1254","csisolatin5","iso-8859-9","iso-ir-148","iso8859-9","iso88599","iso_8859-9","iso_8859-9:1989","l5","latin5","windows-1254","x-cp1254"],name:"windows-1254"},{labels:["cp1255","windows-1255","x-cp1255"],name:"windows-1255"},{labels:["cp1256","windows-1256","x-cp1256"],name:"windows-1256"},{labels:["cp1257","windows-1257","x-cp1257"],name:"windows-1257"},{labels:["cp1258","windows-1258","x-cp1258"],name:"windows-1258"},{labels:["x-mac-cyrillic","x-mac-ukrainian"],name:"x-mac-cyrillic"}],heading:"Legacy single-byte encodings"},{encodings:[{labels:["chinese","csgb2312","csiso58gb231280","gb2312","gb_2312","gb_2312-80","gbk","iso-ir-58","x-gbk"],name:"GBK"},{labels:["gb18030"],name:"gb18030"}],heading:"Legacy multi-byte Chinese (simplified) encodings"},{encodings:[{labels:["big5","big5-hkscs","cn-big5","csbig5","x-x-big5"],name:"Big5"}],heading:"Legacy multi-byte Chinese (traditional) encodings"},{encodings:[{labels:["cseucpkdfmtjapanese","euc-jp","x-euc-jp"],name:"EUC-JP"},{labels:["csiso2022jp","iso-2022-jp"],name:"ISO-2022-JP"},{labels:["csshiftjis","ms932","ms_kanji","shift-jis","shift_jis","sjis","windows-31j","x-sjis"],name:"Shift_JIS"}],heading:"Legacy multi-byte Japanese encodings"},{encodings:[{labels:["cseuckr","csksc56011987","euc-kr","iso-ir-149","korean","ks_c_5601-1987","ks_c_5601-1989","ksc5601","ksc_5601","windows-949"],name:"EUC-KR"}],heading:"Legacy multi-byte Korean encodings"},{encodings:[{labels:["csiso2022kr","hz-gb-2312","iso-2022-cn","iso-2022-cn-ext","iso-2022-kr"],name:"replacement"},{labels:["utf-16be"],name:"UTF-16BE"},{labels:["utf-16","utf-16le"],name:"UTF-16LE"},{labels:["x-user-defined"],name:"x-user-defined"}],heading:"Legacy miscellaneous encodings"}],W={};V.forEach(function(a){a.encodings.forEach(function(a){a.labels.forEach(function(b){W[b]=a})})});var X={},Y={},Z="utf-8";Object.defineProperty&&(Object.defineProperty(u.prototype,"encoding",{get:function(){return this._encoding.name.toLowerCase()}}),Object.defineProperty(u.prototype,"fatal",{get:function(){return"fatal"===this._error_mode}}),Object.defineProperty(u.prototype,"ignoreBOM",{get:function(){return this._ignoreBOM}})),u.prototype.decode=function(a,b){function e(a){return!c(["UTF-8","UTF-16LE","UTF-16BE"],this._encoding.name)||this._ignoreBOM||this._BOMseen||(a.length>0&&65279===a[0]?(this._BOMseen=!0,a.shift()):a.length>0&&(this._BOMseen=!0)),f(a)}var g;g="object"==typeof a&&a instanceof ArrayBuffer?new Uint8Array(a):"object"==typeof a&&"buffer"in a&&a.buffer instanceof ArrayBuffer?new Uint8Array(a.buffer,a.byteOffset,a.byteLength):new Uint8Array(0),b=d(b),this._do_not_flush||(this._decoder=Y[this._encoding.name]({fatal:"fatal"===this._error_mode}),this._BOMseen=!1),this._do_not_flush=Boolean(b.stream);for(var i,j=new h(g),k=[];;){var l=j.read();if(l===T)break;if(i=this._decoder.handler(j,l),i===U)break;null!==i&&(Array.isArray(i)?k.push.apply(k,i):k.push(i))}if(!this._do_not_flush){do{if(i=this._decoder.handler(j,j.read()),i===U)break;null!==i&&(Array.isArray(i)?k.push.apply(k,i):k.push(i))}while(!j.endOfStream());this._decoder=null}return e.call(this,k)},Object.defineProperty&&Object.defineProperty(v.prototype,"encoding",{get:function(){return this._encoding.name.toLowerCase()}}),v.prototype.encode=function(a,b){a=a?String(a):"",b=d(b),this._do_not_flush||(this._encoder=X[this._encoding.name]({fatal:"fatal"===this._fatal})),this._do_not_flush=Boolean(b.stream);for(var c,f=new h(e(a)),g=[];;){var i=f.read();if(i===T)break;if(c=this._encoder.handler(f,i),c===U)break;Array.isArray(c)?g.push.apply(g,c):g.push(c)}if(!this._do_not_flush){for(;;){if(c=this._encoder.handler(f,f.read()),c===U)break;Array.isArray(c)?g.push.apply(g,c):g.push(c)}this._encoder=null}return new Uint8Array(g)},X["UTF-8"]=function(a){return new x(a)},Y["UTF-8"]=function(a){return new w(a)},function(){"encoding-indexes"in a&&V.forEach(function(a){"Legacy single-byte encodings"===a.heading&&a.encodings.forEach(function(a){var b=a.name,c=p(b.toLowerCase());Y[b]=function(a){return new y(c,a)},X[b]=function(a){return new z(c,a)}})})}(),Y.GBK=function(a){return new A(a)},X.GBK=function(a){return new B(a,!0)},X.gb18030=function(a){return new B(a)},Y.gb18030=function(a){return new A(a)},X.Big5=function(a){return new D(a)},Y.Big5=function(a){return new C(a)},X["EUC-JP"]=function(a){return new F(a)},Y["EUC-JP"]=function(a){return new E(a)},X["ISO-2022-JP"]=function(a){return new H(a)},Y["ISO-2022-JP"]=function(a){return new G(a)},X.Shift_JIS=function(a){return new J(a)},Y.Shift_JIS=function(a){return new I(a)},X["EUC-KR"]=function(a){return new L(a)},Y["EUC-KR"]=function(a){return new K(a)},X["UTF-16BE"]=function(a){return new O(!0,a)},Y["UTF-16BE"]=function(a){return new N(!0,a)},X["UTF-16LE"]=function(a){return new O(!1,a)},Y["UTF-16LE"]=function(a){return new N(!1,a)},X["x-user-defined"]=function(a){return new Q(a)},Y["x-user-defined"]=function(a){return new P(a)},a.TextEncoder||(a.TextEncoder=v),a.TextDecoder||(a.TextDecoder=u),"undefined"!=typeof module&&module.exports&&(module.exports={TextEncoder:a.TextEncoder,TextDecoder:a.TextDecoder,EncodingIndexes:a["encoding-indexes"]})}(this); //# sourceMappingURL=tincan-min.map \ No newline at end of file diff --git a/build/tincan-min.map b/build/tincan-min.map index 2162009..979116c 100644 --- a/build/tincan-min.map +++ b/build/tincan-min.map @@ -1 +1 @@ -{"version":3,"file":"tincan-min.js","sources":["tincan.js"],"names":["CryptoJS","i","m","p","h","lib","n","Base","a","extend","b","prototype","this","c","mixIn","$super","create","init","apply","arguments","hasOwnProperty","toString","clone","o","WordArray","words","sigBytes","length","e","stringify","concat","d","clamp","f","push","ceil","call","slice","random","q","enc","Hex","join","parse","parseInt","substr","g","Latin1","String","fromCharCode","charCodeAt","j","Utf8","decodeURIComponent","escape","Error","unescape","encodeURIComponent","k","BufferedBlockAlgorithm","reset","_data","_nDataBytes","_append","_process","blockSize","max","_minBufferSize","min","_doProcessBlock","splice","Hasher","_doReset","update","finalize","_doFinalize","_hash","_createHelper","_createHmacHelper","l","HMAC","algo","Math","SHA1","HmacSHA1","C","C_lib","C_enc","Base64","wordArray","map","_map","base64Chars","byte1","byte2","byte3","triplet","charAt","paddingChar","base64Str","replace","base64StrLength","paddingIndex","indexOf","nBytes","bitsHigh","bitsLow","TinCan","_reservedQSParams","statementId","voidedStatementId","verb","object","registration","context","actor","since","until","limit","authoritative","sparse","instructor","ascending","continueToken","agent","activityId","stateId","profileId","activity_platform","grouping","Accept-Language","cfg","log","recordStores","activity","LOG_SRC","msg","src","DEBUG","console","url","_initFromQueryString","undefined","addRecordStore","Activity","Agent","Context","prop","contextCfg","qsParams","Utils","parseURL","params","lrsProps","lrsCfg","extended","fromJSON","ex","id","activity_id","platform","contextActivities","allowFail","lrs","LRS","prepareStatement","stmt","Statement","target","parent","other","sendStatement","callback","callbackWrapper","self","statement","rsCount","results","callbackResults","err","xhr","args","saveStatement","getStatement","stmtId","retrieveStatement","voidStatement","options","voidingStatement","objectType","getVoidedStatement","retrieveVoidedStatement","sendStatements","stmts","statements","saveStatements","getStatements","queryCfg","sendActor","version","sendActivity","queryStatements","getState","key","retrieveState","setState","val","lastSHA1","contentType","overwriteJSON","isApplicationJSON","method","saveState","deleteState","dropState","getActivityProfile","retrieveActivityProfile","setActivityProfile","saveActivityProfile","deleteActivityProfile","dropActivityProfile","getAgentProfile","retrieveAgentProfile","setAgentProfile","saveAgentProfile","deleteAgentProfile","dropAgentProfile","enableDebug","disableDebug","versions","module","exports","getUUID","r","v","getISODateString","pad","padder","tempVal","pow","getUTCFullYear","getUTCMonth","getUTCDate","getUTCHours","getUTCMinutes","getUTCSeconds","getUTCMilliseconds","convertISO8601DurationToMilliseconds","ISO8601Duration","hours","minutes","seconds","durationInMilliseconds","isValueNegative","indexOfT","indexOfH","indexOfM","indexOfS","parseFloat","isNaN","convertMillisecondsToISO8601Duration","inputMilliseconds","i_inputCentiseconds","i_inputMilliseconds","inputIsNegative","rtnStr","round","getSHA1String","str","getBase64String","getLangDictionaryValue","lang","langDict","und","reURLInformation","match","result","paramMatch","isRelative","_reURLInformation","pl","search","decode","s","allowRelative","unshift","RegExp","protocol","host","hostname","port","path","pathname","hash","exec","substring","getServerRoot","absoluteUrl","urlParts","split","getContentTypeFromHeader","header","toLowerCase","endpoint","auth","versionMatch","code","mesg","username","password","_initByEnvironment","_makeRequest","_IEModeConversion","sendRequest","fullUrl","headers","Authorization","about","requestCfg","requestResult","About","responseText","versionedStatement","asVersion","data","JSON","Content-Type","versionedStatements","_queryStatementsRequestCfg","statementsResult","StatementsResult","config","returnCfg","jsonProps","idProps","valProps","universal","compatibility","0.9","supported","1.0.0","related_activities","related_agents","format","attachments","moreStatements","parsedURL","serverRoot","requestHeaders","requestParams","registrationId","ignore404","status","State","contents","etag","getResponseHeader","state","retrieveStateIds","profileIds","retrieveActivity","ActivityProfile","profile","retrieveActivityProfileIds","AgentProfile","retrieveAgentProfileIds","syncEnabled","AgentAccount","homePage","name","directProps","accountServiceHomePage","accountName","acctJSON","_acct","mbox","mbox_sha1sum","openid","account","degraded","lastName","firstName","familyName","givenName","agentJSON","_agent","Group","member","groupJSON","_group","_downConvertMap","http://adlnet.gov/expapi/verbs/experienced","http://adlnet.gov/expapi/verbs/attended","http://adlnet.gov/expapi/verbs/attempted","http://adlnet.gov/expapi/verbs/completed","http://adlnet.gov/expapi/verbs/passed","http://adlnet.gov/expapi/verbs/failed","http://adlnet.gov/expapi/verbs/answered","http://adlnet.gov/expapi/verbs/interacted","http://adlnet.gov/expapi/verbs/imported","http://adlnet.gov/expapi/verbs/created","http://adlnet.gov/expapi/verbs/shared","http://adlnet.gov/expapi/verbs/voided","Verb","display","verbJSON","_verb","Result","score","success","completion","duration","response","extensions","Score","optionalDirectProps","optionalObjProps","resultJSON","_result","scaled","raw","scoreJSON","_score","InteractionComponent","description","icJSON","_ic","http://adlnet.gov/expapi/activities/course","http://adlnet.gov/expapi/activities/module","http://adlnet.gov/expapi/activities/meeting","http://adlnet.gov/expapi/activities/media","http://adlnet.gov/expapi/activities/performance","http://adlnet.gov/expapi/activities/simulation","http://adlnet.gov/expapi/activities/assessment","http://adlnet.gov/expapi/activities/interaction","http://adlnet.gov/expapi/activities/cmi.interaction","http://adlnet.gov/expapi/activities/question","http://adlnet.gov/expapi/activities/objective","http://adlnet.gov/expapi/activities/link","ActivityDefinition","type","moreInfo","interactionType","correctResponsesPattern","choices","scale","source","steps","interactionComponentProps","definitionJSON","_definition","definition","defString","activityJSON","_activity","ContextActivities","category","objProps","Object","add","contextActivitiesJSON","_contextActivities","team","revision","language","agentGroupProps","StatementRef","SubStatement","contextJSON","_context","stRefJSON","_stRef","timestamp","subStJSON","_subSt","initCfg","storeOriginal","doStamp","stored","authority","voided","inProgress","originalJSON","stamp","Date","stJSON","_st","more","parseError","error","updated","stateJSON","_state","aboutJSON","_about","nativeRequest","xdrRequest","requestComplete","__delay","__IEModeConversion","env","window","sJSON","eval","vContent","nId","sProp","sOutput","constructor","Array","now","hasCORS","useXDR","XMLHttpRequest","withCredentials","XDomainRequest","control","finished","requestCompleteResult","notFoundOk","httpStatus","fakeStatus","pairs","async","fullRequest","MAX_REQUEST_LENGTH","ActiveXObject","open","setRequestHeader","onreadystatechange","readyState","send","onload","onerror","ontimeout","onprogress","timeout","schemeMatches","locationPort","isXD","location"],"mappings":"AAAA,QAOA,IAAIA,UAASA,UAAU,SAASC,EAAEC,GAAG,GAAIC,MAAKC,EAAED,EAAEE,OAAOC,EAAEF,EAAEG,KAAK,WAAW,QAASC,MAAK,OAAOC,OAAO,SAASC,GAAGF,EAAEG,UAAUC,IAAK,IAAIC,GAAE,GAAIL,EAA8B,OAA5BE,IAAGG,EAAEC,MAAMJ,GAAGG,EAAEE,OAAOH,KAAYC,GAAGG,OAAO,WAAW,GAAIR,GAAEI,KAAKH,QAAmC,OAA1BD,GAAES,KAAKC,MAAMV,EAAEW,WAAkBX,GAAGS,KAAK,aAAaH,MAAM,SAASN,GAAG,IAAI,GAAIK,KAAKL,GAAEA,EAAEY,eAAeP,KAAKD,KAAKC,GAAGL,EAAEK,GAAIL,GAAEY,eAAe,cAAcR,KAAKS,SAASb,EAAEa,WAAWC,MAAM,WAAW,MAAOV,MAAKG,OAAON,OAAOG,WAAWW,EAAEnB,EAAEoB,UAAUlB,EAAEG,QAAQQ,KAAK,SAAST,EAAEE,GAAGF,EACpfI,KAAKa,MAAMjB,MAAMI,KAAKc,SAAShB,GAAGR,EAAEQ,EAAE,EAAEF,EAAEmB,QAAQN,SAAS,SAASb,GAAG,OAAOA,GAAGoB,GAAGC,UAAUjB,OAAOkB,OAAO,SAAStB,GAAG,GAAIE,GAAEE,KAAKa,MAAMZ,EAAEL,EAAEiB,MAAMM,EAAEnB,KAAKc,SAASlB,EAAEA,EAAEkB,QAAsB,IAAbd,KAAKoB,QAAWD,EAAE,EAAE,IAAI,GAAIE,GAAE,EAAIzB,EAAFyB,EAAIA,IAAIvB,EAAEqB,E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E,SAAS7P,SAASe,cAA4B,KAA4C,WAApC8O,SAAS7P,SAASe,cAA6B,MAAQ,IAGjI6O,GAEMF,GAGCG,SAAS3P,SAASa,gBAAkBJ,EAAS,IAG7CgP,KACkB,OAAhBhP,EAAS,IAAsC,mBAAhBA,GAAS,IAAsC,KAAhBA,EAAS,GAAaA,EAAS,GAAsB,UAAhBA,EAAS,GAAiB,KAAwB,WAAhBA,EAAS,GAAkB,MAAQ,IAI7K,GAAI0M,IAAIW,SACJ,GAAIX,IAAIY,QAAUyB,EACd7gB,KAAK2S,aAAeyL,eAEnB,IAAII,IAAIY,SAAYyB,EAAe,CACpC,IAAItZ,EAAI+B,UAKJ,KADA9B,KAAI,gFAAiFG,UAEjF2K,KAAM,EACNC,KAAM,wEANV/K,KAAI,oGAAqGG,cAWhH,CACD,IAAIJ,EAAI+B,UAKJ,KADA9B,KAAI,2EAA4EG,UAE5E2K,KAAM,EACNC,KAAM,mEANV/K,KAAI,+FAAgGG,WAoBpH2W,QAAU,WASN,GAAI9T,GAAM,GAAI6U,gBACVrX,EAAMyW,OAAOuC,SAAW,iBAAmBjb,OAAO2C,MAAMkF,SAE5DpD,GAAI2V,KAAK,MAAOnY,GAAK,GACrBwC,EAAI+V,KAAK,YAMbxa,OAAOyD,IAAI0M,aAAc"} \ No newline at end of file +{"version":3,"sources":["tincan.js"],"names":["CryptoJS","e","m","p","j","lib","l","f","Base","extend","a","prototype","this","c","mixIn","hasOwnProperty","init","$super","apply","arguments","create","toString","clone","n","WordArray","words","sigBytes","length","h","stringify","concat","q","d","clamp","b","push","ceil","call","slice","random","enc","Hex","join","parse","parseInt","substr","g","Latin1","String","fromCharCode","charCodeAt","r","Utf8","decodeURIComponent","escape","Error","unescape","encodeURIComponent","k","BufferedBlockAlgorithm","reset","_data","_nDataBytes","_append","_process","blockSize","max","_minBufferSize","min","_doProcessBlock","splice","Hasher","cfg","_doReset","update","finalize","_doFinalize","_createHelper","_createHmacHelper","s","HMAC","algo","Math","SHA1","_hash","floor","HmacSHA1","t","u","v","x","w","sqrt","pow","SHA256","HmacSHA256","C","C_lib","C_enc","Base64","wordArray","map","_map","base64Chars","i","byte1","byte2","byte3","triplet","charAt","paddingChar","base64Str","base64StrLength","paddingIndex","indexOf","nBytes","bits1","bits2","ArrayBuffer","superInit","subInit","typedArray","Uint8Array","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","buffer","byteOffset","byteLength","typedArrayByteLength","TinCan","_reservedQSParams","statementId","voidedStatementId","verb","object","registration","context","actor","since","until","limit","authoritative","sparse","instructor","ascending","continueToken","agent","activityId","stateId","profileId","activity_platform","grouping","Accept-Language","log","recordStores","activity","LOG_SRC","msg","src","DEBUG","console","url","_initFromQueryString","undefined","addRecordStore","Activity","Agent","Context","prop","contextCfg","qsParams","Utils","parseURL","params","lrsProps","lrsCfg","extended","fromJSON","ex","id","activity_id","platform","contextActivities","allowFail","lrs","LRS","prepareStatement","stmt","Statement","target","parent","other","sendStatement","callback","callbackWrapper","self","statement","rsCount","results","callbackResults","err","xhr","args","saveStatement","getStatement","stmtId","retrieveStatement","voidStatement","options","voidingStatement","objectType","getVoidedStatement","retrieveVoidedStatement","sendStatements","stmts","statements","saveStatements","getStatements","queryCfg","sendActor","version","sendActivity","queryStatements","getState","key","retrieveState","setState","val","lastSHA1","contentType","overwriteJSON","isApplicationJSON","method","saveState","deleteState","dropState","getActivityProfile","retrieveActivityProfile","setActivityProfile","saveActivityProfile","deleteActivityProfile","dropActivityProfile","getAgentProfile","retrieveAgentProfile","setAgentProfile","saveAgentProfile","deleteAgentProfile","dropAgentProfile","enableDebug","disableDebug","versions","module","exports","defaultEncoding","getUUID","replace","getISODateString","pad","padder","tempVal","getUTCFullYear","getUTCMonth","getUTCDate","getUTCHours","getUTCMinutes","getUTCSeconds","getUTCMilliseconds","convertISO8601DurationToMilliseconds","ISO8601Duration","hours","minutes","seconds","durationInMilliseconds","isValueNegative","indexOfT","indexOfH","indexOfM","indexOfS","parseFloat","isNaN","convertMillisecondsToISO8601Duration","inputMilliseconds","i_inputCentiseconds","i_inputMilliseconds","inputIsNegative","rtnStr","round","getSHA1String","str","getSHA256String","content","Object","getBase64String","getLangDictionaryValue","lang","langDict","und","reURLInformation","match","result","paramMatch","isRelative","_reURLInformation","pl","search","decode","allowRelative","unshift","RegExp","protocol","host","hostname","port","path","pathname","hash","exec","substring","getServerRoot","absoluteUrl","urlParts","split","getContentTypeFromHeader","header","toLowerCase","stringToArrayBuffer","stringFromArrayBuffer","endpoint","auth","versionMatch","code","mesg","username","password","_initByEnvironment","_getBoundary","_makeRequest","_getMultipartRequestData","_IEModeConversion","_processGetStatementResult","boundary","parsedResponse","attachmentMap","attachments","responseText","getResponseHeader","_parseMultipart","response","JSON","body","headers","_assignAttachmentContent","sendRequest","fullUrl","Authorization","about","requestCfg","requestResult","About","versionedStatement","requestAttachments","asVersion","hasAttachmentWithContent","data","expectMultipart","versionedStatements","_queryStatementsRequestCfg","statementsResult","StatementsResult","config","returnCfg","jsonProps","idProps","valProps","universal","compatibility","0.9","supported","1.0.0","related_activities","related_agents","format","sha2","byteArray","bodyEncodedInString","fullBodyEnd","sliceStart","sliceEnd","headerStart","headerEnd","bodyStart","bodyEnd","__boundary","parts","CRLF","__uint8ToString","_parseHeaders","len","rawHeaders","headerList","moreStatements","parsedURL","serverRoot","requestHeaders","requestParams","registrationId","ignore404","status","State","contents","etag","state","retrieveStateIds","profileIds","retrieveActivity","ActivityProfile","profile","retrieveActivityProfileIds","AgentProfile","retrieveAgentProfileIds","syncEnabled","AgentAccount","homePage","name","directProps","accountServiceHomePage","accountName","acctJSON","_acct","mbox","mbox_sha1sum","openid","account","degraded","lastName","firstName","familyName","givenName","agentJSON","_agent","Group","member","groupJSON","_group","_downConvertMap","http://adlnet.gov/expapi/verbs/experienced","http://adlnet.gov/expapi/verbs/attended","http://adlnet.gov/expapi/verbs/attempted","http://adlnet.gov/expapi/verbs/completed","http://adlnet.gov/expapi/verbs/passed","http://adlnet.gov/expapi/verbs/failed","http://adlnet.gov/expapi/verbs/answered","http://adlnet.gov/expapi/verbs/interacted","http://adlnet.gov/expapi/verbs/imported","http://adlnet.gov/expapi/verbs/created","http://adlnet.gov/expapi/verbs/shared","http://adlnet.gov/expapi/verbs/voided","Verb","display","verbJSON","_verb","Result","score","success","completion","duration","extensions","Score","optionalDirectProps","optionalObjProps","resultJSON","_result","scaled","raw","scoreJSON","_score","InteractionComponent","description","icJSON","_ic","http://adlnet.gov/expapi/activities/course","http://adlnet.gov/expapi/activities/module","http://adlnet.gov/expapi/activities/meeting","http://adlnet.gov/expapi/activities/media","http://adlnet.gov/expapi/activities/performance","http://adlnet.gov/expapi/activities/simulation","http://adlnet.gov/expapi/activities/assessment","http://adlnet.gov/expapi/activities/interaction","http://adlnet.gov/expapi/activities/cmi.interaction","http://adlnet.gov/expapi/activities/question","http://adlnet.gov/expapi/activities/objective","http://adlnet.gov/expapi/activities/link","ActivityDefinition","type","moreInfo","interactionType","correctResponsesPattern","choices","scale","source","steps","interactionComponentProps","definitionJSON","_definition","definition","defString","activityJSON","_activity","ContextActivities","category","objProps","add","contextActivitiesJSON","_contextActivities","team","revision","language","agentGroupProps","StatementRef","SubStatement","contextJSON","_context","stRefJSON","_stRef","timestamp","subStJSON","_subSt","initCfg","storeOriginal","doStamp","stored","authority","voided","inProgress","originalJSON","Attachment","stamp","Date","stJSON","_st","more","parseError","error","updated","stateJSON","_state","aboutJSON","_about","usageType","fileUrl","setContentFromString","setContent","_content","getContentAsString","attachmentJSON","_attachment","_defaultEncoding","requestComplete","__IEModeConversion","nativeRequest","xdrRequest","__createJSONSegment","__createAttachmentSegment","__delay","env","window","sJSON","eval","vContent","nId","sProp","sOutput","constructor","Array","now","forEach","fun","TypeError","thisp","hasCORS","useXDR","XMLHttpRequest","withCredentials","XDomainRequest","control","finished","requestCompleteResult","notFoundOk","httpStatus","fakeStatus","pairs","async","fullRequest","MAX_REQUEST_LENGTH","ActiveXObject","open","responseType","setRequestHeader","onreadystatechange","readyState","send","onload","onerror","ontimeout","onprogress","timeout","schemeMatches","locationPort","isXD","location","jsonContent","Blob","blobParts","encoding","encoder","TextEncoder","encode","decoder","TextDecoder","global","Type","Class","IsCallable","o","ToObject","ToInt32","ToUint32","makeArrayAccessors","obj","makeArrayAccessor","index","defineProperty","get","_getter","set","_setter","enumerable","configurable","MAX_ARRAY_LENGTH","RangeError","as_signed","value","bits","as_unsigned","packI8","unpackI8","bytes","packU8","unpackU8","packU8Clamped","Number","packI16","unpackI16","packU16","unpackU16","packI32","unpackI32","packU32","unpackU32","packIEEE754","ebits","fbits","roundToEven","bias","Infinity","abs","LN2","significand","reverse","unpackIEEE754","NaN","unpackF64","packF64","unpackF32","packF32","orig","dom_only","_","desc","__defineGetter__","__defineSetter__","_bytes","$TypedArray$","BYTES_PER_ELEMENT","array","makeTypedArray","elementSize","pack","unpack","TypedArray","__proto__","from","of","TypedArrayPrototype","$TypedArrayPrototype$","iterable","SyntaxError","_unpack","_pack","start","end","lenVal","to","relativeTarget","relativeStart","relativeEnd","final","direction","count","callbackfn","thisArg","res","predicate","lenValue","kValue","testResult","Boolean","searchElement","separator","tmp","accumulator","half","sequence","offset","comparefn","sort","DataView","makeGetter","arrayType","littleEndian","uint8Array","IS_BIG_ENDIAN","makeSetter","byteView","typeArray","u16array","u8array","begin","num","targetArray","sourceArray","require","inRange","includes","item","ToDictionary","stringToCodePoints","string","codePointsToString","code_points","cp","isASCIIByte","Stream","tokens","decoderError","fatal","opt_code_point","encoderError","code_point","Decoder","Encoder","getEncoding","label","trim","label_to_encoding","indexCodePointFor","pointer","indexPointerFor","indexGB18030RangesCodePointFor","code_point_offset","idx","entry","indexGB18030RangesPointerFor","pointer_offset","indexShiftJISPointerFor","indexBig5PointerFor","index_","lastIndexOf","DEFAULT_ENCODING","_encoding","_decoder","_ignoreBOM","_BOMseen","_error_mode","_do_not_flush","decoders","dec","ignoreBOM","_encoder","_fatal","encoders","warn","UTF8Decoder","utf8_code_point","utf8_bytes_seen","utf8_bytes_needed","utf8_lower_boundary","utf8_upper_boundary","handler","stream","bite","end_of_stream","prepend","UTF8Encoder","temp","SingleByteDecoder","SingleByteEncoder","isASCIICodePoint","GB18030Decoder","gb18030_first","gb18030_second","gb18030_third","lead","GB18030Encoder","gbk_flag","trail","byte4","Big5Decoder","big5_lead","Big5Encoder","EUCJPDecoder","eucjp_jis0212_flag","eucjp_lead","EUCJPEncoder","ISO2022JPDecoder","states","ASCII","Roman","Katakana","LeadByte","TrailByte","EscapeStart","Escape","iso2022jp_decoder_state","iso2022jp_decoder_output_state","iso2022jp_lead","iso2022jp_output_flag","output_flag","ISO2022JPEncoder","jis0208","iso2022jp_state","ShiftJISDecoder","shiftjis_lead","lead_offset","ShiftJISEncoder","EUCKRDecoder","euckr_lead","EUCKREncoder","convertCodeUnitToBytes","code_unit","utf16be","UTF16Decoder","utf16_be","utf16_lead_byte","utf16_lead_surrogate","lead_surrogate","UTF16Encoder","XUserDefinedDecoder","XUserDefinedEncoder","endOfStream","read","pop","token","isArray","shift","encodings","labels","heading","input","serializeStream","input_stream","output","opt_string","EncodingIndexes"],"mappings":"AAAA,QAOA,IAAIA,UAASA,UAAU,SAASC,EAAEC,GAAG,GAAIC,MAAKC,EAAED,EAAEE,OAAOC,EAAE,aAAaC,EAAEH,EAAEI,MAAMC,OAAO,SAASC,GAAGJ,EAAEK,UAAUC,IAAK,IAAIC,GAAE,GAAIP,EAAoI,OAAlII,IAAGG,EAAEC,MAAMJ,GAAGG,EAAEE,eAAe,UAAUF,EAAEG,KAAK,WAAWH,EAAEI,OAAOD,KAAKE,MAAMN,KAAKO,aAAaN,EAAEG,KAAKL,UAAUE,EAAEA,EAAEI,OAAOL,KAAYC,GAAGO,OAAO,WAAW,GAAIV,GAAEE,KAAKH,QAAmC,OAA1BC,GAAEM,KAAKE,MAAMR,EAAES,WAAkBT,GAAGM,KAAK,aAAaF,MAAM,SAASJ,GAAG,IAAI,GAAIG,KAAKH,GAAE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,WAQNyxB,QAAS,SAASC,EAAQC,MAK5BxC,EAAQnvB,WAMNyxB,QAAS,SAASC,EAAQzC,KAiC5B,IAAI2G,KAEAA,YAEIC,QACE,oBACA,QACA,QAEF3b,KAAQ,UAGZ4b,QAAW,iBAGXF,YAEIC,QACE,MACA,QACA,WACA,UAEF3b,KAAQ,WAGR2b,QACE,cACA,aACA,aACA,YACA,WACA,aACA,kBACA,KACA,UAEF3b,KAAQ,eAGR2b,QACE,cACA,aACA,aACA,YACA,WACA,aACA,kBACA,KACA,UAEF3b,KAAQ,eAGR2b,QACE,cACA,aACA,aACA,YACA,WACA,aACA,kBACA,KACA,UAEF3b,KAAQ,eAGR2b,QACE,qBACA,WACA,aACA,aACA,YACA,WACA,aACA,mBAEF3b,KAAQ,eAGR2b,QACE,SACA,WACA,cACA,cACA,mBACA,WACA,aACA,eACA,eACA,aACA,YACA,WACA,aACA,mBAEF3b,KAAQ,eAGR2b,QACE,kBACA,WACA,WACA,QACA,SACA,aACA,aACA,YACA,WACA,aACA,kBACA,gBAEF3b,KAAQ,eAGR2b,QACE,cACA,mBACA,SACA,aACA,eACA,aACA,YACA,WACA,aACA,kBACA,UAEF3b,KAAQ,eAGR2b,QACE,cACA,eACA,WAEF3b,KAAQ,iBAGR2b,QACE,cACA,cACA,aACA,aACA,YACA,KACA,UAEF3b,KAAQ,gBAGR2b,QACE,cACA,aACA,aAEF3b,KAAQ,gBAGR2b,QACE,cACA,aACA,aAEF3b,KAAQ,gBAGR2b,QACE,cACA,cACA,aACA,YACA,cACA,MAEF3b,KAAQ,gBAGR2b,QACE,eAEF3b,KAAQ,gBAGR2b,QACE,UACA,MACA,OACA,SACA,UAEF3b,KAAQ,WAGR2b,QACE,UACA,UAEF3b,KAAQ,WAGR2b,QACE,cACA,MACA,YACA,eAEF3b,KAAQ,cAGR2b,QACE,UACA,cACA,aACA,YACA,UACA,eAEF3b,KAAQ,gBAGR2b,QACE,SACA,eACA,YAEF3b,KAAQ,iBAGR2b,QACE,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9BikB,EAAS,eAAiB,SAASjkB,GACjC,MAAO,IAAIwmB,GAAiBxmB,IA4K9BskB,EAAoB,UAAI,SAAStkB,GAC/B,MAAO,IAAI4nB,GAAgB5nB,IAG7BikB,EAAoB,UAAI,SAASjkB,GAC/B,MAAO,IAAIynB,GAAgBznB,IAmI7BskB,EAAS,UAAY,SAAStkB,GAC5B,MAAO,IAAI+nB,GAAa/nB,IAG1BikB,EAAS,UAAY,SAASjkB,GAC5B,MAAO,IAAI6nB,GAAa7nB,IA2K1BskB,EAAS,YAAc,SAAStkB,GAC9B,MAAO,IAAIwoB,IAAa,EAAMxoB,IAIhCikB,EAAS,YAAc,SAASjkB,GAC9B,MAAO,IAAImoB,IAAa,EAAMnoB,IAMhCskB,EAAS,YAAc,SAAStkB,GAC9B,MAAO,IAAIwoB,IAAa,EAAOxoB,IAIjCikB,EAAS,YAAc,SAASjkB,GAC9B,MAAO,IAAImoB,IAAa,EAAOnoB,IAqEjCskB,EAAS,kBAAoB,SAAStkB,GACpC,MAAO,IAAI0oB,GAAoB1oB,IAGjCikB,EAAS,kBAAoB,SAASjkB,GACpC,MAAO,IAAIyoB,GAAoBzoB,IAG5B2Z,EAAoB,cACvBA,EAAoB,YAAIJ,GACrBI,EAAoB,cACvBA,EAAoB,YAAID,GAEJ,mBAAX/W,SAA0BA,OAAOC,UAC1CD,OAAOC,SACL2W,YAAaI,EAAoB,YACjCD,YAAaC,EAAoB,YACjC8P,gBAAiB9P,EAAO,uBAG5BrmB","file":"tincan-min.js"} \ No newline at end of file diff --git a/build/tincan-node.js b/build/tincan-node.js index 9e53d86..aee79fe 100644 --- a/build/tincan-node.js +++ b/build/tincan-node.js @@ -1,23 +1,41 @@ -"0.41.1"; +"0.50.0"; /* -CryptoJS v3.0.2 +CryptoJS v3.1.2 code.google.com/p/crypto-js -(c) 2009-2012 by Jeff Mott. All rights reserved. +(c) 2009-2013 by Jeff Mott. All rights reserved. code.google.com/p/crypto-js/wiki/License */ -var CryptoJS=CryptoJS||function(i,m){var p={},h=p.lib={},n=h.Base=function(){function a(){}return{extend:function(b){a.prototype=this;var c=new a;b&&c.mixIn(b);c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.$super.extend(this)}}}(),o=h.WordArray=n.extend({init:function(a,b){a= -this.words=a||[];this.sigBytes=b!=m?b:4*a.length},toString:function(a){return(a||e).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes,a=a.sigBytes;this.clamp();if(d%4)for(var f=0;f>>2]|=(c[f>>>2]>>>24-8*(f%4)&255)<<24-8*((d+f)%4);else if(65535>>2]=c[f>>>2];else b.push.apply(b,c);this.sigBytes+=a;return this},clamp:function(){var a=this.words,b=this.sigBytes;a[b>>>2]&=4294967295<<32-8*(b%4);a.length=i.ceil(b/4)},clone:function(){var a= -n.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var b=[],c=0;c>>2]>>>24-8*(d%4)&255;c.push((f>>>4).toString(16));c.push((f&15).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return o.create(c,b/2)}},g=q.Latin1={stringify:function(a){for(var b= -a.words,a=a.sigBytes,c=[],d=0;d>>2]>>>24-8*(d%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>2]|=(a.charCodeAt(d)&255)<<24-8*(d%4);return o.create(c,b)}},j=q.Utf8={stringify:function(a){try{return decodeURIComponent(escape(g.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return g.parse(unescape(encodeURIComponent(a)))}},k=h.BufferedBlockAlgorithm=n.extend({reset:function(){this._data=o.create(); -this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var b=this._data,c=b.words,d=b.sigBytes,f=this.blockSize,e=d/(4*f),e=a?i.ceil(e):i.max((e|0)-this._minBufferSize,0),a=e*f,d=i.min(4*a,d);if(a){for(var g=0;gb;b++){if(16>b)h[b]=o[i+b]|0;else{var c=h[b-3]^h[b-8]^h[b-14]^h[b-16];h[b]=c<<1|c>>>31}c=(g<<5|g>>>27)+a+h[b];c=20>b?c+((j&k|~j&l)+1518500249):40>b?c+((j^k^l)+1859775393):60>b?c+((j&k|j&l|k&l)-1894007588):c+((j^k^l)- -899497514);a=l;l=k;k=j<<30|j>>>2;j=g;g=c}e[0]=e[0]+g|0;e[1]=e[1]+j|0;e[2]=e[2]+k|0;e[3]=e[3]+l|0;e[4]=e[4]+a|0},_doFinalize:function(){var i=this._data,h=i.words,e=8*this._nDataBytes,g=8*i.sigBytes;h[g>>>5]|=128<<24-g%32;h[(g+64>>>9<<4)+15]=e;i.sigBytes=4*h.length;this._process()}});i.SHA1=m._createHelper(n);i.HmacSHA1=m._createHmacHelper(n)})(); +var CryptoJS=CryptoJS||function(e,m){var p={},j=p.lib={},l=function(){},f=j.Base={extend:function(a){l.prototype=this;var c=new l;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}}, +n=j.WordArray=f.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=m?c:4*a.length},toString:function(a){return(a||h).stringify(this)},concat:function(a){var c=this.words,q=a.words,d=this.sigBytes;a=a.sigBytes;this.clamp();if(d%4)for(var b=0;b>>2]|=(q[b>>>2]>>>24-8*(b%4)&255)<<24-8*((d+b)%4);else if(65535>>2]=q[b>>>2];else c.push.apply(c,q);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<< +32-8*(c%4);a.length=e.ceil(c/4)},clone:function(){var a=f.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],b=0;b>>2]>>>24-8*(d%4)&255;b.push((f>>>4).toString(16));b.push((f&15).toString(16))}return b.join("")},parse:function(a){for(var c=a.length,b=[],d=0;d>>3]|=parseInt(a.substr(d, +2),16)<<24-4*(d%8);return new n.init(b,c/2)}},g=b.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var b=[],d=0;d>>2]>>>24-8*(d%4)&255));return b.join("")},parse:function(a){for(var c=a.length,b=[],d=0;d>>2]|=(a.charCodeAt(d)&255)<<24-8*(d%4);return new n.init(b,c)}},r=b.Utf8={stringify:function(a){try{return decodeURIComponent(escape(g.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return g.parse(unescape(encodeURIComponent(a)))}}, +k=j.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new n.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=r.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,b=c.words,d=c.sigBytes,f=this.blockSize,h=d/(4*f),h=a?e.ceil(h):e.max((h|0)-this._minBufferSize,0);a=h*f;d=e.min(4*a,d);if(a){for(var g=0;ga;a++){if(16>a)l[a]=f[n+a]|0;else{var c=l[a-3]^l[a-8]^l[a-14]^l[a-16];l[a]=c<<1|c>>>31}c=(h<<5|h>>>27)+j+l[a];c=20>a?c+((g&e|~g&k)+1518500249):40>a?c+((g^e^k)+1859775393):60>a?c+((g&e|g&k|e&k)-1894007588):c+((g^e^ +k)-899497514);j=k;k=e;e=g<<30|g>>>2;g=h;h=c}b[0]=b[0]+h|0;b[1]=b[1]+g|0;b[2]=b[2]+e|0;b[3]=b[3]+k|0;b[4]=b[4]+j|0},_doFinalize:function(){var f=this._data,e=f.words,b=8*this._nDataBytes,h=8*f.sigBytes;e[h>>>5]|=128<<24-h%32;e[(h+64>>>9<<4)+14]=Math.floor(b/4294967296);e[(h+64>>>9<<4)+15]=b;f.sigBytes=4*e.length;this._process();return this._hash},clone:function(){var e=j.clone.call(this);e._hash=this._hash.clone();return e}});e.SHA1=j._createHelper(m);e.HmacSHA1=j._createHmacHelper(m)})(); /* -CryptoJS v3.0.2 +CryptoJS v3.1.2 code.google.com/p/crypto-js -(c) 2009-2012 by Jeff Mott. All rights reserved. +(c) 2009-2013 by Jeff Mott. All rights reserved. +code.google.com/p/crypto-js/wiki/License +*/ +var CryptoJS=CryptoJS||function(h,s){var f={},t=f.lib={},g=function(){},j=t.Base={extend:function(a){g.prototype=this;var c=new g;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}}, +q=t.WordArray=j.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=s?c:4*a.length},toString:function(a){return(a||u).stringify(this)},concat:function(a){var c=this.words,d=a.words,b=this.sigBytes;a=a.sigBytes;this.clamp();if(b%4)for(var e=0;e>>2]|=(d[e>>>2]>>>24-8*(e%4)&255)<<24-8*((b+e)%4);else if(65535>>2]=d[e>>>2];else c.push.apply(c,d);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<< +32-8*(c%4);a.length=h.ceil(c/4)},clone:function(){var a=j.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],d=0;d>>2]>>>24-8*(b%4)&255;d.push((e>>>4).toString(16));d.push((e&15).toString(16))}return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>3]|=parseInt(a.substr(b, +2),16)<<24-4*(b%8);return new q.init(d,c/2)}},k=v.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b>>2]>>>24-8*(b%4)&255));return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>2]|=(a.charCodeAt(b)&255)<<24-8*(b%4);return new q.init(d,c)}},l=v.Utf8={stringify:function(a){try{return decodeURIComponent(escape(k.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return k.parse(unescape(encodeURIComponent(a)))}}, +x=t.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new q.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=l.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,d=c.words,b=c.sigBytes,e=this.blockSize,f=b/(4*e),f=a?h.ceil(f):h.max((f|0)-this._minBufferSize,0);a=f*e;b=h.min(4*a,b);if(a){for(var m=0;mk;){var l;a:{l=u;for(var x=h.sqrt(l),w=2;w<=x;w++)if(!(l%w)){l=!1;break a}l=!0}l&&(8>k&&(j[k]=v(h.pow(u,0.5))),q[k]=v(h.pow(u,1/3)),k++);u++}var a=[],f=f.SHA256=g.extend({_doReset:function(){this._hash=new t.init(j.slice(0))},_doProcessBlock:function(c,d){for(var b=this._hash.words,e=b[0],f=b[1],m=b[2],h=b[3],p=b[4],j=b[5],k=b[6],l=b[7],n=0;64>n;n++){if(16>n)a[n]= +c[d+n]|0;else{var r=a[n-15],g=a[n-2];a[n]=((r<<25|r>>>7)^(r<<14|r>>>18)^r>>>3)+a[n-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+a[n-16]}r=l+((p<<26|p>>>6)^(p<<21|p>>>11)^(p<<7|p>>>25))+(p&j^~p&k)+q[n]+a[n];g=((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&f^e&m^f&m);l=k;k=j;j=p;p=h+r|0;h=m;m=f;f=e;e=r+g|0}b[0]=b[0]+e|0;b[1]=b[1]+f|0;b[2]=b[2]+m|0;b[3]=b[3]+h|0;b[4]=b[4]+p|0;b[5]=b[5]+j|0;b[6]=b[6]+k|0;b[7]=b[7]+l|0},_doFinalize:function(){var a=this._data,d=a.words,b=8*this._nDataBytes,e=8*a.sigBytes; +d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=h.floor(b/4294967296);d[(e+64>>>9<<4)+15]=b;a.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var a=g.clone.call(this);a._hash=this._hash.clone();return a}});s.SHA256=g._createHelper(f);s.HmacSHA256=g._createHmacHelper(f)})(Math); + +/* +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 () { @@ -92,9 +110,6 @@ code.google.com/p/crypto-js/wiki/License * var wordArray = CryptoJS.enc.Base64.parse(base64String); */ parse: function (base64Str) { - // Ignore whitespaces - base64Str = base64Str.replace(/\s/g, ''); - // Shortcuts var base64StrLength = base64Str.length; var map = this._map; @@ -113,9 +128,9 @@ code.google.com/p/crypto-js/wiki/License var nBytes = 0; for (var i = 0; i < base64StrLength; i++) { if (i % 4) { - var bitsHigh = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2); - var bitsLow = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2); - words[nBytes >>> 2] |= (bitsHigh | bitsLow) << (24 - (nBytes % 4) * 8); + var bits1 = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2); + var bits2 = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2); + words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8); nBytes++; } } @@ -127,6 +142,69 @@ 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_lib = C.lib; + var WordArray = C_lib.WordArray; + + // Reference original init + var superInit = WordArray.init; + + // Augment WordArray.init to handle typed arrays + var subInit = WordArray.init = function (typedArray) { + // Convert buffers to uint8 + if (typedArray instanceof ArrayBuffer) { + typedArray = new Uint8Array(typedArray); + } + + // Convert other array views to uint8 + if ( + typedArray instanceof Int8Array || + typedArray instanceof Uint8ClampedArray || + typedArray instanceof Int16Array || + typedArray instanceof Uint16Array || + typedArray instanceof Int32Array || + typedArray instanceof Uint32Array || + typedArray instanceof Float32Array || + typedArray instanceof Float64Array + ) { + typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength); + } + + // Handle Uint8Array + if (typedArray instanceof Uint8Array) { + // Shortcut + var typedArrayByteLength = typedArray.byteLength; + + // Extract bytes + var words = []; + for (var i = 0; i < typedArrayByteLength; i++) { + words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8); + } + + // Initialize this word array + superInit.call(this, words, typedArrayByteLength); + } else { + // Else call normal init + superInit.apply(this, arguments); + } + }; + + subInit.prototype = WordArray; +}()); + /*! Copyright 2012 Rustici Software @@ -577,17 +655,23 @@ var TinCan; Calls retrieveStatement on the first LRS, provide callback to make it asynchronous @method getStatement - @param {String} statement Statement ID to get + @param {String} [stmtId] Statement ID to get @param {Function} [callback] Callback function to execute on completion + @param {Object} [cfg] Configuration data + @param {Object} [params] Query parameters + @param {Boolean} [attachments] Include attachments in multipart response or don't (defualt: false) @return {Array|Result} Array of results, or single result TODO: make TinCan track statements it has seen in a local cache to be returned easily */ - getStatement: function (stmtId, callback) { + getStatement: function (stmtId, callback, cfg) { this.log("getStatement"); var lrs; + cfg = cfg || {}; + cfg.params = cfg.params || {}; + if (this.recordStores.length > 0) { // // for statements (for now) we only need to read from the first LRS @@ -600,7 +684,7 @@ var TinCan; // lrs = this.recordStores[0]; - return lrs.retrieveStatement(stmtId, { callback: callback }); + return lrs.retrieveStatement(stmtId, { callback: callback, params: cfg.params }); } this.log("[warning] getStatement: No LRSs added yet (statement not retrieved)"); @@ -1428,6 +1512,8 @@ TinCan client library @class TinCan.Utils */ TinCan.Utils = { + defaultEncoding: "utf8", + /** Generates a UUIDv4 compliant string that should be reasonably unique @@ -1593,6 +1679,21 @@ TinCan client library return CryptoJS.SHA1(str).toString(CryptoJS.enc.Hex); }, + /** + @method getSHA256String + @static + @param {ArrayBuffer|String} content Content to hash + @return {String} SHA256 for contents + */ + getSHA256String: function (content) { + /*global CryptoJS*/ + + if (Object.prototype.toString.call(content) === "[object ArrayBuffer]") { + content = CryptoJS.lib.WordArray.create(content); + } + return CryptoJS.SHA256(content).toString(CryptoJS.enc.Hex); + }, + /** @method getBase64String @static @@ -1764,7 +1865,7 @@ TinCan client library /** @method getContentTypeFromHeader @static - @param {String} Content-Type header value + @param {String} header Content-Type header value @return {String} Primary value from Content-Type */ getContentTypeFromHeader: function (header) { @@ -1774,11 +1875,33 @@ TinCan client library /** @method isApplicationJSON @static - @param {String} Content-Type header value + @param {String} header Content-Type header value @return {Boolean} whether "application/json" was matched */ isApplicationJSON: function (header) { return TinCan.Utils.getContentTypeFromHeader(header).toLowerCase().indexOf("application/json") === 0; + }, + + /** + @method stringToArrayBuffer + @static + @param {String} content String of content to convert to an ArrayBuffer + @param {String} [encoding] Encoding to use for conversion + @return {ArrayBuffer} Converted content + */ + stringToArrayBuffer: function () { + TinCan.prototype.log("stringToArrayBuffer not overloaded - no environment loaded?"); + }, + + /** + @method stringFromArrayBuffer + @static + @param {ArrayBuffer} content ArrayBuffer of content to convert to a String + @param {String} [encoding] Encoding to use for conversion + @return {String} Converted content + */ + stringFromArrayBuffer: function () { + TinCan.prototype.log("stringFromArrayBuffer not overloaded - no environment loaded?"); } }; }()); @@ -1942,6 +2065,17 @@ TinCan client library } }, + /** + Creates and returns a boundary for separating parts in + requests where the statement has an attachment + + @method _getBoundary + @private + */ + _getBoundary: function () { + return TinCan.Utils.getUUID().replace(/-/g, ""); + }, + /** Method should be overloaded by an environment to do per environment specifics such that the LRS can make a call @@ -1965,6 +2099,17 @@ TinCan client library this.log("_makeRequest not overloaded - no environment loaded?"); }, + /** + Method should be overloaded by an environment to do per + environment specifics for building multipart request data + + @method _getMultipartRequestData + @private + */ + _getMultipartRequestData: function () { + this.log("_getMultipartRequestData not overloaded - no environment loaded?"); + }, + /** Method is overloaded by the browser environment in order to test converting an HTTP request that is greater than a defined length @@ -1976,6 +2121,30 @@ TinCan client library this.log("_IEModeConversion not overloaded - browser environment not loaded."); }, + _processGetStatementResult: function (xhr, params) { + var boundary, + parsedResponse, + statement, + attachmentMap = {}, + i; + + if (! params.attachments) { + return TinCan.Statement.fromJSON(xhr.responseText); + } + + boundary = xhr.getResponseHeader("Content-Type").split("boundary=")[1]; + + parsedResponse = this._parseMultipart(boundary, xhr.response); + statement = JSON.parse(parsedResponse[0].body); + for (i = 1; i < parsedResponse.length; i += 1) { + attachmentMap[parsedResponse[i].headers["X-Experience-API-Hash"]] = parsedResponse[i].body; + } + + this._assignAttachmentContent([statement], attachmentMap); + + return new TinCan.Statement(statement); + }, + /** Method used to send a request via browser objects to the LRS @@ -1984,13 +2153,14 @@ TinCan client library @param {String} cfg.url URL portion to add to endpoint @param {String} [cfg.method] GET, PUT, POST, etc. @param {Object} [cfg.params] Parameters to set on the querystring - @param {String} [cfg.data] String of body content + @param {String|ArrayBuffer} [cfg.data] Body content as a String or ArrayBuffer @param {Object} [cfg.headers] Additional headers to set in the request @param {Function} [cfg.callback] Function to run at completion @param {String|Null} cfg.callback.err If an error occurred, this parameter will contain the HTTP status code. If the operation succeeded, err will be null. @param {Object} cfg.callback.xhr XHR object @param {Boolean} [cfg.ignore404] Whether 404 status codes should be considered an error + @param {Boolean} [cfg.expectMultipart] Whether to expect the response to be a multipart response @return {Object} XHR if called in a synchronous way (in other words no callback) */ sendRequest: function (cfg) { @@ -2094,8 +2264,14 @@ TinCan client library */ saveStatement: function (stmt, cfg) { this.log("saveStatement"); - var requestCfg, - versionedStatement; + var requestCfg = { + url: "statements", + headers: {} + }, + versionedStatement, + requestAttachments = [], + boundary, + i; cfg = cfg || {}; @@ -2126,13 +2302,48 @@ TinCan client library }; } - requestCfg = { - url: "statements", - data: JSON.stringify(versionedStatement), - headers: { - "Content-Type": "application/json" + if (versionedStatement.hasOwnProperty("attachments") && stmt.hasAttachmentWithContent()) { + boundary = this._getBoundary(); + + requestCfg.headers["Content-Type"] = "multipart/mixed; boundary=" + boundary; + + for (i = 0; i < stmt.attachments.length; i += 1) { + if (stmt.attachments[i].content !== null) { + requestAttachments.push(stmt.attachments[i]); + } } - }; + + try { + requestCfg.data = this._getMultipartRequestData(boundary, versionedStatement, requestAttachments); + } + catch (ex) { + if (this.allowFail) { + this.log("[warning] multipart request data could not be created (attachments probably not supported): " + ex); + if (typeof cfg.callback !== "undefined") { + cfg.callback(null, null); + return; + } + return { + err: null, + xhr: null + }; + } + + this.log("[error] multipart request data could not be created (attachments probably not supported): " + ex); + if (typeof cfg.callback !== "undefined") { + cfg.callback(ex, null); + return; + } + return { + err: ex, + xhr: null + }; + } + } + else { + requestCfg.headers["Content-Type"] = "application/json"; + requestCfg.data = JSON.stringify(versionedStatement); + } if (stmt.id !== null) { requestCfg.method = "PUT"; requestCfg.params = { @@ -2156,6 +2367,8 @@ TinCan client library @method retrieveStatement @param {String} ID of statement to retrieve @param {Object} [cfg] Configuration options + @param {Object} [cfg.params] Query parameters + @param {Boolean} [cfg.params.attachments] Include attachments in multipart response or don't (default: false) @param {Function} [cfg.callback] Callback to execute on completion @return {TinCan.Statement} Statement retrieved */ @@ -2163,9 +2376,11 @@ TinCan client library this.log("retrieveStatement"); var requestCfg, requestResult, - callbackWrapper; + callbackWrapper, + lrs = this; cfg = cfg || {}; + cfg.params = cfg.params || {}; requestCfg = { url: "statements", @@ -2174,12 +2389,16 @@ TinCan client library statementId: stmtId } }; + if (cfg.params.attachments) { + requestCfg.params.attachments = true; + requestCfg.expectMultipart = true; + } if (typeof cfg.callback !== "undefined") { callbackWrapper = function (err, xhr) { var result = xhr; if (err === null) { - result = TinCan.Statement.fromJSON(xhr.responseText); + result = lrs._processGetStatementResult(xhr, cfg.params); } cfg.callback(err, result); @@ -2191,7 +2410,7 @@ TinCan client library if (! callbackWrapper) { requestResult.statement = null; if (requestResult.err === null) { - requestResult.statement = TinCan.Statement.fromJSON(requestResult.xhr.responseText); + requestResult.statement = lrs._processGetStatementResult(requestResult.xhr, cfg.params); } } @@ -2204,6 +2423,8 @@ TinCan client library @method retrieveVoidedStatement @param {String} ID of voided statement to retrieve @param {Object} [cfg] Configuration options + @param {Object} [cfg.params] Query parameters + @param {Boolean} [cfg.params.attachments] Include attachments in multipart response or don't (default: false) @param {Function} [cfg.callback] Callback to execute on completion @return {TinCan.Statement} Statement retrieved */ @@ -2211,9 +2432,11 @@ TinCan client library this.log("retrieveVoidedStatement"); var requestCfg, requestResult, - callbackWrapper; + callbackWrapper, + lrs = this; cfg = cfg || {}; + cfg.params = cfg.params || {}; requestCfg = { url: "statements", @@ -2225,6 +2448,10 @@ TinCan client library } else { requestCfg.params.voidedStatementId = stmtId; + if (cfg.params.attachments) { + requestCfg.params.attachments = true; + requestCfg.expectMultipart = true; + } } if (typeof cfg.callback !== "undefined") { @@ -2232,7 +2459,7 @@ TinCan client library var result = xhr; if (err === null) { - result = TinCan.Statement.fromJSON(xhr.responseText); + result = lrs._processGetStatementResult(xhr, cfg.params); } cfg.callback(err, result); @@ -2244,7 +2471,7 @@ TinCan client library if (! callbackWrapper) { requestResult.statement = null; if (requestResult.err === null) { - requestResult.statement = TinCan.Statement.fromJSON(requestResult.xhr.responseText); + requestResult.statement = lrs._processGetStatementResult(requestResult.xhr, cfg.params); } } @@ -2262,11 +2489,17 @@ TinCan client library */ saveStatements: function (stmts, cfg) { this.log("saveStatements"); - var requestCfg, + var requestCfg = { + url: "statements", + method: "POST", + headers: {} + }, versionedStatement, versionedStatements = [], - i - ; + requestAttachments = [], + boundary, + i, + j; cfg = cfg || {}; @@ -2308,17 +2541,55 @@ TinCan client library xhr: null }; } + + if (stmts[i].hasAttachmentWithContent()) { + for (j = 0; j < stmts[i].attachments.length; j += 1) { + if (stmts[i].attachments[j].content !== null) { + requestAttachments.push(stmts[i].attachments[j]); + } + } + } + versionedStatements.push(versionedStatement); } - requestCfg = { - url: "statements", - method: "POST", - data: JSON.stringify(versionedStatements), - headers: { - "Content-Type": "application/json" + if (requestAttachments.length !== 0) { + boundary = this._getBoundary(); + + requestCfg.headers["Content-Type"] = "multipart/mixed; boundary=" + boundary; + + try { + requestCfg.data = this._getMultipartRequestData(boundary, versionedStatements, requestAttachments); } - }; + catch (ex) { + if (this.allowFail) { + this.log("[warning] multipart request data could not be created (attachments probably not supported): " + ex); + if (typeof cfg.callback !== "undefined") { + cfg.callback(null, null); + return; + } + return { + err: null, + xhr: null + }; + } + + this.log("[error] multipart request data could not be created (attachments probably not supported): " + ex); + if (typeof cfg.callback !== "undefined") { + cfg.callback(ex, null); + return; + } + return { + err: ex, + xhr: null + }; + } + } + else { + requestCfg.headers["Content-Type"] = "application/json"; + requestCfg.data = JSON.stringify(versionedStatements); + } + if (typeof cfg.callback !== "undefined") { requestCfg.callback = cfg.callback; } @@ -2334,8 +2605,8 @@ TinCan client library @param {Object} [cfg] Configuration used to query @param {Object} [cfg.params] Query parameters @param {TinCan.Agent|TinCan.Group} [cfg.params.agent] Agent matches 'actor' or 'object' - @param {TinCan.Verb} [cfg.params.verb] Verb to query on - @param {TinCan.Activity} [cfg.params.activity] Activity to query on + @param {TinCan.Verb|String} [cfg.params.verb] Verb (or verb ID) to query on + @param {TinCan.Activity|String} [cfg.params.activity] Activity (or activity ID) to query on @param {String} [cfg.params.registration] Registration UUID @param {Boolean} [cfg.params.related_activities] Match related activities @param {Boolean} [cfg.params.related_agents] Match related agents @@ -2343,7 +2614,6 @@ TinCan client library @param {String} [cfg.params.until] Match statements stored at or before specified timestamp @param {Integer} [cfg.params.limit] Number of results to retrieve @param {String} [cfg.params.format] One of "ids", "exact", "canonical" (default: "exact") - @param {Boolean} [cfg.params.attachments] Include attachments in multipart response or don't (defualt: false) @param {Boolean} [cfg.params.ascending] Return results in ascending order of stored time @param {TinCan.Agent} [cfg.params.actor] (Removed in 1.0.0, use 'agent' instead) Agent matches 'actor' @@ -2362,18 +2632,23 @@ TinCan client library this.log("queryStatements"); var requestCfg, requestResult, - callbackWrapper; + callbackWrapper, + lrs = this; cfg = cfg || {}; cfg.params = cfg.params || {}; // - // if they misconfigured (possibly do to version mismatches) the + // if they misconfigured (possibly due to version mismatches) the // query then don't try to send a request at all, rather than give // them invalid results // try { requestCfg = this._queryStatementsRequestCfg(cfg); + + if (cfg.params.attachments) { + requestCfg.expectMultipart = true; + } } catch (ex) { this.log("[error] Query statements failed - " + ex); @@ -2389,10 +2664,35 @@ TinCan client library if (typeof cfg.callback !== "undefined") { callbackWrapper = function (err, xhr) { - var result = xhr; + var result = xhr, + parsedResponse, + boundary, + statements, + attachmentMap = {}, + i; if (err === null) { - result = TinCan.StatementsResult.fromJSON(xhr.responseText); + if (! cfg.params.attachments) { + result = TinCan.StatementsResult.fromJSON(xhr.responseText); + } + else { + boundary = xhr.getResponseHeader("Content-Type").split("boundary=")[1]; + + parsedResponse = lrs._parseMultipart(boundary, xhr.response); + statements = JSON.parse(parsedResponse[0].body); + for (i = 1; i < parsedResponse.length; i += 1) { + attachmentMap[parsedResponse[i].headers["X-Experience-API-Hash"]] = parsedResponse[i].body; + } + + lrs._assignAttachmentContent(statements.statements, attachmentMap); + result = new TinCan.StatementsResult({ statements: statements.statements }); + + for (i = 0; i < result.statements.length; i += 1) { + if (! (result.statements[i] instanceof TinCan.Statement)) { + result.statements[i] = new TinCan.Statement(result.statements[i]); + } + } + } } cfg.callback(err, result); @@ -2532,7 +2832,12 @@ TinCan client library for (i = 0; i < idProps.length; i += 1) { if (typeof cfg.params[idProps[i]] !== "undefined") { - params[idProps[i]] = cfg.params[idProps[i]].id; + if (typeof cfg.params[idProps[i]].id === "undefined") { + params[idProps[i]] = cfg.params[idProps[i]]; + } + else { + params[idProps[i]] = cfg.params[idProps[i]].id; + } } } @@ -2545,6 +2850,159 @@ TinCan client library return returnCfg; }, + /** + Assigns attachment content to the correct attachment to create a StatementsResult object that is sent + to the callback of queryStatements() + + @method _assignAttachmentContent + @private + @param {Array} [stmts] Array of TinCan.Statement JSON objects + @param {Object} [attachmentMap] Map of the content to place into its attachment + @return {Array} Array of TinCan.Statement JSON objects with correctly assigned attachment content + */ + _assignAttachmentContent: function (stmts, attachmentMap) { + var i, + j; + + for (i = 0; i < stmts.length; i += 1) { + if (stmts[i].hasOwnProperty("attachments") && stmts[i].attachments !== null) { + for (j = 0; j < stmts[i].attachments.length; j += 1) { + if (attachmentMap.hasOwnProperty(stmts[i].attachments[j].sha2)) { + stmts[i].attachments[j].content = attachmentMap[stmts[i].attachments[j].sha2]; + } + } + } + } + }, + + /** + Parses the different sections of a multipart/mixed response + + @method _parseMultipart + @private + @param {String} [boundary] Boundary used to mark off the sections of the response + @param {ArrayBuffer} [response] Body of the response + @return {Array} Array of objects containing the parsed headers and body of each part + */ + _parseMultipart: function (boundary, response) { + /* global Uint8Array */ + var __boundary = "--" + boundary, + byteArray, + bodyEncodedInString, + fullBodyEnd, + sliceStart, + sliceEnd, + headerStart, + headerEnd, + bodyStart, + bodyEnd, + headers, + body, + parts = [], + CRLF = 2; + + // + // treating the reponse as a stream of bytes and assuming that headers + // and related mime boundaries are all US-ASCII (which is a safe assumption) + // allows us to treat the whole response as a string when looking for offsets + // but then slice on the raw array buffer + // + byteArray = new Uint8Array(response); + bodyEncodedInString = this.__uint8ToString(byteArray); + + fullBodyEnd = bodyEncodedInString.indexOf(__boundary + "--"); + + sliceStart = bodyEncodedInString.indexOf(__boundary); + while (sliceStart !== -1) { + sliceEnd = bodyEncodedInString.indexOf(__boundary, sliceStart + __boundary.length); + + headerStart = sliceStart + __boundary.length + CRLF; + headerEnd = bodyEncodedInString.indexOf("\r\n\r\n", sliceStart); + bodyStart = headerEnd + CRLF + CRLF; + bodyEnd = sliceEnd - 2; + + headers = this._parseHeaders( + this.__uint8ToString( + new Uint8Array( response.slice(headerStart, headerEnd) ) + ) + ); + body = response.slice(bodyStart, bodyEnd); + + // + // we know the first slice is the statement, and we know it is a string in UTF-8 (spec requirement) + // + if (parts.length === 0) { + body = TinCan.Utils.stringFromArrayBuffer(body); + } + + parts.push( + { + headers: headers, + body: body + } + ); + + if (sliceEnd === fullBodyEnd) { + sliceStart = -1; + } + else { + sliceStart = sliceEnd; + } + } + + return parts; + }, + + // + // implemented as a function to avoid 'RangeError: Maximum call stack size exceeded' + // when calling .fromCharCode on the full byteArray which results in a too long + // argument list for large arrays + // + __uint8ToString: function (byteArray) { + var result = "", + len = byteArray.byteLength, + i; + + for (i = 0; i < len; i += 1) { + result += String.fromCharCode(byteArray[i]); + } + return result; + }, + + /** + Parses the headers of a multipart/mixed response section + + @method _parseHeaders + @private + @param {String} [rawHeaders] String containing all the headers + @return {Object} Map of the headers + */ + _parseHeaders: function (rawHeaders) { + var headers = {}, + headerList, + key, + h, + i; + + headerList = rawHeaders.split("\n"); + for (i = 0; i < headerList.length; i += 1) { + h = headerList[i].split(":", 2); + + if (h[1] !== null) { + headers[h[0]] = h[1].replace(/^\s+|\s+$/g, ""); + + key = h[0]; + } + else { + if (h[0].substring(0, 1) === "\t") { + headers[h[0]] = h[1].replace(/^\s+|\s+$/g, ""); + } + } + } + + return headers; + }, + /** Fetch more statements from a previous query, when used from a browser sends to the endpoint using the RESTful interface. Use a callback to make the call asynchronous. @@ -2686,20 +3144,25 @@ TinCan client library ); if (typeof xhr.getResponseHeader !== "undefined" && xhr.getResponseHeader("ETag") !== null && xhr.getResponseHeader("ETag") !== "") { result.etag = xhr.getResponseHeader("ETag"); - } else { + } + else { // // either XHR didn't have getResponseHeader (probably cause it is an IE // XDomainRequest object which doesn't) or not populated by LRS so create // the hash ourselves // - result.etag = TinCan.Utils.getSHA1String(xhr.responseText); + // the LRS is responsible for quoting the Etag value so we need to mimic + // that behavior here as well + // + result.etag = "\"" + TinCan.Utils.getSHA1String(xhr.responseText) + "\""; } if (typeof xhr.contentType !== "undefined") { // most likely an XDomainRequest which has .contentType, // for the ones that it supports result.contentType = xhr.contentType; - } else if (typeof xhr.getResponseHeader !== "undefined" && xhr.getResponseHeader("Content-Type") !== null && xhr.getResponseHeader("Content-Type") !== "") { + } + else if (typeof xhr.getResponseHeader !== "undefined" && xhr.getResponseHeader("Content-Type") !== null && xhr.getResponseHeader("Content-Type") !== "") { result.contentType = xhr.getResponseHeader("Content-Type"); } @@ -2730,19 +3193,24 @@ TinCan client library ); if (typeof requestResult.xhr.getResponseHeader !== "undefined" && requestResult.xhr.getResponseHeader("ETag") !== null && requestResult.xhr.getResponseHeader("ETag") !== "") { requestResult.state.etag = requestResult.xhr.getResponseHeader("ETag"); - } else { + } + else { // // either XHR didn't have getResponseHeader (probably cause it is an IE // XDomainRequest object which doesn't) or not populated by LRS so create // the hash ourselves // - requestResult.state.etag = TinCan.Utils.getSHA1String(requestResult.xhr.responseText); + // the LRS is responsible for quoting the Etag value so we need to mimic + // that behavior here as well + // + requestResult.state.etag = "\"" + TinCan.Utils.getSHA1String(requestResult.xhr.responseText) + "\""; } if (typeof requestResult.xhr.contentType !== "undefined") { // most likely an XDomainRequest which has .contentType // for the ones that it supports requestResult.state.contentType = requestResult.xhr.contentType; - } else if (typeof requestResult.xhr.getResponseHeader !== "undefined" && requestResult.xhr.getResponseHeader("Content-Type") !== null && requestResult.xhr.getResponseHeader("Content-Type") !== "") { + } + else if (typeof requestResult.xhr.getResponseHeader !== "undefined" && requestResult.xhr.getResponseHeader("Content-Type") !== null && requestResult.xhr.getResponseHeader("Content-Type") !== "") { requestResult.state.contentType = requestResult.xhr.getResponseHeader("Content-Type"); } if (TinCan.Utils.isApplicationJSON(requestResult.state.contentType)) { @@ -3112,19 +3580,24 @@ TinCan client library ); if (typeof xhr.getResponseHeader !== "undefined" && xhr.getResponseHeader("ETag") !== null && xhr.getResponseHeader("ETag") !== "") { result.etag = xhr.getResponseHeader("ETag"); - } else { + } + else { // // either XHR didn't have getResponseHeader (probably cause it is an IE // XDomainRequest object which doesn't) or not populated by LRS so create // the hash ourselves // - result.etag = TinCan.Utils.getSHA1String(xhr.responseText); + // the LRS is responsible for quoting the Etag value so we need to mimic + // that behavior here as well + // + result.etag = "\"" + TinCan.Utils.getSHA1String(xhr.responseText) + "\""; } if (typeof xhr.contentType !== "undefined") { // most likely an XDomainRequest which has .contentType // for the ones that it supports result.contentType = xhr.contentType; - } else if (typeof xhr.getResponseHeader !== "undefined" && xhr.getResponseHeader("Content-Type") !== null && xhr.getResponseHeader("Content-Type") !== "") { + } + else if (typeof xhr.getResponseHeader !== "undefined" && xhr.getResponseHeader("Content-Type") !== null && xhr.getResponseHeader("Content-Type") !== "") { result.contentType = xhr.getResponseHeader("Content-Type"); } if (TinCan.Utils.isApplicationJSON(result.contentType)) { @@ -3155,19 +3628,24 @@ TinCan client library ); if (typeof requestResult.xhr.getResponseHeader !== "undefined" && requestResult.xhr.getResponseHeader("ETag") !== null && requestResult.xhr.getResponseHeader("ETag") !== "") { requestResult.profile.etag = requestResult.xhr.getResponseHeader("ETag"); - } else { + } + else { // // either XHR didn't have getResponseHeader (probably cause it is an IE // XDomainRequest object which doesn't) or not populated by LRS so create // the hash ourselves // - requestResult.profile.etag = TinCan.Utils.getSHA1String(requestResult.xhr.responseText); + // the LRS is responsible for quoting the Etag value so we need to mimic + // that behavior here as well + // + requestResult.profile.etag = "\"" + TinCan.Utils.getSHA1String(requestResult.xhr.responseText) + "\""; } if (typeof requestResult.xhr.contentType !== "undefined") { // most likely an XDomainRequest which has .contentType // for the ones that it supports requestResult.profile.contentType = requestResult.xhr.contentType; - } else if (typeof requestResult.xhr.getResponseHeader !== "undefined" && requestResult.xhr.getResponseHeader("Content-Type") !== null && requestResult.xhr.getResponseHeader("Content-Type") !== "") { + } + else if (typeof requestResult.xhr.getResponseHeader !== "undefined" && requestResult.xhr.getResponseHeader("Content-Type") !== null && requestResult.xhr.getResponseHeader("Content-Type") !== "") { requestResult.profile.contentType = requestResult.xhr.getResponseHeader("Content-Type"); } if (TinCan.Utils.isApplicationJSON(requestResult.profile.contentType)) { @@ -3416,19 +3894,24 @@ TinCan client library ); if (typeof xhr.getResponseHeader !== "undefined" && xhr.getResponseHeader("ETag") !== null && xhr.getResponseHeader("ETag") !== "") { result.etag = xhr.getResponseHeader("ETag"); - } else { + } + else { // // either XHR didn't have getResponseHeader (probably cause it is an IE // XDomainRequest object which doesn't) or not populated by LRS so create // the hash ourselves // - result.etag = TinCan.Utils.getSHA1String(xhr.responseText); + // the LRS is responsible for quoting the Etag value so we need to mimic + // that behavior here as well + // + result.etag = "\"" + TinCan.Utils.getSHA1String(xhr.responseText) + "\""; } if (typeof xhr.contentType !== "undefined") { // most likely an XDomainRequest which has .contentType // for the ones that it supports result.contentType = xhr.contentType; - } else if (typeof xhr.getResponseHeader !== "undefined" && xhr.getResponseHeader("Content-Type") !== null && xhr.getResponseHeader("Content-Type") !== "") { + } + else if (typeof xhr.getResponseHeader !== "undefined" && xhr.getResponseHeader("Content-Type") !== null && xhr.getResponseHeader("Content-Type") !== "") { result.contentType = xhr.getResponseHeader("Content-Type"); } if (TinCan.Utils.isApplicationJSON(result.contentType)) { @@ -3459,19 +3942,24 @@ TinCan client library ); if (typeof requestResult.xhr.getResponseHeader !== "undefined" && requestResult.xhr.getResponseHeader("ETag") !== null && requestResult.xhr.getResponseHeader("ETag") !== "") { requestResult.profile.etag = requestResult.xhr.getResponseHeader("ETag"); - } else { + } + else { // // either XHR didn't have getResponseHeader (probably cause it is an IE // XDomainRequest object which doesn't) or not populated by LRS so create // the hash ourselves // - requestResult.profile.etag = TinCan.Utils.getSHA1String(requestResult.xhr.responseText); + // the LRS is responsible for quoting the Etag value so we need to mimic + // that behavior here as well + // + requestResult.profile.etag = "\"" + TinCan.Utils.getSHA1String(requestResult.xhr.responseText) + "\""; } if (typeof requestResult.xhr.contentType !== "undefined") { // most likely an XDomainRequest which has .contentType // for the ones that it supports requestResult.profile.contentType = requestResult.xhr.contentType; - } else if (typeof requestResult.xhr.getResponseHeader !== "undefined" && requestResult.xhr.getResponseHeader("Content-Type") !== null && requestResult.xhr.getResponseHeader("Content-Type") !== "") { + } + else if (typeof requestResult.xhr.getResponseHeader !== "undefined" && requestResult.xhr.getResponseHeader("Content-Type") !== null && requestResult.xhr.getResponseHeader("Content-Type") !== "") { requestResult.profile.contentType = requestResult.xhr.getResponseHeader("Content-Type"); } if (TinCan.Utils.isApplicationJSON(requestResult.profile.contentType)) { @@ -6238,6 +6726,7 @@ TinCan client library @param {TinCan.Result} [cfg.result] Statement Result @param {TinCan.Context} [cfg.context] Statement Context @param {TinCan.Agent} [cfg.authority] Statement Authority + @param {TinCan.Attachment} [cfg.attachments] Statement Attachments @param {String} [cfg.timestamp] ISO8601 Date/time value @param {String} [cfg.stored] ISO8601 Date/time value @param {String} [cfg.version] Version of the statement (post 0.95) @@ -6319,6 +6808,12 @@ TinCan client library */ this.authority = null; + /** + @property attachments + @type Array of TinCan.Attachment + */ + this.attachments = null; + /** @property version @type String @@ -6481,6 +6976,17 @@ TinCan client library this.context = new TinCan.Context (cfg.context); } } + if (cfg.hasOwnProperty("attachments") && cfg.attachments !== null) { + this.attachments = []; + for (i = 0; i < cfg.attachments.length; i += 1) { + if (! (cfg.attachments[i] instanceof TinCan.Attachment)) { + this.attachments.push(new TinCan.Attachment (cfg.attachments[i])); + } + else { + this.attachments.push(cfg.attachments[i]); + } + } + } for (i = 0; i < directProps.length; i += 1) { if (cfg.hasOwnProperty(directProps[i]) && cfg[directProps[i]] !== null) { @@ -6550,6 +7056,19 @@ TinCan client library if (version === "0.9" && this.inProgress !== null) { result.inProgress = this.inProgress; } + if (this.attachments !== null) { + if (! (version === "0.9" || version === "0.95")) { + result.attachments = []; + for (i = 0; i < this.attachments.length; i += 1) { + if (this.attachments[i] instanceof TinCan.Attachment) { + result.attachments.push(this.attachments[i].asVersion(version)); + } + else { + result.attachments.push(new TinCan.Attachment(this.attachments[i]).asVersion(version)); + } + } + } + } return result; }, @@ -6567,6 +7086,28 @@ TinCan client library if (this.timestamp === null) { this.timestamp = TinCan.Utils.getISODateString(new Date()); } + }, + + /** + Checks if the Statement has at least one attachment with content + + @method hasAttachmentsWithContent + */ + hasAttachmentWithContent: function () { + this.log("hasAttachmentWithContent"); + var i; + + if (this.attachments === null) { + return false; + } + + for (i = 0; i < this.attachments.length; i += 1) { + if (this.attachments[i].content !== null) { + return true; + } + } + + return false; } }; @@ -7168,6 +7709,221 @@ TinCan client library }; }()); +/* + Copyright 2016 Rustici Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** +TinCan client library + +@module TinCan +@submodule TinCan.Attachment +**/ +(function () { + "use strict"; + + /** + @class TinCan.Attachment + @constructor + */ + var Attachment = TinCan.Attachment = function (cfg) { + this.log("constructor"); + + /** + @property usageType + @type String + */ + this.usageType = null; + + /** + @property display + @type Object + */ + this.display = null; + + /** + @property contentType + @type String + */ + this.contentType = null; + + /** + @property length + @type int + */ + this.length = null; + + /** + @property sha2 + @type String + */ + this.sha2 = null; + + /** + @property description + @type Object + */ + this.description = null; + + /** + @property fileUrl + @type String + */ + this.fileUrl = null; + + /** + @property content + @type ArrayBuffer + */ + this.content = null; + + this.init(cfg); + }; + Attachment.prototype = { + /** + @property LOG_SRC + */ + LOG_SRC: "Attachment", + + /** + @method log + */ + log: TinCan.prototype.log, + + /** + @method init + @param {Object} [options] Configuration used to initialize + */ + init: function (cfg) { + this.log("init"); + var i, + directProps = [ + "contentType", + "length", + "sha2", + "usageType", + "display", + "description", + "fileUrl" + ] + ; + + cfg = cfg || {}; + + for (i = 0; i < directProps.length; i += 1) { + if (cfg.hasOwnProperty(directProps[i]) && cfg[directProps[i]] !== null) { + this[directProps[i]] = cfg[directProps[i]]; + } + } + + if (cfg.hasOwnProperty("content") && cfg.content !== null) { + if (typeof cfg.content === "string") { + this.setContentFromString(cfg.content); + } + else { + this.setContent(cfg.content); + } + } + }, + + /** + @method asVersion + @param {String} [version] Version to return (defaults to newest supported) + */ + asVersion: function (version) { + this.log("asVersion"); + var result; + + version = version || TinCan.versions()[0]; + + if (version === "0.9" || version === "0.95") { + result = null; + } + else { + result = { + contentType: this.contentType, + display: this.display, + length: this.length, + sha2: this.sha2, + usageType: this.usageType + }; + + if (this.fileUrl !== null) { + result.fileUrl = this.fileUrl; + } + if (this.description !== null) { + result.description = this.description; + } + } + + return result; + }, + + /** + See {{#crossLink "TinCan.Utils/getLangDictionaryValue"}}{{/crossLink}} + + @method getLangDictionaryValue + */ + getLangDictionaryValue: TinCan.Utils.getLangDictionaryValue, + + /** + @method setContent + @param {ArrayBuffer} content Sets content from ArrayBuffer + */ + setContent: function (content) { + this.content = content; + this.length = content.byteLength; + this.sha2 = TinCan.Utils.getSHA256String(content); + }, + + /** + @method setContentFromString + @param {String} content Sets the content property of the attachment from a string + */ + setContentFromString: function (content) { + var _content = content; + + _content = TinCan.Utils.stringToArrayBuffer(content); + + this.setContent(_content); + }, + + /** + @method getContentAsString + @return {String} Value of content property as a string + */ + getContentAsString: function () { + return TinCan.Utils.stringFromArrayBuffer(this.content); + } + }; + + /** + @method fromJSON + @return {Object} Attachment + @static + */ + Attachment.fromJSON = function (attachmentJSON) { + Attachment.prototype.log("fromJSON"); + var _attachment = JSON.parse(attachmentJSON); + + return new Attachment(_attachment); + }; + + Attachment._defaultEncoding = "utf-8"; +}()); + /* Copyright 2012-2013 Rustici Software @@ -7191,13 +7947,15 @@ TinCan client library @submodule TinCan.Environment.Node **/ (function () { - /* globals require */ + /* globals require,Buffer,ArrayBuffer,Uint8Array */ "use strict"; var LOG_SRC = "Environment.Node", log = TinCan.prototype.log, querystring = require("querystring"), XMLHttpRequest = require("xhr2"), - requestComplete; + requestComplete, + __createJSONSegment, + __createAttachmentSegment; requestComplete = function (xhr, cfg) { log("requestComplete - xhr.status: " + xhr.status, LOG_SRC); @@ -7265,6 +8023,11 @@ TinCan client library xhr = new XMLHttpRequest(); xhr.open(cfg.method, url, async); + + if (cfg.expectMultipart) { + xhr.responseType = "arraybuffer"; + } + for (prop in headers) { if (headers.hasOwnProperty(prop)) { xhr.setRequestHeader(prop, headers[prop]); @@ -7297,4 +8060,134 @@ TinCan client library // Synchronos xhr handling is unsupported in node // TinCan.LRS.syncEnabled = false; + + TinCan.LRS.prototype._getMultipartRequestData = function (boundary, jsonContent, requestAttachments) { + var parts = [], + i; + + parts.push( + __createJSONSegment( + boundary, + jsonContent + ) + ); + for (i = 0; i < requestAttachments.length; i += 1) { + if (requestAttachments[i].content !== null) { + parts.push( + __createAttachmentSegment( + boundary, + requestAttachments[i].content, + requestAttachments[i].sha2, + requestAttachments[i].contentType + ) + ); + } + } + if (typeof Buffer.from === "undefined") { + parts.push( new Buffer("\r\n--" + boundary + "--\r\n") ); + } + else { + parts.push( Buffer.from("\r\n--" + boundary + "--\r\n") ); + } + + return Buffer.concat(parts); + }; + + __createJSONSegment = function (boundary, jsonContent) { + var content = [ + "--" + boundary, + "Content-Type: application/json", + "", + JSON.stringify(jsonContent) + ].join("\r\n"); + + content += "\r\n"; + + if (typeof Buffer.from === "undefined") { + return new Buffer(content); + } + return Buffer.from(content); + }; + + __createAttachmentSegment = function (boundary, content, sha2, contentType) { + var bufferParts = [], + header = [ + "--" + boundary, + "Content-Type: " + contentType, + "Content-Transfer-Encoding: binary", + "X-Experience-API-Hash: " + sha2 + ].join("\r\n"); + + header += "\r\n\r\n"; + + if (typeof Buffer.from === "undefined") { + bufferParts.push( new Buffer(header) ); + bufferParts.push( new Buffer(content) ); + } + else { + bufferParts.push(Buffer.from(header)); + bufferParts.push(Buffer.from(content)); + } + + return Buffer.concat(bufferParts); + }; + + TinCan.Utils.stringToArrayBuffer = function (content, encoding) { + var b, + ab, + view, + i; + + if (! encoding) { + encoding = TinCan.Utils.defaultEncoding; + } + + if (typeof Buffer.from === "undefined") { + // for Node.js prior to v4.x + b = new Buffer(content, encoding); + + ab = new ArrayBuffer(b.length); + view = new Uint8Array(ab); + for (i = 0; i < b.length; i += 1) { + view[i] = b[i]; + } + + return ab; + } + + b = Buffer.from(content, encoding); + ab = b.buffer; + + // + // this .slice is required because of the internals of how Buffer is + // implemented, it uses a shared ArrayBuffer underneath for small buffers + // see http://stackoverflow.com/a/31394257/1464957 + // + return ab.slice(b.byteOffset, b.byteOffset + b.byteLength); + }; + + TinCan.Utils.stringFromArrayBuffer = function (content, encoding) { + var b, + view, + i; + + if (! encoding) { + encoding = TinCan.Utils.defaultEncoding; + } + + if (typeof Buffer.from === "undefined") { + // for Node.js prior to v4.x + b = new Buffer(content.byteLength); + + view = new Uint8Array(content); + for (i = 0; i < b.length; i += 1) { + b[i] = view[i]; + } + } + else { + b = Buffer.from(content); + } + + return b.toString(encoding); + }; }()); diff --git a/build/tincan.js b/build/tincan.js index c610d7d..502df7f 100644 --- a/build/tincan.js +++ b/build/tincan.js @@ -1,23 +1,41 @@ -"0.41.1"; +"0.50.0"; /* -CryptoJS v3.0.2 +CryptoJS v3.1.2 code.google.com/p/crypto-js -(c) 2009-2012 by Jeff Mott. All rights reserved. +(c) 2009-2013 by Jeff Mott. All rights reserved. code.google.com/p/crypto-js/wiki/License */ -var CryptoJS=CryptoJS||function(i,m){var p={},h=p.lib={},n=h.Base=function(){function a(){}return{extend:function(b){a.prototype=this;var c=new a;b&&c.mixIn(b);c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.$super.extend(this)}}}(),o=h.WordArray=n.extend({init:function(a,b){a= -this.words=a||[];this.sigBytes=b!=m?b:4*a.length},toString:function(a){return(a||e).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes,a=a.sigBytes;this.clamp();if(d%4)for(var f=0;f>>2]|=(c[f>>>2]>>>24-8*(f%4)&255)<<24-8*((d+f)%4);else if(65535>>2]=c[f>>>2];else b.push.apply(b,c);this.sigBytes+=a;return this},clamp:function(){var a=this.words,b=this.sigBytes;a[b>>>2]&=4294967295<<32-8*(b%4);a.length=i.ceil(b/4)},clone:function(){var a= -n.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var b=[],c=0;c>>2]>>>24-8*(d%4)&255;c.push((f>>>4).toString(16));c.push((f&15).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return o.create(c,b/2)}},g=q.Latin1={stringify:function(a){for(var b= -a.words,a=a.sigBytes,c=[],d=0;d>>2]>>>24-8*(d%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>2]|=(a.charCodeAt(d)&255)<<24-8*(d%4);return o.create(c,b)}},j=q.Utf8={stringify:function(a){try{return decodeURIComponent(escape(g.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return g.parse(unescape(encodeURIComponent(a)))}},k=h.BufferedBlockAlgorithm=n.extend({reset:function(){this._data=o.create(); -this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var b=this._data,c=b.words,d=b.sigBytes,f=this.blockSize,e=d/(4*f),e=a?i.ceil(e):i.max((e|0)-this._minBufferSize,0),a=e*f,d=i.min(4*a,d);if(a){for(var g=0;gb;b++){if(16>b)h[b]=o[i+b]|0;else{var c=h[b-3]^h[b-8]^h[b-14]^h[b-16];h[b]=c<<1|c>>>31}c=(g<<5|g>>>27)+a+h[b];c=20>b?c+((j&k|~j&l)+1518500249):40>b?c+((j^k^l)+1859775393):60>b?c+((j&k|j&l|k&l)-1894007588):c+((j^k^l)- -899497514);a=l;l=k;k=j<<30|j>>>2;j=g;g=c}e[0]=e[0]+g|0;e[1]=e[1]+j|0;e[2]=e[2]+k|0;e[3]=e[3]+l|0;e[4]=e[4]+a|0},_doFinalize:function(){var i=this._data,h=i.words,e=8*this._nDataBytes,g=8*i.sigBytes;h[g>>>5]|=128<<24-g%32;h[(g+64>>>9<<4)+15]=e;i.sigBytes=4*h.length;this._process()}});i.SHA1=m._createHelper(n);i.HmacSHA1=m._createHmacHelper(n)})(); +var CryptoJS=CryptoJS||function(e,m){var p={},j=p.lib={},l=function(){},f=j.Base={extend:function(a){l.prototype=this;var c=new l;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}}, +n=j.WordArray=f.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=m?c:4*a.length},toString:function(a){return(a||h).stringify(this)},concat:function(a){var c=this.words,q=a.words,d=this.sigBytes;a=a.sigBytes;this.clamp();if(d%4)for(var b=0;b>>2]|=(q[b>>>2]>>>24-8*(b%4)&255)<<24-8*((d+b)%4);else if(65535>>2]=q[b>>>2];else c.push.apply(c,q);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<< +32-8*(c%4);a.length=e.ceil(c/4)},clone:function(){var a=f.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],b=0;b>>2]>>>24-8*(d%4)&255;b.push((f>>>4).toString(16));b.push((f&15).toString(16))}return b.join("")},parse:function(a){for(var c=a.length,b=[],d=0;d>>3]|=parseInt(a.substr(d, +2),16)<<24-4*(d%8);return new n.init(b,c/2)}},g=b.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var b=[],d=0;d>>2]>>>24-8*(d%4)&255));return b.join("")},parse:function(a){for(var c=a.length,b=[],d=0;d>>2]|=(a.charCodeAt(d)&255)<<24-8*(d%4);return new n.init(b,c)}},r=b.Utf8={stringify:function(a){try{return decodeURIComponent(escape(g.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return g.parse(unescape(encodeURIComponent(a)))}}, +k=j.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new n.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=r.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,b=c.words,d=c.sigBytes,f=this.blockSize,h=d/(4*f),h=a?e.ceil(h):e.max((h|0)-this._minBufferSize,0);a=h*f;d=e.min(4*a,d);if(a){for(var g=0;ga;a++){if(16>a)l[a]=f[n+a]|0;else{var c=l[a-3]^l[a-8]^l[a-14]^l[a-16];l[a]=c<<1|c>>>31}c=(h<<5|h>>>27)+j+l[a];c=20>a?c+((g&e|~g&k)+1518500249):40>a?c+((g^e^k)+1859775393):60>a?c+((g&e|g&k|e&k)-1894007588):c+((g^e^ +k)-899497514);j=k;k=e;e=g<<30|g>>>2;g=h;h=c}b[0]=b[0]+h|0;b[1]=b[1]+g|0;b[2]=b[2]+e|0;b[3]=b[3]+k|0;b[4]=b[4]+j|0},_doFinalize:function(){var f=this._data,e=f.words,b=8*this._nDataBytes,h=8*f.sigBytes;e[h>>>5]|=128<<24-h%32;e[(h+64>>>9<<4)+14]=Math.floor(b/4294967296);e[(h+64>>>9<<4)+15]=b;f.sigBytes=4*e.length;this._process();return this._hash},clone:function(){var e=j.clone.call(this);e._hash=this._hash.clone();return e}});e.SHA1=j._createHelper(m);e.HmacSHA1=j._createHmacHelper(m)})(); /* -CryptoJS v3.0.2 +CryptoJS v3.1.2 code.google.com/p/crypto-js -(c) 2009-2012 by Jeff Mott. All rights reserved. +(c) 2009-2013 by Jeff Mott. All rights reserved. +code.google.com/p/crypto-js/wiki/License +*/ +var CryptoJS=CryptoJS||function(h,s){var f={},t=f.lib={},g=function(){},j=t.Base={extend:function(a){g.prototype=this;var c=new g;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}}, +q=t.WordArray=j.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=s?c:4*a.length},toString:function(a){return(a||u).stringify(this)},concat:function(a){var c=this.words,d=a.words,b=this.sigBytes;a=a.sigBytes;this.clamp();if(b%4)for(var e=0;e>>2]|=(d[e>>>2]>>>24-8*(e%4)&255)<<24-8*((b+e)%4);else if(65535>>2]=d[e>>>2];else c.push.apply(c,d);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<< +32-8*(c%4);a.length=h.ceil(c/4)},clone:function(){var a=j.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],d=0;d>>2]>>>24-8*(b%4)&255;d.push((e>>>4).toString(16));d.push((e&15).toString(16))}return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>3]|=parseInt(a.substr(b, +2),16)<<24-4*(b%8);return new q.init(d,c/2)}},k=v.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b>>2]>>>24-8*(b%4)&255));return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>2]|=(a.charCodeAt(b)&255)<<24-8*(b%4);return new q.init(d,c)}},l=v.Utf8={stringify:function(a){try{return decodeURIComponent(escape(k.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return k.parse(unescape(encodeURIComponent(a)))}}, +x=t.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new q.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=l.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,d=c.words,b=c.sigBytes,e=this.blockSize,f=b/(4*e),f=a?h.ceil(f):h.max((f|0)-this._minBufferSize,0);a=f*e;b=h.min(4*a,b);if(a){for(var m=0;mk;){var l;a:{l=u;for(var x=h.sqrt(l),w=2;w<=x;w++)if(!(l%w)){l=!1;break a}l=!0}l&&(8>k&&(j[k]=v(h.pow(u,0.5))),q[k]=v(h.pow(u,1/3)),k++);u++}var a=[],f=f.SHA256=g.extend({_doReset:function(){this._hash=new t.init(j.slice(0))},_doProcessBlock:function(c,d){for(var b=this._hash.words,e=b[0],f=b[1],m=b[2],h=b[3],p=b[4],j=b[5],k=b[6],l=b[7],n=0;64>n;n++){if(16>n)a[n]= +c[d+n]|0;else{var r=a[n-15],g=a[n-2];a[n]=((r<<25|r>>>7)^(r<<14|r>>>18)^r>>>3)+a[n-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+a[n-16]}r=l+((p<<26|p>>>6)^(p<<21|p>>>11)^(p<<7|p>>>25))+(p&j^~p&k)+q[n]+a[n];g=((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&f^e&m^f&m);l=k;k=j;j=p;p=h+r|0;h=m;m=f;f=e;e=r+g|0}b[0]=b[0]+e|0;b[1]=b[1]+f|0;b[2]=b[2]+m|0;b[3]=b[3]+h|0;b[4]=b[4]+p|0;b[5]=b[5]+j|0;b[6]=b[6]+k|0;b[7]=b[7]+l|0},_doFinalize:function(){var a=this._data,d=a.words,b=8*this._nDataBytes,e=8*a.sigBytes; +d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=h.floor(b/4294967296);d[(e+64>>>9<<4)+15]=b;a.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var a=g.clone.call(this);a._hash=this._hash.clone();return a}});s.SHA256=g._createHelper(f);s.HmacSHA256=g._createHmacHelper(f)})(Math); + +/* +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 () { @@ -92,9 +110,6 @@ code.google.com/p/crypto-js/wiki/License * var wordArray = CryptoJS.enc.Base64.parse(base64String); */ parse: function (base64Str) { - // Ignore whitespaces - base64Str = base64Str.replace(/\s/g, ''); - // Shortcuts var base64StrLength = base64Str.length; var map = this._map; @@ -113,9 +128,9 @@ code.google.com/p/crypto-js/wiki/License var nBytes = 0; for (var i = 0; i < base64StrLength; i++) { if (i % 4) { - var bitsHigh = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2); - var bitsLow = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2); - words[nBytes >>> 2] |= (bitsHigh | bitsLow) << (24 - (nBytes % 4) * 8); + var bits1 = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2); + var bits2 = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2); + words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8); nBytes++; } } @@ -127,6 +142,69 @@ 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_lib = C.lib; + var WordArray = C_lib.WordArray; + + // Reference original init + var superInit = WordArray.init; + + // Augment WordArray.init to handle typed arrays + var subInit = WordArray.init = function (typedArray) { + // Convert buffers to uint8 + if (typedArray instanceof ArrayBuffer) { + typedArray = new Uint8Array(typedArray); + } + + // Convert other array views to uint8 + if ( + typedArray instanceof Int8Array || + typedArray instanceof Uint8ClampedArray || + typedArray instanceof Int16Array || + typedArray instanceof Uint16Array || + typedArray instanceof Int32Array || + typedArray instanceof Uint32Array || + typedArray instanceof Float32Array || + typedArray instanceof Float64Array + ) { + typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength); + } + + // Handle Uint8Array + if (typedArray instanceof Uint8Array) { + // Shortcut + var typedArrayByteLength = typedArray.byteLength; + + // Extract bytes + var words = []; + for (var i = 0; i < typedArrayByteLength; i++) { + words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8); + } + + // Initialize this word array + superInit.call(this, words, typedArrayByteLength); + } else { + // Else call normal init + superInit.apply(this, arguments); + } + }; + + subInit.prototype = WordArray; +}()); + /*! Copyright 2012 Rustici Software @@ -577,17 +655,23 @@ var TinCan; Calls retrieveStatement on the first LRS, provide callback to make it asynchronous @method getStatement - @param {String} statement Statement ID to get + @param {String} [stmtId] Statement ID to get @param {Function} [callback] Callback function to execute on completion + @param {Object} [cfg] Configuration data + @param {Object} [params] Query parameters + @param {Boolean} [attachments] Include attachments in multipart response or don't (defualt: false) @return {Array|Result} Array of results, or single result TODO: make TinCan track statements it has seen in a local cache to be returned easily */ - getStatement: function (stmtId, callback) { + getStatement: function (stmtId, callback, cfg) { this.log("getStatement"); var lrs; + cfg = cfg || {}; + cfg.params = cfg.params || {}; + if (this.recordStores.length > 0) { // // for statements (for now) we only need to read from the first LRS @@ -600,7 +684,7 @@ var TinCan; // lrs = this.recordStores[0]; - return lrs.retrieveStatement(stmtId, { callback: callback }); + return lrs.retrieveStatement(stmtId, { callback: callback, params: cfg.params }); } this.log("[warning] getStatement: No LRSs added yet (statement not retrieved)"); @@ -1428,6 +1512,8 @@ TinCan client library @class TinCan.Utils */ TinCan.Utils = { + defaultEncoding: "utf8", + /** Generates a UUIDv4 compliant string that should be reasonably unique @@ -1593,6 +1679,21 @@ TinCan client library return CryptoJS.SHA1(str).toString(CryptoJS.enc.Hex); }, + /** + @method getSHA256String + @static + @param {ArrayBuffer|String} content Content to hash + @return {String} SHA256 for contents + */ + getSHA256String: function (content) { + /*global CryptoJS*/ + + if (Object.prototype.toString.call(content) === "[object ArrayBuffer]") { + content = CryptoJS.lib.WordArray.create(content); + } + return CryptoJS.SHA256(content).toString(CryptoJS.enc.Hex); + }, + /** @method getBase64String @static @@ -1764,7 +1865,7 @@ TinCan client library /** @method getContentTypeFromHeader @static - @param {String} Content-Type header value + @param {String} header Content-Type header value @return {String} Primary value from Content-Type */ getContentTypeFromHeader: function (header) { @@ -1774,11 +1875,33 @@ TinCan client library /** @method isApplicationJSON @static - @param {String} Content-Type header value + @param {String} header Content-Type header value @return {Boolean} whether "application/json" was matched */ isApplicationJSON: function (header) { return TinCan.Utils.getContentTypeFromHeader(header).toLowerCase().indexOf("application/json") === 0; + }, + + /** + @method stringToArrayBuffer + @static + @param {String} content String of content to convert to an ArrayBuffer + @param {String} [encoding] Encoding to use for conversion + @return {ArrayBuffer} Converted content + */ + stringToArrayBuffer: function () { + TinCan.prototype.log("stringToArrayBuffer not overloaded - no environment loaded?"); + }, + + /** + @method stringFromArrayBuffer + @static + @param {ArrayBuffer} content ArrayBuffer of content to convert to a String + @param {String} [encoding] Encoding to use for conversion + @return {String} Converted content + */ + stringFromArrayBuffer: function () { + TinCan.prototype.log("stringFromArrayBuffer not overloaded - no environment loaded?"); } }; }()); @@ -1942,6 +2065,17 @@ TinCan client library } }, + /** + Creates and returns a boundary for separating parts in + requests where the statement has an attachment + + @method _getBoundary + @private + */ + _getBoundary: function () { + return TinCan.Utils.getUUID().replace(/-/g, ""); + }, + /** Method should be overloaded by an environment to do per environment specifics such that the LRS can make a call @@ -1965,6 +2099,17 @@ TinCan client library this.log("_makeRequest not overloaded - no environment loaded?"); }, + /** + Method should be overloaded by an environment to do per + environment specifics for building multipart request data + + @method _getMultipartRequestData + @private + */ + _getMultipartRequestData: function () { + this.log("_getMultipartRequestData not overloaded - no environment loaded?"); + }, + /** Method is overloaded by the browser environment in order to test converting an HTTP request that is greater than a defined length @@ -1976,6 +2121,30 @@ TinCan client library this.log("_IEModeConversion not overloaded - browser environment not loaded."); }, + _processGetStatementResult: function (xhr, params) { + var boundary, + parsedResponse, + statement, + attachmentMap = {}, + i; + + if (! params.attachments) { + return TinCan.Statement.fromJSON(xhr.responseText); + } + + boundary = xhr.getResponseHeader("Content-Type").split("boundary=")[1]; + + parsedResponse = this._parseMultipart(boundary, xhr.response); + statement = JSON.parse(parsedResponse[0].body); + for (i = 1; i < parsedResponse.length; i += 1) { + attachmentMap[parsedResponse[i].headers["X-Experience-API-Hash"]] = parsedResponse[i].body; + } + + this._assignAttachmentContent([statement], attachmentMap); + + return new TinCan.Statement(statement); + }, + /** Method used to send a request via browser objects to the LRS @@ -1984,13 +2153,14 @@ TinCan client library @param {String} cfg.url URL portion to add to endpoint @param {String} [cfg.method] GET, PUT, POST, etc. @param {Object} [cfg.params] Parameters to set on the querystring - @param {String} [cfg.data] String of body content + @param {String|ArrayBuffer} [cfg.data] Body content as a String or ArrayBuffer @param {Object} [cfg.headers] Additional headers to set in the request @param {Function} [cfg.callback] Function to run at completion @param {String|Null} cfg.callback.err If an error occurred, this parameter will contain the HTTP status code. If the operation succeeded, err will be null. @param {Object} cfg.callback.xhr XHR object @param {Boolean} [cfg.ignore404] Whether 404 status codes should be considered an error + @param {Boolean} [cfg.expectMultipart] Whether to expect the response to be a multipart response @return {Object} XHR if called in a synchronous way (in other words no callback) */ sendRequest: function (cfg) { @@ -2094,8 +2264,14 @@ TinCan client library */ saveStatement: function (stmt, cfg) { this.log("saveStatement"); - var requestCfg, - versionedStatement; + var requestCfg = { + url: "statements", + headers: {} + }, + versionedStatement, + requestAttachments = [], + boundary, + i; cfg = cfg || {}; @@ -2126,13 +2302,48 @@ TinCan client library }; } - requestCfg = { - url: "statements", - data: JSON.stringify(versionedStatement), - headers: { - "Content-Type": "application/json" + if (versionedStatement.hasOwnProperty("attachments") && stmt.hasAttachmentWithContent()) { + boundary = this._getBoundary(); + + requestCfg.headers["Content-Type"] = "multipart/mixed; boundary=" + boundary; + + for (i = 0; i < stmt.attachments.length; i += 1) { + if (stmt.attachments[i].content !== null) { + requestAttachments.push(stmt.attachments[i]); + } } - }; + + try { + requestCfg.data = this._getMultipartRequestData(boundary, versionedStatement, requestAttachments); + } + catch (ex) { + if (this.allowFail) { + this.log("[warning] multipart request data could not be created (attachments probably not supported): " + ex); + if (typeof cfg.callback !== "undefined") { + cfg.callback(null, null); + return; + } + return { + err: null, + xhr: null + }; + } + + this.log("[error] multipart request data could not be created (attachments probably not supported): " + ex); + if (typeof cfg.callback !== "undefined") { + cfg.callback(ex, null); + return; + } + return { + err: ex, + xhr: null + }; + } + } + else { + requestCfg.headers["Content-Type"] = "application/json"; + requestCfg.data = JSON.stringify(versionedStatement); + } if (stmt.id !== null) { requestCfg.method = "PUT"; requestCfg.params = { @@ -2156,6 +2367,8 @@ TinCan client library @method retrieveStatement @param {String} ID of statement to retrieve @param {Object} [cfg] Configuration options + @param {Object} [cfg.params] Query parameters + @param {Boolean} [cfg.params.attachments] Include attachments in multipart response or don't (default: false) @param {Function} [cfg.callback] Callback to execute on completion @return {TinCan.Statement} Statement retrieved */ @@ -2163,9 +2376,11 @@ TinCan client library this.log("retrieveStatement"); var requestCfg, requestResult, - callbackWrapper; + callbackWrapper, + lrs = this; cfg = cfg || {}; + cfg.params = cfg.params || {}; requestCfg = { url: "statements", @@ -2174,12 +2389,16 @@ TinCan client library statementId: stmtId } }; + if (cfg.params.attachments) { + requestCfg.params.attachments = true; + requestCfg.expectMultipart = true; + } if (typeof cfg.callback !== "undefined") { callbackWrapper = function (err, xhr) { var result = xhr; if (err === null) { - result = TinCan.Statement.fromJSON(xhr.responseText); + result = lrs._processGetStatementResult(xhr, cfg.params); } cfg.callback(err, result); @@ -2191,7 +2410,7 @@ TinCan client library if (! callbackWrapper) { requestResult.statement = null; if (requestResult.err === null) { - requestResult.statement = TinCan.Statement.fromJSON(requestResult.xhr.responseText); + requestResult.statement = lrs._processGetStatementResult(requestResult.xhr, cfg.params); } } @@ -2204,6 +2423,8 @@ TinCan client library @method retrieveVoidedStatement @param {String} ID of voided statement to retrieve @param {Object} [cfg] Configuration options + @param {Object} [cfg.params] Query parameters + @param {Boolean} [cfg.params.attachments] Include attachments in multipart response or don't (default: false) @param {Function} [cfg.callback] Callback to execute on completion @return {TinCan.Statement} Statement retrieved */ @@ -2211,9 +2432,11 @@ TinCan client library this.log("retrieveVoidedStatement"); var requestCfg, requestResult, - callbackWrapper; + callbackWrapper, + lrs = this; cfg = cfg || {}; + cfg.params = cfg.params || {}; requestCfg = { url: "statements", @@ -2225,6 +2448,10 @@ TinCan client library } else { requestCfg.params.voidedStatementId = stmtId; + if (cfg.params.attachments) { + requestCfg.params.attachments = true; + requestCfg.expectMultipart = true; + } } if (typeof cfg.callback !== "undefined") { @@ -2232,7 +2459,7 @@ TinCan client library var result = xhr; if (err === null) { - result = TinCan.Statement.fromJSON(xhr.responseText); + result = lrs._processGetStatementResult(xhr, cfg.params); } cfg.callback(err, result); @@ -2244,7 +2471,7 @@ TinCan client library if (! callbackWrapper) { requestResult.statement = null; if (requestResult.err === null) { - requestResult.statement = TinCan.Statement.fromJSON(requestResult.xhr.responseText); + requestResult.statement = lrs._processGetStatementResult(requestResult.xhr, cfg.params); } } @@ -2262,11 +2489,17 @@ TinCan client library */ saveStatements: function (stmts, cfg) { this.log("saveStatements"); - var requestCfg, + var requestCfg = { + url: "statements", + method: "POST", + headers: {} + }, versionedStatement, versionedStatements = [], - i - ; + requestAttachments = [], + boundary, + i, + j; cfg = cfg || {}; @@ -2308,17 +2541,55 @@ TinCan client library xhr: null }; } + + if (stmts[i].hasAttachmentWithContent()) { + for (j = 0; j < stmts[i].attachments.length; j += 1) { + if (stmts[i].attachments[j].content !== null) { + requestAttachments.push(stmts[i].attachments[j]); + } + } + } + versionedStatements.push(versionedStatement); } - requestCfg = { - url: "statements", - method: "POST", - data: JSON.stringify(versionedStatements), - headers: { - "Content-Type": "application/json" + if (requestAttachments.length !== 0) { + boundary = this._getBoundary(); + + requestCfg.headers["Content-Type"] = "multipart/mixed; boundary=" + boundary; + + try { + requestCfg.data = this._getMultipartRequestData(boundary, versionedStatements, requestAttachments); } - }; + catch (ex) { + if (this.allowFail) { + this.log("[warning] multipart request data could not be created (attachments probably not supported): " + ex); + if (typeof cfg.callback !== "undefined") { + cfg.callback(null, null); + return; + } + return { + err: null, + xhr: null + }; + } + + this.log("[error] multipart request data could not be created (attachments probably not supported): " + ex); + if (typeof cfg.callback !== "undefined") { + cfg.callback(ex, null); + return; + } + return { + err: ex, + xhr: null + }; + } + } + else { + requestCfg.headers["Content-Type"] = "application/json"; + requestCfg.data = JSON.stringify(versionedStatements); + } + if (typeof cfg.callback !== "undefined") { requestCfg.callback = cfg.callback; } @@ -2334,8 +2605,8 @@ TinCan client library @param {Object} [cfg] Configuration used to query @param {Object} [cfg.params] Query parameters @param {TinCan.Agent|TinCan.Group} [cfg.params.agent] Agent matches 'actor' or 'object' - @param {TinCan.Verb} [cfg.params.verb] Verb to query on - @param {TinCan.Activity} [cfg.params.activity] Activity to query on + @param {TinCan.Verb|String} [cfg.params.verb] Verb (or verb ID) to query on + @param {TinCan.Activity|String} [cfg.params.activity] Activity (or activity ID) to query on @param {String} [cfg.params.registration] Registration UUID @param {Boolean} [cfg.params.related_activities] Match related activities @param {Boolean} [cfg.params.related_agents] Match related agents @@ -2343,7 +2614,6 @@ TinCan client library @param {String} [cfg.params.until] Match statements stored at or before specified timestamp @param {Integer} [cfg.params.limit] Number of results to retrieve @param {String} [cfg.params.format] One of "ids", "exact", "canonical" (default: "exact") - @param {Boolean} [cfg.params.attachments] Include attachments in multipart response or don't (defualt: false) @param {Boolean} [cfg.params.ascending] Return results in ascending order of stored time @param {TinCan.Agent} [cfg.params.actor] (Removed in 1.0.0, use 'agent' instead) Agent matches 'actor' @@ -2362,18 +2632,23 @@ TinCan client library this.log("queryStatements"); var requestCfg, requestResult, - callbackWrapper; + callbackWrapper, + lrs = this; cfg = cfg || {}; cfg.params = cfg.params || {}; // - // if they misconfigured (possibly do to version mismatches) the + // if they misconfigured (possibly due to version mismatches) the // query then don't try to send a request at all, rather than give // them invalid results // try { requestCfg = this._queryStatementsRequestCfg(cfg); + + if (cfg.params.attachments) { + requestCfg.expectMultipart = true; + } } catch (ex) { this.log("[error] Query statements failed - " + ex); @@ -2389,10 +2664,35 @@ TinCan client library if (typeof cfg.callback !== "undefined") { callbackWrapper = function (err, xhr) { - var result = xhr; + var result = xhr, + parsedResponse, + boundary, + statements, + attachmentMap = {}, + i; if (err === null) { - result = TinCan.StatementsResult.fromJSON(xhr.responseText); + if (! cfg.params.attachments) { + result = TinCan.StatementsResult.fromJSON(xhr.responseText); + } + else { + boundary = xhr.getResponseHeader("Content-Type").split("boundary=")[1]; + + parsedResponse = lrs._parseMultipart(boundary, xhr.response); + statements = JSON.parse(parsedResponse[0].body); + for (i = 1; i < parsedResponse.length; i += 1) { + attachmentMap[parsedResponse[i].headers["X-Experience-API-Hash"]] = parsedResponse[i].body; + } + + lrs._assignAttachmentContent(statements.statements, attachmentMap); + result = new TinCan.StatementsResult({ statements: statements.statements }); + + for (i = 0; i < result.statements.length; i += 1) { + if (! (result.statements[i] instanceof TinCan.Statement)) { + result.statements[i] = new TinCan.Statement(result.statements[i]); + } + } + } } cfg.callback(err, result); @@ -2532,7 +2832,12 @@ TinCan client library for (i = 0; i < idProps.length; i += 1) { if (typeof cfg.params[idProps[i]] !== "undefined") { - params[idProps[i]] = cfg.params[idProps[i]].id; + if (typeof cfg.params[idProps[i]].id === "undefined") { + params[idProps[i]] = cfg.params[idProps[i]]; + } + else { + params[idProps[i]] = cfg.params[idProps[i]].id; + } } } @@ -2545,6 +2850,159 @@ TinCan client library return returnCfg; }, + /** + Assigns attachment content to the correct attachment to create a StatementsResult object that is sent + to the callback of queryStatements() + + @method _assignAttachmentContent + @private + @param {Array} [stmts] Array of TinCan.Statement JSON objects + @param {Object} [attachmentMap] Map of the content to place into its attachment + @return {Array} Array of TinCan.Statement JSON objects with correctly assigned attachment content + */ + _assignAttachmentContent: function (stmts, attachmentMap) { + var i, + j; + + for (i = 0; i < stmts.length; i += 1) { + if (stmts[i].hasOwnProperty("attachments") && stmts[i].attachments !== null) { + for (j = 0; j < stmts[i].attachments.length; j += 1) { + if (attachmentMap.hasOwnProperty(stmts[i].attachments[j].sha2)) { + stmts[i].attachments[j].content = attachmentMap[stmts[i].attachments[j].sha2]; + } + } + } + } + }, + + /** + Parses the different sections of a multipart/mixed response + + @method _parseMultipart + @private + @param {String} [boundary] Boundary used to mark off the sections of the response + @param {ArrayBuffer} [response] Body of the response + @return {Array} Array of objects containing the parsed headers and body of each part + */ + _parseMultipart: function (boundary, response) { + /* global Uint8Array */ + var __boundary = "--" + boundary, + byteArray, + bodyEncodedInString, + fullBodyEnd, + sliceStart, + sliceEnd, + headerStart, + headerEnd, + bodyStart, + bodyEnd, + headers, + body, + parts = [], + CRLF = 2; + + // + // treating the reponse as a stream of bytes and assuming that headers + // and related mime boundaries are all US-ASCII (which is a safe assumption) + // allows us to treat the whole response as a string when looking for offsets + // but then slice on the raw array buffer + // + byteArray = new Uint8Array(response); + bodyEncodedInString = this.__uint8ToString(byteArray); + + fullBodyEnd = bodyEncodedInString.indexOf(__boundary + "--"); + + sliceStart = bodyEncodedInString.indexOf(__boundary); + while (sliceStart !== -1) { + sliceEnd = bodyEncodedInString.indexOf(__boundary, sliceStart + __boundary.length); + + headerStart = sliceStart + __boundary.length + CRLF; + headerEnd = bodyEncodedInString.indexOf("\r\n\r\n", sliceStart); + bodyStart = headerEnd + CRLF + CRLF; + bodyEnd = sliceEnd - 2; + + headers = this._parseHeaders( + this.__uint8ToString( + new Uint8Array( response.slice(headerStart, headerEnd) ) + ) + ); + body = response.slice(bodyStart, bodyEnd); + + // + // we know the first slice is the statement, and we know it is a string in UTF-8 (spec requirement) + // + if (parts.length === 0) { + body = TinCan.Utils.stringFromArrayBuffer(body); + } + + parts.push( + { + headers: headers, + body: body + } + ); + + if (sliceEnd === fullBodyEnd) { + sliceStart = -1; + } + else { + sliceStart = sliceEnd; + } + } + + return parts; + }, + + // + // implemented as a function to avoid 'RangeError: Maximum call stack size exceeded' + // when calling .fromCharCode on the full byteArray which results in a too long + // argument list for large arrays + // + __uint8ToString: function (byteArray) { + var result = "", + len = byteArray.byteLength, + i; + + for (i = 0; i < len; i += 1) { + result += String.fromCharCode(byteArray[i]); + } + return result; + }, + + /** + Parses the headers of a multipart/mixed response section + + @method _parseHeaders + @private + @param {String} [rawHeaders] String containing all the headers + @return {Object} Map of the headers + */ + _parseHeaders: function (rawHeaders) { + var headers = {}, + headerList, + key, + h, + i; + + headerList = rawHeaders.split("\n"); + for (i = 0; i < headerList.length; i += 1) { + h = headerList[i].split(":", 2); + + if (h[1] !== null) { + headers[h[0]] = h[1].replace(/^\s+|\s+$/g, ""); + + key = h[0]; + } + else { + if (h[0].substring(0, 1) === "\t") { + headers[h[0]] = h[1].replace(/^\s+|\s+$/g, ""); + } + } + } + + return headers; + }, + /** Fetch more statements from a previous query, when used from a browser sends to the endpoint using the RESTful interface. Use a callback to make the call asynchronous. @@ -2686,20 +3144,25 @@ TinCan client library ); if (typeof xhr.getResponseHeader !== "undefined" && xhr.getResponseHeader("ETag") !== null && xhr.getResponseHeader("ETag") !== "") { result.etag = xhr.getResponseHeader("ETag"); - } else { + } + else { // // either XHR didn't have getResponseHeader (probably cause it is an IE // XDomainRequest object which doesn't) or not populated by LRS so create // the hash ourselves // - result.etag = TinCan.Utils.getSHA1String(xhr.responseText); + // the LRS is responsible for quoting the Etag value so we need to mimic + // that behavior here as well + // + result.etag = "\"" + TinCan.Utils.getSHA1String(xhr.responseText) + "\""; } if (typeof xhr.contentType !== "undefined") { // most likely an XDomainRequest which has .contentType, // for the ones that it supports result.contentType = xhr.contentType; - } else if (typeof xhr.getResponseHeader !== "undefined" && xhr.getResponseHeader("Content-Type") !== null && xhr.getResponseHeader("Content-Type") !== "") { + } + else if (typeof xhr.getResponseHeader !== "undefined" && xhr.getResponseHeader("Content-Type") !== null && xhr.getResponseHeader("Content-Type") !== "") { result.contentType = xhr.getResponseHeader("Content-Type"); } @@ -2730,19 +3193,24 @@ TinCan client library ); if (typeof requestResult.xhr.getResponseHeader !== "undefined" && requestResult.xhr.getResponseHeader("ETag") !== null && requestResult.xhr.getResponseHeader("ETag") !== "") { requestResult.state.etag = requestResult.xhr.getResponseHeader("ETag"); - } else { + } + else { // // either XHR didn't have getResponseHeader (probably cause it is an IE // XDomainRequest object which doesn't) or not populated by LRS so create // the hash ourselves // - requestResult.state.etag = TinCan.Utils.getSHA1String(requestResult.xhr.responseText); + // the LRS is responsible for quoting the Etag value so we need to mimic + // that behavior here as well + // + requestResult.state.etag = "\"" + TinCan.Utils.getSHA1String(requestResult.xhr.responseText) + "\""; } if (typeof requestResult.xhr.contentType !== "undefined") { // most likely an XDomainRequest which has .contentType // for the ones that it supports requestResult.state.contentType = requestResult.xhr.contentType; - } else if (typeof requestResult.xhr.getResponseHeader !== "undefined" && requestResult.xhr.getResponseHeader("Content-Type") !== null && requestResult.xhr.getResponseHeader("Content-Type") !== "") { + } + else if (typeof requestResult.xhr.getResponseHeader !== "undefined" && requestResult.xhr.getResponseHeader("Content-Type") !== null && requestResult.xhr.getResponseHeader("Content-Type") !== "") { requestResult.state.contentType = requestResult.xhr.getResponseHeader("Content-Type"); } if (TinCan.Utils.isApplicationJSON(requestResult.state.contentType)) { @@ -3112,19 +3580,24 @@ TinCan client library ); if (typeof xhr.getResponseHeader !== "undefined" && xhr.getResponseHeader("ETag") !== null && xhr.getResponseHeader("ETag") !== "") { result.etag = xhr.getResponseHeader("ETag"); - } else { + } + else { // // either XHR didn't have getResponseHeader (probably cause it is an IE // XDomainRequest object which doesn't) or not populated by LRS so create // the hash ourselves // - result.etag = TinCan.Utils.getSHA1String(xhr.responseText); + // the LRS is responsible for quoting the Etag value so we need to mimic + // that behavior here as well + // + result.etag = "\"" + TinCan.Utils.getSHA1String(xhr.responseText) + "\""; } if (typeof xhr.contentType !== "undefined") { // most likely an XDomainRequest which has .contentType // for the ones that it supports result.contentType = xhr.contentType; - } else if (typeof xhr.getResponseHeader !== "undefined" && xhr.getResponseHeader("Content-Type") !== null && xhr.getResponseHeader("Content-Type") !== "") { + } + else if (typeof xhr.getResponseHeader !== "undefined" && xhr.getResponseHeader("Content-Type") !== null && xhr.getResponseHeader("Content-Type") !== "") { result.contentType = xhr.getResponseHeader("Content-Type"); } if (TinCan.Utils.isApplicationJSON(result.contentType)) { @@ -3155,19 +3628,24 @@ TinCan client library ); if (typeof requestResult.xhr.getResponseHeader !== "undefined" && requestResult.xhr.getResponseHeader("ETag") !== null && requestResult.xhr.getResponseHeader("ETag") !== "") { requestResult.profile.etag = requestResult.xhr.getResponseHeader("ETag"); - } else { + } + else { // // either XHR didn't have getResponseHeader (probably cause it is an IE // XDomainRequest object which doesn't) or not populated by LRS so create // the hash ourselves // - requestResult.profile.etag = TinCan.Utils.getSHA1String(requestResult.xhr.responseText); + // the LRS is responsible for quoting the Etag value so we need to mimic + // that behavior here as well + // + requestResult.profile.etag = "\"" + TinCan.Utils.getSHA1String(requestResult.xhr.responseText) + "\""; } if (typeof requestResult.xhr.contentType !== "undefined") { // most likely an XDomainRequest which has .contentType // for the ones that it supports requestResult.profile.contentType = requestResult.xhr.contentType; - } else if (typeof requestResult.xhr.getResponseHeader !== "undefined" && requestResult.xhr.getResponseHeader("Content-Type") !== null && requestResult.xhr.getResponseHeader("Content-Type") !== "") { + } + else if (typeof requestResult.xhr.getResponseHeader !== "undefined" && requestResult.xhr.getResponseHeader("Content-Type") !== null && requestResult.xhr.getResponseHeader("Content-Type") !== "") { requestResult.profile.contentType = requestResult.xhr.getResponseHeader("Content-Type"); } if (TinCan.Utils.isApplicationJSON(requestResult.profile.contentType)) { @@ -3416,19 +3894,24 @@ TinCan client library ); if (typeof xhr.getResponseHeader !== "undefined" && xhr.getResponseHeader("ETag") !== null && xhr.getResponseHeader("ETag") !== "") { result.etag = xhr.getResponseHeader("ETag"); - } else { + } + else { // // either XHR didn't have getResponseHeader (probably cause it is an IE // XDomainRequest object which doesn't) or not populated by LRS so create // the hash ourselves // - result.etag = TinCan.Utils.getSHA1String(xhr.responseText); + // the LRS is responsible for quoting the Etag value so we need to mimic + // that behavior here as well + // + result.etag = "\"" + TinCan.Utils.getSHA1String(xhr.responseText) + "\""; } if (typeof xhr.contentType !== "undefined") { // most likely an XDomainRequest which has .contentType // for the ones that it supports result.contentType = xhr.contentType; - } else if (typeof xhr.getResponseHeader !== "undefined" && xhr.getResponseHeader("Content-Type") !== null && xhr.getResponseHeader("Content-Type") !== "") { + } + else if (typeof xhr.getResponseHeader !== "undefined" && xhr.getResponseHeader("Content-Type") !== null && xhr.getResponseHeader("Content-Type") !== "") { result.contentType = xhr.getResponseHeader("Content-Type"); } if (TinCan.Utils.isApplicationJSON(result.contentType)) { @@ -3459,19 +3942,24 @@ TinCan client library ); if (typeof requestResult.xhr.getResponseHeader !== "undefined" && requestResult.xhr.getResponseHeader("ETag") !== null && requestResult.xhr.getResponseHeader("ETag") !== "") { requestResult.profile.etag = requestResult.xhr.getResponseHeader("ETag"); - } else { + } + else { // // either XHR didn't have getResponseHeader (probably cause it is an IE // XDomainRequest object which doesn't) or not populated by LRS so create // the hash ourselves // - requestResult.profile.etag = TinCan.Utils.getSHA1String(requestResult.xhr.responseText); + // the LRS is responsible for quoting the Etag value so we need to mimic + // that behavior here as well + // + requestResult.profile.etag = "\"" + TinCan.Utils.getSHA1String(requestResult.xhr.responseText) + "\""; } if (typeof requestResult.xhr.contentType !== "undefined") { // most likely an XDomainRequest which has .contentType // for the ones that it supports requestResult.profile.contentType = requestResult.xhr.contentType; - } else if (typeof requestResult.xhr.getResponseHeader !== "undefined" && requestResult.xhr.getResponseHeader("Content-Type") !== null && requestResult.xhr.getResponseHeader("Content-Type") !== "") { + } + else if (typeof requestResult.xhr.getResponseHeader !== "undefined" && requestResult.xhr.getResponseHeader("Content-Type") !== null && requestResult.xhr.getResponseHeader("Content-Type") !== "") { requestResult.profile.contentType = requestResult.xhr.getResponseHeader("Content-Type"); } if (TinCan.Utils.isApplicationJSON(requestResult.profile.contentType)) { @@ -6238,6 +6726,7 @@ TinCan client library @param {TinCan.Result} [cfg.result] Statement Result @param {TinCan.Context} [cfg.context] Statement Context @param {TinCan.Agent} [cfg.authority] Statement Authority + @param {TinCan.Attachment} [cfg.attachments] Statement Attachments @param {String} [cfg.timestamp] ISO8601 Date/time value @param {String} [cfg.stored] ISO8601 Date/time value @param {String} [cfg.version] Version of the statement (post 0.95) @@ -6319,6 +6808,12 @@ TinCan client library */ this.authority = null; + /** + @property attachments + @type Array of TinCan.Attachment + */ + this.attachments = null; + /** @property version @type String @@ -6481,6 +6976,17 @@ TinCan client library this.context = new TinCan.Context (cfg.context); } } + if (cfg.hasOwnProperty("attachments") && cfg.attachments !== null) { + this.attachments = []; + for (i = 0; i < cfg.attachments.length; i += 1) { + if (! (cfg.attachments[i] instanceof TinCan.Attachment)) { + this.attachments.push(new TinCan.Attachment (cfg.attachments[i])); + } + else { + this.attachments.push(cfg.attachments[i]); + } + } + } for (i = 0; i < directProps.length; i += 1) { if (cfg.hasOwnProperty(directProps[i]) && cfg[directProps[i]] !== null) { @@ -6550,6 +7056,19 @@ TinCan client library if (version === "0.9" && this.inProgress !== null) { result.inProgress = this.inProgress; } + if (this.attachments !== null) { + if (! (version === "0.9" || version === "0.95")) { + result.attachments = []; + for (i = 0; i < this.attachments.length; i += 1) { + if (this.attachments[i] instanceof TinCan.Attachment) { + result.attachments.push(this.attachments[i].asVersion(version)); + } + else { + result.attachments.push(new TinCan.Attachment(this.attachments[i]).asVersion(version)); + } + } + } + } return result; }, @@ -6567,6 +7086,28 @@ TinCan client library if (this.timestamp === null) { this.timestamp = TinCan.Utils.getISODateString(new Date()); } + }, + + /** + Checks if the Statement has at least one attachment with content + + @method hasAttachmentsWithContent + */ + hasAttachmentWithContent: function () { + this.log("hasAttachmentWithContent"); + var i; + + if (this.attachments === null) { + return false; + } + + for (i = 0; i < this.attachments.length; i += 1) { + if (this.attachments[i].content !== null) { + return true; + } + } + + return false; } }; @@ -7168,6 +7709,221 @@ TinCan client library }; }()); +/* + Copyright 2016 Rustici Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** +TinCan client library + +@module TinCan +@submodule TinCan.Attachment +**/ +(function () { + "use strict"; + + /** + @class TinCan.Attachment + @constructor + */ + var Attachment = TinCan.Attachment = function (cfg) { + this.log("constructor"); + + /** + @property usageType + @type String + */ + this.usageType = null; + + /** + @property display + @type Object + */ + this.display = null; + + /** + @property contentType + @type String + */ + this.contentType = null; + + /** + @property length + @type int + */ + this.length = null; + + /** + @property sha2 + @type String + */ + this.sha2 = null; + + /** + @property description + @type Object + */ + this.description = null; + + /** + @property fileUrl + @type String + */ + this.fileUrl = null; + + /** + @property content + @type ArrayBuffer + */ + this.content = null; + + this.init(cfg); + }; + Attachment.prototype = { + /** + @property LOG_SRC + */ + LOG_SRC: "Attachment", + + /** + @method log + */ + log: TinCan.prototype.log, + + /** + @method init + @param {Object} [options] Configuration used to initialize + */ + init: function (cfg) { + this.log("init"); + var i, + directProps = [ + "contentType", + "length", + "sha2", + "usageType", + "display", + "description", + "fileUrl" + ] + ; + + cfg = cfg || {}; + + for (i = 0; i < directProps.length; i += 1) { + if (cfg.hasOwnProperty(directProps[i]) && cfg[directProps[i]] !== null) { + this[directProps[i]] = cfg[directProps[i]]; + } + } + + if (cfg.hasOwnProperty("content") && cfg.content !== null) { + if (typeof cfg.content === "string") { + this.setContentFromString(cfg.content); + } + else { + this.setContent(cfg.content); + } + } + }, + + /** + @method asVersion + @param {String} [version] Version to return (defaults to newest supported) + */ + asVersion: function (version) { + this.log("asVersion"); + var result; + + version = version || TinCan.versions()[0]; + + if (version === "0.9" || version === "0.95") { + result = null; + } + else { + result = { + contentType: this.contentType, + display: this.display, + length: this.length, + sha2: this.sha2, + usageType: this.usageType + }; + + if (this.fileUrl !== null) { + result.fileUrl = this.fileUrl; + } + if (this.description !== null) { + result.description = this.description; + } + } + + return result; + }, + + /** + See {{#crossLink "TinCan.Utils/getLangDictionaryValue"}}{{/crossLink}} + + @method getLangDictionaryValue + */ + getLangDictionaryValue: TinCan.Utils.getLangDictionaryValue, + + /** + @method setContent + @param {ArrayBuffer} content Sets content from ArrayBuffer + */ + setContent: function (content) { + this.content = content; + this.length = content.byteLength; + this.sha2 = TinCan.Utils.getSHA256String(content); + }, + + /** + @method setContentFromString + @param {String} content Sets the content property of the attachment from a string + */ + setContentFromString: function (content) { + var _content = content; + + _content = TinCan.Utils.stringToArrayBuffer(content); + + this.setContent(_content); + }, + + /** + @method getContentAsString + @return {String} Value of content property as a string + */ + getContentAsString: function () { + return TinCan.Utils.stringFromArrayBuffer(this.content); + } + }; + + /** + @method fromJSON + @return {Object} Attachment + @static + */ + Attachment.fromJSON = function (attachmentJSON) { + Attachment.prototype.log("fromJSON"); + var _attachment = JSON.parse(attachmentJSON); + + return new Attachment(_attachment); + }; + + Attachment._defaultEncoding = "utf-8"; +}()); + /* Copyright 2012-2013 Rustici Software @@ -7191,14 +7947,16 @@ TinCan client library @submodule TinCan.Environment.Browser **/ (function () { - /* globals window, XMLHttpRequest, XDomainRequest */ + /* globals window, XMLHttpRequest, XDomainRequest, Blob */ "use strict"; var LOG_SRC = "Environment.Browser", + requestComplete, + __IEModeConversion, nativeRequest, xdrRequest, - requestComplete, + __createJSONSegment, + __createAttachmentSegment, __delay, - __IEModeConversion, env = {}, log = TinCan.prototype.log; @@ -7254,6 +8012,33 @@ TinCan client library }; } + // + // Add .forEach implementation for supporting our string encoding polyfill + // imported from js-polyfills to avoid bringing in the whole es5 shim + // for now, a rewrite probably moves all shims out of the main build or at + // least Environment file and leverages more of them + // + + // ES5 15.4.4.18 Array.prototype.forEach ( callbackfn [ , thisArg ] ) + // From https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/forEach + if (!Array.prototype.forEach) { + /* jshint freeze:false,bitwise:false */ + Array.prototype.forEach = function (fun /*, thisp */) { + if (this === void 0 || this === null) { throw new TypeError(); } + + var t = Object(this); + var len = t.length >>> 0; + if (typeof fun !== "function") { throw new TypeError(); } + + var thisp = arguments[1], i; + for (i = 0; i < len; i += 1) { + if (i in t) { + fun.call(thisp, t[i], i, t); + } + } + }; + } + /* Detect CORS and XDR support */ env.hasCORS = false; env.useXDR = false; @@ -7400,18 +8185,6 @@ TinCan client library } if (fullRequest.length >= MAX_REQUEST_LENGTH) { - // This may change based upon what content is supported in IE Mode - if (typeof headers["Content-Type"] !== "undefined" && headers["Content-Type"] !== "application/json") { - err = new Error("Unsupported content type for IE Mode request"); - if (typeof cfg.callback !== "undefined") { - cfg.callback(err, null); - } - return { - err: err, - xhr: null - }; - } - if (typeof cfg.method === "undefined") { err = new Error("method must not be undefined for an IE Mode Request conversion"); if (typeof cfg.callback !== "undefined") { @@ -7438,18 +8211,35 @@ TinCan client library // http://blogs.msdn.com/b/ie/archive/2006/01/23/516393.aspx // xhr = new ActiveXObject("Microsoft.XMLHTTP"); + + if (cfg.expectMultipart) { + err = new Error("Attachment support not available"); + if (typeof cfg.callback !== "undefined") { + cfg.callback(err, null); + } + return { + err: err, + xhr: null + }; + } } xhr.open(cfg.method, fullUrl, async); + + // + // setting the .responseType before .open was causing IE to fail + // with a StateError, so moved it to here + // + if (cfg.expectMultipart) { + xhr.responseType = "arraybuffer"; + } + for (prop in headers) { if (headers.hasOwnProperty(prop)) { xhr.setRequestHeader(prop, headers[prop]); } } - if (typeof cfg.data !== "undefined") { - cfg.data += ""; - } data = cfg.data; if (async) { @@ -7500,11 +8290,10 @@ TinCan client library }, err; - if (typeof headers["Content-Type"] !== "undefined" && headers["Content-Type"] !== "application/json") { - err = new Error("Unsupported content type for IE Mode request"); - if (cfg.callback) { + if (cfg.expectMultipart) { + err = new Error("Attachment support not available"); + if (typeof cfg.callback !== "undefined") { cfg.callback(err, null); - return null; } return { err: err, @@ -7735,4 +8524,4481 @@ TinCan client library // Synchronous xhr handling is accepted in the browser environment // TinCan.LRS.syncEnabled = true; + + TinCan.LRS.prototype._getMultipartRequestData = function (boundary, jsonContent, requestAttachments) { + var parts = [], + i; + + parts.push( + __createJSONSegment( + boundary, + jsonContent + ) + ); + for (i = 0; i < requestAttachments.length; i += 1) { + if (requestAttachments[i].content !== null) { + parts.push( + __createAttachmentSegment( + boundary, + requestAttachments[i].content, + requestAttachments[i].sha2, + requestAttachments[i].contentType + ) + ); + } + } + parts.push("\r\n--" + boundary + "--\r\n"); + + return new Blob(parts); + }; + + __createJSONSegment = function (boundary, jsonContent) { + var content = [ + "--" + boundary, + "Content-Type: application/json", + "", + JSON.stringify(jsonContent) + ].join("\r\n"); + + content += "\r\n"; + + return content; + }; + + __createAttachmentSegment = function (boundary, content, sha2, contentType) { + var blobParts = [], + header = [ + "--" + boundary, + "Content-Type: " + contentType, + "Content-Transfer-Encoding: binary", + "X-Experience-API-Hash: " + sha2 + ].join("\r\n"); + + header += "\r\n\r\n"; + + blobParts.push(header); + blobParts.push(content); + + return new Blob(blobParts); + }; + + TinCan.Utils.stringToArrayBuffer = function (content, encoding) { + /* global TextEncoder */ + var encoder; + + if (! encoding) { + encoding = TinCan.Utils.defaultEncoding; + } + + encoder = new TextEncoder(encoding); + + return encoder.encode(content).buffer; + }; + + TinCan.Utils.stringFromArrayBuffer = function (content, encoding) { + /* global TextDecoder */ + var decoder; + + if (! encoding) { + encoding = TinCan.Utils.defaultEncoding; + } + + decoder = new TextDecoder(encoding); + + return decoder.decode(content); + }; }()); + +/* + Copyright (c) 2010, Linden Research, Inc. + Copyright (c) 2014, Joshua Bell + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + $/LicenseInfo$ + */ + +// Original can be found at: +// https://bitbucket.org/lindenlab/llsd +// Modifications by Joshua Bell inexorabletash@gmail.com +// https://github.com/inexorabletash/polyfill + +// ES3/ES5 implementation of the Krhonos Typed Array Specification +// Ref: http://www.khronos.org/registry/typedarray/specs/latest/ +// Date: 2011-02-01 +// +// Variations: +// * Allows typed_array.get/set() as alias for subscripts (typed_array[]) +// * Gradually migrating structure from Khronos spec to ES2015 spec +// +// Caveats: +// * Beyond 10000 or so entries, polyfilled array accessors (ta[0], +// etc) become memory-prohibitive, so array creation will fail. Set +// self.TYPED_ARRAY_POLYFILL_NO_ARRAY_ACCESSORS=true to disable +// creation of accessors. Your code will need to use the +// non-standard get()/set() instead, and will need to add those to +// native arrays for interop. +(function(global) { + 'use strict'; + var undefined = (void 0); // Paranoia + + // Beyond this value, index getters/setters (i.e. array[0], array[1]) are so slow to + // create, and consume so much memory, that the browser appears frozen. + var MAX_ARRAY_LENGTH = 1e5; + + // Approximations of internal ECMAScript conversion functions + function Type(v) { + switch(typeof v) { + case 'undefined': return 'undefined'; + case 'boolean': return 'boolean'; + case 'number': return 'number'; + case 'string': return 'string'; + default: return v === null ? 'null' : 'object'; + } + } + + // Class returns internal [[Class]] property, used to avoid cross-frame instanceof issues: + function Class(v) { return Object.prototype.toString.call(v).replace(/^\[object *|\]$/g, ''); } + function IsCallable(o) { return typeof o === 'function'; } + function ToObject(v) { + if (v === null || v === undefined) throw TypeError(); + return Object(v); + } + function ToInt32(v) { return v >> 0; } + function ToUint32(v) { return v >>> 0; } + + // Snapshot intrinsics + var LN2 = Math.LN2, + abs = Math.abs, + floor = Math.floor, + log = Math.log, + max = Math.max, + min = Math.min, + pow = Math.pow, + round = Math.round; + + // emulate ES5 getter/setter API using legacy APIs + // http://blogs.msdn.com/b/ie/archive/2010/09/07/transitioning-existing-code-to-the-es5-getter-setter-apis.aspx + // (second clause tests for Object.defineProperty() in IE<9 that only supports extending DOM prototypes, but + // note that IE<9 does not support __defineGetter__ or __defineSetter__ so it just renders the method harmless) + + (function() { + var orig = Object.defineProperty; + var dom_only = !(function(){try{return Object.defineProperty({},'x',{});}catch(_){return false;}}()); + + if (!orig || dom_only) { + Object.defineProperty = function (o, prop, desc) { + // In IE8 try built-in implementation for defining properties on DOM prototypes. + if (orig) + try { return orig(o, prop, desc); } catch (_) {} + if (o !== Object(o)) + throw TypeError('Object.defineProperty called on non-object'); + if (Object.prototype.__defineGetter__ && ('get' in desc)) + Object.prototype.__defineGetter__.call(o, prop, desc.get); + if (Object.prototype.__defineSetter__ && ('set' in desc)) + Object.prototype.__defineSetter__.call(o, prop, desc.set); + if ('value' in desc) + o[prop] = desc.value; + return o; + }; + } + }()); + + // ES5: Make obj[index] an alias for obj._getter(index)/obj._setter(index, value) + // for index in 0 ... obj.length + function makeArrayAccessors(obj) { + if ('TYPED_ARRAY_POLYFILL_NO_ARRAY_ACCESSORS' in global) + return; + + if (obj.length > MAX_ARRAY_LENGTH) throw RangeError('Array too large for polyfill'); + + function makeArrayAccessor(index) { + Object.defineProperty(obj, index, { + 'get': function() { return obj._getter(index); }, + 'set': function(v) { obj._setter(index, v); }, + enumerable: true, + configurable: false + }); + } + + var i; + for (i = 0; i < obj.length; i += 1) { + makeArrayAccessor(i); + } + } + + // Internal conversion functions: + // pack() - take a number (interpreted as Type), output a byte array + // unpack() - take a byte array, output a Type-like number + + function as_signed(value, bits) { var s = 32 - bits; return (value << s) >> s; } + function as_unsigned(value, bits) { var s = 32 - bits; return (value << s) >>> s; } + + function packI8(n) { return [n & 0xff]; } + function unpackI8(bytes) { return as_signed(bytes[0], 8); } + + function packU8(n) { return [n & 0xff]; } + function unpackU8(bytes) { return as_unsigned(bytes[0], 8); } + + function packU8Clamped(n) { n = round(Number(n)); return [n < 0 ? 0 : n > 0xff ? 0xff : n & 0xff]; } + + function packI16(n) { return [n & 0xff, (n >> 8) & 0xff]; } + function unpackI16(bytes) { return as_signed(bytes[1] << 8 | bytes[0], 16); } + + function packU16(n) { return [n & 0xff, (n >> 8) & 0xff]; } + function unpackU16(bytes) { return as_unsigned(bytes[1] << 8 | bytes[0], 16); } + + function packI32(n) { return [n & 0xff, (n >> 8) & 0xff, (n >> 16) & 0xff, (n >> 24) & 0xff]; } + function unpackI32(bytes) { return as_signed(bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0], 32); } + + function packU32(n) { return [n & 0xff, (n >> 8) & 0xff, (n >> 16) & 0xff, (n >> 24) & 0xff]; } + function unpackU32(bytes) { return as_unsigned(bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0], 32); } + + function packIEEE754(v, ebits, fbits) { + + var bias = (1 << (ebits - 1)) - 1; + + function roundToEven(n) { + var w = floor(n), f = n - w; + if (f < 0.5) + return w; + if (f > 0.5) + return w + 1; + return w % 2 ? w + 1 : w; + } + + // Compute sign, exponent, fraction + var s, e, f; + if (v !== v) { + // NaN + // http://dev.w3.org/2006/webapi/WebIDL/#es-type-mapping + e = (1 << ebits) - 1; f = pow(2, fbits - 1); s = 0; + } else if (v === Infinity || v === -Infinity) { + e = (1 << ebits) - 1; f = 0; s = (v < 0) ? 1 : 0; + } else if (v === 0) { + e = 0; f = 0; s = (1 / v === -Infinity) ? 1 : 0; + } else { + s = v < 0; + v = abs(v); + + if (v >= pow(2, 1 - bias)) { + // Normalized + e = min(floor(log(v) / LN2), 1023); + var significand = v / pow(2, e); + if (significand < 1) { + e -= 1; + significand *= 2; + } + if (significand >= 2) { + e += 1; + significand /= 2; + } + var d = pow(2, fbits); + f = roundToEven(significand * d) - d; + e += bias; + if (f / d >= 1) { + e += 1; + f = 0; + } + if (e > 2 * bias) { + // Overflow + e = (1 << ebits) - 1; + f = 0; + } + } else { + // Denormalized + e = 0; + f = roundToEven(v / pow(2, 1 - bias - fbits)); + } + } + + // Pack sign, exponent, fraction + var bits = [], i; + for (i = fbits; i; i -= 1) { bits.push(f % 2 ? 1 : 0); f = floor(f / 2); } + for (i = ebits; i; i -= 1) { bits.push(e % 2 ? 1 : 0); e = floor(e / 2); } + bits.push(s ? 1 : 0); + bits.reverse(); + var str = bits.join(''); + + // Bits to bytes + var bytes = []; + while (str.length) { + bytes.unshift(parseInt(str.substring(0, 8), 2)); + str = str.substring(8); + } + return bytes; + } + + function unpackIEEE754(bytes, ebits, fbits) { + // Bytes to bits + var bits = [], i, j, b, str, + bias, s, e, f; + + for (i = 0; i < bytes.length; ++i) { + b = bytes[i]; + for (j = 8; j; j -= 1) { + bits.push(b % 2 ? 1 : 0); b = b >> 1; + } + } + bits.reverse(); + str = bits.join(''); + + // Unpack sign, exponent, fraction + bias = (1 << (ebits - 1)) - 1; + s = parseInt(str.substring(0, 1), 2) ? -1 : 1; + e = parseInt(str.substring(1, 1 + ebits), 2); + f = parseInt(str.substring(1 + ebits), 2); + + // Produce number + if (e === (1 << ebits) - 1) { + return f !== 0 ? NaN : s * Infinity; + } else if (e > 0) { + // Normalized + return s * pow(2, e - bias) * (1 + f / pow(2, fbits)); + } else if (f !== 0) { + // Denormalized + return s * pow(2, -(bias - 1)) * (f / pow(2, fbits)); + } else { + return s < 0 ? -0 : 0; + } + } + + function unpackF64(b) { return unpackIEEE754(b, 11, 52); } + function packF64(v) { return packIEEE754(v, 11, 52); } + function unpackF32(b) { return unpackIEEE754(b, 8, 23); } + function packF32(v) { return packIEEE754(v, 8, 23); } + + // + // 3 The ArrayBuffer Type + // + + (function() { + + function ArrayBuffer(length) { + length = ToInt32(length); + if (length < 0) throw RangeError('ArrayBuffer size is not a small enough positive integer.'); + Object.defineProperty(this, 'byteLength', {value: length}); + Object.defineProperty(this, '_bytes', {value: Array(length)}); + + for (var i = 0; i < length; i += 1) + this._bytes[i] = 0; + } + + global.ArrayBuffer = global.ArrayBuffer || ArrayBuffer; + + // + // 5 The Typed Array View Types + // + + function $TypedArray$() { + + // %TypedArray% ( length ) + if (!arguments.length || typeof arguments[0] !== 'object') { + return (function(length) { + length = ToInt32(length); + if (length < 0) throw RangeError('length is not a small enough positive integer.'); + Object.defineProperty(this, 'length', {value: length}); + Object.defineProperty(this, 'byteLength', {value: length * this.BYTES_PER_ELEMENT}); + Object.defineProperty(this, 'buffer', {value: new ArrayBuffer(this.byteLength)}); + Object.defineProperty(this, 'byteOffset', {value: 0}); + + }).apply(this, arguments); + } + + // %TypedArray% ( typedArray ) + if (arguments.length >= 1 && + Type(arguments[0]) === 'object' && + arguments[0] instanceof $TypedArray$) { + return (function(typedArray){ + if (this.constructor !== typedArray.constructor) throw TypeError(); + + var byteLength = typedArray.length * this.BYTES_PER_ELEMENT; + Object.defineProperty(this, 'buffer', {value: new ArrayBuffer(byteLength)}); + Object.defineProperty(this, 'byteLength', {value: byteLength}); + Object.defineProperty(this, 'byteOffset', {value: 0}); + Object.defineProperty(this, 'length', {value: typedArray.length}); + + for (var i = 0; i < this.length; i += 1) + this._setter(i, typedArray._getter(i)); + + }).apply(this, arguments); + } + + // %TypedArray% ( array ) + if (arguments.length >= 1 && + Type(arguments[0]) === 'object' && + !(arguments[0] instanceof $TypedArray$) && + !(arguments[0] instanceof ArrayBuffer || Class(arguments[0]) === 'ArrayBuffer')) { + return (function(array) { + + var byteLength = array.length * this.BYTES_PER_ELEMENT; + Object.defineProperty(this, 'buffer', {value: new ArrayBuffer(byteLength)}); + Object.defineProperty(this, 'byteLength', {value: byteLength}); + Object.defineProperty(this, 'byteOffset', {value: 0}); + Object.defineProperty(this, 'length', {value: array.length}); + + for (var i = 0; i < this.length; i += 1) { + var s = array[i]; + this._setter(i, Number(s)); + } + }).apply(this, arguments); + } + + // %TypedArray% ( buffer, byteOffset=0, length=undefined ) + if (arguments.length >= 1 && + Type(arguments[0]) === 'object' && + (arguments[0] instanceof ArrayBuffer || Class(arguments[0]) === 'ArrayBuffer')) { + return (function(buffer, byteOffset, length) { + + byteOffset = ToUint32(byteOffset); + if (byteOffset > buffer.byteLength) + throw RangeError('byteOffset out of range'); + + // The given byteOffset must be a multiple of the element + // size of the specific type, otherwise an exception is raised. + if (byteOffset % this.BYTES_PER_ELEMENT) + throw RangeError('buffer length minus the byteOffset is not a multiple of the element size.'); + + if (length === undefined) { + var byteLength = buffer.byteLength - byteOffset; + if (byteLength % this.BYTES_PER_ELEMENT) + throw RangeError('length of buffer minus byteOffset not a multiple of the element size'); + length = byteLength / this.BYTES_PER_ELEMENT; + + } else { + length = ToUint32(length); + byteLength = length * this.BYTES_PER_ELEMENT; + } + + if ((byteOffset + byteLength) > buffer.byteLength) + throw RangeError('byteOffset and length reference an area beyond the end of the buffer'); + + Object.defineProperty(this, 'buffer', {value: buffer}); + Object.defineProperty(this, 'byteLength', {value: byteLength}); + Object.defineProperty(this, 'byteOffset', {value: byteOffset}); + Object.defineProperty(this, 'length', {value: length}); + + }).apply(this, arguments); + } + + // %TypedArray% ( all other argument combinations ) + throw TypeError(); + } + + // Properties of the %TypedArray Instrinsic Object + + // %TypedArray%.from ( source , mapfn=undefined, thisArg=undefined ) + Object.defineProperty($TypedArray$, 'from', {value: function(iterable) { + return new this(iterable); + }}); + + // %TypedArray%.of ( ...items ) + Object.defineProperty($TypedArray$, 'of', {value: function(/*...items*/) { + return new this(arguments); + }}); + + // %TypedArray%.prototype + var $TypedArrayPrototype$ = {}; + $TypedArray$.prototype = $TypedArrayPrototype$; + + // WebIDL: getter type (unsigned long index); + Object.defineProperty($TypedArray$.prototype, '_getter', {value: function(index) { + if (arguments.length < 1) throw SyntaxError('Not enough arguments'); + + index = ToUint32(index); + if (index >= this.length) + return undefined; + + var bytes = [], i, o; + for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT; + i < this.BYTES_PER_ELEMENT; + i += 1, o += 1) { + bytes.push(this.buffer._bytes[o]); + } + return this._unpack(bytes); + }}); + + // NONSTANDARD: convenience alias for getter: type get(unsigned long index); + Object.defineProperty($TypedArray$.prototype, 'get', {value: $TypedArray$.prototype._getter}); + + // WebIDL: setter void (unsigned long index, type value); + Object.defineProperty($TypedArray$.prototype, '_setter', {value: function(index, value) { + if (arguments.length < 2) throw SyntaxError('Not enough arguments'); + + index = ToUint32(index); + if (index >= this.length) + return; + + var bytes = this._pack(value), i, o; + for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT; + i < this.BYTES_PER_ELEMENT; + i += 1, o += 1) { + this.buffer._bytes[o] = bytes[i]; + } + }}); + + // get %TypedArray%.prototype.buffer + // get %TypedArray%.prototype.byteLength + // get %TypedArray%.prototype.byteOffset + // -- applied directly to the object in the constructor + + // %TypedArray%.prototype.constructor + Object.defineProperty($TypedArray$.prototype, 'constructor', {value: $TypedArray$}); + + // %TypedArray%.prototype.copyWithin (target, start, end = this.length ) + Object.defineProperty($TypedArray$.prototype, 'copyWithin', {value: function(target, start) { + var end = arguments[2]; + + var o = ToObject(this); + var lenVal = o.length; + var len = ToUint32(lenVal); + len = max(len, 0); + var relativeTarget = ToInt32(target); + var to; + if (relativeTarget < 0) + to = max(len + relativeTarget, 0); + else + to = min(relativeTarget, len); + var relativeStart = ToInt32(start); + var from; + if (relativeStart < 0) + from = max(len + relativeStart, 0); + else + from = min(relativeStart, len); + var relativeEnd; + if (end === undefined) + relativeEnd = len; + else + relativeEnd = ToInt32(end); + var final; + if (relativeEnd < 0) + final = max(len + relativeEnd, 0); + else + final = min(relativeEnd, len); + var count = min(final - from, len - to); + var direction; + if (from < to && to < from + count) { + direction = -1; + from = from + count - 1; + to = to + count - 1; + } else { + direction = 1; + } + while (count > 0) { + o._setter(to, o._getter(from)); + from = from + direction; + to = to + direction; + count = count - 1; + } + return o; + }}); + + // %TypedArray%.prototype.entries ( ) + // -- defined in es6.js to shim browsers w/ native TypedArrays + + // %TypedArray%.prototype.every ( callbackfn, thisArg = undefined ) + Object.defineProperty($TypedArray$.prototype, 'every', {value: function(callbackfn) { + if (this === undefined || this === null) throw TypeError(); + var t = Object(this); + var len = ToUint32(t.length); + if (!IsCallable(callbackfn)) throw TypeError(); + var thisArg = arguments[1]; + for (var i = 0; i < len; i++) { + if (!callbackfn.call(thisArg, t._getter(i), i, t)) + return false; + } + return true; + }}); + + // %TypedArray%.prototype.fill (value, start = 0, end = this.length ) + Object.defineProperty($TypedArray$.prototype, 'fill', {value: function(value) { + var start = arguments[1], + end = arguments[2]; + + var o = ToObject(this); + var lenVal = o.length; + var len = ToUint32(lenVal); + len = max(len, 0); + var relativeStart = ToInt32(start); + var k; + if (relativeStart < 0) + k = max((len + relativeStart), 0); + else + k = min(relativeStart, len); + var relativeEnd; + if (end === undefined) + relativeEnd = len; + else + relativeEnd = ToInt32(end); + var final; + if (relativeEnd < 0) + final = max((len + relativeEnd), 0); + else + final = min(relativeEnd, len); + while (k < final) { + o._setter(k, value); + k += 1; + } + return o; + }}); + + // %TypedArray%.prototype.filter ( callbackfn, thisArg = undefined ) + Object.defineProperty($TypedArray$.prototype, 'filter', {value: function(callbackfn) { + if (this === undefined || this === null) throw TypeError(); + var t = Object(this); + var len = ToUint32(t.length); + if (!IsCallable(callbackfn)) throw TypeError(); + var res = []; + var thisp = arguments[1]; + for (var i = 0; i < len; i++) { + var val = t._getter(i); // in case fun mutates this + if (callbackfn.call(thisp, val, i, t)) + res.push(val); + } + return new this.constructor(res); + }}); + + // %TypedArray%.prototype.find (predicate, thisArg = undefined) + Object.defineProperty($TypedArray$.prototype, 'find', {value: function(predicate) { + var o = ToObject(this); + var lenValue = o.length; + var len = ToUint32(lenValue); + if (!IsCallable(predicate)) throw TypeError(); + var t = arguments.length > 1 ? arguments[1] : undefined; + var k = 0; + while (k < len) { + var kValue = o._getter(k); + var testResult = predicate.call(t, kValue, k, o); + if (Boolean(testResult)) + return kValue; + ++k; + } + return undefined; + }}); + + // %TypedArray%.prototype.findIndex ( predicate, thisArg = undefined ) + Object.defineProperty($TypedArray$.prototype, 'findIndex', {value: function(predicate) { + var o = ToObject(this); + var lenValue = o.length; + var len = ToUint32(lenValue); + if (!IsCallable(predicate)) throw TypeError(); + var t = arguments.length > 1 ? arguments[1] : undefined; + var k = 0; + while (k < len) { + var kValue = o._getter(k); + var testResult = predicate.call(t, kValue, k, o); + if (Boolean(testResult)) + return k; + ++k; + } + return -1; + }}); + + // %TypedArray%.prototype.forEach ( callbackfn, thisArg = undefined ) + Object.defineProperty($TypedArray$.prototype, 'forEach', {value: function(callbackfn) { + if (this === undefined || this === null) throw TypeError(); + var t = Object(this); + var len = ToUint32(t.length); + if (!IsCallable(callbackfn)) throw TypeError(); + var thisp = arguments[1]; + for (var i = 0; i < len; i++) + callbackfn.call(thisp, t._getter(i), i, t); + }}); + + // %TypedArray%.prototype.indexOf (searchElement, fromIndex = 0 ) + Object.defineProperty($TypedArray$.prototype, 'indexOf', {value: function(searchElement) { + if (this === undefined || this === null) throw TypeError(); + var t = Object(this); + var len = ToUint32(t.length); + if (len === 0) return -1; + var n = 0; + if (arguments.length > 0) { + n = Number(arguments[1]); + if (n !== n) { + n = 0; + } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) { + n = (n > 0 || -1) * floor(abs(n)); + } + } + if (n >= len) return -1; + var k = n >= 0 ? n : max(len - abs(n), 0); + for (; k < len; k++) { + if (t._getter(k) === searchElement) { + return k; + } + } + return -1; + }}); + + // %TypedArray%.prototype.join ( separator ) + Object.defineProperty($TypedArray$.prototype, 'join', {value: function(separator) { + if (this === undefined || this === null) throw TypeError(); + var t = Object(this); + var len = ToUint32(t.length); + var tmp = Array(len); + for (var i = 0; i < len; ++i) + tmp[i] = t._getter(i); + return tmp.join(separator === undefined ? ',' : separator); // Hack for IE7 + }}); + + // %TypedArray%.prototype.keys ( ) + // -- defined in es6.js to shim browsers w/ native TypedArrays + + // %TypedArray%.prototype.lastIndexOf ( searchElement, fromIndex = this.length-1 ) + Object.defineProperty($TypedArray$.prototype, 'lastIndexOf', {value: function(searchElement) { + if (this === undefined || this === null) throw TypeError(); + var t = Object(this); + var len = ToUint32(t.length); + if (len === 0) return -1; + var n = len; + if (arguments.length > 1) { + n = Number(arguments[1]); + if (n !== n) { + n = 0; + } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) { + n = (n > 0 || -1) * floor(abs(n)); + } + } + var k = n >= 0 ? min(n, len - 1) : len - abs(n); + for (; k >= 0; k--) { + if (t._getter(k) === searchElement) + return k; + } + return -1; + }}); + + // get %TypedArray%.prototype.length + // -- applied directly to the object in the constructor + + // %TypedArray%.prototype.map ( callbackfn, thisArg = undefined ) + Object.defineProperty($TypedArray$.prototype, 'map', {value: function(callbackfn) { + if (this === undefined || this === null) throw TypeError(); + var t = Object(this); + var len = ToUint32(t.length); + if (!IsCallable(callbackfn)) throw TypeError(); + var res = []; res.length = len; + var thisp = arguments[1]; + for (var i = 0; i < len; i++) + res[i] = callbackfn.call(thisp, t._getter(i), i, t); + return new this.constructor(res); + }}); + + // %TypedArray%.prototype.reduce ( callbackfn [, initialValue] ) + Object.defineProperty($TypedArray$.prototype, 'reduce', {value: function(callbackfn) { + if (this === undefined || this === null) throw TypeError(); + var t = Object(this); + var len = ToUint32(t.length); + if (!IsCallable(callbackfn)) throw TypeError(); + // no value to return if no initial value and an empty array + if (len === 0 && arguments.length === 1) throw TypeError(); + var k = 0; + var accumulator; + if (arguments.length >= 2) { + accumulator = arguments[1]; + } else { + accumulator = t._getter(k++); + } + while (k < len) { + accumulator = callbackfn.call(undefined, accumulator, t._getter(k), k, t); + k++; + } + return accumulator; + }}); + + // %TypedArray%.prototype.reduceRight ( callbackfn [, initialValue] ) + Object.defineProperty($TypedArray$.prototype, 'reduceRight', {value: function(callbackfn) { + if (this === undefined || this === null) throw TypeError(); + var t = Object(this); + var len = ToUint32(t.length); + if (!IsCallable(callbackfn)) throw TypeError(); + // no value to return if no initial value, empty array + if (len === 0 && arguments.length === 1) throw TypeError(); + var k = len - 1; + var accumulator; + if (arguments.length >= 2) { + accumulator = arguments[1]; + } else { + accumulator = t._getter(k--); + } + while (k >= 0) { + accumulator = callbackfn.call(undefined, accumulator, t._getter(k), k, t); + k--; + } + return accumulator; + }}); + + // %TypedArray%.prototype.reverse ( ) + Object.defineProperty($TypedArray$.prototype, 'reverse', {value: function() { + if (this === undefined || this === null) throw TypeError(); + var t = Object(this); + var len = ToUint32(t.length); + var half = floor(len / 2); + for (var i = 0, j = len - 1; i < half; ++i, --j) { + var tmp = t._getter(i); + t._setter(i, t._getter(j)); + t._setter(j, tmp); + } + return t; + }}); + + // %TypedArray%.prototype.set(array, offset = 0 ) + // %TypedArray%.prototype.set(typedArray, offset = 0 ) + // WebIDL: void set(TypedArray array, optional unsigned long offset); + // WebIDL: void set(sequence array, optional unsigned long offset); + Object.defineProperty($TypedArray$.prototype, 'set', {value: function(index, value) { + if (arguments.length < 1) throw SyntaxError('Not enough arguments'); + var array, sequence, offset, len, + i, s, d, + byteOffset, byteLength, tmp; + + if (typeof arguments[0] === 'object' && arguments[0].constructor === this.constructor) { + // void set(TypedArray array, optional unsigned long offset); + array = arguments[0]; + offset = ToUint32(arguments[1]); + + if (offset + array.length > this.length) { + throw RangeError('Offset plus length of array is out of range'); + } + + byteOffset = this.byteOffset + offset * this.BYTES_PER_ELEMENT; + byteLength = array.length * this.BYTES_PER_ELEMENT; + + if (array.buffer === this.buffer) { + tmp = []; + for (i = 0, s = array.byteOffset; i < byteLength; i += 1, s += 1) { + tmp[i] = array.buffer._bytes[s]; + } + for (i = 0, d = byteOffset; i < byteLength; i += 1, d += 1) { + this.buffer._bytes[d] = tmp[i]; + } + } else { + for (i = 0, s = array.byteOffset, d = byteOffset; + i < byteLength; i += 1, s += 1, d += 1) { + this.buffer._bytes[d] = array.buffer._bytes[s]; + } + } + } else if (typeof arguments[0] === 'object' && typeof arguments[0].length !== 'undefined') { + // void set(sequence array, optional unsigned long offset); + sequence = arguments[0]; + len = ToUint32(sequence.length); + offset = ToUint32(arguments[1]); + + if (offset + len > this.length) { + throw RangeError('Offset plus length of array is out of range'); + } + + for (i = 0; i < len; i += 1) { + s = sequence[i]; + this._setter(offset + i, Number(s)); + } + } else { + throw TypeError('Unexpected argument type(s)'); + } + }}); + + // %TypedArray%.prototype.slice ( start, end ) + Object.defineProperty($TypedArray$.prototype, 'slice', {value: function(start, end) { + var o = ToObject(this); + var lenVal = o.length; + var len = ToUint32(lenVal); + var relativeStart = ToInt32(start); + var k = (relativeStart < 0) ? max(len + relativeStart, 0) : min(relativeStart, len); + var relativeEnd = (end === undefined) ? len : ToInt32(end); + var final = (relativeEnd < 0) ? max(len + relativeEnd, 0) : min(relativeEnd, len); + var count = final - k; + var c = o.constructor; + var a = new c(count); + var n = 0; + while (k < final) { + var kValue = o._getter(k); + a._setter(n, kValue); + ++k; + ++n; + } + return a; + }}); + + // %TypedArray%.prototype.some ( callbackfn, thisArg = undefined ) + Object.defineProperty($TypedArray$.prototype, 'some', {value: function(callbackfn) { + if (this === undefined || this === null) throw TypeError(); + var t = Object(this); + var len = ToUint32(t.length); + if (!IsCallable(callbackfn)) throw TypeError(); + var thisp = arguments[1]; + for (var i = 0; i < len; i++) { + if (callbackfn.call(thisp, t._getter(i), i, t)) { + return true; + } + } + return false; + }}); + + // %TypedArray%.prototype.sort ( comparefn ) + Object.defineProperty($TypedArray$.prototype, 'sort', {value: function(comparefn) { + if (this === undefined || this === null) throw TypeError(); + var t = Object(this); + var len = ToUint32(t.length); + var tmp = Array(len); + for (var i = 0; i < len; ++i) + tmp[i] = t._getter(i); + if (comparefn) tmp.sort(comparefn); else tmp.sort(); // Hack for IE8/9 + for (i = 0; i < len; ++i) + t._setter(i, tmp[i]); + return t; + }}); + + // %TypedArray%.prototype.subarray(begin = 0, end = this.length ) + // WebIDL: TypedArray subarray(long begin, optional long end); + Object.defineProperty($TypedArray$.prototype, 'subarray', {value: function(start, end) { + function clamp(v, min, max) { return v < min ? min : v > max ? max : v; } + + start = ToInt32(start); + end = ToInt32(end); + + if (arguments.length < 1) { start = 0; } + if (arguments.length < 2) { end = this.length; } + + if (start < 0) { start = this.length + start; } + if (end < 0) { end = this.length + end; } + + start = clamp(start, 0, this.length); + end = clamp(end, 0, this.length); + + var len = end - start; + if (len < 0) { + len = 0; + } + + return new this.constructor( + this.buffer, this.byteOffset + start * this.BYTES_PER_ELEMENT, len); + }}); + + // %TypedArray%.prototype.toLocaleString ( ) + // %TypedArray%.prototype.toString ( ) + // %TypedArray%.prototype.values ( ) + // %TypedArray%.prototype [ @@iterator ] ( ) + // get %TypedArray%.prototype [ @@toStringTag ] + // -- defined in es6.js to shim browsers w/ native TypedArrays + + function makeTypedArray(elementSize, pack, unpack) { + // Each TypedArray type requires a distinct constructor instance with + // identical logic, which this produces. + var TypedArray = function() { + Object.defineProperty(this, 'constructor', {value: TypedArray}); + $TypedArray$.apply(this, arguments); + makeArrayAccessors(this); + }; + if ('__proto__' in TypedArray) { + TypedArray.__proto__ = $TypedArray$; + } else { + TypedArray.from = $TypedArray$.from; + TypedArray.of = $TypedArray$.of; + } + + TypedArray.BYTES_PER_ELEMENT = elementSize; + + var TypedArrayPrototype = function() {}; + TypedArrayPrototype.prototype = $TypedArrayPrototype$; + + TypedArray.prototype = new TypedArrayPrototype(); + + Object.defineProperty(TypedArray.prototype, 'BYTES_PER_ELEMENT', {value: elementSize}); + Object.defineProperty(TypedArray.prototype, '_pack', {value: pack}); + Object.defineProperty(TypedArray.prototype, '_unpack', {value: unpack}); + + return TypedArray; + } + + var Int8Array = makeTypedArray(1, packI8, unpackI8); + var Uint8Array = makeTypedArray(1, packU8, unpackU8); + var Uint8ClampedArray = makeTypedArray(1, packU8Clamped, unpackU8); + var Int16Array = makeTypedArray(2, packI16, unpackI16); + var Uint16Array = makeTypedArray(2, packU16, unpackU16); + var Int32Array = makeTypedArray(4, packI32, unpackI32); + var Uint32Array = makeTypedArray(4, packU32, unpackU32); + var Float32Array = makeTypedArray(4, packF32, unpackF32); + var Float64Array = makeTypedArray(8, packF64, unpackF64); + + global.Int8Array = global.Int8Array || Int8Array; + global.Uint8Array = global.Uint8Array || Uint8Array; + global.Uint8ClampedArray = global.Uint8ClampedArray || Uint8ClampedArray; + global.Int16Array = global.Int16Array || Int16Array; + global.Uint16Array = global.Uint16Array || Uint16Array; + global.Int32Array = global.Int32Array || Int32Array; + global.Uint32Array = global.Uint32Array || Uint32Array; + global.Float32Array = global.Float32Array || Float32Array; + global.Float64Array = global.Float64Array || Float64Array; + }()); + + // + // 6 The DataView View Type + // + + (function() { + function r(array, index) { + return IsCallable(array.get) ? array.get(index) : array[index]; + } + + var IS_BIG_ENDIAN = (function() { + var u16array = new Uint16Array([0x1234]), + u8array = new Uint8Array(u16array.buffer); + return r(u8array, 0) === 0x12; + }()); + + // DataView(buffer, byteOffset=0, byteLength=undefined) + // WebIDL: Constructor(ArrayBuffer buffer, + // optional unsigned long byteOffset, + // optional unsigned long byteLength) + function DataView(buffer, byteOffset, byteLength) { + if (!(buffer instanceof ArrayBuffer || Class(buffer) === 'ArrayBuffer')) throw TypeError(); + + byteOffset = ToUint32(byteOffset); + if (byteOffset > buffer.byteLength) + throw RangeError('byteOffset out of range'); + + if (byteLength === undefined) + byteLength = buffer.byteLength - byteOffset; + else + byteLength = ToUint32(byteLength); + + if ((byteOffset + byteLength) > buffer.byteLength) + throw RangeError('byteOffset and length reference an area beyond the end of the buffer'); + + Object.defineProperty(this, 'buffer', {value: buffer}); + Object.defineProperty(this, 'byteLength', {value: byteLength}); + Object.defineProperty(this, 'byteOffset', {value: byteOffset}); + }; + + // get DataView.prototype.buffer + // get DataView.prototype.byteLength + // get DataView.prototype.byteOffset + // -- applied directly to instances by the constructor + + function makeGetter(arrayType) { + return function GetViewValue(byteOffset, littleEndian) { + byteOffset = ToUint32(byteOffset); + + if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength) + throw RangeError('Array index out of range'); + + byteOffset += this.byteOffset; + + var uint8Array = new Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT), + bytes = []; + for (var i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1) + bytes.push(r(uint8Array, i)); + + if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN)) + bytes.reverse(); + + return r(new arrayType(new Uint8Array(bytes).buffer), 0); + }; + } + + Object.defineProperty(DataView.prototype, 'getUint8', {value: makeGetter(Uint8Array)}); + Object.defineProperty(DataView.prototype, 'getInt8', {value: makeGetter(Int8Array)}); + Object.defineProperty(DataView.prototype, 'getUint16', {value: makeGetter(Uint16Array)}); + Object.defineProperty(DataView.prototype, 'getInt16', {value: makeGetter(Int16Array)}); + Object.defineProperty(DataView.prototype, 'getUint32', {value: makeGetter(Uint32Array)}); + Object.defineProperty(DataView.prototype, 'getInt32', {value: makeGetter(Int32Array)}); + Object.defineProperty(DataView.prototype, 'getFloat32', {value: makeGetter(Float32Array)}); + Object.defineProperty(DataView.prototype, 'getFloat64', {value: makeGetter(Float64Array)}); + + function makeSetter(arrayType) { + return function SetViewValue(byteOffset, value, littleEndian) { + byteOffset = ToUint32(byteOffset); + if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength) + throw RangeError('Array index out of range'); + + // Get bytes + var typeArray = new arrayType([value]), + byteArray = new Uint8Array(typeArray.buffer), + bytes = [], i, byteView; + + for (i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1) + bytes.push(r(byteArray, i)); + + // Flip if necessary + if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN)) + bytes.reverse(); + + // Write them + byteView = new Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT); + byteView.set(bytes); + }; + } + + Object.defineProperty(DataView.prototype, 'setUint8', {value: makeSetter(Uint8Array)}); + Object.defineProperty(DataView.prototype, 'setInt8', {value: makeSetter(Int8Array)}); + Object.defineProperty(DataView.prototype, 'setUint16', {value: makeSetter(Uint16Array)}); + Object.defineProperty(DataView.prototype, 'setInt16', {value: makeSetter(Int16Array)}); + Object.defineProperty(DataView.prototype, 'setUint32', {value: makeSetter(Uint32Array)}); + Object.defineProperty(DataView.prototype, 'setInt32', {value: makeSetter(Int32Array)}); + Object.defineProperty(DataView.prototype, 'setFloat32', {value: makeSetter(Float32Array)}); + Object.defineProperty(DataView.prototype, 'setFloat64', {value: makeSetter(Float64Array)}); + + global.DataView = global.DataView || DataView; + + }()); + +}(self)); + +// https://github.com/ttaubert/node-arraybuffer-slice +// (c) 2014 Tim Taubert +// arraybuffer-slice may be freely distributed under the MIT license. + +(function (undefined) { + "use strict"; + + function clamp(val, length) { + val = (val|0) || 0; + + if (val < 0) { + return Math.max(val + length, 0); + } + + return Math.min(val, length); + } + + if (!ArrayBuffer.prototype.slice) { + ArrayBuffer.prototype.slice = function (from, to) { + var length = this.byteLength; + var begin = clamp(from, length); + var end = length; + + if (to !== undefined) { + end = clamp(to, length); + } + + if (begin > end) { + return new ArrayBuffer(0); + } + + var num = end - begin; + var target = new ArrayBuffer(num); + var targetArray = new Uint8Array(target); + + var sourceArray = new Uint8Array(this, begin, num); + targetArray.set(sourceArray); + + return target; + }; + } +})(); + +// This is free and unencumbered software released into the public domain. +// See LICENSE.md for more information. + +// If we're in node require encoding-indexes and attach it to the global. +/** + * @fileoverview Global |this| required for resolving indexes in node. + * @suppress {globalThis} + */ +if (typeof module !== "undefined" && module.exports) { + this["encoding-indexes"] = + require("./encoding-indexes.js")["encoding-indexes"]; +} + +(function(global) { + 'use strict'; + + // + // Utilities + // + + /** + * @param {number} a The number to test. + * @param {number} min The minimum value in the range, inclusive. + * @param {number} max The maximum value in the range, inclusive. + * @return {boolean} True if a >= min and a <= max. + */ + function inRange(a, min, max) { + return min <= a && a <= max; + } + + /** + * @param {!Array.<*>} array The array to check. + * @param {*} item The item to look for in the array. + * @return {boolean} True if the item appears in the array. + */ + function includes(array, item) { + return array.indexOf(item) !== -1; + } + + var floor = Math.floor; + + /** + * @param {*} o + * @return {Object} + */ + function ToDictionary(o) { + if (o === undefined) return {}; + if (o === Object(o)) return o; + throw TypeError('Could not convert argument to dictionary'); + } + + /** + * @param {string} string Input string of UTF-16 code units. + * @return {!Array.} Code points. + */ + function stringToCodePoints(string) { + // https://heycam.github.io/webidl/#dfn-obtain-unicode + + // 1. Let S be the DOMString value. + var s = String(string); + + // 2. Let n be the length of S. + var n = s.length; + + // 3. Initialize i to 0. + var i = 0; + + // 4. Initialize U to be an empty sequence of Unicode characters. + var u = []; + + // 5. While i < n: + while (i < n) { + + // 1. Let c be the code unit in S at index i. + var c = s.charCodeAt(i); + + // 2. Depending on the value of c: + + // c < 0xD800 or c > 0xDFFF + if (c < 0xD800 || c > 0xDFFF) { + // Append to U the Unicode character with code point c. + u.push(c); + } + + // 0xDC00 ≤ c ≤ 0xDFFF + else if (0xDC00 <= c && c <= 0xDFFF) { + // Append to U a U+FFFD REPLACEMENT CHARACTER. + u.push(0xFFFD); + } + + // 0xD800 ≤ c ≤ 0xDBFF + else if (0xD800 <= c && c <= 0xDBFF) { + // 1. If i = n−1, then append to U a U+FFFD REPLACEMENT + // CHARACTER. + if (i === n - 1) { + u.push(0xFFFD); + } + // 2. Otherwise, i < n−1: + else { + // 1. Let d be the code unit in S at index i+1. + var d = string.charCodeAt(i + 1); + + // 2. If 0xDC00 ≤ d ≤ 0xDFFF, then: + if (0xDC00 <= d && d <= 0xDFFF) { + // 1. Let a be c & 0x3FF. + var a = c & 0x3FF; + + // 2. Let b be d & 0x3FF. + var b = d & 0x3FF; + + // 3. Append to U the Unicode character with code point + // 2^16+2^10*a+b. + u.push(0x10000 + (a << 10) + b); + + // 4. Set i to i+1. + i += 1; + } + + // 3. Otherwise, d < 0xDC00 or d > 0xDFFF. Append to U a + // U+FFFD REPLACEMENT CHARACTER. + else { + u.push(0xFFFD); + } + } + } + + // 3. Set i to i+1. + i += 1; + } + + // 6. Return U. + return u; + } + + /** + * @param {!Array.} code_points Array of code points. + * @return {string} string String of UTF-16 code units. + */ + function codePointsToString(code_points) { + var s = ''; + for (var i = 0; i < code_points.length; ++i) { + var cp = code_points[i]; + if (cp <= 0xFFFF) { + s += String.fromCharCode(cp); + } else { + cp -= 0x10000; + s += String.fromCharCode((cp >> 10) + 0xD800, + (cp & 0x3FF) + 0xDC00); + } + } + return s; + } + + + // + // Implementation of Encoding specification + // https://encoding.spec.whatwg.org/ + // + + // + // 4. Terminology + // + + /** + * An ASCII byte is a byte in the range 0x00 to 0x7F, inclusive. + * @param {number} a The number to test. + * @return {boolean} True if a is in the range 0x00 to 0x7F, inclusive. + */ + function isASCIIByte(a) { + return 0x00 <= a && a <= 0x7F; + } + + /** + * An ASCII code point is a code point in the range U+0000 to + * U+007F, inclusive. + */ + var isASCIICodePoint = isASCIIByte; + + + /** + * End-of-stream is a special token that signifies no more tokens + * are in the stream. + * @const + */ var end_of_stream = -1; + + /** + * A stream represents an ordered sequence of tokens. + * + * @constructor + * @param {!(Array.|Uint8Array)} tokens Array of tokens that provide + * the stream. + */ + function Stream(tokens) { + /** @type {!Array.} */ + this.tokens = [].slice.call(tokens); + // Reversed as push/pop is more efficient than shift/unshift. + this.tokens.reverse(); + } + + Stream.prototype = { + /** + * @return {boolean} True if end-of-stream has been hit. + */ + endOfStream: function() { + return !this.tokens.length; + }, + + /** + * When a token is read from a stream, the first token in the + * stream must be returned and subsequently removed, and + * end-of-stream must be returned otherwise. + * + * @return {number} Get the next token from the stream, or + * end_of_stream. + */ + read: function() { + if (!this.tokens.length) + return end_of_stream; + return this.tokens.pop(); + }, + + /** + * When one or more tokens are prepended to a stream, those tokens + * must be inserted, in given order, before the first token in the + * stream. + * + * @param {(number|!Array.)} token The token(s) to prepend to the + * stream. + */ + prepend: function(token) { + if (Array.isArray(token)) { + var tokens = /**@type {!Array.}*/(token); + while (tokens.length) + this.tokens.push(tokens.pop()); + } else { + this.tokens.push(token); + } + }, + + /** + * When one or more tokens are pushed to a stream, those tokens + * must be inserted, in given order, after the last token in the + * stream. + * + * @param {(number|!Array.)} token The tokens(s) to push to the + * stream. + */ + push: function(token) { + if (Array.isArray(token)) { + var tokens = /**@type {!Array.}*/(token); + while (tokens.length) + this.tokens.unshift(tokens.shift()); + } else { + this.tokens.unshift(token); + } + } + }; + + // + // 5. Encodings + // + + // 5.1 Encoders and decoders + + /** @const */ + var finished = -1; + + /** + * @param {boolean} fatal If true, decoding errors raise an exception. + * @param {number=} opt_code_point Override the standard fallback code point. + * @return {number} The code point to insert on a decoding error. + */ + function decoderError(fatal, opt_code_point) { + if (fatal) + throw TypeError('Decoder error'); + return opt_code_point || 0xFFFD; + } + + /** + * @param {number} code_point The code point that could not be encoded. + * @return {number} Always throws, no value is actually returned. + */ + function encoderError(code_point) { + throw TypeError('The code point ' + code_point + ' could not be encoded.'); + } + + /** @interface */ + function Decoder() {} + Decoder.prototype = { + /** + * @param {Stream} stream The stream of bytes being decoded. + * @param {number} bite The next byte read from the stream. + * @return {?(number|!Array.)} The next code point(s) + * decoded, or null if not enough data exists in the input + * stream to decode a complete code point, or |finished|. + */ + handler: function(stream, bite) {} + }; + + /** @interface */ + function Encoder() {} + Encoder.prototype = { + /** + * @param {Stream} stream The stream of code points being encoded. + * @param {number} code_point Next code point read from the stream. + * @return {(number|!Array.)} Byte(s) to emit, or |finished|. + */ + handler: function(stream, code_point) {} + }; + + // 5.2 Names and labels + + // TODO: Define @typedef for Encoding: {name:string,labels:Array.} + // https://github.com/google/closure-compiler/issues/247 + + /** + * @param {string} label The encoding label. + * @return {?{name:string,labels:Array.}} + */ + function getEncoding(label) { + // 1. Remove any leading and trailing ASCII whitespace from label. + label = String(label).trim().toLowerCase(); + + // 2. If label is an ASCII case-insensitive match for any of the + // labels listed in the table below, return the corresponding + // encoding, and failure otherwise. + if (Object.prototype.hasOwnProperty.call(label_to_encoding, label)) { + return label_to_encoding[label]; + } + return null; + } + + /** + * Encodings table: https://encoding.spec.whatwg.org/encodings.json + * @const + * @type {!Array.<{ + * heading: string, + * encodings: Array.<{name:string,labels:Array.}> + * }>} + */ + var encodings = [ + { + "encodings": [ + { + "labels": [ + "unicode-1-1-utf-8", + "utf-8", + "utf8" + ], + "name": "UTF-8" + } + ], + "heading": "The Encoding" + }, + { + "encodings": [ + { + "labels": [ + "866", + "cp866", + "csibm866", + "ibm866" + ], + "name": "IBM866" + }, + { + "labels": [ + "csisolatin2", + "iso-8859-2", + "iso-ir-101", + "iso8859-2", + "iso88592", + "iso_8859-2", + "iso_8859-2:1987", + "l2", + "latin2" + ], + "name": "ISO-8859-2" + }, + { + "labels": [ + "csisolatin3", + "iso-8859-3", + "iso-ir-109", + "iso8859-3", + "iso88593", + "iso_8859-3", + "iso_8859-3:1988", + "l3", + "latin3" + ], + "name": "ISO-8859-3" + }, + { + "labels": [ + "csisolatin4", + "iso-8859-4", + "iso-ir-110", + "iso8859-4", + "iso88594", + "iso_8859-4", + "iso_8859-4:1988", + "l4", + "latin4" + ], + "name": "ISO-8859-4" + }, + { + "labels": [ + "csisolatincyrillic", + "cyrillic", + "iso-8859-5", + "iso-ir-144", + "iso8859-5", + "iso88595", + "iso_8859-5", + "iso_8859-5:1988" + ], + "name": "ISO-8859-5" + }, + { + "labels": [ + "arabic", + "asmo-708", + "csiso88596e", + "csiso88596i", + "csisolatinarabic", + "ecma-114", + "iso-8859-6", + "iso-8859-6-e", + "iso-8859-6-i", + "iso-ir-127", + "iso8859-6", + "iso88596", + "iso_8859-6", + "iso_8859-6:1987" + ], + "name": "ISO-8859-6" + }, + { + "labels": [ + "csisolatingreek", + "ecma-118", + "elot_928", + "greek", + "greek8", + "iso-8859-7", + "iso-ir-126", + "iso8859-7", + "iso88597", + "iso_8859-7", + "iso_8859-7:1987", + "sun_eu_greek" + ], + "name": "ISO-8859-7" + }, + { + "labels": [ + "csiso88598e", + "csisolatinhebrew", + "hebrew", + "iso-8859-8", + "iso-8859-8-e", + "iso-ir-138", + "iso8859-8", + "iso88598", + "iso_8859-8", + "iso_8859-8:1988", + "visual" + ], + "name": "ISO-8859-8" + }, + { + "labels": [ + "csiso88598i", + "iso-8859-8-i", + "logical" + ], + "name": "ISO-8859-8-I" + }, + { + "labels": [ + "csisolatin6", + "iso-8859-10", + "iso-ir-157", + "iso8859-10", + "iso885910", + "l6", + "latin6" + ], + "name": "ISO-8859-10" + }, + { + "labels": [ + "iso-8859-13", + "iso8859-13", + "iso885913" + ], + "name": "ISO-8859-13" + }, + { + "labels": [ + "iso-8859-14", + "iso8859-14", + "iso885914" + ], + "name": "ISO-8859-14" + }, + { + "labels": [ + "csisolatin9", + "iso-8859-15", + "iso8859-15", + "iso885915", + "iso_8859-15", + "l9" + ], + "name": "ISO-8859-15" + }, + { + "labels": [ + "iso-8859-16" + ], + "name": "ISO-8859-16" + }, + { + "labels": [ + "cskoi8r", + "koi", + "koi8", + "koi8-r", + "koi8_r" + ], + "name": "KOI8-R" + }, + { + "labels": [ + "koi8-ru", + "koi8-u" + ], + "name": "KOI8-U" + }, + { + "labels": [ + "csmacintosh", + "mac", + "macintosh", + "x-mac-roman" + ], + "name": "macintosh" + }, + { + "labels": [ + "dos-874", + "iso-8859-11", + "iso8859-11", + "iso885911", + "tis-620", + "windows-874" + ], + "name": "windows-874" + }, + { + "labels": [ + "cp1250", + "windows-1250", + "x-cp1250" + ], + "name": "windows-1250" + }, + { + "labels": [ + "cp1251", + "windows-1251", + "x-cp1251" + ], + "name": "windows-1251" + }, + { + "labels": [ + "ansi_x3.4-1968", + "ascii", + "cp1252", + "cp819", + "csisolatin1", + "ibm819", + "iso-8859-1", + "iso-ir-100", + "iso8859-1", + "iso88591", + "iso_8859-1", + "iso_8859-1:1987", + "l1", + "latin1", + "us-ascii", + "windows-1252", + "x-cp1252" + ], + "name": "windows-1252" + }, + { + "labels": [ + "cp1253", + "windows-1253", + "x-cp1253" + ], + "name": "windows-1253" + }, + { + "labels": [ + "cp1254", + "csisolatin5", + "iso-8859-9", + "iso-ir-148", + "iso8859-9", + "iso88599", + "iso_8859-9", + "iso_8859-9:1989", + "l5", + "latin5", + "windows-1254", + "x-cp1254" + ], + "name": "windows-1254" + }, + { + "labels": [ + "cp1255", + "windows-1255", + "x-cp1255" + ], + "name": "windows-1255" + }, + { + "labels": [ + "cp1256", + "windows-1256", + "x-cp1256" + ], + "name": "windows-1256" + }, + { + "labels": [ + "cp1257", + "windows-1257", + "x-cp1257" + ], + "name": "windows-1257" + }, + { + "labels": [ + "cp1258", + "windows-1258", + "x-cp1258" + ], + "name": "windows-1258" + }, + { + "labels": [ + "x-mac-cyrillic", + "x-mac-ukrainian" + ], + "name": "x-mac-cyrillic" + } + ], + "heading": "Legacy single-byte encodings" + }, + { + "encodings": [ + { + "labels": [ + "chinese", + "csgb2312", + "csiso58gb231280", + "gb2312", + "gb_2312", + "gb_2312-80", + "gbk", + "iso-ir-58", + "x-gbk" + ], + "name": "GBK" + }, + { + "labels": [ + "gb18030" + ], + "name": "gb18030" + } + ], + "heading": "Legacy multi-byte Chinese (simplified) encodings" + }, + { + "encodings": [ + { + "labels": [ + "big5", + "big5-hkscs", + "cn-big5", + "csbig5", + "x-x-big5" + ], + "name": "Big5" + } + ], + "heading": "Legacy multi-byte Chinese (traditional) encodings" + }, + { + "encodings": [ + { + "labels": [ + "cseucpkdfmtjapanese", + "euc-jp", + "x-euc-jp" + ], + "name": "EUC-JP" + }, + { + "labels": [ + "csiso2022jp", + "iso-2022-jp" + ], + "name": "ISO-2022-JP" + }, + { + "labels": [ + "csshiftjis", + "ms932", + "ms_kanji", + "shift-jis", + "shift_jis", + "sjis", + "windows-31j", + "x-sjis" + ], + "name": "Shift_JIS" + } + ], + "heading": "Legacy multi-byte Japanese encodings" + }, + { + "encodings": [ + { + "labels": [ + "cseuckr", + "csksc56011987", + "euc-kr", + "iso-ir-149", + "korean", + "ks_c_5601-1987", + "ks_c_5601-1989", + "ksc5601", + "ksc_5601", + "windows-949" + ], + "name": "EUC-KR" + } + ], + "heading": "Legacy multi-byte Korean encodings" + }, + { + "encodings": [ + { + "labels": [ + "csiso2022kr", + "hz-gb-2312", + "iso-2022-cn", + "iso-2022-cn-ext", + "iso-2022-kr" + ], + "name": "replacement" + }, + { + "labels": [ + "utf-16be" + ], + "name": "UTF-16BE" + }, + { + "labels": [ + "utf-16", + "utf-16le" + ], + "name": "UTF-16LE" + }, + { + "labels": [ + "x-user-defined" + ], + "name": "x-user-defined" + } + ], + "heading": "Legacy miscellaneous encodings" + } + ]; + + // Label to encoding registry. + /** @type {Object.}>} */ + var label_to_encoding = {}; + encodings.forEach(function(category) { + category.encodings.forEach(function(encoding) { + encoding.labels.forEach(function(label) { + label_to_encoding[label] = encoding; + }); + }); + }); + + // Registry of of encoder/decoder factories, by encoding name. + /** @type {Object.} */ + var encoders = {}; + /** @type {Object.} */ + var decoders = {}; + + // + // 6. Indexes + // + + /** + * @param {number} pointer The |pointer| to search for. + * @param {(!Array.|undefined)} index The |index| to search within. + * @return {?number} The code point corresponding to |pointer| in |index|, + * or null if |code point| is not in |index|. + */ + function indexCodePointFor(pointer, index) { + if (!index) return null; + return index[pointer] || null; + } + + /** + * @param {number} code_point The |code point| to search for. + * @param {!Array.} index The |index| to search within. + * @return {?number} The first pointer corresponding to |code point| in + * |index|, or null if |code point| is not in |index|. + */ + function indexPointerFor(code_point, index) { + var pointer = index.indexOf(code_point); + return pointer === -1 ? null : pointer; + } + + /** + * @param {string} name Name of the index. + * @return {(!Array.|!Array.>)} + * */ + function index(name) { + if (!('encoding-indexes' in global)) { + throw Error("Indexes missing." + + " Did you forget to include encoding-indexes.js?"); + } + return global['encoding-indexes'][name]; + } + + /** + * @param {number} pointer The |pointer| to search for in the gb18030 index. + * @return {?number} The code point corresponding to |pointer| in |index|, + * or null if |code point| is not in the gb18030 index. + */ + function indexGB18030RangesCodePointFor(pointer) { + // 1. If pointer is greater than 39419 and less than 189000, or + // pointer is greater than 1237575, return null. + if ((pointer > 39419 && pointer < 189000) || (pointer > 1237575)) + return null; + + // 2. If pointer is 7457, return code point U+E7C7. + if (pointer === 7457) return 0xE7C7; + + // 3. Let offset be the last pointer in index gb18030 ranges that + // is equal to or less than pointer and let code point offset be + // its corresponding code point. + var offset = 0; + var code_point_offset = 0; + var idx = index('gb18030'); + var i; + for (i = 0; i < idx.length; ++i) { + /** @type {!Array.} */ + var entry = idx[i]; + if (entry[0] <= pointer) { + offset = entry[0]; + code_point_offset = entry[1]; + } else { + break; + } + } + + // 4. Return a code point whose value is code point offset + + // pointer − offset. + return code_point_offset + pointer - offset; + } + + /** + * @param {number} code_point The |code point| to locate in the gb18030 index. + * @return {number} The first pointer corresponding to |code point| in the + * gb18030 index. + */ + function indexGB18030RangesPointerFor(code_point) { + // 1. If code point is U+E7C7, return pointer 7457. + if (code_point === 0xE7C7) return 7457; + + // 2. Let offset be the last code point in index gb18030 ranges + // that is equal to or less than code point and let pointer offset + // be its corresponding pointer. + var offset = 0; + var pointer_offset = 0; + var idx = index('gb18030'); + var i; + for (i = 0; i < idx.length; ++i) { + /** @type {!Array.} */ + var entry = idx[i]; + if (entry[1] <= code_point) { + offset = entry[1]; + pointer_offset = entry[0]; + } else { + break; + } + } + + // 3. Return a pointer whose value is pointer offset + code point + // − offset. + return pointer_offset + code_point - offset; + } + + /** + * @param {number} code_point The |code_point| to search for in the shift_jis + * index. + * @return {?number} The code point corresponding to |pointer| in |index|, + * or null if |code point| is not in the shift_jis index. + */ + function indexShiftJISPointerFor(code_point) { + // 1. Let index be index jis0208 excluding all pointers in the + // range 8272 to 8835. + var pointer = indexPointerFor(code_point, index('jis0208')); + if (pointer === null || inRange(pointer, 8272, 8835)) + return null; + + // 2. Return the index pointer for code point in index. + return pointer; + } + + /** + * @param {number} code_point The |code_point| to search for in the big5 + * index. + * @return {?number} The code point corresponding to |pointer| in |index|, + * or null if |code point| is not in the big5 index. + */ + function indexBig5PointerFor(code_point) { + + // 1. Let index be index big5. + var index_ = index('big5'); + + // 2. If code point is U+2550, U+255E, U+2561, U+256A, U+5341, or + // U+5345, return the last pointer corresponding to code point in + // index. + if (code_point === 0x2550 || code_point === 0x255E || + code_point === 0x2561 || code_point === 0x256A || + code_point === 0x5341 || code_point === 0x5345) { + return index_.lastIndexOf(code_point); + } + + // 3. Return the index pointer for code point in index. + return indexPointerFor(code_point, index_); + } + + // + // 8. API + // + + /** @const */ var DEFAULT_ENCODING = 'utf-8'; + + // 8.1 Interface TextDecoder + + /** + * @constructor + * @param {string=} label The label of the encoding; + * defaults to 'utf-8'. + * @param {Object=} options + */ + function TextDecoder(label, options) { + // Web IDL conventions + if (!(this instanceof TextDecoder)) + throw TypeError('Called as a function. Did you forget \'new\'?'); + label = label !== undefined ? String(label) : DEFAULT_ENCODING; + options = ToDictionary(options); + + // A TextDecoder object has an associated encoding, decoder, + // stream, ignore BOM flag (initially unset), BOM seen flag + // (initially unset), error mode (initially replacement), and do + // not flush flag (initially unset). + + /** @private */ + this._encoding = null; + /** @private @type {?Decoder} */ + this._decoder = null; + /** @private @type {boolean} */ + this._ignoreBOM = false; + /** @private @type {boolean} */ + this._BOMseen = false; + /** @private @type {string} */ + this._error_mode = 'replacement'; + /** @private @type {boolean} */ + this._do_not_flush = false; + + + // 1. Let encoding be the result of getting an encoding from + // label. + var encoding = getEncoding(label); + + // 2. If encoding is failure or replacement, throw a RangeError. + if (encoding === null || encoding.name === 'replacement') + throw RangeError('Unknown encoding: ' + label); + if (!decoders[encoding.name]) { + throw Error('Decoder not present.' + + ' Did you forget to include encoding-indexes.js?'); + } + + // 3. Let dec be a new TextDecoder object. + var dec = this; + + // 4. Set dec's encoding to encoding. + dec._encoding = encoding; + + // 5. If options's fatal member is true, set dec's error mode to + // fatal. + if (Boolean(options['fatal'])) + dec._error_mode = 'fatal'; + + // 6. If options's ignoreBOM member is true, set dec's ignore BOM + // flag. + if (Boolean(options['ignoreBOM'])) + dec._ignoreBOM = true; + + // For pre-ES5 runtimes: + if (!Object.defineProperty) { + this.encoding = dec._encoding.name.toLowerCase(); + this.fatal = dec._error_mode === 'fatal'; + this.ignoreBOM = dec._ignoreBOM; + } + + // 7. Return dec. + return dec; + } + + if (Object.defineProperty) { + // The encoding attribute's getter must return encoding's name. + Object.defineProperty(TextDecoder.prototype, 'encoding', { + /** @this {TextDecoder} */ + get: function() { return this._encoding.name.toLowerCase(); } + }); + + // The fatal attribute's getter must return true if error mode + // is fatal, and false otherwise. + Object.defineProperty(TextDecoder.prototype, 'fatal', { + /** @this {TextDecoder} */ + get: function() { return this._error_mode === 'fatal'; } + }); + + // The ignoreBOM attribute's getter must return true if ignore + // BOM flag is set, and false otherwise. + Object.defineProperty(TextDecoder.prototype, 'ignoreBOM', { + /** @this {TextDecoder} */ + get: function() { return this._ignoreBOM; } + }); + } + + /** + * @param {BufferSource=} input The buffer of bytes to decode. + * @param {Object=} options + * @return {string} The decoded string. + */ + TextDecoder.prototype.decode = function decode(input, options) { + var bytes; + if (typeof input === 'object' && input instanceof ArrayBuffer) { + bytes = new Uint8Array(input); + } else if (typeof input === 'object' && 'buffer' in input && + input.buffer instanceof ArrayBuffer) { + bytes = new Uint8Array(input.buffer, + input.byteOffset, + input.byteLength); + } else { + bytes = new Uint8Array(0); + } + + options = ToDictionary(options); + + // 1. If the do not flush flag is unset, set decoder to a new + // encoding's decoder, set stream to a new stream, and unset the + // BOM seen flag. + if (!this._do_not_flush) { + this._decoder = decoders[this._encoding.name]({ + fatal: this._error_mode === 'fatal'}); + this._BOMseen = false; + } + + // 2. If options's stream is true, set the do not flush flag, and + // unset the do not flush flag otherwise. + this._do_not_flush = Boolean(options['stream']); + + // 3. If input is given, push a copy of input to stream. + // TODO: Align with spec algorithm - maintain stream on instance. + var input_stream = new Stream(bytes); + + // 4. Let output be a new stream. + var output = []; + + /** @type {?(number|!Array.)} */ + var result; + + // 5. While true: + while (true) { + // 1. Let token be the result of reading from stream. + var token = input_stream.read(); + + // 2. If token is end-of-stream and the do not flush flag is + // set, return output, serialized. + // TODO: Align with spec algorithm. + if (token === end_of_stream) + break; + + // 3. Otherwise, run these subsubsteps: + + // 1. Let result be the result of processing token for decoder, + // stream, output, and error mode. + result = this._decoder.handler(input_stream, token); + + // 2. If result is finished, return output, serialized. + if (result === finished) + break; + + if (result !== null) { + if (Array.isArray(result)) + output.push.apply(output, /**@type {!Array.}*/(result)); + else + output.push(result); + } + + // 3. Otherwise, if result is error, throw a TypeError. + // (Thrown in handler) + + // 4. Otherwise, do nothing. + } + // TODO: Align with spec algorithm. + if (!this._do_not_flush) { + do { + result = this._decoder.handler(input_stream, input_stream.read()); + if (result === finished) + break; + if (result === null) + continue; + if (Array.isArray(result)) + output.push.apply(output, /**@type {!Array.}*/(result)); + else + output.push(result); + } while (!input_stream.endOfStream()); + this._decoder = null; + } + + // A TextDecoder object also has an associated serialize stream + // algorithm... + /** + * @param {!Array.} stream + * @return {string} + * @this {TextDecoder} + */ + function serializeStream(stream) { + // 1. Let token be the result of reading from stream. + // (Done in-place on array, rather than as a stream) + + // 2. If encoding is UTF-8, UTF-16BE, or UTF-16LE, and ignore + // BOM flag and BOM seen flag are unset, run these subsubsteps: + if (includes(['UTF-8', 'UTF-16LE', 'UTF-16BE'], this._encoding.name) && + !this._ignoreBOM && !this._BOMseen) { + if (stream.length > 0 && stream[0] === 0xFEFF) { + // 1. If token is U+FEFF, set BOM seen flag. + this._BOMseen = true; + stream.shift(); + } else if (stream.length > 0) { + // 2. Otherwise, if token is not end-of-stream, set BOM seen + // flag and append token to stream. + this._BOMseen = true; + } else { + // 3. Otherwise, if token is not end-of-stream, append token + // to output. + // (no-op) + } + } + // 4. Otherwise, return output. + return codePointsToString(stream); + } + + return serializeStream.call(this, output); + }; + + // 8.2 Interface TextEncoder + + /** + * @constructor + * @param {string=} label The label of the encoding. NONSTANDARD. + * @param {Object=} options NONSTANDARD. + */ + function TextEncoder(label, options) { + // Web IDL conventions + if (!(this instanceof TextEncoder)) + throw TypeError('Called as a function. Did you forget \'new\'?'); + options = ToDictionary(options); + + // A TextEncoder object has an associated encoding and encoder. + + /** @private */ + this._encoding = null; + /** @private @type {?Encoder} */ + this._encoder = null; + + // Non-standard + /** @private @type {boolean} */ + this._do_not_flush = false; + /** @private @type {string} */ + this._fatal = Boolean(options['fatal']) ? 'fatal' : 'replacement'; + + // 1. Let enc be a new TextEncoder object. + var enc = this; + + // 2. Set enc's encoding to UTF-8's encoder. + if (Boolean(options['NONSTANDARD_allowLegacyEncoding'])) { + // NONSTANDARD behavior. + label = label !== undefined ? String(label) : DEFAULT_ENCODING; + var encoding = getEncoding(label); + if (encoding === null || encoding.name === 'replacement') + throw RangeError('Unknown encoding: ' + label); + if (!encoders[encoding.name]) { + throw Error('Encoder not present.' + + ' Did you forget to include encoding-indexes.js?'); + } + enc._encoding = encoding; + } else { + // Standard behavior. + enc._encoding = getEncoding('utf-8'); + + if (label !== undefined && 'console' in global) { + console.warn('TextEncoder constructor called with encoding label, ' + + 'which is ignored.'); + } + } + + // For pre-ES5 runtimes: + if (!Object.defineProperty) + this.encoding = enc._encoding.name.toLowerCase(); + + // 3. Return enc. + return enc; + } + + if (Object.defineProperty) { + // The encoding attribute's getter must return encoding's name. + Object.defineProperty(TextEncoder.prototype, 'encoding', { + /** @this {TextEncoder} */ + get: function() { return this._encoding.name.toLowerCase(); } + }); + } + + /** + * @param {string=} opt_string The string to encode. + * @param {Object=} options + * @return {!Uint8Array} Encoded bytes, as a Uint8Array. + */ + TextEncoder.prototype.encode = function encode(opt_string, options) { + opt_string = opt_string ? String(opt_string) : ''; + options = ToDictionary(options); + + // NOTE: This option is nonstandard. None of the encodings + // permitted for encoding (i.e. UTF-8, UTF-16) are stateful when + // the input is a USVString so streaming is not necessary. + if (!this._do_not_flush) + this._encoder = encoders[this._encoding.name]({ + fatal: this._fatal === 'fatal'}); + this._do_not_flush = Boolean(options['stream']); + + // 1. Convert input to a stream. + var input = new Stream(stringToCodePoints(opt_string)); + + // 2. Let output be a new stream + var output = []; + + /** @type {?(number|!Array.)} */ + var result; + // 3. While true, run these substeps: + while (true) { + // 1. Let token be the result of reading from input. + var token = input.read(); + if (token === end_of_stream) + break; + // 2. Let result be the result of processing token for encoder, + // input, output. + result = this._encoder.handler(input, token); + if (result === finished) + break; + if (Array.isArray(result)) + output.push.apply(output, /**@type {!Array.}*/(result)); + else + output.push(result); + } + // TODO: Align with spec algorithm. + if (!this._do_not_flush) { + while (true) { + result = this._encoder.handler(input, input.read()); + if (result === finished) + break; + if (Array.isArray(result)) + output.push.apply(output, /**@type {!Array.}*/(result)); + else + output.push(result); + } + this._encoder = null; + } + // 3. If result is finished, convert output into a byte sequence, + // and then return a Uint8Array object wrapping an ArrayBuffer + // containing output. + return new Uint8Array(output); + }; + + + // + // 9. The encoding + // + + // 9.1 utf-8 + + // 9.1.1 utf-8 decoder + /** + * @constructor + * @implements {Decoder} + * @param {{fatal: boolean}} options + */ + function UTF8Decoder(options) { + var fatal = options.fatal; + + // utf-8's decoder's has an associated utf-8 code point, utf-8 + // bytes seen, and utf-8 bytes needed (all initially 0), a utf-8 + // lower boundary (initially 0x80), and a utf-8 upper boundary + // (initially 0xBF). + var /** @type {number} */ utf8_code_point = 0, + /** @type {number} */ utf8_bytes_seen = 0, + /** @type {number} */ utf8_bytes_needed = 0, + /** @type {number} */ utf8_lower_boundary = 0x80, + /** @type {number} */ utf8_upper_boundary = 0xBF; + + /** + * @param {Stream} stream The stream of bytes being decoded. + * @param {number} bite The next byte read from the stream. + * @return {?(number|!Array.)} The next code point(s) + * decoded, or null if not enough data exists in the input + * stream to decode a complete code point. + */ + this.handler = function(stream, bite) { + // 1. If byte is end-of-stream and utf-8 bytes needed is not 0, + // set utf-8 bytes needed to 0 and return error. + if (bite === end_of_stream && utf8_bytes_needed !== 0) { + utf8_bytes_needed = 0; + return decoderError(fatal); + } + + // 2. If byte is end-of-stream, return finished. + if (bite === end_of_stream) + return finished; + + // 3. If utf-8 bytes needed is 0, based on byte: + if (utf8_bytes_needed === 0) { + + // 0x00 to 0x7F + if (inRange(bite, 0x00, 0x7F)) { + // Return a code point whose value is byte. + return bite; + } + + // 0xC2 to 0xDF + if (inRange(bite, 0xC2, 0xDF)) { + // Set utf-8 bytes needed to 1 and utf-8 code point to byte + // − 0xC0. + utf8_bytes_needed = 1; + utf8_code_point = bite - 0xC0; + } + + // 0xE0 to 0xEF + else if (inRange(bite, 0xE0, 0xEF)) { + // 1. If byte is 0xE0, set utf-8 lower boundary to 0xA0. + if (bite === 0xE0) + utf8_lower_boundary = 0xA0; + // 2. If byte is 0xED, set utf-8 upper boundary to 0x9F. + if (bite === 0xED) + utf8_upper_boundary = 0x9F; + // 3. Set utf-8 bytes needed to 2 and utf-8 code point to + // byte − 0xE0. + utf8_bytes_needed = 2; + utf8_code_point = bite - 0xE0; + } + + // 0xF0 to 0xF4 + else if (inRange(bite, 0xF0, 0xF4)) { + // 1. If byte is 0xF0, set utf-8 lower boundary to 0x90. + if (bite === 0xF0) + utf8_lower_boundary = 0x90; + // 2. If byte is 0xF4, set utf-8 upper boundary to 0x8F. + if (bite === 0xF4) + utf8_upper_boundary = 0x8F; + // 3. Set utf-8 bytes needed to 3 and utf-8 code point to + // byte − 0xF0. + utf8_bytes_needed = 3; + utf8_code_point = bite - 0xF0; + } + + // Otherwise + else { + // Return error. + return decoderError(fatal); + } + + // Then (byte is in the range 0xC2 to 0xF4, inclusive) set + // utf-8 code point to utf-8 code point << (6 × utf-8 bytes + // needed) and return continue. + utf8_code_point = utf8_code_point << (6 * utf8_bytes_needed); + return null; + } + + // 4. If byte is not in the range utf-8 lower boundary to utf-8 + // upper boundary, inclusive, run these substeps: + if (!inRange(bite, utf8_lower_boundary, utf8_upper_boundary)) { + + // 1. Set utf-8 code point, utf-8 bytes needed, and utf-8 + // bytes seen to 0, set utf-8 lower boundary to 0x80, and set + // utf-8 upper boundary to 0xBF. + utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0; + utf8_lower_boundary = 0x80; + utf8_upper_boundary = 0xBF; + + // 2. Prepend byte to stream. + stream.prepend(bite); + + // 3. Return error. + return decoderError(fatal); + } + + // 5. Set utf-8 lower boundary to 0x80 and utf-8 upper boundary + // to 0xBF. + utf8_lower_boundary = 0x80; + utf8_upper_boundary = 0xBF; + + // 6. Increase utf-8 bytes seen by one and set utf-8 code point + // to utf-8 code point + (byte − 0x80) << (6 × (utf-8 bytes + // needed − utf-8 bytes seen)). + utf8_bytes_seen += 1; + utf8_code_point += (bite - 0x80) << (6 * (utf8_bytes_needed - + utf8_bytes_seen)); + + // 7. If utf-8 bytes seen is not equal to utf-8 bytes needed, + // continue. + if (utf8_bytes_seen !== utf8_bytes_needed) + return null; + + // 8. Let code point be utf-8 code point. + var code_point = utf8_code_point; + + // 9. Set utf-8 code point, utf-8 bytes needed, and utf-8 bytes + // seen to 0. + utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0; + + // 10. Return a code point whose value is code point. + return code_point; + }; + } + + // 9.1.2 utf-8 encoder + /** + * @constructor + * @implements {Encoder} + * @param {{fatal: boolean}} options + */ + function UTF8Encoder(options) { + var fatal = options.fatal; + /** + * @param {Stream} stream Input stream. + * @param {number} code_point Next code point read from the stream. + * @return {(number|!Array.)} Byte(s) to emit. + */ + this.handler = function(stream, code_point) { + // 1. If code point is end-of-stream, return finished. + if (code_point === end_of_stream) + return finished; + + // 2. If code point is in the range U+0000 to U+007F, return a + // byte whose value is code point. + if (inRange(code_point, 0x0000, 0x007f)) + return code_point; + + // 3. Set count and offset based on the range code point is in: + var count, offset; + // U+0080 to U+07FF, inclusive: + if (inRange(code_point, 0x0080, 0x07FF)) { + // 1 and 0xC0 + count = 1; + offset = 0xC0; + } + // U+0800 to U+FFFF, inclusive: + else if (inRange(code_point, 0x0800, 0xFFFF)) { + // 2 and 0xE0 + count = 2; + offset = 0xE0; + } + // U+10000 to U+10FFFF, inclusive: + else if (inRange(code_point, 0x10000, 0x10FFFF)) { + // 3 and 0xF0 + count = 3; + offset = 0xF0; + } + + // 4.Let bytes be a byte sequence whose first byte is (code + // point >> (6 × count)) + offset. + var bytes = [(code_point >> (6 * count)) + offset]; + + // 5. Run these substeps while count is greater than 0: + while (count > 0) { + + // 1. Set temp to code point >> (6 × (count − 1)). + var temp = code_point >> (6 * (count - 1)); + + // 2. Append to bytes 0x80 | (temp & 0x3F). + bytes.push(0x80 | (temp & 0x3F)); + + // 3. Decrease count by one. + count -= 1; + } + + // 6. Return bytes bytes, in order. + return bytes; + }; + } + + /** @param {{fatal: boolean}} options */ + encoders['UTF-8'] = function(options) { + return new UTF8Encoder(options); + }; + /** @param {{fatal: boolean}} options */ + decoders['UTF-8'] = function(options) { + return new UTF8Decoder(options); + }; + + // + // 10. Legacy single-byte encodings + // + + // 10.1 single-byte decoder + /** + * @constructor + * @implements {Decoder} + * @param {!Array.} index The encoding index. + * @param {{fatal: boolean}} options + */ + function SingleByteDecoder(index, options) { + var fatal = options.fatal; + /** + * @param {Stream} stream The stream of bytes being decoded. + * @param {number} bite The next byte read from the stream. + * @return {?(number|!Array.)} The next code point(s) + * decoded, or null if not enough data exists in the input + * stream to decode a complete code point. + */ + this.handler = function(stream, bite) { + // 1. If byte is end-of-stream, return finished. + if (bite === end_of_stream) + return finished; + + // 2. If byte is an ASCII byte, return a code point whose value + // is byte. + if (isASCIIByte(bite)) + return bite; + + // 3. Let code point be the index code point for byte − 0x80 in + // index single-byte. + var code_point = index[bite - 0x80]; + + // 4. If code point is null, return error. + if (code_point === null) + return decoderError(fatal); + + // 5. Return a code point whose value is code point. + return code_point; + }; + } + + // 10.2 single-byte encoder + /** + * @constructor + * @implements {Encoder} + * @param {!Array.} index The encoding index. + * @param {{fatal: boolean}} options + */ + function SingleByteEncoder(index, options) { + var fatal = options.fatal; + /** + * @param {Stream} stream Input stream. + * @param {number} code_point Next code point read from the stream. + * @return {(number|!Array.)} Byte(s) to emit. + */ + this.handler = function(stream, code_point) { + // 1. If code point is end-of-stream, return finished. + if (code_point === end_of_stream) + return finished; + + // 2. If code point is an ASCII code point, return a byte whose + // value is code point. + if (isASCIICodePoint(code_point)) + return code_point; + + // 3. Let pointer be the index pointer for code point in index + // single-byte. + var pointer = indexPointerFor(code_point, index); + + // 4. If pointer is null, return error with code point. + if (pointer === null) + encoderError(code_point); + + // 5. Return a byte whose value is pointer + 0x80. + return pointer + 0x80; + }; + } + + (function() { + if (!('encoding-indexes' in global)) + return; + encodings.forEach(function(category) { + if (category.heading !== 'Legacy single-byte encodings') + return; + category.encodings.forEach(function(encoding) { + var name = encoding.name; + var idx = index(name.toLowerCase()); + /** @param {{fatal: boolean}} options */ + decoders[name] = function(options) { + return new SingleByteDecoder(idx, options); + }; + /** @param {{fatal: boolean}} options */ + encoders[name] = function(options) { + return new SingleByteEncoder(idx, options); + }; + }); + }); + }()); + + // + // 11. Legacy multi-byte Chinese (simplified) encodings + // + + // 11.1 gbk + + // 11.1.1 gbk decoder + // gbk's decoder is gb18030's decoder. + /** @param {{fatal: boolean}} options */ + decoders['GBK'] = function(options) { + return new GB18030Decoder(options); + }; + + // 11.1.2 gbk encoder + // gbk's encoder is gb18030's encoder with its gbk flag set. + /** @param {{fatal: boolean}} options */ + encoders['GBK'] = function(options) { + return new GB18030Encoder(options, true); + }; + + // 11.2 gb18030 + + // 11.2.1 gb18030 decoder + /** + * @constructor + * @implements {Decoder} + * @param {{fatal: boolean}} options + */ + function GB18030Decoder(options) { + var fatal = options.fatal; + // gb18030's decoder has an associated gb18030 first, gb18030 + // second, and gb18030 third (all initially 0x00). + var /** @type {number} */ gb18030_first = 0x00, + /** @type {number} */ gb18030_second = 0x00, + /** @type {number} */ gb18030_third = 0x00; + /** + * @param {Stream} stream The stream of bytes being decoded. + * @param {number} bite The next byte read from the stream. + * @return {?(number|!Array.)} The next code point(s) + * decoded, or null if not enough data exists in the input + * stream to decode a complete code point. + */ + this.handler = function(stream, bite) { + // 1. If byte is end-of-stream and gb18030 first, gb18030 + // second, and gb18030 third are 0x00, return finished. + if (bite === end_of_stream && gb18030_first === 0x00 && + gb18030_second === 0x00 && gb18030_third === 0x00) { + return finished; + } + // 2. If byte is end-of-stream, and gb18030 first, gb18030 + // second, or gb18030 third is not 0x00, set gb18030 first, + // gb18030 second, and gb18030 third to 0x00, and return error. + if (bite === end_of_stream && + (gb18030_first !== 0x00 || gb18030_second !== 0x00 || + gb18030_third !== 0x00)) { + gb18030_first = 0x00; + gb18030_second = 0x00; + gb18030_third = 0x00; + decoderError(fatal); + } + var code_point; + // 3. If gb18030 third is not 0x00, run these substeps: + if (gb18030_third !== 0x00) { + // 1. Let code point be null. + code_point = null; + // 2. If byte is in the range 0x30 to 0x39, set code point to + // the index gb18030 ranges code point for (((gb18030 first − + // 0x81) × 10 + gb18030 second − 0x30) × 126 + gb18030 third − + // 0x81) × 10 + byte − 0x30. + if (inRange(bite, 0x30, 0x39)) { + code_point = indexGB18030RangesCodePointFor( + (((gb18030_first - 0x81) * 10 + (gb18030_second - 0x30)) * 126 + + (gb18030_third - 0x81)) * 10 + bite - 0x30); + } + + // 3. Let buffer be a byte sequence consisting of gb18030 + // second, gb18030 third, and byte, in order. + var buffer = [gb18030_second, gb18030_third, bite]; + + // 4. Set gb18030 first, gb18030 second, and gb18030 third to + // 0x00. + gb18030_first = 0x00; + gb18030_second = 0x00; + gb18030_third = 0x00; + + // 5. If code point is null, prepend buffer to stream and + // return error. + if (code_point === null) { + stream.prepend(buffer); + return decoderError(fatal); + } + + // 6. Return a code point whose value is code point. + return code_point; + } + + // 4. If gb18030 second is not 0x00, run these substeps: + if (gb18030_second !== 0x00) { + + // 1. If byte is in the range 0x81 to 0xFE, set gb18030 third + // to byte and return continue. + if (inRange(bite, 0x81, 0xFE)) { + gb18030_third = bite; + return null; + } + + // 2. Prepend gb18030 second followed by byte to stream, set + // gb18030 first and gb18030 second to 0x00, and return error. + stream.prepend([gb18030_second, bite]); + gb18030_first = 0x00; + gb18030_second = 0x00; + return decoderError(fatal); + } + + // 5. If gb18030 first is not 0x00, run these substeps: + if (gb18030_first !== 0x00) { + + // 1. If byte is in the range 0x30 to 0x39, set gb18030 second + // to byte and return continue. + if (inRange(bite, 0x30, 0x39)) { + gb18030_second = bite; + return null; + } + + // 2. Let lead be gb18030 first, let pointer be null, and set + // gb18030 first to 0x00. + var lead = gb18030_first; + var pointer = null; + gb18030_first = 0x00; + + // 3. Let offset be 0x40 if byte is less than 0x7F and 0x41 + // otherwise. + var offset = bite < 0x7F ? 0x40 : 0x41; + + // 4. If byte is in the range 0x40 to 0x7E or 0x80 to 0xFE, + // set pointer to (lead − 0x81) × 190 + (byte − offset). + if (inRange(bite, 0x40, 0x7E) || inRange(bite, 0x80, 0xFE)) + pointer = (lead - 0x81) * 190 + (bite - offset); + + // 5. Let code point be null if pointer is null and the index + // code point for pointer in index gb18030 otherwise. + code_point = pointer === null ? null : + indexCodePointFor(pointer, index('gb18030')); + + // 6. If code point is null and byte is an ASCII byte, prepend + // byte to stream. + if (code_point === null && isASCIIByte(bite)) + stream.prepend(bite); + + // 7. If code point is null, return error. + if (code_point === null) + return decoderError(fatal); + + // 8. Return a code point whose value is code point. + return code_point; + } + + // 6. If byte is an ASCII byte, return a code point whose value + // is byte. + if (isASCIIByte(bite)) + return bite; + + // 7. If byte is 0x80, return code point U+20AC. + if (bite === 0x80) + return 0x20AC; + + // 8. If byte is in the range 0x81 to 0xFE, set gb18030 first to + // byte and return continue. + if (inRange(bite, 0x81, 0xFE)) { + gb18030_first = bite; + return null; + } + + // 9. Return error. + return decoderError(fatal); + }; + } + + // 11.2.2 gb18030 encoder + /** + * @constructor + * @implements {Encoder} + * @param {{fatal: boolean}} options + * @param {boolean=} gbk_flag + */ + function GB18030Encoder(options, gbk_flag) { + var fatal = options.fatal; + // gb18030's decoder has an associated gbk flag (initially unset). + /** + * @param {Stream} stream Input stream. + * @param {number} code_point Next code point read from the stream. + * @return {(number|!Array.)} Byte(s) to emit. + */ + this.handler = function(stream, code_point) { + // 1. If code point is end-of-stream, return finished. + if (code_point === end_of_stream) + return finished; + + // 2. If code point is an ASCII code point, return a byte whose + // value is code point. + if (isASCIICodePoint(code_point)) + return code_point; + + // 3. If code point is U+E5E5, return error with code point. + if (code_point === 0xE5E5) + return encoderError(code_point); + + // 4. If the gbk flag is set and code point is U+20AC, return + // byte 0x80. + if (gbk_flag && code_point === 0x20AC) + return 0x80; + + // 5. Let pointer be the index pointer for code point in index + // gb18030. + var pointer = indexPointerFor(code_point, index('gb18030')); + + // 6. If pointer is not null, run these substeps: + if (pointer !== null) { + + // 1. Let lead be floor(pointer / 190) + 0x81. + var lead = floor(pointer / 190) + 0x81; + + // 2. Let trail be pointer % 190. + var trail = pointer % 190; + + // 3. Let offset be 0x40 if trail is less than 0x3F and 0x41 otherwise. + var offset = trail < 0x3F ? 0x40 : 0x41; + + // 4. Return two bytes whose values are lead and trail + offset. + return [lead, trail + offset]; + } + + // 7. If gbk flag is set, return error with code point. + if (gbk_flag) + return encoderError(code_point); + + // 8. Set pointer to the index gb18030 ranges pointer for code + // point. + pointer = indexGB18030RangesPointerFor(code_point); + + // 9. Let byte1 be floor(pointer / 10 / 126 / 10). + var byte1 = floor(pointer / 10 / 126 / 10); + + // 10. Set pointer to pointer − byte1 × 10 × 126 × 10. + pointer = pointer - byte1 * 10 * 126 * 10; + + // 11. Let byte2 be floor(pointer / 10 / 126). + var byte2 = floor(pointer / 10 / 126); + + // 12. Set pointer to pointer − byte2 × 10 × 126. + pointer = pointer - byte2 * 10 * 126; + + // 13. Let byte3 be floor(pointer / 10). + var byte3 = floor(pointer / 10); + + // 14. Let byte4 be pointer − byte3 × 10. + var byte4 = pointer - byte3 * 10; + + // 15. Return four bytes whose values are byte1 + 0x81, byte2 + + // 0x30, byte3 + 0x81, byte4 + 0x30. + return [byte1 + 0x81, + byte2 + 0x30, + byte3 + 0x81, + byte4 + 0x30]; + }; + } + + /** @param {{fatal: boolean}} options */ + encoders['gb18030'] = function(options) { + return new GB18030Encoder(options); + }; + /** @param {{fatal: boolean}} options */ + decoders['gb18030'] = function(options) { + return new GB18030Decoder(options); + }; + + + // + // 12. Legacy multi-byte Chinese (traditional) encodings + // + + // 12.1 big5 + + // 12.1.1 big5 decoder + /** + * @constructor + * @implements {Decoder} + * @param {{fatal: boolean}} options + */ + function Big5Decoder(options) { + var fatal = options.fatal; + // big5's decoder has an associated big5 lead (initially 0x00). + var /** @type {number} */ big5_lead = 0x00; + + /** + * @param {Stream} stream The stream of bytes being decoded. + * @param {number} bite The next byte read from the stream. + * @return {?(number|!Array.)} The next code point(s) + * decoded, or null if not enough data exists in the input + * stream to decode a complete code point. + */ + this.handler = function(stream, bite) { + // 1. If byte is end-of-stream and big5 lead is not 0x00, set + // big5 lead to 0x00 and return error. + if (bite === end_of_stream && big5_lead !== 0x00) { + big5_lead = 0x00; + return decoderError(fatal); + } + + // 2. If byte is end-of-stream and big5 lead is 0x00, return + // finished. + if (bite === end_of_stream && big5_lead === 0x00) + return finished; + + // 3. If big5 lead is not 0x00, let lead be big5 lead, let + // pointer be null, set big5 lead to 0x00, and then run these + // substeps: + if (big5_lead !== 0x00) { + var lead = big5_lead; + var pointer = null; + big5_lead = 0x00; + + // 1. Let offset be 0x40 if byte is less than 0x7F and 0x62 + // otherwise. + var offset = bite < 0x7F ? 0x40 : 0x62; + + // 2. If byte is in the range 0x40 to 0x7E or 0xA1 to 0xFE, + // set pointer to (lead − 0x81) × 157 + (byte − offset). + if (inRange(bite, 0x40, 0x7E) || inRange(bite, 0xA1, 0xFE)) + pointer = (lead - 0x81) * 157 + (bite - offset); + + // 3. If there is a row in the table below whose first column + // is pointer, return the two code points listed in its second + // column + // Pointer | Code points + // --------+-------------- + // 1133 | U+00CA U+0304 + // 1135 | U+00CA U+030C + // 1164 | U+00EA U+0304 + // 1166 | U+00EA U+030C + switch (pointer) { + case 1133: return [0x00CA, 0x0304]; + case 1135: return [0x00CA, 0x030C]; + case 1164: return [0x00EA, 0x0304]; + case 1166: return [0x00EA, 0x030C]; + } + + // 4. Let code point be null if pointer is null and the index + // code point for pointer in index big5 otherwise. + var code_point = (pointer === null) ? null : + indexCodePointFor(pointer, index('big5')); + + // 5. If code point is null and byte is an ASCII byte, prepend + // byte to stream. + if (code_point === null && isASCIIByte(bite)) + stream.prepend(bite); + + // 6. If code point is null, return error. + if (code_point === null) + return decoderError(fatal); + + // 7. Return a code point whose value is code point. + return code_point; + } + + // 4. If byte is an ASCII byte, return a code point whose value + // is byte. + if (isASCIIByte(bite)) + return bite; + + // 5. If byte is in the range 0x81 to 0xFE, set big5 lead to + // byte and return continue. + if (inRange(bite, 0x81, 0xFE)) { + big5_lead = bite; + return null; + } + + // 6. Return error. + return decoderError(fatal); + }; + } + + // 12.1.2 big5 encoder + /** + * @constructor + * @implements {Encoder} + * @param {{fatal: boolean}} options + */ + function Big5Encoder(options) { + var fatal = options.fatal; + /** + * @param {Stream} stream Input stream. + * @param {number} code_point Next code point read from the stream. + * @return {(number|!Array.)} Byte(s) to emit. + */ + this.handler = function(stream, code_point) { + // 1. If code point is end-of-stream, return finished. + if (code_point === end_of_stream) + return finished; + + // 2. If code point is an ASCII code point, return a byte whose + // value is code point. + if (isASCIICodePoint(code_point)) + return code_point; + + // 3. Let pointer be the index big5 pointer for code point. + var pointer = indexBig5PointerFor(code_point); + + // 4. If pointer is null, return error with code point. + if (pointer === null) + return encoderError(code_point); + + // 5. Let lead be floor(pointer / 157) + 0x81. + var lead = floor(pointer / 157) + 0x81; + + // 6. If lead is less than 0xA1, return error with code point. + if (lead < 0xA1) + return encoderError(code_point); + + // 7. Let trail be pointer % 157. + var trail = pointer % 157; + + // 8. Let offset be 0x40 if trail is less than 0x3F and 0x62 + // otherwise. + var offset = trail < 0x3F ? 0x40 : 0x62; + + // Return two bytes whose values are lead and trail + offset. + return [lead, trail + offset]; + }; + } + + /** @param {{fatal: boolean}} options */ + encoders['Big5'] = function(options) { + return new Big5Encoder(options); + }; + /** @param {{fatal: boolean}} options */ + decoders['Big5'] = function(options) { + return new Big5Decoder(options); + }; + + + // + // 13. Legacy multi-byte Japanese encodings + // + + // 13.1 euc-jp + + // 13.1.1 euc-jp decoder + /** + * @constructor + * @implements {Decoder} + * @param {{fatal: boolean}} options + */ + function EUCJPDecoder(options) { + var fatal = options.fatal; + + // euc-jp's decoder has an associated euc-jp jis0212 flag + // (initially unset) and euc-jp lead (initially 0x00). + var /** @type {boolean} */ eucjp_jis0212_flag = false, + /** @type {number} */ eucjp_lead = 0x00; + + /** + * @param {Stream} stream The stream of bytes being decoded. + * @param {number} bite The next byte read from the stream. + * @return {?(number|!Array.)} The next code point(s) + * decoded, or null if not enough data exists in the input + * stream to decode a complete code point. + */ + this.handler = function(stream, bite) { + // 1. If byte is end-of-stream and euc-jp lead is not 0x00, set + // euc-jp lead to 0x00, and return error. + if (bite === end_of_stream && eucjp_lead !== 0x00) { + eucjp_lead = 0x00; + return decoderError(fatal); + } + + // 2. If byte is end-of-stream and euc-jp lead is 0x00, return + // finished. + if (bite === end_of_stream && eucjp_lead === 0x00) + return finished; + + // 3. If euc-jp lead is 0x8E and byte is in the range 0xA1 to + // 0xDF, set euc-jp lead to 0x00 and return a code point whose + // value is 0xFF61 + byte − 0xA1. + if (eucjp_lead === 0x8E && inRange(bite, 0xA1, 0xDF)) { + eucjp_lead = 0x00; + return 0xFF61 + bite - 0xA1; + } + + // 4. If euc-jp lead is 0x8F and byte is in the range 0xA1 to + // 0xFE, set the euc-jp jis0212 flag, set euc-jp lead to byte, + // and return continue. + if (eucjp_lead === 0x8F && inRange(bite, 0xA1, 0xFE)) { + eucjp_jis0212_flag = true; + eucjp_lead = bite; + return null; + } + + // 5. If euc-jp lead is not 0x00, let lead be euc-jp lead, set + // euc-jp lead to 0x00, and run these substeps: + if (eucjp_lead !== 0x00) { + var lead = eucjp_lead; + eucjp_lead = 0x00; + + // 1. Let code point be null. + var code_point = null; + + // 2. If lead and byte are both in the range 0xA1 to 0xFE, set + // code point to the index code point for (lead − 0xA1) × 94 + + // byte − 0xA1 in index jis0208 if the euc-jp jis0212 flag is + // unset and in index jis0212 otherwise. + if (inRange(lead, 0xA1, 0xFE) && inRange(bite, 0xA1, 0xFE)) { + code_point = indexCodePointFor( + (lead - 0xA1) * 94 + (bite - 0xA1), + index(!eucjp_jis0212_flag ? 'jis0208' : 'jis0212')); + } + + // 3. Unset the euc-jp jis0212 flag. + eucjp_jis0212_flag = false; + + // 4. If byte is not in the range 0xA1 to 0xFE, prepend byte + // to stream. + if (!inRange(bite, 0xA1, 0xFE)) + stream.prepend(bite); + + // 5. If code point is null, return error. + if (code_point === null) + return decoderError(fatal); + + // 6. Return a code point whose value is code point. + return code_point; + } + + // 6. If byte is an ASCII byte, return a code point whose value + // is byte. + if (isASCIIByte(bite)) + return bite; + + // 7. If byte is 0x8E, 0x8F, or in the range 0xA1 to 0xFE, set + // euc-jp lead to byte and return continue. + if (bite === 0x8E || bite === 0x8F || inRange(bite, 0xA1, 0xFE)) { + eucjp_lead = bite; + return null; + } + + // 8. Return error. + return decoderError(fatal); + }; + } + + // 13.1.2 euc-jp encoder + /** + * @constructor + * @implements {Encoder} + * @param {{fatal: boolean}} options + */ + function EUCJPEncoder(options) { + var fatal = options.fatal; + /** + * @param {Stream} stream Input stream. + * @param {number} code_point Next code point read from the stream. + * @return {(number|!Array.)} Byte(s) to emit. + */ + this.handler = function(stream, code_point) { + // 1. If code point is end-of-stream, return finished. + if (code_point === end_of_stream) + return finished; + + // 2. If code point is an ASCII code point, return a byte whose + // value is code point. + if (isASCIICodePoint(code_point)) + return code_point; + + // 3. If code point is U+00A5, return byte 0x5C. + if (code_point === 0x00A5) + return 0x5C; + + // 4. If code point is U+203E, return byte 0x7E. + if (code_point === 0x203E) + return 0x7E; + + // 5. If code point is in the range U+FF61 to U+FF9F, return two + // bytes whose values are 0x8E and code point − 0xFF61 + 0xA1. + if (inRange(code_point, 0xFF61, 0xFF9F)) + return [0x8E, code_point - 0xFF61 + 0xA1]; + + // 6. If code point is U+2212, set it to U+FF0D. + if (code_point === 0x2212) + code_point = 0xFF0D; + + // 7. Let pointer be the index pointer for code point in index + // jis0208. + var pointer = indexPointerFor(code_point, index('jis0208')); + + // 8. If pointer is null, return error with code point. + if (pointer === null) + return encoderError(code_point); + + // 9. Let lead be floor(pointer / 94) + 0xA1. + var lead = floor(pointer / 94) + 0xA1; + + // 10. Let trail be pointer % 94 + 0xA1. + var trail = pointer % 94 + 0xA1; + + // 11. Return two bytes whose values are lead and trail. + return [lead, trail]; + }; + } + + /** @param {{fatal: boolean}} options */ + encoders['EUC-JP'] = function(options) { + return new EUCJPEncoder(options); + }; + /** @param {{fatal: boolean}} options */ + decoders['EUC-JP'] = function(options) { + return new EUCJPDecoder(options); + }; + + // 13.2 iso-2022-jp + + // 13.2.1 iso-2022-jp decoder + /** + * @constructor + * @implements {Decoder} + * @param {{fatal: boolean}} options + */ + function ISO2022JPDecoder(options) { + var fatal = options.fatal; + /** @enum */ + var states = { + ASCII: 0, + Roman: 1, + Katakana: 2, + LeadByte: 3, + TrailByte: 4, + EscapeStart: 5, + Escape: 6 + }; + // iso-2022-jp's decoder has an associated iso-2022-jp decoder + // state (initially ASCII), iso-2022-jp decoder output state + // (initially ASCII), iso-2022-jp lead (initially 0x00), and + // iso-2022-jp output flag (initially unset). + var /** @type {number} */ iso2022jp_decoder_state = states.ASCII, + /** @type {number} */ iso2022jp_decoder_output_state = states.ASCII, + /** @type {number} */ iso2022jp_lead = 0x00, + /** @type {boolean} */ iso2022jp_output_flag = false; + /** + * @param {Stream} stream The stream of bytes being decoded. + * @param {number} bite The next byte read from the stream. + * @return {?(number|!Array.)} The next code point(s) + * decoded, or null if not enough data exists in the input + * stream to decode a complete code point. + */ + this.handler = function(stream, bite) { + // switching on iso-2022-jp decoder state: + switch (iso2022jp_decoder_state) { + default: + case states.ASCII: + // ASCII + // Based on byte: + + // 0x1B + if (bite === 0x1B) { + // Set iso-2022-jp decoder state to escape start and return + // continue. + iso2022jp_decoder_state = states.EscapeStart; + return null; + } + + // 0x00 to 0x7F, excluding 0x0E, 0x0F, and 0x1B + if (inRange(bite, 0x00, 0x7F) && bite !== 0x0E + && bite !== 0x0F && bite !== 0x1B) { + // Unset the iso-2022-jp output flag and return a code point + // whose value is byte. + iso2022jp_output_flag = false; + return bite; + } + + // end-of-stream + if (bite === end_of_stream) { + // Return finished. + return finished; + } + + // Otherwise + // Unset the iso-2022-jp output flag and return error. + iso2022jp_output_flag = false; + return decoderError(fatal); + + case states.Roman: + // Roman + // Based on byte: + + // 0x1B + if (bite === 0x1B) { + // Set iso-2022-jp decoder state to escape start and return + // continue. + iso2022jp_decoder_state = states.EscapeStart; + return null; + } + + // 0x5C + if (bite === 0x5C) { + // Unset the iso-2022-jp output flag and return code point + // U+00A5. + iso2022jp_output_flag = false; + return 0x00A5; + } + + // 0x7E + if (bite === 0x7E) { + // Unset the iso-2022-jp output flag and return code point + // U+203E. + iso2022jp_output_flag = false; + return 0x203E; + } + + // 0x00 to 0x7F, excluding 0x0E, 0x0F, 0x1B, 0x5C, and 0x7E + if (inRange(bite, 0x00, 0x7F) && bite !== 0x0E && bite !== 0x0F + && bite !== 0x1B && bite !== 0x5C && bite !== 0x7E) { + // Unset the iso-2022-jp output flag and return a code point + // whose value is byte. + iso2022jp_output_flag = false; + return bite; + } + + // end-of-stream + if (bite === end_of_stream) { + // Return finished. + return finished; + } + + // Otherwise + // Unset the iso-2022-jp output flag and return error. + iso2022jp_output_flag = false; + return decoderError(fatal); + + case states.Katakana: + // Katakana + // Based on byte: + + // 0x1B + if (bite === 0x1B) { + // Set iso-2022-jp decoder state to escape start and return + // continue. + iso2022jp_decoder_state = states.EscapeStart; + return null; + } + + // 0x21 to 0x5F + if (inRange(bite, 0x21, 0x5F)) { + // Unset the iso-2022-jp output flag and return a code point + // whose value is 0xFF61 + byte − 0x21. + iso2022jp_output_flag = false; + return 0xFF61 + bite - 0x21; + } + + // end-of-stream + if (bite === end_of_stream) { + // Return finished. + return finished; + } + + // Otherwise + // Unset the iso-2022-jp output flag and return error. + iso2022jp_output_flag = false; + return decoderError(fatal); + + case states.LeadByte: + // Lead byte + // Based on byte: + + // 0x1B + if (bite === 0x1B) { + // Set iso-2022-jp decoder state to escape start and return + // continue. + iso2022jp_decoder_state = states.EscapeStart; + return null; + } + + // 0x21 to 0x7E + if (inRange(bite, 0x21, 0x7E)) { + // Unset the iso-2022-jp output flag, set iso-2022-jp lead + // to byte, iso-2022-jp decoder state to trail byte, and + // return continue. + iso2022jp_output_flag = false; + iso2022jp_lead = bite; + iso2022jp_decoder_state = states.TrailByte; + return null; + } + + // end-of-stream + if (bite === end_of_stream) { + // Return finished. + return finished; + } + + // Otherwise + // Unset the iso-2022-jp output flag and return error. + iso2022jp_output_flag = false; + return decoderError(fatal); + + case states.TrailByte: + // Trail byte + // Based on byte: + + // 0x1B + if (bite === 0x1B) { + // Set iso-2022-jp decoder state to escape start and return + // continue. + iso2022jp_decoder_state = states.EscapeStart; + return decoderError(fatal); + } + + // 0x21 to 0x7E + if (inRange(bite, 0x21, 0x7E)) { + // 1. Set the iso-2022-jp decoder state to lead byte. + iso2022jp_decoder_state = states.LeadByte; + + // 2. Let pointer be (iso-2022-jp lead − 0x21) × 94 + byte − 0x21. + var pointer = (iso2022jp_lead - 0x21) * 94 + bite - 0x21; + + // 3. Let code point be the index code point for pointer in + // index jis0208. + var code_point = indexCodePointFor(pointer, index('jis0208')); + + // 4. If code point is null, return error. + if (code_point === null) + return decoderError(fatal); + + // 5. Return a code point whose value is code point. + return code_point; + } + + // end-of-stream + if (bite === end_of_stream) { + // Set the iso-2022-jp decoder state to lead byte, prepend + // byte to stream, and return error. + iso2022jp_decoder_state = states.LeadByte; + stream.prepend(bite); + return decoderError(fatal); + } + + // Otherwise + // Set iso-2022-jp decoder state to lead byte and return + // error. + iso2022jp_decoder_state = states.LeadByte; + return decoderError(fatal); + + case states.EscapeStart: + // Escape start + + // 1. If byte is either 0x24 or 0x28, set iso-2022-jp lead to + // byte, iso-2022-jp decoder state to escape, and return + // continue. + if (bite === 0x24 || bite === 0x28) { + iso2022jp_lead = bite; + iso2022jp_decoder_state = states.Escape; + return null; + } + + // 2. Prepend byte to stream. + stream.prepend(bite); + + // 3. Unset the iso-2022-jp output flag, set iso-2022-jp + // decoder state to iso-2022-jp decoder output state, and + // return error. + iso2022jp_output_flag = false; + iso2022jp_decoder_state = iso2022jp_decoder_output_state; + return decoderError(fatal); + + case states.Escape: + // Escape + + // 1. Let lead be iso-2022-jp lead and set iso-2022-jp lead to + // 0x00. + var lead = iso2022jp_lead; + iso2022jp_lead = 0x00; + + // 2. Let state be null. + var state = null; + + // 3. If lead is 0x28 and byte is 0x42, set state to ASCII. + if (lead === 0x28 && bite === 0x42) + state = states.ASCII; + + // 4. If lead is 0x28 and byte is 0x4A, set state to Roman. + if (lead === 0x28 && bite === 0x4A) + state = states.Roman; + + // 5. If lead is 0x28 and byte is 0x49, set state to Katakana. + if (lead === 0x28 && bite === 0x49) + state = states.Katakana; + + // 6. If lead is 0x24 and byte is either 0x40 or 0x42, set + // state to lead byte. + if (lead === 0x24 && (bite === 0x40 || bite === 0x42)) + state = states.LeadByte; + + // 7. If state is non-null, run these substeps: + if (state !== null) { + // 1. Set iso-2022-jp decoder state and iso-2022-jp decoder + // output state to states. + iso2022jp_decoder_state = iso2022jp_decoder_state = state; + + // 2. Let output flag be the iso-2022-jp output flag. + var output_flag = iso2022jp_output_flag; + + // 3. Set the iso-2022-jp output flag. + iso2022jp_output_flag = true; + + // 4. Return continue, if output flag is unset, and error + // otherwise. + return !output_flag ? null : decoderError(fatal); + } + + // 8. Prepend lead and byte to stream. + stream.prepend([lead, bite]); + + // 9. Unset the iso-2022-jp output flag, set iso-2022-jp + // decoder state to iso-2022-jp decoder output state and + // return error. + iso2022jp_output_flag = false; + iso2022jp_decoder_state = iso2022jp_decoder_output_state; + return decoderError(fatal); + } + }; + } + + // 13.2.2 iso-2022-jp encoder + /** + * @constructor + * @implements {Encoder} + * @param {{fatal: boolean}} options + */ + function ISO2022JPEncoder(options) { + var fatal = options.fatal; + // iso-2022-jp's encoder has an associated iso-2022-jp encoder + // state which is one of ASCII, Roman, and jis0208 (initially + // ASCII). + /** @enum */ + var states = { + ASCII: 0, + Roman: 1, + jis0208: 2 + }; + var /** @type {number} */ iso2022jp_state = states.ASCII; + /** + * @param {Stream} stream Input stream. + * @param {number} code_point Next code point read from the stream. + * @return {(number|!Array.)} Byte(s) to emit. + */ + this.handler = function(stream, code_point) { + // 1. If code point is end-of-stream and iso-2022-jp encoder + // state is not ASCII, prepend code point to stream, set + // iso-2022-jp encoder state to ASCII, and return three bytes + // 0x1B 0x28 0x42. + if (code_point === end_of_stream && + iso2022jp_state !== states.ASCII) { + stream.prepend(code_point); + iso2022jp_state = states.ASCII; + return [0x1B, 0x28, 0x42]; + } + + // 2. If code point is end-of-stream and iso-2022-jp encoder + // state is ASCII, return finished. + if (code_point === end_of_stream && iso2022jp_state === states.ASCII) + return finished; + + // 3. If ISO-2022-JP encoder state is ASCII or Roman, and code + // point is U+000E, U+000F, or U+001B, return error with U+FFFD. + if ((iso2022jp_state === states.ASCII || + iso2022jp_state === states.Roman) && + (code_point === 0x000E || code_point === 0x000F || + code_point === 0x001B)) { + return encoderError(0xFFFD); + } + + // 4. If iso-2022-jp encoder state is ASCII and code point is an + // ASCII code point, return a byte whose value is code point. + if (iso2022jp_state === states.ASCII && + isASCIICodePoint(code_point)) + return code_point; + + // 5. If iso-2022-jp encoder state is Roman and code point is an + // ASCII code point, excluding U+005C and U+007E, or is U+00A5 + // or U+203E, run these substeps: + if (iso2022jp_state === states.Roman && + ((isASCIICodePoint(code_point) && + code_point !== 0x005C && code_point !== 0x007E) || + (code_point == 0x00A5 || code_point == 0x203E))) { + + // 1. If code point is an ASCII code point, return a byte + // whose value is code point. + if (isASCIICodePoint(code_point)) + return code_point; + + // 2. If code point is U+00A5, return byte 0x5C. + if (code_point === 0x00A5) + return 0x5C; + + // 3. If code point is U+203E, return byte 0x7E. + if (code_point === 0x203E) + return 0x7E; + } + + // 6. If code point is an ASCII code point, and iso-2022-jp + // encoder state is not ASCII, prepend code point to stream, set + // iso-2022-jp encoder state to ASCII, and return three bytes + // 0x1B 0x28 0x42. + if (isASCIICodePoint(code_point) && + iso2022jp_state !== states.ASCII) { + stream.prepend(code_point); + iso2022jp_state = states.ASCII; + return [0x1B, 0x28, 0x42]; + } + + // 7. If code point is either U+00A5 or U+203E, and iso-2022-jp + // encoder state is not Roman, prepend code point to stream, set + // iso-2022-jp encoder state to Roman, and return three bytes + // 0x1B 0x28 0x4A. + if ((code_point === 0x00A5 || code_point === 0x203E) && + iso2022jp_state !== states.Roman) { + stream.prepend(code_point); + iso2022jp_state = states.Roman; + return [0x1B, 0x28, 0x4A]; + } + + // 8. If code point is U+2212, set it to U+FF0D. + if (code_point === 0x2212) + code_point = 0xFF0D; + + // 9. Let pointer be the index pointer for code point in index + // jis0208. + var pointer = indexPointerFor(code_point, index('jis0208')); + + // 10. If pointer is null, return error with code point. + if (pointer === null) + return encoderError(code_point); + + // 11. If iso-2022-jp encoder state is not jis0208, prepend code + // point to stream, set iso-2022-jp encoder state to jis0208, + // and return three bytes 0x1B 0x24 0x42. + if (iso2022jp_state !== states.jis0208) { + stream.prepend(code_point); + iso2022jp_state = states.jis0208; + return [0x1B, 0x24, 0x42]; + } + + // 12. Let lead be floor(pointer / 94) + 0x21. + var lead = floor(pointer / 94) + 0x21; + + // 13. Let trail be pointer % 94 + 0x21. + var trail = pointer % 94 + 0x21; + + // 14. Return two bytes whose values are lead and trail. + return [lead, trail]; + }; + } + + /** @param {{fatal: boolean}} options */ + encoders['ISO-2022-JP'] = function(options) { + return new ISO2022JPEncoder(options); + }; + /** @param {{fatal: boolean}} options */ + decoders['ISO-2022-JP'] = function(options) { + return new ISO2022JPDecoder(options); + }; + + // 13.3 shift_jis + + // 13.3.1 shift_jis decoder + /** + * @constructor + * @implements {Decoder} + * @param {{fatal: boolean}} options + */ + function ShiftJISDecoder(options) { + var fatal = options.fatal; + // shift_jis's decoder has an associated shift_jis lead (initially + // 0x00). + var /** @type {number} */ shiftjis_lead = 0x00; + /** + * @param {Stream} stream The stream of bytes being decoded. + * @param {number} bite The next byte read from the stream. + * @return {?(number|!Array.)} The next code point(s) + * decoded, or null if not enough data exists in the input + * stream to decode a complete code point. + */ + this.handler = function(stream, bite) { + // 1. If byte is end-of-stream and shift_jis lead is not 0x00, + // set shift_jis lead to 0x00 and return error. + if (bite === end_of_stream && shiftjis_lead !== 0x00) { + shiftjis_lead = 0x00; + return decoderError(fatal); + } + + // 2. If byte is end-of-stream and shift_jis lead is 0x00, + // return finished. + if (bite === end_of_stream && shiftjis_lead === 0x00) + return finished; + + // 3. If shift_jis lead is not 0x00, let lead be shift_jis lead, + // let pointer be null, set shift_jis lead to 0x00, and then run + // these substeps: + if (shiftjis_lead !== 0x00) { + var lead = shiftjis_lead; + var pointer = null; + shiftjis_lead = 0x00; + + // 1. Let offset be 0x40, if byte is less than 0x7F, and 0x41 + // otherwise. + var offset = (bite < 0x7F) ? 0x40 : 0x41; + + // 2. Let lead offset be 0x81, if lead is less than 0xA0, and + // 0xC1 otherwise. + var lead_offset = (lead < 0xA0) ? 0x81 : 0xC1; + + // 3. If byte is in the range 0x40 to 0x7E or 0x80 to 0xFC, + // set pointer to (lead − lead offset) × 188 + byte − offset. + if (inRange(bite, 0x40, 0x7E) || inRange(bite, 0x80, 0xFC)) + pointer = (lead - lead_offset) * 188 + bite - offset; + + // 4. Let code point be null, if pointer is null, and the + // index code point for pointer in index jis0208 otherwise. + var code_point = (pointer === null) ? null : + indexCodePointFor(pointer, index('jis0208')); + + // 5. If code point is null and pointer is in the range 8836 + // to 10528, return a code point whose value is 0xE000 + + // pointer − 8836. + if (code_point === null && pointer !== null && + inRange(pointer, 8836, 10528)) + return 0xE000 + pointer - 8836; + + // 6. If code point is null and byte is an ASCII byte, prepend + // byte to stream. + if (code_point === null && isASCIIByte(bite)) + stream.prepend(bite); + + // 7. If code point is null, return error. + if (code_point === null) + return decoderError(fatal); + + // 8. Return a code point whose value is code point. + return code_point; + } + + // 4. If byte is an ASCII byte or 0x80, return a code point + // whose value is byte. + if (isASCIIByte(bite) || bite === 0x80) + return bite; + + // 5. If byte is in the range 0xA1 to 0xDF, return a code point + // whose value is 0xFF61 + byte − 0xA1. + if (inRange(bite, 0xA1, 0xDF)) + return 0xFF61 + bite - 0xA1; + + // 6. If byte is in the range 0x81 to 0x9F or 0xE0 to 0xFC, set + // shift_jis lead to byte and return continue. + if (inRange(bite, 0x81, 0x9F) || inRange(bite, 0xE0, 0xFC)) { + shiftjis_lead = bite; + return null; + } + + // 7. Return error. + return decoderError(fatal); + }; + } + + // 13.3.2 shift_jis encoder + /** + * @constructor + * @implements {Encoder} + * @param {{fatal: boolean}} options + */ + function ShiftJISEncoder(options) { + var fatal = options.fatal; + /** + * @param {Stream} stream Input stream. + * @param {number} code_point Next code point read from the stream. + * @return {(number|!Array.)} Byte(s) to emit. + */ + this.handler = function(stream, code_point) { + // 1. If code point is end-of-stream, return finished. + if (code_point === end_of_stream) + return finished; + + // 2. If code point is an ASCII code point or U+0080, return a + // byte whose value is code point. + if (isASCIICodePoint(code_point) || code_point === 0x0080) + return code_point; + + // 3. If code point is U+00A5, return byte 0x5C. + if (code_point === 0x00A5) + return 0x5C; + + // 4. If code point is U+203E, return byte 0x7E. + if (code_point === 0x203E) + return 0x7E; + + // 5. If code point is in the range U+FF61 to U+FF9F, return a + // byte whose value is code point − 0xFF61 + 0xA1. + if (inRange(code_point, 0xFF61, 0xFF9F)) + return code_point - 0xFF61 + 0xA1; + + // 6. If code point is U+2212, set it to U+FF0D. + if (code_point === 0x2212) + code_point = 0xFF0D; + + // 7. Let pointer be the index shift_jis pointer for code point. + var pointer = indexShiftJISPointerFor(code_point); + + // 8. If pointer is null, return error with code point. + if (pointer === null) + return encoderError(code_point); + + // 9. Let lead be floor(pointer / 188). + var lead = floor(pointer / 188); + + // 10. Let lead offset be 0x81, if lead is less than 0x1F, and + // 0xC1 otherwise. + var lead_offset = (lead < 0x1F) ? 0x81 : 0xC1; + + // 11. Let trail be pointer % 188. + var trail = pointer % 188; + + // 12. Let offset be 0x40, if trail is less than 0x3F, and 0x41 + // otherwise. + var offset = (trail < 0x3F) ? 0x40 : 0x41; + + // 13. Return two bytes whose values are lead + lead offset and + // trail + offset. + return [lead + lead_offset, trail + offset]; + }; + } + + /** @param {{fatal: boolean}} options */ + encoders['Shift_JIS'] = function(options) { + return new ShiftJISEncoder(options); + }; + /** @param {{fatal: boolean}} options */ + decoders['Shift_JIS'] = function(options) { + return new ShiftJISDecoder(options); + }; + + // + // 14. Legacy multi-byte Korean encodings + // + + // 14.1 euc-kr + + // 14.1.1 euc-kr decoder + /** + * @constructor + * @implements {Decoder} + * @param {{fatal: boolean}} options + */ + function EUCKRDecoder(options) { + var fatal = options.fatal; + + // euc-kr's decoder has an associated euc-kr lead (initially 0x00). + var /** @type {number} */ euckr_lead = 0x00; + /** + * @param {Stream} stream The stream of bytes being decoded. + * @param {number} bite The next byte read from the stream. + * @return {?(number|!Array.)} The next code point(s) + * decoded, or null if not enough data exists in the input + * stream to decode a complete code point. + */ + this.handler = function(stream, bite) { + // 1. If byte is end-of-stream and euc-kr lead is not 0x00, set + // euc-kr lead to 0x00 and return error. + if (bite === end_of_stream && euckr_lead !== 0) { + euckr_lead = 0x00; + return decoderError(fatal); + } + + // 2. If byte is end-of-stream and euc-kr lead is 0x00, return + // finished. + if (bite === end_of_stream && euckr_lead === 0) + return finished; + + // 3. If euc-kr lead is not 0x00, let lead be euc-kr lead, let + // pointer be null, set euc-kr lead to 0x00, and then run these + // substeps: + if (euckr_lead !== 0x00) { + var lead = euckr_lead; + var pointer = null; + euckr_lead = 0x00; + + // 1. If byte is in the range 0x41 to 0xFE, set pointer to + // (lead − 0x81) × 190 + (byte − 0x41). + if (inRange(bite, 0x41, 0xFE)) + pointer = (lead - 0x81) * 190 + (bite - 0x41); + + // 2. Let code point be null, if pointer is null, and the + // index code point for pointer in index euc-kr otherwise. + var code_point = (pointer === null) + ? null : indexCodePointFor(pointer, index('euc-kr')); + + // 3. If code point is null and byte is an ASCII byte, prepend + // byte to stream. + if (pointer === null && isASCIIByte(bite)) + stream.prepend(bite); + + // 4. If code point is null, return error. + if (code_point === null) + return decoderError(fatal); + + // 5. Return a code point whose value is code point. + return code_point; + } + + // 4. If byte is an ASCII byte, return a code point whose value + // is byte. + if (isASCIIByte(bite)) + return bite; + + // 5. If byte is in the range 0x81 to 0xFE, set euc-kr lead to + // byte and return continue. + if (inRange(bite, 0x81, 0xFE)) { + euckr_lead = bite; + return null; + } + + // 6. Return error. + return decoderError(fatal); + }; + } + + // 14.1.2 euc-kr encoder + /** + * @constructor + * @implements {Encoder} + * @param {{fatal: boolean}} options + */ + function EUCKREncoder(options) { + var fatal = options.fatal; + /** + * @param {Stream} stream Input stream. + * @param {number} code_point Next code point read from the stream. + * @return {(number|!Array.)} Byte(s) to emit. + */ + this.handler = function(stream, code_point) { + // 1. If code point is end-of-stream, return finished. + if (code_point === end_of_stream) + return finished; + + // 2. If code point is an ASCII code point, return a byte whose + // value is code point. + if (isASCIICodePoint(code_point)) + return code_point; + + // 3. Let pointer be the index pointer for code point in index + // euc-kr. + var pointer = indexPointerFor(code_point, index('euc-kr')); + + // 4. If pointer is null, return error with code point. + if (pointer === null) + return encoderError(code_point); + + // 5. Let lead be floor(pointer / 190) + 0x81. + var lead = floor(pointer / 190) + 0x81; + + // 6. Let trail be pointer % 190 + 0x41. + var trail = (pointer % 190) + 0x41; + + // 7. Return two bytes whose values are lead and trail. + return [lead, trail]; + }; + } + + /** @param {{fatal: boolean}} options */ + encoders['EUC-KR'] = function(options) { + return new EUCKREncoder(options); + }; + /** @param {{fatal: boolean}} options */ + decoders['EUC-KR'] = function(options) { + return new EUCKRDecoder(options); + }; + + + // + // 15. Legacy miscellaneous encodings + // + + // 15.1 replacement + + // Not needed - API throws RangeError + + // 15.2 Common infrastructure for utf-16be and utf-16le + + /** + * @param {number} code_unit + * @param {boolean} utf16be + * @return {!Array.} bytes + */ + function convertCodeUnitToBytes(code_unit, utf16be) { + // 1. Let byte1 be code unit >> 8. + var byte1 = code_unit >> 8; + + // 2. Let byte2 be code unit & 0x00FF. + var byte2 = code_unit & 0x00FF; + + // 3. Then return the bytes in order: + // utf-16be flag is set: byte1, then byte2. + if (utf16be) + return [byte1, byte2]; + // utf-16be flag is unset: byte2, then byte1. + return [byte2, byte1]; + } + + // 15.2.1 shared utf-16 decoder + /** + * @constructor + * @implements {Decoder} + * @param {boolean} utf16_be True if big-endian, false if little-endian. + * @param {{fatal: boolean}} options + */ + function UTF16Decoder(utf16_be, options) { + var fatal = options.fatal; + var /** @type {?number} */ utf16_lead_byte = null, + /** @type {?number} */ utf16_lead_surrogate = null; + /** + * @param {Stream} stream The stream of bytes being decoded. + * @param {number} bite The next byte read from the stream. + * @return {?(number|!Array.)} The next code point(s) + * decoded, or null if not enough data exists in the input + * stream to decode a complete code point. + */ + this.handler = function(stream, bite) { + // 1. If byte is end-of-stream and either utf-16 lead byte or + // utf-16 lead surrogate is not null, set utf-16 lead byte and + // utf-16 lead surrogate to null, and return error. + if (bite === end_of_stream && (utf16_lead_byte !== null || + utf16_lead_surrogate !== null)) { + return decoderError(fatal); + } + + // 2. If byte is end-of-stream and utf-16 lead byte and utf-16 + // lead surrogate are null, return finished. + if (bite === end_of_stream && utf16_lead_byte === null && + utf16_lead_surrogate === null) { + return finished; + } + + // 3. If utf-16 lead byte is null, set utf-16 lead byte to byte + // and return continue. + if (utf16_lead_byte === null) { + utf16_lead_byte = bite; + return null; + } + + // 4. Let code unit be the result of: + var code_unit; + if (utf16_be) { + // utf-16be decoder flag is set + // (utf-16 lead byte << 8) + byte. + code_unit = (utf16_lead_byte << 8) + bite; + } else { + // utf-16be decoder flag is unset + // (byte << 8) + utf-16 lead byte. + code_unit = (bite << 8) + utf16_lead_byte; + } + // Then set utf-16 lead byte to null. + utf16_lead_byte = null; + + // 5. If utf-16 lead surrogate is not null, let lead surrogate + // be utf-16 lead surrogate, set utf-16 lead surrogate to null, + // and then run these substeps: + if (utf16_lead_surrogate !== null) { + var lead_surrogate = utf16_lead_surrogate; + utf16_lead_surrogate = null; + + // 1. If code unit is in the range U+DC00 to U+DFFF, return a + // code point whose value is 0x10000 + ((lead surrogate − + // 0xD800) << 10) + (code unit − 0xDC00). + if (inRange(code_unit, 0xDC00, 0xDFFF)) { + return 0x10000 + (lead_surrogate - 0xD800) * 0x400 + + (code_unit - 0xDC00); + } + + // 2. Prepend the sequence resulting of converting code unit + // to bytes using utf-16be decoder flag to stream and return + // error. + stream.prepend(convertCodeUnitToBytes(code_unit, utf16_be)); + return decoderError(fatal); + } + + // 6. If code unit is in the range U+D800 to U+DBFF, set utf-16 + // lead surrogate to code unit and return continue. + if (inRange(code_unit, 0xD800, 0xDBFF)) { + utf16_lead_surrogate = code_unit; + return null; + } + + // 7. If code unit is in the range U+DC00 to U+DFFF, return + // error. + if (inRange(code_unit, 0xDC00, 0xDFFF)) + return decoderError(fatal); + + // 8. Return code point code unit. + return code_unit; + }; + } + + // 15.2.2 shared utf-16 encoder + /** + * @constructor + * @implements {Encoder} + * @param {boolean} utf16_be True if big-endian, false if little-endian. + * @param {{fatal: boolean}} options + */ + function UTF16Encoder(utf16_be, options) { + var fatal = options.fatal; + /** + * @param {Stream} stream Input stream. + * @param {number} code_point Next code point read from the stream. + * @return {(number|!Array.)} Byte(s) to emit. + */ + this.handler = function(stream, code_point) { + // 1. If code point is end-of-stream, return finished. + if (code_point === end_of_stream) + return finished; + + // 2. If code point is in the range U+0000 to U+FFFF, return the + // sequence resulting of converting code point to bytes using + // utf-16be encoder flag. + if (inRange(code_point, 0x0000, 0xFFFF)) + return convertCodeUnitToBytes(code_point, utf16_be); + + // 3. Let lead be ((code point − 0x10000) >> 10) + 0xD800, + // converted to bytes using utf-16be encoder flag. + var lead = convertCodeUnitToBytes( + ((code_point - 0x10000) >> 10) + 0xD800, utf16_be); + + // 4. Let trail be ((code point − 0x10000) & 0x3FF) + 0xDC00, + // converted to bytes using utf-16be encoder flag. + var trail = convertCodeUnitToBytes( + ((code_point - 0x10000) & 0x3FF) + 0xDC00, utf16_be); + + // 5. Return a byte sequence of lead followed by trail. + return lead.concat(trail); + }; + } + + // 15.3 utf-16be + // 15.3.1 utf-16be decoder + /** @param {{fatal: boolean}} options */ + encoders['UTF-16BE'] = function(options) { + return new UTF16Encoder(true, options); + }; + // 15.3.2 utf-16be encoder + /** @param {{fatal: boolean}} options */ + decoders['UTF-16BE'] = function(options) { + return new UTF16Decoder(true, options); + }; + + // 15.4 utf-16le + // 15.4.1 utf-16le decoder + /** @param {{fatal: boolean}} options */ + encoders['UTF-16LE'] = function(options) { + return new UTF16Encoder(false, options); + }; + // 15.4.2 utf-16le encoder + /** @param {{fatal: boolean}} options */ + decoders['UTF-16LE'] = function(options) { + return new UTF16Decoder(false, options); + }; + + // 15.5 x-user-defined + + // 15.5.1 x-user-defined decoder + /** + * @constructor + * @implements {Decoder} + * @param {{fatal: boolean}} options + */ + function XUserDefinedDecoder(options) { + var fatal = options.fatal; + /** + * @param {Stream} stream The stream of bytes being decoded. + * @param {number} bite The next byte read from the stream. + * @return {?(number|!Array.)} The next code point(s) + * decoded, or null if not enough data exists in the input + * stream to decode a complete code point. + */ + this.handler = function(stream, bite) { + // 1. If byte is end-of-stream, return finished. + if (bite === end_of_stream) + return finished; + + // 2. If byte is an ASCII byte, return a code point whose value + // is byte. + if (isASCIIByte(bite)) + return bite; + + // 3. Return a code point whose value is 0xF780 + byte − 0x80. + return 0xF780 + bite - 0x80; + }; + } + + // 15.5.2 x-user-defined encoder + /** + * @constructor + * @implements {Encoder} + * @param {{fatal: boolean}} options + */ + function XUserDefinedEncoder(options) { + var fatal = options.fatal; + /** + * @param {Stream} stream Input stream. + * @param {number} code_point Next code point read from the stream. + * @return {(number|!Array.)} Byte(s) to emit. + */ + this.handler = function(stream, code_point) { + // 1.If code point is end-of-stream, return finished. + if (code_point === end_of_stream) + return finished; + + // 2. If code point is an ASCII code point, return a byte whose + // value is code point. + if (isASCIICodePoint(code_point)) + return code_point; + + // 3. If code point is in the range U+F780 to U+F7FF, return a + // byte whose value is code point − 0xF780 + 0x80. + if (inRange(code_point, 0xF780, 0xF7FF)) + return code_point - 0xF780 + 0x80; + + // 4. Return error with code point. + return encoderError(code_point); + }; + } + + /** @param {{fatal: boolean}} options */ + encoders['x-user-defined'] = function(options) { + return new XUserDefinedEncoder(options); + }; + /** @param {{fatal: boolean}} options */ + decoders['x-user-defined'] = function(options) { + return new XUserDefinedDecoder(options); + }; + + if (!global['TextEncoder']) + global['TextEncoder'] = TextEncoder; + if (!global['TextDecoder']) + global['TextDecoder'] = TextDecoder; + + if (typeof module !== "undefined" && module.exports) { + module.exports = { + TextEncoder: global['TextEncoder'], + TextDecoder: global['TextDecoder'], + EncodingIndexes: global["encoding-indexes"] + }; + } +}(this)); diff --git a/package.json b/package.json index a3986f6..d94b111 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tincanjs", "description": "Experience API (Tin Can API) Library", - "version": "0.41.1", + "version": "0.50.0", "private": false, "license": "Apache-2.0", "main": "build/tincan-node.js",