@quiltt/react 3.9.7 → 4.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @quiltt/react
2
2
 
3
+ ## 4.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#343](https://github.com/quiltt/quiltt-js/pull/343) [`da152b7`](https://github.com/quiltt/quiltt-js/commit/da152b7f42606defde5f55488632bcdc095be592) Thanks [@sirwolfgang](https://github.com/sirwolfgang)! - Add the ability to set nonce for the Quiltt SDK Script
8
+
9
+ - Updated dependencies [[`da152b7`](https://github.com/quiltt/quiltt-js/commit/da152b7f42606defde5f55488632bcdc095be592)]:
10
+ - @quiltt/core@4.0.1
11
+
12
+ ## 4.0.0
13
+
14
+ ### Major Changes
15
+
16
+ - [#333](https://github.com/quiltt/quiltt-js/pull/333) [`5afca4a`](https://github.com/quiltt/quiltt-js/commit/5afca4a45f357afbb7f6af02088f86230f351e18) Thanks [@zubairaziz](https://github.com/zubairaziz)! - Migrate to 'Navigate' message for URL handling
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [[`5afca4a`](https://github.com/quiltt/quiltt-js/commit/5afca4a45f357afbb7f6af02088f86230f351e18)]:
21
+ - @quiltt/core@4.0.0
22
+
3
23
  ## 3.9.7
4
24
 
5
25
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Maybe, QuilttJWT, UsernamePayload, UnprocessableData, AuthAPI, PasscodePayload, ConnectorSDKConnectorOptions, ConnectorSDKCallbacks } from '@quiltt/core';
2
2
  export * from '@quiltt/core';
3
- import { RefObject, useLayoutEffect, Dispatch, SetStateAction, FC, PropsWithChildren, JSX, ComponentType, ElementType, MouseEvent } from 'react';
3
+ import { RefObject, useEffect, Dispatch, SetStateAction, FC, PropsWithChildren, JSX, ComponentType, ElementType, MouseEvent } from 'react';
4
4
  import { useApolloClient } from '@apollo/client/react/hooks/useApolloClient.js';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
 
@@ -13,7 +13,7 @@ declare function useEventListener<K extends keyof DocumentEventMap>(eventName: K
13
13
  * This hook is a browser hook. But React code could be generated from the server without the Window API.
14
14
  * This hook switches between useEffect and useLayoutEffect following the execution environment.
15
15
  */
16
- declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
16
+ declare const useIsomorphicLayoutEffect: typeof useEffect;
17
17
 
18
18
  type SetSession = Dispatch<SetStateAction<Maybe<string> | undefined>>;
19
19
  /**
@@ -153,4 +153,5 @@ type QuilttContainerProps<T extends ElementType> = PropsWithChildren<{
153
153
  */
154
154
  declare const QuilttContainer: <T extends ElementType = "div">({ as, connectorId, connectionId, onEvent, onLoad, onExit, onExitSuccess, onExitAbort, onExitError, children, ...props }: QuilttContainerProps<T> & PropsOf<T>) => react_jsx_runtime.JSX.Element;
155
155
 
156
- export { type AuthenticateSession, type IdentifySession, type ImportSession, QuilttAuthProvider, QuilttButton, QuilttContainer, QuilttProvider, QuilttSettingsProvider, type RevokeSession, type SetSession, type UseQuilttSession, useAuthenticateSession, useEventListener, useIdentifySession, useImportSession, useIsomorphicLayoutEffect, useQuilttClient, useQuilttConnector, useQuilttSession, useQuilttSettings, useRevokeSession, useSession, useStorage };
156
+ export { QuilttAuthProvider, QuilttButton, QuilttContainer, QuilttProvider, QuilttSettingsProvider, useAuthenticateSession, useEventListener, useIdentifySession, useImportSession, useIsomorphicLayoutEffect, useQuilttClient, useQuilttConnector, useQuilttSession, useQuilttSettings, useRevokeSession, useSession, useStorage };
157
+ export type { AuthenticateSession, IdentifySession, ImportSession, RevokeSession, SetSession, UseQuilttSession };
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ export { u as useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect-clie
4
4
  import { Q as QuilttAuthProvider } from './QuilttAuthProvider-client-CER-TOln.js';
5
5
  export { b as useAuthenticateSession, a as useIdentifySession, u as useImportSession, c as useRevokeSession } from './QuilttAuthProvider-client-CER-TOln.js';
6
6
  export { u as useQuilttClient } from './useQuilttClient-client-CAAUait1.js';
7
- import { u as useQuilttConnector } from './useQuilttConnector-client-CUeWVNqS.js';
7
+ import { u as useQuilttConnector } from './useQuilttConnector-client-sRplTzek.js';
8
8
  export { u as useQuilttSession } from './useQuilttSession-client-D2mjVT4S.js';
9
9
  export { u as useQuilttSettings } from './useQuilttSettings-client-BOCBjFXe.js';
10
10
  export { u as useSession } from './useSession-client-CCAvnROP.js';
@@ -26,6 +26,7 @@ const QuilttButton = ({ as, connectorId, connectionId, institution, onEvent, onO
26
26
  const { open } = useQuilttConnector(connectorId, {
27
27
  connectionId,
28
28
  institution,
29
+ nonce: props?.nonce,
29
30
  onEvent,
30
31
  onOpen,
31
32
  onLoad,
@@ -58,6 +59,7 @@ const QuilttButton = ({ as, connectorId, connectionId, institution, onEvent, onO
58
59
  * one Container at a time.
59
60
  */ const QuilttContainer = ({ as, connectorId, connectionId, onEvent, onLoad, onExit, onExitSuccess, onExitAbort, onExitError, children, ...props })=>{
60
61
  useQuilttConnector(connectorId, {
62
+ nonce: props?.nonce,
61
63
  onEvent,
62
64
  onLoad,
63
65
  onExit,
@@ -2,12 +2,14 @@
2
2
  import { useState, useEffect, useCallback } from 'react';
3
3
  import { cdnBase } from '@quiltt/core';
4
4
  import { u as useQuilttSession } from './useQuilttSession-client-D2mjVT4S.js';
5
- import { u as useScript } from './useScript-client-CWRBlZBC.js';
5
+ import { u as useScript } from './useScript-client-JCgaTW9n.js';
6
6
 
7
- var version = "3.9.7";
7
+ var version = "4.0.1";
8
8
 
9
9
  const useQuilttConnector = (connectorId, options)=>{
10
- const status = useScript(`${cdnBase}/v1/connector.js?agent=react-${version}`);
10
+ const status = useScript(`${cdnBase}/v1/connector.js?agent=react-${version}`, {
11
+ nonce: options?.nonce
12
+ });
11
13
  const { session } = useQuilttSession();
12
14
  const [connector, setConnector] = useState();
13
15
  const [isOpening, setIsOpening] = useState(false);
@@ -42,6 +42,9 @@ function useScript(src, options) {
42
42
  scriptNode = document.createElement('script');
43
43
  scriptNode.src = src;
44
44
  scriptNode.async = true;
45
+ if (options?.nonce && options.nonce.trim() !== '') {
46
+ scriptNode.nonce = options.nonce;
47
+ }
45
48
  scriptNode.setAttribute('data-status', 'loading');
46
49
  document.body.appendChild(scriptNode);
47
50
  // Store status in attribute on script
@@ -73,10 +76,14 @@ function useScript(src, options) {
73
76
  scriptNode.removeEventListener('load', setStateFromEvent);
74
77
  scriptNode.removeEventListener('error', setStateFromEvent);
75
78
  }
79
+ if (scriptNode && options?.removeOnUnmount) {
80
+ scriptNode.remove();
81
+ }
76
82
  };
77
83
  }, [
78
84
  src,
79
85
  options?.shouldPreventLoad,
86
+ options?.nonce,
80
87
  options?.removeOnUnmount
81
88
  ]);
82
89
  return status;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quiltt/react",
3
- "version": "3.9.7",
3
+ "version": "4.0.1",
4
4
  "description": "React Components and Hooks for Quiltt Connector",
5
5
  "keywords": [
6
6
  "quiltt",
@@ -35,18 +35,18 @@
35
35
  "main": "dist/index.js",
36
36
  "dependencies": {
37
37
  "@apollo/client": "^3.12.4",
38
- "@quiltt/core": "3.9.7"
38
+ "@quiltt/core": "4.0.1"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@biomejs/biome": "1.9.4",
42
- "@types/node": "22.13.10",
43
- "@types/react": "18.3.12",
44
- "@types/react-dom": "18.3.1",
42
+ "@types/node": "22.14.1",
43
+ "@types/react": "18.3.20",
44
+ "@types/react-dom": "18.3.5",
45
45
  "bunchee": "6.3.4",
46
46
  "react": "18.3.1",
47
47
  "react-dom": "18.3.1",
48
48
  "rimraf": "6.0.1",
49
- "typescript": "5.7.3"
49
+ "typescript": "5.8.2"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
@@ -47,6 +47,7 @@ export const QuilttButton = <T extends ElementType = 'button'>({
47
47
  const { open } = useQuilttConnector(connectorId, {
48
48
  connectionId,
49
49
  institution,
50
+ nonce: props?.nonce, // Pass nonce for script loading if needed
50
51
  onEvent,
51
52
  onOpen,
52
53
  onLoad,
@@ -31,6 +31,7 @@ export const QuilttContainer = <T extends ElementType = 'div'>({
31
31
  ...props
32
32
  }: QuilttContainerProps<T> & PropsOf<T>) => {
33
33
  useQuilttConnector(connectorId, {
34
+ nonce: props?.nonce, // Pass nonce for script loading if needed
34
35
  onEvent,
35
36
  onLoad,
36
37
  onExit,
@@ -19,7 +19,9 @@ export const useQuilttConnector = (
19
19
  connectorId?: string,
20
20
  options?: ConnectorSDKConnectorOptions
21
21
  ) => {
22
- const status = useScript(`${cdnBase}/v1/connector.js?agent=react-${version}`)
22
+ const status = useScript(`${cdnBase}/v1/connector.js?agent=react-${version}`, {
23
+ nonce: options?.nonce,
24
+ })
23
25
  const { session } = useQuilttSession()
24
26
  const [connector, setConnector] = useState<ConnectorSDKConnector>()
25
27
  const [isOpening, setIsOpening] = useState<boolean>(false)
@@ -6,6 +6,7 @@ export type UseScriptStatus = 'idle' | 'loading' | 'ready' | 'error'
6
6
  export interface UseScriptOptions {
7
7
  shouldPreventLoad?: boolean
8
8
  removeOnUnmount?: boolean
9
+ nonce?: string
9
10
  }
10
11
 
11
12
  // Cached script statuses
@@ -58,6 +59,9 @@ export function useScript(src: string | null, options?: UseScriptOptions): UseSc
58
59
  scriptNode = document.createElement('script')
59
60
  scriptNode.src = src
60
61
  scriptNode.async = true
62
+ if (options?.nonce && options.nonce.trim() !== '') {
63
+ scriptNode.nonce = options.nonce
64
+ }
61
65
  scriptNode.setAttribute('data-status', 'loading')
62
66
  document.body.appendChild(scriptNode)
63
67
 
@@ -100,7 +104,7 @@ export function useScript(src: string | null, options?: UseScriptOptions): UseSc
100
104
  scriptNode.remove()
101
105
  }
102
106
  }
103
- }, [src, options?.shouldPreventLoad, options?.removeOnUnmount])
107
+ }, [src, options?.shouldPreventLoad, options?.nonce, options?.removeOnUnmount])
104
108
 
105
109
  return status
106
110
  }