@useparagon/connect 1.0.19 → 1.0.20-experimental.2

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.
@@ -1,10 +1,11 @@
1
1
  import { IConnectCredential } from './entities/connectCredential.interface';
2
+ import { IConnectCredentialConfig } from './entities/connectCredentialConfig.interface';
2
3
  import { OauthCallbackResponse } from './entities/credential.interface';
3
4
  import { IConnectIntegrationWithCredentialInfo, IIntegrationMetadata } from './entities/integration.interface';
4
5
  import { PersonaMeta } from './entities/persona.interface';
5
6
  import SDKEventEmitter from './SDKEventEmitter';
6
7
  import { ConnectSdkEnvironments } from './server.types';
7
- import { AuthenticateOptions, AuthenticatedConnectUser, CompleteInstallOptions, Props as ConnectModalProps, ConnectParams, ConnectUser, DisableWorkflowOptions, EventInfo, GetIntegrationAccountOptions, IConnectSDK, InstallIntegrationOptions, TriggerWorkflowRequest, UninstallOptions } from './types';
8
+ import { AuthenticateOptions, AuthenticatedConnectUser, CompleteInstallOptions, Props as ConnectModalProps, ConnectParams, ConnectUser, CreateConfigurationOptions, CredentialConfigOptions, DisableWorkflowOptions, EventInfo, GetIntegrationAccountOptions, IConnectSDK, InstallIntegrationOptions, TriggerWorkflowRequest, UninstallOptions } from './types';
8
9
  export declare const PARAGON_OVERFLOW_EMPTY_VALUE = "PARAGON_OVERFLOW_EMPTY_VALUE";
9
10
  export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
10
11
  root: HTMLIFrameElement | undefined;
@@ -52,7 +53,7 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
52
53
  private createReactRoot;
53
54
  /**
54
55
  * checks
55
- * - if integartion name is valid
56
+ * - if integration name is valid
56
57
  * - if integration is setup in project
57
58
  * - if integration is active in project
58
59
  * throws error if any of these is not met
@@ -115,6 +116,8 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
115
116
  * Display the Paragon Connect modal
116
117
  */
117
118
  connect(action: string, params?: ConnectParams): Promise<void>;
119
+ private setCredentialConfigForUserState;
120
+ private getCredentialAndConfig;
118
121
  /**
119
122
  * Retrieves an integration object from the loaded integrations based on the integration ID.
120
123
  * @param integrationId The ID of the integration to retrieve.
@@ -149,7 +152,7 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
149
152
  body: RequestInit['body'] | object;
150
153
  headers: RequestInit['headers'];
151
154
  }): Promise<TResponse | undefined>;
152
- event(name: string, payload: Record<string, unknown>): Promise<void>;
155
+ event(name: string, payload: Record<string, unknown>, options?: CredentialConfigOptions): Promise<void>;
153
156
  /**
154
157
  * @summary this will be called to close the modal
155
158
  * @param forceClose is set when modal is closed by cross btn
@@ -182,7 +185,7 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
182
185
  * @param workflowId
183
186
  * @param payload
184
187
  */
185
- workflow(workflowId: string, { selectedCredentialId, body, query, headers }?: TriggerWorkflowRequest): Promise<object | undefined>;
188
+ workflow(workflowId: string, { selectedCredentialId, selectedConfigurationId, body, query, headers, }?: TriggerWorkflowRequest): Promise<object | undefined>;
186
189
  /**
187
190
  * for programmatically installing an integration
188
191
  */
@@ -193,6 +196,7 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
193
196
  ensureHeadlessIsSupported(): void;
194
197
  uninstallIntegration(action: string, options?: UninstallOptions): Promise<void>;
195
198
  disableWorkflow(workflowId: string, options?: DisableWorkflowOptions): Promise<void>;
199
+ enableWorkflow(workflowId: string, options?: CredentialConfigOptions): Promise<void>;
196
200
  /**
197
201
  * Get account details by integration type. To get accountAuth, includeAccountAuth should be true in options.
198
202
  * Note that accountAuth is allowed for only some of the integrations.
@@ -200,10 +204,6 @@ export default class ConnectSDK extends SDKEventEmitter implements IConnectSDK {
200
204
  getIntegrationAccount(integrationType: string, options?: GetIntegrationAccountOptions): Promise<IConnectIntegrationWithCredentialInfo>;
201
205
  private getIntegrationForWorkflow;
202
206
  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,4 +246,17 @@ 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 }: {
259
+ id: string;
260
+ }): Promise<void>;
261
+ updateConfiguration(id: string, meta: Record<string, unknown>, credentialId?: string): Promise<IConnectCredentialConfig>;
249
262
  }
@@ -1,9 +1,9 @@
1
- import { ConnectCredentialConfig } from '../types/connect';
1
+ import { IConnectCredentialConfig } from './connectCredentialConfig.interface';
2
2
  export interface IConnectCredential {
3
3
  id: string;
4
4
  projectId: string;
5
5
  integrationId: string;
6
- config: ConnectCredentialConfig;
6
+ configurations: IConnectCredentialConfig[];
7
7
  personaId: string;
8
8
  isPreviewCredential: boolean;
9
9
  /**
@@ -0,0 +1,31 @@
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
+ }
@@ -2,6 +2,8 @@ import { IConnectIntegrationWithCredentialInfo } from '../entities/integration.i
2
2
  import { DataType, KeyedSource } from '../types/resolvers';
3
3
  import { InstallOptions } from '../types/sdk';
4
4
  import { IConnectUserContext } from './ConnectUserContext';
5
+ export declare const CREDENTIAL_POLL_INTERVAL = 3000;
6
+ export declare const MAX_POLL_DURATION = 60000;
5
7
  export type OAuthFlowOptions = {
6
8
  context: IConnectUserContext;
7
9
  integration: IConnectIntegrationWithCredentialInfo;
@@ -17,4 +19,5 @@ export type OAuthFlowOptions = {
17
19
  * @param param0
18
20
  * @returns
19
21
  */
20
- export declare const startOAuthFlow: ({ context, integration, endUserSuppliedValues, authParams, isPreviewMode, installOptions, }: OAuthFlowOptions) => Promise<void>;
22
+ export declare const startOAuthFlow: ({ context, integration, endUserSuppliedValues, authParams, isPreviewMode, installOptions, }: OAuthFlowOptions, sessionId: string) => Window | undefined | null;
23
+ export declare const pollForCredential: (sessionId: string, sendAuthenticatedRequest: (url: string, options: RequestInit) => Promise<any>, render: () => void) => Promise<any>;