@methodfi/opal-react 1.1.0 → 1.3.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/dist/index.d.ts +20 -12
- package/dist/index.js +18 -7
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
type OpalEnvironment = 'local' | 'dev' | 'sandbox' | 'production';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
declare const OpalMode: {
|
|
5
|
+
readonly CONNECT: "connect";
|
|
6
|
+
readonly CARD_CONNECT: "card_connect";
|
|
7
|
+
readonly ACCOUNT_VERIFICATION: "account_verification";
|
|
8
|
+
readonly IDENTITY: "identity";
|
|
9
|
+
};
|
|
10
|
+
type OpalMode = (typeof OpalMode)[keyof typeof OpalMode];
|
|
7
11
|
declare const OpalEventType: {
|
|
8
|
-
readonly SESSION_STARTED: "opal.
|
|
9
|
-
readonly SESSION_ERRORED: "opal.
|
|
10
|
-
readonly SESSION_EXITED: "opal.
|
|
11
|
-
readonly SESSION_COMPLETED: "opal.
|
|
12
|
+
readonly SESSION_STARTED: "opal.started";
|
|
13
|
+
readonly SESSION_ERRORED: "opal.errored";
|
|
14
|
+
readonly SESSION_EXITED: "opal.exited";
|
|
15
|
+
readonly SESSION_COMPLETED: "opal.completed";
|
|
16
|
+
readonly FLOW_STARTED: "flow.started";
|
|
17
|
+
readonly FLOW_COMPLETED: "flow.completed";
|
|
18
|
+
readonly STEP_STARTED: "step.started";
|
|
19
|
+
readonly STEP_COMPLETED: "step.completed";
|
|
12
20
|
};
|
|
13
|
-
type OpalEventType =
|
|
21
|
+
type OpalEventType = (typeof OpalEventType)[keyof typeof OpalEventType];
|
|
14
22
|
/**
|
|
15
23
|
* Structured event object matching Method's Opal event format
|
|
16
|
-
* Types follow the pattern: <
|
|
24
|
+
* Types follow the pattern: <object>.<action>, which is
|
|
17
25
|
* also split up into those properties for convenience.
|
|
18
26
|
*/
|
|
19
27
|
interface OpalEvent {
|
|
20
28
|
type: OpalEventType;
|
|
21
29
|
mode: OpalMode;
|
|
22
|
-
object:
|
|
23
|
-
action:
|
|
30
|
+
object: string;
|
|
31
|
+
action: string;
|
|
24
32
|
timestamp: string;
|
|
25
33
|
data?: OpalEventData | null;
|
|
26
34
|
}
|
|
@@ -143,4 +151,4 @@ declare function OpalProvider({ children }: OpalProviderProps): JSX.Element;
|
|
|
143
151
|
*/
|
|
144
152
|
declare function useOpal(config?: OpalConfig): UseOpalReturn;
|
|
145
153
|
|
|
146
|
-
export { OpalEventType, OpalProvider, useOpal };
|
|
154
|
+
export { OpalEventType, OpalMode, OpalProvider, useOpal };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React, { useState, createContext, useEffect, useRef, useCallback, useContext } from 'react';
|
|
3
3
|
|
|
4
|
+
// Opal modes supported by the SDK
|
|
5
|
+
const OpalMode = {
|
|
6
|
+
CONNECT: 'connect',
|
|
7
|
+
CARD_CONNECT: 'card_connect',
|
|
8
|
+
ACCOUNT_VERIFICATION: 'account_verification',
|
|
9
|
+
IDENTITY: 'identity'
|
|
10
|
+
};
|
|
4
11
|
// Common Opal event types - supports card_connect and account_verification modes
|
|
5
12
|
const OpalEventType = {
|
|
6
|
-
SESSION_STARTED: 'opal.
|
|
7
|
-
SESSION_ERRORED: 'opal.
|
|
8
|
-
SESSION_EXITED: 'opal.
|
|
9
|
-
SESSION_COMPLETED: 'opal.
|
|
13
|
+
SESSION_STARTED: 'opal.started',
|
|
14
|
+
SESSION_ERRORED: 'opal.errored',
|
|
15
|
+
SESSION_EXITED: 'opal.exited',
|
|
16
|
+
SESSION_COMPLETED: 'opal.completed',
|
|
17
|
+
FLOW_STARTED: 'flow.started',
|
|
18
|
+
FLOW_COMPLETED: 'flow.completed',
|
|
19
|
+
STEP_STARTED: 'step.started',
|
|
20
|
+
STEP_COMPLETED: 'step.completed'
|
|
10
21
|
};
|
|
11
22
|
|
|
12
23
|
const OPAL_URLS = {
|
|
@@ -177,8 +188,8 @@ function OpalIframe({ token, opalUrl, onMessage, style }) {
|
|
|
177
188
|
}
|
|
178
189
|
} catch (error) {
|
|
179
190
|
onMessage({
|
|
180
|
-
type: 'opal.
|
|
181
|
-
mode:
|
|
191
|
+
type: 'opal.errored',
|
|
192
|
+
mode: event.data.mode,
|
|
182
193
|
object: 'session',
|
|
183
194
|
action: 'errored',
|
|
184
195
|
timestamp: new Date().toISOString(),
|
|
@@ -209,4 +220,4 @@ function OpalIframe({ token, opalUrl, onMessage, style }) {
|
|
|
209
220
|
});
|
|
210
221
|
}
|
|
211
222
|
|
|
212
|
-
export { OpalEventType, OpalProvider, useOpal };
|
|
223
|
+
export { OpalEventType, OpalMode, OpalProvider, useOpal };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@methodfi/opal-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "React SDK for Opal integration",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -26,4 +26,4 @@
|
|
|
26
26
|
"react": "^18.0.0 || ^19.0.0 || ^19.0.0-rc",
|
|
27
27
|
"react-dom": "^18.0.0 || ^19.0.0 || ^19.0.0-rc"
|
|
28
28
|
}
|
|
29
|
-
}
|
|
29
|
+
}
|