@nocobase/plugin-idp-oauth 2.3.0-beta.6 → 2.4.0-alpha.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.
@@ -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("antd"),require("@nocobase/client"),require("react-router-dom"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-idp-oauth",["react","antd","@nocobase/client","react-router-dom","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-idp-oauth"]=t(require("react"),require("antd"),require("@nocobase/client"),require("react-router-dom"),require("@nocobase/flow-engine")):e["@nocobase/plugin-idp-oauth"]=t(e.react,e.antd,e["@nocobase/client"],e["react-router-dom"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o){return function(){"use strict";var a={342:function(e){e.exports=n},694:function(e){e.exports=o},59:function(e){e.exports=t},155:function(t){t.exports=e},442:function(e){e.exports=r}},i={};function u(e){var t=i[e];if(void 0!==t)return t.exports;var n=i[e]={exports:{}};return a[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&&(c=u.g.location+"");var c,l=u.g.document;if(!c&&l&&(l.currentScript&&"SCRIPT"===l.currentScript.tagName.toUpperCase()&&(c=l.currentScript.src),!c)){var s=l.getElementsByTagName("script");if(s.length)for(var p=s.length-1;p>-1&&(!c||!/^http(s?):/.test(c));)c=s[p--].src}if(!c)throw Error("Automatic publicPath is not supported in this browser");u.p=c.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var f={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-idp-oauth/dist/client/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-idp-oauth/dist/client/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",a="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",c=i.indexOf(a);e=c>=0?i.slice(0,c+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-idp-oauth/dist/client/"}u.p=e}(),!function(){u.r(f),u.d(f,{default:function(){return B}});var e=u(342),t=u(59),n=u(155),r=u.n(n),o=u(442),a=u(694),i=JSON.parse('{"UU":"@nocobase/plugin-idp-oauth"}');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 l(e,t,n,r,o,a,i){try{var u=e[a](i),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).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){l(a,r,o,i,u,"next",e)}function u(e){l(a,r,o,i,u,"throw",e)}i(void 0)})}}function p(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,u=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){u=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(u)throw r}}return a}}(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 d(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),u=Object.defineProperty;return u(i,"next",{value:c(0)}),u(i,"throw",{value:c(1)}),u(i,"return",{value:c(2)}),"function"==typeof Symbol&&u(i,Symbol.iterator,{value:function(){return this}}),i;function c(u){return function(c){var l=[u,c];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}}}}function y(e,t){var n;return(null!=(n=Error)&&"u">typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):e instanceof n)?e.message:t}var m=function(){var u,c=(0,e.useAPIClient)(),l=(0,e.useApp)(),f=(0,o.useLocation)(),m=(0,o.useNavigate)(),h=(u=(0,a.useFlowEngine)(),(0,n.useCallback)(function(e,t){return u.context.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.UU,"client"]},t))},[u])),v=p((0,o.useSearchParams)(),2),b=v[0],g=v[1],w=p((0,n.useState)(!0),2),E=w[0],x=w[1],S=p((0,n.useState)(!1),2),O=S[0],C=S[1],_=p((0,n.useState)(null),2),T=_[0],A=_[1],k=p((0,n.useState)(null),2),j=k[0],I=k[1],P=b.get("user_code")||void 0,B=(0,n.useCallback)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;return s(function(){var n,r;return d(this,function(o){switch(o.label){case 0:return[4,c.request({url:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"".concat("main"===e?"":"__app/".concat(e,"/"),"idpOAuth/device/verification").concat(t)}(l.name,e),method:e?"post":"get",skipNotify:!0,params:e?void 0:{user_code:P},data:t})];case 1:return[2,(null==(r=o.sent())||null==(n=r.data)?void 0:n.data)||(null==r?void 0:r.data)]}})})()},[c,l.name,P]),q=(0,n.useCallback)(function(){return s(function(){var e;return d(this,function(t){switch(t.label){case 0:x(!0),A(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,B()];case 2:if(I(e=t.sent()),"login"===e.status){var n,r,o,a;return m("/signin?redirect=".concat(encodeURIComponent((n=f.pathname,r=f.search,a=(o=e.userCode||P)?"?user_code=".concat(encodeURIComponent(o)):r,"".concat(n).concat(a)))),{replace:!0}),[2]}return[3,5];case 3:return A(y(t.sent(),h("Failed to load device sign-in."))),[3,5];case 4:return x(!1),[7];case 5:return[2]}})})()},[f.pathname,f.search,m,B,h,P]);(0,n.useEffect)(function(){q()},[q]);var R=(0,n.useCallback)(function(e){var t=e.user_code,n=null==t?void 0:t.trim();n&&g({user_code:n})},[g]),M=(0,n.useCallback)(function(e){return s(function(){return d(this,function(t){switch(t.label){case 0:C(!0),A(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,B(e,{user_code:(null==j?void 0:j.userCode)||P})];case 2:return I(t.sent()),[3,5];case 3:return A(y(t.sent(),h("Failed to submit device sign-in."))),[3,5];case 4:return C(!1),[7];case 5:return[2]}})})()},[null==j?void 0:j.userCode,B,h,P]);if(E)return r().createElement("div",{style:{position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}},r().createElement(t.Spin,{style:{fontSize:72}}));if(T)return r().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Alert,{type:"error",message:T,showIcon:!0}));if(!j||"missing_code"===j.status)return r().createElement("div",{style:{maxWidth:440,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Card,null,r().createElement(t.Space,{direction:"vertical",size:"large",style:{width:"100%"}},r().createElement("div",null,r().createElement(t.Typography.Title,{level:3,style:{marginBottom:8}},h("Device sign-in")),r().createElement(t.Typography.Paragraph,{style:{marginBottom:0}},h("Enter the code shown in your terminal to continue signing in."))),r().createElement(t.Form,{layout:"vertical",onFinish:R},r().createElement(t.Form.Item,{name:"user_code",rules:[{required:!0,message:h("Enter the device code.")}]},r().createElement(t.Input,{autoFocus:!0,size:"large",style:{textTransform:"uppercase"}})),r().createElement(t.Button,{type:"primary",htmlType:"submit",block:!0},h("Continue"))))));if("complete"===j.status)return r().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Result,{status:"success",title:h("Device sign-in complete"),subTitle:h("Authorization is complete. You can return to the terminal."),extra:r().createElement(t.Button,{type:"primary",onClick:function(){return m("/")}},h("Back to home"))}));if("cancelled"===j.status)return r().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Result,{status:"warning",title:h("Device sign-in cancelled"),subTitle:h("The device sign-in request was cancelled.")}));if("pending"!==j.status){var F={not_found:h("The device code was not found."),expired:h("The device code has expired."),already_used:h("The device code has already been used.")};return r().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Result,{status:"error",title:h("Device sign-in failed"),subTitle:F[j.status]}))}return r().createElement("div",{style:{maxWidth:520,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Card,null,r().createElement(t.Space,{direction:"vertical",size:"large",style:{width:"100%"}},r().createElement("div",null,r().createElement(t.Typography.Title,{level:3,style:{marginBottom:8}},h("Confirm device")),r().createElement(t.Typography.Paragraph,{style:{marginBottom:0}},h("{{clientName}} is requesting access. Confirm that this code matches the one shown in your terminal.",{clientName:j.clientName||h("Application")}))),r().createElement(t.Typography.Title,{level:2,style:{margin:0,letterSpacing:"0.08em",textAlign:"center"}},j.userCode),r().createElement(t.Space,null,r().createElement(t.Button,{type:"primary",loading:O,onClick:function(){return M(":approve")}},h("Continue")),r().createElement(t.Button,{loading:O,onClick:function(){return M(":cancel")}},h("Cancel"))))))};function h(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 v=function(){var e,n=(function(e){if(Array.isArray(e))return e}(e=(0,o.useSearchParams)())||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),1!==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}}(e)||function(e){if(e){if("string"==typeof e)return h(e,1);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 h(e,1)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],a=n.get("error"),i=n.get("error_description"),u=n.get("iss");return r().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Result,{status:"error",title:a||"Authentication failed",subTitle:i||void 0}),r().createElement(t.Space,{direction:"vertical",size:"middle",style:{width:"100%"}},u?r().createElement("div",null,r().createElement(t.Typography.Text,{type:"secondary"},"Issuer"),r().createElement("div",null,r().createElement(t.Typography.Text,{code:!0},u))):null))};function b(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 g(e,t,n,r,o,a,i){try{var u=e[a](i),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function w(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){g(a,r,o,i,u,"next",e)}function u(e){g(a,r,o,i,u,"throw",e)}i(void 0)})}}function E(e,t){return null!=t&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}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,u=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){u=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(u)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return b(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 b(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 S(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),u=Object.defineProperty;return u(i,"next",{value:c(0)}),u(i,"throw",{value:c(1)}),u(i,"return",{value:c(2)}),"function"==typeof Symbol&&u(i,Symbol.iterator,{value:function(){return this}}),i;function c(u){return function(c){var l=[u,c];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}}}}function O(e,t){return E(e,Error)?e.message:t}var C=function(){var a=(0,e.useAPIClient)(),i=(0,e.useApp)(),u=(0,o.useNavigate)(),c=(0,o.useParams)(),l=x((0,n.useState)(!0),2),s=l[0],p=l[1],f=x((0,n.useState)(null),2),d=f[0],y=f[1],m=x((0,n.useState)(null),2),h=m[0],v=m[1],b=(0,n.useMemo)(function(){return c.uid?"main"===i.name?"idpOAuth/interaction/".concat(c.uid):"__app/".concat(i.name,"/idpOAuth/interaction/").concat(c.uid):null},[i.name,c.uid]),g=(0,n.useMemo)(function(){return c.uid?"/idp-oauth/interaction/".concat(c.uid):"/signin"},[c.uid]),C=(0,n.useCallback)(function(e,t){return w(function(){var n,r,o,i,c;return S(this,function(l){switch(l.label){case 0:if(!b)return y("Invalid interaction path"),p(!1),[2];return r=a.auth.getToken(),o=a.auth.getAuthenticator()||"basic",[4,a.request({url:b,method:e,skipNotify:!0,withCredentials:!0,data:"post"===e?t:void 0,headers:r?{Authorization:"Bearer ".concat(r),"X-Authenticator":o}:void 0})];case 1:if(null==(c=(null==(i=l.sent())||null==(n=i.data)?void 0:n.data)||(null==i?void 0:i.data))?void 0:c.redirectTo)return window.location.replace(c.redirectTo),[2];if((null==c?void 0:c.prompt)!=="login")return[3,4];if(!r)return u("/signin?redirect=".concat(encodeURIComponent(g)),{replace:!0}),[2];if("get"!==e)return[3,3];return[4,C("post")];case 2:return l.sent(),[2];case 3:return u("/signin?redirect=".concat(encodeURIComponent(g)),{replace:!0}),[2];case 4:return v(c),p(!1),[2]}})})()},[a,g,b,u]),_=(0,n.useCallback)(function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return w(function(){return S(this,function(t){switch(t.label){case 0:p(!0),y(null),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,C("post",e?{cancel:1}:{submit:1})];case 2:return t.sent(),[3,4];case 3:return y(O(t.sent(),"Failed to submit interaction")),p(!1),[3,4];case 4:return[2]}})})()},[C]);return((0,n.useEffect)(function(){var e=!1;return w(function(){var t;return S(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,C("get")];case 1:return n.sent(),[3,3];case 2:return t=n.sent(),e||(y(O(t,"Failed to load interaction")),p(!1)),[3,3];case 3:return[2]}})})(),function(){e=!0}},[C]),(0,n.useEffect)(function(){if((null==h?void 0:h.prompt)==="consent"&&!s){var e=function(e){if(!e.defaultPrevented){var t=e.target;if(null==t||!t.closest('input, textarea, select, [contenteditable="true"]')){if("Enter"===e.key&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey){var n=document.activeElement;if(E(n,HTMLButtonElement)||E(n,HTMLAnchorElement))return;e.preventDefault(),_(!1);return}"Escape"===e.key&&(e.preventDefault(),_(!0))}}};return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)}}},[null==h?void 0:h.prompt,s,_]),s)?r().createElement("div",{style:{position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}},r().createElement(t.Spin,{style:{fontSize:72}})):d?r().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Alert,{type:"error",message:d,showIcon:!0})):(null==h?void 0:h.prompt)==="consent"?r().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Card,null,r().createElement(t.Space,{direction:"vertical",size:"large",style:{width:"100%"}},r().createElement("div",null,r().createElement(t.Typography.Title,{level:3,style:{marginBottom:8}},"Authorize application"),r().createElement(t.Typography.Paragraph,{style:{marginBottom:0}},h.clientName||"Application"," requests access to your account.")),h.details?r().createElement(t.Alert,{type:"info",showIcon:!0,message:"Requested permissions",description:h.details}):null,r().createElement(t.Space,null,r().createElement(t.Button,{type:"primary",loading:s,onClick:function(){return _(!1)}},"Continue"),r().createElement(t.Button,{loading:s,onClick:function(){return _(!0)}},"Cancel"))))):r().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Result,{title:"Redirecting...",subTitle:"Please wait while authorization continues."}))},_={};function T(e,t,n,r,o,a,i){try{var u=e[a](i),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function A(e,t,n){return(A=P()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&j(o,n.prototype),o}).apply(null,arguments)}function k(e){return(k=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function j(e,t){return(j=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,n)}function n(){return A(e,arguments,k(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),j(n,e)})(e)}function P(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(P=function(){return!!e})()}var B=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=k(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,P()?Reflect.construct(e,t||[],k(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&j(n,e),t=[{key:"load",value:function(){var e;return(e=function(){var e;return function(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),u=Object.defineProperty;return u(i,"next",{value:c(0)}),u(i,"throw",{value:c(1)}),u(i,"return",{value:c(2)}),"function"==typeof Symbol&&u(i,Symbol.iterator,{value:function(){return this}}),i;function c(u){return function(c){var l=[u,c];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}}}}(this,function(t){return e=this,e.flowEngine.registerModels(_),e.router.add("idp-oauth.interaction",{path:"/idp-oauth/interaction/:uid",Component:C,skipAuthCheck:!0}),e.router.add("idp-oauth.device",{path:"/idpOAuth/device",Component:m,skipAuthCheck:!0}),e.router.add("idp-oauth.error",{path:"/idp-oauth/error",Component:v,skipAuthCheck:!0}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){T(a,r,o,i,u,"next",e)}function u(e){T(a,r,o,i,u,"throw",e)}i(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)}}(n.prototype,t),n}(I(e.Plugin))}(),f}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("antd"),require("@nocobase/client"),require("react-router-dom"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-idp-oauth",["react","antd","@nocobase/client","react-router-dom","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-idp-oauth"]=t(require("react"),require("antd"),require("@nocobase/client"),require("react-router-dom"),require("@nocobase/flow-engine")):e["@nocobase/plugin-idp-oauth"]=t(e.react,e.antd,e["@nocobase/client"],e["react-router-dom"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o){return function(){"use strict";var a={342:function(e){e.exports=n},694:function(e){e.exports=o},59:function(e){e.exports=t},155:function(t){t.exports=e},442:function(e){e.exports=r}},i={};function u(e){var t=i[e];if(void 0!==t)return t.exports;var n=i[e]={exports:{}};return a[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&&(c=u.g.location+"");var c,l=u.g.document;if(!c&&l&&(l.currentScript&&"SCRIPT"===l.currentScript.tagName.toUpperCase()&&(c=l.currentScript.src),!c)){var s=l.getElementsByTagName("script");if(s.length)for(var p=s.length-1;p>-1&&(!c||!/^http(s?):/.test(c));)c=s[p--].src}if(!c)throw Error("Automatic publicPath is not supported in this browser");u.p=c.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var f={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-idp-oauth/dist/client/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-idp-oauth/dist/client/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",a="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",c=i.indexOf(a);e=c>=0?i.slice(0,c+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-idp-oauth/dist/client/"}u.p=e}(),!function(){u.r(f),u.d(f,{default:function(){return B}});var e=u(342),t=u(59),n=u(155),r=u.n(n),o=u(442),a=u(694),i=JSON.parse('{"UU":"@nocobase/plugin-idp-oauth"}');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 l(e,t,n,r,o,a,i){try{var u=e[a](i),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).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){l(a,r,o,i,u,"next",e)}function u(e){l(a,r,o,i,u,"throw",e)}i(void 0)})}}function p(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,u=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){u=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(u)throw r}}return a}}(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 d(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),u=Object.defineProperty;return u(i,"next",{value:c(0)}),u(i,"throw",{value:c(1)}),u(i,"return",{value:c(2)}),"function"==typeof Symbol&&u(i,Symbol.iterator,{value:function(){return this}}),i;function c(u){return function(c){var l=[u,c];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}}}}function m(e,t){var n;return(null!=(n=Error)&&"u">typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):e instanceof n)?e.message:t}var y=function(){var u,c=(0,e.useAPIClient)(),l=(0,e.useApp)(),f=(0,o.useLocation)(),y=(0,o.useNavigate)(),h=(u=(0,a.useFlowEngine)(),(0,n.useCallback)(function(e,t){return u.context.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.UU,"client"]},t))},[u])),v=p((0,o.useSearchParams)(),2),b=v[0],g=v[1],w=p((0,n.useState)(!0),2),E=w[0],x=w[1],S=p((0,n.useState)(!1),2),C=S[0],O=S[1],A=p((0,n.useState)(null),2),k=A[0],_=A[1],T=p((0,n.useState)(null),2),j=T[0],I=T[1],P=b.get("user_code")||void 0,B=(0,n.useCallback)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;return s(function(){var n,r;return d(this,function(o){switch(o.label){case 0:return[4,c.request({url:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"".concat("main"===e?"":"__app/".concat(e,"/"),"idpOAuth/device/verification").concat(t)}(l.name,e),method:e?"post":"get",skipNotify:!0,params:e?void 0:{user_code:P},data:t})];case 1:return[2,(null==(r=o.sent())||null==(n=r.data)?void 0:n.data)||(null==r?void 0:r.data)]}})})()},[c,l.name,P]),q=(0,n.useCallback)(function(){return s(function(){var e;return d(this,function(t){switch(t.label){case 0:x(!0),_(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,B()];case 2:if(I(e=t.sent()),"login"===e.status){var n,r,o,a;return y("/signin?redirect=".concat(encodeURIComponent((n=f.pathname,r=f.search,a=(o=e.userCode||P)?"?user_code=".concat(encodeURIComponent(o)):r,"".concat(n).concat(a)))),{replace:!0}),[2]}return[3,5];case 3:return _(m(t.sent(),h("Failed to load device sign-in."))),[3,5];case 4:return x(!1),[7];case 5:return[2]}})})()},[f.pathname,f.search,y,B,h,P]);(0,n.useEffect)(function(){q()},[q]);var R=(0,n.useCallback)(function(e){var t=e.user_code,n=null==t?void 0:t.trim();n&&g({user_code:n})},[g]),M=(0,n.useCallback)(function(e){return s(function(){return d(this,function(t){switch(t.label){case 0:O(!0),_(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,B(e,{user_code:(null==j?void 0:j.userCode)||P})];case 2:return I(t.sent()),[3,5];case 3:return _(m(t.sent(),h("Failed to submit device sign-in."))),[3,5];case 4:return O(!1),[7];case 5:return[2]}})})()},[null==j?void 0:j.userCode,B,h,P]);if(E)return r().createElement("div",{style:{position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}},r().createElement(t.Spin,{style:{fontSize:72}}));if(k)return r().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Alert,{type:"error",message:k,showIcon:!0}));if(!j||"missing_code"===j.status)return r().createElement("div",{style:{maxWidth:440,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Card,null,r().createElement(t.Space,{direction:"vertical",size:"large",style:{width:"100%"}},r().createElement("div",null,r().createElement(t.Typography.Title,{level:3,style:{marginBottom:8}},h("Device sign-in")),r().createElement(t.Typography.Paragraph,{style:{marginBottom:0}},h("Enter the code shown in your terminal to continue signing in."))),r().createElement(t.Form,{layout:"vertical",onFinish:R},r().createElement(t.Form.Item,{name:"user_code",rules:[{required:!0,message:h("Enter the device code.")}]},r().createElement(t.Input,{autoFocus:!0,size:"large",style:{textTransform:"uppercase"}})),r().createElement(t.Button,{type:"primary",htmlType:"submit",block:!0},h("Continue"))))));if("complete"===j.status)return r().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Result,{status:"success",title:h("Device sign-in complete"),subTitle:h("Authorization is complete. You can return to the terminal."),extra:r().createElement(t.Button,{type:"primary",onClick:function(){var e;return y((e=f.pathname,/(^|\/)settings(\/|$)/.test(e)?"/settings/":"/"))}},h("Back to home"))}));if("cancelled"===j.status)return r().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Result,{status:"warning",title:h("Device sign-in cancelled"),subTitle:h("The device sign-in request was cancelled.")}));if("pending"!==j.status){var F={not_found:h("The device code was not found."),expired:h("The device code has expired."),already_used:h("The device code has already been used.")};return r().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Result,{status:"error",title:h("Device sign-in failed"),subTitle:F[j.status]}))}return r().createElement("div",{style:{maxWidth:520,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Card,null,r().createElement(t.Space,{direction:"vertical",size:"large",style:{width:"100%"}},r().createElement("div",null,r().createElement(t.Typography.Title,{level:3,style:{marginBottom:8}},h("Confirm device")),r().createElement(t.Typography.Paragraph,{style:{marginBottom:0}},h("{{clientName}} is requesting access. Confirm that this code matches the one shown in your terminal.",{clientName:j.clientName||h("Application")}))),r().createElement(t.Typography.Title,{level:2,style:{margin:0,letterSpacing:"0.08em",textAlign:"center"}},j.userCode),r().createElement(t.Space,null,r().createElement(t.Button,{type:"primary",loading:C,onClick:function(){return M(":approve")}},h("Continue")),r().createElement(t.Button,{loading:C,onClick:function(){return M(":cancel")}},h("Cancel"))))))};function h(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 v=function(){var e,n=(function(e){if(Array.isArray(e))return e}(e=(0,o.useSearchParams)())||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),1!==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}}(e)||function(e){if(e){if("string"==typeof e)return h(e,1);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 h(e,1)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],a=n.get("error"),i=n.get("error_description"),u=n.get("iss");return r().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Result,{status:"error",title:a||"Authentication failed",subTitle:i||void 0}),r().createElement(t.Space,{direction:"vertical",size:"middle",style:{width:"100%"}},u?r().createElement("div",null,r().createElement(t.Typography.Text,{type:"secondary"},"Issuer"),r().createElement("div",null,r().createElement(t.Typography.Text,{code:!0},u))):null))};function b(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 g(e,t,n,r,o,a,i){try{var u=e[a](i),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function w(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){g(a,r,o,i,u,"next",e)}function u(e){g(a,r,o,i,u,"throw",e)}i(void 0)})}}function E(e,t){return null!=t&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}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,u=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){u=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(u)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return b(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 b(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 S(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),u=Object.defineProperty;return u(i,"next",{value:c(0)}),u(i,"throw",{value:c(1)}),u(i,"return",{value:c(2)}),"function"==typeof Symbol&&u(i,Symbol.iterator,{value:function(){return this}}),i;function c(u){return function(c){var l=[u,c];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}}}}function C(e,t){return E(e,Error)?e.message:t}var O=function(){var a=(0,e.useAPIClient)(),i=(0,e.useApp)(),u=(0,o.useNavigate)(),c=(0,o.useParams)(),l=x((0,n.useState)(!0),2),s=l[0],p=l[1],f=x((0,n.useState)(null),2),d=f[0],m=f[1],y=x((0,n.useState)(null),2),h=y[0],v=y[1],b=(0,n.useMemo)(function(){return c.uid?"main"===i.name?"idpOAuth/interaction/".concat(c.uid):"__app/".concat(i.name,"/idpOAuth/interaction/").concat(c.uid):null},[i.name,c.uid]),g=(0,n.useMemo)(function(){return c.uid?"/idp-oauth/interaction/".concat(c.uid):"/signin"},[c.uid]),O=(0,n.useCallback)(function(e,t){return w(function(){var n,r,o,i,c;return S(this,function(l){switch(l.label){case 0:if(!b)return m("Invalid interaction path"),p(!1),[2];return r=a.auth.getToken(),o=a.auth.getAuthenticator()||"basic",[4,a.request({url:b,method:e,skipNotify:!0,withCredentials:!0,data:"post"===e?t:void 0,headers:r?{Authorization:"Bearer ".concat(r),"X-Authenticator":o}:void 0})];case 1:if(null==(c=(null==(i=l.sent())||null==(n=i.data)?void 0:n.data)||(null==i?void 0:i.data))?void 0:c.redirectTo)return window.location.replace(c.redirectTo),[2];if((null==c?void 0:c.prompt)!=="login")return[3,4];if(!r)return u("/signin?redirect=".concat(encodeURIComponent(g)),{replace:!0}),[2];if("get"!==e)return[3,3];return[4,O("post")];case 2:return l.sent(),[2];case 3:return u("/signin?redirect=".concat(encodeURIComponent(g)),{replace:!0}),[2];case 4:return v(c),p(!1),[2]}})})()},[a,g,b,u]),A=(0,n.useCallback)(function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return w(function(){return S(this,function(t){switch(t.label){case 0:p(!0),m(null),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,O("post",e?{cancel:1}:{submit:1})];case 2:return t.sent(),[3,4];case 3:return m(C(t.sent(),"Failed to submit interaction")),p(!1),[3,4];case 4:return[2]}})})()},[O]);return((0,n.useEffect)(function(){var e=!1;return w(function(){var t;return S(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,O("get")];case 1:return n.sent(),[3,3];case 2:return t=n.sent(),e||(m(C(t,"Failed to load interaction")),p(!1)),[3,3];case 3:return[2]}})})(),function(){e=!0}},[O]),(0,n.useEffect)(function(){if((null==h?void 0:h.prompt)==="consent"&&!s){var e=function(e){if(!e.defaultPrevented){var t=e.target;if(null==t||!t.closest('input, textarea, select, [contenteditable="true"]')){if("Enter"===e.key&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey){var n=document.activeElement;if(E(n,HTMLButtonElement)||E(n,HTMLAnchorElement))return;e.preventDefault(),A(!1);return}"Escape"===e.key&&(e.preventDefault(),A(!0))}}};return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)}}},[null==h?void 0:h.prompt,s,A]),s)?r().createElement("div",{style:{position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}},r().createElement(t.Spin,{style:{fontSize:72}})):d?r().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Alert,{type:"error",message:d,showIcon:!0})):(null==h?void 0:h.prompt)==="consent"?r().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Card,null,r().createElement(t.Space,{direction:"vertical",size:"large",style:{width:"100%"}},r().createElement("div",null,r().createElement(t.Typography.Title,{level:3,style:{marginBottom:8}},"Authorize application"),r().createElement(t.Typography.Paragraph,{style:{marginBottom:0}},h.clientName||"Application"," requests access to your account.")),h.details?r().createElement(t.Alert,{type:"info",showIcon:!0,message:"Requested permissions",description:h.details}):null,r().createElement(t.Space,null,r().createElement(t.Button,{type:"primary",loading:s,onClick:function(){return A(!1)}},"Continue"),r().createElement(t.Button,{loading:s,onClick:function(){return A(!0)}},"Cancel"))))):r().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},r().createElement(t.Result,{title:"Redirecting...",subTitle:"Please wait while authorization continues."}))},A={};function k(e,t,n,r,o,a,i){try{var u=e[a](i),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function _(e,t,n){return(_=P()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&j(o,n.prototype),o}).apply(null,arguments)}function T(e){return(T=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function j(e,t){return(j=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,n)}function n(){return _(e,arguments,T(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),j(n,e)})(e)}function P(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(P=function(){return!!e})()}var B=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=T(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,P()?Reflect.construct(e,t||[],T(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&j(n,e),t=[{key:"load",value:function(){var e;return(e=function(){var e;return function(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),u=Object.defineProperty;return u(i,"next",{value:c(0)}),u(i,"throw",{value:c(1)}),u(i,"return",{value:c(2)}),"function"==typeof Symbol&&u(i,Symbol.iterator,{value:function(){return this}}),i;function c(u){return function(c){var l=[u,c];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}}}}(this,function(t){return e=this,e.flowEngine.registerModels(A),e.router.add("idp-oauth.interaction",{path:"/idp-oauth/interaction/:uid",Component:O,skipAuthCheck:!0}),e.router.add("idp-oauth.device",{path:"/settings/idpOAuth/device",Component:y,skipAuthCheck:!0}),e.router.add("idp-oauth-legacy-device",{path:"/idpOAuth/device",Component:y,skipAuthCheck:!0}),e.router.add("idp-oauth-modern-legacy-device",{path:"/v/idpOAuth/device",Component:y,skipAuthCheck:!0}),e.router.add("idp-oauth.error",{path:"/idp-oauth/error",Component:v,skipAuthCheck:!0}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){k(a,r,o,i,u,"next",e)}function u(e){k(a,r,o,i,u,"throw",e)}i(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)}}(n.prototype,t),n}(I(e.Plugin))}(),f}()});
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- "use strict";(self.webpackChunk_nocobase_plugin_idp_oauth_client_v2=self.webpackChunk_nocobase_plugin_idp_oauth_client_v2||[]).push([["711"],{290:function(e,t,n){n.r(t);var r=n(694),a=n(59),i=n(155),o=n.n(i),l=n(442),c=n(143);function u(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 s(e,t,n,r,a,i,o){try{var l=e[i](o),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,a)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var i=e.apply(t,n);function o(e){s(i,r,a,o,l,"next",e)}function l(e){s(i,r,a,o,l,"throw",e)}o(void 0)})}}function p(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 i=[],o=!0,l=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(i.push(n.value),!t||i.length!==t);o=!0);}catch(e){l=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return u(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 u(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 m(e,t){var n,r,a,i={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),l=Object.defineProperty;return l(o,"next",{value:c(0)}),l(o,"throw",{value:c(1)}),l(o,"return",{value:c(2)}),"function"==typeof Symbol&&l(o,Symbol.iterator,{value:function(){return this}}),o;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){i.label=u[1];break}if(6===u[0]&&i.label<a[1]){i.label=a[1],a=u;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(u);break}a[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function f(e,t){var n;return(null!=(n=Error)&&"u">typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):e instanceof n)?e.message:t}t.default=function(){var e=(0,r.useFlowContext)(),t=e.api,n=e.app,u=(0,l.useLocation)(),s=(0,l.useNavigate)(),h=(0,c.k)(),y=(0,i.useRef)(t),v=(0,i.useRef)(s),g=(0,i.useRef)(h),b=p((0,l.useSearchParams)(),2),E=b[0],x=b[1],w=p((0,i.useState)(!0),2),C=w[0],S=w[1],_=p((0,i.useState)(!1),2),k=_[0],T=_[1],O=p((0,i.useState)(null),2),A=O[0],I=O[1],j=p((0,i.useState)(null),2),B=j[0],P=j[1],F=(null==n?void 0:n.name)||"main",R=E.get("user_code")||void 0;y.current=t,v.current=s,g.current=h;var U=(0,i.useCallback)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;return d(function(){var n,r,a,i,o;return m(this,function(l){switch(l.label){case 0:return a=(r=y.current).auth.getToken(),i=r.auth.getAuthenticator()||"basic",[4,r.request({url:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"".concat("main"===e?"":"__app/".concat(e,"/"),"idpOAuth/device/verification").concat(t)}(F,e),method:e?"post":"get",skipNotify:!0,withCredentials:!0,params:e?void 0:{user_code:R},data:t,headers:a?{Authorization:"Bearer ".concat(a),"X-Authenticator":i}:void 0})];case 1:return[2,(null==(o=l.sent())||null==(n=o.data)?void 0:n.data)||(null==o?void 0:o.data)]}})})()},[F,R]),z=(0,i.useCallback)(function(){return d(function(){var e;return m(this,function(t){switch(t.label){case 0:S(!0),I(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,U()];case 2:if(P(e=t.sent()),"login"===e.status){var n,r,a,i;return v.current("/signin?redirect=".concat(encodeURIComponent((n=u.pathname,r=u.search,i=(a=e.userCode||R)?"?user_code=".concat(encodeURIComponent(a)):r,"".concat(n).concat(i)))),{replace:!0}),[2]}return[3,5];case 3:return I(f(t.sent(),g.current("Failed to load device sign-in."))),[3,5];case 4:return S(!1),[7];case 5:return[2]}})})()},[u.pathname,u.search,U,R]);(0,i.useEffect)(function(){z()},[z]);var N=(0,i.useCallback)(function(e){var t=e.user_code,n=null==t?void 0:t.trim();n&&x({user_code:n})},[x]),W=(0,i.useCallback)(function(e){return d(function(){return m(this,function(t){switch(t.label){case 0:T(!0),I(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,U(e,{user_code:(null==B?void 0:B.userCode)||R})];case 2:return P(t.sent()),[3,5];case 3:return I(f(t.sent(),h("Failed to submit device sign-in."))),[3,5];case 4:return T(!1),[7];case 5:return[2]}})})()},[null==B?void 0:B.userCode,U,h,R]);if(C)return o().createElement("div",{style:{position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}},o().createElement(a.Spin,{style:{fontSize:72}}));if(A)return o().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},o().createElement(a.Alert,{type:"error",message:A,showIcon:!0}));if(!B||"missing_code"===B.status)return o().createElement("div",{style:{maxWidth:440,margin:"48px auto",padding:"0 24px"}},o().createElement(a.Card,null,o().createElement(a.Space,{direction:"vertical",size:"large",style:{width:"100%"}},o().createElement("div",null,o().createElement(a.Typography.Title,{level:3,style:{marginBottom:8}},h("Device sign-in")),o().createElement(a.Typography.Paragraph,{style:{marginBottom:0}},h("Enter the code shown in your terminal to continue signing in."))),o().createElement(a.Form,{layout:"vertical",onFinish:N},o().createElement(a.Form.Item,{name:"user_code",rules:[{required:!0,message:h("Enter the device code.")}]},o().createElement(a.Input,{autoFocus:!0,size:"large",style:{textTransform:"uppercase"}})),o().createElement(a.Button,{type:"primary",htmlType:"submit",block:!0},h("Continue"))))));if("complete"===B.status)return o().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},o().createElement(a.Result,{status:"success",title:h("Device sign-in complete"),subTitle:h("Authorization is complete. You can return to the terminal."),extra:o().createElement(a.Button,{type:"primary",onClick:function(){return s("/")}},h("Back to home"))}));if("cancelled"===B.status)return o().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},o().createElement(a.Result,{status:"warning",title:h("Device sign-in cancelled"),subTitle:h("The device sign-in request was cancelled.")}));if("pending"!==B.status){var D={not_found:h("The device code was not found."),expired:h("The device code has expired."),already_used:h("The device code has already been used.")};return o().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},o().createElement(a.Result,{status:"error",title:h("Device sign-in failed"),subTitle:D[B.status]}))}return o().createElement("div",{style:{maxWidth:520,margin:"48px auto",padding:"0 24px"}},o().createElement(a.Card,null,o().createElement(a.Space,{direction:"vertical",size:"large",style:{width:"100%"}},o().createElement("div",null,o().createElement(a.Typography.Title,{level:3,style:{marginBottom:8}},h("Confirm device")),o().createElement(a.Typography.Paragraph,{style:{marginBottom:0}},h("{{clientName}} is requesting access. Confirm that this code matches the one shown in your terminal.",{clientName:B.clientName||h("Application")}))),o().createElement(a.Typography.Title,{level:2,style:{margin:0,letterSpacing:"0.08em",textAlign:"center"}},B.userCode),o().createElement(a.Space,null,o().createElement(a.Button,{type:"primary",loading:k,onClick:function(){return W(":approve")}},h("Continue")),o().createElement(a.Button,{loading:k,onClick:function(){return W(":cancel")}},h("Cancel"))))))}},143:function(e,t,n){n.d(t,{k:function(){return o}});var r=n(694),a=n(155),i=JSON.parse('{"UU":"@nocobase/plugin-idp-oauth"}');function o(){var e=(0,r.useFlowEngine)();return(0,a.useCallback)(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:[i.UU,"client"]},n))},[e])}}}]);
10
+ "use strict";(self.webpackChunk_nocobase_plugin_idp_oauth_client_v2=self.webpackChunk_nocobase_plugin_idp_oauth_client_v2||[]).push([["711"],{290:function(e,t,n){n.r(t);var r=n(694),a=n(59),i=n(155),o=n.n(i),l=n(442),c=n(143);function u(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 s(e,t,n,r,a,i,o){try{var l=e[i](o),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,a)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var i=e.apply(t,n);function o(e){s(i,r,a,o,l,"next",e)}function l(e){s(i,r,a,o,l,"throw",e)}o(void 0)})}}function p(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 i=[],o=!0,l=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(i.push(n.value),!t||i.length!==t);o=!0);}catch(e){l=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return u(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 u(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 m(e,t){var n,r,a,i={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),l=Object.defineProperty;return l(o,"next",{value:c(0)}),l(o,"throw",{value:c(1)}),l(o,"return",{value:c(2)}),"function"==typeof Symbol&&l(o,Symbol.iterator,{value:function(){return this}}),o;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){i.label=u[1];break}if(6===u[0]&&i.label<a[1]){i.label=a[1],a=u;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(u);break}a[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function f(e,t){var n;return(null!=(n=Error)&&"u">typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):e instanceof n)?e.message:t}t.default=function(){var e=(0,r.useFlowContext)(),t=e.api,n=e.app,u=(0,l.useLocation)(),s=(0,l.useNavigate)(),h=(0,c.k)(),y=(0,i.useRef)(t),v=(0,i.useRef)(s),g=(0,i.useRef)(h),b=p((0,l.useSearchParams)(),2),E=b[0],x=b[1],w=p((0,i.useState)(!0),2),C=w[0],S=w[1],_=p((0,i.useState)(!1),2),k=_[0],T=_[1],O=p((0,i.useState)(null),2),A=O[0],I=O[1],j=p((0,i.useState)(null),2),B=j[0],P=j[1],F=(null==n?void 0:n.name)||"main",R=E.get("user_code")||void 0;y.current=t,v.current=s,g.current=h;var U=(0,i.useCallback)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;return d(function(){var n,r,a,i,o;return m(this,function(l){switch(l.label){case 0:return a=(r=y.current).auth.getToken(),i=r.auth.getAuthenticator()||"basic",[4,r.request({url:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"".concat("main"===e?"":"__app/".concat(e,"/"),"idpOAuth/device/verification").concat(t)}(F,e),method:e?"post":"get",skipNotify:!0,withCredentials:!0,params:e?void 0:{user_code:R},data:t,headers:a?{Authorization:"Bearer ".concat(a),"X-Authenticator":i}:void 0})];case 1:return[2,(null==(o=l.sent())||null==(n=o.data)?void 0:n.data)||(null==o?void 0:o.data)]}})})()},[F,R]),z=(0,i.useCallback)(function(){return d(function(){var e;return m(this,function(t){switch(t.label){case 0:S(!0),I(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,U()];case 2:if(P(e=t.sent()),"login"===e.status){var n,r,a,i;return v.current("/signin?redirect=".concat(encodeURIComponent((n=u.pathname,r=u.search,i=(a=e.userCode||R)?"?user_code=".concat(encodeURIComponent(a)):r,"".concat(n).concat(i)))),{replace:!0}),[2]}return[3,5];case 3:return I(f(t.sent(),g.current("Failed to load device sign-in."))),[3,5];case 4:return S(!1),[7];case 5:return[2]}})})()},[u.pathname,u.search,U,R]);(0,i.useEffect)(function(){z()},[z]);var N=(0,i.useCallback)(function(e){var t=e.user_code,n=null==t?void 0:t.trim();n&&x({user_code:n})},[x]),W=(0,i.useCallback)(function(e){return d(function(){return m(this,function(t){switch(t.label){case 0:T(!0),I(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,U(e,{user_code:(null==B?void 0:B.userCode)||R})];case 2:return P(t.sent()),[3,5];case 3:return I(f(t.sent(),h("Failed to submit device sign-in."))),[3,5];case 4:return T(!1),[7];case 5:return[2]}})})()},[null==B?void 0:B.userCode,U,h,R]);if(C)return o().createElement("div",{style:{position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}},o().createElement(a.Spin,{style:{fontSize:72}}));if(A)return o().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},o().createElement(a.Alert,{type:"error",message:A,showIcon:!0}));if(!B||"missing_code"===B.status)return o().createElement("div",{style:{maxWidth:440,margin:"48px auto",padding:"0 24px"}},o().createElement(a.Card,null,o().createElement(a.Space,{direction:"vertical",size:"large",style:{width:"100%"}},o().createElement("div",null,o().createElement(a.Typography.Title,{level:3,style:{marginBottom:8}},h("Device sign-in")),o().createElement(a.Typography.Paragraph,{style:{marginBottom:0}},h("Enter the code shown in your terminal to continue signing in."))),o().createElement(a.Form,{layout:"vertical",onFinish:N},o().createElement(a.Form.Item,{name:"user_code",rules:[{required:!0,message:h("Enter the device code.")}]},o().createElement(a.Input,{autoFocus:!0,size:"large",style:{textTransform:"uppercase"}})),o().createElement(a.Button,{type:"primary",htmlType:"submit",block:!0},h("Continue"))))));if("complete"===B.status)return o().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},o().createElement(a.Result,{status:"success",title:h("Device sign-in complete"),subTitle:h("Authorization is complete. You can return to the terminal."),extra:o().createElement(a.Button,{type:"primary",onClick:function(){var e;return s((e=u.pathname,/(^|\/)settings(\/|$)/.test(e)?"/settings/":"/"))}},h("Back to home"))}));if("cancelled"===B.status)return o().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},o().createElement(a.Result,{status:"warning",title:h("Device sign-in cancelled"),subTitle:h("The device sign-in request was cancelled.")}));if("pending"!==B.status){var D={not_found:h("The device code was not found."),expired:h("The device code has expired."),already_used:h("The device code has already been used.")};return o().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},o().createElement(a.Result,{status:"error",title:h("Device sign-in failed"),subTitle:D[B.status]}))}return o().createElement("div",{style:{maxWidth:520,margin:"48px auto",padding:"0 24px"}},o().createElement(a.Card,null,o().createElement(a.Space,{direction:"vertical",size:"large",style:{width:"100%"}},o().createElement("div",null,o().createElement(a.Typography.Title,{level:3,style:{marginBottom:8}},h("Confirm device")),o().createElement(a.Typography.Paragraph,{style:{marginBottom:0}},h("{{clientName}} is requesting access. Confirm that this code matches the one shown in your terminal.",{clientName:B.clientName||h("Application")}))),o().createElement(a.Typography.Title,{level:2,style:{margin:0,letterSpacing:"0.08em",textAlign:"center"}},B.userCode),o().createElement(a.Space,null,o().createElement(a.Button,{type:"primary",loading:k,onClick:function(){return W(":approve")}},h("Continue")),o().createElement(a.Button,{loading:k,onClick:function(){return W(":cancel")}},h("Cancel"))))))}},143:function(e,t,n){n.d(t,{k:function(){return o}});var r=n(694),a=n(155),i=JSON.parse('{"UU":"@nocobase/plugin-idp-oauth"}');function o(){var e=(0,r.useFlowEngine)();return(0,a.useCallback)(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:[i.UU,"client"]},n))},[e])}}}]);
@@ -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("@nocobase/client-v2"),require("react-router-dom"),require("react"),require("antd"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-idp-oauth/client-v2",["@nocobase/client-v2","react-router-dom","react","antd","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-idp-oauth/client-v2"]=t(require("@nocobase/client-v2"),require("react-router-dom"),require("react"),require("antd"),require("@nocobase/flow-engine")):e["@nocobase/plugin-idp-oauth/client-v2"]=t(e["@nocobase/client-v2"],e["react-router-dom"],e.react,e.antd,e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o){return function(){"use strict";var i,u,c,a={485:function(t){t.exports=e},694:function(e){e.exports=o},59:function(e){e.exports=r},155:function(e){e.exports=n},442:function(e){e.exports=t}},l={};function p(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={exports:{}};return a[e](n,n.exports,p),n.exports}p.m=a,p.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return p.d(t,{a:t}),t},p.d=function(e,t){for(var n in t)p.o(t,n)&&!p.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},p.f={},p.e=function(e){return Promise.all(Object.keys(p.f).reduce(function(t,n){return p.f[n](e,t),t},[]))},p.u=function(e){return""+e+"."+({425:"943a9d15dcd8ab57",583:"27517b2dae7d5fdb",711:"89a4c42afec82a37"})[e]+".js"},p.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),p.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},f={},p.l=function(e,t,n,r){if(f[e])return void f[e].push(t);if(void 0!==n)for(var o,i,u=document.getElementsByTagName("script"),c=0;c<u.length;c++){var a=u[c];if(a.getAttribute("src")==e||a.getAttribute("data-rspack")=="@nocobase/plugin-idp-oauth/client-v2:"+n){o=a;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,p.nc&&o.setAttribute("nonce",p.nc),o.setAttribute("data-rspack","@nocobase/plugin-idp-oauth/client-v2:"+n),o.src=e),f[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(s);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)},s=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)},p.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},p.g.importScripts&&(s=p.g.location+"");var f,s,d=p.g.document;if(!s&&d&&(d.currentScript&&"SCRIPT"===d.currentScript.tagName.toUpperCase()&&(s=d.currentScript.src),!s)){var b=d.getElementsByTagName("script");if(b.length)for(var h=b.length-1;h>-1&&(!s||!/^http(s?):/.test(s));)s=b[h--].src}if(!s)throw Error("Automatic publicPath is not supported in this browser");p.p=s.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i={889:0},p.f.j=function(e,t){var n=p.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=p.p+p.u(e),u=Error();p.l(o,function(t){if(p.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;u.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",u.name="ChunkLoadError",u.type=r,u.request=o,n[1](u)}},"chunk-"+e,e)}},u=function(e,t){var n,r,o=t[0],u=t[1],c=t[2],a=0;if(o.some(function(e){return 0!==i[e]})){for(n in u)p.o(u,n)&&(p.m[n]=u[n]);c&&c(p)}for(e&&e(t);a<o.length;a++)r=o[a],p.o(i,r)&&i[r]&&i[r][0](),i[r]=0},(c=self.webpackChunk_nocobase_plugin_idp_oauth_client_v2=self.webpackChunk_nocobase_plugin_idp_oauth_client_v2||[]).forEach(u.bind(null,0)),c.push=u.bind(null,c.push.bind(c));var v={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-idp-oauth/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-idp-oauth/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var u=window.location.pathname||"/",c=u.indexOf(i);e=c>=0?u.slice(0,c+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-idp-oauth/dist/client-v2/"}p.p=e}(),!function(){p.r(v),p.d(v,{default:function(){return c}});var e=p(485);function t(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 n(e,t,r){return(n=u()?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 u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(u=function(){return!!e})()}var c=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,u()?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(){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:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(u,"next",{value:a(0)}),c(u,"throw",{value:a(1)}),c(u,"return",{value:a(2)}),"function"==typeof Symbol&&c(u,Symbol.iterator,{value:function(){return this}}),u;function a(c){return function(a){var l=[c,a];if(n)throw TypeError("Generator is already executing.");for(;u&&(u=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(e){return this.router.add("idp-oauth.interaction",{path:"/idp-oauth/interaction/:uid",componentLoader:function(){return p.e("425").then(p.bind(p,648))},skipAuthCheck:!0}),this.router.add("idp-oauth.device",{path:"/idpOAuth/device",componentLoader:function(){return p.e("711").then(p.bind(p,290))},skipAuthCheck:!0}),this.router.add("idp-oauth.error",{path:"/idp-oauth/error",componentLoader:function(){return p.e("583").then(p.bind(p,34))},skipAuthCheck:!0}),[2]})},function(){var n=this,r=arguments;return new Promise(function(o,i){var u=e.apply(n,r);function c(e){t(u,o,i,c,a,"next",e)}function a(e){t(u,o,i,c,a,"throw",e)}c(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))}(),v}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client-v2"),require("react-router-dom"),require("react"),require("antd"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-idp-oauth/client-v2",["@nocobase/client-v2","react-router-dom","react","antd","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-idp-oauth/client-v2"]=t(require("@nocobase/client-v2"),require("react-router-dom"),require("react"),require("antd"),require("@nocobase/flow-engine")):e["@nocobase/plugin-idp-oauth/client-v2"]=t(e["@nocobase/client-v2"],e["react-router-dom"],e.react,e.antd,e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o){return function(){"use strict";var i,u,c,a={485:function(t){t.exports=e},694:function(e){e.exports=o},59:function(e){e.exports=r},155:function(e){e.exports=n},442:function(e){e.exports=t}},l={};function p(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={exports:{}};return a[e](n,n.exports,p),n.exports}p.m=a,p.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return p.d(t,{a:t}),t},p.d=function(e,t){for(var n in t)p.o(t,n)&&!p.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},p.f={},p.e=function(e){return Promise.all(Object.keys(p.f).reduce(function(t,n){return p.f[n](e,t),t},[]))},p.u=function(e){return""+e+"."+({425:"943a9d15dcd8ab57",583:"27517b2dae7d5fdb",711:"b95ec5ff736ba34c"})[e]+".js"},p.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),p.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},f={},p.l=function(e,t,n,r){if(f[e])return void f[e].push(t);if(void 0!==n)for(var o,i,u=document.getElementsByTagName("script"),c=0;c<u.length;c++){var a=u[c];if(a.getAttribute("src")==e||a.getAttribute("data-rspack")=="@nocobase/plugin-idp-oauth/client-v2:"+n){o=a;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,p.nc&&o.setAttribute("nonce",p.nc),o.setAttribute("data-rspack","@nocobase/plugin-idp-oauth/client-v2:"+n),o.src=e),f[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(s);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)},s=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)},p.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},p.g.importScripts&&(s=p.g.location+"");var f,s,d=p.g.document;if(!s&&d&&(d.currentScript&&"SCRIPT"===d.currentScript.tagName.toUpperCase()&&(s=d.currentScript.src),!s)){var h=d.getElementsByTagName("script");if(h.length)for(var b=h.length-1;b>-1&&(!s||!/^http(s?):/.test(s));)s=h[b--].src}if(!s)throw Error("Automatic publicPath is not supported in this browser");p.p=s.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i={889:0},p.f.j=function(e,t){var n=p.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=p.p+p.u(e),u=Error();p.l(o,function(t){if(p.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;u.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",u.name="ChunkLoadError",u.type=r,u.request=o,n[1](u)}},"chunk-"+e,e)}},u=function(e,t){var n,r,o=t[0],u=t[1],c=t[2],a=0;if(o.some(function(e){return 0!==i[e]})){for(n in u)p.o(u,n)&&(p.m[n]=u[n]);c&&c(p)}for(e&&e(t);a<o.length;a++)r=o[a],p.o(i,r)&&i[r]&&i[r][0](),i[r]=0},(c=self.webpackChunk_nocobase_plugin_idp_oauth_client_v2=self.webpackChunk_nocobase_plugin_idp_oauth_client_v2||[]).forEach(u.bind(null,0)),c.push=u.bind(null,c.push.bind(c));var v={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-idp-oauth/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-idp-oauth/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var u=window.location.pathname||"/",c=u.indexOf(i);e=c>=0?u.slice(0,c+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-idp-oauth/dist/client-v2/"}p.p=e}(),!function(){p.r(v),p.d(v,{default:function(){return c}});var e=p(485);function t(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 n(e,t,r){return(n=u()?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 u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(u=function(){return!!e})()}var c=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,u()?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(){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:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(u,"next",{value:a(0)}),c(u,"throw",{value:a(1)}),c(u,"return",{value:a(2)}),"function"==typeof Symbol&&c(u,Symbol.iterator,{value:function(){return this}}),u;function a(c){return function(a){var l=[c,a];if(n)throw TypeError("Generator is already executing.");for(;u&&(u=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(e){return this.router.add("idp-oauth.interaction",{path:"/idp-oauth/interaction/:uid",componentLoader:function(){return p.e("425").then(p.bind(p,648))},skipAuthCheck:!0}),this.pluginSettingsManager.getRouteName("idpOAuth.device").startsWith("settings.")&&this.router.add("settingsDetails.idpOAuth.device",{path:this.pluginSettingsManager.getRoutePath("idpOAuth.device"),componentLoader:function(){return p.e("711").then(p.bind(p,290))}}),this.router.add("idp-oauth.device",{path:"/settings/idpOAuth/device",componentLoader:function(){return p.e("711").then(p.bind(p,290))},skipAuthCheck:!0}),this.router.add("idp-oauth-legacy-device",{path:"/idpOAuth/device",componentLoader:function(){return p.e("711").then(p.bind(p,290))},skipAuthCheck:!0}),this.router.add("idp-oauth-modern-legacy-device",{path:"/v/idpOAuth/device",componentLoader:function(){return p.e("711").then(p.bind(p,290))},skipAuthCheck:!0}),this.router.add("idp-oauth.error",{path:"/idp-oauth/error",componentLoader:function(){return p.e("583").then(p.bind(p,34))},skipAuthCheck:!0}),[2]})},function(){var n=this,r=arguments;return new Promise(function(o,i){var u=e.apply(n,r);function c(e){t(u,o,i,c,a,"next",e)}function a(e){t(u,o,i,c,a,"throw",e)}c(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))}(),v}()});
@@ -8,15 +8,15 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.3.0-beta.6",
11
+ "@nocobase/client": "2.4.0-alpha.1",
12
12
  "antd": "5.24.2",
13
13
  "react": "18.2.0",
14
14
  "react-router-dom": "6.30.1",
15
- "@nocobase/flow-engine": "2.3.0-beta.6",
16
- "@nocobase/client-v2": "2.3.0-beta.6",
17
- "@nocobase/server": "2.3.0-beta.6",
18
- "@nocobase/cache": "2.3.0-beta.6",
19
- "@nocobase/plugin-auth": "2.3.0-beta.6",
20
- "@nocobase/utils": "2.3.0-beta.6",
21
- "@nocobase/database": "2.3.0-beta.6"
15
+ "@nocobase/flow-engine": "2.4.0-alpha.1",
16
+ "@nocobase/client-v2": "2.4.0-alpha.1",
17
+ "@nocobase/server": "2.4.0-alpha.1",
18
+ "@nocobase/cache": "2.4.0-alpha.1",
19
+ "@nocobase/plugin-auth": "2.4.0-alpha.1",
20
+ "@nocobase/utils": "2.4.0-alpha.1",
21
+ "@nocobase/database": "2.4.0-alpha.1"
22
22
  };
@@ -1 +1 @@
1
- {"name":"light-my-request","version":"6.6.0","description":"Fake HTTP injection library","main":"index.js","type":"commonjs","types":"types/index.d.ts","dependencies":{"cookie":"^1.0.1","process-warning":"^4.0.0","set-cookie-parser":"^2.6.0"},"devDependencies":{"@fastify/ajv-compiler":"^4.0.0","@fastify/pre-commit":"^2.1.0","@types/node":"^22.7.7","c8":"^10.1.2","end-of-stream":"^1.4.4","eslint":"^9.17.0","express":"^4.19.2","form-auto-content":"^3.2.1","form-data":"^4.0.0","formdata-node":"^6.0.3","multer":"^1.4.5-lts.1","neostandard":"^0.12.0","tinybench":"^3.0.0","tsd":"^0.31.0","undici":"^7.0.0"},"scripts":{"benchmark":"node benchmark/benchmark.js","coverage":"npm run unit -- --cov --coverage-report=html","lint":"eslint","lint:fix":"eslint --fix","test":"npm run lint && npm run test:unit && npm run test:typescript","test:typescript":"tsd","test:unit":"c8 --100 node --test"},"repository":{"type":"git","url":"git+https://github.com/fastify/light-my-request.git"},"keywords":["http","inject","fake","request","server"],"author":"Tomas Della Vedova - @delvedor (http://delved.org)","contributors":[{"name":"Matteo Collina","email":"hello@matteocollina.com"},{"name":"Manuel Spigolon","email":"behemoth89@gmail.com"},{"name":"Aras Abbasi","email":"aras.abbasi@gmail.com"},{"name":"Frazer Smith","email":"frazer.dev@icloud.com","url":"https://github.com/fdawgs"}],"license":"BSD-3-Clause","bugs":{"url":"https://github.com/fastify/light-my-request/issues"},"homepage":"https://github.com/fastify/light-my-request#readme","funding":[{"type":"github","url":"https://github.com/sponsors/fastify"},{"type":"opencollective","url":"https://opencollective.com/fastify"}],"_lastModified":"2026-08-31T04:05:08.943Z"}
1
+ {"name":"light-my-request","version":"6.6.0","description":"Fake HTTP injection library","main":"index.js","type":"commonjs","types":"types/index.d.ts","dependencies":{"cookie":"^1.0.1","process-warning":"^4.0.0","set-cookie-parser":"^2.6.0"},"devDependencies":{"@fastify/ajv-compiler":"^4.0.0","@fastify/pre-commit":"^2.1.0","@types/node":"^22.7.7","c8":"^10.1.2","end-of-stream":"^1.4.4","eslint":"^9.17.0","express":"^4.19.2","form-auto-content":"^3.2.1","form-data":"^4.0.0","formdata-node":"^6.0.3","multer":"^1.4.5-lts.1","neostandard":"^0.12.0","tinybench":"^3.0.0","tsd":"^0.31.0","undici":"^7.0.0"},"scripts":{"benchmark":"node benchmark/benchmark.js","coverage":"npm run unit -- --cov --coverage-report=html","lint":"eslint","lint:fix":"eslint --fix","test":"npm run lint && npm run test:unit && npm run test:typescript","test:typescript":"tsd","test:unit":"c8 --100 node --test"},"repository":{"type":"git","url":"git+https://github.com/fastify/light-my-request.git"},"keywords":["http","inject","fake","request","server"],"author":"Tomas Della Vedova - @delvedor (http://delved.org)","contributors":[{"name":"Matteo Collina","email":"hello@matteocollina.com"},{"name":"Manuel Spigolon","email":"behemoth89@gmail.com"},{"name":"Aras Abbasi","email":"aras.abbasi@gmail.com"},{"name":"Frazer Smith","email":"frazer.dev@icloud.com","url":"https://github.com/fdawgs"}],"license":"BSD-3-Clause","bugs":{"url":"https://github.com/fastify/light-my-request/issues"},"homepage":"https://github.com/fastify/light-my-request#readme","funding":[{"type":"github","url":"https://github.com/sponsors/fastify"},{"type":"opencollective","url":"https://opencollective.com/fastify"}],"_lastModified":"2026-09-02T04:18:42.307Z"}
@@ -1 +1 @@
1
- {"name":"ms","version":"2.1.3","description":"Tiny millisecond conversion utility","repository":"vercel/ms","main":"./index","files":["index.js"],"scripts":{"precommit":"lint-staged","lint":"eslint lib/* bin/*","test":"mocha tests.js"},"eslintConfig":{"extends":"eslint:recommended","env":{"node":true,"es6":true}},"lint-staged":{"*.js":["npm run lint","prettier --single-quote --write","git add"]},"license":"MIT","devDependencies":{"eslint":"4.18.2","expect.js":"0.3.1","husky":"0.14.3","lint-staged":"5.0.0","mocha":"4.0.1","prettier":"2.0.5"},"_lastModified":"2026-08-31T04:05:08.980Z"}
1
+ {"name":"ms","version":"2.1.3","description":"Tiny millisecond conversion utility","repository":"vercel/ms","main":"./index","files":["index.js"],"scripts":{"precommit":"lint-staged","lint":"eslint lib/* bin/*","test":"mocha tests.js"},"eslintConfig":{"extends":"eslint:recommended","env":{"node":true,"es6":true}},"lint-staged":{"*.js":["npm run lint","prettier --single-quote --write","git add"]},"license":"MIT","devDependencies":{"eslint":"4.18.2","expect.js":"0.3.1","husky":"0.14.3","lint-staged":"5.0.0","mocha":"4.0.1","prettier":"2.0.5"},"_lastModified":"2026-09-02T04:18:42.352Z"}
@@ -87,6 +87,10 @@ function policyMillisecondsToSeconds(value, fallback) {
87
87
  function escapeHtmlText(value) {
88
88
  return String(value ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
89
89
  }
90
+ function shouldUseSettingsDevicePath() {
91
+ const appClientEntryMode = String(process.env.APP_CLIENT_ENTRY_MODE ?? "").trim();
92
+ return ["modern-only", "modern-default", "settings-default"].includes(appClientEntryMode);
93
+ }
90
94
  function renderDevicePage(options) {
91
95
  return `<!doctype html>
92
96
  <html lang="en">
@@ -295,10 +299,11 @@ class IdpOauthService {
295
299
  }
296
300
  getFrontendDevicePath(appName, issuerPath = this.getIssuerPath(appName)) {
297
301
  const appPublicPath = this.getAppPublicPath();
302
+ const useSettingsPath = shouldUseSettingsDevicePath();
298
303
  if (!this.shouldUseSubAppPublicPrefix(appName, issuerPath)) {
299
- return `${appPublicPath}/idpOAuth/device`;
304
+ return useSettingsPath ? `${appPublicPath}/settings/idpOAuth/device` : `${appPublicPath}/idpOAuth/device`;
300
305
  }
301
- return `${appPublicPath}/apps/${appName}/idpOAuth/device`;
306
+ return useSettingsPath ? `${appPublicPath}/settings/apps/${appName}/idpOAuth/device` : `${appPublicPath}/apps/${appName}/idpOAuth/device`;
302
307
  }
303
308
  getProviderContext(ctx) {
304
309
  var _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-idp-oauth",
3
- "version": "2.3.0-beta.6",
3
+ "version": "2.4.0-alpha.1",
4
4
  "main": "dist/server/index.js",
5
5
  "displayName": "IdP: OAuth",
6
6
  "displayName.zh-CN": "IdP: OAuth",
@@ -24,5 +24,5 @@
24
24
  "keywords": [
25
25
  "Authentication"
26
26
  ],
27
- "gitHead": "45b23791f5245d1417047b122d1a76764aaf5473"
27
+ "gitHead": "82ecd3aed067e4cc98c32e7a0039b6e55cee76a7"
28
28
  }