@nocobase/plugin-license 2.0.0-alpha.51 → 2.0.0-alpha.53

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.
@@ -0,0 +1,16 @@
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
+ interface LicenseSettingContextType {
11
+ onSaveSuccess: () => void;
12
+ keyExist: boolean;
13
+ refreshToken?: any;
14
+ }
15
+ export declare const LicenseSettingContext: React.Context<LicenseSettingContextType>;
16
+ export {};
@@ -0,0 +1,12 @@
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 declare const ServiceValidate: ({ refreshToken }: {
11
+ refreshToken: number;
12
+ }) => React.JSX.Element;
@@ -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("@ant-design/icons"),require("@nocobase/client"),require("antd")):"function"==typeof define&&define.amd?define("@nocobase/plugin-license",["react","ahooks","@ant-design/icons","@nocobase/client","antd"],t):"object"==typeof exports?exports["@nocobase/plugin-license"]=t(require("react"),require("ahooks"),require("@ant-design/icons"),require("@nocobase/client"),require("antd")):e["@nocobase/plugin-license"]=t(e.react,e.ahooks,e["@ant-design/icons"],e["@nocobase/client"],e.antd)}(self,function(e,t,n,r,o){return function(){"use strict";var i={482:function(e){e.exports=n},772:function(e){e.exports=r},749:function(e){e.exports=t},721:function(e){e.exports=o},156:function(t){t.exports=e}},u={};function c(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return i[e](n,n.exports,c),n.exports}c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,{a:t}),t},c.d=function(e,t){for(var n in t)c.o(t,n)&&!c.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return!function(){c.r(a),c.d(a,{PluginLicenseClient:function(){return C},default:function(){return A}});var e=c(772),t=c(156),n=c.n(t),r=c(721),o=c(749),i=JSON.parse('{"u2":"@nocobase/plugin-license"}');function u(){var t=(0,e.useApp)();return function(e){return t.i18n.t(e,{ns:[i.u2,"client"]})}}var l=c(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}function f(e,t,n,r,o,i,u){try{var c=e[i](u),a=c.value}catch(e){n(e);return}c.done?t(a):Promise.resolve(a).then(r,o)}function p(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){f(i,r,o,u,c,"next",e)}function c(e){f(i,r,o,u,c,"throw",e)}u(void 0)})}}function y(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=[],u=!0,c=!1;try{for(o=o.call(e);!(u=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);u=!0);}catch(e){c=!0,r=e}finally{try{u||null==o.return||o.return()}finally{if(c)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return s(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 s(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 d(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){var a=[i,c];if(n)throw TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=t.call(e,u)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}}var b=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 v(){var o,i=(0,e.useAPIClient)(),c=y((0,t.useState)(!1),2),a=c[0],s=c[1],f=y((0,t.useState)(""),2);f[0],f[1];var v=u(),h=(o=p(function(){return d(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:p(function(){return d(this,function(e){switch(e.label){case 0:return[4,h()];case 1:return b({text:e.sent(),onSuccess:function(){r.message.success(v("Copied"))},onError:function(){r.message.error(v("Failed to copy, please open ./storage/.license/instance-id and copy it"))}}),[2]}})}),loading:a,icon:n().createElement(l.CopyOutlined,null),type:"link"},v("Copy"))}var h=function(){var n,o=(0,e.useAPIClient)(),i=y((0,t.useState)(!1),2),c=i[0],a=i[1],l=(0,e.useFormBlockContext)(),s=u(),f=(n=p(function(e){return d(this,function(t){switch(t.label){case 0:a(!0),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,o.request({url:"/license:license-key",method:"POST",data:{licenseKey:e}})];case 2:return t.sent(),a(!1),r.message.success(s("License key saved successfully, please re-run the plugin installation.")),[3,4];case 3:return t.sent(),a(!1),[3,4];case 4:return[2]}})}),function(e){return n.apply(this,arguments)});return{loading:c,onClick:p(function(){var e,t,n;return d(this,function(r){switch(r.label){case 0:return[4,null==(e=l.form)?void 0:e.validate()];case 1:return r.sent(),[4,f(null==(n=l.form)||null==(t=n.values)?void 0:t.licenseKey)];case 2:return r.sent(),[2]}})})}},m=function(i){var c=y((0,t.useState)(!1),2),a=c[0],l=c[1],s=(0,e.useAPIClient)(),f=(0,e.useFormBlockContext)(),b=u();return((0,o.useAsyncEffect)(p(function(){var e,t,n,r;return d(this,function(o){switch(o.label){case 0:return[4,s.request({url:"/license:is-exists",method:"GET"})];case 1:return(null==(n=o.sent())||null==(e=n.data)?void 0:e.data)&&(null==(r=f.form)||r.setFieldState("footer",function(e){e.visible=!1})),l(null==n||null==(t=n.data)?void 0:t.data),[2]}})}),[]),a)?n().createElement(n().Fragment,null,b("License key has been set"),"\xa0",n().createElement(r.Button,{onClick:function(){var e;l(!1),null==(e=f.form)||e.setFieldState("footer",function(e){e.visible=!0})}},b("Change key"))):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))};function g(){var t=u(),o={type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{dataSource:"main",collection:"users"},properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{label:{type:"string",title:t("Instance ID"),"x-component":"InstanceId","x-decorator":"FormItem"},licenseKey:{type:"string",title:t("License key"),required:!0,"x-component":"TextArea","x-decorator":"FormItem","x-component-props":{placeholder:t("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"}}}}}}}};return n().createElement(r.Card,{bordered:!1},n().createElement(e.SchemaComponent,{scope:{useSubmitProps:h},components:{InstanceId:v,TextArea:m},schema:{type:"void",properties:{form:o}}}))}function x(e,t,n,r,o,i,u){try{var c=e[i](u),a=c.value}catch(e){n(e);return}c.done?t(a):Promise.resolve(a).then(r,o)}function S(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){x(i,r,o,u,c,"next",e)}function c(e){x(i,r,o,u,c,"throw",e)}u(void 0)})}}function w(e,t,n){return(w=j()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&k(o,n.prototype),o}).apply(null,arguments)}function O(e){return(O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function k(e,t){return(k=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function P(e){var t="function"==typeof Map?new Map:void 0;return(P=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 w(e,arguments,O(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),k(n,e)})(e)}function j(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(j=function(){return!!e})()}function E(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){var a=[i,c];if(n)throw TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=t.call(e,u)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}}var C=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=O(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,j()?Reflect.construct(e,t||[],O(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&k(n,e),t=[{key:"afterAdd",value:function(){return S(function(){return E(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return S(function(){return E(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return S(function(){return E(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:g,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}(P(e.Plugin)),A=C}(),a}()});
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}()});
@@ -6,5 +6,5 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- export declare function useT(): (str: string) => string;
9
+ export declare function useT(): (str: string, options?: any) => string;
10
10
  export declare function tStr(key: string): string;
@@ -0,0 +1,12 @@
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 const useSubmitProps: () => {
10
+ loading: boolean;
11
+ onClick: () => Promise<void>;
12
+ };
@@ -9,10 +9,16 @@
9
9
 
10
10
  module.exports = {
11
11
  "react": "18.2.0",
12
- "@nocobase/client": "2.0.0-alpha.51",
12
+ "@nocobase/client": "2.0.0-alpha.53",
13
13
  "antd": "5.24.2",
14
14
  "ahooks": "3.7.8",
15
15
  "@ant-design/icons": "5.6.1",
16
- "@nocobase/server": "2.0.0-alpha.51",
17
- "@nocobase/license-kit": "0.2.17"
16
+ "@formily/react": "2.3.7",
17
+ "@nocobase/license-kit": "0.3.2",
18
+ "react-i18next": "11.18.6",
19
+ "@nocobase/server": "2.0.0-alpha.53",
20
+ "lodash": "4.17.21",
21
+ "koa": "2.16.0",
22
+ "axios": "1.7.7",
23
+ "@nocobase/logger": "2.0.0-alpha.53"
18
24
  };
@@ -3,11 +3,35 @@
3
3
  "Copied": "Copied",
4
4
  "Copy": "Copy",
5
5
  "Enter license key": "Enter license key",
6
- "Failed to copy, please open ./storage/.license/instance-id and copy it": "Failed to copy, please open ./storage/.license/instance-id and copy it",
7
6
  "Instance ID": "Instance ID",
8
7
  "Invalid license key": "Invalid license key",
9
8
  "License key": "License key",
10
9
  "License key has been set": "License key has been set",
11
10
  "License key saved successfully, please re-run the plugin installation.": "License key saved successfully, please re-run the plugin installation.",
12
- "License settings": "License settings"
11
+ "License settings": "License settings",
12
+ "Failed to copy, please open ./storage/.license/instance-id and copy it": "Failed to copy, please open ./storage/.license/instance-id and copy it",
13
+ "Invalid license key.": "Invalid license key.",
14
+ "The license key is invalid. Please visit the NocoBase Service to obtain a new license key.": "The license key is invalid. Please visit the NocoBase Service to obtain a new license key.",
15
+ "The current license key has been deprecated. Please visit the NocoBase Service to obtain a new license key.": "The current license key has been deprecated. Please visit the NocoBase Service to obtain a new license key.",
16
+ "The license has exceeded the upgrade validity period.": "The license has exceeded the upgrade validity period.",
17
+ "Plugins bound to this license can still be used but cannot be upgraded. To upgrade, please renew or repurchase the license.": "Plugins bound to this license can still be used but cannot be upgraded. To upgrade, please renew or repurchase the license.",
18
+ "Environment mismatch.": "Environment mismatch.",
19
+ "The current system does not match the licensed system. Please use the new InstanceID to request a new license key.": "The current system does not match the licensed system. Please use the new InstanceID to request a new license key.",
20
+ "The current database does not match the licensed database. Please use the new InstanceID to request a new license key.": "The current database does not match the licensed database. Please use the new InstanceID to request a new license key.",
21
+ "The current system and database do not match the licensed environment. Please use the new InstanceID to request a new license key.": "The current system and database do not match the licensed environment. Please use the new InstanceID to request a new license key.",
22
+ "Domain mismatch.": "Domain mismatch.",
23
+ "The current domain ({{domain}}) does not match the licensed domain. Please use the current domain to request a new license key.": "The current domain ({{domain}}) does not match the licensed domain. Please use the current domain to request a new license key.",
24
+ "Plugin not licensed.": "Plugin not licensed.",
25
+ "An unlicensed plugin has been detected. Please visit the NocoBase Service to complete the purchase or obtain a license.": "An unlicensed plugin has been detected. Please visit the NocoBase Service to complete the purchase or obtain a license.",
26
+ "Network error.": "Network error.",
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
+ "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
+ "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
+ "License key saved successfully. Please retry the plugin installation.": "License key saved successfully. Please retry the plugin installation.",
31
+ "The license key was saved successfully": "The license key was saved successfully",
32
+ "License key not found.": "License key not found.",
33
+ "Please go to the": "Please go to the",
34
+ "License Settings": "License Settings",
35
+ "page to enter the license key.": "page to enter the license key.",
36
+ "License information": "License information"
13
37
  }
@@ -3,11 +3,35 @@
3
3
  "Copied": "复制成功",
4
4
  "Copy": "复制",
5
5
  "Enter license key": "输入授权密钥",
6
- "Failed to copy, please open ./storage/.license/instance-id and copy it": "复制失败,请打开 ./storage/.license/instance-id 并复制",
7
6
  "Instance ID": "实例 ID",
8
7
  "Invalid license key": "无效的授权密钥",
9
8
  "License key": "授权密钥",
10
9
  "License key has been set": "授权密钥已设置",
11
10
  "License key saved successfully, please re-run the plugin installation.": "授权密钥保存成功,请重新执行插件安装操作",
12
- "License settings": "授权设置"
11
+ "License settings": "授权设置",
12
+ "Failed to copy, please open ./storage/.license/instance-id and copy it": "复制失败,请打开 ./storage/.license/instance-id 并复制",
13
+ "Invalid license key.": "授权密钥无效",
14
+ "The license key is invalid. Please visit the NocoBase Service to obtain a new license key.": "无效的授权密钥,请前往 NocoBase Service 重新获取授权密钥。",
15
+ "The current license key has been deprecated. Please visit the NocoBase Service to obtain a new license key.": "当前授权密钥已被废弃,请前往 NocoBase Service 重新获取授权密钥。",
16
+ "The license has exceeded the upgrade validity period.": "许可证已过升级有效期",
17
+ "Plugins bound to this license can still be used but cannot be upgraded. To upgrade, please renew or repurchase the license.": "许可证绑定的插件可以继续使用,但无法升级,如需升级请续费或重新购买许可证。",
18
+ "Environment mismatch.": "环境不匹配",
19
+ "The current system does not match the licensed system. Please use the new InstanceID to request a new license key.": "当前系统与许可绑定的系统不一致,请使用新的 InstanceID 重新申请授权密钥。",
20
+ "The current database does not match the licensed database. Please use the new InstanceID to request a new license key.": "当前数据库与许可绑定的数据库不一致,请使用新的 InstanceID 重新申请授权密钥。",
21
+ "The current system and database do not match the licensed environment. Please use the new InstanceID to request a new license key.": "当前系统和数据库与许可绑定的环境不一致,请使用新的 InstanceID 重新申请授权密钥。",
22
+ "Domain mismatch.": "域名不匹配",
23
+ "The current domain ({{domain}}) does not match the licensed domain. Please use the current domain to request a new license key.": "当前域名({{domain}})与许可绑定的域名不一致,请使用当前域名重新申请授权密钥。",
24
+ "Plugin not licensed.": "插件未授权",
25
+ "An unlicensed plugin has been detected. Please visit the NocoBase Service to complete the purchase or obtain a license.": "检测到你正在使用未获得许可的插件,请前往 NocoBase Service 完成购买或授权。",
26
+ "Network error.": "网络异常",
27
+ "Due to network issues, the license key cannot be updated automatically. Please update it manually if necessary.": "由于网络问题,授权密钥无法自动更新,如有需要请手动更新。",
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
+ "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
+ "License key saved successfully. Please retry the plugin installation.": "授权密钥保存成功,请重新执行插件安装操作。",
31
+ "The license key was saved successfully": "授权密钥保存成功",
32
+ "License key not found.": "授权密钥未找到",
33
+ "Please go to the": "请前往",
34
+ "License Settings": "授权设置",
35
+ "page to enter the license key.": "页面填写授权密钥。",
36
+ "License information": "授权信息"
13
37
  }
@@ -7,3 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  export { default } from './plugin';
10
+ export * from './utils';
@@ -25,6 +25,7 @@ var __copyProps = (to, from, except, desc) => {
25
25
  }
26
26
  return to;
27
27
  };
28
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
28
29
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
30
  // If the importer is in node compatibility mode or this is not an ESM
30
31
  // file that has been converted to a CommonJS file using a Babel-
@@ -40,3 +41,8 @@ __export(server_exports, {
40
41
  });
41
42
  module.exports = __toCommonJS(server_exports);
42
43
  var import_plugin = __toESM(require("./plugin"));
44
+ __reExport(server_exports, require("./utils"), module.exports);
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ ...require("./utils")
48
+ });
@@ -7,9 +7,11 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
+ var __create = Object.create;
10
11
  var __defProp = Object.defineProperty;
11
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
13
  var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
13
15
  var __hasOwnProp = Object.prototype.hasOwnProperty;
14
16
  var __export = (target, all) => {
15
17
  for (var name in all)
@@ -23,6 +25,14 @@ var __copyProps = (to, from, except, desc) => {
23
25
  }
24
26
  return to;
25
27
  };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
26
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
37
  var plugin_exports = {};
28
38
  __export(plugin_exports, {
@@ -32,7 +42,7 @@ __export(plugin_exports, {
32
42
  module.exports = __toCommonJS(plugin_exports);
33
43
  var import_server = require("@nocobase/server");
34
44
  var import_utils = require("./utils");
35
- var import_license_kit = require("@nocobase/license-kit");
45
+ var import_pick = __toESM(require("lodash/pick"));
36
46
  class PluginLicenseServer extends import_server.Plugin {
37
47
  async afterAdd() {
38
48
  }
@@ -48,17 +58,70 @@ class PluginLicenseServer extends import_server.Plugin {
48
58
  },
49
59
  "license-key": async (ctx, next) => {
50
60
  const { licenseKey } = ctx.request.body;
51
- try {
52
- (0, import_license_kit.keyDecrypt)(licenseKey);
53
- } catch (e) {
54
- return ctx.throw(500, ctx.t("Invalid license key", { ns: "@nocobase/plugin-license" }));
61
+ const licenseValidate = await (0, import_utils.getLicenseValidate)({ key: licenseKey, ctx });
62
+ const licenseStatus = await (0, import_utils.getLicenseStatus)(licenseValidate.keyData);
63
+ ctx.body = {
64
+ ...licenseValidate,
65
+ licenseStatus
66
+ };
67
+ if (ctx.body.envMatch && ctx.body.domainMatch && ctx.body.licenseStatus === "active") {
68
+ await (0, import_utils.saveLicenseKey)(licenseKey, ctx);
55
69
  }
56
- await (0, import_utils.saveLicenseKey)(licenseKey);
57
70
  await next();
58
71
  },
59
72
  "is-exists": async (ctx, next) => {
60
73
  ctx.body = await (0, import_utils.isLicenseKeyExists)();
61
74
  await next();
75
+ },
76
+ "license-validate": async (ctx, next) => {
77
+ const isExist = await (0, import_utils.isLicenseKeyExists)();
78
+ if (!isExist) {
79
+ ctx.body = {
80
+ keyExist: false
81
+ };
82
+ await next();
83
+ return;
84
+ }
85
+ const licenseValidate = await (0, import_utils.getLicenseValidate)({ ctx });
86
+ ctx.body = {
87
+ keyExist: true,
88
+ ...licenseValidate,
89
+ keyData: (0, import_pick.default)(licenseValidate.keyData, ["service"])
90
+ };
91
+ await next();
92
+ },
93
+ "service-validate": async (ctx, next) => {
94
+ const keyExist = await (0, import_utils.isLicenseKeyExists)();
95
+ if (!keyExist) {
96
+ ctx.body = {
97
+ keyExist
98
+ };
99
+ await next();
100
+ return;
101
+ }
102
+ let isPkgConnection = false;
103
+ try {
104
+ isPkgConnection = await (0, import_utils.testPkgConnection)();
105
+ } catch (e) {
106
+ isPkgConnection = false;
107
+ }
108
+ let isPkgLogin = false;
109
+ let isServiceConnection = false;
110
+ try {
111
+ const keyData = await (0, import_utils.getLocalKeyData)();
112
+ isPkgLogin = await (0, import_utils.testPkgLogin)(keyData);
113
+ isServiceConnection = await (0, import_utils.testServiceConnection)(keyData);
114
+ } catch (e) {
115
+ isPkgLogin = false;
116
+ isServiceConnection = false;
117
+ }
118
+ ctx.body = {
119
+ keyExist,
120
+ isPkgConnection,
121
+ isPkgLogin,
122
+ isServiceConnection
123
+ };
124
+ await next();
62
125
  }
63
126
  }
64
127
  });
@@ -0,0 +1,16 @@
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 { Env } from '@nocobase/license-kit';
10
+ import { KeyData } from './interface';
11
+ export declare function getClientDomain(ctx: any): string;
12
+ export declare function isDomainMatch(currentDomain: string, keyData: KeyData): boolean;
13
+ export declare function isEnvMatch(env: Env, keyData: KeyData): boolean;
14
+ export declare function isDbMatch(env: Env, keyData: KeyData): boolean;
15
+ export declare function isSysMatch(env: Env, keyData: KeyData): boolean;
16
+ export declare function getEnvOnce(): any;
@@ -0,0 +1,125 @@
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
+ var __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
+ var env_exports = {};
38
+ __export(env_exports, {
39
+ getClientDomain: () => getClientDomain,
40
+ getEnvOnce: () => getEnvOnce,
41
+ isDbMatch: () => isDbMatch,
42
+ isDomainMatch: () => isDomainMatch,
43
+ isEnvMatch: () => isEnvMatch,
44
+ isSysMatch: () => isSysMatch
45
+ });
46
+ module.exports = __toCommonJS(env_exports);
47
+ var import_license_kit = require("@nocobase/license-kit");
48
+ var import_omit = __toESM(require("lodash/omit"));
49
+ var import_isEqual = __toESM(require("lodash/isEqual"));
50
+ function getClientDomain(ctx) {
51
+ var _a, _b, _c, _d;
52
+ if (!ctx) return "";
53
+ const referer = typeof ctx.get === "function" ? ctx.get("referer") : null;
54
+ if (referer) {
55
+ try {
56
+ return new URL(referer).origin;
57
+ } catch {
58
+ console.error("Invalid Referer URL:", referer);
59
+ }
60
+ }
61
+ const protocol = ((_a = ctx.headers) == null ? void 0 : _a["x-forwarded-proto"]) || ctx.protocol || ((_b = ctx.request) == null ? void 0 : _b.protocol) || "http";
62
+ const host = ((_c = ctx.headers) == null ? void 0 : _c["x-forwarded-host"]) || ctx.host || ((_d = ctx.request) == null ? void 0 : _d.host) || "";
63
+ return host ? `${protocol}://${host}` : "";
64
+ }
65
+ function matchSingleDomain(licenseDomain, currentDomain) {
66
+ let hostname = "";
67
+ let port = "";
68
+ try {
69
+ const url = new URL(currentDomain);
70
+ hostname = url.hostname;
71
+ port = url.port ? `:${url.port}` : "";
72
+ } catch {
73
+ return false;
74
+ }
75
+ const fullDomain = hostname + port;
76
+ if (!licenseDomain.includes("*")) {
77
+ return fullDomain === licenseDomain;
78
+ }
79
+ const base = licenseDomain.replace("*", "");
80
+ return fullDomain.endsWith(base);
81
+ }
82
+ function isDomainMatch(currentDomain, keyData) {
83
+ var _a;
84
+ if (!((_a = keyData == null ? void 0 : keyData.licenseKey) == null ? void 0 : _a.domain) || !currentDomain) return false;
85
+ const licenseDomains = keyData.licenseKey.domain.split(",").map((d) => d.trim()).filter(Boolean);
86
+ return licenseDomains.some((licenseDomain) => matchSingleDomain(licenseDomain, currentDomain));
87
+ }
88
+ function isEnvMatch(env, keyData) {
89
+ return isDbMatch(env, keyData) && isSysMatch(env, keyData);
90
+ }
91
+ function isDbMatch(env, keyData) {
92
+ var _a;
93
+ const a = env == null ? void 0 : env.db;
94
+ const b = (_a = keyData == null ? void 0 : keyData.instanceData) == null ? void 0 : _a.db;
95
+ if (!a || !b) return false;
96
+ if (a.id && b.id) return a.id === b.id;
97
+ return (0, import_isEqual.default)((0, import_omit.default)(a, ["id"]), (0, import_omit.default)(b, ["id"]));
98
+ }
99
+ function isSysMatch(env, keyData) {
100
+ const instance = keyData == null ? void 0 : keyData.instanceData;
101
+ if (!env || !instance) return false;
102
+ const normalize = (item) => {
103
+ if (!item) return null;
104
+ return {
105
+ sys: item.sys ?? null,
106
+ osVer: item.osVer ?? null
107
+ };
108
+ };
109
+ const a = normalize(env);
110
+ const b = normalize(instance);
111
+ return (0, import_isEqual.default)(a, b);
112
+ }
113
+ let envPromise;
114
+ function getEnvOnce() {
115
+ return envPromise ?? (envPromise = (0, import_license_kit.getEnvAsync)());
116
+ }
117
+ // Annotate the CommonJS export names for ESM import in node:
118
+ 0 && (module.exports = {
119
+ getClientDomain,
120
+ getEnvOnce,
121
+ isDbMatch,
122
+ isDomainMatch,
123
+ isEnvMatch,
124
+ isSysMatch
125
+ });
@@ -0,0 +1,15 @@
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 * from './key';
10
+ export * from './env';
11
+ export * from './interface';
12
+ export * from './license';
13
+ export * from './instance';
14
+ export * from './plugin';
15
+ export * from './pkg';
@@ -0,0 +1,42 @@
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
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var utils_exports = {};
25
+ module.exports = __toCommonJS(utils_exports);
26
+ __reExport(utils_exports, require("./key"), module.exports);
27
+ __reExport(utils_exports, require("./env"), module.exports);
28
+ __reExport(utils_exports, require("./interface"), module.exports);
29
+ __reExport(utils_exports, require("./license"), module.exports);
30
+ __reExport(utils_exports, require("./instance"), module.exports);
31
+ __reExport(utils_exports, require("./plugin"), module.exports);
32
+ __reExport(utils_exports, require("./pkg"), module.exports);
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ ...require("./key"),
36
+ ...require("./env"),
37
+ ...require("./interface"),
38
+ ...require("./license"),
39
+ ...require("./instance"),
40
+ ...require("./plugin"),
41
+ ...require("./pkg")
42
+ });
@@ -8,5 +8,4 @@
8
8
  */
9
9
  export declare function getInstanceId(): Promise<string>;
10
10
  export declare function createInstanceId(force?: boolean): Promise<unknown>;
11
- export declare function saveLicenseKey(licenseKey: string): Promise<void>;
12
11
  export declare function isLicenseKeyExists(): Promise<boolean>;
@@ -34,14 +34,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
34
34
  mod
35
35
  ));
36
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
- var utils_exports = {};
38
- __export(utils_exports, {
37
+ var instance_exports = {};
38
+ __export(instance_exports, {
39
39
  createInstanceId: () => createInstanceId,
40
40
  getInstanceId: () => getInstanceId,
41
- isLicenseKeyExists: () => isLicenseKeyExists,
42
- saveLicenseKey: () => saveLicenseKey
41
+ isLicenseKeyExists: () => isLicenseKeyExists
43
42
  });
44
- module.exports = __toCommonJS(utils_exports);
43
+ module.exports = __toCommonJS(instance_exports);
45
44
  var import_fs = __toESM(require("fs"));
46
45
  var import_path = __toESM(require("path"));
47
46
  var import_child_process = require("child_process");
@@ -63,11 +62,6 @@ async function createInstanceId(force = false) {
63
62
  });
64
63
  });
65
64
  }
66
- async function saveLicenseKey(licenseKey) {
67
- const dir = import_path.default.resolve(process.cwd(), "storage/.license");
68
- const filePath = import_path.default.resolve(dir, "license-key");
69
- import_fs.default.writeFileSync(filePath, licenseKey);
70
- }
71
65
  async function isLicenseKeyExists() {
72
66
  const dir = import_path.default.resolve(process.cwd(), "storage/.license");
73
67
  const filePath = import_path.default.resolve(dir, "license-key");
@@ -77,6 +71,5 @@ async function isLicenseKeyExists() {
77
71
  0 && (module.exports = {
78
72
  createInstanceId,
79
73
  getInstanceId,
80
- isLicenseKeyExists,
81
- saveLicenseKey
74
+ isLicenseKeyExists
82
75
  });