react-native-plaid-link-sdk 11.8.1 → 11.9.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.
Files changed (49) hide show
  1. package/README.md +3 -1
  2. package/android/build.gradle +37 -1
  3. package/android/src/main/AndroidManifest.xml +1 -1
  4. package/android/src/main/java/com/plaid/PLKEmbeddedViewManager.kt +21 -5
  5. package/android/src/main/java/com/plaid/PlaidModule.kt +13 -12
  6. package/android/src/main/java/com/plaid/PlaidPackage.java +93 -22
  7. package/android/src/paper/java/com/facebook/react/viewmanagers/PLKEmbeddedViewManagerDelegate.java +34 -0
  8. package/android/src/paper/java/com/facebook/react/viewmanagers/PLKEmbeddedViewManagerInterface.java +18 -0
  9. package/android/src/paper/java/com/plaid/NativePlaidLinkModuleAndroidSpec.java +54 -0
  10. package/android/src/paper/java/com/plaid/NativePlaidLinkModuleiOSSpec.java +54 -0
  11. package/dist/EmbeddedLink/EmbeddedLinkView.d.ts +1 -1
  12. package/dist/EmbeddedLink/NativeEmbeddedLinkView.d.ts +1 -1
  13. package/dist/EmbeddedLink/NativeEmbeddedLinkView.js +1 -6
  14. package/dist/PlaidLink.d.ts +1 -1
  15. package/dist/PlaidLink.js +18 -16
  16. package/dist/fabric/EmbeddedLinkViewNativeComponent.d.ts +15 -0
  17. package/dist/fabric/EmbeddedLinkViewNativeComponent.js +2 -0
  18. package/dist/fabric/NativePlaidLinkModuleAndroid.d.ts +13 -0
  19. package/dist/fabric/NativePlaidLinkModuleAndroid.js +4 -0
  20. package/dist/fabric/NativePlaidLinkModuleiOS.d.ts +13 -0
  21. package/dist/fabric/NativePlaidLinkModuleiOS.js +4 -0
  22. package/dist/fabric/fabricUtils.d.ts +1 -0
  23. package/dist/fabric/fabricUtils.js +1 -0
  24. package/ios/PLKEmbeddedView.m +1 -1
  25. package/ios/PLKEmbeddedView.swift +4 -4
  26. package/ios/PLKEmbeddedViewComponentView.h +15 -0
  27. package/ios/PLKEmbeddedViewComponentView.mm +85 -0
  28. package/ios/PLKFabricHelpers.h +70 -0
  29. package/ios/RNLinksdk.h +10 -8
  30. package/ios/{RNLinksdk.m → RNLinksdk.mm} +20 -10
  31. package/ios/RNLinksdk.xcodeproj/project.pbxproj +20 -4
  32. package/ios/RNLinksdk.xcodeproj/project.xcworkspace/xcuserdata/dtroupe.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  33. package/ios/RNLinksdk.xcworkspace/xcuserdata/dtroupe.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  34. package/ios/RNPlaidHelper.h +7 -0
  35. package/ios/RNPlaidHelper.m +10 -0
  36. package/ios/react_native_plaid_link_sdk.h +2 -0
  37. package/package.json +14 -4
  38. package/react-native-plaid-link-sdk.podspec +14 -2
  39. package/src/EmbeddedLink/EmbeddedLinkView.tsx +95 -0
  40. package/src/EmbeddedLink/EmbeddedLinkView.web.tsx +5 -0
  41. package/src/EmbeddedLink/NativeEmbeddedLinkView.tsx +3 -0
  42. package/src/PlaidLink.tsx +181 -0
  43. package/src/Types.ts +559 -0
  44. package/src/__tests__/Types.tests.ts +15 -0
  45. package/src/fabric/EmbeddedLinkViewNativeComponent.ts +24 -0
  46. package/src/fabric/NativePlaidLinkModuleAndroid.ts +26 -0
  47. package/src/fabric/NativePlaidLinkModuleiOS.ts +21 -0
  48. package/src/fabric/fabricUtils.ts +2 -0
  49. package/src/index.ts +21 -0
@@ -0,0 +1,5 @@
1
+ // EmbeddedLinkView.web.tsx is a shim file which causes web bundlers to ignore the EmbeddedLinkView.tsx file
2
+ // which imports requireNativeComponent (causing a runtime error with react-native-web).
3
+ // Ref - https://github.com/plaid/react-native-plaid-link-sdk/issues/564
4
+ import React from 'react';
5
+ export const EmbeddedLinkView = () => null;
@@ -0,0 +1,3 @@
1
+ import NativeEmbeddedLinkView from '../fabric/EmbeddedLinkViewNativeComponent';
2
+
3
+ export default NativeEmbeddedLinkView;
@@ -0,0 +1,181 @@
1
+ import React, { useEffect } from 'react';
2
+ import { NativeEventEmitter, Platform, TouchableOpacity } from 'react-native';
3
+ import {
4
+ LinkError,
5
+ LinkEventListener,
6
+ LinkExit,
7
+ LinkIOSPresentationStyle,
8
+ LinkLogLevel,
9
+ LinkOpenProps,
10
+ LinkSuccess,
11
+ LinkTokenConfiguration,
12
+ PlaidLinkComponentProps,
13
+ PlaidLinkProps,
14
+ } from './Types';
15
+ import RNLinksdkAndroid from './fabric/NativePlaidLinkModuleAndroid';
16
+ import RNLinksdkiOS from './fabric/NativePlaidLinkModuleiOS';
17
+
18
+ const RNLinksdk =
19
+ (Platform.OS === 'android' ? RNLinksdkAndroid : RNLinksdkiOS) ?? undefined;
20
+
21
+ /**
22
+ * A hook that registers a listener on the Plaid emitter for the 'onEvent' type.
23
+ * The listener is cleaned up when this view is unmounted
24
+ *
25
+ * @param LinkEventListener the listener to call
26
+ */
27
+ export const usePlaidEmitter = (linkEventListener: LinkEventListener) => {
28
+ useEffect(() => {
29
+ const emitter = new NativeEventEmitter(RNLinksdk);
30
+ const listener = emitter.addListener('onEvent', linkEventListener);
31
+ // Clean up after this effect:
32
+ return function cleanup() {
33
+ listener.remove();
34
+ };
35
+ }, []);
36
+ };
37
+
38
+ export const create = (props: LinkTokenConfiguration) => {
39
+ let token = props.token;
40
+ let noLoadingState = props.noLoadingState ?? false;
41
+
42
+ if (Platform.OS === 'android') {
43
+ RNLinksdkAndroid?.create(
44
+ token,
45
+ noLoadingState,
46
+ props.logLevel ?? LinkLogLevel.ERROR,
47
+ );
48
+ } else {
49
+ RNLinksdkiOS?.create(token, noLoadingState);
50
+ }
51
+ };
52
+
53
+ export const open = async (props: LinkOpenProps) => {
54
+ if (Platform.OS === 'android') {
55
+ RNLinksdkAndroid?.open(
56
+ (result: LinkSuccess) => {
57
+ if (props.onSuccess != null) {
58
+ props.onSuccess(result);
59
+ }
60
+ },
61
+ (result: LinkExit) => {
62
+ if (props.onExit != null) {
63
+ if (result.error != null && result.error.displayMessage != null) {
64
+ //TODO(RNSDK-118): Remove errorDisplayMessage field in next major update.
65
+ result.error.errorDisplayMessage = result.error.displayMessage;
66
+ }
67
+ props.onExit(result);
68
+ }
69
+ },
70
+ );
71
+ } else {
72
+ let presentFullScreen =
73
+ props.iOSPresentationStyle == LinkIOSPresentationStyle.FULL_SCREEN;
74
+
75
+ RNLinksdkiOS?.open(
76
+ presentFullScreen,
77
+ (result: LinkSuccess) => {
78
+ if (props.onSuccess != null) {
79
+ props.onSuccess(result);
80
+ }
81
+ },
82
+ (error: LinkError, result: LinkExit) => {
83
+ if (props.onExit != null) {
84
+ if (error) {
85
+ var data = result || {};
86
+ data.error = error;
87
+ props.onExit(data);
88
+ } else {
89
+ props.onExit(result);
90
+ }
91
+ }
92
+ },
93
+ );
94
+ }
95
+ };
96
+
97
+ export const dismissLink = () => {
98
+ if (Platform.OS === 'ios') {
99
+ RNLinksdkiOS?.dismiss();
100
+ }
101
+ };
102
+
103
+ /**
104
+ * @deprecated This component is deprecated. Create your own component and use the create & open methods.
105
+ */
106
+ export const PlaidLink = (props: PlaidLinkComponentProps) => {
107
+ function onPress() {
108
+ // Create a handler.
109
+ create(props.tokenConfig);
110
+
111
+ props.onPress?.();
112
+
113
+ const openProps: LinkOpenProps = {
114
+ onSuccess: props.onSuccess,
115
+ onExit: props.onExit,
116
+ iOSPresentationStyle: props.iOSPresentationStyle,
117
+ logLevel: props.logLevel,
118
+ };
119
+
120
+ open(openProps);
121
+ }
122
+
123
+ return (
124
+ <TouchableOpacity onPress={onPress}>{props.children}</TouchableOpacity>
125
+ );
126
+ };
127
+
128
+ /**
129
+ * @deprecated This method is deprecated. For faster loading use the create & open methods.
130
+ */
131
+ export const openLink = async (props: PlaidLinkProps) => {
132
+ let config = props.tokenConfig;
133
+ let noLoadingState = config.noLoadingState ?? false;
134
+
135
+ if (Platform.OS === 'android') {
136
+ RNLinksdkAndroid?.startLinkActivityForResult(
137
+ config.token,
138
+ noLoadingState,
139
+ config.logLevel ?? LinkLogLevel.ERROR,
140
+ (result: LinkSuccess) => {
141
+ if (props.onSuccess != null) {
142
+ props.onSuccess(result);
143
+ }
144
+ },
145
+ (result: LinkExit) => {
146
+ if (props.onExit != null) {
147
+ if (result.error != null && result.error.displayMessage != null) {
148
+ //TODO(RNSDK-118): Remove errorDisplayMessage field in next major update.
149
+ result.error.errorDisplayMessage = result.error.displayMessage;
150
+ }
151
+ props.onExit(result);
152
+ }
153
+ },
154
+ );
155
+ } else {
156
+ RNLinksdkiOS?.create(config.token, noLoadingState);
157
+
158
+ let presentFullScreen =
159
+ props.iOSPresentationStyle == LinkIOSPresentationStyle.FULL_SCREEN;
160
+
161
+ RNLinksdkiOS?.open(
162
+ presentFullScreen,
163
+ (result: LinkSuccess) => {
164
+ if (props.onSuccess != null) {
165
+ props.onSuccess(result);
166
+ }
167
+ },
168
+ (error: LinkError, result: LinkExit) => {
169
+ if (props.onExit != null) {
170
+ if (error) {
171
+ var data = result || {};
172
+ data.error = error;
173
+ props.onExit(data);
174
+ } else {
175
+ props.onExit(result);
176
+ }
177
+ }
178
+ },
179
+ );
180
+ }
181
+ };