@nocobase/plugin-license 2.1.0-beta.9 → 2.2.0-beta.1
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/client-v2.d.ts +2 -0
- package/client-v2.js +1 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/710.9271adce3d7f2397.js +10 -0
- package/dist/client-v2/index.d.ts +9 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/client-v2/locale.d.ts +10 -0
- package/dist/client-v2/pages/LicenseSetting.d.ts +10 -0
- package/dist/client-v2/plugin.d.ts +14 -0
- package/dist/externalVersion.js +8 -5
- package/dist/locale/en-US.json +13 -3
- package/dist/locale/zh-CN.json +13 -3
- package/dist/server/utils/instance.d.ts +1 -1
- package/dist/server/utils/instance.js +22 -16
- package/dist/server/utils/key.js +4 -3
- package/dist/server/utils/pkg.js +3 -1
- package/package.json +3 -2
package/client-v2.d.ts
ADDED
package/client-v2.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/client-v2/index.js');
|
package/dist/client/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("ahooks"),require("@formily/react"),require("@nocobase/client"),require("@ant-design/icons"),require("antd")):"function"==typeof define&&define.amd?define("@nocobase/plugin-license",["react","ahooks","@formily/react","@nocobase/client","@ant-design/icons","antd"],t):"object"==typeof exports?exports["@nocobase/plugin-license"]=t(require("react"),require("ahooks"),require("@formily/react"),require("@nocobase/client"),require("@ant-design/icons"),require("antd")):e["@nocobase/plugin-license"]=t(e.react,e.ahooks,e["@formily/react"],e["@nocobase/client"],e["@ant-design/icons"],e.antd)}(self,function(e,t,n,r,o,i){return function(){"use strict";var a={482:function(e){e.exports=o},505:function(e){e.exports=n},772:function(e){e.exports=r},749:function(e){e.exports=t},721:function(e){e.exports=i},156:function(t){t.exports=e}},u={};function l(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return a[e](n,n.exports,l),n.exports}l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,{a:t}),t},l.d=function(e,t){for(var n in t)l.o(t,n)&&!l.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var c={};return!function(){l.r(c),l.d(c,{PluginLicenseClient:function(){return N},default:function(){return _}});var e=l(772),t=l(156),n=l.n(t),r=l(721),o=l(749),i=JSON.parse('{"u2":"@nocobase/plugin-license"}');function a(){var t=(0,e.useApp)();return function(e,n){return String(t.i18n.t(e,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({ns:[i.u2,"client"]},n||{})))}}var u=l(482);function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var f=function(o){var i,u=o.refreshToken,l=(0,e.useAPIClient)(),c=(i=(0,t.useState)(null),function(e){if(Array.isArray(e))return e}(i)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),i.length!==t);a=!0);}catch(e){u=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw r}}return i}}(i,2)||function(e,t){if(e){if("string"==typeof e)return s(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,t)}}(i,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),f=c[0],p=c[1],y=a();return((0,t.useEffect)(function(){p(null),l.request({url:"/license:license-validate",method:"get"}).then(function(e){var t;p(null==e||null==(t=e.data)?void 0:t.data)}).catch(function(e){console.log(e)})},[u]),(null==f?void 0:f.licenseStatus)&&(null==f?void 0:f.licenseStatus)==="active")?(null==f?void 0:f.isServiceConnection)===!1&&(null==f?void 0:f.isPkgLogin)===!1?n().createElement(r.Alert,{message:y("Network error."),description:n().createElement(n().Fragment,null,y("Due to network issues, the license key cannot be updated automatically. Please update it manually if necessary."),n().createElement("br",null),y("Plugins also cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.")),type:"warning",style:{marginBottom:12}}):(null==f?void 0:f.isServiceConnection)===!1?n().createElement(r.Alert,{message:y("Network error."),description:n().createElement(n().Fragment,null,y("Due to network issues, the license key cannot be updated automatically. Please update it manually if necessary.")),type:"warning",style:{marginBottom:12}}):(null==f?void 0:f.isPkgLogin)===!1?n().createElement(r.Alert,{message:y("Network error."),description:n().createElement(n().Fragment,null,y("Due to network issues, plugins cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.")),type:"warning",style:{marginBottom:12}}):null:null},p=l(505),y=n().createContext(null);function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function h(e,t,n,r,o,i,a){try{var u=e[i](a),l=u.value}catch(e){n(e);return}u.done?t(l):Promise.resolve(l).then(r,o)}function m(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){h(i,r,o,a,u,"next",e)}function u(e){h(i,r,o,a,u,"throw",e)}a(void 0)})}}function b(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){var l=[i,u];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var v=function(){var o,i,u=(0,e.useAPIClient)(),l=(o=(0,t.useState)(!1),function(e){if(Array.isArray(e))return e}(o)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),i.length!==t);a=!0);}catch(e){u=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw r}}return i}}(o,2)||function(e,t){if(e){if("string"==typeof e)return d(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}}(o,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),c=l[0],s=l[1],f=(0,p.useForm)(),h=a(),v=n().useContext(y).onSaveSuccess,g=(i=m(function(e){var t,o,i;return b(this,function(a){switch(a.label){case 0:s(!0),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,u.request({url:"/license:license-key",method:"POST",data:{licenseKey:e}})];case 2:if(o=a.sent(),s(!1),"invalid"===(i=(null==o||null==(t=o.data)?void 0:t.data)||{}).keyStatus)return r.Modal.error({title:h("Invalid license key."),content:h("The license key is invalid. Please visit the NocoBase Service to obtain a new license key.")}),[2];if("invalid"===i.licenseStatus)return r.Modal.error({title:h("Invalid license key."),content:h("The current license key has been deprecated. Please visit the NocoBase Service to obtain a new license key.")}),[2];if(!1===i.envMatch)return r.Modal.error({title:h("Environment mismatch."),content:n().createElement(n().Fragment,null,!1===i.dbMatch&&!1===i.sysMatch&&n().createElement(n().Fragment,null,h("The current system and database do not match the licensed environment. Please use the new InstanceID to request a new license key.")),!0===i.dbMatch&&!1===i.sysMatch&&n().createElement(n().Fragment,null,h("The current system does not match the licensed system. Please use the new InstanceID to request a new license key.")),!1===i.dbMatch&&!0===i.sysMatch&&n().createElement(n().Fragment,null,h("The current database does not match the licensed database. Please use the new InstanceID to request a new license key.")))}),[2];if(!1===i.domainMatch)return r.Modal.error({title:h("Domain mismatch."),content:h("The current domain ({{domain}}) does not match the licensed domain. Please use the current domain to request a new license key.",{domain:i.current.domain,interpolation:{escapeValue:!1}})}),[2];if(null==v||v(),!0===i.isExpired)return r.message.success(h("The license key was saved successfully"),5),r.Modal.warning({title:h("The license has exceeded the upgrade validity period."),content:h("Plugins bound to this license can still be used but cannot be upgraded. To upgrade, please renew or repurchase the license.")}),[2];if(!1===i.isPkgLogin)return r.message.success(h("The license key was saved successfully"),5),r.Modal.warning({title:h("Network error."),content:h("Due to network issues, plugins cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.")}),[2];return r.message.success(h("License key saved successfully. Please retry the plugin installation.")),[3,4];case 3:return a.sent(),s(!1),r.message.error(h("Network error. Please try again.")),[3,4];case 4:return[2]}})}),function(e){return i.apply(this,arguments)});return{loading:c,onClick:m(function(){var e;return b(this,function(t){switch(t.label){case 0:return[4,null==f?void 0:f.validate()];case 1:return t.sent(),[4,g(null==(e=f.values)?void 0:e.licenseKey)];case 2:return t.sent(),[2]}})})}};function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function w(e,t,n,r,o,i,a){try{var u=e[i](a),l=u.value}catch(e){n(e);return}u.done?t(l):Promise.resolve(l).then(r,o)}function k(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){w(i,r,o,a,u,"next",e)}function u(e){w(i,r,o,a,u,"throw",e)}a(void 0)})}}function S(){return(S=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){u=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return g(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function P(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){var l=[i,u];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var E=function(e){var t=e.text,n=e.onSuccess,r=e.onError;if(!navigator.clipboard){var o=document.createElement("textarea");o.value=t,o.style.top="0",o.style.left="0",o.style.position="fixed",document.body.appendChild(o),o.focus(),o.select();try{document.execCommand("copy"),null==n||n()}catch(e){null==r||r()}document.body.removeChild(o);return}navigator.clipboard.writeText(t).then(function(){null==n||n()}).catch(function(e){console.error(e),null==r||r()})};function O(){var o,i=(0,e.useAPIClient)(),l=x((0,t.useState)(!1),2),c=l[0],s=l[1],f=x((0,t.useState)(""),2);f[0],f[1];var p=a(),y=(o=k(function(){return P(this,function(e){return s(!0),[2,i.request({url:"/license:instance-id",method:"GET"}).then(function(e){var t;return null==e||null==(t=e.data)?void 0:t.data}).finally(function(){s(!1)})]})}),function(){return o.apply(this,arguments)});return n().createElement(r.Button,{onClick:k(function(){return P(this,function(e){switch(e.label){case 0:return[4,y()];case 1:return E({text:e.sent(),onSuccess:function(){r.message.success(p("Copied"))},onError:function(){r.message.error(p("Failed to copy, please open ./storage/.license/instance-id and copy it"))}}),[2]}})}),loading:c,icon:n().createElement(u.CopyOutlined,null),type:"link"},p("Copy"))}var j=function(e){var i=S({},function(e){if(null==e)throw TypeError("Cannot destructure "+e);return e}(e)),u=x((0,t.useState)(!1),2),l=u[0],c=u[1],s=(0,p.useForm)(),f=a(),d=n().useContext(y).keyExist;return((0,o.useAsyncEffect)(k(function(){return P(this,function(e){return!1===d&&(c(!0),null==s||s.setFieldState("footer",function(e){e.visible=!0})),[2]})}),[d]),l)?n().createElement(r.Input.TextArea,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({rows:4},i)):d?n().createElement(n().Fragment,null,f("License key has been set"),"\xa0",n().createElement(r.Button,{onClick:function(){c(!0),null==s||s.setFieldState("footer",function(e){e.visible=!0})}},f("Change key"))):null},T=function(){var t=n().useContext(y),r=t.keyExist,o=t.refreshToken;return r?n().createElement(e.SchemaComponent,{key:o,schema:{type:"void",properties:{card:{type:"void","x-component":"LicenseCard"}}}}):null};function A(){var i=a(),u=x((0,t.useState)(0),2),l=u[0],c=u[1],s=x((0,t.useState)(null),2),p=s[0],d=s[1],h=(0,e.useAPIClient)();(0,o.useAsyncEffect)(k(function(){var e,t;return P(this,function(n){switch(n.label){case 0:return[4,h.request({url:"/license:is-exists",method:"GET"})];case 1:return d(null==(t=n.sent())||null==(e=t.data)?void 0:e.data),[2]}})}),[]);var m={type:"void","x-decorator":"Form",properties:{form:{type:"void",properties:{label:{type:"string",title:i("Instance ID"),"x-component":"InstanceId","x-decorator":"FormItem"},licenseKey:{type:"string",title:i("License key"),required:!0,"x-component":"TextArea","x-decorator":"FormItem","x-component-props":{placeholder:i("Enter license key")}},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-use-component-props":"useSubmitProps","x-component-props":{type:"primary",style:{marginBottom:16}}}},"x-visible":!1},licenseInfo:{type:"void","x-component":"LicenseCardWarp"}}}}};return n().createElement(r.Card,{bordered:!1},n().createElement(y.Provider,{value:{onSaveSuccess:function(){c(function(e){return e+1}),d(!0)},keyExist:p,refreshToken:l}},n().createElement(f,{refreshToken:l}),n().createElement(e.SchemaComponent,{scope:{useSubmitProps:v},components:{InstanceId:O,TextArea:j,LicenseCardWarp:T},schema:{type:"void",properties:{form:m}}})))}function C(e,t,n,r,o,i,a){try{var u=e[i](a),l=u.value}catch(e){n(e);return}u.done?t(l):Promise.resolve(l).then(r,o)}function I(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){C(i,r,o,a,u,"next",e)}function u(e){C(i,r,o,a,u,"throw",e)}a(void 0)})}}function M(e,t,n){return(M=D()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&F(o,n.prototype),o}).apply(null,arguments)}function q(e){return(q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function F(e,t){return(F=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function B(e){var t="function"==typeof Map?new Map:void 0;return(B=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return M(e,arguments,q(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),F(n,e)})(e)}function D(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(D=function(){return!!e})()}function L(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){var l=[i,u];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var N=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=q(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,D()?Reflect.construct(e,t||[],q(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&F(n,e),t=[{key:"afterAdd",value:function(){return I(function(){return L(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return I(function(){return L(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return I(function(){return L(this,function(t){return e.app.pluginSettingsManager.add("license-settings",{title:"{{t(".concat(JSON.stringify("License settings"),", { ns: ['").concat(i.u2,"', 'client'], nsMode: 'fallback' })}}"),icon:"SolutionOutlined",Component:A,aclSnippet:"pm.license-settings"}),[2]})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(B(e.Plugin)),_=N}(),c}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("ahooks"),require("react"),require("antd"),require("@nocobase/client"),require("@ant-design/icons"),require("@formily/react")):"function"==typeof define&&define.amd?define("@nocobase/plugin-license",["ahooks","react","antd","@nocobase/client","@ant-design/icons","@formily/react"],t):"object"==typeof exports?exports["@nocobase/plugin-license"]=t(require("ahooks"),require("react"),require("antd"),require("@nocobase/client"),require("@ant-design/icons"),require("@formily/react")):e["@nocobase/plugin-license"]=t(e.ahooks,e.react,e.antd,e["@nocobase/client"],e["@ant-design/icons"],e["@formily/react"])}(self,function(e,t,n,r,o,a){return function(){"use strict";var i={375:function(e){e.exports=o},230:function(e){e.exports=a},342:function(e){e.exports=r},625:function(t){t.exports=e},59:function(e){e.exports=n},155:function(e){e.exports=t}},c={};function u(e){var t=c[e];if(void 0!==t)return t.exports;var n=c[e]={exports:{}};return i[e](n,n.exports,u),n.exports}u.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(t,{a:t}),t},u.d=function(e,t){for(var n in t)u.o(t,n)&&!u.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},u.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},u.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.g.importScripts&&(l=u.g.location+"");var l,s=u.g.document;if(!l&&s&&(s.currentScript&&"SCRIPT"===s.currentScript.tagName.toUpperCase()&&(l=s.currentScript.src),!l)){var f=s.getElementsByTagName("script");if(f.length)for(var p=f.length-1;p>-1&&(!l||!/^http(s?):/.test(l));)l=f[p--].src}if(!l)throw Error("Automatic publicPath is not supported in this browser");u.p=l.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var y={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/@nocobase/plugin-license/dist/client/")}if(!e){var r=window.__nocobase_modern_client_prefix__||"v",o="/"+(r=String(r).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",i=a.indexOf(o);e=i>=0?a.slice(0,i+1):"/"}e&&(e=e.replace(RegExp("/"+r+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-license/dist/client/"}u.p=e}(),!function(){u.r(y),u.d(y,{default:function(){return L},PluginLicenseClient:function(){return D}});var e=u(342),t=u(155),n=u.n(t),r=u(59),o=u(625),a=JSON.parse('{"UU":"@nocobase/plugin-license"}');function i(){var t=(0,e.useApp)();return function(e,n){return String(t.i18n.t(e,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({ns:[a.UU,"client"]},n||{})))}}var c=u(375);function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var s=function(o){var a,c=o.refreshToken,u=(0,e.useAPIClient)(),s=function(e){if(Array.isArray(e))return e}(a=(0,t.useState)(null))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],a=!0,i=!1;try{for(r=r.call(e);!(a=(t=r.next()).done)&&(o.push(t.value),2!==o.length);a=!0);}catch(e){i=!0,n=e}finally{try{a||null==r.return||r.return()}finally{if(i)throw n}}return o}}(a)||function(e){if(e){if("string"==typeof e)return l(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return l(e,2)}}(a)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),f=s[0],p=s[1],y=i();return((0,t.useEffect)(function(){p(null),u.request({url:"/license:license-validate",method:"get"}).then(function(e){var t;p(null==e||null==(t=e.data)?void 0:t.data)}).catch(function(e){console.log(e)})},[c]),(null==f?void 0:f.licenseStatus)&&(null==f?void 0:f.licenseStatus)==="active")?(null==f?void 0:f.isServiceConnection)===!1&&(null==f?void 0:f.isPkgLogin)===!1?n().createElement(r.Alert,{message:y("Network error."),description:n().createElement(n().Fragment,null,y("Due to network issues, the license key cannot be updated automatically. Please update it manually if necessary."),n().createElement("br",null),y("Plugins also cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.")),type:"warning",style:{marginBottom:12}}):(null==f?void 0:f.isServiceConnection)===!1?n().createElement(r.Alert,{message:y("Network error."),description:n().createElement(n().Fragment,null,y("Due to network issues, the license key cannot be updated automatically. Please update it manually if necessary.")),type:"warning",style:{marginBottom:12}}):(null==f?void 0:f.isPkgLogin)===!1?n().createElement(r.Alert,{message:y("Network error."),description:n().createElement(n().Fragment,null,y("Due to network issues, plugins cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.")),type:"warning",style:{marginBottom:12}}):null:null},f=u(230),p=n().createContext(null);function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function h(e,t,n,r,o,a,i){try{var c=e[a](i),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}function b(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){h(a,r,o,i,c,"next",e)}function c(e){h(a,r,o,i,c,"throw",e)}i(void 0)})}}function m(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(i,"next",{value:u(0)}),c(i,"throw",{value:u(1)}),c(i,"return",{value:u(2)}),"function"==typeof Symbol&&c(i,Symbol.iterator,{value:function(){return this}}),i;function u(c){return function(u){var l=[c,u];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var v=function(){var o,a=(0,e.useAPIClient)(),c=function(e){if(Array.isArray(e))return e}(o=(0,t.useState)(!1))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],a=!0,i=!1;try{for(r=r.call(e);!(a=(t=r.next()).done)&&(o.push(t.value),2!==o.length);a=!0);}catch(e){i=!0,n=e}finally{try{a||null==r.return||r.return()}finally{if(i)throw n}}return o}}(o)||function(e){if(e){if("string"==typeof e)return d(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return d(e,2)}}(o)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),u=c[0],l=c[1],s=(0,f.useForm)(),y=i(),h=n().useContext(p).onSaveSuccess;return{loading:u,onClick:function(){return b(function(){var e;return m(this,function(t){switch(t.label){case 0:return[4,null==s?void 0:s.validate()];case 1:var o;return t.sent(),[4,(o=null==(e=s.values)?void 0:e.licenseKey,b(function(){var e,t,i;return m(this,function(c){switch(c.label){case 0:l(!0),c.label=1;case 1:return c.trys.push([1,3,,4]),[4,a.request({url:"/license:license-key",method:"POST",data:{licenseKey:o}})];case 2:if(t=c.sent(),l(!1),"invalid"===(i=(null==t||null==(e=t.data)?void 0:e.data)||{}).keyStatus)return r.Modal.error({title:y("Invalid license key."),content:y("The license key is invalid. Please visit the NocoBase Service to obtain a new license key.")}),[2];if("invalid"===i.licenseStatus)return r.Modal.error({title:y("Invalid license key."),content:y("The current license key has been deprecated. Please visit the NocoBase Service to obtain a new license key.")}),[2];if(!1===i.envMatch)return r.Modal.error({title:y("Environment mismatch."),content:n().createElement(n().Fragment,null,!1===i.dbMatch&&!1===i.sysMatch&&n().createElement(n().Fragment,null,y("The current system and database do not match the licensed environment. Please use the new InstanceID to request a new license key.")),!0===i.dbMatch&&!1===i.sysMatch&&n().createElement(n().Fragment,null,y("The current system does not match the licensed system. Please use the new InstanceID to request a new license key.")),!1===i.dbMatch&&!0===i.sysMatch&&n().createElement(n().Fragment,null,y("The current database does not match the licensed database. Please use the new InstanceID to request a new license key.")))}),[2];if(!1===i.domainMatch)return r.Modal.error({title:y("Domain mismatch."),content:y("The current domain ({{domain}}) does not match the licensed domain. Please use the current domain to request a new license key.",{domain:i.current.domain,interpolation:{escapeValue:!1}})}),[2];if(null==h||h(),!0===i.isExpired)return r.message.success(y("The license key was saved successfully"),5),r.Modal.warning({title:y("The license has exceeded the upgrade validity period."),content:y("Plugins bound to this license can still be used but cannot be upgraded. To upgrade, please renew or repurchase the license.")}),[2];if(!1===i.isPkgLogin)return r.message.success(y("The license key was saved successfully"),5),r.Modal.warning({title:y("Network error."),content:y("Due to network issues, plugins cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.")}),[2];return r.message.success(y("The license key has been saved successfully. Please restart the service, and the system will automatically install the plugin.")),[3,4];case 3:return c.sent(),l(!1),r.message.error(y("Network error. Please try again.")),[3,4];case 4:return[2]}})})())];case 2:return t.sent(),[2]}})})()}}};function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function w(e,t,n,r,o,a,i){try{var c=e[a](i),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}function S(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){w(a,r,o,i,c,"next",e)}function c(e){w(a,r,o,i,c,"throw",e)}i(void 0)})}}function k(){return(k=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){c=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(c)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return g(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(i,"next",{value:u(0)}),c(i,"throw",{value:u(1)}),c(i,"return",{value:u(2)}),"function"==typeof Symbol&&c(i,Symbol.iterator,{value:function(){return this}}),i;function u(c){return function(u){var l=[c,u];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var P=function(e){var t=e.text,n=e.onSuccess,r=e.onError;if(!navigator.clipboard){var o=document.createElement("textarea");o.value=t,o.style.top="0",o.style.left="0",o.style.position="fixed",document.body.appendChild(o),o.focus(),o.select();try{document.execCommand("copy"),null==n||n()}catch(e){null==r||r()}document.body.removeChild(o);return}navigator.clipboard.writeText(t).then(function(){null==n||n()}).catch(function(e){console.error(e),null==r||r()})};function E(){var o=(0,e.useAPIClient)(),a=x((0,t.useState)(!1),2),u=a[0],l=a[1],s=x((0,t.useState)(""),2);s[0],s[1];var f=i();return n().createElement(r.Button,{onClick:function(){return S(function(){return O(this,function(e){switch(e.label){case 0:return[4,S(function(){return O(this,function(e){return l(!0),[2,o.request({url:"/license:instance-id",method:"GET"}).then(function(e){var t;return null==e||null==(t=e.data)?void 0:t.data}).finally(function(){l(!1)})]})})()];case 1:return P({text:e.sent(),onSuccess:function(){r.message.success(f("Copied"))},onError:function(){r.message.error(f("Failed to copy, please open ./storage/.license/instance-id and copy it"))}}),[2]}})})()},loading:u,icon:n().createElement(c.CopyOutlined,null),type:"link"},f("Copy"))}var j=function(e){var a=e;if(null==a)throw TypeError("Cannot destructure "+a);var c=k({},e),u=x((0,t.useState)(!1),2),l=u[0],s=u[1],y=(0,f.useForm)(),d=i(),h=n().useContext(p).keyExist;return((0,o.useAsyncEffect)(function(){return S(function(){return O(this,function(e){return!1===h&&(s(!0),null==y||y.setFieldState("footer",function(e){e.visible=!0})),[2]})})()},[h]),l)?n().createElement(r.Input.TextArea,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({rows:4},c)):h?n().createElement(n().Fragment,null,d("License key has been set"),"\xa0",n().createElement(r.Button,{onClick:function(){s(!0),null==y||y.setFieldState("footer",function(e){e.visible=!0})}},d("Change key"))):null},T=function(){var t=n().useContext(p),r=t.keyExist,o=t.refreshToken;return r?n().createElement(e.SchemaComponent,{key:o,schema:{type:"void",properties:{card:{type:"void","x-component":"LicenseCard"}}}}):null};function I(){var a=i(),c=x((0,t.useState)(0),2),u=c[0],l=c[1],f=x((0,t.useState)(null),2),y=f[0],d=f[1],h=(0,e.useAPIClient)();(0,o.useAsyncEffect)(function(){return S(function(){var e,t;return O(this,function(n){switch(n.label){case 0:return[4,h.request({url:"/license:is-exists",method:"GET"})];case 1:return d(null==(t=n.sent())||null==(e=t.data)?void 0:e.data),[2]}})})()},[]);var b={type:"void","x-decorator":"Form",properties:{form:{type:"void",properties:{label:{type:"string",title:a("Instance ID"),"x-component":"InstanceId","x-decorator":"FormItem"},licenseKey:{type:"string",title:a("License key"),required:!0,"x-component":"TextArea","x-decorator":"FormItem","x-component-props":{placeholder:a("Enter license key")}},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-use-component-props":"useSubmitProps","x-component-props":{type:"primary",style:{marginBottom:16}}}},"x-visible":!1},licenseInfo:{type:"void","x-component":"LicenseCardWarp"}}}}};return n().createElement(r.Card,{bordered:!1},n().createElement(p.Provider,{value:{onSaveSuccess:function(){l(function(e){return e+1}),d(!0)},keyExist:y,refreshToken:u}},n().createElement(s,{refreshToken:u}),n().createElement(e.SchemaComponent,{scope:{useSubmitProps:v},components:{InstanceId:E,TextArea:j,LicenseCardWarp:T},schema:{type:"void",properties:{form:b}}})))}function A(e,t,n,r,o,a,i){try{var c=e[a](i),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}function C(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){A(a,r,o,i,c,"next",e)}function c(e){A(a,r,o,i,c,"throw",e)}i(void 0)})}}function _(e,t,n){return(_=B()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&q(o,n.prototype),o}).apply(null,arguments)}function M(e){return(M=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function q(e,t){return(q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function F(e){var t="function"==typeof Map?new Map:void 0;return(F=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return _(e,arguments,M(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),q(n,e)})(e)}function B(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(B=function(){return!!e})()}function N(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(i,"next",{value:u(0)}),c(i,"throw",{value:u(1)}),c(i,"return",{value:u(2)}),"function"==typeof Symbol&&c(i,Symbol.iterator,{value:function(){return this}}),i;function u(c){return function(u){var l=[c,u];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var D=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=M(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,B()?Reflect.construct(e,t||[],M(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&q(n,e),t=[{key:"afterAdd",value:function(){return C(function(){return N(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return C(function(){return N(this,function(e){return[2]})})()}},{key:"load",value:function(){return C(function(){return N(this,function(e){return this.app.pluginSettingsManager.add("license-settings",{title:"{{t(".concat(JSON.stringify("License settings"),", { ns: ['").concat(a.UU,"', 'client'], nsMode: 'fallback' })}}"),icon:"SolutionOutlined",Component:I,aclSnippet:"pm.license-settings"}),[2]})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(F(e.Plugin)),L=D}(),y}()});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_license_client_v2=self.webpackChunk_nocobase_plugin_license_client_v2||[]).push([["710"],{141:function(e,t,n){n.r(t),n.d(t,{default:function(){return p}});var r=n(375),a=n(694),l=n(59),o=n(155),s=n.n(o);function i(){var e=(0,a.useFlowEngine)();return function(t,n){return e.context.t(t,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({ns:["@nocobase/plugin-license","client"]},n))}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function u(e,t,n,r,a,l,o){try{var s=e[l](o),i=s.value}catch(e){n(e);return}s.done?t(i):Promise.resolve(i).then(r,a)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){u(l,r,a,o,s,"next",e)}function s(e){u(l,r,a,o,s,"throw",e)}o(void 0)})}}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,s=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){s=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(s)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),s=Object.defineProperty;return s(o,"next",{value:i(0)}),s(o,"throw",{value:i(1)}),s(o,"return",{value:i(2)}),"function"==typeof Symbol&&s(o,Symbol.iterator,{value:function(){return this}}),o;function i(s){return function(i){var c=[s,i];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&c[0]?r.return:c[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,c[1])).done)return a;switch(r=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function m(e){var t=e.refreshToken,n=i(),r=(0,a.useFlowContext)().api,c=y((0,o.useState)(null),2),u=c[0],d=c[1];return(0,o.useEffect)(function(){var e=!0;return d(null),r.request({url:"/license:license-validate",method:"get"}).then(function(t){if(e){var n;d((null==t||null==(n=t.data)?void 0:n.data)||null)}}).catch(function(e){console.log(e)}),function(){e=!1}},[r,t]),(0,o.useMemo)(function(){return(null==u?void 0:u.licenseStatus)&&"active"===u.licenseStatus?!1===u.isServiceConnection&&!1===u.isPkgLogin?s().createElement(l.Alert,{message:n("Network error."),description:s().createElement(s().Fragment,null,n("Due to network issues, the license key cannot be updated automatically. Please update it manually if necessary."),s().createElement("br",null),n("Plugins also cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.")),type:"warning",style:{marginBottom:12}}):!1===u.isServiceConnection?s().createElement(l.Alert,{message:n("Network error."),description:n("Due to network issues, the license key cannot be updated automatically. Please update it manually if necessary."),type:"warning",style:{marginBottom:12}}):!1===u.isPkgLogin?s().createElement(l.Alert,{message:n("Network error."),description:n("Due to network issues, plugins cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually."),type:"warning",style:{marginBottom:12}}):null:null},[u,n])}function p(){var e=i(),t=(0,a.useFlowContext)(),n=t.api,c=t.app,u=l.App.useApp(),p=u.message,h=u.modal,b=y(l.Form.useForm(),1)[0],v=y((0,o.useState)(!0),2),g=v[0],k=v[1],w=y((0,o.useState)(!1),2),E=w[0],S=w[1],T=y((0,o.useState)(null),2),C=T[0],P=T[1],F=y((0,o.useState)(!1),2),I=F[0],x=F[1],O=y((0,o.useState)(0),2),A=O[0],j=O[1],q=y((0,o.useState)(""),2),B=q[0],D=q[1],M=y((0,o.useState)(!1),2),N=M[0],_=M[1];(0,o.useEffect)(function(){var e=!0;return k(!0),d(function(){var t,r,a;return f(this,function(l){switch(l.label){case 0:return l.trys.push([0,2,3,4]),[4,n.request({url:"/license:is-exists",method:"GET"})];case 1:if(r=l.sent(),!e)return[2];return P(a=!!(null==r||null==(t=r.data)?void 0:t.data)),x(!a),[3,4];case 2:return console.log(l.sent()),[3,4];case 3:return e&&k(!1),[7];case 4:return[2]}})})(),function(){e=!1}},[n]),(0,o.useEffect)(function(){var e=!0;return n.request({url:"/license:instance-id",method:"GET"}).then(function(t){if(e){var n;D(String((null==t||null==(n=t.data)?void 0:n.data)||""))}}).catch(function(e){console.log(e)}),function(){e=!1}},[n]);var L=(0,o.useCallback)(function(){return d(function(){var t,r,a;return f(this,function(l){switch(l.label){case 0:_(!0),l.label=1;case 1:if(l.trys.push([1,5,6,7]),t=B)return[3,3];return[4,n.request({url:"/license:instance-id",method:"GET"})];case 2:D(t=String((null==(a=l.sent())||null==(r=a.data)?void 0:r.data)||"")),l.label=3;case 3:var o;return[4,(o=t,d(function(){var e,t;return f(this,function(n){switch(n.label){case 0:if(!o)return[2,!1];n.label=1;case 1:if(n.trys.push([1,4,,5]),!(null==(e=navigator.clipboard)?void 0:e.writeText))return[3,3];return[4,navigator.clipboard.writeText(o)];case 2:return n.sent(),[2,!0];case 3:return[3,5];case 4:return n.sent(),[3,5];case 5:(t=document.createElement("textarea")).value=o,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();try{return[2,document.execCommand("copy")]}catch(e){return[2,!1]}finally{document.body.removeChild(t)}}})})())];case 4:if(l.sent())return p.success(e("Copied")),[2];return p.error(e("Failed to copy, please open ./storage/.license/instance-id and copy it")),[3,7];case 5:return l.sent(),p.error(e("Failed to copy, please open ./storage/.license/instance-id and copy it")),[3,7];case 6:return _(!1),[7];case 7:return[2]}})})()},[n,B,p,e]),G=(0,o.useCallback)(function(t){return d(function(){var r,a,l,o;return f(this,function(i){switch(i.label){case 0:S(!0),i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,n.request({url:"/license:license-key",method:"POST",data:{licenseKey:t}})];case 2:if("invalid"===(l=(null==(a=i.sent())||null==(r=a.data)?void 0:r.data)||{}).keyStatus)return h.error({title:e("Invalid license key."),content:e("The license key is invalid. Please visit the NocoBase Service to obtain a new license key.")}),[2];if("invalid"===l.licenseStatus)return h.error({title:e("Invalid license key."),content:e("The current license key has been deprecated. Please visit the NocoBase Service to obtain a new license key.")}),[2];if(!1===l.envMatch)return h.error({title:e("Environment mismatch."),content:s().createElement(s().Fragment,null,!1===l.dbMatch&&!1===l.sysMatch?s().createElement(s().Fragment,null,e("The current system and database do not match the licensed environment. Please use the new InstanceID to request a new license key.")):null,!0===l.dbMatch&&!1===l.sysMatch?s().createElement(s().Fragment,null,e("The current system does not match the licensed system. Please use the new InstanceID to request a new license key.")):null,!1===l.dbMatch&&!0===l.sysMatch?s().createElement(s().Fragment,null,e("The current database does not match the licensed database. Please use the new InstanceID to request a new license key.")):null)}),[2];if(!1===l.domainMatch)return h.error({title:e("Domain mismatch."),content:e("The current domain ({{domain}}) does not match the licensed domain. Please use the current domain to request a new license key.",{domain:null==(o=l.current)?void 0:o.domain,interpolation:{escapeValue:!1}})}),[2];if(P(!0),x(!1),j(function(e){return e+1}),b.resetFields(),!0===l.isExpired)return p.success(e("The license key was saved successfully"),5),h.warning({title:e("The license has exceeded the upgrade validity period."),content:e("Plugins bound to this license can still be used but cannot be upgraded. To upgrade, please renew or repurchase the license.")}),[2];if(!1===l.isPkgLogin)return p.success(e("The license key was saved successfully"),5),h.warning({title:e("Network error."),content:e("Due to network issues, plugins cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.")}),[2];return p.success(e("The license key has been saved successfully. Please restart the service, and the system will automatically install the plugin.")),[3,5];case 3:return i.sent(),p.error(e("Network error. Please try again.")),[3,5];case 4:return S(!1),[7];case 5:return[2]}})})()},[n,b,p,h,e]),K=(0,o.useCallback)(function(){return d(function(){return f(this,function(e){switch(e.label){case 0:return[4,b.validateFields()];case 1:return[4,G(e.sent().licenseKey)];case 2:return e.sent(),[2]}})})()},[b,G]),U=c.getComponent("LicenseCard",!1),V=!!(U&&C);return s().createElement(l.Card,{bordered:!1},s().createElement(l.Spin,{spinning:g},s().createElement(m,{refreshToken:A}),s().createElement(l.Form,{form:b,layout:"vertical"},s().createElement(l.Form.Item,{label:e("Instance ID")},s().createElement(l.Button,{onClick:L,icon:s().createElement(r.CopyOutlined,null),type:"link",loading:N},e("Copy"))),s().createElement(l.Form.Item,{label:e("License key"),required:I},I?s().createElement(l.Form.Item,{name:"licenseKey",noStyle:!0,rules:[{required:!0,message:e("Enter license key")}]},s().createElement(l.Input.TextArea,{rows:4,placeholder:e("Enter license key")})):C?s().createElement(s().Fragment,null,e("License key has been set"),"\xa0",s().createElement(l.Button,{onClick:function(){return x(!0)}},e("Change key"))):null),I?s().createElement(l.Form.Item,null,s().createElement(l.Button,{type:"primary",loading:E,onClick:K},e("Submit"))):null),V?s().createElement(U,{key:A}):null))}}}]);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export { default } from './plugin';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-license/client-v2",["@nocobase/client-v2","react","antd","@ant-design/icons","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-license/client-v2"]=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/flow-engine")):e["@nocobase/plugin-license/client-v2"]=t(e["@nocobase/client-v2"],e.react,e.antd,e["@ant-design/icons"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o){return function(){"use strict";var i,c,u,a={375:function(e){e.exports=r},485:function(t){t.exports=e},694:function(e){e.exports=o},59:function(e){e.exports=n},155:function(e){e.exports=t}},l={};function s(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={exports:{}};return a[e](n,n.exports,s),n.exports}s.m=a,s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.f={},s.e=function(e){return Promise.all(Object.keys(s.f).reduce(function(t,n){return s.f[n](e,t),t},[]))},s.u=function(e){return""+e+".9271adce3d7f2397.js"},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},f={},s.l=function(e,t,n,r){if(f[e])return void f[e].push(t);if(void 0!==n)for(var o,i,c=document.getElementsByTagName("script"),u=0;u<c.length;u++){var a=c[u];if(a.getAttribute("src")==e||a.getAttribute("data-rspack")=="@nocobase/plugin-license/client-v2:"+n){o=a;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,s.nc&&o.setAttribute("nonce",s.nc),o.setAttribute("data-rspack","@nocobase/plugin-license/client-v2:"+n),o.src=e),f[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(p);var r=f[e];if(delete f[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},p=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},s.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.g.importScripts&&(p=s.g.location+"");var f,p,b=s.g.document;if(!p&&b&&(b.currentScript&&"SCRIPT"===b.currentScript.tagName.toUpperCase()&&(p=b.currentScript.src),!p)){var d=b.getElementsByTagName("script");if(d.length)for(var v=d.length-1;v>-1&&(!p||!/^http(s?):/.test(p));)p=d[v--].src}if(!p)throw Error("Automatic publicPath is not supported in this browser");s.p=p.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i={889:0},s.f.j=function(e,t){var n=s.o(i,e)?i[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=i[e]=[t,r]});t.push(n[2]=r);var o=s.p+s.u(e),c=Error();s.l(o,function(t){if(s.o(i,e)&&(0!==(n=i[e])&&(i[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;c.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",c.name="ChunkLoadError",c.type=r,c.request=o,n[1](c)}},"chunk-"+e,e)}},c=function(e,t){var n,r,o=t[0],c=t[1],u=t[2],a=0;if(o.some(function(e){return 0!==i[e]})){for(n in c)s.o(c,n)&&(s.m[n]=c[n]);u&&u(s)}for(e&&e(t);a<o.length;a++)r=o[a],s.o(i,r)&&i[r]&&i[r][0](),i[r]=0},(u=self.webpackChunk_nocobase_plugin_license_client_v2=self.webpackChunk_nocobase_plugin_license_client_v2||[]).forEach(c.bind(null,0)),u.push=c.bind(null,u.push.bind(u));var g={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/@nocobase/plugin-license/dist/client-v2/")}if(!e){var r=window.__nocobase_modern_client_prefix__||"v",o="/"+(r=String(r).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",c=i.indexOf(o);e=c>=0?i.slice(0,c+1):"/"}e&&(e=e.replace(RegExp("/"+r+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-license/dist/client-v2/"}s.p=e}(),!function(){s.r(g),s.d(g,{default:function(){return u}});var e=s(485);function t(e,t,n,r,o,i,c){try{var u=e[i](c),a=u.value}catch(e){n(e);return}u.done?t(a):Promise.resolve(a).then(r,o)}function n(e,t,r){return(n=c()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&o(i,n.prototype),i}).apply(null,arguments)}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e){var t="function"==typeof Map?new Map:void 0;return(i=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return n(e,arguments,r(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),o(i,e)})(e)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(c=function(){return!!e})()}var u=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function i(){var e,t;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return e=i,t=arguments,e=r(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,c()?Reflect.construct(e,t||[],r(this).constructor):e.apply(this,t))}return i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&o(i,e),n=[{key:"load",value:function(){var e;return(e=function(){var e;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(c,"next",{value:a(0)}),u(c,"throw",{value:a(1)}),u(c,"return",{value:a(2)}),"function"==typeof Symbol&&u(c,Symbol.iterator,{value:function(){return this}}),c;function a(u){return function(a){var l=[u,a];if(n)throw TypeError("Generator is already executing.");for(;c&&(c=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(t){return e=this.t("License settings"),this.pluginSettingsManager.addMenuItem({key:"license-settings",title:e,icon:"SolutionOutlined",aclSnippet:"pm.license-settings"}),this.pluginSettingsManager.addPageTabItem({menuKey:"license-settings",key:"index",title:e,aclSnippet:"pm.license-settings",componentLoader:function(){return s.e("710").then(s.bind(s,141))}}),[2]})},function(){var n=this,r=arguments;return new Promise(function(o,i){var c=e.apply(n,r);function u(e){t(c,o,i,u,a,"next",e)}function a(e){t(c,o,i,u,a,"throw",e)}u(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(i.prototype,n),i}(i(e.Plugin))}(),g}()});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useT(): (key: string, options?: Record<string, any>) => string;
|
|
10
|
+
export declare function tExpr(key: string): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
export default function LicenseSetting(): React.JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import type { Application } from '@nocobase/client-v2';
|
|
10
|
+
import { Plugin } from '@nocobase/client-v2';
|
|
11
|
+
export declare class PluginLicenseClientV2 extends Plugin<Record<string, never>, Application> {
|
|
12
|
+
load(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export default PluginLicenseClientV2;
|
package/dist/externalVersion.js
CHANGED
|
@@ -9,16 +9,19 @@
|
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"react": "18.2.0",
|
|
12
|
-
"@nocobase/client": "2.
|
|
12
|
+
"@nocobase/client": "2.2.0-beta.1",
|
|
13
13
|
"antd": "5.24.2",
|
|
14
14
|
"ahooks": "3.7.8",
|
|
15
15
|
"@ant-design/icons": "5.6.1",
|
|
16
16
|
"@formily/react": "2.3.7",
|
|
17
17
|
"@nocobase/license-kit": "0.3.8",
|
|
18
18
|
"react-i18next": "11.18.6",
|
|
19
|
-
"@nocobase/
|
|
20
|
-
"
|
|
21
|
-
"
|
|
19
|
+
"@nocobase/flow-engine": "2.2.0-beta.1",
|
|
20
|
+
"@nocobase/client-v2": "2.2.0-beta.1",
|
|
21
|
+
"@nocobase/server": "2.2.0-beta.1",
|
|
22
|
+
"lodash": "4.18.1",
|
|
23
|
+
"@nocobase/utils": "2.2.0-beta.1",
|
|
24
|
+
"koa": "3.2.0",
|
|
22
25
|
"axios": "1.7.7",
|
|
23
|
-
"@nocobase/logger": "2.
|
|
26
|
+
"@nocobase/logger": "2.2.0-beta.1"
|
|
24
27
|
};
|
package/dist/locale/en-US.json
CHANGED
|
@@ -27,11 +27,21 @@
|
|
|
27
27
|
"Due to network issues, the license key cannot be updated automatically. Please update it manually if necessary.": "Due to network issues, the license key cannot be updated automatically. Please update it manually if necessary.",
|
|
28
28
|
"Due to network issues, plugins cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.": "Due to network issues, plugins cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.",
|
|
29
29
|
"Plugins also cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.": "Plugins also cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.",
|
|
30
|
-
"
|
|
30
|
+
"The license key has been saved successfully. Please restart the service, and the system will automatically install the plugin.": "The license key has been saved successfully. Please restart the service, and the system will automatically install the plugin.",
|
|
31
31
|
"The license key was saved successfully": "The license key was saved successfully",
|
|
32
32
|
"License key not found.": "License key not found.",
|
|
33
33
|
"Please go to the": "Please go to the",
|
|
34
34
|
"License Settings": "License Settings",
|
|
35
35
|
"page to enter the license key.": "page to enter the license key.",
|
|
36
|
-
"License information": "License information"
|
|
37
|
-
|
|
36
|
+
"License information": "License information",
|
|
37
|
+
"Status": "Status",
|
|
38
|
+
"Active": "Active",
|
|
39
|
+
"Invalid": "Invalid",
|
|
40
|
+
"Current domain": "Current domain",
|
|
41
|
+
"Service connection": "Service connection",
|
|
42
|
+
"Plugin service login": "Plugin service login",
|
|
43
|
+
"Connected": "Connected",
|
|
44
|
+
"Disconnected": "Disconnected",
|
|
45
|
+
"Submit": "Submit",
|
|
46
|
+
"Network error. Please try again.": "Network error. Please try again."
|
|
47
|
+
}
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -27,11 +27,21 @@
|
|
|
27
27
|
"Due to network issues, the license key cannot be updated automatically. Please update it manually if necessary.": "由于网络问题,授权密钥无法自动更新,如有需要请手动更新。",
|
|
28
28
|
"Due to network issues, plugins cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.": "由于网络问题,插件无法自动更新(可正常使用),如需要更新插件,请检查网络连接,或参考 NocoBase Service 文档手动上传插件。",
|
|
29
29
|
"Plugins also cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.": "插件也无法自动更新(可正常使用),如需要更新插件,请检查网络连接,或参考 NocoBase Service 文档手动上传插件。",
|
|
30
|
-
"
|
|
30
|
+
"The license key has been saved successfully. Please restart the service, and the system will automatically install the plugin.": "授权密钥已保存成功,请重启服务,系统将自动安装插件。",
|
|
31
31
|
"The license key was saved successfully": "授权密钥保存成功",
|
|
32
32
|
"License key not found.": "授权密钥未找到",
|
|
33
33
|
"Please go to the": "请前往",
|
|
34
34
|
"License Settings": "授权设置",
|
|
35
35
|
"page to enter the license key.": "页面填写授权密钥。",
|
|
36
|
-
"License information": "授权信息"
|
|
37
|
-
|
|
36
|
+
"License information": "授权信息",
|
|
37
|
+
"Status": "状态",
|
|
38
|
+
"Active": "有效",
|
|
39
|
+
"Invalid": "无效",
|
|
40
|
+
"Current domain": "当前域名",
|
|
41
|
+
"Service connection": "服务连接",
|
|
42
|
+
"Plugin service login": "插件服务登录",
|
|
43
|
+
"Connected": "已连接",
|
|
44
|
+
"Disconnected": "未连接",
|
|
45
|
+
"Submit": "提交",
|
|
46
|
+
"Network error. Please try again.": "网络错误,请重试。"
|
|
47
|
+
}
|
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
export declare function getInstanceId(): Promise<string>;
|
|
10
|
-
export declare function createInstanceId(force?: boolean): Promise<
|
|
10
|
+
export declare function createInstanceId(force?: boolean): Promise<string>;
|
|
11
11
|
export declare function isLicenseKeyExists(): Promise<boolean>;
|
|
@@ -42,29 +42,35 @@ __export(instance_exports, {
|
|
|
42
42
|
});
|
|
43
43
|
module.exports = __toCommonJS(instance_exports);
|
|
44
44
|
var import_fs = __toESM(require("fs"));
|
|
45
|
-
var
|
|
46
|
-
var
|
|
45
|
+
var import_utils = require("@nocobase/utils");
|
|
46
|
+
var import_license_kit = require("@nocobase/license-kit");
|
|
47
47
|
async function getInstanceId() {
|
|
48
|
-
const
|
|
49
|
-
const filePath = import_path.default.resolve(dir, "instance-id");
|
|
48
|
+
const filePath = (0, import_utils.storagePathJoin)(".license", "instance-id");
|
|
50
49
|
await createInstanceId(true);
|
|
51
|
-
const id = import_fs.default.
|
|
52
|
-
return id;
|
|
50
|
+
const id = await import_fs.default.promises.readFile(filePath, "utf-8");
|
|
51
|
+
return id.trim();
|
|
53
52
|
}
|
|
54
53
|
async function createInstanceId(force = false) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
const dir = (0, import_utils.storagePathJoin)(".license");
|
|
55
|
+
const filePath = (0, import_utils.storagePathJoin)(".license", "instance-id");
|
|
56
|
+
if (!force) {
|
|
57
|
+
try {
|
|
58
|
+
const existing = await import_fs.default.promises.readFile(filePath, "utf-8");
|
|
59
|
+
const normalized = existing.trim();
|
|
60
|
+
if (normalized) {
|
|
61
|
+
return normalized;
|
|
60
62
|
}
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
}
|
|
63
|
+
} catch (e) {
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
await import_fs.default.promises.mkdir(dir, { recursive: true });
|
|
67
|
+
const instanceId = String(await (0, import_license_kit.getInstanceIdAsync)()).trim();
|
|
68
|
+
await import_fs.default.promises.writeFile(filePath, `${instanceId}
|
|
69
|
+
`);
|
|
70
|
+
return instanceId;
|
|
64
71
|
}
|
|
65
72
|
async function isLicenseKeyExists() {
|
|
66
|
-
const
|
|
67
|
-
const filePath = import_path.default.resolve(dir, "license-key");
|
|
73
|
+
const filePath = (0, import_utils.storagePathJoin)(".license", "license-key");
|
|
68
74
|
return import_fs.default.existsSync(filePath);
|
|
69
75
|
}
|
|
70
76
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/server/utils/key.js
CHANGED
|
@@ -48,6 +48,7 @@ __export(key_exports, {
|
|
|
48
48
|
module.exports = __toCommonJS(key_exports);
|
|
49
49
|
var import_license_kit = require("@nocobase/license-kit");
|
|
50
50
|
var import_path = __toESM(require("path"));
|
|
51
|
+
var import_utils = require("@nocobase/utils");
|
|
51
52
|
var import_fs = __toESM(require("fs"));
|
|
52
53
|
var import_interface2 = require("./interface");
|
|
53
54
|
var import_axios = __toESM(require("axios"));
|
|
@@ -88,7 +89,7 @@ async function request({
|
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
async function saveLicenseKey(licenseKey, ctx) {
|
|
91
|
-
const dir =
|
|
92
|
+
const dir = (0, import_utils.storagePathJoin)(".license");
|
|
92
93
|
const filePath = import_path.default.resolve(dir, "license-key");
|
|
93
94
|
await import_fs.default.promises.writeFile(filePath, licenseKey);
|
|
94
95
|
if (ctx && ctx.cache) {
|
|
@@ -97,7 +98,7 @@ async function saveLicenseKey(licenseKey, ctx) {
|
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
async function getLocalKeyData() {
|
|
100
|
-
const keyFile =
|
|
101
|
+
const keyFile = (0, import_utils.storagePathJoin)(".license", "license-key");
|
|
101
102
|
try {
|
|
102
103
|
const key = (await import_fs.default.promises.readFile(keyFile, "utf8")).trim();
|
|
103
104
|
return JSON.parse((0, import_license_kit.keyDecrypt)(key));
|
|
@@ -108,7 +109,7 @@ async function getLocalKeyData() {
|
|
|
108
109
|
async function getKey(ctx) {
|
|
109
110
|
var _a, _b;
|
|
110
111
|
let key;
|
|
111
|
-
const keyFile =
|
|
112
|
+
const keyFile = (0, import_utils.storagePathJoin)(".license", "license-key");
|
|
112
113
|
if (ctx == null ? void 0 : ctx.cache) {
|
|
113
114
|
try {
|
|
114
115
|
key = await ctx.cache.get(import_interface2.CACHE_KEY);
|
package/dist/server/utils/pkg.js
CHANGED
|
@@ -80,6 +80,7 @@ async function testPkgConnection() {
|
|
|
80
80
|
}
|
|
81
81
|
async function testPkgLogin(keyData) {
|
|
82
82
|
try {
|
|
83
|
+
const timeout = 1e4;
|
|
83
84
|
const NOCOBASE_PKG_URL = getNocoBasePkgUrl();
|
|
84
85
|
const { accessKeyId, accessKeySecret } = keyData || {};
|
|
85
86
|
if (!accessKeyId || !accessKeySecret) {
|
|
@@ -87,7 +88,8 @@ async function testPkgLogin(keyData) {
|
|
|
87
88
|
}
|
|
88
89
|
const credentials = { username: accessKeyId, password: accessKeySecret };
|
|
89
90
|
const res1 = await import_axios.default.post(`${NOCOBASE_PKG_URL}-/verdaccio/sec/login`, credentials, {
|
|
90
|
-
responseType: "json"
|
|
91
|
+
responseType: "json",
|
|
92
|
+
timeout
|
|
91
93
|
});
|
|
92
94
|
const token = res1.data.token;
|
|
93
95
|
if (!token) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-license",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0-beta.1",
|
|
4
4
|
"main": "dist/server/index.js",
|
|
5
5
|
"displayName": "License settings",
|
|
6
6
|
"displayName.ru-RU": "Настройки лицензии",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"description.zh-CN": "实例 ID 和授权密钥设置",
|
|
11
11
|
"peerDependencies": {
|
|
12
12
|
"@nocobase/client": "2.x",
|
|
13
|
+
"@nocobase/client-v2": "2.x",
|
|
13
14
|
"@nocobase/server": "2.x",
|
|
14
15
|
"@nocobase/test": "2.x"
|
|
15
16
|
},
|
|
@@ -17,5 +18,5 @@
|
|
|
17
18
|
"ts:env": "tsc -p tsconfig.env.json"
|
|
18
19
|
},
|
|
19
20
|
"license": "Apache-2.0",
|
|
20
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "f82fa9d0c3aa8e00e53dd94e404a312483b4866b"
|
|
21
22
|
}
|