@tryfinch/react-connect 3.15.1 → 4.1.0

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/.eslintrc.js CHANGED
@@ -21,6 +21,7 @@ module.exports = {
21
21
  'import/resolver': {
22
22
  node: {
23
23
  paths: ['src'],
24
+ extensions: ['.js', '.jsx', '.ts', '.tsx'],
24
25
  },
25
26
  },
26
27
  },
@@ -32,6 +33,16 @@ module.exports = {
32
33
  'jsx-a11y/anchor-is-valid': 'off',
33
34
  'react/jsx-props-no-spreading': 'off',
34
35
  'no-underscore-dangle': 'off',
36
+ 'import/extensions': [
37
+ 'error',
38
+ 'ignorePackages',
39
+ {
40
+ js: 'never',
41
+ jsx: 'never',
42
+ ts: 'never',
43
+ tsx: 'never',
44
+ },
45
+ ],
35
46
  'max-len': [
36
47
  'warn',
37
48
  {
@@ -46,5 +57,6 @@ module.exports = {
46
57
  ignoreRegExpLiterals: true,
47
58
  },
48
59
  ],
60
+ 'no-console': 'off',
49
61
  },
50
62
  };
@@ -0,0 +1,66 @@
1
+ > The following sections MUST be filled out in order for your pull request to be reviewed
2
+ >
3
+ > If you've been asked to review this and information is missing or incomplete please ask the author to complete this first
4
+
5
+ ## What is changing?
6
+
7
+ <!--
8
+ Please ensure your changes are in line with Finch's Coding Standards
9
+ - https://www.notion.so/tryfinch/Coding-Standards-051edcec95ff4dddb107303957e08416
10
+ -->
11
+ TODO
12
+
13
+ ### ⚠️ What breaking changes will developers need to handle?
14
+ TODO (or n/a if no breaking changes)
15
+
16
+ ## Why is it changing?
17
+
18
+ <!-- What problem does this solve? Why are the changes the appropriate solution? -->
19
+ TODO
20
+
21
+ ## Relevant resources
22
+
23
+ <!--
24
+ Link to any:
25
+ - Associated tickets
26
+ - Discussions on Slack
27
+ - Related PRs
28
+ - Relevant metrics or logs
29
+ -->
30
+ TODO
31
+
32
+ ## What steps did you take to test this?
33
+
34
+ <!--
35
+ Include the steps you took to validate these changes work as expected. This can include automated and manual testing.
36
+ These should allow reviewers to be confident that you have exercised all of your changes to verify that they work as expected
37
+ and will not break in production.
38
+
39
+ e.g.
40
+ - Manually verified that when we get the password change error from the provider we throw a 403
41
+ - Updated automated tests to validate that a 403 is raised when the provider returns the password change error
42
+
43
+ If your changes cannot be fully tested for some reason, or if you feel testing is not necessary, you must explain
44
+ why as well as how you will monitor for issues once they are deployed.
45
+ -->
46
+ TODO
47
+
48
+ ### Screenshots
49
+
50
+ <!--
51
+ Include screenshots of your testing if possible, e.g. responses in Postman, successful data sync job runs
52
+ -->
53
+ TODO (or n/a if nothing can be captured in a screenshot)
54
+
55
+ ## Was the JavaScript SDK updated as well?
56
+
57
+ <!--
58
+ If you are changing functionality in this frontend SDK the other one needs to be updated to match
59
+ https://github.com/Finch-API/finch-connect-js
60
+ -->
61
+ TODO (or n/a if no changes to duplicate)
62
+
63
+ ## Was the relevant external documentation updated?
64
+
65
+ <!-- If any external documentation was updated as a result of this PR, link to it below. -->
66
+ TODO (or n/a if no relevant docs)
@@ -0,0 +1,92 @@
1
+ name: Pull Request
2
+
3
+ on:
4
+ pull_request:
5
+
6
+ jobs:
7
+ # basic validations
8
+
9
+ validate-ticket-tracked:
10
+ name: Validate ticket tracked
11
+ uses: finch-api/github-actions-workflows/.github/workflows/valid-ticket-tracked.yml@main
12
+ with:
13
+ GH_EVENT_NUMBER: ${{ github.event.number }}
14
+ REPO_NAME: ${{ github.repository }}
15
+ secrets:
16
+ GHA_TOKEN: ${{ secrets.GH_READONLY_REPOS_AND_PACKAGES_PAT }}
17
+
18
+ validate-pr-title-standard:
19
+ name: Validate PR title is to standard
20
+ runs-on: blacksmith-2vcpu-ubuntu-2404
21
+
22
+ steps:
23
+ - name: Checkout code
24
+ uses: actions/checkout@v5
25
+
26
+ - name: Validate PR title using semantic-pull-request
27
+ uses: amannn/action-semantic-pull-request@v5
28
+ env:
29
+ GITHUB_TOKEN: ${{ secrets.GH_READONLY_REPOS_AND_PACKAGES_PAT }}
30
+ with:
31
+ wip: true
32
+ types: |
33
+ build
34
+ chore
35
+ ci
36
+ docs
37
+ feat
38
+ fix
39
+ infra
40
+ perf
41
+ refactor
42
+ revert
43
+ style
44
+ test
45
+
46
+ # checks
47
+
48
+ lint:
49
+ name: Lint
50
+ runs-on: blacksmith-2vcpu-ubuntu-2404
51
+ needs:
52
+ - validate-ticket-tracked
53
+ - validate-pr-title-standard
54
+
55
+ steps:
56
+ - name: Checkout code
57
+ uses: actions/checkout@v5
58
+
59
+ - name: Configure node
60
+ uses: useblacksmith/setup-node@v5
61
+ with:
62
+ node-version-file: .nvmrc
63
+ cache: npm
64
+
65
+ - name: Install dependencies
66
+ run: npm install
67
+
68
+ - name: Run lint
69
+ run: npm run lint
70
+
71
+ run-tests:
72
+ name: Unit test
73
+ runs-on: blacksmith-2vcpu-ubuntu-2404
74
+ needs:
75
+ - validate-ticket-tracked
76
+ - validate-pr-title-standard
77
+
78
+ steps:
79
+ - name: Checkout code
80
+ uses: actions/checkout@v5
81
+
82
+ - name: Configure node
83
+ uses: useblacksmith/setup-node@v5
84
+ with:
85
+ node-version-file: .nvmrc
86
+ cache: npm
87
+
88
+ - name: Install dependencies
89
+ run: npm install
90
+
91
+ - name: Run tests
92
+ run: npm run test
@@ -0,0 +1,80 @@
1
+ name: Build and Release
2
+
3
+ on:
4
+ release:
5
+ types:
6
+ - published
7
+
8
+ jobs:
9
+ tests:
10
+ name: Tests
11
+ runs-on: blacksmith-2vcpu-ubuntu-2204
12
+ steps:
13
+ - name: Checkout code
14
+ uses: actions/checkout@v5
15
+
16
+ - name: Configure node
17
+ uses: useblacksmith/setup-node@v5
18
+ with:
19
+ node-version-file: .nvmrc
20
+ cache: npm
21
+
22
+ - name: Install dependencies
23
+ run: npm install
24
+
25
+ - name: Run Tests
26
+ run: npm run test
27
+
28
+ lint:
29
+ name: Lint
30
+ runs-on: blacksmith-2vcpu-ubuntu-2404
31
+
32
+ steps:
33
+ - name: Checkout code
34
+ uses: actions/checkout@v5
35
+
36
+ - name: Configure node
37
+ uses: useblacksmith/setup-node@v5
38
+ with:
39
+ node-version-file: .nvmrc
40
+ cache: npm
41
+
42
+ - name: Install dependencies
43
+ run: npm install
44
+
45
+ - name: Run Lint
46
+ run: npm run lint
47
+
48
+ build-and-publish:
49
+ name: Build and Publish to NPM
50
+ runs-on: blacksmith-2vcpu-ubuntu-2204
51
+ needs:
52
+ - tests
53
+ - lint
54
+
55
+ steps:
56
+ - name: Checkout code
57
+ uses: actions/checkout@v5
58
+
59
+ - name: Configure node
60
+ uses: useblacksmith/setup-node@v5
61
+ with:
62
+ node-version-file: .nvmrc
63
+ cache: npm
64
+ registry-url: https://registry.npmjs.org/
65
+
66
+ - name: Install dependencies
67
+ run: npm install
68
+
69
+ - name: Build
70
+ run: npm run build
71
+
72
+ - name: Update package version
73
+ run: npm version --no-git-tag-version ${{ github.ref_name }}
74
+
75
+ - name: Publish to npm
76
+ run: npm publish
77
+ env:
78
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
79
+
80
+
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ v18.17.0
package/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # v4.1.0
2
+
3
+ ## New
4
+ - Added the `openPreview` function, which accepts a client ID and list of products and will launch Connect in preview mode. Completing the authorization flow is disabled in preview mode.
5
+
6
+ # v4.0.0
7
+
8
+ ## ⚠️ Breaking Changes
9
+ - A session ID is now required when calling the `open` method to launch Finch Connect. You can create a session using the [Connect session endpoint](https://developer.tryfinch.com/api-reference/connect/new-session) on the Finch API.
10
+ - The `state` parameter has been moved from the `initialize` call to the `open` call
11
+ - The `open` call no longer allows overriding values for the auth session, all values must be set in the session created by calling the API
package/README.md CHANGED
@@ -10,6 +10,8 @@ npm install --save @tryfinch/react-connect
10
10
 
11
11
  ## Usage
12
12
 
13
+ See the example app at `example/src` for a functional example
14
+
13
15
  ```jsx
14
16
  import React, { useState } from 'react';
15
17
  import { useFinchConnect } from '@tryfinch/react-connect';
@@ -17,33 +19,38 @@ import { useFinchConnect } from '@tryfinch/react-connect';
17
19
  const App = () => {
18
20
  const [code, setCode] = useState(null);
19
21
 
20
- const onSuccess = ({ code }) => setCode(code);
22
+ // Define callbacks
23
+
24
+ /**
25
+ * @param {string} code - The authorization code to exchange for an access token
26
+ * @param {string?} state - The state value that was provided when launching Connect
27
+ */
28
+ const onSuccess = ({ code, state }) => setCode(code);
21
29
  /**
22
30
  * @param {string} errorMessage - The error message
23
31
  * @param {'validation_error' | 'employer_error'} errorType - The type of error
24
- * - 'validation_error': Finch Connect failed to open due to validation error
25
- * - 'employer_connection_error': The errors employers see within the Finch Connect flow
32
+ * - 'validation_error': Finch Connect failed to open due to validation error
33
+ * - 'employer_connection_error': The errors employers see within the Finch Connect flow
26
34
  */
27
35
  const onError = ({ errorMessage, errorType }) => console.error(errorMessage, errorType);
28
36
  const onClose = () => console.log('User exited Finch Connect');
29
37
 
30
- // Generate a session ID using the /connect/sessions endpoint on the Finch API
31
- // See the docs here https://developer.tryfinch.com/api-reference/connect/new-session#create-a-new-connect-session
32
- const sessionId = '';
33
-
38
+ // Initialize the FinchConnect hook
34
39
  const { open } = useFinchConnect({
35
- sessionId,
36
- // zIndex: 999, // Set this to change the z-index of the Connect iframe, defaults to 999
37
40
  onSuccess,
38
41
  onError,
39
42
  onClose,
40
43
  });
41
44
 
45
+ // Generate a session ID using the /connect/sessions endpoint on the Finch API
46
+ // See the docs here https://developer.tryfinch.com/api-reference/connect/new-session#create-a-new-connect-session
47
+ const sessionId = '';
48
+
42
49
  return (
43
50
  <div>
44
51
  <header>
45
52
  <p>Code: {code}</p>
46
- <button type="button" onClick={() => open()}>
53
+ <button type="button" onClick={() => open({ sessionId })}>
47
54
  Open Finch Connect
48
55
  </button>
49
56
  </header>
package/dist/index.d.ts CHANGED
@@ -8,36 +8,39 @@ export type ErrorEvent = {
8
8
  errorMessage: string;
9
9
  errorType?: ErrorType;
10
10
  };
11
- export type Sandbox = 'finch' /** This is to enable the new Finch (simulated) Sandbox */ | 'provider' /** This is to enable the new Provider Sandbox */ | boolean /** This is the old sandbox flag retained for backwards compatibility */;
12
- type BaseConnectOptions = {
13
- state: string | null;
11
+ type ApiConfig = {
12
+ connectUrl: string;
13
+ };
14
+ export type ConnectInitializeArgs = {
14
15
  onSuccess: (e: SuccessEvent) => void;
15
16
  onError: (e: ErrorEvent) => void;
16
17
  onClose: () => void;
17
- zIndex: number;
18
- apiConfig?: {
19
- connectUrl: string;
20
- redirectUrl: string;
21
- };
18
+ apiConfig?: ApiConfig;
22
19
  };
23
- type ConnectOptionsWithSessionId = BaseConnectOptions & {
20
+ export type ConnectLaunchArgs = {
24
21
  sessionId: string;
25
- products?: string[];
22
+ state?: string;
23
+ zIndex?: number;
26
24
  };
27
- type ConnectOptionsWithClientId = BaseConnectOptions & {
28
- category: string | null;
25
+ export type ConnectPreviewLaunchArgs = {
29
26
  clientId: string;
30
- manual: boolean;
31
- payrollProvider: string | null;
32
27
  products: string[];
33
- clientName?: string;
34
- connectionId?: string;
35
- sandbox: Sandbox;
36
28
  };
37
- export type ConnectOptions = ConnectOptionsWithSessionId | ConnectOptionsWithClientId;
38
- type OpenFn = (overrides?: Partial<ConnectOptions>) => void;
39
- export declare const useFinchConnect: (options: Partial<ConnectOptions>) => {
29
+ type OpenFn = (args: ConnectLaunchArgs) => void;
30
+ type OpenPreviewFn = (args: ConnectPreviewLaunchArgs) => void;
31
+ export declare const constructAuthUrl: ({ sessionId, state, apiConfig, }: {
32
+ sessionId: string;
33
+ state?: string | undefined;
34
+ apiConfig?: ApiConfig | undefined;
35
+ }) => string;
36
+ export declare const constructPreviewUrl: ({ clientId, products, apiConfig, }: {
37
+ clientId: string;
38
+ products: string[];
39
+ apiConfig?: ApiConfig | undefined;
40
+ }) => string;
41
+ export declare const useFinchConnect: (initializeArgs: ConnectInitializeArgs) => {
40
42
  open: OpenFn;
43
+ openPreview: OpenPreviewFn;
41
44
  };
42
45
  export {};
43
46
  //# sourceMappingURL=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AE,CAAC;CACpB,CAAC;AAEF,KAAK,MAAM,GAAG,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;AAEhD,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE,wBAAwB,KAAK,IAAI,CAAC;AAsC9D,eAAO,MAAM,gBAAgB;eAKhB,MAAM;;;YAclB,CAAC;AAEF,eAAO,MAAM,mBAAmB;cAKpB,MAAM;cACN,MAAM,EAAE;;YAiBnB,CAAC;AAIF,eAAO,MAAM,eAAe,mBACV,qBAAqB;UAC5B,MAAM;iBAAe,aAAa;CA8H5C,CAAC"}
package/dist/index.es.js CHANGED
@@ -2,68 +2,38 @@ import { useRef, useEffect } from 'react';
2
2
 
3
3
  const POST_MESSAGE_NAME = 'finch-auth-message-v2';
4
4
  const BASE_FINCH_CONNECT_URI = 'https://connect.tryfinch.com';
5
- const DEFAULT_FINCH_REDIRECT_URI = 'https://tryfinch.com';
6
5
  const FINCH_CONNECT_IFRAME_ID = 'finch-connect-iframe';
7
- const constructAuthUrl = (connectOptions) => {
8
- const { state, apiConfig } = connectOptions;
6
+ const appendBaseParams = (url) => {
7
+ url.searchParams.append('app_type', 'spa');
8
+ // The host URL of the SDK. This is used to store the referrer for postMessage purposes
9
+ url.searchParams.append('sdk_host_url', window.location.origin);
10
+ url.searchParams.append('mode', 'employer');
11
+ // replace with actual SDK version by rollup
12
+ url.searchParams.append('sdk_version', 'react-4.1.0');
13
+ };
14
+ const constructAuthUrl = ({ sessionId, state, apiConfig, }) => {
9
15
  const CONNECT_URL = (apiConfig === null || apiConfig === void 0 ? void 0 : apiConfig.connectUrl) || BASE_FINCH_CONNECT_URI;
10
- const REDIRECT_URL = (apiConfig === null || apiConfig === void 0 ? void 0 : apiConfig.redirectUrl) || DEFAULT_FINCH_REDIRECT_URI;
11
16
  const authUrl = new URL(`${CONNECT_URL}/authorize`);
12
- if ('sessionId' in connectOptions) {
13
- const { sessionId, products } = connectOptions;
14
- authUrl.searchParams.append('session', sessionId);
15
- if (products)
16
- authUrl.searchParams.append('products', products.join(' '));
17
- }
18
- else {
19
- const { clientId, payrollProvider, category, products, manual, sandbox, clientName, connectionId, } = connectOptions;
20
- if (clientId)
21
- authUrl.searchParams.append('client_id', clientId);
22
- if (payrollProvider)
23
- authUrl.searchParams.append('payroll_provider', payrollProvider);
24
- if (category)
25
- authUrl.searchParams.append('category', category);
26
- if (clientName)
27
- authUrl.searchParams.append('client_name', clientName);
28
- if (connectionId)
29
- authUrl.searchParams.append('connection_id', connectionId);
30
- authUrl.searchParams.append('products', (products !== null && products !== void 0 ? products : []).join(' '));
31
- if (manual)
32
- authUrl.searchParams.append('manual', String(manual));
33
- if (sandbox)
34
- authUrl.searchParams.append('sandbox', String(sandbox));
35
- }
36
- authUrl.searchParams.append('app_type', 'spa');
37
- authUrl.searchParams.append('redirect_uri', REDIRECT_URL);
38
- /** The host URL of the SDK. This is used to store the referrer for postMessage purposes */
39
- authUrl.searchParams.append('sdk_host_url', window.location.origin);
40
- authUrl.searchParams.append('mode', 'employer');
17
+ authUrl.searchParams.append('session', sessionId);
41
18
  if (state)
42
19
  authUrl.searchParams.append('state', state);
43
- // replace with actual SDK version by rollup
44
- authUrl.searchParams.append('sdk_version', 'react-3.15.1');
20
+ appendBaseParams(authUrl);
45
21
  return authUrl.href;
46
22
  };
47
- const noop = () => {
48
- // intentionally empty
49
- };
50
- const BASE_DEFAULTS = {
51
- onSuccess: noop,
52
- onError: noop,
53
- onClose: noop,
54
- state: null,
55
- zIndex: 999,
23
+ const constructPreviewUrl = ({ clientId, products, apiConfig, }) => {
24
+ const CONNECT_URL = (apiConfig === null || apiConfig === void 0 ? void 0 : apiConfig.connectUrl) || BASE_FINCH_CONNECT_URI;
25
+ const previewUrl = new URL(`${CONNECT_URL}/authorize`);
26
+ previewUrl.searchParams.append('preview', 'true');
27
+ previewUrl.searchParams.append('client_id', clientId);
28
+ previewUrl.searchParams.append('products', (products !== null && products !== void 0 ? products : []).join(' '));
29
+ // This will be replaced by a universally allowed redirect URI in the backend
30
+ // We won't ever redirect to anything in preview mode, so we just need a value to pass validation
31
+ previewUrl.searchParams.append('redirect_uri', 'https://www.tryfinch.com');
32
+ appendBaseParams(previewUrl);
33
+ return previewUrl.href;
56
34
  };
57
- const DEFAULT_OPTIONS_WITH_CLIENT_ID = Object.assign(Object.assign({}, BASE_DEFAULTS), { clientId: '', category: null, manual: false, payrollProvider: null, products: [], clientName: undefined, sandbox: false });
58
- const DEFAULT_OPTIONS_WITH_SESSION_ID = Object.assign(Object.assign({}, BASE_DEFAULTS), { sessionId: '' });
59
35
  let isUseFinchConnectInitialized = false;
60
- const useFinchConnect = (options) => {
61
- if (!('sessionId' in options) && !('clientId' in options)) {
62
- throw new Error('must specify either sessionId or clientId in options for useFinchConnect');
63
- }
64
- if ('sessionId' in options && 'clientId' in options) {
65
- throw new Error('cannot specify both sessionId and clientId in options for useFinchConnect');
66
- }
36
+ const useFinchConnect = (initializeArgs) => {
67
37
  const isHookMounted = useRef(false);
68
38
  useEffect(() => {
69
39
  if (!isHookMounted.current) {
@@ -76,17 +46,14 @@ const useFinchConnect = (options) => {
76
46
  isHookMounted.current = true;
77
47
  }
78
48
  }, []);
79
- const combinedOptions = 'sessionId' in options
80
- ? Object.assign(Object.assign({}, DEFAULT_OPTIONS_WITH_SESSION_ID), options) : Object.assign(Object.assign({}, DEFAULT_OPTIONS_WITH_CLIENT_ID), options);
81
- const open = (overrides) => {
82
- const openOptions = Object.assign(Object.assign({}, combinedOptions), overrides);
49
+ const createAndAttachIFrame = ({ src, zIndexOverride, }) => {
83
50
  if (!document.getElementById(FINCH_CONNECT_IFRAME_ID)) {
84
51
  const iframe = document.createElement('iframe');
85
- iframe.src = constructAuthUrl(openOptions);
52
+ iframe.src = src;
86
53
  iframe.frameBorder = '0';
87
54
  iframe.id = FINCH_CONNECT_IFRAME_ID;
88
55
  iframe.style.position = 'fixed';
89
- iframe.style.zIndex = openOptions.zIndex.toString();
56
+ iframe.style.zIndex = (zIndexOverride === null || zIndexOverride === void 0 ? void 0 : zIndexOverride.toString()) || '999';
90
57
  iframe.style.height = '100%';
91
58
  iframe.style.width = '100%';
92
59
  iframe.style.top = '0';
@@ -97,6 +64,27 @@ const useFinchConnect = (options) => {
97
64
  document.body.style.overflow = 'hidden';
98
65
  }
99
66
  };
67
+ const open = (launchArgs) => {
68
+ const iframeSrc = constructAuthUrl({
69
+ sessionId: launchArgs.sessionId,
70
+ state: launchArgs.state,
71
+ apiConfig: initializeArgs.apiConfig,
72
+ });
73
+ createAndAttachIFrame({
74
+ src: iframeSrc,
75
+ zIndexOverride: launchArgs.zIndex,
76
+ });
77
+ };
78
+ const openPreview = (launchArgs) => {
79
+ const iframeSrc = constructPreviewUrl({
80
+ clientId: launchArgs.clientId,
81
+ products: launchArgs.products,
82
+ apiConfig: initializeArgs.apiConfig,
83
+ });
84
+ createAndAttachIFrame({
85
+ src: iframeSrc,
86
+ });
87
+ };
100
88
  const close = () => {
101
89
  var _a;
102
90
  const frameToRemove = document.getElementById(FINCH_CONNECT_IFRAME_ID);
@@ -108,7 +96,7 @@ const useFinchConnect = (options) => {
108
96
  useEffect(() => {
109
97
  function handleFinchAuth(event) {
110
98
  var _a, _b, _c, _d;
111
- const CONNECT_URL = ((_a = combinedOptions.apiConfig) === null || _a === void 0 ? void 0 : _a.connectUrl) || BASE_FINCH_CONNECT_URI;
99
+ const CONNECT_URL = ((_a = initializeArgs.apiConfig) === null || _a === void 0 ? void 0 : _a.connectUrl) || BASE_FINCH_CONNECT_URI;
112
100
  if (!event.data)
113
101
  return;
114
102
  if (event.data.name !== POST_MESSAGE_NAME)
@@ -119,18 +107,18 @@ const useFinchConnect = (options) => {
119
107
  close();
120
108
  switch (event.data.kind) {
121
109
  case 'closed':
122
- combinedOptions.onClose();
110
+ initializeArgs.onClose();
123
111
  break;
124
112
  case 'error':
125
113
  if ((_b = event.data.error) === null || _b === void 0 ? void 0 : _b.shouldClose)
126
114
  close();
127
- combinedOptions.onError({
115
+ initializeArgs.onError({
128
116
  errorMessage: (_c = event.data.error) === null || _c === void 0 ? void 0 : _c.message,
129
117
  errorType: (_d = event.data.error) === null || _d === void 0 ? void 0 : _d.type,
130
118
  });
131
119
  break;
132
120
  case 'success':
133
- combinedOptions.onSuccess({
121
+ initializeArgs.onSuccess({
134
122
  code: event.data.code,
135
123
  state: event.data.state,
136
124
  idpRedirectUri: event.data.idpRedirectUri,
@@ -138,7 +126,7 @@ const useFinchConnect = (options) => {
138
126
  break;
139
127
  default: {
140
128
  // This case should never happen, if it does it should be reported to us
141
- combinedOptions.onError({
129
+ initializeArgs.onError({
142
130
  errorMessage: `Report to developers@tryfinch.com: unable to handle window.postMessage for: ${JSON.stringify(event.data)}`,
143
131
  });
144
132
  }
@@ -149,11 +137,12 @@ const useFinchConnect = (options) => {
149
137
  window.removeEventListener('message', handleFinchAuth);
150
138
  isUseFinchConnectInitialized = false;
151
139
  };
152
- }, [combinedOptions.onClose, combinedOptions.onError, combinedOptions.onSuccess]);
140
+ }, [initializeArgs.onClose, initializeArgs.onError, initializeArgs.onSuccess]);
153
141
  return {
154
142
  open,
143
+ openPreview,
155
144
  };
156
145
  };
157
146
 
158
- export { useFinchConnect };
147
+ export { constructAuthUrl, constructPreviewUrl, useFinchConnect };
159
148
  //# sourceMappingURL=index.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAwDA,MAAM,iBAAiB,GAAG,uBAAgC,CAAC;AAuB3D,MAAM,sBAAsB,GAAG,8BAA8B,CAAC;AAC9D,MAAM,0BAA0B,GAAG,sBAAsB,CAAC;AAE1D,MAAM,uBAAuB,GAAG,sBAAsB,CAAC;AAEvD,MAAM,gBAAgB,GAAG,CAAC,cAA8B,KAAI;AAC1D,IAAA,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,cAAc,CAAC;AAE5C,IAAA,MAAM,WAAW,GAAG,CAAA,SAAS,KAAT,IAAA,IAAA,SAAS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