whale.js 9.2 KB

1
  1. var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(d){var e=0;return function(){return e<d.length?{done:!1,value:d[e++]}:{done:!0}}};$jscomp.arrayIterator=function(d){return{next:$jscomp.arrayIteratorImpl(d)}};$jscomp.makeIterator=function(d){var e="undefined"!=typeof Symbol&&Symbol.iterator&&d[Symbol.iterator];return e?e.call(d):$jscomp.arrayIterator(d)};$jscomp.getGlobal=function(d){return"undefined"!=typeof window&&window===d?d:"undefined"!=typeof global&&null!=global?global:d};$jscomp.global=$jscomp.getGlobal(this);$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(d,e,h){d!=Array.prototype&&d!=Object.prototype&&(d[e]=h.value)};$jscomp.polyfill=function(d,e,h,f){if(e){h=$jscomp.global;d=d.split(".");for(f=0;f<d.length-1;f++){var c=d[f];c in h||(h[c]={});h=h[c]}d=d[d.length-1];f=h[d];e=e(f);e!=f&&null!=e&&$jscomp.defineProperty(h,d,{configurable:!0,writable:!0,value:e})}};$jscomp.FORCE_POLYFILL_PROMISE=!1;$jscomp.polyfill("Promise",function(d){function e(){this.batch_=null}function h(a){return a instanceof c?a:new c(function(b,c){b(a)})}if(d&&!$jscomp.FORCE_POLYFILL_PROMISE)return d;e.prototype.asyncExecute=function(a){if(null==this.batch_){this.batch_=[];var b=this;this.asyncExecuteFunction(function(){b.executeBatch_()})}this.batch_.push(a)};var f=$jscomp.global.setTimeout;e.prototype.asyncExecuteFunction=function(a){f(a,0)};e.prototype.executeBatch_=function(){for(;this.batch_&&this.batch_.length;){var a=this.batch_;this.batch_=[];for(var b=0;b<a.length;++b){var c=a[b];a[b]=null;try{c()}catch(m){this.asyncThrow_(m)}}}this.batch_=null};e.prototype.asyncThrow_=function(a){this.asyncExecuteFunction(function(){throw a;})};var c=function(a){this.state_=0;this.result_=void 0;this.onSettledCallbacks_=[];var b=this.createResolveAndReject_();try{a(b.resolve,b.reject)}catch(g){b.reject(g)}};c.prototype.createResolveAndReject_=function(){function a(a){return function(g){c||(c=!0,a.call(b,g))}}var b=this,c=!1;return{resolve:a(this.resolveTo_),reject:a(this.reject_)}};c.prototype.resolveTo_=function(a){if(a===this)this.reject_(new TypeError("A Promise cannot resolve to itself"));else if(a instanceof c)this.settleSameAsPromise_(a);else{a:switch(typeof a){case "object":var b=null!=a;break a;case "function":b=!0;break a;default:b=!1}b?this.resolveToNonPromiseObj_(a):this.fulfill_(a)}};c.prototype.resolveToNonPromiseObj_=function(a){var b=void 0;try{b=a.then}catch(g){this.reject_(g);return}"function"==typeof b?this.settleSameAsThenable_(b,a):this.fulfill_(a)};c.prototype.reject_=function(a){this.settle_(2,a)};c.prototype.fulfill_=function(a){this.settle_(1,a)};c.prototype.settle_=function(a,b){if(0!=this.state_)throw Error("Cannot settle("+a+", "+b+"): Promise already settled in state"+this.state_);this.state_=a;this.result_=b;this.executeOnSettledCallbacks_()};c.prototype.executeOnSettledCallbacks_=function(){if(null!=this.onSettledCallbacks_){for(var a=0;a<this.onSettledCallbacks_.length;++a)k.asyncExecute(this.onSettledCallbacks_[a]);this.onSettledCallbacks_=null}};var k=new e;c.prototype.settleSameAsPromise_=function(a){var b=this.createResolveAndReject_();a.callWhenSettled_(b.resolve,b.reject)};c.prototype.settleSameAsThenable_=function(a,b){var c=this.createResolveAndReject_();try{a.call(b,c.resolve,c.reject)}catch(m){c.reject(m)}};c.prototype.then=function(a,b){function g(a,b){return"function"==typeof a?function(b){try{e(a(b))}catch(p){k(p)}}:b}var e,k,d=new c(function(a,b){e=a;k=b});this.callWhenSettled_(g(a,e),g(b,k));return d};c.prototype.catch=function(a){return this.then(void 0,a)};c.prototype.callWhenSettled_=function(a,b){function c(){switch(e.state_){case 1:a(e.result_);break;case 2:b(e.result_);break;default:throw Error("Unexpected state: "+e.state_);}}var e=this;null==this.onSettledCallbacks_?k.asyncExecute(c):this.onSettledCallbacks_.push(c)};c.resolve=h;c.reject=function(a){return new c(function(b,c){c(a)})};c.race=function(a){return new c(function(b,c){for(var g=$jscomp.makeIterator(a),e=g.next();!e.done;e=g.next())h(e.value).callWhenSettled_(b,c)})};c.all=function(a){var b=$jscomp.makeIterator(a),g=b.next();return g.done?h([]):new c(function(a,c){function e(b){return function(c){k[b]=c;d--;0==d&&a(k)}}var k=[],d=0;do k.push(void 0),d++,h(g.value).callWhenSettled_(e(k.length-1),c),g=b.next();while(!g.done)})};return c},"es6","es3");var __crosscertwhale=function(d){var e=navigator.whaleCertManager;e.issuer="unisign";e.ip=d.ESVS.CMPIP;e.port=d.ESVS.CMPPort;var h=[],f=[];return{getCerts:function(c,k,a){c==d.CONST.__USFB_M_HDD.device?e.get({keyUsages:["digitalSignature"]}).then(function(b){var c=[];f=[];for(var e=0;e<b.length;++e)c.push({index:e+1,cert:b[e].derEncodedBuffer.toBase64()}),f.push(b[e]);a(0,"",c)}).catch(function(b){"undefined"==typeof b.code&&(b.code=-1);a(b.code,b.message)}):0==h.length||k>h.length||0>k?a(0,"",[]):e.get({keyUsages:["digitalSignature"],storageType:"portable"}).then(function(b){var c=[];f=[];for(var e=1,d=0;d<b.length;++d)h[k-1]==b[d].storageVolume&&(c.push({index:e++,cert:b[d].derEncodedBuffer.toBase64()}),f.push(b[d]));a(0,"",c)}).catch(function(b){"undefined"==typeof b.code&&(b.code=-1);a(b.code,b.message)})},getDiskList:function(c){e.getRemovableDrives().then(function(e){var a=[];h=[];for(var b=0;b<e.length;++b)a.push(e[b].volume+"("+e[b].name+")"),h.push(e[b].volume);c(0,"",a)}).catch(function(c){"undefined"==typeof c.code&&(c.code=-1)})},getCertR:function(c,k,a){e.getVidWithPrikey(f[c-1],k).then(function(b){b.success?(b=d.usWebToolkit.util.bytesToHex(d.usWebToolkit.util.decode64(b.data.toBase64())),a(0,"",b)):a(b.errorCode,b.errorMessage)}).catch(function(b){"undefined"==typeof b.code&&(b.code=-1);a(b.code,b.message)})},verifyCertitficate:function(c,d){e.verifyCertificate(f[c-1]).then(function(a){a.success?d(0,""):d(a.errorCode,a.errorMessage)}).catch(function(a){"undefined"==typeof a.code&&(a.code=-1);d(a.code,a.message)})},getCACertificates:function(c,d){e.getCertPath(f[c-1]).then(function(a){var b="";(new Uint8Array(a.hashOfRootCa)).forEach(function(a,c,e){a=a.toString(16);1==a.length&&(a="0"+a);b+=a});b.toUpperCase();d(0,"",a.ca.derEncodedBuffer.toBase64(),a.rootCa.derEncodedBuffer.toBase64(),b)}).catch(function(a){"undefined"==typeof a.code&&(a.code=-1);d(a.code,a.message)})},issueCertificate:function(c,d,a,b,g,f){var k="root";""==b&&(k=h[g-1].substr(0,1));e.issueCertificate(c,d,a,k).then(function(a){a.success?f(0,""):f(a.errorCode,a.errorMessage)}).catch(function(a){"undefined"==typeof a.code&&(a.code=-1);f(a.code,a.message)})},reNewCertificate:function(c,d,a){e.updateCertificate(f[c-1],d).then(function(b){b.success?a(0,""):a(b.errorCode,b.errorMessage)}).catch(function(b){"undefined"==typeof b.code&&(b.code=-1);a(b.code,b.message)})},revokeCertificate:function(c,d,a,b){e.revokeCertificate(f[c-1],d,a).then(function(a){a.success?b(0,""):b(a.errorCode,a.errorMessage)}).catch(function(a){"undefined"==typeof a.code&&(a.code=-1);b(a.code,a.message)})},verifyVID:function(c,d,a,b){e.verifyVID(f[c-1],d,a).then(function(a){a.success?b(0,""):b(a.errorCode,a.errorMessage)}).catch(function(a){"undefined"==typeof a.code&&(a.code=-1);b(a.code,a.message)})},normalizeXML:function(c,d){e.normalizeXMLData(c).then(function(a){d(0,"",a)}).catch(function(a){"undefined"==typeof a.code&&(a.code=-1);d(a.code,a.message)})},getSignDataP1:function(c,d,a,b){var g=[];if("string"==typeof c)g.push(e.genSignatureValue(f[d-1],a,c));else for(var k in c)""!=c[k]&&g.push(e.genSignatureValue(f[d-1],a,c[k]));Promise.all(g).then(function(a){if("string"!=typeof c){var e=0,d={},g;for(g in c)d[g]=""==c[g]?"":a[e].success?a[e++].data.toBase64():"";b(0,"",d)}else a[0].success?b(0,"",a[0].data.toBase64()):b(a[0].errorCode,a[0].errorMessage)}).catch(function(a){"undefined"==typeof a.code&&(a.code=-1);b(a.code,a.message)})},getSignDataP7:function(c,d,a,b,g){var k="",h=[];if("string"==typeof c)h.push(e.sign(f[d-1],a,c,b));else for(var n in c)""!=c[n]&&h.push(e.sign(f[d-1],a,c[n],b));Promise.all(h).then(function(a){var d=[],f={};if("string"==typeof c)if(a[0].success)k=a[0].data.toBase64(),b?d.push(e.verifySignedData(a[0].data)):d.push(e.verifySignedData(a[0].data,c));else{g(a[0].errorCode,a[0].errorMessage);return}else{var h=0,l;for(l in c)""!=c[l]?a[h].success?(f[l]=a[h].data.toBase64(),b?d.push(e.verifySignedData(a[h++].data)):d.push(e.verifySignedData(a[h++].data,c[l]))):(c[l]="",f[l]=""):f[l]=""}Promise.all(d).then(function(a){if("string"==typeof c)a[0].success?g(0,"",k):g(a[0].errorCode,a[0].errorMessage);else{var b=0,d;for(d in f)""!=f[d]&&(a[b++].success||(f[d]=""));g(0,"",f)}}).catch(function(a){"undefined"==typeof a.code&&(a.code=-1);g(a.code,a.message)})}).catch(function(a){"undefined"==typeof a.code&&(a.code=-1);g(a.code,a.message)})},getSignDataP7_noConWithHash:function(c,d,a,b,g,h){var k="",n=[];if("string"==typeof c)n.push(e.sign(f[d-1],a,c,!1,!0,b,g));else for(var m in c)""!=c[m]&&n.push(e.sign(f[d-1],a,c[m],!1,!0,b,g));Promise.all(n).then(function(a){if("string"==typeof c)a[0].success?(k=a[0].data.toBase64(),h(0,"",k)):h(a[0].errorCode,a[0].errorMessage);else{var b=0,d={},e;for(e in c)""!=c[e]?a[b].success?d[e]=a[b++].data.toBase64():(c[e]="",d[e]="",b++):d[e]="";h(0,"",d)}}).catch(function(a){"undefined"==typeof a.code&&(a.code=-1);h(a.code,a.message)})}}};