@cloudbase/js-sdk
Version:
cloudbase javascript sdk
2 lines • 262 kB
JavaScript
/*! For license information please see index.node.esm.js.LICENSE.txt */
import*as e from"web-streams-polyfill";import*as a from"jwt-decode";import*as n from"@cloudbase/adapter-interface";import*as i from"@cloudbase/signature-nodejs";import*as o from"jsonwebtoken";import*as t from"ws";import{createRequire as s}from"module";import*as r from"@cloudbase/adapter-wx_mp";var c={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,o){a?e(n,o):i(function(){e(n,o)})}}},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),o=n(190);e.exports=function(e,a,n,t){var s=n.keyedList?n.keyedList[n.index]:n.index;n.jobs[s]=function(e,a,n,o){return 2==e.length?e(n,i(o)):e(n,a,i(o))}(a,s,e[s],function(e,a){s in n.jobs&&(delete n.jobs[s],e?o(n):n.results[s]=a,t(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),o=n(1307);e.exports=function(e){Object.keys(this.jobs).length&&(this.index=this.size,i(this),o(e)(null,this.results))}},8197:(e,a,n)=>{var i=n(5798),o=n(7379),t=n(3797);e.exports=function(e,a,n){for(var s=o(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 t.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),o=n(7379),t=n(3797);function s(e,a){return e<a?-1:e>a?1:0}e.exports=function(e,a,n,s){var r=o(e,n);return i(e,a,r,function n(o,t){o?s(o,t):(r.index++,r.index<(r.keyedList||e).length?i(e,a,r,n):s(null,r.results))}),t.bind(r,s)},e.exports.ascending=s,e.exports.descending=function(e,a){return-1*s(e,a)}},7922:(e,a,n)=>{n.d(a,{$R:()=>w,Bh:()=>h,Fy:()=>g,M4:()=>j,R1:()=>k,eX:()=>d,mI:()=>l,n0:()=>f,po:()=>p,tC:()=>u,vS:()=>y});var i=n(2976),o=function(){return o=Object.assign||function(e){for(var a,n=1,i=arguments.length;n<i;n++)for(var o in a=arguments[n])Object.prototype.hasOwnProperty.call(a,o)&&(e[o]=a[o]);return e},o.apply(this,arguments)},t=i._G.tC,s=i._G.pM,r="",c="@cloudbase/js-sdk";function p(e){r=e}function l(){return r}function u(e){c=e,t(e)}function d(){return c}var m,f="2020-01-10",v=[],x=["env","endPointKey","region"],h="https:";function b(e){return v.find(function(a){return x.filter(function(a){return null!=e[a]}).every(function(n){return a[n]===e[n]})})}function g(e){var a,n;e.protocol&&!/:$/.test(e.protocol)&&(e.protocol="".concat(e.protocol,":"));var i=b(e);i?(null!=e.baseUrl&&(i.baseUrl=e.baseUrl),null!=e.protocol&&(i.protocol=e.protocol)):v.push(o(o({},e),{protocol:null!==(a=e.protocol)&&void 0!==a?a:h})),"CLOUD_API"===e.endPointKey&&s(null!==(n=e.protocol)&&void 0!==n?n:h)}function y(e,a,n){return b({env:e,endPointKey:a,region:n})}function w(e,a,n){var i="//".concat(e,".api.tcloudbasegateway.com/v1");n&&(i="//".concat(e,".api.intl.tcloudbasegateway.com/v1")),g({endPointKey:"GATEWAY",env:e,baseUrl:i,protocol:a})}function k(e,a,n){g({env:e,region:a,baseUrl:"//".concat(e,".").concat(a||"ap-shanghai",".tcb-api.tencentcloudapi.com/web"),protocol:n,endPointKey:"CLOUD_API"})}function j(e,a){void 0===a&&(a="CLOUD_API");var n=y(e,a||"CLOUD_API"),i=n.protocol,o=n.baseUrl;return"".concat(i).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"}(m||(m={}))},4576:(a,n,i)=>{i.r(n),i.d(n,{E:()=>F,NodeRequest:()=>le,SYMBOL_CURRENT_ENV:()=>H,SYMBOL_DEFAULT_ENV:()=>J,TcbError:()=>z,buildAdminUrl:()=>ge,callCompatibleWxOpenApi:()=>Se,callWxOpenApi:()=>Ee,callWxPayApi:()=>Oe,createWebStreamFromNodeReadableStream:()=>D,default:()=>Ke,filterUndefined:()=>B,filterValue:()=>M,getCloudbaseContext:()=>Z,getSecretInfo:()=>ie,getServerInjectUrl:()=>ae,getTcbContextConfig:()=>ee,getWxCloudToken:()=>he,getWxOptions:()=>_e,isPageModuleName:()=>G,isValidEnvFormat:()=>Y,parseContext:()=>Q,parseQueryString:()=>q,processReturn:()=>V,sendWxFormDataRequest:()=>ke,sendWxRequest:()=>we,setThrowOnCode:()=>K,wxCallContainerApi:()=>Ie});var o,t=i(7149),s=i(7147),r=i(1017),c={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参数"}},p="/admin",l="/auth/v1/token/clientCredential",u=/^[a-zA-Z0-9_\-#@~=*(){}[\]:.,<>+]{4,32}$/;!function(e){e.SECRET="SECRET",e.SESSION_SECRET="SESSION_SECRET"}(o||(o={}));var d=i(2976);const m=(f={ReadableStream:()=>e.ReadableStream},v={},i.d(v,f),v);var f,v,x,h=function(e,a,n,i){return new(n||(n=Promise))(function(o,t){function s(e){try{c(i.next(e))}catch(e){t(e)}}function r(e){try{c(i.throw(e))}catch(e){t(e)}}function c(e){var a;e.done?o(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())})},b=function(e,a){var n,i,o,t,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return t={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function r(r){return function(c){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;t&&(t=0,r[0]&&(s=0)),s;)try{if(n=1,i&&(o=2&r[0]?i.return:r[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,r[1])).done)return o;switch(i=0,o&&(r=[2&r[0],o.value]),r[0]){case 0:case 1:o=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(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]<o[3])){s.label=r[1];break}if(6===r[0]&&s.label<o[1]){s.label=o[1],o=r;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(r);break}o[2]&&s.ops.pop(),s.trys.pop();continue}r=a.call(e,s)}catch(e){r=[6,e],i=0}finally{n=o=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,c])}}};function g(e,a){return void 0===a&&(a={}),h(this,void 0,Promise,function(){var n,i,o,t;return b(this,function(s){switch(s.label){case 0:n="".concat("http://metadata.tencentyun.com","/").concat(x.latest,"/").concat(e),i=new AbortController,a.timeout&&(o=setTimeout(function(){return i.abort()},a.timeout)),s.label=1;case 1:return s.trys.push([1,,5,6]),[4,fetch(n,{signal:i.signal})];case 2:return 200!==(t=s.sent()).status?[3,4]:[4,t.text()];case 3:return[2,s.sent()];case 4:throw new Error("[ERROR] GET ".concat(n," status: ").concat(t.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"}(x||(x={}));var y={appId:void 0};function w(){return h(this,void 0,Promise,function(){var e;return b(this,function(a){switch(a.label){case 0:if(void 0!==y.appId)return[3,4];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,g("meta-data/app-id",{timeout:30})];case 2:return e=a.sent(),/^[1-9][0-9]{4,64}$/gim.test(e)?y.appId=e:y.appId="",[3,4];case 3:return a.sent(),[3,4];case 4:return[2,y.appId||""]}})})}var k,j,_=(k=function(e,a){return k=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])},k(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}k(e,a),e.prototype=null===a?Object.create(a):(n.prototype=a.prototype,new n)}),E=function(){return E=Object.assign||function(e){for(var a,n=1,i=arguments.length;n<i;n++)for(var o in a=arguments[n])Object.prototype.hasOwnProperty.call(a,o)&&(e[o]=a[o]);return e},E.apply(this,arguments)},A=function(e,a,n,i){return new(n||(n=Promise))(function(o,t){function s(e){try{c(i.next(e))}catch(e){t(e)}}function r(e){try{c(i.throw(e))}catch(e){t(e)}}function c(e){var a;e.done?o(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())})},S=function(e,a){var n,i,o,t,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return t={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function r(r){return function(c){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;t&&(t=0,r[0]&&(s=0)),s;)try{if(n=1,i&&(o=2&r[0]?i.return:r[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,r[1])).done)return o;switch(i=0,o&&(r=[2&r[0],o.value]),r[0]){case 0:case 1:o=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(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]<o[3])){s.label=r[1];break}if(6===r[0]&&s.label<o[1]){s.label=o[1],o=r;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(r);break}o[2]&&s.ops.pop(),s.trys.pop();continue}r=a.call(e,s)}catch(e){r=[6,e],i=0}finally{n=o=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,c])}}},O=(j=d.P6).isFormData,I=j.toQueryString;function T(e){return"undefined"!=typeof process&&process.env?void 0!==e?process.env[e]:process.env:void 0!==e?void 0:{}}var C=function(){return"SCF"===T("TENCENTCLOUD_RUNENV")},P=new Set(["formal","pre","test"]);function N(){return A(this,void 0,Promise,function(){var e;return S(this,function(a){switch(a.label){case 0:return"true"===T("TENCENTCLOUD")?[2,!0]:[4,w()];case 1:return[2,"string"==typeof(e=a.sent())&&""!==e]}})})}var R=function(e){if("string"!=typeof e)throw E(E({},c.INVALID_PARAM),{message:"uid must be a string"});if(!u.test(e))throw E(E({},c.INVALID_PARAM),{message:'Invalid uid: "'.concat(e,'"')})};function U(e){if(!e||!e.trim())return null;try{return JSON.parse(e)}catch(a){return console.warn("catch an error",{e:a,text:e}),e}}function L(e){return Object.entries(e).reduce(function(e,a){var n=a[0],i=a[1];return e[n]=String(i),e},{})}function q(e){var a={},n=e.replace(/^[?#]/,"");return n?(n.split("&").forEach(function(e){var n=e.split("="),i=n[0],o=n[1];i=decodeURIComponent(i),o=decodeURIComponent(o||""),i&&(a[i]?Array.isArray(a[i])?a[i].push(o):a[i]=[a[i],o]:a[i]=o)}),a):a}function D(e){var a=e[Symbol.asyncIterator]();return new m.ReadableStream({pull:function(e){return A(this,void 0,void 0,function(){var n;return S(this,function(i){switch(i.label){case 0:return[4,a.next()];case 1:return(n=i.sent()).done?e.close():e.enqueue(n.value),[2]}})})}})}var z=function(e){function a(a){var n=e.call(this,a.message)||this;return n.code=a.code||"",n.message=a.message||"",n.requestId=a.requestId||"",n}return _(a,e),a}(Error);function F(e){return new z(e)}function M(e,a){for(var n in e)e[n]===a&&delete e[n]}function B(e){M(e,void 0)}var W=!0;function K(e){W=e}function V(e){if(!W)return e;throw F(E({},e))}function G(e){return void 0===e&&(e=""),"string"==typeof e&&e.startsWith("$:")}var X=/^[a-z0-9_-]{1,40}$/;function Y(e){return void 0===e&&(e=""),"string"==typeof e&&X.test(e)}var H=Symbol.for("SYMBOL_CURRENT_ENV"),J=Symbol.for("SYMBOL_DEFAULT_ENV"),$=function(){return $=Object.assign||function(e){for(var a,n=1,i=arguments.length;n<i;n++)for(var o in a=arguments[n])Object.prototype.hasOwnProperty.call(a,o)&&(e[o]=a[o]);return e},$.apply(this,arguments)};function Q(e){if("object"!=typeof e)throw $($({},c.INVALID_CONTEXT),{message:"context 必须为对象类型"});var a={},n=e.memory_limit_in_mb,i=e.time_limit_in_ms,o=e.request_id,t=e.function_version,s=e.namespace,r=e.function_name,p=e.environ,l=e.environment;try{if(a.memoryLimitInMb=n,a.timeLimitIns=i,a.requestId=o,a.functionVersion=t,a.namespace=s,a.functionName=r,l)a.environment=JSON.parse(l);else{var u=null==p?void 0:p.split(";"),d={};for(var m in u)if(u[m].includes("=")){var f=u[m].indexOf("="),v=u[m].slice(0,f),x=u[m].slice(f+1);x.indexOf(",")>=0&&(x=x.split(",")),d[v]=x}a.environ=d}}catch(e){throw $({},c.INVALID_CONTEXT)}return a}var Z=function(e){C()&&(T("TENCENTCLOUD_REGION")||console.error("[TCB][ERROR] missing `TENCENTCLOUD_REGION` environment"),T("SCF_NAMESPACE")||console.error("[TCB][ERROR] missing `SCF_NAMESPACE` environment"));var a=T(),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},i={};if(e){var o=Q(e),t=o.environment,s=o.environ;i=t||s||{}}for(var r=0,c=[i.TCB_CONTEXT_KEYS||a.TCB_CONTEXT_KEYS,i.WX_CONTEXT_KEYS||a.WX_CONTEXT_KEYS];r<c.length;r++){var p=c[r];if(p)try{for(var l=0,u=p.split(",");l<u.length;l++){var d=u[l];n[d]=i[d]||T(d)}}catch(e){}}var m=$($({},n),i);return Object.fromEntries(Object.entries(m).filter(function(e){return void 0!==e[1]}))};function ee(){try{var e=Z().TCB_CONTEXT_CNFG;return e?JSON.parse(e):{}}catch(e){return console.error("[TCB][ERROR] parse context error: ",e),{}}}function ae(){return ee().URL||""}var ne={},ie=function(e){var a,n,i,t,s,r,c;ne=JSON.parse(JSON.stringify(e||ne));var p=Z(),l=p.TCB_ENV,u=p.SCF_NAMESPACE,d=p.TENCENTCLOUD_RUNENV,m=p.TENCENTCLOUD_SECRETID,f=p.TENCENTCLOUD_SECRETKEY,v=p.TENCENTCLOUD_SESSIONTOKEN,x=p.CLOUDBASE_APIKEY,h=$($({},ne),e),b="";"local"===(b="symbol"!=typeof(null==e?void 0:e.env)&&(null==e?void 0:e.env)?e.env:l||u||"")&&"WX_LOCAL_SCF"===d&&(b="");var g={env:b,secretId:"",secretKey:"",sessionToken:"",accessKey:"",secretType:"",credentials:void 0,context:void 0};if((null==h?void 0:h.context)&&(g.context=h.context),((null==h?void 0:h.credentials)||(null===(a=null==e?void 0:e.auth)||void 0===a?void 0:a.credentials))&&(g.credentials=(null==h?void 0:h.credentials)||(null===(n=null==e?void 0:e.auth)||void 0===n?void 0:n.credentials)),(null==e?void 0:e.accessKey)||(null==h?void 0:h.accessKey))return g.accessKey=(null==e?void 0:e.accessKey)||(null==h?void 0:h.accessKey),g;if((null==h?void 0:h.secretId)&&(null==h?void 0:h.secretKey))return $($({},g),{secretId:h.secretId,secretKey:h.secretKey,sessionToken:h.sessionToken||"",secretType:h.sessionToken?o.SESSION_SECRET:o.SECRET});if((null===(i=null==e?void 0:e.auth)||void 0===i?void 0:i.secretId)&&(null===(t=null==e?void 0:e.auth)||void 0===t?void 0:t.secretKey))return $($({},g),{secretId:e.auth.secretId,secretKey:e.auth.secretKey,sessionToken:e.auth.sessionToken||"",secretType:e.auth.secretType||o.SECRET});if(x)return $($({},g),{accessKey:x});if(m&&f)return $($({},g),{secretId:m,secretKey:f,sessionToken:v||"",secretType:o.SESSION_SECRET});var y=(null==h?void 0:h.context)||(null==e?void 0:e.context);if(null==y?void 0:y.extendedContext){var w=y.extendedContext;return b||(b=w.envId||""),$($({},g),{env:b,secretId:(null===(s=null==w?void 0:w.tmpSecret)||void 0===s?void 0:s.secretId)||"",secretKey:(null===(r=null==w?void 0:w.tmpSecret)||void 0===r?void 0:r.secretKey)||"",sessionToken:(null===(c=null==w?void 0:w.tmpSecret)||void 0===c?void 0:c.token)||""})}return $({},g)},oe=i(7922),te=function(){return te=Object.assign||function(e){for(var a,n=1,i=arguments.length;n<i;n++)for(var o in a=arguments[n])Object.prototype.hasOwnProperty.call(a,o)&&(e[o]=a[o]);return e},te.apply(this,arguments)},se=function(e,a,n,i){return new(n||(n=Promise))(function(o,t){function s(e){try{c(i.next(e))}catch(e){t(e)}}function r(e){try{c(i.throw(e))}catch(e){t(e)}}function c(e){var a;e.done?o(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())})},re=function(e,a){var n,i,o,t,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return t={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function r(r){return function(c){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;t&&(t=0,r[0]&&(s=0)),s;)try{if(n=1,i&&(o=2&r[0]?i.return:r[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,r[1])).done)return o;switch(i=0,o&&(r=[2&r[0],o.value]),r[0]){case 0:case 1:o=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(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]<o[3])){s.label=r[1];break}if(6===r[0]&&s.label<o[1]){s.label=o[1],o=r;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(r);break}o[2]&&s.ops.pop(),s.trys.pop();continue}r=a.call(e,s)}catch(e){r=[6,e],i=0}finally{n=o=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,c])}}},ce=null;function pe(){return se(this,void 0,void 0,function(){var e;return re(this,function(a){switch(a.label){case 0:if(ce)return[3,4];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,Promise.resolve().then(i.bind(i,9143))];case 2:return e=a.sent(),ce=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,ce]}})})}var le=function(){function e(e){var a=this;this.getReqOptions=function(e,n){return se(a,void 0,void 0,function(){var a,i,o,t,s,r,c,u,d,m,f,v,x,h,b,g,y,w,k,j,_,E,O,I,R,L,q,D,z,F,M,B,W,K,V;return re(this,function(G){switch(G.label){case 0:return a=new URL(e),i=Z().TCB_SOURCE,s=(t="".concat((null===(z=null===(D=ne.context)||void 0===D?void 0:D.extendedContext)||void 0===z?void 0:z.source)||i||"",",")).concat,[4,A(void 0,void 0,Promise,function(){return S(this,function(e){switch(e.label){case 0:return C()?[2,"scf"]:T("CBR_ENV_ID")?[2,"cbr"]:P.has(T("SUMERU_ENV")||"")?[2,"sumeru"]:[4,N()];case 1:return e.sent()?[2,"tencentcloud"]:[2,"unknown"]}})})];case 1:return o=s.apply(t,[G.sent()]),n.headers=te(te({},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,oe.mI)())),"X-TCB-Source":o,"X-Client-Timestamp":(new Date).valueOf(),"X-TCB-Region":ne.region||T("TENCENTCLOUD_REGION")||"",Host:a.host}),!1===n.withCredentials||(null===(B=null===(M=n.headers.Authorization)||void 0===M?void 0:M.replace("Bearer",""))||void 0===B?void 0:B.trim())||a.pathname.startsWith("/auth/")&&a.pathname!==l?[2,n]:(r=a.pathname===p,["/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 c=G.sent(),n.headers.Authorization="Bearer ".concat(c),[2,n];case 3:return u=te(te({},this.config),null===(W=this.config)||void 0===W?void 0:W.auth),d=u.secretId,m=u.secretKey,f=u.sessionToken,v=te(te({},this.config),null===(K=this.config)||void 0===K?void 0:K.auth).secretType,x=n.method,h=n.body,b=JSON.parse(JSON.stringify(n.headers)),g=this.isNpmFormData(h),(y=g?h.__plainObj?te({},h.__plainObj):{}:"object"==typeof h?h:U(h)||{}).envName=(null==y?void 0:y.env)||this.config.env||(null===(V=ie())||void 0===V?void 0:V.env)||"",y.access_token?[2,n]:("get"===x.toLowerCase()&&(y=void 0),d&&m&&"SESSION_SECRET"!==v||(w=ie(),d=w.secretId,m=w.secretKey,f=w.sessionToken),d&&m?(delete b.Authorization,b["content-type"]?b["content-type"]=b["content-type"].toLowerCase():b["Content-Type"]&&(b["Content-Type"]=b["Content-Type"].toLowerCase()),r&&f&&(y.sessionToken=f),k={secretId:d,secretKey:m,method:x,url:e,params:y,headers:b,withSignedParams:r,timestamp:Math.floor((new Date).getTime()/1e3)-1,isCloudApi:!r},b["content-type"]||b["Content-Type"]?[4,pe()]:[2,n]):[2,n]);case 4:return(j=G.sent())?(_=j(k),E=_.authorization,O=_.timestamp,"string"==typeof f&&""!==f?r?(b.Authorization="".concat(E),b["X-Timestamp"]=O,b["X-Signature-Expires"]=600):b.Authorization="".concat(E,", Timestamp=").concat(O,", Token=").concat(f):(b.Authorization="".concat(E,", Timestamp=").concat(O),r&&(b["X-Timestamp"]=O,b["X-Signature-Expires"]=600)),g?(I=h,R=new Set(Object.keys(I.__plainObj||{})),y.envName&&!R.has("envName")&&I.append("envName",y.envName),y.sessionToken&&!R.has("sessionToken")&&I.append("sessionToken",y.sessionToken),L=I.getBuffer(),q=I.getHeaders(),[2,te(te({},n),{headers:te(te(te({},b),q),{"content-length":String(L.length)}),body:L})]):[2,te(te({},n),{headers:b,body:"object"==typeof y?JSON.stringify(y):y})]):[2,n]}})})},this.get=function(e){return a.request(te(te({},e),{method:"get"}),a.restrictedMethods.includes("get"))},this.post=function(e){return a.request(te(te({},e),{method:"post"}),a.restrictedMethods.includes("post"))},this.put=function(e){return a.request(te(te({},e),{method:"put"}))},this.upload=function(e){var n,i=e,o=i.data,t=i.file,s=i.fileContent,r=i.name,c=i.method,p=i.headers,l=void 0===p?{}:p,u=null!=t?t:s;if(void 0===u||void 0===r)throw new Error("file and name is required");var d=L(null!=o?o:{}),m=null==c?void 0:c.toLowerCase(),f=null!==(n=["post","put"].find(function(e){return e===m}))&&void 0!==n?n:"put",v=new FormData;return"post"===f?(Object.keys(d).forEach(function(e){v.append(e,d[e])}),v.append("key",r),v.append("file",u instanceof Blob?u:new Blob([u])),a.request(te(te({},e),{data:v,method:f}),a.restrictedMethods.includes("upload"))):a.request(te(te({},e),{method:"put",headers:l,body:u}),a.restrictedMethods.includes("upload"))},this.download=function(e){return se(a,void 0,Promise,function(){var a,n,i,o,t;return re(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(!(a=c.sent()).ok)throw new Error("Download failed with status ".concat(a.status));return[4,a.arrayBuffer()];case 2:return n=c.sent(),i=Buffer.from(n),(o=e.tempFilePath)?(t=r.dirname(o),s.existsSync(t)||s.mkdirSync(t,{recursive:!0}),s.writeFileSync(o,i),[2,{statusCode:200,tempFilePath:o}]):[2,{statusCode:200,tempFilePath:e.url,fileContent:i}]}})})},this.fetch=function(e){return se(a,void 0,Promise,function(){var a,n,i,o,t,s,r,c,p,l,u,d,m,f,v,x;return re(this,function(h){switch(h.label){case 0:return a=e.enableAbort,n=void 0!==a&&a,i=e.stream,o=void 0!==i&&i,t=e.signal,s=e.customReqOpts,r=this.getRealUrl(e.url,e.headers||{},e.body),c=(null==s?void 0:s.timeout)||this.timeout,p=this.createAbortController(c,n,t),l=p[0],u=p[1],d=e.headers?function(e){if(function(e){try{return e instanceof Headers}catch(e){return!1}}(e)){var a={};return e.forEach(function(e,n){a[n]=e}),a}return e}(e.headers):void 0,[4,this.getReqOptions(r,te(te({},e),{headers:d,body:e.body,signal:l.signal}))];case 1:m=h.sent(),this.applyDuplexIfNeeded(m),h.label=2;case 2:return h.trys.push([2,,8,9]),[4,fetch(r,m)];case 3:return f=h.sent(),v=void 0,204!==+f.status?[3,4]:(v="",[3,7]);case 4:return o?(v=f.body,[3,7]):[3,5];case 5:return x=U,[4,f.text()];case 6:v=x.apply(void 0,[h.sent()]),h.label=7;case 7:return[2,{data:v,statusCode:f.status,header:f.headers,response:f}];case 8:return u(),[7];case 9:return[2]}})})},this.request=function(e,n){return void 0===n&&(n=!1),se(a,void 0,Promise,function(){var a,i,o,s,r,c,p,l,u,d,m,f,v,x,h,b,g,y,w,k,j,_,E,A,S,T,C,P,N,R,q,D,z;return re(this,function(F){switch(F.label){case 0:return a=e.url,i=e.headers,o=void 0===i?{}:i,s=e.data,r=e.responseType,c=e.withCredentials,p=e.body,l=e.method,u=e.customReqOpts,d=L(o),m=String(l).toLowerCase()||"get",f=(null==u?void 0:u.timeout)||this.timeout,v=e.signal,x=this.createAbortController(f,n,v),h=x[0],b=x[1],g=O(s)?s:"application/x-www-form-urlencoded"===d["content-type"]?I(null!=s?s:{}):p||(s?JSON.stringify(s):void 0),y=this.getRealUrl((0,t.formatUrl)("https",null!=a?a:"","get"===m?s:{}),e.headers||{},g),[4,this.getReqOptions(y,{method:m,headers:d,body:g,credentials:c?"include":"same-origin",signal:h.signal})];case 1:w=F.sent(),this.applyDuplexIfNeeded(w),F.label=2;case 2:return F.trys.push([2,,19,20]),[4,fetch(y,w)];case 3:k=F.sent(),j={header:{},statusCode:k.status},F.label=4;case 4:return F.trys.push([4,11,,18]),"blob"!==r?[3,6]:(_=j,[4,k.blob()]);case 5:return _.data=F.sent(),[3,10];case 6:return"buffer"!==r?[3,8]:(E=j,S=(A=Buffer).from,[4,k.arrayBuffer()]);case 7:return E.data=S.apply(A,[F.sent()]),[3,10];case 8:return T=j,C=U,[4,k.text()];case 9:T.data=C.apply(void 0,[F.sent()]),F.label=10;case 10:return[3,18];case 11:return P=F.sent(),console.log("catch an error",P),"blob"!==r?[3,13]:(N=j,[4,k.blob()]);case 12:return N.data=F.sent(),[3,17];case 13:return"buffer"!==r?[3,15]:(R=j,D=(q=Buffer).from,[4,k.arrayBuffer()]);case 14:return R.data=D.apply(q,[F.sent()]),[3,17];case 15:return z=j,[4,k.text()];case 16:z.data=F.sent(),F.label=17;case 17:return[3,18];case 18:return k.headers.forEach(function(e,a){return j.header[a.toLowerCase()]=e}),[2,j];case 19:return b(),[7];case 20:return[2]}})})};var n=e.timeout,i=e.restrictedMethods;this.timeout=n,this.restrictedMethods=i||["get","post","upload","download"],this.config=e}return e.prototype.getClientCredential=function(e){var a;return se(this,void 0,Promise,function(){var n;return re(this,function(i){switch(i.label){case 0:return[4,this.fetch({url:"".concat(e.origin).concat(l),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,o,t,s;if(null===(o=null===(i=a.Authorization)||void 0===i?void 0:i.replace("Bearer",""))||void 0===o?void 0:o.trim())return e;if(("object"==typeof n?n:U(n)||"").access_token)return e;var r=new URL(e);return"/web"===r.pathname&&(null===(t=this.config.auth)||void 0===t?void 0:t.secretId)&&(null===(s=this.config.auth)||void 0===s?void 0:s.secretKey)&&(r.pathname=p),r.toString()},e.prototype.createAbortController=function(e,a,n){var i,o=new AbortController;return n&&(n.aborted?o.abort():n.addEventListener("abort",function(){return o.abort()},{once:!0})),e&&(i=setTimeout(function(){var a="请求在".concat(e/1e3,"s内未完成,已中断");console.warn(a),o.abort(new Error(a))},e)),[o,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}(),ue=function(){return ue=Object.assign||function(e){for(var a,n=1,i=arguments.length;n<i;n++)for(var o in a=arguments[n])Object.prototype.hasOwnProperty.call(a,o)&&(e[o]=a[o]);return e},ue.apply(this,arguments)},de=function(e,a,n,i){return new(n||(n=Promise))(function(o,t){function s(e){try{c(i.next(e))}catch(e){t(e)}}function r(e){try{c(i.throw(e))}catch(e){t(e)}}function c(e){var a;e.done?o(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())})},me=function(e,a){var n,i,o,t,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return t={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function r(r){return function(c){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;t&&(t=0,r[0]&&(s=0)),s;)try{if(n=1,i&&(o=2&r[0]?i.return:r[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,r[1])).done)return o;switch(i=0,o&&(r=[2&r[0],o.value]),r[0]){case 0:case 1:o=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(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]<o[3])){s.label=r[1];break}if(6===r[0]&&s.label<o[1]){s.label=o[1],o=r;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(r);break}o[2]&&s.ops.pop(),s.trys.pop();continue}r=a.call(e,s)}catch(e){r=[6,e],i=0}finally{n=o=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,c])}}},fe="/.tencentcloudbase/wx/cloudbase_access_token",ve=6e5,xe={token:"",timestamp:0};function he(){var e=Z(),a=e.TRIGGER_SRC,n=e.WX_TRIGGER_API_TOKEN_V0,i=e.WX_API_TOKEN,o=e.WX_CLOUDBASE_ACCESSTOKEN,t=void 0===o?"":o,r={};return r.wxCloudApiToken="timer"===a?n||i||"":i||"",r.wxCloudApiToken||(r.wxCloudbaseAccesstoken=t||function(){if(xe.token&&Date.now()-xe.timestamp<ve)return xe.token;try{if(("WX_LOCAL_SCF"===process.env.TENCENTCLOUD_RUNENV||"SCF"===process.env.TENCENTCLOUD_RUNENV)&&s.existsSync(fe))return xe.token=s.readFileSync(fe).toString(),xe.timestamp=Date.now(),xe.token}catch(e){console.warn("[TCB][ERROR]: loadWxCloudbaseAccesstoken error: ",e)}return""}()),r}var be=0;function ge(e,a,n){var i="symbol"==typeof e.env?process.env.TCB_ENV||process.env.SCF_NAMESPACE||"":e.env||"",o=e.region||process.env.TENCENTCLOUD_REGION||"",t=function(){be+=1;var e="".concat(Date.now().toString(16),"_").concat(be.toString(16)),a=Z().TCB_SEQID,n=void 0===a?"":a;return n?"".concat(n,"-").concat(e):e}(),s=o?"".concat(o,".tcb-api.tencentcloudapi.com"):"tcb-api.tencentcloudapi.com",r=function(e){return/^[a-z][a-z0-9-]*[a-z0-9]$/.test(e)}(i)?"".concat(i,".").concat(s):s,c="".concat("https","://").concat(r).concat("/admin"),p=n||c,l=a?"env=".concat(i,"&seqId=").concat(t,"&scfRequestId=").concat(a.requestId):"env=".concat(i,"&seqId=").concat(t);return p.includes("?")?"".concat(p).concat(l):"".concat(p,"?").concat(l)}function ye(e){var a=Z(),n=he(),i=n.wxCloudApiToken,o=n.wxCloudbaseAccesstoken;e.wxCloudApiToken=i,o&&(e.wxCloudbaseAccesstoken=o),e.tcb_sessionToken=a.TCB_SESSIONTOKEN||""}function we(e,a,n,i){return de(this,void 0,void 0,function(){return me(this,function(o){return ye(n),[2,e.requestInstance.send(a,n,{pathname:"web",endPointMode:"GATEWAY"},i?{timeout:i.timeout}:void 0)]})})}function ke(e,a,n,o){return de(this,void 0,Promise,function(){var t,s,r,c,p,l,u,d;return me(this,function(m){switch(m.label){case 0:ye(n);try{t=i(1191)}catch(e){throw new Error("缺少依赖 form-data,请执行 npm install form-data")}for((s=new t).append("action",a),r=0,c=Object.keys(n);r<c.length;r++)p=c[r],void 0!==n[p]&&s.append(p,n[p]);return l=ue({action:a},n),s.__plainObj=l,u=ge(e.config,e.scfContext,e.serviceUrl),[4,e.requestInstance.post({url:u,body:s,headers:s.getHeaders(),responseType:"buffer"},o?{timeout:o.timeout}:void 0)];case 1:return(d=m.sent()).data?[2,d.data]:[2,d]}})})}function je(e,a){if(void 0===a&&(a={}),a.getCrossAccountInfo||e.getCrossAccountInfo)throw F(ue(ue({},c.INVALID_PARAM),{message:"invalid config: getCrossAccountInfo"}))}function _e(e,a,n,i){return{requestInstance:i,config:e,scfContext:a,serviceUrl:n}}function Ee(e,a,n){var i=a.apiName,o=a.apiOptions,t=a.cgiName,s=a.requestData;return de(this,void 0,void 0,function(){var a,r,p;return me(this,function(l){switch(l.label){case 0:try{a=s?JSON.stringify(s):""}catch(e){throw F(ue(ue({},e),{code:c.INVALID_PARAM.code,message:"对象出现了循环引用"}))}return je(e.config,n),[4,we(e,"wx.api",{apiName:i,apiOptions:o,cgiName:t,requestData:a},n)];case 1:if((r=l.sent()).code)return[2,r];try{p=JSON.parse(r.responseData)}catch(e){p=r.responseData}return[2,{result:p,requestId:r.requestId}]}})})}function Ae(e,a,n,i){var o=n.apiName,t=n.apiOptions,s=n.cgiName,r=n.requestData;return de(this,void 0,void 0,function(){return me(this,function(n){return je(a.config,i),[2,ke(a,e,{apiName:o,apiOptions:t,cgiName:s,requestData:r},i)]})})}var Se=function(e,a,n){return Ae("wx.openApi",e,a,n)},Oe=function(e,a,n){return Ae("wx.wxPayApi",e,a,n)},Ie=function(e,a,n){return Ae("wx.wxCallContainerApi",e,a,n)},Te=function(){return Te=Object.assign||function(e){for(var a,n=1,i=arguments.length;n<i;n++)for(var o in a=arguments[n])Object.prototype.hasOwnProperty.call(a,o)&&(e[o]=a[o]);return e},Te.apply(this,arguments)},Ce=function(e,a,n,i){return new(n||(n=Promise))(function(o,t){function s(e){try{c(i.next(e))}catch(e){t(e)}}function r(e){try{c(i.throw(e))}catch(e){t(e)}}function c(e){var a;e.done?o(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())})},Pe=function(e,a){var n,i,o,t,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return t={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function r(r){return function(c){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;t&&(t=0,r[0]&&(s=0)),s;)try{if(n=1,i&&(o=2&r[0]?i.return:r[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,r[1])).done)return o;switch(i=0,o&&(r=[2&r[0],o.value]),r[0]){case 0:case 1:o=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(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]<o[3])){s.label=r[1];break}if(6===r[0]&&s.label<o[1]){s.label=o[1],o=r;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(r);break}o[2]&&s.ops.pop(),s.trys.pop();continue}r=a.call(e,s)}catch(e){r=[6,e],i=0}finally{n=o=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,c])}}},Ne=null;function Re(){var e;return Ce(this,void 0,void 0,function(){var a;return Pe(this,function(n){switch(n.label){case 0:if(Ne)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,Promise.resolve().then(i.bind(i,9617))];case 2:return a=n.sent(),Ne=(null===(e=a.default)||void 0===e?void 0:e.sign)||a.sign,[3,4];case 3:return n.sent(),console.error("缺少依赖 jsonwebtoken,请执行以下命令安装:\n\n npm install jsonwebtoken\n\n该依赖用于 Node 环境下的自定义登录票据生成。"),[3,4];case 4:return[2,Ne]}})})}function Ue(){var e=Z();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 Le(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 qe=null,De=function(e,a){var n=a;if(e.parseContext=function(e){var a=Q(e);return qe=a,a},e.getCloudbaseContext=function(e){return Z(e)},e.auth){var i={getUserInfo:function(){return Ue()},getEndUserInfo:function(n){return Ce(this,void 0,Promise,function(){var i;return Pe(this,function(o){return i=Ue(),void 0===n?[2,{userInfo:i}]:(R(n),[2,Le(e,{uuid:n,envName:a.env}).then(function(e){return e.code?e:{userInfo:Te(Te({},i),e.data),requestId:e.requestId}})])})})},createTicket:function(e,n){return void 0===n&&(n={}),Ce(this,void 0,Promise,function(){var i,o,t,s,r,p,l,u,d;return Pe(this,function(m){switch(m.label){case 0:if(R(e),i=(new Date).getTime(),o=(a.auth||{}).credentials,!(t=a.env))throw Te(Te({},c.INVALID_PARAM),{message:"no env in config"});if(!(null==o?void 0:o.env_id))throw Te(Te({},c.INVALID_PARAM),{message:"当前私钥未包含env_id 信息, 请前往腾讯云云开发控制台,获取自定义登录最新私钥"});if(o.env_id!==t)throw Te(Te({},c.INVALID_PARAM),{message:"当前私钥所属环境与 init 指定环境不一致!"});return s=n.refresh,r=void 0===s?36e5:s,p=n.expire,l=void 0===p?i+6048e5:p,[4,Re()];case 1:return u=m.sent(),d=u({alg:"RS256",env:t,iat:i,exp:i+6e5,uid:e,refresh:r,expire:l},o.private_key,{allowInsecureKeySizes:!0,algorithm:"RS256"}),[2,"".concat(o.private_key_id,"/@@/").concat(d)]}})})},queryUserInfo:function(n){return Ce(this,void 0,Promise,function(){var i,o,t;return Pe(this,function(s){return i=n.uid,o=n.platform,t=n.platformId,[2,Le(e,{uuid:i,platform:o,platformId:t,envName:a.env}).then(function(e){return e.code?e:{userInfo:Te({},e.data),requestId:e.requestId}})]})})},getClientIP:function(){return Z().TCB_SOURCE_IP||""},getAuthContext:function(e){var a=Z(e),n=a.TCB_UUID,i=a.LOGINTYPE,o=a.QQ_OPENID,t=a.QQ_APPID,s={uid:n,loginType:i};return"QQ-MINI"===i&&(s.appId=t,s.openId=o),s},getClientCredential:function(i){return Ce(this,void 0,void 0,function(){var o;return Pe(this,function(t){switch(t.label){case 0:return n.accessKey||a.accessKey?[2,n.accessKey||a.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"}},i?{timeout:i.timeout}:void 0)]);case 1:return[2,t.sent().data]}})})}},o=e.auth;Object.keys(i).forEach(function(e){o[e]=i[e]}),e.auth=new Proxy(o,{apply:function(e,a,n){var o=Reflect.apply(e,a,n);return o&&"object"==typeof o&&Object.keys(i).forEach(function(e){e in o||(o[e]=i[e])}),o}})}function t(){var a=n.serviceUrl||ae()||void 0;return _e(n,qe,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 Ee(t(),e,a)},e.callWxPayApi=function(e,a){return Oe(t(),e,a)},e.wxCallContainerApi=function(e,a){return Ie(t(),e,a)},e.callCompatibleWxOpenApi=function(e,a){return Se(t(),e,a)},e.getFileAuthority=function(a,n){var i=a.fileList;return Ce(void 0,void 0,void 0,function(){var a,o,t,s,r,p;return Pe(this,function(l){switch(l.label){case 0:if(a=Z().LOGINTYPE,!Array.isArray(i))throw F(Te(Te({},c.INVALID_PARAM),{message:"[js-sdk] getCosFileAuthority fileList must be a array"}));if(i.some(function(e){return!(null==e?void 0:e.path)||!["READ","WRITE","READWRITE"].includes(e.type)}))throw F(Te(Te({},c.INVALID_PARAM),{message:"[js-sdk] getCosFileAuthority fileList param error"}));return[4,e.auth.getEndUserInfo()];case 1:if(o=l.sent().userInfo,t=o.openId,s=o.uid,!t&&!s)throw F(Te(Te({},c.INVALID_PARAM),{message:"[js-sdk] admin do not need getCosFileAuthority."}));return r={openId:t,uid:s,loginType:a,fileList:i},[4,e.request.send("storage.getFileAuthority",r,{pathname:"web",endPointMode:"GATEWAY"},n?{timeout:n.timeout}:void 0)];case 2:if((p=l.sent()).code)throw F(Te(Te({},p),{message:"[js-sdk] getCosFileAuthority failed: ".concat(p.code)}));return[2,p]}})})},e.callApis=function(a,n){return Ce(void 0,void 0,void 0,function(){var i,o,t,s,r,c,p,l,u,d,m,f;return Pe(this,function(v){if(e.apis)return i=a.name,o=a.path,t=void 0===o?"":o,s=a.method,r=void 0===s?"POST":s,c=a.header,p=void 0===c?{}:c,l=a.body,u=a.token,d=(r||"POST").toLowerCase(),[2,null===(f=null===(m=e.apis[i])||void 0===m?void 0:m[d])||void 0===f?void 0:f.call(m,{path:t,method:r,headers:p,body:l,token:u},n)];throw new Error("callApis is not supported in current configuration")})})}},ze=function(){return ze=Object.assign||function(e){for(var a,n=1,i=arguments.length;n<i;n++)for(var o in a=arguments[n])Object.prototype.hasOwnProperty.call(a,o)&&(e[o]=a[o]);return e},ze.apply(this,arguments)},Fe=null;function Me(){if(!Fe)try{Fe=i(9814)}catch(e){console.error("缺少依赖 ws,请执行以下命令安装:\n\n npm install ws\n\n该依赖用于 Node 环境下的 WebSocket 连接。")}return Fe}var Be,We=(Be=new Map,{mode:"sync",setItem:function(e,a){Be.set(e,a)},getItem:function(e){return Be.get(e)},removeItem:function(e){Be.delete(e)},clear:function(){Be.clear()}});const Ke={genAdapter:function(e){return{nodeTool:De,getSecretInfo:ie,root:{globalThis:{}},reqClass:le,wsClass:Me(),sessionStorage:We,localStorage:We,primaryStorage:t.StorageType.session,captchaOptions:{openURIWithCallback:function(a){var n=e.EventBus,i={},o=a,t=a.match(/^(data:.*?)(\?[^#\s]*)?$/);if(t){o=t[1];var s=t[2];s&&(i=q(s))}var r=i.token,c=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 o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)a.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}(i,["token"]);return/^data:/.test(o)&&!r?Promise.reject({error:"invalid_argument",error_description:"invalie captcha data: ".concat(a)}):r?new Promise(function(e){n.$emit("CAPTCHA_DATA_CHANGE",ze(ze({},c),{token:r,url:o})),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"}},2976:(e,n,i)=>{i.d(n,{j$:()=>s,Fs:()=>r,_G:()=>o,BM:()=>p,RR:()=>c,P6:()=>t});var o={};i.r(o),i.d(o,{vM:()=>x,Sg:()=>h,Fk:()=>v,eX:()=>d,pM:()=>f,tC:()=>u});var t={};i.r(t),i.d(t,{createPromiseCallback:()=>R,execCallback:()=>U,formatUrl:()=>I,genSeqId:()=>S,generateRequestId:()=>O,getHash:()=>P,getQuery:()=>C,isArray:()=>y,isFormData:()=>A,isInstanceOf:()=>E,isNull:()=>_,isPalinObject:()=>j,isString:()=>w,isUndefined:()=>k,parseCaptcha:()=>K,parseQueryString:()=>W,printError:()=>q,printGroupLog:()=>F,printInfo:()=>D,printWarn:()=>L,removeParam:()=>N,sleep:()=>M,throwError:()=>z,toQueryString:()=>T,transformPhone:()=>B});var s={};i.r(s),i.d(s,{Fk:()=>Z,xY:()=>ee});var r={};i.r(r),i.d(r,{q:()=>te});var c={};i.r(c),i.d(c,{P:()=>ue,$:()=>le});var p={};i.r(p),i.d(p,{D:()=>he});var l="@cloudbase/js-sdk";function u(e){l=e}function d(){return l}var m="https:";function f(e){m=e}var v=("undefined"==typeof process||process.env,!1),x="https://support.qq.com/products/148793",h={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"},b=i(7149),g=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 o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)a.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n};function y(e){return"[object Array]"===Object.prototype.toString.call(e)}function w(e){return"string"==typeof e}function k(e){return void 0===e}function j(e){return"[object Object]"===Object.prototype.toString.call(e)}function _(e){return"[object Null]"===Object.prototype.toString.call(e)}function E(e,a){return e instanceof a}function A(e){return"[object FormData]"===Object.prototype.toString.call(e)}function S(){return Math.random().toString(16).slice(2)}function O(){var e=(new Date).getTime(),a=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var i=16*Math.random();return e>0?(i=(e+i)%16|0,e=Math.floor(e/16)):(i=(a+i)%16|0,a=Math.floor(a/16)),("x"===n?i:7&i|8).toString(16)})}function I(e,a,n){void 0===n&&(n={});var i=/\?/.test(a),o="";return Object.keys(n).forEach(function(e){""===o?!i&&(a+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(n[e]))}),/^http(s)?:\/\//.test(a+=o)?a:"".concat(e).concat(a)}function T(e){void 0===e&&(e={});var a=[];return Object.keys(e).forEach(function(n){a.push("".concat(n,"=").concat(encodeURIComponent(e[n])))}),a.join("&")}function C(e,a){if("undefined"==typeof window)return!1;var n=a||decodeURIComponent(window.location.search),i=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=n.substr(n.indexOf("?")+1).match(i);return null!=o?o[2]:""}var P=function(e){if("undefined"==typeof window)return"";var a=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return a?a[1]:""};function N(e,a){var n=a.split("?")[0],i=[],o=-1!==a.indexOf("?")?a.split("?")[1]:"";if(""!==o){for(var t=(i=o.split("&")).length-1;t>=0;t-=1)i[t].split("=")[0]===e&&i.splice(t,1);n="".concat(n,"?").concat(i.join("&"))}return n}function R(){var e={};if(!Promise){(e=function(){}).promise={};var a=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:a}),Object.defineProperty(e.promise,"catch",{get:a}),e}var n=new Promise(function(a,n){e=function(e,i){return e?n(e):a(i)}});return e.promise=n,e}function U(e,a,n){if(void 0===n&&(n=null),e&&"function"==typeof e)return e(a,n);if(a)throw a;return n}function L(e,a){console.warn("[".concat(d(),"][").concat(e,"]:").concat(a))}function q(e,a){console.error({code:e,msg:"[".concat(d(),"][").concat(e,"]:").concat(a)})}function D(e,a){console.log("[".concat(d(),"][").concat(e,"]:").concat(a))}function z(e,a){throw new Error(JSON.stringify({code:e,msg:"[".concat(d(),"][").concat(e,"]:").concat(a)}))}function F(e){var a,n=e.title,i=e.subtitle,o=void 0===i?"":i,t=e.content,s=void 0===t?[]:t,r=e.printTrace,c=void 0!==r&&r,p=e.collapsed;void 0!==p&&p?(console.groupCollapsed||console.error)(n,o):(console.group||console.error)(n,o);for(var l=0,u=s;l<u.length;l++){var d=u[l],m=d.type,f=d.body;switch(m){case"info":console.log(f);break;case"warn":console.warn(f);break;case"error":console.error(f)}}c&&(console.trace||console.log)("stack trace:"),null===(a=console.groupEnd)||void 0===a||a.call(console)}var M=function(e){return void 0===e&&(e=0),new Promise(function(a){return setTimeout(a,e)})};function B(e){return"+86".concat(e)}var W=function(e){e=e.replace(/^\?/,"");var a={};return e.split("&").forEach(function(e){var n=e.split("="),i=n[0],o=n[1];i=decodeURIComponent(i),o=decodeURIComponent(o),i&&(a[i]?Array.isArray(a[i])?a[i].push(o):a[i]=[a[i],o]:a[i]=o)}),a};function K(e){var a={},n=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(n){e=n[1];var i=n[2];i&&(a=W(i))}var o=a.token,t=g(a,["token"]);return/^data:/.test(e)&&!o?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:o?{state:t.state,token:o,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}var V,G,X=(V=function(e,a){return V=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])},V(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}V(e,a),e.prototype=null===a?Object.create(a):(n.prototype=a.prototype,new n)}),Y=function(){return Y=Object.assign||function(e){for(var a,n=1,i=arguments.length;n<i;n++)for(var o in a=arguments[n])Object.prototype.hasOwnProperty.call(a,o)&&(e[o]=a[o]);return e},Y.apply(this,arguments)},H=function(e,a,n,i){return new(n||(n=Promise))(function(o,t){function s(e){try{c(i.next(e))}catch(e){t(e)}}function r(e){try{c(i.throw(e))}catch(e){t(e)}}function c(e){var a;e.done?o(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())})},J=function(e,a){var n,i,o,t,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return t={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function r(r){return function(c){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;t&&(t=0,r[0]&&(s=0)),s;)try{if(n=1,i&&(o=2&r[0]?i.return:r[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,r[1])).done)return o;switch(i=0,o&&(r=[2&r[0],o.value]),r[0]){case 0:case 1:o=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(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]<o[3])){s.label=r[1];break}if(6===r[0]&&s.label<o[1]){s.label=o[1],o=r;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(r);break}o[2]&&s.ops.pop(),s.trys.pop();continue}r=a.call(e,s)}catch(e){r=[6,e],i=0}finally{n=o=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,c])}}},$=function(e){function a(a){var n=e.call(this)||this,i=a.timeout,o=a.timeoutMsg,t=a.restrictedMethods;return n.timeout=i||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=t||["get","post","upload","download"],n}return X(a,e),a.prototype.get=function(e){return this.request(Y(Y({},e),{method:"get"}),this.restrictedMethods.includes("get"))},a.prototype.post=function(e){return this.request(Y(Y({},e),{method:"post"}),this.restrictedMethods.includes("post"))},a.prototype.put=function(e){return this.request(Y(Y({},e),{method:"put"}))},a.prototype.upload=function(e){var a=e.data,n=e.file,i=e.name,o=e.method,t=e.headers,s=void 0===t?{}:t,r={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",c=new FormData;return"post"===r?(Object.keys(a).forEach(function(e){c.append(e,a[e])}),c.append("key",i),c.append("file",n),this.request(Y(Y({},e),{data:c,method:r}),this.restrictedMethods.includes("upload"))):this.request(Y(Y({},e),{method:"put",headers:s,body:n}),this.restrictedMethods.includes("upload"))},a.prototype.download=function(e){return H(this,void 0,Promise,function(){var a,n,i,o;return J(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.get(Y(Y({},e),{headers:{},responseType:"blob"}))];case 1:return a=t.sent().data,n=window.URL.createObjectURL(new Blob([a])),i=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",i),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeC