react-native-plaid-link-sdk 12.0.3 → 12.1.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/README.md CHANGED
@@ -33,12 +33,6 @@ npm install --save react-native-plaid-link-sdk
33
33
 
34
34
  ### iOS Setup
35
35
 
36
- Add `Plaid` to your project’s Podfile as follows (likely located at `ios/Podfile`). The latest version is ![version](https://img.shields.io/cocoapods/v/Plaid).
37
-
38
- ```bash switcher=false
39
- pod 'Plaid', '~> <insert latest version>'
40
- ```
41
-
42
36
  Autolinking should install the CocoaPods dependencies for iOS project. If it fails you can run
43
37
 
44
38
  ```sh
@@ -172,6 +166,34 @@ The React Native Plaid module emits `onEvent` events throughout the account link
172
166
  })
173
167
  ```
174
168
 
169
+ #### Clearing Previous Session State with `destroy()`
170
+
171
+ The `destroy()` method clears state and resources from a previously opened session.
172
+ It's especially useful if you're seeing unexpected behavior when calling `create()` multiple times — for example, if the phone number isn't submitting properly after multiple `create()` calls.
173
+
174
+ #### Problem scenario:
175
+ ```ts
176
+ create(tokenConfiguration1)
177
+ create(tokenConfiguration2)
178
+ submit(phoneNumber) // <-- might not submit correctly
179
+ ```
180
+
181
+ #### Solution:
182
+ ```ts
183
+ create(tokenConfiguration1)
184
+ async () => {
185
+ try {
186
+ await destroy(); // Clear previous session state
187
+ create(tokenConfiguration2);
188
+ submit(phoneNumber);
189
+ } catch (e) {
190
+ console.error('Error during flow:', e);
191
+ }
192
+ }
193
+ ```
194
+
195
+ By calling destroy() before the second create(), you ensure a clean state, preventing issues like failed phone number submissions.
196
+
175
197
  ## Upgrading
176
198
 
177
199
  Plaid releases updates to the SDK approximately every few months. For the best user experience, we recommend using the latest version of the SDK.
@@ -184,6 +206,8 @@ While these older versions are expected to continue to work without disruption,
184
206
 
185
207
  | Plaid SDK Version | Min React Native Version | Android SDK | Android Min Version | Android Compile Version| iOS SDK | iOS Min Version | Status |
186
208
  |-------------------|--------------------------|-------------|---------------------|------------------------|---------|-----------------|-------------------------------|
209
+ | 12.1.1 | * | [5.0.0+] | 21 | 34 | >=6.1.0 | 14.0 | Active, supports Xcode 16.1.0 |
210
+ | 12.1.0 | * | [5.0.0+] | 21 | 34 | >=6.1.0 | 14.0 | Active, supports Xcode 16.1.0 |
187
211
  | 12.0.3 | * | [5.0.0+] | 21 | 34 | >=6.0.4 | 14.0 | Active, supports Xcode 16.1.0 |
188
212
  | 12.0.2 | * | [5.0.0+] | 21 | 34 | >=6.0.2 | 14.0 | Active, supports Xcode 16.1.0 |
189
213
  | 12.0.1 | * | [5.0.0+] | 21 | 34 | >=6.0.2 | 14.0 | Active, supports Xcode 16.1.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.3" />
7
+ android:value="12.1.1" />
8
8
  </application>
9
9
 
10
10
  </manifest>
@@ -3,10 +3,13 @@ package com.plaid
3
3
  import android.app.Activity
4
4
  import android.app.Application
5
5
  import android.content.Intent
6
+ import android.os.Handler
7
+ import android.os.Looper
6
8
  import android.text.TextUtils
7
9
  import android.util.Log
8
10
  import com.facebook.react.bridge.ActivityEventListener
9
11
  import com.facebook.react.bridge.Callback
12
+ import com.facebook.react.bridge.Promise
10
13
  import com.facebook.react.bridge.ReactApplicationContext
11
14
  import com.facebook.react.bridge.ReactMethod
12
15
  import com.facebook.react.module.annotations.ReactModule
@@ -22,6 +25,8 @@ import com.plaid.link.result.LinkResultHandler
22
25
  import com.plaid.link.SubmissionData
23
26
  import org.json.JSONException
24
27
  import org.json.JSONObject
28
+ import java.util.concurrent.CountDownLatch
29
+ import java.util.concurrent.TimeUnit
25
30
 
26
31
  @ReactModule(name = PlaidModule.NAME)
27
32
  class PlaidModule internal constructor(reactContext: ReactApplicationContext) :
@@ -131,6 +136,34 @@ class PlaidModule internal constructor(reactContext: ReactApplicationContext) :
131
136
  }
132
137
  }
133
138
 
139
+ @ReactMethod
140
+ override fun destroy(promise: Promise) {
141
+ val latch = CountDownLatch(1)
142
+
143
+ Handler(Looper.getMainLooper()).post {
144
+ try {
145
+ Plaid.destroy()
146
+ } catch (e: Exception) {
147
+ promise.reject("DESTROY_FAILED", "Failed to destroy Plaid", e)
148
+ latch.countDown()
149
+ return@post
150
+ }
151
+ latch.countDown()
152
+ }
153
+
154
+ try {
155
+ // Wait for main-thread work to finish (max 5 seconds)
156
+ if (!latch.await(5, TimeUnit.SECONDS)) {
157
+ promise.reject("TIMEOUT", "Timed out waiting for destroy() to complete.")
158
+ } else {
159
+ promise.resolve(null)
160
+ }
161
+ } catch (e: InterruptedException) {
162
+ promise.reject("INTERRUPTED", "Thread was interrupted", e)
163
+ }
164
+ }
165
+
166
+
134
167
  @ReactMethod
135
168
  @Suppress("unused")
136
169
  override fun startLinkActivityForResult(
@@ -12,9 +12,10 @@ package com.facebook.react.viewmanagers;
12
12
  import android.view.View;
13
13
  import androidx.annotation.Nullable;
14
14
  import com.facebook.react.uimanager.BaseViewManagerDelegate;
15
- import com.facebook.react.uimanager.BaseViewManagerInterface;
15
+ import com.facebook.react.uimanager.BaseViewManager;
16
+ import com.facebook.react.uimanager.LayoutShadowNode;
16
17
 
17
- public class PLKEmbeddedViewManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & PLKEmbeddedViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
18
+ public class PLKEmbeddedViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & PLKEmbeddedViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
18
19
  public PLKEmbeddedViewManagerDelegate(U viewManager) {
19
20
  super(viewManager);
20
21
  }
@@ -14,6 +14,7 @@ package com.plaid;
14
14
 
15
15
  import com.facebook.proguard.annotations.DoNotStrip;
16
16
  import com.facebook.react.bridge.Callback;
17
+ import com.facebook.react.bridge.Promise;
17
18
  import com.facebook.react.bridge.ReactApplicationContext;
18
19
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
19
20
  import com.facebook.react.bridge.ReactMethod;
@@ -40,6 +41,10 @@ public abstract class NativePlaidLinkModuleAndroidSpec extends ReactContextBaseJ
40
41
  @DoNotStrip
41
42
  public abstract void open(Callback onSuccess, Callback onExit);
42
43
 
44
+ @ReactMethod
45
+ @DoNotStrip
46
+ public abstract void destroy(Promise promise);
47
+
43
48
  @ReactMethod
44
49
  @DoNotStrip
45
50
  public abstract void startLinkActivityForResult(String token, boolean noLoadingState, String logLevel, Callback onSuccessCallback, Callback onExitCallback);
@@ -7,7 +7,14 @@ import { LinkEventListener, LinkOpenProps, LinkTokenConfiguration, FinanceKitErr
7
7
  */
8
8
  export declare const usePlaidEmitter: (linkEventListener: LinkEventListener) => void;
9
9
  export declare const create: (props: LinkTokenConfiguration) => void;
10
- export declare const open: (props: LinkOpenProps) => Promise<void>;
10
+ export declare const open: (props: LinkOpenProps) => void;
11
+ /**
12
+ * Clears any previously created Plaid session and associated resources
13
+ * that were captured during a prior call to create(). This method should
14
+ * be invoked before starting a new layer session with create() to ensure
15
+ * proper cleanup and avoid conflicts from lingering state or resources.
16
+ */
17
+ export declare const destroy: () => Promise<void>;
11
18
  export declare const dismissLink: () => void;
12
19
  export declare const submit: (data: SubmissionData) => void;
13
20
  /**
package/dist/PlaidLink.js CHANGED
@@ -41,7 +41,7 @@ export const create = (props) => {
41
41
  RNLinksdkiOS === null || RNLinksdkiOS === void 0 ? void 0 : RNLinksdkiOS.create(token, noLoadingState);
42
42
  }
43
43
  };
44
- export const open = (props) => __awaiter(void 0, void 0, void 0, function* () {
44
+ export const open = (props) => {
45
45
  if (Platform.OS === 'android') {
46
46
  RNLinksdkAndroid === null || RNLinksdkAndroid === void 0 ? void 0 : RNLinksdkAndroid.open((result) => {
47
47
  if (props.onSuccess != null) {
@@ -76,6 +76,17 @@ export const open = (props) => __awaiter(void 0, void 0, void 0, function* () {
76
76
  }
77
77
  });
78
78
  }
79
+ };
80
+ /**
81
+ * Clears any previously created Plaid session and associated resources
82
+ * that were captured during a prior call to create(). This method should
83
+ * be invoked before starting a new layer session with create() to ensure
84
+ * proper cleanup and avoid conflicts from lingering state or resources.
85
+ */
86
+ export const destroy = () => __awaiter(void 0, void 0, void 0, function* () {
87
+ if (Platform.OS === 'android') {
88
+ yield (RNLinksdkAndroid === null || RNLinksdkAndroid === void 0 ? void 0 : RNLinksdkAndroid.destroy());
89
+ }
79
90
  });
80
91
  export const dismissLink = () => {
81
92
  if (Platform.OS === 'ios') {
@@ -5,6 +5,7 @@ import { LinkSuccess, LinkExit } from '../Types';
5
5
  export interface Spec extends TurboModule {
6
6
  create(token: string, noLoadingState: boolean, logLevel: string): void;
7
7
  open(onSuccess: (result: UnsafeObject<LinkSuccess>) => void, onExit: (result: UnsafeObject<LinkExit>) => void): void;
8
+ destroy(): Promise<void>;
8
9
  startLinkActivityForResult(token: string, noLoadingState: boolean, logLevel: string, onSuccessCallback: (result: UnsafeObject<LinkSuccess>) => void, onExitCallback: (result: UnsafeObject<LinkExit>) => void): void;
9
10
  submit(phoneNumber: string | undefined): void;
10
11
  addListener(eventName: string): void;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { create, open, dismissLink, usePlaidEmitter, syncFinanceKit, submit } from './PlaidLink';
1
+ import { create, open, destroy, dismissLink, usePlaidEmitter, syncFinanceKit, submit } from './PlaidLink';
2
2
  export * from './Types';
3
- export { create, open, dismissLink, usePlaidEmitter, syncFinanceKit, submit, };
3
+ export { create, open, destroy, dismissLink, usePlaidEmitter, syncFinanceKit, submit, };
4
4
  export { EmbeddedLinkView } from './EmbeddedLink/EmbeddedLinkView';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // qwe clean this up...
2
- import { create, open, dismissLink, usePlaidEmitter, syncFinanceKit, submit, } from './PlaidLink';
2
+ import { create, open, destroy, dismissLink, usePlaidEmitter, syncFinanceKit, submit, } from './PlaidLink';
3
3
  export * from './Types';
4
- export { create, open, dismissLink, usePlaidEmitter, syncFinanceKit, submit, };
4
+ export { create, open, destroy, dismissLink, usePlaidEmitter, syncFinanceKit, submit, };
5
5
  // Components
6
6
  export { EmbeddedLinkView } from './EmbeddedLink/EmbeddedLinkView';
package/ios/RNLinksdk.mm CHANGED
@@ -28,7 +28,7 @@ static NSString* const kRNLinkKitVersionConstant = @"version";
28
28
  RCT_EXPORT_MODULE();
29
29
 
30
30
  + (NSString*)sdkVersion {
31
- return @"12.0.3"; // SDK_VERSION
31
+ return @"12.1.1"; // SDK_VERSION
32
32
  }
33
33
 
34
34
  + (NSString*)objCBridgeVersion {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-plaid-link-sdk",
3
- "version": "12.0.3",
3
+ "version": "12.1.1",
4
4
  "description": "React Native Plaid Link SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -35,5 +35,5 @@ Pod::Spec.new do |s|
35
35
  end
36
36
 
37
37
  s.dependency 'React-Core'
38
- s.dependency 'Plaid', '~> 6.0.4'
38
+ s.dependency 'Plaid', '~> 6.1.0'
39
39
  end
package/src/PlaidLink.tsx CHANGED
@@ -51,7 +51,7 @@ export const create = (props: LinkTokenConfiguration) => {
51
51
  }
52
52
  };
53
53
 
54
- export const open = async (props: LinkOpenProps) => {
54
+ export const open = (props: LinkOpenProps) => {
55
55
  if (Platform.OS === 'android') {
56
56
  RNLinksdkAndroid?.open(
57
57
  (result: LinkSuccess) => {
@@ -95,6 +95,18 @@ export const open = async (props: LinkOpenProps) => {
95
95
  }
96
96
  };
97
97
 
98
+ /**
99
+ * Clears any previously created Plaid session and associated resources
100
+ * that were captured during a prior call to create(). This method should
101
+ * be invoked before starting a new layer session with create() to ensure
102
+ * proper cleanup and avoid conflicts from lingering state or resources.
103
+ */
104
+ export const destroy = async () => {
105
+ if (Platform.OS === 'android') {
106
+ await RNLinksdkAndroid?.destroy();
107
+ }
108
+ };
109
+
98
110
  export const dismissLink = () => {
99
111
  if (Platform.OS === 'ios') {
100
112
  RNLinksdkiOS?.dismiss();
@@ -11,6 +11,7 @@ export interface Spec extends TurboModule {
11
11
  onSuccess: (result: UnsafeObject<LinkSuccess>) => void,
12
12
  onExit: (result: UnsafeObject<LinkExit>) => void,
13
13
  ): void;
14
+ destroy(): Promise<void>;
14
15
  startLinkActivityForResult(
15
16
  token: string,
16
17
  noLoadingState: boolean,
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  import {
3
3
  create,
4
4
  open,
5
+ destroy,
5
6
  dismissLink,
6
7
  usePlaidEmitter,
7
8
  syncFinanceKit,
@@ -12,6 +13,7 @@ export * from './Types';
12
13
  export {
13
14
  create,
14
15
  open,
16
+ destroy,
15
17
  dismissLink,
16
18
  usePlaidEmitter,
17
19
  syncFinanceKit,