@methodfi/opal-react 0.0.1 → 0.0.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.
package/README.md CHANGED
@@ -17,7 +17,7 @@ yarn add @methodfi/opal-react
17
17
  Wrap your app with the `OpalProvider`:
18
18
 
19
19
  ```tsx
20
- import { OpalProvider } from '@methodfi/opal-react';
20
+ import {OpalProvider} from '@methodfi/opal-react';
21
21
 
22
22
  export default function App() {
23
23
  return (
@@ -33,20 +33,28 @@ export default function App() {
33
33
  Use the `useOpal` hook in your components:
34
34
 
35
35
  ```tsx
36
- import { useOpal } from '@methodfi/opal-react';
36
+ import {useOpal} from '@methodfi/opal-react';
37
37
 
38
38
  function Screen() {
39
- const { open } = useOpal({
39
+ const {open} = useOpal({
40
40
  env: 'dev',
41
41
  onOpen: () => {},
42
42
  onExit: () => {},
43
- onError: (error) => console.error('Error:', error),
44
- onEvent: (event) => {
43
+ onError: error => console.error('Error:', error),
44
+ onEvent: event => {
45
45
  switch (event.type) {
46
- case 'opal.session.started': { /* ... */ }
47
- case 'opal.session.errored': { /* ... */ }
48
- case 'opal.session.exited': { /* ... */ }
49
- case 'card_connect.card.verified': { /* ... */ }
46
+ case 'opal.session.started': {
47
+ /* ... */
48
+ }
49
+ case 'opal.session.errored': {
50
+ /* ... */
51
+ }
52
+ case 'opal.session.exited': {
53
+ /* ... */
54
+ }
55
+ case 'card_connect.card.verified': {
56
+ /* ... */
57
+ }
50
58
  // See events section
51
59
  }
52
60
  },
@@ -55,13 +63,9 @@ function Screen() {
55
63
  const onLaunchOpal = async () => {
56
64
  // Resulting token from POST /opal/token (otkn_*)
57
65
  const token = await getOpalToken();
58
- open({ token });
66
+ open({token});
59
67
  };
60
68
 
61
- return (
62
- <button onClick={onLaunchOpal}>
63
- Launch Opal
64
- </button>
65
- );
69
+ return <button onClick={onLaunchOpal}>Launch Opal</button>;
66
70
  }
67
- ```
71
+ ```
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { ReactNode } from 'react';
2
- import * as react_jsx_runtime from 'react/jsx-runtime';
3
2
 
4
3
  type OpalEnvironment = 'local' | 'dev' | 'sandbox' | 'production';
5
4
  type OpalMode = 'opal' | 'card_connect' | 'account_verification' | string;
@@ -104,17 +103,6 @@ interface OpalOpenOptions {
104
103
  /** The Opal token (otkn_*) obtained from POST /opal/token */
105
104
  token: string;
106
105
  }
107
- /**
108
- * Legacy message interface - use OpalEvent instead
109
- * @deprecated Use OpalEvent for better type safety
110
- */
111
- interface OpalMessage {
112
- type: string;
113
- mode: string;
114
- object: string;
115
- action: string;
116
- timestamp: string;
117
- }
118
106
  /**
119
107
  * Return type for the useOpal hook
120
108
  */
@@ -130,21 +118,6 @@ interface UseOpalReturn {
130
118
  /** Current error state, if any */
131
119
  error: OpalError | OpalErrorData | null;
132
120
  }
133
- /**
134
- * Props for the OpalIframe component
135
- */
136
- interface OpalIframeProps {
137
- /** The Opal token */
138
- token: string;
139
- /** The full Opal URL with token */
140
- opalUrl: string;
141
- /** Callback for handling iframe messages */
142
- onMessage: (message: OpalEvent) => void;
143
- /** Callback for when the iframe should be closed */
144
- onClose: () => void;
145
- /** Optional styles for the iframe container */
146
- style?: React.CSSProperties;
147
- }
148
121
 
149
122
  interface OpalProviderProps {
150
123
  children: ReactNode;
@@ -167,7 +140,6 @@ interface OpalProviderProps {
167
140
  * ```
168
141
  */
169
142
  declare function OpalProvider({ children }: OpalProviderProps): JSX.Element;
170
-
171
143
  /**
172
144
  * Hook for interacting with Opal within an OpalProvider context.
173
145
  * This hook allows you to configure event handlers and open/close Opal sessions.
@@ -204,7 +176,4 @@ declare function OpalProvider({ children }: OpalProviderProps): JSX.Element;
204
176
  */
205
177
  declare function useOpal(config?: OpalConfig): UseOpalReturn;
206
178
 
207
- declare function OpalIframe({ token, opalUrl, onMessage, style, }: OpalIframeProps): react_jsx_runtime.JSX.Element | null;
208
-
209
- export { OpalIframe, OpalProvider, useOpal };
210
- export type { AccountVerifiedEventData, CardVerifiedEventData, OpalConfig, OpalEnvironment, OpalError, OpalErrorData, OpalEvent, OpalEventAction, OpalEventData, OpalEventObject, OpalEventType, OpalIframeProps, OpalMessage, OpalMode, OpalOpenOptions, OpalSuccessData, UseOpalReturn };
179
+ export { OpalProvider, useOpal };