@parafin/react 6.0.0 → 6.1.1

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/out/index.d.ts CHANGED
@@ -1,4 +1,50 @@
1
- import { WidgetProps, OptInFields } from '@parafin/widget';
2
1
  declare const ParafinWidget: (props: WidgetProps) => import("react/jsx-runtime").JSX.Element;
3
2
  export { ParafinWidget };
4
- export type { OptInFields };
3
+ export type WidgetProps = {
4
+ token: string;
5
+ product: 'capital' | 'spend_card' | 'cash_account';
6
+ externalBusinessId?: string;
7
+ onExit?: () => void;
8
+ onOptIn?: () => Promise<OptInFields>;
9
+ openInNewTab?: boolean;
10
+ };
11
+ type USStates = 'AL' | 'AK' | 'AZ' | 'AR' | 'CA' | 'CO' | 'CT' | 'DE' | 'DC' | 'FL' | 'GA' | 'HI' | 'ID' | 'IL' | 'IN' | 'IA' | 'KS' | 'KY' | 'LA' | 'ME' | 'MD' | 'MA' | 'MI' | 'MN' | 'MS' | 'MO' | 'MT' | 'NE' | 'NV' | 'NH' | 'NJ' | 'NM' | 'NY' | 'NC' | 'ND' | 'OH' | 'OK' | 'OR' | 'PA' | 'RI' | 'SC' | 'SD' | 'TN' | 'TX' | 'UT' | 'VT' | 'VA' | 'WA' | 'WV' | 'WI' | 'WY';
12
+ type USTerritories = 'AS' | 'GU' | 'MP' | 'PR' | 'VI';
13
+ type CanadianProvinces = 'AB' | 'BC' | 'MB' | 'NB' | 'NL' | 'NS' | 'QC' | 'ON' | 'PE' | 'SK';
14
+ type CanadianTerritories = 'NT' | 'NU' | 'YT';
15
+ type Address = {
16
+ addressLine1: string;
17
+ addressLine2?: string;
18
+ city: string;
19
+ state: USStates | USTerritories | CanadianProvinces | CanadianTerritories;
20
+ postalCode: string;
21
+ country: 'US' | 'CA';
22
+ };
23
+ export type OptInFields = {
24
+ businessExternalId: string;
25
+ accountManagers?: {
26
+ name: string;
27
+ email: string;
28
+ }[];
29
+ owner: {
30
+ firstName: string;
31
+ lastName: string;
32
+ email: string;
33
+ phoneNumber?: string;
34
+ /** yyyy-mm-dd */
35
+ dateOfBirth?: string;
36
+ address?: Address;
37
+ };
38
+ business: {
39
+ legalName: string;
40
+ dbaName?: string;
41
+ address?: Address;
42
+ /** yyyy-mm-dd */
43
+ dateEstablished?: string;
44
+ };
45
+ bank?: {
46
+ routingNumber?: string;
47
+ accountNumberLastFour?: string;
48
+ currencyCode?: 'USD' | 'CAD';
49
+ };
50
+ };
package/out/index.js CHANGED
@@ -11,12 +11,13 @@ const openParafinDashboard = (props) => {
11
11
  product: props.product,
12
12
  referrer: 'partner',
13
13
  ...('token' in props && { token: props.token }),
14
+ ...('partner' in props && { partner: props.partner }),
14
15
  ...('externalBusinessId' in props && {
15
16
  externalBusinessId: props.externalBusinessId,
16
17
  }),
17
18
  ...('orderId' in props && { orderId: props.orderId }),
18
- ...('orderAmount' in props && {
19
- orderAmount: props.orderAmount.toString(),
19
+ ...('lineOfCreditApplicationId' in props && {
20
+ lineOfCreditApplicationId: props.lineOfCreditApplicationId,
20
21
  }),
21
22
  ...('additionalQueryParams' in props && props.additionalQueryParams),
22
23
  ...Object.fromEntries(searchParams),
@@ -26,6 +27,10 @@ const openParafinDashboard = (props) => {
26
27
  window.open(url, '_blank');
27
28
  return;
28
29
  }
30
+ if ('mode' in props && props.mode === 'redirect') {
31
+ window.location.href = url;
32
+ return;
33
+ }
29
34
  const existingParafinDashboard = document.getElementById('parafin-dashboard');
30
35
  if (existingParafinDashboard) {
31
36
  document.removeChild(existingParafinDashboard);
@@ -44,11 +49,13 @@ const openParafinDashboard = (props) => {
44
49
  frame.style.transition = 'opacity 0.2s';
45
50
  frame.src = url;
46
51
  frame.allow = 'accelerometer; gyroscope; clipboard-read; clipboard-write';
47
- const parse = (message) => (message ? JSON.parse(message) : undefined);
48
52
  const closeParafinDashboard = (e) => {
49
53
  if (e.origin === origin && e.data?.message === 'close-dashboard') {
50
- if (props.product === 'bnpl' && props.flow === 'checkout') {
51
- props.onExit(parse(e.data.order));
54
+ if ('orderId' in props) {
55
+ props.onExit?.(props.orderId);
56
+ }
57
+ else if ('lineOfCreditApplicationId' in props) {
58
+ props.onExit?.(props.lineOfCreditApplicationId);
52
59
  }
53
60
  else {
54
61
  props.onExit?.();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parafin/react",
3
- "version": "6.0.0",
3
+ "version": "6.1.1",
4
4
  "description": "Parafin React widget",
5
5
  "author": "Parafin (https://www.parafin.com)",
6
6
  "module": "out/index.js",