qcloud-iotexplorer-appdev-plugin-wificonf-core
Advanced tools
Comparing version 1.0.29 to 1.1.0-alpha.0
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Aes=void 0;var BlockCipher_1=require("./BlockCipher"),util_1=require("../util");exports.Aes=function(t){BlockCipher_1.BlockCipher.call(this),exports.Aes.assertKeyArray_(t),this.key_=t,this.keyLengthInWords_=this.key_.length/4,this.numberOfRounds_=this.keyLengthInWords_+6,this.state_=[[],[],[],[]],this.temp_=[[],[],[],[]],this.keySchedule_,this.keyExpansion_()},exports.Aes.prototype=Object.create(BlockCipher_1.BlockCipher.prototype),exports.Aes.prototype.construtor=BlockCipher_1.BlockCipher,exports.Aes.prototype.BLOCK_SIZE=16,exports.Aes.BLOCK_SIZE_IN_WORDS_=exports.Aes.prototype.BLOCK_SIZE/4,exports.Aes.ENABLE_TEST_MODE=!1,exports.Aes.prototype.encrypt=function(t){exports.Aes.ENABLE_TEST_MODE&&this.testKeySchedule_(0,this.keySchedule_,0),this.copyInput_(t),this.addRoundKey_(0);for(var e=1;e<this.numberOfRounds_;++e)exports.Aes.ENABLE_TEST_MODE&&(this.testKeySchedule_(e,this.keySchedule_,e),this.testStartRound_(e,this.state_)),this.subBytes_(exports.Aes.SBOX_),exports.Aes.ENABLE_TEST_MODE&&this.testAfterSubBytes_(e,this.state_),this.shiftRows_(),exports.Aes.ENABLE_TEST_MODE&&this.testAfterShiftRows_(e,this.state_),this.mixColumns_(),exports.Aes.ENABLE_TEST_MODE&&this.testAfterMixColumns_(e,this.state_),this.addRoundKey_(e);return this.subBytes_(exports.Aes.SBOX_),exports.Aes.ENABLE_TEST_MODE&&this.testAfterSubBytes_(e,this.state_),this.shiftRows_(),exports.Aes.ENABLE_TEST_MODE&&this.testAfterShiftRows_(e,this.state_),this.addRoundKey_(this.numberOfRounds_),this.generateOutput_()},exports.Aes.prototype.decrypt=function(t){exports.Aes.ENABLE_TEST_MODE&&this.testKeySchedule_(0,this.keySchedule_,this.numberOfRounds_),this.copyInput_(t),this.addRoundKey_(this.numberOfRounds_);for(var e=1;e<this.numberOfRounds_;++e)exports.Aes.ENABLE_TEST_MODE&&(this.testKeySchedule_(e,this.keySchedule_,this.numberOfRounds_-e),this.testStartRound_(e,this.state_)),this.invShiftRows_(),exports.Aes.ENABLE_TEST_MODE&&this.testAfterShiftRows_(e,this.state_),this.subBytes_(exports.Aes.INV_SBOX_),exports.Aes.ENABLE_TEST_MODE&&this.testAfterSubBytes_(e,this.state_),this.addRoundKey_(this.numberOfRounds_-e),exports.Aes.ENABLE_TEST_MODE&&this.testAfterAddRoundKey_(e,this.state_),this.invMixColumns_();return this.invShiftRows_(),exports.Aes.ENABLE_TEST_MODE&&this.testAfterShiftRows_(e,this.state_),this.subBytes_(exports.Aes.INV_SBOX_),exports.Aes.ENABLE_TEST_MODE&&this.testAfterSubBytes_(this.numberOfRounds_,this.state_),exports.Aes.ENABLE_TEST_MODE&&this.testKeySchedule_(this.numberOfRounds_,this.keySchedule_,0),this.addRoundKey_(0),this.generateOutput_()},exports.Aes.assertKeyArray_=function(t){if(16!=t.length&&24!=t.length&&32!=t.length)throw"Key must have length 16, 24, or 32.";for(var e=0;e<t.length;e++){if("number"!=typeof t[e])throw"arr[i] must be number";if(!(t[e]>=0&&t[e]<=255))throw"arr[i] must be [0, 255]"}},exports.Aes.prototype.testStartRound_=util_1.nullFunction,exports.Aes.prototype.testAfterSubBytes_=util_1.nullFunction,exports.Aes.prototype.testAfterShiftRows_=util_1.nullFunction,exports.Aes.prototype.testAfterMixColumns_=util_1.nullFunction,exports.Aes.prototype.testAfterAddRoundKey_=util_1.nullFunction,exports.Aes.prototype.testKeySchedule_=util_1.nullFunction,exports.Aes.prototype.copyInput_=function(t){var e,s;if(t.length!==this.BLOCK_SIZE)throw"Expecting input of block size.";for(var _=0;_<exports.Aes.BLOCK_SIZE_IN_WORDS_;_++)for(var o=0;o<4;o++){if(!((e=t[s=4*o+_])<=255&&e>=0))throw"Invalid input. Value "+e+" at position "+s+" is not a byte.";this.state_[_][o]=e}},exports.Aes.prototype.generateOutput_=function(){for(var t=[],e=0;e<exports.Aes.BLOCK_SIZE_IN_WORDS_;e++)for(var s=0;s<4;s++)t[4*s+e]=this.state_[e][s];return t},exports.Aes.prototype.addRoundKey_=function(t){for(var e=0;e<4;e++)for(var s=0;s<4;s++)this.state_[e][s]^=this.keySchedule_[4*t+s][e]},exports.Aes.prototype.subBytes_=function(t){for(var e=0;e<4;e++)for(var s=0;s<4;s++)this.state_[e][s]=t[this.state_[e][s]]},exports.Aes.prototype.shiftRows_=function(){for(var t=1;t<4;t++)for(var e=0;e<4;e++)this.temp_[t][e]=this.state_[t][e];for(t=1;t<4;t++)for(e=0;e<4;e++)this.state_[t][e]=this.temp_[t][(e+t)%exports.Aes.BLOCK_SIZE_IN_WORDS_]},exports.Aes.prototype.invShiftRows_=function(){for(var t=1;t<4;t++)for(var e=0;e<4;e++)this.temp_[t][(e+t)%exports.Aes.BLOCK_SIZE_IN_WORDS_]=this.state_[t][e];for(t=1;t<4;t++)for(e=0;e<4;e++)this.state_[t][e]=this.temp_[t][e]},exports.Aes.prototype.mixColumns_=function(){for(var t=this.state_,e=this.temp_[0],s=0;s<4;s++)e[0]=t[0][s],e[1]=t[1][s],e[2]=t[2][s],e[3]=t[3][s],t[0][s]=exports.Aes.MULT_2_[e[0]]^exports.Aes.MULT_3_[e[1]]^e[2]^e[3],t[1][s]=e[0]^exports.Aes.MULT_2_[e[1]]^exports.Aes.MULT_3_[e[2]]^e[3],t[2][s]=e[0]^e[1]^exports.Aes.MULT_2_[e[2]]^exports.Aes.MULT_3_[e[3]],t[3][s]=exports.Aes.MULT_3_[e[0]]^e[1]^e[2]^exports.Aes.MULT_2_[e[3]]},exports.Aes.prototype.invMixColumns_=function(){for(var t=this.state_,e=this.temp_[0],s=0;s<4;s++)e[0]=t[0][s],e[1]=t[1][s],e[2]=t[2][s],e[3]=t[3][s],t[0][s]=exports.Aes.MULT_E_[e[0]]^exports.Aes.MULT_B_[e[1]]^exports.Aes.MULT_D_[e[2]]^exports.Aes.MULT_9_[e[3]],t[1][s]=exports.Aes.MULT_9_[e[0]]^exports.Aes.MULT_E_[e[1]]^exports.Aes.MULT_B_[e[2]]^exports.Aes.MULT_D_[e[3]],t[2][s]=exports.Aes.MULT_D_[e[0]]^exports.Aes.MULT_9_[e[1]]^exports.Aes.MULT_E_[e[2]]^exports.Aes.MULT_B_[e[3]],t[3][s]=exports.Aes.MULT_B_[e[0]]^exports.Aes.MULT_D_[e[1]]^exports.Aes.MULT_9_[e[2]]^exports.Aes.MULT_E_[e[3]]},exports.Aes.prototype.keyExpansion_=function(){this.keySchedule_=new Array(exports.Aes.BLOCK_SIZE_IN_WORDS_*(this.numberOfRounds_+1));for(var t=0;t<this.keyLengthInWords_;t++)this.keySchedule_[t]=[this.key_[4*t],this.key_[4*t+1],this.key_[4*t+2],this.key_[4*t+3]];var e=new Array(4);for(t=this.keyLengthInWords_;t<exports.Aes.BLOCK_SIZE_IN_WORDS_*(this.numberOfRounds_+1);t++)e[0]=this.keySchedule_[t-1][0],e[1]=this.keySchedule_[t-1][1],e[2]=this.keySchedule_[t-1][2],e[3]=this.keySchedule_[t-1][3],t%this.keyLengthInWords_==0?(this.rotWord_(e),this.subWord_(e),e[0]^=exports.Aes.RCON_[t/this.keyLengthInWords_][0],e[1]^=exports.Aes.RCON_[t/this.keyLengthInWords_][1],e[2]^=exports.Aes.RCON_[t/this.keyLengthInWords_][2],e[3]^=exports.Aes.RCON_[t/this.keyLengthInWords_][3]):this.keyLengthInWords_>6&&t%this.keyLengthInWords_==4&&this.subWord_(e),this.keySchedule_[t]=new Array(4),this.keySchedule_[t][0]=this.keySchedule_[t-this.keyLengthInWords_][0]^e[0],this.keySchedule_[t][1]=this.keySchedule_[t-this.keyLengthInWords_][1]^e[1],this.keySchedule_[t][2]=this.keySchedule_[t-this.keyLengthInWords_][2]^e[2],this.keySchedule_[t][3]=this.keySchedule_[t-this.keyLengthInWords_][3]^e[3]},exports.Aes.prototype.subWord_=function(t){return t[0]=exports.Aes.SBOX_[t[0]],t[1]=exports.Aes.SBOX_[t[1]],t[2]=exports.Aes.SBOX_[t[2]],t[3]=exports.Aes.SBOX_[t[3]],t},exports.Aes.prototype.rotWord_=function(t){var e=t[0];return t[0]=t[1],t[1]=t[2],t[2]=t[3],t[3]=e,t},exports.Aes.SBOX_=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],exports.Aes.INV_SBOX_=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],exports.Aes.RCON_=[[0,0,0,0],[1,0,0,0],[2,0,0,0],[4,0,0,0],[8,0,0,0],[16,0,0,0],[32,0,0,0],[64,0,0,0],[128,0,0,0],[27,0,0,0],[54,0,0,0]],exports.Aes.MULT_2_=[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,27,25,31,29,19,17,23,21,11,9,15,13,3,1,7,5,59,57,63,61,51,49,55,53,43,41,47,45,35,33,39,37,91,89,95,93,83,81,87,85,75,73,79,77,67,65,71,69,123,121,127,125,115,113,119,117,107,105,111,109,99,97,103,101,155,153,159,157,147,145,151,149,139,137,143,141,131,129,135,133,187,185,191,189,179,177,183,181,171,169,175,173,163,161,167,165,219,217,223,221,211,209,215,213,203,201,207,205,195,193,199,197,251,249,255,253,243,241,247,245,235,233,239,237,227,225,231,229],exports.Aes.MULT_3_=[0,3,6,5,12,15,10,9,24,27,30,29,20,23,18,17,48,51,54,53,60,63,58,57,40,43,46,45,36,39,34,33,96,99,102,101,108,111,106,105,120,123,126,125,116,119,114,113,80,83,86,85,92,95,90,89,72,75,78,77,68,71,66,65,192,195,198,197,204,207,202,201,216,219,222,221,212,215,210,209,240,243,246,245,252,255,250,249,232,235,238,237,228,231,226,225,160,163,166,165,172,175,170,169,184,187,190,189,180,183,178,177,144,147,150,149,156,159,154,153,136,139,142,141,132,135,130,129,155,152,157,158,151,148,145,146,131,128,133,134,143,140,137,138,171,168,173,174,167,164,161,162,179,176,181,182,191,188,185,186,251,248,253,254,247,244,241,242,227,224,229,230,239,236,233,234,203,200,205,206,199,196,193,194,211,208,213,214,223,220,217,218,91,88,93,94,87,84,81,82,67,64,69,70,79,76,73,74,107,104,109,110,103,100,97,98,115,112,117,118,127,124,121,122,59,56,61,62,55,52,49,50,35,32,37,38,47,44,41,42,11,8,13,14,7,4,1,2,19,16,21,22,31,28,25,26],exports.Aes.MULT_9_=[0,9,18,27,36,45,54,63,72,65,90,83,108,101,126,119,144,153,130,139,180,189,166,175,216,209,202,195,252,245,238,231,59,50,41,32,31,22,13,4,115,122,97,104,87,94,69,76,171,162,185,176,143,134,157,148,227,234,241,248,199,206,213,220,118,127,100,109,82,91,64,73,62,55,44,37,26,19,8,1,230,239,244,253,194,203,208,217,174,167,188,181,138,131,152,145,77,68,95,86,105,96,123,114,5,12,23,30,33,40,51,58,221,212,207,198,249,240,235,226,149,156,135,142,177,184,163,170,236,229,254,247,200,193,218,211,164,173,182,191,128,137,146,155,124,117,110,103,88,81,74,67,52,61,38,47,16,25,2,11,215,222,197,204,243,250,225,232,159,150,141,132,187,178,169,160,71,78,85,92,99,106,113,120,15,6,29,20,43,34,57,48,154,147,136,129,190,183,172,165,210,219,192,201,246,255,228,237,10,3,24,17,46,39,60,53,66,75,80,89,102,111,116,125,161,168,179,186,133,140,151,158,233,224,251,242,205,196,223,214,49,56,35,42,21,28,7,14,121,112,107,98,93,84,79,70],exports.Aes.MULT_B_=[0,11,22,29,44,39,58,49,88,83,78,69,116,127,98,105,176,187,166,173,156,151,138,129,232,227,254,245,196,207,210,217,123,112,109,102,87,92,65,74,35,40,53,62,15,4,25,18,203,192,221,214,231,236,241,250,147,152,133,142,191,180,169,162,246,253,224,235,218,209,204,199,174,165,184,179,130,137,148,159,70,77,80,91,106,97,124,119,30,21,8,3,50,57,36,47,141,134,155,144,161,170,183,188,213,222,195,200,249,242,239,228,61,54,43,32,17,26,7,12,101,110,115,120,73,66,95,84,247,252,225,234,219,208,205,198,175,164,185,178,131,136,149,158,71,76,81,90,107,96,125,118,31,20,9,2,51,56,37,46,140,135,154,145,160,171,182,189,212,223,194,201,248,243,238,229,60,55,42,33,16,27,6,13,100,111,114,121,72,67,94,85,1,10,23,28,45,38,59,48,89,82,79,68,117,126,99,104,177,186,167,172,157,150,139,128,233,226,255,244,197,206,211,216,122,113,108,103,86,93,64,75,34,41,52,63,14,5,24,19,202,193,220,215,230,237,240,251,146,153,132,143,190,181,168,163],exports.Aes.MULT_D_=[0,13,26,23,52,57,46,35,104,101,114,127,92,81,70,75,208,221,202,199,228,233,254,243,184,181,162,175,140,129,150,155,187,182,161,172,143,130,149,152,211,222,201,196,231,234,253,240,107,102,113,124,95,82,69,72,3,14,25,20,55,58,45,32,109,96,119,122,89,84,67,78,5,8,31,18,49,60,43,38,189,176,167,170,137,132,147,158,213,216,207,194,225,236,251,246,214,219,204,193,226,239,248,245,190,179,164,169,138,135,144,157,6,11,28,17,50,63,40,37,110,99,116,121,90,87,64,77,218,215,192,205,238,227,244,249,178,191,168,165,134,139,156,145,10,7,16,29,62,51,36,41,98,111,120,117,86,91,76,65,97,108,123,118,85,88,79,66,9,4,19,30,61,48,39,42,177,188,171,166,133,136,159,146,217,212,195,206,237,224,247,250,183,186,173,160,131,142,153,148,223,210,197,200,235,230,241,252,103,106,125,112,83,94,73,68,15,2,21,24,59,54,33,44,12,1,22,27,56,53,34,47,100,105,126,115,80,93,74,71,220,209,198,203,232,229,242,255,180,185,174,163,128,141,154,151],exports.Aes.MULT_E_=[0,14,28,18,56,54,36,42,112,126,108,98,72,70,84,90,224,238,252,242,216,214,196,202,144,158,140,130,168,166,180,186,219,213,199,201,227,237,255,241,171,165,183,185,147,157,143,129,59,53,39,41,3,13,31,17,75,69,87,89,115,125,111,97,173,163,177,191,149,155,137,135,221,211,193,207,229,235,249,247,77,67,81,95,117,123,105,103,61,51,33,47,5,11,25,23,118,120,106,100,78,64,82,92,6,8,26,20,62,48,34,44,150,152,138,132,174,160,178,188,230,232,250,244,222,208,194,204,65,79,93,83,121,119,101,107,49,63,45,35,9,7,21,27,161,175,189,179,153,151,133,139,209,223,205,195,233,231,245,251,154,148,134,136,162,172,190,176,234,228,246,248,210,220,206,192,122,116,102,104,66,76,94,80,10,4,22,24,50,60,46,32,236,226,240,254,212,218,200,198,156,146,128,142,164,170,184,182,12,2,16,30,52,58,40,38,124,114,96,110,68,74,88,86,55,57,43,37,15,1,19,29,71,73,91,85,127,113,99,109,215,217,203,197,239,225,243,253,167,169,187,181,159,145,131,141]; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Aes=void 0;var BlockCipher_1=require("./BlockCipher"),util_1=require("../util");exports.Aes=function(t){BlockCipher_1.BlockCipher.call(this),exports.Aes.assertKeyArray_(t),this.key_=t,this.keyLengthInWords_=this.key_.length/4,this.numberOfRounds_=this.keyLengthInWords_+6,this.state_=[[],[],[],[]],this.temp_=[[],[],[],[]],this.keySchedule_,this.keyExpansion_()},exports.Aes.prototype=Object.create(BlockCipher_1.BlockCipher.prototype),exports.Aes.prototype.construtor=BlockCipher_1.BlockCipher,exports.Aes.prototype.BLOCK_SIZE=16,exports.Aes.BLOCK_SIZE_IN_WORDS_=exports.Aes.prototype.BLOCK_SIZE/4,exports.Aes.ENABLE_TEST_MODE=!1,exports.Aes.prototype.encrypt=function(t){exports.Aes.ENABLE_TEST_MODE&&this.testKeySchedule_(0,this.keySchedule_,0),this.copyInput_(t),this.addRoundKey_(0);for(var e=1;e<this.numberOfRounds_;++e)exports.Aes.ENABLE_TEST_MODE&&(this.testKeySchedule_(e,this.keySchedule_,e),this.testStartRound_(e,this.state_)),this.subBytes_(exports.Aes.SBOX_),exports.Aes.ENABLE_TEST_MODE&&this.testAfterSubBytes_(e,this.state_),this.shiftRows_(),exports.Aes.ENABLE_TEST_MODE&&this.testAfterShiftRows_(e,this.state_),this.mixColumns_(),exports.Aes.ENABLE_TEST_MODE&&this.testAfterMixColumns_(e,this.state_),this.addRoundKey_(e);return this.subBytes_(exports.Aes.SBOX_),exports.Aes.ENABLE_TEST_MODE&&this.testAfterSubBytes_(e,this.state_),this.shiftRows_(),exports.Aes.ENABLE_TEST_MODE&&this.testAfterShiftRows_(e,this.state_),this.addRoundKey_(this.numberOfRounds_),this.generateOutput_()},exports.Aes.prototype.decrypt=function(t){exports.Aes.ENABLE_TEST_MODE&&this.testKeySchedule_(0,this.keySchedule_,this.numberOfRounds_),this.copyInput_(t),this.addRoundKey_(this.numberOfRounds_);for(var e=1;e<this.numberOfRounds_;++e)exports.Aes.ENABLE_TEST_MODE&&(this.testKeySchedule_(e,this.keySchedule_,this.numberOfRounds_-e),this.testStartRound_(e,this.state_)),this.invShiftRows_(),exports.Aes.ENABLE_TEST_MODE&&this.testAfterShiftRows_(e,this.state_),this.subBytes_(exports.Aes.INV_SBOX_),exports.Aes.ENABLE_TEST_MODE&&this.testAfterSubBytes_(e,this.state_),this.addRoundKey_(this.numberOfRounds_-e),exports.Aes.ENABLE_TEST_MODE&&this.testAfterAddRoundKey_(e,this.state_),this.invMixColumns_();return this.invShiftRows_(),exports.Aes.ENABLE_TEST_MODE&&this.testAfterShiftRows_(e,this.state_),this.subBytes_(exports.Aes.INV_SBOX_),exports.Aes.ENABLE_TEST_MODE&&this.testAfterSubBytes_(this.numberOfRounds_,this.state_),exports.Aes.ENABLE_TEST_MODE&&this.testKeySchedule_(this.numberOfRounds_,this.keySchedule_,0),this.addRoundKey_(0),this.generateOutput_()},exports.Aes.assertKeyArray_=function(t){if(16!=t.length&&24!=t.length&&32!=t.length)throw"Key must have length 16, 24, or 32.";for(var e=0;e<t.length;e++){if("number"!=typeof t[e])throw"arr[i] must be number";if(!(t[e]>=0&&t[e]<=255))throw"arr[i] must be [0, 255]"}},exports.Aes.prototype.testStartRound_=util_1.noop,exports.Aes.prototype.testAfterSubBytes_=util_1.noop,exports.Aes.prototype.testAfterShiftRows_=util_1.noop,exports.Aes.prototype.testAfterMixColumns_=util_1.noop,exports.Aes.prototype.testAfterAddRoundKey_=util_1.noop,exports.Aes.prototype.testKeySchedule_=util_1.noop,exports.Aes.prototype.copyInput_=function(t){var e,s;if(t.length!==this.BLOCK_SIZE)throw"Expecting input of block size.";for(var _=0;_<exports.Aes.BLOCK_SIZE_IN_WORDS_;_++)for(var o=0;o<4;o++){if(!((e=t[s=4*o+_])<=255&&e>=0))throw"Invalid input. Value "+e+" at position "+s+" is not a byte.";this.state_[_][o]=e}},exports.Aes.prototype.generateOutput_=function(){for(var t=[],e=0;e<exports.Aes.BLOCK_SIZE_IN_WORDS_;e++)for(var s=0;s<4;s++)t[4*s+e]=this.state_[e][s];return t},exports.Aes.prototype.addRoundKey_=function(t){for(var e=0;e<4;e++)for(var s=0;s<4;s++)this.state_[e][s]^=this.keySchedule_[4*t+s][e]},exports.Aes.prototype.subBytes_=function(t){for(var e=0;e<4;e++)for(var s=0;s<4;s++)this.state_[e][s]=t[this.state_[e][s]]},exports.Aes.prototype.shiftRows_=function(){for(var t=1;t<4;t++)for(var e=0;e<4;e++)this.temp_[t][e]=this.state_[t][e];for(t=1;t<4;t++)for(e=0;e<4;e++)this.state_[t][e]=this.temp_[t][(e+t)%exports.Aes.BLOCK_SIZE_IN_WORDS_]},exports.Aes.prototype.invShiftRows_=function(){for(var t=1;t<4;t++)for(var e=0;e<4;e++)this.temp_[t][(e+t)%exports.Aes.BLOCK_SIZE_IN_WORDS_]=this.state_[t][e];for(t=1;t<4;t++)for(e=0;e<4;e++)this.state_[t][e]=this.temp_[t][e]},exports.Aes.prototype.mixColumns_=function(){for(var t=this.state_,e=this.temp_[0],s=0;s<4;s++)e[0]=t[0][s],e[1]=t[1][s],e[2]=t[2][s],e[3]=t[3][s],t[0][s]=exports.Aes.MULT_2_[e[0]]^exports.Aes.MULT_3_[e[1]]^e[2]^e[3],t[1][s]=e[0]^exports.Aes.MULT_2_[e[1]]^exports.Aes.MULT_3_[e[2]]^e[3],t[2][s]=e[0]^e[1]^exports.Aes.MULT_2_[e[2]]^exports.Aes.MULT_3_[e[3]],t[3][s]=exports.Aes.MULT_3_[e[0]]^e[1]^e[2]^exports.Aes.MULT_2_[e[3]]},exports.Aes.prototype.invMixColumns_=function(){for(var t=this.state_,e=this.temp_[0],s=0;s<4;s++)e[0]=t[0][s],e[1]=t[1][s],e[2]=t[2][s],e[3]=t[3][s],t[0][s]=exports.Aes.MULT_E_[e[0]]^exports.Aes.MULT_B_[e[1]]^exports.Aes.MULT_D_[e[2]]^exports.Aes.MULT_9_[e[3]],t[1][s]=exports.Aes.MULT_9_[e[0]]^exports.Aes.MULT_E_[e[1]]^exports.Aes.MULT_B_[e[2]]^exports.Aes.MULT_D_[e[3]],t[2][s]=exports.Aes.MULT_D_[e[0]]^exports.Aes.MULT_9_[e[1]]^exports.Aes.MULT_E_[e[2]]^exports.Aes.MULT_B_[e[3]],t[3][s]=exports.Aes.MULT_B_[e[0]]^exports.Aes.MULT_D_[e[1]]^exports.Aes.MULT_9_[e[2]]^exports.Aes.MULT_E_[e[3]]},exports.Aes.prototype.keyExpansion_=function(){this.keySchedule_=new Array(exports.Aes.BLOCK_SIZE_IN_WORDS_*(this.numberOfRounds_+1));for(var t=0;t<this.keyLengthInWords_;t++)this.keySchedule_[t]=[this.key_[4*t],this.key_[4*t+1],this.key_[4*t+2],this.key_[4*t+3]];var e=new Array(4);for(t=this.keyLengthInWords_;t<exports.Aes.BLOCK_SIZE_IN_WORDS_*(this.numberOfRounds_+1);t++)e[0]=this.keySchedule_[t-1][0],e[1]=this.keySchedule_[t-1][1],e[2]=this.keySchedule_[t-1][2],e[3]=this.keySchedule_[t-1][3],t%this.keyLengthInWords_==0?(this.rotWord_(e),this.subWord_(e),e[0]^=exports.Aes.RCON_[t/this.keyLengthInWords_][0],e[1]^=exports.Aes.RCON_[t/this.keyLengthInWords_][1],e[2]^=exports.Aes.RCON_[t/this.keyLengthInWords_][2],e[3]^=exports.Aes.RCON_[t/this.keyLengthInWords_][3]):this.keyLengthInWords_>6&&t%this.keyLengthInWords_==4&&this.subWord_(e),this.keySchedule_[t]=new Array(4),this.keySchedule_[t][0]=this.keySchedule_[t-this.keyLengthInWords_][0]^e[0],this.keySchedule_[t][1]=this.keySchedule_[t-this.keyLengthInWords_][1]^e[1],this.keySchedule_[t][2]=this.keySchedule_[t-this.keyLengthInWords_][2]^e[2],this.keySchedule_[t][3]=this.keySchedule_[t-this.keyLengthInWords_][3]^e[3]},exports.Aes.prototype.subWord_=function(t){return t[0]=exports.Aes.SBOX_[t[0]],t[1]=exports.Aes.SBOX_[t[1]],t[2]=exports.Aes.SBOX_[t[2]],t[3]=exports.Aes.SBOX_[t[3]],t},exports.Aes.prototype.rotWord_=function(t){var e=t[0];return t[0]=t[1],t[1]=t[2],t[2]=t[3],t[3]=e,t},exports.Aes.SBOX_=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],exports.Aes.INV_SBOX_=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],exports.Aes.RCON_=[[0,0,0,0],[1,0,0,0],[2,0,0,0],[4,0,0,0],[8,0,0,0],[16,0,0,0],[32,0,0,0],[64,0,0,0],[128,0,0,0],[27,0,0,0],[54,0,0,0]],exports.Aes.MULT_2_=[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,27,25,31,29,19,17,23,21,11,9,15,13,3,1,7,5,59,57,63,61,51,49,55,53,43,41,47,45,35,33,39,37,91,89,95,93,83,81,87,85,75,73,79,77,67,65,71,69,123,121,127,125,115,113,119,117,107,105,111,109,99,97,103,101,155,153,159,157,147,145,151,149,139,137,143,141,131,129,135,133,187,185,191,189,179,177,183,181,171,169,175,173,163,161,167,165,219,217,223,221,211,209,215,213,203,201,207,205,195,193,199,197,251,249,255,253,243,241,247,245,235,233,239,237,227,225,231,229],exports.Aes.MULT_3_=[0,3,6,5,12,15,10,9,24,27,30,29,20,23,18,17,48,51,54,53,60,63,58,57,40,43,46,45,36,39,34,33,96,99,102,101,108,111,106,105,120,123,126,125,116,119,114,113,80,83,86,85,92,95,90,89,72,75,78,77,68,71,66,65,192,195,198,197,204,207,202,201,216,219,222,221,212,215,210,209,240,243,246,245,252,255,250,249,232,235,238,237,228,231,226,225,160,163,166,165,172,175,170,169,184,187,190,189,180,183,178,177,144,147,150,149,156,159,154,153,136,139,142,141,132,135,130,129,155,152,157,158,151,148,145,146,131,128,133,134,143,140,137,138,171,168,173,174,167,164,161,162,179,176,181,182,191,188,185,186,251,248,253,254,247,244,241,242,227,224,229,230,239,236,233,234,203,200,205,206,199,196,193,194,211,208,213,214,223,220,217,218,91,88,93,94,87,84,81,82,67,64,69,70,79,76,73,74,107,104,109,110,103,100,97,98,115,112,117,118,127,124,121,122,59,56,61,62,55,52,49,50,35,32,37,38,47,44,41,42,11,8,13,14,7,4,1,2,19,16,21,22,31,28,25,26],exports.Aes.MULT_9_=[0,9,18,27,36,45,54,63,72,65,90,83,108,101,126,119,144,153,130,139,180,189,166,175,216,209,202,195,252,245,238,231,59,50,41,32,31,22,13,4,115,122,97,104,87,94,69,76,171,162,185,176,143,134,157,148,227,234,241,248,199,206,213,220,118,127,100,109,82,91,64,73,62,55,44,37,26,19,8,1,230,239,244,253,194,203,208,217,174,167,188,181,138,131,152,145,77,68,95,86,105,96,123,114,5,12,23,30,33,40,51,58,221,212,207,198,249,240,235,226,149,156,135,142,177,184,163,170,236,229,254,247,200,193,218,211,164,173,182,191,128,137,146,155,124,117,110,103,88,81,74,67,52,61,38,47,16,25,2,11,215,222,197,204,243,250,225,232,159,150,141,132,187,178,169,160,71,78,85,92,99,106,113,120,15,6,29,20,43,34,57,48,154,147,136,129,190,183,172,165,210,219,192,201,246,255,228,237,10,3,24,17,46,39,60,53,66,75,80,89,102,111,116,125,161,168,179,186,133,140,151,158,233,224,251,242,205,196,223,214,49,56,35,42,21,28,7,14,121,112,107,98,93,84,79,70],exports.Aes.MULT_B_=[0,11,22,29,44,39,58,49,88,83,78,69,116,127,98,105,176,187,166,173,156,151,138,129,232,227,254,245,196,207,210,217,123,112,109,102,87,92,65,74,35,40,53,62,15,4,25,18,203,192,221,214,231,236,241,250,147,152,133,142,191,180,169,162,246,253,224,235,218,209,204,199,174,165,184,179,130,137,148,159,70,77,80,91,106,97,124,119,30,21,8,3,50,57,36,47,141,134,155,144,161,170,183,188,213,222,195,200,249,242,239,228,61,54,43,32,17,26,7,12,101,110,115,120,73,66,95,84,247,252,225,234,219,208,205,198,175,164,185,178,131,136,149,158,71,76,81,90,107,96,125,118,31,20,9,2,51,56,37,46,140,135,154,145,160,171,182,189,212,223,194,201,248,243,238,229,60,55,42,33,16,27,6,13,100,111,114,121,72,67,94,85,1,10,23,28,45,38,59,48,89,82,79,68,117,126,99,104,177,186,167,172,157,150,139,128,233,226,255,244,197,206,211,216,122,113,108,103,86,93,64,75,34,41,52,63,14,5,24,19,202,193,220,215,230,237,240,251,146,153,132,143,190,181,168,163],exports.Aes.MULT_D_=[0,13,26,23,52,57,46,35,104,101,114,127,92,81,70,75,208,221,202,199,228,233,254,243,184,181,162,175,140,129,150,155,187,182,161,172,143,130,149,152,211,222,201,196,231,234,253,240,107,102,113,124,95,82,69,72,3,14,25,20,55,58,45,32,109,96,119,122,89,84,67,78,5,8,31,18,49,60,43,38,189,176,167,170,137,132,147,158,213,216,207,194,225,236,251,246,214,219,204,193,226,239,248,245,190,179,164,169,138,135,144,157,6,11,28,17,50,63,40,37,110,99,116,121,90,87,64,77,218,215,192,205,238,227,244,249,178,191,168,165,134,139,156,145,10,7,16,29,62,51,36,41,98,111,120,117,86,91,76,65,97,108,123,118,85,88,79,66,9,4,19,30,61,48,39,42,177,188,171,166,133,136,159,146,217,212,195,206,237,224,247,250,183,186,173,160,131,142,153,148,223,210,197,200,235,230,241,252,103,106,125,112,83,94,73,68,15,2,21,24,59,54,33,44,12,1,22,27,56,53,34,47,100,105,126,115,80,93,74,71,220,209,198,203,232,229,242,255,180,185,174,163,128,141,154,151],exports.Aes.MULT_E_=[0,14,28,18,56,54,36,42,112,126,108,98,72,70,84,90,224,238,252,242,216,214,196,202,144,158,140,130,168,166,180,186,219,213,199,201,227,237,255,241,171,165,183,185,147,157,143,129,59,53,39,41,3,13,31,17,75,69,87,89,115,125,111,97,173,163,177,191,149,155,137,135,221,211,193,207,229,235,249,247,77,67,81,95,117,123,105,103,61,51,33,47,5,11,25,23,118,120,106,100,78,64,82,92,6,8,26,20,62,48,34,44,150,152,138,132,174,160,178,188,230,232,250,244,222,208,194,204,65,79,93,83,121,119,101,107,49,63,45,35,9,7,21,27,161,175,189,179,153,151,133,139,209,223,205,195,233,231,245,251,154,148,134,136,162,172,190,176,234,228,246,248,210,220,206,192,122,116,102,104,66,76,94,80,10,4,22,24,50,60,46,32,236,226,240,254,212,218,200,198,156,146,128,142,164,170,184,182,12,2,16,30,52,58,40,38,124,114,96,110,68,74,88,86,55,57,43,37,15,1,19,29,71,73,91,85,127,113,99,109,215,217,203,197,239,225,243,253,167,169,187,181,159,145,131,141]; | ||
//# sourceMappingURL=AesCrypto.js.map |
@@ -9,3 +9,3 @@ import { AppDevSdk } from 'qcloud-iotexplorer-appdev-sdk'; | ||
queueExcuteState: {}; | ||
errorHandler: Function; | ||
errorHandler: any; | ||
constructor(port: any); | ||
@@ -12,0 +12,0 @@ checkIsSupport(): boolean; |
@@ -9,3 +9,3 @@ import { AppDevSdk } from 'qcloud-iotexplorer-appdev-sdk'; | ||
isClose: any; | ||
msgHandler: (res: any) => void; | ||
msgHandler: any; | ||
constructor(socket: any, socketTimeout: number, correctLen?: number); | ||
@@ -12,0 +12,0 @@ startServer(): void; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UDPSocketServer=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),UDPSocketServer=function(e){function t(t,o,i){var r=e.call(this)||this;return r.TAG="UDPSocketServer",r.msgHandler=function(e){},r.mSocket=t,r.isClose=!1,r.mSocket.onClose((function(){r.interrupt()})),r.mTimeout=o,i&&(r.mCorrectLen=i),r}return tslib_1.__extends(t,e),t.prototype.startServer=function(){this.handlerTimeout(this.mTimeout),this.onListening(),this.onMessage(this.mCorrectLen)},t.prototype.handlerTimeout=function(e){var t=this;this.mSocketTimeoutTimer=setTimeout((function(){t.emit("timeout"),t.interrupt()}),e)},t.prototype.onMessage=function(e){var t=this;this.msgHandler=function(o){t.isClose||(console.log(t.TAG,"recieveMsg",o),t.emit("recieveMsg",o),!e||e&&o.remoteInfo.size===e?t.emit("recieveCorrectMsg",o):console.log(t.TAG,"received len is different from specific len"))},this.mSocket.onMessage(this.msgHandler)},t.prototype.onListening=function(){var e=this;this.mSocket.onListening((function(t){e.isClose||(e.emit("recieveMsg",t),console.log(e.TAG,"onListening",t))}))},t.prototype.interrupt=function(){console.log(this.TAG,"USPSocketServer is interrupt"),this.mSocket.offMessage(this.msgHandler),this.close()},t.prototype.close=function(){this.isClose=!0},t}(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.EventEmitter);exports.UDPSocketServer=UDPSocketServer; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UDPSocketServer=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),util_1=require("../util"),UDPSocketServer=function(e){function t(t,o,i){var r=e.call(this)||this;return r.TAG="UDPSocketServer",r.msgHandler=util_1.noop,r.mSocket=t,r.isClose=!1,r.mSocket.onClose((function(){r.interrupt()})),r.mTimeout=o,i&&(r.mCorrectLen=i),r}return tslib_1.__extends(t,e),t.prototype.startServer=function(){this.handlerTimeout(this.mTimeout),this.onListening(),this.onMessage(this.mCorrectLen)},t.prototype.handlerTimeout=function(e){var t=this;this.mSocketTimeoutTimer=setTimeout((function(){t.emit("timeout"),t.interrupt()}),e)},t.prototype.onMessage=function(e){var t=this;this.msgHandler=function(o){t.isClose||(console.log(t.TAG,"recieveMsg",o),t.emit("recieveMsg",o),!e||e&&o.remoteInfo.size===e?t.emit("recieveCorrectMsg",o):console.log(t.TAG,"received len is different from specific len"))},this.mSocket.onMessage(this.msgHandler)},t.prototype.onListening=function(){var e=this;this.mSocket.onListening((function(t){e.isClose||(e.emit("recieveMsg",t),console.log(e.TAG,"onListening",t))}))},t.prototype.interrupt=function(){console.log(this.TAG,"USPSocketServer is interrupt"),this.mSocket.offMessage(this.msgHandler),this.close()},t.prototype.close=function(){this.isClose=!0},t}(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.EventEmitter);exports.UDPSocketServer=UDPSocketServer; | ||
//# sourceMappingURL=UDPSocketServer.js.map |
@@ -38,5 +38,5 @@ export function compareVersion(_v1: any, _v2: any): 0 | 1 | -1; | ||
export function arrayFill(array: any, value: any): void; | ||
export function nullFunction(): void; | ||
export const noop: () => void; | ||
export function checkIsAndroid(): boolean; | ||
export function checkIsIOS(): boolean; | ||
export function getWxVersion(): string; |
@@ -1,2 +0,2 @@ | ||
"use strict";function compareVersion(r,t){for(var e=r.split("."),n=t.split("."),o=Math.max(e.length,n.length);e.length<o;)e.push("0");for(;n.length<o;)n.push("0");for(var i=0;i<o;i++){var p=parseInt(e[i]),s=parseInt(n[i]);if(p>s)return 1;if(p<s)return-1}return 0}function parseInetAddr(r,t,e){for(var n="",o=0;o<e;o++)n+=String(255&r[t+o]),o!==e-1&&(n+=".");return n}function formatInetAddr(r){void 0===r&&(r="");for(var t=r.split("."),e=new Int8Array(t.length),n=0;n<t.length;n++){var o=parseInt(t[n]);e[n]=o>127?o-256:o}return e}function ip2int(r){var t=formatInetAddr(r);return 16777216*(255&t[0])+65536*(255&t[1])+256*(255&t[2])+(255&t[3])}function int2ip(r){return(r>>24&255)+"."+(r>>16&255)+"."+(r>>8&255)+"."+(255&r)}function intIp2byte(r){var t=[0,0,0,0];return t[0]=r>>24&255|0,t[1]=r>>16&255|0,t[2]=r>>8&255|0,t[3]=255&r|0,t}function arrayFill(r,t){for(var e=0;e<r.length;e++)r[e]=t}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getWxVersion=exports.checkIsIOS=exports.checkIsAndroid=exports.nullFunction=exports.arrayFill=exports.intIp2byte=exports.int2ip=exports.ip2int=exports.formatInetAddr=exports.parseInetAddr=exports.compareVersion=void 0,exports.compareVersion=compareVersion,exports.parseInetAddr=parseInetAddr,exports.formatInetAddr=formatInetAddr,exports.ip2int=ip2int,exports.int2ip=int2ip,exports.intIp2byte=intIp2byte,exports.arrayFill=arrayFill,exports.nullFunction=function(){},exports.checkIsAndroid=function(){return wx.getSystemInfoSync().platform.indexOf("android")>-1},exports.checkIsIOS=function(){return wx.getSystemInfoSync().platform.indexOf("ios")>-1},exports.getWxVersion=function(){return wx.getSystemInfoSync().version}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getWxVersion=exports.checkIsIOS=exports.checkIsAndroid=exports.arrayFill=exports.intIp2byte=exports.int2ip=exports.ip2int=exports.formatInetAddr=exports.parseInetAddr=exports.compareVersion=exports.noop=void 0;var src_1=require("qcloud-iotexplorer-appdev-sdk/src");function compareVersion(r,t){for(var e=r.split("."),n=t.split("."),o=Math.max(e.length,n.length);e.length<o;)e.push("0");for(;n.length<o;)n.push("0");for(var p=0;p<o;p++){var i=parseInt(e[p]),s=parseInt(n[p]);if(i>s)return 1;if(i<s)return-1}return 0}function parseInetAddr(r,t,e){for(var n="",o=0;o<e;o++)n+=String(255&r[t+o]),o!==e-1&&(n+=".");return n}function formatInetAddr(r){void 0===r&&(r="");for(var t=r.split("."),e=new Int8Array(t.length),n=0;n<t.length;n++){var o=parseInt(t[n]);e[n]=o>127?o-256:o}return e}function ip2int(r){var t=formatInetAddr(r);return 16777216*(255&t[0])+65536*(255&t[1])+256*(255&t[2])+(255&t[3])}function int2ip(r){return(r>>24&255)+"."+(r>>16&255)+"."+(r>>8&255)+"."+(255&r)}function intIp2byte(r){var t=[0,0,0,0];return t[0]=r>>24&255|0,t[1]=r>>16&255|0,t[2]=r>>8&255|0,t[3]=255&r|0,t}function arrayFill(r,t){for(var e=0;e<r.length;e++)r[e]=t}exports.noop=src_1.AppDevSdk.utils.noop,exports.compareVersion=compareVersion,exports.parseInetAddr=parseInetAddr,exports.formatInetAddr=formatInetAddr,exports.ip2int=ip2int,exports.int2ip=int2ip,exports.intIp2byte=intIp2byte,exports.arrayFill=arrayFill,exports.checkIsAndroid=function(){return wx.getSystemInfoSync().platform.indexOf("android")>-1},exports.checkIsIOS=function(){return wx.getSystemInfoSync().platform.indexOf("ios")>-1},exports.getWxVersion=function(){return wx.getSystemInfoSync().version}; | ||
//# sourceMappingURL=util.js.map |
@@ -20,3 +20,3 @@ import { AppDevSdk } from 'qcloud-iotexplorer-appdev-sdk'; | ||
udpServer: any; | ||
}) => Promise<{}>; | ||
}) => Promise<any>; | ||
onProgress?: (event: Response) => any; | ||
@@ -23,0 +23,0 @@ onError?: (error: Response) => any; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WifiConfProtocolBase=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),queryTokenStateAndBind_1=require("./queryTokenStateAndBind"),constants_1=require("../constants"),utils_1=require("../utils"),issueHandler_1=require("./issueHandler"),WifiConfProtocolBase=function(e){function o(o,t){var s=e.call(this)||this;return s.connectAborted=!1,s.options={udpPort:8266,stepInterval:1e3,familyId:"default",autoRetry:!1,autoBind:!0},s.sdk=o,Object.assign(s.options,t),s}return tslib_1.__extends(o,e),o.prototype.onProgress=function(e){"function"==typeof this.options.onProgress&&this.options.onProgress(e)},o.prototype.onComplete=function(e){"function"==typeof this.options.onComplete&&this.options.onComplete(e)},o.prototype.onError=function(e){"function"==typeof this.options.onError&&this.options.onError(e)},o.prototype.start=function(e){var o=(void 0===e?{}:e).doNotRetry,t=void 0!==o&&o;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,o,s,n,r,i,d,a,c,p,_=this;return tslib_1.__generator(this,(function(u){switch(u.label){case 0:this.onProgress({code:constants_1.WifiConfStepCode.WIFI_CONF_START}),e=this.options.targetWifiInfo,o=e.SSID,s=e.BSSID,n=e.password,this.onProgress({code:constants_1.WifiConfStepCode.PROTOCOL_START,detail:{SSID:o,password:n}}),u.label=1;case 1:u.trys.push([1,7,,10]),r=Date.now(),i=void 0,u.label=2;case 2:return u.trys.push([2,4,,5]),[4,this.doProtocol({SSID:o,BSSID:s,password:n})];case 3:return d=u.sent(),i=d?d.address:null,[3,5];case 4:throw a=u.sent(),console.error(a),tslib_1.__assign({code:"PROTOCOL_FAIL"},a);case 5:if(!i)throw{code:"PROTOCOL_INVALID_RESPONSE"};return this.onProgress({code:constants_1.WifiConfStepCode.PROTOCOL_SUCCESS,detail:{data:{address:i},timeCost:Date.now()-r}}),[4,this.doBusiness({address:i})];case 6:return c=u.sent(),this.onProgress({code:constants_1.WifiConfStepCode.WIFI_CONF_SUCCESS,detail:tslib_1.__assign({timeCost:Date.now()-r},c)}),this.onComplete(c),[3,10];case 7:return p=u.sent(),console.error(p),p&&p.code in constants_1.WifiConfErrorMsg&&(p.uiMsg=constants_1.WifiConfErrorMsg[p.code]),t||!this.options.autoRetry?[3,9]:[4,issueHandler_1.issueHandler({error:p,targetWifiInfo:this.options.targetWifiInfo,wifiConfType:this.options.wifiConfType,onProgress:function(e){_.onProgress.call(_,e)}})];case 8:if(u.sent())return this.onProgress({code:constants_1.WifiConfStepCode.WIFI_CONF_AUTO_RETRY}),[2,this.start({doNotRetry:!0})];u.label=9;case 9:return this.connectAborted=!0,this.onProgress({code:constants_1.WifiConfStepCode.WIFI_CONF_FAIL,detail:{error:p}}),this.onError({code:"WIFI_CONF_FAIL",detail:{error:p}}),[3,10];case 10:return[2]}}))}))},o.prototype.doProtocol=function(e){throw new Error("子类必须自行实现自己协议传输逻辑")},o.prototype.doBusiness=function(e){var o=e.address;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,t,s,n,r,i,d=this;return tslib_1.__generator(this,(function(a){switch(a.label){case 0:return this.onProgress({code:constants_1.WifiConfStepCode.BUSINESS_START}),this.onProgress({code:constants_1.WifiConfStepCode.CREATE_UDP_CONNECTION_START}),e=Date.now(),t=new utils_1.UdpServer({address:o,port:this.options.udpPort,sdk:this.sdk}),s=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.genPromise(),n=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.genPromise(),t.onError((function(e){return s.reject({code:"UDP_ERROR",errMsg:e})})),t.onProgressError((function(e){return n.reject({code:"BUSINESS_DEVICE_ERROR",message:e})})),r=function(){return tslib_1.__awaiter(d,void 0,void 0,(function(){var o,s,n,r,i,d,a,c=this;return tslib_1.__generator(this,(function(p){switch(p.label){case 0:return[4,(o=function(e){return tslib_1.__awaiter(c,void 0,void 0,(function(){return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return[4,qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.delay(e||this.options.stepInterval)];case 1:return o.sent(),this.connectAborted&&qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.logger.debug("connection aborted"),[2]}}))}))})()];case 1:return p.sent(),s="2.0",n={},console.log("getDeviceExtendInfo",this.options.getDeviceExtendInfo),"function"!=typeof this.options.getDeviceExtendInfo?[3,3]:[4,this.options.getDeviceExtendInfo({udpServer:t})];case 2:n=p.sent(),p.label=3;case 3:return[4,t.send(tslib_1.__assign({cmdType:0,token:this.options.wifiConfToken},n),{validateResponse:function(e){return console.log("cmdType",e.cmdType),2==+e.cmdType}})];case 4:return r=p.sent(),this.onProgress({code:constants_1.WifiConfStepCode.CREATE_UDP_CONNECTION_SUCCESS,detail:{data:r,timeCost:Date.now()-e,protoVersion:s}}),[4,o()];case 5:return p.sent(),i=r.productId,d=r.deviceName,a=this,[4,queryTokenStateAndBind_1.queryTokenStateAndBind({token:this.options.wifiConfToken,productId:i,deviceName:d,familyId:this.options.familyId,roomId:this.options.roomId,onProgress:function(e){a.onProgress.call(a,e)},sdk:this.sdk})];case 6:return p.sent(),t.destroy(),[2,{productId:i,deviceName:d}]}}))}))},[4,Promise.race([r(),s.promise,n.promise])];case 1:return i=a.sent(),this.onProgress({code:constants_1.WifiConfStepCode.BUSINESS_SUCCESS,detail:{response:i}}),[2,i]}}))}))},o}(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.EventEmitter);exports.WifiConfProtocolBase=WifiConfProtocolBase; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WifiConfProtocolBase=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),queryTokenStateAndBind_1=require("./queryTokenStateAndBind"),constants_1=require("../constants"),utils_1=require("../utils"),issueHandler_1=require("./issueHandler"),WifiConfProtocolBase=function(e){function o(o,t){var s=e.call(this)||this;return s.connectAborted=!1,s.options={udpPort:8266,stepInterval:1e3,familyId:"default",autoRetry:!1,autoBind:!0},s.sdk=o,Object.assign(s.options,t),s}return tslib_1.__extends(o,e),o.prototype.onProgress=function(e){"function"==typeof this.options.onProgress&&this.options.onProgress(e)},o.prototype.onComplete=function(e){"function"==typeof this.options.onComplete&&this.options.onComplete(e)},o.prototype.onError=function(e){"function"==typeof this.options.onError&&this.options.onError(e)},o.prototype.start=function(e){var o=(void 0===e?{}:e).doNotRetry,t=void 0!==o&&o;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,o,s,n,r,i,d,a,c,p,_=this;return tslib_1.__generator(this,(function(u){switch(u.label){case 0:this.onProgress({code:constants_1.WifiConfStepCode.WIFI_CONF_START}),e=this.options.targetWifiInfo,o=e.SSID,s=e.BSSID,n=e.password,this.onProgress({code:constants_1.WifiConfStepCode.PROTOCOL_START,detail:{SSID:o,password:n}}),u.label=1;case 1:u.trys.push([1,7,,10]),r=Date.now(),i=void 0,u.label=2;case 2:return u.trys.push([2,4,,5]),[4,this.doProtocol({SSID:o,BSSID:s,password:n})];case 3:return d=u.sent(),i=d?d.address:null,[3,5];case 4:throw a=u.sent(),console.error(a),tslib_1.__assign({code:"PROTOCOL_FAIL"},a);case 5:if(!i)throw{code:"PROTOCOL_INVALID_RESPONSE"};return this.onProgress({code:constants_1.WifiConfStepCode.PROTOCOL_SUCCESS,detail:{data:{address:i},timeCost:Date.now()-r}}),[4,this.doBusiness({address:i})];case 6:return c=u.sent(),this.onProgress({code:constants_1.WifiConfStepCode.WIFI_CONF_SUCCESS,detail:tslib_1.__assign({timeCost:Date.now()-r},c)}),this.onComplete(c),[3,10];case 7:return p=u.sent(),console.error(p),p&&p.code in constants_1.WifiConfErrorMsg&&(p.uiMsg=constants_1.WifiConfErrorMsg[p.code]),t||!this.options.autoRetry?[3,9]:[4,issueHandler_1.issueHandler({error:p,targetWifiInfo:this.options.targetWifiInfo,wifiConfType:this.options.wifiConfType,onProgress:function(e){_.onProgress.call(_,e)}})];case 8:if(u.sent())return this.onProgress({code:constants_1.WifiConfStepCode.WIFI_CONF_AUTO_RETRY}),[2,this.start({doNotRetry:!0})];u.label=9;case 9:return this.connectAborted=!0,this.onProgress({code:constants_1.WifiConfStepCode.WIFI_CONF_FAIL,detail:{error:p}}),this.onError({code:"WIFI_CONF_FAIL",detail:{error:p}}),[3,10];case 10:return[2]}}))}))},o.prototype.doProtocol=function(e){throw new Error("子类必须自行实现自己协议传输逻辑")},o.prototype.doBusiness=function(e){var o=e.address;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,t,s,n,r,i,d=this;return tslib_1.__generator(this,(function(a){switch(a.label){case 0:return this.onProgress({code:constants_1.WifiConfStepCode.BUSINESS_START}),this.onProgress({code:constants_1.WifiConfStepCode.CREATE_UDP_CONNECTION_START}),e=Date.now(),t=new utils_1.UdpServer({address:o,port:this.options.udpPort,sdk:this.sdk}),s=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.genPromise(),n=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.genPromise(),t.onError((function(e){return s.reject({code:"UDP_ERROR",errMsg:e})})),t.onProgressError((function(e){return n.reject({code:"BUSINESS_DEVICE_ERROR",message:e})})),r=function(){return tslib_1.__awaiter(d,void 0,void 0,(function(){var o,s,n,r,i,d,a=this;return tslib_1.__generator(this,(function(c){switch(c.label){case 0:return[4,(o=function(e){return tslib_1.__awaiter(a,void 0,void 0,(function(){return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return[4,qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.delay(e||this.options.stepInterval)];case 1:return o.sent(),this.connectAborted&&qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.logger.debug("connection aborted"),[2]}}))}))})()];case 1:return c.sent(),s="2.0",n={},console.log("getDeviceExtendInfo",this.options.getDeviceExtendInfo),"function"!=typeof this.options.getDeviceExtendInfo?[3,3]:[4,this.options.getDeviceExtendInfo({udpServer:t})];case 2:n=c.sent(),c.label=3;case 3:return[4,t.send(tslib_1.__assign({cmdType:0,token:this.options.wifiConfToken},n),{validateResponse:function(e){return console.log("cmdType",e.cmdType),2==+e.cmdType}})];case 4:return r=c.sent(),this.onProgress({code:constants_1.WifiConfStepCode.CREATE_UDP_CONNECTION_SUCCESS,detail:{data:r,timeCost:Date.now()-e,protoVersion:s}}),[4,o()];case 5:return c.sent(),i=r.productId,d=r.deviceName,[4,queryTokenStateAndBind_1.queryTokenStateAndBind({token:this.options.wifiConfToken,productId:i,deviceName:d,familyId:this.options.familyId,roomId:this.options.roomId,onProgress:function(e){a.onProgress.call(a,e)},sdk:this.sdk})];case 6:return c.sent(),t.destroy(),[2,{productId:i,deviceName:d}]}}))}))},[4,Promise.race([r(),s.promise,n.promise])];case 1:return i=a.sent(),this.onProgress({code:constants_1.WifiConfStepCode.BUSINESS_SUCCESS,detail:{response:i}}),[2,i]}}))}))},o}(qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.EventEmitter);exports.WifiConfProtocolBase=WifiConfProtocolBase; | ||
//# sourceMappingURL=WifiConfProtocolBase.js.map |
{ | ||
"name": "qcloud-iotexplorer-appdev-plugin-wificonf-core", | ||
"version": "1.0.29", | ||
"description": "", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"build:lib": "rm -rf lib && npx tsc -p tsconfig.json -t es5 --outDir lib && node bin/minify.js -t lib", | ||
"build": "npm run build:lib" | ||
}, | ||
"author": "xiaoyuze88@gmail.com", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/tencentyun/qcloud-iotexplorer-appdev-sdk/issues" | ||
}, | ||
"dependencies": { | ||
"qcloud-iotexplorer-appdev-sdk": "^1.0.38" | ||
}, | ||
"devDependencies": { | ||
"commander": "^6.0.0", | ||
"miniprogram-api-typings": "^2.10.0-1", | ||
"query-string": "^6.9.0", | ||
"terser": "^5.0.0", | ||
"tslib": "^2.0.1", | ||
"typescript": "^3.9.7" | ||
} | ||
"name": "qcloud-iotexplorer-appdev-plugin-wificonf-core", | ||
"version": "1.1.0-alpha.0", | ||
"description": "", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"build:lib": "rm -rf lib && npx tsc -p tsconfig.json -t es5 --outDir lib && node ../../bin/minify.js -p appdev-plugin-wificonf-core -t lib", | ||
"build": "npm run build:lib" | ||
}, | ||
"author": "xiaoyuze88@gmail.com", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/tencentyun/qcloud-iotexplorer-appdev-sdk/issues" | ||
}, | ||
"dependencies": { | ||
"qcloud-iotexplorer-appdev-sdk": "^1.1.0-alpha.0", | ||
"tslib": "^2.0.1" | ||
}, | ||
"gitHead": "dcb52a29c53f506732f2b835adc941bd6a4fa220" | ||
} |
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
88531
2
27
+ Addedtslib@^2.0.1