@useparagon/connect 1.0.20-experimental.8 → 1.0.20
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.
- package/dist/src/ConnectSDK.d.ts +8 -19
- package/dist/src/entities/connectCredential.interface.d.ts +2 -2
- package/dist/src/index.js +1 -1
- package/dist/src/types/connect.d.ts +12 -27
- package/dist/src/types/sdk.d.ts +5 -45
- package/dist/src/utils/connect.d.ts +0 -6
- package/dist/src/utils/generic.d.ts +0 -2
- package/package.json +2 -6
- package/dist/src/entities/connectCredentialConfig.interface.d.ts +0 -31
- package/sandbox/index.html +0 -161
package/dist/src/ConnectSDK.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { IConnectCredential } from './entities/connectCredential.interface';
|
|
2
|
-
import { IConnectCredentialConfig } from './entities/connectCredentialConfig.interface';
|
|
3
2
|
import { OauthCallbackResponse } from './entities/credential.interface';
|
|
4
3
|
import { IConnectIntegrationWithCredentialInfo, IIntegrationMetadata } from './entities/integration.interface';
|
|
5
4
|
import { PersonaMeta } from './entities/persona.interface';
|
|
6
5
|
import SDKEventEmitter from './SDKEventEmitter';
|
|
7
6
|
import { ConnectSdkEnvironments } from './server.types';
|
|
8
|
-
import { AuthenticateOptions, AuthenticatedConnectUser, CompleteInstallOptions, Props as ConnectModalProps, ConnectParams, ConnectUser,
|
|
7
|
+
import { AuthenticateOptions, AuthenticatedConnectUser, CompleteInstallOptions, Props as ConnectModalProps, ConnectParams, ConnectUser, DisableWorkflowOptions, EventInfo, GetIntegrationAccountOptions, IConnectSDK, InstallIntegrationOptions, TriggerWorkflowRequest, UninstallOptions } from './types';
|
|
9
8
|
export declare const PARAGON_OVERFLOW_EMPTY_VALUE = "PARAGON_OVERFLOW_EMPTY_VALUE";
|
|
10
9
|
export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
|
|
11
10
|
root: HTMLIFrameElement | undefined;
|
|
@@ -53,7 +52,7 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
|
|
|
53
52
|
private createReactRoot;
|
|
54
53
|
/**
|
|
55
54
|
* checks
|
|
56
|
-
* - if
|
|
55
|
+
* - if integartion name is valid
|
|
57
56
|
* - if integration is setup in project
|
|
58
57
|
* - if integration is active in project
|
|
59
58
|
* throws error if any of these is not met
|
|
@@ -116,8 +115,6 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
|
|
|
116
115
|
* Display the Paragon Connect modal
|
|
117
116
|
*/
|
|
118
117
|
connect(action: string, params?: ConnectParams): Promise<void>;
|
|
119
|
-
private setCredentialConfigForUserState;
|
|
120
|
-
private getCredentialAndConfig;
|
|
121
118
|
/**
|
|
122
119
|
* Retrieves an integration object from the loaded integrations based on the integration ID.
|
|
123
120
|
* @param integrationId The ID of the integration to retrieve.
|
|
@@ -152,7 +149,7 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
|
|
|
152
149
|
body: RequestInit['body'] | object;
|
|
153
150
|
headers: RequestInit['headers'];
|
|
154
151
|
}): Promise<TResponse | undefined>;
|
|
155
|
-
event(name: string, payload: Record<string, unknown
|
|
152
|
+
event(name: string, payload: Record<string, unknown>): Promise<void>;
|
|
156
153
|
/**
|
|
157
154
|
* @summary this will be called to close the modal
|
|
158
155
|
* @param forceClose is set when modal is closed by cross btn
|
|
@@ -185,7 +182,7 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
|
|
|
185
182
|
* @param workflowId
|
|
186
183
|
* @param payload
|
|
187
184
|
*/
|
|
188
|
-
workflow(workflowId: string, { selectedCredentialId,
|
|
185
|
+
workflow(workflowId: string, { selectedCredentialId, body, query, headers }?: TriggerWorkflowRequest): Promise<object | undefined>;
|
|
189
186
|
/**
|
|
190
187
|
* for programmatically installing an integration
|
|
191
188
|
*/
|
|
@@ -196,7 +193,6 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
|
|
|
196
193
|
ensureHeadlessIsSupported(): void;
|
|
197
194
|
uninstallIntegration(action: string, options?: UninstallOptions): Promise<void>;
|
|
198
195
|
disableWorkflow(workflowId: string, options?: DisableWorkflowOptions): Promise<void>;
|
|
199
|
-
enableWorkflow(workflowId: string, options?: CredentialConfigOptions): Promise<void>;
|
|
200
196
|
/**
|
|
201
197
|
* Get account details by integration type. To get accountAuth, includeAccountAuth should be true in options.
|
|
202
198
|
* Note that accountAuth is allowed for only some of the integrations.
|
|
@@ -204,6 +200,10 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
|
|
|
204
200
|
getIntegrationAccount(integrationType: string, options?: GetIntegrationAccountOptions): Promise<IConnectIntegrationWithCredentialInfo>;
|
|
205
201
|
private getIntegrationForWorkflow;
|
|
206
202
|
private updateLocalState;
|
|
203
|
+
/**
|
|
204
|
+
* also returns false if unable to find workflow in configured workflow property of any integration
|
|
205
|
+
*/
|
|
206
|
+
private isWorkflowEnabled;
|
|
207
207
|
/**
|
|
208
208
|
* gets the user data from api `/sdk/me`
|
|
209
209
|
*/
|
|
@@ -246,16 +246,5 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
|
|
|
246
246
|
* @returns
|
|
247
247
|
*/
|
|
248
248
|
connectAction(resourceName: string, payload: Record<string, unknown>): Promise<IConnectCredential>;
|
|
249
|
-
/**
|
|
250
|
-
* Creates a new configuration using the provided credentials.
|
|
251
|
-
* @param {CreateConfigurationOptions} param0
|
|
252
|
-
* @returns {Promise<IConnectCredentialConfig> }
|
|
253
|
-
*/
|
|
254
|
-
createConfiguration({ credentialId, externalId, }: CreateConfigurationOptions): Promise<IConnectCredentialConfig>;
|
|
255
|
-
/**
|
|
256
|
-
* Destroys an existing configuration using the provided instance ID.
|
|
257
|
-
*/
|
|
258
|
-
destroyConfiguration({ id, credentialId }: DeleteConfigurationOptions): Promise<void>;
|
|
259
|
-
updateConfiguration({ id, credentialId, meta, }: UpdateConfigurationOptions): Promise<IConnectCredentialConfig>;
|
|
260
249
|
private pollForCredential;
|
|
261
250
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConnectCredentialConfig } from '../types/connect';
|
|
2
2
|
export interface IConnectCredential {
|
|
3
3
|
id: string;
|
|
4
4
|
projectId: string;
|
|
5
5
|
integrationId: string;
|
|
6
|
-
|
|
6
|
+
config: ConnectCredentialConfig;
|
|
7
7
|
personaId: string;
|
|
8
8
|
isPreviewCredential: boolean;
|
|
9
9
|
/**
|
package/dist/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
(()=>{var t={773:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PARAGON_OVERFLOW_EMPTY_VALUE=void 0;const i=n(655),r=i.__importDefault(n(245)),o=n(59),s=n(745),a=n(343),l=n(643),d=n(429),c=i.__importDefault(n(892)),u=n(821),h=n(158),f=n(846),g=n(572),p=n(321),E=n(35),_="paragon-connect-frame",v=`${_}-container`,S="paragon-connect-user-state";e.PARAGON_OVERFLOW_EMPTY_VALUE="PARAGON_OVERFLOW_EMPTY_VALUE";class C extends c.default{constructor(t){if(super(),this.rootLoaded=!1,this.rootElementCreated=!1,this.modalState={integration:null,onClose:this.onClose.bind(this),overlayStyle:{overflow:"auto"},onOpen:this.onOpen.bind(this),apiInstallationOptions:{isApiInstallation:!1,showPortalAfterInstall:!1}},this.userState={authenticated:!1},this.loadedConfigs={},this.loadedIntegrations={},this.endUserIntegrationConfig={},this.metadata={},this.cachedApiResponse=new E.CacheThrottle({ttl:5e3}),this.keyToRequestPromiseMap={},this.originalBodyOverflow=e.PARAGON_OVERFLOW_EMPTY_VALUE,"undefined"==typeof window)return void console.warn("connect sdk can only be used on browser");const n=(0,h.getAssetUrl)({CDN_PUBLIC_URL:"https://cdn.useparagon.com",DASHBOARD_PUBLIC_URL:"https://dashboard.useparagon.com",NODE_ENV:"production",PLATFORM_ENV:"production",VERSION:"latest"});if(this.environments={CDN_PUBLIC_URL:n,CONNECT_PUBLIC_URL:"https://connect.useparagon.com",DASHBOARD_PUBLIC_URL:"https://dashboard.useparagon.com",NODE_ENV:"production",PASSPORT_PUBLIC_URL:"https://passport.useparagon.com",PLATFORM_ENV:"production",VERSION:"latest",WORKER_PROXY_PUBLIC_URL:"https://proxy.useparagon.com",ZEUS_PUBLIC_URL:"https://zeus.useparagon.com",...t},!this.environments.CONNECT_PUBLIC_URL)throw new Error("Paragon SDK error! No `CONNECT_PUBLIC_URL` configured.");if(!this.environments.DASHBOARD_PUBLIC_URL)throw new Error("Paragon SDK error! No `DASHBOARD_PUBLIC_URL` configured.");if(!this.environments.PASSPORT_PUBLIC_URL)throw new Error("Paragon SDK error! No `PASSPORT_PUBLIC_URL` configured.");if(!this.environments.WORKER_PROXY_PUBLIC_URL)throw new Error("Paragon SDK error! No `WORKER_PROXY_PUBLIC_URL` configured.");if(!this.environments.ZEUS_PUBLIC_URL)throw new Error("Paragon SDK error! No `ZEUS_PUBLIC_URL` configured.");this.loadState(),window.addEventListener("message",this.eventMessageHandler.bind(this)),window.document.readyState===u.DocumentLoadingState.LOADING?window.document.addEventListener("DOMContentLoaded",(()=>{this.createReactRoot()})):this.createReactRoot()}async eventMessageHandler(t){switch(t.data.type){case"oauth_success_callback":await this._oauthCallback(t.data.credential);break;case"oauth_error_callback":await this._oauthErrorCallback(t.data.error,t);break;default:await this.functionInvocationHandler(t)}}async functionInvocationHandler(t){if("SDK_FUNCTION_INVOCATION"!==t.data.messageType)return;const{type:e,id:n,parameters:i}=t.data;let r;try{r={messageType:"SDK_FUNCTION_RESPONSE",id:n,type:e,result:await this[e](...i)}}catch(t){r={messageType:"SDK_FUNCTION_ERROR",error:!0,message:t.message,id:n}}t.source.postMessage(r,this.environments.CONNECT_PUBLIC_URL)}createReactRoot(){var t;if(this.rootElementCreated)return;this.rootElementCreated=!0,this.root=document.createElement("iframe"),this.root.onload=()=>{this.rootLoaded=!0,this.render()};const e=!!document.querySelector(`#${v}`);this.root.id=_,this.root.src=`${this.environments.CONNECT_PUBLIC_URL}/ui${this.projectId?`?projectId=${this.projectId}`:""}`,this.root.style.position=e?"absolute":"fixed",this.root.style.top="0",this.root.style.left="0",this.root.style.width=e?"100%":"100vw",this.root.style.height=e?"100%":"100vh",this.root.style.zIndex="2147483647",this.root.style.display="none",null===(t=document.querySelector(`#${v}`)||document.body)||void 0===t||t.appendChild(this.root)}validateAction(t){var e;if(!this.loadedIntegrations[t]&&!(0,a.isCustomIntegrationTypeName)(t))throw new Error(`"${t}" is not a valid integration type. The integrations you have configured for this Paragon project are:\n\n${Object.keys(this.loadedConfigs).map((t=>`- "${t}"`)).join("\n")}\n`);if(!this.loadedConfigs[t]||!this.userState.integrations[t])throw new Error(`integration "${t}" has not been set up in your Paragon project yet.\n\n${Object.keys(this.loadedConfigs).map((t=>`- "${t}"`)).join("\n")}`);if(!(null===(e=this.loadedIntegrations[t])||void 0===e?void 0:e.isActive))throw new Error(`integration "${t}" is not active in your Paragon project yet.`)}isAlreadyInstalled(t,e,n){var i,r;if(n){const t=this.getCredentialAndConfig({selectedCredentialId:n});return(null===(i=null==t?void 0:t.selectedCredential)||void 0===i?void 0:i.status)===o.CredentialStatus.VALID}return Boolean(null===(r=e.integrations[t])||void 0===r?void 0:r.enabled)}async bootstrapSDKState(t){this.projectId&&this.userState.authenticated&&(this.project=await this.sendConnectRequest(`/sdk/projects/${this.projectId}`,{headers:{"X-Paragon-Cache-Metadata":"1",...t?{"X-Paragon-User-Metadata":JSON.stringify(t)}:{}}},!1),await this.updateLocalState())}setModalState(t){this.modalState={config:void 0,...this.modalState,...t},this.render()}loadState(){if("undefined"!=typeof window)try{const t=window.localStorage.getItem(S)?JSON.parse(window.localStorage.getItem(S)):{};if(t.projectId&&(this.projectId=t.projectId),t.userState){const{userState:e}=t;if(!("authenticated"in e&&e.authenticated&&"token"in e))throw new Error("Malformatted or unauthenticated user was persisted into localStorage. Refusing to load.");this.updateAuthenticatedUser(e),this.bootstrapSDKState().catch((()=>{this.clearState()}))}}catch{this.clearState()}}saveState(){"undefined"!=typeof window&&this.userState.authenticated&&window.localStorage.setItem(S,JSON.stringify({projectId:this.projectId,userState:this.userState}))}clearState(){"undefined"!=typeof window&&window.localStorage.removeItem(S)}render(){if(this.root&&this.rootLoaded){const{onClose:t,onOpen:e,...n}=this.modalState,i={messageType:"UI_UPDATE",nextContext:{user:this.userState,projectId:this.projectId,environments:this.environments,project:this.project,endUserIntegrationConfig:this.modalState.integration?this.endUserIntegrationConfig[this.modalState.integration.type]:void 0},nextModalState:n};if(!this.root.contentWindow)throw new Error("Browser not supported");this.root.contentWindow.postMessage(i,this.environments.CONNECT_PUBLIC_URL)}}updateContainerStyle(t){let{isModalShown:e}=t;this.root&&(this.root.style.display=e?"block":"none")}async authenticate(t,e,n){var i;if(!t||!e)throw new Error("projectId or token not specified to paragon.authenticate()");let o={};try{o=(0,r.default)(e)}catch(t){throw new Error("A well-formed JWT was not provided to paragon.authenticate()")}this.projectId=t,this.userState={authenticated:!0,token:e,userId:o.sub||o.id,integrations:{},meta:null!==(i=null==n?void 0:n.metadata)&&void 0!==i?i:{},resources:[]};try{if(Date.now()>=1e3*(o.exp||0))throw new Error("JWT token provided has expired.");await this.bootstrapSDKState(null==n?void 0:n.metadata)}catch(t){throw console.warn("paragon.authenticate() could not login user",t),this.logout(),new Error(`Failed to authenticate user with Paragon: ${t.message}`)}this.render()}getUser(){return Object.fromEntries(Object.entries(this.userState).filter((t=>{let[e]=t;return"token"!==e})))}updateAuthenticatedUser(t){this.userState.authenticated?this.userState={...this.userState,...t}:t.authenticated&&(this.userState=t),this.render()}logout(){this.userState={authenticated:!1},this.clearState(),this.render()}async connect(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{mapObjectFields:n,overrideRedirectUrl:i,isApiInstallation:r=!1,showPortalAfterInstall:o,bypassPostOAuthPrompt:l,allowMultipleCredentials:c,selectedCredentialId:h,selectedConfigurationId:f,accountType:g,...E}=e;return this.integrationToBeEnabled=t,new Promise(((_,v)=>{var S,C,I;if(!this.userState.authenticated)throw new Error("User not authenticated, Call paragon.authenticate(<projectId>, <user token>) before using the SDK.");this.subscribeToIntegration(t,{...E,onInstall:(t,e)=>{var n;_(),(null==E?void 0:E.onInstall)?E.onInstall(t,e):null===(n=null==E?void 0:E.onSuccess)||void 0===n||n.call(E,t,e)},onError:t=>{var e;v(t),null===(e=null==E?void 0:E.onError)||void 0===e||e.call(E,t)}});try{if(n&&!this.project.accessibleFeatures.includes(u.ConnectAddOn.DynamicFieldMapper))throw new Error("Dynamic Field Mapping is available on our Enterprise plan. Contact sales@useparagon.com to learn more or upgrade.");if(this.validateAction(t),i&&!(0,p.isValidUrl)(i))throw new Error(`${i} is not valid url.`);this.endUserIntegrationConfig[t]={mapObjectFields:n,overrideRedirectUrl:i?(0,p.sanitizeUrl)(i):void 0};const E=Object.values(this.loadedIntegrations).find((e=>(0,a.getIntegrationTypeName)(e)===t)),_="string"==typeof g?null==g?void 0:g.trim():"",v=null===(C=null===(S=null==E?void 0:E.sdkIntegrationConfig)||void 0===S?void 0:S.accountTypes)||void 0===C?void 0:C.find((t=>t.id===_)),O={isApiInstallation:r,showPortalAfterInstall:o,bypassPostOAuthPrompt:l,allowMultipleCredentials:c,selectedCredentialId:h,selectedConfigurationId:f};if(this.setCredentialConfigForUserState(t,h,f),e.isApiInstallation){const e={context:{user:this.userState,projectId:this.projectId,environments:this.environments,endUserIntegrationConfig:this.endUserIntegrationConfig[t]},integration:E};if(Boolean(E.needPreOauthInputs&&v&&!(null===(I=v.endUserSuppliedValues)||void 0===I?void 0:I.length)&&v.scheme===s.AuthenticationScheme.OAUTH)||!E.needPreOauthInputs){e.authParams=null==v?void 0:v.oauthParameters,e.installOptions=O;const t=Math.random().toString(36).substring(2,15),n=(0,d.startOAuthFlow)(e,t);if(n){const e=Date.now(),i=setInterval((()=>{if(Date.now()-e>d.MAX_POLL_DURATION)clearInterval(i);else try{n.opener||(clearInterval(i),this.pollForCredential(t))}catch(e){this.pollForCredential(t)}}),500)}}}g&&!v&&console.warn(`Account type "${g}" is not valid for integration "${null==E?void 0:E.type}"`);const y=JSON.parse(JSON.stringify(this.loadedConfigs[t])),w=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(!t)return;const e=new Set,n=[];for(const i of t)e.has(i.value)?console.warn(`Duplicated key: "${i.value}", Ignored: "${i.label}"`):(n.push(i),e.add(i.value));return n};if("dropdowns"in e){const n=e.dropdowns;if(y.sharedMeta&&Array.isArray(y.sharedMeta.inputs))for(const t of y.sharedMeta.inputs){const e=w(n[t.key]);e&&t.customDropdownOptions&&(t.customDropdownOptions=e)}if(y.workflowMeta)for(const t in y.workflowMeta){const e=y.workflowMeta[t];for(const t of e.inputs){const e=w(n[t.key]);e&&t.customDropdownOptions&&(t.customDropdownOptions=e)}}this.loadedConfigs[t]=y}this.setModalState({integration:E,config:this.loadedConfigs[t],apiInstallationOptions:{...O,selectedAccountConfig:v},selectedCredentialId:h,connectionError:void 0})}catch(e){this.emitError(e,t)}}))}setCredentialConfigForUserState(t,e,n){var i,r,s;if(!this.userState.authenticated||!(null===(i=this.userState.integrations[t])||void 0===i?void 0:i.allCredentials.length))return;const a=this.userState.integrations[t],l=null!==(r=null==a?void 0:a.credentialId)&&void 0!==r?r:null==a?void 0:a.allCredentials[0].id,d=this.getCredentialAndConfig(e||n?{selectedCredentialId:e,selectedConfigurationId:n}:{selectedCredentialId:l},a);if(!(null===(s=null==a?void 0:a.allCredentials)||void 0===s?void 0:s.some((t=>{let{id:e}=t;return e===(null==d?void 0:d.selectedCredential.id)})))||!d)throw new Error(`Credential with ID "${e}" is not a valid ${t} account.`);const{selectedConfig:c,selectedCredential:u}=d,h={...a,allConfigurations:(null==a?void 0:a.allConfigurations)||[],allCredentials:(null==a?void 0:a.allCredentials)||[],enabled:u.status===o.CredentialStatus.VALID,credentialId:u.id,credentialStatus:u.status,providerData:u.providerData,providerId:u.providerId,configMeta:null==c?void 0:c.configMeta,credentialConfigId:null==c?void 0:c.id,externalId:null==c?void 0:c.externalId,sharedSettings:null==c?void 0:c.sharedSettings,workflowSettings:null==c?void 0:c.workflowSettings,configuredWorkflows:null==c?void 0:c.workflowSettings};this.userState.integrations={...this.userState.integrations,[t]:h}}getCredentialAndConfig(t,e){var n;const{selectedCredentialId:i,selectedConfigurationId:r}=t;if(!this.userState.authenticated||!i&&!r)return;let o,s;const a=null!==(n=null==e?void 0:e.allCredentials)&&void 0!==n?n:Object.values(this.userState.integrations).flatMap((t=>(null==t?void 0:t.allCredentials)||[])),l=a.flatMap((t=>{let{configurations:e}=t;return e}));if(r){const t=r.startsWith("ext:")||!(0,g.isUUID)(r),e=(0,h.sanitizeExternalConfigId)(r);if(s=l.find((n=>(t?n.externalId===e:n.id===e)&&(!i||n.connectCredentialId===i))),!s)throw new Error(`Credential configuration not found for provided id: ${r}.`)}if(o=a.find((t=>{let{id:e}=t;return e===((null==s?void 0:s.connectCredentialId)||i)})),s=null!=s?s:null==o?void 0:o.configurations.find((t=>{let{isDefault:e}=t;return e})),!o)throw new Error("Unable to find credential for provided options.");if(!s)throw new Error(`Credential configuration not found for credential: ${o.id}.`);if(s&&s.connectCredentialId!==(null==o?void 0:o.id))throw new Error('Provided "selectedCredentialId" does not belongs to provided "selectedConfigurationId".');return{selectedCredential:o,selectedConfig:s}}_getIntegration(t){return Object.values(this.loadedIntegrations).find((e=>e.id===t))}async _oauthCallback(t,e){var n;const{integrationId:i,payload:r}=t,s=this._getIntegration(i);if(!s)return;const l=(0,a.getIntegrationTypeName)(s),d=(null===(n=this.modalState.apiInstallationOptions)||void 0===n?void 0:n.isApiInstallation)?this.modalState.apiInstallationOptions:{};try{const t=e?`/sdk/credentials/${e}/complete-setup`:"/sdk/credentials",n=await this.sendConnectRequest(t,{method:"POST",body:JSON.stringify({integrationId:s.id,config:{},payload:r,installOptions:d})});if(!n)throw new Error("Unable to save oauth credentials");this.updateCredentialData(n,s),n.status===o.CredentialStatus.VALID&&this.triggerSDKEvent({type:u.SDK_EVENT.ON_INTEGRATION_INSTALL,integrationId:s.id,integrationType:l}),this.setModalState({...this.modalState,connectionError:void 0})}catch(t){this.setModalState({...this.modalState,connectionError:t.message}),this.emitError(t,l),await this._oauthErrorCallback(t.message)}}async _oauthErrorCallback(t,e){var n;const i=t;let r;r=this.integrationToBeEnabled?this.loadedIntegrations[this.integrationToBeEnabled].id:null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.integrationId,e&&(this.emitError(e.data.errorResponse,(0,a.getIntegrationTypeName)(this._getIntegration(r))),this.setModalState({...this.modalState,connectionError:e.data.errorResponse})),console.error("Failed to connect account to Paragon over OAuth",i)}async sendConnectRequest(t,e){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];var i;if(!this.userState.authenticated||!this.projectId)throw new Error("Connect SDK attempted to make an API request, but no user was authenticated.\nCall paragon.authenticate(<projectId>, <user token>) before using the SDK.");const r=`${null!==(i=null==e?void 0:e.baseURLOverride)&&void 0!==i?i:this.environments.ZEUS_PUBLIC_URL}${n?`/projects/${this.projectId}`:""}${t}`,o=(0,f.hash)(JSON.stringify({url:r,payload:{...e}})),s=await this.cachedApiResponse.get(o,!0);if((null==e?void 0:e.cacheResult)&&s)return s;const a=Boolean(!e||"GET"===e.method||e.cacheResult);if(a&&"object"==typeof this.keyToRequestPromiseMap[o])return this.keyToRequestPromiseMap[o];const l=this.userState.token,d=this.modalState.integration&&this.integrationToBeEnabled?this.userState.integrations[this.integrationToBeEnabled]:void 0,c=new Promise(((t,n)=>{(async()=>{try{const n=await this.sendRequest(r,{...e,headers:{Accept:"application/json","Content-Type":"application/json",...(null==d?void 0:d.credentialId)?{[u.SELECTED_CREDENTIAL_ID_HEADER]:null==d?void 0:d.credentialId}:{},...null==e?void 0:e.headers,Authorization:`Bearer ${l}`}},a?o:void 0);t(n)}catch(t){n(t)}})()}));return a&&(this.keyToRequestPromiseMap[o]=c),c}async sendRequest(t,e,n){var i;let r,o,s;try{r=await fetch(t,e)}catch(t){s=t}if(r&&!r.ok||s){const e=r?await(0,p.getErrorMessage)(r,!0):null==s?void 0:s.message,o="string"==typeof e?e:null==e?void 0:e.message,a=(0,p.errorMessageParser)(o),l=401===(null==r?void 0:r.status)||403===(null==r?void 0:r.status);if(a||t.includes("proxy")||!l){if(!a&&t.includes("proxy")&&l){const t=await this.fetchUserData();this.updateAuthenticatedUser({integrations:t.integrations,meta:t.meta,resources:t.resources})}}else this.logout();if(n&&(await this.cachedApiResponse.del(n),delete this.keyToRequestPromiseMap[n]),"string"!=typeof e&&t.includes("proxy"))throw null===(i=e.response)||void 0===i||delete i.headers,new p.ProxyRequestError(e.message,e.response);throw new Error(o)}try{o=await(null==r?void 0:r.json())}catch{o=void 0}return n&&(await this.cachedApiResponse.set(n,o),delete this.keyToRequestPromiseMap[n]),o}async request(t,e,n){var i,r;let o=`/sdk/proxy/${t}`;(0,a.isCustomIntegrationTypeName)(t)&&(o=`/sdk/proxy/custom/${null===(i=Object.values(this.loadedIntegrations).find((e=>!!e.customIntegration&&e.customIntegration.slug===t)))||void 0===i?void 0:i.id}`);const s=e.startsWith("/")?e:`/${e}`,l=n.selectedCredentialId?n.selectedCredentialId:null===(r=this.userState.integrations[t])||void 0===r?void 0:r.credentialId,d=await this.sendConnectRequest(`${o}${s}`,{method:n.method,body:"object"==typeof n.body?JSON.stringify(n.body):n.body,headers:{"Content-Type":u.INFER_CONTENT_TYPE_FROM_CONNECT_OPTIONS,...l?{[u.SELECTED_CREDENTIAL_ID_HEADER]:l}:{},...n.headers},baseURLOverride:this.environments.WORKER_PROXY_PUBLIC_URL});return null==d?void 0:d.output}async event(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{selectedConfigurationId:i,selectedCredentialId:r}=n;if(i&&!r||!i&&r)throw new Error("Both Configuration ID and Credential ID must either be provided together or not at all.");const o=this.getCredentialAndConfig({selectedConfigurationId:i,selectedCredentialId:r});await this.sendConnectRequest(`/v2/projects/${this.projectId}/sdk/events/trigger`,{method:"POST",headers:{...o?{[u.SELECTED_CREDENTIAL_ID_HEADER]:o.selectedCredential.id,[u.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:o.selectedConfig.id}:{}},body:JSON.stringify({name:t,payload:e})},!1)}onClose(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{integration:n,apiInstallationOptions:i}=this.modalState;n&&(this.triggerSDKEvent({type:u.SDK_EVENT.ON_PORTAL_CLOSE,integrationId:n.id,integrationType:(0,a.getIntegrationTypeName)(n)}),this.originalBodyOverflow!==e.PARAGON_OVERFLOW_EMPTY_VALUE&&(window.document.body.style.overflow=this.originalBodyOverflow,this.originalBodyOverflow=e.PARAGON_OVERFLOW_EMPTY_VALUE),!t&&(null==i?void 0:i.isApiInstallation)||(this.setModalState({integration:null}),this.integrationToBeEnabled=void 0))}onOpen(){const{integration:t}=this.modalState;if(t&&(this.triggerSDKEvent({type:u.SDK_EVENT.ON_PORTAL_OPEN,integrationId:t.id,integrationType:(0,a.getIntegrationTypeName)(t)}),this.root&&this.originalBodyOverflow===e.PARAGON_OVERFLOW_EMPTY_VALUE)){const t=this.root.getBoundingClientRect();window.innerHeight<=t.height&&window.innerWidth<=t.width&&(this.originalBodyOverflow=window.document.body.style.overflow,window.document.body.style.overflow="hidden")}}triggerSDKEvent(t){this.triggerEvent(t,this.userState)}getIntegrationMetadata(t){const e=t=>{return{...t,icon:(e=t.icon,e.includes(".svg")?(null===(n=e.split(".svg"))||void 0===n?void 0:n[0])+".svg":e)};var e,n};if(t){const n=this.metadata[t];if(!n)throw new Error(`${t} is not a valid integration name`);return e(n)}return Object.values(this.metadata).map(e)}closePortal(){this.onClose(!0)}workflow(t){let{selectedCredentialId:e,selectedConfigurationId:n,body:i={},query:r={},headers:o={}}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var s;if(!t)throw new Error("workflowId is required.");const a=new URLSearchParams(r).toString(),l=this.getIntegrationForWorkflow(t),d=this.getCredentialAndConfig(e||n?{selectedCredentialId:e,selectedConfigurationId:n}:{selectedCredentialId:l.credentialId},l);if(!d||!(null===(s=d.selectedConfig.workflowSettings[t])||void 0===s?void 0:s.enabled))throw new Error(`Workflow ${t} is not enabled for this user.`);return this.sendConnectRequest(`/sdk/triggers/${t}?${a}`,{method:"POST",body:JSON.stringify(i),headers:{[u.SELECTED_CREDENTIAL_ID_HEADER]:d.selectedCredential.id,[u.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:d.selectedConfig.id,...o}},!0)}installIntegration(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.userState.authenticated)throw new Error("User not authenticated, Call paragon.authenticate(<projectId>, <user token>) before using the SDK.");const n={showPortalAfterInstall:!1,bypassPostOAuthPrompt:!1,allowMultipleCredentials:!1,...e,isApiInstallation:!0};if(n.bypassPostOAuthPrompt&&n.showPortalAfterInstall)throw new Error("Could not use both `bypassPostOAuthPrompt` and `showPortalAfterInstall` as true at the same time.");if(this.ensureHeadlessIsSupported(),this.validateAction(t),!n.allowMultipleCredentials&&this.isAlreadyInstalled(t,this.userState))throw new Error(`Integration "${t}" is already installed.`);return this.setModalState({integration:null}),this.connect(t,n)}ensureHeadlessIsSupported(){if(!this.project.accessibleFeatures.includes(u.ConnectAddOn.HeadlessConnectPortal))throw new Error("Headless Connect Portal is available on our Pro plan and above. Contact sales@useparagon.com to learn more or upgrade.")}async uninstallIntegration(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=null==e?void 0:e.selectedCredentialId;if(!this.userState.authenticated)throw new Error("User not authenticated, Call paragon.authenticate(<projectId>, <user token>) before using the SDK.");if(this.ensureHeadlessIsSupported(),this.validateAction(t),!this.isAlreadyInstalled(t,this.userState,e.selectedCredentialId))throw new Error(`Integration "${t}" is not installed.`);const i=this.loadedIntegrations[t].id,r=this.userState.integrations[t],o=n||(null==r?void 0:r.credentialId);if(!o||!r)throw new Error("No credential found for uninstall");await this.sendConnectRequest(`/sdk/integrations/${i}`,{method:"DELETE",headers:{...o?{[u.SELECTED_CREDENTIAL_ID_HEADER]:o}:{}}}),this.updateAuthenticatedUser({integrations:{...this.userState.integrations,[t]:(0,l.getActionStateForCredentialDelete)(o,r)}}),n===this.modalState.selectedCredentialId&&this.setModalState({integration:null,selectedCredentialId:void 0}),this.saveState(),this.triggerSDKEvent({type:u.SDK_EVENT.ON_INTEGRATION_UNINSTALL,integrationId:i,integrationType:t})}async disableWorkflow(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n;const{selectedCredentialId:i,selectedConfigurationId:r}=e,o=this.getIntegrationForWorkflow(t),s=this.getCredentialAndConfig(i||r?{selectedCredentialId:i,selectedConfigurationId:r}:{selectedCredentialId:o.credentialId},o);if(!s||!(null===(n=s.selectedConfig.workflowSettings[t])||void 0===n?void 0:n.enabled))throw new Error(`Workflow ${t} cannot be disabled for this user.`);await this.sendConnectRequest(`/sdk/workflows/${t}`,{method:"DELETE",headers:{[u.SELECTED_CREDENTIAL_ID_HEADER]:s.selectedCredential.id,[u.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:s.selectedConfig.id}}),await this.updateLocalState()}async enableWorkflow(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n;const{selectedCredentialId:i,selectedConfigurationId:r}=e,s=this.getIntegrationForWorkflow(t),a=this.getCredentialAndConfig(i||r?{selectedCredentialId:i,selectedConfigurationId:r}:{selectedCredentialId:s.credentialId},s);if(!a||(null==a?void 0:a.selectedCredential.status)!==o.CredentialStatus.VALID)throw new Error("Valid credential not found for provided options.");const{selectedConfig:l,selectedCredential:d}=a;if(null===(n=l.workflowSettings[t])||void 0===n?void 0:n.enabled)throw new Error(`Workflow ${t} is already enabled for this user.`);await this.sendConnectRequest(`/sdk/workflows/${t}`,{method:"POST",headers:{[u.SELECTED_CREDENTIAL_ID_HEADER]:d.id,[u.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:l.id}}),await this.updateLocalState()}async getIntegrationAccount(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n;this.validateAction(t);const i=null===(n=this.userState.integrations[t])||void 0===n?void 0:n.allCredentials;if(!(null==i?void 0:i.length))throw new Error("Connect credential not found");const r=await this.sendConnectRequest(`/sdk/credentials?integration=${t}&includeAccountAuth=${e.includeAccountAuth}`,{method:"GET",headers:e.selectedCredentialId?{[u.SELECTED_CREDENTIAL_ID_HEADER]:e.selectedCredentialId}:{}});if(!r)throw new Error("Integration not connected");return r}getIntegrationForWorkflow(t){if(!this.userState.authenticated)throw new Error("User not authenticated, Call paragon.authenticate(<projectId>, <user token>) before using the SDK.");const e=Object.values(this.loadedIntegrations).find((e=>{const n=e.configs[0].values;return t in(n.workflowMeta||{})}));if(!e)throw new Error("Workflow not found in the configured integrations in your Paragon project.");const n=(0,a.getIntegrationTypeName)(e)?this.userState.integrations[(0,a.getIntegrationTypeName)(e)]:void 0;if(!n||!n.allCredentials.some((t=>{let{status:e}=t;return e===o.CredentialStatus.VALID})))throw new Error(`Integration "${(0,a.getIntegrationTypeName)(e)}" not enabled for workflow."`);return n}async updateLocalState(){var t;const[e,n]=await Promise.all([this.fetchUserData(),this.fetchIntegrations()]);let i={...e.integrations};if(this.modalState.integration&&this.integrationToBeEnabled){const e=this.userState.integrations[this.integrationToBeEnabled],n=e?null===(t=i[this.integrationToBeEnabled])||void 0===t?void 0:t.allConfigurations.find((t=>{let{id:n}=t;return n===e.credentialConfigId})):void 0;n&&(i={...i,[this.integrationToBeEnabled]:{enabled:!1,allConfigurations:[],allCredentials:[],...i[this.integrationToBeEnabled],credentialConfigId:n.id,workflowSettings:n.workflowSettings,configuredWorkflows:n.workflowSettings,sharedSettings:n.sharedSettings,configMeta:n.configMeta}})}this.updateAuthenticatedUser({integrations:i,meta:e.meta,resources:e.resources}),this.updateIntegrations(n),this.saveState()}async fetchUserData(){const t=await this.sendConnectRequest("/sdk/me");if(!t)throw new Error("Unable to get user Data");return{...t,integrations:Object.fromEntries(Object.entries(t.integrations).map((t=>{let[e,n]=t;const i=n.allCredentials.flatMap((t=>{let{configurations:e}=t;return e}));return[e,{...n,allConfigurations:i}]})))}}async fetchIntegrations(){const t=await this.sendConnectRequest("/sdk/integrations");if(!t)throw new Error("Unable to fetch integrations");return t}updateIntegrations(t){t.forEach((t=>{var e,n,i;if(t.configs.length)try{const r=(0,a.getIntegrationTypeName)(t);this.loadedConfigs[r]=t.configs[0].values,this.loadedIntegrations[r]=t,Boolean(t.isActive)&&(this.metadata[r]={type:r,name:t.name,brandColor:t.brandColor,icon:null!==(n=null===(e=t.customIntegration)||void 0===e?void 0:e.icon)&&void 0!==n?n:`${this.environments.CDN_PUBLIC_URL}/integrations/${u.overrideActionAlias[t.type]||t.type}.svg`}),(null===(i=this.modalState.integration)||void 0===i?void 0:i.id)===t.id&&this.setModalState({integration:t})}catch(t){console.warn(t)}}))}async setUserMetadata(t){return await this.sendConnectRequest("/sdk/me",{method:"PATCH",body:JSON.stringify({meta:t})}),await this.updateLocalState(),this.render(),this.userState}configureGlobal(t,e){var n,i,r,o,s,a;if(!t||!t.host)throw new Error("host not specified");const l=t.host.indexOf("http")>-1?new URL(t.host).hostname:t.host;this.environments.CONNECT_PUBLIC_URL=null!==(n=null==e?void 0:e.CONNECT_PUBLIC_URL)&&void 0!==n?n:(0,p.getServiceUrl)("connect",l),this.environments.DASHBOARD_PUBLIC_URL=null!==(i=null==e?void 0:e.DASHBOARD_PUBLIC_URL)&&void 0!==i?i:(0,p.getServiceUrl)("dashboard",l),this.environments.PASSPORT_PUBLIC_URL=null!==(r=null==e?void 0:e.PASSPORT_PUBLIC_URL)&&void 0!==r?r:(0,p.getServiceUrl)("passport",l),this.environments.ZEUS_PUBLIC_URL=null!==(o=null==e?void 0:e.ZEUS_PUBLIC_URL)&&void 0!==o?o:(0,p.getServiceUrl)("zeus",l),this.environments.CDN_PUBLIC_URL=null!==(s=null==e?void 0:e.CDN_PUBLIC_URL)&&void 0!==s?s:(0,p.getServiceUrl)("dashboard",l),this.environments.WORKER_PROXY_PUBLIC_URL=null!==(a=null==e?void 0:e.WORKER_PROXY_PUBLIC_URL)&&void 0!==a?a:(0,p.getServiceUrl)("proxy",l),this.userState.authenticated=!1,this.root?this.root.src=`${this.environments.CONNECT_PUBLIC_URL}/ui${this.projectId?`?projectId=${this.projectId}`:""}`:console.error("Root element not defined")}async completeInstall(t,e){var n;if(!this.userState.authenticated)throw new Error("Authentication is required");if(!e||!e.authorizationCode)throw new Error("authorizationCode is required");if(e.redirectUrl&&!(0,p.isValidUrl)(e.redirectUrl))throw new Error(`${e.redirectUrl} is not valid url`);this.validateAction(t);const i=Object.values(this.loadedIntegrations).find((e=>(0,a.getIntegrationTypeName)(e)===t)),r=null===(n=e.showPortalAfterInstall)||void 0===n||n,o=await this.sendConnectRequest("/sdk/credentials",{method:"POST",body:JSON.stringify({code:e.authorizationCode,integrationId:i.id,redirectUrl:e.redirectUrl?(0,p.sanitizeUrl)(e.redirectUrl):void 0,integrationOptions:e.integrationOptions||{}})});if(!o)throw new Error("Unable to create credential");this.updateCredentialData(o,i),r&&this.setModalState({integration:i,config:this.loadedConfigs[t],apiInstallationOptions:{}})}updateCredentialData(t,e){var n,i,r,s,l,d;const c=this.userState,u=(0,a.getIntegrationTypeName)(e),h=c.integrations[u],f=h.allCredentials.findIndex((e=>e.id===t.id));f>-1?h.allCredentials[f]=t:h.allCredentials.push(t);const g=Object.fromEntries((h.allConfigurations||[]).concat(t.configurations).map((t=>[t.id,t])));this.updateAuthenticatedUser({integrations:{...c.integrations,[u]:{...h,allConfigurations:Object.values(g),credentialStatus:t.status,enabled:t.status===o.CredentialStatus.VALID,credentialId:t.id,providerId:t.providerId,providerData:t.providerData,configMeta:null===(n=t.configurations[0])||void 0===n?void 0:n.configMeta,credentialConfigId:null===(i=t.configurations[0])||void 0===i?void 0:i.id,externalId:null===(r=t.configurations[0])||void 0===r?void 0:r.externalId,sharedSettings:null===(s=t.configurations[0])||void 0===s?void 0:s.sharedSettings,workflowSettings:null===(l=t.configurations[0])||void 0===l?void 0:l.workflowSettings,configuredWorkflows:null===(d=t.configurations[0])||void 0===d?void 0:d.workflowSettings}}})}async connectAction(t,e){var n;if(!this.userState.authenticated)throw new Error("User not authenticated, Call paragon.authenticate(<projectId>, <user token>) before using the SDK.");const i=null===(n=this.userState.resources.find((e=>t===e.slug)))||void 0===n?void 0:n.id;if(!i)throw new Error(`No resource found with name "${t}".`);if(!e||"object"!=typeof e)throw new Error("payload must be of type object.");const r=await this.sendConnectRequest(`/sdk/resources/${i}/connect`,{method:"POST",body:JSON.stringify(e)});if(!r)throw new Error(`Unable to connect to "${t}".`);return r}async createConfiguration(t){let{credentialId:e,externalId:n}=t;var i,r;if(!this.userState.authenticated)throw new Error("User not authenticated, Call paragon.authenticate(<projectId>, <user token>) before using the SDK.");if(!e)throw new Error('Required options not provided: "credentialId"');const s=this.getCredentialAndConfig({selectedCredentialId:e});if(!s||(null==s?void 0:s.selectedCredential.status)!==o.CredentialStatus.VALID)throw new Error("Valid credential not found for provided options.");const a=await this.sendConnectRequest(`/sdk/credentials/${e}/configurations`,{method:"POST",body:JSON.stringify(n?{externalId:n}:{})});if(!a)throw new Error("Unable to create a configuration for credential.");const l=Object.keys(this.userState.integrations).find((t=>{var e;return null===(e=this.userState.integrations[t])||void 0===e?void 0:e.allCredentials.find((t=>{let{id:e}=t;return e===a.id}))}));if(l){const t=null===(i=this.userState.integrations[l])||void 0===i?void 0:i.allConfigurations.filter((t=>{let{connectCredentialId:e}=t;return e!==a.id})).concat(a.configurations),e=null===(r=this.userState.integrations[l])||void 0===r?void 0:r.allCredentials.map((t=>t.id===a.id?a:t)),n={...this.userState.integrations,[l]:{enabled:!1,...this.userState.integrations[l],allConfigurations:t||[],allCredentials:e||[]}};this.updateAuthenticatedUser({integrations:n})}return a.configurations.sort(((t,e)=>new Date(e.dateCreated).getTime()-new Date(t.dateCreated).getTime()))[0]}async destroyConfiguration(t){let{id:e,credentialId:n}=t;var i,r,o,s;if(!this.userState.authenticated)throw new Error("User not authenticated, Call paragon.authenticate(<projectId>, <user token>) before using the SDK.");if(!(null==e?void 0:e.trim())||!(null==n?void 0:n.trim()))throw new Error("One or more required options not provided.");const a=this.getCredentialAndConfig({selectedConfigurationId:e,selectedCredentialId:n});if(!a)throw new Error(`Unable to find credential for configuration: ${e}.`);if(a.selectedConfig.isDefault)throw new Error("Cannot delete default configuration.");await this.sendConnectRequest(`/sdk/credentials/${a.selectedCredential.id}/configurations`,{method:"DELETE",headers:{[u.SELECTED_CREDENTIAL_ID_HEADER]:null==a?void 0:a.selectedCredential.id,[u.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:null==a?void 0:a.selectedConfig.id}});const l=Object.keys(this.userState.integrations).find((t=>{var e;return null===(e=this.userState.integrations[t])||void 0===e?void 0:e.allCredentials.find((t=>{let{id:e}=t;return e===a.selectedCredential.id}))}));if(l){const{selectedConfig:t,selectedCredential:e}=a,n=null===(i=this.userState.integrations[l])||void 0===i?void 0:i.allConfigurations.filter((e=>{let{id:n}=e;return n!==t.id})),d=null===(r=this.userState.integrations[l])||void 0===r?void 0:r.allCredentials.map((n=>n.id!==e.id?n:{...n,configurations:n.configurations.filter((e=>{let{id:n}=e;return n!==t.id}))})),c={...this.userState.integrations,[l]:{enabled:!1,...this.userState.integrations[l],allConfigurations:n||[],allCredentials:d||[]}};this.updateAuthenticatedUser({integrations:c}),(null===(o=this.userState.integrations[l])||void 0===o?void 0:o.credentialId)===e.id&&(null===(s=this.userState.integrations[l])||void 0===s?void 0:s.credentialConfigId)===t.id&&this.closePortal()}}async updateConfiguration(t){let{id:e,credentialId:n,meta:i={}}=t;var r,o;if(!this.userState.authenticated)throw new Error("User not authenticated, Call paragon.authenticate(<projectId>, <user token>) before using the SDK.");if(!(null==e?void 0:e.trim())||!(null==n?void 0:n.trim()))throw new Error("One or more required options not provided.");const s=this.getCredentialAndConfig({selectedConfigurationId:e,selectedCredentialId:n});if(!(null==s?void 0:s.selectedConfig))throw new Error(`Cannot find credential configuration with given id: "${e}"`);const a=await this.sendConnectRequest(`/sdk/credentials/${s.selectedConfig.connectCredentialId}/configurations`,{method:"PATCH",body:JSON.stringify({meta:i}),headers:{[u.SELECTED_CREDENTIAL_ID_HEADER]:s.selectedCredential.id,[u.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:s.selectedConfig.id}});if(!a)throw new Error("Unable to update configuration.");const l=Object.keys(this.userState.integrations).find((t=>{var e;return null===(e=this.userState.integrations[t])||void 0===e?void 0:e.allCredentials.find((t=>{let{id:e}=t;return e===a.id}))}));if(l){const t=null===(r=this.userState.integrations[l])||void 0===r?void 0:r.allConfigurations.filter((t=>{let{connectCredentialId:e}=t;return e!==a.id})).concat(a.configurations),e=null===(o=this.userState.integrations[l])||void 0===o?void 0:o.allCredentials.map((t=>t.id===a.id?a:t)),n={...this.userState.integrations,[l]:{enabled:!1,...this.userState.integrations[l],allConfigurations:t||[],allCredentials:e||[]}};this.updateAuthenticatedUser({integrations:n})}const d=a.configurations.find((t=>{let{id:e}=t;return e===s.selectedConfig.id}));return d}async pollForCredential(t){const e=Date.now(),n=async()=>{try{return await this.sendConnectRequest(`/sdk/actions/session-id/${t}`,{method:"GET"})}catch(t){return console.error("error",t),null}};try{const t=await(0,g.tryUntil)(n,(function(t,n){return!((arguments.length>2&&void 0!==arguments[2]?arguments[2]:1)>=20||Date.now()-e>=d.MAX_POLL_DURATION||(null==t?void 0:t.connectCredentialId))}),d.CREDENTIAL_POLL_INTERVAL);t&&t.connectCredentialId&&this.updateLocalState()}catch(t){console.error("Error while connecting to integration",t)}finally{await this.sendConnectRequest(`/sdk/actions/session-id/${t}`,{method:"DELETE"})}}}e.default=C},892:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(821);e.default=class{constructor(){this.eventListenersMap={},this.integrationStateCallbacks={}}subscribe(t,e){var n;if(this.assertEventType(t),"function"!=typeof e)throw new Error(`no listener is provided for ${t}`);return this.eventListenersMap={...this.eventListenersMap,[t]:[...null!==(n=this.eventListenersMap[t])&&void 0!==n?n:[],e]},()=>this.unsubscribe(t,e)}subscribeToIntegration(t,e){this.integrationStateCallbacks[t]={...e}}unsubscribe(t,e){var n,i;if(this.assertEventType(t),"function"!=typeof e)throw new Error("listener is required for unsubscription");const r=(null!==(n=this.eventListenersMap[t])&&void 0!==n?n:[]).length;return this.eventListenersMap={...this.eventListenersMap,[t]:(null!==(i=this.eventListenersMap[t])&&void 0!==i?i:[]).filter((t=>t!==e))},r>this.eventListenersMap[t].length}assertEventType(t){if(!Object.values(i.SDK_EVENT).includes(t))throw new Error(`${t} is not valid paragon event`)}emitSafe(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];var r;(null!==(r=this.eventListenersMap[t])&&void 0!==r?r:[]).forEach((t=>{try{t(...n)}catch(t){console.error(t)}}))}emitError(t,e){this.invokeCallbackSafe(e,"onError",t)}invokeCallbackSafe(t,e){var n,i;try{for(var r=arguments.length,o=new Array(r>2?r-2:0),s=2;s<r;s++)o[s-2]=arguments[s];null===(i=null===(n=this.integrationStateCallbacks[t])||void 0===n?void 0:n[e])||void 0===i||i.call(n,...o)}catch(t){console.error(t)}}triggerEvent(t,e){let{type:n,integrationId:r,integrationType:o,workflowId:s,workflowStateChange:a}=t;if(r&&o)switch(n){case i.SDK_EVENT.ON_INTEGRATION_INSTALL:{const t=[{integrationId:r,integrationType:o},e];this.invokeCallbackSafe(o,"onInstall",...t),this.emitSafe(i.SDK_EVENT.ON_INTEGRATION_INSTALL,...t);break}case i.SDK_EVENT.ON_INTEGRATION_UNINSTALL:{const t=[{integrationId:r,integrationType:o},e];this.invokeCallbackSafe(o,"onUninstall",...t),this.emitSafe(i.SDK_EVENT.ON_INTEGRATION_UNINSTALL,...t);break}case i.SDK_EVENT.ON_PORTAL_OPEN:{const t=[{integrationId:r,integrationType:o},e];this.invokeCallbackSafe(o,"onOpen",...t),this.emitSafe(i.SDK_EVENT.ON_PORTAL_OPEN,...t);break}case i.SDK_EVENT.ON_PORTAL_CLOSE:{const t=[{integrationId:r,integrationType:o},e];this.invokeCallbackSafe(o,"onClose",...t),this.emitSafe(i.SDK_EVENT.ON_PORTAL_CLOSE,...t);break}case i.SDK_EVENT.ON_WORKFLOW_CHANGE:{const t=[{integrationId:r,workflowId:s,workflowStateChange:a||{}},e];this.invokeCallbackSafe(o,"onWorkflowChange",...t),this.emitSafe(i.SDK_EVENT.ON_WORKFLOW_CHANGE,...t);break}default:throw new Error(`${n} is not valid event.`)}}}},931:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ACTION_CUSTOM=void 0,e.ACTION_CUSTOM="custom"},59:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CredentialStatus=void 0,function(t){t.PENDING="PENDING",t.INVALID="INVALID",t.VALID="VALID"}(e.CredentialStatus||(e.CredentialStatus={}))},745:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AuthenticationScheme=void 0,function(t){t.BASIC="basic",t.OAUTH="oauth",t.OAUTH_CLIENT_CREDENTIAL="oauth_client_credential",t.SERVICE_ACCOUNT="service_account",t.OAUTH_APP="oauth_app",t.IMPERSONATED_APP="impersonated_app"}(e.AuthenticationScheme||(e.AuthenticationScheme={}))},663:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.generateSlugForIntegration=void 0,e.generateSlugForIntegration=function(t){if(!t.name)return;return`custom.${t.name?t.name.replace(/[\W_]+/g,"").trim().toLowerCase():void 0}`}},343:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isCustomIntegrationTypeName=e.getIntegrationTypeName=void 0;const i=n(931),r=n(663);e.getIntegrationTypeName=function(t){if(t.type===i.ACTION_CUSTOM){if(t.customIntegration)return(0,r.generateSlugForIntegration)(t.customIntegration);throw new Error(`Custom integration details are missing from this integration: ${t.id}`)}return t.type},e.isCustomIntegrationTypeName=function(t){return t.startsWith("custom.")}},950:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GoogleDriveFilePicker=void 0;const i=n(821),r=n(473);class o extends r.BaseFilePicker{constructor(t,e){super(t,e),this.accessToken=""}get google(){return window.google}getInstance(){var t;return null!==(t=this.instance)&&void 0!==t?t:null}open(){var t,e;return!(this.dependencyStatus!==i.FilePickerStatus.LOADED||!this.instance)&&(this.instance.setVisible(!0),null===(e=(t=this.options).onOpen)||void 0===e||e.call(t),!0)}async init(t){this.dependencyStatus=i.FilePickerStatus.LOADING,await this.validateInitOptions(t),this.initOptions={...t};const e=await this.connectSDKInstance.getIntegrationAccount("googledrive",{includeAccountAuth:!0});return this.accessToken=e.accountAuth[i.AUTH_TOKEN_ALLOWED_INTEGRATIONS.googledrive.accessTokenPath],this.initialiseDependencyPromise(),this.injectScript("https://apis.google.com/js/api.js"),this.dependenciesPromise}onScriptLoaded(){this.dependencyStatus=i.FilePickerStatus.LOADED,window.gapi.load("picker",this.onPickerLoaded.bind(this))}onScriptError(){this.dependencyStatus=i.FilePickerStatus.FAILED,this.dependenciesPromise.reject(new Error("Not able to load dependencies"))}onPickerLoaded(){const t=new this.google.picker.PickerBuilder,e=new this.google.picker.DocsView;this.options.allowMultiSelect&&t.enableFeature(this.google.picker.Feature.MULTISELECT_ENABLED),this.options.allowFolderSelect&&(e.setIncludeFolders(!0),e.setSelectFolderEnabled(!0)),this.options.allowedTypes&&this.options.allowedTypes.length>0&&e.setMimeTypes(this.options.allowedTypes.join(",")),this.instance=t.addView(e).setOAuthToken(this.accessToken).setDeveloperKey(this.initOptions.developerKey).setCallback(this.pickerCallback.bind(this)).build(),this.dependenciesPromise.resolve(!0)}pickerCallback(t){var e,n,i,r,o,s;const{action:a,...l}=t;switch(a){case this.google.picker.Action.PICKED:null===(n=(e=this.options).onFileSelect)||void 0===n||n.call(e,l),null===(r=(i=this.options).onClose)||void 0===r||r.call(i);break;case this.google.picker.Action.CANCEL:null===(s=(o=this.options).onCancel)||void 0===s||s.call(o)}}}e.GoogleDriveFilePicker=o},698:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(950);e.default={GoogleDriveFilePicker:i.GoogleDriveFilePicker}},473:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BaseFilePicker=void 0;const i=n(643),r=n(572);e.BaseFilePicker=class{constructor(t,e){this.options=t,this.connectSDKInstance=e}initialiseDependencyPromise(){this.dependenciesPromise=new r.DeferredPromise}getInstance(){return this.instance}injectScript(t){if(this.checkIfScriptLoaded(t))this.onScriptLoaded();else{const e=document.createElement("script");e.src=t,e.async=!0,e.id=t,e.onload=this.onScriptLoaded.bind(this),e.onerror=this.onScriptError.bind(this),document.body.appendChild(e)}}checkIfScriptLoaded(t){const e=document.getElementsByTagName("script");for(let n=0;n<e.length;n++)if(e[n].getAttribute("src")==t)return!0;return!1}async validateInitOptions(t){if(!t||(0,i.isStringEmpty)(t.developerKey))throw new Error("Please provide a valid developer key");return!0}}},731:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.buildExternalFilePickerInstance=void 0;const i=n(655).__importDefault(n(698));class r{constructor(t,e,n){let r;if("googledrive"!==t)throw new Error(`${t}'s file picker is not supported`);r=new i.default.GoogleDriveFilePicker(e,n),this.open=this.open.bind(r),this.init=this.init.bind(r),this.getInstance=this.getInstance.bind(r)}open(){return this.open()}init(t){return this.init(t)}getInstance(){return this.getInstance()}}e.default=r;e.buildExternalFilePickerInstance=t=>function(e,n){if(!t.getUser().authenticated)throw new Error("Authentication is required");if(!e)throw new Error("Missing argument: Integration type is required");return t.validateAction(e),new r(e,n,t)}},50:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.buildExternalFilePickerInstance=e.ExternalFilePicker=void 0;var r=n(731);Object.defineProperty(e,"ExternalFilePicker",{enumerable:!0,get:function(){return i(r).default}}),Object.defineProperty(e,"buildExternalFilePickerInstance",{enumerable:!0,get:function(){return r.buildExternalFilePickerInstance}})},643:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isStringEmpty=e.getActionStateForCredentialDelete=e.stripUndefinedAndNull=e.parseKeyedSource=void 0;const i=n(59);e.parseKeyedSource=function(t){return t&&(null==t?void 0:t.length)?Object.fromEntries(t.map((t=>[t.key,"VALUE"===t.source.type?t.source.value:void 0]))):{}},e.stripUndefinedAndNull=function t(e){const n={};return Object.keys(e).forEach((i=>{var r;(r=e[i])&&"object"==typeof r&&!Array.isArray(r)?n[i]=t(e[i]):void 0!==e[i]&&null!==e[i]&&(n[i]=e[i])})),n};e.getActionStateForCredentialDelete=(t,e)=>{var n;const r=(null!==(n=null==e?void 0:e.allCredentials)&&void 0!==n?n:[]).filter((e=>e.id!==t));if(0===r.length)return{enabled:!1,workflowSettings:{},allCredentials:[],allConfigurations:[]};{const t=r[0];return{...e,credentialStatus:t.status,enabled:t.status===i.CredentialStatus.VALID,credentialId:t.id,providerId:t.providerId,providerData:t.providerData,allCredentials:r}}};e.isStringEmpty=t=>!t||"string"==typeof t&&!t.trim()},429:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.startOAuthFlow=e.MAX_POLL_DURATION=e.CREDENTIAL_POLL_INTERVAL=void 0;const i=n(931),r=n(343),o=n(643);e.CREDENTIAL_POLL_INTERVAL=3e3,e.MAX_POLL_DURATION=6e4;e.startOAuthFlow=(t,e)=>{let{context:n,integration:s,endUserSuppliedValues:a={},authParams:l,isPreviewMode:d=!1,installOptions:c={}}=t;var u;const h=(0,r.getIntegrationTypeName)(s);if(!h)return;const f=l?(0,o.parseKeyedSource)(l):{},g=(0,o.stripUndefinedAndNull)({action:h&&(0,r.isCustomIntegrationTypeName)(h)?i.ACTION_CUSTOM:h,endUserSuppliedValues:JSON.stringify(a),parameters:JSON.stringify(f),userToken:n.user.token,integrationId:s.id,redirectUrl:null===(u=n.endUserIntegrationConfig)||void 0===u?void 0:u.overrideRedirectUrl,originForPostMessage:window.location.origin,isPreviewMode:d,installOptions:JSON.stringify(c),sessionId:e}),p=`${n.environments.ZEUS_PUBLIC_URL}/projects/${n.projectId}/sdk/actions/build-oauth?${new URLSearchParams(g).toString()}`;return window.open(p,void 0,"width=500,height=600,left=100,top=150")}},56:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.paragon=e.connectSingleton=void 0;const i=n(655),r=i.__importDefault(n(773)),o=n(50);i.__exportStar(n(821),e),e.connectSingleton=new r.default,e.paragon={authenticate:e.connectSingleton.authenticate.bind(e.connectSingleton),connect:e.connectSingleton.connect.bind(e.connectSingleton),closePortal:e.connectSingleton.closePortal.bind(e.connectSingleton),event:e.connectSingleton.event.bind(e.connectSingleton),getIntegrationMetadata:e.connectSingleton.getIntegrationMetadata.bind(e.connectSingleton),getUser:e.connectSingleton.getUser.bind(e.connectSingleton),request:e.connectSingleton.request.bind(e.connectSingleton),subscribe:e.connectSingleton.subscribe.bind(e.connectSingleton),unsubscribe:e.connectSingleton.unsubscribe.bind(e.connectSingleton),workflow:e.connectSingleton.workflow.bind(e.connectSingleton),_oauthCallback:e.connectSingleton._oauthCallback.bind(e.connectSingleton),_oauthErrorCallback:e.connectSingleton._oauthErrorCallback.bind(e.connectSingleton),installIntegration:e.connectSingleton.installIntegration.bind(e.connectSingleton),uninstallIntegration:e.connectSingleton.uninstallIntegration.bind(e.connectSingleton),disableWorkflow:e.connectSingleton.disableWorkflow.bind(e.connectSingleton),enableWorkflow:e.connectSingleton.enableWorkflow.bind(e.connectSingleton),getIntegrationAccount:e.connectSingleton.getIntegrationAccount.bind(e.connectSingleton),setUserMetadata:e.connectSingleton.setUserMetadata.bind(e.connectSingleton),configureGlobal:e.connectSingleton.configureGlobal.bind(e.connectSingleton),completeInstall:e.connectSingleton.completeInstall.bind(e.connectSingleton),connectAction:e.connectSingleton.connectAction.bind(e.connectSingleton),createConfiguration:e.connectSingleton.createConfiguration.bind(e.connectSingleton),destroyConfiguration:e.connectSingleton.destroyConfiguration.bind(e.connectSingleton),updateConfiguration:e.connectSingleton.updateConfiguration.bind(e.connectSingleton),ExternalFilePicker:(0,o.buildExternalFilePickerInstance)(e.connectSingleton)},e.default=r.default},992:(t,e)=>{"use strict";var n,i,r;Object.defineProperty(e,"__esModule",{value:!0}),e.AUTH_TOKEN_ALLOWED_INTEGRATIONS=e.overrideActionAlias=e.TokenType=e.SidebarInputType=void 0,function(t){t.Auth="AUTH",t.Enum="ENUM",t.DynamicEnum="DYNAMIC_ENUM",t.Intent="INTENT",t.Text="TEXT",t.TextArea="TEXTAREA",t.ValueText="TEXT_NO_VARS",t.ValueTextArea="TEXTAREA_NO_VARS",t.Code="CODE",t.ActionButton="ACTION_BUTTON",t.Conditional="CONDITIONAL",t.DynamicConditional="DYNAMIC_CONDITIONAL",t.NestedList="NESTED_LIST",t.File="FILE",t.EditableDynamicEnum="EDITABLE_DYNAMIC_ENUM",t.EditableEnum="EDITABLE_ENUM",t.BooleanInput="BOOLEAN_INPUT",t.UserSuppliedCredential="USER_SUPPLIED_CREDENTIAL",t.NativeDynamicEnumInput="NATIVE_DYNAMIC_INPUT",t.TimeConstraintInput="TIME_CONSTRAINT_INPUT",t.LinesListInput="LinesListInput",t.LinesListDynamicInput="LinesListDynamicInput",t.Number="NUMBER",t.Email="EMAIL",t.URL="URL",t.EnumTextAreaPairInput="EnumTextAreaPairInput",t.FieldMapper="FIELD_MAPPER",t.ComboInput="COMBO_INPUT",t.Password="PASSWORD",t.Switch="SWITCH"}(e.SidebarInputType||(e.SidebarInputType={})),function(t){t.ACCESS_TOKEN="ACCESS_TOKEN",t.REFRESH_TOKEN="REFRESH_TOKEN",t.BOT_TOKEN="BOT_TOKEN",t.KLAVIYO_API_KEY="KLAVIYO_API_KEY",t.MARKETO_CLIENT_ID="MARKETO_CLIENT_ID",t.MARKETO_CLIENT_SECRET="MARKETO_CLIENT_SECRETI",t.MARKETO_ENDPOINT="MARKETO_ENDPOINT",t.MARKETO_IDENTITY="MARKETO_IDENTITY",t.MONDAY_API_TOKEN="MONDAY_API_TOKEN",t.ORACLE_CLOUD_URL="ORACLE_CLOUD_URL",t.ORACLE_PASSWORD="ORACLE_PASSWORD",t.ORACLE_USERNAME="ORACLE_USERNAME",t.SAGE_INTACCT_COMPANY_ID="SAGE_INTACCT_COMPANY_ID",t.SAGE_INTACCT_USER_ID="SAGE_INTACCT_USER_ID",t.SAGE_INTACCT_USER_PASSWORD="SAGE_INTACCT_USER_PASSWORD",t.SAILTHRU_COMPANY_KEY="SAILTHRU_COMPANY_KEY",t.SAILTHRU_COMPANY_SECRET="SAILTHRU_COMPANY_SECRET",t.SERVICENOW_PASSWORD="SERVICENOW_PASSWORD",t.SERVICENOW_SUBDOMAIN="SERVICENOW_SUBDOMAIN",t.SERVICENOW_USERNAME="SERVICENOW_USERNAME",t.TABLEAU_PERSONAL_ACCESS_TOKEN_NAME="TABLEAU_PERSONAL_ACCESS_TOKEN_NAME",t.TABLEAU_PERSONAL_ACCESS_TOKEN_SECRET="TABLEAU_PERSONAL_ACCESS_TOKEN_SECRET",t.TABLEAU_SERVER_NAME="TABLEAU_SERVER_NAME",t.TABLEAU_SITE_ID="TABLEAU_SITE_ID",t.TRELLO_API_KEY="TRELLO_API_KEY",t.TRELLO_API_TOKEN="TRELLO_API_TOKEN",t.WOOCOMMERCE_CONSUMER_KEY="WOOCOMMERCE_CONSUMER_KEY",t.WOOCOMMERCE_CONSUMER_SECRET="WOOCOMMERCE_CONSUMER_SECRET",t.WOOCOMMERCE_STORE_DOMAIN="WOOCOMMERCE_STORE_DOMAIN",t.WORKABLE_API_ACCESS_TOKEN="WORKABLE_API_ACCESS_TOKEN",t.WORKABLE_ACCOUNT_SUBDOMAIN="WORKABLE_ACCOUNT_SUBDOMAIN",t.ZOHO_CRM_ACCOUNTS_SERVER="ZOHO_CRM_ACCOUNTS_SERVER",t.ZOHO_CRM_API_DOMAIN="ZOHO_CRM_API_DOMAIN"}(e.TokenType||(e.TokenType={})),function(t){t.INFO="INFO",t.ERROR="ERROR",t.SUCCESS="SUCCESS"}(n||(n={})),function(t){t.NONE="NONE",t.RE_AUTHENTICATE="RE_AUTHENTICATE",t.ALERT="ALERT",t.DISPATCH="DISPATCH"}(i||(i={})),function(t){t.DYNAMIC="DYNAMIC_DATA_SOURCE",t.STATIC_ENUM="STATIC_ENUM_DATA_SOURCE",t.FIELD_MAPPER="FIELD_MAPPER_DATA_SOURCE",t.COMBO_INPUT="COMBO_INPUT_DATA_SOURCE"}(r||(r={})),e.overrideActionAlias={"monday.com":"monday","wordpress.com":"wordpress"},e.AUTH_TOKEN_ALLOWED_INTEGRATIONS={googledrive:{accessTokenPath:"OAUTH_ACCESS_TOKEN"}}},34:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONNECT_PLAN_FEATURE_MAP=void 0;const i=n(471);e.CONNECT_PLAN_FEATURE_MAP={[i.BillingPlan.ConnectBasic]:[],[i.BillingPlan.ConnectPro]:[i.ConnectAddOn.CustomIntegrationBuilder,i.ConnectAddOn.HeadlessConnectPortal,i.ConnectAddOn.Monitoring,i.ConnectAddOn.UserMetadata,i.ConnectAddOn.WhiteLabeling],[i.BillingPlan.ConnectEnterprise]:[i.ConnectAddOn.CustomIntegrationBuilder,i.ConnectAddOn.DynamicFieldMapper,i.ConnectAddOn.HeadlessConnectPortal,i.ConnectAddOn.TaskHistoryAPI,i.ConnectAddOn.Monitoring,i.ConnectAddOn.RoleBasedAccessControl,i.ConnectAddOn.UserMetadata,i.ConnectAddOn.WhiteLabeling,i.ConnectAddOn.WorkflowPermission]}},935:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SELECTED_CREDENTIAL_CONFIG_ID_HEADER=e.SELECTED_CREDENTIAL_ID_HEADER=e.INFER_CONTENT_TYPE_FROM_CONNECT_OPTIONS=void 0;const i=n(992);i.SidebarInputType.ValueText,i.SidebarInputType.DynamicEnum,i.SidebarInputType.Enum,i.SidebarInputType.Number,i.SidebarInputType.Email,i.SidebarInputType.URL,i.SidebarInputType.FieldMapper,i.SidebarInputType.BooleanInput,i.SidebarInputType.ComboInput,i.SidebarInputType.Password,i.SidebarInputType.Switch,i.SidebarInputType.ValueTextArea;e.INFER_CONTENT_TYPE_FROM_CONNECT_OPTIONS="auto",e.SELECTED_CREDENTIAL_ID_HEADER="X-Paragon-Credential",e.SELECTED_CREDENTIAL_CONFIG_ID_HEADER="X-Paragon-Configuration-Id"},977:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},914:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PLATFORM_ENV=e.NODE_ENV=void 0,function(t){t.PRODUCTION="production",t.DEVELOPMENT="development",t.TEST="test"}(e.NODE_ENV||(e.NODE_ENV={})),function(t){t.PRODUCTION="production",t.PRODUCTION_MIRROR_1="p-m1",t.STAGING="staging",t.STAGING_MIRROR_1="s-m1",t.DEVELOPMENT="dev",t.TEST="test",t.SANDBOX="sandbox",t.RELEASE="release",t.ENTERPRISE="enterprise"}(e.PLATFORM_ENV||(e.PLATFORM_ENV={}))},65:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},821:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(655);i.__exportStar(n(992),e),i.__exportStar(n(34),e),i.__exportStar(n(935),e),i.__exportStar(n(977),e),i.__exportStar(n(914),e),i.__exportStar(n(65),e),i.__exportStar(n(835),e),i.__exportStar(n(750),e),i.__exportStar(n(471),e)},835:(t,e)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.DataType=void 0,function(t){t.STRING="STRING",t.NUMBER="NUMBER",t.DATE="DATE",t.BOOLEAN="BOOLEAN",t.EMAIL="EMAIL",t.OBJECT="OBJECT",t.ARRAY="ARRAY",t.ANY="ANY",t.FILE="FILE",t.NON_DECIMAL="NON_DECIMAL"}(e.DataType||(e.DataType={})),function(t){t.None="$none",t.StringContains="$stringContains",t.StringDoesNotContain="$stringDoesNotContain",t.StringExactlyMatches="$stringExactlyMatches",t.StringDoesNotExactlyMatch="$stringDoesNotExactlyMatch",t.StringIsIn="$stringIsIn",t.StringIsNotIn="$stringIsNotIn",t.StringStartsWith="$stringStartsWith",t.StringDoesNotStartWith="$stringDoesNotStartWith",t.StringEndsWith="$stringEndsWith",t.StringDoesNotEndWith="$stringDoesNotEndWith",t.NumberGreaterThan="$numberGreaterThan",t.NumberLessThan="$numberLessThan",t.NumberEquals="$numberEquals",t.NumberDoesNotEqual="$numberDoesNotEqual",t.NumberLessThanOrEqualTo="$numberLessThanOrEqualTo",t.NumberGreaterThanOrEqualTo="$numberGreaterThanOrEqualTo",t.DateTimeAfter="$dateTimeAfter",t.DateTimeBefore="$dateTimeBefore",t.DateTimeEquals="$dateTimeEquals",t.BooleanTrue="$booleanTrue",t.BooleanFalse="$booleanFalse",t.IsNotNull="$exists",t.IsNull="$doesNotExist",t.Exists="$isNotUndefinedOrNull",t.DoesNotExist="$isUndefinedOrNull",t.ArrayIsIn="$arrayIsIn",t.ArrayIsNotIn="$arrayIsNotIn",t.ArrayIsEmpty="$arrayIsEmpty",t.ArrayIsNotEmpty="$arrayIsNotEmpty",t.StringGreaterThan="$stringGreaterThan",t.StringLessThan="$stringLessThan"}(n||(n={}))},750:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.FilePickerStatus=e.DocumentLoadingState=e.SDK_EVENT=e.ModalView=void 0,function(t){t.OVERVIEW="overview",t.CONFIGURATION="configuration"}(e.ModalView||(e.ModalView={})),function(t){t.ON_INTEGRATION_INSTALL="onIntegrationInstall",t.ON_INTEGRATION_UNINSTALL="onIntegrationUninstall",t.ON_WORKFLOW_CHANGE="onWorkflowChange",t.ON_PORTAL_OPEN="onPortalOpen",t.ON_PORTAL_CLOSE="onPortalClose"}(e.SDK_EVENT||(e.SDK_EVENT={})),function(t){t.LOADING="loading",t.INTERACTIVE="interactive",t.COMPLETE="complete"}(e.DocumentLoadingState||(e.DocumentLoadingState={})),function(t){t.LOADING="loading",t.FAILED="failed",t.LOADED="loaded"}(e.FilePickerStatus||(e.FilePickerStatus={}))},471:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ConnectAddOn=e.BillingPlan=void 0,function(t){t.ClassicFree="free",t.ClassicStarter="starter",t.ClassicBusiness="business",t.ClassicPremium="premium",t.ClassicEnterprise="enterprise",t.ConnectTrial="connect_trial",t.ConnectBasic="basic",t.ConnectPro="pro",t.ConnectEnterprise="connect_enterprise"}(e.BillingPlan||(e.BillingPlan={})),function(t){t.CustomIntegrationBuilder="byo",t.DynamicFieldMapper="dfm",t.HeadlessConnectPortal="headless-cp",t.TaskHistoryAPI="th-api",t.Monitoring="monitoring",t.RoleBasedAccessControl="rbac",t.UserMetadata="user-metadata",t.WhiteLabeling="whitelabel",t.WorkflowPermission="workflow-permissions"}(e.ConnectAddOn||(e.ConnectAddOn={}))},158:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sanitizeExternalConfigId=e.getAssetUrl=void 0;const i=n(914);e.getAssetUrl=t=>{let{CDN_PUBLIC_URL:e,DASHBOARD_PUBLIC_URL:n,VERSION:r,PLATFORM_ENV:o,NODE_ENV:s}=t;return e&&s===i.NODE_ENV.PRODUCTION&&o!==i.PLATFORM_ENV.ENTERPRISE?`${e}/${r}/dashboard/public`:n},e.sanitizeExternalConfigId=function(t){if(t.startsWith("ext:")){return(t.split("ext:").pop()||"").trim()}return t.trim()}},846:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.hash=void 0;const i=n(715);e.hash=function(t){return null==t?t:(0,i.sha256)().update(t).digest("hex").substr(0,10)}},572:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.tryUntil=e.isUUID=e.uuidPattern=e.sleep=e.generateMatrix=e.DeferredPromise=void 0;function n(t){return new Promise((e=>setTimeout(e,t)))}e.DeferredPromise=class{get state(){return this._state}constructor(){this._state="pending",this._promise=new Promise(((t,e)=>{this._resolve=t,this._reject=e}))}then(t,e){return this._promise.then(t,e)}catch(t){return this._promise.catch(t)}resolve(t){this._resolve(t),this._state="fulfilled"}reject(t){this._reject(t),this._state="rejected"}finally(t){return null==t||t(),this._promise}},Symbol.toStringTag,e.generateMatrix=function(t,e){const n=Object.keys(t);if(n.reduce(((e,n)=>e+t[n].length),0)&&n.length)for(const e of n)t[e].length||t[e].push(void 0);const i=Object.entries(t).reduce(((t,e)=>{let[,n]=e;return t.length?t.reduce(((t,e)=>(n.forEach((n=>{const i=e.slice();i.push(n),t.push(i)}),[]),t)),[]):n.map((t=>[t]))}),[]).reduce(((t,e)=>{const i=e.reduce(((t,e,i)=>({...t,[n[i]]:e})),{});return[...t,i]}),[]);return e?i.slice(-1*e):i},e.sleep=n,e.uuidPattern=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i,e.isUUID=function(t){return"string"==typeof t&&e.uuidPattern.test(t)},e.tryUntil=async function(t,e,i){let r=0,o=!0;for(;o;){r+=1;let s=null,a=null;try{s=await t()}catch(t){a=t}if(o=await e(s,a,r),!o){if(a)throw a;return s}{const t="number"==typeof i?i:i(r);await n(t)}}throw new Error("Method unable to run: invalid retries.")}},321:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.errorMessageParser=e.isIntegrationError=e.ProxyRequestError=e.getErrorMessage=e.getServiceUrl=e.sanitizeUrl=e.isValidUrl=void 0;function n(t){return t?t.match(/^[a-zA-Z]+:\/\//)?t:`https://${t}`:t}function i(t){return Array.isArray(t)?t.flatMap((t=>[t,i(t.children||[])].flatMap((t=>"string"==typeof t?t:i(t))))).filter((t=>t)).join(", "):Object.values(t.constraints||{}).join(", ")}e.isValidUrl=t=>{const e=n(t);try{return new globalThis.URL(e),!0}catch(t){return!1}},e.sanitizeUrl=n,e.getServiceUrl=function(t,e){return`https://${t}${`.${e}`}`},e.getErrorMessage=async function(t,n){var r,o;const s=null===(r=t.headers)||void 0===r?void 0:r.get("content-type"),a=s&&s.includes("application/json")?await t.json():null;let l;return l=a&&(0,e.isIntegrationError)(a.meta)?JSON.stringify(a.meta):a&&"string"==typeof a.message?a.message:a&&400===t.status&&Array.isArray(a.message)?i(a.message):a?JSON.stringify(a):await(null===(o=t.text)||void 0===o?void 0:o.call(t)),n?{message:l,response:a||t}:l};class r extends Error{constructor(t,e){super(t),this.name="Error",this.response=e,Object.setPrototypeOf(this,r.prototype)}}e.ProxyRequestError=r;e.isIntegrationError=t=>!("object"!=typeof t||!t)&&t.isIntegrationError,e.errorMessageParser=function(t){t="string"==typeof t?t:t.message;try{const n=JSON.parse(t);return!!(0,e.isIntegrationError)(n)}catch(t){return!1}}},35:(t,e,n)=>{"use strict";var i,r,o,s,a=n(155);Object.defineProperty(e,"__esModule",{value:!0}),e.CacheThrottle=e.CacheMode=void 0;const l=n(655),d=n(572);var c,u,h;!function(t){t.Debounce="debounce",t.Throttle="throttle"}(c=e.CacheMode||(e.CacheMode={})),function(t){t.Closed="closed",t.Idle="idle",t.Processing="processing"}(u||(u={})),function(t){t[t.Get=0]="Get",t[t.Set=1]="Set",t[t.GetOrSet=2]="GetOrSet",t[t.Del=3]="Del",t[t.Do=4]="Do"}(h||(h={}));e.CacheThrottle=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i.set(this,u.Idle),r.set(this,{}),o.set(this,void 0),s.set(this,[]),l.__classPrivateFieldSet(this,o,{mode:c.Debounce,ttl:0,...t},"f")}async get(t,e){const n=this.serializeKey(t),i=async()=>{const e=l.__classPrivateFieldGet(this,r,"f")[n],{mode:i,ttl:s,value:a}=null!=e?e:{};return!e||!s||i&&i!==c.Debounce||this.refreshTimeout(t,n,s),l.__classPrivateFieldGet(this,o,"f").clearPendingDeletes&&this.clearPendingDeletesOnKey(n,a),a};return e?i():this.enqueue(n,h.Get,i)}async set(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l.__classPrivateFieldGet(this,o,"f").ttl,i=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;const a=this.serializeKey(t),d=async()=>{const s=l.__classPrivateFieldGet(this,r,"f")[a],d=!!s;return l.__classPrivateFieldGet(this,r,"f")[a]={...s,mode:i,ttl:n,value:e},d&&i===c.Throttle||this.refreshTimeout(t,a,n),l.__classPrivateFieldGet(this,o,"f").clearPendingDeletes&&this.clearPendingDeletesOnKey(a,e),e};return s?d():this.enqueue(a,h.Set,d)}async getOrSet(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l.__classPrivateFieldGet(this,o,"f").ttl,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:l.__classPrivateFieldGet(this,o,"f").mode,s=arguments.length>4?arguments[4]:void 0;const a=this.serializeKey(t),d=async()=>{if(l.__classPrivateFieldGet(this,r,"f")[a])return l.__classPrivateFieldGet(this,r,"f")[a].value;const s=await e();return await this.set(t,s,n,i,!0),l.__classPrivateFieldGet(this,o,"f").clearPendingDeletes&&this.clearPendingDeletesOnKey(a,s),s};return s?d():this.enqueue(a,h.GetOrSet,d)}async del(t){let e=arguments.length>2?arguments[2]:void 0;const n=arguments.length>1&&void 0!==arguments[1]&&arguments[1]?t:this.serializeKey(t),i=async()=>{const t=l.__classPrivateFieldGet(this,r,"f")[n];let e;return(null==t?void 0:t.timeout)&&clearTimeout(t.timeout),t&&(e=t.value,delete l.__classPrivateFieldGet(this,r,"f")[n],await(async()=>{var t,n;return null===(n=(t=l.__classPrivateFieldGet(this,o,"f")).onDeregister)||void 0===n?void 0:n.call(t,e)})().catch((t=>{}))),e};return e?i():this.enqueue(n,h.Del,i)}keys(){return Object.keys(l.__classPrivateFieldGet(this,r,"f"))}async do(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l.__classPrivateFieldGet(this,o,"f").ttl,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:l.__classPrivateFieldGet(this,o,"f").mode;const s=this.serializeKey(t);return this.enqueue(s,h.Do,(async()=>{if(l.__classPrivateFieldGet(this,r,"f")[s])return l.__classPrivateFieldGet(this,r,"f")[s].value;const o=await e();return await this.set(t,o,n,i,!0)}))}async close(){l.__classPrivateFieldSet(this,i,u.Closed,"f"),await Promise.all(Object.keys(l.__classPrivateFieldGet(this,r,"f")).map((t=>this.del(t,!0,!0))))}refreshTimeout(t,e,n){if(l.__classPrivateFieldGet(this,i,"f")===u.Closed)return;const o=l.__classPrivateFieldGet(this,r,"f")[e];return n&&void 0!==(null==o?void 0:o.timeout)&&clearTimeout(o.timeout),n?(o.timeout=setTimeout((()=>this.del(t)),n),o.timeout):void 0}clearPendingDeletesOnKey(t,e){l.__classPrivateFieldSet(this,s,l.__classPrivateFieldGet(this,s,"f").filter((n=>{let[i,r,o,s]=n;return t!==i||r!==h.Del||(s.resolve(e),!1)})),"f")}serializeKey(t){var e,n,i;return null!==(i=null===(n=(e=l.__classPrivateFieldGet(this,o,"f")).serializeKey)||void 0===n?void 0:n.call(e,t))&&void 0!==i?i:t}async enqueue(t,e,n){const r=new d.DeferredPromise;return l.__classPrivateFieldGet(this,s,"f").push([t,e,n,r]),l.__classPrivateFieldGet(this,i,"f")===u.Idle&&this.flush(),r}flush(){l.__classPrivateFieldSet(this,i,u.Processing,"f"),a.nextTick((async()=>{for(;l.__classPrivateFieldGet(this,s,"f").length&&l.__classPrivateFieldGet(this,i,"f")!==u.Closed;){const t=l.__classPrivateFieldGet(this,s,"f").shift();if(t){const[,,e,n]=t;try{const t=await e();n.resolve(t)}catch(t){n.reject(t)}}}l.__classPrivateFieldSet(this,i,u.Idle,"f")}))}},i=new WeakMap,r=new WeakMap,o=new WeakMap,s=new WeakMap},715:(t,e,n)=>{var i=e;i.utils=n(436),i.common=n(772),i.sha=n(41),i.ripemd=n(949),i.hmac=n(326),i.sha1=i.sha.sha1,i.sha256=i.sha.sha256,i.sha224=i.sha.sha224,i.sha384=i.sha.sha384,i.sha512=i.sha.sha512,i.ripemd160=i.ripemd.ripemd160},772:(t,e,n)=>{"use strict";var i=n(436),r=n(746);function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}e.BlockHash=o,o.prototype.update=function(t,e){if(t=i.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var n=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-n,t.length),0===this.pending.length&&(this.pending=null),t=i.join32(t,0,t.length-n,this.endian);for(var r=0;r<t.length;r+=this._delta32)this._update(t,r,r+this._delta32)}return this},o.prototype.digest=function(t){return this.update(this._pad()),r(null===this.pending),this._digest(t)},o.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,n=e-(t+this.padLength)%e,i=new Array(n+this.padLength);i[0]=128;for(var r=1;r<n;r++)i[r]=0;if(t<<=3,"big"===this.endian){for(var o=8;o<this.padLength;o++)i[r++]=0;i[r++]=0,i[r++]=0,i[r++]=0,i[r++]=0,i[r++]=t>>>24&255,i[r++]=t>>>16&255,i[r++]=t>>>8&255,i[r++]=255&t}else for(i[r++]=255&t,i[r++]=t>>>8&255,i[r++]=t>>>16&255,i[r++]=t>>>24&255,i[r++]=0,i[r++]=0,i[r++]=0,i[r++]=0,o=8;o<this.padLength;o++)i[r++]=0;return i}},326:(t,e,n)=>{"use strict";var i=n(436),r=n(746);function o(t,e,n){if(!(this instanceof o))return new o(t,e,n);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(i.toArray(e,n))}t.exports=o,o.prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),r(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=(new this.Hash).update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=(new this.Hash).update(t)},o.prototype.update=function(t,e){return this.inner.update(t,e),this},o.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)}},949:(t,e,n)=>{"use strict";var i=n(436),r=n(772),o=i.rotl32,s=i.sum32,a=i.sum32_3,l=i.sum32_4,d=r.BlockHash;function c(){if(!(this instanceof c))return new c;d.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function u(t,e,n,i){return t<=15?e^n^i:t<=31?e&n|~e&i:t<=47?(e|~n)^i:t<=63?e&i|n&~i:e^(n|~i)}function h(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function f(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}i.inherits(c,d),e.ripemd160=c,c.blockSize=512,c.outSize=160,c.hmacStrength=192,c.padLength=64,c.prototype._update=function(t,e){for(var n=this.h[0],i=this.h[1],r=this.h[2],d=this.h[3],c=this.h[4],v=n,S=i,C=r,I=d,O=c,y=0;y<80;y++){var w=s(o(l(n,u(y,i,r,d),t[g[y]+e],h(y)),E[y]),c);n=c,c=d,d=o(r,10),r=i,i=w,w=s(o(l(v,u(79-y,S,C,I),t[p[y]+e],f(y)),_[y]),O),v=O,O=I,I=o(C,10),C=S,S=w}w=a(this.h[1],r,I),this.h[1]=a(this.h[2],d,O),this.h[2]=a(this.h[3],c,v),this.h[3]=a(this.h[4],n,S),this.h[4]=a(this.h[0],i,C),this.h[0]=w},c.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"little"):i.split32(this.h,"little")};var g=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],p=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],E=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],_=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},41:(t,e,n)=>{"use strict";e.sha1=n(761),e.sha224=n(799),e.sha256=n(344),e.sha384=n(978),e.sha512=n(900)},761:(t,e,n)=>{"use strict";var i=n(436),r=n(772),o=n(38),s=i.rotl32,a=i.sum32,l=i.sum32_5,d=o.ft_1,c=r.BlockHash,u=[1518500249,1859775393,2400959708,3395469782];function h(){if(!(this instanceof h))return new h;c.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}i.inherits(h,c),t.exports=h,h.blockSize=512,h.outSize=160,h.hmacStrength=80,h.padLength=64,h.prototype._update=function(t,e){for(var n=this.W,i=0;i<16;i++)n[i]=t[e+i];for(;i<n.length;i++)n[i]=s(n[i-3]^n[i-8]^n[i-14]^n[i-16],1);var r=this.h[0],o=this.h[1],c=this.h[2],h=this.h[3],f=this.h[4];for(i=0;i<n.length;i++){var g=~~(i/20),p=l(s(r,5),d(g,o,c,h),f,n[i],u[g]);f=h,h=c,c=s(o,30),o=r,r=p}this.h[0]=a(this.h[0],r),this.h[1]=a(this.h[1],o),this.h[2]=a(this.h[2],c),this.h[3]=a(this.h[3],h),this.h[4]=a(this.h[4],f)},h.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"big"):i.split32(this.h,"big")}},799:(t,e,n)=>{"use strict";var i=n(436),r=n(344);function o(){if(!(this instanceof o))return new o;r.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}i.inherits(o,r),t.exports=o,o.blockSize=512,o.outSize=224,o.hmacStrength=192,o.padLength=64,o.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h.slice(0,7),"big"):i.split32(this.h.slice(0,7),"big")}},344:(t,e,n)=>{"use strict";var i=n(436),r=n(772),o=n(38),s=n(746),a=i.sum32,l=i.sum32_4,d=i.sum32_5,c=o.ch32,u=o.maj32,h=o.s0_256,f=o.s1_256,g=o.g0_256,p=o.g1_256,E=r.BlockHash,_=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function v(){if(!(this instanceof v))return new v;E.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=_,this.W=new Array(64)}i.inherits(v,E),t.exports=v,v.blockSize=512,v.outSize=256,v.hmacStrength=192,v.padLength=64,v.prototype._update=function(t,e){for(var n=this.W,i=0;i<16;i++)n[i]=t[e+i];for(;i<n.length;i++)n[i]=l(p(n[i-2]),n[i-7],g(n[i-15]),n[i-16]);var r=this.h[0],o=this.h[1],E=this.h[2],_=this.h[3],v=this.h[4],S=this.h[5],C=this.h[6],I=this.h[7];for(s(this.k.length===n.length),i=0;i<n.length;i++){var O=d(I,f(v),c(v,S,C),this.k[i],n[i]),y=a(h(r),u(r,o,E));I=C,C=S,S=v,v=a(_,O),_=E,E=o,o=r,r=a(O,y)}this.h[0]=a(this.h[0],r),this.h[1]=a(this.h[1],o),this.h[2]=a(this.h[2],E),this.h[3]=a(this.h[3],_),this.h[4]=a(this.h[4],v),this.h[5]=a(this.h[5],S),this.h[6]=a(this.h[6],C),this.h[7]=a(this.h[7],I)},v.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"big"):i.split32(this.h,"big")}},978:(t,e,n)=>{"use strict";var i=n(436),r=n(900);function o(){if(!(this instanceof o))return new o;r.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}i.inherits(o,r),t.exports=o,o.blockSize=1024,o.outSize=384,o.hmacStrength=192,o.padLength=128,o.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h.slice(0,12),"big"):i.split32(this.h.slice(0,12),"big")}},900:(t,e,n)=>{"use strict";var i=n(436),r=n(772),o=n(746),s=i.rotr64_hi,a=i.rotr64_lo,l=i.shr64_hi,d=i.shr64_lo,c=i.sum64,u=i.sum64_hi,h=i.sum64_lo,f=i.sum64_4_hi,g=i.sum64_4_lo,p=i.sum64_5_hi,E=i.sum64_5_lo,_=r.BlockHash,v=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function S(){if(!(this instanceof S))return new S;_.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=v,this.W=new Array(160)}function C(t,e,n,i,r){var o=t&n^~t&r;return o<0&&(o+=4294967296),o}function I(t,e,n,i,r,o){var s=e&i^~e&o;return s<0&&(s+=4294967296),s}function O(t,e,n,i,r){var o=t&n^t&r^n&r;return o<0&&(o+=4294967296),o}function y(t,e,n,i,r,o){var s=e&i^e&o^i&o;return s<0&&(s+=4294967296),s}function w(t,e){var n=s(t,e,28)^s(e,t,2)^s(e,t,7);return n<0&&(n+=4294967296),n}function T(t,e){var n=a(t,e,28)^a(e,t,2)^a(e,t,7);return n<0&&(n+=4294967296),n}function A(t,e){var n=s(t,e,14)^s(t,e,18)^s(e,t,9);return n<0&&(n+=4294967296),n}function m(t,e){var n=a(t,e,14)^a(t,e,18)^a(e,t,9);return n<0&&(n+=4294967296),n}function N(t,e){var n=s(t,e,1)^s(t,e,8)^l(t,e,7);return n<0&&(n+=4294967296),n}function b(t,e){var n=a(t,e,1)^a(t,e,8)^d(t,e,7);return n<0&&(n+=4294967296),n}function P(t,e){var n=s(t,e,19)^s(e,t,29)^l(t,e,6);return n<0&&(n+=4294967296),n}function R(t,e){var n=a(t,e,19)^a(e,t,29)^d(t,e,6);return n<0&&(n+=4294967296),n}i.inherits(S,_),t.exports=S,S.blockSize=1024,S.outSize=512,S.hmacStrength=192,S.padLength=128,S.prototype._prepareBlock=function(t,e){for(var n=this.W,i=0;i<32;i++)n[i]=t[e+i];for(;i<n.length;i+=2){var r=P(n[i-4],n[i-3]),o=R(n[i-4],n[i-3]),s=n[i-14],a=n[i-13],l=N(n[i-30],n[i-29]),d=b(n[i-30],n[i-29]),c=n[i-32],u=n[i-31];n[i]=f(r,o,s,a,l,d,c,u),n[i+1]=g(r,o,s,a,l,d,c,u)}},S.prototype._update=function(t,e){this._prepareBlock(t,e);var n=this.W,i=this.h[0],r=this.h[1],s=this.h[2],a=this.h[3],l=this.h[4],d=this.h[5],f=this.h[6],g=this.h[7],_=this.h[8],v=this.h[9],S=this.h[10],N=this.h[11],b=this.h[12],P=this.h[13],R=this.h[14],L=this.h[15];o(this.k.length===n.length);for(var D=0;D<n.length;D+=2){var U=R,M=L,k=A(_,v),j=m(_,v),F=C(_,v,S,N,b),B=I(_,v,S,N,b,P),x=this.k[D],K=this.k[D+1],$=n[D],V=n[D+1],G=p(U,M,k,j,F,B,x,K,$,V),W=E(U,M,k,j,F,B,x,K,$,V);U=w(i,r),M=T(i,r),k=O(i,r,s,a,l),j=y(i,r,s,a,l,d);var H=u(U,M,k,j),q=h(U,M,k,j);R=b,L=P,b=S,P=N,S=_,N=v,_=u(f,g,G,W),v=h(g,g,G,W),f=l,g=d,l=s,d=a,s=i,a=r,i=u(G,W,H,q),r=h(G,W,H,q)}c(this.h,0,i,r),c(this.h,2,s,a),c(this.h,4,l,d),c(this.h,6,f,g),c(this.h,8,_,v),c(this.h,10,S,N),c(this.h,12,b,P),c(this.h,14,R,L)},S.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"big"):i.split32(this.h,"big")}},38:(t,e,n)=>{"use strict";var i=n(436).rotr32;function r(t,e,n){return t&e^~t&n}function o(t,e,n){return t&e^t&n^e&n}function s(t,e,n){return t^e^n}e.ft_1=function(t,e,n,i){return 0===t?r(e,n,i):1===t||3===t?s(e,n,i):2===t?o(e,n,i):void 0},e.ch32=r,e.maj32=o,e.p32=s,e.s0_256=function(t){return i(t,2)^i(t,13)^i(t,22)},e.s1_256=function(t){return i(t,6)^i(t,11)^i(t,25)},e.g0_256=function(t){return i(t,7)^i(t,18)^t>>>3},e.g1_256=function(t){return i(t,17)^i(t,19)^t>>>10}},436:(t,e,n)=>{"use strict";var i=n(746),r=n(717);function o(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function s(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function l(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}e.inherits=r,e.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var n=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),r=0;r<t.length;r+=2)n.push(parseInt(t[r]+t[r+1],16))}else for(var i=0,r=0;r<t.length;r++){var s=t.charCodeAt(r);s<128?n[i++]=s:s<2048?(n[i++]=s>>6|192,n[i++]=63&s|128):o(t,r)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++r)),n[i++]=s>>18|240,n[i++]=s>>12&63|128,n[i++]=s>>6&63|128,n[i++]=63&s|128):(n[i++]=s>>12|224,n[i++]=s>>6&63|128,n[i++]=63&s|128)}else for(r=0;r<t.length;r++)n[r]=0|t[r];return n},e.toHex=function(t){for(var e="",n=0;n<t.length;n++)e+=a(t[n].toString(16));return e},e.htonl=s,e.toHex32=function(t,e){for(var n="",i=0;i<t.length;i++){var r=t[i];"little"===e&&(r=s(r)),n+=l(r.toString(16))}return n},e.zero2=a,e.zero8=l,e.join32=function(t,e,n,r){var o=n-e;i(o%4==0);for(var s=new Array(o/4),a=0,l=e;a<s.length;a++,l+=4){var d;d="big"===r?t[l]<<24|t[l+1]<<16|t[l+2]<<8|t[l+3]:t[l+3]<<24|t[l+2]<<16|t[l+1]<<8|t[l],s[a]=d>>>0}return s},e.split32=function(t,e){for(var n=new Array(4*t.length),i=0,r=0;i<t.length;i++,r+=4){var o=t[i];"big"===e?(n[r]=o>>>24,n[r+1]=o>>>16&255,n[r+2]=o>>>8&255,n[r+3]=255&o):(n[r+3]=o>>>24,n[r+2]=o>>>16&255,n[r+1]=o>>>8&255,n[r]=255&o)}return n},e.rotr32=function(t,e){return t>>>e|t<<32-e},e.rotl32=function(t,e){return t<<e|t>>>32-e},e.sum32=function(t,e){return t+e>>>0},e.sum32_3=function(t,e,n){return t+e+n>>>0},e.sum32_4=function(t,e,n,i){return t+e+n+i>>>0},e.sum32_5=function(t,e,n,i,r){return t+e+n+i+r>>>0},e.sum64=function(t,e,n,i){var r=t[e],o=i+t[e+1]>>>0,s=(o<i?1:0)+n+r;t[e]=s>>>0,t[e+1]=o},e.sum64_hi=function(t,e,n,i){return(e+i>>>0<e?1:0)+t+n>>>0},e.sum64_lo=function(t,e,n,i){return e+i>>>0},e.sum64_4_hi=function(t,e,n,i,r,o,s,a){var l=0,d=e;return l+=(d=d+i>>>0)<e?1:0,l+=(d=d+o>>>0)<o?1:0,t+n+r+s+(l+=(d=d+a>>>0)<a?1:0)>>>0},e.sum64_4_lo=function(t,e,n,i,r,o,s,a){return e+i+o+a>>>0},e.sum64_5_hi=function(t,e,n,i,r,o,s,a,l,d){var c=0,u=e;return c+=(u=u+i>>>0)<e?1:0,c+=(u=u+o>>>0)<o?1:0,c+=(u=u+a>>>0)<a?1:0,t+n+r+s+l+(c+=(u=u+d>>>0)<d?1:0)>>>0},e.sum64_5_lo=function(t,e,n,i,r,o,s,a,l,d){return e+i+o+a+d>>>0},e.rotr64_hi=function(t,e,n){return(e<<32-n|t>>>n)>>>0},e.rotr64_lo=function(t,e,n){return(t<<32-n|e>>>n)>>>0},e.shr64_hi=function(t,e,n){return t>>>n},e.shr64_lo=function(t,e,n){return(t<<32-n|e>>>n)>>>0}},717:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}}},245:(t,e,n)=>{"use strict";function i(t){this.message=t}n.r(e),n.d(e,{InvalidTokenError:()=>s,default:()=>a}),i.prototype=new Error,i.prototype.name="InvalidCharacterError";var r="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new i("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,o=0,s=0,a="";r=e.charAt(s++);~r&&(n=o%4?64*n+r:r,o++%4)?a+=String.fromCharCode(255&n>>(-2*o&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return a};function o(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(r(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return r(e)}}function s(t){this.message=t}s.prototype=new Error,s.prototype.name="InvalidTokenError";const a=function(t,e){if("string"!=typeof t)throw new s("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(o(t.split(".")[n]))}catch(t){throw new s("Invalid token specified: "+t.message)}}},746:t=>{function e(t,e){if(!t)throw new Error(e||"Assertion failed")}t.exports=e,e.equal=function(t,e,n){if(t!=e)throw new Error(n||"Assertion failed: "+t+" != "+e)}},155:t=>{var e,n,i=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(t){if(e===setTimeout)return setTimeout(t,0);if((e===r||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(n){try{return e.call(null,t,0)}catch(n){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:r}catch(t){e=r}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var a,l=[],d=!1,c=-1;function u(){d&&a&&(d=!1,a.length?l=a.concat(l):c=-1,l.length&&h())}function h(){if(!d){var t=s(u);d=!0;for(var e=l.length;e;){for(a=l,l=[];++c<e;)a&&a[c].run();c=-1,e=l.length}a=null,d=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===o||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{return n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function f(t,e){this.fun=t,this.array=e}function g(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];l.push(new f(t,e)),1!==l.length||d||s(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},655:(t,e,n)=>{"use strict";n.r(e),n.d(e,{__assign:()=>o,__asyncDelegator:()=>I,__asyncGenerator:()=>C,__asyncValues:()=>O,__await:()=>S,__awaiter:()=>c,__classPrivateFieldGet:()=>m,__classPrivateFieldSet:()=>N,__createBinding:()=>h,__decorate:()=>a,__exportStar:()=>f,__extends:()=>r,__generator:()=>u,__importDefault:()=>A,__importStar:()=>T,__makeTemplateObject:()=>y,__metadata:()=>d,__param:()=>l,__read:()=>p,__rest:()=>s,__spread:()=>E,__spreadArray:()=>v,__spreadArrays:()=>_,__values:()=>g});var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)};function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){return o=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},o.apply(this,arguments)};function s(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]])}return n}function a(t,e,n,i){var r,o=arguments.length,s=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,n,s):r(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s}function l(t,e){return function(n,i){e(n,i,t)}}function d(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function c(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))}function u(t,e){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}var h=Object.create?function(t,e,n,i){void 0===i&&(i=n),Object.defineProperty(t,i,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]};function f(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||h(e,t,n)}function g(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function p(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){r={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return s}function E(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(p(arguments[e]));return t}function _(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var i=Array(t),r=0;for(e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)i[r]=o[s];return i}function v(t,e,n){if(n||2===arguments.length)for(var i,r=0,o=e.length;r<o;r++)!i&&r in e||(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}function S(t){return this instanceof S?(this.v=t,this):new S(t)}function C(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=n.apply(t,e||[]),o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(t){r[t]&&(i[t]=function(e){return new Promise((function(n,i){o.push([t,e,n,i])>1||a(t,e)}))})}function a(t,e){try{(n=r[t](e)).value instanceof S?Promise.resolve(n.value.v).then(l,d):c(o[0][2],n)}catch(t){c(o[0][3],t)}var n}function l(t){a("next",t)}function d(t){a("throw",t)}function c(t,e){t(e),o.shift(),o.length&&a(o[0][0],o[0][1])}}function I(t){var e,n;return e={},i("next"),i("throw",(function(t){throw t})),i("return"),e[Symbol.iterator]=function(){return this},e;function i(i,r){e[i]=t[i]?function(e){return(n=!n)?{value:S(t[i](e)),done:"return"===i}:r?r(e):e}:r}}function O(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=g(t),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(n){e[n]=t[n]&&function(e){return new Promise((function(i,r){(function(t,e,n,i){Promise.resolve(i).then((function(e){t({value:e,done:n})}),e)})(i,r,(e=t[n](e)).done,e.value)}))}}}function y(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}var w=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e};function T(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&h(e,t,n);return w(e,t),e}function A(t){return t&&t.__esModule?t:{default:t}}function m(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function N(t,e,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(t,n):r?r.value=n:e.set(t,n),n}}},e={};function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i=n(56);module.exports=i})();
|
|
2
|
+
(()=>{var t={773:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PARAGON_OVERFLOW_EMPTY_VALUE=void 0;const i=n(655),r=i.__importDefault(n(245)),o=n(59),s=n(745),a=n(343),l=n(643),c=n(429),d=i.__importDefault(n(892)),u=n(821),h=n(158),p=n(846),f=n(572),g=n(321),_=n(35),E="paragon-connect-frame",v=`${E}-container`,S="paragon-connect-user-state";e.PARAGON_OVERFLOW_EMPTY_VALUE="PARAGON_OVERFLOW_EMPTY_VALUE";class I extends d.default{constructor(t){if(super(),this.rootLoaded=!1,this.rootElementCreated=!1,this.modalState={integration:null,onClose:this.onClose.bind(this),overlayStyle:{overflow:"auto"},onOpen:this.onOpen.bind(this),apiInstallationOptions:{isApiInstallation:!1,showPortalAfterInstall:!1}},this.userState={authenticated:!1},this.loadedConfigs={},this.loadedIntegrations={},this.endUserIntegrationConfig={},this.metadata={},this.cachedApiResponse=new _.CacheThrottle({ttl:5e3}),this.keyToRequestPromiseMap={},this.originalBodyOverflow=e.PARAGON_OVERFLOW_EMPTY_VALUE,"undefined"==typeof window)return void console.warn("connect sdk can only be used on browser");const n=(0,h.getAssetUrl)({CDN_PUBLIC_URL:"https://cdn.useparagon.com",DASHBOARD_PUBLIC_URL:"https://dashboard.useparagon.com",NODE_ENV:"production",PLATFORM_ENV:"production",VERSION:"latest"});if(this.environments={CDN_PUBLIC_URL:n,CONNECT_PUBLIC_URL:"https://connect.useparagon.com",DASHBOARD_PUBLIC_URL:"https://dashboard.useparagon.com",NODE_ENV:"production",PASSPORT_PUBLIC_URL:"https://passport.useparagon.com",PLATFORM_ENV:"production",VERSION:"latest",WORKER_PROXY_PUBLIC_URL:"https://proxy.useparagon.com",ZEUS_PUBLIC_URL:"https://zeus.useparagon.com",...t},!this.environments.CONNECT_PUBLIC_URL)throw new Error("Paragon SDK error! No `CONNECT_PUBLIC_URL` configured.");if(!this.environments.DASHBOARD_PUBLIC_URL)throw new Error("Paragon SDK error! No `DASHBOARD_PUBLIC_URL` configured.");if(!this.environments.PASSPORT_PUBLIC_URL)throw new Error("Paragon SDK error! No `PASSPORT_PUBLIC_URL` configured.");if(!this.environments.WORKER_PROXY_PUBLIC_URL)throw new Error("Paragon SDK error! No `WORKER_PROXY_PUBLIC_URL` configured.");if(!this.environments.ZEUS_PUBLIC_URL)throw new Error("Paragon SDK error! No `ZEUS_PUBLIC_URL` configured.");this.loadState(),window.addEventListener("message",this.eventMessageHandler.bind(this)),window.document.readyState===u.DocumentLoadingState.LOADING?window.document.addEventListener("DOMContentLoaded",(()=>{this.createReactRoot()})):this.createReactRoot()}async eventMessageHandler(t){switch(t.data.type){case"oauth_success_callback":await this._oauthCallback(t.data.credential);break;case"oauth_error_callback":await this._oauthErrorCallback(t.data.error,t);break;default:await this.functionInvocationHandler(t)}}async functionInvocationHandler(t){if("SDK_FUNCTION_INVOCATION"!==t.data.messageType)return;const{type:e,id:n,parameters:i}=t.data;let r;try{r={messageType:"SDK_FUNCTION_RESPONSE",id:n,type:e,result:await this[e](...i)}}catch(t){r={messageType:"SDK_FUNCTION_ERROR",error:!0,message:t.message,id:n}}t.source.postMessage(r,this.environments.CONNECT_PUBLIC_URL)}createReactRoot(){var t;if(this.rootElementCreated)return;this.rootElementCreated=!0,this.root=document.createElement("iframe"),this.root.onload=()=>{this.rootLoaded=!0,this.render()};const e=!!document.querySelector(`#${v}`);this.root.id=E,this.root.src=`${this.environments.CONNECT_PUBLIC_URL}/ui${this.projectId?`?projectId=${this.projectId}`:""}`,this.root.style.position=e?"absolute":"fixed",this.root.style.top="0",this.root.style.left="0",this.root.style.width=e?"100%":"100vw",this.root.style.height=e?"100%":"100vh",this.root.style.zIndex="2147483647",this.root.style.display="none",null===(t=document.querySelector(`#${v}`)||document.body)||void 0===t||t.appendChild(this.root)}validateAction(t){var e;if(!this.loadedIntegrations[t]&&!(0,a.isCustomIntegrationTypeName)(t))throw new Error(`"${t}" is not a valid integration type. The integrations you have configured for this Paragon project are:\n\n${Object.keys(this.loadedConfigs).map((t=>`- "${t}"`)).join("\n")}\n`);if(!this.loadedConfigs[t]||!this.userState.integrations[t])throw new Error(`integration "${t}" has not been set up in your Paragon project yet.\n\n${Object.keys(this.loadedConfigs).map((t=>`- "${t}"`)).join("\n")}`);if(!(null===(e=this.loadedIntegrations[t])||void 0===e?void 0:e.isActive))throw new Error(`integration "${t}" is not active in your Paragon project yet.`)}isAlreadyInstalled(t,e){var n;return Boolean(null===(n=e.integrations[t])||void 0===n?void 0:n.enabled)}async bootstrapSDKState(t){this.projectId&&this.userState.authenticated&&(this.project=await this.sendConnectRequest(`/sdk/projects/${this.projectId}`,{headers:{"X-Paragon-Cache-Metadata":"1",...t?{"X-Paragon-User-Metadata":JSON.stringify(t)}:{}}},!1),await this.updateLocalState())}setModalState(t){this.modalState={config:void 0,...this.modalState,...t},this.render()}loadState(){if("undefined"!=typeof window)try{const t=window.localStorage.getItem(S)?JSON.parse(window.localStorage.getItem(S)):{};if(t.projectId&&(this.projectId=t.projectId),t.userState){const{userState:e}=t;if(!("authenticated"in e&&e.authenticated&&"token"in e))throw new Error("Malformatted or unauthenticated user was persisted into localStorage. Refusing to load.");this.updateAuthenticatedUser(e),this.bootstrapSDKState().catch((()=>{this.clearState()}))}}catch{this.clearState()}}saveState(){"undefined"!=typeof window&&this.userState.authenticated&&window.localStorage.setItem(S,JSON.stringify({projectId:this.projectId,userState:this.userState}))}clearState(){"undefined"!=typeof window&&window.localStorage.removeItem(S)}render(){if(this.root&&this.rootLoaded){const{onClose:t,onOpen:e,...n}=this.modalState,i={messageType:"UI_UPDATE",nextContext:{user:this.userState,projectId:this.projectId,environments:this.environments,project:this.project,endUserIntegrationConfig:this.modalState.integration?this.endUserIntegrationConfig[this.modalState.integration.type]:void 0},nextModalState:n};if(!this.root.contentWindow)throw new Error("Browser not supported");this.root.contentWindow.postMessage(i,this.environments.CONNECT_PUBLIC_URL)}}updateContainerStyle(t){let{isModalShown:e}=t;this.root&&(this.root.style.display=e?"block":"none")}async authenticate(t,e,n){var i;if(!t||!e)throw new Error("projectId or token not specified to paragon.authenticate()");let o={};try{o=(0,r.default)(e)}catch(t){throw new Error("A well-formed JWT was not provided to paragon.authenticate()")}this.projectId=t,this.userState={authenticated:!0,token:e,userId:o.sub||o.id,integrations:{},meta:null!==(i=null==n?void 0:n.metadata)&&void 0!==i?i:{},resources:[]};try{if(Date.now()>=1e3*(o.exp||0))throw new Error("JWT token provided has expired.");await this.bootstrapSDKState(null==n?void 0:n.metadata)}catch(t){throw console.warn("paragon.authenticate() could not login user",t),this.logout(),new Error(`Failed to authenticate user with Paragon: ${t.message}`)}this.render()}getUser(){return Object.fromEntries(Object.entries(this.userState).filter((t=>{let[e]=t;return"token"!==e})))}updateAuthenticatedUser(t){this.userState.authenticated?this.userState={...this.userState,...t}:t.authenticated&&(this.userState=t),this.render()}logout(){this.userState={authenticated:!1},this.clearState(),this.render()}async connect(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{mapObjectFields:n,overrideRedirectUrl:i,isApiInstallation:r=!1,showPortalAfterInstall:l,bypassPostOAuthPrompt:d,allowMultipleCredentials:h,selectedCredentialId:p,accountType:f,..._}=e;return this.integrationToBeEnabled=t,new Promise(((E,v)=>{var S,I,O;this.subscribeToIntegration(t,{..._,onInstall:(t,e)=>{var n;E(),(null==_?void 0:_.onInstall)?_.onInstall(t,e):null===(n=null==_?void 0:_.onSuccess)||void 0===n||n.call(_,t,e)},onError:t=>{var e;v(t),null===(e=null==_?void 0:_.onError)||void 0===e||e.call(_,t)}});try{if(n&&!this.project.accessibleFeatures.includes(u.ConnectAddOn.DynamicFieldMapper))throw new Error("Dynamic Field Mapping is available on our Enterprise plan. Contact sales@useparagon.com to learn more or upgrade.");if(this.validateAction(t),i&&!(0,g.isValidUrl)(i))throw new Error(`${i} is not valid url.`);this.endUserIntegrationConfig[t]={mapObjectFields:n,overrideRedirectUrl:i?(0,g.sanitizeUrl)(i):void 0};const _=Object.values(this.loadedIntegrations).find((e=>(0,a.getIntegrationTypeName)(e)===t)),E="string"==typeof f?null==f?void 0:f.trim():"",v=null===(I=null===(S=null==_?void 0:_.sdkIntegrationConfig)||void 0===S?void 0:S.accountTypes)||void 0===I?void 0:I.find((t=>t.id===E)),y={isApiInstallation:r,showPortalAfterInstall:l,bypassPostOAuthPrompt:d,allowMultipleCredentials:h,selectedCredentialId:p};if(p&&this.userState.authenticated){const e=this.userState.integrations[t],n=null==e?void 0:e.allCredentials.find((t=>{let{id:e}=t;return p===e}));if(!n)throw new Error(`Credential with ID "${p}" is not a valid ${t} account.`);this.userState.integrations={...this.userState.integrations,[t]:{...e,enabled:n.status===o.CredentialStatus.VALID,configuredWorkflows:n.config.configuredWorkflows,sharedSettings:n.config.sharedSettings,credentialId:n.id,providerData:n.providerData,providerId:n.providerId,credentialStatus:n.status}}}if(e.isApiInstallation){const e={context:{user:this.userState,projectId:this.projectId,environments:this.environments,endUserIntegrationConfig:this.endUserIntegrationConfig[t]},integration:_};if(Boolean(_.needPreOauthInputs&&v&&!(null===(O=v.endUserSuppliedValues)||void 0===O?void 0:O.length)&&v.scheme===s.AuthenticationScheme.OAUTH)||!_.needPreOauthInputs){e.authParams=null==v?void 0:v.oauthParameters,e.installOptions=y;const t=Math.random().toString(36).substring(2,15),n=(0,c.startOAuthFlow)(e,t);if(n){const e=Date.now(),i=setInterval((()=>{if(Date.now()-e>c.MAX_POLL_DURATION)clearInterval(i);else try{n.opener||(clearInterval(i),this.pollForCredential(t))}catch(e){this.pollForCredential(t)}}),500)}}}f&&!v&&console.warn(`Account type "${f}" is not valid for integration "${null==_?void 0:_.type}"`);const T=JSON.parse(JSON.stringify(this.loadedConfigs[t])),A=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(!t)return;const e=new Set,n=[];for(const i of t)e.has(i.value)?console.warn(`Duplicated key: "${i.value}", Ignored: "${i.label}"`):(n.push(i),e.add(i.value));return n};if("dropdowns"in e){const n=e.dropdowns;if(T.sharedMeta&&Array.isArray(T.sharedMeta.inputs))for(const t of T.sharedMeta.inputs){const e=A(n[t.key]);e&&t.customDropdownOptions&&(t.customDropdownOptions=e)}if(T.workflowMeta)for(const t in T.workflowMeta){const e=T.workflowMeta[t];for(const t of e.inputs){const e=A(n[t.key]);e&&t.customDropdownOptions&&(t.customDropdownOptions=e)}}this.loadedConfigs[t]=T}this.setModalState({integration:_,config:this.loadedConfigs[t],apiInstallationOptions:{...y,selectedAccountConfig:v},selectedCredentialId:p,connectionError:void 0})}catch(e){this.emitError(e,t)}}))}_getIntegration(t){return Object.values(this.loadedIntegrations).find((e=>e.id===t))}async _oauthCallback(t,e){var n;const{integrationId:i,payload:r}=t,s=this._getIntegration(i);if(!s)return;const l=(0,a.getIntegrationTypeName)(s),c=(null===(n=this.modalState.apiInstallationOptions)||void 0===n?void 0:n.isApiInstallation)?this.modalState.apiInstallationOptions:{};try{const t=e?`/sdk/credentials/${e}/complete-setup`:"/sdk/credentials",n=await this.sendConnectRequest(t,{method:"POST",body:JSON.stringify({integrationId:s.id,config:{},payload:r,installOptions:c})});if(!n)throw new Error("Unable to save oauth credentials");this.updateCredentialData(n,s),n.status===o.CredentialStatus.VALID&&this.triggerSDKEvent({type:u.SDK_EVENT.ON_INTEGRATION_INSTALL,integrationId:s.id,integrationType:l}),this.setModalState({...this.modalState,connectionError:void 0})}catch(t){this.setModalState({...this.modalState,connectionError:t.message}),this.emitError(t,l),await this._oauthErrorCallback(t.message)}}async _oauthErrorCallback(t,e){var n;const i=t;let r;r=this.integrationToBeEnabled?this.loadedIntegrations[this.integrationToBeEnabled].id:null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.integrationId,e&&(this.emitError(e.data.errorResponse,(0,a.getIntegrationTypeName)(this._getIntegration(r))),this.setModalState({...this.modalState,connectionError:e.data.errorResponse})),console.error("Failed to connect account to Paragon over OAuth",i)}async sendConnectRequest(t,e){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];var i;if(!this.userState.authenticated||!this.projectId)throw new Error("Connect SDK attempted to make an API request, but no user was authenticated.\nCall paragon.authenticate(<projectId>, <user token>) before using the SDK.");const r=`${null!==(i=null==e?void 0:e.baseURLOverride)&&void 0!==i?i:this.environments.ZEUS_PUBLIC_URL}${n?`/projects/${this.projectId}`:""}${t}`,o=(0,p.hash)(JSON.stringify({url:r,payload:{...e}})),s=await this.cachedApiResponse.get(o,!0);if((null==e?void 0:e.cacheResult)&&s)return s;const a=Boolean(!e||"GET"===e.method||e.cacheResult);if(a&&"object"==typeof this.keyToRequestPromiseMap[o])return this.keyToRequestPromiseMap[o];const l=this.userState.token,c=this.modalState.integration?this.userState.integrations[this.modalState.integration.type]:void 0,d=new Promise(((t,n)=>{(async()=>{try{const n=await this.sendRequest(r,{...e,headers:{Accept:"application/json","Content-Type":"application/json",...(null==c?void 0:c.credentialId)?{[u.SELECTED_CREDENTIAL_ID_HEADER]:null==c?void 0:c.credentialId}:{},...null==e?void 0:e.headers,Authorization:`Bearer ${l}`}},a?o:void 0);t(n)}catch(t){n(t)}})()}));return a&&(this.keyToRequestPromiseMap[o]=d),d}async sendRequest(t,e,n){var i;let r,o,s;try{r=await fetch(t,e)}catch(t){s=t}if(r&&!r.ok||s){const e=r?await(0,g.getErrorMessage)(r,!0):null==s?void 0:s.message,o="string"==typeof e?e:null==e?void 0:e.message,a=(0,g.errorMessageParser)(o),l=401===(null==r?void 0:r.status)||403===(null==r?void 0:r.status);if(a||t.includes("proxy")||!l){if(!a&&t.includes("proxy")&&l){const t=await this.fetchUserData();this.updateAuthenticatedUser({integrations:t.integrations,meta:t.meta,resources:t.resources})}}else this.logout();if(n&&(await this.cachedApiResponse.del(n),delete this.keyToRequestPromiseMap[n]),"string"!=typeof e&&t.includes("proxy"))throw null===(i=e.response)||void 0===i||delete i.headers,new g.ProxyRequestError(e.message,e.response);throw new Error(o)}try{o=await(null==r?void 0:r.json())}catch{o=void 0}return n&&(await this.cachedApiResponse.set(n,o),delete this.keyToRequestPromiseMap[n]),o}async request(t,e,n){var i,r;let o=`/sdk/proxy/${t}`;(0,a.isCustomIntegrationTypeName)(t)&&(o=`/sdk/proxy/custom/${null===(i=Object.values(this.loadedIntegrations).find((e=>!!e.customIntegration&&e.customIntegration.slug===t)))||void 0===i?void 0:i.id}`);const s=e.startsWith("/")?e:`/${e}`,l=n.selectedCredentialId?n.selectedCredentialId:null===(r=this.userState.integrations[t])||void 0===r?void 0:r.credentialId,c=await this.sendConnectRequest(`${o}${s}`,{method:n.method,body:"object"==typeof n.body?JSON.stringify(n.body):n.body,headers:{"Content-Type":u.INFER_CONTENT_TYPE_FROM_CONNECT_OPTIONS,...l?{[u.SELECTED_CREDENTIAL_ID_HEADER]:l}:{},...n.headers},baseURLOverride:this.environments.WORKER_PROXY_PUBLIC_URL});return null==c?void 0:c.output}async event(t,e){await this.sendConnectRequest(`/v2/projects/${this.projectId}/sdk/events/trigger`,{method:"POST",body:JSON.stringify({name:t,payload:e})},!1)}onClose(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{integration:n,apiInstallationOptions:i}=this.modalState;n&&(this.triggerSDKEvent({type:u.SDK_EVENT.ON_PORTAL_CLOSE,integrationId:n.id,integrationType:(0,a.getIntegrationTypeName)(n)}),this.originalBodyOverflow!==e.PARAGON_OVERFLOW_EMPTY_VALUE&&(window.document.body.style.overflow=this.originalBodyOverflow,this.originalBodyOverflow=e.PARAGON_OVERFLOW_EMPTY_VALUE),!t&&(null==i?void 0:i.isApiInstallation)||this.setModalState({integration:null}))}onOpen(){const{integration:t}=this.modalState;if(t&&(this.triggerSDKEvent({type:u.SDK_EVENT.ON_PORTAL_OPEN,integrationId:t.id,integrationType:(0,a.getIntegrationTypeName)(t)}),this.root&&this.originalBodyOverflow===e.PARAGON_OVERFLOW_EMPTY_VALUE)){const t=this.root.getBoundingClientRect();window.innerHeight<=t.height&&window.innerWidth<=t.width&&(this.originalBodyOverflow=window.document.body.style.overflow,window.document.body.style.overflow="hidden")}}triggerSDKEvent(t){this.triggerEvent(t,this.userState)}getIntegrationMetadata(t){const e=t=>{return{...t,icon:(e=t.icon,e.includes(".svg")?(null===(n=e.split(".svg"))||void 0===n?void 0:n[0])+".svg":e)};var e,n};if(t){const n=this.metadata[t];if(!n)throw new Error(`${t} is not a valid integration name`);return e(n)}return Object.values(this.metadata).map(e)}closePortal(){this.onClose(!0)}workflow(t){let{selectedCredentialId:e,body:n={},query:i={},headers:r={}}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var o;if(!t)throw new Error("workflowId is required.");const s=new URLSearchParams(i).toString(),a=e||(null===(o=this.getIntegrationForWorkflow(t))||void 0===o?void 0:o.credentialId);return this.sendConnectRequest(`/sdk/triggers/${t}?${s}`,{method:"POST",body:JSON.stringify(n),headers:{...a?{[u.SELECTED_CREDENTIAL_ID_HEADER]:a}:{},...r}},!0)}installIntegration(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.userState.authenticated)throw new Error("User not authenticated, Call paragon.authenticate(<projectId>, <user token>) before using the SDK.");const n={showPortalAfterInstall:!1,bypassPostOAuthPrompt:!1,allowMultipleCredentials:!1,...e,isApiInstallation:!0};if(n.bypassPostOAuthPrompt&&n.showPortalAfterInstall)throw new Error("Could not use both `bypassPostOAuthPrompt` and `showPortalAfterInstall` as true at the same time.");if(this.ensureHeadlessIsSupported(),this.validateAction(t),!n.allowMultipleCredentials&&this.isAlreadyInstalled(t,this.userState))throw new Error(`Integration "${t}" is already installed.`);return this.setModalState({integration:null}),this.connect(t,n)}ensureHeadlessIsSupported(){if(!this.project.accessibleFeatures.includes(u.ConnectAddOn.HeadlessConnectPortal))throw new Error("Headless Connect Portal is available on our Pro plan and above. Contact sales@useparagon.com to learn more or upgrade.")}async uninstallIntegration(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=null==e?void 0:e.selectedCredentialId;if(!this.userState.authenticated)throw new Error("User not authenticated, Call paragon.authenticate(<projectId>, <user token>) before using the SDK.");if(this.ensureHeadlessIsSupported(),this.validateAction(t),!this.isAlreadyInstalled(t,this.userState))throw new Error(`Integration "${t}" is not installed.`);const i=this.loadedIntegrations[t].id,r=this.userState.integrations[t],o=n||(null==r?void 0:r.credentialId);if(!o||!r)throw new Error("No credential found for uninstall");await this.sendConnectRequest(`/sdk/integrations/${i}`,{method:"DELETE",headers:{...o?{[u.SELECTED_CREDENTIAL_ID_HEADER]:o}:{}}}),this.updateAuthenticatedUser({integrations:{...this.userState.integrations,[t]:(0,l.getActionStateForCredentialDelete)(o,r)}}),n===this.modalState.selectedCredentialId&&this.setModalState({integration:null,selectedCredentialId:void 0}),this.saveState(),this.triggerSDKEvent({type:u.SDK_EVENT.ON_INTEGRATION_UNINSTALL,integrationId:i,integrationType:t})}async disableWorkflow(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n;const i=null==e?void 0:e.selectedCredentialId;if(!this.userState.authenticated)throw new Error("User not authenticated, Call paragon.authenticate(<projectId>, <user token>) before using the SDK.");if(!this.isWorkflowEnabled(t,i))throw new Error(`Workflow ${t} cannot be disabled for this user.`);const r=i||(null===(n=this.getIntegrationForWorkflow(t))||void 0===n?void 0:n.credentialId);await this.sendConnectRequest(`/sdk/workflows/${t}`,{method:"DELETE",headers:r?{[u.SELECTED_CREDENTIAL_ID_HEADER]:r}:{}}),await this.updateLocalState()}async getIntegrationAccount(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n;this.validateAction(t);const i=null===(n=this.userState.integrations[t])||void 0===n?void 0:n.allCredentials;if(!(null==i?void 0:i.length))throw new Error("Connect credential not found");const r=await this.sendConnectRequest(`/sdk/credentials?integration=${t}&includeAccountAuth=${e.includeAccountAuth}`,{method:"GET",headers:e.selectedCredentialId?{[u.SELECTED_CREDENTIAL_ID_HEADER]:e.selectedCredentialId}:{}});if(!r)throw new Error("Integration not connected");return r}getIntegrationForWorkflow(t){return Object.values(this.userState.integrations).find((e=>{var n;return null===(n=null==e?void 0:e.configuredWorkflows)||void 0===n?void 0:n[t]}))}async updateLocalState(){const[t,e]=await Promise.all([this.fetchUserData(),this.fetchIntegrations()]);this.updateAuthenticatedUser({integrations:t.integrations,meta:t.meta,resources:t.resources}),this.updateIntegrations(e),this.saveState()}isWorkflowEnabled(t,e){var n,i,r;if(e){const o=Object.values(this.userState.integrations).map((t=>t.allCredentials)).flat().find((t=>t.id===e));return Boolean(null===(r=null===(i=null===(n=null==o?void 0:o.config)||void 0===n?void 0:n.configuredWorkflows)||void 0===i?void 0:i[t])||void 0===r?void 0:r.enabled)}const o=Object.values(this.userState.integrations).find((e=>{var n,i;return null===(i=null===(n=null==e?void 0:e.configuredWorkflows)||void 0===n?void 0:n[t])||void 0===i?void 0:i.enabled}));return void 0!==o}async fetchUserData(){const t=await this.sendConnectRequest("/sdk/me");if(t)return t;throw new Error("Unable to get user Data")}async fetchIntegrations(){const t=await this.sendConnectRequest("/sdk/integrations");if(!t)throw new Error("Unable to fetch integrations");return t}updateIntegrations(t){t.forEach((t=>{var e,n,i;if(t.configs.length)try{const r=(0,a.getIntegrationTypeName)(t);this.loadedConfigs[r]=t.configs[0].values,this.loadedIntegrations[r]=t,Boolean(t.isActive)&&(this.metadata[r]={type:r,name:t.name,brandColor:t.brandColor,icon:null!==(n=null===(e=t.customIntegration)||void 0===e?void 0:e.icon)&&void 0!==n?n:`${this.environments.CDN_PUBLIC_URL}/integrations/${u.overrideActionAlias[t.type]||t.type}.svg`}),(null===(i=this.modalState.integration)||void 0===i?void 0:i.id)===t.id&&this.setModalState({integration:t})}catch(t){console.warn(t)}}))}async setUserMetadata(t){return await this.sendConnectRequest("/sdk/me",{method:"PATCH",body:JSON.stringify({meta:t})}),await this.updateLocalState(),this.render(),this.userState}configureGlobal(t,e){var n,i,r,o,s,a;if(!t||!t.host)throw new Error("host not specified");const l=t.host.indexOf("http")>-1?new URL(t.host).hostname:t.host;this.environments.CONNECT_PUBLIC_URL=null!==(n=null==e?void 0:e.CONNECT_PUBLIC_URL)&&void 0!==n?n:(0,g.getServiceUrl)("connect",l),this.environments.DASHBOARD_PUBLIC_URL=null!==(i=null==e?void 0:e.DASHBOARD_PUBLIC_URL)&&void 0!==i?i:(0,g.getServiceUrl)("dashboard",l),this.environments.PASSPORT_PUBLIC_URL=null!==(r=null==e?void 0:e.PASSPORT_PUBLIC_URL)&&void 0!==r?r:(0,g.getServiceUrl)("passport",l),this.environments.ZEUS_PUBLIC_URL=null!==(o=null==e?void 0:e.ZEUS_PUBLIC_URL)&&void 0!==o?o:(0,g.getServiceUrl)("zeus",l),this.environments.CDN_PUBLIC_URL=null!==(s=null==e?void 0:e.CDN_PUBLIC_URL)&&void 0!==s?s:(0,g.getServiceUrl)("dashboard",l),this.environments.WORKER_PROXY_PUBLIC_URL=null!==(a=null==e?void 0:e.WORKER_PROXY_PUBLIC_URL)&&void 0!==a?a:(0,g.getServiceUrl)("proxy",l),this.userState.authenticated=!1,this.root?this.root.src=`${this.environments.CONNECT_PUBLIC_URL}/ui${this.projectId?`?projectId=${this.projectId}`:""}`:console.error("Root element not defined")}async completeInstall(t,e){var n;if(!this.userState.authenticated)throw new Error("Authentication is required");if(!e||!e.authorizationCode)throw new Error("authorizationCode is required");if(e.redirectUrl&&!(0,g.isValidUrl)(e.redirectUrl))throw new Error(`${e.redirectUrl} is not valid url`);this.validateAction(t);const i=Object.values(this.loadedIntegrations).find((e=>(0,a.getIntegrationTypeName)(e)===t)),r=null===(n=e.showPortalAfterInstall)||void 0===n||n,o=await this.sendConnectRequest("/sdk/credentials",{method:"POST",body:JSON.stringify({code:e.authorizationCode,integrationId:i.id,redirectUrl:e.redirectUrl?(0,g.sanitizeUrl)(e.redirectUrl):void 0,integrationOptions:e.integrationOptions||{}})});if(!o)throw new Error("Unable to create credential");this.updateCredentialData(o,i),r&&this.setModalState({integration:i,config:this.loadedConfigs[t],apiInstallationOptions:{}})}updateCredentialData(t,e){const n=this.userState,i=(0,a.getIntegrationTypeName)(e),r=n.integrations[i],s=r.allCredentials.findIndex((e=>e.id===t.id));s>-1?r.allCredentials[s]=t:r.allCredentials.push(t),this.updateAuthenticatedUser({integrations:{...n.integrations,[i]:{...r,...t.config,credentialStatus:t.status,enabled:t.status===o.CredentialStatus.VALID,credentialId:t.id,providerId:t.providerId,providerData:t.providerData}}})}async connectAction(t,e){var n;if(!this.userState.authenticated)throw new Error("User not authenticated, Call paragon.authenticate(<projectId>, <user token>) before using the SDK.");const i=null===(n=this.userState.resources.find((e=>t===e.slug)))||void 0===n?void 0:n.id;if(!i)throw new Error(`No resource found with name "${t}".`);if(!e||"object"!=typeof e)throw new Error("payload must be of type object.");const r=await this.sendConnectRequest(`/sdk/resources/${i}/connect`,{method:"POST",body:JSON.stringify(e)});if(!r)throw new Error(`Unable to connect to "${t}".`);return r}async pollForCredential(t){const e=Date.now(),n=async()=>{try{return await this.sendConnectRequest(`/sdk/actions/session-id/${t}`,{method:"GET"})}catch(t){return console.error("error",t),null}};try{const t=await(0,f.tryUntil)(n,(function(t,n){return!((arguments.length>2&&void 0!==arguments[2]?arguments[2]:1)>=20||Date.now()-e>=c.MAX_POLL_DURATION||(null==t?void 0:t.connectCredentialId))}),c.CREDENTIAL_POLL_INTERVAL);t&&t.connectCredentialId&&this.updateLocalState()}catch(t){console.error("Error while connecting to integration",t)}finally{await this.sendConnectRequest(`/sdk/actions/session-id/${t}`,{method:"DELETE"})}}}e.default=I},892:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(821);e.default=class{constructor(){this.eventListenersMap={},this.integrationStateCallbacks={}}subscribe(t,e){var n;if(this.assertEventType(t),"function"!=typeof e)throw new Error(`no listener is provided for ${t}`);return this.eventListenersMap={...this.eventListenersMap,[t]:[...null!==(n=this.eventListenersMap[t])&&void 0!==n?n:[],e]},()=>this.unsubscribe(t,e)}subscribeToIntegration(t,e){this.integrationStateCallbacks[t]={...e}}unsubscribe(t,e){var n,i;if(this.assertEventType(t),"function"!=typeof e)throw new Error("listener is required for unsubscription");const r=(null!==(n=this.eventListenersMap[t])&&void 0!==n?n:[]).length;return this.eventListenersMap={...this.eventListenersMap,[t]:(null!==(i=this.eventListenersMap[t])&&void 0!==i?i:[]).filter((t=>t!==e))},r>this.eventListenersMap[t].length}assertEventType(t){if(!Object.values(i.SDK_EVENT).includes(t))throw new Error(`${t} is not valid paragon event`)}emitSafe(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];var r;(null!==(r=this.eventListenersMap[t])&&void 0!==r?r:[]).forEach((t=>{try{t(...n)}catch(t){console.error(t)}}))}emitError(t,e){this.invokeCallbackSafe(e,"onError",t)}invokeCallbackSafe(t,e){var n,i;try{for(var r=arguments.length,o=new Array(r>2?r-2:0),s=2;s<r;s++)o[s-2]=arguments[s];null===(i=null===(n=this.integrationStateCallbacks[t])||void 0===n?void 0:n[e])||void 0===i||i.call(n,...o)}catch(t){console.error(t)}}triggerEvent(t,e){let{type:n,integrationId:r,integrationType:o,workflowId:s,workflowStateChange:a}=t;if(r&&o)switch(n){case i.SDK_EVENT.ON_INTEGRATION_INSTALL:{const t=[{integrationId:r,integrationType:o},e];this.invokeCallbackSafe(o,"onInstall",...t),this.emitSafe(i.SDK_EVENT.ON_INTEGRATION_INSTALL,...t);break}case i.SDK_EVENT.ON_INTEGRATION_UNINSTALL:{const t=[{integrationId:r,integrationType:o},e];this.invokeCallbackSafe(o,"onUninstall",...t),this.emitSafe(i.SDK_EVENT.ON_INTEGRATION_UNINSTALL,...t);break}case i.SDK_EVENT.ON_PORTAL_OPEN:{const t=[{integrationId:r,integrationType:o},e];this.invokeCallbackSafe(o,"onOpen",...t),this.emitSafe(i.SDK_EVENT.ON_PORTAL_OPEN,...t);break}case i.SDK_EVENT.ON_PORTAL_CLOSE:{const t=[{integrationId:r,integrationType:o},e];this.invokeCallbackSafe(o,"onClose",...t),this.emitSafe(i.SDK_EVENT.ON_PORTAL_CLOSE,...t);break}case i.SDK_EVENT.ON_WORKFLOW_CHANGE:{const t=[{integrationId:r,workflowId:s,workflowStateChange:a||{}},e];this.invokeCallbackSafe(o,"onWorkflowChange",...t),this.emitSafe(i.SDK_EVENT.ON_WORKFLOW_CHANGE,...t);break}default:throw new Error(`${n} is not valid event.`)}}}},931:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ACTION_CUSTOM=void 0,e.ACTION_CUSTOM="custom"},59:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CredentialStatus=void 0,function(t){t.PENDING="PENDING",t.INVALID="INVALID",t.VALID="VALID"}(e.CredentialStatus||(e.CredentialStatus={}))},745:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AuthenticationScheme=void 0,function(t){t.BASIC="basic",t.OAUTH="oauth",t.OAUTH_CLIENT_CREDENTIAL="oauth_client_credential",t.SERVICE_ACCOUNT="service_account",t.OAUTH_APP="oauth_app",t.IMPERSONATED_APP="impersonated_app"}(e.AuthenticationScheme||(e.AuthenticationScheme={}))},663:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.generateSlugForIntegration=void 0,e.generateSlugForIntegration=function(t){if(!t.name)return;return`custom.${t.name?t.name.replace(/[\W_]+/g,"").trim().toLowerCase():void 0}`}},343:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isCustomIntegrationTypeName=e.getIntegrationTypeName=void 0;const i=n(931),r=n(663);e.getIntegrationTypeName=function(t){if(t.type===i.ACTION_CUSTOM){if(t.customIntegration)return(0,r.generateSlugForIntegration)(t.customIntegration);throw new Error(`Custom integration details are missing from this integration: ${t.id}`)}return t.type},e.isCustomIntegrationTypeName=function(t){return t.startsWith("custom.")}},950:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GoogleDriveFilePicker=void 0;const i=n(821),r=n(473);class o extends r.BaseFilePicker{constructor(t,e){super(t,e),this.accessToken=""}get google(){return window.google}getInstance(){var t;return null!==(t=this.instance)&&void 0!==t?t:null}open(){var t,e;return!(this.dependencyStatus!==i.FilePickerStatus.LOADED||!this.instance)&&(this.instance.setVisible(!0),null===(e=(t=this.options).onOpen)||void 0===e||e.call(t),!0)}async init(t){this.dependencyStatus=i.FilePickerStatus.LOADING,await this.validateInitOptions(t),this.initOptions={...t};const e=await this.connectSDKInstance.getIntegrationAccount("googledrive",{includeAccountAuth:!0});return this.accessToken=e.accountAuth[i.AUTH_TOKEN_ALLOWED_INTEGRATIONS.googledrive.accessTokenPath],this.initialiseDependencyPromise(),this.injectScript("https://apis.google.com/js/api.js"),this.dependenciesPromise}onScriptLoaded(){this.dependencyStatus=i.FilePickerStatus.LOADED,window.gapi.load("picker",this.onPickerLoaded.bind(this))}onScriptError(){this.dependencyStatus=i.FilePickerStatus.FAILED,this.dependenciesPromise.reject(new Error("Not able to load dependencies"))}onPickerLoaded(){const t=new this.google.picker.PickerBuilder,e=new this.google.picker.DocsView;this.options.allowMultiSelect&&t.enableFeature(this.google.picker.Feature.MULTISELECT_ENABLED),this.options.allowFolderSelect&&(e.setIncludeFolders(!0),e.setSelectFolderEnabled(!0)),this.options.allowedTypes&&this.options.allowedTypes.length>0&&e.setMimeTypes(this.options.allowedTypes.join(",")),this.instance=t.addView(e).setOAuthToken(this.accessToken).setDeveloperKey(this.initOptions.developerKey).setCallback(this.pickerCallback.bind(this)).build(),this.dependenciesPromise.resolve(!0)}pickerCallback(t){var e,n,i,r,o,s;const{action:a,...l}=t;switch(a){case this.google.picker.Action.PICKED:null===(n=(e=this.options).onFileSelect)||void 0===n||n.call(e,l),null===(r=(i=this.options).onClose)||void 0===r||r.call(i);break;case this.google.picker.Action.CANCEL:null===(s=(o=this.options).onCancel)||void 0===s||s.call(o)}}}e.GoogleDriveFilePicker=o},698:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(950);e.default={GoogleDriveFilePicker:i.GoogleDriveFilePicker}},473:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BaseFilePicker=void 0;const i=n(643),r=n(572);e.BaseFilePicker=class{constructor(t,e){this.options=t,this.connectSDKInstance=e}initialiseDependencyPromise(){this.dependenciesPromise=new r.DeferredPromise}getInstance(){return this.instance}injectScript(t){if(this.checkIfScriptLoaded(t))this.onScriptLoaded();else{const e=document.createElement("script");e.src=t,e.async=!0,e.id=t,e.onload=this.onScriptLoaded.bind(this),e.onerror=this.onScriptError.bind(this),document.body.appendChild(e)}}checkIfScriptLoaded(t){const e=document.getElementsByTagName("script");for(let n=0;n<e.length;n++)if(e[n].getAttribute("src")==t)return!0;return!1}async validateInitOptions(t){if(!t||(0,i.isStringEmpty)(t.developerKey))throw new Error("Please provide a valid developer key");return!0}}},731:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.buildExternalFilePickerInstance=void 0;const i=n(655).__importDefault(n(698));class r{constructor(t,e,n){let r;if("googledrive"!==t)throw new Error(`${t}'s file picker is not supported`);r=new i.default.GoogleDriveFilePicker(e,n),this.open=this.open.bind(r),this.init=this.init.bind(r),this.getInstance=this.getInstance.bind(r)}open(){return this.open()}init(t){return this.init(t)}getInstance(){return this.getInstance()}}e.default=r;e.buildExternalFilePickerInstance=t=>function(e,n){if(!t.getUser().authenticated)throw new Error("Authentication is required");if(!e)throw new Error("Missing argument: Integration type is required");return t.validateAction(e),new r(e,n,t)}},50:function(t,e,n){"use strict";var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.buildExternalFilePickerInstance=e.ExternalFilePicker=void 0;var r=n(731);Object.defineProperty(e,"ExternalFilePicker",{enumerable:!0,get:function(){return i(r).default}}),Object.defineProperty(e,"buildExternalFilePickerInstance",{enumerable:!0,get:function(){return r.buildExternalFilePickerInstance}})},643:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isStringEmpty=e.getActionStateForCredentialDelete=e.stripUndefinedAndNull=e.parseKeyedSource=void 0;const i=n(59);e.parseKeyedSource=function(t){return t&&(null==t?void 0:t.length)?Object.fromEntries(t.map((t=>[t.key,"VALUE"===t.source.type?t.source.value:void 0]))):{}},e.stripUndefinedAndNull=function t(e){const n={};return Object.keys(e).forEach((i=>{var r;(r=e[i])&&"object"==typeof r&&!Array.isArray(r)?n[i]=t(e[i]):void 0!==e[i]&&null!==e[i]&&(n[i]=e[i])})),n};e.getActionStateForCredentialDelete=(t,e)=>{var n;const r=(null!==(n=null==e?void 0:e.allCredentials)&&void 0!==n?n:[]).filter((e=>e.id!==t));if(0===r.length)return{enabled:!1,configuredWorkflows:{},allCredentials:[]};{const t=r[0];return{...e,credentialStatus:t.status,enabled:t.status===i.CredentialStatus.VALID,credentialId:t.id,providerId:t.providerId,providerData:t.providerData,allCredentials:r}}};e.isStringEmpty=t=>!t||"string"==typeof t&&!t.trim()},429:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.startOAuthFlow=e.MAX_POLL_DURATION=e.CREDENTIAL_POLL_INTERVAL=void 0;const i=n(931),r=n(343),o=n(643);e.CREDENTIAL_POLL_INTERVAL=3e3,e.MAX_POLL_DURATION=6e4;e.startOAuthFlow=(t,e)=>{let{context:n,integration:s,endUserSuppliedValues:a={},authParams:l,isPreviewMode:c=!1,installOptions:d={}}=t;var u;const h=(0,r.getIntegrationTypeName)(s);if(!h)return;const p=l?(0,o.parseKeyedSource)(l):{},f=(0,o.stripUndefinedAndNull)({action:h&&(0,r.isCustomIntegrationTypeName)(h)?i.ACTION_CUSTOM:h,endUserSuppliedValues:JSON.stringify(a),parameters:JSON.stringify(p),userToken:n.user.token,integrationId:s.id,redirectUrl:null===(u=n.endUserIntegrationConfig)||void 0===u?void 0:u.overrideRedirectUrl,originForPostMessage:window.location.origin,isPreviewMode:c,installOptions:JSON.stringify(d),sessionId:e}),g=`${n.environments.ZEUS_PUBLIC_URL}/projects/${n.projectId}/sdk/actions/build-oauth?${new URLSearchParams(f).toString()}`;return window.open(g,void 0,"width=500,height=600,left=100,top=150")}},56:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.paragon=e.connectSingleton=void 0;const i=n(655),r=i.__importDefault(n(773)),o=n(50);i.__exportStar(n(821),e),e.connectSingleton=new r.default,e.paragon={authenticate:e.connectSingleton.authenticate.bind(e.connectSingleton),connect:e.connectSingleton.connect.bind(e.connectSingleton),closePortal:e.connectSingleton.closePortal.bind(e.connectSingleton),event:e.connectSingleton.event.bind(e.connectSingleton),getIntegrationMetadata:e.connectSingleton.getIntegrationMetadata.bind(e.connectSingleton),getUser:e.connectSingleton.getUser.bind(e.connectSingleton),request:e.connectSingleton.request.bind(e.connectSingleton),subscribe:e.connectSingleton.subscribe.bind(e.connectSingleton),unsubscribe:e.connectSingleton.unsubscribe.bind(e.connectSingleton),workflow:e.connectSingleton.workflow.bind(e.connectSingleton),_oauthCallback:e.connectSingleton._oauthCallback.bind(e.connectSingleton),_oauthErrorCallback:e.connectSingleton._oauthErrorCallback.bind(e.connectSingleton),installIntegration:e.connectSingleton.installIntegration.bind(e.connectSingleton),uninstallIntegration:e.connectSingleton.uninstallIntegration.bind(e.connectSingleton),disableWorkflow:e.connectSingleton.disableWorkflow.bind(e.connectSingleton),getIntegrationAccount:e.connectSingleton.getIntegrationAccount.bind(e.connectSingleton),setUserMetadata:e.connectSingleton.setUserMetadata.bind(e.connectSingleton),configureGlobal:e.connectSingleton.configureGlobal.bind(e.connectSingleton),completeInstall:e.connectSingleton.completeInstall.bind(e.connectSingleton),connectAction:e.connectSingleton.connectAction.bind(e.connectSingleton),ExternalFilePicker:(0,o.buildExternalFilePickerInstance)(e.connectSingleton)},e.default=r.default},992:(t,e)=>{"use strict";var n,i,r;Object.defineProperty(e,"__esModule",{value:!0}),e.AUTH_TOKEN_ALLOWED_INTEGRATIONS=e.overrideActionAlias=e.TokenType=e.SidebarInputType=void 0,function(t){t.Auth="AUTH",t.Enum="ENUM",t.DynamicEnum="DYNAMIC_ENUM",t.Intent="INTENT",t.Text="TEXT",t.TextArea="TEXTAREA",t.ValueText="TEXT_NO_VARS",t.ValueTextArea="TEXTAREA_NO_VARS",t.Code="CODE",t.ActionButton="ACTION_BUTTON",t.Conditional="CONDITIONAL",t.DynamicConditional="DYNAMIC_CONDITIONAL",t.NestedList="NESTED_LIST",t.File="FILE",t.EditableDynamicEnum="EDITABLE_DYNAMIC_ENUM",t.EditableEnum="EDITABLE_ENUM",t.BooleanInput="BOOLEAN_INPUT",t.UserSuppliedCredential="USER_SUPPLIED_CREDENTIAL",t.NativeDynamicEnumInput="NATIVE_DYNAMIC_INPUT",t.TimeConstraintInput="TIME_CONSTRAINT_INPUT",t.LinesListInput="LinesListInput",t.LinesListDynamicInput="LinesListDynamicInput",t.Number="NUMBER",t.Email="EMAIL",t.URL="URL",t.EnumTextAreaPairInput="EnumTextAreaPairInput",t.FieldMapper="FIELD_MAPPER",t.ComboInput="COMBO_INPUT",t.Password="PASSWORD",t.Switch="SWITCH"}(e.SidebarInputType||(e.SidebarInputType={})),function(t){t.ACCESS_TOKEN="ACCESS_TOKEN",t.REFRESH_TOKEN="REFRESH_TOKEN",t.BOT_TOKEN="BOT_TOKEN",t.KLAVIYO_API_KEY="KLAVIYO_API_KEY",t.MARKETO_CLIENT_ID="MARKETO_CLIENT_ID",t.MARKETO_CLIENT_SECRET="MARKETO_CLIENT_SECRETI",t.MARKETO_ENDPOINT="MARKETO_ENDPOINT",t.MARKETO_IDENTITY="MARKETO_IDENTITY",t.MONDAY_API_TOKEN="MONDAY_API_TOKEN",t.ORACLE_CLOUD_URL="ORACLE_CLOUD_URL",t.ORACLE_PASSWORD="ORACLE_PASSWORD",t.ORACLE_USERNAME="ORACLE_USERNAME",t.SAGE_INTACCT_COMPANY_ID="SAGE_INTACCT_COMPANY_ID",t.SAGE_INTACCT_USER_ID="SAGE_INTACCT_USER_ID",t.SAGE_INTACCT_USER_PASSWORD="SAGE_INTACCT_USER_PASSWORD",t.SAILTHRU_COMPANY_KEY="SAILTHRU_COMPANY_KEY",t.SAILTHRU_COMPANY_SECRET="SAILTHRU_COMPANY_SECRET",t.SERVICENOW_PASSWORD="SERVICENOW_PASSWORD",t.SERVICENOW_SUBDOMAIN="SERVICENOW_SUBDOMAIN",t.SERVICENOW_USERNAME="SERVICENOW_USERNAME",t.TABLEAU_PERSONAL_ACCESS_TOKEN_NAME="TABLEAU_PERSONAL_ACCESS_TOKEN_NAME",t.TABLEAU_PERSONAL_ACCESS_TOKEN_SECRET="TABLEAU_PERSONAL_ACCESS_TOKEN_SECRET",t.TABLEAU_SERVER_NAME="TABLEAU_SERVER_NAME",t.TABLEAU_SITE_ID="TABLEAU_SITE_ID",t.TRELLO_API_KEY="TRELLO_API_KEY",t.TRELLO_API_TOKEN="TRELLO_API_TOKEN",t.WOOCOMMERCE_CONSUMER_KEY="WOOCOMMERCE_CONSUMER_KEY",t.WOOCOMMERCE_CONSUMER_SECRET="WOOCOMMERCE_CONSUMER_SECRET",t.WOOCOMMERCE_STORE_DOMAIN="WOOCOMMERCE_STORE_DOMAIN",t.WORKABLE_API_ACCESS_TOKEN="WORKABLE_API_ACCESS_TOKEN",t.WORKABLE_ACCOUNT_SUBDOMAIN="WORKABLE_ACCOUNT_SUBDOMAIN",t.ZOHO_CRM_ACCOUNTS_SERVER="ZOHO_CRM_ACCOUNTS_SERVER",t.ZOHO_CRM_API_DOMAIN="ZOHO_CRM_API_DOMAIN"}(e.TokenType||(e.TokenType={})),function(t){t.INFO="INFO",t.ERROR="ERROR",t.SUCCESS="SUCCESS"}(n||(n={})),function(t){t.NONE="NONE",t.RE_AUTHENTICATE="RE_AUTHENTICATE",t.ALERT="ALERT",t.DISPATCH="DISPATCH"}(i||(i={})),function(t){t.DYNAMIC="DYNAMIC_DATA_SOURCE",t.STATIC_ENUM="STATIC_ENUM_DATA_SOURCE",t.FIELD_MAPPER="FIELD_MAPPER_DATA_SOURCE",t.COMBO_INPUT="COMBO_INPUT_DATA_SOURCE"}(r||(r={})),e.overrideActionAlias={"monday.com":"monday","wordpress.com":"wordpress"},e.AUTH_TOKEN_ALLOWED_INTEGRATIONS={googledrive:{accessTokenPath:"OAUTH_ACCESS_TOKEN"}}},34:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONNECT_PLAN_FEATURE_MAP=void 0;const i=n(471);e.CONNECT_PLAN_FEATURE_MAP={[i.BillingPlan.ConnectBasic]:[],[i.BillingPlan.ConnectPro]:[i.ConnectAddOn.CustomIntegrationBuilder,i.ConnectAddOn.HeadlessConnectPortal,i.ConnectAddOn.Monitoring,i.ConnectAddOn.UserMetadata,i.ConnectAddOn.WhiteLabeling],[i.BillingPlan.ConnectEnterprise]:[i.ConnectAddOn.CustomIntegrationBuilder,i.ConnectAddOn.DynamicFieldMapper,i.ConnectAddOn.HeadlessConnectPortal,i.ConnectAddOn.TaskHistoryAPI,i.ConnectAddOn.Monitoring,i.ConnectAddOn.RoleBasedAccessControl,i.ConnectAddOn.UserMetadata,i.ConnectAddOn.WhiteLabeling,i.ConnectAddOn.WorkflowPermission]}},935:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SELECTED_CREDENTIAL_ID_HEADER=e.INFER_CONTENT_TYPE_FROM_CONNECT_OPTIONS=void 0;const i=n(992);i.SidebarInputType.ValueText,i.SidebarInputType.DynamicEnum,i.SidebarInputType.Enum,i.SidebarInputType.Number,i.SidebarInputType.Email,i.SidebarInputType.URL,i.SidebarInputType.FieldMapper,i.SidebarInputType.BooleanInput,i.SidebarInputType.ComboInput,i.SidebarInputType.Password,i.SidebarInputType.Switch,i.SidebarInputType.ValueTextArea;e.INFER_CONTENT_TYPE_FROM_CONNECT_OPTIONS="auto",e.SELECTED_CREDENTIAL_ID_HEADER="X-Paragon-Credential"},977:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},914:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PLATFORM_ENV=e.NODE_ENV=void 0,function(t){t.PRODUCTION="production",t.DEVELOPMENT="development",t.TEST="test"}(e.NODE_ENV||(e.NODE_ENV={})),function(t){t.PRODUCTION="production",t.PRODUCTION_MIRROR_1="p-m1",t.STAGING="staging",t.STAGING_MIRROR_1="s-m1",t.DEVELOPMENT="dev",t.TEST="test",t.SANDBOX="sandbox",t.RELEASE="release",t.ENTERPRISE="enterprise"}(e.PLATFORM_ENV||(e.PLATFORM_ENV={}))},65:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},821:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i=n(655);i.__exportStar(n(992),e),i.__exportStar(n(34),e),i.__exportStar(n(935),e),i.__exportStar(n(977),e),i.__exportStar(n(914),e),i.__exportStar(n(65),e),i.__exportStar(n(835),e),i.__exportStar(n(750),e),i.__exportStar(n(471),e)},835:(t,e)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.DataType=void 0,function(t){t.STRING="STRING",t.NUMBER="NUMBER",t.DATE="DATE",t.BOOLEAN="BOOLEAN",t.EMAIL="EMAIL",t.OBJECT="OBJECT",t.ARRAY="ARRAY",t.ANY="ANY",t.FILE="FILE",t.NON_DECIMAL="NON_DECIMAL"}(e.DataType||(e.DataType={})),function(t){t.None="$none",t.StringContains="$stringContains",t.StringDoesNotContain="$stringDoesNotContain",t.StringExactlyMatches="$stringExactlyMatches",t.StringDoesNotExactlyMatch="$stringDoesNotExactlyMatch",t.StringIsIn="$stringIsIn",t.StringIsNotIn="$stringIsNotIn",t.StringStartsWith="$stringStartsWith",t.StringDoesNotStartWith="$stringDoesNotStartWith",t.StringEndsWith="$stringEndsWith",t.StringDoesNotEndWith="$stringDoesNotEndWith",t.NumberGreaterThan="$numberGreaterThan",t.NumberLessThan="$numberLessThan",t.NumberEquals="$numberEquals",t.NumberDoesNotEqual="$numberDoesNotEqual",t.NumberLessThanOrEqualTo="$numberLessThanOrEqualTo",t.NumberGreaterThanOrEqualTo="$numberGreaterThanOrEqualTo",t.DateTimeAfter="$dateTimeAfter",t.DateTimeBefore="$dateTimeBefore",t.DateTimeEquals="$dateTimeEquals",t.BooleanTrue="$booleanTrue",t.BooleanFalse="$booleanFalse",t.IsNotNull="$exists",t.IsNull="$doesNotExist",t.Exists="$isNotUndefinedOrNull",t.DoesNotExist="$isUndefinedOrNull",t.ArrayIsIn="$arrayIsIn",t.ArrayIsNotIn="$arrayIsNotIn",t.ArrayIsEmpty="$arrayIsEmpty",t.ArrayIsNotEmpty="$arrayIsNotEmpty",t.StringGreaterThan="$stringGreaterThan",t.StringLessThan="$stringLessThan"}(n||(n={}))},750:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.FilePickerStatus=e.DocumentLoadingState=e.SDK_EVENT=e.ModalView=void 0,function(t){t.OVERVIEW="overview",t.CONFIGURATION="configuration"}(e.ModalView||(e.ModalView={})),function(t){t.ON_INTEGRATION_INSTALL="onIntegrationInstall",t.ON_INTEGRATION_UNINSTALL="onIntegrationUninstall",t.ON_WORKFLOW_CHANGE="onWorkflowChange",t.ON_PORTAL_OPEN="onPortalOpen",t.ON_PORTAL_CLOSE="onPortalClose"}(e.SDK_EVENT||(e.SDK_EVENT={})),function(t){t.LOADING="loading",t.INTERACTIVE="interactive",t.COMPLETE="complete"}(e.DocumentLoadingState||(e.DocumentLoadingState={})),function(t){t.LOADING="loading",t.FAILED="failed",t.LOADED="loaded"}(e.FilePickerStatus||(e.FilePickerStatus={}))},471:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ConnectAddOn=e.BillingPlan=void 0,function(t){t.ClassicFree="free",t.ClassicStarter="starter",t.ClassicBusiness="business",t.ClassicPremium="premium",t.ClassicEnterprise="enterprise",t.ConnectTrial="connect_trial",t.ConnectBasic="basic",t.ConnectPro="pro",t.ConnectEnterprise="connect_enterprise"}(e.BillingPlan||(e.BillingPlan={})),function(t){t.CustomIntegrationBuilder="byo",t.DynamicFieldMapper="dfm",t.HeadlessConnectPortal="headless-cp",t.TaskHistoryAPI="th-api",t.Monitoring="monitoring",t.RoleBasedAccessControl="rbac",t.UserMetadata="user-metadata",t.WhiteLabeling="whitelabel",t.WorkflowPermission="workflow-permissions"}(e.ConnectAddOn||(e.ConnectAddOn={}))},158:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getAssetUrl=void 0;const i=n(914);e.getAssetUrl=t=>{let{CDN_PUBLIC_URL:e,DASHBOARD_PUBLIC_URL:n,VERSION:r,PLATFORM_ENV:o,NODE_ENV:s}=t;return e&&s===i.NODE_ENV.PRODUCTION&&o!==i.PLATFORM_ENV.ENTERPRISE?`${e}/${r}/dashboard/public`:n}},846:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.hash=void 0;const i=n(715);e.hash=function(t){return null==t?t:(0,i.sha256)().update(t).digest("hex").substr(0,10)}},572:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.tryUntil=e.sleep=e.generateMatrix=e.DeferredPromise=void 0;function n(t){return new Promise((e=>setTimeout(e,t)))}e.DeferredPromise=class{get state(){return this._state}constructor(){this._state="pending",this._promise=new Promise(((t,e)=>{this._resolve=t,this._reject=e}))}then(t,e){return this._promise.then(t,e)}catch(t){return this._promise.catch(t)}resolve(t){this._resolve(t),this._state="fulfilled"}reject(t){this._reject(t),this._state="rejected"}finally(t){return null==t||t(),this._promise}},Symbol.toStringTag,e.generateMatrix=function(t,e){const n=Object.keys(t);if(n.reduce(((e,n)=>e+t[n].length),0)&&n.length)for(const e of n)t[e].length||t[e].push(void 0);const i=Object.entries(t).reduce(((t,e)=>{let[,n]=e;return t.length?t.reduce(((t,e)=>(n.forEach((n=>{const i=e.slice();i.push(n),t.push(i)}),[]),t)),[]):n.map((t=>[t]))}),[]).reduce(((t,e)=>{const i=e.reduce(((t,e,i)=>({...t,[n[i]]:e})),{});return[...t,i]}),[]);return e?i.slice(-1*e):i},e.sleep=n,e.tryUntil=async function(t,e,i){let r=0,o=!0;for(;o;){r+=1;let s=null,a=null;try{s=await t()}catch(t){a=t}if(o=await e(s,a,r),!o){if(a)throw a;return s}{const t="number"==typeof i?i:i(r);await n(t)}}throw new Error("Method unable to run: invalid retries.")}},321:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.errorMessageParser=e.isIntegrationError=e.ProxyRequestError=e.getErrorMessage=e.getServiceUrl=e.sanitizeUrl=e.isValidUrl=void 0;function n(t){return t?t.match(/^[a-zA-Z]+:\/\//)?t:`https://${t}`:t}function i(t){return Array.isArray(t)?t.flatMap((t=>[t,i(t.children||[])].flatMap((t=>"string"==typeof t?t:i(t))))).filter((t=>t)).join(", "):Object.values(t.constraints||{}).join(", ")}e.isValidUrl=t=>{const e=n(t);try{return new globalThis.URL(e),!0}catch(t){return!1}},e.sanitizeUrl=n,e.getServiceUrl=function(t,e){return`https://${t}${`.${e}`}`},e.getErrorMessage=async function(t,n){var r,o;const s=null===(r=t.headers)||void 0===r?void 0:r.get("content-type"),a=s&&s.includes("application/json")?await t.json():null;let l;return l=a&&(0,e.isIntegrationError)(a.meta)?JSON.stringify(a.meta):a&&"string"==typeof a.message?a.message:a&&400===t.status&&Array.isArray(a.message)?i(a.message):a?JSON.stringify(a):await(null===(o=t.text)||void 0===o?void 0:o.call(t)),n?{message:l,response:a||t}:l};class r extends Error{constructor(t,e){super(t),this.name="Error",this.response=e,Object.setPrototypeOf(this,r.prototype)}}e.ProxyRequestError=r;e.isIntegrationError=t=>!("object"!=typeof t||!t)&&t.isIntegrationError,e.errorMessageParser=function(t){t="string"==typeof t?t:t.message;try{const n=JSON.parse(t);return!!(0,e.isIntegrationError)(n)}catch(t){return!1}}},35:(t,e,n)=>{"use strict";var i,r,o,s,a=n(155);Object.defineProperty(e,"__esModule",{value:!0}),e.CacheThrottle=e.CacheMode=void 0;const l=n(655),c=n(572);var d,u,h;!function(t){t.Debounce="debounce",t.Throttle="throttle"}(d=e.CacheMode||(e.CacheMode={})),function(t){t.Closed="closed",t.Idle="idle",t.Processing="processing"}(u||(u={})),function(t){t[t.Get=0]="Get",t[t.Set=1]="Set",t[t.GetOrSet=2]="GetOrSet",t[t.Del=3]="Del",t[t.Do=4]="Do"}(h||(h={}));e.CacheThrottle=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i.set(this,u.Idle),r.set(this,{}),o.set(this,void 0),s.set(this,[]),l.__classPrivateFieldSet(this,o,{mode:d.Debounce,ttl:0,...t},"f")}async get(t,e){const n=this.serializeKey(t),i=async()=>{const e=l.__classPrivateFieldGet(this,r,"f")[n],{mode:i,ttl:s,value:a}=null!=e?e:{};return!e||!s||i&&i!==d.Debounce||this.refreshTimeout(t,n,s),l.__classPrivateFieldGet(this,o,"f").clearPendingDeletes&&this.clearPendingDeletesOnKey(n,a),a};return e?i():this.enqueue(n,h.Get,i)}async set(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l.__classPrivateFieldGet(this,o,"f").ttl,i=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;const a=this.serializeKey(t),c=async()=>{const s=l.__classPrivateFieldGet(this,r,"f")[a],c=!!s;return l.__classPrivateFieldGet(this,r,"f")[a]={...s,mode:i,ttl:n,value:e},c&&i===d.Throttle||this.refreshTimeout(t,a,n),l.__classPrivateFieldGet(this,o,"f").clearPendingDeletes&&this.clearPendingDeletesOnKey(a,e),e};return s?c():this.enqueue(a,h.Set,c)}async getOrSet(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l.__classPrivateFieldGet(this,o,"f").ttl,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:l.__classPrivateFieldGet(this,o,"f").mode,s=arguments.length>4?arguments[4]:void 0;const a=this.serializeKey(t),c=async()=>{if(l.__classPrivateFieldGet(this,r,"f")[a])return l.__classPrivateFieldGet(this,r,"f")[a].value;const s=await e();return await this.set(t,s,n,i,!0),l.__classPrivateFieldGet(this,o,"f").clearPendingDeletes&&this.clearPendingDeletesOnKey(a,s),s};return s?c():this.enqueue(a,h.GetOrSet,c)}async del(t){let e=arguments.length>2?arguments[2]:void 0;const n=arguments.length>1&&void 0!==arguments[1]&&arguments[1]?t:this.serializeKey(t),i=async()=>{const t=l.__classPrivateFieldGet(this,r,"f")[n];let e;return(null==t?void 0:t.timeout)&&clearTimeout(t.timeout),t&&(e=t.value,delete l.__classPrivateFieldGet(this,r,"f")[n],await(async()=>{var t,n;return null===(n=(t=l.__classPrivateFieldGet(this,o,"f")).onDeregister)||void 0===n?void 0:n.call(t,e)})().catch((t=>{}))),e};return e?i():this.enqueue(n,h.Del,i)}keys(){return Object.keys(l.__classPrivateFieldGet(this,r,"f"))}async do(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l.__classPrivateFieldGet(this,o,"f").ttl,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:l.__classPrivateFieldGet(this,o,"f").mode;const s=this.serializeKey(t);return this.enqueue(s,h.Do,(async()=>{if(l.__classPrivateFieldGet(this,r,"f")[s])return l.__classPrivateFieldGet(this,r,"f")[s].value;const o=await e();return await this.set(t,o,n,i,!0)}))}async close(){l.__classPrivateFieldSet(this,i,u.Closed,"f"),await Promise.all(Object.keys(l.__classPrivateFieldGet(this,r,"f")).map((t=>this.del(t,!0,!0))))}refreshTimeout(t,e,n){if(l.__classPrivateFieldGet(this,i,"f")===u.Closed)return;const o=l.__classPrivateFieldGet(this,r,"f")[e];return n&&void 0!==(null==o?void 0:o.timeout)&&clearTimeout(o.timeout),n?(o.timeout=setTimeout((()=>this.del(t)),n),o.timeout):void 0}clearPendingDeletesOnKey(t,e){l.__classPrivateFieldSet(this,s,l.__classPrivateFieldGet(this,s,"f").filter((n=>{let[i,r,o,s]=n;return t!==i||r!==h.Del||(s.resolve(e),!1)})),"f")}serializeKey(t){var e,n,i;return null!==(i=null===(n=(e=l.__classPrivateFieldGet(this,o,"f")).serializeKey)||void 0===n?void 0:n.call(e,t))&&void 0!==i?i:t}async enqueue(t,e,n){const r=new c.DeferredPromise;return l.__classPrivateFieldGet(this,s,"f").push([t,e,n,r]),l.__classPrivateFieldGet(this,i,"f")===u.Idle&&this.flush(),r}flush(){l.__classPrivateFieldSet(this,i,u.Processing,"f"),a.nextTick((async()=>{for(;l.__classPrivateFieldGet(this,s,"f").length&&l.__classPrivateFieldGet(this,i,"f")!==u.Closed;){const t=l.__classPrivateFieldGet(this,s,"f").shift();if(t){const[,,e,n]=t;try{const t=await e();n.resolve(t)}catch(t){n.reject(t)}}}l.__classPrivateFieldSet(this,i,u.Idle,"f")}))}},i=new WeakMap,r=new WeakMap,o=new WeakMap,s=new WeakMap},715:(t,e,n)=>{var i=e;i.utils=n(436),i.common=n(772),i.sha=n(41),i.ripemd=n(949),i.hmac=n(326),i.sha1=i.sha.sha1,i.sha256=i.sha.sha256,i.sha224=i.sha.sha224,i.sha384=i.sha.sha384,i.sha512=i.sha.sha512,i.ripemd160=i.ripemd.ripemd160},772:(t,e,n)=>{"use strict";var i=n(436),r=n(746);function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}e.BlockHash=o,o.prototype.update=function(t,e){if(t=i.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var n=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-n,t.length),0===this.pending.length&&(this.pending=null),t=i.join32(t,0,t.length-n,this.endian);for(var r=0;r<t.length;r+=this._delta32)this._update(t,r,r+this._delta32)}return this},o.prototype.digest=function(t){return this.update(this._pad()),r(null===this.pending),this._digest(t)},o.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,n=e-(t+this.padLength)%e,i=new Array(n+this.padLength);i[0]=128;for(var r=1;r<n;r++)i[r]=0;if(t<<=3,"big"===this.endian){for(var o=8;o<this.padLength;o++)i[r++]=0;i[r++]=0,i[r++]=0,i[r++]=0,i[r++]=0,i[r++]=t>>>24&255,i[r++]=t>>>16&255,i[r++]=t>>>8&255,i[r++]=255&t}else for(i[r++]=255&t,i[r++]=t>>>8&255,i[r++]=t>>>16&255,i[r++]=t>>>24&255,i[r++]=0,i[r++]=0,i[r++]=0,i[r++]=0,o=8;o<this.padLength;o++)i[r++]=0;return i}},326:(t,e,n)=>{"use strict";var i=n(436),r=n(746);function o(t,e,n){if(!(this instanceof o))return new o(t,e,n);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(i.toArray(e,n))}t.exports=o,o.prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),r(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=(new this.Hash).update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=(new this.Hash).update(t)},o.prototype.update=function(t,e){return this.inner.update(t,e),this},o.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)}},949:(t,e,n)=>{"use strict";var i=n(436),r=n(772),o=i.rotl32,s=i.sum32,a=i.sum32_3,l=i.sum32_4,c=r.BlockHash;function d(){if(!(this instanceof d))return new d;c.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function u(t,e,n,i){return t<=15?e^n^i:t<=31?e&n|~e&i:t<=47?(e|~n)^i:t<=63?e&i|n&~i:e^(n|~i)}function h(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function p(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}i.inherits(d,c),e.ripemd160=d,d.blockSize=512,d.outSize=160,d.hmacStrength=192,d.padLength=64,d.prototype._update=function(t,e){for(var n=this.h[0],i=this.h[1],r=this.h[2],c=this.h[3],d=this.h[4],v=n,S=i,I=r,O=c,y=d,T=0;T<80;T++){var A=s(o(l(n,u(T,i,r,c),t[f[T]+e],h(T)),_[T]),d);n=d,d=c,c=o(r,10),r=i,i=A,A=s(o(l(v,u(79-T,S,I,O),t[g[T]+e],p(T)),E[T]),y),v=y,y=O,O=o(I,10),I=S,S=A}A=a(this.h[1],r,O),this.h[1]=a(this.h[2],c,y),this.h[2]=a(this.h[3],d,v),this.h[3]=a(this.h[4],n,S),this.h[4]=a(this.h[0],i,I),this.h[0]=A},d.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"little"):i.split32(this.h,"little")};var f=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],g=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],_=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],E=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},41:(t,e,n)=>{"use strict";e.sha1=n(761),e.sha224=n(799),e.sha256=n(344),e.sha384=n(978),e.sha512=n(900)},761:(t,e,n)=>{"use strict";var i=n(436),r=n(772),o=n(38),s=i.rotl32,a=i.sum32,l=i.sum32_5,c=o.ft_1,d=r.BlockHash,u=[1518500249,1859775393,2400959708,3395469782];function h(){if(!(this instanceof h))return new h;d.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}i.inherits(h,d),t.exports=h,h.blockSize=512,h.outSize=160,h.hmacStrength=80,h.padLength=64,h.prototype._update=function(t,e){for(var n=this.W,i=0;i<16;i++)n[i]=t[e+i];for(;i<n.length;i++)n[i]=s(n[i-3]^n[i-8]^n[i-14]^n[i-16],1);var r=this.h[0],o=this.h[1],d=this.h[2],h=this.h[3],p=this.h[4];for(i=0;i<n.length;i++){var f=~~(i/20),g=l(s(r,5),c(f,o,d,h),p,n[i],u[f]);p=h,h=d,d=s(o,30),o=r,r=g}this.h[0]=a(this.h[0],r),this.h[1]=a(this.h[1],o),this.h[2]=a(this.h[2],d),this.h[3]=a(this.h[3],h),this.h[4]=a(this.h[4],p)},h.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"big"):i.split32(this.h,"big")}},799:(t,e,n)=>{"use strict";var i=n(436),r=n(344);function o(){if(!(this instanceof o))return new o;r.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}i.inherits(o,r),t.exports=o,o.blockSize=512,o.outSize=224,o.hmacStrength=192,o.padLength=64,o.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h.slice(0,7),"big"):i.split32(this.h.slice(0,7),"big")}},344:(t,e,n)=>{"use strict";var i=n(436),r=n(772),o=n(38),s=n(746),a=i.sum32,l=i.sum32_4,c=i.sum32_5,d=o.ch32,u=o.maj32,h=o.s0_256,p=o.s1_256,f=o.g0_256,g=o.g1_256,_=r.BlockHash,E=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function v(){if(!(this instanceof v))return new v;_.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=E,this.W=new Array(64)}i.inherits(v,_),t.exports=v,v.blockSize=512,v.outSize=256,v.hmacStrength=192,v.padLength=64,v.prototype._update=function(t,e){for(var n=this.W,i=0;i<16;i++)n[i]=t[e+i];for(;i<n.length;i++)n[i]=l(g(n[i-2]),n[i-7],f(n[i-15]),n[i-16]);var r=this.h[0],o=this.h[1],_=this.h[2],E=this.h[3],v=this.h[4],S=this.h[5],I=this.h[6],O=this.h[7];for(s(this.k.length===n.length),i=0;i<n.length;i++){var y=c(O,p(v),d(v,S,I),this.k[i],n[i]),T=a(h(r),u(r,o,_));O=I,I=S,S=v,v=a(E,y),E=_,_=o,o=r,r=a(y,T)}this.h[0]=a(this.h[0],r),this.h[1]=a(this.h[1],o),this.h[2]=a(this.h[2],_),this.h[3]=a(this.h[3],E),this.h[4]=a(this.h[4],v),this.h[5]=a(this.h[5],S),this.h[6]=a(this.h[6],I),this.h[7]=a(this.h[7],O)},v.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"big"):i.split32(this.h,"big")}},978:(t,e,n)=>{"use strict";var i=n(436),r=n(900);function o(){if(!(this instanceof o))return new o;r.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}i.inherits(o,r),t.exports=o,o.blockSize=1024,o.outSize=384,o.hmacStrength=192,o.padLength=128,o.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h.slice(0,12),"big"):i.split32(this.h.slice(0,12),"big")}},900:(t,e,n)=>{"use strict";var i=n(436),r=n(772),o=n(746),s=i.rotr64_hi,a=i.rotr64_lo,l=i.shr64_hi,c=i.shr64_lo,d=i.sum64,u=i.sum64_hi,h=i.sum64_lo,p=i.sum64_4_hi,f=i.sum64_4_lo,g=i.sum64_5_hi,_=i.sum64_5_lo,E=r.BlockHash,v=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function S(){if(!(this instanceof S))return new S;E.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=v,this.W=new Array(160)}function I(t,e,n,i,r){var o=t&n^~t&r;return o<0&&(o+=4294967296),o}function O(t,e,n,i,r,o){var s=e&i^~e&o;return s<0&&(s+=4294967296),s}function y(t,e,n,i,r){var o=t&n^t&r^n&r;return o<0&&(o+=4294967296),o}function T(t,e,n,i,r,o){var s=e&i^e&o^i&o;return s<0&&(s+=4294967296),s}function A(t,e){var n=s(t,e,28)^s(e,t,2)^s(e,t,7);return n<0&&(n+=4294967296),n}function m(t,e){var n=a(t,e,28)^a(e,t,2)^a(e,t,7);return n<0&&(n+=4294967296),n}function C(t,e){var n=s(t,e,14)^s(t,e,18)^s(e,t,9);return n<0&&(n+=4294967296),n}function w(t,e){var n=a(t,e,14)^a(t,e,18)^a(e,t,9);return n<0&&(n+=4294967296),n}function N(t,e){var n=s(t,e,1)^s(t,e,8)^l(t,e,7);return n<0&&(n+=4294967296),n}function b(t,e){var n=a(t,e,1)^a(t,e,8)^c(t,e,7);return n<0&&(n+=4294967296),n}function P(t,e){var n=s(t,e,19)^s(e,t,29)^l(t,e,6);return n<0&&(n+=4294967296),n}function R(t,e){var n=a(t,e,19)^a(e,t,29)^c(t,e,6);return n<0&&(n+=4294967296),n}i.inherits(S,E),t.exports=S,S.blockSize=1024,S.outSize=512,S.hmacStrength=192,S.padLength=128,S.prototype._prepareBlock=function(t,e){for(var n=this.W,i=0;i<32;i++)n[i]=t[e+i];for(;i<n.length;i+=2){var r=P(n[i-4],n[i-3]),o=R(n[i-4],n[i-3]),s=n[i-14],a=n[i-13],l=N(n[i-30],n[i-29]),c=b(n[i-30],n[i-29]),d=n[i-32],u=n[i-31];n[i]=p(r,o,s,a,l,c,d,u),n[i+1]=f(r,o,s,a,l,c,d,u)}},S.prototype._update=function(t,e){this._prepareBlock(t,e);var n=this.W,i=this.h[0],r=this.h[1],s=this.h[2],a=this.h[3],l=this.h[4],c=this.h[5],p=this.h[6],f=this.h[7],E=this.h[8],v=this.h[9],S=this.h[10],N=this.h[11],b=this.h[12],P=this.h[13],R=this.h[14],L=this.h[15];o(this.k.length===n.length);for(var D=0;D<n.length;D+=2){var U=R,M=L,k=C(E,v),j=w(E,v),F=I(E,v,S,N,b),B=O(E,v,S,N,b,P),x=this.k[D],K=this.k[D+1],$=n[D],V=n[D+1],W=g(U,M,k,j,F,B,x,K,$,V),G=_(U,M,k,j,F,B,x,K,$,V);U=A(i,r),M=m(i,r),k=y(i,r,s,a,l),j=T(i,r,s,a,l,c);var H=u(U,M,k,j),q=h(U,M,k,j);R=b,L=P,b=S,P=N,S=E,N=v,E=u(p,f,W,G),v=h(f,f,W,G),p=l,f=c,l=s,c=a,s=i,a=r,i=u(W,G,H,q),r=h(W,G,H,q)}d(this.h,0,i,r),d(this.h,2,s,a),d(this.h,4,l,c),d(this.h,6,p,f),d(this.h,8,E,v),d(this.h,10,S,N),d(this.h,12,b,P),d(this.h,14,R,L)},S.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"big"):i.split32(this.h,"big")}},38:(t,e,n)=>{"use strict";var i=n(436).rotr32;function r(t,e,n){return t&e^~t&n}function o(t,e,n){return t&e^t&n^e&n}function s(t,e,n){return t^e^n}e.ft_1=function(t,e,n,i){return 0===t?r(e,n,i):1===t||3===t?s(e,n,i):2===t?o(e,n,i):void 0},e.ch32=r,e.maj32=o,e.p32=s,e.s0_256=function(t){return i(t,2)^i(t,13)^i(t,22)},e.s1_256=function(t){return i(t,6)^i(t,11)^i(t,25)},e.g0_256=function(t){return i(t,7)^i(t,18)^t>>>3},e.g1_256=function(t){return i(t,17)^i(t,19)^t>>>10}},436:(t,e,n)=>{"use strict";var i=n(746),r=n(717);function o(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function s(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function l(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}e.inherits=r,e.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var n=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),r=0;r<t.length;r+=2)n.push(parseInt(t[r]+t[r+1],16))}else for(var i=0,r=0;r<t.length;r++){var s=t.charCodeAt(r);s<128?n[i++]=s:s<2048?(n[i++]=s>>6|192,n[i++]=63&s|128):o(t,r)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++r)),n[i++]=s>>18|240,n[i++]=s>>12&63|128,n[i++]=s>>6&63|128,n[i++]=63&s|128):(n[i++]=s>>12|224,n[i++]=s>>6&63|128,n[i++]=63&s|128)}else for(r=0;r<t.length;r++)n[r]=0|t[r];return n},e.toHex=function(t){for(var e="",n=0;n<t.length;n++)e+=a(t[n].toString(16));return e},e.htonl=s,e.toHex32=function(t,e){for(var n="",i=0;i<t.length;i++){var r=t[i];"little"===e&&(r=s(r)),n+=l(r.toString(16))}return n},e.zero2=a,e.zero8=l,e.join32=function(t,e,n,r){var o=n-e;i(o%4==0);for(var s=new Array(o/4),a=0,l=e;a<s.length;a++,l+=4){var c;c="big"===r?t[l]<<24|t[l+1]<<16|t[l+2]<<8|t[l+3]:t[l+3]<<24|t[l+2]<<16|t[l+1]<<8|t[l],s[a]=c>>>0}return s},e.split32=function(t,e){for(var n=new Array(4*t.length),i=0,r=0;i<t.length;i++,r+=4){var o=t[i];"big"===e?(n[r]=o>>>24,n[r+1]=o>>>16&255,n[r+2]=o>>>8&255,n[r+3]=255&o):(n[r+3]=o>>>24,n[r+2]=o>>>16&255,n[r+1]=o>>>8&255,n[r]=255&o)}return n},e.rotr32=function(t,e){return t>>>e|t<<32-e},e.rotl32=function(t,e){return t<<e|t>>>32-e},e.sum32=function(t,e){return t+e>>>0},e.sum32_3=function(t,e,n){return t+e+n>>>0},e.sum32_4=function(t,e,n,i){return t+e+n+i>>>0},e.sum32_5=function(t,e,n,i,r){return t+e+n+i+r>>>0},e.sum64=function(t,e,n,i){var r=t[e],o=i+t[e+1]>>>0,s=(o<i?1:0)+n+r;t[e]=s>>>0,t[e+1]=o},e.sum64_hi=function(t,e,n,i){return(e+i>>>0<e?1:0)+t+n>>>0},e.sum64_lo=function(t,e,n,i){return e+i>>>0},e.sum64_4_hi=function(t,e,n,i,r,o,s,a){var l=0,c=e;return l+=(c=c+i>>>0)<e?1:0,l+=(c=c+o>>>0)<o?1:0,t+n+r+s+(l+=(c=c+a>>>0)<a?1:0)>>>0},e.sum64_4_lo=function(t,e,n,i,r,o,s,a){return e+i+o+a>>>0},e.sum64_5_hi=function(t,e,n,i,r,o,s,a,l,c){var d=0,u=e;return d+=(u=u+i>>>0)<e?1:0,d+=(u=u+o>>>0)<o?1:0,d+=(u=u+a>>>0)<a?1:0,t+n+r+s+l+(d+=(u=u+c>>>0)<c?1:0)>>>0},e.sum64_5_lo=function(t,e,n,i,r,o,s,a,l,c){return e+i+o+a+c>>>0},e.rotr64_hi=function(t,e,n){return(e<<32-n|t>>>n)>>>0},e.rotr64_lo=function(t,e,n){return(t<<32-n|e>>>n)>>>0},e.shr64_hi=function(t,e,n){return t>>>n},e.shr64_lo=function(t,e,n){return(t<<32-n|e>>>n)>>>0}},717:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}}},245:(t,e,n)=>{"use strict";function i(t){this.message=t}n.r(e),n.d(e,{InvalidTokenError:()=>s,default:()=>a}),i.prototype=new Error,i.prototype.name="InvalidCharacterError";var r="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new i("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,o=0,s=0,a="";r=e.charAt(s++);~r&&(n=o%4?64*n+r:r,o++%4)?a+=String.fromCharCode(255&n>>(-2*o&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return a};function o(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(r(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return r(e)}}function s(t){this.message=t}s.prototype=new Error,s.prototype.name="InvalidTokenError";const a=function(t,e){if("string"!=typeof t)throw new s("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(o(t.split(".")[n]))}catch(t){throw new s("Invalid token specified: "+t.message)}}},746:t=>{function e(t,e){if(!t)throw new Error(e||"Assertion failed")}t.exports=e,e.equal=function(t,e,n){if(t!=e)throw new Error(n||"Assertion failed: "+t+" != "+e)}},155:t=>{var e,n,i=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(t){if(e===setTimeout)return setTimeout(t,0);if((e===r||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(n){try{return e.call(null,t,0)}catch(n){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:r}catch(t){e=r}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var a,l=[],c=!1,d=-1;function u(){c&&a&&(c=!1,a.length?l=a.concat(l):d=-1,l.length&&h())}function h(){if(!c){var t=s(u);c=!0;for(var e=l.length;e;){for(a=l,l=[];++d<e;)a&&a[d].run();d=-1,e=l.length}a=null,c=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===o||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{return n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function f(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];l.push(new p(t,e)),1!==l.length||c||s(h)},p.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=f,i.addListener=f,i.once=f,i.off=f,i.removeListener=f,i.removeAllListeners=f,i.emit=f,i.prependListener=f,i.prependOnceListener=f,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},655:(t,e,n)=>{"use strict";n.r(e),n.d(e,{__assign:()=>o,__asyncDelegator:()=>O,__asyncGenerator:()=>I,__asyncValues:()=>y,__await:()=>S,__awaiter:()=>d,__classPrivateFieldGet:()=>w,__classPrivateFieldSet:()=>N,__createBinding:()=>h,__decorate:()=>a,__exportStar:()=>p,__extends:()=>r,__generator:()=>u,__importDefault:()=>C,__importStar:()=>m,__makeTemplateObject:()=>T,__metadata:()=>c,__param:()=>l,__read:()=>g,__rest:()=>s,__spread:()=>_,__spreadArray:()=>v,__spreadArrays:()=>E,__values:()=>f});var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)};function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){return o=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},o.apply(this,arguments)};function s(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]])}return n}function a(t,e,n,i){var r,o=arguments.length,s=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,n,s):r(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s}function l(t,e){return function(n,i){e(n,i,t)}}function c(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function d(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))}function u(t,e){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}var h=Object.create?function(t,e,n,i){void 0===i&&(i=n),Object.defineProperty(t,i,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]};function p(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||h(e,t,n)}function f(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){r={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return s}function _(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(g(arguments[e]));return t}function E(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var i=Array(t),r=0;for(e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)i[r]=o[s];return i}function v(t,e,n){if(n||2===arguments.length)for(var i,r=0,o=e.length;r<o;r++)!i&&r in e||(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}function S(t){return this instanceof S?(this.v=t,this):new S(t)}function I(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=n.apply(t,e||[]),o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(t){r[t]&&(i[t]=function(e){return new Promise((function(n,i){o.push([t,e,n,i])>1||a(t,e)}))})}function a(t,e){try{(n=r[t](e)).value instanceof S?Promise.resolve(n.value.v).then(l,c):d(o[0][2],n)}catch(t){d(o[0][3],t)}var n}function l(t){a("next",t)}function c(t){a("throw",t)}function d(t,e){t(e),o.shift(),o.length&&a(o[0][0],o[0][1])}}function O(t){var e,n;return e={},i("next"),i("throw",(function(t){throw t})),i("return"),e[Symbol.iterator]=function(){return this},e;function i(i,r){e[i]=t[i]?function(e){return(n=!n)?{value:S(t[i](e)),done:"return"===i}:r?r(e):e}:r}}function y(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=f(t),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(n){e[n]=t[n]&&function(e){return new Promise((function(i,r){(function(t,e,n,i){Promise.resolve(i).then((function(e){t({value:e,done:n})}),e)})(i,r,(e=t[n](e)).done,e.value)}))}}}function T(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}var A=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e};function m(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&h(e,t,n);return A(e,t),e}function C(t){return t&&t.__esModule?t:{default:t}}function w(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function N(t,e,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(t,n):r?r.value=n:e.set(t,n),n}}},e={};function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i=n(56);module.exports=i})();
|
|
@@ -1,25 +1,12 @@
|
|
|
1
1
|
import { ConnectCredentialProviderData, CredentialStatus, IConnectCredential } from '../entities/connectCredential.interface';
|
|
2
|
-
import { ConnectCredentialConfigMeta, IConnectCredentialConfig } from '../entities/connectCredentialConfig.interface';
|
|
3
2
|
import { PersonaMeta } from '../entities/persona.interface';
|
|
4
3
|
import { AccountType, DataSource, IntegrationConnectInput, SidebarInputType } from './action';
|
|
5
4
|
import { OrConditions } from './resolvers';
|
|
6
|
-
|
|
7
|
-
export interface SDKConnectCredentialConfig {
|
|
8
|
-
sharedSettings?: IntegrationSharedInputStateMap;
|
|
9
|
-
workflowSettings?: IntegrationWorkflowStateMap;
|
|
10
|
-
configMeta?: ConnectCredentialConfigMeta;
|
|
11
|
-
/**
|
|
12
|
-
* this refer `externalId` of credential config containing shared/workflow settings
|
|
13
|
-
*/
|
|
14
|
-
externalId?: string;
|
|
15
|
-
/**
|
|
16
|
-
* @deprecated - use `workflowSettings`
|
|
17
|
-
*/
|
|
5
|
+
export interface ConnectCredentialConfig {
|
|
18
6
|
configuredWorkflows?: IntegrationWorkflowStateMap;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
isIntegrationEnableTriggered?: boolean;
|
|
7
|
+
sharedSettings?: {
|
|
8
|
+
[inputId: string]: ConnectInputValue | undefined;
|
|
9
|
+
};
|
|
23
10
|
}
|
|
24
11
|
type ConnectInputValue = string | number | boolean | FieldMappingValue | ComboInputValue | undefined;
|
|
25
12
|
type FieldMappingValue = {
|
|
@@ -47,12 +34,9 @@ type ComboInputValue = {
|
|
|
47
34
|
[label: string]: string | undefined;
|
|
48
35
|
};
|
|
49
36
|
};
|
|
50
|
-
|
|
37
|
+
type IntegrationWorkflowStateMap = {
|
|
51
38
|
[workflowId: string]: IntegrationWorkflowState | undefined;
|
|
52
39
|
};
|
|
53
|
-
export type IntegrationSharedInputStateMap = {
|
|
54
|
-
[inputId: string]: ConnectInputValue | undefined;
|
|
55
|
-
};
|
|
56
40
|
export type IntegrationWorkflowState = {
|
|
57
41
|
enabled: boolean;
|
|
58
42
|
settings: {
|
|
@@ -189,13 +173,11 @@ export type SDKResourceState = {
|
|
|
189
173
|
export type SDKIntegration = {
|
|
190
174
|
enabled: boolean;
|
|
191
175
|
credentialId?: string;
|
|
192
|
-
credentialConfigId?: string;
|
|
193
176
|
credentialStatus?: CredentialStatus;
|
|
194
177
|
providerId?: string;
|
|
195
178
|
providerData?: ConnectCredentialProviderData;
|
|
196
179
|
allCredentials: IConnectCredential[];
|
|
197
|
-
|
|
198
|
-
} & SDKConnectCredentialConfig;
|
|
180
|
+
} & ConnectCredentialConfig;
|
|
199
181
|
export type SDKIntegrationConfig = {
|
|
200
182
|
oauthInputs: IntegrationConnectInput[];
|
|
201
183
|
accountTypes: AccountType[];
|
|
@@ -212,8 +194,12 @@ export type SDKIntegrationConfig = {
|
|
|
212
194
|
* available entities.
|
|
213
195
|
*/
|
|
214
196
|
export type SDKIntegrationState = Partial<Record<string, SDKIntegration>>;
|
|
215
|
-
export type UninstallOptions =
|
|
216
|
-
|
|
197
|
+
export type UninstallOptions = {
|
|
198
|
+
selectedCredentialId?: string;
|
|
199
|
+
};
|
|
200
|
+
export type DisableWorkflowOptions = {
|
|
201
|
+
selectedCredentialId?: string;
|
|
202
|
+
};
|
|
217
203
|
/**
|
|
218
204
|
* method options for getIntegrationAccount in sdk
|
|
219
205
|
*/
|
|
@@ -224,5 +210,4 @@ export type GetIntegrationAccountOptions = {
|
|
|
224
210
|
export type IConnectUser = Omit<AuthenticatedConnectUser, 'token'>;
|
|
225
211
|
export declare const INFER_CONTENT_TYPE_FROM_CONNECT_OPTIONS = "auto";
|
|
226
212
|
export declare const SELECTED_CREDENTIAL_ID_HEADER = "X-Paragon-Credential";
|
|
227
|
-
export declare const SELECTED_CREDENTIAL_CONFIG_ID_HEADER = "X-Paragon-Configuration-Id";
|
|
228
213
|
export {};
|
package/dist/src/types/sdk.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import ConnectSDK from '../ConnectSDK';
|
|
2
2
|
import { IConnectCredential } from '../entities/connectCredential.interface';
|
|
3
|
-
import { IConnectCredentialConfig } from '../entities/connectCredentialConfig.interface';
|
|
4
3
|
import { OauthCallbackResponse } from '../entities/credential.interface';
|
|
5
4
|
import { IConnectIntegrationWithCredentialInfo, IIntegrationMetadata } from '../entities/integration.interface';
|
|
6
5
|
import { PersonaMeta } from '../entities/persona.interface';
|
|
@@ -89,10 +88,6 @@ export interface IConnectSDK {
|
|
|
89
88
|
* disables a workflow for the connected user and unsubscribes all the workflows in hermes
|
|
90
89
|
*/
|
|
91
90
|
disableWorkflow(workflowId: string, options: DisableWorkflowOptions): Promise<void>;
|
|
92
|
-
/**
|
|
93
|
-
* enables a workflow for the connected user and subscribe the workflows in hermes
|
|
94
|
-
*/
|
|
95
|
-
enableWorkflow(workflowId: string, options: CredentialConfigOptions): Promise<void>;
|
|
96
91
|
setUserMetadata(meta: PersonaMeta): Promise<AuthenticatedConnectUser>;
|
|
97
92
|
/**
|
|
98
93
|
* sets the base url for different services used in connect sdk
|
|
@@ -112,7 +107,7 @@ export interface IConnectSDK {
|
|
|
112
107
|
* @param name eventName
|
|
113
108
|
* @param payload event payload object
|
|
114
109
|
*/
|
|
115
|
-
event(name: string, payload: Record<string, unknown
|
|
110
|
+
event(name: string, payload: Record<string, unknown>): Promise<void>;
|
|
116
111
|
/**
|
|
117
112
|
* makes an connect proxy action request
|
|
118
113
|
* @param action actionName
|
|
@@ -165,26 +160,6 @@ export interface IConnectSDK {
|
|
|
165
160
|
* Closing the portal by invoking this method
|
|
166
161
|
*/
|
|
167
162
|
closePortal(): void;
|
|
168
|
-
/**
|
|
169
|
-
* Creates a new configuration using the provided credentials.
|
|
170
|
-
*
|
|
171
|
-
* @param {CreateConfigurationOptions} params - An object containing the necessary parameters.
|
|
172
|
-
* @param {string} params.credentialId - The ID of the credential to create the configuration for.
|
|
173
|
-
* @param {string} params.externalId - (Optional) An external identifier associated with the configuration.
|
|
174
|
-
* @returns {Promise<ICreateConfiguration>} - A promise that resolves to the created configuration object.
|
|
175
|
-
*/
|
|
176
|
-
createConfiguration(params: CreateConfigurationOptions): Promise<IConnectCredentialConfig>;
|
|
177
|
-
/**
|
|
178
|
-
* Destroys an existing configuration using the provided instance ID.
|
|
179
|
-
*
|
|
180
|
-
* @param {DestroyConfigurationParams} params - An object containing the necessary parameters.
|
|
181
|
-
* @param {string} params.id - The ID of the configuration to be destroyed.
|
|
182
|
-
* @returns {Promise<void>} - A promise that resolves when the configuration is successfully destroyed.
|
|
183
|
-
*/
|
|
184
|
-
destroyConfiguration(params: {
|
|
185
|
-
id: string;
|
|
186
|
-
}): Promise<void>;
|
|
187
|
-
updateConfiguration(dto: UpdateConfigurationOptions): Promise<IConnectCredentialConfig>;
|
|
188
163
|
}
|
|
189
164
|
/**
|
|
190
165
|
* sdk install options
|
|
@@ -207,28 +182,12 @@ export type InstallOptions = {
|
|
|
207
182
|
*/
|
|
208
183
|
accountType?: string;
|
|
209
184
|
allowMultipleCredentials?: boolean;
|
|
185
|
+
selectedCredentialId?: string;
|
|
210
186
|
/**
|
|
211
187
|
* used to override redirect url passed in getAuthUrl instead of our passport url
|
|
212
188
|
*/
|
|
213
189
|
overrideRedirectUrl?: string;
|
|
214
190
|
};
|
|
215
|
-
export type CredentialConfigOptions = {
|
|
216
|
-
selectedCredentialId?: string;
|
|
217
|
-
selectedConfigurationId?: string;
|
|
218
|
-
};
|
|
219
|
-
export type CreateConfigurationOptions = {
|
|
220
|
-
credentialId: string;
|
|
221
|
-
externalId?: string;
|
|
222
|
-
};
|
|
223
|
-
export type DeleteConfigurationOptions = {
|
|
224
|
-
id: string;
|
|
225
|
-
credentialId: string;
|
|
226
|
-
};
|
|
227
|
-
export type UpdateConfigurationOptions = {
|
|
228
|
-
id: string;
|
|
229
|
-
credentialId: string;
|
|
230
|
-
meta: Record<string, unknown>;
|
|
231
|
-
};
|
|
232
191
|
export type AuthenticateOptions = {
|
|
233
192
|
metadata?: PersonaMeta;
|
|
234
193
|
};
|
|
@@ -275,7 +234,7 @@ export type UserProvidedIntegrationConfig = {
|
|
|
275
234
|
[objectName: string]: DynamicMappingField[] | DynamicMappingOptions;
|
|
276
235
|
};
|
|
277
236
|
};
|
|
278
|
-
export type ConnectParams = CallbackMap & UserProvidedIntegrationConfig & InstallOptions
|
|
237
|
+
export type ConnectParams = CallbackMap & UserProvidedIntegrationConfig & InstallOptions;
|
|
279
238
|
export type EventInfo = {
|
|
280
239
|
type: SDK_EVENT;
|
|
281
240
|
integrationId: string;
|
|
@@ -303,10 +262,11 @@ export declare enum DocumentLoadingState {
|
|
|
303
262
|
INTERACTIVE = "interactive",
|
|
304
263
|
COMPLETE = "complete"
|
|
305
264
|
}
|
|
306
|
-
export type TriggerWorkflowRequest =
|
|
265
|
+
export type TriggerWorkflowRequest = {
|
|
307
266
|
body?: RequestInit['body'] | object;
|
|
308
267
|
headers?: RequestInit['headers'];
|
|
309
268
|
query?: Record<string, string>;
|
|
269
|
+
selectedCredentialId?: string;
|
|
310
270
|
};
|
|
311
271
|
export interface IFilePicker {
|
|
312
272
|
/**
|
|
@@ -11,9 +11,3 @@ export declare const getAssetUrl: ({ CDN_PUBLIC_URL: cdnHost, DASHBOARD_PUBLIC_U
|
|
|
11
11
|
PLATFORM_ENV: string;
|
|
12
12
|
VERSION: string;
|
|
13
13
|
}) => string;
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @param externalId
|
|
17
|
-
* @returns
|
|
18
|
-
*/
|
|
19
|
-
export declare function sanitizeExternalConfigId(externalId: string): string;
|
|
@@ -28,8 +28,6 @@ export declare function generateMatrix<T extends Record<string, any>>(input: {
|
|
|
28
28
|
[k in keyof T]: T[k][];
|
|
29
29
|
}, limit?: number): T[];
|
|
30
30
|
export declare function sleep(milliseconds: number): Promise<void>;
|
|
31
|
-
export declare const uuidPattern: RegExp;
|
|
32
|
-
export declare function isUUID(value: string | unknown): boolean;
|
|
33
31
|
/**
|
|
34
32
|
* keeps attempting to execute a method until a desired result is achieved
|
|
35
33
|
*
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useparagon/connect",
|
|
3
|
-
"version": "1.0.20
|
|
3
|
+
"version": "1.0.20",
|
|
4
4
|
"description": "Embed integrations into your app with the Paragon SDK",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
7
7
|
"exports": "./dist/src/index.js",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"start:dev": "NODE_ENV=development webpack serve",
|
|
10
9
|
"build:prod": "yarn typecheck && yarn clean && webpack --config webpack.config.js",
|
|
11
10
|
"build:watch": "yarn build --watch",
|
|
12
11
|
"build": "yarn typecheck && yarn clean && webpack --config webpack.config.js",
|
|
@@ -61,12 +60,10 @@
|
|
|
61
60
|
"eslint-plugin-react-hooks": "^4.4.0",
|
|
62
61
|
"eslint-plugin-unicorn": "^41.0.0",
|
|
63
62
|
"glob": "^10.3.10",
|
|
64
|
-
"html-webpack-plugin": "^5.6.3",
|
|
65
63
|
"jest": "^27.0.6",
|
|
66
64
|
"jest-fetch-mock": "useparagon/jest-fetch-mock.git#3.0.4",
|
|
67
65
|
"jest-json": "^1.0.4",
|
|
68
66
|
"jest-json-reporter2": "^1.1.0",
|
|
69
|
-
"jsonwebtoken": "^9.0.2",
|
|
70
67
|
"node-notifier": "^10.0.0",
|
|
71
68
|
"nyc": "^15.1.0",
|
|
72
69
|
"pkg": "^5.8.1",
|
|
@@ -87,8 +84,7 @@
|
|
|
87
84
|
"uuid": "^9.0.0",
|
|
88
85
|
"webpack": "^5.75.0",
|
|
89
86
|
"webpack-bundle-analyzer": "^4.3.0",
|
|
90
|
-
"webpack-cli": "^5.0.2"
|
|
91
|
-
"webpack-dev-server": "^5.1.0"
|
|
87
|
+
"webpack-cli": "^5.0.2"
|
|
92
88
|
},
|
|
93
89
|
"license": "MIT",
|
|
94
90
|
"pkg": {
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { IntegrationSharedInputStateMap, IntegrationWorkflowStateMap } from '../types';
|
|
2
|
-
import { IBaseEntity } from './base.entity';
|
|
3
|
-
export type ConnectCredentialConfigMeta = {
|
|
4
|
-
isIntegrationEnableTriggered?: boolean;
|
|
5
|
-
};
|
|
6
|
-
export interface IConnectCredentialConfig extends IBaseEntity {
|
|
7
|
-
/**
|
|
8
|
-
* connect credential id config is associated to
|
|
9
|
-
*/
|
|
10
|
-
connectCredentialId: string;
|
|
11
|
-
/**
|
|
12
|
-
* workflow settings defined for config
|
|
13
|
-
*/
|
|
14
|
-
workflowSettings: IntegrationWorkflowStateMap;
|
|
15
|
-
/**
|
|
16
|
-
* shared settings defined for config
|
|
17
|
-
*/
|
|
18
|
-
sharedSettings: IntegrationSharedInputStateMap;
|
|
19
|
-
/**
|
|
20
|
-
* other information defined ex. postOauthFilled , triggered integration enabled workflow
|
|
21
|
-
*/
|
|
22
|
-
configMeta: ConnectCredentialConfigMeta;
|
|
23
|
-
/**
|
|
24
|
-
* id defined by user for config
|
|
25
|
-
*/
|
|
26
|
-
externalId?: string;
|
|
27
|
-
/**
|
|
28
|
-
* if this config is default config or created separately by sdk
|
|
29
|
-
*/
|
|
30
|
-
isDefault: boolean;
|
|
31
|
-
}
|
package/sandbox/index.html
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<style>
|
|
5
|
-
|
|
6
|
-
html,
|
|
7
|
-
body {
|
|
8
|
-
height: 100%;
|
|
9
|
-
width: 100%;
|
|
10
|
-
display: flex;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
#container {
|
|
14
|
-
width: 49vw;
|
|
15
|
-
height: 100vh;
|
|
16
|
-
float: left;
|
|
17
|
-
font-family: system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Liberation Sans",sans-serif;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
#paragon-connect-frame-container {
|
|
21
|
-
position: relative;
|
|
22
|
-
width: 50vw;
|
|
23
|
-
height: 100vh;
|
|
24
|
-
float: right;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.wrapper {
|
|
28
|
-
margin: 0 auto;
|
|
29
|
-
margin-bottom: 30px;
|
|
30
|
-
display: block;
|
|
31
|
-
width: 350px;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.wrapper input,
|
|
35
|
-
.wrapper textarea,
|
|
36
|
-
.wrapper select {
|
|
37
|
-
width: 100%;
|
|
38
|
-
padding: 3px 5px;
|
|
39
|
-
box-sizing: border-box;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.wrapper textarea {
|
|
43
|
-
height: 150px;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.wrapper textarea {
|
|
47
|
-
display: block;
|
|
48
|
-
clear: both;
|
|
49
|
-
}
|
|
50
|
-
</style>
|
|
51
|
-
</head>
|
|
52
|
-
<body>
|
|
53
|
-
<div id="container">
|
|
54
|
-
<div class="wrapper">
|
|
55
|
-
<h3>Project ID</h3>
|
|
56
|
-
<input id="project-id" data-testid="project-id" />
|
|
57
|
-
</div>
|
|
58
|
-
|
|
59
|
-
<div class="wrapper">
|
|
60
|
-
<h3>User Token</h3>
|
|
61
|
-
<input id="token" data-testid="user-token" />
|
|
62
|
-
</div>
|
|
63
|
-
|
|
64
|
-
<div class="wrapper">
|
|
65
|
-
<button id="authenticate" data-testid="authenticate" onclick="authenticate();">
|
|
66
|
-
Authenticate
|
|
67
|
-
</button>
|
|
68
|
-
</div>
|
|
69
|
-
|
|
70
|
-
<div class="wrapper">
|
|
71
|
-
<button onclick="evalCode();" data-testid="run-code">Run code</button>
|
|
72
|
-
<textarea id="eval-input" data-testid="code"></textarea>
|
|
73
|
-
</div>
|
|
74
|
-
|
|
75
|
-
</div>
|
|
76
|
-
|
|
77
|
-
<div id="paragon-connect-frame-container"></div>
|
|
78
|
-
|
|
79
|
-
<script>
|
|
80
|
-
setCookie = function(name, value, daysToLive) {
|
|
81
|
-
const d = new Date();
|
|
82
|
-
d.setTime(d.getTime() + (daysToLive*24*60*60*1000));
|
|
83
|
-
let expires = "expires="+ d.toUTCString();
|
|
84
|
-
document.cookie = name + "=" + value + ";" + expires + ";path=/";
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
getCookie = function(name) {
|
|
88
|
-
const cookieArr = document.cookie.split(';');
|
|
89
|
-
for(let i = 0; i < cookieArr.length; i++) {
|
|
90
|
-
const cookiePair = cookieArr[i].split('=');
|
|
91
|
-
if(name == cookiePair[0].trim()) {
|
|
92
|
-
return decodeURIComponent(cookiePair[1]);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
window.authenticate = function() {
|
|
99
|
-
if (!window.paragon) {
|
|
100
|
-
if(!window.isScriptLoaded) {
|
|
101
|
-
loadScript(window.authenticate);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
alert('"window.paragon" is undefined!');
|
|
105
|
-
}
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const projectId = document.getElementById('project-id').value;
|
|
110
|
-
const userToken = document.getElementById('token').value;
|
|
111
|
-
|
|
112
|
-
if (!projectId) {
|
|
113
|
-
alert('Project id is empty!')
|
|
114
|
-
return;
|
|
115
|
-
} else if (!userToken) {
|
|
116
|
-
alert('User token is empty!')
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
paragon.authenticate(projectId, userToken);
|
|
121
|
-
const dataToStore = {'project-id': projectId, 'token': userToken};
|
|
122
|
-
setCookie('__paragon_sandbox_storage__', JSON.stringify(dataToStore), 14);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
window.isScriptLoaded = false;
|
|
126
|
-
|
|
127
|
-
window.loadScript = function(callBack) {
|
|
128
|
-
if (window.isScriptLoaded) {
|
|
129
|
-
alert('Already loaded script. Please refresh and try again.');
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const scriptUrl = document.getElementById('script-url').value;
|
|
133
|
-
const script = document.createElement('script');
|
|
134
|
-
script.type = "text/javascript";
|
|
135
|
-
script.src = scriptUrl;
|
|
136
|
-
if(callBack) {
|
|
137
|
-
script.onload = callBack;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
document.head.appendChild(script);
|
|
141
|
-
window.isScriptLoaded = true;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
window.evalCode = function() {
|
|
145
|
-
const code = document.getElementById('eval-input').value;
|
|
146
|
-
eval(code);
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
window.onload = function() {
|
|
150
|
-
const formState = JSON.parse(getCookie('__paragon_sandbox_storage__'));
|
|
151
|
-
if(formState) {
|
|
152
|
-
const formFields = Object.keys(formState);
|
|
153
|
-
for(let i = 0; i < formFields.length; i++) {
|
|
154
|
-
const field = formFields[i];
|
|
155
|
-
document.getElementById(field).value = formState[field];
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
</script>
|
|
160
|
-
</body>
|
|
161
|
-
</html>
|