@nocobase/plugin-idp-oauth 2.1.0-alpha.12 → 2.1.0-alpha.14

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.
Files changed (27) hide show
  1. package/dist/client/index.js +1 -1
  2. package/dist/externalVersion.js +4 -4
  3. package/dist/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +5 -1
  4. package/dist/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +3 -1
  5. package/dist/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
  6. package/dist/node_modules/jose/dist/webapi/lib/deflate.js +4 -4
  7. package/dist/node_modules/jose/package.json +1 -1
  8. package/dist/node_modules/light-my-request/package.json +1 -1
  9. package/dist/node_modules/oidc-provider/lib/actions/code_verification.js +5 -16
  10. package/dist/node_modules/oidc-provider/lib/actions/end_session.js +8 -19
  11. package/dist/node_modules/oidc-provider/lib/helpers/add_client.js +4 -3
  12. package/dist/node_modules/oidc-provider/lib/helpers/client_id_metadata_document.js +2 -2
  13. package/dist/node_modules/oidc-provider/lib/helpers/client_schema.js +29 -12
  14. package/dist/node_modules/oidc-provider/lib/helpers/fetch_body_check.js +9 -7
  15. package/dist/node_modules/oidc-provider/lib/models/client.js +3 -3
  16. package/dist/node_modules/oidc-provider/lib/shared/error_handler.js +4 -4
  17. package/dist/node_modules/oidc-provider/lib/shared/xsrf.js +22 -0
  18. package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/Readme.md +3 -3
  19. package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/dist/index.d.ts +3 -0
  20. package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/dist/index.js +215 -193
  21. package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/dist/index.js.map +1 -1
  22. package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/package.json +2 -2
  23. package/dist/node_modules/oidc-provider/package.json +1 -1
  24. package/dist/server/provider-dispatch.js +4 -2
  25. package/dist/server/service.d.ts +9 -3
  26. package/dist/server/service.js +65 -10
  27. package/package.json +2 -2
@@ -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("antd"),require("react"),require("@nocobase/client"),require("react-router-dom")):"function"==typeof define&&define.amd?define("@nocobase/plugin-idp-oauth",["antd","react","@nocobase/client","react-router-dom"],t):"object"==typeof exports?exports["@nocobase/plugin-idp-oauth"]=t(require("antd"),require("react"),require("@nocobase/client"),require("react-router-dom")):e["@nocobase/plugin-idp-oauth"]=t(e.antd,e.react,e["@nocobase/client"],e["react-router-dom"])}(self,function(e,t,r,n){return function(){"use strict";var o={342:function(e){e.exports=r},59:function(t){t.exports=e},155:function(e){e.exports=t},442:function(e){e.exports=n}},a={};function i(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return o[e](r,r.exports,i),r.exports}i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,{a:t}),t},i.d=function(e,t){for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.g.importScripts&&(u=i.g.location+"");var u,c=i.g.document;if(!u&&c&&(c.currentScript&&"SCRIPT"===c.currentScript.tagName.toUpperCase()&&(u=c.currentScript.src),!u)){var l=c.getElementsByTagName("script");if(l.length)for(var s=l.length-1;s>-1&&(!u||!/^http(s?):/.test(u));)u=l[s--].src}if(!u)throw Error("Automatic publicPath is not supported in this browser");i.p=u.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var p={},f=window.__nocobase_public_path__||"";if(!f&&window.location&&window.location.pathname){var d=window.location.pathname||"/",y=d.indexOf("/v2/");f=y>=0?d.slice(0,y+1):"/"}return f&&(f=f.replace(/\/v2\/?$/,"/")),f||(f="/"),"/"!==f.charAt(f.length-1)&&(f+="/"),i.p=f+"static/plugins/@nocobase/plugin-idp-oauth/dist/client/",!function(){i.r(p),i.d(p,{default:function(){return O}});var e=i(342),t=i(59),r=i(155),n=i.n(r),o=i(442);function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var u=function(){var e,r=(function(e){if(Array.isArray(e))return e}(e=(0,o.useSearchParams)())||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],a=!0,i=!1;try{for(n=n.call(e);!(a=(t=n.next()).done)&&(o.push(t.value),1!==o.length);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==n.return||n.return()}finally{if(i)throw r}}return o}}(e)||function(e){if(e){if("string"==typeof e)return a(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 a(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],i=r.get("error"),u=r.get("error_description"),c=r.get("iss");return n().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},n().createElement(t.Result,{status:"error",title:i||"Authentication failed",subTitle:u||void 0}),n().createElement(t.Space,{direction:"vertical",size:"middle",style:{width:"100%"}},c?n().createElement("div",null,n().createElement(t.Typography.Text,{type:"secondary"},"Issuer"),n().createElement("div",null,n().createElement(t.Typography.Text,{code:!0},c))):null))};function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function l(e,t,r,n,o,a,i){try{var u=e[a](i),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}function s(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){l(a,n,o,i,u,"next",e)}function u(e){l(a,n,o,i,u,"throw",e)}i(void 0)})}}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,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=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){u=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(u)throw n}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))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 r,n,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(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}function y(e,t){var r;return(null!=(r=Error)&&"u">typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):e instanceof r)?e.message:t}var h=function(){var a=(0,e.useAPIClient)();(0,e.useApp)();var i=(0,o.useNavigate)(),u=(0,o.useParams)(),c=f((0,r.useState)(!0),2),l=c[0],p=c[1],h=f((0,r.useState)(null),2),b=h[0],m=h[1],v=f((0,r.useState)(null),2),g=v[0],w=v[1],S=(0,r.useMemo)(function(){return u.appName&&u.uid?"main"===u.appName?"idpOAuth/interaction/".concat(u.uid):"__app/".concat(u.appName,"/idpOAuth/interaction/").concat(u.uid):null},[u.appName,u.uid]),x=(0,r.useMemo)(function(){return u.appName&&u.uid?"/idp-oauth/interaction/".concat(u.appName,"/").concat(u.uid):"/signin"},[u.appName,u.uid]),O=function(e,t){return s(function(){var r,n,o,u,c,l;return d(this,function(s){switch(s.label){case 0:if(!S)return m("Invalid interaction path"),p(!1),[2];return n=a.auth.getToken(),o=a.auth.getAuthenticator()||"basic",u=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},t||{}),n&&(u.bridge_token=n,u.bridge_authenticator=o),[4,a.request({url:S,method:e,skipNotify:!0,withCredentials:!0,data:"post"===e?u:void 0,headers:n?{Authorization:"Bearer ".concat(n),"X-Authenticator":o}:void 0})];case 1:if(null==(l=(null==(c=s.sent())||null==(r=c.data)?void 0:r.data)||(null==c?void 0:c.data))?void 0:l.redirectTo)return window.location.replace(l.redirectTo),[2];if((null==l?void 0:l.prompt)!=="login")return[3,4];if(!n)return i("/signin?redirect=".concat(encodeURIComponent(x)),{replace:!0}),[2];if("get"!==e)return[3,3];return[4,O("post")];case 2:return s.sent(),[2];case 3:return i("/signin?redirect=".concat(encodeURIComponent(x)),{replace:!0}),[2];case 4:return w(l),p(!1),[2]}})})()};(0,r.useEffect)(function(){var e=!1;return s(function(){var t;return d(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,O("get")];case 1:return r.sent(),[3,3];case 2:return t=r.sent(),e||(m(y(t,"Failed to load interaction")),p(!1)),[3,3];case 3:return[2]}})})(),function(){e=!0}},[S]);var E=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return s(function(){return d(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(y(t.sent(),"Failed to submit interaction")),p(!1),[3,4];case 4:return[2]}})})()};return l?n().createElement("div",{style:{display:"flex",justifyContent:"center",padding:48}},n().createElement(t.Spin,{size:"large"})):b?n().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},n().createElement(t.Alert,{type:"error",message:b,showIcon:!0})):(null==g?void 0:g.prompt)==="consent"?n().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},n().createElement(t.Card,null,n().createElement(t.Space,{direction:"vertical",size:"large",style:{width:"100%"}},n().createElement("div",null,n().createElement(t.Typography.Title,{level:3,style:{marginBottom:8}},"Authorize application"),n().createElement(t.Typography.Paragraph,{style:{marginBottom:0}},g.clientName||"Application"," requests access to your account.")),g.details?n().createElement(t.Alert,{type:"info",showIcon:!0,message:"Requested permissions",description:g.details}):null,n().createElement(t.Space,null,n().createElement(t.Button,{type:"primary",loading:l,onClick:function(){return E(!1)}},"Continue"),n().createElement(t.Button,{loading:l,onClick:function(){return E(!0)}},"Cancel"))))):n().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},n().createElement(t.Result,{title:"Redirecting...",subTitle:"Please wait while authorization continues."}))},b={};function m(e,t,r,n,o,a,i){try{var u=e[a](i),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}function v(e,t,r){return(v=x()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&w(o,r.prototype),o}).apply(null,arguments)}function g(e){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function w(e,t){return(w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function S(e){var t="function"==typeof Map?new Map:void 0;return(S=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,r)}function r(){return v(e,arguments,g(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),w(r,e)})(e)}function x(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(x=function(){return!!e})()}var O=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=g(e),function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,x()?Reflect.construct(e,t||[],g(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&w(r,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var r,n,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(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return this.flowEngine.registerModels(b),this.router.add("idp-oauth.interaction",{path:"/idp-oauth/interaction/:appName/:uid",Component:h,skipAuthCheck:!0}),this.router.add("idp-oauth.error",{path:"/idp-oauth/error/:appName",Component:u,skipAuthCheck:!0}),[2]})},function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){m(a,n,o,i,u,"next",e)}function u(e){m(a,n,o,i,u,"throw",e)}i(void 0)})}).call(this)}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(S(e.Plugin))}(),p}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("antd"),require("react"),require("@nocobase/client"),require("react-router-dom")):"function"==typeof define&&define.amd?define("@nocobase/plugin-idp-oauth",["antd","react","@nocobase/client","react-router-dom"],t):"object"==typeof exports?exports["@nocobase/plugin-idp-oauth"]=t(require("antd"),require("react"),require("@nocobase/client"),require("react-router-dom")):e["@nocobase/plugin-idp-oauth"]=t(e.antd,e.react,e["@nocobase/client"],e["react-router-dom"])}(self,function(e,t,r,n){return function(){"use strict";var o={342:function(e){e.exports=r},59:function(t){t.exports=e},155:function(e){e.exports=t},442:function(e){e.exports=n}},i={};function a(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return o[e](r,r.exports,a),r.exports}a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,{a:t}),t},a.d=function(e,t){for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.g.importScripts&&(u=a.g.location+"");var u,c=a.g.document;if(!u&&c&&(c.currentScript&&"SCRIPT"===c.currentScript.tagName.toUpperCase()&&(u=c.currentScript.src),!u)){var l=c.getElementsByTagName("script");if(l.length)for(var s=l.length-1;s>-1&&(!u||!/^http(s?):/.test(u));)u=l[s--].src}if(!u)throw Error("Automatic publicPath is not supported in this browser");a.p=u.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var p={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-idp-oauth/dist/client/")}if(!e){if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var n=window.location.pathname||"/",o=n.indexOf("/v2/");e=o>=0?n.slice(0,o+1):"/"}e&&(e=e.replace(/\/v2\/?$/,"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-idp-oauth/dist/client/"}a.p=e}(),!function(){a.r(p),a.d(p,{default:function(){return O}});var e=a(342),t=a(59),r=a(155),n=a.n(r),o=a(442);function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var u=function(){var e,r=(function(e){if(Array.isArray(e))return e}(e=(0,o.useSearchParams)())||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],i=!0,a=!1;try{for(n=n.call(e);!(i=(t=n.next()).done)&&(o.push(t.value),1!==o.length);i=!0);}catch(e){a=!0,r=e}finally{try{i||null==n.return||n.return()}finally{if(a)throw r}}return o}}(e)||function(e){if(e){if("string"==typeof e)return i(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 i(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=r.get("error"),u=r.get("error_description"),c=r.get("iss");return n().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},n().createElement(t.Result,{status:"error",title:a||"Authentication failed",subTitle:u||void 0}),n().createElement(t.Space,{direction:"vertical",size:"middle",style:{width:"100%"}},c?n().createElement("div",null,n().createElement(t.Typography.Text,{type:"secondary"},"Issuer"),n().createElement("div",null,n().createElement(t.Typography.Text,{code:!0},c))):null))};function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function l(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}function s(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){l(i,n,o,a,u,"next",e)}function u(e){l(i,n,o,a,u,"throw",e)}a(void 0)})}}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(r=o.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){u=!0,n=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw n}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))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 r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}function y(e,t){var r;return(null!=(r=Error)&&"u">typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):e instanceof r)?e.message:t}var h=function(){var i=(0,e.useAPIClient)(),a=(0,e.useApp)(),u=(0,o.useNavigate)(),c=(0,o.useParams)(),l=f((0,r.useState)(!0),2),p=l[0],h=l[1],b=f((0,r.useState)(null),2),m=b[0],v=b[1],g=f((0,r.useState)(null),2),w=g[0],S=g[1],x=(0,r.useMemo)(function(){return c.uid?"main"===a.name?"idpOAuth/interaction/".concat(c.uid):"__app/".concat(a.name,"/idpOAuth/interaction/").concat(c.uid):null},[a.name,c.uid]),O=(0,r.useMemo)(function(){return c.uid?"/idp-oauth/interaction/".concat(c.uid):"/signin"},[c.uid]),E=(0,r.useCallback)(function(e,t){return s(function(){var r,n,o,a,c,l;return d(this,function(s){switch(s.label){case 0:if(!x)return v("Invalid interaction path"),h(!1),[2];return n=i.auth.getToken(),o=i.auth.getAuthenticator()||"basic",a=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},t||{}),n&&(a.bridge_token=n,a.bridge_authenticator=o),[4,i.request({url:x,method:e,skipNotify:!0,withCredentials:!0,data:"post"===e?a:void 0,headers:n?{Authorization:"Bearer ".concat(n),"X-Authenticator":o}:void 0})];case 1:if(null==(l=(null==(c=s.sent())||null==(r=c.data)?void 0:r.data)||(null==c?void 0:c.data))?void 0:l.redirectTo)return window.location.replace(l.redirectTo),[2];if((null==l?void 0:l.prompt)!=="login")return[3,4];if(!n)return u("/signin?redirect=".concat(encodeURIComponent(O)),{replace:!0}),[2];if("get"!==e)return[3,3];return[4,E("post")];case 2:return s.sent(),[2];case 3:return u("/signin?redirect=".concat(encodeURIComponent(O)),{replace:!0}),[2];case 4:return S(l),h(!1),[2]}})})()},[i,O,x,u]);(0,r.useEffect)(function(){var e=!1;return s(function(){var t;return d(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,E("get")];case 1:return r.sent(),[3,3];case 2:return t=r.sent(),e||(v(y(t,"Failed to load interaction")),h(!1)),[3,3];case 3:return[2]}})})(),function(){e=!0}},[E]);var j=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return s(function(){return d(this,function(t){switch(t.label){case 0:h(!0),v(null),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,E("post",e?{cancel:1}:{submit:1})];case 2:return t.sent(),[3,4];case 3:return v(y(t.sent(),"Failed to submit interaction")),h(!1),[3,4];case 4:return[2]}})})()};return p?n().createElement("div",{style:{display:"flex",justifyContent:"center",padding:48}},n().createElement(t.Spin,{size:"large"})):m?n().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},n().createElement(t.Alert,{type:"error",message:m,showIcon:!0})):(null==w?void 0:w.prompt)==="consent"?n().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},n().createElement(t.Card,null,n().createElement(t.Space,{direction:"vertical",size:"large",style:{width:"100%"}},n().createElement("div",null,n().createElement(t.Typography.Title,{level:3,style:{marginBottom:8}},"Authorize application"),n().createElement(t.Typography.Paragraph,{style:{marginBottom:0}},w.clientName||"Application"," requests access to your account.")),w.details?n().createElement(t.Alert,{type:"info",showIcon:!0,message:"Requested permissions",description:w.details}):null,n().createElement(t.Space,null,n().createElement(t.Button,{type:"primary",loading:p,onClick:function(){return j(!1)}},"Continue"),n().createElement(t.Button,{loading:p,onClick:function(){return j(!0)}},"Cancel"))))):n().createElement("div",{style:{maxWidth:640,margin:"48px auto",padding:"0 24px"}},n().createElement(t.Result,{title:"Redirecting...",subTitle:"Please wait while authorization continues."}))},b={};function m(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}function v(e,t,r){return(v=x()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&w(o,r.prototype),o}).apply(null,arguments)}function g(e){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function w(e,t){return(w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function S(e){var t="function"==typeof Map?new Map:void 0;return(S=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,r)}function r(){return v(e,arguments,g(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),w(r,e)})(e)}function x(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(x=function(){return!!e})()}var O=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=g(e),function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,x()?Reflect.construct(e,t||[],g(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&w(r,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return this.flowEngine.registerModels(b),this.router.add("idp-oauth.interaction",{path:"/idp-oauth/interaction/:uid",Component:h,skipAuthCheck:!0}),this.router.add("idp-oauth.error",{path:"/idp-oauth/error",Component:u,skipAuthCheck:!0}),[2]})},function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){m(i,n,o,a,u,"next",e)}function u(e){m(i,n,o,a,u,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(S(e.Plugin))}(),p}()});
@@ -11,8 +11,8 @@ module.exports = {
11
11
  "antd": "5.24.2",
12
12
  "react": "18.2.0",
13
13
  "react-router-dom": "6.30.1",
14
- "@nocobase/client": "2.1.0-alpha.12",
15
- "@nocobase/flow-engine": "2.1.0-alpha.12",
16
- "@nocobase/cache": "2.1.0-alpha.12",
17
- "@nocobase/server": "2.1.0-alpha.12"
14
+ "@nocobase/client": "2.1.0-alpha.14",
15
+ "@nocobase/flow-engine": "2.1.0-alpha.14",
16
+ "@nocobase/cache": "2.1.0-alpha.14",
17
+ "@nocobase/server": "2.1.0-alpha.14"
18
18
  };
@@ -134,7 +134,11 @@ export async function flattenedDecrypt(jwe, key, options) {
134
134
  (!Number.isSafeInteger(maxDecompressedLength) || maxDecompressedLength < 1)) {
135
135
  throw new TypeError('maxDecompressedLength must be 0, a positive safe integer, or Infinity');
136
136
  }
137
- result.plaintext = await decompress(plaintext, maxDecompressedLength);
137
+ result.plaintext = await decompress(plaintext, maxDecompressedLength).catch((cause) => {
138
+ if (cause instanceof JWEInvalid)
139
+ throw cause;
140
+ throw new JWEInvalid('Failed to decompress plaintext', { cause });
141
+ });
138
142
  }
139
143
  if (jwe.protected !== undefined) {
140
144
  result.protectedHeader = parsedProt;
@@ -133,7 +133,9 @@ export class FlattenedEncrypt {
133
133
  }
134
134
  let plaintext = this.#plaintext;
135
135
  if (joseHeader.zip === 'DEF') {
136
- plaintext = await compress(plaintext);
136
+ plaintext = await compress(plaintext).catch((cause) => {
137
+ throw new JWEInvalid('Failed to compress plaintext', { cause });
138
+ });
137
139
  }
138
140
  const { ciphertext, tag, iv } = await encrypt(enc, plaintext, cek, this.#iv, additionalData);
139
141
  const jwe = {
@@ -9,7 +9,7 @@ function isCloudflareWorkers() {
9
9
  let USER_AGENT;
10
10
  if (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) {
11
11
  const NAME = 'jose';
12
- const VERSION = 'v6.2.1';
12
+ const VERSION = 'v6.2.2';
13
13
  USER_AGENT = `${NAME}/${VERSION}`;
14
14
  }
15
15
  export const customFetch = Symbol();
@@ -9,8 +9,8 @@ export async function compress(input) {
9
9
  supported('CompressionStream');
10
10
  const cs = new CompressionStream('deflate-raw');
11
11
  const writer = cs.writable.getWriter();
12
- writer.write(input);
13
- writer.close();
12
+ writer.write(input).catch(() => { });
13
+ writer.close().catch(() => { });
14
14
  const chunks = [];
15
15
  const reader = cs.readable.getReader();
16
16
  for (;;) {
@@ -25,8 +25,8 @@ export async function decompress(input, maxLength) {
25
25
  supported('DecompressionStream');
26
26
  const ds = new DecompressionStream('deflate-raw');
27
27
  const writer = ds.writable.getWriter();
28
- writer.write(input);
29
- writer.close();
28
+ writer.write(input).catch(() => { });
29
+ writer.close().catch(() => { });
30
30
  const chunks = [];
31
31
  let length = 0;
32
32
  const reader = ds.readable.getReader();
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jose",
3
- "version": "6.2.1",
3
+ "version": "6.2.2",
4
4
  "description": "JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes",
5
5
  "keywords": [
6
6
  "akp",
@@ -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-03-25T14:08:05.803Z"}
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-04-07T15:54:32.054Z"}
@@ -1,11 +1,10 @@
1
- import * as crypto from 'node:crypto';
2
-
3
1
  import sessionMiddleware from '../shared/session.js';
4
2
  import paramsMiddleware from '../shared/assemble_params.js';
5
3
  import bodyParser from '../shared/conditional_body.js';
6
4
  import rejectDupes from '../shared/reject_dupes.js';
7
5
  import instance from '../helpers/weak_cache.js';
8
- import { InvalidClient, InvalidRequest } from '../helpers/errors.js';
6
+ import { InvalidClient } from '../helpers/errors.js';
7
+ import { generateXsrf, checkXsrf } from '../shared/xsrf.js';
9
8
  import * as formHtml from '../helpers/user_code_form.js';
10
9
  import formPost from '../response_modes/form_post.js';
11
10
  import { normalize, denormalize } from '../helpers/user_codes.js';
@@ -18,13 +17,11 @@ const parseBody = bodyParser.bind(undefined, 'application/x-www-form-urlencoded'
18
17
  export const get = [
19
18
  sessionMiddleware,
20
19
  paramsMiddleware.bind(undefined, new Set(['user_code'])),
20
+ generateXsrf,
21
21
  async function renderCodeVerification(ctx) {
22
22
  const { charset, userCodeInputSource } = instance(ctx.oidc.provider).features.deviceFlow;
23
23
 
24
- // TODO: generic xsrf middleware to remove this
25
- const secret = crypto.randomBytes(24).toString('hex');
26
- ctx.oidc.session.state = { secret };
27
-
24
+ const { secret } = ctx.oidc.session.state;
28
25
  const action = ctx.oidc.urlFor('code_verification');
29
26
  if (ctx.oidc.params.user_code) {
30
27
  formPost(ctx, action, {
@@ -43,15 +40,7 @@ export const post = [
43
40
  paramsMiddleware.bind(undefined, new Set(['xsrf', 'user_code', 'confirm', 'abort'])),
44
41
  rejectDupes.bind(undefined, {}),
45
42
 
46
- async function codeVerificationCSRF(ctx, next) {
47
- if (!ctx.oidc.session.state) {
48
- throw new InvalidRequest('could not find device form details');
49
- }
50
- if (ctx.oidc.session.state.secret !== ctx.oidc.params.xsrf) {
51
- throw new InvalidRequest('xsrf token invalid');
52
- }
53
- await next();
54
- },
43
+ checkXsrf('could not find device form details'),
55
44
 
56
45
  async function loadDeviceCodeByUserInput(ctx, next) {
57
46
  const { userCodeConfirmSource, mask } = instance(ctx.oidc.provider).features.deviceFlow;
@@ -1,5 +1,3 @@
1
- import * as crypto from 'node:crypto';
2
-
3
1
  import { InvalidClient, InvalidRequest, OIDCProviderError } from '../helpers/errors.js';
4
2
  import * as JWT from '../helpers/jwt.js';
5
3
  import redirectUri from '../helpers/redirect_uri.js';
@@ -11,6 +9,7 @@ import sessionMiddleware from '../shared/session.js';
11
9
  import revoke from '../helpers/revoke.js';
12
10
  import noCache from '../shared/no_cache.js';
13
11
  import formPost from '../response_modes/form_post.js';
12
+ import { generateXsrf, checkXsrf } from '../shared/xsrf.js';
14
13
 
15
14
  const parseBody = bodyParser.bind(undefined, 'application/x-www-form-urlencoded');
16
15
 
@@ -70,16 +69,14 @@ export const init = [
70
69
  await next();
71
70
  },
72
71
 
72
+ generateXsrf,
73
+
73
74
  async function renderLogout(ctx) {
74
- // TODO: generic xsrf middleware to remove this
75
- const secret = crypto.randomBytes(24).toString('hex');
75
+ const { secret } = ctx.oidc.session.state;
76
76
 
77
- ctx.oidc.session.state = {
78
- secret,
79
- clientId: ctx.oidc.client ? ctx.oidc.client.clientId : undefined,
80
- state: ctx.oidc.params.state,
81
- postLogoutRedirectUri: ctx.oidc.params.post_logout_redirect_uri,
82
- };
77
+ ctx.oidc.session.state.clientId = ctx.oidc.client ? ctx.oidc.client.clientId : undefined;
78
+ ctx.oidc.session.state.state = ctx.oidc.params.state;
79
+ ctx.oidc.session.state.postLogoutRedirectUri = ctx.oidc.params.post_logout_redirect_uri;
83
80
 
84
81
  const action = ctx.oidc.urlFor('end_session_confirm');
85
82
 
@@ -105,15 +102,7 @@ export const confirm = [
105
102
  paramsMiddleware.bind(undefined, new Set(['xsrf', 'logout'])),
106
103
  rejectDupes.bind(undefined, {}),
107
104
 
108
- async function checkLogoutToken(ctx, next) {
109
- if (!ctx.oidc.session.state) {
110
- throw new InvalidRequest('could not find logout details');
111
- }
112
- if (ctx.oidc.session.state.secret !== ctx.oidc.params.xsrf) {
113
- throw new InvalidRequest('xsrf token invalid');
114
- }
115
- await next();
116
- },
105
+ checkXsrf('could not find logout details'),
117
106
 
118
107
  async function endSession(ctx) {
119
108
  const { oidc: { session, params } } = ctx;
@@ -1,13 +1,14 @@
1
+ /* eslint-disable no-param-reassign */
1
2
  import sectorValidate from './sector_validate.js';
2
3
 
3
- export default async function add(provider, metadata, { ctx, store = false } = {}) {
4
- const client = new provider.Client(metadata, ctx); // eslint-disable-line no-use-before-define
4
+ export default async function add(provider, metadata, { ctx, store, cimd } = {}) {
5
+ const client = new provider.Client(metadata, ctx, { cimd });
5
6
 
6
7
  if (client.sectorIdentifierUri !== undefined) {
7
8
  await sectorValidate(provider, client);
8
9
  }
9
10
 
10
- if (store) {
11
+ if (!cimd && store) {
11
12
  await provider.Client.adapter.upsert(client.clientId, client.metadata());
12
13
  }
13
14
  return client;
@@ -102,7 +102,7 @@ export async function resolveClientByMetadataDocument(provider, id) {
102
102
  // Check cache
103
103
  const cached = entries.get(id);
104
104
  if (cached && cached.freshUntil > Date.now()) {
105
- const client = await addClient(provider, cached.properties, { store: false });
105
+ const client = await addClient(provider, cached.properties, { cimd: true });
106
106
  Object.defineProperty(client, 'clientIdMetadataDocument', { value: true });
107
107
 
108
108
  if (!(await feature.allowClient(ctx, client))) {
@@ -180,7 +180,7 @@ export async function resolveClientByMetadataDocument(provider, id) {
180
180
  // Compute cache TTL
181
181
  const ttl = parseCacheDuration(response, feature.cacheDuration);
182
182
 
183
- const client = await addClient(provider, properties, { store: false });
183
+ const client = await addClient(provider, properties, { cimd: true });
184
184
 
185
185
  Object.defineProperty(client, 'clientIdMetadataDocument', { value: true });
186
186
 
@@ -211,23 +211,29 @@ export default function getSchema(provider) {
211
211
  };
212
212
 
213
213
  class Schema {
214
+ #cimd = false;
215
+
214
216
  constructor(
215
217
  metadata,
216
218
  ctx,
217
219
  processCustomMetadata = !!configuration.extraClientMetadata.properties.length,
220
+ cimd = false,
218
221
  ) {
219
- this.#initialize(metadata);
222
+ this.#cimd = cimd;
220
223
 
221
224
  if (processCustomMetadata) {
225
+ this.#assign(metadata);
222
226
  this.processCustomMetadata(ctx);
223
227
  this.#initialize(this);
228
+ } else {
229
+ this.#initialize(metadata);
224
230
  }
225
231
 
226
232
  this.ensureStripUnrecognized();
227
233
  this.ensureStripChoices();
228
234
  }
229
235
 
230
- #initialize(metadata) {
236
+ #assign(metadata) {
231
237
  Object.assign(
232
238
  this,
233
239
  omitBy(
@@ -240,6 +246,10 @@ export default function getSchema(provider) {
240
246
  isUndefined,
241
247
  ),
242
248
  );
249
+ }
250
+
251
+ #initialize(metadata) {
252
+ this.#assign(metadata);
243
253
 
244
254
  this.choices();
245
255
  this.required();
@@ -269,10 +279,6 @@ export default function getSchema(provider) {
269
279
 
270
280
  const responseTypes = new Set(this.response_types.map((rt) => rt.split(' ')).flat());
271
281
 
272
- if (this.grant_types.some((type) => ['authorization_code', 'implicit'].includes(type)) && !this.response_types.length) {
273
- this.invalidate('response_types must contain members');
274
- }
275
-
276
282
  if (responseTypes.size && !this.redirect_uris.length) {
277
283
  const { pushedAuthorizationRequests: par } = features;
278
284
  if (
@@ -291,13 +297,19 @@ export default function getSchema(provider) {
291
297
  }
292
298
 
293
299
  if (responseTypes.has('code') && !this.grant_types.includes('authorization_code')) {
294
- this.invalidate("grant_types must contain 'authorization_code' when code is amongst response_types");
300
+ this.grant_types.push('authorization_code');
295
301
  }
296
302
 
297
- if (responseTypes.has('token') || responseTypes.has('id_token')) {
298
- if (!this.grant_types.includes('implicit')) {
299
- this.invalidate("grant_types must contain 'implicit' when 'id_token' or 'token' are amongst response_types");
300
- }
303
+ if ((responseTypes.has('token') || responseTypes.has('id_token')) && !this.grant_types.includes('implicit')) {
304
+ this.grant_types.push('implicit');
305
+ }
306
+
307
+ if (this.grant_types.includes('implicit') && !responseTypes.has('id_token') && !responseTypes.has('token')) {
308
+ this.grant_types.splice(this.grant_types.indexOf('implicit'), 1);
309
+ }
310
+
311
+ if (this.grant_types.includes('authorization_code') && !responseTypes.has('code')) {
312
+ this.grant_types.splice(this.grant_types.indexOf('authorization_code'), 1);
301
313
  }
302
314
 
303
315
  {
@@ -552,7 +564,12 @@ export default function getSchema(provider) {
552
564
  }
553
565
 
554
566
  if (isAry && !this[prop].every((val) => only[method](val))) {
555
- if (length) {
567
+ if (this.#cimd && length) {
568
+ this[prop] = this[prop].filter((val) => only[method](val));
569
+ if (!this[prop].length) {
570
+ this.invalidate(`${prop} has no values supported by this authorization server`);
571
+ }
572
+ } else if (length) {
556
573
  this.invalidate(`${prop} can only contain ${formatters.formatList([...only], { type: 'disjunction' })}`);
557
574
  } else {
558
575
  this.invalidate(`${prop} must be empty (no values are allowed)`);
@@ -3,19 +3,21 @@ import instance from './weak_cache.js';
3
3
  export default async function fetchBodyCheck(provider, purpose, response) {
4
4
  const limit = instance(provider).configuration.fetchResponseBodyLimits[purpose];
5
5
 
6
- if (Number.isFinite(limit)) {
7
- const contentLength = response.headers.get('content-length');
8
- if (contentLength && parseInt(contentLength, 10) > limit) {
9
- await response.body?.cancel();
10
- throw new Error('response too large');
11
- }
6
+ if (!Number.isFinite(limit)) {
7
+ return Buffer.from(await response.arrayBuffer());
8
+ }
9
+
10
+ const contentLength = response.headers.get('content-length');
11
+ if (contentLength && parseInt(contentLength, 10) > limit) {
12
+ await response.body?.cancel();
13
+ throw new Error('response too large');
12
14
  }
13
15
 
14
16
  const chunks = [];
15
17
  let received = 0;
16
18
  for await (const chunk of response.body) {
17
19
  received += chunk.length;
18
- if (Number.isFinite(limit) && received > limit) {
20
+ if (received > limit) {
19
21
  await response.body?.cancel();
20
22
  throw new Error('response too large');
21
23
  }
@@ -322,8 +322,8 @@ export default function getClient(provider) {
322
322
 
323
323
  static #adapter;
324
324
 
325
- constructor(metadata, ctx) {
326
- const schema = new Client.Schema(metadata, ctx);
325
+ constructor(metadata, ctx, { cimd } = {}) {
326
+ const schema = new Client.Schema(metadata, ctx, undefined, cimd);
327
327
 
328
328
  Object.assign(this, mapKeys(schema, (value, key) => {
329
329
  if (!instance(provider).RECOGNIZED_METADATA.includes(key)) {
@@ -551,7 +551,7 @@ export default function getClient(provider) {
551
551
  let client = dynamicClients.get(propHash);
552
552
 
553
553
  if (!client) {
554
- client = await addClient(provider, properties, { store: false });
554
+ client = await addClient(provider, properties);
555
555
  dynamicClients.set(propHash, client);
556
556
  }
557
557
 
@@ -1,5 +1,3 @@
1
- import * as crypto from 'node:crypto';
2
-
3
1
  import debug from 'debug';
4
2
 
5
3
  import instance from '../helpers/weak_cache.js';
@@ -7,6 +5,8 @@ import * as formHtml from '../helpers/user_code_form.js';
7
5
  import { ReRenderError } from '../helpers/re_render_errors.js';
8
6
  import errOut from '../helpers/err_out.js';
9
7
 
8
+ import { generateXsrf } from './xsrf.js';
9
+
10
10
  const debugError = debug('oidc-provider:error');
11
11
  const serverError = debug('oidc-provider:server_error');
12
12
  const serverErrorTrace = debug('oidc-provider:server_error:trace');
@@ -33,8 +33,8 @@ export default function getErrorHandler(provider, eventName) {
33
33
  }
34
34
 
35
35
  if (ctx.oidc?.session && userInputRoutes.has(ctx.oidc.route)) {
36
- const secret = crypto.randomBytes(24).toString('hex');
37
- ctx.oidc.session.state = { secret };
36
+ generateXsrf(ctx, () => {});
37
+ const { secret } = ctx.oidc.session.state;
38
38
 
39
39
  await userCodeInputSource(ctx, formHtml.input(ctx.oidc.urlFor('code_verification'), secret, err.userCode, charset), out, err);
40
40
  if (err instanceof ReRenderError) { // render without emit
@@ -0,0 +1,22 @@
1
+ import * as crypto from 'node:crypto';
2
+
3
+ import { InvalidRequest } from '../helpers/errors.js';
4
+ import constantEquals from '../helpers/constant_equals.js';
5
+
6
+ export function generateXsrf(ctx, next) {
7
+ const secret = crypto.randomBytes(24).toString('hex');
8
+ ctx.oidc.session.state = { secret };
9
+ return next();
10
+ }
11
+
12
+ export function checkXsrf(missingMessage) {
13
+ return async function verifyXsrf(ctx, next) {
14
+ if (!ctx.oidc.session.state) {
15
+ throw new InvalidRequest(missingMessage);
16
+ }
17
+ if (!constantEquals(ctx.oidc.session.state.secret, ctx.oidc.params.xsrf || '')) {
18
+ throw new InvalidRequest('xsrf token invalid');
19
+ }
20
+ await next();
21
+ };
22
+ }
@@ -153,7 +153,7 @@ The `parse` function accepts a string and returns `TokenData`, which can be used
153
153
 
154
154
  `TokenData` has two properties:
155
155
 
156
- - **tokens** A sequence of tokens, currently of types `text`, `parameter`, `wildcard`, or `group`.
156
+ - **tokens** A sequence of tokens, currently of types `text`, `param`, `wildcard`, or `group`.
157
157
  - **originalPath** The original path used with `parse`, shown in error messages to assist debugging.
158
158
 
159
159
  ### Custom path
@@ -165,13 +165,13 @@ import { match } from "path-to-regexp";
165
165
 
166
166
  const tokens = [
167
167
  { type: "text", value: "/" },
168
- { type: "parameter", name: "foo" },
168
+ { type: "param", name: "foo" },
169
169
  ];
170
170
  const originalPath = "/[foo]"; // To help debug error messages.
171
171
  const path = { tokens, originalPath };
172
172
  const fn = match(path);
173
173
 
174
- fn("/test"); //=> { path: '/test', index: 0, params: { foo: 'test' } }
174
+ fn("/test"); //=> { path: '/test', params: { foo: 'test' } }
175
175
  ```
176
176
 
177
177
  ## Errors
@@ -134,6 +134,9 @@ export type Path = string | TokenData;
134
134
  * Transform a path into a match function.
135
135
  */
136
136
  export declare function match<P extends ParamData>(path: Path | Path[], options?: MatchOptions & ParseOptions): MatchFunction<P>;
137
+ /**
138
+ * Transform a path into a regular expression and capture keys.
139
+ */
137
140
  export declare function pathToRegexp(path: Path | Path[], options?: PathToRegexpOptions & ParseOptions): {
138
141
  regexp: RegExp;
139
142
  keys: Keys;