@gov-api-package/subscribe-manager
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -1,1 +0,1 @@ | ||
"use strict";function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var crypt=createCommonjsModule(function(e){var o,n;o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];0<e;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,a=0;n<e.length;n++,a+=8)t[a>>>5]|=e[n]<<24-a%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},bytesToBase64:function(e){for(var t=[],n=0;n<e.length;n+=3)for(var a=e[n]<<16|e[n+1]<<8|e[n+2],r=0;r<4;r++)8*n+6*r<=8*e.length?t.push(o.charAt(a>>>6*(3-r)&63)):t.push("=");return t.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var t=[],n=0,a=0;n<e.length;a=++n%4)0!=a&&t.push((o.indexOf(e.charAt(n-1))&Math.pow(2,-2*a+8)-1)<<2*a|o.indexOf(e.charAt(n))>>>6-2*a);return t}},e.exports=n}),charenc={utf8:{stringToBytes:function(e){return charenc.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(charenc.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}},charenc_1=charenc,isBuffer_1=function(e){return null!=e&&(isBuffer(e)||isSlowBuffer(e)||!!e._isBuffer)};function isBuffer(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function isSlowBuffer(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&isBuffer(e.slice(0,0))}var md5=createCommonjsModule(function(e){function m(e,t){e.constructor==String?e=(t&&"binary"===t.encoding?w:h).stringToBytes(e):b(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=S.bytesToWords(e),t=8*e.length,a=1732584193,r=-271733879,o=-1732584194,s=271733878,i=0;i<n.length;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8);n[t>>>5]|=128<<t%32,n[14+(64+t>>>9<<4)]=t;for(var u=m._ff,c=m._gg,d=m._hh,f=m._ii,i=0;i<n.length;i+=16){var p=a,l=r,y=o,g=s,a=u(a,r,o,s,n[i+0],7,-680876936),s=u(s,a,r,o,n[i+1],12,-389564586),o=u(o,s,a,r,n[i+2],17,606105819),r=u(r,o,s,a,n[i+3],22,-1044525330);a=u(a,r,o,s,n[i+4],7,-176418897),s=u(s,a,r,o,n[i+5],12,1200080426),o=u(o,s,a,r,n[i+6],17,-1473231341),r=u(r,o,s,a,n[i+7],22,-45705983),a=u(a,r,o,s,n[i+8],7,1770035416),s=u(s,a,r,o,n[i+9],12,-1958414417),o=u(o,s,a,r,n[i+10],17,-42063),r=u(r,o,s,a,n[i+11],22,-1990404162),a=u(a,r,o,s,n[i+12],7,1804603682),s=u(s,a,r,o,n[i+13],12,-40341101),o=u(o,s,a,r,n[i+14],17,-1502002290),a=c(a,r=u(r,o,s,a,n[i+15],22,1236535329),o,s,n[i+1],5,-165796510),s=c(s,a,r,o,n[i+6],9,-1069501632),o=c(o,s,a,r,n[i+11],14,643717713),r=c(r,o,s,a,n[i+0],20,-373897302),a=c(a,r,o,s,n[i+5],5,-701558691),s=c(s,a,r,o,n[i+10],9,38016083),o=c(o,s,a,r,n[i+15],14,-660478335),r=c(r,o,s,a,n[i+4],20,-405537848),a=c(a,r,o,s,n[i+9],5,568446438),s=c(s,a,r,o,n[i+14],9,-1019803690),o=c(o,s,a,r,n[i+3],14,-187363961),r=c(r,o,s,a,n[i+8],20,1163531501),a=c(a,r,o,s,n[i+13],5,-1444681467),s=c(s,a,r,o,n[i+2],9,-51403784),o=c(o,s,a,r,n[i+7],14,1735328473),a=d(a,r=c(r,o,s,a,n[i+12],20,-1926607734),o,s,n[i+5],4,-378558),s=d(s,a,r,o,n[i+8],11,-2022574463),o=d(o,s,a,r,n[i+11],16,1839030562),r=d(r,o,s,a,n[i+14],23,-35309556),a=d(a,r,o,s,n[i+1],4,-1530992060),s=d(s,a,r,o,n[i+4],11,1272893353),o=d(o,s,a,r,n[i+7],16,-155497632),r=d(r,o,s,a,n[i+10],23,-1094730640),a=d(a,r,o,s,n[i+13],4,681279174),s=d(s,a,r,o,n[i+0],11,-358537222),o=d(o,s,a,r,n[i+3],16,-722521979),r=d(r,o,s,a,n[i+6],23,76029189),a=d(a,r,o,s,n[i+9],4,-640364487),s=d(s,a,r,o,n[i+12],11,-421815835),o=d(o,s,a,r,n[i+15],16,530742520),a=f(a,r=d(r,o,s,a,n[i+2],23,-995338651),o,s,n[i+0],6,-198630844),s=f(s,a,r,o,n[i+7],10,1126891415),o=f(o,s,a,r,n[i+14],15,-1416354905),r=f(r,o,s,a,n[i+5],21,-57434055),a=f(a,r,o,s,n[i+12],6,1700485571),s=f(s,a,r,o,n[i+3],10,-1894986606),o=f(o,s,a,r,n[i+10],15,-1051523),r=f(r,o,s,a,n[i+1],21,-2054922799),a=f(a,r,o,s,n[i+8],6,1873313359),s=f(s,a,r,o,n[i+15],10,-30611744),o=f(o,s,a,r,n[i+6],15,-1560198380),r=f(r,o,s,a,n[i+13],21,1309151649),a=f(a,r,o,s,n[i+4],6,-145523070),s=f(s,a,r,o,n[i+11],10,-1120210379),o=f(o,s,a,r,n[i+2],15,718787259),r=f(r,o,s,a,n[i+9],21,-343485551),a=a+p>>>0,r=r+l>>>0,o=o+y>>>0,s=s+g>>>0}return S.endian([a,r,o,s])}var S,h,b,w;S=crypt,h=charenc_1.utf8,b=isBuffer_1,w=charenc_1.bin,m._ff=function(e,t,n,a,r,o,s){e=e+(t&n|~t&a)+(r>>>0)+s;return(e<<o|e>>>32-o)+t},m._gg=function(e,t,n,a,r,o,s){e=e+(t&a|n&~a)+(r>>>0)+s;return(e<<o|e>>>32-o)+t},m._hh=function(e,t,n,a,r,o,s){e=e+(t^n^a)+(r>>>0)+s;return(e<<o|e>>>32-o)+t},m._ii=function(e,t,n,a,r,o,s){e=e+(n^(t|~a))+(r>>>0)+s;return(e<<o|e>>>32-o)+t},m._blocksize=16,m._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);e=S.wordsToBytes(m(e,t));return t&&t.asBytes?e:t&&t.asString?w.bytesToString(e):S.bytesToHex(e)}});const SUB_HOST="https://zw.baidusmartapps.com",SUB_QUERY=SUB_HOST+"/ma/zw/subscribe/get_subscribe",SUB_UPDATE=SUB_HOST+"/ma/zw/subscribe/miniapp/subscribe",SUB_MODIFY_INTERVENE=SUB_HOST+"/ma/zw/subscribe/miniapp/modifyintervene",CITY_LIST=SUB_HOST+"/ma/zw/city_list";let locationMap=null;const SUB_SOURCE_MAP={baiduboxapp:405384,bdlite:10014697,tomas:23164036,defaultValue:405384};let appKey,res=swan.getEnvInfoSync();res instanceof Error&&(res={}),appKey=res.appKey||"";const getSystemInfo=()=>new Promise((t,e)=>{swan.getSystemInfo({success:e=>{t(e)},fail:e})});async function getSwanId(){return new Promise((t,e)=>{swan.getSwanId({success(e){t(e.data.swanid)},fail:e})})}async function getQuerySubParams(e){var t=Date.now().toString(),n=await md5(`timestamp=${t}&appKey=`+appKey);return{data:{card_flag:e,appKey:appKey,timestamp:t,sign:n},header:{"Content-Type":"application/x-www-form-urlencoded"},method:"POST"}}async function querySub(e,a){const{data:r,header:o,method:s}=await getQuerySubParams(e);return new Promise((t,n)=>{r.openId=a,swan.request({url:SUB_QUERY,data:r,header:o,method:s,success:e=>{e.data&&!+e.data.status?t(e.data.data[0]):n(e.data)},fail:n})})}async function getCityList(){if(locationMap)return Promise.resolve(locationMap);const t=Date.now().toString(),a=await md5(`timestamp=${t}&appKey=`+appKey);return new Promise((n,e)=>{swan.request({url:CITY_LIST,data:{timestamp:t,appKey:appKey,sign:a},success:e=>{if(e&&e.data&&0===e.data.code){const o=["北京","上海","天津","重庆"],t=e.data.data;locationMap=new Map,t.forEach(e=>{const{label:t,value:n,children:a}=e,r=o.includes(t)?t+"市":t;locationMap.set(r,String(n)),a.forEach(e=>{var{label:e,value:t}=e,e=o.includes(e)?e+"市":e;locationMap.set(r+e,String(t))})}),n(locationMap)}},fail:e})})}async function getLocation(){return new Promise((e,t)=>{swan.getLocation({type:"gcj02",success:e,fail:t})})}async function getUpdateSubParams(e,t,n,a){let r={};if(a){var{intervene:a,interveneType:o}=a;if(a)r.intervene=a;else if(o&&+o<=2)try{var s=await Promise.all([getCityList(),getLocation()]);if(s){const d=s[0]||null;var i,u=s[1]||null;d&&u&&({city:c,province:i}=u,c&&i&&(r.intervene=JSON.stringify([{type:o,value:d.get(1==+o?i+c:i)}])))}}catch(e){}}var{platform:a,host:s}=await getSystemInfo(),u=await getSwanId(),o=Date.now().toString(),c=await md5(`timestamp=${o}&appKey=`+appKey);return{method:"POST",data:{subscribeID:e,opType:t,sourceFlag:n,source:1,appKey:appKey,timestamp:o,swanId:u,sourceApp:getSourceApp(s),deviceType:"android"===a?2:1,sign:c,...r},header:{"Content-Type":"application/x-www-form-urlencoded"}}}async function updateSub(e,a,t,n,r){const{method:o,data:s,header:i}=await getUpdateSubParams(e,t,n,r);return new Promise((t,n)=>{s.openId=a,swan.request({url:SUB_UPDATE,method:o,data:s,header:i,success:e=>{e.data.code&&(e.data.code=+e.data.code),e.data&&(e.data.sendData=s),e.data?t(e.data):n()},fail:n})})}async function modifyIntervene(e,n,t,a,r){const{method:o,data:s,header:i}=await getUpdateSubParams(e,t,a);return new Promise((t,e)=>{swan.request({url:SUB_MODIFY_INTERVENE,method:o,data:{openId:n,intervene:JSON.stringify(r),...s},header:i,success:e=>{t(e)},fail:e})})}function toManage(){swan.navigateToSmartProgram({appKey:"FV8FuO4q887e9aj54GZpQHlwEUOd1XVc",path:"/pages/home/index"})}const addSub=(e,t,n,a)=>updateSub(e,t,1,n,a),cancelSub=(e,t,n)=>updateSub(e,t,0,n),getSourceApp=e=>SUB_SOURCE_MAP[e]||SUB_SOURCE_MAP.defaultValue;var index={querySub:querySub,addSub:addSub,cancelSub:cancelSub,toManage:toManage,modifyIntervene:modifyIntervene};module.exports=index; | ||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var md5=_interopDefault(require("md5"));const ONLINE_HOST="https://zw.baidusmartapps.com";let SUB_HOST,SUB_QUERY,SUB_UPDATE,SUB_MODIFY_INTERVENE,CITY_LIST,locationMap=null;const SUB_SOURCE_MAP={baiduboxapp:405384,bdlite:10014697,tomas:23164036,defaultValue:405384};let appKey,res=swan.getEnvInfoSync();res instanceof Error&&(res={}),appKey=res.appKey||"";const getSystemInfo=()=>new Promise((a,e)=>{swan.getSystemInfo({success:e=>{a(e)},fail:e})});async function getSwanId(){return new Promise((a,e)=>{swan.getSwanId({success(e){a(e.data.swanid)},fail:e})})}async function getQuerySubParams(e,a,t){var n=Date.now().toString(),s=await md5(`timestamp=${n}&appKey=`+appKey),e={card_flag:e,appKey:appKey,timestamp:n,sign:s};a&&Object.assign(e,{openId:a}),t&&Object.assign(e,{search_intervene:t});return{data:e,header:{"Content-Type":"application/x-www-form-urlencoded"},method:"POST"}}async function querySub(e,a,t){const{data:n,header:s,method:i}=await getQuerySubParams(e,a,t);return new Promise((a,t)=>{swan.request({url:SUB_QUERY,data:n,header:s,method:i,success:e=>{e.data&&!+e.data.status?a(e.data.data[0]):t(e.data)},fail:t})})}async function getCityList(){if(locationMap)return Promise.resolve(locationMap);const a=Date.now().toString(),n=await md5(`timestamp=${a}&appKey=`+appKey);return new Promise((t,e)=>{swan.request({url:CITY_LIST,data:{timestamp:a,appKey:appKey,sign:n},success:e=>{if(e&&e.data&&0===e.data.code){const i=["北京","上海","天津","重庆"],a=e.data.data;locationMap=new Map,a.forEach(e=>{const{label:a,value:t,children:n}=e,s=i.includes(a)?a+"市":a;locationMap.set(s,String(t)),n.forEach(e=>{var{label:e,value:a}=e,e=i.includes(e)?e+"市":e;locationMap.set(s+e,String(a))})}),t(locationMap)}},fail:e})})}async function getLocation(){return new Promise((e,a)=>{swan.getLocation({type:"gcj02",success:e,fail:a})})}async function getUpdateSubParams(e,a,t,n){let s={};if(n){var{intervene:n,interveneType:i}=n;if(n)s.intervene=n;else if(i&&+i<=2)try{var r=await Promise.all([getCityList(),getLocation()]);if(r){const d=r[0]||null;var o,c=r[1]||null;d&&c&&({city:u,province:o}=c,u&&o&&(s.intervene=JSON.stringify([{type:i,value:d.get(1==+i?o+u:o)}])))}}catch(e){}}var{platform:n,host:r}=await getSystemInfo(),c=await getSwanId(),i=Date.now().toString(),u=await md5(`timestamp=${i}&appKey=`+appKey);return{method:"POST",data:{subscribeID:e,opType:a,sourceFlag:t,source:1,appKey:appKey,timestamp:i,swanId:c,sourceApp:getSourceApp(r),deviceType:"android"===n?2:1,sign:u,...s},header:{"Content-Type":"application/x-www-form-urlencoded"}}}async function updateSub(e,n,a,t,s){const{method:i,data:r,header:o}=await getUpdateSubParams(e,a,t,s);return new Promise((a,t)=>{r.openId=n,swan.request({url:SUB_UPDATE,method:i,data:r,header:o,success:e=>{e.data.code&&(e.data.code=+e.data.code),e.data&&(e.data.sendData=r),e.data?a(e.data):t()},fail:t})})}async function modifyIntervene(e,t,a,n,s){const{method:i,data:r,header:o}=await getUpdateSubParams(e,a,n);return new Promise((a,e)=>{swan.request({url:SUB_MODIFY_INTERVENE,method:i,data:{openId:t,intervene:JSON.stringify(s),...r},header:o,success:e=>{a(e)},fail:e})})}function toManage(){swan.navigateToSmartProgram({appKey:"FV8FuO4q887e9aj54GZpQHlwEUOd1XVc",path:"/pages/home/index"})}const addSub=(e,a,t,n)=>updateSub(e,a,1,t,n),cancelSub=(e,a,t)=>updateSub(e,a,0,t),getSourceApp=e=>SUB_SOURCE_MAP[e]||SUB_SOURCE_MAP.defaultValue,subInit=e=>{e=(e||{}).host;e&&(SUB_HOST=e,SUB_QUERY=SUB_HOST+"/ma/zw/subscribe/get_subscribe",SUB_UPDATE=SUB_HOST+"/ma/zw/subscribe/miniapp/subscribe",SUB_MODIFY_INTERVENE=SUB_HOST+"/ma/zw/subscribe/miniapp/modifyintervene",CITY_LIST=SUB_HOST+"/ma/zw/city_list")};subInit({host:ONLINE_HOST});var index={querySub:querySub,addSub:addSub,cancelSub:cancelSub,toManage:toManage,modifyIntervene:modifyIntervene,subInit:subInit};module.exports=index; |
{ | ||
"name": "@gov-api-package/subscribe-manager", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "订阅和订阅状态查询", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -50,2 +50,3 @@ # 订阅API | ||
| openId | String | 小程序openId | 是 | | ||
| searchIntervene | String | 特征数据 | 否 | | ||
@@ -74,4 +75,5 @@ #### API返回参数: | ||
* @param {string} openId 小程序openId | ||
* @param {string} searchIntervene 特征数据 | ||
*/ | ||
subscribeManager.querySub(sourceFlag, openId).then(res => { | ||
subscribeManager.querySub(sourceFlag, openId, searchIntervene).then(res => { | ||
console.log(res); | ||
@@ -269,1 +271,9 @@ // 业务逻辑... | ||
``` | ||
### 2.2.6 初始化订阅配置 subInit | ||
#### API请求参数: | ||
| 参数 | 类型 | 说明 | 是否必填 | | ||
| ---- | ---- | ---- | ---- | | ||
| conf | Object | 订阅配置信息 | 是| | ||
| >> conf.host | String | 订阅请求 HOST | 否| |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
276
12245
16
3