n8n-editor-ui
Version:
Workflow Editor UI for n8n
2 lines • 7.33 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.13.4"}}catch(e){}}(),System.register(["./vue.runtime.esm-bundler-legacy-IafOlCW8.js","./_MapCache-legacy-DwgdC8YO.js","./src-legacy-Dwzr7bD0.js","./users.store-legacy-OKuN0qAC.js","./constants-legacy-DNCca_FT.js","./_baseOrderBy-legacy-PsQY_Pvh.js"],(function(e,t){var n,r,o,i,a,c,s,u,l,d,f,p,y,h,w,g,b,C,A;function m(){const e=d(),t=u(),r=h(),o=l(),i=a(),c=f(),s=n(null),p=n(null);function y(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(...y(e,n));return o}function w(e){const t=y(e);return"oAuth2Api"===e||"oAuth1Api"===e||t.includes("oAuth2Api")||t.includes("oAuth1Api")}function C(){o.showError(new Error(i.baseText("credentialEdit.credentialEdit.showError.invalidOAuthUrl.message")),i.baseText("credentialEdit.credentialEdit.showError.invalidOAuthUrl.title"))}async function A(t,n){const r=await async function(t){const n=y(t.type);try{if("oAuth2Api"===t.type||n.includes("oAuth2Api"))return b(await e.oAuth2Authorize(t));if("oAuth1Api"===t.type||n.includes("oAuth1Api"))return b(await e.oAuth1Authorize(t))}catch(r){return o.showError(r,i.baseText("credentialEdit.credentialEdit.showError.generateAuthorizationUrl.title")),g("api-error")}return g("no-url")}(t);if(!r.ok)return"no-url"===r.error&&C(),!1;if(!function(e){try{const t=new URL(e);return["http:","https:"].includes(t.protocol)}catch{return!1}}(r.result))return C(),!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):(C(),!1)}return{getParentTypes:y,isOAuthCredentialType:w,isGoogleOAuthType:function(e){const t=y(e);return"googleOAuth2Api"===e||t.includes("googleOAuth2Api")},hasManagedOAuthCredentials:function(t){if(!w(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:A,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 A(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=s(),h=f(),g=p(),b=l(),T=a(),k=d(),v=u(),_=A(),E=w(),x=n(!1),{isOAuthCredentialType:N,createAndAuthorize:q,cancelAuthorize:O}=m(),P=[],z=o((()=>{const t=new Map;for(const n of e.moduleSettings["quick-connect"]?.options??[])t.set(n.credentialType,n);return t})),I=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 M(e,t){if(0===z.value.size)return;const n=z.value.get(e);if(!n)return;const r=t.split(".")[0];return n.packageName.split(".")[0]===r?n:void 0}async function j(e){return x.value=!0,await async function(e,{quickConnectType:t}){return await C(e,"POST","/quick-connect",{quickConnectType:t})}(_.restApiContext,e)}async function B(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-CLyf4qjy.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(),P.push((()=>r.cleanup()))}))}(e);case"firecrawl":return await j(e);default:throw new Error(`Quick connect for type ${e.quickConnectType} is not implemented`)}}function S(){P.splice(0,P.length).forEach((e=>{try{e()}catch{}}))}function U(e){const t=E.currentUser;return t?["email","firstName","fullName","lastName"].reduce(((e,n)=>e.replaceAll(`{user.${n}}`,t[n]??"")),e):e}return i(S),{loading:x,getQuickConnectOption:M,getQuickConnectOptionByPackageName:function(e){if(0!==I.value.size)return I.value.get(e)},getQuickConnectOptionByCredentialTypes:function(e){if(0!==z.value.size)for(const t of e){const e=z.value.get(t);if(e)return e}},connect:async function(e){S();const{credentialTypeName:t,nodeType:n,source:o}=e;if(h.track("User clicked quick connect button",{source:o,credential_type:t,node_type:n}),N(t))return await q(t,n);const i=M(t,n);if(i){const n=k.getCredentialTypeByName(t);if(!n)return null;try{if(i.consentText&&"confirm"!==await g.confirm(r("span",{innerHTML:y(U(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:y(i.consentCheckbox)}):void 0}))return null;const o=await B(i);return o?await k.createNewCredential({id:"",name:n.displayName,type:t,data:{...o,allowedHttpRequestDomains:"none"}},v.currentProject?.id):null}catch(a){return b.showError(a,T.baseText("credentialEdit.credentialEdit.showError.createCredential.title")),null}finally{x.value=!1,S()}}return null},cancelConnect:O}}}),{setters:[function(e){n=e.Ft,r=e.I,o=e.S,i=e.q},function(e){a=e.bt},function(e){c=e.na},function(e){s=e.As,u=e.Ft,l=e.Tr,d=e.at,f=e.en,p=e.jr,y=e.pl,h=e.s,w=e.t},function(e){g=e.Fi,b=e.Ii,e.Ps},function(e){C=e.d,A=e.r}],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]="9cbf34e3-0fc4-4f8d-947c-8ab42b54430f",e._sentryDebugIdIdentifier="sentry-dbid-9cbf34e3-0fc4-4f8d-947c-8ab42b54430f")}catch(e){}var e,t}}}));
//# sourceMappingURL=useQuickConnect-legacy-Joyt3P8m.js.map