UNPKG

@cloudbase/js-sdk

Version:
2 lines 776 kB
/*! For license information please see index.node.esm.js.LICENSE.txt */ import*as e from"jwt-decode";import*as t from"@cloudbase/adapter-interface";import*as n from"@cloudbase/signature-nodejs";import*as r from"jsonwebtoken";import*as o from"web-streams-polyfill";import*as i from"ws";import{createRequire as a}from"module";import*as s from"@cloudbase/adapter-wx_mp";import*as c from"@cloudbase/wx-cloud-client-sdk";import*as u from"@mattiasbuelens/web-streams-adapter";import*as l from"text-encoding-shim";import*as p from"bson";var d={9954:(e,t,n)=>{e.exports={parallel:n(8197),serial:n(8967),serialOrdered:n(982)}},190:e=>{function t(e){"function"==typeof this.jobs[e]&&this.jobs[e]()}e.exports=function(e){Object.keys(e.jobs).forEach(t.bind(e)),e.jobs={}}},1307:(e,t,n)=>{var r=n(8765);e.exports=function(e){var t=!1;return r(function(){t=!0}),function(n,o){t?e(n,o):r(function(){e(n,o)})}}},8765:e=>{e.exports=function(e){var t="function"==typeof setImmediate?setImmediate:"object"==typeof process&&"function"==typeof process.nextTick?process.nextTick:null;t?t(e):setTimeout(e,0)}},5798:(e,t,n)=>{var r=n(1307),o=n(190);e.exports=function(e,t,n,i){var a=n.keyedList?n.keyedList[n.index]:n.index;n.jobs[a]=function(e,t,n,o){return 2==e.length?e(n,r(o)):e(n,t,r(o))}(t,a,e[a],function(e,t){a in n.jobs&&(delete n.jobs[a],e?o(n):n.results[a]=t,i(e,n.results))})}},7379:e=>{e.exports=function(e,t){var n=!Array.isArray(e),r={index:0,keyedList:n||t?Object.keys(e):null,jobs:{},results:n?{}:[],size:n?Object.keys(e).length:e.length};return t&&r.keyedList.sort(n?t:function(n,r){return t(e[n],e[r])}),r}},3797:(e,t,n)=>{var r=n(190),o=n(1307);e.exports=function(e){Object.keys(this.jobs).length&&(this.index=this.size,r(this),o(e)(null,this.results))}},8197:(e,t,n)=>{var r=n(5798),o=n(7379),i=n(3797);e.exports=function(e,t,n){for(var a=o(e);a.index<(a.keyedList||e).length;)r(e,t,a,function(e,t){e?n(e,t):0!==Object.keys(a.jobs).length||n(null,a.results)}),a.index++;return i.bind(a,n)}},8967:(e,t,n)=>{var r=n(982);e.exports=function(e,t,n){return r(e,t,null,n)}},982:(e,t,n)=>{var r=n(5798),o=n(7379),i=n(3797);function a(e,t){return e<t?-1:e>t?1:0}e.exports=function(e,t,n,a){var s=o(e,n);return r(e,t,s,function n(o,i){o?a(o,i):(s.index++,s.index<(s.keyedList||e).length?r(e,t,s,n):a(null,s.results))}),i.bind(s,a)},e.exports.ascending=a,e.exports.descending=function(e,t){return-1*a(e,t)}},7922:(e,t,n)=>{n.d(t,{$R:()=>w,Bh:()=>y,Fy:()=>b,M4:()=>I,R1:()=>_,eX:()=>d,mI:()=>l,n0:()=>h,po:()=>u,tC:()=>p,vS:()=>x});var r=n(2976),o=function(){return o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)},i=r._G.tC,a=r._G.pM,s="",c="@cloudbase/js-sdk";function u(e){s=e}function l(){return s}function p(e){c=e,i(e)}function d(){return c}var f,h="2020-01-10",m=[],v=["env","endPointKey","region"],y="https:";function g(e){return m.find(function(t){return v.filter(function(t){return null!=e[t]}).every(function(n){return t[n]===e[n]})})}function b(e){var t,n;e.protocol&&!/:$/.test(e.protocol)&&(e.protocol="".concat(e.protocol,":"));var r=g(e);r?(null!=e.baseUrl&&(r.baseUrl=e.baseUrl),null!=e.protocol&&(r.protocol=e.protocol)):m.push(o(o({},e),{protocol:null!==(t=e.protocol)&&void 0!==t?t:y})),"CLOUD_API"===e.endPointKey&&a(null!==(n=e.protocol)&&void 0!==n?n:y)}function x(e,t,n){return g({env:e,endPointKey:t,region:n})}function w(e,t,n){var r="//".concat(e,".api.tcloudbasegateway.com/v1");n&&(r="//".concat(e,".api.intl.tcloudbasegateway.com/v1")),b({endPointKey:"GATEWAY",env:e,baseUrl:r,protocol:t})}function _(e,t,n){b({env:e,region:t,baseUrl:"//".concat(e,".").concat(t||"ap-shanghai",".tcb-api.tencentcloudapi.com/web"),protocol:n,endPointKey:"CLOUD_API"})}function I(e,t){void 0===t&&(t="CLOUD_API");var n=x(e,t||"CLOUD_API"),r=n.protocol,o=n.baseUrl;return"".concat(r).concat(o).match(/(http(s)?:)?\/\/([^/?#]*)/)[0]}!function(e){e.NULL="NULL",e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.WECHAT_PUBLIC="WECHAT-PUBLIC",e.WECHAT_OPEN="WECHAT-OPEN",e.CUSTOM="CUSTOM",e.EMAIL="EMAIL",e.USERNAME="USERNAME",e.PHONE="PHONE"}(f||(f={}))},2301:(e,t,n)=>{n.r(t),n.d(t,{E:()=>D,NodeRequest:()=>se,SYMBOL_CURRENT_ENV:()=>z,SYMBOL_DEFAULT_ENV:()=>K,TcbError:()=>L,buildAdminUrl:()=>ve,callCompatibleWxOpenApi:()=>Ee,callWxOpenApi:()=>_e,callWxPayApi:()=>Se,createWebStreamFromNodeReadableStream:()=>U,default:()=>Be,filterUndefined:()=>M,filterValue:()=>q,getCloudbaseContext:()=>$,getSecretInfo:()=>ee,getServerInjectUrl:()=>X,getTcbContextConfig:()=>Q,getWxCloudToken:()=>he,getWxOptions:()=>we,isPageModuleName:()=>V,isValidEnvFormat:()=>H,parseContext:()=>Y,parseQueryString:()=>j,processReturn:()=>W,sendWxFormDataRequest:()=>be,sendWxRequest:()=>ge,setThrowOnCode:()=>B,wxCallContainerApi:()=>Oe});var r,o=n(7149),i=n(7147),a=n(1017),s={INVALID_PARAM:{code:"INVALID_PARAM",message:"invalid param"},SYS_ERR:{code:"SYS_ERR",message:"system error"},STORAGE_REQUEST_FAIL:{code:"STORAGE_REQUEST_FAIL",message:"storage request fail"},STORAGE_FILE_NONEXIST:{code:"STORAGE_FILE_NONEXIST",message:"storage file not exist"},TCB_CLS_UNOPEN:{code:"TCB_CLS_UNOPEN",message:"需要先开通日志检索功能"},INVALID_CONTEXT:{code:"INVALID_CONTEXT",message:"无效的context对象,请使用 云函数入口的context参数"}},c="/admin",u="/auth/v1/token/clientCredential",l=/^[a-zA-Z0-9_\-#@~=*(){}[\]:.,<>+]{4,32}$/;!function(e){e.SECRET="SECRET",e.SESSION_SECRET="SESSION_SECRET"}(r||(r={}));var p,d=n(2976),f=n(3408),h=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},m=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};function v(e,t){return void 0===t&&(t={}),h(this,void 0,Promise,function(){var n,r,o,i;return m(this,function(a){switch(a.label){case 0:n="".concat("http://metadata.tencentyun.com","/").concat(p.latest,"/").concat(e),r=new AbortController,t.timeout&&(o=setTimeout(function(){return r.abort()},t.timeout)),a.label=1;case 1:return a.trys.push([1,,5,6]),[4,fetch(n,{signal:r.signal})];case 2:return 200!==(i=a.sent()).status?[3,4]:[4,i.text()];case 3:return[2,a.sent()];case 4:throw new Error("[ERROR] GET ".concat(n," status: ").concat(i.status));case 5:return o&&clearTimeout(o),[7];case 6:return[2]}})})}!function(e){e.v20170919="2017-09-19",e["v1.0"]="1.0",e.latest="latest"}(p||(p={}));var y={appId:void 0};function g(){return h(this,void 0,Promise,function(){var e;return m(this,function(t){switch(t.label){case 0:if(void 0!==y.appId)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,v("meta-data/app-id",{timeout:30})];case 2:return e=t.sent(),/^[1-9][0-9]{4,64}$/gim.test(e)?y.appId=e:y.appId="",[3,4];case 3:return t.sent(),[3,4];case 4:return[2,y.appId||""]}})})}var b,x,w=(b=function(e,t){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},b(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}b(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),_=function(){return _=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},_.apply(this,arguments)},I=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},E=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},S=(x=d.P6).isFormData,O=x.toQueryString;function T(e){return"undefined"!=typeof process&&process.env?void 0!==e?process.env[e]:process.env:void 0!==e?void 0:{}}var A=function(){return"SCF"===T("TENCENTCLOUD_RUNENV")},P=new Set(["formal","pre","test"]);function R(){return I(this,void 0,Promise,function(){var e;return E(this,function(t){switch(t.label){case 0:return"true"===T("TENCENTCLOUD")?[2,!0]:[4,g()];case 1:return[2,"string"==typeof(e=t.sent())&&""!==e]}})})}var C=function(e){if("string"!=typeof e)throw _(_({},s.INVALID_PARAM),{message:"uid must be a string"});if(!l.test(e))throw _(_({},s.INVALID_PARAM),{message:'Invalid uid: "'.concat(e,'"')})};function N(e){if(!e||!e.trim())return null;try{return JSON.parse(e)}catch(t){return console.warn("catch an error",{e:t,text:e}),e}}function k(e){return Object.entries(e).reduce(function(e,t){var n=t[0],r=t[1];return e[n]=String(r),e},{})}function j(e){var t={},n=e.replace(/^[?#]/,"");return n?(n.split("&").forEach(function(e){var n=e.split("="),r=n[0],o=n[1];r=decodeURIComponent(r),o=decodeURIComponent(o||""),r&&(t[r]?Array.isArray(t[r])?t[r].push(o):t[r]=[t[r],o]:t[r]=o)}),t):t}function U(e){var t=e[Symbol.asyncIterator]();return new f.ReadableStream({pull:function(e){return I(this,void 0,void 0,function(){var n;return E(this,function(r){switch(r.label){case 0:return[4,t.next()];case 1:return(n=r.sent()).done?e.close():e.enqueue(n.value),[2]}})})}})}var L=function(e){function t(t){var n=e.call(this,t.message)||this;return n.code=t.code||"",n.message=t.message||"",n.requestId=t.requestId||"",n}return w(t,e),t}(Error);function D(e){return new L(e)}function q(e,t){for(var n in e)e[n]===t&&delete e[n]}function M(e){q(e,void 0)}var F=!0;function B(e){F=e}function W(e){if(!F)return e;throw D(_({},e))}function V(e){return void 0===e&&(e=""),"string"==typeof e&&e.startsWith("$:")}var G=/^[a-z0-9_-]{1,40}$/;function H(e){return void 0===e&&(e=""),"string"==typeof e&&G.test(e)}var z=Symbol.for("SYMBOL_CURRENT_ENV"),K=Symbol.for("SYMBOL_DEFAULT_ENV"),J=function(){return J=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},J.apply(this,arguments)};function Y(e){if("object"!=typeof e)throw J(J({},s.INVALID_CONTEXT),{message:"context 必须为对象类型"});var t={},n=e.memory_limit_in_mb,r=e.time_limit_in_ms,o=e.request_id,i=e.function_version,a=e.namespace,c=e.function_name,u=e.environ,l=e.environment;try{if(t.memoryLimitInMb=n,t.timeLimitIns=r,t.requestId=o,t.functionVersion=i,t.namespace=a,t.functionName=c,l)t.environment=JSON.parse(l);else{var p=null==u?void 0:u.split(";"),d={};for(var f in p)if(p[f].includes("=")){var h=p[f].indexOf("="),m=p[f].slice(0,h),v=p[f].slice(h+1);v.indexOf(",")>=0&&(v=v.split(",")),d[m]=v}t.environ=d}}catch(e){throw J({},s.INVALID_CONTEXT)}return t}var $=function(e){A()&&(T("TENCENTCLOUD_REGION")||console.error("[TCB][ERROR] missing `TENCENTCLOUD_REGION` environment"),T("SCF_NAMESPACE")||console.error("[TCB][ERROR] missing `SCF_NAMESPACE` environment"));var t=T(),n={TRIGGER_SRC:t.TRIGGER_SRC,_SCF_TCB_LOG:t._SCF_TCB_LOG,SCF_NAMESPACE:t.SCF_NAMESPACE,TENCENTCLOUD_RUNENV:t.TENCENTCLOUD_RUNENV,TENCENTCLOUD_SECRETID:t.TENCENTCLOUD_SECRETID,TENCENTCLOUD_SECRETKEY:t.TENCENTCLOUD_SECRETKEY,TENCENTCLOUD_SESSIONTOKEN:t.TENCENTCLOUD_SESSIONTOKEN,WX_CONTEXT_KEYS:t.WX_CONTEXT_KEYS,WX_TRIGGER_API_TOKEN_V0:t.WX_TRIGGER_API_TOKEN_V0,WX_CLIENTIP:t.WX_CLIENTIP,WX_CLIENTIPV6:t.WX_CLIENTIPV6,TCB_CONTEXT_KEYS:t.TCB_CONTEXT_KEYS,TCB_CONTEXT_CNFG:t.TCB_CONTEXT_CNFG,LOGINTYPE:t.LOGINTYPE,CLOUDBASE_APIKEY:t.CLOUDBASE_APIKEY},r={};if(e){var o=Y(e),i=o.environment,a=o.environ;r=i||a||{}}for(var s=0,c=[r.TCB_CONTEXT_KEYS||t.TCB_CONTEXT_KEYS,r.WX_CONTEXT_KEYS||t.WX_CONTEXT_KEYS];s<c.length;s++){var u=c[s];if(u)try{for(var l=0,p=u.split(",");l<p.length;l++){var d=p[l];n[d]=r[d]||T(d)}}catch(e){}}var f=J(J({},n),r);return Object.fromEntries(Object.entries(f).filter(function(e){return void 0!==e[1]}))};function Q(){try{var e=$().TCB_CONTEXT_CNFG;return e?JSON.parse(e):{}}catch(e){return console.error("[TCB][ERROR] parse context error: ",e),{}}}function X(){return Q().URL||""}var Z={},ee=function(e){var t,n,o,i,a,s,c;Z=JSON.parse(JSON.stringify(e||Z));var u=$(),l=u.TCB_ENV,p=u.SCF_NAMESPACE,d=u.TENCENTCLOUD_RUNENV,f=u.TENCENTCLOUD_SECRETID,h=u.TENCENTCLOUD_SECRETKEY,m=u.TENCENTCLOUD_SESSIONTOKEN,v=u.CLOUDBASE_APIKEY,y=J(J({},Z),e),g="";"local"===(g="symbol"!=typeof(null==e?void 0:e.env)&&(null==e?void 0:e.env)?e.env:l||p||"")&&"WX_LOCAL_SCF"===d&&(g="");var b={env:g,secretId:"",secretKey:"",sessionToken:"",accessKey:"",secretType:"",credentials:void 0,context:void 0};if((null==y?void 0:y.context)&&(b.context=y.context),((null==y?void 0:y.credentials)||(null===(t=null==e?void 0:e.auth)||void 0===t?void 0:t.credentials))&&(b.credentials=(null==y?void 0:y.credentials)||(null===(n=null==e?void 0:e.auth)||void 0===n?void 0:n.credentials)),(null==e?void 0:e.accessKey)||(null==y?void 0:y.accessKey))return b.accessKey=(null==e?void 0:e.accessKey)||(null==y?void 0:y.accessKey),b;if((null==y?void 0:y.secretId)&&(null==y?void 0:y.secretKey))return J(J({},b),{secretId:y.secretId,secretKey:y.secretKey,sessionToken:y.sessionToken||"",secretType:y.sessionToken?r.SESSION_SECRET:r.SECRET});if((null===(o=null==e?void 0:e.auth)||void 0===o?void 0:o.secretId)&&(null===(i=null==e?void 0:e.auth)||void 0===i?void 0:i.secretKey))return J(J({},b),{secretId:e.auth.secretId,secretKey:e.auth.secretKey,sessionToken:e.auth.sessionToken||"",secretType:e.auth.secretType||r.SECRET});if(v)return J(J({},b),{accessKey:v});if(f&&h)return J(J({},b),{secretId:f,secretKey:h,sessionToken:m||"",secretType:r.SESSION_SECRET});var x=(null==y?void 0:y.context)||(null==e?void 0:e.context);if(null==x?void 0:x.extendedContext){var w=x.extendedContext;return g||(g=w.envId||""),J(J({},b),{env:g,secretId:(null===(a=null==w?void 0:w.tmpSecret)||void 0===a?void 0:a.secretId)||"",secretKey:(null===(s=null==w?void 0:w.tmpSecret)||void 0===s?void 0:s.secretKey)||"",sessionToken:(null===(c=null==w?void 0:w.tmpSecret)||void 0===c?void 0:c.token)||""})}return J({},b)},te=n(7922),ne=function(){return ne=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ne.apply(this,arguments)},re=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},oe=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},ie=null;function ae(){return re(this,void 0,void 0,function(){var e;return oe(this,function(t){switch(t.label){case 0:if(ie)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,Promise.resolve().then(n.bind(n,9143))];case 2:return e=t.sent(),ie=e.sign,[3,4];case 3:return t.sent(),console.error("缺少依赖 @cloudbase/signature-nodejs,请执行以下命令安装:\n\n npm install @cloudbase/signature-nodejs\n\n该依赖用于 Node 环境下的请求签名。"),[3,4];case 4:return[2,ie]}})})}var se=function(){function e(e){var t=this;this.getReqOptions=function(e,n){return re(t,void 0,void 0,function(){var t,r,o,i,a,s,l,p,d,f,h,m,v,y,g,b,x,w,_,S,O,C,k,j,U,L,D,q,M,F,B,W,V,G,H;return oe(this,function(z){switch(z.label){case 0:return t=new URL(e),r=$().TCB_SOURCE,a=(i="".concat((null===(M=null===(q=Z.context)||void 0===q?void 0:q.extendedContext)||void 0===M?void 0:M.source)||r||"",",")).concat,[4,I(void 0,void 0,Promise,function(){return E(this,function(e){switch(e.label){case 0:return A()?[2,"scf"]:T("CBR_ENV_ID")?[2,"cbr"]:P.has(T("SUMERU_ENV")||"")?[2,"sumeru"]:[4,R()];case 1:return e.sent()?[2,"tencentcloud"]:[2,"unknown"]}})})];case 1:return o=a.apply(i,[z.sent()]),n.headers=ne(ne({},n.headers),{"User-Agent":"adapter-node/".concat((null===(F=n.headers)||void 0===F?void 0:F["X-SDK-Version"])||"@cloudbase/js-sdk/".concat((0,te.mI)())),"X-TCB-Source":o,"X-Client-Timestamp":(new Date).valueOf(),"X-TCB-Region":Z.region||T("TENCENTCLOUD_REGION")||"",Host:t.host}),!1===n.withCredentials||(null===(W=null===(B=n.headers.Authorization)||void 0===B?void 0:B.replace("Bearer",""))||void 0===W?void 0:W.trim())||t.pathname.startsWith("/auth/")&&t.pathname!==u?[2,n]:(s=t.pathname===c,["/v1/model/","/v1/rdb/","/v1/ai/"].some(function(e){return t.pathname.startsWith(e)})?[4,this.getClientCredential({origin:t.origin})]:[3,3]);case 2:return l=z.sent(),n.headers.Authorization="Bearer ".concat(l),[2,n];case 3:return p=ne(ne({},this.config),null===(V=this.config)||void 0===V?void 0:V.auth),d=p.secretId,f=p.secretKey,h=p.sessionToken,m=ne(ne({},this.config),null===(G=this.config)||void 0===G?void 0:G.auth).secretType,v=n.method,y=n.body,g=JSON.parse(JSON.stringify(n.headers)),b=this.isNpmFormData(y),(x=b?y.__plainObj?ne({},y.__plainObj):{}:"object"==typeof y?y:N(y)||{}).envName=(null==x?void 0:x.env)||this.config.env||(null===(H=ee())||void 0===H?void 0:H.env)||"",x.access_token?[2,n]:("get"===v.toLowerCase()&&(x=void 0),d&&f&&"SESSION_SECRET"!==m||(w=ee(),d=w.secretId,f=w.secretKey,h=w.sessionToken),d&&f?(delete g.Authorization,g["content-type"]?g["content-type"]=g["content-type"].toLowerCase():g["Content-Type"]&&(g["Content-Type"]=g["Content-Type"].toLowerCase()),s&&h&&(x.sessionToken=h),_={secretId:d,secretKey:f,method:v,url:e,params:x,headers:g,withSignedParams:s,timestamp:Math.floor((new Date).getTime()/1e3)-1,isCloudApi:!s},g["content-type"]||g["Content-Type"]?[4,ae()]:[2,n]):[2,n]);case 4:return(S=z.sent())?(O=S(_),C=O.authorization,k=O.timestamp,"string"==typeof h&&""!==h?s?(g.Authorization="".concat(C),g["X-Timestamp"]=k,g["X-Signature-Expires"]=600):g.Authorization="".concat(C,", Timestamp=").concat(k,", Token=").concat(h):(g.Authorization="".concat(C,", Timestamp=").concat(k),s&&(g["X-Timestamp"]=k,g["X-Signature-Expires"]=600)),b?(j=y,U=new Set(Object.keys(j.__plainObj||{})),x.envName&&!U.has("envName")&&j.append("envName",x.envName),x.sessionToken&&!U.has("sessionToken")&&j.append("sessionToken",x.sessionToken),L=j.getBuffer(),D=j.getHeaders(),[2,ne(ne({},n),{headers:ne(ne(ne({},g),D),{"content-length":String(L.length)}),body:L})]):[2,ne(ne({},n),{headers:g,body:"object"==typeof x?JSON.stringify(x):x})]):[2,n]}})})},this.get=function(e){return t.request(ne(ne({},e),{method:"get"}),t.restrictedMethods.includes("get"))},this.post=function(e){return t.request(ne(ne({},e),{method:"post"}),t.restrictedMethods.includes("post"))},this.put=function(e){return t.request(ne(ne({},e),{method:"put"}))},this.upload=function(e){var n,r=e,o=r.data,i=r.file,a=r.fileContent,s=r.name,c=r.method,u=r.headers,l=void 0===u?{}:u,p=null!=i?i:a;if(void 0===p||void 0===s)throw new Error("file and name is required");var d=k(null!=o?o:{}),f=null==c?void 0:c.toLowerCase(),h=null!==(n=["post","put"].find(function(e){return e===f}))&&void 0!==n?n:"put",m=new FormData;return"post"===h?(Object.keys(d).forEach(function(e){m.append(e,d[e])}),m.append("key",s),m.append("file",p instanceof Blob?p:new Blob([p])),t.request(ne(ne({},e),{data:m,method:h}),t.restrictedMethods.includes("upload"))):t.request(ne(ne({},e),{method:"put",headers:l,body:p}),t.restrictedMethods.includes("upload"))},this.download=function(e){return re(t,void 0,Promise,function(){var t,n,r,o,s;return oe(this,function(c){switch(c.label){case 0:return[4,fetch(e.url,{headers:{},signal:this.timeout?AbortSignal.timeout(this.timeout):void 0})];case 1:if(!(t=c.sent()).ok)throw new Error("Download failed with status ".concat(t.status));return[4,t.arrayBuffer()];case 2:return n=c.sent(),r=Buffer.from(n),(o=e.tempFilePath)?(s=a.dirname(o),i.existsSync(s)||i.mkdirSync(s,{recursive:!0}),i.writeFileSync(o,r),[2,{statusCode:200,tempFilePath:o}]):[2,{statusCode:200,tempFilePath:e.url,fileContent:r}]}})})},this.fetch=function(e){return re(t,void 0,Promise,function(){var t,n,r,o,i,a,s,c,u,l,p,d,f,h,m,v;return oe(this,function(y){switch(y.label){case 0:return t=e.enableAbort,n=void 0!==t&&t,r=e.stream,o=void 0!==r&&r,i=e.signal,a=e.customReqOpts,s=this.getRealUrl(e.url,e.headers||{},e.body),c=(null==a?void 0:a.timeout)||this.timeout,u=this.createAbortController(c,n,i),l=u[0],p=u[1],d=e.headers?function(e){if(function(e){try{return e instanceof Headers}catch(e){return!1}}(e)){var t={};return e.forEach(function(e,n){t[n]=e}),t}return e}(e.headers):void 0,[4,this.getReqOptions(s,ne(ne({},e),{headers:d,body:e.body,signal:l.signal}))];case 1:f=y.sent(),this.applyDuplexIfNeeded(f),y.label=2;case 2:return y.trys.push([2,,8,9]),[4,fetch(s,f)];case 3:return h=y.sent(),m=void 0,204!==+h.status?[3,4]:(m="",[3,7]);case 4:return o?(m=h.body,[3,7]):[3,5];case 5:return v=N,[4,h.text()];case 6:m=v.apply(void 0,[y.sent()]),y.label=7;case 7:return[2,{data:m,statusCode:h.status,header:h.headers,response:h}];case 8:return p(),[7];case 9:return[2]}})})},this.request=function(e,n){return void 0===n&&(n=!1),re(t,void 0,Promise,function(){var t,r,i,a,s,c,u,l,p,d,f,h,m,v,y,g,b,x,w,_,I,E,T,A,P,R,C,j,U,L,D,q,M;return oe(this,function(F){switch(F.label){case 0:return t=e.url,r=e.headers,i=void 0===r?{}:r,a=e.data,s=e.responseType,c=e.withCredentials,u=e.body,l=e.method,p=e.customReqOpts,d=k(i),f=String(l).toLowerCase()||"get",h=(null==p?void 0:p.timeout)||this.timeout,m=e.signal,v=this.createAbortController(h,n,m),y=v[0],g=v[1],b=S(a)?a:"application/x-www-form-urlencoded"===d["content-type"]?O(null!=a?a:{}):u||(a?JSON.stringify(a):void 0),x=this.getRealUrl((0,o.formatUrl)("https",null!=t?t:"","get"===f?a:{}),e.headers||{},b),[4,this.getReqOptions(x,{method:f,headers:d,body:b,credentials:c?"include":"same-origin",signal:y.signal})];case 1:w=F.sent(),this.applyDuplexIfNeeded(w),F.label=2;case 2:return F.trys.push([2,,19,20]),[4,fetch(x,w)];case 3:_=F.sent(),I={header:{},statusCode:_.status},F.label=4;case 4:return F.trys.push([4,11,,18]),"blob"!==s?[3,6]:(E=I,[4,_.blob()]);case 5:return E.data=F.sent(),[3,10];case 6:return"buffer"!==s?[3,8]:(T=I,P=(A=Buffer).from,[4,_.arrayBuffer()]);case 7:return T.data=P.apply(A,[F.sent()]),[3,10];case 8:return R=I,C=N,[4,_.text()];case 9:R.data=C.apply(void 0,[F.sent()]),F.label=10;case 10:return[3,18];case 11:return j=F.sent(),console.log("catch an error",j),"blob"!==s?[3,13]:(U=I,[4,_.blob()]);case 12:return U.data=F.sent(),[3,17];case 13:return"buffer"!==s?[3,15]:(L=I,q=(D=Buffer).from,[4,_.arrayBuffer()]);case 14:return L.data=q.apply(D,[F.sent()]),[3,17];case 15:return M=I,[4,_.text()];case 16:M.data=F.sent(),F.label=17;case 17:return[3,18];case 18:return _.headers.forEach(function(e,t){return I.header[t.toLowerCase()]=e}),[2,I];case 19:return g(),[7];case 20:return[2]}})})};var n=e.timeout,r=e.restrictedMethods;this.timeout=n,this.restrictedMethods=r||["get","post","upload","download"],this.config=e}return e.prototype.getClientCredential=function(e){var t;return re(this,void 0,Promise,function(){var n;return oe(this,function(r){switch(r.label){case 0:return[4,this.fetch({url:"".concat(e.origin).concat(u),method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({grant_type:"client_credentials"})})];case 1:return n=r.sent(),[2,null===(t=n.data)||void 0===t?void 0:t.access_token]}})})},e.prototype.getRealUrl=function(e,t,n){var r,o,i,a;if(null===(o=null===(r=t.Authorization)||void 0===r?void 0:r.replace("Bearer",""))||void 0===o?void 0:o.trim())return e;if(("object"==typeof n?n:N(n)||"").access_token)return e;var s=new URL(e);return"/web"===s.pathname&&(null===(i=this.config.auth)||void 0===i?void 0:i.secretId)&&(null===(a=this.config.auth)||void 0===a?void 0:a.secretKey)&&(s.pathname=c),s.toString()},e.prototype.createAbortController=function(e,t,n){var r,o=new AbortController;return n&&(n.aborted?o.abort():n.addEventListener("abort",function(){return o.abort()},{once:!0})),e&&(r=setTimeout(function(){var t="请求在".concat(e/1e3,"s内未完成,已中断");console.warn(t),o.abort(new Error(t))},e)),[o,function(){return clearTimeout(r)}]},e.prototype.applyDuplexIfNeeded=function(e){var t;e.body&&"function"==typeof(null===(t=e.body)||void 0===t?void 0:t.pipe)&&(e.duplex="half")},e.prototype.isNpmFormData=function(e){return e&&"object"==typeof e&&"function"==typeof e.getHeaders&&"function"==typeof e.getBuffer},e}(),ce=function(){return ce=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ce.apply(this,arguments)},ue=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},le=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},pe="/.tencentcloudbase/wx/cloudbase_access_token",de=6e5,fe={token:"",timestamp:0};function he(){var e=$(),t=e.TRIGGER_SRC,n=e.WX_TRIGGER_API_TOKEN_V0,r=e.WX_API_TOKEN,o=e.WX_CLOUDBASE_ACCESSTOKEN,a=void 0===o?"":o,s={};return s.wxCloudApiToken="timer"===t?n||r||"":r||"",s.wxCloudApiToken||(s.wxCloudbaseAccesstoken=a||function(){if(fe.token&&Date.now()-fe.timestamp<de)return fe.token;try{if(("WX_LOCAL_SCF"===process.env.TENCENTCLOUD_RUNENV||"SCF"===process.env.TENCENTCLOUD_RUNENV)&&i.existsSync(pe))return fe.token=i.readFileSync(pe).toString(),fe.timestamp=Date.now(),fe.token}catch(e){console.warn("[TCB][ERROR]: loadWxCloudbaseAccesstoken error: ",e)}return""}()),s}var me=0;function ve(e,t,n){var r="symbol"==typeof e.env?process.env.TCB_ENV||process.env.SCF_NAMESPACE||"":e.env||"",o=e.region||process.env.TENCENTCLOUD_REGION||"",i=function(){me+=1;var e="".concat(Date.now().toString(16),"_").concat(me.toString(16)),t=$().TCB_SEQID,n=void 0===t?"":t;return n?"".concat(n,"-").concat(e):e}(),a=o?"".concat(o,".tcb-api.tencentcloudapi.com"):"tcb-api.tencentcloudapi.com",s=function(e){return/^[a-z][a-z0-9-]*[a-z0-9]$/.test(e)}(r)?"".concat(r,".").concat(a):a,c="".concat("https","://").concat(s).concat("/admin"),u=n||c,l=t?"env=".concat(r,"&seqId=").concat(i,"&scfRequestId=").concat(t.requestId):"env=".concat(r,"&seqId=").concat(i);return u.includes("?")?"".concat(u).concat(l):"".concat(u,"?").concat(l)}function ye(e){var t=$(),n=he(),r=n.wxCloudApiToken,o=n.wxCloudbaseAccesstoken;e.wxCloudApiToken=r,o&&(e.wxCloudbaseAccesstoken=o),e.tcb_sessionToken=t.TCB_SESSIONTOKEN||""}function ge(e,t,n,r){return ue(this,void 0,void 0,function(){return le(this,function(o){return ye(n),[2,e.requestInstance.send(t,n,{pathname:"web",endPointMode:"GATEWAY"},r?{timeout:r.timeout}:void 0)]})})}function be(e,t,r,o){return ue(this,void 0,Promise,function(){var i,a,s,c,u,l,p,d;return le(this,function(f){switch(f.label){case 0:ye(r);try{i=n(1191)}catch(e){throw new Error("缺少依赖 form-data,请执行 npm install form-data")}for((a=new i).append("action",t),s=0,c=Object.keys(r);s<c.length;s++)u=c[s],void 0!==r[u]&&a.append(u,r[u]);return l=ce({action:t},r),a.__plainObj=l,p=ve(e.config,e.scfContext,e.serviceUrl),[4,e.requestInstance.post({url:p,body:a,headers:a.getHeaders(),responseType:"buffer"},o?{timeout:o.timeout}:void 0)];case 1:return(d=f.sent()).data?[2,d.data]:[2,d]}})})}function xe(e,t){if(void 0===t&&(t={}),t.getCrossAccountInfo||e.getCrossAccountInfo)throw D(ce(ce({},s.INVALID_PARAM),{message:"invalid config: getCrossAccountInfo"}))}function we(e,t,n,r){return{requestInstance:r,config:e,scfContext:t,serviceUrl:n}}function _e(e,t,n){var r=t.apiName,o=t.apiOptions,i=t.cgiName,a=t.requestData;return ue(this,void 0,void 0,function(){var t,c,u;return le(this,function(l){switch(l.label){case 0:try{t=a?JSON.stringify(a):""}catch(e){throw D(ce(ce({},e),{code:s.INVALID_PARAM.code,message:"对象出现了循环引用"}))}return xe(e.config,n),[4,ge(e,"wx.api",{apiName:r,apiOptions:o,cgiName:i,requestData:t},n)];case 1:if((c=l.sent()).code)return[2,c];try{u=JSON.parse(c.responseData)}catch(e){u=c.responseData}return[2,{result:u,requestId:c.requestId}]}})})}function Ie(e,t,n,r){var o=n.apiName,i=n.apiOptions,a=n.cgiName,s=n.requestData;return ue(this,void 0,void 0,function(){return le(this,function(n){return xe(t.config,r),[2,be(t,e,{apiName:o,apiOptions:i,cgiName:a,requestData:s},r)]})})}var Ee=function(e,t,n){return Ie("wx.openApi",e,t,n)},Se=function(e,t,n){return Ie("wx.wxPayApi",e,t,n)},Oe=function(e,t,n){return Ie("wx.wxCallContainerApi",e,t,n)},Te=function(){return Te=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Te.apply(this,arguments)},Ae=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},Pe=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},Re=null;function Ce(){var e;return Ae(this,void 0,void 0,function(){var t;return Pe(this,function(r){switch(r.label){case 0:if(Re)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,Promise.resolve().then(n.bind(n,9617))];case 2:return t=r.sent(),Re=(null===(e=t.default)||void 0===e?void 0:e.sign)||t.sign,[3,4];case 3:return r.sent(),console.error("缺少依赖 jsonwebtoken,请执行以下命令安装:\n\n npm install jsonwebtoken\n\n该依赖用于 Node 环境下的自定义登录票据生成。"),[3,4];case 4:return[2,Re]}})})}function Ne(){var e=$();return{openId:e.WX_OPENID||"",appId:e.WX_APPID||"",uid:e.TCB_UUID||"",customUserId:e.TCB_CUSTOM_USER_ID||"",isAnonymous:"true"===e.TCB_ISANONYMOUS_USER}}function ke(e,t){var n,r;return null===(r=null===(n=null==e?void 0:e.request)||void 0===n?void 0:n.send)||void 0===r?void 0:r.call(n,"auth.getUserInfoForAdmin",t,{pathname:"web",endPointMode:"CLOUD_API"})}var je=null,Ue=function(e,t){var n=t;if(e.parseContext=function(e){var t=Y(e);return je=t,t},e.getCloudbaseContext=function(e){return $(e)},e.auth){var r={getUserInfo:function(){return Ne()},getEndUserInfo:function(n){return Ae(this,void 0,Promise,function(){var r;return Pe(this,function(o){return r=Ne(),void 0===n?[2,{userInfo:r}]:(C(n),[2,ke(e,{uuid:n,envName:t.env}).then(function(e){return e.code?e:{userInfo:Te(Te({},r),e.data),requestId:e.requestId}})])})})},createTicket:function(e,n){return void 0===n&&(n={}),Ae(this,void 0,Promise,function(){var r,o,i,a,c,u,l,p,d;return Pe(this,function(f){switch(f.label){case 0:if(C(e),r=(new Date).getTime(),o=(t.auth||{}).credentials,!(i=t.env))throw Te(Te({},s.INVALID_PARAM),{message:"no env in config"});if(!(null==o?void 0:o.env_id))throw Te(Te({},s.INVALID_PARAM),{message:"当前私钥未包含env_id 信息, 请前往腾讯云云开发控制台,获取自定义登录最新私钥"});if(o.env_id!==i)throw Te(Te({},s.INVALID_PARAM),{message:"当前私钥所属环境与 init 指定环境不一致!"});return a=n.refresh,c=void 0===a?36e5:a,u=n.expire,l=void 0===u?r+6048e5:u,[4,Ce()];case 1:return p=f.sent(),d=p({alg:"RS256",env:i,iat:r,exp:r+6e5,uid:e,refresh:c,expire:l},o.private_key,{allowInsecureKeySizes:!0,algorithm:"RS256"}),[2,"".concat(o.private_key_id,"/@@/").concat(d)]}})})},queryUserInfo:function(n){return Ae(this,void 0,Promise,function(){var r,o,i;return Pe(this,function(a){return r=n.uid,o=n.platform,i=n.platformId,[2,ke(e,{uuid:r,platform:o,platformId:i,envName:t.env}).then(function(e){return e.code?e:{userInfo:Te({},e.data),requestId:e.requestId}})]})})},getClientIP:function(){return $().TCB_SOURCE_IP||""},getAuthContext:function(e){var t=$(e),n=t.TCB_UUID,r=t.LOGINTYPE,o=t.QQ_OPENID,i=t.QQ_APPID,a={uid:n,loginType:r};return"QQ-MINI"===r&&(a.appId=i,a.openId=o),a},getClientCredential:function(r){return Ae(this,void 0,void 0,function(){var o;return Pe(this,function(i){switch(i.label){case 0:return n.accessKey||t.accessKey?[2,n.accessKey||t.accessKey]:(o=e.request.getBaseEndPoint("GATEWAY"),[4,e.request.post({url:"".concat(o).concat("/auth/v1/token/clientCredential"),data:{grant_type:"client_credentials"},headers:{"content-type":"application/json"}},r?{timeout:r.timeout}:void 0)]);case 1:return[2,i.sent().data]}})})}},o=e.auth;Object.keys(r).forEach(function(e){o[e]=r[e]}),e.auth=new Proxy(o,{apply:function(e,t,n){var o=Reflect.apply(e,t,n);return o&&"object"==typeof o&&Object.keys(r).forEach(function(e){e in o||(o[e]=r[e])}),o}})}function i(){var t=n.serviceUrl||X()||void 0;return we(n,je,t||"",e.request)}e.sendTemplateNotification=function(t,n){var r;return null===(r=null==e?void 0:e.callFunction)||void 0===r?void 0:r.call(e,{name:"lowcode-datasource",data:{methodName:"callWedaApi",params:{action:"PushNotifyMsg",data:{NotifyId:t.notifyId,Data:JSON.stringify(t.data),NotifyUsers:void 0,Url:t.url}},mode:"c"}},void 0,n)},e.callWxOpenApi=function(e,t){return _e(i(),e,t)},e.callWxPayApi=function(e,t){return Se(i(),e,t)},e.wxCallContainerApi=function(e,t){return Oe(i(),e,t)},e.callCompatibleWxOpenApi=function(e,t){return Ee(i(),e,t)},e.getFileAuthority=function(t,n){var r=t.fileList;return Ae(void 0,void 0,void 0,function(){var t,o,i,a,c,u;return Pe(this,function(l){switch(l.label){case 0:if(t=$().LOGINTYPE,!Array.isArray(r))throw D(Te(Te({},s.INVALID_PARAM),{message:"[js-sdk] getCosFileAuthority fileList must be a array"}));if(r.some(function(e){return!(null==e?void 0:e.path)||!["READ","WRITE","READWRITE"].includes(e.type)}))throw D(Te(Te({},s.INVALID_PARAM),{message:"[js-sdk] getCosFileAuthority fileList param error"}));return[4,e.auth.getEndUserInfo()];case 1:if(o=l.sent().userInfo,i=o.openId,a=o.uid,!i&&!a)throw D(Te(Te({},s.INVALID_PARAM),{message:"[js-sdk] admin do not need getCosFileAuthority."}));return c={openId:i,uid:a,loginType:t,fileList:r},[4,e.request.send("storage.getFileAuthority",c,{pathname:"web",endPointMode:"GATEWAY"},n?{timeout:n.timeout}:void 0)];case 2:if((u=l.sent()).code)throw D(Te(Te({},u),{message:"[js-sdk] getCosFileAuthority failed: ".concat(u.code)}));return[2,u]}})})},e.callApis=function(t,n){return Ae(void 0,void 0,void 0,function(){var r,o,i,a,s,c,u,l,p,d,f,h;return Pe(this,function(m){if(e.apis)return r=t.name,o=t.path,i=void 0===o?"":o,a=t.method,s=void 0===a?"POST":a,c=t.header,u=void 0===c?{}:c,l=t.body,p=t.token,d=(s||"POST").toLowerCase(),[2,null===(h=null===(f=e.apis[r])||void 0===f?void 0:f[d])||void 0===h?void 0:h.call(f,{path:i,method:s,headers:u,body:l,token:p},n)];throw new Error("callApis is not supported in current configuration")})})}},Le=function(){return Le=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Le.apply(this,arguments)},De=null;function qe(){if(!De)try{De=n(9814)}catch(e){console.error("缺少依赖 ws,请执行以下命令安装:\n\n npm install ws\n\n该依赖用于 Node 环境下的 WebSocket 连接。")}return De}var Me,Fe=(Me=new Map,{mode:"sync",setItem:function(e,t){Me.set(e,t)},getItem:function(e){return Me.get(e)},removeItem:function(e){Me.delete(e)},clear:function(){Me.clear()}});const Be={genAdapter:function(e){return{nodeTool:Ue,getSecretInfo:ee,root:{globalThis:{}},reqClass:se,wsClass:qe(),sessionStorage:Fe,localStorage:Fe,primaryStorage:o.StorageType.session,captchaOptions:{openURIWithCallback:function(t){var n=e.EventBus,r={},o=t,i=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(i){o=i[1];var a=i[2];a&&(r=j(a))}var s=r.token,c=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(r,["token"]);return/^data:/.test(o)&&!s?Promise.reject({error:"invalid_argument",error_description:"invalie captcha data: ".concat(t)}):s?new Promise(function(e){n.$emit("CAPTCHA_DATA_CHANGE",Le(Le({},c),{token:s,url:o})),n.$once("RESOLVE_CAPTCHA_DATA",function(t){e(t)})}):Promise.reject({error:"unimplemented",error_description:"need to impl captcha data"})}}}},isMatch:function(){return"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node},runtime:"node-adapter"}},3171:(e,t,n)=>{var r;if(n.r(t),n.d(t,{getEncryptInfo:()=>q}),!globalThis.IS_MP_BUILD){var o="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis;function M(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function F(e,t){return e&t}function B(e,t){return e|t}function W(e,t){return e^t}function V(e,t){return e&~t}function G(e){if(0==e)return-1;var t=0;return 65535&e||(e>>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function H(e){for(var t=0;0!=e;)e&=e-1,++t;return t}var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function z(e){var t,n,r="";for(t=0;t+3<=e.length;t+=3)n=parseInt(e.substring(t,t+3),16),r+=i.charAt(n>>6)+i.charAt(63&n);for(t+1==e.length?(n=parseInt(e.substring(t,t+1),16),r+=i.charAt(n<<2)):t+2==e.length&&(n=parseInt(e.substring(t,t+2),16),r+=i.charAt(n>>2)+i.charAt((3&n)<<4));(3&r.length)>0;)r+="=";return r}function K(e){var t,n="",r=0,o=0;for(t=0;t<e.length&&"="!=e.charAt(t);++t){var a=i.indexOf(e.charAt(t));a<0||(0==r?(n+=M(a>>2),o=3&a,r=1):1==r?(n+=M(o<<2|a>>4),o=15&a,r=2):2==r?(n+=M(o),n+=M(a>>2),o=3&a,r=3):(n+=M(o<<2|a>>4),n+=M(15&a),r=0))}return 1==r&&(n+=M(o<<2)),n}var a,s,c={decode:function(e){var t;if(void 0===a){var n="0123456789ABCDEF";for(a={},t=0;t<16;++t)a[n.charAt(t)]=t;for(n=n.toLowerCase(),t=10;t<16;++t)a[n.charAt(t)]=t;for(t=0;t<8;++t)a[" \f\n\r\t \u2028\u2029".charAt(t)]=-1}var r=[],o=0,i=0;for(t=0;t<e.length;++t){var s=e.charAt(t);if("="==s)break;if(-1!=(s=a[s])){if(void 0===s)throw new Error("Illegal character at offset "+t);o|=s,++i>=2?(r[r.length]=o,o=0,i=0):o<<=4}}if(i)throw new Error("Hex encoding incomplete: 4 bits missing");return r}},u={decode:function(e){var t;if(void 0===s){for(s=Object.create(null),t=0;t<64;++t)s["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t)]=t;for(t=0;t<9;++t)s["= \f\n\r\t \u2028\u2029".charAt(t)]=-1}var n=[],r=0,o=0;for(t=0;t<e.length;++t){var i=e.charAt(t);if("="==i)break;if(-1!=(i=s[i])){if(void 0===i)throw new Error("Illegal character at offset "+t);r|=i,++o>=4?(n[n.length]=r>>16,n[n.length]=r>>8&255,n[n.length]=255&r,r=0,o=0):r<<=6}}switch(o){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:n[n.length]=r>>10;break;case 3:n[n.length]=r>>16,n[n.length]=r>>8&255}return n},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(e){var t=u.re.exec(e);if(t)if(t[1])e=t[1];else{if(!t[2])throw new Error("RegExp out of sync");e=t[2]}return u.decode(e)}},l=1e13;class J{constructor(e){this.buf=[+e||0]}mulAdd(e,t){var n,r,o=this.buf,i=o.length;for(n=0;n<i;++n)(r=o[n]*e+t)<l?t=0:r-=(t=0|r/l)*l,o[n]=r;t>0&&(o[n]=t)}sub(e){var t,n,r=this.buf,o=r.length;for(t=0;t<o;++t)(n=r[t]-e)<0?(n+=l,e=1):e=0,r[t]=n;for(;0===r[r.length-1];)r.pop()}toString(e){if(10!=(e||10))throw new Error("only base 10 is supported");for(var t=this.buf,n=t[t.length-1].toString(),r=t.length-2;r>=0;--r)n+=(l+t[r]).toString().substring(1);return n}valueOf(){for(var e=this.buf,t=0,n=e.length-1;n>=0;--n)t=t*l+e[n];return t}simplify(){var e=this.buf;return 1==e.length?e[0]:this}}var p,d=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,f=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function Y(e,t){return e.length>t&&(e=e.substring(0,t)+"…"),e}class ${constructor(e,t){this.hexDigits="0123456789ABCDEF",e instanceof $?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=t)}get(e){if(void 0===e&&(e=this.pos++),e>=this.enc.length)throw new Error("Requesting byte offset "+e+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(e):this.enc[e]}hexByte(e){return this.hexDigits.charAt(e>>4&15)+this.hexDigits.charAt(15&e)}hexDump(e,t,n){for(var r="",o=e;o<t;++o)if(r+=this.hexByte(this.get(o)),!0!==n)switch(15&o){case 7:r+=" ";break;case 15:r+="\n";break;default:r+=" "}return r}isASCII(e,t){for(var n=e;n<t;++n){var r=this.get(n);if(r<32||r>176)return!1}return!0}parseStringISO(e,t){for(var n="",r=e;r<t;++r)n+=String.fromCharCode(this.get(r));return n}parseStringUTF(e,t){for(var n="",r=e;r<t;){var o=this.get(r++);n+=o<128?String.fromCharCode(o):o>191&&o<224?String.fromCharCode((31&o)<<6|63&this.get(r++)):String.fromCharCode((15&o)<<12|(63&this.get(r++))<<6|63&this.get(r++))}return n}parseStringBMP(e,t){for(var n,r,o="",i=e;i<t;)n=this.get(i++),r=this.get(i++),o+=String.fromCharCode(n<<8|r);return o}parseTime(e,t,n){var r=this.parseStringISO(e,t),o=(n?d:f).exec(r);return o?(n&&(o[1]=+o[1],o[1]+=+o[1]<70?2e3:1900),r=o[1]+"-"+o[2]+"-"+o[3]+" "+o[4],o[5]&&(r+=":"+o[5],o[6]&&(r+=":"+o[6],o[7]&&(r+="."+o[7]))),o[8]&&(r+=" UTC","Z"!=o[8]&&(r+=o[8],o[9]&&(r+=":"+o[9]))),r):"Unrecognized time: "+r}parseInteger(e,t){for(var n,r=this.get(e),o=r>127,i=o?255:0,a="";r==i&&++e<t;)r=this.get(e);if(0===(n=t-e))return o?-1:0;if(n>4){for(a=r,n<<=3;!(128&(+a^i));)a=+a<<1,--n;a="("+n+" bit)\n"}o&&(r-=256);for(var s=new J(r),c=e+1;c<t;++c)s.mulAdd(256,this.get(c));return a+s.toString()}parseBitString(e,t,n){for(var r=this.get(e),o="("+((t-e-1<<3)-r)+" bit)\n",i="",a=e+1;a<t;++a){for(var s=this.get(a),c=a==t-1?r:0,u=7;u>=c;--u)i+=s>>u&1?"1":"0";if(i.length>n)return o+Y(i,n)}return o+i}parseOctetString(e,t,n){if(this.isASCII(e,t))return Y(this.parseStringISO(e,t),n);var r=t-e,o="("+r+" byte)\n";r>(n/=2)&&(t=e+n);for(var i=e;i<t;++i)o+=this.hexByte(this.get(i));return r>n&&(o+="…"),o}parseOID(e,t,n){for(var r="",o=new J,i=0,a=e;a<t;++a){var s=this.get(a);if(o.mulAdd(128,127&s),i+=7,!(128&s)){if(""===r)if((o=o.simplify())instanceof J)o.sub(80),r="2."+o.toString();else{var c=o<80?o<40?0:1:2;r=c+"."+(o-40*c)}else r+="."+o.toString();if(r.length>n)return Y(r,n);o=new J,i=0}}return i>0&&(r+=".incomplete"),r}}class Q{constructor(e,t,n,r,o){if(!(r instanceof X))throw new Error("Invalid tag value.");this.stream=e,this.header=t,this.length=n,this.tag=r,this.sub=o}typeName(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}}content(e){if(void 0===this.tag)return null;void 0===e&&(e=1/0);var t=this.posContent(),n=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+n,e);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(t)?"false":"true";case 2:return this.stream.parseInteger(t,t+n);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(t,t+n,e);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+n,e);case 6:return this.stream.parseOID(t,t+n,e);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return Y(this.stream.parseStringUTF(t,t+n),e);case 18:case 19:case 20:case 21:case 22:case 26:return Y(this.stream.parseStringISO(t,t+n),e);case 30:return Y(this.stream.parseStringBMP(t,t+n),e);case 23:case 24:return this.stream.parseTime(t,t+n,23==this.tag.tagNumber)}return null}toString(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"}toPrettyString(e){void 0===e&&(e="");var t=e+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(t+="+"),t+=this.length,this.tag.tagConstructed?t+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(t+=" (encapsulates)"),t+="\n",null!==this.sub){e+=" ";for(var n=0,r=this.sub.length;n<r;++n)t+=this.sub[n].toPrettyString(e)}return t}posStart(){return this.stream.pos}posContent(){return this.stream.pos+this.header}posEnd(){return this.stream.pos+this.header+Math.abs(this.length)}toHexString(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)}static decodeLength(e){var t=e.get