react-native-plaid-link-sdk 12.0.0 → 12.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.
Files changed (43) hide show
  1. package/README.md +1 -0
  2. package/android/src/main/AndroidManifest.xml +1 -1
  3. package/dist/exampleRN76/App.d.ts +3 -0
  4. package/dist/exampleRN76/App.js +129 -0
  5. package/dist/exampleRN76/Styles.d.ts +63 -0
  6. package/dist/exampleRN76/Styles.js +47 -0
  7. package/dist/exampleRN76/__tests__/App.test.d.ts +4 -0
  8. package/dist/exampleRN76/__tests__/App.test.js +13 -0
  9. package/dist/exampleRN76/babel.config.d.ts +1 -0
  10. package/dist/exampleRN76/babel.config.js +4 -0
  11. package/dist/exampleRN76/index.d.ts +1 -0
  12. package/dist/exampleRN76/index.js +7 -0
  13. package/dist/exampleRN76/jest.config.d.ts +1 -0
  14. package/dist/exampleRN76/jest.config.js +4 -0
  15. package/dist/exampleRN76/metro.config.d.ts +2 -0
  16. package/dist/exampleRN76/metro.config.js +10 -0
  17. package/dist/fabric/NativePlaidLinkModuleiOS.d.ts +1 -1
  18. package/dist/src/EmbeddedLink/EmbeddedLinkView.d.ts +13 -0
  19. package/dist/src/EmbeddedLink/EmbeddedLinkView.js +55 -0
  20. package/dist/src/EmbeddedLink/EmbeddedLinkView.web.d.ts +1 -0
  21. package/dist/src/EmbeddedLink/EmbeddedLinkView.web.js +1 -0
  22. package/dist/src/EmbeddedLink/NativeEmbeddedLinkView.d.ts +2 -0
  23. package/dist/src/EmbeddedLink/NativeEmbeddedLinkView.js +2 -0
  24. package/dist/src/PlaidLink.d.ts +27 -0
  25. package/dist/src/PlaidLink.js +130 -0
  26. package/dist/src/Types.d.ts +539 -0
  27. package/dist/src/Types.js +454 -0
  28. package/dist/src/__tests__/Types.tests.d.ts +1 -0
  29. package/dist/src/__tests__/Types.tests.js +14 -0
  30. package/dist/src/fabric/EmbeddedLinkViewNativeComponent.d.ts +17 -0
  31. package/dist/src/fabric/EmbeddedLinkViewNativeComponent.js +2 -0
  32. package/dist/src/fabric/NativePlaidLinkModuleAndroid.d.ts +14 -0
  33. package/dist/src/fabric/NativePlaidLinkModuleAndroid.js +4 -0
  34. package/dist/src/fabric/NativePlaidLinkModuleiOS.d.ts +15 -0
  35. package/dist/src/fabric/NativePlaidLinkModuleiOS.js +4 -0
  36. package/dist/src/fabric/fabricUtils.d.ts +1 -0
  37. package/dist/src/fabric/fabricUtils.js +1 -0
  38. package/dist/src/index.d.ts +4 -0
  39. package/dist/src/index.js +6 -0
  40. package/ios/RNLinksdk.mm +1 -1
  41. package/package.json +1 -1
  42. package/react-native-plaid-link-sdk.podspec +1 -1
  43. package/src/fabric/NativePlaidLinkModuleiOS.ts +2 -2
package/README.md CHANGED
@@ -184,6 +184,7 @@ While these older versions are expected to continue to work without disruption,
184
184
 
185
185
  | Plaid SDK Version | Min React Native Version | Android SDK | Android Min Version | Android Compile Version| iOS SDK | iOS Min Version | Status |
186
186
  |-------------------|--------------------------|-------------|---------------------|------------------------|---------|-----------------|-------------------------------|
187
+ | 12.0.1 | * | [5.0.0+] | 21 | 34 | >=6.0.2 | 14.0 | Active, supports Xcode 16.1.0 |
187
188
  | 12.0.0 | * | [5.0.0+] | 21 | 34 | >=6.0.0 | 14.0 | Active, supports Xcode 16.1.0 |
188
189
  | 12.0.0-beta.3 | * | [4.4.0+] | 21 | 34 | >=6.0.0 | 14.0 | Active, supports Xcode 15.3.0 |
189
190
  | 12.0.0-beta.2 | * | [4.4.0+] | 21 | 34 | >=6.0.0 | 14.0 | Active, supports Xcode 15.3.0 |
@@ -4,7 +4,7 @@
4
4
  <application>
5
5
  <meta-data
6
6
  android:name="com.plaid.link.react_native"
7
- android:value="12.0.0" />
7
+ android:value="12.0.1" />
8
8
  </application>
9
9
 
10
10
  </manifest>
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const PlaidLinkScreen: () => React.JSX.Element;
3
+ export default PlaidLinkScreen;
@@ -0,0 +1,129 @@
1
+ import React from 'react';
2
+ import { Platform, TextInput, Text, TouchableOpacity, View } from 'react-native';
3
+ import { styles } from './Styles'; // Adjust import if needed for the actual path
4
+ import { LinkLogLevel, dismissLink, usePlaidEmitter, LinkIOSPresentationStyle, create, open, syncFinanceKit, submit, EmbeddedLinkView, // Make sure this is imported
5
+ } from 'react-native-plaid-link-sdk';
6
+ // EmbeddedLinkView for displaying once a token is entered
7
+ const EmbeddedView = ({ token }) => {
8
+ let content;
9
+ if (token) {
10
+ content = (<View>
11
+ <EmbeddedLinkView token={token} iOSPresentationStyle={LinkIOSPresentationStyle.MODAL} onEvent={(event) => {
12
+ console.log('onEvent', event);
13
+ }} onSuccess={(success) => {
14
+ console.log('onSuccess', success);
15
+ }} onExit={(exit) => {
16
+ console.log('onExit', exit);
17
+ }} style={styles.embedded}/>
18
+ </View>);
19
+ }
20
+ else {
21
+ content = (<Text style={{ fontSize: 24, color: '#2196F3', textAlign: 'center' }}>
22
+ Enter Link Token
23
+ </Text>);
24
+ }
25
+ return <View style={{ padding: 24 }}>{content}</View>;
26
+ };
27
+ function isValidString(str) {
28
+ return str.trim() !== '';
29
+ }
30
+ function createLinkTokenConfiguration(token, noLoadingState = false) {
31
+ console.log(`token: ${token}`);
32
+ return {
33
+ token: token,
34
+ noLoadingState: noLoadingState,
35
+ };
36
+ }
37
+ function createSubmissionData(phoneNumber) {
38
+ return {
39
+ phoneNumber: phoneNumber,
40
+ };
41
+ }
42
+ function createLinkOpenProps() {
43
+ return {
44
+ onSuccess: (success) => {
45
+ console.log('Success: ', success);
46
+ success.metadata.accounts.forEach(it => console.log('accounts', it));
47
+ },
48
+ onExit: (linkExit) => {
49
+ console.log('Exit: ', linkExit);
50
+ dismissLink();
51
+ },
52
+ iOSPresentationStyle: LinkIOSPresentationStyle.MODAL,
53
+ logLevel: LinkLogLevel.ERROR,
54
+ };
55
+ }
56
+ const PlaidLinkScreen = () => {
57
+ // Use event emitter to get real-time events during a Link Session.
58
+ usePlaidEmitter((event) => {
59
+ console.log(event);
60
+ });
61
+ const [text, onChangeText] = React.useState('');
62
+ const [disabled, setDisabled] = React.useState(true);
63
+ const iOSVersionParts = String(Platform.Version).split('.');
64
+ const [majorVersion, minorVersion] = iOSVersionParts.length >= 2 ? iOSVersionParts : [null, null];
65
+ const financeKitText = () => {
66
+ if (majorVersion && minorVersion) {
67
+ const majorInt = parseInt(majorVersion, 10);
68
+ const minorInt = parseInt(minorVersion, 10);
69
+ if (majorInt > 17) {
70
+ return <Text style={styles.button}>Sync FinanceKit</Text>;
71
+ }
72
+ else if (majorInt === 17 && minorInt >= 4) {
73
+ return <Text style={styles.button}>Sync FinanceKit</Text>;
74
+ }
75
+ else {
76
+ return (<Text style={styles.button}>
77
+ FinanceKit not supported on this version of iOS
78
+ </Text>);
79
+ }
80
+ }
81
+ else {
82
+ return <Text style={styles.button}>Invalid iOS version</Text>;
83
+ }
84
+ };
85
+ return (<View style={{ padding: 24 }}>
86
+ <View style={{ height: 48, backgroundColor: 'white' }}/> {/* White view with 48px height */}
87
+ <TextInput style={styles.input} onChangeText={onChangeText} value={text} placeholder="link-sandbox-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" placeholderTextColor={'#D3D3D3'}/>
88
+ <TouchableOpacity style={styles.button} onPress={() => {
89
+ if (isValidString(text)) {
90
+ const tokenConfiguration = createLinkTokenConfiguration(text);
91
+ create(tokenConfiguration);
92
+ setDisabled(false);
93
+ }
94
+ }}>
95
+ <Text style={styles.button}>Create Link</Text>
96
+ </TouchableOpacity>
97
+ <TouchableOpacity disabled={disabled} style={disabled ? styles.disabledButton : styles.button} onPress={() => {
98
+ const submissionData = createSubmissionData('415-555-0015');
99
+ submit(submissionData);
100
+ }}>
101
+ <Text style={styles.button}>Submit Layer Phone Number</Text>
102
+ </TouchableOpacity>
103
+ <TouchableOpacity disabled={disabled} style={disabled ? styles.disabledButton : styles.button} onPress={() => {
104
+ const openProps = createLinkOpenProps();
105
+ open(openProps);
106
+ setDisabled(true);
107
+ }}>
108
+ <Text style={styles.button}>Open Link</Text>
109
+ </TouchableOpacity>
110
+ <TouchableOpacity style={styles.button} onPress={() => {
111
+ const completionHandler = (error) => {
112
+ if (error) {
113
+ console.error('Error:', error);
114
+ }
115
+ else {
116
+ console.log('Sync completed successfully');
117
+ }
118
+ };
119
+ const requestAuthorizationIfNeeded = true;
120
+ syncFinanceKit(text, requestAuthorizationIfNeeded, completionHandler);
121
+ }}>
122
+ {financeKitText()}
123
+ </TouchableOpacity>
124
+
125
+ {/* Embedded Link View below the buttons */}
126
+ <EmbeddedView token={text}/>
127
+ </View>);
128
+ };
129
+ export default PlaidLinkScreen;
@@ -0,0 +1,63 @@
1
+ export namespace styles {
2
+ namespace button {
3
+ let elevation: number;
4
+ let backgroundColor: string;
5
+ let width: "90%";
6
+ let margin: number;
7
+ let paddingVertical: number;
8
+ let fontSize: number;
9
+ let textAlign: "center";
10
+ let color: string;
11
+ let borderRadius: number;
12
+ let alignSelf: "center";
13
+ let textTransform: "uppercase";
14
+ let overflow: "hidden";
15
+ }
16
+ namespace disabledButton {
17
+ let elevation_1: number;
18
+ export { elevation_1 as elevation };
19
+ let backgroundColor_1: string;
20
+ export { backgroundColor_1 as backgroundColor };
21
+ let width_1: "90%";
22
+ export { width_1 as width };
23
+ let margin_1: number;
24
+ export { margin_1 as margin };
25
+ let paddingVertical_1: number;
26
+ export { paddingVertical_1 as paddingVertical };
27
+ let fontSize_1: number;
28
+ export { fontSize_1 as fontSize };
29
+ let textAlign_1: "center";
30
+ export { textAlign_1 as textAlign };
31
+ let color_1: string;
32
+ export { color_1 as color };
33
+ let borderRadius_1: number;
34
+ export { borderRadius_1 as borderRadius };
35
+ let alignSelf_1: "center";
36
+ export { alignSelf_1 as alignSelf };
37
+ let textTransform_1: "uppercase";
38
+ export { textTransform_1 as textTransform };
39
+ let overflow_1: "hidden";
40
+ export { overflow_1 as overflow };
41
+ export let opacity: number;
42
+ }
43
+ namespace input {
44
+ export let height: number;
45
+ let margin_2: number;
46
+ export { margin_2 as margin };
47
+ let width_2: "90%";
48
+ export { width_2 as width };
49
+ let alignSelf_2: "center";
50
+ export { alignSelf_2 as alignSelf };
51
+ export let borderWidth: number;
52
+ export let padding: number;
53
+ export let borderColor: any;
54
+ }
55
+ namespace embedded {
56
+ let width_3: "95%";
57
+ export { width_3 as width };
58
+ let alignSelf_3: "center";
59
+ export { alignSelf_3 as alignSelf };
60
+ let height_1: number;
61
+ export { height_1 as height };
62
+ }
63
+ }
@@ -0,0 +1,47 @@
1
+ import { StyleSheet } from 'react-native';
2
+ import { Colors } from 'react-native/Libraries/NewAppScreen';
3
+ export const styles = StyleSheet.create({
4
+ button: {
5
+ elevation: 8,
6
+ backgroundColor: '#2196F3',
7
+ width: '90%',
8
+ margin: 4,
9
+ paddingVertical: 4,
10
+ fontSize: 16,
11
+ textAlign: 'center',
12
+ color: 'white',
13
+ borderRadius: 4,
14
+ alignSelf: 'center',
15
+ textTransform: 'uppercase',
16
+ overflow: 'hidden',
17
+ },
18
+ disabledButton: {
19
+ elevation: 8,
20
+ backgroundColor: '#2196F3',
21
+ width: '90%',
22
+ margin: 4,
23
+ paddingVertical: 4,
24
+ fontSize: 16,
25
+ textAlign: 'center',
26
+ color: 'white',
27
+ borderRadius: 4,
28
+ alignSelf: 'center',
29
+ textTransform: 'uppercase',
30
+ overflow: 'hidden',
31
+ opacity: 0.5,
32
+ },
33
+ input: {
34
+ height: 40,
35
+ margin: 12,
36
+ width: '90%',
37
+ alignSelf: 'center',
38
+ borderWidth: 1,
39
+ padding: 10,
40
+ borderColor: Colors.black,
41
+ },
42
+ embedded: {
43
+ width: '95%',
44
+ alignSelf: 'center',
45
+ height: 360,
46
+ },
47
+ });
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @format
3
+ */
4
+ import 'react-native';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @format
3
+ */
4
+ import 'react-native';
5
+ import React from 'react';
6
+ import App from '../App';
7
+ // Note: import explicitly to use the types shipped with jest.
8
+ import { it } from '@jest/globals';
9
+ // Note: test renderer must be required after react-native.
10
+ import renderer from 'react-test-renderer';
11
+ it('renders correctly', () => {
12
+ renderer.create(<App />);
13
+ });
@@ -0,0 +1 @@
1
+ export let presets: string[];
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ module.exports = {
3
+ presets: ['module:@react-native/babel-preset'],
4
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @format
3
+ */
4
+ import { AppRegistry } from 'react-native';
5
+ import App from './App';
6
+ import { name as appName } from './app.json';
7
+ AppRegistry.registerComponent(appName, () => App);
@@ -0,0 +1 @@
1
+ export let preset: string;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ module.exports = {
3
+ preset: 'react-native',
4
+ };
@@ -0,0 +1,2 @@
1
+ declare const _exports: any;
2
+ export = _exports;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
3
+ /**
4
+ * Metro configuration
5
+ * https://reactnative.dev/docs/metro
6
+ *
7
+ * @type {import('metro-config').MetroConfig}
8
+ */
9
+ const config = {};
10
+ module.exports = mergeConfig(getDefaultConfig(__dirname), config);
@@ -9,7 +9,7 @@ export interface Spec extends TurboModule {
9
9
  submit(phoneNumber: string | undefined): void;
10
10
  addListener(eventName: string): void;
11
11
  removeListeners(count: Int32): void;
12
- syncFinanceKit(token: string, requestAuthorizationIfNeeded: boolean, onSuccess: (success: void) => void, onError: (error: FinanceKitError) => void): void;
12
+ syncFinanceKit(token: string, requestAuthorizationIfNeeded: boolean, onSuccess: (success: boolean) => void, onError: (error: UnsafeObject<FinanceKitError>) => void): void;
13
13
  }
14
14
  declare const _default: Spec | null;
15
15
  export default _default;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { StyleProp, ViewStyle } from 'react-native';
3
+ import { LinkSuccessListener, LinkExitListener, LinkIOSPresentationStyle, LinkOnEventListener } from '../Types';
4
+ type EmbeddedLinkProps = {
5
+ token: string;
6
+ iOSPresentationStyle: LinkIOSPresentationStyle;
7
+ onEvent: LinkOnEventListener | undefined;
8
+ onSuccess: LinkSuccessListener;
9
+ onExit: LinkExitListener | undefined;
10
+ style: StyleProp<ViewStyle> | undefined;
11
+ };
12
+ export declare const EmbeddedLinkView: React.FC<EmbeddedLinkProps>;
13
+ export {};
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+ import NativeEmbeddedLinkView from './NativeEmbeddedLinkView';
3
+ class EmbeddedEvent {
4
+ constructor(event) {
5
+ this.eventName = event.eventName;
6
+ this.metadata = event.metadata;
7
+ }
8
+ }
9
+ class EmbeddedExit {
10
+ constructor(event) {
11
+ this.error = event.error;
12
+ this.metadata = event.metadata;
13
+ }
14
+ }
15
+ class EmbeddedSuccess {
16
+ constructor(event) {
17
+ this.publicToken = event.publicToken;
18
+ this.metadata = event.metadata;
19
+ }
20
+ }
21
+ export const EmbeddedLinkView = (props) => {
22
+ const { token, iOSPresentationStyle, onEvent, onSuccess, onExit, style } = props;
23
+ const onEmbeddedEvent = (event) => {
24
+ switch (event.nativeEvent.embeddedEventName) {
25
+ case 'onSuccess': {
26
+ if (!onSuccess) {
27
+ return;
28
+ }
29
+ const embeddedSuccess = new EmbeddedSuccess(event.nativeEvent);
30
+ onSuccess(embeddedSuccess);
31
+ break;
32
+ }
33
+ case 'onExit': {
34
+ if (!onExit) {
35
+ return;
36
+ }
37
+ const embeddedExit = new EmbeddedExit(event.nativeEvent);
38
+ onExit(embeddedExit);
39
+ break;
40
+ }
41
+ case 'onEvent': {
42
+ if (!onEvent) {
43
+ return;
44
+ }
45
+ const embeddedEvent = new EmbeddedEvent(event.nativeEvent);
46
+ onEvent(embeddedEvent);
47
+ break;
48
+ }
49
+ default: {
50
+ return;
51
+ }
52
+ }
53
+ };
54
+ return <NativeEmbeddedLinkView token={token} iOSPresentationStyle={iOSPresentationStyle.toString()} onEmbeddedEvent={onEmbeddedEvent} style={style}/>;
55
+ };
@@ -0,0 +1 @@
1
+ export declare const EmbeddedLinkView: () => null;
@@ -0,0 +1 @@
1
+ export const EmbeddedLinkView = () => null;
@@ -0,0 +1,2 @@
1
+ import NativeEmbeddedLinkView from '../fabric/EmbeddedLinkViewNativeComponent';
2
+ export default NativeEmbeddedLinkView;
@@ -0,0 +1,2 @@
1
+ import NativeEmbeddedLinkView from '../fabric/EmbeddedLinkViewNativeComponent';
2
+ export default NativeEmbeddedLinkView;
@@ -0,0 +1,27 @@
1
+ import { LinkEventListener, LinkOpenProps, LinkTokenConfiguration, FinanceKitError, SubmissionData } from './Types';
2
+ /**
3
+ * A hook that registers a listener on the Plaid emitter for the 'onEvent' type.
4
+ * The listener is cleaned up when this view is unmounted
5
+ *
6
+ * @param LinkEventListener the listener to call
7
+ */
8
+ export declare const usePlaidEmitter: (linkEventListener: LinkEventListener) => void;
9
+ export declare const create: (props: LinkTokenConfiguration) => void;
10
+ export declare const open: (props: LinkOpenProps) => Promise<void>;
11
+ export declare const dismissLink: () => void;
12
+ export declare const submit: (data: SubmissionData) => void;
13
+ /**
14
+ * Function to sync the user's transactions from their Apple card.
15
+ *
16
+ * @param {string} token - The `LinkToken` your server retrieved from the /link/token/create endpoint from the Plaid API.
17
+ * This token must be associated with an accessToken.
18
+ * @param {boolean} requestAuthorizationIfNeeded - Indicates if the user should be prompted to authorize the sync if
19
+ * they have not already done so.
20
+ * @param {function} completion - A callback function that is called when the sync has completed.
21
+ *
22
+ * @warning This method only works on iOS >= 17.4.
23
+ * @warning This method is not supported on Android or MacCatalyst.
24
+ * @warning This method can only be used once the user has granted access to their Apple card via a standard Link Session.
25
+ * @warning This method requires that your app has been granted FinanceKit access from Apple.
26
+ */
27
+ export declare const syncFinanceKit: (token: string, requestAuthorizationIfNeeded: boolean, completion: (error?: FinanceKitError) => void) => void;
@@ -0,0 +1,130 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var _a;
11
+ import { useEffect } from 'react';
12
+ import { NativeEventEmitter, Platform } from 'react-native';
13
+ import { LinkIOSPresentationStyle, LinkLogLevel, FinanceKitErrorType, } from './Types';
14
+ import RNLinksdkAndroid from './fabric/NativePlaidLinkModuleAndroid';
15
+ import RNLinksdkiOS from './fabric/NativePlaidLinkModuleiOS';
16
+ const RNLinksdk = (_a = (Platform.OS === 'android' ? RNLinksdkAndroid : RNLinksdkiOS)) !== null && _a !== void 0 ? _a : undefined;
17
+ /**
18
+ * A hook that registers a listener on the Plaid emitter for the 'onEvent' type.
19
+ * The listener is cleaned up when this view is unmounted
20
+ *
21
+ * @param LinkEventListener the listener to call
22
+ */
23
+ export const usePlaidEmitter = (linkEventListener) => {
24
+ useEffect(() => {
25
+ const emitter = new NativeEventEmitter(RNLinksdk);
26
+ const listener = emitter.addListener('onEvent', linkEventListener);
27
+ // Clean up after this effect:
28
+ return function cleanup() {
29
+ listener.remove();
30
+ };
31
+ }, []);
32
+ };
33
+ export const create = (props) => {
34
+ var _a, _b;
35
+ let token = props.token;
36
+ let noLoadingState = (_a = props.noLoadingState) !== null && _a !== void 0 ? _a : false;
37
+ if (Platform.OS === 'android') {
38
+ RNLinksdkAndroid === null || RNLinksdkAndroid === void 0 ? void 0 : RNLinksdkAndroid.create(token, noLoadingState, (_b = props.logLevel) !== null && _b !== void 0 ? _b : LinkLogLevel.ERROR);
39
+ }
40
+ else {
41
+ RNLinksdkiOS === null || RNLinksdkiOS === void 0 ? void 0 : RNLinksdkiOS.create(token, noLoadingState);
42
+ }
43
+ };
44
+ export const open = (props) => __awaiter(void 0, void 0, void 0, function* () {
45
+ if (Platform.OS === 'android') {
46
+ RNLinksdkAndroid === null || RNLinksdkAndroid === void 0 ? void 0 : RNLinksdkAndroid.open((result) => {
47
+ if (props.onSuccess != null) {
48
+ props.onSuccess(result);
49
+ }
50
+ return true;
51
+ }, (result) => {
52
+ if (props.onExit != null) {
53
+ if (result.error != null && result.error.displayMessage != null) {
54
+ //TODO(RNSDK-118): Remove errorDisplayMessage field in next major update.
55
+ result.error.errorDisplayMessage = result.error.displayMessage;
56
+ }
57
+ props.onExit(result);
58
+ }
59
+ return true;
60
+ });
61
+ }
62
+ else {
63
+ let presentFullScreen = props.iOSPresentationStyle == LinkIOSPresentationStyle.FULL_SCREEN;
64
+ RNLinksdkiOS === null || RNLinksdkiOS === void 0 ? void 0 : RNLinksdkiOS.open(presentFullScreen, (result) => {
65
+ if (props.onSuccess != null) {
66
+ props.onSuccess(result);
67
+ }
68
+ return true;
69
+ }, (error, result) => {
70
+ if (props.onExit != null) {
71
+ if (error) {
72
+ var data = result || {};
73
+ data.error = error;
74
+ props.onExit(data);
75
+ }
76
+ else {
77
+ props.onExit(result);
78
+ }
79
+ }
80
+ return true;
81
+ });
82
+ }
83
+ });
84
+ export const dismissLink = () => {
85
+ if (Platform.OS === 'ios') {
86
+ RNLinksdkiOS === null || RNLinksdkiOS === void 0 ? void 0 : RNLinksdkiOS.dismiss();
87
+ }
88
+ };
89
+ export const submit = (data) => {
90
+ if (Platform.OS === 'android') {
91
+ RNLinksdkAndroid === null || RNLinksdkAndroid === void 0 ? void 0 : RNLinksdkAndroid.submit(data.phoneNumber);
92
+ }
93
+ else {
94
+ RNLinksdkiOS === null || RNLinksdkiOS === void 0 ? void 0 : RNLinksdkiOS.submit(data.phoneNumber);
95
+ }
96
+ };
97
+ /**
98
+ * Function to sync the user's transactions from their Apple card.
99
+ *
100
+ * @param {string} token - The `LinkToken` your server retrieved from the /link/token/create endpoint from the Plaid API.
101
+ * This token must be associated with an accessToken.
102
+ * @param {boolean} requestAuthorizationIfNeeded - Indicates if the user should be prompted to authorize the sync if
103
+ * they have not already done so.
104
+ * @param {function} completion - A callback function that is called when the sync has completed.
105
+ *
106
+ * @warning This method only works on iOS >= 17.4.
107
+ * @warning This method is not supported on Android or MacCatalyst.
108
+ * @warning This method can only be used once the user has granted access to their Apple card via a standard Link Session.
109
+ * @warning This method requires that your app has been granted FinanceKit access from Apple.
110
+ */
111
+ export const syncFinanceKit = (token, requestAuthorizationIfNeeded, completion) => {
112
+ if (Platform.OS === 'android') {
113
+ completion({
114
+ type: FinanceKitErrorType.Unknown,
115
+ message: "FinanceKit is unavailable on Android!",
116
+ });
117
+ }
118
+ else {
119
+ RNLinksdkiOS === null || RNLinksdkiOS === void 0 ? void 0 : RNLinksdkiOS.syncFinanceKit(token, requestAuthorizationIfNeeded, () => {
120
+ completion();
121
+ return true;
122
+ }, (error) => {
123
+ completion({
124
+ type: error.type,
125
+ message: error.message,
126
+ });
127
+ return true;
128
+ });
129
+ }
130
+ };