@cloudbase/js-sdk
Version:
cloudbase javascript sdk
2 lines • 282 kB
JavaScript
/*! For license information please see index.node.js.LICENSE.txt */
(()=>{var e,a,n={9954:(e,a,n)=>{e.exports={parallel:n(8197),serial:n(8967),serialOrdered:n(982)}},190:e=>{function a(e){"function"==typeof this.jobs[e]&&this.jobs[e]()}e.exports=function(e){Object.keys(e.jobs).forEach(a.bind(e)),e.jobs={}}},1307:(e,a,n)=>{var i=n(8765);e.exports=function(e){var a=!1;return i(function(){a=!0}),function(n,t){a?e(n,t):i(function(){e(n,t)})}}},8765:e=>{e.exports=function(e){var a="function"==typeof setImmediate?setImmediate:"object"==typeof process&&"function"==typeof process.nextTick?process.nextTick:null;a?a(e):setTimeout(e,0)}},5798:(e,a,n)=>{var i=n(1307),t=n(190);e.exports=function(e,a,n,o){var s=n.keyedList?n.keyedList[n.index]:n.index;n.jobs[s]=function(e,a,n,t){return 2==e.length?e(n,i(t)):e(n,a,i(t))}(a,s,e[s],function(e,a){s in n.jobs&&(delete n.jobs[s],e?t(n):n.results[s]=a,o(e,n.results))})}},7379:e=>{e.exports=function(e,a){var n=!Array.isArray(e),i={index:0,keyedList:n||a?Object.keys(e):null,jobs:{},results:n?{}:[],size:n?Object.keys(e).length:e.length};return a&&i.keyedList.sort(n?a:function(n,i){return a(e[n],e[i])}),i}},3797:(e,a,n)=>{var i=n(190),t=n(1307);e.exports=function(e){Object.keys(this.jobs).length&&(this.index=this.size,i(this),t(e)(null,this.results))}},8197:(e,a,n)=>{var i=n(5798),t=n(7379),o=n(3797);e.exports=function(e,a,n){for(var s=t(e);s.index<(s.keyedList||e).length;)i(e,a,s,function(e,a){e?n(e,a):0!==Object.keys(s.jobs).length||n(null,s.results)}),s.index++;return o.bind(s,n)}},8967:(e,a,n)=>{var i=n(982);e.exports=function(e,a,n){return i(e,a,null,n)}},982:(e,a,n)=>{var i=n(5798),t=n(7379),o=n(3797);function s(e,a){return e<a?-1:e>a?1:0}e.exports=function(e,a,n,s){var r=t(e,n);return i(e,a,r,function n(t,o){t?s(t,o):(r.index++,r.index<(r.keyedList||e).length?i(e,a,r,n):s(null,r.results))}),o.bind(r,s)},e.exports.ascending=s,e.exports.descending=function(e,a){return-1*s(e,a)}},7922:function(e,a,n){"use strict";var i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var a,n=1,i=arguments.length;n<i;n++)for(var t in a=arguments[n])Object.prototype.hasOwnProperty.call(a,t)&&(e[t]=a[t]);return e},i.apply(this,arguments)};Object.defineProperty(a,"__esModule",{value:!0}),a.OAUTH2_LOGINTYPE_PREFIX=a.LOGINTYPE=a.getBaseEndPoint=a.setRegionLevelEndpoint=a.setGatewayEndPointWithEnv=a.getEndPointInfo=a.setEndPointInfo=a.DEFAULT_PROTOCOL=a.DATA_VERSION=a.getSdkName=a.setSdkName=a.getSdkVersion=a.setSdkVersion=void 0;var t=n(2877),o=t.constants.setSdkName,s=t.constants.setProtocol,r="",c="@cloudbase/js-sdk";a.setSdkVersion=function(e){r=e},a.getSdkVersion=function(){return r},a.setSdkName=function(e){c=e,o(e)},a.getSdkName=function(){return c},a.DATA_VERSION="2020-01-10";var p,l=[],u=["env","endPointKey","region"];function d(e){return l.find(function(a){return u.filter(function(a){return null!=e[a]}).every(function(n){return a[n]===e[n]})})}function m(e){var n,t;e.protocol&&!/:$/.test(e.protocol)&&(e.protocol="".concat(e.protocol,":"));var o=d(e);o?(null!=e.baseUrl&&(o.baseUrl=e.baseUrl),null!=e.protocol&&(o.protocol=e.protocol)):l.push(i(i({},e),{protocol:null!==(n=e.protocol)&&void 0!==n?n:a.DEFAULT_PROTOCOL})),"CLOUD_API"===e.endPointKey&&s(null!==(t=e.protocol)&&void 0!==t?t:a.DEFAULT_PROTOCOL)}function f(e,a,n){return d({env:e,endPointKey:a,region:n})}a.DEFAULT_PROTOCOL="https:",a.setEndPointInfo=m,a.getEndPointInfo=f,a.setGatewayEndPointWithEnv=function(e,a,n){var i="//".concat(e,".api.tcloudbasegateway.com/v1");n&&(i="//".concat(e,".api.intl.tcloudbasegateway.com/v1")),m({endPointKey:"GATEWAY",env:e,baseUrl:i,protocol:a})},a.setRegionLevelEndpoint=function(e,a,n){m({env:e,region:a,baseUrl:"//".concat(e,".").concat(a||"ap-shanghai",".tcb-api.tencentcloudapi.com/web"),protocol:n,endPointKey:"CLOUD_API"})},a.getBaseEndPoint=function(e,a){void 0===a&&(a="CLOUD_API");var n=f(e,a||"CLOUD_API"),i=n.protocol,t=n.baseUrl;return"".concat(i).concat(t).match(/(http(s)?:)?\/\/([^/?#]*)/)[0]},(p=a.LOGINTYPE||(a.LOGINTYPE={})).NULL="NULL",p.ANONYMOUS="ANONYMOUS",p.WECHAT="WECHAT",p.WECHAT_PUBLIC="WECHAT-PUBLIC",p.WECHAT_OPEN="WECHAT-OPEN",p.CUSTOM="CUSTOM",p.EMAIL="EMAIL",p.USERNAME="USERNAME",p.PHONE="PHONE",a.OAUTH2_LOGINTYPE_PREFIX="OAUTH2"},6950:function(e,a,n){"use strict";var i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var a,n=1,i=arguments.length;n<i;n++)for(var t in a=arguments[n])Object.prototype.hasOwnProperty.call(a,t)&&(e[t]=a[t]);return e},i.apply(this,arguments)},t=this&&this.__decorate||function(e,a,n,i){var t,o=arguments.length,s=o<3?a:null===i?i=Object.getOwnPropertyDescriptor(a,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,a,n,i);else for(var r=e.length-1;r>=0;r--)(t=e[r])&&(s=(o<3?t(s):o>3?t(a,n,s):t(a,n))||s);return o>3&&s&&Object.defineProperty(a,n,s),s},o=this&&this.__metadata||function(e,a){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,a)},s=this&&this.__awaiter||function(e,a,n,i){return new(n||(n=Promise))(function(t,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function r(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var a;e.done?t(e.value):(a=e.value,a instanceof n?a:new n(function(e){e(a)})).then(s,r)}c((i=i.apply(e,a||[])).next())})},r=this&&this.__generator||function(e,a){var n,i,t,o,s={label:0,sent:function(){if(1&t[0])throw t[1];return t[1]},trys:[],ops:[]};return o={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function r(r){return function(c){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,r[0]&&(s=0)),s;)try{if(n=1,i&&(t=2&r[0]?i.return:r[0]?i.throw||((t=i.return)&&t.call(i),0):i.next)&&!(t=t.call(i,r[1])).done)return t;switch(i=0,t&&(r=[2&r[0],t.value]),r[0]){case 0:case 1:t=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,i=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!((t=(t=s.trys).length>0&&t[t.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!t||r[1]>t[0]&&r[1]<t[3])){s.label=r[1];break}if(6===r[0]&&s.label<t[1]){s.label=t[1],t=r;break}if(t&&s.label<t[2]){s.label=t[2],s.ops.push(r);break}t[2]&&s.ops.pop(),s.trys.pop();continue}r=a.call(e,s)}catch(e){r=[6,e],i=0}finally{n=t=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,c])}}};Object.defineProperty(a,"__esModule",{value:!0}),a.cloudbase=a.LANGS=a.getBaseEndPoint=void 0;var c=n(2877),p=n(4276),l=n(1985),u=n(6938),d=n(901),m=n(7922),f=n(3509),v=n(7922);Object.defineProperty(a,"getBaseEndPoint",{enumerable:!0,get:function(){return v.getBaseEndPoint}});var x=n(3509);Object.defineProperty(a,"LANGS",{enumerable:!0,get:function(){return x.LANGS}});var h=c.adapters.useAdapters,b=c.adapters.useDefaultAdapter,g=c.constants.ERRORS,y=c.constants.COMMUNITY_SITE_URL,w=c.utils.printWarn,_=c.helpers.catchErrorsDecorator,E={persistence:"local"},O=6e5,j={},k=function(){function e(e){this.cloudbaseConfig=e||this.cloudbaseConfig,this.authInstance=null,this.oauthInstance=null,this.version=(0,m.getSdkVersion)()}return Object.defineProperty(e.prototype,"config",{get:function(){return this.cloudbaseConfig},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"platform",{get:function(){return l.Platform},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cache",{get:function(){return(0,u.getCacheByEnvId)(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localCache",{get:function(){return(0,u.getLocalCache)(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){return(0,d.getRequestByEnvId)(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),e.prototype.init=function(a){var n,t,o;if(void 0===a&&(a={env:""}),a.endPointMode=a.endPointMode||"GATEWAY",l.Platform.adapter||this.useDefaultAdapter(),!(a=this.dealNodeAdapterConfig(a)).env)throw new Error(JSON.stringify({code:g.INVALID_PARAMS,msg:"env must not be specified"}));this.isInitialized(a);var s=this.isNodeEnv()?void 0:15e3,r=a.timeout||s,c={timeout:r,timeoutMsg:r?"[".concat((0,m.getSdkName)(),"][REQUEST TIMEOUT] request had been abort since didn't finished within").concat(r/1e3,"s"):void 0,auth:a.auth};this.requestClient=new l.Platform.adapter.reqClass(c),this.cloudbaseConfig=i(i(i({},E),a),{timeout:r,i18n:(0,f.i18nProxy)(l.Platform,a)}),delete this.cloudbaseConfig.lang,this.cloudbaseConfig.timeout=this.formatTimeout(this.cloudbaseConfig.timeout);var p=this.cloudbaseConfig,v=p.env,x=p.persistence,h=p.debug,b=p.timeout,y=p.oauthClient,w=p.i18n;(0,u.initCache)({env:v,persistence:x,debug:h,platformInfo:this.platform}),(0,m.setRegionLevelEndpoint)(v,a.region||""),(0,m.setGatewayEndPointWithEnv)(v,m.DEFAULT_PROTOCOL,a.intl);var _=new e(this.cloudbaseConfig);return(0,d.initRequest)({env:v,region:a.region||"",timeout:b,oauthClient:y,_fromApp:_,i18n:w,endPointMode:a.endPointMode,auth:a.auth}),_.requestClient=this.requestClient,null===(n=null==this?void 0:this.fire)||void 0===n||n.call(this,"cloudbase_init",_),this.try2InitAuth(_),(null===(t=l.Platform.adapter)||void 0===t?void 0:t.nodeTool)&&(null===(o=l.Platform.adapter)||void 0===o||o.nodeTool(_,this.cloudbaseConfig)),_},e.prototype.updateConfig=function(e){var a=e.persistence,n=e.debug;this.cloudbaseConfig.persistence=a,this.cloudbaseConfig.debug=n,(0,u.initCache)({env:this.cloudbaseConfig.env,persistence:a,debug:n,platformInfo:this.platform})},e.prototype.updateLang=function(e){var a;e&&e!==(null===(a=this.cloudbaseConfig.i18n)||void 0===a?void 0:a.lang)&&(this.cloudbaseConfig.i18n.lang=e)},e.prototype.registerExtension=function(e){j[e.name]=e},e.prototype.invokeExtension=function(e,a){return s(this,void 0,void 0,function(){var n;return r(this,function(i){switch(i.label){case 0:if(!(n=j[e]))throw new Error(JSON.stringify({code:g.INVALID_PARAMS,msg:"extension:".concat(e," must be registered before invoke")}));return[4,n.invoke(a,this)];case 1:return[2,i.sent()]}})})},e.prototype.useAdapters=function(e,a){var n=h(e,a)||{},i=n.adapter,t=n.runtime;i&&(l.Platform.adapter=i),t&&(l.Platform.runtime=t)},e.prototype.registerHook=function(a){(0,p.registerHook)(e,a)},e.prototype.registerComponent=function(a){(0,p.registerComponent)(e,a)},e.prototype.registerVersion=function(e){(0,m.setSdkVersion)(e),this.version=e},e.prototype.registerSdkName=function(e){(0,m.setSdkName)(e)},e.prototype.isInitialized=function(e){return void 0===e&&(e=this.cloudbaseConfig),"string"==typeof e.env&&["your-env-id","your-envid","your_env_id","xxx-yyy","xxxx-yyy","envId","env-id","your-environment-id","REPLACE_ME"].some(function(a){return e.env.toLowerCase()===a.toLowerCase()})&&w(g.INVALID_PARAMS,'[CloudBase] 检测到环境 ID "'.concat(e.env,'" 可能是占位符,请替换为真实的环境 ID。\n')+" 获取方式:登录腾讯云开发平台 → 环境管理 → 环境设置 → 环境 ID\n 建议通过环境变量配置:process.env.CLOUDBASE_ENV 或 import.meta.env.VITE_CLOUDBASE_ENV"),!!(null==e?void 0:e.env)},e.prototype.registerEndPoint=function(e,a){(0,m.setEndPointInfo)({baseUrl:e,protocol:a,env:this.config.env,endPointKey:"CLOUD_API"})},e.prototype.registerEndPointWithKey=function(e){(0,m.setEndPointInfo)({env:this.config.env,endPointKey:e.key,baseUrl:e.url,protocol:e.protocol})},e.prototype.registerHost=function(e,a){void 0===a&&(a="http");var n=e.replace(/^(https?:)?\/\//,""),i="//".concat(n);(0,m.setEndPointInfo)({baseUrl:"".concat(i,"/web"),protocol:a,env:this.config.env,endPointKey:"CLOUD_API"}),(0,m.setEndPointInfo)({baseUrl:"".concat(i,"/v1"),protocol:a,env:this.config.env,endPointKey:"GATEWAY"})},e.prototype.getEndPointWithKey=function(e){var a=(0,m.getEndPointInfo)(this.config.env,e);return{BASE_URL:a.baseUrl,PROTOCOL:a.protocol}},e.prototype.parseCaptcha=function(e){return c.utils.parseCaptcha(e)},e.prototype.useDefaultAdapter=function(){var e=b.bind(this)(),a=e.adapter,n=e.runtime;l.Platform.adapter=a,l.Platform.runtime=n},e.prototype.isNodeEnv=function(){var e;return"undefined"!=typeof process&&void 0!==process.env&&!!(null===(e=l.Platform.adapter)||void 0===e?void 0:e.getSecretInfo)},e.prototype.formatTimeout=function(e){if(null==e)return e;switch(!0){case e>O:return w(g.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),O;case e<100:return w(g.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return e}},e.prototype.try2InitAuth=function(e){try{e.auth()}catch(e){console.log("try2InitAuth error:",e)}},e.prototype.dealNodeAdapterConfig=function(e){var a,n;if(this.isNodeEnv()){var t=null===(a=l.Platform.adapter)||void 0===a?void 0:a.getSecretInfo(e);e.auth=i(i({},e.auth),{secretId:t.secretId,secretKey:t.secretKey,sessionToken:t.sessionToken,secretType:t.secretType,credentials:t.credentials||(null===(n=e.auth)||void 0===n?void 0:n.credentials)||void 0}),e.env&&"symbol"!=typeof e.env||(e.env=t.env),!e.accessKey&&t.accessKey&&(e.accessKey=t.accessKey)}return e},t([_({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv3/adapter#%E7%AC%AC-2-%E6%AD%A5%E9%85%8D%E7%BD%AE%E5%AE%89%E5%85%A8%E5%BA%94%E7%94%A8%E6%9D%A5%E6%BA%90)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(y)]}),o("design:type",Function),o("design:paramtypes",[Object]),o("design:returntype",e)],e.prototype,"init",null),t([_({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(y)]}),o("design:type",Function),o("design:paramtypes",[String,Object]),o("design:returntype",Promise)],e.prototype,"invokeExtension",null),e}();a.cloudbase=new k;var A=(0,l.getWxDefaultAdapter)();A&&a.cloudbase.useAdapters(A),a.default=a.cloudbase},1197:(e,a)=>{"use strict";var n;Object.defineProperty(a,"__esModule",{value:!0}),a.SECRET_TYPE=a.checkCustomUserIdRegex=a.CLIENT_AUTH_PATH=a.ADMIN_PATH=a.ERROR=void 0,a.ERROR={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参数"}},a.ADMIN_PATH="/admin",a.CLIENT_AUTH_PATH="/auth/v1/token/clientCredential",a.checkCustomUserIdRegex=/^[a-zA-Z0-9_\-#@~=*(){}[\]:.,<>+]{4,32}$/,(n=a.SECRET_TYPE||(a.SECRET_TYPE={})).SECRET="SECRET",n.SESSION_SECRET="SESSION_SECRET"},9094:function(e,a,n){"use strict";var i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var a,n=1,i=arguments.length;n<i;n++)for(var t in a=arguments[n])Object.prototype.hasOwnProperty.call(a,t)&&(e[t]=a[t]);return e},i.apply(this,arguments)};Object.defineProperty(a,"__esModule",{value:!0}),a.getSecretInfo=a.INIT_CONFIG=a.getServerInjectUrl=a.getTcbContextConfig=a.getCloudbaseContext=a.parseContext=void 0;var t=n(1197),o=n(4353);function s(e){if("object"!=typeof e)throw i(i({},t.ERROR.INVALID_CONTEXT),{message:"context 必须为对象类型"});var a={},n=e.memory_limit_in_mb,o=e.time_limit_in_ms,s=e.request_id,r=e.function_version,c=e.namespace,p=e.function_name,l=e.environ,u=e.environment;try{if(a.memoryLimitInMb=n,a.timeLimitIns=o,a.requestId=s,a.functionVersion=r,a.namespace=c,a.functionName=p,u)a.environment=JSON.parse(u);else{var d=null==l?void 0:l.split(";"),m={};for(var f in d)if(d[f].includes("=")){var v=d[f].indexOf("="),x=d[f].slice(0,v),h=d[f].slice(v+1);h.indexOf(",")>=0&&(h=h.split(",")),m[x]=h}a.environ=m}}catch(e){throw i({},t.ERROR.INVALID_CONTEXT)}return a}function r(){try{var e=(0,a.getCloudbaseContext)().TCB_CONTEXT_CNFG;return e?JSON.parse(e):{}}catch(e){return console.error("[TCB][ERROR] parse context error: ",e),{}}}a.parseContext=s,a.getCloudbaseContext=function(e){(0,o.checkIsInScf)()&&((0,o.getEnv)("TENCENTCLOUD_REGION")||console.error("[TCB][ERROR] missing `TENCENTCLOUD_REGION` environment"),(0,o.getEnv)("SCF_NAMESPACE")||console.error("[TCB][ERROR] missing `SCF_NAMESPACE` environment"));var a=(0,o.getEnv)(),n={TRIGGER_SRC:a.TRIGGER_SRC,_SCF_TCB_LOG:a._SCF_TCB_LOG,SCF_NAMESPACE:a.SCF_NAMESPACE,TENCENTCLOUD_RUNENV:a.TENCENTCLOUD_RUNENV,TENCENTCLOUD_SECRETID:a.TENCENTCLOUD_SECRETID,TENCENTCLOUD_SECRETKEY:a.TENCENTCLOUD_SECRETKEY,TENCENTCLOUD_SESSIONTOKEN:a.TENCENTCLOUD_SESSIONTOKEN,WX_CONTEXT_KEYS:a.WX_CONTEXT_KEYS,WX_TRIGGER_API_TOKEN_V0:a.WX_TRIGGER_API_TOKEN_V0,WX_CLIENTIP:a.WX_CLIENTIP,WX_CLIENTIPV6:a.WX_CLIENTIPV6,TCB_CONTEXT_KEYS:a.TCB_CONTEXT_KEYS,TCB_CONTEXT_CNFG:a.TCB_CONTEXT_CNFG,LOGINTYPE:a.LOGINTYPE,CLOUDBASE_APIKEY:a.CLOUDBASE_APIKEY},t={};if(e){var r=s(e),c=r.environment,p=r.environ;t=c||p||{}}for(var l=0,u=[t.TCB_CONTEXT_KEYS||a.TCB_CONTEXT_KEYS,t.WX_CONTEXT_KEYS||a.WX_CONTEXT_KEYS];l<u.length;l++){var d=u[l];if(d)try{for(var m=0,f=d.split(",");m<f.length;m++){var v=f[m];n[v]=t[v]||(0,o.getEnv)(v)}}catch(e){}}var x=i(i({},n),t);return Object.fromEntries(Object.entries(x).filter(function(e){return void 0!==e[1]}))},a.getTcbContextConfig=r,a.getServerInjectUrl=function(){return r().URL||""},a.INIT_CONFIG={},a.getSecretInfo=function(e){var n,o,s,r,c,p,l;a.INIT_CONFIG=JSON.parse(JSON.stringify(e||a.INIT_CONFIG));var u=(0,a.getCloudbaseContext)(),d=u.TCB_ENV,m=u.SCF_NAMESPACE,f=u.TENCENTCLOUD_RUNENV,v=u.TENCENTCLOUD_SECRETID,x=u.TENCENTCLOUD_SECRETKEY,h=u.TENCENTCLOUD_SESSIONTOKEN,b=u.CLOUDBASE_APIKEY,g=i(i({},a.INIT_CONFIG),e),y="";"local"===(y="symbol"!=typeof(null==e?void 0:e.env)&&(null==e?void 0:e.env)?e.env:d||m||"")&&"WX_LOCAL_SCF"===f&&(y="");var w={env:y,secretId:"",secretKey:"",sessionToken:"",accessKey:"",secretType:"",credentials:void 0,context:void 0};if((null==g?void 0:g.context)&&(w.context=g.context),((null==g?void 0:g.credentials)||(null===(n=null==e?void 0:e.auth)||void 0===n?void 0:n.credentials))&&(w.credentials=(null==g?void 0:g.credentials)||(null===(o=null==e?void 0:e.auth)||void 0===o?void 0:o.credentials)),(null==e?void 0:e.accessKey)||(null==g?void 0:g.accessKey))return w.accessKey=(null==e?void 0:e.accessKey)||(null==g?void 0:g.accessKey),w;if((null==g?void 0:g.secretId)&&(null==g?void 0:g.secretKey))return i(i({},w),{secretId:g.secretId,secretKey:g.secretKey,sessionToken:g.sessionToken||"",secretType:g.sessionToken?t.SECRET_TYPE.SESSION_SECRET:t.SECRET_TYPE.SECRET});if((null===(s=null==e?void 0:e.auth)||void 0===s?void 0:s.secretId)&&(null===(r=null==e?void 0:e.auth)||void 0===r?void 0:r.secretKey))return i(i({},w),{secretId:e.auth.secretId,secretKey:e.auth.secretKey,sessionToken:e.auth.sessionToken||"",secretType:e.auth.secretType||t.SECRET_TYPE.SECRET});if(b)return i(i({},w),{accessKey:b});if(v&&x)return i(i({},w),{secretId:v,secretKey:x,sessionToken:h||"",secretType:t.SECRET_TYPE.SESSION_SECRET});var _=(null==g?void 0:g.context)||(null==e?void 0:e.context);if(null==_?void 0:_.extendedContext){var E=_.extendedContext;return y||(y=E.envId||""),i(i({},w),{env:y,secretId:(null===(c=null==E?void 0:E.tmpSecret)||void 0===c?void 0:c.secretId)||"",secretKey:(null===(p=null==E?void 0:E.tmpSecret)||void 0===p?void 0:p.secretKey)||"",sessionToken:(null===(l=null==E?void 0:E.tmpSecret)||void 0===l?void 0:l.token)||""})}return i({},w)}},2293:function(e,a,n){"use strict";var i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var a,n=1,i=arguments.length;n<i;n++)for(var t in a=arguments[n])Object.prototype.hasOwnProperty.call(a,t)&&(e[t]=a[t]);return e},i.apply(this,arguments)},t=this&&this.__rest||function(e,a){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&a.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var t=0;for(i=Object.getOwnPropertySymbols(e);t<i.length;t++)a.indexOf(i[t])<0&&Object.prototype.propertyIsEnumerable.call(e,i[t])&&(n[i[t]]=e[i[t]])}return n};Object.defineProperty(a,"__esModule",{value:!0}),a.getWxOptions=a.wxCallContainerApi=a.callWxPayApi=a.callCompatibleWxOpenApi=a.callWxOpenApi=a.sendWxFormDataRequest=a.sendWxRequest=a.buildAdminUrl=a.getWxCloudToken=a.getTcbContextConfig=a.getServerInjectUrl=a.getSecretInfo=a.parseContext=a.getCloudbaseContext=a.setThrowOnCode=a.processReturn=a.filterUndefined=a.filterValue=a.isPageModuleName=a.isValidEnvFormat=a.SYMBOL_DEFAULT_ENV=a.SYMBOL_CURRENT_ENV=a.TcbError=a.E=a.createWebStreamFromNodeReadableStream=a.parseQueryString=a.NodeRequest=void 0;var o=n(2764),s=n(9768),r=n(5434),c=n(9094),p=n(4353),l=null;function u(){if(!l)try{l=n(6850)}catch(e){console.error("缺少依赖 ws,请执行以下命令安装:\n\n npm install ws\n\n该依赖用于 Node 环境下的 WebSocket 连接。")}return l}var d=n(9768);Object.defineProperty(a,"NodeRequest",{enumerable:!0,get:function(){return d.NodeRequest}});var m=n(4353);Object.defineProperty(a,"parseQueryString",{enumerable:!0,get:function(){return m.parseQueryString}}),Object.defineProperty(a,"createWebStreamFromNodeReadableStream",{enumerable:!0,get:function(){return m.createWebStreamFromNodeReadableStream}}),Object.defineProperty(a,"E",{enumerable:!0,get:function(){return m.E}}),Object.defineProperty(a,"TcbError",{enumerable:!0,get:function(){return m.TcbError}}),Object.defineProperty(a,"SYMBOL_CURRENT_ENV",{enumerable:!0,get:function(){return m.SYMBOL_CURRENT_ENV}}),Object.defineProperty(a,"SYMBOL_DEFAULT_ENV",{enumerable:!0,get:function(){return m.SYMBOL_DEFAULT_ENV}}),Object.defineProperty(a,"isValidEnvFormat",{enumerable:!0,get:function(){return m.isValidEnvFormat}}),Object.defineProperty(a,"isPageModuleName",{enumerable:!0,get:function(){return m.isPageModuleName}}),Object.defineProperty(a,"filterValue",{enumerable:!0,get:function(){return m.filterValue}}),Object.defineProperty(a,"filterUndefined",{enumerable:!0,get:function(){return m.filterUndefined}}),Object.defineProperty(a,"processReturn",{enumerable:!0,get:function(){return m.processReturn}}),Object.defineProperty(a,"setThrowOnCode",{enumerable:!0,get:function(){return m.setThrowOnCode}});var f=n(9094);Object.defineProperty(a,"getCloudbaseContext",{enumerable:!0,get:function(){return f.getCloudbaseContext}}),Object.defineProperty(a,"parseContext",{enumerable:!0,get:function(){return f.parseContext}}),Object.defineProperty(a,"getSecretInfo",{enumerable:!0,get:function(){return f.getSecretInfo}}),Object.defineProperty(a,"getServerInjectUrl",{enumerable:!0,get:function(){return f.getServerInjectUrl}}),Object.defineProperty(a,"getTcbContextConfig",{enumerable:!0,get:function(){return f.getTcbContextConfig}});var v=n(6480);Object.defineProperty(a,"getWxCloudToken",{enumerable:!0,get:function(){return v.getWxCloudToken}}),Object.defineProperty(a,"buildAdminUrl",{enumerable:!0,get:function(){return v.buildAdminUrl}}),Object.defineProperty(a,"sendWxRequest",{enumerable:!0,get:function(){return v.sendWxRequest}}),Object.defineProperty(a,"sendWxFormDataRequest",{enumerable:!0,get:function(){return v.sendWxFormDataRequest}}),Object.defineProperty(a,"callWxOpenApi",{enumerable:!0,get:function(){return v.callWxOpenApi}}),Object.defineProperty(a,"callCompatibleWxOpenApi",{enumerable:!0,get:function(){return v.callCompatibleWxOpenApi}}),Object.defineProperty(a,"callWxPayApi",{enumerable:!0,get:function(){return v.callWxPayApi}}),Object.defineProperty(a,"wxCallContainerApi",{enumerable:!0,get:function(){return v.wxCallContainerApi}}),Object.defineProperty(a,"getWxOptions",{enumerable:!0,get:function(){return v.getWxOptions}});var x,h=(x=new Map,{mode:"sync",setItem:function(e,a){x.set(e,a)},getItem:function(e){return x.get(e)},removeItem:function(e){x.delete(e)},clear:function(){x.clear()}}),b={genAdapter:function(e){return{nodeTool:r.nodeTool,getSecretInfo:c.getSecretInfo,root:{globalThis:{}},reqClass:s.NodeRequest,wsClass:u(),sessionStorage:h,localStorage:h,primaryStorage:o.StorageType.session,captchaOptions:{openURIWithCallback:function(a){var n=e.EventBus,o={},s=a,r=a.match(/^(data:.*?)(\?[^#\s]*)?$/);if(r){s=r[1];var c=r[2];c&&(o=(0,p.parseQueryString)(c))}var l=o.token,u=t(o,["token"]);return/^data:/.test(s)&&!l?Promise.reject({error:"invalid_argument",error_description:"invalie captcha data: ".concat(a)}):l?new Promise(function(e){n.$emit("CAPTCHA_DATA_CHANGE",i(i({},u),{token:l,url:s})),n.$once("RESOLVE_CAPTCHA_DATA",function(a){e(a)})}):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"};a.default=b},1651:function(e,a){"use strict";var n,i=this&&this.__awaiter||function(e,a,n,i){return new(n||(n=Promise))(function(t,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function r(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var a;e.done?t(e.value):(a=e.value,a instanceof n?a:new n(function(e){e(a)})).then(s,r)}c((i=i.apply(e,a||[])).next())})},t=this&&this.__generator||function(e,a){var n,i,t,o,s={label:0,sent:function(){if(1&t[0])throw t[1];return t[1]},trys:[],ops:[]};return o={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function r(r){return function(c){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,r[0]&&(s=0)),s;)try{if(n=1,i&&(t=2&r[0]?i.return:r[0]?i.throw||((t=i.return)&&t.call(i),0):i.next)&&!(t=t.call(i,r[1])).done)return t;switch(i=0,t&&(r=[2&r[0],t.value]),r[0]){case 0:case 1:t=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,i=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!((t=(t=s.trys).length>0&&t[t.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!t||r[1]>t[0]&&r[1]<t[3])){s.label=r[1];break}if(6===r[0]&&s.label<t[1]){s.label=t[1],t=r;break}if(t&&s.label<t[2]){s.label=t[2],s.ops.push(r);break}t[2]&&s.ops.pop(),s.trys.pop();continue}r=a.call(e,s)}catch(e){r=[6,e],i=0}finally{n=t=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,c])}}};function o(e){return/^[1-9][0-9]{4,64}$/gim.test(e)}function s(e,o){return void 0===o&&(o={}),i(this,void 0,Promise,function(){var i,s,r,c;return t(this,function(t){switch(t.label){case 0:i="".concat(a.kMetadataBaseUrl,"/").concat(n.latest,"/").concat(e),s=new AbortController,o.timeout&&(r=setTimeout(function(){return s.abort()},o.timeout)),t.label=1;case 1:return t.trys.push([1,,5,6]),[4,fetch(i,{signal:s.signal})];case 2:return 200!==(c=t.sent()).status?[3,4]:[4,c.text()];case 3:return[2,t.sent()];case 4:throw new Error("[ERROR] GET ".concat(i," status: ").concat(c.status));case 5:return r&&clearTimeout(r),[7];case 6:return[2]}})})}Object.defineProperty(a,"__esModule",{value:!0}),a.lookupCredentials=a.lookupAppId=a.lookup=a.isAppId=a.kMetadataVersions=a.kSecurityCredentialsPath=a.kAppIdPath=a.kMetadataBaseUrl=void 0,a.kMetadataBaseUrl="http://metadata.tencentyun.com",a.kAppIdPath="meta-data/app-id",a.kSecurityCredentialsPath="meta-data/cam/security-credentials",function(e){e.v20170919="2017-09-19",e["v1.0"]="1.0",e.latest="latest"}(n=a.kMetadataVersions||(a.kMetadataVersions={})),a.isAppId=o,a.lookup=s;var r={appId:void 0};a.lookupAppId=function(){return i(this,void 0,Promise,function(){var e;return t(this,function(n){switch(n.label){case 0:if(void 0!==r.appId)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,s(a.kAppIdPath,{timeout:30})];case 2:return o(e=n.sent())?r.appId=e:r.appId="",[3,4];case 3:return n.sent(),[3,4];case 4:return[2,r.appId||""]}})})},a.lookupCredentials=function(e){return i(this,void 0,Promise,function(){return t(this,function(n){switch(n.label){case 0:return[4,s("".concat(a.kSecurityCredentialsPath,"/").concat(e),{timeout:200})];case 1:return[2,n.sent()]}})})}},9768:function(e,a,n){"use strict";var i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var a,n=1,i=arguments.length;n<i;n++)for(var t in a=arguments[n])Object.prototype.hasOwnProperty.call(a,t)&&(e[t]=a[t]);return e},i.apply(this,arguments)},t=this&&this.__createBinding||(Object.create?function(e,a,n,i){void 0===i&&(i=n);var t=Object.getOwnPropertyDescriptor(a,n);t&&!("get"in t?!a.__esModule:t.writable||t.configurable)||(t={enumerable:!0,get:function(){return a[n]}}),Object.defineProperty(e,i,t)}:function(e,a,n,i){void 0===i&&(i=n),e[i]=a[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,a){Object.defineProperty(e,"default",{enumerable:!0,value:a})}:function(e,a){e.default=a}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var a={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&t(a,e,n);return o(a,e),a},r=this&&this.__awaiter||function(e,a,n,i){return new(n||(n=Promise))(function(t,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function r(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var a;e.done?t(e.value):(a=e.value,a instanceof n?a:new n(function(e){e(a)})).then(s,r)}c((i=i.apply(e,a||[])).next())})},c=this&&this.__generator||function(e,a){var n,i,t,o,s={label:0,sent:function(){if(1&t[0])throw t[1];return t[1]},trys:[],ops:[]};return o={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function r(r){return function(c){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,r[0]&&(s=0)),s;)try{if(n=1,i&&(t=2&r[0]?i.return:r[0]?i.throw||((t=i.return)&&t.call(i),0):i.next)&&!(t=t.call(i,r[1])).done)return t;switch(i=0,t&&(r=[2&r[0],t.value]),r[0]){case 0:case 1:t=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,i=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!((t=(t=s.trys).length>0&&t[t.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!t||r[1]>t[0]&&r[1]<t[3])){s.label=r[1];break}if(6===r[0]&&s.label<t[1]){s.label=t[1],t=r;break}if(t&&s.label<t[2]){s.label=t[2],s.ops.push(r);break}t[2]&&s.ops.pop(),s.trys.pop();continue}r=a.call(e,s)}catch(e){r=[6,e],i=0}finally{n=t=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,c])}}};Object.defineProperty(a,"__esModule",{value:!0}),a.NodeRequest=void 0;var p=s(n(7147)),l=s(n(1017)),u=n(2764),d=n(1197),m=n(9094),f=n(4353),v=n(7922),x=null;function h(){return r(this,void 0,void 0,function(){var e;return c(this,function(a){switch(a.label){case 0:if(x)return[3,4];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,Promise.resolve().then(n.t.bind(n,2858,23))];case 2:return e=a.sent(),x=e.sign,[3,4];case 3:return a.sent(),console.error("缺少依赖 @cloudbase/signature-nodejs,请执行以下命令安装:\n\n npm install @cloudbase/signature-nodejs\n\n该依赖用于 Node 环境下的请求签名。"),[3,4];case 4:return[2,x]}})})}var b=function(){function e(e){var a=this;this.getReqOptions=function(e,n){return r(a,void 0,void 0,function(){var a,t,o,s,r,p,l,u,x,b,g,y,w,_,E,O,j,k,A,S,C,P,I,T,N,R,U,L,D,q,M,F,z,B,W;return c(this,function(c){switch(c.label){case 0:return a=new URL(e),t=(0,m.getCloudbaseContext)().TCB_SOURCE,r=(s="".concat((null===(D=null===(L=m.INIT_CONFIG.context)||void 0===L?void 0:L.extendedContext)||void 0===D?void 0:D.source)||t||"",",")).concat,[4,(0,f.getCurrRunEnvTag)()];case 1:return o=r.apply(s,[c.sent()]),n.headers=i(i({},n.headers),{"User-Agent":"adapter-node/".concat((null===(q=n.headers)||void 0===q?void 0:q["X-SDK-Version"])||"@cloudbase/js-sdk/".concat((0,v.getSdkVersion)())),"X-TCB-Source":o,"X-Client-Timestamp":(new Date).valueOf(),"X-TCB-Region":m.INIT_CONFIG.region||(0,f.getEnv)("TENCENTCLOUD_REGION")||"",Host:a.host}),!1===n.withCredentials||(null===(F=null===(M=n.headers.Authorization)||void 0===M?void 0:M.replace("Bearer",""))||void 0===F?void 0:F.trim())||a.pathname.startsWith("/auth/")&&a.pathname!==d.CLIENT_AUTH_PATH?[2,n]:(p=a.pathname===d.ADMIN_PATH,["/v1/model/","/v1/rdb/","/v1/ai/"].some(function(e){return a.pathname.startsWith(e)})?[4,this.getClientCredential({origin:a.origin})]:[3,3]);case 2:return l=c.sent(),n.headers.Authorization="Bearer ".concat(l),[2,n];case 3:return u=i(i({},this.config),null===(z=this.config)||void 0===z?void 0:z.auth),x=u.secretId,b=u.secretKey,g=u.sessionToken,y=i(i({},this.config),null===(B=this.config)||void 0===B?void 0:B.auth).secretType,w=n.method,_=n.body,E=JSON.parse(JSON.stringify(n.headers)),O=this.isNpmFormData(_),(j=O?_.__plainObj?i({},_.__plainObj):{}:"object"==typeof _?_:(0,f.safeParseJson)(_)||{}).envName=(null==j?void 0:j.env)||this.config.env||(null===(W=(0,m.getSecretInfo)())||void 0===W?void 0:W.env)||"",j.access_token?[2,n]:("get"===w.toLowerCase()&&(j=void 0),x&&b&&"SESSION_SECRET"!==y||(k=(0,m.getSecretInfo)(),x=k.secretId,b=k.secretKey,g=k.sessionToken),x&&b?(delete E.Authorization,E["content-type"]?E["content-type"]=E["content-type"].toLowerCase():E["Content-Type"]&&(E["Content-Type"]=E["Content-Type"].toLowerCase()),p&&g&&(j.sessionToken=g),A={secretId:x,secretKey:b,method:w,url:e,params:j,headers:E,withSignedParams:p,timestamp:Math.floor((new Date).getTime()/1e3)-1,isCloudApi:!p},E["content-type"]||E["Content-Type"]?[4,h()]:[2,n]):[2,n]);case 4:return(S=c.sent())?(C=S(A),P=C.authorization,I=C.timestamp,"string"==typeof g&&""!==g?p?(E.Authorization="".concat(P),E["X-Timestamp"]=I,E["X-Signature-Expires"]=600):E.Authorization="".concat(P,", Timestamp=").concat(I,", Token=").concat(g):(E.Authorization="".concat(P,", Timestamp=").concat(I),p&&(E["X-Timestamp"]=I,E["X-Signature-Expires"]=600)),O?(T=_,N=new Set(Object.keys(T.__plainObj||{})),j.envName&&!N.has("envName")&&T.append("envName",j.envName),j.sessionToken&&!N.has("sessionToken")&&T.append("sessionToken",j.sessionToken),R=T.getBuffer(),U=T.getHeaders(),[2,i(i({},n),{headers:i(i(i({},E),U),{"content-length":String(R.length)}),body:R})]):[2,i(i({},n),{headers:E,body:"object"==typeof j?JSON.stringify(j):j})]):[2,n]}})})},this.get=function(e){return a.request(i(i({},e),{method:"get"}),a.restrictedMethods.includes("get"))},this.post=function(e){return a.request(i(i({},e),{method:"post"}),a.restrictedMethods.includes("post"))},this.put=function(e){return a.request(i(i({},e),{method:"put"}))},this.upload=function(e){var n,t=e,o=t.data,s=t.file,r=t.fileContent,c=t.name,p=t.method,l=t.headers,u=void 0===l?{}:l,d=null!=s?s:r;if(void 0===d||void 0===c)throw new Error("file and name is required");var m=(0,f.obj2StrRecord)(null!=o?o:{}),v=null==p?void 0:p.toLowerCase(),x=null!==(n=["post","put"].find(function(e){return e===v}))&&void 0!==n?n:"put",h=new FormData;return"post"===x?(Object.keys(m).forEach(function(e){h.append(e,m[e])}),h.append("key",c),h.append("file",d instanceof Blob?d:new Blob([d])),a.request(i(i({},e),{data:h,method:x}),a.restrictedMethods.includes("upload"))):a.request(i(i({},e),{method:"put",headers:u,body:d}),a.restrictedMethods.includes("upload"))},this.download=function(e){return r(a,void 0,Promise,function(){var a,n,i,t,o;return c(this,function(s){switch(s.label){case 0:return[4,fetch(e.url,{headers:{},signal:this.timeout?AbortSignal.timeout(this.timeout):void 0})];case 1:if(!(a=s.sent()).ok)throw new Error("Download failed with status ".concat(a.status));return[4,a.arrayBuffer()];case 2:return n=s.sent(),i=Buffer.from(n),(t=e.tempFilePath)?(o=l.dirname(t),p.existsSync(o)||p.mkdirSync(o,{recursive:!0}),p.writeFileSync(t,i),[2,{statusCode:200,tempFilePath:t}]):[2,{statusCode:200,tempFilePath:e.url,fileContent:i}]}})})},this.fetch=function(e){return r(a,void 0,Promise,function(){var a,n,t,o,s,r,p,l,u,d,m,v,x,h,b,g;return c(this,function(c){switch(c.label){case 0:return a=e.enableAbort,n=void 0!==a&&a,t=e.stream,o=void 0!==t&&t,s=e.signal,r=e.customReqOpts,p=this.getRealUrl(e.url,e.headers||{},e.body),l=(null==r?void 0:r.timeout)||this.timeout,u=this.createAbortController(l,n,s),d=u[0],m=u[1],v=e.headers?(0,f.headersInit2Indexable)(e.headers):void 0,[4,this.getReqOptions(p,i(i({},e),{headers:v,body:e.body,signal:d.signal}))];case 1:x=c.sent(),this.applyDuplexIfNeeded(x),c.label=2;case 2:return c.trys.push([2,,8,9]),[4,fetch(p,x)];case 3:return h=c.sent(),b=void 0,204!==+h.status?[3,4]:(b="",[3,7]);case 4:return o?(b=h.body,[3,7]):[3,5];case 5:return g=f.safeParseJson,[4,h.text()];case 6:b=g.apply(void 0,[c.sent()]),c.label=7;case 7:return[2,{data:b,statusCode:h.status,header:h.headers,response:h}];case 8:return m(),[7];case 9:return[2]}})})},this.request=function(e,n){return void 0===n&&(n=!1),r(a,void 0,Promise,function(){var a,i,t,o,s,r,p,l,d,m,v,x,h,b,g,y,w,_,E,O,j,k,A,S,C,P,I,T,N,R,U,L,D;return c(this,function(c){switch(c.label){case 0:return a=e.url,i=e.headers,t=void 0===i?{}:i,o=e.data,s=e.responseType,r=e.withCredentials,p=e.body,l=e.method,d=e.customReqOpts,m=(0,f.obj2StrRecord)(t),v=String(l).toLowerCase()||"get",x=(null==d?void 0:d.timeout)||this.timeout,h=e.signal,b=this.createAbortController(x,n,h),g=b[0],y=b[1],w=(0,f.isFormData)(o)?o:"application/x-www-form-urlencoded"===m["content-type"]?(0,f.toQueryString)(null!=o?o:{}):p||(o?JSON.stringify(o):void 0),_=this.getRealUrl((0,u.formatUrl)("https",null!=a?a:"","get"===v?o:{}),e.headers||{},w),[4,this.getReqOptions(_,{method:v,headers:m,body:w,credentials:r?"include":"same-origin",signal:g.signal})];case 1:E=c.sent(),this.applyDuplexIfNeeded(E),c.label=2;case 2:return c.trys.push([2,,19,20]),[4,fetch(_,E)];case 3:O=c.sent(),j={header:{},statusCode:O.status},c.label=4;case 4:return c.trys.push([4,11,,18]),"blob"!==s?[3,6]:(k=j,[4,O.blob()]);case 5:return k.data=c.sent(),[3,10];case 6:return"buffer"!==s?[3,8]:(A=j,C=(S=Buffer).from,[4,O.arrayBuffer()]);case 7:return A.data=C.apply(S,[c.sent()]),[3,10];case 8:return P=j,I=f.safeParseJson,[4,O.text()];case 9:P.data=I.apply(void 0,[c.sent()]),c.label=10;case 10:return[3,18];case 11:return T=c.sent(),console.log("catch an error",T),"blob"!==s?[3,13]:(N=j,[4,O.blob()]);case 12:return N.data=c.sent(),[3,17];case 13:return"buffer"!==s?[3,15]:(R=j,L=(U=Buffer).from,[4,O.arrayBuffer()]);case 14:return R.data=L.apply(U,[c.sent()]),[3,17];case 15:return D=j,[4,O.text()];case 16:D.data=c.sent(),c.label=17;case 17:return[3,18];case 18:return O.headers.forEach(function(e,a){return j.header[a.toLowerCase()]=e}),[2,j];case 19:return y(),[7];case 20:return[2]}})})};var n=e.timeout,t=e.restrictedMethods;this.timeout=n,this.restrictedMethods=t||["get","post","upload","download"],this.config=e}return e.prototype.getClientCredential=function(e){var a;return r(this,void 0,Promise,function(){var n;return c(this,function(i){switch(i.label){case 0:return[4,this.fetch({url:"".concat(e.origin).concat(d.CLIENT_AUTH_PATH),method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({grant_type:"client_credentials"})})];case 1:return n=i.sent(),[2,null===(a=n.data)||void 0===a?void 0:a.access_token]}})})},e.prototype.getRealUrl=function(e,a,n){var i,t,o,s;if(null===(t=null===(i=a.Authorization)||void 0===i?void 0:i.replace("Bearer",""))||void 0===t?void 0:t.trim())return e;if(("object"==typeof n?n:(0,f.safeParseJson)(n)||"").access_token)return e;var r=new URL(e);return"/web"===r.pathname&&(null===(o=this.config.auth)||void 0===o?void 0:o.secretId)&&(null===(s=this.config.auth)||void 0===s?void 0:s.secretKey)&&(r.pathname=d.ADMIN_PATH),r.toString()},e.prototype.createAbortController=function(e,a,n){var i,t=new AbortController;return n&&(n.aborted?t.abort():n.addEventListener("abort",function(){return t.abort()},{once:!0})),e&&(i=setTimeout(function(){var a="请求在".concat(e/1e3,"s内未完成,已中断");console.warn(a),t.abort(new Error(a))},e)),[t,function(){return clearTimeout(i)}]},e.prototype.applyDuplexIfNeeded=function(e){var a;e.body&&"function"==typeof(null===(a=e.body)||void 0===a?void 0:a.pipe)&&(e.duplex="half")},e.prototype.isNpmFormData=function(e){return e&&"object"==typeof e&&"function"==typeof e.getHeaders&&"function"==typeof e.getBuffer},e}();a.NodeRequest=b},5434:function(e,a,n){"use strict";var i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var a,n=1,i=arguments.length;n<i;n++)for(var t in a=arguments[n])Object.prototype.hasOwnProperty.call(a,t)&&(e[t]=a[t]);return e},i.apply(this,arguments)},t=this&&this.__awaiter||function(e,a,n,i){return new(n||(n=Promise))(function(t,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function r(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var a;e.done?t(e.value):(a=e.value,a instanceof n?a:new n(function(e){e(a)})).then(s,r)}c((i=i.apply(e,a||[])).next())})},o=this&&this.__generator||function(e,a){var n,i,t,o,s={label:0,sent:function(){if(1&t[0])throw t[1];return t[1]},trys:[],ops:[]};return o={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function r(r){return function(c){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,r[0]&&(s=0)),s;)try{if(n=1,i&&(t=2&r[0]?i.return:r[0]?i.throw||((t=i.return)&&t.call(i),0):i.next)&&!(t=t.call(i,r[1])).done)return t;switch(i=0,t&&(r=[2&r[0],t.value]),r[0]){case 0:case 1:t=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,i=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!((t=(t=s.trys).length>0&&t[t.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!t||r[1]>t[0]&&r[1]<t[3])){s.label=r[1];break}if(6===r[0]&&s.label<t[1]){s.label=t[1],t=r;break}if(t&&s.label<t[2]){s.label=t[2],s.ops.push(r);break}t[2]&&s.ops.pop(),s.trys.pop();continue}r=a.call(e,s)}catch(e){r=[6,e],i=0}finally{n=t=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,c])}}};Object.defineProperty(a,"__esModule",{value:!0}),a.nodeTool=void 0;var s=n(1197),r=n(9094),c=n(4353),p=n(6480),l=null;function u(){var e;return t(this,void 0,void 0,function(){var a;return o(this,function(i){switch(i.label){case 0:if(l)return[3,4];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,Promise.resolve().then(n.t.bind(n,156,23))];case 2:return a=i.sent(),l=(null===(e=a.default)||void 0===e?void 0:e.sign)||a.sign,[3,4];case 3:return i.sent(),console.error("缺少依赖 jsonwebtoken,请执行以下命令安装:\n\n npm install jsonwebtoken\n\n该依赖用于 Node 环境下的自定义登录票据生成。"),[3,4];case 4:return[2,l]}})})}function d(){var e=(0,r.getCloudbaseContext)();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 m(e,a){var n,i;return null===(i=null===(n=null==e?void 0:e.request)||void 0===n?void 0:n.send)||void 0===i?void 0:i.call(n,"auth.getUserInfoForAdmin",a,{pathname:"web",endPointMode:"CLOUD_API"})}var f=null;a.nodeTool=function(e,a){var n=a;if(e.parseContext=function(e){var a=(0,r.parseContext)(e);return f=a,a},e.getCloudbaseContext=function(e){return(0,r.getCloudbaseContext)(e)},e.auth){var l={getUserInfo:function(){return d()},getEndUserInfo:function(n){return t(this,void 0,Promise,function(){var t;return o(this,function(o){return t=d(),void 0===n?[2,{userInfo:t}]:((0,c.validateUid)(n),[2,m(e,{uuid:n,envName:a.env}).then(function(e){return e.code?e:{userInfo:i(i({},t),e.data),requestId:e.requestId}})])})})},createTicket:function(e,n){return void 0===n&&(n={}),t(this,void 0,Promise,function(){var t,r,p,l,d,m,f,v,x;return o(this,function(o){switch(o.label){case 0:if((0,c.validateUid)(e),t=(new Date).getTime(),r=(a.auth||{}).credentials,!(p=a.env))throw i(i({},s.ERROR.INVALID_PARAM),{message:"no env in config"});if(!(null==r?void 0:r.env_id))throw i(i({},s.ERROR.INVALID_PARAM),{message:"当前私钥未包含env_id 信息, 请前往腾讯云云开发控制台,获取自定义登录最新私钥"});if(r.env_id!==p)throw i(i({},s.ERROR.INVALID_PARAM),{message:"当前私钥所属环境与 init 指定环境不一致!"});return l=n.refresh,d=void 0===l?36e5:l,m=n.expire,f=void 0===m?t+6048e5:m,[4,u()];case 1:return v=o.sent(),x=v({alg:"RS256",env:p,iat:t,exp:t+6e5,uid:e,refresh:d,expire:f},r.private_key,{allowInsecureKeySizes:!0,algorithm:"RS256"}),[2,"".concat(r.private_key_id,"/@@/").concat(x)]}})})},queryUserInfo:function(n){return t(this,void 0,Promise,function(){var t,s,r;return o(this,function(o){return t=n.uid,s=n.platform,r=n.platformId,[2,m(e,{uuid:t,platform:s,platformId:r,envName:a.env}).then(function(e){return e.code?e:{userInfo:i({},e.data),requestId:e.requestId}})]})})},getClientIP:function(){return(0,r.getCloudbaseContext)().TCB_SOURCE_IP||""},getAuthContext:function(e){var a=(0,r.getCloudbaseContext)(e),n=a.TCB_UUID,i=a.LOGINTYPE,t=a.QQ_OPENID,o=a.QQ_APPID,s={uid:n,loginType:i};return"QQ-MINI"===i&&(s.appId=o,s.openId=t),s},getClientCredential:function(i){return t(this,void 0,void 0,function(){var t;return o(this,function(o){switch(o.label){case 0:return n.accessKey||a.accessKey?[2,n.accessKey||a.accessKey]:(t=e.request.getBaseEndPoint("GATEWAY"),[4,e.request.post({url:"".concat(t).concat("/auth/v1/token/clientCredential"),data:{grant_type:"client_credentials"},headers:{"content-type":"application/json"}},i?{timeout:i.timeout}:void 0)]);case 1:return[2,o.sent().data]}})})}},v=e.auth;Object.keys(l).forEach(function(e){v[e]=l[e]}),e.auth=new Proxy(v,{apply:function(e,a,n){var i=Reflect.apply(e,a,n);return i&&"object"==typeof i&&Object.keys(l).forEach(function(e){e in i||(i[e]=l[e])}),i}})}function x(){var a=n.serviceUrl||(0,r.getServerInjectUrl)()||void 0;return(0,p.getWxOptions)(n,f,a||"",e.request)}e.sendTemplateNotification=function(a,n){var i;return null===(i=null==e?void 0:e.callFunction)||void 0===i?void 0:i.call(e,{name:"lowcode-datasource",data:{methodName:"callWedaApi",params:{action:"PushNotifyMsg",data:{NotifyId:a.notifyId,Data:JSON.stringify(a.data),NotifyUsers:void 0,Url:a.url}},mode:"c"}},void 0,n)},e.callWxOpenApi=function(e,a){return(0,p.callWxOpenApi)(x(),e,a)},e.callWxPayApi=function(e,a){return(0,p.callWxPayApi)(x(),e,a)},e.wxCallContainerApi=function(e,a){return(0,p.wxCallContainerApi)(x(),e,a)},e.callCompatibleWxOpenApi=function(e,a){return(0,p.callCompatibleWxOpenApi)(x(),e,a)},e.getFileAuthority=function(a,n){var p=a.fileList;return t(void 0,void 0,void 0,function(){var a,t,l,u,d,m;return o(this,function(o){switch(o.label){case 0:if(a=(0,r.getCloudbaseContext)().LOGINTYPE,!Array.isArray(p))throw(0,c.E)(i(i({},s.ERROR.INVALID_PARAM),{message:"[js-sdk] getCosFileAuthority fileList must be a array"}));if(p.some(function(e){return!(null==e?void 0:e.path)||!["READ","WRITE","READWRITE"].includes(e.type)}))throw(0,c.E)(i(i({},s.ERROR.INVALID_PARAM),{message:"[js-sdk] getCosFileAuthority fileList param error"}));return[4,e.auth.getEndUserInfo()];case 1:if(t=o.sent().userInfo,l=t.openId,u=t.uid,!l&&!u)throw(0,c.E)(i(i({},s.ERROR.INVALID_PARAM),{message:"[js-sdk] admin do not need getCosFileAuthority."}));return d={openId:l,uid:u,loginType:a,fileList:p},[4,e.request.send("storage.getFileAuthority",d,{pathname:"web",endPointMode:"GATEWAY"},n?{timeout:n.timeout}:void 0)];case 2:if((m=o.sent()).code)throw(0,c.E)(i(i({},m),{message:"[js-sdk] getCosFileAuthority failed: ".concat(m.code)}));return[2,m]}})})},e.callApis=function(a,n){return t(void 0,void 0,void 0,function(){var i,t,s,r,c,p,l,u,d,m,f,v;return o(this,function(o){if(e.apis)return i=a.name,t=a.path,s=void 0===t?"":t,r=a.method,c=void 0===r?"POST":r,p=a.header,l=void 0===p?{}:p,u=a.body,d=a.token,m=(c||"POST").toLowerCase(),[2,null===(v=null===(f=e.apis[i])||void 0===f?void 0:f[m])||void 0===v?void 0:v.call(f,{path:s,method:c,headers:l,body:u,token:d},n)];throw new Error("callApis is not supported in current configuration")})})}}},4353:function(e,a,n){"use strict";var i,t,o=this&&this.__extends||(i=function(e,a){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,a){e.__proto__=a}||function(e,a){for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])},i(e,a)},function(e,a){if("function"!=typeof a&&null!==a)throw new TypeError("Class extends value "+String(a)+" is not a constructor or null");function n(){this.constructor=e}i(e,a),e.prototype=null===a?Object.create(a):(n.prototype=a.prototype,new n)}),s=this&&this.__assign||function(){return s=Object.assign||function(e){for(var a,n=1,i=arguments.length;n<i;n++)for(var t in a=arguments[n])Object.prototype.hasOwnProperty.call(a,t)&&(e[t]=a[t]);return e},s.apply(this,arguments)},r=this&&this.__awaiter||function(e,a,n,i){return new(n||(n=Promise))(function(t,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function r(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var a;e.done?t(e.value):(a=e.value,a instanceof n?a:new n(function(e){e(a)})).then(s,r)}c((i=i.apply(e,a||[])).next())})},c=this&&this.__generator||function(e,a){var n,i,t,o,s={label:0,sent:function(){if(1&t[0])throw t[1];return t[1]},trys:[],ops:[]};return o={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function r(r){return function(c){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,r[0]&&(s=0)),s;)try{if(n=1,i&&(t=2&r[0]?i.return:r[0]?i.throw||((t=i.return)&&t.call(i),0):i.next)&&!(t=t.call(i,r[1])).done)return t;switch(i=0,t&&(r=[2&r[0],t.value]),r[0]){case 0:case 1:t=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,i=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!((t=(t=s.trys).length>0&&t[t.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!t||r[1]>t[0]&&r[1]<t[3])){s.label=r[1];break}if(6===r[0]&&s.label<t[1]){s.label=t[1],t=r;break}if(t&&s.label<t[2]){s.label=t[2],s.ops.push(r);break}t[2]&&s.ops.pop(),s.trys.pop();continue}r=a.call(e,s)}catch(e){r=[6,e],i=0}finally{n=t=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,c])}}};Object.defineProperty(a,"__esModule",{value:!0}),a.SYMBOL_DEFAULT_ENV=a.SYMBOL_CURRENT_ENV=a.isValidEnvFormat=a.isPageModuleName=a.processReturn=a.setThrowOnCode=a.filterUndefined=a.filterValue=a.E=a.TcbError=a.createWebStreamFromNodeReadableStream=a.parseQueryString=a.headersInit2Indexable=a.obj2StrRecord=a.safeParseJson=a.validateUid=a.getCurrRunEnvTag=a.checkIsInTencentCloud=a.checkIsInSumeru=a.checkIsInCBR=a.checkIsInScf=a.getEnv=a.toQueryString=a.isFormData=void 0;var p=n(2877),l=n(8775),u=n(1197),d=n(1651);function m(e){return"undefined"!=typeof process&&process.env?void 0!==e?process.env[e]:process.env:void 0!==e?void 0:{}