@uni2c/graphqlapi4mp 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -29,7 +29,7 @@ var Z={};(Z.asn1===void 0||!Z.asn1)&&(Z.asn1={}),Z.asn1.ASN1Util=new function(){
29
29
  `;return e+=t.wordwrap(this.getPrivateBaseKeyB64())+`
30
30
  `,e+=`-----END RSA PRIVATE KEY-----`,e},t.prototype.getPublicKey=function(){var e=`-----BEGIN PUBLIC KEY-----
31
31
  `;return e+=t.wordwrap(this.getPublicBaseKeyB64())+`
32
- `,e+=`-----END PUBLIC KEY-----`,e},t.hasPublicKeyProperty=function(e){return e||={},e.hasOwnProperty(`n`)&&e.hasOwnProperty(`e`)},t.hasPrivateKeyProperty=function(e){return e||={},e.hasOwnProperty(`n`)&&e.hasOwnProperty(`e`)&&e.hasOwnProperty(`d`)&&e.hasOwnProperty(`p`)&&e.hasOwnProperty(`q`)&&e.hasOwnProperty(`dmp1`)&&e.hasOwnProperty(`dmq1`)&&e.hasOwnProperty(`coeff`)},t.prototype.parsePropertiesFrom=function(e){this.n=e.n,this.e=e.e,e.hasOwnProperty(`d`)&&(this.d=e.d,this.p=e.p,this.q=e.q,this.dmp1=e.dmp1,this.dmq1=e.dmq1,this.coeff=e.coeff)},t}(Ue),Ze=`3.2.1`,Qe=function(){function e(e){e===void 0&&(e={}),e||={},this.default_key_size=e.default_key_size?parseInt(e.default_key_size,10):1024,this.default_public_exponent=e.default_public_exponent||`010001`,this.log=e.log||!1,this.key=null}return e.prototype.setKey=function(e){this.log&&this.key&&console.warn(`A key was already set, overriding existing.`),this.key=new Xe(e)},e.prototype.setPrivateKey=function(e){this.setKey(e)},e.prototype.setPublicKey=function(e){this.setKey(e)},e.prototype.decrypt=function(e){try{return this.getKey().decrypt(ve(e))}catch{return!1}},e.prototype.encrypt=function(e){try{return M(this.getKey().encrypt(e))}catch{return!1}},e.prototype.encryptLong=function(e){try{return M(this.getKey().encryptLong(e))}catch{return!1}},e.prototype.decryptLong=function(e){try{return this.getKey().decryptLong(ve(e))}catch{return!1}},e.prototype.sign=function(e,t,n){try{return M(this.getKey().sign(e,t,n))}catch{return!1}},e.prototype.verify=function(e,t,n){try{return this.getKey().verify(e,ve(t),n)}catch{return!1}},e.prototype.getKey=function(e){if(!this.key){if(this.key=new Xe,e&&{}.toString.call(e)===`[object Function]`){this.key.generateAsync(this.default_key_size,this.default_public_exponent,e);return}this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},e.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},e.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},e.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},e.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},e.version=Ze,e}();const Q=globalThis,$e=new Qe;let $={};const et=()=>e(new Date().getTime()+pt(32));function tt(e){$=Object.assign({PROD:!1,VITE_SALT_KEY:``,VITE_PUBLIC_KEY:``},e);let t=$.VITE_PUBLIC_KEY;$e.setPublicKey(typeof t==`string`?t.replace(/\\r\\n/g,`
32
+ `,e+=`-----END PUBLIC KEY-----`,e},t.hasPublicKeyProperty=function(e){return e||={},e.hasOwnProperty(`n`)&&e.hasOwnProperty(`e`)},t.hasPrivateKeyProperty=function(e){return e||={},e.hasOwnProperty(`n`)&&e.hasOwnProperty(`e`)&&e.hasOwnProperty(`d`)&&e.hasOwnProperty(`p`)&&e.hasOwnProperty(`q`)&&e.hasOwnProperty(`dmp1`)&&e.hasOwnProperty(`dmq1`)&&e.hasOwnProperty(`coeff`)},t.prototype.parsePropertiesFrom=function(e){this.n=e.n,this.e=e.e,e.hasOwnProperty(`d`)&&(this.d=e.d,this.p=e.p,this.q=e.q,this.dmp1=e.dmp1,this.dmq1=e.dmq1,this.coeff=e.coeff)},t}(Ue),Ze=`3.2.1`,Qe=function(){function e(e){e===void 0&&(e={}),e||={},this.default_key_size=e.default_key_size?parseInt(e.default_key_size,10):1024,this.default_public_exponent=e.default_public_exponent||`010001`,this.log=e.log||!1,this.key=null}return e.prototype.setKey=function(e){this.log&&this.key&&console.warn(`A key was already set, overriding existing.`),this.key=new Xe(e)},e.prototype.setPrivateKey=function(e){this.setKey(e)},e.prototype.setPublicKey=function(e){this.setKey(e)},e.prototype.decrypt=function(e){try{return this.getKey().decrypt(ve(e))}catch{return!1}},e.prototype.encrypt=function(e){try{return M(this.getKey().encrypt(e))}catch{return!1}},e.prototype.encryptLong=function(e){try{return M(this.getKey().encryptLong(e))}catch{return!1}},e.prototype.decryptLong=function(e){try{return this.getKey().decryptLong(ve(e))}catch{return!1}},e.prototype.sign=function(e,t,n){try{return M(this.getKey().sign(e,t,n))}catch{return!1}},e.prototype.verify=function(e,t,n){try{return this.getKey().verify(e,ve(t),n)}catch{return!1}},e.prototype.getKey=function(e){if(!this.key){if(this.key=new Xe,e&&{}.toString.call(e)===`[object Function]`){this.key.generateAsync(this.default_key_size,this.default_public_exponent,e);return}this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},e.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},e.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},e.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},e.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},e.version=Ze,e}();const Q=globalThis,$e=new Qe;let $={};const et=()=>e(new Date().getTime()+pt(32));function tt(e){$=Object.assign({PROD:!1,VITE_SALT_KEY:``,VITE_PUBLIC_KEY:``},e);let t=$.VITE_PUBLIC_KEY;$e.setPublicKey(typeof t==`string`?t.trim().replace(/^["']|["']$/g,``).replace(/\\r\\n/g,`
33
33
  `).replace(/\\n/g,`
34
34
  `).trim():``)}function nt(e){let t=encodeURIComponent(e),n=[];for(let e=0;e<t.length;e++)t.charCodeAt(e)===37?(n.push(parseInt(t.slice(e+1,e+3),16)),e+=2):n.push(t.charCodeAt(e));return new Uint8Array(n)}function rt(e){let t=``;for(let n=0;n<e.length;n++)t+=`%${e[n].toString(16).padStart(2,`0`)}`;return decodeURIComponent(t)}function it(e){let t=e.slice().buffer;if(Q.wx?.arrayBufferToBase64)return Q.wx.arrayBufferToBase64(t);if(Q.uni?.arrayBufferToBase64)return Q.uni.arrayBufferToBase64(t);let n=``;for(let t=0;t<e.length;t++)n+=String.fromCharCode(e[t]);return Q.btoa(n)}function at(e){if(Q.wx?.base64ToArrayBuffer)return new Uint8Array(Q.wx.base64ToArrayBuffer(e));if(Q.uni?.base64ToArrayBuffer)return new Uint8Array(Q.uni.base64ToArrayBuffer(e));let t=Q.atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function ot(e,t){let n=nt(e),r=nt(t);if(n.length!==16||r.length!==16)throw Error(`AES-128 key 和 iv 必须都是 16 bytes`);return le(n,r)}function st(e,t,n){return it(ot(t,n).encrypt(nt(e)))}function ct(e,t,n){return rt(ot(t,n).decrypt(at(e)))}function lt(e,t){if(typeof t!=`string`||!/^[\x00-\x7f]{32}$/.test(t))throw Error(`password 必须由 32 个 ASCII 字符组成`);if(!$.VITE_PUBLIC_KEY)throw Error(`请先调用 setEnv 并配置 VITE_PUBLIC_KEY`);let n=$e.getKey();if(!n.n||!n.e)throw Error(`VITE_PUBLIC_KEY 解析失败,请检查 RSA PEM 公钥格式`);let r=n.encrypt(t);if(!r)throw Error(`RSA 加密失败,请检查公钥长度`);let i=M(r);return{value:st(JSON.stringify(e),t.substring(0,16),t.substring(16)),key:i}}function ut(e,t){if(e.data){e.data=ct(e.data,t.substring(0,16),t.substring(16));try{e.data=JSON.parse(e.data||`{}`)}catch(e){console.error(e)}}return e}function dt(e){if(typeof e==`string`)return ft(e);if(e&&typeof e==`object`){let t=[];for(let n of Object.keys(e))e[n]&&t.push(`${n}=${e[n]}`);return ft(t.join(`&`))}return``}function ft(t){return e(`${t.split(`&`).sort().join(`&`)}&key=${$?.VITE_SALT_KEY}`)}function pt(e){let t=``;for(;e--;)t+=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`[Math.floor(Math.random()*62)];return t}function mt(e){return it(nt(e))}function ht(e){return rt(at(e))}function gt(e,t){let n=JSON.parse(JSON.stringify(e)),r=dt(n.data.variables);return n.data.variables.sign=r,$?.PROD&&(n.data=lt(n.data,t)),n}function _t(e,t,n){function r(e,t){if(typeof e!=`object`||!e||Array.isArray(e))return e;let n={...e};for(let r of Object.keys(e))Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=i(e[r],t[r].type));return n}function i(e,t){if(e==null)return e;let a=t.endsWith(`!`)?t.slice(0,-1):t;if(a.startsWith(`[`)&&a.endsWith(`]`))return Array.isArray(e)?e.map(e=>i(e,a.slice(1,-1))):e;switch(a){case`JsonString`:if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}case`Int`:case`Float`:{if(typeof e!=`number`&&typeof e!=`string`||typeof e==`string`&&e.trim()===``)return e;let t=Number(e);return Number.isFinite(t)&&(a!==`Int`||Number.isSafeInteger(t))?t:e}case`Boolean`:return e===`false`||e===`0`||e===0?!1:e===`true`||e===`1`||e===1||e;case`String`:case`ID`:return typeof e==`number`||typeof e==`boolean`?String(e):e;default:{let t=n?.types,i=t&&Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0;return i?r(e,i.fields):e}}}return e.map(e=>t?r(e,t):{...e})}const vt=Object.freeze(Object.create(null)),yt=e=>e===95||e>=65&&e<=90||e>=97&&e<=122,bt=e=>yt(e)||e>=48&&e<=57,xt=e=>e>=48&&e<=57,St=Object.create(null);function Ct(e){let t=+(e.charCodeAt(0)===65279),n=e.length,r,i=Object.create(null),a=new Set([`String`,`Int`,`Float`,`Boolean`,`ID`]),o=new Set;function s(){for(;;){if(t>=n)return;let r=e.charCodeAt(t);if(r===32||r===9||r===10||r===13||r===44){t++;continue}if(r===35){for(;++t<n;){let n=e.charCodeAt(t);if(n===10||n===13)break}continue}if(r===34&&e.charCodeAt(t+1)===34&&e.charCodeAt(t+2)===34){for(t+=3;t<n;){if(e.charCodeAt(t)===34&&e.charCodeAt(t+1)===34&&e.charCodeAt(t+2)===34){t+=3;break}t+=e.charCodeAt(t)===92?2:1}continue}if(r===34){for(t++;t<n;){let n=e.charCodeAt(t++);if(n===92)t++;else if(n===34)break}return`\0s`}if(yt(r)){let r=t++;for(;t<n&&bt(e.charCodeAt(t));)t++;return e.slice(r,t)}if(xt(r)||r===45&&xt(e.charCodeAt(t+1))){for(t++;t<n;){let n=e.charCodeAt(t);if(xt(n)||n===46||n===101||n===69||n===43||n===45)t++;else break}return`\0n`}if(r===46&&e.charCodeAt(t+1)===46&&e.charCodeAt(t+2)===46)return t+=3,`...`;if(r===123||r===125||r===40||r===41||r===91||r===93||r===58||r===33||r===61||r===36||r===64||r===124||r===38)return t++,String.fromCharCode(r);t++}}let c=()=>r??=s(),l=()=>{let e=r??s();return r=void 0,e},u=e=>c()===e&&(l(),!0),d=e=>{let t=l();if(t!==e)throw Error(`parseSDL: expected "${e}", got "${t??`EOF`}"`)},f=()=>{let e=l();if(!e||e===`\0s`||e===`\0n`||!yt(e.charCodeAt(0)))throw Error(`parseSDL: expected NAME, got "${e??`EOF`}"`);return e};function p(){if(u(`[`)){let e=`[${p()}]`;return d(`]`),u(`!`)&&(e+=`!`),e}let e=f();return u(`!`)&&(e+=`!`),e}function m(){if(u(`[`)){for(;c()&&c()!==`]`;)m();d(`]`);return}if(u(`{`)){for(;c()&&c()!==`}`;)f(),d(`:`),m();d(`}`);return}l()}function h(){for(;u(`@`);){if(f(),!u(`(`))continue;let e=1;for(;e&&c();)u(`(`)?e++:u(`)`)?e--:l()}}function g(){if(!u(`(`))return vt;let e=Object.create(null);for(;c()&&c()!==`)`;){let t=f();d(`:`),e[t]=p(),u(`=`)&&m(),h()}return d(`)`),e}function _(){let e=Object.create(null);for(d(`{`);c()&&c()!==`}`;){let t=f(),n=g();d(`:`);let r=p();h(),e[t]={name:t,args:n,type:r}}return d(`}`),e}function v(){let e=f();if(u(`implements`))for(u(`&`);c()&&c()!==`{`;)l();h(),c()===`{`&&(i[e]={name:e,fields:_()})}function y(){a.add(f()),h()}function b(){if(o.add(f()),h(),u(`{`)){for(;c()&&c()!==`}`;)l(),h();d(`}`)}}for(;c();)switch(l()){case`type`:v();break;case`scalar`:y();break;case`enum`:b()}return{query:i.Query?.fields||{},mutation:i.Mutation?.fields||{},types:i,scalars:a,enums:o}}function wt(e){let t=0,n=e.length,r=e.charCodeAt(0),i=e.charCodeAt(n-1);if(r!==91&&r!==33&&i!==93&&i!==33)return e;let a=St[e];if(a)return a;for(;t<n;){let n=e.charCodeAt(t);if(n!==91&&n!==33)break;t++}for(;n>t;){let t=e.charCodeAt(n-1);if(t!==93&&t!==33)break;n--}let o=e.slice(t,n);return St[e]=o,o}function Tt(e,t,n={}){let r=e.types[wt(t.type)];if(!r)return[];let i=[],a=r.fields;for(let t in a){let r=a[t],o=n[t];if(o!==!1){if(!e.types[wt(r.type)]){i.push(t);continue}o!==void 0&&i.push({name:t,fields:Tt(e,r,o===!0?{}:o)})}}return i}function Et(e,t=` `){let n=``;for(let r of e){if(n&&(n+=`
35
35
  `),typeof r==`string`){n+=t+r;continue}let e=Et(r.fields,t+` `);n+=e?`${t}${r.name} {\n${e}\n${t}}`:t+r.name}return n}function Dt(e,t=`query`){let{name:n,args:r=vt,fields:i=[]}=e,a=``,o=``;for(let e in r)a&&(a+=`, `),a+=`$${e}: ${r[e]}`,o+=`${o?`
package/dist/index.mjs CHANGED
@@ -29,7 +29,7 @@ var Z={};(Z.asn1===void 0||!Z.asn1)&&(Z.asn1={}),Z.asn1.ASN1Util=new function(){
29
29
  `;return e+=t.wordwrap(this.getPrivateBaseKeyB64())+`
30
30
  `,e+=`-----END RSA PRIVATE KEY-----`,e},t.prototype.getPublicKey=function(){var e=`-----BEGIN PUBLIC KEY-----
31
31
  `;return e+=t.wordwrap(this.getPublicBaseKeyB64())+`
32
- `,e+=`-----END PUBLIC KEY-----`,e},t.hasPublicKeyProperty=function(e){return e||={},e.hasOwnProperty(`n`)&&e.hasOwnProperty(`e`)},t.hasPrivateKeyProperty=function(e){return e||={},e.hasOwnProperty(`n`)&&e.hasOwnProperty(`e`)&&e.hasOwnProperty(`d`)&&e.hasOwnProperty(`p`)&&e.hasOwnProperty(`q`)&&e.hasOwnProperty(`dmp1`)&&e.hasOwnProperty(`dmq1`)&&e.hasOwnProperty(`coeff`)},t.prototype.parsePropertiesFrom=function(e){this.n=e.n,this.e=e.e,e.hasOwnProperty(`d`)&&(this.d=e.d,this.p=e.p,this.q=e.q,this.dmp1=e.dmp1,this.dmq1=e.dmq1,this.coeff=e.coeff)},t}(Ue),Ze=`3.2.1`,Qe=function(){function e(e){e===void 0&&(e={}),e||={},this.default_key_size=e.default_key_size?parseInt(e.default_key_size,10):1024,this.default_public_exponent=e.default_public_exponent||`010001`,this.log=e.log||!1,this.key=null}return e.prototype.setKey=function(e){this.log&&this.key&&console.warn(`A key was already set, overriding existing.`),this.key=new Xe(e)},e.prototype.setPrivateKey=function(e){this.setKey(e)},e.prototype.setPublicKey=function(e){this.setKey(e)},e.prototype.decrypt=function(e){try{return this.getKey().decrypt(ve(e))}catch{return!1}},e.prototype.encrypt=function(e){try{return M(this.getKey().encrypt(e))}catch{return!1}},e.prototype.encryptLong=function(e){try{return M(this.getKey().encryptLong(e))}catch{return!1}},e.prototype.decryptLong=function(e){try{return this.getKey().decryptLong(ve(e))}catch{return!1}},e.prototype.sign=function(e,t,n){try{return M(this.getKey().sign(e,t,n))}catch{return!1}},e.prototype.verify=function(e,t,n){try{return this.getKey().verify(e,ve(t),n)}catch{return!1}},e.prototype.getKey=function(e){if(!this.key){if(this.key=new Xe,e&&{}.toString.call(e)===`[object Function]`){this.key.generateAsync(this.default_key_size,this.default_public_exponent,e);return}this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},e.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},e.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},e.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},e.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},e.version=Ze,e}();const Q=globalThis,$e=new Qe;let $={};const et=()=>e(new Date().getTime()+pt(32));function tt(e){$=Object.assign({PROD:!1,VITE_SALT_KEY:``,VITE_PUBLIC_KEY:``},e);let t=$.VITE_PUBLIC_KEY;$e.setPublicKey(typeof t==`string`?t.replace(/\\r\\n/g,`
32
+ `,e+=`-----END PUBLIC KEY-----`,e},t.hasPublicKeyProperty=function(e){return e||={},e.hasOwnProperty(`n`)&&e.hasOwnProperty(`e`)},t.hasPrivateKeyProperty=function(e){return e||={},e.hasOwnProperty(`n`)&&e.hasOwnProperty(`e`)&&e.hasOwnProperty(`d`)&&e.hasOwnProperty(`p`)&&e.hasOwnProperty(`q`)&&e.hasOwnProperty(`dmp1`)&&e.hasOwnProperty(`dmq1`)&&e.hasOwnProperty(`coeff`)},t.prototype.parsePropertiesFrom=function(e){this.n=e.n,this.e=e.e,e.hasOwnProperty(`d`)&&(this.d=e.d,this.p=e.p,this.q=e.q,this.dmp1=e.dmp1,this.dmq1=e.dmq1,this.coeff=e.coeff)},t}(Ue),Ze=`3.2.1`,Qe=function(){function e(e){e===void 0&&(e={}),e||={},this.default_key_size=e.default_key_size?parseInt(e.default_key_size,10):1024,this.default_public_exponent=e.default_public_exponent||`010001`,this.log=e.log||!1,this.key=null}return e.prototype.setKey=function(e){this.log&&this.key&&console.warn(`A key was already set, overriding existing.`),this.key=new Xe(e)},e.prototype.setPrivateKey=function(e){this.setKey(e)},e.prototype.setPublicKey=function(e){this.setKey(e)},e.prototype.decrypt=function(e){try{return this.getKey().decrypt(ve(e))}catch{return!1}},e.prototype.encrypt=function(e){try{return M(this.getKey().encrypt(e))}catch{return!1}},e.prototype.encryptLong=function(e){try{return M(this.getKey().encryptLong(e))}catch{return!1}},e.prototype.decryptLong=function(e){try{return this.getKey().decryptLong(ve(e))}catch{return!1}},e.prototype.sign=function(e,t,n){try{return M(this.getKey().sign(e,t,n))}catch{return!1}},e.prototype.verify=function(e,t,n){try{return this.getKey().verify(e,ve(t),n)}catch{return!1}},e.prototype.getKey=function(e){if(!this.key){if(this.key=new Xe,e&&{}.toString.call(e)===`[object Function]`){this.key.generateAsync(this.default_key_size,this.default_public_exponent,e);return}this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},e.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},e.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},e.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},e.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},e.version=Ze,e}();const Q=globalThis,$e=new Qe;let $={};const et=()=>e(new Date().getTime()+pt(32));function tt(e){$=Object.assign({PROD:!1,VITE_SALT_KEY:``,VITE_PUBLIC_KEY:``},e);let t=$.VITE_PUBLIC_KEY;$e.setPublicKey(typeof t==`string`?t.trim().replace(/^["']|["']$/g,``).replace(/\\r\\n/g,`
33
33
  `).replace(/\\n/g,`
34
34
  `).trim():``)}function nt(e){let t=encodeURIComponent(e),n=[];for(let e=0;e<t.length;e++)t.charCodeAt(e)===37?(n.push(parseInt(t.slice(e+1,e+3),16)),e+=2):n.push(t.charCodeAt(e));return new Uint8Array(n)}function rt(e){let t=``;for(let n=0;n<e.length;n++)t+=`%${e[n].toString(16).padStart(2,`0`)}`;return decodeURIComponent(t)}function it(e){let t=e.slice().buffer;if(Q.wx?.arrayBufferToBase64)return Q.wx.arrayBufferToBase64(t);if(Q.uni?.arrayBufferToBase64)return Q.uni.arrayBufferToBase64(t);let n=``;for(let t=0;t<e.length;t++)n+=String.fromCharCode(e[t]);return Q.btoa(n)}function at(e){if(Q.wx?.base64ToArrayBuffer)return new Uint8Array(Q.wx.base64ToArrayBuffer(e));if(Q.uni?.base64ToArrayBuffer)return new Uint8Array(Q.uni.base64ToArrayBuffer(e));let t=Q.atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function ot(e,t){let n=nt(e),r=nt(t);if(n.length!==16||r.length!==16)throw Error(`AES-128 key 和 iv 必须都是 16 bytes`);return le(n,r)}function st(e,t,n){return it(ot(t,n).encrypt(nt(e)))}function ct(e,t,n){return rt(ot(t,n).decrypt(at(e)))}function lt(e,t){if(typeof t!=`string`||!/^[\x00-\x7f]{32}$/.test(t))throw Error(`password 必须由 32 个 ASCII 字符组成`);if(!$.VITE_PUBLIC_KEY)throw Error(`请先调用 setEnv 并配置 VITE_PUBLIC_KEY`);let n=$e.getKey();if(!n.n||!n.e)throw Error(`VITE_PUBLIC_KEY 解析失败,请检查 RSA PEM 公钥格式`);let r=n.encrypt(t);if(!r)throw Error(`RSA 加密失败,请检查公钥长度`);let i=M(r);return{value:st(JSON.stringify(e),t.substring(0,16),t.substring(16)),key:i}}function ut(e,t){if(e.data){e.data=ct(e.data,t.substring(0,16),t.substring(16));try{e.data=JSON.parse(e.data||`{}`)}catch(e){console.error(e)}}return e}function dt(e){if(typeof e==`string`)return ft(e);if(e&&typeof e==`object`){let t=[];for(let n of Object.keys(e))e[n]&&t.push(`${n}=${e[n]}`);return ft(t.join(`&`))}return``}function ft(t){return e(`${t.split(`&`).sort().join(`&`)}&key=${$?.VITE_SALT_KEY}`)}function pt(e){let t=``;for(;e--;)t+=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`[Math.floor(Math.random()*62)];return t}function mt(e){return it(nt(e))}function ht(e){return rt(at(e))}function gt(e,t){let n=JSON.parse(JSON.stringify(e)),r=dt(n.data.variables);return n.data.variables.sign=r,$?.PROD&&(n.data=lt(n.data,t)),n}function _t(e,t,n){function r(e,t){if(typeof e!=`object`||!e||Array.isArray(e))return e;let n={...e};for(let r of Object.keys(e))Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=i(e[r],t[r].type));return n}function i(e,t){if(e==null)return e;let a=t.endsWith(`!`)?t.slice(0,-1):t;if(a.startsWith(`[`)&&a.endsWith(`]`))return Array.isArray(e)?e.map(e=>i(e,a.slice(1,-1))):e;switch(a){case`JsonString`:if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}case`Int`:case`Float`:{if(typeof e!=`number`&&typeof e!=`string`||typeof e==`string`&&e.trim()===``)return e;let t=Number(e);return Number.isFinite(t)&&(a!==`Int`||Number.isSafeInteger(t))?t:e}case`Boolean`:return e===`false`||e===`0`||e===0?!1:e===`true`||e===`1`||e===1||e;case`String`:case`ID`:return typeof e==`number`||typeof e==`boolean`?String(e):e;default:{let t=n?.types,i=t&&Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0;return i?r(e,i.fields):e}}}return e.map(e=>t?r(e,t):{...e})}const vt=Object.freeze(Object.create(null)),yt=e=>e===95||e>=65&&e<=90||e>=97&&e<=122,bt=e=>yt(e)||e>=48&&e<=57,xt=e=>e>=48&&e<=57,St=Object.create(null);function Ct(e){let t=+(e.charCodeAt(0)===65279),n=e.length,r,i=Object.create(null),a=new Set([`String`,`Int`,`Float`,`Boolean`,`ID`]),o=new Set;function s(){for(;;){if(t>=n)return;let r=e.charCodeAt(t);if(r===32||r===9||r===10||r===13||r===44){t++;continue}if(r===35){for(;++t<n;){let n=e.charCodeAt(t);if(n===10||n===13)break}continue}if(r===34&&e.charCodeAt(t+1)===34&&e.charCodeAt(t+2)===34){for(t+=3;t<n;){if(e.charCodeAt(t)===34&&e.charCodeAt(t+1)===34&&e.charCodeAt(t+2)===34){t+=3;break}t+=e.charCodeAt(t)===92?2:1}continue}if(r===34){for(t++;t<n;){let n=e.charCodeAt(t++);if(n===92)t++;else if(n===34)break}return`\0s`}if(yt(r)){let r=t++;for(;t<n&&bt(e.charCodeAt(t));)t++;return e.slice(r,t)}if(xt(r)||r===45&&xt(e.charCodeAt(t+1))){for(t++;t<n;){let n=e.charCodeAt(t);if(xt(n)||n===46||n===101||n===69||n===43||n===45)t++;else break}return`\0n`}if(r===46&&e.charCodeAt(t+1)===46&&e.charCodeAt(t+2)===46)return t+=3,`...`;if(r===123||r===125||r===40||r===41||r===91||r===93||r===58||r===33||r===61||r===36||r===64||r===124||r===38)return t++,String.fromCharCode(r);t++}}let c=()=>r??=s(),l=()=>{let e=r??s();return r=void 0,e},u=e=>c()===e&&(l(),!0),d=e=>{let t=l();if(t!==e)throw Error(`parseSDL: expected "${e}", got "${t??`EOF`}"`)},f=()=>{let e=l();if(!e||e===`\0s`||e===`\0n`||!yt(e.charCodeAt(0)))throw Error(`parseSDL: expected NAME, got "${e??`EOF`}"`);return e};function p(){if(u(`[`)){let e=`[${p()}]`;return d(`]`),u(`!`)&&(e+=`!`),e}let e=f();return u(`!`)&&(e+=`!`),e}function m(){if(u(`[`)){for(;c()&&c()!==`]`;)m();d(`]`);return}if(u(`{`)){for(;c()&&c()!==`}`;)f(),d(`:`),m();d(`}`);return}l()}function h(){for(;u(`@`);){if(f(),!u(`(`))continue;let e=1;for(;e&&c();)u(`(`)?e++:u(`)`)?e--:l()}}function g(){if(!u(`(`))return vt;let e=Object.create(null);for(;c()&&c()!==`)`;){let t=f();d(`:`),e[t]=p(),u(`=`)&&m(),h()}return d(`)`),e}function _(){let e=Object.create(null);for(d(`{`);c()&&c()!==`}`;){let t=f(),n=g();d(`:`);let r=p();h(),e[t]={name:t,args:n,type:r}}return d(`}`),e}function v(){let e=f();if(u(`implements`))for(u(`&`);c()&&c()!==`{`;)l();h(),c()===`{`&&(i[e]={name:e,fields:_()})}function y(){a.add(f()),h()}function b(){if(o.add(f()),h(),u(`{`)){for(;c()&&c()!==`}`;)l(),h();d(`}`)}}for(;c();)switch(l()){case`type`:v();break;case`scalar`:y();break;case`enum`:b()}return{query:i.Query?.fields||{},mutation:i.Mutation?.fields||{},types:i,scalars:a,enums:o}}function wt(e){let t=0,n=e.length,r=e.charCodeAt(0),i=e.charCodeAt(n-1);if(r!==91&&r!==33&&i!==93&&i!==33)return e;let a=St[e];if(a)return a;for(;t<n;){let n=e.charCodeAt(t);if(n!==91&&n!==33)break;t++}for(;n>t;){let t=e.charCodeAt(n-1);if(t!==93&&t!==33)break;n--}let o=e.slice(t,n);return St[e]=o,o}function Tt(e,t,n={}){let r=e.types[wt(t.type)];if(!r)return[];let i=[],a=r.fields;for(let t in a){let r=a[t],o=n[t];if(o!==!1){if(!e.types[wt(r.type)]){i.push(t);continue}o!==void 0&&i.push({name:t,fields:Tt(e,r,o===!0?{}:o)})}}return i}function Et(e,t=` `){let n=``;for(let r of e){if(n&&(n+=`
35
35
  `),typeof r==`string`){n+=t+r;continue}let e=Et(r.fields,t+` `);n+=e?`${t}${r.name} {\n${e}\n${t}}`:t+r.name}return n}function Dt(e,t=`query`){let{name:n,args:r=vt,fields:i=[]}=e,a=``,o=``;for(let e in r)a&&(a+=`, `),a+=`$${e}: ${r[e]}`,o+=`${o?`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uni2c/graphqlapi4mp",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Lightweight GraphQL SDL parser and query builder for TypeScript, Node.js, browsers, and mini programs.",
5
5
  "keywords": [
6
6
  "graphql",