n8n-editor-ui
Version:
Workflow Editor UI for n8n
2 lines • 7.38 kB
JavaScript
!function(){try{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{}).SENTRY_RELEASE={id:"n8n@2.16.1"}}catch(e){}}(),System.register(["./vue.runtime.esm-bundler-legacy-BW6xDdqj.js","./core-legacy-VD8c7QJ-.js","./get-legacy-CLCnFf3e.js","./users.store-legacy-azRUgFdP.js","./constants-legacy-2_ytuuS3.js","./useRootStore-legacy-CC08el-l.js","./settings.store-legacy-I6rZOvfF.js"],(function(e,t){var n,r,o,i,a,c,s,u,l,d,f,p,y,h,w,g,C,A,b;function m(){const e=f(),t=l(),r=y(),o=u(),i=a(),c=d(),s=n(null),p=n(null);function h(t,n=new Set){if(n.has(t))return[];n.add(t);const r=e.getCredentialTypeByName(t);if(void 0===r?.extends)return[];const o=[];for(const e of r.extends)o.push(e),o.push(...h(e,n));return o}function C(e){const t=h(e);return"oAuth2Api"===e||"oAuth1Api"===e||t.includes("oAuth2Api")||t.includes("oAuth1Api")}function A(){o.showError(new Error(i.baseText("credentialEdit.credentialEdit.showError.invalidOAuthUrl.message")),i.baseText("credentialEdit.credentialEdit.showError.invalidOAuthUrl.title"))}async function b(t,n){const r=await async function(t){const n=h(t.type);try{if("oAuth2Api"===t.type||n.includes("oAuth2Api"))return g(await e.oAuth2Authorize(t));if("oAuth1Api"===t.type||n.includes("oAuth1Api"))return g(await e.oAuth1Authorize(t))}catch(r){return o.showError(r,i.baseText("credentialEdit.credentialEdit.showError.generateAuthorizationUrl.title")),w("api-error")}return w("no-url")}(t);if(!r.ok)return"no-url"===r.error&&A(),!1;if(!function(e){try{const t=new URL(e);return["http:","https:"].includes(t.protocol)}catch{return!1}}(r.result))return A(),!1;const a=function(e,t){const n=window.open(e,"OAuth Authorization","scrollbars=no,resizable=yes,status=no,titlebar=no,location=no,toolbar=no,menubar=no,width=500,height=700");return t?.addEventListener("abort",(()=>{n?.close()})),n}(r.result,n);return a?await async function(e,t){return await new Promise((n=>{const r=new BroadcastChannel("oauth-callback");let a=!1;const c=e=>{a||(a=!0,r.close(),n(e))};t?.addEventListener("abort",(()=>{c(!1)})),r.addEventListener("message",(t=>{e.close(),"success"===t.data?(o.showMessage({title:i.baseText("nodeCredentials.oauth.accountConnected"),type:"success"}),c(!0)):(o.showMessage({title:i.baseText("nodeCredentials.oauth.accountConnectionFailed"),type:"error"}),c(!1))}))}))}(a,n):(A(),!1)}return{getParentTypes:h,isOAuthCredentialType:C,isGoogleOAuthType:function(e){const t=h(e);return"googleOAuth2Api"===e||t.includes("googleOAuth2Api")},hasManagedOAuthCredentials:function(t){if(!C(t))return!1;const n=e.getCredentialTypeByName(t);if(!n)return!1;if(n.__skipManagedCreation)return!1;const r=n.__overwrittenProperties??[];return 0!==r.length&&n.properties.filter((e=>"hidden"!==e.type&&"notice"!==e.type&&!r.includes(e.name))).every((e=>!0!==e.required||"string"!==e.type&&"number"!==e.type))},authorize:b,createAndAuthorize:async function(n,a){const u=e.getCredentialTypeByName(n);if(!u)return null;let l;try{l=await e.createNewCredential({id:"",name:u.displayName,type:n,data:{allowedHttpRequestDomains:"none"}},t.currentProject?.id,void 0,{skipStoreUpdate:!0}),c.track("User created credentials",{credential_type:l.type,credential_id:l.id,workflow_id:r.workflowId})}catch(h){return o.showError(h,i.baseText("nodeCredentials.showMessage.title")),null}const d=new AbortController;s.value=d,p.value=l.id;const f=await b(l,d.signal);s.value=null,p.value=null;const y={credential_type:n,workflow_id:r.workflowId??null,credential_id:l.id,is_complete:!0,is_new:!0,is_valid:f,uses_external_secrets:!1};return a&&(y.node_type=a),c.track("User saved credentials",y),f?(e.upsertCredential(l),l):(e.deleteCredential({id:l.id}),null)},cancelAuthorize:function(){s.value&&s.value.abort(),p.value&&e.deleteCredential({id:p.value})}}}return e({n:m,t:function(){const e=b(),y=d(),w=s(),g=u(),T=a(),k=f(),v=l(),E=A(),_=h(),x=n(!1),{isOAuthCredentialType:N,createAndAuthorize:q,cancelAuthorize:O}=m(),z=[],P=o((()=>{const t=new Map;for(const n of e.moduleSettings["quick-connect"]?.options??[])t.set(n.credentialType,n);return t})),j=o((()=>{const t=new Map;for(const n of e.moduleSettings["quick-connect"]?.options??[])t.has(n.packageName)||t.set(n.packageName,n);return t}));function I(e,t){if(0===P.value.size)return;const n=P.value.get(e);if(!n)return;const r=t.split(".")[0];return n.packageName.split(".")[0]===r?n:void 0}async function S(e){return x.value=!0,await async function(e,{quickConnectType:t}){return await C(e,"POST","/quick-connect",{quickConnectType:t})}(E.restApiContext,e)}async function M(e){switch(e.quickConnectType){case"pinecone":return await async function(e){const{ConnectPopup:n}=await c((async()=>{const{ConnectPopup:e}=await t.import("./dist-legacy-BNsWKiwU.js");return{ConnectPopup:e}}),void 0);return await new Promise((t=>{const r=n({onConnect:({key:e})=>t({apiKey:e}),onCancel:()=>t(null),integrationId:String(e.config.integrationId)});r.open(),z.push((()=>r.cleanup()))}))}(e);case"firecrawl":return await S(e);default:throw new Error(`Quick connect for type ${e.quickConnectType} is not implemented`)}}function B(){z.splice(0,z.length).forEach((e=>{try{e()}catch{}}))}function L(e){const t=_.currentUser;return t?["email","firstName","fullName","lastName"].reduce(((e,n)=>e.replaceAll(`{user.${n}}`,t[n]??"")),e):e}return i(B),{loading:x,getQuickConnectOption:I,getQuickConnectOptionByPackageName:function(e){if(0!==j.value.size)return j.value.get(e)},getQuickConnectOptionByCredentialTypes:function(e){if(0!==P.value.size)for(const t of e){const e=P.value.get(t);if(e)return e}},connect:async function(e){B();const{credentialTypeName:t,nodeType:n,source:o}=e;if(y.track("User clicked quick connect button",{source:o,credential_type:t,node_type:n}),N(t))return await q(t,n);const i=I(t,n);if(i){const n=k.getCredentialTypeByName(t);if(!n)return null;try{if(i.consentText&&"confirm"!==await w.confirm(r("span",{innerHTML:p(L(i.consentText))}),T.baseText("nodeCredentials.quickConnect.connectTo",{interpolate:{provider:e.serviceName}}),{customClass:"wide",confirmButtonText:T.baseText("nodeCredentials.quickConnect.consent.confirm"),cancelButtonText:T.baseText("nodeCredentials.quickConnect.consent.cancel"),confirmationCheckboxMessage:i.consentCheckbox?r("span",{innerHTML:p(i.consentCheckbox)}):void 0}))return null;const o=await M(i);return o?await k.createNewCredential({id:"",name:n.displayName,type:t,data:{...o,allowedHttpRequestDomains:"none"}},v.currentProject?.id):null}catch(a){return g.showError(a,T.baseText("credentialEdit.credentialEdit.showError.createCredential.title")),null}finally{x.value=!1,B()}}return null},cancelConnect:O}}}),{setters:[function(e){n=e.Ft,r=e.I,o=e.S,i=e.q},function(e){a=e.at},function(e){c=e.d},function(e){s=e.Ln,u=e.Pn,l=e.ai,d=e.fr,f=e.it,p=e.js,y=e.s,h=e.t},function(e){w=e.vi,g=e.yi,e.ys},function(e){C=e.c,A=e.t},function(e){b=e.t}],execute:function(){try{e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},(t=(new e.Error).stack)&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d8b0138c-74ad-4fe6-8de7-170350fb5fd6",e._sentryDebugIdIdentifier="sentry-dbid-d8b0138c-74ad-4fe6-8de7-170350fb5fd6")}catch(e){}var e,t}}}));
//# sourceMappingURL=useQuickConnect-legacy-BfHzqFqv.js.map